@astryxdesign/cli 0.7.9-canary.d7a7dd3 → 0.7.9-canary.db3451e
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/api/component/__fixtures__/resolutions/modules.txt +2 -2
- package/api/theme/build/build.mjs +85 -35
- package/api/theme/build/core-interception.mjs +92 -29
- package/assets/templates/blocks/components/Calendar/useCalendarDaysHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Calendar/useCalendarDaysHookUsage.tsx +71 -0
- package/assets/templates/blocks/components/Overlay/useOverlayHookUsage.doc.mjs +21 -0
- package/assets/templates/blocks/components/Overlay/useOverlayHookUsage.tsx +49 -0
- package/package.json +9 -9
|
@@ -249,7 +249,7 @@ useBackdropPress useBackdropPress Layer/Layer.doc.mjs Layer/useBackdropPress.ts
|
|
|
249
249
|
useBaseTablePlugins useBaseTablePlugins Table/Table.doc.mjs Table/useBaseTablePlugins.ts
|
|
250
250
|
useBusyAnnouncement useBusyAnnouncement hooks/useAnimatedLayout.doc.mjs hooks/useBusyAnnouncement.ts
|
|
251
251
|
useCalendarConstraints useCalendarConstraints Calendar/Calendar.doc.mjs Calendar/hooks/useCalendarConstraints.ts
|
|
252
|
-
useCalendarDays useCalendarDays Calendar/
|
|
252
|
+
useCalendarDays useCalendarDays Calendar/useCalendarDays.doc.mjs Calendar/hooks/useCalendarDays.ts
|
|
253
253
|
useCalendarNavigation useCalendarNavigation Calendar/Calendar.doc.mjs Calendar/hooks/useCalendarNavigation.ts
|
|
254
254
|
useChatComposerTokens useChatComposerTokens Chat/Chat.doc.mjs Chat/useChatComposerTokens.ts
|
|
255
255
|
useChatDictation useChatDictation Chat/Chat.doc.mjs Chat/useChatDictation.ts
|
|
@@ -279,7 +279,7 @@ useMenuHover useMenuHover hooks/useAnimatedLayout.doc.mjs hooks/useMenuHover.ts
|
|
|
279
279
|
useMenuOverflow useMenuOverflow DropdownMenu/DropdownMenu.doc.mjs DropdownMenu/useMenuOverflow.ts
|
|
280
280
|
useMobileKeyboard ERR_UNKNOWN_COMPONENT - keyboard/useMobileKeyboard.ts
|
|
281
281
|
useOutlineFromDOM useOutlineFromDOM Outline/Outline.doc.mjs Outline/useOutlineFromDOM.ts
|
|
282
|
-
useOverlay useOverlay Overlay/
|
|
282
|
+
useOverlay useOverlay Overlay/useOverlay.doc.mjs Overlay/useOverlay.tsx
|
|
283
283
|
useOwnScrollGesture useOwnScrollGesture DateInput/DateInput.doc.mjs DateInput/useOwnScrollGesture.ts
|
|
284
284
|
usePager usePager hooks/useAnimatedLayout.doc.mjs hooks/usePager.ts
|
|
285
285
|
usePointerDragScroll usePointerDragScroll DateInput/DateInput.doc.mjs DateInput/usePointerDragScroll.ts
|
|
@@ -1013,31 +1013,44 @@ function resolveCoreRoot() {
|
|
|
1013
1013
|
const _componentDeclCache = new Map();
|
|
1014
1014
|
/**
|
|
1015
1015
|
* @param {string} pascalName
|
|
1016
|
+
* @param {{includeTypes?: boolean}} [options]
|
|
1016
1017
|
* @returns {string}
|
|
1017
1018
|
*/
|
|
1018
|
-
function readComponentDeclarations(pascalName) {
|
|
1019
|
-
|
|
1020
|
-
|
|
1019
|
+
function readComponentDeclarations(pascalName, options = {}) {
|
|
1020
|
+
const includeTypes = options.includeTypes === true;
|
|
1021
|
+
const cacheKey = `${pascalName}:${includeTypes ? 'with-types' : 'index-only'}`;
|
|
1022
|
+
if (_componentDeclCache.has(cacheKey)) {
|
|
1023
|
+
return _componentDeclCache.get(cacheKey) ?? '';
|
|
1021
1024
|
}
|
|
1022
1025
|
let contents = '';
|
|
1023
1026
|
const coreRoot = resolveCoreRoot();
|
|
1024
1027
|
if (coreRoot) {
|
|
1025
|
-
const
|
|
1026
|
-
path.join(coreRoot, 'dist', pascalName, 'index.d.ts'),
|
|
1027
|
-
path.join(coreRoot, 'src', pascalName, 'index.ts'),
|
|
1028
|
+
const candidateSets = [
|
|
1029
|
+
[path.join(coreRoot, 'dist', pascalName, 'index.d.ts')],
|
|
1030
|
+
[path.join(coreRoot, 'src', pascalName, 'index.ts')],
|
|
1028
1031
|
];
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1032
|
+
if (includeTypes) {
|
|
1033
|
+
candidateSets[0].push(
|
|
1034
|
+
path.join(coreRoot, 'dist', pascalName, 'types.d.ts'),
|
|
1035
|
+
);
|
|
1036
|
+
candidateSets[1].push(path.join(coreRoot, 'src', pascalName, 'types.ts'));
|
|
1037
|
+
}
|
|
1038
|
+
for (const files of candidateSets) {
|
|
1039
|
+
if (fs.existsSync(files[0])) {
|
|
1040
|
+
for (const file of files) {
|
|
1041
|
+
try {
|
|
1042
|
+
if (fs.existsSync(file)) {
|
|
1043
|
+
contents += fs.readFileSync(file, 'utf-8') + '\n';
|
|
1044
|
+
}
|
|
1045
|
+
} catch {
|
|
1046
|
+
// ignore
|
|
1047
|
+
}
|
|
1034
1048
|
}
|
|
1035
|
-
|
|
1036
|
-
// ignore and try the next candidate
|
|
1049
|
+
if (contents) break;
|
|
1037
1050
|
}
|
|
1038
1051
|
}
|
|
1039
1052
|
}
|
|
1040
|
-
_componentDeclCache.set(
|
|
1053
|
+
_componentDeclCache.set(cacheKey, contents);
|
|
1041
1054
|
return contents;
|
|
1042
1055
|
}
|
|
1043
1056
|
|
|
@@ -1163,10 +1176,11 @@ async function resolveAugmentationTargetCandidates(componentName) {
|
|
|
1163
1176
|
* re-exported) as a type/interface.
|
|
1164
1177
|
* @param {string} pascalName
|
|
1165
1178
|
* @param {string} interfaceName
|
|
1179
|
+
* @param {{includeTypes?: boolean}} [options]
|
|
1166
1180
|
* @returns {boolean}
|
|
1167
1181
|
*/
|
|
1168
|
-
function componentHasAugmentableInterface(pascalName, interfaceName) {
|
|
1169
|
-
const decl = readComponentDeclarations(pascalName);
|
|
1182
|
+
function componentHasAugmentableInterface(pascalName, interfaceName, options) {
|
|
1183
|
+
const decl = readComponentDeclarations(pascalName, options);
|
|
1170
1184
|
if (!decl) return false;
|
|
1171
1185
|
// Require an actual interface declaration in this public subpath, not just a
|
|
1172
1186
|
// type re-export. Module augmentation only widens consumers that import the
|
|
@@ -1199,6 +1213,56 @@ function isComponentValueAugmentationPoint(pascalName, interfaceName) {
|
|
|
1199
1213
|
);
|
|
1200
1214
|
}
|
|
1201
1215
|
|
|
1216
|
+
/**
|
|
1217
|
+
* Extension points whose public module and interface do not follow the usual
|
|
1218
|
+
* `<Component><Prop>Map` convention. TextType reads CustomTextTypes from the
|
|
1219
|
+
* theme module, so both classification and declaration emission must resolve
|
|
1220
|
+
* this same public augmentation point.
|
|
1221
|
+
*
|
|
1222
|
+
* @type {Record<string, {moduleName: string, interfaceName: string, includeTypes?: boolean}>}
|
|
1223
|
+
*/
|
|
1224
|
+
const AUGMENTATION_OVERRIDES = {
|
|
1225
|
+
'text.type': {
|
|
1226
|
+
moduleName: 'theme',
|
|
1227
|
+
interfaceName: 'CustomTextTypes',
|
|
1228
|
+
includeTypes: true,
|
|
1229
|
+
},
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
/**
|
|
1233
|
+
* Resolve the public module/interface that can widen a component prop value.
|
|
1234
|
+
* @param {string} component
|
|
1235
|
+
* @param {string} prop
|
|
1236
|
+
* @returns {Promise<{moduleName: string, interfaceName: string}|null>}
|
|
1237
|
+
*/
|
|
1238
|
+
async function resolveAugmentationTarget(component, prop) {
|
|
1239
|
+
const override = AUGMENTATION_OVERRIDES[`${component}.${prop}`];
|
|
1240
|
+
if (override) {
|
|
1241
|
+
return componentHasAugmentableInterface(
|
|
1242
|
+
override.moduleName,
|
|
1243
|
+
override.interfaceName,
|
|
1244
|
+
{includeTypes: override.includeTypes},
|
|
1245
|
+
)
|
|
1246
|
+
? {moduleName: override.moduleName, interfaceName: override.interfaceName}
|
|
1247
|
+
: null;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
const propPascal = prop.charAt(0).toUpperCase() + prop.slice(1);
|
|
1251
|
+
const target = (await resolveAugmentationTargetCandidates(component)).find(
|
|
1252
|
+
candidate =>
|
|
1253
|
+
isComponentValueAugmentationPoint(
|
|
1254
|
+
candidate.moduleName,
|
|
1255
|
+
`${candidate.interfacePrefix}${propPascal}Map`,
|
|
1256
|
+
),
|
|
1257
|
+
);
|
|
1258
|
+
return target
|
|
1259
|
+
? {
|
|
1260
|
+
moduleName: target.moduleName,
|
|
1261
|
+
interfaceName: `${target.interfacePrefix}${propPascal}Map`,
|
|
1262
|
+
}
|
|
1263
|
+
: null;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1202
1266
|
/**
|
|
1203
1267
|
* Adaptation values from resolved runtime rules, raw input, or normalized built
|
|
1204
1268
|
* metadata. Built modules intentionally omit `__adaptationRules`, so every CLI
|
|
@@ -1503,14 +1567,7 @@ async function classifyComponentValue(component, prop, value) {
|
|
|
1503
1567
|
return 'builtin';
|
|
1504
1568
|
}
|
|
1505
1569
|
|
|
1506
|
-
const
|
|
1507
|
-
const target = (await resolveAugmentationTargetCandidates(component)).find(
|
|
1508
|
-
candidate =>
|
|
1509
|
-
isComponentValueAugmentationPoint(
|
|
1510
|
-
candidate.moduleName,
|
|
1511
|
-
`${candidate.interfacePrefix}${propPascal}Map`,
|
|
1512
|
-
),
|
|
1513
|
-
);
|
|
1570
|
+
const target = await resolveAugmentationTarget(component, prop);
|
|
1514
1571
|
return target ? 'enrollment' : 'unresolved';
|
|
1515
1572
|
}
|
|
1516
1573
|
|
|
@@ -1668,15 +1725,7 @@ async function generateVariantDeclarationsAsync(themeDef) {
|
|
|
1668
1725
|
for (const [prop, values] of Object.entries(props)) {
|
|
1669
1726
|
if (values.size === 0) continue;
|
|
1670
1727
|
|
|
1671
|
-
const
|
|
1672
|
-
const target = (
|
|
1673
|
-
await resolveAugmentationTargetCandidates(component)
|
|
1674
|
-
).find(candidate =>
|
|
1675
|
-
isComponentValueAugmentationPoint(
|
|
1676
|
-
candidate.moduleName,
|
|
1677
|
-
`${candidate.interfacePrefix}${propPascal}Map`,
|
|
1678
|
-
),
|
|
1679
|
-
);
|
|
1728
|
+
const target = await resolveAugmentationTarget(component, prop);
|
|
1680
1729
|
|
|
1681
1730
|
// Resolve the augmentation point again to name it. Classification has
|
|
1682
1731
|
// already established that one exists (that is what `enrollment` means),
|
|
@@ -1687,7 +1736,7 @@ async function generateVariantDeclarationsAsync(themeDef) {
|
|
|
1687
1736
|
if (!target) continue;
|
|
1688
1737
|
|
|
1689
1738
|
const modulePath = `@astryxdesign/core/${target.moduleName}`;
|
|
1690
|
-
const interfaceName =
|
|
1739
|
+
const {interfaceName} = target;
|
|
1691
1740
|
|
|
1692
1741
|
sections.push(`declare module '${modulePath}' {`);
|
|
1693
1742
|
sections.push(` interface ${interfaceName} {`);
|
|
@@ -1924,7 +1973,6 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
1924
1973
|
// A frozen require(esm) namespace cannot be patched, so retain that gap and
|
|
1925
1974
|
// let the selected lineage decide whether it matters.
|
|
1926
1975
|
const commonJsPatch = interception.patchCommonJs(filePath);
|
|
1927
|
-
degraded.commonJs = !commonJsPatch.covered;
|
|
1928
1976
|
try {
|
|
1929
1977
|
try {
|
|
1930
1978
|
mod = jiti(filePath);
|
|
@@ -1946,6 +1994,8 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
|
|
|
1946
1994
|
});
|
|
1947
1995
|
}
|
|
1948
1996
|
} finally {
|
|
1997
|
+
// Read after the load: the root is wrapped when the load requires it.
|
|
1998
|
+
degraded.commonJs = !commonJsPatch.covered;
|
|
1949
1999
|
commonJsPatch.undo();
|
|
1950
2000
|
}
|
|
1951
2001
|
} else {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
* SYNC: packages/cli/api/theme/build/build.mjs (importThemeModule)
|
|
68
68
|
*/
|
|
69
69
|
|
|
70
|
-
import {createRequire} from 'node:module';
|
|
70
|
+
import Module, {createRequire} from 'node:module';
|
|
71
71
|
import * as path from 'node:path';
|
|
72
72
|
|
|
73
73
|
import {findInstalledPackage} from '../../../foundation/fs/paths.mjs';
|
|
@@ -293,20 +293,24 @@ export function interceptCore(coreThemeModule, coreRootModule) {
|
|
|
293
293
|
};
|
|
294
294
|
/** @type {any} */
|
|
295
295
|
let wrappedRoot;
|
|
296
|
+
let rootRead = false;
|
|
296
297
|
// jiti reads a virtual module only when a theme imports its specifier. So
|
|
297
298
|
// the root, which loads all of Core, loads only for a theme that asks.
|
|
298
299
|
Object.defineProperty(modules, '@astryxdesign/core', {
|
|
299
300
|
enumerable: true,
|
|
300
301
|
configurable: true,
|
|
301
302
|
get() {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
303
|
+
if (!rootRead) {
|
|
304
|
+
const root =
|
|
305
|
+
typeof coreRootModule === 'function'
|
|
306
|
+
? coreRootModule()
|
|
307
|
+
: coreRootModule;
|
|
308
|
+
// Falls back to the theme namespace only when the root could not be
|
|
309
|
+
// imported at all; a partial root is better than none, and a core
|
|
310
|
+
// missing its own root entry is already broken.
|
|
311
|
+
wrappedRoot = wrapNamespace(root ?? coreThemeModule);
|
|
312
|
+
rootRead = true;
|
|
313
|
+
}
|
|
310
314
|
return wrappedRoot;
|
|
311
315
|
},
|
|
312
316
|
});
|
|
@@ -469,28 +473,19 @@ export function interceptCore(coreThemeModule, coreRootModule) {
|
|
|
469
473
|
return {covered, undo: () => {}};
|
|
470
474
|
}
|
|
471
475
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
cjs = createRequire(fromFile)(specifier);
|
|
480
|
-
} catch {
|
|
481
|
-
// A specifier that CommonJS cannot resolve cannot be used by a `.cjs`
|
|
482
|
-
// source dependency either, so it creates no unobserved path.
|
|
483
|
-
continue;
|
|
484
|
-
}
|
|
485
|
-
|
|
476
|
+
const requireFromTheme = createRequire(fromFile);
|
|
477
|
+
/**
|
|
478
|
+
* Wraps `defineTheme` on a CommonJS exports object in place, so a call
|
|
479
|
+
* from a `.cjs` dependency is recorded. False when it cannot be wrapped.
|
|
480
|
+
* @param {any} cjs
|
|
481
|
+
*/
|
|
482
|
+
const wrap = cjs => {
|
|
486
483
|
const real = cjs?.defineTheme;
|
|
487
|
-
if (typeof real !== 'function')
|
|
484
|
+
if (typeof real !== 'function') return true;
|
|
488
485
|
const descriptor = Object.getOwnPropertyDescriptor(cjs, 'defineTheme');
|
|
489
486
|
if (!descriptor || !(descriptor.writable || descriptor.configurable)) {
|
|
490
|
-
|
|
491
|
-
continue;
|
|
487
|
+
return false;
|
|
492
488
|
}
|
|
493
|
-
|
|
494
489
|
try {
|
|
495
490
|
Object.defineProperty(cjs, 'defineTheme', {
|
|
496
491
|
...descriptor,
|
|
@@ -503,16 +498,84 @@ export function interceptCore(coreThemeModule, coreRootModule) {
|
|
|
503
498
|
undo.push(() =>
|
|
504
499
|
Object.defineProperty(cjs, 'defineTheme', descriptor),
|
|
505
500
|
);
|
|
501
|
+
return true;
|
|
506
502
|
} catch {
|
|
507
503
|
// ESM namespace exotic objects may report a writable descriptor but
|
|
508
504
|
// still reject redefinition. This is a real coverage failure, not an
|
|
509
505
|
// absent CommonJS entry: a `.cjs` dependency can call the function
|
|
510
506
|
// while the recorder cannot wrap it.
|
|
511
|
-
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
// An entry that CommonJS cannot resolve or load cannot be used by a
|
|
512
|
+
// `.cjs` source dependency either, so it creates no unobserved path. It
|
|
513
|
+
// is skipped, as are the entries of a package config CommonJS cannot
|
|
514
|
+
// read. Throwing instead would fail every theme beside such an install.
|
|
515
|
+
/** @param {string} specifier @returns {string | null} */
|
|
516
|
+
const resolveEntry = specifier => {
|
|
517
|
+
try {
|
|
518
|
+
return requireFromTheme.resolve(specifier);
|
|
519
|
+
} catch {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
const themeFile = resolveEntry('@astryxdesign/core/theme');
|
|
524
|
+
const rootFile = resolveEntry('@astryxdesign/core');
|
|
525
|
+
|
|
526
|
+
// The theme subpath is small, so it is wrapped now.
|
|
527
|
+
if (themeFile) {
|
|
528
|
+
/** @type {any} */
|
|
529
|
+
let themeExports = null;
|
|
530
|
+
try {
|
|
531
|
+
themeExports = requireFromTheme(themeFile);
|
|
532
|
+
} catch {
|
|
533
|
+
// A dependency that requires it fails the same way.
|
|
534
|
+
}
|
|
535
|
+
if (themeExports && !wrap(themeExports)) covered = false;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// The root loads all of Core, so it is wrapped only once this load
|
|
539
|
+
// requires it. Every CommonJS require goes through `Module._load`,
|
|
540
|
+
// which is watched for the load's duration. The watch reads the require
|
|
541
|
+
// cache, where the root's file is keyed by its real path. So any
|
|
542
|
+
// request that loads that file counts, however it is spelled. A load
|
|
543
|
+
// that never requires the root leaves no path through it to observe.
|
|
544
|
+
if (rootFile) {
|
|
545
|
+
/** @type {any} */
|
|
546
|
+
const loader = Module;
|
|
547
|
+
/** Wraps the root once its file has run; false until then. */
|
|
548
|
+
const wrapLoadedRoot = () => {
|
|
549
|
+
const loaded = loader._cache[rootFile];
|
|
550
|
+
// A CommonJS module is cached before its body runs, so a require
|
|
551
|
+
// inside the root's own body sees it partly built.
|
|
552
|
+
if (!loaded?.loaded) return false;
|
|
553
|
+
if (!wrap(loaded.exports)) covered = false;
|
|
554
|
+
return true;
|
|
555
|
+
};
|
|
556
|
+
if (!wrapLoadedRoot()) {
|
|
557
|
+
const load = loader._load;
|
|
558
|
+
/** @this {any} @param {...any} args */
|
|
559
|
+
const watch = function (...args) {
|
|
560
|
+
const exports = load.apply(this, args);
|
|
561
|
+
if (loader._load === watch && wrapLoadedRoot()) {
|
|
562
|
+
loader._load = load;
|
|
563
|
+
}
|
|
564
|
+
return exports;
|
|
565
|
+
};
|
|
566
|
+
loader._load = watch;
|
|
567
|
+
// Theme loads never overlap: each caller awaits one at a time. The
|
|
568
|
+
// watch is still removed only while it is the one installed.
|
|
569
|
+
undo.push(() => {
|
|
570
|
+
if (loader._load === watch) loader._load = load;
|
|
571
|
+
});
|
|
512
572
|
}
|
|
513
573
|
}
|
|
514
574
|
return {
|
|
515
|
-
|
|
575
|
+
/** Read after the load: a root required during it counts. */
|
|
576
|
+
get covered() {
|
|
577
|
+
return covered;
|
|
578
|
+
},
|
|
516
579
|
undo() {
|
|
517
580
|
for (const restore of undo.reverse()) {
|
|
518
581
|
try {
|
|
@@ -0,0 +1,14 @@
|
|
|
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: 'useCalendarDays',
|
|
7
|
+
name: 'useCalendarDays — Month Grid',
|
|
8
|
+
displayName: 'useCalendarDays — Month Grid',
|
|
9
|
+
description:
|
|
10
|
+
'A compact custom month view: a seven-column table built from the weeks and dayNames that useCalendarDays returns, with only as many rows as the month needs. Days from the previous and next months are dimmed, and a Week starts on control (Sunday or Monday) reorders both the header and the grid.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 4 / 3,
|
|
13
|
+
componentsUsed: ['SegmentedControl', 'Layout', 'Text'],
|
|
14
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useState} from 'react';
|
|
6
|
+
import {useCalendarDays} from '@astryxdesign/core/Calendar';
|
|
7
|
+
import {HStack, VStack} from '@astryxdesign/core/Layout';
|
|
8
|
+
import {
|
|
9
|
+
SegmentedControl,
|
|
10
|
+
SegmentedControlItem,
|
|
11
|
+
} from '@astryxdesign/core/SegmentedControl';
|
|
12
|
+
import {Text} from '@astryxdesign/core/Text';
|
|
13
|
+
|
|
14
|
+
export default function UseCalendarDaysHookUsage() {
|
|
15
|
+
const [weekStartsOn, setWeekStartsOn] = useState<0 | 1>(0);
|
|
16
|
+
const {weeks, dayNames} = useCalendarDays({
|
|
17
|
+
year: 2026,
|
|
18
|
+
month: 12,
|
|
19
|
+
weekStartsOn,
|
|
20
|
+
hasVariableRowCount: true,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<VStack gap={3}>
|
|
25
|
+
<HStack gap={2} vAlign="center">
|
|
26
|
+
<Text type="body">Week starts on</Text>
|
|
27
|
+
<SegmentedControl
|
|
28
|
+
label="Week starts on"
|
|
29
|
+
value={String(weekStartsOn)}
|
|
30
|
+
onChange={value => setWeekStartsOn(value === '1' ? 1 : 0)}
|
|
31
|
+
size="sm">
|
|
32
|
+
<SegmentedControlItem value="0" label="Sunday" />
|
|
33
|
+
<SegmentedControlItem value="1" label="Monday" />
|
|
34
|
+
</SegmentedControl>
|
|
35
|
+
</HStack>
|
|
36
|
+
<table style={{tableLayout: 'fixed', width: 280}}>
|
|
37
|
+
<caption>
|
|
38
|
+
<Text type="body" weight="bold">
|
|
39
|
+
December 2026
|
|
40
|
+
</Text>
|
|
41
|
+
</caption>
|
|
42
|
+
<thead>
|
|
43
|
+
<tr>
|
|
44
|
+
{dayNames.map((name, column) => (
|
|
45
|
+
<th key={(weekStartsOn + column) % 7} scope="col">
|
|
46
|
+
<Text type="supporting" color="secondary">
|
|
47
|
+
{name}
|
|
48
|
+
</Text>
|
|
49
|
+
</th>
|
|
50
|
+
))}
|
|
51
|
+
</tr>
|
|
52
|
+
</thead>
|
|
53
|
+
<tbody>
|
|
54
|
+
{weeks.map(week => (
|
|
55
|
+
<tr key={week[0].iso}>
|
|
56
|
+
{week.map(day => (
|
|
57
|
+
<td key={day.iso} align="center">
|
|
58
|
+
<Text
|
|
59
|
+
type="body"
|
|
60
|
+
color={day.isOutside ? 'secondary' : 'primary'}>
|
|
61
|
+
{day.dayNumber}
|
|
62
|
+
</Text>
|
|
63
|
+
</td>
|
|
64
|
+
))}
|
|
65
|
+
</tr>
|
|
66
|
+
))}
|
|
67
|
+
</tbody>
|
|
68
|
+
</table>
|
|
69
|
+
</VStack>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -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: 'useOverlay',
|
|
7
|
+
name: 'useOverlay — Product Quick View',
|
|
8
|
+
displayName: 'useOverlay — Product Quick View',
|
|
9
|
+
description:
|
|
10
|
+
'A product card that is its own overlay container: useOverlay returns the ref and props to spread on the Card and a bottom strip to render once over the image. Hovering the card, or moving keyboard focus into it, slides in a Quick view button along the bottom of the image, and leaving hides it again. The image is a link that the strip leaves clickable above it, and Tab lands on it first so the next Tab reaches Quick view.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 4 / 3,
|
|
13
|
+
componentsUsed: [
|
|
14
|
+
'Overlay',
|
|
15
|
+
'Card',
|
|
16
|
+
'AspectRatio',
|
|
17
|
+
'Button',
|
|
18
|
+
'Layout',
|
|
19
|
+
'Text',
|
|
20
|
+
],
|
|
21
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import type {RefObject} from 'react';
|
|
6
|
+
import {AspectRatio} from '@astryxdesign/core/AspectRatio';
|
|
7
|
+
import {Button} from '@astryxdesign/core/Button';
|
|
8
|
+
import {Card} from '@astryxdesign/core/Card';
|
|
9
|
+
import {VStack} from '@astryxdesign/core/Layout';
|
|
10
|
+
import {useOverlay} from '@astryxdesign/core/Overlay';
|
|
11
|
+
import {Text} from '@astryxdesign/core/Text';
|
|
12
|
+
|
|
13
|
+
export default function UseOverlayHookUsage() {
|
|
14
|
+
const overlay = useOverlay({
|
|
15
|
+
showOn: 'hover',
|
|
16
|
+
position: 'bottom',
|
|
17
|
+
align: 'center',
|
|
18
|
+
content: <Button label="Quick view" variant="secondary" size="sm" />,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Card
|
|
23
|
+
width={280}
|
|
24
|
+
padding={0}
|
|
25
|
+
ref={overlay.containerRef as RefObject<HTMLDivElement | null>}
|
|
26
|
+
{...overlay.containerProps}>
|
|
27
|
+
<div style={{position: 'relative'}}>
|
|
28
|
+
<a href="#ceramic-mug">
|
|
29
|
+
<AspectRatio ratio={1}>
|
|
30
|
+
<img
|
|
31
|
+
src="/template-assets/light-product-1.png"
|
|
32
|
+
alt="Ceramic mug"
|
|
33
|
+
style={{width: '100%', height: '100%', objectFit: 'cover'}}
|
|
34
|
+
/>
|
|
35
|
+
</AspectRatio>
|
|
36
|
+
</a>
|
|
37
|
+
{overlay.element}
|
|
38
|
+
</div>
|
|
39
|
+
<VStack gap={1} padding={3}>
|
|
40
|
+
<Text type="body" weight="bold">
|
|
41
|
+
Ceramic mug
|
|
42
|
+
</Text>
|
|
43
|
+
<Text type="supporting" color="secondary">
|
|
44
|
+
$24
|
|
45
|
+
</Text>
|
|
46
|
+
</VStack>
|
|
47
|
+
</Card>
|
|
48
|
+
);
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.9-canary.
|
|
3
|
+
"version": "0.7.9-canary.db3451e",
|
|
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.9-canary.
|
|
128
|
-
"@astryxdesign/core": "0.7.9-canary.
|
|
129
|
-
"@astryxdesign/lab": "0.7.9-canary.
|
|
130
|
-
"@astryxdesign/theme-neutral": "0.7.9-canary.
|
|
127
|
+
"@astryxdesign/charts": "0.7.9-canary.db3451e",
|
|
128
|
+
"@astryxdesign/core": "0.7.9-canary.db3451e",
|
|
129
|
+
"@astryxdesign/lab": "0.7.9-canary.db3451e",
|
|
130
|
+
"@astryxdesign/theme-neutral": "0.7.9-canary.db3451e"
|
|
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.9-canary.
|
|
148
|
-
"@astryxdesign/core": "0.7.9-canary.
|
|
149
|
-
"@astryxdesign/lab": "0.7.9-canary.
|
|
150
|
-
"@astryxdesign/theme-neutral": "0.7.9-canary.
|
|
147
|
+
"@astryxdesign/charts": "0.7.9-canary.db3451e",
|
|
148
|
+
"@astryxdesign/core": "0.7.9-canary.db3451e",
|
|
149
|
+
"@astryxdesign/lab": "0.7.9-canary.db3451e",
|
|
150
|
+
"@astryxdesign/theme-neutral": "0.7.9-canary.db3451e",
|
|
151
151
|
"@heroicons/react": "^2.2.0",
|
|
152
152
|
"@stylexjs/stylex": "^0.19.0",
|
|
153
153
|
"@types/babel__core": "^7.20.5",
|