{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "route-stop-editor",
  "title": "Route Stop Editor",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/route-stop-editor/RouteStopEditor.tsx",
      "content": "import { Fragment, useState } from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport { Button } from '@/components/ui/button'\nimport { Separator } from '@/components/ui/separator'\nimport { Text } from '@/components/ui/text'\nimport { useAnnouncement } from '@/lib/accessibility'\nimport { cn } from '@/lib/utils'\n\nexport interface RouteStop {\n  id: string\n  label: string\n  detail?: string\n}\n\ninterface RouteStopEditorLabels {\n  start: string\n  finish: string\n  stop: (position: number) => string\n  moveUp: string\n  moveDown: string\n  remove: string\n  add: string\n  limit: (maximum: number) => string\n  moved: (name: string, position: number) => string\n  removed: (name: string) => string\n}\n\nexport interface RouteStopEditorProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  title?: string\n  start: string\n  finish: string\n  /** Only intermediate stops. IDs must be unique and nonempty. */\n  stops?: readonly RouteStop[]\n  /** Maximum intermediate stops that can be added. Existing stops can still be removed. */\n  maxStops?: number\n  onValueChange: (stops: RouteStop[]) => void\n  onAdd?: () => void\n  labels?: Partial<RouteStopEditorLabels>\n}\n\ninterface RequestedChange {\n  id: string\n  index: number\n  announcement: string\n}\n\nexport function RouteStopEditor({\n  className,\n  title = 'Route stops',\n  start,\n  finish,\n  stops = [],\n  maxStops = 4,\n  onValueChange,\n  onAdd,\n  labels,\n  ...props\n}: RouteStopEditorProps) {\n  const [requested, setRequested] = useState<RequestedChange>()\n  const limit = Number.isSafeInteger(maxStops) ? Math.max(0, maxStops) : 4\n  const canAdd = stops.length < limit\n  const moveUp = labels?.moveUp ?? 'Move up'\n  const moveDown = labels?.moveDown ?? 'Move down'\n  const removeLabel = labels?.remove ?? 'Remove'\n  const add = labels?.add ?? 'Add stop'\n  useAnnouncement(\n    requested && stops.findIndex(({ id }) => id === requested.id) === requested.index\n      ? requested.announcement\n      : undefined,\n  )\n\n  function move(index: number, offset: -1 | 1) {\n    const target = index + offset\n    const stop = stops[index]\n    if (!stop || target < 0 || target >= stops.length) return\n    const next = [...stops]\n    next[index] = stops[target]\n    next[target] = stop\n    onValueChange(next)\n    setRequested({\n      id: stop.id,\n      index: target,\n      announcement: labels?.moved?.(stop.label, target + 1) ?? `${stop.label} moved to stop ${target + 1}.`,\n    })\n  }\n\n  function remove(stop: RouteStop) {\n    onValueChange(stops.filter(({ id }) => id !== stop.id))\n    setRequested({\n      id: stop.id,\n      index: -1,\n      announcement: labels?.removed?.(stop.label) ?? `${stop.label} removed.`,\n    })\n  }\n\n  return (\n    <View {...props} className={cn('gap-[16px]', className)}>\n      <Text size=\"title\" accessibilityRole=\"header\">\n        {title}\n      </Text>\n      <View className=\"overflow-hidden rounded-lg border border-border bg-card\">\n        <View className=\"gap-[4px] px-[16px] py-[12px]\">\n          <Text size=\"sm\" variant=\"muted\">\n            {labels?.start ?? 'Start'}\n          </Text>\n          <Text className=\"font-semibold text-card-foreground\">{start}</Text>\n        </View>\n        {stops.map((stop, index) => (\n          <Fragment key={stop.id}>\n            <Separator />\n            <View className=\"gap-[8px] px-[16px] py-[12px]\">\n              <View className=\"gap-[4px]\">\n                <Text size=\"sm\" variant=\"muted\">\n                  {labels?.stop?.(index + 1) ?? `Stop ${index + 1}`}\n                </Text>\n                <Text className=\"font-semibold text-card-foreground\">{stop.label}</Text>\n                {stop.detail ? (\n                  <Text size=\"sm\" variant=\"muted\">\n                    {stop.detail}\n                  </Text>\n                ) : null}\n              </View>\n              <View className=\"flex-row flex-wrap gap-[4px]\">\n                <Button\n                  size=\"sm\"\n                  variant=\"ghost\"\n                  disabled={index === 0}\n                  accessibilityLabel={`${moveUp}, ${stop.label}`}\n                  onPress={() => move(index, -1)}\n                >\n                  {moveUp}\n                </Button>\n                <Button\n                  size=\"sm\"\n                  variant=\"ghost\"\n                  disabled={index === stops.length - 1}\n                  accessibilityLabel={`${moveDown}, ${stop.label}`}\n                  onPress={() => move(index, 1)}\n                >\n                  {moveDown}\n                </Button>\n                <Button\n                  size=\"sm\"\n                  variant=\"ghost\"\n                  textClassName=\"text-destructive\"\n                  accessibilityLabel={`${removeLabel}, ${stop.label}`}\n                  onPress={() => remove(stop)}\n                >\n                  {removeLabel}\n                </Button>\n              </View>\n            </View>\n          </Fragment>\n        ))}\n        {onAdd ? (\n          <>\n            <Separator />\n            <View className=\"gap-[8px] px-[16px] py-[12px]\">\n              <Button\n                variant=\"outline\"\n                accessibilityLabel={add}\n                disabled={!canAdd}\n                onPress={() => {\n                  if (canAdd) onAdd()\n                }}\n              >\n                {add}\n              </Button>\n              {!canAdd ? (\n                <Text size=\"sm\" variant=\"muted\">\n                  {labels?.limit?.(limit) ?? `Maximum intermediate stops: ${limit}`}\n                </Text>\n              ) : null}\n            </View>\n          </>\n        ) : null}\n        <Separator />\n        <View className=\"gap-[4px] px-[16px] py-[12px]\">\n          <Text size=\"sm\" variant=\"muted\">\n            {labels?.finish ?? 'Final stop'}\n          </Text>\n          <Text className=\"font-semibold text-card-foreground\">{finish}</Text>\n        </View>\n      </View>\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/route-stop-editor/RouteStopEditor.tsx"
    },
    {
      "path": "packages/registry-native/blocks/route-stop-editor/index.ts",
      "content": "export { RouteStopEditor, type RouteStop, type RouteStopEditorProps } from './RouteStopEditor'\n",
      "type": "registry:block",
      "target": "~/components/blocks/route-stop-editor/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/accessibility.json",
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/separator.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Fixed route endpoints and caller-owned intermediate stops with accessible move, remove, and add controls.",
  "categories": [
    "travel",
    "logistics"
  ]
}