@erpsquad/common 1.10.77 → 1.10.79

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.
Files changed (44) hide show
  1. package/dist/chunks/{android-12-switch-CoMylrig.js → android-12-switch-BgFAxJ9x.js} +289 -229
  2. package/dist/chunks/{android-12-switch-CoMylrig.js.map → android-12-switch-BgFAxJ9x.js.map} +1 -1
  3. package/dist/chunks/{android-12-switch-CJmu5zpr.esm.js → android-12-switch-DoExcS1P.esm.js} +289 -229
  4. package/dist/chunks/{android-12-switch-CJmu5zpr.esm.js.map → android-12-switch-DoExcS1P.esm.js.map} +1 -1
  5. package/dist/chunks/{appbar-DELlMlbx.esm.js → appbar-D1L6GTYk.esm.js} +30 -25
  6. package/dist/chunks/appbar-D1L6GTYk.esm.js.map +1 -0
  7. package/dist/chunks/{appbar-xuAwm7L1.js → appbar-D424Z-Ai.js} +30 -25
  8. package/dist/chunks/appbar-D424Z-Ai.js.map +1 -0
  9. package/dist/chunks/{default-data-Bhdk8Rkn.esm.js → default-data-CdhwU3H3.esm.js} +3 -3
  10. package/dist/chunks/{default-data-Bhdk8Rkn.esm.js.map → default-data-CdhwU3H3.esm.js.map} +1 -1
  11. package/dist/chunks/{default-data-C_eEc8KO.js → default-data-Cgb7xKe1.js} +3 -3
  12. package/dist/chunks/{default-data-C_eEc8KO.js.map → default-data-Cgb7xKe1.js.map} +1 -1
  13. package/dist/chunks/{fullScreen-B0QUzNj3.js → fullScreen-BUbaMxdQ.js} +2 -2
  14. package/dist/chunks/{fullScreen-B0QUzNj3.js.map → fullScreen-BUbaMxdQ.js.map} +1 -1
  15. package/dist/chunks/{fullScreen-C8dcx8pG.esm.js → fullScreen-COa9H9T5.esm.js} +2 -2
  16. package/dist/chunks/{fullScreen-C8dcx8pG.esm.js.map → fullScreen-COa9H9T5.esm.js.map} +1 -1
  17. package/dist/chunks/{sidebar-fZ9vocVX.esm.js → sidebar-D5jsYGs8.esm.js} +2 -2
  18. package/dist/chunks/{sidebar-fZ9vocVX.esm.js.map → sidebar-D5jsYGs8.esm.js.map} +1 -1
  19. package/dist/chunks/{sidebar-BC824FOR.js → sidebar-DvPIFrpF.js} +2 -2
  20. package/dist/chunks/{sidebar-BC824FOR.js.map → sidebar-DvPIFrpF.js.map} +1 -1
  21. package/dist/chunks/{sidebarScreen--NIbnhIf.esm.js → sidebarScreen-B4RSyJAT.esm.js} +3 -3
  22. package/dist/chunks/{sidebarScreen--NIbnhIf.esm.js.map → sidebarScreen-B4RSyJAT.esm.js.map} +1 -1
  23. package/dist/chunks/{sidebarScreen-B08K08t5.js → sidebarScreen-CFDnYrtL.js} +3 -3
  24. package/dist/chunks/{sidebarScreen-B08K08t5.js.map → sidebarScreen-CFDnYrtL.js.map} +1 -1
  25. package/dist/chunks/{uom-field-wrapper-BmRhzpUZ.js → uom-field-wrapper-DGt-0_BI.js} +359 -221
  26. package/dist/chunks/{uom-field-wrapper-BmRhzpUZ.js.map → uom-field-wrapper-DGt-0_BI.js.map} +1 -1
  27. package/dist/chunks/{uom-field-wrapper-GQYKNbtK.esm.js → uom-field-wrapper-_O6BmPp4.esm.js} +360 -222
  28. package/dist/chunks/{uom-field-wrapper-GQYKNbtK.esm.js.map → uom-field-wrapper-_O6BmPp4.esm.js.map} +1 -1
  29. package/dist/components/chat-bot/doc-intro.d.ts +4 -2
  30. package/dist/components/index.esm.js +4 -4
  31. package/dist/components/index.js +4 -4
  32. package/dist/components/material-table/components/inline-edit-fields.d.ts +9 -9
  33. package/dist/index.esm.js +7 -7
  34. package/dist/index.js +7 -7
  35. package/dist/layout/index.esm.js +2 -2
  36. package/dist/layout/index.js +2 -2
  37. package/dist/src/components/chat-bot/doc-intro.d.ts +4 -2
  38. package/dist/src/components/material-table/components/inline-edit-fields.d.ts +9 -9
  39. package/dist/style.css +10 -1
  40. package/dist/views/index.esm.js +5 -5
  41. package/dist/views/index.js +4 -4
  42. package/package.json +1 -1
  43. package/dist/chunks/appbar-DELlMlbx.esm.js.map +0 -1
  44. package/dist/chunks/appbar-xuAwm7L1.js.map +0 -1
@@ -10,7 +10,7 @@ const images = require("./images-CY-_BlWh.js");
10
10
  const React$1 = require("react");
11
11
  const reactHookForm = require("react-hook-form");
12
12
  ;/* empty css */
13
- const appbar = require("./appbar-xuAwm7L1.js");
13
+ const appbar = require("./appbar-D424Z-Ai.js");
14
14
  const reactI18next = require("react-i18next");
15
15
  const notification = require("./notification-vWmhkTRo.js");
16
16
  const formBuilderDeconversion = require("./form-builder-deconversion-5gDqfT7n.js");
@@ -27616,253 +27616,310 @@ const UploadMedia = React$1.memo((props) => {
27616
27616
  getSelectedFiles(value)
27617
27617
  ] });
27618
27618
  });
27619
- const InlineEditFields = ({
27620
- // cell,
27619
+ const EMPTY_EDIT_PROPERTIES = Object.freeze({});
27620
+ const CACHE_NORMALISED = Symbol.for("erpsquad.inlineEdit.cacheNormalised");
27621
+ const isCacheNormalised = (cache) => Boolean(cache && cache[CACHE_NORMALISED]);
27622
+ const markCacheNormalised = (cache) => {
27623
+ cache[CACHE_NORMALISED] = true;
27624
+ return cache;
27625
+ };
27626
+ const isBlank = (value) => value === void 0 || value === null || value === "";
27627
+ const shallowEqual = (a = {}, b = {}) => {
27628
+ if (a === b) return true;
27629
+ const aKeys = Object.keys(a);
27630
+ const bKeys = Object.keys(b);
27631
+ if (aKeys.length !== bKeys.length) return false;
27632
+ return aKeys.every((key) => Object.is(a[key], b[key]));
27633
+ };
27634
+ const rowSubscribers = /* @__PURE__ */ new Map();
27635
+ const subscribeToRow = (rowId, listener) => {
27636
+ let listeners = rowSubscribers.get(rowId);
27637
+ if (!listeners) {
27638
+ listeners = /* @__PURE__ */ new Set();
27639
+ rowSubscribers.set(rowId, listeners);
27640
+ }
27641
+ listeners.add(listener);
27642
+ return () => {
27643
+ listeners == null ? void 0 : listeners.delete(listener);
27644
+ if (listeners && listeners.size === 0) rowSubscribers.delete(rowId);
27645
+ };
27646
+ };
27647
+ const publishRowCache = (rowId, cache) => {
27648
+ var _a;
27649
+ (_a = rowSubscribers.get(rowId)) == null ? void 0 : _a.forEach((listener) => listener(cache));
27650
+ };
27651
+ const readInitialValue = (mrtColumn, row) => {
27652
+ var _a;
27653
+ const columnDef = (mrtColumn == null ? void 0 : mrtColumn.columnDef) ?? {};
27654
+ const columnId = mrtColumn == null ? void 0 : mrtColumn.id;
27655
+ const {
27656
+ valueKey,
27657
+ is_multiple: isMultiple,
27658
+ defaultValue
27659
+ } = columnDef.editProperties ?? EMPTY_EDIT_PROPERTIES;
27660
+ const variant = columnDef.editVariant;
27661
+ const accessorValue = (_a = row == null ? void 0 : row.original) == null ? void 0 : _a[columnId];
27662
+ const boundValue = valueKey ? _.get(row == null ? void 0 : row.original, valueKey) : accessorValue;
27663
+ const accessorIsSafeFallback = !valueKey || valueKey === columnId;
27664
+ const rawValue = boundValue !== void 0 ? boundValue : accessorIsSafeFallback ? accessorValue : void 0;
27665
+ if (variant === "select" && isMultiple) {
27666
+ if (isBlank(boundValue)) return defaultValue ?? [];
27667
+ return Array.isArray(boundValue) ? boundValue : [boundValue];
27668
+ }
27669
+ if (variant === "date" || variant === "date_time") {
27670
+ const dateSource = boundValue !== void 0 ? boundValue : accessorValue;
27671
+ if (isBlank(dateSource)) return void 0;
27672
+ return dayjs(dateSource).isValid() ? dayjs(dateSource) : void 0;
27673
+ }
27674
+ if (variant === "select") {
27675
+ return isBlank(boundValue) ? defaultValue ?? "" : boundValue;
27676
+ }
27677
+ if (variant === "checkbox") {
27678
+ return isBlank(rawValue) ? Boolean(defaultValue) : Boolean(rawValue);
27679
+ }
27680
+ return isBlank(rawValue) && defaultValue !== void 0 ? defaultValue : rawValue;
27681
+ };
27682
+ const buildInitialCache = (row) => {
27683
+ const cache = {};
27684
+ row.getAllCells().forEach((cell) => {
27685
+ var _a;
27686
+ const enableEditing = (_a = cell.column.columnDef) == null ? void 0 : _a.enableEditing;
27687
+ if (enableEditing === void 0 || enableEditing === true) {
27688
+ cache[cell.column.id] = readInitialValue(cell.column, row);
27689
+ }
27690
+ });
27691
+ return markCacheNormalised(cache);
27692
+ };
27693
+ const extractValue = (event, type) => {
27694
+ var _a;
27695
+ switch (type) {
27696
+ case "date":
27697
+ case "file":
27698
+ case "image":
27699
+ case "phone":
27700
+ return event;
27701
+ case "checkbox":
27702
+ return (_a = event == null ? void 0 : event.target) == null ? void 0 : _a.checked;
27703
+ default:
27704
+ return (event == null ? void 0 : event.target) ? event.target.value : event;
27705
+ }
27706
+ };
27707
+ const InlineEditFields$1 = ({
27621
27708
  column,
27622
27709
  row,
27623
- // table,
27624
27710
  col,
27625
- // callback,
27626
27711
  errors,
27627
27712
  validationSchema: validationSchema2,
27628
27713
  setValidationErrors,
27629
27714
  onChangeRowField,
27630
27715
  getSelectedData
27631
27716
  }) => {
27632
- var _a, _b, _c, _d, _e, _f, _g, _h;
27633
- const [inputValue, setInputValue] = React$1.useState();
27634
- const [isInitialSet, setIsInitialSet] = React$1.useState(false);
27635
- const customFilter = React$1.useRef(null);
27636
- const editCols = row.getAllCells().map((col2) => col2.column.columnDef).filter(
27637
- (col2) => (col2 == null ? void 0 : col2.enableEditing) === void 0 || (col2 == null ? void 0 : col2.enableEditing) === true
27717
+ var _a;
27718
+ const [values, setValues] = React$1.useState(() => (row == null ? void 0 : row._valuesCache) ?? {});
27719
+ const [customFilter, setCustomFilter] = React$1.useState(null);
27720
+ const editVariant = col == null ? void 0 : col.editVariant;
27721
+ const fieldProperties = ((_a = column.columnDef) == null ? void 0 : _a.editProperties) ?? EMPTY_EDIT_PROPERTIES;
27722
+ const columnId = column.id;
27723
+ const rowId = row.id;
27724
+ React$1.useEffect(
27725
+ () => subscribeToRow(rowId, (cache) => {
27726
+ setValues((prev) => shallowEqual(prev, cache) ? prev : cache);
27727
+ }),
27728
+ [rowId]
27638
27729
  );
27639
- const editVariant = col.editVariant;
27640
- const fieldProperties = ((_a = column.columnDef) == null ? void 0 : _a.editProperties) || {};
27641
- let fieldDisbled = false;
27642
- if (fieldProperties == null ? void 0 : fieldProperties.disable) {
27643
- if (typeof fieldProperties.disable === "function") {
27644
- fieldDisbled = Boolean(fieldProperties == null ? void 0 : fieldProperties.disable(row, row._valuesCache));
27645
- } else {
27646
- fieldDisbled = Boolean(fieldProperties.disable);
27647
- }
27648
- }
27649
- const handleCustomFilter = React$1.useCallback(async (row2, values) => {
27650
- try {
27651
- if (typeof fieldProperties.customeFilter === "function") {
27652
- const filter = await fieldProperties.customeFilter(row2, values);
27653
- customFilter.current = filter;
27654
- return filter;
27655
- } else {
27656
- customFilter.current = fieldProperties == null ? void 0 : fieldProperties.customeFilter;
27657
- }
27658
- } catch (error) {
27659
- return null;
27660
- }
27661
- }, [fieldProperties, row, row._valuesCache]);
27662
27730
  React$1.useEffect(() => {
27663
- handleCustomFilter(row, row._valuesCache);
27664
- }, [handleCustomFilter, row, row._valuesCache]);
27665
- const valueKey = fieldProperties == null ? void 0 : fieldProperties.valueKey;
27666
- let defaultValue = "";
27667
- if (editVariant === "select" && (fieldProperties == null ? void 0 : fieldProperties.is_multiple)) {
27668
- defaultValue = valueKey ? _.get(row.original, valueKey, []) : [];
27669
- } else {
27670
- defaultValue = valueKey ? _.get(row.original, valueKey, row.original[column.id]) : row.original[column.id];
27671
- }
27672
- const validate = async (value) => {
27673
- try {
27674
- await validationSchema2.validateAt(
27675
- column.id,
27676
- {
27677
- [column.id]: value
27678
- },
27679
- {
27680
- abortEarly: false
27681
- }
27682
- );
27683
- const fe = {};
27684
- for (const e in errors) {
27685
- if (e != column.id) {
27686
- fe[e] = errors[e];
27687
- }
27688
- }
27689
- setValidationErrors(fe);
27690
- } catch (err) {
27691
- if (err instanceof Yup__namespace.ValidationError) {
27692
- const e = {};
27693
- err.inner.forEach((error) => {
27694
- if (error.path) {
27695
- e[error.path] = error.message;
27696
- }
27697
- });
27698
- const em = { ...errors, ...e };
27699
- setValidationErrors(em);
27700
- }
27701
- }
27702
- };
27703
- const onChange = async (e, type, selectedData) => {
27704
- const data = selectedData;
27705
- let value;
27706
- switch (type) {
27707
- case "date":
27708
- case "file":
27709
- case "image":
27710
- case "phone":
27711
- value = e;
27712
- break;
27713
- case "text":
27714
- case "number":
27715
- value = e.target.value;
27716
- break;
27717
- case "checkbox":
27718
- value = e.target.checked;
27719
- break;
27720
- default:
27721
- value = e.target.value;
27722
- break;
27723
- }
27724
- setInputValue({ ...inputValue, [column.id]: value });
27725
- if (onChangeRowField) {
27726
- const v = await onChangeRowField(e, type, row, col, data);
27727
- if (v) {
27728
- row._valuesCache = { ...row._valuesCache, ...v };
27729
- }
27731
+ const existing = row._valuesCache;
27732
+ if (isCacheNormalised(existing)) {
27733
+ setValues(existing);
27734
+ return;
27730
27735
  }
27731
- row._valuesCache = { ...row._valuesCache, [column.id]: value };
27732
- const updatedCache = { ...row._valuesCache };
27733
- setInputValue(updatedCache);
27734
- window.dispatchEvent(new CustomEvent("row-cache-updated", { detail: { rowId: row.id, cache: updatedCache } }));
27735
- await validate(value);
27736
- };
27737
- React$1.useEffect(() => {
27738
- setInputValue({ ...inputValue, ...row._valuesCache });
27739
- }, [row._valuesCache]);
27736
+ const seeded = buildInitialCache(row);
27737
+ row._valuesCache = seeded;
27738
+ setValues(seeded);
27739
+ publishRowCache(rowId, seeded);
27740
+ }, [rowId]);
27741
+ const rawCustomFilter = fieldProperties.customeFilter;
27740
27742
  React$1.useEffect(() => {
27741
- const handleCacheUpdate = (e) => {
27742
- if (e.detail.rowId === row.id) {
27743
- setInputValue({ ...e.detail.cache });
27743
+ if (editVariant !== "select" || rawCustomFilter === void 0) return;
27744
+ if (typeof rawCustomFilter !== "function") {
27745
+ setCustomFilter(rawCustomFilter ?? null);
27746
+ return;
27747
+ }
27748
+ let cancelled = false;
27749
+ (async () => {
27750
+ try {
27751
+ const filter = await rawCustomFilter(row, row._valuesCache);
27752
+ if (!cancelled) setCustomFilter(filter ?? null);
27753
+ } catch {
27754
+ if (!cancelled) setCustomFilter(null);
27744
27755
  }
27756
+ })();
27757
+ return () => {
27758
+ cancelled = true;
27745
27759
  };
27746
- window.addEventListener("row-cache-updated", handleCacheUpdate);
27747
- return () => window.removeEventListener("row-cache-updated", handleCacheUpdate);
27748
- }, [row.id]);
27749
- React$1.useEffect(() => {
27750
- if (!isInitialSet) {
27751
- const editFields = Object.keys(row._valuesCache || {});
27752
- const dValues = {};
27753
- row.getAllCells().forEach((cell) => {
27754
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
27755
- if (((_a2 = cell.column.columnDef) == null ? void 0 : _a2.enableEditing) === void 0 || ((_b2 = cell.column.columnDef) == null ? void 0 : _b2.enableEditing) === true) {
27756
- const { is_multiple, valueKey: valueKey2 } = ((_c2 = cell.column.columnDef) == null ? void 0 : _c2.editProperties) || {};
27757
- if (editFields.length === 0 || editFields.includes(cell.column.id)) {
27758
- const cachedValue = (_d2 = row._valuesCache) == null ? void 0 : _d2[cell.column.id];
27759
- const vl = _.get(row.original, valueKey2);
27760
- if (editVariant === "select" && is_multiple) {
27761
- dValues[cell.column.id] = cachedValue ?? (vl ? Array.isArray(vl) ? vl : [vl] : []);
27762
- } else if (editVariant === "date" || editVariant === "date_time") {
27763
- dValues[cell.column.id] = cachedValue ?? (vl ? dayjs(vl).isValid() ? dayjs(vl) : void 0 : dayjs(row.original[cell.column.id]).isValid() ? dayjs(row.original[cell.column.id]) : void 0);
27764
- } else if (editVariant === "select" && valueKey2) {
27765
- const idValue = _.get(row.original, valueKey2);
27766
- const cellDefaultValue = (_f2 = (_e2 = cell.column.columnDef) == null ? void 0 : _e2.editProperties) == null ? void 0 : _f2.defaultValue;
27767
- const rawValue = idValue === void 0 || idValue === null ? "" : idValue;
27768
- dValues[cell.column.id] = cachedValue ?? ((rawValue === "" || rawValue === void 0 || rawValue === null) && cellDefaultValue !== void 0 ? cellDefaultValue : rawValue);
27769
- } else {
27770
- const rawValue = _.get(
27771
- row.original,
27772
- valueKey2,
27773
- row.original[cell.column.id]
27774
- );
27775
- const cellDefaultValue = (_h2 = (_g2 = cell.column.columnDef) == null ? void 0 : _g2.editProperties) == null ? void 0 : _h2.defaultValue;
27776
- dValues[cell.column.id] = cachedValue ?? ((rawValue === "" || rawValue === void 0 || rawValue === null) && cellDefaultValue !== void 0 ? cellDefaultValue : rawValue);
27777
- }
27760
+ }, [rawCustomFilter, editVariant, row, values]);
27761
+ const isFieldDisabled = React$1.useMemo(() => {
27762
+ const { disable } = fieldProperties;
27763
+ if (typeof disable === "function") {
27764
+ return Boolean(disable(row, row._valuesCache));
27765
+ }
27766
+ return Boolean(disable);
27767
+ }, [fieldProperties, row, values]);
27768
+ const shouldAutoFocus = React$1.useMemo(() => {
27769
+ const firstEditable = row.getAllCells().map((cell) => cell.column.columnDef).find(
27770
+ (def) => (def == null ? void 0 : def.enableEditing) === void 0 || (def == null ? void 0 : def.enableEditing) === true
27771
+ );
27772
+ return (firstEditable == null ? void 0 : firstEditable.accessorKey) === columnId;
27773
+ }, [row, columnId]);
27774
+ const columnDefaultValue = React$1.useMemo(
27775
+ () => readInitialValue(column, row),
27776
+ [column, row]
27777
+ );
27778
+ const currentValue = (values == null ? void 0 : values[columnId]) !== void 0 ? values[columnId] : columnDefaultValue;
27779
+ const dateValue = React$1.useMemo(() => {
27780
+ if (isBlank(currentValue)) return void 0;
27781
+ return dayjs(currentValue).isValid() ? dayjs(currentValue) : void 0;
27782
+ }, [currentValue]);
27783
+ const fieldError = errors == null ? void 0 : errors[columnId];
27784
+ const validate = React$1.useCallback(
27785
+ async (value) => {
27786
+ if (!validationSchema2) return;
27787
+ try {
27788
+ await validationSchema2.validateAt(
27789
+ columnId,
27790
+ { [columnId]: value },
27791
+ { abortEarly: false }
27792
+ );
27793
+ setValidationErrors((prev) => {
27794
+ if (!prev || prev[columnId] === void 0) return prev ?? {};
27795
+ const next = { ...prev };
27796
+ delete next[columnId];
27797
+ return next;
27798
+ });
27799
+ } catch (err) {
27800
+ if (err instanceof Yup__namespace.ValidationError) {
27801
+ const fieldErrors = {};
27802
+ err.inner.forEach((error) => {
27803
+ if (error.path) fieldErrors[error.path] = error.message;
27804
+ });
27805
+ if (!err.inner.length && err.path) {
27806
+ fieldErrors[err.path] = err.message;
27778
27807
  }
27808
+ setValidationErrors((prev) => ({ ...prev ?? {}, ...fieldErrors }));
27779
27809
  }
27780
- });
27781
- row._valuesCache = dValues;
27782
- setInputValue(dValues);
27783
- setIsInitialSet(true);
27784
- }
27785
- }, [row, editVariant, isInitialSet]);
27786
- const handleMinDate = (state) => typeof state == "function" ? state(row) : state;
27787
- return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(jsxRuntime.jsxRuntimeExports.Fragment, { children: [
27788
- (!editVariant || editVariant === "number") && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27810
+ }
27811
+ },
27812
+ [columnId, setValidationErrors, validationSchema2]
27813
+ );
27814
+ const handleChange = React$1.useCallback(
27815
+ async (event, type, selectedData) => {
27816
+ const value = extractValue(event, type);
27817
+ const optimistic = { ...row._valuesCache ?? {}, [columnId]: value };
27818
+ row._valuesCache = optimistic;
27819
+ setValues(optimistic);
27820
+ publishRowCache(rowId, optimistic);
27821
+ if (onChangeRowField) {
27822
+ const patch = await onChangeRowField(event, type, row, col, selectedData);
27823
+ if (patch) {
27824
+ const merged = { ...row._valuesCache, ...patch, [columnId]: value };
27825
+ row._valuesCache = merged;
27826
+ setValues(merged);
27827
+ publishRowCache(rowId, merged);
27828
+ }
27829
+ }
27830
+ await validate(value);
27831
+ },
27832
+ [col, columnId, onChangeRowField, row, rowId, validate]
27833
+ );
27834
+ const resolveDateBoundary = React$1.useCallback(
27835
+ (boundary) => typeof boundary === "function" ? boundary(row) : boundary,
27836
+ [row]
27837
+ );
27838
+ if (!editVariant || editVariant === "number") {
27839
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27789
27840
  appbar.TextField,
27790
27841
  {
27791
- defaultValue,
27792
- onChange: (e) => onChange(e, editVariant),
27793
- value: inputValue == null ? void 0 : inputValue[column.id],
27794
- autoFocus: ((_b = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _b.accessorKey) === column.id,
27842
+ defaultValue: columnDefaultValue,
27843
+ onChange: (e) => handleChange(e, editVariant),
27844
+ value: currentValue ?? "",
27845
+ autoFocus: shouldAutoFocus,
27795
27846
  type: editVariant || "text",
27796
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27797
- helperText: errors == null ? void 0 : errors[column.id],
27847
+ error: Boolean(fieldError),
27848
+ helperText: fieldError,
27798
27849
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || "",
27799
27850
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27800
- disabled: fieldDisbled
27851
+ disabled: isFieldDisabled
27801
27852
  }
27802
- ),
27803
- editVariant === "select" && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(material.Box, { display: "flex", flexDirection: "column", width: "100%", children: [
27853
+ );
27854
+ }
27855
+ if (editVariant === "select") {
27856
+ const isMultiple = Boolean(fieldProperties == null ? void 0 : fieldProperties.is_multiple);
27857
+ const selectValue = isMultiple ? Array.isArray(currentValue) ? currentValue : [] : currentValue ?? "";
27858
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(material.Box, { display: "flex", flexDirection: "column", width: "100%", children: [
27804
27859
  /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27805
27860
  SearchableSelect,
27806
27861
  {
27807
27862
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27808
- defaultValue,
27863
+ defaultValue: columnDefaultValue,
27809
27864
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || "",
27810
- searchPlaceholder: `Search ${col.header}`,
27811
- onChange: (e, row2) => onChange(e, "select", row2),
27865
+ searchPlaceholder: `Search ${(col == null ? void 0 : col.header) ?? ""}`,
27866
+ onChange: (e, selectedRow) => handleChange(e, "select", selectedRow),
27812
27867
  apiType: fieldProperties == null ? void 0 : fieldProperties.apiType,
27813
- autoFocus: ((_c = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _c.accessorKey) === column.id,
27868
+ autoFocus: shouldAutoFocus,
27814
27869
  options: col == null ? void 0 : col.editSelectOptions,
27815
- customeFilter: customFilter.current,
27870
+ customeFilter: customFilter,
27816
27871
  filterKey: fieldProperties == null ? void 0 : fieldProperties.filterKey,
27817
27872
  labelKey: fieldProperties == null ? void 0 : fieldProperties.labelKey,
27818
27873
  valueKey: fieldProperties == null ? void 0 : fieldProperties.bindingKey,
27819
- attributes: fieldProperties.attributes,
27874
+ attributes: fieldProperties == null ? void 0 : fieldProperties.attributes,
27820
27875
  isInternal: (fieldProperties == null ? void 0 : fieldProperties.isInternal) || !(fieldProperties == null ? void 0 : fieldProperties.apiType),
27821
- multiple: fieldProperties == null ? void 0 : fieldProperties.is_multiple,
27822
- value: (fieldProperties == null ? void 0 : fieldProperties.is_multiple) ? Array.isArray(inputValue == null ? void 0 : inputValue[column.id]) ? inputValue == null ? void 0 : inputValue[column.id] : [] : inputValue == null ? void 0 : inputValue[column.id],
27823
- getSelectedData: (row2) => getSelectedData(fieldProperties == null ? void 0 : fieldProperties.field_name, row2),
27824
- disabled: fieldDisbled
27876
+ multiple: isMultiple,
27877
+ value: selectValue,
27878
+ getSelectedData: (selectedRow) => getSelectedData == null ? void 0 : getSelectedData(fieldProperties == null ? void 0 : fieldProperties.field_name, selectedRow),
27879
+ disabled: isFieldDisabled
27825
27880
  }
27826
27881
  ),
27827
- (errors == null ? void 0 : errors[column.id]) && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useAuth.Typography, { color: "theme.error.600", type: "s5", children: errors == null ? void 0 : errors[column.id] })
27828
- ] }),
27829
- editVariant === "date" && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27882
+ fieldError && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useAuth.Typography, { color: "theme.error.600", type: "s5", children: fieldError })
27883
+ ] });
27884
+ }
27885
+ if (editVariant === "date") {
27886
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27830
27887
  DatePicker2,
27831
27888
  {
27832
27889
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27833
- defaultValue,
27834
- onChange: (v) => onChange(v, "date"),
27835
- textFieldProps: {
27836
- autoFocus: ((_d = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _d.accessorKey) === column.id
27837
- },
27838
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27839
- helperText: errors == null ? void 0 : errors[column.id],
27890
+ defaultValue: columnDefaultValue,
27891
+ onChange: (v) => handleChange(v, "date"),
27892
+ textFieldProps: { autoFocus: shouldAutoFocus },
27893
+ error: Boolean(fieldError),
27894
+ helperText: fieldError,
27840
27895
  format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
27841
27896
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
27842
- value: dayjs(row._valuesCache[column.id]).isValid() ? dayjs(row._valuesCache[column.id]) : void 0,
27843
- disabled: fieldDisbled,
27844
- minDate: () => handleMinDate(fieldProperties == null ? void 0 : fieldProperties.min_date),
27845
- maxDate: () => handleMinDate(fieldProperties == null ? void 0 : fieldProperties.min_date)
27897
+ value: dateValue,
27898
+ disabled: isFieldDisabled,
27899
+ minDate: () => resolveDateBoundary(fieldProperties == null ? void 0 : fieldProperties.min_date),
27900
+ maxDate: () => resolveDateBoundary(fieldProperties == null ? void 0 : fieldProperties.max_date)
27846
27901
  }
27847
- ),
27848
- editVariant === "date_time" && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27902
+ );
27903
+ }
27904
+ if (editVariant === "date_time") {
27905
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27849
27906
  DateTimePicker2,
27850
27907
  {
27851
27908
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27852
- defaultValue,
27853
- onChange: (v) => onChange(v, "date"),
27854
- textFieldProps: {
27855
- autoFocus: ((_e = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _e.accessorKey) === column.id
27856
- },
27857
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27858
- helperText: errors == null ? void 0 : errors[column.id],
27909
+ defaultValue: columnDefaultValue,
27910
+ onChange: (v) => handleChange(v, "date"),
27911
+ textFieldProps: { autoFocus: shouldAutoFocus },
27912
+ error: Boolean(fieldError),
27913
+ helperText: fieldError,
27859
27914
  format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
27860
27915
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
27861
- value: dayjs(row._valuesCache[column.id]).isValid() ? dayjs(row._valuesCache[column.id]) : void 0,
27862
- disabled: fieldDisbled
27916
+ value: dateValue,
27917
+ disabled: isFieldDisabled
27863
27918
  }
27864
- ),
27865
- (editVariant === "file" || editVariant === "image") && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(material.Box, { display: "flex", flexDirection: "column", children: [
27919
+ );
27920
+ }
27921
+ if (editVariant === "file" || editVariant === "image") {
27922
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsxs(material.Box, { display: "flex", flexDirection: "column", children: [
27866
27923
  /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27867
27924
  UploadMedia,
27868
27925
  {
@@ -27872,48 +27929,51 @@ const InlineEditFields = ({
27872
27929
  label: "",
27873
27930
  type: editVariant,
27874
27931
  max_size: 10,
27875
- onChange: (v) => onChange(v, "file"),
27876
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27877
- multiple: Boolean(column == null ? void 0 : column.is_multiple),
27878
- value: row._valuesCache[column.id]
27932
+ onChange: (v) => handleChange(v, "file"),
27933
+ error: Boolean(fieldError),
27934
+ multiple: Boolean((fieldProperties == null ? void 0 : fieldProperties.is_multiple) ?? (col == null ? void 0 : col.is_multiple)),
27935
+ value: currentValue
27879
27936
  }
27880
27937
  ),
27881
- (errors == null ? void 0 : errors[column.id]) && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useAuth.Typography, { color: "theme.error.600", type: "s5", children: errors == null ? void 0 : errors[column.id] })
27882
- ] }),
27883
- editVariant === "phone" && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27938
+ fieldError && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(useAuth.Typography, { color: "theme.error.600", type: "s5", children: fieldError })
27939
+ ] });
27940
+ }
27941
+ if (editVariant === "phone") {
27942
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27884
27943
  PhoneInput,
27885
27944
  {
27886
27945
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27887
- default_value: defaultValue,
27888
- onChange: (v) => onChange(v, "phone"),
27889
- textFieldProps: {
27890
- autoFocus: ((_f = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _f.accessorKey) === column.id
27891
- },
27892
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27893
- helperText: errors == null ? void 0 : errors[column.id],
27946
+ default_value: columnDefaultValue,
27947
+ onChange: (v) => handleChange(v, "phone"),
27948
+ textFieldProps: { autoFocus: shouldAutoFocus },
27949
+ error: Boolean(fieldError),
27950
+ helperText: fieldError,
27894
27951
  format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
27895
27952
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
27896
- value: (_g = row._valuesCache) == null ? void 0 : _g[column.id],
27897
- disabled: fieldDisbled,
27953
+ value: currentValue,
27954
+ disabled: isFieldDisabled,
27898
27955
  isInlineEditing: true
27899
27956
  }
27900
- ),
27901
- editVariant === "checkbox" && /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27957
+ );
27958
+ }
27959
+ if (editVariant === "checkbox") {
27960
+ return /* @__PURE__ */ jsxRuntime.jsxRuntimeExports.jsx(
27902
27961
  checkbox.Checkbox,
27903
27962
  {
27904
27963
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27905
- defaultChecked: Boolean(defaultValue),
27906
- onChange: (v) => onChange(v, "checkbox"),
27907
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27908
- helperText: errors == null ? void 0 : errors[column.id],
27909
- format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
27910
- placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
27911
- value: (_h = row._valuesCache) == null ? void 0 : _h[column.id],
27912
- disabled: fieldDisbled
27964
+ defaultChecked: Boolean(columnDefaultValue),
27965
+ onChange: (v) => handleChange(v, "checkbox"),
27966
+ error: Boolean(fieldError),
27967
+ helperText: fieldError,
27968
+ placeholder: fieldProperties == null ? void 0 : fieldProperties.placeholder,
27969
+ value: Boolean(currentValue),
27970
+ disabled: isFieldDisabled
27913
27971
  }
27914
- )
27915
- ] });
27972
+ );
27973
+ }
27974
+ return null;
27916
27975
  };
27976
+ const InlineEditFields = React$1.memo(InlineEditFields$1);
27917
27977
  const TableWrapper = material.styled(material.Box, {
27918
27978
  shouldForwardProp: (prop) => prop !== "disableMaxHeight"
27919
27979
  })(({ theme: { palette }, disableMaxHeight }) => {
@@ -41940,4 +42000,4 @@ exports.createPermissionConfig = createPermissionConfig;
41940
42000
  exports.dynamicSelectAdd = dynamicSelectAdd;
41941
42001
  exports.useThemeProps = useThemeProps;
41942
42002
  exports.userRoles = userRoles;
41943
- //# sourceMappingURL=android-12-switch-CoMylrig.js.map
42003
+ //# sourceMappingURL=android-12-switch-BgFAxJ9x.js.map