@astryxdesign/cli 0.7.9-canary.7cda408 → 0.7.9-canary.7d6481e

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.
Files changed (42) hide show
  1. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  2. package/api/search/_candidate-score.mjs +25 -23
  3. package/api/search/_main-searcher.mjs +1 -1
  4. package/api/search/_words.d.mts +44 -7
  5. package/api/search/_words.mjs +113 -21
  6. package/api/swizzle/_adapter.d.mts +10 -0
  7. package/api/swizzle/_adapter.mjs +24 -1
  8. package/api/swizzle/copy/copy.mjs +9 -4
  9. package/api/theme/build/build.mjs +21 -1
  10. package/assets/discover/official-packages.json +4 -0
  11. package/assets/docs/tree/calendar-systems.doc.mjs +146 -0
  12. package/assets/docs/tree/calendars.doc.mjs +46 -0
  13. package/assets/docs/tree/i18n-calendars.doc.mjs +51 -0
  14. package/assets/docs/tree/internationalization.doc.mjs +3 -3
  15. package/assets/templates/blocks/components/Icon/useIconHookUsage.doc.mjs +19 -0
  16. package/assets/templates/blocks/components/Icon/useIconHookUsage.tsx +68 -0
  17. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.doc.mjs +2 -1
  18. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +2 -2
  19. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +0 -1
  20. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +0 -1
  21. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.doc.mjs +2 -1
  22. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +0 -2
  23. package/assets/templates/blocks/components/createPanGesture/PanPlayingCardVanilla.doc.mjs +14 -0
  24. package/assets/templates/blocks/components/createPanGesture/PanPlayingCardVanilla.tsx +156 -0
  25. package/assets/templates/blocks/components/usePanGesture/PanPlayingCard.doc.mjs +14 -0
  26. package/assets/templates/blocks/components/usePanGesture/PanPlayingCard.tsx +143 -0
  27. package/assets/templates/pages/table-inbox/page.tsx +11 -8
  28. package/assets/templates/pages/work-item-detail/page.tsx +6 -2
  29. package/clients/cli/commands/ensure-core-built.mjs +399 -43
  30. package/foundation/config/project.mjs +27 -9
  31. package/foundation/discovery/component-discovery.mjs +56 -10
  32. package/foundation/env/search-path.d.mts +12 -0
  33. package/foundation/env/search-path.mjs +71 -43
  34. package/foundation/integrations/manifest-writer.d.mts +3 -4
  35. package/foundation/integrations/manifest-writer.mjs +5 -3
  36. package/foundation/release/cache.d.mts +11 -4
  37. package/foundation/release/cache.mjs +15 -7
  38. package/foundation/text/levenshtein.d.mts +4 -1
  39. package/foundation/text/levenshtein.mjs +44 -1
  40. package/package.json +9 -9
  41. package/api/swizzle/_github.d.mts +0 -8
  42. package/api/swizzle/_github.mjs +0 -22
@@ -0,0 +1,143 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useRef, useState} from 'react';
6
+ import {flushSync} from 'react-dom';
7
+ import {usePanGesture} from '@astryxdesign/core/hooks';
8
+
9
+ const DECK = [
10
+ {face: 'A\u2660', name: 'Ace of spades'},
11
+ {face: 'K\u2665', name: 'King of hearts'},
12
+ {face: 'Q\u2663', name: 'Queen of clubs'},
13
+ {face: 'J\u2666', name: 'Jack of diamonds'},
14
+ ];
15
+ /** A release faster than this (px/s) throws the card away. */
16
+ const THROW_SPEED = 1000;
17
+ /** How far a thrown card travels before the next one is dealt, px. */
18
+ const THROW_DISTANCE = 480;
19
+ const SETTLE = 'translate 300ms cubic-bezier(0.2, 0.9, 0.3, 1.2)';
20
+ const THROW = 'translate 250ms ease-in, opacity 250ms ease-in';
21
+
22
+ export default function PanPlayingCard() {
23
+ const card = useRef<HTMLDivElement>(null);
24
+ const [top, setTop] = useState(0);
25
+ const [announcement, setAnnouncement] = useState('');
26
+ /** A throw is in flight: the next card is dealt when it ends. */
27
+ const throwing = useRef(false);
28
+ /** The drag in progress met a throw: the rest of it moves nothing. */
29
+ const ignoringDrag = useRef(false);
30
+
31
+ /** Move the card, with a transition unless the person reduces motion. */
32
+ function moveTo(x: number, y: number, transition: string) {
33
+ const element = card.current;
34
+ if (element == null) {
35
+ return;
36
+ }
37
+ const reduced = window.matchMedia(
38
+ '(prefers-reduced-motion: reduce)',
39
+ ).matches;
40
+ element.style.transition = reduced ? 'none' : transition;
41
+ element.style.translate = `${x}px ${y}px`;
42
+ }
43
+
44
+ function discard(direction: number) {
45
+ const element = card.current;
46
+ // One throw at a time: a second Discard during it would deal twice.
47
+ if (element == null || throwing.current) {
48
+ return;
49
+ }
50
+ throwing.current = true;
51
+ // The drag in progress, if any, moves nothing more.
52
+ ignoringDrag.current = true;
53
+ moveTo(direction * THROW_DISTANCE, 0, THROW);
54
+ element.style.opacity = '0';
55
+ const deal = () => {
56
+ throwing.current = false;
57
+ // Commit the next card's face first. A reset before that paints the
58
+ // discarded card back at the centre for one frame.
59
+ flushSync(() => {
60
+ setAnnouncement(`${DECK[top % DECK.length].name} discarded`);
61
+ setTop(value => value + 1);
62
+ });
63
+ moveTo(0, 0, 'none');
64
+ element.style.opacity = '1';
65
+ };
66
+ if (element.style.transition === 'none') {
67
+ deal();
68
+ } else {
69
+ element.addEventListener('transitionend', deal, {once: true});
70
+ }
71
+ }
72
+
73
+ // The drag writes the card's style in onPan: no render per move.
74
+ usePanGesture(card, {
75
+ onPan: ({state, translation, velocity}) => {
76
+ // A drag that meets a throw is ignored to its end. Its moves would
77
+ // cancel the throw's transitions, and the next card would jump to it.
78
+ if (state === 'began') {
79
+ ignoringDrag.current = throwing.current;
80
+ }
81
+ if (ignoringDrag.current) {
82
+ return;
83
+ }
84
+ if (state === 'began' || state === 'changed') {
85
+ moveTo(translation.x, translation.y, 'none');
86
+ } else if (state === 'ended' && Math.abs(velocity.x) > THROW_SPEED) {
87
+ discard(Math.sign(velocity.x));
88
+ } else {
89
+ moveTo(0, 0, SETTLE);
90
+ }
91
+ },
92
+ });
93
+
94
+ return (
95
+ <div style={{display: 'grid', gap: 16, padding: 16, maxWidth: 360}}>
96
+ <div
97
+ style={{
98
+ height: 200,
99
+ display: 'grid',
100
+ placeItems: 'center',
101
+ overflow: 'hidden',
102
+ }}>
103
+ <div
104
+ ref={card}
105
+ // An image's name is all a screen reader announces, so it names the
106
+ // card.
107
+ role="img"
108
+ aria-label={DECK[top % DECK.length].name}
109
+ style={{
110
+ width: 120,
111
+ height: 170,
112
+ display: 'grid',
113
+ placeItems: 'center',
114
+ font: 'bold 40px system-ui, sans-serif',
115
+ borderRadius: 12,
116
+ backgroundColor: 'var(--color-background-surface)',
117
+ color: 'var(--color-text-primary)',
118
+ boxShadow: '0 2px 8px rgb(0 0 0 / 0.2)',
119
+ cursor: 'grab',
120
+ userSelect: 'none',
121
+ }}>
122
+ {DECK[top % DECK.length].face}
123
+ </div>
124
+ </div>
125
+ {/* The drag's keyboard and assistive-technology path (WCAG 2.5.7). */}
126
+ <button type="button" onClick={() => discard(1)}>
127
+ Discard the top card
128
+ </button>
129
+ <div
130
+ aria-live="polite"
131
+ style={{
132
+ position: 'absolute',
133
+ width: 1,
134
+ height: 1,
135
+ overflow: 'hidden',
136
+ clipPath: 'inset(50%)',
137
+ whiteSpace: 'nowrap',
138
+ }}>
139
+ {announcement}
140
+ </div>
141
+ </div>
142
+ );
143
+ }
@@ -82,6 +82,7 @@ import {
82
82
  StackItem,
83
83
  VStack,
84
84
  } from '@astryxdesign/core/Layout';
85
+ import {rtlStyles} from '@astryxdesign/core/utils';
85
86
  import {
86
87
  durationVars,
87
88
  easeVars,
@@ -1391,7 +1392,13 @@ function ConversationPane({
1391
1392
  <Button
1392
1393
  label="Inbox"
1393
1394
  variant="ghost"
1394
- icon={<Icon icon={ArrowLeftIcon} size="sm" />}
1395
+ icon={
1396
+ <Icon
1397
+ icon={ArrowLeftIcon}
1398
+ size="sm"
1399
+ xstyle={rtlStyles.mirror}
1400
+ />
1401
+ }
1395
1402
  onClick={onClose}
1396
1403
  />
1397
1404
  }
@@ -1840,7 +1847,9 @@ function ComposeWindow({
1840
1847
  // than being rejected for not matching anything.
1841
1848
  hasCreate
1842
1849
  // Stamps data-autofocus, which is what the sheet looks for
1843
- // once the window is actually visible.
1850
+ // once the window is actually visible. It applies to the
1851
+ // inline field: on a compact touch screen the field opens
1852
+ // its own sheet and ignores it.
1844
1853
  //
1845
1854
  // Deliberately without `hasEntriesOnFocus`: the two together
1846
1855
  // mean the window can never open without the full directory
@@ -1874,10 +1883,6 @@ function ComposeWindow({
1874
1883
  )}
1875
1884
  </>
1876
1885
  }
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"
1881
1886
  />
1882
1887
  {hasCc ? (
1883
1888
  <Tokenizer
@@ -1888,7 +1893,6 @@ function ComposeWindow({
1888
1893
  value={cc}
1889
1894
  onChange={items => setCc(items)}
1890
1895
  hasCreate
1891
- presentation="popover"
1892
1896
  />
1893
1897
  ) : null}
1894
1898
  {hasBcc ? (
@@ -1900,7 +1904,6 @@ function ComposeWindow({
1900
1904
  value={bcc}
1901
1905
  onChange={items => setBcc(items)}
1902
1906
  hasCreate
1903
- presentation="popover"
1904
1907
  />
1905
1908
  ) : null}
1906
1909
  <TextInput
@@ -29,6 +29,7 @@ import {MoreMenu} from '@astryxdesign/core/MoreMenu';
29
29
  import type {DropdownMenuOption} from '@astryxdesign/core/DropdownMenu';
30
30
  import {Link} from '@astryxdesign/core/Link';
31
31
  import {Icon} from '@astryxdesign/core/Icon';
32
+ import {rtlStyles} from '@astryxdesign/core/utils';
32
33
  import {AspectRatio} from '@astryxdesign/core/AspectRatio';
33
34
  import {Divider} from '@astryxdesign/core/Divider';
34
35
  import {StatusDot} from '@astryxdesign/core/StatusDot';
@@ -381,7 +382,11 @@ function PageHeader({
381
382
  <HStack gap={4} vAlign="center" wrap="wrap">
382
383
  <Link href="#" type="supporting" color="secondary">
383
384
  <HStack as="span" gap={1} vAlign="center">
384
- <Icon icon={ArrowLeftIcon} size="sm" />
385
+ <Icon
386
+ icon={ArrowLeftIcon}
387
+ size="sm"
388
+ xstyle={rtlStyles.mirror}
389
+ />
385
390
  All Tasks
386
391
  </HStack>
387
392
  </Link>
@@ -463,7 +468,6 @@ function PageHeader({
463
468
  onRemove={onRemove}
464
469
  />
465
470
  )}
466
- presentation="popover"
467
471
  />
468
472
  </HStack>
469
473
  </VStack>