@skybin-tech/nebula-ui 0.0.29 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -1
  2. package/dist/cjs/components/Accordion/Accordion.cjs.map +1 -1
  3. package/dist/cjs/components/Alert/Alert.cjs.map +1 -1
  4. package/dist/cjs/components/Avatar/Avatar.cjs.map +1 -1
  5. package/dist/cjs/components/Button/Button.cjs.map +1 -1
  6. package/dist/cjs/components/Card/Card.cjs.map +1 -1
  7. package/dist/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
  8. package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
  9. package/dist/cjs/components/Form/Checkbox.cjs.map +1 -1
  10. package/dist/cjs/components/Form/Combobox.cjs.map +1 -1
  11. package/dist/cjs/components/Form/CountryPicker.cjs.map +1 -1
  12. package/dist/cjs/components/Form/CountrySelect.cjs.map +1 -1
  13. package/dist/cjs/components/Form/DatePicker.cjs.map +1 -1
  14. package/dist/cjs/components/Form/FieldLayout.cjs.map +1 -1
  15. package/dist/cjs/components/Form/Form.cjs +9 -8
  16. package/dist/cjs/components/Form/Form.cjs.map +1 -1
  17. package/dist/cjs/components/Form/FormSwitch.cjs.map +1 -1
  18. package/dist/cjs/components/Form/PhoneInput.cjs.map +1 -1
  19. package/dist/cjs/components/Form/Radio.cjs.map +1 -1
  20. package/dist/cjs/components/Form/Select.cjs.map +1 -1
  21. package/dist/cjs/components/Form/TextArea.cjs.map +1 -1
  22. package/dist/cjs/components/Form/TextBox.cjs.map +1 -1
  23. package/dist/cjs/components/Form/context.cjs.map +1 -1
  24. package/dist/cjs/components/Form/hooks.cjs.map +1 -1
  25. package/dist/cjs/components/Form/variants.cjs.map +1 -1
  26. package/dist/cjs/components/Input/Input.cjs.map +1 -1
  27. package/dist/cjs/components/Label/Label.cjs.map +1 -1
  28. package/dist/cjs/components/Pagination/Pagination.cjs.map +1 -1
  29. package/dist/cjs/components/Separator/Separator.cjs.map +1 -1
  30. package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
  31. package/dist/cjs/components/Tabs/Tabs.cjs.map +1 -1
  32. package/dist/cjs/components/Textarea/Textarea.cjs.map +1 -1
  33. package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
  34. package/dist/cjs/hooks/useDebounce.cjs.map +1 -1
  35. package/dist/cjs/hooks/useToggle.cjs.map +1 -1
  36. package/dist/cjs/primitives/accordion.cjs.map +1 -1
  37. package/dist/cjs/primitives/alert.cjs.map +1 -1
  38. package/dist/cjs/primitives/badge.cjs.map +1 -1
  39. package/dist/cjs/primitives/breadcrumb.cjs.map +1 -1
  40. package/dist/cjs/primitives/button.cjs.map +1 -1
  41. package/dist/cjs/primitives/checkbox.cjs.map +1 -1
  42. package/dist/cjs/primitives/command.cjs.map +1 -1
  43. package/dist/cjs/primitives/dialog.cjs.map +1 -1
  44. package/dist/cjs/primitives/dropdown-menu.cjs.map +1 -1
  45. package/dist/cjs/primitives/input-otp.cjs.map +1 -1
  46. package/dist/cjs/primitives/label.cjs.map +1 -1
  47. package/dist/cjs/primitives/progress.cjs.map +1 -1
  48. package/dist/cjs/primitives/radio-group.cjs.map +1 -1
  49. package/dist/cjs/primitives/scroll-area.cjs.map +1 -1
  50. package/dist/cjs/primitives/select.cjs.map +1 -1
  51. package/dist/cjs/primitives/sheet.cjs.map +1 -1
  52. package/dist/cjs/primitives/slider.cjs.map +1 -1
  53. package/dist/cjs/primitives/switch.cjs.map +1 -1
  54. package/dist/cjs/primitives/table.cjs.map +1 -1
  55. package/dist/cjs/primitives/toast.cjs.map +1 -1
  56. package/dist/cjs/primitives/toggle.cjs.map +1 -1
  57. package/dist/cjs/utils/cn.cjs.map +1 -1
  58. package/dist/components/Button/Button.js.map +1 -1
  59. package/dist/components/Form/Checkbox.js.map +1 -1
  60. package/dist/components/Form/Combobox.js.map +1 -1
  61. package/dist/components/Form/CountryPicker.js.map +1 -1
  62. package/dist/components/Form/CountrySelect.js.map +1 -1
  63. package/dist/components/Form/DatePicker.js.map +1 -1
  64. package/dist/components/Form/FieldLayout.js.map +1 -1
  65. package/dist/components/Form/Form.js +9 -8
  66. package/dist/components/Form/Form.js.map +1 -1
  67. package/dist/components/Form/FormSwitch.js.map +1 -1
  68. package/dist/components/Form/PhoneInput.js.map +1 -1
  69. package/dist/components/Form/Radio.js.map +1 -1
  70. package/dist/components/Form/Select.js.map +1 -1
  71. package/dist/components/Form/TextArea.js.map +1 -1
  72. package/dist/components/Form/TextBox.js.map +1 -1
  73. package/dist/components/Pagination/Pagination.js.map +1 -1
  74. package/dist/primitives/accordion.js.map +1 -1
  75. package/dist/primitives/breadcrumb.js.map +1 -1
  76. package/dist/primitives/checkbox.js.map +1 -1
  77. package/dist/primitives/command.js.map +1 -1
  78. package/dist/primitives/dialog.js.map +1 -1
  79. package/dist/primitives/dropdown-menu.js.map +1 -1
  80. package/dist/primitives/input-otp.js.map +1 -1
  81. package/dist/primitives/progress.js.map +1 -1
  82. package/dist/primitives/radio-group.js.map +1 -1
  83. package/dist/primitives/scroll-area.js.map +1 -1
  84. package/dist/primitives/select.js.map +1 -1
  85. package/dist/primitives/sheet.js.map +1 -1
  86. package/dist/primitives/slider.js.map +1 -1
  87. package/dist/primitives/switch.js.map +1 -1
  88. package/dist/primitives/table.js.map +1 -1
  89. package/dist/primitives/toast.js.map +1 -1
  90. package/package.json +22 -22
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.cjs","names":[],"sources":["../../../../src/components/Form/PhoneInput.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useContext, useEffect, useId, useMemo, useState } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type Control, type FieldPath, type FieldValues } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport {\r\n formatE164,\r\n getCountryDialCode,\r\n parseE164,\r\n} from \"../../data/countries\";\r\nimport { TextBoxPrimitive } from \"../../primitives/textbox\";\r\nimport { FormConfigContext, type FieldValidationRules, type FormConfig } from \"./context\";\r\nimport { FieldLayout } from \"./FieldLayout\";\r\nimport { CountryPicker } from \"./CountryPicker\";\r\n\r\nconst phoneInputVariants = cva(\"\", {\r\n variants: {\r\n size: {\r\n sm: \"h-8 text-xs\",\r\n md: \"h-10 text-sm\",\r\n lg: \"h-12 text-base\",\r\n },\r\n variant: {\r\n default: \"border-input focus-within:ring-ring\",\r\n error: \"border-destructive focus-within:ring-destructive\",\r\n success: \"border-green-500 focus-within:ring-green-500\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n variant: \"default\",\r\n },\r\n});\r\n\r\ntype ValidationRule<T> = T | { value: T; message: string };\r\n\r\nexport interface PhoneInputProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends VariantProps<typeof phoneInputVariants> {\r\n name: TName;\r\n label?: string;\r\n helperText?: string;\r\n showError?: boolean;\r\n error?: string;\r\n fullWidth?: boolean;\r\n placeholder?: string;\r\n disabled?: boolean;\r\n className?: string;\r\n id?: string;\r\n control?: Control<TFieldValues>;\r\n defaultCountry?: string;\r\n priorityCountries?: string[];\r\n /** Field is required (`true` or custom error message string) */\r\n required?: boolean | string;\r\n /** Minimum national number length */\r\n minLength?: ValidationRule<number>;\r\n /** Maximum national number length */\r\n maxLength?: ValidationRule<number>;\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\nfunction getValidationRuleValue<T>(\r\n rule: ValidationRule<T> | undefined,\r\n defaultMessage: string\r\n): { value: T; message: string } | null {\r\n if (rule === undefined) {\r\n return null;\r\n }\r\n\r\n if (typeof rule === \"object\" && rule !== null && \"value\" in rule) {\r\n return rule as { value: T; message: string };\r\n }\r\n\r\n return { value: rule as T, message: defaultMessage };\r\n}\r\n\r\nfunction buildPhoneValidate(\r\n required: boolean | string | undefined,\r\n minLength: ValidationRule<number> | undefined,\r\n maxLength: ValidationRule<number> | undefined,\r\n validate: PhoneInputProps[\"validate\"]\r\n) {\r\n const requiredMessage =\r\n typeof required === \"string\" ? required : \"This field is required\";\r\n\r\n return async (value: unknown) => {\r\n const parsed = parseE164(String(value ?? \"\"));\r\n const nationalNumber = parsed?.nationalNumber ?? \"\";\r\n\r\n if (required !== undefined && !nationalNumber) {\r\n return requiredMessage;\r\n }\r\n\r\n const minLengthRule = getValidationRuleValue(\r\n minLength,\r\n `Minimum ${typeof minLength === \"number\" ? minLength : minLength?.value} digits required`\r\n );\r\n if (minLengthRule && nationalNumber.length < minLengthRule.value) {\r\n return minLengthRule.message;\r\n }\r\n\r\n const maxLengthRule = getValidationRuleValue(\r\n maxLength,\r\n `Maximum ${typeof maxLength === \"number\" ? maxLength : maxLength?.value} digits allowed`\r\n );\r\n if (maxLengthRule && nationalNumber.length > maxLengthRule.value) {\r\n return maxLengthRule.message;\r\n }\r\n\r\n if (validate) {\r\n return validate(value);\r\n }\r\n\r\n return true;\r\n };\r\n}\r\n\r\nexport function PhoneInput<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>({\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n fullWidth = true,\r\n placeholder = \"Mobile number\",\r\n disabled,\r\n className,\r\n id: providedId,\r\n control: externalControl,\r\n defaultCountry = \"IN\",\r\n priorityCountries,\r\n required,\r\n minLength,\r\n maxLength,\r\n validate,\r\n}: PhoneInputProps<TFieldValues, TName>) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n const registerFieldValidation = formConfigContext?.registerFieldValidation;\r\n const unregisterFieldValidation = formConfigContext?.unregisterFieldValidation;\r\n\r\n useEffect(() => {\r\n if (registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n if (required !== undefined) rules.required = required;\r\n\r\n if (\r\n required !== undefined ||\r\n minLength !== undefined ||\r\n maxLength !== undefined ||\r\n validate !== undefined\r\n ) {\r\n rules.validate = buildPhoneValidate(required, minLength, maxLength, validate);\r\n }\r\n\r\n registerFieldValidation({\r\n name: name as string,\r\n type: \"string\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n unregisterFieldValidation?.(name as string);\r\n };\r\n }\r\n }, [\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n name,\r\n required,\r\n minLength,\r\n maxLength,\r\n validate,\r\n ]);\r\n\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const parsedValue = useMemo(() => parseE164(field.value ?? \"\"), [field.value]);\r\n const [countryCode, setCountryCode] = useState(\r\n parsedValue?.countryCode ?? defaultCountry\r\n );\r\n const [nationalNumber, setNationalNumber] = useState(parsedValue?.nationalNumber ?? \"\");\r\n\r\n useEffect(() => {\r\n const parsed = parseE164(field.value ?? \"\");\r\n if (parsed) {\r\n setCountryCode(parsed.countryCode);\r\n setNationalNumber(parsed.nationalNumber);\r\n return;\r\n }\r\n\r\n if (!field.value) {\r\n setCountryCode(defaultCountry);\r\n setNationalNumber(\"\");\r\n }\r\n }, [field.value, defaultCountry]);\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n const dialCode = getCountryDialCode(countryCode);\r\n\r\n const updateValue = (nextCountryCode: string, nextNationalNumber: string) => {\r\n setCountryCode(nextCountryCode);\r\n setNationalNumber(nextNationalNumber);\r\n field.onChange(formatE164(nextCountryCode, nextNationalNumber));\r\n };\r\n\r\n return (\r\n <FieldLayout\r\n inputId={inputId}\r\n label={label}\r\n required={!!required}\r\n helperText={helperText}\r\n errorMessage={showError ? errorMessage : undefined}\r\n showError={showError}\r\n fullWidth={fullWidth}\r\n formConfig={formConfig}\r\n >\r\n <div\r\n className={cn(\r\n \"flex items-stretch overflow-hidden rounded-md border bg-background focus-within:ring-2 focus-within:ring-offset-2\",\r\n phoneInputVariants({ size: effectiveSize, variant: effectiveVariant }),\r\n className\r\n )}\r\n >\r\n <CountryPicker\r\n compact\r\n value={countryCode}\r\n onValueChange={(value) => updateValue(value, nationalNumber)}\r\n disabled={effectiveDisabled}\r\n priorityCountries={priorityCountries}\r\n required={!!required}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n />\r\n\r\n <div className=\"flex items-center border-l px-3 text-sm text-muted-foreground\">\r\n {dialCode}\r\n </div>\r\n\r\n <TextBoxPrimitive\r\n id={inputId}\r\n type=\"tel\"\r\n inputMode=\"numeric\"\r\n autoComplete=\"tel-national\"\r\n value={nationalNumber}\r\n onChange={(event) => {\r\n const digits = event.target.value.replace(/\\D/g, \"\");\r\n updateValue(countryCode, digits);\r\n }}\r\n placeholder={placeholder}\r\n disabled={effectiveDisabled}\r\n aria-required={!!required}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n \"h-full min-w-0 flex-1 border-0 bg-transparent px-3 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0\"\r\n )}\r\n />\r\n </div>\r\n </FieldLayout>\r\n );\r\n}\r\n\r\nPhoneInput.displayName = \"PhoneInput\";\r\n"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,sBAAA,GAAA,yBAAA,IAAA,CAAyB,IAAI;CACjC,UAAU;EACR,MAAM;GACJ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AA;GACE;;CACM,CAAA;AAEjB;AAEA,WAAW,cAAc"}
1
+ {"version":3,"file":"PhoneInput.cjs","names":[],"sources":["../../../../src/components/Form/PhoneInput.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useContext, useEffect, useId, useMemo, useState } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type Control, type FieldPath, type FieldValues } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport {\r\n formatE164,\r\n getCountryDialCode,\r\n parseE164,\r\n} from \"../../data/countries\";\r\nimport { TextBoxPrimitive } from \"../../primitives/textbox\";\r\nimport { FormConfigContext, type FieldValidationRules, type FormConfig } from \"./context\";\r\nimport { FieldLayout } from \"./FieldLayout\";\r\nimport { CountryPicker } from \"./CountryPicker\";\r\n\r\nconst phoneInputVariants = cva(\"\", {\r\n variants: {\r\n size: {\r\n sm: \"h-8 text-xs\",\r\n md: \"h-10 text-sm\",\r\n lg: \"h-12 text-base\",\r\n },\r\n variant: {\r\n default: \"border-input focus-within:ring-ring\",\r\n error: \"border-destructive focus-within:ring-destructive\",\r\n success: \"border-green-500 focus-within:ring-green-500\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n variant: \"default\",\r\n },\r\n});\r\n\r\ntype ValidationRule<T> = T | { value: T; message: string };\r\n\r\nexport interface PhoneInputProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends VariantProps<typeof phoneInputVariants> {\r\n name: TName;\r\n label?: string;\r\n helperText?: string;\r\n showError?: boolean;\r\n error?: string;\r\n fullWidth?: boolean;\r\n placeholder?: string;\r\n disabled?: boolean;\r\n className?: string;\r\n id?: string;\r\n control?: Control<TFieldValues>;\r\n defaultCountry?: string;\r\n priorityCountries?: string[];\r\n /** Field is required (`true` or custom error message string) */\r\n required?: boolean | string;\r\n /** Minimum national number length */\r\n minLength?: ValidationRule<number>;\r\n /** Maximum national number length */\r\n maxLength?: ValidationRule<number>;\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\nfunction getValidationRuleValue<T>(\r\n rule: ValidationRule<T> | undefined,\r\n defaultMessage: string\r\n): { value: T; message: string } | null {\r\n if (rule === undefined) {\r\n return null;\r\n }\r\n\r\n if (typeof rule === \"object\" && rule !== null && \"value\" in rule) {\r\n return rule as { value: T; message: string };\r\n }\r\n\r\n return { value: rule as T, message: defaultMessage };\r\n}\r\n\r\nfunction buildPhoneValidate(\r\n required: boolean | string | undefined,\r\n minLength: ValidationRule<number> | undefined,\r\n maxLength: ValidationRule<number> | undefined,\r\n validate: PhoneInputProps[\"validate\"]\r\n) {\r\n const requiredMessage =\r\n typeof required === \"string\" ? required : \"This field is required\";\r\n\r\n return async (value: unknown) => {\r\n const parsed = parseE164(String(value ?? \"\"));\r\n const nationalNumber = parsed?.nationalNumber ?? \"\";\r\n\r\n if (required !== undefined && !nationalNumber) {\r\n return requiredMessage;\r\n }\r\n\r\n const minLengthRule = getValidationRuleValue(\r\n minLength,\r\n `Minimum ${typeof minLength === \"number\" ? minLength : minLength?.value} digits required`\r\n );\r\n if (minLengthRule && nationalNumber.length < minLengthRule.value) {\r\n return minLengthRule.message;\r\n }\r\n\r\n const maxLengthRule = getValidationRuleValue(\r\n maxLength,\r\n `Maximum ${typeof maxLength === \"number\" ? maxLength : maxLength?.value} digits allowed`\r\n );\r\n if (maxLengthRule && nationalNumber.length > maxLengthRule.value) {\r\n return maxLengthRule.message;\r\n }\r\n\r\n if (validate) {\r\n return validate(value);\r\n }\r\n\r\n return true;\r\n };\r\n}\r\n\r\nexport function PhoneInput<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>({\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n fullWidth = true,\r\n placeholder = \"Mobile number\",\r\n disabled,\r\n className,\r\n id: providedId,\r\n control: externalControl,\r\n defaultCountry = \"IN\",\r\n priorityCountries,\r\n required,\r\n minLength,\r\n maxLength,\r\n validate,\r\n}: PhoneInputProps<TFieldValues, TName>) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n const registerFieldValidation = formConfigContext?.registerFieldValidation;\r\n const unregisterFieldValidation = formConfigContext?.unregisterFieldValidation;\r\n\r\n useEffect(() => {\r\n if (registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n if (required !== undefined) rules.required = required;\r\n\r\n if (\r\n required !== undefined ||\r\n minLength !== undefined ||\r\n maxLength !== undefined ||\r\n validate !== undefined\r\n ) {\r\n rules.validate = buildPhoneValidate(required, minLength, maxLength, validate);\r\n }\r\n\r\n registerFieldValidation({\r\n name: name as string,\r\n type: \"string\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n unregisterFieldValidation?.(name as string);\r\n };\r\n }\r\n }, [\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n name,\r\n required,\r\n minLength,\r\n maxLength,\r\n validate,\r\n ]);\r\n\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const parsedValue = useMemo(() => parseE164(field.value ?? \"\"), [field.value]);\r\n const [countryCode, setCountryCode] = useState(\r\n parsedValue?.countryCode ?? defaultCountry\r\n );\r\n const [nationalNumber, setNationalNumber] = useState(parsedValue?.nationalNumber ?? \"\");\r\n\r\n useEffect(() => {\r\n const parsed = parseE164(field.value ?? \"\");\r\n if (parsed) {\r\n setCountryCode(parsed.countryCode);\r\n setNationalNumber(parsed.nationalNumber);\r\n return;\r\n }\r\n\r\n if (!field.value) {\r\n setCountryCode(defaultCountry);\r\n setNationalNumber(\"\");\r\n }\r\n }, [field.value, defaultCountry]);\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n const dialCode = getCountryDialCode(countryCode);\r\n\r\n const updateValue = (nextCountryCode: string, nextNationalNumber: string) => {\r\n setCountryCode(nextCountryCode);\r\n setNationalNumber(nextNationalNumber);\r\n field.onChange(formatE164(nextCountryCode, nextNationalNumber));\r\n };\r\n\r\n return (\r\n <FieldLayout\r\n inputId={inputId}\r\n label={label}\r\n required={!!required}\r\n helperText={helperText}\r\n errorMessage={showError ? errorMessage : undefined}\r\n showError={showError}\r\n fullWidth={fullWidth}\r\n formConfig={formConfig}\r\n >\r\n <div\r\n className={cn(\r\n \"flex items-stretch overflow-hidden rounded-md border bg-background focus-within:ring-2 focus-within:ring-offset-2\",\r\n phoneInputVariants({ size: effectiveSize, variant: effectiveVariant }),\r\n className\r\n )}\r\n >\r\n <CountryPicker\r\n compact\r\n value={countryCode}\r\n onValueChange={(value) => updateValue(value, nationalNumber)}\r\n disabled={effectiveDisabled}\r\n priorityCountries={priorityCountries}\r\n required={!!required}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n />\r\n\r\n <div className=\"flex items-center border-l px-3 text-sm text-muted-foreground\">\r\n {dialCode}\r\n </div>\r\n\r\n <TextBoxPrimitive\r\n id={inputId}\r\n type=\"tel\"\r\n inputMode=\"numeric\"\r\n autoComplete=\"tel-national\"\r\n value={nationalNumber}\r\n onChange={(event) => {\r\n const digits = event.target.value.replace(/\\D/g, \"\");\r\n updateValue(countryCode, digits);\r\n }}\r\n placeholder={placeholder}\r\n disabled={effectiveDisabled}\r\n aria-required={!!required}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n \"h-full min-w-0 flex-1 border-0 bg-transparent px-3 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0\"\r\n )}\r\n />\r\n </div>\r\n </FieldLayout>\r\n );\r\n}\r\n\r\nPhoneInput.displayName = \"PhoneInput\";\r\n"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,sBAAA,GAAqB,yBAAA,IAAA,CAAI,IAAI;CACjC,UAAU;EACR,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EACA,SAAS;GACP,SAAS;GACT,OAAO;GACP,SAAS;EACX;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CAAC;AA8BD,SAAS,uBACP,MACA,gBACsC;CACtC,IAAI,SAAS,KAAA,GACX,OAAO;CAGT,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,WAAW,MAC1D,OAAO;CAGT,OAAO;EAAE,OAAO;EAAW,SAAS;CAAe;AACrD;AAEA,SAAS,mBACP,UACA,WACA,WACA,UACA;CACA,MAAM,kBACJ,OAAO,aAAa,WAAW,WAAW;CAE5C,OAAO,OAAO,UAAmB;EAE/B,MAAM,iBADS,kBAAA,UAAU,OAAO,SAAS,EAAE,CACpB,CAAA,EAAQ,kBAAkB;EAEjD,IAAI,aAAa,KAAA,KAAa,CAAC,gBAC7B,OAAO;EAGT,MAAM,gBAAgB,uBACpB,WACA,WAAW,OAAO,cAAc,WAAW,YAAY,WAAW,MAAM,iBAC1E;EACA,IAAI,iBAAiB,eAAe,SAAS,cAAc,OACzD,OAAO,cAAc;EAGvB,MAAM,gBAAgB,uBACpB,WACA,WAAW,OAAO,cAAc,WAAW,YAAY,WAAW,MAAM,gBAC1E;EACA,IAAI,iBAAiB,eAAe,SAAS,cAAc,OACzD,OAAO,cAAc;EAGvB,IAAI,UACF,OAAO,SAAS,KAAK;EAGvB,OAAO;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E,CAAA;IAEL,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAA,kBAAD;KACE,IAAI;KACJ,MAAK;KACL,WAAU;KACV,cAAa;KACb,OAAO;KACP,WAAW,UAAU;MACnB,MAAM,SAAS,MAAM,OAAO,MAAM,QAAQ,OAAO,EAAE;MACnD,YAAY,aAAa,MAAM;KACjC;KACa;KACb,UAAU;KACV,iBAAe,CAAC,CAAC;KACjB,gBAAc;KACd,oBACE,WACI,GAAG,QAAQ,UACX,aACE,GAAG,QAAQ,WACX,KAAA;KAER,WAAW,WAAA,GACT,iHACF;IACD,CAAA;GACE;;CACM,CAAA;AAEjB;AAEA,WAAW,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.cjs","names":[],"sources":["../../../../src/components/Form/Radio.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { forwardRef, useId, useContext, createContext, useEffect } from \"react\";\r\nimport type { ReactNode, ComponentPropsWithoutRef } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { RadioGroup as ShadcnRadioGroup, RadioGroupItem as ShadcnRadioGroupItem } from \"../../primitives/radio-group\";\r\nimport { Label } from \"../../primitives/label\";\r\nimport type * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\r\n\r\nconst radioSizeVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"h-4 w-4\",\r\n md: \"h-5 w-5\",\r\n lg: \"h-6 w-6\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n }\r\n);\r\n\r\nconst labelVariants = cva(\r\n \"text-sm font-medium cursor-pointer select-none\",\r\n {\r\n variants: {\r\n disabled: {\r\n true: \"cursor-not-allowed opacity-50\",\r\n false: \"\",\r\n },\r\n },\r\n defaultVariants: {\r\n disabled: false,\r\n },\r\n }\r\n);\r\n\r\n// Radio Group Context\r\ninterface RadioGroupContextValue {\r\n name: string;\r\n value: string | number | undefined;\r\n onChange: (value: string | number) => void;\r\n disabled?: boolean;\r\n size?: \"sm\" | \"md\" | \"lg\";\r\n}\r\n\r\nconst RadioGroupContext = createContext<RadioGroupContextValue | null>(null);\r\n\r\nexport interface RadioOption {\r\n label: ReactNode;\r\n value: string | number;\r\n disabled?: boolean;\r\n}\r\n\r\nexport interface RadioGroupProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends VariantProps<typeof radioSizeVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the radio group */\r\n label?: string;\r\n /** Helper text displayed below the radio group */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** Options for the radio group */\r\n options?: RadioOption[];\r\n /** Layout direction */\r\n direction?: \"horizontal\" | \"vertical\";\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n /** Children (alternative to options prop) */\r\n children?: ReactNode;\r\n /** Disabled state */\r\n disabled?: boolean;\r\n /** Additional class name */\r\n className?: string;\r\n /** Variant style */\r\n variant?: \"default\" | \"error\";\r\n \r\n // Validation props\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * RadioGroup component with form integration\r\n * \r\n * This is a wrapper around the shadcn/ui RadioGroup primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component\r\n * <RadioGroup \r\n * name=\"gender\" \r\n * label=\"Gender\"\r\n * required\r\n * options={[\r\n * { label: \"Male\", value: \"male\" },\r\n * { label: \"Female\", value: \"female\" },\r\n * { label: \"Other\", value: \"other\" },\r\n * ]} \r\n * />\r\n * ```\r\n */\r\nexport function RadioGroup<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>({\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n options = [],\r\n direction = \"vertical\",\r\n control: externalControl,\r\n children,\r\n disabled,\r\n className,\r\n // Validation props\r\n required,\r\n validate,\r\n}: RadioGroupProps<TFieldValues, TName>) {\r\n const generatedId = useId();\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n \r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (formConfigContext?.registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n \r\n if (required !== undefined) rules.required = required;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n formConfigContext.registerFieldValidation({\r\n name: name as string,\r\n type: \"string\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n formConfigContext.unregisterFieldValidation(name as string);\r\n };\r\n }\r\n }, [formConfigContext, name, required, validate]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n const contextValue: RadioGroupContextValue = {\r\n name: name as string,\r\n value: field.value,\r\n onChange: field.onChange,\r\n disabled: effectiveDisabled,\r\n size: effectiveSize,\r\n };\r\n\r\n return (\r\n <div className={cn(\"space-y-2\", className)}>\r\n {label && (\r\n <Label className={cn(\r\n \"block\",\r\n required && \"after:content-['*'] after:ml-0.5 after:text-destructive\"\r\n )}>\r\n {label}\r\n {formConfig.colon && \":\"}\r\n </Label>\r\n )}\r\n \r\n <RadioGroupContext.Provider value={contextValue}>\r\n <ShadcnRadioGroup\r\n value={field.value?.toString()}\r\n onValueChange={(value) => field.onChange(value)}\r\n disabled={effectiveDisabled}\r\n aria-labelledby={label ? `${generatedId}-label` : undefined}\r\n className={cn(\r\n direction === \"horizontal\" && \"flex flex-row gap-4\",\r\n direction === \"vertical\" && \"flex flex-col gap-2\"\r\n )}\r\n >\r\n {children ?? options.map((option) => (\r\n <RadioItem\r\n key={option.value}\r\n value={option.value}\r\n disabled={option.disabled}\r\n size={effectiveSize}\r\n variant={effectiveVariant}\r\n >\r\n {option.label}\r\n </RadioItem>\r\n ))}\r\n </ShadcnRadioGroup>\r\n </RadioGroupContext.Provider>\r\n\r\n {showError && hasError && (\r\n <p className=\"text-sm text-destructive\" role=\"alert\">\r\n {errorMessage}\r\n </p>\r\n )}\r\n \r\n {helperText && !hasError && (\r\n <p className=\"text-sm text-muted-foreground\">\r\n {helperText}\r\n </p>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nRadioGroup.displayName = \"RadioGroup\";\r\n\r\nexport interface RadioItemProps extends Omit<ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>, \"value\">,\r\n VariantProps<typeof radioSizeVariants> {\r\n /** Value for this radio option */\r\n value: string | number;\r\n /** Label for this radio option */\r\n children?: ReactNode;\r\n /** Variant style */\r\n variant?: \"default\" | \"error\";\r\n}\r\n\r\n/**\r\n * RadioItem component - must be used within RadioGroup\r\n * \r\n * This is a wrapper around the shadcn/ui RadioGroupItem primitive\r\n */\r\nfunction RadioItemInner(\r\n {\r\n value,\r\n children,\r\n size,\r\n variant,\r\n className,\r\n disabled,\r\n id: providedId,\r\n ...props\r\n }: RadioItemProps,\r\n ref: React.ForwardedRef<React.ElementRef<typeof RadioGroupPrimitive.Item>>\r\n) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n const groupContext = useContext(RadioGroupContext);\r\n \r\n const effectiveSize = size ?? groupContext?.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? groupContext?.disabled;\r\n\r\n return (\r\n <div className=\"flex items-center gap-2\">\r\n <ShadcnRadioGroupItem\r\n {...props}\r\n ref={ref}\r\n id={inputId}\r\n value={value.toString()}\r\n disabled={effectiveDisabled}\r\n className={cn(\r\n radioSizeVariants({ size: effectiveSize }),\r\n variant === \"error\" && \"border-destructive\",\r\n className\r\n )}\r\n />\r\n \r\n {children && (\r\n <Label\r\n htmlFor={inputId}\r\n className={labelVariants({ disabled: effectiveDisabled })}\r\n >\r\n {children}\r\n </Label>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nexport const RadioItem = forwardRef(RadioItemInner);\r\nRadioItem.displayName = \"RadioItem\";\r\n"],"mappings":";;;;;;;;;;;AAYA,IAAM,qBAAA,GAAA,yBAAA,IAAA,CACJ,IACA;CACE,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CACF;AAEA,IAAM,iBAAA,GAAA,yBAAA,IAAA,CACJ,kDACA;CACE,UAAU,EACR,UAAU;EACR,MAAM;EACN,OAAO;CACT,EACF;CACA,iBAAiB,EACf,UAAU,MACZ;AACF,CACF;AAWA,IAAM,qBAAA,GAAA,MAAA,cAAA,CAAiE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;AAmE3E,SAAgB,WAGd,EACA,MACA,OACA,YACA,YAAY,MACZ,OAAO,aACP,MACA,SACA,UAAU,CAAC,GACX,YAAY,YACZ,SAAS,iBACT,UACA,UACA,WAEA,UACA,YACuC;CACvC,MAAM,eAAA,GAAA,MAAA,MAAA,CAAoB;CAG1B,MAAM,qBAAA,GAAA,MAAA,WAA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CAAA,CAEN;;AAET;AAEA,IAAa,aAAA,GAAA,MAAA,WAAA,CAAuB,cAAc;AAClD,UAAU,cAAc"}
1
+ {"version":3,"file":"Radio.cjs","names":[],"sources":["../../../../src/components/Form/Radio.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { forwardRef, useId, useContext, createContext, useEffect } from \"react\";\r\nimport type { ReactNode, ComponentPropsWithoutRef } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { RadioGroup as ShadcnRadioGroup, RadioGroupItem as ShadcnRadioGroupItem } from \"../../primitives/radio-group\";\r\nimport { Label } from \"../../primitives/label\";\r\nimport type * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\r\n\r\nconst radioSizeVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"h-4 w-4\",\r\n md: \"h-5 w-5\",\r\n lg: \"h-6 w-6\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n }\r\n);\r\n\r\nconst labelVariants = cva(\r\n \"text-sm font-medium cursor-pointer select-none\",\r\n {\r\n variants: {\r\n disabled: {\r\n true: \"cursor-not-allowed opacity-50\",\r\n false: \"\",\r\n },\r\n },\r\n defaultVariants: {\r\n disabled: false,\r\n },\r\n }\r\n);\r\n\r\n// Radio Group Context\r\ninterface RadioGroupContextValue {\r\n name: string;\r\n value: string | number | undefined;\r\n onChange: (value: string | number) => void;\r\n disabled?: boolean;\r\n size?: \"sm\" | \"md\" | \"lg\";\r\n}\r\n\r\nconst RadioGroupContext = createContext<RadioGroupContextValue | null>(null);\r\n\r\nexport interface RadioOption {\r\n label: ReactNode;\r\n value: string | number;\r\n disabled?: boolean;\r\n}\r\n\r\nexport interface RadioGroupProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends VariantProps<typeof radioSizeVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the radio group */\r\n label?: string;\r\n /** Helper text displayed below the radio group */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** Options for the radio group */\r\n options?: RadioOption[];\r\n /** Layout direction */\r\n direction?: \"horizontal\" | \"vertical\";\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n /** Children (alternative to options prop) */\r\n children?: ReactNode;\r\n /** Disabled state */\r\n disabled?: boolean;\r\n /** Additional class name */\r\n className?: string;\r\n /** Variant style */\r\n variant?: \"default\" | \"error\";\r\n \r\n // Validation props\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * RadioGroup component with form integration\r\n * \r\n * This is a wrapper around the shadcn/ui RadioGroup primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component\r\n * <RadioGroup \r\n * name=\"gender\" \r\n * label=\"Gender\"\r\n * required\r\n * options={[\r\n * { label: \"Male\", value: \"male\" },\r\n * { label: \"Female\", value: \"female\" },\r\n * { label: \"Other\", value: \"other\" },\r\n * ]} \r\n * />\r\n * ```\r\n */\r\nexport function RadioGroup<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>({\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n options = [],\r\n direction = \"vertical\",\r\n control: externalControl,\r\n children,\r\n disabled,\r\n className,\r\n // Validation props\r\n required,\r\n validate,\r\n}: RadioGroupProps<TFieldValues, TName>) {\r\n const generatedId = useId();\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n \r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (formConfigContext?.registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n \r\n if (required !== undefined) rules.required = required;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n formConfigContext.registerFieldValidation({\r\n name: name as string,\r\n type: \"string\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n formConfigContext.unregisterFieldValidation(name as string);\r\n };\r\n }\r\n }, [formConfigContext, name, required, validate]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n const contextValue: RadioGroupContextValue = {\r\n name: name as string,\r\n value: field.value,\r\n onChange: field.onChange,\r\n disabled: effectiveDisabled,\r\n size: effectiveSize,\r\n };\r\n\r\n return (\r\n <div className={cn(\"space-y-2\", className)}>\r\n {label && (\r\n <Label className={cn(\r\n \"block\",\r\n required && \"after:content-['*'] after:ml-0.5 after:text-destructive\"\r\n )}>\r\n {label}\r\n {formConfig.colon && \":\"}\r\n </Label>\r\n )}\r\n \r\n <RadioGroupContext.Provider value={contextValue}>\r\n <ShadcnRadioGroup\r\n value={field.value?.toString()}\r\n onValueChange={(value) => field.onChange(value)}\r\n disabled={effectiveDisabled}\r\n aria-labelledby={label ? `${generatedId}-label` : undefined}\r\n className={cn(\r\n direction === \"horizontal\" && \"flex flex-row gap-4\",\r\n direction === \"vertical\" && \"flex flex-col gap-2\"\r\n )}\r\n >\r\n {children ?? options.map((option) => (\r\n <RadioItem\r\n key={option.value}\r\n value={option.value}\r\n disabled={option.disabled}\r\n size={effectiveSize}\r\n variant={effectiveVariant}\r\n >\r\n {option.label}\r\n </RadioItem>\r\n ))}\r\n </ShadcnRadioGroup>\r\n </RadioGroupContext.Provider>\r\n\r\n {showError && hasError && (\r\n <p className=\"text-sm text-destructive\" role=\"alert\">\r\n {errorMessage}\r\n </p>\r\n )}\r\n \r\n {helperText && !hasError && (\r\n <p className=\"text-sm text-muted-foreground\">\r\n {helperText}\r\n </p>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nRadioGroup.displayName = \"RadioGroup\";\r\n\r\nexport interface RadioItemProps extends Omit<ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>, \"value\">,\r\n VariantProps<typeof radioSizeVariants> {\r\n /** Value for this radio option */\r\n value: string | number;\r\n /** Label for this radio option */\r\n children?: ReactNode;\r\n /** Variant style */\r\n variant?: \"default\" | \"error\";\r\n}\r\n\r\n/**\r\n * RadioItem component - must be used within RadioGroup\r\n * \r\n * This is a wrapper around the shadcn/ui RadioGroupItem primitive\r\n */\r\nfunction RadioItemInner(\r\n {\r\n value,\r\n children,\r\n size,\r\n variant,\r\n className,\r\n disabled,\r\n id: providedId,\r\n ...props\r\n }: RadioItemProps,\r\n ref: React.ForwardedRef<React.ElementRef<typeof RadioGroupPrimitive.Item>>\r\n) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n const groupContext = useContext(RadioGroupContext);\r\n \r\n const effectiveSize = size ?? groupContext?.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? groupContext?.disabled;\r\n\r\n return (\r\n <div className=\"flex items-center gap-2\">\r\n <ShadcnRadioGroupItem\r\n {...props}\r\n ref={ref}\r\n id={inputId}\r\n value={value.toString()}\r\n disabled={effectiveDisabled}\r\n className={cn(\r\n radioSizeVariants({ size: effectiveSize }),\r\n variant === \"error\" && \"border-destructive\",\r\n className\r\n )}\r\n />\r\n \r\n {children && (\r\n <Label\r\n htmlFor={inputId}\r\n className={labelVariants({ disabled: effectiveDisabled })}\r\n >\r\n {children}\r\n </Label>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nexport const RadioItem = forwardRef(RadioItemInner);\r\nRadioItem.displayName = \"RadioItem\";\r\n"],"mappings":";;;;;;;;;;;AAYA,IAAM,qBAAA,GAAoB,yBAAA,IAAA,CACxB,IACA;CACE,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CACF;AAEA,IAAM,iBAAA,GAAgB,yBAAA,IAAA,CACpB,kDACA;CACE,UAAU,EACR,UAAU;EACR,MAAM;EACN,OAAO;CACT,EACF;CACA,iBAAiB,EACf,UAAU,MACZ;AACF,CACF;AAWA,IAAM,qBAAA,GAAoB,MAAA,cAAA,CAA6C,IAAI;;;;;;;;;;;;;;;;;;;;;;;;AAmE3E,SAAgB,WAGd,EACA,MACA,OACA,YACA,YAAY,MACZ,OAAO,aACP,MACA,SACA,UAAU,CAAC,GACX,YAAY,YACZ,SAAS,iBACT,UACA,UACA,WAEA,UACA,YACuC;CACvC,MAAM,eAAA,GAAc,MAAA,MAAA,CAAM;CAG1B,MAAM,qBAAA,GAAoB,MAAA,WAAA,CAAW,gBAAA,iBAAiB;CACtD,MAAM,aAAyB,qBAAqB,CAAC;CAGrD,MAAM,cAAA,GAAa,gBAAA,eAAA,CAAgC;CACnD,MAAM,UAAU,mBAAmB,YAAY;CAG/C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,mBAAmB,yBAAyB;GAC9C,MAAM,QAA8B,CAAC;GAErC,IAAI,aAAa,KAAA,GAAW,MAAM,WAAW;GAC7C,IAAI,aAAa,KAAA,GAAW,MAAM,WAAW;GAE7C,kBAAkB,wBAAwB;I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AA;GACQ,CAAA;GAE3B,aAAa,YACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IAAG,WAAU;IAA2B,MAAK;IAC1C,UAAA;GACA,CAAA;GAGJ,cAAc,CAAC,YACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IAAG,WAAU;IACV,UAAA;GACA,CAAA;EAEF;;AAET;AAEA,WAAW,cAAc;;;;;;AAiBzB,SAAS,eACP,EACE,OACA,UACA,MACA,SACA,WACA,UACA,IAAI,YACJ,GAAG,SAEL,KACA;CACA,MAAM,eAAA,GAAc,MAAA,MAAA,CAAM;CAC1B,MAAM,UAAU,cAAc;CAE9B,MAAM,gBAAA,GAAe,MAAA,WAAA,CAAW,iBAAiB;CAEjD,MAAM,gBAAgB,QAAQ,cAAc,QAAQ;CACpD,MAAM,oBAAoB,YAAY,cAAc;CAEpD,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,oBAAA,gBAAD;GACE,GAAI;GACC;GACL,IAAI;GACJ,OAAO,MAAM,SAAS;GACtB,UAAU;GACV,WAAW,WAAA,GACT,kBAAkB,EAAE,MAAM,cAAc,CAAC,GACzC,YAAY,WAAW,sBACvB,SACF;EACD,CAAA,GAEA,YACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAA,OAAD;GACE,SAAS;GACT,WAAW,cAAc,EAAE,UAAU,kBAAkB,CAAC;GAEvD;EACI,CAAA,CAEN;;AAET;AAEA,IAAa,aAAA,GAAY,MAAA,WAAA,CAAW,cAAc;AAClD,UAAU,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Select.cjs","names":[],"sources":["../../../../src/components/Form/Select.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useId, useContext, useEffect } from \"react\";\r\nimport type { ReactNode } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { FieldLayout } from \"./FieldLayout\";\r\nimport {\r\n Select as ShadcnSelect,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from \"../../primitives/select\";\r\n\r\nconst selectSizeVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"h-8 text-xs\",\r\n md: \"h-10 text-sm\",\r\n lg: \"h-12 text-base\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n }\r\n);\r\n\r\nexport interface SelectOption {\r\n label: string;\r\n value: string | number;\r\n disabled?: boolean;\r\n}\r\n\r\nexport interface SelectProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends VariantProps<typeof selectSizeVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the select */\r\n label?: string;\r\n /** Helper text displayed below the select */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** Whether the select should take full width */\r\n fullWidth?: boolean;\r\n /** Options for the select */\r\n options?: SelectOption[];\r\n /** Placeholder text */\r\n placeholder?: string;\r\n /** Allow clear selection */\r\n allowClear?: boolean;\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n /** Children (alternative to options prop) */\r\n children?: ReactNode;\r\n /** Disabled state */\r\n disabled?: boolean;\r\n /** Additional class name */\r\n className?: string;\r\n /** ID for the select */\r\n id?: string;\r\n /** Variant style */\r\n variant?: \"default\" | \"error\" | \"success\";\r\n \r\n // Validation props\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * Select component with form integration\r\n * \r\n * This is a wrapper around the shadcn/ui Select primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component\r\n * <Select \r\n * name=\"country\" \r\n * label=\"Country\" \r\n * required\r\n * options={[\r\n * { label: \"USA\", value: \"us\" },\r\n * { label: \"Canada\", value: \"ca\" },\r\n * ]} \r\n * />\r\n * ```\r\n */\r\nexport function Select<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>({\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n fullWidth = true,\r\n className,\r\n disabled,\r\n options = [],\r\n placeholder,\r\n allowClear,\r\n id: providedId,\r\n control: externalControl,\r\n children,\r\n // Validation props\r\n required,\r\n validate,\r\n}: SelectProps<TFieldValues, TName>) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n \r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (formConfigContext?.registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n \r\n if (required !== undefined) rules.required = required;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n formConfigContext.registerFieldValidation({\r\n name: name as string,\r\n type: \"string\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n formConfigContext.unregisterFieldValidation(name as string);\r\n };\r\n }\r\n }, [formConfigContext, name, required, validate]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n \r\n // Determine variant based on error state\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n return (\r\n <FieldLayout\r\n inputId={inputId}\r\n label={label}\r\n required={!!required}\r\n helperText={helperText}\r\n errorMessage={showError ? errorMessage : undefined}\r\n showError={showError}\r\n fullWidth={fullWidth}\r\n formConfig={formConfig}\r\n >\r\n <ShadcnSelect\r\n value={field.value?.toString() ?? \"\"}\r\n onValueChange={(value) => {\r\n if (value === \"\" && allowClear) {\r\n field.onChange(\"\");\r\n } else {\r\n field.onChange(value);\r\n }\r\n }}\r\n disabled={effectiveDisabled}\r\n >\r\n <SelectTrigger\r\n id={inputId}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n selectSizeVariants({ size: effectiveSize }),\r\n effectiveVariant === \"error\" && \"border-destructive focus:ring-destructive\",\r\n effectiveVariant === \"success\" && \"border-green-500 focus:ring-green-500\",\r\n className\r\n )}\r\n >\r\n <SelectValue placeholder={placeholder} />\r\n </SelectTrigger>\r\n <SelectContent>\r\n {allowClear && field.value && (\r\n <SelectItem value=\"\">\r\n <span className=\"text-muted-foreground\">Clear selection</span>\r\n </SelectItem>\r\n )}\r\n {children ?? options.map((option) => (\r\n <SelectItem\r\n key={option.value}\r\n value={option.value.toString()}\r\n disabled={option.disabled}\r\n >\r\n {option.label}\r\n </SelectItem>\r\n ))}\r\n </SelectContent>\r\n </ShadcnSelect>\r\n </FieldLayout>\r\n );\r\n}\r\n\r\nSelect.displayName = \"Select\";\r\n"],"mappings":";;;;;;;;;;;AAiBA,IAAM,sBAAA,GAAA,yBAAA,IAAA,CACJ,IACA;CACE,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,I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B;EACA;EACC;YAEZ,iBAAA,GAAA,kBAAA,KAAA,CAAC,eAAA,QAAD;GACE,OAAO,MAAM,OAAO,SAAS,KAAK;GAClC,gBAAgB,UAAU;IACxB,IAAI,UAAU,MAAM,YAClB,MAAM,SAAS,EAAE;SAEjB,MAAM,SAAS,KAAK;GAExB;GACA,UAAU;aATZ,CAWE,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,eAAD;IACE,IAAI;IACJ,gBAAc;IACd,oBACE,WACI,GAAG,QAAQ,UACX,aACE,GAAG,QAAQ,WACX,KAAA;IAER,WAAW,WAAA,GACT,mBAAmB,EAAE,MAAM,cAAc,CAAC,GAC1C,qBAAqB,WAAW,6CAChC,qBAAqB,aAAa,yCAClC,SACF;cAEA,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,aAAD,EAA0B,YAAc,CAAA;GAC3B,CAAA,GACf,iBAAA,GAAA,kBAAA,KAAA,CAAC,eAAA,eAAD,EAAA,UAAA,CACG,cAAc,MAAM,SACnB,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,YAAD;IAAY,OAAM;cAChB,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,WAAU;eAAwB;IAAqB,CAAA;GACnD,CAAA,GAEb,YAAY,QAAQ,KAAK,WACxB,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,YAAD;IAEE,OAAO,OAAO,MAAM,SAAS;IAC7B,UAAU,OAAO;cAEhB,OAAO;GACE,GALL,OAAO,KAKF,CACb,CACY,EAAA,CAAA,CACH;;CACH,CAAA;AAEjB;AAEA,OAAO,cAAc"}
1
+ {"version":3,"file":"Select.cjs","names":[],"sources":["../../../../src/components/Form/Select.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { useId, useContext, useEffect } from \"react\";\r\nimport type { ReactNode } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { FieldLayout } from \"./FieldLayout\";\r\nimport {\r\n Select as ShadcnSelect,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from \"../../primitives/select\";\r\n\r\nconst selectSizeVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"h-8 text-xs\",\r\n md: \"h-10 text-sm\",\r\n lg: \"h-12 text-base\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n }\r\n);\r\n\r\nexport interface SelectOption {\r\n label: string;\r\n value: string | number;\r\n disabled?: boolean;\r\n}\r\n\r\nexport interface SelectProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends VariantProps<typeof selectSizeVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the select */\r\n label?: string;\r\n /** Helper text displayed below the select */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** Whether the select should take full width */\r\n fullWidth?: boolean;\r\n /** Options for the select */\r\n options?: SelectOption[];\r\n /** Placeholder text */\r\n placeholder?: string;\r\n /** Allow clear selection */\r\n allowClear?: boolean;\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n /** Children (alternative to options prop) */\r\n children?: ReactNode;\r\n /** Disabled state */\r\n disabled?: boolean;\r\n /** Additional class name */\r\n className?: string;\r\n /** ID for the select */\r\n id?: string;\r\n /** Variant style */\r\n variant?: \"default\" | \"error\" | \"success\";\r\n \r\n // Validation props\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * Select component with form integration\r\n * \r\n * This is a wrapper around the shadcn/ui Select primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component\r\n * <Select \r\n * name=\"country\" \r\n * label=\"Country\" \r\n * required\r\n * options={[\r\n * { label: \"USA\", value: \"us\" },\r\n * { label: \"Canada\", value: \"ca\" },\r\n * ]} \r\n * />\r\n * ```\r\n */\r\nexport function Select<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>({\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n fullWidth = true,\r\n className,\r\n disabled,\r\n options = [],\r\n placeholder,\r\n allowClear,\r\n id: providedId,\r\n control: externalControl,\r\n children,\r\n // Validation props\r\n required,\r\n validate,\r\n}: SelectProps<TFieldValues, TName>) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n \r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (formConfigContext?.registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n \r\n if (required !== undefined) rules.required = required;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n formConfigContext.registerFieldValidation({\r\n name: name as string,\r\n type: \"string\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n formConfigContext.unregisterFieldValidation(name as string);\r\n };\r\n }\r\n }, [formConfigContext, name, required, validate]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n \r\n // Determine variant based on error state\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n return (\r\n <FieldLayout\r\n inputId={inputId}\r\n label={label}\r\n required={!!required}\r\n helperText={helperText}\r\n errorMessage={showError ? errorMessage : undefined}\r\n showError={showError}\r\n fullWidth={fullWidth}\r\n formConfig={formConfig}\r\n >\r\n <ShadcnSelect\r\n value={field.value?.toString() ?? \"\"}\r\n onValueChange={(value) => {\r\n if (value === \"\" && allowClear) {\r\n field.onChange(\"\");\r\n } else {\r\n field.onChange(value);\r\n }\r\n }}\r\n disabled={effectiveDisabled}\r\n >\r\n <SelectTrigger\r\n id={inputId}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n selectSizeVariants({ size: effectiveSize }),\r\n effectiveVariant === \"error\" && \"border-destructive focus:ring-destructive\",\r\n effectiveVariant === \"success\" && \"border-green-500 focus:ring-green-500\",\r\n className\r\n )}\r\n >\r\n <SelectValue placeholder={placeholder} />\r\n </SelectTrigger>\r\n <SelectContent>\r\n {allowClear && field.value && (\r\n <SelectItem value=\"\">\r\n <span className=\"text-muted-foreground\">Clear selection</span>\r\n </SelectItem>\r\n )}\r\n {children ?? options.map((option) => (\r\n <SelectItem\r\n key={option.value}\r\n value={option.value.toString()}\r\n disabled={option.disabled}\r\n >\r\n {option.label}\r\n </SelectItem>\r\n ))}\r\n </SelectContent>\r\n </ShadcnSelect>\r\n </FieldLayout>\r\n );\r\n}\r\n\r\nSelect.displayName = \"Select\";\r\n"],"mappings":";;;;;;;;;;;AAiBA,IAAM,sBAAA,GAAqB,yBAAA,IAAA,CACzB,IACA;CACE,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CACA,iB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AA,kBAAA,KAAA,CAAC,eAAA,QAAD;GACE,OAAO,MAAM,OAAO,SAAS,KAAK;GAClC,gBAAgB,UAAU;IACxB,IAAI,UAAU,MAAM,YAClB,MAAM,SAAS,EAAE;SAEjB,MAAM,SAAS,KAAK;GAExB;GACA,UAAU;GATZ,UAAA,CAWE,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,eAAD;IACE,IAAI;IACJ,gBAAc;IACd,oBACE,WACI,GAAG,QAAQ,UACX,aACE,GAAG,QAAQ,WACX,KAAA;IAER,WAAW,WAAA,GACT,mBAAmB,EAAE,MAAM,cAAc,CAAC,GAC1C,qBAAqB,WAAW,6CAChC,qBAAqB,aAAa,yCAClC,SACF;IAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,aAAD,EAA0B,YAAc,CAAA;GAC3B,CAAA,GACf,iBAAA,GAAA,kBAAA,KAAA,CAAC,eAAA,eAAD,EAAA,UAAA,CACG,cAAc,MAAM,SACnB,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,YAAD;IAAY,OAAM;IAChB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,WAAU;KAAwB,UAAA;IAAqB,CAAA;GACnD,CAAA,GAEb,YAAY,QAAQ,KAAK,WACxB,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,YAAD;IAEE,OAAO,OAAO,MAAM,SAAS;IAC7B,UAAU,OAAO;IAEhB,UAAA,OAAO;GACE,GALL,OAAO,KAKF,CACb,CACY,EAAA,CAAA,CACH;;CACH,CAAA;AAEjB;AAEA,OAAO,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"TextArea.cjs","names":[],"sources":["../../../../src/components/Form/TextArea.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { forwardRef, useId, useContext, useEffect } from \"react\";\r\nimport type { TextareaHTMLAttributes } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { labelVariants } from \"./variants\";\r\nimport { Textarea } from \"../../primitives/textarea\";\r\nimport { Label } from \"../../primitives/label\";\r\n\r\nconst textAreaSizeVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"text-xs px-2 py-1.5 min-h-[60px]\",\r\n md: \"text-sm px-3 py-2 min-h-[80px]\",\r\n lg: \"text-base px-4 py-3 min-h-[100px]\",\r\n },\r\n variant: {\r\n default: \"border-input focus-visible:ring-ring\",\r\n error: \"border-destructive focus-visible:ring-destructive\",\r\n success: \"border-green-500 focus-visible:ring-green-500\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n variant: \"default\",\r\n },\r\n }\r\n);\r\n\r\n/**\r\n * Validation rule with optional custom message\r\n */\r\ntype ValidationRule<T> = T | { value: T; message: string };\r\n\r\nexport interface TextAreaProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, \"name\" | \"required\" | \"minLength\" | \"maxLength\">,\r\n VariantProps<typeof textAreaSizeVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the textarea */\r\n label?: string;\r\n /** Helper text displayed below the textarea */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** Whether the textarea should take full width */\r\n fullWidth?: boolean;\r\n /** Show character count */\r\n showCount?: boolean;\r\n /** Maximum character count (for display) */\r\n maxCount?: number;\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n \r\n // Validation props\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Minimum length */\r\n minLength?: ValidationRule<number>;\r\n /** Maximum length */\r\n maxLength?: ValidationRule<number>;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * TextArea component with form integration\r\n * \r\n * This is a wrapper around the shadcn/ui Textarea primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * - Character count display\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component\r\n * <TextArea name=\"description\" label=\"Description\" required minLength={10} />\r\n * <TextArea name=\"bio\" label=\"Bio\" showCount maxCount={500} maxLength={500} />\r\n * ```\r\n */\r\nfunction TextAreaInner<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n {\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n fullWidth = true,\r\n className,\r\n disabled,\r\n showCount,\r\n maxCount,\r\n id: providedId,\r\n control: externalControl,\r\n // Validation props\r\n required,\r\n minLength,\r\n maxLength,\r\n validate,\r\n ...props\r\n }: TextAreaProps<TFieldValues, TName>,\r\n ref: React.ForwardedRef<HTMLTextAreaElement>\r\n) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n \r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (formConfigContext?.registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n \r\n if (required !== undefined) rules.required = required;\r\n if (minLength !== undefined) rules.minLength = minLength;\r\n if (maxLength !== undefined) rules.maxLength = maxLength;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n formConfigContext.registerFieldValidation({\r\n name: name as string,\r\n type: \"string\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n formConfigContext.unregisterFieldValidation(name as string);\r\n };\r\n }\r\n }, [formConfigContext, name, required, minLength, maxLength, validate]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n \r\n // Determine variant based on error state\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n const currentLength = typeof field.value === \"string\" ? field.value.length : 0;\r\n \r\n // Get maxLength value for HTML attribute\r\n const maxLengthValue = maxCount ?? (typeof maxLength === \"number\" ? maxLength : (maxLength as { value: number })?.value);\r\n\r\n return (\r\n <div className={cn(\"space-y-1.5\", fullWidth && \"w-full\")}>\r\n {label && (\r\n <Label\r\n htmlFor={inputId}\r\n className={labelVariants({ required: !!required })}\r\n >\r\n {label}\r\n {formConfig.colon && \":\"}\r\n </Label>\r\n )}\r\n \r\n <div className=\"relative\">\r\n <Textarea\r\n {...props}\r\n {...field}\r\n ref={(node) => {\r\n if (typeof ref === \"function\") {\r\n ref(node);\r\n } else if (ref) {\r\n ref.current = node;\r\n }\r\n field.ref(node);\r\n }}\r\n id={inputId}\r\n disabled={effectiveDisabled}\r\n maxLength={maxLengthValue}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n textAreaSizeVariants({ size: effectiveSize, variant: effectiveVariant }),\r\n showCount && \"pb-6\",\r\n className\r\n )}\r\n />\r\n \r\n {showCount && (\r\n <div className=\"absolute bottom-2 right-2 text-xs text-muted-foreground\">\r\n {currentLength}{maxCount ? `/${maxCount}` : \"\"}\r\n </div>\r\n )}\r\n </div>\r\n\r\n {showError && hasError && (\r\n <p\r\n id={`${inputId}-error`}\r\n className=\"text-sm text-destructive\"\r\n role=\"alert\"\r\n >\r\n {errorMessage}\r\n </p>\r\n )}\r\n \r\n {helperText && !hasError && (\r\n <p\r\n id={`${inputId}-helper`}\r\n className=\"text-sm text-muted-foreground\"\r\n >\r\n {helperText}\r\n </p>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\n// Use forwardRef with generic support\r\nexport const TextArea = forwardRef(TextAreaInner) as <\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n props: TextAreaProps<TFieldValues, TName> & { ref?: React.ForwardedRef<HTMLTextAreaElement> }\r\n) => React.ReactElement;\r\n\r\n(TextArea as React.FC).displayName = \"TextArea\";\r\n"],"mappings":";;;;;;;;;;;;AAYA,IAAM,wBAAA,GAAA,yBAAA,IAAA,CACJ,IACA;CACE,UAAU;EACR,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EACA,SAAS;GACP,SAAS;GACT,OAAO;GACP,SAAS;EACX;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CACF;;;;;;;;;;;;;;;;;AA0DA,SAAS,cAIP,EACE,MACA,OACA,YACA,YAAY,MACZ,OAAO,aACP,MACA,SACA,YAAY,MACZ,WACA,UACA,WACA,UACA,IAAI,YACJ,SAAS,iBAET,UACA,WACA,WACA,UACA,GAAG,SAEL,KACA;CACA,MAAM,eAAA,GAAA,MAAA,MAAA,CAAoB;CAC1B,MAAM,UAAU,cAAc;CAG9B,MAAM,qBAAA,GAAA,MAAA,WAAA,CAA+B,gBAAA,iBAAiB;CACtD,MAAM,aAAyB,qBAAqB,CAAC;CAGrD,MAAM,cAAA,GAAA,gBAAA,eAAA,CAA6C;CACnD,MAAM,UAAU,mBAAmB,YAAY;CAG/C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,mBAAmB,yBAAy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I,KACT,IAAI,UAAU;MAEhB,MAAM,IAAI,IAAI;KAChB;KACA,IAAI;KACJ,UAAU;KACV,WAAW;KACX,gBAAc;KACd,oBACE,WACI,GAAG,QAAQ,UACX,aACA,GAAG,QAAQ,WACX,KAAA;KAEN,WAAW,WAAA,GACT,qBAAqB;MAAE,MAAM;MAAe,SAAS;KAAiB,CAAC,GACvE,aAAa,QACb,SACF;IACD,CAAA,GAEA,aACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;KAAK,WAAU;eAAf,CACG,eAAe,WAAW,IAAI,aAAa,EACzC;MAEJ;;GAEJ,aAAa,YACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;IACV,MAAK;cAEJ;GACA,CAAA;GAGJ,cAAc,CAAC,YACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;cAET;GACA,CAAA;EAEF;;AAET;AAGA,IAAa,YAAA,GAAA,MAAA,WAAA,CAAsB,aAAa;AAOhD,SAAuB,cAAc"}
1
+ {"version":3,"file":"TextArea.cjs","names":[],"sources":["../../../../src/components/Form/TextArea.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { forwardRef, useId, useContext, useEffect } from \"react\";\r\nimport type { TextareaHTMLAttributes } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { labelVariants } from \"./variants\";\r\nimport { Textarea } from \"../../primitives/textarea\";\r\nimport { Label } from \"../../primitives/label\";\r\n\r\nconst textAreaSizeVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"text-xs px-2 py-1.5 min-h-[60px]\",\r\n md: \"text-sm px-3 py-2 min-h-[80px]\",\r\n lg: \"text-base px-4 py-3 min-h-[100px]\",\r\n },\r\n variant: {\r\n default: \"border-input focus-visible:ring-ring\",\r\n error: \"border-destructive focus-visible:ring-destructive\",\r\n success: \"border-green-500 focus-visible:ring-green-500\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n variant: \"default\",\r\n },\r\n }\r\n);\r\n\r\n/**\r\n * Validation rule with optional custom message\r\n */\r\ntype ValidationRule<T> = T | { value: T; message: string };\r\n\r\nexport interface TextAreaProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, \"name\" | \"required\" | \"minLength\" | \"maxLength\">,\r\n VariantProps<typeof textAreaSizeVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the textarea */\r\n label?: string;\r\n /** Helper text displayed below the textarea */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** Whether the textarea should take full width */\r\n fullWidth?: boolean;\r\n /** Show character count */\r\n showCount?: boolean;\r\n /** Maximum character count (for display) */\r\n maxCount?: number;\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n \r\n // Validation props\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Minimum length */\r\n minLength?: ValidationRule<number>;\r\n /** Maximum length */\r\n maxLength?: ValidationRule<number>;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * TextArea component with form integration\r\n * \r\n * This is a wrapper around the shadcn/ui Textarea primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * - Character count display\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component\r\n * <TextArea name=\"description\" label=\"Description\" required minLength={10} />\r\n * <TextArea name=\"bio\" label=\"Bio\" showCount maxCount={500} maxLength={500} />\r\n * ```\r\n */\r\nfunction TextAreaInner<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n {\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n fullWidth = true,\r\n className,\r\n disabled,\r\n showCount,\r\n maxCount,\r\n id: providedId,\r\n control: externalControl,\r\n // Validation props\r\n required,\r\n minLength,\r\n maxLength,\r\n validate,\r\n ...props\r\n }: TextAreaProps<TFieldValues, TName>,\r\n ref: React.ForwardedRef<HTMLTextAreaElement>\r\n) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n \r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (formConfigContext?.registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n \r\n if (required !== undefined) rules.required = required;\r\n if (minLength !== undefined) rules.minLength = minLength;\r\n if (maxLength !== undefined) rules.maxLength = maxLength;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n formConfigContext.registerFieldValidation({\r\n name: name as string,\r\n type: \"string\",\r\n rules,\r\n });\r\n\r\n return () => {\r\n formConfigContext.unregisterFieldValidation(name as string);\r\n };\r\n }\r\n }, [formConfigContext, name, required, minLength, maxLength, validate]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n \r\n // Determine variant based on error state\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n const currentLength = typeof field.value === \"string\" ? field.value.length : 0;\r\n \r\n // Get maxLength value for HTML attribute\r\n const maxLengthValue = maxCount ?? (typeof maxLength === \"number\" ? maxLength : (maxLength as { value: number })?.value);\r\n\r\n return (\r\n <div className={cn(\"space-y-1.5\", fullWidth && \"w-full\")}>\r\n {label && (\r\n <Label\r\n htmlFor={inputId}\r\n className={labelVariants({ required: !!required })}\r\n >\r\n {label}\r\n {formConfig.colon && \":\"}\r\n </Label>\r\n )}\r\n \r\n <div className=\"relative\">\r\n <Textarea\r\n {...props}\r\n {...field}\r\n ref={(node) => {\r\n if (typeof ref === \"function\") {\r\n ref(node);\r\n } else if (ref) {\r\n ref.current = node;\r\n }\r\n field.ref(node);\r\n }}\r\n id={inputId}\r\n disabled={effectiveDisabled}\r\n maxLength={maxLengthValue}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n textAreaSizeVariants({ size: effectiveSize, variant: effectiveVariant }),\r\n showCount && \"pb-6\",\r\n className\r\n )}\r\n />\r\n \r\n {showCount && (\r\n <div className=\"absolute bottom-2 right-2 text-xs text-muted-foreground\">\r\n {currentLength}{maxCount ? `/${maxCount}` : \"\"}\r\n </div>\r\n )}\r\n </div>\r\n\r\n {showError && hasError && (\r\n <p\r\n id={`${inputId}-error`}\r\n className=\"text-sm text-destructive\"\r\n role=\"alert\"\r\n >\r\n {errorMessage}\r\n </p>\r\n )}\r\n \r\n {helperText && !hasError && (\r\n <p\r\n id={`${inputId}-helper`}\r\n className=\"text-sm text-muted-foreground\"\r\n >\r\n {helperText}\r\n </p>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\n// Use forwardRef with generic support\r\nexport const TextArea = forwardRef(TextAreaInner) as <\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n props: TextAreaProps<TFieldValues, TName> & { ref?: React.ForwardedRef<HTMLTextAreaElement> }\r\n) => React.ReactElement;\r\n\r\n(TextArea as React.FC).displayName = \"TextArea\";\r\n"],"mappings":";;;;;;;;;;;;AAYA,IAAM,wBAAA,GAAuB,yBAAA,IAAA,CAC3B,IACA;CACE,UAAU;EACR,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EACA,SAAS;GACP,SAAS;GACT,OAAO;GACP,SAAS;EACX;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CACF;;;;;;;;;;;;;;;;;AA0DA,SAAS,cAIP,EACE,MACA,OACA,YACA,YAAY,MACZ,OAAO,aACP,MACA,SACA,YAAY,MACZ,WACA,UACA,WACA,UACA,IAAI,YACJ,SAAS,iBAET,UACA,WACA,WACA,UACA,GAAG,SAEL,KACA;CACA,MAAM,eAAA,GAAc,MAAA,MAAA,CAAM;CAC1B,MAAM,UAAU,cAAc;CAG9B,MAAM,qBAAA,GAAoB,MAAA,WAAA,CAAW,gBAAA,iBAAiB;CACtD,MAAM,aAAyB,qBAAqB,CAAC;CAGrD,MAAM,cAAA,GAAa,gBAAA,eAAA,CAAgC;CACnD,MAAM,UAAU,mBAAmB,YAAY;CAG/C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,mBAAmB,yBAAyB;GAC9C,MAAM,QAA8B,CAAC;GAErC,IAAI,aAAa,KAAA,GAAW,MAAM,WAAW;GAC7C,IAAI,cAAc,KAAA,GAAW,MAAM,YAAY;GAC/C,IAAI,cAAc,KAAA,GAAW,MAAM,YAAY;GAC/C,IAAI,aAAa,KAAA,GAAW,MAAM,WAAW;GAE7C,kBAAkB,wBAAwB;IAClC;IACN,MAAM;IACN;GACF,CAAC;GAED,aAAa;IACX,kBAAkB,0BAA0B,IAAc;GAC5D;EACF;CACF,GAAG;EAAC;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D;KAAK,WAAU;KAAf,UAAA,CACG,eAAe,WAAW,IAAI,aAAa,EACzC;IAEJ,CAAA,CAAA;;GAEJ,aAAa,YACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;IACV,MAAK;IAEJ,UAAA;GACA,CAAA;GAGJ,cAAc,CAAC,YACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;IAET,UAAA;GACA,CAAA;EAEF;;AAET;AAGA,IAAa,YAAA,GAAW,MAAA,WAAA,CAAW,aAAa;AAOhD,SAAuB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"TextBox.cjs","names":[],"sources":["../../../../src/components/Form/TextBox.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { forwardRef, useId, useContext, useEffect } from \"react\";\r\nimport type { InputHTMLAttributes, ReactNode } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { FieldLayout } from \"./FieldLayout\";\r\nimport { TextBoxPrimitive } from \"../../primitives/textbox\";\r\nimport { X } from \"lucide-react\";\r\n\r\nconst textBoxVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"h-8 text-xs px-2\",\r\n md: \"h-10 text-sm px-3\",\r\n lg: \"h-12 text-base px-4\",\r\n },\r\n variant: {\r\n default: \"border-input focus-visible:ring-ring\",\r\n error: \"border-destructive focus-visible:ring-destructive\",\r\n success: \"border-green-500 focus-visible:ring-green-500\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n variant: \"default\",\r\n },\r\n }\r\n);\r\n\r\n/**\r\n * Validation rule with optional custom message\r\n */\r\ntype ValidationRule<T> = T | { value: T; message: string };\r\n\r\nexport interface TextBoxProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends Omit<InputHTMLAttributes<HTMLInputElement>, \"size\" | \"name\" | \"prefix\" | \"pattern\" | \"required\" | \"minLength\" | \"maxLength\">,\r\n VariantProps<typeof textBoxVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the input */\r\n label?: string;\r\n /** Helper text displayed below the input */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** Whether the input should take full width */\r\n fullWidth?: boolean;\r\n /** Prefix element */\r\n prefix?: ReactNode;\r\n /** Suffix element */\r\n suffix?: ReactNode;\r\n /** Allow clear button */\r\n allowClear?: boolean;\r\n /** Callback when clear is clicked */\r\n onClear?: () => void;\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n \r\n // Validation props\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Minimum length for strings */\r\n minLength?: ValidationRule<number>;\r\n /** Maximum length for strings */\r\n maxLength?: ValidationRule<number>;\r\n /** Minimum value for numbers */\r\n minValue?: ValidationRule<number>;\r\n /** Maximum value for numbers */\r\n maxValue?: ValidationRule<number>;\r\n /** Regex pattern for validation */\r\n pattern?: ValidationRule<RegExp>;\r\n /** Email validation */\r\n email?: boolean | string;\r\n /** URL validation */\r\n url?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * TextBox component with form integration and automatic validation registration\r\n * \r\n * This is a wrapper around the shadcn/ui Input primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * - Prefix/suffix elements\r\n * - Clear button functionality\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component - validation is automatically registered\r\n * <Form onSubmit={handleSubmit} defaultValues={{ username: \"\", email: \"\" }}>\r\n * <TextBox name=\"username\" label=\"Username\" required minLength={3} maxLength={50} />\r\n * <TextBox name=\"email\" label=\"Email\" type=\"email\" required email />\r\n * <TextBox name=\"website\" label=\"Website\" url />\r\n * <Button type=\"submit\">Submit</Button>\r\n * </Form>\r\n * ```\r\n */\r\nfunction TextBoxInner<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n {\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n fullWidth = true,\r\n className,\r\n disabled,\r\n prefix,\r\n suffix,\r\n allowClear,\r\n onClear,\r\n id: providedId,\r\n control: externalControl,\r\n // Validation props\r\n required,\r\n minLength,\r\n maxLength,\r\n minValue,\r\n maxValue,\r\n pattern,\r\n email,\r\n url,\r\n validate,\r\n ...props\r\n }: TextBoxProps<TFieldValues, TName>,\r\n ref: React.ForwardedRef<HTMLInputElement>\r\n) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n\r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Destructure stable function references so the effect doesn't depend on the\r\n // context object identity (which changes every render due to inline construction).\r\n const registerFieldValidation = formConfigContext?.registerFieldValidation;\r\n const unregisterFieldValidation = formConfigContext?.unregisterFieldValidation;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n\r\n if (required !== undefined) rules.required = required;\r\n if (minLength !== undefined) rules.minLength = minLength;\r\n if (maxLength !== undefined) rules.maxLength = maxLength;\r\n if (minValue !== undefined) rules.min = minValue;\r\n if (maxValue !== undefined) rules.max = maxValue;\r\n if (pattern !== undefined) rules.pattern = pattern;\r\n if (email !== undefined) rules.email = email;\r\n if (url !== undefined) rules.url = url;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n // Determine field type and auto-infer rules from input type\r\n const inputType = props.type ?? \"text\";\r\n let fieldType: \"string\" | \"number\" | \"date\" = \"string\";\r\n\r\n if (inputType === \"number\") {\r\n fieldType = \"number\";\r\n } else if (inputType === \"date\") {\r\n fieldType = \"date\";\r\n } else if (inputType === \"email\" && rules.email === undefined) {\r\n rules.email = true;\r\n } else if (inputType === \"url\" && rules.url === undefined) {\r\n rules.url = true;\r\n } else if (inputType === \"tel\" && rules.pattern === undefined) {\r\n rules.pattern = { value: /^\\+?[\\d\\s\\-().]{7,}$/, message: \"Invalid phone number\" };\r\n }\r\n\r\n registerFieldValidation({\r\n name: name as string,\r\n type: fieldType,\r\n rules,\r\n });\r\n\r\n return () => {\r\n unregisterFieldValidation?.(name as string);\r\n };\r\n }\r\n }, [\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n name,\r\n required,\r\n minLength,\r\n maxLength,\r\n minValue,\r\n maxValue,\r\n pattern,\r\n email,\r\n url,\r\n validate,\r\n props.type,\r\n ]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n \r\n // Determine variant based on error state\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n const handleClear = () => {\r\n field.onChange(\"\");\r\n onClear?.();\r\n };\r\n\r\n return (\r\n <FieldLayout\r\n inputId={inputId}\r\n label={label}\r\n required={!!required}\r\n helperText={helperText}\r\n errorMessage={showError ? errorMessage : undefined}\r\n showError={showError}\r\n fullWidth={fullWidth}\r\n formConfig={formConfig}\r\n >\r\n <div className=\"relative\">\r\n {prefix && (\r\n <div className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\">\r\n {prefix}\r\n </div>\r\n )}\r\n\r\n <TextBoxPrimitive\r\n {...props}\r\n {...field}\r\n ref={(node) => {\r\n if (typeof ref === \"function\") {\r\n ref(node);\r\n } else if (ref) {\r\n ref.current = node;\r\n }\r\n field.ref(node);\r\n }}\r\n id={inputId}\r\n disabled={effectiveDisabled}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n textBoxVariants({ size: effectiveSize, variant: effectiveVariant }),\r\n prefix && \"pl-10\",\r\n (suffix || allowClear) && \"pr-10\",\r\n className\r\n )}\r\n />\r\n\r\n {(suffix || (allowClear && field.value)) && (\r\n <div className=\"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1\">\r\n {allowClear && field.value && (\r\n <button\r\n type=\"button\"\r\n onClick={handleClear}\r\n className=\"text-muted-foreground hover:text-foreground transition-colors\"\r\n tabIndex={-1}\r\n aria-label=\"Clear\"\r\n >\r\n <X className=\"h-4 w-4\" />\r\n </button>\r\n )}\r\n {suffix && (\r\n <span className=\"text-muted-foreground\">{suffix}</span>\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n </FieldLayout>\r\n );\r\n}\r\n\r\n// Use forwardRef with generic support\r\nexport const TextBox = forwardRef(TextBoxInner) as <\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n props: TextBoxProps<TFieldValues, TName> & { ref?: React.ForwardedRef<HTMLInputElement> }\r\n) => React.ReactElement;\r\n\r\n(TextBox as React.FC).displayName = \"TextBox\";\r\n"],"mappings":";;;;;;;;;;;;AAYA,IAAM,mBAAA,GAAA,yBAAA,IAAA,CACJ,IACA;CACE,UAAU;EACR,MAAM;GACJ,IAAI;GAC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,gBAAc;KACd,oBACE,WACI,GAAG,QAAQ,UACX,aACE,GAAG,QAAQ,WACX,KAAA;KAER,WAAW,WAAA,GACT,gBAAgB;MAAE,MAAM;MAAe,SAAS;KAAiB,CAAC,GAClE,UAAU,UACT,UAAU,eAAe,SAC1B,SACF;IACD,CAAA;KAEC,UAAW,cAAc,MAAM,UAC/B,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;KAAK,WAAU;eAAf,CACG,cAAc,MAAM,SACnB,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;MACE,MAAK;MACL,SAAS;MACT,WAAU;MACV,UAAU;MACV,cAAW;gBAEX,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,GAAD,EAAG,WAAU,UAAW,CAAA;KAClB,CAAA,GAET,UACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;MAAM,WAAU;gBAAyB;KAAa,CAAA,CAErD;;GAEJ;;CACM,CAAA;AAEjB;AAGA,IAAa,WAAA,GAAA,MAAA,WAAA,CAAqB,YAAY;AAO9C,QAAsB,cAAc"}
1
+ {"version":3,"file":"TextBox.cjs","names":[],"sources":["../../../../src/components/Form/TextBox.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { forwardRef, useId, useContext, useEffect } from \"react\";\r\nimport type { InputHTMLAttributes, ReactNode } from \"react\";\r\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport { cn } from \"../../utils/cn\";\r\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\r\nimport { FieldLayout } from \"./FieldLayout\";\r\nimport { TextBoxPrimitive } from \"../../primitives/textbox\";\r\nimport { X } from \"lucide-react\";\r\n\r\nconst textBoxVariants = cva(\r\n \"\",\r\n {\r\n variants: {\r\n size: {\r\n sm: \"h-8 text-xs px-2\",\r\n md: \"h-10 text-sm px-3\",\r\n lg: \"h-12 text-base px-4\",\r\n },\r\n variant: {\r\n default: \"border-input focus-visible:ring-ring\",\r\n error: \"border-destructive focus-visible:ring-destructive\",\r\n success: \"border-green-500 focus-visible:ring-green-500\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n variant: \"default\",\r\n },\r\n }\r\n);\r\n\r\n/**\r\n * Validation rule with optional custom message\r\n */\r\ntype ValidationRule<T> = T | { value: T; message: string };\r\n\r\nexport interface TextBoxProps<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n> extends Omit<InputHTMLAttributes<HTMLInputElement>, \"size\" | \"name\" | \"prefix\" | \"pattern\" | \"required\" | \"minLength\" | \"maxLength\">,\r\n VariantProps<typeof textBoxVariants> {\r\n /** Field name - required for form integration */\r\n name: TName;\r\n /** Label text for the input */\r\n label?: string;\r\n /** Helper text displayed below the input */\r\n helperText?: string;\r\n /** Whether to show the error message */\r\n showError?: boolean;\r\n /** Custom error message (overrides form error) */\r\n error?: string;\r\n /** Whether the input should take full width */\r\n fullWidth?: boolean;\r\n /** Prefix element */\r\n prefix?: ReactNode;\r\n /** Suffix element */\r\n suffix?: ReactNode;\r\n /** Allow clear button */\r\n allowClear?: boolean;\r\n /** Callback when clear is clicked */\r\n onClear?: () => void;\r\n /** External control (for use outside Form) */\r\n control?: Control<TFieldValues>;\r\n \r\n // Validation props\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Minimum length for strings */\r\n minLength?: ValidationRule<number>;\r\n /** Maximum length for strings */\r\n maxLength?: ValidationRule<number>;\r\n /** Minimum value for numbers */\r\n minValue?: ValidationRule<number>;\r\n /** Maximum value for numbers */\r\n maxValue?: ValidationRule<number>;\r\n /** Regex pattern for validation */\r\n pattern?: ValidationRule<RegExp>;\r\n /** Email validation */\r\n email?: boolean | string;\r\n /** URL validation */\r\n url?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * TextBox component with form integration and automatic validation registration\r\n * \r\n * This is a wrapper around the shadcn/ui Input primitive that adds:\r\n * - Form integration with react-hook-form\r\n * - Automatic validation registration\r\n * - Label, helper text, and error message support\r\n * - Prefix/suffix elements\r\n * - Clear button functionality\r\n * \r\n * @example\r\n * ```tsx\r\n * // Inside a Form component - validation is automatically registered\r\n * <Form onSubmit={handleSubmit} defaultValues={{ username: \"\", email: \"\" }}>\r\n * <TextBox name=\"username\" label=\"Username\" required minLength={3} maxLength={50} />\r\n * <TextBox name=\"email\" label=\"Email\" type=\"email\" required email />\r\n * <TextBox name=\"website\" label=\"Website\" url />\r\n * <Button type=\"submit\">Submit</Button>\r\n * </Form>\r\n * ```\r\n */\r\nfunction TextBoxInner<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n {\r\n name,\r\n label,\r\n helperText,\r\n showError = true,\r\n error: customError,\r\n size,\r\n variant,\r\n fullWidth = true,\r\n className,\r\n disabled,\r\n prefix,\r\n suffix,\r\n allowClear,\r\n onClear,\r\n id: providedId,\r\n control: externalControl,\r\n // Validation props\r\n required,\r\n minLength,\r\n maxLength,\r\n minValue,\r\n maxValue,\r\n pattern,\r\n email,\r\n url,\r\n validate,\r\n ...props\r\n }: TextBoxProps<TFieldValues, TName>,\r\n ref: React.ForwardedRef<HTMLInputElement>\r\n) {\r\n const generatedId = useId();\r\n const inputId = providedId ?? generatedId;\r\n \r\n // Try to get form context\r\n const formConfigContext = useContext(FormConfigContext);\r\n const formConfig: FormConfig = formConfigContext ?? {};\r\n\r\n // Get form context from react-hook-form\r\n const rhfContext = useRHFFormContext<TFieldValues>();\r\n const control = externalControl ?? rhfContext?.control;\r\n\r\n // Destructure stable function references so the effect doesn't depend on the\r\n // context object identity (which changes every render due to inline construction).\r\n const registerFieldValidation = formConfigContext?.registerFieldValidation;\r\n const unregisterFieldValidation = formConfigContext?.unregisterFieldValidation;\r\n\r\n // Register validation rules with the form\r\n useEffect(() => {\r\n if (registerFieldValidation) {\r\n const rules: FieldValidationRules = {};\r\n\r\n if (required !== undefined) rules.required = required;\r\n if (minLength !== undefined) rules.minLength = minLength;\r\n if (maxLength !== undefined) rules.maxLength = maxLength;\r\n if (minValue !== undefined) rules.min = minValue;\r\n if (maxValue !== undefined) rules.max = maxValue;\r\n if (pattern !== undefined) rules.pattern = pattern;\r\n if (email !== undefined) rules.email = email;\r\n if (url !== undefined) rules.url = url;\r\n if (validate !== undefined) rules.validate = validate;\r\n\r\n // Determine field type and auto-infer rules from input type\r\n const inputType = props.type ?? \"text\";\r\n let fieldType: \"string\" | \"number\" | \"date\" = \"string\";\r\n\r\n if (inputType === \"number\") {\r\n fieldType = \"number\";\r\n } else if (inputType === \"date\") {\r\n fieldType = \"date\";\r\n } else if (inputType === \"email\" && rules.email === undefined) {\r\n rules.email = true;\r\n } else if (inputType === \"url\" && rules.url === undefined) {\r\n rules.url = true;\r\n } else if (inputType === \"tel\" && rules.pattern === undefined) {\r\n rules.pattern = { value: /^\\+?[\\d\\s\\-().]{7,}$/, message: \"Invalid phone number\" };\r\n }\r\n\r\n registerFieldValidation({\r\n name: name as string,\r\n type: fieldType,\r\n rules,\r\n });\r\n\r\n return () => {\r\n unregisterFieldValidation?.(name as string);\r\n };\r\n }\r\n }, [\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n name,\r\n required,\r\n minLength,\r\n maxLength,\r\n minValue,\r\n maxValue,\r\n pattern,\r\n email,\r\n url,\r\n validate,\r\n props.type,\r\n ]);\r\n\r\n // Use controller for form integration\r\n const { field, fieldState } = useController<TFieldValues, TName>({\r\n name,\r\n control,\r\n });\r\n\r\n const fieldError = fieldState.error?.message;\r\n const errorMessage = customError ?? fieldError;\r\n const hasError = !!errorMessage;\r\n \r\n // Merge sizes - prop takes precedence over form config\r\n const effectiveSize = size ?? formConfig.size ?? \"md\";\r\n const effectiveDisabled = disabled ?? formConfig.disabled;\r\n \r\n // Determine variant based on error state\r\n const effectiveVariant = hasError ? \"error\" : variant;\r\n\r\n const handleClear = () => {\r\n field.onChange(\"\");\r\n onClear?.();\r\n };\r\n\r\n return (\r\n <FieldLayout\r\n inputId={inputId}\r\n label={label}\r\n required={!!required}\r\n helperText={helperText}\r\n errorMessage={showError ? errorMessage : undefined}\r\n showError={showError}\r\n fullWidth={fullWidth}\r\n formConfig={formConfig}\r\n >\r\n <div className=\"relative\">\r\n {prefix && (\r\n <div className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\">\r\n {prefix}\r\n </div>\r\n )}\r\n\r\n <TextBoxPrimitive\r\n {...props}\r\n {...field}\r\n ref={(node) => {\r\n if (typeof ref === \"function\") {\r\n ref(node);\r\n } else if (ref) {\r\n ref.current = node;\r\n }\r\n field.ref(node);\r\n }}\r\n id={inputId}\r\n disabled={effectiveDisabled}\r\n aria-invalid={hasError}\r\n aria-describedby={\r\n hasError\r\n ? `${inputId}-error`\r\n : helperText\r\n ? `${inputId}-helper`\r\n : undefined\r\n }\r\n className={cn(\r\n textBoxVariants({ size: effectiveSize, variant: effectiveVariant }),\r\n prefix && \"pl-10\",\r\n (suffix || allowClear) && \"pr-10\",\r\n className\r\n )}\r\n />\r\n\r\n {(suffix || (allowClear && field.value)) && (\r\n <div className=\"absolute right-3 top-1/2 -translate-y-1/2 flex items-center gap-1\">\r\n {allowClear && field.value && (\r\n <button\r\n type=\"button\"\r\n onClick={handleClear}\r\n className=\"text-muted-foreground hover:text-foreground transition-colors\"\r\n tabIndex={-1}\r\n aria-label=\"Clear\"\r\n >\r\n <X className=\"h-4 w-4\" />\r\n </button>\r\n )}\r\n {suffix && (\r\n <span className=\"text-muted-foreground\">{suffix}</span>\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n </FieldLayout>\r\n );\r\n}\r\n\r\n// Use forwardRef with generic support\r\nexport const TextBox = forwardRef(TextBoxInner) as <\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n props: TextBoxProps<TFieldValues, TName> & { ref?: React.ForwardedRef<HTMLInputElement> }\r\n) => React.ReactElement;\r\n\r\n(TextBox as React.FC).displayName = \"TextBox\";\r\n"],"mappings":";;;;;;;;;;;;AAYA,IAAM,mBAAA,GAAkB,yBAAA,IAAA,CACtB,IACA;CACE,UAAU;EACR,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EACA,SAAS;GACP,SAAS;GACT,OAAO;GACP,SAAS;EACX;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CACF;;;;;;;;;;;;;;;;;;;;;;AA6EA,SAAS,aAIP,EACE,MACA,OACA,YACA,YAAY,MACZ,OAAO,aACP,MACA,SACA,YAAY,MACZ,WACA,UACA,QACA,QACA,YACA,SACA,IAAI,YACJ,SAAS,iBAET,UACA,WACA,WACA,UACA,UACA,SACA,OACA,KACA,UACA,GAAG,SAEL,KACA;CACA,MAAM,eAAA,GAAc,MAAA,MAAA,CAAM;CAC1B,MAAM,UAAU,cAAc;CAG9B,MAAM,qBAAA,GAAoB,MAAA,WAAA,CAAW,gBAAA,iBAAiB;CACtD,MAAM,aAAyB,qBAAqB,CAAC;CAGrD,MAAM,cAAA,GAAa,gBAAA,eAAA,CAAgC;CACnD,MAAM,UAAU,mBAAmB,YAAY;CAI/C,MAAM,0BAA0B,mBAAmB;CACnD,MAAM,4BAA4B,mBAAmB;CAGrD,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,yBAAyB;GAC3B,MAAM,QAA8B,CAAC;GAErC,IAAI,aAAa,KAAA,GAAW,MAAM,WAAW;GAC7C,IAAI,cAAc,KAAA,GAAW,MAAM,YAAY;GAC/C,IAAI,cAAc,KAAA,GAAW,MAAM,YAAY;GAC/C,IAAI,aAAa,KAAA,GAAW,MAAM,MAAM;GACxC,IAAI,aAAa,KAAA,GAAW,MAAM,MAAM;GACxC,IAAI,YAAY,KAAA,GAAW,MAAM,UAAU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AAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA;IAGP,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAA,kBAAD;KACE,GAAI;KACJ,GAAI;KACJ,MAAM,SAAS;MACb,IAAI,OAAO,QAAQ,YACjB,IAAI,IAAI;WACH,IAAI,KACT,IAAI,UAAU;MAEhB,MAAM,IAAI,IAAI;KAChB;KACA,IAAI;KACJ,UAAU;KACV,gBAAc;KACd,oBACE,WACI,GAAG,QAAQ,UACX,aACE,GAAG,QAAQ,WACX,KAAA;KAER,WAAW,WAAA,GACT,gBAAgB;MAAE,MAAM;MAAe,SAAS;KAAiB,CAAC,GAClE,UAAU,UACT,UAAU,eAAe,SAC1B,SACF;IACD,CAAA;KAEC,UAAW,cAAc,MAAM,UAC/B,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACG,cAAc,MAAM,SACnB,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;MACE,MAAK;MACL,SAAS;MACT,WAAU;MACV,UAAU;MACV,cAAW;MAEX,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,GAAD,EAAG,WAAU,UAAW,CAAA;KAClB,CAAA,GAET,UACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;MAAM,WAAU;MAAyB,UAAA;KAAa,CAAA,CAErD;;GAEJ;;CACM,CAAA;AAEjB;AAGA,IAAa,WAAA,GAAU,MAAA,WAAA,CAAW,YAAY;AAO9C,QAAsB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.cjs","names":[],"sources":["../../../../src/components/Form/context.ts"],"sourcesContent":["'use client';\r\n\r\nimport { createContext, useCallback, useRef } from \"react\";\r\nimport type { UseFormReturn, FieldValues } from \"react-hook-form\";\r\nimport { z } from \"zod\";\r\n\r\n/**\r\n * Validation rule types that can be applied to form fields\r\n */\r\nexport interface FieldValidationRules {\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Minimum length for strings */\r\n minLength?: number | { value: number; message: string };\r\n /** Maximum length for strings */\r\n maxLength?: number | { value: number; message: string };\r\n /** Minimum value for numbers */\r\n min?: number | { value: number; message: string };\r\n /** Maximum value for numbers */\r\n max?: number | { value: number; message: string };\r\n /** Regex pattern for validation */\r\n pattern?: RegExp | { value: RegExp; message: string };\r\n /** Email validation */\r\n email?: boolean | string;\r\n /** URL validation */\r\n url?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * Form configuration options\r\n */\r\nexport interface FormConfig {\r\n /** Show validation errors inline */\r\n showInlineErrors?: boolean;\r\n /** Validate on blur */\r\n validateOnBlur?: boolean;\r\n /** Validate on change */\r\n validateOnChange?: boolean;\r\n /** Size of form controls */\r\n size?: \"sm\" | \"md\" | \"lg\";\r\n /** Layout direction */\r\n layout?: \"horizontal\" | \"vertical\" | \"inline\";\r\n /** Label width for horizontal layout */\r\n labelWidth?: string | number;\r\n /** Whether form is disabled */\r\n disabled?: boolean;\r\n /** Colon after label */\r\n colon?: boolean;\r\n}\r\n\r\n/**\r\n * Field registration info\r\n */\r\nexport interface FieldRegistration {\r\n name: string;\r\n type: \"string\" | \"number\" | \"boolean\" | \"date\" | \"array\";\r\n rules: FieldValidationRules;\r\n}\r\n\r\n/**\r\n * Form context value\r\n */\r\nexport interface FormContextValue<TFieldValues extends FieldValues = FieldValues>\r\n extends FormConfig {\r\n form: UseFormReturn<TFieldValues>;\r\n /** Register a field's validation rules */\r\n registerFieldValidation: (field: FieldRegistration) => void;\r\n /** Unregister a field's validation rules */\r\n unregisterFieldValidation: (name: string) => void;\r\n /** Get current validation schema */\r\n getValidationSchema: () => z.ZodObject<Record<string, z.ZodTypeAny>>;\r\n /** Trigger validation for a specific field */\r\n triggerValidation: (name: string) => Promise<boolean>;\r\n}\r\n\r\n/**\r\n * Default form configuration\r\n */\r\nexport const defaultFormConfig: FormConfig = {\r\n showInlineErrors: true,\r\n validateOnBlur: true,\r\n validateOnChange: false,\r\n size: \"md\",\r\n layout: \"vertical\",\r\n disabled: false,\r\n colon: true,\r\n};\r\n\r\n/**\r\n * Form context for sharing form state and configuration\r\n */\r\nexport const FormConfigContext = createContext<FormContextValue | null>(null);\r\n\r\n/**\r\n * Build a Zod schema from validation rules\r\n */\r\nexport function buildZodSchemaFromRules(\r\n type: FieldRegistration[\"type\"],\r\n rules: FieldValidationRules\r\n): z.ZodTypeAny {\r\n // Helper to extract value and message\r\n const getValueAndMessage = <T>(\r\n rule: T | { value: T; message: string } | undefined,\r\n defaultMessage: string\r\n ): { value: T; message: string } | null => {\r\n if (rule === undefined) return null;\r\n if (typeof rule === \"object\" && rule !== null && \"value\" in rule) {\r\n return rule as { value: T; message: string };\r\n }\r\n return { value: rule as T, message: defaultMessage };\r\n };\r\n\r\n // Build string schema\r\n if (type === \"string\") {\r\n let schema = z.string();\r\n\r\n const minLengthRule = getValueAndMessage(\r\n rules.minLength,\r\n `Minimum ${typeof rules.minLength === \"number\" ? rules.minLength : (rules.minLength as { value: number })?.value} characters required`\r\n );\r\n if (minLengthRule) {\r\n schema = schema.min(minLengthRule.value as number, minLengthRule.message);\r\n }\r\n\r\n const maxLengthRule = getValueAndMessage(\r\n rules.maxLength,\r\n `Maximum ${typeof rules.maxLength === \"number\" ? rules.maxLength : (rules.maxLength as { value: number })?.value} characters allowed`\r\n );\r\n if (maxLengthRule) {\r\n schema = schema.max(maxLengthRule.value as number, maxLengthRule.message);\r\n }\r\n\r\n if (rules.pattern !== undefined) {\r\n const patternRule = rules.pattern instanceof RegExp\r\n ? { value: rules.pattern, message: \"Invalid format\" }\r\n : rules.pattern;\r\n schema = schema.regex(patternRule.value, patternRule.message);\r\n }\r\n\r\n if (rules.email) {\r\n const message = typeof rules.email === \"string\" ? rules.email : \"Invalid email address\";\r\n schema = schema.email(message);\r\n }\r\n\r\n if (rules.url) {\r\n const message = typeof rules.url === \"string\" ? rules.url : \"Invalid URL\";\r\n schema = schema.url(message);\r\n }\r\n\r\n // Handle required - for strings, require non-empty\r\n if (rules.required) {\r\n const message = typeof rules.required === \"string\" ? rules.required : \"This field is required\";\r\n return finalizeSchema(\r\n z.preprocess(\r\n (value) => (value === undefined || value === null ? \"\" : value),\r\n schema.min(1, message)\r\n ),\r\n rules\r\n );\r\n }\r\n\r\n return finalizeSchema(schema.optional(), rules);\r\n }\r\n\r\n // Build number schema\r\n if (type === \"number\") {\r\n let schema = z.coerce.number();\r\n\r\n const minRule = getValueAndMessage(\r\n rules.min,\r\n `Minimum value is ${typeof rules.min === \"number\" ? rules.min : (rules.min as { value: number })?.value}`\r\n );\r\n if (minRule) {\r\n schema = schema.min(minRule.value as number, minRule.message);\r\n }\r\n\r\n const maxRule = getValueAndMessage(\r\n rules.max,\r\n `Maximum value is ${typeof rules.max === \"number\" ? rules.max : (rules.max as { value: number })?.value}`\r\n );\r\n if (maxRule) {\r\n schema = schema.max(maxRule.value as number, maxRule.message);\r\n }\r\n\r\n if (!rules.required) {\r\n return finalizeSchema(schema.optional(), rules);\r\n }\r\n return finalizeSchema(schema, rules);\r\n }\r\n\r\n // Build boolean schema\r\n if (type === \"boolean\") {\r\n const schema = z.boolean();\r\n if (rules.required) {\r\n return finalizeSchema(\r\n schema.refine((val) => val === true, {\r\n message: typeof rules.required === \"string\" ? rules.required : \"This field is required\",\r\n }),\r\n rules\r\n );\r\n }\r\n return finalizeSchema(schema.optional(), rules);\r\n }\r\n\r\n // Build date schema\r\n if (type === \"date\") {\r\n const schema = z.coerce.date();\r\n if (!rules.required) {\r\n return finalizeSchema(schema.optional(), rules);\r\n }\r\n return finalizeSchema(schema, rules);\r\n }\r\n\r\n // Build array schema\r\n if (type === \"array\") {\r\n let schema = z.array(z.unknown());\r\n if (rules.required) {\r\n const message = typeof rules.required === \"string\" ? rules.required : \"This field is required\";\r\n schema = schema.min(1, message);\r\n }\r\n return finalizeSchema(schema, rules);\r\n }\r\n\r\n // Default fallback\r\n return finalizeSchema(z.unknown(), rules);\r\n}\r\n\r\nfunction applyCustomValidate(\r\n schema: z.ZodTypeAny,\r\n rules: FieldValidationRules\r\n): z.ZodTypeAny {\r\n if (!rules.validate) {\r\n return schema;\r\n }\r\n\r\n const validateFn = rules.validate;\r\n\r\n return schema.superRefine(async (value, ctx) => {\r\n const result = await validateFn(value);\r\n\r\n if (result === true) {\r\n return;\r\n }\r\n\r\n ctx.addIssue({\r\n code: z.ZodIssueCode.custom,\r\n message: typeof result === \"string\" ? result : \"Invalid value\",\r\n });\r\n });\r\n}\r\n\r\nfunction finalizeSchema(\r\n schema: z.ZodTypeAny,\r\n rules: FieldValidationRules\r\n): z.ZodTypeAny {\r\n return applyCustomValidate(schema, rules);\r\n}\r\n\r\n/**\r\n * Hook to manage field validations\r\n */\r\nexport function useFieldValidationRegistry() {\r\n const fieldsRef = useRef<Map<string, FieldRegistration>>(new Map());\r\n\r\n const registerFieldValidation = useCallback((field: FieldRegistration) => {\r\n fieldsRef.current.set(field.name, field);\r\n }, []);\r\n\r\n const unregisterFieldValidation = useCallback((name: string) => {\r\n fieldsRef.current.delete(name);\r\n }, []);\r\n\r\n const getValidationSchema = useCallback(() => {\r\n const shape: Record<string, z.ZodTypeAny> = {};\r\n \r\n fieldsRef.current.forEach((field) => {\r\n shape[field.name] = buildZodSchemaFromRules(field.type, field.rules);\r\n });\r\n\r\n return z.object(shape);\r\n }, []);\r\n\r\n return {\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n getValidationSchema,\r\n fieldsRef,\r\n };\r\n}\r\n"],"mappings":";;;;;;;;AAgFA,IAAa,oBAAgC;CAC3C,kBAAkB;CAClB,gBAAgB;CAChB,kBAAkB;CAClB,MAAM;CACN,QAAQ;CACR,UAAU;CACV,OAAO;AACT;;;;AAKA,IAAa,qBAAA,GAAA,MAAA,cAAA,CAA2D,IAAI;;;;AAK5E,SAAgB,wBACd,MACA,OACc;CAEd,MAAM,sBACJ,MACA,mBACyC;EACzC,IAAI,SAAS,KAAA,GAAW,OAAO;EA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AM;CAEzB,OAAO,OAAO,YAAY,OAAO,OAAO,QAAQ;EAC9C,MAAM,SAAS,MAAM,WAAW,KAAK;EAErC,IAAI,WAAW,MACb;EAGF,IAAI,SAAS;GACX,MAAM,IAAA,EAAE,aAAa;GACrB,SAAS,OAAO,WAAW,WAAW,SAAS;EACjD,CAAC;CACH,CAAC;AACH;AAEA,SAAS,eACP,QACA,OACc;CACd,OAAO,oBAAoB,QAAQ,KAAK;AAC1C;;;;AAKA,SAAgB,6BAA6B;CAC3C,MAAM,aAAA,GAAA,MAAA,OAAA,iBAAmD,IAAI,IAAI,CAAC;CAoBlE,OAAO;EACL,0BAAA,GAAA,MAAA,YAAA,EAnB2C,UAA6B;GACxE,UAAU,QAAQ,IAAI,MAAM,MAAM,KAAK;EACzC,GAAG,CAAC,CAiBF;EACA,4BAAA,GAAA,MAAA,YAAA,EAhB6C,SAAiB;GAC9D,UAAU,QAAQ,OAAO,IAAI;EAC/B,GAAG,CAAC,CAcF;EACA,sBAAA,GAAA,MAAA,YAAA,OAb4C;GAC5C,MAAM,QAAsC,CAAC;GAE7C,UAAU,QAAQ,SAAS,UAAU;IACnC,MAAM,MAAM,QAAQ,wBAAwB,MAAM,MAAM,MAAM,KAAK;GACrE,CAAC;GAED,OAAO,IAAA,EAAE,OAAO,KAAK;EACvB,GAAG,CAAC,CAKF;EACA;CACF;AACF"}
1
+ {"version":3,"file":"context.cjs","names":[],"sources":["../../../../src/components/Form/context.ts"],"sourcesContent":["'use client';\r\n\r\nimport { createContext, useCallback, useRef } from \"react\";\r\nimport type { UseFormReturn, FieldValues } from \"react-hook-form\";\r\nimport { z } from \"zod\";\r\n\r\n/**\r\n * Validation rule types that can be applied to form fields\r\n */\r\nexport interface FieldValidationRules {\r\n /** Field is required */\r\n required?: boolean | string;\r\n /** Minimum length for strings */\r\n minLength?: number | { value: number; message: string };\r\n /** Maximum length for strings */\r\n maxLength?: number | { value: number; message: string };\r\n /** Minimum value for numbers */\r\n min?: number | { value: number; message: string };\r\n /** Maximum value for numbers */\r\n max?: number | { value: number; message: string };\r\n /** Regex pattern for validation */\r\n pattern?: RegExp | { value: RegExp; message: string };\r\n /** Email validation */\r\n email?: boolean | string;\r\n /** URL validation */\r\n url?: boolean | string;\r\n /** Custom validation function */\r\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\r\n}\r\n\r\n/**\r\n * Form configuration options\r\n */\r\nexport interface FormConfig {\r\n /** Show validation errors inline */\r\n showInlineErrors?: boolean;\r\n /** Validate on blur */\r\n validateOnBlur?: boolean;\r\n /** Validate on change */\r\n validateOnChange?: boolean;\r\n /** Size of form controls */\r\n size?: \"sm\" | \"md\" | \"lg\";\r\n /** Layout direction */\r\n layout?: \"horizontal\" | \"vertical\" | \"inline\";\r\n /** Label width for horizontal layout */\r\n labelWidth?: string | number;\r\n /** Whether form is disabled */\r\n disabled?: boolean;\r\n /** Colon after label */\r\n colon?: boolean;\r\n}\r\n\r\n/**\r\n * Field registration info\r\n */\r\nexport interface FieldRegistration {\r\n name: string;\r\n type: \"string\" | \"number\" | \"boolean\" | \"date\" | \"array\";\r\n rules: FieldValidationRules;\r\n}\r\n\r\n/**\r\n * Form context value\r\n */\r\nexport interface FormContextValue<TFieldValues extends FieldValues = FieldValues>\r\n extends FormConfig {\r\n form: UseFormReturn<TFieldValues>;\r\n /** Register a field's validation rules */\r\n registerFieldValidation: (field: FieldRegistration) => void;\r\n /** Unregister a field's validation rules */\r\n unregisterFieldValidation: (name: string) => void;\r\n /** Get current validation schema */\r\n getValidationSchema: () => z.ZodObject<Record<string, z.ZodTypeAny>>;\r\n /** Trigger validation for a specific field */\r\n triggerValidation: (name: string) => Promise<boolean>;\r\n}\r\n\r\n/**\r\n * Default form configuration\r\n */\r\nexport const defaultFormConfig: FormConfig = {\r\n showInlineErrors: true,\r\n validateOnBlur: true,\r\n validateOnChange: false,\r\n size: \"md\",\r\n layout: \"vertical\",\r\n disabled: false,\r\n colon: true,\r\n};\r\n\r\n/**\r\n * Form context for sharing form state and configuration\r\n */\r\nexport const FormConfigContext = createContext<FormContextValue | null>(null);\r\n\r\n/**\r\n * Build a Zod schema from validation rules\r\n */\r\nexport function buildZodSchemaFromRules(\r\n type: FieldRegistration[\"type\"],\r\n rules: FieldValidationRules\r\n): z.ZodTypeAny {\r\n // Helper to extract value and message\r\n const getValueAndMessage = <T>(\r\n rule: T | { value: T; message: string } | undefined,\r\n defaultMessage: string\r\n ): { value: T; message: string } | null => {\r\n if (rule === undefined) return null;\r\n if (typeof rule === \"object\" && rule !== null && \"value\" in rule) {\r\n return rule as { value: T; message: string };\r\n }\r\n return { value: rule as T, message: defaultMessage };\r\n };\r\n\r\n // Build string schema\r\n if (type === \"string\") {\r\n let schema = z.string();\r\n\r\n const minLengthRule = getValueAndMessage(\r\n rules.minLength,\r\n `Minimum ${typeof rules.minLength === \"number\" ? rules.minLength : (rules.minLength as { value: number })?.value} characters required`\r\n );\r\n if (minLengthRule) {\r\n schema = schema.min(minLengthRule.value as number, minLengthRule.message);\r\n }\r\n\r\n const maxLengthRule = getValueAndMessage(\r\n rules.maxLength,\r\n `Maximum ${typeof rules.maxLength === \"number\" ? rules.maxLength : (rules.maxLength as { value: number })?.value} characters allowed`\r\n );\r\n if (maxLengthRule) {\r\n schema = schema.max(maxLengthRule.value as number, maxLengthRule.message);\r\n }\r\n\r\n if (rules.pattern !== undefined) {\r\n const patternRule = rules.pattern instanceof RegExp\r\n ? { value: rules.pattern, message: \"Invalid format\" }\r\n : rules.pattern;\r\n schema = schema.regex(patternRule.value, patternRule.message);\r\n }\r\n\r\n if (rules.email) {\r\n const message = typeof rules.email === \"string\" ? rules.email : \"Invalid email address\";\r\n schema = schema.email(message);\r\n }\r\n\r\n if (rules.url) {\r\n const message = typeof rules.url === \"string\" ? rules.url : \"Invalid URL\";\r\n schema = schema.url(message);\r\n }\r\n\r\n // Handle required - for strings, require non-empty\r\n if (rules.required) {\r\n const message = typeof rules.required === \"string\" ? rules.required : \"This field is required\";\r\n return finalizeSchema(\r\n z.preprocess(\r\n (value) => (value === undefined || value === null ? \"\" : value),\r\n schema.min(1, message)\r\n ),\r\n rules\r\n );\r\n }\r\n\r\n return finalizeSchema(schema.optional(), rules);\r\n }\r\n\r\n // Build number schema\r\n if (type === \"number\") {\r\n let schema = z.coerce.number();\r\n\r\n const minRule = getValueAndMessage(\r\n rules.min,\r\n `Minimum value is ${typeof rules.min === \"number\" ? rules.min : (rules.min as { value: number })?.value}`\r\n );\r\n if (minRule) {\r\n schema = schema.min(minRule.value as number, minRule.message);\r\n }\r\n\r\n const maxRule = getValueAndMessage(\r\n rules.max,\r\n `Maximum value is ${typeof rules.max === \"number\" ? rules.max : (rules.max as { value: number })?.value}`\r\n );\r\n if (maxRule) {\r\n schema = schema.max(maxRule.value as number, maxRule.message);\r\n }\r\n\r\n if (!rules.required) {\r\n return finalizeSchema(schema.optional(), rules);\r\n }\r\n return finalizeSchema(schema, rules);\r\n }\r\n\r\n // Build boolean schema\r\n if (type === \"boolean\") {\r\n const schema = z.boolean();\r\n if (rules.required) {\r\n return finalizeSchema(\r\n schema.refine((val) => val === true, {\r\n message: typeof rules.required === \"string\" ? rules.required : \"This field is required\",\r\n }),\r\n rules\r\n );\r\n }\r\n return finalizeSchema(schema.optional(), rules);\r\n }\r\n\r\n // Build date schema\r\n if (type === \"date\") {\r\n const schema = z.coerce.date();\r\n if (!rules.required) {\r\n return finalizeSchema(schema.optional(), rules);\r\n }\r\n return finalizeSchema(schema, rules);\r\n }\r\n\r\n // Build array schema\r\n if (type === \"array\") {\r\n let schema = z.array(z.unknown());\r\n if (rules.required) {\r\n const message = typeof rules.required === \"string\" ? rules.required : \"This field is required\";\r\n schema = schema.min(1, message);\r\n }\r\n return finalizeSchema(schema, rules);\r\n }\r\n\r\n // Default fallback\r\n return finalizeSchema(z.unknown(), rules);\r\n}\r\n\r\nfunction applyCustomValidate(\r\n schema: z.ZodTypeAny,\r\n rules: FieldValidationRules\r\n): z.ZodTypeAny {\r\n if (!rules.validate) {\r\n return schema;\r\n }\r\n\r\n const validateFn = rules.validate;\r\n\r\n return schema.superRefine(async (value, ctx) => {\r\n const result = await validateFn(value);\r\n\r\n if (result === true) {\r\n return;\r\n }\r\n\r\n ctx.addIssue({\r\n code: z.ZodIssueCode.custom,\r\n message: typeof result === \"string\" ? result : \"Invalid value\",\r\n });\r\n });\r\n}\r\n\r\nfunction finalizeSchema(\r\n schema: z.ZodTypeAny,\r\n rules: FieldValidationRules\r\n): z.ZodTypeAny {\r\n return applyCustomValidate(schema, rules);\r\n}\r\n\r\n/**\r\n * Hook to manage field validations\r\n */\r\nexport function useFieldValidationRegistry() {\r\n const fieldsRef = useRef<Map<string, FieldRegistration>>(new Map());\r\n\r\n const registerFieldValidation = useCallback((field: FieldRegistration) => {\r\n fieldsRef.current.set(field.name, field);\r\n }, []);\r\n\r\n const unregisterFieldValidation = useCallback((name: string) => {\r\n fieldsRef.current.delete(name);\r\n }, []);\r\n\r\n const getValidationSchema = useCallback(() => {\r\n const shape: Record<string, z.ZodTypeAny> = {};\r\n \r\n fieldsRef.current.forEach((field) => {\r\n shape[field.name] = buildZodSchemaFromRules(field.type, field.rules);\r\n });\r\n\r\n return z.object(shape);\r\n }, []);\r\n\r\n return {\r\n registerFieldValidation,\r\n unregisterFieldValidation,\r\n getValidationSchema,\r\n fieldsRef,\r\n };\r\n}\r\n"],"mappings":";;;;;;;;AAgFA,IAAa,oBAAgC;CAC3C,kBAAkB;CAClB,gBAAgB;CAChB,kBAAkB;CAClB,MAAM;CACN,QAAQ;CACR,UAAU;CACV,OAAO;AACT;;;;AAKA,IAAa,qBAAA,GAAoB,MAAA,cAAA,CAAuC,IAAI;;;;AAK5E,SAAgB,wBACd,MACA,OACc;CAEd,MAAM,sBACJ,MACA,mBACyC;EACzC,IAAI,SAAS,KAAA,GAAW,OAAO;EAC/B,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,WAAW,MAC1D,OAAO;EAET,OAAO;GAAE,OAAO;GAAW,SAAS;EAAe;CACrD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;EAGF,IAAI,SAAS;GACX,MAAM,IAAA,EAAE,aAAa;GACrB,SAAS,OAAO,WAAW,WAAW,SAAS;EACjD,CAAC;CACH,CAAC;AACH;AAEA,SAAS,eACP,QACA,OACc;CACd,OAAO,oBAAoB,QAAQ,KAAK;AAC1C;;;;AAKA,SAAgB,6BAA6B;CAC3C,MAAM,aAAA,GAAY,MAAA,OAAA,iBAAuC,IAAI,IAAI,CAAC;CAoBlE,OAAO;EACL,0BAAA,GAnB8B,MAAA,YAAA,EAAa,UAA6B;GACxE,UAAU,QAAQ,IAAI,MAAM,MAAM,KAAK;EACzC,GAAG,CAAC,CAiBF;EACA,4BAAA,GAhBgC,MAAA,YAAA,EAAa,SAAiB;GAC9D,UAAU,QAAQ,OAAO,IAAI;EAC/B,GAAG,CAAC,CAcF;EACA,sBAAA,GAb0B,MAAA,YAAA,OAAkB;GAC5C,MAAM,QAAsC,CAAC;GAE7C,UAAU,QAAQ,SAAS,UAAU;IACnC,MAAM,MAAM,QAAQ,wBAAwB,MAAM,MAAM,MAAM,KAAK;GACrE,CAAC;GAED,OAAO,IAAA,EAAE,OAAO,KAAK;EACvB,GAAG,CAAC,CAKF;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","names":[],"sources":["../../../../src/components/Form/hooks.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useContext } from \"react\";\r\nimport {\r\n useFormContext as useRHFFormContext,\r\n useController,\r\n type FieldValues,\r\n type FieldPath,\r\n type UseControllerProps,\r\n type UseControllerReturn,\r\n} from \"react-hook-form\";\r\nimport { FormConfigContext, type FormContextValue, type FormConfig } from \"./context\";\r\n\r\n/**\r\n * Hook to access form configuration context\r\n */\r\nexport function useFormConfig<TFieldValues extends FieldValues = FieldValues>(): FormContextValue<TFieldValues> {\r\n const context = useContext(FormConfigContext) as FormContextValue<TFieldValues> | null;\r\n if (!context) {\r\n throw new Error(\"useFormConfig must be used within a Form component\");\r\n }\r\n return context;\r\n}\r\n\r\n/**\r\n * Hook to access react-hook-form context directly\r\n */\r\nexport function useForm<TFieldValues extends FieldValues = FieldValues>() {\r\n return useRHFFormContext<TFieldValues>();\r\n}\r\n\r\n/**\r\n * Hook to create a controlled field with form context awareness\r\n */\r\nexport function useFormField<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n props: UseControllerProps<TFieldValues, TName>\r\n): UseControllerReturn<TFieldValues, TName> & { config: FormConfig } {\r\n const { form, ...config } = useFormConfig<TFieldValues>();\r\n const controller = useController<TFieldValues, TName>({\r\n ...props,\r\n control: form.control,\r\n });\r\n\r\n return {\r\n ...controller,\r\n config,\r\n };\r\n}\r\n\r\n/**\r\n * Hook to get field error\r\n */\r\nexport function useFieldError<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(name: TName): string | undefined {\r\n const { form } = useFormConfig<TFieldValues>();\r\n const error = form.formState.errors[name];\r\n return error?.message as string | undefined;\r\n}\r\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,gBAAgG;CAC9G,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,gBAAA,iBAAiB;CAC5C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,oDAAoD;CAEtE,OAAO;AACT;;;;AAKA,SAAgB,UAA0D;CACxE,QAAA,GAAA,gBAAA,eAAA,CAAuC;AACzC;;;;AAKA,SAAgB,aAId,OACmE;CACnE,MAAM,EAAE,MAAM,GAAG,WAAW,cAA4B;CAMxD,OAAO;EACL,IAAA,GAAA,gBAAA,cAAA,CANoD;GACpD,GAAG;GACH,SAAS,KAAK;EAChB,CAGK;EACH;CACF;AACF;;;;AAKA,SAAgB,cAGd,MAAiC;CACjC,MAAM,EAAE,SAAS,cAA4B;CAE7C,OADc,KAAK,UAAU,OAAO,KAC7B,EAAO;AAChB"}
1
+ {"version":3,"file":"hooks.cjs","names":[],"sources":["../../../../src/components/Form/hooks.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useContext } from \"react\";\r\nimport {\r\n useFormContext as useRHFFormContext,\r\n useController,\r\n type FieldValues,\r\n type FieldPath,\r\n type UseControllerProps,\r\n type UseControllerReturn,\r\n} from \"react-hook-form\";\r\nimport { FormConfigContext, type FormContextValue, type FormConfig } from \"./context\";\r\n\r\n/**\r\n * Hook to access form configuration context\r\n */\r\nexport function useFormConfig<TFieldValues extends FieldValues = FieldValues>(): FormContextValue<TFieldValues> {\r\n const context = useContext(FormConfigContext) as FormContextValue<TFieldValues> | null;\r\n if (!context) {\r\n throw new Error(\"useFormConfig must be used within a Form component\");\r\n }\r\n return context;\r\n}\r\n\r\n/**\r\n * Hook to access react-hook-form context directly\r\n */\r\nexport function useForm<TFieldValues extends FieldValues = FieldValues>() {\r\n return useRHFFormContext<TFieldValues>();\r\n}\r\n\r\n/**\r\n * Hook to create a controlled field with form context awareness\r\n */\r\nexport function useFormField<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(\r\n props: UseControllerProps<TFieldValues, TName>\r\n): UseControllerReturn<TFieldValues, TName> & { config: FormConfig } {\r\n const { form, ...config } = useFormConfig<TFieldValues>();\r\n const controller = useController<TFieldValues, TName>({\r\n ...props,\r\n control: form.control,\r\n });\r\n\r\n return {\r\n ...controller,\r\n config,\r\n };\r\n}\r\n\r\n/**\r\n * Hook to get field error\r\n */\r\nexport function useFieldError<\r\n TFieldValues extends FieldValues = FieldValues,\r\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\r\n>(name: TName): string | undefined {\r\n const { form } = useFormConfig<TFieldValues>();\r\n const error = form.formState.errors[name];\r\n return error?.message as string | undefined;\r\n}\r\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,gBAAgG;CAC9G,MAAM,WAAA,GAAU,MAAA,WAAA,CAAW,gBAAA,iBAAiB;CAC5C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,oDAAoD;CAEtE,OAAO;AACT;;;;AAKA,SAAgB,UAA0D;CACxE,QAAA,GAAO,gBAAA,eAAA,CAAgC;AACzC;;;;AAKA,SAAgB,aAId,OACmE;CACnE,MAAM,EAAE,MAAM,GAAG,WAAW,cAA4B;CAMxD,OAAO;EACL,IAAA,GANiB,gBAAA,cAAA,CAAmC;GACpD,GAAG;GACH,SAAS,KAAK;EAChB,CAGK;EACH;CACF;AACF;;;;AAKA,SAAgB,cAGd,MAAiC;CACjC,MAAM,EAAE,SAAS,cAA4B;CAE7C,OADc,KAAK,UAAU,OAAO,KAC7B,EAAO;AAChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"variants.cjs","names":[],"sources":["../../../../src/components/Form/variants.ts"],"sourcesContent":["import { cva } from \"class-variance-authority\";\r\n\r\n/**\r\n * Shared label variant for all form field components.\r\n * Shows a required asterisk when required=true.\r\n */\r\nexport const labelVariants = cva(\"block text-sm font-medium mb-1.5\", {\r\n variants: {\r\n required: {\r\n true: \"after:content-['*'] after:ml-0.5 after:text-destructive\",\r\n false: \"\",\r\n },\r\n },\r\n defaultVariants: {\r\n required: false,\r\n },\r\n});\r\n"],"mappings":";;;;;;AAMA,IAAa,iBAAA,qCAAA,CAAA,CAAA,IAAA,CAAoB,oCAAoC;CACnE,UAAU,EACR,UAAU;EACR,MAAM;EACN,OAAO;CACT,EACF;CACA,iBAAiB,EACf,UAAU,MACZ;AACF,CAAC"}
1
+ {"version":3,"file":"variants.cjs","names":[],"sources":["../../../../src/components/Form/variants.ts"],"sourcesContent":["import { cva } from \"class-variance-authority\";\r\n\r\n/**\r\n * Shared label variant for all form field components.\r\n * Shows a required asterisk when required=true.\r\n */\r\nexport const labelVariants = cva(\"block text-sm font-medium mb-1.5\", {\r\n variants: {\r\n required: {\r\n true: \"after:content-['*'] after:ml-0.5 after:text-destructive\",\r\n false: \"\",\r\n },\r\n },\r\n defaultVariants: {\r\n required: false,\r\n },\r\n});\r\n"],"mappings":";;;;;;AAMA,IAAa,iBAAA,qCAAgB,CAAA,CAAA,IAAA,CAAI,oCAAoC;CACnE,UAAU,EACR,UAAU;EACR,MAAM;EACN,OAAO;CACT,EACF;CACA,iBAAiB,EACf,UAAU,MACZ;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Input.cjs","names":[],"sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { Input as InputPrimitive } from \"../../primitives/input\"\r\n\r\nexport type InputProps = ComponentPropsWithoutRef<typeof InputPrimitive>\r\n\r\nexport const Input = forwardRef<\r\n ElementRef<typeof InputPrimitive>,\r\n InputProps\r\n>((props, ref) => <InputPrimitive ref={ref} {...props} />)\r\nInput.displayName = \"Input\"\r\n"],"mappings":";;;;;AAMA,IAAa,SAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAA,kBAAD;CAAqB;CAAK,GAAI;AAAQ,CAAA,CAAC;AACzD,MAAM,cAAc"}
1
+ {"version":3,"file":"Input.cjs","names":[],"sources":["../../../../src/components/Input/Input.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { Input as InputPrimitive } from \"../../primitives/input\"\r\n\r\nexport type InputProps = ComponentPropsWithoutRef<typeof InputPrimitive>\r\n\r\nexport const Input = forwardRef<\r\n ElementRef<typeof InputPrimitive>,\r\n InputProps\r\n>((props, ref) => <InputPrimitive ref={ref} {...props} />)\r\nInput.displayName = \"Input\"\r\n"],"mappings":";;;;;AAMA,IAAa,SAAA,GAAQ,MAAA,WAAA,EAGlB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAA,kBAAD;CAAqB;CAAK,GAAI;AAAQ,CAAA,CAAC;AACzD,MAAM,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Label.cjs","names":[],"sources":["../../../../src/components/Label/Label.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { Label as LabelPrimitive } from \"../../primitives/label\"\r\n\r\nexport type LabelProps = ComponentPropsWithoutRef<typeof LabelPrimitive>\r\n\r\nexport const Label = forwardRef<\r\n ElementRef<typeof LabelPrimitive>,\r\n LabelProps\r\n>((props, ref) => <LabelPrimitive ref={ref} {...props} />)\r\nLabel.displayName = \"Label\"\r\n"],"mappings":";;;;;AAMA,IAAa,SAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAA,OAAD;CAAqB;CAAK,GAAI;AAAQ,CAAA,CAAC;AACzD,MAAM,cAAc"}
1
+ {"version":3,"file":"Label.cjs","names":[],"sources":["../../../../src/components/Label/Label.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { Label as LabelPrimitive } from \"../../primitives/label\"\r\n\r\nexport type LabelProps = ComponentPropsWithoutRef<typeof LabelPrimitive>\r\n\r\nexport const Label = forwardRef<\r\n ElementRef<typeof LabelPrimitive>,\r\n LabelProps\r\n>((props, ref) => <LabelPrimitive ref={ref} {...props} />)\r\nLabel.displayName = \"Label\"\r\n"],"mappings":";;;;;AAMA,IAAa,SAAA,GAAQ,MAAA,WAAA,EAGlB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAA,OAAD;CAAqB;CAAK,GAAI;AAAQ,CAAA,CAAC;AACzD,MAAM,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Pagination.cjs","names":[],"sources":["../../../../src/components/Pagination/Pagination.tsx"],"sourcesContent":["import * as React from \"react\"\r\nimport { ChevronLeft, ChevronRight, MoreHorizontal } from \"lucide-react\"\r\nimport { cn } from \"../../utils/cn\"\r\nimport { ButtonPrimitive, buttonVariants } from \"../../primitives/button\"\r\n\r\nconst Pagination = ({ className, ...props }: React.ComponentProps<\"nav\">) => (\r\n <nav\r\n role=\"navigation\"\r\n aria-label=\"pagination\"\r\n className={cn(\"mx-auto flex w-full justify-center\", className)}\r\n {...props}\r\n />\r\n)\r\nPagination.displayName = \"Pagination\"\r\n\r\nconst PaginationContent = React.forwardRef<\r\n HTMLUListElement,\r\n React.ComponentProps<\"ul\">\r\n>(({ className, ...props }, ref) => (\r\n <ul\r\n ref={ref}\r\n className={cn(\"flex flex-row items-center gap-1\", className)}\r\n {...props}\r\n />\r\n))\r\nPaginationContent.displayName = \"PaginationContent\"\r\n\r\nconst PaginationItem = React.forwardRef<\r\n HTMLLIElement,\r\n React.ComponentProps<\"li\">\r\n>(({ className, ...props }, ref) => (\r\n <li ref={ref} className={cn(\"\", className)} {...props} />\r\n))\r\nPaginationItem.displayName = \"PaginationItem\"\r\n\r\ntype PaginationLinkProps = {\r\n isActive?: boolean\r\n} & Pick<React.ComponentProps<typeof ButtonPrimitive>, \"size\"> &\r\n React.ComponentProps<\"a\">\r\n\r\nconst PaginationLink = ({ className, isActive, size = \"icon\", ...props }: PaginationLinkProps) => (\r\n <a\r\n aria-current={isActive ? \"page\" : undefined}\r\n className={cn(\r\n buttonVariants({\r\n variant: isActive ? \"outline\" : \"ghost\",\r\n size,\r\n }),\r\n className\r\n )}\r\n {...props}\r\n />\r\n)\r\nPaginationLink.displayName = \"PaginationLink\"\r\n\r\nconst PaginationPrevious = ({ className, size = \"default\", ...props }: React.ComponentProps<typeof PaginationLink>) => (\r\n <PaginationLink\r\n aria-label=\"Go to previous page\"\r\n className={cn(\"gap-1 pl-2.5\", className)}\r\n size={size}\r\n {...props}\r\n >\r\n <ChevronLeft className=\"h-4 w-4\" />\r\n <span>Previous</span>\r\n </PaginationLink>\r\n)\r\nPaginationPrevious.displayName = \"PaginationPrevious\"\r\n\r\nconst PaginationNext = ({ className, size = \"default\", ...props }: React.ComponentProps<typeof PaginationLink>) => (\r\n <PaginationLink\r\n aria-label=\"Go to next page\"\r\n className={cn(\"gap-1 pr-2.5\", className)}\r\n size={size}\r\n {...props}\r\n >\r\n <span>Next</span>\r\n <ChevronRight className=\"h-4 w-4\" />\r\n </PaginationLink>\r\n)\r\nPaginationNext.displayName = \"PaginationNext\"\r\n\r\nconst PaginationEllipsis = ({ className, ...props }: React.ComponentProps<\"span\">) => (\r\n <span\r\n aria-hidden\r\n className={cn(\"flex h-9 w-9 items-center justify-center\", className)}\r\n {...props}\r\n >\r\n <MoreHorizontal className=\"h-4 w-4\" />\r\n <span className=\"sr-only\">More pages</span>\r\n </span>\r\n)\r\nPaginationEllipsis.displayName = \"PaginationEllipsis\"\r\n\r\nexport {\r\n Pagination,\r\n PaginationContent,\r\n PaginationItem,\r\n PaginationLink,\r\n PaginationNext,\r\n PaginationPrevious,\r\n PaginationEllipsis,\r\n}\r\n"],"mappings":";;;;;;;;;AAKA,IAAM,cAAc,EAAE,WAAW,GAAG,YAClC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;CACE,MAAK;CACL,cAAW;CACX,WAAW,WAAA,GAAG,sCAAsC,SAAS;CAC7D,GAAI;AACL,CAAA;AAEH,WAAW,cAAc;AAEzB,IAAM,oBAAoB,MAAM,YAG7B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;CACO;CACL,WAAW,WAAA,GAAG,oCAAoC,SAAS;CAC3D,GAAI;AACL,CAAA,CACF;AACD,kBAAkB,cAAc;AAEhC,IAAM,iBAAiB,MAAM,YAG1B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;CAAS;CAAK,WAAW,WAAA,GAAG,IAAI,SAAS;CAAG,GAAI;AAAQ,CAAA,CACzD;AACD,eAAe,cAAc;AAO7B,IAAM,kBAAkB,EAAE,WAAW,UAAU,OAAO,QAAQ,GAAG,YAC/D,iBAAA,GAAA,kBAAA,IAAA,CAAC,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],"sourcesContent":["import * as React from \"react\"\r\nimport { ChevronLeft, ChevronRight, MoreHorizontal } from \"lucide-react\"\r\nimport { cn } from \"../../utils/cn\"\r\nimport { ButtonPrimitive, buttonVariants } from \"../../primitives/button\"\r\n\r\nconst Pagination = ({ className, ...props }: React.ComponentProps<\"nav\">) => (\r\n <nav\r\n role=\"navigation\"\r\n aria-label=\"pagination\"\r\n className={cn(\"mx-auto flex w-full justify-center\", className)}\r\n {...props}\r\n />\r\n)\r\nPagination.displayName = \"Pagination\"\r\n\r\nconst PaginationContent = React.forwardRef<\r\n HTMLUListElement,\r\n React.ComponentProps<\"ul\">\r\n>(({ className, ...props }, ref) => (\r\n <ul\r\n ref={ref}\r\n className={cn(\"flex flex-row items-center gap-1\", className)}\r\n {...props}\r\n />\r\n))\r\nPaginationContent.displayName = \"PaginationContent\"\r\n\r\nconst PaginationItem = React.forwardRef<\r\n HTMLLIElement,\r\n React.ComponentProps<\"li\">\r\n>(({ className, ...props }, ref) => (\r\n <li ref={ref} className={cn(\"\", className)} {...props} />\r\n))\r\nPaginationItem.displayName = \"PaginationItem\"\r\n\r\ntype PaginationLinkProps = {\r\n isActive?: boolean\r\n} & Pick<React.ComponentProps<typeof ButtonPrimitive>, \"size\"> &\r\n React.ComponentProps<\"a\">\r\n\r\nconst PaginationLink = ({ className, isActive, size = \"icon\", ...props }: PaginationLinkProps) => (\r\n <a\r\n aria-current={isActive ? \"page\" : undefined}\r\n className={cn(\r\n buttonVariants({\r\n variant: isActive ? \"outline\" : \"ghost\",\r\n size,\r\n }),\r\n className\r\n )}\r\n {...props}\r\n />\r\n)\r\nPaginationLink.displayName = \"PaginationLink\"\r\n\r\nconst PaginationPrevious = ({ className, size = \"default\", ...props }: React.ComponentProps<typeof PaginationLink>) => (\r\n <PaginationLink\r\n aria-label=\"Go to previous page\"\r\n className={cn(\"gap-1 pl-2.5\", className)}\r\n size={size}\r\n {...props}\r\n >\r\n <ChevronLeft className=\"h-4 w-4\" />\r\n <span>Previous</span>\r\n </PaginationLink>\r\n)\r\nPaginationPrevious.displayName = \"PaginationPrevious\"\r\n\r\nconst PaginationNext = ({ className, size = \"default\", ...props }: React.ComponentProps<typeof PaginationLink>) => (\r\n <PaginationLink\r\n aria-label=\"Go to next page\"\r\n className={cn(\"gap-1 pr-2.5\", className)}\r\n size={size}\r\n {...props}\r\n >\r\n <span>Next</span>\r\n <ChevronRight className=\"h-4 w-4\" />\r\n </PaginationLink>\r\n)\r\nPaginationNext.displayName = \"PaginationNext\"\r\n\r\nconst PaginationEllipsis = ({ className, ...props }: React.ComponentProps<\"span\">) => (\r\n <span\r\n aria-hidden\r\n className={cn(\"flex h-9 w-9 items-center justify-center\", className)}\r\n {...props}\r\n >\r\n <MoreHorizontal className=\"h-4 w-4\" />\r\n <span className=\"sr-only\">More pages</span>\r\n </span>\r\n)\r\nPaginationEllipsis.displayName = \"PaginationEllipsis\"\r\n\r\nexport {\r\n Pagination,\r\n PaginationContent,\r\n PaginationItem,\r\n PaginationLink,\r\n PaginationNext,\r\n PaginationPrevious,\r\n PaginationEllipsis,\r\n}\r\n"],"mappings":";;;;;;;;;AAKA,IAAM,cAAc,EAAE,WAAW,GAAG,YAClC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;CACE,MAAK;CACL,cAAW;CACX,WAAW,WAAA,GAAG,sCAAsC,SAAS;CAC7D,GAAI;AACL,CAAA;AAEH,WAAW,cAAc;AAEzB,IAAM,oBAAoB,MAAM,YAG7B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;CACO;CACL,WAAW,WAAA,GAAG,oCAAoC,SAAS;CAC3D,GAAI;AACL,CAAA,CACF;AACD,kBAAkB,cAAc;AAEhC,IAAM,iBAAiB,MAAM,YAG1B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;CAAS;CAAK,WAAW,WAAA,GAAG,IAAI,SAAS;CAAG,GAAI;AA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kBAAA,IAAA,CAAC,QAAD;EAAM,WAAU;EAAU,UAAA;CAAgB,CAAA,CACtC;;AAER,mBAAmB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Separator.cjs","names":[],"sources":["../../../../src/components/Separator/Separator.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { Separator as SeparatorPrimitive } from \"../../primitives/separator\"\r\n\r\nexport const Separator = forwardRef<\r\n ElementRef<typeof SeparatorPrimitive>,\r\n ComponentPropsWithoutRef<typeof SeparatorPrimitive>\r\n>((props, ref) => <SeparatorPrimitive ref={ref} {...props} />)\r\nSeparator.displayName = \"Separator\"\r\n"],"mappings":";;;;;AAIA,IAAa,aAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAA,WAAD;CAAyB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC7D,UAAU,cAAc"}
1
+ {"version":3,"file":"Separator.cjs","names":[],"sources":["../../../../src/components/Separator/Separator.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { Separator as SeparatorPrimitive } from \"../../primitives/separator\"\r\n\r\nexport const Separator = forwardRef<\r\n ElementRef<typeof SeparatorPrimitive>,\r\n ComponentPropsWithoutRef<typeof SeparatorPrimitive>\r\n>((props, ref) => <SeparatorPrimitive ref={ref} {...props} />)\r\nSeparator.displayName = \"Separator\"\r\n"],"mappings":";;;;;AAIA,IAAa,aAAA,GAAY,MAAA,WAAA,EAGtB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAA,WAAD;CAAyB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC7D,UAAU,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.cjs","names":[],"sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport type * as SwitchPrimitives from \"@radix-ui/react-switch\"\r\nimport { Switch as SwitchPrimitive } from \"../../primitives/switch\"\r\n\r\nexport type SwitchProps = ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>\r\n\r\nexport const Switch = forwardRef<\r\n ElementRef<typeof SwitchPrimitive>,\r\n SwitchProps\r\n>((props, ref) => <SwitchPrimitive ref={ref} {...props} />)\r\nSwitch.displayName = \"Switch\"\r\n"],"mappings":";;;;;AAOA,IAAa,UAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,QAAD;CAAsB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC1D,OAAO,cAAc"}
1
+ {"version":3,"file":"Switch.cjs","names":[],"sources":["../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport type * as SwitchPrimitives from \"@radix-ui/react-switch\"\r\nimport { Switch as SwitchPrimitive } from \"../../primitives/switch\"\r\n\r\nexport type SwitchProps = ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>\r\n\r\nexport const Switch = forwardRef<\r\n ElementRef<typeof SwitchPrimitive>,\r\n SwitchProps\r\n>((props, ref) => <SwitchPrimitive ref={ref} {...props} />)\r\nSwitch.displayName = \"Switch\"\r\n"],"mappings":";;;;;AAOA,IAAa,UAAA,GAAS,MAAA,WAAA,EAGnB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,eAAA,QAAD;CAAsB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC1D,OAAO,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.cjs","names":[],"sources":["../../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport {\r\n Tabs as TabsPrimitive,\r\n TabsList as TabsListPrimitive,\r\n TabsTrigger as TabsTriggerPrimitive,\r\n TabsContent as TabsContentPrimitive,\r\n} from \"../../primitives/tabs\"\r\n\r\nexport const Tabs = forwardRef<\r\n ElementRef<typeof TabsPrimitive>,\r\n ComponentPropsWithoutRef<typeof TabsPrimitive>\r\n>((props, ref) => <TabsPrimitive ref={ref} {...props} />)\r\nTabs.displayName = \"Tabs\"\r\n\r\nexport const TabsList = forwardRef<\r\n ElementRef<typeof TabsListPrimitive>,\r\n ComponentPropsWithoutRef<typeof TabsListPrimitive>\r\n>((props, ref) => <TabsListPrimitive ref={ref} {...props} />)\r\nTabsList.displayName = \"TabsList\"\r\n\r\nexport const TabsTrigger = forwardRef<\r\n ElementRef<typeof TabsTriggerPrimitive>,\r\n ComponentPropsWithoutRef<typeof TabsTriggerPrimitive>\r\n>((props, ref) => <TabsTriggerPrimitive ref={ref} {...props} />)\r\nTabsTrigger.displayName = \"TabsTrigger\"\r\n\r\nexport const TabsContent = forwardRef<\r\n ElementRef<typeof TabsContentPrimitive>,\r\n ComponentPropsWithoutRef<typeof TabsContentPrimitive>\r\n>((props, ref) => <TabsContentPrimitive ref={ref} {...props} />)\r\nTabsContent.displayName = \"TabsContent\"\r\n"],"mappings":";;;;;AASA,IAAa,QAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,MAAD;CAAoB;CAAK,GAAI;AAAQ,CAAA,CAAC;AACxD,KAAK,cAAc;AAEnB,IAAa,YAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,UAAD;CAAwB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC5D,SAAS,cAAc;AAEvB,IAAa,eAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,aAAD;CAA2B;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC/D,YAAY,cAAc;AAE1B,IAAa,eAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,aAAD;CAA2B;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC/D,YAAY,cAAc"}
1
+ {"version":3,"file":"Tabs.cjs","names":[],"sources":["../../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport {\r\n Tabs as TabsPrimitive,\r\n TabsList as TabsListPrimitive,\r\n TabsTrigger as TabsTriggerPrimitive,\r\n TabsContent as TabsContentPrimitive,\r\n} from \"../../primitives/tabs\"\r\n\r\nexport const Tabs = forwardRef<\r\n ElementRef<typeof TabsPrimitive>,\r\n ComponentPropsWithoutRef<typeof TabsPrimitive>\r\n>((props, ref) => <TabsPrimitive ref={ref} {...props} />)\r\nTabs.displayName = \"Tabs\"\r\n\r\nexport const TabsList = forwardRef<\r\n ElementRef<typeof TabsListPrimitive>,\r\n ComponentPropsWithoutRef<typeof TabsListPrimitive>\r\n>((props, ref) => <TabsListPrimitive ref={ref} {...props} />)\r\nTabsList.displayName = \"TabsList\"\r\n\r\nexport const TabsTrigger = forwardRef<\r\n ElementRef<typeof TabsTriggerPrimitive>,\r\n ComponentPropsWithoutRef<typeof TabsTriggerPrimitive>\r\n>((props, ref) => <TabsTriggerPrimitive ref={ref} {...props} />)\r\nTabsTrigger.displayName = \"TabsTrigger\"\r\n\r\nexport const TabsContent = forwardRef<\r\n ElementRef<typeof TabsContentPrimitive>,\r\n ComponentPropsWithoutRef<typeof TabsContentPrimitive>\r\n>((props, ref) => <TabsContentPrimitive ref={ref} {...props} />)\r\nTabsContent.displayName = \"TabsContent\"\r\n"],"mappings":";;;;;AASA,IAAa,QAAA,GAAO,MAAA,WAAA,EAGjB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,MAAD;CAAoB;CAAK,GAAI;AAAQ,CAAA,CAAC;AACxD,KAAK,cAAc;AAEnB,IAAa,YAAA,GAAW,MAAA,WAAA,EAGrB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,UAAD;CAAwB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC5D,SAAS,cAAc;AAEvB,IAAa,eAAA,GAAc,MAAA,WAAA,EAGxB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,aAAD;CAA2B;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC/D,YAAY,cAAc;AAE1B,IAAa,eAAA,GAAc,MAAA,WAAA,EAGxB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,aAAD;CAA2B;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC/D,YAAY,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Textarea.cjs","names":[],"sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { Textarea as TextareaPrimitive } from \"../../primitives/textarea\"\r\n\r\nexport type TextareaProps = ComponentPropsWithoutRef<typeof TextareaPrimitive>\r\n\r\nexport const Textarea = forwardRef<\r\n ElementRef<typeof TextareaPrimitive>,\r\n TextareaProps\r\n>((props, ref) => <TextareaPrimitive ref={ref} {...props} />)\r\nTextarea.displayName = \"Textarea\"\r\n"],"mappings":";;;;;AAMA,IAAa,YAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAA,UAAD;CAAwB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC5D,SAAS,cAAc"}
1
+ {"version":3,"file":"Textarea.cjs","names":[],"sources":["../../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { Textarea as TextareaPrimitive } from \"../../primitives/textarea\"\r\n\r\nexport type TextareaProps = ComponentPropsWithoutRef<typeof TextareaPrimitive>\r\n\r\nexport const Textarea = forwardRef<\r\n ElementRef<typeof TextareaPrimitive>,\r\n TextareaProps\r\n>((props, ref) => <TextareaPrimitive ref={ref} {...props} />)\r\nTextarea.displayName = \"Textarea\"\r\n"],"mappings":";;;;;AAMA,IAAa,YAAA,GAAW,MAAA,WAAA,EAGrB,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,iBAAA,UAAD;CAAwB;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC5D,SAAS,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.cjs","names":[],"sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\r\n Tooltip as TooltipPrimitive,\r\n TooltipTrigger as TooltipTriggerPrimitive,\r\n TooltipContent as TooltipContentPrimitive,\r\n TooltipProvider as TooltipProviderPrimitive,\r\n} from \"../../primitives/tooltip\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { forwardRef } from \"react\"\r\n\r\nexport const TooltipProvider = TooltipProviderPrimitive\r\nexport const Tooltip = TooltipPrimitive\r\nexport const TooltipTrigger = TooltipTriggerPrimitive\r\n\r\nexport const TooltipContent = forwardRef<\r\n ElementRef<typeof TooltipContentPrimitive>,\r\n ComponentPropsWithoutRef<typeof TooltipContentPrimitive>\r\n>((props, ref) => <TooltipContentPrimitive ref={ref} {...props} />)\r\nTooltipContent.displayName = \"TooltipContent\"\r\n\r\nexport type TooltipContentProps = ComponentPropsWithoutRef<typeof TooltipContentPrimitive>\r\n"],"mappings":";;;;;AASA,IAAa,kBAAkB,gBAAA;AAC/B,IAAa,UAAU,gBAAA;AACvB,IAAa,iBAAiB,gBAAA;AAE9B,IAAa,kBAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAA,gBAAD;CAA8B;CAAK,GAAI;AAAQ,CAAA,CAAC;AAClE,eAAe,cAAc"}
1
+ {"version":3,"file":"Tooltip.cjs","names":[],"sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\r\n Tooltip as TooltipPrimitive,\r\n TooltipTrigger as TooltipTriggerPrimitive,\r\n TooltipContent as TooltipContentPrimitive,\r\n TooltipProvider as TooltipProviderPrimitive,\r\n} from \"../../primitives/tooltip\"\r\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\"\r\nimport { forwardRef } from \"react\"\r\n\r\nexport const TooltipProvider = TooltipProviderPrimitive\r\nexport const Tooltip = TooltipPrimitive\r\nexport const TooltipTrigger = TooltipTriggerPrimitive\r\n\r\nexport const TooltipContent = forwardRef<\r\n ElementRef<typeof TooltipContentPrimitive>,\r\n ComponentPropsWithoutRef<typeof TooltipContentPrimitive>\r\n>((props, ref) => <TooltipContentPrimitive ref={ref} {...props} />)\r\nTooltipContent.displayName = \"TooltipContent\"\r\n\r\nexport type TooltipContentProps = ComponentPropsWithoutRef<typeof TooltipContentPrimitive>\r\n"],"mappings":";;;;;AASA,IAAa,kBAAkB,gBAAA;AAC/B,IAAa,UAAU,gBAAA;AACvB,IAAa,iBAAiB,gBAAA;AAE9B,IAAa,kBAAA,GAAiB,MAAA,WAAA,EAG3B,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAA,gBAAD;CAA8B;CAAK,GAAI;AAAQ,CAAA,CAAC;AAClE,eAAe,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDebounce.cjs","names":[],"sources":["../../../src/hooks/useDebounce.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useEffect } from \"react\";\r\n\r\n/**\r\n * A hook that debounces a value by a specified delay\r\n * @param value - The value to debounce\r\n * @param delay - The delay in milliseconds (default: 500)\r\n * @returns The debounced value\r\n */\r\nexport function useDebounce<T>(value: T, delay = 500): T {\r\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\r\n\r\n useEffect(() => {\r\n const timer = setTimeout(() => {\r\n setDebouncedValue(value);\r\n }, delay);\r\n\r\n return () => {\r\n clearTimeout(timer);\r\n };\r\n }, [value, delay]);\r\n\r\n return debouncedValue;\r\n}\r\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,YAAe,OAAU,QAAQ,KAAQ;CACvD,MAAM,CAAC,gBAAgB,sBAAA,GAAA,MAAA,SAAA,CAAiC,KAAK;CAE7D,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,QAAQ,iBAAiB;GAC7B,kBAAkB,KAAK;EACzB,GAAG,KAAK;EAER,aAAa;GACX,aAAa,KAAK;EACpB;CACF,GAAG,CAAC,OAAO,KAAK,CAAC;CAEjB,OAAO;AACT"}
1
+ {"version":3,"file":"useDebounce.cjs","names":[],"sources":["../../../src/hooks/useDebounce.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useEffect } from \"react\";\r\n\r\n/**\r\n * A hook that debounces a value by a specified delay\r\n * @param value - The value to debounce\r\n * @param delay - The delay in milliseconds (default: 500)\r\n * @returns The debounced value\r\n */\r\nexport function useDebounce<T>(value: T, delay = 500): T {\r\n const [debouncedValue, setDebouncedValue] = useState<T>(value);\r\n\r\n useEffect(() => {\r\n const timer = setTimeout(() => {\r\n setDebouncedValue(value);\r\n }, delay);\r\n\r\n return () => {\r\n clearTimeout(timer);\r\n };\r\n }, [value, delay]);\r\n\r\n return debouncedValue;\r\n}\r\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,YAAe,OAAU,QAAQ,KAAQ;CACvD,MAAM,CAAC,gBAAgB,sBAAA,GAAqB,MAAA,SAAA,CAAY,KAAK;CAE7D,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,QAAQ,iBAAiB;GAC7B,kBAAkB,KAAK;EACzB,GAAG,KAAK;EAER,aAAa;GACX,aAAa,KAAK;EACpB;CACF,GAAG,CAAC,OAAO,KAAK,CAAC;CAEjB,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"useToggle.cjs","names":[],"sources":["../../../src/hooks/useToggle.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useCallback } from \"react\";\r\n\r\n/**\r\n * A hook that returns a boolean state and a function to toggle it\r\n * @param initialValue - The initial value of the toggle (default: false)\r\n * @returns A tuple containing the current value and a toggle function\r\n */\r\nexport function useToggle(initialValue = false): [boolean, () => void] {\r\n const [value, setValue] = useState(initialValue);\r\n\r\n const toggle = useCallback(() => {\r\n setValue((prev) => !prev);\r\n }, []);\r\n\r\n return [value, toggle];\r\n}\r\n"],"mappings":";;;;;;;;;AASA,SAAgB,UAAU,eAAe,OAA8B;CACrE,MAAM,CAAC,OAAO,aAAA,GAAA,MAAA,SAAA,CAAqB,YAAY;CAM/C,OAAO,CAAC,QAAA,GAAA,MAAA,YAAA,OAJyB;EAC/B,UAAU,SAAS,CAAC,IAAI;CAC1B,GAAG,CAAC,CAEW,CAAM;AACvB"}
1
+ {"version":3,"file":"useToggle.cjs","names":[],"sources":["../../../src/hooks/useToggle.ts"],"sourcesContent":["'use client';\r\n\r\nimport { useState, useCallback } from \"react\";\r\n\r\n/**\r\n * A hook that returns a boolean state and a function to toggle it\r\n * @param initialValue - The initial value of the toggle (default: false)\r\n * @returns A tuple containing the current value and a toggle function\r\n */\r\nexport function useToggle(initialValue = false): [boolean, () => void] {\r\n const [value, setValue] = useState(initialValue);\r\n\r\n const toggle = useCallback(() => {\r\n setValue((prev) => !prev);\r\n }, []);\r\n\r\n return [value, toggle];\r\n}\r\n"],"mappings":";;;;;;;;;AASA,SAAgB,UAAU,eAAe,OAA8B;CACrE,MAAM,CAAC,OAAO,aAAA,GAAY,MAAA,SAAA,CAAS,YAAY;CAM/C,OAAO,CAAC,QAAA,GAJO,MAAA,YAAA,OAAkB;EAC/B,UAAU,SAAS,CAAC,IAAI;CAC1B,GAAG,CAAC,CAEW,CAAM;AACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"accordion.cjs","names":[],"sources":["../../../src/primitives/accordion.tsx"],"sourcesContent":["import * as React from \"react\"\r\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\r\nimport { ChevronDown } from \"lucide-react\"\r\nimport { cn } from \"@/utils/index\"\r\n\r\nconst Accordion = AccordionPrimitive.Root\r\n\r\nconst AccordionItem = React.forwardRef<\r\n React.ElementRef<typeof AccordionPrimitive.Item>,\r\n React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>\r\n>(({ className, ...props }, ref) => (\r\n <AccordionPrimitive.Item\r\n ref={ref}\r\n className={cn(\"border-b border-border\", className)}\r\n {...props}\r\n />\r\n))\r\nAccordionItem.displayName = \"AccordionItem\"\r\n\r\nconst AccordionTrigger = React.forwardRef<\r\n React.ElementRef<typeof AccordionPrimitive.Trigger>,\r\n React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>\r\n>(({ className, children, ...props }, ref) => (\r\n <AccordionPrimitive.Header className=\"flex\">\r\n <AccordionPrimitive.Trigger\r\n ref={ref}\r\n className={cn(\r\n \"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180\",\r\n className\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <ChevronDown className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200\" />\r\n </AccordionPrimitive.Trigger>\r\n </AccordionPrimitive.Header>\r\n))\r\nAccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName\r\n\r\nconst AccordionContent = React.forwardRef<\r\n React.ElementRef<typeof AccordionPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>\r\n>(({ className, children, ...props }, ref) => (\r\n <AccordionPrimitive.Content\r\n ref={ref}\r\n className=\"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down\"\r\n {...props}\r\n >\r\n <div className={cn(\"pb-4 pt-0\", className)}>{children}</div>\r\n </AccordionPrimitive.Content>\r\n))\r\nAccordionContent.displayName = AccordionPrimitive.Content.displayName\r\n\r\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent }\r\n"],"mappings":";;;;;;;;;;AAKA,IAAM,YAAY,0BAAmB;AAErC,IAAM,gBAAgB,MAAM,YAGzB,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,0BAAmB,MAApB;CACO;CACL,WAAW,WAAA,GAAG,0BAA0B,SAAS;CACjD,GAAI;AACL,CAAA,CACF;AACD,cAAc,cAAc;AAE5B,IAAM,mBAAmB,MAAM,YAG5B,EAAE,WAAW,UAAU,GAAG,SAAS,QACpC,iBAAA,GAAA,kBAAA,IAAA,CAAC,0BAAmB,QAApB;CAA2B,WAAU;WACnC,iBAAA,GAAA,kBAAA,KAAA,CAAC,0BAAmB,SAApB;EACO;EACL,WAAW,WAAA,GACT,kJACA,SACF;EACA,GAAI;YANN,CAQG,UACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,aAAD,EAAa,WAAU,2EAA4E,CAAA,CACzE;;AACH,CAAA,CAC5B;AACD,iBAAiB,cAAc,0BAAmB,QAAQ;AAE1D,IAAM,mBAAmB,MAAM,YAG5B,EAAE,WAAW,UAAU,GAAG,SAAS,QACpC,iBAAA,GAAA,kBAAA,IAAA,CAAC,0BAAmB,SAApB;CACO;CACL,WAAU;CACV,GAAI;WAEJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAW,WAAA,GAAG,aAAa,SAAS;EAAI;CAAc,CAAA;AACjC,CAAA,CAC7B;AACD,iBAAiB,cAAc,0BAAmB,QAAQ"}
1
+ {"version":3,"file":"accordion.cjs","names":[],"sources":["../../../src/primitives/accordion.tsx"],"sourcesContent":["import * as React from \"react\"\r\nimport * as AccordionPrimitive from \"@radix-ui/react-accordion\"\r\nimport { ChevronDown } from \"lucide-react\"\r\nimport { cn } from \"@/utils/index\"\r\n\r\nconst Accordion = AccordionPrimitive.Root\r\n\r\nconst AccordionItem = React.forwardRef<\r\n React.ElementRef<typeof AccordionPrimitive.Item>,\r\n React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>\r\n>(({ className, ...props }, ref) => (\r\n <AccordionPrimitive.Item\r\n ref={ref}\r\n className={cn(\"border-b border-border\", className)}\r\n {...props}\r\n />\r\n))\r\nAccordionItem.displayName = \"AccordionItem\"\r\n\r\nconst AccordionTrigger = React.forwardRef<\r\n React.ElementRef<typeof AccordionPrimitive.Trigger>,\r\n React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>\r\n>(({ className, children, ...props }, ref) => (\r\n <AccordionPrimitive.Header className=\"flex\">\r\n <AccordionPrimitive.Trigger\r\n ref={ref}\r\n className={cn(\r\n \"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180\",\r\n className\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <ChevronDown className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200\" />\r\n </AccordionPrimitive.Trigger>\r\n </AccordionPrimitive.Header>\r\n))\r\nAccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName\r\n\r\nconst AccordionContent = React.forwardRef<\r\n React.ElementRef<typeof AccordionPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>\r\n>(({ className, children, ...props }, ref) => (\r\n <AccordionPrimitive.Content\r\n ref={ref}\r\n className=\"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down\"\r\n {...props}\r\n >\r\n <div className={cn(\"pb-4 pt-0\", className)}>{children}</div>\r\n </AccordionPrimitive.Content>\r\n))\r\nAccordionContent.displayName = AccordionPrimitive.Content.displayName\r\n\r\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent }\r\n"],"mappings":";;;;;;;;;;AAKA,IAAM,YAAY,0BAAmB;AAErC,IAAM,gBAAgB,MAAM,YAGzB,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,0BAAmB,MAApB;CACO;CACL,WAAW,WAAA,GAAG,0BAA0B,SAAS;CACjD,GAAI;AACL,CAAA,CACF;AACD,cAAc,cAAc;AAE5B,IAAM,mBAAmB,MAAM,YAG5B,EAAE,WAAW,UAAU,GAAG,SAAS,QACpC,iBAAA,GAAA,kBAAA,IAAA,CAAC,0BAAmB,QAApB;CAA2B,WAAU;CACnC,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,0BAAmB,SAApB;EACO;EACL,WAAW,WAAA,GACT,kJACA,SACF;EACA,GAAI;EANN,UAAA,CAQG,UACD,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAA,aAAD,EAAa,WAAU,2EAA4E,CAAA,CACzE;;AACH,CAAA,CAC5B;AACD,iBAAiB,cAAc,0BAAmB,QAAQ;AAE1D,IAAM,mBAAmB,MAAM,YAG5B,EAAE,WAAW,UAAU,GAAG,SAAS,QACpC,iBAAA,GAAA,kBAAA,IAAA,CAAC,0BAAmB,SAApB;CACO;CACL,WAAU;CACV,GAAI;CAEJ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAW,WAAA,GAAG,aAAa,SAAS;EAAI;CAAc,CAAA;AACjC,CAAA,CAC7B;AACD,iBAAiB,cAAc,0BAAmB,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"alert.cjs","names":[],"sources":["../../../src/primitives/alert.tsx"],"sourcesContent":["import * as React from \"react\"\r\nimport { cva, type VariantProps } from \"class-variance-authority\"\r\n\r\nimport { cn } from \"@/utils/index\"\r\n\r\nconst alertVariants = cva(\r\n \"relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground\",\r\n {\r\n variants: {\r\n variant: {\r\n default: \"bg-background text-foreground\",\r\n destructive:\r\n \"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n },\r\n }\r\n)\r\n\r\nconst Alert = React.forwardRef<\r\n HTMLDivElement,\r\n React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>\r\n>(({ className, variant, ...props }, ref) => (\r\n <div\r\n ref={ref}\r\n role=\"alert\"\r\n className={cn(alertVariants({ variant }), className)}\r\n {...props}\r\n />\r\n))\r\nAlert.displayName = \"Alert\"\r\n\r\nconst AlertTitle = React.forwardRef<\r\n HTMLParagraphElement,\r\n React.HTMLAttributes<HTMLHeadingElement>\r\n>(({ className, ...props }, ref) => (\r\n <h5\r\n ref={ref}\r\n className={cn(\"mb-1 font-medium leading-none tracking-tight\", className)}\r\n {...props}\r\n />\r\n))\r\nAlertTitle.displayName = \"AlertTitle\"\r\n\r\nconst AlertDescription = React.forwardRef<\r\n HTMLParagraphElement,\r\n React.HTMLAttributes<HTMLParagraphElement>\r\n>(({ className, ...props }, ref) => (\r\n <div\r\n ref={ref}\r\n className={cn(\"text-sm [&_p]:leading-relaxed\", className)}\r\n {...props}\r\n />\r\n))\r\nAlertDescription.displayName = \"AlertDescription\"\r\n\r\nexport { Alert, AlertTitle, AlertDescription }\r\n"],"mappings":";;;;;;;;AAKA,IAAM,iBAAA,GAAA,yBAAA,IAAA,CACJ,6JACA;CACE,UAAU,EACR,SAAS;EACP,SAAS;EACT,aACE;CACJ,EACF;CACA,iBAAiB,EACf,SAAS,UACX;AACF,CACF;AAEA,IAAM,QAAQ,MAAM,YAGjB,EAAE,WAAW,SAAS,GAAG,SAAS,QACnC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;CACO;CACL,MAAK;CACL,WAAW,WAAA,GAAG,cAAc,EAAE,QAAQ,CAAC,GAAG,SAAS;CACnD,GAAI;AACL,CAAA,CACF;AACD,MAAM,cAAc;AAEpB,IAAM,aAAa,MAAM,YAGtB,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;CACO;CACL,WAAW,WAAA,GAAG,gDAAgD,SAAS;CACvE,GAAI;AACL,CAAA,CACF;AACD,WAAW,cAAc;AAEzB,IAAM,mBAAmB,MAAM,YAG5B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;CACO;CACL,WAAW,WAAA,GAAG,iCAAiC,SAAS;CACxD,GAAI;AACL,CAAA,CACF;AACD,iBAAiB,cAAc"}
1
+ {"version":3,"file":"alert.cjs","names":[],"sources":["../../../src/primitives/alert.tsx"],"sourcesContent":["import * as React from \"react\"\r\nimport { cva, type VariantProps } from \"class-variance-authority\"\r\n\r\nimport { cn } from \"@/utils/index\"\r\n\r\nconst alertVariants = cva(\r\n \"relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground\",\r\n {\r\n variants: {\r\n variant: {\r\n default: \"bg-background text-foreground\",\r\n destructive:\r\n \"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n },\r\n }\r\n)\r\n\r\nconst Alert = React.forwardRef<\r\n HTMLDivElement,\r\n React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>\r\n>(({ className, variant, ...props }, ref) => (\r\n <div\r\n ref={ref}\r\n role=\"alert\"\r\n className={cn(alertVariants({ variant }), className)}\r\n {...props}\r\n />\r\n))\r\nAlert.displayName = \"Alert\"\r\n\r\nconst AlertTitle = React.forwardRef<\r\n HTMLParagraphElement,\r\n React.HTMLAttributes<HTMLHeadingElement>\r\n>(({ className, ...props }, ref) => (\r\n <h5\r\n ref={ref}\r\n className={cn(\"mb-1 font-medium leading-none tracking-tight\", className)}\r\n {...props}\r\n />\r\n))\r\nAlertTitle.displayName = \"AlertTitle\"\r\n\r\nconst AlertDescription = React.forwardRef<\r\n HTMLParagraphElement,\r\n React.HTMLAttributes<HTMLParagraphElement>\r\n>(({ className, ...props }, ref) => (\r\n <div\r\n ref={ref}\r\n className={cn(\"text-sm [&_p]:leading-relaxed\", className)}\r\n {...props}\r\n />\r\n))\r\nAlertDescription.displayName = \"AlertDescription\"\r\n\r\nexport { Alert, AlertTitle, AlertDescription }\r\n"],"mappings":";;;;;;;;AAKA,IAAM,iBAAA,GAAgB,yBAAA,IAAA,CACpB,6JACA;CACE,UAAU,EACR,SAAS;EACP,SAAS;EACT,aACE;CACJ,EACF;CACA,iBAAiB,EACf,SAAS,UACX;AACF,CACF;AAEA,IAAM,QAAQ,MAAM,YAGjB,EAAE,WAAW,SAAS,GAAG,SAAS,QACnC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;CACO;CACL,MAAK;CACL,WAAW,WAAA,GAAG,cAAc,EAAE,QAAQ,CAAC,GAAG,SAAS;CACnD,GAAI;AACL,CAAA,CACF;AACD,MAAM,cAAc;AAEpB,IAAM,aAAa,MAAM,YAGtB,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;CACO;CACL,WAAW,WAAA,GAAG,gDAAgD,SAAS;CACvE,GAAI;AACL,CAAA,CACF;AACD,WAAW,cAAc;AAEzB,IAAM,mBAAmB,MAAM,YAG5B,EAAE,WAAW,GAAG,SAAS,QAC1B,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;CACO;CACL,WAAW,WAAA,GAAG,iCAAiC,SAAS;CACxD,GAAI;AACL,CAAA,CACF;AACD,iBAAiB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"badge.cjs","names":[],"sources":["../../../src/primitives/badge.tsx"],"sourcesContent":["import * as React from \"react\"\r\nimport { cva, type VariantProps } from \"class-variance-authority\"\r\n\r\nimport { cn } from \"@/utils\"\r\n\r\nconst badgeVariants = cva(\r\n \"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\",\r\n {\r\n variants: {\r\n variant: {\r\n default:\r\n \"border-transparent bg-primary text-primary-foreground hover:bg-primary/80\",\r\n secondary:\r\n \"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80\",\r\n destructive:\r\n \"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80\",\r\n outline: \"text-foreground\",\r\n success:\r\n \"border-transparent bg-emerald-100 text-emerald-800 hover:bg-emerald-100/80\",\r\n warning:\r\n \"border-transparent bg-amber-100 text-amber-800 hover:bg-amber-100/80\",\r\n info:\r\n \"border-transparent bg-sky-100 text-sky-800 hover:bg-sky-100/80\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n },\r\n }\r\n)\r\n\r\nexport interface BadgeProps\r\n extends React.HTMLAttributes<HTMLDivElement>,\r\n VariantProps<typeof badgeVariants> {}\r\n\r\nfunction Badge({ className, variant, ...props }: BadgeProps) {\r\n return (\r\n <div className={cn(badgeVariants({ variant }), className)} {...props} />\r\n )\r\n}\r\n\r\nexport { Badge, badgeVariants }\r\n"],"mappings":";;;;;;;;AAKA,IAAM,iBAAA,GAAA,yBAAA,IAAA,CACJ,0KACA;CACE,UAAU,EACR,SAAS;EACP,SACE;EACF,WACE;EACF,aACE;EACF,SAAS;EACT,SACE;EACF,SACE;EACF,MACE;CACJ,EACF;CACA,iBAAiB,EACf,SAAS,UACX;AACF,CACF;AAMA,SAAS,MAAM,EAAE,WAAW,SAAS,GAAG,SAAqB;CAC3D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAW,WAAA,GAAG,cAAc,EAAE,QAAQ,CAAC,GAAG,SAAS;EAAG,GAAI;CAAQ,CAAA;AAE3E"}
1
+ {"version":3,"file":"badge.cjs","names":[],"sources":["../../../src/primitives/badge.tsx"],"sourcesContent":["import * as React from \"react\"\r\nimport { cva, type VariantProps } from \"class-variance-authority\"\r\n\r\nimport { cn } from \"@/utils\"\r\n\r\nconst badgeVariants = cva(\r\n \"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2\",\r\n {\r\n variants: {\r\n variant: {\r\n default:\r\n \"border-transparent bg-primary text-primary-foreground hover:bg-primary/80\",\r\n secondary:\r\n \"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80\",\r\n destructive:\r\n \"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80\",\r\n outline: \"text-foreground\",\r\n success:\r\n \"border-transparent bg-emerald-100 text-emerald-800 hover:bg-emerald-100/80\",\r\n warning:\r\n \"border-transparent bg-amber-100 text-amber-800 hover:bg-amber-100/80\",\r\n info:\r\n \"border-transparent bg-sky-100 text-sky-800 hover:bg-sky-100/80\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n },\r\n }\r\n)\r\n\r\nexport interface BadgeProps\r\n extends React.HTMLAttributes<HTMLDivElement>,\r\n VariantProps<typeof badgeVariants> {}\r\n\r\nfunction Badge({ className, variant, ...props }: BadgeProps) {\r\n return (\r\n <div className={cn(badgeVariants({ variant }), className)} {...props} />\r\n )\r\n}\r\n\r\nexport { Badge, badgeVariants }\r\n"],"mappings":";;;;;;;;AAKA,IAAM,iBAAA,GAAgB,yBAAA,IAAA,CACpB,0KACA;CACE,UAAU,EACR,SAAS;EACP,SACE;EACF,WACE;EACF,aACE;EACF,SAAS;EACT,SACE;EACF,SACE;EACF,MACE;CACJ,EACF;CACA,iBAAiB,EACf,SAAS,UACX;AACF,CACF;AAMA,SAAS,MAAM,EAAE,WAAW,SAAS,GAAG,SAAqB;CAC3D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAW,WAAA,GAAG,cAAc,EAAE,QAAQ,CAAC,GAAG,SAAS;EAAG,GAAI;CAAQ,CAAA;AAE3E"}