@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,178 @@
1
+ import {jsxs,jsx}from'react/jsx-runtime';import {useState,useRef}from'react';const style = `
2
+ input[type="date"]::-webkit-calendar-picker-indicator {
3
+ opacity: 0;
4
+ display: none;
5
+ }
6
+ input[type="date"]::-moz-calendar-picker-indicator {
7
+ opacity: 0;
8
+ display: none;
9
+ }
10
+ input[type="date"]::-ms-input-placeholder {
11
+ opacity: 0;
12
+ display: none;
13
+ }
14
+ `;
15
+ const PreviewDateWidget = ({
16
+ id,
17
+ value,
18
+ required,
19
+ disabled,
20
+ readonly,
21
+ onChange,
22
+ placeholder,
23
+ schema,
24
+ rawErrors
25
+ }) => {
26
+ const [isCalendarOpen, setIsCalendarOpen] = useState(false);
27
+ const [currentDate, setCurrentDate] = useState(() => {
28
+ if (value) {
29
+ return new Date(value);
30
+ }
31
+ return new Date();
32
+ });
33
+ const inputRef = useRef(null);
34
+ const handleDateChange = event => {
35
+ const dateValue = event.target.value;
36
+ onChange(dateValue);
37
+ };
38
+ const handleCalendarDateSelect = date => {
39
+ const formattedDate = date.toISOString().split('T')[0];
40
+ onChange(formattedDate);
41
+ setIsCalendarOpen(false);
42
+ };
43
+ const generateCalendarDays = () => {
44
+ const year = currentDate.getFullYear();
45
+ const month = currentDate.getMonth();
46
+ const firstDay = new Date(year, month, 1);
47
+ const startDate = new Date(firstDay);
48
+ startDate.setDate(startDate.getDate() - firstDay.getDay());
49
+ const days = [];
50
+ for (let i = 0; i < 42; i++) {
51
+ const date = new Date(startDate);
52
+ date.setDate(startDate.getDate() + i);
53
+ days.push(date);
54
+ }
55
+ return days;
56
+ };
57
+ return jsxs("div", {
58
+ className: "mb-4",
59
+ children: [jsx("style", {
60
+ children: style
61
+ }), schema?.title && jsxs("label", {
62
+ htmlFor: id,
63
+ className: "block text-base font-semibold text-gray-800 mb-3",
64
+ children: [schema.title, required && jsx("span", {
65
+ className: "text-red-500 ml-1",
66
+ children: "*"
67
+ })]
68
+ }), jsxs("div", {
69
+ className: "relative",
70
+ children: [jsx("input", {
71
+ ref: inputRef,
72
+ id: id,
73
+ type: "date",
74
+ value: value || '',
75
+ onChange: handleDateChange,
76
+ disabled: disabled || readonly,
77
+ className: `w-full px-3 py-2 rounded-md focus:outline-none focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed ${rawErrors && rawErrors.length > 0 ? 'border-2 border-red-500 focus:border-red-500 focus:ring-red-100' : 'border border-gray-300 focus:border-blue-500 focus:ring-blue-500'}`
78
+ }), rawErrors && rawErrors.length > 0 && jsx("p", {
79
+ className: "mt-1 text-sm text-red-500",
80
+ children: rawErrors[0]
81
+ }), !disabled && !readonly && jsx("button", {
82
+ type: "button",
83
+ onClick: () => setIsCalendarOpen(!isCalendarOpen),
84
+ className: "absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",
85
+ tabIndex: -1,
86
+ children: jsx("svg", {
87
+ className: "w-5 h-5",
88
+ fill: "none",
89
+ stroke: "currentColor",
90
+ viewBox: "0 0 24 24",
91
+ children: jsx("path", {
92
+ strokeLinecap: "round",
93
+ strokeLinejoin: "round",
94
+ strokeWidth: 2,
95
+ d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
96
+ })
97
+ })
98
+ }), isCalendarOpen && !disabled && !readonly && jsxs("div", {
99
+ className: "absolute z-10 mt-1 w-64 bg-white border border-gray-300 rounded-md shadow-lg",
100
+ children: [jsx("div", {
101
+ className: "p-3 border-b border-gray-200",
102
+ children: jsxs("div", {
103
+ className: "flex items-center justify-between",
104
+ children: [jsx("button", {
105
+ type: "button",
106
+ onClick: () => {
107
+ const prevMonth = new Date(currentDate);
108
+ prevMonth.setMonth(prevMonth.getMonth() - 1);
109
+ setCurrentDate(prevMonth);
110
+ },
111
+ className: "p-1 hover:bg-gray-100 rounded",
112
+ children: jsx("svg", {
113
+ className: "w-4 h-4",
114
+ fill: "none",
115
+ stroke: "currentColor",
116
+ viewBox: "0 0 24 24",
117
+ children: jsx("path", {
118
+ strokeLinecap: "round",
119
+ strokeLinejoin: "round",
120
+ strokeWidth: 2,
121
+ d: "M15 19l-7-7 7-7"
122
+ })
123
+ })
124
+ }), jsx("span", {
125
+ className: "text-sm font-medium",
126
+ children: currentDate.toLocaleDateString('en-US', {
127
+ year: 'numeric',
128
+ month: 'long'
129
+ })
130
+ }), jsx("button", {
131
+ type: "button",
132
+ onClick: () => {
133
+ const nextMonth = new Date(currentDate);
134
+ nextMonth.setMonth(nextMonth.getMonth() + 1);
135
+ setCurrentDate(nextMonth);
136
+ },
137
+ className: "p-1 hover:bg-gray-100 rounded",
138
+ children: jsx("svg", {
139
+ className: "w-4 h-4",
140
+ fill: "none",
141
+ stroke: "currentColor",
142
+ viewBox: "0 0 24 24",
143
+ children: jsx("path", {
144
+ strokeLinecap: "round",
145
+ strokeLinejoin: "round",
146
+ strokeWidth: 2,
147
+ d: "M9 5l7 7-7 7"
148
+ })
149
+ })
150
+ })]
151
+ })
152
+ }), jsxs("div", {
153
+ className: "p-3",
154
+ children: [jsx("div", {
155
+ className: "grid grid-cols-7 gap-1 text-xs text-gray-500 mb-2",
156
+ children: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].map(day => jsx("div", {
157
+ className: "text-center",
158
+ children: day
159
+ }, day))
160
+ }), jsx("div", {
161
+ className: "grid grid-cols-7 gap-1",
162
+ children: generateCalendarDays().map((date, index) => {
163
+ const isCurrentMonth = date.getMonth() === currentDate.getMonth();
164
+ const isToday = date.toDateString() === new Date().toDateString();
165
+ const isSelected = value && date.toISOString().split('T')[0] === value;
166
+ return jsx("button", {
167
+ type: "button",
168
+ onClick: () => handleCalendarDateSelect(date),
169
+ className: `p-2 text-sm rounded hover:bg-blue-50 ${!isCurrentMonth ? 'text-gray-300' : 'text-gray-700'} ${isToday ? 'bg-blue-100 font-semibold' : ''} ${isSelected ? 'bg-blue-500 text-white hover:bg-blue-600' : ''}`,
170
+ children: date.getDate()
171
+ }, index);
172
+ })
173
+ })]
174
+ })]
175
+ })]
176
+ })]
177
+ });
178
+ };export{PreviewDateWidget};//# sourceMappingURL=PreviewDateWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewDateWidget.js","sources":["../../../src/components/RJSFPreview/PreviewDateWidget.tsx"],"sourcesContent":[null],"names":[],"mappings":"6EAkBA,MAAA,KAAU,GAAA;;AAET;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,21 @@
1
+ import {jsx,jsxs}from'react/jsx-runtime';const PreviewDialog = ({
2
+ open,
3
+ onClose,
4
+ children
5
+ }) => {
6
+ if (!open) return null;
7
+ return jsx("div", {
8
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-40",
9
+ onClick: onClose,
10
+ children: jsxs("div", {
11
+ className: "bg-white rounded-lg shadow-lg p-6 min-w-[320px] max-w-lg w-full relative",
12
+ onClick: e => e.stopPropagation(),
13
+ children: [jsx("button", {
14
+ className: "absolute top-2 right-2 text-gray-500 hover:text-gray-700",
15
+ onClick: onClose,
16
+ "aria-label": "Close",
17
+ children: "\u00D7"
18
+ }), children]
19
+ })
20
+ });
21
+ };export{PreviewDialog};//# sourceMappingURL=PreviewDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewDialog.js","sources":["../../../src/components/RJSFPreview/PreviewDialog.tsx"],"sourcesContent":[null],"names":[],"mappings":"yCAEU,MAAA,aAAA,GAAkB,CAAA;MACxB;SACA;AACA,EAAA;AACH,CAAA,KAAA;AAED,EAAA,IAAA,CAAA,IAAA,EAAA,OAAO;;;;;;;;;;;;;;;"}
@@ -0,0 +1,66 @@
1
+ import {jsxs,jsx}from'react/jsx-runtime';const PreviewDropdownWidget = ({
2
+ id,
3
+ value,
4
+ required,
5
+ disabled,
6
+ readonly,
7
+ onChange,
8
+ placeholder,
9
+ schema,
10
+ options,
11
+ rawErrors
12
+ }) => {
13
+ const handleChange = event => {
14
+ const selectedValue = event.target.value;
15
+ onChange(selectedValue);
16
+ };
17
+ let enumOptions = [];
18
+ if (Array.isArray(options?.enumOptions)) {
19
+ enumOptions = options.enumOptions;
20
+ } else if (schema?.enum && schema?.enumNames) {
21
+ enumOptions = schema.enum.map((value, index) => ({
22
+ value,
23
+ label: schema.enumNames[index] || value
24
+ }));
25
+ } else if (schema?.enumLabels && Array.isArray(schema.enumLabels)) {
26
+ enumOptions = schema.enumLabels.map(option => ({
27
+ value: option.key,
28
+ label: option.value
29
+ }));
30
+ } else if (Array.isArray(schema?.enum)) {
31
+ enumOptions = schema.enum.map(v => ({
32
+ value: v,
33
+ label: v
34
+ }));
35
+ }
36
+ return jsxs("div", {
37
+ className: "space-y-3",
38
+ children: [jsxs("div", {
39
+ className: "block text-base font-semibold text-gray-800 mb-1",
40
+ children: [schema?.title, required && jsx("span", {
41
+ className: "text-red-500 ml-1",
42
+ children: "*"
43
+ })]
44
+ }), jsxs("select", {
45
+ id: id,
46
+ value: value || '',
47
+ onChange: handleChange,
48
+ disabled: disabled || readonly,
49
+ className: `w-full px-3 pb-2 rounded-md focus:outline-none focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed text-sm ${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'}`,
50
+ children: [jsx("option", {
51
+ value: "",
52
+ children: placeholder || 'Select an option...'
53
+ }), Array.isArray(enumOptions) && enumOptions.map((option, index) => {
54
+ const optionValue = option.value !== undefined ? option.value : option;
55
+ const optionLabel = option.label !== undefined ? option.label : option;
56
+ return jsx("option", {
57
+ value: String(optionValue),
58
+ children: String(optionLabel)
59
+ }, index);
60
+ })]
61
+ }), rawErrors && rawErrors.length > 0 && jsx("p", {
62
+ className: "mt-1 text-sm text-red-500",
63
+ children: rawErrors[0]
64
+ })]
65
+ });
66
+ };export{PreviewDropdownWidget};//# sourceMappingURL=PreviewDropdownWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewDropdownWidget.js","sources":["../../../src/components/RJSFPreview/PreviewDropdownWidget.tsx"],"sourcesContent":[null],"names":[],"mappings":"yCACS,MAAA;AAET,EAAA,EAAA;OACI;AACH,EAAA,QAAA;AAED,EAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,69 @@
1
+ import {jsxs,jsx}from'react/jsx-runtime';const PreviewFieldTemplate = ({
2
+ id,
3
+ classNames,
4
+ style,
5
+ label,
6
+ help,
7
+ required,
8
+ description,
9
+ errors,
10
+ children,
11
+ schema,
12
+ uiSchema
13
+ }) => {
14
+ const isGroup = schema.type === 'object' && schema.properties;
15
+ const isStepField = schema.type === 'object' && schema.properties && (id === 'root' || id === 'root_step1' || id.includes('step'));
16
+ if (isStepField) {
17
+ return jsxs("div", {
18
+ className: "mb-4",
19
+ children: [children, jsx("hr", {
20
+ className: "border-gray-300 mt-6"
21
+ }), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
22
+ className: "text-sm text-red-600 mt-2",
23
+ children: errors.map((error, index) => jsx("div", {
24
+ children: error
25
+ }, index))
26
+ }), help && jsx("p", {
27
+ className: "text-sm text-gray-500 mt-2",
28
+ children: help
29
+ })]
30
+ });
31
+ }
32
+ if (isGroup) {
33
+ return jsxs("div", {
34
+ className: "mb-8",
35
+ children: [jsx("div", {
36
+ className: "mb-4 border-t border-gray-300"
37
+ }), jsx("div", {
38
+ className: "space-y-4",
39
+ children: children
40
+ }), jsx("div", {
41
+ className: "mt-4 border-t border-gray-300"
42
+ })]
43
+ });
44
+ }
45
+ return jsxs("div", {
46
+ className: "mb-4",
47
+ children: [label && jsxs("label", {
48
+ className: "block text-base font-semibold text-gray-800 mb-3",
49
+ children: [label, required && jsx("span", {
50
+ className: "text-red-500 ml-1",
51
+ children: "*"
52
+ })]
53
+ }), description && jsx("p", {
54
+ className: "text-sm text-gray-600 mb-3",
55
+ children: description
56
+ }), jsx("div", {
57
+ className: "space-y-2",
58
+ children: children
59
+ }), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
60
+ className: "text-sm text-red-600 mt-2",
61
+ children: errors.map((error, index) => jsx("div", {
62
+ children: error
63
+ }, index))
64
+ }), help && jsx("p", {
65
+ className: "text-sm text-gray-500 mt-2",
66
+ children: help
67
+ })]
68
+ });
69
+ };export{PreviewFieldTemplate};//# sourceMappingURL=PreviewFieldTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewFieldTemplate.js","sources":["../../../src/components/RJSFPreview/PreviewFieldTemplate.tsx"],"sourcesContent":[null],"names":[],"mappings":"yCACS,MAAA,oBAAoB;AAE7B,EAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,113 @@
1
+ import {jsx,jsxs}from'react/jsx-runtime';import {useState,useCallback}from'react';import {useDropzone}from'react-dropzone';import {BsUpload}from'@react-icons/all-files/bs/BsUpload.js';import {BsFileEarmark}from'@react-icons/all-files/bs/BsFileEarmark.js';const PreviewFileUploadWidget = ({
2
+ id,
3
+ value,
4
+ required,
5
+ disabled,
6
+ readonly,
7
+ onChange,
8
+ onBlur,
9
+ onFocus,
10
+ autofocus,
11
+ options,
12
+ schema,
13
+ type,
14
+ label,
15
+ placeholder,
16
+ rawErrors
17
+ }) => {
18
+ const [fileName, setFileName] = useState(() => {
19
+ if (value && typeof value === 'string' && value.startsWith('data:')) {
20
+ return 'Uploaded file';
21
+ }
22
+ return '';
23
+ });
24
+ const [fileDataUrl, setFileDataUrl] = useState(value || '');
25
+ const acceptValue = typeof options?.accept === 'string' && options.accept !== '*' ? {
26
+ [options.accept]: []
27
+ } : undefined;
28
+ const handleDrop = useCallback(acceptedFiles => {
29
+ const file = acceptedFiles[0];
30
+ if (file) {
31
+ setFileName(file.name);
32
+ const reader = new FileReader();
33
+ reader.onload = e => {
34
+ const dataUrl = e.target?.result;
35
+ setFileDataUrl(dataUrl);
36
+ onChange(dataUrl);
37
+ };
38
+ reader.readAsDataURL(file);
39
+ }
40
+ }, [onChange]);
41
+ const handleRemoveFile = () => {
42
+ setFileName('');
43
+ setFileDataUrl('');
44
+ onChange('');
45
+ };
46
+ const {
47
+ getRootProps,
48
+ getInputProps,
49
+ isDragActive,
50
+ isFocused
51
+ } = useDropzone({
52
+ onDrop: handleDrop,
53
+ accept: acceptValue,
54
+ multiple: false,
55
+ disabled: disabled || readonly,
56
+ autoFocus: Boolean(autofocus)
57
+ });
58
+ return jsx("div", {
59
+ className: "bg-white rounded-lg",
60
+ children: jsxs("div", {
61
+ className: "space-y-3",
62
+ children: [label && jsxs("label", {
63
+ htmlFor: id,
64
+ className: "block text-base font-semibold text-gray-800 mb-3",
65
+ children: [label, required && jsx("span", {
66
+ className: "text-red-500 ml-1",
67
+ children: "*"
68
+ })]
69
+ }), !fileName && jsxs("div", {
70
+ ...getRootProps({
71
+ className: `flex items-center justify-start border-2 border-dashed rounded-md px-4 py-6 cursor-pointer transition-colors text-xs ${isDragActive ? 'border-blue-500 bg-blue-50' : rawErrors && rawErrors.length > 0 ? 'border-red-500 bg-red-50 hover:bg-red-100' : 'border-gray-300 bg-gray-100 hover:bg-gray-200'} ${disabled || readonly ? 'opacity-50 cursor-not-allowed' : ''}`,
72
+ tabIndex: 0,
73
+ onBlur: () => onBlur(id, value),
74
+ onFocus: () => onFocus(id, value)
75
+ }),
76
+ children: [jsx("input", {
77
+ ...getInputProps(),
78
+ id: id
79
+ }), jsx(BsUpload, {
80
+ className: "w-4 h-4 mr-2 text-gray-500"
81
+ }), jsx("span", {
82
+ children: isDragActive ? 'Drop the file here...' : placeholder || 'Drag & drop or click to upload file...'
83
+ })]
84
+ }), fileName && jsx("div", {
85
+ className: "space-y-2",
86
+ children: jsxs("div", {
87
+ className: "flex items-center space-x-3 p-2 bg-gray-50 rounded-lg border border-gray-200 max-w-xs",
88
+ children: [jsx(BsFileEarmark, {
89
+ className: "w-5 h-5 text-gray-500"
90
+ }), jsxs("div", {
91
+ className: "flex-1 min-w-0",
92
+ children: [jsx("div", {
93
+ className: "text-sm font-medium text-gray-900 truncate",
94
+ children: fileName
95
+ }), jsx("div", {
96
+ className: "text-xs text-gray-500",
97
+ children: "File uploaded successfully"
98
+ })]
99
+ }), jsx("button", {
100
+ type: "button",
101
+ onClick: handleRemoveFile,
102
+ disabled: disabled || readonly,
103
+ className: "text-red-500 hover:text-red-700 focus:outline-none focus:ring-2 focus:ring-red-500 rounded flex-shrink-0",
104
+ children: "\u00D7"
105
+ })]
106
+ })
107
+ }), rawErrors && rawErrors.length > 0 && jsx("p", {
108
+ className: "mt-1 text-sm text-red-500",
109
+ children: rawErrors[0]
110
+ })]
111
+ })
112
+ });
113
+ };export{PreviewFileUploadWidget};//# sourceMappingURL=PreviewFileUploadWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewFileUploadWidget.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,195 @@
1
+ import {jsx,jsxs}from'react/jsx-runtime';import {useState}from'react';import Form from'@rjsf/core';import {PreviewCustomFieldTemplate}from'./PreviewCustomFieldTemplate.js';import {PreviewInputWidget}from'./PreviewInputWidget.js';import {PreviewFileUploadWidget}from'./PreviewFileUploadWidget.js';import {PreviewImageUploadWidget}from'./PreviewImageUploadWidget.js';import {PreviewCheckboxWidget}from'./PreviewCheckboxWidget.js';import {PreviewDateWidget}from'./PreviewDateWidget.js';import {PreviewTextareaWidget}from'./PreviewTextareaWidget.js';import {PreviewDropdownWidget}from'./PreviewDropdownWidget.js';import {PreviewRadioWidget}from'./PreviewRadioWidget.js';import {PreviewSwitchWidget}from'./PreviewSwitchWidget.js';import {PreviewObjectFieldTemplate}from'./PreviewObjectFieldTemplate.js';import PreviewAsyncDropdown from'./PreviewAsyncDropdown.js';const PreviewFormRenderer = ({
2
+ schema,
3
+ uiSchema,
4
+ stepName,
5
+ onNext,
6
+ onPrevious,
7
+ initialData = {},
8
+ isLoading = false,
9
+ isLastStep = false,
10
+ customValidateFunction,
11
+ validator
12
+ }) => {
13
+ const convertTransformedDataForForm = (formData, schema) => {
14
+ if (!formData || !schema?.properties) return formData;
15
+ const converted = {};
16
+ for (const [key, value] of Object.entries(formData)) {
17
+ const fieldSchema = schema.properties[key];
18
+ if (typeof value === 'object' && value !== null && 'label' in value && 'value' in value) {
19
+ converted[key] = value.value;
20
+ } else if (typeof value === 'object' && value !== null && 'label' in value && 'key' in value) {
21
+ converted[key] = value.key;
22
+ } else if (fieldSchema?.type === 'object' && fieldSchema?.properties) {
23
+ converted[key] = convertTransformedDataForForm(value, fieldSchema);
24
+ } else {
25
+ converted[key] = value;
26
+ }
27
+ }
28
+ return converted;
29
+ };
30
+ const processedInitialData = convertTransformedDataForForm(initialData, schema);
31
+ const [formData, setFormData] = useState(processedInitialData);
32
+ const handleSubmit = data => {
33
+ if (onNext && data.formData) {
34
+ const transformedFormData = transformDropdownAnswers(data.formData, schema);
35
+ onNext(transformedFormData);
36
+ }
37
+ };
38
+ const handleChange = data => {
39
+ if (data.formData) {
40
+ const convertedFormData = convertFormDataTypes(data.formData, schema);
41
+ setFormData(convertedFormData);
42
+ console.log('Current filled form data:', convertedFormData);
43
+ }
44
+ };
45
+ const convertFormDataTypes = (formData, schema) => {
46
+ if (!formData || !schema?.properties) return formData;
47
+ const converted = {};
48
+ for (const [key, value] of Object.entries(formData)) {
49
+ const fieldSchema = schema.properties[key];
50
+ if (fieldSchema?.type === 'boolean') {
51
+ if (typeof value === 'string') {
52
+ converted[key] = value.toLowerCase() === 'true' || value === '1';
53
+ } else if (typeof value === 'number') {
54
+ converted[key] = value === 1;
55
+ } else if (value === null || value === undefined) {
56
+ converted[key] = false;
57
+ } else {
58
+ converted[key] = Boolean(value);
59
+ }
60
+ } else if (fieldSchema?.type === 'object' && fieldSchema?.properties) {
61
+ converted[key] = convertFormDataTypes(value, fieldSchema);
62
+ } else {
63
+ converted[key] = value;
64
+ }
65
+ }
66
+ return converted;
67
+ };
68
+ const transformDropdownAnswers = (formData, schema) => {
69
+ if (!formData || !schema?.properties) return formData;
70
+ const transformed = {};
71
+ for (const [key, value] of Object.entries(formData)) {
72
+ const fieldSchema = schema.properties[key];
73
+ if (fieldSchema?.enum && fieldSchema?.enumNames && Array.isArray(fieldSchema.enum) && value !== null && value !== undefined && value !== '') {
74
+ const idx = fieldSchema.enum.indexOf(value);
75
+ if (idx !== -1 && fieldSchema.enumNames[idx]) {
76
+ const originalLabel = fieldSchema.enumNames[idx];
77
+ const uppercaseLabel = originalLabel.toUpperCase();
78
+ transformed[key] = {
79
+ label: uppercaseLabel,
80
+ value: value
81
+ };
82
+ } else {
83
+ transformed[key] = value;
84
+ }
85
+ } else if (fieldSchema?.oneOf && Array.isArray(fieldSchema.oneOf) && value !== null && value !== undefined && value !== '') {
86
+ const option = fieldSchema.oneOf.find(opt => opt.const === value);
87
+ if (option) {
88
+ transformed[key] = {
89
+ label: option.title,
90
+ key: option.const
91
+ };
92
+ } else {
93
+ transformed[key] = value;
94
+ }
95
+ } else if (fieldSchema?.type === 'object' && fieldSchema?.properties) {
96
+ transformed[key] = transformDropdownAnswers(value, fieldSchema);
97
+ } else {
98
+ transformed[key] = value;
99
+ }
100
+ }
101
+ return transformed;
102
+ };
103
+ const handlePrevious = () => {
104
+ onPrevious?.();
105
+ };
106
+ const createDebugWidget = (widgetName, OriginalWidget) => {
107
+ return props => {
108
+ console.log(`🎯 ${widgetName} called with props:`, {
109
+ id: props.id,
110
+ schema: props.schema,
111
+ uiSchema: props.uiSchema,
112
+ options: props.options,
113
+ value: props.value,
114
+ widgetName
115
+ });
116
+ return jsx(OriginalWidget, {
117
+ ...props
118
+ });
119
+ };
120
+ };
121
+ const customWidgetsWithPreview = {
122
+ TextWidget: PreviewInputWidget,
123
+ EmailWidget: PreviewInputWidget,
124
+ PasswordWidget: PreviewInputWidget,
125
+ URLWidget: PreviewInputWidget,
126
+ DateWidget: PreviewDateWidget,
127
+ DateTimeWidget: PreviewDateWidget,
128
+ TimeWidget: PreviewInputWidget,
129
+ SelectWidget: createDebugWidget('SelectWidget', PreviewDropdownWidget),
130
+ asyncSelect: createDebugWidget('AsyncSelectWidget', PreviewAsyncDropdown),
131
+ RadioWidget: createDebugWidget('RadioWidget', PreviewRadioWidget),
132
+ NumberWidget: PreviewInputWidget,
133
+ CheckboxWidget: PreviewCheckboxWidget,
134
+ CheckboxesWidget: createDebugWidget('CheckboxesWidget', PreviewCheckboxWidget),
135
+ SwitchWidget: createDebugWidget('SwitchWidget', PreviewSwitchWidget),
136
+ FileWidget: PreviewFileUploadWidget,
137
+ TextareaWidget: PreviewTextareaWidget,
138
+ textarea: PreviewTextareaWidget,
139
+ ImageWidget: PreviewImageUploadWidget,
140
+ FileUploadWidget: PreviewFileUploadWidget,
141
+ 'image-upload': PreviewImageUploadWidget,
142
+ 'file-upload': PreviewFileUploadWidget,
143
+ switch: PreviewSwitchWidget
144
+ };
145
+ schema?.title || 'Form';
146
+ const schemaWithoutTitle = schema ? {
147
+ ...schema,
148
+ title: undefined,
149
+ description: undefined
150
+ } : schema;
151
+ return jsx("div", {
152
+ className: "bg-white rounded-lg p-8",
153
+ children: jsx(Form, {
154
+ customValidate: customValidateFunction,
155
+ liveValidate: true,
156
+ validator: validator,
157
+ schema: schemaWithoutTitle,
158
+ uiSchema: uiSchema,
159
+ formData: formData,
160
+ onChange: handleChange,
161
+ onSubmit: handleSubmit,
162
+ className: "space-y-6",
163
+ widgets: customWidgetsWithPreview,
164
+ templates: {
165
+ FieldTemplate: PreviewCustomFieldTemplate,
166
+ ObjectFieldTemplate: PreviewObjectFieldTemplate,
167
+ ErrorListTemplate: () => null
168
+ },
169
+ formContext: {
170
+ labelCol: {
171
+ span: 24
172
+ },
173
+ wrapperCol: {
174
+ span: 24
175
+ },
176
+ isPreviewMode: true
177
+ },
178
+ children: jsxs("div", {
179
+ className: "flex justify-between pt-8",
180
+ children: [jsx("button", {
181
+ type: "button",
182
+ onClick: handlePrevious,
183
+ disabled: !onPrevious,
184
+ className: `px-6 py-2 rounded-md font-medium transition-colors ${onPrevious ? 'bg-white text-gray-700 border border-gray-300 hover:bg-gray-50' : 'bg-gray-50 text-gray-400 cursor-not-allowed'}`,
185
+ children: "Back"
186
+ }), jsx("button", {
187
+ type: "submit",
188
+ disabled: isLoading,
189
+ className: `px-6 py-2 rounded-md font-medium transition-colors ${isLoading ? 'bg-gray-300 text-gray-500 cursor-not-allowed' : 'bg-blue-600 text-white hover:bg-blue-700'}`,
190
+ children: isLoading ? 'Loading...' : isLastStep ? 'Submit' : 'Next'
191
+ })]
192
+ })
193
+ })
194
+ });
195
+ };export{PreviewFormRenderer};//# sourceMappingURL=PreviewFormRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreviewFormRenderer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}