@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.
- 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/ErrorPages/403.d.ts.map +1 -1
- package/lib/components/ErrorPages/403.js +3 -2
- package/lib/components/ErrorPages/403.js.map +1 -1
- package/lib/components/ErrorPages/404.d.ts.map +1 -1
- package/lib/components/ErrorPages/404.js +3 -2
- package/lib/components/ErrorPages/404.js.map +1 -1
- package/lib/components/ErrorPages/500.d.ts.map +1 -1
- package/lib/components/ErrorPages/500.js +3 -2
- package/lib/components/ErrorPages/500.js.map +1 -1
- package/lib/components/ErrorPages/useErrorAsset.d.ts +11 -0
- package/lib/components/ErrorPages/useErrorAsset.d.ts.map +1 -0
- package/lib/components/ErrorPages/useErrorAsset.js +24 -0
- package/lib/components/ErrorPages/useErrorAsset.js.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/PageContainer/PageContainer.d.ts +9 -0
- package/lib/components/PageContainer/PageContainer.d.ts.map +1 -1
- package/lib/components/PageContainer/PageContainer.js +24 -8
- package/lib/components/PageContainer/PageContainer.js.map +1 -1
- package/lib/components/PageContainer/__tests__/PageContainer.test.d.ts +7 -0
- package/lib/components/PageContainer/__tests__/PageContainer.test.d.ts.map +1 -0
- 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/ThemeProvider/ThemeProvider.js +1 -1
- package/lib/components/index.d.ts.map +1 -1
- package/lib/hooks/__tests__/useMediaQuery.test.d.ts +2 -0
- package/lib/hooks/__tests__/useMediaQuery.test.d.ts.map +1 -0
- package/lib/hooks/useMediaQuery.d.ts +9 -2
- package/lib/hooks/useMediaQuery.d.ts.map +1 -1
- package/lib/hooks/useMediaQuery.js +39 -31
- package/lib/hooks/useMediaQuery.js.map +1 -1
- package/lib/hooks/useWindowSize.d.ts +4 -0
- package/lib/hooks/useWindowSize.d.ts.map +1 -1
- package/lib/hooks/useWindowSize.js +13 -19
- package/lib/hooks/useWindowSize.js.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
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import {jsx,jsxs}from'react/jsx-runtime';import {useState,useEffect}from'react';import {useLocation,useNavigate}from'@remix-run/react';import {Spin}from'../Spin/index.js';const
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import {useState,useEffect}from'react';import {useLocation,useNavigate}from'@remix-run/react';import {Spin}from'../Spin/index.js';const trimSlash = path => path.replace(/\/+$/, '');
|
|
2
|
+
/**
|
|
3
|
+
* The tab to highlight for `pathname`: the deepest tab whose path it equals or sits under, so
|
|
4
|
+
* `/billing/plans` owns `/billing/plans/checkout/pro` but not `/billing/plansx`. The bare module path
|
|
5
|
+
* (`/billing`, rendered as its first tab) highlights the first tab. A page outside every listed tab
|
|
6
|
+
* (a page whose own tab is hidden from this viewer) highlights none, instead of passing for the first.
|
|
7
|
+
*/
|
|
8
|
+
function findActiveTabPath(tabList, pathname) {
|
|
9
|
+
const current = trimSlash(pathname);
|
|
10
|
+
const owner = tabList.filter(tab => {
|
|
11
|
+
const tabPath = trimSlash(tab.path);
|
|
12
|
+
return current === tabPath || current.startsWith(`${tabPath}/`);
|
|
13
|
+
}).sort((a, b) => trimSlash(b.path).length - trimSlash(a.path).length)[0];
|
|
14
|
+
if (owner) return owner.path;
|
|
15
|
+
const isModuleRoot = tabList.some(tab => trimSlash(tab.path).startsWith(`${current}/`));
|
|
16
|
+
return isModuleRoot ? tabList[0]?.path : undefined;
|
|
17
|
+
}
|
|
18
|
+
const PageContainer = props => {
|
|
2
19
|
const {
|
|
3
20
|
tabList,
|
|
4
21
|
tabActiveKey,
|
|
@@ -6,16 +23,15 @@ import {jsx,jsxs}from'react/jsx-runtime';import {useState,useEffect}from'react';
|
|
|
6
23
|
tabBarExtraContent,
|
|
7
24
|
loading
|
|
8
25
|
} = props;
|
|
9
|
-
const [activeTabKey, setActiveTabKey] = useState(tabActiveKey);
|
|
10
26
|
const location = useLocation();
|
|
11
27
|
const navigate = useNavigate();
|
|
28
|
+
// Derived from the URL on the first render too, so the server-rendered highlight is the one the
|
|
29
|
+
// browser keeps (it used to start from `tabActiveKey` and move after hydration).
|
|
30
|
+
const activeForLocation = () => tabList && tabList.length > 0 ? findActiveTabPath(tabList, location.pathname) : tabActiveKey;
|
|
31
|
+
const [activeTabKey, setActiveTabKey] = useState(activeForLocation);
|
|
12
32
|
useEffect(() => {
|
|
13
33
|
if (tabList && tabList.length > 0) {
|
|
14
|
-
|
|
15
|
-
// Find a tab where the current path starts with the tab's path (to handle child routes)
|
|
16
|
-
const matchedTab = tabList.find(tab => currentPath.startsWith(tab.path));
|
|
17
|
-
const defaultKey = tabList[0]?.path;
|
|
18
|
-
setActiveTabKey(matchedTab ? matchedTab.path : defaultKey);
|
|
34
|
+
setActiveTabKey(findActiveTabPath(tabList, location.pathname));
|
|
19
35
|
}
|
|
20
36
|
}, [location.pathname, tabList]);
|
|
21
37
|
const handleTabChange = path => {
|
|
@@ -60,4 +76,4 @@ import {jsx,jsxs}from'react/jsx-runtime';import {useState,useEffect}from'react';
|
|
|
60
76
|
children: props.children
|
|
61
77
|
})]
|
|
62
78
|
});
|
|
63
|
-
};export{PageContainer};//# sourceMappingURL=PageContainer.js.map
|
|
79
|
+
};export{PageContainer,findActiveTabPath};//# sourceMappingURL=PageContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageContainer.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PageContainer.js","sources":["../../../src/components/PageContainer/PageContainer.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;AAYG;AACH;;;AAaA,SAAO,kBAAmB,OAAO,EAAC,QAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which tab the PageContainer strip highlights. It follows the URL: the deepest tab that owns the
|
|
3
|
+
* path, the first tab on the bare module path, and none on a page outside every listed tab - a
|
|
4
|
+
* billing page whose own tab is hidden from the viewer used to show the first tab as current.
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=PageContainer.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageContainer.test.d.ts","sourceRoot":"","sources":["../../../../src/components/PageContainer/__tests__/PageContainer.test.tsx"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {jsxs,jsx}from'react/jsx-runtime';import {useState,useCallback,useEffect}from'react';const PreviewAsyncDropdown = props => {
|
|
2
|
+
const {
|
|
3
|
+
id,
|
|
4
|
+
placeholder,
|
|
5
|
+
disabled,
|
|
6
|
+
readonly,
|
|
7
|
+
autofocus,
|
|
8
|
+
options,
|
|
9
|
+
value,
|
|
10
|
+
onChange,
|
|
11
|
+
onBlur,
|
|
12
|
+
onFocus,
|
|
13
|
+
uiSchema,
|
|
14
|
+
multiple = false,
|
|
15
|
+
schema,
|
|
16
|
+
required,
|
|
17
|
+
rawErrors
|
|
18
|
+
} = props;
|
|
19
|
+
console.log('we are here', props);
|
|
20
|
+
const isMultiple = multiple || schema.type === 'array';
|
|
21
|
+
const [loading, setLoading] = useState(false);
|
|
22
|
+
const [dropdownOptions, setDropdownOptions] = useState([]);
|
|
23
|
+
const loadOptions = useCallback(async () => {
|
|
24
|
+
console.log('loadOptions', uiSchema, schema);
|
|
25
|
+
const asyncFuncStr = options?.loadOptionsFunc || schema?.loadOptionsFunc;
|
|
26
|
+
if (!asyncFuncStr) return;
|
|
27
|
+
console.log('asyncFuncStr', asyncFuncStr);
|
|
28
|
+
try {
|
|
29
|
+
setLoading(true);
|
|
30
|
+
const dummyResults = await new Promise(resolve => {
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
resolve([{
|
|
33
|
+
label: 'Async Option 1',
|
|
34
|
+
value: 'async_1'
|
|
35
|
+
}, {
|
|
36
|
+
label: 'Async Option 2',
|
|
37
|
+
value: 'async_2'
|
|
38
|
+
}, {
|
|
39
|
+
label: 'Async Option 3',
|
|
40
|
+
value: 'async_3'
|
|
41
|
+
}, {
|
|
42
|
+
label: 'Dynamic Choice A',
|
|
43
|
+
value: 'dynamic_a'
|
|
44
|
+
}, {
|
|
45
|
+
label: 'Dynamic Choice B',
|
|
46
|
+
value: 'dynamic_b'
|
|
47
|
+
}]);
|
|
48
|
+
}, 1000);
|
|
49
|
+
});
|
|
50
|
+
setDropdownOptions(dummyResults);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('Error loading async dropdown options:', error);
|
|
53
|
+
} finally {
|
|
54
|
+
setLoading(false);
|
|
55
|
+
}
|
|
56
|
+
}, [uiSchema, schema]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
loadOptions();
|
|
59
|
+
}, [loadOptions]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (options?.enumOptions && !options?.loadOptionsFunc) {
|
|
62
|
+
const enumOptions = options.enumOptions.map(option => ({
|
|
63
|
+
label: option.label,
|
|
64
|
+
value: option.value
|
|
65
|
+
}));
|
|
66
|
+
setDropdownOptions(enumOptions);
|
|
67
|
+
}
|
|
68
|
+
}, [options, uiSchema]);
|
|
69
|
+
const handleChange = e => {
|
|
70
|
+
const selectedValue = e.target.value;
|
|
71
|
+
onChange(selectedValue);
|
|
72
|
+
};
|
|
73
|
+
return jsxs("div", {
|
|
74
|
+
className: "space-y-3",
|
|
75
|
+
children: [jsxs("div", {
|
|
76
|
+
className: "block text-base font-semibold text-gray-800 mb-1",
|
|
77
|
+
children: [schema?.title, required && jsx("span", {
|
|
78
|
+
className: "text-red-500 ml-1",
|
|
79
|
+
children: "*"
|
|
80
|
+
})]
|
|
81
|
+
}), jsxs("div", {
|
|
82
|
+
className: "relative",
|
|
83
|
+
children: [jsxs("select", {
|
|
84
|
+
id: id,
|
|
85
|
+
value: value || '',
|
|
86
|
+
disabled: disabled || readonly,
|
|
87
|
+
autoFocus: autofocus,
|
|
88
|
+
onChange: handleChange,
|
|
89
|
+
onBlur: onBlur && (() => onBlur(id, value)),
|
|
90
|
+
onFocus: onFocus && (() => onFocus(id, value)),
|
|
91
|
+
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'}`,
|
|
92
|
+
multiple: isMultiple,
|
|
93
|
+
children: [jsx("option", {
|
|
94
|
+
value: "",
|
|
95
|
+
children: placeholder || 'Select an option...'
|
|
96
|
+
}), dropdownOptions.map((option, index) => jsx("option", {
|
|
97
|
+
value: String(option.value),
|
|
98
|
+
children: String(option.label)
|
|
99
|
+
}, index))]
|
|
100
|
+
}), loading && jsx("div", {
|
|
101
|
+
className: "absolute right-3 top-1/2 transform -translate-y-1/2",
|
|
102
|
+
children: jsx("div", {
|
|
103
|
+
className: "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"
|
|
104
|
+
})
|
|
105
|
+
})]
|
|
106
|
+
}), rawErrors && rawErrors.length > 0 && jsx("p", {
|
|
107
|
+
className: "mt-1 text-sm text-red-500",
|
|
108
|
+
children: rawErrors[0]
|
|
109
|
+
})]
|
|
110
|
+
});
|
|
111
|
+
};export{PreviewAsyncDropdown as default};//# sourceMappingURL=PreviewAsyncDropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreviewAsyncDropdown.js","sources":["../../../src/components/RJSFPreview/PreviewAsyncDropdown.tsx"],"sourcesContent":[null],"names":[],"mappings":"4FAII,MAAA,oBAAmB,GAAA,KAAA,IAAA;AACnB,EAAA,MAAA;AACI,IAAA,EAAA;AACA,IAAA,WAAA;YACF;AACL,IAAA,QAAA;AAOD,IAAA;AA+GA,IAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|