@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.
@@ -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, _b;
59
- return (Object.assign(Object.assign({}, col), { width: index === (((_a = tableProps.columns) === null || _a === void 0 ? void 0 : _a.length) || 1) - 1
60
- ? calculateLastColWidth(col)
61
- : (columnWidths === null || columnWidths === void 0 ? void 0 : columnWidths[index]) ||
62
- ((_b = col.width) !== null && _b !== void 0 ? _b : (DEFAULT_COLUMN_WIDTHS[index] || DEFAULT_COLUMN_WIDTH)) }));
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 renderComponent = (React.createElement(Text, { ellipsis: { tooltip: true }, style: Object.assign({}, (link
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, renderComponent);
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 }, renderComponent));
263
+ return (React.createElement(Link, { to: typeof link === 'function' ? link(record) : link }, RenderComponent));
264
264
  }
265
- return renderComponent;
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, useLayoutEffect, useMemo, useState } from 'react';
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 = ((_b = (_a = cookies.get('_leftmenu_state')) === null || _a === void 0 ? void 0 : _a.openMenuKeys) === null || _b === void 0 ? void 0 : _b[activeApp]) || [];
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(openMenuKeys);
57
+ const [openKeys, setOpenKeys] = useState([]);
59
58
  const { pathname, hash } = window.location;
60
59
  const { isPushDifferentDomain, getPath, navigatePath } = useNavigatePath();
61
- useLayoutEffect(() => {
62
- if (activeApp)
63
- cookies.set('_leftmenu_state', Object.assign(Object.assign({}, leftMenuCookies), { openMenuKeys: Object.assign(Object.assign({}, leftMenuCookies === null || leftMenuCookies === void 0 ? void 0 : leftMenuCookies.openMenuKeys), { [activeApp]: uniq(openKeys === null || openKeys === void 0 ? void 0 : openKeys.filter(item => item !== activeApp)) }) }));
64
- }, [activeApp, cookies, leftMenuCookies, openKeys]);
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 = 'SOURCE';
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 Cookies();
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', Object.assign(Object.assign({}, leftMenuCookies), { expand: state.isExpandMenu }));
59
- // const domain = '.antsomi.com';
60
- // const cookieValue = {
61
- // ...leftMenuCookies,
62
- // expand: state.isExpandMenu,
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
- }, 500);
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
+ };
@@ -6,3 +6,4 @@ export * from './styles';
6
6
  export * from './variables';
7
7
  export * from './actionButtons';
8
8
  export * from './dataTable';
9
+ export * from './cookies';
package/es/utils/index.js CHANGED
@@ -6,3 +6,4 @@ export * from './styles';
6
6
  export * from './variables';
7
7
  export * from './actionButtons';
8
8
  export * from './dataTable';
9
+ export * from './cookies';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.417",
3
+ "version": "1.3.5-beta.419",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",