An open source design system that's fully customizable and agent ready
TypeScript
feat(Icon): request a theme's alternate icon artwork with variant (#8758)
Xinzi Zhou33645a2d27bf
diff --git a/.changeset/ast-087-icon-variant-prop.md b/.changeset/ast-087-icon-variant-prop.mdnew file mode 100644index 0000000000..24fe0aa051--- /dev/null+++ b/.changeset/ast-087-icon-variant-prop.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+'@astryxdesign/cli': patch+---++[feat] `Icon` takes an optional `variant` (an `IconVariant` name) that requests the active theme's alternate artwork for a semantic icon: `<Icon icon="info" variant="filled" />`. The theme's icon entry receives the variant only when the active theme lists it in `iconVariants` and, for an inherited entry, the theme that defined the entry lists it too; otherwise it receives `undefined` and draws its normal artwork. `astryx theme build` keeps each inherited entry's defining list, so a built theme passes the same variants as its runtime theme. A `registerIcons()` entry receives the variants the active theme lists, and a node entry ignores `variant`. An icon component passed directly never receives `variant`, and `variant` is never written to the DOM or reflected on the `icon` theming target. Icons without `variant` render as before.+@imdreamrunnerdiff --git a/packages/cli/api/theme/build/build.icon-entry-variants.test.mjs b/packages/cli/api/theme/build/build.icon-entry-variants.test.mjsnew file mode 100644index 0000000000..b6c1437060--- /dev/null+++ b/packages/cli/api/theme/build/build.icon-entry-variants.test.mjs@@ -0,0 +1,134 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file Built and runtime themes pass an inherited icon entry the same variants.+ * @input Real themeBuild calls on a base theme with a function icon entry and a+ * child that extends it with a wider `iconVariants` list.+ * @output A native ESM load renders `<Icon variant>` under the built child and+ * under the runtime child and compares the variant each entry received.+ * @position `architecture:theme-compilation` INV15 for `spec:AST-087` FR4: an+ * inherited entry keeps its defining theme's list, so a variant only the+ * child lists never reaches it, built or runtime. The node project's global+ * setup supplies the compiled core package.+ */++import {expect, it} from 'vitest';+import {execFileSync} from 'node:child_process';+import * as fs from 'node:fs';+import * as path from 'node:path';+import {themeBuild} from './build.mjs';++it('passes an inherited entry only its defining theme variants in a built child, as at runtime', async () => {+ const tmpDir = fs.mkdtempSync(+ path.resolve(import.meta.dirname, '../../..', '.tmp-icon-entry-variants-'),+ );+ try {+ for (const directory of ['base', 'child', 'unlisted']) {+ fs.mkdirSync(path.join(tmpDir, directory));+ }+ const write = (file, source) =>+ fs.writeFileSync(path.join(tmpDir, file), source);++ write(+ 'base/icons.mjs',+ `import {createElement} from 'react';+export const icons = {+ info: ({variant}) => createElement('svg', {'data-variant': variant ?? 'normal'}),+};+`,+ );+ write(+ 'base/source.mjs',+ `import {defineTheme} from '@astryxdesign/core/theme';+import {icons} from './icons.mjs';+export const baseTheme = defineTheme({+ name: 'entry-variants-base', tokens: {}, iconVariants: ['outline'], icons,+});+`,+ );+ write(+ 'child/source.mjs',+ `import {defineTheme} from '@astryxdesign/core/theme';+import {baseTheme} from '../base/source.mjs';+export default defineTheme({+ name: 'entry-variants-child', extends: baseTheme, tokens: {},+ iconVariants: ['outline', 'filled'],+});+`,+ );+ // A defining theme with no list: the built module writes it as `[]`.+ write(+ 'unlisted/base.mjs',+ `import {defineTheme} from '@astryxdesign/core/theme';+import {icons} from '../base/icons.mjs';+export const unlistedBase = defineTheme({+ name: 'entry-variants-unlisted-base', tokens: {}, icons,+});+`,+ );+ write(+ 'unlisted/source.mjs',+ `import {defineTheme} from '@astryxdesign/core/theme';+import {unlistedBase} from './base.mjs';+export default defineTheme({+ name: 'entry-variants-unlisted-child', extends: unlistedBase, tokens: {},+ iconVariants: ['filled'],+});+`,+ );+ for (const source of ['child/source.mjs', 'unlisted/source.mjs']) {+ const receipt = await themeBuild(source, {}, {cwd: tmpDir});+ expect(receipt?.type).toBe('theme.build');+ }++ const output = execFileSync(+ process.execPath,+ [+ '--input-type=module',+ '--eval',+ `import {createElement} from 'react';+import {renderToStaticMarkup} from 'react-dom/server';+import {Icon} from '@astryxdesign/core/Icon';+import {Theme} from '@astryxdesign/core/theme';+import {entryVariantsChildTheme as built} from './child/entry-variants-child.js';+import runtime from './child/source.mjs';+import {entryVariantsUnlistedChildTheme as unlistedBuilt} from './unlisted/entry-variants-unlisted-child.js';+import unlistedRuntime from './unlisted/source.mjs';+const received = (theme, variant) => {+ const html = renderToStaticMarkup(+ createElement(Theme, {theme}, createElement(Icon, {icon: 'info', variant})),+ );+ return /data-variant="([^"]+)"/.exec(html)?.[1] ?? null;+};+const result = {};+for (const [label, theme] of [+ ['built', built],+ ['runtime', runtime],+ ['unlistedBuilt', unlistedBuilt],+ ['unlistedRuntime', unlistedRuntime],+]) {+ result[label] = {+ filled: received(theme, 'filled'),+ outline: received(theme, 'outline'),+ };+}+process.stdout.write(JSON.stringify(result));`,+ ],+ {cwd: tmpDir, stdio: ['ignore', 'pipe', 'pipe'], timeout: 20000},+ );+ const result = JSON.parse(String(output));++ // The base never listed 'filled', so its entry draws normal artwork for+ // it in the child; 'outline' is listed by both and reaches the entry.+ expect(result.runtime).toEqual({filled: 'normal', outline: 'outline'});+ expect(result.built).toEqual(result.runtime);+ // A base with no list passes its entry no variant, even one its child lists.+ expect(result.unlistedRuntime).toEqual({+ filled: 'normal',+ outline: 'normal',+ });+ expect(result.unlistedBuilt).toEqual(result.unlistedRuntime);+ } finally {+ fs.rmSync(tmpDir, {recursive: true, force: true});+ }+});diff --git a/packages/cli/api/theme/build/build.mjs b/packages/cli/api/theme/build/build.mjsindex 28a9082952..91b7f7c8c2 100644--- a/packages/cli/api/theme/build/build.mjs+++ b/packages/cli/api/theme/build/build.mjs@@ -2175,7 +2175,20 @@ function generateBuiltModule(serializeField('__adaptations', themeDef.__adaptations) +serializeField('__axes', themeDef.__axes ?? {}, true) +// An explicit empty list replaces an inherited one, so keep `[]`.- serializeField('iconVariants', themeDef.iconVariants, true);+ serializeField('iconVariants', themeDef.iconVariants, true) ++ // Each inherited function entry keeps its defining theme's list. JSON+ // drops `undefined`, so a defining theme with no list is written as `[]`,+ // which no variant matches either.+ serializeField(+ '__iconEntryVariants',+ themeDef.__iconEntryVariants &&+ Object.fromEntries(+ Object.entries(themeDef.__iconEntryVariants).map(([name, list]) => [+ name,+ list ?? [],+ ]),+ ),+ );return `${iconImport}${iconDeclaration}/*** ${themeDef.name} theme — built by \`${getCliInvocation()} theme build\`diff --git a/packages/cli/assets/docs/icons.doc.mjs b/packages/cli/assets/docs/icons.doc.mjsindex 8b906e410a..d0fd5b0f54 100644--- a/packages/cli/assets/docs/icons.doc.mjs+++ b/packages/cli/assets/docs/icons.doc.mjs@@ -156,6 +156,17 @@ brandTheme.iconVariants; // ['outline', 'filled']`,type: 'prose',text: 'A theme that `extends` another inherits its list unless it sets its own; a list it sets replaces the inherited one instead of merging with it.',},+ {+ type: 'prose',+ text: "Request a variant with `Icon`'s `variant` prop. The entry receives it only when the active theme lists it; an entry the theme inherited also needs the theme that defined it to list it. Otherwise the entry receives `undefined` and draws its normal artwork, so an unlisted variant never breaks rendering. A `registerIcons()` entry receives the variants the active theme lists, and a node entry draws the same node for every variant. An icon component passed directly to `Icon` never receives `variant`, and `variant` is never written to the DOM: it selects artwork, so there is no theming selector for it.",+ },+ {+ type: 'code',+ lang: 'tsx',+ label: 'Requesting a variant',+ code: `<Icon icon="info" variant="filled" /> // brandTheme: the filled artwork+<Icon icon="info" /> // the normal artwork`,+ },{type: 'prose',text: 'An application declares the variant names it uses by augmenting `IconVariantMap` from `@astryxdesign/core/Icon`. `IconVariant` is those names, and an entry passed to `registerIcons()` receives `variant` typed as `IconVariant`.',diff --git a/packages/cli/test/__golden__/no-icon-set/docs-topics.json b/packages/cli/test/__golden__/no-icon-set/docs-topics.jsonindex 4e2566d15f..ec2826ac37 100644--- a/packages/cli/test/__golden__/no-icon-set/docs-topics.json+++ b/packages/cli/test/__golden__/no-icon-set/docs-topics.json@@ -163,7 +163,7 @@"icon-variants","component-and-library-icons"],- "skeleton": "93430a3f9039a2f8bcf20d0873a6d6a3679096f399bfa493a81083fba92ee908",+ "skeleton": "b58107977247069a83428bd5c6af3c28edef4c4754cb12e6b8bbfa9dca6ab052","mentions": ["This lets you swap the icon set (e.g."]diff --git a/packages/cli/test/__golden__/no-icon-set/search-icon-set.json b/packages/cli/test/__golden__/no-icon-set/search-icon-set.jsonindex c862b58236..e81065eb2b 100644--- a/packages/cli/test/__golden__/no-icon-set/search-icon-set.json+++ b/packages/cli/test/__golden__/no-icon-set/search-icon-set.json@@ -33,6 +33,19 @@"This lets you swap the icon set (e.g."]},+ {+ "domain": "doc",+ "name": "icons",+ "package": "@astryxdesign/cli",+ "score": "<text>",+ "reason": "<text>",+ "description": "<text>",+ "section": "<text>",+ "title": "<text>",+ "command": "astryx docs icons icon-variants",+ "parent": "astryx docs icons --index",+ "mentions": []+ },{"domain": "doc","name": "theme",@@ -233,18 +246,6 @@"kind": "block","command": "astryx template ChatComposerDrawerShowcase --type block","mentions": []- },- {- "domain": "template",- "name": "ChatComposerDrawerWithProgress",- "package": "@astryxdesign/core",- "score": "<text>",- "reason": "<text>",- "description": "<text>",- "displayName": "<text>",- "kind": "block",- "command": "astryx template ChatComposerDrawerWithProgress --type block",- "mentions": []}]},diff --git a/packages/cli/test/__golden__/no-icon-set/search-icon-set.txt b/packages/cli/test/__golden__/no-icon-set/search-icon-set.txtindex a888cb11f6..fb62b92896 100644--- a/packages/cli/test/__golden__/no-icon-set/search-icon-set.txt+++ b/packages/cli/test/__golden__/no-icon-set/search-icon-set.txt@@ -11,6 +11,12 @@ domain: docpackage: @astryxdesign/clicommand: pnpm exec astryx docs icons theme-overridesparent: pnpm exec astryx docs icons --index+name: icons+section: icon-variants+domain: doc+package: @astryxdesign/cli+command: pnpm exec astryx docs icons icon-variants+parent: pnpm exec astryx docs icons --indexname: themesection: icon-sizesdomain: doc@@ -85,8 +91,4 @@ command: pnpm exec astryx template CenterInsideACard --type blockname: ChatComposerDrawerShowcasedomain: templatepackage: @astryxdesign/core-command: pnpm exec astryx template ChatComposerDrawerShowcase --type block-name: ChatComposerDrawerWithProgress-domain: template-package: @astryxdesign/core-command: pnpm exec astryx template ChatComposerDrawerWithProgress --type block\ No newline at end of file+command: pnpm exec astryx template ChatComposerDrawerShowcase --type block\ No newline at end of filediff --git a/packages/cli/test/__golden__/no-icon-set/search-icon.json b/packages/cli/test/__golden__/no-icon-set/search-icon.jsonindex cc9a6d0eb9..5f30250a6b 100644--- a/packages/cli/test/__golden__/no-icon-set/search-icon.json+++ b/packages/cli/test/__golden__/no-icon-set/search-icon.json@@ -76,6 +76,19 @@"This lets you swap the icon set (e.g."]},+ {+ "domain": "doc",+ "name": "icons",+ "package": "@astryxdesign/cli",+ "score": "<text>",+ "reason": "<text>",+ "description": "<text>",+ "section": "<text>",+ "title": "<text>",+ "command": "astryx docs icons icon-variants",+ "parent": "astryx docs icons --index",+ "mentions": []+ },{"domain": "template","name": "BaseTypeaheadCustomSearch",@@ -231,18 +244,6 @@"kind": "block","command": "astryx template ChatComposerFullFeatured --type block","mentions": []- },- {- "domain": "template",- "name": "ChatMessageBubbleMetadata",- "package": "@astryxdesign/core",- "score": "<text>",- "reason": "<text>",- "description": "<text>",- "displayName": "<text>",- "kind": "block",- "command": "astryx template ChatMessageBubbleMetadata --type block",- "mentions": []}]},diff --git a/packages/cli/test/__golden__/no-icon-set/search-icon.txt b/packages/cli/test/__golden__/no-icon-set/search-icon.txtindex ecaabe65ac..62ba263a79 100644--- a/packages/cli/test/__golden__/no-icon-set/search-icon.txt+++ b/packages/cli/test/__golden__/no-icon-set/search-icon.txt@@ -30,6 +30,12 @@ domain: docpackage: @astryxdesign/clicommand: pnpm exec astryx docs icons theme-overridesparent: pnpm exec astryx docs icons --index+name: icons+section: icon-variants+domain: doc+package: @astryxdesign/cli+command: pnpm exec astryx docs icons icon-variants+parent: pnpm exec astryx docs icons --indexname: BaseTypeaheadCustomSearchdomain: templatepackage: @astryxdesign/core@@ -81,8 +87,4 @@ command: pnpm exec astryx template ChatComposerFooterActions --type blockname: ChatComposerFullFeatureddomain: templatepackage: @astryxdesign/core-command: pnpm exec astryx template ChatComposerFullFeatured --type block-name: ChatMessageBubbleMetadata-domain: template-package: @astryxdesign/core-command: pnpm exec astryx template ChatMessageBubbleMetadata --type block\ No newline at end of file+command: pnpm exec astryx template ChatComposerFullFeatured --type block\ No newline at end of filediff --git a/packages/core/src/Icon/Icon.doc.mjs b/packages/core/src/Icon/Icon.doc.mjsindex 917c2027da..d6bc5a311b 100644--- a/packages/core/src/Icon/Icon.doc.mjs+++ b/packages/core/src/Icon/Icon.doc.mjs@@ -89,6 +89,12 @@ export const docs = {"Icon size. xsm, sm, md, and lg are 12, 16, 20, and 24px at a 16px root and scale with the root font size; a theme sets a size's glyph dimension with width and height, in px or rem, on components.icon['size:sm'] (and the other sizes). An explicit value wins. When omitted, Icon uses the nearest default supplied by an owning Astryx component for its icon slot, then falls back to md when no contextual default exists.",default: "Contextual; otherwise 'md'",},+ {+ name: 'variant',+ type: 'IconVariant',+ description:+ "Requests the active theme's alternate artwork for a semantic icon name, such as 'filled'. Names come from IconVariantMap, which an application augments from @astryxdesign/core/Icon; Astryx defines none. The theme's icon entry receives the variant only when the active theme lists it in iconVariants (and, for an entry the theme inherited, the theme that defined the entry lists it too); otherwise it draws its normal artwork. Ignored by an icon component passed directly. Selects artwork only: it is not written to the DOM and has no theming selector.",+ },{name: 'label',type: 'string',@@ -219,6 +225,12 @@ export const docsZh = {"图标尺寸。xsm、sm、md、lg 在 16px 根字号下分别为 12、16、20、24px,并随根字号缩放;主题在 components.icon['size:sm'](及其他尺寸)上以 px 或 rem 设置 width 和 height,即可决定该尺寸的图标尺寸。显式值优先。省略时,Icon 使用最近的 Astryx 所属组件为其图标槽提供的默认尺寸;如果没有上下文默认值,则回退为 md。",default: "上下文默认值;否则为 'md'",},+ {+ name: 'variant',+ type: 'IconVariant',+ description:+ "为语义图标名称请求当前主题的替代图稿,例如 'filled'。名称来自 IconVariantMap,由应用从 @astryxdesign/core/Icon 扩充;Astryx 本身不定义任何名称。只有当前主题在 iconVariants 中列出该变体时(对于主题继承来的条目,还需定义该条目的主题也列出它),主题的图标条目才会收到它;否则绘制常规图稿。直接传入的图标组件会忽略它。它只选择图稿:不会写入 DOM,也没有主题样式选择器。",+ },{name: 'label',type: 'string',@@ -381,6 +393,8 @@ export const docsDense = {icon: 'Semantic icon name or SVG component. Valid names: close, chevronDown, chevronLeft, chevronRight, chevronsLeft, chevronsRight, check, success, error, warning, info, calendar, clock, externalLink, menu, moreHorizontal, search, upload, arrowUp, arrowDown, arrowsUpDown, funnel, eyeSlash, viewColumns, copy, checkDouble, wrench, stop, microphone. For others, pass an SVG component.',color: 'Color variant mapped to Astryx icon color tokens.',size: "xsm/sm/md/lg = 12/16/20/24px at a 16px root, scale w/ root font size; theme sets a size's glyph dimension via width + height (px or rem) on components.icon['size:sm'] etc. Explicit Icon size; otherwise nearest owning-component default, then 'md' when no contextual default exists",+ variant:+ "Requests the active theme's alternate artwork (e.g. 'filled'); names from augmentable IconVariantMap. Reaches the entry only if the active theme's iconVariants lists it (and an inherited entry's defining theme does too); else normal artwork. Ignored by a directly passed component; never in the DOM; no theming selector.",label:'Accessible name for a meaningful, standalone icon. Sets role="img" + aria-label and drops the default aria-hidden. Omit (default) for decorative icons (stays aria-hidden). Empty string = decorative. The accessible-name/alt-text prop for icons.',xstyle:diff --git a/packages/core/src/Icon/Icon.test.tsx b/packages/core/src/Icon/Icon.test.tsxindex 79b75bff80..0bbf37bd0c 100644--- a/packages/core/src/Icon/Icon.test.tsx+++ b/packages/core/src/Icon/Icon.test.tsx@@ -26,6 +26,15 @@ import {type IconRequest,} from './globalIconRegistry';+// The variant names these tests request (spec:AST-087 FR3: an application+// augments the public map).+declare module './index' {+ interface IconVariantMap {+ outline: true;+ filled: true;+ }+}+/** The custom properties a declaration value reads, in order. */function varsRead(value: string): string[] {return [...value.matchAll(/var\(\s*(--[\w-]+)/g)].map(match => match[1]);@@ -452,6 +461,279 @@ describe('Icon', () => {});});+ // spec:AST-087 FR4, FR5; component:Icon FR6 — a requested variant reaches+ // the selected entry only when the active theme lists it and, for a theme+ // entry, the theme that defined it lists it too. Everything else receives+ // `undefined` and draws its normal artwork.+ describe('variant', () => {+ const drawn = (label: string) =>+ vi.fn(+ ({size, variant}: IconRequest) =>+ `${label}-${size}-${variant ?? 'normal'}`,+ );++ function renderInTheme(+ theme: Parameters<typeof Theme>[0]['theme'],+ ui: React.ReactNode,+ ) {+ return render(<Theme theme={theme}>{ui}</Theme>);+ }++ it('passes a variant the active theme lists to its entry', () => {+ resetIcons();+ resetThemes();+ const info = drawn('info');+ const theme = defineTheme({+ name: 'variant-listed',+ iconVariants: ['outline', 'filled'],+ icons: {info},+ });++ renderInTheme(+ theme,+ <Icon icon="info" size="sm" variant="filled" data-testid="icon" />,+ );++ expect(screen.getByTestId('icon')).toHaveTextContent('info-sm-filled');+ expect(info).toHaveBeenLastCalledWith({size: 'sm', variant: 'filled'});+ });++ it('passes undefined when the variant is omitted', () => {+ resetIcons();+ resetThemes();+ const info = drawn('info');+ const theme = defineTheme({+ name: 'variant-omitted',+ iconVariants: ['outline', 'filled'],+ icons: {info},+ });+ info.mockClear();++ renderInTheme(theme, <Icon icon="info" data-testid="icon" />);++ expect(screen.getByTestId('icon')).toHaveTextContent('info-md-normal');+ expect(info).toHaveBeenLastCalledWith({size: 'md'});+ });++ it('renders the normal artwork for a variant the active theme does not list', () => {+ // The theme-independent fallback (component-theming-surface INV14).+ resetIcons();+ resetThemes();+ const info = drawn('info');+ const theme = defineTheme({+ name: 'variant-unlisted',+ iconVariants: ['outline'],+ icons: {info},+ });+ info.mockClear();++ renderInTheme(+ theme,+ <Icon icon="info" size="lg" variant="filled" data-testid="icon" />,+ );++ expect(screen.getByTestId('icon')).toHaveTextContent('info-lg-normal');+ expect(info).toHaveBeenLastCalledWith({size: 'lg'});+ });++ it('renders the normal artwork when the active theme lists no variants', () => {+ resetIcons();+ resetThemes();+ const info = drawn('info');+ const theme = defineTheme({name: 'variant-no-list', icons: {info}});++ renderInTheme(+ theme,+ <Icon icon="info" variant="filled" data-testid="icon" />,+ );++ expect(screen.getByTestId('icon')).toHaveTextContent('info-md-normal');+ });++ it('keeps the defining theme list for an inherited entry', () => {+ resetIcons();+ resetThemes();+ const base = defineTheme({+ name: 'variant-base',+ iconVariants: ['outline'],+ icons: {info: drawn('base-info')},+ });+ const child = defineTheme({+ name: 'variant-child',+ extends: base,+ iconVariants: ['outline', 'filled'],+ icons: {close: drawn('child-close')},+ });++ renderInTheme(+ child,+ <>+ <Icon icon="info" variant="filled" data-testid="inherited-filled" />+ <Icon icon="info" variant="outline" data-testid="inherited-outline" />+ <Icon icon="close" variant="filled" data-testid="own-filled" />+ </>,+ );++ // The base never listed 'filled', so its entry draws normal artwork.+ expect(screen.getByTestId('inherited-filled')).toHaveTextContent(+ 'base-info-md-normal',+ );+ expect(screen.getByTestId('inherited-outline')).toHaveTextContent(+ 'base-info-md-outline',+ );+ expect(screen.getByTestId('own-filled')).toHaveTextContent(+ 'child-close-md-filled',+ );+ });++ it('passes an inherited entry only the variants the child still lists', () => {+ resetIcons();+ resetThemes();+ const base = defineTheme({+ name: 'variant-wide-base',+ iconVariants: ['outline', 'filled'],+ icons: {info: drawn('base-info')},+ });+ const replaced = defineTheme({+ name: 'variant-narrow-child',+ extends: base,+ iconVariants: ['outline'],+ });+ const inherited = defineTheme({+ name: 'variant-inherit-child',+ extends: base,+ });++ renderInTheme(+ replaced,+ <Icon icon="info" variant="filled" data-testid="replaced" />,+ );+ renderInTheme(+ inherited,+ <Icon icon="info" variant="filled" data-testid="inherited" />,+ );++ expect(screen.getByTestId('replaced')).toHaveTextContent(+ 'base-info-md-normal',+ );+ expect(screen.getByTestId('inherited')).toHaveTextContent(+ 'base-info-md-filled',+ );+ });++ it('passes a process-wide registration the variants the active theme lists', () => {+ resetIcons();+ resetThemes();+ registerIcons({info: drawn('global-info')});+ const listing = defineTheme({+ name: 'variant-global-listed',+ iconVariants: ['filled'],+ });+ const notListing = defineTheme({+ name: 'variant-global-unlisted',+ iconVariants: ['outline'],+ });++ renderInTheme(+ listing,+ <Icon icon="info" variant="filled" data-testid="listed" />,+ );+ renderInTheme(+ notListing,+ <Icon icon="info" variant="filled" data-testid="unlisted" />,+ );+ render(<Icon icon="info" variant="filled" data-testid="no-theme" />);++ expect(screen.getByTestId('listed')).toHaveTextContent(+ 'global-info-md-filled',+ );+ expect(screen.getByTestId('unlisted')).toHaveTextContent(+ 'global-info-md-normal',+ );+ expect(screen.getByTestId('no-theme')).toHaveTextContent(+ 'global-info-md-normal',+ );+ });++ it('renders the same node entry for every variant', () => {+ resetIcons();+ resetThemes();+ const theme = defineTheme({+ name: 'variant-node',+ iconVariants: ['outline', 'filled'],+ icons: {info: 'node-info'},+ });++ renderInTheme(+ theme,+ <>+ <Icon icon="info" variant="filled" data-testid="filled" />+ <Icon icon="info" data-testid="normal" />+ </>,+ );++ expect(screen.getByTestId('filled')).toHaveTextContent('node-info');+ expect(screen.getByTestId('normal')).toHaveTextContent('node-info');+ });++ it('never passes variant to a supplied icon component', () => {+ resetIcons();+ resetThemes();+ const Supplied = vi.fn((props: React.SVGProps<SVGSVGElement>) => (+ <svg {...props} />+ ));+ const theme = defineTheme({+ name: 'variant-direct',+ iconVariants: ['outline', 'filled'],+ });++ renderInTheme(+ theme,+ <Icon icon={Supplied} variant="filled" data-testid="icon" />,+ );++ const props = Supplied.mock.calls[0]?.[0] ?? {};+ expect(props).not.toHaveProperty('variant');+ expect(screen.getByTestId('icon')).not.toHaveAttribute('variant');+ });++ it('writes no variant to the DOM or the icon theming target', () => {+ resetIcons();+ resetThemes();+ const theme = defineTheme({+ name: 'variant-dom',+ iconVariants: ['outline', 'filled'],+ icons: {info: drawn('info')},+ });++ renderInTheme(+ theme,+ <>+ <Icon icon="info" variant="filled" data-testid="registry" />+ <Icon icon={TestIcon} variant="filled" data-testid="component" />+ </>,+ );++ for (const id of ['registry', 'component']) {+ const icon = screen.getByTestId(id);+ expect(icon).toHaveClass('astryx-icon');+ expect(icon).not.toHaveAttribute('variant');+ expect(icon).not.toHaveAttribute('data-variant');+ expect(icon.outerHTML).not.toContain('filled"');+ }+ });++ it('types variant by IconVariantMap', () => {+ render(+ <>+ <Icon icon="info" variant="outline" />+ {/* @ts-expect-error — 'bold' is not in IconVariantMap. */}+ <Icon icon="info" variant="bold" />+ </>,+ );+ });+ });+describe('namespaced extension keys', () => {it('renders a theme-registered namespaced key with size and color applied', () => {resetIcons();diff --git a/packages/core/src/Icon/Icon.tsx b/packages/core/src/Icon/Icon.tsxindex 6e45426b1e..02eebd1570 100644--- a/packages/core/src/Icon/Icon.tsx+++ b/packages/core/src/Icon/Icon.tsx@@ -4,7 +4,8 @@/*** @file Icon.tsx- * @input Uses ReactSVGProps, icon components or semantic icon names+ * @input Uses ReactSVGProps, icon components or semantic icon names, and an+ * optional IconVariant request* @output Exports Icon component, IconProps, IconColor, IconSize, IconType types* @position Core implementation; consumed by index.ts, tested by Icon.test.tsx*@@ -13,7 +14,8 @@* directly with and spread SVG props.* - String mode: Pass a semantic name (e.g. 'close', 'chevronDown') — resolved from the* theme's icon registry (or built-in fallback SVGs) and wrapped in a styled span.- * A function registry entry receives `{size}`, the size resolved by ORD1.+ * A function registry entry receives `{size, variant}`: the size resolved by+ * ORD1 and the requested variant when the entry can receive it.** Both modes size the glyph from the `icon` target's private size vars* (`iconSizeStyles` in IconSize.stylex.ts, `registrySizeStyles` below), so a@@ -35,6 +37,7 @@ import {colorVars} from '../theme/tokens.stylex';import {useThemeName} from '../theme/useTheme';import {resolveIcon} from './globalIconRegistry';import type {IconName, NamespacedIconName} from './globalIconRegistry';+import type {IconVariant} from './index';import {mergeProps} from '../utils';import {themeProps} from '../utils/themeProps';import {useIconSize} from './IconDefaultSizeContext';@@ -202,6 +205,23 @@ export interface IconProps extends Omit<* by an owning Astryx component for its icon slot, then falls back to 'md'.*/size?: IconSize;+ /**+ * Requests the active theme's alternate artwork for a semantic icon name,+ * such as `'filled'`. Names come from the augmentable `IconVariantMap`.+ *+ * The theme's icon entry receives the variant only when the active theme+ * lists it in `iconVariants` and, for an entry a theme supplied, the theme+ * that defined the entry lists it too. Otherwise the entry receives+ * `undefined` and draws its normal artwork. An icon component passed+ * directly renders as given and never receives `variant`, and `variant` is+ * never written to the DOM or reflected on the `icon` theming target.+ *+ * @example+ * ```+ * <Icon icon="info" variant="filled" />+ * ```+ */+ variant?: IconVariant;/*** Accessible name for the icon. Set this only when the icon is MEANINGFUL on* its own — a standalone status glyph or an icon-only indicator with no@@ -282,6 +302,7 @@ export function Icon({icon,color = 'inherit',size: sizeProp,+ variant,label,ref,className,@@ -301,6 +322,7 @@ export function Icon({name={icon}color={color}size={size}+ variant={variant}a11yProps={a11yProps}className={className}style={style}@@ -310,7 +332,8 @@ export function Icon({);}- // Component mode: render SVG component directly with ref forwarding+ // Component mode: render SVG component directly with ref forwarding. A+ // supplied component never receives `variant`; it was destructured above.const IconComponent = icon;return (<IconComponent@@ -351,12 +374,14 @@ Icon.displayName = 'Icon';* and renders it in a styled span with proper sizing.** Extracted as a separate component so the registry is only read when the- * icon prop is a string. A function entry receives the resolved size.+ * icon prop is a string. A function entry receives the resolved size and the+ * requested variant when the entry can receive it.*/function IconFromRegistry({name,color,size,+ variant,a11yProps,className,style,@@ -366,6 +391,7 @@ function IconFromRegistry({name: IconName | NamespacedIconName;color: IconColor;size: IconSize;+ variant: IconVariant | undefined;a11yProps: {role: 'img'; 'aria-label': string} | {'aria-hidden': 'true'};className?: string;style?: React.CSSProperties;@@ -373,7 +399,7 @@ function IconFromRegistry({spanProps?: Omit<SVGProps<SVGSVGElement>, 'ref' | 'color'>;}) {const themeName = useThemeName();- const resolvedIcon = resolveIcon(name, themeName, {size});+ const resolvedIcon = resolveIcon(name, themeName, {size, variant});if (resolvedIcon == null) {return null;diff --git a/packages/core/src/Icon/globalIconRegistry.test.tsx b/packages/core/src/Icon/globalIconRegistry.test.tsxindex 1eb303ea88..a93acaf9a2 100644--- a/packages/core/src/Icon/globalIconRegistry.test.tsx+++ b/packages/core/src/Icon/globalIconRegistry.test.tsx@@ -520,6 +520,75 @@ describe('iconRegistry (global, RSC-compatible)', () => {});});+ it('passes a listed variant to theme and process-wide entries only', () => {+ const themeInfo = vi.fn(+ ({variant}: IconRequest) => `theme-${variant ?? 'normal'}`,+ );+ const globalClose = vi.fn(+ ({variant}: IconRequest) => `global-${variant ?? 'normal'}`,+ );+ registerIcons({close: globalClose});+ const theme = defineTheme({+ name: 'resolve-listed',+ iconVariants: ['filled'],+ icons: {info: themeInfo},+ });++ expect(+ resolveIcon('info', theme, {size: 'sm', variant: 'filled'}),+ ).toBe('theme-filled');+ expect(+ resolveIcon('close', theme, {size: 'sm', variant: 'filled'}),+ ).toBe('global-filled');+ expect(+ resolveIcon('info', theme, {size: 'sm', variant: 'outline'}),+ ).toBe('theme-normal');+ expect(+ resolveIcon('close', null, {size: 'sm', variant: 'filled'}),+ ).toBe('global-normal');+ expect(+ resolveIcon('check', theme, {size: 'sm', variant: 'filled'}),+ ).toBe(defaultIcons.check);+ });++ it('keeps the defining list through more than one extends', () => {+ const grandparent = defineTheme({+ name: 'resolve-grandparent',+ iconVariants: ['outline'],+ icons: {info: ({variant}) => `info-${variant ?? 'normal'}`},+ });+ const parent = defineTheme({+ name: 'resolve-parent',+ extends: grandparent,+ iconVariants: ['outline', 'filled'],+ });+ const child = defineTheme({name: 'resolve-child', extends: parent});++ expect(child.iconVariants).toEqual(['outline', 'filled']);+ expect(+ resolveIcon('info', child, {size: 'md', variant: 'filled'}),+ ).toBe('info-normal');+ expect(+ resolveIcon('info', child, {size: 'md', variant: 'outline'}),+ ).toBe('info-outline');+ });++ it('never passes a variant through public reads', () => {+ const info = vi.fn(+ ({variant}: IconRequest) => `info-${variant ?? 'normal'}`,+ );+ const theme = defineTheme({+ name: 'resolve-public-reads',+ iconVariants: ['outline', 'filled'],+ icons: {info},+ });++ expect(getIcon('info', theme)).toBe('info-normal');+ expect(getIconRegistry(theme).info).toBe('info-normal');+ expect(getExtendedIcon('info', 'fallback', theme)).toBe('info-normal');+ expect(theme.icons?.info).toBe('info-normal');+ });+it('passes no variant to an entry, so it draws its normal artwork', () => {const info = vi.fn(({variant}: IconRequest) =>variant === 'filled' ? 'filled-info' : 'normal-info',diff --git a/packages/core/src/Icon/globalIconRegistry.tsx b/packages/core/src/Icon/globalIconRegistry.tsxindex 1bf89fe458..1e496ce796 100644--- a/packages/core/src/Icon/globalIconRegistry.tsx+++ b/packages/core/src/Icon/globalIconRegistry.tsx@@ -16,7 +16,9 @@* {@link IconRequest}. Resolution picks one source — theme entry, then* process-wide registration, then built-in default; a nullish static entry* falls through — and a selected function's result is final. `Icon` passes- * its resolved size; the public reads below pass `{size: 'md'}`.+ * its resolved size and a variant the entry can receive (listed by the active+ * theme and, for a theme entry, by the theme that defined it), otherwise+ * `undefined`; the public reads below pass `{size: 'md'}`.*/import type {ReactNode} from 'react';@@ -161,58 +163,103 @@ function isNamespacedKey(name: string): boolean {return name.includes(':');}+function getTheme(source: IconRegistrySource): DefinedTheme | null {+ return typeof source === 'string'+ ? getRegisteredTheme(source)+ : (source ?? null);+}+/*** The theme's icon entries, functions included. A theme from `defineTheme`* keeps them in `__icons` when any entry is a function (its public `icons`* is the node view); otherwise `icons` already holds them.*/function getThemeIconEntries(- source: IconRegistrySource,+ theme: DefinedTheme | null,): Readonly<Record<string, StoredIconEntry>> | null {- const theme =- typeof source === 'string' ? getRegisteredTheme(source) : source;if (theme == null) {return null;}return theme.__icons ?? theme.icons ?? null;}+/**+ * The selected entry, with every variant list a requested variant must be in+ * for the entry to receive it. No lists: the entry receives no variant.+ */+interface IconSelection {+ entry: StoredIconEntry;+ variantLists: ReadonlyArray<ReadonlyArray<string> | undefined>;+}+/*** Pick the one source that answers `name`: the theme entry, then the* process-wide registration, then the built-in default, then `fallback`. A* nullish static entry falls through; a function is returned as-is, because* its result is final.+ *+ * A theme entry may receive a variant listed by the active theme and by the+ * theme that defined the entry (an inherited entry keeps its defining+ * theme's list). A process-wide registration may receive a variant the+ * active theme lists.*/function selectIconEntry(name: string,source: IconRegistrySource,fallback?: ReactNode,-): StoredIconEntry {- return (- getThemeIconEntries(source)?.[name] ??- globalRegistry[name] ??- defaultIcons[name as IconName] ??- fallback- );+): IconSelection {+ const theme = getTheme(source);+ const activeVariants = theme?.iconVariants;+ const themeEntry = getThemeIconEntries(theme)?.[name];+ if (theme != null && themeEntry != null) {+ const definingVariants =+ theme.__iconEntryVariants != null &&+ Object.hasOwn(theme.__iconEntryVariants, name)+ ? theme.__iconEntryVariants[name]+ : activeVariants;+ return {+ entry: themeEntry,+ variantLists: [activeVariants, definingVariants],+ };+ }+ const globalEntry = globalRegistry[name];+ if (globalEntry != null) {+ return {entry: globalEntry, variantLists: [activeVariants]};+ }+ return {entry: defaultIcons[name as IconName] ?? fallback, variantLists: []};}-/** Read an entry for a request: call a function, return a node as-is. */+/**+ * Read a selected entry for a request: call a function, return a node as-is.+ * The function receives the requested variant only when every list of the+ * selection contains it; otherwise it receives `undefined`.+ */function readIconEntry(- entry: StoredIconEntry,- request: IconRequest<never>,+ {entry, variantLists}: IconSelection,+ {size, variant}: IconRequest<string>,): ReactNode {- return typeof entry === 'function' ? entry(request) : entry;+ if (typeof entry !== 'function') {+ return entry;+ }+ const receivable =+ variant !== undefined &&+ variantLists.length > 0 &&+ variantLists.every(list => list?.includes(variant) === true);+ // A receivable variant is one the entry's theme lists, which is the type+ // the entry was written against.+ return entry((receivable ? {size, variant} : {size}) as IconRequest<never>);}/*** Resolve a key for an Icon request. `Icon` is the caller: it passes the size- * it resolved. Public reads use {@link getIcon} instead.+ * it resolved and the variant it was asked for. Public reads use+ * {@link getIcon} instead.* @internal*/export function resolveIcon(name: ExtendedIconName,source: IconRegistrySource,- request: IconRequest<never>,+ request: IconRequest<string>,): ReactNode {return readIconEntry(selectIconEntry(name, source), request);}@@ -279,7 +326,7 @@ export function getIconRegistry(// resolved via getIcon/getExtendedIcon and intentionally kept out of the// typed IconRegistry snapshot.const names = new Set(Object.keys(defaultIcons));- for (const name of Object.keys(getThemeIconEntries(source) ?? {})) {+ for (const name of Object.keys(getThemeIconEntries(getTheme(source)) ?? {})) {names.add(name);}for (const name of names) {diff --git a/packages/core/src/theme/defineTheme.ts b/packages/core/src/theme/defineTheme.tsindex 32e6dcbf40..f885ea7631 100644--- a/packages/core/src/theme/defineTheme.ts+++ b/packages/core/src/theme/defineTheme.ts@@ -538,6 +538,13 @@ export interface DefinedTheme {* the list it inherited. Absent when no theme in its lineage lists any.*/iconVariants?: ReadonlyArray<string>;+ /**+ * The variant list of the theme that defined each inherited function entry,+ * kept where it differs from `iconVariants`, so the entry receives only+ * variants its defining theme lists. Only Astryx icon resolution reads it.+ * @internal+ */+ __iconEntryVariants?: Record<string, ReadonlyArray<string> | undefined>;/** Indicator overrides for stateful control visuals, keyed by name */indicators?: IndicatorRegistry;/** Whether this theme has been pre-compiled by theme build CLI */@@ -741,6 +748,15 @@ export function defineTheme<? [...input.iconVariants]: base?.iconVariants;+ // An inherited function entry keeps the list of the theme that defined it,+ // so it receives a variant only when both lists contain it.+ const iconEntryVariants = resolveIconEntryVariants(+ iconEntries,+ input.icons,+ base,+ iconVariants,+ );+// Indicator overrides merge by name, like icons: a child theme replacing one// indicator keeps the ones its base replaced.const indicators =@@ -762,6 +778,9 @@ export function defineTheme<icons,...(icons !== iconEntries ? {__icons: iconEntries} : {}),...(iconVariants !== undefined ? {iconVariants} : {}),+ ...(iconEntryVariants !== undefined+ ? {__iconEntryVariants: iconEntryVariants}+ : {}),indicators,__inputTokens:base?.__inputTokens || input.tokens@@ -778,6 +797,41 @@ export function defineTheme<return theme;}+/**+ * For each function entry this theme inherits, the variant list of the theme+ * that defined it, where that list is not this theme's own. Entries this theme+ * defines use its own list, so they need no record.+ */+function resolveIconEntryVariants(+ entries: ThemeIconEntries<never> | undefined,+ ownEntries: Readonly<Record<string, unknown>> | undefined,+ base: DefinedTheme | undefined,+ iconVariants: ReadonlyArray<string> | undefined,+): Record<string, ReadonlyArray<string> | undefined> | undefined {+ if (entries == null || base == null) {+ return undefined;+ }+ const baseRecord = base.__iconEntryVariants;+ let record: Record<string, ReadonlyArray<string> | undefined> | undefined;+ for (const [name, entry] of Object.entries(entries)) {+ if (+ typeof entry !== 'function' ||+ (ownEntries != null && Object.hasOwn(ownEntries, name))+ ) {+ continue;+ }+ const definingVariants =+ baseRecord != null && Object.hasOwn(baseRecord, name)+ ? baseRecord[name]+ : base.iconVariants;+ if (definingVariants !== iconVariants) {+ record ??= {};+ record[name] = definingVariants;+ }+ }+ return record;+}+/*** The node-valued view of a theme's icon entries: each function entry read at* `{size: 'md'}`. Entries without a function are returned as the same object.diff --git a/packages/core/src/theme/extensibleAxes.test.ts b/packages/core/src/theme/extensibleAxes.test.tsindex 85af3ccb2b..85d7ed9a5a 100644--- a/packages/core/src/theme/extensibleAxes.test.ts+++ b/packages/core/src/theme/extensibleAxes.test.ts@@ -32,6 +32,11 @@* `TreeListVariantMap`, with a module-augmentation example in its own JSDoc,* while `themeProps('tree-list', {density})` never passed `variant` — so an* augmented variant type-checked, rendered, and could not be themed.+ *+ * An artwork-request axis (`ARTWORK_REQUEST_MAPS`) keeps (1) but has no+ * styling wiring: it selects theme-supplied artwork, so its target reflects+ * nothing and documents no visual prop (architecture:component-theming-surface+ * INV6, INV14).*/import {describe, it, expect} from 'vitest';@@ -318,6 +323,20 @@ const axes = collectExtensibleAxes(files, aliases, propMaps);const themePropsSites = collectThemePropsSites(files);const docTargets = collectDocTargets(SRC_DIR);+/**+ * Maps whose axis is an artwork request, not a styling selector. Each keeps the+ * public-map check above and is exempt from the themeProps() reflection and+ * visualProps checks only — and must stay unreflected and undocumented as a+ * visual prop. `Icon.variant` selects a theme's artwork; an unlisted name+ * renders the request without a variant. `astryx theme build` keeps the same+ * list out of component-value enrollment+ * (packages/cli/api/theme/build/build.mjs).+ */+const ARTWORK_REQUEST_MAPS: ReadonlySet<string> = new Set(['IconVariantMap']);++const stylingAxes = axes.filter(a => !ARTWORK_REQUEST_MAPS.has(a.mapName));+const artworkAxes = axes.filter(a => ARTWORK_REQUEST_MAPS.has(a.mapName));+/** The target a component's own name maps to, e.g. TreeList -> astryx-tree-list. */function ownTargets(axis: ExtensibleAxis): DocTarget[] {return docTargets.get(axis.dir) ?? [];@@ -349,39 +368,65 @@ describe('extensible prop axes are reachable by a theme', () => {).toEqual([]);});- it.each(axes.map(a => [`${a.dir}.${a.prop} (${a.mapName})`, a] as const))(- '%s reaches the DOM through themeProps',- (_label, axis) => {- // The axis is extensible, so a consumer can add a value we have never- // seen. The only way their CSS can select it is if the component- // reflects the prop.- const targets = ownTargets(axis);- const reflected = targets.some(t =>- themePropsSites.get(t.className)?.has(axis.prop),- );- expect(- reflected,- `${axis.dir} lets a theme add \`${axis.prop}\` values via ${axis.mapName}, but no ` +- `themeProps() call passes \`${axis.prop}\` — a custom value renders no selector, ` +- `so it cannot be styled. Pass it: themeProps('<target>', {${axis.prop}}).`,- ).toBe(true);- },- );+ it.each(+ stylingAxes.map(a => [`${a.dir}.${a.prop} (${a.mapName})`, a] as const),+ )('%s reaches the DOM through themeProps', (_label, axis) => {+ // The axis is extensible, so a consumer can add a value we have never+ // seen. The only way their CSS can select it is if the component+ // reflects the prop.+ const targets = ownTargets(axis);+ const reflected = targets.some(t =>+ themePropsSites.get(t.className)?.has(axis.prop),+ );+ expect(+ reflected,+ `${axis.dir} lets a theme add \`${axis.prop}\` values via ${axis.mapName}, but no ` ++ `themeProps() call passes \`${axis.prop}\` — a custom value renders no selector, ` ++ `so it cannot be styled. Pass it: themeProps('<target>', {${axis.prop}}).`,+ ).toBe(true);+ });- it.each(axes.map(a => [`${a.dir}.${a.prop} (${a.mapName})`, a] as const))(- '%s is documented as a visual prop',+ it.each(+ stylingAxes.map(a => [`${a.dir}.${a.prop} (${a.mapName})`, a] as const),+ )('%s is documented as a visual prop', (_label, axis) => {+ // Undocumented, it is undiscoverable — and `theme build` rejects+ // `'<target>': {'<prop>:custom': …}` as an unknown prop, because its+ // known-prop set is built from exactly this field.+ const targets = ownTargets(axis);+ const documented = targets.some(t => t.visualProps.includes(axis.prop));+ expect(+ documented,+ `${axis.dir} lets a theme add \`${axis.prop}\` values via ${axis.mapName}, but no ` ++ `theming target documents \`${axis.prop}\` in visualProps — a theme author cannot ` ++ `discover the axis, and \`astryx theme build\` warns "Unknown prop" on it.`,+ ).toBe(true);+ });+});++describe('artwork-request axes are exempt from styling wiring only', () => {+ it('lists only maps that are extensible axes', () => {+ // A stale entry would silently exempt nothing; a renamed map would leave+ // its axis held to styling wiring it must not have.+ expect(artworkAxes.map(a => a.mapName).sort()).toEqual(+ [...ARTWORK_REQUEST_MAPS].sort(),+ );+ });++ it.each(+ artworkAxes.map(a => [`${a.dir}.${a.prop} (${a.mapName})`, a] as const),+ )(+ '%s is neither reflected nor documented as a visual prop',(_label, axis) => {- // Undocumented, it is undiscoverable — and `theme build` rejects- // `'<target>': {'<prop>:custom': …}` as an unknown prop, because its- // known-prop set is built from exactly this field.+ // The axis selects artwork, so it has no styling selector.const targets = ownTargets(axis);- const documented = targets.some(t => t.visualProps.includes(axis.prop));expect(- documented,- `${axis.dir} lets a theme add \`${axis.prop}\` values via ${axis.mapName}, but no ` +- `theming target documents \`${axis.prop}\` in visualProps — a theme author cannot ` +- `discover the axis, and \`astryx theme build\` warns "Unknown prop" on it.`,- ).toBe(true);+ targets.some(t => themePropsSites.get(t.className)?.has(axis.prop)),+ `${axis.dir}.${axis.prop} selects artwork; no themeProps() call may reflect it.`,+ ).toBe(false);+ expect(+ targets.some(t => t.visualProps.includes(axis.prop)),+ `${axis.dir}.${axis.prop} selects artwork; no theming target may list it in visualProps.`,+ ).toBe(false);},);});diff --git a/packages/native/src/contract/contracts.test.ts b/packages/native/src/contract/contracts.test.tsindex 424164abac..eb1143d982 100644--- a/packages/native/src/contract/contracts.test.ts+++ b/packages/native/src/contract/contracts.test.ts@@ -117,7 +117,15 @@ describe('native contracts', () => {expect(icon!.core.icon).toMatchObject({type: {kind: 'icon'}});expect(icon!.core.icon.optional).toBe(false);expect(Object.keys(icon!.core)).toEqual(['icon', 'color', 'size', 'label']);- expect(icon!.webOnly.map(prop => prop.name)).toEqual(['xstyle']);+ // `variant` names come from core's augmentable `IconVariantMap`, which has+ // no portable definition yet, so the prop stays on the web.+ expect(icon!.webOnly).toEqual([+ {+ name: 'variant',+ reason: 'type "IconVariant" has no portable definition yet',+ },+ {name: 'xstyle', reason: 'web styling input'},+ ]);const swift = generateSwift(contracts);expect(swift['Icon.swift']).toContain('public var icon: IconName');