@astryxdesign/cli 0.1.5 → 0.1.6-canary.02f2602
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/CHANGELOG.md +4 -0
- package/docs/integration-authoring.md +105 -0
- package/docs/internationalization.doc.mjs +243 -0
- package/package.json +13 -9
- package/src/api/integration-block-exports.test.mjs +240 -0
- package/src/api/template-suffix.test.mjs +246 -0
- package/src/api/template.mjs +104 -28
- package/src/api/validate-integration.mjs +0 -8
- package/src/config.mjs +5 -14
- package/src/doc.mjs +27 -0
- package/src/doc.test.mjs +383 -0
- package/src/integration.mjs +4 -15
- package/src/lib/component-discovery.importpath.test.mjs +59 -0
- package/src/lib/component-discovery.mjs +15 -5
- package/src/lib/component-format.mjs +45 -13
- package/src/lib/component-format.test.mjs +95 -1
- package/src/lib/component-loader.mjs +104 -2
- package/src/lib/componentDocOverlay.test.mjs +111 -0
- package/src/lib/config-schema.mjs +0 -30
- package/src/lib/hook-format.mjs +8 -3
- package/src/lib/xle/registry.mjs +0 -5
- package/src/schemas/doc-schema.mjs +226 -0
- package/src/schemas/template-schema.mjs +47 -0
- package/src/template.mjs +9 -67
- package/src/types/config.d.ts +11 -66
- package/src/types/doc.d.ts +23 -0
- package/src/types/integration.d.ts +7 -18
- package/src/types/template-api.d.ts +14 -50
- package/templates/blocks/components/Avatar/AvatarGroup.tsx +5 -7
- package/templates/blocks/components/Avatar/AvatarShowcase.tsx +4 -6
- package/templates/blocks/components/Avatar/AvatarUserCard.tsx +3 -5
- package/templates/blocks/components/Avatar/AvatarWithImage.tsx +8 -6
- package/templates/blocks/components/Avatar/AvatarWithStatus.tsx +3 -5
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx +1 -1
- package/templates/blocks/components/Table/TableGroupedRowsTable.doc.mjs +14 -0
- package/templates/blocks/components/Table/TableGroupedRowsTable.tsx +66 -0
- package/templates/blocks/components/Table/TableRowIndexTable.doc.mjs +14 -0
- package/templates/blocks/components/Table/TableRowIndexTable.tsx +47 -0
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.doc.mjs +14 -0
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.tsx +41 -0
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.doc.mjs +13 -0
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.tsx +78 -0
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.doc.mjs +14 -0
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.tsx +38 -0
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +14 -0
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.tsx +47 -0
- package/templates/pages/theme-showcase/page.tsx +7 -7
- package/templates/themes/neutral/neutralTheme.ts +63 -32
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Template load-boundary schemas.
|
|
5
|
+
*
|
|
6
|
+
* The Zod schemas that integration template discovery runs a module's default
|
|
7
|
+
* export through (see `loadModuleWithSchema`). Kept free of any
|
|
8
|
+
* `@astryxdesign/core` import so the hot path that loads them (template
|
|
9
|
+
* discovery, `astryx init`) does not require core's built `dist/`. The
|
|
10
|
+
* authoring factories live in `@astryxdesign/core/authoring` and are re-exported
|
|
11
|
+
* from `../template.mjs` for the public `@astryxdesign/cli/template` surface.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {z} from 'zod';
|
|
15
|
+
|
|
16
|
+
const PreviewSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
image: z.string().optional(),
|
|
19
|
+
aspectRatio: z.string().optional(),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Shared authored-template shape. `type` is injected by the create* helpers,
|
|
25
|
+
* so authors never write it. Inline source/sourceFile are intentionally NOT
|
|
26
|
+
* part of v1 — a template's source is the required same-stem sibling file.
|
|
27
|
+
* Exported so integration template discovery can validate the stamped result.
|
|
28
|
+
*/
|
|
29
|
+
export const BaseTemplateSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
name: z.string().min(1, 'name is required'),
|
|
32
|
+
description: z.string().min(1, 'description is required'),
|
|
33
|
+
category: z.string().optional(),
|
|
34
|
+
componentsUsed: z.array(z.string()).optional(),
|
|
35
|
+
preview: PreviewSchema.optional(),
|
|
36
|
+
})
|
|
37
|
+
.strict();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The metadata envelope integration template discovery validates: a stamped
|
|
41
|
+
* template doc. This is the LOAD-boundary contract — a hand-written plain
|
|
42
|
+
* object that matches this shape is accepted (discovery does not check "was it
|
|
43
|
+
* made by the factory", only the shape).
|
|
44
|
+
*/
|
|
45
|
+
export const TemplateEnvelopeSchema = BaseTemplateSchema.extend({
|
|
46
|
+
type: z.enum(['page', 'block']),
|
|
47
|
+
});
|
package/src/template.mjs
CHANGED
|
@@ -1,73 +1,15 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Static template authoring API.
|
|
4
|
+
* @file Static template authoring API (public `@astryxdesign/cli/template`).
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* template discovery runs the module's default export through
|
|
13
|
-
* {@link TemplateEnvelopeSchema} (see `loadModuleWithSchema`).
|
|
6
|
+
* The `createPageTemplate`/`createBlockTemplate` authoring helpers now live in
|
|
7
|
+
* `@astryxdesign/core/authoring` and are re-exported here so existing
|
|
8
|
+
* `@astryxdesign/cli/template` imports keep working. The Zod load-boundary
|
|
9
|
+
* schemas live in `./schemas/template-schema.mjs` (core-free) and are
|
|
10
|
+
* re-exported here for back-compat; internal hot-path code imports them from
|
|
11
|
+
* the schema module directly so it never depends on core's built `dist/`.
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const PreviewSchema = z
|
|
19
|
-
.object({
|
|
20
|
-
image: z.string().optional(),
|
|
21
|
-
aspectRatio: z.string().optional(),
|
|
22
|
-
})
|
|
23
|
-
.strict();
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Shared authored-template shape. `type` is injected by the create* helpers,
|
|
27
|
-
* so authors never write it. Inline source/sourceFile are intentionally NOT
|
|
28
|
-
* part of v1 — a template's source is the required same-stem sibling file.
|
|
29
|
-
* Exported so integration template discovery can validate the stamped result.
|
|
30
|
-
*/
|
|
31
|
-
export const BaseTemplateSchema = z
|
|
32
|
-
.object({
|
|
33
|
-
name: z.string().min(1, 'name is required'),
|
|
34
|
-
description: z.string().min(1, 'description is required'),
|
|
35
|
-
category: z.string().optional(),
|
|
36
|
-
componentsUsed: z.array(z.string()).optional(),
|
|
37
|
-
preview: PreviewSchema.optional(),
|
|
38
|
-
})
|
|
39
|
-
.strict();
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The metadata envelope integration template discovery validates: a stamped
|
|
43
|
-
* template doc. This is the LOAD-boundary contract — a hand-written plain
|
|
44
|
-
* object that matches this shape is accepted (discovery does not check "was it
|
|
45
|
-
* made by the factory", only the shape).
|
|
46
|
-
*/
|
|
47
|
-
export const TemplateEnvelopeSchema = BaseTemplateSchema.extend({
|
|
48
|
-
type: z.enum(['page', 'block']),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Author an Astryx page template doc. Stamp-only: returns the def with
|
|
53
|
-
* `type: 'page'` injected. Validation happens at the load boundary.
|
|
54
|
-
*
|
|
55
|
-
* @template {import('./types/template-api').AstryxPageTemplateInput} T
|
|
56
|
-
* @param {T} def
|
|
57
|
-
* @returns {T & {type: 'page'}}
|
|
58
|
-
*/
|
|
59
|
-
export function createPageTemplate(def) {
|
|
60
|
-
return /** @type {T & {type: 'page'}} */ ({...def, type: 'page'});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Author an Astryx block template doc. Stamp-only: returns the def with
|
|
65
|
-
* `type: 'block'` injected. Validation happens at the load boundary.
|
|
66
|
-
*
|
|
67
|
-
* @template {import('./types/template-api').AstryxBlockTemplateInput} T
|
|
68
|
-
* @param {T} def
|
|
69
|
-
* @returns {T & {type: 'block'}}
|
|
70
|
-
*/
|
|
71
|
-
export function createBlockTemplate(def) {
|
|
72
|
-
return /** @type {T & {type: 'block'}} */ ({...def, type: 'block'});
|
|
73
|
-
}
|
|
14
|
+
export {createPageTemplate, createBlockTemplate} from '@astryxdesign/core/authoring';
|
|
15
|
+
export {BaseTemplateSchema, TemplateEnvelopeSchema} from './schemas/template-schema.mjs';
|
package/src/types/config.d.ts
CHANGED
|
@@ -1,70 +1,15 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The config-authoring surface moved to `@astryxdesign/core/config` so an app's
|
|
5
|
+
* config file gets type feedback without depending on the CLI. Re-exported here
|
|
6
|
+
* so existing `@astryxdesign/cli/config` type imports keep resolving.
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* A post-codemod hook. `buildCommand` receives the package directory and the
|
|
19
|
-
* list of files changed by codemods, and returns the command to run (or a
|
|
20
|
-
* nullish value to skip).
|
|
21
|
-
*/
|
|
22
|
-
export type PostCodemodHook = {
|
|
23
|
-
name?: string;
|
|
24
|
-
buildCommand: (ctx: {
|
|
25
|
-
packageDir: string;
|
|
26
|
-
files: string[];
|
|
27
|
-
}) =>
|
|
28
|
-
| PostCodemodCommand
|
|
29
|
-
| null
|
|
30
|
-
| undefined
|
|
31
|
-
| Promise<PostCodemodCommand | null | undefined>;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** A component XLE layout expressions can reference by name via `{hint}`. */
|
|
35
|
-
export interface XleComponent {
|
|
36
|
-
/** Import specifier the component is imported from, e.g. '@/components/KpiCard'. */
|
|
37
|
-
from: string;
|
|
38
|
-
/** Optional human description shown in tooling. */
|
|
39
|
-
description?: string;
|
|
40
|
-
/** Import as the module's default export instead of a named export. Defaults to false. */
|
|
41
|
-
default?: boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** User config exported from astryx.config.{ts,mjs,js}. */
|
|
45
|
-
export interface AstryxConfig {
|
|
46
|
-
/** Integration package names to load. */
|
|
47
|
-
integrations?: string[];
|
|
48
|
-
/** Where to file issues/feedback for this project. */
|
|
49
|
-
issuesUrl?: string;
|
|
50
|
-
/** Lifecycle hooks. */
|
|
51
|
-
hooks?: {
|
|
52
|
-
postCodemod?: PostCodemodHook[];
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* EXPERIMENTAL — shape may change and is not part of the stable config
|
|
56
|
-
* contract. Provisional home for features still being proven out.
|
|
57
|
-
*/
|
|
58
|
-
experimental?: {
|
|
59
|
-
/** Experimental XLE (layout expression) configuration. */
|
|
60
|
-
xle?: {
|
|
61
|
-
/**
|
|
62
|
-
* Register app-local components so XLE layout expressions can
|
|
63
|
-
* reference them by name via {hint}. Keyed by component name.
|
|
64
|
-
*/
|
|
65
|
-
components?: Record<string, XleComponent>;
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export declare function createConfig<T extends AstryxConfig>(config: T): T;
|
|
8
|
+
export type {
|
|
9
|
+
PostCodemodCommand,
|
|
10
|
+
PostCodemodHook,
|
|
11
|
+
XleComponent,
|
|
12
|
+
AstryxConfig,
|
|
13
|
+
} from '@astryxdesign/core/config';
|
|
14
|
+
|
|
15
|
+
export {createConfig} from '@astryxdesign/core/config';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The doc-authoring surface moved to `@astryxdesign/core/authoring`. Re-exported
|
|
5
|
+
* here so existing `@astryxdesign/cli/doc` type imports keep resolving. The Zod
|
|
6
|
+
* load-boundary schemas remain in the CLI (see `src/doc.mjs`).
|
|
7
|
+
*/
|
|
8
|
+
export type {
|
|
9
|
+
AstryxBaseDocInput,
|
|
10
|
+
AstryxPropInput,
|
|
11
|
+
AstryxParamInput,
|
|
12
|
+
AstryxReturnInput,
|
|
13
|
+
AstryxComponentDocInput,
|
|
14
|
+
AstryxFunctionDocInput,
|
|
15
|
+
AstryxGenericDocInput,
|
|
16
|
+
AstryxComponentDoc,
|
|
17
|
+
} from '@astryxdesign/core/authoring';
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
createComponentDoc,
|
|
21
|
+
createFunctionDoc,
|
|
22
|
+
createDoc,
|
|
23
|
+
} from '@astryxdesign/core/authoring';
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* The integration-manifest authoring surface moved to
|
|
5
|
+
* `@astryxdesign/core/authoring`. `AstryxIntegration` and `createIntegration`
|
|
6
|
+
* are re-exported here so existing `@astryxdesign/cli/integration` type imports
|
|
7
|
+
* keep resolving. `AstryxIntegrationIssue` stays in the CLI — it is an internal
|
|
8
|
+
* validation type, not part of the authoring surface.
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
components?: string;
|
|
12
|
-
/** Relative path to the templates root (resolved to absolute). */
|
|
13
|
-
templates?: string;
|
|
14
|
-
/** Relative path to the codemods root (resolved to absolute). */
|
|
15
|
-
codemods?: string;
|
|
16
|
-
/** Where to file issues/feedback for this integration. */
|
|
17
|
-
issuesUrl?: string;
|
|
18
|
-
}
|
|
10
|
+
export type {AstryxIntegration} from '@astryxdesign/core/authoring';
|
|
11
|
+
export {createIntegration} from '@astryxdesign/core/authoring';
|
|
19
12
|
|
|
20
13
|
/** An issue surfaced by an integration. */
|
|
21
14
|
export interface AstryxIntegrationIssue {
|
|
@@ -23,7 +16,3 @@ export interface AstryxIntegrationIssue {
|
|
|
23
16
|
severity: 'warning' | 'error';
|
|
24
17
|
message: string;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
export declare function createIntegration<T extends AstryxIntegration>(
|
|
28
|
-
integration: T,
|
|
29
|
-
): T;
|
|
@@ -1,54 +1,18 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* `@astryxdesign/cli/template
|
|
6
|
-
*
|
|
7
|
-
* A template doc lives in a `<id>.doc.{ts,mjs,js}` file with a required
|
|
8
|
-
* same-stem sibling source file (`<id>.tsx`). The doc's `type` (page or
|
|
9
|
-
* block) — injected by the create* helpers — decides how the template is
|
|
10
|
-
* scaffolded; there is no `/pages` vs `/blocks` directory requirement.
|
|
4
|
+
* The template-authoring surface moved to `@astryxdesign/core/authoring`.
|
|
5
|
+
* Re-exported here so existing `@astryxdesign/cli/template` type imports keep
|
|
6
|
+
* resolving.
|
|
11
7
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
/** Human-readable template name. Required. */
|
|
24
|
-
name: string;
|
|
25
|
-
/** One-line description of what the template provides. Required. */
|
|
26
|
-
description: string;
|
|
27
|
-
/** Optional grouping/category label. */
|
|
28
|
-
category?: string;
|
|
29
|
-
/** Component display names the template composes. */
|
|
30
|
-
componentsUsed?: string[];
|
|
31
|
-
/** Optional preview metadata. */
|
|
32
|
-
preview?: AstryxTemplatePreview;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Input accepted by {@link createPageTemplate} (no `type` field). */
|
|
36
|
-
export type AstryxPageTemplateInput = AstryxTemplateInput;
|
|
37
|
-
/** Input accepted by {@link createBlockTemplate} (no `type` field). */
|
|
38
|
-
export type AstryxBlockTemplateInput = AstryxTemplateInput;
|
|
39
|
-
|
|
40
|
-
/** A validated page template doc. */
|
|
41
|
-
export type AstryxPageTemplate = AstryxTemplateInput & {type: 'page'};
|
|
42
|
-
/** A validated block template doc. */
|
|
43
|
-
export type AstryxBlockTemplate = AstryxTemplateInput & {type: 'block'};
|
|
44
|
-
|
|
45
|
-
/** A validated template doc (page or block). */
|
|
46
|
-
export type AstryxTemplate = AstryxPageTemplate | AstryxBlockTemplate;
|
|
47
|
-
|
|
48
|
-
export declare function createPageTemplate<T extends AstryxPageTemplateInput>(
|
|
49
|
-
def: T,
|
|
50
|
-
): T & {type: 'page'};
|
|
51
|
-
|
|
52
|
-
export declare function createBlockTemplate<T extends AstryxBlockTemplateInput>(
|
|
53
|
-
def: T,
|
|
54
|
-
): T & {type: 'block'};
|
|
8
|
+
export type {
|
|
9
|
+
AstryxTemplatePreview,
|
|
10
|
+
AstryxTemplateInput,
|
|
11
|
+
AstryxPageTemplateInput,
|
|
12
|
+
AstryxBlockTemplateInput,
|
|
13
|
+
AstryxPageTemplate,
|
|
14
|
+
AstryxBlockTemplate,
|
|
15
|
+
AstryxTemplate,
|
|
16
|
+
} from '@astryxdesign/core/authoring';
|
|
17
|
+
|
|
18
|
+
export {createPageTemplate, createBlockTemplate} from '@astryxdesign/core/authoring';
|
|
@@ -7,28 +7,26 @@ import {AvatarGroup, AvatarGroupOverflow} from '@astryxdesign/core/AvatarGroup';
|
|
|
7
7
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
8
8
|
import {Text} from '@astryxdesign/core/Text';
|
|
9
9
|
|
|
10
|
-
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
11
|
-
|
|
12
10
|
const USERS = [
|
|
13
11
|
{
|
|
14
12
|
name: 'Ami Pena',
|
|
15
|
-
src:
|
|
13
|
+
src: 'https://lookaside.facebook.com/assets/astryx/DATA-Ami-Pena.png',
|
|
16
14
|
},
|
|
17
15
|
{
|
|
18
16
|
name: 'Drew Young',
|
|
19
|
-
src:
|
|
17
|
+
src: 'https://lookaside.facebook.com/assets/astryx/DATA-Drew-Young.png',
|
|
20
18
|
},
|
|
21
19
|
{
|
|
22
20
|
name: 'Gabriela Fernandez',
|
|
23
|
-
src:
|
|
21
|
+
src: 'https://lookaside.facebook.com/assets/astryx/DATA-Gabriela-Fernandez.png',
|
|
24
22
|
},
|
|
25
23
|
{
|
|
26
24
|
name: 'Jihoo Song',
|
|
27
|
-
src:
|
|
25
|
+
src: 'https://lookaside.facebook.com/assets/astryx/DATA-Jihoo-Song.png',
|
|
28
26
|
},
|
|
29
27
|
{
|
|
30
28
|
name: 'Nam Tran',
|
|
31
|
-
src:
|
|
29
|
+
src: 'https://lookaside.facebook.com/assets/astryx/DATA-Nam-Tran.png',
|
|
32
30
|
},
|
|
33
31
|
];
|
|
34
32
|
|
|
@@ -5,29 +5,27 @@
|
|
|
5
5
|
import {Avatar, AvatarStatusDot} from '@astryxdesign/core/Avatar';
|
|
6
6
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
7
7
|
|
|
8
|
-
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
9
|
-
|
|
10
8
|
export default function AvatarShowcase() {
|
|
11
9
|
return (
|
|
12
10
|
<Stack direction="horizontal" gap={4} vAlign="center">
|
|
13
11
|
<Avatar
|
|
14
|
-
src=
|
|
12
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Ana-Thomas.png"
|
|
15
13
|
name="Ana Thomas"
|
|
16
14
|
size="large"
|
|
17
15
|
status={<AvatarStatusDot variant="success" label="Online" />}
|
|
18
16
|
/>
|
|
19
17
|
<Avatar
|
|
20
|
-
src=
|
|
18
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Drew-Young.png"
|
|
21
19
|
name="Drew Young"
|
|
22
20
|
size="large"
|
|
23
21
|
/>
|
|
24
22
|
<Avatar
|
|
25
|
-
src=
|
|
23
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Jihoo-Song.png"
|
|
26
24
|
name="Jihoo Song"
|
|
27
25
|
size="large"
|
|
28
26
|
/>
|
|
29
27
|
<Avatar
|
|
30
|
-
src=
|
|
28
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Nam-Tran.png"
|
|
31
29
|
name="Nam Tran"
|
|
32
30
|
size="large"
|
|
33
31
|
status={<AvatarStatusDot variant="error" label="Online" />}
|
|
@@ -6,24 +6,22 @@ import {Avatar, AvatarStatusDot} from '@astryxdesign/core/Avatar';
|
|
|
6
6
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
7
7
|
import {Text} from '@astryxdesign/core/Text';
|
|
8
8
|
|
|
9
|
-
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
10
|
-
|
|
11
9
|
const USERS = [
|
|
12
10
|
{
|
|
13
11
|
name: 'Itai Jordaan',
|
|
14
|
-
src:
|
|
12
|
+
src: 'https://lookaside.facebook.com/assets/astryx/DATA-Itai-Jordaan.png',
|
|
15
13
|
role: 'Engineering Lead',
|
|
16
14
|
variant: 'success' as const,
|
|
17
15
|
},
|
|
18
16
|
{
|
|
19
17
|
name: 'Margot Schroder',
|
|
20
|
-
src:
|
|
18
|
+
src: 'https://lookaside.facebook.com/assets/astryx/DATA-Margot-Schroder.png',
|
|
21
19
|
role: 'Product Designer',
|
|
22
20
|
variant: 'neutral' as const,
|
|
23
21
|
},
|
|
24
22
|
{
|
|
25
23
|
name: 'Daniela Gimenez',
|
|
26
|
-
src:
|
|
24
|
+
src: 'https://lookaside.facebook.com/assets/astryx/DATA-Daniela-Gimenez.png',
|
|
27
25
|
role: 'Engineering Manager',
|
|
28
26
|
variant: 'error' as const,
|
|
29
27
|
},
|
|
@@ -5,24 +5,26 @@
|
|
|
5
5
|
import {Avatar} from '@astryxdesign/core/Avatar';
|
|
6
6
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
7
7
|
|
|
8
|
-
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
9
|
-
|
|
10
8
|
export default function AvatarWithImage() {
|
|
11
9
|
return (
|
|
12
10
|
<Stack direction="horizontal" gap={4} vAlign="center">
|
|
13
|
-
<Avatar src={`${CDN}/DATA-Ami-Pena.png`} name="Ami Pena" size="tiny" />
|
|
14
11
|
<Avatar
|
|
15
|
-
src=
|
|
12
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Ami-Pena.png"
|
|
13
|
+
name="Ami Pena"
|
|
14
|
+
size="tiny"
|
|
15
|
+
/>
|
|
16
|
+
<Avatar
|
|
17
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Ana-Thomas.png"
|
|
16
18
|
name="Ana Thomas"
|
|
17
19
|
size="small"
|
|
18
20
|
/>
|
|
19
21
|
<Avatar
|
|
20
|
-
src=
|
|
22
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Daniela-Gimenez.png"
|
|
21
23
|
name="Daniela Gimenez"
|
|
22
24
|
size="medium"
|
|
23
25
|
/>
|
|
24
26
|
<Avatar
|
|
25
|
-
src=
|
|
27
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Gabriela-Fernandez.png"
|
|
26
28
|
name="Gabriela Fernandez"
|
|
27
29
|
size="large"
|
|
28
30
|
/>
|
|
@@ -5,25 +5,23 @@
|
|
|
5
5
|
import {Avatar, AvatarStatusDot} from '@astryxdesign/core/Avatar';
|
|
6
6
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
7
7
|
|
|
8
|
-
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
9
|
-
|
|
10
8
|
export default function AvatarWithStatus() {
|
|
11
9
|
return (
|
|
12
10
|
<Stack direction="horizontal" gap={4} vAlign="center">
|
|
13
11
|
<Avatar
|
|
14
|
-
src=
|
|
12
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Itai-Jordaan.png"
|
|
15
13
|
name="Itai Jordaan"
|
|
16
14
|
size="large"
|
|
17
15
|
status={<AvatarStatusDot variant="success" label="Online" />}
|
|
18
16
|
/>
|
|
19
17
|
<Avatar
|
|
20
|
-
src=
|
|
18
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Margot-Schroder.png"
|
|
21
19
|
name="Margot Schroder"
|
|
22
20
|
size="large"
|
|
23
21
|
status={<AvatarStatusDot variant="neutral" label="Offline" />}
|
|
24
22
|
/>
|
|
25
23
|
<Avatar
|
|
26
|
-
src=
|
|
24
|
+
src="https://lookaside.facebook.com/assets/astryx/DATA-Pablo-Morales.png"
|
|
27
25
|
name="Pablo Morales"
|
|
28
26
|
size="large"
|
|
29
27
|
status={<AvatarStatusDot variant="error" label="Busy" />}
|
|
@@ -10,7 +10,7 @@ import {Text} from '@astryxdesign/core/Text';
|
|
|
10
10
|
export default function ChatComposerInputControlledInput() {
|
|
11
11
|
const [value, setValue] = useState('');
|
|
12
12
|
return (
|
|
13
|
-
<Stack direction="vertical" gap={3} style={{width:
|
|
13
|
+
<Stack direction="vertical" gap={3} style={{width: 450, maxWidth: '100%'}}>
|
|
14
14
|
<ChatComposer
|
|
15
15
|
onSubmit={() => setValue('')}
|
|
16
16
|
value={value}
|
|
@@ -7,7 +7,7 @@ import {Stack} from '@astryxdesign/core/Layout';
|
|
|
7
7
|
|
|
8
8
|
export default function ChatComposerInputDisabled() {
|
|
9
9
|
return (
|
|
10
|
-
<Stack direction="vertical" style={{width:
|
|
10
|
+
<Stack direction="vertical" style={{width: 450, maxWidth: '100%'}}>
|
|
11
11
|
<ChatComposer
|
|
12
12
|
onSubmit={() => {}}
|
|
13
13
|
isDisabled
|
|
@@ -43,7 +43,7 @@ export default function ChatComposerInputMentionTrigger() {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
|
-
<Stack direction="vertical" gap={3} style={{width:
|
|
46
|
+
<Stack direction="vertical" gap={3} style={{width: 450, maxWidth: '100%'}}>
|
|
47
47
|
<ChatComposer
|
|
48
48
|
onSubmit={() => setValue('')}
|
|
49
49
|
input={
|
|
@@ -54,7 +54,7 @@ export default function ChatComposerInputMultipleTriggers() {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
|
-
<Stack direction="vertical" gap={3} style={{width:
|
|
57
|
+
<Stack direction="vertical" gap={3} style={{width: 450, maxWidth: '100%'}}>
|
|
58
58
|
<Text type="supporting" color="secondary">
|
|
59
59
|
Type @ for mentions (blue) or / for commands (yellow)
|
|
60
60
|
</Text>
|
|
@@ -7,7 +7,7 @@ import {Stack} from '@astryxdesign/core/Layout';
|
|
|
7
7
|
|
|
8
8
|
export default function ChatComposerInputShowcase() {
|
|
9
9
|
return (
|
|
10
|
-
<Stack direction="vertical" style={{width:
|
|
10
|
+
<Stack direction="vertical" style={{width: 450, maxWidth: '100%'}}>
|
|
11
11
|
<ChatComposer
|
|
12
12
|
onSubmit={() => {}}
|
|
13
13
|
input={
|
|
@@ -40,7 +40,7 @@ export default function ChatComposerInputSlashCommands() {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
|
-
<Stack direction="vertical" style={{width:
|
|
43
|
+
<Stack direction="vertical" style={{width: 450, maxWidth: '100%'}}>
|
|
44
44
|
<ChatComposer
|
|
45
45
|
onSubmit={() => {}}
|
|
46
46
|
input={
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
|
|
4
|
+
export const doc = {
|
|
5
|
+
type: 'block',
|
|
6
|
+
exampleFor: 'useTableGroupedRows',
|
|
7
|
+
name: 'useTableGroupedRows — Collapsible Groups',
|
|
8
|
+
displayName: 'useTableGroupedRows — Collapsible Groups',
|
|
9
|
+
description:
|
|
10
|
+
'A table grouped into collapsible sections with useTableGroupedRows. Each group gets a full-width header with a chevron, label, and member count; click to collapse/expand.',
|
|
11
|
+
isReady: true,
|
|
12
|
+
aspectRatio: 16 / 9,
|
|
13
|
+
componentsUsed: ['Table'],
|
|
14
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useState, useCallback} from 'react';
|
|
6
|
+
import {
|
|
7
|
+
Table,
|
|
8
|
+
useTableGroupedRows,
|
|
9
|
+
proportional,
|
|
10
|
+
pixel,
|
|
11
|
+
} from '@astryxdesign/core/Table';
|
|
12
|
+
import type {TableColumn} from '@astryxdesign/core/Table';
|
|
13
|
+
|
|
14
|
+
interface Person extends Record<string, unknown> {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
team: string;
|
|
18
|
+
role: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const people: Person[] = [
|
|
22
|
+
{id: '1', name: 'Ava Chen', team: 'Design Systems', role: 'Staff Eng'},
|
|
23
|
+
{id: '2', name: 'Liam Park', team: 'Design Systems', role: 'Engineer'},
|
|
24
|
+
{id: '3', name: 'Zoe Vega', team: 'Design Systems', role: 'Manager'},
|
|
25
|
+
{id: '4', name: 'Max Ross', team: 'Infra', role: 'Senior Eng'},
|
|
26
|
+
{id: '5', name: 'Mia Cole', team: 'Infra', role: 'Engineer'},
|
|
27
|
+
{id: '6', name: 'Leo Nash', team: 'Growth', role: 'PM'},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const columns: TableColumn<Person>[] = [
|
|
31
|
+
{key: 'name', header: 'Name', width: proportional(2)},
|
|
32
|
+
{key: 'role', header: 'Role', width: pixel(140)},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
export default function TableGroupedRowsTable() {
|
|
36
|
+
const [collapsedGroups, setCollapsed] = useState<Set<string>>(new Set());
|
|
37
|
+
const onToggleGroup = useCallback((key: string) => {
|
|
38
|
+
setCollapsed(prev => {
|
|
39
|
+
const next = new Set(prev);
|
|
40
|
+
if (next.has(key)) {
|
|
41
|
+
next.delete(key);
|
|
42
|
+
} else {
|
|
43
|
+
next.add(key);
|
|
44
|
+
}
|
|
45
|
+
return next;
|
|
46
|
+
});
|
|
47
|
+
}, []);
|
|
48
|
+
|
|
49
|
+
const grouped = useTableGroupedRows<Person>({
|
|
50
|
+
data: people,
|
|
51
|
+
groupBy: p => p.team,
|
|
52
|
+
collapsedGroups,
|
|
53
|
+
onToggleGroup,
|
|
54
|
+
getRowKey: p => p.id,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Table
|
|
59
|
+
data={grouped.data}
|
|
60
|
+
columns={columns}
|
|
61
|
+
idKey={grouped.idKey}
|
|
62
|
+
hasHover
|
|
63
|
+
plugins={{grouped: grouped.plugin}}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|