@react-stately/list
Advanced tools
Comparing version 3.0.0-alpha.1 to 3.0.0-nightly-07431f4b1-241030
@@ -1,38 +0,28 @@ | ||
var _temp = require("@react-stately/collections"); | ||
var $5450691d3629f6ea$exports = require("./useListState.main.js"); | ||
var $b9e99587a092d199$exports = require("./useSingleSelectListState.main.js"); | ||
var $c9aa5a224613c979$exports = require("./ListCollection.main.js"); | ||
var CollectionBuilder = _temp.CollectionBuilder; | ||
var TreeCollection = _temp.TreeCollection; | ||
var useMemo = require("react").useMemo; | ||
function $parcel$export(e, n, v, s) { | ||
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); | ||
} | ||
var _temp2 = require("@react-stately/selection"); | ||
$parcel$export(module.exports, "useListState", () => $5450691d3629f6ea$exports.useListState); | ||
$parcel$export(module.exports, "useSingleSelectListState", () => $b9e99587a092d199$exports.useSingleSelectListState); | ||
$parcel$export(module.exports, "ListCollection", () => $c9aa5a224613c979$exports.ListCollection); | ||
/* | ||
* Copyright 2020 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
var SelectionManager = _temp2.SelectionManager; | ||
var useMultipleSelectionState = _temp2.useMultipleSelectionState; | ||
function useListState(props) { | ||
var selectionState = useMultipleSelectionState(props); | ||
var disabledKeys = useMemo(function () { | ||
return props.disabledKeys ? new Set(props.disabledKeys) : new Set(); | ||
}, [props.disabledKeys]); | ||
var builder = useMemo(function () { | ||
return new CollectionBuilder(props.itemKey); | ||
}, [props.itemKey]); | ||
var collection = useMemo(function () { | ||
var nodes = builder.build(props, function (key) { | ||
return { | ||
isSelected: selectionState.selectedKeys.has(key), | ||
isDisabled: disabledKeys.has(key), | ||
isFocused: key === selectionState.focusedKey | ||
}; | ||
}); | ||
return new TreeCollection(nodes); | ||
}, [builder, props, selectionState.selectedKeys, selectionState.focusedKey, disabledKeys]); | ||
return { | ||
collection: collection, | ||
disabledKeys: disabledKeys, | ||
selectionManager: new SelectionManager(collection, selectionState) | ||
}; | ||
} | ||
exports.useListState = useListState; | ||
//# sourceMappingURL=main.js.map |
@@ -1,21 +0,21 @@ | ||
import { CollectionBuilder, TreeCollection } from "@react-stately/collections"; | ||
import { useMemo } from "react"; | ||
import { SelectionManager, useMultipleSelectionState } from "@react-stately/selection"; | ||
export function useListState(props) { | ||
let selectionState = useMultipleSelectionState(props); | ||
let disabledKeys = useMemo(() => props.disabledKeys ? new Set(props.disabledKeys) : new Set(), [props.disabledKeys]); | ||
let builder = useMemo(() => new CollectionBuilder(props.itemKey), [props.itemKey]); | ||
let collection = useMemo(() => { | ||
let nodes = builder.build(props, key => ({ | ||
isSelected: selectionState.selectedKeys.has(key), | ||
isDisabled: disabledKeys.has(key), | ||
isFocused: key === selectionState.focusedKey | ||
})); | ||
return new TreeCollection(nodes); | ||
}, [builder, props, selectionState.selectedKeys, selectionState.focusedKey, disabledKeys]); | ||
return { | ||
collection, | ||
disabledKeys, | ||
selectionManager: new SelectionManager(collection, selectionState) | ||
}; | ||
} | ||
import {useListState as $e72dd72e1c76a225$export$2f645645f7bca764} from "./useListState.module.js"; | ||
import {useSingleSelectListState as $a0d645289fe9b86b$export$e7f05e985daf4b5f} from "./useSingleSelectListState.module.js"; | ||
import {ListCollection as $a02d57049d202695$export$d085fb9e920b5ca7} from "./ListCollection.module.js"; | ||
/* | ||
* Copyright 2020 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
export {$e72dd72e1c76a225$export$2f645645f7bca764 as useListState, $a0d645289fe9b86b$export$e7f05e985daf4b5f as useSingleSelectListState, $a02d57049d202695$export$d085fb9e920b5ca7 as ListCollection}; | ||
//# sourceMappingURL=module.js.map |
@@ -1,12 +0,60 @@ | ||
import { Collection, Node } from "@react-stately/collections"; | ||
import { CollectionBase, MultipleSelection } from "@react-types/shared"; | ||
import { Key } from "react"; | ||
import { SelectionManager } from "@react-stately/selection"; | ||
import { Collection, Key, Node, CollectionStateBase, LayoutDelegate, SingleSelection } from "@react-types/shared"; | ||
import { MultipleSelectionStateProps, SelectionManager } from "@react-stately/selection"; | ||
export class ListCollection<T> implements Collection<Node<T>> { | ||
constructor(nodes: Iterable<Node<T>>); | ||
[Symbol.iterator](): Generator<Node<T>, void, undefined>; | ||
get size(): number; | ||
getKeys(): IterableIterator<Key>; | ||
getKeyBefore(key: Key): Key; | ||
getKeyAfter(key: Key): Key; | ||
getFirstKey(): Key; | ||
getLastKey(): Key; | ||
getItem(key: Key): Node<T>; | ||
at(idx: number): Node<T>; | ||
getChildren(key: Key): Iterable<Node<T>>; | ||
} | ||
export interface ListProps<T> extends CollectionStateBase<T>, MultipleSelectionStateProps { | ||
/** Filter function to generate a filtered list of nodes. */ | ||
filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>; | ||
/** @private */ | ||
suppressTextValueWarning?: boolean; | ||
/** | ||
* A delegate object that provides layout information for items in the collection. | ||
* This can be used to override the behavior of shift selection. | ||
*/ | ||
layoutDelegate?: LayoutDelegate; | ||
} | ||
export interface ListState<T> { | ||
/** A collection of items in the list. */ | ||
collection: Collection<Node<T>>; | ||
/** A set of items that are disabled. */ | ||
disabledKeys: Set<Key>; | ||
/** A selection manager to read and update multiple selection state. */ | ||
selectionManager: SelectionManager; | ||
} | ||
export function useListState<T>(props: CollectionBase<T> & MultipleSelection): ListState<T>; | ||
/** | ||
* Provides state management for list-like components. Handles building a collection | ||
* of items from props, and manages multiple selection state. | ||
*/ | ||
export function useListState<T extends object>(props: ListProps<T>): ListState<T>; | ||
export interface SingleSelectListProps<T> extends CollectionStateBase<T>, Omit<SingleSelection, 'disallowEmptySelection'> { | ||
/** Filter function to generate a filtered list of nodes. */ | ||
filter?: (nodes: Iterable<Node<T>>) => Iterable<Node<T>>; | ||
/** @private */ | ||
suppressTextValueWarning?: boolean; | ||
} | ||
export interface SingleSelectListState<T> extends ListState<T> { | ||
/** The key for the currently selected item. */ | ||
readonly selectedKey: Key | null; | ||
/** Sets the selected key. */ | ||
setSelectedKey(key: Key | null): void; | ||
/** The value of the currently selected item. */ | ||
readonly selectedItem: Node<T> | null; | ||
} | ||
/** | ||
* Provides state management for list-like components with single selection. | ||
* Handles building a collection of items from props, and manages selection state. | ||
*/ | ||
export function useSingleSelectListState<T extends object>(props: SingleSelectListProps<T>): SingleSelectListState<T>; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-stately/list", | ||
"version": "3.0.0-alpha.1", | ||
"version": "3.0.0-nightly-07431f4b1-241030", | ||
"description": "Spectrum UI components in React", | ||
@@ -8,6 +8,12 @@ "license": "Apache-2.0", | ||
"module": "dist/module.js", | ||
"exports": { | ||
"types": "./dist/types.d.ts", | ||
"import": "./dist/import.mjs", | ||
"require": "./dist/main.js" | ||
}, | ||
"types": "dist/types.d.ts", | ||
"source": "src/index.ts", | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"src" | ||
], | ||
@@ -17,12 +23,13 @@ "sideEffects": false, | ||
"type": "git", | ||
"url": "https://github.com/adobe-private/react-spectrum-v3" | ||
"url": "https://github.com/adobe/react-spectrum" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.6.2", | ||
"@react-stately/collections": "^3.0.0-alpha.1", | ||
"@react-stately/selection": "^3.0.0-alpha.1", | ||
"@react-stately/utils": "^3.0.0-rc.2" | ||
"@react-stately/collections": "^3.0.0-nightly-07431f4b1-241030", | ||
"@react-stately/selection": "^3.0.0-nightly-07431f4b1-241030", | ||
"@react-stately/utils": "^3.0.0-nightly-07431f4b1-241030", | ||
"@react-types/shared": "^3.0.0-nightly-07431f4b1-241030", | ||
"@swc/helpers": "^0.5.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0" | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" | ||
}, | ||
@@ -32,3 +39,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "207e6ee9076905c96638a7f81a367758872e1410" | ||
} | ||
"stableVersion": "3.11.0" | ||
} |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 4 instances 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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
90638
28
1077
0
3
6
4
80
1
+ Added@swc/helpers@^0.5.0
+ Addedreact@18.3.1(transitive)
- Removed@babel/runtime@^7.6.2
- Removed@babel/runtime@7.26.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedprop-types@15.8.1(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-is@16.13.1(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
Updated@react-stately/collections@^3.0.0-nightly-07431f4b1-241030
Updated@react-stately/selection@^3.0.0-nightly-07431f4b1-241030