unifyedx-storybook-new 0.1.61 → 0.1.63

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.
@@ -75817,25 +75817,19 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75817
75817
  const [section, setSection] = useState(item);
75818
75818
  const [audienceRowId, setAudienceRowId] = useState(null);
75819
75819
  const [audienceFieldName, setAudienceFieldName] = useState(null);
75820
- console.log(`[DataTableRenderer] ${section.key} - Received props:`, { item, initialData });
75821
75820
  const [data, setData] = useState(() => {
75822
75821
  const existingData = initialData && initialData[section.key] || [];
75823
- const result = existingData.length > 0 ? existingData : [{ id: 0 }];
75824
- console.log(`[DataTableRenderer] ${section.key} - Initial data:`, result);
75825
- return result;
75822
+ return existingData.length > 0 ? existingData : [{ id: 0 }];
75826
75823
  });
75827
- const prevInitialDataRef = useRef(initialData);
75828
75824
  useEffect(() => {
75829
- console.log(`[DataTableRenderer] ${section.key} - Checking for initialData changes`);
75830
- console.log(`[DataTableRenderer] ${section.key} - Previous:`, prevInitialDataRef.current);
75831
- console.log(`[DataTableRenderer] ${section.key} - Current:`, initialData);
75832
- if (prevInitialDataRef.current !== initialData) {
75833
- prevInitialDataRef.current = initialData;
75834
- const existingData = initialData && initialData[section.key] || [];
75835
- const newData = existingData.length > 0 ? existingData : [{ id: 0 }];
75836
- console.log(`[DataTableRenderer] ${section.key} - Setting new data:`, newData);
75837
- setData(newData);
75838
- }
75825
+ const existingData = initialData && initialData[section.key] || [];
75826
+ const newData = existingData.length > 0 ? existingData : [{ id: 0 }];
75827
+ console.log(`[DataTableRenderer] ${section.key} - Data update:`, {
75828
+ existingData,
75829
+ newData,
75830
+ initialData
75831
+ });
75832
+ setData(newData);
75839
75833
  }, [initialData, section.key]);
75840
75834
  const prevDataRef = useRef(data);
75841
75835
  const updateTimeoutRef = useRef(null);
@@ -75857,22 +75851,21 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75857
75851
  }
75858
75852
  };
75859
75853
  }, []);
75860
- const getFieldRenderer = (field) => {
75861
- const updateFieldValue = (rowIndex, value) => {
75862
- console.log(`[DataTableRenderer] updateFieldValue called with:`, { rowIndex, value, type: typeof value });
75863
- setData((prevData) => {
75864
- const newData = [...prevData];
75865
- newData[rowIndex][field.key] = value;
75866
- return newData;
75867
- });
75868
- };
75869
- const getFieldError = (rowIndex) => {
75854
+ const updateFieldValue = React__default.useCallback((field, rowIndex, value) => {
75855
+ setData((prevData) => {
75856
+ const newData = [...prevData];
75857
+ newData[rowIndex][field.key] = value;
75858
+ return newData;
75859
+ });
75860
+ }, []);
75861
+ const getFieldRenderer = React__default.useCallback((field) => {
75862
+ const getFieldError = React__default.useCallback((rowIndex) => {
75870
75863
  return validationErrors[section.key]?.[rowIndex]?.[field.key];
75871
- };
75872
- const renderError = (rowIndex) => {
75864
+ }, [validationErrors, section.key, field.key]);
75865
+ const renderError = React__default.useCallback((rowIndex) => {
75873
75866
  const error = getFieldError(rowIndex);
75874
75867
  return error ? /* @__PURE__ */ jsx("div", { className: "text-red-500 text-xs mt-1", children: error }) : null;
75875
- };
75868
+ }, [getFieldError]);
75876
75869
  switch (field.fieldtype) {
75877
75870
  case "text":
75878
75871
  return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { children: [
@@ -75880,7 +75873,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75880
75873
  Input,
75881
75874
  {
75882
75875
  value: props[field.key] || "",
75883
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
75876
+ onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
75884
75877
  placeholder: field.placeholder || `Enter ${field.label}`,
75885
75878
  required: field.required,
75886
75879
  className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`
@@ -75894,7 +75887,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75894
75887
  Textarea,
75895
75888
  {
75896
75889
  value: props[field.key] || "",
75897
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
75890
+ onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
75898
75891
  placeholder: field.placeholder || `Enter ${field.label}`,
75899
75892
  required: field.required,
75900
75893
  className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`,
@@ -75910,7 +75903,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75910
75903
  {
75911
75904
  type: "number",
75912
75905
  value: props[field.key] || "",
75913
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
75906
+ onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
75914
75907
  placeholder: field.placeholder || `Enter ${field.label}`,
75915
75908
  required: field.required,
75916
75909
  className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`
@@ -75925,7 +75918,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75925
75918
  {
75926
75919
  type: "email",
75927
75920
  value: props[field.key] || "",
75928
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
75921
+ onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
75929
75922
  placeholder: field.placeholder || "Enter email address",
75930
75923
  required: field.required,
75931
75924
  className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`
@@ -75940,7 +75933,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75940
75933
  {
75941
75934
  type: "url",
75942
75935
  value: props[field.key] || "",
75943
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
75936
+ onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
75944
75937
  placeholder: field.placeholder || "Enter URL",
75945
75938
  required: field.required,
75946
75939
  className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`
@@ -75955,7 +75948,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75955
75948
  {
75956
75949
  type: "password",
75957
75950
  value: props[field.key] || "",
75958
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
75951
+ onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
75959
75952
  placeholder: field.placeholder || "Enter password",
75960
75953
  required: field.required,
75961
75954
  className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`
@@ -75965,20 +75958,48 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75965
75958
  ] });
75966
75959
  case "select":
75967
75960
  case "dropdown":
75968
- return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { children: [
75969
- /* @__PURE__ */ jsx(
75970
- Select,
75971
- {
75972
- value: props[field.key] || "",
75973
- onChange: (value) => updateFieldValue(rowIndex, value),
75974
- options: field.options || [],
75975
- placeholder: field.placeholder || `Select ${field.label}`,
75976
- required: field.required,
75977
- className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`
75961
+ return (props, rowIndex) => {
75962
+ const options = React__default.useMemo(() => {
75963
+ if (field.optionsFrom && initialData) {
75964
+ const { config, valueField, labelField } = field.optionsFrom;
75965
+ const configData = initialData[config] || [];
75966
+ if (Array.isArray(configData)) {
75967
+ console.log(`[DataTableRenderer] Generating options for ${field.key} from ${config}:`, configData);
75968
+ const mappedOptions = configData.map((item2) => ({
75969
+ value: item2[valueField] || "",
75970
+ label: item2[labelField] || ""
75971
+ }));
75972
+ console.log(`[DataTableRenderer] Generated options:`, mappedOptions);
75973
+ return mappedOptions;
75974
+ }
75975
+ console.log(`[DataTableRenderer] No data found for ${config}, using empty array`);
75976
+ return [];
75978
75977
  }
75979
- ),
75980
- renderError(rowIndex)
75981
- ] });
75978
+ return field.options || [];
75979
+ }, [field.optionsFrom, initialData, field.options]);
75980
+ console.log(`[DataTableRenderer] Rendering select for ${field.key}:`, {
75981
+ currentValue: props[field.key],
75982
+ availableOptions: options,
75983
+ optionsSource: field.optionsFrom ? "dynamic" : "static"
75984
+ });
75985
+ return /* @__PURE__ */ jsxs("div", { children: [
75986
+ /* @__PURE__ */ jsx(
75987
+ Select,
75988
+ {
75989
+ value: props[field.key] || "",
75990
+ onChange: (value) => {
75991
+ console.log(`[DataTableRenderer] Select value changed for ${field.key}:`, value);
75992
+ updateFieldValue(field, rowIndex, value);
75993
+ },
75994
+ options,
75995
+ placeholder: field.placeholder || `Select ${field.label}`,
75996
+ required: field.required,
75997
+ className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`
75998
+ }
75999
+ ),
76000
+ renderError(rowIndex)
76001
+ ] });
76002
+ };
75982
76003
  case "multiselect":
75983
76004
  return (props, rowIndex) => {
75984
76005
  const currentValue = props[field.key] || [];
@@ -76117,7 +76138,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
76117
76138
  {
76118
76139
  type: "range",
76119
76140
  value: props[field.key] || field.min || 0,
76120
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
76141
+ onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
76121
76142
  min: field.min || 0,
76122
76143
  max: field.max || 100,
76123
76144
  step: field.step || 1,
@@ -76155,7 +76176,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
76155
76176
  Input,
76156
76177
  {
76157
76178
  value: props[field.key] || "",
76158
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
76179
+ onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
76159
76180
  placeholder: field.placeholder || `Enter ${field.label}`,
76160
76181
  required: field.required,
76161
76182
  className: `w-full ${getFieldError(rowIndex) ? "border-red-500" : ""}`
@@ -76164,7 +76185,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
76164
76185
  renderError(rowIndex)
76165
76186
  ] });
76166
76187
  }
76167
- };
76188
+ }, [updateFieldValue, validationErrors, section.key, initialData]);
76168
76189
  const addBlankRow = useCallback(() => {
76169
76190
  console.log("[DataTableRenderer] Adding blank row");
76170
76191
  setData((prevData) => {
@@ -76321,6 +76342,9 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
76321
76342
  })()
76322
76343
  ] });
76323
76344
  }
76345
+ const DataTableRenderer$1 = React__default.memo(DataTableRenderer, (prevProps, nextProps) => {
76346
+ return prevProps.item === nextProps.item && prevProps.initialData === nextProps.initialData && prevProps.validationErrors === nextProps.validationErrors;
76347
+ });
76324
76348
 
76325
76349
  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}
76326
76350
 
@@ -76758,7 +76782,7 @@ const UnknownType = ({ item }) => /* @__PURE__ */ jsxs("div", { className: "p-3
76758
76782
  ] });
76759
76783
  const REGISTRY = /* @__PURE__ */ Object.create(null);
76760
76784
  REGISTRY.section = SectionRenderer;
76761
- REGISTRY.datatable = DataTableRenderer;
76785
+ REGISTRY.datatable = DataTableRenderer$1;
76762
76786
  REGISTRY.managecollectionlist = ManageCollectionListRenderer;
76763
76787
  REGISTRY["manage-collection-list"] = ManageCollectionListRenderer;
76764
76788
  function toType(input) {
@@ -76928,11 +76952,15 @@ function DynamicConfig({
76928
76952
  }
76929
76953
  }, [configdata, reload, appid, disableApi]);
76930
76954
  const handleSectionChange = (name, sectiondata) => {
76931
- console.log("Section change:", name, sectiondata);
76955
+ console.log("Section change:", { name, sectiondata });
76932
76956
  setData((prev) => {
76933
76957
  const newData = JSON.parse(JSON.stringify(prev || {}));
76934
76958
  newData[name] = sectiondata;
76935
- console.log("Updated data:", newData);
76959
+ console.log("Complete data after update:", {
76960
+ updatedSection: name,
76961
+ sectionData: sectiondata,
76962
+ allData: newData
76963
+ });
76936
76964
  return newData;
76937
76965
  });
76938
76966
  setValidationErrors((prevErrors) => {