@antscorp/antsomi-ui 1.6.1 → 1.6.2

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.
Files changed (149) hide show
  1. package/es/components/atoms/Input/Input.d.ts +3 -0
  2. package/es/components/atoms/Input/Input.js +4 -1
  3. package/es/components/atoms/InputNumber/InputNumber.d.ts +1 -0
  4. package/es/components/atoms/InputNumber/InputNumber.js +21 -0
  5. package/es/components/atoms/InputNumber/index.d.ts +1 -1
  6. package/es/components/atoms/InputNumber/index.js +1 -1
  7. package/es/components/atoms/Scrollbars/Scrollbars.js +3 -3
  8. package/es/components/atoms/index.d.ts +1 -1
  9. package/es/components/atoms/index.js +1 -1
  10. package/es/components/molecules/AccountSelection/index.d.ts +2 -1
  11. package/es/components/molecules/EditableName/index.d.ts +2 -1
  12. package/es/components/molecules/EmptyData/EmptyData.d.ts +3 -1
  13. package/es/components/molecules/EmptyData/EmptyData.js +17 -5
  14. package/es/components/molecules/EmptyData/styled.js +1 -0
  15. package/es/components/molecules/ThumbnailCard/ThumbnailCard.js +1 -1
  16. package/es/components/molecules/Tree/Tree.d.ts +2 -0
  17. package/es/components/molecules/Tree/Tree.js +1 -0
  18. package/es/components/molecules/Tree/index.d.ts +1 -0
  19. package/es/components/molecules/Tree/index.js +1 -0
  20. package/es/components/molecules/VirtualizedMenu/index.d.ts +1 -1
  21. package/es/components/molecules/index.d.ts +1 -0
  22. package/es/components/molecules/index.js +1 -0
  23. package/es/components/organism/DataTable/DataTable.d.ts +4 -1
  24. package/es/components/organism/DataTable/DataTable.js +23 -11
  25. package/es/components/organism/DataTable/components/Filter/AddFilterButton.js +25 -22
  26. package/es/components/organism/DataTable/components/Filter/FilterActionButton.d.ts +5 -0
  27. package/es/components/organism/DataTable/components/Filter/FilterActionButton.js +126 -0
  28. package/es/components/organism/DataTable/components/Filter/FilterCondition/index.d.ts +14 -0
  29. package/es/components/organism/DataTable/components/Filter/FilterCondition/index.js +99 -0
  30. package/es/components/organism/DataTable/components/Filter/FilterCondition/styled.d.ts +3 -0
  31. package/es/components/organism/DataTable/components/Filter/FilterCondition/styled.js +42 -0
  32. package/es/components/organism/DataTable/components/Filter/FilterCondition/utils.d.ts +0 -0
  33. package/es/components/organism/DataTable/components/Filter/FilterCondition/utils.js +1 -0
  34. package/es/components/organism/DataTable/components/Filter/FilterConditionList.d.ts +5 -0
  35. package/es/components/organism/DataTable/components/Filter/FilterConditionList.js +117 -0
  36. package/es/components/organism/DataTable/components/Filter/FilterItem.d.ts +10 -0
  37. package/es/components/organism/DataTable/components/Filter/FilterItem.js +36 -0
  38. package/es/components/organism/DataTable/components/Filter/SaveFilterPopover.d.ts +9 -0
  39. package/es/components/organism/DataTable/components/Filter/SaveFilterPopover.js +54 -0
  40. package/es/components/organism/DataTable/components/Filter/SavedFilterAndMetrics.d.ts +3 -2
  41. package/es/components/organism/DataTable/components/Filter/SavedFilterAndMetrics.js +53 -91
  42. package/es/components/organism/DataTable/components/Filter/index.js +12 -17
  43. package/es/components/organism/DataTable/components/Filter/styled.d.ts +2 -1
  44. package/es/components/organism/DataTable/components/Filter/styled.js +56 -11
  45. package/es/components/organism/DataTable/components/ModifyColumn/index.d.ts +3 -2
  46. package/es/components/organism/DataTable/components/ModifyColumn/index.js +82 -16
  47. package/es/components/organism/DataTable/components/ModifyColumn/styled.d.ts +2 -0
  48. package/es/components/organism/DataTable/components/ModifyColumn/styled.js +5 -0
  49. package/es/components/organism/DataTable/components/Pagination/index.d.ts +2 -3
  50. package/es/components/organism/DataTable/components/Table/index.js +9 -4
  51. package/es/components/organism/DataTable/components/Toolbar/RowSelectedControl.d.ts +5 -0
  52. package/es/components/organism/DataTable/components/Toolbar/RowSelectedControl.js +30 -0
  53. package/es/components/organism/DataTable/components/Toolbar/SearchPopover.d.ts +8 -0
  54. package/es/components/organism/DataTable/components/Toolbar/SearchPopover.js +122 -0
  55. package/es/components/organism/DataTable/components/Toolbar/ToolbarActionButtons.js +74 -0
  56. package/es/components/organism/DataTable/components/Toolbar/index.js +19 -8
  57. package/es/components/organism/DataTable/components/Toolbar/styled.d.ts +6 -1
  58. package/es/components/organism/DataTable/components/Toolbar/styled.js +38 -2
  59. package/es/components/organism/DataTable/components/common/ApplyPopupContent/index.d.ts +11 -0
  60. package/es/components/organism/DataTable/components/common/ApplyPopupContent/index.js +36 -0
  61. package/es/components/organism/DataTable/components/common/ApplyPopupContent/styled.d.ts +3 -0
  62. package/es/components/organism/DataTable/components/common/ApplyPopupContent/styled.js +42 -0
  63. package/es/components/organism/DataTable/components/common/index.d.ts +0 -0
  64. package/es/components/organism/DataTable/components/common/index.js +1 -0
  65. package/es/components/organism/DataTable/components/index.d.ts +0 -1
  66. package/es/components/organism/DataTable/components/index.js +0 -1
  67. package/es/components/organism/DataTable/constants/filter.d.ts +9 -0
  68. package/es/components/organism/DataTable/constants/filter.js +27 -0
  69. package/es/components/organism/DataTable/constants/index.js +7 -1
  70. package/es/components/organism/DataTable/constants/sample.d.ts +149 -3
  71. package/es/components/organism/DataTable/constants/sample.js +1497 -2
  72. package/es/components/organism/DataTable/constants/theme.js +2 -1
  73. package/es/components/organism/DataTable/constants/toolbar.d.ts +2 -2
  74. package/es/components/organism/DataTable/constants/toolbar.js +1 -0
  75. package/es/components/organism/DataTable/contexts/DataTableContext.js +1 -1
  76. package/es/components/organism/DataTable/hooks/index.d.ts +1 -0
  77. package/es/components/organism/DataTable/hooks/index.js +1 -0
  78. package/es/components/organism/DataTable/hooks/useAddFilterButton.d.ts +22 -0
  79. package/es/components/organism/DataTable/hooks/useAddFilterButton.js +58 -0
  80. package/es/components/organism/DataTable/hooks/useDataTable.d.ts +2 -2
  81. package/es/components/organism/DataTable/hooks/useDataTable.js +16 -4
  82. package/es/components/organism/DataTable/hooks/useDataTableStore.d.ts +28 -0
  83. package/es/components/organism/DataTable/hooks/useDataTableStore.js +36 -0
  84. package/es/components/organism/DataTable/hooks/useTablePerformance.d.ts +0 -0
  85. package/es/components/organism/DataTable/hooks/useTablePerformance.js +1 -0
  86. package/es/components/organism/DataTable/index.d.ts +2 -2
  87. package/es/components/organism/DataTable/index.js +1 -1
  88. package/es/components/organism/DataTable/stores/index.js +3 -3
  89. package/es/components/organism/DataTable/styled/index.d.ts +8 -0
  90. package/es/components/organism/DataTable/styled/index.js +41 -0
  91. package/es/components/organism/DataTable/types/filter.d.ts +21 -1
  92. package/es/components/organism/DataTable/types/index.d.ts +4 -5
  93. package/es/components/organism/DataTable/types/theme.d.ts +1 -0
  94. package/es/components/organism/DataTable/types/toolbar.d.ts +51 -15
  95. package/es/components/organism/DataTable/utils/filter.d.ts +85 -1
  96. package/es/components/organism/DataTable/utils/filter.js +157 -10
  97. package/es/components/organism/ModifyColumnModal/ModifyColumnModal.d.ts +3 -0
  98. package/es/components/organism/ModifyColumnModal/ModifyColumnModal.js +239 -0
  99. package/es/components/organism/ModifyColumnModal/SelectedMetricsList.d.ts +9 -0
  100. package/es/components/organism/ModifyColumnModal/SelectedMetricsList.js +106 -0
  101. package/es/components/organism/ModifyColumnModal/index.d.ts +2 -0
  102. package/es/components/organism/ModifyColumnModal/index.js +1 -0
  103. package/es/components/organism/ModifyColumnModal/styled.d.ts +8 -0
  104. package/es/components/organism/ModifyColumnModal/styled.js +151 -0
  105. package/es/components/organism/ModifyColumnModal/types.d.ts +25 -0
  106. package/es/components/organism/ModifyColumnModal/types.js +1 -0
  107. package/es/components/organism/index.d.ts +1 -0
  108. package/es/components/organism/index.js +1 -0
  109. package/es/constants/condition.d.ts +920 -0
  110. package/es/constants/condition.js +520 -0
  111. package/es/constants/index.d.ts +1 -0
  112. package/es/constants/index.js +1 -0
  113. package/es/constants/theme.js +26 -11
  114. package/es/constants/variables.d.ts +17 -0
  115. package/es/constants/variables.js +18 -0
  116. package/es/hooks/useOutsideClick.d.ts +1 -1
  117. package/es/hooks/useOutsideClick.js +7 -2
  118. package/es/locales/en/translation.json +30 -2
  119. package/es/locales/i18n.d.ts +56 -0
  120. package/es/locales/translations.d.ts +28 -0
  121. package/es/locales/vi/translation.json +30 -2
  122. package/es/providers/ConfigProvider/GlobalStyle.js +46 -9
  123. package/es/services/DataTable/index.d.ts +1 -0
  124. package/es/services/DataTable/index.js +1 -0
  125. package/es/styled/common.d.ts +1 -0
  126. package/es/styled/common.js +24 -0
  127. package/es/styled/index.d.ts +1 -0
  128. package/es/styled/index.js +1 -0
  129. package/es/test.d.ts +11 -0
  130. package/es/test.js +402 -388
  131. package/es/tests/DataTableTest.js +147 -40
  132. package/es/types/actionsButton.d.ts +16 -0
  133. package/es/types/actionsButton.js +1 -0
  134. package/es/types/condition.d.ts +6 -0
  135. package/es/types/condition.js +1 -0
  136. package/es/types/index.d.ts +2 -0
  137. package/es/types/index.js +2 -0
  138. package/es/types/variables.d.ts +0 -17
  139. package/es/utils/actionButtons.d.ts +40 -0
  140. package/es/utils/actionButtons.js +61 -0
  141. package/es/utils/common.d.ts +31 -1
  142. package/es/utils/common.js +81 -0
  143. package/es/utils/index.d.ts +1 -0
  144. package/es/utils/index.js +1 -0
  145. package/package.json +2 -1
  146. package/es/components/organism/DataTable/components/ToolbarActionButton/index.js +0 -52
  147. package/es/components/organism/DataTable/components/ToolbarActionButton/styled.d.ts +0 -5
  148. package/es/components/organism/DataTable/components/ToolbarActionButton/styled.js +0 -26
  149. /package/es/components/organism/DataTable/components/{ToolbarActionButton/index.d.ts → Toolbar/ToolbarActionButtons.d.ts} +0 -0
@@ -28,5 +28,8 @@ export declare const Input: string & import("styled-components").StyledComponent
28
28
  Password: React.ForwardRefExoticComponent<import("antd/es/input").PasswordProps & React.RefAttributes<import("antd").InputRef>>;
29
29
  }, {}> & {
30
30
  DefaultInput: typeof AntdInput;
31
+ CustomSearch: typeof SearchInput;
31
32
  };
33
+ declare const SearchInput: React.FC<InputProps>;
32
34
  export declare const TextArea: React.ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & React.RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
35
+ export {};
@@ -16,11 +16,12 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
16
16
  // Types
17
17
  import { Input as AntdInput } from 'antd';
18
18
  // Components
19
- import { RequiredLabel, Text } from '@antscorp/antsomi-ui/es/components/atoms';
19
+ import { Icon, RequiredLabel, Text } from '@antscorp/antsomi-ui/es/components/atoms';
20
20
  // Utils
21
21
  import { handleError } from '@antscorp/antsomi-ui/es/utils';
22
22
  import { getPreventKeyboardAction } from '@antscorp/antsomi-ui/es/utils/web';
23
23
  import { StyledInput } from './styled';
24
+ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
24
25
  const PATH = '@antscorp/antsomi-ui/es/components/atoms/Input/Input.tsx';
25
26
  const OriginInput = props => {
26
27
  // Props
@@ -95,6 +96,8 @@ OriginInput.defaultProps = {
95
96
  withWrapper: true,
96
97
  };
97
98
  export const Input = OriginInput;
99
+ const SearchInput = props => (React.createElement(Input, Object.assign({ bordered: false, autoFocus: true, suffix: React.createElement(Icon, { type: "icon-ants-search-2", size: 24, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 }) }, props, { className: `${props.className} antsomi-search-input` })));
100
+ Input.CustomSearch = SearchInput;
98
101
  Input.TextArea = StyledInput.TextArea;
99
102
  Input.DefaultInput = AntdInput;
100
103
  Input.Password = AntdInput.Password;
@@ -4,3 +4,4 @@ export interface InputNumberProps extends AntdInputNumberProps {
4
4
  showHandler?: boolean;
5
5
  }
6
6
  export declare const InputNumber: React.FC<InputNumberProps>;
7
+ export declare const FormatInputNumber: React.FC<InputNumberProps>;
@@ -13,8 +13,12 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  import React from 'react';
14
14
  import clsx from 'clsx';
15
15
  import { InputNumber as AntdInputNumber } from 'antd';
16
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
16
17
  // Icons
17
18
  import Icon from '@antscorp/icons';
19
+ // Translations
20
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
21
+ const { t } = i18nInstance;
18
22
  export const InputNumber = props => {
19
23
  // Props
20
24
  const { showHandler, className } = props, restOfProps = __rest(props, ["showHandler", "className"]);
@@ -25,3 +29,20 @@ export const InputNumber = props => {
25
29
  InputNumber.defaultProps = {
26
30
  showHandler: true,
27
31
  };
32
+ export const FormatInputNumber = InputNumber;
33
+ FormatInputNumber.defaultProps = {
34
+ formatter: (value, info) => {
35
+ if (info.userTyping)
36
+ return (value === null || value === void 0 ? void 0 : value.toString()) || '';
37
+ if (!value)
38
+ return '';
39
+ // Split the value into integer and decimal parts
40
+ const parts = value.toString().split('.');
41
+ // Format the integer part with commas
42
+ const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
43
+ // Combine the formatted integer part with the decimal part (if any)
44
+ return parts[1] ? `${integerPart}.${parts[1].slice(0, 3)}` : `${integerPart}`;
45
+ },
46
+ placeholder: `${t(translations.format)}: 1,234.560`,
47
+ parser: value => value === null || value === void 0 ? void 0 : value.replace(/,/g, ''),
48
+ };
@@ -1 +1 @@
1
- export { InputNumber } from './InputNumber';
1
+ export { InputNumber, FormatInputNumber } from './InputNumber';
@@ -1 +1 @@
1
- export { InputNumber } from './InputNumber';
1
+ export { InputNumber, FormatInputNumber } from './InputNumber';
@@ -72,9 +72,9 @@ export const Scrollbars = props => {
72
72
  // Set a minimum height for the view to ensure space for the scrollbar
73
73
  newStyle.minHeight = THUMB_SIZE;
74
74
  // If autoHeightMax is defined, adjust the maxHeight to include space for the scrollbar
75
- if (autoHeightMax) {
76
- newStyle.maxHeight = parseInt(`${autoHeightMax}`) + THUMB_SIZE;
77
- }
75
+ // if (autoHeightMax) {
76
+ // newStyle.maxHeight = parseInt(`${autoHeightMax}`) + THUMB_SIZE;
77
+ // }
78
78
  // Return a div element with the adjusted styles and original props, applying a custom class for styling
79
79
  return React.createElement("div", Object.assign({ className: "scrollbar-view" }, props, { style: newStyle }));
80
80
  }, onUpdate: onUpdate, hideTracksWhenNotNeeded: true }, restProps)));
@@ -1,7 +1,7 @@
1
1
  export { Divider } from './Divider';
2
2
  export { DividerPure } from './DividerPure';
3
3
  export { Input, TextArea } from './Input';
4
- export { InputNumber } from './InputNumber';
4
+ export { InputNumber, FormatInputNumber } from './InputNumber';
5
5
  export { Radio, RadioGroupSub, RadioButton } from './Radio';
6
6
  export { Space } from './Space';
7
7
  export { Tag } from './Tag';
@@ -1,7 +1,7 @@
1
1
  export { Divider } from './Divider';
2
2
  export { DividerPure } from './DividerPure';
3
3
  export { Input, TextArea } from './Input';
4
- export { InputNumber } from './InputNumber';
4
+ export { InputNumber, FormatInputNumber } from './InputNumber';
5
5
  export { Radio, RadioGroupSub, RadioButton } from './Radio';
6
6
  export { Space } from './Space';
7
7
  export { Tag } from './Tag';
@@ -1,3 +1,4 @@
1
1
  export { AccountSelection, type AccountSelectionProps } from './AccountSelection';
2
- export { AccountListing, AccountListingHandle } from './AccountListing';
2
+ export { AccountListing } from './AccountListing';
3
+ export type { AccountListingHandle } from './AccountListing';
3
4
  export { useAccountSelection } from './hooks';
@@ -1 +1,2 @@
1
- export { EditableName, EditableNameHandle } from './EditableName';
1
+ export { EditableName } from './EditableName';
2
+ export type { EditableNameHandle } from './EditableName';
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
- export interface EmptyDataProps {
2
+ import { FlexProps } from '@antscorp/antsomi-ui/es/components/atoms';
3
+ export interface EmptyDataProps extends Omit<FlexProps, 'children' | 'title'> {
4
+ showIcon?: boolean;
3
5
  size?: TUISize;
4
6
  icon?: React.ReactNode;
5
7
  title?: React.ReactNode;
@@ -1,3 +1,14 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  // Libraries
2
13
  import React from 'react';
3
14
  import { LoadingOutlined } from '@ant-design/icons';
@@ -10,12 +21,13 @@ import { Icon } from '@antscorp/antsomi-ui/es/components';
10
21
  import { EmptyIcon, EmptyWrapper, ImageWrapper } from './styled';
11
22
  const { Text } = Typography;
12
23
  export const EmptyData = props => {
13
- const { size = 'medium', icon = 'icon-ants-media', title, subTitle, description, loading, className, image, imageClassName, imageStyle, children, } = props;
14
- return (React.createElement(EmptyWrapper, { className: className },
24
+ const { size = 'medium', icon = 'icon-ants-media', showIcon = true, title, subTitle, description, loading, className, image, imageClassName, imageStyle, children } = props, restOfProps = __rest(props, ["size", "icon", "showIcon", "title", "subTitle", "description", "loading", "className", "image", "imageClassName", "imageStyle", "children"]);
25
+ return (React.createElement(EmptyWrapper, Object.assign({ className: className }, restOfProps),
15
26
  React.createElement(Flex, { vertical: true, align: "center", justify: "center", gap: 15 },
16
- !image && (React.createElement(EmptyIcon, { className: "animate__animated animate__tada", "$size": size }, isString(icon) ? React.createElement(Icon, { type: icon }) : icon)),
17
- image && (React.createElement(ImageWrapper, { className: imageClassName, style: imageStyle },
18
- React.createElement("img", { src: image, alt: "" }))),
27
+ !!showIcon && (React.createElement(React.Fragment, null,
28
+ !image && (React.createElement(EmptyIcon, { className: "animate__animated animate__tada", "$size": size }, isString(icon) ? React.createElement(Icon, { type: icon }) : icon)),
29
+ image && (React.createElement(ImageWrapper, { className: imageClassName, style: imageStyle },
30
+ React.createElement("img", { src: image, alt: "" }))))),
19
31
  loading ? (React.createElement(Spin, { indicator: React.createElement(LoadingOutlined, { style: { fontSize: 24 }, spin: true }) })) : (React.createElement(Flex, { gap: 5, align: "center", justify: "center", vertical: true },
20
32
  title && React.createElement(Text, { className: "title animate__animated animate__fadeInUp" }, title),
21
33
  subTitle && (React.createElement(Text, { className: "subTitle animate__animated animate__fadeInUp" }, subTitle)),
@@ -9,6 +9,7 @@ import { EMPTY_ICON_SIZE, EMPTY_WRAPPER_SIZE } from './constants';
9
9
  export const EmptyWrapper = styled(Flex) `
10
10
  width: 100%;
11
11
  height: 100%;
12
+ padding: 20px;
12
13
 
13
14
  .title {
14
15
  font-size: 14px;
@@ -234,7 +234,7 @@ export const ThumbnailCard = (props) => {
234
234
  // Handlers
235
235
  const handleRemoveThumbnail = e => {
236
236
  e.stopPropagation();
237
- modal.confirm(Object.assign(Object.assign({ title: 'Remove template', centered: true, icon: React.createElement(Icon, { type: "icon-ants-info", style: { fontSize: 16, lineHeight: '25px' } }), content: (React.createElement("div", null,
237
+ modal.confirm(Object.assign(Object.assign({ title: 'Remove template', centered: true, icon: (React.createElement(Icon, { type: "icon-ants-info", style: { fontSize: 16, lineHeight: '25px', marginRight: 13 } })), content: (React.createElement("div", null,
238
238
  React.createElement("p", null, "Are you sure you want to remove the template?"),
239
239
  React.createElement("p", null, "This action can not be undone."))), okText: 'Remove', cancelText: 'Cancel', closable: true }, restOfRemoveTemplateModalProps), { onOk: () => __awaiter(void 0, void 0, void 0, function* () {
240
240
  if (onOk)
@@ -0,0 +1,2 @@
1
+ export { Tree } from 'antd';
2
+ export type { TreeProps, TreeDataNode } from 'antd';
@@ -0,0 +1 @@
1
+ export { Tree } from 'antd';
@@ -0,0 +1 @@
1
+ export * from './Tree';
@@ -0,0 +1 @@
1
+ export * from './Tree';
@@ -1,2 +1,2 @@
1
1
  export { VirtualizedMenu } from './VirtualizedMenu';
2
- export { VirtualizedMenuProps } from './types';
2
+ export type { VirtualizedMenuProps } from './types';
@@ -55,6 +55,7 @@ export * from './PreviewModal';
55
55
  export * from './DrawerDetail';
56
56
  export * from './ThumbnailCard';
57
57
  export * from './ProcessLoading';
58
+ export * from './Tree';
58
59
  export { EditorScript } from './EditorScript';
59
60
  export { EditorTab } from './EditorTab';
60
61
  export { SelectAccount } from './SelectAccount';
@@ -55,6 +55,7 @@ export * from './PreviewModal';
55
55
  export * from './DrawerDetail';
56
56
  export * from './ThumbnailCard';
57
57
  export * from './ProcessLoading';
58
+ export * from './Tree';
58
59
  export { EditorScript } from './EditorScript';
59
60
  export { EditorTab } from './EditorTab';
60
61
  export { SelectAccount } from './SelectAccount';
@@ -1,3 +1,6 @@
1
1
  import React from 'react';
2
2
  import { DataTableProps } from './types';
3
- export declare function DataTable<TTableDataType>(props: DataTableProps<TTableDataType>): React.JSX.Element | null;
3
+ export declare function DataTable<TTableDataType>(props: DataTableProps<TTableDataType>): React.JSX.Element;
4
+ export declare namespace DataTable {
5
+ var useDataTableStore: typeof import("./hooks/useDataTableStore").useDataTableStore;
6
+ }
@@ -1,6 +1,17 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  /* eslint-disable react/function-component-definition */
2
13
  // Libraries
3
- import React, { useRef } from 'react';
14
+ import React from 'react';
4
15
  // Hooks
5
16
  import { useDataTable } from './hooks';
6
17
  // Styled
@@ -11,23 +22,24 @@ import { Table, Pagination, Toolbar } from './components';
11
22
  import { DataTableProvider } from './providers/DataTableProvider';
12
23
  import { AntdTableConfigProvider } from './providers';
13
24
  // Store
14
- import { createDataTableStore } from './stores';
25
+ import { useDataTableStore } from './hooks/useDataTableStore';
15
26
  function DataTableComponent(props) {
16
27
  // Hooks
17
28
  const { pagination, setPagination } = useDataTable(props);
18
29
  return (React.createElement(DataTableWrapper, null,
19
30
  React.createElement(Toolbar, null),
20
31
  React.createElement(Table, null),
21
- React.createElement(Pagination, { id: "data-table-pagination", page: pagination.page, pageSize: pagination.pageSize, onChange: setPagination })));
32
+ React.createElement(Pagination, Object.assign({ id: "data-table-pagination" }, pagination, { onChange: payload => {
33
+ var _a;
34
+ setPagination(payload);
35
+ (_a = pagination.onChange) === null || _a === void 0 ? void 0 : _a.call(pagination, payload);
36
+ } }))));
22
37
  }
23
38
  export function DataTable(props) {
24
- const storeRef = useRef();
25
- if (!storeRef.current) {
26
- storeRef.current = createDataTableStore(props);
27
- }
28
- if (!storeRef.current)
29
- return null;
39
+ const { store } = props, restOfProps = __rest(props, ["store"]);
40
+ const defaultStore = useDataTableStore(restOfProps);
30
41
  return (React.createElement(AntdTableConfigProvider, null,
31
- React.createElement(DataTableProvider, { store: storeRef.current },
32
- React.createElement(DataTableComponent, Object.assign({}, props)))));
42
+ React.createElement(DataTableProvider, { store: store || defaultStore },
43
+ React.createElement(DataTableComponent, Object.assign({}, restOfProps)))));
33
44
  }
45
+ DataTable.useDataTableStore = useDataTableStore;
@@ -1,30 +1,33 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
1
  // Libraries
13
2
  import React, { memo } from 'react';
14
3
  // Components
15
- import { Flex, Icon, Button } from '@antscorp/antsomi-ui/es/components/atoms';
4
+ import { Button, Popover } from '@antscorp/antsomi-ui/es/components/atoms';
5
+ import { FilterCondition } from './FilterCondition';
6
+ import { SavedFilterAndMetrics } from './SavedFilterAndMetrics';
7
+ // Hooks
8
+ import { useAddFilterCondition } from '../../hooks';
16
9
  // Locales
17
10
  import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
18
11
  import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
19
- // Styled
20
- import { FilterButton } from './styled';
21
- import { SavedFilterAndMetrics } from './SavedFilterAndMetrics';
22
- export const AddFilterButton = memo(props => {
23
- const restProps = __rest(props, []);
12
+ // Constants
13
+ import { EXCEPTION_OFF_FILTER_CLASS } from '../../constants/filter';
14
+ export const AddFilterButton = memo(() => {
24
15
  const { t } = i18nInstance;
25
- return (React.createElement(Flex, { align: "center", gap: 7 },
26
- React.createElement(FilterButton, null,
27
- React.createElement(Icon, { type: "icon-ants-filter-slim", size: 18 })),
28
- React.createElement(SavedFilterAndMetrics, null,
29
- React.createElement(Button, { type: "text" }, t(translations.filter.addFilter).toString()))));
16
+ const { openPopover, selectedFilterMetric, onSelectFilterMetric, onApplyFilterMetricCondition, onClickAddFilter, setState: setAddFilterConditionState, } = useAddFilterCondition();
17
+ return (React.createElement(Popover, { open: openPopover, content: React.createElement("div", { className: EXCEPTION_OFF_FILTER_CLASS }, selectedFilterMetric ? (React.createElement(FilterCondition, { filterMetric: selectedFilterMetric, onCancel: () => onSelectFilterMetric(undefined), onApply: ({ operator, value }) => {
18
+ onApplyFilterMetricCondition({
19
+ filterMetric: selectedFilterMetric,
20
+ operator,
21
+ value,
22
+ });
23
+ onSelectFilterMetric(undefined);
24
+ setAddFilterConditionState(prev => (Object.assign(Object.assign({}, prev), { openPopover: false })));
25
+ } })) : (React.createElement(SavedFilterAndMetrics, { onSelectFilterMetric: onSelectFilterMetric }))), trigger: ['click'], overlayInnerStyle: { width: 300, padding: 0 }, arrow: false, placement: "bottomLeft", destroyTooltipOnHide: true, onOpenChange: open => {
26
+ setAddFilterConditionState(prev => (Object.assign(Object.assign({}, prev), { openPopover: open })));
27
+ if (!open) {
28
+ /* Reset filter metric */
29
+ onSelectFilterMetric(undefined);
30
+ }
31
+ } },
32
+ React.createElement(Button, { type: "text", onClick: () => onClickAddFilter() }, t(translations.filter.addFilter).toString())));
30
33
  });
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface FilterActionButtonProps {
3
+ }
4
+ export declare const FilterActionButton: React.FC<FilterActionButtonProps>;
5
+ export {};
@@ -0,0 +1,126 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ // Libraries
11
+ import React, { memo, useState } from 'react';
12
+ // Components
13
+ import { Flex, Icon } from '@antscorp/antsomi-ui/es/components/atoms';
14
+ import { Modal } from '@antscorp/antsomi-ui/es/components/molecules';
15
+ // Utils
16
+ import { renderActionButtons } from '@antscorp/antsomi-ui/es/utils';
17
+ // Styled
18
+ import { ActionButton } from '../../styled';
19
+ import { EXCEPTION_OFF_FILTER_CLASS, FILTER_ACTION_OPTIONS } from '../../constants/filter';
20
+ // Context
21
+ import { useDataTableContext } from '../../contexts/DataTableContext';
22
+ import { SaveFilterPopover } from './SaveFilterPopover';
23
+ // Constants
24
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
25
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
26
+ const { t } = i18nInstance;
27
+ export const FilterActionButton = memo(() => {
28
+ // Store
29
+ const actionButtons = useDataTableContext(store => store.filter.actionButtons);
30
+ const { filters, savedFilter, onSaveFilter = () => Promise.resolve(), } = useDataTableContext(store => store.filter);
31
+ const setFilter = useDataTableContext(store => store.setFilter);
32
+ // State
33
+ const [state, setState] = useState({
34
+ openSaveFilterPopover: false,
35
+ saveFilterLoading: false,
36
+ });
37
+ // Variables
38
+ const { saveFilterLoading, openSaveFilterPopover } = state;
39
+ // Hooks
40
+ const [modal, context] = Modal.useModal();
41
+ // Handlers
42
+ const handleClickActionButton = (key) => {
43
+ switch (key) {
44
+ case 'CLOSE':
45
+ setFilter({
46
+ isFilterActive: false,
47
+ });
48
+ break;
49
+ case 'RESET': {
50
+ setFilter({
51
+ filters: [],
52
+ });
53
+ break;
54
+ }
55
+ default:
56
+ break;
57
+ }
58
+ };
59
+ /* Handle render action buttons */
60
+ const renderComponent = ({ key, label, buttonProps, icon, customRender }, option) => {
61
+ const actionButton = (React.createElement(ActionButton, Object.assign({ key: key, type: "text" }, buttonProps, {
62
+ // Handle hide action button except close button when filter is active
63
+ onClick: e => {
64
+ if (buttonProps && buttonProps.onClick) {
65
+ buttonProps.onClick(e);
66
+ }
67
+ handleClickActionButton(key);
68
+ }, "$hide": key !== 'CLOSE' && !(filters === null || filters === void 0 ? void 0 : filters.length) }),
69
+ React.createElement(Flex, { align: "center", justify: "center", style: { height: 24, width: 24, flexShrink: 0 } },
70
+ React.createElement(Icon, { type: icon, size: (option === null || option === void 0 ? void 0 : option.iconSize) || 18 })),
71
+ `${label}`.toUpperCase()));
72
+ // If action has customer render props then return it not handle more
73
+ if (customRender) {
74
+ return actionButton;
75
+ }
76
+ switch (key) {
77
+ case 'SAVE': {
78
+ return (React.createElement(SaveFilterPopover, { open: openSaveFilterPopover, onApply: (name) => __awaiter(void 0, void 0, void 0, function* () {
79
+ var _a;
80
+ const existSavedFilter = (_a = savedFilter === null || savedFilter === void 0 ? void 0 : savedFilter.list) === null || _a === void 0 ? void 0 : _a.find(savedFilter => savedFilter.name.trim() === name);
81
+ if (existSavedFilter) {
82
+ modal.confirm({
83
+ title: t(translations.dataTableFilter.replaceFilterSet.title).toString(),
84
+ centered: true,
85
+ content: t(translations.dataTableFilter.replaceFilterSet.description, {
86
+ filterName: name,
87
+ }).toString(),
88
+ icon: React.createElement("div", null),
89
+ wrapClassName: EXCEPTION_OFF_FILTER_CLASS,
90
+ okText: t(translations.global.replace).toString(),
91
+ onOk: () => __awaiter(void 0, void 0, void 0, function* () {
92
+ return new Promise((resolve, reject) => {
93
+ onSaveFilter({
94
+ filters: filters || [],
95
+ name,
96
+ existSavedFilter,
97
+ })
98
+ .then(() => resolve(true))
99
+ .catch(() => reject());
100
+ });
101
+ }),
102
+ });
103
+ }
104
+ else {
105
+ setState(prev => (Object.assign(Object.assign({}, prev), { saveFilterLoading: true })));
106
+ yield onSaveFilter({
107
+ filters: filters || [],
108
+ name,
109
+ });
110
+ setState(prev => (Object.assign(Object.assign({}, prev), { saveFilterLoading: false, openSaveFilterPopover: false })));
111
+ }
112
+ }), onCancel: () => setState(prev => (Object.assign(Object.assign({}, prev), { openSaveFilterPopover: false }))), loading: saveFilterLoading, onOpenChange: open => setState(prev => (Object.assign(Object.assign({}, prev), { openSaveFilterPopover: open }))) }, actionButton));
113
+ }
114
+ default:
115
+ return actionButton;
116
+ }
117
+ };
118
+ return (React.createElement(React.Fragment, null,
119
+ React.createElement(Flex, { align: "center", gap: 2 }, renderActionButtons({
120
+ renderComponent,
121
+ // CLOSE ACTION ALWAYS VISIBLE
122
+ actionButtons: Object.assign(Object.assign({}, actionButtons), { CLOSE: Object.assign({}, actionButtons === null || actionButtons === void 0 ? void 0 : actionButtons.CLOSE) }),
123
+ defaultActionOptions: FILTER_ACTION_OPTIONS,
124
+ })),
125
+ context));
126
+ });
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { FilterItem, FilterMetic } from '../../../types';
3
+ type TFormType = {
4
+ operator: string;
5
+ value: any;
6
+ };
7
+ interface FilterConditionProps {
8
+ filterMetric: FilterMetic;
9
+ filterCondition?: FilterItem;
10
+ onCancel?: () => void;
11
+ onApply?: (values: TFormType) => void;
12
+ }
13
+ export declare const FilterCondition: React.FC<FilterConditionProps>;
14
+ export {};
@@ -0,0 +1,99 @@
1
+ // Libraries
2
+ import React, { useEffect, useMemo } from 'react';
3
+ // Components
4
+ import { Flex } from '@antscorp/antsomi-ui/es/components/atoms';
5
+ import { Select, Form } from '@antscorp/antsomi-ui/es/components/molecules';
6
+ import { ApplyPopupContent } from '../../common/ApplyPopupContent';
7
+ // Constants
8
+ import { OPERATORS, OPERATORS_OPTION } from '@antscorp/antsomi-ui/es/constants/condition';
9
+ import { renderValueField } from '../../../utils';
10
+ import { EXCEPTION_OFF_FILTER_CLASS } from '../../../constants/filter';
11
+ const { BETWEEN, EXISTS, NOT_EXISTS } = OPERATORS_OPTION;
12
+ export const FilterCondition = props => {
13
+ // Props
14
+ const { filterMetric, filterCondition, onCancel, onApply } = props;
15
+ // Hooks
16
+ const [form] = Form.useForm();
17
+ // Form
18
+ const operator = Form.useWatch('operator', form);
19
+ const value = Form.useWatch('value', form);
20
+ // Variables
21
+ const { name, dataType } = filterMetric;
22
+ // Memos
23
+ const operatorList = useMemo(() => { var _a; return Object.values(((_a = OPERATORS[dataType || '']) === null || _a === void 0 ? void 0 : _a.list) || []); }, [dataType]);
24
+ const isDisableApply = useMemo(() => {
25
+ let isDisable = false;
26
+ console.log('value', value);
27
+ switch (operator) {
28
+ case BETWEEN.value: {
29
+ const [firstValue, secondValue] = (value === null || value === void 0 ? void 0 : value.split('AND')) || [];
30
+ isDisable = isNaN(parseInt(firstValue)) || isNaN(parseInt(secondValue));
31
+ break;
32
+ }
33
+ case EXISTS.value:
34
+ case NOT_EXISTS.value: {
35
+ isDisable = false;
36
+ break;
37
+ }
38
+ default: {
39
+ if (Array.isArray(value) && !value.length) {
40
+ isDisable = true;
41
+ }
42
+ else {
43
+ isDisable = !value;
44
+ }
45
+ break;
46
+ }
47
+ }
48
+ return isDisable;
49
+ }, [operator, value]);
50
+ // Effects
51
+ /* Handle set default operator when mount */
52
+ useEffect(() => {
53
+ var _a;
54
+ form.setFieldsValue({
55
+ operator: ((_a = operatorList[0]) === null || _a === void 0 ? void 0 : _a.value) || '',
56
+ });
57
+ }, [form, operatorList]);
58
+ /* Update filter condition values */
59
+ useEffect(() => {
60
+ if (filterCondition) {
61
+ form.setFieldsValue({
62
+ operator: filterCondition.operator,
63
+ value: filterCondition.value,
64
+ });
65
+ }
66
+ }, [filterCondition, form]);
67
+ // Handlers
68
+ const onFinishForm = (values) => {
69
+ if (onApply) {
70
+ onApply(values);
71
+ }
72
+ };
73
+ const handleCancel = () => {
74
+ form.resetFields();
75
+ if (onCancel) {
76
+ onCancel();
77
+ }
78
+ };
79
+ return (React.createElement(ApplyPopupContent, { title: name, applyButtonProps: {
80
+ disabled: isDisableApply,
81
+ }, onCancel: handleCancel, onApply: () => form.submit() },
82
+ React.createElement(Form, { form: form, layout: "vertical", onFinish: onFinishForm },
83
+ React.createElement(Flex, { vertical: true, gap: 20 },
84
+ React.createElement(Form.Item, { name: "operator", noStyle: true },
85
+ React.createElement(Select, { value: operator, options: operatorList, onChange: () => form.setFieldsValue({
86
+ value: '',
87
+ }), dropdownRender: menu => React.createElement("div", { className: EXCEPTION_OFF_FILTER_CLASS }, menu) })),
88
+ React.createElement(Form.Item, { name: "value", noStyle: true }),
89
+ renderValueField({
90
+ filterMetric,
91
+ operator,
92
+ value,
93
+ onChangeValue: value => {
94
+ form.setFieldsValue({
95
+ value,
96
+ });
97
+ },
98
+ })))));
99
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const FilterConditionWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const CloseButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/flex/interface").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;