unifyedx-storybook-new 0.1.67 → 0.1.68

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.
@@ -75754,6 +75754,31 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75754
75754
  const error = getFieldError(field, rowIndex);
75755
75755
  return error ? /* @__PURE__ */ jsx("div", { className: "text-red-500 text-xs mt-1", children: error }) : null;
75756
75756
  }, [getFieldError]);
75757
+ const fieldOptionsCache = React__default.useMemo(() => {
75758
+ const cache = /* @__PURE__ */ new Map();
75759
+ section.fields.forEach((field) => {
75760
+ if (field.optionsFrom && initialData) {
75761
+ const { config, valueField, labelField } = field.optionsFrom;
75762
+ const configData = initialData[config] || [];
75763
+ if (Array.isArray(configData)) {
75764
+ const options = configData.map((item2) => ({
75765
+ id: item2[valueField] || "",
75766
+ value: item2[valueField] || "",
75767
+ label: item2[labelField] || ""
75768
+ }));
75769
+ cache.set(field.key, options);
75770
+ } else {
75771
+ cache.set(field.key, field.options || []);
75772
+ }
75773
+ } else {
75774
+ cache.set(field.key, field.options || []);
75775
+ }
75776
+ });
75777
+ return cache;
75778
+ }, [initialData, section.fields]);
75779
+ const getDynamicOptions = React__default.useCallback((field) => {
75780
+ return fieldOptionsCache.get(field.key) || [];
75781
+ }, [fieldOptionsCache]);
75757
75782
  const getFieldRenderer = React__default.useCallback((field) => {
75758
75783
  switch (field.fieldtype) {
75759
75784
  case "text":
@@ -75848,21 +75873,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75848
75873
  case "select":
75849
75874
  case "dropdown":
75850
75875
  return (props, rowIndex) => {
75851
- let options = [];
75852
- if (field.optionsFrom && initialData) {
75853
- const { config, valueField, labelField } = field.optionsFrom;
75854
- const configData = initialData[config] || [];
75855
- if (Array.isArray(configData)) {
75856
- options = configData.map((item2) => ({
75857
- id: item2[valueField] || "",
75858
- // Add id for backward compatibility
75859
- value: item2[valueField] || "",
75860
- label: item2[labelField] || ""
75861
- }));
75862
- }
75863
- } else {
75864
- options = field.options || [];
75865
- }
75876
+ const options = getDynamicOptions(field);
75866
75877
  return /* @__PURE__ */ jsxs("div", { children: [
75867
75878
  /* @__PURE__ */ jsx(
75868
75879
  Select,
@@ -76063,7 +76074,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
76063
76074
  renderError(field, rowIndex)
76064
76075
  ] });
76065
76076
  }
76066
- }, [updateFieldValue, validationErrors, section.key, initialData]);
76077
+ }, [updateFieldValue, validationErrors, section.key, initialData, getDynamicOptions, getFieldError, renderError]);
76067
76078
  const addBlankRow = useCallback(() => {
76068
76079
  isStructuralChangeRef.current = true;
76069
76080
  setData((prevData) => {