@antscorp/antsomi-ui 1.3.5-beta.673 → 1.3.5-beta.675
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.
- package/es/components/molecules/MatchAnySelect/MatchesAnySelect.js +13 -8
- package/es/components/molecules/MatchAnySelect/styled.js +26 -1
- package/es/components/molecules/MatchAnySelect/types.d.ts +3 -1
- package/es/components/organism/Login/components/LoginSelectPortal/LoginSelectPortal.js +2 -1
- package/es/components/organism/Login/styled.js +16 -0
- package/es/tests/MatchesAnySelect.js +16 -17
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
|
31
31
|
import { useDeepCompareEffect, useDeepCompareMemo, useIntersectionObserver, } from '@antscorp/antsomi-ui/es/hooks';
|
|
32
32
|
// Utils
|
|
33
33
|
import { flatTree, recursiveSearchItems } from '@antscorp/antsomi-ui/es/utils';
|
|
34
|
-
import { DataIcon } from '../../icons';
|
|
34
|
+
import { DataIcon, WarningIcon } from '../../icons';
|
|
35
35
|
import clsx from 'clsx';
|
|
36
36
|
const initialState = {
|
|
37
37
|
isOpenPopover: false,
|
|
@@ -123,8 +123,15 @@ export function MatchesAny(props) {
|
|
|
123
123
|
const onRemoveAll = () => {
|
|
124
124
|
setState(prev => (Object.assign(Object.assign({}, prev), { selectedItems: [] })));
|
|
125
125
|
};
|
|
126
|
+
const renderItemError = (item) => {
|
|
127
|
+
if (customItemRenders === null || customItemRenders === void 0 ? void 0 : customItemRenders.error) {
|
|
128
|
+
return customItemRenders === null || customItemRenders === void 0 ? void 0 : customItemRenders.error(item);
|
|
129
|
+
}
|
|
130
|
+
return item.error ? (React.createElement(Tooltip, { title: item.error },
|
|
131
|
+
React.createElement(WarningIcon, { size: 16 }))) : null;
|
|
132
|
+
};
|
|
126
133
|
const renderItemNodeTitle = ({ item, mode = 'unselect', onSelectItem, onRemoveItem, }) => {
|
|
127
|
-
var _a, _b
|
|
134
|
+
var _a, _b;
|
|
128
135
|
const { isExtendValue, title, subTitle } = item; // Destructure properties from item
|
|
129
136
|
return (React.createElement(React.Fragment, null,
|
|
130
137
|
React.createElement("div", { className: clsx('title-content', {
|
|
@@ -140,7 +147,7 @@ export function MatchesAny(props) {
|
|
|
140
147
|
: extraValue.render
|
|
141
148
|
: item[extraValue.key]))))))),
|
|
142
149
|
React.createElement(Flex, { align: "center", gap: 10 },
|
|
143
|
-
mode === 'select' && (
|
|
150
|
+
mode === 'select' && renderItemError(item),
|
|
144
151
|
isExtendValue && (React.createElement(Icon, { type: "icon-ants-empty-flag", size: 20, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary })),
|
|
145
152
|
React.createElement(ActionButton, { className: "select-button", align: "center", justify: "center", onClick: () => {
|
|
146
153
|
// Call onSelectItem function if provided
|
|
@@ -212,11 +219,9 @@ export function MatchesAny(props) {
|
|
|
212
219
|
? flatTree(item.children, 'children').some(item => notExtendValueSelectedItems === null || notExtendValueSelectedItems === void 0 ? void 0 : notExtendValueSelectedItems.some(selectedItem => selectedItem.key === item.key))
|
|
213
220
|
: notExtendValueSelectedItems === null || notExtendValueSelectedItems === void 0 ? void 0 : notExtendValueSelectedItems.some(selectedItem => selectedItem.key === item.key);
|
|
214
221
|
return isSelected;
|
|
215
|
-
})) === null || _a === void 0 ? void 0 : _a.map(item => (Object.assign(Object.assign(Object.assign({}, item), { title: renderItemNodeTitle({ item, mode: 'select', onRemoveItem }) }), (item.children
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
: { className: 'leaf-node' }))))) || [];
|
|
222
|
+
})) === 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 && {
|
|
223
|
+
children: serializeTreeData(item.children),
|
|
224
|
+
})), (!!item.error && { className: 'error-node' }))))) || [];
|
|
220
225
|
};
|
|
221
226
|
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 }) })))) || []);
|
|
222
227
|
}, [items, selectedItems]);
|
|
@@ -6,7 +6,7 @@ import { Tree } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
|
6
6
|
// Constants
|
|
7
7
|
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
8
8
|
import { EXTRA_VALUE_SHIFT_WIDTH, EXTRA_VALUE_WIDTH } from './constants';
|
|
9
|
-
const { borderRadius, bw3, bw6, blue, blue1, colorPrimary } = globalToken || {};
|
|
9
|
+
const { borderRadius, bw3, bw6, blue, blue1, colorPrimary, colorError } = globalToken || {};
|
|
10
10
|
export const MatchesAnyWrapper = styled(Flex) `
|
|
11
11
|
width: 100%;
|
|
12
12
|
height: 550px;
|
|
@@ -67,6 +67,10 @@ export const MatchesAnyWrapper = styled(Flex) `
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
.antsomi-tree {
|
|
70
|
+
.antsomi-tree-list-holder-inner {
|
|
71
|
+
gap: 5px;
|
|
72
|
+
}
|
|
73
|
+
|
|
70
74
|
.antsomi-tree-treenode {
|
|
71
75
|
width: 100%;
|
|
72
76
|
padding: 0px;
|
|
@@ -177,6 +181,27 @@ export const MatchesAnyWrapper = styled(Flex) `
|
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
}
|
|
184
|
+
|
|
185
|
+
&.error-node {
|
|
186
|
+
.antsomi-tree-node-content-wrapper {
|
|
187
|
+
border-color: ${colorError};
|
|
188
|
+
border-width: 1px;
|
|
189
|
+
border-style: solid;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
&:not(:has(span.antsomi-tree-switcher-noop)) {
|
|
193
|
+
.antsomi-tree-node-content-wrapper {
|
|
194
|
+
border-left-width: 0px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.antsomi-tree-switcher {
|
|
198
|
+
border-color: ${colorError};
|
|
199
|
+
border-width: 1px;
|
|
200
|
+
border-right-width: 0;
|
|
201
|
+
border-style: solid;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
180
205
|
}
|
|
181
206
|
}
|
|
182
207
|
|
|
@@ -10,6 +10,8 @@ export type MatchesAnyItem<TItem = Record<string, any>> = TreeDataNode & {
|
|
|
10
10
|
isExtendValue?: boolean;
|
|
11
11
|
/** An array of children items. */
|
|
12
12
|
children?: MatchesAnyItem<TItem>[];
|
|
13
|
+
/** An error message */
|
|
14
|
+
error?: string;
|
|
13
15
|
} & TItem;
|
|
14
16
|
export type GroupSelectProps = PopoverSelectProps & {
|
|
15
17
|
/** Name of the group select to be displayed */
|
|
@@ -23,7 +25,7 @@ export type RenderExtraValue<TItem = Record<string, any>> = {
|
|
|
23
25
|
export type CustomItemRenders<TItem> = {
|
|
24
26
|
title?: (item: MatchesAnyItem<TItem>) => ReactNode;
|
|
25
27
|
subTitle?: (item: MatchesAnyItem<TItem>) => ReactNode;
|
|
26
|
-
|
|
28
|
+
error?: (item: MatchesAnyItem<TItem>) => ReactNode;
|
|
27
29
|
};
|
|
28
30
|
export interface MatchesAnySelectProps<TItem = Record<string, any>> extends SelectProps {
|
|
29
31
|
/** The name of object to be displayed in Popover */
|
|
@@ -178,8 +178,9 @@ export const LoginSelectPortal = props => {
|
|
|
178
178
|
color: '#595959',
|
|
179
179
|
fontSize: 11,
|
|
180
180
|
} }, "No portal matches your keyword"))) : (React.createElement(Scrollbars, { style: {
|
|
181
|
-
height:
|
|
181
|
+
height: `calc(100vh - 410px)`,
|
|
182
182
|
width: '100%',
|
|
183
|
+
minHeight: `145px`,
|
|
183
184
|
} },
|
|
184
185
|
React.createElement(WrapperList, null,
|
|
185
186
|
React.createElement(Row, { gutter: [20, 20] }, filterListNetworks.map((network) => (React.createElement(Col, { span: 12 },
|
|
@@ -75,6 +75,10 @@ export const StyledForm = styled(Form) `
|
|
|
75
75
|
input {
|
|
76
76
|
height: ${(props) => (props.isMobile ? ' 44px' : '36px')};
|
|
77
77
|
font-size: ${(props) => props.isMobile ? ' 16px !important' : '14px !important'};
|
|
78
|
+
|
|
79
|
+
&::placeholder {
|
|
80
|
+
font-size: ${(props) => props.isMobile ? ' 16px !important' : '14px !important'};
|
|
81
|
+
}
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
input:-webkit-autofill,
|
|
@@ -87,11 +91,19 @@ export const StyledForm = styled(Form) `
|
|
|
87
91
|
|
|
88
92
|
.antsomi-input-password-icon {
|
|
89
93
|
font-size: ${(props) => (props.isMobile ? ' 24px' : '14px')};
|
|
94
|
+
|
|
95
|
+
&:hover {
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
}
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
.antsomi-input-affix-wrapper {
|
|
93
101
|
padding: 0 10px !important;
|
|
94
102
|
font-size: ${(props) => props.isMobile ? ' 16px !important' : '14px !important'};
|
|
103
|
+
|
|
104
|
+
&::placeholder {
|
|
105
|
+
font-size: ${(props) => props.isMobile ? ' 16px !important' : '14px !important'};
|
|
106
|
+
}
|
|
95
107
|
}
|
|
96
108
|
|
|
97
109
|
.antsomi-form-item-explain-error {
|
|
@@ -101,6 +113,10 @@ export const StyledForm = styled(Form) `
|
|
|
101
113
|
export const StyleInput = styled(Input) `
|
|
102
114
|
height: ${(props) => props.isMobile ? ' 44px !important' : '36px !important'};
|
|
103
115
|
font-size: ${(props) => props.isMobile ? ' 16px !important' : '14px !important'};
|
|
116
|
+
|
|
117
|
+
&::placeholder {
|
|
118
|
+
font-size: ${(props) => props.isMobile ? ' 16px !important' : '14px !important'};
|
|
119
|
+
}
|
|
104
120
|
`;
|
|
105
121
|
export const StyleButton = styled(Button) `
|
|
106
122
|
height: ${(props) => props.isMobile ? ' 44px !important' : '40px !important'};
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import React, { useMemo, useState } from 'react';
|
|
3
|
-
import { MatchesAnySelect,
|
|
3
|
+
import { MatchesAnySelect, Typography } from '../components';
|
|
4
4
|
import { EXTRA_VALUE_SAMPLE_DATA } from '../components/molecules/MatchAnySelect/constants';
|
|
5
|
-
import { WarningIcon } from '../components/icons';
|
|
6
5
|
import { recursiveSearchItems } from '../utils';
|
|
7
6
|
export const MatchesAnySelectTest = () => {
|
|
7
|
+
const getError = (status) => {
|
|
8
|
+
let error = '';
|
|
9
|
+
switch (status) {
|
|
10
|
+
case 3:
|
|
11
|
+
error = 'This segment is archived';
|
|
12
|
+
break;
|
|
13
|
+
case 4:
|
|
14
|
+
error = 'This segment does not exist';
|
|
15
|
+
break;
|
|
16
|
+
default:
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
return error;
|
|
20
|
+
};
|
|
8
21
|
const [state, setState] = useState({
|
|
9
22
|
selectedItems: [],
|
|
10
23
|
items: EXTRA_VALUE_SAMPLE_DATA.map(item => {
|
|
@@ -16,6 +29,7 @@ export const MatchesAnySelectTest = () => {
|
|
|
16
29
|
rowCount: item.rowCount,
|
|
17
30
|
subTitle: (_a = item.id) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
18
31
|
status: item.status,
|
|
32
|
+
error: getError(item.status),
|
|
19
33
|
});
|
|
20
34
|
}),
|
|
21
35
|
searchValue: '',
|
|
@@ -50,21 +64,6 @@ export const MatchesAnySelectTest = () => {
|
|
|
50
64
|
var _a;
|
|
51
65
|
return (React.createElement(Typography.Link, { href: item.key.toString() }, (_a = item.title) === null || _a === void 0 ? void 0 : _a.toString()));
|
|
52
66
|
},
|
|
53
|
-
status(item) {
|
|
54
|
-
let tooltip = '';
|
|
55
|
-
switch (item.status) {
|
|
56
|
-
case 3:
|
|
57
|
-
tooltip = 'This segment is archived';
|
|
58
|
-
break;
|
|
59
|
-
case 4:
|
|
60
|
-
tooltip = 'This segment does not exist';
|
|
61
|
-
break;
|
|
62
|
-
default:
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
return (!!tooltip && (React.createElement(Tooltip, { title: tooltip },
|
|
66
|
-
React.createElement(WarningIcon, { size: 16 }))));
|
|
67
|
-
},
|
|
68
67
|
},
|
|
69
68
|
/** Support for handle search outside */
|
|
70
69
|
onChangeSearch: searchValue => {
|