@antscorp/antsomi-ui 1.3.5-beta.784 → 1.3.5-beta.785
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/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +0 -1
- package/es/components/molecules/TagifyInput/TagifyInput.js +15 -3
- package/es/components/molecules/TagifyInput/hooks/useSettingsTagify.js +3 -2
- package/es/components/molecules/TagifyInput/styled.d.ts +2 -1
- package/es/components/molecules/TagifyInput/styled.js +2 -2
- package/es/components/molecules/TagifyInput/types.d.ts +2 -0
- package/es/components/molecules/TagifyInput/utils.d.ts +2 -1
- package/es/components/molecules/TagifyInput/utils.js +14 -0
- package/es/components/template/TemplateListing/Loadable.d.ts +0 -1
- package/es/locales/en/google-sheet.json +1 -1
- package/es/locales/ja/google-sheet.json +1043 -1043
- package/es/locales/vi/google-sheet.json +38 -38
- package/package.json +1 -1
|
@@ -21,8 +21,7 @@ import { acceptablePatternChecking, getCachedRegex, getPersonalizeTagInfo, patte
|
|
|
21
21
|
import { EMOJI, PERSONALIZE_PTN, SHORT_LINK, defaultCssVariables, tagifyDefaultProps, } from './constants';
|
|
22
22
|
const TagifyInput = forwardRef((props, ref) => {
|
|
23
23
|
// Props
|
|
24
|
-
const { initialValue, readonly, disabled, maxLength, placeholder, acceptableTagPattern, mapAttributes, maxPersonalizeTags, name, children, cssTagifyVariables, onTagClick, onChange, } = props;
|
|
25
|
-
console.count('------------ re-render ------------');
|
|
24
|
+
const { initialValue, status, readonly, disabled, maxLength, placeholder, acceptableTagPattern, mapAttributes, maxPersonalizeTags, name, children, cssTagifyVariables, onTagClick, onChange, } = props;
|
|
26
25
|
// States
|
|
27
26
|
const [inputTypeDebounce, , setInputTyping] = useDebounce(initialValue, 450);
|
|
28
27
|
// Refs
|
|
@@ -86,10 +85,23 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
86
85
|
// Check readonly
|
|
87
86
|
if (readonly)
|
|
88
87
|
return;
|
|
88
|
+
const currentTagData = tagifyRef.current.getSetTagData(currentTagEle);
|
|
89
|
+
const currentTagValue = currentTagData?.value;
|
|
90
|
+
const newTagValue = newTag.value;
|
|
91
|
+
const spaceEle = tagifyRef.current.insertAfterTag(currentTagEle, '\u00A0'); // <- adds space after the tag to keep valid caret positioning
|
|
89
92
|
tagifyRef.current.replaceTag(currentTagEle, newTag);
|
|
93
|
+
// Only update data if value is changed
|
|
94
|
+
if (currentTagValue !== newTagValue) {
|
|
95
|
+
// Change data out
|
|
96
|
+
const inputValue = tagifyRef.current.getInputValue();
|
|
97
|
+
const convertedValue = convertInputStringToOriginal(inputValue);
|
|
98
|
+
onChange(convertedValue);
|
|
99
|
+
}
|
|
100
|
+
tagifyRef.current.placeCaretAfterNode(spaceEle); // <- restore the caret after the edited tag
|
|
90
101
|
}
|
|
91
102
|
},
|
|
92
103
|
}), [onChange]);
|
|
104
|
+
console.log('tagifyRef', tagifyRef);
|
|
93
105
|
const onTagItemClick = useCallback((event) => {
|
|
94
106
|
if (event.detail && onTagClick) {
|
|
95
107
|
const { tagify } = event.detail;
|
|
@@ -291,7 +303,7 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
291
303
|
}
|
|
292
304
|
};
|
|
293
305
|
}, []);
|
|
294
|
-
return (_jsxs(TagifyWrapper, { ref: tagifyWrapperRef, "$cssTagifyVariables": cssVariablesMemoized, className: "tagify-container", id: "tagify-container", "data-test": "tagify-wrapper", children: [_jsx(TagTextArea, { id: "tagify-textarea", ref: inputRef, name: name, defaultValue: parsedDefaultValue, "data-test": "tagify-input" }), _jsx(WrapperPlaceHolder, { ref: placeHolderRef, "$isShow": !!children, children: children })] }));
|
|
306
|
+
return (_jsxs(TagifyWrapper, { ref: tagifyWrapperRef, "$cssTagifyVariables": cssVariablesMemoized, className: "tagify-container", id: "tagify-container", "data-test": "tagify-wrapper", "$status": status, children: [_jsx(TagTextArea, { id: "tagify-textarea", ref: inputRef, name: name, defaultValue: parsedDefaultValue, "data-test": "tagify-input" }), _jsx(WrapperPlaceHolder, { ref: placeHolderRef, "$isShow": !!children, children: children })] }));
|
|
295
307
|
});
|
|
296
308
|
TagifyInput.defaultProps = tagifyDefaultProps;
|
|
297
309
|
export default memo(TagifyInput);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
2
|
// Libraries
|
|
3
|
-
import { useLayoutEffect } from 'react';
|
|
3
|
+
import { useEffect, useLayoutEffect } from 'react';
|
|
4
4
|
export const useSettingsTagify = (tagifyInstance, settings) => {
|
|
5
5
|
const { readonly, disabled, placeholder, maxPersonalizeTags } = settings;
|
|
6
6
|
// Set read only
|
|
7
|
-
|
|
7
|
+
useEffect(() => {
|
|
8
8
|
if (tagifyInstance && typeof readonly !== 'undefined') {
|
|
9
9
|
tagifyInstance.setReadonly(readonly);
|
|
10
|
+
console.log('newReadonly', readonly, tagifyInstance);
|
|
10
11
|
}
|
|
11
12
|
}, [readonly]);
|
|
12
13
|
// Set disabled
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { TagifyInputProps } from './types';
|
|
1
|
+
import type { StatusType, TagifyInputProps } from './types';
|
|
2
2
|
export declare const WrapperPlaceHolder: import("styled-components").StyledComponent<"div", any, {
|
|
3
3
|
$isShow?: boolean | undefined;
|
|
4
4
|
}, never>;
|
|
5
5
|
export declare const TagifyWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
6
6
|
$cssTagifyVariables?: TagifyInputProps['cssTagifyVariables'];
|
|
7
|
+
$status?: StatusType | undefined;
|
|
7
8
|
}, never>;
|
|
8
9
|
export declare const TagInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
9
10
|
export declare const TagTextArea: import("styled-components").StyledComponent<"textarea", any, {}, never>;
|
|
@@ -4,7 +4,7 @@ import styled, { css } from 'styled-components';
|
|
|
4
4
|
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
5
5
|
import { MIN_H_WRAPPER, TAG_H } from './constants';
|
|
6
6
|
// Utils
|
|
7
|
-
import { getStyledTags } from './utils';
|
|
7
|
+
import { getBackgroundInputStatus, getStyledTags } from './utils';
|
|
8
8
|
export const WrapperPlaceHolder = styled.div `
|
|
9
9
|
${({ $isShow }) => $isShow
|
|
10
10
|
? css `
|
|
@@ -17,7 +17,7 @@ export const WrapperPlaceHolder = styled.div `
|
|
|
17
17
|
`;
|
|
18
18
|
export const TagifyWrapper = styled.div `
|
|
19
19
|
background: ${globalToken?.bw0};
|
|
20
|
-
border-bottom: 1px solid ${
|
|
20
|
+
border-bottom: 1px solid ${({ $status }) => getBackgroundInputStatus($status)};
|
|
21
21
|
min-height: ${MIN_H_WRAPPER}px;
|
|
22
22
|
width: 100%;
|
|
23
23
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { ClassNameSettings, TagData, TagifySettings } from '@yaireo/tagify';
|
|
4
4
|
import { EMOJI_COLLECTIONS, PATTERN_CACHE_TYPE, SHORT_LINK_TYPE, TAG_TYPE } from './constants';
|
|
5
5
|
export type MapAttributesProps = Record<string, Record<string, any>>;
|
|
6
|
+
export type StatusType = 'error' | 'success' | 'warning';
|
|
6
7
|
/**
|
|
7
8
|
* Interface defining the properties for the Tagify input component.
|
|
8
9
|
* Provides configuration options and event handlers to manage Tagify's behavior and appearance.
|
|
@@ -37,6 +38,7 @@ export interface TagifyInputProps {
|
|
|
37
38
|
* Helps enforce constraints by limiting the number of tags a user can input.
|
|
38
39
|
*/
|
|
39
40
|
maxPersonalizeTags?: TagifySettings['maxTags'];
|
|
41
|
+
status?: StatusType;
|
|
40
42
|
/**
|
|
41
43
|
* Defines acceptable patterns or validation rules for tags.
|
|
42
44
|
* Ensures only tags matching specified patterns can be added, enforcing content rules.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AcceptablePattern, EmojiCollection, EmojiTag, TagType } from './types';
|
|
1
|
+
import { AcceptablePattern, EmojiCollection, EmojiTag, StatusType, TagType } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Parses the input string and replaces matching patterns with processed tags.
|
|
4
4
|
* This function iterates over predefined regex patterns and replaces each match
|
|
@@ -45,3 +45,4 @@ export declare const emojiManufacturer: (text: string, collectionType: EmojiColl
|
|
|
45
45
|
export declare const getEmojiTag: ({ src, emoji, code }: EmojiTag) => string;
|
|
46
46
|
export declare const getStyledTags: () => string;
|
|
47
47
|
export declare const isPersonalizeTagType: (type: TagType) => boolean;
|
|
48
|
+
export declare const getBackgroundInputStatus: (status?: StatusType) => string;
|
|
@@ -3,6 +3,7 @@ import stringReplaceToArray from 'string-replace-to-array';
|
|
|
3
3
|
// Constants
|
|
4
4
|
import { 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
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
6
7
|
// Utils
|
|
7
8
|
import { acceptablePatternChecking, getCachedRegex, patternHandlers, tagRegexStringPattern, } from './patternHandlers';
|
|
8
9
|
/**
|
|
@@ -327,3 +328,16 @@ export const getStyledTags = () => {
|
|
|
327
328
|
return styledTags.join('');
|
|
328
329
|
};
|
|
329
330
|
export const isPersonalizeTagType = (type) => [CUSTOMER, VISITOR, EVENT, PROMOTION_CODE, OBJECT_WIDGET, CUSTOM_FN].includes(type);
|
|
331
|
+
export const getBackgroundInputStatus = (status) => {
|
|
332
|
+
switch (status) {
|
|
333
|
+
case 'error':
|
|
334
|
+
return globalToken?.colorError || '#EF3340';
|
|
335
|
+
case 'warning':
|
|
336
|
+
return globalToken?.colorWarning || '#faad14';
|
|
337
|
+
case 'success':
|
|
338
|
+
return globalToken?.colorSuccess || '#12B800';
|
|
339
|
+
default: {
|
|
340
|
+
return globalToken?.blue1 || '#B8CFE6';
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
@@ -2642,5 +2642,5 @@
|
|
|
2642
2642
|
"_COOKIE_DM_INSTRUCTION_1_DES_1": "This is the base domain for all subdomains you want to track. ",
|
|
2643
2643
|
"_COOKIE_DM_INSTRUCTION_1_DES_2": "Example: {{x}}",
|
|
2644
2644
|
"_COOKIE_DM_INSTRUCTION_2_SUM": "Configure the Cookie Domain:",
|
|
2645
|
-
"_COOKIE_DM_INSTRUCTION_2_DES_1": "Input {{x}} to track data across all subdomains (eg:
|
|
2645
|
+
"_COOKIE_DM_INSTRUCTION_2_DES_1": "Input {{x}} to track data across all subdomains (eg: {{y}} or {{y}})"
|
|
2646
2646
|
}
|