schummar-table 1.0.0 → 1.0.1

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.js CHANGED
@@ -1602,6 +1602,70 @@ function FilterPopover({ anchor, onClose, column, children }) {
1602
1602
  });
1603
1603
  }
1604
1604
  //#endregion
1605
+ //#region src/components/hiddenColumnFilters.tsx
1606
+ /** Lets users edit the filters of columns that are not visible, see `enableHiddenColumnFilters`. */
1607
+ function HiddenColumnFilters() {
1608
+ const { props, visibleColumns, filterValues, actions } = useTableStructure();
1609
+ const IconButton = useTheme((t) => t.components.IconButton);
1610
+ const Button = useTheme((t) => t.components.Button);
1611
+ const FilterList = useTheme((t) => t.icons.FilterList);
1612
+ const title = useTheme((t) => t.text.hiddenColumnFilters);
1613
+ const [anchor, setAnchor] = useState(null);
1614
+ const [selected, setSelected] = useState();
1615
+ const columns = props.columns.filter((column) => column.filter && !visibleColumns.some((visible) => visible.id === column.id));
1616
+ if (columns.length === 0) return null;
1617
+ const isActive = (columnId) => isActiveFilter(columns.find((column) => column.id === columnId)?.filter, filterValues.get(columnId));
1618
+ const anyActive = columns.some((column) => isActive(column.id));
1619
+ const selectedColumn = columns.find((column) => column.id === selected);
1620
+ function close() {
1621
+ setAnchor(null);
1622
+ setSelected(void 0);
1623
+ }
1624
+ const color = (active) => active ? "var(--primaryMain)" : "#b0bac9";
1625
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(IconButton, {
1626
+ onClick: (event) => setAnchor(event.currentTarget),
1627
+ css: { color: color(anyActive) },
1628
+ children: /* @__PURE__ */ jsx(FilterList, {})
1629
+ }), anchor && /* @__PURE__ */ jsx(FilterPopover, {
1630
+ anchor,
1631
+ onClose: close,
1632
+ column: selectedColumn,
1633
+ children: selectedColumn ? /* @__PURE__ */ jsxs("div", {
1634
+ css: { display: "grid" },
1635
+ children: [/* @__PURE__ */ jsxs(Button, {
1636
+ onClick: () => setSelected(void 0),
1637
+ css: {
1638
+ justifyContent: "flex-start",
1639
+ color: "inherit"
1640
+ },
1641
+ children: ["‹ ", selectedColumn.header]
1642
+ }), /* @__PURE__ */ jsx(FilterPanel, {
1643
+ column: selectedColumn,
1644
+ close
1645
+ }, selectedColumn.id)]
1646
+ }) : /* @__PURE__ */ jsxs("div", {
1647
+ css: {
1648
+ padding: "calc(var(--spacing) * 2)",
1649
+ display: "grid",
1650
+ gap: "var(--spacing)"
1651
+ },
1652
+ children: [/* @__PURE__ */ jsx("div", { children: title }), columns.map((column) => /* @__PURE__ */ jsx(Button, {
1653
+ onClick: () => setSelected(column.id),
1654
+ onContextMenu: (event) => {
1655
+ actions.setFilterValue(column.id, void 0);
1656
+ event.preventDefault();
1657
+ },
1658
+ startIcon: /* @__PURE__ */ jsx(FilterList, { css: { color: color(isActive(column.id)) } }),
1659
+ css: {
1660
+ justifyContent: "flex-start",
1661
+ color: isActive(column.id) ? "var(--primaryMain)" : "inherit"
1662
+ },
1663
+ children: column.header
1664
+ }, column.id))]
1665
+ })
1666
+ })] });
1667
+ }
1668
+ //#endregion
1605
1669
  //#region src/components/sortComponent.tsx
1606
1670
  function SortComponent({ children }) {
1607
1671
  const { sort, activeColumns, props, actions } = useTableStructure();
@@ -1661,7 +1725,7 @@ function SortComponent({ children }) {
1661
1725
  //#region src/components/columnHeader.tsx
1662
1726
  function ColumnHeader() {
1663
1727
  const columnId = useColumnContext();
1664
- const { activeColumns } = useTableStructure();
1728
+ const { props, activeColumns, visibleColumns } = useTableStructure();
1665
1729
  const column = activeColumns.find((column) => column.id === columnId);
1666
1730
  const { classes, styles } = useTheme((theme) => columnTheme(theme, column));
1667
1731
  return /* @__PURE__ */ jsxs("div", {
@@ -1679,6 +1743,7 @@ function ColumnHeader() {
1679
1743
  /* @__PURE__ */ jsx(SortComponent, { children: column?.header }),
1680
1744
  /* @__PURE__ */ jsx("div", { css: { flex: 1 } }),
1681
1745
  /* @__PURE__ */ jsx(FilterControl, {}),
1746
+ props.enableHiddenColumnFilters && visibleColumns[visibleColumns.length - 1]?.id === columnId && /* @__PURE__ */ jsx(HiddenColumnFilters, {}),
1682
1747
  /* @__PURE__ */ jsx(ResizeHandle, {})
1683
1748
  ]
1684
1749
  });
@@ -1853,70 +1918,6 @@ function Export() {
1853
1918
  })] });
1854
1919
  }
1855
1920
  //#endregion
1856
- //#region src/components/hiddenColumnFilters.tsx
1857
- /** Lets users edit the filters of columns that are not visible, see `enableHiddenColumnFilters`. */
1858
- function HiddenColumnFilters() {
1859
- const { props, visibleColumns, filterValues, actions } = useTableStructure();
1860
- const IconButton = useTheme((t) => t.components.IconButton);
1861
- const Button = useTheme((t) => t.components.Button);
1862
- const FilterList = useTheme((t) => t.icons.FilterList);
1863
- const title = useTheme((t) => t.text.hiddenColumnFilters);
1864
- const [anchor, setAnchor] = useState(null);
1865
- const [selected, setSelected] = useState();
1866
- const columns = props.columns.filter((column) => column.filter && !visibleColumns.some((visible) => visible.id === column.id));
1867
- if (columns.length === 0) return null;
1868
- const isActive = (columnId) => isActiveFilter(columns.find((column) => column.id === columnId)?.filter, filterValues.get(columnId));
1869
- const anyActive = columns.some((column) => isActive(column.id));
1870
- const selectedColumn = columns.find((column) => column.id === selected);
1871
- function close() {
1872
- setAnchor(null);
1873
- setSelected(void 0);
1874
- }
1875
- const color = (active) => active ? "var(--primaryMain)" : "#b0bac9";
1876
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(IconButton, {
1877
- onClick: (event) => setAnchor(event.currentTarget),
1878
- css: { color: color(anyActive) },
1879
- children: /* @__PURE__ */ jsx(FilterList, {})
1880
- }), anchor && /* @__PURE__ */ jsx(FilterPopover, {
1881
- anchor,
1882
- onClose: close,
1883
- column: selectedColumn,
1884
- children: selectedColumn ? /* @__PURE__ */ jsxs("div", {
1885
- css: { display: "grid" },
1886
- children: [/* @__PURE__ */ jsxs(Button, {
1887
- onClick: () => setSelected(void 0),
1888
- css: {
1889
- justifyContent: "flex-start",
1890
- color: "inherit"
1891
- },
1892
- children: ["‹ ", selectedColumn.header]
1893
- }), /* @__PURE__ */ jsx(FilterPanel, {
1894
- column: selectedColumn,
1895
- close
1896
- }, selectedColumn.id)]
1897
- }) : /* @__PURE__ */ jsxs("div", {
1898
- css: {
1899
- padding: "calc(var(--spacing) * 2)",
1900
- display: "grid",
1901
- gap: "var(--spacing)"
1902
- },
1903
- children: [/* @__PURE__ */ jsx("div", { children: title }), columns.map((column) => /* @__PURE__ */ jsx(Button, {
1904
- onClick: () => setSelected(column.id),
1905
- onContextMenu: (event) => {
1906
- actions.setFilterValue(column.id, void 0);
1907
- event.preventDefault();
1908
- },
1909
- startIcon: /* @__PURE__ */ jsx(FilterList, { css: { color: color(isActive(column.id)) } }),
1910
- css: {
1911
- justifyContent: "flex-start",
1912
- color: isActive(column.id) ? "var(--primaryMain)" : "inherit"
1913
- },
1914
- children: column.header
1915
- }, column.id))]
1916
- })
1917
- })] });
1918
- }
1919
- //#endregion
1920
1921
  //#region src/components/tableHeader.tsx
1921
1922
  const TableHeader = memo(function TableHeader() {
1922
1923
  const { props, visibleColumns } = useTableStructure();
@@ -1946,8 +1947,8 @@ const TableHeader = memo(function TableHeader() {
1946
1947
  enableSelection && /* @__PURE__ */ jsx(SelectAll, {}),
1947
1948
  enableColumnSelection && /* @__PURE__ */ jsx(ColumnSelection, {}),
1948
1949
  enableExport && /* @__PURE__ */ jsx(Export, {}),
1949
- enableHiddenColumnFilters && /* @__PURE__ */ jsx(HiddenColumnFilters, {}),
1950
- (enableSelection || enableColumnSelection || enableExport || enableHiddenColumnFilters) && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", { css: { flex: 1 } }), /* @__PURE__ */ jsx(ResizeHandleView, {})] })
1950
+ enableHiddenColumnFilters && visibleColumns.length === 0 && /* @__PURE__ */ jsx(HiddenColumnFilters, {}),
1951
+ (enableSelection || enableColumnSelection || enableExport || enableHiddenColumnFilters && visibleColumns.length === 0) && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", { css: { flex: 1 } }), /* @__PURE__ */ jsx(ResizeHandleView, {})] })
1951
1952
  ]
1952
1953
  }),
1953
1954
  visibleColumns.map((column) => /* @__PURE__ */ jsx(ColumnContext.Provider, {