@pantheon-systems/pds-toolkit-react 2.0.0-alpha.52 → 2.0.0-alpha.53
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/codemods/v1-to-v2/mappings.json +6 -1
- package/dist/components/icons/Icon/generated-icon-data.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1331 -1330
- package/dist/index.js.map +1 -1
- package/dist/index.source.d.ts +1 -0
- package/dist/utilities/hooks/useKeyPress/useKeyPress.d.ts +6 -0
- package/dist/utilities/hooks/useKeyboardShortcut/useKeyboardShortcut.d.ts +29 -0
- package/package.json +9 -3
package/dist/index.source.d.ts
CHANGED
|
@@ -127,6 +127,7 @@ export * from './utilities/hooks/useBreakpoint/useBreakpoint';
|
|
|
127
127
|
export * from './utilities/hooks/useClipboard/useClipboard';
|
|
128
128
|
export * from './utilities/hooks/useDropdown';
|
|
129
129
|
export * from './utilities/hooks/useIsMobile/useIsMobile';
|
|
130
|
+
export * from './utilities/hooks/useKeyboardShortcut/useKeyboardShortcut';
|
|
130
131
|
export * from './utilities/hooks/useKeyPress/useKeyPress';
|
|
131
132
|
export * from './utilities/hooks/useMediaQuery/useMediaQuery';
|
|
132
133
|
export * from './utilities/hooks/useWindowWidth/useWindowWidth';
|
|
@@ -20,4 +20,10 @@ export interface UseKeyPressOptions {
|
|
|
20
20
|
*/
|
|
21
21
|
shiftKey?: boolean;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use `useKeyboardShortcut` instead. `useKeyPress` fires even while
|
|
25
|
+
* the user is typing in a form field and requires callers to manually disable
|
|
26
|
+
* shortcuts when an overlay is open; `useKeyboardShortcut` handles both by
|
|
27
|
+
* default. This hook will be removed before the v2 stable release.
|
|
28
|
+
*/
|
|
23
29
|
export declare const useKeyPress: (targetKey: string, callback?: (event: KeyboardEvent) => void, options?: UseKeyPressOptions) => boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HotkeyCallback, Keys, Options } from 'react-hotkeys-hook';
|
|
2
|
+
export type UseKeyboardShortcutOptions = Options;
|
|
3
|
+
/**
|
|
4
|
+
* Registers a keyboard shortcut, applying the PDS defaults on top of
|
|
5
|
+
* `react-hotkeys-hook`:
|
|
6
|
+
*
|
|
7
|
+
* - **Ignores form fields by default.** Shortcuts do not fire while focus is in
|
|
8
|
+
* an `input`, `textarea`, `select`, or `contentEditable` element, so typing a
|
|
9
|
+
* shortcut character (e.g. `/`) into a field never hijacks it. Opt in per
|
|
10
|
+
* shortcut with `enableOnFormTags` / `enableOnContentEditable` when a shortcut
|
|
11
|
+
* genuinely needs to fire inside a field.
|
|
12
|
+
* - **Overlay-aware.** Shortcuts auto-suppress while any PDS overlay (modal,
|
|
13
|
+
* drawer, mobile menu, etc.) is open, so callers never have to thread
|
|
14
|
+
* `hasOpenOverlay` through their own `enabled` flag.
|
|
15
|
+
*
|
|
16
|
+
* The full `react-hotkeys-hook` option surface (scopes, key sequences,
|
|
17
|
+
* `description`, cross-platform `mod`, etc.) is available via `options`.
|
|
18
|
+
*
|
|
19
|
+
* @param keys - The key or combination to listen for, e.g. `'/'`, `'mod+k'`,
|
|
20
|
+
* `'shift+['`. Uses `react-hotkeys-hook` key syntax.
|
|
21
|
+
* @param callback - Invoked when the shortcut fires. Receives the
|
|
22
|
+
* `KeyboardEvent` and the parsed hotkey event.
|
|
23
|
+
* @param options - `react-hotkeys-hook` options. `enabled` is combined with the
|
|
24
|
+
* overlay state so a shortcut is active only when enabled *and* no overlay is
|
|
25
|
+
* open.
|
|
26
|
+
* @param dependencies - Optional dependency array for the callback, forwarded to
|
|
27
|
+
* `react-hotkeys-hook`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const useKeyboardShortcut: (keys: Keys, callback: HotkeyCallback, options?: UseKeyboardShortcutOptions, dependencies?: unknown[]) => (instance: HTMLElement) => void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pantheon-systems/pds-toolkit-react",
|
|
3
3
|
"technology": "React",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.53",
|
|
5
5
|
"description": "PDS toolkit built using the React framework",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -163,7 +163,6 @@
|
|
|
163
163
|
"prettier-plugin-css-order": "^2.2.0",
|
|
164
164
|
"react": "^18.2.0",
|
|
165
165
|
"react-dom": "^18.2.0",
|
|
166
|
-
"react-router-dom": "^7.0.0",
|
|
167
166
|
"storybook": "^10.4.0",
|
|
168
167
|
"tsc-alias": "^1.8.17",
|
|
169
168
|
"typescript": "^5.4.5",
|
|
@@ -205,7 +204,14 @@
|
|
|
205
204
|
"@babel/plugin-transform-modules-systemjs": "^7.29.4",
|
|
206
205
|
"fast-uri": "^3.1.4",
|
|
207
206
|
"hono": "^4.12.18",
|
|
208
|
-
"ip-address": "^10.1.1"
|
|
207
|
+
"ip-address": "^10.1.1",
|
|
208
|
+
"micromatch": "^4.0.8",
|
|
209
|
+
"minimatch": "^10.0.0",
|
|
210
|
+
"postcss-insert": {
|
|
211
|
+
"postcss": "^8.4.31"
|
|
212
|
+
},
|
|
213
|
+
"valibot": "^1.4.2",
|
|
214
|
+
"yaml": "^2.8.3"
|
|
209
215
|
},
|
|
210
216
|
"lint-staged": {
|
|
211
217
|
"*": "prettier --write --ignore-unknown",
|