@antscorp/antsomi-ui 1.3.5-beta.982 → 1.3.5-beta.984

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.
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { PayloadInfo } from '@antscorp/antsomi-ui/es/types';
3
2
  export type TDisplayFormat = 'number' | 'percentage' | 'currency' | 'datetime';
4
3
  type DisplayFormatProps = {
@@ -43,10 +43,9 @@ export const DisplayFormatSettings = props => {
43
43
  if (displayFormatType === 'datetime') {
44
44
  formatDFValue = formatDatetimeDF(DATE_TIME_EXAMPLE, settings);
45
45
  }
46
- return (_jsxs("div", { className: "ants-flex ants-items-center ants-gap-2 ant-flex-row", style: {
46
+ return (_jsxs("div", { className: "ants-flex ants-items-center ant-flex-row", style: {
47
47
  display: 'flex',
48
48
  alignItems: 'center',
49
- gap: '8px',
50
49
  marginBottom: '5px',
51
50
  flexShrink: 0,
52
51
  width: '100%',
@@ -64,7 +63,7 @@ export const DisplayFormatSettings = props => {
64
63
  whiteSpace: 'nowrap',
65
64
  flexShrink: 0,
66
65
  width: '100%',
67
- maxWidth: displayFormatType === 'datetime' ? '100%' : 'calc(98% + 1px)',
66
+ maxWidth: displayFormatType === 'datetime' ? '100%' : 'calc(100% - 2.5px)',
68
67
  }, suffixCount: 7, tooltip: true, children: formatDFValue }), _jsx(Button, { disabled: disabled, size: "small", icon: _jsx(EditIcon, { width: 16, height: 16, color: "#005EB8" }), className: "ants-border-none", style: {
69
68
  backgroundColor: showDetailEdit ? '#DEEFFE' : 'transparent',
70
69
  border: 'none',
@@ -12,7 +12,7 @@ type Option = {
12
12
  export interface InputSelectAttributeProps {
13
13
  sourceOptions: Option[];
14
14
  codeOptions: Option[];
15
- listSourceInit: Option[];
15
+ codeOptionsInitial?: Option[];
16
16
  label?: string;
17
17
  errorMsg?: string;
18
18
  value: Value;
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  // Libraries
3
3
  import { memo, useCallback, useEffect, useMemo, useState } from 'react';
4
- import { get, keyBy } from 'lodash';
5
- import { Form, Select, Typography } from 'antd';
4
+ import { get, isUndefined, keyBy } from 'lodash';
5
+ import { Flex, Form, Select, Tooltip, Typography } from 'antd';
6
6
  // Translations
7
7
  import { translate, translations } from '@antscorp/antsomi-ui/es/locales';
8
8
  // Components
@@ -10,10 +10,12 @@ import Icon from '@antscorp/icons';
10
10
  import { ModalV2 } from '../ModalV2';
11
11
  import { StyledTag as Tag } from '@antscorp/antsomi-ui/es/components/molecules/SelectV2/styled';
12
12
  import { StyledSelect } from './styled';
13
+ import { EmptyData } from '../EmptyData';
14
+ import { Dashboard30Icon, ErrorIcon } from '../../icons';
13
15
  // Constants
14
16
  import { THEME } from '@antscorp/antsomi-ui/es/constants';
15
17
  const InputSelectAttribute = (props) => {
16
- const { value, errorMsg, label, listSourceInit = [], sourceOptions = [], codeOptions = [], onChange, onChangeSelectSource, } = props;
18
+ const { value, errorMsg, label, sourceOptions = [], codeOptions = [], codeOptionsInitial = [], onChange, onChangeSelectSource, } = props;
17
19
  const [form] = Form.useForm();
18
20
  // States
19
21
  const [openModal, setOpenModal] = useState(false);
@@ -28,13 +30,14 @@ const InputSelectAttribute = (props) => {
28
30
  });
29
31
  // Effects
30
32
  useEffect(() => {
31
- if (attributeState.code === '') {
33
+ if (attributeState.code === '' ||
34
+ !codeOptions.find(option => option.value === attributeState.code)) {
32
35
  form.setFieldsValue({ code: codeOptions[0]?.value });
33
36
  }
34
37
  }, [attributeState, codeOptions, form]);
35
38
  // Memoized
36
39
  const mapCodeOpts = useMemo(() => keyBy(codeOptions, 'value'), [codeOptions]);
37
- const listSourceInitOpts = useMemo(() => keyBy(listSourceInit, 'value'), [listSourceInit]);
40
+ const mapCodeOriginOpts = useMemo(() => keyBy(codeOptionsInitial, 'value'), [codeOptionsInitial]);
38
41
  const onOpenModal = useCallback(() => {
39
42
  setOpenModal(true);
40
43
  }, []);
@@ -66,6 +69,8 @@ const InputSelectAttribute = (props) => {
66
69
  let element = null;
67
70
  const isObjValue = value && typeof value !== 'string';
68
71
  if (openModal || isObjValue) {
72
+ const isErrorTag = (isObjValue &&
73
+ isUndefined(get(mapCodeOriginOpts, [value.code])));
69
74
  element = (_jsxs("div", { style: {
70
75
  display: 'flex',
71
76
  alignItems: 'center',
@@ -73,21 +78,21 @@ const InputSelectAttribute = (props) => {
73
78
  height: 32,
74
79
  padding: '4px 12px 4px 4px',
75
80
  borderBottom: `1px solid ${errorMsg ? THEME.token?.colorError : THEME.token?.blue1}`,
76
- }, children: [_jsx("div", { style: { width: '100%', cursor: 'pointer' }, onClick: onOpenModal, children: isObjValue && (_jsx(Tag, { children: get(mapCodeOpts, [value.code, 'label'], get(listSourceInitOpts, [value.code, 'label'])) })) }), _jsx(Icon, { type: "icon-ants-remove", style: { fontSize: 10, color: '#222', cursor: 'pointer' }, onClick: onDeselect })] }));
81
+ }, 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 }) })] })) : (get(mapCodeOpts, [value.code, 'label'], mapCodeOriginOpts[value.code]?.label)) })) }), _jsx(Icon, { type: "icon-ants-remove", style: { fontSize: 10, color: '#222', cursor: 'pointer' }, onClick: onDeselect })] }));
77
82
  }
78
83
  else {
79
- element = (_jsx(StyledSelect, { mode: "multiple", options: [{ value: '', label: translate(translations.orSelectAField.title) }], 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: {
84
+ 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: {
80
85
  ...(openModal ? { display: 'none' } : {}),
81
86
  } }));
82
87
  }
83
88
  return element;
84
89
  };
85
- 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, destroyOnClose: true, children: _jsxs(Form, { colon: false, form: form, initialValues: {
90
+ 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, destroyOnClose: true, centered: true, children: _jsxs(Form, { colon: false, form: form, initialValues: {
86
91
  sources: attributeState.source || sourceOptions[0]?.value,
87
92
  code: attributeState.code || codeOptions[0]?.value,
88
- }, children: [_jsx(Form.Item, { label: translate(translations._TITL_PERSONALIZATION_TYPE, 'Content Source'), name: "sources", 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, value: attributeState.source, onChange: newValue => {
93
+ }, children: [_jsx(Form.Item, { label: translate(translations._TITL_PERSONALIZATION_TYPE, 'Content Source'), name: "sources", 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", value: attributeState.source, onChange: newValue => {
89
94
  setAttributeState(state => ({ ...state, code: '', source: newValue }));
90
95
  onChangeSelectSource(newValue);
91
- } }) }), _jsx(Form.Item, { label: label || 'Allocated Code', 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 } }), value: attributeState.code, options: codeOptions }) })] }) })] }));
96
+ } }) }), _jsx(Form.Item, { label: label || 'Allocated Code', 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", value: attributeState.code, options: codeOptions }) })] }) })] }));
92
97
  };
93
98
  export default memo(InputSelectAttribute);
@@ -9,7 +9,9 @@ export declare const StyledSelect: import("styled-components").StyledComponent<(
9
9
  OptGroup: import("rc-select/lib/OptGroup").OptionGroupFC;
10
10
  _InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/_util/type").AnyObject) => import("react").JSX.Element;
11
11
  }, any, {}, never>;
12
- export declare const StyledTag: import("styled-components").StyledComponent<import("antd").TagType, any, {}, never>;
12
+ export declare const StyledTag: import("styled-components").StyledComponent<import("antd").TagType, any, {
13
+ isError?: boolean | undefined;
14
+ }, never>;
13
15
  export declare const CloseButton: import("styled-components").StyledComponent<"div", any, {
14
16
  borderColor?: any;
15
17
  }, never>;
@@ -105,8 +105,8 @@ export const StyledTag = styled(Tag) `
105
105
  margin-right: 5px !important;
106
106
  padding: 5px 10px !important;
107
107
  border-radius: 15px !important;
108
- border: none !important;
109
- background-color: ${THEME.token?.blue2} !important;
108
+ border: ${p => (p.isError ? `1px solid ${THEME.token?.colorError}` : 'none')} !important;
109
+ background-color: ${p => (p.isError ? THEME.token?.bw0 : THEME.token?.blue2)} !important;
110
110
  cursor: pointer !important;
111
111
 
112
112
  .antsomi-tag-close-icon {
@@ -19,7 +19,7 @@ import { TagTextArea, TagifyWrapper, WrapperPlaceHolder } from './styled';
19
19
  import { parseTagStringToTagify, convertInputStringToOriginal, emojiManufacturer, getEmojiTag, isPersonalizeTagType, generateTagContent, unescapeString, hasLineBreak, selectRange, isTagClickable, findURLInTextNodes, getAttributesString, isAnchorNodeChildOfElement, isShortLinkTagType, isCustomTagType, sanitizeTagAttributes, getTagAttributes, applyTagAttributes, getTagContentAttributes, } from './utils';
20
20
  import { acceptablePatternChecking, detectURLRegex, getCachedRegex, getCustomTagId, getPersonalizeTagInfo, getShortLinkTagInfo, patternHandlers, } from './patternHandlers';
21
21
  // Constants
22
- import { DETECT_LINK, EMOJI, PERSONALIZE_PTN, PROMOTION_CODE, SHORT_LINK, SHORT_LINK_PTN, SHORT_LINK_V2, TAG_TYPE, defaultCssVariables, tagifyDefaultProps, TAG_CUSTOM_ATTRIBUTES, } from './constants';
22
+ import { DETECT_LINK, EMOJI, PERSONALIZE_PTN, SHORT_LINK, SHORT_LINK_PTN, SHORT_LINK_V2, TAG_TYPE, defaultCssVariables, tagifyDefaultProps, TAG_CUSTOM_ATTRIBUTES, } from './constants';
23
23
  const { CUSTOM_TAG } = TAG_TYPE;
24
24
  const { READONLY_TAG, INVALID_TAG, MESSAGE_TAG, FORCE_SHOW_TOOLTIP, ERROR_TAG, WARNING_TAG } = TAG_CUSTOM_ATTRIBUTES;
25
25
  const TagifyInput = forwardRef((props, ref) => {
@@ -535,8 +535,8 @@ const TagifyInput = forwardRef((props, ref) => {
535
535
  /*
536
536
  * Any map attribute change will sync label of the tags
537
537
  */
538
- const makeValidLabelTags = useCallback((attributes, errorAttributes, tagProperties) => {
539
- if (tagifyRef.current && labelTagRefreshness) {
538
+ const makeValidLabelTags = useCallback((attributes, errorAttributes) => {
539
+ if (tagifyRef.current) {
540
540
  const tagElements = tagifyRef.current.getTagElms();
541
541
  const { pattern, name: cachePatternName, acceptablePattern: acceptableType, } = patternHandlers[PERSONALIZE_PTN];
542
542
  tagElements.forEach(tagElement => {
@@ -559,8 +559,7 @@ const TagifyInput = forwardRef((props, ref) => {
559
559
  while ((match = regex.exec(value)) !== null) {
560
560
  const [, personalizeContent] = match;
561
561
  const [tagCode] = personalizeContent.split('||');
562
- const { label: tagLabel, isValid, message, type, isRemoved, canView, isArchived, isActive, isExpired, } = getPersonalizeTagInfo(tagCode, attributes, errorAttributes, tagProperties);
563
- const isPromotionCode = type === PROMOTION_CODE;
562
+ const { label: tagLabel, type, status, statusMsg, } = getPersonalizeTagInfo(tagCode, attributes, errorAttributes);
564
563
  const tagTextNode = tagifyRef.current?.getTagTextNode(tagElement);
565
564
  /*
566
565
  * Just only update to the correct text of the tag
@@ -575,22 +574,14 @@ const TagifyInput = forwardRef((props, ref) => {
575
574
  }
576
575
  // Remove all existing attributes
577
576
  sanitizeTagAttributes(tagElement);
578
- // In case promotion pool has something wrong
579
- if (message) {
580
- if (isRemoved || isArchived || !isActive || isExpired) {
581
- tagElement.setAttribute(ERROR_TAG, 'true');
582
- tagElement.setAttribute(MESSAGE_TAG, message);
583
- }
584
- else if (!canView) {
585
- tagElement.setAttribute(WARNING_TAG, 'true');
586
- tagElement.setAttribute(MESSAGE_TAG, message);
587
- }
588
- else if (!isValid) {
589
- tagElement.setAttribute(READONLY_TAG, 'true');
590
- tagElement.setAttribute(INVALID_TAG, 'true');
591
- tagElement.setAttribute(MESSAGE_TAG, message);
592
- }
593
- }
577
+ // Update new tag attributes
578
+ const tagAttributes = getTagAttributes({
579
+ type: type,
580
+ status,
581
+ statusMsg,
582
+ displayName: tagLabel,
583
+ });
584
+ applyTagAttributes(tagElement, tagAttributes);
594
585
  }
595
586
  }
596
587
  }
@@ -600,7 +591,7 @@ const TagifyInput = forwardRef((props, ref) => {
600
591
  if (!isAccepted)
601
592
  return;
602
593
  const { url, shortener, label } = tagData;
603
- const { label: tagLabel, isValid, message, type: tagType, } = getShortLinkTagInfo({
594
+ const { label: tagLabel, type: tagType, status, statusMsg, } = getShortLinkTagInfo({
604
595
  type,
605
596
  label,
606
597
  shortener,
@@ -617,11 +608,14 @@ const TagifyInput = forwardRef((props, ref) => {
617
608
  tagTextNode.textContent = tagLabel;
618
609
  // Remove all existing attributes
619
610
  sanitizeTagAttributes(tagElement);
620
- // In case promotion pool has something wrong
621
- if (!isValid && message) {
622
- tagElement.setAttribute(ERROR_TAG, 'true');
623
- tagElement.setAttribute(MESSAGE_TAG, message);
624
- }
611
+ // Update new tag attributes
612
+ const tagAttributes = getTagAttributes({
613
+ type: type,
614
+ status,
615
+ statusMsg,
616
+ displayName: tagLabel,
617
+ });
618
+ applyTagAttributes(tagElement, tagAttributes);
625
619
  }
626
620
  }
627
621
  }
@@ -826,7 +820,7 @@ const TagifyInput = forwardRef((props, ref) => {
826
820
  * Need to sync label of the tags if any map attribute is changed to make correct label
827
821
  * */
828
822
  useDeepCompareEffect(() => {
829
- makeValidLabelTags(mapAttributes, mapErrorAttributes, {});
823
+ makeValidLabelTags(mapAttributes, mapErrorAttributes);
830
824
  }, [mapAttributes, mapErrorAttributes, makeValidLabelTags]);
831
825
  useLayoutEffect(() => {
832
826
  if (tagProperties) {
@@ -882,7 +876,7 @@ const TagifyInput = forwardRef((props, ref) => {
882
876
  const content = parseTagStringToTagify(textValue, acceptableTagPattern);
883
877
  tagifyRef.current.loadOriginalValues(content);
884
878
  // Need to sync label of the tags if any map attribute is changed to make correct label
885
- makeValidLabelTags(mapAttributes, mapErrorAttributes, tagProperties);
879
+ makeValidLabelTags(mapAttributes, mapErrorAttributes);
886
880
  }
887
881
  }
888
882
  }, [
@@ -891,7 +885,6 @@ const TagifyInput = forwardRef((props, ref) => {
891
885
  mapErrorAttributes,
892
886
  escapeHTML,
893
887
  acceptableTagPattern,
894
- tagProperties,
895
888
  makeValidLabelTags,
896
889
  ]);
897
890
  useEffect(() => {
@@ -1,14 +1,9 @@
1
- import type { AcceptablePattern, MapAttributesProps, PatterTagName, PatternHandlerWrapper, TagProperties, TagTypeProperty } from './types';
1
+ import type { AcceptablePattern, MapAttributesProps, PatterTagName, PatternHandlerWrapper, TagTypeProperty } from './types';
2
2
  interface TagInfo {
3
3
  label: string;
4
4
  type: string;
5
- isValid: boolean;
6
- message?: string;
7
- isRemoved?: boolean;
8
- canView?: boolean;
9
- isArchived?: boolean;
10
- isActive?: boolean;
11
- isExpired?: boolean;
5
+ status: string;
6
+ statusMsg: string;
12
7
  }
13
8
  /**
14
9
  * Retrieves a cached regular expression or compiles and caches it if not found.
@@ -29,7 +24,7 @@ export declare function acceptablePatternChecking(pattern: AcceptablePattern, ac
29
24
  * @returns {string} The extracted custom tag ID if the tag type is a custom tag; otherwise, empty string.
30
25
  */
31
26
  export declare const getCustomTagId: (tagType: TagTypeProperty, mergeCode: string) => string;
32
- export declare const getPersonalizeTagInfo: (originalTag: string, mapAttributes: MapAttributesProps, mapErrorAttributes: MapAttributesProps, tagProperties: TagProperties) => TagInfo;
27
+ export declare const getPersonalizeTagInfo: (originalTag: string, mapAttributes: MapAttributesProps, mapErrorAttributes: MapAttributesProps) => TagInfo;
33
28
  export declare const getShortLinkTagInfo: (params: {
34
29
  type: string;
35
30
  label: string;
@@ -1,14 +1,14 @@
1
1
  /* eslint-disable no-cond-assign */
2
2
  /* eslint-disable no-console */
3
3
  // Libraries
4
- import { get, has } from 'lodash';
4
+ import { has } from 'lodash';
5
5
  import { translate, translations } from '@antscorp/antsomi-locales';
6
6
  // Utils
7
7
  import { errorWrapper } from './errorWrapper';
8
8
  import { isViberEmoji } from './iconsViber';
9
9
  import { random } from '@antscorp/antsomi-ui/es/utils';
10
10
  // Constants
11
- import { CONTENT_SOURCE_GROUP, EMOJI, EMOJI_COLLECTIONS, LINE_EMOJI_PTN, PERSONALIZE_PTN, PREFIX_PATTERN_LINE_MESSAGE, PROMOTION_CODE, SHORT_LINK, SHORT_LINK_GENERAL_PTN, SHORT_LINK_INDIVIDUAL_PTN, SHORT_LINK_PTN, SHORT_LINK_TYPE, SHORT_LINK_V2, SHORT_LINK_V2_GENERAL_PTN, SHORT_LINK_V2_INDIVIDUAL_PTN, TAG_TYPE, VIBER_EMOJI_PTN, } from './constants';
11
+ import { CONTENT_SOURCE_GROUP, EMOJI, EMOJI_COLLECTIONS, LINE_EMOJI_PTN, PERSONALIZE_PTN, PREFIX_PATTERN_LINE_MESSAGE, PROMOTION_CODE, SHORT_LINK, SHORT_LINK_GENERAL_PTN, SHORT_LINK_INDIVIDUAL_PTN, SHORT_LINK_PTN, SHORT_LINK_TYPE, SHORT_LINK_V2, SHORT_LINK_V2_GENERAL_PTN, SHORT_LINK_V2_INDIVIDUAL_PTN, TAG_STATUS, TAG_TYPE, VIBER_EMOJI_PTN, } from './constants';
12
12
  const { CUSTOM_TAG } = TAG_TYPE;
13
13
  /*
14
14
  * Usage to cache compiled regular expressions:
@@ -244,88 +244,68 @@ const getLabelAttribute = (type, attributeName, subAttributeName, mapAttributes)
244
244
  mapping[combineAttribute]?.template_name ||
245
245
  combineAttribute);
246
246
  };
247
- export const getPersonalizeTagInfo = (originalTag, mapAttributes, mapErrorAttributes, tagProperties) => {
247
+ export const getPersonalizeTagInfo = (originalTag, mapAttributes, mapErrorAttributes) => {
248
248
  try {
249
249
  const [type, attributeName, subAttributeName] = originalTag.split('.');
250
250
  const isCsGroup = type === CONTENT_SOURCE_GROUP;
251
251
  const combineAttribute = subAttributeName
252
252
  ? `${attributeName}.${subAttributeName}`
253
253
  : attributeName;
254
- // Check additional case for each tag type
255
- let [isValid, message, isRemoved, canView, isArchived, isActive, isExpired] = [
256
- true,
257
- '',
258
- false,
259
- true,
260
- false,
261
- true,
262
- false,
263
- ];
264
- if (!has(mapAttributes, type) && !has(tagProperties, attributeName) && !isCsGroup) {
265
- // return fallback if no mapping
266
- return {
267
- type,
268
- label: attributeName || type,
269
- isValid: false,
270
- message: 'This tag does not exist anymore',
271
- isRemoved,
272
- canView,
273
- isArchived,
274
- isActive,
275
- isExpired,
276
- };
277
- }
254
+ let status = '';
255
+ let statusMsg = '';
278
256
  // Get label based on mapping
279
257
  const label = isCsGroup
280
258
  ? getContentSourceLabel(attributeName, subAttributeName, mapAttributes)
281
259
  : getLabelAttribute(type, attributeName, subAttributeName, mapAttributes);
282
- const tagType = type === CUSTOM_TAG ? get(tagProperties, [attributeName, 'type']) : type;
283
- switch (tagType) {
260
+ switch (type) {
284
261
  case PROMOTION_CODE: {
285
- if (has(mapErrorAttributes, [tagType, attributeName])) {
286
- isValid = false;
287
- message = 'This pool does not exist anymore';
262
+ if (has(mapErrorAttributes, [type, attributeName])) {
263
+ status = TAG_STATUS.INVALID;
264
+ statusMsg = 'This pool does not exist anymore';
288
265
  const {
289
266
  // isEdit = false,
290
- isView = false, isExist = true, isArchived: _isArchived = false, isActive: _isActive = true, isExpired: _isExpired = false, } = mapErrorAttributes?.[tagType]?.[attributeName] || {};
267
+ isView = false, isExist = true, isArchived: _isArchived = false, isActive: _isActive = true, isExpired: _isExpired = false, } = mapErrorAttributes?.[type]?.[attributeName] || {};
291
268
  if (!isExist) {
292
269
  // Case Pool Removed
293
- isRemoved = !isExist;
294
- message = translate(translations._PERSONALIZATION_TAG_ERR_REMOVED, 'This pool is removed');
270
+ status = TAG_STATUS.REMOVED;
271
+ statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_REMOVED, 'This pool is removed');
295
272
  }
296
273
  else if (_isArchived) {
297
274
  // Case Pool is Archived
298
- isArchived = true;
299
- message = translate(translations._PERSONALIZATION_TAG_ERR_ATT_ARCHIVE, 'This attribute has been archived');
275
+ status = TAG_STATUS.ARCHIVED;
276
+ statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_ATT_ARCHIVE, 'This attribute has been archived');
300
277
  }
301
278
  else if (!_isActive) {
302
279
  // Case Pool is Inactive
303
- isActive = false;
304
- message = translate(translations._PERSONALIZATION_TAG_ERR_POOL_DEACTIVATE, 'This pool has been deactivated. You have to turn it on to use');
280
+ status = TAG_STATUS.INACTIVE;
281
+ statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_POOL_DEACTIVATE, 'This pool has been deactivated. You have to turn it on to use');
305
282
  }
306
283
  else if (_isExpired) {
307
284
  // Case Pool is Expired
308
- isExpired = true;
309
- message = translate(translations._PERSONALIZATION_TAG_ERR_POOL_EXPIRE, 'This pool has expired, new codes could not be allocated');
285
+ status = TAG_STATUS.EXPIRED;
286
+ statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_POOL_EXPIRE, 'This pool has expired, new codes could not be allocated');
310
287
  }
311
288
  else if (!isView) {
312
289
  // Case Pool Can't View
313
- canView = isView;
314
- message = translate(translations._PERMISSION_ERR_POOL, 'You do not have permission on this pool');
290
+ status = TAG_STATUS.DO_NOT_VIEW;
291
+ statusMsg = translate(translations._PERMISSION_ERR_POOL, 'You do not have permission on this pool');
315
292
  }
316
293
  }
317
294
  // }
318
295
  break;
319
296
  }
297
+ case CUSTOM_TAG: {
298
+ break;
299
+ }
320
300
  default: {
321
- if (has(mapErrorAttributes, [tagType, combineAttribute])) {
322
- isValid = false;
323
- message = 'This attribute does not exist anymore';
324
- const { isArchived: _isArchived = false, isActive: _isActive = true, isExpired: _isExpired = false, } = mapErrorAttributes?.[tagType]?.[combineAttribute] || {};
301
+ if (has(mapErrorAttributes, [type, combineAttribute])) {
302
+ status = TAG_STATUS.ERROR;
303
+ statusMsg = 'This attribute does not exist anymore';
304
+ const { isArchived: _isArchived = false, isActive: _isActive = true, isExpired: _isExpired = false, } = mapErrorAttributes?.[type]?.[combineAttribute] || {};
325
305
  if (_isArchived) {
326
306
  // Case Tag is Archived
327
- isArchived = true;
328
- message = translate(translations._PERSONALIZATION_TAG_ERR_ATT_ARCHIVE, 'This attribute has been archived');
307
+ status = TAG_STATUS.ARCHIVED;
308
+ statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_ATT_ARCHIVE, 'This attribute has been archived');
329
309
  }
330
310
  }
331
311
  break;
@@ -333,39 +313,39 @@ export const getPersonalizeTagInfo = (originalTag, mapAttributes, mapErrorAttrib
333
313
  }
334
314
  return {
335
315
  type,
336
- message,
337
- isValid,
338
316
  label: label || type,
339
- isRemoved,
340
- canView,
341
- isArchived,
342
- isActive,
343
- isExpired,
317
+ status,
318
+ statusMsg,
344
319
  };
345
320
  }
346
321
  catch (error) {
347
322
  console.error('Error in getTagLabel', error);
348
- return { label: originalTag, type: originalTag, isValid: false, isRemoved: false };
323
+ return {
324
+ label: originalTag,
325
+ type: originalTag,
326
+ status: TAG_STATUS.ERROR,
327
+ statusMsg: 'This tag does not exist anymore',
328
+ };
349
329
  }
350
330
  };
351
331
  export const getShortLinkTagInfo = (params) => {
352
332
  const { type, label, url, shortener, mapAttributes, mapErrorAttributes } = params;
353
333
  try {
354
- let [isValid, message] = [true, ''];
334
+ let [status, statusMsg] = ['', ''];
355
335
  switch (type) {
356
336
  case SHORT_LINK_V2:
357
337
  if (mapAttributes && mapAttributes[type]) {
358
338
  const isExistShortLink = has(mapAttributes[type], shortener);
359
339
  if (!isExistShortLink) {
360
- isValid = false;
361
- message = translate(translations?._PER_TAG_LINK_ERR || '', 'This shortener is inactivated or removed');
340
+ status = TAG_STATUS.INVALID;
341
+ statusMsg = translate(translations?._PER_TAG_LINK_ERR || '', 'This shortener is inactivated or removed');
362
342
  if (mapErrorAttributes &&
363
343
  mapErrorAttributes?.[type] &&
364
344
  mapErrorAttributes?.[type]?.[shortener]) {
365
345
  const { isView = true, isExist = true } = mapErrorAttributes[type][shortener] || {};
366
346
  if (!isExist || !isView) {
367
- isValid = false;
368
- message = translate(translations?._PER_TAG_LINK_ERR || '', 'This shortener is inactivated or removed');
347
+ status = TAG_STATUS.REMOVED;
348
+ statusMsg = translate(translations?._PER_TAG_LINK_ERR || '', 'This shortener is inactivated or removed');
369
349
  }
370
350
  }
371
351
  }
@@ -376,9 +356,9 @@ export const getShortLinkTagInfo = (params) => {
376
356
  }
377
357
  return {
378
358
  type,
379
- message,
380
- isValid,
381
359
  label,
360
+ status,
361
+ statusMsg,
382
362
  };
383
363
  }
384
364
  catch (error) {
@@ -386,8 +366,8 @@ export const getShortLinkTagInfo = (params) => {
386
366
  return {
387
367
  label,
388
368
  type,
389
- isValid: false,
390
- message: translate(translations._PER_TAG_LINK_ERR, 'This shortener is inactivated or removed'),
369
+ status: TAG_STATUS.ERROR,
370
+ statusMsg: translate(translations._PER_TAG_LINK_ERR, 'This shortener is inactivated or removed'),
391
371
  };
392
372
  }
393
373
  };
@@ -3,5 +3,4 @@
3
3
  * Asynchronously loads the component for TemplateListing
4
4
  *
5
5
  */
6
- /// <reference types="react" />
7
6
  export declare const TemplateListing: (props: import("./types").TemplateListingProps<{}>) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.982",
3
+ "version": "1.3.5-beta.984",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",