@trsys-tech/matrix-library 0.6.1 → 1.0.0-canary.1

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 (156) hide show
  1. package/dist/accordion.es.js +27 -27
  2. package/dist/accordion.es.js.map +1 -1
  3. package/dist/avatar.es.js +28 -14
  4. package/dist/avatar.es.js.map +1 -1
  5. package/dist/badge.es.js +24 -24
  6. package/dist/badge.es.js.map +1 -1
  7. package/dist/breadcrumb.es.js +34 -24
  8. package/dist/breadcrumb.es.js.map +1 -1
  9. package/dist/button.es.js +28 -28
  10. package/dist/button.es.js.map +1 -1
  11. package/dist/calendar.es.js +64 -61
  12. package/dist/calendar.es.js.map +1 -1
  13. package/dist/card.es.js +21 -21
  14. package/dist/card.es.js.map +1 -1
  15. package/dist/checkbox.es.js +15 -15
  16. package/dist/checkbox.es.js.map +1 -1
  17. package/dist/chip.es.js +24 -24
  18. package/dist/chip.es.js.map +1 -1
  19. package/dist/collapsible.es.js +17 -17
  20. package/dist/collapsible.es.js.map +1 -1
  21. package/dist/combobox.es.js +79 -70
  22. package/dist/combobox.es.js.map +1 -1
  23. package/dist/command.es.js +62 -59
  24. package/dist/command.es.js.map +1 -1
  25. package/dist/components/accordion/Accordion.d.ts.map +1 -1
  26. package/dist/components/avatar/Avatar.d.ts.map +1 -1
  27. package/dist/components/badge/Badge.d.ts +2 -2
  28. package/dist/components/breadcrumb/Breadcrumb.d.ts.map +1 -1
  29. package/dist/components/button/Button.d.ts +2 -2
  30. package/dist/components/chip/Chip.d.ts +2 -2
  31. package/dist/components/combobox/Combobox.d.ts.map +1 -1
  32. package/dist/components/command/Command.d.ts.map +1 -1
  33. package/dist/components/confirm/Confirm.d.ts.map +1 -1
  34. package/dist/components/context-menu/ContextMenu.d.ts.map +1 -1
  35. package/dist/components/data-grid/DataGrid.d.ts.map +1 -1
  36. package/dist/components/date-picker/TimePickerContent.d.ts.map +1 -1
  37. package/dist/components/date-picker/calendar.d.ts.map +1 -1
  38. package/dist/components/dialog/Dialog.d.ts.map +1 -1
  39. package/dist/components/drawer/Drawer.d.ts.map +1 -1
  40. package/dist/components/drawer/SwipableDrawer.d.ts.map +1 -1
  41. package/dist/components/form/Form.d.ts.map +1 -1
  42. package/dist/components/icon-botton/IconButton.d.ts +2 -2
  43. package/dist/components/icon-botton/IconButton.d.ts.map +1 -1
  44. package/dist/components/label/Label.d.ts +1 -1
  45. package/dist/components/label/Label.d.ts.map +1 -1
  46. package/dist/components/modal/Modal.d.ts.map +1 -1
  47. package/dist/components/multi-select/MultiSelect.d.ts +2 -2
  48. package/dist/components/progress/Progress.d.ts.map +1 -1
  49. package/dist/components/rating/Rating.d.ts +2 -2
  50. package/dist/components/select/Select.d.ts.map +1 -1
  51. package/dist/components/sheet/Sheet.d.ts +2 -2
  52. package/dist/components/sheet/Sheet.d.ts.map +1 -1
  53. package/dist/components/sidebar/Sidebar.d.ts.map +1 -1
  54. package/dist/components/switch/Switch.d.ts +2 -2
  55. package/dist/components/text-field/TextField.d.ts.map +1 -1
  56. package/dist/components/toast/toast-components.d.ts +4 -4
  57. package/dist/components/toast/toast-components.d.ts.map +1 -1
  58. package/dist/confirm.es.js +18 -8
  59. package/dist/confirm.es.js.map +1 -1
  60. package/dist/contextmenu.es.js +77 -70
  61. package/dist/contextmenu.es.js.map +1 -1
  62. package/dist/datagrid.es.js +101 -97
  63. package/dist/datagrid.es.js.map +1 -1
  64. package/dist/desktopdatepicker.es.js +30 -30
  65. package/dist/desktopdatepicker.es.js.map +1 -1
  66. package/dist/desktopdaterangepicker.es.js +44 -44
  67. package/dist/desktopdaterangepicker.es.js.map +1 -1
  68. package/dist/desktoptimepicker.es.js +24 -24
  69. package/dist/desktoptimepicker.es.js.map +1 -1
  70. package/dist/dialog.es.js +43 -43
  71. package/dist/dialog.es.js.map +1 -1
  72. package/dist/drawer.es.js +27 -27
  73. package/dist/drawer.es.js.map +1 -1
  74. package/dist/duration.es.js +34 -34
  75. package/dist/duration.es.js.map +1 -1
  76. package/dist/form.es.js +20 -20
  77. package/dist/form.es.js.map +1 -1
  78. package/dist/formcheckbox.es.js +13 -13
  79. package/dist/formcheckbox.es.js.map +1 -1
  80. package/dist/formcombobox.es.js +17 -17
  81. package/dist/formcombobox.es.js.map +1 -1
  82. package/dist/formdatepicker.es.js +12 -12
  83. package/dist/formdatepicker.es.js.map +1 -1
  84. package/dist/formdaterangepicker.es.js +16 -16
  85. package/dist/formdaterangepicker.es.js.map +1 -1
  86. package/dist/formduration.es.js +13 -13
  87. package/dist/formduration.es.js.map +1 -1
  88. package/dist/forminput.es.js +10 -10
  89. package/dist/forminput.es.js.map +1 -1
  90. package/dist/formmultiselect.es.js +7 -7
  91. package/dist/formmultiselect.es.js.map +1 -1
  92. package/dist/formrating.es.js +21 -21
  93. package/dist/formrating.es.js.map +1 -1
  94. package/dist/formselect.es.js +28 -28
  95. package/dist/formselect.es.js.map +1 -1
  96. package/dist/formswitch.es.js +14 -14
  97. package/dist/formswitch.es.js.map +1 -1
  98. package/dist/formtextarea.es.js +12 -12
  99. package/dist/formtextarea.es.js.map +1 -1
  100. package/dist/formtimepicker.es.js +12 -12
  101. package/dist/formtimepicker.es.js.map +1 -1
  102. package/dist/iconbutton.es.js +22 -22
  103. package/dist/iconbutton.es.js.map +1 -1
  104. package/dist/label.es.js +6 -6
  105. package/dist/label.es.js.map +1 -1
  106. package/dist/lib/utils.d.ts.map +1 -1
  107. package/dist/mobiledatepicker.es.js +42 -42
  108. package/dist/mobiledatepicker.es.js.map +1 -1
  109. package/dist/mobiledaterangepicker.es.js +50 -50
  110. package/dist/mobiledaterangepicker.es.js.map +1 -1
  111. package/dist/mobiletimepicker.es.js +30 -30
  112. package/dist/mobiletimepicker.es.js.map +1 -1
  113. package/dist/modal.es.js +48 -44
  114. package/dist/modal.es.js.map +1 -1
  115. package/dist/multiselect.es.js +120 -120
  116. package/dist/multiselect.es.js.map +1 -1
  117. package/dist/popover.es.js +16 -16
  118. package/dist/popover.es.js.map +1 -1
  119. package/dist/progress.es.js +29 -21
  120. package/dist/progress.es.js.map +1 -1
  121. package/dist/radiogroup.es.js +16 -16
  122. package/dist/radiogroup.es.js.map +1 -1
  123. package/dist/rating.es.js +76 -76
  124. package/dist/rating.es.js.map +1 -1
  125. package/dist/select.es.js +82 -63
  126. package/dist/select.es.js.map +1 -1
  127. package/dist/separator.es.js +13 -13
  128. package/dist/separator.es.js.map +1 -1
  129. package/dist/sheet.es.js +44 -44
  130. package/dist/sheet.es.js.map +1 -1
  131. package/dist/sidebar.es.js +245 -233
  132. package/dist/sidebar.es.js.map +1 -1
  133. package/dist/skeleton.es.js +6 -6
  134. package/dist/skeleton.es.js.map +1 -1
  135. package/dist/styles.css +1 -1
  136. package/dist/swipabledrawer.es.js +41 -38
  137. package/dist/swipabledrawer.es.js.map +1 -1
  138. package/dist/switch.es.js +16 -16
  139. package/dist/switch.es.js.map +1 -1
  140. package/dist/tabs.es.js +22 -22
  141. package/dist/tabs.es.js.map +1 -1
  142. package/dist/textarea.es.js +12 -12
  143. package/dist/textarea.es.js.map +1 -1
  144. package/dist/textfield.es.js +37 -37
  145. package/dist/textfield.es.js.map +1 -1
  146. package/dist/timepickercontent.es.js +63 -56
  147. package/dist/timepickercontent.es.js.map +1 -1
  148. package/dist/toast-components.es.js +47 -44
  149. package/dist/toast-components.es.js.map +1 -1
  150. package/dist/toast.es.js +24 -24
  151. package/dist/toast.es.js.map +1 -1
  152. package/dist/tooltip.es.js +16 -16
  153. package/dist/tooltip.es.js.map +1 -1
  154. package/dist/utils.es.js +6 -5
  155. package/dist/utils.es.js.map +1 -1
  156. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.es.js","sources":["../src/components/dialog/Dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport type {\n DialogContentProps,\n DialogTriggerProps,\n DialogProps,\n DialogCloseProps,\n DialogTitleProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogDescriptionProps,\n} from \"@radix-ui/react-dialog\";\nimport { XMark } from \"@trsys-tech/matrix-icons\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-sm disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <XMark className=\"h-5 w-5\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"flex flex-col space-y-1.5 text-left\", className)} {...props} />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\", className)} {...props} />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<React.ElementRef<typeof DialogPrimitive.Title>, React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>>(\n ({ className, ...props }, ref) => (\n <DialogPrimitive.Title ref={ref} className={cn(\"text-lg font-semibold leading-none tracking-tight\", className)} {...props} />\n ),\n);\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => <DialogPrimitive.Description ref={ref} className={cn(\"text-sm text-muted-foreground\", className)} {...props} />);\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription };\nexport type {\n DialogContentProps,\n DialogTriggerProps,\n DialogProps,\n DialogCloseProps,\n DialogTitleProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogDescriptionProps,\n};\n"],"names":["Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","React","className","props","ref","jsx","cn","DialogContent","children","jsxs","XMark","DialogHeader","DialogFooter","DialogTitle","DialogDescription"],"mappings":";;;;;AAkBA,MAAMA,IAASC,EAAgB,MAEzBC,IAAgBD,EAAgB,SAEhCE,IAAeF,EAAgB,QAE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GAAGC,EAAA,CAAO;AAE7GS,EAAa,cAAc;AAE3B,MAAMC,IAAcZ,EAAM;AAAA,EACxB,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAASC,MACxB,gBAAAC,EAACT,EAAgB,OAAhB,EAAsB,KAAAQ,GAAU,WAAWE,EAAG,qDAAqDJ,CAAS,GAAI,GAAGC,EAAA,CAAO;AAE/H;AACAU,EAAY,cAAcjB,EAAgB,MAAM;AAEhD,MAAMkB,IAAoBb,EAAM,WAG9B,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAASC,MAAQ,gBAAAC,EAACT,EAAgB,aAAhB,EAA4B,KAAAQ,GAAU,WAAWE,EAAG,iCAAiCJ,CAAS,GAAI,GAAGC,GAAO,CAAE;AACnJW,EAAkB,cAAclB,EAAgB,YAAY;"}
1
+ {"version":3,"file":"dialog.es.js","sources":["../src/components/dialog/Dialog.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport type {\n DialogContentProps,\n DialogTriggerProps,\n DialogProps,\n DialogCloseProps,\n DialogTitleProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogDescriptionProps,\n} from \"@radix-ui/react-dialog\";\nimport { XMark } from \"@trsys-tech/matrix-icons\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"mtx-fixed mtx-inset-0 mtx-z-50 mtx-bg-black/80 data-[state=open]:mtx-animate-in data-[state=closed]:mtx-animate-out data-[state=closed]:mtx-fade-out-0 data-[state=open]:mtx-fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"mtx-fixed mtx-left-[50%] mtx-top-[50%] mtx-z-50 mtx-grid mtx-w-full mtx-max-w-lg mtx-translate-x-[-50%] mtx-translate-y-[-50%] mtx-gap-4 mtx-border mtx-bg-background mtx-p-6 mtx-shadow-lg mtx-duration-200 data-[state=open]:mtx-animate-in data-[state=closed]:mtx-animate-out data-[state=closed]:mtx-fade-out-0 data-[state=open]:mtx-fade-in-0 data-[state=closed]:mtx-zoom-out-95 data-[state=open]:mtx-zoom-in-95 data-[state=closed]:mtx-slide-out-to-left-1/2 data-[state=closed]:mtx-slide-out-to-top-[48%] data-[state=open]:mtx-slide-in-from-left-1/2 data-[state=open]:mtx-slide-in-from-top-[48%] sm:mtx-rounded-lg\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"mtx-absolute mtx-right-4 mtx-top-4 mtx-rounded-sm disabled:mtx-pointer-events-none data-[state=open]:mtx-bg-accent data-[state=open]:mtx-text-muted-foreground\">\n <XMark className=\"mtx-h-5 mtx-w-5\" />\n <span className=\"mtx-sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"mtx-flex mtx-flex-col mtx-space-y-1.5 mtx-text-left\", className)} {...props} />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"mtx-flex mtx-flex-col-reverse sm:mtx-flex-row sm:mtx-justify-end sm:mtx-space-x-2\", className)} {...props} />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<React.ElementRef<typeof DialogPrimitive.Title>, React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>>(\n ({ className, ...props }, ref) => (\n <DialogPrimitive.Title ref={ref} className={cn(\"mtx-text-lg mtx-font-semibold mtx-leading-none mtx-tracking-tight\", className)} {...props} />\n ),\n);\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description ref={ref} className={cn(\"mtx-text-sm mtx-text-muted-foreground\", className)} {...props} />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport { Dialog, DialogPortal, DialogOverlay, DialogTrigger, DialogClose, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription };\nexport type {\n DialogContentProps,\n DialogTriggerProps,\n DialogProps,\n DialogCloseProps,\n DialogTitleProps,\n DialogPortalProps,\n DialogOverlayProps,\n DialogDescriptionProps,\n};\n"],"names":["Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","React","className","props","ref","jsx","cn","DialogContent","children","jsxs","XMark","DialogHeader","DialogFooter","DialogTitle","DialogDescription"],"mappings":";;;;;AAkBA,MAAMA,IAASC,EAAgB,MAEzBC,IAAgBD,EAAgB,SAEhCE,IAAeF,EAAgB,QAE/BG,IAAcH,EAAgB,OAE9BI,IAAgBC,EAAM,WAG1B,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAASC,MAC1B,gBAAAC;AAAA,EAACT,EAAgB;AAAA,EAAhB;AAAA,IACC,KAAAQ;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAJ;AAAA,IAAA;AAAA,IAED,GA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AA,CAAO;AAE/I;AACAU,EAAY,cAAcjB,EAAgB,MAAM;AAEhD,MAAMkB,IAAoBb,EAAM,WAG9B,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAASC,MAC1B,gBAAAC,EAACT,EAAgB,aAAhB,EAA4B,KAAAQ,GAAU,WAAWE,EAAG,yCAAyCJ,CAAS,GAAI,GAAGC,GAAO,CACtH;AACDW,EAAkB,cAAclB,EAAgB,YAAY;"}
package/dist/drawer.es.js CHANGED
@@ -1,49 +1,49 @@
1
- import { jsx as e, Fragment as v, jsxs as b } from "react/jsx-runtime";
2
- import * as h from "react";
3
- import { Slot as g } from "@radix-ui/react-slot";
1
+ import { jsx as r, Fragment as v, jsxs as w } from "react/jsx-runtime";
2
+ import * as p from "react";
3
+ import { Slot as b } from "@radix-ui/react-slot";
4
4
  import { ChevronsRight as C } from "@trsys-tech/matrix-icons";
5
5
  import { createContextScope as D } from "@radix-ui/react-context";
6
- import { cn as i } from "./utils.es.js";
6
+ import { cn as a } from "./utils.es.js";
7
7
  import { Modal as M } from "./modal.es.js";
8
8
  import { IconButton as R } from "./iconbutton.es.js";
9
9
  import { useIsMobile as E } from "./use-mobile.es.js";
10
- const w = "Drawer", [A] = D(w), [_, N] = A(w), j = h.forwardRef((t, r) => {
11
- const { asChild: c, anchor: n = "right", children: o, open: l, width: d = 240, className: s, onClose: a, __scopeDrawer: f, ...m } = t, p = c ? g : "div", u = E();
12
- return /* @__PURE__ */ e(p, { ref: r, className: i("flex", s), ...m, children: /* @__PURE__ */ e(_, { anchor: n, onClose: a, open: l, width: d, isMobile: u, scope: f, children: o }) });
10
+ const u = "Drawer", [A] = D(u), [_, g] = A(u), j = p.forwardRef((o, t) => {
11
+ const { asChild: x, anchor: m = "right", children: e, open: n, width: i = 240, className: l, onClose: s, __scopeDrawer: c, ...d } = o, f = x ? b : "div", h = E();
12
+ return /* @__PURE__ */ r(f, { ref: t, className: a("mtx-flex", l), ...d, children: /* @__PURE__ */ r(_, { anchor: m, onClose: s, open: n, width: i, isMobile: h, scope: c, children: e }) });
13
13
  });
14
- j.displayName = w;
15
- const x = "DrawerMain", k = h.forwardRef(
16
- ({ asChild: t, children: r, className: c, style: n, __scopeDrawer: o, ...l }, d) => {
17
- const s = t ? g : "div", { anchor: a, open: f, width: m, isMobile: p } = N(x, o), u = h.useMemo(() => p ? {} : a === "left" ? { marginInlineStart: f ? m : 0 } : { marginInlineEnd: f ? m : 0 }, [a, f, m, p]);
18
- return /* @__PURE__ */ e(s, { ref: d, className: i("flex-grow overflow-hidden", c), style: { ...n, ...u }, ...l, children: r });
14
+ j.displayName = u;
15
+ const N = "DrawerMain", k = p.forwardRef(
16
+ ({ asChild: o, children: t, className: x, style: m, __scopeDrawer: e, ...n }, i) => {
17
+ const l = o ? b : "div", { anchor: s, open: c, width: d, isMobile: f } = g(N, e), h = p.useMemo(() => f ? {} : s === "left" ? { marginInlineStart: c ? d : 0 } : { marginInlineEnd: c ? d : 0 }, [s, c, d, f]);
18
+ return /* @__PURE__ */ r(l, { ref: i, className: a("mtx-flex-grow mtx-overflow-hidden", x), style: { ...m, ...h }, ...n, children: t });
19
19
  }
20
20
  );
21
- k.displayName = x;
22
- const y = "DrawerContent", I = h.forwardRef(({ children: t, title: r, __scopeDrawer: c }, n) => {
23
- const { anchor: o, open: l, width: d, onClose: s, isMobile: a } = N(y, c);
24
- return /* @__PURE__ */ e(v, { children: a ? /* @__PURE__ */ e(M, { title: r, open: l, onOpenChange: s, ref: n, fullScreen: !0, children: t }) : /* @__PURE__ */ e("div", { className: i("hidden md:block overflow-hidden"), style: { width: d }, ref: n, children: /* @__PURE__ */ b(
21
+ k.displayName = N;
22
+ const y = "DrawerContent", I = p.forwardRef(({ children: o, title: t, __scopeDrawer: x }, m) => {
23
+ const { anchor: e, open: n, width: i, onClose: l, isMobile: s } = g(y, x);
24
+ return /* @__PURE__ */ r(v, { children: s ? /* @__PURE__ */ r(M, { title: t, open: n, onOpenChange: l, ref: m, fullScreen: !0, children: o }) : /* @__PURE__ */ r("div", { className: a("mtx-hidden md:mtx-block mtx-overflow-hidden"), style: { width: i }, ref: m, children: /* @__PURE__ */ w(
25
25
  "div",
26
26
  {
27
- className: i(
28
- "overflow-y-auto flex flex-col h-full top-0 z-[120] bg-background transition-all border-gray-200",
29
- l ? "" : o === "left" ? "-translate-x-full rtl:translate-x-full invisible" : "translate-x-full rtl:-translate-x-full invisible",
30
- o === "left" ? "border-r" : "border-l"
27
+ className: a(
28
+ "mtx-overflow-y-auto mtx-flex mtx-flex-col mtx-h-full mtx-top-0 mtx-z-[120] mtx-bg-background mtx-transition-all mtx-border-gray-200",
29
+ n ? "" : e === "left" ? "-mtx-translate-x-full rtl:mtx-translate-x-full mtx-invisible" : "mtx-translate-x-full rtl:-mtx-translate-x-full mtx-invisible",
30
+ e === "left" ? "mtx-border-r" : "mtx-border-l"
31
31
  ),
32
32
  children: [
33
- /* @__PURE__ */ b(
33
+ /* @__PURE__ */ w(
34
34
  "div",
35
35
  {
36
- className: i(
37
- "h-9 flex items-center gap-2 p-2 bg-background w-full sticky top-0 border-b border-gray-200",
38
- o === "right" ? "justify-start rtl:justify-end" : "justify-end rtl:justify-start"
36
+ className: a(
37
+ "mtx-h-9 mtx-flex mtx-items-center mtx-gap-2 mtx-p-2 mtx-bg-background mtx-w-full mtx-sticky mtx-top-0 mtx-border-b mtx-border-gray-200",
38
+ e === "right" ? "mtx-justify-start rtl:mtx-justify-end" : "mtx-justify-end rtl:mtx-justify-start"
39
39
  ),
40
40
  children: [
41
- /* @__PURE__ */ e(R, { onClick: s, className: "w-5 h-5 p-0", children: /* @__PURE__ */ e(C, { className: i("w-5 h-5", o === "right" ? "rtl:-scale-100" : "-scale-100 rtl:scale-100") }) }),
42
- typeof r == "string" || typeof r == "number" ? /* @__PURE__ */ e("h2", { className: "text-lg font-bold text-text", children: r }) : r
41
+ /* @__PURE__ */ r(R, { onClick: l, className: "mtx-w-5 mtx-h-5 mtx-p-0", children: /* @__PURE__ */ r(C, { className: a("mtx-w-5 mtx-h-5", e === "right" ? "rtl:-mtx-scale-100" : "-mtx-scale-100 rtl:mtx-scale-100") }) }),
42
+ typeof t == "string" || typeof t == "number" ? /* @__PURE__ */ r("h2", { className: "mtx-text-lg mtx-font-bold mtx-text-text", children: t }) : t
43
43
  ]
44
44
  }
45
45
  ),
46
- t
46
+ o
47
47
  ]
48
48
  }
49
49
  ) }) });
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.es.js","sources":["../src/components/drawer/Drawer.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { Slot } from \"@radix-ui/react-slot\";\r\nimport { ChevronsRight } from \"@trsys-tech/matrix-icons\";\r\nimport { createContextScope, Scope } from \"@radix-ui/react-context\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { Modal } from \"../modal/Modal\";\r\nimport { IconButton } from \"../icon-botton/IconButton\";\r\nimport { useIsMobile } from \"../../lib/hooks/use-mobile\";\r\n\r\ntype ScopedProps<P> = P & { __scopeDrawer?: Scope };\r\n\r\nconst DRAWER_NAME = \"Drawer\";\r\n\r\nconst [createDrawerContext] = createContextScope(DRAWER_NAME);\r\n\r\ninterface DrawerProps extends React.HTMLAttributes<HTMLDivElement> {\r\n open: boolean;\r\n onClose?: () => void;\r\n anchor?: \"left\" | \"right\";\r\n width?: number;\r\n children?: React.ReactNode;\r\n asChild?: boolean;\r\n mobileBreakpoint?: number;\r\n}\r\n\r\ntype DrawerContextValue = {\r\n open: boolean;\r\n onClose?: () => void;\r\n anchor: \"left\" | \"right\";\r\n width: number;\r\n isMobile: boolean;\r\n};\r\n\r\nconst [DrawerProvider, useDrawerProvider] = createDrawerContext<DrawerContextValue>(DRAWER_NAME);\r\n\r\n/**\r\n * Drawer component\r\n * This is the wrapper component for Drawer content and main components\r\n * @param {React.HTMLAttributes<HTMLDivElement>} props\r\n * @param {boolean} open - Drawer open state\r\n * @param {() => void} onClose - Drawer close handler\r\n * @param {\"left\" | \"right\"} anchor - Drawer anchor position\r\n * @param {number} width - Drawer width\r\n * @param {React.ReactNode} children - Drawer children\r\n * @param {boolean} asChild - Render as child component\r\n * @returns {React.ReactElement}\r\n */\r\nconst Drawer = React.forwardRef<React.ElementRef<\"div\">, ScopedProps<DrawerProps>>((props, ref) => {\r\n const { asChild, anchor = \"right\", children, open, width = 240, className, onClose, __scopeDrawer, ...restProps } = props;\r\n const Comp = asChild ? Slot : \"div\";\r\n\r\n const isMobile = useIsMobile();\r\n\r\n return (\r\n <Comp ref={ref} className={cn(\"flex\", className)} {...restProps}>\r\n <DrawerProvider anchor={anchor} onClose={onClose} open={open} width={width} isMobile={isMobile} scope={__scopeDrawer}>\r\n {children}\r\n </DrawerProvider>\r\n </Comp>\r\n );\r\n});\r\n\r\nDrawer.displayName = DRAWER_NAME;\r\n\r\ninterface DrawerMainProps extends React.HTMLAttributes<HTMLDivElement> {\r\n asChild: boolean;\r\n}\r\n\r\nconst DRAWER_MAIN_NAME = \"DrawerMain\";\r\n\r\n/**\r\n * DrawerMain component\r\n * This is the main container for the tree that should be shown always\r\n * @param {React.HTMLAttributes<HTMLDivElement>} props\r\n * @param {boolean} asChild - Render as child component\r\n * @property {React.ReactNode} children - DrawerMain children\r\n * @property {string} className - DrawerMain class name\r\n * @property {React.CSSProperties} style - DrawerMain style\r\n * @property {ScopedProps<DrawerMainProps>} __scopeDrawer - DrawerMain scope\r\n * @property {React.Ref<HTMLDivElement>} ref - DrawerMain ref\r\n * @property {React.HTMLAttributes<HTMLDivElement>} props - DrawerMain props\r\n * @returns {React.ReactElement}\r\n */\r\nconst DrawerMain = React.forwardRef<HTMLDivElement, ScopedProps<DrawerMainProps>>(\r\n ({ asChild, children, className, style, __scopeDrawer, ...props }, ref) => {\r\n const Comp = asChild ? Slot : \"div\";\r\n const { anchor, open, width, isMobile } = useDrawerProvider(DRAWER_MAIN_NAME, __scopeDrawer);\r\n\r\n const marginStyle = React.useMemo(() => {\r\n if (isMobile) {\r\n return {};\r\n }\r\n if (anchor === \"left\") {\r\n return { marginInlineStart: open ? width : 0 };\r\n } else {\r\n return { marginInlineEnd: open ? width : 0 };\r\n }\r\n }, [anchor, open, width, isMobile]);\r\n\r\n return (\r\n <Comp ref={ref} className={cn(\"flex-grow overflow-hidden\", className)} style={{ ...style, ...marginStyle }} {...props}>\r\n {children}\r\n </Comp>\r\n );\r\n },\r\n);\r\n\r\nDrawerMain.displayName = DRAWER_MAIN_NAME;\r\n\r\ntype DrawerContentProps = {\r\n children?: React.ReactNode;\r\n title: React.ReactNode;\r\n};\r\n\r\nconst DRAWER_CONTENT_NAME = \"DrawerContent\";\r\n\r\n/**\r\n * DrawerContent component\r\n * This is the content container for the tree that should be shown when the drawer is open\r\n * @param {React.HTMLAttributes<HTMLDivElement>} props\r\n * @param {React.ReactNode} children - DrawerContent children\r\n * @param {React.ReactNode} title - DrawerContent title\r\n * @property {ScopedProps<DrawerContentProps>} __scopeDrawer - DrawerContent scope\r\n * @property {React.Ref<HTMLDivElement>} ref - DrawerContent ref\r\n * @property {React.HTMLAttributes<HTMLDivElement>} props - DrawerContent props\r\n * @returns {React.ReactElement}\r\n */\r\nconst DrawerContent = React.forwardRef<HTMLDivElement, ScopedProps<DrawerContentProps>>(({ children, title, __scopeDrawer }, ref) => {\r\n const { anchor, open, width, onClose, isMobile } = useDrawerProvider(DRAWER_CONTENT_NAME, __scopeDrawer);\r\n\r\n return (\r\n <>\r\n {isMobile ? (\r\n <Modal title={title} open={open} onOpenChange={onClose} ref={ref} fullScreen>\r\n {children}\r\n </Modal>\r\n ) : (\r\n <div className={cn(\"hidden md:block overflow-hidden\")} style={{ width }} ref={ref}>\r\n <div\r\n className={cn(\r\n \"overflow-y-auto flex flex-col h-full top-0 z-[120] bg-background transition-all border-gray-200\",\r\n open ? \"\" : anchor === \"left\" ? \"-translate-x-full rtl:translate-x-full invisible\" : \"translate-x-full rtl:-translate-x-full invisible\",\r\n anchor === \"left\" ? \"border-r\" : \"border-l\",\r\n )}\r\n >\r\n <div\r\n className={cn(\r\n \"h-9 flex items-center gap-2 p-2 bg-background w-full sticky top-0 border-b border-gray-200\",\r\n anchor === \"right\" ? \"justify-start rtl:justify-end\" : \"justify-end rtl:justify-start\",\r\n )}\r\n >\r\n <IconButton onClick={onClose} className=\"w-5 h-5 p-0\">\r\n <ChevronsRight className={cn(\"w-5 h-5\", anchor === \"right\" ? \"rtl:-scale-100\" : \"-scale-100 rtl:scale-100\")} />\r\n </IconButton>\r\n {typeof title === \"string\" || typeof title === \"number\" ? <h2 className=\"text-lg font-bold text-text\">{title}</h2> : title}\r\n </div>\r\n {children}\r\n </div>\r\n </div>\r\n )}\r\n </>\r\n );\r\n});\r\n\r\nDrawerContent.displayName = DRAWER_CONTENT_NAME;\r\n\r\nconst Root = Drawer;\r\nconst Main = DrawerMain;\r\nconst Content = DrawerContent;\r\n\r\nexport { Drawer, DrawerMain, DrawerContent, Root, Main, Content };\r\nexport type { DrawerContentProps, DrawerMainProps, DrawerProps };\r\n"],"names":["DRAWER_NAME","createDrawerContext","createContextScope","DrawerProvider","useDrawerProvider","Drawer","React","props","ref","asChild","anchor","children","open","width","className","onClose","__scopeDrawer","restProps","Comp","Slot","isMobile","useIsMobile","jsx","cn","DRAWER_MAIN_NAME","DrawerMain","style","marginStyle","DRAWER_CONTENT_NAME","DrawerContent","title","Fragment","Modal","jsxs","IconButton","ChevronsRight"],"mappings":";;;;;;;;;AAcA,MAAMA,IAAc,UAEd,CAACC,CAAmB,IAAIC,EAAmBF,CAAW,GAoBtD,CAACG,GAAgBC,CAAiB,IAAIH,EAAwCD,CAAW,GAczFK,IAASC,EAAM,WAA8D,CAACC,GAAOC,MAAQ;AACjG,QAAM,EAAE,SAAAC,GAAS,QAAAC,IAAS,SAAS,UAAAC,GAAU,MAAAC,GAAM,OAAAC,IAAQ,KAAK,WAAAC,GAAW,SAAAC,GAAS,eAAAC,GAAe,GAAGC,MAAcV,GAC9GW,IAAOT,IAAUU,IAAO,OAExBC,IAAWC,EAAA;AAE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GAAY,cAAcG,GAAS,KAAAP,GAAU,YAAU,IACzE,UAAAG,GACH,IAEA,gBAAAW,EAAC,OAAA,EAAI,WAAWC,EAAG,iCAAiC,GAAG,OAAO,EAAE,OAAAV,EAAA,GAAS,KAAAL,GACvE,UAAA,gBAAAyB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWV;AAAA,QACT;AAAA,QACAX,IAAO,KAAKF,MAAW,SAAS,qDAAqD;AAAA,QACrFA,MAAW,SAAS,aAAa;AAAA,MAAA;AAAA,MAGnC,UAAA;AAAA,QAAA,gBAAAuB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWV;AAAA,cACT;AAAA,cACAb,MAAW,UAAU,kCAAkC;AAAA,YAAA;AAAA,YAGzD,UAAA;AAAA,cAAA,gBAAAY,EAACY,GAAA,EAAW,SAASnB,GAAS,WAAU,eACtC,UAAA,gBAAAO,EAACa,GAAA,EAAc,WAAWZ,EAAG,WAAWb,MAAW,UAAU,mBAAmB,0BAA0B,GAAG,GAC/G;AAAA,cACC,OAAOoB,KAAU,YAAY,OAAOA,KAAU,WAAW,gBAAAR,EAAC,MAAA,EAAG,WAAU,+BAA+B,UAAAQ,EAAA,CAAM,IAAQA;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAEtHnB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEL,EAAA,CAEJ;AAEJ,CAAC;AAEDkB,EAAc,cAAcD;"}
1
+ {"version":3,"file":"drawer.es.js","sources":["../src/components/drawer/Drawer.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { Slot } from \"@radix-ui/react-slot\";\r\nimport { ChevronsRight } from \"@trsys-tech/matrix-icons\";\r\nimport { createContextScope, Scope } from \"@radix-ui/react-context\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { Modal } from \"../modal/Modal\";\r\nimport { IconButton } from \"../icon-botton/IconButton\";\r\nimport { useIsMobile } from \"../../lib/hooks/use-mobile\";\r\n\r\ntype ScopedProps<P> = P & { __scopeDrawer?: Scope };\r\n\r\nconst DRAWER_NAME = \"Drawer\";\r\n\r\nconst [createDrawerContext] = createContextScope(DRAWER_NAME);\r\n\r\ninterface DrawerProps extends React.HTMLAttributes<HTMLDivElement> {\r\n open: boolean;\r\n onClose?: () => void;\r\n anchor?: \"left\" | \"right\";\r\n width?: number;\r\n children?: React.ReactNode;\r\n asChild?: boolean;\r\n mobileBreakpoint?: number;\r\n}\r\n\r\ntype DrawerContextValue = {\r\n open: boolean;\r\n onClose?: () => void;\r\n anchor: \"left\" | \"right\";\r\n width: number;\r\n isMobile: boolean;\r\n};\r\n\r\nconst [DrawerProvider, useDrawerProvider] = createDrawerContext<DrawerContextValue>(DRAWER_NAME);\r\n\r\n/**\r\n * Drawer component\r\n * This is the wrapper component for Drawer content and main components\r\n * @param {React.HTMLAttributes<HTMLDivElement>} props\r\n * @param {boolean} open - Drawer open state\r\n * @param {() => void} onClose - Drawer close handler\r\n * @param {\"left\" | \"right\"} anchor - Drawer anchor position\r\n * @param {number} width - Drawer width\r\n * @param {React.ReactNode} children - Drawer children\r\n * @param {boolean} asChild - Render as child component\r\n * @returns {React.ReactElement}\r\n */\r\nconst Drawer = React.forwardRef<React.ElementRef<\"div\">, ScopedProps<DrawerProps>>((props, ref) => {\r\n const { asChild, anchor = \"right\", children, open, width = 240, className, onClose, __scopeDrawer, ...restProps } = props;\r\n const Comp = asChild ? Slot : \"div\";\r\n\r\n const isMobile = useIsMobile();\r\n\r\n return (\r\n <Comp ref={ref} className={cn(\"mtx-flex\", className)} {...restProps}>\r\n <DrawerProvider anchor={anchor} onClose={onClose} open={open} width={width} isMobile={isMobile} scope={__scopeDrawer}>\r\n {children}\r\n </DrawerProvider>\r\n </Comp>\r\n );\r\n});\r\n\r\nDrawer.displayName = DRAWER_NAME;\r\n\r\ninterface DrawerMainProps extends React.HTMLAttributes<HTMLDivElement> {\r\n asChild: boolean;\r\n}\r\n\r\nconst DRAWER_MAIN_NAME = \"DrawerMain\";\r\n\r\n/**\r\n * DrawerMain component\r\n * This is the main container for the tree that should be shown always\r\n * @param {React.HTMLAttributes<HTMLDivElement>} props\r\n * @param {boolean} asChild - Render as child component\r\n * @property {React.ReactNode} children - DrawerMain children\r\n * @property {string} className - DrawerMain class name\r\n * @property {React.CSSProperties} style - DrawerMain style\r\n * @property {ScopedProps<DrawerMainProps>} __scopeDrawer - DrawerMain scope\r\n * @property {React.Ref<HTMLDivElement>} ref - DrawerMain ref\r\n * @property {React.HTMLAttributes<HTMLDivElement>} props - DrawerMain props\r\n * @returns {React.ReactElement}\r\n */\r\nconst DrawerMain = React.forwardRef<HTMLDivElement, ScopedProps<DrawerMainProps>>(\r\n ({ asChild, children, className, style, __scopeDrawer, ...props }, ref) => {\r\n const Comp = asChild ? Slot : \"div\";\r\n const { anchor, open, width, isMobile } = useDrawerProvider(DRAWER_MAIN_NAME, __scopeDrawer);\r\n\r\n const marginStyle = React.useMemo(() => {\r\n if (isMobile) {\r\n return {};\r\n }\r\n if (anchor === \"left\") {\r\n return { marginInlineStart: open ? width : 0 };\r\n } else {\r\n return { marginInlineEnd: open ? width : 0 };\r\n }\r\n }, [anchor, open, width, isMobile]);\r\n\r\n return (\r\n <Comp ref={ref} className={cn(\"mtx-flex-grow mtx-overflow-hidden\", className)} style={{ ...style, ...marginStyle }} {...props}>\r\n {children}\r\n </Comp>\r\n );\r\n },\r\n);\r\n\r\nDrawerMain.displayName = DRAWER_MAIN_NAME;\r\n\r\ntype DrawerContentProps = {\r\n children?: React.ReactNode;\r\n title: React.ReactNode;\r\n};\r\n\r\nconst DRAWER_CONTENT_NAME = \"DrawerContent\";\r\n\r\n/**\r\n * DrawerContent component\r\n * This is the content container for the tree that should be shown when the drawer is open\r\n * @param {React.HTMLAttributes<HTMLDivElement>} props\r\n * @param {React.ReactNode} children - DrawerContent children\r\n * @param {React.ReactNode} title - DrawerContent title\r\n * @property {ScopedProps<DrawerContentProps>} __scopeDrawer - DrawerContent scope\r\n * @property {React.Ref<HTMLDivElement>} ref - DrawerContent ref\r\n * @property {React.HTMLAttributes<HTMLDivElement>} props - DrawerContent props\r\n * @returns {React.ReactElement}\r\n */\r\nconst DrawerContent = React.forwardRef<HTMLDivElement, ScopedProps<DrawerContentProps>>(({ children, title, __scopeDrawer }, ref) => {\r\n const { anchor, open, width, onClose, isMobile } = useDrawerProvider(DRAWER_CONTENT_NAME, __scopeDrawer);\r\n\r\n return (\r\n <>\r\n {isMobile ? (\r\n <Modal title={title} open={open} onOpenChange={onClose} ref={ref} fullScreen>\r\n {children}\r\n </Modal>\r\n ) : (\r\n <div className={cn(\"mtx-hidden md:mtx-block mtx-overflow-hidden\")} style={{ width }} ref={ref}>\r\n <div\r\n className={cn(\r\n \"mtx-overflow-y-auto mtx-flex mtx-flex-col mtx-h-full mtx-top-0 mtx-z-[120] mtx-bg-background mtx-transition-all mtx-border-gray-200\",\r\n open\r\n ? \"\"\r\n : anchor === \"left\"\r\n ? \"-mtx-translate-x-full rtl:mtx-translate-x-full mtx-invisible\"\r\n : \"mtx-translate-x-full rtl:-mtx-translate-x-full mtx-invisible\",\r\n anchor === \"left\" ? \"mtx-border-r\" : \"mtx-border-l\",\r\n )}\r\n >\r\n <div\r\n className={cn(\r\n \"mtx-h-9 mtx-flex mtx-items-center mtx-gap-2 mtx-p-2 mtx-bg-background mtx-w-full mtx-sticky mtx-top-0 mtx-border-b mtx-border-gray-200\",\r\n anchor === \"right\" ? \"mtx-justify-start rtl:mtx-justify-end\" : \"mtx-justify-end rtl:mtx-justify-start\",\r\n )}\r\n >\r\n <IconButton onClick={onClose} className=\"mtx-w-5 mtx-h-5 mtx-p-0\">\r\n <ChevronsRight className={cn(\"mtx-w-5 mtx-h-5\", anchor === \"right\" ? \"rtl:-mtx-scale-100\" : \"-mtx-scale-100 rtl:mtx-scale-100\")} />\r\n </IconButton>\r\n {typeof title === \"string\" || typeof title === \"number\" ? <h2 className=\"mtx-text-lg mtx-font-bold mtx-text-text\">{title}</h2> : title}\r\n </div>\r\n {children}\r\n </div>\r\n </div>\r\n )}\r\n </>\r\n );\r\n});\r\n\r\nDrawerContent.displayName = DRAWER_CONTENT_NAME;\r\n\r\nconst Root = Drawer;\r\nconst Main = DrawerMain;\r\nconst Content = DrawerContent;\r\n\r\nexport { Drawer, DrawerMain, DrawerContent, Root, Main, Content };\r\nexport type { DrawerContentProps, DrawerMainProps, DrawerProps };\r\n"],"names":["DRAWER_NAME","createDrawerContext","createContextScope","DrawerProvider","useDrawerProvider","Drawer","React","props","ref","asChild","anchor","children","open","width","className","onClose","__scopeDrawer","restProps","Comp","Slot","isMobile","useIsMobile","jsx","cn","DRAWER_MAIN_NAME","DrawerMain","style","marginStyle","DRAWER_CONTENT_NAME","DrawerContent","title","Fragment","Modal","jsxs","IconButton","ChevronsRight"],"mappings":";;;;;;;;;AAcA,MAAMA,IAAc,UAEd,CAACC,CAAmB,IAAIC,EAAmBF,CAAW,GAoBtD,CAACG,GAAgBC,CAAiB,IAAIH,EAAwCD,CAAW,GAczFK,IAASC,EAAM,WAA8D,CAACC,GAAOC,MAAQ;AACjG,QAAM,EAAE,SAAAC,GAAS,QAAAC,IAAS,SAAS,UAAAC,GAAU,MAAAC,GAAM,OAAAC,IAAQ,KAAK,WAAAC,GAAW,SAAAC,GAAS,eAAAC,GAAe,GAAGC,MAAcV,GAC9GW,IAAOT,IAAUU,IAAO,OAExBC,IAAWC,EAAA;AAEjB,SACE,gBAAAC,EAACJ,KAAK,KAAAV,GAAU,WAAWe,EAAG,YAAYT,CAAS,GAAI,GAAGG,GACxD,4BAACd,GAAA,EAAe,QAAAO,GAAgB,SAAAK,GAAkB,MAAAH,GAAY,OAAAC,GAAc,UAAAO,GAAoB,OAAOJ,GACpG,UAAAL,GACH,EAAA,CACF;AAEJ,CAAC;AAEDN,EAAO,cAAcL;AAMrB,MAAMwB,IAAmB,cAenBC,IAAanB,EAAM;AAAA,EACvB,CAAC,EAAE,SAAAG,GAAS,UAAAE,GA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AAA,gBAAAuB;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWV;AAAA,cACT;AAAA,cACAb,MAAW,UAAU,0CAA0C;AAAA,YAAA;AAAA,YAGjE,UAAA;AAAA,cAAA,gBAAAY,EAACY,GAAA,EAAW,SAASnB,GAAS,WAAU,2BACtC,UAAA,gBAAAO,EAACa,GAAA,EAAc,WAAWZ,EAAG,mBAAmBb,MAAW,UAAU,uBAAuB,kCAAkC,GAAG,GACnI;AAAA,cACC,OAAOoB,KAAU,YAAY,OAAOA,KAAU,WAAW,gBAAAR,EAAC,MAAA,EAAG,WAAU,2CAA2C,UAAAQ,EAAA,CAAM,IAAQA;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAElInB;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAEL,EAAA,CAEJ;AAEJ,CAAC;AAEDkB,EAAc,cAAcD;"}
@@ -1,44 +1,44 @@
1
1
  import { jsxs as $, jsx as E } from "react/jsx-runtime";
2
- import * as p from "react";
2
+ import * as x from "react";
3
3
  import { tv as F } from "tailwind-variants";
4
4
  import { cn as h } from "./utils.es.js";
5
5
  const H = F({
6
6
  base: [
7
- "flex items-center w-full rounded-sm border border-input text-text bg-transparent p-0 text-xs [&_input]:text-xs font-medium transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",
8
- "placeholder:text-text-300 hover:border-primary-400 focus-within:border-primary-400 focus-within:outline-none focus-within:ring focus-within:ring-primary-100",
9
- "aria-disabled:text-text-300 aria-disabled:bg-gray-100 aria-disabled:border-gray-100"
7
+ "mtx-flex mtx-items-center mtx-w-full mtx-rounded-sm mtx-border mtx-border-input mtx-text-text mtx-bg-transparent mtx-p-0 mtx-text-xs [&_input]:mtx-text-xs mtx-font-medium mtx-transition-colors file:mtx-border-0 file:mtx-bg-transparent file:mtx-text-sm file:mtx-font-medium file:mtx-text-foreground",
8
+ "placeholder:mtx-text-text-300 hover:mtx-border-primary-400 focus-within:mtx-border-primary-400 focus-within:mtx-outline-none focus-within:mtx-ring focus-within:mtx-ring-primary-100",
9
+ "aria-disabled:mtx-text-text-300 aria-disabled:mtx-bg-gray-100 aria-disabled:mtx-border-gray-100"
10
10
  ],
11
11
  variants: {
12
12
  size: {
13
- sm: "h-7",
14
- md: "h-8",
15
- lg: "h-11"
13
+ sm: "mtx-h-7",
14
+ md: "mtx-h-8",
15
+ lg: "mtx-h-11"
16
16
  }
17
17
  },
18
18
  defaultVariants: {
19
19
  size: "md"
20
20
  }
21
- }), T = p.forwardRef(
22
- ({ className: v, slotProps: g, endAdornment: w, startAdornment: x, size: D, value: d, onChange: c, defaultValue: A, disabled: b, showSeconds: u = !1, ...R }, V) => {
23
- const f = p.useCallback(
21
+ }), T = x.forwardRef(
22
+ ({ className: v, slotProps: d, endAdornment: w, startAdornment: g, size: D, value: p, onChange: u, defaultValue: A, disabled: b, showSeconds: m = !1, ...R }, V) => {
23
+ const c = x.useCallback(
24
24
  (e) => {
25
- const r = e.replace(/\D/g, ""), n = u ? 6 : 4, a = r.substring(0, n).padEnd(n, "0");
26
- let t = a.substring(0, 2), o = a.substring(2, 4), i = u ? a.substring(4, 6) : "";
27
- parseInt(t, 10) > 23 && (t = "23"), parseInt(o, 10) > 59 && (o = "59"), u && parseInt(i, 10) > 59 && (i = "59");
25
+ const r = e.replace(/\D/g, ""), n = m ? 6 : 4, a = r.substring(0, n).padEnd(n, "0");
26
+ let t = a.substring(0, 2), o = a.substring(2, 4), i = m ? a.substring(4, 6) : "";
27
+ parseInt(t, 10) > 23 && (t = "23"), parseInt(o, 10) > 59 && (o = "59"), m && parseInt(i, 10) > 59 && (i = "59");
28
28
  let s = t;
29
- return n >= 4 && (s += `:${o}`), u && (s += `:${i}`), s;
29
+ return n >= 4 && (s += `:${o}`), m && (s += `:${i}`), s;
30
30
  },
31
- [u]
32
- ), [l, m] = p.useState(() => f(A || "")), y = p.useRef(null);
33
- p.useImperativeHandle(V, () => y.current), p.useEffect(() => {
34
- d !== void 0 && m(f(d));
35
- }, [d, f]);
31
+ [m]
32
+ ), [l, f] = x.useState(() => c(A || "")), y = x.useRef(null);
33
+ x.useImperativeHandle(V, () => y.current), x.useEffect(() => {
34
+ p !== void 0 && f(c(p));
35
+ }, [p, c]);
36
36
  const M = (e) => {
37
37
  e.preventDefault();
38
- const r = e.currentTarget, { key: n } = e, a = r.selectionStart ?? 0, t = l.substring(0, a) + n + l.substring(a + 1), o = f(t);
39
- if (m(o), c) {
38
+ const r = e.currentTarget, { key: n } = e, a = r.selectionStart ?? 0, t = l.substring(0, a) + n + l.substring(a + 1), o = c(t);
39
+ if (f(o), u) {
40
40
  const i = { ...e, target: { ...e.target, value: o } };
41
- c(i);
41
+ u(i);
42
42
  }
43
43
  requestAnimationFrame(() => {
44
44
  let i = a + 1;
@@ -53,12 +53,12 @@ const H = F({
53
53
  a = `${l.substring(0, n - 2)}0${l.substring(n - 1)}`, t = n - 2;
54
54
  else {
55
55
  const i = l.replace(/\D/g, ""), s = n - Math.floor((n - 1) / 3), N = `${i.substring(0, s - 1)}0${i.substring(s)}`;
56
- a = f(N);
56
+ a = c(N);
57
57
  }
58
- const o = f(a);
59
- if (m(o), c) {
58
+ const o = c(a);
59
+ if (f(o), u) {
60
60
  const i = { ...e, target: { ...e.target, value: o } };
61
- c(i);
61
+ u(i);
62
62
  }
63
63
  requestAnimationFrame(() => {
64
64
  r.setSelectionRange(t, t);
@@ -71,12 +71,12 @@ const H = F({
71
71
  else if (o >= 3 && o <= 5) {
72
72
  const s = t[1] + a;
73
73
  s >= 60 ? (t[0] = (t[0] + 1) % 24, t[1] = s % 60) : s < 0 ? (t[0] = (t[0] - 1 + 24) % 24, t[1] = 59) : t[1] = s;
74
- } else if (u && o >= 6) {
74
+ } else if (m && o >= 6) {
75
75
  const s = t[2] + a;
76
76
  s >= 60 ? (t[1] += 1, t[2] = s % 60) : s < 0 ? (t[1] -= 1, t[2] = 59) : t[2] = s, t[1] >= 60 ? (t[0] = (t[0] + 1) % 24, t[1] %= 60) : t[1] < 0 && (t[0] = (t[0] - 1 + 24) % 24, t[1] = 59);
77
77
  }
78
78
  const i = t.map((s) => String(s).padStart(2, "0")).join(":");
79
- m(i), c && c({ target: { value: i } }), requestAnimationFrame(() => {
79
+ f(i), u && u({ target: { value: i } }), requestAnimationFrame(() => {
80
80
  r.setSelectionRange(o, o);
81
81
  });
82
82
  }, I = (e) => {
@@ -84,7 +84,7 @@ const H = F({
84
84
  r.length === 1 && /\d/.test(r) ? M(e) : r === "Backspace" ? S(e) : r === "ArrowUp" || r === "ArrowDown" ? k(e) : r === "ArrowRight" || r === "ArrowLeft" || r.length > 1 || a !== t || e.preventDefault();
85
85
  };
86
86
  return /* @__PURE__ */ $("div", { ...R, className: h(H({ size: D, className: v })), "aria-disabled": b, children: [
87
- x,
87
+ g,
88
88
  /* @__PURE__ */ E(
89
89
  "input",
90
90
  {
@@ -95,13 +95,13 @@ const H = F({
95
95
  onChange: () => {
96
96
  },
97
97
  value: l,
98
- placeholder: u ? "HH:MM:SS" : "HH:MM",
98
+ placeholder: m ? "HH:MM:SS" : "HH:MM",
99
99
  disabled: b,
100
- ...g?.inputProps ?? {},
100
+ ...d?.inputProps ?? {},
101
101
  className: h(
102
- "focus:outline-none w-full h-full py-1 rounded-sm file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-text-300",
103
- x ? "ps-1 pe-3" : "px-3",
104
- g?.inputProps?.className
102
+ "focus:mtx-outline-none mtx-w-full mtx-h-full mtx-py-1 mtx-rounded-sm file:mtx-border-0 file:mtx-bg-transparent file:mtx-text-sm file:mtx-font-medium file:mtx-text-foreground placeholder:mtx-text-text-300",
103
+ g ? "mtx-ps-1 mtx-pe-3" : "mtx-px-3",
104
+ d?.inputProps?.className
105
105
  )
106
106
  }
107
107
  ),
@@ -1 +1 @@
1
- {"version":3,"file":"duration.es.js","sources":["../src/components/duration/Duration.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { tv, VariantProps } from \"tailwind-variants\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst textFieldVariants = tv({\r\n base: [\r\n \"flex items-center w-full rounded-sm border border-input text-text bg-transparent p-0 text-xs [&_input]:text-xs font-medium transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground\",\r\n \"placeholder:text-text-300 hover:border-primary-400 focus-within:border-primary-400 focus-within:outline-none focus-within:ring focus-within:ring-primary-100\",\r\n \"aria-disabled:text-text-300 aria-disabled:bg-gray-100 aria-disabled:border-gray-100\",\r\n ],\r\n variants: {\r\n size: {\r\n sm: \"h-7\",\r\n md: \"h-8\",\r\n lg: \"h-11\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n});\r\n\r\ninterface DurationProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof textFieldVariants> {\r\n disabled?: boolean;\r\n endAdornment?: React.ReactNode;\r\n startAdornment?: React.ReactNode;\r\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\r\n value?: string;\r\n defaultValue?: string;\r\n showSeconds?: boolean;\r\n slotProps?: {\r\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\r\n };\r\n}\r\n\r\nconst Duration = React.forwardRef<HTMLInputElement, DurationProps>(\r\n (\r\n { className, slotProps, endAdornment, startAdornment, size, value: _value, onChange, defaultValue, disabled, showSeconds = false, ...props },\r\n ref,\r\n ) => {\r\n const getFormattedValue = React.useCallback(\r\n (val: string) => {\r\n const digits = val.replace(/\\D/g, \"\");\r\n const maxLength = showSeconds ? 6 : 4;\r\n const limitedDigits = digits.substring(0, maxLength).padEnd(maxLength, \"0\");\r\n\r\n let hours = limitedDigits.substring(0, 2);\r\n let minutes = limitedDigits.substring(2, 4);\r\n let seconds = showSeconds ? limitedDigits.substring(4, 6) : \"\";\r\n\r\n if (parseInt(hours, 10) > 23) hours = \"23\";\r\n if (parseInt(minutes, 10) > 59) minutes = \"59\";\r\n if (showSeconds && parseInt(seconds, 10) > 59) seconds = \"59\";\r\n\r\n let formatted = hours;\r\n if (maxLength >= 4) formatted += `:${minutes}`;\r\n if (showSeconds) formatted += `:${seconds}`;\r\n\r\n return formatted;\r\n },\r\n [showSeconds],\r\n );\r\n\r\n const [value, setValue] = React.useState(() => getFormattedValue(defaultValue || \"\"));\r\n const inputRef = React.useRef<HTMLInputElement>(null);\r\n\r\n React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement);\r\n\r\n React.useEffect(() => {\r\n if (_value !== undefined) {\r\n setValue(getFormattedValue(_value));\r\n }\r\n }, [_value, getFormattedValue]);\r\n\r\n const handleNumericInput = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n e.preventDefault();\r\n const input = e.currentTarget;\r\n const { key } = e;\r\n const selection = input.selectionStart ?? 0;\r\n const nextValue = value.substring(0, selection) + key + value.substring(selection + 1);\r\n const formatted = getFormattedValue(nextValue);\r\n setValue(formatted);\r\n\r\n if (onChange) {\r\n const syntheticEvent = { ...e, target: { ...e.target, value: formatted } };\r\n onChange(syntheticEvent as unknown as React.ChangeEvent<HTMLInputElement>);\r\n }\r\n\r\n requestAnimationFrame(() => {\r\n let nextCursor = selection + 1;\r\n if (formatted[nextCursor] === \":\") {\r\n nextCursor++;\r\n }\r\n input.setSelectionRange(nextCursor, nextCursor);\r\n });\r\n };\r\n\r\n const handleBackspace = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n e.preventDefault();\r\n const input = e.currentTarget;\r\n const selection = input.selectionStart ?? 0;\r\n if (selection === 0) return;\r\n\r\n let nextValue = \"\";\r\n let nextCursor = selection - 1;\r\n\r\n if (value[selection - 1] === \":\") {\r\n nextValue = `${value.substring(0, selection - 2)}0${value.substring(selection - 1)}`;\r\n nextCursor = selection - 2;\r\n } else {\r\n const currentValue = value.replace(/\\D/g, \"\");\r\n const cursorIndex = selection - Math.floor((selection - 1) / 3);\r\n const nextDigits = `${currentValue.substring(0, cursorIndex - 1)}0${currentValue.substring(cursorIndex)}`;\r\n nextValue = getFormattedValue(nextDigits);\r\n }\r\n\r\n const formatted = getFormattedValue(nextValue);\r\n setValue(formatted);\r\n\r\n if (onChange) {\r\n const syntheticEvent = { ...e, target: { ...e.target, value: formatted } };\r\n onChange(syntheticEvent as unknown as React.ChangeEvent<HTMLInputElement>);\r\n }\r\n\r\n requestAnimationFrame(() => {\r\n input.setSelectionRange(nextCursor, nextCursor);\r\n });\r\n };\r\n\r\n const handleArrowKey = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n e.preventDefault();\r\n const input = e.currentTarget;\r\n const { key } = e;\r\n const increment = key === \"ArrowUp\" ? 1 : -1;\r\n const parts = value.split(\":\").map(Number);\r\n const selection = input.selectionStart ?? 0;\r\n\r\n if (selection <= 2) {\r\n // Hours\r\n parts[0] = (parts[0] + increment + 24) % 24;\r\n } else if (selection >= 3 && selection <= 5) {\r\n // Minutes\r\n const newMinutes = parts[1] + increment;\r\n if (newMinutes >= 60) {\r\n parts[0] = (parts[0] + 1) % 24;\r\n parts[1] = newMinutes % 60;\r\n } else if (newMinutes < 0) {\r\n parts[0] = (parts[0] - 1 + 24) % 24;\r\n parts[1] = 59;\r\n } else {\r\n parts[1] = newMinutes;\r\n }\r\n } else if (showSeconds && selection >= 6) {\r\n // Seconds\r\n const newSeconds = parts[2] + increment;\r\n if (newSeconds >= 60) {\r\n parts[1] += 1;\r\n parts[2] = newSeconds % 60;\r\n } else if (newSeconds < 0) {\r\n parts[1] -= 1;\r\n parts[2] = 59;\r\n } else {\r\n parts[2] = newSeconds;\r\n }\r\n\r\n if (parts[1] >= 60) {\r\n parts[0] = (parts[0] + 1) % 24;\r\n parts[1] %= 60;\r\n } else if (parts[1] < 0) {\r\n parts[0] = (parts[0] - 1 + 24) % 24;\r\n parts[1] = 59;\r\n }\r\n }\r\n\r\n const newValue = parts.map(part => String(part).padStart(2, \"0\")).join(\":\");\r\n setValue(newValue);\r\n if (onChange) {\r\n onChange({ target: { value: newValue } } as React.ChangeEvent<HTMLInputElement>);\r\n }\r\n requestAnimationFrame(() => {\r\n input.setSelectionRange(selection, selection);\r\n });\r\n };\r\n\r\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n const { key, currentTarget } = e;\r\n const { selectionStart, selectionEnd } = currentTarget;\r\n\r\n if (key.length === 1 && /\\d/.test(key)) {\r\n handleNumericInput(e);\r\n } else if (key === \"Backspace\") {\r\n handleBackspace(e);\r\n } else if (key === \"ArrowUp\" || key === \"ArrowDown\") {\r\n handleArrowKey(e);\r\n } else if (key === \"ArrowRight\" || key === \"ArrowLeft\" || key.length > 1 || selectionStart !== selectionEnd) {\r\n // Allow navigation, control keys, and replacing a selection\r\n } else {\r\n e.preventDefault();\r\n }\r\n };\r\n\r\n return (\r\n <div {...props} className={cn(textFieldVariants({ size, className }))} aria-disabled={disabled}>\r\n {startAdornment}\r\n <input\r\n type=\"text\"\r\n inputMode=\"numeric\"\r\n ref={inputRef}\r\n onKeyDown={handleKeyDown}\r\n onChange={() => {}}\r\n value={value}\r\n placeholder={showSeconds ? \"HH:MM:SS\" : \"HH:MM\"}\r\n disabled={disabled}\r\n {...(slotProps?.inputProps ?? {})}\r\n className={cn(\r\n \"focus:outline-none w-full h-full py-1 rounded-sm file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-text-300\",\r\n !startAdornment ? \"px-3\" : \"ps-1 pe-3\",\r\n slotProps?.inputProps?.className,\r\n )}\r\n />\r\n\r\n {endAdornment}\r\n </div>\r\n );\r\n },\r\n);\r\nDuration.displayName = \"Duration\";\r\n\r\nexport { Duration, type DurationProps };\r\n"],"names":["textFieldVariants","tv","Duration","React","className","slotProps","endAdornment","startAdornment","size","_value","onChange","defaultValue","disabled","showSeconds","props","ref","getFormattedValue","val","digits","maxLength","limitedDigits","hours","minutes","seconds","formatted","value","setValue","inputRef","handleNumericInput","input","key","selection","nextValue","syntheticEvent","nextCursor","handleBackspace","currentValue","cursorIndex","nextDigits","handleArrowKey","increment","parts","newMinutes","newS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,UAAU,MAAM;AAAA,UAAC;AAAA,UACjB,OAAArB;AAAA,UACA,aAAaZ,IAAc,aAAa;AAAA,UACxC,UAAAD;AAAA,UACC,GAAIP,GAAW,cAAc,CAAA;AAAA,UAC9B,WAAW8C;AAAA,YACT;AAAA,YACC5C,IAA0B,cAAT;AAAA,YAClBF,GAAW,YAAY;AAAA,UAAA;AAAA,QACzB;AAAA,MAAA;AAAA,MAGDC;AAAA,IAAA,GACH;AAAA,EAEJ;AACF;AACAJ,EAAS,cAAc;"}
1
+ {"version":3,"file":"duration.es.js","sources":["../src/components/duration/Duration.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { tv, VariantProps } from \"tailwind-variants\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst textFieldVariants = tv({\r\n base: [\r\n \"mtx-flex mtx-items-center mtx-w-full mtx-rounded-sm mtx-border mtx-border-input mtx-text-text mtx-bg-transparent mtx-p-0 mtx-text-xs [&_input]:mtx-text-xs mtx-font-medium mtx-transition-colors file:mtx-border-0 file:mtx-bg-transparent file:mtx-text-sm file:mtx-font-medium file:mtx-text-foreground\",\r\n \"placeholder:mtx-text-text-300 hover:mtx-border-primary-400 focus-within:mtx-border-primary-400 focus-within:mtx-outline-none focus-within:mtx-ring focus-within:mtx-ring-primary-100\",\r\n \"aria-disabled:mtx-text-text-300 aria-disabled:mtx-bg-gray-100 aria-disabled:mtx-border-gray-100\",\r\n ],\r\n variants: {\r\n size: {\r\n sm: \"mtx-h-7\",\r\n md: \"mtx-h-8\",\r\n lg: \"mtx-h-11\",\r\n },\r\n },\r\n defaultVariants: {\r\n size: \"md\",\r\n },\r\n});\r\n\r\ninterface DurationProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof textFieldVariants> {\r\n disabled?: boolean;\r\n endAdornment?: React.ReactNode;\r\n startAdornment?: React.ReactNode;\r\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\r\n value?: string;\r\n defaultValue?: string;\r\n showSeconds?: boolean;\r\n slotProps?: {\r\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\r\n };\r\n}\r\n\r\nconst Duration = React.forwardRef<HTMLInputElement, DurationProps>(\r\n (\r\n { className, slotProps, endAdornment, startAdornment, size, value: _value, onChange, defaultValue, disabled, showSeconds = false, ...props },\r\n ref,\r\n ) => {\r\n const getFormattedValue = React.useCallback(\r\n (val: string) => {\r\n const digits = val.replace(/\\D/g, \"\");\r\n const maxLength = showSeconds ? 6 : 4;\r\n const limitedDigits = digits.substring(0, maxLength).padEnd(maxLength, \"0\");\r\n\r\n let hours = limitedDigits.substring(0, 2);\r\n let minutes = limitedDigits.substring(2, 4);\r\n let seconds = showSeconds ? limitedDigits.substring(4, 6) : \"\";\r\n\r\n if (parseInt(hours, 10) > 23) hours = \"23\";\r\n if (parseInt(minutes, 10) > 59) minutes = \"59\";\r\n if (showSeconds && parseInt(seconds, 10) > 59) seconds = \"59\";\r\n\r\n let formatted = hours;\r\n if (maxLength >= 4) formatted += `:${minutes}`;\r\n if (showSeconds) formatted += `:${seconds}`;\r\n\r\n return formatted;\r\n },\r\n [showSeconds],\r\n );\r\n\r\n const [value, setValue] = React.useState(() => getFormattedValue(defaultValue || \"\"));\r\n const inputRef = React.useRef<HTMLInputElement>(null);\r\n\r\n React.useImperativeHandle(ref, () => inputRef.current as HTMLInputElement);\r\n\r\n React.useEffect(() => {\r\n if (_value !== undefined) {\r\n setValue(getFormattedValue(_value));\r\n }\r\n }, [_value, getFormattedValue]);\r\n\r\n const handleNumericInput = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n e.preventDefault();\r\n const input = e.currentTarget;\r\n const { key } = e;\r\n const selection = input.selectionStart ?? 0;\r\n const nextValue = value.substring(0, selection) + key + value.substring(selection + 1);\r\n const formatted = getFormattedValue(nextValue);\r\n setValue(formatted);\r\n\r\n if (onChange) {\r\n const syntheticEvent = { ...e, target: { ...e.target, value: formatted } };\r\n onChange(syntheticEvent as unknown as React.ChangeEvent<HTMLInputElement>);\r\n }\r\n\r\n requestAnimationFrame(() => {\r\n let nextCursor = selection + 1;\r\n if (formatted[nextCursor] === \":\") {\r\n nextCursor++;\r\n }\r\n input.setSelectionRange(nextCursor, nextCursor);\r\n });\r\n };\r\n\r\n const handleBackspace = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n e.preventDefault();\r\n const input = e.currentTarget;\r\n const selection = input.selectionStart ?? 0;\r\n if (selection === 0) return;\r\n\r\n let nextValue = \"\";\r\n let nextCursor = selection - 1;\r\n\r\n if (value[selection - 1] === \":\") {\r\n nextValue = `${value.substring(0, selection - 2)}0${value.substring(selection - 1)}`;\r\n nextCursor = selection - 2;\r\n } else {\r\n const currentValue = value.replace(/\\D/g, \"\");\r\n const cursorIndex = selection - Math.floor((selection - 1) / 3);\r\n const nextDigits = `${currentValue.substring(0, cursorIndex - 1)}0${currentValue.substring(cursorIndex)}`;\r\n nextValue = getFormattedValue(nextDigits);\r\n }\r\n\r\n const formatted = getFormattedValue(nextValue);\r\n setValue(formatted);\r\n\r\n if (onChange) {\r\n const syntheticEvent = { ...e, target: { ...e.target, value: formatted } };\r\n onChange(syntheticEvent as unknown as React.ChangeEvent<HTMLInputElement>);\r\n }\r\n\r\n requestAnimationFrame(() => {\r\n input.setSelectionRange(nextCursor, nextCursor);\r\n });\r\n };\r\n\r\n const handleArrowKey = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n e.preventDefault();\r\n const input = e.currentTarget;\r\n const { key } = e;\r\n const increment = key === \"ArrowUp\" ? 1 : -1;\r\n const parts = value.split(\":\").map(Number);\r\n const selection = input.selectionStart ?? 0;\r\n\r\n if (selection <= 2) {\r\n // Hours\r\n parts[0] = (parts[0] + increment + 24) % 24;\r\n } else if (selection >= 3 && selection <= 5) {\r\n // Minutes\r\n const newMinutes = parts[1] + increment;\r\n if (newMinutes >= 60) {\r\n parts[0] = (parts[0] + 1) % 24;\r\n parts[1] = newMinutes % 60;\r\n } else if (newMinutes < 0) {\r\n parts[0] = (parts[0] - 1 + 24) % 24;\r\n parts[1] = 59;\r\n } else {\r\n parts[1] = newMinutes;\r\n }\r\n } else if (showSeconds && selection >= 6) {\r\n // Seconds\r\n const newSeconds = parts[2] + increment;\r\n if (newSeconds >= 60) {\r\n parts[1] += 1;\r\n parts[2] = newSeconds % 60;\r\n } else if (newSeconds < 0) {\r\n parts[1] -= 1;\r\n parts[2] = 59;\r\n } else {\r\n parts[2] = newSeconds;\r\n }\r\n\r\n if (parts[1] >= 60) {\r\n parts[0] = (parts[0] + 1) % 24;\r\n parts[1] %= 60;\r\n } else if (parts[1] < 0) {\r\n parts[0] = (parts[0] - 1 + 24) % 24;\r\n parts[1] = 59;\r\n }\r\n }\r\n\r\n const newValue = parts.map(part => String(part).padStart(2, \"0\")).join(\":\");\r\n setValue(newValue);\r\n if (onChange) {\r\n onChange({ target: { value: newValue } } as React.ChangeEvent<HTMLInputElement>);\r\n }\r\n requestAnimationFrame(() => {\r\n input.setSelectionRange(selection, selection);\r\n });\r\n };\r\n\r\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\r\n const { key, currentTarget } = e;\r\n const { selectionStart, selectionEnd } = currentTarget;\r\n\r\n if (key.length === 1 && /\\d/.test(key)) {\r\n handleNumericInput(e);\r\n } else if (key === \"Backspace\") {\r\n handleBackspace(e);\r\n } else if (key === \"ArrowUp\" || key === \"ArrowDown\") {\r\n handleArrowKey(e);\r\n } else if (key === \"ArrowRight\" || key === \"ArrowLeft\" || key.length > 1 || selectionStart !== selectionEnd) {\r\n // Allow navigation, control keys, and replacing a selection\r\n } else {\r\n e.preventDefault();\r\n }\r\n };\r\n\r\n return (\r\n <div {...props} className={cn(textFieldVariants({ size, className }))} aria-disabled={disabled}>\r\n {startAdornment}\r\n <input\r\n type=\"text\"\r\n inputMode=\"numeric\"\r\n ref={inputRef}\r\n onKeyDown={handleKeyDown}\r\n onChange={() => {}}\r\n value={value}\r\n placeholder={showSeconds ? \"HH:MM:SS\" : \"HH:MM\"}\r\n disabled={disabled}\r\n {...(slotProps?.inputProps ?? {})}\r\n className={cn(\r\n \"focus:mtx-outline-none mtx-w-full mtx-h-full mtx-py-1 mtx-rounded-sm file:mtx-border-0 file:mtx-bg-transparent file:mtx-text-sm file:mtx-font-medium file:mtx-text-foreground placeholder:mtx-text-text-300\",\r\n !startAdornment ? \"mtx-px-3\" : \"mtx-ps-1 mtx-pe-3\",\r\n slotProps?.inputProps?.className,\r\n )}\r\n />\r\n\r\n {endAdornment}\r\n </div>\r\n );\r\n },\r\n);\r\nDuration.displayName = \"Duration\";\r\n\r\nexport { Duration, type DurationProps };\r\n"],"names":["textFieldVariants","tv","Duration","React","className","slotProps","endAdornment","startAdornment","size","_value","onChange","defaultValue","disabled","showSeconds","props","ref","getFormattedValue","val","digits","maxLength","limitedDigits","hours","minutes","seconds","formatted","value","setValue","inputRef","handleNumericInput","input","key","selection","nextValue","syntheticEvent","nextCursor","handleBackspace","currentValue","cursorIndex","nextDigits","handleArrowKey","increment","parts","newMinutes","newSeconds","newValue","part","handleKeyDown","currentTarget","selectionStart","selectionEnd","jsxs","cn","jsx"],"mappings":";;;;AAOA,MAAMA,IAAoBC,EAAG;AAAA,EAC3B,MAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IAAA;AAAA,EACN;AAAA,EAEF,iBAAiB;AAAA,IACf,MAAM;AAAA,EAAA;AAEV,CAAC,GAeKC,IAAWC,EAAM;AAAA,EACrB,CACE,EAAE,WAAAC,GAAW,WAAAC,GAAW,cAAAC,GAAc,gBAAAC,GAAgB,MAAAC,GAAM,OAAOC,GAAQ,UAAAC,GAAU,cAAAC,GAAc,UAAAC,GAAU,aAAAC,IAAc,IAAO,GAAGC,EAAA,GACrIC,MACG;AACH,UAAMC,IAAoBb,EAAM;AAAA,MAC9B,CAAC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E,YAAM,EAAE,KAAAhB,GAAK,eAAAiB,EAAA,IAAkB,GACzB,EAAE,gBAAAC,GAAgB,cAAAC,EAAA,IAAiBF;AAEzC,MAAIjB,EAAI,WAAW,KAAK,KAAK,KAAKA,CAAG,IACnCF,EAAmB,CAAC,IACXE,MAAQ,cACjBK,EAAgB,CAAC,IACRL,MAAQ,aAAaA,MAAQ,cACtCS,EAAe,CAAC,IACPT,MAAQ,gBAAgBA,MAAQ,eAAeA,EAAI,SAAS,KAAKkB,MAAmBC,KAG7F,EAAE,eAAA;AAAA,IAEN;AAEA,WACE,gBAAAC,EAAC,OAAA,EAAK,GAAGpC,GAAO,WAAWqC,EAAGnD,EAAkB,EAAE,MAAAQ,GAAM,WAAAJ,EAAA,CAAW,CAAC,GAAG,iBAAeQ,GACnF,UAAA;AAAA,MAAAL;AAAA,MACD,gBAAA6C;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,KAAKzB;AAAA,UACL,WAAWmB;AAAA,UACX,UAAU,MAAM;AAAA,UAAC;AAAA,UACjB,OAAArB;AAAA,UACA,aAAaZ,IAAc,aAAa;AAAA,UACxC,UAAAD;AAAA,UACC,GAAIP,GAAW,cAAc,CAAA;AAAA,UAC9B,WAAW8C;AAAA,YACT;AAAA,YACC5C,IAA8B,sBAAb;AAAA,YAClBF,GAAW,YAAY;AAAA,UAAA;AAAA,QACzB;AAAA,MAAA;AAAA,MAGDC;AAAA,IAAA,GACH;AAAA,EAEJ;AACF;AACAJ,EAAS,cAAc;"}
package/dist/form.es.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
2
  import * as m from "react";
3
- import { Slot as F } from "@radix-ui/react-slot";
4
- import { FormProvider as u, Controller as p, useFormContext as x } from "react-hook-form";
3
+ import { Slot as x } from "@radix-ui/react-slot";
4
+ import { FormProvider as F, Controller as u, useFormContext as p } from "react-hook-form";
5
5
  import { Label as I } from "./label.es.js";
6
6
  import { cn as i } from "./utils.es.js";
7
- const D = u, l = m.createContext({}), M = ({
7
+ const D = F, l = m.createContext({}), M = ({
8
8
  ...e
9
- }) => /* @__PURE__ */ a(l.Provider, { value: { name: e.name }, children: /* @__PURE__ */ a(p, { ...e }) }), d = () => {
10
- const e = m.useContext(l), o = m.useContext(f), { getFieldState: t, formState: r } = x(), n = t(e.name, r);
9
+ }) => /* @__PURE__ */ a(l.Provider, { value: { name: e.name }, children: /* @__PURE__ */ a(u, { ...e }) }), d = () => {
10
+ const e = m.useContext(l), t = m.useContext(f), { getFieldState: o, formState: r } = p(), n = o(e.name, r);
11
11
  if (!e)
12
12
  throw new Error("useFormField should be used within <FormField>");
13
- const { id: s } = o;
13
+ const { id: s } = t;
14
14
  return {
15
15
  id: s,
16
16
  name: e.name,
@@ -19,39 +19,39 @@ const D = u, l = m.createContext({}), M = ({
19
19
  formMessageId: `${s}-form-item-message`,
20
20
  ...n
21
21
  };
22
- }, f = m.createContext({}), g = m.forwardRef(({ className: e, ...o }, t) => {
22
+ }, f = m.createContext({}), g = m.forwardRef(({ className: e, ...t }, o) => {
23
23
  const r = m.useId();
24
- return /* @__PURE__ */ a(f.Provider, { value: { id: r }, children: /* @__PURE__ */ a("div", { ref: t, className: i("space-y-1", e), ...o }) });
24
+ return /* @__PURE__ */ a(f.Provider, { value: { id: r }, children: /* @__PURE__ */ a("div", { ref: o, className: i("mtx-space-y-1", e), ...t }) });
25
25
  });
26
26
  g.displayName = "FormItem";
27
- const b = m.forwardRef(({ className: e, ...o }, t) => {
27
+ const b = m.forwardRef(({ className: e, ...t }, o) => {
28
28
  const { error: r, formItemId: n } = d();
29
- return /* @__PURE__ */ a(I, { ref: t, className: i(r && "text-danger", "block text-text-300", e), htmlFor: n, ...o });
29
+ return /* @__PURE__ */ a(I, { ref: o, className: i(r && "mtx-text-danger", "mtx-block mtx-text-text-300", e), htmlFor: n, ...t });
30
30
  });
31
31
  b.displayName = "FormLabel";
32
- const C = m.forwardRef(({ className: e, ...o }, t) => {
32
+ const C = m.forwardRef(({ className: e, ...t }, o) => {
33
33
  const { error: r, formItemId: n, formDescriptionId: s, formMessageId: c } = d();
34
34
  return /* @__PURE__ */ a(
35
- F,
35
+ x,
36
36
  {
37
- ref: t,
37
+ ref: o,
38
38
  id: n,
39
39
  "aria-describedby": r ? `${s} ${c}` : `${s}`,
40
40
  "aria-invalid": !!r,
41
- className: i(e, r && "border-danger hover:border-danger focus-visible:border-danger"),
42
- ...o
41
+ className: i(e, r && "mtx-border-danger hover:mtx-border-danger focus-visible:mtx-border-danger"),
42
+ ...t
43
43
  }
44
44
  );
45
45
  });
46
46
  C.displayName = "FormControl";
47
- const N = m.forwardRef(({ className: e, ...o }, t) => {
47
+ const N = m.forwardRef(({ className: e, ...t }, o) => {
48
48
  const { formDescriptionId: r } = d();
49
- return /* @__PURE__ */ a("p", { ref: t, id: r, className: i("text-[0.8rem] text-muted-foreground", e), ...o });
49
+ return /* @__PURE__ */ a("p", { ref: o, id: r, className: i("mtx-text-[0.8rem] mtx-text-muted-foreground", e), ...t });
50
50
  });
51
51
  N.displayName = "FormDescription";
52
- const h = m.forwardRef(({ className: e, children: o, ...t }, r) => {
53
- const { error: n, formMessageId: s } = d(), c = n ? String(n?.message) : o;
54
- return /* @__PURE__ */ a("p", { ref: r, id: s, className: i("text-[0.625rem] font-medium text-danger h-4", e), ...t, children: c ?? " " });
52
+ const h = m.forwardRef(({ className: e, children: t, ...o }, r) => {
53
+ const { error: n, formMessageId: s } = d(), c = n ? String(n?.message) : t;
54
+ return /* @__PURE__ */ a("p", { ref: r, id: s, className: i("mtx-text-[0.625rem] mtx-font-medium mtx-text-danger mtx-h-4", e), ...o, children: c ?? " " });
55
55
  });
56
56
  h.displayName = "FormMessage";
57
57
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"form.es.js","sources":["../src/components/form/Form.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from \"react-hook-form\";\n\nimport { Label } from \"../label/Label\";\nimport { cn } from \"../../lib/utils\";\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);\n\nconst FormField = <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState, formState } = useFormContext();\n\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(\"space-y-1\", className)} {...props} />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<HTMLLabelElement, React.ComponentPropsWithoutRef<\"label\">>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return <Label ref={ref} className={cn(error && \"text-danger\", \"block text-text-300\", className)} htmlFor={formItemId} {...props} />;\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(({ className, ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n className={cn(className, error && \"border-danger hover:border-danger focus-visible:border-danger\")}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return <p ref={ref} id={formDescriptionId} className={cn(\"text-[0.8rem] text-muted-foreground\", className)} {...props} />;\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message) : children;\n\n // if (!body) {\n // return null;\n // }\n\n return (\n <p ref={ref} id={formMessageId} className={cn(\"text-[0.625rem] font-medium text-danger h-4\", className)} {...props}>\n {body ?? \" \"}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body"],"mappings":";;;;;;AASA,MAAMA,IAAOC,GAMPC,IAAmBC,EAAM,cAAqC,EAA2B,GAEzFC,IAAY,CAAkH;AAAA,EAClI,GAAGC;AACL,MAEI,gBAAAC,EAACJ,EAAiB,UAAjB,EAA0B,OAAO,EAAE,MAAMG,E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WAAAe,GAAW,GAAGb,EAAA,GAASc,MAAQ;AACjJ,QAAM,EAAE,OAAAG,GAAO,YAAAC,GAAY,mBAAAG,GAAmB,eAAAC,EAAA,IAAkBnB,EAAA;AAEhE,SACE,gBAAAF;AAAA,IAACsB;AAAA,IAAA;AAAA,MACC,KAAAT;AAAA,MACA,IAAII;AAAA,MACJ,oBAAmBD,IAAiC,GAAGI,CAAiB,IAAIC,CAAa,KAA9D,GAAGD,CAAiB;AAAA,MAC/C,gBAAc,CAAC,CAACJ;AAAA,MAChB,WAAWF,EAAGF,GAAWI,KAAS,+DAA+D;AAAA,MAChG,GAAGjB;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDoB,EAAY,cAAc;AAE1B,MAAMI,IAAkB1B,EAAM,WAA6E,CAAC,EAAE,WAAAe,GAAW,GAAGb,EAAA,GAASc,MAAQ;AAC3I,QAAM,EAAE,mBAAAO,EAAA,IAAsBlB,EAAA;AAE9B,SAAO,gBAAAF,EAAC,KAAA,EAAE,KAAAa,GAAU,IAAIO,GAAmB,WAAWN,EAAG,uCAAuCF,CAAS,GAAI,GAAGb,EAAA,CAAO;AACzH,CAAC;AACDwB,EAAgB,cAAc;AAE9B,MAAMC,IAAc3B,EAAM,WAA6E,CAAC,EAAE,WAAAe,GAAW,UAAAa,GAAU,GAAG1B,EAAA,GAASc,MAAQ;AACjJ,QAAM,EAAE,OAAAG,GAAO,eAAAK,EAAA,IAAkBnB,EAAA,GAC3BwB,IAAOV,IAAQ,OAAOA,GAAO,OAAO,IAAIS;AAM9C,SACE,gBAAAzB,EAAC,KAAA,EAAE,KAAAa,GAAU,IAAIQ,GAAe,WAAWP,EAAG,+CAA+CF,CAAS,GAAI,GAAGb,GAC1G,eAAQ,KACX;AAEJ,CAAC;AACDyB,EAAY,cAAc;"}
1
+ {"version":3,"file":"form.es.js","sources":["../src/components/form/Form.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Controller, ControllerProps, FieldPath, FieldValues, FormProvider, useFormContext } from \"react-hook-form\";\n\nimport { Label } from \"../label/Label\";\nimport { cn } from \"../../lib/utils\";\n\nconst Form = FormProvider;\n\ntype FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue);\n\nconst FormField = <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState, formState } = useFormContext();\n\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\");\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(\"mtx-space-y-1\", className)} {...props} />\n </FormItemContext.Provider>\n );\n});\nFormItem.displayName = \"FormItem\";\n\nconst FormLabel = React.forwardRef<HTMLLabelElement, React.ComponentPropsWithoutRef<\"label\">>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField();\n\n return <Label ref={ref} className={cn(error && \"mtx-text-danger\", \"mtx-block mtx-text-text-300\", className)} htmlFor={formItemId} {...props} />;\n});\nFormLabel.displayName = \"FormLabel\";\n\nconst FormControl = React.forwardRef<React.ElementRef<typeof Slot>, React.ComponentPropsWithoutRef<typeof Slot>>(({ className, ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField();\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n className={cn(className, error && \"mtx-border-danger hover:mtx-border-danger focus-visible:mtx-border-danger\")}\n {...props}\n />\n );\n});\nFormControl.displayName = \"FormControl\";\n\nconst FormDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField();\n\n return <p ref={ref} id={formDescriptionId} className={cn(\"mtx-text-[0.8rem] mtx-text-muted-foreground\", className)} {...props} />;\n});\nFormDescription.displayName = \"FormDescription\";\n\nconst FormMessage = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message) : children;\n\n // if (!body) {\n // return null;\n // }\n\n return (\n <p ref={ref} id={formMessageId} className={cn(\"mtx-text-[0.625rem] mtx-font-medium mtx-text-danger mtx-h-4\", className)} {...props}>\n {body ?? \" \"}\n </p>\n );\n});\nFormMessage.displayName = \"FormMessage\";\n\nexport { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField };\n"],"names":["Form","FormProvider","FormFieldContext","React","FormField","props","jsx","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","className","ref","cn","FormLabel","error","formItemId","Label","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body"],"mappings":";;;;;;AASA,MAAMA,IAAOC,GAMPC,IAAmBC,EAAM,cAAqC,EAA2B,GAEzFC,IAAY,CAAkH;AAAA,EAClI,GAAGC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";
4
4
  import { Checkbox as N } from "./checkbox.es.js";
5
5
  import { useCallback as j } from "react";
6
6
  import { cn as y } from "./utils.es.js";
7
- const U = (p) => {
8
- const { name: a, control: t, defaultValue: l, disabled: s, readOnly: f, rules: m, shouldUnregister: n, label: h, slotProps: e, required: c, ...u } = p, { field: d } = P({ name: a, control: t, rules: m, defaultValue: l, disabled: s, shouldUnregister: n }), x = j(
7
+ const U = (x) => {
8
+ const { name: m, control: s, defaultValue: a, disabled: t, readOnly: p, rules: l, shouldUnregister: n, label: f, slotProps: e, required: c, ...h } = x, { field: d } = P({ name: m, control: s, rules: l, defaultValue: a, disabled: t, shouldUnregister: n }), u = j(
9
9
  (o) => {
10
10
  d.onChange(o);
11
11
  },
@@ -14,27 +14,27 @@ const U = (p) => {
14
14
  return /* @__PURE__ */ r(
15
15
  C,
16
16
  {
17
- control: t,
18
- name: a,
19
- defaultValue: l,
20
- disabled: s,
21
- rules: m,
17
+ control: s,
18
+ name: m,
19
+ defaultValue: a,
20
+ disabled: t,
21
+ rules: l,
22
22
  shouldUnregister: n,
23
- render: ({ field: o }) => /* @__PURE__ */ i(b, { ...u, className: "flex items-center gap-2 justify-start space-y-0", children: [
23
+ render: ({ field: o }) => /* @__PURE__ */ i(b, { ...h, className: "mtx-flex mtx-items-center mtx-gap-2 mtx-justify-start mtx-space-y-0", children: [
24
24
  /* @__PURE__ */ r(g, { ...e?.formControlProps ?? {}, children: /* @__PURE__ */ r(
25
25
  N,
26
26
  {
27
27
  ...e?.checkboxProps ?? {},
28
28
  ...o,
29
29
  checked: o.value,
30
- onCheckedChange: x,
30
+ onCheckedChange: u,
31
31
  "aria-required": c,
32
- disabled: s || f
32
+ disabled: t || p
33
33
  }
34
34
  ) }),
35
- /* @__PURE__ */ i(k, { ...e?.formLabelProps ?? {}, className: y("text-text", e?.formLabelProps?.className), children: [
36
- h,
37
- c && /* @__PURE__ */ r("span", { className: "text-danger text-sm leading-4", children: "*" })
35
+ /* @__PURE__ */ i(k, { ...e?.formLabelProps ?? {}, className: y("mtx-text-text", e?.formLabelProps?.className), children: [
36
+ f,
37
+ c && /* @__PURE__ */ r("span", { className: "mtx-text-danger mtx-text-sm mtx-leading-4", children: "*" })
38
38
  ] }),
39
39
  /* @__PURE__ */ r(F, { ...e?.formMessageProps ?? {} })
40
40
  ] })
@@ -1 +1 @@
1
- {"version":3,"file":"formcheckbox.es.js","sources":["../src/components/form-checkbox/FormCheckbox.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport { FormControl, FormField, FormItem, FormLabel, FormMessage } from \"../form/Form\";\r\nimport { SlotProps } from \"@radix-ui/react-slot\";\r\nimport { Control, ControllerProps, FieldPath, FieldValues, useController } from \"react-hook-form\";\r\nimport { Checkbox, CheckboxProps } from \"../checkbox/Checkbox\";\r\nimport { useCallback } from \"react\";\r\nimport { cn } from \"../../lib/utils\";\r\n\r\ntype FormCheckboxProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = Omit<\r\n ControllerProps<TFieldValues, TName>,\r\n \"render\"\r\n> &\r\n React.ComponentProps<typeof FormItem> & {\r\n label: string;\r\n control: Control<TFieldValues>;\r\n required?: boolean;\r\n readOnly?: boolean;\r\n slotProps?: {\r\n formLabelProps?: React.HTMLAttributes<HTMLLabelElement> & React.RefAttributes<HTMLLabelElement>;\r\n formMessageProps?: React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>;\r\n formControlProps?: Omit<SlotProps & React.RefAttributes<HTMLElement>, \"ref\"> & React.RefAttributes<HTMLElement>;\r\n checkboxProps?: CheckboxProps;\r\n };\r\n };\r\n\r\nconst FormCheckbox = <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>(props: FormCheckboxProps<TFieldValues, TName>) => {\r\n const { name, control, defaultValue, disabled, readOnly, rules, shouldUnregister, label, slotProps, required, ...formItemProps } = props;\r\n const { field } = useController({ name, control, rules, defaultValue, disabled, shouldUnregister });\r\n\r\n const handleCheckChanged = useCallback(\r\n (checked: boolean) => {\r\n field.onChange(checked);\r\n },\r\n [field],\r\n );\r\n\r\n return (\r\n <FormField\r\n control={control}\r\n name={name}\r\n defaultValue={defaultValue}\r\n disabled={disabled}\r\n rules={rules}\r\n shouldUnregister={shouldUnregister}\r\n render={({ field }) => {\r\n return (\r\n <FormItem {...formItemProps} className=\"flex items-center gap-2 justify-start space-y-0\">\r\n <FormControl {...(slotProps?.formControlProps ?? {})}>\r\n <Checkbox\r\n {...(slotProps?.checkboxProps ?? {})}\r\n {...field}\r\n checked={field.value}\r\n onCheckedChange={handleCheckChanged}\r\n aria-required={required}\r\n disabled={disabled || readOnly}\r\n />\r\n </FormControl>\r\n <FormLabel {...(slotProps?.formLabelProps ?? {})} className={cn(\"text-text\", slotProps?.formLabelProps?.className)}>\r\n {label}\r\n {required && <span className=\"text-danger text-sm leading-4\">*</span>}\r\n </FormLabel>\r\n <FormMessage {...(slotProps?.formMessageProps ?? {})} />\r\n </FormItem>\r\n );\r\n }}\r\n />\r\n );\r\n};\r\nexport { FormCheckbox, type FormCheckboxProps };\r\n"],"names":["FormCheckbox","props","name","control","defaultValue","disabled","readOnly","rules","shouldUnregister","label","slotProps","required","formItemProps","field","useController","handleCheckChanged","useCallback","checked","jsx","FormField","jsxs","FormItem","FormControl","Checkbox","FormLabel","cn","FormMessage"],"mappings":";;;;;;AA0BA,MAAMA,IAAe,CAA0EC,MAAkD;AAC/I,QAAM,EAAE,MAAAC,GAAM,SAAAC,GAAS,cAAAC,GAAc,UAAAC,GAAU,UAAAC,GAAU,OAAAC,GAAO,kBAAAC,GAAkB,OAAAC,GAAO,WAAAC,GAAW,UAAAC,GAAU,GAAGC,MAAkBX,GAC7H,EAAE,OAAAY,EAAA,IAAUC,EAAc,EAAE,MAAAZ,GAAM,SAAAC,GAAS,OAAAI,GAAO,cAAAH,GAAc,UAAAC,GAAU,kBAAAG,GAAkB,GAE5FO,IAAqBC;AAAA,IACzB,CAACC,MAAqB;AACpB,MAAAJ,EAAM,SAASI,CAAO;AAAA,IACxB;AAAA,IACA,CAACJ,CAAK;AAAA,EAAA;AAGR,SACE,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAAhB;AAAA,MACA,MAAAD;AAAA,MACA,cAAAE;AAAA,MACA,UAAAC;AAAA,MACA,OAAAE;AAAA,MACA,kBAAAC;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAK,QAEP,gBAAAO,EAACC,GAAA,EAAU,GAAGT,GAAe,WAAU,mDACrC,UAAA;AAAA,QAAA,gBAAAM,EAACI,GAAA,EAAa,GAAIZ,GAAW,oBAAoB,CAAA,GAC/C,UAAA,gBAAAQ;AAAA,UAACK;AAAA,UAAA;AAAA,YACE,GAAIb,GAAW,iBAAiB,CAAA;AAAA,YAChC,GAAGG;AAAAA,YACJ,SAASA,EAAM;AAAA,YACf,iBAAiBE;AAAA,YACjB,iBAAeJ;AAAA,YACf,UAAUN,KAAYC;AAAA,UAAA;AAAA,QAAA,GAE1B;AAAA,QACA,gBAAAc,EAACI,GAAA,EAAW,GAAId,GAAW,kBAAkB,CAAA,GAAK,WAAWe,EAAG,aAAaf,GAAW,gBAAgB,SAAS,GAC9G,UAAA;AAAA,UAAAD;AAAA,UACAE,KAAY,gBAAAO,EAAC,QAAA,EAAK,WAAU,iCAAgC,UAAA,IAAA,CAAC;AAAA,QAAA,GAChE;AAAA,0BACCQ,GAAA,EAAa,GAAIhB,GAAW,oBAAoB,CAAA,EAAC,CAAI;AAAA,MAAA,GACxD;AAAA,IAEJ;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"formcheckbox.es.js","sources":["../src/components/form-checkbox/FormCheckbox.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport { FormControl, FormField, FormItem, FormLabel, FormMessage } from \"../form/Form\";\r\nimport { SlotProps } from \"@radix-ui/react-slot\";\r\nimport { Control, ControllerProps, FieldPath, FieldValues, useController } from \"react-hook-form\";\r\nimport { Checkbox, CheckboxProps } from \"../checkbox/Checkbox\";\r\nimport { useCallback } from \"react\";\r\nimport { cn } from \"../../lib/utils\";\r\n\r\ntype FormCheckboxProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = Omit<\r\n ControllerProps<TFieldValues, TName>,\r\n \"render\"\r\n> &\r\n React.ComponentProps<typeof FormItem> & {\r\n label: string;\r\n control: Control<TFieldValues>;\r\n required?: boolean;\r\n readOnly?: boolean;\r\n slotProps?: {\r\n formLabelProps?: React.HTMLAttributes<HTMLLabelElement> & React.RefAttributes<HTMLLabelElement>;\r\n formMessageProps?: React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>;\r\n formControlProps?: Omit<SlotProps & React.RefAttributes<HTMLElement>, \"ref\"> & React.RefAttributes<HTMLElement>;\r\n checkboxProps?: CheckboxProps;\r\n };\r\n };\r\n\r\nconst FormCheckbox = <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>>(props: FormCheckboxProps<TFieldValues, TName>) => {\r\n const { name, control, defaultValue, disabled, readOnly, rules, shouldUnregister, label, slotProps, required, ...formItemProps } = props;\r\n const { field } = useController({ name, control, rules, defaultValue, disabled, shouldUnregister });\r\n\r\n const handleCheckChanged = useCallback(\r\n (checked: boolean) => {\r\n field.onChange(checked);\r\n },\r\n [field],\r\n );\r\n\r\n return (\r\n <FormField\r\n control={control}\r\n name={name}\r\n defaultValue={defaultValue}\r\n disabled={disabled}\r\n rules={rules}\r\n shouldUnregister={shouldUnregister}\r\n render={({ field }) => {\r\n return (\r\n <FormItem {...formItemProps} className=\"mtx-flex mtx-items-center mtx-gap-2 mtx-justify-start mtx-space-y-0\">\r\n <FormControl {...(slotProps?.formControlProps ?? {})}>\r\n <Checkbox\r\n {...(slotProps?.checkboxProps ?? {})}\r\n {...field}\r\n checked={field.value}\r\n onCheckedChange={handleCheckChanged}\r\n aria-required={required}\r\n disabled={disabled || readOnly}\r\n />\r\n </FormControl>\r\n <FormLabel {...(slotProps?.formLabelProps ?? {})} className={cn(\"mtx-text-text\", slotProps?.formLabelProps?.className)}>\r\n {label}\r\n {required && <span className=\"mtx-text-danger mtx-text-sm mtx-leading-4\">*</span>}\r\n </FormLabel>\r\n <FormMessage {...(slotProps?.formMessageProps ?? {})} />\r\n </FormItem>\r\n );\r\n }}\r\n />\r\n );\r\n};\r\nexport { FormCheckbox, type FormCheckboxProps };\r\n"],"names":["FormCheckbox","props","name","control","defaultValue","disabled","readOnly","rules","shouldUnregister","label","slotProps","required","formItemProps","field","useController","handleCheckChanged","useCallback","checked","jsx","FormField","jsxs","FormItem","FormControl","Checkbox","FormLabel","cn","FormMessage"],"mappings":";;;;;;AA0BA,MAAMA,IAAe,CAA0EC,MAAkD;AAC/I,QAAM,EAAE,MAAAC,GAAM,SAAAC,GAAS,cAAAC,GAAc,UAAAC,GAAU,UAAAC,GAAU,OAAAC,GAAO,kBAAAC,GAAkB,OAAAC,GAAO,WAAAC,GAAW,UAAAC,GAAU,GAAGC,MAAkBX,GAC7H,EAAE,OAAAY,EAAA,IAAUC,EAAc,EAAE,MAAAZ,GAAM,SAAAC,GAAS,OAAAI,GAAO,cAAAH,GAAc,UAAAC,GAAU,kBAAAG,GAAkB,GAE5FO,IAAqBC;AAAA,IACzB,CAACC,MAAqB;AACpB,MAAAJ,EAAM,SAASI,CAAO;AAAA,IACxB;AAAA,IACA,CAACJ,CAAK;AAAA,EAAA;AAGR,SACE,gBAAAK;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAAhB;AAAA,MACA,MAAAD;AAAA,MACA,cAAAE;AAAA,MACA,UAAAC;AAAA,MACA,OAAAE;AAAA,MACA,kBAAAC;AAAA,MACA,QAAQ,CAAC,EAAE,OAAAK,QAEP,gBAAAO,EAACC,GAAA,EAAU,GAAGT,GAAe,WAAU,uEACrC,UAAA;AAAA,QAAA,gBAAAM,EAACI,GAAA,EAAa,GAAIZ,GAAW,oBAAoB,CAAA,GAC/C,UAAA,gBAAAQ;AAAA,UAACK;AAAA,UAAA;AAAA,YACE,GAAIb,GAAW,iB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