@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.
@@ -4,23 +4,9 @@ declare const _default: {
4
4
  chakra: {
5
5
  theme: Record<string, any>;
6
6
  };
7
- component: {
8
- <P>({ columns, dataSource, isLoading, withSelectedRow, onSelectedRow, onSort, manualSorting, sortingState, styles, ...props }: import("../components/data-table").DataTableProps<P>): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>;
9
- defaultProps: {
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, ColumnSort, SortingState } from '@tanstack/react-table';
2
+ import type { ColumnDef, ColumnSort, 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: ColumnSort[] | ((prevState: SortingState) => SortingState)) => void;
19
+ onSort?: (data: ColumnSort[] | SortingState | ((prevState: SortingState) => 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 const DataTable: {
24
- <P>({ columns, dataSource, isLoading, withSelectedRow, onSelectedRow, onSort, manualSorting, sortingState, styles, ...props }: DataTableProps<P>): React.ReactElement;
25
- defaultProps: {
26
- withSelectedRow: boolean;
27
- overflowX: string;
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;
@@ -1,5 +1,8 @@
1
- import * as React from 'react';
2
- declare const IndeterminateCheckbox: ({ indeterminate, ...rest }: {
3
- indeterminate: boolean;
4
- } & React.HTMLProps<HTMLInputElement>) => JSX.Element;
1
+ import type { CheckboxProps } from '@chakra-ui/react';
2
+ import React from 'react';
3
+ interface IndeterminateCheckboxProps extends CheckboxProps {
4
+ isIndeterminate?: boolean;
5
+ name: string;
6
+ }
7
+ declare const IndeterminateCheckbox: React.ForwardRefExoticComponent<IndeterminateCheckboxProps & React.RefAttributes<HTMLInputElement>>;
5
8
  export default IndeterminateCheckbox;
@@ -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';
@@ -2,6 +2,7 @@ import type { HTMLChakraProps, ThemingProps } from '@chakra-ui/react';
2
2
  export interface LoaderProps {
3
3
  size?: string;
4
4
  variant?: string;
5
+ thickness?: string;
5
6
  }
6
7
  export interface CustomBadgeProps extends HTMLChakraProps<'span'>, ThemingProps {
7
8
  }
@@ -520,37 +520,104 @@ CheckboxGroupComponent.defaultProps = {
520
520
  errorMessage: ''
521
521
  };
522
522
 
523
- const IndeterminateCheckbox = ({
524
- indeterminate = false,
523
+ const Chips = ({
524
+ children,
525
525
  ...rest
526
526
  }) => {
527
- const ref = React.useRef(null);
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'
561
+ };
562
+
563
+ const useCombinedRefs = (...refs) => {
564
+ const targetRef = React.useRef();
565
+ React.useEffect(() => {
566
+ refs.forEach(ref => {
567
+ /* eslint-disable no-param-reassign */
568
+ if (!ref) return;
569
+ if (typeof ref === 'function') {
570
+ ref(targetRef.current);
571
+ } else {
572
+ ref.current = targetRef.current;
573
+ }
574
+ });
575
+ }, [refs]);
576
+ return targetRef;
577
+ };
578
+ const IndeterminateCheckbox = /*#__PURE__*/React.forwardRef(({
579
+ isIndeterminate,
580
+ isChecked,
581
+ ...rest
582
+ }, ref) => {
583
+ const defaultRef = React.useRef(null);
584
+ const combinedRef = useCombinedRefs(ref, defaultRef);
528
585
  React.useEffect(() => {
529
- if (ref.current && typeof indeterminate === 'boolean') {
530
- ref.current.indeterminate = !rest.checked && indeterminate;
586
+ if (combinedRef !== null && combinedRef !== void 0 && combinedRef.current) {
587
+ combinedRef.current.indeterminate = isIndeterminate !== null && isIndeterminate !== void 0 ? isIndeterminate : false;
531
588
  }
532
- }, [ref, indeterminate]);
533
- return /*#__PURE__*/React.createElement(react.Flex, {
534
- align: "center"
535
- }, /*#__PURE__*/React.createElement("input", Object.assign({
536
- type: "checkbox",
537
- ref: ref
538
- }, rest)));
589
+ }, [combinedRef, isIndeterminate]);
590
+ return /*#__PURE__*/React__default.createElement(react.Checkbox, Object.assign({
591
+ ref: combinedRef,
592
+ focusBorderColor: "0",
593
+ isIndeterminate: isIndeterminate,
594
+ isChecked: isChecked,
595
+ inputProps: {
596
+ 'data-test-id': `CT_component_indeterminate-checkbox_${rest.id || rest.name}`
597
+ }
598
+ }, rest));
599
+ });
600
+ IndeterminateCheckbox.displayName = 'IndeterminateCheckbox';
601
+ IndeterminateCheckbox.defaultProps = {
602
+ isIndeterminate: false
539
603
  };
540
604
 
541
605
  /* eslint-disable react-hooks/rules-of-hooks */
542
- const DataTable = ({
543
- columns,
544
- dataSource = [],
545
- isLoading,
546
- withSelectedRow,
547
- onSelectedRow,
548
- onSort,
549
- manualSorting,
550
- sortingState,
551
- styles,
552
- ...props
553
- }) => {
606
+ const DataTable = /*#__PURE__*/React.forwardRef((props, ref) => {
607
+ const {
608
+ columns,
609
+ dataSource = [],
610
+ isLoading,
611
+ withSelectedRow,
612
+ onSelectedRow,
613
+ onSort,
614
+ sortDescFirst,
615
+ styles,
616
+ sortingState,
617
+ headerSticky,
618
+ manualSorting,
619
+ onRowClick
620
+ } = props;
554
621
  const [sorting, setSorting] = React.useState(sortingState !== null && sortingState !== void 0 ? sortingState : []);
555
622
  const [rowSelection, onRowSelectionChange] = React.useState({});
556
623
  const dataColumns = React.useMemo(() => columns, [columns]);
@@ -558,14 +625,18 @@ const DataTable = ({
558
625
  id: 'select',
559
626
  header: ({
560
627
  table
561
- }) => /*#__PURE__*/React.createElement(IndeterminateCheckbox, Object.assign({}, {
628
+ }) => /*#__PURE__*/React.createElement(IndeterminateCheckbox, Object.assign({
629
+ name: "select-header"
630
+ }, {
562
631
  checked: table.getIsAllRowsSelected(),
563
632
  indeterminate: table.getIsSomeRowsSelected(),
564
633
  onChange: table.getToggleAllRowsSelectedHandler()
565
634
  })),
566
635
  cell: ({
567
636
  row
568
- }) => /*#__PURE__*/React.createElement(IndeterminateCheckbox, Object.assign({}, {
637
+ }) => /*#__PURE__*/React.createElement(IndeterminateCheckbox, Object.assign({
638
+ name: `select-${row.index}`
639
+ }, {
569
640
  checked: row.getIsSelected(),
570
641
  indeterminate: row.getIsSomeSelected(),
571
642
  onChange: row.getToggleSelectedHandler()
@@ -589,24 +660,31 @@ const DataTable = ({
589
660
  getCoreRowModel: reactTable.getCoreRowModel(),
590
661
  getSortedRowModel: reactTable.getSortedRowModel(),
591
662
  manualPagination: true,
592
- sortDescFirst: true,
663
+ manualSorting,
664
+ sortDescFirst,
593
665
  state: {
594
666
  sorting,
595
667
  rowSelection
596
668
  },
597
669
  onRowSelectionChange,
598
- onSortingChange,
599
- manualSorting
670
+ onSortingChange
600
671
  });
672
+ const {
673
+ getSelectedRowModel,
674
+ toggleAllRowsSelected
675
+ } = table;
601
676
  const {
602
677
  flatRows
603
- } = table.getSelectedRowModel();
678
+ } = getSelectedRowModel();
604
679
  React.useEffect(() => {
605
680
  const rowData = flatRows.map(row => row.original);
606
681
  if (onSelectedRow) {
607
682
  onSelectedRow(rowData);
608
683
  }
609
684
  }, [flatRows]);
685
+ React.useImperativeHandle(ref, () => ({
686
+ toggleAllRowsSelected
687
+ }));
610
688
  return /*#__PURE__*/React.createElement(react.Box, Object.assign({}, props), isLoading && /*#__PURE__*/React.createElement(react.Flex, {
611
689
  w: "100%",
612
690
  h: "100%",
@@ -619,7 +697,12 @@ const DataTable = ({
619
697
  color: "primary.500",
620
698
  thickness: "4px",
621
699
  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({}, styles === null || styles === void 0 ? void 0 : styles.tableHead), table.getHeaderGroups().map(headerGroup => /*#__PURE__*/React.createElement(react.Tr, Object.assign({
700
+ })), /*#__PURE__*/React.createElement(react.Table, Object.assign({}, styles === null || styles === void 0 ? void 0 : styles.table), /*#__PURE__*/React.createElement(react.Thead, Object.assign({}, (headerSticky ? {
701
+ position: 'sticky',
702
+ top: 0,
703
+ bg: 'white',
704
+ zIndex: 1
705
+ } : {})), table.getHeaderGroups().map(headerGroup => /*#__PURE__*/React.createElement(react.Tr, Object.assign({
623
706
  key: headerGroup.id,
624
707
  bg: react.useColorModeValue('initial', 'ebony-clay.700')
625
708
  }, styles === null || styles === void 0 ? void 0 : styles.tableRow), headerGroup.headers.map(header => {
@@ -651,21 +734,27 @@ const DataTable = ({
651
734
  h: 2
652
735
  }))));
653
736
  })))), /*#__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({
737
+ "data-test-id": "6aZAeefGHBA2oG1wLuv-L",
654
738
  key: row.id
655
739
  }, styles === null || styles === void 0 ? void 0 : styles.tableRow, {
656
740
  css: react$1.css`
657
- &:last-child {
658
- td {
659
- border-bottom: none;
741
+ &:last-child {
742
+ td {
743
+ border-bottom: none;
744
+ }
660
745
  }
661
- }
662
- `
746
+ `,
747
+ onClick: () => {
748
+ if (onRowClick) {
749
+ onRowClick(row.original);
750
+ }
751
+ }
663
752
  }), row.getVisibleCells().map(cell => /*#__PURE__*/React.createElement(react.Td, Object.assign({
664
753
  key: cell.id,
665
754
  fontSize: "text.sm",
666
755
  color: react.useColorModeValue('dark.800', 'dark.300')
667
756
  }, styles === null || styles === void 0 ? void 0 : styles.tableCell), reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()))))))));
668
- };
757
+ });
669
758
  /* eslint-disable react/default-props-match-prop-types */
670
759
  DataTable.defaultProps = {
671
760
  withSelectedRow: false,
@@ -679,7 +768,10 @@ DataTable.defaultProps = {
679
768
  onSelectedRow: undefined,
680
769
  onSort: undefined,
681
770
  manualSorting: false,
682
- sortingState: []
771
+ sortingState: [],
772
+ sortDescFirst: false,
773
+ headerSticky: false,
774
+ onRowClick: undefined
683
775
  };
684
776
 
685
777
  const getProperties = props => {
@@ -3942,7 +4034,7 @@ const Checkbox = /*#__PURE__*/defineMultiStyleConfig$1({
3942
4034
  }
3943
4035
  });
3944
4036
 
3945
- const Chips = /*#__PURE__*/styledSystem.defineStyleConfig({
4037
+ const Chips$1 = /*#__PURE__*/styledSystem.defineStyleConfig({
3946
4038
  baseStyle: props => {
3947
4039
  const {
3948
4040
  isDisabled,
@@ -4129,6 +4221,7 @@ const rotate = /*#__PURE__*/react$1.keyframes({
4129
4221
  const getLoaderColor = color => {
4130
4222
  if (color === 'primary') return colors.primary[600];
4131
4223
  if (color === 'danger') return colors.danger[500];
4224
+ if (color === 'warning') return colors.warning[700];
4132
4225
  return colors.white.high;
4133
4226
  };
4134
4227
  const LoaderStyle = /*#__PURE__*/styledSystem.defineStyleConfig({
@@ -4487,7 +4580,7 @@ var components = {
4487
4580
  Button: Button$1,
4488
4581
  Card: CardStyle,
4489
4582
  Checkbox: Checkbox,
4490
- Chips: Chips,
4583
+ Chips: Chips$1,
4491
4584
  FormLabel: FormLabel,
4492
4585
  Input: Input,
4493
4586
  LoaderStyle: LoaderStyle,
@@ -4734,6 +4827,18 @@ Object.defineProperty(exports, 'Heading', {
4734
4827
  return react.Heading;
4735
4828
  }
4736
4829
  });
4830
+ Object.defineProperty(exports, 'Icon', {
4831
+ enumerable: true,
4832
+ get: function () {
4833
+ return react.Icon;
4834
+ }
4835
+ });
4836
+ Object.defineProperty(exports, 'Image', {
4837
+ enumerable: true,
4838
+ get: function () {
4839
+ return react.Image;
4840
+ }
4841
+ });
4737
4842
  Object.defineProperty(exports, 'InputElementLeft', {
4738
4843
  enumerable: true,
4739
4844
  get: function () {
@@ -4746,6 +4851,24 @@ Object.defineProperty(exports, 'InputElementRight', {
4746
4851
  return react.InputRightElement;
4747
4852
  }
4748
4853
  });
4854
+ Object.defineProperty(exports, 'List', {
4855
+ enumerable: true,
4856
+ get: function () {
4857
+ return react.List;
4858
+ }
4859
+ });
4860
+ Object.defineProperty(exports, 'ListIcon', {
4861
+ enumerable: true,
4862
+ get: function () {
4863
+ return react.ListIcon;
4864
+ }
4865
+ });
4866
+ Object.defineProperty(exports, 'ListItem', {
4867
+ enumerable: true,
4868
+ get: function () {
4869
+ return react.ListItem;
4870
+ }
4871
+ });
4749
4872
  Object.defineProperty(exports, 'Modal', {
4750
4873
  enumerable: true,
4751
4874
  get: function () {
@@ -4776,6 +4899,72 @@ Object.defineProperty(exports, 'ModalOverlay', {
4776
4899
  return react.ModalOverlay;
4777
4900
  }
4778
4901
  });
4902
+ Object.defineProperty(exports, 'OrderedList', {
4903
+ enumerable: true,
4904
+ get: function () {
4905
+ return react.OrderedList;
4906
+ }
4907
+ });
4908
+ Object.defineProperty(exports, 'Popover', {
4909
+ enumerable: true,
4910
+ get: function () {
4911
+ return react.Popover;
4912
+ }
4913
+ });
4914
+ Object.defineProperty(exports, 'PopoverAnchor', {
4915
+ enumerable: true,
4916
+ get: function () {
4917
+ return react.PopoverAnchor;
4918
+ }
4919
+ });
4920
+ Object.defineProperty(exports, 'PopoverArrow', {
4921
+ enumerable: true,
4922
+ get: function () {
4923
+ return react.PopoverArrow;
4924
+ }
4925
+ });
4926
+ Object.defineProperty(exports, 'PopoverBody', {
4927
+ enumerable: true,
4928
+ get: function () {
4929
+ return react.PopoverBody;
4930
+ }
4931
+ });
4932
+ Object.defineProperty(exports, 'PopoverCloseButton', {
4933
+ enumerable: true,
4934
+ get: function () {
4935
+ return react.PopoverCloseButton;
4936
+ }
4937
+ });
4938
+ Object.defineProperty(exports, 'PopoverContent', {
4939
+ enumerable: true,
4940
+ get: function () {
4941
+ return react.PopoverContent;
4942
+ }
4943
+ });
4944
+ Object.defineProperty(exports, 'PopoverFooter', {
4945
+ enumerable: true,
4946
+ get: function () {
4947
+ return react.PopoverFooter;
4948
+ }
4949
+ });
4950
+ Object.defineProperty(exports, 'PopoverHeader', {
4951
+ enumerable: true,
4952
+ get: function () {
4953
+ return react.PopoverHeader;
4954
+ }
4955
+ });
4956
+ Object.defineProperty(exports, 'PopoverTrigger', {
4957
+ enumerable: true,
4958
+ get: function () {
4959
+ return react.PopoverTrigger;
4960
+ }
4961
+ });
4962
+ Object.defineProperty(exports, 'Portal', {
4963
+ enumerable: true,
4964
+ get: function () {
4965
+ return react.Portal;
4966
+ }
4967
+ });
4779
4968
  Object.defineProperty(exports, 'Stack', {
4780
4969
  enumerable: true,
4781
4970
  get: function () {
@@ -4824,6 +5013,12 @@ Object.defineProperty(exports, 'Tooltip', {
4824
5013
  return react.Tooltip;
4825
5014
  }
4826
5015
  });
5016
+ Object.defineProperty(exports, 'UnorderedList', {
5017
+ enumerable: true,
5018
+ get: function () {
5019
+ return react.UnorderedList;
5020
+ }
5021
+ });
4827
5022
  Object.defineProperty(exports, 'VStack', {
4828
5023
  enumerable: true,
4829
5024
  get: function () {
@@ -4962,6 +5157,7 @@ exports.Button = Button;
4962
5157
  exports.Card = CardCustom;
4963
5158
  exports.Checkbox = CheckboxComponent;
4964
5159
  exports.CheckboxGroup = CheckboxGroupComponent;
5160
+ exports.Chips = Chips;
4965
5161
  exports.DataTable = DataTable;
4966
5162
  exports.DatePickerMonth = DatePickerMonth;
4967
5163
  exports.Datepicker = Datepicker;