schummar-table 1.0.4 → 1.1.0

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.
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_tableTheme = require("./tableTheme-CsTWp3yn.cjs");
3
- const require_useTheme = require("./useTheme-BrKiZfIC.cjs");
3
+ const require_useTheme = require("./useTheme-DLbyOgz7.cjs");
4
4
  let react = require("react");
5
5
  let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
6
6
  let _mantine_core = require("@mantine/core");
@@ -1,4 +1,4 @@
1
- import { l as PartialTableTheme } from "./types-CWF6E2Xg.cjs";
1
+ import { l as PartialTableTheme } from "./types-DCfeZ6qS.cjs";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/theme/mantineTheme/index.d.ts
4
4
  export declare const mantineTheme: PartialTableTheme;
@@ -1,4 +1,4 @@
1
- import { l as PartialTableTheme } from "./types-Dlq59yQq.js";
1
+ import { l as PartialTableTheme } from "./types-13m4fK5g.js";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/theme/mantineTheme/index.d.ts
4
4
  export declare const mantineTheme: PartialTableTheme;
@@ -1,5 +1,5 @@
1
1
  import { a as TableSettingsProvider, n as Popover, t as mergeThemes } from "./tableTheme-BgaqIBux.js";
2
- import { C as endOfDay, M as useCssVariables, S as dateIntersect, v as DatePickerQuickOptions } from "./useTheme-B2ejsCOL.js";
2
+ import { C as endOfDay, M as useCssVariables, S as dateIntersect, v as DatePickerQuickOptions } from "./useTheme-C4YfOu-U.js";
3
3
  import { useEffect, useMemo, useState } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "@emotion/react/jsx-runtime";
5
5
  import { ActionIcon, Button, Checkbox, Indicator, Loader, TextInput } from "@mantine/core";
@@ -1,4 +1,4 @@
1
- import { l as PartialTableTheme } from "./types-CWF6E2Xg.cjs";
1
+ import { l as PartialTableTheme } from "./types-DCfeZ6qS.cjs";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/theme/mui4Theme/index.d.ts
4
4
  export declare const mui4Theme: PartialTableTheme;
@@ -1,4 +1,4 @@
1
- import { l as PartialTableTheme } from "./types-Dlq59yQq.js";
1
+ import { l as PartialTableTheme } from "./types-13m4fK5g.js";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/theme/mui4Theme/index.d.ts
4
4
  export declare const mui4Theme: PartialTableTheme;
@@ -1,4 +1,4 @@
1
- import { l as PartialTableTheme } from "./types-CWF6E2Xg.cjs";
1
+ import { l as PartialTableTheme } from "./types-DCfeZ6qS.cjs";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/theme/mui5Theme/index.d.ts
4
4
  export declare const mui5Theme: PartialTableTheme;
@@ -1,4 +1,4 @@
1
- import { l as PartialTableTheme } from "./types-Dlq59yQq.js";
1
+ import { l as PartialTableTheme } from "./types-13m4fK5g.js";
2
2
  import { ReactNode } from "react";
3
3
  //#region src/theme/mui5Theme/index.d.ts
4
4
  export declare const mui5Theme: PartialTableTheme;
@@ -98,7 +98,7 @@ declare function DatePickerQuickOptions({ onSelect, ...props }: DatePickerProps
98
98
  declare function DefaultDatePicker(props: DatePickerProps): import("@emotion/react/jsx-runtime").JSX.Element;
99
99
  //#endregion
100
100
  //#region src/state/persistence.d.ts
101
- declare const PERSIST_KEYS: readonly ['sort', 'selection', 'expanded', 'hiddenColumns', 'filterValues', 'columnWidths'];
101
+ declare const PERSIST_KEYS: readonly ['sort', 'selection', 'expanded', 'hiddenColumns', 'columnOrder', 'filterValues', 'columnWidths'];
102
102
  type PersistKey = (typeof PERSIST_KEYS)[number];
103
103
  type TableStateStorage = {
104
104
  getItem: (key: string) => string | null | Promise<string | null>;
@@ -158,6 +158,8 @@ interface TableTheme<TItem = unknown> {
158
158
  rangeMax: ReactNode;
159
159
  calendarWeek: ReactNode;
160
160
  hiddenColumnFilters: ReactNode;
161
+ moveColumnLeft: string;
162
+ moveColumnRight: string;
161
163
  };
162
164
  /** Define styles. */
163
165
  classes?: {
@@ -200,6 +202,8 @@ interface TableTheme<TItem = unknown> {
200
202
  onContextMenu?: (event: React.MouseEvent<Element>) => void;
201
203
  className?: string;
202
204
  type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
205
+ disabled?: boolean;
206
+ 'aria-label'?: string;
203
207
  }>;
204
208
  Button: ComponentType<{
205
209
  children: ReactNode;
@@ -352,6 +356,13 @@ interface TableProps<TItem> extends PartialTableTheme<TItem> {
352
356
  hiddenColumns?: Set<Id>;
353
357
  /** Called when hidden columns change. */
354
358
  onHiddenColumnsChange?: (hiddenColumns: Set<Id>) => void;
359
+ /** Default column order, by column id. Columns missing from it keep their place relative to the
360
+ * column defined before them. */
361
+ defaultColumnOrder?: Id[];
362
+ /** If given, controls the column order. */
363
+ columnOrder?: Id[];
364
+ /** Called when the column order changes, with the ids of all columns. */
365
+ onColumnOrderChange?: (columnOrder: Id[]) => void;
355
366
  /** Default filter values by column id. Columns without an entry use their filter's `defaultValue`. */
356
367
  defaultFilterValues?: Map<Id, unknown>;
357
368
  /** If given, controls filter values. Columns without an entry use their filter's `defaultValue`;
@@ -418,6 +429,10 @@ interface TableProps<TItem> extends PartialTableTheme<TItem> {
418
429
  * @default true
419
430
  */
420
431
  enableColumnResize?: boolean | 'visualOnly';
432
+ /** Allow to reorder columns by dragging their headers and from the column selection menu.
433
+ * @default true
434
+ */
435
+ enableColumnReorder?: boolean;
421
436
  /** If enabled, automatically store table state in localStorage, localForage or another compatible storage. */
422
437
  persist?: {
423
438
  storage: TableStateStorage;
@@ -459,6 +474,8 @@ interface TableRef {
459
474
  setExpanded: (expanded: Set<Id>) => void;
460
475
  getHiddenColumns: () => Set<Id>;
461
476
  setHiddenColumns: (hidden: Set<Id>) => void;
477
+ getColumnOrder: () => Id[];
478
+ setColumnOrder: (columnOrder: Id[]) => void;
462
479
  getFilterValues: () => Map<Id, unknown>;
463
480
  setFilterValues: (filterValues: Map<Id, unknown>) => void;
464
481
  }
@@ -530,6 +547,8 @@ interface TableState<TItem> {
530
547
  selection: Set<Id>;
531
548
  expanded: Set<Id>;
532
549
  hiddenColumns: Set<Id>;
550
+ /** Ids of all columns, in display order. */
551
+ columnOrder: Id[];
533
552
  columnWidths: Map<Id, string>;
534
553
  /** Filter values by column id, defaults included. Hidden columns keep theirs. */
535
554
  filterValues: Map<Id, unknown>;
@@ -559,6 +578,9 @@ interface TableActions<TItem = unknown> {
559
578
  setExpanded: (expanded: Set<Id>) => void;
560
579
  toggleExpanded: (itemId: Id) => void;
561
580
  setHiddenColumns: (hiddenColumns: Set<Id>) => void;
581
+ setColumnOrder: (columnOrder: Id[]) => void;
582
+ /** Moves a column to the position of `targetId`, shifting the columns in between. */
583
+ moveColumn: (columnId: Id, targetId: Id) => void;
562
584
  setColumnWidth: (columnId: Id, width: string | undefined) => void;
563
585
  setFilterValues: (filterValues: Map<Id, unknown>) => void;
564
586
  setFilterValue: (columnId: Id, value: unknown) => void;
@@ -620,4 +642,4 @@ interface Filter<TInput, TState = any, TOptions = any> extends FilterOptions<TSt
620
642
  }
621
643
  //#endregion
622
644
  export { DateRange as A, thisWeek as B, TableStateStorage as C, DatePickerProvider as D, DatePickerProps as E, endOfDay as F, today as H, getCalendarWeek as I, lastDays as L, commonQuickOptions as M, dateClamp as N, DatePickerQuickOption as O, dateIntersect as P, startOfDay as R, WrapRowProps as S, DatePickerChangeSource as T, thisYear as V, TableProps as _, FilterComponentProps as a, TableStructure as b, InternalColumn as c, SingleOrMultiple as d, Sort as f, TableItem as g, TableContextValue as h, Filter as i, DefaultDatePicker as j, DatePickerQuickOptions as k, PartialTableTheme as l, TableActions as m, ColumnFactory as n, FilterOptions as o, SortDirection as p, ColumnGenerator as r, Id as s, Column as t, SingleOf as u, TableRef as v, DatePicker as w, TableTheme as x, TableState as y, thisMonth as z };
623
- //# sourceMappingURL=types-Dlq59yQq.d.ts.map
645
+ //# sourceMappingURL=types-13m4fK5g.d.ts.map
@@ -98,7 +98,7 @@ declare function DatePickerQuickOptions({ onSelect, ...props }: DatePickerProps
98
98
  declare function DefaultDatePicker(props: DatePickerProps): import("@emotion/react/jsx-runtime").JSX.Element;
99
99
  //#endregion
100
100
  //#region src/state/persistence.d.ts
101
- declare const PERSIST_KEYS: readonly ['sort', 'selection', 'expanded', 'hiddenColumns', 'filterValues', 'columnWidths'];
101
+ declare const PERSIST_KEYS: readonly ['sort', 'selection', 'expanded', 'hiddenColumns', 'columnOrder', 'filterValues', 'columnWidths'];
102
102
  type PersistKey = (typeof PERSIST_KEYS)[number];
103
103
  type TableStateStorage = {
104
104
  getItem: (key: string) => string | null | Promise<string | null>;
@@ -158,6 +158,8 @@ interface TableTheme<TItem = unknown> {
158
158
  rangeMax: ReactNode;
159
159
  calendarWeek: ReactNode;
160
160
  hiddenColumnFilters: ReactNode;
161
+ moveColumnLeft: string;
162
+ moveColumnRight: string;
161
163
  };
162
164
  /** Define styles. */
163
165
  classes?: {
@@ -200,6 +202,8 @@ interface TableTheme<TItem = unknown> {
200
202
  onContextMenu?: (event: React.MouseEvent<Element>) => void;
201
203
  className?: string;
202
204
  type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
205
+ disabled?: boolean;
206
+ 'aria-label'?: string;
203
207
  }>;
204
208
  Button: ComponentType<{
205
209
  children: ReactNode;
@@ -352,6 +356,13 @@ interface TableProps<TItem> extends PartialTableTheme<TItem> {
352
356
  hiddenColumns?: Set<Id>;
353
357
  /** Called when hidden columns change. */
354
358
  onHiddenColumnsChange?: (hiddenColumns: Set<Id>) => void;
359
+ /** Default column order, by column id. Columns missing from it keep their place relative to the
360
+ * column defined before them. */
361
+ defaultColumnOrder?: Id[];
362
+ /** If given, controls the column order. */
363
+ columnOrder?: Id[];
364
+ /** Called when the column order changes, with the ids of all columns. */
365
+ onColumnOrderChange?: (columnOrder: Id[]) => void;
355
366
  /** Default filter values by column id. Columns without an entry use their filter's `defaultValue`. */
356
367
  defaultFilterValues?: Map<Id, unknown>;
357
368
  /** If given, controls filter values. Columns without an entry use their filter's `defaultValue`;
@@ -418,6 +429,10 @@ interface TableProps<TItem> extends PartialTableTheme<TItem> {
418
429
  * @default true
419
430
  */
420
431
  enableColumnResize?: boolean | 'visualOnly';
432
+ /** Allow to reorder columns by dragging their headers and from the column selection menu.
433
+ * @default true
434
+ */
435
+ enableColumnReorder?: boolean;
421
436
  /** If enabled, automatically store table state in localStorage, localForage or another compatible storage. */
422
437
  persist?: {
423
438
  storage: TableStateStorage;
@@ -459,6 +474,8 @@ interface TableRef {
459
474
  setExpanded: (expanded: Set<Id>) => void;
460
475
  getHiddenColumns: () => Set<Id>;
461
476
  setHiddenColumns: (hidden: Set<Id>) => void;
477
+ getColumnOrder: () => Id[];
478
+ setColumnOrder: (columnOrder: Id[]) => void;
462
479
  getFilterValues: () => Map<Id, unknown>;
463
480
  setFilterValues: (filterValues: Map<Id, unknown>) => void;
464
481
  }
@@ -530,6 +547,8 @@ interface TableState<TItem> {
530
547
  selection: Set<Id>;
531
548
  expanded: Set<Id>;
532
549
  hiddenColumns: Set<Id>;
550
+ /** Ids of all columns, in display order. */
551
+ columnOrder: Id[];
533
552
  columnWidths: Map<Id, string>;
534
553
  /** Filter values by column id, defaults included. Hidden columns keep theirs. */
535
554
  filterValues: Map<Id, unknown>;
@@ -559,6 +578,9 @@ interface TableActions<TItem = unknown> {
559
578
  setExpanded: (expanded: Set<Id>) => void;
560
579
  toggleExpanded: (itemId: Id) => void;
561
580
  setHiddenColumns: (hiddenColumns: Set<Id>) => void;
581
+ setColumnOrder: (columnOrder: Id[]) => void;
582
+ /** Moves a column to the position of `targetId`, shifting the columns in between. */
583
+ moveColumn: (columnId: Id, targetId: Id) => void;
562
584
  setColumnWidth: (columnId: Id, width: string | undefined) => void;
563
585
  setFilterValues: (filterValues: Map<Id, unknown>) => void;
564
586
  setFilterValue: (columnId: Id, value: unknown) => void;
@@ -620,4 +642,4 @@ interface Filter<TInput, TState = any, TOptions = any> extends FilterOptions<TSt
620
642
  }
621
643
  //#endregion
622
644
  export { DateRange as A, thisWeek as B, TableStateStorage as C, DatePickerProvider as D, DatePickerProps as E, endOfDay as F, today as H, getCalendarWeek as I, lastDays as L, commonQuickOptions as M, dateClamp as N, DatePickerQuickOption as O, dateIntersect as P, startOfDay as R, WrapRowProps as S, DatePickerChangeSource as T, thisYear as V, TableProps as _, FilterComponentProps as a, TableStructure as b, InternalColumn as c, SingleOrMultiple as d, Sort as f, TableItem as g, TableContextValue as h, Filter as i, DefaultDatePicker as j, DatePickerQuickOptions as k, PartialTableTheme as l, TableActions as m, ColumnFactory as n, FilterOptions as o, SortDirection as p, ColumnGenerator as r, Id as s, Column as t, SingleOf as u, TableRef as v, DatePicker as w, TableTheme as x, TableState as y, thisMonth as z };
623
- //# sourceMappingURL=types-CWF6E2Xg.d.cts.map
645
+ //# sourceMappingURL=types-DCfeZ6qS.d.cts.map
@@ -1533,7 +1533,12 @@ const iconButtonCss = css({
1533
1533
  color: "inherit",
1534
1534
  background: "transparent",
1535
1535
  "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.04)" },
1536
- "&:active": { transformColor: "scale3d(0.95, 0.95, 1)" }
1536
+ "&:active": { transformColor: "scale3d(0.95, 0.95, 1)" },
1537
+ "&:disabled": {
1538
+ opacity: .3,
1539
+ cursor: "default",
1540
+ backgroundColor: "transparent"
1541
+ }
1537
1542
  });
1538
1543
  const IconButton = ({ className, ...props }) => {
1539
1544
  const libraryClass = useLibraryClassName();
@@ -1635,7 +1640,9 @@ const defaultTableTheme = {
1635
1640
  rangeMin: "Min",
1636
1641
  rangeMax: "Max",
1637
1642
  calendarWeek: "Wk",
1638
- hiddenColumnFilters: "Filters of hidden columns"
1643
+ hiddenColumnFilters: "Filters of hidden columns",
1644
+ moveColumnLeft: "Move column left",
1645
+ moveColumnRight: "Move column right"
1639
1646
  },
1640
1647
  components: defaultComponents,
1641
1648
  icons: {
@@ -1790,4 +1797,4 @@ function columnTheme(theme, column) {
1790
1797
  //#endregion
1791
1798
  export { today as A, endOfDay as C, thisMonth as D, startOfDay$1 as E, useCssVariables as M, thisWeek as O, dateIntersect as S, lastDays as T, DatePickerProvider as _, useLibraryClassName as a, commonQuickOptions as b, castArray as c, getDescendants as d, helpers_exports as f, DatePicker as g, uniq as h, useTheme$1 as i, debounce as j, thisYear as k, cx as l, toSingles as m, columnTheme as n, useUserClassName as o, orderBy as p, useTableTheme as r, asString as s, ThemeContext as t, getAncestors as u, DatePickerQuickOptions as v, getCalendarWeek as w, dateClamp as x, DefaultDatePicker as y };
1792
1799
 
1793
- //# sourceMappingURL=useTheme-B2ejsCOL.js.map
1800
+ //# sourceMappingURL=useTheme-C4YfOu-U.js.map