@antscorp/antsomi-ui 2.0.2 → 2.0.3

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 (50) hide show
  1. package/es/components/icons/LazyIcon/LazyIcon.d.ts +1 -0
  2. package/es/components/icons/LazyIcon/LazyIcon.js +1 -0
  3. package/es/components/icons/LongerIcon.d.ts +3 -0
  4. package/es/components/icons/LongerIcon.js +7 -0
  5. package/es/components/icons/index.d.ts +1 -0
  6. package/es/components/icons/index.js +1 -0
  7. package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +12 -2
  8. package/es/components/molecules/EditorTab/EditorTab.js +16 -6
  9. package/es/components/molecules/EditorTab/styled.js +4 -2
  10. package/es/components/molecules/EmptyData/styled.js +2 -1
  11. package/es/components/molecules/MatchAnySelect/MatchesAnySelect.d.ts +2 -2
  12. package/es/components/molecules/MatchAnySelect/MatchesAnySelect.js +78 -31
  13. package/es/components/molecules/MatchAnySelect/constants.d.ts +19 -0
  14. package/es/components/molecules/MatchAnySelect/constants.js +81 -0
  15. package/es/components/molecules/MatchAnySelect/styled.d.ts +6 -10
  16. package/es/components/molecules/MatchAnySelect/styled.js +62 -4
  17. package/es/components/molecules/MatchAnySelect/types.d.ts +42 -22
  18. package/es/components/molecules/SearchPopover/SearchPopover.js +1 -1
  19. package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.js +10 -7
  20. package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +17 -17
  21. package/es/components/molecules/SearchPopover/components/PopoverSelect/styled.d.ts +2 -2
  22. package/es/components/molecules/SearchPopover/components/PopoverSelect/styled.js +2 -3
  23. package/es/components/molecules/SearchPopover/types.d.ts +1 -1
  24. package/es/components/molecules/Tabs/index.d.ts +1 -0
  25. package/es/components/molecules/Tree/Tree.d.ts +26 -2
  26. package/es/components/molecules/Tree/Tree.js +26 -1
  27. package/es/components/molecules/Tree/index.d.ts +1 -0
  28. package/es/components/molecules/Tree/index.js +1 -0
  29. package/es/components/molecules/Tree/styled.d.ts +16 -0
  30. package/es/components/molecules/Tree/styled.js +24 -0
  31. package/es/components/molecules/Tree/utils.d.ts +10 -0
  32. package/es/components/molecules/Tree/utils.js +17 -0
  33. package/es/components/molecules/UploadImage/index.js +1 -1
  34. package/es/components/molecules/index.d.ts +1 -1
  35. package/es/components/molecules/index.js +1 -1
  36. package/es/components/organism/AlgorithmsSetting/styled.d.ts +1 -1
  37. package/es/components/organism/Help/Help.js +27 -33
  38. package/es/components/organism/Help/styled.d.ts +0 -5
  39. package/es/components/organism/Help/styled.js +27 -38
  40. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.js +3 -3
  41. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.js +4 -2
  42. package/es/components/template/TemplateListing/index.js +5 -3
  43. package/es/constants/theme.js +13 -10
  44. package/es/index.d.ts +2 -0
  45. package/es/index.js +1 -0
  46. package/es/providers/ConfigProvider/GlobalStyle.js +10 -2
  47. package/es/test.js +5 -6
  48. package/es/tests/MatchesAnySelect.js +70 -4
  49. package/es/utils/common.js +1 -1
  50. package/package.json +1 -1
@@ -204,6 +204,7 @@ export declare const LazyIcon: {
204
204
  backgroundColor?: string | undefined;
205
205
  } & import("react").RefAttributes<SVGSVGElement>>>;
206
206
  LocalMallIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
207
+ LongerIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
207
208
  MapIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
208
209
  MarkAsReadIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
209
210
  MarketingHub30Icon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
@@ -208,6 +208,7 @@ export const LazyIcon = {
208
208
  ListIcon: lazy(() => import('../ListIcon').then(m => ({ default: m.ListIcon }))),
209
209
  LoadingIcon: lazy(() => import('../LoadingIcon').then(m => ({ default: m.LoadingIcon }))),
210
210
  LocalMallIcon: lazy(() => import('../LocalMallIcon').then(m => ({ default: m.LocalMallIcon }))),
211
+ LongerIcon: lazy(() => import('../LongerIcon').then(m => ({ default: m.LongerIcon }))),
211
212
  MapIcon: lazy(() => import('../MapIcon').then(m => ({ default: m.MapIcon }))),
212
213
  MarkAsReadIcon: lazy(() => import('../MarkAsReadIcon').then(m => ({ default: m.MarkAsReadIcon }))),
213
214
  MarketingHub30Icon: lazy(() => import('../MarketingHub30Icon').then(m => ({ default: m.MarketingHub30Icon }))),
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { IconProps } from './types';
3
+ export declare const LongerIcon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,7 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { useIcon } from './hooks/useIcon';
3
+ export const LongerIcon = forwardRef((props, ref) => {
4
+ const { width, height } = useIcon(props);
5
+ return (React.createElement("svg", Object.assign({ viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props, { ref: ref, width: width, height: height }),
6
+ React.createElement("path", { d: "M14.0156 17.0156V18.9844H3.98438V17.0156H14.0156ZM20.0156 9V11.0156H3.98438V9H20.0156ZM3.98438 15V12.9844H20.0156V15H3.98438ZM3.98438 5.01562H20.0156V6.98438H3.98438V5.01562Z", fill: "currentColor" })));
7
+ });
@@ -200,6 +200,7 @@ export { LinkManagementIcon } from './LinkManagementIcon';
200
200
  export { ListIcon } from './ListIcon';
201
201
  export { LoadingIcon } from './LoadingIcon';
202
202
  export { LocalMallIcon } from './LocalMallIcon';
203
+ export { LongerIcon } from './LongerIcon';
203
204
  export { MapIcon } from './MapIcon';
204
205
  export { MarkAsReadIcon } from './MarkAsReadIcon';
205
206
  export { MarketingHub30Icon } from './MarketingHub30Icon';
@@ -200,6 +200,7 @@ export { LinkManagementIcon } from './LinkManagementIcon';
200
200
  export { ListIcon } from './ListIcon';
201
201
  export { LoadingIcon } from './LoadingIcon';
202
202
  export { LocalMallIcon } from './LocalMallIcon';
203
+ export { LongerIcon } from './LongerIcon';
203
204
  export { MapIcon } from './MapIcon';
204
205
  export { MarkAsReadIcon } from './MarkAsReadIcon';
205
206
  export { MarketingHub30Icon } from './MarketingHub30Icon';
@@ -64,6 +64,8 @@ export const AdvancedPicker = props => {
64
64
  },
65
65
  date: dayjs().tz(timezone).format(format),
66
66
  dateDisplay: dayjs().tz(timezone).format(format),
67
+ // date: dayjs(propsDate).tz(timezone).format(format),
68
+ // dateDisplay: dayjs(propsDate).tz(timezone).format(format),
67
69
  });
68
70
  const { isOpen, option, date, dateDisplay } = state;
69
71
  const isShowFixed = option.dateType.value === 'fixed' || onlyShowFixed;
@@ -146,9 +148,17 @@ export const AdvancedPicker = props => {
146
148
  }
147
149
  }, [option, format, timezone]);
148
150
  useDeepCompareEffect(() => {
151
+ const DEFAULT_OPTION = onlyShowFixed
152
+ ? {
153
+ dateType: 'fixed',
154
+ calculationDate: 'days',
155
+ calculationType: 'minus',
156
+ value: 0,
157
+ }
158
+ : {};
149
159
  try {
150
- if (propsOption) {
151
- const { dateType, calculationType, calculationDate, value = 0 } = propsOption || {};
160
+ if (propsOption || onlyShowFixed) {
161
+ const { dateType, calculationType, calculationDate, value = 0, } = propsOption || DEFAULT_OPTION;
152
162
  const newDateTypes = DATE_TYPES;
153
163
  const newDateType = newDateTypes.find(dType => dType.value === dateType);
154
164
  const newCalculationType = CALCULATION_TYPES.find(calType => calType.value === calculationType);
@@ -19,7 +19,7 @@ import { EditorTabStyled } from './styled';
19
19
  import { handleError } from '@antscorp/antsomi-ui/es/utils';
20
20
  const PATH = 'src/components/EditorTab/index.jsx';
21
21
  export const EditorTab = props => {
22
- var _a;
22
+ var _a, _b, _c, _d, _e;
23
23
  const { listTab = [], activeId = '', showArrow, showDropdown, editNameOnConfigure,
24
24
  // disabledScroll,
25
25
  onCloseTab, onClickRemoveTab, onConfirmRemove, onActiveTab, onAddTab, onConfigure, onSaveName, newTabText, showComposeNewQuery, className, leftBlockClassName, tabItemClassName, confirmOnRemoveTab, modalFuncProps, } = props;
@@ -28,7 +28,17 @@ export const EditorTab = props => {
28
28
  const [isEditable, setIsEditable] = useState();
29
29
  const [modal, contextModal] = Modal.useModal();
30
30
  // Ref
31
+ const [offsetWidth, setOffsetWidth] = useState(0);
32
+ const [scrollWidth, setScrollWidth] = useState(0);
31
33
  const leftBlockRef = useRef(null);
34
+ const isLeftBlockOverflow = ((_b = leftBlockRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) && ((_c = leftBlockRef.current) === null || _c === void 0 ? void 0 : _c.scrollWidth)
35
+ ? ((_d = leftBlockRef.current) === null || _d === void 0 ? void 0 : _d.offsetWidth) < ((_e = leftBlockRef.current) === null || _e === void 0 ? void 0 : _e.scrollWidth)
36
+ : offsetWidth < scrollWidth;
37
+ useEffect(() => {
38
+ var _a, _b;
39
+ setOffsetWidth(((_a = leftBlockRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0);
40
+ setScrollWidth(((_b = leftBlockRef.current) === null || _b === void 0 ? void 0 : _b.scrollWidth) || 0);
41
+ }, []);
32
42
  useEffect(() => {
33
43
  if (listTab.length - arrTabs.length === 1) {
34
44
  setActiveTabId(listTab[listTab.length - 1].id);
@@ -94,7 +104,7 @@ export const EditorTab = props => {
94
104
  onActiveTab(tabId);
95
105
  }, [onActiveTab]);
96
106
  const handleCloseTab = (e, tab, idx) => __awaiter(void 0, void 0, void 0, function* () {
97
- var _b, _c;
107
+ var _f, _g;
98
108
  e.stopPropagation();
99
109
  // if (arrTabs.length < 2) {
100
110
  // return;
@@ -110,10 +120,10 @@ export const EditorTab = props => {
110
120
  return;
111
121
  if (activeTabId === tab.id) {
112
122
  if (idx === arrTabs.length - 1) {
113
- handleActiveTab((_b = arrTabs[idx - 1]) === null || _b === void 0 ? void 0 : _b.id);
123
+ handleActiveTab((_f = arrTabs[idx - 1]) === null || _f === void 0 ? void 0 : _f.id);
114
124
  }
115
125
  else if (arrTabs.length > 1) {
116
- handleActiveTab((_c = arrTabs[idx + 1]) === null || _c === void 0 ? void 0 : _c.id);
126
+ handleActiveTab((_g = arrTabs[idx + 1]) === null || _g === void 0 ? void 0 : _g.id);
117
127
  }
118
128
  }
119
129
  onCloseTab === null || onCloseTab === void 0 ? void 0 : onCloseTab(tab, idx, newTabs);
@@ -153,7 +163,7 @@ export const EditorTab = props => {
153
163
  }, [activeTabId, arrTabs, handleActiveTab]);
154
164
  return (React.createElement(EditorTabStyled, { className: className || '' },
155
165
  contextModal,
156
- showArrow && (React.createElement("div", { className: "navigate-button", onClick: () => onClickArrow('left') },
166
+ showArrow && isLeftBlockOverflow && (React.createElement("div", { className: "navigate-button", onClick: () => onClickArrow('left') },
157
167
  React.createElement(Icon, { type: "icon-ants-angle-left" }))),
158
168
  React.createElement("div", { ref: leftBlockRef, className: classnames('left-block', leftBlockClassName), onWheel: onWheelLeftBlock }, arrTabs && arrTabs.length
159
169
  ? arrTabs.map((tab, idx) => {
@@ -192,7 +202,7 @@ export const EditorTab = props => {
192
202
  React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-three-dot-vertical", overlayStyle: { fontSize: 12 } }), size: "small" }))) : closable ? (React.createElement(Button, { onClick: e => handleCloseTab(e, tab, idx), icon: React.createElement(Icon, { type: "icon-ants-remove-slim", overlayStyle: { fontSize: 12 } }), size: "small" })) : null));
193
203
  })
194
204
  : null),
195
- showArrow && (React.createElement("div", { className: "navigate-button", onClick: () => onClickArrow('right') },
205
+ showArrow && isLeftBlockOverflow && (React.createElement("div", { className: "navigate-button", onClick: () => onClickArrow('right') },
196
206
  React.createElement(Icon, { type: "icon-ants-angle-right" }))),
197
207
  showComposeNewQuery || newTabText ? (React.createElement(Button, { onClick: handleAddNew, className: "new-query-button" },
198
208
  React.createElement(Icon, { type: "icon-ants-add-square", style: { fontSize: '16px' } }),
@@ -47,11 +47,13 @@ export const EditorTabStyled = styled.div `
47
47
  align-items: center;
48
48
  flex-shrink: 0;
49
49
  gap: 7px;
50
- width: 150px;
50
+ /* width: 150px; */
51
+ min-width: 150px;
52
+ max-width: 300px;
53
+
51
54
  height: 40px;
52
55
  padding: 0 10px;
53
56
  overflow: hidden;
54
- max-width: 200px;
55
57
  background-color: ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.bw2};
56
58
 
57
59
  /* &.active button, */
@@ -9,7 +9,8 @@ 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
+ padding: 20px 0px;
13
+ text-align: center;
13
14
 
14
15
  .title {
15
16
  font-size: 14px;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { MatchesAnyProps, MatchesAnySelectProps } from './types';
3
- export declare const MatchesAny: React.FC<MatchesAnyProps>;
4
- export declare const MatchesAnySelect: React.FC<MatchesAnySelectProps>;
3
+ export declare function MatchesAny<TItem = Record<string, any>>(props: MatchesAnyProps<TItem>): React.JSX.Element;
4
+ export declare function MatchesAnySelect<TItem = Record<string, any>>(props: MatchesAnySelectProps<TItem>): React.JSX.Element;
@@ -9,17 +9,18 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
+ /* eslint-disable react/function-component-definition */
12
13
  /* eslint-disable react/destructuring-assignment */
13
14
  // Libraries
14
15
  import { ConfigProvider } from 'antd';
15
16
  import { uniqBy } from 'lodash';
16
- import React, { useEffect, useMemo, useState } from 'react';
17
+ import React, { useEffect, useState } from 'react';
17
18
  // Components
18
- import { EmptyData, Select } from '@antscorp/antsomi-ui/es/components/molecules';
19
+ import { EmptyData, PopoverSelect, Select } from '@antscorp/antsomi-ui/es/components/molecules';
19
20
  import { Button, Flex, Icon, Input, Popover, Scrollbars, Spin, Typography, Tooltip, } from '@antscorp/antsomi-ui/es/components/atoms';
20
21
  import { ExtendValuePopup } from './components/ExtendValuePopup';
21
22
  // Styled
22
- import { MatchesAnyWrapper, ActionButton, StyledTree, TextButton } from './styled';
23
+ import { MatchesAnyWrapper, ActionButton, StyledTree, TextButton, GroupSelectButton, ExtraValueLabel, } from './styled';
23
24
  // Locales
24
25
  import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
25
26
  import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
@@ -30,7 +31,8 @@ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
30
31
  import { useDeepCompareEffect, useDeepCompareMemo, useIntersectionObserver, } from '@antscorp/antsomi-ui/es/hooks';
31
32
  // Utils
32
33
  import { flatTree, recursiveSearchItems } from '@antscorp/antsomi-ui/es/utils';
33
- import { DataIcon } from '../../icons';
34
+ import { DataIcon, WarningIcon } from '../../icons';
35
+ import clsx from 'clsx';
34
36
  const initialState = {
35
37
  isOpenPopover: false,
36
38
  };
@@ -41,13 +43,15 @@ const matchesAnyInitialState = {
41
43
  };
42
44
  const { t } = i18nInstance;
43
45
  const { Text } = Typography;
44
- export const MatchesAny = props => {
46
+ export function MatchesAny(props) {
45
47
  // Props
46
- const { objectName, loading = false, showExtendValue = true, items, onApply = () => { }, onCancel = () => { }, onLoadMore = () => { } } = props, restOfProps = __rest(props, ["objectName", "loading", "showExtendValue", "items", "onApply", "onCancel", "onLoadMore"]);
48
+ const { objectName, loading = false, showExtendValue = true, items, groupSelectProps, renderExtraValues, customItemRenders, listEmptyProps, selectedListEmptyProps, onApply = () => { }, onCancel = () => { }, onLoadMore = () => { }, onChangeSearch } = props, restOfProps = __rest(props, ["objectName", "loading", "showExtendValue", "items", "groupSelectProps", "renderExtraValues", "customItemRenders", "listEmptyProps", "selectedListEmptyProps", "onApply", "onCancel", "onLoadMore", "onChangeSearch"]);
47
49
  // State
48
50
  const [state, setState] = useState(matchesAnyInitialState);
49
51
  // Variables
50
52
  const { searchValue, selectedItems, isShowLoadMoreEl } = state;
53
+ const _a = listEmptyProps || {}, { icon: listEmptyIcon, description: listEmptyDescription = t(translations.global.noResultsMatchesKeyWord).toString() } = _a, restListEmptyProps = __rest(_a, ["icon", "description"]);
54
+ const _b = selectedListEmptyProps || {}, { description: selectedListEmptyDescription = t(translations.global.selectItemsFromList).toString(), icon: selectedListEmptyIcon = React.createElement(DataIcon, { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw5, size: 48 }) } = _b, restSelectedListEmptyProps = __rest(_b, ["description", "icon"]);
51
55
  // Refs
52
56
  const { ref: loadMoreRef } = useIntersectionObserver({
53
57
  threshold: 0,
@@ -121,13 +125,31 @@ export const MatchesAny = props => {
121
125
  const onRemoveAll = () => {
122
126
  setState(prev => (Object.assign(Object.assign({}, prev), { selectedItems: [] })));
123
127
  };
124
- const renderItemNodeTitle = ({ item, onSelectItem, onRemoveItem, }) => {
128
+ const renderItemError = (item) => {
129
+ if (customItemRenders === null || customItemRenders === void 0 ? void 0 : customItemRenders.error) {
130
+ return customItemRenders === null || customItemRenders === void 0 ? void 0 : customItemRenders.error(item);
131
+ }
132
+ return item.error ? (React.createElement(Tooltip, { title: item.error },
133
+ React.createElement(WarningIcon, { size: 16 }))) : null;
134
+ };
135
+ const renderItemNodeTitle = ({ item, mode = 'unselect', onSelectItem, onRemoveItem, }) => {
136
+ var _a, _b;
125
137
  const { isExtendValue, title, subTitle } = item; // Destructure properties from item
126
138
  return (React.createElement(React.Fragment, null,
127
- React.createElement("div", { className: "title-content" },
128
- React.createElement(Text, { ellipsis: { tooltip: true } }, title),
129
- subTitle && (React.createElement(Text, { className: "sub-title", ellipsis: { tooltip: true }, style: { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 } }, subTitle))),
130
- React.createElement(Flex, { align: "center", gap: 5 },
139
+ React.createElement("div", { className: clsx('title-content', {
140
+ 'extra-value': !!(renderExtraValues === null || renderExtraValues === void 0 ? void 0 : renderExtraValues.length),
141
+ }) },
142
+ React.createElement(Flex, { vertical: true, gap: 5, className: "left-content" },
143
+ React.createElement(Text, { ellipsis: { tooltip: `${item.title || ''}` } }, ((_a = customItemRenders === null || customItemRenders === void 0 ? void 0 : customItemRenders.title) === null || _a === void 0 ? void 0 : _a.call(customItemRenders, item)) || title),
144
+ subTitle && (React.createElement(Text, { className: "sub-title", ellipsis: { tooltip: `${item.subTitle || ''}` }, style: { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 } }, ((_b = customItemRenders === null || customItemRenders === void 0 ? void 0 : customItemRenders.subTitle) === null || _b === void 0 ? void 0 : _b.call(customItemRenders, item)) || subTitle))),
145
+ !!(renderExtraValues === null || renderExtraValues === void 0 ? void 0 : renderExtraValues.length) && (React.createElement(Flex, { align: "center", gap: 10 }, renderExtraValues.map(extraValue => (React.createElement("div", { className: "extra-value-content", key: `${extraValue.key}` },
146
+ React.createElement(Text, { ellipsis: { tooltip: true } }, extraValue.render
147
+ ? typeof extraValue.render === 'function'
148
+ ? extraValue.render(item)
149
+ : extraValue.render
150
+ : item[extraValue.key]))))))),
151
+ React.createElement(Flex, { align: "center", gap: 10 },
152
+ mode === 'select' && renderItemError(item),
131
153
  isExtendValue && (React.createElement(Icon, { type: "icon-ants-empty-flag", size: 20, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary })),
132
154
  React.createElement(ActionButton, { className: "select-button", align: "center", justify: "center", onClick: () => {
133
155
  // Call onSelectItem function if provided
@@ -142,11 +164,12 @@ export const MatchesAny = props => {
142
164
  React.createElement(Icon, { type: `icon-ants-${onSelectItem ? 'double-arrow-up' : 'remove-slim'}`, size: 11 })))));
143
165
  };
144
166
  // Memos
145
- const { treeData, matchedParents } = useMemo(() => {
167
+ const { treeData, matchedParents } = useDeepCompareMemo(() => {
168
+ var _a;
146
169
  const { results, matchedParents } = recursiveSearchItems({
147
170
  list: items || [],
148
171
  searchKeys: ['title', 'key'],
149
- searchValue,
172
+ searchValue: !onChangeSearch ? searchValue : '',
150
173
  childrenKey: 'children',
151
174
  });
152
175
  const serializeTreeData = (list) => list.map(item => {
@@ -171,10 +194,14 @@ export const MatchesAny = props => {
171
194
  children: serializeTreeData(item.children),
172
195
  }));
173
196
  });
174
- const treeData = serializeTreeData(results);
197
+ let treeData = serializeTreeData(results);
198
+ // Filter the tree data based on the group selected items
199
+ if (groupSelectProps && ((_a = groupSelectProps.selected) === null || _a === void 0 ? void 0 : _a.length)) {
200
+ treeData = treeData.filter(item => { var _a; return (_a = groupSelectProps.selected) === null || _a === void 0 ? void 0 : _a.includes(item.key); });
201
+ }
175
202
  return { treeData, matchedParents };
176
- }, [items, searchValue, selectedItems]);
177
- const selectedTreeData = useMemo(() => {
203
+ }, [items, searchValue, selectedItems, groupSelectProps, onChangeSearch]);
204
+ const selectedTreeData = useDeepCompareMemo(() => {
178
205
  var _a;
179
206
  const notExtendValueSelectedItems = (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.filter(item => !item.isExtendValue)) || [];
180
207
  const extendValueSelectedItems = (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.filter(item => item.isExtendValue)) || [];
@@ -194,11 +221,11 @@ export const MatchesAny = props => {
194
221
  ? flatTree(item.children, 'children').some(item => notExtendValueSelectedItems === null || notExtendValueSelectedItems === void 0 ? void 0 : notExtendValueSelectedItems.some(selectedItem => selectedItem.key === item.key))
195
222
  : notExtendValueSelectedItems === null || notExtendValueSelectedItems === void 0 ? void 0 : notExtendValueSelectedItems.some(selectedItem => selectedItem.key === item.key);
196
223
  return isSelected;
197
- })) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign(Object.assign({}, item), { title: renderItemNodeTitle({ item, onRemoveItem }) }), (item.children && {
224
+ })) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign(Object.assign(Object.assign({}, item), { title: renderItemNodeTitle({ item, mode: 'select', onRemoveItem }) }), (item.children && {
198
225
  children: serializeTreeData(item.children),
199
- }))))) || [];
226
+ })), (!!item.error && { className: 'error-node' }))))) || [];
200
227
  };
201
- return serializeTreeData(items || []).concat(((_a = [...lazyLoadSelectedItems, ...extendValueSelectedItems]) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign({}, item), { title: renderItemNodeTitle({ item, onRemoveItem }) })))) || []);
228
+ return serializeTreeData(items || []).concat(((_a = [...lazyLoadSelectedItems, ...extendValueSelectedItems]) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign({}, item), { title: renderItemNodeTitle({ item, mode: 'select', onRemoveItem }) })))) || []);
202
229
  }, [items, selectedItems]);
203
230
  const isDisableRemoveAll = useDeepCompareMemo(() => !(selectedTreeData === null || selectedTreeData === void 0 ? void 0 : selectedTreeData.length), [selectedTreeData]);
204
231
  const isDisableSelectAll = useDeepCompareMemo(() => {
@@ -206,30 +233,50 @@ export const MatchesAny = props => {
206
233
  return !(flattenTreeData === null || flattenTreeData === void 0 ? void 0 : flattenTreeData.some(item => !item.disabled));
207
234
  }, [treeData]);
208
235
  // Renders
236
+ const renderExtraValueLabels = () => {
237
+ if (renderExtraValues === null || renderExtraValues === void 0 ? void 0 : renderExtraValues.length) {
238
+ return renderExtraValues.map((extraValue, index) => (React.createElement(ExtraValueLabel, { key: extraValue.key || index },
239
+ React.createElement(Text, { strong: true, ellipsis: { tooltip: true } }, extraValue.label))));
240
+ }
241
+ return null;
242
+ };
209
243
  const renderSelectList = () => {
210
- var _a;
244
+ var _a, _b;
211
245
  return (React.createElement("div", { className: "matches-any__section matches-any__section--left" },
212
246
  React.createElement("div", { className: "matches-any__header" },
247
+ !!groupSelectProps && (React.createElement(PopoverSelect, Object.assign({}, groupSelectProps),
248
+ React.createElement(GroupSelectButton, { type: "default", size: "small", shape: "round" },
249
+ React.createElement("span", { className: "group-name" }, groupSelectProps === null || groupSelectProps === void 0 ? void 0 :
250
+ groupSelectProps.name,
251
+ ":"),
252
+ `${((_a = groupSelectProps === null || groupSelectProps === void 0 ? void 0 : groupSelectProps.selected) === null || _a === void 0 ? void 0 : _a.length) || 0} ${t(translations.global.selected)}`))),
213
253
  React.createElement("div", { style: { width: '100%' } },
214
- 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 }))) }))),
254
+ React.createElement(Input.CustomSearch, { placeholder: `${(_b = t(translations.global.search)) === null || _b === void 0 ? void 0 : _b.toString()}...`, onAfterChange: searchValue => {
255
+ setState(prev => (Object.assign(Object.assign({}, prev), { searchValue })));
256
+ if (onChangeSearch) {
257
+ onChangeSearch(searchValue);
258
+ }
259
+ } }))),
215
260
  React.createElement("div", { className: "matches-any__body" },
216
261
  React.createElement(Flex, { align: "center", justify: "space-between" },
217
262
  React.createElement(Text, { strong: true }, `${objectName} (${flatTree(items, 'children').filter(item => !item.children).length})`),
218
- React.createElement(TextButton, { disabled: isDisableSelectAll, onClick: onSelectAll }, t(translations.global.selectAll).toString())),
263
+ React.createElement(Flex, { align: "center", gap: 10 },
264
+ renderExtraValueLabels(),
265
+ React.createElement(TextButton, { disabled: isDisableSelectAll, onClick: onSelectAll }, t(translations.global.selectAll).toString()))),
219
266
  React.createElement(Spin, { spinning: loading },
220
267
  React.createElement(Scrollbars, { style: { height: '100%' } }, (treeData === null || treeData === void 0 ? void 0 : treeData.length) ? (React.createElement(React.Fragment, null,
221
268
  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: {
222
269
  transform: props.expanded ? 'rotate(0)' : 'rotate(-90deg)',
223
270
  transition: 'transform 0.3s ease',
224
271
  }, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 })) }),
225
- isShowLoadMoreEl && React.createElement("div", { ref: loadMoreRef }))) : (React.createElement(EmptyData, { showIcon: false, description: t(translations.global.noResultsMatchesKeyWord).toString() })))))));
272
+ isShowLoadMoreEl && React.createElement("div", { ref: loadMoreRef }))) : (React.createElement(EmptyData, Object.assign({ icon: listEmptyIcon, showIcon: !!listEmptyIcon, description: listEmptyDescription }, restListEmptyProps))))))));
226
273
  };
227
274
  const renderSelectedList = () => (React.createElement("div", { className: "matches-any__section" },
228
275
  React.createElement(Flex, { className: "matches-any__header", justify: "space-between" },
229
276
  React.createElement(Text, { strong: true }, `${t(translations.global.selected)} (${(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) || 0})`),
230
277
  React.createElement(TextButton, { disabled: isDisableRemoveAll, onClick: onRemoveAll }, t(translations.global.removeAll).toString())),
231
278
  React.createElement("div", { className: "matches-any__body" },
232
- React.createElement(Scrollbars, { style: { height: '100%' } }, !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) ? (React.createElement(EmptyData, { icon: React.createElement(DataIcon, { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw5, size: 48 }), description: t(translations.global.selectItemsFromList).toString() })) : (React.createElement(StyledTree, { selectable: false, treeData: selectedTreeData, switcherIcon: props => (React.createElement(Icon, { type: "icon-ants-caret-down", style: {
279
+ React.createElement(Scrollbars, { style: { height: '100%' } }, !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) ? (React.createElement(EmptyData, Object.assign({ icon: selectedListEmptyIcon, description: selectedListEmptyDescription }, restSelectedListEmptyProps))) : (React.createElement(StyledTree, { selectable: false, treeData: selectedTreeData, switcherIcon: props => (React.createElement(Icon, { type: "icon-ants-caret-down", style: {
233
280
  transform: props.expanded ? 'rotate(0)' : 'rotate(-90deg)',
234
281
  transition: 'transform 0.3s ease',
235
282
  }, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 })) }))))));
@@ -257,12 +304,12 @@ export const MatchesAny = props => {
257
304
  React.createElement(Flex, { align: "center", gap: 10 },
258
305
  React.createElement(Button, { type: "primary", onClick: () => onApply(selectedItems || []) }, t(translations.apply.title).toString()),
259
306
  React.createElement(Button, { onClick: () => onCancel() }, t(translations.cancel.title).toString())),
260
- showExtendValue && (React.createElement(ExtendValuePopup, { onApply: onApplyExtendValue },
307
+ showExtendValue && (React.createElement(ExtendValuePopup, { getPopupContainer: trigger => trigger.parentElement || document.body, onApply: onApplyExtendValue },
261
308
  React.createElement(Button, { icon: React.createElement(Icon, { type: "icon-ants-empty-flag" }) }, t(translations.extendValue.title).toString())))))));
262
- };
263
- export const MatchesAnySelect = props => {
309
+ }
310
+ export function MatchesAnySelect(props) {
264
311
  var _a, _b, _c;
265
- const { placeholder = 'Select an item', dropdownStyle, objectName, selectedItems, items, loading, popupClassName, onChange = () => { }, onLoadMore } = props, restProps = __rest(props, ["placeholder", "dropdownStyle", "objectName", "selectedItems", "items", "loading", "popupClassName", "onChange", "onLoadMore"]);
312
+ const { placeholder = 'Select an item', dropdownStyle, objectName, selectedItems, items, loading, popupClassName, groupSelectProps, renderExtraValues, customItemRenders, popoverProps, listEmptyProps, selectedListEmptyProps, onChangeSearch, onChange = () => { }, onLoadMore } = props, restProps = __rest(props, ["placeholder", "dropdownStyle", "objectName", "selectedItems", "items", "loading", "popupClassName", "groupSelectProps", "renderExtraValues", "customItemRenders", "popoverProps", "listEmptyProps", "selectedListEmptyProps", "onChangeSearch", "onChange", "onLoadMore"]);
266
313
  // State
267
314
  const [state, setState] = useState(initialState);
268
315
  // Variables
@@ -275,14 +322,14 @@ export const MatchesAnySelect = props => {
275
322
  onChange(selectedItems);
276
323
  setState(prev => (Object.assign(Object.assign({}, prev), { isOpenPopover: false })));
277
324
  };
278
- return (React.createElement(Popover, { open: isOpenPopover, arrow: false, placement: "bottomLeft", content: React.createElement(MatchesAny, { className: popupClassName, items: items, selectedItems: selectedItems, loading: loading, objectName: objectName, onApply: onApplyMatchesAny, onCancel: () => setState(prev => (Object.assign(Object.assign({}, prev), { isOpenPopover: false }))), onLoadMore: onLoadMore }), align: {
325
+ return (React.createElement(Popover, Object.assign({ open: isOpenPopover, arrow: false, placement: "bottomLeft", content: React.createElement(MatchesAny, { className: popupClassName, items: items, selectedItems: selectedItems, loading: loading, objectName: objectName, groupSelectProps: groupSelectProps, renderExtraValues: renderExtraValues, customItemRenders: customItemRenders, listEmptyProps: listEmptyProps, selectedListEmptyProps: selectedListEmptyProps, onChangeSearch: onChangeSearch, onApply: onApplyMatchesAny, onCancel: () => setState(prev => (Object.assign(Object.assign({}, prev), { isOpenPopover: false }))), onLoadMore: onLoadMore }), align: {
279
326
  overflow: {
280
327
  shiftY: 0,
281
328
  shiftX: 0,
282
329
  },
283
330
  }, overlayStyle: { width: 700 }, overlayInnerStyle: {
284
331
  padding: 0,
285
- }, trigger: ['click'], destroyTooltipOnHide: true, onOpenChange: () => setState(prev => (Object.assign(Object.assign({}, prev), { isOpenPopover: !isOpenPopover }))) },
332
+ }, trigger: ['click'], destroyTooltipOnHide: true, onOpenChange: () => setState(prev => (Object.assign(Object.assign({}, prev), { isOpenPopover: !isOpenPopover }))), zIndex: 1400 }, popoverProps),
286
333
  React.createElement(Tooltip, { mouseEnterDelay: 0.5, title: `${selectedItems ? selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.map(item => item.title).join(', ') : ''}` },
287
334
  React.createElement(Select, Object.assign({ title: "", value: value, placeholder: placeholder, popupMatchSelectWidth: 700, dropdownStyle: Object.assign(Object.assign({}, dropdownStyle), { display: 'none', padding: 0 }), loading: loading }, restProps)))));
288
- };
335
+ }
@@ -1,3 +1,22 @@
1
1
  import { ThemeConfig, TreeDataNode } from 'antd';
2
+ /** The width of the extra value */
3
+ export declare const EXTRA_VALUE_WIDTH = 70;
4
+ /** The shift width of the extra value */
5
+ export declare const EXTRA_VALUE_SHIFT_WIDTH = 54;
2
6
  export declare const SAMPLE_DATA: TreeDataNode[];
3
7
  export declare const MATCHES_ANY_THEME: ThemeConfig;
8
+ export declare const EXTRA_VALUE_SAMPLE_DATA: {
9
+ rowCount: string;
10
+ portalId: number;
11
+ itemTypeId: number;
12
+ status: number;
13
+ isSort: number;
14
+ isFilter: number;
15
+ preDefined: number;
16
+ segmentSize: string;
17
+ utime: string;
18
+ processStatus: string;
19
+ id: number;
20
+ name: string;
21
+ code: string;
22
+ }[];
@@ -1,3 +1,7 @@
1
+ /** The width of the extra value */
2
+ export const EXTRA_VALUE_WIDTH = 70;
3
+ /** The shift width of the extra value */
4
+ export const EXTRA_VALUE_SHIFT_WIDTH = 54;
1
5
  export const SAMPLE_DATA = [
2
6
  {
3
7
  key: '12179',
@@ -302,3 +306,80 @@ export const MATCHES_ANY_THEME = {
302
306
  },
303
307
  },
304
308
  };
309
+ export const EXTRA_VALUE_SAMPLE_DATA = [
310
+ {
311
+ rowCount: '5',
312
+ portalId: 564890051,
313
+ itemTypeId: -1003,
314
+ status: 3,
315
+ isSort: 1,
316
+ isFilter: 1,
317
+ preDefined: 0,
318
+ segmentSize: '91',
319
+ utime: '2024-03-06T18:00:03.336Z',
320
+ processStatus: '2',
321
+ id: 5110110,
322
+ name: 'ANTSOMI',
323
+ code: 'sgmt_5110110',
324
+ },
325
+ {
326
+ rowCount: '5',
327
+ portalId: 564890051,
328
+ itemTypeId: -1003,
329
+ status: 4,
330
+ isSort: 1,
331
+ isFilter: 1,
332
+ preDefined: 0,
333
+ segmentSize: '686',
334
+ utime: '2024-08-12T07:56:53.750Z',
335
+ processStatus: '2',
336
+ id: 5562963,
337
+ name: 'CLIENT',
338
+ code: 'sgmt_5562963',
339
+ },
340
+ {
341
+ rowCount: '5',
342
+ portalId: 564890051,
343
+ itemTypeId: -1003,
344
+ status: 2,
345
+ isSort: 1,
346
+ isFilter: 1,
347
+ preDefined: 0,
348
+ segmentSize: '265',
349
+ utime: '2024-05-14T09:48:16.678Z',
350
+ processStatus: '2',
351
+ id: 16368074,
352
+ name: 'Lead BSS send to client 14/5',
353
+ code: 'sgmt_16368074',
354
+ },
355
+ {
356
+ rowCount: '5',
357
+ portalId: 564890051,
358
+ itemTypeId: -1003,
359
+ status: 1,
360
+ isSort: 1,
361
+ isFilter: 1,
362
+ preDefined: 0,
363
+ segmentSize: '49',
364
+ utime: '2024-06-24T10:48:40.007Z',
365
+ processStatus: '2',
366
+ id: 17172749,
367
+ name: 'Customer - Antsomian',
368
+ code: 'sgmt_17172749',
369
+ },
370
+ {
371
+ rowCount: '5',
372
+ portalId: 564890051,
373
+ itemTypeId: -1003,
374
+ status: 1,
375
+ isSort: 1,
376
+ isFilter: 1,
377
+ preDefined: 0,
378
+ segmentSize: '534',
379
+ utime: '2024-06-26T08:57:01.839Z',
380
+ processStatus: '2',
381
+ id: 17190312,
382
+ name: 'Ba thang chua quay lai App OCB',
383
+ code: 'sgmt_17190312',
384
+ },
385
+ ];
@@ -3,15 +3,11 @@ export declare const MatchesAnyWrapper: import("styled-components").StyledCompon
3
3
  export declare const TextButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/typography/Text").TextProps & import("react").RefAttributes<HTMLSpanElement>>, any, {
4
4
  disabled?: boolean | undefined;
5
5
  }, never>;
6
- export declare const ActionButton: 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>;
7
- export declare const StyledTree: import("styled-components").StyledComponent<(<T extends import("rc-tree").BasicDataNode | import("rc-tree/lib/interface").DataNode = import("rc-tree/lib/interface").DataNode>(props: import("antd/es/tree/Tree").TreeProps<T> & {
8
- children?: import("react").ReactNode;
9
- } & import("react").RefAttributes<import("rc-tree").default<import("rc-tree/lib/interface").DataNode>>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) & {
10
- TreeNode: import("react").FC<import("rc-tree").TreeNodeProps<import("rc-tree/lib/interface").DataNode>>;
11
- DirectoryTree: (<T_1 extends import("rc-tree").BasicDataNode | import("rc-tree/lib/interface").DataNode = import("rc-tree/lib/interface").DataNode>(props: import("antd/es/tree").DirectoryTreeProps<T_1> & {
12
- children?: import("react").ReactNode;
13
- } & import("react").RefAttributes<import("rc-tree").default<import("rc-tree/lib/interface").DataNode>>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) & {
14
- displayName?: string | undefined;
15
- };
6
+ export declare const GroupSelectButton: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/button/button").ButtonProps & import("react").RefAttributes<HTMLElement>> & {
7
+ Group: import("react").FC<import("antd/es/button").ButtonGroupProps>;
16
8
  }, any, {}, never>;
9
+ export declare const ActionButton: 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>;
10
+ export declare const StyledTree: import("styled-components").StyledComponent<import("react").ComponentType<any> | keyof import("react").JSX.IntrinsicElements, any, any, any>;
17
11
  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, {}, never>;
12
+ export declare const ExtraValueLabel: import("styled-components").StyledComponent<"div", any, {}, never>;
13
+ export declare const ItemStatus: 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>;