@antscorp/antsomi-ui 2.0.10 → 2.0.12

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.
@@ -15,7 +15,7 @@ var __rest = (this && this.__rest) || function (s, e) {
15
15
  // Libraries
16
16
  import { ConfigProvider } from 'antd';
17
17
  import clsx from 'clsx';
18
- import { isEmpty, uniqBy } from 'lodash';
18
+ import { cloneDeep, isEmpty, uniqBy } from 'lodash';
19
19
  import React, { useCallback, useRef, useState } from 'react';
20
20
  // Components
21
21
  import { Button, Flex, Icon, Input, Popover, Spin, Tooltip, Typography, } from '@antscorp/antsomi-ui/es/components/atoms';
@@ -100,7 +100,7 @@ export function MatchesAny(props) {
100
100
  }, [selectedTreeDataProp, selectedItemsProp]);
101
101
  // Handlers
102
102
  const onSelectItem = (item) => {
103
- let newSelectedItems = [...(selectedItems || [])];
103
+ let newSelectedItems = cloneDeep(selectedItems || []);
104
104
  if (item.children) {
105
105
  const flattenChild = flatTree(item.children, 'children');
106
106
  newSelectedItems = newSelectedItems.concat(flattenChild.filter(item => !item.children));
@@ -108,6 +108,7 @@ export function MatchesAny(props) {
108
108
  else {
109
109
  newSelectedItems = newSelectedItems.concat(item);
110
110
  }
111
+ newSelectedItems = uniqBy(newSelectedItems, 'key');
111
112
  const newSelectedTreeData = getSelectedTreeData(items || [], newSelectedItems || [], selectedTreeData || []);
112
113
  setState(prev => (Object.assign(Object.assign({}, prev), { selectedItems: newSelectedItems, selectedTreeData: newSelectedTreeData })));
113
114
  };
@@ -256,7 +257,7 @@ export function MatchesAny(props) {
256
257
  } }))),
257
258
  React.createElement("div", { className: "matches-any__body" },
258
259
  React.createElement(Flex, { align: "center", justify: "space-between" },
259
- React.createElement(Text, { strong: true }, `${objectName} (${flatTree(items, 'children').filter(item => !item.children).length})`),
260
+ React.createElement(Text, { strong: true }, `${objectName} (${flatTree(treeData, 'children').filter(item => !item.children).length - 1})`),
260
261
  React.createElement(Flex, { align: "center", gap: 10 },
261
262
  renderExtraValueLabels(),
262
263
  React.createElement(TextButton, { disabled: isDisableSelectAll, onClick: onSelectAll }, t(translations.global.selectAll).toString()))),
@@ -268,7 +269,10 @@ export function MatchesAny(props) {
268
269
  }, color: globalToken === null || globalToken === void 0 ? void 0 : globalToken.bw8 })), titleRender: (item) => isShowLoadMoreEl && item.isLoadMore ? (React.createElement("div", { ref: loadMoreRef })) : (renderItemNodeTitle({
269
270
  item,
270
271
  onSelectItem,
271
- })), height: 396 })) : (React.createElement(EmptyData, Object.assign({ icon: listEmptyIcon, showIcon: !!listEmptyIcon, description: listEmptyDescription }, restListEmptyProps)))))));
272
+ })), height: 396 })) : /**
273
+ * If search value is not empty and no listEmpty props show no results matches key word message empty in case data is empty
274
+ */
275
+ !!searchValue && !listEmptyProps ? (React.createElement(EmptyData, { showIcon: false, description: t(translations.global.noResultsMatchesKeyWord).toString() })) : (React.createElement(EmptyData, Object.assign({ icon: listEmptyIcon, showIcon: !!listEmptyIcon, description: listEmptyDescription }, restListEmptyProps)))))));
272
276
  };
273
277
  const renderSelectedList = () => (React.createElement("div", { className: "matches-any__section" },
274
278
  React.createElement(Flex, { className: "matches-any__header", justify: "space-between" },
@@ -1,2 +1,92 @@
1
1
  import { MatchesAnyItem } from './types';
2
- export declare const getSelectedTreeData: (items: MatchesAnyItem<any>[], selectedItems: MatchesAnyItem<any>[], selectedTreeData?: MatchesAnyItem<any>[]) => any;
2
+ export declare const getSelectedTreeData: (items: MatchesAnyItem<any>[], selectedItems: MatchesAnyItem<any>[], selectedTreeData?: MatchesAnyItem<any>[]) => {
3
+ toString: () => string;
4
+ charAt: (pos: number) => string;
5
+ charCodeAt: (index: number) => number;
6
+ concat: (...strings: string[]) => string;
7
+ indexOf: (searchString: string, position?: number | undefined) => number;
8
+ lastIndexOf: (searchString: string, position?: number | undefined) => number;
9
+ localeCompare: {
10
+ (that: string): number;
11
+ (that: string, locales?: string | string[] | undefined, options?: Intl.CollatorOptions | undefined): number;
12
+ (that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions | undefined): number;
13
+ };
14
+ match: {
15
+ (regexp: string | RegExp): RegExpMatchArray | null;
16
+ (matcher: {
17
+ [Symbol.match](string: string): RegExpMatchArray | null;
18
+ }): RegExpMatchArray | null;
19
+ };
20
+ replace: {
21
+ (searchValue: string | RegExp, replaceValue: string): string;
22
+ (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string;
23
+ (searchValue: {
24
+ [Symbol.replace](string: string, replaceValue: string): string;
25
+ }, replaceValue: string): string;
26
+ (searchValue: {
27
+ [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
28
+ }, replacer: (substring: string, ...args: any[]) => string): string;
29
+ };
30
+ search: {
31
+ (regexp: string | RegExp): number;
32
+ (searcher: {
33
+ [Symbol.search](string: string): number;
34
+ }): number;
35
+ };
36
+ slice: (start?: number | undefined, end?: number | undefined) => string;
37
+ split: {
38
+ (separator: string | RegExp, limit?: number | undefined): string[];
39
+ (splitter: {
40
+ [Symbol.split](string: string, limit?: number | undefined): string[];
41
+ }, limit?: number | undefined): string[];
42
+ };
43
+ substring: (start: number, end?: number | undefined) => string;
44
+ toLowerCase: () => string;
45
+ toLocaleLowerCase: {
46
+ (locales?: string | string[] | undefined): string;
47
+ (locales?: Intl.LocalesArgument): string;
48
+ };
49
+ toUpperCase: () => string;
50
+ toLocaleUpperCase: {
51
+ (locales?: string | string[] | undefined): string;
52
+ (locales?: Intl.LocalesArgument): string;
53
+ };
54
+ trim: () => string;
55
+ readonly length: number;
56
+ substr: (from: number, length?: number | undefined) => string;
57
+ valueOf: () => string;
58
+ codePointAt: (pos: number) => number | undefined;
59
+ includes: (searchString: string, position?: number | undefined) => boolean;
60
+ endsWith: (searchString: string, endPosition?: number | undefined) => boolean;
61
+ normalize: {
62
+ (form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
63
+ (form?: string | undefined): string;
64
+ };
65
+ repeat: (count: number) => string;
66
+ startsWith: (searchString: string, position?: number | undefined) => boolean;
67
+ anchor: (name: string) => string;
68
+ big: () => string;
69
+ blink: () => string;
70
+ bold: () => string;
71
+ fixed: () => string;
72
+ fontcolor: (color: string) => string;
73
+ fontsize: {
74
+ (size: number): string;
75
+ (size: string): string;
76
+ };
77
+ italics: () => string;
78
+ link: (url: string) => string;
79
+ small: () => string;
80
+ strike: () => string;
81
+ sub: () => string;
82
+ sup: () => string;
83
+ padStart: (maxLength: number, fillString?: string | undefined) => string;
84
+ padEnd: (maxLength: number, fillString?: string | undefined) => string;
85
+ trimEnd: () => string;
86
+ trimStart: () => string;
87
+ trimLeft: () => string;
88
+ trimRight: () => string;
89
+ matchAll: (regexp: RegExp) => IterableIterator<RegExpExecArray>;
90
+ [Symbol.iterator]: () => IterableIterator<string>;
91
+ at: (index: number) => string | undefined;
92
+ }[];
@@ -1,5 +1,6 @@
1
1
  // Libraries
2
2
  import deepmerge from 'deepmerge';
3
+ import { isEmpty, unionBy } from 'lodash';
3
4
  // Utils
4
5
  import { flatTree } from '@antscorp/antsomi-ui/es/utils';
5
6
  const customMergeTreeData = (key) => (target, source) => {
@@ -16,9 +17,6 @@ const customMergeTreeData = (key) => (target, source) => {
16
17
  export const getSelectedTreeData = (items, selectedItems, selectedTreeData = []) => {
17
18
  const notExtendValueSelectedItems = (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.filter(item => !item.isExtendValue)) || [];
18
19
  const extendValueSelectedItems = (selectedItems === null || selectedItems === void 0 ? void 0 : selectedItems.filter(item => item.isExtendValue)) || [];
19
- const notFoundItems = !(selectedTreeData === null || selectedTreeData === void 0 ? void 0 : selectedTreeData.length)
20
- ? notExtendValueSelectedItems === null || notExtendValueSelectedItems === void 0 ? void 0 : notExtendValueSelectedItems.filter(item => !(items === null || items === void 0 ? void 0 : items.some(i => i.key === item.key)))
21
- : [];
22
20
  const serializeTreeData = (list) => {
23
21
  var _a;
24
22
  return ((_a = list
@@ -41,5 +39,13 @@ export const getSelectedTreeData = (items, selectedItems, selectedTreeData = [])
41
39
  const mergeItems = deepmerge(selectedTreeData || [], items || [], {
42
40
  arrayMerge: customMergeTreeData('key'),
43
41
  });
44
- return serializeTreeData(mergeItems).concat([...notFoundItems, ...extendValueSelectedItems]);
42
+ // If all of items not have children then filter item is not found in list but has selected for display
43
+ const notFoundItems = !mergeItems.some(item => !isEmpty(item.children))
44
+ ? notExtendValueSelectedItems === null || notExtendValueSelectedItems === void 0 ? void 0 : notExtendValueSelectedItems.filter(item => !(items === null || items === void 0 ? void 0 : items.some(i => i.key === item.key)))
45
+ : [];
46
+ const treeData = serializeTreeData(mergeItems).concat([
47
+ ...notFoundItems,
48
+ ...extendValueSelectedItems,
49
+ ]);
50
+ return unionBy(treeData, 'key');
45
51
  };
@@ -99,7 +99,7 @@ export const PopoverSelect = (props) => {
99
99
  }
100
100
  };
101
101
  const handleSelectAll = () => {
102
- setSelectedKeys(new Set(options.map(field => field.key)));
102
+ setSelectedKeys(new Set(filteredOptions.map(field => field.key)));
103
103
  };
104
104
  const handleDeselectAll = () => {
105
105
  setSelectedKeys(new Set());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",
@@ -126,7 +126,8 @@
126
126
  "react-virtualized-auto-sizer": "^1.0.24",
127
127
  "react-window": "^1.8.10",
128
128
  "rehype-highlight": "^6.0.0",
129
- "remark-gfm": "^4.0.0",
129
+ "remark-gfm": "^3.0.1",
130
+ "remark-gfm-alias-story": "npm:remark-gfm@4.0.0",
130
131
  "socket.io-client": "^4.7.5",
131
132
  "swiper": "^11.0.7",
132
133
  "ts-dedent": "^2.2.0",