@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.
- package/lib/components/ErrorHandlers/ApplicationErrorHandler.d.ts.map +1 -1
- package/lib/components/ErrorHandlers/ApplicationErrorHandler.js +5 -1
- package/lib/components/ErrorHandlers/ApplicationErrorHandler.js.map +1 -1
- package/lib/components/ErrorHandlers/RemixErrorBoundary.d.ts +11 -0
- package/lib/components/ErrorHandlers/RemixErrorBoundary.d.ts.map +1 -1
- package/lib/components/ErrorHandlers/RemixErrorBoundary.js +134 -3
- package/lib/components/ErrorHandlers/RemixErrorBoundary.js.map +1 -1
- package/lib/components/ErrorHandlers/SPAErrorBoundary.d.ts.map +1 -1
- package/lib/components/ErrorHandlers/SPAErrorBoundary.js +5 -1
- package/lib/components/ErrorHandlers/SPAErrorBoundary.js.map +1 -1
- package/lib/components/ErrorHandlers/__tests__/RemixErrorBoundary.test.d.ts +2 -0
- package/lib/components/ErrorHandlers/__tests__/RemixErrorBoundary.test.d.ts.map +1 -0
- package/lib/components/InputToolBar/InputToolBar.d.ts.map +1 -1
- package/lib/components/InputToolBar/InputToolBar.js +73 -31
- package/lib/components/InputToolBar/InputToolBar.js.map +1 -1
- package/lib/components/InputToolBar/__tests__/RightOverflowMenu.test.d.ts +8 -0
- package/lib/components/InputToolBar/__tests__/RightOverflowMenu.test.d.ts.map +1 -0
- package/lib/components/InputToolBar/types.d.ts +2 -0
- package/lib/components/InputToolBar/types.d.ts.map +1 -1
- package/lib/components/RJSFPreview/PreviewAsyncDropdown.js +111 -0
- package/lib/components/RJSFPreview/PreviewAsyncDropdown.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewCheckboxWidget.js +95 -0
- package/lib/components/RJSFPreview/PreviewCheckboxWidget.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewCustomFieldTemplate.js +235 -0
- package/lib/components/RJSFPreview/PreviewCustomFieldTemplate.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewDateWidget.js +178 -0
- package/lib/components/RJSFPreview/PreviewDateWidget.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewDialog.js +21 -0
- package/lib/components/RJSFPreview/PreviewDialog.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewDropdownWidget.js +66 -0
- package/lib/components/RJSFPreview/PreviewDropdownWidget.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewFieldTemplate.js +69 -0
- package/lib/components/RJSFPreview/PreviewFieldTemplate.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewFileUploadWidget.js +113 -0
- package/lib/components/RJSFPreview/PreviewFileUploadWidget.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewFormRenderer.js +195 -0
- package/lib/components/RJSFPreview/PreviewFormRenderer.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewImageUploadWidget.js +104 -0
- package/lib/components/RJSFPreview/PreviewImageUploadWidget.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewInputWidget.js +70 -0
- package/lib/components/RJSFPreview/PreviewInputWidget.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewObjectFieldTemplate.js +33 -0
- package/lib/components/RJSFPreview/PreviewObjectFieldTemplate.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewRadioWidget.js +55 -0
- package/lib/components/RJSFPreview/PreviewRadioWidget.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewStepper.js +40 -0
- package/lib/components/RJSFPreview/PreviewStepper.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewSwitchWidget.js +75 -0
- package/lib/components/RJSFPreview/PreviewSwitchWidget.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewTab.js +358 -0
- package/lib/components/RJSFPreview/PreviewTab.js.map +1 -0
- package/lib/components/RJSFPreview/PreviewTextareaWidget.js +45 -0
- package/lib/components/RJSFPreview/PreviewTextareaWidget.js.map +1 -0
- package/lib/components/RJSFPreview/generateSchemaWithInputs.js +134 -0
- package/lib/components/RJSFPreview/generateSchemaWithInputs.js.map +1 -0
- package/lib/components/RJSFPreview/index.d.ts +34 -0
- package/lib/components/RJSFPreview/index.d.ts.map +1 -1
- package/lib/components/RJSFPreview/index.js +1 -0
- package/lib/components/RJSFPreview/index.js.map +1 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/shardui/chart.d.ts +1 -1
- package/lib/shardui/resizable.d.ts +1 -1
- package/package.json +20 -5
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {jsxs,jsx}from'react/jsx-runtime';const PreviewCheckboxWidget = ({
|
|
2
|
+
id,
|
|
3
|
+
value,
|
|
4
|
+
required,
|
|
5
|
+
disabled,
|
|
6
|
+
readonly,
|
|
7
|
+
onChange,
|
|
8
|
+
label,
|
|
9
|
+
placeholder,
|
|
10
|
+
schema,
|
|
11
|
+
options,
|
|
12
|
+
rawErrors
|
|
13
|
+
}) => {
|
|
14
|
+
const isBooleanCheckbox = schema?.type === 'boolean';
|
|
15
|
+
const isArrayCheckbox = schema?.type === 'array';
|
|
16
|
+
if (isBooleanCheckbox) {
|
|
17
|
+
const handleBooleanChange = event => {
|
|
18
|
+
onChange(event.target.checked);
|
|
19
|
+
};
|
|
20
|
+
const displayLabel = placeholder || schema?.placeholder || label || schema?.title || 'Checkbox';
|
|
21
|
+
return jsxs("div", {
|
|
22
|
+
className: "space-y-2",
|
|
23
|
+
children: [jsxs("div", {
|
|
24
|
+
className: "flex items-start space-x-3",
|
|
25
|
+
children: [jsx("input", {
|
|
26
|
+
id: id,
|
|
27
|
+
type: "checkbox",
|
|
28
|
+
checked: value || false,
|
|
29
|
+
onChange: handleBooleanChange,
|
|
30
|
+
disabled: disabled || readonly,
|
|
31
|
+
className: `mt-1 h-4 w-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed ${rawErrors && rawErrors.length > 0 ? 'border-2 border-red-500' : 'border border-gray-300'}`
|
|
32
|
+
}), jsx("label", {
|
|
33
|
+
htmlFor: id,
|
|
34
|
+
className: `text-sm text-gray-700 ${disabled || readonly ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`,
|
|
35
|
+
children: displayLabel
|
|
36
|
+
})]
|
|
37
|
+
}), rawErrors && rawErrors.length > 0 && jsx("p", {
|
|
38
|
+
className: "mt-1 text-sm text-red-500",
|
|
39
|
+
children: rawErrors[0]
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (isArrayCheckbox) {
|
|
44
|
+
const handleArrayChange = (optionValue, checked) => {
|
|
45
|
+
const currentValues = Array.isArray(value) ? value : [];
|
|
46
|
+
let newValues;
|
|
47
|
+
if (checked) {
|
|
48
|
+
newValues = currentValues.includes(optionValue) ? currentValues : [...currentValues, optionValue];
|
|
49
|
+
} else {
|
|
50
|
+
newValues = currentValues.filter(v => v !== optionValue);
|
|
51
|
+
}
|
|
52
|
+
onChange(newValues);
|
|
53
|
+
};
|
|
54
|
+
const checkboxOptions = Array.isArray(options?.enumOptions) ? options.enumOptions : Array.isArray(schema?.items?.oneOf) ? (schema?.items?.oneOf || []).map(option => ({
|
|
55
|
+
value: option.const || option.value || option,
|
|
56
|
+
label: option.title || option.label || option.const || option
|
|
57
|
+
})) : Array.isArray(schema?.items?.enum) ? (schema?.items?.enum || []).map(option => ({
|
|
58
|
+
value: option,
|
|
59
|
+
label: option
|
|
60
|
+
})) : [];
|
|
61
|
+
const currentValues = Array.isArray(value) ? value : [];
|
|
62
|
+
schema?.title || label || 'Select Options';
|
|
63
|
+
return jsxs("div", {
|
|
64
|
+
className: "space-y-2",
|
|
65
|
+
children: [checkboxOptions.map((option, index) => {
|
|
66
|
+
const optionValue = option.value !== undefined ? option.value : option;
|
|
67
|
+
const optionLabel = option.label !== undefined ? option.label : option;
|
|
68
|
+
const checkboxId = `${id}-${index}`;
|
|
69
|
+
const isChecked = currentValues.includes(optionValue);
|
|
70
|
+
return jsxs("div", {
|
|
71
|
+
className: "flex items-center space-x-3",
|
|
72
|
+
children: [jsx("input", {
|
|
73
|
+
id: checkboxId,
|
|
74
|
+
type: "checkbox",
|
|
75
|
+
checked: isChecked,
|
|
76
|
+
onChange: e => handleArrayChange(optionValue, e.target.checked),
|
|
77
|
+
disabled: disabled || readonly,
|
|
78
|
+
className: `h-4 w-4 text-blue-600 rounded focus:ring-blue-500 focus:ring-2 disabled:opacity-50 disabled:cursor-not-allowed ${rawErrors && rawErrors.length > 0 ? 'border-2 border-red-500' : 'border border-gray-300'}`
|
|
79
|
+
}), jsx("label", {
|
|
80
|
+
htmlFor: checkboxId,
|
|
81
|
+
className: `text-sm text-gray-700 ${disabled || readonly ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`,
|
|
82
|
+
children: String(optionLabel)
|
|
83
|
+
})]
|
|
84
|
+
}, index);
|
|
85
|
+
}), rawErrors && rawErrors.length > 0 && jsx("p", {
|
|
86
|
+
className: "mt-1 text-sm text-red-500",
|
|
87
|
+
children: rawErrors[0]
|
|
88
|
+
})]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return jsxs("div", {
|
|
92
|
+
className: "text-red-500 text-sm",
|
|
93
|
+
children: ["Unsupported checkbox schema type: ", schema?.type]
|
|
94
|
+
});
|
|
95
|
+
};export{PreviewCheckboxWidget};//# sourceMappingURL=PreviewCheckboxWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewCheckboxWidget.js","sources":["../../../src/components/RJSFPreview/PreviewCheckboxWidget.tsx"],"sourcesContent":[null],"names":[],"mappings":"yCACS,MAAA;AAET,EAAA,EAAA;OACI;AACH,EAAA,QAAA;AAED,EAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {jsxs,jsx}from'react/jsx-runtime';import React__default from'react';import {PreviewImageUploadWidget}from'./PreviewImageUploadWidget.js';import {PreviewFileUploadWidget}from'./PreviewFileUploadWidget.js';const PreviewCustomFieldTemplate = props => {
|
|
2
|
+
const {
|
|
3
|
+
id,
|
|
4
|
+
classNames,
|
|
5
|
+
style,
|
|
6
|
+
label,
|
|
7
|
+
help,
|
|
8
|
+
required,
|
|
9
|
+
description,
|
|
10
|
+
errors,
|
|
11
|
+
children,
|
|
12
|
+
schema,
|
|
13
|
+
uiSchema,
|
|
14
|
+
rawErrors
|
|
15
|
+
} = props;
|
|
16
|
+
const isImageField = schema.type === 'string' && schema.format === 'data-url' && (uiSchema?.['ui:widget'] === 'image-upload' || uiSchema?.['ui:options']?.fieldType === 'image' || typeof uiSchema?.['ui:options']?.accept === 'string' && uiSchema['ui:options'].accept.includes('image/*'));
|
|
17
|
+
const isFileField = schema.type === 'string' && schema.format === 'data-url' && (uiSchema?.['ui:widget'] === 'file-upload' || uiSchema?.['ui:options']?.fieldType === 'file' || typeof uiSchema?.['ui:options']?.accept === 'string' && !uiSchema['ui:options'].accept.includes('image/*'));
|
|
18
|
+
const isTextareaField = schema.type === 'string' && (uiSchema?.['ui:widget'] === 'textarea' || schema.widget === 'textarea');
|
|
19
|
+
const isDropdownField = schema.type === 'string' && schema.enum && Array.isArray(schema.enum) && schema.enum.length > 0;
|
|
20
|
+
const isGroupField = schema.type === 'object' && schema.properties;
|
|
21
|
+
const isStepField = schema.type === 'object' && schema.properties && (id === 'root' || id === 'root_step1' || id.includes('step'));
|
|
22
|
+
const isRadioField = schema.type === 'string' && (uiSchema?.['ui:widget'] === 'radio' || uiSchema?.['ui:widget'] === 'MultiFormControl' || schema.widget === 'radio' || schema.oneOf && Array.isArray(schema.oneOf));
|
|
23
|
+
const shouldShowLabel = label && (isImageField || isFileField || !isStepField && !isGroupField && !isTextareaField && (isDropdownField || schema.type !== 'object'));
|
|
24
|
+
const isPlainTextOrNumberInput = (schema.type === 'string' || schema.type === 'number') && !isImageField && !isFileField && !isTextareaField && !isDropdownField;
|
|
25
|
+
if (isPlainTextOrNumberInput) {
|
|
26
|
+
return jsxs("div", {
|
|
27
|
+
className: classNames,
|
|
28
|
+
style: style,
|
|
29
|
+
children: [React__default.isValidElement(children) ? React__default.cloneElement(children, {
|
|
30
|
+
rawErrors
|
|
31
|
+
}) : children, description && id !== 'root' && jsx("p", {
|
|
32
|
+
className: "text-sm text-gray-600 mb-3",
|
|
33
|
+
children: description
|
|
34
|
+
}), help && jsx("p", {
|
|
35
|
+
className: "text-sm text-gray-500 mt-2",
|
|
36
|
+
children: help
|
|
37
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
38
|
+
className: "text-red-600 text-sm mt-2",
|
|
39
|
+
children: errors.map((error, index) => jsx("div", {
|
|
40
|
+
children: error
|
|
41
|
+
}, index))
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (isDropdownField) {
|
|
46
|
+
return jsxs("div", {
|
|
47
|
+
className: classNames,
|
|
48
|
+
style: style,
|
|
49
|
+
children: [React__default.isValidElement(children) ? React__default.cloneElement(children, {
|
|
50
|
+
rawErrors
|
|
51
|
+
}) : children, description && jsx("p", {
|
|
52
|
+
className: "text-sm text-gray-600 mb-3",
|
|
53
|
+
children: description
|
|
54
|
+
}), help && jsx("p", {
|
|
55
|
+
className: "text-sm text-gray-500 mt-2",
|
|
56
|
+
children: help
|
|
57
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
58
|
+
className: "text-red-600 text-sm mt-2",
|
|
59
|
+
children: errors.map((error, index) => jsx("div", {
|
|
60
|
+
children: error
|
|
61
|
+
}, index))
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (isImageField) {
|
|
66
|
+
const childProps = children?.props;
|
|
67
|
+
if (childProps) {
|
|
68
|
+
return jsxs("div", {
|
|
69
|
+
className: classNames,
|
|
70
|
+
style: style,
|
|
71
|
+
children: [shouldShowLabel && jsxs("label", {
|
|
72
|
+
htmlFor: id,
|
|
73
|
+
className: "block text-base font-bold text-gray-800 mb-4",
|
|
74
|
+
children: [label, required && jsx("span", {
|
|
75
|
+
className: "text-red-500 ml-1",
|
|
76
|
+
children: "*"
|
|
77
|
+
})]
|
|
78
|
+
}), jsx(PreviewImageUploadWidget, {
|
|
79
|
+
...childProps
|
|
80
|
+
}), description && jsx("p", {
|
|
81
|
+
className: "text-sm text-gray-600 mb-3",
|
|
82
|
+
children: description
|
|
83
|
+
}), help && jsx("p", {
|
|
84
|
+
className: "text-sm text-gray-500 mt-2",
|
|
85
|
+
children: help
|
|
86
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
87
|
+
className: "text-red-600 text-sm mt-2",
|
|
88
|
+
children: errors.map((error, index) => jsx("div", {
|
|
89
|
+
children: error
|
|
90
|
+
}, index))
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (isFileField) {
|
|
96
|
+
const childProps = children?.props;
|
|
97
|
+
if (childProps) {
|
|
98
|
+
return jsxs("div", {
|
|
99
|
+
className: classNames,
|
|
100
|
+
style: style,
|
|
101
|
+
children: [shouldShowLabel && jsxs("label", {
|
|
102
|
+
htmlFor: id,
|
|
103
|
+
className: "block text-base font-bold text-gray-800 mb-4",
|
|
104
|
+
children: [label, required && jsx("span", {
|
|
105
|
+
className: "text-red-500 ml-1",
|
|
106
|
+
children: "*"
|
|
107
|
+
})]
|
|
108
|
+
}), jsx(PreviewFileUploadWidget, {
|
|
109
|
+
...childProps
|
|
110
|
+
}), description && jsx("p", {
|
|
111
|
+
className: "text-sm text-gray-600 mb-3",
|
|
112
|
+
children: description
|
|
113
|
+
}), help && jsx("p", {
|
|
114
|
+
className: "text-sm text-gray-500 mt-2",
|
|
115
|
+
children: help
|
|
116
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
117
|
+
className: "text-red-600 text-sm mt-2",
|
|
118
|
+
children: errors.map((error, index) => jsx("div", {
|
|
119
|
+
children: error
|
|
120
|
+
}, index))
|
|
121
|
+
})]
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (isTextareaField) {
|
|
126
|
+
return jsxs("div", {
|
|
127
|
+
className: classNames,
|
|
128
|
+
style: style,
|
|
129
|
+
children: [React__default.isValidElement(children) ? React__default.cloneElement(children, {
|
|
130
|
+
rawErrors
|
|
131
|
+
}) : children, help && jsx("p", {
|
|
132
|
+
className: "text-sm text-gray-500 mt-2",
|
|
133
|
+
children: help
|
|
134
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
135
|
+
className: "text-red-600 text-sm mt-2",
|
|
136
|
+
children: errors.map((error, index) => jsx("div", {
|
|
137
|
+
children: error
|
|
138
|
+
}, index))
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (isRadioField) {
|
|
143
|
+
return jsxs("div", {
|
|
144
|
+
className: classNames,
|
|
145
|
+
style: style,
|
|
146
|
+
children: [React__default.isValidElement(children) ? React__default.cloneElement(children, {
|
|
147
|
+
rawErrors,
|
|
148
|
+
label
|
|
149
|
+
}) : children, description && jsx("p", {
|
|
150
|
+
className: "text-sm text-gray-600 mb-3",
|
|
151
|
+
children: description
|
|
152
|
+
}), help && jsx("p", {
|
|
153
|
+
className: "text-sm text-gray-500 mt-2",
|
|
154
|
+
children: help
|
|
155
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
156
|
+
className: "text-red-600 text-sm mt-2",
|
|
157
|
+
children: errors.map((error, index) => jsx("div", {
|
|
158
|
+
children: error
|
|
159
|
+
}, index))
|
|
160
|
+
})]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (isGroupField && !isStepField) {
|
|
164
|
+
return jsxs("div", {
|
|
165
|
+
className: "bg-white rounded-lg pt-5 pr-5 pb-5 pl-0 mb-4",
|
|
166
|
+
children: [jsx("div", {
|
|
167
|
+
className: "mb-1",
|
|
168
|
+
children: React__default.isValidElement(children) ? React__default.cloneElement(children, {
|
|
169
|
+
rawErrors
|
|
170
|
+
}) : children
|
|
171
|
+
}), help && jsx("p", {
|
|
172
|
+
className: "text-sm text-gray-500 mt-2",
|
|
173
|
+
children: help
|
|
174
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
175
|
+
className: "text-red-600 text-sm mt-2",
|
|
176
|
+
children: errors.map((error, index) => jsx("div", {
|
|
177
|
+
children: error
|
|
178
|
+
}, index))
|
|
179
|
+
})]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const isBooleanCheckbox = schema.type === 'boolean';
|
|
183
|
+
const isArrayCheckbox = schema.type === 'array' && !isDropdownField && !isFileField && !isImageField && !isTextareaField;
|
|
184
|
+
if (isBooleanCheckbox || isArrayCheckbox) {
|
|
185
|
+
return jsxs("div", {
|
|
186
|
+
className: "bg-white rounded-lg mb-4",
|
|
187
|
+
children: [label && jsxs("label", {
|
|
188
|
+
htmlFor: id,
|
|
189
|
+
className: "block text-base font-bold text-gray-800 mb-4",
|
|
190
|
+
children: [label, required && jsx("span", {
|
|
191
|
+
className: "text-red-500 ml-1",
|
|
192
|
+
children: "*"
|
|
193
|
+
})]
|
|
194
|
+
}), React__default.isValidElement(children) ? React__default.cloneElement(children, {
|
|
195
|
+
rawErrors
|
|
196
|
+
}) : children, description && jsx("p", {
|
|
197
|
+
className: "text-sm text-gray-600 mb-3",
|
|
198
|
+
children: description
|
|
199
|
+
}), help && jsx("p", {
|
|
200
|
+
className: "text-sm text-gray-500 mt-2",
|
|
201
|
+
children: help
|
|
202
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
203
|
+
className: "text-red-600 text-sm mt-2",
|
|
204
|
+
children: errors.map((error, index) => jsx("div", {
|
|
205
|
+
children: error
|
|
206
|
+
}, index))
|
|
207
|
+
})]
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return jsxs("div", {
|
|
211
|
+
className: classNames,
|
|
212
|
+
style: style,
|
|
213
|
+
children: [shouldShowLabel && jsxs("label", {
|
|
214
|
+
htmlFor: id,
|
|
215
|
+
className: "block text-base font-bold text-gray-800 mb-4",
|
|
216
|
+
children: [label, required && jsx("span", {
|
|
217
|
+
className: "text-red-500 ml-1",
|
|
218
|
+
children: "*"
|
|
219
|
+
})]
|
|
220
|
+
}), React__default.isValidElement(children) ? React__default.cloneElement(children, {
|
|
221
|
+
rawErrors
|
|
222
|
+
}) : children, !isTextareaField && description && jsx("p", {
|
|
223
|
+
className: "text-sm text-gray-600 mb-3",
|
|
224
|
+
children: description
|
|
225
|
+
}), help && jsx("p", {
|
|
226
|
+
className: "text-sm text-gray-500 mt-2",
|
|
227
|
+
children: help
|
|
228
|
+
}), errors && Array.isArray(errors) && errors.length > 0 && jsx("div", {
|
|
229
|
+
className: "text-red-600 text-sm mt-2",
|
|
230
|
+
children: errors.map((error, index) => jsx("div", {
|
|
231
|
+
children: error
|
|
232
|
+
}, index))
|
|
233
|
+
})]
|
|
234
|
+
});
|
|
235
|
+
};export{PreviewCustomFieldTemplate};//# sourceMappingURL=PreviewCustomFieldTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewCustomFieldTemplate.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|