@awsui/collection-hooks
Advanced tools
Comparing version 1.0.22 to 1.0.23
@@ -8,3 +8,4 @@ import { UseCollectionOptions, CollectionState, TrackBy } from '../interfaces'; | ||
}; | ||
export declare const getTrackableValue: <T>(trackBy: TrackBy<T> | undefined, item: T) => any; | ||
export declare const processSelectedItems: <T>(items: readonly T[], selectedItems: readonly T[], trackBy?: TrackBy<T> | undefined) => T[]; | ||
export declare const itemsAreEqual: <T>(items1: readonly T[], items2: readonly T[], trackBy?: TrackBy<T> | undefined) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.itemsAreEqual = exports.processSelectedItems = exports.processItems = void 0; | ||
exports.itemsAreEqual = exports.processSelectedItems = exports.getTrackableValue = exports.processItems = void 0; | ||
var filter_js_1 = require("./filter.js"); | ||
@@ -43,6 +43,7 @@ var property_filter_js_1 = require("./property-filter.js"); | ||
}; | ||
exports.getTrackableValue = getTrackableValue; | ||
var processSelectedItems = function (items, selectedItems, trackBy) { | ||
var selectedSet = new Set(); | ||
selectedItems.forEach(function (item) { return selectedSet.add(getTrackableValue(trackBy, item)); }); | ||
return items.filter(function (item) { return selectedSet.has(getTrackableValue(trackBy, item)); }); | ||
selectedItems.forEach(function (item) { return selectedSet.add((0, exports.getTrackableValue)(trackBy, item)); }); | ||
return items.filter(function (item) { return selectedSet.has((0, exports.getTrackableValue)(trackBy, item)); }); | ||
}; | ||
@@ -55,5 +56,5 @@ exports.processSelectedItems = processSelectedItems; | ||
var set1 = new Set(); | ||
items1.forEach(function (item) { return set1.add(getTrackableValue(trackBy, item)); }); | ||
return items2.every(function (item) { return set1.has(item); }); | ||
items1.forEach(function (item) { return set1.add((0, exports.getTrackableValue)(trackBy, item)); }); | ||
return items2.every(function (item) { return set1.has((0, exports.getTrackableValue)(trackBy, item)); }); | ||
}; | ||
exports.itemsAreEqual = itemsAreEqual; |
@@ -25,3 +25,3 @@ "use strict"; | ||
var newSelectedItems = (0, index_js_1.processSelectedItems)(items, state.selectedItems, options.selection.trackBy); | ||
if (!(0, index_js_1.itemsAreEqual)(newSelectedItems, state.selectedItems)) { | ||
if (!(0, index_js_1.itemsAreEqual)(newSelectedItems, state.selectedItems, options.selection.trackBy)) { | ||
// This is a recommended pattern for how to handle the state, dependent on the incoming props | ||
@@ -28,0 +28,0 @@ // https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops |
@@ -8,3 +8,4 @@ import { UseCollectionOptions, CollectionState, TrackBy } from '../interfaces'; | ||
}; | ||
export declare const getTrackableValue: <T>(trackBy: TrackBy<T> | undefined, item: T) => any; | ||
export declare const processSelectedItems: <T>(items: readonly T[], selectedItems: readonly T[], trackBy?: TrackBy<T> | undefined) => T[]; | ||
export declare const itemsAreEqual: <T>(items1: readonly T[], items2: readonly T[], trackBy?: TrackBy<T> | undefined) => boolean; |
@@ -30,3 +30,3 @@ import { filter } from './filter.js'; | ||
} | ||
var getTrackableValue = function (trackBy, item) { | ||
export var getTrackableValue = function (trackBy, item) { | ||
if (!trackBy) { | ||
@@ -51,3 +51,3 @@ return item; | ||
items1.forEach(function (item) { return set1.add(getTrackableValue(trackBy, item)); }); | ||
return items2.every(function (item) { return set1.has(item); }); | ||
return items2.every(function (item) { return set1.has(getTrackableValue(trackBy, item)); }); | ||
}; |
@@ -22,3 +22,3 @@ var __assign = (this && this.__assign) || function () { | ||
var newSelectedItems = processSelectedItems(items, state.selectedItems, options.selection.trackBy); | ||
if (!itemsAreEqual(newSelectedItems, state.selectedItems)) { | ||
if (!itemsAreEqual(newSelectedItems, state.selectedItems, options.selection.trackBy)) { | ||
// This is a recommended pattern for how to handle the state, dependent on the incoming props | ||
@@ -25,0 +25,0 @@ // https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops |
{ | ||
"name": "@awsui/collection-hooks", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66146
1218