@astryxdesign/cli 0.7.9-canary.d7a7dd3 → 0.7.9-canary.dd5ca29

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.
@@ -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/Overlay.doc.mjs Overlay/useOverlay.tsx
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
- if (_componentDeclCache.has(pascalName)) {
1020
- return _componentDeclCache.get(pascalName) ?? '';
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 candidates = [
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
- for (const file of candidates) {
1030
- try {
1031
- if (fs.existsSync(file)) {
1032
- contents = fs.readFileSync(file, 'utf-8');
1033
- break;
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
- } catch {
1036
- // ignore and try the next candidate
1049
+ if (contents) break;
1037
1050
  }
1038
1051
  }
1039
1052
  }
1040
- _componentDeclCache.set(pascalName, contents);
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 propPascal = prop.charAt(0).toUpperCase() + prop.slice(1);
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 propPascal = prop.charAt(0).toUpperCase() + prop.slice(1);
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 = `${target.interfacePrefix}${propPascal}Map`;
1739
+ const {interfaceName} = target;
1691
1740
 
1692
1741
  sections.push(`declare module '${modulePath}' {`);
1693
1742
  sections.push(` interface ${interfaceName} {`);
@@ -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.d7a7dd3",
3
+ "version": "0.7.9-canary.dd5ca29",
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.d7a7dd3",
128
- "@astryxdesign/core": "0.7.9-canary.d7a7dd3",
129
- "@astryxdesign/lab": "0.7.9-canary.d7a7dd3",
130
- "@astryxdesign/theme-neutral": "0.7.9-canary.d7a7dd3"
127
+ "@astryxdesign/charts": "0.7.9-canary.dd5ca29",
128
+ "@astryxdesign/core": "0.7.9-canary.dd5ca29",
129
+ "@astryxdesign/lab": "0.7.9-canary.dd5ca29",
130
+ "@astryxdesign/theme-neutral": "0.7.9-canary.dd5ca29"
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.d7a7dd3",
148
- "@astryxdesign/core": "0.7.9-canary.d7a7dd3",
149
- "@astryxdesign/lab": "0.7.9-canary.d7a7dd3",
150
- "@astryxdesign/theme-neutral": "0.7.9-canary.d7a7dd3",
147
+ "@astryxdesign/charts": "0.7.9-canary.dd5ca29",
148
+ "@astryxdesign/core": "0.7.9-canary.dd5ca29",
149
+ "@astryxdesign/lab": "0.7.9-canary.dd5ca29",
150
+ "@astryxdesign/theme-neutral": "0.7.9-canary.dd5ca29",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",