@knovator/pagecreator-admin 0.7.2 → 0.7.4
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/index.cjs +41 -196
- package/index.css +8 -258
- package/index.js +42 -197
- package/package.json +1 -1
- package/src/lib/hooks/usePage.d.ts +1 -1
- package/src/lib/types/context.d.ts +1 -1
package/index.cjs
CHANGED
|
@@ -2806,7 +2806,7 @@ const usePage = ({
|
|
|
2806
2806
|
}
|
|
2807
2807
|
onError(code, 'error', data === null || data === void 0 ? void 0 : data.message);
|
|
2808
2808
|
}, [onError, onLogout]);
|
|
2809
|
-
const getWidgets = React.useCallback((search, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2809
|
+
const getWidgets = React.useCallback((search, collectionItems, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2810
2810
|
try {
|
|
2811
2811
|
setWidgetsLoading(true);
|
|
2812
2812
|
const api = getApiType({
|
|
@@ -2821,6 +2821,7 @@ const usePage = ({
|
|
|
2821
2821
|
url: api.url,
|
|
2822
2822
|
onError: handleError(CALLBACK_CODES.GET_ALL),
|
|
2823
2823
|
data: {
|
|
2824
|
+
collectionItems: collectionItems || [],
|
|
2824
2825
|
search: search || '',
|
|
2825
2826
|
all: true,
|
|
2826
2827
|
isActive: true
|
|
@@ -3685,193 +3686,6 @@ $$7({ global: true, forced: parseInt != $parseInt }, {
|
|
|
3685
3686
|
parseInt: $parseInt
|
|
3686
3687
|
});
|
|
3687
3688
|
|
|
3688
|
-
const Form = /*#__PURE__*/React.forwardRef(({
|
|
3689
|
-
schema,
|
|
3690
|
-
onSubmit,
|
|
3691
|
-
data,
|
|
3692
|
-
isUpdating: _isUpdating = false,
|
|
3693
|
-
enable: _enable = true,
|
|
3694
|
-
updates,
|
|
3695
|
-
watcher
|
|
3696
|
-
}, ref) => {
|
|
3697
|
-
const {
|
|
3698
|
-
register,
|
|
3699
|
-
formState: {
|
|
3700
|
-
errors
|
|
3701
|
-
},
|
|
3702
|
-
handleSubmit,
|
|
3703
|
-
reset,
|
|
3704
|
-
setValue,
|
|
3705
|
-
control,
|
|
3706
|
-
setError,
|
|
3707
|
-
watch
|
|
3708
|
-
} = reactHookForm.useForm();
|
|
3709
|
-
// setting update data in form
|
|
3710
|
-
React.useEffect(() => {
|
|
3711
|
-
if (!isEmpty(data)) {
|
|
3712
|
-
reset(data);
|
|
3713
|
-
}
|
|
3714
|
-
}, [data, reset]);
|
|
3715
|
-
// setting subscriber if watcher is provided
|
|
3716
|
-
React.useEffect(() => {
|
|
3717
|
-
if (watcher) {
|
|
3718
|
-
const subscription = watch((value, {
|
|
3719
|
-
name,
|
|
3720
|
-
type
|
|
3721
|
-
}) => watcher(value, name, type));
|
|
3722
|
-
return () => subscription.unsubscribe();
|
|
3723
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3724
|
-
} else return () => {};
|
|
3725
|
-
}, [watch, watcher]);
|
|
3726
|
-
// setting values if updates are provided
|
|
3727
|
-
React.useEffect(() => {
|
|
3728
|
-
if (updates) {
|
|
3729
|
-
Object.keys(updates).forEach(key => {
|
|
3730
|
-
setValue(key, updates[key]);
|
|
3731
|
-
});
|
|
3732
|
-
}
|
|
3733
|
-
}, [setValue, updates]);
|
|
3734
|
-
const inputRenderer = schema => {
|
|
3735
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3736
|
-
let input;
|
|
3737
|
-
if (typeof schema.show !== 'undefined' && !schema.show) return null;
|
|
3738
|
-
if (schema.type) {
|
|
3739
|
-
switch (schema.type) {
|
|
3740
|
-
case 'ReactSelect':
|
|
3741
|
-
input = /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
|
|
3742
|
-
disabled: !_enable,
|
|
3743
|
-
label: schema.label,
|
|
3744
|
-
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
3745
|
-
onChange: value => {
|
|
3746
|
-
if (value) {
|
|
3747
|
-
setValue(schema.accessor, Array.isArray(value) ? value.map(item => item.value) : value.value);
|
|
3748
|
-
if (schema.onChange) schema.onChange(value);
|
|
3749
|
-
}
|
|
3750
|
-
},
|
|
3751
|
-
selectedOptions: schema.selectedOptions,
|
|
3752
|
-
required: schema.required,
|
|
3753
|
-
isMulti: schema.isMulti,
|
|
3754
|
-
isSearchable: schema.isSearchable,
|
|
3755
|
-
isLoading: schema.isLoading,
|
|
3756
|
-
placeholder: schema.placeholder,
|
|
3757
|
-
wrapperClassName: schema.wrapperClassName,
|
|
3758
|
-
formatOptionLabel: schema.formatOptionLabel,
|
|
3759
|
-
selectKey: schema.selectKey,
|
|
3760
|
-
loadOptions: schema.loadOptions
|
|
3761
|
-
});
|
|
3762
|
-
break;
|
|
3763
|
-
case 'checkbox':
|
|
3764
|
-
input = /*#__PURE__*/React__default["default"].createElement(Input.Checkbox, {
|
|
3765
|
-
error: (_d = (_c = errors[schema.accessor]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
3766
|
-
switchClass: schema.switchClass,
|
|
3767
|
-
label: schema.label,
|
|
3768
|
-
rest: register(schema.accessor, schema.validations || {}),
|
|
3769
|
-
className: "block",
|
|
3770
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable,
|
|
3771
|
-
wrapperClassName: schema.wrapperClassName
|
|
3772
|
-
});
|
|
3773
|
-
break;
|
|
3774
|
-
case 'select':
|
|
3775
|
-
input = /*#__PURE__*/React__default["default"].createElement(reactHookForm.Controller, {
|
|
3776
|
-
control: control,
|
|
3777
|
-
name: schema.accessor,
|
|
3778
|
-
render: ({
|
|
3779
|
-
field
|
|
3780
|
-
}) => {
|
|
3781
|
-
var _a, _b;
|
|
3782
|
-
return /*#__PURE__*/React__default["default"].createElement(Input.Select, {
|
|
3783
|
-
options: schema.options,
|
|
3784
|
-
label: schema.label,
|
|
3785
|
-
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
3786
|
-
onChange: e => field.onChange(e.target.value),
|
|
3787
|
-
value: field.value,
|
|
3788
|
-
className: "w-full",
|
|
3789
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
|
|
3790
|
-
required: schema.required,
|
|
3791
|
-
wrapperClassName: schema.wrapperClassName
|
|
3792
|
-
});
|
|
3793
|
-
}
|
|
3794
|
-
});
|
|
3795
|
-
break;
|
|
3796
|
-
case 'srcset':
|
|
3797
|
-
input = /*#__PURE__*/React__default["default"].createElement(Input.SrcSet, {
|
|
3798
|
-
control: control,
|
|
3799
|
-
register: register,
|
|
3800
|
-
label: schema.label,
|
|
3801
|
-
required: schema.required,
|
|
3802
|
-
errors: errors[schema.accessor],
|
|
3803
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable
|
|
3804
|
-
});
|
|
3805
|
-
break;
|
|
3806
|
-
case 'text':
|
|
3807
|
-
case 'number':
|
|
3808
|
-
case 'url':
|
|
3809
|
-
default:
|
|
3810
|
-
input = /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
3811
|
-
rest: register(schema.accessor, schema.validations || {}),
|
|
3812
|
-
label: schema.label,
|
|
3813
|
-
error: (_f = (_e = errors[schema.accessor]) === null || _e === void 0 ? void 0 : _e.message) === null || _f === void 0 ? void 0 : _f.toString(),
|
|
3814
|
-
type: schema.type,
|
|
3815
|
-
className: "w-full p-2",
|
|
3816
|
-
placeholder: schema.placeholder,
|
|
3817
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
|
|
3818
|
-
required: schema.required,
|
|
3819
|
-
onInput: schema.onInput,
|
|
3820
|
-
wrapperClassName: schema.wrapperClassName
|
|
3821
|
-
});
|
|
3822
|
-
break;
|
|
3823
|
-
}
|
|
3824
|
-
} else if (schema.Input) {
|
|
3825
|
-
input = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3826
|
-
className: "kms_input-wrapper"
|
|
3827
|
-
}, /*#__PURE__*/React__default["default"].createElement("label", {
|
|
3828
|
-
className: "kms_input-label"
|
|
3829
|
-
}, schema.label), /*#__PURE__*/React__default["default"].createElement(reactHookForm.Controller, {
|
|
3830
|
-
control: control,
|
|
3831
|
-
name: schema.accessor,
|
|
3832
|
-
rules: schema.validations,
|
|
3833
|
-
render: ({
|
|
3834
|
-
field
|
|
3835
|
-
}) => {
|
|
3836
|
-
var _a, _b;
|
|
3837
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
3838
|
-
return schema.Input({
|
|
3839
|
-
field,
|
|
3840
|
-
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
3841
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
|
|
3842
|
-
setError: msg => setError.call(null, schema.accessor, {
|
|
3843
|
-
type: 'custom',
|
|
3844
|
-
message: msg
|
|
3845
|
-
})
|
|
3846
|
-
});
|
|
3847
|
-
}
|
|
3848
|
-
}));
|
|
3849
|
-
} else throw new Error(`Please provide Input or type prop to render input Labeled ${schema.label}`);
|
|
3850
|
-
return input;
|
|
3851
|
-
};
|
|
3852
|
-
const onFormSubmit = e => __awaiter(void 0, void 0, void 0, function* () {
|
|
3853
|
-
e.preventDefault();
|
|
3854
|
-
handleSubmit(data => {
|
|
3855
|
-
const formattedData = schema.reduce((values, schemaItem) => {
|
|
3856
|
-
// Do not add field if editing is disabled for it
|
|
3857
|
-
if (_isUpdating && typeof schemaItem.editable !== 'undefined' && !schemaItem.editable) return values;
|
|
3858
|
-
if (schemaItem.type === 'number') {
|
|
3859
|
-
values[schemaItem.accessor] = data[schemaItem.accessor] === '' ? null : parseInt(data[schemaItem.accessor]);
|
|
3860
|
-
} else values[schemaItem.accessor] = data[schemaItem.accessor];
|
|
3861
|
-
return values;
|
|
3862
|
-
}, {});
|
|
3863
|
-
onSubmit(formattedData);
|
|
3864
|
-
})();
|
|
3865
|
-
});
|
|
3866
|
-
return /*#__PURE__*/React__default["default"].createElement("form", {
|
|
3867
|
-
onSubmit: onFormSubmit,
|
|
3868
|
-
ref: ref,
|
|
3869
|
-
className: "khb-form-items"
|
|
3870
|
-
}, schema.map((schema, i) => /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, {
|
|
3871
|
-
key: i
|
|
3872
|
-
}, inputRenderer(schema))));
|
|
3873
|
-
});
|
|
3874
|
-
|
|
3875
3689
|
const SimpleForm = /*#__PURE__*/React.forwardRef(({
|
|
3876
3690
|
schema,
|
|
3877
3691
|
onSubmit,
|
|
@@ -4064,7 +3878,30 @@ const PageForm = ({
|
|
|
4064
3878
|
canAdd,
|
|
4065
3879
|
canUpdate
|
|
4066
3880
|
} = usePageState();
|
|
3881
|
+
const {
|
|
3882
|
+
register,
|
|
3883
|
+
formState: {
|
|
3884
|
+
errors
|
|
3885
|
+
},
|
|
3886
|
+
handleSubmit,
|
|
3887
|
+
reset,
|
|
3888
|
+
setValue,
|
|
3889
|
+
control,
|
|
3890
|
+
setError,
|
|
3891
|
+
getValues
|
|
3892
|
+
} = reactHookForm.useForm();
|
|
4067
3893
|
const callerRef = React.useRef(null);
|
|
3894
|
+
React.useEffect(() => {
|
|
3895
|
+
if (!isEmpty(data)) {
|
|
3896
|
+
reset(data);
|
|
3897
|
+
}
|
|
3898
|
+
}, [data, reset]);
|
|
3899
|
+
React.useEffect(() => {
|
|
3900
|
+
if (formState === 'ADD') {
|
|
3901
|
+
setSelectedWidgets([]);
|
|
3902
|
+
}
|
|
3903
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3904
|
+
}, [formState]);
|
|
4068
3905
|
// Form Utility Functions
|
|
4069
3906
|
function handleCapitalize(event) {
|
|
4070
3907
|
event.target.value = capitalizeFirstLetter(event.target.value);
|
|
@@ -4085,11 +3922,18 @@ const PageForm = ({
|
|
|
4085
3922
|
return event;
|
|
4086
3923
|
}
|
|
4087
3924
|
function loadOptions(value, callback) {
|
|
3925
|
+
let widgetItems = [];
|
|
3926
|
+
if (formState === 'UPDATE') {
|
|
3927
|
+
widgetItems = getValues('widgets');
|
|
3928
|
+
}
|
|
3929
|
+
widgetItems = Array.isArray(widgetItems) ? widgetItems : (data === null || data === void 0 ? void 0 : data.widgets) ? data === null || data === void 0 ? void 0 : data.widgets : [];
|
|
4088
3930
|
if (callerRef.current) clearTimeout(callerRef.current);
|
|
4089
3931
|
callerRef.current = setTimeout(() => {
|
|
4090
|
-
|
|
3932
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3933
|
+
// @ts-ignore
|
|
3934
|
+
getWidgets(value || '', widgetItems, widgetsData => {
|
|
4091
3935
|
if (callback) callback(widgetsData);
|
|
4092
|
-
if (formState === 'UPDATE' && data) setSelectedWidgets(
|
|
3936
|
+
if (formState === 'UPDATE' && data) setSelectedWidgets(widgetItems.map(widgetId => widgetsData.find(widget => widget['value'] === widgetId)).filter(widget => widget));
|
|
4093
3937
|
});
|
|
4094
3938
|
}, 300);
|
|
4095
3939
|
}
|
|
@@ -4147,15 +3991,17 @@ const PageForm = ({
|
|
|
4147
3991
|
if (!canAdd && !canUpdate) return null;
|
|
4148
3992
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
4149
3993
|
className: "khb_form"
|
|
4150
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
3994
|
+
}, /*#__PURE__*/React__default["default"].createElement(SimpleForm, {
|
|
4151
3995
|
schema: pageFormSchema,
|
|
4152
3996
|
onSubmit: onPageFormSubmit,
|
|
4153
3997
|
ref: formRef,
|
|
4154
|
-
data: data,
|
|
4155
3998
|
isUpdating: formState === 'UPDATE',
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
3999
|
+
register: register,
|
|
4000
|
+
errors: errors,
|
|
4001
|
+
handleSubmit: handleSubmit,
|
|
4002
|
+
setValue: setValue,
|
|
4003
|
+
control: control,
|
|
4004
|
+
setError: setError
|
|
4159
4005
|
}), /*#__PURE__*/React__default["default"].createElement(DNDItemsList, {
|
|
4160
4006
|
onDragEnd: onDragEnd,
|
|
4161
4007
|
items: selectedWidgets
|
|
@@ -7218,7 +7064,6 @@ const WidgetForm = ({
|
|
|
7218
7064
|
}, {
|
|
7219
7065
|
label: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.label,
|
|
7220
7066
|
placeholder: `Select ${selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.label}...`,
|
|
7221
|
-
required: true,
|
|
7222
7067
|
accessor: 'collectionItems',
|
|
7223
7068
|
type: 'ReactSelect',
|
|
7224
7069
|
options: collectionData,
|
package/index.css
CHANGED
|
@@ -682,9 +682,6 @@ video {
|
|
|
682
682
|
text-overflow: ellipsis;
|
|
683
683
|
white-space: nowrap;
|
|
684
684
|
}
|
|
685
|
-
.whitespace-nowrap {
|
|
686
|
-
white-space: nowrap;
|
|
687
|
-
}
|
|
688
685
|
.whitespace-pre-wrap {
|
|
689
686
|
white-space: pre-wrap;
|
|
690
687
|
}
|
|
@@ -926,26 +923,26 @@ video {
|
|
|
926
923
|
--tw-text-opacity: 1;
|
|
927
924
|
color: rgb(17 24 39 / var(--tw-text-opacity));
|
|
928
925
|
}
|
|
929
|
-
.text-gray-500 {
|
|
930
|
-
--tw-text-opacity: 1;
|
|
931
|
-
color: rgb(107 114 128 / var(--tw-text-opacity));
|
|
932
|
-
}
|
|
933
926
|
.text-gray-700 {
|
|
934
927
|
--tw-text-opacity: 1;
|
|
935
928
|
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
936
929
|
}
|
|
937
|
-
.text-gray-
|
|
930
|
+
.text-gray-500 {
|
|
938
931
|
--tw-text-opacity: 1;
|
|
939
|
-
color: rgb(
|
|
932
|
+
color: rgb(107 114 128 / var(--tw-text-opacity));
|
|
940
933
|
}
|
|
941
|
-
.text-
|
|
934
|
+
.text-gray-400 {
|
|
942
935
|
--tw-text-opacity: 1;
|
|
943
|
-
color: rgb(
|
|
936
|
+
color: rgb(156 163 175 / var(--tw-text-opacity));
|
|
944
937
|
}
|
|
945
938
|
.text-black {
|
|
946
939
|
--tw-text-opacity: 1;
|
|
947
940
|
color: rgb(0 0 0 / var(--tw-text-opacity));
|
|
948
941
|
}
|
|
942
|
+
.text-red-600 {
|
|
943
|
+
--tw-text-opacity: 1;
|
|
944
|
+
color: rgb(220 38 38 / var(--tw-text-opacity));
|
|
945
|
+
}
|
|
949
946
|
.opacity-100 {
|
|
950
947
|
opacity: 1;
|
|
951
948
|
}
|
|
@@ -1023,23 +1020,6 @@ video {
|
|
|
1023
1020
|
--tw-ring-opacity: 1;
|
|
1024
1021
|
--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity));
|
|
1025
1022
|
}
|
|
1026
|
-
@media (prefers-color-scheme: dark) {
|
|
1027
|
-
|
|
1028
|
-
.khb_btn-primary {
|
|
1029
|
-
--tw-bg-opacity: 1;
|
|
1030
|
-
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
.khb_btn-primary:hover {
|
|
1034
|
-
--tw-bg-opacity: 1;
|
|
1035
|
-
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
.khb_btn-primary:focus {
|
|
1039
|
-
--tw-ring-opacity: 1;
|
|
1040
|
-
--tw-ring-color: rgb(30 64 175 / var(--tw-ring-opacity));
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
1023
|
.khb_btn-primary:disabled {
|
|
1044
1024
|
--tw-bg-opacity: 1;
|
|
1045
1025
|
background-color: rgb(30 64 175 / var(--tw-bg-opacity));
|
|
@@ -1079,23 +1059,6 @@ video {
|
|
|
1079
1059
|
--tw-ring-opacity: 1;
|
|
1080
1060
|
--tw-ring-color: rgb(134 239 172 / var(--tw-ring-opacity));
|
|
1081
1061
|
}
|
|
1082
|
-
@media (prefers-color-scheme: dark) {
|
|
1083
|
-
|
|
1084
|
-
.khb_btn-success {
|
|
1085
|
-
--tw-bg-opacity: 1;
|
|
1086
|
-
background-color: rgb(22 163 74 / var(--tw-bg-opacity));
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
.khb_btn-success:hover {
|
|
1090
|
-
--tw-bg-opacity: 1;
|
|
1091
|
-
background-color: rgb(21 128 61 / var(--tw-bg-opacity));
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
.khb_btn-success:focus {
|
|
1095
|
-
--tw-ring-opacity: 1;
|
|
1096
|
-
--tw-ring-color: rgb(22 101 52 / var(--tw-ring-opacity));
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
1062
|
.khb_btn-danger {
|
|
1100
1063
|
--tw-bg-opacity: 1;
|
|
1101
1064
|
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
|
|
@@ -1110,23 +1073,6 @@ video {
|
|
|
1110
1073
|
--tw-ring-opacity: 1;
|
|
1111
1074
|
--tw-ring-color: rgb(252 165 165 / var(--tw-ring-opacity));
|
|
1112
1075
|
}
|
|
1113
|
-
@media (prefers-color-scheme: dark) {
|
|
1114
|
-
|
|
1115
|
-
.khb_btn-danger {
|
|
1116
|
-
--tw-bg-opacity: 1;
|
|
1117
|
-
background-color: rgb(220 38 38 / var(--tw-bg-opacity));
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
.khb_btn-danger:hover {
|
|
1121
|
-
--tw-bg-opacity: 1;
|
|
1122
|
-
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
.khb_btn-danger:focus {
|
|
1126
|
-
--tw-ring-opacity: 1;
|
|
1127
|
-
--tw-ring-color: rgb(127 29 29 / var(--tw-ring-opacity));
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
1076
|
.khb_btn-danger:disabled {
|
|
1131
1077
|
--tw-bg-opacity: 1;
|
|
1132
1078
|
background-color: rgb(153 27 27 / var(--tw-bg-opacity));
|
|
@@ -1207,13 +1153,6 @@ video {
|
|
|
1207
1153
|
--tw-text-opacity: 1;
|
|
1208
1154
|
color: rgb(107 114 128 / var(--tw-text-opacity));
|
|
1209
1155
|
}
|
|
1210
|
-
@media (prefers-color-scheme: dark) {
|
|
1211
|
-
|
|
1212
|
-
.khb_table {
|
|
1213
|
-
--tw-text-opacity: 1;
|
|
1214
|
-
color: rgb(156 163 175 / var(--tw-text-opacity));
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
1156
|
.khb_thead {
|
|
1218
1157
|
--tw-bg-opacity: 1;
|
|
1219
1158
|
background-color: rgb(249 250 251 / var(--tw-bg-opacity));
|
|
@@ -1223,15 +1162,6 @@ video {
|
|
|
1223
1162
|
--tw-text-opacity: 1;
|
|
1224
1163
|
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
1225
1164
|
}
|
|
1226
|
-
@media (prefers-color-scheme: dark) {
|
|
1227
|
-
|
|
1228
|
-
.khb_thead {
|
|
1229
|
-
--tw-bg-opacity: 1;
|
|
1230
|
-
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
|
|
1231
|
-
--tw-text-opacity: 1;
|
|
1232
|
-
color: rgb(156 163 175 / var(--tw-text-opacity));
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
1165
|
.khb_table-heading {
|
|
1236
1166
|
padding-top: 0.75rem;
|
|
1237
1167
|
padding-bottom: 0.75rem;
|
|
@@ -1247,20 +1177,6 @@ video {
|
|
|
1247
1177
|
--tw-bg-opacity: 1;
|
|
1248
1178
|
background-color: rgb(249 250 251 / var(--tw-bg-opacity));
|
|
1249
1179
|
}
|
|
1250
|
-
@media (prefers-color-scheme: dark) {
|
|
1251
|
-
|
|
1252
|
-
.khb_table-row {
|
|
1253
|
-
--tw-border-opacity: 1;
|
|
1254
|
-
border-color: rgb(55 65 81 / var(--tw-border-opacity));
|
|
1255
|
-
--tw-bg-opacity: 1;
|
|
1256
|
-
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
.khb_table-row:hover {
|
|
1260
|
-
--tw-bg-opacity: 1;
|
|
1261
|
-
background-color: rgb(75 85 99 / var(--tw-bg-opacity));
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
1180
|
.khb_table-row-heading {
|
|
1265
1181
|
white-space: nowrap;
|
|
1266
1182
|
padding-top: 1rem;
|
|
@@ -1271,13 +1187,6 @@ video {
|
|
|
1271
1187
|
--tw-text-opacity: 1;
|
|
1272
1188
|
color: rgb(17 24 39 / var(--tw-text-opacity));
|
|
1273
1189
|
}
|
|
1274
|
-
@media (prefers-color-scheme: dark) {
|
|
1275
|
-
|
|
1276
|
-
.khb_table-row-heading {
|
|
1277
|
-
--tw-text-opacity: 1;
|
|
1278
|
-
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
1190
|
.khb_table-row-data {
|
|
1282
1191
|
padding-top: 0.75rem;
|
|
1283
1192
|
padding-bottom: 0.75rem;
|
|
@@ -1317,23 +1226,6 @@ video {
|
|
|
1317
1226
|
--tw-ring-opacity: 1;
|
|
1318
1227
|
--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity));
|
|
1319
1228
|
}
|
|
1320
|
-
@media (prefers-color-scheme: dark) {
|
|
1321
|
-
|
|
1322
|
-
.khb_actions-update {
|
|
1323
|
-
--tw-bg-opacity: 1;
|
|
1324
|
-
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
.khb_actions-update:hover {
|
|
1328
|
-
--tw-bg-opacity: 1;
|
|
1329
|
-
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
.khb_actions-update:focus {
|
|
1333
|
-
--tw-ring-opacity: 1;
|
|
1334
|
-
--tw-ring-color: rgb(30 64 175 / var(--tw-ring-opacity));
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
1229
|
.khb_actions-update:disabled {
|
|
1338
1230
|
--tw-bg-opacity: 1;
|
|
1339
1231
|
background-color: rgb(30 64 175 / var(--tw-bg-opacity));
|
|
@@ -1376,23 +1268,6 @@ video {
|
|
|
1376
1268
|
--tw-ring-opacity: 1;
|
|
1377
1269
|
--tw-ring-color: rgb(252 165 165 / var(--tw-ring-opacity));
|
|
1378
1270
|
}
|
|
1379
|
-
@media (prefers-color-scheme: dark) {
|
|
1380
|
-
|
|
1381
|
-
.khb_actions-delete {
|
|
1382
|
-
--tw-bg-opacity: 1;
|
|
1383
|
-
background-color: rgb(220 38 38 / var(--tw-bg-opacity));
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
.khb_actions-delete:hover {
|
|
1387
|
-
--tw-bg-opacity: 1;
|
|
1388
|
-
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
.khb_actions-delete:focus {
|
|
1392
|
-
--tw-ring-opacity: 1;
|
|
1393
|
-
--tw-ring-color: rgb(127 29 29 / var(--tw-ring-opacity));
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
1271
|
.khb_actions-delete:disabled {
|
|
1397
1272
|
--tw-bg-opacity: 1;
|
|
1398
1273
|
background-color: rgb(153 27 27 / var(--tw-bg-opacity));
|
|
@@ -1424,37 +1299,16 @@ video {
|
|
|
1424
1299
|
--tw-text-opacity: 1;
|
|
1425
1300
|
color: rgb(107 114 128 / var(--tw-text-opacity));
|
|
1426
1301
|
}
|
|
1427
|
-
@media (prefers-color-scheme: dark) {
|
|
1428
|
-
|
|
1429
|
-
.khb_pagination-total {
|
|
1430
|
-
--tw-text-opacity: 1;
|
|
1431
|
-
color: rgb(156 163 175 / var(--tw-text-opacity));
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
1302
|
.khb_pagination-total-showing {
|
|
1435
1303
|
font-weight: 600;
|
|
1436
1304
|
--tw-text-opacity: 1;
|
|
1437
1305
|
color: rgb(17 24 39 / var(--tw-text-opacity));
|
|
1438
1306
|
}
|
|
1439
|
-
@media (prefers-color-scheme: dark) {
|
|
1440
|
-
|
|
1441
|
-
.khb_pagination-total-showing {
|
|
1442
|
-
--tw-text-opacity: 1;
|
|
1443
|
-
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
1307
|
.khb_pagination-total-items {
|
|
1447
1308
|
font-weight: 600;
|
|
1448
1309
|
--tw-text-opacity: 1;
|
|
1449
1310
|
color: rgb(17 24 39 / var(--tw-text-opacity));
|
|
1450
1311
|
}
|
|
1451
|
-
@media (prefers-color-scheme: dark) {
|
|
1452
|
-
|
|
1453
|
-
.khb_pagination-total-items {
|
|
1454
|
-
--tw-text-opacity: 1;
|
|
1455
|
-
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
1312
|
.khb_pagination-actions {
|
|
1459
1313
|
display: inline-flex;
|
|
1460
1314
|
align-items: center;
|
|
@@ -1523,13 +1377,6 @@ video {
|
|
|
1523
1377
|
--tw-text-opacity: 1;
|
|
1524
1378
|
color: rgb(220 38 38 / var(--tw-text-opacity));
|
|
1525
1379
|
}
|
|
1526
|
-
@media (prefers-color-scheme: dark) {
|
|
1527
|
-
|
|
1528
|
-
.khb_input-error {
|
|
1529
|
-
--tw-text-opacity: 1;
|
|
1530
|
-
color: rgb(239 68 68 / var(--tw-text-opacity));
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
1380
|
.khb_input-xs {
|
|
1534
1381
|
padding: 0.375rem;
|
|
1535
1382
|
font-size: 0.875rem;
|
|
@@ -1554,13 +1401,6 @@ video {
|
|
|
1554
1401
|
--tw-text-opacity: 1;
|
|
1555
1402
|
color: rgb(17 24 39 / var(--tw-text-opacity));
|
|
1556
1403
|
}
|
|
1557
|
-
@media (prefers-color-scheme: dark) {
|
|
1558
|
-
|
|
1559
|
-
.khb_input-label {
|
|
1560
|
-
--tw-text-opacity: 1;
|
|
1561
|
-
color: rgb(209 213 219 / var(--tw-text-opacity));
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
1404
|
.khb_input-label-required {
|
|
1565
1405
|
--tw-text-opacity: 1;
|
|
1566
1406
|
color: rgb(220 38 38 / var(--tw-text-opacity));
|
|
@@ -2273,23 +2113,6 @@ input:checked + .slider:before {
|
|
|
2273
2113
|
--tw-ring-opacity: 1;
|
|
2274
2114
|
--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity));
|
|
2275
2115
|
}
|
|
2276
|
-
@media (prefers-color-scheme: dark) {
|
|
2277
|
-
|
|
2278
|
-
.khb_tabs-add {
|
|
2279
|
-
--tw-bg-opacity: 1;
|
|
2280
|
-
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
.khb_tabs-add:hover {
|
|
2284
|
-
--tw-bg-opacity: 1;
|
|
2285
|
-
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2288
|
-
.khb_tabs-add:focus {
|
|
2289
|
-
--tw-ring-opacity: 1;
|
|
2290
|
-
--tw-ring-color: rgb(30 64 175 / var(--tw-ring-opacity));
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
2116
|
.khb_tabs-add:disabled {
|
|
2294
2117
|
--tw-bg-opacity: 1;
|
|
2295
2118
|
background-color: rgb(30 64 175 / var(--tw-bg-opacity));
|
|
@@ -2366,10 +2189,6 @@ input:checked + .slider:before {
|
|
|
2366
2189
|
--tw-bg-opacity: 1;
|
|
2367
2190
|
background-color: rgb(153 27 27 / var(--tw-bg-opacity));
|
|
2368
2191
|
}
|
|
2369
|
-
.hover\:bg-gray-50:hover {
|
|
2370
|
-
--tw-bg-opacity: 1;
|
|
2371
|
-
background-color: rgb(249 250 251 / var(--tw-bg-opacity));
|
|
2372
|
-
}
|
|
2373
2192
|
.hover\:bg-gray-200:hover {
|
|
2374
2193
|
--tw-bg-opacity: 1;
|
|
2375
2194
|
background-color: rgb(229 231 235 / var(--tw-bg-opacity));
|
|
@@ -2396,79 +2215,10 @@ input:checked + .slider:before {
|
|
|
2396
2215
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
2397
2216
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
2398
2217
|
}
|
|
2399
|
-
.focus\:ring-blue-300:focus {
|
|
2400
|
-
--tw-ring-opacity: 1;
|
|
2401
|
-
--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity));
|
|
2402
|
-
}
|
|
2403
|
-
.focus\:ring-green-300:focus {
|
|
2404
|
-
--tw-ring-opacity: 1;
|
|
2405
|
-
--tw-ring-color: rgb(134 239 172 / var(--tw-ring-opacity));
|
|
2406
|
-
}
|
|
2407
|
-
.focus\:ring-red-300:focus {
|
|
2408
|
-
--tw-ring-opacity: 1;
|
|
2409
|
-
--tw-ring-color: rgb(252 165 165 / var(--tw-ring-opacity));
|
|
2410
|
-
}
|
|
2411
2218
|
.focus\:ring-blue-500:focus {
|
|
2412
2219
|
--tw-ring-opacity: 1;
|
|
2413
2220
|
--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity));
|
|
2414
2221
|
}
|
|
2415
|
-
@media (prefers-color-scheme: dark) {
|
|
2416
|
-
|
|
2417
|
-
.dark\:border-gray-700 {
|
|
2418
|
-
--tw-border-opacity: 1;
|
|
2419
|
-
border-color: rgb(55 65 81 / var(--tw-border-opacity));
|
|
2420
|
-
}
|
|
2421
|
-
|
|
2422
|
-
.dark\:bg-blue-600 {
|
|
2423
|
-
--tw-bg-opacity: 1;
|
|
2424
|
-
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
|
|
2425
|
-
}
|
|
2426
|
-
|
|
2427
|
-
.dark\:bg-green-600 {
|
|
2428
|
-
--tw-bg-opacity: 1;
|
|
2429
|
-
background-color: rgb(22 163 74 / var(--tw-bg-opacity));
|
|
2430
|
-
}
|
|
2431
|
-
|
|
2432
|
-
.dark\:bg-red-600 {
|
|
2433
|
-
--tw-bg-opacity: 1;
|
|
2434
|
-
background-color: rgb(220 38 38 / var(--tw-bg-opacity));
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
.dark\:bg-gray-700 {
|
|
2438
|
-
--tw-bg-opacity: 1;
|
|
2439
|
-
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
.dark\:bg-gray-800 {
|
|
2443
|
-
--tw-bg-opacity: 1;
|
|
2444
|
-
background-color: rgb(31 41 55 / var(--tw-bg-opacity));
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
.dark\:hover\:bg-blue-700:hover {
|
|
2448
|
-
--tw-bg-opacity: 1;
|
|
2449
|
-
background-color: rgb(29 78 216 / var(--tw-bg-opacity));
|
|
2450
|
-
}
|
|
2451
|
-
|
|
2452
|
-
.dark\:hover\:bg-green-700:hover {
|
|
2453
|
-
--tw-bg-opacity: 1;
|
|
2454
|
-
background-color: rgb(21 128 61 / var(--tw-bg-opacity));
|
|
2455
|
-
}
|
|
2456
|
-
|
|
2457
|
-
.dark\:hover\:bg-red-700:hover {
|
|
2458
|
-
--tw-bg-opacity: 1;
|
|
2459
|
-
background-color: rgb(185 28 28 / var(--tw-bg-opacity));
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
|
-
.dark\:focus\:ring-green-800:focus {
|
|
2463
|
-
--tw-ring-opacity: 1;
|
|
2464
|
-
--tw-ring-color: rgb(22 101 52 / var(--tw-ring-opacity));
|
|
2465
|
-
}
|
|
2466
|
-
|
|
2467
|
-
.dark\:focus\:ring-red-900:focus {
|
|
2468
|
-
--tw-ring-opacity: 1;
|
|
2469
|
-
--tw-ring-color: rgb(127 29 29 / var(--tw-ring-opacity));
|
|
2470
|
-
}
|
|
2471
|
-
}
|
|
2472
2222
|
@media (min-width: 640px) {
|
|
2473
2223
|
|
|
2474
2224
|
.sm\:my-8 {
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { createContext, useContext, useRef, useState, useCallback, useEff
|
|
|
2
2
|
import fetchUrl, { setAPIConfig } from '@knovator/api';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import ReactSelect from 'react-select/async';
|
|
5
|
-
import { useFieldArray,
|
|
5
|
+
import { useFieldArray, Controller, useForm } from 'react-hook-form';
|
|
6
6
|
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
7
7
|
import CSSTransition from 'react-transition-group/CSSTransition';
|
|
8
8
|
import { useDropzone } from 'react-dropzone';
|
|
@@ -2794,7 +2794,7 @@ const usePage = ({
|
|
|
2794
2794
|
}
|
|
2795
2795
|
onError(code, 'error', data === null || data === void 0 ? void 0 : data.message);
|
|
2796
2796
|
}, [onError, onLogout]);
|
|
2797
|
-
const getWidgets = useCallback((search, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2797
|
+
const getWidgets = useCallback((search, collectionItems, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2798
2798
|
try {
|
|
2799
2799
|
setWidgetsLoading(true);
|
|
2800
2800
|
const api = getApiType({
|
|
@@ -2809,6 +2809,7 @@ const usePage = ({
|
|
|
2809
2809
|
url: api.url,
|
|
2810
2810
|
onError: handleError(CALLBACK_CODES.GET_ALL),
|
|
2811
2811
|
data: {
|
|
2812
|
+
collectionItems: collectionItems || [],
|
|
2812
2813
|
search: search || '',
|
|
2813
2814
|
all: true,
|
|
2814
2815
|
isActive: true
|
|
@@ -3673,193 +3674,6 @@ $$7({ global: true, forced: parseInt != $parseInt }, {
|
|
|
3673
3674
|
parseInt: $parseInt
|
|
3674
3675
|
});
|
|
3675
3676
|
|
|
3676
|
-
const Form = /*#__PURE__*/forwardRef(({
|
|
3677
|
-
schema,
|
|
3678
|
-
onSubmit,
|
|
3679
|
-
data,
|
|
3680
|
-
isUpdating: _isUpdating = false,
|
|
3681
|
-
enable: _enable = true,
|
|
3682
|
-
updates,
|
|
3683
|
-
watcher
|
|
3684
|
-
}, ref) => {
|
|
3685
|
-
const {
|
|
3686
|
-
register,
|
|
3687
|
-
formState: {
|
|
3688
|
-
errors
|
|
3689
|
-
},
|
|
3690
|
-
handleSubmit,
|
|
3691
|
-
reset,
|
|
3692
|
-
setValue,
|
|
3693
|
-
control,
|
|
3694
|
-
setError,
|
|
3695
|
-
watch
|
|
3696
|
-
} = useForm();
|
|
3697
|
-
// setting update data in form
|
|
3698
|
-
useEffect(() => {
|
|
3699
|
-
if (!isEmpty(data)) {
|
|
3700
|
-
reset(data);
|
|
3701
|
-
}
|
|
3702
|
-
}, [data, reset]);
|
|
3703
|
-
// setting subscriber if watcher is provided
|
|
3704
|
-
useEffect(() => {
|
|
3705
|
-
if (watcher) {
|
|
3706
|
-
const subscription = watch((value, {
|
|
3707
|
-
name,
|
|
3708
|
-
type
|
|
3709
|
-
}) => watcher(value, name, type));
|
|
3710
|
-
return () => subscription.unsubscribe();
|
|
3711
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
3712
|
-
} else return () => {};
|
|
3713
|
-
}, [watch, watcher]);
|
|
3714
|
-
// setting values if updates are provided
|
|
3715
|
-
useEffect(() => {
|
|
3716
|
-
if (updates) {
|
|
3717
|
-
Object.keys(updates).forEach(key => {
|
|
3718
|
-
setValue(key, updates[key]);
|
|
3719
|
-
});
|
|
3720
|
-
}
|
|
3721
|
-
}, [setValue, updates]);
|
|
3722
|
-
const inputRenderer = schema => {
|
|
3723
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3724
|
-
let input;
|
|
3725
|
-
if (typeof schema.show !== 'undefined' && !schema.show) return null;
|
|
3726
|
-
if (schema.type) {
|
|
3727
|
-
switch (schema.type) {
|
|
3728
|
-
case 'ReactSelect':
|
|
3729
|
-
input = /*#__PURE__*/React.createElement(CustomReactSelect, {
|
|
3730
|
-
disabled: !_enable,
|
|
3731
|
-
label: schema.label,
|
|
3732
|
-
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
3733
|
-
onChange: value => {
|
|
3734
|
-
if (value) {
|
|
3735
|
-
setValue(schema.accessor, Array.isArray(value) ? value.map(item => item.value) : value.value);
|
|
3736
|
-
if (schema.onChange) schema.onChange(value);
|
|
3737
|
-
}
|
|
3738
|
-
},
|
|
3739
|
-
selectedOptions: schema.selectedOptions,
|
|
3740
|
-
required: schema.required,
|
|
3741
|
-
isMulti: schema.isMulti,
|
|
3742
|
-
isSearchable: schema.isSearchable,
|
|
3743
|
-
isLoading: schema.isLoading,
|
|
3744
|
-
placeholder: schema.placeholder,
|
|
3745
|
-
wrapperClassName: schema.wrapperClassName,
|
|
3746
|
-
formatOptionLabel: schema.formatOptionLabel,
|
|
3747
|
-
selectKey: schema.selectKey,
|
|
3748
|
-
loadOptions: schema.loadOptions
|
|
3749
|
-
});
|
|
3750
|
-
break;
|
|
3751
|
-
case 'checkbox':
|
|
3752
|
-
input = /*#__PURE__*/React.createElement(Input.Checkbox, {
|
|
3753
|
-
error: (_d = (_c = errors[schema.accessor]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
3754
|
-
switchClass: schema.switchClass,
|
|
3755
|
-
label: schema.label,
|
|
3756
|
-
rest: register(schema.accessor, schema.validations || {}),
|
|
3757
|
-
className: "block",
|
|
3758
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable,
|
|
3759
|
-
wrapperClassName: schema.wrapperClassName
|
|
3760
|
-
});
|
|
3761
|
-
break;
|
|
3762
|
-
case 'select':
|
|
3763
|
-
input = /*#__PURE__*/React.createElement(Controller, {
|
|
3764
|
-
control: control,
|
|
3765
|
-
name: schema.accessor,
|
|
3766
|
-
render: ({
|
|
3767
|
-
field
|
|
3768
|
-
}) => {
|
|
3769
|
-
var _a, _b;
|
|
3770
|
-
return /*#__PURE__*/React.createElement(Input.Select, {
|
|
3771
|
-
options: schema.options,
|
|
3772
|
-
label: schema.label,
|
|
3773
|
-
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
3774
|
-
onChange: e => field.onChange(e.target.value),
|
|
3775
|
-
value: field.value,
|
|
3776
|
-
className: "w-full",
|
|
3777
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
|
|
3778
|
-
required: schema.required,
|
|
3779
|
-
wrapperClassName: schema.wrapperClassName
|
|
3780
|
-
});
|
|
3781
|
-
}
|
|
3782
|
-
});
|
|
3783
|
-
break;
|
|
3784
|
-
case 'srcset':
|
|
3785
|
-
input = /*#__PURE__*/React.createElement(Input.SrcSet, {
|
|
3786
|
-
control: control,
|
|
3787
|
-
register: register,
|
|
3788
|
-
label: schema.label,
|
|
3789
|
-
required: schema.required,
|
|
3790
|
-
errors: errors[schema.accessor],
|
|
3791
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable
|
|
3792
|
-
});
|
|
3793
|
-
break;
|
|
3794
|
-
case 'text':
|
|
3795
|
-
case 'number':
|
|
3796
|
-
case 'url':
|
|
3797
|
-
default:
|
|
3798
|
-
input = /*#__PURE__*/React.createElement(Input, {
|
|
3799
|
-
rest: register(schema.accessor, schema.validations || {}),
|
|
3800
|
-
label: schema.label,
|
|
3801
|
-
error: (_f = (_e = errors[schema.accessor]) === null || _e === void 0 ? void 0 : _e.message) === null || _f === void 0 ? void 0 : _f.toString(),
|
|
3802
|
-
type: schema.type,
|
|
3803
|
-
className: "w-full p-2",
|
|
3804
|
-
placeholder: schema.placeholder,
|
|
3805
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
|
|
3806
|
-
required: schema.required,
|
|
3807
|
-
onInput: schema.onInput,
|
|
3808
|
-
wrapperClassName: schema.wrapperClassName
|
|
3809
|
-
});
|
|
3810
|
-
break;
|
|
3811
|
-
}
|
|
3812
|
-
} else if (schema.Input) {
|
|
3813
|
-
input = /*#__PURE__*/React.createElement("div", {
|
|
3814
|
-
className: "kms_input-wrapper"
|
|
3815
|
-
}, /*#__PURE__*/React.createElement("label", {
|
|
3816
|
-
className: "kms_input-label"
|
|
3817
|
-
}, schema.label), /*#__PURE__*/React.createElement(Controller, {
|
|
3818
|
-
control: control,
|
|
3819
|
-
name: schema.accessor,
|
|
3820
|
-
rules: schema.validations,
|
|
3821
|
-
render: ({
|
|
3822
|
-
field
|
|
3823
|
-
}) => {
|
|
3824
|
-
var _a, _b;
|
|
3825
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
3826
|
-
return schema.Input({
|
|
3827
|
-
field,
|
|
3828
|
-
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
3829
|
-
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
|
|
3830
|
-
setError: msg => setError.call(null, schema.accessor, {
|
|
3831
|
-
type: 'custom',
|
|
3832
|
-
message: msg
|
|
3833
|
-
})
|
|
3834
|
-
});
|
|
3835
|
-
}
|
|
3836
|
-
}));
|
|
3837
|
-
} else throw new Error(`Please provide Input or type prop to render input Labeled ${schema.label}`);
|
|
3838
|
-
return input;
|
|
3839
|
-
};
|
|
3840
|
-
const onFormSubmit = e => __awaiter(void 0, void 0, void 0, function* () {
|
|
3841
|
-
e.preventDefault();
|
|
3842
|
-
handleSubmit(data => {
|
|
3843
|
-
const formattedData = schema.reduce((values, schemaItem) => {
|
|
3844
|
-
// Do not add field if editing is disabled for it
|
|
3845
|
-
if (_isUpdating && typeof schemaItem.editable !== 'undefined' && !schemaItem.editable) return values;
|
|
3846
|
-
if (schemaItem.type === 'number') {
|
|
3847
|
-
values[schemaItem.accessor] = data[schemaItem.accessor] === '' ? null : parseInt(data[schemaItem.accessor]);
|
|
3848
|
-
} else values[schemaItem.accessor] = data[schemaItem.accessor];
|
|
3849
|
-
return values;
|
|
3850
|
-
}, {});
|
|
3851
|
-
onSubmit(formattedData);
|
|
3852
|
-
})();
|
|
3853
|
-
});
|
|
3854
|
-
return /*#__PURE__*/React.createElement("form", {
|
|
3855
|
-
onSubmit: onFormSubmit,
|
|
3856
|
-
ref: ref,
|
|
3857
|
-
className: "khb-form-items"
|
|
3858
|
-
}, schema.map((schema, i) => /*#__PURE__*/React.createElement(React.Fragment, {
|
|
3859
|
-
key: i
|
|
3860
|
-
}, inputRenderer(schema))));
|
|
3861
|
-
});
|
|
3862
|
-
|
|
3863
3677
|
const SimpleForm = /*#__PURE__*/forwardRef(({
|
|
3864
3678
|
schema,
|
|
3865
3679
|
onSubmit,
|
|
@@ -4052,7 +3866,30 @@ const PageForm = ({
|
|
|
4052
3866
|
canAdd,
|
|
4053
3867
|
canUpdate
|
|
4054
3868
|
} = usePageState();
|
|
3869
|
+
const {
|
|
3870
|
+
register,
|
|
3871
|
+
formState: {
|
|
3872
|
+
errors
|
|
3873
|
+
},
|
|
3874
|
+
handleSubmit,
|
|
3875
|
+
reset,
|
|
3876
|
+
setValue,
|
|
3877
|
+
control,
|
|
3878
|
+
setError,
|
|
3879
|
+
getValues
|
|
3880
|
+
} = useForm();
|
|
4055
3881
|
const callerRef = useRef(null);
|
|
3882
|
+
useEffect(() => {
|
|
3883
|
+
if (!isEmpty(data)) {
|
|
3884
|
+
reset(data);
|
|
3885
|
+
}
|
|
3886
|
+
}, [data, reset]);
|
|
3887
|
+
useEffect(() => {
|
|
3888
|
+
if (formState === 'ADD') {
|
|
3889
|
+
setSelectedWidgets([]);
|
|
3890
|
+
}
|
|
3891
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3892
|
+
}, [formState]);
|
|
4056
3893
|
// Form Utility Functions
|
|
4057
3894
|
function handleCapitalize(event) {
|
|
4058
3895
|
event.target.value = capitalizeFirstLetter(event.target.value);
|
|
@@ -4073,11 +3910,18 @@ const PageForm = ({
|
|
|
4073
3910
|
return event;
|
|
4074
3911
|
}
|
|
4075
3912
|
function loadOptions(value, callback) {
|
|
3913
|
+
let widgetItems = [];
|
|
3914
|
+
if (formState === 'UPDATE') {
|
|
3915
|
+
widgetItems = getValues('widgets');
|
|
3916
|
+
}
|
|
3917
|
+
widgetItems = Array.isArray(widgetItems) ? widgetItems : (data === null || data === void 0 ? void 0 : data.widgets) ? data === null || data === void 0 ? void 0 : data.widgets : [];
|
|
4076
3918
|
if (callerRef.current) clearTimeout(callerRef.current);
|
|
4077
3919
|
callerRef.current = setTimeout(() => {
|
|
4078
|
-
|
|
3920
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3921
|
+
// @ts-ignore
|
|
3922
|
+
getWidgets(value || '', widgetItems, widgetsData => {
|
|
4079
3923
|
if (callback) callback(widgetsData);
|
|
4080
|
-
if (formState === 'UPDATE' && data) setSelectedWidgets(
|
|
3924
|
+
if (formState === 'UPDATE' && data) setSelectedWidgets(widgetItems.map(widgetId => widgetsData.find(widget => widget['value'] === widgetId)).filter(widget => widget));
|
|
4081
3925
|
});
|
|
4082
3926
|
}, 300);
|
|
4083
3927
|
}
|
|
@@ -4135,15 +3979,17 @@ const PageForm = ({
|
|
|
4135
3979
|
if (!canAdd && !canUpdate) return null;
|
|
4136
3980
|
return /*#__PURE__*/React.createElement("div", {
|
|
4137
3981
|
className: "khb_form"
|
|
4138
|
-
}, /*#__PURE__*/React.createElement(
|
|
3982
|
+
}, /*#__PURE__*/React.createElement(SimpleForm, {
|
|
4139
3983
|
schema: pageFormSchema,
|
|
4140
3984
|
onSubmit: onPageFormSubmit,
|
|
4141
3985
|
ref: formRef,
|
|
4142
|
-
data: data,
|
|
4143
3986
|
isUpdating: formState === 'UPDATE',
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
3987
|
+
register: register,
|
|
3988
|
+
errors: errors,
|
|
3989
|
+
handleSubmit: handleSubmit,
|
|
3990
|
+
setValue: setValue,
|
|
3991
|
+
control: control,
|
|
3992
|
+
setError: setError
|
|
4147
3993
|
}), /*#__PURE__*/React.createElement(DNDItemsList, {
|
|
4148
3994
|
onDragEnd: onDragEnd,
|
|
4149
3995
|
items: selectedWidgets
|
|
@@ -7206,7 +7052,6 @@ const WidgetForm = ({
|
|
|
7206
7052
|
}, {
|
|
7207
7053
|
label: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.label,
|
|
7208
7054
|
placeholder: `Select ${selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.label}...`,
|
|
7209
|
-
required: true,
|
|
7210
7055
|
accessor: 'collectionItems',
|
|
7211
7056
|
type: 'ReactSelect',
|
|
7212
7057
|
options: collectionData,
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ declare const usePage: ({ routes, defaultLimit, canList, preConfirmDelete, }: Us
|
|
|
24
24
|
widgets: ObjectType[];
|
|
25
25
|
itemData: any;
|
|
26
26
|
formState: FormActionTypes | undefined;
|
|
27
|
-
getWidgets: (search?: string, callback?: ((data: any) => void) | undefined) => Promise<void>;
|
|
27
|
+
getWidgets: (search?: string, collectionItems?: string[], callback?: ((data: any) => void) | undefined) => Promise<void>;
|
|
28
28
|
onCloseForm: () => void;
|
|
29
29
|
widgetsLoading: boolean;
|
|
30
30
|
selectedWidgets: {
|
|
@@ -70,7 +70,7 @@ export interface PageContextType {
|
|
|
70
70
|
list: any[];
|
|
71
71
|
searchText: string;
|
|
72
72
|
changeSearch: (val: string) => void;
|
|
73
|
-
getWidgets: (search
|
|
73
|
+
getWidgets: (search: string, collectionItems: string[], callback?: (data: any) => void) => void;
|
|
74
74
|
formState: FormActionTypes | undefined;
|
|
75
75
|
closeForm: () => void;
|
|
76
76
|
onPageFormSubmit: (data: any) => void;
|