@btst/plugin-cms 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/LICENSE.md +17 -0
  2. package/dist/api/getters.cjs +328 -0
  3. package/dist/api/getters.mjs +314 -0
  4. package/dist/api/index.cjs +29 -0
  5. package/dist/api/index.d.cts +209 -0
  6. package/dist/api/index.d.mts +209 -0
  7. package/dist/api/index.d.ts +209 -0
  8. package/dist/api/index.mjs +7 -0
  9. package/dist/api/lifecycle-migrations.cjs +13 -0
  10. package/dist/api/lifecycle-migrations.mjs +11 -0
  11. package/dist/api/mutations.cjs +59 -0
  12. package/dist/api/mutations.mjs +57 -0
  13. package/dist/api/operations.cjs +1769 -0
  14. package/dist/api/operations.mjs +1762 -0
  15. package/dist/api/plugin.cjs +337 -0
  16. package/dist/api/plugin.mjs +331 -0
  17. package/dist/api/query-key-defs.cjs +44 -0
  18. package/dist/api/query-key-defs.mjs +39 -0
  19. package/dist/api/relations.cjs +76 -0
  20. package/dist/api/relations.mjs +70 -0
  21. package/dist/client/components/forms/content-form.cjs +286 -0
  22. package/dist/client/components/forms/content-form.mjs +284 -0
  23. package/dist/client/components/forms/file-upload.cjs +160 -0
  24. package/dist/client/components/forms/file-upload.mjs +158 -0
  25. package/dist/client/components/forms/relation-field.cjs +237 -0
  26. package/dist/client/components/forms/relation-field.mjs +235 -0
  27. package/dist/client/components/index.cjs +14 -0
  28. package/dist/client/components/index.d.cts +20 -0
  29. package/dist/client/components/index.d.mts +20 -0
  30. package/dist/client/components/index.d.ts +20 -0
  31. package/dist/client/components/index.mjs +10 -0
  32. package/dist/client/components/inverse-relations-panel.cjs +272 -0
  33. package/dist/client/components/inverse-relations-panel.mjs +270 -0
  34. package/dist/client/components/loading/dashboard-skeleton.cjs +18 -0
  35. package/dist/client/components/loading/dashboard-skeleton.mjs +16 -0
  36. package/dist/client/components/loading/editor-skeleton.cjs +32 -0
  37. package/dist/client/components/loading/editor-skeleton.mjs +30 -0
  38. package/dist/client/components/loading/list-skeleton.cjs +32 -0
  39. package/dist/client/components/loading/list-skeleton.mjs +30 -0
  40. package/dist/client/components/pages/404-page.cjs +26 -0
  41. package/dist/client/components/pages/404-page.mjs +24 -0
  42. package/dist/client/components/pages/content-editor-page.cjs +84 -0
  43. package/dist/client/components/pages/content-editor-page.internal.cjs +170 -0
  44. package/dist/client/components/pages/content-editor-page.internal.mjs +168 -0
  45. package/dist/client/components/pages/content-editor-page.mjs +82 -0
  46. package/dist/client/components/pages/content-list-page.cjs +49 -0
  47. package/dist/client/components/pages/content-list-page.internal.cjs +334 -0
  48. package/dist/client/components/pages/content-list-page.internal.mjs +332 -0
  49. package/dist/client/components/pages/content-list-page.mjs +47 -0
  50. package/dist/client/components/pages/dashboard-page.cjs +42 -0
  51. package/dist/client/components/pages/dashboard-page.internal.cjs +102 -0
  52. package/dist/client/components/pages/dashboard-page.internal.mjs +100 -0
  53. package/dist/client/components/pages/dashboard-page.mjs +40 -0
  54. package/dist/client/components/shared/default-error.cjs +17 -0
  55. package/dist/client/components/shared/default-error.mjs +15 -0
  56. package/dist/client/components/shared/empty-state.cjs +16 -0
  57. package/dist/client/components/shared/empty-state.mjs +14 -0
  58. package/dist/client/components/shared/page-wrapper.cjs +29 -0
  59. package/dist/client/components/shared/page-wrapper.mjs +27 -0
  60. package/dist/client/constants.cjs +5 -0
  61. package/dist/client/constants.mjs +3 -0
  62. package/dist/client/hooks/cms-hooks.cjs +300 -0
  63. package/dist/client/hooks/cms-hooks.mjs +280 -0
  64. package/dist/client/hooks/cms-resource.cjs +13 -0
  65. package/dist/client/hooks/cms-resource.mjs +11 -0
  66. package/dist/client/hooks/index.cjs +25 -0
  67. package/dist/client/hooks/index.d.cts +693 -0
  68. package/dist/client/hooks/index.d.mts +693 -0
  69. package/dist/client/hooks/index.d.ts +693 -0
  70. package/dist/client/hooks/index.mjs +1 -0
  71. package/dist/client/index.cjs +15 -0
  72. package/dist/client/index.d.cts +654 -0
  73. package/dist/client/index.d.mts +654 -0
  74. package/dist/client/index.d.ts +654 -0
  75. package/dist/client/index.mjs +3 -0
  76. package/dist/client/overrides.cjs +26 -0
  77. package/dist/client/overrides.mjs +24 -0
  78. package/dist/client/plugin.cjs +316 -0
  79. package/dist/client/plugin.mjs +314 -0
  80. package/dist/client.css +3 -0
  81. package/dist/db.cjs +118 -0
  82. package/dist/db.mjs +116 -0
  83. package/dist/permissions.cjs +46 -0
  84. package/dist/permissions.d.cts +42 -0
  85. package/dist/permissions.d.mts +42 -0
  86. package/dist/permissions.d.ts +42 -0
  87. package/dist/permissions.mjs +44 -0
  88. package/dist/query-keys.cjs +229 -0
  89. package/dist/query-keys.d.cts +8 -0
  90. package/dist/query-keys.d.mts +8 -0
  91. package/dist/query-keys.d.ts +8 -0
  92. package/dist/query-keys.mjs +225 -0
  93. package/dist/schemas.cjs +81 -0
  94. package/dist/schemas.mjs +72 -0
  95. package/dist/shared/plugin-cms.BBshPRkb.d.cts +6 -0
  96. package/dist/shared/plugin-cms.BBshPRkb.d.mts +6 -0
  97. package/dist/shared/plugin-cms.BBshPRkb.d.ts +6 -0
  98. package/dist/shared/plugin-cms.DQLAoogy.d.ts +1749 -0
  99. package/dist/shared/plugin-cms.W4Le8D91.d.mts +1749 -0
  100. package/dist/shared/plugin-cms.c-GeWvTf.d.cts +1749 -0
  101. package/dist/style.css +6 -0
  102. package/dist/types.cjs +2 -0
  103. package/dist/types.d.cts +406 -0
  104. package/dist/types.d.mts +406 -0
  105. package/dist/types.d.ts +406 -0
  106. package/dist/types.mjs +1 -0
  107. package/dist/ui/src/components/accordion.cjs +81 -0
  108. package/dist/ui/src/components/accordion.mjs +62 -0
  109. package/dist/ui/src/components/alert-dialog.cjs +157 -0
  110. package/dist/ui/src/components/alert-dialog.mjs +132 -0
  111. package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
  112. package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
  113. package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
  114. package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
  115. package/dist/ui/src/components/auto-form/config.cjs +40 -0
  116. package/dist/ui/src/components/auto-form/config.mjs +37 -0
  117. package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
  118. package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
  119. package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
  120. package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
  121. package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
  122. package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
  123. package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
  124. package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
  125. package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
  126. package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
  127. package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
  128. package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
  129. package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
  130. package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
  131. package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
  132. package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
  133. package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
  134. package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
  135. package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
  136. package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
  137. package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
  138. package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
  139. package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
  140. package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
  141. package/dist/ui/src/components/auto-form/index.cjs +92 -0
  142. package/dist/ui/src/components/auto-form/index.mjs +86 -0
  143. package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
  144. package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
  145. package/dist/ui/src/components/auto-form/types.cjs +11 -0
  146. package/dist/ui/src/components/auto-form/types.mjs +9 -0
  147. package/dist/ui/src/components/badge.cjs +42 -0
  148. package/dist/ui/src/components/badge.mjs +39 -0
  149. package/dist/ui/src/components/button.cjs +56 -0
  150. package/dist/ui/src/components/button.mjs +53 -0
  151. package/dist/ui/src/components/calendar.cjs +207 -0
  152. package/dist/ui/src/components/calendar.mjs +190 -0
  153. package/dist/ui/src/components/card.cjs +56 -0
  154. package/dist/ui/src/components/card.mjs +51 -0
  155. package/dist/ui/src/components/checkbox.cjs +48 -0
  156. package/dist/ui/src/components/checkbox.mjs +32 -0
  157. package/dist/ui/src/components/command.cjs +78 -0
  158. package/dist/ui/src/components/command.mjs +73 -0
  159. package/dist/ui/src/components/date-picker.cjs +41 -0
  160. package/dist/ui/src/components/date-picker.mjs +39 -0
  161. package/dist/ui/src/components/dialog.cjs +119 -0
  162. package/dist/ui/src/components/dialog.mjs +97 -0
  163. package/dist/ui/src/components/form.cjs +120 -0
  164. package/dist/ui/src/components/form.mjs +98 -0
  165. package/dist/ui/src/components/input.cjs +23 -0
  166. package/dist/ui/src/components/input.mjs +21 -0
  167. package/dist/ui/src/components/label.cjs +39 -0
  168. package/dist/ui/src/components/label.mjs +23 -0
  169. package/dist/ui/src/components/multi-select.cjs +555 -0
  170. package/dist/ui/src/components/multi-select.mjs +540 -0
  171. package/dist/ui/src/components/page-layout.cjs +25 -0
  172. package/dist/ui/src/components/page-layout.mjs +23 -0
  173. package/dist/ui/src/components/page-wrapper.cjs +20 -0
  174. package/dist/ui/src/components/page-wrapper.mjs +18 -0
  175. package/dist/ui/src/components/popover.cjs +60 -0
  176. package/dist/ui/src/components/popover.mjs +42 -0
  177. package/dist/ui/src/components/radio-group.cjs +62 -0
  178. package/dist/ui/src/components/radio-group.mjs +45 -0
  179. package/dist/ui/src/components/select.cjs +161 -0
  180. package/dist/ui/src/components/select.mjs +139 -0
  181. package/dist/ui/src/components/separator.cjs +43 -0
  182. package/dist/ui/src/components/separator.mjs +27 -0
  183. package/dist/ui/src/components/skeleton.cjs +17 -0
  184. package/dist/ui/src/components/skeleton.mjs +15 -0
  185. package/dist/ui/src/components/stack-attribution.cjs +24 -0
  186. package/dist/ui/src/components/stack-attribution.mjs +22 -0
  187. package/dist/ui/src/components/switch.cjs +48 -0
  188. package/dist/ui/src/components/switch.mjs +32 -0
  189. package/dist/ui/src/components/table.cjs +89 -0
  190. package/dist/ui/src/components/table.mjs +82 -0
  191. package/dist/ui/src/components/textarea.cjs +20 -0
  192. package/dist/ui/src/components/textarea.mjs +18 -0
  193. package/dist/ui/src/hooks/use-debounce.cjs +16 -0
  194. package/dist/ui/src/hooks/use-debounce.mjs +14 -0
  195. package/dist/ui/src/hooks/use-route-lifecycle.cjs +31 -0
  196. package/dist/ui/src/hooks/use-route-lifecycle.mjs +29 -0
  197. package/dist/ui/src/lib/schema-converter.cjs +133 -0
  198. package/dist/ui/src/lib/schema-converter.mjs +127 -0
  199. package/dist/ui/src/lib/utils.cjs +10 -0
  200. package/dist/ui/src/lib/utils.mjs +8 -0
  201. package/dist/utils.cjs +19 -0
  202. package/dist/utils.mjs +12 -0
  203. package/package.json +170 -3
  204. package/README.md +0 -3
@@ -0,0 +1,217 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from '../../accordion.mjs';
3
+ import { FormField } from '../../form.mjs';
4
+ import { useFormContext } from 'react-hook-form';
5
+ import * as z from 'zod';
6
+ import { DEFAULT_ZOD_HANDLERS, INPUT_COMPONENTS } from '../config.mjs';
7
+ import { getBaseSchema, sortFieldsByOrder, getBaseType, beautifyObjectName, zodToHtmlInputProps } from '../helpers.mjs';
8
+ import AutoFormArray from './array.mjs';
9
+ import resolveDependencies from '../dependencies.mjs';
10
+
11
+ function DefaultParent({ children }) {
12
+ return /* @__PURE__ */ jsx(Fragment, { children });
13
+ }
14
+ function AutoFormObject({
15
+ schema,
16
+ form,
17
+ fieldConfig,
18
+ path = [],
19
+ dependencies = []
20
+ }) {
21
+ const { watch } = useFormContext();
22
+ if (!schema) {
23
+ return null;
24
+ }
25
+ const { shape } = getBaseSchema(schema) || {};
26
+ if (!shape) {
27
+ return null;
28
+ }
29
+ const handleIfZodNumber = (item) => {
30
+ const def = item._zod?.def;
31
+ const defType = def?.type;
32
+ const innerDefType = def?.innerType?._zod?.def?.type;
33
+ const isZodNumber = defType === "number" || defType === "int" || defType === "float";
34
+ const isInnerZodNumber = innerDefType === "number" || innerDefType === "int" || innerDefType === "float";
35
+ if (isZodNumber && def) {
36
+ def.coerce = true;
37
+ } else if (isInnerZodNumber && def?.innerType?._zod?.def) {
38
+ def.innerType._zod.def.coerce = true;
39
+ }
40
+ return item;
41
+ };
42
+ const sortedFieldKeys = sortFieldsByOrder(fieldConfig, Object.keys(shape));
43
+ return /* @__PURE__ */ jsx(Accordion, { type: "multiple", className: "space-y-5 border-none", children: sortedFieldKeys.map((name) => {
44
+ let item = shape[name];
45
+ item = handleIfZodNumber(item);
46
+ const zodBaseType = getBaseType(item);
47
+ const itemName = beautifyObjectName(name);
48
+ const key = [...path, name].join(".");
49
+ const {
50
+ isHidden,
51
+ isDisabled,
52
+ isRequired: isRequiredByDependency,
53
+ overrideOptions
54
+ } = resolveDependencies(dependencies, name, watch);
55
+ if (isHidden) {
56
+ return null;
57
+ }
58
+ if (zodBaseType === "ZodObject") {
59
+ const objectFieldConfig = fieldConfig?.[name] ?? {};
60
+ if (typeof objectFieldConfig.fieldType === "function") {
61
+ const zodInputProps2 = zodToHtmlInputProps(item);
62
+ let isRequired2 = isRequiredByDependency || zodInputProps2.required || false;
63
+ if (objectFieldConfig.inputProps?.required !== void 0) {
64
+ isRequired2 = objectFieldConfig.inputProps.required;
65
+ }
66
+ const CustomComponent = objectFieldConfig.fieldType;
67
+ const ParentElement = objectFieldConfig.renderParent ?? DefaultParent;
68
+ return /* @__PURE__ */ jsx(
69
+ FormField,
70
+ {
71
+ control: form.control,
72
+ name: key,
73
+ render: ({ field }) => {
74
+ const fieldProps = {
75
+ ...zodInputProps2,
76
+ ...field,
77
+ ...objectFieldConfig.inputProps,
78
+ disabled: objectFieldConfig.inputProps?.disabled || isDisabled,
79
+ ref: void 0,
80
+ value: field.value
81
+ };
82
+ return /* @__PURE__ */ jsx(ParentElement, { children: /* @__PURE__ */ jsx(
83
+ CustomComponent,
84
+ {
85
+ zodInputProps: zodInputProps2,
86
+ field,
87
+ fieldConfigItem: objectFieldConfig,
88
+ label: objectFieldConfig.label || itemName,
89
+ isRequired: isRequired2,
90
+ zodItem: item,
91
+ fieldProps
92
+ }
93
+ ) }, `${key}.parent`);
94
+ }
95
+ },
96
+ key
97
+ );
98
+ }
99
+ return /* @__PURE__ */ jsxs(AccordionItem, { value: name, className: "border-none", children: [
100
+ /* @__PURE__ */ jsx(AccordionTrigger, { children: itemName }),
101
+ /* @__PURE__ */ jsx(AccordionContent, { className: "p-2", children: /* @__PURE__ */ jsx(
102
+ AutoFormObject,
103
+ {
104
+ schema: item,
105
+ form,
106
+ fieldConfig: fieldConfig?.[name] ?? {},
107
+ path: [...path, name]
108
+ }
109
+ ) })
110
+ ] }, key);
111
+ }
112
+ if (zodBaseType === "ZodArray") {
113
+ const arrayFieldConfig = fieldConfig?.[name] ?? {};
114
+ if (typeof arrayFieldConfig.fieldType === "function") {
115
+ const zodInputProps2 = zodToHtmlInputProps(item);
116
+ let isRequired2 = isRequiredByDependency || zodInputProps2.required || false;
117
+ if (arrayFieldConfig.inputProps?.required !== void 0) {
118
+ isRequired2 = arrayFieldConfig.inputProps.required;
119
+ }
120
+ const CustomComponent = arrayFieldConfig.fieldType;
121
+ const ParentElement = arrayFieldConfig.renderParent ?? DefaultParent;
122
+ return /* @__PURE__ */ jsx(
123
+ FormField,
124
+ {
125
+ control: form.control,
126
+ name: key,
127
+ render: ({ field }) => {
128
+ const fieldProps = {
129
+ ...zodInputProps2,
130
+ ...field,
131
+ ...arrayFieldConfig.inputProps,
132
+ disabled: arrayFieldConfig.inputProps?.disabled || isDisabled,
133
+ ref: void 0,
134
+ value: field.value
135
+ };
136
+ return /* @__PURE__ */ jsx(ParentElement, { children: /* @__PURE__ */ jsx(
137
+ CustomComponent,
138
+ {
139
+ zodInputProps: zodInputProps2,
140
+ field,
141
+ fieldConfigItem: arrayFieldConfig,
142
+ label: arrayFieldConfig.label || itemName,
143
+ isRequired: isRequired2,
144
+ zodItem: item,
145
+ fieldProps
146
+ }
147
+ ) }, `${key}.parent`);
148
+ }
149
+ },
150
+ key
151
+ );
152
+ }
153
+ return /* @__PURE__ */ jsx(
154
+ AutoFormArray,
155
+ {
156
+ name,
157
+ item,
158
+ form,
159
+ fieldConfig: arrayFieldConfig,
160
+ path: [...path, name]
161
+ },
162
+ key
163
+ );
164
+ }
165
+ const fieldConfigItem = fieldConfig?.[name] ?? {};
166
+ const zodInputProps = zodToHtmlInputProps(item);
167
+ let isRequired = isRequiredByDependency || zodInputProps.required || false;
168
+ if (fieldConfigItem.inputProps?.required !== void 0) {
169
+ isRequired = fieldConfigItem.inputProps.required;
170
+ }
171
+ if (overrideOptions) {
172
+ item = z.enum(overrideOptions);
173
+ }
174
+ return /* @__PURE__ */ jsx(
175
+ FormField,
176
+ {
177
+ control: form.control,
178
+ name: key,
179
+ render: ({ field }) => {
180
+ const inputType = fieldConfigItem.fieldType ?? DEFAULT_ZOD_HANDLERS[zodBaseType] ?? "fallback";
181
+ const InputComponent = typeof inputType === "function" ? inputType : INPUT_COMPONENTS[inputType];
182
+ const ParentElement = fieldConfigItem.renderParent ?? DefaultParent;
183
+ const defaultValue = fieldConfigItem.inputProps?.defaultValue;
184
+ const value = field.value ?? defaultValue ?? "";
185
+ const { defaultValue: _omitDV, ...safeInputProps } = fieldConfigItem.inputProps ?? {};
186
+ const fieldProps = {
187
+ ...zodToHtmlInputProps(item),
188
+ ...field,
189
+ ...safeInputProps,
190
+ disabled: safeInputProps.disabled || isDisabled,
191
+ ref: void 0,
192
+ value
193
+ };
194
+ if (InputComponent === void 0) {
195
+ return /* @__PURE__ */ jsx(Fragment, {});
196
+ }
197
+ return /* @__PURE__ */ jsx(ParentElement, { children: /* @__PURE__ */ jsx(
198
+ InputComponent,
199
+ {
200
+ zodInputProps,
201
+ field,
202
+ fieldConfigItem,
203
+ label: itemName,
204
+ isRequired,
205
+ zodItem: item,
206
+ fieldProps,
207
+ className: fieldProps.className
208
+ }
209
+ ) }, `${key}.parent`);
210
+ }
211
+ },
212
+ key
213
+ );
214
+ }) });
215
+ }
216
+
217
+ export { AutoFormObject as default };
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ const jsxRuntime = require('react/jsx-runtime');
4
+ const form = require('../../form.cjs');
5
+ const radioGroup = require('../../radio-group.cjs');
6
+ const label = require('../common/label.cjs');
7
+ const tooltip = require('../common/tooltip.cjs');
8
+ const helpers = require('../helpers.cjs');
9
+
10
+ function getEnumValues(schema) {
11
+ if (Array.isArray(schema.options)) {
12
+ return schema.options;
13
+ }
14
+ if (schema.enum) {
15
+ return Object.values(schema.enum);
16
+ }
17
+ const def = schema._zod?.def;
18
+ if (def?.entries) {
19
+ return Object.values(def.entries);
20
+ }
21
+ return [];
22
+ }
23
+ function AutoFormRadioGroup({
24
+ label: label$1,
25
+ isRequired,
26
+ field,
27
+ zodItem,
28
+ fieldProps,
29
+ fieldConfigItem
30
+ }) {
31
+ const baseSchema = helpers.getBaseSchema(zodItem);
32
+ const values = getEnumValues(baseSchema);
33
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
34
+ /* @__PURE__ */ jsxRuntime.jsxs(form.FormItem, { children: [
35
+ /* @__PURE__ */ jsxRuntime.jsx(
36
+ label,
37
+ {
38
+ label: fieldConfigItem?.label || label$1,
39
+ isRequired
40
+ }
41
+ ),
42
+ /* @__PURE__ */ jsxRuntime.jsx(form.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
43
+ radioGroup.RadioGroup,
44
+ {
45
+ onValueChange: field.onChange,
46
+ defaultValue: field.value,
47
+ ...fieldProps,
48
+ children: values?.map((value) => /* @__PURE__ */ jsxRuntime.jsxs(
49
+ form.FormItem,
50
+ {
51
+ className: "mb-2 flex items-center gap-3 space-y-0",
52
+ children: [
53
+ /* @__PURE__ */ jsxRuntime.jsx(form.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(radioGroup.RadioGroupItem, { value }) }),
54
+ /* @__PURE__ */ jsxRuntime.jsx(form.FormLabel, { className: "font-normal", children: value })
55
+ ]
56
+ },
57
+ value
58
+ ))
59
+ }
60
+ ) }),
61
+ /* @__PURE__ */ jsxRuntime.jsx(form.FormMessage, {})
62
+ ] }),
63
+ /* @__PURE__ */ jsxRuntime.jsx(tooltip, { fieldConfigItem })
64
+ ] });
65
+ }
66
+
67
+ module.exports = AutoFormRadioGroup;
@@ -0,0 +1,65 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { FormItem, FormControl, FormLabel, FormMessage } from '../../form.mjs';
3
+ import { RadioGroup, RadioGroupItem } from '../../radio-group.mjs';
4
+ import AutoFormLabel from '../common/label.mjs';
5
+ import AutoFormTooltip from '../common/tooltip.mjs';
6
+ import { getBaseSchema } from '../helpers.mjs';
7
+
8
+ function getEnumValues(schema) {
9
+ if (Array.isArray(schema.options)) {
10
+ return schema.options;
11
+ }
12
+ if (schema.enum) {
13
+ return Object.values(schema.enum);
14
+ }
15
+ const def = schema._zod?.def;
16
+ if (def?.entries) {
17
+ return Object.values(def.entries);
18
+ }
19
+ return [];
20
+ }
21
+ function AutoFormRadioGroup({
22
+ label,
23
+ isRequired,
24
+ field,
25
+ zodItem,
26
+ fieldProps,
27
+ fieldConfigItem
28
+ }) {
29
+ const baseSchema = getBaseSchema(zodItem);
30
+ const values = getEnumValues(baseSchema);
31
+ return /* @__PURE__ */ jsxs("div", { children: [
32
+ /* @__PURE__ */ jsxs(FormItem, { children: [
33
+ /* @__PURE__ */ jsx(
34
+ AutoFormLabel,
35
+ {
36
+ label: fieldConfigItem?.label || label,
37
+ isRequired
38
+ }
39
+ ),
40
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
41
+ RadioGroup,
42
+ {
43
+ onValueChange: field.onChange,
44
+ defaultValue: field.value,
45
+ ...fieldProps,
46
+ children: values?.map((value) => /* @__PURE__ */ jsxs(
47
+ FormItem,
48
+ {
49
+ className: "mb-2 flex items-center gap-3 space-y-0",
50
+ children: [
51
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(RadioGroupItem, { value }) }),
52
+ /* @__PURE__ */ jsx(FormLabel, { className: "font-normal", children: value })
53
+ ]
54
+ },
55
+ value
56
+ ))
57
+ }
58
+ ) }),
59
+ /* @__PURE__ */ jsx(FormMessage, {})
60
+ ] }),
61
+ /* @__PURE__ */ jsx(AutoFormTooltip, { fieldConfigItem })
62
+ ] });
63
+ }
64
+
65
+ export { AutoFormRadioGroup as default };
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ const jsxRuntime = require('react/jsx-runtime');
4
+ const form = require('../../form.cjs');
5
+ const _switch = require('../../switch.cjs');
6
+ const label = require('../common/label.cjs');
7
+ const tooltip = require('../common/tooltip.cjs');
8
+
9
+ function AutoFormSwitch({
10
+ label: label$1,
11
+ isRequired,
12
+ field,
13
+ fieldConfigItem,
14
+ fieldProps
15
+ }) {
16
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
17
+ /* @__PURE__ */ jsxRuntime.jsx(form.FormItem, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
18
+ /* @__PURE__ */ jsxRuntime.jsx(form.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
19
+ _switch.Switch,
20
+ {
21
+ checked: field.value,
22
+ onCheckedChange: field.onChange,
23
+ ...fieldProps
24
+ }
25
+ ) }),
26
+ /* @__PURE__ */ jsxRuntime.jsx(
27
+ label,
28
+ {
29
+ label: fieldConfigItem?.label || label$1,
30
+ isRequired
31
+ }
32
+ )
33
+ ] }) }),
34
+ /* @__PURE__ */ jsxRuntime.jsx(tooltip, { fieldConfigItem })
35
+ ] });
36
+ }
37
+
38
+ module.exports = AutoFormSwitch;
@@ -0,0 +1,36 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { FormItem, FormControl } from '../../form.mjs';
3
+ import { Switch } from '../../switch.mjs';
4
+ import AutoFormLabel from '../common/label.mjs';
5
+ import AutoFormTooltip from '../common/tooltip.mjs';
6
+
7
+ function AutoFormSwitch({
8
+ label,
9
+ isRequired,
10
+ field,
11
+ fieldConfigItem,
12
+ fieldProps
13
+ }) {
14
+ return /* @__PURE__ */ jsxs("div", { children: [
15
+ /* @__PURE__ */ jsx(FormItem, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
16
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
17
+ Switch,
18
+ {
19
+ checked: field.value,
20
+ onCheckedChange: field.onChange,
21
+ ...fieldProps
22
+ }
23
+ ) }),
24
+ /* @__PURE__ */ jsx(
25
+ AutoFormLabel,
26
+ {
27
+ label: fieldConfigItem?.label || label,
28
+ isRequired
29
+ }
30
+ )
31
+ ] }) }),
32
+ /* @__PURE__ */ jsx(AutoFormTooltip, { fieldConfigItem })
33
+ ] });
34
+ }
35
+
36
+ export { AutoFormSwitch as default };
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const jsxRuntime = require('react/jsx-runtime');
4
+ const form = require('../../form.cjs');
5
+ const textarea = require('../../textarea.cjs');
6
+ const label = require('../common/label.cjs');
7
+ const tooltip = require('../common/tooltip.cjs');
8
+
9
+ function AutoFormTextarea({
10
+ label: label$1,
11
+ isRequired,
12
+ fieldConfigItem,
13
+ fieldProps
14
+ }) {
15
+ const { showLabel: _showLabel, ...fieldPropsWithoutShowLabel } = fieldProps;
16
+ const showLabel = _showLabel === void 0 ? true : _showLabel;
17
+ return /* @__PURE__ */ jsxRuntime.jsxs(form.FormItem, { children: [
18
+ showLabel && /* @__PURE__ */ jsxRuntime.jsx(
19
+ label,
20
+ {
21
+ label: fieldConfigItem?.label || label$1,
22
+ isRequired
23
+ }
24
+ ),
25
+ /* @__PURE__ */ jsxRuntime.jsx(form.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(textarea.Textarea, { ...fieldPropsWithoutShowLabel }) }),
26
+ /* @__PURE__ */ jsxRuntime.jsx(tooltip, { fieldConfigItem }),
27
+ /* @__PURE__ */ jsxRuntime.jsx(form.FormMessage, {})
28
+ ] });
29
+ }
30
+
31
+ module.exports = AutoFormTextarea;
@@ -0,0 +1,29 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { FormItem, FormControl, FormMessage } from '../../form.mjs';
3
+ import { Textarea } from '../../textarea.mjs';
4
+ import AutoFormLabel from '../common/label.mjs';
5
+ import AutoFormTooltip from '../common/tooltip.mjs';
6
+
7
+ function AutoFormTextarea({
8
+ label,
9
+ isRequired,
10
+ fieldConfigItem,
11
+ fieldProps
12
+ }) {
13
+ const { showLabel: _showLabel, ...fieldPropsWithoutShowLabel } = fieldProps;
14
+ const showLabel = _showLabel === void 0 ? true : _showLabel;
15
+ return /* @__PURE__ */ jsxs(FormItem, { children: [
16
+ showLabel && /* @__PURE__ */ jsx(
17
+ AutoFormLabel,
18
+ {
19
+ label: fieldConfigItem?.label || label,
20
+ isRequired
21
+ }
22
+ ),
23
+ /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(Textarea, { ...fieldPropsWithoutShowLabel }) }),
24
+ /* @__PURE__ */ jsx(AutoFormTooltip, { fieldConfigItem }),
25
+ /* @__PURE__ */ jsx(FormMessage, {})
26
+ ] });
27
+ }
28
+
29
+ export { AutoFormTextarea as default };