@solid-aria/focus
Advanced tools
Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "@solid-aria/focus", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"private": false, | ||
@@ -27,5 +27,14 @@ "description": "Primitives for dealing with focus rings and focus management.", | ||
"type": "module", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"solid": "./dist/source/index.js", | ||
"import": "./dist/esm/index.js", | ||
"browser": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.js", | ||
"node": "./dist/cjs/index.js" | ||
} | ||
}, | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/types/index.d.ts", | ||
"files": [ | ||
@@ -35,9 +44,10 @@ "dist" | ||
"dependencies": { | ||
"@solid-aria/interactions": "^0.0.4", | ||
"@solid-aria/types": "^0.0.3", | ||
"@solid-aria/utils": "^0.0.4" | ||
"@solid-aria/interactions": "^0.0.5", | ||
"@solid-aria/types": "^0.0.4", | ||
"@solid-aria/utils": "^0.0.5" | ||
}, | ||
"peerDependencies": { | ||
"@solid-primitives/utils": "^1.3.0", | ||
"solid-js": "^1.3.15" | ||
"@solid-primitives/props": "^2.1.2", | ||
"@solid-primitives/utils": "^2.0.1", | ||
"solid-js": "^1.4.0" | ||
}, | ||
@@ -54,3 +64,3 @@ "publishConfig": { | ||
"scripts": { | ||
"build": "tsup", | ||
"build": "rollup -c", | ||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist", | ||
@@ -57,0 +67,0 @@ "dev": "vite serve dev --host", |
@@ -17,2 +17,3 @@ <p> | ||
- [`createFocusRing`](#createFocusRing) - Determines whether a focus ring should be shown to indicate keyboard focus. | ||
- [`FocusScope`](#FocusScope) - Utility component that can be used to manage focus for its descendants. | ||
@@ -98,4 +99,38 @@ ## Installation | ||
## `FocusScope` | ||
A FocusScope manages focus for its descendants. It supports containing focus inside the scope, restoring focus to the previously focused element on unmount, and auto focusing children on mount. It also acts as a container for a programmatic focus management interface that can be used to move focus forward and back in response to user events. | ||
### How to use it | ||
A basic example of a focus scope that contains focus within it. Clicking the "Open" button mounts a FocusScope, which auto focuses the first input inside it. Once open, you can press the `Tab` key to move within the scope, but focus is contained inside. Clicking the "Close" button unmounts the focus scope, which restores focus back to the button. | ||
For a full example of building a modal dialog, see [`createDialog`](../dialog/README.md). | ||
```tsx | ||
import { FocusScope } from "@solid-aria/focus"; | ||
import { createSignal, Show } from "solid-js"; | ||
function Example() { | ||
const [isOpen, setOpen] = createSignal(false); | ||
return ( | ||
<> | ||
<button onClick={() => setOpen(true)}>Open</button> | ||
<Show when={isOpen()}> | ||
<FocusScope contain restoreFocus autoFocus> | ||
<label for="first-input">First Input</label> | ||
<input id="first-input" /> | ||
<label for="second-input">Second Input</label> | ||
<input id="second-input" /> | ||
<button onClick={() => setOpen(false)}>Close</button> | ||
</FocusScope> | ||
</Show> | ||
</> | ||
); | ||
} | ||
``` | ||
## Changelog | ||
All notable changes are described in the [CHANGELOG.md](./CHANGELOG.md) file. |
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
Mixed license
License(Experimental) Package contains multiple licenses.
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 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
221923
19
2440
135
6
2
80
1
+ Added@solid-aria/interactions@0.0.5(transitive)
+ Added@solid-aria/types@0.0.4(transitive)
+ Added@solid-aria/utils@0.0.5(transitive)
+ Added@solid-primitives/props@2.2.2(transitive)
+ Added@solid-primitives/utils@2.2.13.1.0(transitive)
- Removed@solid-aria/interactions@0.0.4(transitive)
- Removed@solid-aria/types@0.0.3(transitive)
- Removed@solid-aria/utils@0.0.4(transitive)
- Removed@solid-primitives/utils@1.5.2(transitive)
Updated@solid-aria/types@^0.0.4
Updated@solid-aria/utils@^0.0.5