schummar-table 0.51.3 → 0.51.5

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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { r as ExporterEntry } from "./exporter-ZZesPOOU.cjs";
2
- import { _ as TableTheme, a as FilterImplementation, c as InternalColumn, d as PartialTableTheme, f as Sort, g as TableRef, h as TableProps, i as CommonFilterProps, l as InternalTableState, m as TableItem, n as ColumnFactory, o as FunctionWithDeps, p as SortDirection, r as ColumnGenerator, s as Id, t as Column, u as MemoizedTableTheme, v as TableStateStorage } from "./types-DqoOnlp7.cjs";
2
+ import { _ as TableTheme, a as FilterImplementation, c as InternalColumn, d as PartialTableTheme, f as Sort, g as TableRef, h as TableProps, i as CommonFilterProps, l as InternalTableState, m as TableItem, n as ColumnFactory, o as FunctionWithDeps, p as SortDirection, r as ColumnGenerator, s as Id, t as Column, u as MemoizedTableTheme, v as TableStateStorage } from "./types-1gz-mJJm.cjs";
3
3
  import * as _emotion_react_jsx_runtime1 from "@emotion/react/jsx-runtime";
4
4
  import * as react0 from "react";
5
5
  import { ComponentType, ForwardedRef, HTMLProps, ReactNode } from "react";
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { r as ExporterEntry } from "./exporter-zK7PhTrL.js";
2
- import { _ as TableTheme, a as FilterImplementation, c as InternalColumn, d as PartialTableTheme, f as Sort, g as TableRef, h as TableProps, i as CommonFilterProps, l as InternalTableState, m as TableItem, n as ColumnFactory, o as FunctionWithDeps, p as SortDirection, r as ColumnGenerator, s as Id, t as Column, u as MemoizedTableTheme, v as TableStateStorage } from "./types-BfdXNfLi.js";
2
+ import { _ as TableTheme, a as FilterImplementation, c as InternalColumn, d as PartialTableTheme, f as Sort, g as TableRef, h as TableProps, i as CommonFilterProps, l as InternalTableState, m as TableItem, n as ColumnFactory, o as FunctionWithDeps, p as SortDirection, r as ColumnGenerator, s as Id, t as Column, u as MemoizedTableTheme, v as TableStateStorage } from "./types-CJOB-Acy.js";
3
3
  import * as react0 from "react";
4
4
  import { ComponentType, ForwardedRef, HTMLProps, ReactNode } from "react";
5
- import * as _emotion_react_jsx_runtime9 from "@emotion/react/jsx-runtime";
5
+ import * as _emotion_react_jsx_runtime1 from "@emotion/react/jsx-runtime";
6
6
  import { Store } from "schummar-state/react";
7
7
 
8
8
  //#region src/components/autoFocusTextField.d.ts
9
9
  type Props = TableTheme['components']['TextField'] extends ComponentType<infer T> ? T : never;
10
- declare function AutoFocusTextField(props: Omit<Props, 'inputRef'>): _emotion_react_jsx_runtime9.JSX.Element;
10
+ declare function AutoFocusTextField(props: Omit<Props, 'inputRef'>): _emotion_react_jsx_runtime1.JSX.Element;
11
11
  //#endregion
12
12
  //#region src/components/combinedFilter.d.ts
13
13
  interface CombinedFilterProps extends Pick<CommonFilterProps<any, any, any, any>, 'classNames'> {
@@ -16,7 +16,7 @@ interface CombinedFilterProps extends Pick<CommonFilterProps<any, any, any, any>
16
16
  declare function CombinedFilter({
17
17
  columnIds: inputColumnIds,
18
18
  ...props
19
- }: CombinedFilterProps): _emotion_react_jsx_runtime9.JSX.Element;
19
+ }: CombinedFilterProps): _emotion_react_jsx_runtime1.JSX.Element;
20
20
  //#endregion
21
21
  //#region src/components/datePicker.d.ts
22
22
  type DateRange = {
@@ -68,7 +68,7 @@ declare function DatePickerProvider({
68
68
  ...props
69
69
  }: Partial<Omit<DatePickerProps, 'value' | 'onChange'>> & {
70
70
  children?: ReactNode;
71
- }): _emotion_react_jsx_runtime9.JSX.Element;
71
+ }): _emotion_react_jsx_runtime1.JSX.Element;
72
72
  /** Rounds a date down to the start of the day. */
73
73
  declare const startOfDay: (d: Date) => Date;
74
74
  /** Rounds a date up to the end of the day. */
@@ -81,34 +81,34 @@ declare const thisYear: (delta?: number) => DateRange;
81
81
  declare const getCalendarWeek: (date: Date) => number;
82
82
  declare const commonQuickOptions: {
83
83
  today: {
84
- label: _emotion_react_jsx_runtime9.JSX.Element;
84
+ label: _emotion_react_jsx_runtime1.JSX.Element;
85
85
  value: () => DateRange;
86
86
  };
87
87
  thisWeek: {
88
- label: _emotion_react_jsx_runtime9.JSX.Element;
88
+ label: _emotion_react_jsx_runtime1.JSX.Element;
89
89
  value: (props: DatePickerProps) => DateRange;
90
90
  };
91
91
  thisMonth: {
92
- label: _emotion_react_jsx_runtime9.JSX.Element;
92
+ label: _emotion_react_jsx_runtime1.JSX.Element;
93
93
  value: () => DateRange;
94
94
  };
95
95
  thisYear: {
96
- label: _emotion_react_jsx_runtime9.JSX.Element;
96
+ label: _emotion_react_jsx_runtime1.JSX.Element;
97
97
  value: () => DateRange;
98
98
  };
99
99
  lastSevenDays: {
100
- label: _emotion_react_jsx_runtime9.JSX.Element;
100
+ label: _emotion_react_jsx_runtime1.JSX.Element;
101
101
  value: () => DateRange;
102
102
  };
103
103
  lastThirtyDays: {
104
- label: _emotion_react_jsx_runtime9.JSX.Element;
104
+ label: _emotion_react_jsx_runtime1.JSX.Element;
105
105
  value: () => DateRange;
106
106
  };
107
107
  };
108
108
  /** Returns whether two dates and/or date ranges intersect. Intersection is considered per day. */
109
109
  declare function dateIntersect(a: Date | DateRange | null | undefined, b: Date | DateRange | null | undefined): boolean;
110
110
  declare function dateClamp(date: Date, min?: Date, max?: Date): Date;
111
- declare function DatePicker(props: DatePickerProps): _emotion_react_jsx_runtime9.JSX.Element;
111
+ declare function DatePicker(props: DatePickerProps): _emotion_react_jsx_runtime1.JSX.Element;
112
112
  //#endregion
113
113
  //#region src/components/dateFilter.d.ts
114
114
  declare function DateFilter<TItem, TColumnValue>({
@@ -259,7 +259,7 @@ declare function TableSettingsProvider({
259
259
  }: Partial<TableSettingsContextType> & {
260
260
  additionalExporters?: ExporterEntry[];
261
261
  children?: ReactNode;
262
- }): _emotion_react_jsx_runtime9.JSX.Element;
262
+ }): _emotion_react_jsx_runtime1.JSX.Element;
263
263
  //#endregion
264
264
  //#region src/misc/textMatch.d.ts
265
265
  declare const textMatch: (text: string, query: string) => boolean;
package/dist/index.js CHANGED
@@ -2894,8 +2894,11 @@ function filterColumns(state) {
2894
2894
  ], ([columns, hiddenColumns, columnOrder, displaySize], draft) => {
2895
2895
  draft.activeColumns = orderBy(columns.filter((column) => !(column.hidden ?? hiddenColumns.has(column.id))), [(column) => columnOrder.indexOf(column.id)]);
2896
2896
  draft.visibleColumns = draft.activeColumns.filter((column) => displaySize === void 0 || column.displaySize === void 0 || column.displaySize.includes(displaySize));
2897
- draft.rowHeights.clear();
2898
2897
  }, { runNow: true }), [state]);
2898
+ useEffect(() => state.addReaction((state$1) => new Set(state$1.visibleColumns.map((column) => column.id)), (_, draft) => {
2899
+ draft.rowHeights.clear();
2900
+ draft.rowHeightsKey = Math.random();
2901
+ }, { runNow: false }), [state]);
2899
2902
  }
2900
2903
 
2901
2904
  //#endregion
@@ -3002,6 +3005,7 @@ function useTableState(_props) {
3002
3005
  selection: props.defaultSelection ?? /* @__PURE__ */ new Set(),
3003
3006
  expanded: props.defaultExpanded ?? /* @__PURE__ */ new Set(),
3004
3007
  rowHeights: /* @__PURE__ */ new Map(),
3008
+ rowHeightsKey: Math.random(),
3005
3009
  filters: /* @__PURE__ */ new Map(),
3006
3010
  filterValues: /* @__PURE__ */ new Map(),
3007
3011
  hiddenColumns: props.defaultHiddenColumns ?? /* @__PURE__ */ new Set(),
@@ -3469,9 +3473,14 @@ function Export() {
3469
3473
  });
3470
3474
  const [anchor, setAnchor] = useState(null);
3471
3475
  function execute({ action, exporter }) {
3472
- const { activeColumns, activeItems, items } = table.getState();
3476
+ const { activeColumns, activeItems, selection, items } = table.getState();
3473
3477
  const columns = activeColumns.map((column) => column.exportHeader);
3474
- const rows = (all ? items : activeItems).map((item) => activeColumns.map((column) => column.exportCell(column.value(item.value), item.value)));
3478
+ let exportedItems = items;
3479
+ if (!all) {
3480
+ exportedItems = activeItems;
3481
+ if (selection.size > 0) exportedItems = exportedItems.filter((item) => selection.has(item.id));
3482
+ }
3483
+ const rows = exportedItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item.value), item.value)));
3475
3484
  if (action === "copy") {
3476
3485
  const data = exporter.exportToString(columns, rows);
3477
3486
  navigator.clipboard.writeText(data);
@@ -3690,7 +3699,7 @@ function SelectComponent({ itemId }) {
3690
3699
 
3691
3700
  //#endregion
3692
3701
  //#region src/components/row.tsx
3693
- const Row = memo(function Row$1({ itemId, rowIndex }) {
3702
+ const Row = memo(function Row$1({ itemId, rowIndex, rowHeightsKey }) {
3694
3703
  const table = useTableContext();
3695
3704
  const divRef = useRef(null);
3696
3705
  const detailsDivRef = useRef(null);
@@ -3737,7 +3746,8 @@ const Row = memo(function Row$1({ itemId, rowIndex }) {
3737
3746
  table,
3738
3747
  itemId,
3739
3748
  divRef.current,
3740
- detailsDivRef.current
3749
+ detailsDivRef.current,
3750
+ rowHeightsKey
3741
3751
  ]);
3742
3752
  useLayoutEffect(() => {
3743
3753
  table.getState().props.debugRender?.("render row", itemId);
@@ -3942,6 +3952,7 @@ const TableInner = memo(function TableInner$1({ hidden }) {
3942
3952
  const enableColumnSelection = table.useState((state) => state.props.enableColumnSelection);
3943
3953
  const enableExport = table.useState((state) => state.props.enableExport);
3944
3954
  const cssVariables = useCssVariables();
3955
+ const rowHeightsKey = table.useState((state) => state.rowHeightsKey);
3945
3956
  const enableClearFiltersButton = table.useState((state) => state.props.enableClearFiltersButton);
3946
3957
  useLayoutEffect(() => {
3947
3958
  table.getState().props.debugRender?.("render table inner");
@@ -4047,7 +4058,8 @@ const TableInner = memo(function TableInner$1({ hidden }) {
4047
4058
  ] })] }),
4048
4059
  children: (itemIds, startIndex) => itemIds.map((itemId, index) => /* @__PURE__ */ jsx(Row, {
4049
4060
  itemId,
4050
- rowIndex: startIndex + index
4061
+ rowIndex: startIndex + index,
4062
+ rowHeightsKey
4051
4063
  }, itemId))
4052
4064
  });
4053
4065
  });