@ctlyst.id/internal-ui 2.0.8 → 2.0.9
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/data-table/components/indeterminate-checkbox.d.ts +7 -4
- 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 +236 -40
- package/dist/internal-ui.cjs.development.js.map +1 -1
- package/dist/internal-ui.cjs.production.min.js +13 -13
- package/dist/internal-ui.cjs.production.min.js.map +1 -1
- package/dist/internal-ui.esm.js +136 -43
- package/dist/internal-ui.esm.js.map +1 -1
- package/package.json +2 -2
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, useRef, useEffect, useState,
|
3
|
+
import React__default, { createElement, forwardRef as forwardRef$2, useMemo, useRef, useEffect, useState, useImperativeHandle, Fragment, useCallback, createContext as createContext$1, useContext } 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,104 @@ CheckboxGroupComponent.defaultProps = {
|
|
514
514
|
errorMessage: ''
|
515
515
|
};
|
516
516
|
|
517
|
-
const
|
518
|
-
|
517
|
+
const Chips = ({
|
518
|
+
children,
|
519
519
|
...rest
|
520
520
|
}) => {
|
521
|
-
const
|
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'
|
555
|
+
};
|
556
|
+
|
557
|
+
const useCombinedRefs = (...refs) => {
|
558
|
+
const targetRef = useRef();
|
559
|
+
useEffect(() => {
|
560
|
+
refs.forEach(ref => {
|
561
|
+
/* eslint-disable no-param-reassign */
|
562
|
+
if (!ref) return;
|
563
|
+
if (typeof ref === 'function') {
|
564
|
+
ref(targetRef.current);
|
565
|
+
} else {
|
566
|
+
ref.current = targetRef.current;
|
567
|
+
}
|
568
|
+
});
|
569
|
+
}, [refs]);
|
570
|
+
return targetRef;
|
571
|
+
};
|
572
|
+
const IndeterminateCheckbox = /*#__PURE__*/forwardRef$2(({
|
573
|
+
isIndeterminate,
|
574
|
+
isChecked,
|
575
|
+
...rest
|
576
|
+
}, ref) => {
|
577
|
+
const defaultRef = useRef(null);
|
578
|
+
const combinedRef = useCombinedRefs(ref, defaultRef);
|
522
579
|
useEffect(() => {
|
523
|
-
if (
|
524
|
-
|
580
|
+
if (combinedRef !== null && combinedRef !== void 0 && combinedRef.current) {
|
581
|
+
combinedRef.current.indeterminate = isIndeterminate !== null && isIndeterminate !== void 0 ? isIndeterminate : false;
|
525
582
|
}
|
526
|
-
}, [
|
527
|
-
return /*#__PURE__*/createElement(
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
583
|
+
}, [combinedRef, isIndeterminate]);
|
584
|
+
return /*#__PURE__*/React__default.createElement(Checkbox$1, Object.assign({
|
585
|
+
ref: combinedRef,
|
586
|
+
focusBorderColor: "0",
|
587
|
+
isIndeterminate: isIndeterminate,
|
588
|
+
isChecked: isChecked,
|
589
|
+
inputProps: {
|
590
|
+
'data-test-id': `CT_component_indeterminate-checkbox_${rest.id || rest.name}`
|
591
|
+
}
|
592
|
+
}, rest));
|
593
|
+
});
|
594
|
+
IndeterminateCheckbox.displayName = 'IndeterminateCheckbox';
|
595
|
+
IndeterminateCheckbox.defaultProps = {
|
596
|
+
isIndeterminate: false
|
533
597
|
};
|
534
598
|
|
535
599
|
/* eslint-disable react-hooks/rules-of-hooks */
|
536
|
-
const DataTable = ({
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
600
|
+
const DataTable = /*#__PURE__*/forwardRef$2((props, ref) => {
|
601
|
+
const {
|
602
|
+
columns,
|
603
|
+
dataSource = [],
|
604
|
+
isLoading,
|
605
|
+
withSelectedRow,
|
606
|
+
onSelectedRow,
|
607
|
+
onSort,
|
608
|
+
sortDescFirst,
|
609
|
+
styles,
|
610
|
+
sortingState,
|
611
|
+
headerSticky,
|
612
|
+
manualSorting,
|
613
|
+
onRowClick
|
614
|
+
} = props;
|
548
615
|
const [sorting, setSorting] = useState(sortingState !== null && sortingState !== void 0 ? sortingState : []);
|
549
616
|
const [rowSelection, onRowSelectionChange] = useState({});
|
550
617
|
const dataColumns = useMemo(() => columns, [columns]);
|
@@ -552,14 +619,18 @@ const DataTable = ({
|
|
552
619
|
id: 'select',
|
553
620
|
header: ({
|
554
621
|
table
|
555
|
-
}) => /*#__PURE__*/createElement(IndeterminateCheckbox, Object.assign({
|
622
|
+
}) => /*#__PURE__*/createElement(IndeterminateCheckbox, Object.assign({
|
623
|
+
name: "select-header"
|
624
|
+
}, {
|
556
625
|
checked: table.getIsAllRowsSelected(),
|
557
626
|
indeterminate: table.getIsSomeRowsSelected(),
|
558
627
|
onChange: table.getToggleAllRowsSelectedHandler()
|
559
628
|
})),
|
560
629
|
cell: ({
|
561
630
|
row
|
562
|
-
}) => /*#__PURE__*/createElement(IndeterminateCheckbox, Object.assign({
|
631
|
+
}) => /*#__PURE__*/createElement(IndeterminateCheckbox, Object.assign({
|
632
|
+
name: `select-${row.index}`
|
633
|
+
}, {
|
563
634
|
checked: row.getIsSelected(),
|
564
635
|
indeterminate: row.getIsSomeSelected(),
|
565
636
|
onChange: row.getToggleSelectedHandler()
|
@@ -583,24 +654,31 @@ const DataTable = ({
|
|
583
654
|
getCoreRowModel: getCoreRowModel(),
|
584
655
|
getSortedRowModel: getSortedRowModel(),
|
585
656
|
manualPagination: true,
|
586
|
-
|
657
|
+
manualSorting,
|
658
|
+
sortDescFirst,
|
587
659
|
state: {
|
588
660
|
sorting,
|
589
661
|
rowSelection
|
590
662
|
},
|
591
663
|
onRowSelectionChange,
|
592
|
-
onSortingChange
|
593
|
-
manualSorting
|
664
|
+
onSortingChange
|
594
665
|
});
|
666
|
+
const {
|
667
|
+
getSelectedRowModel,
|
668
|
+
toggleAllRowsSelected
|
669
|
+
} = table;
|
595
670
|
const {
|
596
671
|
flatRows
|
597
|
-
} =
|
672
|
+
} = getSelectedRowModel();
|
598
673
|
useEffect(() => {
|
599
674
|
const rowData = flatRows.map(row => row.original);
|
600
675
|
if (onSelectedRow) {
|
601
676
|
onSelectedRow(rowData);
|
602
677
|
}
|
603
678
|
}, [flatRows]);
|
679
|
+
useImperativeHandle(ref, () => ({
|
680
|
+
toggleAllRowsSelected
|
681
|
+
}));
|
604
682
|
return /*#__PURE__*/createElement(Box, Object.assign({}, props), isLoading && /*#__PURE__*/createElement(Flex, {
|
605
683
|
w: "100%",
|
606
684
|
h: "100%",
|
@@ -613,7 +691,12 @@ const DataTable = ({
|
|
613
691
|
color: "primary.500",
|
614
692
|
thickness: "4px",
|
615
693
|
size: "lg"
|
616
|
-
})), /*#__PURE__*/createElement(Table, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.table), /*#__PURE__*/createElement(Thead, Object.assign({},
|
694
|
+
})), /*#__PURE__*/createElement(Table, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.table), /*#__PURE__*/createElement(Thead, Object.assign({}, (headerSticky ? {
|
695
|
+
position: 'sticky',
|
696
|
+
top: 0,
|
697
|
+
bg: 'white',
|
698
|
+
zIndex: 1
|
699
|
+
} : {})), table.getHeaderGroups().map(headerGroup => /*#__PURE__*/createElement(Tr, Object.assign({
|
617
700
|
key: headerGroup.id,
|
618
701
|
bg: useColorModeValue('initial', 'ebony-clay.700')
|
619
702
|
}, styles === null || styles === void 0 ? void 0 : styles.tableRow), headerGroup.headers.map(header => {
|
@@ -645,21 +728,27 @@ const DataTable = ({
|
|
645
728
|
h: 2
|
646
729
|
}))));
|
647
730
|
})))), /*#__PURE__*/createElement(Tbody, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.tableBody), table.getRowModel().rows.map(row => /*#__PURE__*/createElement(Tr, Object.assign({
|
731
|
+
"data-test-id": "6aZAeefGHBA2oG1wLuv-L",
|
648
732
|
key: row.id
|
649
733
|
}, styles === null || styles === void 0 ? void 0 : styles.tableRow, {
|
650
734
|
css: css`
|
651
|
-
|
652
|
-
|
653
|
-
|
735
|
+
&:last-child {
|
736
|
+
td {
|
737
|
+
border-bottom: none;
|
738
|
+
}
|
654
739
|
}
|
655
|
-
|
656
|
-
|
740
|
+
`,
|
741
|
+
onClick: () => {
|
742
|
+
if (onRowClick) {
|
743
|
+
onRowClick(row.original);
|
744
|
+
}
|
745
|
+
}
|
657
746
|
}), row.getVisibleCells().map(cell => /*#__PURE__*/createElement(Td, Object.assign({
|
658
747
|
key: cell.id,
|
659
748
|
fontSize: "text.sm",
|
660
749
|
color: useColorModeValue('dark.800', 'dark.300')
|
661
750
|
}, styles === null || styles === void 0 ? void 0 : styles.tableCell), flexRender(cell.column.columnDef.cell, cell.getContext()))))))));
|
662
|
-
};
|
751
|
+
});
|
663
752
|
/* eslint-disable react/default-props-match-prop-types */
|
664
753
|
DataTable.defaultProps = {
|
665
754
|
withSelectedRow: false,
|
@@ -673,7 +762,10 @@ DataTable.defaultProps = {
|
|
673
762
|
onSelectedRow: undefined,
|
674
763
|
onSort: undefined,
|
675
764
|
manualSorting: false,
|
676
|
-
sortingState: []
|
765
|
+
sortingState: [],
|
766
|
+
sortDescFirst: false,
|
767
|
+
headerSticky: false,
|
768
|
+
onRowClick: undefined
|
677
769
|
};
|
678
770
|
|
679
771
|
const getProperties = props => {
|
@@ -3936,7 +4028,7 @@ const Checkbox = /*#__PURE__*/defineMultiStyleConfig$1({
|
|
3936
4028
|
}
|
3937
4029
|
});
|
3938
4030
|
|
3939
|
-
const Chips = /*#__PURE__*/defineStyleConfig({
|
4031
|
+
const Chips$1 = /*#__PURE__*/defineStyleConfig({
|
3940
4032
|
baseStyle: props => {
|
3941
4033
|
const {
|
3942
4034
|
isDisabled,
|
@@ -4123,6 +4215,7 @@ const rotate = /*#__PURE__*/keyframes({
|
|
4123
4215
|
const getLoaderColor = color => {
|
4124
4216
|
if (color === 'primary') return colors.primary[600];
|
4125
4217
|
if (color === 'danger') return colors.danger[500];
|
4218
|
+
if (color === 'warning') return colors.warning[700];
|
4126
4219
|
return colors.white.high;
|
4127
4220
|
};
|
4128
4221
|
const LoaderStyle = /*#__PURE__*/defineStyleConfig({
|
@@ -4481,7 +4574,7 @@ var components = {
|
|
4481
4574
|
Button: Button$1,
|
4482
4575
|
Card: CardStyle,
|
4483
4576
|
Checkbox: Checkbox,
|
4484
|
-
Chips: Chips,
|
4577
|
+
Chips: Chips$1,
|
4485
4578
|
FormLabel: FormLabel,
|
4486
4579
|
Input: Input,
|
4487
4580
|
LoaderStyle: LoaderStyle,
|
@@ -4578,5 +4671,5 @@ function useFetcher() {
|
|
4578
4671
|
};
|
4579
4672
|
}
|
4580
4673
|
|
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 };
|
4674
|
+
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
4675
|
//# sourceMappingURL=internal-ui.esm.js.map
|