@antscorp/antsomi-ui 1.3.5-beta.136 → 1.3.5-beta.138

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 (135) hide show
  1. package/es/components/atoms/InputDynamic/types.d.ts +9 -0
  2. package/es/components/atoms/RequiredLabel/index.js +1 -1
  3. package/es/components/molecules/AddDynamicContent/constants.d.ts +17 -0
  4. package/es/components/molecules/AddDynamicContent/constants.js +17 -0
  5. package/es/components/molecules/DatePickerV2/index.d.ts +9 -0
  6. package/es/components/molecules/DatePickerV2/index.js +51 -0
  7. package/es/components/molecules/DatePickerV2/styled.d.ts +1 -0
  8. package/es/components/molecules/DatePickerV2/styled.js +12 -0
  9. package/es/components/molecules/SelectEventAttribute/index.d.ts +21 -0
  10. package/es/components/molecules/SelectEventAttribute/index.js +267 -0
  11. package/es/components/molecules/SelectEventAttribute/styled.d.ts +13 -0
  12. package/es/components/molecules/SelectEventAttribute/styled.js +13 -0
  13. package/es/components/molecules/SelectMulti/index.d.ts +17 -0
  14. package/es/components/molecules/SelectMulti/index.js +50 -0
  15. package/es/components/molecules/SelectMulti/styled.d.ts +11 -0
  16. package/es/components/molecules/SelectMulti/styled.js +71 -0
  17. package/es/components/molecules/SelectV2/index.d.ts +34 -0
  18. package/es/components/molecules/SelectV2/index.js +100 -0
  19. package/es/components/molecules/SelectV2/styled.d.ts +15 -0
  20. package/es/components/molecules/SelectV2/styled.js +135 -0
  21. package/es/components/molecules/index.d.ts +7 -0
  22. package/es/components/molecules/index.js +5 -0
  23. package/es/components/organism/AlgorithmsSetting/constants.d.ts +146 -0
  24. package/es/components/organism/AlgorithmsSetting/constants.js +223 -0
  25. package/es/components/organism/AlgorithmsSetting/index.d.ts +13 -0
  26. package/es/components/organism/AlgorithmsSetting/index.js +767 -0
  27. package/es/components/organism/AlgorithmsSetting/styled.d.ts +22 -0
  28. package/es/components/organism/AlgorithmsSetting/styled.js +46 -0
  29. package/es/components/organism/AlgorithmsSetting/types.d.ts +4 -0
  30. package/es/components/organism/AlgorithmsSetting/types.js +1 -0
  31. package/es/components/organism/AlgorithmsSetting/utils.d.ts +2 -0
  32. package/es/components/organism/AlgorithmsSetting/utils.js +9 -0
  33. package/es/components/organism/ContentSources/Content.d.ts +18 -0
  34. package/es/components/organism/ContentSources/Content.js +81 -0
  35. package/es/components/organism/ContentSources/Group.d.ts +15 -0
  36. package/es/components/organism/ContentSources/Group.js +138 -0
  37. package/es/components/organism/ContentSources/Settings.d.ts +13 -0
  38. package/es/components/organism/ContentSources/Settings.js +245 -0
  39. package/es/components/organism/ContentSources/components/LevelSetting/constants.d.ts +14 -0
  40. package/es/components/organism/ContentSources/components/LevelSetting/constants.js +24 -0
  41. package/es/components/organism/ContentSources/components/LevelSetting/index.d.ts +7 -0
  42. package/es/components/organism/ContentSources/components/LevelSetting/index.js +23 -0
  43. package/es/components/organism/ContentSources/constants.d.ts +7 -0
  44. package/es/components/organism/ContentSources/constants.js +46 -0
  45. package/es/components/organism/ContentSources/index.d.ts +17 -0
  46. package/es/components/organism/ContentSources/index.js +33 -0
  47. package/es/components/organism/ContentSources/provider.d.ts +14 -0
  48. package/es/components/organism/ContentSources/provider.js +27 -0
  49. package/es/components/organism/ContentSources/reducer.d.ts +17 -0
  50. package/es/components/organism/ContentSources/reducer.js +87 -0
  51. package/es/components/organism/ContentSources/styled.d.ts +8 -0
  52. package/es/components/organism/ContentSources/styled.js +58 -0
  53. package/es/components/organism/ContentSources/types.d.ts +134 -0
  54. package/es/components/organism/ContentSources/types.js +1 -0
  55. package/es/components/organism/ContentSources/utils.d.ts +29 -0
  56. package/es/components/organism/ContentSources/utils.js +150 -0
  57. package/es/components/organism/FilterSetting/components/common/InputArray/index.d.ts +9 -0
  58. package/es/components/organism/FilterSetting/components/common/InputArray/index.js +32 -0
  59. package/es/components/organism/FilterSetting/components/common/InputArray/styled.d.ts +12 -0
  60. package/es/components/organism/FilterSetting/components/common/InputArray/styled.js +8 -0
  61. package/es/components/organism/FilterSetting/components/common/InputBoolean/index.d.ts +8 -0
  62. package/es/components/organism/FilterSetting/components/common/InputBoolean/index.js +20 -0
  63. package/es/components/organism/FilterSetting/components/common/InputCalendar/index.d.ts +11 -0
  64. package/es/components/organism/FilterSetting/components/common/InputCalendar/index.js +44 -0
  65. package/es/components/organism/FilterSetting/components/common/InputCalendarBetween/index.d.ts +9 -0
  66. package/es/components/organism/FilterSetting/components/common/InputCalendarBetween/index.js +47 -0
  67. package/es/components/organism/FilterSetting/components/common/InputDateTimeAgo/index.d.ts +13 -0
  68. package/es/components/organism/FilterSetting/components/common/InputDateTimeAgo/index.js +23 -0
  69. package/es/components/organism/FilterSetting/components/common/InputDateTimeBetweenAgo/index.d.ts +11 -0
  70. package/es/components/organism/FilterSetting/components/common/InputDateTimeBetweenAgo/index.js +34 -0
  71. package/es/components/organism/FilterSetting/components/common/InputNumber/index.d.ts +7 -0
  72. package/es/components/organism/FilterSetting/components/common/InputNumber/index.js +11 -0
  73. package/es/components/organism/FilterSetting/components/common/InputNumberBetween/index.d.ts +7 -0
  74. package/es/components/organism/FilterSetting/components/common/InputNumberBetween/index.js +26 -0
  75. package/es/components/organism/FilterSetting/components/common/InputOrSelect/index.d.ts +79 -0
  76. package/es/components/organism/FilterSetting/components/common/InputOrSelect/index.js +537 -0
  77. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/ColumnSuggestion/index.d.ts +15 -0
  78. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/ColumnSuggestion/index.js +66 -0
  79. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/Tree/index.d.ts +20 -0
  80. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/Tree/index.js +57 -0
  81. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/index.d.ts +88 -0
  82. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/index.js +569 -0
  83. package/es/components/organism/FilterSetting/components/common/TextTreeSelect/index.d.ts +10 -0
  84. package/es/components/organism/FilterSetting/components/common/TextTreeSelect/index.js +13 -0
  85. package/es/components/organism/FilterSetting/components/common/index.d.ts +11 -0
  86. package/es/components/organism/FilterSetting/components/common/index.js +11 -0
  87. package/es/components/organism/FilterSetting/constants.d.ts +178 -0
  88. package/es/components/organism/FilterSetting/constants.js +300 -0
  89. package/es/components/organism/FilterSetting/context.d.ts +7 -0
  90. package/es/components/organism/FilterSetting/context.js +8 -0
  91. package/es/components/organism/FilterSetting/index.d.ts +30 -0
  92. package/es/components/organism/FilterSetting/index.js +431 -0
  93. package/es/components/organism/FilterSetting/styled.d.ts +4 -0
  94. package/es/components/organism/FilterSetting/styled.js +28 -0
  95. package/es/components/organism/FilterSetting/utils.d.ts +46 -0
  96. package/es/components/organism/FilterSetting/utils.js +349 -0
  97. package/es/components/organism/index.d.ts +1 -0
  98. package/es/components/organism/index.js +1 -0
  99. package/es/components/template/TemplateListing/components/CategoryListing/index.js +8 -4
  100. package/es/components/template/TemplateListing/components/CategoryListing/styled.js +37 -27
  101. package/es/components/template/TemplateListing/index.js +23 -20
  102. package/es/components/template/TemplateListing/stories/dataTypes/components/CategoryListingPropsTable/index.js +7 -0
  103. package/es/components/template/TemplateListing/stories/dataTypes/components/TemplatesPropsTable/index.js +7 -0
  104. package/es/components/template/TemplateListing/styled/index.d.ts +1 -0
  105. package/es/components/template/TemplateListing/styled/index.js +8 -0
  106. package/es/components/template/TemplateListing/types/CategoryListing.d.ts +3 -1
  107. package/es/components/template/TemplateListing/types/TemplateListing.d.ts +5 -0
  108. package/es/constants/contentSource.d.ts +29 -0
  109. package/es/constants/contentSource.js +46 -0
  110. package/es/constants/queries.d.ts +2 -0
  111. package/es/constants/queries.js +3 -0
  112. package/es/constants/theme.js +1 -0
  113. package/es/locales/en/translation.json +296 -0
  114. package/es/locales/i18n.d.ts +296 -0
  115. package/es/locales/translations.d.ts +296 -0
  116. package/es/models/BusinessObject.d.ts +78 -0
  117. package/es/models/BusinessObject.js +92 -0
  118. package/es/models/FallbackBO.d.ts +9 -0
  119. package/es/models/FallbackBO.js +10 -0
  120. package/es/queries/BusinessObject/index.d.ts +1 -0
  121. package/es/queries/BusinessObject/index.js +1 -0
  122. package/es/queries/BusinessObject/useGetBODetail.d.ts +5 -0
  123. package/es/queries/BusinessObject/useGetBODetail.js +19 -0
  124. package/es/queries/ThirdParty/index.d.ts +1 -0
  125. package/es/queries/ThirdParty/index.js +1 -0
  126. package/es/queries/ThirdParty/useGetListFallbackBO.d.ts +10 -0
  127. package/es/queries/ThirdParty/useGetListFallbackBO.js +11 -0
  128. package/es/services/MediaTemplateDesign/BusinessObject/index.d.ts +16 -1
  129. package/es/services/MediaTemplateDesign/BusinessObject/index.js +146 -6
  130. package/es/services/ThirParty/ListFallbackBO/getListFallbackBO.d.ts +2 -0
  131. package/es/services/ThirParty/ListFallbackBO/getListFallbackBO.js +29 -0
  132. package/es/test.js +103 -47
  133. package/es/utils/common.d.ts +8 -0
  134. package/es/utils/common.js +10 -0
  135. package/package.json +1 -1
@@ -45,6 +45,15 @@ export type EventMetadata = {
45
45
  item_property_label: string | null;
46
46
  event_property_syntax: string | null;
47
47
  };
48
+ export type EventBoFieldMetadata = EventMetadata & {
49
+ field_code_bo?: string;
50
+ field_label_bo?: string;
51
+ useBo?: boolean;
52
+ };
53
+ export type SelectOption = {
54
+ value?: string;
55
+ label?: string;
56
+ };
48
57
  export type TFilter = {
49
58
  value: any;
50
59
  operator: TOperatorValue;
@@ -21,5 +21,5 @@ export const RequiredLabel = memo(props => {
21
21
  return (React.createElement(Text, Object.assign({}, restProps),
22
22
  !isReverseMask && React.createElement(StyledRequired, null, "*"),
23
23
  children,
24
- isReverseMask && React.createElement(StyledRequired, null, "*")));
24
+ isReverseMask && (React.createElement(StyledRequired, { style: { marginLeft: 4, marginRight: 0 } }, "*"))));
25
25
  });
@@ -99,3 +99,20 @@ export declare const ATTRIBUTE_NUMBERIC_FORMAT_OPTION: {
99
99
  };
100
100
  };
101
101
  };
102
+ export declare const COLLECTION_STATUS: {
103
+ 2: {
104
+ value: number;
105
+ label: string;
106
+ errorMessage: string;
107
+ };
108
+ 4: {
109
+ value: number;
110
+ label: string;
111
+ errorMessage: string;
112
+ };
113
+ DELETE: {
114
+ value: number;
115
+ label: string;
116
+ errorMessage: string;
117
+ };
118
+ };
@@ -150,3 +150,20 @@ export const ATTRIBUTE_NUMBERIC_FORMAT_OPTION = {
150
150
  },
151
151
  },
152
152
  };
153
+ export const COLLECTION_STATUS = {
154
+ 2: {
155
+ value: 2,
156
+ label: 'Disable',
157
+ errorMessage: 'This collection is disabled',
158
+ },
159
+ 4: {
160
+ value: 4,
161
+ label: 'Archive',
162
+ errorMessage: 'This collection is not available',
163
+ },
164
+ DELETE: {
165
+ value: 3,
166
+ label: 'Delete',
167
+ errorMessage: 'This collection does not exist',
168
+ },
169
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { DatePickerProps as AntDatePickerProps } from 'antd';
3
+ type DatePickerProps = {
4
+ onChange: (key: any, value: any) => void;
5
+ required?: boolean;
6
+ focused?: boolean;
7
+ } & AntDatePickerProps;
8
+ export declare const DatePickerV2: React.FC<DatePickerProps>;
9
+ export {};
@@ -0,0 +1,51 @@
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
+ /* eslint-disable react/destructuring-assignment */
13
+ // Libraries
14
+ import React, { useEffect, useMemo, useState } from 'react';
15
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
16
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
17
+ // Atoms
18
+ import { Space, Text } from '@antscorp/antsomi-ui/es/components/atoms';
19
+ // Components
20
+ import { DatePicker as AntDatePicker } from 'antd';
21
+ // Styled
22
+ import { DatePickerWrapper } from './styled';
23
+ export const DatePickerV2 = props => {
24
+ const { required, focused, onChange } = props, restOf = __rest(props, ["required", "focused", "onChange"]);
25
+ // I18n
26
+ const { t } = i18nInstance;
27
+ const [isFocused, setFocused] = useState(false);
28
+ const requiredMsg = useMemo(() => {
29
+ let msg = '';
30
+ const isEmptyValue = props.value == null;
31
+ if (required && isEmptyValue && isFocused) {
32
+ msg = t(translations.messageError.fieldIsRequired.message);
33
+ }
34
+ return msg;
35
+ }, [props.value, required, isFocused, t]);
36
+ useEffect(() => {
37
+ if (focused) {
38
+ setFocused(focused);
39
+ }
40
+ }, [focused]);
41
+ return (React.createElement(DatePickerWrapper, null,
42
+ React.createElement(Space, { direction: "vertical", size: 5 },
43
+ React.createElement(AntDatePicker, Object.assign({}, restOf, { onBlur: e => {
44
+ if (!isFocused) {
45
+ setFocused(true);
46
+ }
47
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
48
+ props.onBlur && props.onBlur(e);
49
+ }, onChange: date => onChange('date-picker', date) })),
50
+ requiredMsg ? (React.createElement(Text, { color: "#ff4d4f", style: { marginLeft: 8 } }, requiredMsg)) : null)));
51
+ };
@@ -0,0 +1 @@
1
+ export declare const DatePickerWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,12 @@
1
+ var _a;
2
+ // Libraries
3
+ import styled from 'styled-components';
4
+ // Constants
5
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
6
+ export const DatePickerWrapper = styled.div `
7
+ input {
8
+ &::placeholder {
9
+ font-size: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.fontSize}px;
10
+ }
11
+ }
12
+ `;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ export type EventMetadata = {
3
+ insight_property_id: any | any[] | null;
4
+ insight_property_ids?: string[] | null;
5
+ event_action_id: string | null;
6
+ event_category_id: string | null;
7
+ event_tracking_name: string | null;
8
+ item_type_id: string | null;
9
+ item_type_name: string | null;
10
+ item_property_name: string | null;
11
+ item_property_label: string | null;
12
+ event_property_syntax: string | null;
13
+ };
14
+ interface SelectEventAttributeProps {
15
+ eventMetadata: EventMetadata;
16
+ isShowErrorAlert: boolean;
17
+ journeySettings: Record<string, any>;
18
+ onChange: (eventMetaData: EventMetadata, ignoreUndoAction?: boolean) => void;
19
+ }
20
+ export declare const SelectEventAttribute: React.FC<SelectEventAttributeProps>;
21
+ export {};
@@ -0,0 +1,267 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ // Libraries
22
+ import React, { memo, useEffect, useMemo, useState } from 'react';
23
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
24
+ import get from 'lodash/get';
25
+ // Hooks
26
+ import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
27
+ // Molecules
28
+ import { SelectV2 as Select } from '@antscorp/antsomi-ui/es/components/molecules';
29
+ import { TreeSelect } from '../TreeSelect';
30
+ // Locales
31
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
32
+ // Selectors
33
+ import { useSelectServiceAuth } from '../../organism/ContentSources/provider';
34
+ // Styled
35
+ import { SelectEventAttributeWrapper, StyledSelect } from './styled';
36
+ // Utils
37
+ import { handleError, flattenTree } from '../../../utils';
38
+ import { buildOptionAttrArchive, checkStatusAttr } from '../AddDynamicContent/utils';
39
+ // Services
40
+ import { getListAllEvents, getListAttributesEvent, getListSourceByEvent, } from '@antscorp/antsomi-ui/es/services/MediaTemplateDesign/BusinessObject';
41
+ const PATH = 'src/components/molecules/SelectEventAttribute/index.tsx';
42
+ export const SelectEventAttribute = memo(props => {
43
+ // I18n
44
+ const { t } = i18nInstance;
45
+ // Props
46
+ const { eventMetadata, journeySettings, isShowErrorAlert, onChange } = props;
47
+ // Selectors
48
+ const { triggerEvent } = journeySettings || {};
49
+ const serviceAuth = useSelectServiceAuth();
50
+ const { url = '' } = serviceAuth, restAuthInfo = __rest(serviceAuth, ["url"]);
51
+ // State
52
+ const [listEvent, setListEvent] = useState([]);
53
+ const [listSourceByEvent, setListSourceByEvent] = useState([]);
54
+ const [treeEventAttrs, setTreeEventAttrs] = useState([]);
55
+ const [loading, setLoading] = useState({
56
+ isLoadingEvent: false,
57
+ isLoadingSource: false,
58
+ isLoadingAttrs: false,
59
+ });
60
+ const [eventAttrs, setEventAttrs] = useState([]);
61
+ const flatEventAttrs = useMemo(() => flattenTree(eventAttrs, 'items'), [eventAttrs]);
62
+ const memoizedEventAttributeValue = useMemo(() => {
63
+ const attributeValue = eventMetadata.item_type_id
64
+ ? `${eventMetadata.item_type_id}.${eventMetadata.item_property_name}`
65
+ : eventMetadata.item_property_name || undefined;
66
+ return attributeValue;
67
+ }, [eventMetadata.item_property_name, eventMetadata.item_type_id]);
68
+ const { errorMessage } = checkStatusAttr({
69
+ listAttribute: flatEventAttrs.map(({ itemPropertyName, eventPropertyName, status }) => ({
70
+ value: eventPropertyName || itemPropertyName,
71
+ status,
72
+ })) || [],
73
+ field: eventMetadata.item_property_name || undefined,
74
+ });
75
+ // Use Effect
76
+ useEffect(() => {
77
+ getListEvents();
78
+ }, []);
79
+ // Handle set trigger event when didn't chose event and trigger event is exists
80
+ useDeepCompareEffect(() => {
81
+ const { eventActionId, eventCategoryId, insightPropertyIds = [] } = triggerEvent || {};
82
+ const draftEventMetadata = Object.assign({}, eventMetadata);
83
+ if (!!eventActionId &&
84
+ !!eventCategoryId &&
85
+ listEvent.length &&
86
+ !eventMetadata.event_action_id) {
87
+ const defaultEvent = listEvent.find(event => +event.eventActionId === +eventActionId && +event.eventCategoryId === +eventCategoryId);
88
+ if (defaultEvent) {
89
+ draftEventMetadata.event_action_id = defaultEvent.eventActionId;
90
+ draftEventMetadata.event_category_id = defaultEvent.eventCategoryId;
91
+ draftEventMetadata.event_tracking_name = defaultEvent.eventTrackingName;
92
+ }
93
+ if (get(insightPropertyIds, 'length', 0) &&
94
+ !get(eventMetadata, 'insight_property_id.length', 0)) {
95
+ draftEventMetadata.insight_property_id = insightPropertyIds;
96
+ }
97
+ onChange(draftEventMetadata, true);
98
+ }
99
+ // eslint-disable-next-line react-hooks/exhaustive-deps
100
+ }, [triggerEvent, listEvent, eventMetadata]);
101
+ useEffect(() => {
102
+ if (eventMetadata.event_action_id && eventMetadata.event_category_id) {
103
+ getListSources({
104
+ event_action_id: eventMetadata.event_action_id,
105
+ event_category_id: eventMetadata.event_category_id,
106
+ });
107
+ }
108
+ }, [eventMetadata.event_action_id, eventMetadata.event_category_id]);
109
+ useEffect(() => {
110
+ var _a;
111
+ if (typeof eventMetadata.insight_property_id === 'object' &&
112
+ !((_a = eventMetadata.insight_property_id) === null || _a === void 0 ? void 0 : _a.length)) {
113
+ return;
114
+ }
115
+ if (!eventMetadata.insight_property_id) {
116
+ return;
117
+ }
118
+ getListAttributes({
119
+ insight_property_id: Array.isArray(eventMetadata.insight_property_id)
120
+ ? eventMetadata.insight_property_id.join(',')
121
+ : eventMetadata.insight_property_id,
122
+ event_action_id: eventMetadata.event_action_id,
123
+ event_category_id: eventMetadata.event_category_id,
124
+ });
125
+ // eslint-disable-next-line react-hooks/exhaustive-deps
126
+ }, [eventMetadata.insight_property_id]);
127
+ // Handlers
128
+ const getListEvents = () => __awaiter(void 0, void 0, void 0, function* () {
129
+ try {
130
+ setLoading(loading => (Object.assign(Object.assign({}, loading), { isLoadingEvent: true })));
131
+ const { rows } = yield getListAllEvents({ url }, restAuthInfo);
132
+ setListEvent(rows);
133
+ }
134
+ catch (error) {
135
+ handleError(error, {
136
+ path: PATH,
137
+ name: 'getListEvents',
138
+ args: {},
139
+ });
140
+ }
141
+ finally {
142
+ setLoading(loading => (Object.assign(Object.assign({}, loading), { isLoadingEvent: false })));
143
+ }
144
+ });
145
+ const getListSources = (_a) => __awaiter(void 0, [_a], void 0, function* ({ event_action_id, event_category_id }) {
146
+ try {
147
+ setLoading(loading => (Object.assign(Object.assign({}, loading), { isLoadingSource: true })));
148
+ const { rows } = yield getListSourceByEvent({
149
+ url,
150
+ eventActionId: event_action_id,
151
+ eventCategoryId: event_category_id,
152
+ }, restAuthInfo);
153
+ setListSourceByEvent(rows);
154
+ }
155
+ catch (error) {
156
+ handleError(error, {
157
+ path: PATH,
158
+ name: 'getListSources',
159
+ args: { event_action_id, event_category_id },
160
+ });
161
+ }
162
+ finally {
163
+ setLoading(loading => (Object.assign(Object.assign({}, loading), { isLoadingSource: false })));
164
+ }
165
+ });
166
+ const getListAttributes = (_b) => __awaiter(void 0, [_b], void 0, function* ({ insight_property_id, event_action_id, event_category_id }) {
167
+ try {
168
+ setLoading(loading => (Object.assign(Object.assign({}, loading), { isLoadingAttrs: true })));
169
+ const { rows } = yield getListAttributesEvent(serviceAuth, {
170
+ sourceId: insight_property_id,
171
+ eventActionId: event_action_id,
172
+ eventCategoryId: event_category_id,
173
+ });
174
+ setEventAttrs(rows);
175
+ const treeAttrs = rows.map((attr) => (Object.assign({ value: get(attr, 'items.length', 0)
176
+ ? `sub-${attr.eventPropertyName}`
177
+ : attr.eventPropertyName, title: attr.eventPropertyDisplay, isLeaf: attr.items ? get(attr, 'items.length', 0) === 0 : true, selectable: attr.items ? get(attr, 'items.length', 0) === 0 : true }, (attr.items &&
178
+ get(attr, 'items.length', 0) && {
179
+ children: attr.items.map((childAttr) => ({
180
+ value: `${childAttr.itemTypeId}.${childAttr.itemPropertyName}`,
181
+ title: childAttr.translateLabel,
182
+ status: childAttr.status,
183
+ isLeaf: true,
184
+ })),
185
+ }))));
186
+ setTreeEventAttrs(treeAttrs);
187
+ }
188
+ catch (error) {
189
+ handleError(error, {
190
+ path: PATH,
191
+ name: 'getListAttributes',
192
+ args: { insight_property_id, event_action_id, event_category_id },
193
+ });
194
+ }
195
+ finally {
196
+ setLoading(loading => (Object.assign(Object.assign({}, loading), { isLoadingAttrs: false })));
197
+ }
198
+ });
199
+ const onChangeEvent = (value) => {
200
+ try {
201
+ const eventSelected = listEvent.find(event => event.value === value);
202
+ onChange(Object.assign(Object.assign({}, eventMetadata), { event_action_id: eventSelected.eventActionId, event_category_id: eventSelected.eventCategoryId, event_tracking_name: eventSelected.eventTrackingName,
203
+ // resets
204
+ insight_property_id: null, item_type_id: null, item_type_name: null, item_property_name: null, item_property_label: null, event_property_syntax: null }));
205
+ setEventAttrs([]);
206
+ setTreeEventAttrs([]);
207
+ }
208
+ catch (error) {
209
+ handleError(error, {
210
+ path: PATH,
211
+ name: 'onChangeEvent',
212
+ args: { value },
213
+ });
214
+ }
215
+ };
216
+ const onChangeSource = (values = []) => {
217
+ try {
218
+ const sourcesSelected = listSourceByEvent.filter(source => values.includes(source.value));
219
+ if (values.length === 0) {
220
+ setTreeEventAttrs([]);
221
+ setEventAttrs([]);
222
+ }
223
+ onChange(Object.assign(Object.assign({}, eventMetadata), { insight_property_id: sourcesSelected.map(source => source.insightPropertyId),
224
+ // resets
225
+ item_type_id: null, item_type_name: null, item_property_name: null, item_property_label: null, event_property_syntax: null }));
226
+ }
227
+ catch (error) {
228
+ handleError(error, {
229
+ path: PATH,
230
+ name: 'onChangeSource',
231
+ args: { values },
232
+ });
233
+ }
234
+ };
235
+ const onChangeEventAttribute = (value) => {
236
+ try {
237
+ const [attribute, item] = value.split('.');
238
+ if (!item) {
239
+ const selected = eventAttrs.find(attr => attr.value === attribute);
240
+ if (selected) {
241
+ onChange(Object.assign(Object.assign({}, eventMetadata), { item_type_id: null, item_type_name: null, item_property_name: selected.eventPropertyName, item_property_label: selected.label, event_property_syntax: selected.eventPropertySyntax }));
242
+ }
243
+ }
244
+ else {
245
+ const selectedAttribute = eventAttrs.find(attr => +attr.itemTypeId === +attribute);
246
+ const selected = selectedAttribute.items.find((attr) => attr.itemPropertyName === item);
247
+ if (selected) {
248
+ onChange(Object.assign(Object.assign({}, eventMetadata), { item_type_id: selected.itemTypeId, item_type_name: selected.itemTypeName, item_property_name: selected.itemPropertyName, item_property_label: selected.translateLabel, event_property_syntax: selected.eventPropertySyntax }));
249
+ }
250
+ }
251
+ }
252
+ catch (error) {
253
+ handleError(error, {
254
+ path: PATH,
255
+ name: 'onChangeEventAttribute',
256
+ args: {},
257
+ });
258
+ }
259
+ };
260
+ return (React.createElement(SelectEventAttributeWrapper, null,
261
+ React.createElement(Select, { showSearch: true, required: true, focused: isShowErrorAlert, value: eventMetadata.event_tracking_name || undefined, loading: loading.isLoadingEvent, placeholder: t(translations.selectEvent.title).toString(), options: listEvent.map(({ value, label }) => ({ value, label })), onChange: onChangeEvent }),
262
+ React.createElement(StyledSelect, { showSearch: true, required: true, focused: isShowErrorAlert, value: eventMetadata.insight_property_id || undefined, mode: "multiple", allowClear: true, maxTagTextLength: 18, loading: loading.isLoadingSource, placeholder: t(translations.inAnySourceOf.title).toString(), options: listSourceByEvent.map(({ value, label }) => ({ value, label })), onChange: onChangeSource }),
263
+ React.createElement(TreeSelect, { showSearch: true,
264
+ // required
265
+ // focused={isShowErrorAlert}
266
+ value: memoizedEventAttributeValue || undefined, placeholder: t(translations.selectEventAttribute.title).toString(), treeData: treeEventAttrs.map(attr => (Object.assign(Object.assign({}, attr), { children: buildOptionAttrArchive(attr.children || [], memoizedEventAttributeValue) }))), loading: loading.isLoadingAttrs, onChange: onChangeEventAttribute, status: errorMessage ? 'error' : '' })));
267
+ });
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export declare const SelectEventAttributeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const StyledSelect: import("styled-components").StyledComponent<{
4
+ (props: import("@antscorp/antsomi-ui/es/components/molecules").SelectV2Props): import("react").JSX.Element;
5
+ defaultProps: {
6
+ suffixIcon: import("react").JSX.Element;
7
+ filterOption: (input: any, option: any) => boolean;
8
+ tagRender: (props: any) => import("react").JSX.Element;
9
+ containerStyle: {};
10
+ labelStyle: {};
11
+ clearIcon: import("react").JSX.Element;
12
+ };
13
+ }, any, {}, never>;
@@ -0,0 +1,13 @@
1
+ // Libraries
2
+ import { SelectV2 as Select } from '@antscorp/antsomi-ui/es/components/molecules';
3
+ import styled from 'styled-components';
4
+ export const SelectEventAttributeWrapper = styled.div `
5
+ display: flex;
6
+ flex-direction: column;
7
+ margin-top: 10px;
8
+ `;
9
+ export const StyledSelect = styled(Select) `
10
+ .antsomi-select-selector {
11
+ height: auto;
12
+ }
13
+ `;
@@ -0,0 +1,17 @@
1
+ import React, { MouseEventHandler } from 'react';
2
+ import { SelectProps as AntdSelectProps } from 'antd/lib/select';
3
+ interface SelectMultiProps extends AntdSelectProps {
4
+ label?: string;
5
+ }
6
+ export declare const SelectMulti: React.FC<SelectMultiProps>;
7
+ export declare const SelectMultiOption: import("rc-select/lib/Option").OptionFC;
8
+ export declare const SelectMultOptGroup: import("rc-select/lib/OptGroup").OptionGroupFC;
9
+ interface SelectOptionLabelProps {
10
+ title?: string;
11
+ label: string;
12
+ checked: boolean;
13
+ onClick: MouseEventHandler<HTMLDivElement>;
14
+ disabled?: boolean;
15
+ }
16
+ export declare const SelectOptionLabel: React.FC<SelectOptionLabelProps>;
17
+ export {};
@@ -0,0 +1,50 @@
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 from 'react';
14
+ // Antd components
15
+ import { Select as AntdSelect } from 'antd';
16
+ // Atoms
17
+ import { Text, Checkbox, Icon } from '../../atoms';
18
+ // Styled
19
+ import { StyledSelect, SelectWrapper as SelectMultiWrapper } from './styled';
20
+ export const SelectMulti = props => {
21
+ const { label, children } = props, restOf = __rest(props, ["label", "children"]);
22
+ return (React.createElement(SelectMultiWrapper, null,
23
+ label && (React.createElement(Text, { style: { marginBottom: 5 }, color: "#666666" }, label)),
24
+ React.createElement(StyledSelect, Object.assign({}, restOf), children),
25
+ React.createElement(Icon, { type: "icon-antsomi-expand-more", className: "icon-arrow-down" })));
26
+ };
27
+ export const SelectMultiOption = AntdSelect.Option;
28
+ export const SelectMultOptGroup = AntdSelect.OptGroup;
29
+ export const SelectOptionLabel = props => {
30
+ const { title, label, checked, onClick, disabled } = props;
31
+ return (React.createElement("div", { style: {
32
+ display: 'flex',
33
+ alignItems: 'center',
34
+ pointerEvents: disabled ? 'none' : 'auto',
35
+ opacity: disabled ? 0.5 : 1,
36
+ }, onClick: onClick },
37
+ React.createElement(Checkbox, { checked: checked }),
38
+ React.createElement(Text, { style: {
39
+ marginLeft: 8,
40
+ overflow: 'hidden',
41
+ textOverflow: 'ellipsis',
42
+ whiteSpace: 'nowrap',
43
+ }, title: title || label }, label)));
44
+ };
45
+ SelectMulti.defaultProps = {
46
+ mode: 'multiple',
47
+ suffixIcon: React.createElement(Icon, { type: "icon-antsomi-expand-more" }),
48
+ value: [],
49
+ onChange: () => { },
50
+ };
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ export declare const SelectWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const StyledSelect: import("styled-components").StyledComponent<(<ValueType = any, OptionType extends import("rc-select/lib/Select").DefaultOptionType | import("rc-select/lib/Select").BaseOptionType = import("rc-select/lib/Select").DefaultOptionType>(props: import("antd").SelectProps<ValueType, OptionType> & {
4
+ children?: import("react").ReactNode;
5
+ } & import("react").RefAttributes<import("antd").RefSelectProps>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) & {
6
+ displayName?: string | undefined;
7
+ SECRET_COMBOBOX_MODE_DO_NOT_USE: string;
8
+ Option: import("rc-select/lib/Option").OptionFC;
9
+ OptGroup: import("rc-select/lib/OptGroup").OptionGroupFC;
10
+ _InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/_util/type").AnyObject) => import("react").JSX.Element;
11
+ }, any, {}, never>;
@@ -0,0 +1,71 @@
1
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2
+ // Libraries
3
+ import styled from 'styled-components';
4
+ // Antd components
5
+ import { Select as AntdSelect } from 'antd';
6
+ // Constants
7
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
8
+ export const SelectWrapper = styled.div `
9
+ display: flex;
10
+ flex-direction: column;
11
+ position: relative;
12
+
13
+ .icon-arrow-down {
14
+ position: absolute;
15
+ bottom: 4px;
16
+ right: 8px;
17
+ }
18
+ `;
19
+ export const StyledSelect = styled(AntdSelect) `
20
+ font-family: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.fontFamily};
21
+
22
+ .antsomi-select-arrow {
23
+ display: flex;
24
+ align-items: center;
25
+ color: ${(_b = THEME.token) === null || _b === void 0 ? void 0 : _b.colorTextBase} !important;
26
+ }
27
+
28
+ .antsomi-select-selector {
29
+ justify-content: space-between;
30
+ height: 30px;
31
+ padding: 0 5px;
32
+ font-size: ${(_c = THEME.token) === null || _c === void 0 ? void 0 : _c.fontSize}px;
33
+ font-weight: normal;
34
+
35
+ transition: all 0.3s ease;
36
+ color: ${(_d = THEME.token) === null || _d === void 0 ? void 0 : _d.colorTextBase};
37
+
38
+ &:hover {
39
+ background-color: ${(_e = THEME.token) === null || _e === void 0 ? void 0 : _e.blue0};
40
+ }
41
+
42
+ border-radius: 0px !important;
43
+ border-style: none !important;
44
+ --tw-shadow: 0 1px 0 0 ${(_f = THEME.token) === null || _f === void 0 ? void 0 : _f.blue1} !important;
45
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
46
+ var(--tw-shadow) !important;
47
+
48
+ cursor: pointer !important;
49
+ caret-color: transparent;
50
+
51
+ &:active,
52
+ &:focus {
53
+ background-color: ${(_g = THEME.token) === null || _g === void 0 ? void 0 : _g.blue0};
54
+ --tw-shadow: 0 1px 0 0 #194e8d !important;
55
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
56
+ var(--tw-shadow) !important;
57
+ }
58
+
59
+ &:disabled {
60
+ background-color: ${(_h = THEME.token) === null || _h === void 0 ? void 0 : _h.accent};
61
+ color: ${(_j = THEME.token) === null || _j === void 0 ? void 0 : _j.accent5};
62
+ box-shadow: 0 1px 0 0 ${(_k = THEME.token) === null || _k === void 0 ? void 0 : _k.accent1};
63
+ }
64
+ }
65
+
66
+ &.antsomi-select-disabled {
67
+ .antsomi-select-arrow {
68
+ color: ${(_l = THEME.token) === null || _l === void 0 ? void 0 : _l.accent5} !important;
69
+ }
70
+ }
71
+ `;
@@ -0,0 +1,34 @@
1
+ import React, { ReactNode } from 'react';
2
+ import type { CustomTagProps } from 'rc-select/lib/BaseSelect';
3
+ import { CSSProperties } from 'styled-components';
4
+ import { SelectProps as AntdSelectProps } from 'antd';
5
+ export interface SelectProps extends AntdSelectProps {
6
+ label?: ReactNode;
7
+ labelClassname?: string;
8
+ description?: string;
9
+ showCount?: boolean;
10
+ maxLength?: number;
11
+ errorMsg?: string;
12
+ errorArchive?: string;
13
+ containerStyle?: CSSProperties;
14
+ labelStyle?: CSSProperties;
15
+ isReverseMask?: boolean;
16
+ required?: boolean;
17
+ focused?: boolean;
18
+ }
19
+ type TTagRender = CustomTagProps & {
20
+ style?: CSSProperties;
21
+ };
22
+ export declare const SelectV2: {
23
+ (props: SelectProps): React.JSX.Element;
24
+ defaultProps: {
25
+ suffixIcon: React.JSX.Element;
26
+ filterOption: (input: any, option: any) => boolean;
27
+ tagRender: (props: any) => React.JSX.Element;
28
+ containerStyle: {};
29
+ labelStyle: {};
30
+ clearIcon: React.JSX.Element;
31
+ };
32
+ };
33
+ export declare const tagRender: (props: TTagRender) => React.JSX.Element;
34
+ export {};