@antscorp/antsomi-ui 2.0.59 → 2.0.61-staging.1

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 (42) hide show
  1. package/es/components/atoms/SelectAssociatedTag/SelectAssociatedTag.d.ts +5 -0
  2. package/es/components/atoms/SelectAssociatedTag/SelectAssociatedTag.js +15 -0
  3. package/es/components/atoms/SelectAssociatedTag/SelectTag.d.ts +4 -0
  4. package/es/components/atoms/SelectAssociatedTag/SelectTag.js +26 -0
  5. package/es/components/atoms/SelectAssociatedTag/constants.d.ts +11 -0
  6. package/es/components/atoms/SelectAssociatedTag/constants.js +42 -0
  7. package/es/components/atoms/SelectAssociatedTag/index.d.ts +3 -0
  8. package/es/components/atoms/SelectAssociatedTag/index.js +2 -0
  9. package/es/components/atoms/SelectAssociatedTag/styled.d.ts +7 -0
  10. package/es/components/atoms/SelectAssociatedTag/styled.js +60 -0
  11. package/es/components/atoms/SelectAssociatedTag/types.d.ts +76 -0
  12. package/es/components/atoms/SelectAssociatedTag/types.js +1 -0
  13. package/es/components/atoms/Typography/EllipsisMiddle.d.ts +7 -0
  14. package/es/components/atoms/Typography/EllipsisMiddle.js +9 -0
  15. package/es/components/atoms/Typography/index.d.ts +1 -0
  16. package/es/components/atoms/Typography/index.js +1 -0
  17. package/es/components/atoms/index.d.ts +2 -1
  18. package/es/components/atoms/index.js +2 -1
  19. package/es/components/molecules/DisplayFormat/DisplayFormatSettings.js +47 -11
  20. package/es/components/molecules/DisplayFormat/components/FormatNumber.js +5 -5
  21. package/es/components/molecules/DisplayFormat/constants.d.ts +21 -0
  22. package/es/components/molecules/DisplayFormat/constants.js +65 -0
  23. package/es/components/molecules/DisplayFormat/utils.js +17 -12
  24. package/es/components/molecules/InputSelectAttribute/index.d.ts +25 -0
  25. package/es/components/molecules/InputSelectAttribute/index.js +115 -0
  26. package/es/components/molecules/InputSelectAttribute/styled.d.ts +14 -0
  27. package/es/components/molecules/InputSelectAttribute/styled.js +33 -0
  28. package/es/components/molecules/SearchPopover/utils.js +1 -1
  29. package/es/components/molecules/SelectV2/styled.d.ts +3 -1
  30. package/es/components/molecules/SelectV2/styled.js +2 -2
  31. package/es/components/molecules/TagifyInput/TagifyInput.js +169 -77
  32. package/es/components/molecules/TagifyInput/constants.d.ts +24 -2
  33. package/es/components/molecules/TagifyInput/constants.js +25 -2
  34. package/es/components/molecules/TagifyInput/patternHandlers.d.ts +12 -6
  35. package/es/components/molecules/TagifyInput/patternHandlers.js +88 -43
  36. package/es/components/molecules/TagifyInput/types.d.ts +24 -3
  37. package/es/components/molecules/TagifyInput/utils.d.ts +7 -1
  38. package/es/components/molecules/TagifyInput/utils.js +72 -4
  39. package/es/components/molecules/TagifyInput/utils.style.js +82 -96
  40. package/es/components/molecules/index.d.ts +1 -0
  41. package/es/components/molecules/index.js +1 -0
  42. package/package.json +2 -1
@@ -0,0 +1,5 @@
1
+ import type { SelectAssociatedTagProps } from './types';
2
+ export declare const SelectAssociatedTag: {
3
+ (props: SelectAssociatedTagProps): import("react/jsx-runtime").JSX.Element;
4
+ defaultProps: SelectAssociatedTagProps;
5
+ };
@@ -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,4 @@
1
+ /// <reference types="react" />
2
+ import { TagConfigProps } from './types';
3
+ declare const _default: import("react").MemoExoticComponent<(props: TagConfigProps) => import("react/jsx-runtime").JSX.Element>;
4
+ export default _default;
@@ -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,3 @@
1
+ export { SelectAssociatedTag } from './SelectAssociatedTag';
2
+ export type { SelectAssociatedTagProps } from './types';
3
+ export * from './constants';
@@ -0,0 +1,2 @@
1
+ export { SelectAssociatedTag } from './SelectAssociatedTag';
2
+ export * from './constants';
@@ -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 {};
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const EllipsisMiddle: React.FC<{
3
+ suffixCount: number;
4
+ children: string;
5
+ tooltip?: string;
6
+ style?: React.CSSProperties;
7
+ }>;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Typography } from 'antd';
3
+ export const EllipsisMiddle = ({ suffixCount, children, tooltip = false, style }) => {
4
+ if (children.length <= suffixCount)
5
+ return _jsx(Typography.Text, { style: style, children: children });
6
+ const start = children.slice(0, children.length - suffixCount);
7
+ const suffix = children.slice(-suffixCount);
8
+ return (_jsx(Typography.Text, { style: style, ellipsis: { tooltip: tooltip ? _jsx("bdo", { dir: "ltr", children: tooltip }) : false, suffix }, children: start }));
9
+ };
@@ -1 +1,2 @@
1
1
  export { Typography } from './Text';
2
+ export { EllipsisMiddle } from './EllipsisMiddle';
@@ -1 +1,2 @@
1
1
  export { Typography } from './Text';
2
+ export { EllipsisMiddle } from './EllipsisMiddle';
@@ -6,7 +6,7 @@ export { Radio, RadioGroupSub, RadioButton } from './Radio';
6
6
  export { Space } from './Space';
7
7
  export { Tag } from './Tag';
8
8
  export { Tooltip } from './Tooltip';
9
- export { Typography } from './Typography';
9
+ export { Typography, EllipsisMiddle } from './Typography';
10
10
  export { Checkbox } from './Checkbox';
11
11
  export { message } from './Message';
12
12
  export { Segmented } from './Segmented';
@@ -46,6 +46,7 @@ export * from './RateV2';
46
46
  export * from './Popover';
47
47
  export * from './Iframe';
48
48
  export * from './Avatar';
49
+ export * from './SelectAssociatedTag';
49
50
  export type { SliderProps } from './Slider';
50
51
  export type { PaginationProps } from './Pagination';
51
52
  export type { InputDynamicProps } from './InputDynamic';
@@ -6,7 +6,7 @@ export { Radio, RadioGroupSub, RadioButton } from './Radio';
6
6
  export { Space } from './Space';
7
7
  export { Tag } from './Tag';
8
8
  export { Tooltip } from './Tooltip';
9
- export { Typography } from './Typography';
9
+ export { Typography, EllipsisMiddle } from './Typography';
10
10
  export { Checkbox } from './Checkbox';
11
11
  export { message } from './Message';
12
12
  export { Segmented } from './Segmented';
@@ -46,3 +46,4 @@ export * from './RateV2';
46
46
  export * from './Popover';
47
47
  export * from './Iframe';
48
48
  export * from './Avatar';
49
+ export * from './SelectAssociatedTag';
@@ -1,20 +1,23 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  // Libraries
3
3
  import { useEffect, useState } from 'react';
4
4
  import { translate, translations } from '@antscorp/antsomi-locales';
5
5
  // Components
6
6
  import { FormatDatetime, FormatNumber, } from './components';
7
7
  import { EditIcon } from '../../icons';
8
- import { Button, Text } from '../../atoms';
8
+ import { Button, EllipsisMiddle, Typography } from '../../atoms';
9
9
  // Utils
10
10
  import { formatDatetimeDF, formatNumberDF } from './utils';
11
11
  // Constants
12
12
  import { DATE_TIME_EXAMPLE, DATETIME_SETTINGS_DEFAULT, NUMBER_SETTINGS_DEFAULT, NUMBER_EXAMPLE, } from './constants';
13
+ // Json
14
+ import Currencies from './currencies.json';
13
15
  export const DisplayFormatSettings = props => {
14
16
  const { infos, url, displayFormatType, formatSettings, dynamicContentType, onSettingsChange, disabled, ...rest } = props;
15
17
  const [settings, setSettings] = useState(formatSettings ??
16
18
  (displayFormatType === 'datetime' ? DATETIME_SETTINGS_DEFAULT : NUMBER_SETTINGS_DEFAULT));
17
19
  const [showDetailEdit, setShowDetailEdit] = useState(false);
20
+ const [prefixSymbol, setPrefixSymbol] = useState(undefined);
18
21
  useEffect(() => {
19
22
  setSettings(displayFormatType === 'datetime' ? DATETIME_SETTINGS_DEFAULT : NUMBER_SETTINGS_DEFAULT);
20
23
  }, [displayFormatType]);
@@ -22,6 +25,14 @@ export const DisplayFormatSettings = props => {
22
25
  if (Object.keys(formatSettings).length > 0) {
23
26
  setSettings(formatSettings);
24
27
  }
28
+ if (displayFormatType === 'currency' &&
29
+ formatSettings.prefixType === 'symbol' &&
30
+ Currencies[formatSettings.currencyCode].symbolOnLeft) {
31
+ setPrefixSymbol(Currencies[formatSettings.currencyCode].symbol);
32
+ }
33
+ else {
34
+ setPrefixSymbol(undefined);
35
+ }
25
36
  }, [formatSettings]);
26
37
  const handleChangeFormat = (updatedSettings) => {
27
38
  if (onSettingsChange) {
@@ -43,15 +54,40 @@ export const DisplayFormatSettings = props => {
43
54
  if (displayFormatType === 'datetime') {
44
55
  formatDFValue = formatDatetimeDF(DATE_TIME_EXAMPLE, settings);
45
56
  }
46
- return (_jsxs("div", { className: "ants-flex ants-flex-wrap ants-items-center ants-mt-1 ants-gap-2 ant-flex-row", style: { display: 'flex', alignItems: 'end', gap: '8px', marginBottom: '5px' }, ...rest, children: [_jsx(Text, { size: 11, className: "ants-flex", color: "#7F7F7F", dangerouslySetInnerHTML: {
47
- __html: `${translate(translations._ACT_PREVIEW)}: &nbsp;<bdo dir='ltr'>${formatDFValue}</bdo>`,
48
- } }), _jsx(Button, { disabled: disabled, size: "small", icon: _jsx(EditIcon, { width: 16, height: 16, color: "#005EB8" }), className: "ants-border-none", style: {
49
- marginTop: '1px',
50
- backgroundColor: showDetailEdit ? '#DEEFFE' : 'transparent',
51
- border: 'none',
52
- boxShadow: 'none',
53
- borderRadius: '5px',
54
- }, onClick: () => setShowDetailEdit(prevShow => !prevShow) })] }));
57
+ return (_jsxs("div", { className: "ants-flex ants-items-center ant-flex-row", style: {
58
+ display: 'flex',
59
+ alignItems: 'center',
60
+ marginBottom: '5px',
61
+ flexShrink: 0,
62
+ width: '100%',
63
+ flexWrap: 'nowrap',
64
+ marginTop: '5px',
65
+ }, ...rest, children: [_jsxs(Typography.Text, { className: "ants-flex", style: {
66
+ color: '#7F7F7F',
67
+ fontSize: '11px',
68
+ whiteSpace: 'nowrap',
69
+ maxWidth: '100%',
70
+ }, children: [translate(translations._ACT_PREVIEW), ": \u00A0"] }), prefixSymbol && (_jsx("bdo", { dir: "ltr", style: { color: '#7F7F7F', fontSize: '11px' }, children: prefixSymbol })), _jsxs("div", { style: { display: 'inline-flex', maxWidth: '100%', alignItems: 'center' }, dir: "ltr", children: [_jsx(EllipsisMiddle, { style: {
71
+ color: '#7F7F7F',
72
+ fontSize: '11px',
73
+ whiteSpace: 'nowrap',
74
+ flexShrink: 0,
75
+ width: displayFormatType === 'datetime'
76
+ ? '100%'
77
+ : `calc(100% - (2px + ${translate(translations._ACT_PREVIEW).length * 0.35}px))`,
78
+ flexGrow: 1,
79
+ maxWidth: displayFormatType === 'datetime'
80
+ ? '100%'
81
+ : prefixSymbol
82
+ ? `calc(99% - (${prefixSymbol.length * 0.1}px + 1px))`
83
+ : `calc(100% - 2.5px)`,
84
+ }, suffixCount: 7, tooltip: prefixSymbol ? `${prefixSymbol}${formatDFValue}` : formatDFValue, children: formatDFValue }), _jsx(Button, { disabled: disabled, size: "small", icon: _jsx(EditIcon, { width: 16, height: 16, color: "#005EB8" }), className: "ants-border-none", style: {
85
+ backgroundColor: showDetailEdit ? '#DEEFFE' : 'transparent',
86
+ border: 'none',
87
+ boxShadow: 'none',
88
+ borderRadius: '5px',
89
+ flexShrink: 0,
90
+ }, onClick: () => setShowDetailEdit(prevShow => !prevShow) })] })] }));
55
91
  };
56
92
  const renderFormatSetting = () => {
57
93
  switch (displayFormatType) {
@@ -112,18 +112,18 @@ export const FormatNumber = (props) => {
112
112
  ...settingValues,
113
113
  isCompact: checked,
114
114
  });
115
- }, children: t(translations.dynamicContent.modal.label.formNumberDisplayFormat.compact) }) }), _jsx(Form.Item, { label: decimalPlacesLabel, style: { marginBottom: 12 }, colon: false, labelCol: { span: 10 }, wrapperCol: { span: 14 }, children: _jsxs("div", { style: { display: 'flex', marginLeft: '55px', gap: '15px' }, children: [_jsx(Button, { style: { border: 'none', boxShadow: 'none', borderRadius: '5px' }, disabled: decimalPlaces <= 0, onClick: () => onChangeSettingsHandle({
115
+ }, children: translate(translations._TITL_EDIT_NUMBER_COMPACT) }) }), _jsx(Form.Item, { label: decimalPlacesLabel, style: { marginBottom: 12 }, colon: false, labelCol: { span: 12 }, wrapperCol: { span: 12 }, children: _jsxs("div", { style: { display: 'flex', marginLeft: '55px', gap: '15px' }, children: [_jsx(Button, { style: { border: 'none', boxShadow: 'none', borderRadius: '5px' }, disabled: decimalPlaces <= 0, onClick: () => onChangeSettingsHandle({
116
116
  ...settingValues,
117
117
  decimalPlaces: decimalPlaces - 1,
118
118
  }), size: "small", icon: _jsx(DecreaseDecimalIcon, { color: "#005EB8", style: { padding: '2px' } }) }), _jsx(Button, { style: { border: 'none', boxShadow: 'none', borderRadius: '5px' }, onClick: () => onChangeSettingsHandle({
119
119
  ...settingValues,
120
120
  decimalPlaces: decimalPlaces + 1,
121
- }), size: "small", icon: _jsx(IncreaseDecimalIcon, { color: "#005EB8", style: { padding: '2px' } }) })] }) }), _jsx(Form.Item, { label: _jsxs(_Fragment, { children: [_jsx("span", { style: { marginRight: '6px' }, children: translate(translations._DISPLAY_GROUPING) }), _jsx(Tooltip, { placement: "top", title: t(translations.dynamicContent.modal.label.formNumberDisplayFormat
122
- .groupingIconTooltipTitle), style: { marginLeft: 4, opacity: 0.4 }, children: _jsx(ViewDetailsInformationIcon, { size: 14 }) })] }), colon: false, labelCol: { span: 10 }, wrapperCol: { span: 14 }, children: _jsx(Select, { style: { width: 100 }, value: grouping, onChange: value => onChangeSettingsHandle({
121
+ }),
122
+ // disabled={decimalPlaces >= 100}
123
+ size: "small", icon: _jsx(IncreaseDecimalIcon, { color: "#005EB8", style: { padding: '2px' } }) })] }) }), _jsx(Form.Item, { label: _jsxs(_Fragment, { children: [_jsx("span", { style: { marginRight: '6px' }, children: translate(translations._DISPLAY_GROUPING) }), _jsx(Tooltip, { placement: "top", title: translate(translations._TOOLTIP__DISPLAY_DECIMAL), style: { marginLeft: 4, opacity: 0.4 }, children: _jsx(ViewDetailsInformationIcon, { size: 14 }) })] }), colon: false, labelCol: { span: 10 }, wrapperCol: { span: 14 }, children: _jsx(Select, { style: { width: 100 }, value: grouping, onChange: value => onChangeSettingsHandle({
123
124
  ...settingValues,
124
125
  grouping: value,
125
- }), options: listGroupingSeparatorOptions }) }), _jsx(Form.Item, { label: _jsxs(_Fragment, { children: [_jsx("span", { style: { marginRight: '6px' }, children: translate(translations._DISPLAY_DECIMAL) }), _jsx(Tooltip, { placement: "top", title: t(translations.dynamicContent.modal.label.formNumberDisplayFormat
126
- .decimalIconTooltipTitle), style: { marginLeft: 4, opacity: 0.4 }, children: _jsx(ViewDetailsInformationIcon, { size: 14 }) })] }), labelCol: { span: 10 }, wrapperCol: { span: 14 }, colon: false, children: _jsx(Select, { style: { width: 100 }, value: decimal, onChange: value => onChangeSettingsHandle({
126
+ }), options: listGroupingSeparatorOptions }) }), _jsx(Form.Item, { label: _jsxs(_Fragment, { children: [_jsx("span", { style: { marginRight: '6px' }, children: translate(translations._DISPLAY_DECIMAL) }), _jsx(Tooltip, { placement: "top", title: translate(translations._TOOLTIP__DISPLAY_GROUPING), style: { marginLeft: 4, opacity: 0.4 }, children: _jsx(ViewDetailsInformationIcon, { size: 14 }) })] }), labelCol: { span: 10 }, wrapperCol: { span: 14 }, colon: false, children: _jsx(Select, { style: { width: 100 }, value: decimal, onChange: value => onChangeSettingsHandle({
127
127
  ...settingValues,
128
128
  decimal: value,
129
129
  }), options: listDecimalSeparatorOptions }) })] }));
@@ -149,3 +149,24 @@ export declare const DYNAMIC_CONTENT_DF_FORMAT_TYPE: {
149
149
  number: string;
150
150
  datetime: string;
151
151
  };
152
+ export declare const TYPE_FORMAT_OPTIONS: {
153
+ SHORT: string;
154
+ MEDIUM: string;
155
+ LONG: string;
156
+ };
157
+ export declare const DATE_FORMAT_LIST_TEST: {
158
+ [x: string]: {
159
+ [x: string]: {
160
+ label: string;
161
+ value: string;
162
+ };
163
+ };
164
+ };
165
+ export declare const TIME_FORMAT_LIST_TEST: {
166
+ [x: string]: {
167
+ [x: string]: {
168
+ label: string;
169
+ value: string;
170
+ };
171
+ };
172
+ };
@@ -239,3 +239,68 @@ export const DYNAMIC_CONTENT_DF_FORMAT_TYPE = {
239
239
  number: 'number',
240
240
  datetime: 'datetime',
241
241
  };
242
+ export const TYPE_FORMAT_OPTIONS = {
243
+ SHORT: 'short',
244
+ MEDIUM: 'medium',
245
+ LONG: 'long',
246
+ };
247
+ export const DATE_FORMAT_LIST_TEST = {
248
+ [DATE_FORMAT_OPTIONS[0].value]: {
249
+ [TYPE_FORMAT_OPTIONS.SHORT]: {
250
+ label: translate(translations._DATE_SHORT_FORMAT1),
251
+ value: 'MM/DD/YYYY',
252
+ },
253
+ [TYPE_FORMAT_OPTIONS.MEDIUM]: {
254
+ label: translate(translations._DATE_MEDIUM_FORMAT1),
255
+ value: 'MMM DD, YYYY',
256
+ },
257
+ [TYPE_FORMAT_OPTIONS.LONG]: {
258
+ label: translate(translations._DATE_LONG_FORMAT1),
259
+ value: 'MMMM DD, YYYY',
260
+ },
261
+ },
262
+ [DATE_FORMAT_OPTIONS[1].value]: {
263
+ [TYPE_FORMAT_OPTIONS.SHORT]: {
264
+ label: translate(translations._DATE_SHORT_FORMAT2),
265
+ value: 'DD/MM/YYYY',
266
+ },
267
+ [TYPE_FORMAT_OPTIONS.MEDIUM]: {
268
+ label: translate(translations._DATE_MEDIUM_FORMAT2),
269
+ value: 'DD MMM, YYYY',
270
+ },
271
+ [TYPE_FORMAT_OPTIONS.LONG]: {
272
+ label: translate(translations._DATE_LONG_FORMAT2),
273
+ value: 'DD MMMM, YYYY',
274
+ },
275
+ },
276
+ };
277
+ export const TIME_FORMAT_LIST_TEST = {
278
+ [TIME_FORMAT_OPTIONS[0].value]: {
279
+ [TYPE_FORMAT_OPTIONS.SHORT]: {
280
+ label: translate(translations._TIME_SHORT_FOTMAT1),
281
+ value: 'h:mm A',
282
+ },
283
+ [TYPE_FORMAT_OPTIONS.MEDIUM]: {
284
+ label: translate(translations._TIME_MEDIUM_FORMAT1),
285
+ value: 'h:mm:ss A',
286
+ },
287
+ [TYPE_FORMAT_OPTIONS.LONG]: {
288
+ label: translate(translations._TIME_LONG_FORMAT1),
289
+ value: 'h:mm:ss A [GMT]',
290
+ },
291
+ },
292
+ [TIME_FORMAT_OPTIONS[1].value]: {
293
+ [TYPE_FORMAT_OPTIONS.SHORT]: {
294
+ label: translate(translations._TIME_SHORT_FOTMAT2),
295
+ value: 'H:mm',
296
+ },
297
+ [TYPE_FORMAT_OPTIONS.MEDIUM]: {
298
+ label: translate(translations._TIME_MEDIUM_FORMAT2),
299
+ value: 'H:mm:ss',
300
+ },
301
+ [TYPE_FORMAT_OPTIONS.LONG]: {
302
+ label: translate(translations._TIME_LONG_FORMAT2),
303
+ value: 'H:mm:ss [GMT]',
304
+ },
305
+ },
306
+ };
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable prefer-regex-literals */
2
2
  // Libraries
3
3
  import dayjs from 'dayjs';
4
- import currencyFormatter from 'currency-formatter';
5
4
  import { has, get, set } from 'lodash';
6
5
  import 'dayjs/locale/vi';
6
+ import BigNumber from 'bignumber.js';
7
7
  // Json
8
8
  import Currencies from './currencies.json';
9
9
  // Constants
@@ -114,12 +114,15 @@ export function formatNumberDF(number, fType, fOptions = {
114
114
  });
115
115
  let formatedCompactNumber;
116
116
  if (item) {
117
- const compactNumber = (number / item.value).toFixed(decimalPlaces).replace(rx, '$1');
117
+ const bigNum = new BigNumber(number);
118
+ const divisor = new BigNumber(item.value);
119
+ const numString = bigNum.div(divisor).toFixed(decimalPlaces);
120
+ const [integerPart, decimalPart] = numString.split('.');
121
+ const formattedInteger = new Intl.NumberFormat('en-US').format(Number(integerPart));
118
122
  formatedCompactNumber =
119
- currencyFormatter.format(Number(compactNumber), {
120
- decimal,
121
- precision: decimalPlaces,
122
- }) + item.symbol;
123
+ formattedInteger.replace(/,/g, grouping !== 'none' ? grouping || '' : '') +
124
+ (decimalPart ? decimal + decimalPart : '') +
125
+ item.symbol;
123
126
  }
124
127
  else {
125
128
  formatedCompactNumber = '0';
@@ -128,11 +131,13 @@ export function formatNumberDF(number, fType, fOptions = {
128
131
  result.textNumberFormated = formatedCompactNumber;
129
132
  }
130
133
  else {
131
- result.textNumberFormated = currencyFormatter.format(number, {
132
- thousand: grouping === 'none' ? '' : grouping,
133
- decimal,
134
- precision: decimalPlaces,
135
- });
134
+ const bigNum = new BigNumber(number);
135
+ const numString = bigNum.toFixed(decimalPlaces);
136
+ const [integerPart, decimalPart] = numString.split('.');
137
+ const formattedInteger = new Intl.NumberFormat('en-US').format(Number(integerPart));
138
+ result.textNumberFormated =
139
+ formattedInteger.replace(/,/g, grouping !== 'none' ? grouping || '' : '') +
140
+ (decimalPart ? decimal + decimalPart : '');
136
141
  }
137
142
  switch (fType) {
138
143
  case 'percentage':
@@ -167,7 +172,7 @@ export function formatNumberDF(number, fType, fOptions = {
167
172
  let html = result.textNumberFormated;
168
173
  if (result.hasSymbol) {
169
174
  if (result.symbolOnLeft) {
170
- html = `${result.symbol}${html}`;
175
+ html = `${html}`;
171
176
  }
172
177
  else {
173
178
  html = `${html}${result.symbol}`;
@@ -0,0 +1,25 @@
1
+ /// <reference types="react" />
2
+ export type ValueType = 'input' | 'select';
3
+ type Value = {
4
+ source: string;
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;