@antscorp/antsomi-ui 1.3.3-beta.71 → 1.3.3-beta.72
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.
|
@@ -15,6 +15,8 @@ import { getObjectPropSafely, random, safeParse } from '@antscorp/antsomi-ui/es/
|
|
|
15
15
|
import { convertBreakTag, convertDivToBreakTag, convertHtmlText, genShortLinkValue, getInsertLinkPatternWithAppendSpaceEnd, getInsertPatternWithAppendSpaceEnd, handleUpdateInputPersonalization, initialValue, mapLabelPersonalization, pasteHtmlAtCaret, removeHtmlTag, spacingNonTracking, validateHTMLTags, createElement, getBgColorByContentSourceType, } from './utils';
|
|
16
16
|
// Hooks
|
|
17
17
|
import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounce';
|
|
18
|
+
// Constants
|
|
19
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
18
20
|
const PATH = 'src/components/atoms/InputDynamic/InputDynamic.tsx';
|
|
19
21
|
export const AllowDynamicType = {
|
|
20
22
|
SHORTLINK: 'shortlink',
|
|
@@ -32,6 +34,7 @@ const defaultProps = {
|
|
|
32
34
|
accountId: '1600085679',
|
|
33
35
|
userId: '1600085679',
|
|
34
36
|
},
|
|
37
|
+
disabled: false,
|
|
35
38
|
showIndex: true,
|
|
36
39
|
showDisplayFormat: true,
|
|
37
40
|
isShowCustomFunction: true,
|
|
@@ -40,7 +43,7 @@ const defaultProps = {
|
|
|
40
43
|
addMessageToQueue: () => { },
|
|
41
44
|
};
|
|
42
45
|
export const InputDynamic = (props) => {
|
|
43
|
-
const { value, isViewMode, errors, disabledOpts, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
|
|
46
|
+
const { value, isViewMode, errors, disabledOpts, disabled, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
|
|
44
47
|
// States
|
|
45
48
|
const [textValue, setTextValue] = useState(initialValue(value));
|
|
46
49
|
const [initSelectedProperties, setInitSelectedProperties] = useState({
|
|
@@ -125,6 +128,8 @@ export const InputDynamic = (props) => {
|
|
|
125
128
|
setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { visible: newChange })));
|
|
126
129
|
}, []);
|
|
127
130
|
const handleOpenChange = (newOpen) => {
|
|
131
|
+
if (disabled)
|
|
132
|
+
return;
|
|
128
133
|
setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: '' })));
|
|
129
134
|
setIsShowPopover(newOpen);
|
|
130
135
|
};
|
|
@@ -433,6 +438,7 @@ export const InputDynamic = (props) => {
|
|
|
433
438
|
return allowDynamicOptions.map((dynamicKey) => (React.createElement(DynamicItem, { key: dynamicKey, onClick: e => handleClickDynamicItem(e, dynamicKey) }, mapLabelPersonalization(dynamicKey))));
|
|
434
439
|
};
|
|
435
440
|
const renderAddPersonalizationView = () => {
|
|
441
|
+
var _a, _b;
|
|
436
442
|
if (isViewMode) {
|
|
437
443
|
return null;
|
|
438
444
|
}
|
|
@@ -442,15 +448,25 @@ export const InputDynamic = (props) => {
|
|
|
442
448
|
const hasOnlyShortlink = isOnlyOneOpt && (allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.includes(AllowDynamicType.SHORTLINK));
|
|
443
449
|
const iconPersonalization = (React.createElement(Icon, { type: "icon-ants-person-alt", onClick: e => {
|
|
444
450
|
e.stopPropagation();
|
|
451
|
+
if (disabled || isRenderPopover)
|
|
452
|
+
return;
|
|
445
453
|
// Open short link modal
|
|
446
454
|
if (hasOnlyShortlink) {
|
|
447
455
|
toggleShortLinkModal();
|
|
448
456
|
}
|
|
449
|
-
|
|
450
|
-
|
|
457
|
+
else if (hasOnlyPersonalization) {
|
|
458
|
+
// Open Personalization modal
|
|
451
459
|
setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: '', visible: true })));
|
|
452
460
|
}
|
|
453
|
-
|
|
461
|
+
else {
|
|
462
|
+
toggleShortLinkModal();
|
|
463
|
+
}
|
|
464
|
+
}, className: "customize-antsomi-profile", style: {
|
|
465
|
+
width: 24,
|
|
466
|
+
height: 24,
|
|
467
|
+
color: disabled ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorTextDisabled : (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorPrimary,
|
|
468
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
469
|
+
} }));
|
|
454
470
|
if (!isRenderPopover) {
|
|
455
471
|
return iconPersonalization;
|
|
456
472
|
}
|