@antscorp/antsomi-ui 1.3.5-beta.707 → 1.3.5-beta.708

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.
@@ -3,6 +3,7 @@ import { HideOptionTypes, TContentSourceGroup, UpdateGroupAction } from './types
3
3
  import { FallbackBO } from '@antscorp/antsomi-ui/es/models/FallbackBO';
4
4
  export type TProps = {
5
5
  groups: TContentSourceGroup[];
6
+ justOneGroup?: boolean;
6
7
  isLoadingListBO: boolean;
7
8
  listBO: any;
8
9
  hideOptionTypes?: HideOptionTypes;
@@ -18,6 +18,7 @@ import { THEME } from '@antscorp/antsomi-ui/es/constants';
18
18
  const defaultProps = {
19
19
  groups: [],
20
20
  isShowErrorAlert: false,
21
+ justOneGroup: false,
21
22
  journeySettings: {},
22
23
  isLoadingListBO: true,
23
24
  listFallbackBO: [],
@@ -25,7 +26,7 @@ const defaultProps = {
25
26
  };
26
27
  const Content = (props = defaultProps) => {
27
28
  // prettier-ignore
28
- const { groups, isLoadingListBO, listBO, onChangeGroup, onChangeExpand, expanded, isShowErrorAlert, hideOptionTypes, listFallbackBO, journeySettings, onDeleteGroup } = props;
29
+ const { groups, isLoadingListBO, listBO, onChangeGroup, onChangeExpand, expanded, isShowErrorAlert, hideOptionTypes, listFallbackBO, journeySettings, justOneGroup, onDeleteGroup } = props;
29
30
  const { t } = i18nInstance;
30
31
  const mode = useSelectModeView();
31
32
  const isCDP = mode === 'CDP';
@@ -69,8 +70,8 @@ const Content = (props = defaultProps) => {
69
70
  }, onClick: (e) => handleOnDeleteGroup(e, group.groupId), type: "icon-ants-outline-delete", size: 20 })));
70
71
  };
71
72
  return (React.createElement(Collapse, { ghost: true, bordered: true, activeKey: expanded, expandIconPosition: "end", onChange: handleOnChangeExpand, destroyInactivePanel: true, rootClassName: "no-border-top" }, groups.map((group, index) => {
72
- const groupNode = (React.createElement(Group, { data: group, hideOptionTypes: hideOptionTypes, groupNames: groupNames, isLoadingSelectBO: isLoadingListBO, listBO: listBO, onChange: onChangeGroup, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, listFallbackBO: listFallbackBO }));
73
- if (isCDP) {
73
+ const groupNode = (React.createElement(Group, { data: group, justOneGroup: justOneGroup, hideOptionTypes: hideOptionTypes, groupNames: groupNames, isLoadingSelectBO: isLoadingListBO, listBO: listBO, onChange: onChangeGroup, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, listFallbackBO: listFallbackBO }));
74
+ if (isCDP || justOneGroup) {
74
75
  return React.createElement(React.Fragment, { key: group.groupId }, groupNode);
75
76
  }
76
77
  return (React.createElement(React.Fragment, { key: group.groupId },
@@ -4,6 +4,7 @@ import { FallbackBO } from '@antscorp/antsomi-ui/es/models/FallbackBO';
4
4
  type TProps = {
5
5
  data: TContentSourceGroup;
6
6
  listBO: any[];
7
+ justOneGroup?: boolean;
7
8
  hideOptionTypes?: HideOptionTypes;
8
9
  isLoadingSelectBO: boolean;
9
10
  onChange?: (groupId: string, action: UpdateGroupAction) => void;
@@ -1,7 +1,7 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { cloneDeep, get, isEmpty } from 'lodash';
3
3
  // Molecules
4
- import { Space, Text } from '../../atoms';
4
+ import { Divider, Space, Text } from '../../atoms';
5
5
  import { SelectV2 as Select } from '../../molecules';
6
6
  // Styled
7
7
  import { WrapperFallback } from './styled';
@@ -31,7 +31,7 @@ const cdpStyle = {
31
31
  };
32
32
  const Group = (props) => {
33
33
  var _a, _b;
34
- const { data, isLoadingSelectBO, listBO, listFallbackBO, hideOptionTypes, isShowErrorAlert, journeySettings, onChange, } = props;
34
+ const { data, isLoadingSelectBO, listBO, listFallbackBO, hideOptionTypes, isShowErrorAlert, journeySettings, justOneGroup = false, onChange, } = props;
35
35
  const { itemTypeId, filters, level, itemTypeName } = data;
36
36
  const mode = useSelectModeView();
37
37
  const isCDP = mode === 'CDP';
@@ -105,10 +105,11 @@ const Group = (props) => {
105
105
  }
106
106
  }, [level, relationship]);
107
107
  return (React.createElement(Space, { size: 20, direction: "vertical" },
108
- React.createElement(Select, { showSearch: true, loading: isLoadingSelectBO, required: isCDP, isReverseMask: isCDP, labelStyle: isCDP ? cdpStyle : {}, style: isCDP ? { width: '100%' } : {}, containerStyle: isCDP ? { flexDirection: 'row', alignItems: 'baseline' } : {}, label: React.createElement(Text, { type: "secondary", color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorText }, isCDP ? TRANSLATE_TEXT.csTitle : TRANSLATE_TEXT.selectCsTitle), options: options, placeholder: TRANSLATE_TEXT.selectAnItem, value: convertValue(listBO, itemTypeId), onChange: value => handleChange({
108
+ React.createElement(Select, { showSearch: true, loading: isLoadingSelectBO, required: isCDP, isReverseMask: isCDP, labelStyle: isCDP ? cdpStyle : {}, style: isCDP ? { width: '100%' } : {}, containerStyle: isCDP ? { flexDirection: 'row', alignItems: 'baseline' } : {}, label: React.createElement(Text, { type: "secondary", color: (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorText }, TRANSLATE_TEXT.csTitle), options: options, placeholder: TRANSLATE_TEXT.selectAnItem, value: convertValue(listBO, itemTypeId), onChange: value => handleChange({
109
109
  type: 'BO_TYPE',
110
110
  payload: { itemTypeId: value },
111
111
  }), errorArchive: isCheckBOArchiveDelete(listBO, itemTypeId) }),
112
+ justOneGroup && (React.createElement(Divider, { type: "horizontal", style: { margin: 0 }, rootClassName: "root-divider-bottom-cs", className: "divider-bottom-cs" })),
112
113
  isShowLevelSetting && (React.createElement(LevelSetting, { value: level || 'parent', levelOption: relationship.recommendation_level, onChange: e => {
113
114
  handleChange({
114
115
  type: 'LEVEL',
@@ -4,6 +4,7 @@ import type { ContentSourceModeView, HideOptionTypes, JourneySettings, TContentS
4
4
  interface SettingsProps {
5
5
  serviceAuth: TServiceAuth;
6
6
  mode: ContentSourceModeView;
7
+ justOneGroup?: boolean;
7
8
  hideOptionTypes?: HideOptionTypes;
8
9
  onChange: (contentSource: TContentSourceSettings) => void;
9
10
  onBOChange?: (item: {
@@ -36,7 +36,7 @@ import { deleteContentSourceGroup, setContentSourceGroup, setContentSourceGroupB
36
36
  import { handleError } from '@antscorp/antsomi-ui/es/utils';
37
37
  const PATH = 'src/components/organism/ContentSources/Settings.tsx';
38
38
  const Settings = (props) => {
39
- const { serviceAuth, mode, isShowErrorAlert, initValue, journeySettings, hideOptionTypes, onChange, onBOChange, } = props;
39
+ const { serviceAuth, mode, isShowErrorAlert, initValue, justOneGroup = false, journeySettings, hideOptionTypes, onChange, onBOChange, } = props;
40
40
  const { url = '', userId, token, accountId } = serviceAuth;
41
41
  const { t } = i18nInstance;
42
42
  const boIdByGroupCS = useSelectBoIdByGroupFromCS();
@@ -56,7 +56,7 @@ const Settings = (props) => {
56
56
  }, {
57
57
  onSuccess(data) {
58
58
  if (!isInitDataCDPDone &&
59
- isCDP &&
59
+ (isCDP || justOneGroup) &&
60
60
  isArray(data) &&
61
61
  contentSources.groups.length === 1 &&
62
62
  contentSources.groups[0] &&
@@ -69,7 +69,7 @@ const Settings = (props) => {
69
69
  let valueRanking = GET_TOP_RANKING_DEFAULT;
70
70
  if (itemTypeId === PRODUCT_ITEM_TYPE_ID) {
71
71
  valueRanking = PRODUCT_RANKING_DEFAULT;
72
- if (isCDP) {
72
+ if (isCDP || justOneGroup) {
73
73
  set(valueRanking, 'algorithms.sort', 'order');
74
74
  }
75
75
  }
@@ -109,7 +109,7 @@ const Settings = (props) => {
109
109
  let valueRanking = GET_TOP_RANKING_DEFAULT;
110
110
  if (id === PRODUCT_ITEM_TYPE_ID) {
111
111
  valueRanking = PRODUCT_RANKING_DEFAULT;
112
- if (isCDP) {
112
+ if (isCDP || justOneGroup) {
113
113
  set(valueRanking, 'algorithms.sort', 'order');
114
114
  }
115
115
  }
@@ -224,28 +224,28 @@ const Settings = (props) => {
224
224
  }, [mode, contentSourceDispatch]);
225
225
  // INIT group in case using CDP mode
226
226
  useLayoutEffect(() => {
227
- if (isCDP && groups.length === 0) {
227
+ if ((isCDP || justOneGroup) && groups.length === 0) {
228
228
  contentSourceDispatch({
229
229
  type: 'ADD_CONTENT_SOURCE',
230
230
  payload: {},
231
231
  });
232
232
  }
233
- }, [isCDP, contentSourceDispatch, groups.length]);
233
+ }, [isCDP, justOneGroup, contentSourceDispatch, groups.length]);
234
234
  // init data
235
235
  useDeepCompareEffect(() => {
236
236
  if (!isEmpty(initValue)) {
237
237
  contentSourceDispatch(updateContentSourceSettings(initValue));
238
- if (isCDP) {
238
+ if (isCDP || justOneGroup) {
239
239
  setIsInitDataCDPDone(true);
240
240
  }
241
241
  }
242
242
  else {
243
- if (isCDP) {
243
+ if (isCDP || justOneGroup) {
244
244
  refetchListBO();
245
245
  setIsInitDataCDPDone(false);
246
246
  }
247
247
  }
248
- }, [initValue, contentSourceDispatch, isCDP]);
248
+ }, [initValue, contentSourceDispatch, isCDP, justOneGroup]);
249
249
  useDeepCompareEffect(() => {
250
250
  let ignore = false;
251
251
  if (!isEmpty(boIdByGroupCS) && !isEmpty(serviceAuth)) {
@@ -284,7 +284,7 @@ const Settings = (props) => {
284
284
  }
285
285
  }, [contentSourcesDebounce]);
286
286
  return (React.createElement(ContentContainer, { className: "contentsource-container" },
287
- React.createElement(Content, { isLoadingListBO: isLoadingListBO || isLoadingDataTableBO, hideOptionTypes: hideOptionTypes, listBO: listBO, groups: groups, expanded: expanded, onChangeExpand: expanded => {
287
+ React.createElement(Content, { isLoadingListBO: isLoadingListBO || isLoadingDataTableBO, hideOptionTypes: hideOptionTypes, justOneGroup: justOneGroup, listBO: listBO, groups: groups, expanded: expanded, onChangeExpand: expanded => {
288
288
  contentSourceDispatch({
289
289
  type: 'EXPANDED',
290
290
  payload: {
@@ -294,7 +294,7 @@ const Settings = (props) => {
294
294
  }, onChangeGroup: (groupId, action) => {
295
295
  handleChangeContentSourceGroup(groupId, action);
296
296
  }, onDeleteGroup: groupId => handleDeleteContentSourceGroup(groupId), journeySettings: journeySettings, isShowErrorAlert: isShowErrorAlert, listFallbackBO: listFallbackBO || [] }),
297
- groups.length < MAX_NUM_OF_CONTENT_SOURCE && !isCDP && (React.createElement(Button, { type: "text", onClick: () => contentSourceDispatch({
297
+ groups.length < MAX_NUM_OF_CONTENT_SOURCE && !isCDP && !justOneGroup && (React.createElement(Button, { type: "text", onClick: () => contentSourceDispatch({
298
298
  type: 'ADD_CONTENT_SOURCE',
299
299
  payload: {},
300
300
  }) },
@@ -17,7 +17,10 @@ const LevelSetting = (props) => {
17
17
  const { onChange, levelOption, value } = props;
18
18
  const mode = useSelectModeView();
19
19
  const isCDP = mode === 'CDP';
20
- return (React.createElement(SettingWrapper, { label: t(translations.level.title).toString(), labelStyle: { fontWeight: mode === 'CDP' ? 'normal' : 'bold', width: LABEL_WIDTH }, labelColor: isCDP ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorText : undefined, containerStyle: isCDP ? { justifyContent: 'flex-start' } : {} },
20
+ return (React.createElement(SettingWrapper, { label: t(translations.level.title).toString(), labelStyle: {
21
+ fontWeight: isCDP ? 'normal' : 'bold',
22
+ width: isCDP ? LABEL_WIDTH : 'auto',
23
+ }, labelColor: isCDP ? (_a = THEME.token) === null || _a === void 0 ? void 0 : _a.colorText : undefined, containerStyle: isCDP ? { justifyContent: 'flex-start' } : {} },
21
24
  React.createElement(RadioGroup, { options: LEVEL_OPTIONS[levelOption], defaultValue: value, value: value, onChange: onChange })));
22
25
  };
23
26
  export default React.memo(LevelSetting);
@@ -5,6 +5,7 @@ export interface ContentSourceProps {
5
5
  useQueryClient: boolean;
6
6
  serviceAuth: TServiceAuth;
7
7
  isShowErrorAlert: boolean;
8
+ justOneGroup?: boolean;
8
9
  hideOptionTypes?: HideOptionTypes;
9
10
  mode: ContentSourceModeView;
10
11
  initValue?: TContentSourceSettings;
@@ -11,6 +11,7 @@ import { JOURNEY_SETTINGS_DEFAULT } from './constants';
11
11
  const defaultProps = {
12
12
  useQueryClient: true,
13
13
  isShowErrorAlert: false,
14
+ justOneGroup: false,
14
15
  hideOptionTypes: {
15
16
  filter: false,
16
17
  level: false,
@@ -28,12 +29,12 @@ const defaultProps = {
28
29
  },
29
30
  };
30
31
  const ContentSource = (props) => {
31
- const { useQueryClient, serviceAuth, mode, isShowErrorAlert, initValue, hideOptionTypes, journeySettings, onChange, onBOChange, } = props;
32
+ const { useQueryClient, serviceAuth, mode, isShowErrorAlert, justOneGroup, initValue, hideOptionTypes, journeySettings, onChange, onBOChange, } = props;
32
33
  if (!useQueryClient)
33
- return (React.createElement(Settings, { mode: mode, initValue: initValue, hideOptionTypes: hideOptionTypes, serviceAuth: serviceAuth, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, onChange: onChange, onBOChange: onBOChange }));
34
+ return (React.createElement(Settings, { mode: mode, initValue: initValue, hideOptionTypes: hideOptionTypes, justOneGroup: justOneGroup, serviceAuth: serviceAuth, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, onChange: onChange, onBOChange: onBOChange }));
34
35
  return (React.createElement(QueryClientProviderAntsomiUI, { client: queryClientAntsomiUI },
35
36
  React.createElement(ContentSourceProvider, null,
36
- React.createElement(Settings, { mode: mode, initValue: initValue, hideOptionTypes: hideOptionTypes, serviceAuth: serviceAuth, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, onChange: onChange, onBOChange: onBOChange }))));
37
+ React.createElement(Settings, { mode: mode, initValue: initValue, justOneGroup: justOneGroup, hideOptionTypes: hideOptionTypes, serviceAuth: serviceAuth, isShowErrorAlert: isShowErrorAlert, journeySettings: journeySettings, onChange: onChange, onBOChange: onBOChange }))));
37
38
  };
38
39
  ContentSource.defaultProps = defaultProps;
39
40
  export default memo(ContentSource);
package/es/test.js CHANGED
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  import React, { useState } from 'react';
12
12
  import { createRoot } from 'react-dom/client';
13
13
  import '@antscorp/icons/main.css';
14
- import { TemplateSaveAsModal, useTemplateSave, Button, Layout, } from './components';
14
+ import { TemplateSaveAsModal, useTemplateSave, Button, Layout, Login, ContentSources, } from './components';
15
15
  // Constants
16
16
  import { GET_LIST_TYPE, OBJECT_TYPES, PUBLIC_LEVEL } from './constants';
17
17
  // import { Slider } from 'antd';
@@ -107,6 +107,24 @@ export const App = () => {
107
107
  const callbackSlideBar = (type, data) => {
108
108
  console.log({ type, data });
109
109
  };
110
+ const d = {
111
+ loginDomain: 'https://iam.ants.tech/',
112
+ };
113
+ // const d = {
114
+ // loginDomain: 'https://sandbox-aacm.ants.vn',
115
+ // networkId: '76753',
116
+ // theme: 'white',
117
+ // u_ogs: 'uogs_sand_48956',
118
+ // apiDomain: '//sandbox-permission.ants.vn',
119
+ // };
120
+ /* Login */
121
+ return (React.createElement(ContentSources, { mode: "MEDIA", useQueryClient: true, justOneGroup: true, serviceAuth: {
122
+ url: 'https://sandbox-media-template.antsomi.com/cdp/api/v1',
123
+ userId: '1600080515',
124
+ accountId: '1600083946',
125
+ token: '5474r2x214z254a4u2a4y454t4065406a434d4e4b4z5',
126
+ } }));
127
+ return React.createElement(Login, Object.assign({}, d));
110
128
  /* MatchesAnySelect */
111
129
  return React.createElement(MatchesAnySelectTest, null);
112
130
  /* Data Table */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.707",
3
+ "version": "1.3.5-beta.708",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",