@questpie/admin 0.0.1 → 1.0.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 (250) hide show
  1. package/README.md +439 -424
  2. package/dist/auth-layout-M8K8_q5R.mjs +181 -0
  3. package/dist/auth-layout-M8K8_q5R.mjs.map +1 -0
  4. package/dist/bulk-upload-dialog-D7w7W1Hl.mjs +273 -0
  5. package/dist/bulk-upload-dialog-D7w7W1Hl.mjs.map +1 -0
  6. package/dist/{components/ui/card.mjs → card-BKHjBQfw.mjs} +8 -8
  7. package/dist/card-BKHjBQfw.mjs.map +1 -0
  8. package/dist/client/styles/index.css +434 -0
  9. package/dist/client-DbpZKSgH.d.mts +13585 -0
  10. package/dist/client-DbpZKSgH.d.mts.map +1 -0
  11. package/dist/client-njX1rZmi.mjs +22612 -0
  12. package/dist/client-njX1rZmi.mjs.map +1 -0
  13. package/dist/client.d.mts +3 -0
  14. package/dist/client.mjs +13 -0
  15. package/dist/content-locales-provider-BXvuIgfg.mjs +1650 -0
  16. package/dist/content-locales-provider-BXvuIgfg.mjs.map +1 -0
  17. package/dist/dashboard-page-B4PGEdc2.mjs +2500 -0
  18. package/dist/dashboard-page-B4PGEdc2.mjs.map +1 -0
  19. package/dist/dashboard-page-mCY0pgZv.mjs +3 -0
  20. package/dist/dropzone-Do3awXKd.mjs +634 -0
  21. package/dist/dropzone-Do3awXKd.mjs.map +1 -0
  22. package/dist/{views/auth/forgot-password-form.mjs → forgot-password-page-Bcp-An4Y.mjs} +87 -14
  23. package/dist/forgot-password-page-Bcp-An4Y.mjs.map +1 -0
  24. package/dist/forgot-password-page-CEwsdLwn.mjs +3 -0
  25. package/dist/index-B9Xwk4hi.d.mts +2753 -0
  26. package/dist/index-B9Xwk4hi.d.mts.map +1 -0
  27. package/dist/index.d.mts +3 -0
  28. package/dist/index.mjs +13 -0
  29. package/dist/login-page-BUnpCbCa.mjs +3 -0
  30. package/dist/login-page-CP4gA-dl.mjs +298 -0
  31. package/dist/login-page-CP4gA-dl.mjs.map +1 -0
  32. package/dist/preview-utils-BKQ9-TMa.mjs +65 -0
  33. package/dist/preview-utils-BKQ9-TMa.mjs.map +1 -0
  34. package/dist/{views/auth/reset-password-form.mjs → reset-password-page-BqfDmLxA.mjs} +111 -14
  35. package/dist/reset-password-page-BqfDmLxA.mjs.map +1 -0
  36. package/dist/reset-password-page-CufHz3h3.mjs +3 -0
  37. package/dist/runtime-6VZM878K.mjs +69 -0
  38. package/dist/runtime-6VZM878K.mjs.map +1 -0
  39. package/dist/saved-views.types-BMsz5mCy.d.mts +42 -0
  40. package/dist/saved-views.types-BMsz5mCy.d.mts.map +1 -0
  41. package/dist/server.d.mts +250 -0
  42. package/dist/server.d.mts.map +1 -0
  43. package/dist/server.mjs +832 -0
  44. package/dist/server.mjs.map +1 -0
  45. package/dist/setup-page-BNNzt_Z6.mjs +3 -0
  46. package/dist/setup-page-YAP_fzqh.mjs +264 -0
  47. package/dist/setup-page-YAP_fzqh.mjs.map +1 -0
  48. package/dist/shared.d.mts +57 -0
  49. package/dist/shared.d.mts.map +1 -0
  50. package/dist/shared.mjs +3 -0
  51. package/dist/{hooks/use-auth.mjs → use-auth-BoLmWtmU.mjs} +42 -30
  52. package/dist/use-auth-BoLmWtmU.mjs.map +1 -0
  53. package/package.json +48 -198
  54. package/.turbo/turbo-build.log +0 -108
  55. package/CHANGELOG.md +0 -10
  56. package/STATUS.md +0 -917
  57. package/VALIDATION.md +0 -602
  58. package/components.json +0 -24
  59. package/dist/__tests__/setup.mjs +0 -38
  60. package/dist/__tests__/test-utils.mjs +0 -45
  61. package/dist/__tests__/vitest.d.mjs +0 -3
  62. package/dist/components/admin-app.mjs +0 -69
  63. package/dist/components/fields/array-field.mjs +0 -190
  64. package/dist/components/fields/checkbox-field.mjs +0 -34
  65. package/dist/components/fields/custom-field.mjs +0 -32
  66. package/dist/components/fields/date-field.mjs +0 -41
  67. package/dist/components/fields/datetime-field.mjs +0 -42
  68. package/dist/components/fields/email-field.mjs +0 -37
  69. package/dist/components/fields/embedded-collection.mjs +0 -253
  70. package/dist/components/fields/field-types.mjs +0 -1
  71. package/dist/components/fields/field-utils.mjs +0 -10
  72. package/dist/components/fields/field-wrapper.mjs +0 -34
  73. package/dist/components/fields/index.mjs +0 -23
  74. package/dist/components/fields/json-field.mjs +0 -243
  75. package/dist/components/fields/locale-badge.mjs +0 -16
  76. package/dist/components/fields/number-field.mjs +0 -39
  77. package/dist/components/fields/password-field.mjs +0 -37
  78. package/dist/components/fields/relation-field.mjs +0 -104
  79. package/dist/components/fields/relation-picker.mjs +0 -229
  80. package/dist/components/fields/relation-select.mjs +0 -188
  81. package/dist/components/fields/rich-text-editor/index.mjs +0 -897
  82. package/dist/components/fields/select-field.mjs +0 -41
  83. package/dist/components/fields/switch-field.mjs +0 -34
  84. package/dist/components/fields/text-field.mjs +0 -38
  85. package/dist/components/fields/textarea-field.mjs +0 -38
  86. package/dist/components/index.mjs +0 -59
  87. package/dist/components/primitives/checkbox-input.mjs +0 -127
  88. package/dist/components/primitives/date-input.mjs +0 -303
  89. package/dist/components/primitives/index.mjs +0 -12
  90. package/dist/components/primitives/number-input.mjs +0 -104
  91. package/dist/components/primitives/select-input.mjs +0 -177
  92. package/dist/components/primitives/tag-input.mjs +0 -135
  93. package/dist/components/primitives/text-input.mjs +0 -39
  94. package/dist/components/primitives/textarea-input.mjs +0 -37
  95. package/dist/components/primitives/toggle-input.mjs +0 -31
  96. package/dist/components/primitives/types.mjs +0 -12
  97. package/dist/components/ui/accordion.mjs +0 -55
  98. package/dist/components/ui/avatar.mjs +0 -54
  99. package/dist/components/ui/badge.mjs +0 -34
  100. package/dist/components/ui/button.mjs +0 -48
  101. package/dist/components/ui/checkbox.mjs +0 -21
  102. package/dist/components/ui/combobox.mjs +0 -163
  103. package/dist/components/ui/dialog.mjs +0 -95
  104. package/dist/components/ui/dropdown-menu.mjs +0 -138
  105. package/dist/components/ui/field.mjs +0 -113
  106. package/dist/components/ui/input-group.mjs +0 -82
  107. package/dist/components/ui/input.mjs +0 -17
  108. package/dist/components/ui/label.mjs +0 -15
  109. package/dist/components/ui/popover.mjs +0 -56
  110. package/dist/components/ui/scroll-area.mjs +0 -38
  111. package/dist/components/ui/select.mjs +0 -100
  112. package/dist/components/ui/separator.mjs +0 -16
  113. package/dist/components/ui/sheet.mjs +0 -90
  114. package/dist/components/ui/sidebar.mjs +0 -387
  115. package/dist/components/ui/skeleton.mjs +0 -14
  116. package/dist/components/ui/spinner.mjs +0 -16
  117. package/dist/components/ui/switch.mjs +0 -22
  118. package/dist/components/ui/table.mjs +0 -68
  119. package/dist/components/ui/tabs.mjs +0 -48
  120. package/dist/components/ui/textarea.mjs +0 -15
  121. package/dist/components/ui/tooltip.mjs +0 -44
  122. package/dist/config/component-registry.mjs +0 -38
  123. package/dist/config/index.mjs +0 -129
  124. package/dist/hooks/admin-provider.mjs +0 -70
  125. package/dist/hooks/index.mjs +0 -7
  126. package/dist/hooks/store.mjs +0 -178
  127. package/dist/hooks/use-collection-db.mjs +0 -146
  128. package/dist/hooks/use-collection.mjs +0 -112
  129. package/dist/hooks/use-global.mjs +0 -46
  130. package/dist/hooks/use-mobile.mjs +0 -20
  131. package/dist/lib/utils.mjs +0 -10
  132. package/dist/styles/index.css +0 -336
  133. package/dist/styles/index.mjs +0 -1
  134. package/dist/utils/index.mjs +0 -9
  135. package/dist/views/auth/auth-layout.mjs +0 -52
  136. package/dist/views/auth/index.mjs +0 -6
  137. package/dist/views/auth/login-form.mjs +0 -156
  138. package/dist/views/collection/auto-form-fields.mjs +0 -525
  139. package/dist/views/collection/collection-form.mjs +0 -91
  140. package/dist/views/collection/collection-list.mjs +0 -76
  141. package/dist/views/collection/form-field.mjs +0 -42
  142. package/dist/views/collection/index.mjs +0 -6
  143. package/dist/views/common/index.mjs +0 -4
  144. package/dist/views/common/locale-switcher.mjs +0 -39
  145. package/dist/views/common/version-history.mjs +0 -272
  146. package/dist/views/index.mjs +0 -9
  147. package/dist/views/layout/admin-layout.mjs +0 -40
  148. package/dist/views/layout/admin-router.mjs +0 -95
  149. package/dist/views/layout/admin-sidebar.mjs +0 -63
  150. package/dist/views/layout/index.mjs +0 -5
  151. package/src/__tests__/setup.ts +0 -44
  152. package/src/__tests__/test-utils.tsx +0 -49
  153. package/src/__tests__/vitest.d.ts +0 -9
  154. package/src/components/admin-app.tsx +0 -221
  155. package/src/components/fields/array-field.tsx +0 -237
  156. package/src/components/fields/checkbox-field.tsx +0 -47
  157. package/src/components/fields/custom-field.tsx +0 -50
  158. package/src/components/fields/date-field.tsx +0 -65
  159. package/src/components/fields/datetime-field.tsx +0 -67
  160. package/src/components/fields/email-field.tsx +0 -51
  161. package/src/components/fields/embedded-collection.tsx +0 -315
  162. package/src/components/fields/field-types.ts +0 -162
  163. package/src/components/fields/field-utils.ts +0 -6
  164. package/src/components/fields/field-wrapper.tsx +0 -52
  165. package/src/components/fields/index.ts +0 -66
  166. package/src/components/fields/json-field.tsx +0 -440
  167. package/src/components/fields/locale-badge.tsx +0 -15
  168. package/src/components/fields/number-field.tsx +0 -57
  169. package/src/components/fields/password-field.tsx +0 -51
  170. package/src/components/fields/relation-field.tsx +0 -243
  171. package/src/components/fields/relation-picker.tsx +0 -402
  172. package/src/components/fields/relation-select.tsx +0 -327
  173. package/src/components/fields/rich-text-editor/index.tsx +0 -1337
  174. package/src/components/fields/select-field.tsx +0 -61
  175. package/src/components/fields/switch-field.tsx +0 -47
  176. package/src/components/fields/text-field.tsx +0 -55
  177. package/src/components/fields/textarea-field.tsx +0 -55
  178. package/src/components/index.ts +0 -40
  179. package/src/components/primitives/checkbox-input.tsx +0 -193
  180. package/src/components/primitives/date-input.tsx +0 -401
  181. package/src/components/primitives/index.ts +0 -24
  182. package/src/components/primitives/number-input.tsx +0 -132
  183. package/src/components/primitives/select-input.tsx +0 -296
  184. package/src/components/primitives/tag-input.tsx +0 -200
  185. package/src/components/primitives/text-input.tsx +0 -49
  186. package/src/components/primitives/textarea-input.tsx +0 -46
  187. package/src/components/primitives/toggle-input.tsx +0 -36
  188. package/src/components/primitives/types.ts +0 -235
  189. package/src/components/ui/accordion.tsx +0 -72
  190. package/src/components/ui/avatar.tsx +0 -106
  191. package/src/components/ui/badge.tsx +0 -48
  192. package/src/components/ui/button.tsx +0 -53
  193. package/src/components/ui/card.tsx +0 -94
  194. package/src/components/ui/checkbox.tsx +0 -27
  195. package/src/components/ui/combobox.tsx +0 -290
  196. package/src/components/ui/dialog.tsx +0 -151
  197. package/src/components/ui/dropdown-menu.tsx +0 -254
  198. package/src/components/ui/field.tsx +0 -227
  199. package/src/components/ui/input-group.tsx +0 -149
  200. package/src/components/ui/input.tsx +0 -20
  201. package/src/components/ui/label.tsx +0 -18
  202. package/src/components/ui/popover.tsx +0 -88
  203. package/src/components/ui/scroll-area.tsx +0 -53
  204. package/src/components/ui/select.tsx +0 -192
  205. package/src/components/ui/separator.tsx +0 -23
  206. package/src/components/ui/sheet.tsx +0 -127
  207. package/src/components/ui/sidebar.tsx +0 -723
  208. package/src/components/ui/skeleton.tsx +0 -13
  209. package/src/components/ui/spinner.tsx +0 -10
  210. package/src/components/ui/switch.tsx +0 -32
  211. package/src/components/ui/table.tsx +0 -99
  212. package/src/components/ui/tabs.tsx +0 -82
  213. package/src/components/ui/textarea.tsx +0 -18
  214. package/src/components/ui/tooltip.tsx +0 -70
  215. package/src/config/component-registry.ts +0 -190
  216. package/src/config/index.ts +0 -1099
  217. package/src/hooks/README.md +0 -269
  218. package/src/hooks/admin-provider.tsx +0 -110
  219. package/src/hooks/index.ts +0 -41
  220. package/src/hooks/store.ts +0 -248
  221. package/src/hooks/use-auth.ts +0 -168
  222. package/src/hooks/use-collection-db.ts +0 -209
  223. package/src/hooks/use-collection.ts +0 -156
  224. package/src/hooks/use-global.ts +0 -69
  225. package/src/hooks/use-mobile.ts +0 -21
  226. package/src/lib/utils.ts +0 -6
  227. package/src/styles/index.css +0 -340
  228. package/src/utils/index.ts +0 -6
  229. package/src/views/auth/auth-layout.tsx +0 -77
  230. package/src/views/auth/forgot-password-form.tsx +0 -192
  231. package/src/views/auth/index.ts +0 -21
  232. package/src/views/auth/login-form.tsx +0 -229
  233. package/src/views/auth/reset-password-form.tsx +0 -232
  234. package/src/views/collection/auto-form-fields.tsx +0 -982
  235. package/src/views/collection/collection-form.tsx +0 -186
  236. package/src/views/collection/collection-list.tsx +0 -223
  237. package/src/views/collection/form-field.tsx +0 -52
  238. package/src/views/collection/index.ts +0 -15
  239. package/src/views/common/index.ts +0 -8
  240. package/src/views/common/locale-switcher.tsx +0 -45
  241. package/src/views/common/version-history.tsx +0 -406
  242. package/src/views/index.ts +0 -25
  243. package/src/views/layout/admin-layout.tsx +0 -117
  244. package/src/views/layout/admin-router.tsx +0 -206
  245. package/src/views/layout/admin-sidebar.tsx +0 -185
  246. package/src/views/layout/index.ts +0 -12
  247. package/tsconfig.json +0 -13
  248. package/tsconfig.tsbuildinfo +0 -1
  249. package/tsdown.config.ts +0 -13
  250. package/vitest.config.ts +0 -29
@@ -1,41 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { SelectInput } from "../primitives/select-input";
3
- import { Controller } from "react-hook-form";
4
- import { FieldWrapper } from "./field-wrapper";
5
- import { useResolvedControl } from "./field-utils";
6
-
7
- //#region src/components/fields/select-field.tsx
8
- function SelectField({ name, label, description, placeholder, required, disabled, localized, locale, control, className, options, loadOptions, multiple, clearable, maxSelections, emptyMessage }) {
9
- return /* @__PURE__ */ jsx(Controller, {
10
- name,
11
- control: useResolvedControl(control),
12
- render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FieldWrapper, {
13
- name,
14
- label,
15
- description,
16
- required,
17
- disabled,
18
- localized,
19
- locale,
20
- error: fieldState.error?.message,
21
- children: /* @__PURE__ */ jsx(SelectInput, {
22
- id: name,
23
- value: field.value ?? (multiple ? [] : null),
24
- onChange: field.onChange,
25
- options,
26
- loadOptions,
27
- multiple,
28
- clearable,
29
- maxSelections,
30
- emptyMessage,
31
- placeholder,
32
- disabled,
33
- "aria-invalid": !!fieldState.error,
34
- className
35
- })
36
- })
37
- });
38
- }
39
-
40
- //#endregion
41
- export { SelectField };
@@ -1,34 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { ToggleInput } from "../primitives/toggle-input";
3
- import { Controller } from "react-hook-form";
4
- import { FieldWrapper } from "./field-wrapper";
5
- import { useResolvedControl } from "./field-utils";
6
-
7
- //#region src/components/fields/switch-field.tsx
8
- function SwitchField({ name, label, description, required, disabled, localized, locale, control, className }) {
9
- return /* @__PURE__ */ jsx(Controller, {
10
- name,
11
- control: useResolvedControl(control),
12
- render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FieldWrapper, {
13
- name,
14
- label,
15
- description,
16
- required,
17
- disabled,
18
- localized,
19
- locale,
20
- error: fieldState.error?.message,
21
- children: /* @__PURE__ */ jsx(ToggleInput, {
22
- id: name,
23
- value: !!field.value,
24
- onChange: field.onChange,
25
- disabled,
26
- "aria-invalid": !!fieldState.error,
27
- className
28
- })
29
- })
30
- });
31
- }
32
-
33
- //#endregion
34
- export { SwitchField };
@@ -1,38 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { TextInput } from "../primitives/text-input";
3
- import { Controller } from "react-hook-form";
4
- import { FieldWrapper } from "./field-wrapper";
5
- import { useResolvedControl } from "./field-utils";
6
-
7
- //#region src/components/fields/text-field.tsx
8
- function TextField({ name, label, description, placeholder, required, disabled, localized, locale, control, className, type = "text", maxLength, autoComplete }) {
9
- return /* @__PURE__ */ jsx(Controller, {
10
- name,
11
- control: useResolvedControl(control),
12
- render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FieldWrapper, {
13
- name,
14
- label,
15
- description,
16
- required,
17
- disabled,
18
- localized,
19
- locale,
20
- error: fieldState.error?.message,
21
- children: /* @__PURE__ */ jsx(TextInput, {
22
- id: name,
23
- value: field.value ?? "",
24
- onChange: field.onChange,
25
- type,
26
- placeholder,
27
- disabled,
28
- maxLength,
29
- autoComplete,
30
- "aria-invalid": !!fieldState.error,
31
- className
32
- })
33
- })
34
- });
35
- }
36
-
37
- //#endregion
38
- export { TextField };
@@ -1,38 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { TextareaInput } from "../primitives/textarea-input";
3
- import { Controller } from "react-hook-form";
4
- import { FieldWrapper } from "./field-wrapper";
5
- import { useResolvedControl } from "./field-utils";
6
-
7
- //#region src/components/fields/textarea-field.tsx
8
- function TextareaField({ name, label, description, placeholder, required, disabled, localized, locale, control, className, rows, maxLength, autoResize }) {
9
- return /* @__PURE__ */ jsx(Controller, {
10
- name,
11
- control: useResolvedControl(control),
12
- render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FieldWrapper, {
13
- name,
14
- label,
15
- description,
16
- required,
17
- disabled,
18
- localized,
19
- locale,
20
- error: fieldState.error?.message,
21
- children: /* @__PURE__ */ jsx(TextareaInput, {
22
- id: name,
23
- value: field.value ?? "",
24
- onChange: field.onChange,
25
- placeholder,
26
- disabled,
27
- rows,
28
- maxLength,
29
- autoResize,
30
- "aria-invalid": !!fieldState.error,
31
- className
32
- })
33
- })
34
- });
35
- }
36
-
37
- //#endregion
38
- export { TextareaField };
@@ -1,59 +0,0 @@
1
- import { AdminApp } from "./admin-app";
2
-
3
- export * from "../views"
4
-
5
- export * from "./fields"
6
-
7
- export * from "./ui/accordion"
8
-
9
- export * from "./ui/avatar"
10
-
11
- export * from "./ui/badge"
12
-
13
- export * from "./ui/button"
14
-
15
- export * from "./ui/card"
16
-
17
- export * from "./ui/checkbox"
18
-
19
- export * from "./ui/combobox"
20
-
21
- export * from "./ui/dialog"
22
-
23
- export * from "./ui/dropdown-menu"
24
-
25
- export * from "./ui/field"
26
-
27
- export * from "./ui/input"
28
-
29
- export * from "./ui/input-group"
30
-
31
- export * from "./ui/label"
32
-
33
- export * from "./ui/popover"
34
-
35
- export * from "./ui/scroll-area"
36
-
37
- export * from "./ui/select"
38
-
39
- export * from "./ui/separator"
40
-
41
- export * from "./ui/sheet"
42
-
43
- export * from "./ui/sidebar"
44
-
45
- export * from "./ui/skeleton"
46
-
47
- export * from "./ui/spinner"
48
-
49
- export * from "./ui/switch"
50
-
51
- export * from "./ui/table"
52
-
53
- export * from "./ui/tabs"
54
-
55
- export * from "./ui/textarea"
56
-
57
- export * from "./ui/tooltip"
58
-
59
- export { AdminApp };
@@ -1,127 +0,0 @@
1
- "use client";
2
-
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { Checkbox } from "../ui/checkbox";
5
- import { cn } from "../../lib/utils";
6
-
7
- //#region src/components/primitives/checkbox-input.tsx
8
- /**
9
- * Checkbox Input Primitive
10
- *
11
- * A single checkbox with value/onChange pattern.
12
- *
13
- * @example
14
- * ```tsx
15
- * <CheckboxInput
16
- * value={isAccepted}
17
- * onChange={setIsAccepted}
18
- * />
19
- * ```
20
- */
21
- function CheckboxInput({ value, onChange, disabled, className, id, "aria-invalid": ariaInvalid }) {
22
- return /* @__PURE__ */ jsx(Checkbox, {
23
- id,
24
- checked: value,
25
- onCheckedChange: (checked) => onChange(checked === true),
26
- disabled,
27
- "aria-invalid": ariaInvalid,
28
- className: cn(className)
29
- });
30
- }
31
- /**
32
- * Checkbox Group Primitive
33
- *
34
- * A group of checkboxes for multi-selection.
35
- * Returns an array of selected values.
36
- *
37
- * @example
38
- * ```tsx
39
- * <CheckboxGroup
40
- * value={selectedCategories}
41
- * onChange={setSelectedCategories}
42
- * options={[
43
- * { value: "news", label: "News" },
44
- * { value: "blog", label: "Blog" },
45
- * { value: "tutorial", label: "Tutorial" },
46
- * ]}
47
- * orientation="vertical"
48
- * />
49
- * ```
50
- */
51
- function CheckboxGroup({ value, onChange, options, orientation = "vertical", disabled, className, id, "aria-invalid": ariaInvalid }) {
52
- const handleChange = (optionValue, checked) => {
53
- if (checked) onChange([...value, optionValue]);
54
- else onChange(value.filter((v) => v !== optionValue));
55
- };
56
- return /* @__PURE__ */ jsx("div", {
57
- id,
58
- role: "group",
59
- "aria-invalid": ariaInvalid,
60
- className: cn("flex gap-3", orientation === "vertical" ? "flex-col" : "flex-row flex-wrap", className),
61
- children: options.map((option) => {
62
- const optionId = `${id}-${String(option.value)}`;
63
- return /* @__PURE__ */ jsxs("div", {
64
- className: cn("flex items-center gap-2", option.disabled || disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"),
65
- children: [/* @__PURE__ */ jsx(CheckboxInput, {
66
- id: optionId,
67
- value: value.includes(option.value),
68
- onChange: (checked) => handleChange(option.value, checked),
69
- disabled: option.disabled || disabled
70
- }), /* @__PURE__ */ jsx("label", {
71
- htmlFor: optionId,
72
- className: "text-sm cursor-pointer",
73
- children: option.label
74
- })]
75
- }, String(option.value));
76
- })
77
- });
78
- }
79
- /**
80
- * Radio Group Primitive
81
- *
82
- * A group of radio buttons for single selection.
83
- * Returns the selected value or null.
84
- *
85
- * @example
86
- * ```tsx
87
- * <RadioGroup
88
- * value={selectedPriority}
89
- * onChange={setSelectedPriority}
90
- * options={[
91
- * { value: "low", label: "Low" },
92
- * { value: "medium", label: "Medium" },
93
- * { value: "high", label: "High" },
94
- * ]}
95
- * />
96
- * ```
97
- */
98
- function RadioGroup({ value, onChange, options, orientation = "vertical", disabled, className, id, "aria-invalid": ariaInvalid }) {
99
- return /* @__PURE__ */ jsx("div", {
100
- id,
101
- role: "radiogroup",
102
- "aria-invalid": ariaInvalid,
103
- className: cn("flex gap-3", orientation === "vertical" ? "flex-col" : "flex-row flex-wrap", className),
104
- children: options.map((option) => {
105
- const optionId = `${id}-${String(option.value)}`;
106
- return /* @__PURE__ */ jsxs("div", {
107
- className: cn("flex items-center gap-2", option.disabled || disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"),
108
- children: [/* @__PURE__ */ jsx("input", {
109
- type: "radio",
110
- id: optionId,
111
- name: id,
112
- checked: value === option.value,
113
- onChange: () => onChange(option.value),
114
- disabled: option.disabled || disabled,
115
- className: cn("size-4 shrink-0 accent-primary", "disabled:cursor-not-allowed disabled:opacity-50")
116
- }), /* @__PURE__ */ jsx("label", {
117
- htmlFor: optionId,
118
- className: "text-sm cursor-pointer",
119
- children: option.label
120
- })]
121
- }, String(option.value));
122
- })
123
- });
124
- }
125
-
126
- //#endregion
127
- export { CheckboxGroup, CheckboxInput, RadioGroup };
@@ -1,303 +0,0 @@
1
- "use client";
2
-
3
- import { useState } from "react";
4
- import { jsx, jsxs } from "react/jsx-runtime";
5
- import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
6
- import { cn } from "../../lib/utils";
7
- import { DayPicker } from "react-day-picker";
8
- import { format } from "date-fns";
9
- import { CalendarBlank, X } from "@phosphor-icons/react";
10
-
11
- //#region src/components/primitives/date-input.tsx
12
- /**
13
- * Date Input Primitive
14
- *
15
- * A date picker with popover calendar.
16
- * Uses react-day-picker under the hood.
17
- *
18
- * @example
19
- * ```tsx
20
- * <DateInput
21
- * value={selectedDate}
22
- * onChange={setSelectedDate}
23
- * placeholder="Select date"
24
- * />
25
- * ```
26
- */
27
- function DateInput({ value, onChange, minDate, maxDate, format: dateFormat = "PP", placeholder = "Select date", disabled, className, id, "aria-invalid": ariaInvalid }) {
28
- const [open, setOpen] = useState(false);
29
- const handleSelect = (date) => {
30
- onChange(date ?? null);
31
- setOpen(false);
32
- };
33
- const handleClear = (e) => {
34
- e.stopPropagation();
35
- onChange(null);
36
- };
37
- return /* @__PURE__ */ jsxs(Popover, {
38
- open,
39
- onOpenChange: setOpen,
40
- children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
41
- id,
42
- disabled,
43
- "aria-invalid": ariaInvalid,
44
- className: cn("flex h-9 w-full items-center justify-start gap-2 border border-input bg-background px-3 py-2 text-sm", "hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:opacity-50", !value && "text-muted-foreground", className),
45
- children: [
46
- /* @__PURE__ */ jsx(CalendarBlank, { className: "size-4" }),
47
- /* @__PURE__ */ jsx("span", {
48
- className: "flex-1 text-left",
49
- children: value ? format(value, dateFormat) : placeholder
50
- }),
51
- value && !disabled && /* @__PURE__ */ jsx(X, {
52
- className: "size-4 opacity-50 hover:opacity-100",
53
- onClick: handleClear
54
- })
55
- ]
56
- }), /* @__PURE__ */ jsx(PopoverContent, {
57
- className: "w-auto p-0",
58
- align: "start",
59
- children: /* @__PURE__ */ jsx(DayPicker, {
60
- mode: "single",
61
- selected: value ?? void 0,
62
- onSelect: handleSelect,
63
- disabled: (date) => {
64
- if (minDate && date < minDate) return true;
65
- if (maxDate && date > maxDate) return true;
66
- return false;
67
- },
68
- className: "p-3",
69
- classNames: {
70
- months: "flex flex-col sm:flex-row gap-2",
71
- month: "flex flex-col gap-4",
72
- month_caption: "flex justify-center pt-1 relative items-center w-full",
73
- caption_label: "text-sm font-medium",
74
- nav: "flex items-center gap-1",
75
- button_previous: "absolute left-1 size-7 bg-transparent p-0 opacity-50 hover:opacity-100",
76
- button_next: "absolute right-1 size-7 bg-transparent p-0 opacity-50 hover:opacity-100",
77
- month_grid: "w-full border-collapse",
78
- weekdays: "flex",
79
- weekday: "text-muted-foreground w-8 font-normal text-[0.8rem]",
80
- week: "flex w-full mt-2",
81
- day: "relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50",
82
- day_button: cn("size-8 p-0 font-normal", "hover:bg-accent hover:text-accent-foreground", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),
83
- selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
84
- today: "bg-accent text-accent-foreground",
85
- outside: "text-muted-foreground opacity-50",
86
- disabled: "text-muted-foreground opacity-50",
87
- hidden: "invisible"
88
- }
89
- })
90
- })]
91
- });
92
- }
93
- /**
94
- * DateTime Input Primitive
95
- *
96
- * A date and time picker.
97
- *
98
- * @example
99
- * ```tsx
100
- * <DateTimeInput
101
- * value={scheduledAt}
102
- * onChange={setScheduledAt}
103
- * precision="minute"
104
- * />
105
- * ```
106
- */
107
- function DateTimeInput({ value, onChange, minDate, maxDate, format: dateFormat = "PPp", precision = "minute", placeholder = "Select date and time", disabled, className, id, "aria-invalid": ariaInvalid }) {
108
- const [open, setOpen] = useState(false);
109
- const [timeValue, setTimeValue] = useState(() => {
110
- if (!value) return "";
111
- return precision === "second" ? format(value, "HH:mm:ss") : format(value, "HH:mm");
112
- });
113
- const handleDateSelect = (date) => {
114
- if (!date) {
115
- onChange(null);
116
- return;
117
- }
118
- if (timeValue) {
119
- const [hours, minutes, seconds] = timeValue.split(":").map(Number);
120
- date.setHours(hours || 0, minutes || 0, seconds || 0);
121
- }
122
- onChange(date);
123
- };
124
- const handleTimeChange = (e) => {
125
- const time = e.target.value;
126
- setTimeValue(time);
127
- if (value && time) {
128
- const [hours, minutes, seconds] = time.split(":").map(Number);
129
- const newDate = new Date(value);
130
- newDate.setHours(hours || 0, minutes || 0, seconds || 0);
131
- onChange(newDate);
132
- }
133
- };
134
- const handleClear = (e) => {
135
- e.stopPropagation();
136
- onChange(null);
137
- setTimeValue("");
138
- };
139
- return /* @__PURE__ */ jsxs(Popover, {
140
- open,
141
- onOpenChange: setOpen,
142
- children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
143
- id,
144
- disabled,
145
- "aria-invalid": ariaInvalid,
146
- className: cn("flex h-9 w-full items-center justify-start gap-2 border border-input bg-background px-3 py-2 text-sm", "hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:opacity-50", !value && "text-muted-foreground", className),
147
- children: [
148
- /* @__PURE__ */ jsx(CalendarBlank, { className: "size-4" }),
149
- /* @__PURE__ */ jsx("span", {
150
- className: "flex-1 text-left",
151
- children: value ? format(value, dateFormat) : placeholder
152
- }),
153
- value && !disabled && /* @__PURE__ */ jsx(X, {
154
- className: "size-4 opacity-50 hover:opacity-100",
155
- onClick: handleClear
156
- })
157
- ]
158
- }), /* @__PURE__ */ jsxs(PopoverContent, {
159
- className: "w-auto p-0",
160
- align: "start",
161
- children: [/* @__PURE__ */ jsx(DayPicker, {
162
- mode: "single",
163
- selected: value ?? void 0,
164
- onSelect: handleDateSelect,
165
- disabled: (date) => {
166
- if (minDate && date < minDate) return true;
167
- if (maxDate && date > maxDate) return true;
168
- return false;
169
- },
170
- className: "p-3",
171
- classNames: {
172
- months: "flex flex-col sm:flex-row gap-2",
173
- month: "flex flex-col gap-4",
174
- month_caption: "flex justify-center pt-1 relative items-center w-full",
175
- caption_label: "text-sm font-medium",
176
- nav: "flex items-center gap-1",
177
- button_previous: "absolute left-1 size-7 bg-transparent p-0 opacity-50 hover:opacity-100",
178
- button_next: "absolute right-1 size-7 bg-transparent p-0 opacity-50 hover:opacity-100",
179
- month_grid: "w-full border-collapse",
180
- weekdays: "flex",
181
- weekday: "text-muted-foreground w-8 font-normal text-[0.8rem]",
182
- week: "flex w-full mt-2",
183
- day: "relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50",
184
- day_button: cn("size-8 p-0 font-normal", "hover:bg-accent hover:text-accent-foreground", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),
185
- selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
186
- today: "bg-accent text-accent-foreground",
187
- outside: "text-muted-foreground opacity-50",
188
- disabled: "text-muted-foreground opacity-50",
189
- hidden: "invisible"
190
- }
191
- }), /* @__PURE__ */ jsx("div", {
192
- className: "border-t border-border p-3",
193
- children: /* @__PURE__ */ jsx("input", {
194
- type: "time",
195
- step: precision === "second" ? 1 : 60,
196
- value: timeValue,
197
- onChange: handleTimeChange,
198
- className: cn("flex h-9 w-full border border-input bg-background px-3 py-2 text-sm", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2")
199
- })
200
- })]
201
- })]
202
- });
203
- }
204
- /**
205
- * Date Range Input Primitive
206
- *
207
- * A date range picker for selecting start and end dates.
208
- *
209
- * @example
210
- * ```tsx
211
- * <DateRangeInput
212
- * value={{ start: startDate, end: endDate }}
213
- * onChange={setDateRange}
214
- * />
215
- * ```
216
- */
217
- function DateRangeInput({ value, onChange, minDate, maxDate, placeholder = "Select date range", disabled, className, id, "aria-invalid": ariaInvalid }) {
218
- const [open, setOpen] = useState(false);
219
- const handleSelect = (range) => {
220
- onChange({
221
- start: range?.from ?? null,
222
- end: range?.to ?? null
223
- });
224
- };
225
- const handleClear = (e) => {
226
- e.stopPropagation();
227
- onChange({
228
- start: null,
229
- end: null
230
- });
231
- };
232
- const displayValue = () => {
233
- if (!value.start && !value.end) return placeholder;
234
- if (value.start && value.end) return `${format(value.start, "PP")} - ${format(value.end, "PP")}`;
235
- if (value.start) return `${format(value.start, "PP")} - ...`;
236
- return placeholder;
237
- };
238
- return /* @__PURE__ */ jsxs(Popover, {
239
- open,
240
- onOpenChange: setOpen,
241
- children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
242
- id,
243
- disabled,
244
- "aria-invalid": ariaInvalid,
245
- className: cn("flex h-9 w-full items-center justify-start gap-2 border border-input bg-background px-3 py-2 text-sm", "hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:opacity-50", !value.start && !value.end && "text-muted-foreground", className),
246
- children: [
247
- /* @__PURE__ */ jsx(CalendarBlank, { className: "size-4" }),
248
- /* @__PURE__ */ jsx("span", {
249
- className: "flex-1 text-left",
250
- children: displayValue()
251
- }),
252
- (value.start || value.end) && !disabled && /* @__PURE__ */ jsx(X, {
253
- className: "size-4 opacity-50 hover:opacity-100",
254
- onClick: handleClear
255
- })
256
- ]
257
- }), /* @__PURE__ */ jsx(PopoverContent, {
258
- className: "w-auto p-0",
259
- align: "start",
260
- children: /* @__PURE__ */ jsx(DayPicker, {
261
- mode: "range",
262
- selected: value.start || value.end ? {
263
- from: value.start ?? void 0,
264
- to: value.end ?? void 0
265
- } : void 0,
266
- onSelect: handleSelect,
267
- numberOfMonths: 2,
268
- disabled: (date) => {
269
- if (minDate && date < minDate) return true;
270
- if (maxDate && date > maxDate) return true;
271
- return false;
272
- },
273
- className: "p-3",
274
- classNames: {
275
- months: "flex flex-col sm:flex-row gap-2",
276
- month: "flex flex-col gap-4",
277
- month_caption: "flex justify-center pt-1 relative items-center w-full",
278
- caption_label: "text-sm font-medium",
279
- nav: "flex items-center gap-1",
280
- button_previous: "absolute left-1 size-7 bg-transparent p-0 opacity-50 hover:opacity-100",
281
- button_next: "absolute right-1 size-7 bg-transparent p-0 opacity-50 hover:opacity-100",
282
- month_grid: "w-full border-collapse",
283
- weekdays: "flex",
284
- weekday: "text-muted-foreground w-8 font-normal text-[0.8rem]",
285
- week: "flex w-full mt-2",
286
- day: "relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50",
287
- day_button: cn("size-8 p-0 font-normal", "hover:bg-accent hover:text-accent-foreground", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),
288
- selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
289
- range_start: "rounded-l-md",
290
- range_end: "rounded-r-md",
291
- range_middle: "bg-accent",
292
- today: "bg-accent text-accent-foreground",
293
- outside: "text-muted-foreground opacity-50",
294
- disabled: "text-muted-foreground opacity-50",
295
- hidden: "invisible"
296
- }
297
- })
298
- })]
299
- });
300
- }
301
-
302
- //#endregion
303
- export { DateInput, DateRangeInput, DateTimeInput };
@@ -1,12 +0,0 @@
1
- import { TextInput } from "./text-input";
2
- import { NumberInput } from "./number-input";
3
- import { TextareaInput } from "./textarea-input";
4
- import { SelectInput } from "./select-input";
5
- import { ToggleInput } from "./toggle-input";
6
- import { CheckboxGroup, CheckboxInput, RadioGroup } from "./checkbox-input";
7
- import { DateInput, DateRangeInput, DateTimeInput } from "./date-input";
8
- import { TagInput } from "./tag-input";
9
-
10
- export * from "./types"
11
-
12
- export { CheckboxGroup, CheckboxInput, DateInput, DateRangeInput, DateTimeInput, NumberInput, RadioGroup, SelectInput, TagInput, TextInput, TextareaInput, ToggleInput };