@astryxdesign/cli 0.7.10 → 0.7.11-canary.143a5de
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/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.doc.mjs +1 -1
- package/api/build/kit/rank.mjs +21 -4
- package/api/build/kit/signals.mjs +9 -3
- package/api/build/kit/start.d.mts +19 -0
- package/api/build/kit/start.mjs +49 -2
- package/api/build/kit/weights.d.mts +12 -0
- package/api/build/kit/weights.mjs +52 -16
- package/api/build/kit/words.d.mts +1 -0
- package/api/build/kit/words.mjs +1 -1
- package/api/docs/_adapter.mjs +2 -1
- package/api/doctor/_adapter.d.mts +28 -1
- package/api/doctor/_adapter.mjs +39 -2
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +9 -2
- package/api/doctor/theme-checks.d.mts +44 -3
- package/api/doctor/theme-checks.mjs +273 -6
- package/api/hook/hook.mjs +13 -0
- package/api/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +8 -2
- package/api/icon/_authoring.d.mts +1 -0
- package/api/icon/_authoring.mjs +362 -38
- package/api/icon/_default-look.d.mts +155 -0
- package/api/icon/_default-look.mjs +474 -0
- package/api/icon/_records.d.mts +1 -1
- package/api/icon/_records.mjs +1 -0
- package/api/icon/add/add.mjs +224 -38
- package/api/icon/icon.type.d.mts +7 -2
- package/api/icon/icon.type.mjs +4 -2
- package/api/icon/iconAdd.doc.mjs +2 -2
- package/api/icon/iconNewDefinition.doc.mjs +3 -2
- package/api/icon/iconNewSet.doc.mjs +4 -4
- package/api/icon/search/search.mjs +10 -9
- package/api/integration/add-helpers.d.mts +2 -1
- package/api/integration/add-helpers.mjs +5 -2
- package/api/integration/authoring-checks.d.mts +0 -2
- package/api/integration/authoring-checks.mjs +1 -6
- package/api/integration/pack-check.d.mts +8 -6
- package/api/integration/pack-check.mjs +16 -6
- package/api/logger.mjs +2 -1
- package/api/render/_adapter.mjs +47 -1
- package/api/render/render.doc.mjs +2 -1
- package/api/search/_gather-components.mjs +2 -1
- package/api/swizzle/copy/copy.mjs +5 -1
- package/api/theme/build/build.mjs +15 -4
- package/assets/docs/author-a-theme.doc.mjs +2 -0
- package/assets/docs/getting-started.doc.mjs +20 -0
- package/assets/docs/tree/building-blocks.doc.mjs +1 -0
- package/assets/docs/tree/global-integrations.doc.mjs +1 -0
- package/assets/docs/tree/help.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +9 -3
- package/assets/docs/tree/quick-start.doc.mjs +1 -0
- package/assets/docs/tree/render-pages.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +2 -2
- package/assets/templates/blocks/components/Table/TableLeadingMarkSelection.doc.mjs +15 -0
- package/assets/templates/blocks/components/Table/TableLeadingMarkSelection.tsx +134 -0
- package/assets/templates/pages/theme-showcase/page.tsx +724 -792
- package/assets/templates/pages/theme-showcase/template.doc.mjs +4 -5
- package/authoring/doctypes/_schema.d.mts +1 -1
- package/clients/cli/commands/build.doc.mjs +3 -2
- package/clients/cli/commands/build.mjs +34 -5
- package/clients/cli/commands/experimental/icon.mjs +31 -10
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +2 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
- package/clients/cli/index.mjs +36 -7
- package/foundation/discovery/authoring-self-docs.mjs +8 -3
- package/foundation/discovery/cli-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.mjs +16 -0
- package/foundation/discovery/doc-types.mjs +9 -2
- package/foundation/discovery/docs-discovery.mjs +6 -4
- package/foundation/discovery/icon-definition-discovery.mjs +3 -3
- package/foundation/discovery/icon-ranking.d.mts +27 -3
- package/foundation/discovery/icon-ranking.mjs +125 -8
- package/foundation/discovery/icon-set-checks.mjs +40 -20
- package/foundation/discovery/icon-set-writer.d.mts +210 -16
- package/foundation/discovery/icon-set-writer.mjs +619 -79
- package/foundation/discovery/module-exports.d.mts +92 -4
- package/foundation/discovery/module-exports.mjs +410 -61
- package/foundation/discovery/template-adapter.mjs +5 -7
- package/foundation/discovery/theme-discovery.mjs +8 -10
- package/foundation/doc-compiler/tree.mjs +2 -2
- package/foundation/env/package-manager.d.mts +12 -4
- package/foundation/env/package-manager.mjs +15 -6
- package/foundation/env/semver.mjs +41 -9
- package/foundation/fs/listing-cache.d.mts +3 -1
- package/foundation/fs/listing-cache.mjs +63 -11
- package/foundation/fs/paths.mjs +2 -1
- package/foundation/release/notices.d.mts +16 -0
- package/foundation/release/notices.mjs +27 -6
- package/foundation/render/embedded-imports.d.mts +7 -0
- package/foundation/render/embedded-imports.mjs +1 -1
- package/foundation/render/page-worker.mjs +109 -4
- package/foundation/render/render-page.d.mts +16 -1
- package/foundation/render/render-page.mjs +25 -18
- package/foundation/render/served-packages.d.mts +33 -0
- package/foundation/render/served-packages.mjs +75 -0
- package/foundation/render/single-copy-hooks.d.mts +18 -0
- package/foundation/render/single-copy-hooks.mjs +44 -0
- package/foundation/text/shell-arg.d.mts +14 -0
- package/foundation/text/shell-arg.mjs +17 -0
- package/foundation/text/string-utils.mjs +25 -25
- package/package.json +6 -6
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Compare generated theme outputs without making their build directory
|
|
6
|
-
* CLI/Core version look like source drift. Normalization
|
|
7
|
-
*
|
|
8
|
-
* well-formed Source, CLI, and Core line
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* Compare generated theme outputs without making their build directory,
|
|
6
|
+
* CLI/Core version, or build command look like source drift. Normalization
|
|
7
|
+
* applies only to a file whose first comment is the generated header with
|
|
8
|
+
* exactly one well-formed Source, CLI, and Core line; it covers those lines
|
|
9
|
+
* and, in a built module, the one `built by` line that names the command
|
|
10
|
+
* (`yarn astryx`, `pnpm exec astryx`, or a host's own). Missing, duplicate,
|
|
11
|
+
* malformed, reordered, or any other bytes stay significant. `theme build
|
|
12
|
+
* --check` deliberately stays strict.
|
|
11
13
|
* @param {string} content
|
|
12
14
|
*/
|
|
13
15
|
export function normalizeThemeVerifyForCompare(content: string): string;
|
|
@@ -99,14 +99,20 @@ const GENERATED_HEADER_LINE =
|
|
|
99
99
|
const SOURCE_LINE = /^( \* Source: )(\S(?:.*\S)?)(\s*)$/u;
|
|
100
100
|
const CLI_VERSION_LINE = /^( \* CLI: @astryxdesign\/cli@)(\S+)(\s*)$/u;
|
|
101
101
|
const CORE_VERSION_LINE = /^( \* Core: @astryxdesign\/core@)(\S+)(\s*)$/u;
|
|
102
|
+
// The built module's own doc comment names the command that built it, which
|
|
103
|
+
// depends on the package manager and host that ran the build.
|
|
104
|
+
const BUILT_BY_LINE =
|
|
105
|
+
/^( \* \S(?:.*\S)? theme — built by `)(\S(?:.*\S)?)( theme build`)(\s*)$/u;
|
|
102
106
|
|
|
103
107
|
/**
|
|
104
|
-
* Compare generated theme outputs without making their build directory
|
|
105
|
-
* CLI/Core version look like source drift. Normalization
|
|
106
|
-
*
|
|
107
|
-
* well-formed Source, CLI, and Core line
|
|
108
|
-
*
|
|
109
|
-
*
|
|
108
|
+
* Compare generated theme outputs without making their build directory,
|
|
109
|
+
* CLI/Core version, or build command look like source drift. Normalization
|
|
110
|
+
* applies only to a file whose first comment is the generated header with
|
|
111
|
+
* exactly one well-formed Source, CLI, and Core line; it covers those lines
|
|
112
|
+
* and, in a built module, the one `built by` line that names the command
|
|
113
|
+
* (`yarn astryx`, `pnpm exec astryx`, or a host's own). Missing, duplicate,
|
|
114
|
+
* malformed, reordered, or any other bytes stay significant. `theme build
|
|
115
|
+
* --check` deliberately stays strict.
|
|
110
116
|
* @param {string} content
|
|
111
117
|
*/
|
|
112
118
|
export function normalizeThemeVerifyForCompare(content) {
|
|
@@ -125,8 +131,12 @@ export function normalizeThemeVerifyForCompare(content) {
|
|
|
125
131
|
if (source.length !== 1 || cli.length !== 1 || core.length !== 1) {
|
|
126
132
|
return normalized;
|
|
127
133
|
}
|
|
134
|
+
const builtBy = lines.filter(line => BUILT_BY_LINE.test(line)).length;
|
|
128
135
|
return lines
|
|
129
136
|
.map((line, index) => {
|
|
137
|
+
if (builtBy === 1 && BUILT_BY_LINE.test(line)) {
|
|
138
|
+
return line.replace(BUILT_BY_LINE, '$1<command>$3$4');
|
|
139
|
+
}
|
|
130
140
|
if (index >= close) return line;
|
|
131
141
|
if (SOURCE_LINE.test(line)) {
|
|
132
142
|
return line.replace(SOURCE_LINE, '$1<source>$3');
|
package/api/logger.mjs
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file The one `Logger`. Source of truth: the `Logger` type is generated from
|
|
5
5
|
* the JSDoc here, and `logger` is the single instance every side-effecting
|
|
6
|
-
* command (`upgrade`, `init`, `themeBuild
|
|
6
|
+
* command (`upgrade`, `init`, `themeBuild`, the experimental icon commands)
|
|
7
|
+
* writes progress through.
|
|
7
8
|
*
|
|
8
9
|
* It is silent by default, so a programmatic caller (or `--json` mode) sees
|
|
9
10
|
* nothing but the returned `{type, data}`. The CLI calls `logger.setSilent(false)`
|
package/api/render/_adapter.mjs
CHANGED
|
@@ -26,6 +26,10 @@ import {isAstryxMarkup} from '../../foundation/render/html-reader.mjs';
|
|
|
26
26
|
import {rebuildPage} from '../../foundation/render/rebuild.mjs';
|
|
27
27
|
import {cliVersion} from '../../foundation/integrations/cli-peer-version.mjs';
|
|
28
28
|
import {assertWithin, PathSafetyError} from '../../foundation/fs/path-safety.mjs';
|
|
29
|
+
import {requireCoreDir} from '../../foundation/fs/paths.mjs';
|
|
30
|
+
import {runChoice} from '../../foundation/release/run-context.mjs';
|
|
31
|
+
import {isServedPackage} from '../../foundation/render/served-packages.mjs';
|
|
32
|
+
import {hostedRun, recordResolved} from '../../foundation/runtime/package-root.mjs';
|
|
29
33
|
|
|
30
34
|
export {PAGE_EXTENSIONS, embeddedPathProblem};
|
|
31
35
|
|
|
@@ -238,6 +242,29 @@ function asAstryxError(e) {
|
|
|
238
242
|
return e;
|
|
239
243
|
}
|
|
240
244
|
|
|
245
|
+
/**
|
|
246
|
+
* The package set the CLI runs from, for a page outside a project
|
|
247
|
+
* (architecture:cli-surface INV30): the Core it carries, found by the rule of
|
|
248
|
+
* every command that answers from Core outside a project. Inside a project
|
|
249
|
+
* (spec AST-081: a Core or CLI the folder reads, or a package.json that
|
|
250
|
+
* declares one) the project's packages serve the page alone, so this is
|
|
251
|
+
* null.
|
|
252
|
+
* When the carried Core cannot be had, the reason is kept for the error a
|
|
253
|
+
* page that needs it gets (spec AST-081 FR3).
|
|
254
|
+
* @param {string} input absolute path of the page
|
|
255
|
+
* @returns {{dir: string, integrations: readonly string[]} | {unavailable: Error} | null}
|
|
256
|
+
*/
|
|
257
|
+
function servedSet(input) {
|
|
258
|
+
const dir = path.dirname(input);
|
|
259
|
+
if (runChoice(dir).inProject) return null;
|
|
260
|
+
try {
|
|
261
|
+
return {dir: requireCoreDir(dir), integrations: hostedRun()?.integrations ?? []};
|
|
262
|
+
} catch (e) {
|
|
263
|
+
const err = /** @type {any} */ (e);
|
|
264
|
+
return err?.code === ERROR_CODES.ERR_VERSIONS_UNAVAILABLE ? {unavailable: err} : null;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
241
268
|
/**
|
|
242
269
|
* Render a page module to one HTML file and write it.
|
|
243
270
|
* @param {{cwd: string, input: string, output: string, title?: string}} args absolute paths
|
|
@@ -249,10 +276,29 @@ export async function renderToFile({cwd, input, output, title}) {
|
|
|
249
276
|
/** @type {import('../../foundation/render/render-page.mjs').RenderedPage} */
|
|
250
277
|
let page;
|
|
251
278
|
try {
|
|
252
|
-
|
|
279
|
+
const set = servedSet(input);
|
|
280
|
+
try {
|
|
281
|
+
page = await renderPage(input, {title, version: cliVersion(), served: set && 'dir' in set ? set : null});
|
|
282
|
+
} catch (e) {
|
|
283
|
+
// A page that needs the Core the CLI could not obtain says why.
|
|
284
|
+
const missing = /** @type {any} */ (e)?.code === 'ERR_RENDER_MISSING_DEPENDENCY' ? /** @type {any} */ (e).detail?.package : null;
|
|
285
|
+
if (set && 'unavailable' in set && typeof missing === 'string' && isServedPackage(missing, hostedRun()?.integrations ?? [])) {
|
|
286
|
+
throw new AstryxError(set.unavailable.message, [], ERROR_CODES.ERR_VERSIONS_UNAVAILABLE);
|
|
287
|
+
}
|
|
288
|
+
throw e;
|
|
289
|
+
}
|
|
253
290
|
} catch (e) {
|
|
254
291
|
throw asAstryxError(e);
|
|
255
292
|
}
|
|
293
|
+
for (const {name, dir} of page.fromSet) {
|
|
294
|
+
let version = null;
|
|
295
|
+
try {
|
|
296
|
+
version = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8')).version;
|
|
297
|
+
} catch {
|
|
298
|
+
// A package without a readable version is still named.
|
|
299
|
+
}
|
|
300
|
+
recordResolved(name, version, dir, 'package-set');
|
|
301
|
+
}
|
|
256
302
|
refuseProtected([output], cwd);
|
|
257
303
|
// An existing file is replaced only when a render wrote it.
|
|
258
304
|
if (
|
|
@@ -16,7 +16,7 @@ export const doc = {
|
|
|
16
16
|
summary:
|
|
17
17
|
'Render a page to one self-contained HTML file, or turn a rendered file back into a page.',
|
|
18
18
|
description:
|
|
19
|
-
"Renders the page module's default export on the server with the project's own React and Astryx components, and writes ONE static HTML file that needs nothing beside it: the page's own StyleX styles are compiled, Core's stylesheets are cut to the rules the markup uses (layer order, custom properties and keyframes kept), local images become data: URIs, and the page's source is embedded so it can be given back exactly. The file runs no script and loads nothing from the network, so it works inside a sandboxed frame with a strict content security policy, and its colors follow the viewer's light or dark scheme. Warnings name anything that may differ from what the author meant, such as a component that did not render the text it was given. With `reverse`, it writes the embedded source back byte for byte, and only the files a render embeds: the page and the local modules, stylesheets, JSON files and images it imports, into a new folder; a file with Astryx markup but no embedded source is rebuilt from its component class names and data attributes (text and layout only); any other file is refused. Experimental: it may change or be removed in a patch release.",
|
|
19
|
+
"Renders the page module's default export on the server with the project's own React and Astryx components (outside a project, with the Astryx, React and StyleX the CLI runs with), and writes ONE static HTML file that needs nothing beside it: the page's own StyleX styles are compiled, Core's stylesheets are cut to the rules the markup uses (layer order, custom properties and keyframes kept), local images become data: URIs, and the page's source is embedded so it can be given back exactly. The file runs no script and loads nothing from the network, so it works inside a sandboxed frame with a strict content security policy, and its colors follow the viewer's light or dark scheme. Warnings name anything that may differ from what the author meant, such as a component that did not render the text it was given. With `reverse`, it writes the embedded source back byte for byte, and only the files a render embeds: the page and the local modules, stylesheets, JSON files and images it imports, into a new folder; a file with Astryx markup but no embedded source is rebuilt from its component class names and data attributes (text and layout only); any other file is refused. Experimental: it may change or be removed in a patch release.",
|
|
20
20
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
21
21
|
signature:
|
|
22
22
|
'render(file: string, options?: RenderOptions): Promise<RenderPageResponse | RenderReverseResponse>',
|
|
@@ -92,6 +92,7 @@ export const doc = {
|
|
|
92
92
|
{code: 'ERR_RENDER_COMPILE', when: 'the page does not compile, or a stylesheet it imports is not valid CSS (the message names the file)'},
|
|
93
93
|
{code: 'ERR_RENDER_NO_DEFAULT_EXPORT', when: 'the page has no default export'},
|
|
94
94
|
{code: 'ERR_RENDER_MISSING_DEPENDENCY', when: 'the page imports a package that is not installed; the suggestion is its install line'},
|
|
95
|
+
{code: 'ERR_VERSIONS_UNAVAILABLE', when: 'outside a project, the page imports an Astryx package, React or StyleX, and the Core of the release that answers cannot be downloaded'},
|
|
95
96
|
{code: 'ERR_RENDER_BROWSER_API', when: 'the page reads a browser-only API, such as window or document, while rendering'},
|
|
96
97
|
{code: 'ERR_RENDER_ASSET_TOO_LARGE', when: 'a local file the page uses is over 8 MB'},
|
|
97
98
|
{code: 'ERR_RENDER_TIMEOUT', when: 'the page does not finish rendering within 60 seconds'},
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import {discoverExternalPackages} from '../../foundation/fs/paths.mjs';
|
|
11
|
+
import {listDir} from '../../foundation/fs/listing-cache.mjs';
|
|
11
12
|
import {
|
|
12
13
|
discoverComponents,
|
|
13
14
|
discoverValidIntegrationComponents,
|
|
@@ -103,7 +104,7 @@ async function gatherCoreComponents(coreDir) {
|
|
|
103
104
|
// A family doc with no component of its own name (Chat) names members too.
|
|
104
105
|
const srcDir = path.join(coreDir, 'src');
|
|
105
106
|
const listed = new Set(names);
|
|
106
|
-
for (const dir of fs.existsSync(srcDir) ?
|
|
107
|
+
for (const dir of fs.existsSync(srcDir) ? listDir(srcDir) : []) {
|
|
107
108
|
const doc = path.join(srcDir, dir, `${dir}.doc.mjs`);
|
|
108
109
|
if (listed.has(dir) || !fs.existsSync(doc)) continue;
|
|
109
110
|
for (const [n, place] of familyPlaces(await loadModuleDoc(doc)))
|
|
@@ -342,7 +342,11 @@ function confineWrite(target, cwd, options) {
|
|
|
342
342
|
/** @param {string} file */
|
|
343
343
|
function isExcludedFromCopy(file) {
|
|
344
344
|
return (
|
|
345
|
-
file.includes('.test.') ||
|
|
345
|
+
file.includes('.test.') ||
|
|
346
|
+
file.includes('.doc.') ||
|
|
347
|
+
file === 'README.md' ||
|
|
348
|
+
// Browser test harnesses import dev-only packages a consumer cannot resolve.
|
|
349
|
+
/\.spec\.[cm]?[jt]sx?$/.test(file)
|
|
346
350
|
);
|
|
347
351
|
}
|
|
348
352
|
|
|
@@ -925,17 +925,28 @@ async function loadKnownValuesIndex() {
|
|
|
925
925
|
return result;
|
|
926
926
|
};
|
|
927
927
|
|
|
928
|
+
// A component can appear in more than one doc: its own doc declares its
|
|
929
|
+
// props, and a parent doc can list it by name only. Merge every entry, so
|
|
930
|
+
// the result does not depend on the order the docs load in.
|
|
928
931
|
/** @type {Record<string, Record<string, Set<string>>>} */
|
|
929
932
|
const valuesByOwner = {};
|
|
933
|
+
/**
|
|
934
|
+
* @param {string} name
|
|
935
|
+
* @param {any[]} props
|
|
936
|
+
*/
|
|
937
|
+
const addOwnerValues = (name, props) => {
|
|
938
|
+
const owner = (valuesByOwner[targetName(name)] ??= {});
|
|
939
|
+
for (const [prop, values] of Object.entries(valuesFromProps(props))) {
|
|
940
|
+
owner[prop] = new Set([...(owner[prop] ?? []), ...values]);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
930
943
|
for (const doc of docs) {
|
|
931
944
|
if (typeof doc?.name === 'string') {
|
|
932
|
-
|
|
945
|
+
addOwnerValues(doc.name, doc.props);
|
|
933
946
|
}
|
|
934
947
|
for (const component of /** @type {any[]} */ (doc?.components ?? [])) {
|
|
935
948
|
if (typeof component?.name === 'string') {
|
|
936
|
-
|
|
937
|
-
component.props,
|
|
938
|
-
);
|
|
949
|
+
addOwnerValues(component.name, component.props);
|
|
939
950
|
}
|
|
940
951
|
}
|
|
941
952
|
}
|
|
@@ -15,6 +15,8 @@ export const docs = {
|
|
|
15
15
|
title: 'Custom themes',
|
|
16
16
|
content: [
|
|
17
17
|
{type: 'prose', text: "Use an installed built theme as the base for ordinary customization. Import it into your source and pass it as `extends` to `defineTheme({extends: importedTheme, ...})`. Build the result, then add the local slug. Only eject when you need to own and maintain a full source fork."},
|
|
18
|
+
{type: 'prose', text: "A local theme is a folder in `src/themes/<slug>/` holding a `<name>Theme.ts` source that exports `<name>Theme`, and a same-stem `<name>Theme.doc.mjs` descriptor that `theme add` reads. The stem must be a valid export name, so a hyphenated slug drops the hyphen: `brand-dark` lives in `src/themes/brand-dark/brandDarkTheme.ts` exporting `brandDarkTheme`, beside `brandDarkTheme.doc.mjs`. The descriptor's `name` is the folder's slug, and it must declare its type or `theme add` and `theme list` refuse it. {@command docs authoring theme-doc} lists every field."},
|
|
19
|
+
{type: 'code', lang: 'js', label: 'src/themes/brand-dark/brandDarkTheme.doc.mjs', code: "/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\nexport default {\n type: 'theme',\n name: 'brand-dark',\n displayName: 'Brand Dark',\n description: 'The brand accent, tuned for dark mode.',\n maintained: false,\n};"},
|
|
18
20
|
{type: 'code', lang: 'bash', label: 'Add to use, eject to fork', code: '{@command theme list}\n{@command theme add stone}\n{@command theme eject stone}\n{@command theme build src/themes/stone/stoneTheme.ts}\n{@command theme add stone}'},
|
|
19
21
|
{type: 'prose', text: "For an annotated map of the whole surface (every defineTheme field, the token families, and the component override syntax, each with the CLI command that prints its reference), run `{@command theme template}`. It writes `theme.template.ts` into your project to read and copy from (`{@command init --features theme}` writes it as part of project setup)."},
|
|
20
22
|
{type: 'prose', text: 'To apply a theme you created, see {@link generic:use-a-theme}. To generate colors from seed values, see the Palette section below. Before you eject a package theme instead, see when that fits in {@link generic:use-a-theme}.'},
|
|
@@ -64,6 +64,26 @@ export const docs = {
|
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
66
|
},
|
|
67
|
+
{
|
|
68
|
+
id: 'upgrade',
|
|
69
|
+
title: 'Upgrade',
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: 'prose',
|
|
73
|
+
text: 'Upgrade every Astryx package your app lists in one command, to the same release. Each theme names the exact Core release it works with, so a theme left on an older release no longer matches the new Core.',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: 'code',
|
|
77
|
+
lang: 'bash',
|
|
78
|
+
label: 'Terminal',
|
|
79
|
+
code: `{@pm install @astryxdesign/core@latest @astryxdesign/theme-neutral@latest @astryxdesign/cli@latest}\n{@command upgrade --from <old Core version> --apply}`,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'prose',
|
|
83
|
+
text: "Add every other Astryx package your app lists to the same command, and pass the Core version you had before to `--from`. If your package manager holds new releases back, exempt the whole `@astryxdesign/*` scope; in pnpm, `minimumReleaseAgeExclude: ['@astryxdesign/*']`. Exempting only some of its packages installs packages from different releases side by side.",
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
67
87
|
{
|
|
68
88
|
id: 'install-once',
|
|
69
89
|
title: 'Install once, use everywhere',
|
|
@@ -9,7 +9,7 @@ export const docs = {
|
|
|
9
9
|
placement: {parent: 'namespace:authoring', slot: 'guides', order: 40},
|
|
10
10
|
title: 'Help',
|
|
11
11
|
summary: 'Find a CLI message and how to fix it.',
|
|
12
|
-
keywords: ['help', 'troubleshooting', 'error'],
|
|
12
|
+
keywords: ['authoring', 'help', 'troubleshooting', 'error'],
|
|
13
13
|
slots: {
|
|
14
14
|
guides: {title: 'Help', accepts: {kinds: ['generic']}},
|
|
15
15
|
},
|
|
@@ -139,7 +139,7 @@ astryx experimental icon add --variant solid --from @heroicons/react/24/solid --
|
|
|
139
139
|
},
|
|
140
140
|
{
|
|
141
141
|
type: 'prose',
|
|
142
|
-
text: "A library that redraws its artwork for small sizes (Heroicons' 20px mini and 16px micro) ships each of those as its own set in its own package (their export names match the 24px ones), not as variants: a variant's size comes from CSS. `--variants` lists the variants; `--default-variant` names the one each icon's own export draws (the first variant
|
|
142
|
+
text: "A library that redraws its artwork for small sizes (Heroicons' 20px mini and 16px micro) ships each of those as its own set in its own package (their export names match the 24px ones), not as variants: a variant's size comes from CSS. `--variants` lists the variants; `--default-variant` names the one each icon's own export draws (when omitted, the look a library that names its looks draws; otherwise the set's current default, else, on a set without icons, the first variant; a set with icons changes it only with `--from`, and only in a library that names its looks). `--all` adds the variant for every icon whose id an export of `--from` has (`TrashIcon` in the solid module becomes `TrashSolidIcon`, the solid variant of `trash`), and the receipt lists the icons the module has no export for. Running it again changes nothing.",
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
145
|
type: 'prose',
|
|
@@ -177,7 +177,7 @@ astryx experimental icon add --variant solid --from @heroicons/react/24/solid --
|
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
type: 'prose',
|
|
180
|
-
text:
|
|
180
|
+
text: 'An optional render test you can copy. Save it inside your package directory and run it there, since it imports your package by name through its `exports`, and install `react-dom` first (`npm install -D react-dom`). A library may add its own classes beside yours, so it checks the class list. A component that writes its own `width` and `height` attributes (24, from a `size` prop, say) still fills its box when it passes `style` through to its svg: the `Icon` component and `themeIcons` size the svg with CSS, which overrides size attributes. The test checks that too.',
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
type: 'code',
|
|
@@ -191,6 +191,8 @@ for (const [name, Icon] of Object.entries(icons)) {
|
|
|
191
191
|
const html = renderToStaticMarkup(createElement(Icon, {className: 'x'}));
|
|
192
192
|
if (!/class="([^"]* )?x( [^"]*)?"/.test(html)) throw new Error(\`\${name} drops className\`);
|
|
193
193
|
if (!html.includes('currentColor')) throw new Error(\`\${name} has a fixed color\`);
|
|
194
|
+
const styled = renderToStaticMarkup(createElement(Icon, {style: {width: '1em'}}));
|
|
195
|
+
if (!styled.includes('width:1em')) throw new Error(\`\${name} drops style, so CSS cannot size it\`);
|
|
194
196
|
}`,
|
|
195
197
|
},
|
|
196
198
|
],
|
|
@@ -215,6 +217,10 @@ for (const [name, Icon] of Object.entries(icons)) {
|
|
|
215
217
|
'A subpath per style',
|
|
216
218
|
'`experimental icon add --variant solid --from @acme/glyph-library/solid --all` for every icon at once, or `experimental icon add Bin --from @acme/glyph-library/solid --id bin --variant solid` for one (the set must declare the variant: `new-set --variants`)',
|
|
217
219
|
],
|
|
220
|
+
[
|
|
221
|
+
'Every look in its export names (`XOutline24WGHT500Icon`, `XFilled24WGHT500Icon`)',
|
|
222
|
+
"`experimental icon new-set meta --from @acme/vector-icons` wraps each glyph once as `x` (`XIcon`), in the look `--default-variant` names or the library's usual default (outline, the middle weight). For another look: `experimental icon new-set meta --variants outline,filled` declares it in place, then `experimental icon add --variant filled --from @acme/vector-icons --all`",
|
|
223
|
+
],
|
|
218
224
|
[
|
|
219
225
|
'One file per icon, default export',
|
|
220
226
|
'`experimental icon add Rocket --from @acme/glyph-library/rocket --default --definition rocket`',
|
|
@@ -262,7 +268,7 @@ export function adapt(data) {
|
|
|
262
268
|
content: [
|
|
263
269
|
{
|
|
264
270
|
type: 'prose',
|
|
265
|
-
text:
|
|
271
|
+
text: "The generated module also exports `themeIcons`: one entry per built-in definition in `map`, each an element of your own icon, hidden from assistive technology and sized `1em` by its attributes and by CSS (its `style`), so it fills the theme's icon box even when your component writes its own size attributes. The CLI rewrites it on every `experimental icon add` and `experimental icon map`, so you never write it by hand, and `integration check` proves it matches `map`. A theme uses it in one line:",
|
|
266
272
|
},
|
|
267
273
|
{
|
|
268
274
|
type: 'code',
|
|
@@ -44,7 +44,7 @@ export const docs = {
|
|
|
44
44
|
content: [
|
|
45
45
|
{
|
|
46
46
|
type: 'prose',
|
|
47
|
-
text: 'Build the page with Astryx components as usual, then render it. The page module needs a default export; it renders on your machine with the React and Astryx packages your project installed.',
|
|
47
|
+
text: 'Build the page with Astryx components as usual, then render it. The page module needs a default export; it renders on your machine with the React and Astryx packages your project installed. Outside a project (no Astryx Core or CLI installed or declared for the folder), it renders with the Astryx, React and StyleX that the CLI itself runs with, so a single page file renders anywhere, a React app included.',
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
type: 'code',
|
|
@@ -9,7 +9,7 @@ export const docs = {
|
|
|
9
9
|
placement: {parent: 'namespace:authoring', slot: 'guides', order: 30},
|
|
10
10
|
title: 'Ship',
|
|
11
11
|
summary: 'Test, publish, and upgrade your package.',
|
|
12
|
-
keywords: ['ship', 'publish', 'release', 'upgrade'],
|
|
12
|
+
keywords: ['authoring', 'ship', 'publish', 'release', 'upgrade'],
|
|
13
13
|
slots: {
|
|
14
14
|
guides: {title: 'Ship', accepts: {kinds: ['generic']}},
|
|
15
15
|
},
|
|
@@ -45,7 +45,7 @@ export const docs = {
|
|
|
45
45
|
],
|
|
46
46
|
[
|
|
47
47
|
"--color-icon-<status>",
|
|
48
|
-
"Status icons on the page or a card. Defaults to the text colour.",
|
|
48
|
+
"Status icons and marks on the page or a card, such as a StatusDot. Defaults to the text colour.",
|
|
49
49
|
"—"
|
|
50
50
|
],
|
|
51
51
|
[
|
|
@@ -55,7 +55,7 @@ export const docs = {
|
|
|
55
55
|
],
|
|
56
56
|
[
|
|
57
57
|
"--color-<status>",
|
|
58
|
-
"Strong status fill, such as a Badge
|
|
58
|
+
"Strong status fill, such as a Badge.",
|
|
59
59
|
"--color-on-<status>"
|
|
60
60
|
],
|
|
61
61
|
[
|
|
@@ -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: 'useTableSelectionState',
|
|
7
|
+
alsoExampleFor: ['Table'],
|
|
8
|
+
name: 'Table — Selection in the Leading Mark',
|
|
9
|
+
displayName: 'Table — Selection in the Leading Mark',
|
|
10
|
+
description:
|
|
11
|
+
'Selection without a checkbox column: each item shows its avatar, and the checkbox takes the avatar slot while a mouse is over it, on keyboard focus, and everywhere once anything is selected; on touch screens it always shows. The state comes from useTableSelectionState, and the checkboxes render in the name column instead of the useTableSelection column, so checked items get no aria-selected or highlight; add them if needed.',
|
|
12
|
+
isReady: true,
|
|
13
|
+
aspectRatio: 16 / 9,
|
|
14
|
+
componentsUsed: ['Table', 'CheckboxInput', 'Avatar'],
|
|
15
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
import {useState} from 'react';
|
|
6
|
+
import * as stylex from '@stylexjs/stylex';
|
|
7
|
+
import {Avatar} from '@astryxdesign/core/Avatar';
|
|
8
|
+
import {CheckboxInput} from '@astryxdesign/core/CheckboxInput';
|
|
9
|
+
import {HStack} from '@astryxdesign/core/HStack';
|
|
10
|
+
import {useContainerReveal} from '@astryxdesign/core/hooks';
|
|
11
|
+
import {
|
|
12
|
+
Table,
|
|
13
|
+
proportional,
|
|
14
|
+
useTableSelectionState,
|
|
15
|
+
} from '@astryxdesign/core/Table';
|
|
16
|
+
import type {TableColumn} from '@astryxdesign/core/Table';
|
|
17
|
+
import {colorVars, spacingVars} from '@astryxdesign/core/theme/tokens.stylex';
|
|
18
|
+
import {mergeProps} from '@astryxdesign/core/utils';
|
|
19
|
+
|
|
20
|
+
interface Automation extends Record<string, unknown> {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
owner: string;
|
|
24
|
+
schedule: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const automations: Automation[] = [
|
|
28
|
+
{id: '1', name: 'Nightly backup', owner: 'Alice', schedule: 'Daily, 2:00'},
|
|
29
|
+
{id: '2', name: 'Weekly digest', owner: 'Bob', schedule: 'Mondays, 9:00'},
|
|
30
|
+
{id: '3', name: 'Cache warmup', owner: 'Diana', schedule: 'Hourly'},
|
|
31
|
+
{id: '4', name: 'Usage report', owner: 'Eve', schedule: 'Monthly, 1st'},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const styles = stylex.create({
|
|
35
|
+
mark: {
|
|
36
|
+
display: 'grid',
|
|
37
|
+
placeItems: 'center',
|
|
38
|
+
flexShrink: 0,
|
|
39
|
+
},
|
|
40
|
+
// A flex layer is exactly as tall as the 24px avatar; a block layer
|
|
41
|
+
// follows the taller line box and lets the avatar's edge show under the
|
|
42
|
+
// checkbox.
|
|
43
|
+
layer: {
|
|
44
|
+
gridArea: '1 / 1',
|
|
45
|
+
display: 'flex',
|
|
46
|
+
},
|
|
47
|
+
// The checkbox covers the avatar while it shows, so the two never read as
|
|
48
|
+
// one mark.
|
|
49
|
+
checkbox: {
|
|
50
|
+
borderRadius: '50%',
|
|
51
|
+
backgroundColor: colorVars['--color-background-surface'],
|
|
52
|
+
},
|
|
53
|
+
name: {
|
|
54
|
+
paddingInlineStart: spacingVars['--spacing-1'],
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export default function TableLeadingMarkSelection() {
|
|
59
|
+
const [selectedKeys, setSelectedKeys] = useState<Set<string>>(new Set());
|
|
60
|
+
// The mark reveals its checkbox on hover and keyboard focus, and always
|
|
61
|
+
// shows it on touch.
|
|
62
|
+
const {getContainerProps, getContentRevealProps} = useContainerReveal();
|
|
63
|
+
const {selectionConfig, selectionState} = useTableSelectionState<Automation>({
|
|
64
|
+
data: automations,
|
|
65
|
+
idKey: 'id',
|
|
66
|
+
selectedKeys,
|
|
67
|
+
setSelectedKeys,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const columns: TableColumn<Automation>[] = [
|
|
71
|
+
{
|
|
72
|
+
key: 'name',
|
|
73
|
+
header: (
|
|
74
|
+
<HStack gap={2} vAlign="center">
|
|
75
|
+
<CheckboxInput
|
|
76
|
+
label="Select all automations"
|
|
77
|
+
isLabelHidden
|
|
78
|
+
value={
|
|
79
|
+
selectionConfig.getIsAllSelected()
|
|
80
|
+
? true
|
|
81
|
+
: selectionConfig.getIsIndeterminate?.()
|
|
82
|
+
? 'indeterminate'
|
|
83
|
+
: false
|
|
84
|
+
}
|
|
85
|
+
onChange={checked =>
|
|
86
|
+
selectionConfig.onSelectAll({isAllSelected: checked})
|
|
87
|
+
}
|
|
88
|
+
/>
|
|
89
|
+
Automation
|
|
90
|
+
</HStack>
|
|
91
|
+
),
|
|
92
|
+
width: proportional(2),
|
|
93
|
+
renderCell: item => {
|
|
94
|
+
const isSelected = selectionConfig.getIsItemSelected(item);
|
|
95
|
+
return (
|
|
96
|
+
<HStack gap={2} vAlign="center">
|
|
97
|
+
<span
|
|
98
|
+
{...mergeProps(stylex.props(styles.mark), getContainerProps())}>
|
|
99
|
+
{selectionState.hasSelection ? null : (
|
|
100
|
+
<span {...stylex.props(styles.layer)}>
|
|
101
|
+
<Avatar name={item.owner} size="sm" tooltip={false} />
|
|
102
|
+
</span>
|
|
103
|
+
)}
|
|
104
|
+
<span
|
|
105
|
+
{...mergeProps(
|
|
106
|
+
stylex.props(styles.layer, styles.checkbox),
|
|
107
|
+
getContentRevealProps({
|
|
108
|
+
isLayoutPreserved: true,
|
|
109
|
+
forceVisibility: selectionState.hasSelection
|
|
110
|
+
? 'shown'
|
|
111
|
+
: undefined,
|
|
112
|
+
}),
|
|
113
|
+
)}>
|
|
114
|
+
<CheckboxInput
|
|
115
|
+
label={`Select ${item.name}`}
|
|
116
|
+
isLabelHidden
|
|
117
|
+
value={isSelected}
|
|
118
|
+
onChange={checked =>
|
|
119
|
+
selectionConfig.onSelectItem({item, isSelected: checked})
|
|
120
|
+
}
|
|
121
|
+
/>
|
|
122
|
+
</span>
|
|
123
|
+
</span>
|
|
124
|
+
<span {...stylex.props(styles.name)}>{item.name}</span>
|
|
125
|
+
</HStack>
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{key: 'owner', header: 'Owner', width: proportional(1)},
|
|
130
|
+
{key: 'schedule', header: 'Schedule', width: proportional(1)},
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
return <Table data={automations} columns={columns} idKey="id" />;
|
|
134
|
+
}
|