@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 @@ import * as React$1 from "react";
10
10
  import React__default, { memo, forwardRef, useRef, useState, useEffect, useCallback, useMemo, cloneElement, createElement } from "react";
11
11
  import { Controller, useWatch, useFormContext, useForm, FormProvider } from "react-hook-form";
12
12
  /* empty css */
13
- import { x as default_1$a, M as Modal, S as SearchBar, z as Typography$1, _ as _inheritsLoose, U as forceReflow, h as Transition, V as classNamesShape, f as ButtonBase, n as chainPropTypes, u as useTheme$4, W as useSlotProps, P as Paper, X as Fade, q as Modal$1, Y as Backdrop, Z as Portal, Q as refType, o as HTMLElementType, $ as Grow, a0 as FocusTrap, y as List, t as ListItem, a1 as TransitionGroup, a2 as isHostComponent, j as elementTypeAcceptingRef, K as Menu$1, k as getReactElementRef, G as resolveComponentProps, F as o, p as useRtl, N as MenuItem$1, a3 as MenuList, a4 as Divider$1, T as TextField$2, e as Tooltip$1, E as default_1$c, w as default_1$d, c as ConfirmPopUp, D as DynamicInput, d as Toast, m as elementAcceptingRef, a5 as exactProp, B as Box$1, b as Avatar } from "./appbar-DELlMlbx.esm.js";
13
+ import { x as default_1$a, M as Modal, S as SearchBar, z as Typography$1, _ as _inheritsLoose, U as forceReflow, h as Transition, V as classNamesShape, f as ButtonBase, n as chainPropTypes, u as useTheme$4, W as useSlotProps, P as Paper, X as Fade, q as Modal$1, Y as Backdrop, Z as Portal, Q as refType, o as HTMLElementType, $ as Grow, a0 as FocusTrap, y as List, t as ListItem, a1 as TransitionGroup, a2 as isHostComponent, j as elementTypeAcceptingRef, K as Menu$1, k as getReactElementRef, G as resolveComponentProps, F as o, p as useRtl, N as MenuItem$1, a3 as MenuList, a4 as Divider$1, T as TextField$2, e as Tooltip$1, E as default_1$c, w as default_1$d, c as ConfirmPopUp, D as DynamicInput, d as Toast, m as elementAcceptingRef, a5 as exactProp, B as Box$1, b as Avatar } from "./appbar-D1L6GTYk.esm.js";
14
14
  import { useTranslation } from "react-i18next";
15
15
  import { h as getDisplayName, e as extendSxProp, a as clsx, b as composeClasses, s as styled$3, g as generateUtilityClasses, c as createSvgIcon, i as require$$1, r as rootShouldForwardProp, f as reactIsExports, j as slotShouldForwardProp } from "./notification-_WEc_EZI.esm.js";
16
16
  import { C as Chip$1, a as DocumentPreview, M as Menu$2, t as transformTableColumns, f as formBuilderDeConversion } from "./form-builder-deconversion-BJ0TOUiY.esm.js";
@@ -27598,253 +27598,310 @@ const UploadMedia = memo((props) => {
27598
27598
  getSelectedFiles(value)
27599
27599
  ] });
27600
27600
  });
27601
+ const EMPTY_EDIT_PROPERTIES = Object.freeze({});
27602
+ const CACHE_NORMALISED = Symbol.for("erpsquad.inlineEdit.cacheNormalised");
27603
+ const isCacheNormalised = (cache) => Boolean(cache && cache[CACHE_NORMALISED]);
27604
+ const markCacheNormalised = (cache) => {
27605
+ cache[CACHE_NORMALISED] = true;
27606
+ return cache;
27607
+ };
27608
+ const isBlank = (value) => value === void 0 || value === null || value === "";
27609
+ const shallowEqual = (a = {}, b = {}) => {
27610
+ if (a === b) return true;
27611
+ const aKeys = Object.keys(a);
27612
+ const bKeys = Object.keys(b);
27613
+ if (aKeys.length !== bKeys.length) return false;
27614
+ return aKeys.every((key) => Object.is(a[key], b[key]));
27615
+ };
27616
+ const rowSubscribers = /* @__PURE__ */ new Map();
27617
+ const subscribeToRow = (rowId, listener) => {
27618
+ let listeners = rowSubscribers.get(rowId);
27619
+ if (!listeners) {
27620
+ listeners = /* @__PURE__ */ new Set();
27621
+ rowSubscribers.set(rowId, listeners);
27622
+ }
27623
+ listeners.add(listener);
27624
+ return () => {
27625
+ listeners == null ? void 0 : listeners.delete(listener);
27626
+ if (listeners && listeners.size === 0) rowSubscribers.delete(rowId);
27627
+ };
27628
+ };
27629
+ const publishRowCache = (rowId, cache) => {
27630
+ var _a;
27631
+ (_a = rowSubscribers.get(rowId)) == null ? void 0 : _a.forEach((listener) => listener(cache));
27632
+ };
27633
+ const readInitialValue = (mrtColumn, row) => {
27634
+ var _a;
27635
+ const columnDef = (mrtColumn == null ? void 0 : mrtColumn.columnDef) ?? {};
27636
+ const columnId = mrtColumn == null ? void 0 : mrtColumn.id;
27637
+ const {
27638
+ valueKey,
27639
+ is_multiple: isMultiple,
27640
+ defaultValue
27641
+ } = columnDef.editProperties ?? EMPTY_EDIT_PROPERTIES;
27642
+ const variant = columnDef.editVariant;
27643
+ const accessorValue = (_a = row == null ? void 0 : row.original) == null ? void 0 : _a[columnId];
27644
+ const boundValue = valueKey ? _.get(row == null ? void 0 : row.original, valueKey) : accessorValue;
27645
+ const accessorIsSafeFallback = !valueKey || valueKey === columnId;
27646
+ const rawValue = boundValue !== void 0 ? boundValue : accessorIsSafeFallback ? accessorValue : void 0;
27647
+ if (variant === "select" && isMultiple) {
27648
+ if (isBlank(boundValue)) return defaultValue ?? [];
27649
+ return Array.isArray(boundValue) ? boundValue : [boundValue];
27650
+ }
27651
+ if (variant === "date" || variant === "date_time") {
27652
+ const dateSource = boundValue !== void 0 ? boundValue : accessorValue;
27653
+ if (isBlank(dateSource)) return void 0;
27654
+ return dayjs(dateSource).isValid() ? dayjs(dateSource) : void 0;
27655
+ }
27656
+ if (variant === "select") {
27657
+ return isBlank(boundValue) ? defaultValue ?? "" : boundValue;
27658
+ }
27659
+ if (variant === "checkbox") {
27660
+ return isBlank(rawValue) ? Boolean(defaultValue) : Boolean(rawValue);
27661
+ }
27662
+ return isBlank(rawValue) && defaultValue !== void 0 ? defaultValue : rawValue;
27663
+ };
27664
+ const buildInitialCache = (row) => {
27665
+ const cache = {};
27666
+ row.getAllCells().forEach((cell) => {
27667
+ var _a;
27668
+ const enableEditing = (_a = cell.column.columnDef) == null ? void 0 : _a.enableEditing;
27669
+ if (enableEditing === void 0 || enableEditing === true) {
27670
+ cache[cell.column.id] = readInitialValue(cell.column, row);
27671
+ }
27672
+ });
27673
+ return markCacheNormalised(cache);
27674
+ };
27675
+ const extractValue = (event, type) => {
27676
+ var _a;
27677
+ switch (type) {
27678
+ case "date":
27679
+ case "file":
27680
+ case "image":
27681
+ case "phone":
27682
+ return event;
27683
+ case "checkbox":
27684
+ return (_a = event == null ? void 0 : event.target) == null ? void 0 : _a.checked;
27685
+ default:
27686
+ return (event == null ? void 0 : event.target) ? event.target.value : event;
27687
+ }
27688
+ };
27601
27689
  const InlineEditFields = ({
27602
- // cell,
27603
27690
  column,
27604
27691
  row,
27605
- // table,
27606
27692
  col,
27607
- // callback,
27608
27693
  errors,
27609
27694
  validationSchema: validationSchema2,
27610
27695
  setValidationErrors,
27611
27696
  onChangeRowField,
27612
27697
  getSelectedData
27613
27698
  }) => {
27614
- var _a, _b, _c, _d, _e, _f, _g, _h;
27615
- const [inputValue, setInputValue] = useState();
27616
- const [isInitialSet, setIsInitialSet] = useState(false);
27617
- const customFilter = useRef(null);
27618
- const editCols = row.getAllCells().map((col2) => col2.column.columnDef).filter(
27619
- (col2) => (col2 == null ? void 0 : col2.enableEditing) === void 0 || (col2 == null ? void 0 : col2.enableEditing) === true
27699
+ var _a;
27700
+ const [values, setValues] = useState(() => (row == null ? void 0 : row._valuesCache) ?? {});
27701
+ const [customFilter, setCustomFilter] = useState(null);
27702
+ const editVariant = col == null ? void 0 : col.editVariant;
27703
+ const fieldProperties = ((_a = column.columnDef) == null ? void 0 : _a.editProperties) ?? EMPTY_EDIT_PROPERTIES;
27704
+ const columnId = column.id;
27705
+ const rowId = row.id;
27706
+ useEffect(
27707
+ () => subscribeToRow(rowId, (cache) => {
27708
+ setValues((prev) => shallowEqual(prev, cache) ? prev : cache);
27709
+ }),
27710
+ [rowId]
27620
27711
  );
27621
- const editVariant = col.editVariant;
27622
- const fieldProperties = ((_a = column.columnDef) == null ? void 0 : _a.editProperties) || {};
27623
- let fieldDisbled = false;
27624
- if (fieldProperties == null ? void 0 : fieldProperties.disable) {
27625
- if (typeof fieldProperties.disable === "function") {
27626
- fieldDisbled = Boolean(fieldProperties == null ? void 0 : fieldProperties.disable(row, row._valuesCache));
27627
- } else {
27628
- fieldDisbled = Boolean(fieldProperties.disable);
27629
- }
27630
- }
27631
- const handleCustomFilter = useCallback(async (row2, values) => {
27632
- try {
27633
- if (typeof fieldProperties.customeFilter === "function") {
27634
- const filter = await fieldProperties.customeFilter(row2, values);
27635
- customFilter.current = filter;
27636
- return filter;
27637
- } else {
27638
- customFilter.current = fieldProperties == null ? void 0 : fieldProperties.customeFilter;
27639
- }
27640
- } catch (error) {
27641
- return null;
27642
- }
27643
- }, [fieldProperties, row, row._valuesCache]);
27644
27712
  useEffect(() => {
27645
- handleCustomFilter(row, row._valuesCache);
27646
- }, [handleCustomFilter, row, row._valuesCache]);
27647
- const valueKey = fieldProperties == null ? void 0 : fieldProperties.valueKey;
27648
- let defaultValue = "";
27649
- if (editVariant === "select" && (fieldProperties == null ? void 0 : fieldProperties.is_multiple)) {
27650
- defaultValue = valueKey ? _.get(row.original, valueKey, []) : [];
27651
- } else {
27652
- defaultValue = valueKey ? _.get(row.original, valueKey, row.original[column.id]) : row.original[column.id];
27653
- }
27654
- const validate = async (value) => {
27655
- try {
27656
- await validationSchema2.validateAt(
27657
- column.id,
27658
- {
27659
- [column.id]: value
27660
- },
27661
- {
27662
- abortEarly: false
27663
- }
27664
- );
27665
- const fe = {};
27666
- for (const e in errors) {
27667
- if (e != column.id) {
27668
- fe[e] = errors[e];
27669
- }
27670
- }
27671
- setValidationErrors(fe);
27672
- } catch (err) {
27673
- if (err instanceof Yup.ValidationError) {
27674
- const e = {};
27675
- err.inner.forEach((error) => {
27676
- if (error.path) {
27677
- e[error.path] = error.message;
27678
- }
27679
- });
27680
- const em = { ...errors, ...e };
27681
- setValidationErrors(em);
27682
- }
27683
- }
27684
- };
27685
- const onChange = async (e, type, selectedData) => {
27686
- const data = selectedData;
27687
- let value;
27688
- switch (type) {
27689
- case "date":
27690
- case "file":
27691
- case "image":
27692
- case "phone":
27693
- value = e;
27694
- break;
27695
- case "text":
27696
- case "number":
27697
- value = e.target.value;
27698
- break;
27699
- case "checkbox":
27700
- value = e.target.checked;
27701
- break;
27702
- default:
27703
- value = e.target.value;
27704
- break;
27705
- }
27706
- setInputValue({ ...inputValue, [column.id]: value });
27707
- if (onChangeRowField) {
27708
- const v = await onChangeRowField(e, type, row, col, data);
27709
- if (v) {
27710
- row._valuesCache = { ...row._valuesCache, ...v };
27711
- }
27713
+ const existing = row._valuesCache;
27714
+ if (isCacheNormalised(existing)) {
27715
+ setValues(existing);
27716
+ return;
27712
27717
  }
27713
- row._valuesCache = { ...row._valuesCache, [column.id]: value };
27714
- const updatedCache = { ...row._valuesCache };
27715
- setInputValue(updatedCache);
27716
- window.dispatchEvent(new CustomEvent("row-cache-updated", { detail: { rowId: row.id, cache: updatedCache } }));
27717
- await validate(value);
27718
- };
27719
- useEffect(() => {
27720
- setInputValue({ ...inputValue, ...row._valuesCache });
27721
- }, [row._valuesCache]);
27718
+ const seeded = buildInitialCache(row);
27719
+ row._valuesCache = seeded;
27720
+ setValues(seeded);
27721
+ publishRowCache(rowId, seeded);
27722
+ }, [rowId]);
27723
+ const rawCustomFilter = fieldProperties.customeFilter;
27722
27724
  useEffect(() => {
27723
- const handleCacheUpdate = (e) => {
27724
- if (e.detail.rowId === row.id) {
27725
- setInputValue({ ...e.detail.cache });
27725
+ if (editVariant !== "select" || rawCustomFilter === void 0) return;
27726
+ if (typeof rawCustomFilter !== "function") {
27727
+ setCustomFilter(rawCustomFilter ?? null);
27728
+ return;
27729
+ }
27730
+ let cancelled = false;
27731
+ (async () => {
27732
+ try {
27733
+ const filter = await rawCustomFilter(row, row._valuesCache);
27734
+ if (!cancelled) setCustomFilter(filter ?? null);
27735
+ } catch {
27736
+ if (!cancelled) setCustomFilter(null);
27726
27737
  }
27738
+ })();
27739
+ return () => {
27740
+ cancelled = true;
27727
27741
  };
27728
- window.addEventListener("row-cache-updated", handleCacheUpdate);
27729
- return () => window.removeEventListener("row-cache-updated", handleCacheUpdate);
27730
- }, [row.id]);
27731
- useEffect(() => {
27732
- if (!isInitialSet) {
27733
- const editFields = Object.keys(row._valuesCache || {});
27734
- const dValues = {};
27735
- row.getAllCells().forEach((cell) => {
27736
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
27737
- if (((_a2 = cell.column.columnDef) == null ? void 0 : _a2.enableEditing) === void 0 || ((_b2 = cell.column.columnDef) == null ? void 0 : _b2.enableEditing) === true) {
27738
- const { is_multiple, valueKey: valueKey2 } = ((_c2 = cell.column.columnDef) == null ? void 0 : _c2.editProperties) || {};
27739
- if (editFields.length === 0 || editFields.includes(cell.column.id)) {
27740
- const cachedValue = (_d2 = row._valuesCache) == null ? void 0 : _d2[cell.column.id];
27741
- const vl = _.get(row.original, valueKey2);
27742
- if (editVariant === "select" && is_multiple) {
27743
- dValues[cell.column.id] = cachedValue ?? (vl ? Array.isArray(vl) ? vl : [vl] : []);
27744
- } else if (editVariant === "date" || editVariant === "date_time") {
27745
- 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);
27746
- } else if (editVariant === "select" && valueKey2) {
27747
- const idValue = _.get(row.original, valueKey2);
27748
- const cellDefaultValue = (_f2 = (_e2 = cell.column.columnDef) == null ? void 0 : _e2.editProperties) == null ? void 0 : _f2.defaultValue;
27749
- const rawValue = idValue === void 0 || idValue === null ? "" : idValue;
27750
- dValues[cell.column.id] = cachedValue ?? ((rawValue === "" || rawValue === void 0 || rawValue === null) && cellDefaultValue !== void 0 ? cellDefaultValue : rawValue);
27751
- } else {
27752
- const rawValue = _.get(
27753
- row.original,
27754
- valueKey2,
27755
- row.original[cell.column.id]
27756
- );
27757
- const cellDefaultValue = (_h2 = (_g2 = cell.column.columnDef) == null ? void 0 : _g2.editProperties) == null ? void 0 : _h2.defaultValue;
27758
- dValues[cell.column.id] = cachedValue ?? ((rawValue === "" || rawValue === void 0 || rawValue === null) && cellDefaultValue !== void 0 ? cellDefaultValue : rawValue);
27759
- }
27742
+ }, [rawCustomFilter, editVariant, row, values]);
27743
+ const isFieldDisabled = useMemo(() => {
27744
+ const { disable } = fieldProperties;
27745
+ if (typeof disable === "function") {
27746
+ return Boolean(disable(row, row._valuesCache));
27747
+ }
27748
+ return Boolean(disable);
27749
+ }, [fieldProperties, row, values]);
27750
+ const shouldAutoFocus = useMemo(() => {
27751
+ const firstEditable = row.getAllCells().map((cell) => cell.column.columnDef).find(
27752
+ (def) => (def == null ? void 0 : def.enableEditing) === void 0 || (def == null ? void 0 : def.enableEditing) === true
27753
+ );
27754
+ return (firstEditable == null ? void 0 : firstEditable.accessorKey) === columnId;
27755
+ }, [row, columnId]);
27756
+ const columnDefaultValue = useMemo(
27757
+ () => readInitialValue(column, row),
27758
+ [column, row]
27759
+ );
27760
+ const currentValue = (values == null ? void 0 : values[columnId]) !== void 0 ? values[columnId] : columnDefaultValue;
27761
+ const dateValue = useMemo(() => {
27762
+ if (isBlank(currentValue)) return void 0;
27763
+ return dayjs(currentValue).isValid() ? dayjs(currentValue) : void 0;
27764
+ }, [currentValue]);
27765
+ const fieldError = errors == null ? void 0 : errors[columnId];
27766
+ const validate = useCallback(
27767
+ async (value) => {
27768
+ if (!validationSchema2) return;
27769
+ try {
27770
+ await validationSchema2.validateAt(
27771
+ columnId,
27772
+ { [columnId]: value },
27773
+ { abortEarly: false }
27774
+ );
27775
+ setValidationErrors((prev) => {
27776
+ if (!prev || prev[columnId] === void 0) return prev ?? {};
27777
+ const next = { ...prev };
27778
+ delete next[columnId];
27779
+ return next;
27780
+ });
27781
+ } catch (err) {
27782
+ if (err instanceof Yup.ValidationError) {
27783
+ const fieldErrors = {};
27784
+ err.inner.forEach((error) => {
27785
+ if (error.path) fieldErrors[error.path] = error.message;
27786
+ });
27787
+ if (!err.inner.length && err.path) {
27788
+ fieldErrors[err.path] = err.message;
27760
27789
  }
27790
+ setValidationErrors((prev) => ({ ...prev ?? {}, ...fieldErrors }));
27761
27791
  }
27762
- });
27763
- row._valuesCache = dValues;
27764
- setInputValue(dValues);
27765
- setIsInitialSet(true);
27766
- }
27767
- }, [row, editVariant, isInitialSet]);
27768
- const handleMinDate = (state) => typeof state == "function" ? state(row) : state;
27769
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
27770
- (!editVariant || editVariant === "number") && /* @__PURE__ */ jsxRuntimeExports.jsx(
27792
+ }
27793
+ },
27794
+ [columnId, setValidationErrors, validationSchema2]
27795
+ );
27796
+ const handleChange = useCallback(
27797
+ async (event, type, selectedData) => {
27798
+ const value = extractValue(event, type);
27799
+ const optimistic = { ...row._valuesCache ?? {}, [columnId]: value };
27800
+ row._valuesCache = optimistic;
27801
+ setValues(optimistic);
27802
+ publishRowCache(rowId, optimistic);
27803
+ if (onChangeRowField) {
27804
+ const patch = await onChangeRowField(event, type, row, col, selectedData);
27805
+ if (patch) {
27806
+ const merged = { ...row._valuesCache, ...patch, [columnId]: value };
27807
+ row._valuesCache = merged;
27808
+ setValues(merged);
27809
+ publishRowCache(rowId, merged);
27810
+ }
27811
+ }
27812
+ await validate(value);
27813
+ },
27814
+ [col, columnId, onChangeRowField, row, rowId, validate]
27815
+ );
27816
+ const resolveDateBoundary = useCallback(
27817
+ (boundary) => typeof boundary === "function" ? boundary(row) : boundary,
27818
+ [row]
27819
+ );
27820
+ if (!editVariant || editVariant === "number") {
27821
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
27771
27822
  TextField$2,
27772
27823
  {
27773
- defaultValue,
27774
- onChange: (e) => onChange(e, editVariant),
27775
- value: inputValue == null ? void 0 : inputValue[column.id],
27776
- autoFocus: ((_b = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _b.accessorKey) === column.id,
27824
+ defaultValue: columnDefaultValue,
27825
+ onChange: (e) => handleChange(e, editVariant),
27826
+ value: currentValue ?? "",
27827
+ autoFocus: shouldAutoFocus,
27777
27828
  type: editVariant || "text",
27778
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27779
- helperText: errors == null ? void 0 : errors[column.id],
27829
+ error: Boolean(fieldError),
27830
+ helperText: fieldError,
27780
27831
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || "",
27781
27832
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27782
- disabled: fieldDisbled
27833
+ disabled: isFieldDisabled
27783
27834
  }
27784
- ),
27785
- editVariant === "select" && /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { display: "flex", flexDirection: "column", width: "100%", children: [
27835
+ );
27836
+ }
27837
+ if (editVariant === "select") {
27838
+ const isMultiple = Boolean(fieldProperties == null ? void 0 : fieldProperties.is_multiple);
27839
+ const selectValue = isMultiple ? Array.isArray(currentValue) ? currentValue : [] : currentValue ?? "";
27840
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { display: "flex", flexDirection: "column", width: "100%", children: [
27786
27841
  /* @__PURE__ */ jsxRuntimeExports.jsx(
27787
27842
  SearchableSelect,
27788
27843
  {
27789
27844
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27790
- defaultValue,
27845
+ defaultValue: columnDefaultValue,
27791
27846
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || "",
27792
- searchPlaceholder: `Search ${col.header}`,
27793
- onChange: (e, row2) => onChange(e, "select", row2),
27847
+ searchPlaceholder: `Search ${(col == null ? void 0 : col.header) ?? ""}`,
27848
+ onChange: (e, selectedRow) => handleChange(e, "select", selectedRow),
27794
27849
  apiType: fieldProperties == null ? void 0 : fieldProperties.apiType,
27795
- autoFocus: ((_c = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _c.accessorKey) === column.id,
27850
+ autoFocus: shouldAutoFocus,
27796
27851
  options: col == null ? void 0 : col.editSelectOptions,
27797
- customeFilter: customFilter.current,
27852
+ customeFilter: customFilter,
27798
27853
  filterKey: fieldProperties == null ? void 0 : fieldProperties.filterKey,
27799
27854
  labelKey: fieldProperties == null ? void 0 : fieldProperties.labelKey,
27800
27855
  valueKey: fieldProperties == null ? void 0 : fieldProperties.bindingKey,
27801
- attributes: fieldProperties.attributes,
27856
+ attributes: fieldProperties == null ? void 0 : fieldProperties.attributes,
27802
27857
  isInternal: (fieldProperties == null ? void 0 : fieldProperties.isInternal) || !(fieldProperties == null ? void 0 : fieldProperties.apiType),
27803
- multiple: fieldProperties == null ? void 0 : fieldProperties.is_multiple,
27804
- 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],
27805
- getSelectedData: (row2) => getSelectedData(fieldProperties == null ? void 0 : fieldProperties.field_name, row2),
27806
- disabled: fieldDisbled
27858
+ multiple: isMultiple,
27859
+ value: selectValue,
27860
+ getSelectedData: (selectedRow) => getSelectedData == null ? void 0 : getSelectedData(fieldProperties == null ? void 0 : fieldProperties.field_name, selectedRow),
27861
+ disabled: isFieldDisabled
27807
27862
  }
27808
27863
  ),
27809
- (errors == null ? void 0 : errors[column.id]) && /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { color: "theme.error.600", type: "s5", children: errors == null ? void 0 : errors[column.id] })
27810
- ] }),
27811
- editVariant === "date" && /* @__PURE__ */ jsxRuntimeExports.jsx(
27864
+ fieldError && /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { color: "theme.error.600", type: "s5", children: fieldError })
27865
+ ] });
27866
+ }
27867
+ if (editVariant === "date") {
27868
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
27812
27869
  DatePicker2,
27813
27870
  {
27814
27871
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27815
- defaultValue,
27816
- onChange: (v) => onChange(v, "date"),
27817
- textFieldProps: {
27818
- autoFocus: ((_d = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _d.accessorKey) === column.id
27819
- },
27820
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27821
- helperText: errors == null ? void 0 : errors[column.id],
27872
+ defaultValue: columnDefaultValue,
27873
+ onChange: (v) => handleChange(v, "date"),
27874
+ textFieldProps: { autoFocus: shouldAutoFocus },
27875
+ error: Boolean(fieldError),
27876
+ helperText: fieldError,
27822
27877
  format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
27823
27878
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
27824
- value: dayjs(row._valuesCache[column.id]).isValid() ? dayjs(row._valuesCache[column.id]) : void 0,
27825
- disabled: fieldDisbled,
27826
- minDate: () => handleMinDate(fieldProperties == null ? void 0 : fieldProperties.min_date),
27827
- maxDate: () => handleMinDate(fieldProperties == null ? void 0 : fieldProperties.min_date)
27879
+ value: dateValue,
27880
+ disabled: isFieldDisabled,
27881
+ minDate: () => resolveDateBoundary(fieldProperties == null ? void 0 : fieldProperties.min_date),
27882
+ maxDate: () => resolveDateBoundary(fieldProperties == null ? void 0 : fieldProperties.max_date)
27828
27883
  }
27829
- ),
27830
- editVariant === "date_time" && /* @__PURE__ */ jsxRuntimeExports.jsx(
27884
+ );
27885
+ }
27886
+ if (editVariant === "date_time") {
27887
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
27831
27888
  DateTimePicker2,
27832
27889
  {
27833
27890
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27834
- defaultValue,
27835
- onChange: (v) => onChange(v, "date"),
27836
- textFieldProps: {
27837
- autoFocus: ((_e = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _e.accessorKey) === column.id
27838
- },
27839
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27840
- helperText: errors == null ? void 0 : errors[column.id],
27891
+ defaultValue: columnDefaultValue,
27892
+ onChange: (v) => handleChange(v, "date"),
27893
+ textFieldProps: { autoFocus: shouldAutoFocus },
27894
+ error: Boolean(fieldError),
27895
+ helperText: fieldError,
27841
27896
  format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
27842
27897
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
27843
- value: dayjs(row._valuesCache[column.id]).isValid() ? dayjs(row._valuesCache[column.id]) : void 0,
27844
- disabled: fieldDisbled
27898
+ value: dateValue,
27899
+ disabled: isFieldDisabled
27845
27900
  }
27846
- ),
27847
- (editVariant === "file" || editVariant === "image") && /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { display: "flex", flexDirection: "column", children: [
27901
+ );
27902
+ }
27903
+ if (editVariant === "file" || editVariant === "image") {
27904
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { display: "flex", flexDirection: "column", children: [
27848
27905
  /* @__PURE__ */ jsxRuntimeExports.jsx(
27849
27906
  UploadMedia,
27850
27907
  {
@@ -27854,48 +27911,51 @@ const InlineEditFields = ({
27854
27911
  label: "",
27855
27912
  type: editVariant,
27856
27913
  max_size: 10,
27857
- onChange: (v) => onChange(v, "file"),
27858
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27859
- multiple: Boolean(column == null ? void 0 : column.is_multiple),
27860
- value: row._valuesCache[column.id]
27914
+ onChange: (v) => handleChange(v, "file"),
27915
+ error: Boolean(fieldError),
27916
+ multiple: Boolean((fieldProperties == null ? void 0 : fieldProperties.is_multiple) ?? (col == null ? void 0 : col.is_multiple)),
27917
+ value: currentValue
27861
27918
  }
27862
27919
  ),
27863
- (errors == null ? void 0 : errors[column.id]) && /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { color: "theme.error.600", type: "s5", children: errors == null ? void 0 : errors[column.id] })
27864
- ] }),
27865
- editVariant === "phone" && /* @__PURE__ */ jsxRuntimeExports.jsx(
27920
+ fieldError && /* @__PURE__ */ jsxRuntimeExports.jsx(Typography, { color: "theme.error.600", type: "s5", children: fieldError })
27921
+ ] });
27922
+ }
27923
+ if (editVariant === "phone") {
27924
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
27866
27925
  PhoneInput,
27867
27926
  {
27868
27927
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27869
- default_value: defaultValue,
27870
- onChange: (v) => onChange(v, "phone"),
27871
- textFieldProps: {
27872
- autoFocus: ((_f = editCols == null ? void 0 : editCols[0]) == null ? void 0 : _f.accessorKey) === column.id
27873
- },
27874
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27875
- helperText: errors == null ? void 0 : errors[column.id],
27928
+ default_value: columnDefaultValue,
27929
+ onChange: (v) => handleChange(v, "phone"),
27930
+ textFieldProps: { autoFocus: shouldAutoFocus },
27931
+ error: Boolean(fieldError),
27932
+ helperText: fieldError,
27876
27933
  format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
27877
27934
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
27878
- value: (_g = row._valuesCache) == null ? void 0 : _g[column.id],
27879
- disabled: fieldDisbled,
27935
+ value: currentValue,
27936
+ disabled: isFieldDisabled,
27880
27937
  isInlineEditing: true
27881
27938
  }
27882
- ),
27883
- editVariant === "checkbox" && /* @__PURE__ */ jsxRuntimeExports.jsx(
27939
+ );
27940
+ }
27941
+ if (editVariant === "checkbox") {
27942
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
27884
27943
  Checkbox,
27885
27944
  {
27886
27945
  name: (fieldProperties == null ? void 0 : fieldProperties.field_name) || "",
27887
- defaultChecked: Boolean(defaultValue),
27888
- onChange: (v) => onChange(v, "checkbox"),
27889
- error: (errors == null ? void 0 : errors[column.id]) ? true : false,
27890
- helperText: errors == null ? void 0 : errors[column.id],
27891
- format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
27892
- placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
27893
- value: (_h = row._valuesCache) == null ? void 0 : _h[column.id],
27894
- disabled: fieldDisbled
27946
+ defaultChecked: Boolean(columnDefaultValue),
27947
+ onChange: (v) => handleChange(v, "checkbox"),
27948
+ error: Boolean(fieldError),
27949
+ helperText: fieldError,
27950
+ placeholder: fieldProperties == null ? void 0 : fieldProperties.placeholder,
27951
+ value: Boolean(currentValue),
27952
+ disabled: isFieldDisabled
27895
27953
  }
27896
- )
27897
- ] });
27954
+ );
27955
+ }
27956
+ return null;
27898
27957
  };
27958
+ const InlineEditFields$1 = React__default.memo(InlineEditFields);
27899
27959
  const TableWrapper = styled$2(Box, {
27900
27960
  shouldForwardProp: (prop) => prop !== "disableMaxHeight"
27901
27961
  })(({ theme: { palette }, disableMaxHeight }) => {
@@ -28318,7 +28378,7 @@ const MaterialTable = React__default.memo(({
28318
28378
  ...editDisplayMode === "row" ? {
28319
28379
  Edit: ({ cell, row: row2, table: table2, column }) => {
28320
28380
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
28321
- InlineEditFields,
28381
+ InlineEditFields$1,
28322
28382
  {
28323
28383
  cell,
28324
28384
  column,
@@ -41928,4 +41988,4 @@ export {
41928
41988
  DynamicTagsInput as y,
41929
41989
  DynamicTime as z
41930
41990
  };
41931
- //# sourceMappingURL=android-12-switch-CJmu5zpr.esm.js.map
41991
+ //# sourceMappingURL=android-12-switch-DoExcS1P.esm.js.map