@antscorp/antsomi-ui 1.3.5-beta.453 → 1.3.5-beta.454

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 (49) hide show
  1. package/es/components/atoms/Flex/index.d.ts +2 -1
  2. package/es/components/atoms/Flex/index.js +1 -1
  3. package/es/components/atoms/Input/Input.js +1 -1
  4. package/es/components/atoms/Input/styled.d.ts +6 -0
  5. package/es/components/atoms/Input/styled.js +5 -0
  6. package/es/components/atoms/Popover/index.d.ts +1 -0
  7. package/es/components/atoms/index.d.ts +2 -2
  8. package/es/components/atoms/index.js +2 -2
  9. package/es/components/molecules/ApplyPopupContent/ApplyPopupContent.d.ts +17 -0
  10. package/es/components/{organism/DataTable/components/common/ApplyPopupContent/index.js → molecules/ApplyPopupContent/ApplyPopupContent.js} +4 -2
  11. package/es/components/molecules/ApplyPopupContent/index.d.ts +2 -0
  12. package/es/components/molecules/ApplyPopupContent/index.js +1 -0
  13. package/es/components/{organism/DataTable/components/common → molecules}/ApplyPopupContent/styled.js +0 -2
  14. package/es/components/molecules/CalendarSelection/styled.d.ts +1 -1
  15. package/es/components/molecules/CalendarSelection/styled.js +3 -1
  16. package/es/components/molecules/MatchAnySelect/MatchesAnySelect.d.ts +4 -0
  17. package/es/components/molecules/MatchAnySelect/MatchesAnySelect.js +237 -0
  18. package/es/components/molecules/MatchAnySelect/components/ExtendValuePopup.d.ts +7 -0
  19. package/es/components/molecules/MatchAnySelect/components/ExtendValuePopup.js +66 -0
  20. package/es/components/molecules/MatchAnySelect/constants.d.ts +3 -0
  21. package/es/components/molecules/MatchAnySelect/constants.js +304 -0
  22. package/es/components/molecules/MatchAnySelect/index.d.ts +1 -0
  23. package/es/components/molecules/MatchAnySelect/index.js +1 -0
  24. package/es/components/molecules/MatchAnySelect/styled.d.ts +17 -0
  25. package/es/components/molecules/MatchAnySelect/styled.js +184 -0
  26. package/es/components/molecules/MatchAnySelect/types.d.ts +20 -0
  27. package/es/components/molecules/MatchAnySelect/types.js +1 -0
  28. package/es/components/molecules/index.d.ts +3 -0
  29. package/es/components/molecules/index.js +2 -0
  30. package/es/components/organism/AlgorithmsSetting/styled.js +2 -1
  31. package/es/components/organism/DataTable/components/Filter/FilterCondition/index.js +2 -3
  32. package/es/components/organism/DataTable/components/Filter/SaveFilterPopover.js +2 -2
  33. package/es/components/organism/DataTable/components/Table/ResizableCell.d.ts +1 -2
  34. package/es/components/organism/DataTable/components/Table/ResizableCell.js +21 -10
  35. package/es/components/organism/DataTable/components/Table/index.js +0 -7
  36. package/es/components/organism/FilterSetting/components/common/InputOrSelect/index.js +2 -1
  37. package/es/locales/en/translation.json +10 -2
  38. package/es/locales/i18n.d.ts +16 -0
  39. package/es/locales/translations.d.ts +8 -0
  40. package/es/locales/vi/translation.json +10 -2
  41. package/es/providers/ConfigProvider/GlobalStyle.js +5 -0
  42. package/es/tests/DataTableTest.js +24 -117
  43. package/es/utils/common.d.ts +7 -1
  44. package/es/utils/common.js +8 -0
  45. package/package.json +1 -1
  46. package/es/components/organism/DataTable/components/common/ApplyPopupContent/index.d.ts +0 -11
  47. package/es/components/organism/DataTable/components/common/index.d.ts +0 -0
  48. package/es/components/organism/DataTable/components/common/index.js +0 -1
  49. /package/es/components/{organism/DataTable/components/common → molecules}/ApplyPopupContent/styled.d.ts +0 -0
@@ -1 +1,2 @@
1
- export * from './Flex';
1
+ export { Flex } from './Flex';
2
+ export type { FlexProps } from './Flex';
@@ -1 +1 @@
1
- export * from './Flex';
1
+ export { Flex } from './Flex';
@@ -96,7 +96,7 @@ OriginInput.defaultProps = {
96
96
  withWrapper: true,
97
97
  };
98
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` })));
99
+ const SearchInput = props => (React.createElement(OriginInput, 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
100
  Input.CustomSearch = SearchInput;
101
101
  Input.TextArea = StyledInput.TextArea;
102
102
  Input.DefaultInput = AntdInput;
@@ -9,3 +9,9 @@ export declare const StyledInput: import("styled-components").StyledComponent<im
9
9
  export declare const TextArea: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & import("react").RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>, any, {
10
10
  showBorder?: boolean | undefined;
11
11
  }, never>;
12
+ export declare const StyledSearchInput: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").InputProps & import("react").RefAttributes<import("antd").InputRef>> & {
13
+ Group: import("react").FC<import("antd/es/input").GroupProps>;
14
+ Search: import("react").ForwardRefExoticComponent<import("antd/es/input").SearchProps & import("react").RefAttributes<import("antd").InputRef>>;
15
+ TextArea: import("react").ForwardRefExoticComponent<import("antd/es/input").TextAreaProps & import("react").RefAttributes<import("antd/es/input/TextArea").TextAreaRef>>;
16
+ Password: import("react").ForwardRefExoticComponent<import("antd/es/input").PasswordProps & import("react").RefAttributes<import("antd").InputRef>>;
17
+ }, any, {}, never>;
@@ -107,3 +107,8 @@ export const TextArea = styled(InputAntd.TextArea) `
107
107
  border: 1px solid #e0e0e0;
108
108
  `}
109
109
  `;
110
+ export const StyledSearchInput = styled(InputAntd) `
111
+ &.antsomi-input-affix-wrapper:hover > input.antsomi-input {
112
+ background-color: transparent;
113
+ }
114
+ `;
@@ -1 +1,2 @@
1
1
  export { Popover } from './Popover';
2
+ export type { PopoverProps } from 'antd';
@@ -21,7 +21,6 @@ export { Steps } from './Steps';
21
21
  export { Empty } from './Empty';
22
22
  export { Icon } from './Icon';
23
23
  export { Text } from './Text';
24
- export { Popover } from './Popover';
25
24
  export { RequiredLabel } from './RequiredLabel';
26
25
  export { Slider } from './Slider';
27
26
  export { Spin } from './Spin';
@@ -32,7 +31,6 @@ export { SliderV2 } from './SliderV2';
32
31
  export { InputDynamic } from './InputDynamic';
33
32
  export { ContentEditable } from './ContentEditable';
34
33
  export * from './Flex';
35
- export * from './RateV2';
36
34
  export * from './PreviewTabs';
37
35
  export * from './MobileFrame';
38
36
  export * from './MobileFrameV2';
@@ -41,6 +39,8 @@ export * from './ReactIframe';
41
39
  export * from './Scrollbars';
42
40
  export * from './Switch';
43
41
  export * from './Button';
42
+ export * from './RateV2';
43
+ export * from './Popover';
44
44
  export type { SliderProps } from './Slider';
45
45
  export type { PaginationProps } from './Pagination';
46
46
  export type { InputDynamicProps } from './InputDynamic';
@@ -21,7 +21,6 @@ export { Steps } from './Steps';
21
21
  export { Empty } from './Empty';
22
22
  export { Icon } from './Icon';
23
23
  export { Text } from './Text';
24
- export { Popover } from './Popover';
25
24
  export { RequiredLabel } from './RequiredLabel';
26
25
  export { Slider } from './Slider';
27
26
  export { Spin } from './Spin';
@@ -32,7 +31,6 @@ export { SliderV2 } from './SliderV2';
32
31
  export { InputDynamic } from './InputDynamic';
33
32
  export { ContentEditable } from './ContentEditable';
34
33
  export * from './Flex';
35
- export * from './RateV2';
36
34
  export * from './PreviewTabs';
37
35
  export * from './MobileFrame';
38
36
  export * from './MobileFrameV2';
@@ -41,3 +39,5 @@ export * from './ReactIframe';
41
39
  export * from './Scrollbars';
42
40
  export * from './Switch';
43
41
  export * from './Button';
42
+ export * from './RateV2';
43
+ export * from './Popover';
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { ButtonProps, FlexProps } from '@antscorp/antsomi-ui/es/components/atoms';
3
+ export interface ApplyPopupContentProps extends React.HTMLAttributes<HTMLDivElement> {
4
+ /** The title of the popup content */
5
+ title?: string;
6
+ /** Properties for the cancel button. */
7
+ cancelButtonProps?: ButtonProps;
8
+ /** Properties for the apply button. */
9
+ applyButtonProps?: ButtonProps;
10
+ /** Properties for the footer Flex container, excluding children. */
11
+ footerProps?: Omit<FlexProps, 'children'>;
12
+ /** Handler for the cancel button click event. */
13
+ onCancel?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
14
+ /** Handler for the apply button click event. */
15
+ onApply?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void;
16
+ }
17
+ export declare const ApplyPopupContent: React.FC<React.PropsWithChildren<ApplyPopupContentProps>>;
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  // Libraries
13
13
  import React from 'react';
14
+ import clsx from 'clsx';
14
15
  // Components
15
16
  import { Flex, Typography, Icon, Button, } from '@antscorp/antsomi-ui/es/components/atoms';
16
17
  // Styled
@@ -21,7 +22,8 @@ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
21
22
  import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
22
23
  const { Text } = Typography;
23
24
  export const ApplyPopupContent = props => {
24
- const { title, children, cancelButtonProps, applyButtonProps, onApply, onCancel } = props, restProps = __rest(props, ["title", "children", "cancelButtonProps", "applyButtonProps", "onApply", "onCancel"]);
25
+ const { title, children, cancelButtonProps, applyButtonProps, footerProps, onApply, onCancel } = props, restProps = __rest(props, ["title", "children", "cancelButtonProps", "applyButtonProps", "footerProps", "onApply", "onCancel"]);
26
+ const { align = 'center', justify = 'flex-end' } = footerProps || {};
25
27
  const { t } = i18nInstance;
26
28
  return (React.createElement(ContentWrapper, Object.assign({}, restProps),
27
29
  React.createElement(Flex, { className: "content__body", vertical: true, gap: 20 },
@@ -30,7 +32,7 @@ export const ApplyPopupContent = props => {
30
32
  React.createElement(CloseButton, { align: "center", justify: "center", onClick: onCancel },
31
33
  React.createElement(Icon, { type: "icon-ants-remove-slim" }))),
32
34
  children),
33
- React.createElement("div", { className: "content__footer" },
35
+ React.createElement(Flex, Object.assign({}, footerProps, { align: align, justify: justify, className: clsx('content__footer', footerProps === null || footerProps === void 0 ? void 0 : footerProps.className) }),
34
36
  React.createElement(Button, Object.assign({ onClick: onCancel }, cancelButtonProps), t(translations.cancel.title).toString()),
35
37
  React.createElement(Button, Object.assign({ type: "primary", onClick: onApply }, applyButtonProps), t(translations.apply.title).toString()))));
36
38
  };
@@ -0,0 +1,2 @@
1
+ export { ApplyPopupContent } from './ApplyPopupContent';
2
+ export type { ApplyPopupContentProps } from './ApplyPopupContent';
@@ -0,0 +1 @@
1
+ export { ApplyPopupContent } from './ApplyPopupContent';
@@ -17,8 +17,6 @@ export const ContentWrapper = styled.div `
17
17
 
18
18
  &__footer {
19
19
  display: flex;
20
- align-items: center;
21
- justify-content: flex-end;
22
20
  padding: 15px;
23
21
  gap: 10px;
24
22
  border-top: 1px solid ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw3};
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare const StyledPopover: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").PopoverProps & import("react").RefAttributes<unknown>> & {
2
+ export declare const StyledPopover: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/popover").PopoverProps & import("react").RefAttributes<unknown>> & {
3
3
  _InternalPanelDoNotUseOrYouWillBeFired: import("react").FC<import("antd/es/popover/PurePanel").PurePanelProps>;
4
4
  }, any, {}, never>;
5
5
  export declare const StyledPopoverContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,5 +1,7 @@
1
- import { Popover } from '@antscorp/antsomi-ui/es/components/atoms';
1
+ // Libraries
2
2
  import styled from 'styled-components';
3
+ // Components
4
+ import { Popover } from '@antscorp/antsomi-ui/es/components/atoms/Popover';
3
5
  export const StyledPopover = styled(Popover) `
4
6
  font-size: 12px;
5
7
  `;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { MatchesAnyProps, MatchesAnySelectProps } from './types';
3
+ export declare const MatchesAny: React.FC<MatchesAnyProps>;
4
+ export declare const MatchesAnySelect: React.FC<MatchesAnySelectProps>;
@@ -0,0 +1,237 @@
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
+ /* eslint-disable react/destructuring-assignment */
13
+ // Libraries
14
+ import { ConfigProvider } from 'antd';
15
+ import { uniqBy } from 'lodash';
16
+ import React, { useMemo, useState } from 'react';
17
+ // Components
18
+ import { EmptyData, Select } from '@antscorp/antsomi-ui/es/components/molecules';
19
+ import { Button, Flex, Icon, Input, Scrollbars, Spin, Typography, } from '@antscorp/antsomi-ui/es/components/atoms';
20
+ import { ExtendValuePopup } from './components/ExtendValuePopup';
21
+ // Styled
22
+ import { MatchesAnyWrapper, ActionButton, StyledTree, TextButton } from './styled';
23
+ // Locales
24
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
25
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
26
+ // Constants
27
+ import { MATCHES_ANY_THEME, SAMPLE_DATA } from './constants';
28
+ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
29
+ // Hooks
30
+ import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
31
+ // Utils
32
+ import { flatTree, recursiveSearchItems } from '@antscorp/antsomi-ui/es/utils';
33
+ const initialState = {};
34
+ const matchesAnyInitialState = {
35
+ searchValue: '',
36
+ selectedItems: [],
37
+ };
38
+ const { t } = i18nInstance;
39
+ const { Text } = Typography;
40
+ export const MatchesAny = props => {
41
+ // Props
42
+ const { objectName, isLoading = false, showExtendValue = true } = props, restOfProps = __rest(props, ["objectName", "isLoading", "showExtendValue"]);
43
+ // State
44
+ const [state, setState] = useState(matchesAnyInitialState);
45
+ // Variables
46
+ const { searchValue, selectedItems } = state;
47
+ // Handlers
48
+ /**
49
+ * Adds an item and, if applicable, its leaf descendants to the list of selected items.
50
+ *
51
+ * If the item has children, the function flattens the tree structure and adds only the leaf nodes
52
+ * (nodes without children) to the selected items list. If the item does not have children, it adds
53
+ * the item directly to the selected items list.
54
+ *
55
+ * @param {MatchesAnyItem} item - The item to be added to the selected items list.
56
+ * This item can have children.
57
+ */
58
+ const onSelectItem = (item) => {
59
+ if (item.children) {
60
+ const flattenChild = flatTree(item.children, 'children');
61
+ setState(prev => (Object.assign(Object.assign({}, prev), { selectedItems: [
62
+ ...(prev.selectedItems || []),
63
+ ...flattenChild === null || flattenChild === void 0 ? void 0 : flattenChild.filter(item => !item.children),
64
+ ] })));
65
+ return;
66
+ }
67
+ setState(prev => (Object.assign(Object.assign({}, prev), { selectedItems: [...(prev.selectedItems || []), item] })));
68
+ };
69
+ /**
70
+ * Removes an item and its descendants from the list of selected items.
71
+ *
72
+ * This function updates the state by removing the specified item and, if applicable,
73
+ * any of its descendants from the list of selected items.
74
+ *
75
+ */
76
+ const onRemoveItem = (item) => {
77
+ setState(prev => {
78
+ var _a;
79
+ return (Object.assign(Object.assign({}, prev), { selectedItems: (_a = prev.selectedItems) === null || _a === void 0 ? void 0 : _a.filter(selectedItem => {
80
+ if (item.children) {
81
+ const flattenChild = flatTree(item.children, 'children');
82
+ return (selectedItem.key !== item.key &&
83
+ !(flattenChild === null || flattenChild === void 0 ? void 0 : flattenChild.some(item => item.key === selectedItem.key)));
84
+ }
85
+ return selectedItem.key !== item.key;
86
+ }) }));
87
+ });
88
+ };
89
+ const onSelectAll = () => {
90
+ const flattenTreeData = flatTree(SAMPLE_DATA, 'children').filter(item => !item.children &&
91
+ !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.some(selectedItem => selectedItem.key === item.key || selectedItem.title === item.title)));
92
+ setState(prev => (Object.assign(Object.assign({}, prev), { selectedItems: uniqBy([...(prev.selectedItems || []), ...flattenTreeData], 'key') })));
93
+ };
94
+ const onRemoveAll = () => {
95
+ setState(prev => (Object.assign(Object.assign({}, prev), { selectedItems: [] })));
96
+ };
97
+ const renderItemNodeTitle = ({ item, onSelectItem, onRemoveItem, }) => {
98
+ const { isExtendValue, title } = item; // Destructure properties from item
99
+ return (React.createElement(React.Fragment, null,
100
+ React.createElement(Text, { ellipsis: { tooltip: true } }, title),
101
+ React.createElement(Flex, { align: "center", gap: 5 },
102
+ isExtendValue && (React.createElement(Icon, { type: "icon-ants-empty-flag", size: 20, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary })),
103
+ React.createElement(ActionButton, { className: "select-button", align: "center", justify: "center", onClick: () => {
104
+ // Call onSelectItem function if provided
105
+ if (onSelectItem) {
106
+ onSelectItem(item);
107
+ }
108
+ // Call onRemoveItem function if provided
109
+ if (onRemoveItem) {
110
+ onRemoveItem(item);
111
+ }
112
+ } },
113
+ React.createElement(Icon, { type: `icon-ants-${onSelectItem ? 'double-arrow-up' : 'remove-slim'}`, size: 11 })))));
114
+ };
115
+ // Memos
116
+ const { treeData, matchedParents } = useMemo(() => {
117
+ const { results, matchedParents } = recursiveSearchItems({
118
+ list: SAMPLE_DATA,
119
+ searchKeys: ['title', 'key'],
120
+ searchValue,
121
+ childrenKey: 'children',
122
+ });
123
+ const serializeTreeData = (list) => list.map(item => {
124
+ /**
125
+ * Checks if the given item is selected.
126
+ *
127
+ * If the item has children, it flattens the children tree structure and checks if all leaf nodes are selected (Compare key or title if item is extend value).
128
+ * If the item does not have children, it directly checks if the item is in the selected items list.
129
+ *
130
+ */
131
+ const isSelected = item.children
132
+ ? flatTree(item.children, 'children')
133
+ .filter(item => !item.children)
134
+ .every(item => selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.some(selectedItem => selectedItem.key === item.key ||
135
+ (selectedItem.isExtendValue && selectedItem.title === item.title)))
136
+ : selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.some(selectedItem => selectedItem.key === item.key ||
137
+ (selectedItem.isExtendValue && selectedItem.title === item.title));
138
+ return Object.assign(Object.assign(Object.assign({}, item), { title: renderItemNodeTitle({ item, onSelectItem }), disabled: isSelected }), (item.children && {
139
+ children: serializeTreeData(item.children),
140
+ }));
141
+ });
142
+ const treeData = serializeTreeData(results);
143
+ return { treeData, matchedParents };
144
+ }, [searchValue, selectedItems]);
145
+ const selectedTreeData = useMemo(() => {
146
+ const notExtendValueSelectedItems = selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.filter(item => !item.isExtendValue);
147
+ const extendValueSelectedItems = selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.filter(item => item.isExtendValue);
148
+ const serializeTreeData = (list) => {
149
+ var _a;
150
+ return ((_a = list
151
+ .filter(item => {
152
+ /**
153
+ * Checks if the given item or any of its descendants are selected.
154
+ *
155
+ * If the item has children, it flattens the children tree structure and checks if any node is selected.
156
+ * If the item does not have children, it directly checks if the item is in the selected items list.
157
+ *
158
+ */
159
+ const isSelected = item.children
160
+ ? flatTree(item.children, 'children').some(item => notExtendValueSelectedItems === null || notExtendValueSelectedItems === void 0 ? void 0 : notExtendValueSelectedItems.some(selectedItem => selectedItem.key === item.key))
161
+ : notExtendValueSelectedItems === null || notExtendValueSelectedItems === void 0 ? void 0 : notExtendValueSelectedItems.some(selectedItem => selectedItem.key === item.key);
162
+ return isSelected;
163
+ })) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign(Object.assign({}, item), { title: renderItemNodeTitle({ item, onRemoveItem }) }), (item.children && {
164
+ children: serializeTreeData(item.children),
165
+ }))))) || [];
166
+ };
167
+ return serializeTreeData(SAMPLE_DATA || []).concat((extendValueSelectedItems === null || extendValueSelectedItems === void 0 ? void 0 : extendValueSelectedItems.map(item => (Object.assign(Object.assign({}, item), { title: renderItemNodeTitle({ item, onRemoveItem }) })))) || []);
168
+ }, [selectedItems]);
169
+ const isDisableRemoveAll = useDeepCompareMemo(() => !(selectedTreeData === null || selectedTreeData === void 0 ? void 0 : selectedTreeData.length), [selectedTreeData]);
170
+ const isDisableSelectAll = useDeepCompareMemo(() => {
171
+ const flattenTreeData = flatTree(treeData, 'children');
172
+ return !(flattenTreeData === null || flattenTreeData === void 0 ? void 0 : flattenTreeData.some(item => !item.disabled));
173
+ }, [treeData]);
174
+ // Renders
175
+ const renderSelectList = () => {
176
+ var _a;
177
+ return (React.createElement("div", { className: "matches-any__section matches-any__section--left" },
178
+ React.createElement("div", { className: "matches-any__header" },
179
+ React.createElement("div", { style: { width: '100%' } },
180
+ React.createElement(Input.CustomSearch, { placeholder: `${(_a = t(translations.global.search)) === null || _a === void 0 ? void 0 : _a.toString()}...`, onAfterChange: searchValue => setState(prev => (Object.assign(Object.assign({}, prev), { searchValue }))) }))),
181
+ React.createElement("div", { className: "matches-any__body" },
182
+ React.createElement(Flex, { align: "center", justify: "space-between" },
183
+ React.createElement(Text, { strong: true }, `${objectName} (${flatTree(SAMPLE_DATA, 'children').filter(item => !item.children).length})`),
184
+ React.createElement(TextButton, { disabled: isDisableSelectAll, onClick: onSelectAll }, t(translations.global.selectAll).toString())),
185
+ React.createElement(Spin, { spinning: isLoading },
186
+ React.createElement(Scrollbars, { style: { height: '100%' } },
187
+ React.createElement(StyledTree, { key: searchValue, defaultExpandedKeys: matchedParents.map(item => item.key), selectable: false, treeData: treeData, switcherIcon: props => (React.createElement(Icon, { type: "icon-ants-caret-down", style: {
188
+ transform: props.expanded ? 'rotate(0)' : 'rotate(-90deg)',
189
+ transition: 'transform 0.3s ease',
190
+ }, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 })) }))))));
191
+ };
192
+ const renderSelectedList = () => (React.createElement("div", { className: "matches-any__section" },
193
+ React.createElement(Flex, { className: "matches-any__header", justify: "space-between" },
194
+ React.createElement(Text, { strong: true }, `${t(translations.global.selected)} (${(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) || 0})`),
195
+ React.createElement(TextButton, { disabled: isDisableRemoveAll, onClick: onRemoveAll }, t(translations.global.removeAll).toString())),
196
+ React.createElement("div", { className: "matches-any__body" },
197
+ React.createElement(Spin, { spinning: isLoading },
198
+ React.createElement(Scrollbars, { style: { height: '100%' } }, !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) ? (React.createElement(EmptyData, { icon: "icon-ants-channel-integration", description: "Select items from the list" })) : (React.createElement(StyledTree, { selectable: false, treeData: selectedTreeData, switcherIcon: props => (React.createElement(Icon, { type: "icon-ants-caret-down", style: {
199
+ transform: props.expanded ? 'rotate(0)' : 'rotate(-90deg)',
200
+ transition: 'transform 0.3s ease',
201
+ }, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 })) })))))));
202
+ // Handlers
203
+ const onApplyExtendValue = (extendValues) => {
204
+ // Filter out values that are already present in selectedItems
205
+ const availableExtendValues = extendValues === null || extendValues === void 0 ? void 0 : extendValues.filter(value => !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.some(item => item.title === value)));
206
+ // If there are available values to add
207
+ if (availableExtendValues) {
208
+ // Create new items in the format required (MatchesAnyItem)
209
+ const newSelectedItems = availableExtendValues.map(value => ({
210
+ key: value,
211
+ title: value,
212
+ isExtendValue: true, // Flag to indicate that this item is an extend value
213
+ }));
214
+ setState(prev => (Object.assign(Object.assign({}, prev), { selectedItems: [...(selectedItems || []), ...newSelectedItems] })));
215
+ }
216
+ };
217
+ return (React.createElement(ConfigProvider, { theme: MATCHES_ANY_THEME },
218
+ React.createElement(MatchesAnyWrapper, Object.assign({}, restOfProps, { vertical: true, justify: "space-between" }),
219
+ React.createElement(Flex, { style: { width: '100%', height: '100%' } },
220
+ renderSelectList(),
221
+ renderSelectedList()),
222
+ React.createElement(Flex, { className: "matches-any__footer", align: "center", justify: "space-between" },
223
+ React.createElement(Flex, { align: "center", gap: 10 },
224
+ React.createElement(Button, { type: "primary" }, t(translations.apply.title).toString()),
225
+ React.createElement(Button, null, t(translations.cancel.title).toString())),
226
+ showExtendValue && (React.createElement(ExtendValuePopup, { onApply: onApplyExtendValue },
227
+ React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-empty-flag" }) }, "Extend Value")))))));
228
+ };
229
+ export const MatchesAnySelect = props => {
230
+ const { placeholder = 'Select an item', dropdownStyle, objectName } = props, restProps = __rest(props, ["placeholder", "dropdownStyle", "objectName"]);
231
+ // State
232
+ const [state, setState] = useState({});
233
+ // Renders
234
+ const renderPopoverContent = () => (React.createElement(MatchesAny, { objectName: objectName, style: { margin: '-8px 0px' } }));
235
+ return renderPopoverContent();
236
+ return (React.createElement(Select, Object.assign({}, restProps, { dropdownRender: renderPopoverContent, placeholder: placeholder, popupMatchSelectWidth: 700, dropdownStyle: Object.assign(Object.assign({}, dropdownStyle), { padding: 0 }) })));
237
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { type PopoverProps } from '@antscorp/antsomi-ui/es/components/atoms';
3
+ interface ExtendValuePopupProps extends PopoverProps {
4
+ onApply?: (extendValues: string[]) => void;
5
+ }
6
+ export declare const ExtendValuePopup: React.FC<ExtendValuePopupProps>;
7
+ export {};
@@ -0,0 +1,66 @@
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
+ // Libraries
13
+ import { uniq } from 'lodash';
14
+ import React, { useState } from 'react';
15
+ import styled from 'styled-components';
16
+ // Components
17
+ import { ApplyPopupContent, Form } from '@antscorp/antsomi-ui/es/components/molecules';
18
+ import { Input, Popover } from '@antscorp/antsomi-ui/es/components/atoms';
19
+ // Constants
20
+ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
21
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
22
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
23
+ // Utils
24
+ import { splitTextByNewline } from '@antscorp/antsomi-ui/es/utils';
25
+ const { borderRadius, blue1 } = globalToken || {};
26
+ const { t } = i18nInstance;
27
+ // Styled
28
+ const TextArea = styled(Input.TextArea) `
29
+ &.antsomi-input-borderless {
30
+ border: 1px solid ${blue1} !important;
31
+ border-radius: ${borderRadius}px;
32
+ }
33
+ `;
34
+ export const ExtendValuePopup = props => {
35
+ // Props
36
+ const { children, onApply = () => { } } = props, restProps = __rest(props, ["children", "onApply"]);
37
+ // State
38
+ const [state, setState] = useState({
39
+ isOpenPopover: false,
40
+ });
41
+ // Variables
42
+ const { isOpenPopover } = state;
43
+ // Hooks
44
+ const [form] = Form.useForm();
45
+ // Form
46
+ const extendValues = Form.useWatch('extendValues', form);
47
+ // Handlers
48
+ const onClosePopover = () => {
49
+ setState(prev => (Object.assign(Object.assign({}, prev), { isOpenPopover: false })));
50
+ form.resetFields();
51
+ };
52
+ const onFinishSubmit = (values) => {
53
+ const extendValues = uniq(splitTextByNewline(values.extendValues).filter(Boolean));
54
+ onApply(extendValues);
55
+ onClosePopover();
56
+ };
57
+ return (React.createElement(Popover, Object.assign({ open: isOpenPopover, overlayInnerStyle: {
58
+ padding: 0,
59
+ width: 500,
60
+ }, trigger: ['click'], arrow: false, placement: "topRight", onOpenChange: () => setState(prev => (Object.assign(Object.assign({}, prev), { isOpenPopover: !isOpenPopover }))) }, restProps, { content: React.createElement(ApplyPopupContent, { title: t(translations.extendValue.title).toString(), applyButtonProps: {
61
+ disabled: !(extendValues === null || extendValues === void 0 ? void 0 : extendValues.trim()),
62
+ }, onCancel: onClosePopover, onApply: () => form.submit() },
63
+ React.createElement(Form, { form: form, onFinish: onFinishSubmit },
64
+ React.createElement(Form.Item, { noStyle: true, name: "extendValues" },
65
+ React.createElement(TextArea, { autoSize: false, bordered: false, rows: 9, placeholder: t(translations.extendValue.placeholder).toString() })))) }), children));
66
+ };
@@ -0,0 +1,3 @@
1
+ import { ThemeConfig, TreeDataNode } from 'antd';
2
+ export declare const SAMPLE_DATA: TreeDataNode[];
3
+ export declare const MATCHES_ANY_THEME: ThemeConfig;