@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
package/dist/internal-ui.esm.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { cx, dataAttr } from '@chakra-ui/shared-utils';
|
2
2
|
import { forwardRef, omitThemingProps, useMultiStyleConfig, chakra, useColorMode } from '@chakra-ui/system';
|
3
|
-
import React__default, { createElement, forwardRef as forwardRef$2,
|
3
|
+
import React__default, { createElement, forwardRef as forwardRef$2, useMemo, useState, useEffect, useImperativeHandle, Fragment, useCallback, createContext as createContext$1, useContext, useRef } from 'react';
|
4
4
|
import { createContext } from '@chakra-ui/react-context';
|
5
5
|
import { CheckCircle, Info, AlertTriangle, Close, EyeOff, Eye, Rating as Rating$1, Check } from '@ctlyst.id/internal-icon';
|
6
6
|
import { cx as cx$1 } from '@chakra-ui/utils';
|
7
7
|
import { forwardRef as forwardRef$1, useStyleConfig, Box, Button as Button$2, Badge as Badge$2, useToken, Text, useColorModeValue, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Card, Checkbox as Checkbox$1, FormControl, FormLabel as FormLabel$1, FormHelperText, FormErrorMessage, CheckboxGroup, Stack, Flex, Spinner, Table, Thead, Tr, Th, Tbody, Td, defineStyle, InputGroup, Input as Input$1, InputRightAddon, InputRightElement, theme as theme$1, InputLeftAddon, Textarea as Textarea$1, Image, useDisclosure, Popover as Popover$1, HStack, VStack, PopoverTrigger, Avatar, PopoverContent, PopoverArrow, PopoverBody, useColorMode as useColorMode$1, ModalBody as ModalBody$1, ModalCloseButton as ModalCloseButton$1, ModalFooter as ModalFooter$1, ModalHeader as ModalHeader$1, createIcon, Icon, Portal, Link, VisuallyHidden, Select as Select$1, Radio as Radio$1, RadioGroup, Grid, useMultiStyleConfig as useMultiStyleConfig$1, omitThemingProps as omitThemingProps$1, useCheckbox, chakra as chakra$1, useTab, TabList as TabList$1, TabPanel as TabPanel$1, Heading, createMultiStyleConfigHelpers as createMultiStyleConfigHelpers$1, defineStyleConfig as defineStyleConfig$1, extendTheme } from '@chakra-ui/react';
|
8
|
-
export { AlertDialog, ModalBody as AlertDialogBody, ModalCloseButton as AlertDialogCloseButton, AlertDialogContent, ModalFooter as AlertDialogFooter, ModalHeader as AlertDialogHeader, ModalOverlay as AlertDialogOverlay, Box, ButtonGroup, ChakraProvider, CloseButton, Container, Divider, Drawer, ModalBody as DrawerBody, ModalCloseButton as DrawerCloseButton, DrawerContent, ModalFooter as DrawerFooter, ModalHeader as DrawerHeader, ModalOverlay as DrawerOverlay, Flex, Grid, GridItem, HStack, Heading, InputLeftElement as InputElementLeft, InputRightElement as InputElementRight, Modal, ModalContent, ModalContextProvider, ModalFocusScope, ModalOverlay, Stack, TabIndicator, TabPanels, Tabs, TabsDescendantsProvider, TabsProvider, Text, Tooltip, VStack, Wrap, WrapItem, extendTheme, useColorModeValue, useDisclosure, useDrawerContext, useModal, useModalContext, useModalStyles, useTab, useTabIndicator, useTabList, useTabPanel, useTabPanels, useTabs, useTabsContext, useTabsDescendant, useTabsDescendants, useTabsDescendantsContext, useTabsStyles } from '@chakra-ui/react';
|
8
|
+
export { AlertDialog, ModalBody as AlertDialogBody, ModalCloseButton as AlertDialogCloseButton, AlertDialogContent, ModalFooter as AlertDialogFooter, ModalHeader as AlertDialogHeader, ModalOverlay as AlertDialogOverlay, Box, ButtonGroup, ChakraProvider, CloseButton, Container, Divider, Drawer, ModalBody as DrawerBody, ModalCloseButton as DrawerCloseButton, DrawerContent, ModalFooter as DrawerFooter, ModalHeader as DrawerHeader, ModalOverlay as DrawerOverlay, Flex, Grid, GridItem, HStack, Heading, Icon, Image, InputLeftElement as InputElementLeft, InputRightElement as InputElementRight, List, ListIcon, ListItem, Modal, ModalContent, ModalContextProvider, ModalFocusScope, ModalOverlay, OrderedList, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, Portal, Stack, TabIndicator, TabPanels, Tabs, TabsDescendantsProvider, TabsProvider, Text, Tooltip, UnorderedList, VStack, Wrap, WrapItem, extendTheme, useColorModeValue, useDisclosure, useDrawerContext, useModal, useModalContext, useModalStyles, useTab, useTabIndicator, useTabList, useTabPanel, useTabPanels, useTabs, useTabsContext, useTabsDescendant, useTabsDescendants, useTabsDescendantsContext, useTabsStyles } from '@chakra-ui/react';
|
9
9
|
import { FiChevronsRight, FiHome, FiCalendar, FiX, FiPower, FiMoon, FiSun, FiShoppingBag, FiShoppingCart, FiRepeat, FiBox, FiLayers, FiDollarSign, FiUsers, FiRotateCcw, FiSettings, FiLayout, FiGift, FiChevronDown } from 'react-icons/fi';
|
10
10
|
import { ChevronUpIcon, ChevronDownIcon, UpDownIcon, ArrowLeftIcon, ChevronLeftIcon, ChevronRightIcon, ArrowRightIcon } from '@chakra-ui/icons';
|
11
11
|
import { css, Global, keyframes } from '@emotion/react';
|
@@ -514,37 +514,63 @@ CheckboxGroupComponent.defaultProps = {
|
|
514
514
|
errorMessage: ''
|
515
515
|
};
|
516
516
|
|
517
|
-
const
|
518
|
-
|
517
|
+
const Chips = ({
|
518
|
+
children,
|
519
519
|
...rest
|
520
520
|
}) => {
|
521
|
-
const
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
521
|
+
const {
|
522
|
+
isActive,
|
523
|
+
isDisabled,
|
524
|
+
onClose
|
525
|
+
} = rest;
|
526
|
+
const styles = useStyleConfig('Chips', rest);
|
527
|
+
const closeColor = useMemo(() => {
|
528
|
+
if (isActive) return 'white.high';
|
529
|
+
if (isDisabled) return 'black.low';
|
530
|
+
return 'primary.500';
|
531
|
+
}, [isActive, isDisabled]);
|
532
|
+
return /*#__PURE__*/React__default.createElement(Box, Object.assign({
|
533
|
+
__css: styles,
|
534
|
+
display: "inline-flex",
|
535
|
+
alignItems: "center",
|
536
|
+
justifyContent: "center"
|
537
|
+
}, rest), children, onClose && /*#__PURE__*/React__default.createElement(Box, {
|
538
|
+
onClick: isDisabled ? undefined : onClose,
|
539
|
+
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
540
|
+
ml: 2,
|
541
|
+
display: "flex",
|
542
|
+
alignItems: "center",
|
543
|
+
justifyContent: "center"
|
544
|
+
}, /*#__PURE__*/React__default.createElement(Close, {
|
545
|
+
color: closeColor,
|
546
|
+
size: 4
|
547
|
+
})));
|
548
|
+
};
|
549
|
+
Chips.defaultProps = {
|
550
|
+
isDisabled: false,
|
551
|
+
isActive: false,
|
552
|
+
onClose: undefined,
|
553
|
+
children: undefined,
|
554
|
+
size: 'sm'
|
533
555
|
};
|
534
556
|
|
535
557
|
/* eslint-disable react-hooks/rules-of-hooks */
|
536
|
-
const DataTable = ({
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
558
|
+
const DataTable = /*#__PURE__*/forwardRef$2((props, ref) => {
|
559
|
+
const {
|
560
|
+
columns,
|
561
|
+
dataSource = [],
|
562
|
+
isLoading,
|
563
|
+
withSelectedRow,
|
564
|
+
onSelectedRow,
|
565
|
+
onSort,
|
566
|
+
sortDescFirst,
|
567
|
+
styles,
|
568
|
+
sortingState,
|
569
|
+
headerSticky,
|
570
|
+
manualSorting,
|
571
|
+
onRowClick
|
572
|
+
} = props;
|
573
|
+
const [isFirstLoad, setIsFirstLoad] = useState(true);
|
548
574
|
const [sorting, setSorting] = useState(sortingState !== null && sortingState !== void 0 ? sortingState : []);
|
549
575
|
const [rowSelection, onRowSelectionChange] = useState({});
|
550
576
|
const dataColumns = useMemo(() => columns, [columns]);
|
@@ -552,16 +578,20 @@ const DataTable = ({
|
|
552
578
|
id: 'select',
|
553
579
|
header: ({
|
554
580
|
table
|
555
|
-
}) => /*#__PURE__*/createElement(
|
556
|
-
|
557
|
-
|
581
|
+
}) => /*#__PURE__*/createElement(Checkbox$1, Object.assign({
|
582
|
+
"data-test-id": "select-header-data-table"
|
583
|
+
}, {
|
584
|
+
isChecked: table.getIsAllRowsSelected(),
|
585
|
+
isIndeterminate: table.getIsSomeRowsSelected(),
|
558
586
|
onChange: table.getToggleAllRowsSelectedHandler()
|
559
587
|
})),
|
560
588
|
cell: ({
|
561
589
|
row
|
562
|
-
}) => /*#__PURE__*/createElement(
|
563
|
-
|
564
|
-
|
590
|
+
}) => /*#__PURE__*/createElement(Checkbox$1, Object.assign({
|
591
|
+
"data-test-id": `select-data-table-${row.index}`
|
592
|
+
}, {
|
593
|
+
isChecked: row.getIsSelected(),
|
594
|
+
isIndeterminate: row.getIsSomeSelected(),
|
565
595
|
onChange: row.getToggleSelectedHandler()
|
566
596
|
}))
|
567
597
|
}], []);
|
@@ -573,9 +603,6 @@ const DataTable = ({
|
|
573
603
|
};
|
574
604
|
const onSortingChange = data => {
|
575
605
|
setSorting(data);
|
576
|
-
if (onSort) {
|
577
|
-
onSort(data);
|
578
|
-
}
|
579
606
|
};
|
580
607
|
const table = useReactTable({
|
581
608
|
data: dataSource,
|
@@ -583,24 +610,39 @@ const DataTable = ({
|
|
583
610
|
getCoreRowModel: getCoreRowModel(),
|
584
611
|
getSortedRowModel: getSortedRowModel(),
|
585
612
|
manualPagination: true,
|
586
|
-
|
613
|
+
manualSorting,
|
614
|
+
sortDescFirst,
|
587
615
|
state: {
|
588
616
|
sorting,
|
589
617
|
rowSelection
|
590
618
|
},
|
591
619
|
onRowSelectionChange,
|
592
|
-
onSortingChange
|
593
|
-
manualSorting
|
620
|
+
onSortingChange
|
594
621
|
});
|
622
|
+
const {
|
623
|
+
getSelectedRowModel,
|
624
|
+
toggleAllRowsSelected
|
625
|
+
} = table;
|
595
626
|
const {
|
596
627
|
flatRows
|
597
|
-
} =
|
628
|
+
} = getSelectedRowModel();
|
598
629
|
useEffect(() => {
|
599
630
|
const rowData = flatRows.map(row => row.original);
|
600
631
|
if (onSelectedRow) {
|
601
632
|
onSelectedRow(rowData);
|
602
633
|
}
|
603
634
|
}, [flatRows]);
|
635
|
+
useImperativeHandle(ref, () => ({
|
636
|
+
toggleAllRowsSelected
|
637
|
+
}));
|
638
|
+
useEffect(() => {
|
639
|
+
if (onSort && !isFirstLoad) {
|
640
|
+
onSort(sorting);
|
641
|
+
}
|
642
|
+
}, [sorting]);
|
643
|
+
useEffect(() => {
|
644
|
+
setIsFirstLoad(false);
|
645
|
+
}, []);
|
604
646
|
return /*#__PURE__*/createElement(Box, Object.assign({}, props), isLoading && /*#__PURE__*/createElement(Flex, {
|
605
647
|
w: "100%",
|
606
648
|
h: "100%",
|
@@ -613,7 +655,12 @@ const DataTable = ({
|
|
613
655
|
color: "primary.500",
|
614
656
|
thickness: "4px",
|
615
657
|
size: "lg"
|
616
|
-
})), /*#__PURE__*/createElement(Table, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.table), /*#__PURE__*/createElement(Thead, Object.assign({},
|
658
|
+
})), /*#__PURE__*/createElement(Table, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.table), /*#__PURE__*/createElement(Thead, Object.assign({}, (headerSticky ? {
|
659
|
+
position: 'sticky',
|
660
|
+
top: 0,
|
661
|
+
bg: 'white',
|
662
|
+
zIndex: 1
|
663
|
+
} : {})), table.getHeaderGroups().map(headerGroup => /*#__PURE__*/createElement(Tr, Object.assign({
|
617
664
|
key: headerGroup.id,
|
618
665
|
bg: useColorModeValue('initial', 'ebony-clay.700')
|
619
666
|
}, styles === null || styles === void 0 ? void 0 : styles.tableRow), headerGroup.headers.map(header => {
|
@@ -645,6 +692,7 @@ const DataTable = ({
|
|
645
692
|
h: 2
|
646
693
|
}))));
|
647
694
|
})))), /*#__PURE__*/createElement(Tbody, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.tableBody), table.getRowModel().rows.map(row => /*#__PURE__*/createElement(Tr, Object.assign({
|
695
|
+
"data-test-id": "6aZAeefGHBA2oG1wLuv-L",
|
648
696
|
key: row.id
|
649
697
|
}, styles === null || styles === void 0 ? void 0 : styles.tableRow, {
|
650
698
|
css: css`
|
@@ -653,13 +701,18 @@ const DataTable = ({
|
|
653
701
|
border-bottom: none;
|
654
702
|
}
|
655
703
|
}
|
656
|
-
|
704
|
+
`,
|
705
|
+
onClick: () => {
|
706
|
+
if (onRowClick) {
|
707
|
+
onRowClick(row.original);
|
708
|
+
}
|
709
|
+
}
|
657
710
|
}), row.getVisibleCells().map(cell => /*#__PURE__*/createElement(Td, Object.assign({
|
658
711
|
key: cell.id,
|
659
712
|
fontSize: "text.sm",
|
660
713
|
color: useColorModeValue('dark.800', 'dark.300')
|
661
714
|
}, styles === null || styles === void 0 ? void 0 : styles.tableCell), flexRender(cell.column.columnDef.cell, cell.getContext()))))))));
|
662
|
-
};
|
715
|
+
});
|
663
716
|
/* eslint-disable react/default-props-match-prop-types */
|
664
717
|
DataTable.defaultProps = {
|
665
718
|
withSelectedRow: false,
|
@@ -673,7 +726,10 @@ DataTable.defaultProps = {
|
|
673
726
|
onSelectedRow: undefined,
|
674
727
|
onSort: undefined,
|
675
728
|
manualSorting: false,
|
676
|
-
sortingState: []
|
729
|
+
sortingState: [],
|
730
|
+
sortDescFirst: false,
|
731
|
+
headerSticky: false,
|
732
|
+
onRowClick: undefined
|
677
733
|
};
|
678
734
|
|
679
735
|
const getProperties = props => {
|
@@ -3936,7 +3992,7 @@ const Checkbox = /*#__PURE__*/defineMultiStyleConfig$1({
|
|
3936
3992
|
}
|
3937
3993
|
});
|
3938
3994
|
|
3939
|
-
const Chips = /*#__PURE__*/defineStyleConfig({
|
3995
|
+
const Chips$1 = /*#__PURE__*/defineStyleConfig({
|
3940
3996
|
baseStyle: props => {
|
3941
3997
|
const {
|
3942
3998
|
isDisabled,
|
@@ -4123,6 +4179,7 @@ const rotate = /*#__PURE__*/keyframes({
|
|
4123
4179
|
const getLoaderColor = color => {
|
4124
4180
|
if (color === 'primary') return colors.primary[600];
|
4125
4181
|
if (color === 'danger') return colors.danger[500];
|
4182
|
+
if (color === 'warning') return colors.warning[700];
|
4126
4183
|
return colors.white.high;
|
4127
4184
|
};
|
4128
4185
|
const LoaderStyle = /*#__PURE__*/defineStyleConfig({
|
@@ -4481,7 +4538,7 @@ var components = {
|
|
4481
4538
|
Button: Button$1,
|
4482
4539
|
Card: CardStyle,
|
4483
4540
|
Checkbox: Checkbox,
|
4484
|
-
Chips: Chips,
|
4541
|
+
Chips: Chips$1,
|
4485
4542
|
FormLabel: FormLabel,
|
4486
4543
|
Input: Input,
|
4487
4544
|
LoaderStyle: LoaderStyle,
|
@@ -4578,5 +4635,5 @@ function useFetcher() {
|
|
4578
4635
|
};
|
4579
4636
|
}
|
4580
4637
|
|
4581
|
-
export { Alert, AlertAction, AlertClose, AlertDescription, AlertIcon, AlertTitle, Badge, BreadCrumb, Button, CardCustom as Card, CheckboxComponent as Checkbox, CheckboxGroupComponent as CheckboxGroup, DataTable, DatePickerMonth, Datepicker, Field, Header, InputAddonLeft, InputAddonRight, InputField, Loader, Navigation as MainMenu, ModalBody, ModalCloseButton, ModalFooter, ModalHeader, MultiDatePickerMonth, Pagination, PaginationDetail, PaginationFilter, Provider, ProviderContext, RadioComponent as Radio, RadioGroupComponent as RadioGroup, Rating, Select, SelectAsync, SelectAsyncCreatable, SelectCreatable, Switch, Tab, TabList, TabPanel, TextareaField, Uploader, foundations, theme, useAlertStyles, useFetcher, useInternalUI };
|
4638
|
+
export { Alert, AlertAction, AlertClose, AlertDescription, AlertIcon, AlertTitle, Badge, BreadCrumb, Button, CardCustom as Card, CheckboxComponent as Checkbox, CheckboxGroupComponent as CheckboxGroup, Chips, DataTable, DatePickerMonth, Datepicker, Field, Header, InputAddonLeft, InputAddonRight, InputField, Loader, Navigation as MainMenu, ModalBody, ModalCloseButton, ModalFooter, ModalHeader, MultiDatePickerMonth, Pagination, PaginationDetail, PaginationFilter, Provider, ProviderContext, RadioComponent as Radio, RadioGroupComponent as RadioGroup, Rating, Select, SelectAsync, SelectAsyncCreatable, SelectCreatable, Switch, Tab, TabList, TabPanel, TextareaField, Uploader, foundations, theme, useAlertStyles, useFetcher, useInternalUI };
|
4582
4639
|
//# sourceMappingURL=internal-ui.esm.js.map
|