@antscorp/antsomi-ui 1.3.5-beta.961 → 1.3.5-beta.963

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.
@@ -5,11 +5,11 @@ import { DisplayFormatSettings } from './DisplayFormatSettings';
5
5
  // Types
6
6
  import { Select } from '../Select';
7
7
  // Constants
8
- import { DYNAMIC_CONTENT_ATTR_DF_TYPE, NUMBER_SETTINGS_DEFAULT, DATETIME_SETTINGS_DEFAULT, } from './constants';
8
+ import { DYNAMIC_CONTENT_ATTR_DF_TYPE, NUMBER_SETTINGS_DEFAULT, DATETIME_SETTINGS_DEFAULT, DYNAMIC_CONTENT_DF_FORMAT_TYPE, } from './constants';
9
9
  import { useUpdateEffect } from '@antscorp/antsomi-ui/es/hooks';
10
10
  export const DisplayFormatSelect = props => {
11
- const { onSettingChange, formatType = 'number', setting = formatType === 'datetime' ? DATETIME_SETTINGS_DEFAULT : NUMBER_SETTINGS_DEFAULT, disabled, infos, url, ...rest } = props;
12
- const { type: settingType = 'number' } = setting || {};
11
+ const { onSettingChange, formatType, setting = formatType === 'datetime' ? DATETIME_SETTINGS_DEFAULT : NUMBER_SETTINGS_DEFAULT, disabled, infos, url, ...rest } = props;
12
+ const { type: settingType = DYNAMIC_CONTENT_DF_FORMAT_TYPE[formatType] } = setting || {};
13
13
  // Memo
14
14
  const typeOptions = useMemo(() => DYNAMIC_CONTENT_ATTR_DF_TYPE.filter(dfType => dfType.dataType === formatType), [formatType]);
15
15
  // Effects
@@ -17,9 +17,9 @@ export const DisplayFormatSelect = props => {
17
17
  onSettingChange(formatType === 'datetime' ? DATETIME_SETTINGS_DEFAULT : NUMBER_SETTINGS_DEFAULT);
18
18
  // eslint-disable-next-line react-hooks/exhaustive-deps
19
19
  }, [formatType]);
20
- return (typeOptions.length > 0 && (_jsxs("div", { ...rest, style: { display: 'flex', flexDirection: 'column', gap: '16px' }, children: [_jsx(Select, { disabled: disabled, value: settingType, options: typeOptions, onSelect: type => onSettingChange({
20
+ return (typeOptions.length > 0 && (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, ...rest, children: [_jsx(Select, { disabled: disabled, value: settingType, options: typeOptions, onSelect: type => onSettingChange({
21
21
  ...setting,
22
- type,
22
+ type: type,
23
23
  }) }), _jsx(DisplayFormatSettings, { disabled: disabled, onSettingsChange: setting => {
24
24
  onSettingChange(setting);
25
25
  }, displayFormatType: settingType, formatSettings: setting, url: url ?? '', infos: infos ?? {} })] })));
@@ -12,39 +12,39 @@ import { formatDatetimeDF, formatNumberDF } from './utils';
12
12
  import { DATE_TIME_EXAMPLE, DATETIME_SETTINGS_DEFAULT, NUMBER_SETTINGS_DEFAULT, NUMBER_EXAMPLE, } from './constants';
13
13
  export const DisplayFormatSettings = props => {
14
14
  const { infos, url, displayFormatType, formatSettings, dynamicContentType, onSettingsChange, disabled, ...rest } = props;
15
- const [settings, setSettings] = useState(displayFormatType === 'datetime' ? DATETIME_SETTINGS_DEFAULT : NUMBER_SETTINGS_DEFAULT);
15
+ const [settings, setSettings] = useState(formatSettings ??
16
+ (displayFormatType === 'datetime' ? DATETIME_SETTINGS_DEFAULT : NUMBER_SETTINGS_DEFAULT));
16
17
  const [showDetailEdit, setShowDetailEdit] = useState(false);
17
- const [formatType, setFormatType] = useState(displayFormatType);
18
18
  useEffect(() => {
19
19
  setSettings(displayFormatType === 'datetime' ? DATETIME_SETTINGS_DEFAULT : NUMBER_SETTINGS_DEFAULT);
20
- setFormatType(displayFormatType);
21
20
  }, [displayFormatType]);
22
21
  useEffect(() => {
23
22
  if (Object.keys(formatSettings).length > 0) {
24
23
  setSettings(formatSettings);
25
24
  }
26
25
  }, [formatSettings]);
27
- // const handleChange = (updatedSettings: TDatetimeFormatSetting) => {
28
- // if (onSettingsChange) {
29
- // onSettingsChange({
30
- // ...updatedSettings,
31
- // type: 'datetime',
32
- // language: portalLanguage,
33
- // });
34
- // }
35
- // };
26
+ const handleChangeFormat = (updatedSettings) => {
27
+ if (onSettingsChange) {
28
+ onSettingsChange({
29
+ ...updatedSettings,
30
+ type: displayFormatType,
31
+ });
32
+ }
33
+ };
36
34
  const renderFormatDisplay = () => {
37
35
  let formatDFValue = '';
38
36
  // Numeric Attribute DF
39
- if (formatType === 'number' || formatType === 'currency' || formatType === 'percentage') {
40
- formatDFValue = formatNumberDF(NUMBER_EXAMPLE, formatType, settings);
37
+ if (displayFormatType === 'number' ||
38
+ displayFormatType === 'currency' ||
39
+ displayFormatType === 'percentage') {
40
+ formatDFValue = formatNumberDF(NUMBER_EXAMPLE, displayFormatType, settings);
41
41
  }
42
42
  // Datetime Attribute DF
43
- if (formatType === 'datetime') {
43
+ if (displayFormatType === 'datetime') {
44
44
  formatDFValue = formatDatetimeDF(DATE_TIME_EXAMPLE, settings);
45
45
  }
46
- return (_jsxs("div", { ...rest, className: "ants-flex ants-flex-wrap ants-items-center ants-mt-4 ants-gap-2 ant-flex-row", style: { display: 'flex', alignItems: 'end', gap: '8px', marginBottom: '5px' }, children: [_jsx(Text, { size: 11, className: "text-[11px] ants-flex", color: "#7F7F7F", dangerouslySetInnerHTML: {
47
- __html: `${translate(translations._ACT_PREVIEW)}: <bdo dir='ltr'>${formatDFValue}</bdo>`,
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
48
  } }), _jsx(Button, { disabled: disabled, size: "small", icon: _jsx(EditIcon, { width: 16, height: 16, color: "#005EB8" }), className: "ants-border-none", style: {
49
49
  marginTop: '1px',
50
50
  backgroundColor: showDetailEdit ? '#DEEFFE' : 'transparent',
@@ -54,14 +54,14 @@ export const DisplayFormatSettings = props => {
54
54
  }, onClick: () => setShowDetailEdit(prevShow => !prevShow) })] }));
55
55
  };
56
56
  const renderFormatSetting = () => {
57
- switch (formatType) {
57
+ switch (displayFormatType) {
58
58
  case 'number':
59
59
  case 'percentage':
60
60
  case 'currency': {
61
- return (_jsx(FormatNumber, { ...settings, onSettingsChange: onSettingsChange, type: formatType, url: url, infos: infos }));
61
+ return (_jsx(FormatNumber, { ...settings, onSettingsChange: handleChangeFormat, type: displayFormatType, url: url, infos: infos }));
62
62
  }
63
63
  case 'datetime': {
64
- return (_jsx(FormatDatetime, { ...settings, onSettingsChange: onSettingsChange, type: formatType, dynamicContentType: dynamicContentType }));
64
+ return (_jsx(FormatDatetime, { ...settings, onSettingsChange: handleChangeFormat, type: displayFormatType, dynamicContentType: dynamicContentType }));
65
65
  }
66
66
  default: {
67
67
  return null;
@@ -3,7 +3,7 @@ export type TDatetimeFormatSetting = {
3
3
  hasDateFormat: boolean;
4
4
  hasTimeFormat: boolean;
5
5
  dateParseFormat: 'DD/MM/YYYY' | 'MM/DD/YYYY' | 'YYYY/MM/DD';
6
- timeParseFormat: '12hour' | '24hour' | string;
6
+ timeParseFormat: '12hour' | '24hour';
7
7
  dateParseOption: 'short' | 'medium' | 'long' | undefined;
8
8
  timeParseOption: 'short' | 'medium' | 'long' | undefined;
9
9
  language?: string;
@@ -42,7 +42,13 @@ export const FormatDatetime = (props) => {
42
42
  return (_jsxs("div", { children: [_jsxs("div", { style: { display: 'flex', gap: '16px', alignItems: 'start' }, children: [_jsx(Checkbox, { style: { marginTop: '4px' }, checked: hasDateFormat, disabled: hasDateFormat && !hasTimeFormat, onChange: e => handleChange({
43
43
  ...dfSettings,
44
44
  hasDateFormat: e.target.checked,
45
- }) }), _jsxs("div", { children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '10px', marginBottom: '4px' }, children: [_jsx("span", { style: { width: '135px' }, children: translate(translations._TITL_DISPLAY_DATE_AS) }), _jsx(Select, { style: { width: 150 }, disabled: !hasDateFormat, defaultValue: dateParseFormat, options: DATE_FORMAT_OPTIONS, onChange: value => {
45
+ }) }), _jsxs("div", { style: { width: '100%' }, children: [_jsxs("div", { style: {
46
+ display: 'flex',
47
+ alignItems: 'center',
48
+ marginBottom: '4px',
49
+ width: '100%',
50
+ justifyContent: 'space-between',
51
+ }, children: [_jsx("span", { style: { fontSize: '12px' }, children: translate(translations._TITL_DISPLAY_DATE_AS) }), _jsx(Select, { style: { width: 150 }, disabled: !hasDateFormat, defaultValue: dateParseFormat, options: DATE_FORMAT_OPTIONS, onChange: value => {
46
52
  handleChange({
47
53
  ...dfSettings,
48
54
  dateParseFormat: value,
@@ -51,10 +57,21 @@ export const FormatDatetime = (props) => {
51
57
  } })] }), _jsx(RadioGroup, { disabled: !hasDateFormat, defaultValue: dateParseOption, onChange: e => handleChange({
52
58
  ...dfSettings,
53
59
  dateParseOption: e.target.value,
54
- }), children: _jsxs(Space, { direction: "vertical", size: "middle", children: [_jsx(Radio, { value: "short", children: dateFormatExamples.SHORT }), _jsx(Radio, { value: "medium", children: dateFormatExamples.MEDIUM }), _jsx(Radio, { value: "long", children: dateFormatExamples.LONG })] }) })] })] }), _jsxs("div", { style: { display: 'flex', gap: '16px', alignItems: 'start', marginTop: '10px' }, children: [_jsx(Checkbox, { style: { marginTop: '4px' }, checked: hasTimeFormat, disabled: hasTimeFormat && !hasDateFormat, onChange: e => handleChange({
60
+ }), children: _jsxs(Space, { direction: "vertical", size: "middle", children: [_jsx(Radio, { value: "short", children: dateFormatExamples.SHORT }), _jsx(Radio, { value: "medium", children: dateFormatExamples.MEDIUM }), _jsx(Radio, { value: "long", children: dateFormatExamples.LONG })] }) })] })] }), _jsxs("div", { style: {
61
+ display: 'flex',
62
+ gap: '16px',
63
+ alignItems: 'start',
64
+ marginTop: '10px',
65
+ }, children: [_jsx(Checkbox, { style: { marginTop: '4px' }, checked: hasTimeFormat, disabled: hasTimeFormat && !hasDateFormat, onChange: e => handleChange({
55
66
  ...dfSettings,
56
67
  hasTimeFormat: e.target.checked,
57
- }) }), _jsxs("div", { children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '10px', marginBottom: '4px' }, children: [_jsx("span", { style: { width: '135px' }, children: translate(translations._TITL_DISPLAY_TIME_AS) }), _jsx(Select, { style: { width: 150 }, disabled: !hasTimeFormat, defaultValue: timeParseFormat, options: TIME_FORMAT_OPTIONS, onChange: value => {
68
+ }) }), _jsxs("div", { style: { width: '100%' }, children: [_jsxs("div", { style: {
69
+ display: 'flex',
70
+ alignItems: 'center',
71
+ justifyContent: 'space-between',
72
+ width: '100%',
73
+ marginBottom: '4px',
74
+ }, children: [_jsx("span", { style: { fontSize: '12px' }, children: translate(translations._TITL_DISPLAY_TIME_AS) }), _jsx(Select, { style: { width: 150 }, disabled: !hasTimeFormat, defaultValue: timeParseFormat, options: TIME_FORMAT_OPTIONS, onChange: value => {
58
75
  handleChange({
59
76
  ...dfSettings,
60
77
  timeParseFormat: value,
@@ -42,7 +42,6 @@ export type TNumberFormatSettings = {
42
42
  };
43
43
  type FormatNumberProps = {
44
44
  onSettingsChange?: (settingValues: TNumberFormatSettings) => void;
45
- type: TDisplayFormat;
46
45
  } & TNumberFormatSettings & {
47
46
  infos: PayloadInfo;
48
47
  url: string;
@@ -15,11 +15,15 @@ import { translate, translations } from '@antscorp/antsomi-locales';
15
15
  import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
16
16
  import { DecreaseDecimalIcon, IncreaseDecimalIcon, ViewDetailsInformationIcon, } from '../../../icons';
17
17
  import { CURRENCY_REGEX, DECIMAL_PLACES_REGEX } from '../regex';
18
+ import { useAppConfigContext } from '@antscorp/antsomi-ui/es/providers';
19
+ import { MEDIA_TEMPLATE_API } from '@antscorp/antsomi-ui/es/constants';
18
20
  const groupingOptions = ATTRIBUTE_NUMBERIC_FORMAT_OPTION.GROUPING_SEPARATOR;
19
21
  const decimalOptions = ATTRIBUTE_NUMBERIC_FORMAT_OPTION.DECIMAL_SEPARATOR;
20
22
  export const FormatNumber = (props) => {
21
23
  const { t, language } = i18nInstance;
22
- const { onSettingsChange, type: displayType, infos, url } = props;
24
+ const { onSettingsChange, type: formatType, infos, url } = props;
25
+ const { appConfig } = useAppConfigContext();
26
+ const { auth, env } = appConfig || {};
23
27
  const { currencyCode, decimalPlaces, grouping, decimal, prefixType, isCompact } = props;
24
28
  const settingValues = {
25
29
  decimalPlaces,
@@ -28,6 +32,7 @@ export const FormatNumber = (props) => {
28
32
  isCompact,
29
33
  currencyCode,
30
34
  prefixType,
35
+ type: formatType,
31
36
  };
32
37
  const [listCurrencyOptions, setListCurrencyOptions] = useState([]);
33
38
  const [isLoadingCurrencyOptions, setIsLoadingCurrencyOptions] = useState(true);
@@ -36,7 +41,7 @@ export const FormatNumber = (props) => {
36
41
  if (onSettingsChange) {
37
42
  onSettingsChange({
38
43
  ...settingValues,
39
- type: displayType,
44
+ // type: displayType,
40
45
  });
41
46
  }
42
47
  };
@@ -54,7 +59,7 @@ export const FormatNumber = (props) => {
54
59
  else {
55
60
  setIsLoadingCurrencyOptions(true);
56
61
  try {
57
- const data = await getCurrencyList({ lang: language, url }, infos);
62
+ const data = await getCurrencyList({ lang: language, url: `${MEDIA_TEMPLATE_API[env || 'sandbox-cdp']}/api/v1` }, auth || {});
58
63
  const currencies = data.reduce((accumulate, currency) => {
59
64
  if (Currencies[currency.code]) {
60
65
  accumulate.push({
@@ -96,10 +101,10 @@ export const FormatNumber = (props) => {
96
101
  ...decimal,
97
102
  ...(decimal.value === grouping && { disabled: true }),
98
103
  })), [grouping]);
99
- return (_jsxs(Form, { style: { width: '100%', fontSize: '12px' }, labelAlign: "left", children: [displayType === 'currency' && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { labelCol: { span: 3 }, wrapperCol: { span: 21 }, label: translate(translations._TITL_CURRENCY), colon: false, children: _jsxs(Radio.Group, { value: prefixType, onChange: ({ target: { value } }) => onChangeSettingsHandle({
104
+ return (_jsxs(Form, { style: { width: '100%', fontSize: '12px' }, labelAlign: "left", children: [formatType === 'currency' && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { labelCol: { span: 10 }, wrapperCol: { span: 14 }, label: translate(translations._TITL_CURRENCY), colon: false, children: _jsxs(Radio.Group, { value: prefixType, onChange: ({ target: { value } }) => onChangeSettingsHandle({
100
105
  ...settingValues,
101
106
  prefixType: value,
102
- }), children: [_jsx(Radio, { style: { fontSize: 12 }, value: "code", children: t(translations.dynamicContent.modal.label.formNumberDisplayFormat.currencyCode) }), _jsx(Radio, { style: { fontSize: 12 }, value: "symbol", children: t(translations.dynamicContent.modal.label.formNumberDisplayFormat.currencySymbol) })] }) }), _jsx(Form.Item, { label: " ", labelCol: { span: 3 }, wrapperCol: { span: 21 }, colon: false, children: _jsx(Select, { style: { width: 150 }, disabled: isLoadingCurrencyOptions, options: listCurrencyOptions, value: currencyCode, onChange: value => onChangeSettingsHandle({
107
+ }), children: [_jsx(Radio, { style: { fontSize: 12 }, value: "code", children: t(translations.dynamicContent.modal.label.formNumberDisplayFormat.currencyCode) }), _jsx(Radio, { style: { fontSize: 12 }, value: "symbol", children: t(translations.dynamicContent.modal.label.formNumberDisplayFormat.currencySymbol) })] }) }), _jsx(Form.Item, { label: " ", labelCol: { span: 10 }, wrapperCol: { span: 14 }, colon: false, children: _jsx(Select, { style: { width: 150 }, disabled: isLoadingCurrencyOptions, options: listCurrencyOptions, value: currencyCode, onChange: value => onChangeSettingsHandle({
103
108
  ...settingValues,
104
109
  currencyCode: value,
105
110
  }), showSearch: true }) })] })), _jsx(Form.Item, { children: _jsx(Checkbox, { style: { fontSize: 12 }, checked: isCompact, onChange: ({ target: { checked } }) => {
@@ -107,18 +112,18 @@ export const FormatNumber = (props) => {
107
112
  ...settingValues,
108
113
  isCompact: checked,
109
114
  });
110
- }, children: t(translations.dynamicContent.modal.label.formNumberDisplayFormat.compact) }) }), _jsx(Form.Item, { label: decimalPlacesLabel, style: { marginBottom: 12 }, colon: false, labelCol: { span: 3 }, wrapperCol: { span: 21 }, 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: 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({
111
116
  ...settingValues,
112
117
  decimalPlaces: decimalPlaces - 1,
113
118
  }), size: "small", icon: _jsx(DecreaseDecimalIcon, { color: "#005EB8", style: { padding: '2px' } }) }), _jsx(Button, { style: { border: 'none', boxShadow: 'none', borderRadius: '5px' }, onClick: () => onChangeSettingsHandle({
114
119
  ...settingValues,
115
120
  decimalPlaces: decimalPlaces + 1,
116
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
117
- .groupingIconTooltipTitle), style: { marginLeft: 4, opacity: 0.4 }, children: _jsx(ViewDetailsInformationIcon, { size: 14 }) })] }), colon: false, labelCol: { span: 3 }, wrapperCol: { span: 21 }, children: _jsx(Select, { style: { width: 100 }, value: grouping, onChange: value => onChangeSettingsHandle({
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({
118
123
  ...settingValues,
119
124
  grouping: value,
120
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
121
- .decimalIconTooltipTitle), style: { marginLeft: 4, opacity: 0.4 }, children: _jsx(ViewDetailsInformationIcon, { size: 14 }) })] }), labelCol: { span: 3 }, wrapperCol: { span: 21 }, colon: false, children: _jsx(Select, { style: { width: 100 }, value: decimal, onChange: value => onChangeSettingsHandle({
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({
122
127
  ...settingValues,
123
128
  decimal: value,
124
129
  }), options: listDecimalSeparatorOptions }) })] }));
@@ -145,3 +145,7 @@ export declare const TIME_FORMAT_LIST: {
145
145
  export declare const GROUPING_OPTIONS: {};
146
146
  export declare const NUMBER_SETTINGS_DEFAULT: TNumberFormatSettings;
147
147
  export declare const DATETIME_SETTINGS_DEFAULT: TDatetimeFormatSetting;
148
+ export declare const DYNAMIC_CONTENT_DF_FORMAT_TYPE: {
149
+ number: string;
150
+ datetime: string;
151
+ };
@@ -235,3 +235,7 @@ export const DATETIME_SETTINGS_DEFAULT = {
235
235
  timeParseFormat: '12hour',
236
236
  type: 'datetime',
237
237
  };
238
+ export const DYNAMIC_CONTENT_DF_FORMAT_TYPE = {
239
+ number: 'number',
240
+ datetime: 'datetime',
241
+ };
@@ -23,7 +23,7 @@ import { DETECT_LINK, EMOJI, ERROR_TAG, FORCE_SHOW_TOOLTIP, INVALID_TAG, MESSAGE
23
23
  const { CUSTOM_TAG } = TAG_TYPE;
24
24
  const TagifyInput = forwardRef((props, ref) => {
25
25
  // Props
26
- const { initialValue, escapeHTML, status, readonly, readonlyTag, realtime, disabled, maxLength, maxHeight, minWidth, placeholder, minWidthPlaceholder, isSingleLineText, acceptableTagPattern, tagProperties, mapAttributes, mapErrorAttributes, maxPersonalizeTags, name, children, cssTagifyVariables, onTagClick, onChange, } = props;
26
+ const { initialValue, escapeHTML, status, readonly, readonlyTag, realtime, disabled, maxLength, maxHeight, minWidth, placeholder, minWidthPlaceholder, isSingleLineText, acceptableTagPattern, tagProperties, mapAttributes, mapErrorAttributes, maxPersonalizeTags, name, children, cssTagifyVariables, onTagClick, onTagRemove, onChange, } = props;
27
27
  // States
28
28
  const [isLineBreak, setIsLineBreak] = useState(hasLineBreak(initialValue));
29
29
  const [tooltipRefresher, setTooltipRefresher] = useState(1);
@@ -451,6 +451,11 @@ const TagifyInput = forwardRef((props, ref) => {
451
451
  onTagClick(event.detail);
452
452
  }
453
453
  }, [onTagClick]);
454
+ const onTagifyRemoveTag = useCallback((event) => {
455
+ if (event.detail && onTagRemove) {
456
+ onTagRemove(event.detail);
457
+ }
458
+ }, [onTagRemove]);
454
459
  // Used to trigger replace URL detection and line break
455
460
  const onTagifyTyping = useCallback((event) => {
456
461
  if (event.detail) {
@@ -852,11 +857,13 @@ const TagifyInput = forwardRef((props, ref) => {
852
857
  tagifyInstance.on('click', onTagItemClick);
853
858
  tagifyInstance.on('input', onInputTagifyDebounce);
854
859
  tagifyInstance.on('change', onTagifyChangedDebounce);
860
+ tagifyInstance.on('remove', onTagifyRemoveTag);
855
861
  }
856
862
  // Off listen to Tagify events
857
863
  return () => {
858
864
  if (tagifyInstance) {
859
865
  tagifyInstance.off('click', onTagItemClick);
866
+ tagifyInstance.off('remove', onTagifyRemoveTag);
860
867
  if (onInputTagifyDebounce) {
861
868
  tagifyInstance.off('input', onInputTagifyDebounce);
862
869
  }
@@ -865,7 +872,7 @@ const TagifyInput = forwardRef((props, ref) => {
865
872
  }
866
873
  }
867
874
  };
868
- }, [onTagItemClick, onTagifyTyping, onTagifyChanged]);
875
+ }, [onTagItemClick, onTagifyTyping, onTagifyChanged, onTagifyRemoveTag]);
869
876
  // At the first render, need to update URL to tag to show hint in the tooltip with tag
870
877
  useEffect(() => {
871
878
  detectReplaceURLToTag();
@@ -131,6 +131,11 @@ export interface TagifyInputProps {
131
131
  * Receives the tag detail as parameter, allowing custom actions on tag click.
132
132
  */
133
133
  onTagClick?: (tagDetail: Tagify.ClickEventData<TagDataCustomize>) => void;
134
+ /**
135
+ * Event handler triggered when a tag is removed.
136
+ * Receives the tag detail as parameter, allowing custom actions on tag removal.
137
+ */
138
+ onTagRemove?: (tagDetail: Tagify.RemoveEventData<TagDataCustomize>) => void;
134
139
  /**
135
140
  * Event handler triggered when the input value changes.
136
141
  * Receives the updated input value as a string, allowing for controlled component updates.
@@ -64,6 +64,7 @@ export * from './Tabs';
64
64
  export * from './TagifyInput';
65
65
  export * from './EmojiCollections';
66
66
  export * from './EmojiPopover';
67
+ export * from './DisplayFormat';
67
68
  export { EditorScript } from './EditorScript';
68
69
  export { EditorTab } from './EditorTab';
69
70
  export { SelectAccount } from './SelectAccount';
@@ -64,6 +64,7 @@ export * from './Tabs';
64
64
  export * from './TagifyInput';
65
65
  export * from './EmojiCollections';
66
66
  export * from './EmojiPopover';
67
+ export * from './DisplayFormat';
67
68
  export { EditorScript } from './EditorScript';
68
69
  export { EditorTab } from './EditorTab';
69
70
  export { SelectAccount } from './SelectAccount';
@@ -16,7 +16,7 @@ export const CDP_API = {
16
16
  export const MEDIA_TEMPLATE_API = {
17
17
  [ENV.DEV]: 'https://sandbox-media-template.antsomi.com',
18
18
  [ENV.SANDBOX]: 'https://sandbox-media-template.antsomi.com',
19
- [ENV.SANDBOX_CDP]: 'https://sandbox-media-template.antsomi.com',
19
+ [ENV.SANDBOX_CDP]: 'https://sandbox-media-template.antsomi.com/cdp',
20
20
  [ENV.STAGING]: 'https://staging-media-template.antsomi.com',
21
21
  [ENV.PROD]: 'https://media-template.antsomi.com',
22
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.961",
3
+ "version": "1.3.5-beta.963",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",