@antscorp/antsomi-ui 1.3.5-beta.785 → 1.3.5-beta.787
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/molecules/TagifyInput/TagifyInput.js +33 -7
- package/es/components/molecules/TagifyInput/constants.d.ts +3 -1
- package/es/components/molecules/TagifyInput/constants.js +3 -1
- package/es/components/molecules/TagifyInput/patternHandlers.js +33 -12
- package/es/components/molecules/TagifyInput/utils.js +10 -2
- package/es/locales/en/google-sheet.json +5 -0
- package/es/locales/i18n.d.ts +15 -0
- package/es/locales/ja/google-sheet.json +1084 -1079
- package/es/locales/vi/google-sheet.json +44 -39
- package/package.json +1 -1
- package/es/components/molecules/TagifyInput/hooks/index.d.ts +0 -1
- package/es/components/molecules/TagifyInput/hooks/index.js +0 -1
- package/es/components/molecules/TagifyInput/hooks/useSettingsTagify.d.ts +0 -7
- package/es/components/molecules/TagifyInput/hooks/useSettingsTagify.js +0 -31
|
@@ -7,7 +7,6 @@ import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks/useDeepCompare
|
|
|
7
7
|
import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounce';
|
|
8
8
|
import { useUpdateEffect } from '@antscorp/antsomi-ui/es/hooks/useUpdateEffect';
|
|
9
9
|
import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks/useDeepCompareEffect';
|
|
10
|
-
import { useSettingsTagify } from './hooks';
|
|
11
10
|
// Components
|
|
12
11
|
import Tagify from '@yaireo/tagify';
|
|
13
12
|
// Css
|
|
@@ -53,6 +52,10 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
53
52
|
selection.removeAllRanges();
|
|
54
53
|
selection.addRange(range);
|
|
55
54
|
}
|
|
55
|
+
// Change data out
|
|
56
|
+
const inputValue = tagifyRef.current.getInputValue();
|
|
57
|
+
const convertedValue = convertInputStringToOriginal(inputValue);
|
|
58
|
+
onChange(convertedValue);
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
58
61
|
// In case add new common tag
|
|
@@ -208,12 +211,29 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
208
211
|
};
|
|
209
212
|
}, [initializeTagify]);
|
|
210
213
|
// Settings some tagify attributes
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
useLayoutEffect(() => {
|
|
215
|
+
if (tagifyRef.current && typeof readonly !== 'undefined') {
|
|
216
|
+
tagifyRef.current.setReadonly(!!readonly);
|
|
217
|
+
}
|
|
218
|
+
}, [readonly]);
|
|
219
|
+
// Set disabled
|
|
220
|
+
useLayoutEffect(() => {
|
|
221
|
+
if (tagifyRef.current && typeof disabled !== 'undefined') {
|
|
222
|
+
tagifyRef.current.setDisabled(!!disabled);
|
|
223
|
+
}
|
|
224
|
+
}, [disabled]);
|
|
225
|
+
// Set placeholder
|
|
226
|
+
useLayoutEffect(() => {
|
|
227
|
+
if (tagifyRef.current && typeof placeholder !== 'undefined') {
|
|
228
|
+
tagifyRef.current.setPlaceholder(placeholder);
|
|
229
|
+
}
|
|
230
|
+
}, [placeholder]);
|
|
231
|
+
// Set max personalize tags
|
|
232
|
+
useLayoutEffect(() => {
|
|
233
|
+
if (tagifyRef.current && typeof maxPersonalizeTags !== 'undefined') {
|
|
234
|
+
tagifyRef.current.settings.maxTags = maxPersonalizeTags;
|
|
235
|
+
}
|
|
236
|
+
}, [maxPersonalizeTags]);
|
|
217
237
|
/*
|
|
218
238
|
* Need to sync label of the tags if any map attribute is changed to make correct label
|
|
219
239
|
* */
|
|
@@ -275,6 +295,12 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
275
295
|
const convertedValue = convertInputStringToOriginal(inputTypeDebounce);
|
|
276
296
|
onChange(convertedValue);
|
|
277
297
|
}, [inputTypeDebounce]);
|
|
298
|
+
// Removes all tags and resets the original input tag's value property if the initial value back to is empty string
|
|
299
|
+
useUpdateEffect(() => {
|
|
300
|
+
if (initialValue === '' && tagifyRef.current) {
|
|
301
|
+
tagifyRef.current.removeAllTags();
|
|
302
|
+
}
|
|
303
|
+
}, [initialValue]);
|
|
278
304
|
useEffect(() => {
|
|
279
305
|
if (!tagifyRef.current?.DOM.scope)
|
|
280
306
|
return;
|
|
@@ -39,8 +39,9 @@ export declare const TAG_TYPE: {
|
|
|
39
39
|
readonly CUSTOM_FN: "custom";
|
|
40
40
|
readonly EMOJI: "emoji";
|
|
41
41
|
readonly SHORT_LINK: "shortlink";
|
|
42
|
+
readonly CONTENT_SOURCE_GROUP: "groups";
|
|
42
43
|
};
|
|
43
|
-
export declare const CUSTOMER: "customer", VISITOR: "visitor", EVENT: "event", PROMOTION_CODE: "promotion_code", CUSTOM_FN: "custom", EMOJI: "emoji", SHORT_LINK: "shortlink", OBJECT_WIDGET: "objectWidget";
|
|
44
|
+
export declare const CUSTOMER: "customer", VISITOR: "visitor", EVENT: "event", PROMOTION_CODE: "promotion_code", CUSTOM_FN: "custom", EMOJI: "emoji", SHORT_LINK: "shortlink", OBJECT_WIDGET: "objectWidget", CONTENT_SOURCE_GROUP: "groups";
|
|
44
45
|
export declare const TAG_COLOR: {
|
|
45
46
|
readonly customer: string | undefined;
|
|
46
47
|
readonly shortlink: string | undefined;
|
|
@@ -49,6 +50,7 @@ export declare const TAG_COLOR: {
|
|
|
49
50
|
readonly promotion_code: "#d8cafe";
|
|
50
51
|
readonly objectWidget: "#cafedd";
|
|
51
52
|
readonly custom: "#bbefbe";
|
|
53
|
+
readonly groups: "#ffdd9f";
|
|
52
54
|
};
|
|
53
55
|
export declare const EMOJI_COLLECTIONS: {
|
|
54
56
|
readonly COMMON: "common";
|
|
@@ -53,8 +53,9 @@ export const TAG_TYPE = {
|
|
|
53
53
|
CUSTOM_FN: 'custom',
|
|
54
54
|
EMOJI: 'emoji',
|
|
55
55
|
SHORT_LINK: 'shortlink',
|
|
56
|
+
CONTENT_SOURCE_GROUP: 'groups',
|
|
56
57
|
};
|
|
57
|
-
export const { CUSTOMER, VISITOR, EVENT, PROMOTION_CODE, CUSTOM_FN, EMOJI, SHORT_LINK, OBJECT_WIDGET, } = TAG_TYPE;
|
|
58
|
+
export const { CUSTOMER, VISITOR, EVENT, PROMOTION_CODE, CUSTOM_FN, EMOJI, SHORT_LINK, OBJECT_WIDGET, CONTENT_SOURCE_GROUP, } = TAG_TYPE;
|
|
58
59
|
export const TAG_COLOR = {
|
|
59
60
|
[CUSTOMER]: globalToken?.blue2,
|
|
60
61
|
[SHORT_LINK]: globalToken?.blue2,
|
|
@@ -63,6 +64,7 @@ export const TAG_COLOR = {
|
|
|
63
64
|
[PROMOTION_CODE]: '#d8cafe',
|
|
64
65
|
[OBJECT_WIDGET]: '#cafedd',
|
|
65
66
|
[CUSTOM_FN]: '#bbefbe',
|
|
67
|
+
[CONTENT_SOURCE_GROUP]: '#ffdd9f',
|
|
66
68
|
};
|
|
67
69
|
export const EMOJI_COLLECTIONS = {
|
|
68
70
|
COMMON: 'common',
|
|
@@ -5,7 +5,7 @@ import { errorWrapper } from './errorWrapper';
|
|
|
5
5
|
import { isViberEmoji } from './iconsViber';
|
|
6
6
|
import { random } from '@antscorp/antsomi-ui/es/utils';
|
|
7
7
|
// Constants
|
|
8
|
-
import { EMOJI, EMOJI_COLLECTIONS, LINE_EMOJI_PTN, PERSONALIZE_PTN, PREFIX_PATTERN_LINE_MESSAGE, SHORT_LINK, SHORT_LINK_GENERAL_PTN, SHORT_LINK_INDIVIDUAL_PTN, SHORT_LINK_PTN, SHORT_LINK_TYPE, VIBER_EMOJI_PTN, } from './constants';
|
|
8
|
+
import { CONTENT_SOURCE_GROUP, EMOJI, EMOJI_COLLECTIONS, LINE_EMOJI_PTN, PERSONALIZE_PTN, PREFIX_PATTERN_LINE_MESSAGE, SHORT_LINK, SHORT_LINK_GENERAL_PTN, SHORT_LINK_INDIVIDUAL_PTN, SHORT_LINK_PTN, SHORT_LINK_TYPE, VIBER_EMOJI_PTN, } from './constants';
|
|
9
9
|
/*
|
|
10
10
|
* Usage to cache compiled regular expressions:
|
|
11
11
|
* const regex = getCachedRegex(pattern, flags);
|
|
@@ -40,19 +40,38 @@ export function validateURL(txt) {
|
|
|
40
40
|
}
|
|
41
41
|
export const getPersonalizeTagInfo = (originalTag, mapAttributes) => {
|
|
42
42
|
try {
|
|
43
|
-
const [type, attributeName] = originalTag.split('.');
|
|
44
|
-
|
|
43
|
+
const [type, attributeName, subAttributeName] = originalTag.split('.');
|
|
44
|
+
const isCsGroup = type === CONTENT_SOURCE_GROUP;
|
|
45
|
+
let label = attributeName || type;
|
|
46
|
+
if (!mapAttributes || (!mapAttributes[type] && !isCsGroup)) {
|
|
45
47
|
// return fallback if no mapping
|
|
46
|
-
return { type, label
|
|
48
|
+
return { type, label };
|
|
49
|
+
}
|
|
50
|
+
// Check if it is a content source tag
|
|
51
|
+
if (isCsGroup) {
|
|
52
|
+
const csRegex = getCachedRegex('^([^\\[]+)', 'g', 'cs_group_Regex');
|
|
53
|
+
const match = attributeName.match(csRegex);
|
|
54
|
+
if (match) {
|
|
55
|
+
const csGroupId = match[0];
|
|
56
|
+
const mapping = mapAttributes[csGroupId];
|
|
57
|
+
label =
|
|
58
|
+
mapping[subAttributeName]?.display ||
|
|
59
|
+
mapping[subAttributeName]?.label ||
|
|
60
|
+
subAttributeName;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const mapping = mapAttributes[type];
|
|
65
|
+
label =
|
|
66
|
+
mapping[attributeName]?.label ||
|
|
67
|
+
mapping[attributeName]?.display ||
|
|
68
|
+
mapping[attributeName]?.template_name ||
|
|
69
|
+
mapping[attributeName]?.value ||
|
|
70
|
+
type;
|
|
47
71
|
}
|
|
48
|
-
const mapping = mapAttributes[type];
|
|
49
72
|
return {
|
|
50
73
|
type,
|
|
51
|
-
label:
|
|
52
|
-
mapping[attributeName]?.display ||
|
|
53
|
-
mapping[attributeName]?.template_name ||
|
|
54
|
-
mapping[attributeName]?.value ||
|
|
55
|
-
type,
|
|
74
|
+
label: label || type,
|
|
56
75
|
};
|
|
57
76
|
}
|
|
58
77
|
catch (error) {
|
|
@@ -143,14 +162,16 @@ const handleLinePattern = match => {
|
|
|
143
162
|
const handlePersonalizeTagPattern = match => {
|
|
144
163
|
const [personalizeTag, personalizeContent] = match;
|
|
145
164
|
const [tagCode] = personalizeContent.split('||');
|
|
146
|
-
const [type, attributeName] = tagCode.split('.');
|
|
165
|
+
const [type, attributeName, subAttributeName] = tagCode.split('.');
|
|
147
166
|
if (!tagCode || !type) {
|
|
148
167
|
console.error('Invalid personalize pattern detected: ', tagCode);
|
|
149
168
|
return { isValid: false, tag: '[[Invalid Personalize]]' };
|
|
150
169
|
}
|
|
170
|
+
const isContentSourceTag = type === CONTENT_SOURCE_GROUP;
|
|
171
|
+
const label = isContentSourceTag && subAttributeName ? subAttributeName : attributeName || type;
|
|
151
172
|
const tag = createTagPattern({
|
|
173
|
+
label,
|
|
152
174
|
type: type,
|
|
153
|
-
label: attributeName || type,
|
|
154
175
|
value: personalizeTag,
|
|
155
176
|
});
|
|
156
177
|
return { isValid: true, tag };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import stringReplaceToArray from 'string-replace-to-array';
|
|
3
3
|
// Constants
|
|
4
|
-
import { CUSTOMER, CUSTOM_FN, EMOJI, EMOJI_COLLECTIONS, EVENT, OBJECT_WIDGET, PREFIX_PATTERN_LINE_MESSAGE, PROMOTION_CODE, TAG_COLOR, TAG_TYPE, VISITOR, } from './constants';
|
|
4
|
+
import { CONTENT_SOURCE_GROUP, CUSTOMER, CUSTOM_FN, EMOJI, EMOJI_COLLECTIONS, EVENT, OBJECT_WIDGET, PREFIX_PATTERN_LINE_MESSAGE, PROMOTION_CODE, TAG_COLOR, TAG_TYPE, VISITOR, } from './constants';
|
|
5
5
|
import { iconsViber } from './iconsViber';
|
|
6
6
|
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
7
7
|
// Utils
|
|
@@ -327,7 +327,15 @@ export const getStyledTags = () => {
|
|
|
327
327
|
});
|
|
328
328
|
return styledTags.join('');
|
|
329
329
|
};
|
|
330
|
-
export const isPersonalizeTagType = (type) => [
|
|
330
|
+
export const isPersonalizeTagType = (type) => [
|
|
331
|
+
CUSTOMER,
|
|
332
|
+
VISITOR,
|
|
333
|
+
EVENT,
|
|
334
|
+
PROMOTION_CODE,
|
|
335
|
+
OBJECT_WIDGET,
|
|
336
|
+
CUSTOM_FN,
|
|
337
|
+
CONTENT_SOURCE_GROUP,
|
|
338
|
+
].includes(type);
|
|
331
339
|
export const getBackgroundInputStatus = (status) => {
|
|
332
340
|
switch (status) {
|
|
333
341
|
case 'error':
|
|
@@ -758,6 +758,11 @@
|
|
|
758
758
|
"_NOTI_INVALID_DATE_FORMAT": "Invalid Date Format",
|
|
759
759
|
"_NOTI_INVALID_NAME": "Invalid field",
|
|
760
760
|
"_NOTI_INVALID_URL": "Invalid URL",
|
|
761
|
+
"_NOTI_INVALID_DOMAIN_1": "Please enter a valid domain, including a top-level domain (e.g., .com, .net, .vn)",
|
|
762
|
+
"_NOTI_INVALID_DOMAIN_2": "Only letters (a-z), numbers (0-9), hyphens (-), and dots (.) are allowed",
|
|
763
|
+
"_NOTI_INVALID_COOKIE_1": "The Cookie Domain must not end with a special character",
|
|
764
|
+
"_NOTI_INVALID_COOKIE_2": "The Cookie Domain must be a part of the entered domain",
|
|
765
|
+
"_NOTI_EMPTY": "This field can’t be empty",
|
|
761
766
|
"_NOTI_JOURNEY_NOT_FOUND": "Journey Not Found",
|
|
762
767
|
"_NOTI_MAXIMUM_COLUMN_SET": "You can save a maximum of 15 column sets",
|
|
763
768
|
"_NOTI_MAXIMUM_FILE_SIZE_ICON": "Please select a file less than {{fileSize}} MB, please try again",
|
package/es/locales/i18n.d.ts
CHANGED
|
@@ -760,6 +760,11 @@ export declare const translationsJson: {
|
|
|
760
760
|
_NOTI_INVALID_DATE_FORMAT: string;
|
|
761
761
|
_NOTI_INVALID_NAME: string;
|
|
762
762
|
_NOTI_INVALID_URL: string;
|
|
763
|
+
_NOTI_INVALID_DOMAIN_1: string;
|
|
764
|
+
_NOTI_INVALID_DOMAIN_2: string;
|
|
765
|
+
_NOTI_INVALID_COOKIE_1: string;
|
|
766
|
+
_NOTI_INVALID_COOKIE_2: string;
|
|
767
|
+
_NOTI_EMPTY: string;
|
|
763
768
|
_NOTI_JOURNEY_NOT_FOUND: string;
|
|
764
769
|
_NOTI_MAXIMUM_COLUMN_SET: string;
|
|
765
770
|
_NOTI_MAXIMUM_FILE_SIZE_ICON: string;
|
|
@@ -4091,6 +4096,11 @@ export declare const translationsJson: {
|
|
|
4091
4096
|
_NOTI_INVALID_DATE_FORMAT: string;
|
|
4092
4097
|
_NOTI_INVALID_NAME: string;
|
|
4093
4098
|
_NOTI_INVALID_URL: string;
|
|
4099
|
+
_NOTI_INVALID_DOMAIN_1: string;
|
|
4100
|
+
_NOTI_INVALID_DOMAIN_2: string;
|
|
4101
|
+
_NOTI_INVALID_COOKIE_1: string;
|
|
4102
|
+
_NOTI_INVALID_COOKIE_2: string;
|
|
4103
|
+
_NOTI_EMPTY: string;
|
|
4094
4104
|
_NOTI_JOURNEY_NOT_FOUND: string;
|
|
4095
4105
|
_NOTI_MAXIMUM_COLUMN_SET: string;
|
|
4096
4106
|
_NOTI_MAXIMUM_FILE_SIZE_ICON: string;
|
|
@@ -6972,6 +6982,11 @@ export declare const translationsJson: {
|
|
|
6972
6982
|
_NOTI_INVALID_DATE_FORMAT: string;
|
|
6973
6983
|
_NOTI_INVALID_NAME: string;
|
|
6974
6984
|
_NOTI_INVALID_URL: string;
|
|
6985
|
+
_NOTI_INVALID_DOMAIN_1: string;
|
|
6986
|
+
_NOTI_INVALID_DOMAIN_2: string;
|
|
6987
|
+
_NOTI_INVALID_COOKIE_1: string;
|
|
6988
|
+
_NOTI_INVALID_COOKIE_2: string;
|
|
6989
|
+
_NOTI_EMPTY: string;
|
|
6975
6990
|
_NOTI_JOURNEY_NOT_FOUND: string;
|
|
6976
6991
|
_NOTI_MAXIMUM_COLUMN_SET: string;
|
|
6977
6992
|
_NOTI_MAXIMUM_FILE_SIZE_ICON: string;
|