schummar-table 0.6.0 → 0.8.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 +693 -611
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mui4Theme.js +5 -5
- package/dist/cjs/mui4Theme.js.map +1 -1
- package/dist/cjs/mui5Theme.js +6 -6
- package/dist/cjs/mui5Theme.js.map +1 -1
- package/dist/cjs/tableTheme.js +20 -5
- package/dist/cjs/tableTheme.js.map +1 -1
- package/dist/es/index.js +695 -613
- package/dist/es/index.js.map +1 -1
- package/dist/es/mui4Theme.js +5 -5
- package/dist/es/mui4Theme.js.map +1 -1
- package/dist/es/mui5Theme.js +6 -6
- package/dist/es/mui5Theme.js.map +1 -1
- package/dist/es/tableTheme.js +20 -5
- package/dist/es/tableTheme.js.map +1 -1
- package/dist/types/components/columnFooter.d.ts +1 -0
- package/dist/types/components/columnHeader.d.ts +1 -2
- package/dist/types/components/row.d.ts +2 -2
- package/dist/types/components/virtualized.d.ts +2 -1
- package/dist/types/hooks/useFilter.d.ts +1 -0
- package/dist/types/hooks/useMemoMap.d.ts +2 -0
- package/dist/types/hooks/useTableMemo.d.ts +6 -0
- package/dist/types/hooks/useTheme.d.ts +2 -2
- package/dist/types/misc/throttle.d.ts +1 -0
- package/dist/types/theme/defaultTheme/defaultClasses.d.ts +3 -0
- package/dist/types/types.d.ts +42 -23
- package/package.json +11 -11
package/dist/es/mui4Theme.js
CHANGED
|
@@ -37,7 +37,7 @@ import "react-dom";
|
|
|
37
37
|
import "@emotion/react";
|
|
38
38
|
const mui4Theme = {
|
|
39
39
|
components: {
|
|
40
|
-
Button: (props) => jsx(Button, __spreadProps(__spreadValues({}, props), {
|
|
40
|
+
Button: (props) => /* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({}, props), {
|
|
41
41
|
size: "small",
|
|
42
42
|
fullWidth: true,
|
|
43
43
|
css: {
|
|
@@ -45,11 +45,11 @@ const mui4Theme = {
|
|
|
45
45
|
},
|
|
46
46
|
color: props.variant === "contained" ? "primary" : "inherit"
|
|
47
47
|
})),
|
|
48
|
-
IconButton: (props) => jsx(IconButton, __spreadProps(__spreadValues({}, props), {
|
|
48
|
+
IconButton: (props) => /* @__PURE__ */ jsx(IconButton, __spreadProps(__spreadValues({}, props), {
|
|
49
49
|
size: "small",
|
|
50
50
|
color: "inherit"
|
|
51
51
|
})),
|
|
52
|
-
Checkbox: (props) => jsx(Checkbox, __spreadProps(__spreadValues({}, props), {
|
|
52
|
+
Checkbox: (props) => /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, props), {
|
|
53
53
|
color: "primary",
|
|
54
54
|
size: "medium"
|
|
55
55
|
})),
|
|
@@ -61,7 +61,7 @@ const mui4Theme = {
|
|
|
61
61
|
} = _b, props = __objRest(_b, [
|
|
62
62
|
"endIcon"
|
|
63
63
|
]);
|
|
64
|
-
return jsx(TextField, __spreadProps(__spreadValues({}, props), {
|
|
64
|
+
return /* @__PURE__ */ jsx(TextField, __spreadProps(__spreadValues({}, props), {
|
|
65
65
|
InputProps: {
|
|
66
66
|
endAdornment: endIcon
|
|
67
67
|
},
|
|
@@ -85,7 +85,7 @@ function Mui4TableThemeProvider({
|
|
|
85
85
|
}
|
|
86
86
|
}, mui4Theme, theme != null ? theme : {});
|
|
87
87
|
}, [muiTheme, theme]);
|
|
88
|
-
return jsx(TableThemeContext.Provider, {
|
|
88
|
+
return /* @__PURE__ */ jsx(TableThemeContext.Provider, {
|
|
89
89
|
value: _theme,
|
|
90
90
|
children
|
|
91
91
|
});
|
package/dist/es/mui4Theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mui4Theme.js","sources":["../../src/theme/mui4Theme/index.tsx"],"sourcesContent":["import { Badge, Button, Checkbox, CircularProgress, IconButton, TextField, useTheme } from '@material-ui/core';\nimport { ReactNode, useMemo } from 'react';\nimport { PartialTableTheme } from '../../types';\nimport { Popover } from '../defaultTheme/popover';\nimport { mergeThemes, TableThemeContext } from '../tableTheme';\n\nexport const mui4Theme: PartialTableTheme = {\n components: {\n Button: (props) => (\n <Button\n {...props}\n size=\"small\"\n fullWidth\n css={{ justifyContent: 'start !important' }}\n color={props.variant === 'contained' ? 'primary' : 'inherit'}\n />\n ),\n IconButton: (props) => <IconButton {...props} size=\"small\" color=\"inherit\" />,\n Checkbox: (props) => <Checkbox {...props} color=\"primary\" size=\"medium\" />,\n Popover,\n Badge,\n TextField: ({ endIcon, ...props }) => <TextField {...props} InputProps={{ endAdornment: endIcon }} size=\"small\" variant=\"outlined\" />,\n Spinner: CircularProgress,\n },\n};\n\nexport function Mui4TableThemeProvider({ theme, children }: { theme?: PartialTableTheme; children: ReactNode }) {\n const muiTheme = useTheme();\n\n const _theme = useMemo(() => {\n return mergeThemes(\n {\n colors: {\n primary: muiTheme.palette.primary,\n secondary: muiTheme.palette.secondary,\n },\n },\n mui4Theme,\n theme ?? {},\n );\n }, [muiTheme, theme]);\n\n return <TableThemeContext.Provider value={_theme}>{children}</TableThemeContext.Provider>;\n}\n"],"names":["mui4Theme","components","Button","props","
|
|
1
|
+
{"version":3,"file":"mui4Theme.js","sources":["../../src/theme/mui4Theme/index.tsx"],"sourcesContent":["import { Badge, Button, Checkbox, CircularProgress, IconButton, TextField, useTheme } from '@material-ui/core';\nimport { ReactNode, useMemo } from 'react';\nimport { PartialTableTheme } from '../../types';\nimport { Popover } from '../defaultTheme/popover';\nimport { mergeThemes, TableThemeContext } from '../tableTheme';\n\nexport const mui4Theme: PartialTableTheme = {\n components: {\n Button: (props) => (\n <Button\n {...props}\n size=\"small\"\n fullWidth\n css={{ justifyContent: 'start !important' }}\n color={props.variant === 'contained' ? 'primary' : 'inherit'}\n />\n ),\n IconButton: (props) => <IconButton {...props} size=\"small\" color=\"inherit\" />,\n Checkbox: (props) => <Checkbox {...props} color=\"primary\" size=\"medium\" />,\n Popover,\n Badge,\n TextField: ({ endIcon, ...props }) => <TextField {...props} InputProps={{ endAdornment: endIcon }} size=\"small\" variant=\"outlined\" />,\n Spinner: CircularProgress,\n },\n};\n\nexport function Mui4TableThemeProvider({ theme, children }: { theme?: PartialTableTheme; children: ReactNode }) {\n const muiTheme = useTheme();\n\n const _theme = useMemo(() => {\n return mergeThemes(\n {\n colors: {\n primary: muiTheme.palette.primary,\n secondary: muiTheme.palette.secondary,\n },\n },\n mui4Theme,\n theme ?? {},\n );\n }, [muiTheme, theme]);\n\n return <TableThemeContext.Provider value={_theme}>{children}</TableThemeContext.Provider>;\n}\n"],"names":["mui4Theme","components","Button","props","justifyContent","variant","IconButton","Checkbox","Popover","Badge","TextField","endIcon","endAdornment","Spinner","CircularProgress","theme","children","muiTheme","useTheme","_theme","useMemo","mergeThemes","colors","primary","palette","secondary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAMaA,YAA+B;AAAA,EAC1CC,YAAY;AAAA,IACVC,QAASC,+BACN,yCACKA;MACJ,MAAK;AAAA,MACL;MACA,KAAK;AAAA,QAAEC,gBAAgB;AAAA;MACvB,OAAOD,MAAME,YAAY,cAAc,YAAY;AAAA;IAGvDC,YAAaH,+BAAW,6CAAeA;MAAO,MAAK;AAAA,MAAQ,OAAM;AAAA;IACjEI,UAAWJ,+BAAW,2CAAaA;MAAO,OAAM;AAAA,MAAU,MAAK;AAAA;IAC/DK;AAAAA,IACAC;AAAAA,IACAC,WAAW,CAAC;AAAA,mBAAEC;AAAAA;AAAAA,UAAF,IAAcR,kBAAd,IAAcA;AAAAA,QAAZQ;AAAAA;iCAAyB,4CAAcR;QAAO,YAAY;AAAA,UAAES,cAAcD;AAAAA;QAAW,MAAK;AAAA,QAAQ,SAAQ;AAAA;;IACxHE,SAASC;AAAAA;AAhB+B;gCAoBL;AAAA,EAAEC;AAAAA,EAAOC;AAAAA,GAAgE;QACxGC,WAAWC;QAEXC,SAASC,QAAQ,MAAM;WACpBC,YACL;AAAA,MACEC,QAAQ;AAAA,QACNC,SAASN,SAASO,QAAQD;AAAAA,QAC1BE,WAAWR,SAASO,QAAQC;AAAAA;OAGhCzB,WACAe,wBAAS,EARO;AAAA,KAUjB,CAACE,UAAUF,KAAX,CAXmB;6BAad,kBAAkB;IAAS,OAAOI;AAAAA;;AAC3C;;"}
|
package/dist/es/mui5Theme.js
CHANGED
|
@@ -37,7 +37,7 @@ import "react-dom";
|
|
|
37
37
|
import "@emotion/react";
|
|
38
38
|
const mui5Theme = {
|
|
39
39
|
components: {
|
|
40
|
-
Button: (props) => jsx(Button, __spreadProps(__spreadValues({}, props), {
|
|
40
|
+
Button: (props) => /* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({}, props), {
|
|
41
41
|
size: "small",
|
|
42
42
|
fullWidth: true,
|
|
43
43
|
css: {
|
|
@@ -45,14 +45,14 @@ const mui5Theme = {
|
|
|
45
45
|
},
|
|
46
46
|
color: props.variant === "contained" ? "primary" : "inherit"
|
|
47
47
|
})),
|
|
48
|
-
IconButton: (props) => jsx(IconButton, __spreadProps(__spreadValues({}, props), {
|
|
48
|
+
IconButton: (props) => /* @__PURE__ */ jsx(IconButton, __spreadProps(__spreadValues({}, props), {
|
|
49
49
|
size: "small",
|
|
50
50
|
css: {
|
|
51
51
|
fontSize: "0.8em"
|
|
52
52
|
},
|
|
53
53
|
color: "inherit"
|
|
54
54
|
})),
|
|
55
|
-
Checkbox: (props) => jsx(Checkbox, __spreadProps(__spreadValues({}, props), {
|
|
55
|
+
Checkbox: (props) => /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, props), {
|
|
56
56
|
color: "primary",
|
|
57
57
|
size: "small"
|
|
58
58
|
})),
|
|
@@ -64,14 +64,14 @@ const mui5Theme = {
|
|
|
64
64
|
} = _b, props = __objRest(_b, [
|
|
65
65
|
"endIcon"
|
|
66
66
|
]);
|
|
67
|
-
return jsx(TextField, __spreadProps(__spreadValues({}, props), {
|
|
67
|
+
return /* @__PURE__ */ jsx(TextField, __spreadProps(__spreadValues({}, props), {
|
|
68
68
|
InputProps: {
|
|
69
69
|
endAdornment: endIcon
|
|
70
70
|
},
|
|
71
71
|
size: "small"
|
|
72
72
|
}));
|
|
73
73
|
},
|
|
74
|
-
Spinner: (props) => jsx(CircularProgress, __spreadProps(__spreadValues({}, props), {
|
|
74
|
+
Spinner: (props) => /* @__PURE__ */ jsx(CircularProgress, __spreadProps(__spreadValues({}, props), {
|
|
75
75
|
size: 20
|
|
76
76
|
}))
|
|
77
77
|
}
|
|
@@ -89,7 +89,7 @@ function Mui5TableThemeProvider({
|
|
|
89
89
|
}
|
|
90
90
|
}, mui5Theme, theme != null ? theme : {});
|
|
91
91
|
}, [muiTheme, theme]);
|
|
92
|
-
return jsx(TableThemeContext.Provider, {
|
|
92
|
+
return /* @__PURE__ */ jsx(TableThemeContext.Provider, {
|
|
93
93
|
value: _theme,
|
|
94
94
|
children
|
|
95
95
|
});
|
package/dist/es/mui5Theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mui5Theme.js","sources":["../../src/theme/mui5Theme/index.tsx"],"sourcesContent":["import { Badge, Button, Checkbox, CircularProgress, IconButton, TextField, useTheme } from '@mui/material';\nimport { ReactNode, useMemo } from 'react';\nimport { PartialTableTheme } from '../../types';\nimport { Popover } from '../defaultTheme/popover';\nimport { mergeThemes, TableThemeContext } from '../tableTheme';\n\nexport const mui5Theme: PartialTableTheme = {\n components: {\n Button: (props) => (\n <Button\n {...props}\n size=\"small\"\n fullWidth\n css={{ justifyContent: 'start !important' }}\n color={props.variant === 'contained' ? 'primary' : 'inherit'}\n />\n ),\n IconButton: (props) => <IconButton {...props} size=\"small\" css={{ fontSize: '0.8em' }} color=\"inherit\" />,\n Checkbox: (props) => <Checkbox {...props} color=\"primary\" size=\"small\" />,\n Popover,\n Badge,\n TextField: ({ endIcon, ...props }) => <TextField {...props} InputProps={{ endAdornment: endIcon }} size=\"small\" />,\n Spinner: (props) => <CircularProgress {...props} size={20} />,\n },\n};\n\nexport function Mui5TableThemeProvider({ theme, children }: { theme?: PartialTableTheme; children: ReactNode }) {\n const muiTheme = useTheme();\n\n const _theme = useMemo(() => {\n return mergeThemes(\n {\n colors: {\n primary: muiTheme.palette.primary,\n secondary: muiTheme.palette.secondary,\n },\n },\n mui5Theme,\n theme ?? {},\n );\n }, [muiTheme, theme]);\n\n return <TableThemeContext.Provider value={_theme}>{children}</TableThemeContext.Provider>;\n}\n"],"names":["mui5Theme","components","Button","props","
|
|
1
|
+
{"version":3,"file":"mui5Theme.js","sources":["../../src/theme/mui5Theme/index.tsx"],"sourcesContent":["import { Badge, Button, Checkbox, CircularProgress, IconButton, TextField, useTheme } from '@mui/material';\nimport { ReactNode, useMemo } from 'react';\nimport { PartialTableTheme } from '../../types';\nimport { Popover } from '../defaultTheme/popover';\nimport { mergeThemes, TableThemeContext } from '../tableTheme';\n\nexport const mui5Theme: PartialTableTheme = {\n components: {\n Button: (props) => (\n <Button\n {...props}\n size=\"small\"\n fullWidth\n css={{ justifyContent: 'start !important' }}\n color={props.variant === 'contained' ? 'primary' : 'inherit'}\n />\n ),\n IconButton: (props) => <IconButton {...props} size=\"small\" css={{ fontSize: '0.8em' }} color=\"inherit\" />,\n Checkbox: (props) => <Checkbox {...props} color=\"primary\" size=\"small\" />,\n Popover,\n Badge,\n TextField: ({ endIcon, ...props }) => <TextField {...props} InputProps={{ endAdornment: endIcon }} size=\"small\" />,\n Spinner: (props) => <CircularProgress {...props} size={20} />,\n },\n};\n\nexport function Mui5TableThemeProvider({ theme, children }: { theme?: PartialTableTheme; children: ReactNode }) {\n const muiTheme = useTheme();\n\n const _theme = useMemo(() => {\n return mergeThemes(\n {\n colors: {\n primary: muiTheme.palette.primary,\n secondary: muiTheme.palette.secondary,\n },\n },\n mui5Theme,\n theme ?? {},\n );\n }, [muiTheme, theme]);\n\n return <TableThemeContext.Provider value={_theme}>{children}</TableThemeContext.Provider>;\n}\n"],"names":["mui5Theme","components","Button","props","justifyContent","variant","IconButton","fontSize","Checkbox","Popover","Badge","TextField","endIcon","endAdornment","Spinner","theme","children","muiTheme","useTheme","_theme","useMemo","mergeThemes","colors","primary","palette","secondary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAMaA,YAA+B;AAAA,EAC1CC,YAAY;AAAA,IACVC,QAASC,+BACN,yCACKA;MACJ,MAAK;AAAA,MACL;MACA,KAAK;AAAA,QAAEC,gBAAgB;AAAA;MACvB,OAAOD,MAAME,YAAY,cAAc,YAAY;AAAA;IAGvDC,YAAaH,+BAAW,6CAAeA;MAAO,MAAK;AAAA,MAAQ,KAAK;AAAA,QAAEI,UAAU;AAAA;MAAW,OAAM;AAAA;IAC7FC,UAAWL,+BAAW,2CAAaA;MAAO,OAAM;AAAA,MAAU,MAAK;AAAA;IAC/DM;AAAAA,IACAC;AAAAA,IACAC,WAAW,CAAC;AAAA,mBAAEC;AAAAA;AAAAA,UAAF,IAAcT,kBAAd,IAAcA;AAAAA,QAAZS;AAAAA;iCAAyB,4CAAcT;QAAO,YAAY;AAAA,UAAEU,cAAcD;AAAAA;QAAW,MAAK;AAAA;;IACxGE,SAAUX,+BAAW,mDAAqBA;MAAO,MAAM;AAAA;;AAhBf;gCAoBL;AAAA,EAAEY;AAAAA,EAAOC;AAAAA,GAAgE;QACxGC,WAAWC;QAEXC,SAASC,QAAQ,MAAM;WACpBC,YACL;AAAA,MACEC,QAAQ;AAAA,QACNC,SAASN,SAASO,QAAQD;AAAAA,QAC1BE,WAAWR,SAASO,QAAQC;AAAAA;OAGhCzB,WACAe,wBAAS,EARO;AAAA,KAUjB,CAACE,UAAUF,KAAX,CAXmB;6BAad,kBAAkB;IAAS,OAAOI;AAAAA;;AAC3C;;"}
|
package/dist/es/tableTheme.js
CHANGED
|
@@ -48,6 +48,12 @@ const defaultClasses = {
|
|
|
48
48
|
borderBottom: `1px solid #c9cfda`,
|
|
49
49
|
background: white
|
|
50
50
|
}),
|
|
51
|
+
footerCell: css(cell, {
|
|
52
|
+
padding: `var(--spacing) 0 var(--spacing) calc(2 * var(--spacing))`,
|
|
53
|
+
borderTop: `1px solid #c9cfda`,
|
|
54
|
+
borderBottom: "none",
|
|
55
|
+
background: white
|
|
56
|
+
}),
|
|
51
57
|
firstCell: css({
|
|
52
58
|
justifyContent: "start"
|
|
53
59
|
}),
|
|
@@ -56,10 +62,19 @@ const defaultClasses = {
|
|
|
56
62
|
top: 0,
|
|
57
63
|
zIndex: 2
|
|
58
64
|
}),
|
|
65
|
+
stickyBottom: css({
|
|
66
|
+
position: "sticky",
|
|
67
|
+
bottom: 0,
|
|
68
|
+
zIndex: 2
|
|
69
|
+
}),
|
|
59
70
|
headerFill: css({
|
|
60
71
|
borderBottom: `1px solid #c9cfda`,
|
|
61
72
|
background: white
|
|
62
73
|
}),
|
|
74
|
+
footerFill: css({
|
|
75
|
+
borderTop: `1px solid #c9cfda`,
|
|
76
|
+
background: white
|
|
77
|
+
}),
|
|
63
78
|
text: css({
|
|
64
79
|
minWidth: 0,
|
|
65
80
|
overflow: "hidden",
|
|
@@ -140,10 +155,10 @@ const Popover = ({
|
|
|
140
155
|
}), [depth, visible]);
|
|
141
156
|
if (!open)
|
|
142
157
|
return null;
|
|
143
|
-
return jsx(PopoverContext.Provider, {
|
|
158
|
+
return /* @__PURE__ */ jsx(PopoverContext.Provider, {
|
|
144
159
|
value: context,
|
|
145
|
-
children: createPortal(jsxs(Fragment, {
|
|
146
|
-
children: [jsx("div", {
|
|
160
|
+
children: createPortal(/* @__PURE__ */ jsxs(Fragment, {
|
|
161
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
147
162
|
css: [{
|
|
148
163
|
position: "fixed",
|
|
149
164
|
left: 0,
|
|
@@ -155,7 +170,7 @@ const Popover = ({
|
|
|
155
170
|
display: "none"
|
|
156
171
|
}],
|
|
157
172
|
onClick: () => onClose()
|
|
158
|
-
}), jsx("div", {
|
|
173
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
159
174
|
ref: popper,
|
|
160
175
|
className,
|
|
161
176
|
css: [defaultClasses.card, __spreadProps(__spreadValues({
|
|
@@ -183,7 +198,7 @@ function TableThemeProvider({
|
|
|
183
198
|
theme,
|
|
184
199
|
children
|
|
185
200
|
}) {
|
|
186
|
-
return jsx(TableThemeContext.Provider, {
|
|
201
|
+
return /* @__PURE__ */ jsx(TableThemeContext.Provider, {
|
|
187
202
|
value: theme,
|
|
188
203
|
children
|
|
189
204
|
});
|
|
@@ -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 background: white,\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 headerFill: css({\n borderBottom: `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":["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","_jsx","createPortal","_jsxs","right","zIndex","display","defaultClasses","card","maxWidth","maxHeight","visibility","body","globalTableTheme","tableTheme","TableThemeContext","theme","themes","text","Object","assign","map","classes","components","icons","colors","primary","secondary","spac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
{"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 background: white,\n }),\n\n footerCell: css(cell, {\n padding: `var(--spacing) 0 var(--spacing) calc(2 * var(--spacing))`,\n borderTop: `1px solid #c9cfda`,\n borderBottom: 'none',\n background: white,\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":["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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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;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ColumnFooter(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { HTMLProps } from 'react';
|
|
2
1
|
import { StoreScope } from 'schummar-state/react';
|
|
3
2
|
import { Id } from '..';
|
|
4
3
|
export declare const ColumnHeaderContext: StoreScope<{
|
|
5
4
|
items: Map<Id, HTMLDivElement>;
|
|
6
5
|
}>;
|
|
7
|
-
export declare function ColumnHeader(
|
|
6
|
+
export declare function ColumnHeader(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Id,
|
|
3
|
-
export declare function calcClassNames<T>(classes:
|
|
2
|
+
import { Id, MemoizedTableTheme } from '../types';
|
|
3
|
+
export declare function calcClassNames<T>(classes: MemoizedTableTheme<any>['classes'] | undefined, item: T, index: number): (string | false | undefined)[];
|
|
4
4
|
export declare const Row: React.MemoExoticComponent<(<T>({ itemId, rowIndex }: {
|
|
5
5
|
itemId: Id;
|
|
6
6
|
rowIndex: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HTMLProps, ReactNode } from 'react';
|
|
2
2
|
import { Id } from '../types';
|
|
3
|
-
export declare function Virtualized<T>({ header, children, ...props }: {
|
|
3
|
+
export declare function Virtualized<T>({ header, footer, children, ...props }: {
|
|
4
4
|
header: ReactNode;
|
|
5
|
+
footer: ReactNode;
|
|
5
6
|
children: (itemIds: Id[], startIndex: number) => ReactNode;
|
|
6
7
|
} & HTMLProps<HTMLDivElement>): JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { FunctionWithDeps } from '../types';
|
|
3
|
+
export declare function TableMemoContextProvider({ children }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function useTableMemo(): <Fn extends (...args: any[]) => any>(key: string, fn: FunctionWithDeps<Fn>) => Fn;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function useTheme<T>(
|
|
1
|
+
import { MemoizedTableTheme } from '../types';
|
|
2
|
+
export declare function useTheme<T, S>(selector: (theme: MemoizedTableTheme<T>) => S): S;
|
|
@@ -7,9 +7,12 @@ export declare const defaultClasses: {
|
|
|
7
7
|
cell: import("@emotion/utils").SerializedStyles;
|
|
8
8
|
cellFill: import("@emotion/utils").SerializedStyles;
|
|
9
9
|
headerCell: import("@emotion/utils").SerializedStyles;
|
|
10
|
+
footerCell: import("@emotion/utils").SerializedStyles;
|
|
10
11
|
firstCell: import("@emotion/utils").SerializedStyles;
|
|
11
12
|
sticky: import("@emotion/utils").SerializedStyles;
|
|
13
|
+
stickyBottom: import("@emotion/utils").SerializedStyles;
|
|
12
14
|
headerFill: import("@emotion/utils").SerializedStyles;
|
|
15
|
+
footerFill: import("@emotion/utils").SerializedStyles;
|
|
13
16
|
text: import("@emotion/utils").SerializedStyles;
|
|
14
17
|
card: import("@emotion/utils").SerializedStyles;
|
|
15
18
|
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSInterpolation } from '@emotion/serialize';
|
|
2
|
-
import React, { ComponentType, ReactNode, Ref } from 'react';
|
|
2
|
+
import React, { ComponentType, DependencyList, ReactNode, Ref } from 'react';
|
|
3
3
|
import { TableStateStorage } from './internalState/tableStateStorage';
|
|
4
4
|
import { CsvExportOptions } from './misc/csvExport';
|
|
5
5
|
export declare type Sort = {
|
|
@@ -11,6 +11,10 @@ export declare type Id = string | number;
|
|
|
11
11
|
export declare type KeyOfType<T, S> = {
|
|
12
12
|
[K in keyof T]: T[K] extends S ? K : never;
|
|
13
13
|
}[keyof T];
|
|
14
|
+
export declare type FunctionWithDeps<F extends (...args: any[]) => any> = F | [function: F, ...deps: DependencyList];
|
|
15
|
+
export declare type MemoizedFunctions<T> = {
|
|
16
|
+
[K in keyof T]: Exclude<T[K], [function: (...args: any[]) => any, ...deps: DependencyList[]]>;
|
|
17
|
+
};
|
|
14
18
|
export interface TableTheme<T = unknown> {
|
|
15
19
|
/** Define display texts. */
|
|
16
20
|
text: {
|
|
@@ -23,17 +27,18 @@ export interface TableTheme<T = unknown> {
|
|
|
23
27
|
thisWeek: ReactNode;
|
|
24
28
|
reset: ReactNode;
|
|
25
29
|
loading: ReactNode;
|
|
26
|
-
selected: (count: number) => ReactNode
|
|
30
|
+
selected: FunctionWithDeps<(count: number) => ReactNode>;
|
|
27
31
|
};
|
|
28
32
|
/** Define styles. */
|
|
29
33
|
classes?: {
|
|
30
34
|
table?: string;
|
|
31
35
|
headerCell?: string;
|
|
32
|
-
|
|
36
|
+
footerCell?: string;
|
|
37
|
+
cell?: string | FunctionWithDeps<(item: T, index: number) => string | undefined>;
|
|
33
38
|
evenCell?: string;
|
|
34
39
|
oddCell?: string;
|
|
35
40
|
};
|
|
36
|
-
/**
|
|
41
|
+
/** Define components to be used in the table. */
|
|
37
42
|
components: {
|
|
38
43
|
IconButton: ComponentType<{
|
|
39
44
|
children: ReactNode;
|
|
@@ -102,19 +107,27 @@ export interface TableTheme<T = unknown> {
|
|
|
102
107
|
export declare type PartialTableTheme<T = unknown> = {
|
|
103
108
|
[K in keyof TableTheme<T>]?: TableTheme<T>[K] extends Record<string, any> ? Partial<TableTheme<T>[K]> : TableTheme<T>[K];
|
|
104
109
|
};
|
|
110
|
+
export declare type MemoizedTableTheme<T> = Omit<TableTheme, 'classes' | 'text'> & {
|
|
111
|
+
classes: MemoizedFunctions<TableTheme<T>['classes']>;
|
|
112
|
+
text: MemoizedFunctions<TableTheme<T>['text']>;
|
|
113
|
+
};
|
|
105
114
|
export interface TableProps<T> extends PartialTableTheme<T> {
|
|
106
115
|
/** The data to be rendered. One item per row. */
|
|
107
116
|
items?: T[];
|
|
108
117
|
/** Unique id for each item/row. */
|
|
109
|
-
id: (
|
|
118
|
+
id: FunctionWithDeps<(item: T) => Id> | KeyOfType<T, Id>;
|
|
110
119
|
/** Create a nested structure by assigning parents to items. Child items are hidden until the parent is expanded. */
|
|
111
|
-
parentId?: (
|
|
120
|
+
parentId?: FunctionWithDeps<(item: T) => Id | undefined> | KeyOfType<T, Id | undefined>;
|
|
112
121
|
/** If true for an item, it means that children will be loaded asynchronously as soon as item is expanded. */
|
|
113
122
|
hasDeferredChildren?: (item: T) => boolean;
|
|
114
123
|
/** Column definitions. */
|
|
115
124
|
columns: Column<T, any>[] | ((col: <V>(value: (item: T) => V, column: Omit<Column<T, V>, 'value'>) => Column<T, V>) => Column<T, any>[]);
|
|
125
|
+
/** Default props for all column. Will take effect if not overriden in column definition. */
|
|
126
|
+
defaultColumnProps?: Omit<Column<T, unknown>, 'id' | 'value'>;
|
|
127
|
+
/** Wrap each cell */
|
|
128
|
+
wrapCell?: FunctionWithDeps<(content: ReactNode, value: unknown, item: T, index: number) => ReactNode>;
|
|
116
129
|
/** Display a cell at the start of each row. Useful for "go to details" button for example. */
|
|
117
|
-
rowAction?: ReactNode | (
|
|
130
|
+
rowAction?: ReactNode | FunctionWithDeps<(item: T, index: number) => ReactNode>;
|
|
118
131
|
/** Default sort order. */
|
|
119
132
|
defaultSort?: Sort[];
|
|
120
133
|
/** If given, controls the sort order. */
|
|
@@ -155,16 +168,20 @@ export interface TableProps<T> extends PartialTableTheme<T> {
|
|
|
155
168
|
hiddenColumns?: Set<Id>;
|
|
156
169
|
/** Called when hidden columns change. */
|
|
157
170
|
onHiddenColumnsChange?: (hiddenColumns: Set<Id>) => void;
|
|
158
|
-
/** Default width for columns. */
|
|
159
|
-
defaultWidth?: string;
|
|
160
171
|
/** Whether to stretch the table component over the available space. If value is "left" or "right", align accordingly. */
|
|
161
172
|
fullWidth?: boolean | 'left' | 'right';
|
|
162
173
|
/** Whether the table header should be sticky.
|
|
163
|
-
* @default
|
|
174
|
+
* @default true
|
|
164
175
|
*/
|
|
165
176
|
stickyHeader?: boolean | {
|
|
166
177
|
top: number;
|
|
167
178
|
};
|
|
179
|
+
/** Whether the table footer should be sticky.
|
|
180
|
+
* @default true
|
|
181
|
+
*/
|
|
182
|
+
stickyFooter?: boolean | {
|
|
183
|
+
bottom: number;
|
|
184
|
+
};
|
|
168
185
|
/** Whether the table cells should only be rendered when in viewport.
|
|
169
186
|
* @default true
|
|
170
187
|
*/
|
|
@@ -205,7 +222,7 @@ export interface TableProps<T> extends PartialTableTheme<T> {
|
|
|
205
222
|
debug?: (...output: any) => void;
|
|
206
223
|
debugRender?: (...output: any) => void;
|
|
207
224
|
}
|
|
208
|
-
export declare type InternalTableProps<T> = Omit<TableProps<T>, 'id' | 'parentId' | 'columns' | 'enableExport'> & {
|
|
225
|
+
export declare type InternalTableProps<T> = MemoizedFunctions<Omit<TableProps<T>, 'id' | 'parentId' | 'columns' | 'defaultColumnProps' | 'enableExport'> & {
|
|
209
226
|
id: (item: T) => Id;
|
|
210
227
|
parentId?: (item: T) => Id | undefined;
|
|
211
228
|
columns: InternalColumn<T, unknown>[];
|
|
@@ -213,11 +230,12 @@ export declare type InternalTableProps<T> = Omit<TableProps<T>, 'id' | 'parentId
|
|
|
213
230
|
copy?: CsvExportOptions;
|
|
214
231
|
download?: CsvExportOptions;
|
|
215
232
|
};
|
|
216
|
-
}
|
|
217
|
-
export declare type TableItem<T = unknown> =
|
|
233
|
+
}>;
|
|
234
|
+
export declare type TableItem<T = unknown> = {
|
|
218
235
|
id: Id;
|
|
219
236
|
parentId?: Id;
|
|
220
237
|
children: TableItem<T>[];
|
|
238
|
+
value: T;
|
|
221
239
|
};
|
|
222
240
|
export declare type Column<T, V> = {
|
|
223
241
|
/** Column id. If not provided, the index in the column array will be used.
|
|
@@ -225,15 +243,17 @@ export declare type Column<T, V> = {
|
|
|
225
243
|
*/
|
|
226
244
|
id?: string;
|
|
227
245
|
/** Render table header for this column. */
|
|
228
|
-
header?: ReactNode
|
|
246
|
+
header?: ReactNode | FunctionWithDeps<(values: V[], items: T[]) => ReactNode>;
|
|
247
|
+
/** Render table header for this column. */
|
|
248
|
+
footer?: ReactNode | FunctionWithDeps<(values: V[], items: T[]) => ReactNode>;
|
|
229
249
|
/** Extract value for this column */
|
|
230
|
-
value: (item: T) => V
|
|
250
|
+
value: FunctionWithDeps<(item: T) => V>;
|
|
231
251
|
/** Render table cell. If not provided, a string representation of the value will be rendered. */
|
|
232
|
-
renderCell?: (value: V, item: T) => ReactNode
|
|
252
|
+
renderCell?: FunctionWithDeps<(value: V, item: T) => ReactNode>;
|
|
233
253
|
/** Serialize column value for exports. If not provided, a string representation of the value will be used. */
|
|
234
254
|
exportCell?: (value: V, item: T) => string | number;
|
|
235
255
|
/** Customize sort criteria. By default it will be the value itself in case it's a number or Date, or a string representation of the value otherwise. */
|
|
236
|
-
sortBy?: (
|
|
256
|
+
sortBy?: FunctionWithDeps<(value: V, item: T) => unknown>[];
|
|
237
257
|
/** Set filter component that will be displayed in the column header */
|
|
238
258
|
filter?: ReactNode;
|
|
239
259
|
/** Prevent hiding the column. */
|
|
@@ -244,12 +264,11 @@ export declare type Column<T, V> = {
|
|
|
244
264
|
width?: string;
|
|
245
265
|
/** Provide css class names to override columns styles. */
|
|
246
266
|
classes?: TableTheme<T>['classes'];
|
|
247
|
-
/** If the column definition changes, supply parameters that it depends on. If not set, the column will not update */
|
|
248
|
-
dependencies?: any[];
|
|
249
267
|
};
|
|
250
|
-
export declare type InternalColumn<T, V> = Required<Omit<Column<T, V>, 'id'>, 'header' | 'renderCell' | 'exportCell' | 'sortBy'> & {
|
|
268
|
+
export declare type InternalColumn<T, V> = MemoizedFunctions<Required<Omit<Column<T, V>, 'id' | 'sortBy'>, 'header' | 'renderCell' | 'exportCell' | 'sortBy'> & {
|
|
251
269
|
id: Id;
|
|
252
|
-
|
|
270
|
+
sortBy: ((value: V, item: T) => unknown)[];
|
|
271
|
+
}>;
|
|
253
272
|
declare type Required<T, S> = T & {
|
|
254
273
|
[P in keyof T as P extends S ? P : never]-?: T[P];
|
|
255
274
|
};
|
|
@@ -259,7 +278,7 @@ export declare type InternalTableState<T> = {
|
|
|
259
278
|
selection: Set<Id>;
|
|
260
279
|
expanded: Set<Id>;
|
|
261
280
|
rowHeights: Map<Id, number>;
|
|
262
|
-
filters: Map<Id, FilterImplementation<T, any, any, any
|
|
281
|
+
filters: Map<Id, MemoizedFunctions<FilterImplementation<T, any, any, any>>>;
|
|
263
282
|
filterValues: Map<Id, any>;
|
|
264
283
|
hiddenColumns: Set<Id>;
|
|
265
284
|
columnWidths: Map<Id, string>;
|
|
@@ -274,7 +293,7 @@ export declare type InternalTableState<T> = {
|
|
|
274
293
|
};
|
|
275
294
|
export declare type CommonFilterProps<T, V, F, S extends SerializableValue> = {
|
|
276
295
|
/** Filter by? By default the column value will be used. If filterBy returns an array, an items will be active if at least one entry matches the active filter. */
|
|
277
|
-
filterBy?: (value: V, item: T) => F | F[]
|
|
296
|
+
filterBy?: FunctionWithDeps<(value: V, item: T) => F | F[]>;
|
|
278
297
|
/** Preselected filter value. */
|
|
279
298
|
defaultValue?: S;
|
|
280
299
|
/** Controlled filter value. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "schummar-table",
|
|
3
3
|
"repository": "schummar/schummar-table",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"docs:build": "npm -w docs run build"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@emotion/react": "^11.
|
|
61
|
+
"@emotion/react": "^11.9.0",
|
|
62
62
|
"dayzed": "^3.2.2",
|
|
63
63
|
"immer": "^9.0.12",
|
|
64
64
|
"schummar-state": "0.2.1-experimental-13"
|
|
@@ -84,21 +84,21 @@
|
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@emotion/styled": "^11.8.1",
|
|
87
|
-
"@material-ui/core": "^4.12.
|
|
88
|
-
"@mui/material": "^5.
|
|
87
|
+
"@material-ui/core": "^4.12.4",
|
|
88
|
+
"@mui/material": "^5.6.3",
|
|
89
89
|
"@types/react": "17",
|
|
90
90
|
"@types/react-dom": "^17.0.13",
|
|
91
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
92
|
-
"@typescript-eslint/parser": "^5.
|
|
93
|
-
"@vitejs/plugin-react": "^1.
|
|
94
|
-
"eslint": "^8.
|
|
91
|
+
"@typescript-eslint/eslint-plugin": "^5.21.0",
|
|
92
|
+
"@typescript-eslint/parser": "^5.21.0",
|
|
93
|
+
"@vitejs/plugin-react": "^1.3.1",
|
|
94
|
+
"eslint": "^8.14.0",
|
|
95
95
|
"npm-run-all": "^4.1.5",
|
|
96
|
-
"prettier": "^2.
|
|
96
|
+
"prettier": "^2.6.2",
|
|
97
97
|
"react": "17",
|
|
98
98
|
"react-dom": "17",
|
|
99
99
|
"rimraf": "^3.0.2",
|
|
100
|
-
"typescript": "^4.6.
|
|
101
|
-
"vite": "^2.
|
|
100
|
+
"typescript": "^4.6.3",
|
|
101
|
+
"vite": "^2.9.5"
|
|
102
102
|
},
|
|
103
103
|
"files": [
|
|
104
104
|
"dist"
|