@admin-layout/tailwind-ui 12.2.4-alpha.97 → 12.2.5-alpha.10

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 (94) hide show
  1. package/lib/components/ErrorHandlers/ApplicationErrorHandler.d.ts.map +1 -1
  2. package/lib/components/ErrorHandlers/ApplicationErrorHandler.js +5 -1
  3. package/lib/components/ErrorHandlers/ApplicationErrorHandler.js.map +1 -1
  4. package/lib/components/ErrorHandlers/RemixErrorBoundary.d.ts +11 -0
  5. package/lib/components/ErrorHandlers/RemixErrorBoundary.d.ts.map +1 -1
  6. package/lib/components/ErrorHandlers/RemixErrorBoundary.js +134 -3
  7. package/lib/components/ErrorHandlers/RemixErrorBoundary.js.map +1 -1
  8. package/lib/components/ErrorHandlers/SPAErrorBoundary.d.ts.map +1 -1
  9. package/lib/components/ErrorHandlers/SPAErrorBoundary.js +5 -1
  10. package/lib/components/ErrorHandlers/SPAErrorBoundary.js.map +1 -1
  11. package/lib/components/ErrorHandlers/__tests__/RemixErrorBoundary.test.d.ts +2 -0
  12. package/lib/components/ErrorHandlers/__tests__/RemixErrorBoundary.test.d.ts.map +1 -0
  13. package/lib/components/ErrorPages/403.d.ts.map +1 -1
  14. package/lib/components/ErrorPages/403.js +3 -2
  15. package/lib/components/ErrorPages/403.js.map +1 -1
  16. package/lib/components/ErrorPages/404.d.ts.map +1 -1
  17. package/lib/components/ErrorPages/404.js +3 -2
  18. package/lib/components/ErrorPages/404.js.map +1 -1
  19. package/lib/components/ErrorPages/500.d.ts.map +1 -1
  20. package/lib/components/ErrorPages/500.js +3 -2
  21. package/lib/components/ErrorPages/500.js.map +1 -1
  22. package/lib/components/ErrorPages/useErrorAsset.d.ts +11 -0
  23. package/lib/components/ErrorPages/useErrorAsset.d.ts.map +1 -0
  24. package/lib/components/ErrorPages/useErrorAsset.js +24 -0
  25. package/lib/components/ErrorPages/useErrorAsset.js.map +1 -0
  26. package/lib/components/InputToolBar/InputToolBar.d.ts.map +1 -1
  27. package/lib/components/InputToolBar/InputToolBar.js +73 -31
  28. package/lib/components/InputToolBar/InputToolBar.js.map +1 -1
  29. package/lib/components/InputToolBar/__tests__/RightOverflowMenu.test.d.ts +8 -0
  30. package/lib/components/InputToolBar/__tests__/RightOverflowMenu.test.d.ts.map +1 -0
  31. package/lib/components/InputToolBar/types.d.ts +2 -0
  32. package/lib/components/InputToolBar/types.d.ts.map +1 -1
  33. package/lib/components/PageContainer/PageContainer.d.ts +9 -0
  34. package/lib/components/PageContainer/PageContainer.d.ts.map +1 -1
  35. package/lib/components/PageContainer/PageContainer.js +24 -8
  36. package/lib/components/PageContainer/PageContainer.js.map +1 -1
  37. package/lib/components/PageContainer/__tests__/PageContainer.test.d.ts +7 -0
  38. package/lib/components/PageContainer/__tests__/PageContainer.test.d.ts.map +1 -0
  39. package/lib/components/RJSFPreview/PreviewAsyncDropdown.js +111 -0
  40. package/lib/components/RJSFPreview/PreviewAsyncDropdown.js.map +1 -0
  41. package/lib/components/RJSFPreview/PreviewCheckboxWidget.js +95 -0
  42. package/lib/components/RJSFPreview/PreviewCheckboxWidget.js.map +1 -0
  43. package/lib/components/RJSFPreview/PreviewCustomFieldTemplate.js +235 -0
  44. package/lib/components/RJSFPreview/PreviewCustomFieldTemplate.js.map +1 -0
  45. package/lib/components/RJSFPreview/PreviewDateWidget.js +178 -0
  46. package/lib/components/RJSFPreview/PreviewDateWidget.js.map +1 -0
  47. package/lib/components/RJSFPreview/PreviewDialog.js +21 -0
  48. package/lib/components/RJSFPreview/PreviewDialog.js.map +1 -0
  49. package/lib/components/RJSFPreview/PreviewDropdownWidget.js +66 -0
  50. package/lib/components/RJSFPreview/PreviewDropdownWidget.js.map +1 -0
  51. package/lib/components/RJSFPreview/PreviewFieldTemplate.js +69 -0
  52. package/lib/components/RJSFPreview/PreviewFieldTemplate.js.map +1 -0
  53. package/lib/components/RJSFPreview/PreviewFileUploadWidget.js +113 -0
  54. package/lib/components/RJSFPreview/PreviewFileUploadWidget.js.map +1 -0
  55. package/lib/components/RJSFPreview/PreviewFormRenderer.js +195 -0
  56. package/lib/components/RJSFPreview/PreviewFormRenderer.js.map +1 -0
  57. package/lib/components/RJSFPreview/PreviewImageUploadWidget.js +104 -0
  58. package/lib/components/RJSFPreview/PreviewImageUploadWidget.js.map +1 -0
  59. package/lib/components/RJSFPreview/PreviewInputWidget.js +70 -0
  60. package/lib/components/RJSFPreview/PreviewInputWidget.js.map +1 -0
  61. package/lib/components/RJSFPreview/PreviewObjectFieldTemplate.js +33 -0
  62. package/lib/components/RJSFPreview/PreviewObjectFieldTemplate.js.map +1 -0
  63. package/lib/components/RJSFPreview/PreviewRadioWidget.js +55 -0
  64. package/lib/components/RJSFPreview/PreviewRadioWidget.js.map +1 -0
  65. package/lib/components/RJSFPreview/PreviewStepper.js +40 -0
  66. package/lib/components/RJSFPreview/PreviewStepper.js.map +1 -0
  67. package/lib/components/RJSFPreview/PreviewSwitchWidget.js +75 -0
  68. package/lib/components/RJSFPreview/PreviewSwitchWidget.js.map +1 -0
  69. package/lib/components/RJSFPreview/PreviewTab.js +358 -0
  70. package/lib/components/RJSFPreview/PreviewTab.js.map +1 -0
  71. package/lib/components/RJSFPreview/PreviewTextareaWidget.js +45 -0
  72. package/lib/components/RJSFPreview/PreviewTextareaWidget.js.map +1 -0
  73. package/lib/components/RJSFPreview/generateSchemaWithInputs.js +134 -0
  74. package/lib/components/RJSFPreview/generateSchemaWithInputs.js.map +1 -0
  75. package/lib/components/RJSFPreview/index.d.ts +34 -0
  76. package/lib/components/RJSFPreview/index.d.ts.map +1 -1
  77. package/lib/components/RJSFPreview/index.js +1 -0
  78. package/lib/components/RJSFPreview/index.js.map +1 -0
  79. package/lib/components/ThemeProvider/ThemeProvider.js +1 -1
  80. package/lib/components/index.d.ts.map +1 -1
  81. package/lib/hooks/__tests__/useMediaQuery.test.d.ts +2 -0
  82. package/lib/hooks/__tests__/useMediaQuery.test.d.ts.map +1 -0
  83. package/lib/hooks/useMediaQuery.d.ts +9 -2
  84. package/lib/hooks/useMediaQuery.d.ts.map +1 -1
  85. package/lib/hooks/useMediaQuery.js +39 -31
  86. package/lib/hooks/useMediaQuery.js.map +1 -1
  87. package/lib/hooks/useWindowSize.d.ts +4 -0
  88. package/lib/hooks/useWindowSize.d.ts.map +1 -1
  89. package/lib/hooks/useWindowSize.js +13 -19
  90. package/lib/hooks/useWindowSize.js.map +1 -1
  91. package/lib/index.js +1 -1
  92. package/lib/shardui/chart.d.ts +1 -1
  93. package/lib/shardui/resizable.d.ts +1 -1
  94. package/package.json +20 -5
@@ -0,0 +1,358 @@
1
+ import {jsx,jsxs}from'react/jsx-runtime';import React__default,{useState,useMemo}from'react';import {PreviewStepper}from'./PreviewStepper.js';import {PreviewFormRenderer}from'./PreviewFormRenderer.js';import {PreviewDialog}from'./PreviewDialog.js';import {generateAmenitiesFragmentSchema}from'./generateSchemaWithInputs.js';const PreviewTab = ({
2
+ formSchema,
3
+ uiSchema,
4
+ customValidateFunction,
5
+ validator,
6
+ handleSubmit,
7
+ isConfigurationSchema = false,
8
+ extensionData
9
+ }) => {
10
+ const [currentStep, setCurrentStep] = useState('');
11
+ const [formData, setFormData] = useState({});
12
+ const [isLoading, setIsLoading] = useState(false);
13
+ const [isDialogOpen, setIsDialogOpen] = useState(false);
14
+ const [submittedData, setSubmittedData] = useState(null);
15
+ // Get steps from schema
16
+ const steps = useMemo(() => {
17
+ if (isConfigurationSchema) {
18
+ return ['properties'];
19
+ }
20
+ return Object.keys(formSchema?.properties || {});
21
+ }, [formSchema, isConfigurationSchema]);
22
+ // Set initial step
23
+ React__default.useEffect(() => {
24
+ if (steps.length > 0 && !currentStep) {
25
+ setCurrentStep(steps[0]);
26
+ }
27
+ }, [steps, currentStep]);
28
+ // Get current step schema
29
+ const currentStepSchema = useMemo(() => {
30
+ if (isConfigurationSchema) {
31
+ return {
32
+ type: 'object',
33
+ title: '',
34
+ properties: formSchema?.properties || {},
35
+ required: formSchema?.required || [],
36
+ description: formSchema?.description || '',
37
+ definitions: formSchema?.definitions || formSchema?.$defs || {}
38
+ };
39
+ }
40
+ if (!currentStep || !formSchema?.properties?.[currentStep]) {
41
+ return null;
42
+ }
43
+ const stepSchema = formSchema.properties[currentStep];
44
+ const stepTitle = stepSchema.title || currentStep;
45
+ return {
46
+ type: 'object',
47
+ title: stepTitle,
48
+ properties: stepSchema.properties || {},
49
+ required: stepSchema.required || [],
50
+ description: stepSchema.description || '',
51
+ definitions: formSchema.definitions || formSchema.$defs || {}
52
+ };
53
+ }, [currentStep, formSchema, isConfigurationSchema]);
54
+ // Get current step UI schema
55
+ const currentUISchema = useMemo(() => {
56
+ if (isConfigurationSchema) {
57
+ return uiSchema || {};
58
+ }
59
+ if (!currentStep || !uiSchema) {
60
+ return {};
61
+ }
62
+ return uiSchema[currentStep] || {};
63
+ }, [currentStep, uiSchema, isConfigurationSchema]);
64
+ const handleNext = stepData => {
65
+ // Save current step data
66
+ setFormData(prev => ({
67
+ ...prev,
68
+ [currentStep]: stepData
69
+ }));
70
+ const currentStepIndex = steps.indexOf(currentStep);
71
+ const isLastStep = currentStepIndex === steps.length - 1;
72
+ if (isLastStep) {
73
+ // Instead of submitting, show dialog
74
+ const allFormData = {
75
+ ...formData,
76
+ [currentStep]: stepData
77
+ };
78
+ setSubmittedData(allFormData);
79
+ setIsDialogOpen(true);
80
+ } else {
81
+ // Move to next step
82
+ const nextStep = steps[currentStepIndex + 1];
83
+ setCurrentStep(nextStep);
84
+ }
85
+ };
86
+ const handlePrevious = () => {
87
+ const currentStepIndex = steps.indexOf(currentStep);
88
+ if (currentStepIndex > 0) {
89
+ const previousStep = steps[currentStepIndex - 1];
90
+ setCurrentStep(previousStep);
91
+ }
92
+ };
93
+ // Helper to render summary
94
+ const renderFieldValue = (schema, value) => {
95
+ if (value === undefined || value === null || value === '') return jsx("span", {
96
+ className: "text-gray-400",
97
+ children: "(empty)"
98
+ });
99
+ if (typeof value === 'object' && !Array.isArray(value) && value !== null && !(value instanceof Date)) {
100
+ const properties = schema?.properties || Object.keys(value).reduce((acc, key) => {
101
+ acc[key] = {};
102
+ return acc;
103
+ }, {});
104
+ return jsx("ul", {
105
+ className: "pl-4",
106
+ children: Object.entries(properties).map(([field, fieldSchema]) => jsxs("li", {
107
+ className: "mb-1",
108
+ children: [jsxs("span", {
109
+ className: "font-medium",
110
+ children: [fieldSchema?.title || field, ":"]
111
+ }), ' ', renderFieldValue(fieldSchema, value[field])]
112
+ }, field))
113
+ });
114
+ }
115
+ if (schema?.format === 'data-url' || schema?.type === 'file' || schema?.widget === 'file') {
116
+ if (typeof value === 'string' && value.startsWith('data:')) {
117
+ return jsxs("span", {
118
+ children: [jsx("a", {
119
+ href: value,
120
+ download: true,
121
+ className: "text-blue-600 underline",
122
+ target: "_blank",
123
+ rel: "noopener noreferrer",
124
+ children: "Download file"
125
+ }), "\u2192 exmaple.com"]
126
+ });
127
+ }
128
+ if (typeof value === 'string') {
129
+ return jsx("span", {
130
+ children: value
131
+ });
132
+ }
133
+ return jsx("span", {
134
+ children: "[file]"
135
+ });
136
+ }
137
+ if (schema?.widget === 'image' || schema?.format === 'image' || typeof value === 'string' && value.startsWith('data:image')) {
138
+ return jsx("img", {
139
+ src: value,
140
+ alt: "Uploaded",
141
+ className: "max-h-24 max-w-xs rounded border border-gray-200"
142
+ });
143
+ }
144
+ if (typeof value === 'boolean') {
145
+ return jsx("span", {
146
+ children: value ? 'Yes' : 'No'
147
+ });
148
+ }
149
+ if (typeof value === 'object' && value !== null && !Array.isArray(value) && 'label' in value && 'value' in value && typeof value.value === 'boolean') {
150
+ return jsx("span", {
151
+ children: value.value ? 'Yes' : 'No'
152
+ });
153
+ }
154
+ if (Array.isArray(value)) {
155
+ if (value.length > 0 && value[0] && typeof value[0] === 'object' && 'label' in value[0]) {
156
+ const displayValues = value.map(item => item.label || item.value || item.key);
157
+ return jsx("span", {
158
+ children: displayValues.join(', ')
159
+ });
160
+ } else if (schema?.items?.oneOf) {
161
+ const displayValues = value.map(val => {
162
+ const option = schema.items.oneOf.find(opt => opt.const === val);
163
+ return option?.title || val;
164
+ });
165
+ return jsx("span", {
166
+ children: displayValues.join(', ')
167
+ });
168
+ }
169
+ return jsx("span", {
170
+ children: value.join(', ')
171
+ });
172
+ }
173
+ if (typeof value === 'object' && value !== null && value.label && value.value) {
174
+ return jsx("span", {
175
+ children: value.label
176
+ });
177
+ }
178
+ if (typeof value === 'object' && value !== null && value.label && value.key) {
179
+ return jsxs("span", {
180
+ children: [value.label, " (key: ", value.key, ")"]
181
+ });
182
+ }
183
+ if (schema?.enum && schema?.enumNames && Array.isArray(schema.enum)) {
184
+ const idx = schema.enum.indexOf(value);
185
+ if (idx !== -1 && schema.enumNames[idx]) {
186
+ return jsx("span", {
187
+ children: schema.enumNames[idx]
188
+ });
189
+ }
190
+ } else if (schema?.enumLabels && Array.isArray(schema.enumLabels)) {
191
+ const matchingOption = schema.enumLabels.find(option => option.key === value);
192
+ if (matchingOption) {
193
+ return jsx("span", {
194
+ children: matchingOption.value
195
+ });
196
+ }
197
+ } else if (schema?.enum && Array.isArray(schema.enum)) {
198
+ const idx = schema.enum.indexOf(value);
199
+ if (idx !== -1 && schema.enumNames && schema.enumNames[idx]) {
200
+ return jsx("span", {
201
+ children: schema.enumNames[idx]
202
+ });
203
+ }
204
+ }
205
+ return jsx("span", {
206
+ children: String(value)
207
+ });
208
+ };
209
+ const renderFields = (schema, values, isTopLevel = false) => {
210
+ if (!schema || !schema.properties || typeof values !== 'object' || values === null) {
211
+ return null;
212
+ }
213
+ return jsx("ul", {
214
+ className: "pl-4",
215
+ children: Object.entries(schema.properties).map(([field, fieldSchema]) => {
216
+ const value = values[field];
217
+ if (fieldSchema.type === 'object' && fieldSchema.properties) {
218
+ return jsxs("li", {
219
+ className: "mb-2",
220
+ children: [!(isConfigurationSchema && isTopLevel) && jsxs("div", {
221
+ className: "mb-1",
222
+ children: [jsxs("span", {
223
+ className: "font-bold",
224
+ children: [fieldSchema.title || field, ":"]
225
+ }), fieldSchema.databaseField && jsxs("span", {
226
+ className: "text-xs text-gray-500 ml-2",
227
+ children: ["\u2192 (", fieldSchema.databaseField, ")"]
228
+ })]
229
+ }), renderFields(fieldSchema, value, false)]
230
+ }, field);
231
+ }
232
+ const isObjectValue = typeof value === 'object' && !Array.isArray(value) && value !== null && !(value instanceof Date);
233
+ return jsxs("li", {
234
+ className: "mb-1",
235
+ children: [jsxs("span", {
236
+ className: "font-medium",
237
+ children: [fieldSchema.title || field, ":"]
238
+ }), isObjectValue && fieldSchema.databaseField && jsxs("span", {
239
+ className: "text-xs text-gray-500 ml-2",
240
+ children: ["\u2192 (", fieldSchema.databaseField, ")"]
241
+ }), ' ', renderFieldValue(fieldSchema, value), !isObjectValue && fieldSchema.databaseField && jsxs("span", {
242
+ className: "text-xs text-gray-500 ml-2",
243
+ children: ["\u2192 (", fieldSchema.databaseField, ")"]
244
+ })]
245
+ }, field);
246
+ })
247
+ });
248
+ };
249
+ const renderSummary = data => {
250
+ if (isConfigurationSchema) {
251
+ const actualFormData = data.properties || data;
252
+ return jsx("div", {
253
+ className: "space-y-6",
254
+ children: jsx("div", {
255
+ className: "bg-gray-50 border border-gray-200 rounded-lg p-4 mb-2",
256
+ children: renderFields(formSchema, actualFormData, true)
257
+ })
258
+ });
259
+ }
260
+ return jsx("div", {
261
+ className: "space-y-6",
262
+ children: Object.entries(data).map(([step, values]) => {
263
+ const stepSchema = formSchema?.properties?.[step];
264
+ return jsxs("div", {
265
+ className: "bg-gray-50 border border-gray-200 rounded-lg p-4 mb-2",
266
+ children: [!(stepSchema && stepSchema.type === 'object' && stepSchema.properties) && jsx("div", {
267
+ className: "font-semibold text-lg mb-2 text-gray-800 border-b border-gray-200 pb-1",
268
+ children: stepSchema?.title || step
269
+ }), renderFields(stepSchema, values, false)]
270
+ }, step);
271
+ })
272
+ });
273
+ };
274
+ if (!currentStepSchema) {
275
+ return jsx("main", {
276
+ className: "flex-1 p-8 overflow-y-auto",
277
+ children: jsx("div", {
278
+ className: "max-w-4xl mx-auto",
279
+ children: jsx("div", {
280
+ className: "text-center text-gray-500",
281
+ children: "No form steps available"
282
+ })
283
+ })
284
+ });
285
+ }
286
+ return jsx("main", {
287
+ className: "flex-1 p-8 overflow-y-auto",
288
+ children: jsxs("div", {
289
+ className: "max-w-4xl mx-auto",
290
+ children: [!isConfigurationSchema && jsx(PreviewStepper, {
291
+ steps: steps,
292
+ currentStep: currentStep,
293
+ schema: formSchema
294
+ }), jsxs("div", {
295
+ className: "bg-white border border-gray-200 rounded-lg shadow-sm p-5 mb-8",
296
+ children: [jsx("h2", {
297
+ className: "text-3xl font-bold text-gray-800 text-center",
298
+ children: isConfigurationSchema ? formSchema?.properties?.configurationStep?.title || 'Configuration' : currentStepSchema?.title || currentStep
299
+ }), !isConfigurationSchema && currentStepSchema?.description && jsx("div", {
300
+ className: "text-lg text-gray-800 font-medium text-center mb-2 mt-2",
301
+ children: currentStepSchema.description
302
+ }), jsx(PreviewFormRenderer, {
303
+ schema: currentStepSchema,
304
+ uiSchema: currentUISchema,
305
+ stepName: currentStep,
306
+ onNext: handleNext,
307
+ onPrevious: steps.indexOf(currentStep) > 0 ? handlePrevious : undefined,
308
+ isLoading: isLoading,
309
+ isLastStep: steps.indexOf(currentStep) === steps.length - 1,
310
+ customValidateFunction: customValidateFunction,
311
+ validator: validator
312
+ })]
313
+ }), jsxs(PreviewDialog, {
314
+ open: isDialogOpen,
315
+ onClose: () => setIsDialogOpen(false),
316
+ children: [jsx("h3", {
317
+ className: "text-xl font-bold mb-4 text-center",
318
+ children: "Review Your Submission"
319
+ }), jsx("div", {
320
+ className: "max-h-[60vh] overflow-y-auto pr-2",
321
+ children: submittedData ? renderSummary(submittedData) : jsx("div", {
322
+ className: "text-center text-gray-500 py-8",
323
+ children: "No data to review"
324
+ })
325
+ }), jsxs("div", {
326
+ className: "flex justify-end gap-2 mt-6",
327
+ children: [jsx("button", {
328
+ className: "px-4 py-2 bg-gray-200 rounded hover:bg-gray-300",
329
+ onClick: () => setIsDialogOpen(false),
330
+ children: "Cancel"
331
+ }), jsx("button", {
332
+ className: "px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700",
333
+ onClick: () => {
334
+ setIsDialogOpen(false);
335
+ setIsLoading(true);
336
+ if (isConfigurationSchema && submittedData) {
337
+ const amenitiesFragmentSchema = generateAmenitiesFragmentSchema(formSchema);
338
+ console.log('amenitiesFragmentSchema', {
339
+ amenitiesFragmentSchema
340
+ });
341
+ handleSubmit({
342
+ formData: submittedData,
343
+ amenitiesFragmentSchema
344
+ });
345
+ } else {
346
+ handleSubmit({
347
+ formData: submittedData
348
+ });
349
+ }
350
+ setIsLoading(false);
351
+ },
352
+ children: "Confirm & Submit"
353
+ })]
354
+ })]
355
+ })]
356
+ })
357
+ });
358
+ };export{PreviewTab};//# sourceMappingURL=PreviewTab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewTab.js","sources":["../../../src/components/RJSFPreview/PreviewTab.tsx"],"sourcesContent":[null],"names":[],"mappings":"oUAWI,MAAA,UACI,GAAA,CAAA;YAIA;UACA;wBACA;AACH,EAAA;cACD;uBACmB,GAAC,KAAA;AACvB,EAAA;AAED,CAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,45 @@
1
+ import {jsxs,jsx}from'react/jsx-runtime';const PreviewTextareaWidget = ({
2
+ id,
3
+ value,
4
+ required,
5
+ disabled,
6
+ readonly,
7
+ onChange,
8
+ placeholder,
9
+ schema,
10
+ rawErrors
11
+ }) => {
12
+ const handleChange = event => {
13
+ const textValue = event.target.value;
14
+ if (typeof onChange === 'function') {
15
+ onChange(textValue);
16
+ }
17
+ };
18
+ return jsxs("div", {
19
+ className: "bg-white rounded-lg mb-4 space-y-2",
20
+ children: [schema?.title && jsxs("label", {
21
+ htmlFor: id,
22
+ className: "block text-base font-semibold text-gray-800 mb-3",
23
+ children: [schema.title, required && jsx("span", {
24
+ className: "text-red-500 ml-1",
25
+ children: "*"
26
+ })]
27
+ }), jsx("textarea", {
28
+ id: id,
29
+ value: value || '',
30
+ onChange: handleChange,
31
+ disabled: disabled || readonly,
32
+ placeholder: placeholder,
33
+ rows: 4,
34
+ minLength: schema?.minLength,
35
+ maxLength: schema?.maxLength,
36
+ className: `w-full px-3 py-2 rounded-md shadow-sm focus:outline-none focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed resize-vertical min-h-[100px] ${rawErrors && rawErrors.length > 0 ? 'border-2 border-red-500 focus:border-red-500 focus:ring-red-500' : 'border border-gray-300 focus:border-blue-500 focus:ring-blue-500'}`
37
+ }), schema?.maxLength && jsxs("div", {
38
+ className: "text-xs text-gray-500 text-right mt-1",
39
+ children: [(value || '').length, "/", schema.maxLength, " characters"]
40
+ }), rawErrors && rawErrors.length > 0 && jsx("p", {
41
+ className: "mt-1 text-sm text-red-500",
42
+ children: rawErrors[0]
43
+ })]
44
+ });
45
+ };export{PreviewTextareaWidget};//# sourceMappingURL=PreviewTextareaWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewTextareaWidget.js","sources":["../../../src/components/RJSFPreview/PreviewTextareaWidget.tsx"],"sourcesContent":[null],"names":[],"mappings":"yCACS,MAAA;AAET,EAAA,EAAA;OACI;AACH,EAAA,QAAA;AAED,EAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Generates a JSON schema with input values embedded in the properties
3
+ */
4
+ function generateSchemaWithInputs(formSchema, formData) {
5
+ if (!formSchema || !formData) {
6
+ return formSchema;
7
+ }
8
+ const newSchema = JSON.parse(JSON.stringify(formSchema));
9
+ function processProperties(schema, data) {
10
+ if (!schema || !schema.properties) {
11
+ return {};
12
+ }
13
+ const result = {};
14
+ for (const [propertyName, propertySchema] of Object.entries(schema.properties)) {
15
+ const inputValue = data?.[propertyName];
16
+ const safePropertySchema = propertySchema && typeof propertySchema === 'object' ? propertySchema : {};
17
+ if (safePropertySchema && typeof safePropertySchema === 'object' && safePropertySchema['type'] === 'object' && safePropertySchema['properties'] && typeof safePropertySchema['properties'] === 'object') {
18
+ const nestedValues = processProperties(safePropertySchema, inputValue);
19
+ result[propertyName] = nestedValues;
20
+ } else {
21
+ if (safePropertySchema && safePropertySchema['type'] === 'boolean' && typeof inputValue === 'boolean') {
22
+ const fieldLabel = safePropertySchema['placeholder'] || safePropertySchema['title'] || propertyName;
23
+ result[propertyName] = {
24
+ label: fieldLabel,
25
+ value: inputValue
26
+ };
27
+ } else if (safePropertySchema && safePropertySchema['type'] === 'array' && safePropertySchema['items'] && safePropertySchema['items']['oneOf'] && Array.isArray(inputValue)) {
28
+ const oneOfOptions = safePropertySchema['items']['oneOf'];
29
+ const selectedObjects = inputValue.map(selectedKey => {
30
+ const option = oneOfOptions.find(opt => opt.const === selectedKey);
31
+ return {
32
+ label: option?.title || selectedKey,
33
+ value: selectedKey
34
+ };
35
+ });
36
+ result[propertyName] = selectedObjects;
37
+ } else {
38
+ if (inputValue !== undefined && inputValue !== null && inputValue !== '') {
39
+ result[propertyName] = inputValue;
40
+ } else {
41
+ result[propertyName] = null;
42
+ }
43
+ }
44
+ }
45
+ }
46
+ return result;
47
+ }
48
+ return processProperties(newSchema, formData);
49
+ }
50
+ function extractConfigurationFormData(formData) {
51
+ return formData;
52
+ }
53
+ function extractMultiStepFormData(formData) {
54
+ const flattenedData = {};
55
+ for (const [, stepData] of Object.entries(formData)) {
56
+ if (typeof stepData === 'object' && stepData !== null) {
57
+ Object.assign(flattenedData, stepData);
58
+ }
59
+ }
60
+ return flattenedData;
61
+ }
62
+ function generateAmenitiesFragmentSchema(formSchema) {
63
+ if (!formSchema) {
64
+ return null;
65
+ }
66
+ const definitions = formSchema.definitions || formSchema.$defs || {};
67
+ const transformedDefs = {};
68
+ function removeTitle(obj) {
69
+ if (Array.isArray(obj)) {
70
+ return obj.map(removeTitle);
71
+ } else if (obj && typeof obj === 'object') {
72
+ const {
73
+ title,
74
+ ...rest
75
+ } = obj;
76
+ const result = {};
77
+ for (const [key, value] of Object.entries(rest)) {
78
+ result[key] = removeTitle(value);
79
+ }
80
+ return result;
81
+ }
82
+ return obj;
83
+ }
84
+ for (const [defName, defSchema] of Object.entries(definitions)) {
85
+ transformedDefs[defName] = removeTitle(defSchema);
86
+ }
87
+ function transformProperties(properties) {
88
+ if (!properties || typeof properties !== 'object') {
89
+ return {};
90
+ }
91
+ const transformedProps = {};
92
+ for (const [propName, propSchema] of Object.entries(properties)) {
93
+ const schema = propSchema;
94
+ if (schema.type === 'object' && schema.properties) {
95
+ transformedProps[propName] = {
96
+ type: 'object',
97
+ properties: transformProperties(schema.properties)
98
+ };
99
+ } else if (schema.$ref) {
100
+ let normalizedRef = schema.$ref;
101
+ if (normalizedRef.startsWith('#/definitions/')) {
102
+ normalizedRef = normalizedRef.replace('#/definitions/', '#/$defs/');
103
+ }
104
+ transformedProps[propName] = {
105
+ $ref: normalizedRef
106
+ };
107
+ } else {
108
+ const fieldType = schema.type || 'string';
109
+ const baseDefName = `${propName}Base`;
110
+ if (!transformedDefs[baseDefName]) {
111
+ transformedDefs[baseDefName] = {
112
+ type: fieldType
113
+ };
114
+ }
115
+ transformedProps[propName] = {
116
+ $ref: `#/$defs/${baseDefName}`
117
+ };
118
+ }
119
+ }
120
+ return transformedProps;
121
+ }
122
+ const transformedProperties = transformProperties(formSchema.properties);
123
+ const schemaWithoutTitle = removeTitle({
124
+ type: 'object',
125
+ properties: transformedProperties
126
+ });
127
+ const amenitiesFragment = {
128
+ configuration: {
129
+ $defs: transformedDefs,
130
+ schema: schemaWithoutTitle
131
+ }
132
+ };
133
+ return amenitiesFragment;
134
+ }export{extractConfigurationFormData,extractMultiStepFormData,generateAmenitiesFragmentSchema,generateSchemaWithInputs};//# sourceMappingURL=generateSchemaWithInputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateSchemaWithInputs.js","sources":["../../../src/components/RJSFPreview/generateSchemaWithInputs.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;AAEG;AACH,SAAA,wBAAgB,CAAA,UAAyB,EAAA,QAAY,EAAA;AA4DrD,EAAA,IAAA,CAAA,UAAA,IAAA,CAAA;AAIA,IAAA,OAAA,UAAA;AAUA,EAAA;AAwFA,EAAA,MAAA,SAAA,GAAA,IAAgB,gCAAgC,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +1,36 @@
1
+ /**
2
+ * Schema-driven forms.
3
+ *
4
+ * A form here is a JSON Schema plus a uiSchema: the schema is the data contract
5
+ * (fields, types, required, secret) and the uiSchema is the presentation, which
6
+ * is per-surface - the same schema renders dense on the web and one step per
7
+ * screen on a phone, without either side re-declaring the fields.
8
+ *
9
+ * Exported as its own subpath, `@admin-layout/tailwind-ui/forms`, so @rjsf/*
10
+ * stays an optional peer for every other consumer. This lived behind a deep import
11
+ * (`@admin-layout/tailwind-ui/src/components/RJSFPreview`) with no consumers,
12
+ * and the cost showed: product forms were hand-rolled instead - a credential
13
+ * vault form built on raw <input> elements grew its own autofill desync, had no
14
+ * record binding to update through, and kept its validation in a marker parser.
15
+ * A shared renderer nobody can import is a shared renderer nobody uses.
16
+ */
1
17
  export { PreviewTab } from './PreviewTab';
18
+ export { PreviewFormRenderer } from './PreviewFormRenderer';
19
+ export { PreviewStepper } from './PreviewStepper';
20
+ export { PreviewDialog } from './PreviewDialog';
21
+ export { PreviewFieldTemplate } from './PreviewFieldTemplate';
22
+ export { PreviewCustomFieldTemplate } from './PreviewCustomFieldTemplate';
23
+ export { PreviewObjectFieldTemplate } from './PreviewObjectFieldTemplate';
24
+ export { PreviewInputWidget } from './PreviewInputWidget';
25
+ export { PreviewTextareaWidget } from './PreviewTextareaWidget';
26
+ export { PreviewDropdownWidget } from './PreviewDropdownWidget';
27
+ export { PreviewRadioWidget } from './PreviewRadioWidget';
28
+ export { PreviewCheckboxWidget } from './PreviewCheckboxWidget';
29
+ export { PreviewSwitchWidget } from './PreviewSwitchWidget';
30
+ export { PreviewDateWidget } from './PreviewDateWidget';
31
+ export { PreviewFileUploadWidget } from './PreviewFileUploadWidget';
32
+ export { PreviewImageUploadWidget } from './PreviewImageUploadWidget';
33
+ export { default as PreviewAsyncDropdown } from './PreviewAsyncDropdown';
34
+ export type { SelectWidgetProps } from './PreviewAsyncDropdown';
35
+ export { generateSchemaWithInputs, extractConfigurationFormData, extractMultiStepFormData, } from './generateSchemaWithInputs';
2
36
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RJSFPreview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/RJSFPreview/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAK1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EACH,wBAAwB,EACxB,4BAA4B,EAC5B,wBAAwB,GAC3B,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1 @@
1
+ export{PreviewTab}from'./PreviewTab.js';export{PreviewFormRenderer}from'./PreviewFormRenderer.js';export{PreviewStepper}from'./PreviewStepper.js';export{PreviewDialog}from'./PreviewDialog.js';export{PreviewFieldTemplate}from'./PreviewFieldTemplate.js';export{PreviewCustomFieldTemplate}from'./PreviewCustomFieldTemplate.js';export{PreviewObjectFieldTemplate}from'./PreviewObjectFieldTemplate.js';export{PreviewInputWidget}from'./PreviewInputWidget.js';export{PreviewTextareaWidget}from'./PreviewTextareaWidget.js';export{PreviewDropdownWidget}from'./PreviewDropdownWidget.js';export{PreviewRadioWidget}from'./PreviewRadioWidget.js';export{PreviewCheckboxWidget}from'./PreviewCheckboxWidget.js';export{PreviewSwitchWidget}from'./PreviewSwitchWidget.js';export{PreviewDateWidget}from'./PreviewDateWidget.js';export{PreviewFileUploadWidget}from'./PreviewFileUploadWidget.js';export{PreviewImageUploadWidget}from'./PreviewImageUploadWidget.js';export{default as PreviewAsyncDropdown}from'./PreviewAsyncDropdown.js';export{extractConfigurationFormData,extractMultiStepFormData,generateSchemaWithInputs}from'./generateSchemaWithInputs.js';//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import {jsx}from'react/jsx-runtime';import {createContext,useState,useEffect,useMemo}from'react';import'../../hooks/useToast.js';import {useMediaQuery}from'../../hooks/useMediaQuery.js';const themes = [{
1
+ import {jsx}from'react/jsx-runtime';import {createContext,useState,useEffect,useMemo}from'react';import {useMediaQuery}from'../../hooks/useMediaQuery.js';import'../../hooks/useToast.js';const themes = [{
2
2
  value: 'default',
3
3
  label: 'Default',
4
4
  description: 'Clean and minimal design'
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAChF,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAK7B,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAChF,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useMediaQuery.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMediaQuery.test.d.ts","sourceRoot":"","sources":["../../../src/hooks/__tests__/useMediaQuery.test.tsx"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- interface MediaQueryResult {
1
+ export interface MediaQueryResult {
2
2
  width: number;
3
3
  height: number;
4
4
  isMobile: boolean;
@@ -9,6 +9,13 @@ interface MediaQueryResult {
9
9
  xl: boolean;
10
10
  '2xl': boolean;
11
11
  }
12
+ /**
13
+ * Viewport size and Tailwind breakpoint flags.
14
+ *
15
+ * Hydration-safe: while hydrating, React renders the server snapshot (desktop) so the
16
+ * markup matches what the server sent, then re-renders with the real viewport. Reading
17
+ * `window` in the first render instead made every phone-width load throw React #418 and
18
+ * discard the server HTML. Client-only mounts get the real viewport straight away.
19
+ */
12
20
  export declare const useMediaQuery: () => MediaQueryResult;
13
- export {};
14
21
  //# sourceMappingURL=useMediaQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useMediaQuery.ts"],"names":[],"mappings":"AAEA,UAAU,gBAAgB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CAClB;AAoBD,eAAO,MAAM,aAAa,QAAO,gBAyChC,CAAC"}
1
+ {"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useMediaQuery.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;CAClB;AAoDD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAO,gBAAmF,CAAC"}