@admin-layout/tailwind-ui 12.2.4-alpha.98 → 12.2.5-alpha.5

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 (64) 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/InputToolBar/InputToolBar.d.ts.map +1 -1
  14. package/lib/components/InputToolBar/InputToolBar.js +73 -31
  15. package/lib/components/InputToolBar/InputToolBar.js.map +1 -1
  16. package/lib/components/InputToolBar/__tests__/RightOverflowMenu.test.d.ts +8 -0
  17. package/lib/components/InputToolBar/__tests__/RightOverflowMenu.test.d.ts.map +1 -0
  18. package/lib/components/InputToolBar/types.d.ts +2 -0
  19. package/lib/components/InputToolBar/types.d.ts.map +1 -1
  20. package/lib/components/RJSFPreview/PreviewAsyncDropdown.js +111 -0
  21. package/lib/components/RJSFPreview/PreviewAsyncDropdown.js.map +1 -0
  22. package/lib/components/RJSFPreview/PreviewCheckboxWidget.js +95 -0
  23. package/lib/components/RJSFPreview/PreviewCheckboxWidget.js.map +1 -0
  24. package/lib/components/RJSFPreview/PreviewCustomFieldTemplate.js +235 -0
  25. package/lib/components/RJSFPreview/PreviewCustomFieldTemplate.js.map +1 -0
  26. package/lib/components/RJSFPreview/PreviewDateWidget.js +178 -0
  27. package/lib/components/RJSFPreview/PreviewDateWidget.js.map +1 -0
  28. package/lib/components/RJSFPreview/PreviewDialog.js +21 -0
  29. package/lib/components/RJSFPreview/PreviewDialog.js.map +1 -0
  30. package/lib/components/RJSFPreview/PreviewDropdownWidget.js +66 -0
  31. package/lib/components/RJSFPreview/PreviewDropdownWidget.js.map +1 -0
  32. package/lib/components/RJSFPreview/PreviewFieldTemplate.js +69 -0
  33. package/lib/components/RJSFPreview/PreviewFieldTemplate.js.map +1 -0
  34. package/lib/components/RJSFPreview/PreviewFileUploadWidget.js +113 -0
  35. package/lib/components/RJSFPreview/PreviewFileUploadWidget.js.map +1 -0
  36. package/lib/components/RJSFPreview/PreviewFormRenderer.js +195 -0
  37. package/lib/components/RJSFPreview/PreviewFormRenderer.js.map +1 -0
  38. package/lib/components/RJSFPreview/PreviewImageUploadWidget.js +104 -0
  39. package/lib/components/RJSFPreview/PreviewImageUploadWidget.js.map +1 -0
  40. package/lib/components/RJSFPreview/PreviewInputWidget.js +70 -0
  41. package/lib/components/RJSFPreview/PreviewInputWidget.js.map +1 -0
  42. package/lib/components/RJSFPreview/PreviewObjectFieldTemplate.js +33 -0
  43. package/lib/components/RJSFPreview/PreviewObjectFieldTemplate.js.map +1 -0
  44. package/lib/components/RJSFPreview/PreviewRadioWidget.js +55 -0
  45. package/lib/components/RJSFPreview/PreviewRadioWidget.js.map +1 -0
  46. package/lib/components/RJSFPreview/PreviewStepper.js +40 -0
  47. package/lib/components/RJSFPreview/PreviewStepper.js.map +1 -0
  48. package/lib/components/RJSFPreview/PreviewSwitchWidget.js +75 -0
  49. package/lib/components/RJSFPreview/PreviewSwitchWidget.js.map +1 -0
  50. package/lib/components/RJSFPreview/PreviewTab.js +358 -0
  51. package/lib/components/RJSFPreview/PreviewTab.js.map +1 -0
  52. package/lib/components/RJSFPreview/PreviewTextareaWidget.js +45 -0
  53. package/lib/components/RJSFPreview/PreviewTextareaWidget.js.map +1 -0
  54. package/lib/components/RJSFPreview/generateSchemaWithInputs.js +134 -0
  55. package/lib/components/RJSFPreview/generateSchemaWithInputs.js.map +1 -0
  56. package/lib/components/RJSFPreview/index.d.ts +34 -0
  57. package/lib/components/RJSFPreview/index.d.ts.map +1 -1
  58. package/lib/components/RJSFPreview/index.js +1 -0
  59. package/lib/components/RJSFPreview/index.js.map +1 -0
  60. package/lib/components/index.d.ts.map +1 -1
  61. package/lib/index.js +1 -1
  62. package/lib/shardui/chart.d.ts +1 -1
  63. package/lib/shardui/resizable.d.ts +1 -1
  64. package/package.json +20 -5
@@ -0,0 +1,40 @@
1
+ import {jsx,jsxs}from'react/jsx-runtime';const PreviewStepper = ({
2
+ steps,
3
+ currentStep,
4
+ schema
5
+ }) => {
6
+ steps.indexOf(currentStep);
7
+ const isSingleStep = steps.length === 1;
8
+ return jsx("div", {
9
+ className: "mb-8",
10
+ children: jsxs("div", {
11
+ className: "flex items-center justify-center relative",
12
+ children: [jsx("div", {
13
+ className: "absolute top-5 left-0 w-full h-0.5 bg-gray-200"
14
+ }), jsx("div", {
15
+ className: `flex items-center w-full relative z-10 px-4 ${isSingleStep ? 'justify-center' : 'justify-between'}`,
16
+ children: steps.map((step, index) => {
17
+ const isCurrent = currentStep === step;
18
+ const stepSchema = schema?.properties?.[step];
19
+ const title = stepSchema?.title || step.replace(/([A-Z])/g, ' $1').replace(/^./, str => str.toUpperCase());
20
+ return jsxs("div", {
21
+ className: "flex flex-col items-center",
22
+ children: [jsx("div", {
23
+ className: `
24
+ w-10 h-10 rounded-full flex items-center justify-center text-lg font-bold border-2
25
+ ${isCurrent ? 'bg-blue-600 text-white border-white' : 'bg-white text-gray-600 border-gray-300'}
26
+ `,
27
+ children: index + 1
28
+ }), jsx("div", {
29
+ className: "mt-2 text-center",
30
+ children: jsx("p", {
31
+ className: `text-sm ${isCurrent ? 'text-blue-600 font-medium' : 'text-gray-600'}`,
32
+ children: title.replace('_', ' ')
33
+ })
34
+ })]
35
+ }, step);
36
+ })
37
+ })]
38
+ })
39
+ });
40
+ };export{PreviewStepper};//# sourceMappingURL=PreviewStepper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewStepper.js","sources":["../../../src/components/RJSFPreview/PreviewStepper.tsx"],"sourcesContent":[null],"names":[],"mappings":"yCAEU,MAAA,cAAA,GAAmB,CAAA;OACzB;aACA;;AAEH,CAAA,KAAA;AAED,eAA6B,CAAA,WAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,75 @@
1
+ import {jsxs,jsx}from'react/jsx-runtime';const PreviewSwitchWidget = ({
2
+ id,
3
+ value,
4
+ required,
5
+ disabled,
6
+ readonly,
7
+ onChange,
8
+ label,
9
+ placeholder,
10
+ options,
11
+ schema,
12
+ rawErrors,
13
+ showTitle = false
14
+ }) => {
15
+ const handleToggle = () => {
16
+ if (!disabled && !readonly) {
17
+ onChange(!value);
18
+ }
19
+ };
20
+ const handleKeyDown = event => {
21
+ if (event.key === ' ' || event.key === 'Enter') {
22
+ event.preventDefault();
23
+ handleToggle();
24
+ }
25
+ };
26
+ return jsxs("div", {
27
+ className: "space-y-3",
28
+ children: [showTitle && schema?.title && jsxs("label", {
29
+ className: "block text-base font-semibold text-gray-800 mb-3",
30
+ children: [schema.title, required && jsx("span", {
31
+ className: "text-red-500 ml-1",
32
+ children: "*"
33
+ })]
34
+ }), jsxs("div", {
35
+ className: "flex items-center space-x-3",
36
+ children: [jsxs("button", {
37
+ type: "button",
38
+ role: "switch",
39
+ "aria-checked": value || false,
40
+ "aria-labelledby": `${id}-label`,
41
+ onClick: handleToggle,
42
+ onKeyDown: handleKeyDown,
43
+ disabled: disabled || readonly,
44
+ className: `
45
+ relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent
46
+ transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2
47
+ ${value ? 'bg-blue-600' : 'bg-gray-200'}
48
+ ${disabled || readonly ? 'opacity-50 cursor-not-allowed' : 'hover:bg-blue-700 hover:bg-opacity-90'}
49
+ `,
50
+ children: [jsxs("span", {
51
+ className: "sr-only",
52
+ children: [value ? 'Disable' : 'Enable', " ", schema?.title || label || 'toggle']
53
+ }), jsx("span", {
54
+ "aria-hidden": "true",
55
+ className: `
56
+ pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0
57
+ transition duration-200 ease-in-out
58
+ ${value ? 'translate-x-5' : 'translate-x-0'}
59
+ `
60
+ })]
61
+ }), jsx("label", {
62
+ id: `${id}-label`,
63
+ className: `text-sm text-gray-700 ${disabled || readonly ? 'opacity-50' : 'cursor-pointer'}`,
64
+ onClick: !disabled && !readonly ? handleToggle : undefined,
65
+ children: placeholder || options?.placeholder || 'Toggle option'
66
+ })]
67
+ }), rawErrors && rawErrors.length > 0 && jsx("p", {
68
+ className: "text-sm text-red-500 mt-1",
69
+ children: rawErrors[0]
70
+ }), schema?.description && jsx("p", {
71
+ className: "text-xs text-gray-500 mt-1",
72
+ children: schema.description
73
+ })]
74
+ });
75
+ };export{PreviewSwitchWidget};//# sourceMappingURL=PreviewSwitchWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewSwitchWidget.js","sources":["../../../src/components/RJSFPreview/PreviewSwitchWidget.tsx"],"sourcesContent":[null],"names":[],"mappings":"yCACS,MAAA;AAET,EAAA,EAAA;OACI;UACA;AACH,EAAA,QAAA;AAED,EAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}