schummar-table 1.0.5 → 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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { r as ExporterEntry } from "./exporter-Dv2Vqqth.cjs";
2
- import { A as DateRange, B as thisWeek, C as TableStateStorage, D as DatePickerProvider, E as DatePickerProps, F as endOfDay, H as today, I as getCalendarWeek, L as lastDays, M as commonQuickOptions, N as dateClamp, O as DatePickerQuickOption, P as dateIntersect, R as startOfDay, S as WrapRowProps, T as DatePickerChangeSource, V as thisYear, _ as TableProps, a as FilterComponentProps, b as TableStructure, c as InternalColumn, d as SingleOrMultiple, f as Sort, g as TableItem, h as TableContextValue, i as Filter, j as DefaultDatePicker, k as DatePickerQuickOptions, l as PartialTableTheme, m as TableActions, n as ColumnFactory, o as FilterOptions, p as SortDirection, r as ColumnGenerator, s as Id, t as Column, u as SingleOf, v as TableRef, w as DatePicker, x as TableTheme, y as TableState, z as thisMonth } from "./types-CWF6E2Xg.cjs";
2
+ import { A as DateRange, B as thisWeek, C as TableStateStorage, D as DatePickerProvider, E as DatePickerProps, F as endOfDay, H as today, I as getCalendarWeek, L as lastDays, M as commonQuickOptions, N as dateClamp, O as DatePickerQuickOption, P as dateIntersect, R as startOfDay, S as WrapRowProps, T as DatePickerChangeSource, V as thisYear, _ as TableProps, a as FilterComponentProps, b as TableStructure, c as InternalColumn, d as SingleOrMultiple, f as Sort, g as TableItem, h as TableContextValue, i as Filter, j as DefaultDatePicker, k as DatePickerQuickOptions, l as PartialTableTheme, m as TableActions, n as ColumnFactory, o as FilterOptions, p as SortDirection, r as ColumnGenerator, s as Id, t as Column, u as SingleOf, v as TableRef, w as DatePicker, x as TableTheme, y as TableState, z as thisMonth } from "./types-DCfeZ6qS.cjs";
3
3
  import { ComponentType, HTMLProps, ReactElement, ReactNode, Ref } from "react";
4
4
  //#endregion
5
5
  //#region src/components/autoFocusTextField.d.ts
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { r as ExporterEntry } from "./exporter-Dv2Vqqth.js";
2
- import { A as DateRange, B as thisWeek, C as TableStateStorage, D as DatePickerProvider, E as DatePickerProps, F as endOfDay, H as today, I as getCalendarWeek, L as lastDays, M as commonQuickOptions, N as dateClamp, O as DatePickerQuickOption, P as dateIntersect, R as startOfDay, S as WrapRowProps, T as DatePickerChangeSource, V as thisYear, _ as TableProps, a as FilterComponentProps, b as TableStructure, c as InternalColumn, d as SingleOrMultiple, f as Sort, g as TableItem, h as TableContextValue, i as Filter, j as DefaultDatePicker, k as DatePickerQuickOptions, l as PartialTableTheme, m as TableActions, n as ColumnFactory, o as FilterOptions, p as SortDirection, r as ColumnGenerator, s as Id, t as Column, u as SingleOf, v as TableRef, w as DatePicker, x as TableTheme, y as TableState, z as thisMonth } from "./types-Dlq59yQq.js";
2
+ import { A as DateRange, B as thisWeek, C as TableStateStorage, D as DatePickerProvider, E as DatePickerProps, F as endOfDay, H as today, I as getCalendarWeek, L as lastDays, M as commonQuickOptions, N as dateClamp, O as DatePickerQuickOption, P as dateIntersect, R as startOfDay, S as WrapRowProps, T as DatePickerChangeSource, V as thisYear, _ as TableProps, a as FilterComponentProps, b as TableStructure, c as InternalColumn, d as SingleOrMultiple, f as Sort, g as TableItem, h as TableContextValue, i as Filter, j as DefaultDatePicker, k as DatePickerQuickOptions, l as PartialTableTheme, m as TableActions, n as ColumnFactory, o as FilterOptions, p as SortDirection, r as ColumnGenerator, s as Id, t as Column, u as SingleOf, v as TableRef, w as DatePicker, x as TableTheme, y as TableState, z as thisMonth } from "./types-13m4fK5g.js";
3
3
  import { ComponentType, HTMLProps, ReactElement, ReactNode, Ref } from "react";
4
4
  //#region src/components/autoFocusTextField.d.ts
5
5
  type Props = TableTheme['components']['TextField'] extends ComponentType<infer T> ? T : never;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as TableSettingsProvider, i as TableSettingsContext, r as defaultClasses, t as mergeThemes } from "./tableTheme-BgaqIBux.js";
2
- import { A as today, C as endOfDay, D as thisMonth, E as startOfDay, M as useCssVariables, O as thisWeek, S as dateIntersect, T as lastDays, _ as DatePickerProvider, a as useLibraryClassName, b as commonQuickOptions, c as castArray, d as getDescendants, f as helpers_exports, g as DatePicker, h as uniq, i as useTheme, j as debounce, k as thisYear, l as cx, m as toSingles, n as columnTheme, o as useUserClassName, p as orderBy, r as useTableTheme, s as asString, t as ThemeContext, u as getAncestors, v as DatePickerQuickOptions, w as getCalendarWeek, x as dateClamp, y as DefaultDatePicker } from "./useTheme-B2ejsCOL.js";
2
+ import { A as today, C as endOfDay, D as thisMonth, E as startOfDay, M as useCssVariables, O as thisWeek, S as dateIntersect, T as lastDays, _ as DatePickerProvider, a as useLibraryClassName, b as commonQuickOptions, c as castArray, d as getDescendants, f as helpers_exports, g as DatePicker, h as uniq, i as useTheme, j as debounce, k as thisYear, l as cx, m as toSingles, n as columnTheme, o as useUserClassName, p as orderBy, r as useTableTheme, s as asString, t as ThemeContext, u as getAncestors, v as DatePickerQuickOptions, w as getCalendarWeek, x as dateClamp, y as DefaultDatePicker } from "./useTheme-C4YfOu-U.js";
3
3
  import { createContext, isValidElement, memo, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "@emotion/react/jsx-runtime";
5
5
  import { ClassNames, css } from "@emotion/react";
@@ -94,6 +94,7 @@ const PERSIST_KEYS = [
94
94
  "selection",
95
95
  "expanded",
96
96
  "hiddenColumns",
97
+ "columnOrder",
97
98
  "filterValues",
98
99
  "columnWidths"
99
100
  ];
@@ -246,10 +247,25 @@ function useNormalized(value, normalized, set) {
246
247
  }
247
248
  //#endregion
248
249
  //#region src/state/useColumns.ts
250
+ /** Columns missing from `order` follow the column defined before them. */
251
+ function orderColumns(columns, order) {
252
+ if (order.length === 0) return columns;
253
+ const ids = new Set(order);
254
+ const byId = new Map(columns.map((column) => [column.id, column]));
255
+ const result = [...ids].flatMap((id) => byId.get(id) ?? []);
256
+ columns.forEach((column, index) => {
257
+ if (ids.has(column.id)) return;
258
+ const previous = columns[index - 1];
259
+ result.splice(previous ? result.indexOf(previous) + 1 : 0, 0, column);
260
+ });
261
+ return result;
262
+ }
249
263
  function useColumns(props, displaySize) {
250
264
  const [hiddenColumns, setHiddenColumns, setHiddenColumnsInternal] = useControllableState(props.hiddenColumns, () => props.defaultHiddenColumns ?? /* @__PURE__ */ new Set(), props.onHiddenColumnsChange);
265
+ const [storedOrder, setColumnOrder, setColumnOrderInternal] = useControllableState(props.columnOrder, () => props.defaultColumnOrder ?? [], props.onColumnOrderChange);
251
266
  const [columnWidths, setColumnWidths] = useState(() => /* @__PURE__ */ new Map());
252
- const allColumns = props.columns;
267
+ const allColumns = useMemo(() => orderColumns(props.columns, storedOrder), [props.columns, storedOrder]);
268
+ const columnOrder = useMemo(() => allColumns.map((column) => column.id), [allColumns]);
253
269
  const matchesDisplaySize = (column) => displaySize === void 0 || column.displaySize === void 0 || column.displaySize.includes(displaySize);
254
270
  const columns = useMemo(() => allColumns.filter(matchesDisplaySize), [allColumns, displaySize]);
255
271
  const activeColumns = useMemo(() => allColumns.filter((column) => !(column.hidden ?? hiddenColumns.has(column.id))), [allColumns, hiddenColumns]);
@@ -257,6 +273,10 @@ function useColumns(props, displaySize) {
257
273
  hiddenColumns,
258
274
  setHiddenColumns,
259
275
  setHiddenColumnsInternal,
276
+ storedOrder,
277
+ columnOrder,
278
+ setColumnOrder,
279
+ setColumnOrderInternal,
260
280
  columnWidths,
261
281
  setColumnWidths,
262
282
  columns,
@@ -609,11 +629,13 @@ const defaultProps = {
609
629
  stickyFooter: true,
610
630
  enableColumnSelection: true,
611
631
  enableColumnResize: true,
632
+ enableColumnReorder: true,
612
633
  displaySizeOverrides: { mobile: {
613
634
  enableSelection: false,
614
635
  enableColumnSelection: false,
615
636
  enableExport: false,
616
- enableColumnResize: false
637
+ enableColumnResize: false,
638
+ enableColumnReorder: false
617
639
  } }
618
640
  };
619
641
  const identity = (value) => value;
@@ -777,6 +799,7 @@ function useTable(raw, onReset, isReset = false) {
777
799
  selection: selection.selection,
778
800
  expanded: expanded.expanded,
779
801
  hiddenColumns: columns.hiddenColumns,
802
+ columnOrder: columns.columnOrder,
780
803
  columnWidths: columns.columnWidths,
781
804
  filterValues: filters.filterValues,
782
805
  columns: columns.columns,
@@ -798,6 +821,7 @@ function useTable(raw, onReset, isReset = false) {
798
821
  add("selection", selection.selection, props.selection !== void 0);
799
822
  add("expanded", expanded.expanded, props.expanded !== void 0);
800
823
  add("hiddenColumns", columns.hiddenColumns, props.hiddenColumns !== void 0);
824
+ add("columnOrder", columns.storedOrder, props.columnOrder !== void 0);
801
825
  add("columnWidths", columns.columnWidths);
802
826
  add("filterValues", new Map([...filters.stored].filter(([columnId]) => isFilterValuePersisted(persist, columnId) && !isControlledFilter(props.columns, columnId))), props.filterValues !== void 0);
803
827
  return data;
@@ -810,6 +834,7 @@ function useTable(raw, onReset, isReset = false) {
810
834
  selection.selection,
811
835
  expanded.expanded,
812
836
  columns.hiddenColumns,
837
+ columns.storedOrder,
813
838
  columns.columnWidths,
814
839
  filters.stored,
815
840
  props.columns,
@@ -817,6 +842,7 @@ function useTable(raw, onReset, isReset = false) {
817
842
  props.selection !== void 0,
818
843
  props.expanded !== void 0,
819
844
  props.hiddenColumns !== void 0,
845
+ props.columnOrder !== void 0,
820
846
  props.filterValues !== void 0
821
847
  ]);
822
848
  const latest = useRef({
@@ -846,6 +872,7 @@ function useTable(raw, onReset, isReset = false) {
846
872
  if (data.selection && props.selection === void 0) selection.setSelection(data.selection);
847
873
  if (data.expanded && props.expanded === void 0) expanded.setExpanded(data.expanded);
848
874
  if (data.hiddenColumns && props.hiddenColumns === void 0) columns.setHiddenColumns(data.hiddenColumns);
875
+ if (data.columnOrder && props.columnOrder === void 0) columns.setColumnOrder(data.columnOrder);
849
876
  if (data.columnWidths) columns.setColumnWidths(data.columnWidths);
850
877
  const filterValues = data.filterValues;
851
878
  if (filterValues && props.filterValues === void 0) {
@@ -934,6 +961,18 @@ function useTable(raw, onReset, isReset = false) {
934
961
  patchState({ expanded: next });
935
962
  },
936
963
  setHiddenColumns: (hiddenColumns) => get().columns.setHiddenColumns(hiddenColumns),
964
+ setColumnOrder: (columnOrder) => get().columns.setColumnOrder(columnOrder),
965
+ moveColumn(columnId, targetId) {
966
+ const { state, columns } = get();
967
+ const next = [...state.columnOrder];
968
+ const from = next.indexOf(columnId);
969
+ const to = next.indexOf(targetId);
970
+ if (from === -1 || to === -1 || from === to) return;
971
+ next.splice(from, 1);
972
+ next.splice(to, 0, columnId);
973
+ columns.setColumnOrder(next);
974
+ patchState({ columnOrder: next });
975
+ },
937
976
  setColumnWidth(columnId, width) {
938
977
  get().columns.setColumnWidths((widths) => withEntry(widths, columnId, width));
939
978
  },
@@ -956,13 +995,14 @@ function useTable(raw, onReset, isReset = false) {
956
995
  }
957
996
  };
958
997
  });
959
- const { sort: sortValue, hiddenColumns, columnWidths, filterValues } = state;
998
+ const { sort: sortValue, hiddenColumns, columnOrder, columnWidths, filterValues } = state;
960
999
  const { columns: allColumns, activeColumns, visibleColumns } = state;
961
1000
  const structure = useMemo(() => ({
962
1001
  props,
963
1002
  displaySize,
964
1003
  sort: sortValue,
965
1004
  hiddenColumns,
1005
+ columnOrder,
966
1006
  columnWidths,
967
1007
  filterValues,
968
1008
  columns: allColumns,
@@ -976,6 +1016,7 @@ function useTable(raw, onReset, isReset = false) {
976
1016
  displaySize,
977
1017
  sortValue,
978
1018
  hiddenColumns,
1019
+ columnOrder,
979
1020
  columnWidths,
980
1021
  filterValues,
981
1022
  allColumns,
@@ -1007,6 +1048,7 @@ function useTable(raw, onReset, isReset = false) {
1007
1048
  setSelectionInternal: selection.setSelectionInternal,
1008
1049
  setExpandedInternal: expanded.setExpandedInternal,
1009
1050
  setHiddenColumnsInternal: columns.setHiddenColumnsInternal,
1051
+ setColumnOrderInternal: columns.setColumnOrderInternal,
1010
1052
  setFilterValuesInternal: filters.setFilterValuesInternal
1011
1053
  };
1012
1054
  }
@@ -1024,6 +1066,8 @@ function useTableImperativeHandle(ref, table) {
1024
1066
  setExpanded: table.setExpandedInternal,
1025
1067
  getHiddenColumns: () => actions.getState().hiddenColumns,
1026
1068
  setHiddenColumns: table.setHiddenColumnsInternal,
1069
+ getColumnOrder: () => actions.getState().columnOrder,
1070
+ setColumnOrder: table.setColumnOrderInternal,
1027
1071
  getFilterValues: () => actions.getState().filterValues,
1028
1072
  setFilterValues: table.setFilterValuesInternal
1029
1073
  }), [actions]);
@@ -1042,6 +1086,7 @@ function useTableReset(props) {
1042
1086
  if (props.expanded === void 0) props.onExpandedChange?.(props.defaultExpanded ?? /* @__PURE__ */ new Set());
1043
1087
  if (props.selection === void 0) props.onSelectionChange?.(props.defaultSelection ?? /* @__PURE__ */ new Set());
1044
1088
  if (props.hiddenColumns === void 0) props.onHiddenColumnsChange?.(props.defaultHiddenColumns ?? /* @__PURE__ */ new Set());
1089
+ if (props.columnOrder === void 0) props.onColumnOrderChange?.(props.defaultColumnOrder ?? []);
1045
1090
  props.onReset?.("table");
1046
1091
  }, [])];
1047
1092
  }
@@ -1514,6 +1559,126 @@ const TableFooter = memo(function TableFooter() {
1514
1559
  })] });
1515
1560
  });
1516
1561
  //#endregion
1562
+ //#region src/components/columnDrag.ts
1563
+ const threshold = 5;
1564
+ const interactive = "button, input, select, textarea, a, label, [role=\"button\"]";
1565
+ /**
1566
+ * Drag a column header to reorder. The drag only touches the DOM and every way out (release,
1567
+ * cancel, Escape, blur, unmount) goes through `finish`, so no drag state can outlive it.
1568
+ */
1569
+ function useColumnDrag(columnId) {
1570
+ const { props, visibleColumns, actions } = useTableStructure();
1571
+ const abort = useRef(void 0);
1572
+ useEffect(() => () => abort.current?.(), []);
1573
+ function onPointerDown(event) {
1574
+ if (!props.enableColumnReorder || event.button !== 0 || event.pointerType === "touch") return;
1575
+ if (abort.current || event.target.closest(interactive)) return;
1576
+ const header = event.currentTarget;
1577
+ const table = header.closest("[data-schummar-table]");
1578
+ const headers = [...header.parentElement?.children ?? []].filter((element) => element.hasAttribute("data-column-header"));
1579
+ const from = headers.indexOf(header);
1580
+ const ids = visibleColumns.map((column) => column.id);
1581
+ if (!table || from === -1 || headers.length !== ids.length) return;
1582
+ const { pointerId, clientX: startX } = event;
1583
+ const { style } = header;
1584
+ const previousStyle = style.cssText;
1585
+ const bodyStyle = document.body.style;
1586
+ const previousBodyStyle = {
1587
+ cursor: bodyStyle.cursor,
1588
+ userSelect: bodyStyle.userSelect
1589
+ };
1590
+ let isDragging = false;
1591
+ let target;
1592
+ let indicator;
1593
+ const stopClick = (event) => {
1594
+ event.stopPropagation();
1595
+ event.preventDefault();
1596
+ };
1597
+ function start() {
1598
+ isDragging = true;
1599
+ window.getSelection()?.removeAllRanges();
1600
+ window.addEventListener("click", stopClick, true);
1601
+ Object.assign(style, {
1602
+ zIndex: "3",
1603
+ boxShadow: "0 4px 12px rgb(0 0 0 / 20%)",
1604
+ cursor: "grabbing"
1605
+ });
1606
+ Object.assign(bodyStyle, {
1607
+ cursor: "grabbing",
1608
+ userSelect: "none"
1609
+ });
1610
+ indicator = document.createElement("div");
1611
+ Object.assign(indicator.style, {
1612
+ position: "absolute",
1613
+ top: "0",
1614
+ bottom: "0",
1615
+ width: "2px",
1616
+ marginLeft: "-1px",
1617
+ background: "var(--primaryMain)",
1618
+ zIndex: "3",
1619
+ pointerEvents: "none",
1620
+ display: "none"
1621
+ });
1622
+ table.append(indicator);
1623
+ }
1624
+ function update(clientX) {
1625
+ const rects = headers.map((header) => header.getBoundingClientRect());
1626
+ let index = 0;
1627
+ rects.forEach((rect, i) => {
1628
+ if (i !== from && rect.left + rect.width / 2 < clientX) index++;
1629
+ });
1630
+ target = index === from ? void 0 : ids[index];
1631
+ if (target === void 0) {
1632
+ indicator.style.display = "none";
1633
+ return;
1634
+ }
1635
+ const edge = index < from ? rects[index].left : rects[index].right;
1636
+ const tableRect = table.getBoundingClientRect();
1637
+ Object.assign(indicator.style, {
1638
+ display: "block",
1639
+ left: `${edge - tableRect.left - table.clientLeft + table.scrollLeft}px`
1640
+ });
1641
+ }
1642
+ function onMove(event) {
1643
+ if (event.pointerId !== pointerId) return;
1644
+ const dx = event.clientX - startX;
1645
+ if (!isDragging) {
1646
+ if (Math.abs(dx) < threshold) return;
1647
+ start();
1648
+ }
1649
+ style.transform = `translateX(${dx}px)`;
1650
+ update(event.clientX);
1651
+ }
1652
+ const onUp = (event) => event.pointerId === pointerId && finish("drop");
1653
+ const onCancel = (event) => event.pointerId === pointerId && finish("abort");
1654
+ const onKeyDown = (event) => event.key === "Escape" && finish("escape");
1655
+ const onBlur = () => finish("abort");
1656
+ const listeners = [
1657
+ ["pointermove", onMove],
1658
+ ["pointerup", onUp],
1659
+ ["pointercancel", onCancel],
1660
+ ["keydown", onKeyDown],
1661
+ ["blur", onBlur]
1662
+ ];
1663
+ function finish(reason) {
1664
+ abort.current = void 0;
1665
+ for (const [type, listener] of listeners) window.removeEventListener(type, listener);
1666
+ if (!isDragging) return;
1667
+ style.cssText = previousStyle;
1668
+ Object.assign(bodyStyle, previousBodyStyle);
1669
+ indicator?.remove();
1670
+ const releaseClick = () => window.removeEventListener("click", stopClick, true);
1671
+ if (reason === "drop") setTimeout(releaseClick);
1672
+ else if (reason === "escape") window.addEventListener("pointerup", () => setTimeout(releaseClick), { once: true });
1673
+ else releaseClick();
1674
+ if (reason === "drop" && target !== void 0) actions.moveColumn(columnId, target);
1675
+ }
1676
+ for (const [type, listener] of listeners) window.addEventListener(type, listener);
1677
+ abort.current = () => finish("abort");
1678
+ }
1679
+ return onPointerDown;
1680
+ }
1681
+ //#endregion
1517
1682
  //#region src/components/filterPanel.tsx
1518
1683
  /** Renders a column's filter UI. Changes apply after the filter's `debounce`, or on unmount. */
1519
1684
  function FilterPanel({ column, close }) {
@@ -1728,6 +1893,7 @@ function ColumnHeader() {
1728
1893
  const { props, activeColumns, visibleColumns } = useTableStructure();
1729
1894
  const column = activeColumns.find((column) => column.id === columnId);
1730
1895
  const { classes, styles } = useTheme((theme) => columnTheme(theme, column));
1896
+ const onPointerDown = useColumnDrag(columnId);
1731
1897
  return /* @__PURE__ */ jsxs("div", {
1732
1898
  "data-column-header": "",
1733
1899
  className: classes?.headerCell,
@@ -1739,6 +1905,7 @@ function ColumnHeader() {
1739
1905
  },
1740
1906
  styles?.headerCell
1741
1907
  ],
1908
+ onPointerDown,
1742
1909
  children: [
1743
1910
  /* @__PURE__ */ jsx(SortComponent, { children: column?.header }),
1744
1911
  /* @__PURE__ */ jsx("div", { css: { flex: 1 } }),
@@ -1773,13 +1940,16 @@ function ColumnSelection() {
1773
1940
  const Checkbox = useTheme((t) => t.components.Checkbox);
1774
1941
  const Button = useTheme((t) => t.components.Button);
1775
1942
  const Settings = useTheme((t) => t.icons.Settings);
1943
+ const ArrowUpward = useTheme((t) => t.icons.ArrowUpward);
1944
+ const moveLeft = useTheme((t) => t.text.moveColumnLeft);
1945
+ const moveRight = useTheme((t) => t.text.moveColumnRight);
1776
1946
  const selectColumns = useTheme((t) => t.text.selectColumns);
1777
1947
  const resetAll = useTheme((t) => t.text.resetAll);
1778
1948
  const showAll = useTheme((t) => t.text.showAllColumns);
1779
1949
  const hideAll = useTheme((t) => t.text.hideAllColumns);
1780
1950
  const classes = useTheme((t) => t.classes);
1781
1951
  const cssVariables = useCssVariables();
1782
- const { columns, hiddenColumns, actions } = useTableStructure();
1952
+ const { props, columns, hiddenColumns, actions } = useTableStructure();
1783
1953
  const [anchorElement, setAnchorElement] = useState(null);
1784
1954
  const toggle = (column, state) => {
1785
1955
  const newValue = new Set(hiddenColumns);
@@ -1824,14 +1994,41 @@ function ColumnSelection() {
1824
1994
  children: resetAll
1825
1995
  })]
1826
1996
  }),
1827
- columns.map((column) => /* @__PURE__ */ jsx(FormControlLabel, {
1828
- control: /* @__PURE__ */ jsx(Checkbox, {
1829
- checked: !(column.hidden ?? hiddenColumns.has(column.id)),
1830
- onChange: () => toggle(column),
1831
- disabled: column.hidden !== void 0
1832
- }),
1833
- label: column.header
1834
- }, column.id))
1997
+ columns.map((column, index) => {
1998
+ const previous = columns[index - 1];
1999
+ const next = columns[index + 1];
2000
+ return /* @__PURE__ */ jsxs("div", {
2001
+ css: {
2002
+ display: "flex",
2003
+ alignItems: "center"
2004
+ },
2005
+ children: [/* @__PURE__ */ jsx(FormControlLabel, {
2006
+ control: /* @__PURE__ */ jsx(Checkbox, {
2007
+ checked: !(column.hidden ?? hiddenColumns.has(column.id)),
2008
+ onChange: () => toggle(column),
2009
+ disabled: column.hidden !== void 0
2010
+ }),
2011
+ label: column.header
2012
+ }), props.enableColumnReorder && /* @__PURE__ */ jsxs("div", {
2013
+ css: {
2014
+ marginLeft: "auto",
2015
+ paddingLeft: "var(--spacing)",
2016
+ display: "flex"
2017
+ },
2018
+ children: [/* @__PURE__ */ jsx(IconButton, {
2019
+ "aria-label": moveLeft,
2020
+ disabled: !previous,
2021
+ onClick: () => previous && actions.moveColumn(column.id, previous.id),
2022
+ children: /* @__PURE__ */ jsx(ArrowUpward, {})
2023
+ }), /* @__PURE__ */ jsx(IconButton, {
2024
+ "aria-label": moveRight,
2025
+ disabled: !next,
2026
+ onClick: () => next && actions.moveColumn(column.id, next.id),
2027
+ children: /* @__PURE__ */ jsx(ArrowUpward, { css: { transform: "rotate(180deg)" } })
2028
+ })]
2029
+ })]
2030
+ }, column.id);
2031
+ })
1835
2032
  ]
1836
2033
  })
1837
2034
  })] });