schummar-table 0.8.3 → 0.9.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/cjs/index.js +43 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tableTheme.js +9 -0
- package/dist/cjs/tableTheme.js.map +1 -1
- package/dist/es/index.js +43 -16
- package/dist/es/index.js.map +1 -1
- package/dist/es/tableTheme.js +9 -0
- package/dist/es/tableTheme.js.map +1 -1
- package/dist/types/theme/defaultTheme/defaultClasses.d.ts +1 -0
- package/dist/types/types.d.ts +5 -0
- package/package.json +1 -1
package/dist/cjs/tableTheme.js
CHANGED
|
@@ -83,6 +83,15 @@ const defaultClasses = {
|
|
|
83
83
|
borderRadius: 4,
|
|
84
84
|
boxShadow: "0px 3px 14px 2px rgb(0 0 0 / 12%)",
|
|
85
85
|
background: "white"
|
|
86
|
+
}),
|
|
87
|
+
clearFiltersButton: react.css({
|
|
88
|
+
fontWeight: "bold",
|
|
89
|
+
textAlign: "center",
|
|
90
|
+
gridColumn: "1/-1",
|
|
91
|
+
button: {
|
|
92
|
+
color: "var(--primaryMain) !important",
|
|
93
|
+
margin: "var(--spacing)"
|
|
94
|
+
}
|
|
86
95
|
})
|
|
87
96
|
};
|
|
88
97
|
const MARGIN = 10;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableTheme.js","sources":["../../src/theme/defaultTheme/defaultClasses.ts","../../src/theme/defaultTheme/popover.tsx","../../src/theme/tableTheme.tsx"],"sourcesContent":["import { css } from '@emotion/react';\n\nexport const white = '#ffffff';\nexport const lightGray = '#eeeeee';\nexport const gray = '#bdbdbd';\nexport const darkGray = '#777';\n\nconst cell = css({\n padding: `calc(var(--spacing) * 0.1) calc(2 * var(--spacing))`,\n display: 'flex',\n alignItems: 'center',\n borderBottom: `1px solid #dfe2e9`,\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n background: 'white',\n});\n\nexport const defaultClasses = {\n table: css({\n position: 'relative',\n display: 'grid',\n }),\n\n cell,\n\n cellFill: css({\n borderBottom: `1px solid ${lightGray}`,\n }),\n\n headerCell: css(cell, {\n padding: `var(--spacing) 0 var(--spacing) calc(2 * var(--spacing))`,\n borderBottom: `1px solid #c9cfda`,\n }),\n\n footerCell: css(cell, {\n padding: `var(--spacing) calc(2 * var(--spacing))`,\n borderTop: `1px solid #c9cfda`,\n borderBottom: 'none',\n }),\n\n firstCell: css({\n justifyContent: 'start',\n }),\n\n sticky: css({\n position: 'sticky',\n top: 0,\n zIndex: 2,\n }),\n\n stickyBottom: css({\n position: 'sticky',\n bottom: 0,\n zIndex: 2,\n }),\n\n headerFill: css({\n borderBottom: `1px solid #c9cfda`,\n background: white,\n }),\n\n footerFill: css({\n borderTop: `1px solid #c9cfda`,\n background: white,\n }),\n\n text: css({\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }),\n\n card: css({\n borderRadius: 4,\n boxShadow: '0px 3px 14px 2px rgb(0 0 0 / 12%)',\n background: 'white',\n }),\n};\n","import React, { createContext, useContext, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { TableTheme } from '../../types';\nimport { defaultClasses } from './defaultClasses';\n\nconst MARGIN = 10;\nconst MAX_OFFSET = 20;\n\nexport const PopoverContext = createContext({ depth: 0, visible: false });\n\nexport const Popover: TableTheme['components']['Popover'] = ({ anchorEl, open, hidden, onClose, children, className, align }) => {\n const popper = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<{ left: number; top: number }>();\n\n useLayoutEffect(() => {\n if (!anchorEl || !open) {\n setPosition(undefined);\n return;\n }\n\n let last: { left: number; top: number } | undefined;\n\n function check() {\n if (!anchorEl) return;\n const { left: anchorLeft, bottom: anchorBottom, width: anchorWidth } = anchorEl.getBoundingClientRect();\n const { width: popperWidth = 0, height: popperHeight = 0 } = popper.current?.getBoundingClientRect() ?? {};\n const viewportWidth = document.documentElement.clientWidth;\n const viewportHeight = document.documentElement.clientHeight;\n\n const next = {\n left:\n align === 'center'\n ? anchorLeft + anchorWidth / 2 - popperWidth / 2\n : anchorLeft - Math.min(popperWidth ? popperWidth / 2 : Infinity, MAX_OFFSET),\n top: anchorBottom,\n };\n\n if (next.left + popperWidth + MARGIN > viewportWidth) {\n next.left = viewportWidth - popperWidth - MARGIN;\n }\n if (next.top + popperHeight + MARGIN > viewportHeight) {\n next.top = viewportHeight - popperHeight - MARGIN;\n }\n\n if (next.left !== last?.left || next.top !== last?.top) {\n setPosition(next);\n }\n\n last = next;\n }\n check();\n\n const handle = setInterval(check, 16);\n return () => {\n clearInterval(handle);\n };\n }, [anchorEl, open]);\n\n const { depth } = useContext(PopoverContext);\n const visible = !hidden && !!position;\n const context = useMemo(() => ({ depth: depth + 1, visible }), [depth, visible]);\n\n if (!open) return null;\n\n return (\n <PopoverContext.Provider value={context}>\n {createPortal(\n <>\n <div\n css={[\n {\n position: 'fixed',\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n zIndex: 1000 + depth * 2,\n },\n hidden && { display: 'none' },\n ]}\n onClick={() => onClose()}\n />\n\n <div\n ref={popper}\n className={className}\n css={[\n defaultClasses.card,\n {\n position: 'fixed',\n maxWidth: document.documentElement.clientWidth,\n maxHeight: document.documentElement.clientHeight,\n ...position,\n zIndex: 1001 + depth * 2,\n },\n hidden && { display: 'none' },\n !position && { visibility: 'hidden' },\n ]}\n >\n {children}\n </div>\n </>,\n document.body,\n )}\n </PopoverContext.Provider>\n );\n};\n","import { createContext, ReactNode } from 'react';\nimport { PartialTableTheme } from '../types';\n\nexport let globalTableTheme: PartialTableTheme = {};\nexport function configureTableTheme(tableTheme: PartialTableTheme) {\n globalTableTheme = tableTheme;\n}\n\nexport const TableThemeContext = createContext<PartialTableTheme>({});\n\nexport function TableThemeProvider({ theme, children }: { theme: PartialTableTheme; children: ReactNode }) {\n return <TableThemeContext.Provider value={theme}>{children}</TableThemeContext.Provider>;\n}\n\nexport function mergeThemes<T>(...themes: PartialTableTheme<T>[]): PartialTableTheme<T> {\n return {\n text: Object.assign({}, ...themes.map((theme) => theme.text)),\n classes: Object.assign({}, ...themes.map((theme) => theme.classes)),\n components: Object.assign({}, ...themes.map((theme) => theme.components)),\n icons: Object.assign({}, ...themes.map((theme) => theme.icons)),\n colors: {\n primary: Object.assign({}, ...themes.map((theme) => theme.colors?.primary)),\n secondary: Object.assign({}, ...themes.map((theme) => theme.colors?.secondary)),\n },\n spacing: themes\n .map((theme) => theme.spacing)\n .reverse()\n .find((x) => x !== undefined),\n };\n}\n"],"names":["css","MARGIN","MAX_OFFSET","PopoverContext","createContext","depth","visible","Popover","anchorEl","open","hidden","onClose","children","className","align","popper","useRef","position","setPosition","useState","undefined","last","left","anchorLeft","bottom","anchorBottom","width","anchorWidth","getBoundingClientRect","popperWidth","height","popperHeight","current","viewportWidth","document","documentElement","clientWidth","viewportHeight","clientHeight","next","Math","min","Infinity","top","handle","setInterval","check","useContext","context","useMemo","createPortal","right","zIndex","display","defaultClasses","card","maxWidth","maxHeight","visibility","body","globalTableTheme","tableTheme","TableThemeContext","theme","themes","text","Object","assign","map","classes","components","icons","colors","primary","secondary","spacing","reverse","find","x"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;MAEa,QAAQ;MACR,YAAY;MACZ,OAAO;MACP,WAAW;AAExB,MAAM,OAAOA,UAAI;AAAA,EACf,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,YAAY;AACd,CAAC;MAEY,iBAAiB;AAAA,EAC5B,OAAOA,UAAI;AAAA,IACT,UAAU;AAAA,IACV,SAAS;AAAA,GACV;AAAA,EAED;AAAA,EAEA,UAAUA,UAAI;AAAA,IACZ,cAAc,aAAa;AAAA,GAC5B;AAAA,EAED,YAAYA,UAAI,MAAM;AAAA,IACpB,SAAS;AAAA,IACT,cAAc;AAAA,GACf;AAAA,EAED,YAAYA,UA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AgBG;AAAAA,WACjCrB,WAJL;AAAA,UAKEmC,QAAQ,OAAO/C,QAAQ;AAAA,YAEzBK,UAAU;AAAA,UAAE2C,SAAS;AAAA,WACrB,CAACpC,YAAY;AAAA,UAAEyC,YAAY;AAAA,SAVxB;AAAA;QAnBT;AAAA,QAmCAxB,SAASyB,IApCE;AAAA;AAwClB;ACvGUC,2BAAsC;6BACbC,YAA+B;6BAC9CA;AACpB;MAEYC,oBAAoB1D,sBAAiC,EAApB;4BAEX;AAAA,EAAE2D;AAAAA,EAAOnD;AAAAA,GAA+D;wCACjG,kBAAkB;IAAS,OAAOmD;AAAAA;;AAC3C;wBAEiCC,QAAsD;SAC/E;AAAA,IACLC,MAAMC,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL,WAAUA,MAAME,IAA5B,CAArB;AAAA,IACNI,SAASH,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL,WAAUA,MAAMM,OAA5B,CAArB;AAAA,IACTC,YAAYJ,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL,WAAUA,MAAMO,UAA5B,CAArB;AAAA,IACZC,OAAOL,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL,WAAUA,MAAMQ,KAA5B,CAArB;AAAA,IACPC,QAAQ;AAAA,MACNC,SAASP,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL;;AAAUA,2BAAMS,WAANT,mBAAcU;AAAAA,OAApC,CAArB;AAAA,MACTC,WAAWR,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL;;AAAUA,2BAAMS,WAANT,mBAAcW;AAAAA,OAApC,CAArB;AAAA;IAEbC,SAASX,OACNI,IAAKL,WAAUA,MAAMY,OADf,EAENC,UACAC,KAAMC,OAAMA,MAAM1D,MAHZ;AAAA;AAKZ;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"tableTheme.js","sources":["../../src/theme/defaultTheme/defaultClasses.ts","../../src/theme/defaultTheme/popover.tsx","../../src/theme/tableTheme.tsx"],"sourcesContent":["import { css } from '@emotion/react';\n\nexport const white = '#ffffff';\nexport const lightGray = '#eeeeee';\nexport const gray = '#bdbdbd';\nexport const darkGray = '#777';\n\nconst cell = css({\n padding: `calc(var(--spacing) * 0.1) calc(2 * var(--spacing))`,\n display: 'flex',\n alignItems: 'center',\n borderBottom: `1px solid #dfe2e9`,\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n background: 'white',\n});\n\nexport const defaultClasses = {\n table: css({\n position: 'relative',\n display: 'grid',\n }),\n\n cell,\n\n cellFill: css({\n borderBottom: `1px solid ${lightGray}`,\n }),\n\n headerCell: css(cell, {\n padding: `var(--spacing) 0 var(--spacing) calc(2 * var(--spacing))`,\n borderBottom: `1px solid #c9cfda`,\n }),\n\n footerCell: css(cell, {\n padding: `var(--spacing) calc(2 * var(--spacing))`,\n borderTop: `1px solid #c9cfda`,\n borderBottom: 'none',\n }),\n\n firstCell: css({\n justifyContent: 'start',\n }),\n\n sticky: css({\n position: 'sticky',\n top: 0,\n zIndex: 2,\n }),\n\n stickyBottom: css({\n position: 'sticky',\n bottom: 0,\n zIndex: 2,\n }),\n\n headerFill: css({\n borderBottom: `1px solid #c9cfda`,\n background: white,\n }),\n\n footerFill: css({\n borderTop: `1px solid #c9cfda`,\n background: white,\n }),\n\n text: css({\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }),\n\n card: css({\n borderRadius: 4,\n boxShadow: '0px 3px 14px 2px rgb(0 0 0 / 12%)',\n background: 'white',\n }),\n\n clearFiltersButton: css({\n fontWeight: 'bold',\n textAlign: 'center',\n gridColumn: '1/-1',\n button: {\n color: 'var(--primaryMain) !important',\n margin: 'var(--spacing)',\n },\n }),\n};\n","import React, { createContext, useContext, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { TableTheme } from '../../types';\nimport { defaultClasses } from './defaultClasses';\n\nconst MARGIN = 10;\nconst MAX_OFFSET = 20;\n\nexport const PopoverContext = createContext({ depth: 0, visible: false });\n\nexport const Popover: TableTheme['components']['Popover'] = ({ anchorEl, open, hidden, onClose, children, className, align }) => {\n const popper = useRef<HTMLDivElement>(null);\n const [position, setPosition] = useState<{ left: number; top: number }>();\n\n useLayoutEffect(() => {\n if (!anchorEl || !open) {\n setPosition(undefined);\n return;\n }\n\n let last: { left: number; top: number } | undefined;\n\n function check() {\n if (!anchorEl) return;\n const { left: anchorLeft, bottom: anchorBottom, width: anchorWidth } = anchorEl.getBoundingClientRect();\n const { width: popperWidth = 0, height: popperHeight = 0 } = popper.current?.getBoundingClientRect() ?? {};\n const viewportWidth = document.documentElement.clientWidth;\n const viewportHeight = document.documentElement.clientHeight;\n\n const next = {\n left:\n align === 'center'\n ? anchorLeft + anchorWidth / 2 - popperWidth / 2\n : anchorLeft - Math.min(popperWidth ? popperWidth / 2 : Infinity, MAX_OFFSET),\n top: anchorBottom,\n };\n\n if (next.left + popperWidth + MARGIN > viewportWidth) {\n next.left = viewportWidth - popperWidth - MARGIN;\n }\n if (next.top + popperHeight + MARGIN > viewportHeight) {\n next.top = viewportHeight - popperHeight - MARGIN;\n }\n\n if (next.left !== last?.left || next.top !== last?.top) {\n setPosition(next);\n }\n\n last = next;\n }\n check();\n\n const handle = setInterval(check, 16);\n return () => {\n clearInterval(handle);\n };\n }, [anchorEl, open]);\n\n const { depth } = useContext(PopoverContext);\n const visible = !hidden && !!position;\n const context = useMemo(() => ({ depth: depth + 1, visible }), [depth, visible]);\n\n if (!open) return null;\n\n return (\n <PopoverContext.Provider value={context}>\n {createPortal(\n <>\n <div\n css={[\n {\n position: 'fixed',\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n zIndex: 1000 + depth * 2,\n },\n hidden && { display: 'none' },\n ]}\n onClick={() => onClose()}\n />\n\n <div\n ref={popper}\n className={className}\n css={[\n defaultClasses.card,\n {\n position: 'fixed',\n maxWidth: document.documentElement.clientWidth,\n maxHeight: document.documentElement.clientHeight,\n ...position,\n zIndex: 1001 + depth * 2,\n },\n hidden && { display: 'none' },\n !position && { visibility: 'hidden' },\n ]}\n >\n {children}\n </div>\n </>,\n document.body,\n )}\n </PopoverContext.Provider>\n );\n};\n","import { createContext, ReactNode } from 'react';\nimport { PartialTableTheme } from '../types';\n\nexport let globalTableTheme: PartialTableTheme = {};\nexport function configureTableTheme(tableTheme: PartialTableTheme) {\n globalTableTheme = tableTheme;\n}\n\nexport const TableThemeContext = createContext<PartialTableTheme>({});\n\nexport function TableThemeProvider({ theme, children }: { theme: PartialTableTheme; children: ReactNode }) {\n return <TableThemeContext.Provider value={theme}>{children}</TableThemeContext.Provider>;\n}\n\nexport function mergeThemes<T>(...themes: PartialTableTheme<T>[]): PartialTableTheme<T> {\n return {\n text: Object.assign({}, ...themes.map((theme) => theme.text)),\n classes: Object.assign({}, ...themes.map((theme) => theme.classes)),\n components: Object.assign({}, ...themes.map((theme) => theme.components)),\n icons: Object.assign({}, ...themes.map((theme) => theme.icons)),\n colors: {\n primary: Object.assign({}, ...themes.map((theme) => theme.colors?.primary)),\n secondary: Object.assign({}, ...themes.map((theme) => theme.colors?.secondary)),\n },\n spacing: themes\n .map((theme) => theme.spacing)\n .reverse()\n .find((x) => x !== undefined),\n };\n}\n"],"names":["css","MARGIN","MAX_OFFSET","PopoverContext","createContext","depth","visible","Popover","anchorEl","open","hidden","onClose","children","className","align","popper","useRef","position","setPosition","useState","undefined","last","left","anchorLeft","bottom","anchorBottom","width","anchorWidth","getBoundingClientRect","popperWidth","height","popperHeight","current","viewportWidth","document","documentElement","clientWidth","viewportHeight","clientHeight","next","Math","min","Infinity","top","handle","setInterval","check","useContext","context","useMemo","createPortal","right","zIndex","display","defaultClasses","card","maxWidth","maxHeight","visibility","body","globalTableTheme","tableTheme","TableThemeContext","theme","themes","text","Object","assign","map","classes","components","icons","colors","primary","secondary","spacing","reverse","find","x"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;MAEa,QAAQ;MACR,YAAY;MACZ,OAAO;MACP,WA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A5B,CAArB;AAAA,IACZC,OAAOL,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL,WAAUA,MAAMQ,KAA5B,CAArB;AAAA,IACPC,QAAQ;AAAA,MACNC,SAASP,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL;;AAAUA,2BAAMS,WAANT,mBAAcU;AAAAA,OAApC,CAArB;AAAA,MACTC,WAAWR,OAAOC,OAAO,IAAI,GAAGH,OAAOI,IAAKL;;AAAUA,2BAAMS,WAANT,mBAAcW;AAAAA,OAApC,CAArB;AAAA;IAEbC,SAASX,OACNI,IAAKL,WAAUA,MAAMY,OADf,EAENC,UACAC,KAAMC,OAAMA,MAAM1D,MAHZ;AAAA;AAKZ;;;;;;;;;;;"}
|
package/dist/es/index.js
CHANGED
|
@@ -399,7 +399,7 @@ const noopParentId = () => void 0;
|
|
|
399
399
|
function calcProps(props) {
|
|
400
400
|
const cache = useTableMemo();
|
|
401
401
|
return useMemo(() => {
|
|
402
|
-
var _f, _g, _h, _i, _j, _k, _l;
|
|
402
|
+
var _f, _g, _h, _i, _j, _k, _l, _m;
|
|
403
403
|
let id;
|
|
404
404
|
if (props.id instanceof Function || Array.isArray(props.id)) {
|
|
405
405
|
id = cache("id", props.id);
|
|
@@ -478,8 +478,9 @@ function calcProps(props) {
|
|
|
478
478
|
stickyFooter: (_i = props.stickyFooter) != null ? _i : true,
|
|
479
479
|
enableExport,
|
|
480
480
|
enableColumnSelection: (_j = props.enableColumnSelection) != null ? _j : true,
|
|
481
|
-
|
|
482
|
-
|
|
481
|
+
enableClearFiltersButton: (_k = props.enableClearFiltersButton) != null ? _k : false,
|
|
482
|
+
enableColumnResize: (_l = props.enableColumnResize) != null ? _l : true,
|
|
483
|
+
enableColumnReorder: (_m = props.enableColumnReorder) != null ? _m : true
|
|
483
484
|
});
|
|
484
485
|
}, [props]);
|
|
485
486
|
}
|
|
@@ -1633,6 +1634,13 @@ const TableInner = memo(function TableInner2({
|
|
|
1633
1634
|
width: column.width,
|
|
1634
1635
|
classes: column.classes
|
|
1635
1636
|
})));
|
|
1637
|
+
const hasActiveFilters = table.useState((state) => {
|
|
1638
|
+
return state.activeColumns.some((column) => {
|
|
1639
|
+
const filter = state.filters.get(column.id);
|
|
1640
|
+
const filterValue = state.filterValues.get(column.id);
|
|
1641
|
+
return filter !== void 0 && filterValue !== void 0 && filter.isActive(filterValue);
|
|
1642
|
+
});
|
|
1643
|
+
});
|
|
1636
1644
|
const columnWidths = table.useState("columnWidths", {
|
|
1637
1645
|
throttle: 16
|
|
1638
1646
|
});
|
|
@@ -1644,6 +1652,9 @@ const TableInner = memo(function TableInner2({
|
|
|
1644
1652
|
const enableColumnSelection = table.useState("props.enableColumnSelection");
|
|
1645
1653
|
const enableExport = table.useState((state) => !!state.props.enableExport.copy || !!state.props.enableExport.download);
|
|
1646
1654
|
const cssVariables = useCssVariables();
|
|
1655
|
+
const enableClearFiltersButton = table.useState("props.enableClearFiltersButton");
|
|
1656
|
+
const Button2 = useTheme((t) => t.components.Button);
|
|
1657
|
+
const textClearFilters = useTheme((t) => t.text.clearFilters);
|
|
1647
1658
|
useLayoutEffect(() => {
|
|
1648
1659
|
var _a, _b;
|
|
1649
1660
|
return (_b = (_a = table.getState().props).debugRender) == null ? void 0 : _b.call(_a, "render table inner");
|
|
@@ -1681,19 +1692,34 @@ const TableInner = memo(function TableInner2({
|
|
|
1681
1692
|
css: [defaultClasses.headerFill, stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
|
|
1682
1693
|
})]
|
|
1683
1694
|
}),
|
|
1684
|
-
footer:
|
|
1685
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1695
|
+
footer: /* @__PURE__ */ jsxs(Fragment, {
|
|
1696
|
+
children: [enableClearFiltersButton && hasActiveFilters && /* @__PURE__ */ jsx("div", {
|
|
1697
|
+
css: defaultClasses.clearFiltersButton,
|
|
1698
|
+
children: /* @__PURE__ */ jsx(Button2, {
|
|
1699
|
+
variant: "text",
|
|
1700
|
+
onClick: () => {
|
|
1701
|
+
table.update((state) => {
|
|
1702
|
+
state.activeColumns.forEach((column) => {
|
|
1703
|
+
state.filterValues.delete(column.id);
|
|
1704
|
+
});
|
|
1705
|
+
});
|
|
1706
|
+
},
|
|
1707
|
+
children: textClearFilters
|
|
1708
|
+
})
|
|
1709
|
+
}), hasFooter && /* @__PURE__ */ jsxs(Fragment, {
|
|
1710
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1711
|
+
className: classes == null ? void 0 : classes.footerCell,
|
|
1712
|
+
css: [defaultClasses.footerFill, stickyFooter && defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
|
|
1713
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1714
|
+
className: classes == null ? void 0 : classes.footerCell,
|
|
1715
|
+
css: [defaultClasses.footerFill, stickyFooter && defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
|
|
1716
|
+
}), activeColumns.map((column) => /* @__PURE__ */ jsx(ColumnContext.Provider, {
|
|
1717
|
+
value: column.id,
|
|
1718
|
+
children: /* @__PURE__ */ jsx(ColumnFooter, {})
|
|
1719
|
+
}, column.id)), /* @__PURE__ */ jsx("div", {
|
|
1720
|
+
className: classes == null ? void 0 : classes.footerCell,
|
|
1721
|
+
css: [defaultClasses.footerFill, stickyFooter && defaultClasses.stickyBottom, stickyFooter instanceof Object && stickyFooter]
|
|
1722
|
+
})]
|
|
1697
1723
|
})]
|
|
1698
1724
|
}),
|
|
1699
1725
|
children: (itemIds, startIndex) => itemIds.map((itemId, index) => /* @__PURE__ */ jsx(Row, {
|
|
@@ -2125,6 +2151,7 @@ const defaultTexts = {
|
|
|
2125
2151
|
exportDownload: "Download",
|
|
2126
2152
|
today: "Today",
|
|
2127
2153
|
thisWeek: "This week",
|
|
2154
|
+
clearFilters: "Clear all filters",
|
|
2128
2155
|
reset: "Reset",
|
|
2129
2156
|
loading: "Loading",
|
|
2130
2157
|
selected: (count) => `${count} selected`
|