@astryxdesign/core 0.5.2-canary.c9c8564 → 0.5.2-canary.e4f8e4e
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/dist/BottomSheet/BottomSheet.d.ts +3 -1
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +4 -3
- package/dist/BottomSheet/BottomSheetEdgeTint.d.ts +2 -2
- package/dist/BottomSheet/BottomSheetEdgeTint.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetEdgeTint.js +7 -10
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetSwitcher.js +1 -1
- package/dist/Button/Button.d.ts +2 -1
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +11 -4
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +2 -2
- package/dist/Chat/ChatToolCalls.d.ts.map +1 -1
- package/dist/Chat/ChatToolCalls.js +34 -17
- package/dist/ContextMenu/ContextMenu.d.ts +14 -3
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +149 -26
- package/dist/ContextMenu/index.d.ts +1 -0
- package/dist/ContextMenu/index.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.d.ts +24 -5
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +340 -26
- package/dist/DropdownMenu/DropdownMenuContext.d.ts +1 -1
- package/dist/DropdownMenu/DropdownMenuContext.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuItem.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuItem.js +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts +6 -2
- package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +43 -14
- package/dist/DropdownMenu/MenuBottomSheet.d.ts +20 -0
- package/dist/DropdownMenu/MenuBottomSheet.d.ts.map +1 -0
- package/dist/DropdownMenu/MenuBottomSheet.js +36 -0
- package/dist/DropdownMenu/MenuBottomSheetActionList.d.ts +10 -0
- package/dist/DropdownMenu/MenuBottomSheetActionList.d.ts.map +1 -0
- package/dist/DropdownMenu/MenuBottomSheetActionList.js +111 -0
- package/dist/DropdownMenu/index.d.ts +2 -1
- package/dist/DropdownMenu/index.d.ts.map +1 -1
- package/dist/DropdownMenu/menuWidth.d.ts +14 -0
- package/dist/DropdownMenu/menuWidth.d.ts.map +1 -0
- package/dist/DropdownMenu/menuWidth.js +35 -0
- package/dist/DropdownMenu/useMenuOverflow.d.ts +10 -0
- package/dist/DropdownMenu/useMenuOverflow.d.ts.map +1 -0
- package/dist/DropdownMenu/useMenuOverflow.js +60 -0
- package/dist/MoreMenu/MoreMenu.d.ts +8 -2
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +2 -0
- package/dist/MultiSelector/MultiSelector.d.ts +11 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +97 -68
- package/dist/MultiSelector/index.d.ts +1 -1
- package/dist/MultiSelector/index.d.ts.map +1 -1
- package/dist/Popover/Popover.d.ts +10 -6
- package/dist/Popover/Popover.d.ts.map +1 -1
- package/dist/Popover/Popover.js +141 -16
- package/dist/Popover/usePopover.d.ts +4 -0
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +52 -5
- package/dist/Selector/Selector.d.ts +10 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +106 -80
- package/dist/Selector/SelectorBottomSheet.d.ts +21 -0
- package/dist/Selector/SelectorBottomSheet.d.ts.map +1 -0
- package/dist/Selector/SelectorBottomSheet.js +83 -0
- package/dist/Selector/index.d.ts +1 -1
- package/dist/Selector/index.d.ts.map +1 -1
- package/dist/Selector/selectorPresentation.stylex.d.ts +16 -0
- package/dist/Selector/selectorPresentation.stylex.d.ts.map +1 -0
- package/dist/Selector/selectorPresentation.stylex.js +21 -0
- package/dist/Selector/useSelectorPresentation.d.ts +32 -0
- package/dist/Selector/useSelectorPresentation.d.ts.map +1 -0
- package/dist/Selector/useSelectorPresentation.js +90 -0
- package/dist/Toast/useToastGesture.d.ts.map +1 -1
- package/dist/Toast/useToastGesture.js +46 -9
- package/dist/astryx.css +19 -1
- package/dist/hooks/useAdaptivePresentation.d.ts +5 -0
- package/dist/hooks/useAdaptivePresentation.d.ts.map +1 -0
- package/dist/hooks/useAdaptivePresentation.js +19 -0
- package/dist/hooks/useFocusReturnVisibility.d.ts +7 -0
- package/dist/hooks/useFocusReturnVisibility.d.ts.map +1 -0
- package/dist/hooks/useFocusReturnVisibility.js +35 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +12 -0
- package/locales/en.json +20 -0
- package/locales/pseudo.json +15 -0
- package/package.json +2 -2
- package/src/BottomSheet/BottomSheet.doc.mjs +6 -0
- package/src/BottomSheet/BottomSheet.test.tsx +29 -0
- package/src/BottomSheet/BottomSheet.tsx +7 -4
- package/src/BottomSheet/BottomSheetEdgeTint.test.tsx +4 -6
- package/src/BottomSheet/BottomSheetEdgeTint.tsx +7 -10
- package/src/BottomSheet/BottomSheetSwitcher.tsx +1 -2
- package/src/Button/Button.doc.mjs +56 -0
- package/src/Button/Button.test.tsx +10 -0
- package/src/Button/Button.tsx +13 -5
- package/src/ButtonGroup/ButtonGroup.doc.mjs +47 -0
- package/src/Carousel/Carousel.test.tsx +83 -0
- package/src/Carousel/Carousel.tsx +8 -2
- package/src/Chat/ChatToolCalls.test.tsx +44 -0
- package/src/Chat/ChatToolCalls.tsx +36 -15
- package/src/ContextMenu/ContextMenu.doc.mjs +13 -1
- package/src/ContextMenu/ContextMenu.test.tsx +131 -1
- package/src/ContextMenu/ContextMenu.tsx +199 -32
- package/src/ContextMenu/index.ts +1 -0
- package/src/DropdownMenu/DropdownMenu.doc.mjs +201 -40
- package/src/DropdownMenu/DropdownMenu.test.tsx +518 -7
- package/src/DropdownMenu/DropdownMenu.tsx +459 -28
- package/src/DropdownMenu/DropdownMenuContext.tsx +1 -1
- package/src/DropdownMenu/DropdownMenuItem.tsx +2 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.doc.mjs +4 -2
- package/src/DropdownMenu/DropdownMenuSubMenu.test.tsx +124 -0
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +72 -17
- package/src/DropdownMenu/MenuBottomSheet.tsx +46 -0
- package/src/DropdownMenu/MenuBottomSheetActionList.tsx +141 -0
- package/src/DropdownMenu/index.ts +2 -0
- package/src/DropdownMenu/menuWidth.ts +51 -0
- package/src/DropdownMenu/useMenuOverflow.ts +77 -0
- package/src/IconButton/IconButton.doc.mjs +38 -0
- package/src/MoreMenu/MoreMenu.doc.mjs +17 -0
- package/src/MoreMenu/MoreMenu.test.tsx +47 -0
- package/src/MoreMenu/MoreMenu.tsx +13 -1
- package/src/MultiSelector/MultiSelector.doc.mjs +16 -0
- package/src/MultiSelector/MultiSelector.test.tsx +127 -0
- package/src/MultiSelector/MultiSelector.tsx +121 -73
- package/src/MultiSelector/index.ts +1 -0
- package/src/Popover/Popover.doc.mjs +11 -11
- package/src/Popover/Popover.test.tsx +397 -2
- package/src/Popover/Popover.tsx +228 -21
- package/src/Popover/usePopover.tsx +92 -15
- package/src/ProgressBar/ProgressBar.spec.md +208 -0
- package/src/SegmentedControl/SegmentedControl.doc.mjs +56 -0
- package/src/Selector/Selector.doc.mjs +12 -0
- package/src/Selector/Selector.test.tsx +135 -0
- package/src/Selector/Selector.tsx +141 -82
- package/src/Selector/SelectorBottomSheet.tsx +97 -0
- package/src/Selector/index.ts +1 -0
- package/src/Selector/selectorPresentation.stylex.ts +20 -0
- package/src/Selector/useSelectorPresentation.ts +147 -0
- package/src/Toast/ToastViewport.test.tsx +118 -4
- package/src/Toast/useToastGesture.ts +61 -8
- package/src/ToggleButton/ToggleButton.doc.mjs +56 -0
- package/src/hooks/useAdaptivePresentation.ts +35 -0
- package/src/hooks/useFocusReturnVisibility.ts +45 -0
- package/src/hooks/useFocusTrap.test.tsx +40 -0
- package/src/hooks/useFocusTrap.ts +13 -0
- package/src/theme/themingTargets.test.ts +91 -25
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
4
4
|
/**
|
|
5
5
|
* @file Guards `theming.targets` against the real `themeProps()` call sites (#3741).
|
|
6
|
-
* @input
|
|
7
|
-
*
|
|
6
|
+
* @input Core/Lab component sources (*.tsx/*.ts), their `{Name}.doc.mjs`
|
|
7
|
+
* files, and the Lab promotion-candidate manifest.
|
|
8
|
+
* @output Vitest failures naming each undocumented class / visual prop on the
|
|
9
|
+
* stable Core surface or a capability-participating Lab component.
|
|
8
10
|
* @position Sibling of derivedVarRegistry.test.ts, which already validates the
|
|
9
11
|
* OTHER fields of the same `theming` block (`vars`, `derived`). `targets` was
|
|
10
12
|
* the one field with no machine check, so it drifted — twice (#3652, #3680).
|
|
@@ -22,6 +24,11 @@
|
|
|
22
24
|
* `visualProps` or `states`. Docs may list MORE than the source passes —
|
|
23
25
|
* components forward props they don't themselves reflect (Timestamp passes
|
|
24
26
|
* `{format}` but documents `type`/`color`/`format`), and that is intentional.
|
|
27
|
+
*
|
|
28
|
+
* Lab is capability-based: a component participates when it already declares
|
|
29
|
+
* `theming.targets` or enters the existing promotion-candidate manifest. Other
|
|
30
|
+
* Lab components remain free to iterate with runtime hooks that are not yet a
|
|
31
|
+
* documented public theming promise.
|
|
25
32
|
*/
|
|
26
33
|
|
|
27
34
|
import {describe, it, expect} from 'vitest';
|
|
@@ -30,7 +37,23 @@ import {join, relative} from 'node:path';
|
|
|
30
37
|
import ts from 'typescript';
|
|
31
38
|
import {stableClassName} from '../naming';
|
|
32
39
|
|
|
33
|
-
const
|
|
40
|
+
const CORE_SRC_DIR = join(__dirname, '..');
|
|
41
|
+
const LAB_SRC_DIR = join(__dirname, '../../../lab/src');
|
|
42
|
+
const LAB_PROMOTION_MANIFEST = join(
|
|
43
|
+
__dirname,
|
|
44
|
+
'../../../../internal/lab-readiness/manifest.mjs',
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
interface LabPromotionCandidate {
|
|
48
|
+
sourceDir: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const {CANDIDATES: labPromotionCandidates} = require(
|
|
52
|
+
LAB_PROMOTION_MANIFEST,
|
|
53
|
+
) as {CANDIDATES: LabPromotionCandidate[]};
|
|
54
|
+
const LAB_PROMOTION_DIRS = new Set(
|
|
55
|
+
labPromotionCandidates.map(candidate => candidate.sourceDir),
|
|
56
|
+
);
|
|
34
57
|
|
|
35
58
|
// ---------------------------------------------------------------------------
|
|
36
59
|
// Source scanning: find themeProps() call sites via the TypeScript AST
|
|
@@ -314,6 +337,7 @@ type DocBlock = {theming?: {targets?: DocTarget[]}};
|
|
|
314
337
|
type ComponentDocModule = {docs?: DocBlock; docsZh?: DocBlock};
|
|
315
338
|
|
|
316
339
|
interface ComponentInfo {
|
|
340
|
+
packageName: 'core' | 'lab';
|
|
317
341
|
dir: string;
|
|
318
342
|
sites: ThemeTargetSite[];
|
|
319
343
|
/** The doc blocks that carry theming.targets, by the key they live under. */
|
|
@@ -328,7 +352,10 @@ interface ComponentInfo {
|
|
|
328
352
|
* Reads the file as text rather than requiring it: this runs for directories
|
|
329
353
|
* that have no doc of their own, so most candidates are misses.
|
|
330
354
|
*/
|
|
331
|
-
function docFilesDocumenting(
|
|
355
|
+
function docFilesDocumenting(
|
|
356
|
+
srcDir: string,
|
|
357
|
+
classNames: Set<string>,
|
|
358
|
+
): string[] {
|
|
332
359
|
const matches: string[] = [];
|
|
333
360
|
const walk = (dir: string): void => {
|
|
334
361
|
for (const entry of readdirSync(dir, {withFileTypes: true})) {
|
|
@@ -346,18 +373,22 @@ function docFilesDocumenting(classNames: Set<string>): string[] {
|
|
|
346
373
|
}
|
|
347
374
|
}
|
|
348
375
|
};
|
|
349
|
-
walk(
|
|
376
|
+
walk(srcDir);
|
|
350
377
|
return matches;
|
|
351
378
|
}
|
|
352
379
|
|
|
353
|
-
function discoverComponents(
|
|
380
|
+
function discoverComponents(
|
|
381
|
+
srcDir: string,
|
|
382
|
+
packageName: ComponentInfo['packageName'],
|
|
383
|
+
requiredDirs: ReadonlySet<string> = new Set(),
|
|
384
|
+
): ComponentInfo[] {
|
|
354
385
|
const results: ComponentInfo[] = [];
|
|
355
|
-
const dirs = readdirSync(
|
|
386
|
+
const dirs = readdirSync(srcDir, {withFileTypes: true})
|
|
356
387
|
.filter(d => d.isDirectory())
|
|
357
388
|
.map(d => d.name);
|
|
358
389
|
|
|
359
390
|
for (const dir of dirs) {
|
|
360
|
-
const dirPath = join(
|
|
391
|
+
const dirPath = join(srcDir, dir);
|
|
361
392
|
const dirEntries = readdirSync(dirPath);
|
|
362
393
|
|
|
363
394
|
const sourceFiles = dirEntries.filter(
|
|
@@ -389,10 +420,7 @@ function discoverComponents(): ComponentInfo[] {
|
|
|
389
420
|
// doc file that CI never checks. (Same guard as derivedVarRegistry.test.ts.)
|
|
390
421
|
const docFiles = dirEntries.includes(`${dir}.doc.mjs`)
|
|
391
422
|
? [join(dirPath, `${dir}.doc.mjs`)]
|
|
392
|
-
: docFilesDocumenting(new Set(sites.map(s => s.className)));
|
|
393
|
-
if (docFiles.length === 0) {
|
|
394
|
-
continue;
|
|
395
|
-
}
|
|
423
|
+
: docFilesDocumenting(srcDir, new Set(sites.map(s => s.className)));
|
|
396
424
|
|
|
397
425
|
const docBlocks: ComponentInfo['docBlocks'] = [];
|
|
398
426
|
for (const docFile of docFiles) {
|
|
@@ -404,18 +432,23 @@ function discoverComponents(): ComponentInfo[] {
|
|
|
404
432
|
}
|
|
405
433
|
for (const key of ['docs', 'docsZh'] as const) {
|
|
406
434
|
const targets = mod[key]?.theming?.targets;
|
|
407
|
-
//
|
|
408
|
-
//
|
|
435
|
+
// A normal Core or Lab component enrolls by declaring a theming
|
|
436
|
+
// surface. Promotion candidates are also enrolled here so a missing
|
|
437
|
+
// block is a failure rather than a silently skipped readiness gap.
|
|
409
438
|
if (targets != null) {
|
|
410
|
-
docBlocks.push({key, file: relative(
|
|
439
|
+
docBlocks.push({key, file: relative(srcDir, docFile), targets});
|
|
411
440
|
}
|
|
412
441
|
}
|
|
413
442
|
}
|
|
414
|
-
|
|
443
|
+
const participates =
|
|
444
|
+
packageName === 'core'
|
|
445
|
+
? docBlocks.length > 0
|
|
446
|
+
: requiredDirs.has(dir) || docBlocks.length > 0;
|
|
447
|
+
if (!participates) {
|
|
415
448
|
continue;
|
|
416
449
|
}
|
|
417
450
|
|
|
418
|
-
results.push({dir, sites, docBlocks});
|
|
451
|
+
results.push({packageName, dir, sites, docBlocks});
|
|
419
452
|
}
|
|
420
453
|
return results;
|
|
421
454
|
}
|
|
@@ -425,24 +458,57 @@ function discoverComponents(): ComponentInfo[] {
|
|
|
425
458
|
// ---------------------------------------------------------------------------
|
|
426
459
|
|
|
427
460
|
describe('theming.targets matches the themeProps() call sites', () => {
|
|
428
|
-
const components =
|
|
461
|
+
const components = [
|
|
462
|
+
...discoverComponents(CORE_SRC_DIR, 'core'),
|
|
463
|
+
...discoverComponents(LAB_SRC_DIR, 'lab', LAB_PROMOTION_DIRS),
|
|
464
|
+
];
|
|
465
|
+
|
|
466
|
+
it('finds participating Core and Lab components', () => {
|
|
467
|
+
// A refactor that renames themeProps or drops the Lab package from this
|
|
468
|
+
// inventory must not silently disable either side of the guard.
|
|
469
|
+
expect(components.some(component => component.packageName === 'core')).toBe(
|
|
470
|
+
true,
|
|
471
|
+
);
|
|
472
|
+
expect(components.some(component => component.packageName === 'lab')).toBe(
|
|
473
|
+
true,
|
|
474
|
+
);
|
|
475
|
+
});
|
|
429
476
|
|
|
430
|
-
it('
|
|
431
|
-
|
|
432
|
-
|
|
477
|
+
it('enrolls every Lab promotion candidate and explicit theming capability', () => {
|
|
478
|
+
const labDirs = new Set(
|
|
479
|
+
components
|
|
480
|
+
.filter(component => component.packageName === 'lab')
|
|
481
|
+
.map(component => component.dir),
|
|
482
|
+
);
|
|
483
|
+
expect([...LAB_PROMOTION_DIRS].filter(dir => !labDirs.has(dir))).toEqual(
|
|
484
|
+
[],
|
|
485
|
+
);
|
|
486
|
+
expect(LAB_PROMOTION_DIRS.has('CircularProgress')).toBe(false);
|
|
487
|
+
expect(labDirs.has('CircularProgress')).toBe(true);
|
|
488
|
+
expect(labDirs.has('Schedule')).toBe(false);
|
|
433
489
|
});
|
|
434
490
|
|
|
435
|
-
for (const {dir, sites, docBlocks} of components) {
|
|
491
|
+
for (const {packageName, dir, sites, docBlocks} of components) {
|
|
492
|
+
const componentLabel = `${packageName}/${dir}`;
|
|
436
493
|
const renderedClasses = [...new Set(sites.map(s => s.className))].sort();
|
|
437
494
|
|
|
495
|
+
it(`${componentLabel}: participating components declare theming metadata`, () => {
|
|
496
|
+
expect(
|
|
497
|
+
docBlocks,
|
|
498
|
+
`${componentLabel} participates in the public theming contract but has ` +
|
|
499
|
+
`no loadable .doc.mjs theming.targets. Lab components participate ` +
|
|
500
|
+
`when they declare theming.targets or enter the promotion manifest.`,
|
|
501
|
+
).not.toHaveLength(0);
|
|
502
|
+
});
|
|
503
|
+
|
|
438
504
|
for (const {key, file, targets} of docBlocks) {
|
|
439
505
|
const documented = new Set(targets.map(t => t.className));
|
|
440
506
|
|
|
441
|
-
it(`${
|
|
507
|
+
it(`${componentLabel} (${file} ${key}): every rendered class is documented`, () => {
|
|
442
508
|
const undocumented = renderedClasses.filter(c => !documented.has(c));
|
|
443
509
|
expect(
|
|
444
510
|
undocumented,
|
|
445
|
-
`${
|
|
511
|
+
`${componentLabel} renders ${undocumented.length} astryx-* class(es) that ` +
|
|
446
512
|
`${file} ${key}.theming.targets does not document: ` +
|
|
447
513
|
`${undocumented.join(', ')}. An undocumented class is an ` +
|
|
448
514
|
`unthemeable element — theme authors and codegen read targets[] ` +
|
|
@@ -450,7 +516,7 @@ describe('theming.targets matches the themeProps() call sites', () => {
|
|
|
450
516
|
).toEqual([]);
|
|
451
517
|
});
|
|
452
518
|
|
|
453
|
-
it(`${
|
|
519
|
+
it(`${componentLabel} (${file} ${key}): every visual prop passed to themeProps is documented`, () => {
|
|
454
520
|
const missing: string[] = [];
|
|
455
521
|
for (const site of sites) {
|
|
456
522
|
const target = targets.find(t => t.className === site.className);
|