unifyedx-storybook-new 0.1.72 → 0.1.73
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.
|
@@ -75254,22 +75254,20 @@ function SectionRenderer({ item, data: initialData, updateHandler, validationErr
|
|
|
75254
75254
|
const sectionData = initialData && initialData[item.key] || (item.type === "datatable" ? [] : {});
|
|
75255
75255
|
return sectionData;
|
|
75256
75256
|
});
|
|
75257
|
-
const
|
|
75258
|
-
if (field.optionsFrom) {
|
|
75257
|
+
const getDynamicOptions = (field) => {
|
|
75258
|
+
if (field.optionsFrom && initialData) {
|
|
75259
75259
|
const { config, valueField, labelField } = field.optionsFrom;
|
|
75260
|
-
const configData = initialData[config];
|
|
75260
|
+
const configData = initialData[config] || [];
|
|
75261
75261
|
if (Array.isArray(configData)) {
|
|
75262
75262
|
return configData.map((item2) => ({
|
|
75263
|
-
id: item2[valueField],
|
|
75264
|
-
|
|
75265
|
-
|
|
75266
|
-
label: item2[labelField]
|
|
75263
|
+
id: item2[valueField] || "",
|
|
75264
|
+
value: item2[valueField] || "",
|
|
75265
|
+
label: item2[labelField] || ""
|
|
75267
75266
|
}));
|
|
75268
75267
|
}
|
|
75269
|
-
return [];
|
|
75270
75268
|
}
|
|
75271
75269
|
return field.options || [];
|
|
75272
|
-
}
|
|
75270
|
+
};
|
|
75273
75271
|
const handleFieldChange = React__default.useCallback((fieldKey, value) => {
|
|
75274
75272
|
setData((prevData) => {
|
|
75275
75273
|
const newData = { ...prevData, [fieldKey]: value };
|
|
@@ -75415,7 +75413,23 @@ function SectionRenderer({ item, data: initialData, updateHandler, validationErr
|
|
|
75415
75413
|
name: field.key,
|
|
75416
75414
|
value: data[field.key] || field.default || "",
|
|
75417
75415
|
onChange: (value) => handleFieldChange(field.key, value),
|
|
75418
|
-
options:
|
|
75416
|
+
options: field.options || [],
|
|
75417
|
+
placeholder: field.placeholder || `Select ${field.label}`,
|
|
75418
|
+
required: field.required,
|
|
75419
|
+
disabled: field.disabled ? field.disabled : false,
|
|
75420
|
+
className: `w-full ${validationErrors[section.key]?.[field.key] ? "border-red-500" : ""}`
|
|
75421
|
+
}
|
|
75422
|
+
),
|
|
75423
|
+
validationErrors[section.key]?.[field.key] && /* @__PURE__ */ jsx("div", { style: { color: "#ef4444", fontSize: "12px", marginTop: "2px" }, children: validationErrors[section.key][field.key] })
|
|
75424
|
+
] }),
|
|
75425
|
+
field.fieldtype === "selectDynamic" && /* @__PURE__ */ jsxs("div", { children: [
|
|
75426
|
+
/* @__PURE__ */ jsx(
|
|
75427
|
+
Select,
|
|
75428
|
+
{
|
|
75429
|
+
name: field.key,
|
|
75430
|
+
value: data[field.key] || field.default || "",
|
|
75431
|
+
onChange: (value) => handleFieldChange(field.key, value),
|
|
75432
|
+
options: getDynamicOptions(field),
|
|
75419
75433
|
placeholder: field.placeholder || `Select ${field.label}`,
|
|
75420
75434
|
required: field.required,
|
|
75421
75435
|
disabled: field.disabled ? field.disabled : false,
|
|
@@ -75718,12 +75732,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75718
75732
|
useEffect(() => {
|
|
75719
75733
|
const existingData = initialData && initialData[section.key] || [];
|
|
75720
75734
|
const newData = existingData.length > 0 ? existingData : [{ id: 0 }];
|
|
75721
|
-
setData((prevData) =>
|
|
75722
|
-
if (JSON.stringify(prevData) !== JSON.stringify(newData)) {
|
|
75723
|
-
return newData;
|
|
75724
|
-
}
|
|
75725
|
-
return prevData;
|
|
75726
|
-
});
|
|
75735
|
+
setData((prevData) => JSON.stringify(prevData) !== JSON.stringify(newData) ? newData : prevData);
|
|
75727
75736
|
}, [initialData, section.key]);
|
|
75728
75737
|
const debounce = useCallback((func, delay) => {
|
|
75729
75738
|
let timeoutId;
|
|
@@ -75734,9 +75743,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75734
75743
|
}, []);
|
|
75735
75744
|
const debouncedUpdate = useCallback(
|
|
75736
75745
|
debounce((newData) => {
|
|
75737
|
-
if (updateHandler
|
|
75738
|
-
updateHandler(section.key, newData);
|
|
75739
|
-
}
|
|
75746
|
+
if (updateHandler) updateHandler(section.key, newData);
|
|
75740
75747
|
}, 300),
|
|
75741
75748
|
[section.key, updateHandler, debounce]
|
|
75742
75749
|
);
|
|
@@ -75761,20 +75768,6 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75761
75768
|
const error = getFieldError(field, rowIndex);
|
|
75762
75769
|
return error ? /* @__PURE__ */ jsx("div", { className: "text-red-500 text-xs mt-1", children: error }) : null;
|
|
75763
75770
|
}, [getFieldError]);
|
|
75764
|
-
const getDynamicOptions = useCallback((field) => {
|
|
75765
|
-
if (field.optionsFrom && initialData) {
|
|
75766
|
-
const { config, valueField, labelField } = field.optionsFrom;
|
|
75767
|
-
const configData = initialData[config] || [];
|
|
75768
|
-
if (Array.isArray(configData)) {
|
|
75769
|
-
return configData.map((item2) => ({
|
|
75770
|
-
id: item2[valueField] || "",
|
|
75771
|
-
value: item2[valueField] || "",
|
|
75772
|
-
label: item2[labelField] || ""
|
|
75773
|
-
}));
|
|
75774
|
-
}
|
|
75775
|
-
}
|
|
75776
|
-
return field.options || [];
|
|
75777
|
-
}, [initialData]);
|
|
75778
75771
|
const getFieldRenderer = useCallback((field) => {
|
|
75779
75772
|
switch (field.fieldtype) {
|
|
75780
75773
|
case "text":
|
|
@@ -75821,54 +75814,22 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75821
75814
|
),
|
|
75822
75815
|
renderError(field, rowIndex)
|
|
75823
75816
|
] });
|
|
75824
|
-
case "
|
|
75817
|
+
case "select":
|
|
75818
|
+
case "dropdown":
|
|
75825
75819
|
return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { children: [
|
|
75826
75820
|
/* @__PURE__ */ jsx(
|
|
75827
|
-
|
|
75821
|
+
Select,
|
|
75828
75822
|
{
|
|
75829
|
-
type: "email",
|
|
75830
75823
|
value: props[field.key] || "",
|
|
75831
|
-
onChange: (
|
|
75832
|
-
|
|
75824
|
+
onChange: (value) => updateFieldValue(field, rowIndex, value),
|
|
75825
|
+
options: field.options || [],
|
|
75826
|
+
placeholder: field.placeholder || `Select ${field.label}`,
|
|
75833
75827
|
required: field.required,
|
|
75834
75828
|
className: `w-full ${getFieldError(field, rowIndex) ? "border-red-500" : ""}`
|
|
75835
75829
|
}
|
|
75836
75830
|
),
|
|
75837
75831
|
renderError(field, rowIndex)
|
|
75838
75832
|
] });
|
|
75839
|
-
case "select":
|
|
75840
|
-
case "dropdown":
|
|
75841
|
-
return (props, rowIndex) => {
|
|
75842
|
-
const options = getDynamicOptions(field);
|
|
75843
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
75844
|
-
/* @__PURE__ */ jsx(
|
|
75845
|
-
Select,
|
|
75846
|
-
{
|
|
75847
|
-
value: props[field.key] || "",
|
|
75848
|
-
onChange: (value) => updateFieldValue(field, rowIndex, value),
|
|
75849
|
-
options,
|
|
75850
|
-
placeholder: field.placeholder || `Select ${field.label}`,
|
|
75851
|
-
required: field.required,
|
|
75852
|
-
className: `w-full ${getFieldError(field, rowIndex) ? "border-red-500" : ""}`
|
|
75853
|
-
}
|
|
75854
|
-
),
|
|
75855
|
-
renderError(field, rowIndex)
|
|
75856
|
-
] });
|
|
75857
|
-
};
|
|
75858
|
-
case "multiselect":
|
|
75859
|
-
return (props, rowIndex) => {
|
|
75860
|
-
const currentValue = props[field.key] || [];
|
|
75861
|
-
return /* @__PURE__ */ jsx(
|
|
75862
|
-
MultiSelect$1,
|
|
75863
|
-
{
|
|
75864
|
-
selectedItems: currentValue,
|
|
75865
|
-
onSelectionChange: (selectedItems) => updateFieldValue(field, rowIndex, selectedItems),
|
|
75866
|
-
options: field.options || [],
|
|
75867
|
-
placeholder: field.placeholder || `Select ${field.label}`,
|
|
75868
|
-
className: "w-full"
|
|
75869
|
-
}
|
|
75870
|
-
);
|
|
75871
|
-
};
|
|
75872
75833
|
case "checkbox":
|
|
75873
75834
|
case "boolean":
|
|
75874
75835
|
return (props, rowIndex) => /* @__PURE__ */ jsx(
|
|
@@ -75880,27 +75841,6 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75880
75841
|
className: "w-full"
|
|
75881
75842
|
}
|
|
75882
75843
|
);
|
|
75883
|
-
case "toggle":
|
|
75884
|
-
case "switch":
|
|
75885
|
-
return (props, rowIndex) => /* @__PURE__ */ jsx(
|
|
75886
|
-
ToggleSwitch,
|
|
75887
|
-
{
|
|
75888
|
-
isOn: Boolean(props[field.key]),
|
|
75889
|
-
onToggle: (isOn) => updateFieldValue(field, rowIndex, isOn),
|
|
75890
|
-
label: field.placeholder || field.label,
|
|
75891
|
-
className: "w-full"
|
|
75892
|
-
}
|
|
75893
|
-
);
|
|
75894
|
-
case "date":
|
|
75895
|
-
return (props, rowIndex) => /* @__PURE__ */ jsx(
|
|
75896
|
-
DatePicker$1,
|
|
75897
|
-
{
|
|
75898
|
-
selectedDate: props[field.key] ? new Date(props[field.key]) : null,
|
|
75899
|
-
onDateChange: (date) => updateFieldValue(field, rowIndex, date ? date.toISOString().split("T")[0] : ""),
|
|
75900
|
-
placeholder: field.placeholder || "Select date",
|
|
75901
|
-
className: "w-full"
|
|
75902
|
-
}
|
|
75903
|
-
);
|
|
75904
75844
|
default:
|
|
75905
75845
|
return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { children: [
|
|
75906
75846
|
/* @__PURE__ */ jsx(
|
|
@@ -75916,24 +75856,14 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75916
75856
|
renderError(field, rowIndex)
|
|
75917
75857
|
] });
|
|
75918
75858
|
}
|
|
75919
|
-
}, [updateFieldValue,
|
|
75859
|
+
}, [updateFieldValue, getFieldError, renderError]);
|
|
75920
75860
|
const addBlankRow = useCallback(() => {
|
|
75921
75861
|
isStructuralChangeRef.current = true;
|
|
75922
75862
|
setData((prevData) => {
|
|
75923
75863
|
const blankRow = { id: prevData.length };
|
|
75924
|
-
section.fields.forEach((field) => {
|
|
75925
|
-
if (field.fieldtype === "audience") {
|
|
75926
|
-
blankRow[field.key] = { users: [], groups: [], roles: [] };
|
|
75927
|
-
} else {
|
|
75928
|
-
blankRow[field.key] = "";
|
|
75929
|
-
}
|
|
75930
|
-
});
|
|
75864
|
+
section.fields.forEach((field) => blankRow[field.key] = field.fieldtype === "audience" ? { users: [], groups: [], roles: [] } : "");
|
|
75931
75865
|
const newData = [...prevData, blankRow];
|
|
75932
|
-
setTimeout(() =>
|
|
75933
|
-
if (updateHandler && typeof updateHandler === "function") {
|
|
75934
|
-
updateHandler(section.key, newData);
|
|
75935
|
-
}
|
|
75936
|
-
}, 0);
|
|
75866
|
+
setTimeout(() => updateHandler?.(section.key, newData), 0);
|
|
75937
75867
|
return newData;
|
|
75938
75868
|
});
|
|
75939
75869
|
}, [section.fields, updateHandler, section.key]);
|
|
@@ -75943,11 +75873,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75943
75873
|
if (prevData.length <= 1) return prevData;
|
|
75944
75874
|
const newData = [...prevData];
|
|
75945
75875
|
newData.splice(index, 1);
|
|
75946
|
-
setTimeout(() =>
|
|
75947
|
-
if (updateHandler && typeof updateHandler === "function") {
|
|
75948
|
-
updateHandler(section.key, newData);
|
|
75949
|
-
}
|
|
75950
|
-
}, 0);
|
|
75876
|
+
setTimeout(() => updateHandler?.(section.key, newData), 0);
|
|
75951
75877
|
return newData;
|
|
75952
75878
|
});
|
|
75953
75879
|
}, [updateHandler, section.key]);
|
|
@@ -75966,9 +75892,9 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75966
75892
|
if (draggedIndex === null || draggedIndex === dropIndex) return;
|
|
75967
75893
|
setData((prevData) => {
|
|
75968
75894
|
const newData = [...prevData];
|
|
75969
|
-
const
|
|
75895
|
+
const item2 = newData[draggedIndex];
|
|
75970
75896
|
newData.splice(draggedIndex, 1);
|
|
75971
|
-
newData.splice(dropIndex, 0,
|
|
75897
|
+
newData.splice(dropIndex, 0, item2);
|
|
75972
75898
|
return newData;
|
|
75973
75899
|
});
|
|
75974
75900
|
setDraggedIndex(null);
|
|
@@ -75981,9 +75907,9 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
75981
75907
|
const newData = [...prevData];
|
|
75982
75908
|
if (audienceRowId !== null && audienceFieldName && newData[audienceRowId]) {
|
|
75983
75909
|
const pendingInvites = selectedEntities.pendingInvites || [];
|
|
75984
|
-
const users = pendingInvites.filter((
|
|
75985
|
-
const groups = pendingInvites.filter((
|
|
75986
|
-
const roles = pendingInvites.filter((
|
|
75910
|
+
const users = pendingInvites.filter((i) => i.type === "User");
|
|
75911
|
+
const groups = pendingInvites.filter((i) => i.type === "Group");
|
|
75912
|
+
const roles = pendingInvites.filter((i) => i.type === "Role");
|
|
75987
75913
|
newData[audienceRowId][audienceFieldName] = {
|
|
75988
75914
|
users: [...newData[audienceRowId][audienceFieldName]?.users || [], ...users],
|
|
75989
75915
|
groups: [...newData[audienceRowId][audienceFieldName]?.groups || [], ...groups],
|
|
@@ -76026,28 +75952,16 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
76026
75952
|
onDrop: (e) => handleDrop(e, rowIndex),
|
|
76027
75953
|
onDragEnd: handleDragEnd,
|
|
76028
75954
|
children: [
|
|
76029
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-2
|
|
76030
|
-
section.fields.map((field, fieldIndex) => /* @__PURE__ */ jsx("td", { className: "px-4 py-2
|
|
76031
|
-
/* @__PURE__ */ jsx("td", { className: "px-4 py-2 ", children: /* @__PURE__ */ jsx(
|
|
76032
|
-
"button",
|
|
76033
|
-
{
|
|
76034
|
-
onClick: () => removeRow(rowIndex),
|
|
76035
|
-
className: "text-red-500 hover:text-red-700",
|
|
76036
|
-
title: "Delete row",
|
|
76037
|
-
children: /* @__PURE__ */ jsx(Trash, { size: 16 })
|
|
76038
|
-
}
|
|
76039
|
-
) })
|
|
75955
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-2", children: /* @__PURE__ */ jsx("div", { className: "cursor-move text-gray-400 hover:text-gray-600", children: /* @__PURE__ */ jsx(GripVertical, { size: 16 }) }) }),
|
|
75956
|
+
section.fields.map((field, fieldIndex) => /* @__PURE__ */ jsx("td", { className: "px-4 py-2", children: getFieldRenderer(field)(row, rowIndex) }, `field-${rowIndex}-${fieldIndex}-${field.key}`)),
|
|
75957
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-2", children: /* @__PURE__ */ jsx("button", { onClick: () => removeRow(rowIndex), className: "text-red-500 hover:text-red-700", title: "Delete row", children: /* @__PURE__ */ jsx(Trash, { size: 16 }) }) })
|
|
76040
75958
|
]
|
|
76041
75959
|
},
|
|
76042
75960
|
`row-${rowIndex}-${row.id || "empty"}`
|
|
76043
75961
|
)) })
|
|
76044
75962
|
] }) }),
|
|
76045
75963
|
audienceRowId !== null && (() => {
|
|
76046
|
-
const existingAudienceData = data[audienceRowId]
|
|
76047
|
-
users: data[audienceRowId][audienceFieldName].users || [],
|
|
76048
|
-
groups: data[audienceRowId][audienceFieldName].groups || [],
|
|
76049
|
-
roles: data[audienceRowId][audienceFieldName].roles || []
|
|
76050
|
-
} : { users: [], groups: [], roles: [] };
|
|
75964
|
+
const existingAudienceData = data[audienceRowId]?.[audienceFieldName] || { users: [], groups: [], roles: [] };
|
|
76051
75965
|
return /* @__PURE__ */ jsx(
|
|
76052
75966
|
AddUserGroupsRolesModal,
|
|
76053
75967
|
{
|
|
@@ -76064,9 +75978,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
|
|
|
76064
75978
|
})()
|
|
76065
75979
|
] });
|
|
76066
75980
|
}
|
|
76067
|
-
const DataTableRenderer$1 = React__default.memo(DataTableRenderer, (prevProps, nextProps) =>
|
|
76068
|
-
return prevProps.item === nextProps.item && prevProps.initialData === nextProps.initialData && prevProps.validationErrors === nextProps.validationErrors;
|
|
76069
|
-
});
|
|
75981
|
+
const DataTableRenderer$1 = React__default.memo(DataTableRenderer, (prevProps, nextProps) => prevProps.item === nextProps.item && prevProps.initialData === nextProps.initialData && prevProps.validationErrors === nextProps.validationErrors);
|
|
76070
75982
|
|
|
76071
75983
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
76072
75984
|
|