@antscorp/antsomi-ui 1.3.5-beta.414 → 1.3.5-beta.416

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,6 +1,8 @@
1
1
  var _a, _b, _c;
2
+ // Libraries
2
3
  import styled from 'styled-components';
3
- import { THEME } from '@antscorp/antsomi-ui/es/constants';
4
+ // Constants
5
+ import { THEME, globalToken } from '@antscorp/antsomi-ui/es/constants';
4
6
  export const HeaderV2Styled = styled.div `
5
7
  height: ${(_a = THEME.token) === null || _a === void 0 ? void 0 : _a.headerHeight};
6
8
  background-color: #f6f8fc;
@@ -42,6 +44,7 @@ export const HeaderV2Styled = styled.div `
42
44
  font-size: 20px;
43
45
  line-height: 23px;
44
46
  font-weight: bold;
47
+ color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorTextBase};
45
48
  }
46
49
  `;
47
50
  export const LogoWrapper = styled.div `
@@ -9,9 +9,9 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import React from 'react';
12
+ import React, { useEffect, useRef, useState } from 'react';
13
13
  import { CardDefinationContainer, CardRecommendedContainer, RecommendItem, StyledCard, } from './styled';
14
- import { Typography } from 'antd';
14
+ import { Tooltip, Typography } from 'antd';
15
15
  import clsx from 'clsx';
16
16
  import { globalToken } from '@antscorp/antsomi-ui/es/constants';
17
17
  const { Text, Paragraph } = Typography;
@@ -20,22 +20,42 @@ export const Card = (props) => {
20
20
  return (React.createElement(StyledCard, Object.assign({ bordered: bordered }, rest), children));
21
21
  };
22
22
  export const CardDefination = (props) => {
23
+ const refreshKey = useRef(0);
24
+ const [isExpanded, setIsExpanded] = useState(false);
25
+ const [expandable, setExpandable] = useState(true);
23
26
  const { title, description, descriptionEllipsis = {
24
27
  rows: 3,
25
28
  symbol: 'Learn more',
26
- expandable: true,
27
29
  tooltip: true,
28
30
  }, } = props;
31
+ useEffect(() => {
32
+ if (!expandable) {
33
+ setExpandable(true);
34
+ }
35
+ }, [expandable]);
36
+ const handleCollapse = () => {
37
+ refreshKey.current += 1;
38
+ setExpandable(false);
39
+ };
29
40
  return (React.createElement(CardDefinationContainer, null,
30
41
  title && React.createElement(Text, { className: "title" }, title),
31
- description && (React.createElement(Paragraph, { ellipsis: descriptionEllipsis, className: "description" }, description))));
42
+ description && (React.createElement(Paragraph, { key: refreshKey.current, ellipsis: Object.assign(Object.assign({}, descriptionEllipsis), { expandable, onExpand: () => setIsExpanded(true) }), className: "description" },
43
+ description,
44
+ isExpanded && (React.createElement("span", { className: "antsomi-typography-collapse", onClick: handleCollapse }, "View less"))))));
32
45
  };
33
46
  export const CardRecommended = (props) => {
34
47
  const { title, recomendations = [] } = props;
35
48
  return (React.createElement(CardRecommendedContainer, null,
36
49
  title && React.createElement(Text, { className: "title" }, title),
37
50
  React.createElement("div", { className: "recomendations" }, recomendations.map(i => {
38
- const { className, color = globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue2, bordered = false } = i;
39
- return (React.createElement(RecommendItem, Object.assign({}, i, { key: i.key, color: color, bordered: bordered, className: clsx('item', className) })));
51
+ const { description, className, color = globalToken === null || globalToken === void 0 ? void 0 : globalToken.blue2, bordered = false } = i;
52
+ const item = (React.createElement(RecommendItem, Object.assign({}, i, { key: i.key, color: color, bordered: bordered, className: clsx('item', className) })));
53
+ if (typeof description === 'string') {
54
+ return (React.createElement(Tooltip, { title: description, placement: "top" }, item));
55
+ }
56
+ if (description) {
57
+ return React.createElement(Tooltip, Object.assign({}, description), item);
58
+ }
59
+ return item;
40
60
  }))));
41
61
  };
@@ -125,6 +125,12 @@ export const CardDefinationContainer = styled.div `
125
125
  .antsomi-typography-expand {
126
126
  font-weight: 500;
127
127
  }
128
+
129
+ .antsomi-typography-collapse {
130
+ font-weight: 500;
131
+ color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary};
132
+ cursor: pointer;
133
+ }
128
134
  }
129
135
  `;
130
136
  export const CardRecommendedContainer = styled.div `
@@ -1,6 +1,7 @@
1
1
  import React, { RefCallback } from 'react';
2
2
  import { MenuProps, ModalProps, TagProps } from 'antd';
3
3
  import { EllipsisConfig } from 'antd/es/typography/Base';
4
+ import { TooltipProps } from 'antd/lib';
4
5
  export type ModalSelectProps = {
5
6
  open?: boolean;
6
7
  value?: string;
@@ -23,5 +24,6 @@ export type CardRecommendedProps = {
23
24
  title?: string;
24
25
  recomendations?: (TagProps & {
25
26
  key?: React.Key;
27
+ description?: string | TooltipProps;
26
28
  })[];
27
29
  };
@@ -17,7 +17,7 @@ export declare const ROLE_ACCESS_LABEL: {
17
17
  2: string;
18
18
  3: string;
19
19
  };
20
- export declare const ACCESS_PROPERTIES_BY_ROLE: Record<AccessRole, Pick<UserAccessInfo, 'role' | 'allowView' | 'allowEdit' | 'allowComment' | 'accessType'>>;
20
+ export declare const ACCESS_PROPERTIES_BY_ROLE: Record<AccessRole, Pick<UserAccessInfo, 'role' | 'allowView' | 'allowEdit' | 'allowComment'>>;
21
21
  export declare const PEOPLE_ACTION_KEYS: {
22
22
  readonly TO_VIEWER: "to_viewer";
23
23
  readonly TO_EDITOR: "to_editor";
@@ -22,30 +22,18 @@ export const ACCESS_PROPERTIES_BY_ROLE = {
22
22
  allowView: 1,
23
23
  allowEdit: 1,
24
24
  allowComment: 1,
25
- accessType: {
26
- label: ROLE_ACCESS_LABEL[ROLE_MAPPING.OWNER],
27
- value: ROLE_ACCESS_LABEL[ROLE_MAPPING.OWNER].toLowerCase(),
28
- },
29
25
  },
30
26
  [ROLE_MAPPING.EDITOR]: {
31
27
  role: ROLE_MAPPING.EDITOR,
32
28
  allowView: 1,
33
29
  allowEdit: 1,
34
30
  allowComment: 1,
35
- accessType: {
36
- label: ROLE_ACCESS_LABEL[ROLE_MAPPING.EDITOR],
37
- value: ROLE_ACCESS_LABEL[ROLE_MAPPING.EDITOR].toLowerCase(),
38
- },
39
31
  },
40
32
  [ROLE_MAPPING.VIEWER]: {
41
33
  role: ROLE_MAPPING.VIEWER,
42
34
  allowView: 1,
43
35
  allowEdit: 0,
44
36
  allowComment: 0,
45
- accessType: {
46
- label: ROLE_ACCESS_LABEL[ROLE_MAPPING.VIEWER],
47
- value: ROLE_ACCESS_LABEL[ROLE_MAPPING.VIEWER].toLowerCase(),
48
- },
49
37
  },
50
38
  };
51
39
  export const PEOPLE_ACTION_KEYS = {
@@ -1,11 +1,12 @@
1
1
  import produce from 'immer';
2
2
  import { TYPES } from './actions';
3
+ import { mappingOutData } from './utils';
3
4
  export const shareAccessReducer = (onChange) => (state, action) => produce(state, draft => {
4
5
  switch (action.type) {
5
6
  case TYPES.UPDATE_OBJECT_ACCESS_INFO: {
6
7
  draft.accessInfo = action.payload;
7
8
  if (onChange) {
8
- onChange(action.payload);
9
+ onChange(mappingOutData(action.payload));
9
10
  }
10
11
  break;
11
12
  }
@@ -13,17 +13,13 @@ export type UserInfo = {
13
13
  };
14
14
  export type UserAccessInfo = {
15
15
  userId: number;
16
- fullName: string;
17
- email: string;
18
- avatar: string;
16
+ fullName?: string;
17
+ email?: string;
18
+ avatar?: string;
19
19
  role: number;
20
20
  allowView: number;
21
21
  allowEdit: number;
22
22
  allowComment: number;
23
- accessType: {
24
- label: string;
25
- value: string;
26
- };
27
23
  [key: string]: any;
28
24
  };
29
25
  export type ObjectAccessInfo = {
@@ -1,4 +1,4 @@
1
- import { ObjectAccessInfo, UserInfo } from './types';
1
+ import { ObjectAccessInfo, UserAccessInfo, UserInfo } from './types';
2
2
  export declare const mergePermission: (objectPermissionAllow: boolean, menuPermissionValue: number) => boolean;
3
3
  export declare const composeObjectMenuPermissions: (params: {
4
4
  isPublic: boolean;
@@ -41,18 +41,20 @@ export declare const formattedAccessInfo: (accessInfo: ObjectAccessInfo) => {
41
41
  ownerId: number;
42
42
  listAccess: {
43
43
  userId: number;
44
- fullName: string;
45
- email: string;
46
- avatar: string;
44
+ fullName?: string | undefined;
45
+ email?: string | undefined;
46
+ avatar?: string | undefined;
47
47
  role: number;
48
48
  allowView: number;
49
49
  allowEdit: number;
50
50
  allowComment: number;
51
- accessType: {
52
- label: string;
53
- value: string;
54
- };
55
51
  }[];
56
52
  isPublic: number;
57
53
  publicRole: number | null;
58
54
  };
55
+ export declare const mappingOutData: (shareAccess: ObjectAccessInfo) => {
56
+ isPublic: number;
57
+ publicRole: number | null;
58
+ ownerId: number;
59
+ listAccess: UserAccessInfo[];
60
+ };
@@ -59,10 +59,7 @@ export const getActionsByUser = (args) => {
59
59
  export const initAccessInfoDefault = (userInfo) => ({
60
60
  ownerId: +(userInfo === null || userInfo === void 0 ? void 0 : userInfo.user_id),
61
61
  listAccess: [
62
- Object.assign(Object.assign({}, snakeCaseToCamelCase(userInfo)), { role: ROLE_MAPPING.OWNER, allowView: 1, allowEdit: 1, allowComment: 1, accessType: {
63
- label: ROLE_ACCESS_LABEL[ROLE_MAPPING.OWNER],
64
- value: ROLE_ACCESS_LABEL[ROLE_MAPPING.OWNER].toLowerCase(),
65
- } }),
62
+ Object.assign(Object.assign({}, snakeCaseToCamelCase(userInfo)), { role: ROLE_MAPPING.OWNER, allowView: 1, allowEdit: 1, allowComment: 1 }),
66
63
  ],
67
64
  publicRole: PUBLIC_ROLE.ONLY_VIEWER,
68
65
  isPublic: 0,
@@ -71,3 +68,17 @@ export const formattedAccessInfo = (accessInfo) => {
71
68
  var _a;
72
69
  return (Object.assign(Object.assign({}, accessInfo), { ownerId: +((accessInfo === null || accessInfo === void 0 ? void 0 : accessInfo.ownerId) || -1), listAccess: (_a = accessInfo === null || accessInfo === void 0 ? void 0 : accessInfo.listAccess) === null || _a === void 0 ? void 0 : _a.map(user => (Object.assign(Object.assign({}, user), { userId: +user.userId }))) }));
73
70
  };
71
+ export const mappingOutData = (shareAccess) => {
72
+ const result = Object.assign({}, shareAccess);
73
+ result.listAccess = result.listAccess.map(accessInfo => {
74
+ const roleLabel = ROLE_ACCESS_LABEL[accessInfo.role];
75
+ if (typeof roleLabel === 'string') {
76
+ accessInfo.accessType = {
77
+ label: roleLabel,
78
+ value: roleLabel.toLowerCase(),
79
+ };
80
+ }
81
+ return accessInfo;
82
+ });
83
+ return result;
84
+ };
@@ -22,6 +22,7 @@ const StyledAddButton = styled(Flex) `
22
22
  height: 30px;
23
23
  background-color: ${globalToken === null || globalToken === void 0 ? void 0 : globalToken.colorPrimary};
24
24
  color: #fff;
25
+ flex-shrink: 0;
25
26
  cursor: pointer;
26
27
  `;
27
28
  export const AddButton = memo(props => {
@@ -38,7 +38,13 @@ export const Toolbar = memo(() => {
38
38
  if (addButtonComponent) {
39
39
  return (React.createElement(React.Fragment, null,
40
40
  addButtonComponent,
41
- React.createElement(Divider, { dashed: true, type: "vertical", style: { height: 38, margin: '0px 10px', borderWidth: 2, borderSpacing: 5 } })));
41
+ React.createElement(Divider, { dashed: true, type: "vertical", style: {
42
+ height: 38,
43
+ margin: '0px 10px',
44
+ borderWidth: 2,
45
+ borderSpacing: 5,
46
+ borderLeftStyle: 'dotted',
47
+ } })));
42
48
  }
43
49
  return null;
44
50
  };
@@ -54,6 +60,7 @@ export const Toolbar = memo(() => {
54
60
  margin: '0px 5px',
55
61
  borderWidth: 2,
56
62
  borderSpacing: 5,
63
+ borderLeftStyle: 'dotted',
57
64
  } }),
58
65
  React.createElement(CollapseButton, { "$collapsed": !!collapsed, onClick: () => onCollapse && onCollapse(!collapsed) },
59
66
  React.createElement(Icon, { type: "icon-ants-angle-down", size: 12 })))))) : (React.createElement(FilterActionButton, null))));
@@ -47,6 +47,9 @@ export interface UseDataTableListingProps<TTableType = any, TSearchType = any> {
47
47
  itemMapKeys: Record<keyof Omit<TSearchItem, 'icon' | 'link'>, keyof TSearchType>;
48
48
  render?: (record: TSearchType, index: number, node: ReactNode) => ReactNode;
49
49
  };
50
+ filter?: {
51
+ externalFilters?: FilterItem[];
52
+ };
50
53
  }
51
54
  export interface DataTableLocalStorage {
52
55
  filter?: {
@@ -54,7 +54,7 @@ const initialState = {
54
54
  };
55
55
  export function useDataTableListing(props) {
56
56
  // Props
57
- const { config, name = 'default', table: tableProps, search: searchProps } = props || {};
57
+ const { config, name = 'default', table: tableProps, search: searchProps, filter: filterProps, } = props || {};
58
58
  // Hooks
59
59
  const { appConfig } = useAppConfigContext();
60
60
  // State
@@ -67,6 +67,7 @@ export function useDataTableListing(props) {
67
67
  const _c = apiListing || {}, { url: listingUrl = '', enabled: enabledApiListing = true } = _c, restOfApiListingRequest = __rest(_c, ["url", "enabled"]);
68
68
  const _d = apiSearch || {}, { url: searchUrl = '', enabled: enabledApiSearch = true } = _d, restOfApiSearchRequest = __rest(_d, ["url", "enabled"]);
69
69
  const { filters, selectedFilterId, pagination, selectedRowKeys, searchValue } = state;
70
+ const { externalFilters } = filterProps || {};
70
71
  const modifyColumnAuth = Object.assign(Object.assign({}, auth), { url: columnUrl });
71
72
  const filterAuth = Object.assign(Object.assign({}, auth), { url: filterUrl });
72
73
  const listingAuth = Object.assign(Object.assign({}, auth), { url: listingUrl });
@@ -129,7 +130,7 @@ export function useDataTableListing(props) {
129
130
  params: {
130
131
  limit: pagination.pageSize,
131
132
  page: pagination.page,
132
- filter: JSON.stringify(mapFiltersToApiFilters(filters || [])),
133
+ filter: JSON.stringify(mapFiltersToApiFilters([...(filters || []), ...(externalFilters || [])])),
133
134
  },
134
135
  request: restOfApiListingRequest,
135
136
  },
@@ -285,6 +286,12 @@ export function useDataTableListing(props) {
285
286
  setState(prev => (Object.assign(Object.assign({}, prev), { pagination })));
286
287
  }
287
288
  }, [localStorageValues]);
289
+ // /** Update filters from external filters */
290
+ // useDeepCompareEffect(() => {
291
+ // if (externalFilters) {
292
+ // setState(prev => ({ ...prev, filters: [...(filters || []), ...externalFilters] }));
293
+ // }
294
+ // }, [externalFilters]);
288
295
  // Handlers
289
296
  /* Modify Column */
290
297
  const handleUpdatePagination = useCallback((pagination) => {
@@ -28,6 +28,7 @@ export declare const QUERY_KEYS: {
28
28
  GET_RECENT_ACCOUNT: string;
29
29
  GET_ABSTRACT_USERS: string;
30
30
  GET_COLUMN_METRICS: string;
31
+ GET_DATA_TABLE_LISTING: string;
31
32
  GET_MODIFY_COLUMN_LIST: string;
32
33
  GET_SAVED_FILTER_LIST: string;
33
34
  GET_FILTER_METRIC_LIST: string;
@@ -41,6 +41,7 @@ export const QUERY_KEYS = {
41
41
  GET_ABSTRACT_USERS: 'GET_ABSTRACT_USERS',
42
42
  // DATA TABLE
43
43
  GET_COLUMN_METRICS: 'GET_COLUMN_METRICS',
44
+ GET_DATA_TABLE_LISTING: 'GET_DATA_TABLE_LISTING',
44
45
  GET_MODIFY_COLUMN_LIST: 'GET_MODIFY_COLUMN_LIST',
45
46
  GET_SAVED_FILTER_LIST: 'GET_SAVED_FILTER_LIST',
46
47
  GET_FILTER_METRIC_LIST: 'GET_FILTER_METRIC_LIST',
@@ -4,7 +4,7 @@ import { useMutation, useQuery, useQueryClient, } from '@tanstack/react-query';
4
4
  import { dataTableServices, } from '../../services/DataTable';
5
5
  // Constants
6
6
  import { QUERY_KEYS } from '../../constants';
7
- const { GET_COLUMN_METRICS, GET_MODIFY_COLUMN_LIST, GET_SAVED_FILTER_LIST, GET_FILTER_METRIC_LIST, GET_SEARCH_LIST, } = QUERY_KEYS;
7
+ const { GET_COLUMN_METRICS, GET_MODIFY_COLUMN_LIST, GET_SAVED_FILTER_LIST, GET_FILTER_METRIC_LIST, GET_SEARCH_LIST, GET_DATA_TABLE_LISTING, } = QUERY_KEYS;
8
8
  /* Column */
9
9
  export const useGetColumnMetrics = (params) => {
10
10
  const { args, options } = params;
@@ -80,7 +80,7 @@ export const useDeleteSavedFilter = (params) => {
80
80
  /* Table Listing */
81
81
  export const useGetTableListing = (params) => {
82
82
  const { options, args } = params || {};
83
- return useQuery(Object.assign({ queryKey: [GET_FILTER_METRIC_LIST, args === null || args === void 0 ? void 0 : args.params, args === null || args === void 0 ? void 0 : args.request], queryFn: () => dataTableServices.listing.getTableListing(args) }, options));
83
+ return useQuery(Object.assign({ queryKey: [GET_DATA_TABLE_LISTING, args === null || args === void 0 ? void 0 : args.params, args === null || args === void 0 ? void 0 : args.request], queryFn: () => dataTableServices.listing.getTableListing(args) }, options));
84
84
  };
85
85
  export const useGetSearchListing = (params) => {
86
86
  const { args, options } = params || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.414",
3
+ "version": "1.3.5-beta.416",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",