unifyedx-storybook-new 0.1.69 → 0.1.71

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.
@@ -838,7 +838,7 @@ const Avatar = ({
838
838
  showIcon && /* @__PURE__ */ jsx("span", { className: "avatar-icon", children: /* @__PURE__ */ jsx(User, {}) })
839
839
  ] });
840
840
  };
841
- const AvatarGroup$1 = ({ children, max = 4, truncatedMessage = "Members", ...props }) => {
841
+ const AvatarGroup = ({ children, max = 4, truncatedMessage = "Members", ...props }) => {
842
842
  const avatars = React__default.Children.toArray(children);
843
843
  const visibleAvatars = avatars.slice(0, max);
844
844
  const hiddenCount = avatars.length - max;
@@ -75705,7 +75705,6 @@ const SectionRenderer$1 = React__default.memo(SectionRenderer, (prevProps, nextP
75705
75705
  return prevProps.item === nextProps.item && prevProps.data === nextProps.data && prevProps.updateHandler === nextProps.updateHandler && JSON.stringify(prevProps.validationErrors) === JSON.stringify(nextProps.validationErrors);
75706
75706
  });
75707
75707
 
75708
- const AvatarGroup = ({ children }) => /* @__PURE__ */ jsx("div", { className: "flex -space-x-2", children });
75709
75708
  function DataTableRenderer({ item, data: initialData, updateHandler, validationErrors = {} }) {
75710
75709
  item.key;
75711
75710
  const [section, setSection] = useState(item);
@@ -75726,14 +75725,14 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75726
75725
  return prevData;
75727
75726
  });
75728
75727
  }, [initialData, section.key]);
75729
- const debounce = React__default.useCallback((func, delay) => {
75728
+ const debounce = useCallback((func, delay) => {
75730
75729
  let timeoutId;
75731
75730
  return (...args) => {
75732
75731
  clearTimeout(timeoutId);
75733
75732
  timeoutId = setTimeout(() => func.apply(null, args), delay);
75734
75733
  };
75735
75734
  }, []);
75736
- const debouncedUpdate = React__default.useCallback(
75735
+ const debouncedUpdate = useCallback(
75737
75736
  debounce((newData) => {
75738
75737
  if (updateHandler && typeof updateHandler === "function") {
75739
75738
  updateHandler(section.key, newData);
@@ -75748,46 +75747,35 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75748
75747
  isStructuralChangeRef.current = false;
75749
75748
  }
75750
75749
  }, [data, debouncedUpdate]);
75751
- const updateFieldValue = React__default.useCallback((field, rowIndex, value) => {
75750
+ const updateFieldValue = useCallback((field, rowIndex, value) => {
75752
75751
  setData((prevData) => {
75753
75752
  const newData = [...prevData];
75754
75753
  newData[rowIndex][field.key] = value;
75755
75754
  return newData;
75756
75755
  });
75757
75756
  }, []);
75758
- const getFieldError = React__default.useCallback((field, rowIndex) => {
75757
+ const getFieldError = useCallback((field, rowIndex) => {
75759
75758
  return validationErrors[section.key]?.[rowIndex]?.[field.key];
75760
75759
  }, [validationErrors, section.key]);
75761
- const renderError = React__default.useCallback((field, rowIndex) => {
75760
+ const renderError = useCallback((field, rowIndex) => {
75762
75761
  const error = getFieldError(field, rowIndex);
75763
75762
  return error ? /* @__PURE__ */ jsx("div", { className: "text-red-500 text-xs mt-1", children: error }) : null;
75764
75763
  }, [getFieldError]);
75765
- const fieldOptionsCache = React__default.useMemo(() => {
75766
- const cache = /* @__PURE__ */ new Map();
75767
- section.fields.forEach((field) => {
75768
- if (field.optionsFrom && initialData) {
75769
- const { config, valueField, labelField } = field.optionsFrom;
75770
- const configData = initialData[config] || [];
75771
- if (Array.isArray(configData)) {
75772
- const options = configData.map((item2) => ({
75773
- id: item2[valueField] || "",
75774
- value: item2[valueField] || "",
75775
- label: item2[labelField] || ""
75776
- }));
75777
- cache.set(field.key, options);
75778
- } else {
75779
- cache.set(field.key, field.options || []);
75780
- }
75781
- } else {
75782
- cache.set(field.key, field.options || []);
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
+ }));
75783
75774
  }
75784
- });
75785
- return cache;
75786
- }, [initialData, section.fields]);
75787
- const getDynamicOptions = React__default.useCallback((field) => {
75788
- return fieldOptionsCache.get(field.key) || [];
75789
- }, [fieldOptionsCache]);
75790
- const getFieldRenderer = React__default.useCallback((field) => {
75775
+ }
75776
+ return field.options || [];
75777
+ }, [initialData]);
75778
+ const getFieldRenderer = useCallback((field) => {
75791
75779
  switch (field.fieldtype) {
75792
75780
  case "text":
75793
75781
  return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { children: [
@@ -75848,40 +75836,13 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75848
75836
  ),
75849
75837
  renderError(field, rowIndex)
75850
75838
  ] });
75851
- case "url":
75852
- return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { children: [
75853
- /* @__PURE__ */ jsx(
75854
- Input$1,
75855
- {
75856
- type: "url",
75857
- value: props[field.key] || "",
75858
- onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
75859
- placeholder: field.placeholder || "Enter URL",
75860
- required: field.required,
75861
- className: `w-full ${getFieldError(field, rowIndex) ? "border-red-500" : ""}`
75862
- }
75863
- ),
75864
- renderError(field, rowIndex)
75865
- ] });
75866
- case "password":
75867
- return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { children: [
75868
- /* @__PURE__ */ jsx(
75869
- Input$1,
75870
- {
75871
- type: "password",
75872
- value: props[field.key] || "",
75873
- onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
75874
- placeholder: field.placeholder || "Enter password",
75875
- required: field.required,
75876
- className: `w-full ${getFieldError(field, rowIndex) ? "border-red-500" : ""}`
75877
- }
75878
- ),
75879
- renderError(field, rowIndex)
75880
- ] });
75881
75839
  case "select":
75882
75840
  case "dropdown":
75883
75841
  return (props, rowIndex) => {
75884
- const options = getDynamicOptions(field);
75842
+ const [options, setOptions] = useState([]);
75843
+ const handleOpen = () => {
75844
+ setOptions(getDynamicOptions(field));
75845
+ };
75885
75846
  return /* @__PURE__ */ jsxs("div", { children: [
75886
75847
  /* @__PURE__ */ jsx(
75887
75848
  Select,
@@ -75889,6 +75850,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75889
75850
  value: props[field.key] || "",
75890
75851
  onChange: (value) => updateFieldValue(field, rowIndex, value),
75891
75852
  options,
75853
+ onOpen: handleOpen,
75892
75854
  placeholder: field.placeholder || `Select ${field.label}`,
75893
75855
  required: field.required,
75894
75856
  className: `w-full ${getFieldError(field, rowIndex) ? "border-red-500" : ""}`
@@ -75904,7 +75866,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75904
75866
  MultiSelect$1,
75905
75867
  {
75906
75868
  selectedItems: currentValue,
75907
- onSelectionChange: (selectedItems) => updateFieldValue(rowIndex, selectedItems),
75869
+ onSelectionChange: (selectedItems) => updateFieldValue(field, rowIndex, selectedItems),
75908
75870
  options: field.options || [],
75909
75871
  placeholder: field.placeholder || `Select ${field.label}`,
75910
75872
  className: "w-full"
@@ -75917,7 +75879,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75917
75879
  Checkbox,
75918
75880
  {
75919
75881
  checked: Boolean(props[field.key]),
75920
- onChange: (checked) => updateFieldValue(rowIndex, checked),
75882
+ onChange: (checked) => updateFieldValue(field, rowIndex, checked),
75921
75883
  label: field.placeholder || field.label,
75922
75884
  className: "w-full"
75923
75885
  }
@@ -75928,7 +75890,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75928
75890
  ToggleSwitch,
75929
75891
  {
75930
75892
  isOn: Boolean(props[field.key]),
75931
- onToggle: (isOn) => updateFieldValue(rowIndex, isOn),
75893
+ onToggle: (isOn) => updateFieldValue(field, rowIndex, isOn),
75932
75894
  label: field.placeholder || field.label,
75933
75895
  className: "w-full"
75934
75896
  }
@@ -75938,135 +75900,11 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
75938
75900
  DatePicker$1,
75939
75901
  {
75940
75902
  selectedDate: props[field.key] ? new Date(props[field.key]) : null,
75941
- onDateChange: (date) => updateFieldValue(rowIndex, date ? date.toISOString().split("T")[0] : ""),
75903
+ onDateChange: (date) => updateFieldValue(field, rowIndex, date ? date.toISOString().split("T")[0] : ""),
75942
75904
  placeholder: field.placeholder || "Select date",
75943
75905
  className: "w-full"
75944
75906
  }
75945
75907
  );
75946
- case "datetime":
75947
- return (props, rowIndex) => /* @__PURE__ */ jsx(
75948
- Input$1,
75949
- {
75950
- type: "datetime-local",
75951
- value: props[field.key] || "",
75952
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
75953
- placeholder: field.placeholder || "Select date and time",
75954
- required: field.required,
75955
- className: "w-full"
75956
- }
75957
- );
75958
- case "time":
75959
- return (props, rowIndex) => /* @__PURE__ */ jsx(
75960
- Input$1,
75961
- {
75962
- type: "time",
75963
- value: props[field.key] || "",
75964
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
75965
- placeholder: field.placeholder || "Select time",
75966
- required: field.required,
75967
- className: "w-full"
75968
- }
75969
- );
75970
- case "radio":
75971
- return (props, rowIndex) => /* @__PURE__ */ jsx(
75972
- RadioGroup,
75973
- {
75974
- selectedValue: props[field.key] || "",
75975
- onValueChange: (value) => updateFieldValue(rowIndex, value),
75976
- options: field.options || [],
75977
- className: "w-full"
75978
- }
75979
- );
75980
- case "search":
75981
- return (props, rowIndex) => /* @__PURE__ */ jsx(
75982
- SearchBar,
75983
- {
75984
- value: props[field.key] || "",
75985
- onChange: (value) => updateFieldValue(rowIndex, value),
75986
- placeholder: field.placeholder || `Search ${field.label}`,
75987
- className: "w-full"
75988
- }
75989
- );
75990
- case "audience":
75991
- return (props, rowIndex) => {
75992
- const audienceData = props[field.key] || { users: [], groups: [], roles: [] };
75993
- const allAudience = [
75994
- ...audienceData.users || [],
75995
- ...audienceData.groups || [],
75996
- ...audienceData.roles || []
75997
- ];
75998
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
75999
- /* @__PURE__ */ jsx(AvatarGroup, { children: allAudience.length > 0 ? allAudience.slice(0, 3).map((aud, idx) => /* @__PURE__ */ jsx(
76000
- Avatar,
76001
- {
76002
- size: "small",
76003
- name: aud.name || aud.displayName || aud.id,
76004
- src: aud.avatarUrl
76005
- },
76006
- idx
76007
- )) : null }),
76008
- /* @__PURE__ */ jsx(
76009
- "button",
76010
- {
76011
- className: "text-blue-600 font-semibold hover:text-blue-800",
76012
- onClick: () => {
76013
- setAudienceFieldName(field.key);
76014
- setAudienceRowId(rowIndex);
76015
- },
76016
- children: allAudience.length > 0 ? "Edit" : "Assign"
76017
- }
76018
- )
76019
- ] });
76020
- };
76021
- case "color":
76022
- return (props, rowIndex) => /* @__PURE__ */ jsx(
76023
- Input$1,
76024
- {
76025
- type: "color",
76026
- value: props[field.key] || "#000000",
76027
- onChange: (e) => updateFieldValue(rowIndex, e.target.value),
76028
- className: "w-full h-10"
76029
- }
76030
- );
76031
- case "range":
76032
- return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
76033
- /* @__PURE__ */ jsx(
76034
- Input$1,
76035
- {
76036
- type: "range",
76037
- value: props[field.key] || field.min || 0,
76038
- onChange: (e) => updateFieldValue(field, rowIndex, e.target.value),
76039
- min: field.min || 0,
76040
- max: field.max || 100,
76041
- step: field.step || 1,
76042
- className: "w-full"
76043
- }
76044
- ),
76045
- /* @__PURE__ */ jsx("span", { className: "text-sm text-gray-500", children: props[field.key] || field.min || 0 })
76046
- ] });
76047
- case "file":
76048
- return (props, rowIndex) => /* @__PURE__ */ jsx(
76049
- Input$1,
76050
- {
76051
- type: "file",
76052
- onChange: (e) => {
76053
- const file = e.target.files[0];
76054
- updateFieldValue(rowIndex, file ? file.name : "");
76055
- },
76056
- accept: field.accept,
76057
- className: "w-full"
76058
- }
76059
- );
76060
- case "hidden":
76061
- return (props, rowIndex) => /* @__PURE__ */ jsx(
76062
- Input$1,
76063
- {
76064
- type: "hidden",
76065
- value: props[field.key] || "",
76066
- onChange: (e) => updateFieldValue(rowIndex, e.target.value)
76067
- }
76068
- );
76069
- // Default fallback for unknown field types
76070
75908
  default:
76071
75909
  return (props, rowIndex) => /* @__PURE__ */ jsxs("div", { children: [
76072
75910
  /* @__PURE__ */ jsx(
@@ -76082,14 +75920,11 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
76082
75920
  renderError(field, rowIndex)
76083
75921
  ] });
76084
75922
  }
76085
- }, [updateFieldValue, validationErrors, section.key, initialData, getDynamicOptions, getFieldError, renderError]);
75923
+ }, [updateFieldValue, getDynamicOptions, getFieldError, renderError]);
76086
75924
  const addBlankRow = useCallback(() => {
76087
75925
  isStructuralChangeRef.current = true;
76088
75926
  setData((prevData) => {
76089
- const blankRow = {
76090
- id: prevData.length
76091
- // Assign next available ID
76092
- };
75927
+ const blankRow = { id: prevData.length };
76093
75928
  section.fields.forEach((field) => {
76094
75929
  if (field.fieldtype === "audience") {
76095
75930
  blankRow[field.key] = { users: [], groups: [], roles: [] };
@@ -76109,9 +75944,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
76109
75944
  const removeRow = useCallback((index) => {
76110
75945
  isStructuralChangeRef.current = true;
76111
75946
  setData((prevData) => {
76112
- if (prevData.length <= 1) {
76113
- return prevData;
76114
- }
75947
+ if (prevData.length <= 1) return prevData;
76115
75948
  const newData = [...prevData];
76116
75949
  newData.splice(index, 1);
76117
75950
  setTimeout(() => {
@@ -76184,14 +76017,7 @@ function DataTableRenderer({ item, data: initialData, updateHandler, validationE
76184
76017
  /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full bg-white border border-gray-300", style: { marginBottom: "20px" }, children: [
76185
76018
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "bg-gray-50", children: [
76186
76019
  /* @__PURE__ */ jsx("th", { className: "px-4 py-2 w-10" }),
76187
- section.fields.map((field, idx) => /* @__PURE__ */ jsx(
76188
- "th",
76189
- {
76190
- className: "px-4 py-2 text-left text-sm font-medium text-gray-700",
76191
- children: field.label || field.key
76192
- },
76193
- idx
76194
- )),
76020
+ section.fields.map((field, idx) => /* @__PURE__ */ jsx("th", { className: "px-4 py-2 text-left text-sm font-medium text-gray-700", children: field.label || field.key }, idx)),
76195
76021
  /* @__PURE__ */ jsx("th", { className: "px-4 py-2 w-16" })
76196
76022
  ] }) }),
76197
76023
  /* @__PURE__ */ jsx("tbody", { children: data.map((row, rowIndex) => /* @__PURE__ */ jsxs(
@@ -218794,5 +218620,5 @@ const CustomDataGrid = forwardRef((props, ref) => {
218794
218620
  });
218795
218621
  CustomDataGrid.displayName = "CustomDataGrid";
218796
218622
 
218797
- export { AddUserGroupsRolesModal, Avatar, AvatarGroup$1 as AvatarGroup, Badge, Breadcrumbs, Button$2 as Button, Checkbox, CustomDataGrid, CustomDialog, CustomGridToolbar, DatePicker$1 as DatePicker, DateRangePicker$1 as DateRangePicker, DynamicConfig, FileUploadModal, FullConfigPage, FullScreenLoader, GenericFilter, Input$1 as Input, ManageCollectionList, Modal, MultiSelect$1 as MultiSelect, OptionsMenu, PageHeader, PageLayout, Pagination, RadioGroup, SearchBar, Select, Sidebar, Spinner, Textarea, ToastProvider, ToggleSwitch, Tooltip$1 as Tooltip, TreeView, UnifyedCoreButton, WizardModal, adGroupsListSearchApi, axiosDelete, axiosGet, axiosPatch, axiosPost, axiosPut, cookies$1 as cookies, createHttpClient, directoryPermissionsApi, filePermissionsApi, gateWayUrl, gatewayBase, getBaseUrl, getSnapshot, http, localStore, myDriveGatewayBaseV2, notify, provisioningBase, rbacBase, searchRolesApi, sessionStore, userSearchBase };
218623
+ export { AddUserGroupsRolesModal, Avatar, AvatarGroup, Badge, Breadcrumbs, Button$2 as Button, Checkbox, CustomDataGrid, CustomDialog, CustomGridToolbar, DatePicker$1 as DatePicker, DateRangePicker$1 as DateRangePicker, DynamicConfig, FileUploadModal, FullConfigPage, FullScreenLoader, GenericFilter, Input$1 as Input, ManageCollectionList, Modal, MultiSelect$1 as MultiSelect, OptionsMenu, PageHeader, PageLayout, Pagination, RadioGroup, SearchBar, Select, Sidebar, Spinner, Textarea, ToastProvider, ToggleSwitch, Tooltip$1 as Tooltip, TreeView, UnifyedCoreButton, WizardModal, adGroupsListSearchApi, axiosDelete, axiosGet, axiosPatch, axiosPost, axiosPut, cookies$1 as cookies, createHttpClient, directoryPermissionsApi, filePermissionsApi, gateWayUrl, gatewayBase, getBaseUrl, getSnapshot, http, localStore, myDriveGatewayBaseV2, notify, provisioningBase, rbacBase, searchRolesApi, sessionStore, userSearchBase };
218798
218624
  //# sourceMappingURL=unifyedx-storybook-new.es.js.map