@antscorp/antsomi-ui 1.3.3-beta.69 → 1.3.3-beta.70

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.
Files changed (134) hide show
  1. package/es/components/atoms/InputDynamic/InputDynamic.d.ts +5 -25
  2. package/es/components/atoms/InputDynamic/InputDynamic.js +200 -16
  3. package/es/components/atoms/InputDynamic/PopupShortLink.d.ts +1 -1
  4. package/es/components/atoms/InputDynamic/constants.d.ts +71 -0
  5. package/es/components/atoms/InputDynamic/constants.js +71 -0
  6. package/es/components/atoms/InputDynamic/index.d.ts +1 -1
  7. package/es/components/atoms/InputDynamic/styled.d.ts +1 -0
  8. package/es/components/atoms/InputDynamic/styled.js +14 -2
  9. package/es/components/atoms/InputDynamic/types.d.ts +110 -0
  10. package/es/components/atoms/InputDynamic/types.js +1 -0
  11. package/es/components/atoms/InputDynamic/utils.d.ts +8 -0
  12. package/es/components/atoms/InputDynamic/utils.js +123 -2
  13. package/es/components/atoms/Spin/styled.d.ts +1 -1
  14. package/es/components/common/ConfigProvider/GlobalStyle.js +10 -0
  15. package/es/components/molecules/AddDynamicContent/AddDynamicContent.d.ts +35 -0
  16. package/es/components/molecules/AddDynamicContent/AddDynamicContent.js +1245 -0
  17. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +12 -0
  18. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.js +25 -0
  19. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/index.d.ts +3 -0
  20. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/index.js +3 -0
  21. package/es/components/molecules/AddDynamicContent/components/FormatDatetime/FormatDatetime.d.ts +19 -0
  22. package/es/components/molecules/AddDynamicContent/components/FormatDatetime/FormatDatetime.js +101 -0
  23. package/es/components/molecules/AddDynamicContent/components/FormatDatetime/index.d.ts +1 -0
  24. package/es/components/molecules/AddDynamicContent/components/FormatDatetime/index.js +1 -0
  25. package/es/components/molecules/AddDynamicContent/components/FormatNumber/FormatNumber.d.ts +52 -0
  26. package/es/components/molecules/AddDynamicContent/components/FormatNumber/FormatNumber.js +132 -0
  27. package/es/components/molecules/AddDynamicContent/components/FormatNumber/index.d.ts +1 -0
  28. package/es/components/molecules/AddDynamicContent/components/FormatNumber/index.js +1 -0
  29. package/es/components/molecules/AddDynamicContent/components/index.d.ts +3 -0
  30. package/es/components/molecules/AddDynamicContent/components/index.js +3 -0
  31. package/es/components/molecules/AddDynamicContent/constants.d.ts +101 -0
  32. package/es/components/molecules/AddDynamicContent/constants.js +152 -0
  33. package/es/components/molecules/AddDynamicContent/currencies.json +1523 -0
  34. package/es/components/molecules/AddDynamicContent/index.d.ts +2 -0
  35. package/es/components/molecules/AddDynamicContent/index.js +2 -0
  36. package/es/components/molecules/AddDynamicContent/styled.d.ts +9 -0
  37. package/es/components/molecules/AddDynamicContent/styled.js +18 -0
  38. package/es/components/molecules/AddDynamicContent/types.d.ts +13 -0
  39. package/es/components/molecules/AddDynamicContent/types.js +1 -0
  40. package/es/components/molecules/AddDynamicContent/utils.d.ts +42 -0
  41. package/es/components/molecules/AddDynamicContent/utils.js +398 -0
  42. package/es/components/molecules/Modal/Modal.d.ts +2 -2
  43. package/es/components/molecules/Modal/styled.d.ts +1 -1
  44. package/es/components/molecules/Modal/styled.js +2 -0
  45. package/es/components/molecules/ModalV2/styled.d.ts +1 -1
  46. package/es/components/molecules/Select/Select.d.ts +2 -4
  47. package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/styled.d.ts +1 -1
  48. package/es/components/molecules/TreeSelect/TreeSelect.d.ts +3 -5
  49. package/es/components/molecules/UploadImage/MediaThumb.d.ts +11 -0
  50. package/es/components/molecules/UploadImage/MediaThumb.js +31 -0
  51. package/es/components/molecules/UploadImage/index.d.ts +6 -2
  52. package/es/components/molecules/UploadImage/index.js +101 -77
  53. package/es/components/molecules/UploadImage/styled.js +0 -4
  54. package/es/components/molecules/UploadImage/utils.d.ts +3 -0
  55. package/es/components/molecules/UploadImage/utils.js +24 -0
  56. package/es/components/organism/Help/styled.d.ts +2 -6
  57. package/es/constants/queries.d.ts +14 -0
  58. package/es/constants/queries.js +21 -0
  59. package/es/hooks/index.d.ts +1 -0
  60. package/es/hooks/index.js +1 -0
  61. package/es/hooks/useDeepCompareMemo.d.ts +2 -0
  62. package/es/hooks/useDeepCompareMemo.js +21 -0
  63. package/es/locales/en/translation.json +151 -0
  64. package/es/locales/i18n.d.ts +151 -0
  65. package/es/locales/translations.d.ts +151 -0
  66. package/es/models/BusinessObject.d.ts +116 -0
  67. package/es/models/BusinessObject.js +113 -0
  68. package/es/models/Currency.d.ts +9 -0
  69. package/es/models/Currency.js +10 -0
  70. package/es/models/CustomFunction.d.ts +19 -0
  71. package/es/models/CustomFunction.js +25 -0
  72. package/es/models/DynamicContentAttribute.d.ts +34 -0
  73. package/es/models/DynamicContentAttribute.js +9 -0
  74. package/es/models/EventTrackingAttribute.d.ts +11 -0
  75. package/es/models/EventTrackingAttribute.js +13 -0
  76. package/es/models/PromotionPool.d.ts +11 -0
  77. package/es/models/PromotionPool.js +12 -0
  78. package/es/models/{SavedImage.d.ts → SavedMedia.d.ts} +5 -5
  79. package/es/models/{SavedImage.js → SavedMedia.js} +3 -3
  80. package/es/queries/BusinessObject/index.d.ts +6 -0
  81. package/es/queries/BusinessObject/index.js +6 -0
  82. package/es/queries/BusinessObject/useGetListAllEvents.d.ts +11 -0
  83. package/es/queries/BusinessObject/useGetListAllEvents.js +14 -0
  84. package/es/queries/BusinessObject/useGetListAttributeBO.d.ts +17 -0
  85. package/es/queries/BusinessObject/useGetListAttributeBO.js +41 -0
  86. package/es/queries/BusinessObject/useGetListBO.d.ts +6 -0
  87. package/es/queries/BusinessObject/useGetListBO.js +19 -0
  88. package/es/queries/BusinessObject/useGetListEventAttr.d.ts +4 -0
  89. package/es/queries/BusinessObject/useGetListEventAttr.js +15 -0
  90. package/es/queries/BusinessObject/useGetListPromotionCodeAttr.d.ts +6 -0
  91. package/es/queries/BusinessObject/useGetListPromotionCodeAttr.js +26 -0
  92. package/es/queries/BusinessObject/useGetListSourceByEvent.d.ts +13 -0
  93. package/es/queries/BusinessObject/useGetListSourceByEvent.js +11 -0
  94. package/es/queries/CustomFunction/index.d.ts +2 -0
  95. package/es/queries/CustomFunction/index.js +2 -0
  96. package/es/queries/CustomFunction/useCustomFunction.d.ts +19 -0
  97. package/es/queries/CustomFunction/useCustomFunction.js +53 -0
  98. package/es/queries/DynamicContentAttribute/index.d.ts +1 -0
  99. package/es/queries/DynamicContentAttribute/index.js +1 -0
  100. package/es/queries/DynamicContentAttribute/useGetDynamicContentAttr.d.ts +10 -0
  101. package/es/queries/DynamicContentAttribute/useGetDynamicContentAttr.js +21 -0
  102. package/es/queries/PromotionPool/index.d.ts +1 -0
  103. package/es/queries/PromotionPool/index.js +1 -0
  104. package/es/queries/PromotionPool/useGetListPromotionPool.d.ts +9 -0
  105. package/es/queries/PromotionPool/useGetListPromotionPool.js +62 -0
  106. package/es/queries/ThirdParty/index.d.ts +1 -0
  107. package/es/queries/ThirdParty/index.js +1 -0
  108. package/es/queries/ThirdParty/useGetEventTrackingAttributes.d.ts +14 -0
  109. package/es/queries/ThirdParty/useGetEventTrackingAttributes.js +15 -0
  110. package/es/queries/configs.d.ts +4 -0
  111. package/es/queries/configs.js +13 -0
  112. package/es/queries/index.d.ts +6 -0
  113. package/es/queries/index.js +6 -0
  114. package/es/services/MediaTemplateDesign/BusinessObject/index.d.ts +8 -0
  115. package/es/services/MediaTemplateDesign/BusinessObject/index.js +100 -0
  116. package/es/services/MediaTemplateDesign/CustomFunction/index.d.ts +15 -0
  117. package/es/services/MediaTemplateDesign/CustomFunction/index.js +135 -0
  118. package/es/services/MediaTemplateDesign/DynamicContentAttribute/index.d.ts +4 -0
  119. package/es/services/MediaTemplateDesign/DynamicContentAttribute/index.js +39 -0
  120. package/es/services/MediaTemplateDesign/ListCurrency/index.d.ts +6 -0
  121. package/es/services/MediaTemplateDesign/ListCurrency/index.js +34 -0
  122. package/es/services/MediaTemplateDesign/PromotionPool/index.d.ts +3 -0
  123. package/es/services/MediaTemplateDesign/PromotionPool/index.js +31 -0
  124. package/es/services/MediaTemplateDesign/UploadFile/index.d.ts +5 -5
  125. package/es/services/MediaTemplateDesign/UploadFile/index.js +36 -19
  126. package/es/services/ThirParty/index.d.ts +8 -0
  127. package/es/services/ThirParty/index.js +26 -0
  128. package/es/services/index.d.ts +14 -5
  129. package/es/services/index.js +45 -1
  130. package/es/test.js +50 -10
  131. package/es/types/index.d.ts +5 -0
  132. package/es/utils/common.d.ts +1 -0
  133. package/es/utils/common.js +1 -0
  134. package/package.json +9 -2
@@ -1,30 +1,10 @@
1
1
  import React from 'react';
2
- import { DisableShortLinkTypeProps } from './PopupShortLink';
3
- export type KeyTagType = 'shortlink' | 'shortlink_static';
4
- export type SelectedPropertiesProps = {
5
- keyTag: KeyTagType;
6
- link: string;
7
- urlDetected: string;
8
- };
9
- export type InputDynamicProps = {
10
- value: string;
11
- isViewMode?: boolean;
12
- errors?: string[];
13
- disabledOpts?: DisableShortLinkTypeProps;
14
- canMultipleLine?: boolean;
15
- onError?: Function;
16
- onChange: (valueOut: string) => any;
17
- addMessageToQueue?: Function;
2
+ import { InputDynamicProps } from './types';
3
+ export declare const AllowDynamicType: {
4
+ readonly SHORTLINK: "shortlink";
5
+ readonly ADDPERSONALIZATION: "addPersonalization";
18
6
  };
19
7
  export declare const InputDynamic: {
20
8
  (props: InputDynamicProps): React.JSX.Element;
21
- defaultProps: {
22
- value: string;
23
- isViewMode: boolean;
24
- errors: never[];
25
- canMultipleLine: boolean;
26
- onError: () => void;
27
- onChange: () => void;
28
- addMessageToQueue: () => void;
29
- };
9
+ defaultProps: InputDynamicProps;
30
10
  };
@@ -1,28 +1,43 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-expressions */
1
2
  // Libraries
2
- import React, { useState, useLayoutEffect, useEffect, useRef, useCallback, } from 'react';
3
+ import React, { useState, useLayoutEffect, useEffect, useRef, useCallback, useMemo, } from 'react';
3
4
  import classnames from 'classnames';
5
+ import { has, isEmpty, omit } from 'lodash';
4
6
  // Components
5
7
  import CaretPositioning from './EditCaretPositioning';
6
- import { WrapperInputStyle, TooltipHover } from './styled';
8
+ import { WrapperInputStyle, TooltipHover, DynamicItem } from './styled';
9
+ import { Popover } from 'antd';
10
+ import { AddDynamicContent } from '../../molecules/AddDynamicContent';
7
11
  import { PopupShortLink } from './PopupShortLink';
8
12
  import Icon from '@antscorp/icons';
9
13
  // Utils
10
14
  import { getObjectPropSafely, random, safeParse } from '@antscorp/antsomi-ui/es/utils';
11
- import { convertBreakTag, convertDivToBreakTag, convertHtmlText, genShortLinkValue, getInsertLinkPatternWithAppendSpaceEnd, handleUpdateInputPersonalization, initialValue, pasteHtmlAtCaret, removeHtmlTag, spacingNonTracking, validateHTMLTags, } from './utils';
15
+ import { convertBreakTag, convertDivToBreakTag, convertHtmlText, genShortLinkValue, getInsertLinkPatternWithAppendSpaceEnd, getInsertPatternWithAppendSpaceEnd, handleUpdateInputPersonalization, initialValue, mapLabelPersonalization, pasteHtmlAtCaret, removeHtmlTag, spacingNonTracking, validateHTMLTags, createElement, getBgColorByContentSourceType, } from './utils';
12
16
  // Hooks
13
17
  import { useDebounce } from '@antscorp/antsomi-ui/es/hooks/useDebounce';
14
18
  const PATH = 'src/components/atoms/InputDynamic/InputDynamic.tsx';
19
+ export const AllowDynamicType = {
20
+ SHORTLINK: 'shortlink',
21
+ ADDPERSONALIZATION: 'addPersonalization',
22
+ };
15
23
  const defaultProps = {
16
24
  value: '',
17
25
  isViewMode: false,
18
26
  errors: [],
19
27
  canMultipleLine: false,
28
+ apiConfig: {
29
+ domain: 'https://sandbox-media-template.antsomi.com/cdp',
30
+ slug: '/api/v1',
31
+ token: '5474r2x214z2a4b403e4y446p4b4t2b4t474j4t2i5',
32
+ accountId: '1600085679',
33
+ userId: '1600085679',
34
+ },
20
35
  onError: () => { },
21
36
  onChange: () => { },
22
37
  addMessageToQueue: () => { },
23
38
  };
24
39
  export const InputDynamic = (props) => {
25
- const { value, isViewMode, errors, disabledOpts, canMultipleLine, onError, onChange, addMessageToQueue, } = props;
40
+ const { value, isViewMode, errors, disabledOpts, canMultipleLine, allowDynamicOptions, apiConfig, onError, onChange, addMessageToQueue, } = props;
26
41
  // States
27
42
  const [textValue, setTextValue] = useState(initialValue(value));
28
43
  const [initSelectedProperties, setInitSelectedProperties] = useState({
@@ -30,11 +45,39 @@ export const InputDynamic = (props) => {
30
45
  link: '',
31
46
  urlDetected: '',
32
47
  });
48
+ const [isShowPopover, setIsShowPopover] = useState(false);
49
+ const [dynamicContent, setDynamicContent] = useState({
50
+ visible: false,
51
+ defaultData: {},
52
+ activeTagId: '',
53
+ contentSources: {
54
+ groups: [],
55
+ expanded: [],
56
+ isLoadingDataBO: false,
57
+ },
58
+ journeySettings: {
59
+ unsubscribeSegmentType: 'customer',
60
+ triggerType: 'event_based',
61
+ triggerEvent: {
62
+ eventActionId: '',
63
+ eventCategoryId: '',
64
+ insightPropertyIds: [],
65
+ },
66
+ },
67
+ });
33
68
  const [popoverOpenShortLink, setPopoverOpenShortLink] = useState(false);
34
69
  const [tooltipHoverDebounce, _tooltipHover, setTooltipHover] = useDebounce({ x: 0, y: 0 }, 200);
35
70
  // Refs
36
71
  const caretPositionRef = useRef(null);
37
72
  const personalizationInputRef = useRef(null);
73
+ const isRenderAddDynamicContent = useMemo(() => {
74
+ if (isEmpty(apiConfig) ||
75
+ isEmpty(allowDynamicOptions) ||
76
+ (allowDynamicOptions &&
77
+ allowDynamicOptions.findIndex(dynamicKey => dynamicKey === AllowDynamicType.ADDPERSONALIZATION) === -1))
78
+ return false;
79
+ return true;
80
+ }, [apiConfig, allowDynamicOptions]);
38
81
  const onTriggerChange = (event = null) => {
39
82
  var _a;
40
83
  try {
@@ -72,6 +115,16 @@ export const InputDynamic = (props) => {
72
115
  console.error(error);
73
116
  }
74
117
  };
118
+ const handleHidePopover = () => {
119
+ setIsShowPopover(false);
120
+ };
121
+ const handleOpenChangeAddDynamicContent = useCallback((newChange) => {
122
+ setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { visible: newChange })));
123
+ }, []);
124
+ const handleOpenChange = (newOpen) => {
125
+ setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: '' })));
126
+ setIsShowPopover(newOpen);
127
+ };
75
128
  const callback = (type, data) => {
76
129
  var _a, _b;
77
130
  switch (type) {
@@ -126,6 +179,94 @@ export const InputDynamic = (props) => {
126
179
  }
127
180
  }
128
181
  };
182
+ const handleCloseAddDynamicContent = () => {
183
+ setDynamicContent(Object.assign(Object.assign({}, dynamicContent), { visible: false }));
184
+ };
185
+ const handleInsertText = (dataObj) => {
186
+ try {
187
+ const id = random(5);
188
+ const { mappingFields = '', type = '', attribute = {}, customFunction = {} } = dataObj;
189
+ const personalizationCode = `#{${mappingFields}||""}`;
190
+ const bgColor = getBgColorByContentSourceType(type);
191
+ const label = getObjectPropSafely(() => type === 'custom' ? customFunction.personalizationName : attribute.label);
192
+ if (personalizationInputRef.current instanceof HTMLElement) {
193
+ if (dynamicContent.activeTagId) {
194
+ // for case update
195
+ const element = document.getElementById(dynamicContent.activeTagId);
196
+ const child = createElement('em', {
197
+ class: 'editor-icon-remove',
198
+ style: 'color: white;font-style: normal;',
199
+ }, ['x']);
200
+ const newElement = createElement('button', {
201
+ id,
202
+ class: 'insert-word',
203
+ style: `color: white; font-size: inherit; outline: none;border: 1px solid transparent; border-radius: 1.2rem; max-height: 30px; cursor: pointer; backgroundColor: ${bgColor}`,
204
+ contentEditable: 'false',
205
+ value: `${personalizationCode.replace(/\s/gm, ' ')}`,
206
+ }, [
207
+ `${getObjectPropSafely(() => type === 'custom' ? customFunction.personalizationName : attribute.label)} `,
208
+ child,
209
+ ]);
210
+ if (element && element.parentNode) {
211
+ element.parentNode.replaceChild(newElement, element);
212
+ }
213
+ setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: dynamicContent.activeTagId, defaultData: Object.assign(Object.assign({}, (prev.defaultData || {})), { [dynamicContent.activeTagId]: dataObj }), visible: false })));
214
+ onTriggerChange();
215
+ // if (type === 'custom') {
216
+ // const found = personalizationCode.replace(/#|{|}|/g, '').split('.');
217
+ // // setStateCustomPersonal(draft => {
218
+ // // // draft.list.push(customFunction);
219
+ // // draft.map[found[1]] = customFunction;
220
+ // // });
221
+ // } else if (
222
+ // selectedProperties.displayFormat.dataType &&
223
+ // DATA_ATTR_WITH_TYPE.includes(selectedProperties.displayFormat.dataType)
224
+ // ) {
225
+ // const key = personalizationCode.replace(regexAttrFormat, '');
226
+ // const dataAttrFormat = mapDataFormatAttribute(selectedProperties.displayFormat);
227
+ // // setstateFormatAttr(draft => {
228
+ // // draft.formatAttributes[key] = dataAttrFormat;
229
+ // // onTriggerChange(null, draft);
230
+ // // });
231
+ // }
232
+ return;
233
+ }
234
+ personalizationInputRef.current.focus();
235
+ CaretPositioning.restoreSelection(personalizationInputRef.current, caretPositionRef.current);
236
+ pasteHtmlAtCaret(getInsertPatternWithAppendSpaceEnd(id, personalizationCode, label, bgColor), null, () => {
237
+ caretPositionRef.current = CaretPositioning.saveSelection(personalizationInputRef.current);
238
+ onTriggerChange();
239
+ });
240
+ setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: id, defaultData: Object.assign(Object.assign({}, (prev.defaultData || {})), { [id]: dataObj }), visible: false })));
241
+ }
242
+ // if (personalType.value === 'custom') {
243
+ // // const found = personalizationCode.replace(/#|{|}|/g, '').split('.');
244
+ // // setStateCustomPersonal(draft => {
245
+ // // // draft.list.push(customFunction);
246
+ // // draft.map[found[1]] = customFunction;
247
+ // // });
248
+ // } else if (
249
+ // selectedProperties.displayFormat.dataType &&
250
+ // DATA_ATTR_WITH_TYPE.includes(selectedProperties.displayFormat.dataType)
251
+ // ) {
252
+ // const key = personalizationCode.replace(regexAttrFormat, '');
253
+ // // setstateFormatAttr(draft => {
254
+ // // draft.formatAttributes[key] = mapDataFormatAttribute(selectedProperties.displayFormat);
255
+ // // });
256
+ // }
257
+ }
258
+ catch (error) {
259
+ if (typeof addMessageToQueue === 'function') {
260
+ addMessageToQueue({
261
+ path: PATH,
262
+ func: 'handleInsertText',
263
+ data: error,
264
+ });
265
+ }
266
+ // eslint-disable-next-line no-console
267
+ console.log(error);
268
+ }
269
+ };
129
270
  const handleKeyPress = (e) => {
130
271
  if (canMultipleLine)
131
272
  return;
@@ -155,21 +296,35 @@ export const InputDynamic = (props) => {
155
296
  const toggleShortLinkModal = useCallback(() => {
156
297
  setPopoverOpenShortLink(!popoverOpenShortLink);
157
298
  }, [popoverOpenShortLink]);
299
+ const handleClickDynamicItem = (e, dynamicKey) => {
300
+ e.stopPropagation();
301
+ handleHidePopover();
302
+ if (dynamicKey === AllowDynamicType.SHORTLINK) {
303
+ toggleShortLinkModal();
304
+ }
305
+ if (dynamicKey === AllowDynamicType.ADDPERSONALIZATION) {
306
+ handleOpenChangeAddDynamicContent(true);
307
+ }
308
+ };
158
309
  /**
159
- * [NOTE:open shortlink modal to edit]
310
+ * [NOTE:open modal to edit]
160
311
  */
161
312
  useEffect(() => {
162
313
  const handleClickTag = (e) => {
163
314
  try {
164
315
  e.stopPropagation();
165
316
  if (e.target) {
166
- const { value = '' } = e.target;
317
+ const { value = '', id = '' } = e.target;
167
318
  const shortLink = value.replace(/#|{|}|/g, '').split('(');
168
319
  if (shortLink && shortLink.length >= 2) {
169
320
  const link = shortLink[1].substring(0, shortLink[1].length - 1) || '';
170
321
  setInitSelectedProperties(prev => (Object.assign(Object.assign({}, prev), { link, keyTag: shortLink[0], urlDetected: e.currentTarget })));
171
322
  toggleShortLinkModal();
172
323
  }
324
+ else {
325
+ setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: id })));
326
+ handleOpenChangeAddDynamicContent(true);
327
+ }
173
328
  }
174
329
  }
175
330
  catch (err) {
@@ -188,7 +343,7 @@ export const InputDynamic = (props) => {
188
343
  tag.removeEventListener('click', handleClickTag);
189
344
  });
190
345
  };
191
- }, [textValue, toggleShortLinkModal]);
346
+ }, [handleOpenChangeAddDynamicContent, textValue, toggleShortLinkModal]);
192
347
  /** Anchor tooltip */
193
348
  useEffect(() => {
194
349
  let listElement = [];
@@ -246,11 +401,18 @@ export const InputDynamic = (props) => {
246
401
  const buttonElement = document.querySelectorAll('.insert-word');
247
402
  const listBtnElement = buttonElement && Array.from(buttonElement);
248
403
  const handleRemoveTag = (e) => {
249
- var _a, _b, _c, _d, _e;
404
+ var _a, _b, _c, _d, _e, _f, _g, _h;
250
405
  if (e && ((_a = e.target) === null || _a === void 0 ? void 0 : _a.nodeName) === 'EM' && ((_b = e.target) === null || _b === void 0 ? void 0 : _b.className) === 'editor-icon-remove') {
251
406
  e.stopPropagation();
252
- (_d = (_c = e.target) === null || _c === void 0 ? void 0 : _c.parentElement) === null || _d === void 0 ? void 0 : _d.remove();
253
- setTextValue(personalizationInputRef && ((_e = personalizationInputRef.current) === null || _e === void 0 ? void 0 : _e.innerHTML));
407
+ if (((_c = e.target) === null || _c === void 0 ? void 0 : _c.parentElement) &&
408
+ has(dynamicContent.defaultData, [(_e = (_d = e.target) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.id])) {
409
+ setDynamicContent(prev => {
410
+ var _a, _b;
411
+ return (Object.assign(Object.assign({}, prev), { activeTagId: '', defaultData: omit(prev.defaultData, [(_b = (_a = e.target) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.id]) }));
412
+ });
413
+ }
414
+ (_g = (_f = e.target) === null || _f === void 0 ? void 0 : _f.parentElement) === null || _g === void 0 ? void 0 : _g.remove();
415
+ setTextValue(personalizationInputRef && ((_h = personalizationInputRef.current) === null || _h === void 0 ? void 0 : _h.innerHTML));
254
416
  }
255
417
  };
256
418
  listIconRemove.forEach(eachIcon => {
@@ -262,7 +424,7 @@ export const InputDynamic = (props) => {
262
424
  eachIcon.removeEventListener('click', handleRemoveTag);
263
425
  });
264
426
  };
265
- }, [textValue]);
427
+ }, [dynamicContent.defaultData, textValue]);
266
428
  useLayoutEffect(() => {
267
429
  try {
268
430
  // save caret position
@@ -292,6 +454,28 @@ export const InputDynamic = (props) => {
292
454
  }
293
455
  }
294
456
  }, [addMessageToQueue, onError, textValue]);
457
+ const renderContentDynamicOptions = () => {
458
+ if (!(allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.length)) {
459
+ return null;
460
+ }
461
+ return allowDynamicOptions.map((dynamicKey) => (React.createElement(DynamicItem, { key: dynamicKey, onClick: e => handleClickDynamicItem(e, dynamicKey) }, mapLabelPersonalization(dynamicKey))));
462
+ };
463
+ const renderAddPersonalizationView = () => {
464
+ if (isViewMode) {
465
+ return null;
466
+ }
467
+ const isRenderPopover = allowDynamicOptions && (allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.length) > 0;
468
+ const iconPersonalization = (React.createElement(Icon, { type: "icon-ants-person-alt", onClick: e => {
469
+ e.stopPropagation();
470
+ if (!isRenderPopover) {
471
+ toggleShortLinkModal();
472
+ }
473
+ }, className: "customize-antsomi-profile", style: { width: 24, height: 24 } }));
474
+ if (!isRenderPopover) {
475
+ return iconPersonalization;
476
+ }
477
+ return (React.createElement(Popover, { content: renderContentDynamicOptions(), placement: "bottomLeft", rootClassName: "no-padding-content", trigger: "click", open: isShowPopover, onOpenChange: handleOpenChange }, iconPersonalization));
478
+ };
295
479
  return (React.createElement(WrapperInputStyle, { id: "ants-ui-input-personalization" },
296
480
  React.createElement("div", { className: classnames({
297
481
  'input-wrapper-outter': true,
@@ -310,11 +494,11 @@ export const InputDynamic = (props) => {
310
494
  dangerouslySetInnerHTML: {
311
495
  __html: getDangerouslySetInnerHTML(textValue),
312
496
  }, onPaste: onPaste }),
313
- !isViewMode && (React.createElement(Icon, { type: "icon-ants-person-alt", onClick: e => {
314
- e.stopPropagation();
315
- toggleShortLinkModal();
316
- }, className: "customize-antsomi-profile", style: { width: 24, height: 24 } }))),
497
+ renderAddPersonalizationView()),
317
498
  React.createElement(TooltipHover, { isShow: tooltipHoverDebounce.x > 0 && tooltipHoverDebounce.y > 0, top: tooltipHoverDebounce.y, left: tooltipHoverDebounce.x }, "Click on the link to convert it to a shortlink"),
318
- popoverOpenShortLink && (React.createElement(PopupShortLink, { open: popoverOpenShortLink, disabledOpts: disabledOpts, onOk: handleInsertSortLink, onClose: toggleShortLinkModal, initSelectedProperties: initSelectedProperties, callback: callback }))));
499
+ popoverOpenShortLink && (React.createElement(PopupShortLink, { open: popoverOpenShortLink, disabledOpts: disabledOpts, onOk: handleInsertSortLink, onClose: toggleShortLinkModal, initSelectedProperties: initSelectedProperties, callback: callback })),
500
+ isRenderAddDynamicContent && (React.createElement(AddDynamicContent, { APIConfig: apiConfig, defaultDynamicIndex: 1, showIndex: true, showDisplayFormat: true, visible: dynamicContent.visible, defaultData: dynamicContent.defaultData[dynamicContent.activeTagId] || {}, journeySettings: dynamicContent.journeySettings, contentSources: dynamicContent.contentSources, onOk: (value) => {
501
+ handleInsertText(value);
502
+ }, onCancel: () => handleCloseAddDynamicContent() }))));
319
503
  };
320
504
  InputDynamic.defaultProps = defaultProps;
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import type { SelectedPropertiesProps } from './InputDynamic';
2
+ import type { SelectedPropertiesProps } from './types';
3
3
  type PopupShortLinkProps = {
4
4
  open: any;
5
5
  onClose: Function;
@@ -0,0 +1,71 @@
1
+ export declare const DATE_AND_TIME_DEFAULT: {
2
+ type: string;
3
+ config: {
4
+ format: string;
5
+ date: {
6
+ check: boolean;
7
+ value: string;
8
+ };
9
+ time: {
10
+ check: boolean;
11
+ value: string;
12
+ timeFormat: string;
13
+ };
14
+ };
15
+ };
16
+ export declare const MAP_DATA_TYPE: {
17
+ number: {
18
+ name: string;
19
+ label: string;
20
+ translateCode: string;
21
+ value: string;
22
+ };
23
+ string: {
24
+ name: string;
25
+ label: string;
26
+ translateCode: string;
27
+ value: string;
28
+ };
29
+ text: {
30
+ name: string;
31
+ label: string;
32
+ translateCode: string;
33
+ value: string;
34
+ };
35
+ datetime: {
36
+ name: string;
37
+ label: string;
38
+ translateCode: string;
39
+ value: string;
40
+ };
41
+ boolean: {
42
+ name: string;
43
+ label: string;
44
+ translateCode: string;
45
+ value: string;
46
+ };
47
+ array_number: {
48
+ name: string;
49
+ label: string;
50
+ translateCode: string;
51
+ value: string;
52
+ };
53
+ array_string: {
54
+ name: string;
55
+ label: string;
56
+ translateCode: string;
57
+ value: string;
58
+ };
59
+ array_datetime: {
60
+ name: string;
61
+ label: string;
62
+ translateCode: string;
63
+ value: string;
64
+ };
65
+ object: {
66
+ name: string;
67
+ label: string;
68
+ translateCode: string;
69
+ value: string;
70
+ };
71
+ };
@@ -0,0 +1,71 @@
1
+ export const DATE_AND_TIME_DEFAULT = {
2
+ type: 'DATE_AND_TIME',
3
+ config: {
4
+ format: 'DD/MM/YYYY',
5
+ date: {
6
+ check: true,
7
+ value: 'long',
8
+ },
9
+ time: {
10
+ check: true,
11
+ value: 'medium',
12
+ timeFormat: '24',
13
+ },
14
+ },
15
+ };
16
+ export const MAP_DATA_TYPE = {
17
+ number: {
18
+ name: 'number',
19
+ label: 'Number',
20
+ translateCode: '',
21
+ value: 'number',
22
+ },
23
+ string: {
24
+ name: 'string',
25
+ label: 'String',
26
+ translateCode: '',
27
+ value: 'string',
28
+ },
29
+ text: {
30
+ name: 'text',
31
+ label: 'Text',
32
+ translateCode: '',
33
+ value: 'text',
34
+ },
35
+ datetime: {
36
+ name: 'datetime',
37
+ label: 'Datetime',
38
+ translateCode: '',
39
+ value: 'datetime',
40
+ },
41
+ boolean: {
42
+ name: 'boolean',
43
+ label: 'Boolean',
44
+ translateCode: '',
45
+ value: 'boolean',
46
+ },
47
+ array_number: {
48
+ name: 'array_number',
49
+ label: 'Array of Numbers',
50
+ translateCode: '',
51
+ value: 'array_number',
52
+ },
53
+ array_string: {
54
+ name: 'array_string',
55
+ label: 'Array of Strings',
56
+ translateCode: '',
57
+ value: 'array_string',
58
+ },
59
+ array_datetime: {
60
+ name: 'array_datetime',
61
+ label: 'Array of Datetimes',
62
+ translateCode: '',
63
+ value: 'array_datetime',
64
+ },
65
+ object: {
66
+ name: 'object',
67
+ label: 'Object',
68
+ translateCode: '',
69
+ value: 'object',
70
+ },
71
+ };
@@ -1,2 +1,2 @@
1
1
  export { InputDynamic } from './InputDynamic';
2
- export type { InputDynamicProps } from './InputDynamic';
2
+ export type { InputDynamicProps } from './types';
@@ -10,3 +10,4 @@ export declare const TooltipHover: import("styled-components").StyledComponent<"
10
10
  left: number;
11
11
  isShow: boolean;
12
12
  }, never>;
13
+ export declare const DynamicItem: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,4 +1,4 @@
1
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
1
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
2
2
  // Libraries
3
3
  import styled from 'styled-components';
4
4
  import { Input } from '../Input/Input';
@@ -264,7 +264,7 @@ export const TooltipHover = styled.div `
264
264
  background: rgba(0, 0, 0, 0.62);
265
265
  transition: opacity 186ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
266
266
  transform 124ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
267
- color: #fff;
267
+ color: ${(_o = THEME.token) === null || _o === void 0 ? void 0 : _o.bw0};
268
268
  font-size: 12px;
269
269
  box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14),
270
270
  0px 3px 14px 2px rgba(0, 0, 0, 0.12);
@@ -279,3 +279,15 @@ export const TooltipHover = styled.div `
279
279
  overflow: hidden;
280
280
  box-sizing: border-box;
281
281
  `;
282
+ export const DynamicItem = styled.div `
283
+ padding: 4px 16px;
284
+ font-size: 13px;
285
+ color: ${(_p = THEME.token) === null || _p === void 0 ? void 0 : _p.bw10};
286
+ cursor: pointer;
287
+ transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
288
+
289
+ &:hover {
290
+ color: ${(_q = THEME.token) === null || _q === void 0 ? void 0 : _q.bw0};
291
+ background-color: ${(_r = THEME.token) === null || _r === void 0 ? void 0 : _r.colorPrimary};
292
+ }
293
+ `;
@@ -0,0 +1,110 @@
1
+ import { DisableShortLinkTypeProps } from './PopupShortLink';
2
+ import { AllowDynamicType } from './InputDynamic';
3
+ import { APIConfig, TDataType } from '../../molecules/AddDynamicContent';
4
+ export type KeyTagType = 'shortlink' | 'shortlink_static';
5
+ export type SelectedPropertiesProps = {
6
+ keyTag: KeyTagType;
7
+ link: string;
8
+ urlDetected: string;
9
+ };
10
+ export type AllowDynamicOptions = (typeof AllowDynamicType)[keyof typeof AllowDynamicType];
11
+ export type InputDynamicProps = {
12
+ value: string;
13
+ isViewMode?: boolean;
14
+ errors?: string[];
15
+ disabledOpts?: DisableShortLinkTypeProps;
16
+ allowDynamicOptions?: Array<AllowDynamicOptions>;
17
+ apiConfig?: APIConfig;
18
+ canMultipleLine?: boolean;
19
+ onError?: Function;
20
+ onChange: (valueOut: string) => any;
21
+ addMessageToQueue?: Function;
22
+ };
23
+ export type TOperatorValue = 'greater_than' | 'greater_than_equal' | 'less_than' | 'less_than_equal' | 'not_equals' | 'equals' | 'between' | 'exists' | 'not_exists' | 'contains' | 'doesnt_contain' | 'start_with' | 'not_start_with' | 'end_with' | 'not_end_with' | 'before_date' | 'after_date' | 'equal_time_ago' | 'not_equal_time_ago' | 'before_time_ago' | 'after_time_ago' | 'between_time_ago' | 'matches' | 'not_matches' | 'includes' | 'doesnt_include' | null;
24
+ export type VisitorMetadata = {
25
+ item_type_id: string | number;
26
+ item_type_name: string;
27
+ item_property_name: string;
28
+ };
29
+ export type CustomerMetadata = VisitorMetadata;
30
+ export type EventMetadata = {
31
+ insight_property_id: any | any[] | null;
32
+ insight_property_ids?: string[] | null;
33
+ event_action_id: string | null;
34
+ event_category_id: string | null;
35
+ event_tracking_name: string | null;
36
+ item_type_id: string | null;
37
+ item_type_name: string | null;
38
+ item_property_name: string | null;
39
+ item_property_label: string | null;
40
+ event_property_syntax: string | null;
41
+ };
42
+ export type TFilter = {
43
+ value: any;
44
+ operator: TOperatorValue;
45
+ data_type: TDataType;
46
+ column: string | null;
47
+ condition_type: 'comp_attr' | null;
48
+ value_type: 'event' | 'normal' | 'visitor' | 'customer';
49
+ time_unit?: 'DAY' | 'HOUR';
50
+ event_metadata?: EventMetadata;
51
+ visitor_metadata?: VisitorMetadata;
52
+ customer_metadata?: CustomerMetadata;
53
+ extend?: any;
54
+ };
55
+ export type TFilters = {
56
+ OR: {
57
+ AND: TFilter[];
58
+ }[];
59
+ };
60
+ export type TRanking = {
61
+ type: 'algorithms' | 'custom';
62
+ algorithms: {
63
+ sort: 'mix' | 'order';
64
+ value: {
65
+ value: string;
66
+ quantity: number;
67
+ by?: string;
68
+ last?: number;
69
+ to?: string;
70
+ sort_type?: 'desc' | 'asc';
71
+ [key: string]: any;
72
+ }[];
73
+ filters: string[];
74
+ };
75
+ custom: string;
76
+ };
77
+ export type TContentSourceGroup = {
78
+ groupId: string;
79
+ groupName: string;
80
+ filters: TFilters;
81
+ ranking: TRanking;
82
+ itemTypeId: number | null;
83
+ itemTypeName: string | null;
84
+ itemTypeDisplay: string | null;
85
+ fallback: string;
86
+ level?: string;
87
+ data?: Record<string, any>[];
88
+ };
89
+ export type TContentSourceSettings = {
90
+ groups: TContentSourceGroup[];
91
+ expanded: string[];
92
+ isLoadingDataBO: boolean;
93
+ };
94
+ export type DynamicContentProps = {
95
+ visible: boolean;
96
+ contentSources: TContentSourceSettings;
97
+ activeTagId: string;
98
+ defaultData: {
99
+ [tagId: string]: Record<string, any>;
100
+ };
101
+ journeySettings: {
102
+ unsubscribeSegmentType?: string | null;
103
+ triggerType?: string | null;
104
+ triggerEvent?: {
105
+ eventActionId: number | string;
106
+ eventCategoryId: number | string;
107
+ insightPropertyIds: any[];
108
+ };
109
+ };
110
+ };
@@ -0,0 +1 @@
1
+ export {};