@astryxdesign/cli 0.7.7 → 0.7.8-canary.0588a13
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/README.md +1 -1
- package/api/component/__fixtures__/resolutions/case-01.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-02.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-03.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-04.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-05.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-06.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-07.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-08.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-09.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-10.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-11.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-12.txt +30 -0
- package/api/component/__fixtures__/resolutions/case-13.txt +25 -0
- package/api/component/__fixtures__/resolutions/modules.txt +308 -0
- package/api/component/component.mjs +11 -7
- package/api/doctor/_adapter.d.mts +6 -2
- package/api/doctor/_adapter.mjs +5 -3
- package/api/doctor/built-checks.d.mts +9 -4
- package/api/doctor/built-checks.mjs +15 -10
- package/api/gap-report/gap-report.mjs +9 -4
- package/api/integration/authoring-checks.mjs +31 -0
- package/api/integration/check/check.mjs +8 -3
- package/api/search/_candidate-score.d.mts +4 -1
- package/api/search/_candidate-score.mjs +27 -11
- package/api/search/_gather-components.mjs +5 -0
- package/api/search/_gather-templates.mjs +31 -6
- package/api/search/_lexical.d.mts +14 -0
- package/api/search/_lexical.mjs +4 -0
- package/api/search/_result.d.mts +1 -0
- package/api/search/_result.mjs +1 -0
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.type.d.mts +4 -0
- package/api/search/search.type.mjs +1 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/promote-tokenizer-presentation.mjs +191 -0
- package/assets/discover/official-packages.json +4 -8
- package/assets/docs/browser-support.doc.mjs +27 -1
- package/assets/docs/motion.doc.mjs +1 -1
- package/assets/docs/tree/tokens-duration.doc.mjs +4 -0
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- package/assets/templates/blocks/components/Hooks/useAnnounceHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useAnnounceHookUsage.tsx +90 -0
- package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.tsx +35 -0
- package/assets/templates/blocks/components/Hooks/useFocusTrapHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useFocusTrapHookUsage.tsx +70 -0
- package/assets/templates/blocks/components/Hooks/useHotkeysHookUsage.doc.mjs +23 -0
- package/assets/templates/blocks/components/Hooks/useHotkeysHookUsage.tsx +90 -0
- package/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx +119 -0
- package/assets/templates/blocks/components/Hooks/useKeyboardHintHookUsage.doc.mjs +3 -11
- package/assets/templates/blocks/components/Hooks/useKeyboardHintHookUsage.tsx +60 -45
- package/assets/templates/blocks/components/Hooks/useLocaleHookUsage.doc.mjs +20 -0
- package/assets/templates/blocks/components/Hooks/useLocaleHookUsage.tsx +72 -0
- package/assets/templates/blocks/components/Hooks/useScrollableAreaHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useScrollableAreaHookUsage.tsx +90 -0
- package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.doc.mjs +15 -0
- package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.tsx +98 -0
- package/assets/templates/blocks/components/Hooks/useTypeaheadHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useTypeaheadHookUsage.tsx +66 -0
- package/assets/templates/blocks/components/Lightbox/LightboxHookUsage.doc.mjs +15 -0
- package/assets/templates/blocks/components/Lightbox/LightboxHookUsage.tsx +62 -0
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -0
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +1 -0
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -0
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -0
- package/assets/templates/blocks/components/createAnimator/AnimatorPlayingCardsVanilla.doc.mjs +14 -0
- package/assets/templates/blocks/components/createAnimator/AnimatorPlayingCardsVanilla.tsx +199 -0
- package/assets/templates/blocks/components/useAnimator/AnimatorPlayingCards.doc.mjs +21 -0
- package/assets/templates/blocks/components/useAnimator/AnimatorPlayingCards.tsx +210 -0
- package/assets/templates/pages/table-inbox/page.tsx +6 -0
- package/assets/templates/pages/work-item-detail/page.tsx +1 -0
- package/assets/theme.template.ts +2 -1
- package/authoring/doctypes/_schema.d.mts +16 -0
- package/authoring/doctypes/_schema.mjs +15 -0
- package/authoring/doctypes/component/component.doc.mjs +6 -0
- package/authoring/doctypes/component/type.ts +16 -0
- package/authoring/index.d.ts +1 -0
- package/clients/cli/commands/build.mjs +9 -3
- package/clients/cli/commands/component.mjs +18 -8
- package/clients/cli/commands/search.mjs +8 -2
- package/clients/cli/formatters/index.mjs +11 -0
- package/clients/cli/index.mjs +56 -11
- package/clients/cli/program.mjs +15 -0
- package/clients/cli/run.mjs +4 -1
- package/foundation/discovery/component-discovery.mjs +111 -16
- package/foundation/discovery/template-adapter.d.mts +10 -0
- package/foundation/discovery/template-adapter.mjs +94 -4
- package/foundation/fs/listing-cache.d.mts +25 -0
- package/foundation/fs/listing-cache.mjs +69 -2
- package/foundation/fs/paths.mjs +50 -5
- package/foundation/integrations/public-imports.d.mts +24 -0
- package/foundation/integrations/public-imports.mjs +2 -2
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/xle/registry.d.mts +1 -1
- package/foundation/xle/registry.mjs +11 -1
- package/package.json +9 -9
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {createAnimator} from '@astryxdesign/core';
|
|
6
|
+
|
|
7
|
+
const DECK = [
|
|
8
|
+
{face: 'A\u2660', name: 'Ace of spades'},
|
|
9
|
+
{face: 'K\u2665', name: 'King of hearts'},
|
|
10
|
+
{face: 'Q\u2663', name: 'Queen of clubs'},
|
|
11
|
+
{face: 'J\u2666', name: 'Jack of diamonds'},
|
|
12
|
+
];
|
|
13
|
+
/** A release faster than this (px/s) throws the card away. */
|
|
14
|
+
const THROW_SPEED = 1000;
|
|
15
|
+
/** The slowest throw, so a thrown card always leaves the table. */
|
|
16
|
+
const MIN_THROW = 1600;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A deck on a table, in plain JavaScript: no React below this line. It
|
|
20
|
+
* returns a function that takes it down again.
|
|
21
|
+
*/
|
|
22
|
+
function mountDeck(table: HTMLElement, discardButton: HTMLButtonElement) {
|
|
23
|
+
let top = 0;
|
|
24
|
+
const card = document.createElement('div');
|
|
25
|
+
card.textContent = DECK[0].face;
|
|
26
|
+
// An image's name is all a screen reader announces, so it names the card.
|
|
27
|
+
card.setAttribute('role', 'img');
|
|
28
|
+
card.setAttribute('aria-label', DECK[0].name);
|
|
29
|
+
Object.assign(card.style, {
|
|
30
|
+
width: '120px',
|
|
31
|
+
height: '170px',
|
|
32
|
+
display: 'grid',
|
|
33
|
+
placeItems: 'center',
|
|
34
|
+
font: 'bold 40px system-ui, sans-serif',
|
|
35
|
+
// The theme's surface and text, so the rank reads in light and dark.
|
|
36
|
+
borderRadius: 'var(--radius-container)',
|
|
37
|
+
backgroundColor: 'var(--color-background-surface)',
|
|
38
|
+
color: 'var(--color-text-primary)',
|
|
39
|
+
boxShadow: '0 2px 8px var(--color-shadow)',
|
|
40
|
+
touchAction: 'none',
|
|
41
|
+
cursor: 'grab',
|
|
42
|
+
userSelect: 'none',
|
|
43
|
+
});
|
|
44
|
+
// Announces each discard to screen readers.
|
|
45
|
+
const status = document.createElement('div');
|
|
46
|
+
status.setAttribute('aria-live', 'polite');
|
|
47
|
+
Object.assign(status.style, {
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
width: '1px',
|
|
50
|
+
height: '1px',
|
|
51
|
+
overflow: 'hidden',
|
|
52
|
+
clipPath: 'inset(50%)',
|
|
53
|
+
whiteSpace: 'nowrap',
|
|
54
|
+
});
|
|
55
|
+
table.append(card, status);
|
|
56
|
+
const animator = createAnimator(card);
|
|
57
|
+
// One discard at a time: a press while a card leaves deals no second card.
|
|
58
|
+
let isDiscarding = false;
|
|
59
|
+
|
|
60
|
+
// Announces the discard and deals the next card in place of the old one.
|
|
61
|
+
async function dealNext() {
|
|
62
|
+
status.textContent = `${DECK[top % DECK.length].name} discarded`;
|
|
63
|
+
top += 1;
|
|
64
|
+
const next = DECK[top % DECK.length];
|
|
65
|
+
card.textContent = next.face;
|
|
66
|
+
card.setAttribute('aria-label', next.name);
|
|
67
|
+
animator.set({x: 0, y: 0, rotate: 0, scale: 0.9, opacity: 0});
|
|
68
|
+
isDiscarding = false;
|
|
69
|
+
await animator.animate({scale: 1, opacity: 1});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Starts a discard unless one runs. It also ends a drag in progress: the
|
|
73
|
+
// drag's next move would take the discard's motion over and drag the dealt
|
|
74
|
+
// card.
|
|
75
|
+
function startDiscard() {
|
|
76
|
+
if (isDiscarding) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
isDiscarding = true;
|
|
80
|
+
origin = null;
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function discard(vx: number, vy: number) {
|
|
85
|
+
if (!startDiscard()) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const speed = Math.hypot(vx, vy);
|
|
89
|
+
const boost = speed < MIN_THROW ? MIN_THROW / Math.max(speed, 1) : 1;
|
|
90
|
+
// The card coasts on while it fades; once it is gone, the next card is
|
|
91
|
+
// dealt in place, which ends the coast. A coast continues the person's
|
|
92
|
+
// throw, so Reduce Motion keeps it.
|
|
93
|
+
void animator.decay({x: speed < 1 ? MIN_THROW : vx * boost, y: vy * boost});
|
|
94
|
+
await animator.animate({opacity: 0});
|
|
95
|
+
await dealNext();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// The drag: follow the pointer, then read the 80 ms before the release, so
|
|
99
|
+
// a pointer that held still before letting go releases at rest.
|
|
100
|
+
let origin: {x: number; y: number} | null = null;
|
|
101
|
+
let samples: {t: number; x: number; y: number}[] = [];
|
|
102
|
+
function onDown(event: PointerEvent) {
|
|
103
|
+
// A leaving card takes no press. Pinning it would end its discard and deal
|
|
104
|
+
// the next card under the finger.
|
|
105
|
+
if (isDiscarding) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
card.setPointerCapture(event.pointerId);
|
|
109
|
+
// Pins the card where it shows, so the drag starts there. Only the
|
|
110
|
+
// position stops, so a card fading in keeps fading in.
|
|
111
|
+
const {x, y, rotate} = animator.get();
|
|
112
|
+
animator.set({x, y, rotate});
|
|
113
|
+
origin = {x: event.clientX - x, y: event.clientY - y};
|
|
114
|
+
samples = [];
|
|
115
|
+
}
|
|
116
|
+
function onMove(event: PointerEvent) {
|
|
117
|
+
if (origin == null) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const x = event.clientX - origin.x;
|
|
121
|
+
const y = event.clientY - origin.y;
|
|
122
|
+
samples.push({t: event.timeStamp, x, y});
|
|
123
|
+
animator.set({x, y, rotate: x / 18});
|
|
124
|
+
}
|
|
125
|
+
// A cancelled pointer was not let go, so the card springs back.
|
|
126
|
+
function onCancel() {
|
|
127
|
+
if (origin == null) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
origin = null;
|
|
131
|
+
void animator.animate({x: 0, y: 0, rotate: 0});
|
|
132
|
+
}
|
|
133
|
+
function onUp(event: PointerEvent) {
|
|
134
|
+
if (origin == null) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
origin = null;
|
|
138
|
+
const recent = samples.filter(s => event.timeStamp - s.t <= 80);
|
|
139
|
+
const first = recent[0];
|
|
140
|
+
const last = recent.at(-1);
|
|
141
|
+
const seconds = last && first ? (last.t - first.t) / 1000 : 0;
|
|
142
|
+
const vx = seconds > 0 && last && first ? (last.x - first.x) / seconds : 0;
|
|
143
|
+
const vy = seconds > 0 && last && first ? (last.y - first.y) / seconds : 0;
|
|
144
|
+
if (Math.abs(vx) > THROW_SPEED) {
|
|
145
|
+
void discard(vx, vy);
|
|
146
|
+
} else {
|
|
147
|
+
void animator.animate(
|
|
148
|
+
{x: 0, y: 0, rotate: 0},
|
|
149
|
+
{velocity: {x: vx, y: vy}},
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// The button moves the card off on the state-change motion: a planned
|
|
154
|
+
// move, which Reduce Motion turns into a fade where the card is.
|
|
155
|
+
async function discardWithButton() {
|
|
156
|
+
if (!startDiscard()) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
await animator.animate({x: 400, opacity: 0});
|
|
160
|
+
await dealNext();
|
|
161
|
+
}
|
|
162
|
+
const onDiscard = () => void discardWithButton();
|
|
163
|
+
|
|
164
|
+
card.addEventListener('pointerdown', onDown);
|
|
165
|
+
card.addEventListener('pointermove', onMove);
|
|
166
|
+
card.addEventListener('pointerup', onUp);
|
|
167
|
+
card.addEventListener('pointercancel', onCancel);
|
|
168
|
+
discardButton.addEventListener('click', onDiscard);
|
|
169
|
+
return () => {
|
|
170
|
+
discardButton.removeEventListener('click', onDiscard);
|
|
171
|
+
animator.destroy();
|
|
172
|
+
card.remove();
|
|
173
|
+
status.remove();
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Mounts the deck when the wrapper attaches, and takes it down when it
|
|
179
|
+
* detaches: its cleanup is the callback ref's.
|
|
180
|
+
*/
|
|
181
|
+
function mountTable(wrapper: HTMLDivElement | null) {
|
|
182
|
+
if (wrapper == null) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
const table = wrapper.firstElementChild as HTMLElement;
|
|
186
|
+
const button = wrapper.querySelector('button') as HTMLButtonElement;
|
|
187
|
+
return mountDeck(table, button);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export default function AnimatorPlayingCardsVanilla() {
|
|
191
|
+
return (
|
|
192
|
+
<div
|
|
193
|
+
ref={mountTable}
|
|
194
|
+
style={{display: 'grid', gap: 16, padding: 16, maxWidth: 360}}>
|
|
195
|
+
<div style={{height: 200, display: 'grid', placeItems: 'center'}} />
|
|
196
|
+
<button type="button">Discard the top card</button>
|
|
197
|
+
</div>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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: 'useAnimator',
|
|
7
|
+
name: 'useAnimator — Playing cards',
|
|
8
|
+
displayName: 'useAnimator — Playing cards',
|
|
9
|
+
description:
|
|
10
|
+
'A playing card that follows a drag: a gentle release springs it back on its release velocity, and a quick flick throws it away with momentum before the next card is dealt. A Discard button moves it off from the keyboard, fading it in place under Reduce Motion, and the discard is announced. Built only on the public useAnimator hook.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 4 / 3,
|
|
13
|
+
componentsUsed: [
|
|
14
|
+
'Card',
|
|
15
|
+
'Button',
|
|
16
|
+
'Layout',
|
|
17
|
+
'Text',
|
|
18
|
+
'VisuallyHidden',
|
|
19
|
+
'useAnimator',
|
|
20
|
+
],
|
|
21
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useRef, useState} from 'react';
|
|
6
|
+
import type {PointerEvent} from 'react';
|
|
7
|
+
import {Button} from '@astryxdesign/core/Button';
|
|
8
|
+
import {Card} from '@astryxdesign/core/Card';
|
|
9
|
+
import {useAnimator} from '@astryxdesign/core/hooks';
|
|
10
|
+
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
11
|
+
import {Text} from '@astryxdesign/core/Text';
|
|
12
|
+
import {VisuallyHidden} from '@astryxdesign/core/VisuallyHidden';
|
|
13
|
+
|
|
14
|
+
const DECK = [
|
|
15
|
+
{rank: 'A', suit: '\u2660', name: 'Ace of spades'},
|
|
16
|
+
{rank: 'K', suit: '\u2665', name: 'King of hearts'},
|
|
17
|
+
{rank: 'Q', suit: '\u2663', name: 'Queen of clubs'},
|
|
18
|
+
{rank: 'J', suit: '\u2666', name: 'Jack of diamonds'},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/** A release faster than this (px/s) throws the card away. */
|
|
22
|
+
const THROW_SPEED = 1000;
|
|
23
|
+
/** The slowest throw, so a thrown card always leaves the table. */
|
|
24
|
+
const MIN_THROW = 1600;
|
|
25
|
+
|
|
26
|
+
interface Sample {
|
|
27
|
+
t: number;
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The release velocity in px/s, over the 80 ms before the release: a finger
|
|
34
|
+
* that held still before letting go releases at rest.
|
|
35
|
+
*/
|
|
36
|
+
function releaseVelocity(
|
|
37
|
+
samples: Sample[],
|
|
38
|
+
releasedAt: number,
|
|
39
|
+
): {x: number; y: number} {
|
|
40
|
+
const recent = samples.filter(s => releasedAt - s.t <= 80);
|
|
41
|
+
const first = recent[0];
|
|
42
|
+
const last = recent.at(-1);
|
|
43
|
+
if (last == null || first == null || last.t === first.t) {
|
|
44
|
+
return {x: 0, y: 0};
|
|
45
|
+
}
|
|
46
|
+
const seconds = (last.t - first.t) / 1000;
|
|
47
|
+
return {x: (last.x - first.x) / seconds, y: (last.y - first.y) / seconds};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default function AnimatorPlayingCards() {
|
|
51
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
52
|
+
const animator = useAnimator(ref);
|
|
53
|
+
const [top, setTop] = useState(0);
|
|
54
|
+
const [status, setStatus] = useState('');
|
|
55
|
+
const drag = useRef<{start: Sample; samples: Sample[]} | null>(null);
|
|
56
|
+
// One discard at a time: a press while a card leaves deals no second card.
|
|
57
|
+
const discarding = useRef(false);
|
|
58
|
+
const card = DECK[top % DECK.length];
|
|
59
|
+
|
|
60
|
+
// Announces the discard and deals the next card in place of the old one.
|
|
61
|
+
const dealNext = async () => {
|
|
62
|
+
setStatus(`${card.name} discarded`);
|
|
63
|
+
setTop(index => index + 1);
|
|
64
|
+
animator.set({x: 0, y: 0, rotate: 0, scale: 0.9, opacity: 0});
|
|
65
|
+
discarding.current = false;
|
|
66
|
+
await animator.animate({scale: 1, opacity: 1});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Starts a discard unless one runs. It also ends a drag in progress: the
|
|
70
|
+
// drag's next move would take the discard's motion over and drag the dealt
|
|
71
|
+
// card.
|
|
72
|
+
const startDiscard = () => {
|
|
73
|
+
if (discarding.current) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
discarding.current = true;
|
|
77
|
+
drag.current = null;
|
|
78
|
+
return true;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Throws the card away on its release velocity, then deals the next one.
|
|
82
|
+
const discard = async (velocity: {x: number; y: number}) => {
|
|
83
|
+
if (!startDiscard()) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const speed = Math.hypot(velocity.x, velocity.y);
|
|
87
|
+
const boost = speed < MIN_THROW ? MIN_THROW / Math.max(speed, 1) : 1;
|
|
88
|
+
const throwX = speed < 1 ? MIN_THROW : velocity.x * boost;
|
|
89
|
+
// The card coasts on while it fades; once it is gone, the next card is
|
|
90
|
+
// dealt in place, which ends the coast. A coast continues the person's
|
|
91
|
+
// throw, so Reduce Motion keeps it.
|
|
92
|
+
void animator.decay({x: throwX, y: velocity.y * boost});
|
|
93
|
+
await animator.animate({opacity: 0});
|
|
94
|
+
await dealNext();
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// The button moves the card off on the state-change motion: a planned
|
|
98
|
+
// move, which Reduce Motion turns into a fade where the card is.
|
|
99
|
+
const discardWithButton = async () => {
|
|
100
|
+
if (!startDiscard()) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
await animator.animate({x: 400, opacity: 0});
|
|
104
|
+
await dealNext();
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const onPointerDown = (event: PointerEvent<HTMLDivElement>) => {
|
|
108
|
+
// A leaving card takes no press. Pinning it would end its discard and deal
|
|
109
|
+
// the next card under the finger.
|
|
110
|
+
if (discarding.current) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
114
|
+
// Pins the card where it shows, so the drag starts there. Only the
|
|
115
|
+
// position stops, so a card fading in keeps fading in.
|
|
116
|
+
const {x, y, rotate} = animator.get();
|
|
117
|
+
animator.set({x, y, rotate});
|
|
118
|
+
const start = {
|
|
119
|
+
t: event.timeStamp,
|
|
120
|
+
x: event.clientX - x,
|
|
121
|
+
y: event.clientY - y,
|
|
122
|
+
};
|
|
123
|
+
drag.current = {start, samples: []};
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const onPointerMove = (event: PointerEvent<HTMLDivElement>) => {
|
|
127
|
+
const current = drag.current;
|
|
128
|
+
if (current == null) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const x = event.clientX - current.start.x;
|
|
132
|
+
const y = event.clientY - current.start.y;
|
|
133
|
+
current.samples.push({t: event.timeStamp, x, y});
|
|
134
|
+
// The card follows the finger, turning a little with the drag.
|
|
135
|
+
animator.set({x, y, rotate: x / 18});
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// A cancelled pointer was not let go, so the card springs back.
|
|
139
|
+
const onPointerCancel = () => {
|
|
140
|
+
if (drag.current == null) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
drag.current = null;
|
|
144
|
+
void animator.animate({x: 0, y: 0, rotate: 0});
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const onPointerUp = (event: PointerEvent<HTMLDivElement>) => {
|
|
148
|
+
const current = drag.current;
|
|
149
|
+
drag.current = null;
|
|
150
|
+
if (current == null) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const velocity = releaseVelocity(current.samples, event.timeStamp);
|
|
154
|
+
if (Math.abs(velocity.x) > THROW_SPEED) {
|
|
155
|
+
void discard(velocity);
|
|
156
|
+
} else {
|
|
157
|
+
// A gentle release springs back, carrying on as it was let go.
|
|
158
|
+
void animator.animate({x: 0, y: 0, rotate: 0}, {velocity});
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<VStack gap={4} style={{maxWidth: 360, padding: 16}}>
|
|
164
|
+
<Text type="body">
|
|
165
|
+
Drag the card and let go. A gentle release springs it back; a quick
|
|
166
|
+
flick throws it away.
|
|
167
|
+
</Text>
|
|
168
|
+
<div style={{height: 200, display: 'grid', placeItems: 'center'}}>
|
|
169
|
+
<Card
|
|
170
|
+
ref={ref}
|
|
171
|
+
width={120}
|
|
172
|
+
minHeight={170}
|
|
173
|
+
onPointerDown={onPointerDown}
|
|
174
|
+
onPointerMove={onPointerMove}
|
|
175
|
+
onPointerUp={onPointerUp}
|
|
176
|
+
onPointerCancel={onPointerCancel}
|
|
177
|
+
style={{touchAction: 'none', cursor: 'grab', userSelect: 'none'}}
|
|
178
|
+
role="img"
|
|
179
|
+
aria-label={card.name}>
|
|
180
|
+
<VStack gap={1} hAlign="center" style={{paddingBlock: 40}}>
|
|
181
|
+
<Text type="display-2" weight="bold">
|
|
182
|
+
{card.rank}
|
|
183
|
+
</Text>
|
|
184
|
+
<Text type="display-3">{card.suit}</Text>
|
|
185
|
+
</VStack>
|
|
186
|
+
</Card>
|
|
187
|
+
</div>
|
|
188
|
+
<HStack gap={2}>
|
|
189
|
+
<Button
|
|
190
|
+
label={`Discard ${card.name}`}
|
|
191
|
+
variant="secondary"
|
|
192
|
+
onClick={() => void discardWithButton()}
|
|
193
|
+
/>
|
|
194
|
+
<Button
|
|
195
|
+
label="Shake"
|
|
196
|
+
variant="ghost"
|
|
197
|
+
onClick={() =>
|
|
198
|
+
void animator.animate(
|
|
199
|
+
{x: 0, rotate: 0},
|
|
200
|
+
{velocity: {x: 900, rotate: 300}},
|
|
201
|
+
)
|
|
202
|
+
}
|
|
203
|
+
/>
|
|
204
|
+
</HStack>
|
|
205
|
+
<VisuallyHidden as="div" aria-live="polite">
|
|
206
|
+
{status}
|
|
207
|
+
</VisuallyHidden>
|
|
208
|
+
</VStack>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
@@ -1874,6 +1874,10 @@ function ComposeWindow({
|
|
|
1874
1874
|
)}
|
|
1875
1875
|
</>
|
|
1876
1876
|
}
|
|
1877
|
+
// The recipient rows read as one header, so all three stay
|
|
1878
|
+
// inline fields on every device; the sheet has no end lane
|
|
1879
|
+
// for the Cc and Bcc buttons.
|
|
1880
|
+
presentation="popover"
|
|
1877
1881
|
/>
|
|
1878
1882
|
{hasCc ? (
|
|
1879
1883
|
<Tokenizer
|
|
@@ -1884,6 +1888,7 @@ function ComposeWindow({
|
|
|
1884
1888
|
value={cc}
|
|
1885
1889
|
onChange={items => setCc(items)}
|
|
1886
1890
|
hasCreate
|
|
1891
|
+
presentation="popover"
|
|
1887
1892
|
/>
|
|
1888
1893
|
) : null}
|
|
1889
1894
|
{hasBcc ? (
|
|
@@ -1895,6 +1900,7 @@ function ComposeWindow({
|
|
|
1895
1900
|
value={bcc}
|
|
1896
1901
|
onChange={items => setBcc(items)}
|
|
1897
1902
|
hasCreate
|
|
1903
|
+
presentation="popover"
|
|
1898
1904
|
/>
|
|
1899
1905
|
) : null}
|
|
1900
1906
|
<TextInput
|
package/assets/theme.template.ts
CHANGED
|
@@ -230,7 +230,8 @@ export const myTheme = defineTheme({
|
|
|
230
230
|
// --border-width hairline thickness shared by bordered surfaces
|
|
231
231
|
// --radius-* none · inner · element · container · page · chat · full
|
|
232
232
|
// --shadow-* low/med/high + inset-{hover,selected,success,warning,error}
|
|
233
|
-
// --duration-* {fast,medium,slow} × {-min, base, -max}
|
|
233
|
+
// --duration-* {fast,medium,slow} × {-min, base, -max} · exit
|
|
234
|
+
// (dismissal; defaults to fast)
|
|
234
235
|
// --ease-* standard (state) · entrance (arriving) · move (on
|
|
235
236
|
// screen) · exit (leaving)
|
|
236
237
|
// --font-family-* body · heading · code
|
|
@@ -219,6 +219,10 @@ export const ComponentDocKindSchema: z.ZodObject<{
|
|
|
219
219
|
playground: z.ZodOptional<z.ZodUnknown>;
|
|
220
220
|
examples: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
221
221
|
replaces: z.ZodOptional<z.ZodString>;
|
|
222
|
+
deprecated: z.ZodOptional<z.ZodObject<{
|
|
223
|
+
replacement: z.ZodString;
|
|
224
|
+
description: z.ZodString;
|
|
225
|
+
}, z.core.$strict>>;
|
|
222
226
|
name: z.ZodString;
|
|
223
227
|
displayName: z.ZodOptional<z.ZodString>;
|
|
224
228
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -750,6 +754,10 @@ export const LegacyDocSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
750
754
|
default: z.ZodOptional<z.ZodString>;
|
|
751
755
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
752
756
|
}, z.core.$loose>>;
|
|
757
|
+
deprecated: z.ZodOptional<z.ZodObject<{
|
|
758
|
+
replacement: z.ZodString;
|
|
759
|
+
description: z.ZodString;
|
|
760
|
+
}, z.core.$strict>>;
|
|
753
761
|
}, z.core.$loose>, z.ZodObject<{
|
|
754
762
|
name: z.ZodString;
|
|
755
763
|
displayName: z.ZodOptional<z.ZodString>;
|
|
@@ -823,6 +831,10 @@ export const LegacyDocSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
823
831
|
}>>;
|
|
824
832
|
stability: z.ZodOptional<z.ZodLiteral<"experimental">>;
|
|
825
833
|
components: z.ZodArray<z.ZodUnknown>;
|
|
834
|
+
deprecated: z.ZodOptional<z.ZodObject<{
|
|
835
|
+
replacement: z.ZodString;
|
|
836
|
+
description: z.ZodString;
|
|
837
|
+
}, z.core.$strict>>;
|
|
826
838
|
}, z.core.$loose>, z.ZodObject<{
|
|
827
839
|
name: z.ZodString;
|
|
828
840
|
displayName: z.ZodOptional<z.ZodString>;
|
|
@@ -860,6 +872,10 @@ export const LegacyDocSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
860
872
|
default: z.ZodOptional<z.ZodString>;
|
|
861
873
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
862
874
|
}, z.core.$loose>>;
|
|
875
|
+
deprecated: z.ZodOptional<z.ZodObject<{
|
|
876
|
+
replacement: z.ZodString;
|
|
877
|
+
description: z.ZodString;
|
|
878
|
+
}, z.core.$strict>>;
|
|
863
879
|
}, z.core.$loose>, z.ZodObject<{
|
|
864
880
|
name: z.ZodString;
|
|
865
881
|
displayName: z.ZodOptional<z.ZodString>;
|
|
@@ -306,6 +306,17 @@ const BaseDocFields = {
|
|
|
306
306
|
isHiddenFromOverview: z.boolean().optional(),
|
|
307
307
|
};
|
|
308
308
|
|
|
309
|
+
/**
|
|
310
|
+
* A deprecated component's replacement (`ComponentBaseDoc.deprecated`). Strict:
|
|
311
|
+
* the docsite and search read both fields, so a misspelled one fails to load.
|
|
312
|
+
*/
|
|
313
|
+
const ComponentDeprecationSchema = z
|
|
314
|
+
.object({
|
|
315
|
+
replacement: nonEmptyString,
|
|
316
|
+
description: nonEmptyString,
|
|
317
|
+
})
|
|
318
|
+
.strict();
|
|
319
|
+
|
|
309
320
|
const ComponentBaseSchema = z
|
|
310
321
|
.object({
|
|
311
322
|
...BaseDocFields,
|
|
@@ -314,6 +325,7 @@ const ComponentBaseSchema = z
|
|
|
314
325
|
playground: z.unknown().optional(),
|
|
315
326
|
examples: z.array(z.unknown()).optional(),
|
|
316
327
|
replaces: z.string().min(1).optional(),
|
|
328
|
+
deprecated: ComponentDeprecationSchema.optional(),
|
|
317
329
|
})
|
|
318
330
|
.passthrough();
|
|
319
331
|
|
|
@@ -776,10 +788,12 @@ const LegacyReferenceDocSchema = LegacyBaseDocSchema.extend({
|
|
|
776
788
|
|
|
777
789
|
const LegacySingleComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
778
790
|
props: z.array(PropSchema),
|
|
791
|
+
deprecated: ComponentDeprecationSchema.optional(),
|
|
779
792
|
}).passthrough();
|
|
780
793
|
|
|
781
794
|
const LegacyMultiComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
782
795
|
components: z.array(z.unknown()),
|
|
796
|
+
deprecated: ComponentDeprecationSchema.optional(),
|
|
783
797
|
}).passthrough();
|
|
784
798
|
|
|
785
799
|
const LegacyHookDocSchema = LegacyBaseDocSchema.extend({
|
|
@@ -791,6 +805,7 @@ const LegacySubComponentDocSchema = LegacyBaseDocSchema.extend({
|
|
|
791
805
|
subComponentOf: z.string().min(1, 'subComponentOf is required'),
|
|
792
806
|
description: z.string(),
|
|
793
807
|
props: z.array(PropSchema),
|
|
808
|
+
deprecated: ComponentDeprecationSchema.optional(),
|
|
794
809
|
}).passthrough();
|
|
795
810
|
|
|
796
811
|
/** The permissive legacy union (sub-component, hook, multi, single, then reference). */
|
|
@@ -58,6 +58,12 @@ export const doc = {
|
|
|
58
58
|
description:
|
|
59
59
|
'Integration components only: the exact `name` of the Core ComponentDoc this component takes over for unqualified lookup, so every app that loads the integration gets it from component detail, component lists, search, `swizzle <Name>`, and issue routing; `swizzle --list` keeps listing Core names. The Core original stays reachable with `--package @astryxdesign/core`. It takes effect only when the package\'s peer range starts at the release that applies it, `"@astryxdesign/cli": ">=0.6.7"` or later; with a lower range nothing changes and `doctor integration components` warns ({@link generic:replace-a-core-component}). Set it only to intentionally own a Core identity; give an alternative or variant its own name instead.',
|
|
60
60
|
},
|
|
61
|
+
{
|
|
62
|
+
name: 'deprecated',
|
|
63
|
+
type: '{replacement: string; description: string}',
|
|
64
|
+
description:
|
|
65
|
+
"Marks a deprecated component: it keeps working and stays documented, labeled with what replaces it. `replacement` is the `name` of the documented component to use instead; `description` is the modernization route in a sentence or two. The docsite shows a Deprecated badge in the component's page header and index tile, labels its search result, and adds a notice that links the replacement; `astryx search` results and `astryx build` kit entries carry the field. Omit it for a component that is not deprecated.",
|
|
66
|
+
},
|
|
61
67
|
{
|
|
62
68
|
name: 'keywords',
|
|
63
69
|
type: 'string[]',
|
|
@@ -21,6 +21,15 @@ import type {
|
|
|
21
21
|
UsageDoc,
|
|
22
22
|
} from '../base/type.js';
|
|
23
23
|
|
|
24
|
+
/** What replaces a deprecated component (`ComponentBaseDoc.deprecated`). */
|
|
25
|
+
export interface ComponentDeprecation {
|
|
26
|
+
/** `name` of the documented component to use instead, e.g. `'BottomSheet'`. */
|
|
27
|
+
replacement: string;
|
|
28
|
+
/** The modernization route in a sentence or two: what to write instead,
|
|
29
|
+
* and where the migration is described. */
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
/**
|
|
25
34
|
* Shared fields between single-component and multi-component docs.
|
|
26
35
|
* Do not use this interface directly — use `ComponentDoc` (the union type).
|
|
@@ -63,6 +72,13 @@ export interface ComponentBaseDoc extends AuthoredDocGraphFields {
|
|
|
63
72
|
* range, and on older CLIs that do not read `replaces`, the component keeps
|
|
64
73
|
* its own name. */
|
|
65
74
|
replaces?: string;
|
|
75
|
+
/** Marks a deprecated component (spec:AST-017 FR26, FR29b): it keeps
|
|
76
|
+
* working and stays documented, labeled with its replacement. The docsite
|
|
77
|
+
* shows a Deprecated badge in its page header and index tile, labels its
|
|
78
|
+
* search result, and adds a notice that links the replacement; `astryx
|
|
79
|
+
* search` results and `astryx build` kit entries carry the field. Omit for
|
|
80
|
+
* a component that is not deprecated. */
|
|
81
|
+
deprecated?: ComponentDeprecation;
|
|
66
82
|
/** Search keywords for CLI discovery. Terms a developer might type when
|
|
67
83
|
* looking for this component: synonyms, related UI concepts, and common
|
|
68
84
|
* names from other design systems (MUI, Chakra, Radix, and others).
|
package/authoring/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
|
21
21
|
import {resultSet, resultSetOf} from '../../../foundation/debug/index.mjs';
|
|
22
22
|
import {
|
|
23
23
|
emit,
|
|
24
|
+
formatDeprecation,
|
|
24
25
|
section,
|
|
25
26
|
text,
|
|
26
27
|
list,
|
|
@@ -172,18 +173,23 @@ export function registerBuild(program) {
|
|
|
172
173
|
'package',
|
|
173
174
|
'domain',
|
|
174
175
|
'displayName',
|
|
176
|
+
'deprecated',
|
|
175
177
|
'score',
|
|
176
178
|
'reason',
|
|
177
179
|
'import',
|
|
178
180
|
'description',
|
|
179
181
|
'command',
|
|
180
182
|
],
|
|
181
|
-
format: {command: formatCliCommand},
|
|
183
|
+
format: {command: formatCliCommand, deprecated: formatDeprecation},
|
|
182
184
|
};
|
|
183
185
|
/** @param {string[]} fields */
|
|
184
186
|
const brief = fields => ({
|
|
185
187
|
fields,
|
|
186
|
-
format: {
|
|
188
|
+
format: {
|
|
189
|
+
command: formatCliCommand,
|
|
190
|
+
description: firstSentence,
|
|
191
|
+
deprecated: formatDeprecation,
|
|
192
|
+
},
|
|
187
193
|
});
|
|
188
194
|
// Blocks and components are extras: the text names the top few, and
|
|
189
195
|
// says how many more the JSON and --verbose carry.
|
|
@@ -277,7 +283,7 @@ export function registerBuild(program) {
|
|
|
277
283
|
? [
|
|
278
284
|
records(
|
|
279
285
|
shown(domain),
|
|
280
|
-
verbose ? full : brief(['name', 'package', 'description']),
|
|
286
|
+
verbose ? full : brief(['name', 'package', 'deprecated', 'description']),
|
|
281
287
|
),
|
|
282
288
|
]
|
|
283
289
|
: []),
|