@xanui/ui 1.1.16 → 1.1.18
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.map +1 -1
- package/Accordion/index.mjs.map +1 -1
- package/Alert/index.js.map +1 -1
- package/Alert/index.mjs.map +1 -1
- package/Avatar/index.js.map +1 -1
- package/Avatar/index.mjs.map +1 -1
- package/Badge/index.js.map +1 -1
- package/Badge/index.mjs.map +1 -1
- package/Box/index.js.map +1 -1
- package/Box/index.mjs.map +1 -1
- package/Button/index.js.map +1 -1
- package/Button/index.mjs.map +1 -1
- package/ButtonGroup/index.js.map +1 -1
- package/ButtonGroup/index.mjs.map +1 -1
- package/Calendar/index.js.map +1 -1
- package/Calendar/index.mjs.map +1 -1
- package/CalendarInput/index.js.map +1 -1
- package/CalendarInput/index.mjs.map +1 -1
- package/Checkbox/index.js.map +1 -1
- package/Checkbox/index.mjs.map +1 -1
- package/Chip/index.js.map +1 -1
- package/Chip/index.mjs.map +1 -1
- package/CircleProgress/index.js.map +1 -1
- package/CircleProgress/index.mjs.map +1 -1
- package/ClickOutside/index.js.map +1 -1
- package/ClickOutside/index.mjs.map +1 -1
- package/Collaps/index.js.map +1 -1
- package/Collaps/index.mjs.map +1 -1
- package/Container/index.js.map +1 -1
- package/Container/index.mjs.map +1 -1
- package/Datatable/FilterBox.js +5 -8
- package/Datatable/FilterBox.js.map +1 -1
- package/Datatable/FilterBox.mjs +5 -8
- package/Datatable/FilterBox.mjs.map +1 -1
- package/Datatable/Row.js +6 -7
- package/Datatable/Row.js.map +1 -1
- package/Datatable/Row.mjs +6 -7
- package/Datatable/Row.mjs.map +1 -1
- package/Datatable/SelectedBox.js +2 -3
- package/Datatable/SelectedBox.js.map +1 -1
- package/Datatable/SelectedBox.mjs +2 -3
- package/Datatable/SelectedBox.mjs.map +1 -1
- package/Datatable/Table.js.map +1 -1
- package/Datatable/Table.mjs.map +1 -1
- package/Datatable/TableHead.js +20 -10
- package/Datatable/TableHead.js.map +1 -1
- package/Datatable/TableHead.mjs +20 -10
- package/Datatable/TableHead.mjs.map +1 -1
- package/Datatable/index.d.ts +2 -67
- package/Datatable/index.js +18 -17
- package/Datatable/index.js.map +1 -1
- package/Datatable/index.mjs +19 -18
- package/Datatable/index.mjs.map +1 -1
- package/Datatable/types.d.ts +69 -0
- package/Divider/index.js.map +1 -1
- package/Divider/index.mjs.map +1 -1
- package/Drawer/index.js.map +1 -1
- package/Drawer/index.mjs.map +1 -1
- package/Form/index.js.map +1 -1
- package/Form/index.mjs.map +1 -1
- package/GridContainer/index.js.map +1 -1
- package/GridContainer/index.mjs.map +1 -1
- package/GridItem/index.js.map +1 -1
- package/GridItem/index.mjs.map +1 -1
- package/IconButton/index.js.map +1 -1
- package/IconButton/index.mjs.map +1 -1
- package/Image/index.js.map +1 -1
- package/Image/index.mjs.map +1 -1
- package/Input/index.js.map +1 -1
- package/Input/index.mjs.map +1 -1
- package/Label/index.js.map +1 -1
- package/Label/index.mjs.map +1 -1
- package/Layer/index.js.map +1 -1
- package/Layer/index.mjs.map +1 -1
- package/LineProgress/index.js.map +1 -1
- package/LineProgress/index.mjs.map +1 -1
- package/List/index.js.map +1 -1
- package/List/index.mjs.map +1 -1
- package/ListItem/index.js.map +1 -1
- package/ListItem/index.mjs.map +1 -1
- package/LoadingBox/index.js.map +1 -1
- package/LoadingBox/index.mjs.map +1 -1
- package/Menu/index.js.map +1 -1
- package/Menu/index.mjs.map +1 -1
- package/Modal/index.d.ts +1 -1
- package/Modal/index.js.map +1 -1
- package/Modal/index.mjs.map +1 -1
- package/NoSSR/index.js.map +1 -1
- package/NoSSR/index.mjs.map +1 -1
- package/Option/index.js.map +1 -1
- package/Option/index.mjs.map +1 -1
- package/Paper/index.js.map +1 -1
- package/Paper/index.mjs.map +1 -1
- package/Portal/index.js.map +1 -1
- package/Portal/index.mjs.map +1 -1
- package/Radio/index.js.map +1 -1
- package/Radio/index.mjs.map +1 -1
- package/Scrollbar/index.js.map +1 -1
- package/Scrollbar/index.mjs.map +1 -1
- package/Select/index.js.map +1 -1
- package/Select/index.mjs.map +1 -1
- package/Stack/index.js.map +1 -1
- package/Stack/index.mjs.map +1 -1
- package/Switch/index.js.map +1 -1
- package/Switch/index.mjs.map +1 -1
- package/Tab/index.js.map +1 -1
- package/Tab/index.mjs.map +1 -1
- package/Table/index.js.map +1 -1
- package/Table/index.mjs.map +1 -1
- package/TableBody/index.js.map +1 -1
- package/TableBody/index.mjs.map +1 -1
- package/TableCell/index.js.map +1 -1
- package/TableCell/index.mjs.map +1 -1
- package/TableFooter/index.js.map +1 -1
- package/TableFooter/index.mjs.map +1 -1
- package/TableHead/index.js.map +1 -1
- package/TableHead/index.mjs.map +1 -1
- package/TablePagination/index.d.ts +1 -0
- package/TablePagination/index.js +10 -14
- package/TablePagination/index.js.map +1 -1
- package/TablePagination/index.mjs +11 -15
- package/TablePagination/index.mjs.map +1 -1
- package/TableRow/index.js.map +1 -1
- package/TableRow/index.mjs.map +1 -1
- package/Tabs/index.js +1 -1
- package/Tabs/index.js.map +1 -1
- package/Tabs/index.mjs +1 -1
- package/Tabs/index.mjs.map +1 -1
- package/Text/index.js.map +1 -1
- package/Text/index.mjs.map +1 -1
- package/Toast/index.js.map +1 -1
- package/Toast/index.mjs.map +1 -1
- package/Tooltip/index.js.map +1 -1
- package/Tooltip/index.mjs.map +1 -1
- package/ViewBox/index.js.map +1 -1
- package/ViewBox/index.mjs.map +1 -1
- package/package.json +2 -2
- package/readme.md +104 -104
- package/useAlert/index.js.map +1 -1
- package/useAlert/index.mjs.map +1 -1
- package/useBlurCss/index.js.map +1 -1
- package/useBlurCss/index.mjs.map +1 -1
- package/useCorner/index.js.map +1 -1
- package/useCorner/index.mjs.map +1 -1
- package/useLayer/index.js.map +1 -1
- package/useLayer/index.mjs.map +1 -1
- package/useModal/index.js.map +1 -1
- package/useModal/index.mjs.map +1 -1
package/Datatable/Row.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sources":["../../src/Datatable/Row.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"Row.js","sources":["../../src/Datatable/Row.tsx"],"sourcesContent":["\"use client\";\nimport { useState } from 'react'\nimport TableRow from '../TableRow'\nimport TableCell from '../TableCell'\nimport Checkbox from '../Checkbox'\nimport IconButton from '../IconButton'\nimport List from '../List'\nimport ListItem from '../ListItem'\nimport ActionIcon from '@xanui/icons/MoreVert'\nimport Menu from '../Menu'\nimport { DataTableDefaultRow, DatatablePropsWithState } from './types';\n\n\ntype Props = DatatablePropsWithState & {\n rawRow: DataTableDefaultRow;\n row: DataTableDefaultRow;\n}\n\nconst Row = ({ rows, rawRow, row, rowAction, disableRow, hideCheckbox, columns, state, update }: Props) => {\n const selected = row.id ? state.selected.includes(row?.id) : false\n let selectedColor = selected ? \"primary.soft\" : \"transparent\"\n const [target, setTarget] = useState<any>()\n const isDisable = (disableRow ? disableRow(rawRow, state) : false) || false\n\n return (\n <TableRow disabled={isDisable}>\n {!hideCheckbox && <TableCell width={40} bgcolor={selectedColor}>\n {\n !!row.id && <Checkbox\n checked={selected}\n onChange={() => {\n if (isDisable || !row.id) return\n let ids = [...state.selected]\n ids.includes(row.id) ? ids.splice(ids.indexOf(row.id), 1) : ids.push(row.id)\n let selectedLength = 0\n rows.forEach(r => {\n const isDisable = (disableRow ? disableRow(r, state) : false) || false\n if (!isDisable) selectedLength++\n })\n\n update({\n selectAll: selectedLength === ids.length,\n selected: ids\n })\n }}\n />\n }\n\n </TableCell>}\n {\n columns.map(({ label, field, sortable, ...rest }, idx) => {\n field = field || label\n if (!row[field]) return <TableCell key={idx}></TableCell>\n return (\n <TableCell\n key={idx}\n textAlign=\"left\"\n {...rest}\n bgcolor={selectedColor}\n >\n {row[field]}\n </TableCell>\n )\n })\n }\n <TableCell width={30} bgcolor={selectedColor} borderColor=\"divider\">\n {rowAction && <>\n <IconButton\n disabled={isDisable || selected}\n onClick={(e: any) => setTarget(e.currentTarget)}\n variant=\"text\"\n color=\"default\"\n >\n <ActionIcon />\n </IconButton>\n <Menu target={target} placement=\"bottom-right\" onClickOutside={() => setTarget(null)}>\n <List\n bgcolor=\"background.primary\"\n minWidth={160}\n sx={{\n '& > li': {\n borderBottom: 1,\n '&:last-child': {\n borderBottom: 0\n }\n }\n }}\n >\n {rowAction({ row, state }).map(({ label, icon, onClick }) => {\n return (\n <ListItem\n key={label}\n startIcon={icon}\n onClick={(e: any) => {\n onClick && onClick(e)\n setTarget(null)\n }}\n >{label}</ListItem>\n )\n })}\n </List>\n </Menu>\n </>}\n </TableCell>\n </TableRow>\n )\n}\n\nexport default Row"],"names":[],"mappings":";;;;;;;;;;;;;;;AAkBA;;;;;AAMI;AAOwB;;;AAEA;;AAEA;;AAEI;AAAgB;AACpB;AAEA;AACI;AACA;AACH;AACL;;AAOJ;AACA;AAAiB;;AAWrB;AAiBgB;AACI;AACA;AACI;AACH;AACJ;;AAID;AAKY;;AAEJ;AAGZ;AAO5B;;"}
|
package/Datatable/Row.mjs
CHANGED
|
@@ -11,16 +11,15 @@ import ListItem from '../ListItem/index.mjs';
|
|
|
11
11
|
import ActionIcon from '@xanui/icons/MoreVert';
|
|
12
12
|
import Menu from '../Menu/index.mjs';
|
|
13
13
|
|
|
14
|
-
const Row = ({ rows, rawRow, row, rowAction, disableRow,
|
|
15
|
-
|
|
16
|
-
const selected = row.id ? state.selectedIds.includes(row === null || row === void 0 ? void 0 : row.id) : false;
|
|
14
|
+
const Row = ({ rows, rawRow, row, rowAction, disableRow, hideCheckbox, columns, state, update }) => {
|
|
15
|
+
const selected = row.id ? state.selected.includes(row === null || row === void 0 ? void 0 : row.id) : false;
|
|
17
16
|
let selectedColor = selected ? "primary.soft" : "transparent";
|
|
18
17
|
const [target, setTarget] = useState();
|
|
19
18
|
const isDisable = (disableRow ? disableRow(rawRow, state) : false) || false;
|
|
20
|
-
return (jsxs(TableRow, { disabled: isDisable, children: [!
|
|
19
|
+
return (jsxs(TableRow, { disabled: isDisable, children: [!hideCheckbox && jsx(TableCell, { width: 40, bgcolor: selectedColor, children: !!row.id && jsx(Checkbox, { checked: selected, onChange: () => {
|
|
21
20
|
if (isDisable || !row.id)
|
|
22
21
|
return;
|
|
23
|
-
let ids = [...
|
|
22
|
+
let ids = [...state.selected];
|
|
24
23
|
ids.includes(row.id) ? ids.splice(ids.indexOf(row.id), 1) : ids.push(row.id);
|
|
25
24
|
let selectedLength = 0;
|
|
26
25
|
rows.forEach(r => {
|
|
@@ -30,10 +29,10 @@ const Row = ({ rows, rawRow, row, rowAction, disableRow, disableSelect, columns,
|
|
|
30
29
|
});
|
|
31
30
|
update({
|
|
32
31
|
selectAll: selectedLength === ids.length,
|
|
33
|
-
|
|
32
|
+
selected: ids
|
|
34
33
|
});
|
|
35
34
|
} }) }), columns.map((_a, idx) => {
|
|
36
|
-
var { label, field } = _a, rest = __rest(_a, ["label", "field"]);
|
|
35
|
+
var { label, field, sortable } = _a, rest = __rest(_a, ["label", "field", "sortable"]);
|
|
37
36
|
field = field || label;
|
|
38
37
|
if (!row[field])
|
|
39
38
|
return jsx(TableCell, {}, idx);
|
package/Datatable/Row.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.mjs","sources":["../../src/Datatable/Row.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"Row.mjs","sources":["../../src/Datatable/Row.tsx"],"sourcesContent":["\"use client\";\nimport { useState } from 'react'\nimport TableRow from '../TableRow'\nimport TableCell from '../TableCell'\nimport Checkbox from '../Checkbox'\nimport IconButton from '../IconButton'\nimport List from '../List'\nimport ListItem from '../ListItem'\nimport ActionIcon from '@xanui/icons/MoreVert'\nimport Menu from '../Menu'\nimport { DataTableDefaultRow, DatatablePropsWithState } from './types';\n\n\ntype Props = DatatablePropsWithState & {\n rawRow: DataTableDefaultRow;\n row: DataTableDefaultRow;\n}\n\nconst Row = ({ rows, rawRow, row, rowAction, disableRow, hideCheckbox, columns, state, update }: Props) => {\n const selected = row.id ? state.selected.includes(row?.id) : false\n let selectedColor = selected ? \"primary.soft\" : \"transparent\"\n const [target, setTarget] = useState<any>()\n const isDisable = (disableRow ? disableRow(rawRow, state) : false) || false\n\n return (\n <TableRow disabled={isDisable}>\n {!hideCheckbox && <TableCell width={40} bgcolor={selectedColor}>\n {\n !!row.id && <Checkbox\n checked={selected}\n onChange={() => {\n if (isDisable || !row.id) return\n let ids = [...state.selected]\n ids.includes(row.id) ? ids.splice(ids.indexOf(row.id), 1) : ids.push(row.id)\n let selectedLength = 0\n rows.forEach(r => {\n const isDisable = (disableRow ? disableRow(r, state) : false) || false\n if (!isDisable) selectedLength++\n })\n\n update({\n selectAll: selectedLength === ids.length,\n selected: ids\n })\n }}\n />\n }\n\n </TableCell>}\n {\n columns.map(({ label, field, sortable, ...rest }, idx) => {\n field = field || label\n if (!row[field]) return <TableCell key={idx}></TableCell>\n return (\n <TableCell\n key={idx}\n textAlign=\"left\"\n {...rest}\n bgcolor={selectedColor}\n >\n {row[field]}\n </TableCell>\n )\n })\n }\n <TableCell width={30} bgcolor={selectedColor} borderColor=\"divider\">\n {rowAction && <>\n <IconButton\n disabled={isDisable || selected}\n onClick={(e: any) => setTarget(e.currentTarget)}\n variant=\"text\"\n color=\"default\"\n >\n <ActionIcon />\n </IconButton>\n <Menu target={target} placement=\"bottom-right\" onClickOutside={() => setTarget(null)}>\n <List\n bgcolor=\"background.primary\"\n minWidth={160}\n sx={{\n '& > li': {\n borderBottom: 1,\n '&:last-child': {\n borderBottom: 0\n }\n }\n }}\n >\n {rowAction({ row, state }).map(({ label, icon, onClick }) => {\n return (\n <ListItem\n key={label}\n startIcon={icon}\n onClick={(e: any) => {\n onClick && onClick(e)\n setTarget(null)\n }}\n >{label}</ListItem>\n )\n })}\n </List>\n </Menu>\n </>}\n </TableCell>\n </TableRow>\n )\n}\n\nexport default Row"],"names":[],"mappings":";;;;;;;;;;;;;AAkBA;;;;;AAMI;AAOwB;;;AAEA;;AAEA;;AAEI;AAAgB;AACpB;AAEA;AACI;AACA;AACH;AACL;;AAOJ;AACA;AAAiB;;AAWrB;AAiBgB;AACI;AACA;AACI;AACH;AACJ;;AAID;AAKY;;AAEJ;AAGZ;AAO5B;;"}
|
package/Datatable/SelectedBox.js
CHANGED
|
@@ -8,11 +8,10 @@ var index$1 = require('../Text/index.js');
|
|
|
8
8
|
|
|
9
9
|
const SelectedBox = (props) => {
|
|
10
10
|
let { state, rowAction } = props;
|
|
11
|
-
let
|
|
12
|
-
let checked = state.selectAll || !!selected.length;
|
|
11
|
+
let checked = state.selectAll || !!state.selected.length;
|
|
13
12
|
if (!checked)
|
|
14
13
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
15
|
-
return (jsxRuntime.jsxs(index, { bgcolor: "background.secondary", direction: "row", alignItems: "center", justifyContent: "space-between", zIndex: 1, radius: 1, mb: 1, height: 50, width: "100%", px: 1.5, children: [jsxRuntime.jsxs(index$1, { fontWeight: 600, children: ["Selected: ", selected.length] }), jsxRuntime.jsx(index, { flexRow: true, gap: 1, children: rowAction && rowAction({ row: null, state }).map((_a) => {
|
|
14
|
+
return (jsxRuntime.jsxs(index, { bgcolor: "background.secondary", direction: "row", alignItems: "center", justifyContent: "space-between", zIndex: 1, radius: 1, mb: 1, height: 50, width: "100%", px: 1.5, children: [jsxRuntime.jsxs(index$1, { fontWeight: 600, children: ["Selected: ", state.selected.length] }), jsxRuntime.jsx(index, { flexRow: true, gap: 1, children: rowAction && rowAction({ row: null, state }).map((_a) => {
|
|
16
15
|
var { label, icon } = _a, bprops = tslib.__rest(_a, ["label", "icon"]);
|
|
17
16
|
return (jsxRuntime.jsx(index$2, Object.assign({ variant: "soft", color: "brand" }, bprops, { children: icon }), label));
|
|
18
17
|
}) })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectedBox.js","sources":["../../src/Datatable/SelectedBox.tsx"],"sourcesContent":["import IconButton from '../IconButton'\
|
|
1
|
+
{"version":3,"file":"SelectedBox.js","sources":["../../src/Datatable/SelectedBox.tsx"],"sourcesContent":["import IconButton from '../IconButton'\nimport Stack from '../Stack'\nimport Text from '../Text'\nimport { DatatablePropsWithState } from './types'\n\nconst SelectedBox = (props: DatatablePropsWithState) => {\n let {\n state,\n rowAction\n } = props\n\n let checked = state.selectAll || !!state.selected.length\n if (!checked) return <></>\n\n return (\n <Stack\n bgcolor=\"background.secondary\"\n direction=\"row\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n zIndex={1}\n radius={1}\n mb={1}\n height={50}\n width=\"100%\"\n px={1.5}\n >\n <Text fontWeight={600}>Selected: {state.selected.length}</Text>\n <Stack\n flexRow\n gap={1}\n >\n {rowAction && rowAction({ row: null, state }).map(({ label, icon, ...bprops }) => {\n return (\n <IconButton\n key={label}\n variant=\"soft\"\n color=\"brand\"\n {...bprops}\n >\n {icon}\n </IconButton>\n )\n })}\n </Stack>\n </Stack>\n )\n}\n\nexport default SelectedBox"],"names":["_jsx","_jsxs","Stack","Text","__rest","IconButton"],"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,uCAAK;AAE1B,IAAA,QACGC,eAAA,CAACC,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,CAEPD,gBAACE,OAAI,EAAA,EAAC,UAAU,EAAE,GAAG,2BAAa,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAA,EAAA,CAAQ,EAC/DH,eAACE,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,GAAAE,YAAA,CAAA,EAAA,EAAxB,iBAA0B,CAAF;AACxE,oBAAA,QACGJ,cAAA,CAACK,OAAU,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;;;;"}
|
|
@@ -6,11 +6,10 @@ import Text from '../Text/index.mjs';
|
|
|
6
6
|
|
|
7
7
|
const SelectedBox = (props) => {
|
|
8
8
|
let { state, rowAction } = props;
|
|
9
|
-
let
|
|
10
|
-
let checked = state.selectAll || !!selected.length;
|
|
9
|
+
let checked = state.selectAll || !!state.selected.length;
|
|
11
10
|
if (!checked)
|
|
12
11
|
return jsx(Fragment, {});
|
|
13
|
-
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: ", selected.length] }), jsx(Stack, { flexRow: true, gap: 1, children: rowAction && rowAction({ row: null, state }).map((_a) => {
|
|
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) => {
|
|
14
13
|
var { label, icon } = _a, bprops = __rest(_a, ["label", "icon"]);
|
|
15
14
|
return (jsx(IconButton, Object.assign({ variant: "soft", color: "brand" }, bprops, { children: icon }), label));
|
|
16
15
|
}) })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectedBox.mjs","sources":["../../src/Datatable/SelectedBox.tsx"],"sourcesContent":["import IconButton from '../IconButton'\
|
|
1
|
+
{"version":3,"file":"SelectedBox.mjs","sources":["../../src/Datatable/SelectedBox.tsx"],"sourcesContent":["import IconButton from '../IconButton'\nimport Stack from '../Stack'\nimport Text from '../Text'\nimport { DatatablePropsWithState } from './types'\n\nconst SelectedBox = (props: DatatablePropsWithState) => {\n let {\n state,\n rowAction\n } = props\n\n let checked = state.selectAll || !!state.selected.length\n if (!checked) return <></>\n\n return (\n <Stack\n bgcolor=\"background.secondary\"\n direction=\"row\"\n alignItems=\"center\"\n justifyContent=\"space-between\"\n zIndex={1}\n radius={1}\n mb={1}\n height={50}\n width=\"100%\"\n px={1.5}\n >\n <Text fontWeight={600}>Selected: {state.selected.length}</Text>\n <Stack\n flexRow\n gap={1}\n >\n {rowAction && rowAction({ row: null, state }).map(({ label, icon, ...bprops }) => {\n return (\n <IconButton\n key={label}\n variant=\"soft\"\n color=\"brand\"\n {...bprops}\n >\n {icon}\n </IconButton>\n )\n })}\n </Stack>\n </Stack>\n )\n}\n\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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sources":["../../src/Datatable/Table.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../../src/Datatable/Table.tsx"],"sourcesContent":["\"use client\";\n\nimport TableHead from './TableHead'\nimport Table from '../Table'\nimport TableBody from '../TableBody'\nimport Row from './Row'\nimport { DatatablePropsWithState } from './types';\n\nconst TableArea = (props: DatatablePropsWithState) => {\n let {\n rows,\n renderRow,\n state,\n update,\n slotProps\n } = props\n\n return (\n <Table width=\"100%\" border=\"1px solid\" borderColor=\"divider\" {...slotProps?.table}>\n <TableHead {...props} update={update} state={state} />\n <TableBody\n sx={{\n '& tr:last-child td': {\n borderBottom: 0\n }\n }}\n >\n {\n rows?.map((row: any, idx) => {\n let _row = renderRow ? renderRow({ ...row }, state) : row\n return <Row\n key={row.id + idx}\n rawRow={row}\n row={_row}\n {...props}\n update={update}\n state={state}\n />\n })\n }\n </TableBody>\n </Table>\n )\n}\n\nexport default TableArea"],"names":[],"mappings":";;;;;;;;;AAQA;AACG;AAQA;AAKY;AACG;AACF;AACH;AAIK;;AASH;AAKf;;"}
|
package/Datatable/Table.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.mjs","sources":["../../src/Datatable/Table.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"Table.mjs","sources":["../../src/Datatable/Table.tsx"],"sourcesContent":["\"use client\";\n\nimport TableHead from './TableHead'\nimport Table from '../Table'\nimport TableBody from '../TableBody'\nimport Row from './Row'\nimport { DatatablePropsWithState } from './types';\n\nconst TableArea = (props: DatatablePropsWithState) => {\n let {\n rows,\n renderRow,\n state,\n update,\n slotProps\n } = props\n\n return (\n <Table width=\"100%\" border=\"1px solid\" borderColor=\"divider\" {...slotProps?.table}>\n <TableHead {...props} update={update} state={state} />\n <TableBody\n sx={{\n '& tr:last-child td': {\n borderBottom: 0\n }\n }}\n >\n {\n rows?.map((row: any, idx) => {\n let _row = renderRow ? renderRow({ ...row }, state) : row\n return <Row\n key={row.id + idx}\n rawRow={row}\n row={_row}\n {...props}\n update={update}\n state={state}\n />\n })\n }\n </TableBody>\n </Table>\n )\n}\n\nexport default TableArea"],"names":[],"mappings":";;;;;;;AAQA;AACG;AAQA;AAKY;AACG;AACF;AACH;AAIK;;AASH;AAKf;;"}
|
package/Datatable/TableHead.js
CHANGED
|
@@ -8,13 +8,16 @@ var index$1 = require('../TableRow/index.js');
|
|
|
8
8
|
var index$2 = require('../TableCell/index.js');
|
|
9
9
|
var index$3 = require('../Checkbox/index.js');
|
|
10
10
|
var IndeterminateCheckBoxIcon = require('@xanui/icons/IndeterminateCheckBox');
|
|
11
|
+
var index$4 = require('../Stack/index.js');
|
|
12
|
+
var ArrowDropDown = require('@xanui/icons/ArrowDropDown');
|
|
13
|
+
var icons = require('@xanui/icons');
|
|
11
14
|
|
|
12
|
-
const TableHeadRender = ({ columns, rows, disableRow,
|
|
15
|
+
const TableHeadRender = ({ columns, rows, disableRow, rowAction, hideCheckbox, state, update }) => {
|
|
13
16
|
if (!columns.length)
|
|
14
17
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
return (jsxRuntime.jsx(index, { position: "relative", children: jsxRuntime.jsxs(index$1, { bgcolor: "default", borderBottom: 1, children: [!
|
|
18
|
+
let checked = state.selectAll || !!state.selected.length;
|
|
19
|
+
const sortables = state.sortable || {};
|
|
20
|
+
return (jsxRuntime.jsx(index, { position: "relative", children: jsxRuntime.jsxs(index$1, { bgcolor: "default", borderBottom: 1, children: [!hideCheckbox && jsxRuntime.jsx(index$2, { th: true, width: 40, children: jsxRuntime.jsx(index$3, { checkIcon: state.selected.length && !state.selectAll ? jsxRuntime.jsx(IndeterminateCheckBoxIcon, {}) : undefined, checked: checked, onChange: () => {
|
|
18
21
|
let ids = [];
|
|
19
22
|
let undefinedCount = 0;
|
|
20
23
|
for (let i = 0; i < rows.length; i++) {
|
|
@@ -29,20 +32,27 @@ const TableHeadRender = ({ columns, rows, disableRow, disableSelect, state, upda
|
|
|
29
32
|
}
|
|
30
33
|
if (undefinedCount) {
|
|
31
34
|
update({
|
|
32
|
-
|
|
33
|
-
selectAll: !selected.length
|
|
35
|
+
selected: state.selected.length ? [] : ids,
|
|
36
|
+
selectAll: !state.selected.length
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
37
40
|
update({
|
|
38
|
-
|
|
41
|
+
selected: state.selectAll ? [] : ids,
|
|
39
42
|
selectAll: !state.selectAll
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
} }) }), columns.map((_a, idx) => {
|
|
43
|
-
var { label, field: _f } = _a, rest = tslib.__rest(_a, ["label", "field"]);
|
|
44
|
-
return jsxRuntime.jsx(index$2, Object.assign({ th: true, textAlign: "left" }, rest, { children:
|
|
45
|
-
|
|
46
|
+
var { label, field: _f, sortable } = _a, rest = tslib.__rest(_a, ["label", "field", "sortable"]);
|
|
47
|
+
return jsxRuntime.jsx(index$2, Object.assign({ th: true, textAlign: "left" }, rest, { children: jsxRuntime.jsxs(index$4, { flexRow: true, alignItems: "center", cursor: sortable ? "pointer" : "default", userSelect: "none", onClick: () => {
|
|
48
|
+
if (sortable) {
|
|
49
|
+
let newSort = sortables[_f] === 'asc' ? 'desc' : 'asc';
|
|
50
|
+
update({
|
|
51
|
+
sortable: Object.assign(Object.assign({}, sortables), { [_f]: newSort })
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, children: [label, sortable && jsxRuntime.jsx(jsxRuntime.Fragment, { children: sortables[_f] === 'asc' ? jsxRuntime.jsx(ArrowDropDown, {}) : jsxRuntime.jsx(icons.ArrowDropUp, {}) })] }) }), idx);
|
|
55
|
+
}), rowAction && jsxRuntime.jsx(index$2, { th: true, width: 30 })] }) }));
|
|
46
56
|
};
|
|
47
57
|
|
|
48
58
|
module.exports = TableHeadRender;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHead.js","sources":["../../src/Datatable/TableHead.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"TableHead.js","sources":["../../src/Datatable/TableHead.tsx"],"sourcesContent":["\"use client\";\nimport TableHead from '../TableHead'\nimport TableRow from '../TableRow'\nimport TableCell from '../TableCell'\nimport Checkbox from '../Checkbox'\nimport IntermidiatIcon from '@xanui/icons/IndeterminateCheckBox'\nimport { DatatablePropsWithState } from './types';\nimport Stack from '../Stack';\nimport ArrowDropDown from '@xanui/icons/ArrowDropDown';\nimport { ArrowDropUp } from '@xanui/icons';\n\n\nconst TableHeadRender = ({ columns, rows, disableRow, rowAction, hideCheckbox, state, update }: DatatablePropsWithState) => {\n if (!columns.length) return <></>\n let checked = state.selectAll || !!state.selected.length\n const sortables = state.sortable || {}\n return (\n <TableHead position=\"relative\">\n <TableRow bgcolor=\"default\" borderBottom={1} >\n {!hideCheckbox && <TableCell th width={40}>\n <Checkbox\n checkIcon={state.selected.length && !state.selectAll ? <IntermidiatIcon /> : undefined}\n checked={checked}\n onChange={() => {\n let ids: any = []\n let undefinedCount = 0\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i]\n const isDisable = (disableRow ? disableRow(row, state) : false) || false\n if (!isDisable && row.id) {\n ids.push(row.id)\n } else {\n undefinedCount += 1\n }\n }\n\n if (undefinedCount) {\n update({\n selected: state.selected.length ? [] : ids,\n selectAll: !state.selected.length\n })\n } else {\n update({\n selected: state.selectAll ? [] : ids,\n selectAll: !state.selectAll\n })\n }\n }}\n />\n </TableCell>}\n {\n columns.map(({ label, field: _f, sortable, ...rest }, idx) => <TableCell key={idx} th textAlign=\"left\" {...rest}>\n <Stack\n flexRow\n alignItems=\"center\"\n cursor={sortable ? \"pointer\" : \"default\"}\n userSelect={\"none\"}\n onClick={() => {\n\n if (sortable) {\n let newSort: any = sortables[_f as any] === 'asc' ? 'desc' : 'asc'\n update({\n sortable: {\n ...sortables,\n [_f as any]: newSort\n }\n })\n }\n }}\n >\n {label}\n {sortable && <>\n {\n sortables[_f as any] === 'asc' ? <ArrowDropDown /> : <ArrowDropUp />\n }\n </>}\n </Stack>\n </TableCell>)\n }\n {\n rowAction && <TableCell th width={30} />\n }\n </TableRow>\n </TableHead>\n )\n}\n\nexport default TableHeadRender\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAYA;;AACyB;AACrB;AACA;AACA;;;AAUwB;AACI;;AAEA;AACI;;;;;;;AAOJ;AACI;AACA;AACH;;;AAED;;AAEI;AACH;;AAET;AAIS;AAAiD;;AAS9C;AACA;;AAKC;;AAET;AASI;AAQhC;;"}
|
package/Datatable/TableHead.mjs
CHANGED
|
@@ -6,13 +6,16 @@ import TableRow from '../TableRow/index.mjs';
|
|
|
6
6
|
import TableCell from '../TableCell/index.mjs';
|
|
7
7
|
import Checkbox from '../Checkbox/index.mjs';
|
|
8
8
|
import IndeterminateCheckBoxIcon from '@xanui/icons/IndeterminateCheckBox';
|
|
9
|
+
import Stack from '../Stack/index.mjs';
|
|
10
|
+
import ArrowDropDown from '@xanui/icons/ArrowDropDown';
|
|
11
|
+
import { ArrowDropUp } from '@xanui/icons';
|
|
9
12
|
|
|
10
|
-
const TableHeadRender = ({ columns, rows, disableRow,
|
|
13
|
+
const TableHeadRender = ({ columns, rows, disableRow, rowAction, hideCheckbox, state, update }) => {
|
|
11
14
|
if (!columns.length)
|
|
12
15
|
return jsx(Fragment, {});
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
return (jsx(TableHead, { position: "relative", children: jsxs(TableRow, { bgcolor: "default", borderBottom: 1, children: [!
|
|
16
|
+
let checked = state.selectAll || !!state.selected.length;
|
|
17
|
+
const sortables = state.sortable || {};
|
|
18
|
+
return (jsx(TableHead, { position: "relative", children: jsxs(TableRow, { bgcolor: "default", borderBottom: 1, children: [!hideCheckbox && jsx(TableCell, { th: true, width: 40, children: jsx(Checkbox, { checkIcon: state.selected.length && !state.selectAll ? jsx(IndeterminateCheckBoxIcon, {}) : undefined, checked: checked, onChange: () => {
|
|
16
19
|
let ids = [];
|
|
17
20
|
let undefinedCount = 0;
|
|
18
21
|
for (let i = 0; i < rows.length; i++) {
|
|
@@ -27,20 +30,27 @@ const TableHeadRender = ({ columns, rows, disableRow, disableSelect, state, upda
|
|
|
27
30
|
}
|
|
28
31
|
if (undefinedCount) {
|
|
29
32
|
update({
|
|
30
|
-
|
|
31
|
-
selectAll: !selected.length
|
|
33
|
+
selected: state.selected.length ? [] : ids,
|
|
34
|
+
selectAll: !state.selected.length
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
37
|
else {
|
|
35
38
|
update({
|
|
36
|
-
|
|
39
|
+
selected: state.selectAll ? [] : ids,
|
|
37
40
|
selectAll: !state.selectAll
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
} }) }), columns.map((_a, idx) => {
|
|
41
|
-
var { label, field: _f } = _a, rest = __rest(_a, ["label", "field"]);
|
|
42
|
-
return jsx(TableCell, Object.assign({ th: true, textAlign: "left" }, rest, { children:
|
|
43
|
-
|
|
44
|
+
var { label, field: _f, sortable } = _a, rest = __rest(_a, ["label", "field", "sortable"]);
|
|
45
|
+
return jsx(TableCell, Object.assign({ th: true, textAlign: "left" }, rest, { children: jsxs(Stack, { flexRow: true, alignItems: "center", cursor: sortable ? "pointer" : "default", userSelect: "none", onClick: () => {
|
|
46
|
+
if (sortable) {
|
|
47
|
+
let newSort = sortables[_f] === 'asc' ? 'desc' : 'asc';
|
|
48
|
+
update({
|
|
49
|
+
sortable: Object.assign(Object.assign({}, sortables), { [_f]: newSort })
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}, children: [label, sortable && jsx(Fragment, { children: sortables[_f] === 'asc' ? jsx(ArrowDropDown, {}) : jsx(ArrowDropUp, {}) })] }) }), idx);
|
|
53
|
+
}), rowAction && jsx(TableCell, { th: true, width: 30 })] }) }));
|
|
44
54
|
};
|
|
45
55
|
|
|
46
56
|
export { TableHeadRender as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHead.mjs","sources":["../../src/Datatable/TableHead.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"TableHead.mjs","sources":["../../src/Datatable/TableHead.tsx"],"sourcesContent":["\"use client\";\nimport TableHead from '../TableHead'\nimport TableRow from '../TableRow'\nimport TableCell from '../TableCell'\nimport Checkbox from '../Checkbox'\nimport IntermidiatIcon from '@xanui/icons/IndeterminateCheckBox'\nimport { DatatablePropsWithState } from './types';\nimport Stack from '../Stack';\nimport ArrowDropDown from '@xanui/icons/ArrowDropDown';\nimport { ArrowDropUp } from '@xanui/icons';\n\n\nconst TableHeadRender = ({ columns, rows, disableRow, rowAction, hideCheckbox, state, update }: DatatablePropsWithState) => {\n if (!columns.length) return <></>\n let checked = state.selectAll || !!state.selected.length\n const sortables = state.sortable || {}\n return (\n <TableHead position=\"relative\">\n <TableRow bgcolor=\"default\" borderBottom={1} >\n {!hideCheckbox && <TableCell th width={40}>\n <Checkbox\n checkIcon={state.selected.length && !state.selectAll ? <IntermidiatIcon /> : undefined}\n checked={checked}\n onChange={() => {\n let ids: any = []\n let undefinedCount = 0\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i]\n const isDisable = (disableRow ? disableRow(row, state) : false) || false\n if (!isDisable && row.id) {\n ids.push(row.id)\n } else {\n undefinedCount += 1\n }\n }\n\n if (undefinedCount) {\n update({\n selected: state.selected.length ? [] : ids,\n selectAll: !state.selected.length\n })\n } else {\n update({\n selected: state.selectAll ? [] : ids,\n selectAll: !state.selectAll\n })\n }\n }}\n />\n </TableCell>}\n {\n columns.map(({ label, field: _f, sortable, ...rest }, idx) => <TableCell key={idx} th textAlign=\"left\" {...rest}>\n <Stack\n flexRow\n alignItems=\"center\"\n cursor={sortable ? \"pointer\" : \"default\"}\n userSelect={\"none\"}\n onClick={() => {\n\n if (sortable) {\n let newSort: any = sortables[_f as any] === 'asc' ? 'desc' : 'asc'\n update({\n sortable: {\n ...sortables,\n [_f as any]: newSort\n }\n })\n }\n }}\n >\n {label}\n {sortable && <>\n {\n sortables[_f as any] === 'asc' ? <ArrowDropDown /> : <ArrowDropUp />\n }\n </>}\n </Stack>\n </TableCell>)\n }\n {\n rowAction && <TableCell th width={30} />\n }\n </TableRow>\n </TableHead>\n )\n}\n\nexport default TableHeadRender\n"],"names":[],"mappings":";;;;;;;;;;;;AAYA;;AACyB;AACrB;AACA;AACA;;;AAUwB;AACI;;AAEA;AACI;;;;;;;AAOJ;AACI;AACA;AACH;;;AAED;;AAEI;AACH;;AAET;AAIS;AAAiD;;AAS9C;AACA;;AAKC;;AAET;AASI;AAQhC;;"}
|
package/Datatable/index.d.ts
CHANGED
|
@@ -1,71 +1,6 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import { IconButtonProps } from '../IconButton/index.js';
|
|
4
|
-
import { InputProps } from '../Input/index.js';
|
|
5
|
-
import { TablePaginationProps } from '../TablePagination/index.js';
|
|
6
|
-
import { TableProps } from '../Table/index.js';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatatableProps } from './types.js';
|
|
7
3
|
|
|
8
|
-
type ColumnType = (Omit<TableColumnProps, "children"> & {
|
|
9
|
-
label: string;
|
|
10
|
-
field?: string;
|
|
11
|
-
});
|
|
12
|
-
type DataTableDefaultRow = {
|
|
13
|
-
id?: number;
|
|
14
|
-
[key: string | number]: any;
|
|
15
|
-
};
|
|
16
|
-
type RowActionType = Omit<IconButtonProps, "children"> & {
|
|
17
|
-
label: string;
|
|
18
|
-
icon: ReactElement;
|
|
19
|
-
};
|
|
20
|
-
type TabsProps = {
|
|
21
|
-
label: string;
|
|
22
|
-
value?: string;
|
|
23
|
-
};
|
|
24
|
-
type DatatableFilter = {
|
|
25
|
-
label: string;
|
|
26
|
-
value: string | number;
|
|
27
|
-
};
|
|
28
|
-
type DatatableProps = {
|
|
29
|
-
rows: DataTableDefaultRow[];
|
|
30
|
-
columns: ColumnType[];
|
|
31
|
-
tabs?: TabsProps[];
|
|
32
|
-
defaultActiveTab?: string;
|
|
33
|
-
rowAction?: (props: {
|
|
34
|
-
row: DataTableDefaultRow | null;
|
|
35
|
-
state: State;
|
|
36
|
-
}) => RowActionType[];
|
|
37
|
-
renderRow?: (row: DataTableDefaultRow, state: State) => DataTableDefaultRow;
|
|
38
|
-
disableRow?: (row: DataTableDefaultRow, state: State) => boolean | void;
|
|
39
|
-
totalCount?: number;
|
|
40
|
-
page?: number;
|
|
41
|
-
perpages?: number[];
|
|
42
|
-
getState?: (state: State) => void;
|
|
43
|
-
onSearch?: (text: string, state: State) => void;
|
|
44
|
-
onTabChange?: (tab: string, state: State) => void;
|
|
45
|
-
filters?: {
|
|
46
|
-
[key: string]: DatatableFilter[];
|
|
47
|
-
};
|
|
48
|
-
fixedHeader?: boolean;
|
|
49
|
-
disablePagination?: boolean;
|
|
50
|
-
disableSearch?: boolean;
|
|
51
|
-
disableSelect?: boolean;
|
|
52
|
-
slotProps?: {
|
|
53
|
-
search?: Omit<InputProps, "value" | "onChange">;
|
|
54
|
-
table?: Omit<TableProps, 'children'>;
|
|
55
|
-
pagination?: TablePaginationProps;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
type State = {
|
|
59
|
-
selectedIds: number[];
|
|
60
|
-
selectAll: boolean;
|
|
61
|
-
paginationState: {
|
|
62
|
-
page: number;
|
|
63
|
-
perpage: number;
|
|
64
|
-
};
|
|
65
|
-
activeTab: string;
|
|
66
|
-
search: string;
|
|
67
|
-
};
|
|
68
4
|
declare const DataTable: React.ForwardRefExoticComponent<DatatableProps & React.RefAttributes<HTMLDivElement>>;
|
|
69
5
|
|
|
70
6
|
export { DataTable as default };
|
|
71
|
-
export type { ColumnType, DataTableDefaultRow, DatatableFilter, DatatableProps, RowActionType, State, TabsProps };
|
package/Datatable/index.js
CHANGED
|
@@ -13,24 +13,25 @@ var index$1 = require('../Stack/index.js');
|
|
|
13
13
|
|
|
14
14
|
const DataTable = React.forwardRef((props, ref) => {
|
|
15
15
|
let [_props] = core.useInterface("Datatable", props, {});
|
|
16
|
-
let { rows, tabs,
|
|
16
|
+
let { rows, tabs, totalCount, pagination: { perpages = [30, 50, 100] } = {}, defaultState = {}, onStateChange, fixedHeader, disablePagination, slotProps, } = _props;
|
|
17
17
|
const [state, setState] = React.useState({
|
|
18
|
-
|
|
19
|
-
selectAll: false,
|
|
20
|
-
|
|
21
|
-
page: page || 1,
|
|
22
|
-
perpage: perpages ? perpages[0] :
|
|
18
|
+
selected: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.selected) || [],
|
|
19
|
+
selectAll: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.selectAll) || false,
|
|
20
|
+
pagination: {
|
|
21
|
+
page: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.page) || 1,
|
|
22
|
+
perpage: perpages && perpages.length > 0 ? perpages[0] : 10,
|
|
23
|
+
from: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.from) || 1,
|
|
24
|
+
to: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.to) || (perpages && perpages.length > 0 ? perpages[0] : 10),
|
|
23
25
|
},
|
|
24
|
-
|
|
25
|
-
search: ""
|
|
26
|
+
tab: tabs ? ((defaultState === null || defaultState === void 0 ? void 0 : defaultState.tab) || tabs[0].value || tabs[0].label.toLowerCase()) : "",
|
|
27
|
+
search: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.search) || "",
|
|
26
28
|
});
|
|
27
|
-
const update = (s) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
29
|
+
const update = (s) => setState(o => (Object.assign(Object.assign({}, o), s)));
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (onStateChange) {
|
|
32
|
+
onStateChange(state);
|
|
33
|
+
}
|
|
34
|
+
}, [state]);
|
|
34
35
|
return (jsxRuntime.jsxs(index, { baseClass: 'datatable', ref: ref, height: "100%", sx: {
|
|
35
36
|
'& thead': fixedHeader ? {
|
|
36
37
|
position: "sticky",
|
|
@@ -42,8 +43,8 @@ const DataTable = React.forwardRef((props, ref) => {
|
|
|
42
43
|
display: "flex",
|
|
43
44
|
flexDirection: "row",
|
|
44
45
|
justifyContent: "space-between"
|
|
45
|
-
}, children: [jsxRuntime.jsx(SelectedBox, Object.assign({}, _props, { update: update, state: state })), jsxRuntime.jsx(FilterBox, Object.assign({}, _props, { update: update, state: state }))] })), children: [jsxRuntime.jsx(Table, Object.assign({}, _props, { update: update, state: state })), jsxRuntime.jsx(index$1, { p: 1, alignItems: "flex-end", children: !disablePagination && jsxRuntime.jsx(index$2, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.pagination, { total: totalCount || rows.length, page: state.
|
|
46
|
-
update({
|
|
46
|
+
}, children: [jsxRuntime.jsx(SelectedBox, Object.assign({}, _props, { update: update, state: state })), jsxRuntime.jsx(FilterBox, Object.assign({}, _props, { update: update, state: state }))] })), children: [jsxRuntime.jsx(Table, Object.assign({}, _props, { update: update, state: state })), jsxRuntime.jsx(index$1, { p: 1, alignItems: "flex-end", children: !disablePagination && jsxRuntime.jsx(index$2, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.pagination, { total: totalCount || rows.length, page: state.pagination.page, perpage: state.pagination.perpage, perpages: perpages, onChange: (state) => {
|
|
47
|
+
update({ pagination: state });
|
|
47
48
|
} })) })] }));
|
|
48
49
|
});
|
|
49
50
|
|
package/Datatable/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Datatable/index.tsx"],"sourcesContent":["\"use client\";\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Datatable/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useState } from 'react'\nimport ViewBox from '../ViewBox'\nimport { Tag, useInterface } from '@xanui/core';\nimport SelectedBox from './SelectedBox'\nimport TableArea from './Table'\nimport FilterBox from './FilterBox'\nimport TablePagination, { TablePaginationState } from '../TablePagination'\nimport Stack from '../Stack'\nimport { DatatableProps, DatatableState } from './types';\n\n\nconst DataTable = React.forwardRef((props: DatatableProps, ref: React.Ref<HTMLDivElement>) => {\n let [_props] = useInterface<any>(\"Datatable\", props, {})\n let {\n rows,\n tabs,\n totalCount,\n\n pagination: { perpages = [30, 50, 100] } = {},\n defaultState = {},\n onStateChange,\n\n fixedHeader,\n disablePagination,\n slotProps,\n } = _props\n\n const [state, setState] = useState<DatatableState>({\n selected: defaultState?.selected || [],\n selectAll: defaultState?.selectAll || false,\n pagination: {\n page: defaultState?.page || 1,\n perpage: perpages && perpages.length > 0 ? perpages[0] : 10,\n from: defaultState?.from || 1,\n to: defaultState?.to || (perpages && perpages.length > 0 ? perpages[0] : 10),\n },\n tab: tabs ? (defaultState?.tab || tabs[0].value || tabs[0].label.toLowerCase()) : \"\",\n search: defaultState?.search || \"\",\n })\n\n const update = (s: Partial<DatatableState>) => setState(o => ({ ...o, ...s }))\n\n useEffect(() => {\n if (onStateChange) {\n onStateChange(state)\n }\n }, [state])\n\n return (\n <ViewBox\n baseClass='datatable'\n ref={ref as any}\n height=\"100%\"\n sx={{\n '& thead': fixedHeader ? {\n position: \"sticky\",\n top: 0,\n bgcolor: \"background.primary\",\n zIndex: 1\n } : {},\n }}\n startContent={(\n <Tag\n baseClass='datatable-header'\n sxr={{\n display: \"flex\",\n flexDirection: \"row\",\n justifyContent: \"space-between\"\n }}\n >\n <SelectedBox {..._props} update={update} state={state} />\n <FilterBox {..._props} update={update} state={state} />\n </Tag>\n )}\n >\n <TableArea\n {..._props}\n update={update}\n state={state}\n />\n <Stack\n p={1}\n alignItems=\"flex-end\"\n >\n {!disablePagination && <TablePagination\n {...slotProps?.pagination}\n total={totalCount || rows.length}\n page={state.pagination.page}\n perpage={state.pagination.perpage}\n perpages={perpages}\n onChange={(state: TablePaginationState) => {\n update({ pagination: state })\n }}\n />}\n </Stack>\n </ViewBox>\n )\n})\n\nexport default DataTable"],"names":[],"mappings":";;;;;;;;;;;;;AAYA;AACI;AACA;AAcA;;;AAGI;;AAEI;;AAEA;AACH;AACD;;AAEH;AAED;;;;;AAMA;AAEA;AAMY;AACI;AACA;AACA;AACA;;;AAOI;AACA;AACA;;AAwBA;AACJ;AAKpB;;"}
|
package/Datatable/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import React, { useState } from 'react';
|
|
3
|
+
import React, { useState, useEffect } from 'react';
|
|
4
4
|
import ViewBox from '../ViewBox/index.mjs';
|
|
5
5
|
import { useInterface, Tag } from '@xanui/core';
|
|
6
6
|
import SelectedBox from './SelectedBox.mjs';
|
|
@@ -11,24 +11,25 @@ import Stack from '../Stack/index.mjs';
|
|
|
11
11
|
|
|
12
12
|
const DataTable = React.forwardRef((props, ref) => {
|
|
13
13
|
let [_props] = useInterface("Datatable", props, {});
|
|
14
|
-
let { rows, tabs,
|
|
14
|
+
let { rows, tabs, totalCount, pagination: { perpages = [30, 50, 100] } = {}, defaultState = {}, onStateChange, fixedHeader, disablePagination, slotProps, } = _props;
|
|
15
15
|
const [state, setState] = useState({
|
|
16
|
-
|
|
17
|
-
selectAll: false,
|
|
18
|
-
|
|
19
|
-
page: page || 1,
|
|
20
|
-
perpage: perpages ? perpages[0] :
|
|
16
|
+
selected: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.selected) || [],
|
|
17
|
+
selectAll: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.selectAll) || false,
|
|
18
|
+
pagination: {
|
|
19
|
+
page: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.page) || 1,
|
|
20
|
+
perpage: perpages && perpages.length > 0 ? perpages[0] : 10,
|
|
21
|
+
from: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.from) || 1,
|
|
22
|
+
to: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.to) || (perpages && perpages.length > 0 ? perpages[0] : 10),
|
|
21
23
|
},
|
|
22
|
-
|
|
23
|
-
search: ""
|
|
24
|
+
tab: tabs ? ((defaultState === null || defaultState === void 0 ? void 0 : defaultState.tab) || tabs[0].value || tabs[0].label.toLowerCase()) : "",
|
|
25
|
+
search: (defaultState === null || defaultState === void 0 ? void 0 : defaultState.search) || "",
|
|
24
26
|
});
|
|
25
|
-
const update = (s) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
27
|
+
const update = (s) => setState(o => (Object.assign(Object.assign({}, o), s)));
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (onStateChange) {
|
|
30
|
+
onStateChange(state);
|
|
31
|
+
}
|
|
32
|
+
}, [state]);
|
|
32
33
|
return (jsxs(ViewBox, { baseClass: 'datatable', ref: ref, height: "100%", sx: {
|
|
33
34
|
'& thead': fixedHeader ? {
|
|
34
35
|
position: "sticky",
|
|
@@ -40,8 +41,8 @@ const DataTable = React.forwardRef((props, ref) => {
|
|
|
40
41
|
display: "flex",
|
|
41
42
|
flexDirection: "row",
|
|
42
43
|
justifyContent: "space-between"
|
|
43
|
-
}, 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: !disablePagination && jsx(TablePagination, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.pagination, { total: totalCount || rows.length, page: state.
|
|
44
|
-
update({
|
|
44
|
+
}, 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: !disablePagination && jsx(TablePagination, Object.assign({}, slotProps === null || slotProps === void 0 ? void 0 : slotProps.pagination, { total: totalCount || rows.length, page: state.pagination.page, perpage: state.pagination.perpage, perpages: perpages, onChange: (state) => {
|
|
45
|
+
update({ pagination: state });
|
|
45
46
|
} })) })] }));
|
|
46
47
|
});
|
|
47
48
|
|