@btst/plugin-cms 0.0.0-stage → 1.0.0-beta.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.Bptwe33B.d.cts +1749 -0
  99. package/dist/shared/plugin-cms.Csx7tNDO.d.mts +1749 -0
  100. package/dist/shared/plugin-cms.eNW9_FO5.d.ts +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,654 @@
1
+ 'use client';
2
+ import * as _btst_stack_client from '@btst/stack/client';
3
+ import * as _btst_yar from '@btst/yar';
4
+ import * as react from 'react';
5
+ import { ComponentType } from 'react';
6
+ import { D as DashboardPageComponent } from '../shared/plugin-cms.BBshPRkb.js';
7
+ import { ContentTypeConfig } from '../types.js';
8
+ export { CMSContentFields, CMSContentItemResult, CMSReadOptions, CMSReadView, CMSSelectedData, PaginatedContentItems, SerializedContentItemContent } from '../types.js';
9
+ import { ControllerRenderProps, FieldValues } from 'react-hook-form';
10
+ import * as z from 'zod';
11
+ import { z as z$1 } from 'zod';
12
+
13
+ declare const CMS_LOCALIZATION: {
14
+ CMS_RELATION_LOADING: string;
15
+ CMS_RELATION_SELECT_PLACEHOLDER: string;
16
+ CMS_RELATION_SELECT_PLACEHOLDER_MULTI: string;
17
+ CMS_RELATION_EMPTY: string;
18
+ CMS_RELATION_CREATE_TITLE: string;
19
+ CMS_RELATION_NAME_PLACEHOLDER: string;
20
+ CMS_RELATION_DESCRIPTION_LABEL: string;
21
+ CMS_RELATION_DESCRIPTION_PLACEHOLDER: string;
22
+ CMS_RELATION_CREATE_BUTTON: string;
23
+ CMS_RELATION_CREATING: string;
24
+ CMS_RELATION_CREATE_ERROR: string;
25
+ CMS_RELATED_ITEMS_TITLE: string;
26
+ CMS_RELATED_EMPTY: string;
27
+ CMS_RELATED_ADD: string;
28
+ CMS_RELATED_DELETE_TITLE: string;
29
+ CMS_RELATED_DELETE_DESCRIPTION: string;
30
+ CMS_RELATED_DELETE_ERROR: string;
31
+ CMS_EDITOR_TITLE_NEW: string;
32
+ CMS_EDITOR_TITLE_EDIT: string;
33
+ CMS_EDITOR_SLUG_AUTO: string;
34
+ CMS_EDITOR_SLUG_MANUAL: string;
35
+ CMS_EDITOR_DELETE_CONFIRM: string;
36
+ CMS_EDITOR_UNSAVED_CHANGES: string;
37
+ CMS_EDITOR_SLUG_PLACEHOLDER: string;
38
+ CMS_EDITOR_SLUG_PLACEHOLDER_AUTO: string;
39
+ CMS_EDITOR_SLUG_REQUIRED: string;
40
+ CMS_EDITOR_FILE_INVALID_TYPE: string;
41
+ CMS_EDITOR_FILE_UPLOAD_FAILED: string;
42
+ CMS_LIST_TITLE: string;
43
+ CMS_LIST_EMPTY: string;
44
+ CMS_LIST_EMPTY_DESCRIPTION: string;
45
+ CMS_LIST_COLUMN_SLUG: string;
46
+ CMS_LIST_COLUMN_CREATED: string;
47
+ CMS_LIST_COLUMN_UPDATED: string;
48
+ CMS_LIST_COLUMN_ACTIONS: string;
49
+ CMS_LIST_ACTION_EDIT: string;
50
+ CMS_LIST_ACTION_DELETE: string;
51
+ CMS_LIST_PAGINATION_SHOWING: string;
52
+ CMS_LIST_PAGINATION_PREVIOUS: string;
53
+ CMS_LIST_PAGINATION_NEXT: string;
54
+ CMS_LIST_SEARCH_PLACEHOLDER: string;
55
+ CMS_LIST_SEARCH_EMPTY: string;
56
+ CMS_LIST_SEARCH_EMPTY_DESCRIPTION: string;
57
+ CMS_DASHBOARD_TITLE: string;
58
+ CMS_DASHBOARD_SUBTITLE: string;
59
+ CMS_DASHBOARD_NO_TYPES: string;
60
+ CMS_DASHBOARD_NO_TYPES_DESCRIPTION: string;
61
+ CMS_DASHBOARD_ITEMS_COUNT: string;
62
+ CMS_DASHBOARD_ITEMS_COUNT_ZERO: string;
63
+ CMS_DASHBOARD_ITEMS_COUNT_ONE: string;
64
+ CMS_TOAST_CREATE_SUCCESS: string;
65
+ CMS_TOAST_UPDATE_SUCCESS: string;
66
+ CMS_TOAST_DELETE_SUCCESS: string;
67
+ CMS_TOAST_ERROR: string;
68
+ CMS_TOAST_VALIDATION_ERROR: string;
69
+ CMS_TOAST_DUPLICATE_SLUG: string;
70
+ CMS_BUTTON_SAVE: string;
71
+ CMS_BUTTON_CANCEL: string;
72
+ CMS_BUTTON_DELETE: string;
73
+ CMS_BUTTON_CREATE: string;
74
+ CMS_BUTTON_BACK: string;
75
+ CMS_BUTTON_NEW_ITEM: string;
76
+ CMS_LABEL_SLUG: string;
77
+ CMS_LABEL_SLUG_DESCRIPTION: string;
78
+ CMS_LABEL_CREATED_AT: string;
79
+ CMS_LABEL_UPDATED_AT: string;
80
+ CMS_LABEL_ACTIONS: string;
81
+ CMS_STATUS_LOADING: string;
82
+ CMS_STATUS_SAVING: string;
83
+ CMS_STATUS_DELETING: string;
84
+ CMS_ERROR_GENERIC: string;
85
+ CMS_ERROR_NOT_FOUND: string;
86
+ CMS_ERROR_VALIDATION: string;
87
+ CMS_ERROR_TYPE_NOT_FOUND_DESCRIPTION: string;
88
+ CMS_ERROR_ITEM_NOT_FOUND_DESCRIPTION: string;
89
+ CMS_404_TITLE: string;
90
+ CMS_404_DESCRIPTION: string;
91
+ CMS_404_BACK: string;
92
+ CMS_ATTRIBUTION: string;
93
+ };
94
+ type CMSLocalization = typeof CMS_LOCALIZATION;
95
+
96
+ declare function AutoFormCheckbox({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
97
+
98
+ declare function AutoFormDate({ label, isRequired, field, fieldConfigItem, fieldProps, zodItem, }: AutoFormInputComponentProps): react.JSX.Element;
99
+
100
+ declare function AutoFormEnum({ label, isRequired, field, fieldConfigItem, zodItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
101
+
102
+ declare function AutoFormInput({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
103
+
104
+ declare function AutoFormNumber({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
105
+
106
+ declare function AutoFormRadioGroup({ label, isRequired, field, zodItem, fieldProps, fieldConfigItem, }: AutoFormInputComponentProps): react.JSX.Element;
107
+
108
+ declare function AutoFormSwitch({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
109
+
110
+ declare function AutoFormTextarea({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react.JSX.Element;
111
+
112
+ declare const INPUT_COMPONENTS: {
113
+ checkbox: typeof AutoFormCheckbox;
114
+ date: typeof AutoFormDate;
115
+ select: typeof AutoFormEnum;
116
+ radio: typeof AutoFormRadioGroup;
117
+ switch: typeof AutoFormSwitch;
118
+ textarea: typeof AutoFormTextarea;
119
+ number: typeof AutoFormNumber;
120
+ fallback: typeof AutoFormInput;
121
+ };
122
+
123
+ /**
124
+ * Common input props shared by all field types.
125
+ */
126
+ interface BaseInputProps {
127
+ /** Whether the field is disabled */
128
+ disabled?: boolean;
129
+ /** Whether the field is read-only */
130
+ readOnly?: boolean;
131
+ /** Whether the field is required */
132
+ required?: boolean;
133
+ /** Whether to show the label (auto-form specific) */
134
+ showLabel?: boolean;
135
+ }
136
+ /**
137
+ * Generic input props that accept any field type.
138
+ * Use this when the backing type is not known at compile time.
139
+ *
140
+ * This is the catch-all type used for runtime flexibility.
141
+ */
142
+ interface SerializableInputProps extends BaseInputProps {
143
+ placeholder?: string;
144
+ type?: string;
145
+ defaultValue?: unknown;
146
+ min?: number | string;
147
+ max?: number | string;
148
+ step?: number | string;
149
+ minLength?: number;
150
+ maxLength?: number;
151
+ pattern?: string;
152
+ autoComplete?: string;
153
+ /** Allow additional props for extensibility */
154
+ [key: string]: unknown;
155
+ }
156
+
157
+ /**
158
+ * Input props for form fields.
159
+ *
160
+ * This is the runtime type that accepts any input props.
161
+ * For type-safe props, use the discriminated types:
162
+ * - StringInputProps for text inputs
163
+ * - NumberInputProps for number inputs
164
+ * - BooleanInputProps for checkboxes/switches
165
+ * - DateInputProps for date pickers
166
+ * - EnumInputProps for selects/radios
167
+ */
168
+ type FieldInputProps = SerializableInputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof SerializableInputProps> & Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof SerializableInputProps>;
169
+ /**
170
+ * Configuration for a single field in AutoForm.
171
+ *
172
+ * Note: This type is designed to align with form-builder's FormBuilderFieldProps
173
+ * so that JSON Schema properties can be easily converted to field configs.
174
+ */
175
+ type FieldConfigItem = {
176
+ /** Description text or React node */
177
+ description?: React.ReactNode;
178
+ /** Input props passed to the field component */
179
+ inputProps?: FieldInputProps;
180
+ /** Display label */
181
+ label?: string;
182
+ /** Field type override - built-in type or custom component */
183
+ fieldType?: keyof typeof INPUT_COMPONENTS | React.FC<AutoFormInputComponentProps>;
184
+ /** Wrapper component for custom field layout */
185
+ renderParent?: (props: {
186
+ children: React.ReactNode;
187
+ }) => React.ReactElement | null;
188
+ /** Display order for field ordering */
189
+ order?: number;
190
+ };
191
+ /**
192
+ * A FormInput component can handle a specific Zod type (e.g. "ZodBoolean")
193
+ */
194
+ type AutoFormInputComponentProps = {
195
+ zodInputProps: React.InputHTMLAttributes<HTMLInputElement>;
196
+ field: ControllerRenderProps<FieldValues, any>;
197
+ fieldConfigItem: FieldConfigItem;
198
+ label: string;
199
+ isRequired: boolean;
200
+ fieldProps: any;
201
+ zodItem: z.ZodType;
202
+ className?: string;
203
+ };
204
+
205
+ /** Browser-safe CMS factory values carried by the resolved client stack. */
206
+ interface CMSProviderConfig {
207
+ /** Declared content types, used to preserve application-defined UI order. */
208
+ readonly contentTypes?: readonly ContentTypeConfig[];
209
+ }
210
+ /**
211
+ * Props for the overridable CMS image input field component.
212
+ */
213
+ interface CmsImageInputFieldProps {
214
+ /** Current image URL value */
215
+ value: string;
216
+ /** Called when the image URL changes */
217
+ onChange: (value: string) => void;
218
+ /** Whether the field is required */
219
+ isRequired?: boolean;
220
+ }
221
+ /**
222
+ * Context passed to lifecycle hooks
223
+ */
224
+ interface RouteContext {
225
+ /** Current route path */
226
+ path: string;
227
+ /** Route parameters (e.g., { typeSlug: "product", id: "123" }) */
228
+ params?: Record<string, string>;
229
+ /** Whether rendering on server (true) or client (false) */
230
+ isSSR: boolean;
231
+ /** Additional context properties */
232
+ [key: string]: unknown;
233
+ }
234
+ /**
235
+ * Overridable components and functions for the CMS plugin
236
+ *
237
+ * External consumers can provide their own implementations to customize
238
+ * plugin-specific components and behavior.
239
+ */
240
+ interface CMSPluginOverrides {
241
+ /**
242
+ * Function used to upload a new image file and return its URL.
243
+ * Used by the default "file" field component when not selecting an existing
244
+ * asset via `imagePicker` or `imageInputField`.
245
+ */
246
+ uploadImage?: (file: File) => Promise<string>;
247
+ /**
248
+ * Optional custom component for image fields (fieldType: "file").
249
+ *
250
+ * When provided it replaces the default file-upload input entirely.
251
+ * The component receives `value` (current URL string) and `onChange` (setter).
252
+ *
253
+ * @example
254
+ * ```tsx
255
+ * imageInputField: ({ value, onChange }) =>
256
+ * value ? (
257
+ * <div>
258
+ * <img src={value} alt="Preview" />
259
+ * <MediaPicker trigger={<button>Change</button>} accept={["image/*"]}
260
+ * onSelect={(assets) => onChange(assets[0].url)} />
261
+ * </div>
262
+ * ) : (
263
+ * <MediaPicker trigger={<button>Browse media</button>} accept={["image/*"]}
264
+ * onSelect={(assets) => onChange(assets[0].url)} />
265
+ * )
266
+ * ```
267
+ */
268
+ imageInputField?: ComponentType<CmsImageInputFieldProps>;
269
+ /**
270
+ * Optional trigger component for a media picker.
271
+ * When provided, it is rendered inside the default "file" field component as a
272
+ * "Browse media" option, letting users select a previously uploaded asset.
273
+ * Receives `onSelect(url)` — the URL is set as the field value.
274
+ *
275
+ * @example
276
+ * ```tsx
277
+ * imagePicker: ({ onSelect }) => (
278
+ * <MediaPicker
279
+ * trigger={<Button size="sm" variant="outline">Browse media</Button>}
280
+ * accept={["image/*"]}
281
+ * onSelect={(assets) => onSelect(assets[0].url)}
282
+ * />
283
+ * )
284
+ * ```
285
+ */
286
+ imagePicker?: ComponentType<{
287
+ onSelect: (url: string) => void;
288
+ }>;
289
+ /**
290
+ * Optional class names merged onto specific UI elements.
291
+ * Use these for targeted styling without replacing whole components.
292
+ */
293
+ classNames?: {
294
+ /** Page container shared by every CMS page */
295
+ container?: string;
296
+ /** Each content-type card on the dashboard */
297
+ contentTypeCard?: string;
298
+ /** Title inside a content-type card */
299
+ contentTypeTitle?: string;
300
+ /** Wrapper around the content entries table */
301
+ table?: string;
302
+ /** Each row in the content entries table */
303
+ tableRow?: string;
304
+ /** Pagination footer under the content entries table */
305
+ pagination?: string;
306
+ };
307
+ /**
308
+ * Custom field components for AutoForm fields.
309
+ *
310
+ * These map field type names to React components. Use these to:
311
+ * - Override built-in field types (checkbox, date, select, radio, switch, textarea, file, number, fallback)
312
+ * - Add custom field types for your content types
313
+ *
314
+ * The component receives AutoFormInputComponentProps which includes:
315
+ * - field: react-hook-form field controller
316
+ * - label: the field label
317
+ * - isRequired: whether the field is required
318
+ * - fieldConfigItem: the field config (description, inputProps, etc.)
319
+ * - fieldProps: additional props from fieldConfig.inputProps
320
+ * - zodItem: the Zod schema for this field
321
+ *
322
+ * @example
323
+ * ```tsx
324
+ * fieldComponents: {
325
+ * // Override the file type with custom S3 upload
326
+ * file: ({ field, label, isRequired }) => (
327
+ * <MyS3Upload
328
+ * value={field.value}
329
+ * onChange={field.onChange}
330
+ * label={label}
331
+ * required={isRequired}
332
+ * />
333
+ * ),
334
+ * // Add a custom rich text editor
335
+ * richText: ({ field, label }) => (
336
+ * <MyRichTextEditor value={field.value} onChange={field.onChange} />
337
+ * ),
338
+ * }
339
+ * ```
340
+ */
341
+ fieldComponents?: Record<string, ComponentType<AutoFormInputComponentProps>>;
342
+ /**
343
+ * Localization object for the CMS plugin
344
+ */
345
+ localization?: Partial<CMSLocalization>;
346
+ /**
347
+ * Whether to show the attribution
348
+ */
349
+ showAttribution?: boolean;
350
+ /**
351
+ * Called when a route is rendered
352
+ * @param routeName - Name of the route (e.g., 'dashboard', 'contentList', 'contentEditor')
353
+ * @param context - Route context with path, params, etc.
354
+ */
355
+ onRouteRender?: (routeName: string, context: RouteContext) => void | Promise<void>;
356
+ /**
357
+ * Called when a route encounters an error
358
+ * @param routeName - Name of the route
359
+ * @param error - The error that occurred
360
+ * @param context - Route context
361
+ */
362
+ onRouteError?: (routeName: string, error: Error, context: RouteContext) => void | Promise<void>;
363
+ }
364
+
365
+ /**
366
+ * Context passed to loader hooks
367
+ */
368
+ interface LoaderContext {
369
+ /** Current route path */
370
+ path: string;
371
+ /** Route parameters (e.g., { typeSlug: "product", id: "123" }) */
372
+ params?: Record<string, string>;
373
+ /** Whether rendering on server (true) or client (false) */
374
+ isSSR: boolean;
375
+ /** Base URL for API calls */
376
+ apiBaseURL: string;
377
+ /** Path where the API is mounted */
378
+ apiBasePath: string;
379
+ /** Optional headers for the request */
380
+ headers?: Headers;
381
+ /** Additional context properties */
382
+ [key: string]: unknown;
383
+ }
384
+ /**
385
+ * Hooks for CMS client plugin
386
+ * All hooks are optional and allow consumers to customize behavior
387
+ */
388
+ interface CMSClientHooks {
389
+ /**
390
+ * Called before loading the dashboard page. If it throws, remaining loader
391
+ * work stops, `onErrorLoad` is notified, and the loader still resolves.
392
+ * @param context - Loader context with path, params, etc.
393
+ */
394
+ beforeLoadDashboard?: (context: LoaderContext) => Promise<void> | void;
395
+ /**
396
+ * Called after the dashboard is loaded.
397
+ * @param context - Loader context
398
+ */
399
+ afterLoadDashboard?: (context: LoaderContext) => Promise<void> | void;
400
+ /**
401
+ * Called before loading a content list page. If it throws, remaining loader
402
+ * work stops, `onErrorLoad` is notified, and the loader still resolves.
403
+ * @param typeSlug - The content type slug
404
+ * @param context - Loader context
405
+ */
406
+ beforeLoadContentList?: (typeSlug: string, context: LoaderContext) => Promise<void> | void;
407
+ /**
408
+ * Called after a content list is loaded.
409
+ * @param typeSlug - The content type slug
410
+ * @param context - Loader context
411
+ */
412
+ afterLoadContentList?: (typeSlug: string, context: LoaderContext) => Promise<void> | void;
413
+ /**
414
+ * Called before loading the content editor page. If it throws, remaining
415
+ * loader work stops, `onErrorLoad` is notified, and the loader still resolves.
416
+ * @param typeSlug - The content type slug
417
+ * @param id - The content item ID (undefined for new items)
418
+ * @param context - Loader context
419
+ */
420
+ beforeLoadContentEditor?: (typeSlug: string, id: string | undefined, context: LoaderContext) => Promise<void> | void;
421
+ /**
422
+ * Called after the content editor is loaded.
423
+ * @param typeSlug - The content type slug
424
+ * @param id - The content item ID (undefined for new items)
425
+ * @param context - Loader context
426
+ */
427
+ afterLoadContentEditor?: (typeSlug: string, id: string | undefined, context: LoaderContext) => Promise<void> | void;
428
+ /**
429
+ * Called when a loading error occurs.
430
+ * This is a reporting-only observer. Callback errors are contained and the
431
+ * loader never rejects, so throwing framework redirects are not supported.
432
+ * @param error - The error that occurred
433
+ * @param context - Loader context
434
+ */
435
+ onErrorLoad?: (error: Error, context: LoaderContext) => Promise<void> | void;
436
+ }
437
+ /**
438
+ * CMS-specific client configuration. Shared API, site, query-client, and
439
+ * request-header values are inherited from `createClientStack()`.
440
+ */
441
+ interface CMSClientConfig {
442
+ /**
443
+ * Content types declared by this application. The HTTP contract remains the
444
+ * data source; this list preserves the developer-defined order in CMS pages.
445
+ * Omit it when a separately managed backend owns the catalog.
446
+ */
447
+ contentTypes?: readonly ContentTypeConfig[];
448
+ /** Optional hooks for route loading, error reporting, and telemetry. */
449
+ hooks?: CMSClientHooks;
450
+ /**
451
+ * Optional page component overrides.
452
+ * Replace any plugin page with a custom React component.
453
+ * The built-in component is used as the fallback when not provided.
454
+ */
455
+ pageComponents?: {
456
+ /** Replaces the CMS dashboard page */
457
+ dashboard?: ComponentType;
458
+ /** Replaces the content list page */
459
+ contentList?: ComponentType<{
460
+ params: {
461
+ typeSlug: string;
462
+ };
463
+ }>;
464
+ /** Replaces the new content editor page */
465
+ newContent?: ComponentType<{
466
+ params: {
467
+ typeSlug: string;
468
+ };
469
+ }>;
470
+ /** Replaces the edit content editor page */
471
+ editContent?: ComponentType<{
472
+ params: {
473
+ typeSlug: string;
474
+ id: string;
475
+ };
476
+ }>;
477
+ };
478
+ }
479
+ /**
480
+ * CMS client plugin
481
+ * Provides routes and components for the CMS admin interface.
482
+ *
483
+ * @param config - Optional CMS-specific behavior and page choices.
484
+ */
485
+ declare const cmsClientPlugin: (config?: CMSClientConfig) => _btst_stack_client.ClientPluginDefinition<CMSPluginOverrides, {
486
+ dashboard: _btst_yar.DefinedRoute<"/cms", {
487
+ readonly page: react.LazyExoticComponent<typeof DashboardPageComponent>;
488
+ readonly loader: () => Promise<void>;
489
+ readonly meta: () => ({
490
+ title: string;
491
+ name?: undefined;
492
+ content?: undefined;
493
+ } | {
494
+ name: string;
495
+ content: string;
496
+ title?: undefined;
497
+ })[];
498
+ }, _btst_yar.RouteMeta>;
499
+ contentList: _btst_yar.DefinedRoute<"/cms/:typeSlug", {
500
+ readonly page: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug", _btst_yar.RouteOptions>) => react.JSX.Element;
501
+ readonly loader: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug", _btst_yar.RouteOptions>) => Promise<void>;
502
+ readonly meta: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug", _btst_yar.RouteOptions>) => ({
503
+ title: string;
504
+ name?: undefined;
505
+ content?: undefined;
506
+ } | {
507
+ name: string;
508
+ content: string;
509
+ title?: undefined;
510
+ })[];
511
+ }, _btst_yar.RouteMeta>;
512
+ newContent: _btst_yar.DefinedRoute<"/cms/:typeSlug/new", {
513
+ readonly page: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug/new", _btst_yar.RouteOptions>) => react.JSX.Element;
514
+ readonly loader: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug/new", _btst_yar.RouteOptions>) => Promise<void>;
515
+ readonly meta: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug/new", _btst_yar.RouteOptions>) => ({
516
+ title: string;
517
+ name?: undefined;
518
+ content?: undefined;
519
+ } | {
520
+ name: string;
521
+ content: string;
522
+ title?: undefined;
523
+ })[];
524
+ }, _btst_yar.RouteMeta>;
525
+ editContent: _btst_yar.DefinedRoute<"/cms/:typeSlug/:id", {
526
+ readonly page: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug/:id", _btst_yar.RouteOptions>) => react.JSX.Element;
527
+ readonly loader: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug/:id", _btst_yar.RouteOptions>) => Promise<void>;
528
+ readonly meta: ({ params }: _btst_yar.RouteContext<"/cms/:typeSlug/:id", _btst_yar.RouteOptions>) => ({
529
+ title: string;
530
+ name?: undefined;
531
+ content?: undefined;
532
+ } | {
533
+ name: string;
534
+ content: string;
535
+ title?: undefined;
536
+ })[];
537
+ }, _btst_yar.RouteMeta>;
538
+ }, "cms", {
539
+ contentTypes?: readonly ContentTypeConfig[] | undefined;
540
+ }, never>;
541
+
542
+ interface FormStep {
543
+ id: string;
544
+ title: string;
545
+ }
546
+ interface FormSchemaMetadata {
547
+ /** Multi-step form step definitions */
548
+ steps?: FormStep[];
549
+ /** Map of field names to their step indices */
550
+ stepGroupMap?: Record<string, number>;
551
+ }
552
+ interface JsonSchemaProperty {
553
+ type?: string;
554
+ format?: string;
555
+ formatMinimum?: string;
556
+ formatMaximum?: string;
557
+ stepGroup?: number;
558
+ properties?: Record<string, JsonSchemaProperty>;
559
+ [key: string]: unknown;
560
+ }
561
+ interface FormJsonSchema {
562
+ type?: string;
563
+ properties?: Record<string, JsonSchemaProperty>;
564
+ required?: string[];
565
+ steps?: FormStep[];
566
+ stepGroupMap?: Record<string, number>;
567
+ [key: string]: unknown;
568
+ }
569
+ /**
570
+ * Convert a Zod schema to JSON Schema with proper handling for:
571
+ * - z.date() → { type: "string", format: "date-time" }
572
+ * - Date min/max constraints → formatMinimum/formatMaximum
573
+ * - Steps metadata (if provided via schema.meta() or explicit metadata param)
574
+ *
575
+ * @param schema - The Zod schema to convert
576
+ * @param metadata - Optional explicit metadata to include (overrides schema meta)
577
+ */
578
+ declare function zodToFormSchema<T extends z$1.ZodType>(schema: T, metadata?: FormSchemaMetadata): FormJsonSchema;
579
+ /**
580
+ * Convert JSON Schema to Zod schema with proper handling for:
581
+ * - { type: "string", format: "date-time" } → date field (with constraints)
582
+ * - Steps metadata re-attachment (preserved via .meta())
583
+ * - Step group mapping
584
+ *
585
+ * @param jsonSchema - The JSON Schema to convert
586
+ * @returns A Zod schema ready for validation, with all metadata preserved
587
+ */
588
+ declare function formSchemaToZod(jsonSchema: FormJsonSchema): z$1.ZodType;
589
+ /**
590
+ * Check if a JSON Schema has multi-step configuration.
591
+ */
592
+ declare function hasSteps(jsonSchema: FormJsonSchema): boolean;
593
+ /**
594
+ * Get steps from a JSON Schema.
595
+ */
596
+ declare function getSteps(jsonSchema: FormJsonSchema): FormStep[];
597
+ /**
598
+ * Get the step group map from a JSON Schema.
599
+ * Returns a map of field names to step indices.
600
+ */
601
+ declare function getStepGroupMap(jsonSchema: FormJsonSchema): Record<string, number>;
602
+
603
+ /**
604
+ * Props for the CMSFileUpload component
605
+ */
606
+ interface CMSFileUploadProps extends AutoFormInputComponentProps {
607
+ /**
608
+ * Function to upload an image file and return the URL.
609
+ * This is required - consumers must provide an upload implementation.
610
+ */
611
+ uploadImage: (file: File) => Promise<string>;
612
+ /**
613
+ * Optional custom component for the image field.
614
+ * When provided, it replaces the default file-upload input entirely.
615
+ */
616
+ imageInputField?: ComponentType<{
617
+ value: string;
618
+ onChange: (value: string) => void;
619
+ isRequired?: boolean;
620
+ }>;
621
+ /**
622
+ * Optional trigger component for a media picker.
623
+ * When provided, it is rendered as a "Browse media" option.
624
+ */
625
+ imagePicker?: ComponentType<{
626
+ onSelect: (url: string) => void;
627
+ }>;
628
+ }
629
+ /**
630
+ * Default file upload component for CMS image fields.
631
+ *
632
+ * This component:
633
+ * - Accepts image files via file input
634
+ * - Uses the required uploadImage prop to upload and get a URL
635
+ * - Shows a preview of the uploaded image
636
+ * - Allows removing the uploaded image
637
+ *
638
+ * You can use this component directly in your fieldComponents override,
639
+ * or create your own custom component using this as a reference.
640
+ *
641
+ * @example
642
+ * ```tsx
643
+ * // Use the default component with your upload function
644
+ * fieldComponents: {
645
+ * file: (props) => (
646
+ * <CMSFileUpload {...props} uploadImage={myUploadFn} />
647
+ * ),
648
+ * }
649
+ * ```
650
+ */
651
+ declare function CMSFileUpload({ label, isRequired, fieldConfigItem, fieldProps, field, uploadImage, imageInputField: ImageInputField, imagePicker: ImagePickerTrigger, }: CMSFileUploadProps): react.JSX.Element;
652
+
653
+ export { CMSFileUpload, ContentTypeConfig, cmsClientPlugin, formSchemaToZod, getStepGroupMap, getSteps, hasSteps, zodToFormSchema };
654
+ export type { AutoFormInputComponentProps, CMSClientConfig, CMSClientHooks, CMSFileUploadProps, CMSLocalization, CMSPluginOverrides, CMSProviderConfig, FormSchemaMetadata, FormStep, LoaderContext, RouteContext };
@@ -0,0 +1,3 @@
1
+ export { cmsClientPlugin } from './plugin.mjs';
2
+ export { formSchemaToZod, getStepGroupMap, getSteps, hasSteps, zodToFormSchema } from '../ui/src/lib/schema-converter.mjs';
3
+ export { CMSFileUpload } from './components/forms/file-upload.mjs';
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ function orderCMSContentTypes(contentTypes, providerConfig) {
4
+ const configured = providerConfig?.contentTypes;
5
+ if (!Array.isArray(configured) || configured.length === 0) {
6
+ return [...contentTypes];
7
+ }
8
+ const positions = /* @__PURE__ */ new Map();
9
+ for (const [index, value] of configured.entries()) {
10
+ if (value !== null && typeof value === "object" && "slug" in value && typeof value.slug === "string") {
11
+ positions.set(value.slug, index);
12
+ }
13
+ }
14
+ return contentTypes.map((value, index) => ({ value, index })).sort((left, right) => {
15
+ const leftPosition = positions.get(left.value.slug);
16
+ const rightPosition = positions.get(right.value.slug);
17
+ if (leftPosition === void 0 && rightPosition === void 0) {
18
+ return left.index - right.index;
19
+ }
20
+ if (leftPosition === void 0) return 1;
21
+ if (rightPosition === void 0) return -1;
22
+ return leftPosition - rightPosition;
23
+ }).map(({ value }) => value);
24
+ }
25
+
26
+ exports.orderCMSContentTypes = orderCMSContentTypes;