@antscorp/antsomi-ui 1.3.5-beta.363 → 1.3.5-beta.365
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/assets/css/main.scss +4 -0
- package/es/components/molecules/AccountSelection/hooks/useAccountSelection.js +15 -7
- package/es/components/molecules/CalendarSelection/CalendarSelection.js +18 -9
- package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.js +40 -39
- package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.js +12 -81
- package/es/components/molecules/CalendarSelection/components/RangePicker/RangePicker.js +1 -1
- package/es/components/molecules/CalendarSelection/components/RangePicker/styled.js +18 -5
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.d.ts +1 -1
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/NumOfDaysRanges/index.js +1 -1
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.js +29 -2
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.d.ts +2 -2
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.js +2 -2
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js +7 -13
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.js +15 -56
- package/es/components/molecules/CalendarSelection/index.d.ts +31 -0
- package/es/components/molecules/CalendarSelection/index.js +6 -1
- package/es/components/molecules/CalendarSelection/utils.js +1 -1
- package/es/components/molecules/index.d.ts +1 -1
- package/es/components/molecules/index.js +1 -1
- package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +7 -2
- package/es/components/organism/LeftMenu/hooks/usePermission.js +2 -2
- package/es/components/organism/LeftMenu/utils/index.d.ts +2 -1
- package/es/components/organism/LeftMenu/utils/index.js +5 -1
- package/es/components/template/Layout/Layout.js +8 -2
- package/es/providers/AppConfigProvider/contexts/index.d.ts +2 -0
- package/es/utils/common.d.ts +1 -1
- package/es/utils/common.js +3 -3
- package/package.json +1 -1
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.d.ts +0 -1
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/styled.js +0 -29
package/es/assets/css/main.scss
CHANGED
|
@@ -3,13 +3,21 @@ import { useMemo } from 'react';
|
|
|
3
3
|
// Queries
|
|
4
4
|
import { useGetAccountList, useGetPermissionAccountList, useGetRecentAccount, } from '@antscorp/antsomi-ui/es/queries';
|
|
5
5
|
// Constant
|
|
6
|
-
import {
|
|
6
|
+
import { APP_CODES } from '@antscorp/antsomi-ui/es/constants';
|
|
7
|
+
const { APP_ANTALYSER, DATAFLOWS } = APP_CODES;
|
|
8
|
+
// NOTES: Just define for account selection
|
|
9
|
+
const isUsePermissionAccount = (appCode) => {
|
|
10
|
+
if ([APP_ANTALYSER, DATAFLOWS].includes(appCode)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
};
|
|
7
15
|
export const useAccountSelection = (apiConfig) => {
|
|
8
|
-
const { domain, token, userId, appCode, menuCode
|
|
16
|
+
const { domain, token, userId, appCode, menuCode } = apiConfig;
|
|
9
17
|
const { data } = useGetAccountList({
|
|
10
18
|
apiConfig,
|
|
11
19
|
options: {
|
|
12
|
-
enabled:
|
|
20
|
+
enabled: !isUsePermissionAccount(appCode || ''),
|
|
13
21
|
},
|
|
14
22
|
});
|
|
15
23
|
const { data: permissionAccountList } = useGetPermissionAccountList({
|
|
@@ -24,18 +32,18 @@ export const useAccountSelection = (apiConfig) => {
|
|
|
24
32
|
menuCode: menuCode || appCode || '',
|
|
25
33
|
},
|
|
26
34
|
options: {
|
|
27
|
-
enabled:
|
|
35
|
+
enabled: isUsePermissionAccount(appCode || ''),
|
|
28
36
|
},
|
|
29
37
|
});
|
|
30
38
|
const { data: recentData } = useGetRecentAccount({
|
|
31
39
|
apiConfig,
|
|
32
40
|
options: {
|
|
33
|
-
enabled:
|
|
41
|
+
enabled: !isUsePermissionAccount(appCode || ''),
|
|
34
42
|
},
|
|
35
43
|
});
|
|
36
44
|
// Memos
|
|
37
45
|
const accountData = useMemo(() => {
|
|
38
|
-
if (
|
|
46
|
+
if (isUsePermissionAccount(appCode || '')) {
|
|
39
47
|
return ((permissionAccountList === null || permissionAccountList === void 0 ? void 0 : permissionAccountList.map(account => ({
|
|
40
48
|
email: account.email,
|
|
41
49
|
userId: account.user_id,
|
|
@@ -44,6 +52,6 @@ export const useAccountSelection = (apiConfig) => {
|
|
|
44
52
|
}))) || []);
|
|
45
53
|
}
|
|
46
54
|
return (data === null || data === void 0 ? void 0 : data.entries) || [];
|
|
47
|
-
}, [data === null || data === void 0 ? void 0 : data.entries, permissionAccountList
|
|
55
|
+
}, [appCode, data === null || data === void 0 ? void 0 : data.entries, permissionAccountList]);
|
|
48
56
|
return { recentData, accountData };
|
|
49
57
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-no-constructed-context-values */
|
|
2
2
|
import React, { useLayoutEffect, useReducer, useRef } from 'react';
|
|
3
|
-
import { Divider } from 'antd';
|
|
3
|
+
import { Divider, ConfigProvider as AntdConfigProvider } from 'antd';
|
|
4
4
|
import { ActionContext, StateContext } from './context';
|
|
5
5
|
import { reducer, INITIAL_STATE } from './reducer';
|
|
6
6
|
import { StyledPopover, StyledPopoverBody, StyledPopoverContainer } from './styled';
|
|
@@ -34,12 +34,21 @@ export const CalendarSelection = props => {
|
|
|
34
34
|
React.createElement(Divider, { style: { margin: 0 } }),
|
|
35
35
|
React.createElement(Footer, null)));
|
|
36
36
|
// console.log(state.value.current.rangeValue);
|
|
37
|
-
return (React.createElement(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
37
|
+
return (React.createElement(AntdConfigProvider, { theme: {
|
|
38
|
+
components: {
|
|
39
|
+
Popover: {
|
|
40
|
+
borderRadiusLG: 0,
|
|
41
|
+
borderRadius: 0,
|
|
42
|
+
borderRadiusOuter: 0,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
} },
|
|
46
|
+
React.createElement(StateContext.Provider, { value: Object.assign(Object.assign({}, state), { rangeLimit,
|
|
47
|
+
timezone }) },
|
|
48
|
+
React.createElement(ActionContext.Provider, { value: { dispatch } },
|
|
49
|
+
React.createElement(StyledPopover, Object.assign({}, popoverProps, { open: state.open, arrow: false, trigger: ['click'], content: popoverContent, destroyTooltipOnHide: true, overlayInnerStyle: { padding: 0 }, onOpenChange: isOpen => {
|
|
50
|
+
if (!isOpen)
|
|
51
|
+
dispatch({ type: 'toggle_popover' });
|
|
52
|
+
} }),
|
|
53
|
+
React.createElement(TimeRangeDisplay, Object.assign({}, timeDisplayProps)))))));
|
|
45
54
|
};
|
|
@@ -65,44 +65,45 @@ export const CustomPicker = props => {
|
|
|
65
65
|
return React.createElement(StyledCellDate, { rangeColor: cellBgColor }, originNode);
|
|
66
66
|
}, [rangeValue]);
|
|
67
67
|
return (React.createElement(StyledCustomPickerRoot, null,
|
|
68
|
-
React.createElement("div", { className: "
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
React.createElement("div", { className: "range-input
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
68
|
+
React.createElement("div", { className: "section-input" },
|
|
69
|
+
React.createElement("div", { className: "range-inputs" }, rangeValue.map((range, rangeIdx) => (React.createElement(ConfigProvider, { key: rangeIdx, theme: {
|
|
70
|
+
components: {
|
|
71
|
+
DatePicker: Object.assign({ cellHeight: 20 }, (range.color && {
|
|
72
|
+
hoverBorderColor: range.color,
|
|
73
|
+
colorBorder: range.color,
|
|
74
|
+
colorPrimary: range.color,
|
|
75
|
+
colorPrimaryActive: range.color,
|
|
76
|
+
cellActiveWithRangeBg: new TinyColor(range.color).lighten(40).toHexString(),
|
|
77
|
+
})),
|
|
78
|
+
},
|
|
79
|
+
} },
|
|
80
|
+
React.createElement("div", { className: "range-input" },
|
|
81
|
+
React.createElement("div", { className: "range-input-label" }, generateRangeInputLabel(rangeIdx, range.label)),
|
|
82
|
+
React.createElement(RangePicker, Object.assign({}, rest, { open: true, value: [dayjs(range.start), dayjs(range.end)], onClick: () => setActiveRangeIdx(rangeIdx), getPopupContainer: () => popupContainer.current || document.body, panelRender: originalPanel => {
|
|
83
|
+
if (activeRangeIdx !== rangeIdx)
|
|
84
|
+
return null;
|
|
85
|
+
return originalPanel;
|
|
86
|
+
}, cellRender: (current, info) => {
|
|
87
|
+
if (typeof current === 'number' || info.type !== 'date') {
|
|
88
|
+
return info.originNode;
|
|
89
|
+
}
|
|
90
|
+
return renderCellDate(current, info.originNode);
|
|
91
|
+
}, onCalendarChange: value => {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
let start = '';
|
|
94
|
+
let end = '';
|
|
95
|
+
const valueFirst = dayjs((_a = value === null || value === void 0 ? void 0 : value.at(0)) === null || _a === void 0 ? void 0 : _a.toDate());
|
|
96
|
+
const valueSecond = dayjs((_b = value === null || value === void 0 ? void 0 : value.at(1)) === null || _b === void 0 ? void 0 : _b.toDate());
|
|
97
|
+
if (valueFirst.isBefore(valueSecond)) {
|
|
98
|
+
start = valueFirst.toISOString();
|
|
99
|
+
end = valueSecond.toISOString();
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
start = valueSecond.toISOString();
|
|
103
|
+
end = valueFirst.toISOString();
|
|
104
|
+
}
|
|
105
|
+
handleCalendarChange(start, end);
|
|
106
|
+
} }))))))),
|
|
107
|
+
React.createElement(AutoUpdateTo, null)),
|
|
107
108
|
React.createElement(CalendarContainerStyled, { className: "calendar-container", ref: popupContainer })));
|
|
108
109
|
};
|
|
@@ -20,17 +20,23 @@ export const StyledCustomPickerRoot = styled.div `
|
|
|
20
20
|
display: flex;
|
|
21
21
|
flex-direction: column;
|
|
22
22
|
gap: 8px;
|
|
23
|
-
padding: 8px 12px;
|
|
24
23
|
|
|
25
|
-
.
|
|
24
|
+
.section-input {
|
|
25
|
+
padding: 8px 12px;
|
|
26
26
|
display: flex;
|
|
27
27
|
flex-direction: column;
|
|
28
|
-
gap:
|
|
28
|
+
gap: 4px;
|
|
29
29
|
|
|
30
|
-
.range-
|
|
30
|
+
.range-inputs {
|
|
31
31
|
display: flex;
|
|
32
32
|
flex-direction: column;
|
|
33
|
-
gap:
|
|
33
|
+
gap: 8px;
|
|
34
|
+
|
|
35
|
+
.range-input {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: 4px;
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
|
|
@@ -68,83 +74,8 @@ export const CalendarContainerStyled = styled.div `
|
|
|
68
74
|
|
|
69
75
|
/* Content */
|
|
70
76
|
.antsomi-picker-content {
|
|
71
|
-
/* Rectangle */
|
|
72
|
-
& td,
|
|
73
|
-
& th,
|
|
74
|
-
& .antsomi-picker-cell-inner,
|
|
75
|
-
& td::before {
|
|
76
|
-
/* width: var(--cellWidth);
|
|
77
|
-
height: var(--cellHeight); */
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* Date node */
|
|
81
|
-
.antsomi-picker-cell-inner {
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/* Today node */
|
|
85
|
-
.antsomi-picker-cell-today {
|
|
86
|
-
.antsomi-picker-cell-inner {
|
|
87
|
-
&::before {
|
|
88
|
-
border-radius: 18px;
|
|
89
|
-
border: 0.0001rem solid var(--colorToDay);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/* Selected node */
|
|
95
|
-
.antsomi-picker-cell-in-view {
|
|
96
|
-
&.antsomi-picker-cell-selected,
|
|
97
|
-
&.antsomi-picker-cell-range-start,
|
|
98
|
-
&.antsomi-picker-cell-range-end {
|
|
99
|
-
.antsomi-picker-cell-inner {
|
|
100
|
-
background: var(--colorSelected) !important;
|
|
101
|
-
border-radius: 18px !important;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/* In Range */
|
|
107
|
-
.antsomi-picker-cell-in-range.antsomi-picker-cell-in-view {
|
|
108
|
-
&::before {
|
|
109
|
-
background: var(--colorInRange) !important;
|
|
110
|
-
}
|
|
111
|
-
.antsomi-picker-cell-inner {
|
|
112
|
-
/* background: var(--colorInRange) !important; */
|
|
113
|
-
&::after {
|
|
114
|
-
content: none !important;
|
|
115
|
-
background: var(--colorInRange) !important;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/* In Range Start End */
|
|
121
|
-
.antsomi-picker-cell-in-view.antsomi-picker-cell-range-start:not(
|
|
122
|
-
.antsomi-picker-cell-range-start-single
|
|
123
|
-
) {
|
|
124
|
-
&::before {
|
|
125
|
-
background: var(--colorInRange) !important;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
.antsomi-picker-cell-in-view.antsomi-picker-cell-range-end:not(
|
|
129
|
-
.antsomi-picker-cell-range-end-single
|
|
130
|
-
) {
|
|
131
|
-
&::before {
|
|
132
|
-
background: var(--colorInRange) !important;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/* Hover */
|
|
137
|
-
.antsomi-picker-cell-in-view {
|
|
138
|
-
&.antsomi-picker-cell-range-hover,
|
|
139
|
-
&.antsomi-picker-cell-range-hover-start,
|
|
140
|
-
&.antsomi-picker-cell-range-hover-end {
|
|
141
|
-
&:not(.antsomi-picker-cell-in-range)::after {
|
|
142
|
-
content: none !important;
|
|
143
|
-
border: none;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
77
|
}
|
|
78
|
+
|
|
148
79
|
.antsomi-picker-range-arrow {
|
|
149
80
|
display: none !important;
|
|
150
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyledRangePicker } from './styled';
|
|
3
3
|
const DATE_FORMAT = 'DD/MM/YYYY';
|
|
4
|
-
export const RangePicker = props => (React.createElement(StyledRangePicker, Object.assign({}, props, { allowEmpty: [true, true], allowClear: false, autoFocus: false, size: "
|
|
4
|
+
export const RangePicker = props => (React.createElement(StyledRangePicker, Object.assign({}, props, { allowEmpty: [true, true], allowClear: false, autoFocus: false, bordered: false, size: "middle", suffixIcon: false, format: DATE_FORMAT })));
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import { DatePicker } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
2
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
const { RangePicker } = DatePicker;
|
|
4
5
|
export const StyledRangePicker = styled(RangePicker) `
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
&.antsomi-picker {
|
|
7
|
+
font-size: 12px;
|
|
8
|
+
padding: 0;
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
.antsomi-picker-active-bar {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.antsomi-picker-input {
|
|
15
|
+
padding: 4px 10px;
|
|
16
|
+
|
|
17
|
+
&.antsomi-picker-input-active {
|
|
18
|
+
border-bottom: 2px solid ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
input {
|
|
22
|
+
font-size: inherit;
|
|
23
|
+
}
|
|
11
24
|
}
|
|
12
25
|
}
|
|
13
26
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { NumOfDaysRanges } from './NumOfDaysRanges';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { NumOfDaysRanges } from './NumOfDaysRanges';
|
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
|
+
import { List, Menu } from 'antd';
|
|
2
3
|
import Icon from '@antscorp/icons';
|
|
4
|
+
import styled from 'styled-components';
|
|
3
5
|
import { Popover } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
4
6
|
import classNames from 'classnames';
|
|
5
7
|
import { useCalendarSelectionContext } from '../../../../hooks';
|
|
6
8
|
import { changeRangeType } from '../../../../actions';
|
|
7
9
|
import { rangeInfoToStringType } from '../../../../utils';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
const StyledMenu = styled(Menu) `
|
|
11
|
+
&.antsomi-menu-root {
|
|
12
|
+
.antsomi-menu-item {
|
|
13
|
+
position: relative;
|
|
14
|
+
color: black;
|
|
15
|
+
height: 32px;
|
|
16
|
+
line-height: 32px;
|
|
17
|
+
border-radius: 0;
|
|
18
|
+
width: 100%;
|
|
19
|
+
margin: 0;
|
|
20
|
+
|
|
21
|
+
&.antsomi-menu-item-selected {
|
|
22
|
+
font-weight: bold;
|
|
23
|
+
|
|
24
|
+
&:after {
|
|
25
|
+
content: '';
|
|
26
|
+
position: absolute;
|
|
27
|
+
left: 0;
|
|
28
|
+
top: 0;
|
|
29
|
+
width: 4px;
|
|
30
|
+
height: 100%;
|
|
31
|
+
background-color: #005fb8;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
10
37
|
export const Option = props => {
|
|
11
38
|
const itemRef = useRef(null);
|
|
12
39
|
const { label = '', options = [], type } = props;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { Option } from './Option';
|
|
2
|
+
export { NumOfDaysRanges } from './NumOfDaysRanges';
|
package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { Option } from './Option';
|
|
2
|
+
export { NumOfDaysRanges } from './NumOfDaysRanges';
|
package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js
CHANGED
|
@@ -10,22 +10,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import cls from 'clsx';
|
|
13
|
-
import React, { forwardRef
|
|
13
|
+
import React, { forwardRef } from 'react';
|
|
14
14
|
import { Typography } from '@antscorp/antsomi-ui/es/components/atoms';
|
|
15
15
|
import { ACTION_TYPES } from '../../actions';
|
|
16
16
|
import { useCalendarSelectionContext } from '../../hooks';
|
|
17
17
|
import { getRangeTypeSelectedTitle, getRangeValueSelctedTitle } from '../../utils';
|
|
18
18
|
import { StyledBtnDisplayWrapper } from './styled';
|
|
19
|
-
import Icon from '@antscorp/icons';
|
|
20
19
|
const { Text } = Typography;
|
|
21
20
|
export const TimeRangeDisplay = forwardRef((props, ref) => {
|
|
22
21
|
const { showType = true, formatStart, formatEnd, operator } = props, rest = __rest(props, ["showType", "formatStart", "formatEnd", "operator"]);
|
|
23
22
|
const { state, action } = useCalendarSelectionContext();
|
|
24
|
-
// console.log({ state, action });
|
|
25
|
-
const [collapse, setCollapse] = useState(false);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
setCollapse(false);
|
|
28
|
-
}, []);
|
|
29
23
|
const { rangeInfo, rangeValue } = state.value.original;
|
|
30
24
|
const handleOpenPopover = () => {
|
|
31
25
|
action.dispatch({ type: ACTION_TYPES.togglePopover });
|
|
@@ -36,14 +30,14 @@ export const TimeRangeDisplay = forwardRef((props, ref) => {
|
|
|
36
30
|
formatEnd,
|
|
37
31
|
operator,
|
|
38
32
|
});
|
|
39
|
-
|
|
33
|
+
const renderDateTitle = (title) => (React.createElement(Text, { className: "range-date-title", ellipsis: {
|
|
34
|
+
tooltip: title,
|
|
35
|
+
} }, title));
|
|
40
36
|
return (React.createElement(StyledBtnDisplayWrapper, Object.assign({ ref: ref }, rest, { onClick: handleOpenPopover, role: "button" }),
|
|
41
37
|
showType && (React.createElement(Text, { className: "range-type", ellipsis: { tooltip: rangeSelectedTitle } }, rangeSelectedTitle)),
|
|
42
|
-
React.createElement("div", { className: cls('range-date'
|
|
43
|
-
rangeValue.length > 0 && (
|
|
44
|
-
rangeValueTitles[0],
|
|
45
|
-
React.createElement(Icon, { className: "collapse-btn", type: "icon-ants-angle-down", style: { fontSize: 9 } }))),
|
|
38
|
+
React.createElement("div", { className: cls('range-date') },
|
|
39
|
+
rangeValue.length > 0 && renderDateTitle(rangeValueTitles[0]),
|
|
46
40
|
rangeValue.length > 1 && (React.createElement("div", { className: cls('collapse-wrapper') }, rangeValueTitles.slice(1).map(title => (React.createElement(React.Fragment, { key: title },
|
|
47
41
|
React.createElement("div", { className: "compare-title" }, "Compare"),
|
|
48
|
-
|
|
42
|
+
renderDateTitle(title)))))))));
|
|
49
43
|
});
|
|
@@ -1,70 +1,29 @@
|
|
|
1
|
+
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
1
2
|
import styled from 'styled-components';
|
|
2
3
|
export const StyledBtnDisplayWrapper = styled.div `
|
|
3
4
|
display: flex;
|
|
4
5
|
overflow: hidden;
|
|
5
6
|
text-overflow: ellipsis;
|
|
6
|
-
background-color: transparent;
|
|
7
7
|
cursor: pointer;
|
|
8
8
|
width: fit-content;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
gap: 4px;
|
|
11
|
+
line-height: 1.4;
|
|
9
12
|
|
|
10
13
|
.range-type {
|
|
11
|
-
/* font-size: 0.75rem;
|
|
12
|
-
width: fit-content;
|
|
13
|
-
padding: 2px 8px; */
|
|
14
|
-
|
|
15
14
|
display: block;
|
|
16
|
-
font-size:
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
font-size: 11px;
|
|
16
|
+
padding: 3px 5px;
|
|
17
|
+
border-radius: 3px;
|
|
18
|
+
width: fit-content;
|
|
19
|
+
background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw2};
|
|
20
|
+
line-height: inherit;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
.range-date {
|
|
22
|
-
|
|
23
|
-
border-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
background: transparent;
|
|
27
|
-
border-bottom: 1px solid rgb(184, 207, 230);
|
|
28
|
-
text-align: left;
|
|
29
|
-
display: flex;
|
|
30
|
-
-webkit-box-pack: justify;
|
|
31
|
-
justify-content: space-between;
|
|
32
|
-
-webkit-box-align: center;
|
|
33
|
-
align-items: center;
|
|
34
|
-
font-size: 0.75rem;
|
|
35
|
-
padding: 2px 8px;
|
|
36
|
-
max-width: unset;
|
|
37
|
-
|
|
38
|
-
.range-date-title {
|
|
39
|
-
display: flex;
|
|
40
|
-
align-items: center;
|
|
41
|
-
gap: 8px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.collapse-wrapper {
|
|
45
|
-
display: flex;
|
|
46
|
-
flex-direction: column;
|
|
47
|
-
gap: 2px;
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
|
|
50
|
-
.compare-title {
|
|
51
|
-
font-size: 11px;
|
|
52
|
-
color: #878d93;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.collapse-btn {
|
|
57
|
-
padding: 4px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
&.collapse {
|
|
61
|
-
.collapse-wrapper {
|
|
62
|
-
height: 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.collapse-btn {
|
|
66
|
-
transform: rotate(180deg);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
23
|
+
.range-date-title {
|
|
24
|
+
padding: 3px 5px;
|
|
25
|
+
border-radius: 3px;
|
|
26
|
+
background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue1_1};
|
|
27
|
+
line-height: inherit;
|
|
69
28
|
}
|
|
70
29
|
`;
|
|
@@ -21,5 +21,36 @@ export declare const CalendarSelectionConstants: {
|
|
|
21
21
|
readonly days_up_to_today: "days_up_to_today";
|
|
22
22
|
readonly days_up_to_yesterday: "days_up_to_yesterday";
|
|
23
23
|
};
|
|
24
|
+
AUTO_UPDATE_TO_KEY: {
|
|
25
|
+
readonly today: "today";
|
|
26
|
+
readonly yesterday: "yesterday";
|
|
27
|
+
readonly fixed: "fixed";
|
|
28
|
+
};
|
|
24
29
|
};
|
|
25
30
|
export type { TriggerOutInfo, CalendarSelectionValue } from './types';
|
|
31
|
+
export declare const CalendarSelectionUtils: {
|
|
32
|
+
getDefaultDate: () => {
|
|
33
|
+
toDay: string;
|
|
34
|
+
yesterday: string;
|
|
35
|
+
startWeekSS: string;
|
|
36
|
+
startWeekMS: string;
|
|
37
|
+
last7Days: string;
|
|
38
|
+
startLastWeekSS: string;
|
|
39
|
+
startLastWeekMS: string;
|
|
40
|
+
endLastWeekSS: string;
|
|
41
|
+
endLastWeekMS: string;
|
|
42
|
+
last14Days: string;
|
|
43
|
+
startOfThisMonth: string;
|
|
44
|
+
endOfThisMonth: string;
|
|
45
|
+
last30Days: string;
|
|
46
|
+
lastMonthFirstDate: string;
|
|
47
|
+
lastMonthLastDate: string;
|
|
48
|
+
thisQuaterFirstDate: string;
|
|
49
|
+
thisQuaterLastDate: string;
|
|
50
|
+
lastQuaterFirstDate: string;
|
|
51
|
+
lastQuaterLastDate: string;
|
|
52
|
+
maxSub: number;
|
|
53
|
+
todayUptoCount: (val: number) => string;
|
|
54
|
+
yesterdayUptoCount: (val: number) => string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { TRIGGER_OUT_MODE, SELECTION_KEY } from './constants';
|
|
1
|
+
import { TRIGGER_OUT_MODE, SELECTION_KEY, AUTO_UPDATE_TO_KEY } from './constants';
|
|
2
|
+
import { getDefaultDate } from './utils';
|
|
2
3
|
export { CalendarSelection } from './CalendarSelection';
|
|
3
4
|
export const CalendarSelectionConstants = {
|
|
4
5
|
TRIGGER_OUT_MODE,
|
|
5
6
|
SELECTION_KEY,
|
|
7
|
+
AUTO_UPDATE_TO_KEY,
|
|
8
|
+
};
|
|
9
|
+
export const CalendarSelectionUtils = {
|
|
10
|
+
getDefaultDate,
|
|
6
11
|
};
|
|
@@ -7,7 +7,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear';
|
|
|
7
7
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
8
8
|
import { AUTO_UPDATE_TO_KEY, DEFAULT_NUM_UP_TO, MAP_TITLE, RANGE_LIMIT, SELECTION_KEY, } from './constants';
|
|
9
9
|
import { last } from 'lodash';
|
|
10
|
-
import { asssertCannotReach } from '@antscorp/antsomi-ui/es/utils
|
|
10
|
+
import { asssertCannotReach } from '@antscorp/antsomi-ui/es/utils';
|
|
11
11
|
dayjs.extend(utc);
|
|
12
12
|
dayjs.extend(timezone);
|
|
13
13
|
dayjs.extend(isoWeek);
|
|
@@ -48,6 +48,7 @@ export { ModalSelect } from './ModalSelect';
|
|
|
48
48
|
export { EditableName } from './EditableName';
|
|
49
49
|
export { VirtualizedMenu } from './VirtualizedMenu';
|
|
50
50
|
export { SearchPopover, PopoverAddField } from './SearchPopover';
|
|
51
|
+
export { CalendarSelection, CalendarSelectionConstants, CalendarSelectionUtils, } from './CalendarSelection';
|
|
51
52
|
export * from './EmptyData';
|
|
52
53
|
export * from './PreviewModal';
|
|
53
54
|
export * from './Drawer';
|
|
@@ -55,7 +56,6 @@ export * from './DrawerDetail';
|
|
|
55
56
|
export * from './ThumbnailCard';
|
|
56
57
|
export * from './ProcessLoading';
|
|
57
58
|
export { EditorScript } from './EditorScript';
|
|
58
|
-
export { CalendarSelection, CalendarSelectionConstants } from './CalendarSelection';
|
|
59
59
|
export { EditorTab } from './EditorTab';
|
|
60
60
|
export { SelectAccount } from './SelectAccount';
|
|
61
61
|
export type { AdvancedPickerProps, TAdvancedPickerOption, TAdvancedRangePickerTimeRange, } from './DatePicker';
|
|
@@ -48,6 +48,7 @@ export { ModalSelect } from './ModalSelect';
|
|
|
48
48
|
export { EditableName } from './EditableName';
|
|
49
49
|
export { VirtualizedMenu } from './VirtualizedMenu';
|
|
50
50
|
export { SearchPopover, PopoverAddField } from './SearchPopover';
|
|
51
|
+
export { CalendarSelection, CalendarSelectionConstants, CalendarSelectionUtils, } from './CalendarSelection';
|
|
51
52
|
export * from './EmptyData';
|
|
52
53
|
export * from './PreviewModal';
|
|
53
54
|
export * from './Drawer';
|
|
@@ -55,6 +56,5 @@ export * from './DrawerDetail';
|
|
|
55
56
|
export * from './ThumbnailCard';
|
|
56
57
|
export * from './ProcessLoading';
|
|
57
58
|
export { EditorScript } from './EditorScript';
|
|
58
|
-
export { CalendarSelection, CalendarSelectionConstants } from './CalendarSelection';
|
|
59
59
|
export { EditorTab } from './EditorTab';
|
|
60
60
|
export { SelectAccount } from './SelectAccount';
|
|
@@ -30,7 +30,7 @@ const styles = {
|
|
|
30
30
|
};
|
|
31
31
|
export const ChildMenu = memo(props => {
|
|
32
32
|
const { items = [], onMenuClick } = props;
|
|
33
|
-
const auth = useLeftMenuStore(store =>
|
|
33
|
+
const { auth, env } = useLeftMenuStore(store => store.state.appConfig) || {};
|
|
34
34
|
const activeAppCode = useLeftMenuStore(store => store.state.activeAppCode);
|
|
35
35
|
const menuItems = useLeftMenuStore(store => store.state.menuItems);
|
|
36
36
|
const customItems = useLeftMenuStore(store => store.state.customItems);
|
|
@@ -57,7 +57,12 @@ export const ChildMenu = memo(props => {
|
|
|
57
57
|
else {
|
|
58
58
|
const url = `${pathname}${hash}`;
|
|
59
59
|
// Active menu item by current url
|
|
60
|
-
const activeMenuItem = (_a = findLastMatchedItemByUrl({
|
|
60
|
+
const activeMenuItem = (_a = findLastMatchedItemByUrl({
|
|
61
|
+
url,
|
|
62
|
+
menuItems,
|
|
63
|
+
auth,
|
|
64
|
+
env,
|
|
65
|
+
})) === null || _a === void 0 ? void 0 : _a.menu_item_code;
|
|
61
66
|
if (activeMenuItem && activeMenuItem !== currentActiveItem) {
|
|
62
67
|
setCurrentActiveItem(activeMenuItem);
|
|
63
68
|
// Find parent key of active menu item to open it
|
|
@@ -13,7 +13,7 @@ export const usePermission = () => {
|
|
|
13
13
|
const appConfig = useLeftMenuStore(store => store.state.appConfig);
|
|
14
14
|
const isCustomized = useLeftMenuStore(store => store.state.isCustomized);
|
|
15
15
|
const { isGrouped, objectId, objectType } = useLeftMenuStore(store => store.state.dashboardParams);
|
|
16
|
-
const { auth, languageCode = 'en', env = 'development' } = appConfig || {};
|
|
16
|
+
const { auth, languageCode = 'en', env = 'development', permissionDomain } = appConfig || {};
|
|
17
17
|
const { pathname, hash } = window.location;
|
|
18
18
|
const { data: menuList } = useGetListMenu({
|
|
19
19
|
args: {
|
|
@@ -63,7 +63,7 @@ export const usePermission = () => {
|
|
|
63
63
|
args: {
|
|
64
64
|
auth: {
|
|
65
65
|
token: auth === null || auth === void 0 ? void 0 : auth.token,
|
|
66
|
-
url: PERMISSION_API,
|
|
66
|
+
url: permissionDomain || PERMISSION_API,
|
|
67
67
|
userId: auth === null || auth === void 0 ? void 0 : auth.userId,
|
|
68
68
|
accountId: auth === null || auth === void 0 ? void 0 : auth.userId,
|
|
69
69
|
},
|
|
@@ -32,7 +32,7 @@ export declare const getGeneratePath: (path: string, params?: Partial<PayloadInf
|
|
|
32
32
|
* This is used to delete the hash of the path returned from the api,
|
|
33
33
|
* the purpose of which is to compare with the url to activate the app
|
|
34
34
|
*/
|
|
35
|
-
export declare const getComparePath: (path: string) => string;
|
|
35
|
+
export declare const getComparePath: (path: string, env?: string) => string;
|
|
36
36
|
/**
|
|
37
37
|
* Creates an initial feature menu item object with default values.
|
|
38
38
|
* @param {Partial<TFeatureMenu>} featureMenuItem - The partial feature menu item object.
|
|
@@ -82,6 +82,7 @@ export declare const findLastMatchedItemByUrl: (args: {
|
|
|
82
82
|
url: string;
|
|
83
83
|
menuItems: TFeatureMenu[];
|
|
84
84
|
auth?: Partial<PayloadInfo>;
|
|
85
|
+
env?: string;
|
|
85
86
|
}) => TFeatureMenu | undefined;
|
|
86
87
|
export declare const findPathOfActiveItem: (args: {
|
|
87
88
|
activeMenuItem: TFeatureMenu;
|
|
@@ -16,6 +16,7 @@ import { APP_KEYS, MARKETING_CHANNEL_KEY, HOME_MENU_ITEMS, MARKETING_ROUTES, MEN
|
|
|
16
16
|
import { MARKETING_CHANNEL_CODE } from '../../../template/Layout/constants';
|
|
17
17
|
// Utils
|
|
18
18
|
import { handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
19
|
+
import { ENV } from '@antscorp/antsomi-ui/es/config';
|
|
19
20
|
const PATH = 'src/components/organism/LeftMenu/utils/index.ts';
|
|
20
21
|
/**
|
|
21
22
|
* Converts a feature menu item to a menu item suitable for rendering in the UI.
|
|
@@ -101,8 +102,11 @@ export const getGeneratePath = (path, params) => {
|
|
|
101
102
|
* This is used to delete the hash of the path returned from the api,
|
|
102
103
|
* the purpose of which is to compare with the url to activate the app
|
|
103
104
|
*/
|
|
104
|
-
export const getComparePath = (path) => {
|
|
105
|
+
export const getComparePath = (path, env) => {
|
|
105
106
|
var _a;
|
|
107
|
+
if (env !== ENV.DEV) {
|
|
108
|
+
return path;
|
|
109
|
+
}
|
|
106
110
|
if (path === null || path === void 0 ? void 0 : path.includes('#')) {
|
|
107
111
|
const customPath = ((_a = path === null || path === void 0 ? void 0 : path.split('#')) === null || _a === void 0 ? void 0 : _a[1]) || '';
|
|
108
112
|
return customPath;
|
|
@@ -36,7 +36,7 @@ export const Layout = memo(props => {
|
|
|
36
36
|
const _a = leftMenuProps || {}, { className = '' } = _a, restOfLeftMenuProps = __rest(_a, ["className"]);
|
|
37
37
|
const _b = workspaceProps || {}, { workspaceContentProps } = _b, restOfWorkspaceProps = __rest(_b, ["workspaceContentProps"]);
|
|
38
38
|
const appConfig = useContextSelector(AppConfigContext, state => state);
|
|
39
|
-
const { auth, languageCode, appCode, env } = appConfig;
|
|
39
|
+
const { auth, languageCode, appCode, permissionDomain: configPermissionDomain, env } = appConfig;
|
|
40
40
|
const { token, userId, portalId } = auth || {};
|
|
41
41
|
const showLeftMenu = useLayoutStore(store => store.state.leftMenu.show);
|
|
42
42
|
const header = useLayoutStore(store => store.state.header);
|
|
@@ -63,6 +63,12 @@ export const Layout = memo(props => {
|
|
|
63
63
|
// Memo
|
|
64
64
|
const permissionDomain = useMemo(() => {
|
|
65
65
|
var _a;
|
|
66
|
+
/**
|
|
67
|
+
* Priority for permission domain
|
|
68
|
+
*/
|
|
69
|
+
if (configPermissionDomain) {
|
|
70
|
+
return configPermissionDomain;
|
|
71
|
+
}
|
|
66
72
|
/**
|
|
67
73
|
* Check if appCode not exist and portalId is SANDBOX
|
|
68
74
|
* then return production permission api
|
|
@@ -76,7 +82,7 @@ export const Layout = memo(props => {
|
|
|
76
82
|
default:
|
|
77
83
|
return PERMISSION_API;
|
|
78
84
|
}
|
|
79
|
-
}, [appCode, env, portalId]);
|
|
85
|
+
}, [appCode, configPermissionDomain, env, portalId]);
|
|
80
86
|
const iamDomain = useMemo(() => {
|
|
81
87
|
var _a;
|
|
82
88
|
/**
|
|
@@ -8,6 +8,8 @@ export interface AppConfigProps {
|
|
|
8
8
|
menuCode?: string;
|
|
9
9
|
languageCode?: string;
|
|
10
10
|
urlLogout?: string;
|
|
11
|
+
/** Domain */
|
|
12
|
+
permissionDomain?: string;
|
|
11
13
|
setAppConfig: React.Dispatch<React.SetStateAction<AppConfigProviderProps>>;
|
|
12
14
|
}
|
|
13
15
|
export interface AppConfigProviderProps extends Omit<AppConfigProps, 'setAppConfig'> {
|
package/es/utils/common.d.ts
CHANGED
|
@@ -63,7 +63,6 @@ export declare const isEmail: (email: string) => boolean;
|
|
|
63
63
|
*/
|
|
64
64
|
export declare function mapNumberToOrdinalText(num: number): string;
|
|
65
65
|
export declare const searchParamsToObject: (searchParams?: string) => Record<string, unknown>;
|
|
66
|
-
export declare function asssertCannotReach(x: never): void;
|
|
67
66
|
export declare const getShuffleArray: <T>(array: T[]) => T[];
|
|
68
67
|
export declare const snakeCaseToCamelCase: <T = Record<string, any>>(object: Record<string, any> | Record<string, any>[], recursive?: boolean) => T;
|
|
69
68
|
export declare const camelCaseToSnakeCase: <T = Record<string, any>>(object: Record<string, any>, recursive?: boolean) => T;
|
|
@@ -86,3 +85,4 @@ export declare const searchStringQuery: (str: string, queryStr: string) => boole
|
|
|
86
85
|
export declare const isExistedImage: (imageUrl: string) => boolean;
|
|
87
86
|
export declare const getUrlNoCache: (url?: string, cacheValue?: number | string) => string;
|
|
88
87
|
export declare const safeParseJson: (json?: string | null, defaultValue?: any) => any;
|
|
88
|
+
export declare function asssertCannotReach(x: never): void;
|
package/es/utils/common.js
CHANGED
|
@@ -387,9 +387,6 @@ export function mapNumberToOrdinalText(num) {
|
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
export const searchParamsToObject = (searchParams = '') => Object.fromEntries(new URLSearchParams(searchParams));
|
|
390
|
-
export function asssertCannotReach(x) {
|
|
391
|
-
throw new Error('cannot reach this place in the code!');
|
|
392
|
-
}
|
|
393
390
|
export const getShuffleArray = (array) => {
|
|
394
391
|
for (let i = array.length - 1; i > 0; i--) {
|
|
395
392
|
/* Choose a random position from 0 to i */
|
|
@@ -502,3 +499,6 @@ export const safeParseJson = (json, defaultValue) => {
|
|
|
502
499
|
return defaultValue;
|
|
503
500
|
}
|
|
504
501
|
};
|
|
502
|
+
export function asssertCannotReach(x) {
|
|
503
|
+
throw new Error('cannot reach this place in the code!');
|
|
504
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const StyledMenu: any;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Menu } from 'antd';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
export const StyledMenu = styled(Menu) `
|
|
4
|
-
&.antsomi-menu-root {
|
|
5
|
-
.antsomi-menu-item {
|
|
6
|
-
position: relative;
|
|
7
|
-
color: black;
|
|
8
|
-
height: 32px;
|
|
9
|
-
line-height: 32px;
|
|
10
|
-
border-radius: 0;
|
|
11
|
-
width: 100%;
|
|
12
|
-
margin: 0;
|
|
13
|
-
|
|
14
|
-
&.antsomi-menu-item-selected {
|
|
15
|
-
font-weight: bold;
|
|
16
|
-
|
|
17
|
-
&:after {
|
|
18
|
-
content: '';
|
|
19
|
-
position: absolute;
|
|
20
|
-
left: 0;
|
|
21
|
-
top: 0;
|
|
22
|
-
width: 4px;
|
|
23
|
-
height: 100%;
|
|
24
|
-
background-color: #005fb8;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`;
|