@antscorp/antsomi-ui 1.3.3-beta.70 → 1.3.3-beta.71
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/atoms/InputDynamic/InputDynamic.js +19 -39
- package/es/components/atoms/InputDynamic/types.d.ts +3 -0
- package/es/components/molecules/AddDynamicContent/AddDynamicContent.js +73 -70
- package/es/components/molecules/AddDynamicContent/components/FormatDatetime/FormatDatetime.js +10 -11
- package/es/components/molecules/AddDynamicContent/components/FormatNumber/FormatNumber.js +14 -14
- package/es/components/molecules/AddDynamicContent/constants.d.ts +1 -1
- package/es/components/molecules/AddDynamicContent/constants.js +1 -1
- package/es/components/molecules/AddDynamicContent/styled.d.ts +3 -0
- package/es/components/molecules/AddDynamicContent/styled.js +13 -1
- package/es/components/molecules/AddDynamicContent/utils.d.ts +2 -3
- package/es/components/molecules/AddDynamicContent/utils.js +6 -8
- package/es/components/molecules/EditorScript/EditorScript.d.ts +14 -0
- package/es/components/molecules/EditorScript/EditorScript.js +89 -0
- package/es/components/molecules/EditorScript/index.d.ts +1 -0
- package/es/components/molecules/EditorScript/index.js +1 -0
- package/es/components/molecules/EditorScript/styled.d.ts +1 -0
- package/es/components/molecules/EditorScript/styled.js +3 -0
- package/es/components/molecules/UploadImage/index.js +12 -9
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/locales/en/translation.json +4 -0
- package/es/locales/i18n.d.ts +4 -0
- package/es/locales/translations.d.ts +4 -0
- package/package.json +3 -2
|
@@ -32,12 +32,15 @@ const defaultProps = {
|
|
|
32
32
|
accountId: '1600085679',
|
|
33
33
|
userId: '1600085679',
|
|
34
34
|
},
|
|
35
|
+
showIndex: true,
|
|
36
|
+
showDisplayFormat: true,
|
|
37
|
+
isShowCustomFunction: true,
|
|
35
38
|
onError: () => { },
|
|
36
39
|
onChange: () => { },
|
|
37
40
|
addMessageToQueue: () => { },
|
|
38
41
|
};
|
|
39
42
|
export const InputDynamic = (props) => {
|
|
40
|
-
const { value, isViewMode, errors, disabledOpts, canMultipleLine, allowDynamicOptions, apiConfig, onError, onChange, addMessageToQueue, } = props;
|
|
43
|
+
const { value, isViewMode, errors, disabledOpts, canMultipleLine, allowDynamicOptions, showIndex, showDisplayFormat, isShowCustomFunction, apiConfig, onError, onChange, addMessageToQueue, } = props;
|
|
41
44
|
// States
|
|
42
45
|
const [textValue, setTextValue] = useState(initialValue(value));
|
|
43
46
|
const [initSelectedProperties, setInitSelectedProperties] = useState({
|
|
@@ -186,9 +189,10 @@ export const InputDynamic = (props) => {
|
|
|
186
189
|
try {
|
|
187
190
|
const id = random(5);
|
|
188
191
|
const { mappingFields = '', type = '', attribute = {}, customFunction = {} } = dataObj;
|
|
189
|
-
const
|
|
192
|
+
const isCustom = type === 'custom';
|
|
193
|
+
const personalizationCode = isCustom ? mappingFields : `#{${mappingFields}||""}`;
|
|
190
194
|
const bgColor = getBgColorByContentSourceType(type);
|
|
191
|
-
const label = getObjectPropSafely(() =>
|
|
195
|
+
const label = getObjectPropSafely(() => isCustom ? customFunction.templateName : attribute.label);
|
|
192
196
|
if (personalizationInputRef.current instanceof HTMLElement) {
|
|
193
197
|
if (dynamicContent.activeTagId) {
|
|
194
198
|
// for case update
|
|
@@ -204,7 +208,7 @@ export const InputDynamic = (props) => {
|
|
|
204
208
|
contentEditable: 'false',
|
|
205
209
|
value: `${personalizationCode.replace(/\s/gm, ' ')}`,
|
|
206
210
|
}, [
|
|
207
|
-
`${getObjectPropSafely(() =>
|
|
211
|
+
`${getObjectPropSafely(() => isCustom ? customFunction.templateName : attribute.label)} `,
|
|
208
212
|
child,
|
|
209
213
|
]);
|
|
210
214
|
if (element && element.parentNode) {
|
|
@@ -212,23 +216,6 @@ export const InputDynamic = (props) => {
|
|
|
212
216
|
}
|
|
213
217
|
setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: dynamicContent.activeTagId, defaultData: Object.assign(Object.assign({}, (prev.defaultData || {})), { [dynamicContent.activeTagId]: dataObj }), visible: false })));
|
|
214
218
|
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
219
|
return;
|
|
233
220
|
}
|
|
234
221
|
personalizationInputRef.current.focus();
|
|
@@ -239,21 +226,6 @@ export const InputDynamic = (props) => {
|
|
|
239
226
|
});
|
|
240
227
|
setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: id, defaultData: Object.assign(Object.assign({}, (prev.defaultData || {})), { [id]: dataObj }), visible: false })));
|
|
241
228
|
}
|
|
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
229
|
}
|
|
258
230
|
catch (error) {
|
|
259
231
|
if (typeof addMessageToQueue === 'function') {
|
|
@@ -464,12 +436,20 @@ export const InputDynamic = (props) => {
|
|
|
464
436
|
if (isViewMode) {
|
|
465
437
|
return null;
|
|
466
438
|
}
|
|
467
|
-
const isRenderPopover = allowDynamicOptions && (allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.length) >
|
|
439
|
+
const isRenderPopover = allowDynamicOptions && (allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.length) > 1;
|
|
440
|
+
const isOnlyOneOpt = allowDynamicOptions && (allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.length) === 1;
|
|
441
|
+
const hasOnlyPersonalization = isOnlyOneOpt && (allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.includes(AllowDynamicType.ADDPERSONALIZATION));
|
|
442
|
+
const hasOnlyShortlink = isOnlyOneOpt && (allowDynamicOptions === null || allowDynamicOptions === void 0 ? void 0 : allowDynamicOptions.includes(AllowDynamicType.SHORTLINK));
|
|
468
443
|
const iconPersonalization = (React.createElement(Icon, { type: "icon-ants-person-alt", onClick: e => {
|
|
469
444
|
e.stopPropagation();
|
|
470
|
-
|
|
445
|
+
// Open short link modal
|
|
446
|
+
if (hasOnlyShortlink) {
|
|
471
447
|
toggleShortLinkModal();
|
|
472
448
|
}
|
|
449
|
+
// Open Personalization modal
|
|
450
|
+
if (hasOnlyPersonalization) {
|
|
451
|
+
setDynamicContent(prev => (Object.assign(Object.assign({}, prev), { activeTagId: '', visible: true })));
|
|
452
|
+
}
|
|
473
453
|
}, className: "customize-antsomi-profile", style: { width: 24, height: 24 } }));
|
|
474
454
|
if (!isRenderPopover) {
|
|
475
455
|
return iconPersonalization;
|
|
@@ -497,7 +477,7 @@ export const InputDynamic = (props) => {
|
|
|
497
477
|
renderAddPersonalizationView()),
|
|
498
478
|
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"),
|
|
499
479
|
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:
|
|
480
|
+
isRenderAddDynamicContent && (React.createElement(AddDynamicContent, { APIConfig: apiConfig, defaultDynamicIndex: 1, showIndex: showIndex, showDisplayFormat: showDisplayFormat, isShowCustomFunction: isShowCustomFunction, visible: dynamicContent.visible, defaultData: dynamicContent.defaultData[dynamicContent.activeTagId] || {}, journeySettings: dynamicContent.journeySettings, contentSources: dynamicContent.contentSources, onOk: (value) => {
|
|
501
481
|
handleInsertText(value);
|
|
502
482
|
}, onCancel: () => handleCloseAddDynamicContent() }))));
|
|
503
483
|
};
|
|
@@ -14,6 +14,9 @@ export type InputDynamicProps = {
|
|
|
14
14
|
errors?: string[];
|
|
15
15
|
disabledOpts?: DisableShortLinkTypeProps;
|
|
16
16
|
allowDynamicOptions?: Array<AllowDynamicOptions>;
|
|
17
|
+
showIndex?: boolean;
|
|
18
|
+
showDisplayFormat?: boolean;
|
|
19
|
+
isShowCustomFunction?: boolean;
|
|
17
20
|
apiConfig?: APIConfig;
|
|
18
21
|
canMultipleLine?: boolean;
|
|
19
22
|
onError?: Function;
|
|
@@ -14,7 +14,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
14
14
|
// Libraries
|
|
15
15
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
|
16
16
|
import { omit, isEmpty, flatMapDeep, set, get, isNaN } from 'lodash';
|
|
17
|
-
import classnames from 'classnames';
|
|
18
17
|
// Hooks
|
|
19
18
|
import { useDeepCompareEffect, useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
|
|
20
19
|
// Components
|
|
@@ -22,7 +21,6 @@ import { TreeNode } from 'rc-tree-select';
|
|
|
22
21
|
import { Button, Checkbox, Text, Spin } from '../../atoms';
|
|
23
22
|
import { TreeSelect, Form, Select } from 'antd';
|
|
24
23
|
// Locales
|
|
25
|
-
import { useTranslation } from 'react-i18next';
|
|
26
24
|
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
27
25
|
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
28
26
|
// Query
|
|
@@ -40,6 +38,7 @@ import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
|
40
38
|
import { formatDatetimeDF, formatNumberDF, getAvailableAttrs, getStringFormatDateDF, regexCSType, serilizeBOAttr, serializeCSSelectedString, serilizeDynamicContentAttr, serilizeEventAttr, serilizePromotionPool, buildOptionAttrArchive, checkStatusAttr, serializeLabelToCode, buildMappingFields, CUSTOM_TYPE, } from './utils';
|
|
41
39
|
// Style
|
|
42
40
|
import { InputSuggestion, ModalCustom } from './styled';
|
|
41
|
+
import { EditorScript } from '../EditorScript';
|
|
43
42
|
const getMembers = (member) => {
|
|
44
43
|
if (!member.children || !member.children.length) {
|
|
45
44
|
return member;
|
|
@@ -79,8 +78,7 @@ export const AddDynamicContent = props => {
|
|
|
79
78
|
const { data: customFunction } = useGetCustomFunction({ url }, infos);
|
|
80
79
|
const { mutate: updateCSFunction } = useUpdateCSFunction();
|
|
81
80
|
//* Hooks
|
|
82
|
-
const {
|
|
83
|
-
const { t } = i18nInstance;
|
|
81
|
+
const { t, language } = i18nInstance;
|
|
84
82
|
//* Selectors
|
|
85
83
|
const { triggerEvent } = journeySettings;
|
|
86
84
|
const [itemTypeId, setItemTypeId] = useState(null);
|
|
@@ -251,7 +249,7 @@ export const AddDynamicContent = props => {
|
|
|
251
249
|
args: error === null || error === void 0 ? void 0 : error.message,
|
|
252
250
|
});
|
|
253
251
|
},
|
|
254
|
-
select: (data) => serilizeEventAttr(data,
|
|
252
|
+
select: (data) => serilizeEventAttr(data, language, additionalAttrProperties),
|
|
255
253
|
});
|
|
256
254
|
const { data: listPromotionPools, isFetching: isFetchingPromotionPool } = useGetListPromotionPool({ url }, infos, {
|
|
257
255
|
onSuccess: () => {
|
|
@@ -276,7 +274,7 @@ export const AddDynamicContent = props => {
|
|
|
276
274
|
select: (data) => data
|
|
277
275
|
.filter((attr) => +(attr === null || attr === void 0 ? void 0 : attr.status) === 1)
|
|
278
276
|
.map((attr) => ({
|
|
279
|
-
label: attr.propertyDisplayMultilang[
|
|
277
|
+
label: attr.propertyDisplayMultilang[language] ||
|
|
280
278
|
attr.propertyDisplayMultilang[get(attr, "propertyDisplayMultilang['DEFAULT_LANG']", 'EN')],
|
|
281
279
|
value: attr.itemPropertyName,
|
|
282
280
|
dataType: attr.dataType,
|
|
@@ -348,8 +346,8 @@ export const AddDynamicContent = props => {
|
|
|
348
346
|
if (dynamicContentAttr) {
|
|
349
347
|
const { customer, visitor } = dynamicContentAttr;
|
|
350
348
|
const dynamicContentType = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE);
|
|
351
|
-
const parseCustomers = serilizeDynamicContentAttr(customer,
|
|
352
|
-
const parseVisitors = serilizeDynamicContentAttr(visitor,
|
|
349
|
+
const parseCustomers = serilizeDynamicContentAttr(customer, language, additionalAttrProperties);
|
|
350
|
+
const parseVisitors = serilizeDynamicContentAttr(visitor, language, additionalAttrProperties);
|
|
353
351
|
setListCustomerAttributes(parseCustomers);
|
|
354
352
|
setListVisitorAttributes(parseVisitors);
|
|
355
353
|
if (form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE))
|
|
@@ -365,7 +363,7 @@ export const AddDynamicContent = props => {
|
|
|
365
363
|
});
|
|
366
364
|
}
|
|
367
365
|
}
|
|
368
|
-
}, [dynamicContentAttr, form,
|
|
366
|
+
}, [dynamicContentAttr, form, language]);
|
|
369
367
|
useDeepCompareEffect(() => {
|
|
370
368
|
if (listSources && selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
|
|
371
369
|
if (!isEmpty(form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.SOURCE)))
|
|
@@ -506,6 +504,7 @@ export const AddDynamicContent = props => {
|
|
|
506
504
|
[DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE]: draftDefaultData.type,
|
|
507
505
|
[DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]: outputFormat.type,
|
|
508
506
|
[DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE]: customFunction.outputDataType,
|
|
507
|
+
[DYNAMIC_CONTENT_SETTING_KEY.PERNAME]: customFunction.templateName,
|
|
509
508
|
[DYNAMIC_CONTENT_SETTING_KEY.FUNCTION]: customFunction.customFunction,
|
|
510
509
|
});
|
|
511
510
|
setTemplateName(customFunction.templateName);
|
|
@@ -616,7 +615,7 @@ export const AddDynamicContent = props => {
|
|
|
616
615
|
}
|
|
617
616
|
// Datatime Attribute DF
|
|
618
617
|
if ((selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.dataType) === 'datetime') {
|
|
619
|
-
settings = settings !== null && settings !== void 0 ? settings : Object.assign(Object.assign({}, initDatetimeDFSettings), { language
|
|
618
|
+
settings = settings !== null && settings !== void 0 ? settings : Object.assign(Object.assign({}, initDatetimeDFSettings), { language });
|
|
620
619
|
formatedDFValue = formatDatetimeDF(dateExample, settings);
|
|
621
620
|
}
|
|
622
621
|
if (!attrDFOptions.length) {
|
|
@@ -634,7 +633,7 @@ export const AddDynamicContent = props => {
|
|
|
634
633
|
}
|
|
635
634
|
// Datatime Attribute DF
|
|
636
635
|
if (dataType === 'datetime') {
|
|
637
|
-
settings = settings !== null && settings !== void 0 ? settings : Object.assign(Object.assign({}, initDatetimeDFSettings), { language
|
|
636
|
+
settings = settings !== null && settings !== void 0 ? settings : Object.assign(Object.assign({}, initDatetimeDFSettings), { language });
|
|
638
637
|
formatedDFValue = formatDatetimeDF(dateExample, settings);
|
|
639
638
|
}
|
|
640
639
|
if (!attrDFOptions.length) {
|
|
@@ -647,7 +646,7 @@ export const AddDynamicContent = props => {
|
|
|
647
646
|
attrDFSettings,
|
|
648
647
|
selectedDFType,
|
|
649
648
|
attrDFOptions.length,
|
|
650
|
-
|
|
649
|
+
language,
|
|
651
650
|
defaultAttrDFSetings,
|
|
652
651
|
form,
|
|
653
652
|
selectedAttr,
|
|
@@ -684,10 +683,6 @@ export const AddDynamicContent = props => {
|
|
|
684
683
|
default:
|
|
685
684
|
break;
|
|
686
685
|
}
|
|
687
|
-
// const dataFormat =
|
|
688
|
-
// dataTmp[0].output_format.type.toLowerCase() === 'date_and_time'
|
|
689
|
-
// ? 'datetime'
|
|
690
|
-
// : dataTmp[0].output_format.type.toLowerCase();
|
|
691
686
|
form.setFieldsValue({
|
|
692
687
|
[DYNAMIC_CONTENT_SETTING_KEY.FUNCTION]: dataTmp[0].custom_function,
|
|
693
688
|
[DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE]: dataTmp[0].output_data_type,
|
|
@@ -707,7 +702,7 @@ export const AddDynamicContent = props => {
|
|
|
707
702
|
break;
|
|
708
703
|
}
|
|
709
704
|
case 'date_and_time': {
|
|
710
|
-
setAttrDFSettings(Object.assign(Object.assign({}, initDatetimeDFSettings), { language
|
|
705
|
+
setAttrDFSettings(Object.assign(Object.assign({}, initDatetimeDFSettings), { language, hasDateFormat: format.date.check || true, hasTimeFormat: format.time.check || true, dateParseOption: format.date.value || 'medium', timeParseOption: format.time.value || 'medium', dateParseFormat: format.format || 'MM/DD/YYYY', timeParseFormat: `${format.time.timeFormat || 12}hour` }));
|
|
711
706
|
break;
|
|
712
707
|
}
|
|
713
708
|
case 'raw_string': {
|
|
@@ -718,9 +713,6 @@ export const AddDynamicContent = props => {
|
|
|
718
713
|
break;
|
|
719
714
|
}
|
|
720
715
|
};
|
|
721
|
-
// const handleSearch = data => {
|
|
722
|
-
// console.log('onSelect', data);
|
|
723
|
-
// };
|
|
724
716
|
const handleOnOkModal = () => {
|
|
725
717
|
if (isActionArchive &&
|
|
726
718
|
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
|
|
@@ -1012,7 +1004,7 @@ export const AddDynamicContent = props => {
|
|
|
1012
1004
|
let settings = attrDFSettings;
|
|
1013
1005
|
// Datatime Attribute DF
|
|
1014
1006
|
if (fieldValue === 'datetime') {
|
|
1015
|
-
settings = Object.assign(Object.assign({}, initDatetimeDFSettings), { language
|
|
1007
|
+
settings = Object.assign(Object.assign({}, initDatetimeDFSettings), { language });
|
|
1016
1008
|
}
|
|
1017
1009
|
else if (fieldValue === 'string') {
|
|
1018
1010
|
settings = undefined;
|
|
@@ -1041,7 +1033,7 @@ export const AddDynamicContent = props => {
|
|
|
1041
1033
|
break;
|
|
1042
1034
|
}
|
|
1043
1035
|
case 'datetime': {
|
|
1044
|
-
setAttrDFSettings(Object.assign(Object.assign({}, initDatetimeDFSettings), { language
|
|
1036
|
+
setAttrDFSettings(Object.assign(Object.assign({}, initDatetimeDFSettings), { language }));
|
|
1045
1037
|
break;
|
|
1046
1038
|
}
|
|
1047
1039
|
case 'raw_string': {
|
|
@@ -1063,8 +1055,8 @@ export const AddDynamicContent = props => {
|
|
|
1063
1055
|
if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
|
|
1064
1056
|
return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.boAttr)));
|
|
1065
1057
|
}
|
|
1066
|
-
return (React.createElement(Form.Item, {
|
|
1067
|
-
React.createElement(Select, { loading: isFetchingListBoAttr,
|
|
1058
|
+
return (React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.attribute), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
|
|
1059
|
+
React.createElement(Select, { loading: isFetchingListBoAttr, style: { height: '28px' }, labelInValue: true, options: buildOptionAttrArchive(listBoAttributes || [], selectedAttr),
|
|
1068
1060
|
// errorArchive={errorMessageAttr}
|
|
1069
1061
|
disabled: isActionArchive, showSearch: true })));
|
|
1070
1062
|
};
|
|
@@ -1074,37 +1066,40 @@ export const AddDynamicContent = props => {
|
|
|
1074
1066
|
if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
|
|
1075
1067
|
return null;
|
|
1076
1068
|
}
|
|
1077
|
-
return (React.createElement(Form.Item, {
|
|
1078
|
-
React.createElement(Select, { disabled: disabled, loading: loading,
|
|
1069
|
+
return (React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.index), name: DYNAMIC_CONTENT_SETTING_KEY.INDEX, required: true },
|
|
1070
|
+
React.createElement(Select, { disabled: disabled, loading: loading, style: { height: '28px' }, options: Array.from({ length: 90 }, (_, i) => ({ value: i + 1, label: i + 1 })), showSearch: true })));
|
|
1079
1071
|
};
|
|
1080
1072
|
const renderCustomFunctionFields = () => {
|
|
1081
1073
|
const dataType = form.getFieldValue([DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]);
|
|
1082
1074
|
return (React.createElement(React.Fragment, null,
|
|
1083
|
-
React.createElement(Form.Item, {
|
|
1075
|
+
React.createElement(Form.Item, { label: t(translations.dynamicContent.modal.label.personalizationName), name: DYNAMIC_CONTENT_SETTING_KEY.PERNAME, style: { alignItems: 'center' }, required: true },
|
|
1084
1076
|
React.createElement(InputSuggestion, { onSelect: handleSelect, placeholder: "Custom function name...", options: searchValue.length > 0 ? listCustomTemplatesSearch : listCustomTemplates, onChange: onChangeDataInput, value: templateName }),
|
|
1085
1077
|
hasError[DYNAMIC_CONTENT_SETTING_KEY.PERNAME] && (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.perName)))),
|
|
1086
|
-
React.createElement(Form.Item, {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1078
|
+
React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.function), name: DYNAMIC_CONTENT_SETTING_KEY.FUNCTION, required: true },
|
|
1079
|
+
React.createElement(EditorScript, { mode: "javascript", hideExpand: true })),
|
|
1080
|
+
React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.ouputDataType), name: DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE, required: true },
|
|
1081
|
+
React.createElement(Select, { style: { height: 28 }, options: optionDataType })),
|
|
1082
|
+
React.createElement(Form.Item, { style: { alignItems: 'start' }, required: true, label: t(translations.dynamicContent.modal.label.ouputFormat), name: DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE, extra: React.createElement("div", { style: {
|
|
1083
|
+
display: 'flex',
|
|
1084
|
+
flexWrap: 'wrap',
|
|
1085
|
+
alignItems: 'center',
|
|
1086
|
+
gap: '8px',
|
|
1087
|
+
marginTop: '16px',
|
|
1088
|
+
} },
|
|
1094
1089
|
dataType !== 'raw_string' ? (React.createElement(Text, { color: "#555", dangerouslySetInnerHTML: {
|
|
1095
1090
|
__html: `${t(translations.dynamicContent.modal.label.displayFormat)}: <bdo dir='ltr'>${formatedAttr}</bdo>`,
|
|
1096
1091
|
} })) : null,
|
|
1097
1092
|
!showDetailEditDF && (React.createElement(Button, { disabled: isActionArchive &&
|
|
1098
|
-
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, type: "text",
|
|
1093
|
+
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, type: "text", style: { display: 'inline-block' }, onClick: () => setShowDetailEditDF(prevShow => !prevShow) }, t(translations.edit.title)))) },
|
|
1099
1094
|
React.createElement(Select, { disabled: isActionArchive &&
|
|
1100
|
-
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value,
|
|
1095
|
+
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, style: { height: 28 }, options: attrDFOptions }))));
|
|
1101
1096
|
};
|
|
1102
1097
|
const renderCustomerAttrFields = () => {
|
|
1103
1098
|
if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
|
|
1104
1099
|
return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.customerAttr)));
|
|
1105
1100
|
}
|
|
1106
|
-
return (React.createElement(Form.Item, {
|
|
1107
|
-
React.createElement(Select, { loading: isFetchingDynamicContentAttr,
|
|
1101
|
+
return (React.createElement(Form.Item, { style: { alignItems: 'center' }, initialValue: listCustomerAttributes[0], label: t(translations.dynamicContent.modal.label.attribute), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
|
|
1102
|
+
React.createElement(Select, { loading: isFetchingDynamicContentAttr, style: { height: 28 }, labelInValue: true,
|
|
1108
1103
|
// errorArchive={errorMessageAttr}
|
|
1109
1104
|
disabled: isActionArchive, options: buildOptionAttrArchive(listCustomerAttributes, selectedAttr), showSearch: true })));
|
|
1110
1105
|
};
|
|
@@ -1114,18 +1109,8 @@ export const AddDynamicContent = props => {
|
|
|
1114
1109
|
return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.eventAttr)));
|
|
1115
1110
|
}
|
|
1116
1111
|
return (React.createElement(React.Fragment, null,
|
|
1117
|
-
React.createElement(Form.Item, {
|
|
1118
|
-
React.createElement(TreeSelect, { loading: isFetchingEventAttr || !(listEvents === null || listEvents === void 0 ? void 0 : listEvents.length),
|
|
1119
|
-
// filterTreeNode={(val, option) => {
|
|
1120
|
-
// if (option?.children?.length) {
|
|
1121
|
-
// return option?.children?.some(
|
|
1122
|
-
// child => (child?.title?.toString() || '').toLowerCase().indexOf(val.toLowerCase().trim()) >= 0,
|
|
1123
|
-
// );
|
|
1124
|
-
// } else {
|
|
1125
|
-
// return (option?.title?.toString() || '').toLowerCase().indexOf(val.toLowerCase().trim()) >= 0;
|
|
1126
|
-
// }
|
|
1127
|
-
// }}
|
|
1128
|
-
labelInValue: true, showSearch: true }, listEventAttributes &&
|
|
1112
|
+
React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.selectEventAttr), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
|
|
1113
|
+
React.createElement(TreeSelect, { loading: isFetchingEventAttr || !(listEvents === null || listEvents === void 0 ? void 0 : listEvents.length), style: { height: 28 }, labelInValue: true, showSearch: true }, listEventAttributes &&
|
|
1129
1114
|
listEventAttributes.map((attr) => {
|
|
1130
1115
|
var _a, _b, _c;
|
|
1131
1116
|
return (React.createElement(TreeNode, { key: attr.value, value: attr.value, selectable: !((_a = attr === null || attr === void 0 ? void 0 : attr.children) === null || _a === void 0 ? void 0 : _a.length), title: ((_b = attr.children) === null || _b === void 0 ? void 0 : _b.length) ? (React.createElement("div", { onClick: () => handleOnClickParentNode(attr) }, attr.label)) : (attr.label) }, (_c = buildOptionAttrArchive(attr === null || attr === void 0 ? void 0 : attr.children, selectedAttr)) === null || _c === void 0 ? void 0 : _c.map((item) => (React.createElement(TreeNode, { key: item.value, value: item.value, title: item.label })))));
|
|
@@ -1137,22 +1122,22 @@ export const AddDynamicContent = props => {
|
|
|
1137
1122
|
if (hasError[DYNAMIC_CONTENT_SETTING_KEY.EVENT]) {
|
|
1138
1123
|
return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.eventBySource)));
|
|
1139
1124
|
}
|
|
1140
|
-
return (React.createElement(Form.Item, {
|
|
1141
|
-
React.createElement(Select, { disabled: !!(triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.eventActionId) && !!(triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.eventCategoryId), loading: isFetchingEventBySource,
|
|
1125
|
+
return (React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.selectEvent), name: DYNAMIC_CONTENT_SETTING_KEY.EVENT, required: true, preserve: false },
|
|
1126
|
+
React.createElement(Select, { disabled: !!(triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.eventActionId) && !!(triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.eventCategoryId), loading: isFetchingEventBySource, style: { height: 28 }, options: listEvents, showSearch: true })));
|
|
1142
1127
|
};
|
|
1143
1128
|
const renderSourceFields = () => {
|
|
1144
1129
|
if (hasError[DYNAMIC_CONTENT_SETTING_KEY.SOURCE]) {
|
|
1145
1130
|
return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.source)));
|
|
1146
1131
|
}
|
|
1147
|
-
return (React.createElement(Form.Item, {
|
|
1132
|
+
return (React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.selectSource), name: DYNAMIC_CONTENT_SETTING_KEY.SOURCE, required: true },
|
|
1148
1133
|
React.createElement(Select, { disabled: !isEmpty(triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.insightPropertyIds), mode: "multiple", loading: isFetchingSourceBO, options: listSources, showSearch: true })));
|
|
1149
1134
|
};
|
|
1150
1135
|
const renderPromotionCodeAttr = () => {
|
|
1151
1136
|
if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
|
|
1152
1137
|
return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.promotionCodeAttr)));
|
|
1153
1138
|
}
|
|
1154
|
-
return (React.createElement(Form.Item, {
|
|
1155
|
-
React.createElement(Select, { loading: isFetchingPromotionCodeAttr,
|
|
1139
|
+
return (React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.promotionCodeAttr), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
|
|
1140
|
+
React.createElement(Select, { loading: isFetchingPromotionCodeAttr, style: { height: 28 }, labelInValue: true, options: buildOptionAttrArchive(listPromotionCodeAttributes || [], selectedAttr), showSearch: true,
|
|
1156
1141
|
// errorArchive={errorMessageAttr}
|
|
1157
1142
|
disabled: isActionArchive })));
|
|
1158
1143
|
};
|
|
@@ -1160,17 +1145,15 @@ export const AddDynamicContent = props => {
|
|
|
1160
1145
|
if (hasError[DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL]) {
|
|
1161
1146
|
return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.promotionPools)));
|
|
1162
1147
|
}
|
|
1163
|
-
return (React.createElement(Form.Item, {
|
|
1164
|
-
|
|
1165
|
-
label: t(translations.dynamicContent.modal.label.promotionPools), name: DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL, required: true },
|
|
1166
|
-
React.createElement(Select, { loading: isFetchingPromotionPool, className: classnames('ants-h-7'), options: listPromotionPools, showSearch: true })));
|
|
1148
|
+
return (React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.promotionPools), name: DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL, required: true },
|
|
1149
|
+
React.createElement(Select, { loading: isFetchingPromotionPool, style: { height: 28 }, options: listPromotionPools, showSearch: true })));
|
|
1167
1150
|
};
|
|
1168
1151
|
const renderVisitorAttrFields = () => {
|
|
1169
1152
|
if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
|
|
1170
1153
|
return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.visitorAttr)));
|
|
1171
1154
|
}
|
|
1172
|
-
return (React.createElement(Form.Item, {
|
|
1173
|
-
React.createElement(Select, { loading: isFetchingDynamicContentAttr,
|
|
1155
|
+
return (React.createElement(Form.Item, { style: { alignItems: 'center' }, initialValue: listVisitorAttributes[0], label: t(translations.dynamicContent.modal.label.attribute), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
|
|
1156
|
+
React.createElement(Select, { loading: isFetchingDynamicContentAttr, style: { height: 28 }, labelInValue: true, options: buildOptionAttrArchive(listVisitorAttributes, selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.value), showSearch: true,
|
|
1174
1157
|
// errorArchive={errorMessageAttr}
|
|
1175
1158
|
disabled: isActionArchive })));
|
|
1176
1159
|
};
|
|
@@ -1183,19 +1166,33 @@ export const AddDynamicContent = props => {
|
|
|
1183
1166
|
!attrDFOptions.length)
|
|
1184
1167
|
return null;
|
|
1185
1168
|
if (selectedAttr.dataType === 'number' || selectedAttr.dataType === 'datetime')
|
|
1186
|
-
return (React.createElement(Form.Item, { initialValue: attrDFOptions[0].value,
|
|
1169
|
+
return (React.createElement(Form.Item, { initialValue: attrDFOptions[0].value, style: { alignItems: 'start' }, label: t(translations.dynamicContent.modal.label.displayFormat), name: DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE, extra: React.createElement("div", { style: {
|
|
1170
|
+
display: 'flex',
|
|
1171
|
+
flexWrap: 'wrap',
|
|
1172
|
+
alignItems: 'center',
|
|
1173
|
+
gap: '8px',
|
|
1174
|
+
marginTop: '16px',
|
|
1175
|
+
} },
|
|
1187
1176
|
React.createElement(Text, { color: "#555", dangerouslySetInnerHTML: {
|
|
1188
1177
|
__html: `${t(translations.dynamicContent.modal.label.displayFormat)}: <bdo dir='ltr'>${formatedAttr}</bdo>`,
|
|
1189
1178
|
} }),
|
|
1190
1179
|
!showDetailEditDF && (React.createElement(Button, { disabled: isActionArchive &&
|
|
1191
|
-
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, type: "text",
|
|
1180
|
+
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, type: "text", style: { display: 'inline-block' }, onClick: () => setShowDetailEditDF(prevShow => !prevShow) }, t(translations.edit.title)))) },
|
|
1192
1181
|
React.createElement(Select, { disabled: isActionArchive &&
|
|
1193
|
-
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value,
|
|
1182
|
+
selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, style: { height: 28 }, options: attrDFOptions })));
|
|
1194
1183
|
return null;
|
|
1195
1184
|
};
|
|
1196
1185
|
const renderDetailDFSettings = () => {
|
|
1197
1186
|
if (showDetailEditDF && selectedDFType && attrDFSettings)
|
|
1198
|
-
return (React.createElement("div", {
|
|
1187
|
+
return (React.createElement("div", { style: {
|
|
1188
|
+
border: '1px solid #9e9e9e',
|
|
1189
|
+
borderRadius: '2px',
|
|
1190
|
+
padding: '8px',
|
|
1191
|
+
marginTop: '8px',
|
|
1192
|
+
display: 'flex',
|
|
1193
|
+
flexDirection: 'column',
|
|
1194
|
+
gap: '8px',
|
|
1195
|
+
} },
|
|
1199
1196
|
React.createElement(DisplayFormat, { infos: infos, url: url, displayFormatType: selectedDFType, formatSettings: attrDFSettings, onSettingsChange: (values) => setAttrDFSettings(values), dynamicContentType: form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE) })));
|
|
1200
1197
|
};
|
|
1201
1198
|
return (React.createElement(ModalCustom, { closable: false, destroyOnClose: true, forceRender: true, mask: true, okButtonProps: { disabled: formSubmitDisabled }, title: modalTitle || t(translations.dynamicContent.modal.title.addDynamicContent), visible: visible, onCancel: handleOnCancelModal, onOk: handleOnOkModal },
|
|
@@ -1205,11 +1202,11 @@ export const AddDynamicContent = props => {
|
|
|
1205
1202
|
isFetchingPromotionPool ||
|
|
1206
1203
|
isFetchingPromotionCodeAttr ||
|
|
1207
1204
|
isFetchingDynamicContentAttr },
|
|
1208
|
-
React.createElement(Form, {
|
|
1205
|
+
React.createElement(Form, { style: { width: '100%' }, form: form, labelAlign: "left", labelCol: { span: 9 }, wrapperCol: { span: 15 }, onValuesChange: handleFormValuesChanges, initialValues: {
|
|
1209
1206
|
[DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE]: listDynamicContentTypes[0].value,
|
|
1210
1207
|
} },
|
|
1211
|
-
React.createElement(Form.Item, {
|
|
1212
|
-
React.createElement(Select, {
|
|
1208
|
+
React.createElement(Form.Item, { style: { alignItems: 'center' }, label: t(translations.dynamicContent.modal.label.contentSource), name: DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE, required: true },
|
|
1209
|
+
React.createElement(Select, { style: { height: 28 }, options: listDynamicContentTypes })),
|
|
1213
1210
|
selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.VISITOR_ATTRIBUTE.value && (React.createElement(React.Fragment, null, renderVisitorAttrFields())),
|
|
1214
1211
|
selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.CUSTOMER_ATTRIBUTE.value && (React.createElement(React.Fragment, null, renderCustomerAttrFields())),
|
|
1215
1212
|
selectedDynamicContentType === CUSTOM_TYPE.value && React.createElement(React.Fragment, null, renderCustomFunctionFields()),
|
|
@@ -1228,7 +1225,13 @@ export const AddDynamicContent = props => {
|
|
|
1228
1225
|
renderIndexFields({ disabled: isActionArchive, loading: isFetchingListBoAttr }))),
|
|
1229
1226
|
showDisplayFormat && renderDisplayFormat()),
|
|
1230
1227
|
showDisplayFormat && renderDisplayFormat() !== null && renderDetailDFSettings(),
|
|
1231
|
-
isShowCustomFunction && selectedDynamicContentType === CUSTOM_TYPE.value && (React.createElement("div", {
|
|
1228
|
+
isShowCustomFunction && selectedDynamicContentType === CUSTOM_TYPE.value && (React.createElement("div", { style: {
|
|
1229
|
+
display: 'flex',
|
|
1230
|
+
alignItems: 'center',
|
|
1231
|
+
justifyContent: 'start',
|
|
1232
|
+
marginBottom: '8px',
|
|
1233
|
+
marginTop: '10px',
|
|
1234
|
+
} },
|
|
1232
1235
|
React.createElement(Checkbox, { onChange: handleSaveAsTemplate, checked: saveAsTemplate },
|
|
1233
1236
|
React.createElement("span", { style: { fontSize: '12px' } }, t(translations.dynamicContent.modal.label.saveTemplate))))))));
|
|
1234
1237
|
};
|
package/es/components/molecules/AddDynamicContent/components/FormatDatetime/FormatDatetime.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Libraries
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
5
|
// Locales
|
|
7
6
|
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
7
|
+
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
8
8
|
// Atoms
|
|
9
9
|
import { Checkbox, Radio, Space } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
10
10
|
// Molecules
|
|
@@ -12,12 +12,11 @@ import { RadioGroup } from '../../../RadioGroup';
|
|
|
12
12
|
import { Select } from '../../../Select';
|
|
13
13
|
// Utils
|
|
14
14
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
15
|
-
// Utils
|
|
16
15
|
import { transformDateFormat } from '../../utils';
|
|
17
16
|
dayjs.extend(customParseFormat);
|
|
18
17
|
export const dateExample = dayjs('2020-04-15 18:23:11');
|
|
19
18
|
const FormatDatetime = ({ hasDateFormat, hasTimeFormat, dateParseFormat, timeParseFormat, dateParseOption, timeParseOption, onSettingsChange, dynamicContentType, }) => {
|
|
20
|
-
const { t,
|
|
19
|
+
const { t, language: portalLanguage } = i18nInstance;
|
|
21
20
|
const dfSettings = {
|
|
22
21
|
hasDateFormat,
|
|
23
22
|
hasTimeFormat,
|
|
@@ -37,9 +36,9 @@ const FormatDatetime = ({ hasDateFormat, hasTimeFormat, dateParseFormat, timePar
|
|
|
37
36
|
};
|
|
38
37
|
const labelHours = dynamicContentType !== 'custom' ? 'HH:MM:SS' : '';
|
|
39
38
|
return (React.createElement("div", null,
|
|
40
|
-
React.createElement("div", {
|
|
39
|
+
React.createElement("div", { style: { display: 'flex', alignItems: 'center', gap: '16px' } },
|
|
41
40
|
React.createElement(Checkbox, { checked: hasDateFormat, disabled: hasDateFormat && !hasTimeFormat, onChange: e => handleChange(Object.assign(Object.assign({}, dfSettings), { hasDateFormat: e.target.checked })) }, t(translations.dynamicContent.modal.label.datimeDisplayFormat.dateDF)),
|
|
42
|
-
React.createElement(Select, {
|
|
41
|
+
React.createElement(Select, { style: { width: 190 }, disabled: !hasDateFormat, defaultValue: dateParseFormat, options: [
|
|
43
42
|
{
|
|
44
43
|
label: `MM/DD/YYYY ${labelHours}`,
|
|
45
44
|
value: 'MM/DD/YYYY',
|
|
@@ -53,9 +52,9 @@ const FormatDatetime = ({ hasDateFormat, hasTimeFormat, dateParseFormat, timePar
|
|
|
53
52
|
value: 'YYYY/MM/DD',
|
|
54
53
|
},
|
|
55
54
|
], onChange: value => handleChange(Object.assign(Object.assign({}, dfSettings), { dateParseFormat: value })) })),
|
|
56
|
-
React.createElement("div", {
|
|
55
|
+
React.createElement("div", { style: { marginTop: '8px' } },
|
|
57
56
|
React.createElement(RadioGroup, { disabled: !hasDateFormat, defaultValue: dateParseOption, onChange: e => handleChange(Object.assign(Object.assign({}, dfSettings), { dateParseOption: e.target.value })) },
|
|
58
|
-
React.createElement(Space, { direction: "vertical", size: 4,
|
|
57
|
+
React.createElement(Space, { direction: "vertical", size: 4, style: { marginLeft: '20px' } },
|
|
59
58
|
React.createElement(Radio, { value: "short" },
|
|
60
59
|
t(translations.dynamicContent.modal.label.datimeDisplayFormat.short),
|
|
61
60
|
' - ',
|
|
@@ -68,9 +67,9 @@ const FormatDatetime = ({ hasDateFormat, hasTimeFormat, dateParseFormat, timePar
|
|
|
68
67
|
t(translations.dynamicContent.modal.label.datimeDisplayFormat.long),
|
|
69
68
|
' - ',
|
|
70
69
|
datetimeEx.format(transformDateFormat(dateParseFormat, 'long')))))),
|
|
71
|
-
React.createElement("div", {
|
|
70
|
+
React.createElement("div", { style: { display: 'flex', alignItems: 'center', gap: '16px', marginTop: 16 } },
|
|
72
71
|
React.createElement(Checkbox, { checked: hasTimeFormat, disabled: hasTimeFormat && !hasDateFormat, onChange: e => handleChange(Object.assign(Object.assign({}, dfSettings), { hasTimeFormat: e.target.checked })) }, t(translations.dynamicContent.modal.label.datimeDisplayFormat.timeDF)),
|
|
73
|
-
React.createElement(Select, {
|
|
72
|
+
React.createElement(Select, { style: { width: 190 }, disabled: !hasTimeFormat, defaultValue: timeParseFormat, options: [
|
|
74
73
|
{
|
|
75
74
|
label: 'AM/PM',
|
|
76
75
|
value: '12hour',
|
|
@@ -80,9 +79,9 @@ const FormatDatetime = ({ hasDateFormat, hasTimeFormat, dateParseFormat, timePar
|
|
|
80
79
|
value: '24hour',
|
|
81
80
|
},
|
|
82
81
|
], onChange: value => handleChange(Object.assign(Object.assign({}, dfSettings), { timeParseFormat: value })) })),
|
|
83
|
-
React.createElement("div", {
|
|
82
|
+
React.createElement("div", { style: { marginTop: '8px' } },
|
|
84
83
|
React.createElement(RadioGroup, { defaultValue: timeParseOption, disabled: !hasTimeFormat, onChange: e => handleChange(Object.assign(Object.assign({}, dfSettings), { timeParseOption: e.target.value })) },
|
|
85
|
-
React.createElement(Space, { direction: "vertical", size: 4,
|
|
84
|
+
React.createElement(Space, { direction: "vertical", size: 4, style: { marginLeft: '20px' } },
|
|
86
85
|
React.createElement(Radio, { value: "short" },
|
|
87
86
|
t(translations.dynamicContent.modal.label.datimeDisplayFormat.short),
|
|
88
87
|
' - ',
|
|
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
// Libraries
|
|
11
11
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
12
|
-
import classnames from 'classnames';
|
|
13
12
|
// Components
|
|
14
13
|
import { Radio } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
15
|
-
import { Col, Row, Tooltip,
|
|
14
|
+
import { Col, Row, Tooltip, Form, Select, Checkbox } from 'antd';
|
|
16
15
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
16
|
+
import { ButtonCustom } from '../../styled';
|
|
17
17
|
// Json
|
|
18
18
|
import Currencies from '../../currencies.json';
|
|
19
19
|
// Constants
|
|
@@ -22,11 +22,11 @@ import { ATTRIBUTE_NUMBERIC_FORMAT_OPTION } from '../../constants';
|
|
|
22
22
|
import { getCurrencyList } from '@antscorp/antsomi-ui/es/services/MediaTemplateDesign/ListCurrency';
|
|
23
23
|
// Locales
|
|
24
24
|
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
25
|
-
import
|
|
25
|
+
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
26
26
|
const groupingOptions = ATTRIBUTE_NUMBERIC_FORMAT_OPTION.GROUPING_SEPARATOR;
|
|
27
27
|
const decimalOptions = ATTRIBUTE_NUMBERIC_FORMAT_OPTION.DECIMAL_SEPARATOR;
|
|
28
28
|
const FormatNumber = (props) => {
|
|
29
|
-
const { t,
|
|
29
|
+
const { t, language } = i18nInstance;
|
|
30
30
|
const { onSettingsChange, type: displayType, infos, url } = props;
|
|
31
31
|
const { currencyCode, decimalPlaces, grouping, decimal, prefixType, isCompact } = props;
|
|
32
32
|
const settingValues = {
|
|
@@ -97,36 +97,36 @@ const FormatNumber = (props) => {
|
|
|
97
97
|
const listDecimalSeparatorOptions = useMemo(() => Object.values(decimalOptions)
|
|
98
98
|
.sort((a, b) => a.index - b.index)
|
|
99
99
|
.map(decimal => (Object.assign(Object.assign({}, decimal), (decimal.value === grouping && { disabled: true })))), [grouping]);
|
|
100
|
-
return (React.createElement(Form, {
|
|
100
|
+
return (React.createElement(Form, { style: { width: '100%', fontSize: '12px' }, labelAlign: "left" },
|
|
101
101
|
displayType === 'currency' && (React.createElement(React.Fragment, null,
|
|
102
102
|
React.createElement(Form.Item, { labelCol: { span: 8 }, wrapperCol: { span: 16 }, label: t(translations.dynamicContent.modal.label.formNumberDisplayFormat.currency), colon: false },
|
|
103
103
|
React.createElement(Radio.Group, { value: prefixType, onChange: ({ target: { value } }) => onChangeSettingsHandle(Object.assign(Object.assign({}, settingValues), { prefixType: value })) },
|
|
104
104
|
React.createElement(Radio, { style: { fontSize: 12 }, value: "code" }, t(translations.dynamicContent.modal.label.formNumberDisplayFormat.currencyCode)),
|
|
105
105
|
React.createElement(Radio, { style: { fontSize: 12 }, value: "symbol" }, t(translations.dynamicContent.modal.label.formNumberDisplayFormat.currencySymbol)))),
|
|
106
106
|
React.createElement(Form.Item, { label: " ", labelCol: { span: 8 }, wrapperCol: { span: 16 }, colon: false },
|
|
107
|
-
React.createElement(Select, {
|
|
107
|
+
React.createElement(Select, { style: { height: 28 }, disabled: isLoadingCurrencyOptions, options: listCurrencyOptions, value: currencyCode, onChange: value => onChangeSettingsHandle(Object.assign(Object.assign({}, settingValues), { currencyCode: value })), showSearch: true })))),
|
|
108
108
|
React.createElement(Form.Item, null,
|
|
109
109
|
React.createElement(Checkbox, { style: { fontSize: 12 }, checked: isCompact, onChange: ({ target: { checked } }) => {
|
|
110
110
|
onChangeSettingsHandle(Object.assign(Object.assign({}, settingValues), { isCompact: checked }));
|
|
111
111
|
} }, t(translations.dynamicContent.modal.label.formNumberDisplayFormat.compact))),
|
|
112
|
-
React.createElement(Form.Item, { label: `${t(translations.dynamicContent.modal.label.formNumberDisplayFormat.decimalPlace)} (${decimalPlaces})`,
|
|
113
|
-
React.createElement("div", {
|
|
114
|
-
React.createElement(
|
|
115
|
-
React.createElement(
|
|
112
|
+
React.createElement(Form.Item, { label: `${t(translations.dynamicContent.modal.label.formNumberDisplayFormat.decimalPlace)} (${decimalPlaces})`, style: { marginBottom: 12 }, colon: false },
|
|
113
|
+
React.createElement("div", { style: { display: 'flex', marginLeft: 40 } },
|
|
114
|
+
React.createElement(ButtonCustom, { disabled: decimalPlaces <= 0, onClick: () => onChangeSettingsHandle(Object.assign(Object.assign({}, settingValues), { decimalPlaces: decimalPlaces - 1 })) }, '<< .0'),
|
|
115
|
+
React.createElement(ButtonCustom, { onClick: () => onChangeSettingsHandle(Object.assign(Object.assign({}, settingValues), { decimalPlaces: decimalPlaces + 1 })) }, '.00 >>'))),
|
|
116
116
|
React.createElement(Row, { gutter: 15 },
|
|
117
117
|
React.createElement(Col, { span: 12 },
|
|
118
118
|
React.createElement(Form.Item, { label: React.createElement("span", null,
|
|
119
119
|
t(translations.dynamicContent.modal.label.formNumberDisplayFormat.grouping),
|
|
120
120
|
React.createElement(Tooltip, { placement: "top", title: t(translations.dynamicContent.modal.label.formNumberDisplayFormat
|
|
121
|
-
.groupingIconTooltipTitle),
|
|
121
|
+
.groupingIconTooltipTitle), style: { marginLeft: 4, opacity: 0.4 } },
|
|
122
122
|
React.createElement(FontAwesomeIcon, { icon: ['fas', 'info-circle'] }))), colon: false },
|
|
123
|
-
React.createElement(Select, {
|
|
123
|
+
React.createElement(Select, { style: { height: 28 }, value: grouping, onChange: value => onChangeSettingsHandle(Object.assign(Object.assign({}, settingValues), { grouping: value })), options: listGroupingSeparatorOptions }))),
|
|
124
124
|
React.createElement(Col, { span: 12 },
|
|
125
125
|
React.createElement(Form.Item, { label: React.createElement("span", null,
|
|
126
126
|
t(translations.dynamicContent.modal.label.formNumberDisplayFormat.decimal),
|
|
127
127
|
React.createElement(Tooltip, { placement: "top", title: t(translations.dynamicContent.modal.label.formNumberDisplayFormat
|
|
128
|
-
.decimalIconTooltipTitle),
|
|
128
|
+
.decimalIconTooltipTitle), style: { marginLeft: 4, opacity: 0.4 } },
|
|
129
129
|
React.createElement(FontAwesomeIcon, { icon: ['fas', 'info-circle'] }))), colon: false },
|
|
130
|
-
React.createElement(Select, {
|
|
130
|
+
React.createElement(Select, { style: { height: 28 }, value: decimal, onChange: value => onChangeSettingsHandle(Object.assign(Object.assign({}, settingValues), { decimal: value })), options: listDecimalSeparatorOptions }))))));
|
|
131
131
|
};
|
|
132
132
|
export default FormatNumber;
|
|
@@ -20,7 +20,7 @@ export declare const DYNAMIC_CONTENT_TYPE_KEY: {
|
|
|
20
20
|
readonly EVENT_ATTRIBUTE: "event-attribute";
|
|
21
21
|
readonly PROMOTION_CODE: "promotion-code";
|
|
22
22
|
readonly VISITOR_ATTRIBUTE: "visitor-attribute";
|
|
23
|
-
readonly CUSTOM_FUNCTION: "custom
|
|
23
|
+
readonly CUSTOM_FUNCTION: "custom";
|
|
24
24
|
};
|
|
25
25
|
export declare const DYNAMIC_CONTENT_TYPE: {
|
|
26
26
|
[key: string]: {
|
|
@@ -19,7 +19,7 @@ export const DYNAMIC_CONTENT_TYPE_KEY = {
|
|
|
19
19
|
EVENT_ATTRIBUTE: 'event-attribute',
|
|
20
20
|
PROMOTION_CODE: 'promotion-code',
|
|
21
21
|
VISITOR_ATTRIBUTE: 'visitor-attribute',
|
|
22
|
-
CUSTOM_FUNCTION: 'custom
|
|
22
|
+
CUSTOM_FUNCTION: 'custom',
|
|
23
23
|
};
|
|
24
24
|
export const DYNAMIC_CONTENT_TYPE = {
|
|
25
25
|
BO_SETTINGS: {
|
|
@@ -7,3 +7,6 @@ export declare const InputSuggestion: import("styled-components").StyledComponen
|
|
|
7
7
|
_InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/_util/type").AnyObject) => import("react").JSX.Element;
|
|
8
8
|
}, any, {}, never>;
|
|
9
9
|
export declare const ModalCustom: import("styled-components").StyledComponent<import("react").ComponentType<any> | keyof import("react").JSX.IntrinsicElements, any, import("../Modal/styled").CustomModalProps, any>;
|
|
10
|
+
export declare const ButtonCustom: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").ButtonProps & import("react").RefAttributes<HTMLElement>> & {
|
|
11
|
+
Group: import("react").FC<import("antd/es/button").ButtonGroupProps>;
|
|
12
|
+
}, any, {}, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Libraries
|
|
2
|
-
import { AutoComplete } from 'antd';
|
|
2
|
+
import { AutoComplete, Button } from 'antd';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { Modal } from '../Modal';
|
|
5
5
|
export const InputSuggestion = styled(AutoComplete) `
|
|
@@ -16,3 +16,15 @@ export const ModalCustom = styled(Modal) `
|
|
|
16
16
|
max-height: 500px;
|
|
17
17
|
}
|
|
18
18
|
`;
|
|
19
|
+
export const ButtonCustom = styled(Button) `
|
|
20
|
+
width: 64px;
|
|
21
|
+
background-color: rgb(191 219 254);
|
|
22
|
+
|
|
23
|
+
&:hover {
|
|
24
|
+
background-color: rgb(147 197 253);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:focus {
|
|
28
|
+
background-color: rgb(147 197 253);
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import { i18n } from 'i18next';
|
|
3
2
|
import type { TDatetimeFormatSetting, TNumberFormatSettings } from './components';
|
|
4
3
|
import { LabeledTreeValue, LabeledValue } from './AddDynamicContent';
|
|
5
4
|
export declare function getStringFormatDateDF(formatSettings: TDatetimeFormatSetting): string;
|
|
@@ -13,14 +12,14 @@ export declare const serializeCSSelectedString: (value?: string) => {
|
|
|
13
12
|
groupId: string;
|
|
14
13
|
itemTypeId: number;
|
|
15
14
|
};
|
|
16
|
-
export declare const serilizeDynamicContentAttr: (attrs: any[] | undefined,
|
|
15
|
+
export declare const serilizeDynamicContentAttr: (attrs: any[] | undefined, language: any, additionalAttrProperties?: string[]) => {
|
|
17
16
|
label: any;
|
|
18
17
|
value: any;
|
|
19
18
|
dataType: any;
|
|
20
19
|
disabled: boolean;
|
|
21
20
|
status: any;
|
|
22
21
|
}[];
|
|
23
|
-
export declare const serilizeEventAttr: (attrs: any[] | undefined,
|
|
22
|
+
export declare const serilizeEventAttr: (attrs: any[] | undefined, language: any, additionalAttrProperties?: string[]) => LabeledTreeValue[];
|
|
24
23
|
export declare const serilizePromotionPool: (data: any, additionalAttrProperties?: string[]) => LabeledValue[];
|
|
25
24
|
export declare const CUSTOM_TYPE: {
|
|
26
25
|
index: number;
|
|
@@ -9,8 +9,6 @@ import Currencies from './currencies.json';
|
|
|
9
9
|
import { ATTRIBUTE_STATUS, BO_STATUS, DYNAMIC_CONTENT_TYPE } from './constants';
|
|
10
10
|
// Models
|
|
11
11
|
import { ListAttribute } from '@antscorp/antsomi-ui/es/models/BusinessObject';
|
|
12
|
-
// Locales
|
|
13
|
-
import { getTranslateMessage, translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
14
12
|
export function getStringFormatDateDF(formatSettings) {
|
|
15
13
|
const { hasDateFormat, hasTimeFormat, timeParseFormat, dateParseFormat, timeParseOption, dateParseOption, } = formatSettings;
|
|
16
14
|
let dateFormat = '';
|
|
@@ -208,9 +206,9 @@ export const serializeCSSelectedString = (value = '') => {
|
|
|
208
206
|
itemTypeId: Number(itemTypeId),
|
|
209
207
|
};
|
|
210
208
|
};
|
|
211
|
-
export const serilizeDynamicContentAttr = (attrs = [],
|
|
209
|
+
export const serilizeDynamicContentAttr = (attrs = [], language, additionalAttrProperties) => attrs.map(attr => {
|
|
212
210
|
const temp = {
|
|
213
|
-
label: attr.label[
|
|
211
|
+
label: attr.label[language && language.toUpperCase()] ||
|
|
214
212
|
attr.label[get(attr, 'label.DEFAULT_LANG')] ||
|
|
215
213
|
attr.defaultLabel,
|
|
216
214
|
value: attr.value,
|
|
@@ -224,7 +222,7 @@ export const serilizeDynamicContentAttr = (attrs = [], i18n, additionalAttrPrope
|
|
|
224
222
|
});
|
|
225
223
|
return temp;
|
|
226
224
|
});
|
|
227
|
-
export const serilizeEventAttr = (attrs = [],
|
|
225
|
+
export const serilizeEventAttr = (attrs = [], language, additionalAttrProperties) => attrs.map(row => {
|
|
228
226
|
var _a;
|
|
229
227
|
const event = new ListAttribute(row);
|
|
230
228
|
const temp = {
|
|
@@ -244,7 +242,7 @@ export const serilizeEventAttr = (attrs = [], i18n, additionalAttrProperties) =>
|
|
|
244
242
|
itemTypeName: event.itemTypeName,
|
|
245
243
|
propertyName: child.itemPropertyName,
|
|
246
244
|
eventPropertySyntax: child.eventPropertySyntax,
|
|
247
|
-
label: child.propertyDisplayMultilang[
|
|
245
|
+
label: child.propertyDisplayMultilang[language] ||
|
|
248
246
|
child.propertyDisplayMultilang[get(child, "propertyDisplayMultilang['DEFAULT_LANG']")] ||
|
|
249
247
|
child.itemPropertyDisplay,
|
|
250
248
|
children: [],
|
|
@@ -278,8 +276,8 @@ export const serilizePromotionPool = (data, additionalAttrProperties) => data.ro
|
|
|
278
276
|
});
|
|
279
277
|
export const CUSTOM_TYPE = {
|
|
280
278
|
index: 0,
|
|
281
|
-
label:
|
|
282
|
-
value:
|
|
279
|
+
label: 'Custom Function',
|
|
280
|
+
value: 'custom',
|
|
283
281
|
};
|
|
284
282
|
export const buildOptionAttrArchive = (list, selected) => {
|
|
285
283
|
const arrSelected = Array.isArray(selected) ? selected : [selected];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { IAceEditorProps } from 'react-ace';
|
|
3
|
+
import 'ace-builds/webpack-resolver';
|
|
4
|
+
import 'ace-builds/src-noconflict/mode-javascript';
|
|
5
|
+
import 'ace-builds/src-noconflict/mode-css';
|
|
6
|
+
import 'ace-builds/src-noconflict/theme-tomorrow';
|
|
7
|
+
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
8
|
+
interface EditorScriptProps extends IAceEditorProps {
|
|
9
|
+
label?: string | ReactNode;
|
|
10
|
+
expandModalLabel?: string | ReactNode;
|
|
11
|
+
hideExpand?: boolean | ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare const EditorScript: React.FC<EditorScriptProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
// Libraries
|
|
13
|
+
import React, { useState } from 'react';
|
|
14
|
+
import AceEditor from 'react-ace';
|
|
15
|
+
// Translations
|
|
16
|
+
import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
|
|
17
|
+
import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
|
|
18
|
+
// Atoms
|
|
19
|
+
import { Button, Icon } from '../../atoms';
|
|
20
|
+
// Molecules
|
|
21
|
+
import { Modal } from '../Modal';
|
|
22
|
+
// Styled
|
|
23
|
+
import { EditorScriptWrapper } from './styled';
|
|
24
|
+
// Ace editor
|
|
25
|
+
import 'ace-builds/webpack-resolver';
|
|
26
|
+
import 'ace-builds/src-noconflict/mode-javascript';
|
|
27
|
+
import 'ace-builds/src-noconflict/mode-css';
|
|
28
|
+
import 'ace-builds/src-noconflict/theme-tomorrow';
|
|
29
|
+
import 'ace-builds/src-noconflict/ext-language_tools';
|
|
30
|
+
// Utils
|
|
31
|
+
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
32
|
+
const PATH = 'src/components/molecules/EditorScript/EditorScript.tsx';
|
|
33
|
+
export const EditorScript = props => {
|
|
34
|
+
// Props
|
|
35
|
+
const { label, expandModalLabel, className, height, setOptions, hideExpand } = props, restOf = __rest(props, ["label", "expandModalLabel", "className", "height", "setOptions", "hideExpand"]);
|
|
36
|
+
// State
|
|
37
|
+
const [isExpandEditor, setExpandEditor] = useState(false);
|
|
38
|
+
const { t } = i18nInstance;
|
|
39
|
+
const renderAceEditor = (aceHeight = height) => {
|
|
40
|
+
try {
|
|
41
|
+
return (React.createElement(AceEditor, Object.assign({ setOptions: Object.assign({ enableBasicAutocompletion: true, enableLiveAutocompletion: true, enableSnippets: true, showLineNumbers: true, tabSize: 2 }, setOptions) }, restOf, { style: { width: '100%', height: aceHeight } })));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
handleError(error, {
|
|
45
|
+
path: PATH,
|
|
46
|
+
name: 'renderAceEditor',
|
|
47
|
+
args: {},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const onCancelModal = () => {
|
|
52
|
+
try {
|
|
53
|
+
setExpandEditor(false);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
handleError(error, {
|
|
57
|
+
path: PATH,
|
|
58
|
+
name: 'onCancelModal',
|
|
59
|
+
args: {},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return (React.createElement(React.Fragment, null,
|
|
64
|
+
React.createElement(EditorScriptWrapper, { className: className },
|
|
65
|
+
label && React.createElement("div", { className: "ants-mb-5" }, label),
|
|
66
|
+
renderAceEditor(),
|
|
67
|
+
!hideExpand && (React.createElement(Button, { type: "text", className: "ants-mt-5px", onClick: () => {
|
|
68
|
+
setExpandEditor(true);
|
|
69
|
+
} },
|
|
70
|
+
React.createElement(Icon, { type: "icon-ants-expand", size: 14, style: {
|
|
71
|
+
transform: 'scaleX(-1)',
|
|
72
|
+
} }),
|
|
73
|
+
t(translations.expandEditor.title)))),
|
|
74
|
+
React.createElement(Modal, { visible: isExpandEditor, title: expandModalLabel, onCancel: onCancelModal, centered: true, width: 1000, footer: React.createElement(Button, { onClick: onCancelModal }, t(translations.close)) }, renderAceEditor('500px'))));
|
|
75
|
+
};
|
|
76
|
+
EditorScript.defaultProps = {
|
|
77
|
+
expandModalLabel: 'Editor Script',
|
|
78
|
+
mode: 'javascript',
|
|
79
|
+
theme: 'tomorrow',
|
|
80
|
+
name: 'Editor Script',
|
|
81
|
+
placeholder: '',
|
|
82
|
+
fontSize: 12,
|
|
83
|
+
showPrintMargin: true,
|
|
84
|
+
showGutter: true,
|
|
85
|
+
highlightActiveLine: true,
|
|
86
|
+
setOptions: {},
|
|
87
|
+
hideExpand: false,
|
|
88
|
+
height: '267px',
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EditorScript';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EditorScript';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EditorScriptWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -51,7 +51,7 @@ const SORT_OPTIONS = {
|
|
|
51
51
|
};
|
|
52
52
|
const PATH = '@antscorp/antsomi-ui/es/components/molecules/UploadImage/index.tsx';
|
|
53
53
|
export const UploadImage = props => {
|
|
54
|
-
var _a, _b, _c, _d, _e;
|
|
54
|
+
var _a, _b, _c, _d, _e, _f;
|
|
55
55
|
const { labelHeadingModal, labelButtonSelect, labelModalDelete, searchPlaceholder, onRemoveImage, onChangeImage: onChangeMedia, isOpen, isInputMode, width, placeholder, extensions, maxSize, title, showImageURL: showMediaURL, selectedImage: selectedMediaProp, required, focused, domainMedia, slug, paramConfigs, errors, iconName, mode, } = props;
|
|
56
56
|
const { Dragger } = Upload;
|
|
57
57
|
const [storeSavedMedia, setStoreSavedMedia] = useState([]);
|
|
@@ -287,8 +287,11 @@ export const UploadImage = props => {
|
|
|
287
287
|
React.createElement(Input, { required: required, status: errors && (errors === null || errors === void 0 ? void 0 : errors.length) > 0 ? 'error' : '', placeholder: placeholder, value: selectedMedia.url ? selectedMedia.url : '', focused: focused, style: { paddingRight: 40 }, onAfterChange: value => handleSelectMedia({
|
|
288
288
|
url: value,
|
|
289
289
|
}) }),
|
|
290
|
-
React.createElement(WrapperIcon, { onClick: showModal },
|
|
291
|
-
|
|
290
|
+
React.createElement(WrapperIcon, { onClick: showModal }, mode === 'video' ? (React.createElement(Icon, { type: "icon-ants-video", size: 24, style: {
|
|
291
|
+
zIndex: 1,
|
|
292
|
+
marginLeft: 2,
|
|
293
|
+
color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorIcon,
|
|
294
|
+
} })) : (React.createElement(MediaIcon, null))),
|
|
292
295
|
isError && React.createElement(ErrorMessage, null, errors && (errors === null || errors === void 0 ? void 0 : errors.length) > 0 ? errors[0] : ''))) : (React.createElement(UploadImageWrapper, null,
|
|
293
296
|
title ? React.createElement(Text, { style: { marginTop: 10 } }, title) : null,
|
|
294
297
|
React.createElement("div", { className: `image-upload-content ${selectedMedia && selectedMedia.url ? 'uploaded' : ''}` },
|
|
@@ -296,14 +299,14 @@ export const UploadImage = props => {
|
|
|
296
299
|
!selectedMedia || !selectedMedia.url ? (React.createElement(Icon, { type: `icon-ants-${iconName}`, size: 36, style: {
|
|
297
300
|
zIndex: 1,
|
|
298
301
|
marginLeft: 25,
|
|
299
|
-
color: (
|
|
302
|
+
color: (_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorIcon,
|
|
300
303
|
} })) : null,
|
|
301
304
|
React.createElement("div", { style: flexStyleCenter },
|
|
302
305
|
React.createElement(Button, { onClick: showModal, style: { backgroundColor: '#ffffff' } },
|
|
303
306
|
"Browse ",
|
|
304
307
|
mode === 'video' ? 'Video' : 'Image'),
|
|
305
308
|
selectedMedia && selectedMedia.url ? (React.createElement(Button, { onClick: handleRemoveMedia, style: { backgroundColor: '#ffffff' } },
|
|
306
|
-
React.createElement(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: (
|
|
309
|
+
React.createElement(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: (_c = THEME.token) === null || _c === void 0 ? void 0 : _c.colorPrimary } }))) : null)),
|
|
307
310
|
React.createElement("div", { className: "upload-file-info", style: { marginTop: 12 } },
|
|
308
311
|
React.createElement(Text, null,
|
|
309
312
|
"File type: ", extensions === null || extensions === void 0 ? void 0 :
|
|
@@ -318,8 +321,8 @@ export const UploadImage = props => {
|
|
|
318
321
|
}) }))))),
|
|
319
322
|
React.createElement(Modal, { title: labelModalDelete, visible: isOpenConfirmDelete, onOk: () => handleRemoveUploadedMedia(deleteMediaRef.current, false), onCancel: () => setOpenConfirmDelete(prev => !prev), okText: "OK", cancelText: "Cancel" },
|
|
320
323
|
React.createElement("p", null,
|
|
321
|
-
"Are you sure you want to delete ", (
|
|
322
|
-
|
|
324
|
+
"Are you sure you want to delete ", (_d = deleteMediaRef.current) === null || _d === void 0 ? void 0 :
|
|
325
|
+
_d.name,
|
|
323
326
|
"?")),
|
|
324
327
|
React.createElement(Modal, { wrapClassName: "icons-selection-modal", title: React.createElement("div", { style: { display: 'flex', gap: '8px', alignItems: 'center' } },
|
|
325
328
|
React.createElement(Icon, { type: `icon-ants-${iconName}`, size: 20 }),
|
|
@@ -347,7 +350,7 @@ export const UploadImage = props => {
|
|
|
347
350
|
// onChange={onChangeFileUpload}
|
|
348
351
|
showUploadList: false, multiple: true, customRequest: customRequestUpload }),
|
|
349
352
|
React.createElement("div", { style: Object.assign(Object.assign({}, flexStyleCenter), { height: 80 }) },
|
|
350
|
-
React.createElement(Icon, { type: `icon-ants-${iconName}`, size: 36, style: { color: (
|
|
353
|
+
React.createElement(Icon, { type: `icon-ants-${iconName}`, size: 36, style: { color: (_e = THEME.token) === null || _e === void 0 ? void 0 : _e.colorIcon } }),
|
|
351
354
|
React.createElement("div", { style: Object.assign(Object.assign({}, flexStyleCenter), { justifyContent: 'flex-start' }) },
|
|
352
355
|
React.createElement(TextStyled, { className: "ant-upload-text" }, "Drag & Drop file here"),
|
|
353
356
|
React.createElement("span", null, "or"),
|
|
@@ -356,7 +359,7 @@ export const UploadImage = props => {
|
|
|
356
359
|
display: 'none !important',
|
|
357
360
|
backgroundColor: '#ffffff',
|
|
358
361
|
} },
|
|
359
|
-
React.createElement(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: (
|
|
362
|
+
React.createElement(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: (_f = THEME.token) === null || _f === void 0 ? void 0 : _f.colorPrimary } })))))),
|
|
360
363
|
React.createElement("div", { style: {
|
|
361
364
|
display: 'flex',
|
|
362
365
|
flexWrap: 'wrap',
|
|
@@ -36,6 +36,7 @@ export * from './RichMenu';
|
|
|
36
36
|
export { ModalV2 } from './ModalV2';
|
|
37
37
|
export * from './PreviewModal';
|
|
38
38
|
export * from './Drawer';
|
|
39
|
+
export { EditorScript } from './EditorScript';
|
|
39
40
|
export type { AdvancedPickerProps, TAdvancedPickerOption, TAdvancedRangePickerTimeRange, } from './DatePicker';
|
|
40
41
|
export type { ColorPickerProps } from './ColorPicker';
|
|
41
42
|
export type { AlignEditProps, AlignSettingProps } from './AlignSetting';
|
package/es/locales/i18n.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antscorp/antsomi-ui",
|
|
3
|
-
"version": "1.3.3-beta.
|
|
3
|
+
"version": "1.3.3-beta.71",
|
|
4
4
|
"description": "An enterprise-class UI design language and React UI library.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"dist/*",
|
|
@@ -81,6 +81,8 @@
|
|
|
81
81
|
"@tanstack/react-query": "4.20.4",
|
|
82
82
|
"@tanstack/react-query-devtools": "4.20.4",
|
|
83
83
|
"pako": "2.0.4",
|
|
84
|
+
"ace-builds": "1.4.14",
|
|
85
|
+
"react-ace": "9.5.0",
|
|
84
86
|
"i18next-browser-languagedetector": "6.1.2",
|
|
85
87
|
"immer": "3.0.0",
|
|
86
88
|
"lodash": "^4.17.21",
|
|
@@ -189,4 +191,3 @@
|
|
|
189
191
|
"react-dom": ">=16.9.0"
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
|
-
|