@antscorp/antsomi-ui 1.3.6-beta.3 → 1.3.6-beta.5
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/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +1 -0
- package/es/components/molecules/CodeStructure/CodeStructure.d.ts +21 -0
- package/es/components/molecules/CodeStructure/CodeStructure.js +39 -13
- package/es/components/molecules/CodeStructure/constants.js +4 -4
- package/es/components/molecules/CodeStructure/styled.d.ts +3 -0
- package/es/components/molecules/CodeStructure/styled.js +6 -0
- package/es/components/molecules/CodeStructure/type.d.ts +1 -2
- package/es/components/molecules/CodeStructure/type.js +0 -1
- package/es/components/molecules/CodeStructure/utils.js +3 -3
- package/es/components/molecules/EditingListV2/EditingList.d.ts +2 -0
- package/es/components/molecules/EditingListV2/EditingList.js +15 -0
- package/es/components/molecules/EditingListV2/components/Action/Action.d.ts +6 -0
- package/es/components/molecules/EditingListV2/components/Action/Action.js +10 -0
- package/es/components/molecules/EditingListV2/components/Action/index.d.ts +1 -0
- package/es/components/molecules/EditingListV2/components/Action/index.js +1 -0
- package/es/components/molecules/EditingListV2/components/List/List.d.ts +9 -0
- package/es/components/molecules/EditingListV2/components/List/List.js +38 -0
- package/es/components/molecules/EditingListV2/components/List/index.d.ts +1 -0
- package/es/components/molecules/EditingListV2/components/List/index.js +1 -0
- package/es/components/molecules/EditingListV2/components/Loadable.d.ts +14 -0
- package/es/components/molecules/EditingListV2/components/Loadable.js +3 -0
- package/es/components/molecules/EditingListV2/components/Popover/Popover.d.ts +11 -0
- package/es/components/molecules/EditingListV2/components/Popover/Popover.js +17 -0
- package/es/components/molecules/EditingListV2/components/Popover/index.d.ts +1 -0
- package/es/components/molecules/EditingListV2/components/Popover/index.js +1 -0
- package/es/components/molecules/EditingListV2/components/Search/Search.d.ts +4 -0
- package/es/components/molecules/EditingListV2/components/Search/Search.js +8 -0
- package/es/components/molecules/EditingListV2/components/Search/index.d.ts +1 -0
- package/es/components/molecules/EditingListV2/components/Search/index.js +1 -0
- package/es/components/molecules/EditingListV2/components/Title/Title.d.ts +9 -0
- package/es/components/molecules/EditingListV2/components/Title/Title.js +16 -0
- package/es/components/molecules/EditingListV2/components/Title/index.d.ts +1 -0
- package/es/components/molecules/EditingListV2/components/Title/index.js +1 -0
- package/es/components/molecules/EditingListV2/components/index.d.ts +6 -0
- package/es/components/molecules/EditingListV2/components/index.js +6 -0
- package/es/components/molecules/EditingListV2/index.d.ts +2 -0
- package/es/components/molecules/EditingListV2/index.js +1 -0
- package/es/components/molecules/EditingListV2/styled.d.ts +5 -0
- package/es/components/molecules/EditingListV2/styled.js +38 -0
- package/es/components/molecules/EditingListV2/types.d.ts +18 -0
- package/es/components/molecules/EditingListV2/types.js +1 -0
- package/es/components/molecules/EditingListV2/utils.d.ts +27 -0
- package/es/components/molecules/EditingListV2/utils.js +28 -0
- package/es/components/molecules/SearchPopover/components/PopoverSelect/PopoverSelect.js +2 -2
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/components/template/TemplateListing/Loadable.d.ts +1 -0
- package/package.json +1 -1
|
@@ -7,5 +7,26 @@ interface CodeStructureProps {
|
|
|
7
7
|
isError: boolean;
|
|
8
8
|
}) => void;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Component to configure the code structure for a pool rule.
|
|
12
|
+
*
|
|
13
|
+
* The component contains a form with fields for:
|
|
14
|
+
* - Prefix
|
|
15
|
+
* - Infix (character type, number of digits, number of letters, capitalization, character order)
|
|
16
|
+
* - Suffix
|
|
17
|
+
* - Separator
|
|
18
|
+
* - Quantity (number of codes per time)
|
|
19
|
+
* - Refill interval (manual or automatic)
|
|
20
|
+
* - Refill threshold (number of codes remaining)
|
|
21
|
+
* - Refill unit (codes or percent)
|
|
22
|
+
*
|
|
23
|
+
* The form also displays a preview of the generated code sample.
|
|
24
|
+
*
|
|
25
|
+
* The component calls the `onChange` callback with the updated form values and an `isError` flag
|
|
26
|
+
* indicating whether the form is valid or not.
|
|
27
|
+
*
|
|
28
|
+
* @param {CodeStructureProps} props The component props.
|
|
29
|
+
* @returns {React.ReactElement} The rendered component.
|
|
30
|
+
*/
|
|
10
31
|
export declare const CodeStructure: React.FC<CodeStructureProps>;
|
|
11
32
|
export {};
|
|
@@ -4,17 +4,39 @@ import { useEffect } from 'react';
|
|
|
4
4
|
import { Form, InputNumber, Radio, Select, Typography, Flex, Input, Row, Col } from 'antd';
|
|
5
5
|
import { useImmer } from 'use-immer';
|
|
6
6
|
import { translate, translations } from '@antscorp/antsomi-locales';
|
|
7
|
+
import { isEmpty } from 'lodash';
|
|
7
8
|
// Utils
|
|
8
9
|
import { calculateTotalCodes, generateCodeWithPrefixAndSuffix, generateRandomCodeWithConfig, } from './utils';
|
|
9
10
|
// Types
|
|
10
11
|
import { CapitalizationType, CharacterOrderType, CharacterType, RefillType, RefillUnitType, SeparatorType, } from './type';
|
|
11
12
|
// Constants
|
|
12
13
|
import { CAPITALIZATION_OPTIONS, CHARACTER_ORDER_OPTIONS, CHARACTER_TYPE_OPTIONS, REFILL_UNIT_OPTIONS, SEPARATOR_OPTIONS, } from './constants';
|
|
13
|
-
import { CodeStructureWrapper } from './styled';
|
|
14
|
+
import { BlockAbsolute, CodeStructureWrapper } from './styled';
|
|
14
15
|
import { useDebouncedCallbackV2 } from '@antscorp/antsomi-ui/es/hooks';
|
|
15
16
|
const { Title } = Typography;
|
|
17
|
+
/**
|
|
18
|
+
* Component to configure the code structure for a pool rule.
|
|
19
|
+
*
|
|
20
|
+
* The component contains a form with fields for:
|
|
21
|
+
* - Prefix
|
|
22
|
+
* - Infix (character type, number of digits, number of letters, capitalization, character order)
|
|
23
|
+
* - Suffix
|
|
24
|
+
* - Separator
|
|
25
|
+
* - Quantity (number of codes per time)
|
|
26
|
+
* - Refill interval (manual or automatic)
|
|
27
|
+
* - Refill threshold (number of codes remaining)
|
|
28
|
+
* - Refill unit (codes or percent)
|
|
29
|
+
*
|
|
30
|
+
* The form also displays a preview of the generated code sample.
|
|
31
|
+
*
|
|
32
|
+
* The component calls the `onChange` callback with the updated form values and an `isError` flag
|
|
33
|
+
* indicating whether the form is valid or not.
|
|
34
|
+
*
|
|
35
|
+
* @param {CodeStructureProps} props The component props.
|
|
36
|
+
* @returns {React.ReactElement} The rendered component.
|
|
37
|
+
*/
|
|
16
38
|
export const CodeStructure = ({ initialData, onChange }) => {
|
|
17
|
-
const { characterType = CharacterType.DIGIT_AND_LETTERS, digitalNumbers = 2, alphabetLetters = 3, capitalization = CapitalizationType.UPPERCASE, characterOrder = CharacterOrderType.RANDOM, separator = SeparatorType.UNDERSCORE, quantity =
|
|
39
|
+
const { characterType = CharacterType.DIGIT_AND_LETTERS, digitalNumbers = 2, alphabetLetters = 3, capitalization = CapitalizationType.UPPERCASE, characterOrder = CharacterOrderType.RANDOM, separator = SeparatorType.UNDERSCORE, quantity = 50, suffix = '', refillInterval = RefillType.MANUAL, prefix = '', refillThreshold = 10, refillUnit = RefillUnitType.CODES, } = initialData;
|
|
18
40
|
const [form] = Form.useForm();
|
|
19
41
|
const [state, setState] = useImmer({
|
|
20
42
|
codeSample: '',
|
|
@@ -42,7 +64,7 @@ export const CodeStructure = ({ initialData, onChange }) => {
|
|
|
42
64
|
draft.codeWithPrefixAndSuffix = value;
|
|
43
65
|
});
|
|
44
66
|
};
|
|
45
|
-
const debouncedOnChange = useDebouncedCallbackV2(onChange,
|
|
67
|
+
const debouncedOnChange = useDebouncedCallbackV2(onChange, 700);
|
|
46
68
|
const updateFormValues = async (fieldKeyChange, isError) => {
|
|
47
69
|
// Get all values from the form
|
|
48
70
|
const allValues = form.getFieldsValue();
|
|
@@ -110,28 +132,32 @@ export const CodeStructure = ({ initialData, onChange }) => {
|
|
|
110
132
|
updateFormValues(fieldKeyChange, isValidate);
|
|
111
133
|
}, children: [_jsx(Title, { level: 5, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE, 'Code Structure') }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_PREFIX, 'Prefix'), name: "prefix", children: _jsx(Input, { placeholder: "", style: {
|
|
112
134
|
maxWidth: 465,
|
|
113
|
-
} }) }), _jsxs(Row, { children: [_jsx(Col, { span: 6, offset: 0, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_INFIX, 'Infix') }), _jsx(Col, { span: 16, offset: 0, children: _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: _jsx(Col, { offset: 0, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE, 'Character Type') }) }), _jsx(Form.Item, { name: "characterType", children: _jsx(Radio.Group, { options: CHARACTER_TYPE_OPTIONS }) })] }) })] }), _jsx(Row, { children: _jsx(Col, { offset: 6, children: _jsxs(Flex, { gap: 10, align: "center",
|
|
135
|
+
} }) }), _jsxs(Row, { children: [_jsx(Col, { span: 6, offset: 0, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_INFIX, 'Infix') }), _jsx(Col, { span: 16, offset: 0, children: _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: _jsx(Col, { offset: 0, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE, 'Character Type') }) }), _jsx(Form.Item, { name: "characterType", children: _jsx(Radio.Group, { options: CHARACTER_TYPE_OPTIONS }) })] }) })] }), _jsx(Row, { children: _jsx(Col, { offset: 6, children: _jsxs(Flex, { gap: 10, align: "center", style: {
|
|
136
|
+
position: 'relative',
|
|
137
|
+
}, children: [_jsx(Form.Item, { name: "digitalNumbers", rules: [{ required: true, message: `This field can't be empty` }], children: _jsx(InputNumber, { min: 1, max: 50, style: { width: '40px' } }) }), _jsx(BlockAbsolute, { children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE_DIG_NO, 'digital numbers') })] }) }) }), _jsx(Row, { children: _jsx(Col, { offset: 6, children: _jsxs(Flex, { gap: 10, align: "center", style: {
|
|
138
|
+
position: 'relative',
|
|
139
|
+
}, children: [_jsx(Form.Item, { name: "alphabetLetters", rules: [{ required: true, message: `This field can't be empty` }], children: _jsx(InputNumber, { min: 1, max: 50, style: { width: '40px' } }) }), _jsx(BlockAbsolute, { children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_TYPE_LET_NO, 'alphabet letters') })] }) }) }), _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: _jsx(Col, { offset: 6, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP, 'Letters Capitalization') }) }), _jsx(Form.Item, { label: _jsx("span", { children: "\u00A0" }), name: "capitalization", children: _jsx(Radio.Group, { options: CAPITALIZATION_OPTIONS }) })] }), _jsxs(Flex, { vertical: true, gap: 10, children: [_jsx(Row, { children: _jsx(Col, { offset: 6, children: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CHAC_ORDER, 'Character Order') }) }), _jsx(Form.Item, { label: _jsx("span", { children: "\u00A0" }), name: "characterOrder", children: _jsx(Radio.Group, { options: CHARACTER_ORDER_OPTIONS }) })] }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_SUFFIX, 'Suffix'), name: "suffix", children: _jsx(Input, { placeholder: "", style: {
|
|
114
140
|
maxWidth: 465,
|
|
115
|
-
} }) }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_SEPARATOR, 'Separator'), name: "separator", children: _jsx(Select, { options: SEPARATOR_OPTIONS, style: { width: '180px' } }) }), _jsxs(Row, { children: [_jsx(Col, { span: 6, children: _jsxs(Flex, { justify: "start", align: "center", gap: 5, children: [translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_QUANTITY, 'Quantity'), ' ', _jsx("span", { style: { color: 'red' }, children: "*" })] }) }), _jsx(Col, { children: _jsxs(Flex, { gap: 10, align: "center", children: [_jsx(Form.Item, { required: true, name: "quantity", rules: [{ required: true }], children: _jsx(InputNumber, { min: 1, max: 10000 }) }), _jsx(
|
|
141
|
+
} }) }), _jsx(Form.Item, { label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_SEPARATOR, 'Separator'), name: "separator", children: _jsx(Select, { options: SEPARATOR_OPTIONS, style: { width: '180px' } }) }), _jsxs(Row, { children: [_jsx(Col, { span: 6, children: _jsxs(Flex, { justify: "start", align: "center", gap: 5, children: [translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_QUANTITY, 'Quantity'), ' ', _jsx("span", { style: { color: 'red' }, children: "*" })] }) }), _jsx(Col, { children: _jsxs(Flex, { gap: 10, align: "center", style: { position: 'relative' }, children: [_jsx(Form.Item, { required: true, name: "quantity", rules: [{ required: true, message: `This field can't be empty` }], children: _jsx(InputNumber, { min: 1, max: 10000 }) }), _jsx(BlockAbsolute, { left: 100, children: "code(s) per time" })] }) })] }), _jsxs(Form.Item, { label: translate(translations._ACT_PREVIEW, 'Preview'), children: ["Maximum of ", _jsx("b", { children: maxCodes.toLocaleString() }), " codes (sample", ' ', generateCodeWithPrefixAndSuffix(codeSample, form.getFieldValue('prefix'), form.getFieldValue('suffix'), form.getFieldValue('separator')), ") to be generated"] }), _jsx(Title, { level: 5, children: "Code Refill" }), _jsx(Form.Item, { label: "Refill Interval", name: "refillInterval", children: _jsxs(Radio.Group, { style: { display: 'flex', flexDirection: 'column', gap: '10px' }, onChange: e => {
|
|
142
|
+
if (e.target.value === 'manual' && isEmpty(form.getFieldValue('refillThreshold'))) {
|
|
143
|
+
form.setFieldsValue({ refillThreshold: 10 });
|
|
144
|
+
form.validateFields(['refillThreshold']);
|
|
145
|
+
}
|
|
146
|
+
}, children: [_jsx(Radio, { value: "manual", children: "Manual refill only" }), _jsx(Radio, { value: "auto", children: _jsxs(Flex, { gap: 10, align: "center", children: [_jsx(Typography.Text, { style: { whiteSpace: 'nowrap' }, children: "Add codes when less than" }), _jsx(Form.Item, { noStyle: true, shouldUpdate: true, children: ({ getFieldValue }) => {
|
|
116
147
|
const refillUnit = getFieldValue('refillUnit');
|
|
117
148
|
return (_jsx(Form.Item, { name: "refillThreshold", noStyle: true, rules: [
|
|
118
149
|
{ required: true, message: '' },
|
|
119
150
|
{
|
|
120
151
|
validator: (_, value) => {
|
|
121
152
|
if (refillUnit === RefillUnitType.PERCENT) {
|
|
122
|
-
if (value
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
else if (refillUnit === RefillUnitType.CODES) {
|
|
127
|
-
if (value < 0) {
|
|
128
|
-
return Promise.reject(new Error(''));
|
|
153
|
+
if (value > 100) {
|
|
154
|
+
form.setFieldsValue({ refillThreshold: 100 });
|
|
129
155
|
}
|
|
130
156
|
}
|
|
131
157
|
return Promise.resolve();
|
|
132
158
|
},
|
|
133
159
|
},
|
|
134
|
-
], children: _jsx(InputNumber, { min:
|
|
160
|
+
], children: _jsx(InputNumber, { min: 1, max: refillUnit === RefillUnitType.PERCENT ? 100 : undefined, style: { width: '63px' } }) }));
|
|
135
161
|
} }), _jsx(Form.Item, { noStyle: true, shouldUpdate: true, children: () => (_jsx(Form.Item, { name: "refillUnit", noStyle: true, rules: [
|
|
136
162
|
{ required: true, message: '' },
|
|
137
163
|
{
|
|
@@ -29,10 +29,10 @@ export const CAPITALIZATION_OPTIONS = [
|
|
|
29
29
|
value: CapitalizationType.LOWERCASE,
|
|
30
30
|
label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP_LOW, 'lowercase'),
|
|
31
31
|
},
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
32
|
+
// {
|
|
33
|
+
// value: CapitalizationType.TITLE_CASE,
|
|
34
|
+
// label: translate(translations._POOL_RULE_SETTING_CODE_STRUCTURE_CAP_TITL, 'Title case'),
|
|
35
|
+
// },
|
|
36
36
|
];
|
|
37
37
|
export const CHARACTER_ORDER_OPTIONS = [
|
|
38
38
|
{
|
|
@@ -14,7 +14,6 @@ export var CapitalizationType;
|
|
|
14
14
|
(function (CapitalizationType) {
|
|
15
15
|
CapitalizationType["UPPERCASE"] = "upper";
|
|
16
16
|
CapitalizationType["LOWERCASE"] = "lower";
|
|
17
|
-
CapitalizationType["TITLE_CASE"] = "title";
|
|
18
17
|
})(CapitalizationType || (CapitalizationType = {}));
|
|
19
18
|
export var SeparatorType;
|
|
20
19
|
(function (SeparatorType) {
|
|
@@ -18,9 +18,9 @@ export const generateRandomCodeWithConfig = ({ characterType, digitalNumbers, al
|
|
|
18
18
|
else if (capitalization === CapitalizationType.LOWERCASE) {
|
|
19
19
|
letterPart = letterPart.toLowerCase();
|
|
20
20
|
}
|
|
21
|
-
else if (capitalization === CapitalizationType.TITLE_CASE && letterPart.length > 0) {
|
|
22
|
-
|
|
23
|
-
}
|
|
21
|
+
// } else if (capitalization === CapitalizationType.TITLE_CASE && letterPart.length > 0) {
|
|
22
|
+
// letterPart = letterPart.charAt(0).toUpperCase() + letterPart.slice(1).toLowerCase();
|
|
23
|
+
// }
|
|
24
24
|
// Order characters
|
|
25
25
|
let finalCode = '';
|
|
26
26
|
if (characterOrder === CharacterOrderType.RANDOM) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Suspense } from '../../atoms';
|
|
4
|
+
import { ListItem, LazyComponent } from './components';
|
|
5
|
+
const { Popover } = LazyComponent;
|
|
6
|
+
export const EditingListV2 = (props) => {
|
|
7
|
+
const { isLoading = false, addButtonLabel = 'Add', options = [], selected = [], removable = true, popupPlacement = 'right', className, onChange, } = props;
|
|
8
|
+
const selectedOptions = useMemo(() => options.filter(opt => selected.includes(opt.key)), [selected, options]);
|
|
9
|
+
// const isSelectAll = selectedOptions.length === options.length;
|
|
10
|
+
const handleRemove = (removedKey) => {
|
|
11
|
+
const selectedKeys = selectedOptions.filter(opt => opt.key !== removedKey).map(opt => opt.key);
|
|
12
|
+
onChange?.(selectedKeys);
|
|
13
|
+
};
|
|
14
|
+
return (_jsxs("div", { className: className, children: [_jsx(ListItem, { isLoading: isLoading, selectOptions: selectedOptions, removable: removable, onClickRemove: handleRemove }), !isLoading && (_jsx(Suspense, { children: _jsx(Popover, { placement: popupPlacement, options: options, selected: selected, addButtonLabel: addButtonLabel, onChange: onChange }) }))] }));
|
|
15
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CloseIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
3
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
4
|
+
import { CLS } from '../../utils';
|
|
5
|
+
export const Action = (props) => {
|
|
6
|
+
const { removable, onClickRemove } = props;
|
|
7
|
+
if (!removable)
|
|
8
|
+
return null;
|
|
9
|
+
return (_jsx(CloseIcon, { className: CLS.RemoveButton.default, size: 20, color: globalToken?.bw8, onClick: onClickRemove }));
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Action } from './Action';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Action } from './Action';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Option } from '../../types';
|
|
2
|
+
type ListProps = {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
selectOptions: Option[];
|
|
5
|
+
removable?: boolean;
|
|
6
|
+
onClickRemove?: (key: string) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const ListItem: (props: ListProps) => import("react/jsx-runtime").JSX.Element | undefined;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Spin, Typography } from '../../../../atoms';
|
|
3
|
+
import { isEmpty } from 'lodash';
|
|
4
|
+
import { CLS } from '../../utils';
|
|
5
|
+
import { List } from 'antd';
|
|
6
|
+
import { CloseIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
7
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
export const ListItem = (props) => {
|
|
10
|
+
const { isLoading, selectOptions, onClickRemove, removable } = props;
|
|
11
|
+
const [hover, setHover] = useState('');
|
|
12
|
+
const renderLabel = (label) => {
|
|
13
|
+
if (typeof label === 'string') {
|
|
14
|
+
return _jsx(Typography.Text, { ellipsis: { tooltip: true }, children: label });
|
|
15
|
+
}
|
|
16
|
+
return label;
|
|
17
|
+
};
|
|
18
|
+
const items = selectOptions.map(opt => ({
|
|
19
|
+
className: CLS.ListItem.default,
|
|
20
|
+
key: opt.key,
|
|
21
|
+
label: renderLabel(opt.label),
|
|
22
|
+
}));
|
|
23
|
+
if (isLoading) {
|
|
24
|
+
return _jsx(Spin, { indicatorSize: 24 });
|
|
25
|
+
}
|
|
26
|
+
if (isEmpty(selectOptions)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return (_jsx(List, { dataSource: items, renderItem: item => (_jsxs(List.Item, { style: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
border: '1px solid #B8CFE6',
|
|
33
|
+
borderRadius: '4px',
|
|
34
|
+
padding: '10px',
|
|
35
|
+
marginBottom: '10px',
|
|
36
|
+
minHeight: '40px',
|
|
37
|
+
}, onMouseEnter: () => setHover(item.key), onMouseLeave: () => setHover(''), children: [item.label, ' ', hover === item.key && removable && (_jsx(CloseIcon, { size: 18, color: globalToken?.bw8, style: { flexShrink: 0 }, onClick: onClickRemove ? () => onClickRemove(item.key) : undefined }))] })) }));
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListItem } from './List';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ListItem } from './List';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Title: import("react").LazyExoticComponent<(props: {
|
|
3
|
+
title: import("react").ReactNode;
|
|
4
|
+
showNum: boolean;
|
|
5
|
+
selectedAmount?: number | undefined;
|
|
6
|
+
optionAmount?: number | undefined;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
8
|
+
export declare const Popover: import("react").LazyExoticComponent<(props: {
|
|
9
|
+
placement?: "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "left" | "right" | "bottom" | "top" | "bottomLeft" | "topLeft" | "topRight" | "bottomRight" | undefined;
|
|
10
|
+
options: import("../types").Option[];
|
|
11
|
+
selected: string[];
|
|
12
|
+
addButtonLabel: import("react").ReactNode;
|
|
13
|
+
onChange?: ((selected: string[]) => void) | undefined;
|
|
14
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Option } from '../../types';
|
|
3
|
+
type PopoverProps = {
|
|
4
|
+
placement?: 'left' | 'right' | 'top' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
5
|
+
options: Option[];
|
|
6
|
+
selected: string[];
|
|
7
|
+
addButtonLabel: React.ReactNode;
|
|
8
|
+
onChange?: (selected: string[]) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const Popover: (props: PopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
3
|
+
import { AddIcon } from '../../../../icons';
|
|
4
|
+
import { PopoverAddField } from '../../../SearchPopover';
|
|
5
|
+
export const Popover = (props) => {
|
|
6
|
+
const { options, selected, addButtonLabel, onChange, placement } = props;
|
|
7
|
+
return (_jsx(_Fragment, { children: _jsx(PopoverAddField, { style: { margin: 0 }, fields: options, placement: placement, selected: selected,
|
|
8
|
+
// onApply={value =>
|
|
9
|
+
// updateUnsubscribeSetting([
|
|
10
|
+
// {
|
|
11
|
+
// fieldPath: 'settings.unsubscribePreferences.preferenceListIds',
|
|
12
|
+
// data: value as unknown as string,
|
|
13
|
+
// },
|
|
14
|
+
// ])
|
|
15
|
+
// }
|
|
16
|
+
onApply: onChange, children: _jsxs(Button, { type: "text", children: [_jsx(AddIcon, { size: 14 }), addButtonLabel] }) }) }));
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Popover } from './Popover';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Popover } from './Popover';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { InputSearch } from '../../../InputSearch';
|
|
4
|
+
import { CLS } from '../../utils';
|
|
5
|
+
export const Search = (props) => {
|
|
6
|
+
const { className, placeholder, onChange } = props;
|
|
7
|
+
return (_jsx(InputSearch, { className: clsx(CLS.Search, className), placeholder: placeholder || 'Search...', onChange: onChange }));
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Search } from './Search';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Search } from './Search';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, Typography } from 'antd';
|
|
3
|
+
import { AmountSelected } from '../../styled';
|
|
4
|
+
import { CLS } from '../../utils';
|
|
5
|
+
export const Title = (props) => {
|
|
6
|
+
const { title, showNum } = props;
|
|
7
|
+
const renderSelectedAmount = () => {
|
|
8
|
+
if (!showNum)
|
|
9
|
+
return null;
|
|
10
|
+
const { optionAmount, selectedAmount } = props;
|
|
11
|
+
if (!optionAmount || !selectedAmount)
|
|
12
|
+
return null;
|
|
13
|
+
return (_jsxs(AmountSelected, { children: ["(", selectedAmount, "/", optionAmount, ")"] }));
|
|
14
|
+
};
|
|
15
|
+
return (_jsxs(Flex, { className: CLS.Title.default, align: "center", gap: 8, children: [_jsx(Typography.Text, { strong: true, children: title }), renderSelectedAmount()] }));
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Title } from './Title';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Title } from './Title';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EditingListV2 } from './EditingList';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const EditingListRoot: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
3
|
+
export declare const StyledListWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const StyledAddBtn: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
5
|
+
export declare const AmountSelected: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/typography/Text").TextProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
2
|
+
import { Flex, Typography } from 'antd';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { CLS } from './utils';
|
|
5
|
+
export const EditingListRoot = styled(Flex) `
|
|
6
|
+
/* height: 100%; */
|
|
7
|
+
`;
|
|
8
|
+
export const StyledListWrapper = styled.div `
|
|
9
|
+
/* flex: auto; */
|
|
10
|
+
/* height: auto; */
|
|
11
|
+
|
|
12
|
+
.${CLS.ListItem.default} {
|
|
13
|
+
.${CLS.RemoveButton.default} {
|
|
14
|
+
flex-shrink: 0;
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
.${CLS.RemoveButton.default} {
|
|
20
|
+
display: block;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
export const StyledAddBtn = styled(Flex) `
|
|
26
|
+
color: ${globalToken?.colorPrimary};
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
font-weight: bold;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
gap: 4px;
|
|
32
|
+
width: fit-content;
|
|
33
|
+
`;
|
|
34
|
+
export const AmountSelected = styled(Typography.Text) `
|
|
35
|
+
&.antsomi-typography {
|
|
36
|
+
font-size: 11px;
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type Option = {
|
|
3
|
+
key: string;
|
|
4
|
+
label: React.ReactNode;
|
|
5
|
+
search?: string;
|
|
6
|
+
};
|
|
7
|
+
export type EditingListProps = {
|
|
8
|
+
popupPlacement?: 'left' | 'right' | 'top' | 'bottom' | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
9
|
+
addButtonLabel?: string;
|
|
10
|
+
options?: Option[];
|
|
11
|
+
selected?: string[];
|
|
12
|
+
showNum?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
isLoading?: boolean;
|
|
15
|
+
emptyDescription?: string;
|
|
16
|
+
removable?: boolean;
|
|
17
|
+
onChange?: (selected: string[]) => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const componentCls: (className: string) => string;
|
|
2
|
+
export declare const CLS: {
|
|
3
|
+
readonly Root: {
|
|
4
|
+
readonly default: string;
|
|
5
|
+
};
|
|
6
|
+
readonly Title: {
|
|
7
|
+
readonly default: string;
|
|
8
|
+
};
|
|
9
|
+
readonly Search: {
|
|
10
|
+
readonly default: string;
|
|
11
|
+
};
|
|
12
|
+
readonly RemoveButton: {
|
|
13
|
+
readonly default: string;
|
|
14
|
+
};
|
|
15
|
+
readonly AddButton: {
|
|
16
|
+
readonly default: string;
|
|
17
|
+
};
|
|
18
|
+
readonly ListWapper: {
|
|
19
|
+
readonly default: string;
|
|
20
|
+
};
|
|
21
|
+
readonly List: {
|
|
22
|
+
readonly default: string;
|
|
23
|
+
};
|
|
24
|
+
readonly ListItem: {
|
|
25
|
+
readonly default: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { antsomiClsx } from '@antscorp/antsomi-ui/es/utils';
|
|
2
|
+
export const componentCls = antsomiClsx('editing-list');
|
|
3
|
+
export const CLS = {
|
|
4
|
+
Root: {
|
|
5
|
+
default: componentCls('root'),
|
|
6
|
+
},
|
|
7
|
+
Title: {
|
|
8
|
+
default: componentCls('title'),
|
|
9
|
+
},
|
|
10
|
+
Search: {
|
|
11
|
+
default: componentCls('search'),
|
|
12
|
+
},
|
|
13
|
+
RemoveButton: {
|
|
14
|
+
default: componentCls('remove-btn'),
|
|
15
|
+
},
|
|
16
|
+
AddButton: {
|
|
17
|
+
default: componentCls('add-btn'),
|
|
18
|
+
},
|
|
19
|
+
ListWapper: {
|
|
20
|
+
default: componentCls('selected-list-wrapper'),
|
|
21
|
+
},
|
|
22
|
+
List: {
|
|
23
|
+
default: componentCls('selected-list'),
|
|
24
|
+
},
|
|
25
|
+
ListItem: {
|
|
26
|
+
default: componentCls('selected-list-item'),
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -113,11 +113,11 @@ export const PopoverSelect = (props) => {
|
|
|
113
113
|
key: opt.key,
|
|
114
114
|
label: (_jsx(Checkbox, { onChange: e => handleToggleField(opt, e.target.checked), checked: selectedKeys.has(opt.key), children: renderCheckBoxLabel(opt) })),
|
|
115
115
|
}));
|
|
116
|
-
return (_jsx(SearchPopover, { destroyTooltipOnHide: true, ...rest, content: _jsxs(_Fragment, { children: [optionsProp.length > 0 && (_jsxs(StyledAction, { children: [_jsx(Button, { type: "link", size: "small", onClick: () => setShowSelected(current => !current), children: showSelected ? showAllLabel : showSelectedLabel }), selectedKeys.size === options.length ? (_jsx(Button, { type: "link", onClick: handleDeselectAll, children: deselectAllLabel })) : (_jsx(Button, { type: "link", onClick: handleSelectAll, children: selectAllLabel }))] })), filteredOptions.length ? (_jsx(StyledListFieldsWrapper, { "$minHeight": calDefaultListHeightInPopover({
|
|
116
|
+
return (_jsx(SearchPopover, { destroyTooltipOnHide: true, placement: "bottomLeft", ...rest, content: _jsxs(_Fragment, { children: [optionsProp.length > 0 && (_jsxs(StyledAction, { children: [_jsx(Button, { type: "link", size: "small", onClick: () => setShowSelected(current => !current), children: showSelected ? showAllLabel : showSelectedLabel }), selectedKeys.size === options.length ? (_jsx(Button, { type: "link", onClick: handleDeselectAll, children: deselectAllLabel })) : (_jsx(Button, { type: "link", onClick: handleSelectAll, children: selectAllLabel }))] })), filteredOptions.length ? (_jsx(StyledListFieldsWrapper, { "$minHeight": calDefaultListHeightInPopover({
|
|
117
117
|
listLength: filteredOptions.length,
|
|
118
118
|
itemSize,
|
|
119
119
|
itemSpacing,
|
|
120
|
-
}), children: _jsx(VirtualizedMenu, { ...menuProps, itemSize: itemSize, items: items }) })) : (_jsx(EmptyData, { showIcon: false, description: t(translations.noData).toString() })), _jsxs(StyledFooter, { children: [_jsx(Button, { onClick: handleCancel, children: "Cancel" }), _jsx(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary", children: "Apply" })] })] }), trigger: ['click'],
|
|
120
|
+
}), children: _jsx(VirtualizedMenu, { ...menuProps, itemSize: itemSize, items: items }) })) : (_jsx(EmptyData, { showIcon: false, description: t(translations.noData).toString() })), _jsxs(StyledFooter, { children: [_jsx(Button, { onClick: handleCancel, children: "Cancel" }), _jsx(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary", children: "Apply" })] })] }), trigger: ['click'], open: open, inputSearchProps: {
|
|
121
121
|
...restInputSearchProps,
|
|
122
122
|
value: search,
|
|
123
123
|
onAfterChange: handleOnSearch,
|
|
@@ -6,6 +6,7 @@ export { Select } from './Select';
|
|
|
6
6
|
export { SelectV2 } from './SelectV2';
|
|
7
7
|
export { DatePicker } from './DatePicker';
|
|
8
8
|
export { ChatBox, ChatBoxInsight } from './ChatBox';
|
|
9
|
+
export { EditingListV2 } from './EditingListV2';
|
|
9
10
|
export { PopupDraggable } from './PopupDraggable';
|
|
10
11
|
export { CaptureScreen } from './CaptureScreen';
|
|
11
12
|
export { SettingWrapper } from './SettingWrapper';
|
|
@@ -6,6 +6,7 @@ export { Select } from './Select';
|
|
|
6
6
|
export { SelectV2 } from './SelectV2';
|
|
7
7
|
export { DatePicker } from './DatePicker';
|
|
8
8
|
export { ChatBox, ChatBoxInsight } from './ChatBox';
|
|
9
|
+
export { EditingListV2 } from './EditingListV2';
|
|
9
10
|
export { PopupDraggable } from './PopupDraggable';
|
|
10
11
|
export { CaptureScreen } from './CaptureScreen';
|
|
11
12
|
export { SettingWrapper } from './SettingWrapper';
|