@rovula/ui 0.1.7 → 0.1.8

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 (196) hide show
  1. package/dist/cjs/bundle.css +281 -124
  2. package/dist/cjs/bundle.js +1545 -1545
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/AlertDialog/AlertDialog.stories.d.ts +3 -0
  5. package/dist/cjs/types/components/Dialog/Dialog.d.ts +7 -1
  6. package/dist/cjs/types/components/Dialog/Dialog.stories.d.ts +3 -0
  7. package/dist/cjs/types/components/Dropdown/Dropdown.d.ts +2 -0
  8. package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +2 -0
  9. package/dist/cjs/types/components/Form/Field.d.ts +26 -0
  10. package/dist/cjs/types/components/Form/FieldMessage.d.ts +7 -0
  11. package/dist/cjs/types/components/Form/Form.d.ts +49 -11
  12. package/dist/cjs/types/components/Form/Form.stories.d.ts +23 -0
  13. package/dist/cjs/types/components/Form/ValidationHintList.d.ts +17 -0
  14. package/dist/cjs/types/components/Form/ValidationHintList.stories.d.ts +9 -0
  15. package/dist/cjs/types/components/Form/index.d.ts +10 -0
  16. package/dist/cjs/types/components/Form/useOptionBridge.d.ts +17 -0
  17. package/dist/cjs/types/components/OtpInput/OtpInput.d.ts +17 -0
  18. package/dist/cjs/types/components/OtpInput/OtpInput.stories.d.ts +15 -0
  19. package/dist/cjs/types/components/OtpInput/OtpInputGroup.d.ts +25 -0
  20. package/dist/cjs/types/components/OtpInput/index.d.ts +5 -0
  21. package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +3 -0
  22. package/dist/cjs/types/index.d.ts +5 -0
  23. package/dist/cjs/types/theme/ThemeColorCoverageRuntime.stories.d.ts +10 -0
  24. package/dist/cjs/types/utils/colors.d.ts +84 -0
  25. package/dist/components/ActionButton/ActionButton.stories.js +2 -2
  26. package/dist/components/ActionButton/ActionButton.styles.js +1 -1
  27. package/dist/components/AlertDialog/AlertDialog.js +6 -6
  28. package/dist/components/AlertDialog/AlertDialog.stories.js +3 -0
  29. package/dist/components/Avatar/Avatar.stories.js +1 -1
  30. package/dist/components/Avatar/Avatar.styles.js +1 -1
  31. package/dist/components/Avatar/AvatarBase.js +1 -1
  32. package/dist/components/Avatar/AvatarGroup.stories.js +1 -1
  33. package/dist/components/Button/Buttons.stories.js +2 -2
  34. package/dist/components/Calendar/Calendar.js +1 -1
  35. package/dist/components/Checkbox/Checkbox.js +1 -1
  36. package/dist/components/Checkbox/Checkbox.stories.js +17 -7
  37. package/dist/components/Collapsible/Collapsible.styles.js +1 -1
  38. package/dist/components/DataTable/DataTable.js +2 -2
  39. package/dist/components/Dialog/Dialog.js +12 -7
  40. package/dist/components/Dialog/Dialog.stories.js +90 -2
  41. package/dist/components/Dropdown/Dropdown.js +2 -2
  42. package/dist/components/DropdownMenu/DropdownMenu.js +3 -3
  43. package/dist/components/FocusedScrollView/FocusedScrollView.stories.js +6 -6
  44. package/dist/components/Form/Field.js +60 -0
  45. package/dist/components/Form/FieldMessage.js +24 -0
  46. package/dist/components/Form/Form.js +73 -41
  47. package/dist/components/Form/Form.stories.js +221 -0
  48. package/dist/components/Form/ValidationHintList.js +30 -0
  49. package/dist/components/Form/ValidationHintList.stories.js +50 -0
  50. package/dist/components/Form/index.js +5 -0
  51. package/dist/components/Form/useOptionBridge.js +27 -0
  52. package/dist/components/InputFilter/InputFilter.js +5 -4
  53. package/dist/components/InputFilter/InputFilter.stories.js +1 -1
  54. package/dist/components/InputFilter/InputFilter.styles.js +14 -1
  55. package/dist/components/Label/Label.styles.js +1 -1
  56. package/dist/components/Menu/Menu.js +2 -2
  57. package/dist/components/NumberInput/NumberInput.stories.js +1 -1
  58. package/dist/components/OtpInput/OtpInput.js +118 -0
  59. package/dist/components/OtpInput/OtpInput.stories.js +60 -0
  60. package/dist/components/OtpInput/OtpInputGroup.js +23 -0
  61. package/dist/components/OtpInput/index.js +3 -0
  62. package/dist/components/PasswordInput/PasswordInput.stories.js +1 -1
  63. package/dist/components/Popover/Popover.js +1 -1
  64. package/dist/components/RadioGroup/RadioGroup.js +1 -1
  65. package/dist/components/RadioGroup/RadioGroup.stories.js +2 -2
  66. package/dist/components/Search/Search.js +13 -1
  67. package/dist/components/Search/Search.stories.js +1 -1
  68. package/dist/components/Slider/Slider.js +1 -1
  69. package/dist/components/Slider/Slider.stories.js +5 -5
  70. package/dist/components/Switch/Switch.stories.js +2 -2
  71. package/dist/components/Table/Table.js +5 -5
  72. package/dist/components/Tabs/Tabs.js +12 -9
  73. package/dist/components/Tabs/Tabs.stories.js +1 -1
  74. package/dist/components/Text/Text.js +1 -1
  75. package/dist/components/Text/Text.stories.js +1 -1
  76. package/dist/components/TextArea/TextArea.stories.js +1 -1
  77. package/dist/components/TextArea/TextArea.styles.js +3 -3
  78. package/dist/components/TextInput/TextInput.js +3 -2
  79. package/dist/components/TextInput/TextInput.stories.js +3 -3
  80. package/dist/components/TextInput/TextInput.styles.js +41 -19
  81. package/dist/components/Toast/Toast.js +4 -2
  82. package/dist/components/Toast/Toast.stories.js +1 -1
  83. package/dist/components/Toast/Toast.styles.js +4 -4
  84. package/dist/components/Toast/Toaster.js +2 -2
  85. package/dist/components/Tree/Tree.stories.js +1 -1
  86. package/dist/components/Tree/TreeItem.js +1 -1
  87. package/dist/esm/bundle.css +281 -124
  88. package/dist/esm/bundle.js +1545 -1545
  89. package/dist/esm/bundle.js.map +1 -1
  90. package/dist/esm/types/components/AlertDialog/AlertDialog.stories.d.ts +3 -0
  91. package/dist/esm/types/components/Dialog/Dialog.d.ts +7 -1
  92. package/dist/esm/types/components/Dialog/Dialog.stories.d.ts +3 -0
  93. package/dist/esm/types/components/Dropdown/Dropdown.d.ts +2 -0
  94. package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +2 -0
  95. package/dist/esm/types/components/Form/Field.d.ts +26 -0
  96. package/dist/esm/types/components/Form/FieldMessage.d.ts +7 -0
  97. package/dist/esm/types/components/Form/Form.d.ts +49 -11
  98. package/dist/esm/types/components/Form/Form.stories.d.ts +23 -0
  99. package/dist/esm/types/components/Form/ValidationHintList.d.ts +17 -0
  100. package/dist/esm/types/components/Form/ValidationHintList.stories.d.ts +9 -0
  101. package/dist/esm/types/components/Form/index.d.ts +10 -0
  102. package/dist/esm/types/components/Form/useOptionBridge.d.ts +17 -0
  103. package/dist/esm/types/components/OtpInput/OtpInput.d.ts +17 -0
  104. package/dist/esm/types/components/OtpInput/OtpInput.stories.d.ts +15 -0
  105. package/dist/esm/types/components/OtpInput/OtpInputGroup.d.ts +25 -0
  106. package/dist/esm/types/components/OtpInput/index.d.ts +5 -0
  107. package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +3 -0
  108. package/dist/esm/types/index.d.ts +5 -0
  109. package/dist/esm/types/theme/ThemeColorCoverageRuntime.stories.d.ts +10 -0
  110. package/dist/esm/types/utils/colors.d.ts +84 -0
  111. package/dist/index.d.ts +245 -2
  112. package/dist/index.js +3 -0
  113. package/dist/src/theme/global.css +351 -149
  114. package/dist/theme/ThemeColorCoverageRuntime.stories.js +91 -0
  115. package/dist/utils/colors.js +92 -0
  116. package/package.json +4 -2
  117. package/src/components/ActionButton/ActionButton.stories.tsx +6 -6
  118. package/src/components/ActionButton/ActionButton.styles.ts +1 -1
  119. package/src/components/AlertDialog/AlertDialog.stories.tsx +22 -0
  120. package/src/components/AlertDialog/AlertDialog.tsx +6 -6
  121. package/src/components/Avatar/Avatar.stories.tsx +1 -1
  122. package/src/components/Avatar/Avatar.styles.ts +1 -1
  123. package/src/components/Avatar/AvatarBase.tsx +1 -1
  124. package/src/components/Avatar/AvatarGroup.stories.tsx +1 -1
  125. package/src/components/Button/Buttons.stories.tsx +10 -10
  126. package/src/components/Calendar/Calendar.tsx +3 -3
  127. package/src/components/Checkbox/Checkbox.stories.tsx +35 -12
  128. package/src/components/Checkbox/Checkbox.tsx +7 -5
  129. package/src/components/Collapsible/Collapsible.styles.ts +1 -1
  130. package/src/components/DataTable/DataTable.tsx +2 -2
  131. package/src/components/Dialog/Dialog.stories.tsx +173 -0
  132. package/src/components/Dialog/Dialog.tsx +32 -15
  133. package/src/components/Dropdown/Dropdown.styles.ts +1 -1
  134. package/src/components/Dropdown/Dropdown.tsx +16 -14
  135. package/src/components/DropdownMenu/DropdownMenu.tsx +3 -3
  136. package/src/components/FocusedScrollView/FocusedScrollView.stories.tsx +10 -10
  137. package/src/components/Form/Field.tsx +160 -0
  138. package/src/components/Form/FieldMessage.tsx +38 -0
  139. package/src/components/Form/Form.docs.mdx +67 -0
  140. package/src/components/Form/Form.stories.tsx +490 -0
  141. package/src/components/Form/Form.tsx +185 -87
  142. package/src/components/Form/README.md +284 -0
  143. package/src/components/Form/ValidationHintList.stories.tsx +118 -0
  144. package/src/components/Form/ValidationHintList.tsx +82 -0
  145. package/src/components/Form/index.ts +28 -0
  146. package/src/components/Form/useOptionBridge.ts +55 -0
  147. package/src/components/InputFilter/InputFilter.stories.tsx +1 -1
  148. package/src/components/InputFilter/InputFilter.styles.ts +14 -1
  149. package/src/components/InputFilter/InputFilter.tsx +33 -28
  150. package/src/components/Label/Label.styles.ts +2 -2
  151. package/src/components/Label/Label.tsx +1 -1
  152. package/src/components/Menu/Menu.tsx +12 -12
  153. package/src/components/NumberInput/NumberInput.stories.tsx +1 -1
  154. package/src/components/OtpInput/OtpInput.stories.tsx +168 -0
  155. package/src/components/OtpInput/OtpInput.tsx +210 -0
  156. package/src/components/OtpInput/OtpInputGroup.tsx +74 -0
  157. package/src/components/OtpInput/index.ts +5 -0
  158. package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
  159. package/src/components/Popover/Popover.tsx +1 -1
  160. package/src/components/RadioGroup/RadioGroup.stories.tsx +4 -4
  161. package/src/components/RadioGroup/RadioGroup.tsx +2 -1
  162. package/src/components/Search/Search.stories.tsx +1 -1
  163. package/src/components/Search/Search.tsx +6 -2
  164. package/src/components/Slider/Slider.stories.tsx +7 -7
  165. package/src/components/Slider/Slider.tsx +1 -1
  166. package/src/components/Switch/Switch.stories.tsx +4 -4
  167. package/src/components/Table/Table.tsx +5 -5
  168. package/src/components/Tabs/Tabs.stories.tsx +1 -1
  169. package/src/components/Tabs/Tabs.tsx +29 -18
  170. package/src/components/Text/Text.stories.tsx +1 -1
  171. package/src/components/Text/Text.tsx +1 -1
  172. package/src/components/TextArea/TextArea.stories.tsx +1 -1
  173. package/src/components/TextArea/TextArea.styles.ts +3 -3
  174. package/src/components/TextInput/TextInput.stories.tsx +7 -7
  175. package/src/components/TextInput/TextInput.styles.ts +42 -19
  176. package/src/components/TextInput/TextInput.tsx +3 -1
  177. package/src/components/Toast/Toast.stories.tsx +1 -1
  178. package/src/components/Toast/Toast.styles.tsx +7 -7
  179. package/src/components/Toast/Toast.tsx +5 -4
  180. package/src/components/Toast/Toaster.tsx +17 -20
  181. package/src/components/Tree/Tree.stories.tsx +1 -1
  182. package/src/components/Tree/TreeItem.tsx +1 -1
  183. package/src/index.ts +5 -0
  184. package/src/theme/ThemeColorCoverageRuntime.stories.tsx +236 -0
  185. package/src/theme/direct-token-migration-plan.md +121 -0
  186. package/src/theme/figma-mcp-check-report.md +225 -0
  187. package/src/theme/figma-mcp-component-checklist.json +1250 -0
  188. package/src/theme/presets/colors.js +155 -44
  189. package/src/theme/themes/xspector/components/loading.css +2 -2
  190. package/src/theme/tokens/color.css +3 -3
  191. package/src/theme/tokens/components/action-button.css +1 -1
  192. package/src/theme/tokens/components/dropdown-menu.css +3 -3
  193. package/src/theme/tokens/components/loading.css +2 -2
  194. package/src/theme/tokens/components/switch.css +1 -1
  195. package/src/theme/utils.js +164 -25
  196. package/src/utils/colors.ts +92 -0
@@ -111,8 +111,8 @@ const previewStates = [
111
111
  { label: "Disable", isLoading: false, disabled: true },
112
112
  ];
113
113
  export const FigmaPreview = {
114
- render: () => (_jsx("div", { className: "bg-base-bg2 p-8 min-h-screen", children: _jsx("div", { className: "flex flex-col gap-10", children: previewColors.map((color) => (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("h3", { className: "text-xl font-semibold tracking-wide text-text-white capitalize", children: [color, " btn"] }), previewStates.map((state) => (_jsx("div", { className: "grid grid-cols-[repeat(3,minmax(0,1fr))] items-stretch gap-2", children: previewStyles.map((style) => (_jsxs("div", { className: "h-full rounded-lg border border-base-bg-stroke1 bg-base-bg1 p-3", children: [_jsxs("span", { className: "text-xs font-semibold tracking-wide text-text-white uppercase", children: [style.label, " (", state.label, ")"] }), _jsx("div", { className: "mt-3 flex flex-col gap-2", children: previewSizes.map((size) => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { color: color, variant: style.variant, size: size, title: previewSizeLabel[size], startIcon: icon, isLoading: state.isLoading, disabled: state.disabled, fullwidth: false }), _jsx(Button, { color: color, variant: style.variant, size: size, title: previewSizeLabel[size], isLoading: state.isLoading, disabled: state.disabled, fullwidth: false }), _jsx(Button, { color: color, variant: style.variant, size: size, title: previewSizeLabel[size], endIcon: icon, isLoading: state.isLoading, disabled: state.disabled, fullwidth: false })] }, size))) })] }, style.label))) }, state.label)))] }, color))) }) })),
114
+ render: () => (_jsx("div", { className: "bg-bg-bg2 p-8 min-h-screen", children: _jsx("div", { className: "flex flex-col gap-10", children: previewColors.map((color) => (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("h3", { className: "text-xl font-semibold tracking-wide text-text-contrast-max capitalize", children: [color, " btn"] }), previewStates.map((state) => (_jsx("div", { className: "grid grid-cols-[repeat(3,minmax(0,1fr))] items-stretch gap-2", children: previewStyles.map((style) => (_jsxs("div", { className: "h-full rounded-lg border border-bg-stroke1 bg-bg-bg1 p-3", children: [_jsxs("span", { className: "text-xs font-semibold tracking-wide text-text-contrast-max uppercase", children: [style.label, " (", state.label, ")"] }), _jsx("div", { className: "mt-3 flex flex-col gap-2", children: previewSizes.map((size) => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { color: color, variant: style.variant, size: size, title: previewSizeLabel[size], startIcon: icon, isLoading: state.isLoading, disabled: state.disabled, fullwidth: false }), _jsx(Button, { color: color, variant: style.variant, size: size, title: previewSizeLabel[size], isLoading: state.isLoading, disabled: state.disabled, fullwidth: false }), _jsx(Button, { color: color, variant: style.variant, size: size, title: previewSizeLabel[size], endIcon: icon, isLoading: state.isLoading, disabled: state.disabled, fullwidth: false })] }, size))) })] }, style.label))) }, state.label)))] }, color))) }) })),
115
115
  };
116
116
  export const FigmaPreviewCapsule = {
117
- render: () => (_jsx("div", { className: "bg-base-bg2 p-8 min-h-screen", children: _jsx("div", { className: "flex flex-col gap-10", children: previewColors.map((color) => (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("h3", { className: "text-xl font-semibold tracking-wide text-text-white capitalize", children: [color, " btn"] }), previewStates.map((state) => (_jsx("div", { className: "grid grid-cols-[repeat(3,minmax(0,1fr))] items-stretch gap-4", children: previewStyles.map((style) => (_jsxs("div", { className: "h-full rounded-lg border border-base-bg-stroke1 bg-base-bg1 p-3", children: [_jsxs("span", { className: "text-xs font-semibold tracking-wide text-text-white uppercase", children: [style.label, " (", state.label, ")"] }), _jsx("div", { className: "mt-3 flex flex-col gap-2", children: previewSizes.map((size) => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { color: color, variant: style.variant, size: size, shape: "capsule", title: previewSizeLabel[size], startIcon: icon, isLoading: state.isLoading, disabled: state.disabled, fullwidth: false }), _jsx(Button, { color: color, variant: style.variant, size: size, shape: "capsule", title: previewSizeLabel[size], isLoading: state.isLoading, disabled: state.disabled, fullwidth: false }), _jsx(Button, { color: color, variant: style.variant, size: size, shape: "capsule", title: previewSizeLabel[size], endIcon: icon, isLoading: state.isLoading, disabled: state.disabled, fullwidth: false })] }, size))) })] }, style.label))) }, state.label)))] }, color))) }) })),
117
+ render: () => (_jsx("div", { className: "bg-bg-bg2 p-8 min-h-screen", children: _jsx("div", { className: "flex flex-col gap-10", children: previewColors.map((color) => (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("h3", { className: "text-xl font-semibold tracking-wide text-text-contrast-max capitalize", children: [color, " btn"] }), previewStates.map((state) => (_jsx("div", { className: "grid grid-cols-[repeat(3,minmax(0,1fr))] items-stretch gap-4", children: previewStyles.map((style) => (_jsxs("div", { className: "h-full rounded-lg border border-bg-stroke1 bg-bg-bg1 p-3", children: [_jsxs("span", { className: "text-xs font-semibold tracking-wide text-text-contrast-max uppercase", children: [style.label, " (", state.label, ")"] }), _jsx("div", { className: "mt-3 flex flex-col gap-2", children: previewSizes.map((size) => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { color: color, variant: style.variant, size: size, shape: "capsule", title: previewSizeLabel[size], startIcon: icon, isLoading: state.isLoading, disabled: state.disabled, fullwidth: false }), _jsx(Button, { color: color, variant: style.variant, size: size, shape: "capsule", title: previewSizeLabel[size], isLoading: state.isLoading, disabled: state.disabled, fullwidth: false }), _jsx(Button, { color: color, variant: style.variant, size: size, shape: "capsule", title: previewSizeLabel[size], endIcon: icon, isLoading: state.isLoading, disabled: state.disabled, fullwidth: false })] }, size))) })] }, style.label))) }, state.label)))] }, color))) }) })),
118
118
  };
@@ -17,7 +17,7 @@ import { cn } from "@/utils/cn";
17
17
  function Calendar(_a) {
18
18
  var { className, classNames, showOutsideDays = true } = _a, props = __rest(_a, ["className", "classNames", "showOutsideDays"]);
19
19
  const defaultClassNames = getDefaultClassNames();
20
- return (_jsx(DayPicker, Object.assign({ showOutsideDays: showOutsideDays, captionLayout: "dropdown-years" }, props, { className: cn("bg-surface text-surface-foreground border-surface", className), classNames: Object.assign(Object.assign(Object.assign({}, defaultClassNames), { day_button: cn(defaultClassNames.day_button, "size-9"), day: "typography-subtitle1 ", today: "text-bold text-surface-foreground [&_button]:rounded-full [&_button]:!border-primary [&_button]:!border [&_button]:!border-solid", selected: "bg-primary !text-primary-foreground rounded-full ", weekdays: "text-gray-400", month_caption: cn(defaultClassNames.month_caption, "h-[54px]"), outside: "text-gray-400", nav: cn(defaultClassNames.nav, "gap-6 absolute flex right-0"), chevron: "fill-primary", root: cn(defaultClassNames.root, "px-6 py-4"), caption_label: cn(defaultClassNames.caption_label, "gap-2 flex items-center"), months: "flex flex-col relative", disabled: "[&_button]:rounded-full [&_button]:!text-input-disable-text" }), classNames), styles: {
20
+ return (_jsx(DayPicker, Object.assign({ showOutsideDays: showOutsideDays, captionLayout: "dropdown-years" }, props, { className: cn("bg-bg-bg1 text-common-black border-bg-bg1", className), classNames: Object.assign(Object.assign(Object.assign({}, defaultClassNames), { day_button: cn(defaultClassNames.day_button, "size-9"), day: "typography-subtitle1 ", today: "text-bold text-common-black [&_button]:rounded-full [&_button]:!border-primary [&_button]:!border [&_button]:!border-solid", selected: "bg-primary !text-state-primary-text-solid rounded-full ", weekdays: "text-gray-400", month_caption: cn(defaultClassNames.month_caption, "h-[54px]"), outside: "text-gray-400", nav: cn(defaultClassNames.nav, "gap-6 absolute flex right-0"), chevron: "fill-primary", root: cn(defaultClassNames.root, "px-6 py-4"), caption_label: cn(defaultClassNames.caption_label, "gap-2 flex items-center"), months: "flex flex-col relative", disabled: "[&_button]:rounded-full [&_button]:!text-input-disable-text" }), classNames), styles: {
21
21
  caption_label: {
22
22
  zIndex: 1,
23
23
  position: "relative",
@@ -17,7 +17,7 @@ import { CheckIcon, MinusIcon } from "@heroicons/react/16/solid";
17
17
  import { cn } from "@/utils/cn";
18
18
  const Checkbox = React.forwardRef((_a, ref) => {
19
19
  var { className } = _a, props = __rest(_a, ["className"]);
20
- return (_jsx(CheckboxPrimitive.Root, Object.assign({ ref: ref, className: cn("peer size-4 shrink-0 cursor-pointer rounded-[var(--spacing-spacing-xxs,2px)] border border-function-default-solid ring-offset-background", "hover:border-function-default-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:border-state-disable-solid disabled:text-state-disable-outline disabled:data-[state=checked]:bg-state-disable-solid disabled:data-[state=indeterminate]:bg-state-disable-solid", {
20
+ return (_jsx(CheckboxPrimitive.Root, Object.assign({ ref: ref, className: cn("peer size-4 shrink-0 cursor-pointer rounded-[var(--spacing-spacing-xxs,2px)] border border-function-default-solid ring-offset-bg-bg1", "hover:border-function-default-hover", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-input-active-stroke focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:border-state-disable-outline disabled:text-state-disable-outline", "disabled:data-[state=checked]:border-state-disable-solid disabled:data-[state=checked]:bg-state-disable-solid", "disabled:data-[state=indeterminate]:border-state-disable-solid disabled:data-[state=indeterminate]:bg-state-disable-solid", {
21
21
  "data-[state=checked]:border-function-active-solid data-[state=checked]:bg-function-active-solid data-[state=checked]:text-function-active-icon data-[state=indeterminate]:border-function-active-solid data-[state=indeterminate]:bg-function-active-solid data-[state=indeterminate]:text-function-active-icon": !props.disabled,
22
22
  "hover:data-[state=checked]:border-function-active-hover hover:data-[state=checked]:bg-function-active-hover hover:data-[state=indeterminate]:border-function-active-hover hover:data-[state=indeterminate]:bg-function-active-hover": !props.disabled,
23
23
  }, className) }, props, { children: _jsxs(CheckboxPrimitive.Indicator, { className: cn("flex size-[14px] items-center justify-center text-current", "[&[data-state=checked]_.checkbox-check-icon]:block", "[&[data-state=indeterminate]_.checkbox-minus-icon]:block"), children: [_jsx(CheckIcon, { className: "checkbox-check-icon hidden size-[14px]" }), _jsx(MinusIcon, { className: "checkbox-minus-icon hidden size-[14px]" })] }) })));
@@ -8,7 +8,7 @@ const meta = {
8
8
  layout: "fullscreen",
9
9
  },
10
10
  decorators: [
11
- (Story) => (_jsx("div", { className: "p-5 flex w-full bg-base-bg2", children: _jsx(Story, {}) })),
11
+ (Story) => (_jsx("div", { className: "p-5 flex w-full bg-bg-bg2", children: _jsx(Story, {}) })),
12
12
  ],
13
13
  };
14
14
  export default meta;
@@ -19,26 +19,30 @@ export const Default = {
19
19
  },
20
20
  render: (args) => {
21
21
  const props = Object.assign({}, args);
22
- return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(Checkbox, Object.assign({ id: "terms" }, props)), _jsx("label", { htmlFor: "terms", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Accept terms and conditions" })] }) }));
22
+ return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(Checkbox, Object.assign({ id: "terms" }, props)), _jsx("label", { htmlFor: "terms", className: "text-sm font-medium leading-none text-text-contrast-max peer-disabled:cursor-not-allowed peer-disabled:text-state-disable-outline", children: "Accept terms and conditions" })] }) }));
23
23
  },
24
24
  };
25
25
  export const WithText = {
26
26
  args: {},
27
27
  render: (args) => {
28
28
  const props = Object.assign({}, args);
29
- return (_jsxs("div", { className: "items-top flex space-x-2", children: [_jsx(Checkbox, { id: "terms1" }), _jsxs("div", { className: "grid gap-1.5 leading-none", children: [_jsx("label", { htmlFor: "terms1", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Accept terms and conditions" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "You agree to our Terms of Service and Privacy Policy." })] })] }));
29
+ return (_jsxs("div", { className: "items-top flex space-x-2", children: [_jsx(Checkbox, { id: "terms1" }), _jsxs("div", { className: "grid gap-1.5 leading-none", children: [_jsx("label", { htmlFor: "terms1", className: "text-sm font-medium leading-none text-text-contrast-max peer-disabled:cursor-not-allowed peer-disabled:text-state-disable-outline", children: "Accept terms and conditions" }), _jsx("p", { className: "text-sm text-text-g-contrast-medium", children: "You agree to our Terms of Service and Privacy Policy." })] })] }));
30
30
  },
31
31
  };
32
32
  export const Disabled = {
33
33
  args: {},
34
34
  render: (args) => {
35
35
  const props = Object.assign({}, args);
36
- return (_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(Checkbox, { id: "terms2", disabled: true }), _jsx("label", { htmlFor: "terms2", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Accept terms and conditions" })] }));
36
+ return (_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(Checkbox, { id: "terms2", disabled: true }), _jsx("label", { htmlFor: "terms2", className: "text-sm font-medium leading-none text-state-disable-outline peer-disabled:cursor-not-allowed", children: "Accept terms and conditions" })] }));
37
37
  },
38
38
  };
39
39
  const checkboxPreviewRows = [
40
40
  { label: "Default", checked: false },
41
- { label: "Hover", checked: false, className: "!border-function-default-hover" },
41
+ {
42
+ label: "Hover",
43
+ checked: false,
44
+ className: "!border-function-default-hover",
45
+ },
42
46
  { label: "Disable", checked: false, disabled: true },
43
47
  { label: "Checked", checked: true },
44
48
  {
@@ -53,8 +57,14 @@ const checkboxPreviewRows = [
53
57
  checked: "indeterminate",
54
58
  className: "!data-[state=indeterminate]:border-function-active-hover !data-[state=indeterminate]:bg-function-active-hover",
55
59
  },
56
- { label: "Indeterminate - Disable", checked: "indeterminate", disabled: true },
60
+ {
61
+ label: "Indeterminate - Disable",
62
+ checked: "indeterminate",
63
+ disabled: true,
64
+ },
57
65
  ];
58
66
  export const FigmaPreview = {
59
- render: () => (_jsx("div", { className: "bg-base-bg2 p-8 min-h-screen", children: _jsx("div", { className: "mx-auto flex w-full max-w-[360px] flex-col gap-4 rounded-lg border border-base-bg-stroke1 bg-base-bg1 p-6", children: checkboxPreviewRows.map((row) => (_jsxs("div", { className: "grid grid-cols-[160px_16px] items-center gap-4", children: [_jsx("span", { className: "text-sm font-medium text-text-white", children: row.label }), _jsx(Checkbox, { checked: row.checked, disabled: row.disabled, className: row.className })] }, row.label))) }) })),
67
+ render: () => (_jsx("div", { className: "bg-bg-bg2 p-8 min-h-screen", children: _jsx("div", { className: "mx-auto flex w-full max-w-[360px] flex-col gap-4 rounded-lg border border-bg-stroke1 bg-bg-bg1 p-6", children: checkboxPreviewRows.map((row) => (_jsxs("div", { className: "grid grid-cols-[160px_16px] items-center gap-4", children: [_jsx("span", { className: `text-sm font-medium ${row.disabled
68
+ ? "text-state-disable-outline"
69
+ : "text-text-contrast-max"}`, children: row.label }), _jsx(Checkbox, { checked: row.checked, disabled: row.disabled, className: row.className })] }, row.label))) }) })),
60
70
  };
@@ -1,6 +1,6 @@
1
1
  import { cva } from "class-variance-authority";
2
2
  export const collapseButtonVariants = cva([
3
- "flex flex-1 bg-secondary-default hover:bg-secondary-hover text-secondary-foreground",
3
+ "flex flex-1 bg-secondary-default hover:bg-secondary-hover text-state-secondary-text-solid",
4
4
  "focus:outline-none focus-visible:ring focus-visible:ring-gray-500 focus-visible:ring-opacity-75",
5
5
  ], {
6
6
  variants: {
@@ -65,6 +65,6 @@ export function DataTable({ data, columns, manualSorting = false, onSorting, fet
65
65
  : flexRender(header.column.columnDef.header, header.getContext()), (_a = {
66
66
  asc: _jsx(ArrowUpIcon, { className: "ml-3 h-4 w-4" }),
67
67
  desc: _jsx(ArrowDownIcon, { className: "ml-3 h-4 w-4" }),
68
- }[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : (header.column.getCanSort() ? (_jsx(ArrowsUpDownIcon, { className: "ml-3 h-4 w-4 text-text-grey-light" })) : null)] }) }, header.id));
69
- }) }, headerGroup.id))) }), _jsx(TableBody, { className: "overflow-y-scroll", children: !isEmpty ? (table.getRowModel().rows.map((row) => (_jsx(TableRow, { "data-state": row.getIsSelected() && "selected", className: "", children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id)))) : (_jsx(TableRow, { className: "h-full self-stretch", children: _jsx(TableCell, { colSpan: columns.length, className: "typography-body1 text-text-grey-medium text-center h-full", children: _jsxs("div", { className: "flex flex-1 h-full flex-col items-center justify-center gap-3", children: [_jsx(ClipboardDocumentListIcon, { className: "w-8 text-secondary-120" }), "There is no information yet."] }) }) })) })] }) }));
68
+ }[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : (header.column.getCanSort() ? (_jsx(ArrowsUpDownIcon, { className: "ml-3 h-4 w-4 text-text-g-contrast-high" })) : null)] }) }, header.id));
69
+ }) }, headerGroup.id))) }), _jsx(TableBody, { className: "overflow-y-scroll", children: !isEmpty ? (table.getRowModel().rows.map((row) => (_jsx(TableRow, { "data-state": row.getIsSelected() && "selected", className: "", children: row.getVisibleCells().map((cell) => (_jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id)))) : (_jsx(TableRow, { className: "h-full self-stretch", children: _jsx(TableCell, { colSpan: columns.length, className: "typography-body1 text-text-g-contrast-medium text-center h-full", children: _jsxs("div", { className: "flex flex-1 h-full flex-col items-center justify-center gap-3", children: [_jsx(ClipboardDocumentListIcon, { className: "w-8 text-secondary-120" }), "There is no information yet."] }) }) })) })] }) }));
70
70
  }
@@ -21,32 +21,37 @@ const DialogPortal = DialogPrimitive.Portal;
21
21
  const DialogClose = DialogPrimitive.Close;
22
22
  const DialogOverlay = React.forwardRef((_a, ref) => {
23
23
  var { className } = _a, props = __rest(_a, ["className"]);
24
- return (_jsx(DialogPrimitive.Overlay, Object.assign({ ref: ref, className: cn("fixed inset-0 z-50 bg-base-popup-curtain data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className) }, props)));
24
+ return (_jsx(DialogPrimitive.Overlay, Object.assign({ ref: ref, className: cn("fixed inset-0 z-50 bg-modal-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className) }, props)));
25
25
  });
26
26
  DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
27
27
  const DialogContent = React.forwardRef((_a, ref) => {
28
28
  var { className, children, showCloseButton = false, closeButtonClassName } = _a, props = __rest(_a, ["className", "children", "showCloseButton", "closeButtonClassName"]);
29
- return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, Object.assign({ ref: ref, className: cn("fixed text-base-popup-foreground left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-base-popup bg-base-popup 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-md", className) }, props, { children: [children, showCloseButton && (_jsxs(DialogPrimitive.Close, { className: cn("absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-primary data-[state=open]:text-primary-foreground", closeButtonClassName), children: [_jsx(XMarkIcon, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: "Close" })] }))] }))] }));
29
+ return (_jsxs(DialogPortal, { children: [_jsx(DialogOverlay, {}), _jsxs(DialogPrimitive.Content, Object.assign({ ref: ref, className: cn("fixed left-[50%] top-[50%] z-50 flex w-[calc(100%-32px)] max-w-[650px] translate-x-[-50%] translate-y-[-50%] flex-col rounded-md bg-modal-surface p-8 text-text-g-contrast-medium shadow-[0px_12px_24px_-4px_rgba(0,0,0,0.12)] 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%]", className) }, props, { children: [children, showCloseButton && (_jsxs(DialogPrimitive.Close, { className: cn("absolute right-8 top-8 rounded-sm opacity-70 ring-offset-bg-bg1 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-input-active-stroke focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-primary data-[state=open]:text-state-primary-text-solid", closeButtonClassName), children: [_jsx(XMarkIcon, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: "Close" })] }))] }))] }));
30
30
  });
31
31
  DialogContent.displayName = DialogPrimitive.Content.displayName;
32
32
  const DialogHeader = (_a) => {
33
33
  var { className } = _a, props = __rest(_a, ["className"]);
34
- return (_jsx("div", Object.assign({ className: cn("flex flex-col space-y-2 text-center sm:text-left", className) }, props)));
34
+ return (_jsx("div", Object.assign({ className: cn("flex flex-col gap-2 text-left", className) }, props)));
35
35
  };
36
36
  DialogHeader.displayName = "DialogHeader";
37
+ const DialogBody = (_a) => {
38
+ var { className, scrollable = false } = _a, props = __rest(_a, ["className", "scrollable"]);
39
+ return (_jsx("div", Object.assign({ className: cn("flex flex-1 min-h-0 flex-col mt-8", scrollable && "overflow-y-auto", className) }, props)));
40
+ };
41
+ DialogBody.displayName = "DialogBody";
37
42
  const DialogFooter = (_a) => {
38
43
  var { className } = _a, props = __rest(_a, ["className"]);
39
- return (_jsx("div", Object.assign({ className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 ", className) }, props)));
44
+ return (_jsx("div", Object.assign({ className: cn("flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-end sm:gap-6", className) }, props)));
40
45
  };
41
46
  DialogFooter.displayName = "DialogFooter";
42
47
  const DialogTitle = React.forwardRef((_a, ref) => {
43
48
  var { className } = _a, props = __rest(_a, ["className"]);
44
- return (_jsx(DialogPrimitive.Title, Object.assign({ ref: ref, className: cn("typography-h5 tracking-tight ", className) }, props)));
49
+ return (_jsx(DialogPrimitive.Title, Object.assign({ ref: ref, className: cn("typography-h4 tracking-tight text-text-contrast-max", className) }, props)));
45
50
  });
46
51
  DialogTitle.displayName = DialogPrimitive.Title.displayName;
47
52
  const DialogDescription = React.forwardRef((_a, ref) => {
48
53
  var { className } = _a, props = __rest(_a, ["className"]);
49
- return (_jsx(DialogPrimitive.Description, Object.assign({ ref: ref, className: cn("text-sm", className) }, props)));
54
+ return (_jsx(DialogPrimitive.Description, Object.assign({ ref: ref, className: cn("typography-subtitle1 text-text-g-contrast-medium", className) }, props)));
50
55
  });
51
56
  DialogDescription.displayName = DialogPrimitive.Description.displayName;
52
- export { Dialog, DialogPortal, DialogOverlay, DialogClose, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, };
57
+ export { Dialog, DialogPortal, DialogOverlay, DialogClose, DialogTrigger, DialogContent, DialogHeader, DialogBody, DialogFooter, DialogTitle, DialogDescription, };
@@ -1,8 +1,11 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "./Dialog";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import * as yup from "yup";
3
+ import { Dialog, DialogContent, DialogDescription, DialogBody, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "./Dialog";
3
4
  import Button from "../Button/Button";
4
5
  import { Label } from "../Label/Label";
5
6
  import { Input } from "../Input/Input";
7
+ import { Field, Form, ValidationHintList } from "../Form";
8
+ import PasswordInput from "../PasswordInput";
6
9
  const meta = {
7
10
  title: "Components/Dialog",
8
11
  component: Dialog,
@@ -39,3 +42,88 @@ export const Demo = {
39
42
  return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsxs(Dialog, { children: [_jsx(DialogTrigger, { asChild: true, children: _jsx(Button, { variant: "outline", children: "Edit Profile" }) }), _jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Edit profile" }), _jsx(DialogDescription, { children: "Make changes to your profile here. Click save when you're done." })] }), _jsxs("div", { className: "grid gap-4 py-4", children: [_jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [_jsx(Label, { htmlFor: "name", className: "text-right", children: "Name" }), _jsx(Input, { id: "name", defaultValue: "Pedro Duarte", className: "col-span-3" })] }), _jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [_jsx(Label, { htmlFor: "username", className: "text-right", children: "Username" }), _jsx(Input, { id: "username", defaultValue: "@peduarte", className: "col-span-3" })] })] }), _jsx(DialogFooter, { children: _jsx(Button, { type: "submit", children: "Save changes" }) })] })] }) }));
40
43
  },
41
44
  };
45
+ const passwordHints = [
46
+ {
47
+ id: "min-length",
48
+ label: "Minimum 12 characters",
49
+ validate: (values) => values.newPassword.length >= 12,
50
+ when: (values) => Boolean(values.newPassword),
51
+ },
52
+ {
53
+ id: "lower-and-upper",
54
+ label: "At least a lower and upper case",
55
+ validate: (values) => /[a-z]/.test(values.newPassword) && /[A-Z]/.test(values.newPassword),
56
+ when: (values) => Boolean(values.newPassword),
57
+ },
58
+ {
59
+ id: "special",
60
+ label: "At least 1 special character",
61
+ validate: (values) => /[^A-Za-z0-9]/.test(values.newPassword),
62
+ when: (values) => Boolean(values.newPassword),
63
+ },
64
+ {
65
+ id: "numeral",
66
+ label: "At least 1 numeral",
67
+ validate: (values) => /\d/.test(values.newPassword),
68
+ when: (values) => Boolean(values.newPassword),
69
+ },
70
+ {
71
+ id: "capital",
72
+ label: "At least 1 capital letter",
73
+ validate: (values) => /[A-Z]/.test(values.newPassword),
74
+ when: (values) => Boolean(values.newPassword),
75
+ },
76
+ {
77
+ id: "match",
78
+ label: "Password and confirmation are matching",
79
+ validate: (values) => Boolean(values.newPassword) &&
80
+ values.newPassword === values.confirmPassword,
81
+ when: (values) => Boolean(values.newPassword) && Boolean(values.confirmPassword),
82
+ },
83
+ ];
84
+ const changePasswordSchema = yup.object({
85
+ newPassword: yup
86
+ .string()
87
+ .required("New password is required")
88
+ .min(12, "Password must be at least 12 characters")
89
+ .matches(/[a-z]/, "Password must include a lowercase letter")
90
+ .matches(/[A-Z]/, "Password must include an uppercase letter")
91
+ .matches(/\d/, "Password must include a numeral")
92
+ .matches(/[^A-Za-z0-9]/, "Password must include a special character"),
93
+ confirmPassword: yup
94
+ .string()
95
+ .required("Please confirm your password")
96
+ .oneOf([yup.ref("newPassword")], "Passwords must match"),
97
+ });
98
+ export const FigmaChangePassword = {
99
+ render: () => {
100
+ return (_jsx("div", { className: "flex w-full", children: _jsx(Dialog, { defaultOpen: true, children: _jsx(DialogContent, { className: "min-h-[686px] max-w-[650px]", children: _jsx(Form, { className: "contents", defaultValues: {
101
+ newPassword: "",
102
+ confirmPassword: "",
103
+ }, mode: "onTouched", validationSchema: changePasswordSchema, onSubmit: (values) => {
104
+ // eslint-disable-next-line no-console
105
+ console.log("Change password submit:", values);
106
+ }, children: ({ formState, watch }) => {
107
+ const newPassword = watch("newPassword");
108
+ const confirmPassword = watch("confirmPassword");
109
+ return (_jsxs(_Fragment, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Welcome!" }), _jsx(DialogDescription, { children: "Please create a new password to replace the temporary password." })] }), _jsx(DialogBody, { children: _jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(Field, { name: "newPassword", component: PasswordInput, componentProps: {
110
+ id: "new-password",
111
+ label: "New password",
112
+ type: "password",
113
+ required: true,
114
+ fullwidth: true,
115
+ size: "lg",
116
+ } }), _jsx(Field, { name: "confirmPassword", component: PasswordInput, componentProps: {
117
+ id: "confirm-password",
118
+ label: "Confirm password",
119
+ type: "password",
120
+ required: true,
121
+ fullwidth: true,
122
+ size: "lg",
123
+ } }), _jsx(ValidationHintList, { values: {
124
+ newPassword: newPassword || "",
125
+ confirmPassword: confirmPassword || "",
126
+ }, rules: passwordHints })] }) }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "outline", color: "primary", size: "lg", fullwidth: false, children: "Back" }), _jsx(Button, { type: "submit", size: "lg", fullwidth: false, className: "w-[180px]", disabled: !formState.isValid || formState.isSubmitting, isLoading: formState.isSubmitting, children: "Save changes" })] })] }));
127
+ } }) }) }) }));
128
+ },
129
+ };
@@ -18,7 +18,7 @@ import { Menu } from "../Menu/Menu";
18
18
  import { ChevronDownIcon } from "@heroicons/react/16/solid";
19
19
  import { cn } from "@/utils/cn";
20
20
  const Dropdown = forwardRef((_a, ref) => {
21
- var { id, options = [], value, label, size = "md", rounded = "normal", variant = "outline", defaultMenuItemType = "checkbox", helperText, errorMessage, fullwidth = true, disabled = false, error = false, filterMode = false, required = true, modal = false, onChangeText, onSelect, renderOptions: customRenderOptions, optionContainerClassName, optionItemClassName, optionNotFoundItemClassName } = _a, props = __rest(_a, ["id", "options", "value", "label", "size", "rounded", "variant", "defaultMenuItemType", "helperText", "errorMessage", "fullwidth", "disabled", "error", "filterMode", "required", "modal", "onChangeText", "onSelect", "renderOptions", "optionContainerClassName", "optionItemClassName", "optionNotFoundItemClassName"]);
21
+ var { id, options = [], value, label, size = "md", rounded = "normal", variant = "outline", defaultMenuItemType = "checkbox", helperText, errorMessage, fullwidth = true, disabled = false, error = false, filterMode = false, required = true, modal = false, onChangeText, onSelect, renderOptions: customRenderOptions, optionContainerClassName, optionItemClassName, optionNotFoundItemClassName, segmentedInput = true } = _a, props = __rest(_a, ["id", "options", "value", "label", "size", "rounded", "variant", "defaultMenuItemType", "helperText", "errorMessage", "fullwidth", "disabled", "error", "filterMode", "required", "modal", "onChangeText", "onSelect", "renderOptions", "optionContainerClassName", "optionItemClassName", "optionNotFoundItemClassName", "segmentedInput"]);
22
22
  const _id = id || `${label}-select`;
23
23
  const [isFocused, setIsFocused] = useState(false);
24
24
  const [selectedOption, setSelectedOption] = useState(null);
@@ -192,7 +192,7 @@ const Dropdown = forwardRef((_a, ref) => {
192
192
  keyCode.current = e.code;
193
193
  (_a = props === null || props === void 0 ? void 0 : props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, e);
194
194
  }, [props === null || props === void 0 ? void 0 : props.onKeyDown]);
195
- return (_jsxs("div", { className: `relative ${fullwidth ? "w-full" : ""}`, children: [_jsx(TextInput, Object.assign({ hasClearIcon: false, endIcon: _jsx(ChevronDownIcon, { className: dropdownIconVariant({ isFocus: isFocused }) }) }, props, { ref: inputRef, readOnly: !filterMode, value: textValue, onChange: handleOnChangeText, label: label, placeholder: " ", type: "text", autoComplete: "off", rounded: rounded, variant: variant, helperText: helperText, errorMessage: errorMessage, fullwidth: fullwidth, error: error, required: required, id: _id, disabled: disabled, size: size, className: customInputVariant({ size }), onFocus: handleOnFocus, onBlur: handleOnBlur, onKeyDown: handleOnKeyDown })), isFocused &&
195
+ return (_jsxs("div", { className: `relative ${fullwidth ? "w-full" : ""}`, children: [_jsx(TextInput, Object.assign({ hasClearIcon: false, endIcon: _jsx(ChevronDownIcon, { className: dropdownIconVariant({ isFocus: isFocused }) }) }, props, { ref: inputRef, readOnly: !filterMode, value: textValue, onChange: handleOnChangeText, label: label, placeholder: " ", type: "text", autoComplete: "off", rounded: rounded, variant: variant, helperText: helperText, errorMessage: errorMessage, fullwidth: fullwidth, error: error, required: required, id: _id, disabled: disabled, size: size, className: segmentedInput ? customInputVariant({ size }) : undefined, onFocus: handleOnFocus, onBlur: handleOnBlur, onKeyDown: handleOnKeyDown })), isFocused &&
196
196
  (usePortal ? (_jsx(Portal.Root, { container: document.body, children: renderOptions() })) : (renderOptions()))] }));
197
197
  });
198
198
  export default Dropdown;
@@ -31,13 +31,13 @@ DropdownMenuSubTrigger.displayName =
31
31
  DropdownMenuPrimitive.SubTrigger.displayName;
32
32
  const DropdownMenuSubContent = React.forwardRef((_a, ref) => {
33
33
  var { className } = _a, props = __rest(_a, ["className"]);
34
- return (_jsx(DropdownMenuPrimitive.SubContent, Object.assign({ ref: ref, className: cn("z-50 min-w-[154px] overflow-hidden rounded-md bg-base-popup text-base-popup-foreground 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props, { style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, props.style) })));
34
+ return (_jsx(DropdownMenuPrimitive.SubContent, Object.assign({ ref: ref, className: cn("z-50 min-w-[154px] overflow-hidden rounded-md bg-modal-surface text-text-contrast-low 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props, { style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, props.style) })));
35
35
  });
36
36
  DropdownMenuSubContent.displayName =
37
37
  DropdownMenuPrimitive.SubContent.displayName;
38
38
  const DropdownMenuContent = React.forwardRef((_a, ref) => {
39
39
  var { className, sideOffset = 4 } = _a, props = __rest(_a, ["className", "sideOffset"]);
40
- return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, Object.assign({ ref: ref, sideOffset: sideOffset, className: cn("z-50 min-w-[154px] overflow-hidden rounded-md bg-base-popup text-base-popup-foreground 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props, { style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, props.style) })) }));
40
+ return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, Object.assign({ ref: ref, sideOffset: sideOffset, className: cn("z-50 min-w-[154px] overflow-hidden rounded-md bg-modal-surface text-text-contrast-low 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className) }, props, { style: Object.assign({ boxShadow: "var(--dropdown-menu-shadow)" }, props.style) })) }));
41
41
  });
42
42
  DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
43
43
  const DropdownMenuItem = React.forwardRef((_a, ref) => {
@@ -58,7 +58,7 @@ const DropdownMenuRadioItem = React.forwardRef((_a, ref) => {
58
58
  DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
59
59
  const DropdownMenuLabel = React.forwardRef((_a, ref) => {
60
60
  var { className, inset } = _a, props = __rest(_a, ["className", "inset"]);
61
- return (_jsx(DropdownMenuPrimitive.Label, Object.assign({ ref: ref, className: cn("px-3 py-2 typography-small4 text-text-grey-medium", inset && "pl-8", className) }, props)));
61
+ return (_jsx(DropdownMenuPrimitive.Label, Object.assign({ ref: ref, className: cn("px-3 py-2 typography-small4 text-text-g-contrast-medium", inset && "pl-8", className) }, props)));
62
62
  });
63
63
  DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
64
64
  const DropdownMenuSeparator = React.forwardRef((_a, ref) => {
@@ -15,9 +15,9 @@ const items = Array.from({ length: 30 }, (_, i) => `Item ${i + 1}`);
15
15
  export const VerticalScroll = {
16
16
  render: (args) => {
17
17
  const [selected, setSelected] = useState("item-5");
18
- return (_jsxs("div", { className: "p-6 space-y-4", children: [_jsxs("div", { className: "flex gap-2", children: [_jsx("button", { onClick: () => setSelected("item-5"), className: "px-3 py-1 bg-primary text-white rounded", children: "Scroll to Item 5" }), _jsx("button", { onClick: () => setSelected("item-20"), className: "px-3 py-1 bg-primary text-white rounded", children: "Scroll to Item 20" }), _jsx("button", { onClick: () => setSelected("item-29"), className: "px-3 py-1 bg-primary text-white rounded", children: "Scroll to Item 30" })] }), _jsx(FocusedScrollView, Object.assign({}, args, { selectedKey: selected, children: items.map((item, index) => (_jsx("div", { className: `px-4 py-2 ${selected === `item-${index + 1}`
19
- ? "bg-secondary text-secondary-foreground"
20
- : "bg-white"}`, children: item }, `item-${index + 1}`))) }))] }));
18
+ return (_jsxs("div", { className: "p-6 space-y-4", children: [_jsxs("div", { className: "flex gap-2", children: [_jsx("button", { onClick: () => setSelected("item-5"), className: "px-3 py-1 bg-primary text-state-primary-text-solid rounded", children: "Scroll to Item 5" }), _jsx("button", { onClick: () => setSelected("item-20"), className: "px-3 py-1 bg-primary text-state-primary-text-solid rounded", children: "Scroll to Item 20" }), _jsx("button", { onClick: () => setSelected("item-29"), className: "px-3 py-1 bg-primary text-state-primary-text-solid rounded", children: "Scroll to Item 30" })] }), _jsx(FocusedScrollView, Object.assign({}, args, { selectedKey: selected, children: items.map((item, index) => (_jsx("div", { className: `px-4 py-2 ${selected === `item-${index + 1}`
19
+ ? "bg-secondary text-state-secondary-text-solid"
20
+ : "bg-bg-bg1"}`, children: item }, `item-${index + 1}`))) }))] }));
21
21
  },
22
22
  };
23
23
  export const HorizontalScroll = {
@@ -26,8 +26,8 @@ export const HorizontalScroll = {
26
26
  },
27
27
  render: (args) => {
28
28
  const [selected, setSelected] = useState("item-15");
29
- return (_jsxs("div", { className: "p-6 space-y-4", children: [_jsxs("div", { className: "flex gap-2", children: [_jsx("button", { onClick: () => setSelected("item-5"), className: "px-3 py-1 bg-primary text-white rounded", children: "Scroll to Item 5" }), _jsx("button", { onClick: () => setSelected("item-15"), className: "px-3 py-1 bg-primary text-white rounded", children: "Scroll to Item 15" }), _jsx("button", { onClick: () => setSelected("item-25"), className: "px-3 py-1 bg-primary text-white rounded", children: "Scroll to Item 25" })] }), _jsx(FocusedScrollView, Object.assign({}, args, { selectedKey: selected, children: items.map((item, index) => (_jsx("div", { className: `inline-block w-28 h-12 mx-2 text-center leading-[3rem] rounded ${selected === `item-${index + 1}`
30
- ? "bg-secondary text-secondary-foreground"
31
- : "bg-gray-200"}`, children: item }, `item-${index + 1}`))) }))] }));
29
+ return (_jsxs("div", { className: "p-6 space-y-4", children: [_jsxs("div", { className: "flex gap-2", children: [_jsx("button", { onClick: () => setSelected("item-5"), className: "px-3 py-1 bg-primary text-state-primary-text-solid rounded", children: "Scroll to Item 5" }), _jsx("button", { onClick: () => setSelected("item-15"), className: "px-3 py-1 bg-primary text-state-primary-text-solid rounded", children: "Scroll to Item 15" }), _jsx("button", { onClick: () => setSelected("item-25"), className: "px-3 py-1 bg-primary text-state-primary-text-solid rounded", children: "Scroll to Item 25" })] }), _jsx(FocusedScrollView, Object.assign({}, args, { selectedKey: selected, children: items.map((item, index) => (_jsx("div", { className: `inline-block w-28 h-12 mx-2 text-center leading-[3rem] rounded ${selected === `item-${index + 1}`
30
+ ? "bg-secondary text-state-secondary-text-solid"
31
+ : "bg-transparent-grey2-16"}`, children: item }, `item-${index + 1}`))) }))] }));
32
32
  },
33
33
  };
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { useController, } from "react-hook-form";
4
+ const extractChangedValue = (payload) => {
5
+ if (payload &&
6
+ typeof payload === "object" &&
7
+ "target" in payload &&
8
+ payload.target &&
9
+ typeof payload.target === "object") {
10
+ const target = payload.target;
11
+ if (target.type === "checkbox") {
12
+ return target.checked;
13
+ }
14
+ return target.value;
15
+ }
16
+ return payload;
17
+ };
18
+ export const Field = ({ name, component: Component, componentProps, rules, defaultValue, disabled = false, shouldUnregister = false, id, describedBy, valuePropName = "value", changePropName = "onChange", blurPropName = "onBlur", refPropName = "ref", errorMessagePropName = "errorMessage", invalidPropName = "error", parseValue, formatValue, onChange, onBlur, }) => {
19
+ const fieldId = useId();
20
+ const resolvedId = id || `${name.replace(/\./g, "-")}-${fieldId}`;
21
+ const { field, fieldState: { error, invalid }, } = useController({
22
+ name,
23
+ rules,
24
+ disabled,
25
+ defaultValue,
26
+ shouldUnregister,
27
+ });
28
+ const handleChange = (rawPayload) => {
29
+ const extractedValue = extractChangedValue(rawPayload);
30
+ const parsedValue = parseValue
31
+ ? parseValue(extractedValue, rawPayload)
32
+ : extractedValue;
33
+ field.onChange(parsedValue);
34
+ onChange === null || onChange === void 0 ? void 0 : onChange(parsedValue, rawPayload);
35
+ };
36
+ const handleBlur = () => {
37
+ field.onBlur();
38
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur();
39
+ };
40
+ const componentValue = formatValue
41
+ ? formatValue(field.value)
42
+ : field.value;
43
+ const sharedProps = Object.assign(Object.assign({}, componentProps), { id: resolvedId, name: field.name, disabled, "aria-invalid": invalid || undefined, "aria-describedby": describedBy });
44
+ sharedProps[valuePropName] = componentValue;
45
+ sharedProps[changePropName] = handleChange;
46
+ if (blurPropName) {
47
+ sharedProps[blurPropName] = handleBlur;
48
+ }
49
+ if (refPropName) {
50
+ sharedProps[refPropName] = field.ref;
51
+ }
52
+ if (errorMessagePropName) {
53
+ sharedProps[errorMessagePropName] = error === null || error === void 0 ? void 0 : error.message;
54
+ }
55
+ if (invalidPropName) {
56
+ sharedProps[invalidPropName] = invalid;
57
+ }
58
+ return _jsx(Component, Object.assign({}, sharedProps));
59
+ };
60
+ export default Field;
@@ -0,0 +1,24 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { useFormContext } from "react-hook-form";
14
+ import { cn } from "@/utils/cn";
15
+ export const FieldMessage = (_a) => {
16
+ var { name, className } = _a, props = __rest(_a, ["name", "className"]);
17
+ const { getFieldState, formState } = useFormContext();
18
+ const { error } = getFieldState(name, formState);
19
+ if (!(error === null || error === void 0 ? void 0 : error.message)) {
20
+ return null;
21
+ }
22
+ return (_jsx("p", Object.assign({}, props, { className: cn("text-sm text-input-error mt-1", className), role: "alert", children: error.message })));
23
+ };
24
+ export default FieldMessage;
@@ -1,45 +1,77 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // src/Form.tsx
3
- import { useState } from "react";
4
- import * as yup from "yup";
5
- const schema = yup.object().shape({
6
- name: yup.string().required("Name is required"),
7
- email: yup.string().email("Invalid email").required("Email is required"),
8
- password: yup
9
- .string()
10
- .min(6, "Password must be at least 6 characters")
11
- .required("Password is required"),
12
- });
13
- const Form = ({ onSubmit, className = "" }) => {
14
- const [values, setValues] = useState({
15
- name: "",
16
- email: "",
17
- password: "",
18
- });
19
- const [errors, setErrors] = useState({});
20
- const handleChange = (e) => {
21
- const { name, value } = e.target;
22
- setValues(Object.assign(Object.assign({}, values), { [name]: value }));
23
- };
24
- const handleSubmit = async (e) => {
25
- e.preventDefault();
26
- try {
27
- await schema.validate(values, { abortEarly: false });
28
- setErrors({});
29
- onSubmit(values);
30
- }
31
- catch (err) {
32
- if (err instanceof yup.ValidationError) {
33
- const validationErrors = {};
34
- err.inner.forEach((error) => {
35
- if (error.path) {
36
- validationErrors[error.path] = error.message;
37
- }
38
- });
39
- setErrors(validationErrors);
40
- }
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
41
9
  }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import React from "react";
14
+ import { FormProvider, useForm, } from "react-hook-form";
15
+ import { yupResolver } from "@hookform/resolvers/yup";
16
+ export const createYupResolver = (schema) => yupResolver(schema);
17
+ export const createControlledForm = ({ methods, defaultValues, controllerRef, }) => {
18
+ const FormRoot = React.forwardRef((_a, ref) => {
19
+ var { children } = _a, props = __rest(_a, ["children"]);
20
+ return (_jsx(Form, Object.assign({}, props, { ref: ref, methods: methods, defaultValues: defaultValues, controllerRef: controllerRef, children: children })));
21
+ });
22
+ FormRoot.displayName = "ControlledFormRoot";
23
+ return {
24
+ methods,
25
+ FormRoot,
42
26
  };
43
- return (_jsxs("form", { className: `form ${className}`, onSubmit: handleSubmit, children: [_jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "name", children: "Name" }), _jsx("input", { id: "name", name: "name", type: "text", value: values.name, onChange: handleChange }), errors.name && _jsx("span", { className: "error", children: errors.name })] }), _jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "email", children: "Email" }), _jsx("input", { id: "email", name: "email", type: "email", value: values.email, onChange: handleChange }), errors.email && _jsx("span", { className: "error", children: errors.email })] }), _jsxs("div", { className: "form-group", children: [_jsx("label", { htmlFor: "password", children: "Password" }), _jsx("input", { id: "password", name: "password", type: "password", value: values.password, onChange: handleChange }), errors.password && _jsx("span", { className: "error", children: errors.password })] }), _jsx("button", { type: "submit", children: "Submit" })] }));
44
27
  };
28
+ export const useControlledForm = ({ defaultValues, controllerRef, resolver, validationSchema, mode = "onSubmit", reValidateMode = "onChange", }) => {
29
+ const resolvedResolver = resolver !== null && resolver !== void 0 ? resolver : (validationSchema
30
+ ? createYupResolver(validationSchema)
31
+ : undefined);
32
+ const methods = useForm({
33
+ defaultValues,
34
+ resolver: resolvedResolver,
35
+ mode,
36
+ reValidateMode,
37
+ });
38
+ return createControlledForm({
39
+ methods,
40
+ defaultValues,
41
+ controllerRef,
42
+ });
43
+ };
44
+ const FormInner = (_a, ref) => {
45
+ var { children, defaultValues, methods: externalMethods, controllerRef, onSubmit, onInvalidSubmit, resolver, validationSchema, mode = "onSubmit", reValidateMode = "onChange", noValidate = true } = _a, formProps = __rest(_a, ["children", "defaultValues", "methods", "controllerRef", "onSubmit", "onInvalidSubmit", "resolver", "validationSchema", "mode", "reValidateMode", "noValidate"]);
46
+ const resolvedResolver = resolver !== null && resolver !== void 0 ? resolver : (validationSchema
47
+ ? createYupResolver(validationSchema)
48
+ : undefined);
49
+ const internalMethods = useForm({
50
+ defaultValues,
51
+ resolver: resolvedResolver,
52
+ mode,
53
+ reValidateMode,
54
+ });
55
+ const methods = externalMethods !== null && externalMethods !== void 0 ? externalMethods : internalMethods;
56
+ const controller = React.useMemo(() => ({
57
+ submit: async () => {
58
+ await methods.handleSubmit(onSubmit, onInvalidSubmit)();
59
+ },
60
+ getValues: () => methods.getValues(),
61
+ setValue: methods.setValue,
62
+ trigger: methods.trigger,
63
+ reset: methods.reset,
64
+ }), [methods, onSubmit, onInvalidSubmit]);
65
+ React.useImperativeHandle(ref, () => controller, [controller]);
66
+ React.useEffect(() => {
67
+ if (!controllerRef)
68
+ return;
69
+ controllerRef.current = controller;
70
+ return () => {
71
+ controllerRef.current = null;
72
+ };
73
+ }, [controllerRef, controller]);
74
+ return (_jsx(FormProvider, Object.assign({}, methods, { children: _jsx("form", Object.assign({}, formProps, { noValidate: noValidate, onSubmit: methods.handleSubmit(onSubmit, onInvalidSubmit), children: typeof children === "function" ? children(methods) : children })) })));
75
+ };
76
+ export const Form = React.forwardRef(FormInner);
45
77
  export default Form;