luan-ui 0.5.2 → 0.6.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 (103) hide show
  1. package/README.md +7 -3
  2. package/dist/components/accordion/accordion.d.ts +14 -15
  3. package/dist/components/accordion/accordion.js +11 -9
  4. package/dist/components/accordion/accordion.js.map +1 -1
  5. package/dist/components/alert/alert.d.ts +19 -18
  6. package/dist/components/alert/alert.js +35 -15
  7. package/dist/components/alert/alert.js.map +1 -1
  8. package/dist/components/alert-dialog/alert-dialog.d.ts +14 -9
  9. package/dist/components/alert-dialog/alert-dialog.js +21 -15
  10. package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
  11. package/dist/components/avatar/avatar-group.d.ts +3 -2
  12. package/dist/components/avatar/avatar-group.js +4 -4
  13. package/dist/components/avatar/avatar-group.js.map +1 -1
  14. package/dist/components/avatar/avatar.d.ts +8 -4
  15. package/dist/components/avatar/avatar.js +10 -8
  16. package/dist/components/avatar/avatar.js.map +1 -1
  17. package/dist/components/badge/badge.d.ts +12 -5
  18. package/dist/components/badge/badge.js +18 -7
  19. package/dist/components/badge/badge.js.map +1 -1
  20. package/dist/components/button/button.d.ts +24 -18
  21. package/dist/components/button/button.js +30 -15
  22. package/dist/components/button/button.js.map +1 -1
  23. package/dist/components/card/card.d.ts +32 -19
  24. package/dist/components/card/card.js +52 -20
  25. package/dist/components/card/card.js.map +1 -1
  26. package/dist/components/checkbox/checkbox.d.ts +6 -7
  27. package/dist/components/checkbox/checkbox.js +6 -8
  28. package/dist/components/checkbox/checkbox.js.map +1 -1
  29. package/dist/components/dialog/dialog.d.ts +16 -9
  30. package/dist/components/dialog/dialog.js +23 -18
  31. package/dist/components/dialog/dialog.js.map +1 -1
  32. package/dist/components/drawer/drawer.d.ts +19 -9
  33. package/dist/components/drawer/drawer.js +31 -25
  34. package/dist/components/drawer/drawer.js.map +1 -1
  35. package/dist/components/dropdown-menu/dropdown-menu.d.ts +30 -21
  36. package/dist/components/dropdown-menu/dropdown-menu.js +35 -30
  37. package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
  38. package/dist/components/form-field/form-field.d.ts +4 -8
  39. package/dist/components/form-field/form-field.js +3 -4
  40. package/dist/components/form-field/form-field.js.map +1 -1
  41. package/dist/components/form-helper/form-helper.d.ts +4 -6
  42. package/dist/components/form-helper/form-helper.js +2 -3
  43. package/dist/components/form-helper/form-helper.js.map +1 -1
  44. package/dist/components/icon/icon.d.ts +9 -15
  45. package/dist/components/icon/icon.js +20 -19
  46. package/dist/components/icon/icon.js.map +1 -1
  47. package/dist/components/input/input.d.ts +4 -4
  48. package/dist/components/input/input.js +2 -4
  49. package/dist/components/input/input.js.map +1 -1
  50. package/dist/components/label/label.d.ts +3 -4
  51. package/dist/components/label/label.js +5 -6
  52. package/dist/components/label/label.js.map +1 -1
  53. package/dist/components/pagination/pagination.d.ts +25 -21
  54. package/dist/components/pagination/pagination.js +30 -19
  55. package/dist/components/pagination/pagination.js.map +1 -1
  56. package/dist/components/popover/popover.d.ts +30 -14
  57. package/dist/components/popover/popover.js +30 -22
  58. package/dist/components/popover/popover.js.map +1 -1
  59. package/dist/components/progress/progress.d.ts +4 -6
  60. package/dist/components/progress/progress.js +4 -6
  61. package/dist/components/progress/progress.js.map +1 -1
  62. package/dist/components/radio-group/radio-group.d.ts +8 -7
  63. package/dist/components/radio-group/radio-group.js +8 -35
  64. package/dist/components/radio-group/radio-group.js.map +1 -1
  65. package/dist/components/select/select.d.ts +26 -15
  66. package/dist/components/select/select.js +28 -50
  67. package/dist/components/select/select.js.map +1 -1
  68. package/dist/components/skeleton/skeleton.d.ts +3 -1
  69. package/dist/components/skeleton/skeleton.js +3 -6
  70. package/dist/components/skeleton/skeleton.js.map +1 -1
  71. package/dist/components/slider/slider.d.ts +7 -14
  72. package/dist/components/slider/slider.js +23 -13
  73. package/dist/components/slider/slider.js.map +1 -1
  74. package/dist/components/switch/switch.d.ts +7 -7
  75. package/dist/components/switch/switch.js +9 -11
  76. package/dist/components/switch/switch.js.map +1 -1
  77. package/dist/components/table/table.d.ts +17 -8
  78. package/dist/components/table/table.js +24 -41
  79. package/dist/components/table/table.js.map +1 -1
  80. package/dist/components/tabs/tabs.d.ts +9 -5
  81. package/dist/components/tabs/tabs.js +10 -8
  82. package/dist/components/tabs/tabs.js.map +1 -1
  83. package/dist/components/text-area/text-area.d.ts +3 -5
  84. package/dist/components/text-area/text-area.js +2 -4
  85. package/dist/components/text-area/text-area.js.map +1 -1
  86. package/dist/components/toast/toast.d.ts +4 -10
  87. package/dist/components/toast/toast.js +4 -7
  88. package/dist/components/toast/toast.js.map +1 -1
  89. package/dist/components/tooltip/tooltip.d.ts +18 -9
  90. package/dist/components/tooltip/tooltip.js +21 -20
  91. package/dist/components/tooltip/tooltip.js.map +1 -1
  92. package/dist/index.d.ts +2 -2
  93. package/dist/index.js +2 -2
  94. package/dist/index.js.map +1 -1
  95. package/dist/styles/index.css +2 -2
  96. package/dist/utilities/merge-refs/merge-refs.d.ts +2 -2
  97. package/dist/utilities/merge-refs/merge-refs.js +1 -1
  98. package/dist/utilities/merge-refs/merge-refs.js.map +1 -1
  99. package/dist/utilities/responsive/responsive.d.ts +14 -10
  100. package/package.json +71 -72
  101. package/dist/components/slot/slot.d.ts +0 -13
  102. package/dist/components/slot/slot.js +0 -70
  103. package/dist/components/slot/slot.js.map +0 -1
@@ -2,7 +2,7 @@ import { jsxs as _jsxs, Fragment as _Fragment, jsx as _jsx } from "react/jsx-run
2
2
  import { FormHelper } from "../form-helper/form-helper";
3
3
  import { Label } from "../label/label";
4
4
  import { getVariants } from "../../utilities/responsive/responsive";
5
- import { Children, forwardRef, isValidElement, } from "react";
5
+ import { Children, isValidElement } from "react";
6
6
  import { FormFieldProvider } from "./form-field-context";
7
7
  const formFieldStyles = getVariants({
8
8
  base: "flex gap-2",
@@ -25,7 +25,7 @@ const formFieldStyles = getVariants({
25
25
  * </FormField>
26
26
  * ```
27
27
  */
28
- export const FormField = forwardRef(({ className, children, orientation = "vertical", disabled, required, error, ...props }, ref) => {
28
+ export function FormField({ className, children, orientation = "vertical", disabled, required, error, ref, ...props }) {
29
29
  const childElements = Children.toArray(children);
30
30
  const label = childElements.find((child) => isValidElement(child) && child.type === Label);
31
31
  const helperText = childElements.find((child) => isValidElement(child) && child.type === FormHelper);
@@ -41,6 +41,5 @@ export const FormField = forwardRef(({ className, children, orientation = "verti
41
41
  required,
42
42
  error,
43
43
  }, children: _jsx("div", { ref: ref, className: formFieldStyles({ orientation, className }), ...props, children: orientation === "horizontal" ? (_jsxs(_Fragment, { children: [input, _jsxs("div", { className: "flex flex-col", children: [label, helperText] })] })) : (_jsxs(_Fragment, { children: [label, input, helperText] })) }) }));
44
- });
45
- FormField.displayName = "FormField";
44
+ }
46
45
  //# sourceMappingURL=form-field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-field.js","sourceRoot":"/","sources":["components/form-field/form-field.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EACN,QAAQ,EAER,UAAU,EACV,cAAc,GACd,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AASzD,MAAM,eAAe,GAAG,WAAW,CAAC;IACnC,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE;QACT,WAAW,EAAE;YACZ,UAAU,EAAE,sBAAsB;YAClC,QAAQ,EAAE,UAAU;SACpB;KACD;CACD,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAClC,CACC,EACC,SAAS,EACT,QAAQ,EACR,WAAW,GAAG,UAAU,EACxB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACR,EACD,GAAG,EACF,EAAE;IACH,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAC/B,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CACxD,CAAC;IACF,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CACpC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAC7D,CAAC;IACF,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAC/B,CAAC,KAAK,EAAE,EAAE,CACT,cAAc,CAAC,KAAK,CAAC;QACrB,KAAK,CAAC,IAAI,KAAK,KAAK;QACpB,KAAK,CAAC,IAAI,KAAK,UAAU,CAC1B,CAAC;IAEF,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CACX,gEAAgE,CAChE,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,CACN,KAAC,iBAAiB,IACjB,KAAK,EAAE;YACN,QAAQ;YACR,QAAQ;YACR,KAAK;SACL,YAED,cACC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,eAAe,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,KAClD,KAAK,YAER,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,CAC/B,8BACE,KAAK,EACN,eAAK,SAAS,EAAC,eAAe,aAC5B,KAAK,EACL,UAAU,IACN,IACJ,CACH,CAAC,CAAC,CAAC,CACH,8BACE,KAAK,EACL,KAAK,EACL,UAAU,IACT,CACH,GACI,GACa,CACpB,CAAC;AACH,CAAC,CACD,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC","sourcesContent":["import { FormHelper } from \"@components/form-helper/form-helper\";\nimport { Label } from \"@components/label/label\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\nimport {\n\tChildren,\n\ttype ComponentPropsWithoutRef,\n\tforwardRef,\n\tisValidElement,\n} from \"react\";\nimport { FormFieldProvider } from \"./form-field-context\";\n\nexport type FormFieldProps = ComponentPropsWithoutRef<\"div\"> & {\n\torientation?: \"horizontal\" | \"vertical\";\n\tdisabled?: boolean;\n\trequired?: boolean;\n\terror?: boolean;\n};\n\nconst formFieldStyles = getVariants({\n\tbase: \"flex gap-2\",\n\tvariants: {\n\t\torientation: {\n\t\t\thorizontal: \"flex-row items-start\",\n\t\t\tvertical: \"flex-col\",\n\t\t},\n\t},\n});\n\n/**\n * A component that displays a form field. Should be used as a parent of a Label, an input element and a FormHelper component.\n *\n * @example\n * ```tsx\n * <FormField>\n * <Label>Email</Label>\n * <Input />\n * <FormHelper>This is a helper text</FormHelper>\n * </FormField>\n * ```\n */\nexport const FormField = forwardRef<HTMLDivElement, FormFieldProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tchildren,\n\t\t\torientation = \"vertical\",\n\t\t\tdisabled,\n\t\t\trequired,\n\t\t\terror,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst childElements = Children.toArray(children);\n\t\tconst label = childElements.find(\n\t\t\t(child) => isValidElement(child) && child.type === Label,\n\t\t);\n\t\tconst helperText = childElements.find(\n\t\t\t(child) => isValidElement(child) && child.type === FormHelper,\n\t\t);\n\t\tconst input = childElements.find(\n\t\t\t(child) =>\n\t\t\t\tisValidElement(child) &&\n\t\t\t\tchild.type !== Label &&\n\t\t\t\tchild.type !== FormHelper,\n\t\t);\n\n\t\tif (!label || !input) {\n\t\t\tconsole.warn(\n\t\t\t\t\"FormField requires both Label and Input components as children\",\n\t\t\t);\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<FormFieldProvider\n\t\t\t\tvalue={{\n\t\t\t\t\tdisabled,\n\t\t\t\t\trequired,\n\t\t\t\t\terror,\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tref={ref}\n\t\t\t\t\tclassName={formFieldStyles({ orientation, className })}\n\t\t\t\t\t{...props}\n\t\t\t\t>\n\t\t\t\t\t{orientation === \"horizontal\" ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{input}\n\t\t\t\t\t\t\t<div className=\"flex flex-col\">\n\t\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t\t{helperText}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t{input}\n\t\t\t\t\t\t\t{helperText}\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t</FormFieldProvider>\n\t\t);\n\t},\n);\n\nFormField.displayName = \"FormField\";\n"]}
1
+ {"version":3,"file":"form-field.js","sourceRoot":"/","sources":["components/form-field/form-field.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAuB,cAAc,EAAY,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAUzD,MAAM,eAAe,GAAG,WAAW,CAAC;IACnC,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE;QACT,WAAW,EAAE;YACZ,UAAU,EAAE,sBAAsB;YAClC,QAAQ,EAAE,UAAU;SACpB;KACD;CACD,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,SAAS,CAAC,EACzB,SAAS,EACT,QAAQ,EACR,WAAW,GAAG,UAAU,EACxB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACQ;IAChB,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAC/B,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CACxD,CAAC;IACF,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CACpC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAC7D,CAAC;IACF,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAC/B,CAAC,KAAK,EAAE,EAAE,CACT,cAAc,CAAC,KAAK,CAAC;QACrB,KAAK,CAAC,IAAI,KAAK,KAAK;QACpB,KAAK,CAAC,IAAI,KAAK,UAAU,CAC1B,CAAC;IAEF,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CACX,gEAAgE,CAChE,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,CACN,KAAC,iBAAiB,IACjB,KAAK,EAAE;YACN,QAAQ;YACR,QAAQ;YACR,KAAK;SACL,YAED,cACC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,eAAe,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,KAClD,KAAK,YAER,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,CAC/B,8BACE,KAAK,EACN,eAAK,SAAS,EAAC,eAAe,aAC5B,KAAK,EACL,UAAU,IACN,IACJ,CACH,CAAC,CAAC,CAAC,CACH,8BACE,KAAK,EACL,KAAK,EACL,UAAU,IACT,CACH,GACI,GACa,CACpB,CAAC;AACH,CAAC","sourcesContent":["import { FormHelper } from \"@components/form-helper/form-helper\";\nimport { Label } from \"@components/label/label\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\nimport { Children, type ComponentProps, isValidElement, type Ref } from \"react\";\nimport { FormFieldProvider } from \"./form-field-context\";\n\nexport type FormFieldProps = ComponentProps<\"div\"> & {\n\torientation?: \"horizontal\" | \"vertical\";\n\tdisabled?: boolean;\n\trequired?: boolean;\n\terror?: boolean;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst formFieldStyles = getVariants({\n\tbase: \"flex gap-2\",\n\tvariants: {\n\t\torientation: {\n\t\t\thorizontal: \"flex-row items-start\",\n\t\t\tvertical: \"flex-col\",\n\t\t},\n\t},\n});\n\n/**\n * A component that displays a form field. Should be used as a parent of a Label, an input element and a FormHelper component.\n *\n * @example\n * ```tsx\n * <FormField>\n * <Label>Email</Label>\n * <Input />\n * <FormHelper>This is a helper text</FormHelper>\n * </FormField>\n * ```\n */\nexport function FormField({\n\tclassName,\n\tchildren,\n\torientation = \"vertical\",\n\tdisabled,\n\trequired,\n\terror,\n\tref,\n\t...props\n}: FormFieldProps) {\n\tconst childElements = Children.toArray(children);\n\tconst label = childElements.find(\n\t\t(child) => isValidElement(child) && child.type === Label,\n\t);\n\tconst helperText = childElements.find(\n\t\t(child) => isValidElement(child) && child.type === FormHelper,\n\t);\n\tconst input = childElements.find(\n\t\t(child) =>\n\t\t\tisValidElement(child) &&\n\t\t\tchild.type !== Label &&\n\t\t\tchild.type !== FormHelper,\n\t);\n\n\tif (!label || !input) {\n\t\tconsole.warn(\n\t\t\t\"FormField requires both Label and Input components as children\",\n\t\t);\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<FormFieldProvider\n\t\t\tvalue={{\n\t\t\t\tdisabled,\n\t\t\t\trequired,\n\t\t\t\terror,\n\t\t\t}}\n\t\t>\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tclassName={formFieldStyles({ orientation, className })}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{orientation === \"horizontal\" ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{input}\n\t\t\t\t\t\t<div className=\"flex flex-col\">\n\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t\t{helperText}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{label}\n\t\t\t\t\t\t{input}\n\t\t\t\t\t\t{helperText}\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</FormFieldProvider>\n\t);\n}\n"]}
@@ -1,7 +1,8 @@
1
- import { type ComponentPropsWithoutRef } from "react";
2
- export type FormHelperProps = ComponentPropsWithoutRef<"div"> & {
1
+ import type { ComponentProps, Ref } from "react";
2
+ export type FormHelperProps = ComponentProps<"div"> & {
3
3
  error?: boolean;
4
4
  disabled?: boolean;
5
+ ref?: Ref<HTMLDivElement>;
5
6
  };
6
7
  /**
7
8
  * A component that displays a helper text for a form field. Should be used as a child of a FormField component and will inherit the form field's error and disabled state.
@@ -15,7 +16,4 @@ export type FormHelperProps = ComponentPropsWithoutRef<"div"> & {
15
16
  * </FormField>
16
17
  * ```
17
18
  */
18
- export declare const FormHelper: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
19
- error?: boolean;
20
- disabled?: boolean;
21
- } & import("react").RefAttributes<HTMLDivElement>>;
19
+ export declare function FormHelper({ className, children, error: initialError, disabled: initialDisabled, ref, ...props }: FormHelperProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useFormContext } from "../form-field/form-field-context";
3
3
  import { getVariants } from "../../utilities/responsive/responsive";
4
- import { forwardRef } from "react";
5
4
  const formHelperStyles = getVariants({
6
5
  base: "text-gray-500 text-sm",
7
6
  variants: {
@@ -32,11 +31,11 @@ const formHelperStyles = getVariants({
32
31
  * </FormField>
33
32
  * ```
34
33
  */
35
- export const FormHelper = forwardRef(({ className, children, error: initialError, disabled: initialDisabled, ...props }, ref) => {
34
+ export function FormHelper({ className, children, error: initialError, disabled: initialDisabled, ref, ...props }) {
36
35
  const { error, disabled } = useFormContext({
37
36
  error: initialError,
38
37
  disabled: initialDisabled,
39
38
  });
40
39
  return (_jsx("div", { ref: ref, className: formHelperStyles({ error, disabled, className }), role: error ? "alert" : "status", ...props, children: children }));
41
- });
40
+ }
42
41
  //# sourceMappingURL=form-helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-helper.js","sourceRoot":"/","sources":["components/form-helper/form-helper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAiC,UAAU,EAAE,MAAM,OAAO,CAAC;AAOlE,MAAM,gBAAgB,GAAG,WAAW,CAAC;IACpC,IAAI,EAAE,uBAAuB;IAC7B,QAAQ,EAAE;QACT,KAAK,EAAE;YACN,IAAI,EAAE,cAAc;SACpB;QACD,QAAQ,EAAE;YACT,IAAI,EAAE,eAAe;SACrB;KACD;IACD,gBAAgB,EAAE;QACjB;YACC,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,eAAe;SAC1B;KACD;CACD,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CACnC,CACC,EACC,SAAS,EACT,QAAQ,EACR,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,eAAe,EACzB,GAAG,KAAK,EACR,EACD,GAAG,EACF,EAAE;IACH,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;QAC1C,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,eAAe;KACzB,CAAC,CAAC;IAEH,OAAO,CACN,cACC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,gBAAgB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAC3D,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,KAC5B,KAAK,YAER,QAAQ,GACJ,CACN,CAAC;AACH,CAAC,CACD,CAAC","sourcesContent":["import { useFormContext } from \"@components/form-field/form-field-context\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\nimport { type ComponentPropsWithoutRef, forwardRef } from \"react\";\n\nexport type FormHelperProps = ComponentPropsWithoutRef<\"div\"> & {\n\terror?: boolean;\n\tdisabled?: boolean;\n};\n\nconst formHelperStyles = getVariants({\n\tbase: \"text-gray-500 text-sm\",\n\tvariants: {\n\t\terror: {\n\t\t\ttrue: \"text-red-600\",\n\t\t},\n\t\tdisabled: {\n\t\t\ttrue: \"text-gray-300\",\n\t\t},\n\t},\n\tcompoundVariants: [\n\t\t{\n\t\t\terror: true,\n\t\t\tdisabled: true,\n\t\t\tclassName: \"text-gray-300\",\n\t\t},\n\t],\n});\n\n/**\n * A component that displays a helper text for a form field. Should be used as a child of a FormField component and will inherit the form field's error and disabled state.\n *\n * @example\n * ```tsx\n * <FormField>\n * <Label>Email</Label>\n * <Input />\n * <FormHelper>This is a helper text</FormHelper>\n * </FormField>\n * ```\n */\nexport const FormHelper = forwardRef<HTMLDivElement, FormHelperProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tchildren,\n\t\t\terror: initialError,\n\t\t\tdisabled: initialDisabled,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst { error, disabled } = useFormContext({\n\t\t\terror: initialError,\n\t\t\tdisabled: initialDisabled,\n\t\t});\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tclassName={formHelperStyles({ error, disabled, className })}\n\t\t\t\trole={error ? \"alert\" : \"status\"}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t},\n);\n"]}
1
+ {"version":3,"file":"form-helper.js","sourceRoot":"/","sources":["components/form-helper/form-helper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAS/D,MAAM,gBAAgB,GAAG,WAAW,CAAC;IACpC,IAAI,EAAE,uBAAuB;IAC7B,QAAQ,EAAE;QACT,KAAK,EAAE;YACN,IAAI,EAAE,cAAc;SACpB;QACD,QAAQ,EAAE;YACT,IAAI,EAAE,eAAe;SACrB;KACD;IACD,gBAAgB,EAAE;QACjB;YACC,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,eAAe;SAC1B;KACD;CACD,CAAC,CAAC;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,EAC1B,SAAS,EACT,QAAQ,EACR,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,eAAe,EACzB,GAAG,EACH,GAAG,KAAK,EACS;IACjB,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;QAC1C,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,eAAe;KACzB,CAAC,CAAC;IAEH,OAAO,CACN,cACC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,gBAAgB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAC3D,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,KAC5B,KAAK,YAER,QAAQ,GACJ,CACN,CAAC;AACH,CAAC","sourcesContent":["import { useFormContext } from \"@components/form-field/form-field-context\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\nimport type { ComponentProps, Ref } from \"react\";\n\nexport type FormHelperProps = ComponentProps<\"div\"> & {\n\terror?: boolean;\n\tdisabled?: boolean;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst formHelperStyles = getVariants({\n\tbase: \"text-gray-500 text-sm\",\n\tvariants: {\n\t\terror: {\n\t\t\ttrue: \"text-red-600\",\n\t\t},\n\t\tdisabled: {\n\t\t\ttrue: \"text-gray-300\",\n\t\t},\n\t},\n\tcompoundVariants: [\n\t\t{\n\t\t\terror: true,\n\t\t\tdisabled: true,\n\t\t\tclassName: \"text-gray-300\",\n\t\t},\n\t],\n});\n\n/**\n * A component that displays a helper text for a form field. Should be used as a child of a FormField component and will inherit the form field's error and disabled state.\n *\n * @example\n * ```tsx\n * <FormField>\n * <Label>Email</Label>\n * <Input />\n * <FormHelper>This is a helper text</FormHelper>\n * </FormField>\n * ```\n */\nexport function FormHelper({\n\tclassName,\n\tchildren,\n\terror: initialError,\n\tdisabled: initialDisabled,\n\tref,\n\t...props\n}: FormHelperProps) {\n\tconst { error, disabled } = useFormContext({\n\t\terror: initialError,\n\t\tdisabled: initialDisabled,\n\t});\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={formHelperStyles({ error, disabled, className })}\n\t\t\trole={error ? \"alert\" : \"status\"}\n\t\t\t{...props}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"]}
@@ -1,6 +1,6 @@
1
+ import { useRender } from "@base-ui/react/use-render";
1
2
  import type { ResponsiveValue } from "../../utilities/responsive/responsive";
2
- export type IconProps = React.SVGProps<SVGSVGElement> & {
3
- asChild?: boolean;
3
+ export type IconProps = useRender.ComponentProps<"svg"> & {
4
4
  size?: ResponsiveValue<"small" | "medium" | "large">;
5
5
  };
6
6
  export declare const SIZES: {
@@ -27,28 +27,22 @@ export declare const SIZES: {
27
27
  };
28
28
  /**
29
29
  * A flexible icon component that serves as a wrapper for SVG icons.
30
- * Must be used with asChild={true} to render the actual icon component.
30
+ * Use the render prop to render the actual icon component.
31
31
  *
32
32
  * @example
33
- * // Correct usage
34
- * <Icon asChild size="medium">
35
- * <HomeIcon />
36
- * </Icon>
33
+ * // Basic usage with render prop
34
+ * <Icon render={<HomeIcon />} size="medium" />
37
35
  *
38
36
  * @example
39
37
  * // With different sizes
40
- * <Icon asChild size="small">
41
- * <UserIcon />
42
- * </Icon>
38
+ * <Icon render={<UserIcon />} size="small" />
43
39
  *
44
40
  * @example
45
41
  * // With custom className
46
- * <Icon asChild className="text-blue-500">
47
- * <SettingsIcon />
48
- * </Icon>
42
+ * <Icon render={<SettingsIcon />} className="text-blue-500" />
49
43
  *
50
- * @param {boolean} [props.asChild] - Should always be true when using this component
44
+ * @param {React.ReactElement | ((props, state) => React.ReactElement)} [props.render] - The icon element or render function
51
45
  * @param {ResponsiveValue<"small" | "medium" | "large">} [props.size="medium"] - The size of the icon
52
46
  * @param {string} [props.className] - Additional CSS classes to apply
53
47
  */
54
- export declare const Icon: import("react").ForwardRefExoticComponent<Omit<IconProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
48
+ export declare function Icon({ className, size, render, ref, ...props }: IconProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
@@ -1,7 +1,6 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Slot } from "../slot/slot";
1
+ import { mergeProps } from "@base-ui/react/merge-props";
2
+ import { useRender } from "@base-ui/react/use-render";
3
3
  import { getVariants } from "../../utilities/responsive/responsive";
4
- import { forwardRef } from "react";
5
4
  export const SIZES = {
6
5
  sm: {
7
6
  small: "sm:h-4 sm:w-4",
@@ -36,32 +35,34 @@ const iconStyles = getVariants({
36
35
  });
37
36
  /**
38
37
  * A flexible icon component that serves as a wrapper for SVG icons.
39
- * Must be used with asChild={true} to render the actual icon component.
38
+ * Use the render prop to render the actual icon component.
40
39
  *
41
40
  * @example
42
- * // Correct usage
43
- * <Icon asChild size="medium">
44
- * <HomeIcon />
45
- * </Icon>
41
+ * // Basic usage with render prop
42
+ * <Icon render={<HomeIcon />} size="medium" />
46
43
  *
47
44
  * @example
48
45
  * // With different sizes
49
- * <Icon asChild size="small">
50
- * <UserIcon />
51
- * </Icon>
46
+ * <Icon render={<UserIcon />} size="small" />
52
47
  *
53
48
  * @example
54
49
  * // With custom className
55
- * <Icon asChild className="text-blue-500">
56
- * <SettingsIcon />
57
- * </Icon>
50
+ * <Icon render={<SettingsIcon />} className="text-blue-500" />
58
51
  *
59
- * @param {boolean} [props.asChild] - Should always be true when using this component
52
+ * @param {React.ReactElement | ((props, state) => React.ReactElement)} [props.render] - The icon element or render function
60
53
  * @param {ResponsiveValue<"small" | "medium" | "large">} [props.size="medium"] - The size of the icon
61
54
  * @param {string} [props.className] - Additional CSS classes to apply
62
55
  */
63
- export const Icon = forwardRef(({ className, size = "medium", asChild, ...props }, ref) => {
64
- const Comp = asChild ? Slot : "svg";
65
- return (_jsx(Comp, { ref: ref, className: iconStyles({ size, className }), ...props }));
66
- });
56
+ export function Icon({ className, size = "medium", render, ref, ...props }) {
57
+ const defaultProps = {
58
+ className: iconStyles({ size, className }),
59
+ };
60
+ const element = useRender({
61
+ defaultTagName: "svg",
62
+ render,
63
+ ref,
64
+ props: mergeProps(defaultProps, props),
65
+ });
66
+ return element;
67
+ }
67
68
  //# sourceMappingURL=icon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icon.js","sourceRoot":"/","sources":["components/icon/icon.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAOnC,MAAM,CAAC,MAAM,KAAK,GAAG;IACpB,EAAE,EAAE;QACH,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,eAAe;KACtB;IACD,EAAE,EAAE;QACH,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,eAAe;KACtB;IACD,EAAE,EAAE;QACH,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,eAAe;KACtB;IACD,EAAE,EAAE;QACH,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,eAAe;KACtB;CACD,CAAC;AAEF,MAAM,UAAU,GAAG,WAAW,CAAC;IAC9B,IAAI,EAAE,2BAA2B;IACjC,QAAQ,EAAE;QACT,IAAI,EAAE;YACL,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,SAAS;SAChB;KACD;CACD,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAC7B,CAAC,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC1D,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACpC,OAAO,CACN,KAAC,IAAI,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,KAAM,KAAK,GAAI,CACzE,CAAC;AACH,CAAC,CACD,CAAC","sourcesContent":["import { Slot } from \"@components/slot/slot\";\nimport type { ResponsiveValue } from \"@utilities/responsive/responsive\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\nimport { forwardRef } from \"react\";\n\nexport type IconProps = React.SVGProps<SVGSVGElement> & {\n\tasChild?: boolean;\n\tsize?: ResponsiveValue<\"small\" | \"medium\" | \"large\">;\n};\n\nexport const SIZES = {\n\tsm: {\n\t\tsmall: \"sm:h-4 sm:w-4\",\n\t\tmedium: \"sm:h-6 sm:w-6\",\n\t\tlarge: \"sm:h-8 sm:w-8\",\n\t},\n\tmd: {\n\t\tsmall: \"md:h-4 md:w-4\",\n\t\tmedium: \"md:h-6 md:w-6\",\n\t\tlarge: \"md:h-8 md:w-8\",\n\t},\n\tlg: {\n\t\tsmall: \"lg:h-4 lg:w-4\",\n\t\tmedium: \"lg:h-6 lg:w-6\",\n\t\tlarge: \"lg:h-8 lg:w-8\",\n\t},\n\txl: {\n\t\tsmall: \"xl:h-4 xl:w-4\",\n\t\tmedium: \"xl:h-6 xl:w-6\",\n\t\tlarge: \"xl:h-8 xl:w-8\",\n\t},\n};\n\nconst iconStyles = getVariants({\n\tbase: \"fill-current text-current\",\n\tvariants: {\n\t\tsize: {\n\t\t\tsmall: \"h-4 w-4\",\n\t\t\tmedium: \"h-6 w-6\",\n\t\t\tlarge: \"h-8 w-8\",\n\t\t},\n\t},\n});\n\n/**\n * A flexible icon component that serves as a wrapper for SVG icons.\n * Must be used with asChild={true} to render the actual icon component.\n *\n * @example\n * // Correct usage\n * <Icon asChild size=\"medium\">\n * <HomeIcon />\n * </Icon>\n *\n * @example\n * // With different sizes\n * <Icon asChild size=\"small\">\n * <UserIcon />\n * </Icon>\n *\n * @example\n * // With custom className\n * <Icon asChild className=\"text-blue-500\">\n * <SettingsIcon />\n * </Icon>\n *\n * @param {boolean} [props.asChild] - Should always be true when using this component\n * @param {ResponsiveValue<\"small\" | \"medium\" | \"large\">} [props.size=\"medium\"] - The size of the icon\n * @param {string} [props.className] - Additional CSS classes to apply\n */\nexport const Icon = forwardRef<SVGSVGElement, IconProps>(\n\t({ className, size = \"medium\", asChild, ...props }, ref) => {\n\t\tconst Comp = asChild ? Slot : \"svg\";\n\t\treturn (\n\t\t\t<Comp ref={ref} className={iconStyles({ size, className })} {...props} />\n\t\t);\n\t},\n);\n"]}
1
+ {"version":3,"file":"icon.js","sourceRoot":"/","sources":["components/icon/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAM/D,MAAM,CAAC,MAAM,KAAK,GAAG;IACpB,EAAE,EAAE;QACH,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,eAAe;KACtB;IACD,EAAE,EAAE;QACH,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,eAAe;KACtB;IACD,EAAE,EAAE;QACH,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,eAAe;KACtB;IACD,EAAE,EAAE;QACH,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,eAAe;QACvB,KAAK,EAAE,eAAe;KACtB;CACD,CAAC;AAEF,MAAM,UAAU,GAAG,WAAW,CAAC;IAC9B,IAAI,EAAE,2BAA2B;IACjC,QAAQ,EAAE;QACT,IAAI,EAAE;YACL,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,SAAS;SAChB;KACD;CACD,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,IAAI,CAAC,EACpB,SAAS,EACT,IAAI,GAAG,QAAQ,EACf,MAAM,EACN,GAAG,EACH,GAAG,KAAK,EACG;IACX,MAAM,YAAY,GAAkC;QACnD,SAAS,EAAE,UAAU,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAC1C,CAAC;IAEF,MAAM,OAAO,GAAG,SAAS,CAAC;QACzB,cAAc,EAAE,KAAK;QACrB,MAAM;QACN,GAAG;QACH,KAAK,EAAE,UAAU,CAAQ,YAAY,EAAE,KAAK,CAAC;KAC7C,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport type { ResponsiveValue } from \"@utilities/responsive/responsive\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\n\nexport type IconProps = useRender.ComponentProps<\"svg\"> & {\n\tsize?: ResponsiveValue<\"small\" | \"medium\" | \"large\">;\n};\n\nexport const SIZES = {\n\tsm: {\n\t\tsmall: \"sm:h-4 sm:w-4\",\n\t\tmedium: \"sm:h-6 sm:w-6\",\n\t\tlarge: \"sm:h-8 sm:w-8\",\n\t},\n\tmd: {\n\t\tsmall: \"md:h-4 md:w-4\",\n\t\tmedium: \"md:h-6 md:w-6\",\n\t\tlarge: \"md:h-8 md:w-8\",\n\t},\n\tlg: {\n\t\tsmall: \"lg:h-4 lg:w-4\",\n\t\tmedium: \"lg:h-6 lg:w-6\",\n\t\tlarge: \"lg:h-8 lg:w-8\",\n\t},\n\txl: {\n\t\tsmall: \"xl:h-4 xl:w-4\",\n\t\tmedium: \"xl:h-6 xl:w-6\",\n\t\tlarge: \"xl:h-8 xl:w-8\",\n\t},\n};\n\nconst iconStyles = getVariants({\n\tbase: \"fill-current text-current\",\n\tvariants: {\n\t\tsize: {\n\t\t\tsmall: \"h-4 w-4\",\n\t\t\tmedium: \"h-6 w-6\",\n\t\t\tlarge: \"h-8 w-8\",\n\t\t},\n\t},\n});\n\n/**\n * A flexible icon component that serves as a wrapper for SVG icons.\n * Use the render prop to render the actual icon component.\n *\n * @example\n * // Basic usage with render prop\n * <Icon render={<HomeIcon />} size=\"medium\" />\n *\n * @example\n * // With different sizes\n * <Icon render={<UserIcon />} size=\"small\" />\n *\n * @example\n * // With custom className\n * <Icon render={<SettingsIcon />} className=\"text-blue-500\" />\n *\n * @param {React.ReactElement | ((props, state) => React.ReactElement)} [props.render] - The icon element or render function\n * @param {ResponsiveValue<\"small\" | \"medium\" | \"large\">} [props.size=\"medium\"] - The size of the icon\n * @param {string} [props.className] - Additional CSS classes to apply\n */\nexport function Icon({\n\tclassName,\n\tsize = \"medium\",\n\trender,\n\tref,\n\t...props\n}: IconProps) {\n\tconst defaultProps: useRender.ElementProps<\"svg\"> = {\n\t\tclassName: iconStyles({ size, className }),\n\t};\n\n\tconst element = useRender({\n\t\tdefaultTagName: \"svg\",\n\t\trender,\n\t\tref,\n\t\tprops: mergeProps<\"svg\">(defaultProps, props),\n\t});\n\n\treturn element;\n}\n"]}
@@ -1,5 +1,7 @@
1
- export type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
1
+ import type { ComponentProps, Ref } from "react";
2
+ export type InputProps = ComponentProps<"input"> & {
2
3
  error?: boolean;
4
+ ref?: Ref<HTMLInputElement>;
3
5
  };
4
6
  /**
5
7
  * A basic input component with styling.
@@ -9,7 +11,5 @@ export type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
9
11
  * <Input placeholder="Enter your email" id="email" />
10
12
  * ```
11
13
  */
12
- declare const Input: import("react").ForwardRefExoticComponent<import("react").InputHTMLAttributes<HTMLInputElement> & {
13
- error?: boolean;
14
- } & import("react").RefAttributes<HTMLInputElement>>;
14
+ declare function Input({ className, disabled: initialDisabled, required: initialRequired, error: initialError, ref, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
15
15
  export { Input };
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useFormContext } from "../form-field/form-field-context";
3
3
  import { getVariants } from "../../utilities/responsive/responsive";
4
- import { forwardRef } from "react";
5
4
  const inputStyles = getVariants({
6
5
  base: "rounded-sm border border-gray-400 px-3 py-2 text-sm placeholder:text-gray-400 focus-visible:outline focus-visible:outline-gray-800",
7
6
  variants: {
@@ -28,14 +27,13 @@ const inputStyles = getVariants({
28
27
  * <Input placeholder="Enter your email" id="email" />
29
28
  * ```
30
29
  */
31
- const Input = forwardRef(({ className, disabled: initialDisabled, required: initialRequired, error: initialError, ...props }, ref) => {
30
+ function Input({ className, disabled: initialDisabled, required: initialRequired, error: initialError, ref, ...props }) {
32
31
  const { disabled, required, error } = useFormContext({
33
32
  disabled: initialDisabled,
34
33
  required: initialRequired,
35
34
  error: initialError,
36
35
  });
37
36
  return (_jsx("input", { className: inputStyles({ disabled, error, className }), disabled: disabled, required: required, "aria-invalid": error, ...props, ref: ref }));
38
- });
39
- Input.displayName = "Input";
37
+ }
40
38
  export { Input };
41
39
  //# sourceMappingURL=input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"input.js","sourceRoot":"/","sources":["components/input/input.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMnC,MAAM,WAAW,GAAG,WAAW,CAAC;IAC/B,IAAI,EAAE,oIAAoI;IAC1I,QAAQ,EAAE;QACT,KAAK,EAAE;YACN,IAAI,EAAE,gBAAgB;SACtB;QACD,QAAQ,EAAE;YACT,IAAI,EAAE,iDAAiD;SACvD;KACD;IACD,gBAAgB,EAAE;QACjB;YACC,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;YACd,SAAS,EACR,iEAAiE;SAClE;KACD;CACD,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,KAAK,GAAG,UAAU,CACvB,CACC,EACC,SAAS,EACT,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,YAAY,EACnB,GAAG,KAAK,EACR,EACD,GAAG,EACF,EAAE;IACH,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC;QACpD,QAAQ,EAAE,eAAe;QACzB,QAAQ,EAAE,eAAe;QACzB,KAAK,EAAE,YAAY;KACnB,CAAC,CAAC;IACH,OAAO,CACN,gBACC,SAAS,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EACtD,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,kBACJ,KAAK,KACf,KAAK,EACT,GAAG,EAAE,GAAG,GACP,CACF,CAAC;AACH,CAAC,CACD,CAAC;AACF,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { useFormContext } from \"@components/form-field/form-field-context\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\nimport { forwardRef } from \"react\";\n\nexport type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {\n\terror?: boolean;\n};\n\nconst inputStyles = getVariants({\n\tbase: \"rounded-sm border border-gray-400 px-3 py-2 text-sm placeholder:text-gray-400 focus-visible:outline focus-visible:outline-gray-800\",\n\tvariants: {\n\t\terror: {\n\t\t\ttrue: \"border-red-600\",\n\t\t},\n\t\tdisabled: {\n\t\t\ttrue: \"disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t},\n\t},\n\tcompoundVariants: [\n\t\t{\n\t\t\terror: true,\n\t\t\tdisabled: true,\n\t\t\tclassName:\n\t\t\t\t\"border-gray-400 disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t},\n\t],\n});\n\n/**\n * A basic input component with styling.\n *\n * @example\n * ```tsx\n * <Input placeholder=\"Enter your email\" id=\"email\" />\n * ```\n */\nconst Input = forwardRef<HTMLInputElement, InputProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tdisabled: initialDisabled,\n\t\t\trequired: initialRequired,\n\t\t\terror: initialError,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst { disabled, required, error } = useFormContext({\n\t\t\tdisabled: initialDisabled,\n\t\t\trequired: initialRequired,\n\t\t\terror: initialError,\n\t\t});\n\t\treturn (\n\t\t\t<input\n\t\t\t\tclassName={inputStyles({ disabled, error, className })}\n\t\t\t\tdisabled={disabled}\n\t\t\t\trequired={required}\n\t\t\t\taria-invalid={error}\n\t\t\t\t{...props}\n\t\t\t\tref={ref}\n\t\t\t/>\n\t\t);\n\t},\n);\nInput.displayName = \"Input\";\n\nexport { Input };\n"]}
1
+ {"version":3,"file":"input.js","sourceRoot":"/","sources":["components/input/input.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAQ/D,MAAM,WAAW,GAAG,WAAW,CAAC;IAC/B,IAAI,EAAE,oIAAoI;IAC1I,QAAQ,EAAE;QACT,KAAK,EAAE;YACN,IAAI,EAAE,gBAAgB;SACtB;QACD,QAAQ,EAAE;YACT,IAAI,EAAE,iDAAiD;SACvD;KACD;IACD,gBAAgB,EAAE;QACjB;YACC,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,IAAI;YACd,SAAS,EACR,iEAAiE;SAClE;KACD;CACD,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,SAAS,KAAK,CAAC,EACd,SAAS,EACT,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,YAAY,EACnB,GAAG,EACH,GAAG,KAAK,EACI;IACZ,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC;QACpD,QAAQ,EAAE,eAAe;QACzB,QAAQ,EAAE,eAAe;QACzB,KAAK,EAAE,YAAY;KACnB,CAAC,CAAC;IACH,OAAO,CACN,gBACC,SAAS,EAAE,WAAW,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EACtD,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,kBACJ,KAAK,KACf,KAAK,EACT,GAAG,EAAE,GAAG,GACP,CACF,CAAC;AACH,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { useFormContext } from \"@components/form-field/form-field-context\";\nimport { getVariants } from \"@utilities/responsive/responsive\";\nimport type { ComponentProps, Ref } from \"react\";\n\nexport type InputProps = ComponentProps<\"input\"> & {\n\terror?: boolean;\n\tref?: Ref<HTMLInputElement>;\n};\n\nconst inputStyles = getVariants({\n\tbase: \"rounded-sm border border-gray-400 px-3 py-2 text-sm placeholder:text-gray-400 focus-visible:outline focus-visible:outline-gray-800\",\n\tvariants: {\n\t\terror: {\n\t\t\ttrue: \"border-red-600\",\n\t\t},\n\t\tdisabled: {\n\t\t\ttrue: \"disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t},\n\t},\n\tcompoundVariants: [\n\t\t{\n\t\t\terror: true,\n\t\t\tdisabled: true,\n\t\t\tclassName:\n\t\t\t\t\"border-gray-400 disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t},\n\t],\n});\n\n/**\n * A basic input component with styling.\n *\n * @example\n * ```tsx\n * <Input placeholder=\"Enter your email\" id=\"email\" />\n * ```\n */\nfunction Input({\n\tclassName,\n\tdisabled: initialDisabled,\n\trequired: initialRequired,\n\terror: initialError,\n\tref,\n\t...props\n}: InputProps) {\n\tconst { disabled, required, error } = useFormContext({\n\t\tdisabled: initialDisabled,\n\t\trequired: initialRequired,\n\t\terror: initialError,\n\t});\n\treturn (\n\t\t<input\n\t\t\tclassName={inputStyles({ disabled, error, className })}\n\t\t\tdisabled={disabled}\n\t\t\trequired={required}\n\t\t\taria-invalid={error}\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t/>\n\t);\n}\n\nexport { Input };\n"]}
@@ -1,4 +1,5 @@
1
- export type LabelProps = React.LabelHTMLAttributes<HTMLLabelElement> & {
1
+ import type { ComponentProps } from "react";
2
+ export type LabelProps = ComponentProps<"label"> & {
2
3
  required?: boolean;
3
4
  };
4
5
  /**
@@ -10,7 +11,5 @@ export type LabelProps = React.LabelHTMLAttributes<HTMLLabelElement> & {
10
11
  * <Input id="email" />
11
12
  * ```
12
13
  */
13
- declare const Label: import("react").ForwardRefExoticComponent<import("react").LabelHTMLAttributes<HTMLLabelElement> & {
14
- required?: boolean;
15
- } & import("react").RefAttributes<HTMLLabelElement>>;
14
+ declare function Label({ className, required: initialRequired, children, ref, ...props }: LabelProps): import("react/jsx-runtime").JSX.Element;
16
15
  export { Label };
@@ -1,8 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useFormContext } from "../form-field/form-field-context";
3
3
  import { cn } from "../../utilities/cn/cn";
4
- import { Label as RadixLabel } from "radix-ui";
5
- import { forwardRef } from "react";
6
4
  /**
7
5
  * A label component that can be used to label form fields.
8
6
  *
@@ -12,12 +10,13 @@ import { forwardRef } from "react";
12
10
  * <Input id="email" />
13
11
  * ```
14
12
  */
15
- const Label = forwardRef(({ className, required: initialRequired, children, ...props }, ref) => {
13
+ function Label({ className, required: initialRequired, children, ref, ...props }) {
16
14
  const { required } = useFormContext({
17
15
  required: initialRequired,
18
16
  });
19
- return (_jsxs(RadixLabel.Root, { className: cn("font-medium text-gray-900 text-md peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className), ...props, ref: ref, children: [children, required && _jsx("span", { children: "*" })] }));
20
- });
21
- Label.displayName = RadixLabel.Root.displayName;
17
+ return (
18
+ // biome-ignore lint/a11y/noLabelWithoutControl: htmlFor is passed via props at runtime
19
+ _jsxs("label", { className: cn("font-medium text-gray-900 text-md peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className), ...props, ref: ref, children: [children, required && _jsx("span", { children: "*" })] }));
20
+ }
22
21
  export { Label };
23
22
  //# sourceMappingURL=label.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"label.js","sourceRoot":"/","sources":["components/label/label.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAMnC;;;;;;;;GAQG;AACH,MAAM,KAAK,GAAG,UAAU,CACvB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACrE,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;QACnC,QAAQ,EAAE,eAAe;KACzB,CAAC,CAAC;IACH,OAAO,CACN,MAAC,UAAU,CAAC,IAAI,IACf,SAAS,EAAE,EAAE,CACZ,6FAA6F,EAC7F,SAAS,CACT,KACG,KAAK,EACT,GAAG,EAAE,GAAG,aAEP,QAAQ,EACR,QAAQ,IAAI,+BAAc,IACV,CAClB,CAAC;AACH,CAAC,CACD,CAAC;AAEF,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { useFormContext } from \"@components/form-field/form-field-context\";\nimport { cn } from \"@utilities/cn/cn\";\nimport { Label as RadixLabel } from \"radix-ui\";\nimport { forwardRef } from \"react\";\n\nexport type LabelProps = React.LabelHTMLAttributes<HTMLLabelElement> & {\n\trequired?: boolean;\n};\n\n/**\n * A label component that can be used to label form fields.\n *\n * @example\n * ```tsx\n * <Label htmlFor=\"email\">Email</Label>\n * <Input id=\"email\" />\n * ```\n */\nconst Label = forwardRef<HTMLLabelElement, LabelProps>(\n\t({ className, required: initialRequired, children, ...props }, ref) => {\n\t\tconst { required } = useFormContext({\n\t\t\trequired: initialRequired,\n\t\t});\n\t\treturn (\n\t\t\t<RadixLabel.Root\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"font-medium text-gray-900 text-md peer-disabled:cursor-not-allowed peer-disabled:opacity-50\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\t{...props}\n\t\t\t\tref={ref}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t\t{required && <span>*</span>}\n\t\t\t</RadixLabel.Root>\n\t\t);\n\t},\n);\n\nLabel.displayName = RadixLabel.Root.displayName;\n\nexport { Label };\n"]}
1
+ {"version":3,"file":"label.js","sourceRoot":"/","sources":["components/label/label.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAOtC;;;;;;;;GAQG;AACH,SAAS,KAAK,CAAC,EACd,SAAS,EACT,QAAQ,EAAE,eAAe,EACzB,QAAQ,EACR,GAAG,EACH,GAAG,KAAK,EACI;IACZ,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,CAAC;QACnC,QAAQ,EAAE,eAAe;KACzB,CAAC,CAAC;IACH,OAAO;IACN,uFAAuF;IACvF,iBACC,SAAS,EAAE,EAAE,CACZ,6FAA6F,EAC7F,SAAS,CACT,KACG,KAAK,EACT,GAAG,EAAE,GAAG,aAEP,QAAQ,EACR,QAAQ,IAAI,+BAAc,IACpB,CACR,CAAC;AACH,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,CAAC","sourcesContent":["import { useFormContext } from \"@components/form-field/form-field-context\";\nimport { cn } from \"@utilities/cn/cn\";\nimport type { ComponentProps } from \"react\";\n\nexport type LabelProps = ComponentProps<\"label\"> & {\n\trequired?: boolean;\n};\n\n/**\n * A label component that can be used to label form fields.\n *\n * @example\n * ```tsx\n * <Label htmlFor=\"email\">Email</Label>\n * <Input id=\"email\" />\n * ```\n */\nfunction Label({\n\tclassName,\n\trequired: initialRequired,\n\tchildren,\n\tref,\n\t...props\n}: LabelProps) {\n\tconst { required } = useFormContext({\n\t\trequired: initialRequired,\n\t});\n\treturn (\n\t\t// biome-ignore lint/a11y/noLabelWithoutControl: htmlFor is passed via props at runtime\n\t\t<label\n\t\t\tclassName={cn(\n\t\t\t\t\"font-medium text-gray-900 text-md peer-disabled:cursor-not-allowed peer-disabled:opacity-50\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t\tref={ref}\n\t\t>\n\t\t\t{children}\n\t\t\t{required && <span>*</span>}\n\t\t</label>\n\t);\n}\n\nexport { Label };\n"]}
@@ -1,20 +1,22 @@
1
+ import { useRender } from "@base-ui/react/use-render";
2
+ import { type PropsWithChildren, type Ref } from "react";
1
3
  /**
2
4
  * Pagination
3
5
  */
4
- export type PaginationProps = {
6
+ export type PaginationProps = useRender.ComponentProps<"nav"> & {
5
7
  children?: React.ReactNode;
6
8
  page: number;
7
9
  totalPages: number;
8
10
  onPageChange: (page: number) => void;
9
- asChild?: boolean;
10
- } & React.HTMLAttributes<HTMLElement>;
11
+ className?: string;
12
+ };
11
13
  /**
12
14
  * Pagination component that provides navigation controls for a set of pages.
13
15
  *
14
16
  * @param {number} props.page - The current active page number
15
17
  * @param {number} props.totalPages - The total number of pages
16
18
  * @param {(page: number) => void} props.onPageChange - Callback function called when page changes
17
- * @param {boolean} [props.asChild] - Whether to render the root element as a child component
19
+ * @param {React.ReactElement | ((props, state) => React.ReactElement)} [props.render] - Custom element to render instead of nav
18
20
  * @param {React.ReactNode} [props.children] - The content to render within the pagination component
19
21
  * @param {string} [props.className] - Additional CSS classes to apply
20
22
  *
@@ -27,20 +29,23 @@ export type PaginationProps = {
27
29
  * <PaginationNext>Next</PaginationNext>
28
30
  * </Pagination>
29
31
  * ```
32
+ *
33
+ * @example
34
+ * // With render prop to change the element
35
+ * ```tsx
36
+ * <Pagination render={<div />} page={1} totalPages={10} onPageChange={handleChange}>
37
+ * ...
38
+ * </Pagination>
39
+ * ```
30
40
  */
31
- declare const Pagination: import("react").ForwardRefExoticComponent<{
32
- children?: React.ReactNode;
33
- page: number;
34
- totalPages: number;
35
- onPageChange: (page: number) => void;
36
- asChild?: boolean;
37
- } & import("react").HTMLAttributes<HTMLElement> & import("react").RefAttributes<HTMLElement>>;
41
+ declare function Pagination({ children, page: initialPage, totalPages: initialTotalPages, onPageChange, className, render, ...props }: PaginationProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
38
42
  /**
39
43
  * Pagination Item
40
44
  */
41
45
  export type PaginationItemProps = {
42
46
  children?: React.ReactNode;
43
47
  index?: number;
48
+ ref?: Ref<HTMLButtonElement>;
44
49
  } & React.HTMLAttributes<HTMLButtonElement>;
45
50
  /**
46
51
  * Individual page item within the Pagination component.
@@ -49,13 +54,13 @@ export type PaginationItemProps = {
49
54
  * ```tsx
50
55
  * <PaginationItem index={1}>1</PaginationItem>
51
56
  */
52
- declare const PaginationItem: import("react").ForwardRefExoticComponent<{
53
- children?: React.ReactNode;
54
- index?: number;
55
- } & import("react").HTMLAttributes<HTMLButtonElement> & import("react").RefAttributes<HTMLButtonElement>>;
57
+ declare function PaginationItem({ index, children, className, ref, ...props }: PaginationItemProps): import("react/jsx-runtime").JSX.Element;
56
58
  /**
57
59
  * Pagination Prev
58
60
  */
61
+ export type PaginationPrevProps = PropsWithChildren<React.HTMLAttributes<HTMLButtonElement>> & {
62
+ ref?: Ref<HTMLButtonElement>;
63
+ };
59
64
  /**
60
65
  * Previous page button component for the Pagination.
61
66
  * Automatically disabled when on the first page.
@@ -65,12 +70,13 @@ declare const PaginationItem: import("react").ForwardRefExoticComponent<{
65
70
  * <PaginationPrev>Previous</PaginationPrev>
66
71
  * ```
67
72
  */
68
- declare const PaginationPrev: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLButtonElement> & {
69
- children?: import("react").ReactNode | undefined;
70
- } & import("react").RefAttributes<HTMLButtonElement>>;
73
+ declare function PaginationPrev({ children, className, ref, ...props }: PaginationPrevProps): import("react/jsx-runtime").JSX.Element;
71
74
  /**
72
75
  * Pagination Next
73
76
  */
77
+ export type PaginationNextProps = PropsWithChildren<React.HTMLAttributes<HTMLButtonElement>> & {
78
+ ref?: Ref<HTMLButtonElement>;
79
+ };
74
80
  /**
75
81
  * Next page button component for the Pagination.
76
82
  * Automatically disabled when on the last page.
@@ -80,7 +86,5 @@ declare const PaginationPrev: import("react").ForwardRefExoticComponent<import("
80
86
  * <PaginationNext>Next</PaginationNext>
81
87
  * ```
82
88
  */
83
- declare const PaginationNext: import("react").ForwardRefExoticComponent<import("react").HTMLAttributes<HTMLButtonElement> & {
84
- children?: import("react").ReactNode | undefined;
85
- } & import("react").RefAttributes<HTMLButtonElement>>;
89
+ declare function PaginationNext({ children, className, ref, ...props }: PaginationNextProps): import("react/jsx-runtime").JSX.Element;
86
90
  export { Pagination, PaginationItem, PaginationPrev, PaginationNext };
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Slot } from "../slot/slot";
2
+ import { mergeProps } from "@base-ui/react/merge-props";
3
+ import { useRender } from "@base-ui/react/use-render";
3
4
  import { cn } from "../../utilities/cn/cn";
4
5
  import { mergeRefs } from "../../utilities/merge-refs/merge-refs";
5
6
  import { getTruncatedElements } from "../../utilities/pagination/get-truncated-elements";
6
7
  import { handleKeyboardNavigation } from "../../utilities/pagination/keyboard-navigation";
7
8
  import clsx from "clsx";
8
- import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
9
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
9
10
  const PaginationContext = createContext(undefined);
10
11
  const usePaginationContext = () => {
11
12
  const context = useContext(PaginationContext);
@@ -20,7 +21,7 @@ const usePaginationContext = () => {
20
21
  * @param {number} props.page - The current active page number
21
22
  * @param {number} props.totalPages - The total number of pages
22
23
  * @param {(page: number) => void} props.onPageChange - Callback function called when page changes
23
- * @param {boolean} [props.asChild] - Whether to render the root element as a child component
24
+ * @param {React.ReactElement | ((props, state) => React.ReactElement)} [props.render] - Custom element to render instead of nav
24
25
  * @param {React.ReactNode} [props.children] - The content to render within the pagination component
25
26
  * @param {string} [props.className] - Additional CSS classes to apply
26
27
  *
@@ -33,8 +34,16 @@ const usePaginationContext = () => {
33
34
  * <PaginationNext>Next</PaginationNext>
34
35
  * </Pagination>
35
36
  * ```
37
+ *
38
+ * @example
39
+ * // With render prop to change the element
40
+ * ```tsx
41
+ * <Pagination render={<div />} page={1} totalPages={10} onPageChange={handleChange}>
42
+ * ...
43
+ * </Pagination>
44
+ * ```
36
45
  */
37
- const Pagination = forwardRef(({ children, page: initialPage, totalPages: initialTotalPages, onPageChange, className, asChild, ...props }, ref) => {
46
+ function Pagination({ children, page: initialPage, totalPages: initialTotalPages, onPageChange, className, render, ...props }) {
38
47
  const [page, setPage] = useState(initialPage);
39
48
  const [totalPages, setTotalPages] = useState(initialTotalPages);
40
49
  const [hasNextPage, setHasNextPage] = useState(page < totalPages);
@@ -76,9 +85,17 @@ const Pagination = forwardRef(({ children, page: initialPage, totalPages: initia
76
85
  hasPreviousPage,
77
86
  registerRef: registerRefWrapper,
78
87
  }), [page, totalPages, hasNextPage, hasPreviousPage, registerRefWrapper]);
79
- const Component = asChild ? Slot : "nav";
80
- return (_jsx(Component, { "aria-label": "Pagination", className: clsx("flex items-center gap-1", className), ...props, ref: ref, children: _jsx(PaginationContext.Provider, { value: memoContextValue, children: getTruncatedElements({ page, children }) }) }));
81
- });
88
+ const defaultProps = {
89
+ "aria-label": "Pagination",
90
+ className: clsx("flex items-center gap-1", className),
91
+ children: (_jsx(PaginationContext.Provider, { value: memoContextValue, children: getTruncatedElements({ page, children }) })),
92
+ };
93
+ return useRender({
94
+ defaultTagName: "nav",
95
+ render,
96
+ props: mergeProps(defaultProps, props),
97
+ });
98
+ }
82
99
  /**
83
100
  * Individual page item within the Pagination component.
84
101
  *
@@ -86,7 +103,7 @@ const Pagination = forwardRef(({ children, page: initialPage, totalPages: initia
86
103
  * ```tsx
87
104
  * <PaginationItem index={1}>1</PaginationItem>
88
105
  */
89
- const PaginationItem = forwardRef(({ index, children, className, ...props }, ref) => {
106
+ function PaginationItem({ index, children, className, ref, ...props }) {
90
107
  const { registerRef, page, setPage } = usePaginationContext();
91
108
  const isActive = page === index;
92
109
  const handleClick = () => {
@@ -97,10 +114,7 @@ const PaginationItem = forwardRef(({ index, children, className, ...props }, ref
97
114
  return (_jsx("button", { type: "button", onClick: handleClick, ref: mergeRefs(ref, (el) => registerRef(index ?? 0, el)), className: cn("flex h-10 w-10 items-center justify-center rounded-full hover:bg-gray-200", {
98
115
  "bg-gray-700 text-white hover:bg-gray-800": isActive,
99
116
  }, className), "aria-current": isActive ? "page" : undefined, ...props, children: children ?? index }));
100
- });
101
- /**
102
- * Pagination Prev
103
- */
117
+ }
104
118
  /**
105
119
  * Previous page button component for the Pagination.
106
120
  * Automatically disabled when on the first page.
@@ -110,13 +124,10 @@ const PaginationItem = forwardRef(({ index, children, className, ...props }, ref
110
124
  * <PaginationPrev>Previous</PaginationPrev>
111
125
  * ```
112
126
  */
113
- const PaginationPrev = forwardRef(({ children, className, ...props }, ref) => {
127
+ function PaginationPrev({ children, className, ref, ...props }) {
114
128
  const { registerRef, page, setPage, hasPreviousPage } = usePaginationContext();
115
129
  return (_jsx("button", { type: "button", onClick: () => setPage(page - 1), ref: mergeRefs(ref, (el) => registerRef(0, el)), disabled: !hasPreviousPage, className: cn("flex h-10 w-10 items-center justify-center rounded-full hover:bg-gray-200 disabled:opacity-25", className), ...props, children: children }));
116
- });
117
- /**
118
- * Pagination Next
119
- */
130
+ }
120
131
  /**
121
132
  * Next page button component for the Pagination.
122
133
  * Automatically disabled when on the last page.
@@ -126,9 +137,9 @@ const PaginationPrev = forwardRef(({ children, className, ...props }, ref) => {
126
137
  * <PaginationNext>Next</PaginationNext>
127
138
  * ```
128
139
  */
129
- const PaginationNext = forwardRef(({ children, className, ...props }, ref) => {
140
+ function PaginationNext({ children, className, ref, ...props }) {
130
141
  const { page, setPage, hasNextPage, registerRef, totalPages } = usePaginationContext();
131
142
  return (_jsx("button", { type: "button", className: cn("flex h-10 w-10 items-center justify-center rounded-full hover:bg-gray-200 disabled:opacity-25", className), onClick: () => setPage(page + 1), disabled: !hasNextPage, ref: mergeRefs(ref, (el) => registerRef(totalPages + 1, el)), ...props, children: children }));
132
- });
143
+ }
133
144
  export { Pagination, PaginationItem, PaginationPrev, PaginationNext };
134
145
  //# sourceMappingURL=pagination.js.map