@xanui/ui 1.1.37 → 1.1.38
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/Accordion/index.js +19 -21
- package/Accordion/index.js.map +1 -1
- package/Alert/index.js +33 -35
- package/Alert/index.js.map +1 -1
- package/Autocomplete/index.js +23 -25
- package/Autocomplete/index.js.map +1 -1
- package/Avatar/index.js +15 -17
- package/Avatar/index.js.map +1 -1
- package/Badge/index.js +12 -14
- package/Badge/index.js.map +1 -1
- package/Box/index.js +7 -9
- package/Box/index.js.map +1 -1
- package/Button/index.js +17 -19
- package/Button/index.js.map +1 -1
- package/ButtonGroup/index.js +12 -14
- package/ButtonGroup/index.js.map +1 -1
- package/Calendar/index.js +39 -41
- package/Calendar/index.js.map +1 -1
- package/CalendarInput/index.js +19 -21
- package/CalendarInput/index.js.map +1 -1
- package/Checkbox/index.js +14 -16
- package/Checkbox/index.js.map +1 -1
- package/Chip/index.js +12 -14
- package/Chip/index.js.map +1 -1
- package/CircleProgress/index.js +13 -15
- package/CircleProgress/index.js.map +1 -1
- package/ClickOutside/index.js +9 -11
- package/ClickOutside/index.js.map +1 -1
- package/Collaps/index.js +9 -11
- package/Collaps/index.js.map +1 -1
- package/Container/index.js +9 -11
- package/Container/index.js.map +1 -1
- package/DataFilter/index.js +30 -41
- package/DataFilter/index.js.map +1 -1
- package/DataFilter/options/DateFilter.js +16 -18
- package/DataFilter/options/DateFilter.js.map +1 -1
- package/DataFilter/options/DateRangeFilter.js +12 -14
- package/DataFilter/options/DateRangeFilter.js.map +1 -1
- package/DataFilter/options/MultiSelectFilter.js +20 -22
- package/DataFilter/options/MultiSelectFilter.js.map +1 -1
- package/DataFilter/options/NumberFilter.js +11 -13
- package/DataFilter/options/NumberFilter.js.map +1 -1
- package/DataFilter/options/NumberRangeFilter.js +12 -14
- package/DataFilter/options/NumberRangeFilter.js.map +1 -1
- package/DataFilter/options/SelectFilter.js +18 -20
- package/DataFilter/options/SelectFilter.js.map +1 -1
- package/DataFilter/options/TextFilter.js +11 -13
- package/DataFilter/options/TextFilter.js.map +1 -1
- package/Datatable/FilterBox.js +21 -23
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/Row.js +19 -21
- package/Datatable/Row.js.map +1 -1
- package/Datatable/SelectedBox.js +10 -12
- package/Datatable/SelectedBox.js.map +1 -1
- package/Datatable/Table.js +8 -10
- package/Datatable/Table.js.map +1 -1
- package/Datatable/TableHead.js +18 -20
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/index.js +21 -23
- package/Datatable/index.js.map +1 -1
- package/Divider/index.js +8 -10
- package/Divider/index.js.map +1 -1
- package/Drawer/index.js +12 -14
- package/Drawer/index.js.map +1 -1
- package/Form/index.js +8 -10
- package/Form/index.js.map +1 -1
- package/GridContainer/index.js +7 -9
- package/GridContainer/index.js.map +1 -1
- package/GridItem/index.js +7 -9
- package/GridItem/index.js.map +1 -1
- package/IconButton/index.js +12 -14
- package/IconButton/index.js.map +1 -1
- package/Image/index.js +9 -11
- package/Image/index.js.map +1 -1
- package/Input/index.js +18 -20
- package/Input/index.js.map +1 -1
- package/InputNumber/index.js +6 -8
- package/InputNumber/index.js.map +1 -1
- package/Label/index.js +7 -9
- package/Label/index.js.map +1 -1
- package/Layer/index.js +19 -21
- package/Layer/index.js.map +1 -1
- package/LineProgress/index.js +11 -13
- package/LineProgress/index.js.map +1 -1
- package/List/ListContext.js +2 -5
- package/List/ListContext.js.map +1 -1
- package/List/index.js +12 -14
- package/List/index.js.map +1 -1
- package/ListItem/index.js +12 -14
- package/ListItem/index.js.map +1 -1
- package/LoadingBox/index.js +11 -13
- package/LoadingBox/index.js.map +1 -1
- package/Menu/index.js +18 -20
- package/Menu/index.js.map +1 -1
- package/Modal/index.js +15 -17
- package/Modal/index.js.map +1 -1
- package/NoSSR/index.js +4 -6
- package/NoSSR/index.js.map +1 -1
- package/Option/index.js +7 -9
- package/Option/index.js.map +1 -1
- package/Paper/index.js +8 -10
- package/Paper/index.js.map +1 -1
- package/Portal/index.js +9 -11
- package/Portal/index.js.map +1 -1
- package/Radio/index.js +9 -11
- package/Radio/index.js.map +1 -1
- package/Scrollbar/index.js +10 -12
- package/Scrollbar/index.js.map +1 -1
- package/Select/index.js +22 -24
- package/Select/index.js.map +1 -1
- package/Skeleton/index.js +7 -9
- package/Skeleton/index.js.map +1 -1
- package/Stack/index.js +7 -9
- package/Stack/index.js.map +1 -1
- package/Switch/index.js +12 -14
- package/Switch/index.js.map +1 -1
- package/Tab/index.js +9 -11
- package/Tab/index.js.map +1 -1
- package/Table/index.js +13 -15
- package/Table/index.js.map +1 -1
- package/TableBody/index.js +7 -9
- package/TableBody/index.js.map +1 -1
- package/TableCell/index.js +7 -9
- package/TableCell/index.js.map +1 -1
- package/TableFooter/index.js +7 -9
- package/TableFooter/index.js.map +1 -1
- package/TableHead/index.js +7 -9
- package/TableHead/index.js.map +1 -1
- package/TablePagination/index.js +21 -23
- package/TablePagination/index.js.map +1 -1
- package/TableRow/index.js +7 -9
- package/TableRow/index.js.map +1 -1
- package/Tabs/index.js +19 -21
- package/Tabs/index.js.map +1 -1
- package/Text/index.js +8 -10
- package/Text/index.js.map +1 -1
- package/Toast/index.js +18 -20
- package/Toast/index.js.map +1 -1
- package/Tooltip/index.js +11 -13
- package/Tooltip/index.js.map +1 -1
- package/ViewBox/index.js +11 -13
- package/ViewBox/index.js.map +1 -1
- package/index.js +64 -133
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/useAlert/index.js +12 -14
- package/useAlert/index.js.map +1 -1
- package/useBlurCss/index.js +5 -7
- package/useBlurCss/index.js.map +1 -1
- package/useCorner/index.js +1 -3
- package/useCorner/index.js.map +1 -1
- package/useLayer/index.js +7 -9
- package/useLayer/index.js.map +1 -1
- package/useModal/index.js +8 -10
- package/useModal/index.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectFilter.js","sources":["../../../src/DataFilter/options/SelectFilter.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport React from \"react\";\r\nimport { DataFilterSelect } from \"../types\";\r\nimport Menu from \"../../Menu\";\r\nimport List from \"../../List\";\r\nimport ListItem from \"../../ListItem\";\r\nimport Checkbox from \"../../Checkbox\";\r\nimport IconButton from \"../../IconButton\";\r\nimport Stack from \"../../Stack\";\r\nimport Text from \"../../Text\";\r\nimport Close from \"@xanui/icons/Close\";\r\nimport Add from \"@xanui/icons/Add\";\r\nimport ClearAll from \"@xanui/icons/ClearAll\";\r\nimport Chip from \"../../Chip\";\r\n\r\n\r\ntype Props = {\r\n option: DataFilterSelect;\r\n value: string | null;\r\n onChange: (value: string | null) => void;\r\n}\r\n\r\nconst SelectFilter = ({ option, onChange, value }: Props) => {\r\n const ref: any = React.useRef(null)\r\n const [target, setTarget] = React.useState<HTMLElement | undefined>()\r\n return (\r\n <Stack\r\n width={\"100%\"}\r\n bgcolor=\"background.secondary\"\r\n p={1}\r\n radius={1}\r\n >\r\n <Stack\r\n direction=\"row\"\r\n alignItems=\"center\"\r\n justifyContent={\"space-between\"}\r\n gap={0.5}\r\n mb={value ? .5 : 0}\r\n >\r\n <Text>{option.label}</Text>\r\n <Stack\r\n direction=\"row\"\r\n gap={0.5}\r\n >\r\n <IconButton\r\n size=\"small\"\r\n variant=\"soft\"\r\n color={\"default\"}\r\n onClick={(e: any) => {\r\n setTarget(e.currentTarget)\r\n }}\r\n >\r\n <Add />\r\n </IconButton>\r\n {\r\n !!value && <IconButton\r\n size=\"small\"\r\n variant=\"soft\"\r\n color={\"danger\"}\r\n onClick={() => {\r\n onChange(null);\r\n }}\r\n >\r\n <ClearAll />\r\n </IconButton>\r\n }\r\n </Stack>\r\n </Stack>\r\n <Stack\r\n direction=\"row\"\r\n gap={0.5}\r\n flexWrap=\"wrap\"\r\n >\r\n {\r\n !!value && <Chip\r\n size=\"small\"\r\n color=\"default\"\r\n label={value}\r\n endIcon={<IconButton\r\n size={16}\r\n variant={\"text\"}\r\n color=\"default\"\r\n onClick={() => {\r\n onChange(null);\r\n }}\r\n >\r\n <Close />\r\n </IconButton>}\r\n />\r\n }\r\n </Stack>\r\n <Menu\r\n target={target}\r\n onClickOutside={() => setTarget(undefined)}\r\n placement={\"bottom-right\"}\r\n >\r\n <List width={ref?.current?.offsetWidth || 200} size=\"small\">\r\n {\r\n option.options.map((opt, index) => (\r\n <ListItem\r\n key={index}\r\n startIcon={<Checkbox checked={value === opt.value} />}\r\n onClick={() => {\r\n onChange(opt.value);\r\n }}\r\n >\r\n {opt.label}\r\n </ListItem>\r\n ))\r\n }\r\n </List>\r\n </Menu>\r\n </Stack>\r\n )\r\n}\r\n\r\nexport default SelectFilter"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectFilter.js","sources":["../../../src/DataFilter/options/SelectFilter.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport React from \"react\";\r\nimport { DataFilterSelect } from \"../types\";\r\nimport Menu from \"../../Menu\";\r\nimport List from \"../../List\";\r\nimport ListItem from \"../../ListItem\";\r\nimport Checkbox from \"../../Checkbox\";\r\nimport IconButton from \"../../IconButton\";\r\nimport Stack from \"../../Stack\";\r\nimport Text from \"../../Text\";\r\nimport Close from \"@xanui/icons/Close\";\r\nimport Add from \"@xanui/icons/Add\";\r\nimport ClearAll from \"@xanui/icons/ClearAll\";\r\nimport Chip from \"../../Chip\";\r\n\r\n\r\ntype Props = {\r\n option: DataFilterSelect;\r\n value: string | null;\r\n onChange: (value: string | null) => void;\r\n}\r\n\r\nconst SelectFilter = ({ option, onChange, value }: Props) => {\r\n const ref: any = React.useRef(null)\r\n const [target, setTarget] = React.useState<HTMLElement | undefined>()\r\n return (\r\n <Stack\r\n width={\"100%\"}\r\n bgcolor=\"background.secondary\"\r\n p={1}\r\n radius={1}\r\n >\r\n <Stack\r\n direction=\"row\"\r\n alignItems=\"center\"\r\n justifyContent={\"space-between\"}\r\n gap={0.5}\r\n mb={value ? .5 : 0}\r\n >\r\n <Text>{option.label}</Text>\r\n <Stack\r\n direction=\"row\"\r\n gap={0.5}\r\n >\r\n <IconButton\r\n size=\"small\"\r\n variant=\"soft\"\r\n color={\"default\"}\r\n onClick={(e: any) => {\r\n setTarget(e.currentTarget)\r\n }}\r\n >\r\n <Add />\r\n </IconButton>\r\n {\r\n !!value && <IconButton\r\n size=\"small\"\r\n variant=\"soft\"\r\n color={\"danger\"}\r\n onClick={() => {\r\n onChange(null);\r\n }}\r\n >\r\n <ClearAll />\r\n </IconButton>\r\n }\r\n </Stack>\r\n </Stack>\r\n <Stack\r\n direction=\"row\"\r\n gap={0.5}\r\n flexWrap=\"wrap\"\r\n >\r\n {\r\n !!value && <Chip\r\n size=\"small\"\r\n color=\"default\"\r\n label={value}\r\n endIcon={<IconButton\r\n size={16}\r\n variant={\"text\"}\r\n color=\"default\"\r\n onClick={() => {\r\n onChange(null);\r\n }}\r\n >\r\n <Close />\r\n </IconButton>}\r\n />\r\n }\r\n </Stack>\r\n <Menu\r\n target={target}\r\n onClickOutside={() => setTarget(undefined)}\r\n placement={\"bottom-right\"}\r\n >\r\n <List width={ref?.current?.offsetWidth || 200} size=\"small\">\r\n {\r\n option.options.map((opt, index) => (\r\n <ListItem\r\n key={index}\r\n startIcon={<Checkbox checked={value === opt.value} />}\r\n onClick={() => {\r\n onChange(opt.value);\r\n }}\r\n >\r\n {opt.label}\r\n </ListItem>\r\n ))\r\n }\r\n </List>\r\n </Menu>\r\n </Stack>\r\n )\r\n}\r\n\r\nexport default SelectFilter"],"names":[],"mappings":";;;;;;;;;;;;;;;AAuBA;;;;AAGG;AAwBkB;AACH;;AAWG;;AAuBA;AAmBM;AACH;AAUxB;;"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var ClearAll = require('@xanui/icons/ClearAll');
|
|
10
|
-
var index$3 = require('../../Input/index.js');
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import IconButton from '../../IconButton/index.js';
|
|
4
|
+
import Stack from '../../Stack/index.js';
|
|
5
|
+
import Text from '../../Text/index.js';
|
|
6
|
+
import Add from '@xanui/icons/Add';
|
|
7
|
+
import ClearAll from '@xanui/icons/ClearAll';
|
|
8
|
+
import Input from '../../Input/index.js';
|
|
11
9
|
|
|
12
10
|
const TextFilter = ({ option, onChange, value }) => {
|
|
13
11
|
const isValue = value !== null && value !== undefined;
|
|
14
|
-
return (
|
|
12
|
+
return (jsxs(Stack, { width: "100%", bgcolor: "background.secondary", p: 1, radius: 1, children: [jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 0.5, mb: isValue ? .5 : 0, children: [jsx(Text, { children: option.label }), jsxs(Stack, { direction: "row", gap: 0.5, children: [jsx(IconButton, { size: "small", variant: "soft", color: "default", onClick: () => {
|
|
15
13
|
onChange('');
|
|
16
|
-
}, children:
|
|
14
|
+
}, children: jsx(Add, {}) }), isValue && jsx(IconButton, { size: "small", variant: "soft", color: "danger", onClick: () => {
|
|
17
15
|
onChange(null);
|
|
18
|
-
}, children:
|
|
16
|
+
}, children: jsx(ClearAll, {}) })] })] }), jsx(Stack, { direction: "row", gap: 0.5, flexWrap: "wrap", children: isValue && jsx(Input, { variant: "outline", value: value.toString(), onChange: (e) => {
|
|
19
17
|
onChange(e.target.value);
|
|
20
18
|
}, fullWidth: true }) })] }));
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
export { TextFilter as default };
|
|
24
22
|
//# sourceMappingURL=TextFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextFilter.js","sources":["../../../src/DataFilter/options/TextFilter.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { DataFilterSelect } from \"../types\";\r\nimport IconButton from \"../../IconButton\";\r\nimport Stack from \"../../Stack\";\r\nimport Text from \"../../Text\";\r\nimport Add from \"@xanui/icons/Add\";\r\nimport ClearAll from \"@xanui/icons/ClearAll\";\r\nimport Input from \"../../Input\";\r\n\r\ntype Props = {\r\n option: DataFilterSelect;\r\n value: string | null;\r\n onChange: (value: string | null) => void;\r\n}\r\n\r\nconst TextFilter = ({ option, onChange, value }: Props) => {\r\n\r\n const isValue = value !== null && value !== undefined;\r\n\r\n return (\r\n <Stack\r\n width={\"100%\"}\r\n bgcolor=\"background.secondary\"\r\n p={1}\r\n radius={1}\r\n >\r\n <Stack\r\n direction=\"row\"\r\n alignItems=\"center\"\r\n justifyContent={\"space-between\"}\r\n gap={0.5}\r\n mb={isValue ? .5 : 0}\r\n >\r\n <Text>{option.label}</Text>\r\n <Stack\r\n direction=\"row\"\r\n gap={0.5}\r\n >\r\n <IconButton\r\n size=\"small\"\r\n variant=\"soft\"\r\n color={\"default\"}\r\n onClick={() => {\r\n onChange('');\r\n }}\r\n >\r\n <Add />\r\n </IconButton>\r\n {\r\n isValue && <IconButton\r\n size=\"small\"\r\n variant=\"soft\"\r\n color={\"danger\"}\r\n onClick={() => {\r\n onChange(null);\r\n }}\r\n >\r\n <ClearAll />\r\n </IconButton>\r\n }\r\n </Stack>\r\n </Stack>\r\n <Stack\r\n direction=\"row\"\r\n gap={0.5}\r\n flexWrap=\"wrap\"\r\n >\r\n {\r\n isValue && <Input\r\n variant={\"outline\"}\r\n value={value.toString()}\r\n onChange={(e: any) => {\r\n onChange(e.target.value);\r\n }}\r\n fullWidth\r\n />\r\n }\r\n </Stack>\r\n </Stack>\r\n )\r\n}\r\n\r\nexport default TextFilter"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextFilter.js","sources":["../../../src/DataFilter/options/TextFilter.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { DataFilterSelect } from \"../types\";\r\nimport IconButton from \"../../IconButton\";\r\nimport Stack from \"../../Stack\";\r\nimport Text from \"../../Text\";\r\nimport Add from \"@xanui/icons/Add\";\r\nimport ClearAll from \"@xanui/icons/ClearAll\";\r\nimport Input from \"../../Input\";\r\n\r\ntype Props = {\r\n option: DataFilterSelect;\r\n value: string | null;\r\n onChange: (value: string | null) => void;\r\n}\r\n\r\nconst TextFilter = ({ option, onChange, value }: Props) => {\r\n\r\n const isValue = value !== null && value !== undefined;\r\n\r\n return (\r\n <Stack\r\n width={\"100%\"}\r\n bgcolor=\"background.secondary\"\r\n p={1}\r\n radius={1}\r\n >\r\n <Stack\r\n direction=\"row\"\r\n alignItems=\"center\"\r\n justifyContent={\"space-between\"}\r\n gap={0.5}\r\n mb={isValue ? .5 : 0}\r\n >\r\n <Text>{option.label}</Text>\r\n <Stack\r\n direction=\"row\"\r\n gap={0.5}\r\n >\r\n <IconButton\r\n size=\"small\"\r\n variant=\"soft\"\r\n color={\"default\"}\r\n onClick={() => {\r\n onChange('');\r\n }}\r\n >\r\n <Add />\r\n </IconButton>\r\n {\r\n isValue && <IconButton\r\n size=\"small\"\r\n variant=\"soft\"\r\n color={\"danger\"}\r\n onClick={() => {\r\n onChange(null);\r\n }}\r\n >\r\n <ClearAll />\r\n </IconButton>\r\n }\r\n </Stack>\r\n </Stack>\r\n <Stack\r\n direction=\"row\"\r\n gap={0.5}\r\n flexWrap=\"wrap\"\r\n >\r\n {\r\n isValue && <Input\r\n variant={\"outline\"}\r\n value={value.toString()}\r\n onChange={(e: any) => {\r\n onChange(e.target.value);\r\n }}\r\n fullWidth\r\n />\r\n }\r\n </Stack>\r\n </Stack>\r\n )\r\n}\r\n\r\nexport default TextFilter"],"names":[],"mappings":";;;;;;;;;AAgBA;;AAIG;;;;;AAqDkB;AACH;AAOlB;;"}
|
package/Datatable/FilterBox.js
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var index$6 = require('../ViewBox/index.js');
|
|
17
|
-
var index$7 = require('../DataFilter/index.js');
|
|
2
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import Stack from '../Stack/index.js';
|
|
4
|
+
import Tabs from '../Tabs/index.js';
|
|
5
|
+
import Tab from '../Tab/index.js';
|
|
6
|
+
import Input from '../Input/index.js';
|
|
7
|
+
import IconSearch from '@xanui/icons/Search';
|
|
8
|
+
import IconButton from '../IconButton/index.js';
|
|
9
|
+
import FilterListOutlined from '@xanui/icons/FilterListOutlined';
|
|
10
|
+
import Drawer from '../Drawer/index.js';
|
|
11
|
+
import Text from '../Text/index.js';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import CloseOutlined from '@xanui/icons/CloseOutlined';
|
|
14
|
+
import ViewBox from '../ViewBox/index.js';
|
|
15
|
+
import DataFilter from '../DataFilter/index.js';
|
|
18
16
|
|
|
19
17
|
const FilterBox = (props) => {
|
|
20
18
|
let { tabs, filters, hideSearch, slotProps, skeleton, state, update, } = props;
|
|
21
19
|
const [openFilter, setOpenFilter] = React.useState(false);
|
|
22
20
|
let checked = state.selectAll || !!state.selected.length;
|
|
23
21
|
if (checked)
|
|
24
|
-
return
|
|
25
|
-
return (
|
|
22
|
+
return jsx(Fragment, {});
|
|
23
|
+
return (jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", zIndex: 1, radius: 1, mb: 1, height: 50, width: "100%", children: [jsx(Stack, { gap: 2.4, flexRow: true, children: tabs && jsx(Tabs, { disabled: skeleton ? true : false, onChange: (value) => {
|
|
26
24
|
update({ tab: value });
|
|
27
|
-
}, value: state.tab, children: tabs.map(t =>
|
|
25
|
+
}, value: state.tab, children: tabs.map(t => jsx(Tab, { value: t.value || t.label.toLowerCase(), children: t.label }, t.label)) }) }), jsxs(Stack, { flexRow: true, gap: 2, className: 'datatable-header-right-area', alignItems: "center", children: [!hideSearch && jsx(Input, Object.assign({ disabled: skeleton ? true : false, endIcon: jsx(IconSearch, {}), placeholder: 'Search...' }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.search, { value: state.search, onChange: (e) => {
|
|
28
26
|
update({ search: e.target.value });
|
|
29
|
-
} })), filters &&
|
|
27
|
+
} })), filters && jsxs(Stack, { children: [jsx(IconButton, { color: "default", variant: "text", onClick: () => {
|
|
30
28
|
setOpenFilter(true);
|
|
31
|
-
}, children:
|
|
29
|
+
}, children: jsx(FilterListOutlined, {}) }), jsx(Drawer, { open: openFilter, onClickOutside: () => { }, placement: "right", children: jsx(ViewBox, { height: "100%", p: 1, startContent: jsxs(Stack, { mb: 2, px: 2, flexRow: true, justifyContent: "space-between", alignItems: "center", children: [jsx(Text, { fontWeight: 600, fontSize: "h6", children: "Filters" }), jsx(IconButton, { size: "small", color: "default", variant: "text", onClick: () => {
|
|
32
30
|
setOpenFilter(false);
|
|
33
|
-
}, children:
|
|
31
|
+
}, children: jsx(CloseOutlined, {}) })] }), children: jsx(Stack, { gap: 2, children: jsx(DataFilter, { options: filters, value: state.filters, onChange: (s) => {
|
|
34
32
|
update({ filters: s });
|
|
35
33
|
} }) }) }) })] })] })] }));
|
|
36
34
|
};
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
export { FilterBox as default };
|
|
39
37
|
//# sourceMappingURL=FilterBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBox.js","sources":["../../src/Datatable/FilterBox.tsx"],"sourcesContent":["\"use client\";\r\nimport Stack from '../Stack'\r\nimport Tabs from '../Tabs'\r\nimport Tab from '../Tab'\r\nimport Input from '../Input'\r\nimport IconSearch from '@xanui/icons/Search'\r\nimport { DatatablePropsWithState } from './types';\r\nimport IconButton from '../IconButton';\r\nimport FilterListOutlined from '@xanui/icons/FilterListOutlined';\r\nimport Drawer from '../Drawer';\r\nimport Text from '../Text';\r\nimport React from 'react';\r\nimport CloseOutlined from '@xanui/icons/CloseOutlined';\r\nimport ViewBox from '../ViewBox';\r\nimport DataFilter from '../DataFilter';\r\n\r\nconst FilterBox = (props: DatatablePropsWithState) => {\r\n let {\r\n tabs,\r\n filters,\r\n hideSearch,\r\n slotProps,\r\n skeleton,\r\n state,\r\n update,\r\n } = props\r\n const [openFilter, setOpenFilter] = React.useState(false)\r\n let checked = state.selectAll || !!state.selected.length\r\n\r\n if (checked) return <></>\r\n\r\n return (\r\n <Stack\r\n direction=\"row\"\r\n alignItems=\"center\"\r\n justifyContent=\"space-between\"\r\n zIndex={1}\r\n radius={1}\r\n mb={1}\r\n height={50}\r\n width=\"100%\"\r\n >\r\n <Stack gap={2.4} flexRow>\r\n {\r\n tabs && <Tabs\r\n disabled={skeleton ? true : false}\r\n onChange={(value: any) => {\r\n update({ tab: value })\r\n }}\r\n value={state.tab}\r\n >\r\n {\r\n tabs.map(t => <Tab key={t.label} value={t.value || t.label.toLowerCase()}>{t.label}</Tab>)\r\n }\r\n </Tabs>\r\n }\r\n </Stack>\r\n <Stack\r\n flexRow\r\n gap={2}\r\n className='datatable-header-right-area'\r\n alignItems={\"center\"}\r\n >\r\n {!hideSearch && <Input\r\n disabled={skeleton ? true : false}\r\n endIcon={<IconSearch />}\r\n placeholder='Search...'\r\n {...slotProps?.search}\r\n value={state.search}\r\n onChange={(e: any) => {\r\n update({ search: e.target.value })\r\n }}\r\n />}\r\n {\r\n filters && <Stack>\r\n <IconButton\r\n color=\"default\"\r\n variant={\"text\"}\r\n onClick={() => {\r\n setOpenFilter(true)\r\n }}\r\n >\r\n <FilterListOutlined />\r\n </IconButton>\r\n <Drawer\r\n open={openFilter}\r\n onClickOutside={() => { }}\r\n placement={\"right\"}\r\n >\r\n <ViewBox\r\n height=\"100%\"\r\n p={1}\r\n startContent={<Stack mb={2} px={2} flexRow justifyContent={\"space-between\"} alignItems=\"center\">\r\n <Text fontWeight={600} fontSize=\"h6\">Filters</Text>\r\n <IconButton\r\n size=\"small\"\r\n color=\"default\"\r\n variant=\"text\"\r\n onClick={() => {\r\n setOpenFilter(false)\r\n }}\r\n >\r\n <CloseOutlined />\r\n </IconButton>\r\n </Stack>}\r\n >\r\n <Stack\r\n gap={2}\r\n >\r\n <DataFilter\r\n options={filters}\r\n value={state.filters}\r\n onChange={(s) => {\r\n update({ filters: s })\r\n }}\r\n />\r\n </Stack>\r\n </ViewBox>\r\n </Drawer>\r\n </Stack>\r\n }\r\n </Stack>\r\n </Stack>\r\n )\r\n}\r\n\r\nexport default FilterBox"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilterBox.js","sources":["../../src/Datatable/FilterBox.tsx"],"sourcesContent":["\"use client\";\r\nimport Stack from '../Stack'\r\nimport Tabs from '../Tabs'\r\nimport Tab from '../Tab'\r\nimport Input from '../Input'\r\nimport IconSearch from '@xanui/icons/Search'\r\nimport { DatatablePropsWithState } from './types';\r\nimport IconButton from '../IconButton';\r\nimport FilterListOutlined from '@xanui/icons/FilterListOutlined';\r\nimport Drawer from '../Drawer';\r\nimport Text from '../Text';\r\nimport React from 'react';\r\nimport CloseOutlined from '@xanui/icons/CloseOutlined';\r\nimport ViewBox from '../ViewBox';\r\nimport DataFilter from '../DataFilter';\r\n\r\nconst FilterBox = (props: DatatablePropsWithState) => {\r\n let {\r\n tabs,\r\n filters,\r\n hideSearch,\r\n slotProps,\r\n skeleton,\r\n state,\r\n update,\r\n } = props\r\n const [openFilter, setOpenFilter] = React.useState(false)\r\n let checked = state.selectAll || !!state.selected.length\r\n\r\n if (checked) return <></>\r\n\r\n return (\r\n <Stack\r\n direction=\"row\"\r\n alignItems=\"center\"\r\n justifyContent=\"space-between\"\r\n zIndex={1}\r\n radius={1}\r\n mb={1}\r\n height={50}\r\n width=\"100%\"\r\n >\r\n <Stack gap={2.4} flexRow>\r\n {\r\n tabs && <Tabs\r\n disabled={skeleton ? true : false}\r\n onChange={(value: any) => {\r\n update({ tab: value })\r\n }}\r\n value={state.tab}\r\n >\r\n {\r\n tabs.map(t => <Tab key={t.label} value={t.value || t.label.toLowerCase()}>{t.label}</Tab>)\r\n }\r\n </Tabs>\r\n }\r\n </Stack>\r\n <Stack\r\n flexRow\r\n gap={2}\r\n className='datatable-header-right-area'\r\n alignItems={\"center\"}\r\n >\r\n {!hideSearch && <Input\r\n disabled={skeleton ? true : false}\r\n endIcon={<IconSearch />}\r\n placeholder='Search...'\r\n {...slotProps?.search}\r\n value={state.search}\r\n onChange={(e: any) => {\r\n update({ search: e.target.value })\r\n }}\r\n />}\r\n {\r\n filters && <Stack>\r\n <IconButton\r\n color=\"default\"\r\n variant={\"text\"}\r\n onClick={() => {\r\n setOpenFilter(true)\r\n }}\r\n >\r\n <FilterListOutlined />\r\n </IconButton>\r\n <Drawer\r\n open={openFilter}\r\n onClickOutside={() => { }}\r\n placement={\"right\"}\r\n >\r\n <ViewBox\r\n height=\"100%\"\r\n p={1}\r\n startContent={<Stack mb={2} px={2} flexRow justifyContent={\"space-between\"} alignItems=\"center\">\r\n <Text fontWeight={600} fontSize=\"h6\">Filters</Text>\r\n <IconButton\r\n size=\"small\"\r\n color=\"default\"\r\n variant=\"text\"\r\n onClick={() => {\r\n setOpenFilter(false)\r\n }}\r\n >\r\n <CloseOutlined />\r\n </IconButton>\r\n </Stack>}\r\n >\r\n <Stack\r\n gap={2}\r\n >\r\n <DataFilter\r\n options={filters}\r\n value={state.filters}\r\n onChange={(s) => {\r\n update({ filters: s })\r\n }}\r\n />\r\n </Stack>\r\n </ViewBox>\r\n </Drawer>\r\n </Stack>\r\n }\r\n </Stack>\r\n </Stack>\r\n )\r\n}\r\n\r\nexport default FilterBox"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAgBA;AACG;AASA;AACA;AAEA;AAAa;AAEb;AAgBkB;;;;;AAiCA;;AAoBS;AAaG;;AAWjC;;"}
|
package/Datatable/Row.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var ActionIcon = require('@xanui/icons/MoreVert');
|
|
14
|
-
var index$4 = require('../Menu/index.js');
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import TableRow from '../TableRow/index.js';
|
|
6
|
+
import TableCell from '../TableCell/index.js';
|
|
7
|
+
import Checkbox from '../Checkbox/index.js';
|
|
8
|
+
import IconButton from '../IconButton/index.js';
|
|
9
|
+
import List from '../List/index.js';
|
|
10
|
+
import ListItem from '../ListItem/index.js';
|
|
11
|
+
import ActionIcon from '@xanui/icons/MoreVert';
|
|
12
|
+
import Menu from '../Menu/index.js';
|
|
15
13
|
|
|
16
14
|
const Row = ({ rows, rawRow, row, rowAction, disableRow, hideCheckbox, columns, compact, state, update }) => {
|
|
17
15
|
var _a;
|
|
18
16
|
const selected = row.id ? state.selected.includes(row === null || row === void 0 ? void 0 : row.id) : false;
|
|
19
17
|
let selectedColor = selected ? "primary.soft" : "transparent";
|
|
20
|
-
const [target, setTarget] =
|
|
18
|
+
const [target, setTarget] = useState();
|
|
21
19
|
const isDisable = (disableRow ? disableRow(rawRow, state) : false) || false;
|
|
22
|
-
return (
|
|
20
|
+
return (jsxs(TableRow, { children: [!hideCheckbox && jsx(TableCell, { width: 40, bgcolor: selectedColor, children: !!row.id && jsx(Checkbox, { size: compact ? "small" : "medium", checked: selected, onChange: () => {
|
|
23
21
|
if (isDisable || !row.id)
|
|
24
22
|
return;
|
|
25
23
|
let ids = [...state.selected];
|
|
@@ -35,12 +33,12 @@ const Row = ({ rows, rawRow, row, rowAction, disableRow, hideCheckbox, columns,
|
|
|
35
33
|
selected: ids
|
|
36
34
|
});
|
|
37
35
|
} }) }), columns.map((_a, idx) => {
|
|
38
|
-
var { label, field, sortable } = _a, rest =
|
|
36
|
+
var { label, field, sortable } = _a, rest = __rest(_a, ["label", "field", "sortable"]);
|
|
39
37
|
field = field || label;
|
|
40
38
|
if (!row[field])
|
|
41
|
-
return
|
|
42
|
-
return (
|
|
43
|
-
}), !!(rows.length && rowAction && ((_a = rowAction(rows[0])) === null || _a === void 0 ? void 0 : _a.length)) &&
|
|
39
|
+
return jsx(TableCell, {}, idx);
|
|
40
|
+
return (jsx(TableCell, Object.assign({ textAlign: "left" }, rest, { bgcolor: selectedColor, children: row[field] }), idx));
|
|
41
|
+
}), !!(rows.length && rowAction && ((_a = rowAction(rows[0])) === null || _a === void 0 ? void 0 : _a.length)) && jsxs(TableCell, { width: 30, bgcolor: selectedColor, borderColor: "divider", children: [jsx(IconButton, { disabled: isDisable || selected, onClick: (e) => setTarget(e.currentTarget), variant: "text", color: "default", children: jsx(ActionIcon, {}) }), jsx(Menu, { target: target, placement: "bottom-right", onClickOutside: () => setTarget(null), children: jsx(List, { bgcolor: "background.primary", minWidth: 160, sx: {
|
|
44
42
|
'& > li': {
|
|
45
43
|
borderBottom: 1,
|
|
46
44
|
'&:last-child': {
|
|
@@ -48,12 +46,12 @@ const Row = ({ rows, rawRow, row, rowAction, disableRow, hideCheckbox, columns,
|
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
}, children: rowAction({ row, state }).map(({ label, icon, onClick }) => {
|
|
51
|
-
return (
|
|
49
|
+
return (jsx(ListItem, { startIcon: icon, onClick: (e) => {
|
|
52
50
|
onClick && onClick(e);
|
|
53
51
|
setTarget(null);
|
|
54
52
|
}, children: label }, label));
|
|
55
53
|
}) }) })] })] }));
|
|
56
54
|
};
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
export { Row as default };
|
|
59
57
|
//# sourceMappingURL=Row.js.map
|
package/Datatable/Row.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sources":["../../src/Datatable/Row.tsx"],"sourcesContent":["\"use client\";\r\nimport { useState } from 'react'\r\nimport TableRow from '../TableRow'\r\nimport TableCell from '../TableCell'\r\nimport Checkbox from '../Checkbox'\r\nimport IconButton from '../IconButton'\r\nimport List from '../List'\r\nimport ListItem from '../ListItem'\r\nimport ActionIcon from '@xanui/icons/MoreVert'\r\nimport Menu from '../Menu'\r\nimport { DataTableDefaultRow, DatatablePropsWithState } from './types';\r\n\r\n\r\ntype Props = DatatablePropsWithState & {\r\n rawRow: DataTableDefaultRow;\r\n row: DataTableDefaultRow;\r\n}\r\n\r\nconst Row = ({ rows, rawRow, row, rowAction, disableRow, hideCheckbox, columns, compact, state, update }: Props) => {\r\n const selected = row.id ? state.selected.includes(row?.id) : false\r\n let selectedColor = selected ? \"primary.soft\" : \"transparent\"\r\n const [target, setTarget] = useState<any>()\r\n const isDisable = (disableRow ? disableRow(rawRow, state) : false) || false\r\n\r\n return (\r\n <TableRow >\r\n {!hideCheckbox && <TableCell width={40} bgcolor={selectedColor}>\r\n {\r\n !!row.id && <Checkbox\r\n size={compact ? \"small\" : \"medium\"}\r\n checked={selected}\r\n onChange={() => {\r\n if (isDisable || !row.id) return\r\n let ids = [...state.selected]\r\n ids.includes(row.id) ? ids.splice(ids.indexOf(row.id), 1) : ids.push(row.id)\r\n let selectedLength = 0\r\n rows.forEach(r => {\r\n const isDisable = (disableRow ? disableRow(r, state) : false) || false\r\n if (!isDisable) selectedLength++\r\n })\r\n\r\n update({\r\n selectAll: selectedLength === ids.length,\r\n selected: ids\r\n })\r\n }}\r\n />\r\n }\r\n\r\n </TableCell>}\r\n {\r\n columns.map(({ label, field, sortable, ...rest }, idx) => {\r\n field = field || label\r\n if (!row[field]) return <TableCell key={idx}></TableCell>\r\n return (\r\n <TableCell\r\n key={idx}\r\n textAlign=\"left\"\r\n {...rest}\r\n bgcolor={selectedColor}\r\n >\r\n {row[field]}\r\n </TableCell>\r\n )\r\n })\r\n }\r\n {!!(rows.length && rowAction && rowAction((rows as any)[0])?.length) && <TableCell width={30} bgcolor={selectedColor} borderColor=\"divider\">\r\n <IconButton\r\n disabled={isDisable || selected}\r\n onClick={(e: any) => setTarget(e.currentTarget)}\r\n variant=\"text\"\r\n color=\"default\"\r\n >\r\n <ActionIcon />\r\n </IconButton>\r\n <Menu target={target} placement=\"bottom-right\" onClickOutside={() => setTarget(null)}>\r\n <List\r\n bgcolor=\"background.primary\"\r\n minWidth={160}\r\n sx={{\r\n '& > li': {\r\n borderBottom: 1,\r\n '&:last-child': {\r\n borderBottom: 0\r\n }\r\n }\r\n }}\r\n >\r\n {rowAction({ row, state }).map(({ label, icon, onClick }) => {\r\n return (\r\n <ListItem\r\n key={label}\r\n startIcon={icon}\r\n onClick={(e: any) => {\r\n onClick && onClick(e)\r\n setTarget(null)\r\n }}\r\n >{label}</ListItem>\r\n )\r\n })}\r\n </List>\r\n </Menu>\r\n </TableCell>\r\n }\r\n </TableRow>\r\n )\r\n}\r\n\r\nexport default Row"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Row.js","sources":["../../src/Datatable/Row.tsx"],"sourcesContent":["\"use client\";\r\nimport { useState } from 'react'\r\nimport TableRow from '../TableRow'\r\nimport TableCell from '../TableCell'\r\nimport Checkbox from '../Checkbox'\r\nimport IconButton from '../IconButton'\r\nimport List from '../List'\r\nimport ListItem from '../ListItem'\r\nimport ActionIcon from '@xanui/icons/MoreVert'\r\nimport Menu from '../Menu'\r\nimport { DataTableDefaultRow, DatatablePropsWithState } from './types';\r\n\r\n\r\ntype Props = DatatablePropsWithState & {\r\n rawRow: DataTableDefaultRow;\r\n row: DataTableDefaultRow;\r\n}\r\n\r\nconst Row = ({ rows, rawRow, row, rowAction, disableRow, hideCheckbox, columns, compact, state, update }: Props) => {\r\n const selected = row.id ? state.selected.includes(row?.id) : false\r\n let selectedColor = selected ? \"primary.soft\" : \"transparent\"\r\n const [target, setTarget] = useState<any>()\r\n const isDisable = (disableRow ? disableRow(rawRow, state) : false) || false\r\n\r\n return (\r\n <TableRow >\r\n {!hideCheckbox && <TableCell width={40} bgcolor={selectedColor}>\r\n {\r\n !!row.id && <Checkbox\r\n size={compact ? \"small\" : \"medium\"}\r\n checked={selected}\r\n onChange={() => {\r\n if (isDisable || !row.id) return\r\n let ids = [...state.selected]\r\n ids.includes(row.id) ? ids.splice(ids.indexOf(row.id), 1) : ids.push(row.id)\r\n let selectedLength = 0\r\n rows.forEach(r => {\r\n const isDisable = (disableRow ? disableRow(r, state) : false) || false\r\n if (!isDisable) selectedLength++\r\n })\r\n\r\n update({\r\n selectAll: selectedLength === ids.length,\r\n selected: ids\r\n })\r\n }}\r\n />\r\n }\r\n\r\n </TableCell>}\r\n {\r\n columns.map(({ label, field, sortable, ...rest }, idx) => {\r\n field = field || label\r\n if (!row[field]) return <TableCell key={idx}></TableCell>\r\n return (\r\n <TableCell\r\n key={idx}\r\n textAlign=\"left\"\r\n {...rest}\r\n bgcolor={selectedColor}\r\n >\r\n {row[field]}\r\n </TableCell>\r\n )\r\n })\r\n }\r\n {!!(rows.length && rowAction && rowAction((rows as any)[0])?.length) && <TableCell width={30} bgcolor={selectedColor} borderColor=\"divider\">\r\n <IconButton\r\n disabled={isDisable || selected}\r\n onClick={(e: any) => setTarget(e.currentTarget)}\r\n variant=\"text\"\r\n color=\"default\"\r\n >\r\n <ActionIcon />\r\n </IconButton>\r\n <Menu target={target} placement=\"bottom-right\" onClickOutside={() => setTarget(null)}>\r\n <List\r\n bgcolor=\"background.primary\"\r\n minWidth={160}\r\n sx={{\r\n '& > li': {\r\n borderBottom: 1,\r\n '&:last-child': {\r\n borderBottom: 0\r\n }\r\n }\r\n }}\r\n >\r\n {rowAction({ row, state }).map(({ label, icon, onClick }) => {\r\n return (\r\n <ListItem\r\n key={label}\r\n startIcon={icon}\r\n onClick={(e: any) => {\r\n onClick && onClick(e)\r\n setTarget(null)\r\n }}\r\n >{label}</ListItem>\r\n )\r\n })}\r\n </List>\r\n </Menu>\r\n </TableCell>\r\n }\r\n </TableRow>\r\n )\r\n}\r\n\r\nexport default Row"],"names":[],"mappings":";;;;;;;;;;;;;AAkBA;;;;;;;AAc4B;;;AAEA;;AAEA;;AAEI;AAAgB;AACpB;AAEA;AACI;AACA;AACH;AACL;;AAOJ;AACA;AAAiB;;;AA2BT;AACI;AACA;AACI;AACH;AACJ;;AAID;AAKY;;AAEJ;AAGZ;AAOxB;;"}
|
package/Datatable/SelectedBox.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var index = require('../Stack/index.js');
|
|
7
|
-
var index$1 = require('../Text/index.js');
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import IconButton from '../IconButton/index.js';
|
|
4
|
+
import Stack from '../Stack/index.js';
|
|
5
|
+
import Text from '../Text/index.js';
|
|
8
6
|
|
|
9
7
|
const SelectedBox = (props) => {
|
|
10
8
|
let { state, rowAction } = props;
|
|
11
9
|
let checked = state.selectAll || !!state.selected.length;
|
|
12
10
|
if (!checked)
|
|
13
|
-
return
|
|
14
|
-
return (
|
|
15
|
-
var { label, icon } = _a, bprops =
|
|
16
|
-
return (
|
|
11
|
+
return jsx(Fragment, {});
|
|
12
|
+
return (jsxs(Stack, { bgcolor: "background.secondary", direction: "row", alignItems: "center", justifyContent: "space-between", zIndex: 1, radius: 1, mb: 1, height: 50, width: "100%", px: 1.5, children: [jsxs(Text, { fontWeight: 600, children: ["Selected: ", state.selected.length] }), jsx(Stack, { flexRow: true, gap: 1, children: rowAction && rowAction({ row: null, state }).map((_a) => {
|
|
13
|
+
var { label, icon } = _a, bprops = __rest(_a, ["label", "icon"]);
|
|
14
|
+
return (jsx(IconButton, Object.assign({ variant: "soft", color: "brand" }, bprops, { children: icon }), label));
|
|
17
15
|
}) })] }));
|
|
18
16
|
};
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
export { SelectedBox as default };
|
|
21
19
|
//# sourceMappingURL=SelectedBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectedBox.js","sources":["../../src/Datatable/SelectedBox.tsx"],"sourcesContent":["import IconButton from '../IconButton'\r\nimport Stack from '../Stack'\r\nimport Text from '../Text'\r\nimport { DatatablePropsWithState } from './types'\r\n\r\nconst SelectedBox = (props: DatatablePropsWithState) => {\r\n let {\r\n state,\r\n rowAction\r\n } = props\r\n\r\n let checked = state.selectAll || !!state.selected.length\r\n if (!checked) return <></>\r\n\r\n return (\r\n <Stack\r\n bgcolor=\"background.secondary\"\r\n direction=\"row\"\r\n alignItems=\"center\"\r\n justifyContent=\"space-between\"\r\n zIndex={1}\r\n radius={1}\r\n mb={1}\r\n height={50}\r\n width=\"100%\"\r\n px={1.5}\r\n >\r\n <Text fontWeight={600}>Selected: {state.selected.length}</Text>\r\n <Stack\r\n flexRow\r\n gap={1}\r\n >\r\n {rowAction && rowAction({ row: null, state }).map(({ label, icon, ...bprops }) => {\r\n return (\r\n <IconButton\r\n key={label}\r\n variant=\"soft\"\r\n color=\"brand\"\r\n {...bprops}\r\n >\r\n {icon}\r\n </IconButton>\r\n )\r\n })}\r\n </Stack>\r\n </Stack>\r\n )\r\n}\r\n\r\nexport default SelectedBox"],"names":["_jsx","_jsxs"
|
|
1
|
+
{"version":3,"file":"SelectedBox.js","sources":["../../src/Datatable/SelectedBox.tsx"],"sourcesContent":["import IconButton from '../IconButton'\r\nimport Stack from '../Stack'\r\nimport Text from '../Text'\r\nimport { DatatablePropsWithState } from './types'\r\n\r\nconst SelectedBox = (props: DatatablePropsWithState) => {\r\n let {\r\n state,\r\n rowAction\r\n } = props\r\n\r\n let checked = state.selectAll || !!state.selected.length\r\n if (!checked) return <></>\r\n\r\n return (\r\n <Stack\r\n bgcolor=\"background.secondary\"\r\n direction=\"row\"\r\n alignItems=\"center\"\r\n justifyContent=\"space-between\"\r\n zIndex={1}\r\n radius={1}\r\n mb={1}\r\n height={50}\r\n width=\"100%\"\r\n px={1.5}\r\n >\r\n <Text fontWeight={600}>Selected: {state.selected.length}</Text>\r\n <Stack\r\n flexRow\r\n gap={1}\r\n >\r\n {rowAction && rowAction({ row: null, state }).map(({ label, icon, ...bprops }) => {\r\n return (\r\n <IconButton\r\n key={label}\r\n variant=\"soft\"\r\n color=\"brand\"\r\n {...bprops}\r\n >\r\n {icon}\r\n </IconButton>\r\n )\r\n })}\r\n </Stack>\r\n </Stack>\r\n )\r\n}\r\n\r\nexport default SelectedBox"],"names":["_jsx","_jsxs"],"mappings":";;;;;;AAKA,MAAM,WAAW,GAAG,CAAC,KAA8B,KAAI;AACpD,IAAA,IAAI,EACD,KAAK,EACL,SAAS,EACX,GAAG,KAAK;AAET,IAAA,IAAI,OAAO,GAAG,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM;AACxD,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAOA,iBAAK;AAE1B,IAAA,QACGC,IAAA,CAAC,KAAK,IACH,OAAO,EAAC,sBAAsB,EAC9B,SAAS,EAAC,KAAK,EACf,UAAU,EAAC,QAAQ,EACnB,cAAc,EAAC,eAAe,EAC9B,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,CAAC,EACT,EAAE,EAAE,CAAC,EACL,MAAM,EAAE,EAAE,EACV,KAAK,EAAC,MAAM,EACZ,EAAE,EAAE,GAAG,EAAA,QAAA,EAAA,CAEPA,KAAC,IAAI,EAAA,EAAC,UAAU,EAAE,GAAG,2BAAa,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAA,EAAA,CAAQ,EAC/DD,IAAC,KAAK,EAAA,EACH,OAAO,EAAA,IAAA,EACP,GAAG,EAAE,CAAC,YAEL,SAAS,IAAI,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAA0B,KAAI;wBAA9B,EAAE,KAAK,EAAE,IAAI,EAAA,GAAA,EAAa,EAAR,MAAM,GAAA,MAAA,CAAA,EAAA,EAAxB,iBAA0B,CAAF;AACxE,oBAAA,QACGA,GAAA,CAAC,UAAU,kBAER,OAAO,EAAC,MAAM,EACd,KAAK,EAAC,OAAO,EAAA,EACT,MAAM,EAAA,EAAA,QAAA,EAET,IAAI,KALA,KAAK,CAMA;AAEnB,gBAAA,CAAC,CAAC,EAAA,CACG,CAAA,EAAA,CACH;AAEd;;;;"}
|
package/Datatable/Table.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var index$1 = require('../TableBody/index.js');
|
|
8
|
-
var Row = require('./Row.js');
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import TableHeadRender from './TableHead.js';
|
|
4
|
+
import Table from '../Table/index.js';
|
|
5
|
+
import TableBody from '../TableBody/index.js';
|
|
6
|
+
import Row from './Row.js';
|
|
9
7
|
|
|
10
8
|
const TableArea = (props) => {
|
|
11
9
|
let { rows, compact, renderRow, state, update, slotProps } = props;
|
|
12
|
-
return (
|
|
10
|
+
return (jsxs(Table, Object.assign({ width: "100%", size: compact ? "small" : "medium", border: "1px solid", borderColor: "divider" }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.table, { children: [jsx(TableHeadRender, Object.assign({}, props, { update: update, state: state })), jsx(TableBody, { sx: {
|
|
13
11
|
'& tr:last-child td': {
|
|
14
12
|
borderBottom: 0
|
|
15
13
|
}
|
|
16
14
|
}, children: rows === null || rows === void 0 ? void 0 : rows.map((row, idx) => {
|
|
17
15
|
let _row = renderRow ? renderRow(Object.assign({}, row), state) : row;
|
|
18
|
-
return
|
|
16
|
+
return jsx(Row, Object.assign({ rawRow: row, row: _row }, props, { update: update, state: state }), `dt-row-${row.id}-${idx}`);
|
|
19
17
|
}) })] })));
|
|
20
18
|
};
|
|
21
19
|
|
|
22
|
-
|
|
20
|
+
export { TableArea as default };
|
|
23
21
|
//# sourceMappingURL=Table.js.map
|
package/Datatable/Table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sources":["../../src/Datatable/Table.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport TableHead from './TableHead'\r\nimport Table from '../Table'\r\nimport TableBody from '../TableBody'\r\nimport Row from './Row'\r\nimport { DatatablePropsWithState } from './types';\r\n\r\nconst TableArea = (props: DatatablePropsWithState) => {\r\n let {\r\n rows,\r\n compact,\r\n renderRow,\r\n state,\r\n update,\r\n slotProps\r\n } = props\r\n\r\n return (\r\n <Table width=\"100%\" size={compact ? \"small\" : \"medium\"} border=\"1px solid\" borderColor=\"divider\" {...slotProps?.table}>\r\n <TableHead {...props} update={update} state={state} />\r\n <TableBody\r\n sx={{\r\n '& tr:last-child td': {\r\n borderBottom: 0\r\n }\r\n }}\r\n >\r\n {\r\n rows?.map((row: any, idx) => {\r\n let _row = renderRow ? renderRow({ ...row }, state) : row\r\n return <Row\r\n key={`dt-row-${row.id}-${idx}`}\r\n rawRow={row}\r\n row={_row}\r\n {...props}\r\n update={update}\r\n state={state}\r\n />\r\n })\r\n }\r\n </TableBody>\r\n </Table>\r\n )\r\n}\r\n\r\nexport default TableArea"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../../src/Datatable/Table.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport TableHead from './TableHead'\r\nimport Table from '../Table'\r\nimport TableBody from '../TableBody'\r\nimport Row from './Row'\r\nimport { DatatablePropsWithState } from './types';\r\n\r\nconst TableArea = (props: DatatablePropsWithState) => {\r\n let {\r\n rows,\r\n compact,\r\n renderRow,\r\n state,\r\n update,\r\n slotProps\r\n } = props\r\n\r\n return (\r\n <Table width=\"100%\" size={compact ? \"small\" : \"medium\"} border=\"1px solid\" borderColor=\"divider\" {...slotProps?.table}>\r\n <TableHead {...props} update={update} state={state} />\r\n <TableBody\r\n sx={{\r\n '& tr:last-child td': {\r\n borderBottom: 0\r\n }\r\n }}\r\n >\r\n {\r\n rows?.map((row: any, idx) => {\r\n let _row = renderRow ? renderRow({ ...row }, state) : row\r\n return <Row\r\n key={`dt-row-${row.id}-${idx}`}\r\n rawRow={row}\r\n row={_row}\r\n {...props}\r\n update={update}\r\n state={state}\r\n />\r\n })\r\n }\r\n </TableBody>\r\n </Table>\r\n )\r\n}\r\n\r\nexport default TableArea"],"names":[],"mappings":";;;;;;;AAQA;AACG;;AAcY;AACG;AACF;AACH;AAIK;AACA;AAQH;AAKf;;"}
|
package/Datatable/TableHead.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var ArrowDropUp = require('@xanui/icons/ArrowDropUp');
|
|
14
|
-
var index$5 = require('../Text/index.js');
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import TableHead from '../TableHead/index.js';
|
|
5
|
+
import TableRow from '../TableRow/index.js';
|
|
6
|
+
import TableCell from '../TableCell/index.js';
|
|
7
|
+
import Checkbox from '../Checkbox/index.js';
|
|
8
|
+
import IndeterminateCheckBoxIcon from '@xanui/icons/IndeterminateCheckBox';
|
|
9
|
+
import Stack from '../Stack/index.js';
|
|
10
|
+
import ArrowDropDown from '@xanui/icons/ArrowDropDown';
|
|
11
|
+
import ArrowDropUp from '@xanui/icons/ArrowDropUp';
|
|
12
|
+
import Text from '../Text/index.js';
|
|
15
13
|
|
|
16
14
|
const TableHeadRender = ({ columns, rows, disableRow, rowAction, hideCheckbox, compact, skeleton, state, update }) => {
|
|
17
15
|
var _a;
|
|
18
16
|
if (!columns.length)
|
|
19
|
-
return
|
|
17
|
+
return jsx(Fragment, {});
|
|
20
18
|
let checked = state.selectAll || !!state.selected.length;
|
|
21
19
|
const sortables = state.sortable || {};
|
|
22
|
-
return (
|
|
20
|
+
return (jsx(TableHead, { position: "relative", children: jsxs(TableRow, { bgcolor: "default", borderBottom: 1, children: [!hideCheckbox && jsx(TableCell, { th: true, width: 40, children: jsx(Checkbox, { size: compact ? "small" : "medium", checkIcon: state.selected.length && !state.selectAll ? jsx(IndeterminateCheckBoxIcon, {}) : undefined, checked: checked, onChange: () => {
|
|
23
21
|
let ids = [];
|
|
24
22
|
let undefinedCount = 0;
|
|
25
23
|
for (let i = 0; i < rows.length; i++) {
|
|
@@ -45,17 +43,17 @@ const TableHeadRender = ({ columns, rows, disableRow, rowAction, hideCheckbox, c
|
|
|
45
43
|
});
|
|
46
44
|
}
|
|
47
45
|
} }) }), columns.map((_a, idx) => {
|
|
48
|
-
var { label, field: _f, sortable } = _a, rest =
|
|
49
|
-
return
|
|
46
|
+
var { label, field: _f, sortable } = _a, rest = __rest(_a, ["label", "field", "sortable"]);
|
|
47
|
+
return jsx(TableCell, Object.assign({ th: true, textAlign: "left" }, rest, { children: jsxs(Stack, { disabled: skeleton ? true : false, flexRow: true, alignItems: "center", cursor: sortable ? "pointer" : "default", userSelect: "none", onClick: () => {
|
|
50
48
|
if (sortable) {
|
|
51
49
|
let newSort = sortables[_f] === 'asc' ? 'desc' : 'asc';
|
|
52
50
|
update({
|
|
53
51
|
sortable: Object.assign(Object.assign({}, sortables), { [_f]: newSort })
|
|
54
52
|
});
|
|
55
53
|
}
|
|
56
|
-
}, children: [
|
|
57
|
-
}), !!(rows.length && rowAction && ((_a = rowAction(rows[0])) === null || _a === void 0 ? void 0 : _a.length)) &&
|
|
54
|
+
}, children: [jsx(Text, { color: "text.secondary", children: label }), sortable && jsx(Fragment, { children: sortables[_f] === 'asc' ? jsx(ArrowDropDown, {}) : jsx(ArrowDropUp, {}) })] }) }), idx);
|
|
55
|
+
}), !!(rows.length && rowAction && ((_a = rowAction(rows[0])) === null || _a === void 0 ? void 0 : _a.length)) && jsx(TableCell, { th: true, width: 30 })] }) }));
|
|
58
56
|
};
|
|
59
57
|
|
|
60
|
-
|
|
58
|
+
export { TableHeadRender as default };
|
|
61
59
|
//# sourceMappingURL=TableHead.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHead.js","sources":["../../src/Datatable/TableHead.tsx"],"sourcesContent":["\"use client\";\r\nimport TableHead from '../TableHead'\r\nimport TableRow from '../TableRow'\r\nimport TableCell from '../TableCell'\r\nimport Checkbox from '../Checkbox'\r\nimport IntermidiatIcon from '@xanui/icons/IndeterminateCheckBox'\r\nimport { DatatablePropsWithState } from './types';\r\nimport Stack from '../Stack';\r\nimport ArrowDropDown from '@xanui/icons/ArrowDropDown';\r\nimport ArrowDropUp from '@xanui/icons/ArrowDropUp';\r\nimport Text from '../Text';\r\n\r\n\r\nconst TableHeadRender = ({ columns, rows, disableRow, rowAction, hideCheckbox, compact, skeleton, state, update }: DatatablePropsWithState) => {\r\n if (!columns.length) return <></>\r\n let checked = state.selectAll || !!state.selected.length\r\n const sortables = state.sortable || {}\r\n\r\n return (\r\n <TableHead position=\"relative\">\r\n <TableRow bgcolor=\"default\" borderBottom={1} >\r\n {!hideCheckbox && <TableCell th width={40}>\r\n <Checkbox\r\n size={compact ? \"small\" : \"medium\"}\r\n checkIcon={state.selected.length && !state.selectAll ? <IntermidiatIcon /> : undefined}\r\n checked={checked}\r\n onChange={() => {\r\n let ids: any = []\r\n let undefinedCount = 0\r\n for (let i = 0; i < rows.length; i++) {\r\n const row = rows[i]\r\n const isDisable = (disableRow ? disableRow(row, state) : false) || false\r\n if (!isDisable && row.id) {\r\n ids.push(row.id)\r\n } else {\r\n undefinedCount += 1\r\n }\r\n }\r\n\r\n if (undefinedCount) {\r\n update({\r\n selected: state.selected.length ? [] : ids,\r\n selectAll: !state.selected.length\r\n })\r\n } else {\r\n update({\r\n selected: state.selectAll ? [] : ids,\r\n selectAll: !state.selectAll\r\n })\r\n }\r\n }}\r\n />\r\n </TableCell>}\r\n {\r\n columns.map(({ label, field: _f, sortable, ...rest }, idx) => <TableCell\r\n key={idx}\r\n th\r\n textAlign=\"left\"\r\n {...rest}\r\n >\r\n <Stack\r\n disabled={skeleton ? true : false}\r\n flexRow\r\n alignItems=\"center\"\r\n cursor={sortable ? \"pointer\" : \"default\"}\r\n userSelect={\"none\"}\r\n onClick={() => {\r\n\r\n if (sortable) {\r\n let newSort: any = sortables[_f as any] === 'asc' ? 'desc' : 'asc'\r\n update({\r\n sortable: {\r\n ...sortables,\r\n [_f as any]: newSort\r\n }\r\n })\r\n }\r\n }}\r\n >\r\n <Text color=\"text.secondary\">{label}</Text>\r\n {sortable && <>\r\n {\r\n sortables[_f as any] === 'asc' ? <ArrowDropDown /> : <ArrowDropUp />\r\n }\r\n </>}\r\n </Stack>\r\n </TableCell>)\r\n }\r\n {\r\n !!(rows.length && rowAction && rowAction((rows as any)[0])?.length) && <TableCell th width={30} />\r\n }\r\n </TableRow>\r\n </TableHead>\r\n )\r\n}\r\n\r\nexport default TableHeadRender\r\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableHead.js","sources":["../../src/Datatable/TableHead.tsx"],"sourcesContent":["\"use client\";\r\nimport TableHead from '../TableHead'\r\nimport TableRow from '../TableRow'\r\nimport TableCell from '../TableCell'\r\nimport Checkbox from '../Checkbox'\r\nimport IntermidiatIcon from '@xanui/icons/IndeterminateCheckBox'\r\nimport { DatatablePropsWithState } from './types';\r\nimport Stack from '../Stack';\r\nimport ArrowDropDown from '@xanui/icons/ArrowDropDown';\r\nimport ArrowDropUp from '@xanui/icons/ArrowDropUp';\r\nimport Text from '../Text';\r\n\r\n\r\nconst TableHeadRender = ({ columns, rows, disableRow, rowAction, hideCheckbox, compact, skeleton, state, update }: DatatablePropsWithState) => {\r\n if (!columns.length) return <></>\r\n let checked = state.selectAll || !!state.selected.length\r\n const sortables = state.sortable || {}\r\n\r\n return (\r\n <TableHead position=\"relative\">\r\n <TableRow bgcolor=\"default\" borderBottom={1} >\r\n {!hideCheckbox && <TableCell th width={40}>\r\n <Checkbox\r\n size={compact ? \"small\" : \"medium\"}\r\n checkIcon={state.selected.length && !state.selectAll ? <IntermidiatIcon /> : undefined}\r\n checked={checked}\r\n onChange={() => {\r\n let ids: any = []\r\n let undefinedCount = 0\r\n for (let i = 0; i < rows.length; i++) {\r\n const row = rows[i]\r\n const isDisable = (disableRow ? disableRow(row, state) : false) || false\r\n if (!isDisable && row.id) {\r\n ids.push(row.id)\r\n } else {\r\n undefinedCount += 1\r\n }\r\n }\r\n\r\n if (undefinedCount) {\r\n update({\r\n selected: state.selected.length ? [] : ids,\r\n selectAll: !state.selected.length\r\n })\r\n } else {\r\n update({\r\n selected: state.selectAll ? [] : ids,\r\n selectAll: !state.selectAll\r\n })\r\n }\r\n }}\r\n />\r\n </TableCell>}\r\n {\r\n columns.map(({ label, field: _f, sortable, ...rest }, idx) => <TableCell\r\n key={idx}\r\n th\r\n textAlign=\"left\"\r\n {...rest}\r\n >\r\n <Stack\r\n disabled={skeleton ? true : false}\r\n flexRow\r\n alignItems=\"center\"\r\n cursor={sortable ? \"pointer\" : \"default\"}\r\n userSelect={\"none\"}\r\n onClick={() => {\r\n\r\n if (sortable) {\r\n let newSort: any = sortables[_f as any] === 'asc' ? 'desc' : 'asc'\r\n update({\r\n sortable: {\r\n ...sortables,\r\n [_f as any]: newSort\r\n }\r\n })\r\n }\r\n }}\r\n >\r\n <Text color=\"text.secondary\">{label}</Text>\r\n {sortable && <>\r\n {\r\n sortables[_f as any] === 'asc' ? <ArrowDropDown /> : <ArrowDropUp />\r\n }\r\n </>}\r\n </Stack>\r\n </TableCell>)\r\n }\r\n {\r\n !!(rows.length && rowAction && rowAction((rows as any)[0])?.length) && <TableCell th width={30} />\r\n }\r\n </TableRow>\r\n </TableHead>\r\n )\r\n}\r\n\r\nexport default TableHeadRender\r\n"],"names":[],"mappings":";;;;;;;;;;;;;AAaA;;;AACyB;AACrB;AACA;AAEA;;;AAWwB;AACI;;AAEA;AACI;;;;;;;AAOJ;AACI;AACA;AACH;;;AAED;;AAEI;AACH;;AAET;AAIS;;;AAeG;AACA;;AAKC;;AAET;AASI;AAQhC;;"}
|
package/Datatable/index.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var index$2 = require('../Stack/index.js');
|
|
14
|
-
var index = require('../Skeleton/index.js');
|
|
2
|
+
import { __rest } from 'tslib';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import React, { useMemo, useState, useEffect } from 'react';
|
|
5
|
+
import ViewBox from '../ViewBox/index.js';
|
|
6
|
+
import { useInterface, Tag } from '@xanui/core';
|
|
7
|
+
import SelectedBox from './SelectedBox.js';
|
|
8
|
+
import TableArea from './Table.js';
|
|
9
|
+
import FilterBox from './FilterBox.js';
|
|
10
|
+
import TablePagination from '../TablePagination/index.js';
|
|
11
|
+
import Stack from '../Stack/index.js';
|
|
12
|
+
import Skeleton from '../Skeleton/index.js';
|
|
15
13
|
|
|
16
14
|
const DataTable = React.forwardRef((props, ref) => {
|
|
17
|
-
let [p] =
|
|
18
|
-
let _props =
|
|
15
|
+
let [p] = useInterface("Datatable", props, {});
|
|
16
|
+
let _props = useMemo(() => {
|
|
19
17
|
let np = Object.assign({}, p);
|
|
20
18
|
if (typeof np.skeleton === 'number' || np.skeleton === true) {
|
|
21
19
|
const limit = np.perpages && np.perpages.length > 0 ? np.perpages[0] : 10;
|
|
@@ -39,7 +37,7 @@ const DataTable = React.forwardRef((props, ref) => {
|
|
|
39
37
|
}
|
|
40
38
|
np.renderRow = (r) => {
|
|
41
39
|
for (let col of columns) {
|
|
42
|
-
r[col.field] =
|
|
40
|
+
r[col.field] = jsx(Skeleton, { animation: "wave", height: 16, radius: .5, width: "100%" });
|
|
43
41
|
}
|
|
44
42
|
return r;
|
|
45
43
|
};
|
|
@@ -50,8 +48,8 @@ const DataTable = React.forwardRef((props, ref) => {
|
|
|
50
48
|
}, [p.skeleton, props.columns, props.rowAction, p.hideCheckbox, p.rows]);
|
|
51
49
|
let { rows, tabs, pagination: { perpages = [30, 50, 100], total = 0 } = {}, defaultState = {}, onStateChange, fixedHeader, hidePagination, slotProps,
|
|
52
50
|
// skip props for ViewBox
|
|
53
|
-
skeleton, rowAction, disableRow, renderRow, filters, hideCheckbox, hideSearch, columns, compact } = _props, viewBoxProps =
|
|
54
|
-
const [state, setState] =
|
|
51
|
+
skeleton, rowAction, disableRow, renderRow, filters, hideCheckbox, hideSearch, columns, compact } = _props, viewBoxProps = __rest(_props, ["rows", "tabs", "pagination", "defaultState", "onStateChange", "fixedHeader", "hidePagination", "slotProps", "skeleton", "rowAction", "disableRow", "renderRow", "filters", "hideCheckbox", "hideSearch", "columns", "compact"]);
|
|
52
|
+
const [state, setState] = useState({
|
|
55
53
|
selected: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.selected) || [],
|
|
56
54
|
selectAll: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.selectAll) || false,
|
|
57
55
|
pagination: {
|
|
@@ -66,21 +64,21 @@ const DataTable = React.forwardRef((props, ref) => {
|
|
|
66
64
|
filters: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.filter) || {}
|
|
67
65
|
});
|
|
68
66
|
const update = (s) => setState(o => (Object.assign(Object.assign({}, o), s)));
|
|
69
|
-
|
|
67
|
+
useEffect(() => {
|
|
70
68
|
if (onStateChange) {
|
|
71
69
|
onStateChange(state);
|
|
72
70
|
}
|
|
73
71
|
}, [state]);
|
|
74
|
-
return (
|
|
72
|
+
return (jsxs(ViewBox, Object.assign({ height: "100%" }, viewBoxProps, { baseClass: 'datatable', ref: ref, sx: Object.assign(Object.assign({}, viewBoxProps === null || viewBoxProps === void 0 ? void 0 : viewBoxProps.sx), { '& thead': fixedHeader ? {
|
|
75
73
|
position: "sticky",
|
|
76
74
|
top: 0,
|
|
77
75
|
bgcolor: "background.primary",
|
|
78
76
|
zIndex: 1
|
|
79
|
-
} : {} }), startContent: (
|
|
77
|
+
} : {} }), startContent: (jsxs(Tag, { baseClass: 'datatable-header', sxr: {
|
|
80
78
|
display: "flex",
|
|
81
79
|
flexDirection: "row",
|
|
82
80
|
justifyContent: "space-between"
|
|
83
|
-
}, children: [
|
|
81
|
+
}, children: [jsx(SelectedBox, Object.assign({}, _props, { update: update, state: state })), jsx(FilterBox, Object.assign({}, _props, { update: update, state: state }))] })), children: [jsx(TableArea, Object.assign({}, _props, { update: update, state: state })), jsx(Stack, { p: 1, alignItems: "flex-end", children: !hidePagination && jsx(TablePagination, Object.assign({ disabled: _props.skeleton ? true : false }, slotProps === null || slotProps === void 0 ? void 0 : slotProps.pagination, { total: total || rows.length, page: state.pagination.page, perpage: state.pagination.perpage, perpages: perpages, slotProps: {
|
|
84
82
|
select: {
|
|
85
83
|
size: "small",
|
|
86
84
|
}
|
|
@@ -89,5 +87,5 @@ const DataTable = React.forwardRef((props, ref) => {
|
|
|
89
87
|
} })) })] })));
|
|
90
88
|
});
|
|
91
89
|
|
|
92
|
-
|
|
90
|
+
export { DataTable as default };
|
|
93
91
|
//# sourceMappingURL=index.js.map
|