{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "spending-limit",
  "title": "Spending Limit",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/spending-limit/SpendingLimit.tsx",
      "content": "import * as React from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport { Alert, AlertDescription } from '@/components/ui/alert'\nimport { Button } from '@/components/ui/button'\nimport { Text } from '@/components/ui/text'\nimport { useAnnouncement } from '@/lib/accessibility'\nimport { cn } from '@/lib/utils'\n\nconst defaultLabels = {\n  current: 'Current limit',\n  save: 'Save limit',\n  saving: 'Saving limit…',\n  saved: 'Limit saved.',\n  retry: 'Retry save',\n  discard: 'Discard changes',\n}\n\nexport interface SpendingLimitProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  /** The effective limit and its caller-localized representation. Amounts are nonnegative integer minor units. */\n  current: { minorUnits: number; display: string }\n  /** The caller's parsed edit. Null represents empty, incomplete, or invalid input. */\n  draft: number | null\n  /** Describes what the effective limit applies to. */\n  scope: string\n  /** Describes when or where a saved change takes effect. */\n  effectiveSummary: string\n  editor: (state: { disabled: boolean }) => React.ReactNode\n  onSave: (minorUnits: number) => void\n  onDiscard?: () => void\n  saving?: boolean\n  disabled?: boolean\n  unavailableReason?: string\n  /** Validation blocks saving while a failed request remains retryable. */\n  validationError?: string\n  saveError?: string\n  labels?: Partial<typeof defaultLabels>\n}\n\nexport function SpendingLimit({\n  className,\n  current,\n  draft,\n  scope,\n  effectiveSummary,\n  editor,\n  onSave,\n  onDiscard,\n  saving = false,\n  disabled = false,\n  unavailableReason,\n  validationError,\n  saveError,\n  labels,\n  ...props\n}: SpendingLimitProps) {\n  const copy = { ...defaultLabels, ...labels }\n  const changed = draft !== current.minorUnits\n  const blocked = disabled || saving || !!unavailableReason\n  const canSave = !blocked && changed && draft !== null && Number.isSafeInteger(draft) && draft >= 0 && !validationError\n  const [submitted, setSubmitted] = React.useState<number>()\n  const saved = !saveError && submitted !== undefined && submitted === current.minorUnits\n  const action = saving ? copy.saving : saveError ? copy.retry : copy.save\n  useAnnouncement(saving ? copy.saving : saveError || (saved && !changed ? copy.saved : undefined))\n\n  return (\n    <View {...props} className={cn('gap-4', className)}>\n      <View className=\"gap-1 rounded-xl bg-muted px-4 py-4\">\n        <Text size=\"sm\" variant=\"muted\">\n          {copy.current}\n        </Text>\n        <Text size=\"title\" accessibilityRole=\"header\" style={{ fontVariant: ['tabular-nums'] }}>\n          {current.display}\n        </Text>\n        <Text size=\"sm\">{scope}</Text>\n      </View>\n      {editor({ disabled: blocked })}\n      <Text size=\"sm\" variant=\"muted\">\n        {effectiveSummary}\n      </Text>\n      {unavailableReason ? <Text size=\"sm\">{unavailableReason}</Text> : null}\n      {!saving && (validationError || saveError) ? (\n        <Alert variant=\"destructive\">\n          <AlertDescription>{validationError || saveError}</AlertDescription>\n        </Alert>\n      ) : null}\n      {saved && !changed && !saving ? (\n        <Text size=\"sm\" className=\"font-medium\">\n          {copy.saved}\n        </Text>\n      ) : null}\n      <Button\n        accessibilityLabel={action}\n        disabled={!saving && !canSave}\n        loading={saving}\n        onPress={() => {\n          if (!canSave) return\n          setSubmitted(draft)\n          onSave(draft)\n        }}\n      >\n        {action}\n      </Button>\n      {changed && onDiscard ? (\n        <Button\n          variant=\"ghost\"\n          accessibilityLabel={copy.discard}\n          disabled={blocked}\n          onPress={() => {\n            if (blocked) return\n            setSubmitted(undefined)\n            onDiscard()\n          }}\n        >\n          {copy.discard}\n        </Button>\n      ) : null}\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/spending-limit/SpendingLimit.tsx"
    },
    {
      "path": "packages/registry-native/blocks/spending-limit/index.ts",
      "content": "export { SpendingLimit, type SpendingLimitProps } from './SpendingLimit'\n",
      "type": "registry:block",
      "target": "~/components/blocks/spending-limit/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/accessibility.json",
    "https://native.uipkge.dev/r/native/alert.json",
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/text.json"
  ],
  "description": "An editable spending limit with effective scope, draft validation, and a recoverable save action.",
  "categories": [
    "finance",
    "settings"
  ]
}