@erpsquad/common 1.10.17 → 1.10.19

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 (59) hide show
  1. package/dist/chunks/{android-12-switch-Nw977vtV.esm.js → android-12-switch-BJGIDwYR.esm.js} +131 -80
  2. package/dist/chunks/android-12-switch-BJGIDwYR.esm.js.map +1 -0
  3. package/dist/chunks/{android-12-switch-DQG8As1Y.js → android-12-switch-PEYCUiaq.js} +131 -80
  4. package/dist/chunks/android-12-switch-PEYCUiaq.js.map +1 -0
  5. package/dist/chunks/{appbar-CGe_OPDv.js → appbar-rUKxg-G7.js} +3 -2
  6. package/dist/chunks/{appbar-CGe_OPDv.js.map → appbar-rUKxg-G7.js.map} +1 -1
  7. package/dist/chunks/{appbar-KrkQiVAV.esm.js → appbar-zELMJiqH.esm.js} +3 -2
  8. package/dist/chunks/{appbar-KrkQiVAV.esm.js.map → appbar-zELMJiqH.esm.js.map} +1 -1
  9. package/dist/chunks/{default-data-pmy2guR7.js → default-data-COIp_txP.js} +4 -4
  10. package/dist/chunks/{default-data-pmy2guR7.js.map → default-data-COIp_txP.js.map} +1 -1
  11. package/dist/chunks/{default-data-Dt8HLhhG.esm.js → default-data-Ceg98EuN.esm.js} +4 -4
  12. package/dist/chunks/{default-data-Dt8HLhhG.esm.js.map → default-data-Ceg98EuN.esm.js.map} +1 -1
  13. package/dist/chunks/{form-builder-deconversion-DLGJdpXM.esm.js → form-builder-deconversion-B4OuGvBB.esm.js} +6 -2
  14. package/dist/chunks/form-builder-deconversion-B4OuGvBB.esm.js.map +1 -0
  15. package/dist/chunks/{form-builder-deconversion-D5-FPTEJ.js → form-builder-deconversion-BcmOEnG9.js} +6 -2
  16. package/dist/chunks/form-builder-deconversion-BcmOEnG9.js.map +1 -0
  17. package/dist/chunks/{fullScreen-8kPj1_fu.esm.js → fullScreen-BZgvFEKI.esm.js} +2 -2
  18. package/dist/chunks/{fullScreen-8kPj1_fu.esm.js.map → fullScreen-BZgvFEKI.esm.js.map} +1 -1
  19. package/dist/chunks/{fullScreen-DZWgEHUi.js → fullScreen-CSJaBvxv.js} +2 -2
  20. package/dist/chunks/{fullScreen-DZWgEHUi.js.map → fullScreen-CSJaBvxv.js.map} +1 -1
  21. package/dist/chunks/{sidebar-BeSjxulx.esm.js → sidebar-BXrUlb1O.esm.js} +2 -2
  22. package/dist/chunks/{sidebar-BeSjxulx.esm.js.map → sidebar-BXrUlb1O.esm.js.map} +1 -1
  23. package/dist/chunks/{sidebar-DKHIqaS0.js → sidebar-BbJUAEIV.js} +2 -2
  24. package/dist/chunks/{sidebar-DKHIqaS0.js.map → sidebar-BbJUAEIV.js.map} +1 -1
  25. package/dist/chunks/{sidebarScreen-Ca2YjEI4.js → sidebarScreen-DnI42_mr.js} +3 -3
  26. package/dist/chunks/{sidebarScreen-Ca2YjEI4.js.map → sidebarScreen-DnI42_mr.js.map} +1 -1
  27. package/dist/chunks/{sidebarScreen-DQWQqmvK.esm.js → sidebarScreen-NlMW1w_l.esm.js} +3 -3
  28. package/dist/chunks/{sidebarScreen-DQWQqmvK.esm.js.map → sidebarScreen-NlMW1w_l.esm.js.map} +1 -1
  29. package/dist/chunks/{uom-field-wrapper-DjrmGUaV.js → uom-field-wrapper-BsTblyVT.js} +91 -15
  30. package/dist/chunks/uom-field-wrapper-BsTblyVT.js.map +1 -0
  31. package/dist/chunks/{uom-field-wrapper-Db0m4mhG.esm.js → uom-field-wrapper-D0YgJsP5.esm.js} +91 -15
  32. package/dist/chunks/uom-field-wrapper-D0YgJsP5.esm.js.map +1 -0
  33. package/dist/components/department-add-modal.d.ts +8 -1
  34. package/dist/components/designation-add-modal.d.ts +9 -1
  35. package/dist/components/form-control/form-builder/form-builder-element/dynamic-select.d.ts +1 -0
  36. package/dist/components/index.esm.js +5 -5
  37. package/dist/components/index.js +5 -5
  38. package/dist/components/team-add-modal.d.ts +7 -1
  39. package/dist/hooks/useSetDefaultConfig.d.ts +2 -1
  40. package/dist/index.esm.js +8 -8
  41. package/dist/index.js +8 -8
  42. package/dist/layout/index.esm.js +2 -2
  43. package/dist/layout/index.js +2 -2
  44. package/dist/src/components/department-add-modal.d.ts +8 -1
  45. package/dist/src/components/designation-add-modal.d.ts +9 -1
  46. package/dist/src/components/form-control/form-builder/form-builder-element/dynamic-select.d.ts +1 -0
  47. package/dist/src/components/team-add-modal.d.ts +7 -1
  48. package/dist/src/hooks/useSetDefaultConfig.d.ts +2 -1
  49. package/dist/utils/index.esm.js +1 -1
  50. package/dist/utils/index.js +1 -1
  51. package/dist/views/index.esm.js +5 -5
  52. package/dist/views/index.js +4 -4
  53. package/package.json +1 -1
  54. package/dist/chunks/android-12-switch-DQG8As1Y.js.map +0 -1
  55. package/dist/chunks/android-12-switch-Nw977vtV.esm.js.map +0 -1
  56. package/dist/chunks/form-builder-deconversion-D5-FPTEJ.js.map +0 -1
  57. package/dist/chunks/form-builder-deconversion-DLGJdpXM.esm.js.map +0 -1
  58. package/dist/chunks/uom-field-wrapper-Db0m4mhG.esm.js.map +0 -1
  59. package/dist/chunks/uom-field-wrapper-DjrmGUaV.js.map +0 -1
@@ -2,8 +2,8 @@ import { j as jsxRuntimeExports } from "./jsx-runtime-ClFauRgV.esm.js";
2
2
  import { useFieldArray, Controller, useForm, useFormContext } from "react-hook-form";
3
3
  import { P as PropTypes, e as _objectWithoutPropertiesLoose, _ as _extends$1, g as generateUtilityClass, j as capitalize, u as useDefaultProps, k as interopRequireDefaultExports, w as lighten_1, x as darken_1, f as alpha_1 } from "./identifier-u4E_J1of.esm.js";
4
4
  import { i as default_1$3, T as Typography, e as useForkRef, o as ownerWindow, d as useEnhancedEffect, h as debounce, p as isMuiElement, u as useAuth, q as useControlled, r as requireCreateSvgIcon } from "./useAuth-Dp6w9OBc.esm.js";
5
- import { an as default_1$4, w as DynamicSelect, i as DateTimePicker, D as DatePicker$1, ao as useThemeProps, A as Accordion$1, C as Checkbox$1, g as ChipOrPlaceholder$1, j as DropdownButton, ad as TitleDropdownButton, T as HeaderCard, ab as TabBar, ap as default_1$5, a6 as SearchableSelect, aq as Chip$1, ac as TimePicker, ah as UploadMedia, a3 as PhoneInput, Z as ModalLoader, Y as MaterialTable, u as DynamicSearchSelect, n as DynamicDate, z as DynamicTime, f as ChipGenerator, l as DynamicCheckBox, M as Footer, F as Fallback, ar as TabContext, as as TabList, at as Tab, au as TabPanel, av as default_1$9, a as ActionBar, aw as SwitchBase } from "./android-12-switch-Nw977vtV.esm.js";
6
- import { D as DynamicInput, F as Typography$1, b as Avatar, I as o, M as Modal, d as Select, B as Button, c as ConfirmPopUp, g as Box$1, e as Toast, u as useTheme$1, S as SearchBar, J as resolveComponentProps, K as mergeSlotProps, N as appendOwnerState, P as Paper$1, p as chainPropTypes, i as ButtonBase$1, z as default_1$6, T as TextField$1, f as Tooltip$1, G as default_1$7, y as default_1$8, O as Menu$2, Q as MenuItem$1, U as IconButton$1, s as useRtl, E as List$1, w as ListItem, V as ListItemText$1, W as refType } from "./appbar-KrkQiVAV.esm.js";
5
+ import { an as default_1$4, w as DynamicSelect, i as DateTimePicker, D as DatePicker$1, ao as useThemeProps, A as Accordion$1, C as Checkbox$1, g as ChipOrPlaceholder$1, j as DropdownButton, ad as TitleDropdownButton, T as HeaderCard, ab as TabBar, ap as default_1$5, a6 as SearchableSelect, aq as Chip$1, ac as TimePicker, ah as UploadMedia, a3 as PhoneInput, Z as ModalLoader, Y as MaterialTable, u as DynamicSearchSelect, n as DynamicDate, z as DynamicTime, f as ChipGenerator, l as DynamicCheckBox, M as Footer, F as Fallback, ar as TabContext, as as TabList, at as Tab, au as TabPanel, av as default_1$9, a as ActionBar, aw as SwitchBase } from "./android-12-switch-BJGIDwYR.esm.js";
6
+ import { D as DynamicInput, F as Typography$1, b as Avatar, I as o, M as Modal, d as Select, B as Button, c as ConfirmPopUp, g as Box$1, e as Toast, u as useTheme$1, S as SearchBar, J as resolveComponentProps, K as mergeSlotProps, N as appendOwnerState, P as Paper$1, p as chainPropTypes, i as ButtonBase$1, z as default_1$6, T as TextField$1, f as Tooltip$1, G as default_1$7, y as default_1$8, O as Menu$2, Q as MenuItem$1, U as IconButton$1, s as useRtl, E as List$1, w as ListItem, V as ListItemText$1, W as refType } from "./appbar-zELMJiqH.esm.js";
7
7
  import * as React from "react";
8
8
  import React__default, { useState, lazy, useMemo, useRef, useEffect, useCallback, useContext, createElement, useLayoutEffect, createContext, cloneElement } from "react";
9
9
  import DatePicker from "react-datepicker";
@@ -22,7 +22,7 @@ import * as d3 from "d3";
22
22
  import { marked } from "marked";
23
23
  import { bl as streamV1AiFeatureChat, aJ as getV1User, bm as getV1ReportsScheduleReport, N as getV1ReportsReportList, bn as deleteV1ReportsScheduleReportId, bo as putV1ReportsUpdateScheduleReportId, bp as postV1ReportsScheduleReport, y as getV1FormBuilder } from "./api-C4k7-AHj.esm.js";
24
24
  import * as Yup from "yup";
25
- import { C as Chip, M as Menu, t as transformTableColumns, b as formateValueByType, r as renderEmptyRowsFallback } from "./form-builder-deconversion-DLGJdpXM.esm.js";
25
+ import { C as Chip, M as Menu, t as transformTableColumns, b as formateValueByType, r as renderEmptyRowsFallback } from "./form-builder-deconversion-B4OuGvBB.esm.js";
26
26
  import { M as MoreIcon, s as Filter, e as Close$1, b as ArrowUpDown, q as RecgtangleIcon, C as CheckBoxIcon$1, T as Trash, h as Export, r as Calendar$1, E as Edit } from "./trash-jodcm4T5.esm.js";
27
27
  import { enqueueSnackbar, useSnackbar, SnackbarProvider } from "notistack";
28
28
  import { useDispatch } from "react-redux";
@@ -47,7 +47,7 @@ import { v as viewTypes } from "./action-bar-BsXTcYpL.esm.js";
47
47
  import DataEditor, { GridCellKind } from "@glideapps/glide-data-grid";
48
48
  import { useExtraCells } from "@glideapps/glide-data-grid-cells";
49
49
  import { createPortal } from "react-dom";
50
- import { C as Collapse$1 } from "./sidebar-BeSjxulx.esm.js";
50
+ import { C as Collapse$1 } from "./sidebar-BXrUlb1O.esm.js";
51
51
  import { useMaterialReactTable, MaterialReactTable } from "material-react-table";
52
52
  import _$1 from "lodash";
53
53
  import { f as usePages, b as useDeepMemo, g as usePermissions, a as useApi } from "./useAccountSetting-BNRXy2Yy.esm.js";
@@ -7531,6 +7531,7 @@ const InlineEditFields = ({
7531
7531
  await validationSchema2.validateAt(
7532
7532
  column.id,
7533
7533
  {
7534
+ // ...row._valuesCache,
7534
7535
  [column.id]: value
7535
7536
  },
7536
7537
  {
@@ -7661,7 +7662,8 @@ const InlineEditFields = ({
7661
7662
  isInternal: (fieldProperties == null ? void 0 : fieldProperties.isInternal) || !(fieldProperties == null ? void 0 : fieldProperties.apiType),
7662
7663
  multiple: fieldProperties == null ? void 0 : fieldProperties.is_multiple,
7663
7664
  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],
7664
- getSelectedData: (row2) => getSelectedData(fieldProperties == null ? void 0 : fieldProperties.field_name, row2)
7665
+ getSelectedData: (row2) => getSelectedData(fieldProperties == null ? void 0 : fieldProperties.field_name, row2),
7666
+ disabled: fieldDisbled
7665
7667
  }
7666
7668
  ),
7667
7669
  (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] })
@@ -7679,7 +7681,7 @@ const InlineEditFields = ({
7679
7681
  helperText: errors == null ? void 0 : errors[column.id],
7680
7682
  format: fieldProperties == null ? void 0 : fieldProperties.dateFormat,
7681
7683
  placeholder: (fieldProperties == null ? void 0 : fieldProperties.placeholder) || (fieldProperties == null ? void 0 : fieldProperties.dateFormat),
7682
- value: dayjs(row._valuesCache[column.id]).isValid() ? dayjs(row._valuesCache[column.id]) : void 0,
7684
+ value: row._valuesCache[column.id] && dayjs(row._valuesCache[column.id]).isValid() ? dayjs(row._valuesCache[column.id]) : null,
7683
7685
  disabled: fieldDisbled,
7684
7686
  minDate: fieldProperties == null ? void 0 : fieldProperties.min_date,
7685
7687
  maxDate: fieldProperties == null ? void 0 : fieldProperties.max_date
@@ -7940,6 +7942,21 @@ const MaterialEditableTable = React__default.memo(({
7940
7942
  /^(https?:\/\/)?((([a-zA-Z0-9_-]+\.)+[a-zA-Z]{2,})|localhost)(:\d{2,5})?(\/[a-zA-Z0-9#_-]+\/?)*(\?[a-zA-Z0-9&=_-]+)?(#\S+)?$/,
7941
7943
  { excludeEmptyString: true, message: "Please enter valid URL." }
7942
7944
  );
7945
+ case "date":
7946
+ case "date_time":
7947
+ case "time":
7948
+ return Yup.date().nullable().transform((value, originalValue) => {
7949
+ if (originalValue === "" || originalValue === null || originalValue === void 0) {
7950
+ return null;
7951
+ }
7952
+ if (originalValue && typeof originalValue === "object" && "toDate" in originalValue) {
7953
+ return originalValue.toDate();
7954
+ }
7955
+ return value;
7956
+ }).typeError("Valid date is required");
7957
+ case "file":
7958
+ case "image":
7959
+ return Yup.mixed().nullable();
7943
7960
  default:
7944
7961
  return Yup.string();
7945
7962
  }
@@ -8095,6 +8112,23 @@ const MaterialEditableTable = React__default.memo(({
8095
8112
  validation.testFn
8096
8113
  );
8097
8114
  break;
8115
+ case "validate":
8116
+ if (typeof validation.callback === "function") {
8117
+ vld = vld.test(
8118
+ validation.name || "custom-validate",
8119
+ validation.msg_en || "Validation failed",
8120
+ function(value) {
8121
+ var _a2;
8122
+ const rowObj = ((_a2 = this.options.context) == null ? void 0 : _a2.row) || {
8123
+ original: this.parent,
8124
+ origin: this.parent,
8125
+ _valuesCache: this.parent
8126
+ };
8127
+ return validation.callback(value, this.parent, rowObj);
8128
+ }
8129
+ );
8130
+ }
8131
+ break;
8098
8132
  case "when":
8099
8133
  return vld.when(validation.relation, {
8100
8134
  is: (val) => typeof validation.is === "function" ? validation.is(val) : Array.isArray(validation.values) ? validation.values.includes(val) : val === validation.values,
@@ -8268,7 +8302,7 @@ const MaterialEditableTable = React__default.memo(({
8268
8302
  const setLoadingState = isEditMode ? setIsEditingRow : setIsCreatingRow;
8269
8303
  const rowId = row2.id;
8270
8304
  try {
8271
- await validationSchema2.validate(values, { abortEarly: false });
8305
+ await validationSchema2.validate(values, { abortEarly: false, context: { row: row2 } });
8272
8306
  setValidationErrors((prev) => {
8273
8307
  const next = { ...prev };
8274
8308
  delete next[rowId];
@@ -8305,16 +8339,58 @@ const MaterialEditableTable = React__default.memo(({
8305
8339
  },
8306
8340
  [validationSchema2, onEditRow, onCreateRow, formtValues]
8307
8341
  );
8308
- const validate = useCallback(async (values) => {
8342
+ const validate = useCallback(async (values, row2) => {
8309
8343
  try {
8310
- await validationSchema2.validate(values, { abortEarly: false });
8344
+ await validationSchema2.validate(values, { abortEarly: false, context: { row: row2 } });
8311
8345
  setValidationErrors({});
8312
8346
  return true;
8313
8347
  } catch (err) {
8314
8348
  return false;
8315
8349
  }
8316
8350
  }, [validationSchema2]);
8351
+ useCallback(
8352
+ async (columnId, value, rowId, rowValues) => {
8353
+ if (!validationSchema2 || typeof validationSchema2.validateAt !== "function" || !validationSchema2.fields || !validationSchema2.fields[columnId]) return;
8354
+ try {
8355
+ await validationSchema2.validateAt(
8356
+ columnId,
8357
+ {
8358
+ ...rowValues,
8359
+ [columnId]: value
8360
+ },
8361
+ {
8362
+ abortEarly: false
8363
+ }
8364
+ );
8365
+ setValidationErrors((prev) => {
8366
+ const next = { ...prev };
8367
+ if (next[rowId]) {
8368
+ const rowErrs = { ...next[rowId] };
8369
+ delete rowErrs[columnId];
8370
+ next[rowId] = rowErrs;
8371
+ }
8372
+ return next;
8373
+ });
8374
+ } catch (err) {
8375
+ if (err instanceof Yup.ValidationError) {
8376
+ const fieldErrors = err.inner.reduce((acc, { path: path2, message }) => {
8377
+ if (path2) acc[path2] = message;
8378
+ return acc;
8379
+ }, {});
8380
+ setValidationErrors((prev) => ({
8381
+ ...prev,
8382
+ [rowId]: {
8383
+ ...prev[rowId] ?? {},
8384
+ ...fieldErrors
8385
+ }
8386
+ }));
8387
+ }
8388
+ }
8389
+ },
8390
+ [validationSchema2]
8391
+ );
8317
8392
  const valuesRef = useRef({});
8393
+ console.log("🚀 ~ valuesRef:", valuesRef);
8318
8394
  const syncFieldValue = useCallback(
8319
8395
  (rowId, columnId, value) => {
8320
8396
  valuesRef.current[rowId] = {
@@ -8344,7 +8420,7 @@ const MaterialEditableTable = React__default.memo(({
8344
8420
  const creatingRow = table2.getState().creatingRow;
8345
8421
  if (!editingRow) return;
8346
8422
  const values = getRowValues(editingRow);
8347
- const isValid = await validate(values);
8423
+ const isValid = await validate(values, editingRow);
8348
8424
  if (!isValid) {
8349
8425
  await handleSaveRow({ row: editingRow, values, table: table2 }, "edit");
8350
8426
  return;
@@ -8368,7 +8444,7 @@ const MaterialEditableTable = React__default.memo(({
8368
8444
  if (values == null ? void 0 : values["mrt-row-actions"]) {
8369
8445
  delete values["mrt-row-actions"];
8370
8446
  }
8371
- const isValid = await validate(values);
8447
+ const isValid = await validate(values, creatingRow);
8372
8448
  await handleSaveRow({ row: creatingRow, values, table: table2 }, "create");
8373
8449
  if (!isValid) return;
8374
8450
  if (isValid) {
@@ -8735,14 +8811,14 @@ const MaterialEditableTable = React__default.memo(({
8735
8811
  let saveSucceeded = false;
8736
8812
  if (currentCreatingRow) {
8737
8813
  const values = getRowValues(currentCreatingRow);
8738
- const isValid = await validate(values);
8814
+ const isValid = await validate(values, currentCreatingRow);
8739
8815
  if (!isValid) return;
8740
8816
  await handleSaveRow({ row: currentCreatingRow, values, table: table2 }, "create");
8741
8817
  clearRow("mrt-row-create");
8742
8818
  saveSucceeded = true;
8743
8819
  } else if (currentEditingRow) {
8744
8820
  const values = getRowValues(currentEditingRow);
8745
- const isValid = await validate(values);
8821
+ const isValid = await validate(values, currentEditingRow);
8746
8822
  if (!isValid) return;
8747
8823
  await handleSaveRow({ row: currentEditingRow, values, table: table2 }, "edit");
8748
8824
  clearRow(currentEditingRow.id);
@@ -8770,8 +8846,8 @@ const MaterialEditableTable = React__default.memo(({
8770
8846
  } else {
8771
8847
  const editingRow = table2.getState().editingRow;
8772
8848
  if (editingRow) {
8773
- handleSaveRow({ row: editingRow, values: editingRow.original, table: table2 }, "edit");
8774
8849
  clearRow(editingRow.id);
8850
+ table2.setEditingRow(null);
8775
8851
  }
8776
8852
  }
8777
8853
  setDisableNextEdit(false);
@@ -16196,4 +16272,4 @@ export {
16196
16272
  DynamicDateTime as y,
16197
16273
  DynamicLayoutWrapper as z
16198
16274
  };
16199
- //# sourceMappingURL=uom-field-wrapper-Db0m4mhG.esm.js.map
16275
+ //# sourceMappingURL=uom-field-wrapper-D0YgJsP5.esm.js.map