@astryxdesign/cli 0.6.3-canary.d0d49a4 → 0.6.3-canary.db4e378

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 (206) hide show
  1. package/README.md +86 -72
  2. package/api/build/build.doc.mjs +3 -3
  3. package/api/build/build.test.mjs +14 -3
  4. package/api/build/build.type.d.mts +35 -1
  5. package/api/build/build.type.mjs +24 -3
  6. package/api/build/help/help.d.mts +8 -5
  7. package/api/build/help/help.mjs +56 -6
  8. package/api/component/component.doc.mjs +12 -3
  9. package/api/component/component.mjs +31 -2
  10. package/api/component/component.test.mjs +38 -0
  11. package/api/component/component.type.d.mts +16 -5
  12. package/api/component/component.type.mjs +13 -5
  13. package/api/component/detail/blocks/blocks.d.mts +2 -1
  14. package/api/component/detail/blocks/blocks.mjs +4 -3
  15. package/api/component/list/list.d.mts +0 -5
  16. package/api/component/list/list.mjs +37 -9
  17. package/api/discover/discover.doc.mjs +1 -1
  18. package/api/gap-report/gap-report.doc.mjs +7 -4
  19. package/api/init/init.doc.mjs +4 -0
  20. package/api/init/init.test.mjs +41 -1
  21. package/api/init/remove/remove.mjs +1 -1
  22. package/api/init/run/run.mjs +20 -10
  23. package/api/integration/add-contribution.component-names.test.mjs +120 -0
  24. package/api/integration/add-contribution.mjs +11 -0
  25. package/api/integration/add-contribution.test.mjs +80 -0
  26. package/api/integration/integrationAdd.doc.mjs +7 -4
  27. package/api/integration/integrationAddComponent.doc.mjs +1 -1
  28. package/api/integration/validate-integration.mjs +2 -0
  29. package/api/integration/validate-integration.test.mjs +91 -0
  30. package/api/integration/validateIntegration.doc.mjs +1 -1
  31. package/api/json/envelope-types.test.mjs +76 -0
  32. package/api/json/parseResponse.doc.mjs +2 -2
  33. package/api/layout/expand/expand.mjs +7 -5
  34. package/api/layout/expand/expand.path-safety.test.mjs +53 -0
  35. package/api/layout/grammar/grammar.mjs +2 -1
  36. package/api/layout/layoutExpand.doc.mjs +1 -1
  37. package/api/search/search-return-type.test.mjs +54 -0
  38. package/api/search/search.d.mts +2 -9
  39. package/api/search/search.doc.mjs +5 -1
  40. package/api/search/search.mjs +10 -3
  41. package/api/search/search.test.mjs +34 -0
  42. package/api/swizzle/copy/copy.mjs +28 -11
  43. package/api/swizzle/swizzle.doc.mjs +1 -1
  44. package/api/template/copy/copy.mjs +17 -23
  45. package/api/template/copy/copy.test.mjs +17 -0
  46. package/api/template/template.doc.mjs +2 -1
  47. package/api/theme/add/add.binary.test.mjs +91 -0
  48. package/api/theme/add/add.mjs +20 -3
  49. package/api/theme/add/add.staging.test.mjs +66 -0
  50. package/api/theme/build/build.mjs +114 -37
  51. package/api/theme/build/build.public-component-vars.test.mjs +1 -1
  52. package/api/theme/build/build.receipt-doc.test.mjs +111 -0
  53. package/api/theme/build/font-warning.mjs +3 -3
  54. package/api/theme/build/font-warning.test.mjs +5 -2
  55. package/api/theme/palette/generate/generate.mjs +7 -2
  56. package/api/theme/palette/generate/generate.test.mjs +96 -0
  57. package/api/theme/palette/generate/generator.mjs +8 -1
  58. package/api/theme/palette/generate/generator.test.mjs +10 -0
  59. package/api/theme/template/template.mjs +11 -2
  60. package/api/theme/template/template.test.mjs +15 -0
  61. package/api/theme/themeBuild.doc.mjs +7 -4
  62. package/api/theme/themeTemplate.doc.mjs +4 -1
  63. package/api/upgrade/_adapter.mjs +27 -4
  64. package/api/upgrade/list/list.mjs +2 -1
  65. package/api/upgrade/list/list.test.mjs +73 -0
  66. package/api/upgrade/status/status.mjs +2 -2
  67. package/api/upgrade/upgrade.doc.mjs +2 -1
  68. package/api/upgrade/upgrade.type.d.mts +4 -0
  69. package/api/upgrade/upgrade.type.mjs +1 -0
  70. package/assets/codemods/term-log.mjs +32 -8
  71. package/assets/codemods/term-log.test.mjs +19 -1
  72. package/assets/codemods/transform-prop.mjs +109 -0
  73. package/assets/codemods/transform-prop.test.mjs +95 -0
  74. package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
  75. package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
  76. package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
  77. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
  78. package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
  79. package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
  80. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
  81. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
  82. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
  83. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
  84. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
  85. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
  86. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
  87. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
  88. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
  89. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
  90. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
  91. package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
  92. package/assets/templates/pages/table-tree/page.tsx +1704 -0
  93. package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
  94. package/authoring/config/config.doc.mjs +1 -1
  95. package/authoring/config/debug-composition.test.mjs +92 -0
  96. package/authoring/config/type.ts +15 -3
  97. package/clients/cli/command-load-failure.test.mjs +83 -0
  98. package/clients/cli/commands/blog.mjs +23 -8
  99. package/clients/cli/commands/blog.test.mjs +42 -1
  100. package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
  101. package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
  102. package/clients/cli/commands/build-theme.mjs +5 -5
  103. package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
  104. package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
  105. package/clients/cli/commands/build.doc.mjs +4 -1
  106. package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
  107. package/clients/cli/commands/build.mjs +32 -47
  108. package/clients/cli/commands/build.playbook.test.mjs +75 -0
  109. package/clients/cli/commands/build.text-fields.test.mjs +40 -0
  110. package/clients/cli/commands/component/index.mjs +2 -7
  111. package/clients/cli/commands/component-package.test.mjs +46 -0
  112. package/clients/cli/commands/component-resolution.test.mjs +21 -0
  113. package/clients/cli/commands/component.test.mjs +19 -0
  114. package/clients/cli/commands/detail-levels.test.mjs +2 -2
  115. package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
  116. package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
  117. package/clients/cli/commands/discover.doc.mjs +4 -2
  118. package/clients/cli/commands/discover.mjs +3 -3
  119. package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
  120. package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
  121. package/clients/cli/commands/doctor.mjs +6 -16
  122. package/clients/cli/commands/doctor.test.mjs +42 -0
  123. package/clients/cli/commands/gap-report.doc.mjs +16 -5
  124. package/clients/cli/commands/gap-report.test.mjs +72 -0
  125. package/clients/cli/commands/hook/index.mjs +7 -17
  126. package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
  127. package/clients/cli/commands/init.doc.mjs +19 -8
  128. package/clients/cli/commands/init.flag-help.test.mjs +153 -0
  129. package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
  130. package/clients/cli/commands/integration-add.doc.mjs +21 -5
  131. package/clients/cli/commands/interactive-guard.test.mjs +101 -24
  132. package/clients/cli/commands/json-contract.test.mjs +33 -0
  133. package/clients/cli/commands/layout-check.doc.mjs +14 -3
  134. package/clients/cli/commands/layout-expand.doc.mjs +21 -4
  135. package/clients/cli/commands/layout.doc.mjs +2 -2
  136. package/clients/cli/commands/layout.mjs +21 -9
  137. package/clients/cli/commands/layout.path-help.test.mjs +33 -0
  138. package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
  139. package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
  140. package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
  141. package/clients/cli/commands/search.doc.mjs +6 -3
  142. package/clients/cli/commands/search.mjs +17 -7
  143. package/clients/cli/commands/search.test.mjs +75 -0
  144. package/clients/cli/commands/swizzle.doc.mjs +2 -1
  145. package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
  146. package/clients/cli/commands/template.doc.mjs +28 -6
  147. package/clients/cli/commands/template.flag-help.test.mjs +117 -0
  148. package/clients/cli/commands/template.path-help.test.mjs +40 -0
  149. package/clients/cli/commands/theme-add.doc.mjs +2 -1
  150. package/clients/cli/commands/theme-build.doc.mjs +7 -6
  151. package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
  152. package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
  153. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  154. package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
  155. package/clients/cli/commands/upgrade.doc.mjs +17 -6
  156. package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
  157. package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
  158. package/clients/cli/index.mjs +13 -30
  159. package/clients/cli/latest-version-env.test.mjs +50 -0
  160. package/clients/cli/lib/cli-error.test.mjs +7 -0
  161. package/clients/cli/lib/component-format.mjs +9 -9
  162. package/clients/cli/lib/component-format.test.mjs +1 -1
  163. package/clients/cli/lib/define-command.mjs +32 -6
  164. package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
  165. package/clients/cli/lib/exit-codes.test.mjs +97 -0
  166. package/clients/cli/lib/hook-format.mjs +5 -5
  167. package/clients/cli/lib/json-shim.mjs +38 -2
  168. package/clients/cli/lib/json-shim.test.mjs +83 -0
  169. package/clients/cli/lib/manifest.d.ts +2 -0
  170. package/clients/cli/lib/manifest.mjs +22 -0
  171. package/clients/cli/lib/manifest.test.mjs +17 -0
  172. package/foundation/agent-docs/agent-docs.d.mts +4 -0
  173. package/foundation/agent-docs/agent-docs.mjs +69 -3
  174. package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
  175. package/foundation/config/integration-debug.test.mjs +28 -3
  176. package/foundation/config/project.mjs +123 -9
  177. package/foundation/config/project.test.mjs +126 -0
  178. package/foundation/discovery/template-adapter.d.mts +14 -5
  179. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
  180. package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
  181. package/foundation/discovery/template-adapter.mjs +292 -25
  182. package/foundation/discovery/theming-targets.test.mjs +4 -0
  183. package/foundation/fs/module-loader.d.mts +1 -0
  184. package/foundation/fs/module-loader.mjs +50 -1
  185. package/foundation/fs/module-loader.stdout.test.mjs +332 -0
  186. package/foundation/fs/path-safety.d.mts +3 -2
  187. package/foundation/fs/path-safety.mjs +49 -19
  188. package/foundation/fs/path-safety.test.mjs +50 -0
  189. package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
  190. package/foundation/integrations/autolink.mjs +6 -1
  191. package/foundation/response/base.d.ts +8 -4
  192. package/foundation/response/error-codes.doc.mjs +1 -2
  193. package/foundation/response/error-codes.mjs +1 -1
  194. package/foundation/response/error-codes.test.mjs +83 -0
  195. package/foundation/response/json-contract.test.mjs +11 -0
  196. package/foundation/response/json.d.mts +4 -2
  197. package/foundation/response/json.mjs +8 -10
  198. package/foundation/response/response-types.doc.mjs +10 -10
  199. package/foundation/response/response-types.doc.test.mjs +158 -0
  200. package/foundation/xle/expand.d.mts +2 -0
  201. package/foundation/xle/expand.mjs +3 -2
  202. package/foundation/xle/expand.test.mjs +54 -0
  203. package/package.json +9 -9
  204. package/clients/cli/lib/update-check.mjs +0 -83
  205. package/clients/cli/lib/update-check.test.mjs +0 -137
  206. package/clients/cli/update-hint-commands.test.mjs +0 -54
@@ -8,6 +8,9 @@
8
8
  * released conflict rule (the unified property wins when both are present).
9
9
  * A spread or computed property can change precedence invisibly, so dynamic
10
10
  * objects stay unchanged and receive a manual-migration TODO instead.
11
+ * Named and namespace imports both count, and a type-only wrapper (`as`,
12
+ * `satisfies`, a non-null assertion, parentheses) does not make a
13
+ * configuration dynamic.
11
14
  */
12
15
 
13
16
  export const meta = {
@@ -33,6 +36,26 @@ const MANUAL_MIGRATION_COMMENT =
33
36
  'or computed property. Rename minSizePx/maxSizePx to minSize/maxSize ' +
34
37
  'manually without changing property precedence. ';
35
38
 
39
+ const TYPE_WRAPPERS = new Set([
40
+ 'TSAsExpression',
41
+ 'TSSatisfiesExpression',
42
+ 'TSTypeAssertion',
43
+ 'TSNonNullExpression',
44
+ 'ParenthesizedExpression',
45
+ ]);
46
+
47
+ /**
48
+ * The expression under type-only wrappers such as `{...} as const`.
49
+ * @param {any} node
50
+ */
51
+ function unwrap(node) {
52
+ let current = node;
53
+ while (current && TYPE_WRAPPERS.has(current.type)) {
54
+ current = current.expression;
55
+ }
56
+ return current;
57
+ }
58
+
36
59
  /** @param {any} property */
37
60
  function staticPropertyName(property) {
38
61
  if (property.computed) return null;
@@ -128,6 +151,8 @@ export default function transformer(file, api) {
128
151
  const root = j(file.source);
129
152
  /** @type {Map<string, any>} */
130
153
  const bindings = new Map();
154
+ /** @type {Map<string, any>} */
155
+ const namespaces = new Map();
131
156
 
132
157
  root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
133
158
  if (!IMPORT_SOURCES.has(path.node.source.value)) return;
@@ -138,17 +163,40 @@ export default function transformer(file, api) {
138
163
  ) {
139
164
  const local = specifier.local?.name ?? 'useResizable';
140
165
  bindings.set(local, path.scope.lookup(local) ?? path.scope);
166
+ } else if (specifier.type === 'ImportNamespaceSpecifier') {
167
+ const local = specifier.local.name;
168
+ namespaces.set(local, path.scope.lookup(local) ?? path.scope);
141
169
  }
142
170
  }
143
171
  });
144
- if (bindings.size === 0) return undefined;
172
+ if (bindings.size === 0 && namespaces.size === 0) return undefined;
173
+
174
+ /**
175
+ * @param {any} callee
176
+ * @param {any} scope
177
+ */
178
+ const isUseResizable = (callee, scope) => {
179
+ if (callee.type === 'Identifier') {
180
+ return (
181
+ bindings.has(callee.name) &&
182
+ scope.lookup(callee.name) === bindings.get(callee.name)
183
+ );
184
+ }
185
+ return (
186
+ callee.type === 'MemberExpression' &&
187
+ !callee.computed &&
188
+ callee.object.type === 'Identifier' &&
189
+ callee.property.type === 'Identifier' &&
190
+ callee.property.name === 'useResizable' &&
191
+ namespaces.has(callee.object.name) &&
192
+ scope.lookup(callee.object.name) === namespaces.get(callee.object.name)
193
+ );
194
+ };
145
195
 
146
196
  let changed = false;
147
197
  root.find(j.CallExpression).forEach((/** @type {any} */ path) => {
148
- const callee = path.node.callee;
149
- if (callee.type !== 'Identifier' || !bindings.has(callee.name)) return;
150
- if (path.scope.lookup(callee.name) !== bindings.get(callee.name)) return;
151
- const config = path.node.arguments[0];
198
+ if (!isUseResizable(path.node.callee, path.scope)) return;
199
+ const config = unwrap(path.node.arguments[0]);
152
200
  if (config?.type !== 'ObjectExpression') return;
153
201
 
154
202
  changed = migrateObject(j, config) || changed;
@@ -158,13 +206,12 @@ export default function transformer(file, api) {
158
206
  staticPropertyName(property) === 'regions',
159
207
  );
160
208
  if (!regions || !('value' in regions)) return;
161
- const regionsObject = regions.value;
209
+ const regionsObject = unwrap(regions.value);
162
210
  if (regionsObject?.type !== 'ObjectExpression') return;
163
211
  for (const region of regionsObject.properties) {
164
- if (!('value' in region) || region.value?.type !== 'ObjectExpression') {
165
- continue;
166
- }
167
- changed = migrateObject(j, region.value) || changed;
212
+ const regionConfig = 'value' in region ? unwrap(region.value) : null;
213
+ if (regionConfig?.type !== 'ObjectExpression') continue;
214
+ changed = migrateObject(j, regionConfig) || changed;
168
215
  }
169
216
  });
170
217
 
@@ -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: 'ScrollableArea',
7
+ name: 'ScrollableArea — Inline Rail',
8
+ displayName: 'Scrollable Area — Inline Rail',
9
+ description:
10
+ 'axis="inline" scrolls the same cards sideways; isFullBleed lets the rail run to the panel edges while the content padding keeps the first card aligned with the heading.',
11
+ isReady: true,
12
+ aspectRatio: 16 / 9,
13
+ componentsUsed: ['ScrollableArea', 'Card', 'Link'],
14
+ };
@@ -0,0 +1,61 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {ScrollableArea} from '@astryxdesign/core/ScrollableArea';
6
+ import {Card} from '@astryxdesign/core/Card';
7
+ import {HStack, VStack} from '@astryxdesign/core/Layout';
8
+ import {Heading, Text} from '@astryxdesign/core/Text';
9
+ import {Link} from '@astryxdesign/core/Link';
10
+
11
+ const FILES = [
12
+ {id: 'brief', title: 'Q3 launch brief', meta: 'Edited 2 days ago'},
13
+ {id: 'pricing', title: 'Pricing rework', meta: 'Edited 3 days ago'},
14
+ {id: 'onboarding', title: 'Onboarding flow v4', meta: 'Edited 4 days ago'},
15
+ {id: 'macros', title: 'Support macros', meta: 'Edited last week'},
16
+ {id: 'brand', title: 'Brand refresh', meta: 'Priya Raman'},
17
+ {id: 'checkout', title: 'Checkout audit', meta: 'Tomas Lindqvist'},
18
+ {id: 'partner', title: 'Partner deck', meta: 'Ines Okafor'},
19
+ ];
20
+
21
+ export default function ScrollableAreaInlineRail() {
22
+ return (
23
+ <Card width={460} padding={4}>
24
+ <VStack gap={3}>
25
+ <HStack hAlign="between" vAlign="center">
26
+ <VStack gap={0.5}>
27
+ <Heading level={3}>Workspace files</Heading>
28
+ <Text type="supporting">Recently opened</Text>
29
+ </VStack>
30
+ <Link href="#files">View all</Link>
31
+ </HStack>
32
+ {/* isFullBleed lets the rail reach the card's edges, while the content
33
+ padding keeps the first card aligned with the heading above it and
34
+ leaves room under the cards for the scrollbar. */}
35
+ <ScrollableArea
36
+ axis="inline"
37
+ role="region"
38
+ label="Recently opened files"
39
+ isFullBleed
40
+ paddingInline={4}
41
+ paddingBlockStart={0.5}
42
+ paddingBlockEnd={4}>
43
+ <HStack gap={2}>
44
+ {FILES.map(file => (
45
+ <Card key={file.id} variant="muted" padding={3} width={170}>
46
+ <VStack gap={1}>
47
+ <Text weight="medium" maxLines={1}>
48
+ {file.title}
49
+ </Text>
50
+ <Text type="supporting" maxLines={1}>
51
+ {file.meta}
52
+ </Text>
53
+ </VStack>
54
+ </Card>
55
+ ))}
56
+ </HStack>
57
+ </ScrollableArea>
58
+ </VStack>
59
+ </Card>
60
+ );
61
+ }
@@ -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: 'ScrollableArea',
7
+ name: 'ScrollableArea — Overscroll',
8
+ displayName: 'Scrollable Area — Overscroll',
9
+ description:
10
+ 'The same section, two edge policies: the default overscroll="allow" hands a gesture that reaches the end to the panel behind it, while overscroll="contain" stops it at the section edge.',
11
+ isReady: true,
12
+ aspectRatio: 1,
13
+ componentsUsed: ['ScrollableArea', 'Card', 'Grid'],
14
+ };
@@ -0,0 +1,126 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import * as stylex from '@stylexjs/stylex';
6
+ import {ScrollableArea} from '@astryxdesign/core/ScrollableArea';
7
+ import {Card} from '@astryxdesign/core/Card';
8
+ import {Grid} from '@astryxdesign/core/Grid';
9
+ import {VStack} from '@astryxdesign/core/Layout';
10
+ import {Heading, Text} from '@astryxdesign/core/Text';
11
+ import {
12
+ borderVars,
13
+ colorVars,
14
+ radiusVars,
15
+ } from '@astryxdesign/core/theme/tokens.stylex';
16
+
17
+ const styles = stylex.create({
18
+ // A hairline frame so the nested viewport's edge — the edge the gesture
19
+ // meets — is visible.
20
+ sectionFrame: {
21
+ borderWidth: borderVars['--border-width'],
22
+ borderStyle: 'solid',
23
+ borderColor: colorVars['--color-border'],
24
+ borderRadius: radiusVars['--radius-element'],
25
+ },
26
+ });
27
+
28
+ const SHARED = [
29
+ {id: 'brand', title: 'Brand refresh', meta: 'Priya Raman'},
30
+ {id: 'checkout', title: 'Checkout audit', meta: 'Tomas Lindqvist'},
31
+ {id: 'partner', title: 'Partner deck', meta: 'Ines Okafor'},
32
+ {id: 'research', title: 'Research synthesis', meta: 'Mei Watanabe'},
33
+ {id: 'tax', title: 'Tax region notes', meta: 'Hugo Bernard'},
34
+ {id: 'sso', title: 'SSO rollout plan', meta: 'Sofia Marchetti'},
35
+ ];
36
+
37
+ const ARCHIVED = [
38
+ {id: 'roadmap', title: '2025 roadmap', meta: 'Archived in March'},
39
+ {id: 'legacy', title: 'Legacy pricing', meta: 'Archived in March'},
40
+ {id: 'kit', title: 'Old brand kit', meta: 'Archived in January'},
41
+ {id: 'beta', title: 'Beta feedback', meta: 'Archived in January'},
42
+ {id: 'survey', title: 'Q4 survey results', meta: 'Archived in January'},
43
+ {id: 'offsite', title: 'Offsite agenda', meta: 'Archived last year'},
44
+ ];
45
+
46
+ function FileGrid({
47
+ files,
48
+ }: {
49
+ files: Array<{id: string; title: string; meta: string}>;
50
+ }) {
51
+ return (
52
+ <Grid columns={2} gap={2}>
53
+ {files.map(file => (
54
+ <Card key={file.id} variant="muted" padding={3}>
55
+ <VStack gap={1}>
56
+ <Text weight="medium" maxLines={1}>
57
+ {file.title}
58
+ </Text>
59
+ <Text type="supporting" maxLines={1}>
60
+ {file.meta}
61
+ </Text>
62
+ </VStack>
63
+ </Card>
64
+ ))}
65
+ </Grid>
66
+ );
67
+ }
68
+
69
+ export default function ScrollableAreaOverscrollChaining() {
70
+ return (
71
+ <Card width={400} padding={0}>
72
+ <ScrollableArea
73
+ axis="block"
74
+ role="region"
75
+ label="Workspace files"
76
+ height={300}
77
+ padding={4}>
78
+ <VStack gap={4}>
79
+ <VStack gap={0.5}>
80
+ <Heading level={3}>Workspace files</Heading>
81
+ <Text type="supporting">Two sections, two edge policies</Text>
82
+ </VStack>
83
+
84
+ <VStack gap={2}>
85
+ <Text type="label" color="secondary">
86
+ Shared with you
87
+ </Text>
88
+ {/* Default overscroll="allow": a gesture that reaches this
89
+ section's end carries on scrolling the panel behind it. */}
90
+ <ScrollableArea
91
+ axis="block"
92
+ label="Shared with you"
93
+ height={150}
94
+ padding={2}
95
+ xstyle={styles.sectionFrame}>
96
+ <FileGrid files={SHARED} />
97
+ </ScrollableArea>
98
+ <Text type="supporting">
99
+ Scroll past the end and the panel keeps going.
100
+ </Text>
101
+ </VStack>
102
+
103
+ <VStack gap={2}>
104
+ <Text type="label" color="secondary">
105
+ Archived
106
+ </Text>
107
+ {/* overscroll="contain" stops the gesture at this section's
108
+ edge, so the panel behind it stays put. */}
109
+ <ScrollableArea
110
+ axis="block"
111
+ label="Archived"
112
+ overscroll="contain"
113
+ height={150}
114
+ padding={2}
115
+ xstyle={styles.sectionFrame}>
116
+ <FileGrid files={ARCHIVED} />
117
+ </ScrollableArea>
118
+ <Text type="supporting">
119
+ Scroll past the end and the panel stays where it is.
120
+ </Text>
121
+ </VStack>
122
+ </VStack>
123
+ </ScrollableArea>
124
+ </Card>
125
+ );
126
+ }
@@ -0,0 +1,15 @@
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: 'ScrollableArea',
7
+ name: 'ScrollableArea',
8
+ displayName: 'Scrollable Area',
9
+ description:
10
+ 'A fixed-height file panel that scrolls on the block axis; the heading sits inside the viewport, so it scrolls away with the content.',
11
+ isReady: true,
12
+ aspectRatio: 1,
13
+ isShowcase: true,
14
+ componentsUsed: ['ScrollableArea', 'Card', 'Grid'],
15
+ };
@@ -0,0 +1,86 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {ScrollableArea} from '@astryxdesign/core/ScrollableArea';
6
+ import {Card} from '@astryxdesign/core/Card';
7
+ import {Grid} from '@astryxdesign/core/Grid';
8
+ import {VStack} from '@astryxdesign/core/Layout';
9
+ import {Heading, Text} from '@astryxdesign/core/Text';
10
+
11
+ const SECTIONS = [
12
+ {
13
+ label: 'Recently opened',
14
+ files: [
15
+ {id: 'brief', title: 'Q3 launch brief', meta: 'Edited 2 days ago'},
16
+ {id: 'pricing', title: 'Pricing rework', meta: 'Edited 3 days ago'},
17
+ {
18
+ id: 'onboarding',
19
+ title: 'Onboarding flow v4',
20
+ meta: 'Edited 4 days ago',
21
+ },
22
+ {id: 'macros', title: 'Support macros', meta: 'Edited last week'},
23
+ ],
24
+ },
25
+ {
26
+ label: 'Shared with you',
27
+ files: [
28
+ {id: 'brand', title: 'Brand refresh', meta: 'Priya Raman'},
29
+ {id: 'checkout', title: 'Checkout audit', meta: 'Tomas Lindqvist'},
30
+ {id: 'partner', title: 'Partner deck', meta: 'Ines Okafor'},
31
+ {id: 'research', title: 'Research synthesis', meta: 'Mei Watanabe'},
32
+ ],
33
+ },
34
+ {
35
+ label: 'Archived',
36
+ files: [
37
+ {id: 'roadmap', title: '2025 roadmap', meta: 'Archived in March'},
38
+ {id: 'legacy', title: 'Legacy pricing', meta: 'Archived in March'},
39
+ {id: 'kit', title: 'Old brand kit', meta: 'Archived in January'},
40
+ {id: 'beta', title: 'Beta feedback', meta: 'Archived in January'},
41
+ ],
42
+ },
43
+ ];
44
+
45
+ export default function ScrollableAreaShowcase() {
46
+ return (
47
+ <Card width={380} padding={0}>
48
+ {/* The heading sits inside the viewport, so it scrolls away with the
49
+ content instead of staying pinned above it. */}
50
+ <ScrollableArea
51
+ axis="block"
52
+ role="region"
53
+ label="Workspace files"
54
+ height={300}
55
+ padding={4}>
56
+ <VStack gap={4}>
57
+ <VStack gap={0.5}>
58
+ <Heading level={3}>Workspace files</Heading>
59
+ <Text type="supporting">12 files across 3 sections</Text>
60
+ </VStack>
61
+ {SECTIONS.map(section => (
62
+ <VStack key={section.label} gap={2}>
63
+ <Text type="label" color="secondary">
64
+ {section.label}
65
+ </Text>
66
+ <Grid columns={2} gap={2}>
67
+ {section.files.map(file => (
68
+ <Card key={file.id} variant="muted" padding={3}>
69
+ <VStack gap={1}>
70
+ <Text weight="medium" maxLines={1}>
71
+ {file.title}
72
+ </Text>
73
+ <Text type="supporting" maxLines={1}>
74
+ {file.meta}
75
+ </Text>
76
+ </VStack>
77
+ </Card>
78
+ ))}
79
+ </Grid>
80
+ </VStack>
81
+ ))}
82
+ </VStack>
83
+ </ScrollableArea>
84
+ </Card>
85
+ );
86
+ }
@@ -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: 'ScrollableArea',
7
+ name: 'ScrollableArea — Sticky Section Labels',
8
+ displayName: 'Scrollable Area — Sticky Section Labels',
9
+ description:
10
+ 'A scrollable viewport is the containing block for position: sticky, so section labels pin to the top edge of the list instead of the page.',
11
+ isReady: true,
12
+ aspectRatio: 1,
13
+ componentsUsed: ['ScrollableArea', 'Card', 'Grid'],
14
+ };
@@ -0,0 +1,99 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import * as stylex from '@stylexjs/stylex';
6
+ import {ScrollableArea} from '@astryxdesign/core/ScrollableArea';
7
+ import {Card} from '@astryxdesign/core/Card';
8
+ import {Grid} from '@astryxdesign/core/Grid';
9
+ import {VStack} from '@astryxdesign/core/Layout';
10
+ import {Heading, Text} from '@astryxdesign/core/Text';
11
+ import {colorVars, spacingVars} from '@astryxdesign/core/theme/tokens.stylex';
12
+
13
+ const styles = stylex.create({
14
+ sectionLabel: {
15
+ position: 'sticky',
16
+ insetBlockStart: 0,
17
+ zIndex: 1,
18
+ backgroundColor: colorVars['--color-background-card'],
19
+ paddingBlock: spacingVars['--spacing-2'],
20
+ },
21
+ });
22
+
23
+ const SECTIONS = [
24
+ {
25
+ label: 'Recently opened',
26
+ files: [
27
+ {id: 'brief', title: 'Q3 launch brief', meta: 'Edited 2 days ago'},
28
+ {id: 'pricing', title: 'Pricing rework', meta: 'Edited 3 days ago'},
29
+ {
30
+ id: 'onboarding',
31
+ title: 'Onboarding flow v4',
32
+ meta: 'Edited 4 days ago',
33
+ },
34
+ {id: 'macros', title: 'Support macros', meta: 'Edited last week'},
35
+ ],
36
+ },
37
+ {
38
+ label: 'Shared with you',
39
+ files: [
40
+ {id: 'brand', title: 'Brand refresh', meta: 'Priya Raman'},
41
+ {id: 'checkout', title: 'Checkout audit', meta: 'Tomas Lindqvist'},
42
+ {id: 'partner', title: 'Partner deck', meta: 'Ines Okafor'},
43
+ {id: 'research', title: 'Research synthesis', meta: 'Mei Watanabe'},
44
+ ],
45
+ },
46
+ {
47
+ label: 'Archived',
48
+ files: [
49
+ {id: 'roadmap', title: '2025 roadmap', meta: 'Archived in March'},
50
+ {id: 'legacy', title: 'Legacy pricing', meta: 'Archived in March'},
51
+ {id: 'kit', title: 'Old brand kit', meta: 'Archived in January'},
52
+ {id: 'beta', title: 'Beta feedback', meta: 'Archived in January'},
53
+ ],
54
+ },
55
+ ];
56
+
57
+ export default function ScrollableAreaStickyGroupHeaders() {
58
+ return (
59
+ <Card width={380} padding={0}>
60
+ {/* The viewport is the containing block for position: sticky. The panel
61
+ heading is ordinary content and scrolls away; the section labels
62
+ below it pin to the top of the list, not the page. */}
63
+ <ScrollableArea
64
+ axis="block"
65
+ role="region"
66
+ label="Workspace files"
67
+ height={300}
68
+ padding={4}>
69
+ <VStack gap={0.5} paddingBlockEnd={2}>
70
+ <Heading level={3}>Workspace files</Heading>
71
+ <Text type="supporting">12 files across 3 sections</Text>
72
+ </VStack>
73
+ {SECTIONS.map(section => (
74
+ <section key={section.label}>
75
+ <div {...stylex.props(styles.sectionLabel)}>
76
+ <Text type="label" color="secondary">
77
+ {section.label}
78
+ </Text>
79
+ </div>
80
+ <Grid columns={2} gap={2}>
81
+ {section.files.map(file => (
82
+ <Card key={file.id} variant="muted" padding={3}>
83
+ <VStack gap={1}>
84
+ <Text weight="medium" maxLines={1}>
85
+ {file.title}
86
+ </Text>
87
+ <Text type="supporting" maxLines={1}>
88
+ {file.meta}
89
+ </Text>
90
+ </VStack>
91
+ </Card>
92
+ ))}
93
+ </Grid>
94
+ </section>
95
+ ))}
96
+ </ScrollableArea>
97
+ </Card>
98
+ );
99
+ }
@@ -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: 'ScrollableArea',
7
+ name: 'ScrollableArea — Sticky Passthrough',
8
+ displayName: 'Scrollable Area — Sticky Passthrough',
9
+ description:
10
+ 'A section whose content fits clips instead of scrolling, so its sticky label passes outward and pins to the panel edge. The next section sets stickyContainment="always" and keeps its label in its own box.',
11
+ isReady: true,
12
+ aspectRatio: 1,
13
+ componentsUsed: ['ScrollableArea', 'Card', 'Grid'],
14
+ };