@antscorp/antsomi-ui 1.3.5-beta.957 → 1.3.5-beta.959
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 +43 -0
- package/es/components/atoms/SelectAssociatedTag/index.d.ts +2 -0
- package/es/components/atoms/SelectAssociatedTag/index.js +1 -0
- package/es/components/atoms/SelectAssociatedTag/styled.d.ts +7 -0
- package/es/components/atoms/SelectAssociatedTag/styled.js +46 -0
- package/es/components/atoms/SelectAssociatedTag/types.d.ts +59 -0
- package/es/components/atoms/SelectAssociatedTag/types.js +1 -0
- package/es/components/atoms/index.d.ts +2 -0
- package/es/components/atoms/index.js +1 -0
- package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +0 -1
- package/es/components/template/TemplateListing/Loadable.d.ts +0 -1
- package/package.json +1 -1
|
@@ -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, selected, options, onSelect } = props;
|
|
12
|
+
const { tag, value } = selected || {};
|
|
13
|
+
return (_jsxs(StyledSpace, { className: "select-associated-tag", style: style, children: [_jsx(SelectTag, { ...tagConfigs, selectedTag: tag }), _jsx(Divider, { type: "vertical", style: { margin: '0px 1px 0px 6px' } }), _jsx(Select, { style: { width: '100%', height: '100%' }, value: value, 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, 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, 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_265: "SHA_265";
|
|
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,43 @@
|
|
|
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_265: 'SHA_265',
|
|
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: 'SHA265',
|
|
24
|
+
value: DEFAULT_TAGS.SHA_265,
|
|
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._, 'Hash Method'),
|
|
34
|
+
title: 'Hash Method',
|
|
35
|
+
onSelect: () => { },
|
|
36
|
+
},
|
|
37
|
+
selected: {
|
|
38
|
+
tag: DEFAULT_TAGS.RAW,
|
|
39
|
+
value: DEFAULT_TAGS.SHA_265,
|
|
40
|
+
},
|
|
41
|
+
options: DEFAULT_TAGS_LIST,
|
|
42
|
+
onSelect: () => { },
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectAssociatedTag } from './SelectAssociatedTag';
|
|
@@ -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,46 @@
|
|
|
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
|
+
> div:last-child {
|
|
17
|
+
width: 100%;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.antsomi-divider.antsomi-divider-vertical {
|
|
21
|
+
height: 20px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.antsomi-select-selector {
|
|
25
|
+
border: none !important;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
export const SelectedTag = styled(Typography.Text) `
|
|
29
|
+
border-radius: 3px;
|
|
30
|
+
height: 16px;
|
|
31
|
+
line-height: 16px;
|
|
32
|
+
padding-left: 3px;
|
|
33
|
+
padding-right: 3px;
|
|
34
|
+
flex-shrink: 0;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
|
|
37
|
+
background: ${props => props.$background};
|
|
38
|
+
|
|
39
|
+
&.antsomi-typography {
|
|
40
|
+
color: ${props => props.$color};
|
|
41
|
+
|
|
42
|
+
&.antsomi-typography-ellipsis {
|
|
43
|
+
max-width: 50px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Dictionary } from 'lodash';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
export type TagItem = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
background: CSSProperties['background'];
|
|
7
|
+
color: CSSProperties['color'];
|
|
8
|
+
};
|
|
9
|
+
export interface TagConfigProps {
|
|
10
|
+
selectedTag: TagItem['value'];
|
|
11
|
+
title?: string;
|
|
12
|
+
options: TagItem[];
|
|
13
|
+
onSelect: (newItem: TagItem) => void;
|
|
14
|
+
}
|
|
15
|
+
export type SelectOption = {
|
|
16
|
+
label: string;
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Properties for the SelectAssociatedTag component.
|
|
21
|
+
*/
|
|
22
|
+
export interface SelectAssociatedTagProps {
|
|
23
|
+
/**
|
|
24
|
+
* Configuration properties for tag options, excluding the selected tag.
|
|
25
|
+
* @type {Omit<TagConfigProps, 'selectedTag'>}
|
|
26
|
+
*/
|
|
27
|
+
tagConfigs: Omit<TagConfigProps, 'selectedTag'>;
|
|
28
|
+
/**
|
|
29
|
+
* The currently selected tag and its associated value.
|
|
30
|
+
* @type {{ tag: string; value: string; }}
|
|
31
|
+
*/
|
|
32
|
+
selected: {
|
|
33
|
+
/**
|
|
34
|
+
* The identifier for the selected tag.
|
|
35
|
+
* @type {string}
|
|
36
|
+
*/
|
|
37
|
+
tag: string;
|
|
38
|
+
/**
|
|
39
|
+
* The value associated with the selected tag.
|
|
40
|
+
* @type {Dictionary<SelectOption>}
|
|
41
|
+
*/
|
|
42
|
+
value: Dictionary<SelectOption>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* A list of selectable options.
|
|
46
|
+
* @type {SelectOption[]}
|
|
47
|
+
*/
|
|
48
|
+
options: SelectOption[];
|
|
49
|
+
/**
|
|
50
|
+
* The style object for the SelectAssociatedTag component.
|
|
51
|
+
* @type {CSSProperties}
|
|
52
|
+
*/
|
|
53
|
+
style?: CSSProperties;
|
|
54
|
+
/**
|
|
55
|
+
* Callback function called when an option is selected.
|
|
56
|
+
* @type {(value: Dictionary<SelectOption>, option: SelectOption | SelectOption[]) => void}
|
|
57
|
+
*/
|
|
58
|
+
onSelect: (value: Dictionary<SelectOption>, option: SelectOption | SelectOption[]) => void;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -34,6 +34,7 @@ export { Image } from './Image';
|
|
|
34
34
|
export { IconField } from './IconField';
|
|
35
35
|
export { Suspense } from './Suspense';
|
|
36
36
|
export { App } from './App';
|
|
37
|
+
export { SelectAssociatedTag } from './SelectAssociatedTag';
|
|
37
38
|
export * from './Flex';
|
|
38
39
|
export * from './PreviewTabs';
|
|
39
40
|
export * from './MobileFrame';
|
|
@@ -54,3 +55,4 @@ export type { PaginationProps } from './Pagination';
|
|
|
54
55
|
export type { InputDynamicProps } from './InputDynamic';
|
|
55
56
|
export type { ImageProps } from './Image';
|
|
56
57
|
export type { AppProps } from './App';
|
|
58
|
+
export type { SelectAssociatedTagProps } from './SelectAssociatedTag';
|
|
@@ -34,6 +34,7 @@ export { Image } from './Image';
|
|
|
34
34
|
export { IconField } from './IconField';
|
|
35
35
|
export { Suspense } from './Suspense';
|
|
36
36
|
export { App } from './App';
|
|
37
|
+
export { SelectAssociatedTag } from './SelectAssociatedTag';
|
|
37
38
|
export * from './Flex';
|
|
38
39
|
export * from './PreviewTabs';
|
|
39
40
|
export * from './MobileFrame';
|