@antscorp/antsomi-ui 1.3.5-beta.320 → 1.3.5-beta.321

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 (24) hide show
  1. package/es/components/molecules/SearchPopover/SearchPopover.d.ts +2 -6
  2. package/es/components/molecules/SearchPopover/SearchPopover.js +3 -4
  3. package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.d.ts +4 -0
  4. package/es/components/molecules/SearchPopover/components/PopoverAddField/PopoverAddField.js +115 -0
  5. package/es/components/molecules/SearchPopover/components/PopoverAddField/index.d.ts +1 -0
  6. package/es/components/molecules/SearchPopover/components/PopoverAddField/index.js +1 -0
  7. package/es/components/molecules/SearchPopover/components/PopoverAddField/styles.scss +59 -0
  8. package/es/components/molecules/SearchPopover/components/index.d.ts +1 -0
  9. package/es/components/molecules/SearchPopover/components/index.js +1 -0
  10. package/es/components/molecules/SearchPopover/constants.d.ts +27 -0
  11. package/es/components/molecules/SearchPopover/constants.js +27 -0
  12. package/es/components/molecules/SearchPopover/index.d.ts +3 -1
  13. package/es/components/molecules/SearchPopover/index.js +1 -0
  14. package/es/components/molecules/SearchPopover/styles.scss +2 -0
  15. package/es/components/molecules/SearchPopover/types.d.ts +18 -0
  16. package/es/components/molecules/SearchPopover/types.js +1 -0
  17. package/es/components/molecules/SearchPopover/utils.d.ts +2 -0
  18. package/es/components/molecules/SearchPopover/utils.js +23 -0
  19. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +11 -3
  20. package/es/components/molecules/VirtualizedMenu/types.d.ts +1 -0
  21. package/es/components/molecules/index.d.ts +2 -2
  22. package/es/components/molecules/index.js +1 -1
  23. package/es/components/organism/LeftMenu/index.js +1 -2
  24. package/package.json +1 -1
@@ -1,8 +1,4 @@
1
- import React, { PropsWithChildren } from 'react';
2
- import { PopoverProps } from 'antd';
3
- import { InputProps } from '../../atoms/Input';
1
+ import React from 'react';
4
2
  import './styles.scss';
5
- export type SearchPopoverProps = PropsWithChildren<PopoverProps & {
6
- inputSearchProps?: InputProps;
7
- }>;
3
+ import { SearchPopoverProps } from './types';
8
4
  export declare const SearchPopover: (props: SearchPopoverProps) => React.JSX.Element;
@@ -11,14 +11,13 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import React from 'react';
13
13
  import { Popover } from 'antd';
14
- import { Input } from '../../atoms/Input';
15
- import Icon from '@antscorp/icons';
14
+ import { Input, Icon } from '../../atoms';
16
15
  import './styles.scss';
17
16
  import clsx from 'clsx';
18
17
  export const SearchPopover = (props) => {
19
- const { inputSearchProps } = props, popoverProps = __rest(props, ["inputSearchProps"]);
18
+ const { inputSearchProps = {} } = props, popoverProps = __rest(props, ["inputSearchProps"]);
20
19
  const { overlayClassName, arrow = false, children, content, trigger = ['click'] } = popoverProps, restPopoverProps = __rest(popoverProps, ["overlayClassName", "arrow", "children", "content", "trigger"]);
21
20
  return (React.createElement(Popover, Object.assign({ trigger: trigger, arrow: arrow }, restPopoverProps, { overlayClassName: clsx('search-popover-overlay', overlayClassName), overlay: true, content: React.createElement(React.Fragment, null,
22
- React.createElement(Input, Object.assign({ placeholder: (inputSearchProps === null || inputSearchProps === void 0 ? void 0 : inputSearchProps.placeholder) || 'Search...', addonAfter: React.createElement(Icon, { type: "icon-ants-search-2" }), bordered: false }, inputSearchProps, { withWrapper: false })),
21
+ React.createElement(Input, Object.assign({ placeholder: (inputSearchProps === null || inputSearchProps === void 0 ? void 0 : inputSearchProps.placeholder) || 'Search...', bordered: false }, inputSearchProps, { addonAfter: React.createElement(Icon, { type: "icon-ants-search-2" }), withWrapper: false })),
23
22
  content) }), children));
24
23
  };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { PopoverAddFieldProps } from '../../types';
3
+ import './styles.scss';
4
+ export declare const PopoverAddField: (props: PopoverAddFieldProps) => React.JSX.Element;
@@ -0,0 +1,115 @@
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
+ import React, { useEffect, useMemo, useState } from 'react';
13
+ import { THEME } from '@antscorp/antsomi-ui/es/constants';
14
+ import { SearchPopover } from '../../SearchPopover';
15
+ import { Button, Checkbox, Menu } from 'antd';
16
+ import { renderIconField } from '../../utils';
17
+ import './styles.scss';
18
+ import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
19
+ import { Icon } from '../../../../atoms';
20
+ import Scrollbars from 'react-custom-scrollbars';
21
+ export const PopoverAddField = (props) => {
22
+ var _a, _b;
23
+ const { open: openProp, selected, fields = [], onCancel, onApply, inputSearchProps = {}, children } = props, rest = __rest(props, ["open", "selected", "fields", "onCancel", "onApply", "inputSearchProps", "children"]);
24
+ const { value: searchValue } = inputSearchProps, restInputSearchProps = __rest(inputSearchProps, ["value"]);
25
+ const [open, setOpen] = useState(openProp);
26
+ const [selectedKeys, setSelectedKeys] = useState(new Set());
27
+ const [search, setSearch] = useState('');
28
+ const [showChecked, setShowChecked] = useState(false);
29
+ const applyDisabled = selectedKeys.size === 0;
30
+ useEffect(() => {
31
+ if (openProp !== undefined) {
32
+ setOpen(openProp);
33
+ }
34
+ }, [openProp]);
35
+ useEffect(() => {
36
+ if (searchValue !== undefined) {
37
+ setSearch(searchValue.toString());
38
+ }
39
+ }, [searchValue]);
40
+ useEffect(() => {
41
+ if (selected !== undefined) {
42
+ setSelectedKeys(new Set(selected));
43
+ }
44
+ }, [selected]);
45
+ const filteredField = useMemo(() => {
46
+ let result = fields.filter(field => {
47
+ const labelIncluded = searchStringQuery(field.label, search);
48
+ const keyIncluded = searchStringQuery(field.key, search);
49
+ return labelIncluded || keyIncluded;
50
+ });
51
+ if (showChecked) {
52
+ result = result.filter(field => selectedKeys.has(field.key));
53
+ }
54
+ return result;
55
+ }, [fields, search, showChecked, selectedKeys]);
56
+ const handleToggleField = (field, checked) => {
57
+ const newSelectedKeys = new Set(selectedKeys);
58
+ if (checked) {
59
+ newSelectedKeys.add(field.key);
60
+ }
61
+ else {
62
+ newSelectedKeys.delete(field.key);
63
+ }
64
+ setSelectedKeys(newSelectedKeys);
65
+ };
66
+ const handleCancel = () => {
67
+ setOpen(false);
68
+ if (onCancel)
69
+ onCancel();
70
+ };
71
+ const handleApply = () => {
72
+ if (onApply)
73
+ onApply(Array.from(selectedKeys));
74
+ setOpen(false);
75
+ };
76
+ const handleOnSearch = (searchValue) => {
77
+ setSearch(searchValue);
78
+ if (inputSearchProps.onAfterChange) {
79
+ inputSearchProps.onAfterChange(searchValue);
80
+ }
81
+ };
82
+ const handleUncheckAll = () => {
83
+ setSelectedKeys(new Set());
84
+ };
85
+ const handleAfterOpenChange = (visible) => {
86
+ if (!visible) {
87
+ setSearch(searchValue ? searchValue.toString() : '');
88
+ setSelectedKeys(selected ? new Set(selected) : new Set());
89
+ }
90
+ if (rest.afterOpenChange) {
91
+ rest.afterOpenChange(visible);
92
+ }
93
+ };
94
+ const handleOpenChange = (visible) => {
95
+ setOpen(visible);
96
+ };
97
+ return (React.createElement(SearchPopover, Object.assign({}, rest, { content: React.createElement(React.Fragment, null,
98
+ !!fields.length && (React.createElement("div", { className: "actions" },
99
+ React.createElement(Button, { type: "link", size: "small", onClick: () => setShowChecked(current => !current) }, showChecked ? 'Show all' : 'Show checked'),
100
+ !!selectedKeys.size && (React.createElement(Button, { type: "link", onClick: handleUncheckAll }, "Uncheck all")))),
101
+ !!filteredField.length && (React.createElement(Scrollbars, { autoHeight: true, autoHeightMax: 260 },
102
+ React.createElement(Menu, { className: "list-fields", selectable: false, items: filteredField.map(field => ({
103
+ key: field.key,
104
+ label: (React.createElement(Checkbox, { onChange: e => handleToggleField(field, e.target.checked), checked: selectedKeys.has(field.key) },
105
+ field.dataType && renderIconField(field.dataType),
106
+ field.label)),
107
+ })) }))),
108
+ React.createElement("div", { className: "footer" },
109
+ React.createElement(Button, { onClick: handleCancel }, "Cancel"),
110
+ React.createElement(Button, { onClick: handleApply, disabled: applyDisabled, type: "primary" }, "Apply"))), overlayInnerStyle: {
111
+ '--item-padding': `${((_b = (_a = THEME.components) === null || _a === void 0 ? void 0 : _a.Menu) === null || _b === void 0 ? void 0 : _b.itemPaddingInline) || 10}px`,
112
+ }, trigger: ['click'], placement: "bottomLeft", open: open, inputSearchProps: Object.assign(Object.assign({}, restInputSearchProps), { value: search, onAfterChange: handleOnSearch }), afterOpenChange: handleAfterOpenChange, onOpenChange: handleOpenChange }), children || (React.createElement(Button, { type: "text" },
113
+ React.createElement(Icon, { type: "icon-ants-plus-slim", size: 14 }),
114
+ "Add fields"))));
115
+ };
@@ -0,0 +1 @@
1
+ export { PopoverAddField } from './PopoverAddField';
@@ -0,0 +1 @@
1
+ export { PopoverAddField } from './PopoverAddField';
@@ -0,0 +1,59 @@
1
+ .search-popover-overlay {
2
+ &.antsomi-popover {
3
+ .antsomi-popover-inner {
4
+ min-width: 300px;
5
+
6
+ .antsomi-popover-inner-content {
7
+ .antsomi-menu.list-fields {
8
+ border-bottom: 1px solid var(--divider-1);
9
+
10
+ > .antsomi-menu-item {
11
+ padding: 0;
12
+
13
+ > .antsomi-menu-title-content {
14
+ > .antsomi-checkbox-wrapper {
15
+ padding: 0 var(--item-padding);
16
+ display: flex;
17
+ align-items: center;
18
+ width: 100%;
19
+ height: 100%;
20
+
21
+ span:nth-child(2) {
22
+ > i {
23
+ min-width: 20px;
24
+ text-align: center;
25
+ }
26
+
27
+ display: flex;
28
+ align-items: center;
29
+ gap: 6px;
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+
36
+ > .actions {
37
+ display: flex;
38
+ align-items: center;
39
+ justify-content: space-between;
40
+ gap: 10px;
41
+ padding: 5px 0px;
42
+
43
+ > button {
44
+ height: 30px;
45
+ padding: 0 10px;
46
+ }
47
+ }
48
+
49
+ > .footer {
50
+ gap: 10px;
51
+ padding: 10px;
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: flex-end;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
@@ -0,0 +1 @@
1
+ export { PopoverAddField } from './PopoverAddField';
@@ -0,0 +1 @@
1
+ export { PopoverAddField } from './PopoverAddField';
@@ -0,0 +1,27 @@
1
+ export declare const FIELD_DATA_TYPE: {
2
+ readonly NUMBER: {
3
+ readonly label: "Number";
4
+ readonly name: "number";
5
+ readonly value: 2;
6
+ };
7
+ readonly STRING: {
8
+ readonly label: "String";
9
+ readonly name: "string";
10
+ readonly value: 1;
11
+ };
12
+ readonly TEXT: {
13
+ readonly label: "Text";
14
+ readonly name: "text";
15
+ readonly value: 1;
16
+ };
17
+ readonly DATE_TIME: {
18
+ readonly label: "Datetime";
19
+ readonly name: "datetime";
20
+ readonly value: 5;
21
+ };
22
+ readonly BOOLEAN: {
23
+ readonly label: "Boolean";
24
+ readonly name: "boolean";
25
+ readonly value: 17;
26
+ };
27
+ };
@@ -0,0 +1,27 @@
1
+ export const FIELD_DATA_TYPE = {
2
+ NUMBER: {
3
+ label: 'Number',
4
+ name: 'number',
5
+ value: 2,
6
+ },
7
+ STRING: {
8
+ label: 'String',
9
+ name: 'string',
10
+ value: 1,
11
+ },
12
+ TEXT: {
13
+ label: 'Text',
14
+ name: 'text',
15
+ value: 1,
16
+ },
17
+ DATE_TIME: {
18
+ label: 'Datetime',
19
+ name: 'datetime',
20
+ value: 5,
21
+ },
22
+ BOOLEAN: {
23
+ label: 'Boolean',
24
+ name: 'boolean',
25
+ value: 17,
26
+ },
27
+ };
@@ -1 +1,3 @@
1
- export { SearchPopover, SearchPopoverProps } from './SearchPopover';
1
+ export { PopoverAddField } from './components';
2
+ export { SearchPopover } from './SearchPopover';
3
+ export type { SearchPopoverProps, PopoverAddFieldProps } from './types';
@@ -1 +1,2 @@
1
+ export { PopoverAddField } from './components';
1
2
  export { SearchPopover } from './SearchPopover';
@@ -17,10 +17,12 @@
17
17
  background: transparent;
18
18
  font-size: 20px;
19
19
  padding: 0;
20
+ min-width: 25px;
20
21
 
21
22
  > i {
22
23
  font-size: 24px;
23
24
  color: #595959;
25
+ cursor: pointer;
24
26
  }
25
27
  }
26
28
  }
@@ -0,0 +1,18 @@
1
+ import { PopoverProps } from 'antd';
2
+ import { InputProps } from '../../atoms/Input';
3
+ import { PropsWithChildren } from 'react';
4
+ export type SearchPopoverProps = PropsWithChildren<{
5
+ inputSearchProps?: InputProps;
6
+ } & PopoverProps>;
7
+ export type Field = {
8
+ key: string;
9
+ label: string;
10
+ dataType?: string | number;
11
+ };
12
+ export type PopoverAddFieldProps = SearchPopoverProps & Partial<{
13
+ fields: Field[];
14
+ selected: string[];
15
+ onCancel: () => void;
16
+ onApply: (selected: string[]) => void;
17
+ children: React.ReactNode;
18
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const renderIconField: (dataType?: string | number) => React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Icon } from '../../atoms/Icon';
3
+ import { FIELD_DATA_TYPE } from './constants';
4
+ export const renderIconField = (dataType = FIELD_DATA_TYPE.STRING.name) => {
5
+ switch (dataType) {
6
+ case FIELD_DATA_TYPE.STRING.name:
7
+ case FIELD_DATA_TYPE.STRING.value:
8
+ case FIELD_DATA_TYPE.TEXT.name:
9
+ case FIELD_DATA_TYPE.TEXT.value:
10
+ return React.createElement(Icon, { type: "icon-ants-ABC", style: { color: '#56b261' } });
11
+ case FIELD_DATA_TYPE.BOOLEAN.name:
12
+ case FIELD_DATA_TYPE.BOOLEAN.value:
13
+ return React.createElement(Icon, { type: "icon-ants-boolean", style: { color: '#51a5d5' } });
14
+ case FIELD_DATA_TYPE.NUMBER.name:
15
+ case FIELD_DATA_TYPE.NUMBER.value:
16
+ return React.createElement(Icon, { type: "icon-ants-123", style: { color: '#51a5d5' } });
17
+ case FIELD_DATA_TYPE.DATE_TIME.name:
18
+ case FIELD_DATA_TYPE.DATE_TIME.value:
19
+ return React.createElement(Icon, { type: "icon-ants-calendar-v2", style: { color: '#56b261' } });
20
+ default:
21
+ return React.createElement(Icon, { type: "icon-ants-ABC", style: { color: '#56b261' } });
22
+ }
23
+ };
@@ -22,7 +22,7 @@ const innerElementType = forwardRef((_a, ref) => {
22
22
  return React.createElement("div", Object.assign({ ref: ref, style: style }, rest));
23
23
  });
24
24
  export const MenuInline = (props) => {
25
- const { width, height, items = [], inlineIndent = INLINE_INDENT, inlinePadding = INLINE_PADDING, itemSize = ITEM_SIZE, itemSpacing = ITEM_SPACING, openKeys: openKeysProp = [], onClick, className, } = props;
25
+ const { width, height, items = [], inlineIndent = INLINE_INDENT, inlinePadding = INLINE_PADDING, itemSize = ITEM_SIZE, itemSpacing = ITEM_SPACING, openKeys: openKeysProp = [], onClick, selectable = false, className, } = props;
26
26
  const [openKeys, setOpenKeys] = useState(new Set());
27
27
  const [selectedKeys, setSelectedKeys] = useState(new Set());
28
28
  useDeepCompareEffect(() => {
@@ -74,13 +74,21 @@ export const MenuInline = (props) => {
74
74
  if (hasChilren && !isOpen) {
75
75
  handleExpandItem(item);
76
76
  }
77
- if (!hasChilren && !selectedKeys.has(key)) {
77
+ if (selectable && !hasChilren && !selectedKeys.has(key)) {
78
78
  setSelectedKeys(new Set([item.key]));
79
79
  }
80
80
  if (onClick) {
81
81
  onClick({ item, pathKey: flattenItems[idx].pathKey });
82
82
  }
83
- }, [flattenItems, handleCollapseItem, handleExpandItem, onClick, openKeys, selectedKeys]);
83
+ }, [
84
+ selectable,
85
+ flattenItems,
86
+ handleCollapseItem,
87
+ handleExpandItem,
88
+ onClick,
89
+ openKeys,
90
+ selectedKeys,
91
+ ]);
84
92
  const renderItem = useCallback((args) => {
85
93
  const { index, style } = args;
86
94
  const item = flattenItems[index];
@@ -25,6 +25,7 @@ export type VirtualizedMenuProps = Partial<{
25
25
  pathKey: PathKey;
26
26
  }) => void;
27
27
  className: string;
28
+ selectable: boolean;
28
29
  }>;
29
30
  export type PathKey = (string | number)[];
30
31
  export type MenuInlineProps = Omit<VirtualizedMenuProps, 'mode'>;
@@ -48,7 +48,7 @@ export * from './DatePickerV2';
48
48
  export { ModalSelect } from './ModalSelect';
49
49
  export { EditableName } from './EditableName';
50
50
  export { VirtualizedMenu } from './VirtualizedMenu';
51
- export { SearchPopover } from './SearchPopover';
51
+ export { SearchPopover, PopoverAddField } from './SearchPopover';
52
52
  export * from './EmptyData';
53
53
  export * from './PreviewModal';
54
54
  export * from './Drawer';
@@ -71,4 +71,4 @@ export type { ImageResizeHandle } from './ImageEditor';
71
71
  export type { EditableNameHandle } from './EditableName';
72
72
  export type { AccountListingHandle, AccountSelectionProps } from './AccountSelection';
73
73
  export type { VirtualizedMenuProps } from './VirtualizedMenu';
74
- export type { SearchPopoverProps } from './SearchPopover';
74
+ export type { SearchPopoverProps, PopoverAddFieldProps } from './SearchPopover';
@@ -48,7 +48,7 @@ export * from './DatePickerV2';
48
48
  export { ModalSelect } from './ModalSelect';
49
49
  export { EditableName } from './EditableName';
50
50
  export { VirtualizedMenu } from './VirtualizedMenu';
51
- export { SearchPopover } from './SearchPopover';
51
+ export { SearchPopover, PopoverAddField } from './SearchPopover';
52
52
  export * from './EmptyData';
53
53
  export * from './PreviewModal';
54
54
  export * from './Drawer';
@@ -5,8 +5,6 @@ import { Typography } from 'antd';
5
5
  import classNames from 'classnames';
6
6
  import { isNil, isString } from 'lodash';
7
7
  import { Link } from 'react-router-dom';
8
- // Assets
9
- import SubLogoAntsomi from '@antscorp/antsomi-ui/es/assets/images/logo/sub-logo-antsomi.png';
10
8
  // Styled
11
9
  import { ChildMenuWrapper, ExpandWrapper, FeatureMenu, FeatureMenuItem, LeftMenuNav, LeftMenuNavWrapper, PopoverWrapper, NavLogoWrapper, FeatureMenuWrapper, IconWrapper, } from './styled';
12
10
  // Constants
@@ -15,6 +13,7 @@ import { APP_KEYS } from './constants';
15
13
  import { CustomMenu, CommonMenu, HomeMenu } from './components';
16
14
  // Hooks
17
15
  import { useLeftMenu, useNavigatePath } from './hooks';
16
+ const SubLogoAntsomi = 'https://st-media-template.antsomi.com/icons/antsomi/antsomi.png';
18
17
  export const LeftMenu = memo(props => {
19
18
  const { style, className, customization } = props;
20
19
  const { isExpandable = true, isCustomized = false, items = [], onMenuItemClick, } = customization || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.320",
3
+ "version": "1.3.5-beta.321",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",