@antscorp/antsomi-ui 1.3.5-beta.417 → 1.3.5-beta.419
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/molecules/ImageEditor/index.d.ts +1 -1
- package/es/components/organism/DataTable/components/Table/index.js +11 -11
- package/es/components/organism/DataTable/hooks/useDataTableListing/useDataTableListing.js +4 -4
- package/es/components/organism/LeftMenu/LeftMenu.js +3 -4
- package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +22 -9
- package/es/components/organism/LeftMenu/components/common/ChildMenu/utils.js +2 -2
- package/es/components/organism/LeftMenu/hooks/useLeftMenu.js +10 -12
- package/es/components/organism/LeftMenu/hooks/useNavigatePath.js +1 -0
- package/es/utils/cookies.d.ts +14 -0
- package/es/utils/cookies.js +33 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ImageEditor, ImageResizeHandle } from './ImageEditor';
|
|
1
|
+
export { ImageEditor, type ImageResizeHandle } from './ImageEditor';
|
|
@@ -55,11 +55,15 @@ export const Table = memo(() => {
|
|
|
55
55
|
setState(prev => {
|
|
56
56
|
var _a;
|
|
57
57
|
return (Object.assign(Object.assign({}, prev), { columns: (_a = tableProps.columns) === null || _a === void 0 ? void 0 : _a.map((col, index) => {
|
|
58
|
-
var _a
|
|
59
|
-
return (Object.assign(Object.assign({}, col), {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
var _a;
|
|
59
|
+
return (Object.assign(Object.assign({}, col), {
|
|
60
|
+
// width:
|
|
61
|
+
// index === (tableProps.columns?.length || 1) - 1
|
|
62
|
+
// ? calculateLastColWidth(col)
|
|
63
|
+
// : columnWidths?.[index] ||
|
|
64
|
+
// (col.width ?? (DEFAULT_COLUMN_WIDTHS[index] || DEFAULT_COLUMN_WIDTH)),
|
|
65
|
+
width: (columnWidths === null || columnWidths === void 0 ? void 0 : columnWidths[index]) ||
|
|
66
|
+
((_a = col.width) !== null && _a !== void 0 ? _a : (DEFAULT_COLUMN_WIDTHS[index] || DEFAULT_COLUMN_WIDTH)) }));
|
|
63
67
|
}) }));
|
|
64
68
|
});
|
|
65
69
|
}
|
|
@@ -68,7 +72,8 @@ export const Table = memo(() => {
|
|
|
68
72
|
tableRef.current = ref === null || ref === void 0 ? void 0 : ref.nativeElement;
|
|
69
73
|
}, scroll: Object.assign(Object.assign({}, scroll), { y: (scroll === null || scroll === void 0 ? void 0 : scroll.y) || '500px', x: (scroll === null || scroll === void 0 ? void 0 : scroll.x) || '100%' }), components: {
|
|
70
74
|
header: Object.assign({ cell: ResizableCell }, (_b = tableProps === null || tableProps === void 0 ? void 0 : tableProps.components) === null || _b === void 0 ? void 0 : _b.header),
|
|
71
|
-
} }, (!!(tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource) &&
|
|
75
|
+
} }, (!!(tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource) &&
|
|
76
|
+
!!(tableProps === null || tableProps === void 0 ? void 0 : tableProps.rowSelection) && {
|
|
72
77
|
rowSelection: Object.assign(Object.assign({ fixed: true, columnWidth: DEFAULT_ROW_SELECTION_WIDTH }, tableProps === null || tableProps === void 0 ? void 0 : tableProps.rowSelection), { onChange(selectedRowKeys, selectedRows, info) {
|
|
73
78
|
var _a, _b;
|
|
74
79
|
setTable({
|
|
@@ -82,11 +87,6 @@ export const Table = memo(() => {
|
|
|
82
87
|
fixed: column.fixed,
|
|
83
88
|
width: column.width,
|
|
84
89
|
index,
|
|
85
|
-
// handleProps: {
|
|
86
|
-
// style: {
|
|
87
|
-
// height: tableRef?.current?.clientHeight,
|
|
88
|
-
// },
|
|
89
|
-
// },
|
|
90
90
|
onResize: onResize(index),
|
|
91
91
|
onResizeStop: onResizeStop(index),
|
|
92
92
|
}) }))), bordered: true, pagination: false, loading: {
|
|
@@ -250,19 +250,19 @@ export function useDataTableListing(props) {
|
|
|
250
250
|
return Object.assign(Object.assign({ key: name, dataIndex: name, title: label, fixed: fixColumn ? 'left' : undefined }, columns === null || columns === void 0 ? void 0 : columns[name]), { render(value, record, index) {
|
|
251
251
|
var _a;
|
|
252
252
|
const { link } = (columns === null || columns === void 0 ? void 0 : columns[name]) || {};
|
|
253
|
-
const
|
|
253
|
+
const RenderComponent = (React.createElement(Text, { ellipsis: { tooltip: true }, style: Object.assign({}, (link
|
|
254
254
|
? {
|
|
255
255
|
fontWeight: globalToken === null || globalToken === void 0 ? void 0 : globalToken.fontWeightStrong,
|
|
256
256
|
color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary,
|
|
257
257
|
}
|
|
258
258
|
: {})) }, typeof value !== 'object' ? value || DEFAULT_CELL_EMPTY : DEFAULT_CELL_EMPTY));
|
|
259
259
|
if ((_a = columns === null || columns === void 0 ? void 0 : columns[name]) === null || _a === void 0 ? void 0 : _a.render) {
|
|
260
|
-
return columns[name].render(value, record, index,
|
|
260
|
+
return columns[name].render(value, record, index, RenderComponent);
|
|
261
261
|
}
|
|
262
262
|
if (link) {
|
|
263
|
-
return (React.createElement(Link, { to: typeof link === 'function' ? link(record) : link },
|
|
263
|
+
return (React.createElement(Link, { to: typeof link === 'function' ? link(record) : link }, RenderComponent));
|
|
264
264
|
}
|
|
265
|
-
return
|
|
265
|
+
return RenderComponent;
|
|
266
266
|
} });
|
|
267
267
|
})) || []);
|
|
268
268
|
return data;
|
|
@@ -58,8 +58,7 @@ export const LeftMenuComponent = memo(props => {
|
|
|
58
58
|
const isHover = state.hoverItem === permission_code;
|
|
59
59
|
const renderLabel = () => (React.createElement("li", { role: "menuitem", className: classNames({ isActive, isHover }), onClick: () => onMenuItemClick === null || onMenuItemClick === void 0 ? void 0 : onMenuItemClick(permission_code || 'null', [permission_code || 'null']) },
|
|
60
60
|
React.createElement(IconWrapper, null, isNil(icon_name) ? null : React.createElement(Icon, { type: icon_name })),
|
|
61
|
-
React.createElement(Typography.Text, null, menu_item_name)
|
|
62
|
-
React.createElement("div", { className: "popup-triangle" })));
|
|
61
|
+
React.createElement(Typography.Text, null, menu_item_name)));
|
|
63
62
|
return (React.createElement(FeatureMenuItem, { key: menu_item, onMouseEnter: () => onMouseEnter(permission_code || 'null') }, renderLabel()));
|
|
64
63
|
}, [customActiveAppKey, onMenuItemClick, onMouseEnter, state.hoverItem]);
|
|
65
64
|
const renderCustomizedMenuItems = useCallback((items) => items === null || items === void 0 ? void 0 : items.map(item => {
|
|
@@ -105,8 +104,8 @@ export const LeftMenuComponent = memo(props => {
|
|
|
105
104
|
React.createElement(FeatureMenu, { role: "menu", className: "antsomi-scroll-box" },
|
|
106
105
|
React.createElement("div", { className: "menu-content scroll-content" }, renderAppMenuItems()),
|
|
107
106
|
React.createElement("div", { className: "nav-blank", onMouseEnter: onHoverMenuBar }),
|
|
108
|
-
React.createElement(PopoverWrapper, { show: state.isShowPopover && isExpandable, hasMarginTop: !isRecommendation, className: "antsomi-scroll-box antsomi-child-menu-popover" },
|
|
109
|
-
React.createElement("div", { className: "scroll-content", style: { width: '200px', maxHeight: '100%' } }, childHoverMenu))),
|
|
107
|
+
!isRecommendation && (React.createElement(PopoverWrapper, { show: state.isShowPopover && isExpandable, hasMarginTop: !isRecommendation, className: "antsomi-scroll-box antsomi-child-menu-popover" },
|
|
108
|
+
React.createElement("div", { className: "scroll-content", style: { width: '200px', maxHeight: '100%' } }, childHoverMenu)))),
|
|
110
109
|
React.createElement("div", { style: { flexShrink: 0 } }, renderSettings())),
|
|
111
110
|
isExpandable && !isRecommendation && (React.createElement(ExpandWrapper, { onMouseEnter: onMouseLeave },
|
|
112
111
|
React.createElement(Icon, { type: "icon-ants-expand-more", style: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Libraries
|
|
2
|
-
import React, { memo,
|
|
2
|
+
import React, { memo, useMemo, useState } from 'react';
|
|
3
3
|
import Icon from '@antscorp/icons';
|
|
4
4
|
import { isEmpty, isNil, uniq } from 'lodash';
|
|
5
5
|
import classNames from 'classnames';
|
|
@@ -38,7 +38,6 @@ const styles = {
|
|
|
38
38
|
menuItemTitle: { flex: '1 1 0%', maxWidth: '100%', overflow: 'hidden' },
|
|
39
39
|
};
|
|
40
40
|
export const ChildMenu = memo(props => {
|
|
41
|
-
var _a, _b;
|
|
42
41
|
const { items = [], onMenuClick } = props;
|
|
43
42
|
const cookies = useMemo(() => new Cookies(), []);
|
|
44
43
|
const auth = useLeftMenuContext(store => { var _a; return (_a = store.appConfig) === null || _a === void 0 ? void 0 : _a.auth; });
|
|
@@ -52,16 +51,30 @@ export const ChildMenu = memo(props => {
|
|
|
52
51
|
const customActiveCurrentKey = useLeftMenuContext(store => store.customActiveCurrentKey);
|
|
53
52
|
const setLeftMenuState = useLeftMenuContext(store => store.setState);
|
|
54
53
|
const activeApp = useMemo(() => (isCustomized ? customActiveAppKey : activeAppCode), [activeAppCode, customActiveAppKey, isCustomized]);
|
|
55
|
-
const leftMenuCookies = cookies.get('_leftmenu_state');
|
|
56
|
-
const openMenuKeys =
|
|
54
|
+
// const leftMenuCookies = cookies.get('_leftmenu_state');
|
|
55
|
+
// const openMenuKeys = cookies.get('_leftmenu_state')?.openMenuKeys?.[activeApp] || [];
|
|
57
56
|
const [currentActiveItem, setCurrentActiveItem] = useState('');
|
|
58
|
-
const [openKeys, setOpenKeys] = useState(
|
|
57
|
+
const [openKeys, setOpenKeys] = useState([]);
|
|
59
58
|
const { pathname, hash } = window.location;
|
|
60
59
|
const { isPushDifferentDomain, getPath, navigatePath } = useNavigatePath();
|
|
61
|
-
useLayoutEffect(() => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
// useLayoutEffect(() => {
|
|
61
|
+
// if (activeApp)
|
|
62
|
+
// cookies.set(
|
|
63
|
+
// '_leftmenu_state',
|
|
64
|
+
// {
|
|
65
|
+
// ...leftMenuCookies,
|
|
66
|
+
// openMenuKeys: {
|
|
67
|
+
// ...leftMenuCookies?.openMenuKeys,
|
|
68
|
+
// [activeApp]: uniq(openKeys?.filter(item => item !== activeApp)),
|
|
69
|
+
// },
|
|
70
|
+
// },
|
|
71
|
+
// {
|
|
72
|
+
// domain: 'antsomi.com',
|
|
73
|
+
// // domain: origin.split('.').slice(-2).join('.'),
|
|
74
|
+
// path: '/; samesite=None',
|
|
75
|
+
// },
|
|
76
|
+
// );
|
|
77
|
+
// }, [activeApp, cookies, leftMenuCookies, openKeys]);
|
|
65
78
|
useDeepCompareEffect(() => {
|
|
66
79
|
var _a;
|
|
67
80
|
switch (true) {
|
|
@@ -151,8 +151,8 @@ export const handleActiveRecommendationItem = (args) => {
|
|
|
151
151
|
}
|
|
152
152
|
break;
|
|
153
153
|
case 'EVENT_SOURCES':
|
|
154
|
-
if (!['EVENT', 'EVENT_ATTRIBUTE', 'CONVERSION'].includes(currentActiveItem))
|
|
155
|
-
menuActiveKey = '
|
|
154
|
+
if (!['EVENT_SOURCES', 'EVENT', 'EVENT_ATTRIBUTE', 'CONVERSION'].includes(currentActiveItem))
|
|
155
|
+
menuActiveKey = 'EVENT_SOURCES';
|
|
156
156
|
break;
|
|
157
157
|
case 'DATAFLOWS':
|
|
158
158
|
if (!['BATCH_STREAMING', 'REALTIME_STREAMING'].includes(currentActiveItem))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Libraries
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { isArray, isNil } from 'lodash';
|
|
4
|
-
import { Cookies } from 'react-cookie';
|
|
4
|
+
import { Cookies as ReactCookies } from 'react-cookie';
|
|
5
5
|
// Utils
|
|
6
6
|
import { findActiveAppCodeByChild, findActiveAppCodeByUrl, recursiveGetMenuItemByPermission, } from '../utils';
|
|
7
7
|
// Store
|
|
@@ -32,7 +32,7 @@ export const useLeftMenu = (props) => {
|
|
|
32
32
|
return activeKey;
|
|
33
33
|
}
|
|
34
34
|
}, [activeKey, isRecommendation]);
|
|
35
|
-
const cookies = new
|
|
35
|
+
const cookies = new ReactCookies();
|
|
36
36
|
const { pathname, hash, origin } = window.location;
|
|
37
37
|
const activeAppCode = useLeftMenuContext(store => store.activeAppCode);
|
|
38
38
|
const customActiveAppKey = useLeftMenuContext(store => store.customActiveAppKey);
|
|
@@ -40,6 +40,7 @@ export const useLeftMenu = (props) => {
|
|
|
40
40
|
const { auth, env } = appConfig || {};
|
|
41
41
|
const timeoutPopover = useRef(null);
|
|
42
42
|
const leftMenuCookies = cookies.get('_leftmenu_state');
|
|
43
|
+
console.log({ leftMenuCookies });
|
|
43
44
|
const isOpenMenu = !isNil(leftMenuCookies === null || leftMenuCookies === void 0 ? void 0 : leftMenuCookies.expand) ? leftMenuCookies === null || leftMenuCookies === void 0 ? void 0 : leftMenuCookies.expand : true;
|
|
44
45
|
const [state, setState] = useState({
|
|
45
46
|
hoverItem: '',
|
|
@@ -55,15 +56,12 @@ export const useLeftMenu = (props) => {
|
|
|
55
56
|
}, [customActiveAppKey, isRecommendation, onMenuItemClick, setLeftMenuContextState]);
|
|
56
57
|
useDeepCompareEffect(() => {
|
|
57
58
|
if (!expandMenu) {
|
|
58
|
-
cookies.set('_leftmenu_state',
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// document.cookie = `_leftmenu_state=${JSON.stringify(
|
|
65
|
-
// cookieValue,
|
|
66
|
-
// )}; domain=${domain}; path=/; SameSite=None; Secure`;
|
|
59
|
+
cookies.set('_leftmenu_state', state.isExpandMenu ? 1 : 0, {
|
|
60
|
+
domain: `.${origin.split('.').splice(-2).join('.')}`,
|
|
61
|
+
path: '/',
|
|
62
|
+
sameSite: 'none',
|
|
63
|
+
secure: true,
|
|
64
|
+
});
|
|
67
65
|
}
|
|
68
66
|
}, [leftMenuCookies, origin, state.isExpandMenu]);
|
|
69
67
|
useDeepCompareEffect(() => {
|
|
@@ -235,7 +233,7 @@ export const useLeftMenu = (props) => {
|
|
|
235
233
|
timeoutPopover.current = setTimeout(() => {
|
|
236
234
|
setState(prev => (Object.assign(Object.assign({}, prev), { hoverItem: '' })));
|
|
237
235
|
setState(prev => (Object.assign(Object.assign({}, prev), { isShowPopover: false })));
|
|
238
|
-
},
|
|
236
|
+
}, 200);
|
|
239
237
|
// if (!state.isExpandMenu || !isExpandable) {
|
|
240
238
|
// setState(prev => ({ ...prev, hoverItem: '' }));
|
|
241
239
|
// }
|
|
@@ -47,6 +47,7 @@ export const useNavigatePath = () => {
|
|
|
47
47
|
}, [auth, searchParams]);
|
|
48
48
|
const navigatePath = useCallback((domain, path) => {
|
|
49
49
|
const newDomain = isNil(domain) || env === ENV.DEV ? '' : domain;
|
|
50
|
+
console.log({ name: 'navigatePath', path, domain });
|
|
50
51
|
window.location.assign(getGeneratePath(`${newDomain}${path}${searchParams}`, auth));
|
|
51
52
|
}, [auth, env, searchParams]);
|
|
52
53
|
return { isPushDifferentDomain, getPath, navigatePath };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets a cookie with the specified name, value, expiration days, and domain.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} name - The name of the cookie.
|
|
5
|
+
* @param {any} value - The value to be stored in the cookie.
|
|
6
|
+
* @param {number} exdays - The number of days until the cookie expires.
|
|
7
|
+
* @param {string} domain - The domain associated with the cookie.
|
|
8
|
+
*/
|
|
9
|
+
export declare const setCookie: (args: {
|
|
10
|
+
name: string;
|
|
11
|
+
value: any;
|
|
12
|
+
exdays: number;
|
|
13
|
+
domain: string;
|
|
14
|
+
}) => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { get } from 'lodash';
|
|
2
|
+
// Utils
|
|
3
|
+
import { handleError } from './handleError';
|
|
4
|
+
const PATH = 'src/utils/cookies.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Sets a cookie with the specified name, value, expiration days, and domain.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} name - The name of the cookie.
|
|
9
|
+
* @param {any} value - The value to be stored in the cookie.
|
|
10
|
+
* @param {number} exdays - The number of days until the cookie expires.
|
|
11
|
+
* @param {string} domain - The domain associated with the cookie.
|
|
12
|
+
*/
|
|
13
|
+
export const setCookie = (args) => {
|
|
14
|
+
try {
|
|
15
|
+
const { name, value, exdays, domain } = args;
|
|
16
|
+
const { protocol = 'https:' } = get(window, 'location', '') || {};
|
|
17
|
+
const d = new Date();
|
|
18
|
+
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
|
|
19
|
+
if (protocol === 'https:') {
|
|
20
|
+
document.cookie = `${name}=${value}; Domain=${domain}; Path=/; Expires=${d.toUTCString()}; SameSite=None; Secure`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
document.cookie = `${name}=${value}; Domain=${domain}; Path=/; Expires=${d.toUTCString()};`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
handleError(error, {
|
|
28
|
+
path: PATH,
|
|
29
|
+
name: setCookie.name,
|
|
30
|
+
args,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED