@antscorp/antsomi-ui 2.0.114 → 2.0.116
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/atoms/SelectAssociatedTag/SelectAssociatedTag.d.ts +5 -0
- package/es/components/atoms/SelectAssociatedTag/SelectAssociatedTag.js +15 -0
- package/es/components/atoms/SelectAssociatedTag/SelectTag.d.ts +4 -0
- package/es/components/atoms/SelectAssociatedTag/SelectTag.js +26 -0
- package/es/components/atoms/SelectAssociatedTag/constants.d.ts +11 -0
- package/es/components/atoms/SelectAssociatedTag/constants.js +42 -0
- package/es/components/atoms/SelectAssociatedTag/index.d.ts +3 -0
- package/es/components/atoms/SelectAssociatedTag/index.js +2 -0
- package/es/components/atoms/SelectAssociatedTag/styled.d.ts +7 -0
- package/es/components/atoms/SelectAssociatedTag/styled.js +60 -0
- package/es/components/atoms/SelectAssociatedTag/types.d.ts +76 -0
- package/es/components/atoms/SelectAssociatedTag/types.js +1 -0
- package/es/components/atoms/index.d.ts +1 -0
- package/es/components/atoms/index.js +1 -0
- package/es/components/icons/CircleInfoIcon.js +2 -2
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +2 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +2 -0
- package/es/components/molecules/AddDynamicContent/styled.d.ts +12 -1
- package/es/components/molecules/DisplayFormat/styled.d.ts +12 -1
- package/es/components/molecules/InputSelectAttribute/index.d.ts +25 -0
- package/es/components/molecules/InputSelectAttribute/index.js +124 -0
- package/es/components/molecules/InputSelectAttribute/styled.d.ts +14 -0
- package/es/components/molecules/InputSelectAttribute/styled.js +33 -0
- package/es/components/molecules/Modal/Modal.d.ts +11 -11
- package/es/components/molecules/Modal/Modal.js +11 -9
- package/es/components/molecules/Select/Select.js +1 -1
- package/es/components/molecules/SelectV2/styled.d.ts +3 -1
- package/es/components/molecules/SelectV2/styled.js +2 -2
- package/es/components/molecules/TagifyInput/TagifyInput.js +159 -71
- package/es/components/molecules/TagifyInput/constants.d.ts +24 -2
- package/es/components/molecules/TagifyInput/constants.js +25 -2
- package/es/components/molecules/TagifyInput/patternHandlers.d.ts +12 -6
- package/es/components/molecules/TagifyInput/patternHandlers.js +88 -43
- package/es/components/molecules/TagifyInput/types.d.ts +24 -3
- package/es/components/molecules/TagifyInput/utils.d.ts +10 -1
- package/es/components/molecules/TagifyInput/utils.js +82 -4
- package/es/components/molecules/TagifyInput/utils.style.js +81 -96
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/components/organism/AccountSharing/AccountSharing.js +18 -10
- package/es/components/organism/ActivityTimeline/utils.js +168 -2
- package/es/components/organism/LeftMenu/components/HomeMenu/styled.d.ts +12 -1
- package/es/components/organism/LeftMenu/hooks/usePermission.js +1 -1
- package/es/components/organism/LeftMenu/utils/index.js +1 -1
- package/es/components/organism/PreviewTemplateModal/styled.d.ts +12 -1
- package/es/components/organism/SQLGeneration/components/styled.d.ts +12 -1
- package/es/utils/cookie.js +9 -0
- package/package.json +6 -6
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Components
|
|
3
|
+
import { StyledSpace } from './styled';
|
|
4
|
+
import { Divider } from 'antd';
|
|
5
|
+
import { Select } from '../../molecules';
|
|
6
|
+
import SelectTag from './SelectTag';
|
|
7
|
+
// Constants
|
|
8
|
+
import { defaultProps } from './constants';
|
|
9
|
+
export const SelectAssociatedTag = (props) => {
|
|
10
|
+
// Props
|
|
11
|
+
const { tagConfigs, style, status, selected, disabled, options, children, onSelect } = props;
|
|
12
|
+
const { tag, value } = selected || {};
|
|
13
|
+
return (_jsxs(StyledSpace, { className: `select-associated-tag ${status}`, style: style, children: [_jsx(SelectTag, { ...tagConfigs, selectedTag: tag }), _jsx(Divider, { type: "vertical", style: { margin: '0px 1px 0px 6px' }, className: "antsomi-divider-between-select" }), children ?? (_jsx(Select, { style: { width: '100%', height: '100%' }, value: value, disabled: disabled, options: options, onChange: onSelect }))] }));
|
|
14
|
+
};
|
|
15
|
+
SelectAssociatedTag.defaultProps = defaultProps;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Libraries
|
|
3
|
+
import { memo, useMemo, useState } from 'react';
|
|
4
|
+
import { keyBy } from 'lodash';
|
|
5
|
+
// Components
|
|
6
|
+
import { Flex, Typography } from 'antd';
|
|
7
|
+
import { Popover } from '../Popover';
|
|
8
|
+
import { SelectedTag } from './styled';
|
|
9
|
+
const SelectTag = (props) => {
|
|
10
|
+
// Props
|
|
11
|
+
const { selectedTag, disabled, title, options, onSelect } = props;
|
|
12
|
+
// State
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
// Memoized
|
|
15
|
+
const mapOptsMemo = useMemo(() => keyBy(options, 'value'), [options]);
|
|
16
|
+
const selectedItem = useMemo(() => mapOptsMemo?.[selectedTag] || {}, [selectedTag, mapOptsMemo]);
|
|
17
|
+
const handleOpenChange = () => {
|
|
18
|
+
setOpen(!open);
|
|
19
|
+
};
|
|
20
|
+
const handleClick = (item) => {
|
|
21
|
+
setOpen(false);
|
|
22
|
+
onSelect(item);
|
|
23
|
+
};
|
|
24
|
+
return (_jsx(Popover, { open: open && !disabled, title: _jsx(Typography.Text, { style: { fontWeight: '400', maxWidth: 130 }, ellipsis: { tooltip: title }, children: title }), content: _jsx(Flex, { wrap: "wrap", gap: 6, style: { padding: '10px 0px' }, children: options?.map(item => (_jsx(SelectedTag, { "$color": item.color, "$background": item.background, ellipsis: { tooltip: item.label }, onClick: () => handleClick(item), children: item.label }, item.value))) }), placement: "bottomLeft", trigger: "click", overlayInnerStyle: { padding: 10, maxWidth: 150 }, onOpenChange: handleOpenChange, children: _jsx(SelectedTag, { "$color": selectedItem?.color, "$background": selectedItem?.background, ellipsis: { tooltip: selectedItem?.label }, children: selectedItem?.label }) }));
|
|
25
|
+
};
|
|
26
|
+
export default memo(SelectTag);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SelectAssociatedTagProps, TagItem } from './types';
|
|
2
|
+
export declare const DEFAULT_TAGS: {
|
|
3
|
+
readonly RAW: "RAW";
|
|
4
|
+
readonly md5: "md5";
|
|
5
|
+
readonly sha_256: "sha_256";
|
|
6
|
+
readonly MD5: "MD5";
|
|
7
|
+
readonly SHA_256: "SHA_256";
|
|
8
|
+
};
|
|
9
|
+
export declare const DEFAULT_TAGS_OPTS: Record<string, TagItem>;
|
|
10
|
+
export declare const DEFAULT_TAGS_LIST: TagItem[];
|
|
11
|
+
export declare const defaultProps: SelectAssociatedTagProps;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Constants
|
|
2
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
3
|
+
// Locales
|
|
4
|
+
import { translations, translate } from '@antscorp/antsomi-locales';
|
|
5
|
+
export const DEFAULT_TAGS = {
|
|
6
|
+
RAW: 'RAW',
|
|
7
|
+
md5: 'md5',
|
|
8
|
+
sha_256: 'sha_256',
|
|
9
|
+
MD5: 'MD5',
|
|
10
|
+
SHA_256: 'SHA_256',
|
|
11
|
+
};
|
|
12
|
+
export const DEFAULT_TAGS_OPTS = {
|
|
13
|
+
RAW: { label: 'RAW', value: DEFAULT_TAGS.RAW, color: globalToken?.bw0, background: '#4CB4C9' },
|
|
14
|
+
md5: { label: 'md5', value: DEFAULT_TAGS.md5, color: globalToken?.bw0, background: '#3B8FDE' },
|
|
15
|
+
sha_256: {
|
|
16
|
+
label: 'sha-256',
|
|
17
|
+
value: DEFAULT_TAGS.sha_256,
|
|
18
|
+
color: globalToken?.bw0,
|
|
19
|
+
background: '#12B800',
|
|
20
|
+
},
|
|
21
|
+
MD5: { label: 'MD5', value: DEFAULT_TAGS.MD5, color: globalToken?.bw0, background: '#3B8FDE' },
|
|
22
|
+
SHA_265: {
|
|
23
|
+
label: 'SHA-256',
|
|
24
|
+
value: DEFAULT_TAGS.SHA_256,
|
|
25
|
+
color: globalToken?.bw0,
|
|
26
|
+
background: '#12B800',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export const DEFAULT_TAGS_LIST = Object.values(DEFAULT_TAGS_OPTS);
|
|
30
|
+
export const defaultProps = {
|
|
31
|
+
tagConfigs: {
|
|
32
|
+
options: DEFAULT_TAGS_LIST,
|
|
33
|
+
title: translate(translations._INFO_STORY_WAIT_FOR_HASH, 'Hash Method'),
|
|
34
|
+
onSelect: () => { },
|
|
35
|
+
},
|
|
36
|
+
selected: {
|
|
37
|
+
tag: DEFAULT_TAGS.RAW,
|
|
38
|
+
value: DEFAULT_TAGS.SHA_256,
|
|
39
|
+
},
|
|
40
|
+
options: DEFAULT_TAGS_LIST,
|
|
41
|
+
onSelect: () => { },
|
|
42
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { TagItem } from './types';
|
|
3
|
+
export declare const StyledSpace: import("styled-components").StyledComponent<import("react").FC<import("antd/es/space/Compact").SpaceCompactProps>, any, {}, never>;
|
|
4
|
+
export declare const SelectedTag: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd/es/typography/Text").TextProps & import("react").RefAttributes<HTMLSpanElement>>, any, {
|
|
5
|
+
$background: TagItem['background'];
|
|
6
|
+
$color: TagItem['color'];
|
|
7
|
+
}, never>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
// Components
|
|
4
|
+
import { Space } from '../Space';
|
|
5
|
+
import { Typography } from 'antd';
|
|
6
|
+
// Constants
|
|
7
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
8
|
+
export const StyledSpace = styled(Space.Compact) `
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 30px;
|
|
11
|
+
padding-left: 5px;
|
|
12
|
+
align-items: center;
|
|
13
|
+
|
|
14
|
+
border-bottom: 1px solid ${globalToken?.blue1};
|
|
15
|
+
|
|
16
|
+
&.select-associated-tag {
|
|
17
|
+
&.warning {
|
|
18
|
+
border-bottom-color: ${globalToken?.colorWarning};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.error {
|
|
22
|
+
border-bottom-color: ${globalToken?.colorError};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.success {
|
|
26
|
+
border-bottom-color: ${globalToken?.colorSuccess};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
> div:last-child {
|
|
31
|
+
width: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.antsomi-divider.antsomi-divider-vertical {
|
|
35
|
+
height: 20px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.antsomi-select-selector {
|
|
39
|
+
border: none !important;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
export const SelectedTag = styled(Typography.Text) `
|
|
43
|
+
border-radius: 3px;
|
|
44
|
+
height: 16px;
|
|
45
|
+
line-height: 16px;
|
|
46
|
+
padding-left: 3px;
|
|
47
|
+
padding-right: 3px;
|
|
48
|
+
flex-shrink: 0;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
|
|
51
|
+
background: ${props => props.$background};
|
|
52
|
+
|
|
53
|
+
&.antsomi-typography {
|
|
54
|
+
color: ${props => props.$color};
|
|
55
|
+
|
|
56
|
+
&.antsomi-typography-ellipsis {
|
|
57
|
+
max-width: 70px;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Dictionary } from 'lodash';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
export type TagItem = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
background: CSSProperties['background'];
|
|
7
|
+
color: CSSProperties['color'];
|
|
8
|
+
};
|
|
9
|
+
export type Status = 'error' | 'warning' | 'success';
|
|
10
|
+
export interface TagConfigProps {
|
|
11
|
+
selectedTag: TagItem['value'];
|
|
12
|
+
title?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
options: TagItem[];
|
|
15
|
+
onSelect: (newItem: TagItem) => void;
|
|
16
|
+
}
|
|
17
|
+
export type SelectOption = {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Properties for the SelectAssociatedTag component.
|
|
23
|
+
*/
|
|
24
|
+
export interface SelectAssociatedTagProps {
|
|
25
|
+
/**
|
|
26
|
+
* Configuration properties for tag options, excluding the selected tag.
|
|
27
|
+
* @type {Omit<TagConfigProps, 'selectedTag'>}
|
|
28
|
+
*/
|
|
29
|
+
tagConfigs: Omit<TagConfigProps, 'selectedTag'>;
|
|
30
|
+
/**
|
|
31
|
+
* The currently selected tag and its associated value.
|
|
32
|
+
* @type {{ tag: string; value: string; }}
|
|
33
|
+
*/
|
|
34
|
+
selected: {
|
|
35
|
+
/**
|
|
36
|
+
* The identifier for the selected tag.
|
|
37
|
+
* @type {string}
|
|
38
|
+
*/
|
|
39
|
+
tag: string;
|
|
40
|
+
/**
|
|
41
|
+
* The value associated with the selected tag.
|
|
42
|
+
* @type {Dictionary<SelectOption>}
|
|
43
|
+
*/
|
|
44
|
+
value: Dictionary<SelectOption>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Whether the SelectAssociatedTag is disabled.
|
|
48
|
+
* @type {boolean}
|
|
49
|
+
*/
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The status of the SelectAssociatedTag, if any.
|
|
53
|
+
* @type {'error' | 'warning' | 'success' }
|
|
54
|
+
*/
|
|
55
|
+
status?: Status;
|
|
56
|
+
/**
|
|
57
|
+
* A list of selectable options.
|
|
58
|
+
* @type {SelectOption[]}
|
|
59
|
+
*/
|
|
60
|
+
options: SelectOption[];
|
|
61
|
+
/**
|
|
62
|
+
* The style object for the SelectAssociatedTag component.
|
|
63
|
+
* @type {CSSProperties}
|
|
64
|
+
*/
|
|
65
|
+
style?: CSSProperties;
|
|
66
|
+
/**
|
|
67
|
+
* The children to be rendered inside the SelectAssociatedTag component.
|
|
68
|
+
* @type {ReactNode}
|
|
69
|
+
*/
|
|
70
|
+
children?: ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* Callback function called when an option is selected.
|
|
73
|
+
* @type {(value: Dictionary<SelectOption>, option: SelectOption | SelectOption[]) => void}
|
|
74
|
+
*/
|
|
75
|
+
onSelect: (value: Dictionary<SelectOption>, option: SelectOption | SelectOption[]) => void;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { useIcon } from './hooks/useIcon';
|
|
4
4
|
export const CircleInfoIcon = forwardRef((props, ref) => {
|
|
5
5
|
const { width, height } = useIcon(props);
|
|
6
|
-
return (
|
|
6
|
+
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", ...props, ref: ref, width: width, height: height, children: _jsx("path", { d: "M12 22C10.0222 22 8.08879 21.4136 6.4443 20.3148C4.79981 19.216 3.51809 17.6541 2.76121 15.8268C2.00433 13.9996 1.8063 11.9889 2.19215 10.0492C2.578 8.10937 3.53041 6.32775 4.92894 4.92924C6.32746 3.53073 8.10929 2.57796 10.0491 2.19211C11.9889 1.80627 13.9996 2.00444 15.8269 2.7613C17.6541 3.51817 19.2159 4.79981 20.3148 6.44429C21.4135 8.08876 22 10.0224 22 12.0002C21.997 14.6513 20.9424 17.1929 19.0677 19.0675C17.193 20.9423 14.6513 21.997 12 22ZM8.99 9.44579C8.8334 9.44578 8.68318 9.50817 8.5723 9.61878C8.46144 9.72938 8.39895 9.8793 8.39857 10.0359V11.0857C8.39895 11.2423 8.46144 11.3922 8.5723 11.5028C8.68318 11.6134 8.8334 11.6758 8.99 11.6758H10.4757V19.0599H13.3329V9.44579H8.99ZM11.6714 4.87484C11.3154 4.87455 10.9673 4.97932 10.6712 5.17687C10.375 5.37442 10.1441 5.65582 10.0076 5.98461C9.87108 6.31341 9.83514 6.67473 9.90431 7.02395C9.97349 7.37316 10.1447 7.69415 10.3962 7.94609C10.6477 8.19802 10.9683 8.37021 11.3174 8.43994C11.6665 8.50967 12.0285 8.47408 12.3575 8.3381C12.6865 8.20212 12.9678 7.97129 13.1659 7.67544C13.3639 7.3796 13.4697 7.03187 13.47 6.67588C13.4708 6.19798 13.2817 5.73937 12.9445 5.40078C12.6072 5.06219 12.1493 4.87109 11.6714 4.86995V4.87484Z", fill: "currentColor" }) }));
|
|
7
7
|
});
|
|
@@ -408,4 +408,6 @@ export declare const LazyIcon: {
|
|
|
408
408
|
WebPersonalizationIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
|
|
409
409
|
WidgetIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
|
|
410
410
|
WritingAIAssitantIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
|
|
411
|
+
QRCodeManagementIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
|
|
412
|
+
QRSetDashboardIcon: import("react").LazyExoticComponent<import("react").ForwardRefExoticComponent<import("../types").IconProps & import("react").RefAttributes<SVGSVGElement>>>;
|
|
411
413
|
};
|
|
@@ -411,4 +411,6 @@ export const LazyIcon = {
|
|
|
411
411
|
WebPersonalizationIcon: lazy(() => import('../WebPersonalizationIcon').then(m => ({ default: m.WebPersonalizationIcon }))),
|
|
412
412
|
WidgetIcon: lazy(() => import('../WidgetIcon').then(m => ({ default: m.WidgetIcon }))),
|
|
413
413
|
WritingAIAssitantIcon: lazy(() => import('../WritingAIAssitantIcon').then(m => ({ default: m.WritingAIAssitantIcon }))),
|
|
414
|
+
QRCodeManagementIcon: lazy(() => import('../QRCodeManagementIcon').then(m => ({ default: m.QRCodeManagementIcon }))),
|
|
415
|
+
QRSetDashboardIcon: lazy(() => import('../QRSetDashboardIcon').then(m => ({ default: m.QRSetDashboardIcon }))),
|
|
414
416
|
};
|
|
@@ -6,7 +6,18 @@ export declare const InputSuggestion: import("styled-components").StyledComponen
|
|
|
6
6
|
Option: import("rc-select/lib/Option").OptionFC;
|
|
7
7
|
_InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/_util/type").AnyObject) => import("react").JSX.Element;
|
|
8
8
|
}, any, {}, never>;
|
|
9
|
-
export declare const ModalCustom: import("styled-components").StyledComponent<import("react").
|
|
9
|
+
export declare const ModalCustom: import("styled-components").StyledComponent<import("react").FC<import("../Modal").ModalProps> & {
|
|
10
|
+
confirm: (props: import("antd").ModalFuncProps) => {
|
|
11
|
+
destroy: () => void;
|
|
12
|
+
update: (configUpdate: import("antd").ModalFuncProps | ((prevConfig: import("antd").ModalFuncProps) => import("antd").ModalFuncProps)) => void;
|
|
13
|
+
};
|
|
14
|
+
useModal: typeof import("antd/es/modal/useModal").default;
|
|
15
|
+
success: import("antd/es/modal/confirm").ModalFunc;
|
|
16
|
+
info: import("antd/es/modal/confirm").ModalFunc;
|
|
17
|
+
error: import("antd/es/modal/confirm").ModalFunc;
|
|
18
|
+
warning: import("antd/es/modal/confirm").ModalFunc;
|
|
19
|
+
destroyAll: () => void;
|
|
20
|
+
}, any, {}, never>;
|
|
10
21
|
export declare const ButtonCustom: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").ButtonProps & import("react").RefAttributes<HTMLElement>> & {
|
|
11
22
|
Group: import("react").FC<import("antd/es/button").ButtonGroupProps>;
|
|
12
23
|
}, any, {}, never>;
|
|
@@ -6,4 +6,15 @@ export declare const InputSuggestion: import("styled-components").StyledComponen
|
|
|
6
6
|
Option: import("rc-select/lib/Option").OptionFC;
|
|
7
7
|
_InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/_util/type").AnyObject) => import("react").JSX.Element;
|
|
8
8
|
}, any, {}, never>;
|
|
9
|
-
export declare const ModalCustom: import("styled-components").StyledComponent<import("react").
|
|
9
|
+
export declare const ModalCustom: import("styled-components").StyledComponent<import("react").FC<import("../Modal").ModalProps> & {
|
|
10
|
+
confirm: (props: import("antd").ModalFuncProps) => {
|
|
11
|
+
destroy: () => void;
|
|
12
|
+
update: (configUpdate: import("antd").ModalFuncProps | ((prevConfig: import("antd").ModalFuncProps) => import("antd").ModalFuncProps)) => void;
|
|
13
|
+
};
|
|
14
|
+
useModal: typeof import("antd/es/modal/useModal").default;
|
|
15
|
+
success: import("antd/es/modal/confirm").ModalFunc;
|
|
16
|
+
info: import("antd/es/modal/confirm").ModalFunc;
|
|
17
|
+
error: import("antd/es/modal/confirm").ModalFunc;
|
|
18
|
+
warning: import("antd/es/modal/confirm").ModalFunc;
|
|
19
|
+
destroyAll: () => void;
|
|
20
|
+
}, any, {}, never>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type ValueType = 'input' | 'select';
|
|
3
|
+
type Value = {
|
|
4
|
+
source: any;
|
|
5
|
+
code: any;
|
|
6
|
+
} | string;
|
|
7
|
+
type Option = {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
};
|
|
12
|
+
export interface InputSelectAttributeProps {
|
|
13
|
+
sourceOptions: Option[];
|
|
14
|
+
mapCodeOptions: Record<string, Option[]>;
|
|
15
|
+
label?: string;
|
|
16
|
+
isErrorTag?: boolean;
|
|
17
|
+
errorMsg?: string;
|
|
18
|
+
value: Value;
|
|
19
|
+
onChange: (newValueData: {
|
|
20
|
+
value: Value;
|
|
21
|
+
valueType: ValueType;
|
|
22
|
+
}) => void;
|
|
23
|
+
}
|
|
24
|
+
declare const _default: import("react").MemoExoticComponent<(props: InputSelectAttributeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Libraries
|
|
3
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
4
|
+
import { get, has, keyBy, upperFirst } from 'lodash';
|
|
5
|
+
import { Flex, Form, Select, Tooltip, Typography } from 'antd';
|
|
6
|
+
// Translations
|
|
7
|
+
import { translate, translations } from '@antscorp/antsomi-ui/es/locales';
|
|
8
|
+
// Components
|
|
9
|
+
import Icon from '@antscorp/icons';
|
|
10
|
+
import { ModalV2 } from '../ModalV2';
|
|
11
|
+
import { StyledTag as Tag } from '@antscorp/antsomi-ui/es/components/molecules/SelectV2/styled';
|
|
12
|
+
import { StyledSelect } from './styled';
|
|
13
|
+
import { EmptyData } from '../EmptyData';
|
|
14
|
+
import { Dashboard30Icon, ErrorIcon } from '../../icons';
|
|
15
|
+
// Constants
|
|
16
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
17
|
+
import { TAG_TYPE } from '../TagifyInput';
|
|
18
|
+
const InputSelectAttribute = (props) => {
|
|
19
|
+
const { value, errorMsg, label, isErrorTag, sourceOptions = [], mapCodeOptions = {}, onChange, } = props;
|
|
20
|
+
const [form] = Form.useForm();
|
|
21
|
+
const sourceValue = Form.useWatch('source', form);
|
|
22
|
+
// States
|
|
23
|
+
const [openModal, setOpenModal] = useState(false);
|
|
24
|
+
const codeOptions = useMemo(() => {
|
|
25
|
+
if (sourceValue) {
|
|
26
|
+
return get(mapCodeOptions, sourceValue, []);
|
|
27
|
+
}
|
|
28
|
+
return [];
|
|
29
|
+
}, [sourceValue, mapCodeOptions]);
|
|
30
|
+
const initCodeTitleField = useMemo(() => {
|
|
31
|
+
if (sourceValue === TAG_TYPE.PROMOTION_CODE) {
|
|
32
|
+
return 'Allocated Code';
|
|
33
|
+
}
|
|
34
|
+
return upperFirst(translate(translations._ITEM_NAME_ATTRIBUTE, 'attribute'));
|
|
35
|
+
}, [sourceValue]);
|
|
36
|
+
const mapCodeBySource = useMemo(() => {
|
|
37
|
+
if (typeof value === 'string')
|
|
38
|
+
return {};
|
|
39
|
+
return keyBy(get(mapCodeOptions, value?.source, []), 'value');
|
|
40
|
+
}, [mapCodeOptions, value]);
|
|
41
|
+
const mapSourceOptions = useMemo(() => {
|
|
42
|
+
if (typeof value === 'string')
|
|
43
|
+
return {};
|
|
44
|
+
return keyBy(sourceOptions, 'value');
|
|
45
|
+
}, [sourceOptions, value]);
|
|
46
|
+
const getCodeDefaultBySource = useCallback((source) => get(mapCodeOptions, [source, '0', 'value'], ''), [mapCodeOptions]);
|
|
47
|
+
const onOpenModal = useCallback(() => {
|
|
48
|
+
if (value && typeof value !== 'string') {
|
|
49
|
+
const isExistCode = has(mapCodeBySource, [value?.code, 'label']);
|
|
50
|
+
const isExistSource = has(mapSourceOptions, [value?.source]);
|
|
51
|
+
form.setFieldsValue({
|
|
52
|
+
source: isExistSource ? value?.source : undefined,
|
|
53
|
+
code: isExistCode ? value?.code : undefined,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const source = sourceOptions[0]?.value || '';
|
|
58
|
+
const code = getCodeDefaultBySource(source);
|
|
59
|
+
form.setFieldsValue({ source, code });
|
|
60
|
+
}
|
|
61
|
+
setOpenModal(true);
|
|
62
|
+
}, [value, mapCodeBySource, form, sourceOptions, mapSourceOptions, getCodeDefaultBySource]);
|
|
63
|
+
const onDeselect = useCallback(() => {
|
|
64
|
+
onChange({ value: '', valueType: 'input' });
|
|
65
|
+
}, [onChange]);
|
|
66
|
+
const onHideModal = useCallback(() => {
|
|
67
|
+
setOpenModal(false);
|
|
68
|
+
}, []);
|
|
69
|
+
const onAfterClose = useCallback(() => {
|
|
70
|
+
form.resetFields();
|
|
71
|
+
}, [form]);
|
|
72
|
+
const onOk = async () => {
|
|
73
|
+
try {
|
|
74
|
+
// Validate form fields before getting values
|
|
75
|
+
const values = await form.validateFields();
|
|
76
|
+
if (typeof values !== 'string') {
|
|
77
|
+
const newValue = {
|
|
78
|
+
source: values?.source,
|
|
79
|
+
code: values?.code,
|
|
80
|
+
};
|
|
81
|
+
onChange({ value: newValue, valueType: 'select' });
|
|
82
|
+
}
|
|
83
|
+
setOpenModal(false);
|
|
84
|
+
}
|
|
85
|
+
catch (errorInfo) {
|
|
86
|
+
// eslint-disable-next-line no-console
|
|
87
|
+
console.error('Validation Failed:', errorInfo);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const onChangeInput = useCallback((val) => {
|
|
91
|
+
onChange({ value: val, valueType: 'input' });
|
|
92
|
+
}, [onChange]);
|
|
93
|
+
const onValuesChange = useCallback((changedValues) => {
|
|
94
|
+
// If source changed -> set new code based on new source
|
|
95
|
+
if (changedValues?.source) {
|
|
96
|
+
const newCode = getCodeDefaultBySource(changedValues.source);
|
|
97
|
+
form.setFieldValue('code', newCode);
|
|
98
|
+
}
|
|
99
|
+
}, [form, getCodeDefaultBySource]);
|
|
100
|
+
const renderInput = () => {
|
|
101
|
+
let element = null;
|
|
102
|
+
const isObjValue = value && typeof value !== 'string';
|
|
103
|
+
if (openModal || isObjValue) {
|
|
104
|
+
element = (_jsxs("div", { style: {
|
|
105
|
+
display: 'flex',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
justifyContent: 'space-between',
|
|
108
|
+
height: 32,
|
|
109
|
+
padding: '4px 12px 4px 4px',
|
|
110
|
+
borderBottom: `1px solid ${errorMsg ? THEME.token?.colorError : THEME.token?.blue1}`,
|
|
111
|
+
}, children: [_jsx("div", { style: { width: '100%', cursor: 'pointer' }, onClick: onOpenModal, children: isObjValue && (_jsx(Tag, { isError: isErrorTag, children: isErrorTag ? (_jsxs(Flex, { gap: 5, align: "center", children: ["Unknown", _jsx(Tooltip, { title: "The used dynamic content is removed", children: _jsx(ErrorIcon, { size: 16 }) })] })) : (_jsx(Typography.Text, { ellipsis: {
|
|
112
|
+
tooltip: get(mapCodeBySource, [value?.code, 'label'], value?.code),
|
|
113
|
+
}, style: { maxWidth: 150 }, children: get(mapCodeBySource, [value?.code, 'label'], value?.code) })) })) }), _jsx(Icon, { type: "icon-ants-remove", style: { fontSize: 10, color: '#222', cursor: 'pointer' }, onClick: onDeselect })] }));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
element = (_jsx(StyledSelect, { mode: "multiple", options: [{ value: '', label: 'Or select a field' }], notFoundContent: null, onSelect: onOpenModal, style: { width: '100%', borderTop: 'none', borderLeft: 'none', borderRight: 'none' }, onDeselect: onDeselect, autoClearSearchValue: false, searchValue: typeof value === 'string' ? value : '', onSearch: onChangeInput, status: errorMsg ? 'error' : undefined, placeholder: typeof value === 'string' ? value : translate(translations.inputYourValue.title), "$isPlaceholder": !value, "$isError": !!errorMsg, dropdownStyle: {
|
|
117
|
+
...(openModal ? { display: 'none' } : {}),
|
|
118
|
+
} }));
|
|
119
|
+
}
|
|
120
|
+
return element;
|
|
121
|
+
};
|
|
122
|
+
return (_jsxs(_Fragment, { children: [renderInput(), errorMsg ? (_jsx(Typography.Text, { style: { marginLeft: 8, color: THEME.token?.red8, marginTop: 5 }, children: errorMsg })) : null, _jsx(ModalV2, { title: translate(translations._PREDICT_MODEL_SELECT_ATTRIBUTE, 'Select attribute'), okText: translate(translations._ACT_APPLY, 'Apply'), open: openModal, onOk: onOk, onCancel: onHideModal, afterClose: onAfterClose, destroyOnClose: true, centered: true, children: _jsxs(Form, { colon: false, form: form, onValuesChange: onValuesChange, children: [_jsx(Form.Item, { label: translate(translations._TITL_PERSONALIZATION_TYPE, 'Content Source'), name: "source", required: true, labelCol: { span: 6 }, labelAlign: "left", rules: [{ required: true, message: 'Please select field!' }], children: _jsx(Select, { suffixIcon: _jsx(Icon, { type: "icon-ants-expand-more", style: { fontSize: '20px', color: THEME.token?.colorIcon } }), options: sourceOptions, placeholder: "Please select an item" }) }), _jsx(Form.Item, { label: label || initCodeTitleField, required: true, labelCol: { span: 6 }, labelAlign: "left", name: "code", rules: [{ required: true, message: 'Please select field!' }], children: _jsx(Select, { suffixIcon: _jsx(Icon, { type: "icon-ants-expand-more", style: { fontSize: '20px', color: THEME.token?.colorIcon } }), notFoundContent: _jsx(EmptyData, { size: "small", icon: _jsx(Dashboard30Icon, {}), description: "No personalized content in this journey" }), placeholder: "Please select an item", options: codeOptions }) })] }) })] }));
|
|
123
|
+
};
|
|
124
|
+
export default memo(InputSelectAttribute);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const StyledSelect: import("styled-components").StyledComponent<{
|
|
2
|
+
(props: import("@antscorp/antsomi-ui/es/components/molecules").SelectV2Props): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
defaultProps: {
|
|
4
|
+
suffixIcon: import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
filterOption: (input: any, option: any) => boolean;
|
|
6
|
+
tagRender: (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
containerStyle: {};
|
|
8
|
+
labelStyle: {};
|
|
9
|
+
clearIcon: import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
};
|
|
11
|
+
}, any, {
|
|
12
|
+
$isPlaceholder?: any;
|
|
13
|
+
$isError?: boolean | undefined;
|
|
14
|
+
}, never>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
// Components
|
|
4
|
+
import { SelectV2 as Select } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
5
|
+
// Constants
|
|
6
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
7
|
+
export const StyledSelect = styled(Select) `
|
|
8
|
+
.antsomi-select-selection-overflow .antsomi-select-selection-overflow-item {
|
|
9
|
+
flex: 1;
|
|
10
|
+
|
|
11
|
+
.antsomi-select-selection-search {
|
|
12
|
+
width: fit-content !important;
|
|
13
|
+
flex: 1;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
${({ $isError }) => $isError
|
|
18
|
+
? css `
|
|
19
|
+
.antsomi-select-selector {
|
|
20
|
+
box-shadow: none !important;
|
|
21
|
+
}
|
|
22
|
+
`
|
|
23
|
+
: css ``}
|
|
24
|
+
|
|
25
|
+
.antsomi-select-selection-placeholder {
|
|
26
|
+
${props => !props.$isPlaceholder
|
|
27
|
+
? css `
|
|
28
|
+
color: rgba(0, 0, 0, 0.85);
|
|
29
|
+
font-size: ${THEME.token?.fontSize}px;
|
|
30
|
+
`
|
|
31
|
+
: css ``}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="hoist-non-react-statics" />
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import { ModalProps as AntdModalProps } from 'antd';
|
|
2
|
+
import { ModalProps as AntdModalProps, ModalFuncProps } from 'antd';
|
|
4
3
|
export interface ModalProps extends AntdModalProps {
|
|
5
4
|
header?: React.ReactNode;
|
|
6
5
|
headerStyle?: {
|
|
@@ -10,14 +9,15 @@ export interface ModalProps extends AntdModalProps {
|
|
|
10
9
|
loading?: boolean;
|
|
11
10
|
}
|
|
12
11
|
export declare const OriginalModal: React.FC<ModalProps>;
|
|
13
|
-
export declare const Modal:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, any, import("./styled").CustomModalProps, never> & import("hoist-non-react-statics").NonReactStatics<React.FC<AntdModalProps> & import("antd/es/modal/confirm").ModalStaticFunctions & {
|
|
12
|
+
export declare const Modal: React.FC<ModalProps> & {
|
|
13
|
+
confirm: (props: ModalFuncProps) => {
|
|
14
|
+
destroy: () => void;
|
|
15
|
+
update: (configUpdate: ModalFuncProps | ((prevConfig: ModalFuncProps) => ModalFuncProps)) => void;
|
|
16
|
+
};
|
|
19
17
|
useModal: typeof import("antd/es/modal/useModal").default;
|
|
18
|
+
success: import("antd/es/modal/confirm").ModalFunc;
|
|
19
|
+
info: import("antd/es/modal/confirm").ModalFunc;
|
|
20
|
+
error: import("antd/es/modal/confirm").ModalFunc;
|
|
21
|
+
warning: import("antd/es/modal/confirm").ModalFunc;
|
|
20
22
|
destroyAll: () => void;
|
|
21
|
-
|
|
22
|
-
_InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/modal/PurePanel").PurePanelProps) => React.JSX.Element;
|
|
23
|
-
}, {}> & React.FC<ModalProps>;
|
|
23
|
+
};
|
|
@@ -15,16 +15,18 @@ export const OriginalModal = memo(props => {
|
|
|
15
15
|
maskClosable: loading ? false : props.maskClosable, children: [props.header || null, props.children || null] }));
|
|
16
16
|
});
|
|
17
17
|
OriginalModal.displayName = 'OriginalModal';
|
|
18
|
-
export const Modal = OriginalModal
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export const Modal = Object.assign(OriginalModal, {
|
|
19
|
+
confirm: (props) => StyledModal.confirm({
|
|
20
|
+
cancelText: 'Cancel',
|
|
21
|
+
...props,
|
|
22
|
+
}),
|
|
23
|
+
useModal: StyledModal.useModal,
|
|
24
|
+
success: StyledModal.success,
|
|
25
|
+
info: StyledModal.info,
|
|
26
|
+
error: StyledModal.error,
|
|
27
|
+
warning: StyledModal.warning,
|
|
28
|
+
destroyAll: StyledModal.destroyAll,
|
|
22
29
|
});
|
|
23
|
-
Modal.useModal = StyledModal.useModal;
|
|
24
|
-
Modal.success = StyledModal.success;
|
|
25
|
-
Modal.info = StyledModal.info;
|
|
26
|
-
Modal.error = StyledModal.error;
|
|
27
|
-
Modal.warning = StyledModal.warning;
|
|
28
30
|
Modal.defaultProps = {
|
|
29
31
|
loading: false,
|
|
30
32
|
};
|