jaci-ui 0.9.4 → 1.0.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 (166) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +11 -1
  3. package/dist/_virtual/_rolldown/runtime.cjs +1 -1
  4. package/dist/components/accordion/accordion.cjs.map +1 -1
  5. package/dist/components/accordion/accordion.js.map +1 -1
  6. package/dist/components/alert/alert.cjs.map +1 -1
  7. package/dist/components/alert/alert.js.map +1 -1
  8. package/dist/components/alert-dialog/alert-dialog.cjs.map +1 -1
  9. package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
  10. package/dist/components/aspect-ratio/aspect-ratio.cjs.map +1 -1
  11. package/dist/components/avatar/avatar.cjs.map +1 -1
  12. package/dist/components/avatar/avatar.js.map +1 -1
  13. package/dist/components/breadcrumbs/breadcrumbs.cjs.map +1 -1
  14. package/dist/components/button/button.cjs +1 -0
  15. package/dist/components/button/button.cjs.map +1 -1
  16. package/dist/components/button/button.d.cts +2 -1
  17. package/dist/components/button/button.d.ts +2 -1
  18. package/dist/components/button/button.js +1 -0
  19. package/dist/components/button/button.js.map +1 -1
  20. package/dist/components/button-group/button-group.cjs.map +1 -1
  21. package/dist/components/calendar/calendar.cjs +4 -6
  22. package/dist/components/calendar/calendar.cjs.map +1 -1
  23. package/dist/components/calendar/calendar.js +4 -6
  24. package/dist/components/calendar/calendar.js.map +1 -1
  25. package/dist/components/card/card.cjs.map +1 -1
  26. package/dist/components/carousel/carousel.cjs.map +1 -1
  27. package/dist/components/carousel/carousel.js.map +1 -1
  28. package/dist/components/checkbox-group/checkbox-group.cjs +7 -3
  29. package/dist/components/checkbox-group/checkbox-group.cjs.map +1 -1
  30. package/dist/components/checkbox-group/checkbox-group.js +7 -3
  31. package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
  32. package/dist/components/code/code.cjs.map +1 -1
  33. package/dist/components/code/code.js.map +1 -1
  34. package/dist/components/collapsible/collapsible.cjs.map +1 -1
  35. package/dist/components/collapsible/collapsible.js.map +1 -1
  36. package/dist/components/color-picker/color-picker.cjs.map +1 -1
  37. package/dist/components/color-picker/color-picker.js.map +1 -1
  38. package/dist/components/color-swatch/color-swatch.cjs.map +1 -1
  39. package/dist/components/combobox/combobox.cjs +2 -1
  40. package/dist/components/combobox/combobox.cjs.map +1 -1
  41. package/dist/components/combobox/combobox.js +2 -1
  42. package/dist/components/combobox/combobox.js.map +1 -1
  43. package/dist/components/command/command.cjs.map +1 -1
  44. package/dist/components/command/command.js.map +1 -1
  45. package/dist/components/context-menu/context-menu.cjs.map +1 -1
  46. package/dist/components/controls/checkbox.cjs.map +1 -1
  47. package/dist/components/controls/checkbox.js.map +1 -1
  48. package/dist/components/controls/input.cjs.map +1 -1
  49. package/dist/components/controls/input.js.map +1 -1
  50. package/dist/components/controls/radio.cjs.map +1 -1
  51. package/dist/components/controls/switch.cjs.map +1 -1
  52. package/dist/components/controls/switch.js.map +1 -1
  53. package/dist/components/controls/textarea.cjs.map +1 -1
  54. package/dist/components/controls/textarea.js.map +1 -1
  55. package/dist/components/copyable/copyable.cjs.map +1 -1
  56. package/dist/components/copyable/copyable.js.map +1 -1
  57. package/dist/components/data-toolbar/data-toolbar.cjs.map +1 -1
  58. package/dist/components/data-toolbar/data-toolbar.js.map +1 -1
  59. package/dist/components/data-view/data-view.cjs.map +1 -1
  60. package/dist/components/date-picker/date-picker.cjs +4 -7
  61. package/dist/components/date-picker/date-picker.cjs.map +1 -1
  62. package/dist/components/date-picker/date-picker.js +4 -7
  63. package/dist/components/date-picker/date-picker.js.map +1 -1
  64. package/dist/components/date-range-picker/date-range-picker.cjs +4 -6
  65. package/dist/components/date-range-picker/date-range-picker.cjs.map +1 -1
  66. package/dist/components/date-range-picker/date-range-picker.js +4 -6
  67. package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
  68. package/dist/components/dialog/dialog.cjs.map +1 -1
  69. package/dist/components/dialog/dialog.js.map +1 -1
  70. package/dist/components/download-trigger/download-trigger.cjs.map +1 -1
  71. package/dist/components/drawer/drawer.cjs.map +1 -1
  72. package/dist/components/drawer/drawer.js.map +1 -1
  73. package/dist/components/empty-state/empty-state.cjs.map +1 -1
  74. package/dist/components/feedback/badge.cjs.map +1 -1
  75. package/dist/components/field/field.cjs.map +1 -1
  76. package/dist/components/field/field.js.map +1 -1
  77. package/dist/components/fieldset/fieldset.cjs.map +1 -1
  78. package/dist/components/figure/figure.cjs.map +1 -1
  79. package/dist/components/figure/figure.js.map +1 -1
  80. package/dist/components/form/form.cjs.map +1 -1
  81. package/dist/components/form/form.js.map +1 -1
  82. package/dist/components/icon-button/icon-button.cjs.map +1 -1
  83. package/dist/components/icon-button/icon-button.js.map +1 -1
  84. package/dist/components/image/image.cjs.map +1 -1
  85. package/dist/components/image/image.js.map +1 -1
  86. package/dist/components/input-group/input-group.cjs.map +1 -1
  87. package/dist/components/kbd/kbd.cjs.map +1 -1
  88. package/dist/components/layout/index.cjs.map +1 -1
  89. package/dist/components/list/list.cjs.map +1 -1
  90. package/dist/components/menu/menu.cjs.map +1 -1
  91. package/dist/components/menubar/menubar.cjs.map +1 -1
  92. package/dist/components/menubar/menubar.js.map +1 -1
  93. package/dist/components/meter/meter.cjs.map +1 -1
  94. package/dist/components/meter/meter.js.map +1 -1
  95. package/dist/components/navigation/navigation.cjs.map +1 -1
  96. package/dist/components/navigation/navigation.js.map +1 -1
  97. package/dist/components/navigation-menu/navigation-menu.cjs.map +1 -1
  98. package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
  99. package/dist/components/number-field/number-field.cjs +2 -1
  100. package/dist/components/number-field/number-field.cjs.map +1 -1
  101. package/dist/components/number-field/number-field.js +2 -1
  102. package/dist/components/number-field/number-field.js.map +1 -1
  103. package/dist/components/option-selector/option-selector.cjs.map +1 -1
  104. package/dist/components/option-selector/option-selector.js.map +1 -1
  105. package/dist/components/pagination/pagination.cjs.map +1 -1
  106. package/dist/components/pagination/pagination.js.map +1 -1
  107. package/dist/components/pin-input/pin-input.cjs.map +1 -1
  108. package/dist/components/pin-input/pin-input.js.map +1 -1
  109. package/dist/components/popover/popover.cjs.map +1 -1
  110. package/dist/components/popover/popover.js.map +1 -1
  111. package/dist/components/progress/progress.cjs.map +1 -1
  112. package/dist/components/progress/progress.js.map +1 -1
  113. package/dist/components/qr-code/qr-code.cjs.map +1 -1
  114. package/dist/components/qr-code/qr-code.js.map +1 -1
  115. package/dist/components/quote/quote.cjs.map +1 -1
  116. package/dist/components/quote/quote.js.map +1 -1
  117. package/dist/components/radio-group/radio-group.cjs +7 -3
  118. package/dist/components/radio-group/radio-group.cjs.map +1 -1
  119. package/dist/components/radio-group/radio-group.js +7 -3
  120. package/dist/components/radio-group/radio-group.js.map +1 -1
  121. package/dist/components/range-slider/range-slider.cjs.map +1 -1
  122. package/dist/components/range-slider/range-slider.js.map +1 -1
  123. package/dist/components/scroll-area/scroll-area.cjs.map +1 -1
  124. package/dist/components/select/select.cjs.map +1 -1
  125. package/dist/components/select/select.js.map +1 -1
  126. package/dist/components/sidebar/sidebar.cjs.map +1 -1
  127. package/dist/components/sidebar/sidebar.js.map +1 -1
  128. package/dist/components/skeleton/skeleton.cjs.map +1 -1
  129. package/dist/components/slider/slider.cjs.map +1 -1
  130. package/dist/components/slider/slider.js.map +1 -1
  131. package/dist/components/spacer/spacer.cjs.map +1 -1
  132. package/dist/components/stat/stat.cjs.map +1 -1
  133. package/dist/components/stat/stat.js.map +1 -1
  134. package/dist/components/stepper/stepper.cjs +2 -1
  135. package/dist/components/stepper/stepper.cjs.map +1 -1
  136. package/dist/components/stepper/stepper.js +2 -1
  137. package/dist/components/stepper/stepper.js.map +1 -1
  138. package/dist/components/table/table.cjs.map +1 -1
  139. package/dist/components/table/table.js.map +1 -1
  140. package/dist/components/tabs/tabs.cjs.map +1 -1
  141. package/dist/components/tabs/tabs.js.map +1 -1
  142. package/dist/components/tags-input/tags-input.cjs.map +1 -1
  143. package/dist/components/tags-input/tags-input.js.map +1 -1
  144. package/dist/components/toast/toast.cjs.map +1 -1
  145. package/dist/components/toast/toast.js.map +1 -1
  146. package/dist/components/toggle/toggle.cjs.map +1 -1
  147. package/dist/components/toggle-group/toggle-group.cjs.map +1 -1
  148. package/dist/components/toolbar/toolbar.cjs.map +1 -1
  149. package/dist/components/tooltip/tooltip.cjs.map +1 -1
  150. package/dist/components/tree-view/tree-view.cjs.map +1 -1
  151. package/dist/components/tree-view/tree-view.js.map +1 -1
  152. package/dist/components/typography/heading.cjs.map +1 -1
  153. package/dist/components/typography/link.cjs.map +1 -1
  154. package/dist/components/typography/paragraph.cjs.map +1 -1
  155. package/dist/components/typography/text.cjs.map +1 -1
  156. package/dist/components/upload/upload.cjs +2 -2
  157. package/dist/components/upload/upload.cjs.map +1 -1
  158. package/dist/components/upload/upload.js +2 -2
  159. package/dist/components/upload/upload.js.map +1 -1
  160. package/dist/components/visually-hidden/visually-hidden.cjs.map +1 -1
  161. package/dist/panda-preset.cjs.map +1 -1
  162. package/dist/styles.css +0 -21
  163. package/dist/theme/theme-provider.cjs.map +1 -1
  164. package/dist/theme/theme-provider.js.map +1 -1
  165. package/dist/theme/theme-scope.cjs.map +1 -1
  166. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"option-selector.cjs","names":["optionSelector","cx"],"sources":["../../../src/components/option-selector/option-selector.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useId, useState } from \"react\";\nimport type { ChangeEventHandler, ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { optionSelector } from \"../../styled-system/recipes\";\n\nexport interface OptionSelectorOption {\n /** Stable value submitted by the option. */\n value: string;\n /** Optional visible text. Use `children` for a richer option body. */\n label?: ReactNode;\n /** Custom content such as an icon, preview or illustration. */\n children?: ReactNode;\n /** Disables only this option. */\n disabled?: boolean;\n /** Explicit id for the native input and its label. */\n id?: string;\n}\n\nexport type OptionSelectorValue = string | string[];\n\nexport interface OptionSelectorProps\n extends Omit<ComponentPropsWithoutRef<\"fieldset\">, \"children\" | \"onChange\"> {\n /** Optional icon displayed next to the legend. */\n icon?: ReactNode;\n /** Accessible and visible group label. */\n label?: ReactNode;\n /** Supporting text announced with the group. */\n description?: ReactNode;\n /** Options rendered as custom selectable cards. */\n options?: OptionSelectorOption[];\n /** Name used by the native radio/checkbox inputs and form submission. */\n name?: string;\n /** Select multiple options with checkboxes instead of one radio option. */\n multiple?: boolean;\n /** Controlled selection. A string is used for one option and an array for many. */\n value?: OptionSelectorValue;\n /** Initial selection for an uncontrolled selector. */\n defaultValue?: OptionSelectorValue;\n /** Called with the next selected value after an option changes. */\n onValueChange?: (value: OptionSelectorValue) => void;\n /** Native change event callback. */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /** Layout of the option cards. Defaults to the horizontal layout. */\n orientation?: \"horizontal\" | \"vertical\";\n /** Responsive number of columns in the option grid. */\n columns?: 1 | 2 | 3 | 4;\n children?: ReactNode;\n}\n\nfunction getMultipleValues(value: OptionSelectorValue | undefined) {\n if (Array.isArray(value)) {\n return value;\n }\n\n return value === undefined ? [] : [value];\n}\n\nfunction getSingleValue(value: OptionSelectorValue | undefined) {\n return Array.isArray(value) ? value[0] : value;\n}\n\nfunction isSelected(value: string, selected: OptionSelectorValue | undefined, multiple: boolean) {\n return multiple\n ? getMultipleValues(selected).includes(value)\n : getSingleValue(selected) === value;\n}\n\nexport const OptionSelector = forwardRef<HTMLFieldSetElement, OptionSelectorProps>(\n function OptionSelector(\n {\n children,\n className,\n columns = 1,\n defaultValue,\n description,\n disabled = false,\n icon,\n id,\n label,\n multiple = false,\n name,\n onChange,\n onValueChange,\n options = [],\n orientation = \"horizontal\",\n value: controlledValue,\n ...props\n },\n ref,\n ) {\n const generatedId = useId();\n const baseId = id ?? generatedId;\n const descriptionId = description ? `${baseId}-description` : undefined;\n const inputName = name ?? `${baseId}-options`;\n const [uncontrolledValue, setUncontrolledValue] = useState<OptionSelectorValue>(() =>\n multiple ? getMultipleValues(defaultValue) : (getSingleValue(defaultValue) ?? \"\"),\n );\n const selectedValue = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const styles = optionSelector({\n orientation,\n columns: String(columns) as \"1\" | \"2\" | \"3\" | \"4\",\n });\n\n return (\n <fieldset\n {...props}\n ref={ref}\n aria-describedby={props[\"aria-describedby\"] ?? descriptionId}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"option-selector\"\n data-slot=\"option-selector\"\n disabled={disabled}\n id={id}\n >\n {label || icon ? (\n <legend className={styles.legend} data-slot=\"option-selector-legend\">\n {icon ? (\n <span aria-hidden=\"true\" className={styles.icon} data-slot=\"option-selector-icon\">\n {icon}\n </span>\n ) : null}\n <span className={styles.label} data-slot=\"option-selector-label\">\n {label}\n </span>\n </legend>\n ) : null}\n {description ? (\n <p\n className={styles.description}\n data-slot=\"option-selector-description\"\n id={descriptionId}\n >\n {description}\n </p>\n ) : null}\n <div className={styles.options} data-slot=\"option-selector-options\">\n {options.map((option, index) => {\n const optionDisabled = disabled || Boolean(option.disabled);\n const selected = isSelected(option.value, selectedValue, multiple);\n const optionId = option.id ?? `${baseId}-option-${index}`;\n\n return (\n <label\n className={styles.option}\n data-disabled={optionDisabled || undefined}\n data-selected={selected || undefined}\n data-slot=\"option-selector-option\"\n htmlFor={optionId}\n key={option.value}\n >\n <input\n aria-label={typeof option.label === \"string\" ? option.label : undefined}\n checked={selected}\n className={styles.input}\n data-slot=\"option-selector-input\"\n disabled={optionDisabled}\n id={optionId}\n name={inputName}\n onChange={(event) => {\n const nextValue = multiple\n ? event.currentTarget.checked\n ? [...getMultipleValues(selectedValue), option.value]\n : getMultipleValues(selectedValue).filter(\n (current) => current !== option.value,\n )\n : option.value;\n\n setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n onChange?.(event);\n }}\n type={multiple ? \"checkbox\" : \"radio\"}\n value={option.value}\n />\n <span className={styles.content}>\n {option.children}\n {option.label ? (\n <span className={styles.optionLabel} data-slot=\"option-selector-option-label\">\n {option.label}\n </span>\n ) : null}\n </span>\n </label>\n );\n })}\n {children}\n </div>\n </fieldset>\n );\n },\n);\n"],"mappings":";;;;;;AAoDA,SAAS,kBAAkB,OAAwC;CACjE,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAGT,OAAO,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK;AAC1C;AAEA,SAAS,eAAe,OAAwC;CAC9D,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;AAC3C;AAEA,SAAS,WAAW,OAAe,UAA2C,UAAmB;CAC/F,OAAO,WACH,kBAAkB,QAAQ,CAAC,CAAC,SAAS,KAAK,IAC1C,eAAe,QAAQ,MAAM;AACnC;AAEA,MAAa,kBAAA,GAAA,MAAA,WAAA,CACX,SAAS,eACP,EACE,UACA,WACA,UAAU,GACV,cACA,aACA,WAAW,OACX,MACA,IACA,OACA,WAAW,OACX,MACA,UACA,eACA,UAAU,CAAC,GACX,cAAc,cACd,OAAO,iBACP,GAAG,SAEL,KACA;CACA,MAAM,eAAA,GAAA,MAAA,MAAA,CAAoB;CAC1B,MAAM,SAAS,MAAM;CACrB,MAAM,gBAAgB,cAAc,GAAG,OAAO,gBAAgB,KAAA;CAC9D,MAAM,YAAY,QAAQ,GAAG,OAAO;CACpC,MAAM,CAAC,mBAAmB,yBAAA,GAAA,MAAA,SAAA,OACxB,WAAW,kBAAkB,YAAY,IAAK,eAAe,YAAY,KAAK,EAChF;CACA,MAAM,gBAAgB,oBAAoB,KAAA,IAAY,oBAAoB;CAC1E,MAAM,SAASA,wBAAAA,eAAe;EAC5B;EACA,SAAS,OAAO,OAAO;CACzB,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,YAAD;EACE,GAAI;EACC;EACL,oBAAkB,MAAM,uBAAuB;EAC/C,WAAWC,WAAAA,GAAG,OAAO,MAAM,SAAS;EACpC,iBAAe,YAAY,KAAA;EAC3B,uBAAoB;EACpB,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gB,SAAS;QACzB,WAAW,KAAK;OAClB;OACA,MAAM,WAAW,aAAa;OAC9B,OAAO,OAAO;MACf,CAAA,GACD,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;OAAM,WAAW,OAAO;iBAAxB,CACG,OAAO,UACP,OAAO,QACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;QAAM,WAAW,OAAO;QAAa,aAAU;kBAC5C,OAAO;OACJ,CAAA,IACJ,IACA;QACD;QAlCA,OAAO,KAkCP;IAEX,CAAC,GACA,QACE;;EACG;;AAEd,CACF"}
1
+ {"version":3,"file":"option-selector.cjs","names":["forwardRef","useId","useState","optionSelector","cx"],"sources":["../../../src/components/option-selector/option-selector.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useId, useState } from \"react\";\nimport type { ChangeEventHandler, ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { optionSelector } from \"../../styled-system/recipes\";\n\nexport interface OptionSelectorOption {\n /** Stable value submitted by the option. */\n value: string;\n /** Optional visible text. Use `children` for a richer option body. */\n label?: ReactNode;\n /** Custom content such as an icon, preview or illustration. */\n children?: ReactNode;\n /** Disables only this option. */\n disabled?: boolean;\n /** Explicit id for the native input and its label. */\n id?: string;\n}\n\nexport type OptionSelectorValue = string | string[];\n\nexport interface OptionSelectorProps\n extends Omit<ComponentPropsWithoutRef<\"fieldset\">, \"children\" | \"onChange\"> {\n /** Optional icon displayed next to the legend. */\n icon?: ReactNode;\n /** Accessible and visible group label. */\n label?: ReactNode;\n /** Supporting text announced with the group. */\n description?: ReactNode;\n /** Options rendered as custom selectable cards. */\n options?: OptionSelectorOption[];\n /** Name used by the native radio/checkbox inputs and form submission. */\n name?: string;\n /** Select multiple options with checkboxes instead of one radio option. */\n multiple?: boolean;\n /** Controlled selection. A string is used for one option and an array for many. */\n value?: OptionSelectorValue;\n /** Initial selection for an uncontrolled selector. */\n defaultValue?: OptionSelectorValue;\n /** Called with the next selected value after an option changes. */\n onValueChange?: (value: OptionSelectorValue) => void;\n /** Native change event callback. */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /** Layout of the option cards. Defaults to the horizontal layout. */\n orientation?: \"horizontal\" | \"vertical\";\n /** Responsive number of columns in the option grid. */\n columns?: 1 | 2 | 3 | 4;\n children?: ReactNode;\n}\n\nfunction getMultipleValues(value: OptionSelectorValue | undefined) {\n if (Array.isArray(value)) {\n return value;\n }\n\n return value === undefined ? [] : [value];\n}\n\nfunction getSingleValue(value: OptionSelectorValue | undefined) {\n return Array.isArray(value) ? value[0] : value;\n}\n\nfunction isSelected(value: string, selected: OptionSelectorValue | undefined, multiple: boolean) {\n return multiple\n ? getMultipleValues(selected).includes(value)\n : getSingleValue(selected) === value;\n}\n\nexport const OptionSelector = forwardRef<HTMLFieldSetElement, OptionSelectorProps>(\n function OptionSelector(\n {\n children,\n className,\n columns = 1,\n defaultValue,\n description,\n disabled = false,\n icon,\n id,\n label,\n multiple = false,\n name,\n onChange,\n onValueChange,\n options = [],\n orientation = \"horizontal\",\n value: controlledValue,\n ...props\n },\n ref,\n ) {\n const generatedId = useId();\n const baseId = id ?? generatedId;\n const descriptionId = description ? `${baseId}-description` : undefined;\n const inputName = name ?? `${baseId}-options`;\n const [uncontrolledValue, setUncontrolledValue] = useState<OptionSelectorValue>(() =>\n multiple ? getMultipleValues(defaultValue) : (getSingleValue(defaultValue) ?? \"\"),\n );\n const selectedValue = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const styles = optionSelector({\n orientation,\n columns: String(columns) as \"1\" | \"2\" | \"3\" | \"4\",\n });\n\n return (\n <fieldset\n {...props}\n ref={ref}\n aria-describedby={props[\"aria-describedby\"] ?? descriptionId}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"option-selector\"\n data-slot=\"option-selector\"\n disabled={disabled}\n id={id}\n >\n {label || icon ? (\n <legend className={styles.legend} data-slot=\"option-selector-legend\">\n {icon ? (\n <span aria-hidden=\"true\" className={styles.icon} data-slot=\"option-selector-icon\">\n {icon}\n </span>\n ) : null}\n <span className={styles.label} data-slot=\"option-selector-label\">\n {label}\n </span>\n </legend>\n ) : null}\n {description ? (\n <p\n className={styles.description}\n data-slot=\"option-selector-description\"\n id={descriptionId}\n >\n {description}\n </p>\n ) : null}\n <div className={styles.options} data-slot=\"option-selector-options\">\n {options.map((option, index) => {\n const optionDisabled = disabled || Boolean(option.disabled);\n const selected = isSelected(option.value, selectedValue, multiple);\n const optionId = option.id ?? `${baseId}-option-${index}`;\n\n return (\n <label\n className={styles.option}\n data-disabled={optionDisabled || undefined}\n data-selected={selected || undefined}\n data-slot=\"option-selector-option\"\n htmlFor={optionId}\n key={option.value}\n >\n <input\n aria-label={typeof option.label === \"string\" ? option.label : undefined}\n checked={selected}\n className={styles.input}\n data-slot=\"option-selector-input\"\n disabled={optionDisabled}\n id={optionId}\n name={inputName}\n onChange={(event) => {\n const nextValue = multiple\n ? event.currentTarget.checked\n ? [...getMultipleValues(selectedValue), option.value]\n : getMultipleValues(selectedValue).filter(\n (current) => current !== option.value,\n )\n : option.value;\n\n setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n onChange?.(event);\n }}\n type={multiple ? \"checkbox\" : \"radio\"}\n value={option.value}\n />\n <span className={styles.content}>\n {option.children}\n {option.label ? (\n <span className={styles.optionLabel} data-slot=\"option-selector-option-label\">\n {option.label}\n </span>\n ) : null}\n </span>\n </label>\n );\n })}\n {children}\n </div>\n </fieldset>\n );\n },\n);\n"],"mappings":";;;;;;AAoDA,SAAS,kBAAkB,OAAwC;CACjE,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAGT,OAAO,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK;AAC1C;AAEA,SAAS,eAAe,OAAwC;CAC9D,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;AAC3C;AAEA,SAAS,WAAW,OAAe,UAA2C,UAAmB;CAC/F,OAAO,WACH,kBAA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,OAAO,KAkCP;IAEX,CAAC,GACA,QACE;;EACG;;AAEd,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"option-selector.js","names":[],"sources":["../../../src/components/option-selector/option-selector.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useId, useState } from \"react\";\nimport type { ChangeEventHandler, ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { optionSelector } from \"../../styled-system/recipes\";\n\nexport interface OptionSelectorOption {\n /** Stable value submitted by the option. */\n value: string;\n /** Optional visible text. Use `children` for a richer option body. */\n label?: ReactNode;\n /** Custom content such as an icon, preview or illustration. */\n children?: ReactNode;\n /** Disables only this option. */\n disabled?: boolean;\n /** Explicit id for the native input and its label. */\n id?: string;\n}\n\nexport type OptionSelectorValue = string | string[];\n\nexport interface OptionSelectorProps\n extends Omit<ComponentPropsWithoutRef<\"fieldset\">, \"children\" | \"onChange\"> {\n /** Optional icon displayed next to the legend. */\n icon?: ReactNode;\n /** Accessible and visible group label. */\n label?: ReactNode;\n /** Supporting text announced with the group. */\n description?: ReactNode;\n /** Options rendered as custom selectable cards. */\n options?: OptionSelectorOption[];\n /** Name used by the native radio/checkbox inputs and form submission. */\n name?: string;\n /** Select multiple options with checkboxes instead of one radio option. */\n multiple?: boolean;\n /** Controlled selection. A string is used for one option and an array for many. */\n value?: OptionSelectorValue;\n /** Initial selection for an uncontrolled selector. */\n defaultValue?: OptionSelectorValue;\n /** Called with the next selected value after an option changes. */\n onValueChange?: (value: OptionSelectorValue) => void;\n /** Native change event callback. */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /** Layout of the option cards. Defaults to the horizontal layout. */\n orientation?: \"horizontal\" | \"vertical\";\n /** Responsive number of columns in the option grid. */\n columns?: 1 | 2 | 3 | 4;\n children?: ReactNode;\n}\n\nfunction getMultipleValues(value: OptionSelectorValue | undefined) {\n if (Array.isArray(value)) {\n return value;\n }\n\n return value === undefined ? [] : [value];\n}\n\nfunction getSingleValue(value: OptionSelectorValue | undefined) {\n return Array.isArray(value) ? value[0] : value;\n}\n\nfunction isSelected(value: string, selected: OptionSelectorValue | undefined, multiple: boolean) {\n return multiple\n ? getMultipleValues(selected).includes(value)\n : getSingleValue(selected) === value;\n}\n\nexport const OptionSelector = forwardRef<HTMLFieldSetElement, OptionSelectorProps>(\n function OptionSelector(\n {\n children,\n className,\n columns = 1,\n defaultValue,\n description,\n disabled = false,\n icon,\n id,\n label,\n multiple = false,\n name,\n onChange,\n onValueChange,\n options = [],\n orientation = \"horizontal\",\n value: controlledValue,\n ...props\n },\n ref,\n ) {\n const generatedId = useId();\n const baseId = id ?? generatedId;\n const descriptionId = description ? `${baseId}-description` : undefined;\n const inputName = name ?? `${baseId}-options`;\n const [uncontrolledValue, setUncontrolledValue] = useState<OptionSelectorValue>(() =>\n multiple ? getMultipleValues(defaultValue) : (getSingleValue(defaultValue) ?? \"\"),\n );\n const selectedValue = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const styles = optionSelector({\n orientation,\n columns: String(columns) as \"1\" | \"2\" | \"3\" | \"4\",\n });\n\n return (\n <fieldset\n {...props}\n ref={ref}\n aria-describedby={props[\"aria-describedby\"] ?? descriptionId}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"option-selector\"\n data-slot=\"option-selector\"\n disabled={disabled}\n id={id}\n >\n {label || icon ? (\n <legend className={styles.legend} data-slot=\"option-selector-legend\">\n {icon ? (\n <span aria-hidden=\"true\" className={styles.icon} data-slot=\"option-selector-icon\">\n {icon}\n </span>\n ) : null}\n <span className={styles.label} data-slot=\"option-selector-label\">\n {label}\n </span>\n </legend>\n ) : null}\n {description ? (\n <p\n className={styles.description}\n data-slot=\"option-selector-description\"\n id={descriptionId}\n >\n {description}\n </p>\n ) : null}\n <div className={styles.options} data-slot=\"option-selector-options\">\n {options.map((option, index) => {\n const optionDisabled = disabled || Boolean(option.disabled);\n const selected = isSelected(option.value, selectedValue, multiple);\n const optionId = option.id ?? `${baseId}-option-${index}`;\n\n return (\n <label\n className={styles.option}\n data-disabled={optionDisabled || undefined}\n data-selected={selected || undefined}\n data-slot=\"option-selector-option\"\n htmlFor={optionId}\n key={option.value}\n >\n <input\n aria-label={typeof option.label === \"string\" ? option.label : undefined}\n checked={selected}\n className={styles.input}\n data-slot=\"option-selector-input\"\n disabled={optionDisabled}\n id={optionId}\n name={inputName}\n onChange={(event) => {\n const nextValue = multiple\n ? event.currentTarget.checked\n ? [...getMultipleValues(selectedValue), option.value]\n : getMultipleValues(selectedValue).filter(\n (current) => current !== option.value,\n )\n : option.value;\n\n setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n onChange?.(event);\n }}\n type={multiple ? \"checkbox\" : \"radio\"}\n value={option.value}\n />\n <span className={styles.content}>\n {option.children}\n {option.label ? (\n <span className={styles.optionLabel} data-slot=\"option-selector-option-label\">\n {option.label}\n </span>\n ) : null}\n </span>\n </label>\n );\n })}\n {children}\n </div>\n </fieldset>\n );\n },\n);\n"],"mappings":";;;;;;AAoDA,SAAS,kBAAkB,OAAwC;CACjE,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAGT,OAAO,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK;AAC1C;AAEA,SAAS,eAAe,OAAwC;CAC9D,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK;AAC3C;AAEA,SAAS,WAAW,OAAe,UAA2C,UAAmB;CAC/F,OAAO,WACH,kBAAkB,QAAQ,CAAC,CAAC,SAAS,KAAK,IAC1C,eAAe,QAAQ,MAAM;AACnC;AAEA,MAAa,iBAAiB,WAC5B,SAAS,eACP,EACE,UACA,WACA,UAAU,GACV,cACA,aACA,WAAW,OACX,MACA,IACA,OACA,WAAW,OACX,MACA,UACA,eACA,UAAU,CAAC,GACX,cAAc,cACd,OAAO,iBACP,GAAG,SAEL,KACA;CACA,MAAM,cAAc,MAAM;CAC1B,MAAM,SAAS,MAAM;CACrB,MAAM,gBAAg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AClB,aAAU;OACV,UAAU;OACV,IAAI;OACJ,MAAM;OACN,WAAW,UAAU;QACnB,MAAM,YAAY,WACd,MAAM,cAAc,UAClB,CAAC,GAAG,kBAAkB,aAAa,GAAG,OAAO,KAAK,IAClD,kBAAkB,aAAa,CAAC,CAAC,QAC9B,YAAY,YAAY,OAAO,KAClC,IACF,OAAO;QAEX,qBAAqB,SAAS;QAC9B,gBAAgB,SAAS;QACzB,WAAW,KAAK;OAClB;OACA,MAAM,WAAW,aAAa;OAC9B,OAAO,OAAO;MACf,CAAA,GACD,qBAAC,QAAD;OAAM,WAAW,OAAO;iBAAxB,CACG,OAAO,UACP,OAAO,QACN,oBAAC,QAAD;QAAM,WAAW,OAAO;QAAa,aAAU;kBAC5C,OAAO;OACJ,CAAA,IACJ,IACA;QACD;QAlCA,OAAO,KAkCP;IAEX,CAAC,GACA,QACE;;EACG;;AAEd,CACF"}
1
+ {"version":3,"file":"option-selector.js","names":[],"sources":["../../../src/components/option-selector/option-selector.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, useId, useState } from \"react\";\nimport type { ChangeEventHandler, ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { optionSelector } from \"../../styled-system/recipes\";\n\nexport interface OptionSelectorOption {\n /** Stable value submitted by the option. */\n value: string;\n /** Optional visible text. Use `children` for a richer option body. */\n label?: ReactNode;\n /** Custom content such as an icon, preview or illustration. */\n children?: ReactNode;\n /** Disables only this option. */\n disabled?: boolean;\n /** Explicit id for the native input and its label. */\n id?: string;\n}\n\nexport type OptionSelectorValue = string | string[];\n\nexport interface OptionSelectorProps\n extends Omit<ComponentPropsWithoutRef<\"fieldset\">, \"children\" | \"onChange\"> {\n /** Optional icon displayed next to the legend. */\n icon?: ReactNode;\n /** Accessible and visible group label. */\n label?: ReactNode;\n /** Supporting text announced with the group. */\n description?: ReactNode;\n /** Options rendered as custom selectable cards. */\n options?: OptionSelectorOption[];\n /** Name used by the native radio/checkbox inputs and form submission. */\n name?: string;\n /** Select multiple options with checkboxes instead of one radio option. */\n multiple?: boolean;\n /** Controlled selection. A string is used for one option and an array for many. */\n value?: OptionSelectorValue;\n /** Initial selection for an uncontrolled selector. */\n defaultValue?: OptionSelectorValue;\n /** Called with the next selected value after an option changes. */\n onValueChange?: (value: OptionSelectorValue) => void;\n /** Native change event callback. */\n onChange?: ChangeEventHandler<HTMLInputElement>;\n /** Layout of the option cards. Defaults to the horizontal layout. */\n orientation?: \"horizontal\" | \"vertical\";\n /** Responsive number of columns in the option grid. */\n columns?: 1 | 2 | 3 | 4;\n children?: ReactNode;\n}\n\nfunction getMultipleValues(value: OptionSelectorValue | undefined) {\n if (Array.isArray(value)) {\n return value;\n }\n\n return value === undefined ? [] : [value];\n}\n\nfunction getSingleValue(value: OptionSelectorValue | undefined) {\n return Array.isArray(value) ? value[0] : value;\n}\n\nfunction isSelected(value: string, selected: OptionSelectorValue | undefined, multiple: boolean) {\n return multiple\n ? getMultipleValues(selected).includes(value)\n : getSingleValue(selected) === value;\n}\n\nexport const OptionSelector = forwardRef<HTMLFieldSetElement, OptionSelectorProps>(\n function OptionSelector(\n {\n children,\n className,\n columns = 1,\n defaultValue,\n description,\n disabled = false,\n icon,\n id,\n label,\n multiple = false,\n name,\n onChange,\n onValueChange,\n options = [],\n orientation = \"horizontal\",\n value: controlledValue,\n ...props\n },\n ref,\n ) {\n const generatedId = useId();\n const baseId = id ?? generatedId;\n const descriptionId = description ? `${baseId}-description` : undefined;\n const inputName = name ?? `${baseId}-options`;\n const [uncontrolledValue, setUncontrolledValue] = useState<OptionSelectorValue>(() =>\n multiple ? getMultipleValues(defaultValue) : (getSingleValue(defaultValue) ?? \"\"),\n );\n const selectedValue = controlledValue === undefined ? uncontrolledValue : controlledValue;\n const styles = optionSelector({\n orientation,\n columns: String(columns) as \"1\" | \"2\" | \"3\" | \"4\",\n });\n\n return (\n <fieldset\n {...props}\n ref={ref}\n aria-describedby={props[\"aria-describedby\"] ?? descriptionId}\n className={cx(styles.root, className)}\n data-disabled={disabled || undefined}\n data-jaci-component=\"option-selector\"\n data-slot=\"option-selector\"\n disabled={disabled}\n id={id}\n >\n {label || icon ? (\n <legend className={styles.legend} data-slot=\"option-selector-legend\">\n {icon ? (\n <span aria-hidden=\"true\" className={styles.icon} data-slot=\"option-selector-icon\">\n {icon}\n </span>\n ) : null}\n <span className={styles.label} data-slot=\"option-selector-label\">\n {label}\n </span>\n </legend>\n ) : null}\n {description ? (\n <p\n className={styles.description}\n data-slot=\"option-selector-description\"\n id={descriptionId}\n >\n {description}\n </p>\n ) : null}\n <div className={styles.options} data-slot=\"option-selector-options\">\n {options.map((option, index) => {\n const optionDisabled = disabled || Boolean(option.disabled);\n const selected = isSelected(option.value, selectedValue, multiple);\n const optionId = option.id ?? `${baseId}-option-${index}`;\n\n return (\n <label\n className={styles.option}\n data-disabled={optionDisabled || undefined}\n data-selected={selected || undefined}\n data-slot=\"option-selector-option\"\n htmlFor={optionId}\n key={option.value}\n >\n <input\n aria-label={typeof option.label === \"string\" ? option.label : undefined}\n checked={selected}\n className={styles.input}\n data-slot=\"option-selector-input\"\n disabled={optionDisabled}\n id={optionId}\n name={inputName}\n onChange={(event) => {\n const nextValue = multiple\n ? event.currentTarget.checked\n ? [...getMultipleValues(selectedValue), option.value]\n : getMultipleValues(selectedValue).filter(\n (current) => current !== option.value,\n )\n : option.value;\n\n setUncontrolledValue(nextValue);\n onValueChange?.(nextValue);\n onChange?.(event);\n }}\n type={multiple ? \"checkbox\" : \"radio\"}\n value={option.value}\n />\n <span className={styles.content}>\n {option.children}\n {option.label ? (\n <span className={styles.optionLabel} data-slot=\"option-selector-option-label\">\n {option.label}\n </span>\n ) : null}\n </span>\n </label>\n );\n })}\n {children}\n </div>\n </fieldset>\n );\n },\n);\n"],"mappings":";;;;;;AAoDA,SAAS,kBAAkB,OAAwC;CACjE,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAGT,OAAO,UAAU,KAAA,IAAY,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;IACE,WAAW,OAAO;IAClB,aAAU;IACV,IAAI;IAEH,UAAA;GACA,CAAA,IACD;GACJ,qBAAC,OAAD;IAAK,WAAW,OAAO;IAAS,aAAU;IAA1C,UAAA,CACG,QAAQ,KAAK,QAAQ,UAAU;KAC9B,MAAM,iBAAiB,YAAY,QAAQ,OAAO,QAAQ;KAC1D,MAAM,WAAW,WAAW,OAAO,OAAO,eAAe,QAAQ;KACjE,MAAM,WAAW,OAAO,MAAM,GAAG,OAAO,UAAU;KAElD,OACE,qBAAC,SAAD;MACE,WAAW,OAAO;MAClB,iBAAe,kBAAkB,KAAA;MACjC,iBAAe,YAAY,KAAA;MAC3B,aAAU;MACV,SAAS;MALX,UAAA,CAQE,oBAAC,SAAD;OACE,cAAY,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ,KAAA;OAC9D,SAAS;OACT,WAAW,OAAO;OAClB,aAAU;OACV,UAAU;OACV,IAAI;OACJ,MAAM;OACN,WAAW,UAAU;QACnB,MAAM,YAAY,WACd,MAAM,cAAc,UAClB,CAAC,GAAG,kBAAkB,aAAa,GAAG,OAAO,KAAK,IAClD,kBAAkB,aAAa,CAAC,CAAC,QAC9B,YAAY,YAAY,OAAO,KAClC,IACF,OAAO;QAEX,qBAAqB,SAAS;QAC9B,gBAAgB,SAAS;QACzB,WAAW,KAAK;OAClB;OACA,MAAM,WAAW,aAAa;OAC9B,OAAO,OAAO;MACf,CAAA,GACD,qBAAC,QAAD;OAAM,WAAW,OAAO;OAAxB,UAAA,CACG,OAAO,UACP,OAAO,QACN,oBAAC,QAAD;QAAM,WAAW,OAAO;QAAa,aAAU;QAC5C,UAAA,OAAO;OACJ,CAAA,IACJ,IACA;MACD,CAAA,CAAA;KAlCA,GAAA,OAAO,KAkCP;IAEX,CAAC,GACA,QACE;;EACG;;AAEd,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.cjs","names":["cx","pagination"],"sources":["../../../src/components/pagination/pagination.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { pagination } from \"../../styled-system/recipes\";\n\nexport type PaginationDensity = \"compact\" | \"comfortable\";\n\ninterface PaginationContextValue {\n density: PaginationDensity;\n goTo: (page: number) => void;\n page: number | undefined;\n pageCount: number | undefined;\n}\n\nconst PaginationContext = createContext<PaginationContextValue | null>(null);\n\nfunction usePaginationContext() {\n return useContext(PaginationContext);\n}\n\nexport interface PaginationRootProps extends Omit<ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n children?: ReactNode;\n defaultPage?: number;\n density?: PaginationDensity;\n onPageChange?: (page: number) => void;\n page?: number;\n pageCount?: number;\n showFirstLast?: boolean;\n siblingCount?: number;\n}\n\nexport const PaginationRoot = forwardRef<HTMLElement, PaginationRootProps>(function PaginationRoot(\n {\n children,\n \"aria-label\": ariaLabel,\n className,\n defaultPage = 1,\n density = \"comfortable\",\n onPageChange,\n page: controlledPage,\n pageCount,\n showFirstLast = false,\n siblingCount = 1,\n ...props\n },\n ref,\n) {\n const [uncontrolledPage, setUncontrolledPage] = useState(defaultPage);\n const page = pageCount\n ? Math.min(Math.max(controlledPage ?? uncontrolledPage, 1), pageCount)\n : controlledPage;\n const goTo = useCallback(\n (nextPage: number) => {\n if (!pageCount) return;\n const next = Math.min(Math.max(nextPage, 1), pageCount);\n if (controlledPage === undefined) setUncontrolledPage(next);\n onPageChange?.(next);\n },\n [controlledPage, onPageChange, pageCount],\n );\n const context = useMemo(\n () => ({ density, goTo, page, pageCount }),\n [density, goTo, page, pageCount],\n );\n\n return (\n <PaginationContext.Provider value={context}>\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Pagination\"}\n ref={ref}\n className={cx(pagination({ density }).root, className)}\n data-density={density}\n data-jaci-component=\"pagination\"\n data-slot=\"pagination\"\n >\n {children ??\n (pageCount ? (\n <PaginationGenerated\n page={page ?? 1}\n pageCount={pageCount}\n showFirstLast={showFirstLast}\n siblingCount={siblingCount}\n />\n ) : null)}\n </nav>\n </PaginationContext.Provider>\n );\n});\n\nexport type PaginationListProps = ComponentPropsWithoutRef<\"ul\">;\nexport const PaginationList = forwardRef<HTMLUListElement, PaginationListProps>(\n function PaginationList({ className, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <ul\n {...props}\n ref={ref}\n className={cx(pagination({ density: context?.density }).list, className)}\n data-slot=\"pagination-list\"\n />\n );\n },\n);\n\nexport type PaginationItemProps = ComponentPropsWithoutRef<\"li\">;\nexport const PaginationItem = forwardRef<HTMLLIElement, PaginationItemProps>(\n function PaginationItem({ className, ...props }, ref) {\n return (\n <li\n {...props}\n ref={ref}\n className={cx(pagination().item, className)}\n data-slot=\"pagination-item\"\n />\n );\n },\n);\n\nexport interface PaginationLinkProps extends ComponentPropsWithoutRef<\"a\"> {\n active?: boolean;\n disabled?: boolean;\n page?: number | undefined;\n}\n\ntype PaginationAnchorSlot =\n | \"pagination-link\"\n | \"pagination-first\"\n | \"pagination-last\"\n | \"pagination-previous\"\n | \"pagination-next\";\n\ninterface PaginationAnchorProps extends PaginationLinkProps {\n slot: PaginationAnchorSlot;\n}\n\nfunction getAnchorClassName(\n active: boolean,\n disabled: boolean,\n density: PaginationDensity | undefined,\n slot: PaginationAnchorSlot,\n) {\n const styles = pagination({ active, density, disabled });\n if (slot === \"pagination-previous\") return cx(styles.link, styles.previous);\n if (slot === \"pagination-next\") return cx(styles.link, styles.next);\n if (slot === \"pagination-first\") return cx(styles.link, styles.first);\n if (slot === \"pagination-last\") return cx(styles.link, styles.last);\n return styles.link;\n}\n\nconst PaginationAnchor = forwardRef<HTMLAnchorElement, PaginationAnchorProps>(\n function PaginationAnchor(\n {\n active: activeProp,\n \"aria-current\": ariaCurrent,\n className,\n disabled: disabledProp = false,\n href,\n onClick,\n page,\n slot,\n tabIndex,\n ...props\n },\n ref,\n ) {\n const context = usePaginationContext();\n const active = activeProp ?? (page !== undefined && context?.page === page);\n const disabled = Boolean(disabledProp || (page !== undefined && context?.pageCount === 1));\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n aria-disabled={disabled || undefined}\n ref={ref}\n className={cx(\n getAnchorClassName(Boolean(active), disabled, context?.density, slot),\n className,\n )}\n data-active={active || undefined}\n data-disabled={disabled || undefined}\n data-page={page}\n data-slot={slot}\n href={disabled ? undefined : href}\n onClick={(event) => {\n if (disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n if (page !== undefined && context?.pageCount) {\n event.preventDefault();\n context.goTo(page);\n }\n onClick?.(event);\n }}\n tabIndex={disabled ? -1 : tabIndex}\n />\n );\n },\n);\n\nexport const PaginationLink = forwardRef<HTMLAnchorElement, PaginationLinkProps>(\n function PaginationLink(props, ref) {\n return <PaginationAnchor {...props} ref={ref} slot=\"pagination-link\" />;\n },\n);\n\nexport interface PaginationPreviousProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationPrevious = forwardRef<HTMLAnchorElement, PaginationPreviousProps>(\n function PaginationPrevious({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page - 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to previous page\"}\n disabled={props.disabled ?? (targetPage !== undefined && targetPage < 1)}\n page={targetPage}\n ref={ref}\n rel={rel ?? \"prev\"}\n slot=\"pagination-previous\"\n >\n {children ?? (\n <>\n <span aria-hidden=\"true\">‹</span>\n <span>Previous</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationNextProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationNext = forwardRef<HTMLAnchorElement, PaginationNextProps>(\n function PaginationNext({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page + 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to next page\"}\n disabled={\n props.disabled ??\n (targetPage !== undefined && targetPage > (context?.pageCount ?? Infinity))\n }\n page={targetPage}\n ref={ref}\n rel={rel ?? \"next\"}\n slot=\"pagination-next\"\n >\n {children ?? (\n <>\n <span>Next</span>\n <span aria-hidden=\"true\">›</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationFirstProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationFirst = forwardRef<HTMLAnchorElement, PaginationFirstProps>(\n function PaginationFirst({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to first page\"}\n page={page ?? 1}\n ref={ref}\n slot=\"pagination-first\"\n >\n {children ?? \"First\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationLastProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationLast = forwardRef<HTMLAnchorElement, PaginationLastProps>(\n function PaginationLast({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to last page\"}\n page={page ?? context?.pageCount}\n ref={ref}\n slot=\"pagination-last\"\n >\n {children ?? \"Last\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport type PaginationEllipsisProps = ComponentPropsWithoutRef<\"span\">;\nexport const PaginationEllipsis = forwardRef<HTMLSpanElement, PaginationEllipsisProps>(\n function PaginationEllipsis({ children = \"…\", className, ...props }, ref) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n ref={ref}\n className={cx(pagination().ellipsis, className)}\n data-slot=\"pagination-ellipsis\"\n >\n {children}\n </span>\n );\n },\n);\n\ntype PaginationPageItem = number | \"ellipsis\";\n\nfunction getPageItems(page: number, pageCount: number, siblingCount: number): PaginationPageItem[] {\n const visible = new Set<number>([1, pageCount]);\n for (let index = page - siblingCount; index <= page + siblingCount; index += 1) {\n if (index > 0 && index <= pageCount) visible.add(index);\n }\n const pages = [...visible].sort((left, right) => left - right);\n const items: PaginationPageItem[] = [];\n pages.forEach((value, index) => {\n const previous = pages[index - 1];\n if (previous !== undefined && value - previous > 1) items.push(\"ellipsis\");\n items.push(value);\n });\n return items;\n}\n\nfunction PaginationGenerated({\n page,\n pageCount,\n showFirstLast,\n siblingCount,\n}: {\n page: number;\n pageCount: number;\n showFirstLast: boolean;\n siblingCount: number;\n}) {\n const pageItems = getPageItems(page, pageCount, siblingCount);\n return (\n <PaginationList>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationFirst disabled={page <= 1} />\n </PaginationItem>\n ) : null}\n <PaginationItem>\n <PaginationPrevious disabled={page <= 1} />\n </PaginationItem>\n {pageItems.map((item, index) =>\n item === \"ellipsis\" ? (\n <PaginationItem\n key={`ellipsis-${pageItems.slice(0, index).filter((value) => value === \"ellipsis\").length + 1}`}\n >\n <PaginationEllipsis />\n </PaginationItem>\n ) : (\n <PaginationItem key={item}>\n <PaginationLink page={item}>{item}</PaginationLink>\n </PaginationItem>\n ),\n )}\n <PaginationItem>\n <PaginationNext disabled={page >= pageCount} />\n </PaginationItem>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationLast disabled={page >= pageCount} />\n </PaginationItem>\n ) : null}\n </PaginationList>\n );\n}\n\nexport const Pagination = {\n Root: PaginationRoot,\n List: PaginationList,\n Item: PaginationItem,\n Link: PaginationLink,\n First: PaginationFirst,\n Previous: PaginationPrevious,\n Next: PaginationNext,\n Last: PaginationLast,\n Ellipsis: PaginationEllipsis,\n};\n"],"mappings":";;;;;;AAiBA,MAAM,qBAAA,GAAA,MAAA,cAAA,CAAiE,IAAI;AAE3E,SAAS,uBAAuB;CAC9B,QAAA,GAAA,MAAA,WAAA,CAAkB,iBAAiB;AACrC;AAaA,MAAa,kBAAA,GAAA,MAAA,WAAA,CAA8D,SAAS,eAClF,EACE,UACA,cAAc,WACd,WACA,cAAc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A,CAAC,oBAAD,CAAqB,CAAA,EACP,GAHT,YAAY,UAAU,MAAM,GAAG,KAAK,CAAC,CAAC,QAAQ,UAAU,UAAU,UAAU,CAAC,CAAC,SAAS,GAG9E,IAEhB,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD;GAAgB,MAAM;aAAO;EAAqB,CAAA,EACpC,GAFK,IAEL,CAEpB;EACA,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAgB,UAAU,QAAQ,UAAY,CAAA,EAChC,CAAA;EACf,gBACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAgB,UAAU,QAAQ,UAAY,CAAA,EAChC,CAAA,IACd;CACU,EAAA,CAAA;AAEpB;AAEA,MAAa,aAAa;CACxB,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,UAAU;CACV,MAAM;CACN,MAAM;CACN,UAAU;AACZ"}
1
+ {"version":3,"file":"pagination.cjs","names":["createContext","useContext","forwardRef","useState","useCallback","useMemo","cx","pagination"],"sources":["../../../src/components/pagination/pagination.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { pagination } from \"../../styled-system/recipes\";\n\nexport type PaginationDensity = \"compact\" | \"comfortable\";\n\ninterface PaginationContextValue {\n density: PaginationDensity;\n goTo: (page: number) => void;\n page: number | undefined;\n pageCount: number | undefined;\n}\n\nconst PaginationContext = createContext<PaginationContextValue | null>(null);\n\nfunction usePaginationContext() {\n return useContext(PaginationContext);\n}\n\nexport interface PaginationRootProps extends Omit<ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n children?: ReactNode;\n defaultPage?: number;\n density?: PaginationDensity;\n onPageChange?: (page: number) => void;\n page?: number;\n pageCount?: number;\n showFirstLast?: boolean;\n siblingCount?: number;\n}\n\nexport const PaginationRoot = forwardRef<HTMLElement, PaginationRootProps>(function PaginationRoot(\n {\n children,\n \"aria-label\": ariaLabel,\n className,\n defaultPage = 1,\n density = \"comfortable\",\n onPageChange,\n page: controlledPage,\n pageCount,\n showFirstLast = false,\n siblingCount = 1,\n ...props\n },\n ref,\n) {\n const [uncontrolledPage, setUncontrolledPage] = useState(defaultPage);\n const page = pageCount\n ? Math.min(Math.max(controlledPage ?? uncontrolledPage, 1), pageCount)\n : controlledPage;\n const goTo = useCallback(\n (nextPage: number) => {\n if (!pageCount) return;\n const next = Math.min(Math.max(nextPage, 1), pageCount);\n if (controlledPage === undefined) setUncontrolledPage(next);\n onPageChange?.(next);\n },\n [controlledPage, onPageChange, pageCount],\n );\n const context = useMemo(\n () => ({ density, goTo, page, pageCount }),\n [density, goTo, page, pageCount],\n );\n\n return (\n <PaginationContext.Provider value={context}>\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Pagination\"}\n ref={ref}\n className={cx(pagination({ density }).root, className)}\n data-density={density}\n data-jaci-component=\"pagination\"\n data-slot=\"pagination\"\n >\n {children ??\n (pageCount ? (\n <PaginationGenerated\n page={page ?? 1}\n pageCount={pageCount}\n showFirstLast={showFirstLast}\n siblingCount={siblingCount}\n />\n ) : null)}\n </nav>\n </PaginationContext.Provider>\n );\n});\n\nexport type PaginationListProps = ComponentPropsWithoutRef<\"ul\">;\nexport const PaginationList = forwardRef<HTMLUListElement, PaginationListProps>(\n function PaginationList({ className, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <ul\n {...props}\n ref={ref}\n className={cx(pagination({ density: context?.density }).list, className)}\n data-slot=\"pagination-list\"\n />\n );\n },\n);\n\nexport type PaginationItemProps = ComponentPropsWithoutRef<\"li\">;\nexport const PaginationItem = forwardRef<HTMLLIElement, PaginationItemProps>(\n function PaginationItem({ className, ...props }, ref) {\n return (\n <li\n {...props}\n ref={ref}\n className={cx(pagination().item, className)}\n data-slot=\"pagination-item\"\n />\n );\n },\n);\n\nexport interface PaginationLinkProps extends ComponentPropsWithoutRef<\"a\"> {\n active?: boolean;\n disabled?: boolean;\n page?: number | undefined;\n}\n\ntype PaginationAnchorSlot =\n | \"pagination-link\"\n | \"pagination-first\"\n | \"pagination-last\"\n | \"pagination-previous\"\n | \"pagination-next\";\n\ninterface PaginationAnchorProps extends PaginationLinkProps {\n slot: PaginationAnchorSlot;\n}\n\nfunction getAnchorClassName(\n active: boolean,\n disabled: boolean,\n density: PaginationDensity | undefined,\n slot: PaginationAnchorSlot,\n) {\n const styles = pagination({ active, density, disabled });\n if (slot === \"pagination-previous\") return cx(styles.link, styles.previous);\n if (slot === \"pagination-next\") return cx(styles.link, styles.next);\n if (slot === \"pagination-first\") return cx(styles.link, styles.first);\n if (slot === \"pagination-last\") return cx(styles.link, styles.last);\n return styles.link;\n}\n\nconst PaginationAnchor = forwardRef<HTMLAnchorElement, PaginationAnchorProps>(\n function PaginationAnchor(\n {\n active: activeProp,\n \"aria-current\": ariaCurrent,\n className,\n disabled: disabledProp = false,\n href,\n onClick,\n page,\n slot,\n tabIndex,\n ...props\n },\n ref,\n ) {\n const context = usePaginationContext();\n const active = activeProp ?? (page !== undefined && context?.page === page);\n const disabled = Boolean(disabledProp || (page !== undefined && context?.pageCount === 1));\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n aria-disabled={disabled || undefined}\n ref={ref}\n className={cx(\n getAnchorClassName(Boolean(active), disabled, context?.density, slot),\n className,\n )}\n data-active={active || undefined}\n data-disabled={disabled || undefined}\n data-page={page}\n data-slot={slot}\n href={disabled ? undefined : href}\n onClick={(event) => {\n if (disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n if (page !== undefined && context?.pageCount) {\n event.preventDefault();\n context.goTo(page);\n }\n onClick?.(event);\n }}\n tabIndex={disabled ? -1 : tabIndex}\n />\n );\n },\n);\n\nexport const PaginationLink = forwardRef<HTMLAnchorElement, PaginationLinkProps>(\n function PaginationLink(props, ref) {\n return <PaginationAnchor {...props} ref={ref} slot=\"pagination-link\" />;\n },\n);\n\nexport interface PaginationPreviousProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationPrevious = forwardRef<HTMLAnchorElement, PaginationPreviousProps>(\n function PaginationPrevious({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page - 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to previous page\"}\n disabled={props.disabled ?? (targetPage !== undefined && targetPage < 1)}\n page={targetPage}\n ref={ref}\n rel={rel ?? \"prev\"}\n slot=\"pagination-previous\"\n >\n {children ?? (\n <>\n <span aria-hidden=\"true\">‹</span>\n <span>Previous</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationNextProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationNext = forwardRef<HTMLAnchorElement, PaginationNextProps>(\n function PaginationNext({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page + 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to next page\"}\n disabled={\n props.disabled ??\n (targetPage !== undefined && targetPage > (context?.pageCount ?? Infinity))\n }\n page={targetPage}\n ref={ref}\n rel={rel ?? \"next\"}\n slot=\"pagination-next\"\n >\n {children ?? (\n <>\n <span>Next</span>\n <span aria-hidden=\"true\">›</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationFirstProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationFirst = forwardRef<HTMLAnchorElement, PaginationFirstProps>(\n function PaginationFirst({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to first page\"}\n page={page ?? 1}\n ref={ref}\n slot=\"pagination-first\"\n >\n {children ?? \"First\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationLastProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationLast = forwardRef<HTMLAnchorElement, PaginationLastProps>(\n function PaginationLast({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to last page\"}\n page={page ?? context?.pageCount}\n ref={ref}\n slot=\"pagination-last\"\n >\n {children ?? \"Last\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport type PaginationEllipsisProps = ComponentPropsWithoutRef<\"span\">;\nexport const PaginationEllipsis = forwardRef<HTMLSpanElement, PaginationEllipsisProps>(\n function PaginationEllipsis({ children = \"…\", className, ...props }, ref) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n ref={ref}\n className={cx(pagination().ellipsis, className)}\n data-slot=\"pagination-ellipsis\"\n >\n {children}\n </span>\n );\n },\n);\n\ntype PaginationPageItem = number | \"ellipsis\";\n\nfunction getPageItems(page: number, pageCount: number, siblingCount: number): PaginationPageItem[] {\n const visible = new Set<number>([1, pageCount]);\n for (let index = page - siblingCount; index <= page + siblingCount; index += 1) {\n if (index > 0 && index <= pageCount) visible.add(index);\n }\n const pages = [...visible].sort((left, right) => left - right);\n const items: PaginationPageItem[] = [];\n pages.forEach((value, index) => {\n const previous = pages[index - 1];\n if (previous !== undefined && value - previous > 1) items.push(\"ellipsis\");\n items.push(value);\n });\n return items;\n}\n\nfunction PaginationGenerated({\n page,\n pageCount,\n showFirstLast,\n siblingCount,\n}: {\n page: number;\n pageCount: number;\n showFirstLast: boolean;\n siblingCount: number;\n}) {\n const pageItems = getPageItems(page, pageCount, siblingCount);\n return (\n <PaginationList>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationFirst disabled={page <= 1} />\n </PaginationItem>\n ) : null}\n <PaginationItem>\n <PaginationPrevious disabled={page <= 1} />\n </PaginationItem>\n {pageItems.map((item, index) =>\n item === \"ellipsis\" ? (\n <PaginationItem\n key={`ellipsis-${pageItems.slice(0, index).filter((value) => value === \"ellipsis\").length + 1}`}\n >\n <PaginationEllipsis />\n </PaginationItem>\n ) : (\n <PaginationItem key={item}>\n <PaginationLink page={item}>{item}</PaginationLink>\n </PaginationItem>\n ),\n )}\n <PaginationItem>\n <PaginationNext disabled={page >= pageCount} />\n </PaginationItem>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationLast disabled={page >= pageCount} />\n </PaginationItem>\n ) : null}\n </PaginationList>\n );\n}\n\nexport const Pagination = {\n Root: PaginationRoot,\n List: PaginationList,\n Item: PaginationItem,\n Link: PaginationLink,\n First: PaginationFirst,\n Previous: PaginationPrevious,\n Next: PaginationNext,\n Last: PaginationLast,\n Ellipsis: PaginationEllipsis,\n};\n"],"mappings":";;;;;;AAiBA,MAAM,qBAAA,GAAoBA,MAAAA,cAAAA,CAA6C,IAAI;AAE3E,SAAS,uBAAuB;CAC9B,QAAA,GAAOC,MAAAA,WAAAA,CAAW,iBAAiB;AACrC;AAaA,MAAa,kBAAA,GAAiBC,MAAAA,WAAAA,CAA6C,SAAS,eAClF,EACE,UACA,cAAc,WACd,WACA,cAAc,GACd,UAAU,eACV,cACA,MAAM,gBACN,WACA,gBAAgB,OAChB,eAAe,GACf,GAAG,SAEL,KACA;CACA,MAAM,CAAC,kBAAkB,wBAAA,GAAuBC,MAAAA,SAAAA,CAAS,WAAW;CACpE,MAAM,OAAO,YACT,KAAK,IAAI,KAAK,IAAI,kBAAkB,kBAAkB,CAAC,GAAG,SAAS,IACnE;CACJ,MAAM,QAAA,GAAOC,MAAAA,YAAAA,EACV,aAAqB;EACpB,IAAI,CAAC,WAAW;EAChB,MAAM,OAAO,KAAK,IAAI,KAAK,IAAI,UAAU,CAAC,GAAG,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AAA;EAAqB,CAAA,EACpC,GAFK,IAEL,CAEpB;EACA,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAgB,UAAU,QAAQ,UAAY,CAAA,EAChC,CAAA;EACf,gBACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,gBAAD,EAAgB,UAAU,QAAQ,UAAY,CAAA,EAChC,CAAA,IACd;CACU,EAAA,CAAA;AAEpB;AAEA,MAAa,aAAa;CACxB,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,UAAU;CACV,MAAM;CACN,MAAM;CACN,UAAU;AACZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.js","names":[],"sources":["../../../src/components/pagination/pagination.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { pagination } from \"../../styled-system/recipes\";\n\nexport type PaginationDensity = \"compact\" | \"comfortable\";\n\ninterface PaginationContextValue {\n density: PaginationDensity;\n goTo: (page: number) => void;\n page: number | undefined;\n pageCount: number | undefined;\n}\n\nconst PaginationContext = createContext<PaginationContextValue | null>(null);\n\nfunction usePaginationContext() {\n return useContext(PaginationContext);\n}\n\nexport interface PaginationRootProps extends Omit<ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n children?: ReactNode;\n defaultPage?: number;\n density?: PaginationDensity;\n onPageChange?: (page: number) => void;\n page?: number;\n pageCount?: number;\n showFirstLast?: boolean;\n siblingCount?: number;\n}\n\nexport const PaginationRoot = forwardRef<HTMLElement, PaginationRootProps>(function PaginationRoot(\n {\n children,\n \"aria-label\": ariaLabel,\n className,\n defaultPage = 1,\n density = \"comfortable\",\n onPageChange,\n page: controlledPage,\n pageCount,\n showFirstLast = false,\n siblingCount = 1,\n ...props\n },\n ref,\n) {\n const [uncontrolledPage, setUncontrolledPage] = useState(defaultPage);\n const page = pageCount\n ? Math.min(Math.max(controlledPage ?? uncontrolledPage, 1), pageCount)\n : controlledPage;\n const goTo = useCallback(\n (nextPage: number) => {\n if (!pageCount) return;\n const next = Math.min(Math.max(nextPage, 1), pageCount);\n if (controlledPage === undefined) setUncontrolledPage(next);\n onPageChange?.(next);\n },\n [controlledPage, onPageChange, pageCount],\n );\n const context = useMemo(\n () => ({ density, goTo, page, pageCount }),\n [density, goTo, page, pageCount],\n );\n\n return (\n <PaginationContext.Provider value={context}>\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Pagination\"}\n ref={ref}\n className={cx(pagination({ density }).root, className)}\n data-density={density}\n data-jaci-component=\"pagination\"\n data-slot=\"pagination\"\n >\n {children ??\n (pageCount ? (\n <PaginationGenerated\n page={page ?? 1}\n pageCount={pageCount}\n showFirstLast={showFirstLast}\n siblingCount={siblingCount}\n />\n ) : null)}\n </nav>\n </PaginationContext.Provider>\n );\n});\n\nexport type PaginationListProps = ComponentPropsWithoutRef<\"ul\">;\nexport const PaginationList = forwardRef<HTMLUListElement, PaginationListProps>(\n function PaginationList({ className, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <ul\n {...props}\n ref={ref}\n className={cx(pagination({ density: context?.density }).list, className)}\n data-slot=\"pagination-list\"\n />\n );\n },\n);\n\nexport type PaginationItemProps = ComponentPropsWithoutRef<\"li\">;\nexport const PaginationItem = forwardRef<HTMLLIElement, PaginationItemProps>(\n function PaginationItem({ className, ...props }, ref) {\n return (\n <li\n {...props}\n ref={ref}\n className={cx(pagination().item, className)}\n data-slot=\"pagination-item\"\n />\n );\n },\n);\n\nexport interface PaginationLinkProps extends ComponentPropsWithoutRef<\"a\"> {\n active?: boolean;\n disabled?: boolean;\n page?: number | undefined;\n}\n\ntype PaginationAnchorSlot =\n | \"pagination-link\"\n | \"pagination-first\"\n | \"pagination-last\"\n | \"pagination-previous\"\n | \"pagination-next\";\n\ninterface PaginationAnchorProps extends PaginationLinkProps {\n slot: PaginationAnchorSlot;\n}\n\nfunction getAnchorClassName(\n active: boolean,\n disabled: boolean,\n density: PaginationDensity | undefined,\n slot: PaginationAnchorSlot,\n) {\n const styles = pagination({ active, density, disabled });\n if (slot === \"pagination-previous\") return cx(styles.link, styles.previous);\n if (slot === \"pagination-next\") return cx(styles.link, styles.next);\n if (slot === \"pagination-first\") return cx(styles.link, styles.first);\n if (slot === \"pagination-last\") return cx(styles.link, styles.last);\n return styles.link;\n}\n\nconst PaginationAnchor = forwardRef<HTMLAnchorElement, PaginationAnchorProps>(\n function PaginationAnchor(\n {\n active: activeProp,\n \"aria-current\": ariaCurrent,\n className,\n disabled: disabledProp = false,\n href,\n onClick,\n page,\n slot,\n tabIndex,\n ...props\n },\n ref,\n ) {\n const context = usePaginationContext();\n const active = activeProp ?? (page !== undefined && context?.page === page);\n const disabled = Boolean(disabledProp || (page !== undefined && context?.pageCount === 1));\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n aria-disabled={disabled || undefined}\n ref={ref}\n className={cx(\n getAnchorClassName(Boolean(active), disabled, context?.density, slot),\n className,\n )}\n data-active={active || undefined}\n data-disabled={disabled || undefined}\n data-page={page}\n data-slot={slot}\n href={disabled ? undefined : href}\n onClick={(event) => {\n if (disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n if (page !== undefined && context?.pageCount) {\n event.preventDefault();\n context.goTo(page);\n }\n onClick?.(event);\n }}\n tabIndex={disabled ? -1 : tabIndex}\n />\n );\n },\n);\n\nexport const PaginationLink = forwardRef<HTMLAnchorElement, PaginationLinkProps>(\n function PaginationLink(props, ref) {\n return <PaginationAnchor {...props} ref={ref} slot=\"pagination-link\" />;\n },\n);\n\nexport interface PaginationPreviousProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationPrevious = forwardRef<HTMLAnchorElement, PaginationPreviousProps>(\n function PaginationPrevious({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page - 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to previous page\"}\n disabled={props.disabled ?? (targetPage !== undefined && targetPage < 1)}\n page={targetPage}\n ref={ref}\n rel={rel ?? \"prev\"}\n slot=\"pagination-previous\"\n >\n {children ?? (\n <>\n <span aria-hidden=\"true\">‹</span>\n <span>Previous</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationNextProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationNext = forwardRef<HTMLAnchorElement, PaginationNextProps>(\n function PaginationNext({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page + 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to next page\"}\n disabled={\n props.disabled ??\n (targetPage !== undefined && targetPage > (context?.pageCount ?? Infinity))\n }\n page={targetPage}\n ref={ref}\n rel={rel ?? \"next\"}\n slot=\"pagination-next\"\n >\n {children ?? (\n <>\n <span>Next</span>\n <span aria-hidden=\"true\">›</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationFirstProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationFirst = forwardRef<HTMLAnchorElement, PaginationFirstProps>(\n function PaginationFirst({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to first page\"}\n page={page ?? 1}\n ref={ref}\n slot=\"pagination-first\"\n >\n {children ?? \"First\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationLastProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationLast = forwardRef<HTMLAnchorElement, PaginationLastProps>(\n function PaginationLast({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to last page\"}\n page={page ?? context?.pageCount}\n ref={ref}\n slot=\"pagination-last\"\n >\n {children ?? \"Last\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport type PaginationEllipsisProps = ComponentPropsWithoutRef<\"span\">;\nexport const PaginationEllipsis = forwardRef<HTMLSpanElement, PaginationEllipsisProps>(\n function PaginationEllipsis({ children = \"…\", className, ...props }, ref) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n ref={ref}\n className={cx(pagination().ellipsis, className)}\n data-slot=\"pagination-ellipsis\"\n >\n {children}\n </span>\n );\n },\n);\n\ntype PaginationPageItem = number | \"ellipsis\";\n\nfunction getPageItems(page: number, pageCount: number, siblingCount: number): PaginationPageItem[] {\n const visible = new Set<number>([1, pageCount]);\n for (let index = page - siblingCount; index <= page + siblingCount; index += 1) {\n if (index > 0 && index <= pageCount) visible.add(index);\n }\n const pages = [...visible].sort((left, right) => left - right);\n const items: PaginationPageItem[] = [];\n pages.forEach((value, index) => {\n const previous = pages[index - 1];\n if (previous !== undefined && value - previous > 1) items.push(\"ellipsis\");\n items.push(value);\n });\n return items;\n}\n\nfunction PaginationGenerated({\n page,\n pageCount,\n showFirstLast,\n siblingCount,\n}: {\n page: number;\n pageCount: number;\n showFirstLast: boolean;\n siblingCount: number;\n}) {\n const pageItems = getPageItems(page, pageCount, siblingCount);\n return (\n <PaginationList>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationFirst disabled={page <= 1} />\n </PaginationItem>\n ) : null}\n <PaginationItem>\n <PaginationPrevious disabled={page <= 1} />\n </PaginationItem>\n {pageItems.map((item, index) =>\n item === \"ellipsis\" ? (\n <PaginationItem\n key={`ellipsis-${pageItems.slice(0, index).filter((value) => value === \"ellipsis\").length + 1}`}\n >\n <PaginationEllipsis />\n </PaginationItem>\n ) : (\n <PaginationItem key={item}>\n <PaginationLink page={item}>{item}</PaginationLink>\n </PaginationItem>\n ),\n )}\n <PaginationItem>\n <PaginationNext disabled={page >= pageCount} />\n </PaginationItem>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationLast disabled={page >= pageCount} />\n </PaginationItem>\n ) : null}\n </PaginationList>\n );\n}\n\nexport const Pagination = {\n Root: PaginationRoot,\n List: PaginationList,\n Item: PaginationItem,\n Link: PaginationLink,\n First: PaginationFirst,\n Previous: PaginationPrevious,\n Next: PaginationNext,\n Last: PaginationLast,\n Ellipsis: PaginationEllipsis,\n};\n"],"mappings":";;;;;;AAiBA,MAAM,oBAAoB,cAA6C,IAAI;AAE3E,SAAS,uBAAuB;CAC9B,OAAO,WAAW,iBAAiB;AACrC;AAaA,MAAa,iBAAiB,WAA6C,SAAS,eAClF,EACE,UACA,cAAc,WACd,WACA,cAAc,GACd,UAAU,eACV,cACA,MAAM,gBACN,WACA,gBAAgB,OAChB,eAAe,GACf,GAAG,SAEL,KACA;CACA,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,WAAW;CACpE,MAAM,OAAO,YACT,KAAK,IAAI,KAAK,IAAI,kBAAkB,kBAAkB,CAAC,GAAG,SAAS,IACnE;CACJ,MAAM,OAAO,aACV,aAAqB;EACpB,IAAI,CAAC,WAAW;EAChB,MAAM,OAAO,KAAK,IAAI,KAAK,IAAI,UAAU,CAAC,GAAG,SAAS;EACtD,IAAI,mBAAmB,KAAA,GAAW,oBAAoB,IAAI;EAC1D,eAAe,IAAI;CACrB,GACA;EAAC;EAAgB;EAAc;CAAS,CAC1C;CACA,MAAM,UAAU,eACP;EAAE;EAAS;EAAM;EAAM;CAAU,IACxC;EAAC;EAAS;EAAM;EAAM;CAAS,CACjC;CAEA,OACE,oBAAC,kBAAkB,UAAnB;EAA4B,OAAO;YACjC,oBAAC,OAAD;GACE,GAAI;GACJ,cAAY,aAAa;GACpB;GACL,WAAW,GAAG,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,SAAS;GACrD,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CAAA;AAEpB;AAEA,MAAa,aAAa;CACxB,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,UAAU;CACV,MAAM;CACN,MAAM;CACN,UAAU;AACZ"}
1
+ {"version":3,"file":"pagination.js","names":[],"sources":["../../../src/components/pagination/pagination.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, forwardRef, useCallback, useContext, useMemo, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { pagination } from \"../../styled-system/recipes\";\n\nexport type PaginationDensity = \"compact\" | \"comfortable\";\n\ninterface PaginationContextValue {\n density: PaginationDensity;\n goTo: (page: number) => void;\n page: number | undefined;\n pageCount: number | undefined;\n}\n\nconst PaginationContext = createContext<PaginationContextValue | null>(null);\n\nfunction usePaginationContext() {\n return useContext(PaginationContext);\n}\n\nexport interface PaginationRootProps extends Omit<ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n children?: ReactNode;\n defaultPage?: number;\n density?: PaginationDensity;\n onPageChange?: (page: number) => void;\n page?: number;\n pageCount?: number;\n showFirstLast?: boolean;\n siblingCount?: number;\n}\n\nexport const PaginationRoot = forwardRef<HTMLElement, PaginationRootProps>(function PaginationRoot(\n {\n children,\n \"aria-label\": ariaLabel,\n className,\n defaultPage = 1,\n density = \"comfortable\",\n onPageChange,\n page: controlledPage,\n pageCount,\n showFirstLast = false,\n siblingCount = 1,\n ...props\n },\n ref,\n) {\n const [uncontrolledPage, setUncontrolledPage] = useState(defaultPage);\n const page = pageCount\n ? Math.min(Math.max(controlledPage ?? uncontrolledPage, 1), pageCount)\n : controlledPage;\n const goTo = useCallback(\n (nextPage: number) => {\n if (!pageCount) return;\n const next = Math.min(Math.max(nextPage, 1), pageCount);\n if (controlledPage === undefined) setUncontrolledPage(next);\n onPageChange?.(next);\n },\n [controlledPage, onPageChange, pageCount],\n );\n const context = useMemo(\n () => ({ density, goTo, page, pageCount }),\n [density, goTo, page, pageCount],\n );\n\n return (\n <PaginationContext.Provider value={context}>\n <nav\n {...props}\n aria-label={ariaLabel ?? \"Pagination\"}\n ref={ref}\n className={cx(pagination({ density }).root, className)}\n data-density={density}\n data-jaci-component=\"pagination\"\n data-slot=\"pagination\"\n >\n {children ??\n (pageCount ? (\n <PaginationGenerated\n page={page ?? 1}\n pageCount={pageCount}\n showFirstLast={showFirstLast}\n siblingCount={siblingCount}\n />\n ) : null)}\n </nav>\n </PaginationContext.Provider>\n );\n});\n\nexport type PaginationListProps = ComponentPropsWithoutRef<\"ul\">;\nexport const PaginationList = forwardRef<HTMLUListElement, PaginationListProps>(\n function PaginationList({ className, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <ul\n {...props}\n ref={ref}\n className={cx(pagination({ density: context?.density }).list, className)}\n data-slot=\"pagination-list\"\n />\n );\n },\n);\n\nexport type PaginationItemProps = ComponentPropsWithoutRef<\"li\">;\nexport const PaginationItem = forwardRef<HTMLLIElement, PaginationItemProps>(\n function PaginationItem({ className, ...props }, ref) {\n return (\n <li\n {...props}\n ref={ref}\n className={cx(pagination().item, className)}\n data-slot=\"pagination-item\"\n />\n );\n },\n);\n\nexport interface PaginationLinkProps extends ComponentPropsWithoutRef<\"a\"> {\n active?: boolean;\n disabled?: boolean;\n page?: number | undefined;\n}\n\ntype PaginationAnchorSlot =\n | \"pagination-link\"\n | \"pagination-first\"\n | \"pagination-last\"\n | \"pagination-previous\"\n | \"pagination-next\";\n\ninterface PaginationAnchorProps extends PaginationLinkProps {\n slot: PaginationAnchorSlot;\n}\n\nfunction getAnchorClassName(\n active: boolean,\n disabled: boolean,\n density: PaginationDensity | undefined,\n slot: PaginationAnchorSlot,\n) {\n const styles = pagination({ active, density, disabled });\n if (slot === \"pagination-previous\") return cx(styles.link, styles.previous);\n if (slot === \"pagination-next\") return cx(styles.link, styles.next);\n if (slot === \"pagination-first\") return cx(styles.link, styles.first);\n if (slot === \"pagination-last\") return cx(styles.link, styles.last);\n return styles.link;\n}\n\nconst PaginationAnchor = forwardRef<HTMLAnchorElement, PaginationAnchorProps>(\n function PaginationAnchor(\n {\n active: activeProp,\n \"aria-current\": ariaCurrent,\n className,\n disabled: disabledProp = false,\n href,\n onClick,\n page,\n slot,\n tabIndex,\n ...props\n },\n ref,\n ) {\n const context = usePaginationContext();\n const active = activeProp ?? (page !== undefined && context?.page === page);\n const disabled = Boolean(disabledProp || (page !== undefined && context?.pageCount === 1));\n return (\n <a\n {...props}\n aria-current={ariaCurrent ?? (active ? \"page\" : undefined)}\n aria-disabled={disabled || undefined}\n ref={ref}\n className={cx(\n getAnchorClassName(Boolean(active), disabled, context?.density, slot),\n className,\n )}\n data-active={active || undefined}\n data-disabled={disabled || undefined}\n data-page={page}\n data-slot={slot}\n href={disabled ? undefined : href}\n onClick={(event) => {\n if (disabled) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n if (page !== undefined && context?.pageCount) {\n event.preventDefault();\n context.goTo(page);\n }\n onClick?.(event);\n }}\n tabIndex={disabled ? -1 : tabIndex}\n />\n );\n },\n);\n\nexport const PaginationLink = forwardRef<HTMLAnchorElement, PaginationLinkProps>(\n function PaginationLink(props, ref) {\n return <PaginationAnchor {...props} ref={ref} slot=\"pagination-link\" />;\n },\n);\n\nexport interface PaginationPreviousProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationPrevious = forwardRef<HTMLAnchorElement, PaginationPreviousProps>(\n function PaginationPrevious({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page - 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to previous page\"}\n disabled={props.disabled ?? (targetPage !== undefined && targetPage < 1)}\n page={targetPage}\n ref={ref}\n rel={rel ?? \"prev\"}\n slot=\"pagination-previous\"\n >\n {children ?? (\n <>\n <span aria-hidden=\"true\">‹</span>\n <span>Previous</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationNextProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationNext = forwardRef<HTMLAnchorElement, PaginationNextProps>(\n function PaginationNext({ \"aria-label\": ariaLabel, children, page, rel, ...props }, ref) {\n const context = usePaginationContext();\n const targetPage = page ?? (context?.page ? context.page + 1 : undefined);\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to next page\"}\n disabled={\n props.disabled ??\n (targetPage !== undefined && targetPage > (context?.pageCount ?? Infinity))\n }\n page={targetPage}\n ref={ref}\n rel={rel ?? \"next\"}\n slot=\"pagination-next\"\n >\n {children ?? (\n <>\n <span>Next</span>\n <span aria-hidden=\"true\">›</span>\n </>\n )}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationFirstProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationFirst = forwardRef<HTMLAnchorElement, PaginationFirstProps>(\n function PaginationFirst({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to first page\"}\n page={page ?? 1}\n ref={ref}\n slot=\"pagination-first\"\n >\n {children ?? \"First\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport interface PaginationLastProps extends PaginationLinkProps {\n children?: ReactNode;\n}\nexport const PaginationLast = forwardRef<HTMLAnchorElement, PaginationLastProps>(\n function PaginationLast({ \"aria-label\": ariaLabel, children, page, ...props }, ref) {\n const context = usePaginationContext();\n return (\n <PaginationAnchor\n {...props}\n aria-label={ariaLabel ?? \"Go to last page\"}\n page={page ?? context?.pageCount}\n ref={ref}\n slot=\"pagination-last\"\n >\n {children ?? \"Last\"}\n </PaginationAnchor>\n );\n },\n);\n\nexport type PaginationEllipsisProps = ComponentPropsWithoutRef<\"span\">;\nexport const PaginationEllipsis = forwardRef<HTMLSpanElement, PaginationEllipsisProps>(\n function PaginationEllipsis({ children = \"…\", className, ...props }, ref) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n ref={ref}\n className={cx(pagination().ellipsis, className)}\n data-slot=\"pagination-ellipsis\"\n >\n {children}\n </span>\n );\n },\n);\n\ntype PaginationPageItem = number | \"ellipsis\";\n\nfunction getPageItems(page: number, pageCount: number, siblingCount: number): PaginationPageItem[] {\n const visible = new Set<number>([1, pageCount]);\n for (let index = page - siblingCount; index <= page + siblingCount; index += 1) {\n if (index > 0 && index <= pageCount) visible.add(index);\n }\n const pages = [...visible].sort((left, right) => left - right);\n const items: PaginationPageItem[] = [];\n pages.forEach((value, index) => {\n const previous = pages[index - 1];\n if (previous !== undefined && value - previous > 1) items.push(\"ellipsis\");\n items.push(value);\n });\n return items;\n}\n\nfunction PaginationGenerated({\n page,\n pageCount,\n showFirstLast,\n siblingCount,\n}: {\n page: number;\n pageCount: number;\n showFirstLast: boolean;\n siblingCount: number;\n}) {\n const pageItems = getPageItems(page, pageCount, siblingCount);\n return (\n <PaginationList>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationFirst disabled={page <= 1} />\n </PaginationItem>\n ) : null}\n <PaginationItem>\n <PaginationPrevious disabled={page <= 1} />\n </PaginationItem>\n {pageItems.map((item, index) =>\n item === \"ellipsis\" ? (\n <PaginationItem\n key={`ellipsis-${pageItems.slice(0, index).filter((value) => value === \"ellipsis\").length + 1}`}\n >\n <PaginationEllipsis />\n </PaginationItem>\n ) : (\n <PaginationItem key={item}>\n <PaginationLink page={item}>{item}</PaginationLink>\n </PaginationItem>\n ),\n )}\n <PaginationItem>\n <PaginationNext disabled={page >= pageCount} />\n </PaginationItem>\n {showFirstLast ? (\n <PaginationItem>\n <PaginationLast disabled={page >= pageCount} />\n </PaginationItem>\n ) : null}\n </PaginationList>\n );\n}\n\nexport const Pagination = {\n Root: PaginationRoot,\n List: PaginationList,\n Item: PaginationItem,\n Link: PaginationLink,\n First: PaginationFirst,\n Previous: PaginationPrevious,\n Next: PaginationNext,\n Last: PaginationLast,\n Ellipsis: PaginationEllipsis,\n};\n"],"mappings":";;;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KAAA,KAAa,QAAQ,WAAW,GAAG,MAAM,KAAK,UAAU;EACzE,MAAM,KAAK,KAAK;CAClB,CAAC;CACD,OAAO;AACT;AAEA,SAAS,oBAAoB,EAC3B,MACA,WACA,eACA,gBAMC;CACD,MAAM,YAAY,aAAa,MAAM,WAAW,YAAY;CAC5D,OACE,qBAAC,gBAAD,EAAA,UAAA;EACG,gBACC,oBAAC,gBAAD,EAAA,UACE,oBAAC,iBAAD,EAAiB,UAAU,QAAQ,EAAI,CAAA,EACzB,CAAA,IACd;EACJ,oBAAC,gBAAD,EAAA,UACE,oBAAC,oBAAD,EAAoB,UAAU,QAAQ,EAAI,CAAA,EAC5B,CAAA;EACf,UAAU,KAAK,MAAM,UACpB,SAAS,aACP,oBAAC,gBAAD,EAAA,UAGE,oBAAC,oBAAD,CAAqB,CAAA,EACP,GAHT,YAAY,UAAU,MAAM,GAAG,KAAK,CAAC,CAAC,QAAQ,UAAU,UAAU,UAAU,CAAC,CAAC,SAAS,GAG9E,IAEhB,oBAAC,gBAAD,EAAA,UACE,oBAAC,gBAAD;GAAgB,MAAM;GAAO,UAAA;EAAqB,CAAA,EACpC,GAFK,IAEL,CAEpB;EACA,oBAAC,gBAAD,EAAA,UACE,oBAAC,gBAAD,EAAgB,UAAU,QAAQ,UAAY,CAAA,EAChC,CAAA;EACf,gBACC,oBAAC,gBAAD,EAAA,UACE,oBAAC,gBAAD,EAAgB,UAAU,QAAQ,UAAY,CAAA,EAChC,CAAA,IACd;CACU,EAAA,CAAA;AAEpB;AAEA,MAAa,aAAa;CACxB,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,UAAU;CACV,MAAM;CACN,MAAM;CACN,UAAU;AACZ"}
@@ -1 +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,qBAA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,CAAC,KAAD;EACE,GAAI;EACJ,WAAWA,WAAAA,GAAG,OAAO,OAAO,SAAS;EACrC,aAAU;EACV,MAAK;EACA;CACN,CAAA;AAEL,CACF;AAKA,MAAa,uBAAA,GAAA,MAAA,WAAA,CACX,SAAS,oBAAoB,OAAO,KAAK;CACvC,MAAM,EAAE,UAAU,QAAQ,UAAU,mBAAmB;CACvD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;EACE,GAAI;EACJ,eAAY;EACZ,WAAW,OAAO;EAClB,UAAU,YAAY,MAAM;EAC5B,UAAA;EACK;EACL,UAAU;EACV,MAAK;EACE;CACR,CAAA;AAEL,CACF;AAEA,MAAa,WAAW;CACtB,MAAM;CACN,OAAO;CACP,SAAS;CACT,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,aAAa;AACf"}
1
+ {"version":3,"file":"pin-input.cjs","names":["createContext","useContext","forwardRef","useId","pinInput","useState","useRef","useCallback","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,GAAkBA,MAAAA,cAAAA,CAA2C,IAAI;AAEvE,SAAS,SAAS,OAAe;CAC/B,OAAO,SAAS;AAClB;AAEA,SAAS,qBAAqB;CAC5B,MAAM,WAAA,GAAUC,MAAAA,WAAAA,CAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAkBA,MAAa,gBAAA,GAAeC,MAAAA,WAAAA,CAA8C,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,GAAcC,MAAAA,MAAAA,CAAM;CAC1B,MAAM,KAAK,cAAc;CACzB,MAAM,SAASC,kBAAAA,SAAS;CACxB,MAAM,aAAa,KAAK,IAAI,GAAG,KAAK,MAAM,MAAM,CAAC;CACjD,MAAM,CAAC,mBAAm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A;AAEL,CACF;AAEA,MAAa,WAAW;CACtB,MAAM;CACN,OAAO;CACP,SAAS;CACT,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,aAAa;AACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"pin-input.js","names":[],"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,kBAAkB,cAA2C,IAAI;AAEvE,SAAS,SAAS,OAAe;CAC/B,OAAO,SAAS;AAClB;AAEA,SAAS,qBAAqB;CAC5B,MAAM,UAAU,WAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAkBA,MAAa,eAAe,WAA8C,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,cAAc,MAAM;CAC1B,MAAM,KAAK,cAAc;CACzB,MAAM,SAAS,SAAS;CACxB,MAAM,aAAa,KAAK,IAAI,GAAG,KAAK,MAAM,MAAM,CAAC;CACjD,MAAM,CAAC,mBAAmB,wBAAwB,eAChD,aAAa,MAAM,GAAG,UAAU,CAClC;CACA,MAAM,SAAS,mBAAmB,kBAAA,CAAmB,MAAM,GAAG,UAAU;CACxE,MAAM,YAAY,OAAuC,CAAC,CAAC;CAC3D,MAAM,eAAe,OAAO,KAAK;CACjC,MAAM,cAAc,aACjB,SAAiB;EAChB,MAAM,aAAa,KAAK,MAAM,GAAG,UAAU;EAC3C,IAAI,oBAAoB,KAAA,GAAW,qBAAqB,UAAU;EAClE,gBAAgB,UAAU;EAC1B,IAAI,WAAW,WAAW,YAAY,aAAa,UAAU;CAC/D,GACA;EAAC;EAAiB;EAAY;EAAe;CAAU,CACzD;CACA,MAAM,YAAY,aACf,SAAiB;EAChB,MAAM,aAAa,MAAM,KAAK,IAAI;EAClC,QAAQ,MAAM,WAAW,QAAQ,cAAc,SAAS,KAAK,SAAS,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SAAS;CACT,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,aAAa;AACf"}
1
+ {"version":3,"file":"pin-input.js","names":[],"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,kBAAkB,cAA2C,IAAI;AAEvE,SAAS,SAAS,OAAe;CAC/B,OAAO,SAAS;AAClB;AAEA,SAAS,qBAAqB;CAC5B,MAAM,UAAU,WAAW,eAAe;CAC1C,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,uDAAuD;CACrF,OAAO;AACT;AAkBA,MAAa,eAAe,WAA8C,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,cAAc,MAAM;CAC1B,MAAM,KAAK,cAAc;CACzB,MAAM,SAAS,SAAS;CACxB,MAAM,aAAa,KAAK,IAAI,GAAG,KAAK,MAAM,MAAM,CAAC;CACjD,MAAM,CAAC,mBAAmB,wBAAwB,eAChD,aAAa,MAAM,GAAG,UAAU,CAClC;CACA,MAAM,SAAS,mBAAmB,kBAAA,CAAmB,MAAM,GAAG,UAAU;CACxE,MAAM,YAAY,OAAuC,CAAC,CAAC;CAC3D,MAAM,eAAe,OAAO,KAAK;CACjC,MAAM,cAAc,aACjB,SAAiB;EAChB,MAAM,aAAa,KAAK,MAAM,GAAG,UAAU;EAC3C,IAAI,oBAAoB,KAAA,GAAW,qBAAqB,UAAU;EAClE,gBAAgB,UAAU;EAC1B,IAAI,WAAW,WAAW,YAAY,aAAa,UAAU;CAC/D,GACA;EAAC;EAAiB;EAAY;EAAe;CAAU,CACzD;CACA,MAAM,YAAY,aACf,SAAiB;EAChB,MAAM,aAAa,MAAM,KAAK,IAAI;EAClC,QAAQ,MAAM,WAAW,QAAQ,cAAc,SAAS,KAAK,SAAS,CAAC,IAAI,WAAA,CACxE,KAAK,EAAE,CAAC,CACR,MAAM,GAAG,UAAU;CACxB,G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;AACf"}
@@ -1 +1 @@
1
- {"version":3,"file":"popover.cjs","names":["BasePopover","withRecipeClassName","popover","useThemePortalProps"],"sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { Popover as BasePopover } from \"@base-ui/react/popover\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { PopoverRoot as BasePopoverRoot } from \"@base-ui/react/popover\";\n\nimport { popover } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\n/** Preserves Base UI's controlled `open` API and uncontrolled `defaultOpen` API. */\nexport type PopoverRootProps<Payload = unknown> = BasePopoverRoot.Props<Payload>;\n\nexport function PopoverRoot<Payload = unknown>(props: PopoverRootProps<Payload>) {\n return <BasePopover.Root {...props} />;\n}\n\nexport type PopoverTriggerProps = ComponentPropsWithoutRef<typeof BasePopover.Trigger>;\n\nexport const PopoverTrigger = forwardRef<HTMLButtonElement, PopoverTriggerProps>(\n function PopoverTrigger({ className, ...props }, ref) {\n return (\n <BasePopover.Trigger\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().trigger, className)}\n data-jaci-component=\"popover\"\n data-slot=\"popover-trigger\"\n />\n );\n },\n);\n\n/** Preserves Base UI's optional portal container and mount controls. */\nexport function PopoverPortal(props: ComponentPropsWithoutRef<typeof BasePopover.Portal>) {\n return <BasePopover.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type PopoverPositionerProps = ComponentPropsWithoutRef<typeof BasePopover.Positioner>;\n\nexport const PopoverPositioner = forwardRef<HTMLDivElement, PopoverPositionerProps>(\n function PopoverPositioner({ className, ...props }, ref) {\n return (\n <BasePopover.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().positioner, className)}\n data-slot=\"popover-positioner\"\n />\n );\n },\n);\n\nexport type PopoverPopupProps = ComponentPropsWithoutRef<typeof BasePopover.Popup>;\n\nexport const PopoverPopup = forwardRef<HTMLDivElement, PopoverPopupProps>(function PopoverPopup(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().popup, className)}\n data-jaci-component=\"popover\"\n data-slot=\"popover-popup\"\n />\n );\n});\n\nexport type PopoverTitleProps = ComponentPropsWithoutRef<typeof BasePopover.Title>;\n\nexport const PopoverTitle = forwardRef<HTMLHeadingElement, PopoverTitleProps>(function PopoverTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().title, className)}\n data-slot=\"popover-title\"\n />\n );\n});\n\nexport type PopoverDescriptionProps = ComponentPropsWithoutRef<typeof BasePopover.Description>;\n\nexport const PopoverDescription = forwardRef<HTMLParagraphElement, PopoverDescriptionProps>(\n function PopoverDescription({ className, ...props }, ref) {\n return (\n <BasePopover.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().description, className)}\n data-slot=\"popover-description\"\n />\n );\n },\n);\n\nexport type PopoverCloseProps = ComponentPropsWithoutRef<typeof BasePopover.Close>;\n\nexport const PopoverClose = forwardRef<HTMLButtonElement, PopoverCloseProps>(function PopoverClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BasePopover.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Close popover\")}\n ref={ref}\n className={withRecipeClassName(popover().close, className)}\n data-slot=\"popover-close\"\n >\n {children ?? \"×\"}\n </BasePopover.Close>\n );\n});\n\nexport type PopoverArrowProps = ComponentPropsWithoutRef<typeof BasePopover.Arrow>;\n\nexport const PopoverArrow = forwardRef<HTMLDivElement, PopoverArrowProps>(function PopoverArrow(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Arrow\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().arrow, className)}\n data-slot=\"popover-arrow\"\n />\n );\n});\n\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Portal: PopoverPortal,\n Positioner: PopoverPositioner,\n Popup: PopoverPopup,\n Title: PopoverTitle,\n Description: PopoverDescription,\n Close: PopoverClose,\n Arrow: PopoverArrow,\n createHandle: BasePopover.createHandle,\n};\n"],"mappings":";;;;;;;;AAcA,SAAgB,YAA+B,OAAkC;CAC/E,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,uBAAAA,QAAY,MAAb,EAAkB,GAAI,MAAQ,CAAA;AACvC;AAIA,MAAa,kBAAA,GAAA,MAAA,WAAA,CACX,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,uBAAAA,QAAY,SAAb;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,SAAS,SAAS;EAC3D,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;;AAGA,SAAgB,cAAc,OAA4D;CACxF,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACF,uBAAAA,QAAY,QAAb,EAAoB,GAAIG,oBAAAA,oBAAoB,KAAK,EAAI,CAAA;AAC9D;AAIA,MAAa,qBAAA,GAAA,MAAA,WAAA,CACX,SAAS,kBAAkB,EAAE,WAAW,GAAG,SAAS,KAAK;CACvD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACH,uBAAAA,QAAY,YAAb;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,YAAY,SAAS;EAC9D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,gBAAA,GAAA,MAAA,WAAA,CAA6D,SAAS,aACjF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACF,uBAAAA,QAAY,OAAb;EACE,GAAI;EACC;EACL,WAAWC,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,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AED,MAAa,UAAU;CACrB,MAAM;CACN,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,OAAO;CACP,OAAO;CACP,aAAa;CACb,OAAO;CACP,OAAO;CACP,cAAcF,uBAAAA,QAAY;AAC5B"}
1
+ {"version":3,"file":"popover.cjs","names":["BasePopover","forwardRef","withRecipeClassName","popover","useThemePortalProps"],"sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { Popover as BasePopover } from \"@base-ui/react/popover\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { PopoverRoot as BasePopoverRoot } from \"@base-ui/react/popover\";\n\nimport { popover } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\n/** Preserves Base UI's controlled `open` API and uncontrolled `defaultOpen` API. */\nexport type PopoverRootProps<Payload = unknown> = BasePopoverRoot.Props<Payload>;\n\nexport function PopoverRoot<Payload = unknown>(props: PopoverRootProps<Payload>) {\n return <BasePopover.Root {...props} />;\n}\n\nexport type PopoverTriggerProps = ComponentPropsWithoutRef<typeof BasePopover.Trigger>;\n\nexport const PopoverTrigger = forwardRef<HTMLButtonElement, PopoverTriggerProps>(\n function PopoverTrigger({ className, ...props }, ref) {\n return (\n <BasePopover.Trigger\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().trigger, className)}\n data-jaci-component=\"popover\"\n data-slot=\"popover-trigger\"\n />\n );\n },\n);\n\n/** Preserves Base UI's optional portal container and mount controls. */\nexport function PopoverPortal(props: ComponentPropsWithoutRef<typeof BasePopover.Portal>) {\n return <BasePopover.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type PopoverPositionerProps = ComponentPropsWithoutRef<typeof BasePopover.Positioner>;\n\nexport const PopoverPositioner = forwardRef<HTMLDivElement, PopoverPositionerProps>(\n function PopoverPositioner({ className, ...props }, ref) {\n return (\n <BasePopover.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().positioner, className)}\n data-slot=\"popover-positioner\"\n />\n );\n },\n);\n\nexport type PopoverPopupProps = ComponentPropsWithoutRef<typeof BasePopover.Popup>;\n\nexport const PopoverPopup = forwardRef<HTMLDivElement, PopoverPopupProps>(function PopoverPopup(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().popup, className)}\n data-jaci-component=\"popover\"\n data-slot=\"popover-popup\"\n />\n );\n});\n\nexport type PopoverTitleProps = ComponentPropsWithoutRef<typeof BasePopover.Title>;\n\nexport const PopoverTitle = forwardRef<HTMLHeadingElement, PopoverTitleProps>(function PopoverTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().title, className)}\n data-slot=\"popover-title\"\n />\n );\n});\n\nexport type PopoverDescriptionProps = ComponentPropsWithoutRef<typeof BasePopover.Description>;\n\nexport const PopoverDescription = forwardRef<HTMLParagraphElement, PopoverDescriptionProps>(\n function PopoverDescription({ className, ...props }, ref) {\n return (\n <BasePopover.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().description, className)}\n data-slot=\"popover-description\"\n />\n );\n },\n);\n\nexport type PopoverCloseProps = ComponentPropsWithoutRef<typeof BasePopover.Close>;\n\nexport const PopoverClose = forwardRef<HTMLButtonElement, PopoverCloseProps>(function PopoverClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BasePopover.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Close popover\")}\n ref={ref}\n className={withRecipeClassName(popover().close, className)}\n data-slot=\"popover-close\"\n >\n {children ?? \"×\"}\n </BasePopover.Close>\n );\n});\n\nexport type PopoverArrowProps = ComponentPropsWithoutRef<typeof BasePopover.Arrow>;\n\nexport const PopoverArrow = forwardRef<HTMLDivElement, PopoverArrowProps>(function PopoverArrow(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Arrow\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().arrow, className)}\n data-slot=\"popover-arrow\"\n />\n );\n});\n\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Portal: PopoverPortal,\n Positioner: PopoverPositioner,\n Popup: PopoverPopup,\n Title: PopoverTitle,\n Description: PopoverDescription,\n Close: PopoverClose,\n Arrow: PopoverArrow,\n createHandle: BasePopover.createHandle,\n};\n"],"mappings":";;;;;;;;AAcA,SAAgB,YAA+B,OAAkC;CAC/E,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,uBAAAA,QAAY,MAAb,EAAkB,GAAI,MAAQ,CAAA;AACvC;AAIA,MAAa,kBAAA,GAAiBC,MAAAA,WAAAA,CAC5B,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACD,uBAAAA,QAAY,SAAb;EACE,GAAI;EACC;EACL,WAAWE,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,SAAS,SAAS;EAC3D,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;;AAGA,SAAgB,cAAc,OAA4D;CACxF,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACH,uBAAAA,QAAY,QAAb,EAAoB,GAAII,oBAAAA,oBAAoB,KAAK,EAAI,CAAA;AAC9D;AAIA,MAAa,qBAAA,GAAoBH,MAAAA,WAAAA,CAC/B,SAAS,kBAAkB,EAAE,WAAW,GAAG,SAAS,KAAK;CACvD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACD,uBAAAA,QAAY,YAAb;EACE,GAAI;EACC;EACL,WAAWE,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,YAAY,SAAS;EAC9D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,gBAAA,GAAeF,MAAAA,WAAAA,CAA8C,SAAS,aACjF,EAAE,WAA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ACE,iBAAA,GAAA,kBAAA,IAAA,CAACD,uBAAAA,QAAY,OAAb;EACE,GAAI;EACC;EACL,WAAWE,gBAAAA,oBAAoBC,gBAAAA,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,aAAU;CACX,CAAA;AAEL,CAAC;AAED,MAAa,UAAU;CACrB,MAAM;CACN,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,OAAO;CACP,OAAO;CACP,aAAa;CACb,OAAO;CACP,OAAO;CACP,cAAcH,uBAAAA,QAAY;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","names":["PopoverRoot","BasePopover","Popover"],"sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { Popover as BasePopover } from \"@base-ui/react/popover\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { PopoverRoot as BasePopoverRoot } from \"@base-ui/react/popover\";\n\nimport { popover } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\n/** Preserves Base UI's controlled `open` API and uncontrolled `defaultOpen` API. */\nexport type PopoverRootProps<Payload = unknown> = BasePopoverRoot.Props<Payload>;\n\nexport function PopoverRoot<Payload = unknown>(props: PopoverRootProps<Payload>) {\n return <BasePopover.Root {...props} />;\n}\n\nexport type PopoverTriggerProps = ComponentPropsWithoutRef<typeof BasePopover.Trigger>;\n\nexport const PopoverTrigger = forwardRef<HTMLButtonElement, PopoverTriggerProps>(\n function PopoverTrigger({ className, ...props }, ref) {\n return (\n <BasePopover.Trigger\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().trigger, className)}\n data-jaci-component=\"popover\"\n data-slot=\"popover-trigger\"\n />\n );\n },\n);\n\n/** Preserves Base UI's optional portal container and mount controls. */\nexport function PopoverPortal(props: ComponentPropsWithoutRef<typeof BasePopover.Portal>) {\n return <BasePopover.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type PopoverPositionerProps = ComponentPropsWithoutRef<typeof BasePopover.Positioner>;\n\nexport const PopoverPositioner = forwardRef<HTMLDivElement, PopoverPositionerProps>(\n function PopoverPositioner({ className, ...props }, ref) {\n return (\n <BasePopover.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().positioner, className)}\n data-slot=\"popover-positioner\"\n />\n );\n },\n);\n\nexport type PopoverPopupProps = ComponentPropsWithoutRef<typeof BasePopover.Popup>;\n\nexport const PopoverPopup = forwardRef<HTMLDivElement, PopoverPopupProps>(function PopoverPopup(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().popup, className)}\n data-jaci-component=\"popover\"\n data-slot=\"popover-popup\"\n />\n );\n});\n\nexport type PopoverTitleProps = ComponentPropsWithoutRef<typeof BasePopover.Title>;\n\nexport const PopoverTitle = forwardRef<HTMLHeadingElement, PopoverTitleProps>(function PopoverTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().title, className)}\n data-slot=\"popover-title\"\n />\n );\n});\n\nexport type PopoverDescriptionProps = ComponentPropsWithoutRef<typeof BasePopover.Description>;\n\nexport const PopoverDescription = forwardRef<HTMLParagraphElement, PopoverDescriptionProps>(\n function PopoverDescription({ className, ...props }, ref) {\n return (\n <BasePopover.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().description, className)}\n data-slot=\"popover-description\"\n />\n );\n },\n);\n\nexport type PopoverCloseProps = ComponentPropsWithoutRef<typeof BasePopover.Close>;\n\nexport const PopoverClose = forwardRef<HTMLButtonElement, PopoverCloseProps>(function PopoverClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BasePopover.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Close popover\")}\n ref={ref}\n className={withRecipeClassName(popover().close, className)}\n data-slot=\"popover-close\"\n >\n {children ?? \"×\"}\n </BasePopover.Close>\n );\n});\n\nexport type PopoverArrowProps = ComponentPropsWithoutRef<typeof BasePopover.Arrow>;\n\nexport const PopoverArrow = forwardRef<HTMLDivElement, PopoverArrowProps>(function PopoverArrow(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Arrow\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().arrow, className)}\n data-slot=\"popover-arrow\"\n />\n );\n});\n\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Portal: PopoverPortal,\n Positioner: PopoverPositioner,\n Popup: PopoverPopup,\n Title: PopoverTitle,\n Description: PopoverDescription,\n Close: PopoverClose,\n Arrow: PopoverArrow,\n createHandle: BasePopover.createHandle,\n};\n"],"mappings":";;;;;;;;AAcA,SAAgBA,cAA+B,OAAkC;CAC/E,OAAO,oBAACC,QAAY,MAAb,EAAkB,GAAI,MAAQ,CAAA;AACvC;AAIA,MAAa,iBAAiB,WAC5B,SAAS,eAAe,EAAE,WAAW,GAAG,SAAS,KAAK;CACpD,OACE,oBAACA,QAAY,SAAb;EACE,GAAI;EACC;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,SAAS,SAAS;EAC3D,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CACF;;AAGA,SAAgB,cAAc,OAA4D;CACxF,OAAO,oBAACA,QAAY,QAAb,EAAoB,GAAI,oBAAoB,KAAK,EAAI,CAAA;AAC9D;AAIA,MAAa,oBAAoB,WAC/B,SAAS,kBAAkB,EAAE,WAAW,GAAG,SAAS,KAAK;CACvD,OACE,oBAACA,QAAY,YAAb;EACE,GAAI;EACC;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,YAAY,SAAS;EAC9D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,eAAe,WAA8C,SAAS,aACjF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAACA,QAAY,OAAb;EACE,GAAI;EACC;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,uBAAoB;EACpB,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,eAAe,WAAkD,SAAS,aACrF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAACA,QAAY,OAAb;EACE,GAAI;EACC;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,aAAU;CACX,CAAA;AAEL,CAAC;AAID,MAAa,qBAAqB,WAChC,SAAS,mBAAmB,EAAE,WAAW,GAAG,SAAS,KAAK;CACxD,OACE,oBAACA,QAAY,aAAb;EACE,GAAI;EACC;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,aAAa,SAAS;EAC/D,aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,eAAe,WAAiD,SAAS,aACpF,EAAE,cAAc,WAAW,UAAU,WAAW,GAAG,SACnD,KACA;CACA,MAAM,kBAAkB,YAAY;CAEpC,OACE,oBAACA,QAAY,OAAb;EACE,GAAI;EACJ,cAAY,cAAc,kBAAkB,KAAA,IAAY;EACnD;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,aAAU;YAET,YAAY;CACI,CAAA;AAEvB,CAAC;AAID,MAAa,eAAe,WAA8C,SAAS,aACjF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAACA,QAAY,OAAb;EACE,GAAI;EACC;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,aAAU;CACX,CAAA;AAEL,CAAC;AAED,MAAaC,YAAU;CACrB,MAAMF;CACN,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,OAAO;CACP,OAAO;CACP,aAAa;CACb,OAAO;CACP,OAAO;CACP,cAAcC,QAAY;AAC5B"}
1
+ {"version":3,"file":"popover.js","names":["PopoverRoot","BasePopover","Popover"],"sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport { Popover as BasePopover } from \"@base-ui/react/popover\";\nimport { forwardRef } from \"react\";\nimport type { ComponentPropsWithoutRef } from \"react\";\nimport type { PopoverRoot as BasePopoverRoot } from \"@base-ui/react/popover\";\n\nimport { popover } from \"../../styled-system/recipes\";\nimport { withRecipeClassName } from \"../base-ui\";\nimport { useThemePortalProps } from \"../../theme/theme-scope\";\n\n/** Preserves Base UI's controlled `open` API and uncontrolled `defaultOpen` API. */\nexport type PopoverRootProps<Payload = unknown> = BasePopoverRoot.Props<Payload>;\n\nexport function PopoverRoot<Payload = unknown>(props: PopoverRootProps<Payload>) {\n return <BasePopover.Root {...props} />;\n}\n\nexport type PopoverTriggerProps = ComponentPropsWithoutRef<typeof BasePopover.Trigger>;\n\nexport const PopoverTrigger = forwardRef<HTMLButtonElement, PopoverTriggerProps>(\n function PopoverTrigger({ className, ...props }, ref) {\n return (\n <BasePopover.Trigger\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().trigger, className)}\n data-jaci-component=\"popover\"\n data-slot=\"popover-trigger\"\n />\n );\n },\n);\n\n/** Preserves Base UI's optional portal container and mount controls. */\nexport function PopoverPortal(props: ComponentPropsWithoutRef<typeof BasePopover.Portal>) {\n return <BasePopover.Portal {...useThemePortalProps(props)} />;\n}\n\nexport type PopoverPositionerProps = ComponentPropsWithoutRef<typeof BasePopover.Positioner>;\n\nexport const PopoverPositioner = forwardRef<HTMLDivElement, PopoverPositionerProps>(\n function PopoverPositioner({ className, ...props }, ref) {\n return (\n <BasePopover.Positioner\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().positioner, className)}\n data-slot=\"popover-positioner\"\n />\n );\n },\n);\n\nexport type PopoverPopupProps = ComponentPropsWithoutRef<typeof BasePopover.Popup>;\n\nexport const PopoverPopup = forwardRef<HTMLDivElement, PopoverPopupProps>(function PopoverPopup(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Popup\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().popup, className)}\n data-jaci-component=\"popover\"\n data-slot=\"popover-popup\"\n />\n );\n});\n\nexport type PopoverTitleProps = ComponentPropsWithoutRef<typeof BasePopover.Title>;\n\nexport const PopoverTitle = forwardRef<HTMLHeadingElement, PopoverTitleProps>(function PopoverTitle(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Title\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().title, className)}\n data-slot=\"popover-title\"\n />\n );\n});\n\nexport type PopoverDescriptionProps = ComponentPropsWithoutRef<typeof BasePopover.Description>;\n\nexport const PopoverDescription = forwardRef<HTMLParagraphElement, PopoverDescriptionProps>(\n function PopoverDescription({ className, ...props }, ref) {\n return (\n <BasePopover.Description\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().description, className)}\n data-slot=\"popover-description\"\n />\n );\n },\n);\n\nexport type PopoverCloseProps = ComponentPropsWithoutRef<typeof BasePopover.Close>;\n\nexport const PopoverClose = forwardRef<HTMLButtonElement, PopoverCloseProps>(function PopoverClose(\n { \"aria-label\": ariaLabel, children, className, ...props },\n ref,\n) {\n const hasVisibleLabel = children != null;\n\n return (\n <BasePopover.Close\n {...props}\n aria-label={ariaLabel ?? (hasVisibleLabel ? undefined : \"Close popover\")}\n ref={ref}\n className={withRecipeClassName(popover().close, className)}\n data-slot=\"popover-close\"\n >\n {children ?? \"×\"}\n </BasePopover.Close>\n );\n});\n\nexport type PopoverArrowProps = ComponentPropsWithoutRef<typeof BasePopover.Arrow>;\n\nexport const PopoverArrow = forwardRef<HTMLDivElement, PopoverArrowProps>(function PopoverArrow(\n { className, ...props },\n ref,\n) {\n return (\n <BasePopover.Arrow\n {...props}\n ref={ref}\n className={withRecipeClassName(popover().arrow, className)}\n data-slot=\"popover-arrow\"\n />\n );\n});\n\nexport const Popover = {\n Root: PopoverRoot,\n Trigger: PopoverTrigger,\n Portal: PopoverPortal,\n Positioner: PopoverPositioner,\n Popup: PopoverPopup,\n Title: PopoverTitle,\n Description: PopoverDescription,\n Close: PopoverClose,\n Arrow: PopoverArrow,\n createHandle: Bas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aAAU;CACX,CAAA;AAEL,CACF;AAIA,MAAa,eAAe,WAAiD,SAAS,aACpF,EAAE,cAAc,WAAW,UAAU,WAAW,GAAG,SACnD,KACA;CACA,MAAM,kBAAkB,YAAY;CAEpC,OACE,oBAACA,QAAY,OAAb;EACE,GAAI;EACJ,cAAY,cAAc,kBAAkB,KAAA,IAAY;EACnD;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,aAAU;EAET,UAAA,YAAY;CACI,CAAA;AAEvB,CAAC;AAID,MAAa,eAAe,WAA8C,SAAS,aACjF,EAAE,WAAW,GAAG,SAChB,KACA;CACA,OACE,oBAACA,QAAY,OAAb;EACE,GAAI;EACC;EACL,WAAW,oBAAoB,QAAQ,CAAC,CAAC,OAAO,SAAS;EACzD,aAAU;CACX,CAAA;AAEL,CAAC;AAED,MAAaC,YAAU;CACrB,MAAMF;CACN,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,OAAO;CACP,OAAO;CACP,aAAa;CACb,OAAO;CACP,OAAO;CACP,cAAcC,QAAY;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"progress.cjs","names":["progress","cx"],"sources":["../../../src/components/progress/progress.tsx"],"sourcesContent":["import { forwardRef, useId } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { progress } from \"../../styled-system/recipes\";\n\nfunction clamp(value: number, maximum: number) {\n if (!Number.isFinite(value)) {\n return 0;\n }\n\n return Math.min(Math.max(value, 0), maximum);\n}\n\nexport interface ProgressProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** The current amount. Omit it, or set `indeterminate`, when it is unknown. */\n value?: number | null;\n /** The value that represents completion. Defaults to 100. */\n max?: number;\n /** Omits `aria-valuenow` and renders an in-progress visual state. */\n indeterminate?: boolean;\n /** A visible, automatically associated accessible label. */\n label?: ReactNode;\n valueLabel?: ReactNode;\n locale?: Intl.LocalesArgument;\n format?: Intl.NumberFormatOptions;\n getAriaValueText?: (formattedValue: string, value: number) => string;\n}\n\n/**\n * A semantic progress bar. Provide `label` or `aria-label` so its purpose is\n * announced to assistive technology.\n */\nexport const Progress = forwardRef<HTMLDivElement, ProgressProps>(function Progress(\n {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n className,\n format,\n getAriaValueText,\n indeterminate = false,\n label,\n locale,\n max = 100,\n value = 0,\n valueLabel,\n ...props\n },\n ref,\n) {\n const labelId = useId();\n const maximum = Number.isFinite(max) && max > 0 ? max : 100;\n const currentValue = clamp(value ?? 0, maximum);\n const percentage = (currentValue / maximum) * 100;\n const formattedValue = new Intl.NumberFormat(locale, format).format(currentValue);\n const computedValueText = getAriaValueText?.(formattedValue, currentValue);\n const hasVisibleLabel = label !== null && label !== undefined;\n const labelledBy = ariaLabelledBy ?? (ariaLabel || !hasVisibleLabel ? undefined : labelId);\n const accessibleLabel = ariaLabel ?? (labelledBy ? undefined : \"Progress\");\n const styles = progress({ indeterminate });\n\n return (\n <div\n {...props}\n ref={ref}\n aria-busy={indeterminate || undefined}\n aria-label={accessibleLabel}\n aria-labelledby={labelledBy}\n aria-valuemax={maximum}\n aria-valuemin={0}\n aria-valuenow={indeterminate ? undefined : currentValue}\n aria-valuetext={ariaValueText ?? computedValueText}\n className={cx(styles.root, className)}\n data-indeterminate={indeterminate || undefined}\n data-jaci-component=\"progress\"\n data-slot=\"progress\"\n role=\"progressbar\"\n >\n {hasVisibleLabel || valueLabel !== undefined ? (\n <div style={{ display: \"flex\", minWidth: 0 }}>\n {hasVisibleLabel ? (\n <span className={styles.label} data-slot=\"progress-label\" id={labelId}>\n {label}\n </span>\n ) : null}\n {valueLabel !== undefined ? (\n <span className={styles.value} data-slot=\"progress-value\">\n {valueLabel}\n </span>\n ) : null}\n </div>\n ) : null}\n <div aria-hidden=\"true\" className={styles.track} data-slot=\"progress-track\">\n <div\n className={styles.indicator}\n data-indeterminate={indeterminate || undefined}\n data-slot=\"progress-indicator\"\n style={indeterminate ? undefined : { width: `${percentage}%` }}\n />\n </div>\n </div>\n );\n});\n"],"mappings":";;;;;AAMA,SAAS,MAAM,OAAe,SAAiB;CAC7C,IAAI,CAAC,OAAO,SAAS,KAAK,GACxB,OAAO;CAGT,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,OAAO;AAC7C;;;;;AAqBA,MAAa,YAAA,GAAA,MAAA,WAAA,CAAqD,SAAS,SACzE,EACE,cAAc,WACd,mBAAmB,gBACnB,kBAAkB,eAClB,WACA,QACA,kBACA,gBAAgB,OAChB,OACA,QACA,MAAM,KACN,QAAQ,GACR,YACA,GAAG,SAEL,KACA;CACA,MAAM,WAAA,GAAA,MAAA,MAAA,CAAgB;CACtB,MAAM,UAAU,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;CACxD,MAAM,eAAe,MAAM,SAAS,GAAG,OAAO;CAC9C,MAAM,aAAc,eAAe,UAAW;CAC9C,MAAM,iBAAiB,IAAI,KAAK,aAAa,QAAQ,MAAM,CAAC,CAAC,OAAO,YAAY;CAChF,MAAM,oBAAoB,mBAAmB,gBAAgB,YAAY;CACzE,MAAM,kBAAkB,UAAU,QAAQ,UAAU,KAAA;CACpD,MAAM,aAAa,mBAAmB,aAAa,CAAC,kBAAkB,KAAA,IAAY;CAClF,MAAM,kBAAkB,cAAc,aAAa,KAAA,IAAY;CAC/D,MAAM,SAASA,iBAAAA,SAAS,EAAE,cAAc,CAAC;CAEzC,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,aAAW,iBAAiB,KAAA;EAC5B,cAAY;EACZ,mBAAiB;EACjB,iBAAe;EACf,iBAAe;EACf,iBAAe,gBAAgB,KAAA,IAAY;EAC3C,kBAAgB,iBAAiB;EACjC,WAAWC,WAAAA,GAAG,OAAO,MAAM,SAAS;EACpC,sBAAoB,iBAAiB,KAAA;EACrC,uBAAoB;EACpB,aAAU;EACV,MAAK;YAdP,CAgBG,mBAAmB,eAAe,KAAA,IACjC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;GAAK,OAAO;IAAE,SAAS;IAAQ,UAAU;GAAE;aAA3C,CACG,kBACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;IAAM,WAAW,OAAO;IAAO,aAAU;IAAiB,IAAI;cAC3D;GACG,CAAA,IACJ,MACH,eAAe,KAAA,IACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;IAAM,WAAW,OAAO;IAAO,aAAU;cACtC;GACG,CAAA,IACJ,IACD;OACH,MACJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,eAAY;GAAO,WAAW,OAAO;GAAO,aAAU;aACzD,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IACE,WAAW,OAAO;IAClB,sBAAoB,iBAAiB,KAAA;IACrC,aAAU;IACV,OAAO,gBAAgB,KAAA,IAAY,EAAE,OAAO,GAAG,WAAW,GAAG;GAC9D,CAAA;EACE,CAAA,CACF;;AAET,CAAC"}
1
+ {"version":3,"file":"progress.cjs","names":["forwardRef","useId","progress","cx"],"sources":["../../../src/components/progress/progress.tsx"],"sourcesContent":["import { forwardRef, useId } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\nimport { cx } from \"../../styled-system/css\";\nimport { progress } from \"../../styled-system/recipes\";\n\nfunction clamp(value: number, maximum: number) {\n if (!Number.isFinite(value)) {\n return 0;\n }\n\n return Math.min(Math.max(value, 0), maximum);\n}\n\nexport interface ProgressProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** The current amount. Omit it, or set `indeterminate`, when it is unknown. */\n value?: number | null;\n /** The value that represents completion. Defaults to 100. */\n max?: number;\n /** Omits `aria-valuenow` and renders an in-progress visual state. */\n indeterminate?: boolean;\n /** A visible, automatically associated accessible label. */\n label?: ReactNode;\n valueLabel?: ReactNode;\n locale?: Intl.LocalesArgument;\n format?: Intl.NumberFormatOptions;\n getAriaValueText?: (formattedValue: string, value: number) => string;\n}\n\n/**\n * A semantic progress bar. Provide `label` or `aria-label` so its purpose is\n * announced to assistive technology.\n */\nexport const Progress = forwardRef<HTMLDivElement, ProgressProps>(function Progress(\n {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-valuetext\": ariaValueText,\n className,\n format,\n getAriaValueText,\n indeterminate = false,\n label,\n locale,\n max = 100,\n value = 0,\n valueLabel,\n ...props\n },\n ref,\n) {\n const labelId = useId();\n const maximum = Number.isFinite(max) && max > 0 ? max : 100;\n const currentValue = clamp(value ?? 0, maximum);\n const percentage = (currentValue / maximum) * 100;\n const formattedValue = new Intl.NumberFormat(locale, format).format(currentValue);\n const computedValueText = getAriaValueText?.(formattedValue, currentValue);\n const hasVisibleLabel = label !== null && label !== undefined;\n const labelledBy = ariaLabelledBy ?? (ariaLabel || !hasVisibleLabel ? undefined : labelId);\n const accessibleLabel = ariaLabel ?? (labelledBy ? undefined : \"Progress\");\n const styles = progress({ indeterminate });\n\n return (\n <div\n {...props}\n ref={ref}\n aria-busy={indeterminate || undefined}\n aria-label={accessibleLabel}\n aria-labelledby={labelledBy}\n aria-valuemax={maximum}\n aria-valuemin={0}\n aria-valuenow={indeterminate ? undefined : currentValue}\n aria-valuetext={ariaValueText ?? computedValueText}\n className={cx(styles.root, className)}\n data-indeterminate={indeterminate || undefined}\n data-jaci-component=\"progress\"\n data-slot=\"progress\"\n role=\"progressbar\"\n >\n {hasVisibleLabel || valueLabel !== undefined ? (\n <div style={{ display: \"flex\", minWidth: 0 }}>\n {hasVisibleLabel ? (\n <span className={styles.label} data-slot=\"progress-label\" id={labelId}>\n {label}\n </span>\n ) : null}\n {valueLabel !== undefined ? (\n <span className={styles.value} data-slot=\"progress-value\">\n {valueLabel}\n </span>\n ) : null}\n </div>\n ) : null}\n <div aria-hidden=\"true\" className={styles.track} data-slot=\"progress-track\">\n <div\n className={styles.indicator}\n data-indeterminate={indeterminate || undefined}\n data-slot=\"progress-indicator\"\n style={indeterminate ? undefined : { width: `${percentage}%` }}\n />\n </div>\n </div>\n );\n});\n"],"mappings":";;;;;AAMA,SAAS,MAAM,OAAe,SAAiB;CAC7C,IAAI,CAAC,OAAO,SAAS,KAAK,GACxB,OAAO;CAGT,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,CAAC,GAAG,OAAO;AAC7C;;;;;AAqBA,MAAa,YAAA,GAAWA,MAAAA,WAAAA,CAA0C,SAAS,SACzE,EACE,cAAc,WACd,mBAAmB,gBACnB,kBAAkB,eAClB,WACA,QACA,kBACA,gBAAgB,OAChB,OACA,QACA,MAAM,KACN,QAAQ,GACR,YACA,GAAG,SAEL,KACA;CACA,MAAM,WAAA,GAAUC,MAAAA,MAAAA,CAAM;CACtB,MAAM,UAAU,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;CACxD,MAAM,eAAe,MAAM,SAAS,GAAG,OAAO;CAC9C,MAAM,aAAc,eAAe,UAAW;CAC9C,MAAM,iBAAiB,IAAI,KAAK,aAAa,QAAQ,MAAM,CAAC,CAAC,OAAO,YAAY;CAChF,MAAM,oBAAoB,mBAAmB,gBAAgB,YAAY;CACzE,MAAM,kBAAkB,UAAU,QAAQ,UAAU,KAAA;CACpD,MAAM,aAAa,mBAAmB,aAAa,CAAC,kBAAkB,KAAA,IAAY;CAClF,MAAM,kBAAkB,cAAc,aAAa,KAAA,IAAY;CAC/D,MAAM,SAASC,iBAAAA,SAAS,EAAE,cAAc,CAAC;CAEzC,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EACE,GAAI;EACC;EACL,aAAW,iBAAiB,KAAA;EAC5B,cAAY;EACZ,mBAAiB;EACjB,iBAAe;EACf,iBAAe;EACf,iBAAe,gBAAgB,KAAA,IAAY;EAC3C,kBAAgB,iBAAiB;EACjC,WAAWC,WAAAA,GAAG,OAAO,MAAM,SAAS;EACpC,sBAAoB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