@vectoriox/iox-ui 5.20.0 → 5.22.0

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.
@@ -8390,6 +8390,14 @@ interface SwitchElementStyleResult {
8390
8390
  /** Traits the old style owned whose value the author had changed — kept, never overwritten. */
8391
8391
  kept: OwnedTrait[];
8392
8392
  }
8393
+ /** Every trait the style owns with the value it writes — base first, then hover/active/focus. */
8394
+ declare function ownedTraitsOf(style: ElementStyle): Array<OwnedTrait & {
8395
+ value: string;
8396
+ }>;
8397
+ /** The node's value of one owned trait (a base trait, or a trait inside a pseudo-state map). */
8398
+ declare function readOwnedTrait(target: ElementStyleTarget, owned: OwnedTrait): unknown;
8399
+ /** Write one owned trait. False when a builder node has no slot for a base trait (dropped). */
8400
+ declare function writeOwnedTrait(target: ElementStyleTarget, owned: OwnedTrait, value: string): boolean;
8393
8401
  /** Write the style's exact base map and its hover/active/focus maps into the target. */
8394
8402
  declare function applyElementStyle(target: ElementStyleTarget, id: string): ApplyElementStyleResult;
8395
8403
  /**
@@ -8427,6 +8435,125 @@ declare function elementStyleClass(id: string | null | undefined): string | null
8427
8435
  */
8428
8436
  declare function applyHeadingLevelRule(target: ElementStyleTarget, oldLevel: string | null | undefined, newLevel: string | null | undefined, baseline?: Readonly<Record<string, unknown>>): SwitchElementStyleResult | null;
8429
8437
 
8438
+ /**
8439
+ * ADOPT (design-system DS7, decision D5): link the nodes of a page saved before element styles to
8440
+ * the style a NEW node of their type is born wearing, so the page follows the look from then on.
8441
+ * Opt-in per page, one click, one undo step — this module is only the pure tree pass; the builder
8442
+ * owns the click, the history step and the save.
8443
+ *
8444
+ * The rule that keeps the author's work: a trait the style owns is rewritten to the style's
8445
+ * reference ONLY when the node still holds what an untouched node of its type was saved with — the
8446
+ * type's BASELINE (the unstyled constructor default the caller supplies), or a value a machine wrote
8447
+ * into every new node before element styles existed (`PRE_DS2_FLAVOR_DEFAULTS`). Anything else is an
8448
+ * author edit and is KEPT, and reported.
8449
+ *
8450
+ * A node that already wears a style is UPGRADED where it holds a value that style wrote in an OLDER
8451
+ * contract (`SUPERSEDED_STYLE_VALUES`) — the same untouched-means-machine-written rule, one version on.
8452
+ *
8453
+ * Works on both node shapes element-styles.ts does: a builder node (values in `styleTraits`) or a
8454
+ * serialized node (`styleProps`), so the server-side site build can run it too.
8455
+ */
8456
+ /**
8457
+ * What a NEW node holds before its element style is written (C1.1): running text inherits, so a
8458
+ * literal colour on any container would override the section's text. The factory
8459
+ * (`ComponentRegistryService.createConfig`) writes it; adopt releases a baseline colour to it, so an
8460
+ * adopted node is exactly what a new node of its type is.
8461
+ */
8462
+ declare const NEW_NODE_STYLE_DEFAULTS: Readonly<Record<string, string>>;
8463
+ /**
8464
+ * Values a machine wrote into every NEW node of a type before element styles: the F1 Swiss pack's
8465
+ * element defaults (`SWISS_FLAVOR.defaults`, iox-ui 5.3.0 `0a00761` + iox-builder 4.24.0 `85109eb`,
8466
+ * `createConfig → applyFlavorDefaults`, resolved by `resolveFlavorDefaults` to
8467
+ * `var(--iox-<token>, <pack value>)`; deleted in DS2). An untouched node created between F1 and DS2
8468
+ * holds exactly these, so they count as untouched.
8469
+ */
8470
+ declare const PRE_DS2_FLAVOR_DEFAULTS: Readonly<Record<string, Readonly<Record<string, string>>>>;
8471
+ /** One owned trait whose value an element style CHANGED in the contract's history. */
8472
+ interface SupersededStyleValue extends OwnedTrait {
8473
+ readonly style: string;
8474
+ /** What the style wrote before. */
8475
+ readonly values: ReadonlyArray<string>;
8476
+ /** The style did not own the trait before, so an untouched node held its type's baseline. */
8477
+ readonly wasUnowned?: boolean;
8478
+ /** The iox-ai-guidance contract commit that changed it. */
8479
+ readonly contract: string;
8480
+ }
8481
+ /**
8482
+ * Every element-style value the contract has superseded since element styles shipped (a diff of
8483
+ * `flavor-spec.v1.json`'s `elementStyles` across its history — nothing else changed a value):
8484
+ * - `b86c54f` (C1): body / lead `color: var(--iox-text)` → `inherit`;
8485
+ * - `602d96e` (C1.1): box / card / panel / nav gained `color: inherit` — before, they owned no colour.
8486
+ * A spec pins this list against the generated contract. Add an entry with every contract change.
8487
+ */
8488
+ declare const SUPERSEDED_STYLE_VALUES: ReadonlyArray<SupersededStyleValue>;
8489
+ declare enum AdoptOutcome {
8490
+ /** The node wore no style; it now wears its type's default (or its legacy Button variant's). */
8491
+ Linked = "linked",
8492
+ /** The node wore a style; values that style wrote in an older contract were brought current. */
8493
+ Upgraded = "upgraded"
8494
+ }
8495
+ declare enum AdoptSkipReason {
8496
+ /** The type is born wearing no style (Gallery, SliderContainer, Spacer, …). */
8497
+ NoStyle = "no-style",
8498
+ /** The node takes its look from a style preset — the author's own class. */
8499
+ Preset = "preset",
8500
+ /** The node is (inside) a linked symbol instance: its look is the symbol's, shared across pages. */
8501
+ Symbol = "symbol"
8502
+ }
8503
+ interface AdoptContext {
8504
+ /** Per type, the style map an untouched SAVED node of it holds — its unstyled constructor
8505
+ * defaults (the builder's `ComponentRegistryService.adoptionBaseline`). */
8506
+ baseline(type: string): Readonly<Record<string, unknown>>;
8507
+ }
8508
+ /** The shapes this pass reads: an element-style target plus the fields that decide skips and styles. */
8509
+ interface AdoptableNode extends ElementStyleTarget {
8510
+ id?: string;
8511
+ props?: Readonly<Record<string, unknown>> | null;
8512
+ traits?: ReadonlyArray<{
8513
+ name: string;
8514
+ default?: unknown;
8515
+ }> | null;
8516
+ stylePresetId?: string | null;
8517
+ symbolId?: string | null;
8518
+ children?: AdoptableNode[] | null;
8519
+ }
8520
+ /** An owned trait the author had changed — kept, with the value kept. */
8521
+ interface KeptEdit extends OwnedTrait {
8522
+ value: unknown;
8523
+ }
8524
+ interface AdoptedNode {
8525
+ id?: string;
8526
+ type: string;
8527
+ style: string;
8528
+ outcome: AdoptOutcome;
8529
+ /** Traits rewritten (the style's references, a current value, or a released colour). */
8530
+ written: OwnedTrait[];
8531
+ kept: KeptEdit[];
8532
+ }
8533
+ interface SkippedNode {
8534
+ id?: string;
8535
+ type: string;
8536
+ reason: AdoptSkipReason;
8537
+ }
8538
+ interface AdoptReport {
8539
+ adopted: AdoptedNode[];
8540
+ skipped: SkippedNode[];
8541
+ /** Author edits kept across every adopted node. */
8542
+ kept: number;
8543
+ }
8544
+ /** The style an unstyled node adopts: a legacy Button by its `variant` (spec `buttonVariantToStyle`),
8545
+ * every other type by its default (a Heading by its level), or null. */
8546
+ declare function adoptionStyleFor(node: AdoptableNode): string | null;
8547
+ /**
8548
+ * Adopt every node of `tree` in place (children included) and report what happened. Skipped, never
8549
+ * touched: a node with a style preset, and every node of a linked symbol instance. A node whose type
8550
+ * has no default style is not linked, but an untouched baseline colour on it is released to the
8551
+ * new-node default all the same, so adopted text inside it is not painted the old literal.
8552
+ */
8553
+ declare function adoptElementStyles(tree: AdoptableNode[] | null | undefined, ctx: AdoptContext): AdoptReport;
8554
+ /** What adopting `tree` WOULD do, without touching it (the banner's count). */
8555
+ declare function previewElementStyleAdoption(tree: AdoptableNode[] | null | undefined, ctx: AdoptContext): AdoptReport;
8556
+
8430
8557
  /**
8431
8558
  * The design-system classes a node renders, in BOTH renderers (builder canvas, engine component
8432
8559
  * path, engine string path) — ONE helper, so the three can never disagree about which class a node
@@ -8830,6 +8957,13 @@ interface FontsForTokensOptions {
8830
8957
  * would otherwise download a monospace face for a site with no code on it.
8831
8958
  */
8832
8959
  usedCss?: string;
8960
+ /**
8961
+ * The families the org UPLOADED. An uploaded family renders from the org's own files, so it is
8962
+ * never fetched from Google — even when the catalog has a family of that name (an org that uploads
8963
+ * Inter's variable file means THAT Inter: linking Google's too put its static cuts beside the
8964
+ * upload, and the browser picked Google's — DS5.1).
8965
+ */
8966
+ uploaded?: ReadonlyArray<string>;
8833
8967
  }
8834
8968
  /**
8835
8969
  * The Google css2 ids to load for a token set: every catalog family named by the display / body /
@@ -9038,5 +9172,5 @@ interface FontFamilyRemoval {
9038
9172
  */
9039
9173
  declare function planFontFamilyRemoval(existing: ReadonlyArray<StoredDesignTokenRow>, previous: StoredDesign, family: string): FontFamilyRemoval;
9040
9174
 
9041
- export { ACCENT_TOKEN_NAMES, BUTTON_VARIANT_TO_STYLE, COLOR_SCHEMES, COLOR_SCHEME_TRAIT, COLOR_SCHEME_TYPES, ColorScheme, DEFAULT_FLAVOR_ID, DESIGN_TOKEN_GROUPS, DESIGN_TOKEN_TIERS, DESIGN_TOKEN_TYPES, DesignConfigKey, ELEMENT_STYLES, ELEMENT_STYLE_MARKER_CLASS, ELEMENT_STYLE_STATES, EMPTY_IMAGE_ATTRIBUTE, EMPTY_IMAGE_SRC, ElementStyleState, FLAVOR_SPEC_VERSION, FONT_CATALOG, FONT_FAMILY_TOKENS, FONT_FILE_ACCEPT, FONT_FILE_EXTENSIONS, FONT_FILE_FORMATS, FONT_STYLES, FONT_WEIGHTS, FontUploadError, GOOGLE_FONTS_CSS_ORIGIN, GOOGLE_FONTS_FILE_ORIGIN, MAX_FONT_FILE_BYTES, OwnedTraitLink, PALETTE_PRESETS, REDUCED_MOTION_OVERRIDES, REDUCED_TRANSPARENCY_OVERRIDES, REVERT_WINDOW_MS, SPEC_A11Y, SPEC_AXES, SPEC_BUTTON_VARIANT_TO_STYLE, SPEC_CONTRAST, SPEC_DEFAULT_ELEMENT_STYLE, SPEC_ELEMENT_STYLES, SPEC_FIELD_CLASS_BASELINE, SPEC_FLAVORS, SPEC_FLAVOR_PACKS, SPEC_FONTS, SPEC_FONT_ROLES, SPEC_LEGACY_ALIASES, SPEC_PALETTE_PRESETS, SPEC_SCHEMES, SPEC_SPRINGS, SPEC_TIERS, SPEC_TIER_IDS, SPEC_TOKEN_TYPES, SWISS_FLAVOR, USER_TOKEN_SOURCE, WCAG_AA_TEXT, apcaLc, applyElementStyle, applyHeadingLevelRule, buildFlavorTokens, buildFontFaceCss, catalogFontId, checkFontWeight, choicesForPack, colorSchemeClass, colorSchemeOf, compareFontWeights, compileSchemeCss, compileTokenCss, compileTokenCssBlocks, cssString, defaultDesignChoices, defaultElementStyleFor, deriveAccentTokens, deriveBrandTokens, designBaseline, designConfigEntries, designModeOf, designTokenRepairs, designTokenRows, elementStyleById, elementStyleClass, elementStylesFor, emptyImageLabelSrc, emptyImagePlaceholder, emptyImageSrc, flavorPackById, flavorSourceStamp, fontFamilyKey, fontFileName, fontFileStem, fontFormatOf, fontPreloads, fontRoleReferences, fontStackWithout, fontWeightCovers, fontWeightRange, fontWeightValue, fontsForTokens, formatFontFamilies, formatFontFamily, formatFontWeight, googleFontHref, groupFontFamilies, hasElementStyleMarker, isDesignTokenGroup, isDesignTokenTier, isDesignTokenType, isFontWeightRange, isRetiredFlavorId, legacyRuleTokenReferences, matchFontWeight, missingDesignRows, missingFontRoles, nodeDesignClasses, normalizeFontStyle, normalizeFontWeight, normalizeFontWeightValue, oklabToRgb, ownedTraitStatus, packDesignChoices, parseFontFamilies, parseFontWeight, parseHexColor, planDesignApply, planFlavorRevert, planFlavorSeed, planFontFamilyRemoval, planSwissMigration, previewFontWeight, readDesignConfig, relativeLuminance, resolveDesignChoices, resolveTokenReferences, resolveTokenValues, revertAvailable, rgbToOklab, sameDesignChoices, specTokenNames, springToLinear, stackNamesFamily, styleKeyToKebab, switchElementStyle, syncNodeDesignClasses, toHexColor, tokenReferences, tokensToDarkVarMap, tokensToVarMap, unknownTokenReferences, userFontStack, validateFlavorPack, wcagContrastRatio };
9042
- export type { AccentBackgrounds, AccentTokenName, ApplyElementStyleResult, DensityId, DesignChoices, DesignClassSource, DesignConfigEntry, DesignMode, DesignTokenGroup, DesignTokenLike, DesignTokenRow, DesignTokenTier, DesignTokenType, ElementStyle, ElementStyleTarget, ElementStyleTraitLike, FlavorPack, FlavorPackV2, FlavorRevertPlan, FlavorRevertSnapshot, FlavorSeedPlan, FlavorSpecToken, FlavorTokenDef, FontDescriptor, FontFamilyGroup, FontFamilyRemoval, FontFamilyToken, FontFormat, FontPair, FontRoleToken, FontStyle, FontWeight, FontWeightRange, FontsForTokensOptions, LinearSpring, MissingFontRole, MotionId, OkLab, OwnedTrait, OwnedTraitStatus, PalettePreset, ResolvedMode, Rgb, SchemeId, SeedBaseline, SeedExpectation, ShapeId, StoredDesign, StoredDesignTokenRow, SwissMigration, SwitchElementStyleResult, TokenCssBlocks, TokenCssOptions };
9175
+ export { ACCENT_TOKEN_NAMES, AdoptOutcome, AdoptSkipReason, BUTTON_VARIANT_TO_STYLE, COLOR_SCHEMES, COLOR_SCHEME_TRAIT, COLOR_SCHEME_TYPES, ColorScheme, DEFAULT_FLAVOR_ID, DESIGN_TOKEN_GROUPS, DESIGN_TOKEN_TIERS, DESIGN_TOKEN_TYPES, DesignConfigKey, ELEMENT_STYLES, ELEMENT_STYLE_MARKER_CLASS, ELEMENT_STYLE_STATES, EMPTY_IMAGE_ATTRIBUTE, EMPTY_IMAGE_SRC, ElementStyleState, FLAVOR_SPEC_VERSION, FONT_CATALOG, FONT_FAMILY_TOKENS, FONT_FILE_ACCEPT, FONT_FILE_EXTENSIONS, FONT_FILE_FORMATS, FONT_STYLES, FONT_WEIGHTS, FontUploadError, GOOGLE_FONTS_CSS_ORIGIN, GOOGLE_FONTS_FILE_ORIGIN, MAX_FONT_FILE_BYTES, NEW_NODE_STYLE_DEFAULTS, OwnedTraitLink, PALETTE_PRESETS, PRE_DS2_FLAVOR_DEFAULTS, REDUCED_MOTION_OVERRIDES, REDUCED_TRANSPARENCY_OVERRIDES, REVERT_WINDOW_MS, SPEC_A11Y, SPEC_AXES, SPEC_BUTTON_VARIANT_TO_STYLE, SPEC_CONTRAST, SPEC_DEFAULT_ELEMENT_STYLE, SPEC_ELEMENT_STYLES, SPEC_FIELD_CLASS_BASELINE, SPEC_FLAVORS, SPEC_FLAVOR_PACKS, SPEC_FONTS, SPEC_FONT_ROLES, SPEC_LEGACY_ALIASES, SPEC_PALETTE_PRESETS, SPEC_SCHEMES, SPEC_SPRINGS, SPEC_TIERS, SPEC_TIER_IDS, SPEC_TOKEN_TYPES, SUPERSEDED_STYLE_VALUES, SWISS_FLAVOR, USER_TOKEN_SOURCE, WCAG_AA_TEXT, adoptElementStyles, adoptionStyleFor, apcaLc, applyElementStyle, applyHeadingLevelRule, buildFlavorTokens, buildFontFaceCss, catalogFontId, checkFontWeight, choicesForPack, colorSchemeClass, colorSchemeOf, compareFontWeights, compileSchemeCss, compileTokenCss, compileTokenCssBlocks, cssString, defaultDesignChoices, defaultElementStyleFor, deriveAccentTokens, deriveBrandTokens, designBaseline, designConfigEntries, designModeOf, designTokenRepairs, designTokenRows, elementStyleById, elementStyleClass, elementStylesFor, emptyImageLabelSrc, emptyImagePlaceholder, emptyImageSrc, flavorPackById, flavorSourceStamp, fontFamilyKey, fontFileName, fontFileStem, fontFormatOf, fontPreloads, fontRoleReferences, fontStackWithout, fontWeightCovers, fontWeightRange, fontWeightValue, fontsForTokens, formatFontFamilies, formatFontFamily, formatFontWeight, googleFontHref, groupFontFamilies, hasElementStyleMarker, isDesignTokenGroup, isDesignTokenTier, isDesignTokenType, isFontWeightRange, isRetiredFlavorId, legacyRuleTokenReferences, matchFontWeight, missingDesignRows, missingFontRoles, nodeDesignClasses, normalizeFontStyle, normalizeFontWeight, normalizeFontWeightValue, oklabToRgb, ownedTraitStatus, ownedTraitsOf, packDesignChoices, parseFontFamilies, parseFontWeight, parseHexColor, planDesignApply, planFlavorRevert, planFlavorSeed, planFontFamilyRemoval, planSwissMigration, previewElementStyleAdoption, previewFontWeight, readDesignConfig, readOwnedTrait, relativeLuminance, resolveDesignChoices, resolveTokenReferences, resolveTokenValues, revertAvailable, rgbToOklab, sameDesignChoices, specTokenNames, springToLinear, stackNamesFamily, styleKeyToKebab, switchElementStyle, syncNodeDesignClasses, toHexColor, tokenReferences, tokensToDarkVarMap, tokensToVarMap, unknownTokenReferences, userFontStack, validateFlavorPack, wcagContrastRatio, writeOwnedTrait };
9176
+ export type { AccentBackgrounds, AccentTokenName, AdoptContext, AdoptReport, AdoptableNode, AdoptedNode, ApplyElementStyleResult, DensityId, DesignChoices, DesignClassSource, DesignConfigEntry, DesignMode, DesignTokenGroup, DesignTokenLike, DesignTokenRow, DesignTokenTier, DesignTokenType, ElementStyle, ElementStyleTarget, ElementStyleTraitLike, FlavorPack, FlavorPackV2, FlavorRevertPlan, FlavorRevertSnapshot, FlavorSeedPlan, FlavorSpecToken, FlavorTokenDef, FontDescriptor, FontFamilyGroup, FontFamilyRemoval, FontFamilyToken, FontFormat, FontPair, FontRoleToken, FontStyle, FontWeight, FontWeightRange, FontsForTokensOptions, KeptEdit, LinearSpring, MissingFontRole, MotionId, OkLab, OwnedTrait, OwnedTraitStatus, PalettePreset, ResolvedMode, Rgb, SchemeId, SeedBaseline, SeedExpectation, ShapeId, SkippedNode, StoredDesign, StoredDesignTokenRow, SupersededStyleValue, SwissMigration, SwitchElementStyleResult, TokenCssBlocks, TokenCssOptions };
@@ -9914,6 +9914,21 @@ function ownedEntries(style) {
9914
9914
  }
9915
9915
  return out;
9916
9916
  }
9917
+ /** Every trait the style owns with the value it writes — base first, then hover/active/focus. */
9918
+ function ownedTraitsOf(style) {
9919
+ return ownedEntries(style);
9920
+ }
9921
+ /** The node's value of one owned trait (a base trait, or a trait inside a pseudo-state map). */
9922
+ function readOwnedTrait(target, owned) {
9923
+ return owned.state ? readState(target, owned.state, owned.trait) : readBase(target, owned.trait);
9924
+ }
9925
+ /** Write one owned trait. False when a builder node has no slot for a base trait (dropped). */
9926
+ function writeOwnedTrait(target, owned, value) {
9927
+ if (!owned.state)
9928
+ return writeBase(target, owned.trait, value);
9929
+ writeState(target, owned.state, owned.trait, value);
9930
+ return true;
9931
+ }
9917
9932
  const sameOwned = (a, b) => a.trait === b.trait && a.state === b.state;
9918
9933
  function writeEntries(target, style, skip = []) {
9919
9934
  const unknown = [];
@@ -10043,6 +10058,202 @@ function applyHeadingLevelRule(target, oldLevel, newLevel, baseline = {}) {
10043
10058
  return switchElementStyle(target, from, to, baseline);
10044
10059
  }
10045
10060
 
10061
+ /**
10062
+ * ADOPT (design-system DS7, decision D5): link the nodes of a page saved before element styles to
10063
+ * the style a NEW node of their type is born wearing, so the page follows the look from then on.
10064
+ * Opt-in per page, one click, one undo step — this module is only the pure tree pass; the builder
10065
+ * owns the click, the history step and the save.
10066
+ *
10067
+ * The rule that keeps the author's work: a trait the style owns is rewritten to the style's
10068
+ * reference ONLY when the node still holds what an untouched node of its type was saved with — the
10069
+ * type's BASELINE (the unstyled constructor default the caller supplies), or a value a machine wrote
10070
+ * into every new node before element styles existed (`PRE_DS2_FLAVOR_DEFAULTS`). Anything else is an
10071
+ * author edit and is KEPT, and reported.
10072
+ *
10073
+ * A node that already wears a style is UPGRADED where it holds a value that style wrote in an OLDER
10074
+ * contract (`SUPERSEDED_STYLE_VALUES`) — the same untouched-means-machine-written rule, one version on.
10075
+ *
10076
+ * Works on both node shapes element-styles.ts does: a builder node (values in `styleTraits`) or a
10077
+ * serialized node (`styleProps`), so the server-side site build can run it too.
10078
+ */
10079
+ /**
10080
+ * What a NEW node holds before its element style is written (C1.1): running text inherits, so a
10081
+ * literal colour on any container would override the section's text. The factory
10082
+ * (`ComponentRegistryService.createConfig`) writes it; adopt releases a baseline colour to it, so an
10083
+ * adopted node is exactly what a new node of its type is.
10084
+ */
10085
+ const NEW_NODE_STYLE_DEFAULTS = { color: 'inherit' };
10086
+ /**
10087
+ * Values a machine wrote into every NEW node of a type before element styles: the F1 Swiss pack's
10088
+ * element defaults (`SWISS_FLAVOR.defaults`, iox-ui 5.3.0 `0a00761` + iox-builder 4.24.0 `85109eb`,
10089
+ * `createConfig → applyFlavorDefaults`, resolved by `resolveFlavorDefaults` to
10090
+ * `var(--iox-<token>, <pack value>)`; deleted in DS2). An untouched node created between F1 and DS2
10091
+ * holds exactly these, so they count as untouched.
10092
+ */
10093
+ const PRE_DS2_FLAVOR_DEFAULTS = {
10094
+ Button: { borderRadius: 'var(--iox-radius-control, 4px)', padding: 'var(--iox-space-control, 10px 18px)' },
10095
+ ButtonBlock: { borderRadius: 'var(--iox-radius-control, 4px)', padding: 'var(--iox-space-control, 10px 18px)' },
10096
+ Card: { borderRadius: 'var(--iox-radius-surface, 4px)' },
10097
+ };
10098
+ /**
10099
+ * Every element-style value the contract has superseded since element styles shipped (a diff of
10100
+ * `flavor-spec.v1.json`'s `elementStyles` across its history — nothing else changed a value):
10101
+ * - `b86c54f` (C1): body / lead `color: var(--iox-text)` → `inherit`;
10102
+ * - `602d96e` (C1.1): box / card / panel / nav gained `color: inherit` — before, they owned no colour.
10103
+ * A spec pins this list against the generated contract. Add an entry with every contract change.
10104
+ */
10105
+ const SUPERSEDED_STYLE_VALUES = [
10106
+ { style: 'body', trait: 'color', values: ['var(--iox-text)'], contract: 'b86c54f' },
10107
+ { style: 'lead', trait: 'color', values: ['var(--iox-text)'], contract: 'b86c54f' },
10108
+ { style: 'box', trait: 'color', values: [], wasUnowned: true, contract: '602d96e' },
10109
+ { style: 'card', trait: 'color', values: [], wasUnowned: true, contract: '602d96e' },
10110
+ { style: 'panel', trait: 'color', values: [], wasUnowned: true, contract: '602d96e' },
10111
+ { style: 'nav', trait: 'color', values: [], wasUnowned: true, contract: '602d96e' },
10112
+ ];
10113
+ var AdoptOutcome;
10114
+ (function (AdoptOutcome) {
10115
+ /** The node wore no style; it now wears its type's default (or its legacy Button variant's). */
10116
+ AdoptOutcome["Linked"] = "linked";
10117
+ /** The node wore a style; values that style wrote in an older contract were brought current. */
10118
+ AdoptOutcome["Upgraded"] = "upgraded";
10119
+ })(AdoptOutcome || (AdoptOutcome = {}));
10120
+ var AdoptSkipReason;
10121
+ (function (AdoptSkipReason) {
10122
+ /** The type is born wearing no style (Gallery, SliderContainer, Spacer, …). */
10123
+ AdoptSkipReason["NoStyle"] = "no-style";
10124
+ /** The node takes its look from a style preset — the author's own class. */
10125
+ AdoptSkipReason["Preset"] = "preset";
10126
+ /** The node is (inside) a linked symbol instance: its look is the symbol's, shared across pages. */
10127
+ AdoptSkipReason["Symbol"] = "symbol";
10128
+ })(AdoptSkipReason || (AdoptSkipReason = {}));
10129
+ const sameValue$1 = (a, b) => a === b || (a !== undefined && a !== null && b !== undefined && b !== null && String(a) === String(b));
10130
+ function propOf(node, name) {
10131
+ const fromProps = node.props?.[name];
10132
+ if (fromProps !== undefined)
10133
+ return fromProps;
10134
+ return node.traits?.find(t => t?.name === name)?.default;
10135
+ }
10136
+ /** The style an unstyled node adopts: a legacy Button by its `variant` (spec `buttonVariantToStyle`),
10137
+ * every other type by its default (a Heading by its level), or null. */
10138
+ function adoptionStyleFor(node) {
10139
+ if (node.type === 'Button') {
10140
+ const byVariant = BUTTON_VARIANT_TO_STYLE[String(propOf(node, 'variant') ?? '')];
10141
+ if (byVariant)
10142
+ return byVariant;
10143
+ }
10144
+ const traits = { ...(node.props ?? {}) };
10145
+ for (const t of node.traits ?? [])
10146
+ if (t?.name && !(t.name in traits))
10147
+ traits[t.name] = t.default;
10148
+ return defaultElementStyleFor(node.type, traits);
10149
+ }
10150
+ const owns = (style, trait) => trait in style.base;
10151
+ /** Release each new-node default the style does not own, where the node still holds its baseline. */
10152
+ function releaseNewNodeDefaults(node, style, baseline, written) {
10153
+ for (const [trait, value] of Object.entries(NEW_NODE_STYLE_DEFAULTS)) {
10154
+ if (style && owns(style, trait))
10155
+ continue;
10156
+ const ref = { trait };
10157
+ const current = readOwnedTrait(node, ref);
10158
+ if (current === undefined || sameValue$1(current, value) || !sameValue$1(current, baseline[trait]))
10159
+ continue;
10160
+ if (writeOwnedTrait(node, ref, value))
10161
+ written.push(ref);
10162
+ }
10163
+ }
10164
+ function untouched(node, trait, value, baseline) {
10165
+ return value === undefined || sameValue$1(value, baseline[trait]) || sameValue$1(value, PRE_DS2_FLAVOR_DEFAULTS[node.type]?.[trait]);
10166
+ }
10167
+ function link(node, style, baseline) {
10168
+ const written = [];
10169
+ const kept = [];
10170
+ for (const { value, ...ref } of ownedTraitsOf(style)) {
10171
+ const current = readOwnedTrait(node, ref);
10172
+ if (sameValue$1(current, value))
10173
+ continue;
10174
+ // A pseudo-state map has no baseline: a state value is always the author's.
10175
+ const free = ref.state ? current === undefined : untouched(node, ref.trait, current, baseline);
10176
+ if (!free) {
10177
+ kept.push({ ...ref, value: current });
10178
+ continue;
10179
+ }
10180
+ if (writeOwnedTrait(node, ref, value))
10181
+ written.push(ref);
10182
+ }
10183
+ releaseNewNodeDefaults(node, style, baseline, written);
10184
+ node.elementStyle = style.id;
10185
+ return { id: node.id, type: node.type, style: style.id, outcome: AdoptOutcome.Linked, written, kept };
10186
+ }
10187
+ function upgrade(node, style, baseline) {
10188
+ const written = [];
10189
+ for (const old of SUPERSEDED_STYLE_VALUES) {
10190
+ if (old.style !== style.id)
10191
+ continue;
10192
+ const ref = old.state ? { trait: old.trait, state: old.state } : { trait: old.trait };
10193
+ const now = old.state ? style[old.state]?.[old.trait] : style.base[old.trait];
10194
+ if (now === undefined)
10195
+ continue;
10196
+ const current = readOwnedTrait(node, ref);
10197
+ const before = old.wasUnowned ? [...old.values, baseline[old.trait]] : old.values;
10198
+ if (!before.some(v => sameValue$1(current, v)))
10199
+ continue;
10200
+ if (writeOwnedTrait(node, ref, now))
10201
+ written.push(ref);
10202
+ }
10203
+ releaseNewNodeDefaults(node, style, baseline, written);
10204
+ return written.length ? { id: node.id, type: node.type, style: style.id, outcome: AdoptOutcome.Upgraded, written, kept: [] } : null;
10205
+ }
10206
+ /**
10207
+ * Adopt every node of `tree` in place (children included) and report what happened. Skipped, never
10208
+ * touched: a node with a style preset, and every node of a linked symbol instance. A node whose type
10209
+ * has no default style is not linked, but an untouched baseline colour on it is released to the
10210
+ * new-node default all the same, so adopted text inside it is not painted the old literal.
10211
+ */
10212
+ function adoptElementStyles(tree, ctx) {
10213
+ const report = { adopted: [], skipped: [], kept: 0 };
10214
+ const visit = (nodes, inSymbol) => {
10215
+ for (const node of nodes ?? []) {
10216
+ if (!node?.type)
10217
+ continue;
10218
+ const symbol = inSymbol || !!node.symbolId;
10219
+ adoptNode(node, symbol, ctx, report);
10220
+ visit(node.children, symbol);
10221
+ }
10222
+ };
10223
+ visit(tree, false);
10224
+ report.kept = report.adopted.reduce((n, a) => n + a.kept.length, 0);
10225
+ return report;
10226
+ }
10227
+ function adoptNode(node, inSymbol, ctx, report) {
10228
+ const worn = elementStyleById(node.elementStyle);
10229
+ const target = worn ? null : elementStyleById(adoptionStyleFor(node));
10230
+ const reason = inSymbol ? AdoptSkipReason.Symbol : node.stylePresetId ? AdoptSkipReason.Preset : null;
10231
+ if (reason) {
10232
+ if (target)
10233
+ report.skipped.push({ id: node.id, type: node.type, reason });
10234
+ return;
10235
+ }
10236
+ const baseline = ctx.baseline(node.type) ?? {};
10237
+ if (worn) {
10238
+ const upgraded = upgrade(node, worn, baseline);
10239
+ if (upgraded)
10240
+ report.adopted.push(upgraded);
10241
+ return;
10242
+ }
10243
+ if (node.elementStyle)
10244
+ return;
10245
+ if (!target) {
10246
+ releaseNewNodeDefaults(node, null, baseline, []);
10247
+ report.skipped.push({ id: node.id, type: node.type, reason: AdoptSkipReason.NoStyle });
10248
+ return;
10249
+ }
10250
+ report.adopted.push(link(node, target, baseline));
10251
+ }
10252
+ /** What adopting `tree` WOULD do, without touching it (the banner's count). */
10253
+ function previewElementStyleAdoption(tree, ctx) {
10254
+ return adoptElementStyles(JSON.parse(JSON.stringify(tree ?? [])), ctx);
10255
+ }
10256
+
10046
10257
  /**
10047
10258
  * The design-system classes a node renders, in BOTH renderers (builder canvas, engine component
10048
10259
  * path, engine string path) — ONE helper, so the three can never disagree about which class a node
@@ -10816,14 +11027,23 @@ function fontsForTokens(tokens, opts = {}) {
10816
11027
  const monoRead = MONO_REFERENCE.test(opts.usedCss ?? '')
10817
11028
  || rows.some(t => t.name !== MONO_ROLE && MONO_REFERENCE.test(`${t.value ?? ''} ${t.values?.dark ?? ''}`));
10818
11029
  const roles = monoRead ? FONT_FAMILY_TOKENS : ALWAYS_LOADED_ROLES;
11030
+ const uploaded = new Set((opts.uploaded ?? []).map(fontFamilyKey));
10819
11031
  const seen = new Set();
10820
11032
  const ids = [];
10821
11033
  for (const role of roles) {
10822
11034
  const row = rows.find(t => t.name === role);
10823
- // The role's FIRST catalog family is the one that renders (or stands in for an uploaded
10824
- // family that is missing — `userFontStack` puts the look's font right after the author's);
10825
- // a catalog family further down is never reached, so it is never loaded.
10826
- const id = parseFontFamilies(row?.value ?? '').map(catalogFontId).find((x) => !!x);
11035
+ // The role's FIRST family that renders decides: an uploaded one needs nothing from Google; the
11036
+ // first catalog one is linked (it renders, or stands in for an uploaded family that is missing
11037
+ // — `userFontStack` puts the look's font right after the author's). Nothing further down is
11038
+ // ever reached, so nothing further down is loaded.
11039
+ let id = null;
11040
+ for (const family of parseFontFamilies(row?.value ?? '')) {
11041
+ if (uploaded.has(fontFamilyKey(family)))
11042
+ break;
11043
+ id = catalogFontId(family);
11044
+ if (id)
11045
+ break;
11046
+ }
10827
11047
  if (id && !seen.has(id)) {
10828
11048
  seen.add(id);
10829
11049
  ids.push(id);
@@ -11514,5 +11734,5 @@ function planFontFamilyRemoval(existing, previous, family) {
11514
11734
  * Generated bundle index. Do not edit.
11515
11735
  */
11516
11736
 
11517
- export { ACCENT_TOKEN_NAMES, BUTTON_VARIANT_TO_STYLE, COLOR_SCHEMES, COLOR_SCHEME_TRAIT, COLOR_SCHEME_TYPES, ColorScheme, DEFAULT_FLAVOR_ID, DESIGN_TOKEN_GROUPS, DESIGN_TOKEN_TIERS, DESIGN_TOKEN_TYPES, DesignConfigKey, ELEMENT_STYLES, ELEMENT_STYLE_MARKER_CLASS, ELEMENT_STYLE_STATES, EMPTY_IMAGE_ATTRIBUTE, EMPTY_IMAGE_SRC, ElementStyleState, FLAVOR_SPEC_VERSION, FONT_CATALOG, FONT_FAMILY_TOKENS, FONT_FILE_ACCEPT, FONT_FILE_EXTENSIONS, FONT_FILE_FORMATS, FONT_STYLES, FONT_WEIGHTS, FontUploadError, GOOGLE_FONTS_CSS_ORIGIN, GOOGLE_FONTS_FILE_ORIGIN, MAX_FONT_FILE_BYTES, OwnedTraitLink, PALETTE_PRESETS, REDUCED_MOTION_OVERRIDES, REDUCED_TRANSPARENCY_OVERRIDES, REVERT_WINDOW_MS, SPEC_A11Y, SPEC_AXES, SPEC_BUTTON_VARIANT_TO_STYLE, SPEC_CONTRAST, SPEC_DEFAULT_ELEMENT_STYLE, SPEC_ELEMENT_STYLES, SPEC_FIELD_CLASS_BASELINE, SPEC_FLAVORS, SPEC_FLAVOR_PACKS, SPEC_FONTS, SPEC_FONT_ROLES, SPEC_LEGACY_ALIASES, SPEC_PALETTE_PRESETS, SPEC_SCHEMES, SPEC_SPRINGS, SPEC_TIERS, SPEC_TIER_IDS, SPEC_TOKEN_TYPES, SWISS_FLAVOR, USER_TOKEN_SOURCE, WCAG_AA_TEXT, apcaLc, applyElementStyle, applyHeadingLevelRule, buildFlavorTokens, buildFontFaceCss, catalogFontId, checkFontWeight, choicesForPack, colorSchemeClass, colorSchemeOf, compareFontWeights, compileSchemeCss, compileTokenCss, compileTokenCssBlocks, cssString, defaultDesignChoices, defaultElementStyleFor, deriveAccentTokens, deriveBrandTokens, designBaseline, designConfigEntries, designModeOf, designTokenRepairs, designTokenRows, elementStyleById, elementStyleClass, elementStylesFor, emptyImageLabelSrc, emptyImagePlaceholder, emptyImageSrc, flavorPackById, flavorSourceStamp, fontFamilyKey, fontFileName, fontFileStem, fontFormatOf, fontPreloads, fontRoleReferences, fontStackWithout, fontWeightCovers, fontWeightRange, fontWeightValue, fontsForTokens, formatFontFamilies, formatFontFamily, formatFontWeight, googleFontHref, groupFontFamilies, hasElementStyleMarker, isDesignTokenGroup, isDesignTokenTier, isDesignTokenType, isFontWeightRange, isRetiredFlavorId, legacyRuleTokenReferences, matchFontWeight, missingDesignRows, missingFontRoles, nodeDesignClasses, normalizeFontStyle, normalizeFontWeight, normalizeFontWeightValue, oklabToRgb, ownedTraitStatus, packDesignChoices, parseFontFamilies, parseFontWeight, parseHexColor, planDesignApply, planFlavorRevert, planFlavorSeed, planFontFamilyRemoval, planSwissMigration, previewFontWeight, readDesignConfig, relativeLuminance, resolveDesignChoices, resolveTokenReferences, resolveTokenValues, revertAvailable, rgbToOklab, sameDesignChoices, specTokenNames, springToLinear, stackNamesFamily, styleKeyToKebab, switchElementStyle, syncNodeDesignClasses, toHexColor, tokenReferences, tokensToDarkVarMap, tokensToVarMap, unknownTokenReferences, userFontStack, validateFlavorPack, wcagContrastRatio };
11737
+ export { ACCENT_TOKEN_NAMES, AdoptOutcome, AdoptSkipReason, BUTTON_VARIANT_TO_STYLE, COLOR_SCHEMES, COLOR_SCHEME_TRAIT, COLOR_SCHEME_TYPES, ColorScheme, DEFAULT_FLAVOR_ID, DESIGN_TOKEN_GROUPS, DESIGN_TOKEN_TIERS, DESIGN_TOKEN_TYPES, DesignConfigKey, ELEMENT_STYLES, ELEMENT_STYLE_MARKER_CLASS, ELEMENT_STYLE_STATES, EMPTY_IMAGE_ATTRIBUTE, EMPTY_IMAGE_SRC, ElementStyleState, FLAVOR_SPEC_VERSION, FONT_CATALOG, FONT_FAMILY_TOKENS, FONT_FILE_ACCEPT, FONT_FILE_EXTENSIONS, FONT_FILE_FORMATS, FONT_STYLES, FONT_WEIGHTS, FontUploadError, GOOGLE_FONTS_CSS_ORIGIN, GOOGLE_FONTS_FILE_ORIGIN, MAX_FONT_FILE_BYTES, NEW_NODE_STYLE_DEFAULTS, OwnedTraitLink, PALETTE_PRESETS, PRE_DS2_FLAVOR_DEFAULTS, REDUCED_MOTION_OVERRIDES, REDUCED_TRANSPARENCY_OVERRIDES, REVERT_WINDOW_MS, SPEC_A11Y, SPEC_AXES, SPEC_BUTTON_VARIANT_TO_STYLE, SPEC_CONTRAST, SPEC_DEFAULT_ELEMENT_STYLE, SPEC_ELEMENT_STYLES, SPEC_FIELD_CLASS_BASELINE, SPEC_FLAVORS, SPEC_FLAVOR_PACKS, SPEC_FONTS, SPEC_FONT_ROLES, SPEC_LEGACY_ALIASES, SPEC_PALETTE_PRESETS, SPEC_SCHEMES, SPEC_SPRINGS, SPEC_TIERS, SPEC_TIER_IDS, SPEC_TOKEN_TYPES, SUPERSEDED_STYLE_VALUES, SWISS_FLAVOR, USER_TOKEN_SOURCE, WCAG_AA_TEXT, adoptElementStyles, adoptionStyleFor, apcaLc, applyElementStyle, applyHeadingLevelRule, buildFlavorTokens, buildFontFaceCss, catalogFontId, checkFontWeight, choicesForPack, colorSchemeClass, colorSchemeOf, compareFontWeights, compileSchemeCss, compileTokenCss, compileTokenCssBlocks, cssString, defaultDesignChoices, defaultElementStyleFor, deriveAccentTokens, deriveBrandTokens, designBaseline, designConfigEntries, designModeOf, designTokenRepairs, designTokenRows, elementStyleById, elementStyleClass, elementStylesFor, emptyImageLabelSrc, emptyImagePlaceholder, emptyImageSrc, flavorPackById, flavorSourceStamp, fontFamilyKey, fontFileName, fontFileStem, fontFormatOf, fontPreloads, fontRoleReferences, fontStackWithout, fontWeightCovers, fontWeightRange, fontWeightValue, fontsForTokens, formatFontFamilies, formatFontFamily, formatFontWeight, googleFontHref, groupFontFamilies, hasElementStyleMarker, isDesignTokenGroup, isDesignTokenTier, isDesignTokenType, isFontWeightRange, isRetiredFlavorId, legacyRuleTokenReferences, matchFontWeight, missingDesignRows, missingFontRoles, nodeDesignClasses, normalizeFontStyle, normalizeFontWeight, normalizeFontWeightValue, oklabToRgb, ownedTraitStatus, ownedTraitsOf, packDesignChoices, parseFontFamilies, parseFontWeight, parseHexColor, planDesignApply, planFlavorRevert, planFlavorSeed, planFontFamilyRemoval, planSwissMigration, previewElementStyleAdoption, previewFontWeight, readDesignConfig, readOwnedTrait, relativeLuminance, resolveDesignChoices, resolveTokenReferences, resolveTokenValues, revertAvailable, rgbToOklab, sameDesignChoices, specTokenNames, springToLinear, stackNamesFamily, styleKeyToKebab, switchElementStyle, syncNodeDesignClasses, toHexColor, tokenReferences, tokensToDarkVarMap, tokensToVarMap, unknownTokenReferences, userFontStack, validateFlavorPack, wcagContrastRatio, writeOwnedTrait };
11518
11738
  //# sourceMappingURL=vectoriox-iox-ui-design-core.mjs.map