schummar-table 0.9.0 → 0.10.2

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/cjs/index.js CHANGED
@@ -622,6 +622,25 @@ function useCssVariables() {
622
622
  "--secondaryContrastText": colors.secondary.contrastText
623
623
  }));
624
624
  }
625
+ function ClearFiltersButton() {
626
+ const Button2 = useTheme((t) => t.components.Button);
627
+ const textClearFilters = useTheme((t) => t.text.clearFilters);
628
+ const table = useTableContext();
629
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
630
+ css: tableTheme.defaultClasses.clearFiltersButton,
631
+ children: /* @__PURE__ */ jsxRuntime.jsx(Button2, {
632
+ variant: "outlined",
633
+ onClick: () => {
634
+ table.update((state) => {
635
+ state.activeColumns.forEach((column) => {
636
+ state.filterValues.delete(column.id);
637
+ });
638
+ });
639
+ },
640
+ children: textClearFilters
641
+ })
642
+ });
643
+ }
625
644
  function ColumnFooter() {
626
645
  const table = useTableContext();
627
646
  const columnId = useColumnContext();
@@ -1655,8 +1674,6 @@ const TableInner = react.memo(function TableInner2({
1655
1674
  const enableExport = table.useState((state) => !!state.props.enableExport.copy || !!state.props.enableExport.download);
1656
1675
  const cssVariables = useCssVariables();
1657
1676
  const enableClearFiltersButton = table.useState("props.enableClearFiltersButton");
1658
- const Button2 = useTheme((t) => t.components.Button);
1659
- const textClearFilters = useTheme((t) => t.text.clearFilters);
1660
1677
  react.useLayoutEffect(() => {
1661
1678
  var _a, _b;
1662
1679
  return (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
@@ -1683,7 +1700,11 @@ const TableInner = react.memo(function TableInner2({
1683
1700
  }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
1684
1701
  className: classes == null ? void 0 : classes.headerCell,
1685
1702
  css: [tableTheme.defaultClasses.headerCell, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
1686
- children: [enableSelection && /* @__PURE__ */ jsxRuntime.jsx(SelectComponent, {}), enableColumnSelection && /* @__PURE__ */ jsxRuntime.jsx(ColumnSelection, {}), enableExport && /* @__PURE__ */ jsxRuntime.jsx(Export$1, {}), /* @__PURE__ */ jsxRuntime.jsx(ResizeHandleView, {})]
1703
+ children: [enableSelection && /* @__PURE__ */ jsxRuntime.jsx(SelectComponent, {}), enableColumnSelection && /* @__PURE__ */ jsxRuntime.jsx(ColumnSelection, {}), enableExport && /* @__PURE__ */ jsxRuntime.jsx(Export$1, {}), /* @__PURE__ */ jsxRuntime.jsx("div", {
1704
+ css: {
1705
+ flex: 1
1706
+ }
1707
+ }), /* @__PURE__ */ jsxRuntime.jsx(ResizeHandleView, {})]
1687
1708
  }), /* @__PURE__ */ jsxRuntime.jsx(ColumnHeaderContext.Provider, {
1688
1709
  children: activeColumns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(ColumnContext.Provider, {
1689
1710
  value: column.id,
@@ -1695,20 +1716,7 @@ const TableInner = react.memo(function TableInner2({
1695
1716
  })]
1696
1717
  }),
1697
1718
  footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
1698
- children: [enableClearFiltersButton && hasActiveFilters && /* @__PURE__ */ jsxRuntime.jsx("div", {
1699
- css: tableTheme.defaultClasses.clearFiltersButton,
1700
- children: /* @__PURE__ */ jsxRuntime.jsx(Button2, {
1701
- variant: "text",
1702
- onClick: () => {
1703
- table.update((state) => {
1704
- state.activeColumns.forEach((column) => {
1705
- state.filterValues.delete(column.id);
1706
- });
1707
- });
1708
- },
1709
- children: textClearFilters
1710
- })
1711
- }), hasFooter && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
1719
+ children: [enableClearFiltersButton && hasActiveFilters && /* @__PURE__ */ jsxRuntime.jsx(ClearFiltersButton, {}), hasFooter && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
1712
1720
  children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
1713
1721
  className: classes == null ? void 0 : classes.footerCell,
1714
1722
  css: [tableTheme.defaultClasses.footerFill, stickyFooter && tableTheme.defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
@@ -2156,7 +2164,7 @@ const defaultTexts = {
2156
2164
  clearFilters: "Clear all filters",
2157
2165
  reset: "Reset",
2158
2166
  loading: "Loading",
2159
- selected: (count) => `${count} selected`
2167
+ deselectAll: "Deselect all"
2160
2168
  };
2161
2169
  const defaultTableTheme = {
2162
2170
  text: defaultTexts,
@@ -2175,14 +2183,11 @@ function useTheme(selector) {
2175
2183
  const process = (t) => {
2176
2184
  var _a2;
2177
2185
  const cell = (_a2 = t.classes) == null ? void 0 : _a2.cell;
2178
- const selected = t.text.selected;
2179
2186
  return __spreadProps(__spreadValues({}, t), {
2180
2187
  classes: __spreadProps(__spreadValues({}, t.classes), {
2181
2188
  cell: cell instanceof Function || Array.isArray(cell) ? memo("theme.classes.cell", cell) : cell
2182
2189
  }),
2183
- text: __spreadProps(__spreadValues({}, t.text), {
2184
- selected: selected instanceof Function || Array.isArray(selected) ? memo("theme.text.selected", selected) : selected
2185
- })
2190
+ text: __spreadValues({}, t.text)
2186
2191
  });
2187
2192
  };
2188
2193
  const theme = (_b = (_a = table == null ? void 0 : table.useState((state) => {
@@ -2690,7 +2695,7 @@ function SelectFilter(_m) {
2690
2695
  const Checkbox2 = useTheme((t) => t.components.Checkbox);
2691
2696
  const Search2 = useTheme((t) => t.icons.Search);
2692
2697
  const Clear2 = useTheme((t) => t.icons.Clear);
2693
- const selected = useTheme((t) => t.text.selected);
2698
+ const deselectAll = useTheme((t) => t.text.deselectAll);
2694
2699
  const noResults = useTheme((t) => t.text.noResults);
2695
2700
  const table = useTableContext();
2696
2701
  const columnId = useColumnContext();
@@ -2717,6 +2722,7 @@ function SelectFilter(_m) {
2717
2722
  });
2718
2723
  const [query, setQuery] = react.useState("");
2719
2724
  const filtered = options.filter((option) => !query || stringValue(option).toLowerCase().includes(query.toLowerCase()));
2725
+ const Button2 = useTheme((t) => t.components.Button);
2720
2726
  return /* @__PURE__ */ jsxRuntime.jsxs("div", {
2721
2727
  css: {
2722
2728
  padding: "calc(var(--spacing) * 2)",
@@ -2733,28 +2739,28 @@ function SelectFilter(_m) {
2733
2739
  css: {
2734
2740
  marginBottom: "var(--spacing)"
2735
2741
  }
2736
- }), /* @__PURE__ */ jsxRuntime.jsxs("div", {
2742
+ }), /* @__PURE__ */ jsxRuntime.jsx(Button2, {
2743
+ disabled: !(value.size > 0),
2744
+ onClick: () => onChange(/* @__PURE__ */ new Set()),
2745
+ variant: "outlined",
2746
+ css: {
2747
+ justifyContent: "center",
2748
+ width: "100%",
2749
+ marginBottom: "var(--spacing)"
2750
+ },
2751
+ children: deselectAll
2752
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", {
2737
2753
  css: {
2738
2754
  maxHeight: "20em",
2739
2755
  overflowY: "auto"
2740
2756
  },
2741
- children: [/* @__PURE__ */ jsxRuntime.jsx(FormControlLabel, {
2742
- disabled: value.size === 0,
2743
- control: /* @__PURE__ */ jsxRuntime.jsx(Checkbox2, {
2744
- disabled: value.size === 0,
2745
- checked: value.size > 0,
2746
- onChange: () => onChange(/* @__PURE__ */ new Set())
2747
- }),
2748
- label: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
2749
- children: ["<", selected(value.size), ">"]
2750
- })
2751
- }), filtered.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(FormControlLabel, {
2757
+ children: filtered.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(FormControlLabel, {
2752
2758
  control: /* @__PURE__ */ jsxRuntime.jsx(Checkbox2, {
2753
2759
  checked: value.has(option),
2754
2760
  onChange: () => onChange(toggle(value, option, singleSelect))
2755
2761
  }),
2756
2762
  label: render(option)
2757
- }, index))]
2763
+ }, index))
2758
2764
  }), filtered.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("span", {
2759
2765
  css: {
2760
2766
  textAlign: "center"