@vitnode/core 1.2.0-canary.60 → 1.2.0-canary.61

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 (274) hide show
  1. package/dist/scripts/get-config.js +15 -0
  2. package/dist/scripts/plugin.js +188 -0
  3. package/dist/scripts/prepare-database.js +177 -0
  4. package/dist/scripts/prepare-plugins-files.js +134 -0
  5. package/dist/scripts/run-interactive-shell-command.js +21 -0
  6. package/dist/scripts/scripts.js +39 -13
  7. package/dist/scripts/shared/file-utils.js +203 -0
  8. package/dist/src/api/adapters/sso/discord.js +1 -77
  9. package/dist/src/api/adapters/sso/facebook.js +1 -76
  10. package/dist/src/api/adapters/sso/google.js +1 -87
  11. package/dist/src/api/config.js +1 -67
  12. package/dist/src/api/lib/check-plugin-id.js +1 -43
  13. package/dist/src/api/lib/cron.js +1 -22
  14. package/dist/src/api/lib/logger-middleware.js +1 -35
  15. package/dist/src/api/lib/module.js +1 -22
  16. package/dist/src/api/lib/plugin.js +1 -22
  17. package/dist/src/api/lib/route.js +1 -27
  18. package/dist/src/api/lib/with-pagination.js +1 -83
  19. package/dist/src/api/middlewares/captcha.middleware.js +1 -63
  20. package/dist/src/api/middlewares/cron-auth.middleware.js +1 -19
  21. package/dist/src/api/middlewares/global.middleware.js +1 -93
  22. package/dist/src/api/middlewares/rate-limiter.middleware.js +1 -32
  23. package/dist/src/api/models/device.js +1 -61
  24. package/dist/src/api/models/email.js +1 -76
  25. package/dist/src/api/models/password.js +1 -36
  26. package/dist/src/api/models/session-admin.js +1 -106
  27. package/dist/src/api/models/session.js +1 -85
  28. package/dist/src/api/models/sso.js +1 -120
  29. package/dist/src/api/models/user/get-user-by-id.js +1 -19
  30. package/dist/src/api/models/user/sign-in-with-passwords.js +1 -22
  31. package/dist/src/api/models/user/sign-up.js +1 -73
  32. package/dist/src/api/models/user.js +1 -8
  33. package/dist/src/api/modules/admin/admin.module.js +1 -19
  34. package/dist/src/api/modules/admin/advanced/advanced.admin.module.js +1 -11
  35. package/dist/src/api/modules/admin/advanced/cron/cron.admin.module.js +1 -12
  36. package/dist/src/api/modules/admin/advanced/cron/routes/get.route.js +1 -66
  37. package/dist/src/api/modules/admin/advanced/cron/routes/run.route.js +1 -95
  38. package/dist/src/api/modules/admin/debug/debug.admin.module.js +1 -10
  39. package/dist/src/api/modules/admin/debug/routes/logs.route.js +1 -94
  40. package/dist/src/api/modules/admin/routes/session.route.js +1 -47
  41. package/dist/src/api/modules/admin/users/routes/list.route.js +1 -79
  42. package/dist/src/api/modules/admin/users/routes/users.route.js +1 -84
  43. package/dist/src/api/modules/admin/users/users.admin.module.js +1 -10
  44. package/dist/src/api/modules/cron/cron/clean.cron.js +1 -24
  45. package/dist/src/api/modules/cron/cron.module.js +1 -14
  46. package/dist/src/api/modules/cron/helpers/process-cron-jobs.d.ts.map +1 -1
  47. package/dist/src/api/modules/cron/helpers/process-cron-jobs.js +1 -76
  48. package/dist/src/api/modules/cron/routes/cron.route.js +1 -101
  49. package/dist/src/api/modules/middleware/middleware.module.js +1 -10
  50. package/dist/src/api/modules/middleware/route.js +1 -49
  51. package/dist/src/api/modules/users/avatar-color.js +1 -43
  52. package/dist/src/api/modules/users/routes/change-password.route.js +1 -58
  53. package/dist/src/api/modules/users/routes/reset-passowrd.route.js +1 -91
  54. package/dist/src/api/modules/users/routes/session.route.js +1 -46
  55. package/dist/src/api/modules/users/routes/sign-in.route.js +1 -71
  56. package/dist/src/api/modules/users/routes/sign-out.route.js +1 -43
  57. package/dist/src/api/modules/users/routes/sign-up.route.js +1 -77
  58. package/dist/src/api/modules/users/routes/test.route.js +1 -33
  59. package/dist/src/api/modules/users/sso/routes/callback.route.js +1 -52
  60. package/dist/src/api/modules/users/sso/routes/create-url.route.js +1 -36
  61. package/dist/src/api/modules/users/sso/sso.module.js +1 -12
  62. package/dist/src/api/modules/users/users.module.js +1 -26
  63. package/dist/src/api/plugin.js +1 -15
  64. package/dist/src/app/login/page.js +1 -16
  65. package/dist/src/app/login/reset-password/page.js +1 -18
  66. package/dist/src/app/login/sso/[providerId]/page.js +1 -10
  67. package/dist/src/app/register/page.js +1 -16
  68. package/dist/src/app_admin/core/advanced/cron/page.js +1 -42
  69. package/dist/src/app_admin/core/debug/page.js +1 -45
  70. package/dist/src/app_admin/core/page.js +1 -5
  71. package/dist/src/app_admin/core/test/page.js +1 -5
  72. package/dist/src/app_admin/core/users/page.js +1 -38
  73. package/dist/src/components/avatar.js +1 -14
  74. package/dist/src/components/confirm-action/confirm-action-alert-dialog.js +1 -42
  75. package/dist/src/components/confirm-action/content.js +1 -31
  76. package/dist/src/components/date-format.js +1 -41
  77. package/dist/src/components/form/auto-form.js +1 -103
  78. package/dist/src/components/form/common/desc.js +1 -9
  79. package/dist/src/components/form/common/label.js +1 -18
  80. package/dist/src/components/form/fields/checkbox.js +1 -37
  81. package/dist/src/components/form/fields/combobox-async.js +1 -123
  82. package/dist/src/components/form/fields/combobox.js +1 -87
  83. package/dist/src/components/form/fields/input.js +1 -39
  84. package/dist/src/components/form/fields/radio-group.js +1 -50
  85. package/dist/src/components/form/fields/select.js +1 -58
  86. package/dist/src/components/form/fields/switch.js +1 -36
  87. package/dist/src/components/form/fields/textarea.js +1 -36
  88. package/dist/src/components/i18n-provider.js +1 -43
  89. package/dist/src/components/logo-vitnode.js +1 -119
  90. package/dist/src/components/switchers/langs/language-switcher.js +1 -47
  91. package/dist/src/components/switchers/themes/theme-switcher.js +1 -28
  92. package/dist/src/components/table/content.js +1 -81
  93. package/dist/src/components/table/data-table.js +1 -68
  94. package/dist/src/components/table/order-table-head.js +1 -50
  95. package/dist/src/components/table/pagination.js +1 -122
  96. package/dist/src/components/tiptap/extension.js +1 -33
  97. package/dist/src/components/tiptap/toolbar/actions/alignment-action.js +1 -91
  98. package/dist/src/components/tiptap/toolbar/actions/bold-action.js +1 -39
  99. package/dist/src/components/tiptap/toolbar/actions/headings-action.js +1 -93
  100. package/dist/src/components/tiptap/toolbar/actions/italic-action.js +1 -38
  101. package/dist/src/components/tiptap/toolbar/actions/list-action.js +1 -61
  102. package/dist/src/components/tiptap/toolbar/actions/text-format-more/text-format-more.js +1 -59
  103. package/dist/src/components/tiptap/toolbar/actions/underline-action.js +1 -38
  104. package/dist/src/components/tiptap/toolbar/actions/undo-redo-actions.js +1 -63
  105. package/dist/src/components/tiptap/toolbar/actions/utils/tooltip-shortcut.js +1 -11
  106. package/dist/src/components/tiptap/toolbar/tiptap-toolbar.js +1 -55
  107. package/dist/src/components/tiptap/toolbar/use-toolbar-editor.js +1 -5
  108. package/dist/src/components/ui/accordion.js +1 -46
  109. package/dist/src/components/ui/alert-dialog.js +1 -123
  110. package/dist/src/components/ui/alert.js +1 -39
  111. package/dist/src/components/ui/badge.js +1 -28
  112. package/dist/src/components/ui/button-client.js +1 -57
  113. package/dist/src/components/ui/button.js +1 -32
  114. package/dist/src/components/ui/card.js +1 -52
  115. package/dist/src/components/ui/checkbox.js +1 -20
  116. package/dist/src/components/ui/collapsible.js +1 -22
  117. package/dist/src/components/ui/command.js +1 -98
  118. package/dist/src/components/ui/context-menu.js +1 -140
  119. package/dist/src/components/ui/dialog.js +1 -189
  120. package/dist/src/components/ui/drawer.js +1 -83
  121. package/dist/src/components/ui/dropdown-menu.js +1 -141
  122. package/dist/src/components/ui/editor-content.js +1 -10
  123. package/dist/src/components/ui/editor.js +1 -35
  124. package/dist/src/components/ui/form.js +1 -148
  125. package/dist/src/components/ui/header-content.js +1 -30
  126. package/dist/src/components/ui/hover-card.js +1 -29
  127. package/dist/src/components/ui/input-otp.js +1 -48
  128. package/dist/src/components/ui/input.js +1 -11
  129. package/dist/src/components/ui/label.js +1 -12
  130. package/dist/src/components/ui/loader.js +1 -16
  131. package/dist/src/components/ui/menubar.js +1 -151
  132. package/dist/src/components/ui/navigation-menu.js +1 -82
  133. package/dist/src/components/ui/popover.js +1 -35
  134. package/dist/src/components/ui/progress.js +1 -19
  135. package/dist/src/components/ui/radio-group.js +1 -27
  136. package/dist/src/components/ui/scroll-area.js +1 -33
  137. package/dist/src/components/ui/select.js +1 -113
  138. package/dist/src/components/ui/separator.js +1 -14
  139. package/dist/src/components/ui/sheet.js +1 -92
  140. package/dist/src/components/ui/sidebar.js +1 -433
  141. package/dist/src/components/ui/skeleton.js +1 -10
  142. package/dist/src/components/ui/slider.js +1 -50
  143. package/dist/src/components/ui/sonner.js +1 -26
  144. package/dist/src/components/ui/switch.js +1 -16
  145. package/dist/src/components/ui/table.js +1 -63
  146. package/dist/src/components/ui/tabs.js +1 -33
  147. package/dist/src/components/ui/textarea.js +1 -10
  148. package/dist/src/components/ui/toggle-group.js +1 -45
  149. package/dist/src/components/ui/toggle.js +1 -34
  150. package/dist/src/components/ui/tooltip.js +1 -57
  151. package/dist/src/config.js +1 -4
  152. package/dist/src/database/admins.js +1 -74
  153. package/dist/src/database/cron.js +1 -22
  154. package/dist/src/database/languages.js +1 -52
  155. package/dist/src/database/logs.js +1 -34
  156. package/dist/src/database/moderators.js +1 -37
  157. package/dist/src/database/roles.js +1 -13
  158. package/dist/src/database/sessions.js +1 -60
  159. package/dist/src/database/users.js +1 -145
  160. package/dist/src/drizzle.config.js +1 -67
  161. package/dist/src/emails/default-template.js +1 -99
  162. package/dist/src/emails/reset-password.js +1 -132
  163. package/dist/src/emails/ui/button.js +1 -36
  164. package/dist/src/emails/ui/card.js +1 -39
  165. package/dist/src/hooks/use-before-unload.js +1 -30
  166. package/dist/src/hooks/use-captcha.js +1 -122
  167. package/dist/src/hooks/use-mobile.js +1 -16
  168. package/dist/src/lib/api/get-middleware-api.js +1 -13
  169. package/dist/src/lib/api/get-next-cron-run-date.js +1 -14
  170. package/dist/src/lib/api/get-next-cron-run-date.test.js +1 -55
  171. package/dist/src/lib/api/get-session-admin-api.js +1 -19
  172. package/dist/src/lib/api/get-session-api.js +1 -14
  173. package/dist/src/lib/api/should-cron-job-run.js +1 -16
  174. package/dist/src/lib/api/should-cron-job-run.test.js +1 -213
  175. package/dist/src/lib/api/validate-cron-schedule.d.ts +2 -0
  176. package/dist/src/lib/api/validate-cron-schedule.d.ts.map +1 -0
  177. package/dist/src/lib/api/validate-cron-schedule.js +1 -0
  178. package/dist/src/lib/api/validate-cron-schedule.test.d.ts +2 -0
  179. package/dist/src/lib/api/validate-cron-schedule.test.d.ts.map +1 -0
  180. package/dist/src/lib/api/validate-cron-schedule.test.js +1 -0
  181. package/dist/src/lib/colors.js +1 -140
  182. package/dist/src/lib/colors.test.js +1 -173
  183. package/dist/src/lib/config.js +1 -14
  184. package/dist/src/lib/ctrl-or-command-character.js +1 -5
  185. package/dist/src/lib/fetcher/cookie-from-string-to-object.js +1 -12
  186. package/dist/src/lib/fetcher/cookie-from-string-to-object.test.js +1 -78
  187. package/dist/src/lib/fetcher/core.js +3 -48
  188. package/dist/src/lib/fetcher/helpers-server.js +1 -18
  189. package/dist/src/lib/fetcher/helpers.js +1 -16
  190. package/dist/src/lib/fetcher/helpers.test.js +1 -37
  191. package/dist/src/lib/fetcher/types.js +1 -1
  192. package/dist/src/lib/fetcher-client.js +1 -17
  193. package/dist/src/lib/fetcher.js +1 -33
  194. package/dist/src/lib/helpers/auto-form.js +1 -98
  195. package/dist/src/lib/helpers/auto-form.test.js +1 -336
  196. package/dist/src/lib/navigation.js +1 -11
  197. package/dist/src/lib/plugin.js +1 -3
  198. package/dist/src/lib/special-characters.js +1 -4
  199. package/dist/src/lib/special-characters.test.js +1 -56
  200. package/dist/src/lib/utils.js +1 -5
  201. package/dist/src/locales/en.json +308 -0
  202. package/dist/src/tests/setup.js +1 -6
  203. package/dist/src/views/admin/layouts/admin-layout.js +1 -73
  204. package/dist/src/views/admin/layouts/sidebar/nav/item.js +1 -98
  205. package/dist/src/views/admin/layouts/sidebar/nav/nav.js +1 -60
  206. package/dist/src/views/admin/layouts/sidebar/sidebar.js +1 -28
  207. package/dist/src/views/admin/layouts/sidebar/sign-out.js +1 -14
  208. package/dist/src/views/admin/layouts/user-bar/client.js +1 -69
  209. package/dist/src/views/admin/layouts/user-bar/user-bar.js +1 -32
  210. package/dist/src/views/admin/sign-in/sign-in-admin-view.js +1 -27
  211. package/dist/src/views/admin/views/core/advanced/cron/cron-table-view.js +1 -97
  212. package/dist/src/views/admin/views/core/advanced/cron/run-action/mutation-api.js +1 -23
  213. package/dist/src/views/admin/views/core/advanced/cron/run-action/run-action.js +1 -38
  214. package/dist/src/views/admin/views/core/dashboard/dashboard-admin-view.js +1 -44
  215. package/dist/src/views/admin/views/core/debug/actions/clear-cache/clear-cache.js +1 -35
  216. package/dist/src/views/admin/views/core/debug/actions/clear-cache/mutation-api.js +1 -5
  217. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/content.js +1 -281
  218. package/dist/src/views/admin/views/core/debug/system-logs/actions/more/more.js +1 -67
  219. package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-status.js +1 -14
  220. package/dist/src/views/admin/views/core/debug/system-logs/badges/badge-type-log.js +1 -30
  221. package/dist/src/views/admin/views/core/debug/system-logs/system-logs-view.js +1 -96
  222. package/dist/src/views/admin/views/core/test.js +1 -161
  223. package/dist/src/views/admin/views/core/users/users-admin-view.js +1 -89
  224. package/dist/src/views/auth/password-reset/change-password-form/form.js +1 -48
  225. package/dist/src/views/auth/password-reset/change-password-form/mutation-api.js +1 -22
  226. package/dist/src/views/auth/password-reset/change-password-form/use-form.js +1 -36
  227. package/dist/src/views/auth/password-reset/form/form.js +1 -104
  228. package/dist/src/views/auth/password-reset/form/mutation-api.js +1 -21
  229. package/dist/src/views/auth/password-reset/form/use-form.js +1 -33
  230. package/dist/src/views/auth/password-reset/password-reset-view.js +1 -37
  231. package/dist/src/views/auth/sign-in/form/form.js +1 -64
  232. package/dist/src/views/auth/sign-in/form/mutation-api.js +1 -33
  233. package/dist/src/views/auth/sign-in/form/use-form.js +1 -38
  234. package/dist/src/views/auth/sign-in/sign-in-view.js +1 -61
  235. package/dist/src/views/auth/sign-up/components/password-input.js +1 -96
  236. package/dist/src/views/auth/sign-up/email-confirmation-view.js +1 -55
  237. package/dist/src/views/auth/sign-up/form/form.js +1 -89
  238. package/dist/src/views/auth/sign-up/form/mutation-api.js +1 -30
  239. package/dist/src/views/auth/sign-up/form/use-form.js +1 -70
  240. package/dist/src/views/auth/sign-up/sign-up-view.js +1 -65
  241. package/dist/src/views/auth/sign-up/wrapper.js +1 -22
  242. package/dist/src/views/auth/sso/buttons/client.js +1 -22
  243. package/dist/src/views/auth/sso/buttons/mutation-api.js +1 -24
  244. package/dist/src/views/auth/sso/buttons/sso-buttons.js +1 -56
  245. package/dist/src/views/auth/sso/callback/callback-sso-view.js +1 -32
  246. package/dist/src/views/auth/sso/callback/client/client.js +1 -68
  247. package/dist/src/views/auth/sso/callback/client/mutation-api.js +1 -32
  248. package/dist/src/views/error/back-button.js +1 -14
  249. package/dist/src/views/error/error-view.js +1 -58
  250. package/dist/src/views/error/global-error-view.js +1 -50
  251. package/dist/src/views/layouts/provider.js +1 -44
  252. package/dist/src/views/layouts/root-layout.js +1 -25
  253. package/dist/src/views/layouts/theme/header/header.js +1 -38
  254. package/dist/src/views/layouts/theme/header/user/auth/auth.js +1 -33
  255. package/dist/src/views/layouts/theme/header/user/auth/client.js +1 -47
  256. package/dist/src/views/layouts/theme/header/user/auth/log-out-mutation-api.js +1 -27
  257. package/dist/src/views/layouts/theme/header/user/user.js +1 -32
  258. package/dist/src/views/layouts/theme/layout.js +1 -16
  259. package/dist/src/vitnode.config.js +1 -42
  260. package/dist/tsconfig.tsbuildinfo +1 -1
  261. package/dist/tsup.config.js +18 -0
  262. package/dist/vitest.config.d.ts.map +1 -1
  263. package/dist/vitest.config.js +49 -0
  264. package/eslint.config.mjs +2 -0
  265. package/package.json +6 -10
  266. package/dist/src/api/adapters/cron/node-cron.adapter.d.ts +0 -3
  267. package/dist/src/api/adapters/cron/node-cron.adapter.d.ts.map +0 -1
  268. package/dist/src/api/adapters/cron/node-cron.adapter.js +0 -11
  269. package/dist/src/api/adapters/email/nodemailer.d.ts +0 -10
  270. package/dist/src/api/adapters/email/nodemailer.d.ts.map +0 -1
  271. package/dist/src/api/adapters/email/nodemailer.js +0 -30
  272. package/dist/src/api/adapters/email/resend.d.ts +0 -6
  273. package/dist/src/api/adapters/email/resend.d.ts.map +0 -1
  274. package/dist/src/api/adapters/email/resend.js +0 -21
@@ -1,9 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { cn } from "../../../lib/utils.js";
3
- export const AutoFormDesc = ({ children, className, ...props })=>{
4
- return /*#__PURE__*/ _jsx("p", {
5
- className: cn("text-muted-foreground text-sm", className),
6
- ...props,
7
- children: children
8
- });
9
- };
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{cn}from"../../../lib/utils.js";export const AutoFormDesc=({children,className,...props})=>{return _jsx("p",{className:cn("text-muted-foreground text-sm",className),...props,children:children})};
@@ -1,18 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FormLabel } from "../../ui/form.js";
3
- import { cn } from "../../../lib/utils.js";
4
- export const AutoFormLabel = ({ children, labelRight, className, ...props })=>{
5
- return /*#__PURE__*/ _jsxs(FormLabel, {
6
- className: cn({
7
- "flex flex-wrap items-center": labelRight
8
- }, className),
9
- ...props,
10
- children: [
11
- children,
12
- labelRight && /*#__PURE__*/ _jsx("span", {
13
- className: "ml-auto",
14
- children: labelRight
15
- })
16
- ]
17
- });
18
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{FormLabel}from"../../ui/form.js";import{cn}from"../../../lib/utils.js";export const AutoFormLabel=({children,labelRight,className,...props})=>{return _jsxs(FormLabel,{className:cn({"flex flex-wrap items-center":labelRight},className),...props,children:[children,labelRight&&_jsx("span",{className:"ml-auto",children:labelRight})]})};
@@ -1,37 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Checkbox } from "../../ui/checkbox.js";
3
- import { FormControl, FormItem, FormMessage } from "../../ui/form.js";
4
- import { AutoFormDesc } from "../common/desc.js";
5
- import { AutoFormLabel } from "../common/label.js";
6
- export const AutoFormCheckbox = ({ label, labelRight, description, otherProps: { isOptional }, field, ...props })=>{
7
- return /*#__PURE__*/ _jsxs(FormItem, {
8
- className: "flex flex-row items-start space-y-0 space-x-3 rounded-md border p-4",
9
- children: [
10
- /*#__PURE__*/ _jsx(FormControl, {
11
- children: /*#__PURE__*/ _jsx(Checkbox, {
12
- checked: field.value ?? false,
13
- onCheckedChange: (e)=>{
14
- field.onChange(e);
15
- props.onCheckedChange?.(e);
16
- },
17
- ...field,
18
- ...props
19
- })
20
- }),
21
- !!(label ?? description) && /*#__PURE__*/ _jsxs("div", {
22
- className: "space-y-1 leading-none",
23
- children: [
24
- label && /*#__PURE__*/ _jsx(AutoFormLabel, {
25
- isOptional: isOptional,
26
- labelRight: labelRight,
27
- children: label
28
- }),
29
- description && /*#__PURE__*/ _jsx(AutoFormDesc, {
30
- children: description
31
- }),
32
- /*#__PURE__*/ _jsx(FormMessage, {})
33
- ]
34
- })
35
- ]
36
- });
37
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Checkbox}from"../../ui/checkbox.js";import{FormControl,FormItem,FormMessage}from"../../ui/form.js";import{AutoFormDesc}from"../common/desc.js";import{AutoFormLabel}from"../common/label.js";export const AutoFormCheckbox=({label,labelRight,description,otherProps:{isOptional},field,...props})=>{return _jsxs(FormItem,{className:"flex flex-row items-start space-y-0 space-x-3 rounded-md border p-4",children:[_jsx(FormControl,{children:_jsx(Checkbox,{checked:field.value??false,onCheckedChange:e=>{field.onChange(e);props.onCheckedChange?.(e)},...field,...props})}),!!(label??description)&&_jsxs("div",{className:"space-y-1 leading-none",children:[label&&_jsx(AutoFormLabel,{isOptional:isOptional,labelRight:labelRight,children:label}),description&&_jsx(AutoFormDesc,{children:description}),_jsx(FormMessage,{})]})]})};
@@ -1,123 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useQuery } from "@tanstack/react-query";
3
- import { Check, ChevronsUpDown } from "lucide-react";
4
- import { useTranslations } from "next-intl";
5
- import React from "react";
6
- import { useDebouncedCallback } from "use-debounce";
7
- import { Button } from "../../ui/button.js";
8
- import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "../../ui/command.js";
9
- import { FormControl, FormItem, FormMessage } from "../../ui/form.js";
10
- import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
11
- import { cn } from "../../../lib/utils.js";
12
- import { Skeleton } from "../../ui/skeleton.js";
13
- import { AutoFormDesc } from "../common/desc.js";
14
- import { AutoFormLabel } from "../common/label.js";
15
- export const AutoFormComboboxAsync = ({ label, field, description, placeholder, className, labelRight, id, otherProps: { isOptional }, searchPlaceholder, fetchData, ...props })=>{
16
- const t = useTranslations("core.global");
17
- const [search, setSearch] = React.useState("");
18
- const { data, isLoading } = useQuery({
19
- queryKey: [
20
- id,
21
- {
22
- search
23
- }
24
- ],
25
- queryFn: async ()=>{
26
- return await fetchData({
27
- search
28
- });
29
- }
30
- });
31
- const handleChangeSearch = useDebouncedCallback((value)=>{
32
- setSearch(value);
33
- }, 500);
34
- return /*#__PURE__*/ _jsxs(FormItem, {
35
- className: "flex flex-col",
36
- children: [
37
- label && /*#__PURE__*/ _jsx(AutoFormLabel, {
38
- isOptional: isOptional,
39
- labelRight: labelRight,
40
- children: label
41
- }),
42
- /*#__PURE__*/ _jsxs(Popover, {
43
- children: [
44
- /*#__PURE__*/ _jsx(PopoverTrigger, {
45
- asChild: true,
46
- children: /*#__PURE__*/ _jsx(FormControl, {
47
- children: /*#__PURE__*/ _jsxs(Button, {
48
- "aria-label": "Combobox",
49
- className: cn("w-[200px] justify-between bg-transparent", !field.value && "text-muted-foreground", className),
50
- role: "combobox",
51
- variant: "outline",
52
- ...props,
53
- children: [
54
- field.value?.label ?? placeholder ?? t("select_option"),
55
- /*#__PURE__*/ _jsx(ChevronsUpDown, {
56
- className: "ml-2 size-4 shrink-0 opacity-50"
57
- })
58
- ]
59
- })
60
- })
61
- }),
62
- /*#__PURE__*/ _jsx(PopoverContent, {
63
- className: "w-[200px] p-0",
64
- children: /*#__PURE__*/ _jsxs(Command, {
65
- shouldFilter: false,
66
- children: [
67
- /*#__PURE__*/ _jsx(CommandInput, {
68
- onChangeCapture: (e)=>{
69
- handleChangeSearch(e.currentTarget.value);
70
- },
71
- placeholder: searchPlaceholder ?? t("search_placeholder")
72
- }),
73
- /*#__PURE__*/ _jsx(CommandList, {
74
- children: (()=>{
75
- if (isLoading) {
76
- return /*#__PURE__*/ _jsxs("div", {
77
- className: "space-y-2 p-2",
78
- children: [
79
- /*#__PURE__*/ _jsx(Skeleton, {
80
- className: "h-6 rounded-sm"
81
- }),
82
- /*#__PURE__*/ _jsx(Skeleton, {
83
- className: "h-6 rounded-sm"
84
- })
85
- ]
86
- });
87
- }
88
- if ((data ?? []).length === 0) {
89
- return /*#__PURE__*/ _jsx(CommandEmpty, {
90
- children: t("results_not_found")
91
- });
92
- }
93
- return /*#__PURE__*/ _jsx(CommandGroup, {
94
- children: (data ?? []).map(({ label, value })=>/*#__PURE__*/ _jsxs(CommandItem, {
95
- onSelect: ()=>{
96
- field.onChange({
97
- label,
98
- value
99
- });
100
- },
101
- value: label,
102
- children: [
103
- label,
104
- /*#__PURE__*/ _jsx(Check, {
105
- className: cn("ml-auto", value === field.value?.value ? "opacity-100" : "opacity-0")
106
- })
107
- ]
108
- }, value))
109
- });
110
- })()
111
- })
112
- ]
113
- })
114
- })
115
- ]
116
- }),
117
- description && /*#__PURE__*/ _jsx(AutoFormDesc, {
118
- children: description
119
- }),
120
- /*#__PURE__*/ _jsx(FormMessage, {})
121
- ]
122
- });
123
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useQuery}from"@tanstack/react-query";import{Check,ChevronsUpDown}from"lucide-react";import{useTranslations}from"next-intl";import React from"react";import{useDebouncedCallback}from"use-debounce";import{Button}from"../../ui/button.js";import{Command,CommandEmpty,CommandGroup,CommandInput,CommandItem,CommandList}from"../../ui/command.js";import{FormControl,FormItem,FormMessage}from"../../ui/form.js";import{Popover,PopoverContent,PopoverTrigger}from"../../ui/popover.js";import{cn}from"../../../lib/utils.js";import{Skeleton}from"../../ui/skeleton.js";import{AutoFormDesc}from"../common/desc.js";import{AutoFormLabel}from"../common/label.js";export const AutoFormComboboxAsync=({label,field,description,placeholder,className,labelRight,id,otherProps:{isOptional},searchPlaceholder,fetchData,...props})=>{const t=useTranslations("core.global");const[search,setSearch]=React.useState("");const{data,isLoading}=useQuery({queryKey:[id,{search}],queryFn:async()=>{return await fetchData({search})}});const handleChangeSearch=useDebouncedCallback(value=>{setSearch(value)},500);return _jsxs(FormItem,{className:"flex flex-col",children:[label&&_jsx(AutoFormLabel,{isOptional:isOptional,labelRight:labelRight,children:label}),_jsxs(Popover,{children:[_jsx(PopoverTrigger,{asChild:true,children:_jsx(FormControl,{children:_jsxs(Button,{"aria-label":"Combobox",className:cn("w-[200px] justify-between bg-transparent",!field.value&&"text-muted-foreground",className),role:"combobox",variant:"outline",...props,children:[field.value?.label??placeholder??t("select_option"),_jsx(ChevronsUpDown,{className:"ml-2 size-4 shrink-0 opacity-50"})]})})}),_jsx(PopoverContent,{className:"w-[200px] p-0",children:_jsxs(Command,{shouldFilter:false,children:[_jsx(CommandInput,{onChangeCapture:e=>{handleChangeSearch(e.currentTarget.value)},placeholder:searchPlaceholder??t("search_placeholder")}),_jsx(CommandList,{children:(()=>{if(isLoading){return _jsxs("div",{className:"space-y-2 p-2",children:[_jsx(Skeleton,{className:"h-6 rounded-sm"}),_jsx(Skeleton,{className:"h-6 rounded-sm"})]})}if((data??[]).length===0){return _jsx(CommandEmpty,{children:t("results_not_found")})}return _jsx(CommandGroup,{children:(data??[]).map(({label,value})=>_jsxs(CommandItem,{onSelect:()=>{field.onChange({label,value})},value:label,children:[label,_jsx(Check,{className:cn("ml-auto",value===field.value?.value?"opacity-100":"opacity-0")})]},value))})})()})]})})]}),description&&_jsx(AutoFormDesc,{children:description}),_jsx(FormMessage,{})]})};
@@ -1,87 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Check, ChevronsUpDown } from "lucide-react";
3
- import { useTranslations } from "next-intl";
4
- import { Button } from "../../ui/button.js";
5
- import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "../../ui/command.js";
6
- import { FormControl, FormItem, FormMessage } from "../../ui/form.js";
7
- import { Popover, PopoverContent, PopoverTrigger } from "../../ui/popover.js";
8
- import { cn } from "../../../lib/utils.js";
9
- import { AutoFormDesc } from "../common/desc.js";
10
- import { AutoFormLabel } from "../common/label.js";
11
- export const AutoFormCombobox = ({ label, field, description, placeholder, className, otherProps: { enum: enumValues = [], isOptional }, labels = [], labelRight, searchPlaceholder, ...props })=>{
12
- const t = useTranslations("core.global");
13
- const values = enumValues.map((value)=>{
14
- const label = labels.find((l)=>l.value === value)?.label;
15
- return {
16
- value,
17
- label: label ?? value
18
- };
19
- });
20
- return /*#__PURE__*/ _jsxs(FormItem, {
21
- className: "flex flex-col",
22
- children: [
23
- label && /*#__PURE__*/ _jsx(AutoFormLabel, {
24
- isOptional: isOptional,
25
- labelRight: labelRight,
26
- children: label
27
- }),
28
- /*#__PURE__*/ _jsxs(Popover, {
29
- children: [
30
- /*#__PURE__*/ _jsx(PopoverTrigger, {
31
- asChild: true,
32
- children: /*#__PURE__*/ _jsx(FormControl, {
33
- children: /*#__PURE__*/ _jsxs(Button, {
34
- "aria-label": "Combobox",
35
- className: cn("w-[200px] justify-between", !field.value && "text-muted-foreground", className),
36
- role: "combobox",
37
- variant: "outline",
38
- ...props,
39
- children: [
40
- field.value ? values.find(({ value })=>value === field.value)?.label : placeholder ?? t("select_option"),
41
- /*#__PURE__*/ _jsx(ChevronsUpDown, {
42
- className: "ml-2 size-4 shrink-0 opacity-50"
43
- })
44
- ]
45
- })
46
- })
47
- }),
48
- /*#__PURE__*/ _jsx(PopoverContent, {
49
- className: "w-[200px] p-0",
50
- children: /*#__PURE__*/ _jsxs(Command, {
51
- children: [
52
- /*#__PURE__*/ _jsx(CommandInput, {
53
- placeholder: searchPlaceholder ?? t("search_placeholder")
54
- }),
55
- /*#__PURE__*/ _jsxs(CommandList, {
56
- children: [
57
- /*#__PURE__*/ _jsx(CommandEmpty, {
58
- children: t("results_not_found")
59
- }),
60
- /*#__PURE__*/ _jsx(CommandGroup, {
61
- children: values.map(({ label, value })=>/*#__PURE__*/ _jsxs(CommandItem, {
62
- onSelect: ()=>{
63
- field.onChange(value);
64
- },
65
- value: label,
66
- children: [
67
- label,
68
- /*#__PURE__*/ _jsx(Check, {
69
- className: cn("ml-auto", value === field.value ? "opacity-100" : "opacity-0")
70
- })
71
- ]
72
- }, value))
73
- })
74
- ]
75
- })
76
- ]
77
- })
78
- })
79
- ]
80
- }),
81
- description && /*#__PURE__*/ _jsx(AutoFormDesc, {
82
- children: description
83
- }),
84
- /*#__PURE__*/ _jsx(FormMessage, {})
85
- ]
86
- });
87
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Check,ChevronsUpDown}from"lucide-react";import{useTranslations}from"next-intl";import{Button}from"../../ui/button.js";import{Command,CommandEmpty,CommandGroup,CommandInput,CommandItem,CommandList}from"../../ui/command.js";import{FormControl,FormItem,FormMessage}from"../../ui/form.js";import{Popover,PopoverContent,PopoverTrigger}from"../../ui/popover.js";import{cn}from"../../../lib/utils.js";import{AutoFormDesc}from"../common/desc.js";import{AutoFormLabel}from"../common/label.js";export const AutoFormCombobox=({label,field,description,placeholder,className,otherProps:{enum:enumValues=[],isOptional},labels=[],labelRight,searchPlaceholder,...props})=>{const t=useTranslations("core.global");const values=enumValues.map(value=>{const label=labels.find(l=>l.value===value)?.label;return{value,label:label??value}});return _jsxs(FormItem,{className:"flex flex-col",children:[label&&_jsx(AutoFormLabel,{isOptional:isOptional,labelRight:labelRight,children:label}),_jsxs(Popover,{children:[_jsx(PopoverTrigger,{asChild:true,children:_jsx(FormControl,{children:_jsxs(Button,{"aria-label":"Combobox",className:cn("w-[200px] justify-between",!field.value&&"text-muted-foreground",className),role:"combobox",variant:"outline",...props,children:[field.value?values.find(({value})=>value===field.value)?.label:placeholder??t("select_option"),_jsx(ChevronsUpDown,{className:"ml-2 size-4 shrink-0 opacity-50"})]})})}),_jsx(PopoverContent,{className:"w-[200px] p-0",children:_jsxs(Command,{children:[_jsx(CommandInput,{placeholder:searchPlaceholder??t("search_placeholder")}),_jsxs(CommandList,{children:[_jsx(CommandEmpty,{children:t("results_not_found")}),_jsx(CommandGroup,{children:values.map(({label,value})=>_jsxs(CommandItem,{onSelect:()=>{field.onChange(value)},value:label,children:[label,_jsx(Check,{className:cn("ml-auto",value===field.value?"opacity-100":"opacity-0")})]},value))})]})]})})]}),description&&_jsx(AutoFormDesc,{children:description}),_jsx(FormMessage,{})]})};
@@ -1,39 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FormControl, FormItem, FormMessage } from "../../ui/form.js";
3
- import { Input } from "../../ui/input.js";
4
- import { AutoFormDesc } from "../common/desc.js";
5
- import { AutoFormLabel } from "../common/label.js";
6
- export const AutoFormInput = ({ label, labelRight, description, otherProps: { isOptional, maxLength, minLength, pattern, type }, field, ...props })=>{
7
- return /*#__PURE__*/ _jsxs(FormItem, {
8
- children: [
9
- label && /*#__PURE__*/ _jsx(AutoFormLabel, {
10
- isOptional: isOptional,
11
- labelRight: labelRight,
12
- children: label
13
- }),
14
- /*#__PURE__*/ _jsx(FormControl, {
15
- children: /*#__PURE__*/ _jsx(Input, {
16
- ...field,
17
- maxLength: maxLength,
18
- minLength: minLength,
19
- onBlur: (e)=>{
20
- field.onBlur();
21
- props.onBlur?.(e);
22
- },
23
- onChange: (e)=>{
24
- field.onChange(e);
25
- props.onChange?.(e);
26
- },
27
- pattern: pattern,
28
- type: type ?? "text",
29
- value: field.value ?? "",
30
- ...props
31
- })
32
- }),
33
- description && /*#__PURE__*/ _jsx(AutoFormDesc, {
34
- children: description
35
- }),
36
- /*#__PURE__*/ _jsx(FormMessage, {})
37
- ]
38
- });
39
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{FormControl,FormItem,FormMessage}from"../../ui/form.js";import{Input}from"../../ui/input.js";import{AutoFormDesc}from"../common/desc.js";import{AutoFormLabel}from"../common/label.js";export const AutoFormInput=({label,labelRight,description,otherProps:{isOptional,maxLength,minLength,pattern,type},field,...props})=>{return _jsxs(FormItem,{children:[label&&_jsx(AutoFormLabel,{isOptional:isOptional,labelRight:labelRight,children:label}),_jsx(FormControl,{children:_jsx(Input,{...field,maxLength:maxLength,minLength:minLength,onBlur:e=>{field.onBlur();props.onBlur?.(e)},onChange:e=>{field.onChange(e);props.onChange?.(e)},pattern:pattern,type:type??"text",value:field.value??"",...props})}),description&&_jsx(AutoFormDesc,{children:description}),_jsx(FormMessage,{})]})};
@@ -1,50 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FormControl, FormItem, FormLabel, FormMessage } from "../../ui/form.js";
3
- import { RadioGroup, RadioGroupItem } from "../../ui/radio-group.js";
4
- import { AutoFormDesc } from "../common/desc.js";
5
- import { AutoFormLabel } from "../common/label.js";
6
- export const AutoFormRadioGroup = ({ label, labelRight, field, description, otherProps: { enum: enumValues = [], isOptional }, labels = [], ...props })=>{
7
- const values = enumValues.map((value)=>{
8
- const label = labels.find((l)=>l.value === value)?.label;
9
- return {
10
- value,
11
- label: label ?? value
12
- };
13
- });
14
- return /*#__PURE__*/ _jsxs(FormItem, {
15
- className: "space-y-3",
16
- children: [
17
- label && /*#__PURE__*/ _jsx(AutoFormLabel, {
18
- isOptional: isOptional,
19
- labelRight: labelRight,
20
- children: label
21
- }),
22
- /*#__PURE__*/ _jsx(FormControl, {
23
- children: /*#__PURE__*/ _jsx(RadioGroup, {
24
- defaultValue: field.value,
25
- disabled: props.disabled,
26
- onValueChange: field.onChange,
27
- ...props,
28
- children: values.map(({ value, label })=>/*#__PURE__*/ _jsxs(FormItem, {
29
- className: "flex items-center space-y-0 space-x-3",
30
- children: [
31
- /*#__PURE__*/ _jsx(FormControl, {
32
- children: /*#__PURE__*/ _jsx(RadioGroupItem, {
33
- value: value
34
- })
35
- }),
36
- /*#__PURE__*/ _jsx(FormLabel, {
37
- className: "font-normal",
38
- children: label
39
- })
40
- ]
41
- }, value))
42
- })
43
- }),
44
- description && /*#__PURE__*/ _jsx(AutoFormDesc, {
45
- children: description
46
- }),
47
- /*#__PURE__*/ _jsx(FormMessage, {})
48
- ]
49
- });
50
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{FormControl,FormItem,FormLabel,FormMessage}from"../../ui/form.js";import{RadioGroup,RadioGroupItem}from"../../ui/radio-group.js";import{AutoFormDesc}from"../common/desc.js";import{AutoFormLabel}from"../common/label.js";export const AutoFormRadioGroup=({label,labelRight,field,description,otherProps:{enum:enumValues=[],isOptional},labels=[],...props})=>{const values=enumValues.map(value=>{const label=labels.find(l=>l.value===value)?.label;return{value,label:label??value}});return _jsxs(FormItem,{className:"space-y-3",children:[label&&_jsx(AutoFormLabel,{isOptional:isOptional,labelRight:labelRight,children:label}),_jsx(FormControl,{children:_jsx(RadioGroup,{defaultValue:field.value,disabled:props.disabled,onValueChange:field.onChange,...props,children:values.map(({value,label})=>_jsxs(FormItem,{className:"flex items-center space-y-0 space-x-3",children:[_jsx(FormControl,{children:_jsx(RadioGroupItem,{value:value})}),_jsx(FormLabel,{className:"font-normal",children:label})]},value))})}),description&&_jsx(AutoFormDesc,{children:description}),_jsx(FormMessage,{})]})};
@@ -1,58 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useTranslations } from "next-intl";
3
- import { FormControl, FormItem, FormMessage } from "../../ui/form.js";
4
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/select.js";
5
- import { AutoFormDesc } from "../common/desc.js";
6
- import { AutoFormLabel } from "../common/label.js";
7
- export const AutoFormSelect = ({ label, field, description, otherProps: { enum: enumValues = [], isOptional }, placeholder, labelRight, labels = [], ...props })=>{
8
- const t = useTranslations("core.global");
9
- const values = enumValues.map((value)=>{
10
- const label = labels.find((l)=>l.value === value)?.label;
11
- return {
12
- value,
13
- label: label ?? value
14
- };
15
- });
16
- const currentPlaceholder = (values ?? labels).find((l)=>l.value === field.value)?.label ?? t("select_option");
17
- return /*#__PURE__*/ _jsxs(FormItem, {
18
- className: "space-y-3",
19
- children: [
20
- label && /*#__PURE__*/ _jsx(AutoFormLabel, {
21
- isOptional: isOptional,
22
- labelRight: labelRight,
23
- children: label
24
- }),
25
- /*#__PURE__*/ _jsx(FormControl, {
26
- children: /*#__PURE__*/ _jsxs(Select, {
27
- defaultValue: field.value,
28
- disabled: props.disabled,
29
- onValueChange: (e)=>{
30
- field.onChange(e);
31
- props?.onValueChange?.(e);
32
- },
33
- ...props,
34
- children: [
35
- /*#__PURE__*/ _jsx(SelectTrigger, {
36
- ...props,
37
- children: /*#__PURE__*/ _jsx(SelectValue, {
38
- onBlur: field.onBlur,
39
- placeholder: placeholder ?? currentPlaceholder,
40
- children: currentPlaceholder
41
- })
42
- }),
43
- /*#__PURE__*/ _jsx(SelectContent, {
44
- children: values.map(({ value, label })=>/*#__PURE__*/ _jsx(SelectItem, {
45
- value: value,
46
- children: label
47
- }, value))
48
- })
49
- ]
50
- })
51
- }),
52
- description && /*#__PURE__*/ _jsx(AutoFormDesc, {
53
- children: description
54
- }),
55
- /*#__PURE__*/ _jsx(FormMessage, {})
56
- ]
57
- });
58
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useTranslations}from"next-intl";import{FormControl,FormItem,FormMessage}from"../../ui/form.js";import{Select,SelectContent,SelectItem,SelectTrigger,SelectValue}from"../../ui/select.js";import{AutoFormDesc}from"../common/desc.js";import{AutoFormLabel}from"../common/label.js";export const AutoFormSelect=({label,field,description,otherProps:{enum:enumValues=[],isOptional},placeholder,labelRight,labels=[],...props})=>{const t=useTranslations("core.global");const values=enumValues.map(value=>{const label=labels.find(l=>l.value===value)?.label;return{value,label:label??value}});const currentPlaceholder=(values??labels).find(l=>l.value===field.value)?.label??t("select_option");return _jsxs(FormItem,{className:"space-y-3",children:[label&&_jsx(AutoFormLabel,{isOptional:isOptional,labelRight:labelRight,children:label}),_jsx(FormControl,{children:_jsxs(Select,{defaultValue:field.value,disabled:props.disabled,onValueChange:e=>{field.onChange(e);props?.onValueChange?.(e)},...props,children:[_jsx(SelectTrigger,{...props,children:_jsx(SelectValue,{onBlur:field.onBlur,placeholder:placeholder??currentPlaceholder,children:currentPlaceholder})}),_jsx(SelectContent,{children:values.map(({value,label})=>_jsx(SelectItem,{value:value,children:label},value))})]})}),description&&_jsx(AutoFormDesc,{children:description}),_jsx(FormMessage,{})]})};
@@ -1,36 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FormControl, FormItem } from "../../ui/form.js";
3
- import { Switch } from "../../ui/switch.js";
4
- import { AutoFormDesc } from "../common/desc.js";
5
- import { AutoFormLabel } from "../common/label.js";
6
- export const AutoFormSwitch = ({ label, field, labelRight, otherProps: { isOptional }, description, ...props })=>{
7
- return /*#__PURE__*/ _jsxs(FormItem, {
8
- className: "flex flex-row items-center justify-between rounded-lg border p-4",
9
- children: [
10
- (label ?? description) && /*#__PURE__*/ _jsxs("div", {
11
- className: "space-y-0.5",
12
- children: [
13
- label && /*#__PURE__*/ _jsx(AutoFormLabel, {
14
- className: "text-base",
15
- isOptional: isOptional,
16
- labelRight: labelRight,
17
- children: label
18
- }),
19
- description && /*#__PURE__*/ _jsx(AutoFormDesc, {
20
- children: description
21
- })
22
- ]
23
- }),
24
- /*#__PURE__*/ _jsx(FormControl, {
25
- children: /*#__PURE__*/ _jsx(Switch, {
26
- checked: field.value ?? false,
27
- onCheckedChange: (e)=>{
28
- field.onChange(e);
29
- props?.onCheckedChange?.(e);
30
- },
31
- ...props
32
- })
33
- })
34
- ]
35
- });
36
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{FormControl,FormItem}from"../../ui/form.js";import{Switch}from"../../ui/switch.js";import{AutoFormDesc}from"../common/desc.js";import{AutoFormLabel}from"../common/label.js";export const AutoFormSwitch=({label,field,labelRight,otherProps:{isOptional},description,...props})=>{return _jsxs(FormItem,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[(label??description)&&_jsxs("div",{className:"space-y-0.5",children:[label&&_jsx(AutoFormLabel,{className:"text-base",isOptional:isOptional,labelRight:labelRight,children:label}),description&&_jsx(AutoFormDesc,{children:description})]}),_jsx(FormControl,{children:_jsx(Switch,{checked:field.value??false,onCheckedChange:e=>{field.onChange(e);props?.onCheckedChange?.(e)},...props})})]})};
@@ -1,36 +1 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FormControl, FormItem, FormMessage } from "../../ui/form.js";
3
- import { Textarea } from "../../ui/textarea.js";
4
- import { AutoFormDesc } from "../common/desc.js";
5
- import { AutoFormLabel } from "../common/label.js";
6
- export const AutoFormTextarea = ({ label, description, labelRight, otherProps: { isOptional, maxLength, minLength }, field, ...props })=>{
7
- return /*#__PURE__*/ _jsxs(FormItem, {
8
- children: [
9
- label && /*#__PURE__*/ _jsx(AutoFormLabel, {
10
- isOptional: isOptional,
11
- labelRight: labelRight,
12
- children: label
13
- }),
14
- /*#__PURE__*/ _jsx(FormControl, {
15
- children: /*#__PURE__*/ _jsx(Textarea, {
16
- maxLength: maxLength,
17
- minLength: minLength,
18
- onBlur: (e)=>{
19
- field.onBlur();
20
- props.onBlur?.(e);
21
- },
22
- onChange: (e)=>{
23
- field.onChange(e);
24
- props.onChange?.(e);
25
- },
26
- value: field.value ?? "",
27
- ...props
28
- })
29
- }),
30
- description && /*#__PURE__*/ _jsx(AutoFormDesc, {
31
- children: description
32
- }),
33
- /*#__PURE__*/ _jsx(FormMessage, {})
34
- ]
35
- });
36
- };
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{FormControl,FormItem,FormMessage}from"../../ui/form.js";import{Textarea}from"../../ui/textarea.js";import{AutoFormDesc}from"../common/desc.js";import{AutoFormLabel}from"../common/label.js";export const AutoFormTextarea=({label,description,labelRight,otherProps:{isOptional,maxLength,minLength},field,...props})=>{return _jsxs(FormItem,{children:[label&&_jsx(AutoFormLabel,{isOptional:isOptional,labelRight:labelRight,children:label}),_jsx(FormControl,{children:_jsx(Textarea,{maxLength:maxLength,minLength:minLength,onBlur:e=>{field.onBlur();props.onBlur?.(e)},onChange:e=>{field.onChange(e);props.onChange?.(e)},value:field.value??"",...props})}),description&&_jsx(AutoFormDesc,{children:description}),_jsx(FormMessage,{})]})};
@@ -1,43 +1 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { NextIntlClientProvider } from "next-intl";
3
- import { getLocale, getMessages } from "next-intl/server";
4
- import "server-only";
5
- const pick = (obj, paths)=>{
6
- const result = {};
7
- for (const path of paths){
8
- const keys = path.split(".");
9
- let src = obj;
10
- let dest = result;
11
- for(let i = 0; i < keys.length; i++){
12
- const key = keys[i];
13
- if (src && Object.hasOwn(src, key)) {
14
- if (i === keys.length - 1) {
15
- dest[key] = src[key];
16
- } else {
17
- dest[key] ??= {};
18
- dest = dest[key];
19
- src = src[key];
20
- }
21
- } else {
22
- break;
23
- }
24
- }
25
- }
26
- return result;
27
- };
28
- export async function I18nProvider({ children, namespaces }) {
29
- const locale = await getLocale();
30
- const messagesInit = await getMessages({
31
- locale
32
- });
33
- const messages = pick(messagesInit, [
34
- "core.global",
35
- ...Array.isArray(namespaces) ? namespaces : [
36
- namespaces
37
- ]
38
- ]);
39
- return /*#__PURE__*/ _jsx(NextIntlClientProvider, {
40
- messages: messages,
41
- children: children
42
- });
43
- }
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{NextIntlClientProvider}from"next-intl";import{getLocale,getMessages}from"next-intl/server";import"server-only";const pick=(obj,paths)=>{const result={};for(const path of paths){const keys=path.split(".");let src=obj;let dest=result;for(let i=0;i<keys.length;i++){const key=keys[i];if(src&&Object.hasOwn(src,key)){if(i===keys.length-1){dest[key]=src[key]}else{dest[key]??={};dest=dest[key];src=src[key]}}else{break}}}return result};export async function I18nProvider({children,namespaces}){const locale=await getLocale();const messagesInit=await getMessages({locale});const messages=pick(messagesInit,["core.global",...Array.isArray(namespaces)?namespaces:[namespaces]]);return _jsx(NextIntlClientProvider,{messages:messages,children:children})}