@monolith-forensics/monolith-ui 1.2.110 → 1.2.112

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.
@@ -193,9 +193,10 @@ const InputSegment = styled.div `
193
193
  }
194
194
  `;
195
195
  const DateInput = forwardRef(({ className, style = {}, defaultValue, value, format = "YYYY-MM-DD HH:mm:ss", label, description, arrow = true, size = "sm", variant = "outlined", clearable = false, required = false, onChange = () => { }, min, max, error, enableCalendar = false, utc = false, closeOnSelect = true, disabled = false, }, _ref) => {
196
- const isControlled = value !== undefined;
196
+ // Determine controlled status only once at mount
197
+ const isControlled = useRef(value !== undefined);
197
198
  const [unControlledValue, setUncontrolledValue] = useState(defaultValue);
198
- const _value = isControlled ? value : unControlledValue;
199
+ const _value = isControlled.current ? value : unControlledValue;
199
200
  const [selectedSegment, setSelectedSegment] = useState();
200
201
  const [isOpen, setIsOpen] = useState(false);
201
202
  // Check if format is date only and does not include time
@@ -351,7 +352,10 @@ const DateInput = forwardRef(({ className, style = {}, defaultValue, value, form
351
352
  setUncontrolledValue((prev) => {
352
353
  if (!(selectedSegment === null || selectedSegment === void 0 ? void 0 : selectedSegment.momentType))
353
354
  return prev;
354
- const momentValue = utc ? moment.utc(prev) : moment(prev);
355
+ // if prev is null, use undefined - passing null to moment returns a null moment value
356
+ const momentValue = utc
357
+ ? moment.utc(prev || undefined)
358
+ : moment(prev || undefined);
355
359
  let newValue = moment(momentValue)
356
360
  .set(selectedSegment.momentType, parseInt(tempValue, 10) -
357
361
  (selectedSegment.type === "month" ? 1 : 0))
@@ -0,0 +1 @@
1
+ export declare const LoadingCellIndicator: React.FC;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled from "styled-components";
3
+ const LoadingIndicator = styled.div `
4
+ @keyframes fadeInOut {
5
+ 0% {
6
+ background-color: ${({ theme }) => theme.palette.background.alt};
7
+ }
8
+ 50% {
9
+ background-color: ${({ theme }) => theme.palette.background.paper};
10
+ }
11
+ 100% {
12
+ background-color: ${({ theme }) => theme.palette.background.alt};
13
+ }
14
+ }
15
+
16
+ width: 100%;
17
+ height: 100%;
18
+ min-height: 20px;
19
+ border-radius: 4px;
20
+ animation: fadeInOut 1.25s ease-in-out infinite;
21
+ display: flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+ font-size: 10px;
25
+ color: ${({ theme }) => theme.palette.text.secondary};
26
+ background-color: #f0f0f0;
27
+ `;
28
+ export const LoadingCellIndicator = () => {
29
+ return _jsx(LoadingIndicator, { children: "loading..." });
30
+ };
@@ -4,7 +4,7 @@ import TableRow from "./TableRow";
4
4
  import useTable from "./useTable";
5
5
  const StaticRows = ({ targetElm, listElm }) => {
6
6
  var _a;
7
- const { data } = useTable();
8
- return (_jsx(TBody, { className: "mfui-tbody", children: _jsx(TableViewPort, { className: "mfui-tbody-viewport", ref: targetElm, children: _jsx(TableListElement, { className: "mfui-tbody-list", ref: listElm, children: (_a = data === null || data === void 0 ? void 0 : data.map) === null || _a === void 0 ? void 0 : _a.call(data, (row, index) => (_jsx(TableRow, { rowData: row }, index))) }) }) }));
7
+ const { data, loadingRowIds, keyField } = useTable();
8
+ return (_jsx(TBody, { className: "mfui-tbody", children: _jsx(TableViewPort, { className: "mfui-tbody-viewport", ref: targetElm, children: _jsx(TableListElement, { className: "mfui-tbody-list", ref: listElm, children: (_a = data === null || data === void 0 ? void 0 : data.map) === null || _a === void 0 ? void 0 : _a.call(data, (row, index) => (_jsx(TableRow, { rowData: row, loading: !!keyField ? loadingRowIds === null || loadingRowIds === void 0 ? void 0 : loadingRowIds.includes(row[keyField]) : false }, index))) }) }) }));
9
9
  };
10
10
  export default StaticRows;
@@ -6,7 +6,8 @@ import useTable from "./useTable";
6
6
  import ActionCell from "./ActionCell";
7
7
  import ActionButton from "./ActionButton";
8
8
  import CheckBox from "../CheckBox";
9
- const TableRow = ({ rowData, rowStyle }) => {
9
+ import { LoadingCellIndicator } from "./LoadingCellIndicator";
10
+ const TableRow = ({ rowData, loading, rowStyle }) => {
10
11
  const { columnState, enableActionButton, onActionButtonClick, actionButtonIcon: Icon, enableSelection, selectRow, deselectRow, isRowSelected, onRowUpdated, } = useTable();
11
12
  const selected = isRowSelected(rowData);
12
13
  const handleSelectionChange = (e) => {
@@ -15,6 +16,13 @@ const TableRow = ({ rowData, rowStyle }) => {
15
16
  return (_jsxs(TR, { className: "mfui-tr", style: rowStyle, "data-key": rowData.__key, "data-selected": selected, children: [enableSelection && (_jsx(ActionCell, { className: `mfui-td column-select`, children: _jsx(InnerCellContent, { className: "mfui inner-cell-content row-action", children: _jsx(CheckBox, { className: `mfui-checkbox`, value: selected, onChange: (e) => handleSelectionChange(e) }) }) })), enableActionButton && (_jsx(ActionCell, { className: `mfui-td column-action`, children: _jsx(InnerCellContent, { className: "mfui inner-cell-content row-action", children: _jsx(ActionButton, { variant: "subtle", onClick: () => onActionButtonClick === null || onActionButtonClick === void 0 ? void 0 : onActionButtonClick(rowData), children: Icon ? _jsx(Icon, { size: 14 }) : _jsx(Maximize2Icon, { size: 14 }) }) }) })), columnState.map((column, index) => {
16
17
  if (column.visible === false)
17
18
  return null;
19
+ if (loading) {
20
+ return (_jsx(TD, { className: `mfui-td column-${column.columnId}`, "data-field": column.dataField, style: {
21
+ width: column.width,
22
+ minWidth: column.minWidth,
23
+ flex: column.width ? "0 0 auto" : "1",
24
+ }, children: _jsx(LoadingCellIndicator, {}) }, index));
25
+ }
18
26
  return (_jsxs(TD, { className: `mfui-td column-${column.columnId}`, "data-field": column.dataField, style: {
19
27
  width: column.width,
20
28
  minWidth: column.minWidth,
@@ -5,7 +5,7 @@ import useTable from "./useTable";
5
5
  import TableDefaults from "./TableDefaults";
6
6
  import TableRow from "./TableRow";
7
7
  const VirtualizedRows = ({ tableDimensions, targetElm, listElm, rowHeight, headerRowHeight }) => {
8
- const { data, compactState } = useTable();
8
+ const { data, compactState, loadingRowIds, keyField } = useTable();
9
9
  const effectiveRowHeight = compactState
10
10
  ? TableDefaults.row.height.compact
11
11
  : rowHeight
@@ -22,7 +22,7 @@ const VirtualizedRows = ({ tableDimensions, targetElm, listElm, rowHeight, heade
22
22
  }, children: ({ data, index, style }) => {
23
23
  var _a;
24
24
  const row = ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a[index]) || {};
25
- return (_jsx(TableRow, { rowData: row, rowStyle: Object.assign(Object.assign({}, style), { height: rowHeight }) }, index));
25
+ return (_jsx(TableRow, { rowData: row, loading: !!keyField ? loadingRowIds === null || loadingRowIds === void 0 ? void 0 : loadingRowIds.includes(row[keyField]) : false, rowStyle: Object.assign(Object.assign({}, style), { height: rowHeight }) }, index));
26
26
  } }) }));
27
27
  };
28
28
  export default VirtualizedRows;
@@ -105,6 +105,7 @@ export type TableContextType = {
105
105
  rowHeight?: number;
106
106
  virtualized?: boolean;
107
107
  loading?: boolean;
108
+ loadingRowIds?: (string | number)[];
108
109
  tableElement: MutableRefObject<HTMLDivElement | null>;
109
110
  headerRowElm: MutableRefObject<HTMLDivElement | null>;
110
111
  tableDimensions: TableDimensions;
@@ -197,6 +198,7 @@ export interface TableRowProps {
197
198
  [key: string]: any;
198
199
  };
199
200
  rowStyle?: React.CSSProperties;
201
+ loading?: boolean;
200
202
  }
201
203
  export interface OnColumnChangeProps {
202
204
  columnState: ColumnState[];
@@ -251,6 +253,7 @@ export interface TableProps {
251
253
  minHeight?: number;
252
254
  virtualized?: boolean;
253
255
  loading?: boolean;
256
+ loadingRowIds?: (string | number)[];
254
257
  compact?: boolean;
255
258
  headerRowHeight?: number;
256
259
  rowHeight?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monolith-forensics/monolith-ui",
3
- "version": "1.2.110",
3
+ "version": "1.2.112",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Matt Danner (Monolith Forensics LLC)",