schummar-table 0.8.3 → 0.10.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/cjs/index.js +64 -35
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tableTheme.js +14 -0
- package/dist/cjs/tableTheme.js.map +1 -1
- package/dist/es/index.js +64 -35
- package/dist/es/index.js.map +1 -1
- package/dist/es/tableTheme.js +14 -0
- package/dist/es/tableTheme.js.map +1 -1
- package/dist/types/components/clearFiltersButton.d.ts +1 -0
- package/dist/types/theme/defaultTheme/defaultClasses.d.ts +1 -0
- package/dist/types/types.d.ts +7 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -401,7 +401,7 @@ const noopParentId = () => void 0;
|
|
|
401
401
|
function calcProps(props) {
|
|
402
402
|
const cache = useTableMemo();
|
|
403
403
|
return react.useMemo(() => {
|
|
404
|
-
var _f, _g, _h, _i, _j, _k, _l;
|
|
404
|
+
var _f, _g, _h, _i, _j, _k, _l, _m;
|
|
405
405
|
let id;
|
|
406
406
|
if (props.id instanceof Function || Array.isArray(props.id)) {
|
|
407
407
|
id = cache("id", props.id);
|
|
@@ -480,8 +480,9 @@ function calcProps(props) {
|
|
|
480
480
|
stickyFooter: (_i = props.stickyFooter) != null ? _i : true,
|
|
481
481
|
enableExport,
|
|
482
482
|
enableColumnSelection: (_j = props.enableColumnSelection) != null ? _j : true,
|
|
483
|
-
|
|
484
|
-
|
|
483
|
+
enableClearFiltersButton: (_k = props.enableClearFiltersButton) != null ? _k : false,
|
|
484
|
+
enableColumnResize: (_l = props.enableColumnResize) != null ? _l : true,
|
|
485
|
+
enableColumnReorder: (_m = props.enableColumnReorder) != null ? _m : true
|
|
485
486
|
});
|
|
486
487
|
}, [props]);
|
|
487
488
|
}
|
|
@@ -621,6 +622,25 @@ function useCssVariables() {
|
|
|
621
622
|
"--secondaryContrastText": colors.secondary.contrastText
|
|
622
623
|
}));
|
|
623
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
|
+
}
|
|
624
644
|
function ColumnFooter() {
|
|
625
645
|
const table = useTableContext();
|
|
626
646
|
const columnId = useColumnContext();
|
|
@@ -1635,6 +1655,13 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1635
1655
|
width: column.width,
|
|
1636
1656
|
classes: column.classes
|
|
1637
1657
|
})));
|
|
1658
|
+
const hasActiveFilters = table.useState((state) => {
|
|
1659
|
+
return state.activeColumns.some((column) => {
|
|
1660
|
+
const filter = state.filters.get(column.id);
|
|
1661
|
+
const filterValue = state.filterValues.get(column.id);
|
|
1662
|
+
return filter !== void 0 && filterValue !== void 0 && filter.isActive(filterValue);
|
|
1663
|
+
});
|
|
1664
|
+
});
|
|
1638
1665
|
const columnWidths = table.useState("columnWidths", {
|
|
1639
1666
|
throttle: 16
|
|
1640
1667
|
});
|
|
@@ -1646,6 +1673,7 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1646
1673
|
const enableColumnSelection = table.useState("props.enableColumnSelection");
|
|
1647
1674
|
const enableExport = table.useState((state) => !!state.props.enableExport.copy || !!state.props.enableExport.download);
|
|
1648
1675
|
const cssVariables = useCssVariables();
|
|
1676
|
+
const enableClearFiltersButton = table.useState("props.enableClearFiltersButton");
|
|
1649
1677
|
react.useLayoutEffect(() => {
|
|
1650
1678
|
var _a, _b;
|
|
1651
1679
|
return (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
|
|
@@ -1683,19 +1711,21 @@ const TableInner = react.memo(function TableInner2({
|
|
|
1683
1711
|
css: [tableTheme.defaultClasses.headerFill, stickyHeader && tableTheme.defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
|
|
1684
1712
|
})]
|
|
1685
1713
|
}),
|
|
1686
|
-
footer:
|
|
1687
|
-
children: [/* @__PURE__ */ jsxRuntime.jsx(
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1714
|
+
footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1715
|
+
children: [enableClearFiltersButton && hasActiveFilters && /* @__PURE__ */ jsxRuntime.jsx(ClearFiltersButton, {}), hasFooter && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1716
|
+
children: [/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
1717
|
+
className: classes == null ? void 0 : classes.footerCell,
|
|
1718
|
+
css: [tableTheme.defaultClasses.footerFill, stickyFooter && tableTheme.defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
|
|
1719
|
+
}), /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
1720
|
+
className: classes == null ? void 0 : classes.footerCell,
|
|
1721
|
+
css: [tableTheme.defaultClasses.footerFill, stickyFooter && tableTheme.defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
|
|
1722
|
+
}), activeColumns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(ColumnContext.Provider, {
|
|
1723
|
+
value: column.id,
|
|
1724
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ColumnFooter, {})
|
|
1725
|
+
}, column.id)), /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
1726
|
+
className: classes == null ? void 0 : classes.footerCell,
|
|
1727
|
+
css: [tableTheme.defaultClasses.footerFill, stickyFooter && tableTheme.defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
|
|
1728
|
+
})]
|
|
1699
1729
|
})]
|
|
1700
1730
|
}),
|
|
1701
1731
|
children: (itemIds, startIndex) => itemIds.map((itemId, index) => /* @__PURE__ */ jsxRuntime.jsx(Row, {
|
|
@@ -2127,9 +2157,10 @@ const defaultTexts = {
|
|
|
2127
2157
|
exportDownload: "Download",
|
|
2128
2158
|
today: "Today",
|
|
2129
2159
|
thisWeek: "This week",
|
|
2160
|
+
clearFilters: "Clear all filters",
|
|
2130
2161
|
reset: "Reset",
|
|
2131
2162
|
loading: "Loading",
|
|
2132
|
-
|
|
2163
|
+
deselectAll: "Deselect all"
|
|
2133
2164
|
};
|
|
2134
2165
|
const defaultTableTheme = {
|
|
2135
2166
|
text: defaultTexts,
|
|
@@ -2148,14 +2179,11 @@ function useTheme(selector) {
|
|
|
2148
2179
|
const process = (t) => {
|
|
2149
2180
|
var _a2;
|
|
2150
2181
|
const cell = (_a2 = t.classes) == null ? void 0 : _a2.cell;
|
|
2151
|
-
const selected = t.text.selected;
|
|
2152
2182
|
return __spreadProps(__spreadValues({}, t), {
|
|
2153
2183
|
classes: __spreadProps(__spreadValues({}, t.classes), {
|
|
2154
2184
|
cell: cell instanceof Function || Array.isArray(cell) ? memo("theme.classes.cell", cell) : cell
|
|
2155
2185
|
}),
|
|
2156
|
-
text:
|
|
2157
|
-
selected: selected instanceof Function || Array.isArray(selected) ? memo("theme.text.selected", selected) : selected
|
|
2158
|
-
})
|
|
2186
|
+
text: __spreadValues({}, t.text)
|
|
2159
2187
|
});
|
|
2160
2188
|
};
|
|
2161
2189
|
const theme = (_b = (_a = table == null ? void 0 : table.useState((state) => {
|
|
@@ -2663,7 +2691,7 @@ function SelectFilter(_m) {
|
|
|
2663
2691
|
const Checkbox2 = useTheme((t) => t.components.Checkbox);
|
|
2664
2692
|
const Search2 = useTheme((t) => t.icons.Search);
|
|
2665
2693
|
const Clear2 = useTheme((t) => t.icons.Clear);
|
|
2666
|
-
const
|
|
2694
|
+
const deselectAll = useTheme((t) => t.text.deselectAll);
|
|
2667
2695
|
const noResults = useTheme((t) => t.text.noResults);
|
|
2668
2696
|
const table = useTableContext();
|
|
2669
2697
|
const columnId = useColumnContext();
|
|
@@ -2690,6 +2718,7 @@ function SelectFilter(_m) {
|
|
|
2690
2718
|
});
|
|
2691
2719
|
const [query, setQuery] = react.useState("");
|
|
2692
2720
|
const filtered = options.filter((option) => !query || stringValue(option).toLowerCase().includes(query.toLowerCase()));
|
|
2721
|
+
const Button2 = useTheme((t) => t.components.Button);
|
|
2693
2722
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
2694
2723
|
css: {
|
|
2695
2724
|
padding: "calc(var(--spacing) * 2)",
|
|
@@ -2706,28 +2735,28 @@ function SelectFilter(_m) {
|
|
|
2706
2735
|
css: {
|
|
2707
2736
|
marginBottom: "var(--spacing)"
|
|
2708
2737
|
}
|
|
2709
|
-
}), /* @__PURE__ */ jsxRuntime.
|
|
2738
|
+
}), /* @__PURE__ */ jsxRuntime.jsx(Button2, {
|
|
2739
|
+
disabled: !(value.size > 0),
|
|
2740
|
+
onClick: () => onChange(/* @__PURE__ */ new Set()),
|
|
2741
|
+
variant: "outlined",
|
|
2742
|
+
css: {
|
|
2743
|
+
justifyContent: "center",
|
|
2744
|
+
width: "100%",
|
|
2745
|
+
marginBottom: "var(--spacing)"
|
|
2746
|
+
},
|
|
2747
|
+
children: deselectAll
|
|
2748
|
+
}), /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
2710
2749
|
css: {
|
|
2711
2750
|
maxHeight: "20em",
|
|
2712
2751
|
overflowY: "auto"
|
|
2713
2752
|
},
|
|
2714
|
-
children:
|
|
2715
|
-
disabled: value.size === 0,
|
|
2716
|
-
control: /* @__PURE__ */ jsxRuntime.jsx(Checkbox2, {
|
|
2717
|
-
disabled: value.size === 0,
|
|
2718
|
-
checked: value.size > 0,
|
|
2719
|
-
onChange: () => onChange(/* @__PURE__ */ new Set())
|
|
2720
|
-
}),
|
|
2721
|
-
label: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2722
|
-
children: ["<", selected(value.size), ">"]
|
|
2723
|
-
})
|
|
2724
|
-
}), filtered.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(FormControlLabel, {
|
|
2753
|
+
children: filtered.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(FormControlLabel, {
|
|
2725
2754
|
control: /* @__PURE__ */ jsxRuntime.jsx(Checkbox2, {
|
|
2726
2755
|
checked: value.has(option),
|
|
2727
2756
|
onChange: () => onChange(toggle(value, option, singleSelect))
|
|
2728
2757
|
}),
|
|
2729
2758
|
label: render(option)
|
|
2730
|
-
}, index))
|
|
2759
|
+
}, index))
|
|
2731
2760
|
}), filtered.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
2732
2761
|
css: {
|
|
2733
2762
|
textAlign: "center"
|