@vuu-ui/vuu-utils 3.3.11 → 3.3.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.
- package/package.json +6 -6
- package/src/array-utils.js +16 -5
- package/types/array-utils.d.ts +6 -4
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "3.3.
|
|
2
|
+
"version": "3.3.12",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@dnd-kit/react": "^0.1.21",
|
|
18
|
-
"@vuu-ui/vuu-data-types": "3.3.
|
|
19
|
-
"@vuu-ui/vuu-table-types": "3.3.
|
|
20
|
-
"@vuu-ui/vuu-filter-types": "3.3.
|
|
21
|
-
"@vuu-ui/vuu-protocol-types": "3.3.
|
|
18
|
+
"@vuu-ui/vuu-data-types": "3.3.12",
|
|
19
|
+
"@vuu-ui/vuu-table-types": "3.3.12",
|
|
20
|
+
"@vuu-ui/vuu-filter-types": "3.3.12",
|
|
21
|
+
"@vuu-ui/vuu-protocol-types": "3.3.12"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@internationalized/date": "^3.0.0",
|
|
25
|
-
"@vuu-ui/vuu-filter-parser": "3.3.
|
|
25
|
+
"@vuu-ui/vuu-filter-parser": "3.3.12",
|
|
26
26
|
"clsx": "^2.0.0",
|
|
27
27
|
"react": "^19.2.3",
|
|
28
28
|
"react-dom": "^19.2.3"
|
package/src/array-utils.js
CHANGED
|
@@ -41,12 +41,23 @@ const moveItem = (items, fromIndex, toIndex)=>{
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
const getAddedItems = (
|
|
45
|
-
const isNew = (
|
|
46
|
-
if (void 0 ===
|
|
47
|
-
if (
|
|
44
|
+
const getAddedItems = (currentItems, newItems)=>{
|
|
45
|
+
const isNew = (i)=>!currentItems?.includes(i);
|
|
46
|
+
if (void 0 === currentItems) return newItems;
|
|
47
|
+
if (newItems.some(isNew)) return newItems.filter(isNew);
|
|
48
48
|
return [];
|
|
49
49
|
};
|
|
50
|
+
const getRemovedItems = (currentItems, newItems)=>{
|
|
51
|
+
const isRemoved = (i)=>!newItems?.includes(i);
|
|
52
|
+
if (void 0 === newItems) return currentItems;
|
|
53
|
+
if (currentItems.some(isRemoved)) return currentItems.filter(isRemoved);
|
|
54
|
+
return [];
|
|
55
|
+
};
|
|
56
|
+
const containsSubsetOfItems = (allItems, comparedItems)=>{
|
|
57
|
+
if (comparedItems.length > allItems.length) return false;
|
|
58
|
+
const invalidItems = getAddedItems(allItems, comparedItems);
|
|
59
|
+
return 0 === invalidItems.length;
|
|
60
|
+
};
|
|
50
61
|
const getMissingItems = (sourceItems, items, identity)=>items.filter((i)=>-1 === sourceItems.findIndex((s)=>identity(s) === i));
|
|
51
62
|
const reorderItems = (originalItems, orderedNames)=>{
|
|
52
63
|
const orderedItems = [];
|
|
@@ -58,4 +69,4 @@ const reorderItems = (originalItems, orderedNames)=>{
|
|
|
58
69
|
}
|
|
59
70
|
return orderedItems;
|
|
60
71
|
};
|
|
61
|
-
export { getAddedItems, getMissingItems, itemsChanged, itemsOrOrderChanged, moveItem, moveItemDeprecated, partition, reorderItems };
|
|
72
|
+
export { containsSubsetOfItems, getAddedItems, getMissingItems, getRemovedItems, itemsChanged, itemsOrOrderChanged, moveItem, moveItemDeprecated, partition, reorderItems };
|
package/types/array-utils.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export type PartitionTest<T> = (value: T, index: number) => boolean;
|
|
2
2
|
export declare function partition<T>(array: T[], test: PartitionTest<T>, pass?: T[], fail?: T[]): [T[], T[]];
|
|
3
|
-
export declare function itemsChanged<T = unknown>(currentItems: T[], newItems: T[], identityProperty?: string): boolean;
|
|
4
|
-
export declare function itemsOrOrderChanged<T = unknown>(currentItems: T[], newItems: T[], identityProperty?: string): boolean;
|
|
3
|
+
export declare function itemsChanged<T = unknown>(currentItems: readonly T[], newItems: readonly T[], identityProperty?: string): boolean;
|
|
4
|
+
export declare function itemsOrOrderChanged<T = unknown>(currentItems: readonly T[], newItems: readonly T[], identityProperty?: string): boolean;
|
|
5
5
|
export declare const moveItemDeprecated: <T = unknown>(items: T[], item: T, moveTo: number) => T[];
|
|
6
6
|
export declare const moveItem: <T = unknown>(items: T[], fromIndex: number, toIndex: number) => T[];
|
|
7
|
-
export declare const getAddedItems: <T>(
|
|
8
|
-
export declare const
|
|
7
|
+
export declare const getAddedItems: <T>(currentItems: undefined | readonly T[], newItems: readonly T[]) => readonly T[];
|
|
8
|
+
export declare const getRemovedItems: <T>(currentItems: readonly T[], newItems: undefined | readonly T[]) => readonly T[];
|
|
9
|
+
export declare const containsSubsetOfItems: <T>(allItems: readonly T[], comparedItems: readonly T[]) => boolean;
|
|
10
|
+
export declare const getMissingItems: <T, I>(sourceItems: readonly T[], items: readonly I[], identity: (s: T) => I) => I[];
|
|
9
11
|
/**
|
|
10
12
|
* Given an ordered list of item names, return items in same order
|
|
11
13
|
*/
|