jaci-ui 0.3.0 → 0.4.0

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 (112) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +48 -0
  3. package/dist/components/calendar/calendar.cjs +377 -0
  4. package/dist/components/calendar/calendar.cjs.map +1 -0
  5. package/dist/components/calendar/calendar.d.cts +56 -0
  6. package/dist/components/calendar/calendar.d.ts +56 -0
  7. package/dist/components/calendar/calendar.js +368 -0
  8. package/dist/components/calendar/calendar.js.map +1 -0
  9. package/dist/components/calendar/index.d.cts +2 -0
  10. package/dist/components/calendar/index.d.ts +2 -0
  11. package/dist/components/combobox/combobox.cjs +13 -1
  12. package/dist/components/combobox/combobox.cjs.map +1 -1
  13. package/dist/components/combobox/combobox.d.cts +7 -2
  14. package/dist/components/combobox/combobox.d.ts +7 -2
  15. package/dist/components/combobox/combobox.js +13 -2
  16. package/dist/components/combobox/combobox.js.map +1 -1
  17. package/dist/components/combobox/index.d.cts +2 -2
  18. package/dist/components/combobox/index.d.ts +2 -2
  19. package/dist/components/controls/input.cjs +26 -5
  20. package/dist/components/controls/input.cjs.map +1 -1
  21. package/dist/components/controls/input.d.cts +5 -2
  22. package/dist/components/controls/input.d.ts +5 -2
  23. package/dist/components/controls/input.js +28 -7
  24. package/dist/components/controls/input.js.map +1 -1
  25. package/dist/components/controls/textarea.cjs +26 -5
  26. package/dist/components/controls/textarea.cjs.map +1 -1
  27. package/dist/components/controls/textarea.d.cts +5 -2
  28. package/dist/components/controls/textarea.d.ts +5 -2
  29. package/dist/components/controls/textarea.js +28 -7
  30. package/dist/components/controls/textarea.js.map +1 -1
  31. package/dist/components/date-picker/date-picker.cjs +9 -9
  32. package/dist/components/date-picker/date-picker.cjs.map +1 -1
  33. package/dist/components/date-picker/date-picker.d.cts +3 -1
  34. package/dist/components/date-picker/date-picker.d.ts +3 -1
  35. package/dist/components/date-picker/date-picker.js +9 -9
  36. package/dist/components/date-picker/date-picker.js.map +1 -1
  37. package/dist/components/date-range-picker/date-range-picker.cjs +589 -0
  38. package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -0
  39. package/dist/components/date-range-picker/date-range-picker.d.cts +134 -0
  40. package/dist/components/date-range-picker/date-range-picker.d.ts +134 -0
  41. package/dist/components/date-range-picker/date-range-picker.js +568 -0
  42. package/dist/components/date-range-picker/date-range-picker.js.map +1 -0
  43. package/dist/components/date-range-picker/index.d.cts +2 -0
  44. package/dist/components/date-range-picker/index.d.ts +2 -0
  45. package/dist/components/field/field.cjs +106 -11
  46. package/dist/components/field/field.cjs.map +1 -1
  47. package/dist/components/field/field.d.cts +22 -4
  48. package/dist/components/field/field.d.ts +22 -4
  49. package/dist/components/field/field.js +107 -13
  50. package/dist/components/field/field.js.map +1 -1
  51. package/dist/components/field/index.d.cts +2 -2
  52. package/dist/components/field/index.d.ts +2 -2
  53. package/dist/components/pin-input/index.d.cts +2 -0
  54. package/dist/components/pin-input/index.d.ts +2 -0
  55. package/dist/components/pin-input/pin-input.cjs +266 -0
  56. package/dist/components/pin-input/pin-input.cjs.map +1 -0
  57. package/dist/components/pin-input/pin-input.d.cts +46 -0
  58. package/dist/components/pin-input/pin-input.d.ts +46 -0
  59. package/dist/components/pin-input/pin-input.js +258 -0
  60. package/dist/components/pin-input/pin-input.js.map +1 -0
  61. package/dist/components/select/index.d.cts +2 -2
  62. package/dist/components/select/index.d.ts +2 -2
  63. package/dist/components/select/select.cjs +80 -3
  64. package/dist/components/select/select.cjs.map +1 -1
  65. package/dist/components/select/select.d.cts +18 -3
  66. package/dist/components/select/select.d.ts +18 -3
  67. package/dist/components/select/select.js +78 -5
  68. package/dist/components/select/select.js.map +1 -1
  69. package/dist/components/tags-input/tags-input.cjs +83 -5
  70. package/dist/components/tags-input/tags-input.cjs.map +1 -1
  71. package/dist/components/tags-input/tags-input.d.cts +3 -0
  72. package/dist/components/tags-input/tags-input.d.ts +3 -0
  73. package/dist/components/tags-input/tags-input.js +83 -5
  74. package/dist/components/tags-input/tags-input.js.map +1 -1
  75. package/dist/components/upload/index.d.cts +2 -2
  76. package/dist/components/upload/index.d.ts +2 -2
  77. package/dist/components/upload/upload.cjs +90 -10
  78. package/dist/components/upload/upload.cjs.map +1 -1
  79. package/dist/components/upload/upload.d.cts +25 -2
  80. package/dist/components/upload/upload.d.ts +25 -2
  81. package/dist/components/upload/upload.js +89 -11
  82. package/dist/components/upload/upload.js.map +1 -1
  83. package/dist/index.cjs +52 -1
  84. package/dist/index.d.cts +11 -5
  85. package/dist/index.d.ts +11 -5
  86. package/dist/index.js +9 -6
  87. package/dist/styled-system/recipes/calendar.cjs +43 -0
  88. package/dist/styled-system/recipes/calendar.cjs.map +1 -0
  89. package/dist/styled-system/recipes/calendar.js +43 -0
  90. package/dist/styled-system/recipes/calendar.js.map +1 -0
  91. package/dist/styled-system/recipes/combobox.cjs +1 -0
  92. package/dist/styled-system/recipes/combobox.cjs.map +1 -1
  93. package/dist/styled-system/recipes/combobox.js +1 -0
  94. package/dist/styled-system/recipes/combobox.js.map +1 -1
  95. package/dist/styled-system/recipes/date-range-picker.cjs +52 -0
  96. package/dist/styled-system/recipes/date-range-picker.cjs.map +1 -0
  97. package/dist/styled-system/recipes/date-range-picker.js +52 -0
  98. package/dist/styled-system/recipes/date-range-picker.js.map +1 -0
  99. package/dist/styled-system/recipes/pin-input.cjs +39 -0
  100. package/dist/styled-system/recipes/pin-input.cjs.map +1 -0
  101. package/dist/styled-system/recipes/pin-input.js +39 -0
  102. package/dist/styled-system/recipes/pin-input.js.map +1 -0
  103. package/dist/styled-system/recipes/select.cjs +5 -1
  104. package/dist/styled-system/recipes/select.cjs.map +1 -1
  105. package/dist/styled-system/recipes/select.js +5 -1
  106. package/dist/styled-system/recipes/select.js.map +1 -1
  107. package/dist/styled-system/recipes/upload.cjs +2 -0
  108. package/dist/styled-system/recipes/upload.cjs.map +1 -1
  109. package/dist/styled-system/recipes/upload.js +2 -0
  110. package/dist/styled-system/recipes/upload.js.map +1 -1
  111. package/dist/styles.css +745 -81
  112. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"field.js","names":["Field","BaseField"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useContext } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n name: string | undefined;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n errors: [],\n insideField: false,\n invalid: false,\n name: undefined,\n});\n\nfunction normalizeErrors(errors: ReactNode | ReactNode[] | undefined): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor: string;\n}\n\nexport const Field = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const errors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const invalid = invalidProp || errors.length > 0;\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider value={{ errors, insideField: true, invalid, name }}>\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-slot=\"field\"\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n validate={validate}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { insideField, invalid } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n"],"mappings":";;;;;;;;AAoBA,MAAM,eAAe,cAAiC;CACpD,QAAQ,CAAC;CACT,aAAa;CACb,SAAS;CACT,MAAM,KAAA;AACR,CAAC;AAED,SAAS,gBAAgB,QAA0D;CACjF,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,OACxD,OAAO,CAAC;CAGV,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD;AAEA,SAAS,aAAa,QAAqB;CACzC,IAAI,OAAO,UAAU,GACnB,OAAO,OAAO;CAGhB,OACE,oBAAC,MAAD,EAAA,UACG,OAAO,KAAK,OAAO,UAClB,oBAAC,MAAD,EAAA,UAAqD,MAAU,GAAtD,OAAO,UAAU,WAAW,Q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CACxD,MAAM,mBAAmB;EACvB,GAAG;EACH,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,aAAa,SAAS;EACvD,aAAa;CACf;CAEA,IAAI,CAAC,aACH,OAAO,oBAAC,KAAD;EAAG,GAAI;EAAuB;CAAM,CAAA;CAG7C,OAAO,oBAACA,MAAU,aAAX;EAAuB,GAAI;EAAuB;CAAM,CAAA;AACjE,CACF;AAOA,MAAa,aAAa,WAAkD,SAAS,WACnF,EAAE,UAAU,WAAW,OAAO,GAAG,SACjC,KACA;CACA,MAAM,EAAE,QAAQ,aAAa,YAAY,WAAW,YAAY;CAChE,MAAM,UAAU,YAAY,aAAa,MAAM;CAE/C,IAAI,CAAC,aAAa;EAChB,IAAI,YAAY,KAAA,KAAa,YAAY,QAAQ,YAAY,OAC3D,OAAO;EAGT,OACE,oBAAC,KAAD;GACE,GAAI;GACC;GACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;GACjD,aAAU;GACV,MAAK;aAEJ;EACA,CAAA;CAEP;CAEA,OACE,oBAACA,MAAU,OAAX;EACE,GAAI;EACC;EACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,oBAAC,KAAD,CAAI,CAAA;EACZ,MAAK;YAEJ;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,OAAO,WAAW,YAAY;AAChC"}
1
+ {"version":3,"file":"field.js","names":["FieldRoot","Field","BaseField"],"sources":["../../../src/components/field/field.tsx"],"sourcesContent":["\"use client\";\n\nimport { Field as BaseField } from \"@base-ui/react/field\";\nimport { createContext, forwardRef, useCallback, useContext, useId, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode, Ref } from \"react\";\nimport type { FieldRoot as BaseFieldRoot } from \"@base-ui/react/field\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { field } from \"../../styled-system/recipes\";\nimport { JaciFormContext } from \"../form\";\n\nexport type FieldValidationMode = \"onSubmit\" | \"onBlur\" | \"onChange\";\n\ninterface FieldContextValue {\n controlId: string | undefined;\n descriptionId: string | undefined;\n dirty: boolean;\n errorId: string | undefined;\n errors: ReactNode[];\n insideField: boolean;\n invalid: boolean;\n labelId: string | undefined;\n name: string | undefined;\n pending: boolean;\n touched: boolean;\n valid: boolean | null;\n}\n\nconst FieldContext = createContext<FieldContextValue>({\n controlId: undefined,\n descriptionId: undefined,\n dirty: false,\n errorId: undefined,\n errors: [],\n insideField: false,\n invalid: false,\n labelId: undefined,\n name: undefined,\n pending: false,\n touched: false,\n valid: null,\n});\n\nfunction normalizeErrors(errors: ReactNode | ReactNode[] | undefined): ReactNode[] {\n if (errors === undefined || errors === null || errors === false) {\n return [];\n }\n\n return Array.isArray(errors) ? errors : [errors];\n}\n\nfunction renderErrors(errors: ReactNode[]) {\n if (errors.length <= 1) {\n return errors[0];\n }\n\n return (\n <ul>\n {errors.map((error, index) => (\n <li key={typeof error === \"string\" ? error : index}>{error}</li>\n ))}\n </ul>\n );\n}\n\nexport interface FieldProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Marks the field invalid when an external validator owns its state. */\n invalid?: boolean;\n /** Field name used to resolve errors supplied to the parent Form. */\n name?: string;\n /** Direct error content, useful outside a Form or with custom validation. */\n errors?: ReactNode | ReactNode[];\n /** Disables the field and its Base UI validation state. */\n disabled?: boolean;\n /** Native/Base UI validation callback. */\n validate?: BaseFieldRoot.Props[\"validate\"];\n /** Validation timing used by the parent Form. */\n validationMode?: FieldValidationMode;\n /** Debounce duration for `validationMode=\"onChange\"`. */\n validationDebounceTime?: number;\n /** Controlled dirty/touched state for integrations with external form state. */\n dirty?: boolean;\n touched?: boolean;\n /** Marks the field as awaiting asynchronous validation. */\n pending?: boolean;\n /** Imperative field validation actions. */\n actionsRef?: BaseFieldRoot.Props[\"actionsRef\"];\n children?: ReactNode;\n}\n\nexport interface FieldLabelProps extends ComponentPropsWithoutRef<\"label\"> {\n htmlFor?: string;\n}\n\nconst FieldRoot = forwardRef<HTMLDivElement, FieldProps>(function Field(\n {\n actionsRef,\n children,\n className,\n dirty,\n disabled = false,\n errors: directErrors,\n invalid: invalidProp = false,\n name,\n pending: pendingProp = false,\n touched,\n validate,\n validationDebounceTime,\n validationMode,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const controlId = `${generatedId}-control`;\n const labelId = `${generatedId}-label`;\n const descriptionId = `${generatedId}-description`;\n const errorId = `${generatedId}-error`;\n const [pendingValidation, setPendingValidation] = useState(false);\n const [validationErrors, setValidationErrors] = useState<ReactNode[]>([]);\n const [validationValid, setValidationValid] = useState<boolean | null>(null);\n const validationSequence = useRef(0);\n const { errors: formErrors } = useContext(JaciFormContext);\n const formError = name ? formErrors[name] : undefined;\n const externalErrors =\n directErrors === undefined ? normalizeErrors(formError) : normalizeErrors(directErrors);\n const errors =\n directErrors !== undefined || formError !== undefined ? externalErrors : validationErrors;\n const invalid = invalidProp || errors.length > 0;\n const pending = pendingProp || pendingValidation;\n const wrappedValidate = useCallback<NonNullable<BaseFieldRoot.Props[\"validate\"]>>(\n (value, formValues) => {\n const sequence = ++validationSequence.current;\n if (!validate) return null;\n const result = validate(value, formValues);\n if (!result || typeof result !== \"object\" || !(\"then\" in result)) {\n const resultErrors = normalizeErrors(result);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n setPendingValidation(false);\n return result;\n }\n setValidationErrors([]);\n setValidationValid(null);\n setPendingValidation(true);\n return Promise.resolve(result)\n .then((validationResult) => {\n if (sequence !== validationSequence.current) return null;\n const resultErrors = normalizeErrors(validationResult);\n setValidationErrors(resultErrors);\n setValidationValid(resultErrors.length === 0);\n return validationResult;\n })\n .finally(() => {\n if (sequence === validationSequence.current) setPendingValidation(false);\n });\n },\n [validate],\n );\n const styles = field({ invalid });\n\n return (\n <FieldContext.Provider\n value={{\n controlId,\n descriptionId,\n dirty: dirty ?? false,\n errorId,\n errors,\n insideField: true,\n invalid,\n labelId,\n name,\n pending,\n touched: touched ?? false,\n valid: invalid ? false : validationValid,\n }}\n >\n <BaseField.Root\n {...props}\n ref={ref}\n actionsRef={actionsRef}\n className={cx(styles.root, className)}\n aria-busy={pending || undefined}\n data-dirty={dirty || undefined}\n data-invalid={invalid || undefined}\n data-jaci-component=\"field\"\n data-pending={pending || undefined}\n data-slot=\"field\"\n data-touched={touched || undefined}\n disabled={disabled}\n dirty={dirty}\n invalid={invalid}\n name={name}\n touched={touched}\n {...(validate ? { validate: wrappedValidate } : {})}\n validationDebounceTime={validationDebounceTime}\n validationMode={validationMode}\n >\n {children}\n </BaseField.Root>\n </FieldContext.Provider>\n );\n});\n\nexport interface FieldControlProps extends ComponentPropsWithoutRef<typeof BaseField.Control> {}\n\nexport const FieldControl = forwardRef<HTMLElement, FieldControlProps>(function FieldControl(\n {\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n \"aria-invalid\": ariaInvalid,\n \"aria-labelledby\": ariaLabelledBy,\n className,\n id,\n ...props\n },\n ref,\n) {\n const { controlId, descriptionId, errorId, invalid, labelId, pending, insideField } =\n useContext(FieldContext);\n const describedBy =\n [ariaDescribedBy, descriptionId, invalid ? errorId : undefined].filter(Boolean).join(\" \") ||\n undefined;\n const labelledBy = [ariaLabelledBy, labelId].filter(Boolean).join(\" \") || undefined;\n const controlProps = {\n ...props,\n \"aria-busy\": pending || undefined,\n \"aria-describedby\": describedBy,\n \"aria-errormessage\": ariaErrorMessage ?? (invalid ? errorId : undefined),\n \"aria-invalid\": ariaInvalid ?? (invalid || undefined),\n \"aria-labelledby\": labelledBy,\n className,\n \"data-pending\": pending || undefined,\n id: id ?? controlId,\n };\n if (!insideField) return <BaseField.Control {...controlProps} ref={ref} />;\n return <BaseField.Control {...controlProps} ref={ref} />;\n});\n\nexport const FieldLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(function FieldLabel(\n { children, className, htmlFor, ...props },\n ref,\n) {\n const { controlId, insideField, invalid, labelId } = useContext(FieldContext);\n\n const labelProps = {\n ...props,\n className: cx(field({ invalid }).label, className),\n \"data-slot\": \"field-label\",\n htmlFor: htmlFor ?? controlId,\n id: props.id ?? labelId,\n };\n\n if (!insideField) {\n return (\n <label {...labelProps} ref={ref} htmlFor={htmlFor ?? controlId}>\n {children}\n </label>\n );\n }\n\n return (\n <BaseField.Label {...labelProps} ref={ref as Ref<HTMLElement>}>\n {children}\n </BaseField.Label>\n );\n});\n\nexport const FieldDescription = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<\"p\">>(\n function FieldDescription({ className, ...props }, ref) {\n const { descriptionId, insideField, invalid } = useContext(FieldContext);\n const descriptionProps = {\n ...props,\n className: cx(field({ invalid }).description, className),\n \"data-slot\": \"field-description\",\n id: props.id ?? descriptionId,\n };\n\n if (!insideField) {\n return <p {...descriptionProps} ref={ref} />;\n }\n\n return <BaseField.Description {...descriptionProps} ref={ref} />;\n },\n);\n\nexport interface FieldErrorProps extends Omit<ComponentPropsWithoutRef<\"p\">, \"children\"> {\n children?: ReactNode;\n match?: boolean | keyof ValidityState;\n}\n\nexport const FieldError = forwardRef<HTMLParagraphElement, FieldErrorProps>(function FieldError(\n { children, className, match, ...props },\n ref,\n) {\n const { errorId, errors, insideField, invalid } = useContext(FieldContext);\n const content = children ?? renderErrors(errors);\n\n if (!insideField) {\n if (content === undefined || content === null || content === false) {\n return null;\n }\n\n return (\n <p\n {...props}\n ref={ref}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n role=\"alert\"\n >\n {content}\n </p>\n );\n }\n\n return (\n <BaseField.Error\n {...props}\n ref={ref as Ref<HTMLDivElement>}\n className={cx(field({ invalid }).error, className)}\n data-slot=\"field-error\"\n id={props.id ?? errorId}\n match={match ?? (invalid ? true : undefined)}\n render={<p />}\n role=\"alert\"\n >\n {content}\n </BaseField.Error>\n );\n});\n\nexport function useFieldState() {\n return useContext(FieldContext);\n}\n\nexport const Field = Object.assign(FieldRoot, {\n Root: FieldRoot,\n Control: FieldControl,\n Label: FieldLabel,\n Description: FieldDescription,\n Error: FieldError,\n});\n"],"mappings":";;;;;;;;AA4BA,MAAM,eAAe,cAAiC;CACpD,WAAW,KAAA;CACX,eAAe,KAAA;CACf,OAAO;CACP,SAAS,KAAA;CACT,QAAQ,CAAC;CACT,aAAa;CACb,SAAS;CACT,SAAS,KAAA;CACT,MAAM,KAAA;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT,CAAC;AAED,SAAS,gBAAgB,QAA0D;CACjF,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,OACxD,OAAO,CAAC;CAGV,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD;AAEA,SAAS,aAAa,QAAqB;CACzC,IAAI,OAAO,UAAU,GACnB,OAAO,OAAO;CAGhB,OACE,oBAAC,MAAD,EAAA,UACG,OAAO,KAAK,OAAO,UAClB,oBAAC,MAAD,EAAA,UAAqD,MAAU,GAAtD,OAAO,UAAU,WAAW,QAAQ,KAAkB,CAChE,EACC,CAAA;AAER;AA+BA,MAAMA,cAAY,WAAuC,SAASC,QAChE,EACE,YACA,UACA,WACA,OACA,WAAW,OACX,QAAQ,cACR,SAAS,cAAc,OACvB,MACA,SAAS,cAAc,OACvB,SACA,UACA,wBACA,gBACA,GAAG,SAEL,KACA;CACA,MAAM,cAAc,MAAM;CAC1B,MAAM,YAAY,GAAG,YAAY;CACjC,MAAM,UAAU,GAAG,YAAY;CAC/B,MAAM,gBAAgB,GAAG,YAAY;CACrC,MAAM,UAAU,GAAG,YAAY;CAC/B,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,KAAK;CAChE,MAAM,CAAC,kBAAkB,uBAAuB,SAAsB,CAAC,CAAC;CACxE,MAAM,CAAC,iBAAiB,sBAAsB,SAAyB,IAAI;CAC3E,MAAM,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AAX;EACE,GAAI;EACC;EACL,WAAW,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,SAAS;EACjD,aAAU;EACV,IAAI,MAAM,MAAM;EAChB,OAAO,UAAU,UAAU,OAAO,KAAA;EAClC,QAAQ,oBAAC,KAAD,CAAI,CAAA;EACZ,MAAK;YAEJ;CACc,CAAA;AAErB,CAAC;AAED,SAAgB,gBAAgB;CAC9B,OAAO,WAAW,YAAY;AAChC;AAEA,MAAaD,UAAQ,OAAO,OAAOD,aAAW;CAC5C,MAAMA;CACN,SAAS;CACT,OAAO;CACP,aAAa;CACb,OAAO;AACT,CAAC"}
@@ -1,2 +1,2 @@
1
- import { Field, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState } from "./field.cjs";
2
- export { Field, FieldDescription, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, type FieldValidationMode, useFieldState };
1
+ import { Field, FieldControl, FieldControlProps, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState } from "./field.cjs";
2
+ export { Field, FieldControl, type FieldControlProps, FieldDescription, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, type FieldValidationMode, useFieldState };
@@ -1,2 +1,2 @@
1
- import { Field, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState } from "./field.js";
2
- export { Field, FieldDescription, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, type FieldValidationMode, useFieldState };
1
+ import { Field, FieldControl, FieldControlProps, FieldDescription, FieldError, FieldErrorProps, FieldLabel, FieldLabelProps, FieldProps, FieldValidationMode, useFieldState } from "./field.js";
2
+ export { Field, FieldControl, type FieldControlProps, FieldDescription, FieldError, type FieldErrorProps, FieldLabel, type FieldLabelProps, type FieldProps, type FieldValidationMode, useFieldState };
@@ -0,0 +1,2 @@
1
+ import { PinInput, PinInputControl, PinInputControlProps, PinInputDescription, PinInputDescriptionProps, PinInputError, PinInputErrorProps, PinInputHiddenInput, PinInputHiddenInputProps, PinInputInput, PinInputInputProps, PinInputInputs, PinInputInputsProps, PinInputLabel, PinInputLabelProps, PinInputRoot, PinInputRootProps } from "./pin-input.cjs";
2
+ export { PinInput, PinInputControl, type PinInputControlProps, PinInputDescription, type PinInputDescriptionProps, PinInputError, type PinInputErrorProps, PinInputHiddenInput, type PinInputHiddenInputProps, PinInputInput, type PinInputInputProps, PinInputInputs, type PinInputInputsProps, PinInputLabel, type PinInputLabelProps, PinInputRoot, type PinInputRootProps };
@@ -0,0 +1,2 @@
1
+ import { PinInput, PinInputControl, PinInputControlProps, PinInputDescription, PinInputDescriptionProps, PinInputError, PinInputErrorProps, PinInputHiddenInput, PinInputHiddenInputProps, PinInputInput, PinInputInputProps, PinInputInputs, PinInputInputsProps, PinInputLabel, PinInputLabelProps, PinInputRoot, PinInputRootProps } from "./pin-input.js";
2
+ export { PinInput, PinInputControl, type PinInputControlProps, PinInputDescription, type PinInputDescriptionProps, PinInputError, type PinInputErrorProps, PinInputHiddenInput, type PinInputHiddenInputProps, PinInputInput, type PinInputInputProps, PinInputInputs, type PinInputInputsProps, PinInputLabel, type PinInputLabelProps, PinInputRoot, type PinInputRootProps };
@@ -0,0 +1,266 @@
1
+ "use client";
2
+ const require_cx = require("../../styled-system/css/cx.cjs");
3
+ const require_pin_input = require("../../styled-system/recipes/pin-input.cjs");
4
+ let react = require("react");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ //#region src/components/pin-input/pin-input.tsx
7
+ const PinInputContext = (0, react.createContext)(null);
8
+ function digitKey(index) {
9
+ return `digit-${index}`;
10
+ }
11
+ function usePinInputContext() {
12
+ const context = (0, react.useContext)(PinInputContext);
13
+ if (!context) throw new Error("PinInput parts must be rendered inside PinInput.Root.");
14
+ return context;
15
+ }
16
+ const PinInputRoot = (0, react.forwardRef)(function PinInputRoot({ autoFocus = false, children, className, defaultValue = "", disabled = false, id: providedId, invalid = false, length, name, onValueChange, onComplete, otp = false, type = "text", value: controlledValue, ...props }, ref) {
17
+ const generatedId = (0, react.useId)();
18
+ const id = providedId ?? generatedId;
19
+ const styles = require_pin_input.pinInput();
20
+ const safeLength = Math.max(1, Math.floor(length));
21
+ const [uncontrolledValue, setUncontrolledValue] = (0, react.useState)(() => defaultValue.slice(0, safeLength));
22
+ const value = (controlledValue ?? uncontrolledValue).slice(0, safeLength);
23
+ const inputRefs = (0, react.useRef)([]);
24
+ const composingRef = (0, react.useRef)(false);
25
+ const updateValue = (0, react.useCallback)((next) => {
26
+ const normalized = next.slice(0, safeLength);
27
+ if (controlledValue === void 0) setUncontrolledValue(normalized);
28
+ onValueChange?.(normalized);
29
+ if (normalized.length === safeLength) onComplete?.(normalized);
30
+ }, [
31
+ controlledValue,
32
+ onComplete,
33
+ onValueChange,
34
+ safeLength
35
+ ]);
36
+ const normalize = (0, react.useCallback)((next) => {
37
+ const characters = Array.from(next);
38
+ return (otp ? characters.filter((character) => /[0-9]/u.test(character)) : characters).join("").slice(0, safeLength);
39
+ }, [otp, safeLength]);
40
+ const focusIndex = (0, react.useCallback)((index) => {
41
+ inputRefs.current[Math.max(0, Math.min(safeLength - 1, index))]?.focus();
42
+ }, [safeLength]);
43
+ const onInput = (0, react.useCallback)((index, nextCharacter) => {
44
+ if (composingRef.current) return;
45
+ const characters = Array.from(value);
46
+ const next = normalize(nextCharacter).slice(-1);
47
+ characters[index] = next;
48
+ const nextValue = characters.join("").slice(0, safeLength);
49
+ updateValue(nextValue);
50
+ if (next) focusIndex(index + 1);
51
+ }, [
52
+ focusIndex,
53
+ normalize,
54
+ safeLength,
55
+ updateValue,
56
+ value
57
+ ]);
58
+ const onCompositionStart = (0, react.useCallback)(() => {
59
+ composingRef.current = true;
60
+ }, []);
61
+ const onCompositionEnd = (0, react.useCallback)((index, event) => {
62
+ composingRef.current = false;
63
+ onInput(index, event.currentTarget.value);
64
+ }, [onInput]);
65
+ const onPaste = (0, react.useCallback)((index, event) => {
66
+ event.preventDefault();
67
+ const pasted = normalize(event.clipboardData.getData("text"));
68
+ if (!pasted) return;
69
+ const characters = Array.from(value);
70
+ Array.from(pasted).forEach((character, offset) => {
71
+ if (index + offset < safeLength) characters[index + offset] = character;
72
+ });
73
+ const nextValue = characters.join("").slice(0, safeLength);
74
+ updateValue(nextValue);
75
+ focusIndex(Math.min(safeLength - 1, index + pasted.length));
76
+ }, [
77
+ focusIndex,
78
+ normalize,
79
+ safeLength,
80
+ updateValue,
81
+ value
82
+ ]);
83
+ const context = {
84
+ disabled,
85
+ id,
86
+ invalid,
87
+ inputRefs,
88
+ length: safeLength,
89
+ onInput,
90
+ onCompositionEnd,
91
+ onCompositionStart,
92
+ onKeyDown: (0, react.useCallback)((index, event) => {
93
+ if (event.key === "Backspace" && !event.currentTarget.value && index > 0) {
94
+ event.preventDefault();
95
+ const characters = Array.from(value);
96
+ characters[index - 1] = "";
97
+ updateValue(characters.join(""));
98
+ focusIndex(index - 1);
99
+ } else if (event.key === "ArrowLeft") {
100
+ event.preventDefault();
101
+ focusIndex(index - 1);
102
+ } else if (event.key === "ArrowRight") {
103
+ event.preventDefault();
104
+ focusIndex(index + 1);
105
+ } else if (event.key === "Home") {
106
+ event.preventDefault();
107
+ focusIndex(0);
108
+ } else if (event.key === "End") {
109
+ event.preventDefault();
110
+ focusIndex(safeLength - 1);
111
+ }
112
+ }, [
113
+ focusIndex,
114
+ safeLength,
115
+ updateValue,
116
+ value
117
+ ]),
118
+ onPaste,
119
+ otp,
120
+ styles,
121
+ type,
122
+ value
123
+ };
124
+ (0, react.useEffect)(() => {
125
+ if (autoFocus) inputRefs.current[0]?.focus();
126
+ }, [autoFocus]);
127
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
128
+ ...props,
129
+ className: require_cx.cx(styles.root, className),
130
+ "data-disabled": disabled || void 0,
131
+ "data-invalid": invalid || void 0,
132
+ "data-jaci-component": "pin-input",
133
+ "data-slot": "pin-input",
134
+ id,
135
+ ref,
136
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PinInputContext.Provider, {
137
+ value: context,
138
+ children
139
+ }), name ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
140
+ "aria-hidden": "true",
141
+ className: styles.hiddenInput,
142
+ disabled,
143
+ name,
144
+ tabIndex: -1,
145
+ value,
146
+ readOnly: true
147
+ }) : null]
148
+ });
149
+ });
150
+ const PinInputLabel = (0, react.forwardRef)(function PinInputLabel({ className, ...props }, ref) {
151
+ const { id, styles } = usePinInputContext();
152
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
153
+ ...props,
154
+ className: require_cx.cx(styles.label, className),
155
+ "data-slot": "pin-input-label",
156
+ htmlFor: props.htmlFor ?? `${id}-0`,
157
+ ref
158
+ });
159
+ });
160
+ const PinInputControl = (0, react.forwardRef)(function PinInputControl({ className, ...props }, ref) {
161
+ const { styles } = usePinInputContext();
162
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
163
+ ...props,
164
+ className: require_cx.cx(styles.control, className),
165
+ "data-slot": "pin-input-control",
166
+ ref
167
+ });
168
+ });
169
+ const PinInputInputs = (0, react.forwardRef)(function PinInputInputs({ className, ...props }, ref) {
170
+ const { length, styles } = usePinInputContext();
171
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
172
+ ...props,
173
+ className: require_cx.cx(styles.inputs, className),
174
+ "data-slot": "pin-input-inputs",
175
+ ref,
176
+ children: Array.from({ length }, (_, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PinInputInput, { index }, digitKey(index)))
177
+ });
178
+ });
179
+ const PinInputInput = (0, react.forwardRef)(function PinInputInput({ className, index, id, onCompositionEnd: onInputCompositionEnd, onCompositionStart: onInputCompositionStart, ...props }, ref) {
180
+ const { disabled, id: rootId, inputRefs, invalid, length, onInput, onCompositionEnd, onCompositionStart, onKeyDown, onPaste, otp, styles, type, value } = usePinInputContext();
181
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
182
+ ...props,
183
+ "aria-label": props["aria-label"] ?? `Digit ${index + 1} of ${length}`,
184
+ "aria-invalid": invalid || void 0,
185
+ autoComplete: otp ? "one-time-code" : props.autoComplete,
186
+ className: require_cx.cx(styles.input, className),
187
+ "data-slot": "pin-input-input",
188
+ disabled: disabled || props.disabled,
189
+ id: id ?? `${rootId}-${index}`,
190
+ inputMode: otp ? "numeric" : props.inputMode,
191
+ maxLength: 1,
192
+ onChange: (event) => onInput(index, event.currentTarget.value),
193
+ onCompositionEnd: (event) => {
194
+ onCompositionEnd(index, event);
195
+ onInputCompositionEnd?.(event);
196
+ },
197
+ onCompositionStart: (event) => {
198
+ onCompositionStart();
199
+ onInputCompositionStart?.(event);
200
+ },
201
+ onKeyDown: (event) => onKeyDown(index, event),
202
+ onPaste: (event) => onPaste(index, event),
203
+ ref: (node) => {
204
+ inputRefs.current[index] = node;
205
+ if (typeof ref === "function") ref(node);
206
+ else if (ref) ref.current = node;
207
+ },
208
+ type,
209
+ value: Array.from(value)[index] ?? ""
210
+ });
211
+ });
212
+ const PinInputDescription = (0, react.forwardRef)(function PinInputDescription({ className, ...props }, ref) {
213
+ const { styles } = usePinInputContext();
214
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
215
+ ...props,
216
+ className: require_cx.cx(styles.description, className),
217
+ "data-slot": "pin-input-description",
218
+ ref
219
+ });
220
+ });
221
+ const PinInputError = (0, react.forwardRef)(function PinInputError({ className, ...props }, ref) {
222
+ const { styles } = usePinInputContext();
223
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
224
+ ...props,
225
+ className: require_cx.cx(styles.error, className),
226
+ "data-slot": "pin-input-error",
227
+ role: "alert",
228
+ ref
229
+ });
230
+ });
231
+ const PinInputHiddenInput = (0, react.forwardRef)(function PinInputHiddenInput(props, ref) {
232
+ const { disabled, styles, value } = usePinInputContext();
233
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
234
+ ...props,
235
+ "aria-hidden": "true",
236
+ className: styles.hiddenInput,
237
+ disabled: disabled || props.disabled,
238
+ readOnly: true,
239
+ ref,
240
+ tabIndex: -1,
241
+ type: "hidden",
242
+ value
243
+ });
244
+ });
245
+ const PinInput = {
246
+ Root: PinInputRoot,
247
+ Label: PinInputLabel,
248
+ Control: PinInputControl,
249
+ Inputs: PinInputInputs,
250
+ Input: PinInputInput,
251
+ Description: PinInputDescription,
252
+ Error: PinInputError,
253
+ HiddenInput: PinInputHiddenInput
254
+ };
255
+ //#endregion
256
+ exports.PinInput = PinInput;
257
+ exports.PinInputControl = PinInputControl;
258
+ exports.PinInputDescription = PinInputDescription;
259
+ exports.PinInputError = PinInputError;
260
+ exports.PinInputHiddenInput = PinInputHiddenInput;
261
+ exports.PinInputInput = PinInputInput;
262
+ exports.PinInputInputs = PinInputInputs;
263
+ exports.PinInputLabel = PinInputLabel;
264
+ exports.PinInputRoot = PinInputRoot;
265
+
266
+ //# sourceMappingURL=pin-input.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pin-input.cjs","names":["pinInput","cx"],"sources":["../../../src/components/pin-input/pin-input.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useId,\n useRef,\n useState,\n} from \"react\";\nimport type {\n ClipboardEvent,\n CompositionEvent,\n ComponentPropsWithoutRef,\n KeyboardEvent,\n MutableRefObject,\n ReactNode,\n} from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { pinInput } from \"../../styled-system/recipes\";\n\ninterface PinInputContextValue {\n disabled: boolean;\n id: string;\n invalid: boolean;\n inputRefs: MutableRefObject<Array<HTMLInputElement | null>>;\n length: number;\n onInput: (index: number, value: string) => void;\n onCompositionEnd: (index: number, event: CompositionEvent<HTMLInputElement>) => void;\n onCompositionStart: () => void;\n onKeyDown: (index: number, event: KeyboardEvent<HTMLInputElement>) => void;\n onPaste: (index: number, event: ClipboardEvent<HTMLInputElement>) => void;\n otp: boolean;\n styles: ReturnType<typeof pinInput>;\n type: \"text\" | \"password\";\n value: string;\n}\n\nconst PinInputContext = createContext<PinInputContextValue | null>(null);\n\nfunction digitKey(index: number) {\n return `digit-${index}`;\n}\n\nfunction usePinInputContext() {\n const context = useContext(PinInputContext);\n if (!context) throw new Error(\"PinInput parts must be rendered inside PinInput.Root.\");\n return context;\n}\n\nexport interface PinInputRootProps\n extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\" | \"defaultValue\"> {\n length: number;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n onComplete?: (value: string) => void;\n type?: \"text\" | \"password\";\n otp?: boolean;\n autoFocus?: boolean;\n disabled?: boolean;\n invalid?: boolean;\n name?: string;\n children?: ReactNode;\n}\n\nexport const PinInputRoot = forwardRef<HTMLDivElement, PinInputRootProps>(function PinInputRoot(\n {\n autoFocus = false,\n children,\n className,\n defaultValue = \"\",\n disabled = false,\n id: providedId,\n invalid = false,\n length,\n name,\n onValueChange,\n onComplete,\n otp = false,\n type = \"text\",\n value: controlledValue,\n ...props\n },\n ref,\n) {\n const generatedId = useId();\n const id = providedId ?? generatedId;\n const styles = pinInput();\n const safeLength = Math.max(1, Math.floor(length));\n const [uncontrolledValue, setUncontrolledValue] = useState(() =>\n defaultValue.slice(0, safeLength),\n );\n const value = (controlledValue ?? uncontrolledValue).slice(0, safeLength);\n const inputRefs = useRef<Array<HTMLInputElement | null>>([]);\n const composingRef = useRef(false);\n const updateValue = useCallback(\n (next: string) => {\n const normalized = next.slice(0, safeLength);\n if (controlledValue === undefined) setUncontrolledValue(normalized);\n onValueChange?.(normalized);\n if (normalized.length === safeLength) onComplete?.(normalized);\n },\n [controlledValue, onComplete, onValueChange, safeLength],\n );\n const normalize = useCallback(\n (next: string) => {\n const characters = Array.from(next);\n return (otp ? characters.filter((character) => /[0-9]/u.test(character)) : characters)\n .join(\"\")\n .slice(0, safeLength);\n },\n [otp, safeLength],\n );\n const focusIndex = useCallback(\n (index: number) => {\n inputRefs.current[Math.max(0, Math.min(safeLength - 1, index))]?.focus();\n },\n [safeLength],\n );\n const onInput = useCallback(\n (index: number, nextCharacter: string) => {\n if (composingRef.current) return;\n const characters = Array.from(value);\n const next = normalize(nextCharacter).slice(-1);\n characters[index] = next;\n const nextValue = characters.join(\"\").slice(0, safeLength);\n updateValue(nextValue);\n if (next) focusIndex(index + 1);\n },\n [focusIndex, normalize, safeLength, updateValue, value],\n );\n const onCompositionStart = useCallback(() => {\n composingRef.current = true;\n }, []);\n const onCompositionEnd = useCallback(\n (index: number, event: CompositionEvent<HTMLInputElement>) => {\n composingRef.current = false;\n onInput(index, event.currentTarget.value);\n },\n [onInput],\n );\n const onPaste = useCallback(\n (index: number, event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n const pasted = normalize(event.clipboardData.getData(\"text\"));\n if (!pasted) return;\n const characters = Array.from(value);\n Array.from(pasted).forEach((character, offset) => {\n if (index + offset < safeLength) characters[index + offset] = character;\n });\n const nextValue = characters.join(\"\").slice(0, safeLength);\n updateValue(nextValue);\n focusIndex(Math.min(safeLength - 1, index + pasted.length));\n },\n [focusIndex, normalize, safeLength, updateValue, value],\n );\n const onKeyDown = useCallback(\n (index: number, event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Backspace\" && !event.currentTarget.value && index > 0) {\n event.preventDefault();\n const characters = Array.from(value);\n characters[index - 1] = \"\";\n updateValue(characters.join(\"\"));\n focusIndex(index - 1);\n } else if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n focusIndex(index - 1);\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n focusIndex(index + 1);\n } else if (event.key === \"Home\") {\n event.preventDefault();\n focusIndex(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n focusIndex(safeLength - 1);\n }\n },\n [focusIndex, safeLength, updateValue, value],\n );\n const context: PinInputContextValue = {\n disabled,\n id,\n invalid,\n inputRefs,\n length: safeLength,\n onInput,\n onCompositionEnd,\n onCompositionStart,\n onKeyDown,\n onPaste,\n otp,\n styles,\n type,\n value,\n };\n\n useEffect(() => {\n if (autoFocus) inputRefs.current[0]?.focus();\n }, [autoFocus]);\n\n return (\n <div\n {...props}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-invalid={invalid || undefined}\n data-jaci-component=\"pin-input\"\n data-slot=\"pin-input\"\n id={id}\n ref={ref}\n >\n <PinInputContext.Provider value={context}>{children}</PinInputContext.Provider>\n {name ? (\n <input\n aria-hidden=\"true\"\n className={styles.hiddenInput}\n disabled={disabled}\n name={name}\n tabIndex={-1}\n value={value}\n readOnly\n />\n ) : null}\n </div>\n );\n});\n\nexport type PinInputLabelProps = ComponentPropsWithoutRef<\"label\">;\nexport const PinInputLabel = forwardRef<HTMLLabelElement, PinInputLabelProps>(\n function PinInputLabel({ className, ...props }, ref) {\n const { id, styles } = usePinInputContext();\n return (\n // biome-ignore lint/a11y/noLabelWithoutControl: the generated Inputs slot supplies the control.\n <label\n {...props}\n className={cx(styles.label, className)}\n data-slot=\"pin-input-label\"\n htmlFor={props.htmlFor ?? `${id}-0`}\n ref={ref}\n />\n );\n },\n);\n\nexport type PinInputControlProps = ComponentPropsWithoutRef<\"div\">;\nexport const PinInputControl = forwardRef<HTMLDivElement, PinInputControlProps>(\n function PinInputControl({ className, ...props }, ref) {\n const { styles } = usePinInputContext();\n return (\n <div\n {...props}\n className={cx(styles.control, className)}\n data-slot=\"pin-input-control\"\n ref={ref}\n />\n );\n },\n);\n\nexport type PinInputInputsProps = ComponentPropsWithoutRef<\"div\">;\nexport const PinInputInputs = forwardRef<HTMLDivElement, PinInputInputsProps>(\n function PinInputInputs({ className, ...props }, ref) {\n const { length, styles } = usePinInputContext();\n return (\n <div\n {...props}\n className={cx(styles.inputs, className)}\n data-slot=\"pin-input-inputs\"\n ref={ref}\n >\n {Array.from({ length }, (_, index) => (\n <PinInputInput index={index} key={digitKey(index)} />\n ))}\n </div>\n );\n },\n);\n\nexport interface PinInputInputProps\n extends Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"defaultValue\" | \"onChange\" | \"onKeyDown\" | \"onPaste\" | \"type\" | \"value\"\n > {\n index: number;\n}\nexport const PinInputInput = forwardRef<HTMLInputElement, PinInputInputProps>(\n function PinInputInput(\n {\n className,\n index,\n id,\n onCompositionEnd: onInputCompositionEnd,\n onCompositionStart: onInputCompositionStart,\n ...props\n },\n ref,\n ) {\n const {\n disabled,\n id: rootId,\n inputRefs,\n invalid,\n length,\n onInput,\n onCompositionEnd,\n onCompositionStart,\n onKeyDown,\n onPaste,\n otp,\n styles,\n type,\n value,\n } = usePinInputContext();\n return (\n <input\n {...props}\n aria-label={props[\"aria-label\"] ?? `Digit ${index + 1} of ${length}`}\n aria-invalid={invalid || undefined}\n autoComplete={otp ? \"one-time-code\" : props.autoComplete}\n className={cx(styles.input, className)}\n data-slot=\"pin-input-input\"\n disabled={disabled || props.disabled}\n id={id ?? `${rootId}-${index}`}\n inputMode={otp ? \"numeric\" : props.inputMode}\n maxLength={1}\n onChange={(event) => onInput(index, event.currentTarget.value)}\n onCompositionEnd={(event) => {\n onCompositionEnd(index, event);\n onInputCompositionEnd?.(event);\n }}\n onCompositionStart={(event) => {\n onCompositionStart();\n onInputCompositionStart?.(event);\n }}\n onKeyDown={(event) => onKeyDown(index, event)}\n onPaste={(event) => onPaste(index, event)}\n ref={(node) => {\n inputRefs.current[index] = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }}\n type={type}\n value={Array.from(value)[index] ?? \"\"}\n />\n );\n },\n);\n\nexport type PinInputDescriptionProps = ComponentPropsWithoutRef<\"p\">;\nexport const PinInputDescription = forwardRef<HTMLParagraphElement, PinInputDescriptionProps>(\n function PinInputDescription({ className, ...props }, ref) {\n const { styles } = usePinInputContext();\n return (\n <p\n {...props}\n className={cx(styles.description, className)}\n data-slot=\"pin-input-description\"\n ref={ref}\n />\n );\n },\n);\nexport type PinInputErrorProps = ComponentPropsWithoutRef<\"p\">;\nexport const PinInputError = forwardRef<HTMLParagraphElement, PinInputErrorProps>(\n function PinInputError({ className, ...props }, ref) {\n const { styles } = usePinInputContext();\n return (\n <p\n {...props}\n className={cx(styles.error, className)}\n data-slot=\"pin-input-error\"\n role=\"alert\"\n ref={ref}\n />\n );\n },\n);\nexport type PinInputHiddenInputProps = Omit<\n ComponentPropsWithoutRef<\"input\">,\n \"name\" | \"type\" | \"value\"\n>;\nexport const PinInputHiddenInput = forwardRef<HTMLInputElement, PinInputHiddenInputProps>(\n function PinInputHiddenInput(props, ref) {\n const { disabled, styles, value } = usePinInputContext();\n return (\n <input\n {...props}\n aria-hidden=\"true\"\n className={styles.hiddenInput}\n disabled={disabled || props.disabled}\n readOnly\n ref={ref}\n tabIndex={-1}\n type=\"hidden\"\n value={value}\n />\n );\n },\n);\n\nexport const PinInput = {\n Root: PinInputRoot,\n Label: PinInputLabel,\n Control: PinInputControl,\n Inputs: PinInputInputs,\n Input: PinInputInput,\n Description: PinInputDescription,\n Error: PinInputError,\n HiddenInput: PinInputHiddenInput,\n};\n"],"mappings":";;;;;;AAyCA,MAAM,mBAAA,GAAA,MAAA,cAAA,CAA6D,IAAI;AAEvE,SAAS,SAAS,OAAe;CAC/B,OAAO,SAAS;AAClB;AAEA,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAkBA,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA6D,SAAS,aACjF,EACE,YAAY,OACZ,UACA,WACA,eAAe,IACf,WAAW,OACX,IAAI,YACJ,UAAU,OACV,QACA,MACA,eACA,YACA,MAAM,OACN,OAAO,QACP,OAAO,iBACP,GAAG,SAEL,KACA;CACA,MAAM,eAAA,GAAA,MAAA,MAAA,CAAoB;CAC1B,MAAM,KAAK,cAAc;CACz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ACR,CAAA;AAEL,CACF;AAEA,MAAa,WAAW;CACtB,MAAM;CACN,OAAO;CACP,SAAS;CACT,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,aAAa;AACf"}
@@ -0,0 +1,46 @@
1
+ import { ComponentPropsWithoutRef, ReactNode } from "react";
2
+ //#region src/components/pin-input/pin-input.d.ts
3
+ interface PinInputRootProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "defaultValue"> {
4
+ length: number;
5
+ value?: string;
6
+ defaultValue?: string;
7
+ onValueChange?: (value: string) => void;
8
+ onComplete?: (value: string) => void;
9
+ type?: "text" | "password";
10
+ otp?: boolean;
11
+ autoFocus?: boolean;
12
+ disabled?: boolean;
13
+ invalid?: boolean;
14
+ name?: string;
15
+ children?: ReactNode;
16
+ }
17
+ declare const PinInputRoot: import("react").ForwardRefExoticComponent<PinInputRootProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ type PinInputLabelProps = ComponentPropsWithoutRef<"label">;
19
+ declare const PinInputLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
20
+ type PinInputControlProps = ComponentPropsWithoutRef<"div">;
21
+ declare const PinInputControl: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
22
+ type PinInputInputsProps = ComponentPropsWithoutRef<"div">;
23
+ declare const PinInputInputs: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
24
+ interface PinInputInputProps extends Omit<ComponentPropsWithoutRef<"input">, "defaultValue" | "onChange" | "onKeyDown" | "onPaste" | "type" | "value"> {
25
+ index: number;
26
+ }
27
+ declare const PinInputInput: import("react").ForwardRefExoticComponent<PinInputInputProps & import("react").RefAttributes<HTMLInputElement>>;
28
+ type PinInputDescriptionProps = ComponentPropsWithoutRef<"p">;
29
+ declare const PinInputDescription: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
30
+ type PinInputErrorProps = ComponentPropsWithoutRef<"p">;
31
+ declare const PinInputError: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
32
+ type PinInputHiddenInputProps = Omit<ComponentPropsWithoutRef<"input">, "name" | "type" | "value">;
33
+ declare const PinInputHiddenInput: import("react").ForwardRefExoticComponent<PinInputHiddenInputProps & import("react").RefAttributes<HTMLInputElement>>;
34
+ declare const PinInput: {
35
+ Root: import("react").ForwardRefExoticComponent<PinInputRootProps & import("react").RefAttributes<HTMLDivElement>>;
36
+ Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
37
+ Control: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
38
+ Inputs: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
39
+ Input: import("react").ForwardRefExoticComponent<PinInputInputProps & import("react").RefAttributes<HTMLInputElement>>;
40
+ Description: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
41
+ Error: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
42
+ HiddenInput: import("react").ForwardRefExoticComponent<PinInputHiddenInputProps & import("react").RefAttributes<HTMLInputElement>>;
43
+ };
44
+ //#endregion
45
+ export { PinInput, PinInputControl, PinInputControlProps, PinInputDescription, PinInputDescriptionProps, PinInputError, PinInputErrorProps, PinInputHiddenInput, PinInputHiddenInputProps, PinInputInput, PinInputInputProps, PinInputInputs, PinInputInputsProps, PinInputLabel, PinInputLabelProps, PinInputRoot, PinInputRootProps };
46
+ //# sourceMappingURL=pin-input.d.cts.map
@@ -0,0 +1,46 @@
1
+ import { ComponentPropsWithoutRef, ReactNode } from "react";
2
+ //#region src/components/pin-input/pin-input.d.ts
3
+ interface PinInputRootProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "defaultValue"> {
4
+ length: number;
5
+ value?: string;
6
+ defaultValue?: string;
7
+ onValueChange?: (value: string) => void;
8
+ onComplete?: (value: string) => void;
9
+ type?: "text" | "password";
10
+ otp?: boolean;
11
+ autoFocus?: boolean;
12
+ disabled?: boolean;
13
+ invalid?: boolean;
14
+ name?: string;
15
+ children?: ReactNode;
16
+ }
17
+ declare const PinInputRoot: import("react").ForwardRefExoticComponent<PinInputRootProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ type PinInputLabelProps = ComponentPropsWithoutRef<"label">;
19
+ declare const PinInputLabel: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
20
+ type PinInputControlProps = ComponentPropsWithoutRef<"div">;
21
+ declare const PinInputControl: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
22
+ type PinInputInputsProps = ComponentPropsWithoutRef<"div">;
23
+ declare const PinInputInputs: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
24
+ interface PinInputInputProps extends Omit<ComponentPropsWithoutRef<"input">, "defaultValue" | "onChange" | "onKeyDown" | "onPaste" | "type" | "value"> {
25
+ index: number;
26
+ }
27
+ declare const PinInputInput: import("react").ForwardRefExoticComponent<PinInputInputProps & import("react").RefAttributes<HTMLInputElement>>;
28
+ type PinInputDescriptionProps = ComponentPropsWithoutRef<"p">;
29
+ declare const PinInputDescription: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
30
+ type PinInputErrorProps = ComponentPropsWithoutRef<"p">;
31
+ declare const PinInputError: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
32
+ type PinInputHiddenInputProps = Omit<ComponentPropsWithoutRef<"input">, "name" | "type" | "value">;
33
+ declare const PinInputHiddenInput: import("react").ForwardRefExoticComponent<PinInputHiddenInputProps & import("react").RefAttributes<HTMLInputElement>>;
34
+ declare const PinInput: {
35
+ Root: import("react").ForwardRefExoticComponent<PinInputRootProps & import("react").RefAttributes<HTMLDivElement>>;
36
+ Label: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
37
+ Control: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
38
+ Inputs: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
39
+ Input: import("react").ForwardRefExoticComponent<PinInputInputProps & import("react").RefAttributes<HTMLInputElement>>;
40
+ Description: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
41
+ Error: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
42
+ HiddenInput: import("react").ForwardRefExoticComponent<PinInputHiddenInputProps & import("react").RefAttributes<HTMLInputElement>>;
43
+ };
44
+ //#endregion
45
+ export { PinInput, PinInputControl, PinInputControlProps, PinInputDescription, PinInputDescriptionProps, PinInputError, PinInputErrorProps, PinInputHiddenInput, PinInputHiddenInputProps, PinInputInput, PinInputInputProps, PinInputInputs, PinInputInputsProps, PinInputLabel, PinInputLabelProps, PinInputRoot, PinInputRootProps };
46
+ //# sourceMappingURL=pin-input.d.ts.map