@antscorp/antsomi-ui 1.3.5-beta.476 → 1.3.5-beta.478

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { IconProps } from './type';
3
+ export declare const DataIcon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<SVGSVGElement>>;
@@ -0,0 +1,18 @@
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
+ // Libraries
13
+ import React, { forwardRef } from 'react';
14
+ export const DataIcon = forwardRef((props, ref) => {
15
+ const restProps = __rest(props, []);
16
+ return (React.createElement("svg", Object.assign({ ref: ref, width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, restProps),
17
+ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M19.002 6.5C19.002 7.88071 15.6499 9 11.515 9C7.38 9 4.02795 7.88071 4.02795 6.5C4.02795 5.11929 7.38 4 11.515 4C15.6499 4 19.002 5.11929 19.002 6.5ZM18.974 12.131C18.974 13.42 15.622 14.465 11.487 14.465C7.352 14.465 4 13.419 4 12.131V8.46204C4 9.75104 7.352 10.795 11.487 10.795C15.622 10.795 18.974 9.74904 18.974 8.46204V12.131ZM18.974 17.8423C18.974 19.1313 15.622 20.1763 11.487 20.1763C7.352 20.1763 4 19.1303 4 17.8423V14.1733C4 15.4623 7.352 16.5063 11.487 16.5063C15.622 16.5063 18.974 15.4603 18.974 14.1733V17.8423Z", fill: "currentColor" })));
18
+ });
@@ -54,3 +54,4 @@ export { Interactive } from './Interactive';
54
54
  export { Web } from './Web';
55
55
  export { LocalMallIcon } from './LocalMallIcon';
56
56
  export { LoadingIcon } from './LoadingIcon';
57
+ export { DataIcon } from './DataIcon';
@@ -54,3 +54,4 @@ export { Interactive } from './Interactive';
54
54
  export { Web } from './Web';
55
55
  export { LocalMallIcon } from './LocalMallIcon';
56
56
  export { LoadingIcon } from './LoadingIcon';
57
+ export { DataIcon } from './DataIcon';
@@ -30,6 +30,7 @@ import { globalToken } from '@antscorp/antsomi-ui/es/constants';
30
30
  import { useDeepCompareEffect, useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
31
31
  // Utils
32
32
  import { flatTree, recursiveSearchItems } from '@antscorp/antsomi-ui/es/utils';
33
+ import { DataIcon } from '../../icons';
33
34
  const initialState = {
34
35
  isOpenPopover: false,
35
36
  };
@@ -205,7 +206,7 @@ export const MatchesAny = props => {
205
206
  React.createElement(TextButton, { disabled: isDisableRemoveAll, onClick: onRemoveAll }, t(translations.global.removeAll).toString())),
206
207
  React.createElement("div", { className: "matches-any__body" },
207
208
  React.createElement(Spin, { spinning: loading },
208
- React.createElement(Scrollbars, { style: { height: '100%' } }, !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) ? (React.createElement(EmptyData, { icon: "icon-ants-database", description: t(translations.global.selectItemsFromList).toString() })) : (React.createElement(StyledTree, { selectable: false, treeData: selectedTreeData, switcherIcon: props => (React.createElement(Icon, { type: "icon-ants-caret-down", style: {
209
+ React.createElement(Scrollbars, { style: { height: '100%' } }, !(selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.length) ? (React.createElement(EmptyData, { icon: React.createElement(DataIcon, { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw5, width: 48, height: 48 }), description: t(translations.global.selectItemsFromList).toString() })) : (React.createElement(StyledTree, { selectable: false, treeData: selectedTreeData, switcherIcon: props => (React.createElement(Icon, { type: "icon-ants-caret-down", style: {
209
210
  transform: props.expanded ? 'rotate(0)' : 'rotate(-90deg)',
210
211
  transition: 'transform 0.3s ease',
211
212
  }, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 })) })))))));
@@ -33,7 +33,11 @@ export const AddFilterButton = memo(() => {
33
33
  });
34
34
  } })) : (React.createElement(SavedFilterAndMetrics, { onSelectFilterMetric: onSelectFilterMetric, onSelectSavedFilter: () => {
35
35
  setAddFilterConditionState(prev => (Object.assign(Object.assign({}, prev), { openPopover: false })));
36
- } }))), trigger: ['click'], overlayInnerStyle: { width: 300, padding: 0 }, arrow: false, placement: "bottomLeft", destroyTooltipOnHide: true, onOpenChange: open => {
36
+ } }))), trigger: ['click'], overlayInnerStyle: {
37
+ width: 300,
38
+ padding: 0,
39
+ overflow: selectedFilterMetric ? 'visible' : 'hidden',
40
+ }, arrow: false, placement: "bottomLeft", destroyTooltipOnHide: true, onOpenChange: open => {
37
41
  setAddFilterConditionState(prev => (Object.assign(Object.assign({}, prev), { openPopover: open })));
38
42
  if (!open) {
39
43
  /* Reset filter metric */
@@ -5,8 +5,9 @@ import { Flex } from '@antscorp/antsomi-ui/es/components/atoms';
5
5
  import { Select, Form, ApplyPopupContent } from '@antscorp/antsomi-ui/es/components/molecules';
6
6
  // Constants
7
7
  import { OPERATORS, OPERATORS_OPTION } from '@antscorp/antsomi-ui/es/constants/condition';
8
- import { renderValueField } from '../../../utils';
9
8
  import { EXCEPTION_OFF_FILTER_CLASS } from '../../../constants/filter';
9
+ // Utils
10
+ import { renderValueField } from '../../../utils';
10
11
  const { BETWEEN, EXISTS, NOT_EXISTS } = OPERATORS_OPTION;
11
12
  export const FilterCondition = props => {
12
13
  // Props
@@ -88,7 +89,7 @@ export const FilterCondition = props => {
88
89
  React.createElement(Form.Item, { name: "operator", noStyle: true },
89
90
  React.createElement(Select, { value: operator, options: operatorList, onChange: () => form.setFieldsValue({
90
91
  value: '',
91
- }), dropdownRender: menu => (React.createElement("div", { className: EXCEPTION_OFF_FILTER_CLASS, onClick: e => e.stopPropagation() }, menu)) })),
92
+ }), getPopupContainer: triggerNode => triggerNode.parentElement, dropdownRender: menu => (React.createElement("div", { className: EXCEPTION_OFF_FILTER_CLASS, onClick: e => e.stopPropagation() }, menu)) })),
92
93
  React.createElement(Form.Item, { name: "value", noStyle: true }),
93
94
  renderValueField({
94
95
  filterMetric,
@@ -28,12 +28,12 @@ export const FilterItem = props => {
28
28
  if (dayjs(value).isValid()) {
29
29
  return dayjs(value).format(DATE_TIME_FORMAT.FILTER_CONDITION);
30
30
  }
31
- // Check value is an array and operator is MATCHES_ANY
32
- if (Array.isArray(value) && operator === MATCHES_ANY) {
33
- return value.map(item => item.title).join(', ');
31
+ // Check value is an array
32
+ if (Array.isArray(value)) {
33
+ return value.map(item => item.title || item).join(', ');
34
34
  }
35
35
  return value;
36
- }, [operator, value]);
36
+ }, [value]);
37
37
  const serializeOperator = useMemo(() => {
38
38
  var _a;
39
39
  const operatorLabel = ((_a = Object.values(OPERATORS_OPTION).find(({ value }) => value === operator)) === null || _a === void 0 ? void 0 : _a.label) || '';
@@ -33,19 +33,22 @@ export const ResizableCell = props => {
33
33
  if (isRowSelectionCol || !width || disableResize) {
34
34
  return (React.createElement("th", Object.assign({}, restProps, { style: columnStyle, onClick: onClick }), CellHeaderContent));
35
35
  }
36
- const toggleCellClass = (className = 'resizable-cell') => {
36
+ const handleStyleResizable = (type) => {
37
37
  var _a, _b;
38
38
  (_b = (_a = tableRef === null || tableRef === void 0 ? void 0 : tableRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.antsomi-table-row')) === null || _b === void 0 ? void 0 : _b.forEach(rowEl => {
39
39
  var _a;
40
- const cell = (_a = rowEl.querySelectorAll(`.antsomi-table-cell`)) === null || _a === void 0 ? void 0 : _a[(index !== null && index !== void 0 ? index : 0) + 1];
40
+ const cell = (_a = rowEl.querySelectorAll(`.antsomi-table-cell:not(.antsomi-table-selection-column)`)) === null || _a === void 0 ? void 0 : _a[index !== null && index !== void 0 ? index : 0];
41
41
  if (cell) {
42
- cell.classList.toggle(className);
42
+ if (type === 'add') {
43
+ return cell.setAttribute('aria-resizable', 'true');
44
+ }
45
+ cell.removeAttribute('aria-resizable');
43
46
  }
44
47
  });
45
48
  };
46
49
  return (React.createElement(Resizable, { width: width || 0, height: 0, minConstraints: [MIN_COLUMN_WIDTH, 0], handle: React.createElement("div", { className: "resizable-handle-wrapper", onClick: e => {
47
50
  e.stopPropagation();
48
- } },
51
+ }, onMouseEnter: () => handleStyleResizable('add'), onMouseLeave: () => handleStyleResizable('remove') },
49
52
  React.createElement("span", Object.assign({ className: "resizable-handle" }, handleProps))), onResize: (_e, data) => {
50
53
  var _a;
51
54
  const { size } = data; // Destructure size from the resize data
@@ -16,6 +16,8 @@ import { useShallow } from 'zustand/react/shallow';
16
16
  // Components
17
17
  import { ResizableCell } from './ResizableCell';
18
18
  import { Spin, Icon } from '@antscorp/antsomi-ui/es/components/atoms';
19
+ import { EmptyData } from '@antscorp/antsomi-ui/es/components/molecules';
20
+ import { DataIcon } from '@antscorp/antsomi-ui/es/components/icons';
19
21
  // Hooks
20
22
  import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
21
23
  // Styled
@@ -25,6 +27,10 @@ import { useDataTableContext } from '../../contexts/DataTableContext';
25
27
  // Constants
26
28
  import { DEFAULT_COLUMN_WIDTH, DEFAULT_COLUMN_WIDTHS, DEFAULT_ROW_SELECTION_WIDTH, } from '../../constants';
27
29
  import { globalToken } from '@antscorp/antsomi-ui/es/constants';
30
+ // Locales
31
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
32
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
33
+ const { t } = i18nInstance;
28
34
  export const Table = memo(() => {
29
35
  var _a;
30
36
  // Store
@@ -59,7 +65,7 @@ export const Table = memo(() => {
59
65
  });
60
66
  }
61
67
  }, [tableProps.columns, columnWidths]);
62
- return (React.createElement(ConfigProvider, { theme: { token: { motion: false } } },
68
+ return (React.createElement(ConfigProvider, { theme: { token: { motion: false } }, renderEmpty: () => (React.createElement(EmptyData, { icon: React.createElement(DataIcon, { color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw5, width: 48, height: 48 }), description: t(translations.noData).toString() })) },
63
69
  React.createElement(StyledTable, Object.assign({}, restOfTable, { ref: ref => {
64
70
  tableRef.current = ref === null || ref === void 0 ? void 0 : ref.nativeElement;
65
71
  }, scroll: Object.assign(Object.assign({}, scroll), { y: (scroll === null || scroll === void 0 ? void 0 : scroll.y) || '100%', x: (scroll === null || scroll === void 0 ? void 0 : scroll.x) || '100%' }), components: {
@@ -65,13 +65,9 @@ export const StyledTable = styled(Table) `
65
65
  }
66
66
  }
67
67
 
68
- .antsomi-table-tbody-virtual {
69
- .antsomi-table-row {
70
- .antsomi-table-cell {
71
- &.resizable-cell {
72
- border-inline-end: 2px solid ${blue1} !important;
73
- }
74
- }
68
+ .antsomi-table-row {
69
+ .antsomi-table-cell[aria-resizable='true'] {
70
+ border-inline-end: 2px solid ${blue1} !important;
75
71
  }
76
72
  }
77
73
  }
@@ -50,7 +50,7 @@ const StyledContent = styled.div `
50
50
  }
51
51
  `;
52
52
  export const SearchPopover = props => {
53
- const { children, objectName, searchList, isClientSearch, loading, isAddFilterFromSearchItem, onAddFilter = () => { }, onSearch = () => { }, onClick = () => { }, onClickSearchItem, itemSearchRender, searchItemProps } = props, restProps = __rest(props, ["children", "objectName", "searchList", "isClientSearch", "loading", "isAddFilterFromSearchItem", "onAddFilter", "onSearch", "onClick", "onClickSearchItem", "itemSearchRender", "searchItemProps"]);
53
+ const { children, objectName, searchList, isClientSearch, loading, isAddFilterFromSearchItem, searchItemProps, onAddFilter = () => { }, onSearch = () => { }, onClick = () => { }, onClickSearchItem, itemSearchRender } = props, restProps = __rest(props, ["children", "objectName", "searchList", "isClientSearch", "loading", "isAddFilterFromSearchItem", "searchItemProps", "onAddFilter", "onSearch", "onClick", "onClickSearchItem", "itemSearchRender"]);
54
54
  // State
55
55
  const [state, setState] = useState({
56
56
  searchValue: '',
@@ -19,7 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  return t;
20
20
  };
21
21
  // Libraries
22
- import React, { useCallback, useMemo, useState } from 'react';
22
+ import React, { useCallback, useState } from 'react';
23
23
  import { Link } from 'react-router-dom';
24
24
  import { isEmpty, pick } from 'lodash';
25
25
  import { useQueryClient } from '@tanstack/react-query';
@@ -92,12 +92,12 @@ export function useDataTableListing(props) {
92
92
  ? apiMatchesAny === null || apiMatchesAny === void 0 ? void 0 : apiMatchesAny[`${selectedFilterItem === null || selectedFilterItem === void 0 ? void 0 : selectedFilterItem.column}`.toLowerCase()]
93
93
  : apiMatchesAny === null || apiMatchesAny === void 0 ? void 0 : apiMatchesAny.general;
94
94
  // Memos
95
- const mapObject = useMemo(() => ({
95
+ const mapObject = useDeepCompareMemo(() => ({
96
96
  objType: object === null || object === void 0 ? void 0 : object.type,
97
97
  objId: object === null || object === void 0 ? void 0 : object.objectId,
98
98
  }), [object === null || object === void 0 ? void 0 : object.objectId, object === null || object === void 0 ? void 0 : object.type]);
99
- const localStorageKey = useMemo(() => `${TABLE_LISTING_PREFIX}${name}`, [name]);
100
- const localStorageValues = useMemo(() => parseJSONFromLocalStorage(localStorageKey) || {}, [localStorageKey]);
99
+ const localStorageKey = useDeepCompareMemo(() => `${TABLE_LISTING_PREFIX}${name}`, [name]);
100
+ const localStorageValues = useDeepCompareMemo(() => parseJSONFromLocalStorage(localStorageKey) || {}, [localStorageKey]);
101
101
  // Queries
102
102
  const getColumnMetrics = useGetColumnMetrics({
103
103
  args: {
@@ -145,7 +145,6 @@ export function useDataTableListing(props) {
145
145
  retry: false,
146
146
  },
147
147
  });
148
- console.log('getMatchesAnyList', getMatchesAnyList);
149
148
  // Variables
150
149
  const { data: modifyColumnsData, isLoading: isModifyColumnsLoading } = getModifyColumnList || {};
151
150
  const modifyColumnSelected = useDeepCompareMemo(() => { var _a; return ((_a = modifyColumnsData === null || modifyColumnsData === void 0 ? void 0 : modifyColumnsData.find(({ isLasted }) => +isLasted === 1)) === null || _a === void 0 ? void 0 : _a.modifyColId) || ''; }, [modifyColumnsData]);
@@ -249,7 +248,7 @@ export function useDataTableListing(props) {
249
248
  name: filterName,
250
249
  removable: true,
251
250
  }))) || []), [savedFiltersData]);
252
- const tableColumns = useMemo(() => {
251
+ const tableColumns = useDeepCompareMemo(() => {
253
252
  let data = [];
254
253
  const { columns } = tableProps || {};
255
254
  // Check if has column toggle then add toggle switch column
@@ -297,7 +296,7 @@ export function useDataTableListing(props) {
297
296
  const { itemMapKeys, icon, link } = searchProps || {};
298
297
  return ((searchListingBody === null || searchListingBody === void 0 ? void 0 : searchListingBody.map(searchItem => (Object.assign(Object.assign({}, Object.entries(itemMapKeys || {}).reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [key]: searchItem[value] })), {})), { icon: typeof icon === 'function' ? icon(searchItem) : icon, link: typeof link === 'function' ? link(searchItem) : link })))) || []);
299
298
  }, [searchListingData, searchProps]);
300
- const matchesAnyList = useMemo(() => {
299
+ const matchesAnyList = useDeepCompareMemo(() => {
301
300
  /**
302
301
  * If `selectedFilterItem` has a column, the function will attempt to find a matching property in the `matchesAny`
303
302
  * object by converting the column name to lowercase. If such a property does not exist, it will default to using
@@ -160,14 +160,14 @@ export const renderValueField = ({ filterMetric, operator, value, matchesAny, on
160
160
  case OPERATORS_CODE.MATCHES_ANY:
161
161
  case OPERATORS_CODE.NOT_MATCHES: {
162
162
  const { list, isLoading } = matchesAny || {};
163
- return (React.createElement(MatchesAnySelect, { selectedItems: value, popupClassName: EXCEPTION_OFF_FILTER_CLASS, objectName: name, items: list, loading: isLoading, onChange: onChangeValue }));
163
+ return (React.createElement(MatchesAnySelect, { selectedItems: Array.isArray(value) ? value : [], popupClassName: EXCEPTION_OFF_FILTER_CLASS, objectName: name, items: list, loading: isLoading, onChange: onChangeValue }));
164
164
  }
165
165
  case OPERATORS_CODE.AFTER:
166
166
  case OPERATORS_CODE.AFTER_DATE:
167
167
  case OPERATORS_CODE.BEFORE:
168
168
  case OPERATORS_CODE.ON:
169
169
  case OPERATORS_CODE.BEFORE_DATE: {
170
- return (React.createElement(DatePicker, { placeholder: DATE_TIME_FORMAT_DISPLAY.FILTER_CONDITION, format: DATE_TIME_FORMAT_DISPLAY.FILTER_CONDITION, allowClear: false, popupClassName: EXCEPTION_OFF_FILTER_CLASS, value: dayjs(value).isValid() ? dayjs(value) : undefined, onChange: onChangeValue }));
170
+ return (React.createElement(DatePicker, { placeholder: DATE_TIME_FORMAT_DISPLAY.FILTER_CONDITION, format: DATE_TIME_FORMAT_DISPLAY.FILTER_CONDITION, allowClear: false, getPopupContainer: trigger => trigger.parentElement, placement: "bottomLeft", popupClassName: EXCEPTION_OFF_FILTER_CLASS, value: value && dayjs(value).isValid() ? dayjs(value) : undefined, onChange: onChangeValue }));
171
171
  }
172
172
  default:
173
173
  return null;
@@ -449,7 +449,7 @@ export const removeAccent = (str) => {
449
449
  return str;
450
450
  };
451
451
  /** Remove all accents and convert string to lower case, remove leading and trailing white space */
452
- export const simplifyString = (str) => removeAccent(str.toLowerCase().trim()) || '';
452
+ export const simplifyString = (str) => removeAccent(`${str || ''}`.toLowerCase().trim()) || '';
453
453
  /**
454
454
  * @param str target string
455
455
  * @param queryStr search query
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.476",
3
+ "version": "1.3.5-beta.478",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",