@react-stately/select
Advanced tools
Comparing version 3.0.0-alpha.1 to 3.0.0-nightly-4980928d3-240906
@@ -1,49 +0,22 @@ | ||
var _babelRuntimeHelpersObjectSpread = $parcel$interopDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var $80ebb60e77198879$exports = require("./useSelectState.main.js"); | ||
var _babelRuntimeHelpersSlicedToArray = $parcel$interopDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var useMemo = require("react").useMemo; | ||
var useMenuTriggerState = require("@react-stately/menu").useMenuTriggerState; | ||
var useControlledState = require("@react-stately/utils").useControlledState; | ||
var useListState = require("@react-stately/list").useListState; | ||
function $parcel$interopDefault(a) { | ||
return a && a.__esModule ? a.default : a; | ||
function $parcel$export(e, n, v, s) { | ||
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); | ||
} | ||
function useSelectState(props) { | ||
var _useControlledState = useControlledState(props.selectedKey, props.defaultSelectedKey, props.onSelectionChange), | ||
_useControlledState2 = _babelRuntimeHelpersSlicedToArray(_useControlledState, 2), | ||
selectedKey = _useControlledState2[0], | ||
setSelectedKey = _useControlledState2[1]; | ||
$parcel$export(module.exports, "useSelectState", () => $80ebb60e77198879$exports.useSelectState); | ||
/* | ||
* 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 selectedKeys = useMemo(function () { | ||
return selectedKey != null ? [selectedKey] : []; | ||
}, [selectedKey]); | ||
var triggerState = useMenuTriggerState(props); | ||
var _useListState = useListState(_babelRuntimeHelpersObjectSpread({}, props, { | ||
selectionMode: 'single', | ||
selectedKeys: selectedKeys, | ||
onSelectionChange: function onSelectionChange(keys) { | ||
setSelectedKey(keys.values().next().value); | ||
triggerState.setOpen(false); | ||
} | ||
})), | ||
collection = _useListState.collection, | ||
disabledKeys = _useListState.disabledKeys, | ||
selectionManager = _useListState.selectionManager; | ||
return _babelRuntimeHelpersObjectSpread({}, triggerState, { | ||
collection: collection, | ||
disabledKeys: disabledKeys, | ||
selectionManager: selectionManager, | ||
selectedKey: selectedKey, | ||
setSelectedKey: setSelectedKey | ||
}); | ||
} | ||
exports.useSelectState = useSelectState; | ||
//# sourceMappingURL=main.js.map |
@@ -1,29 +0,17 @@ | ||
import _babelRuntimeHelpersEsmObjectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import { useMemo } from "react"; | ||
import { useMenuTriggerState } from "@react-stately/menu"; | ||
import { useControlledState } from "@react-stately/utils"; | ||
import { useListState } from "@react-stately/list"; | ||
export function useSelectState(props) { | ||
let [selectedKey, setSelectedKey] = useControlledState(props.selectedKey, props.defaultSelectedKey, props.onSelectionChange); | ||
let selectedKeys = useMemo(() => selectedKey != null ? [selectedKey] : [], [selectedKey]); | ||
let triggerState = useMenuTriggerState(props); | ||
let { | ||
collection, | ||
disabledKeys, | ||
selectionManager | ||
} = useListState(_babelRuntimeHelpersEsmObjectSpread({}, props, { | ||
selectionMode: 'single', | ||
selectedKeys, | ||
onSelectionChange: keys => { | ||
setSelectedKey(keys.values().next().value); | ||
triggerState.setOpen(false); | ||
} | ||
})); | ||
return _babelRuntimeHelpersEsmObjectSpread({}, triggerState, { | ||
collection, | ||
disabledKeys, | ||
selectionManager, | ||
selectedKey, | ||
setSelectedKey | ||
}); | ||
} | ||
import {useSelectState as $2bc3a590c5373a4e$export$5159ec8b34d4ec12} from "./useSelectState.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 {$2bc3a590c5373a4e$export$5159ec8b34d4ec12 as useSelectState}; | ||
//# sourceMappingURL=module.js.map |
@@ -1,15 +0,28 @@ | ||
import { Collection, Node } from "@react-stately/collections"; | ||
import { Key } from "react"; | ||
import { MenuTriggerState } from "@react-stately/menu"; | ||
import { SelectionManager } from "@react-stately/selection"; | ||
import { CollectionStateBase, FocusStrategy } from "@react-types/shared"; | ||
import { FormValidationState } from "@react-stately/form"; | ||
import { OverlayTriggerState } from "@react-stately/overlays"; | ||
import { SelectProps } from "@react-types/select"; | ||
export interface SelectState<T> extends MenuTriggerState { | ||
collection: Collection<Node<T>>; | ||
disabledKeys: Set<Key>; | ||
selectionManager: SelectionManager; | ||
selectedKey: Key; | ||
setSelectedKey: (key: Key) => void; | ||
import { SingleSelectListState } from "@react-stately/list"; | ||
export interface SelectStateOptions<T> extends Omit<SelectProps<T>, 'children'>, CollectionStateBase<T> { | ||
} | ||
export function useSelectState<T>(props: SelectProps<T>): SelectState<T>; | ||
export interface SelectState<T> extends SingleSelectListState<T>, OverlayTriggerState, FormValidationState { | ||
/** Whether the select is currently focused. */ | ||
readonly isFocused: boolean; | ||
/** Sets whether the select is focused. */ | ||
setFocused(isFocused: boolean): void; | ||
/** Controls which item will be auto focused when the menu opens. */ | ||
readonly focusStrategy: FocusStrategy | null; | ||
/** Opens the menu. */ | ||
open(focusStrategy?: FocusStrategy | null): void; | ||
/** Toggles the menu. */ | ||
toggle(focusStrategy?: FocusStrategy | null): void; | ||
} | ||
/** | ||
* Provides state management for a select component. Handles building a collection | ||
* of items from props, handles the open state for the popup menu, and manages | ||
* multiple selection state. | ||
*/ | ||
export function useSelectState<T extends object>(props: SelectStateOptions<T>): SelectState<T>; | ||
export type { SelectProps } from '@react-types/select'; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-stately/select", | ||
"version": "3.0.0-alpha.1", | ||
"version": "3.0.0-nightly-4980928d3-240906", | ||
"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,15 +23,14 @@ "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/list": "^3.0.0-alpha.1", | ||
"@react-stately/menu": "^3.0.0-alpha.1", | ||
"@react-stately/selection": "^3.0.0-alpha.1", | ||
"@react-stately/utils": "^3.0.0-rc.2", | ||
"@react-types/select": "^3.0.0-alpha.1" | ||
"@react-stately/form": "^3.0.0-nightly-4980928d3-240906", | ||
"@react-stately/list": "^3.0.0-nightly-4980928d3-240906", | ||
"@react-stately/overlays": "^3.0.0-nightly-4980928d3-240906", | ||
"@react-types/select": "^3.0.0-nightly-4980928d3-240906", | ||
"@react-types/shared": "^3.0.0-nightly-4980928d3-240906", | ||
"@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" | ||
}, | ||
@@ -35,3 +40,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "207e6ee9076905c96638a7f81a367758872e1410" | ||
} | ||
"stableVersion": "3.6.7" | ||
} |
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 5 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
28352
7
16
329
0
3
63
5
60
1
204
+ Added@react-stately/overlays@^3.0.0-nightly-4980928d3-240906
+ Added@swc/helpers@^0.5.0
+ Added@react-stately/form@3.0.6(transitive)
+ Addedreact@18.3.1(transitive)
- Removed@babel/runtime@^7.6.2
- Removed@react-stately/menu@^3.0.0-alpha.1
- Removed@react-stately/utils@^3.0.0-rc.2
- Removed@babel/runtime@7.26.0(transitive)
- Removed@react-stately/menu@3.8.3(transitive)
- Removed@react-types/menu@3.9.12(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)