@ctlyst.id/internal-ui 2.0.8 → 2.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/data-table/__stories__/datatable.stories.d.ts +3 -17
- package/dist/components/data-table/components/data-table.d.ts +10 -20
- package/dist/components/index.d.ts +4 -0
- package/dist/components/loader/components/loader.d.ts +1 -0
- package/dist/internal-ui.cjs.development.js +205 -45
- package/dist/internal-ui.cjs.development.js.map +1 -1
- package/dist/internal-ui.cjs.production.min.js +5 -5
- package/dist/internal-ui.cjs.production.min.js.map +1 -1
- package/dist/internal-ui.esm.js +105 -48
- package/dist/internal-ui.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/data-table/components/indeterminate-checkbox.d.ts +0 -5
@@ -4,23 +4,9 @@ declare const _default: {
|
|
4
4
|
chakra: {
|
5
5
|
theme: Record<string, any>;
|
6
6
|
};
|
7
|
-
component: {
|
8
|
-
|
9
|
-
|
10
|
-
withSelectedRow: boolean;
|
11
|
-
overflowX: string;
|
12
|
-
pos: string;
|
13
|
-
maxW: string;
|
14
|
-
minH: number;
|
15
|
-
w: string;
|
16
|
-
styles: undefined;
|
17
|
-
isLoading: undefined;
|
18
|
-
onSelectedRow: undefined;
|
19
|
-
onSort: undefined;
|
20
|
-
manualSorting: boolean;
|
21
|
-
sortingState: never[];
|
22
|
-
};
|
23
|
-
};
|
7
|
+
component: <T extends unknown>(props: import("../components/data-table").DataTableProps<T> & {
|
8
|
+
ref?: ((instance: Pick<any, "toggleAllRowsSelected"> | null) => void) | React.RefObject<Pick<any, "toggleAllRowsSelected">> | null | undefined;
|
9
|
+
}) => JSX.Element;
|
24
10
|
argTypes: {
|
25
11
|
selectedRow: {
|
26
12
|
options: boolean[];
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { BoxProps, TableBodyProps, TableCellProps, TableColumnHeaderProps, TableHeadProps, TableProps, TableRowProps } from '@chakra-ui/react';
|
2
|
-
import type { ColumnDef,
|
2
|
+
import type { ColumnDef, RowSelectionInstance, SortingState } from '@tanstack/react-table';
|
3
3
|
import * as React from 'react';
|
4
4
|
export interface TableStyleProps {
|
5
5
|
table?: TableProps;
|
@@ -16,25 +16,15 @@ export interface DataTableProps<T = unknown> extends BoxProps {
|
|
16
16
|
isLoading?: boolean;
|
17
17
|
withSelectedRow?: boolean | undefined;
|
18
18
|
onSelectedRow?: (data: T[]) => void;
|
19
|
-
onSort?: (data:
|
19
|
+
onSort?: (data: SortingState) => void;
|
20
20
|
manualSorting?: boolean;
|
21
21
|
sortingState?: SortingState;
|
22
|
+
sortDescFirst?: boolean;
|
23
|
+
headerSticky?: boolean;
|
24
|
+
onRowClick?: (data: T) => void;
|
22
25
|
}
|
23
|
-
declare
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
pos: string;
|
29
|
-
maxW: string;
|
30
|
-
minH: number;
|
31
|
-
w: string;
|
32
|
-
styles: undefined;
|
33
|
-
isLoading: undefined;
|
34
|
-
onSelectedRow: undefined;
|
35
|
-
onSort: undefined;
|
36
|
-
manualSorting: boolean;
|
37
|
-
sortingState: never[];
|
38
|
-
};
|
39
|
-
};
|
40
|
-
export default DataTable;
|
26
|
+
export declare type DataTableRefs<T> = Pick<RowSelectionInstance<T>, 'toggleAllRowsSelected'>;
|
27
|
+
declare const _default: <T extends unknown>(props: DataTableProps<T> & {
|
28
|
+
ref?: ((instance: Pick<any, "toggleAllRowsSelected"> | null) => void) | React.RefObject<Pick<any, "toggleAllRowsSelected">> | null | undefined;
|
29
|
+
}) => JSX.Element;
|
30
|
+
export default _default;
|
@@ -4,16 +4,20 @@ export * from './breadcrumb';
|
|
4
4
|
export * from './button';
|
5
5
|
export * from './card';
|
6
6
|
export * from './checkbox';
|
7
|
+
export * from './chips';
|
7
8
|
export * from './data-table';
|
8
9
|
export * from './datepicker';
|
9
10
|
export * from './field';
|
10
11
|
export * from './form';
|
11
12
|
export * from './header';
|
13
|
+
export * from './image';
|
12
14
|
export * from './layouting';
|
15
|
+
export * from './list';
|
13
16
|
export * from './loader';
|
14
17
|
export * from './modal';
|
15
18
|
export * from './navigation';
|
16
19
|
export * from './pagination';
|
20
|
+
export * from './popover';
|
17
21
|
export * from './radio';
|
18
22
|
export * from './rating';
|
19
23
|
export * from './select';
|
@@ -520,37 +520,63 @@ CheckboxGroupComponent.defaultProps = {
|
|
520
520
|
errorMessage: ''
|
521
521
|
};
|
522
522
|
|
523
|
-
const
|
524
|
-
|
523
|
+
const Chips = ({
|
524
|
+
children,
|
525
525
|
...rest
|
526
526
|
}) => {
|
527
|
-
const
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
527
|
+
const {
|
528
|
+
isActive,
|
529
|
+
isDisabled,
|
530
|
+
onClose
|
531
|
+
} = rest;
|
532
|
+
const styles = react.useStyleConfig('Chips', rest);
|
533
|
+
const closeColor = React.useMemo(() => {
|
534
|
+
if (isActive) return 'white.high';
|
535
|
+
if (isDisabled) return 'black.low';
|
536
|
+
return 'primary.500';
|
537
|
+
}, [isActive, isDisabled]);
|
538
|
+
return /*#__PURE__*/React__default.createElement(react.Box, Object.assign({
|
539
|
+
__css: styles,
|
540
|
+
display: "inline-flex",
|
541
|
+
alignItems: "center",
|
542
|
+
justifyContent: "center"
|
543
|
+
}, rest), children, onClose && /*#__PURE__*/React__default.createElement(react.Box, {
|
544
|
+
onClick: isDisabled ? undefined : onClose,
|
545
|
+
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
546
|
+
ml: 2,
|
547
|
+
display: "flex",
|
548
|
+
alignItems: "center",
|
549
|
+
justifyContent: "center"
|
550
|
+
}, /*#__PURE__*/React__default.createElement(internalIcon.Close, {
|
551
|
+
color: closeColor,
|
552
|
+
size: 4
|
553
|
+
})));
|
554
|
+
};
|
555
|
+
Chips.defaultProps = {
|
556
|
+
isDisabled: false,
|
557
|
+
isActive: false,
|
558
|
+
onClose: undefined,
|
559
|
+
children: undefined,
|
560
|
+
size: 'sm'
|
539
561
|
};
|
540
562
|
|
541
563
|
/* eslint-disable react-hooks/rules-of-hooks */
|
542
|
-
const DataTable = ({
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
564
|
+
const DataTable = /*#__PURE__*/React.forwardRef((props, ref) => {
|
565
|
+
const {
|
566
|
+
columns,
|
567
|
+
dataSource = [],
|
568
|
+
isLoading,
|
569
|
+
withSelectedRow,
|
570
|
+
onSelectedRow,
|
571
|
+
onSort,
|
572
|
+
sortDescFirst,
|
573
|
+
styles,
|
574
|
+
sortingState,
|
575
|
+
headerSticky,
|
576
|
+
manualSorting,
|
577
|
+
onRowClick
|
578
|
+
} = props;
|
579
|
+
const [isFirstLoad, setIsFirstLoad] = React.useState(true);
|
554
580
|
const [sorting, setSorting] = React.useState(sortingState !== null && sortingState !== void 0 ? sortingState : []);
|
555
581
|
const [rowSelection, onRowSelectionChange] = React.useState({});
|
556
582
|
const dataColumns = React.useMemo(() => columns, [columns]);
|
@@ -558,16 +584,20 @@ const DataTable = ({
|
|
558
584
|
id: 'select',
|
559
585
|
header: ({
|
560
586
|
table
|
561
|
-
}) => /*#__PURE__*/React.createElement(
|
562
|
-
|
563
|
-
|
587
|
+
}) => /*#__PURE__*/React.createElement(react.Checkbox, Object.assign({
|
588
|
+
"data-test-id": "select-header-data-table"
|
589
|
+
}, {
|
590
|
+
isChecked: table.getIsAllRowsSelected(),
|
591
|
+
isIndeterminate: table.getIsSomeRowsSelected(),
|
564
592
|
onChange: table.getToggleAllRowsSelectedHandler()
|
565
593
|
})),
|
566
594
|
cell: ({
|
567
595
|
row
|
568
|
-
}) => /*#__PURE__*/React.createElement(
|
569
|
-
|
570
|
-
|
596
|
+
}) => /*#__PURE__*/React.createElement(react.Checkbox, Object.assign({
|
597
|
+
"data-test-id": `select-data-table-${row.index}`
|
598
|
+
}, {
|
599
|
+
isChecked: row.getIsSelected(),
|
600
|
+
isIndeterminate: row.getIsSomeSelected(),
|
571
601
|
onChange: row.getToggleSelectedHandler()
|
572
602
|
}))
|
573
603
|
}], []);
|
@@ -579,9 +609,6 @@ const DataTable = ({
|
|
579
609
|
};
|
580
610
|
const onSortingChange = data => {
|
581
611
|
setSorting(data);
|
582
|
-
if (onSort) {
|
583
|
-
onSort(data);
|
584
|
-
}
|
585
612
|
};
|
586
613
|
const table = reactTable.useReactTable({
|
587
614
|
data: dataSource,
|
@@ -589,24 +616,39 @@ const DataTable = ({
|
|
589
616
|
getCoreRowModel: reactTable.getCoreRowModel(),
|
590
617
|
getSortedRowModel: reactTable.getSortedRowModel(),
|
591
618
|
manualPagination: true,
|
592
|
-
|
619
|
+
manualSorting,
|
620
|
+
sortDescFirst,
|
593
621
|
state: {
|
594
622
|
sorting,
|
595
623
|
rowSelection
|
596
624
|
},
|
597
625
|
onRowSelectionChange,
|
598
|
-
onSortingChange
|
599
|
-
manualSorting
|
626
|
+
onSortingChange
|
600
627
|
});
|
628
|
+
const {
|
629
|
+
getSelectedRowModel,
|
630
|
+
toggleAllRowsSelected
|
631
|
+
} = table;
|
601
632
|
const {
|
602
633
|
flatRows
|
603
|
-
} =
|
634
|
+
} = getSelectedRowModel();
|
604
635
|
React.useEffect(() => {
|
605
636
|
const rowData = flatRows.map(row => row.original);
|
606
637
|
if (onSelectedRow) {
|
607
638
|
onSelectedRow(rowData);
|
608
639
|
}
|
609
640
|
}, [flatRows]);
|
641
|
+
React.useImperativeHandle(ref, () => ({
|
642
|
+
toggleAllRowsSelected
|
643
|
+
}));
|
644
|
+
React.useEffect(() => {
|
645
|
+
if (onSort && !isFirstLoad) {
|
646
|
+
onSort(sorting);
|
647
|
+
}
|
648
|
+
}, [sorting]);
|
649
|
+
React.useEffect(() => {
|
650
|
+
setIsFirstLoad(false);
|
651
|
+
}, []);
|
610
652
|
return /*#__PURE__*/React.createElement(react.Box, Object.assign({}, props), isLoading && /*#__PURE__*/React.createElement(react.Flex, {
|
611
653
|
w: "100%",
|
612
654
|
h: "100%",
|
@@ -619,7 +661,12 @@ const DataTable = ({
|
|
619
661
|
color: "primary.500",
|
620
662
|
thickness: "4px",
|
621
663
|
size: "lg"
|
622
|
-
})), /*#__PURE__*/React.createElement(react.Table, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.table), /*#__PURE__*/React.createElement(react.Thead, Object.assign({},
|
664
|
+
})), /*#__PURE__*/React.createElement(react.Table, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.table), /*#__PURE__*/React.createElement(react.Thead, Object.assign({}, (headerSticky ? {
|
665
|
+
position: 'sticky',
|
666
|
+
top: 0,
|
667
|
+
bg: 'white',
|
668
|
+
zIndex: 1
|
669
|
+
} : {})), table.getHeaderGroups().map(headerGroup => /*#__PURE__*/React.createElement(react.Tr, Object.assign({
|
623
670
|
key: headerGroup.id,
|
624
671
|
bg: react.useColorModeValue('initial', 'ebony-clay.700')
|
625
672
|
}, styles === null || styles === void 0 ? void 0 : styles.tableRow), headerGroup.headers.map(header => {
|
@@ -651,6 +698,7 @@ const DataTable = ({
|
|
651
698
|
h: 2
|
652
699
|
}))));
|
653
700
|
})))), /*#__PURE__*/React.createElement(react.Tbody, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.tableBody), table.getRowModel().rows.map(row => /*#__PURE__*/React.createElement(react.Tr, Object.assign({
|
701
|
+
"data-test-id": "6aZAeefGHBA2oG1wLuv-L",
|
654
702
|
key: row.id
|
655
703
|
}, styles === null || styles === void 0 ? void 0 : styles.tableRow, {
|
656
704
|
css: react$1.css`
|
@@ -659,13 +707,18 @@ const DataTable = ({
|
|
659
707
|
border-bottom: none;
|
660
708
|
}
|
661
709
|
}
|
662
|
-
|
710
|
+
`,
|
711
|
+
onClick: () => {
|
712
|
+
if (onRowClick) {
|
713
|
+
onRowClick(row.original);
|
714
|
+
}
|
715
|
+
}
|
663
716
|
}), row.getVisibleCells().map(cell => /*#__PURE__*/React.createElement(react.Td, Object.assign({
|
664
717
|
key: cell.id,
|
665
718
|
fontSize: "text.sm",
|
666
719
|
color: react.useColorModeValue('dark.800', 'dark.300')
|
667
720
|
}, styles === null || styles === void 0 ? void 0 : styles.tableCell), reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()))))))));
|
668
|
-
};
|
721
|
+
});
|
669
722
|
/* eslint-disable react/default-props-match-prop-types */
|
670
723
|
DataTable.defaultProps = {
|
671
724
|
withSelectedRow: false,
|
@@ -679,7 +732,10 @@ DataTable.defaultProps = {
|
|
679
732
|
onSelectedRow: undefined,
|
680
733
|
onSort: undefined,
|
681
734
|
manualSorting: false,
|
682
|
-
sortingState: []
|
735
|
+
sortingState: [],
|
736
|
+
sortDescFirst: false,
|
737
|
+
headerSticky: false,
|
738
|
+
onRowClick: undefined
|
683
739
|
};
|
684
740
|
|
685
741
|
const getProperties = props => {
|
@@ -3942,7 +3998,7 @@ const Checkbox = /*#__PURE__*/defineMultiStyleConfig$1({
|
|
3942
3998
|
}
|
3943
3999
|
});
|
3944
4000
|
|
3945
|
-
const Chips = /*#__PURE__*/styledSystem.defineStyleConfig({
|
4001
|
+
const Chips$1 = /*#__PURE__*/styledSystem.defineStyleConfig({
|
3946
4002
|
baseStyle: props => {
|
3947
4003
|
const {
|
3948
4004
|
isDisabled,
|
@@ -4129,6 +4185,7 @@ const rotate = /*#__PURE__*/react$1.keyframes({
|
|
4129
4185
|
const getLoaderColor = color => {
|
4130
4186
|
if (color === 'primary') return colors.primary[600];
|
4131
4187
|
if (color === 'danger') return colors.danger[500];
|
4188
|
+
if (color === 'warning') return colors.warning[700];
|
4132
4189
|
return colors.white.high;
|
4133
4190
|
};
|
4134
4191
|
const LoaderStyle = /*#__PURE__*/styledSystem.defineStyleConfig({
|
@@ -4487,7 +4544,7 @@ var components = {
|
|
4487
4544
|
Button: Button$1,
|
4488
4545
|
Card: CardStyle,
|
4489
4546
|
Checkbox: Checkbox,
|
4490
|
-
Chips: Chips,
|
4547
|
+
Chips: Chips$1,
|
4491
4548
|
FormLabel: FormLabel,
|
4492
4549
|
Input: Input,
|
4493
4550
|
LoaderStyle: LoaderStyle,
|
@@ -4734,6 +4791,18 @@ Object.defineProperty(exports, 'Heading', {
|
|
4734
4791
|
return react.Heading;
|
4735
4792
|
}
|
4736
4793
|
});
|
4794
|
+
Object.defineProperty(exports, 'Icon', {
|
4795
|
+
enumerable: true,
|
4796
|
+
get: function () {
|
4797
|
+
return react.Icon;
|
4798
|
+
}
|
4799
|
+
});
|
4800
|
+
Object.defineProperty(exports, 'Image', {
|
4801
|
+
enumerable: true,
|
4802
|
+
get: function () {
|
4803
|
+
return react.Image;
|
4804
|
+
}
|
4805
|
+
});
|
4737
4806
|
Object.defineProperty(exports, 'InputElementLeft', {
|
4738
4807
|
enumerable: true,
|
4739
4808
|
get: function () {
|
@@ -4746,6 +4815,24 @@ Object.defineProperty(exports, 'InputElementRight', {
|
|
4746
4815
|
return react.InputRightElement;
|
4747
4816
|
}
|
4748
4817
|
});
|
4818
|
+
Object.defineProperty(exports, 'List', {
|
4819
|
+
enumerable: true,
|
4820
|
+
get: function () {
|
4821
|
+
return react.List;
|
4822
|
+
}
|
4823
|
+
});
|
4824
|
+
Object.defineProperty(exports, 'ListIcon', {
|
4825
|
+
enumerable: true,
|
4826
|
+
get: function () {
|
4827
|
+
return react.ListIcon;
|
4828
|
+
}
|
4829
|
+
});
|
4830
|
+
Object.defineProperty(exports, 'ListItem', {
|
4831
|
+
enumerable: true,
|
4832
|
+
get: function () {
|
4833
|
+
return react.ListItem;
|
4834
|
+
}
|
4835
|
+
});
|
4749
4836
|
Object.defineProperty(exports, 'Modal', {
|
4750
4837
|
enumerable: true,
|
4751
4838
|
get: function () {
|
@@ -4776,6 +4863,72 @@ Object.defineProperty(exports, 'ModalOverlay', {
|
|
4776
4863
|
return react.ModalOverlay;
|
4777
4864
|
}
|
4778
4865
|
});
|
4866
|
+
Object.defineProperty(exports, 'OrderedList', {
|
4867
|
+
enumerable: true,
|
4868
|
+
get: function () {
|
4869
|
+
return react.OrderedList;
|
4870
|
+
}
|
4871
|
+
});
|
4872
|
+
Object.defineProperty(exports, 'Popover', {
|
4873
|
+
enumerable: true,
|
4874
|
+
get: function () {
|
4875
|
+
return react.Popover;
|
4876
|
+
}
|
4877
|
+
});
|
4878
|
+
Object.defineProperty(exports, 'PopoverAnchor', {
|
4879
|
+
enumerable: true,
|
4880
|
+
get: function () {
|
4881
|
+
return react.PopoverAnchor;
|
4882
|
+
}
|
4883
|
+
});
|
4884
|
+
Object.defineProperty(exports, 'PopoverArrow', {
|
4885
|
+
enumerable: true,
|
4886
|
+
get: function () {
|
4887
|
+
return react.PopoverArrow;
|
4888
|
+
}
|
4889
|
+
});
|
4890
|
+
Object.defineProperty(exports, 'PopoverBody', {
|
4891
|
+
enumerable: true,
|
4892
|
+
get: function () {
|
4893
|
+
return react.PopoverBody;
|
4894
|
+
}
|
4895
|
+
});
|
4896
|
+
Object.defineProperty(exports, 'PopoverCloseButton', {
|
4897
|
+
enumerable: true,
|
4898
|
+
get: function () {
|
4899
|
+
return react.PopoverCloseButton;
|
4900
|
+
}
|
4901
|
+
});
|
4902
|
+
Object.defineProperty(exports, 'PopoverContent', {
|
4903
|
+
enumerable: true,
|
4904
|
+
get: function () {
|
4905
|
+
return react.PopoverContent;
|
4906
|
+
}
|
4907
|
+
});
|
4908
|
+
Object.defineProperty(exports, 'PopoverFooter', {
|
4909
|
+
enumerable: true,
|
4910
|
+
get: function () {
|
4911
|
+
return react.PopoverFooter;
|
4912
|
+
}
|
4913
|
+
});
|
4914
|
+
Object.defineProperty(exports, 'PopoverHeader', {
|
4915
|
+
enumerable: true,
|
4916
|
+
get: function () {
|
4917
|
+
return react.PopoverHeader;
|
4918
|
+
}
|
4919
|
+
});
|
4920
|
+
Object.defineProperty(exports, 'PopoverTrigger', {
|
4921
|
+
enumerable: true,
|
4922
|
+
get: function () {
|
4923
|
+
return react.PopoverTrigger;
|
4924
|
+
}
|
4925
|
+
});
|
4926
|
+
Object.defineProperty(exports, 'Portal', {
|
4927
|
+
enumerable: true,
|
4928
|
+
get: function () {
|
4929
|
+
return react.Portal;
|
4930
|
+
}
|
4931
|
+
});
|
4779
4932
|
Object.defineProperty(exports, 'Stack', {
|
4780
4933
|
enumerable: true,
|
4781
4934
|
get: function () {
|
@@ -4824,6 +4977,12 @@ Object.defineProperty(exports, 'Tooltip', {
|
|
4824
4977
|
return react.Tooltip;
|
4825
4978
|
}
|
4826
4979
|
});
|
4980
|
+
Object.defineProperty(exports, 'UnorderedList', {
|
4981
|
+
enumerable: true,
|
4982
|
+
get: function () {
|
4983
|
+
return react.UnorderedList;
|
4984
|
+
}
|
4985
|
+
});
|
4827
4986
|
Object.defineProperty(exports, 'VStack', {
|
4828
4987
|
enumerable: true,
|
4829
4988
|
get: function () {
|
@@ -4962,6 +5121,7 @@ exports.Button = Button;
|
|
4962
5121
|
exports.Card = CardCustom;
|
4963
5122
|
exports.Checkbox = CheckboxComponent;
|
4964
5123
|
exports.CheckboxGroup = CheckboxGroupComponent;
|
5124
|
+
exports.Chips = Chips;
|
4965
5125
|
exports.DataTable = DataTable;
|
4966
5126
|
exports.DatePickerMonth = DatePickerMonth;
|
4967
5127
|
exports.Datepicker = Datepicker;
|