@natoora-libs/core 0.1.9-dev-doug-4 → 0.1.9-dev-doug-6

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.
@@ -383,7 +383,7 @@ __export(components_exports, {
383
383
  Switch: () => Switch_default,
384
384
  Table: () => Table_default,
385
385
  TableDesktop: () => TableDesktop_default,
386
- TableDesktopRowActions: () => TableDesktopRowActions,
386
+ TableDesktopFooter: () => TableDesktopFooter,
387
387
  TableDesktopRowCell: () => TableDesktopRowCell,
388
388
  TableDesktopSmartSelect: () => TableDesktopSmartSelect,
389
389
  TableEmptyResult: () => TableEmptyResult_default,
@@ -3082,7 +3082,7 @@ var RoundButton = ({
3082
3082
  onClick(e);
3083
3083
  }
3084
3084
  };
3085
- const Button14 = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
3085
+ const Button15 = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
3086
3086
  import_material16.Fab,
3087
3087
  {
3088
3088
  className: cx(
@@ -3106,7 +3106,7 @@ var RoundButton = ({
3106
3106
  children: icon ? iconComponentMap[icon] : children || ""
3107
3107
  }
3108
3108
  );
3109
- return tooltip ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_material16.Tooltip, { title: tooltip, children: Button14 }) : Button14;
3109
+ return tooltip ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_material16.Tooltip, { title: tooltip, children: Button15 }) : Button15;
3110
3110
  };
3111
3111
  var RoundButton_default = RoundButton;
3112
3112
 
@@ -7060,6 +7060,7 @@ var TableEmptyResult_default = TableEmptyResult;
7060
7060
 
7061
7061
  // src/components/TableDesktop/TableDesktop.tsx
7062
7062
  var import_jsx_runtime111 = require("react/jsx-runtime");
7063
+ var ROW_HEIGHT = 56;
7063
7064
  var useStyles48 = (0, import_mui54.makeStyles)()((theme) => ({
7064
7065
  root: {
7065
7066
  justifyContent: "space-between",
@@ -7145,14 +7146,14 @@ var TableDesktop = ({
7145
7146
  onApplyFilters,
7146
7147
  shouldShowCheckOnFilter
7147
7148
  }) => {
7149
+ const { classes } = useStyles48();
7148
7150
  const [order, setOrder] = (0, import_react33.useState)(appliedFilters?.sortDir || "desc");
7149
7151
  const [orderBy, setOrderBy] = (0, import_react33.useState)(
7150
7152
  appliedFilters?.sortField || "delivery_date"
7151
7153
  );
7152
7154
  const [selected, setSelected] = (0, import_react33.useState)(/* @__PURE__ */ new Set());
7153
7155
  const [page] = (0, import_react33.useState)(0);
7154
- const { classes } = useStyles48();
7155
- const rowHeight = 56;
7156
+ const numRows = data.length;
7156
7157
  const emptyRows = (0, import_react33.useMemo)(
7157
7158
  () => rowsPerPage - data.length,
7158
7159
  [rowsPerPage, data]
@@ -7198,6 +7199,18 @@ var TableDesktop = ({
7198
7199
  );
7199
7200
  const renderTableRows = (0, import_react33.useMemo)(() => {
7200
7201
  const sortedData = disableInternalSort ? data : stableSort(data, getComparator(order, orderBy));
7202
+ if (isLoading) {
7203
+ return [...Array(Math.min(numRows, rowsPerPage))].map((_, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_material60.TableRow, { children: [...Array(visibleHeadCells.length)].map((_2, cellIndex) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_material60.TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
7204
+ import_material60.Skeleton,
7205
+ {
7206
+ animation: "pulse",
7207
+ variant: "rounded",
7208
+ height: ROW_HEIGHT - 33,
7209
+ sx: { bgcolor: colors.neutral150 },
7210
+ "data-testid": "loading-skeleton"
7211
+ }
7212
+ ) }, cellIndex)) }, rowIndex));
7213
+ }
7201
7214
  return sortedData.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map((row, index) => {
7202
7215
  const isItemSelected = selected.has(row[keyField]);
7203
7216
  return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
@@ -7209,8 +7222,8 @@ var TableDesktop = ({
7209
7222
  deleteItem,
7210
7223
  isItemSelected,
7211
7224
  enableCheckboxSelection,
7212
- enableRowActions,
7213
- keyFieldValue: row[keyField],
7225
+ rowHeight: ROW_HEIGHT,
7226
+ rowId: row[keyField],
7214
7227
  handleRowCheckboxChange,
7215
7228
  visibleHeadCells
7216
7229
  }
@@ -7240,17 +7253,7 @@ var TableDesktop = ({
7240
7253
  }
7241
7254
  }, [enableCheckboxSelection]);
7242
7255
  return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: classes.root, style: { height }, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(import_material60.Paper, { className: classes.paper, children: [
7243
- isLoading ? /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_material60.Box, { width: "100%", overflow: "hidden", children: [...Array(Math.floor(rowsPerPage ?? 50))].map((_, index) => /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
7244
- import_material60.Skeleton,
7245
- {
7246
- animation: "pulse",
7247
- variant: "rounded",
7248
- sx: { margin: 1 },
7249
- height: rowHeight,
7250
- "data-testid": "loading-skeleton"
7251
- },
7252
- index
7253
- )) }) : /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_material60.TableContainer, { className: classes.container, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
7256
+ /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_material60.TableContainer, { className: classes.container, children: /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)(
7254
7257
  import_material60.Table,
7255
7258
  {
7256
7259
  stickyHeader: true,
@@ -7265,7 +7268,7 @@ var TableDesktop = ({
7265
7268
  order,
7266
7269
  orderBy,
7267
7270
  numSelected: selected.size,
7268
- numRows: data.length,
7271
+ numRows,
7269
7272
  enableCheckboxSelection,
7270
7273
  headerFilters: headerFilters ?? {},
7271
7274
  onRequestSort: handleRequestSort,
@@ -7693,41 +7696,84 @@ var Table2 = ({
7693
7696
  };
7694
7697
  var Table_default = Table2;
7695
7698
 
7696
- // src/components/TableDesktopRowActions/TableDesktopRowActions.tsx
7699
+ // src/components/TableDesktopFooter/TableDesktopFooter.tsx
7700
+ var import_Refresh = __toESM(require("@mui/icons-material/Refresh"), 1);
7697
7701
  var import_material64 = require("@mui/material");
7698
7702
  var import_jsx_runtime115 = require("react/jsx-runtime");
7699
- var TableDesktopRowActions = ({
7700
- isRowHovered,
7701
- children,
7702
- sx,
7703
- zIndex = 1,
7704
- backgroundColor
7703
+ var TableDesktopFooter = ({
7704
+ numPages,
7705
+ page,
7706
+ pageSize,
7707
+ pageSizeOptions,
7708
+ handlePageChange,
7709
+ handlePageSizeChange,
7710
+ refetch,
7711
+ isFetching
7705
7712
  }) => {
7706
- return isRowHovered ? /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
7707
- import_material64.TableCell,
7713
+ return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(
7714
+ import_material64.Box,
7708
7715
  {
7709
- padding: "none",
7710
- sx: {
7711
- top: 0,
7712
- right: 0,
7713
- zIndex,
7714
- position: "sticky",
7715
- display: "flex",
7716
- justifyContent: "flex-end",
7717
- alignItems: "center"
7718
- },
7719
- children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
7720
- import_material64.Box,
7721
- {
7722
- sx,
7723
- display: "flex",
7724
- flexDirection: "row",
7725
- bgcolor: backgroundColor ?? colors.neutral100,
7726
- children
7727
- }
7728
- )
7716
+ py: 1,
7717
+ gap: 2,
7718
+ display: "flex",
7719
+ justifyContent: "space-between",
7720
+ alignItems: "center",
7721
+ borderTop: `1px solid ${colors.neutral300}`,
7722
+ bgcolor: (theme) => theme.palette.background.default,
7723
+ children: [
7724
+ /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(
7725
+ import_material64.Button,
7726
+ {
7727
+ disableRipple: true,
7728
+ variant: "outlined",
7729
+ onClick: () => refetch(),
7730
+ disabled: isFetching,
7731
+ sx: {
7732
+ ml: 1,
7733
+ gap: 1,
7734
+ borderRadius: 25,
7735
+ color: colors.neutral800,
7736
+ borderColor: colors.neutral600
7737
+ },
7738
+ children: [
7739
+ /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
7740
+ import_Refresh.default,
7741
+ {
7742
+ fontSize: "small",
7743
+ color: isFetching ? "disabled" : "primary"
7744
+ }
7745
+ ),
7746
+ "REFRESH"
7747
+ ]
7748
+ }
7749
+ ),
7750
+ /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(import_material64.Box, { display: "flex", children: [
7751
+ /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)(import_material64.Stack, { direction: "row", spacing: 2, alignItems: "center", children: [
7752
+ /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_material64.Typography, { children: "Rows per page:" }),
7753
+ /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
7754
+ import_material64.Select,
7755
+ {
7756
+ value: pageSize,
7757
+ onChange: handlePageSizeChange,
7758
+ size: "small",
7759
+ variant: "standard",
7760
+ children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_material64.MenuItem, { value: size, children: size }, size))
7761
+ }
7762
+ )
7763
+ ] }),
7764
+ /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
7765
+ import_material64.Pagination,
7766
+ {
7767
+ color: "standard",
7768
+ count: numPages,
7769
+ page,
7770
+ onChange: handlePageChange
7771
+ }
7772
+ )
7773
+ ] })
7774
+ ]
7729
7775
  }
7730
- ) : null;
7776
+ );
7731
7777
  };
7732
7778
 
7733
7779
  // src/components/TableDesktopRowCell/TableDesktopRowCell.tsx
@@ -7749,6 +7795,7 @@ var TableDesktopSmartSelect = (0, import_react36.memo)(({
7749
7795
  inputLabel,
7750
7796
  fieldName,
7751
7797
  rowId,
7798
+ disabled,
7752
7799
  filterOptions,
7753
7800
  refetchFilterOptions,
7754
7801
  isFetchingFilterOptions,
@@ -7774,6 +7821,7 @@ var TableDesktopSmartSelect = (0, import_react36.memo)(({
7774
7821
  value: valueId,
7775
7822
  inputLabel,
7776
7823
  options,
7824
+ disabled,
7777
7825
  refetch: refetchFilterOptions,
7778
7826
  isFetching: isFetchingFilterOptions,
7779
7827
  defaultOption: {
@@ -7799,11 +7847,12 @@ var TableDesktopTextField = ({
7799
7847
  rowId,
7800
7848
  editInitialValue,
7801
7849
  inputLabel,
7850
+ disabled,
7802
7851
  validateInput,
7803
7852
  onUpdateEditableCell
7804
7853
  }) => {
7805
7854
  const [value, setValue] = (0, import_react37.useState)(editInitialValue);
7806
- const hasError = (0, import_react37.useMemo)(() => validateInput?.(value), [value, validateInput]);
7855
+ const hasError = (0, import_react37.useMemo)(() => !validateInput?.(value), [value, validateInput]);
7807
7856
  return /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
7808
7857
  import_TextField.default,
7809
7858
  {
@@ -7812,6 +7861,7 @@ var TableDesktopTextField = ({
7812
7861
  defaultValue: value,
7813
7862
  label: inputLabel,
7814
7863
  error: hasError,
7864
+ disabled,
7815
7865
  onChange: ({ target: { value: value2 } }) => {
7816
7866
  setValue(value2);
7817
7867
  },
@@ -7826,38 +7876,55 @@ var TableDesktopTextField = ({
7826
7876
  };
7827
7877
 
7828
7878
  // src/components/TableDesktopRowCell/TableDesktopRowCell.tsx
7879
+ var import_Close = __toESM(require("@mui/icons-material/Close"), 1);
7880
+ var import_Edit = __toESM(require("@mui/icons-material/Edit"), 1);
7829
7881
  var import_jsx_runtime118 = require("react/jsx-runtime");
7830
7882
  var TableDesktopRowCell = ({
7831
- ref,
7832
7883
  inputLabel,
7833
7884
  editInitialValue,
7834
7885
  rowId,
7835
7886
  fieldName,
7836
7887
  width,
7837
- isEditMode,
7888
+ disabled,
7838
7889
  readOnlyValue,
7839
7890
  editableCellType,
7840
7891
  filterOptions,
7841
7892
  refetchFilterOptions,
7842
7893
  isFetchingFilterOptions,
7843
7894
  validateInput,
7844
- onUpdateEditableCell
7895
+ onUpdateEditableCell,
7896
+ onCellClick
7845
7897
  }) => {
7846
7898
  const cellRef = (0, import_react38.useRef)(null);
7847
7899
  const [isOverflowed, setIsOverflowed] = (0, import_react38.useState)(false);
7900
+ const [isCellHovered, setIsCellHovered] = (0, import_react38.useState)(false);
7901
+ const [isEditMode, setIsEditMode] = (0, import_react38.useState)(false);
7848
7902
  (0, import_react38.useEffect)(() => {
7849
- const ref2 = cellRef.current;
7850
- if (ref2) {
7851
- setIsOverflowed(ref2.scrollWidth > ref2.clientWidth);
7903
+ const ref = cellRef.current;
7904
+ if (ref) {
7905
+ setIsOverflowed(ref.scrollWidth > ref.clientWidth);
7852
7906
  }
7853
7907
  }, [readOnlyValue, width]);
7908
+ (0, import_react38.useEffect)(() => {
7909
+ const handleKeyDown = (e) => {
7910
+ if (e.key === "Escape") {
7911
+ setIsEditMode(false);
7912
+ }
7913
+ };
7914
+ if (isEditMode) {
7915
+ window.addEventListener("keydown", handleKeyDown);
7916
+ }
7917
+ return () => {
7918
+ window.removeEventListener("keydown", handleKeyDown);
7919
+ };
7920
+ }, [isEditMode]);
7854
7921
  const editableComponents = {
7855
7922
  "select": /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
7856
7923
  TableDesktopSmartSelect,
7857
7924
  {
7858
- ref,
7859
7925
  rowId,
7860
7926
  fieldName,
7927
+ disabled,
7861
7928
  initialValue: editInitialValue,
7862
7929
  inputLabel: inputLabel ?? "",
7863
7930
  filterOptions,
@@ -7870,6 +7937,7 @@ var TableDesktopRowCell = ({
7870
7937
  import_material65.Checkbox,
7871
7938
  {
7872
7939
  disableRipple: true,
7940
+ disabled,
7873
7941
  defaultChecked: editInitialValue,
7874
7942
  onChange: ({ target: { checked } }) => {
7875
7943
  onUpdateEditableCell?.(rowId, checked);
@@ -7880,6 +7948,7 @@ var TableDesktopRowCell = ({
7880
7948
  TableDesktopTextField,
7881
7949
  {
7882
7950
  rowId,
7951
+ disabled,
7883
7952
  editInitialValue,
7884
7953
  inputLabel: inputLabel ?? "",
7885
7954
  validateInput,
@@ -7891,6 +7960,7 @@ var TableDesktopRowCell = ({
7891
7960
  {
7892
7961
  fullWidth: true,
7893
7962
  variant: "standard",
7963
+ disabled,
7894
7964
  defaultValue: editInitialValue,
7895
7965
  label: inputLabel,
7896
7966
  onChange: (e) => {
@@ -7913,18 +7983,49 @@ var TableDesktopRowCell = ({
7913
7983
  }
7914
7984
  return "-";
7915
7985
  };
7986
+ const handleEditClick = (e) => {
7987
+ e.stopPropagation();
7988
+ setIsEditMode((prev) => !prev);
7989
+ };
7916
7990
  return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_material65.Tooltip, { title: isOverflowed ? String(readOnlyValue) : "", arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
7917
7991
  import_material65.TableCell,
7918
7992
  {
7919
7993
  ref: cellRef,
7920
7994
  align: "left",
7995
+ onMouseEnter: () => editableCellType && !disabled && setIsCellHovered(true),
7996
+ onMouseLeave: () => editableCellType && !disabled && setIsCellHovered(false),
7997
+ onClick: (event) => !disabled && onCellClick?.(event, isEditMode),
7921
7998
  sx: {
7999
+ padding: 1,
7922
8000
  width: width ?? "auto",
7923
8001
  overflow: "hidden",
7924
8002
  textOverflow: "ellipsis",
7925
- whiteSpace: "nowrap"
8003
+ whiteSpace: "nowrap",
8004
+ position: "relative",
8005
+ cursor: disabled ? "default" : "pointer",
8006
+ opacity: disabled ? 0.2 : 1,
8007
+ ":hover": editableCellType && {
8008
+ background: isEditMode ? colors.lightBlueBackground : colors.neutral100
8009
+ },
8010
+ background: isEditMode ? colors.lightBlueBackground : (theme) => theme.palette.background.default
7926
8011
  },
7927
- children: isEditMode && editableCellType ? editableComponents[editableCellType] : typeof readOnlyValue === "boolean" ? getReadOnlyBooleanIcon(readOnlyValue) : readOnlyValue
8012
+ children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(import_material65.Box, { p: 1, children: [
8013
+ isCellHovered ? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_material65.Tooltip, { title: "Toggle Edit Mode", children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
8014
+ import_material65.IconButton,
8015
+ {
8016
+ onClick: handleEditClick,
8017
+ sx: {
8018
+ position: "absolute",
8019
+ top: 0,
8020
+ right: 0,
8021
+ zIndex: 1,
8022
+ borderRadius: 0
8023
+ },
8024
+ children: isEditMode ? /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_Close.default, { fontSize: "small", color: "error" }) : /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_Edit.default, { fontSize: "small" })
8025
+ }
8026
+ ) }) : null,
8027
+ isEditMode && editableCellType ? editableComponents[editableCellType] : typeof readOnlyValue === "boolean" ? getReadOnlyBooleanIcon(readOnlyValue) : readOnlyValue
8028
+ ] })
7928
8029
  }
7929
8030
  ) });
7930
8031
  };
@@ -8470,7 +8571,7 @@ var IconChart_default = SvgIconChart;
8470
8571
  Switch,
8471
8572
  Table,
8472
8573
  TableDesktop,
8473
- TableDesktopRowActions,
8574
+ TableDesktopFooter,
8474
8575
  TableDesktopRowCell,
8475
8576
  TableDesktopSmartSelect,
8476
8577
  TableEmptyResult,