@astryxdesign/cli 0.7.8-canary.b95497d → 0.7.8-canary.c8f08f9
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.
|
@@ -134,7 +134,7 @@ generateThemeRules generateThemeRules theme/MediaTheme.doc.mjs theme/generateThe
|
|
|
134
134
|
gestureCounter gestureCounter Layer/Layer.doc.mjs Layer/gestureCounter.ts
|
|
135
135
|
getInitialFocusDate getInitialFocusDate Calendar/Calendar.doc.mjs Calendar/getInitialFocusDate.ts
|
|
136
136
|
getLocaleDirection getLocaleDirection i18n/InternationalizationProvider.doc.mjs i18n/getLocaleDirection.ts
|
|
137
|
-
|
|
137
|
+
getWeekdayHeaderNames getWeekdayHeaderNames Calendar/Calendar.doc.mjs Calendar/getWeekdayHeaderNames.ts
|
|
138
138
|
glidingDivider glidingDivider Table/Table.doc.mjs Table/glidingDivider.ts
|
|
139
139
|
globalIconRegistry globalIconRegistry Icon/Icon.doc.mjs Icon/globalIconRegistry.tsx
|
|
140
140
|
grammar grammar CodeBlock/CodeBlock.doc.mjs CodeBlock/grammar.ts
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
|
|
4
|
+
export const doc = {
|
|
5
|
+
type: 'block',
|
|
6
|
+
exampleFor: 'useHotkeys',
|
|
7
|
+
name: 'useHotkeys — Search and Help Shortcuts',
|
|
8
|
+
displayName: 'useHotkeys — Search and Help Shortcuts',
|
|
9
|
+
description:
|
|
10
|
+
'Page shortcuts registered with useHotkeys: "/" focuses the search field and "?" opens the shortcut help, while typing either character in the field just types it. A switch turns the single-key shortcuts off through isDisabled.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 4 / 3,
|
|
13
|
+
componentsUsed: [
|
|
14
|
+
'Card',
|
|
15
|
+
'TextInput',
|
|
16
|
+
'Button',
|
|
17
|
+
'Switch',
|
|
18
|
+
'Dialog',
|
|
19
|
+
'Kbd',
|
|
20
|
+
'Text',
|
|
21
|
+
'Layout',
|
|
22
|
+
],
|
|
23
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useRef, useState} from 'react';
|
|
6
|
+
import {Button} from '@astryxdesign/core/Button';
|
|
7
|
+
import {Card} from '@astryxdesign/core/Card';
|
|
8
|
+
import {Dialog, DialogHeader} from '@astryxdesign/core/Dialog';
|
|
9
|
+
import {useHotkeys} from '@astryxdesign/core/hooks';
|
|
10
|
+
import {Kbd} from '@astryxdesign/core/Kbd';
|
|
11
|
+
import {
|
|
12
|
+
HStack,
|
|
13
|
+
Layout,
|
|
14
|
+
LayoutContent,
|
|
15
|
+
StackItem,
|
|
16
|
+
VStack,
|
|
17
|
+
} from '@astryxdesign/core/Layout';
|
|
18
|
+
import {Switch} from '@astryxdesign/core/Switch';
|
|
19
|
+
import {Text} from '@astryxdesign/core/Text';
|
|
20
|
+
import {TextInput} from '@astryxdesign/core/TextInput';
|
|
21
|
+
|
|
22
|
+
export default function UseHotkeysHookUsage() {
|
|
23
|
+
const searchRef = useRef<HTMLInputElement>(null);
|
|
24
|
+
const [query, setQuery] = useState('');
|
|
25
|
+
const [isHelpOpen, setIsHelpOpen] = useState(false);
|
|
26
|
+
// Single-character shortcuts need an off switch (WCAG 2.1.4).
|
|
27
|
+
const [hasShortcuts, setHasShortcuts] = useState(true);
|
|
28
|
+
|
|
29
|
+
useHotkeys([
|
|
30
|
+
{
|
|
31
|
+
keys: '/',
|
|
32
|
+
onPress: () => searchRef.current?.focus(),
|
|
33
|
+
isDisabled: !hasShortcuts,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
keys: '?',
|
|
37
|
+
onPress: () => setIsHelpOpen(true),
|
|
38
|
+
isDisabled: !hasShortcuts,
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Card width={480} padding={4}>
|
|
44
|
+
<VStack gap={3}>
|
|
45
|
+
<HStack gap={2} vAlign="center">
|
|
46
|
+
<StackItem size="fill">
|
|
47
|
+
<TextInput
|
|
48
|
+
ref={searchRef}
|
|
49
|
+
label="Search"
|
|
50
|
+
isLabelHidden
|
|
51
|
+
placeholder="Search projects"
|
|
52
|
+
value={query}
|
|
53
|
+
onChange={setQuery}
|
|
54
|
+
/>
|
|
55
|
+
</StackItem>
|
|
56
|
+
<Button label="Shortcuts" onClick={() => setIsHelpOpen(true)} />
|
|
57
|
+
</HStack>
|
|
58
|
+
<Switch
|
|
59
|
+
label="Single-key shortcuts"
|
|
60
|
+
value={hasShortcuts}
|
|
61
|
+
onChange={setHasShortcuts}
|
|
62
|
+
/>
|
|
63
|
+
</VStack>
|
|
64
|
+
<Dialog isOpen={isHelpOpen} onOpenChange={setIsHelpOpen}>
|
|
65
|
+
<Layout
|
|
66
|
+
header={
|
|
67
|
+
<DialogHeader
|
|
68
|
+
title="Keyboard shortcuts"
|
|
69
|
+
onOpenChange={setIsHelpOpen}
|
|
70
|
+
/>
|
|
71
|
+
}
|
|
72
|
+
content={
|
|
73
|
+
<LayoutContent>
|
|
74
|
+
<VStack gap={2}>
|
|
75
|
+
<HStack gap={2} vAlign="center">
|
|
76
|
+
<Kbd keys="/" />
|
|
77
|
+
<Text type="body">Focus search</Text>
|
|
78
|
+
</HStack>
|
|
79
|
+
<HStack gap={2} vAlign="center">
|
|
80
|
+
<Kbd keys="?" />
|
|
81
|
+
<Text type="body">Show this help</Text>
|
|
82
|
+
</HStack>
|
|
83
|
+
</VStack>
|
|
84
|
+
</LayoutContent>
|
|
85
|
+
}
|
|
86
|
+
/>
|
|
87
|
+
</Dialog>
|
|
88
|
+
</Card>
|
|
89
|
+
);
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.8-canary.
|
|
3
|
+
"version": "0.7.8-canary.c8f08f9",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -124,10 +124,10 @@
|
|
|
124
124
|
"zod": "^4.4.3"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@astryxdesign/charts": "0.7.8-canary.
|
|
128
|
-
"@astryxdesign/core": "0.7.8-canary.
|
|
129
|
-
"@astryxdesign/lab": "0.7.8-canary.
|
|
130
|
-
"@astryxdesign/theme-neutral": "0.7.8-canary.
|
|
127
|
+
"@astryxdesign/charts": "0.7.8-canary.c8f08f9",
|
|
128
|
+
"@astryxdesign/core": "0.7.8-canary.c8f08f9",
|
|
129
|
+
"@astryxdesign/lab": "0.7.8-canary.c8f08f9",
|
|
130
|
+
"@astryxdesign/theme-neutral": "0.7.8-canary.c8f08f9"
|
|
131
131
|
},
|
|
132
132
|
"peerDependenciesMeta": {
|
|
133
133
|
"@astryxdesign/charts": {
|
|
@@ -144,10 +144,10 @@
|
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
|
-
"@astryxdesign/charts": "0.7.8-canary.
|
|
148
|
-
"@astryxdesign/core": "0.7.8-canary.
|
|
149
|
-
"@astryxdesign/lab": "0.7.8-canary.
|
|
150
|
-
"@astryxdesign/theme-neutral": "0.7.8-canary.
|
|
147
|
+
"@astryxdesign/charts": "0.7.8-canary.c8f08f9",
|
|
148
|
+
"@astryxdesign/core": "0.7.8-canary.c8f08f9",
|
|
149
|
+
"@astryxdesign/lab": "0.7.8-canary.c8f08f9",
|
|
150
|
+
"@astryxdesign/theme-neutral": "0.7.8-canary.c8f08f9",
|
|
151
151
|
"@heroicons/react": "^2.2.0",
|
|
152
152
|
"@stylexjs/stylex": "^0.19.0",
|
|
153
153
|
"@types/babel__core": "^7.20.5",
|