@sky.ui/core 0.0.43 → 0.0.44

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.
@@ -1,2 +1,2 @@
1
- import{ContextConsumer as s}from"@lit/context";import{configContext as t,findNearestPresetsConfig as e,captureInitialUserAttributes as i,clearAppliedPresetLayer as o,getPresetLayer as h,applyPresetLayer as n}from"../utils/component-presets.js";class p{constructor(e,i={}){this.host=e,this.options=i,this.revision=0,this._lastPresetName="",this._lastPaused=!1,this._applyQueued=!1,this._consumer=new s(this.host,{context:t,subscribe:!0,callback:()=>{this._scheduleApply()}}),this.host.addController(this)}get componentKey(){return this.options.componentKey||this.host.localName||""}get config(){const s=this._consumer.value;return s&&(s.defaults||s.presets)?s:e(this.host)??s??null}hostConnected(){i(this.host),this._scheduleApply()}hostUpdate(){const s=String(this.host.preset??""),t=Boolean(this.options.isPaused?.());(s!==this._lastPresetName||t!==this._lastPaused||this._applyQueued)&&this._applyNow()}hostDisconnected(){}reapply(){this._scheduleApply()}_scheduleApply(){this._applyQueued=!0,this.revision++,this.host.requestUpdate()}_applyNow(){this._applyQueued=!1;const s=String(this.host.preset??""),t=Boolean(this.options.isPaused?.());this._lastPresetName=s,this._lastPaused=t;let e=!1;if(t)e=o(this.host);else{const t=h(this.config,this.componentKey,s||null);e=n(this.host,t,{skipKeys:this.options.skipKeys})}e&&(this.revision++,this.options.onChange?.(),queueMicrotask(()=>this.host.requestUpdate()))}}export{p as PresetController};
1
+ import{ContextConsumer as s}from"@lit/context";import{configContext as t,captureBuiltInPropSnapshot as e,findNearestPresetsConfig as i,finalizeBuiltInPropSnapshot as o,captureInitialUserAttributes as h,clearAppliedPresetLayer as n,getPresetLayer as p,applyPresetLayer as l}from"../utils/component-presets.js";class a{constructor(i,o={}){this.host=i,this.options=o,this.revision=0,this._lastPresetName="",this._lastPaused=!1,this._applyQueued=!1,this._consumer=new s(this.host,{context:t,subscribe:!0,callback:()=>{this._scheduleApply()}}),this.host.addController(this),e(this.host)}get componentKey(){return this.options.componentKey||this.host.localName||""}get config(){const s=this._consumer.value;return s&&(s.defaults||s.presets)?s:i(this.host)??s??null}hostConnected(){o(this.host),h(this.host),this._scheduleApply()}hostUpdate(){const s=String(this.host.preset??""),t=Boolean(this.options.isPaused?.());(s!==this._lastPresetName||t!==this._lastPaused||this._applyQueued)&&this._applyNow()}hostDisconnected(){}reapply(){this._scheduleApply()}_scheduleApply(){this._applyQueued=!0,this.revision++,this.host.requestUpdate()}_applyNow(){this._applyQueued=!1;const s=String(this.host.preset??""),t=Boolean(this.options.isPaused?.());this._lastPresetName=s,this._lastPaused=t;let e=!1;if(t)e=n(this.host);else{const t=p(this.config,this.componentKey,s||null);e=l(this.host,t,{skipKeys:this.options.skipKeys})}e&&(this.revision++,this.options.onChange?.(),queueMicrotask(()=>this.host.requestUpdate()))}}export{a as PresetController};
2
2
  //# sourceMappingURL=preset-controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preset-controller.js","sources":["../../../src/helper/controllers/preset-controller.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport { ContextConsumer } from \"@lit/context\";\nimport {\n applyPresetLayer,\n captureInitialUserAttributes,\n clearAppliedPresetLayer,\n configContext,\n findNearestPresetsConfig,\n getPresetLayer,\n type ComponentPresetKey,\n type ComponentPresetsConfig,\n} from \"../utils/component-presets.js\";\n\ntype PresetHost = ReactiveControllerHost &\n HTMLElement & {\n preset?: string;\n };\n\nexport type PresetControllerOptions = {\n /**\n * Config key under `defaults` / `presets`.\n * Prefer the custom element tag (`sky-button`). Defaults to `host.localName`.\n * Short aliases (`button`) resolve to the same bag.\n */\n componentKey?: ComponentPresetKey;\n /**\n * When true, clear preset-applied props (e.g. `sky-button` inside a group\n * that owns visual knobs).\n */\n isPaused?: () => boolean;\n /** Called after props are applied / cleared (e.g. mark style cache dirty). */\n onChange?: () => void;\n /** Prop names never written from presets. */\n skipKeys?: string[];\n};\n\n/**\n * Consumes nearest `<sky-config-provider>` and **assigns every prop** from the\n * active defaults + named `preset` bag onto the host (unless the user set that\n * attribute). Changing the provider config or `preset=\"…\"` re-applies the bag.\n *\n * Timing note (Lit reactive-element ≥2): controller `hostUpdate` runs *after*\n * the host's `willUpdate` and *before* `update`/render. Components that derive\n * paint from props must rebuild in `update()`/`updated()` (not `willUpdate`),\n * or rely on the follow-up `requestUpdate` scheduled when props change.\n */\nexport class PresetController implements ReactiveController {\n private readonly _consumer: ContextConsumer<\n typeof configContext,\n PresetHost\n >;\n\n /** Bumps when context / applied props change. */\n revision = 0;\n\n private _lastPresetName = \"\";\n private _lastPaused = false;\n private _applyQueued = false;\n\n constructor(\n private readonly host: PresetHost,\n private readonly options: PresetControllerOptions = {},\n ) {\n this._consumer = new ContextConsumer(this.host, {\n context: configContext,\n subscribe: true,\n callback: () => {\n this._scheduleApply();\n },\n });\n this.host.addController(this);\n }\n\n /** Tag name (or explicit override) used to look up config bags. */\n get componentKey(): ComponentPresetKey {\n return this.options.componentKey || this.host.localName || \"\";\n }\n\n /** Merged presets from context, or nearest provider via DOM walk. */\n get config(): ComponentPresetsConfig | null {\n const fromCtx = this._consumer.value;\n if (fromCtx && (fromCtx.defaults || fromCtx.presets)) {\n return fromCtx;\n }\n return findNearestPresetsConfig(this.host) ?? fromCtx ?? null;\n }\n\n hostConnected(): void {\n captureInitialUserAttributes(this.host);\n this._scheduleApply();\n }\n\n hostUpdate(): void {\n const presetName = String(this.host.preset ?? \"\");\n const paused = Boolean(this.options.isPaused?.());\n if (\n presetName !== this._lastPresetName ||\n paused !== this._lastPaused ||\n this._applyQueued\n ) {\n this._applyNow();\n }\n }\n\n hostDisconnected(): void {\n // ContextConsumer cleans up with the host.\n }\n\n /** Force re-apply (e.g. after imperative config tweaks). */\n reapply(): void {\n this._scheduleApply();\n }\n\n private _scheduleApply(): void {\n this._applyQueued = true;\n this.revision++;\n this.host.requestUpdate();\n }\n\n private _applyNow(): void {\n this._applyQueued = false;\n const presetName = String(this.host.preset ?? \"\");\n const paused = Boolean(this.options.isPaused?.());\n this._lastPresetName = presetName;\n this._lastPaused = paused;\n\n let changed = false;\n if (paused) {\n changed = clearAppliedPresetLayer(this.host);\n } else {\n const layer = getPresetLayer(\n this.config,\n this.componentKey,\n presetName || null,\n );\n changed = applyPresetLayer(this.host, layer, {\n skipKeys: this.options.skipKeys,\n });\n }\n\n if (changed) {\n this.revision++;\n this.options.onChange?.();\n // Props were written during hostUpdate (after willUpdate). Lit will not\n // enqueue another update while one is pending, and the mid-update writes\n // are wiped from the pending-change map at end of update — so schedule a\n // follow-up pass for hosts that still resolve styles in willUpdate.\n queueMicrotask(() => this.host.requestUpdate());\n }\n }\n}\n"],"names":["PresetController","constructor","host","options","this","revision","_lastPresetName","_lastPaused","_applyQueued","_consumer","ContextConsumer","context","configContext","subscribe","callback","_scheduleApply","addController","componentKey","localName","config","fromCtx","value","defaults","presets","findNearestPresetsConfig","hostConnected","captureInitialUserAttributes","hostUpdate","presetName","String","preset","paused","Boolean","isPaused","_applyNow","hostDisconnected","reapply","requestUpdate","changed","clearAppliedPresetLayer","layer","getPresetLayer","applyPresetLayer","skipKeys","onChange","queueMicrotask"],"mappings":"oPA8CO,MAAMA,EAaX,WAAAC,CACmBC,EACAC,EAAmC,IADnCC,KAAAF,KAAAA,EACAE,KAAAD,QAAAA,EARnBC,KAAAC,SAAW,EAEXD,KAAQE,gBAAkB,GAC1BF,KAAQG,aAAc,EACtBH,KAAQI,cAAe,EAMrBJ,KAAKK,UAAY,IAAIC,EAAgBN,KAAKF,KAAM,CAC9CS,QAASC,EACTC,WAAW,EACXC,SAAU,KACRV,KAAKW,oBAGTX,KAAKF,KAAKc,cAAcZ,KAC1B,CAGA,gBAAIa,GACF,OAAOb,KAAKD,QAAQc,cAAgBb,KAAKF,KAAKgB,WAAa,EAC7D,CAGA,UAAIC,GACF,MAAMC,EAAUhB,KAAKK,UAAUY,MAC/B,OAAID,IAAYA,EAAQE,UAAYF,EAAQG,SACnCH,EAEFI,EAAyBpB,KAAKF,OAASkB,GAAW,IAC3D,CAEA,aAAAK,GACEC,EAA6BtB,KAAKF,MAClCE,KAAKW,gBACP,CAEA,UAAAY,GACE,MAAMC,EAAaC,OAAOzB,KAAKF,KAAK4B,QAAU,IACxCC,EAASC,QAAQ5B,KAAKD,QAAQ8B,eAElCL,IAAexB,KAAKE,iBACpByB,IAAW3B,KAAKG,aAChBH,KAAKI,eAELJ,KAAK8B,WAET,CAEA,gBAAAC,GAEA,CAGA,OAAAC,GACEhC,KAAKW,gBACP,CAEQ,cAAAA,GACNX,KAAKI,cAAe,EACpBJ,KAAKC,WACLD,KAAKF,KAAKmC,eACZ,CAEQ,SAAAH,GACN9B,KAAKI,cAAe,EACpB,MAAMoB,EAAaC,OAAOzB,KAAKF,KAAK4B,QAAU,IACxCC,EAASC,QAAQ5B,KAAKD,QAAQ8B,cACpC7B,KAAKE,gBAAkBsB,EACvBxB,KAAKG,YAAcwB,EAEnB,IAAIO,GAAU,EACd,GAAIP,EACFO,EAAUC,EAAwBnC,KAAKF,UAClC,CACL,MAAMsC,EAAQC,EACZrC,KAAKe,OACLf,KAAKa,aACLW,GAAc,MAEhBU,EAAUI,EAAiBtC,KAAKF,KAAMsC,EAAO,CAC3CG,SAAUvC,KAAKD,QAAQwC,UAE3B,CAEIL,IACFlC,KAAKC,WACLD,KAAKD,QAAQyC,aAKbC,eAAe,IAAMzC,KAAKF,KAAKmC,iBAEnC"}
1
+ {"version":3,"file":"preset-controller.js","sources":["../../../src/helper/controllers/preset-controller.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from \"lit\";\nimport { ContextConsumer } from \"@lit/context\";\nimport {\n applyPresetLayer,\n captureBuiltInPropSnapshot,\n captureInitialUserAttributes,\n clearAppliedPresetLayer,\n configContext,\n finalizeBuiltInPropSnapshot,\n findNearestPresetsConfig,\n getPresetLayer,\n type ComponentPresetKey,\n type ComponentPresetsConfig,\n} from \"../utils/component-presets.js\";\n\ntype PresetHost = ReactiveControllerHost &\n HTMLElement & {\n preset?: string;\n };\n\nexport type PresetControllerOptions = {\n /**\n * Config key under `defaults` / `presets`.\n * Prefer the custom element tag (`sky-button`). Defaults to `host.localName`.\n * Short aliases (`button`) resolve to the same bag.\n */\n componentKey?: ComponentPresetKey;\n /**\n * When true, clear preset-applied props (e.g. `sky-button` inside a group\n * that owns visual knobs).\n */\n isPaused?: () => boolean;\n /** Called after props are applied / cleared (e.g. mark style cache dirty). */\n onChange?: () => void;\n /** Prop names never written from presets. */\n skipKeys?: string[];\n};\n\n/**\n * Consumes nearest `<sky-config-provider>` and **assigns every prop** from the\n * active defaults + named `preset` bag onto the host (unless the user set that\n * attribute). Changing the provider config or `preset=\"…\"` re-applies the bag.\n *\n * Timing note (Lit reactive-element ≥2): controller `hostUpdate` runs *after*\n * the host's `willUpdate` and *before* `update`/render. Components that derive\n * paint from props must rebuild in `update()`/`updated()` (not `willUpdate`),\n * or rely on the follow-up `requestUpdate` scheduled when props change.\n */\nexport class PresetController implements ReactiveController {\n private readonly _consumer: ContextConsumer<\n typeof configContext,\n PresetHost\n >;\n\n /** Bumps when context / applied props change. */\n revision = 0;\n\n private _lastPresetName = \"\";\n private _lastPaused = false;\n private _applyQueued = false;\n\n constructor(\n private readonly host: PresetHost,\n private readonly options: PresetControllerOptions = {},\n ) {\n this._consumer = new ContextConsumer(this.host, {\n context: configContext,\n subscribe: true,\n callback: () => {\n this._scheduleApply();\n },\n });\n this.host.addController(this);\n // Snapshot @property initials now (before Vue/React assign host props).\n // Keep this field initializer after presettable props on the host class.\n captureBuiltInPropSnapshot(this.host);\n }\n\n /** Tag name (or explicit override) used to look up config bags. */\n get componentKey(): ComponentPresetKey {\n return this.options.componentKey || this.host.localName || \"\";\n }\n\n /** Merged presets from context, or nearest provider via DOM walk. */\n get config(): ComponentPresetsConfig | null {\n const fromCtx = this._consumer.value;\n if (fromCtx && (fromCtx.defaults || fromCtx.presets)) {\n return fromCtx;\n }\n return findNearestPresetsConfig(this.host) ?? fromCtx ?? null;\n }\n\n hostConnected(): void {\n finalizeBuiltInPropSnapshot(this.host);\n captureInitialUserAttributes(this.host);\n this._scheduleApply();\n }\n\n hostUpdate(): void {\n const presetName = String(this.host.preset ?? \"\");\n const paused = Boolean(this.options.isPaused?.());\n if (\n presetName !== this._lastPresetName ||\n paused !== this._lastPaused ||\n this._applyQueued\n ) {\n this._applyNow();\n }\n }\n\n hostDisconnected(): void {\n // ContextConsumer cleans up with the host.\n }\n\n /** Force re-apply (e.g. after imperative config tweaks). */\n reapply(): void {\n this._scheduleApply();\n }\n\n private _scheduleApply(): void {\n this._applyQueued = true;\n this.revision++;\n this.host.requestUpdate();\n }\n\n private _applyNow(): void {\n this._applyQueued = false;\n const presetName = String(this.host.preset ?? \"\");\n const paused = Boolean(this.options.isPaused?.());\n this._lastPresetName = presetName;\n this._lastPaused = paused;\n\n let changed = false;\n if (paused) {\n changed = clearAppliedPresetLayer(this.host);\n } else {\n const layer = getPresetLayer(\n this.config,\n this.componentKey,\n presetName || null,\n );\n changed = applyPresetLayer(this.host, layer, {\n skipKeys: this.options.skipKeys,\n });\n }\n\n if (changed) {\n this.revision++;\n this.options.onChange?.();\n // Props were written during hostUpdate (after willUpdate). Lit will not\n // enqueue another update while one is pending, and the mid-update writes\n // are wiped from the pending-change map at end of update — so schedule a\n // follow-up pass for hosts that still resolve styles in willUpdate.\n queueMicrotask(() => this.host.requestUpdate());\n }\n }\n}\n"],"names":["PresetController","constructor","host","options","this","revision","_lastPresetName","_lastPaused","_applyQueued","_consumer","ContextConsumer","context","configContext","subscribe","callback","_scheduleApply","addController","captureBuiltInPropSnapshot","componentKey","localName","config","fromCtx","value","defaults","presets","findNearestPresetsConfig","hostConnected","finalizeBuiltInPropSnapshot","captureInitialUserAttributes","hostUpdate","presetName","String","preset","paused","Boolean","isPaused","_applyNow","hostDisconnected","reapply","requestUpdate","changed","clearAppliedPresetLayer","layer","getPresetLayer","applyPresetLayer","skipKeys","onChange","queueMicrotask"],"m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ZvC,KAAKgB,OACLhB,KAAKc,aACLY,GAAc,MAEhBU,EAAUI,EAAiBxC,KAAKF,KAAMwC,EAAO,CAC3CG,SAAUzC,KAAKD,QAAQ0C,UAE3B,CAEIL,IACFpC,KAAKC,WACLD,KAAKD,QAAQ2C,aAKbC,eAAe,IAAM3C,KAAKF,KAAKqC,iBAEnC"}
@@ -1,2 +1,2 @@
1
- export{extractIconNames,fetchIconsForOffline,registerOfflineIcons}from"./iconify-offline.js";export{AnimationController}from"./controllers/animation-controller.js";export{CONTRAST_COLOR_SUPPORT_QUERY,ON_COLOR_FALLBACK_DARK,ON_COLOR_FALLBACK_LIGHT,contrastOnFill,contrastOverlay,contrastThemeInk,cssContrastColor,cssOnFill,cssOnFillEnhance,isLightFill,parseCssRgb,perceivedLuminance,relativeLuminance}from"./utils/contrast-color.js";export{ColorResolver,DEFAULT_COLOR_TOKENS,colorResolver,createGradient,darkShade,fadeMix,hoverShade,isDefaultColorToken,lightShade,parseGradientSpec,resolveAccentColorForToken,resolveColor,resolveGradientStop,resolveInkColorForToken,resolveSemanticSurfaceKey,semanticSoftSurfaceTokens,skyBorderPrimaryShorthand,skyBorderWidthSolid,tuneSurfaceVariantForDefaultColor}from"./utils/color-resolver.js";export{FormControlBase}from"./internals/form-control-base.js";export{PopoverController}from"./controllers/popover-controller.js";export{PresetController}from"./controllers/preset-controller.js";export{applyPresetLayer,camelToKebab,captureInitialUserAttributes,clearAppliedPresetLayer,configContext,findNearestPresetsConfig,getPresetLayer,isUserSetProp,lookupPresetSection,markUserSetProp,mergePresetsConfig,presetKeyAliases,refreshUserAttributes,resolveComponentProps,toPresetTagKey}from"./utils/component-presets.js";export{resolveRadius}from"./utils/size-resolver.js";
1
+ export{extractIconNames,fetchIconsForOffline,registerOfflineIcons}from"./iconify-offline.js";export{AnimationController}from"./controllers/animation-controller.js";export{CONTRAST_COLOR_SUPPORT_QUERY,ON_COLOR_FALLBACK_DARK,ON_COLOR_FALLBACK_LIGHT,contrastOnFill,contrastOverlay,contrastThemeInk,cssContrastColor,cssOnFill,cssOnFillEnhance,isLightFill,parseCssRgb,perceivedLuminance,relativeLuminance}from"./utils/contrast-color.js";export{ColorResolver,DEFAULT_COLOR_TOKENS,colorResolver,createGradient,darkShade,fadeMix,hoverShade,isDefaultColorToken,lightShade,parseGradientSpec,resolveAccentColorForToken,resolveColor,resolveGradientStop,resolveInkColorForToken,resolveSemanticSurfaceKey,semanticSoftSurfaceTokens,skyBorderPrimaryShorthand,skyBorderWidthSolid,tuneSurfaceVariantForDefaultColor}from"./utils/color-resolver.js";export{FormControlBase}from"./internals/form-control-base.js";export{PopoverController}from"./controllers/popover-controller.js";export{PresetController}from"./controllers/preset-controller.js";export{applyPresetLayer,camelToKebab,captureBuiltInPropSnapshot,captureInitialUserAttributes,clearAppliedPresetLayer,configContext,finalizeBuiltInPropSnapshot,findNearestPresetsConfig,getPresetLayer,isUserSetProp,lookupPresetSection,markUserSetProp,mergePresetsConfig,presetKeyAliases,refreshUserAttributes,resolveComponentProps,toPresetTagKey}from"./utils/component-presets.js";export{resolveRadius}from"./utils/size-resolver.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -2,8 +2,8 @@
2
2
  * Component prop presets — global defaults + named bundles for sky-* CEs.
3
3
  *
4
4
  * Precedence (highest wins):
5
- * explicit user prop (attribute or marked/diverged property) → named `preset`
6
- * → provider `defaults` → built-in class default
5
+ * explicit user prop (attribute, framework property, or marked/diverged) →
6
+ * named `preset` → provider `defaults` → built-in class default
7
7
  *
8
8
  * A named preset overlays `defaults` unless it sets `$inheritDefaults: false`,
9
9
  * in which case it is used standalone (keys it omits fall to the built-in).
@@ -12,6 +12,10 @@
12
12
  * - attributes present before Lit's first reflect (and any attrs added later)
13
13
  * - props marked via `markUserSetProp`
14
14
  * - props the consumer changed after presets applied (divergence)
15
+ * - props a framework set before first apply (current value ≠ constructor
16
+ * snapshot from `captureBuiltInPropSnapshot` — covers Vue/React CE property
17
+ * bindings that never create attributes). Overriding *back* to the exact
18
+ * built-in default still needs an attribute or `markUserSetProp`.
15
19
  *
16
20
  * @see sky-config-provider
17
21
  */
@@ -57,6 +61,23 @@ export declare function camelToKebab(name: string): string;
57
61
  * Declarative HTML / early `setAttribute` calls are treated as user-owned thereafter.
58
62
  */
59
63
  export declare function captureInitialUserAttributes(host: HTMLElement): void;
64
+ /**
65
+ * Snapshot Lit `@property` values once during host construction (before frameworks
66
+ * assign props). Later diffs against this map mark framework property bindings as
67
+ * user-owned so presets do not overwrite them.
68
+ *
69
+ * Declare `PresetController` after the host's presettable `@property` fields so
70
+ * those initials are already assigned when this runs. Keys still `undefined` are
71
+ * filled by `finalizeBuiltInPropSnapshot` on connect (constructor-body defaults).
72
+ */
73
+ export declare function captureBuiltInPropSnapshot(host: HTMLElement): void;
74
+ /**
75
+ * Fill snapshot entries that were still `undefined` when the controller
76
+ * constructed (e.g. defaults assigned in the host `constructor` body after the
77
+ * controller field). Does not overwrite defined snapshot values — those are the
78
+ * true built-ins Vue/React may have already overridden by connect time.
79
+ */
80
+ export declare function finalizeBuiltInPropSnapshot(host: HTMLElement): void;
60
81
  /**
61
82
  * Merge any attributes that appeared after connect (late framework bindings)
62
83
  * into the user-owned attribute snapshot.
@@ -69,7 +90,9 @@ export declare function refreshUserAttributes(host: HTMLElement): void;
69
90
  export declare function markUserSetProp(host: HTMLElement, prop: string): void;
70
91
  /**
71
92
  * True when the host had an attribute for this prop before/at apply time,
72
- * or the prop was marked user-owned (explicit mark or post-apply divergence).
93
+ * the prop was marked user-owned (explicit mark or post-apply divergence),
94
+ * or a framework assigned a property that differs from the constructor snapshot
95
+ * before presets first wrote that key.
73
96
  */
74
97
  export declare function isUserSetProp(host: HTMLElement, prop: string): boolean;
75
98
  /**
@@ -115,7 +138,8 @@ export type ApplyPresetLayerOptions = {
115
138
  *
116
139
  * Before writing, detects divergence: if the host value no longer matches the
117
140
  * last preset-applied value, that prop is marked user-owned (property-only
118
- * overrides after first apply).
141
+ * overrides after first apply). Also locks in framework property bindings that
142
+ * differ from the constructor snapshot before the first write for that key.
119
143
  *
120
144
  * @returns true if any host property changed
121
145
  */
@@ -1,2 +1,2 @@
1
- import{createContext as t}from"@lit/context";const e=new Set(["$inheritDefaults"]);function n(t){const e=String(t||"").trim();if(!e)return[];const n=new Set([e]);return e.startsWith("sky-")?n.add(e.slice(4)):n.add(`sky-${e}`),[...n]}function o(t,e){if(t)for(const o of n(e))if(Object.prototype.hasOwnProperty.call(t,o))return t[o]}function s(t){const e=String(t||"").trim();return e?e.startsWith("sky-")?e:`sky-${e}`:e}const r=t("sky/component-presets");function c(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}const f=new WeakMap,i=new WeakMap,u=new WeakMap;function a(t){f.has(t)||f.set(t,new Set(t.getAttributeNames()))}function l(t){const e=f.get(t)??new Set;for(const n of t.getAttributeNames())e.add(n);f.set(t,e)}function p(t,e){const n=i.get(t)??new Set;n.add(e),i.set(t,n)}function g(t,e){if(i.get(t)?.has(e))return!0;const n=c(e),o=f.get(t);return o?o.has(n)||n!==e&&o.has(e):t.hasAttribute(n)||n!==e&&t.hasAttribute(e)}function d(t,e){const n=t??{},o=e??{},r={};for(const t of[n.defaults,o.defaults])for(const[e,n]of Object.entries(t??{})){const t=s(e);r[t]={...r[t]??{},...n??{}}}const c={};for(const t of[n.presets,o.presets])for(const[e,n]of Object.entries(t??{})){const t=s(e),o={...c[t]??{}};for(const[t,e]of Object.entries(n??{}))o[t]={...o[t]??{},...e??{}};c[t]=o}return{defaults:r,presets:c}}function h(t){const e=[];let n=t.parentElement;for(;n;){if("sky-config-provider"===n.localName){const t=n;if(t.mergedConfig)return t.mergedConfig;t.presets&&e.push(t.presets)}n=n.parentElement}return e.length?e.reduceRight((t,e)=>d(t,e),{}):null}function w(t,o,s){const r=function(t,e){if(!t)return{};let o={};for(const s of n(e)){const e=t[s];e&&(o={...o,...e})}return o}(t?.defaults,o),c=function(t,e){if(!t)return{};const o={};for(const s of n(e)){const e=t[s];if(e)for(const[t,n]of Object.entries(e))o[t]={...o[t]??{},...n??{}}}return o}(t?.presets,o),f=s&&c[s]?c[s]:null,i=f&&!1===f.$inheritDefaults?{...f}:{...r,...f??{}};for(const t of e)delete i[t];return i}const y=new WeakMap,k=new Set(["preset",...e]);function m(t,e,n){l(t),function(t){const e=u.get(t);if(!e?.size)return;const n=t;for(const[o,s]of e)g(t,o)||n[o]!==s&&p(t,o)}(t);const o=new Set([...k,...n?.skipKeys??[]]),s=y.get(t)??new Map,r=u.get(t)??new Map;let c=!1;const f=t;for(const n of[...s.keys()])if(!Object.prototype.hasOwnProperty.call(e,n)||void 0===e[n]){if(!g(t,n)&&s.has(n)){const t=s.get(n);f[n]!==t&&(f[n]=t,c=!0)}s.delete(n),r.delete(n)}for(const[n,i]of Object.entries(e))o.has(n)||void 0===i||(g(t,n)?r.delete(n):(s.has(n)||s.set(n,f[n]),f[n]!==i&&(f[n]=i,c=!0),r.set(n,i)));return y.set(t,s),u.set(t,r),c}function b(t){const e=y.get(t);if(!e?.size)return!1;const n=t;let o=!1;for(const[s,r]of e)g(t,s)||n[s]!==r&&(n[s]=r,o=!0);return e.clear(),u.get(t)?.clear(),o}function O(t){const{host:e,componentKey:n,presetName:o,config:s,values:r,keys:c}=t,f=w(s,n,o),i=c??Object.keys(f),u={...r};for(const t of i){const n=t;g(e,n)||Object.prototype.hasOwnProperty.call(f,n)&&void 0!==f[n]&&(u[n]=f[n])}return u}export{m as applyPresetLayer,c as camelToKebab,a as captureInitialUserAttributes,b as clearAppliedPresetLayer,r as configContext,h as findNearestPresetsConfig,w as getPresetLayer,g as isUserSetProp,o as lookupPresetSection,p as markUserSetProp,d as mergePresetsConfig,n as presetKeyAliases,l as refreshUserAttributes,O as resolveComponentProps,s as toPresetTagKey};
1
+ import{createContext as t}from"@lit/context";const e=new Set(["$inheritDefaults"]);function n(t){const e=String(t||"").trim();if(!e)return[];const n=new Set([e]);return e.startsWith("sky-")?n.add(e.slice(4)):n.add(`sky-${e}`),[...n]}function o(t,e){if(t)for(const o of n(e))if(Object.prototype.hasOwnProperty.call(t,o))return t[o]}function s(t){const e=String(t||"").trim();return e?e.startsWith("sky-")?e:`sky-${e}`:e}const r=t("sky/component-presets");function c(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}const f=new WeakMap,i=new WeakMap,a=new WeakMap,u=new WeakMap,p=new Set(["preset",...e]);function l(t){f.has(t)||f.set(t,new Set(t.getAttributeNames()))}function g(t){if(u.has(t))return;const e=new Map,n=t,o=t.constructor.elementProperties;if(o)for(const t of o.keys())"string"!=typeof t||p.has(t)||e.set(t,n[t]);u.set(t,e)}function h(t){if(!u.has(t))return void g(t);const e=u.get(t),n=t;for(const[t,o]of e)void 0===o&&void 0!==n[t]&&e.set(t,n[t])}function d(t){const e=f.get(t)??new Set;for(const n of t.getAttributeNames())e.add(n);f.set(t,e)}function y(t,e){const n=i.get(t)??new Set;n.add(e),i.set(t,n)}function w(t,e){if(i.get(t)?.has(e))return!0;const n=c(e),o=f.get(t);if(o?.has(n)||n!==e&&o?.has(e))return!0;if(!o&&(t.hasAttribute(n)||n!==e&&t.hasAttribute(e)))return!0;if(!a.get(t)?.has(e)){const n=u.get(t);if(n?.has(e)){if(t[e]!==n.get(e))return!0}}return!1}function k(t,e){const n=t??{},o=e??{},r={};for(const t of[n.defaults,o.defaults])for(const[e,n]of Object.entries(t??{})){const t=s(e);r[t]={...r[t]??{},...n??{}}}const c={};for(const t of[n.presets,o.presets])for(const[e,n]of Object.entries(t??{})){const t=s(e),o={...c[t]??{}};for(const[t,e]of Object.entries(n??{}))o[t]={...o[t]??{},...e??{}};c[t]=o}return{defaults:r,presets:c}}function m(t){const e=[];let n=t.parentElement;for(;n;){if("sky-config-provider"===n.localName){const t=n;if(t.mergedConfig)return t.mergedConfig;t.presets&&e.push(t.presets)}n=n.parentElement}return e.length?e.reduceRight((t,e)=>k(t,e),{}):null}function b(t,o,s){const r=function(t,e){if(!t)return{};let o={};for(const s of n(e)){const e=t[s];e&&(o={...o,...e})}return o}(t?.defaults,o),c=function(t,e){if(!t)return{};const o={};for(const s of n(e)){const e=t[s];if(e)for(const[t,n]of Object.entries(e))o[t]={...o[t]??{},...n??{}}}return o}(t?.presets,o),f=s&&c[s]?c[s]:null,i=f&&!1===f.$inheritDefaults?{...f}:{...r,...f??{}};for(const t of e)delete i[t];return i}const O=new WeakMap;function j(t,e,n){d(t),function(t,e){const n=u.get(t);if(!n?.size)return;const o=a.get(t),s=t;for(const r of Object.keys(e))p.has(r)||o?.has(r)||i.get(t)?.has(r)||n.has(r)&&s[r]!==n.get(r)&&y(t,r)}(t,e),function(t){const e=a.get(t);if(!e?.size)return;const n=t;for(const[o,s]of e)w(t,o)||n[o]!==s&&y(t,o)}(t);const o=new Set([...p,...n?.skipKeys??[]]),s=O.get(t)??new Map,r=a.get(t)??new Map;let c=!1;const f=t;for(const n of[...s.keys()])if(!Object.prototype.hasOwnProperty.call(e,n)||void 0===e[n]){if(!w(t,n)&&s.has(n)){const t=s.get(n);f[n]!==t&&(f[n]=t,c=!0)}s.delete(n),r.delete(n)}for(const[n,i]of Object.entries(e))o.has(n)||void 0===i||(w(t,n)?r.delete(n):(s.has(n)||s.set(n,f[n]),f[n]!==i&&(f[n]=i,c=!0),r.set(n,i)));return O.set(t,s),a.set(t,r),c}function S(t){const e=O.get(t);if(!e?.size)return!1;const n=t;let o=!1;for(const[s,r]of e)w(t,s)||n[s]!==r&&(n[s]=r,o=!0);return e.clear(),a.get(t)?.clear(),o}function v(t){const{host:e,componentKey:n,presetName:o,config:s,values:r,keys:c}=t,f=b(s,n,o),i=c??Object.keys(f),a={...r};for(const t of i){const n=t;w(e,n)||Object.prototype.hasOwnProperty.call(f,n)&&void 0!==f[n]&&(a[n]=f[n])}return a}export{j as applyPresetLayer,c as camelToKebab,g as captureBuiltInPropSnapshot,l as captureInitialUserAttributes,S as clearAppliedPresetLayer,r as configContext,h as finalizeBuiltInPropSnapshot,m as findNearestPresetsConfig,b as getPresetLayer,w as isUserSetProp,o as lookupPresetSection,y as markUserSetProp,k as mergePresetsConfig,n as presetKeyAliases,d as refreshUserAttributes,v as resolveComponentProps,s as toPresetTagKey};
2
2
  //# sourceMappingURL=component-presets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component-presets.js","sources":["../../../src/helper/utils/component-presets.ts"],"sourcesContent":["/**\n * Component prop presets — global defaults + named bundles for sky-* CEs.\n *\n * Precedence (highest wins):\n * explicit user prop (attribute or marked/diverged property) → named `preset`\n * → provider `defaults` → built-in class default\n *\n * A named preset overlays `defaults` unless it sets `$inheritDefaults: false`,\n * in which case it is used standalone (keys it omits fall to the built-in).\n *\n * User-owned detection:\n * - attributes present before Lit's first reflect (and any attrs added later)\n * - props marked via `markUserSetProp`\n * - props the consumer changed after presets applied (divergence)\n *\n * @see sky-config-provider\n */\n\nimport { createContext } from \"@lit/context\";\n\n/** Prop bag applied to a single component instance. */\nexport type ComponentPropBag = Record<string, unknown> & {\n /**\n * Named presets only: set `false` to ignore `defaults[component]` and use\n * this bag standalone. Omitted / `true` keeps the default layering.\n */\n $inheritDefaults?: boolean;\n};\n\n/** Reserved bag keys that configure resolution instead of naming a prop. */\nconst RESERVED_BAG_KEYS = new Set([\"$inheritDefaults\"]);\n\n/**\n * Config keys are custom element tag names (`sky-button`).\n * Short aliases without the `sky-` prefix (`button`) are also accepted.\n */\nexport type ComponentPresetKey = string;\n\nexport type ComponentPresetsConfig = {\n /** Applied when the instance does not set the prop (no matching attribute). */\n defaults?: Partial<Record<ComponentPresetKey, ComponentPropBag>>;\n /** Named bundles selected via `preset=\"name\"` on the instance. */\n presets?: Partial<\n Record<ComponentPresetKey, Record<string, ComponentPropBag>>\n >;\n};\n\n/**\n * Lookup aliases for a component key: tag name and short name.\n * `sky-button` ↔ `button`, `sky-button-group` ↔ `button-group`.\n */\nexport function presetKeyAliases(key: string): string[] {\n const k = String(key || \"\").trim();\n if (!k) return [];\n const aliases = new Set<string>([k]);\n if (k.startsWith(\"sky-\")) aliases.add(k.slice(4));\n else aliases.add(`sky-${k}`);\n return [...aliases];\n}\n\n/** First matching bag under `defaults` / `presets` for any alias of `key`. */\nexport function lookupPresetSection<T>(\n section: Partial<Record<string, T>> | null | undefined,\n key: string,\n): T | undefined {\n if (!section) return undefined;\n for (const alias of presetKeyAliases(key)) {\n if (Object.prototype.hasOwnProperty.call(section, alias)) {\n return section[alias];\n }\n }\n return undefined;\n}\n\n/** Merge all alias bags (short + tag) under a section key. Later aliases win. */\nfunction mergeAliasBags(\n section: Partial<Record<string, ComponentPropBag>> | null | undefined,\n key: string,\n): ComponentPropBag {\n if (!section) return {};\n let out: ComponentPropBag = {};\n for (const alias of presetKeyAliases(key)) {\n const bag = section[alias];\n if (bag) out = { ...out, ...bag };\n }\n return out;\n}\n\nfunction mergeAliasNamedMaps(\n section:\n | Partial<Record<string, Record<string, ComponentPropBag>>>\n | null\n | undefined,\n key: string,\n): Record<string, ComponentPropBag> {\n if (!section) return {};\n const out: Record<string, ComponentPropBag> = {};\n for (const alias of presetKeyAliases(key)) {\n const named = section[alias];\n if (!named) continue;\n for (const [name, bag] of Object.entries(named)) {\n out[name] = { ...(out[name] ?? {}), ...(bag ?? {}) };\n }\n }\n return out;\n}\n\n/**\n * Canonical tag form for storage/docs: `button` → `sky-button`.\n * Already-tagged names are unchanged.\n */\nexport function toPresetTagKey(key: string): string {\n const k = String(key || \"\").trim();\n if (!k) return k;\n return k.startsWith(\"sky-\") ? k : `sky-${k}`;\n}\n\n/** Lit context provided by `<sky-config-provider>`. */\nexport const configContext = createContext<ComponentPresetsConfig | null>(\n \"sky/component-presets\",\n);\n\n/** camelCase / PascalCase → kebab-case attribute name. */\nexport function camelToKebab(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n .replace(/_/g, \"-\")\n .toLowerCase();\n}\n\n/**\n * Attributes present before Lit's first reflect (captured in `PresetController`).\n * Needed so reflected class defaults (e.g. `variant=\"solid\"`) do not look user-owned.\n */\nconst initialUserAttrs = new WeakMap<HTMLElement, Set<string>>();\n\n/** Props explicitly marked user-owned (property-only writes / divergence). */\nconst userOwnedProps = new WeakMap<HTMLElement, Set<string>>();\n\n/** Last values written by `applyPresetLayer` (for divergence detection). */\nconst lastPresetApplied = new WeakMap<HTMLElement, Map<string, unknown>>();\n\n/**\n * Snapshot host attributes once (call from controller `hostConnected`, before first update).\n * Declarative HTML / early `setAttribute` calls are treated as user-owned thereafter.\n */\nexport function captureInitialUserAttributes(host: HTMLElement): void {\n if (initialUserAttrs.has(host)) return;\n initialUserAttrs.set(host, new Set(host.getAttributeNames()));\n}\n\n/**\n * Merge any attributes that appeared after connect (late framework bindings)\n * into the user-owned attribute snapshot.\n */\nexport function refreshUserAttributes(host: HTMLElement): void {\n const set = initialUserAttrs.get(host) ?? new Set<string>();\n for (const name of host.getAttributeNames()) set.add(name);\n initialUserAttrs.set(host, set);\n}\n\n/**\n * Mark a prop as consumer-owned so presets will not overwrite it.\n * Use for property-only bindings (no attribute) when needed.\n */\nexport function markUserSetProp(host: HTMLElement, prop: string): void {\n const set = userOwnedProps.get(host) ?? new Set<string>();\n set.add(prop);\n userOwnedProps.set(host, set);\n}\n\n/**\n * True when the host had an attribute for this prop before/at apply time,\n * or the prop was marked user-owned (explicit mark or post-apply divergence).\n */\nexport function isUserSetProp(host: HTMLElement, prop: string): boolean {\n if (userOwnedProps.get(host)?.has(prop)) return true;\n const kebab = camelToKebab(prop);\n const initial = initialUserAttrs.get(host);\n if (initial) {\n return initial.has(kebab) || (kebab !== prop && initial.has(prop));\n }\n return host.hasAttribute(kebab) || (kebab !== prop && host.hasAttribute(prop));\n}\n\n/**\n * If the consumer changed a prop after we applied a preset value, mark it\n * user-owned so later re-applies leave it alone.\n */\nfunction detectDivergedUserProps(host: HTMLElement): void {\n const applied = lastPresetApplied.get(host);\n if (!applied?.size) return;\n const record = host as HTMLElement & Record<string, unknown>;\n for (const [key, appliedValue] of applied) {\n if (isUserSetProp(host, key)) continue;\n if (record[key] !== appliedValue) {\n markUserSetProp(host, key);\n }\n }\n}\n\n/**\n * Deep-merge parent + child preset configs.\n * Inner provider wins per component key, then per prop / named preset.\n */\nexport function mergePresetsConfig(\n parent: ComponentPresetsConfig | null | undefined,\n child: ComponentPresetsConfig | null | undefined,\n): ComponentPresetsConfig {\n const p = parent ?? {};\n const c = child ?? {};\n\n const defaults: NonNullable<ComponentPresetsConfig[\"defaults\"]> = {};\n for (const source of [p.defaults, c.defaults]) {\n for (const [key, bag] of Object.entries(source ?? {})) {\n const tag = toPresetTagKey(key);\n defaults[tag] = { ...(defaults[tag] ?? {}), ...(bag ?? {}) };\n }\n }\n\n const presets: NonNullable<ComponentPresetsConfig[\"presets\"]> = {};\n for (const source of [p.presets, c.presets]) {\n for (const [comp, named] of Object.entries(source ?? {})) {\n const tag = toPresetTagKey(comp);\n const mergedNamed: Record<string, ComponentPropBag> = {\n ...(presets[tag] ?? {}),\n };\n for (const [name, bag] of Object.entries(named ?? {})) {\n mergedNamed[name] = { ...(mergedNamed[name] ?? {}), ...(bag ?? {}) };\n }\n presets[tag] = mergedNamed;\n }\n }\n\n return { defaults, presets };\n}\n\nexport type ResolveComponentPropsOptions<T extends Record<string, unknown>> = {\n host: HTMLElement;\n componentKey: ComponentPresetKey;\n /** Value of the instance `preset` attribute/prop. */\n presetName?: string | null;\n config?: ComponentPresetsConfig | null;\n /** Current instance values (class built-ins already applied). */\n values: T;\n /**\n * Keys eligible for preset / default substitution.\n * Omit to apply every key present in the preset layer.\n */\n keys?: Array<keyof T & string>;\n};\n\n/**\n * Walk ancestors for `<sky-config-provider>` and deep-merge outer → inner.\n * Used when Lit context has not delivered a value yet (or as a reliable fallback).\n */\nexport function findNearestPresetsConfig(\n host: HTMLElement,\n): ComponentPresetsConfig | null {\n const layers: ComponentPresetsConfig[] = [];\n let el: HTMLElement | null = host.parentElement;\n while (el) {\n if (el.localName === \"sky-config-provider\") {\n const provider = el as HTMLElement & {\n presets?: ComponentPresetsConfig;\n mergedConfig?: ComponentPresetsConfig;\n };\n // Prefer live `presets` so we do not depend on context publish timing.\n if (provider.mergedConfig) {\n // Nearest provider already merged its ancestors — use it and stop.\n return provider.mergedConfig;\n }\n if (provider.presets) layers.push(provider.presets);\n }\n el = el.parentElement;\n }\n if (!layers.length) return null;\n // layers collected inner→outer while walking up; merge outer first, inner last.\n return layers.reduceRight(\n (acc, layer) => mergePresetsConfig(acc, layer),\n {} as ComponentPresetsConfig,\n );\n}\n\n/**\n * Resolve the active prop bag for a component: `defaults[key]` ← `presets[key][name]`.\n * Any prop key present in that bag can be applied to the instance.\n *\n * A named preset with `$inheritDefaults: false` is used standalone, so keys it\n * omits fall through to the component built-in instead of `defaults`.\n */\nexport function getPresetLayer(\n config: ComponentPresetsConfig | null | undefined,\n componentKey: ComponentPresetKey,\n presetName?: string | null,\n): ComponentPropBag {\n const defaults = mergeAliasBags(config?.defaults, componentKey);\n const namedMap = mergeAliasNamedMaps(config?.presets, componentKey);\n const named =\n presetName && namedMap[presetName] ? namedMap[presetName]! : null;\n\n const merged =\n named && named.$inheritDefaults === false\n ? { ...named }\n : { ...defaults, ...(named ?? {}) };\n\n for (const key of RESERVED_BAG_KEYS) delete merged[key];\n return merged;\n}\n\n/** Per-host map of prop → value before presets overwrote it (for revert). */\nconst presetRestoreValues = new WeakMap<HTMLElement, Map<string, unknown>>();\n\nconst PRESET_SKIP_KEYS = new Set([\"preset\", ...RESERVED_BAG_KEYS]);\n\nexport type ApplyPresetLayerOptions = {\n /** Extra keys never written from presets. */\n skipKeys?: string[];\n};\n\n/**\n * Write every key from the preset layer onto the host (any component prop).\n * Skips user-owned attributes / props. Remembers prior values so removing a\n * key from the provider config restores the built-in / prior value.\n *\n * Before writing, detects divergence: if the host value no longer matches the\n * last preset-applied value, that prop is marked user-owned (property-only\n * overrides after first apply).\n *\n * @returns true if any host property changed\n */\nexport function applyPresetLayer(\n host: HTMLElement,\n layer: ComponentPropBag,\n options?: ApplyPresetLayerOptions,\n): boolean {\n refreshUserAttributes(host);\n detectDivergedUserProps(host);\n\n const skip = new Set([\n ...PRESET_SKIP_KEYS,\n ...(options?.skipKeys ?? []),\n ]);\n const restore = presetRestoreValues.get(host) ?? new Map<string, unknown>();\n const applied = lastPresetApplied.get(host) ?? new Map<string, unknown>();\n let changed = false;\n const record = host as HTMLElement & Record<string, unknown>;\n\n // Drop / revert keys no longer provided by the layer.\n for (const key of [...restore.keys()]) {\n if (\n Object.prototype.hasOwnProperty.call(layer, key) &&\n layer[key] !== undefined\n ) {\n continue;\n }\n if (!isUserSetProp(host, key) && restore.has(key)) {\n const prev = restore.get(key);\n if (record[key] !== prev) {\n record[key] = prev;\n changed = true;\n }\n }\n restore.delete(key);\n applied.delete(key);\n }\n\n // Apply all keys in the layer (full prop surface — not a whitelist).\n for (const [key, value] of Object.entries(layer)) {\n if (skip.has(key) || value === undefined) continue;\n if (isUserSetProp(host, key)) {\n applied.delete(key);\n continue;\n }\n if (!restore.has(key)) {\n restore.set(key, record[key]);\n }\n if (record[key] !== value) {\n record[key] = value;\n changed = true;\n }\n applied.set(key, value);\n }\n\n presetRestoreValues.set(host, restore);\n lastPresetApplied.set(host, applied);\n return changed;\n}\n\n/**\n * Clear preset-applied props and restore saved built-ins (e.g. when paused in a group).\n */\nexport function clearAppliedPresetLayer(host: HTMLElement): boolean {\n const restore = presetRestoreValues.get(host);\n if (!restore?.size) return false;\n const record = host as HTMLElement & Record<string, unknown>;\n let changed = false;\n for (const [key, prev] of restore) {\n if (isUserSetProp(host, key)) continue;\n if (record[key] !== prev) {\n record[key] = prev;\n changed = true;\n }\n }\n restore.clear();\n lastPresetApplied.get(host)?.clear();\n return changed;\n}\n\n/**\n * Resolve effective props for styling / behavior without mutating the host.\n * When `keys` is omitted, every key in the preset layer is considered.\n * Skips keys the user set via attributes.\n */\nexport function resolveComponentProps<T extends Record<string, unknown>>(\n options: ResolveComponentPropsOptions<T>,\n): T {\n const { host, componentKey, presetName, config, values, keys } = options;\n const layer = getPresetLayer(config, componentKey, presetName);\n const keysToApply =\n keys ?? (Object.keys(layer) as Array<keyof T & string>);\n\n const out = { ...values };\n for (const key of keysToApply) {\n const k = key as string;\n if (isUserSetProp(host, k)) continue;\n if (Object.prototype.hasOwnProperty.call(layer, k) && layer[k] !== undefined) {\n (out as Record<string, unknown>)[k] = layer[k];\n }\n }\n return out;\n}\n"],"names":["RESERVED_BAG_KEYS","Set","presetKeyAliases","key","k","String","trim","aliases","startsWith","add","slice","lookupPresetSection","section","alias","Object","prototype","hasOwnProperty","call","toPresetTagKey","configContext","createContext","camelToKebab","name","replace","toLowerCase","initialUserAttrs","WeakMap","userOwnedProps","lastPresetApplied","captureInitialUserAttributes","host","has","set","getAttributeNames","refreshUserAttributes","get","markUserSetProp","prop","isUserSetProp","kebab","initial","hasAttribute","mergePresetsConfig","parent","child","p","c","defaults","source","bag","entries","tag","presets","comp","named","mergedNamed","findNearestPresetsConfig","layers","el","parentElement","localName","provider","mergedConfig","push","length","reduceRight","acc","layer","getPresetLayer","config","componentKey","presetName","out","mergeAliasBags","namedMap","mergeAliasNamedMaps","merged","$inheritDefaults","presetRestoreValues","PRESET_SKIP_KEYS","applyPresetLayer","options","applied","size","record","appliedValue","detectDivergedUserProps","skip","skipKeys","restore","Map","changed","keys","prev","delete","value","clearAppliedPresetLayer","clear","resolveComponentProps","values","keysToApply"],"mappings":"6CA8BA,MAAMA,EAAoB,IAAIC,IAAI,CAAC,qBAqB5B,SAASC,EAAiBC,GAC/B,MAAMC,EAAIC,OAAOF,GAAO,IAAIG,OAC5B,IAAKF,EAAG,MAAO,GACf,MAAMG,EAAU,IAAIN,IAAY,CAACG,IAGjC,OAFIA,EAAEI,WAAW,UAAiBC,IAAIL,EAAEM,MAAM,IACzCH,EAAQE,IAAI,OAAOL,KACjB,IAAIG,EACb,CAGO,SAASI,EACdC,EACAT,GAEA,GAAKS,EACL,IAAA,MAAWC,KAASX,EAAiBC,GACnC,GAAIW,OAAOC,UAAU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ACzDoE,EAAgCpE,GAAK+D,EAAM/D,GAEhD,CACA,OAAOoE,CACT"}
1
+ {"version":3,"file":"component-presets.js","sources":["../../../src/helper/utils/component-presets.ts"],"sourcesContent":["/**\n * Component prop presets — global defaults + named bundles for sky-* CEs.\n *\n * Precedence (highest wins):\n * explicit user prop (attribute, framework property, or marked/diverged) →\n * named `preset` → provider `defaults` → built-in class default\n *\n * A named preset overlays `defaults` unless it sets `$inheritDefaults: false`,\n * in which case it is used standalone (keys it omits fall to the built-in).\n *\n * User-owned detection:\n * - attributes present before Lit's first reflect (and any attrs added later)\n * - props marked via `markUserSetProp`\n * - props the consumer changed after presets applied (divergence)\n * - props a framework set before first apply (current value ≠ constructor\n * snapshot from `captureBuiltInPropSnapshot` — covers Vue/React CE property\n * bindings that never create attributes). Overriding *back* to the exact\n * built-in default still needs an attribute or `markUserSetProp`.\n *\n * @see sky-config-provider\n */\n\nimport { createContext } from \"@lit/context\";\n\n/** Prop bag applied to a single component instance. */\nexport type ComponentPropBag = Record<string, unknown> & {\n /**\n * Named presets only: set `false` to ignore `defaults[component]` and use\n * this bag standalone. Omitted / `true` keeps the default layering.\n */\n $inheritDefaults?: boolean;\n};\n\n/** Reserved bag keys that configure resolution instead of naming a prop. */\nconst RESERVED_BAG_KEYS = new Set([\"$inheritDefaults\"]);\n\n/**\n * Config keys are custom element tag names (`sky-button`).\n * Short aliases without the `sky-` prefix (`button`) are also accepted.\n */\nexport type ComponentPresetKey = string;\n\nexport type ComponentPresetsConfig = {\n /** Applied when the instance does not set the prop (no matching attribute). */\n defaults?: Partial<Record<ComponentPresetKey, ComponentPropBag>>;\n /** Named bundles selected via `preset=\"name\"` on the instance. */\n presets?: Partial<\n Record<ComponentPresetKey, Record<string, ComponentPropBag>>\n >;\n};\n\n/**\n * Lookup aliases for a component key: tag name and short name.\n * `sky-button` ↔ `button`, `sky-button-group` ↔ `button-group`.\n */\nexport function presetKeyAliases(key: string): string[] {\n const k = String(key || \"\").trim();\n if (!k) return [];\n const aliases = new Set<string>([k]);\n if (k.startsWith(\"sky-\")) aliases.add(k.slice(4));\n else aliases.add(`sky-${k}`);\n return [...aliases];\n}\n\n/** First matching bag under `defaults` / `presets` for any alias of `key`. */\nexport function lookupPresetSection<T>(\n section: Partial<Record<string, T>> | null | undefined,\n key: string,\n): T | undefined {\n if (!section) return undefined;\n for (const alias of presetKeyAliases(key)) {\n if (Object.prototype.hasOwnProperty.call(section, alias)) {\n return section[alias];\n }\n }\n return undefined;\n}\n\n/** Merge all alias bags (short + tag) under a section key. Later aliases win. */\nfunction mergeAliasBags(\n section: Partial<Record<string, ComponentPropBag>> | null | undefined,\n key: string,\n): ComponentPropBag {\n if (!section) return {};\n let out: ComponentPropBag = {};\n for (const alias of presetKeyAliases(key)) {\n const bag = section[alias];\n if (bag) out = { ...out, ...bag };\n }\n return out;\n}\n\nfunction mergeAliasNamedMaps(\n section:\n | Partial<Record<string, Record<string, ComponentPropBag>>>\n | null\n | undefined,\n key: string,\n): Record<string, ComponentPropBag> {\n if (!section) return {};\n const out: Record<string, ComponentPropBag> = {};\n for (const alias of presetKeyAliases(key)) {\n const named = section[alias];\n if (!named) continue;\n for (const [name, bag] of Object.entries(named)) {\n out[name] = { ...(out[name] ?? {}), ...(bag ?? {}) };\n }\n }\n return out;\n}\n\n/**\n * Canonical tag form for storage/docs: `button` → `sky-button`.\n * Already-tagged names are unchanged.\n */\nexport function toPresetTagKey(key: string): string {\n const k = String(key || \"\").trim();\n if (!k) return k;\n return k.startsWith(\"sky-\") ? k : `sky-${k}`;\n}\n\n/** Lit context provided by `<sky-config-provider>`. */\nexport const configContext = createContext<ComponentPresetsConfig | null>(\n \"sky/component-presets\",\n);\n\n/** camelCase / PascalCase → kebab-case attribute name. */\nexport function camelToKebab(name: string): string {\n return name\n .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n .replace(/_/g, \"-\")\n .toLowerCase();\n}\n\n/**\n * Attributes present before Lit's first reflect (captured in `PresetController`).\n * Needed so reflected class defaults (e.g. `variant=\"solid\"`) do not look user-owned.\n */\nconst initialUserAttrs = new WeakMap<HTMLElement, Set<string>>();\n\n/** Props explicitly marked user-owned (property-only writes / divergence). */\nconst userOwnedProps = new WeakMap<HTMLElement, Set<string>>();\n\n/** Last values written by `applyPresetLayer` (for divergence detection). */\nconst lastPresetApplied = new WeakMap<HTMLElement, Map<string, unknown>>();\n\n/**\n * Prop values at CE construction (before Vue/React assign host props).\n * Call from `PresetController` construction so field initializers are visible.\n */\nconst builtInPropSnapshots = new WeakMap<HTMLElement, Map<string, unknown>>();\n\nconst PRESET_SKIP_KEYS = new Set([\"preset\", ...RESERVED_BAG_KEYS]);\n\n/**\n * Snapshot host attributes once (call from controller `hostConnected`, before first update).\n * Declarative HTML / early `setAttribute` calls are treated as user-owned thereafter.\n */\nexport function captureInitialUserAttributes(host: HTMLElement): void {\n if (initialUserAttrs.has(host)) return;\n initialUserAttrs.set(host, new Set(host.getAttributeNames()));\n}\n\n/**\n * Snapshot Lit `@property` values once during host construction (before frameworks\n * assign props). Later diffs against this map mark framework property bindings as\n * user-owned so presets do not overwrite them.\n *\n * Declare `PresetController` after the host's presettable `@property` fields so\n * those initials are already assigned when this runs. Keys still `undefined` are\n * filled by `finalizeBuiltInPropSnapshot` on connect (constructor-body defaults).\n */\nexport function captureBuiltInPropSnapshot(host: HTMLElement): void {\n if (builtInPropSnapshots.has(host)) return;\n const snap = new Map<string, unknown>();\n const record = host as HTMLElement & Record<string, unknown>;\n const meta = (\n host.constructor as { elementProperties?: Map<PropertyKey, unknown> }\n ).elementProperties;\n if (meta) {\n for (const prop of meta.keys()) {\n if (typeof prop !== \"string\" || PRESET_SKIP_KEYS.has(prop)) continue;\n snap.set(prop, record[prop]);\n }\n }\n builtInPropSnapshots.set(host, snap);\n}\n\n/**\n * Fill snapshot entries that were still `undefined` when the controller\n * constructed (e.g. defaults assigned in the host `constructor` body after the\n * controller field). Does not overwrite defined snapshot values — those are the\n * true built-ins Vue/React may have already overridden by connect time.\n */\nexport function finalizeBuiltInPropSnapshot(host: HTMLElement): void {\n if (!builtInPropSnapshots.has(host)) {\n captureBuiltInPropSnapshot(host);\n return;\n }\n const snap = builtInPropSnapshots.get(host)!;\n const record = host as HTMLElement & Record<string, unknown>;\n for (const [key, value] of snap) {\n if (value === undefined && record[key] !== undefined) {\n snap.set(key, record[key]);\n }\n }\n}\n\n/**\n * Merge any attributes that appeared after connect (late framework bindings)\n * into the user-owned attribute snapshot.\n */\nexport function refreshUserAttributes(host: HTMLElement): void {\n const set = initialUserAttrs.get(host) ?? new Set<string>();\n for (const name of host.getAttributeNames()) set.add(name);\n initialUserAttrs.set(host, set);\n}\n\n/**\n * Mark a prop as consumer-owned so presets will not overwrite it.\n * Use for property-only bindings (no attribute) when needed.\n */\nexport function markUserSetProp(host: HTMLElement, prop: string): void {\n const set = userOwnedProps.get(host) ?? new Set<string>();\n set.add(prop);\n userOwnedProps.set(host, set);\n}\n\n/**\n * True when the host had an attribute for this prop before/at apply time,\n * the prop was marked user-owned (explicit mark or post-apply divergence),\n * or a framework assigned a property that differs from the constructor snapshot\n * before presets first wrote that key.\n */\nexport function isUserSetProp(host: HTMLElement, prop: string): boolean {\n if (userOwnedProps.get(host)?.has(prop)) return true;\n const kebab = camelToKebab(prop);\n const initial = initialUserAttrs.get(host);\n if (initial?.has(kebab) || (kebab !== prop && initial?.has(prop))) {\n return true;\n }\n if (\n !initial &&\n (host.hasAttribute(kebab) || (kebab !== prop && host.hasAttribute(prop)))\n ) {\n return true;\n }\n // Framework CE bindings (Vue/React) set properties, not attributes.\n if (!lastPresetApplied.get(host)?.has(prop)) {\n const snap = builtInPropSnapshots.get(host);\n if (snap?.has(prop)) {\n const record = host as HTMLElement & Record<string, unknown>;\n if (record[prop] !== snap.get(prop)) return true;\n }\n }\n return false;\n}\n\n/**\n * Permanently mark props a framework changed before our first write for that key.\n */\nfunction detectPreApplyFrameworkProps(\n host: HTMLElement,\n layer: ComponentPropBag,\n): void {\n const snap = builtInPropSnapshots.get(host);\n if (!snap?.size) return;\n const applied = lastPresetApplied.get(host);\n const record = host as HTMLElement & Record<string, unknown>;\n for (const key of Object.keys(layer)) {\n if (PRESET_SKIP_KEYS.has(key) || applied?.has(key)) continue;\n if (userOwnedProps.get(host)?.has(key)) continue;\n if (!snap.has(key)) continue;\n if (record[key] !== snap.get(key)) {\n markUserSetProp(host, key);\n }\n }\n}\n\n/**\n * If the consumer changed a prop after we applied a preset value, mark it\n * user-owned so later re-applies leave it alone.\n */\nfunction detectDivergedUserProps(host: HTMLElement): void {\n const applied = lastPresetApplied.get(host);\n if (!applied?.size) return;\n const record = host as HTMLElement & Record<string, unknown>;\n for (const [key, appliedValue] of applied) {\n if (isUserSetProp(host, key)) continue;\n if (record[key] !== appliedValue) {\n markUserSetProp(host, key);\n }\n }\n}\n\n/**\n * Deep-merge parent + child preset configs.\n * Inner provider wins per component key, then per prop / named preset.\n */\nexport function mergePresetsConfig(\n parent: ComponentPresetsConfig | null | undefined,\n child: ComponentPresetsConfig | null | undefined,\n): ComponentPresetsConfig {\n const p = parent ?? {};\n const c = child ?? {};\n\n const defaults: NonNullable<ComponentPresetsConfig[\"defaults\"]> = {};\n for (const source of [p.defaults, c.defaults]) {\n for (const [key, bag] of Object.entries(source ?? {})) {\n const tag = toPresetTagKey(key);\n defaults[tag] = { ...(defaults[tag] ?? {}), ...(bag ?? {}) };\n }\n }\n\n const presets: NonNullable<ComponentPresetsConfig[\"presets\"]> = {};\n for (const source of [p.presets, c.presets]) {\n for (const [comp, named] of Object.entries(source ?? {})) {\n const tag = toPresetTagKey(comp);\n const mergedNamed: Record<string, ComponentPropBag> = {\n ...(presets[tag] ?? {}),\n };\n for (const [name, bag] of Object.entries(named ?? {})) {\n mergedNamed[name] = { ...(mergedNamed[name] ?? {}), ...(bag ?? {}) };\n }\n presets[tag] = mergedNamed;\n }\n }\n\n return { defaults, presets };\n}\n\nexport type ResolveComponentPropsOptions<T extends Record<string, unknown>> = {\n host: HTMLElement;\n componentKey: ComponentPresetKey;\n /** Value of the instance `preset` attribute/prop. */\n presetName?: string | null;\n config?: ComponentPresetsConfig | null;\n /** Current instance values (class built-ins already applied). */\n values: T;\n /**\n * Keys eligible for preset / default substitution.\n * Omit to apply every key present in the preset layer.\n */\n keys?: Array<keyof T & string>;\n};\n\n/**\n * Walk ancestors for `<sky-config-provider>` and deep-merge outer → inner.\n * Used when Lit context has not delivered a value yet (or as a reliable fallback).\n */\nexport function findNearestPresetsConfig(\n host: HTMLElement,\n): ComponentPresetsConfig | null {\n const layers: ComponentPresetsConfig[] = [];\n let el: HTMLElement | null = host.parentElement;\n while (el) {\n if (el.localName === \"sky-config-provider\") {\n const provider = el as HTMLElement & {\n presets?: ComponentPresetsConfig;\n mergedConfig?: ComponentPresetsConfig;\n };\n // Prefer live `presets` so we do not depend on context publish timing.\n if (provider.mergedConfig) {\n // Nearest provider already merged its ancestors — use it and stop.\n return provider.mergedConfig;\n }\n if (provider.presets) layers.push(provider.presets);\n }\n el = el.parentElement;\n }\n if (!layers.length) return null;\n // layers collected inner→outer while walking up; merge outer first, inner last.\n return layers.reduceRight(\n (acc, layer) => mergePresetsConfig(acc, layer),\n {} as ComponentPresetsConfig,\n );\n}\n\n/**\n * Resolve the active prop bag for a component: `defaults[key]` ← `presets[key][name]`.\n * Any prop key present in that bag can be applied to the instance.\n *\n * A named preset with `$inheritDefaults: false` is used standalone, so keys it\n * omits fall through to the component built-in instead of `defaults`.\n */\nexport function getPresetLayer(\n config: ComponentPresetsConfig | null | undefined,\n componentKey: ComponentPresetKey,\n presetName?: string | null,\n): ComponentPropBag {\n const defaults = mergeAliasBags(config?.defaults, componentKey);\n const namedMap = mergeAliasNamedMaps(config?.presets, componentKey);\n const named =\n presetName && namedMap[presetName] ? namedMap[presetName]! : null;\n\n const merged =\n named && named.$inheritDefaults === false\n ? { ...named }\n : { ...defaults, ...(named ?? {}) };\n\n for (const key of RESERVED_BAG_KEYS) delete merged[key];\n return merged;\n}\n\n/** Per-host map of prop → value before presets overwrote it (for revert). */\nconst presetRestoreValues = new WeakMap<HTMLElement, Map<string, unknown>>();\n\nexport type ApplyPresetLayerOptions = {\n /** Extra keys never written from presets. */\n skipKeys?: string[];\n};\n\n/**\n * Write every key from the preset layer onto the host (any component prop).\n * Skips user-owned attributes / props. Remembers prior values so removing a\n * key from the provider config restores the built-in / prior value.\n *\n * Before writing, detects divergence: if the host value no longer matches the\n * last preset-applied value, that prop is marked user-owned (property-only\n * overrides after first apply). Also locks in framework property bindings that\n * differ from the constructor snapshot before the first write for that key.\n *\n * @returns true if any host property changed\n */\nexport function applyPresetLayer(\n host: HTMLElement,\n layer: ComponentPropBag,\n options?: ApplyPresetLayerOptions,\n): boolean {\n refreshUserAttributes(host);\n detectPreApplyFrameworkProps(host, layer);\n detectDivergedUserProps(host);\n\n const skip = new Set([\n ...PRESET_SKIP_KEYS,\n ...(options?.skipKeys ?? []),\n ]);\n const restore = presetRestoreValues.get(host) ?? new Map<string, unknown>();\n const applied = lastPresetApplied.get(host) ?? new Map<string, unknown>();\n let changed = false;\n const record = host as HTMLElement & Record<string, unknown>;\n\n // Drop / revert keys no longer provided by the layer.\n for (const key of [...restore.keys()]) {\n if (\n Object.prototype.hasOwnProperty.call(layer, key) &&\n layer[key] !== undefined\n ) {\n continue;\n }\n if (!isUserSetProp(host, key) && restore.has(key)) {\n const prev = restore.get(key);\n if (record[key] !== prev) {\n record[key] = prev;\n changed = true;\n }\n }\n restore.delete(key);\n applied.delete(key);\n }\n\n // Apply all keys in the layer (full prop surface — not a whitelist).\n for (const [key, value] of Object.entries(layer)) {\n if (skip.has(key) || value === undefined) continue;\n if (isUserSetProp(host, key)) {\n applied.delete(key);\n continue;\n }\n if (!restore.has(key)) {\n restore.set(key, record[key]);\n }\n if (record[key] !== value) {\n record[key] = value;\n changed = true;\n }\n applied.set(key, value);\n }\n\n presetRestoreValues.set(host, restore);\n lastPresetApplied.set(host, applied);\n return changed;\n}\n\n/**\n * Clear preset-applied props and restore saved built-ins (e.g. when paused in a group).\n */\nexport function clearAppliedPresetLayer(host: HTMLElement): boolean {\n const restore = presetRestoreValues.get(host);\n if (!restore?.size) return false;\n const record = host as HTMLElement & Record<string, unknown>;\n let changed = false;\n for (const [key, prev] of restore) {\n if (isUserSetProp(host, key)) continue;\n if (record[key] !== prev) {\n record[key] = prev;\n changed = true;\n }\n }\n restore.clear();\n lastPresetApplied.get(host)?.clear();\n return changed;\n}\n\n/**\n * Resolve effective props for styling / behavior without mutating the host.\n * When `keys` is omitted, every key in the preset layer is considered.\n * Skips keys the user set via attributes.\n */\nexport function resolveComponentProps<T extends Record<string, unknown>>(\n options: ResolveComponentPropsOptions<T>,\n): T {\n const { host, componentKey, presetName, config, values, keys } = options;\n const layer = getPresetLayer(config, componentKey, presetName);\n const keysToApply =\n keys ?? (Object.keys(layer) as Array<keyof T & string>);\n\n const out = { ...values };\n for (const key of keysToApply) {\n const k = key as string;\n if (isUserSetProp(host, k)) continue;\n if (Object.prototype.hasOwnProperty.call(layer, k) && layer[k] !== undefined) {\n (out as Record<string, unknown>)[k] = layer[k];\n }\n }\n return out;\n}\n"],"names":["RESERVED_BAG_KEYS","Set","presetKeyAliases","key","k","String","trim","aliases","startsWith","add","slice","lookupPresetSection","section","alias","Object","prototype","hasOwnProperty","call","toPresetTagKey","configContext","createContext","camelToKebab","name","replace","toLowerCase","initialUserAttrs","WeakMap","userOwnedProps","lastPresetApplied","builtInPropSnapshots","PRESET_SKIP_KEYS","captureInitialUserAttributes","host","has","set","getAttributeNames","captureBuiltInPropSnapshot","snap","Map","record","meta","constructor","elementProperties","prop","keys","finalizeBuiltInPropSnapshot","get","value","refreshUserAttributes","markUserSetProp","isUserSetProp","kebab","initial","hasAttribute","mergePresetsConfig","parent","child","p","c","defaults","source","bag","entries","tag","presets","comp","named","mergedNamed","findNearestPresetsConfig","layers","el","parentElement","localName","provider","mergedConfig","push","length","reduceRight","acc","layer","getPresetLayer","config","componentKey","presetName","out","mergeAliasBags","namedMap","mergeAliasNamedMaps","merged","$inheritDefaults","presetRestoreValues","applyPresetLayer","options","size","applied","detectPreApplyFrameworkProps","appliedValue","detectDivergedUserProps","skip","skipKeys","restore","changed","prev","delete","clearAppliedPresetLayer","clear","resolveComponentProps","values","keysToApply"],"mappings":"6CAkCA,MAAMA,EAAoB,IAAIC,IAAI,CAAC,qBAqB5B,SAASC,EAAiBC,GAC/B,MAAMC,EAAIC,OAAOF,GAAO,IAAIG,OAC5B,IAAKF,EAAG,MAAO,GACf,MAAMG,EAAU,IAAIN,IAAY,CAACG,IAGjC,OAFIA,EAAEI,WAAW,UAAiBC,IAAIL,EAAEM,MAAM,IACzCH,EAAQE,IAAI,OAAOL,KACjB,IAAIG,EACb,CAGO,SAASI,EACdC,EACAT,GAEA,GAAKS,EACL,IAAA,MAAWC,KAASX,EAAiBC,GACnC,GAAIW,OAAOC,UAAUC,eAAeC,KAAKL,EAASC,GAChD,OAAOD,EAAQC,EAIrB,CAuCO,SAASK,EAAef,GAC7B,MAAMC,EAAIC,OAAOF,GAAO,IAAIG,OAC5B,OAAKF,EACEA,EAAEI,WAAW,QAAUJ,EAAI,OAAOA,IAD1BA,CAEjB,CAGO,MAAMe,EAAgBC,EAC3B,yBAIK,SAASC,EAAaC,GAC3B,OAAOA,EACJC,QAAQ,qBAAsB,SAC9BA,QAAQ,KAAM,KACdC,aACL,CAMA,MAAMC,MAAuBC,QAGvBC,MAAqBD,QAGrBE,MAAwBF,QAMxBG,MAA2BH,QAE3BI,EAAmB,IAAI7B,IAAI,CAAC,YAAaD,IAMxC,SAAS+B,EAA6BC,GACvCP,EAAiBQ,IAAID,IACzBP,EAAiBS,IAAIF,EAAM,IAAI/B,IAAI+B,EAAKG,qBAC1C,CAWO,SAASC,EAA2BJ,GACzC,GAAIH,EAAqBI,IAAID,GAAO,OACpC,MAAMK,MAAWC,IACXC,EAASP,EACTQ,EACJR,EAAKS,YACLC,kBACF,GAAIF,EACF,IAAA,MAAWG,KAAQH,EAAKI,OACF,iBAATD,GAAqB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,IAClB/D,EAAOpC,GAAOmG,EACdD,GAAU,GAKd,OAFAD,EAAQK,QACR7E,EAAkBkB,IAAId,IAAOyE,QACtBJ,CACT,CAOO,SAASK,EACdd,GAEA,MAAM5D,KAAEA,EAAAkD,aAAMA,EAAAC,WAAcA,SAAYF,EAAA0B,OAAQA,EAAA/D,KAAQA,GAASgD,EAC3Db,EAAQC,EAAeC,EAAQC,EAAcC,GAC7CyB,EACJhE,GAAS9B,OAAO8B,KAAKmC,GAEjBK,EAAM,IAAKuB,GACjB,IAAA,MAAWxG,KAAOyG,EAAa,CAC7B,MAAMxG,EAAID,EACN+C,EAAclB,EAAM5B,IACpBU,OAAOC,UAAUC,eAAeC,KAAK8D,EAAO3E,aAAM2E,EAAM3E,KACzDgF,EAAgChF,GAAK2E,EAAM3E,GAEhD,CACA,OAAOgF,CACT"}
@@ -1,2 +1,2 @@
1
- export{ColorResolver,DEFAULT_COLOR_TOKENS,colorResolver,createGradient,darkShade,fadeMix,hoverShade,isDefaultColorToken,lightShade,parseGradientSpec,resolveAccentColorForToken,resolveColor,resolveGradientStop,resolveInkColorForToken,resolveSemanticSurfaceKey,semanticSoftSurfaceTokens,skyBorderPrimaryShorthand,skyBorderWidthSolid,tuneSurfaceVariantForDefaultColor}from"./color-resolver.js";export{applyPresetLayer,camelToKebab,captureInitialUserAttributes,clearAppliedPresetLayer,configContext,findNearestPresetsConfig,getPresetLayer,isUserSetProp,lookupPresetSection,markUserSetProp,mergePresetsConfig,presetKeyAliases,refreshUserAttributes,resolveComponentProps,toPresetTagKey}from"./component-presets.js";export{CONTRAST_COLOR_SUPPORT_QUERY,ON_COLOR_FALLBACK_DARK,ON_COLOR_FALLBACK_LIGHT,contrastOnFill,contrastOverlay,contrastThemeInk,cssContrastColor,cssOnFill,cssOnFillEnhance,isLightFill,parseCssRgb,perceivedLuminance,relativeLuminance}from"./contrast-color.js";export{resolveRadius}from"./size-resolver.js";
1
+ export{ColorResolver,DEFAULT_COLOR_TOKENS,colorResolver,createGradient,darkShade,fadeMix,hoverShade,isDefaultColorToken,lightShade,parseGradientSpec,resolveAccentColorForToken,resolveColor,resolveGradientStop,resolveInkColorForToken,resolveSemanticSurfaceKey,semanticSoftSurfaceTokens,skyBorderPrimaryShorthand,skyBorderWidthSolid,tuneSurfaceVariantForDefaultColor}from"./color-resolver.js";export{applyPresetLayer,camelToKebab,captureBuiltInPropSnapshot,captureInitialUserAttributes,clearAppliedPresetLayer,configContext,finalizeBuiltInPropSnapshot,findNearestPresetsConfig,getPresetLayer,isUserSetProp,lookupPresetSection,markUserSetProp,mergePresetsConfig,presetKeyAliases,refreshUserAttributes,resolveComponentProps,toPresetTagKey}from"./component-presets.js";export{CONTRAST_COLOR_SUPPORT_QUERY,ON_COLOR_FALLBACK_DARK,ON_COLOR_FALLBACK_LIGHT,contrastOnFill,contrastOverlay,contrastThemeInk,cssContrastColor,cssOnFill,cssOnFillEnhance,isLightFill,parseCssRgb,perceivedLuminance,relativeLuminance}from"./contrast-color.js";export{resolveRadius}from"./size-resolver.js";
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{html}from"lit";export{AnimationController}from"./helper/controllers/animation-controller.js";export{CONTRAST_COLOR_SUPPORT_QUERY,ON_COLOR_FALLBACK_DARK,ON_COLOR_FALLBACK_LIGHT,contrastOnFill,contrastOverlay,contrastThemeInk,cssContrastColor,cssOnFill,cssOnFillEnhance,isLightFill,parseCssRgb,perceivedLuminance,relativeLuminance}from"./helper/utils/contrast-color.js";export{ColorResolver,DEFAULT_COLOR_TOKENS,colorResolver,createGradient,darkShade,fadeMix,hoverShade,isDefaultColorToken,lightShade,parseGradientSpec,resolveAccentColorForToken,resolveColor,resolveGradientStop,resolveInkColorForToken,resolveSemanticSurfaceKey,semanticSoftSurfaceTokens,skyBorderPrimaryShorthand,skyBorderWidthSolid,tuneSurfaceVariantForDefaultColor}from"./helper/utils/color-resolver.js";export{FormControlBase}from"./helper/internals/form-control-base.js";export{PopoverController}from"./helper/controllers/popover-controller.js";export{PresetController}from"./helper/controllers/preset-controller.js";export{SkyAlert}from"./sky-alert/sky-alert.js";export{SkyAppbar}from"./sky-appbar/sky-appbar.js";export{SkyAvatar}from"./sky-avatar/sky-avatar.js";export{SkyBadge}from"./sky-badge/sky-badge.js";export{SkyButton}from"./sky-button/sky-button.js";export{SkyCard}from"./sky-card/sky-card.js";export{SkyCheckbox}from"./sky-checkbox/sky-checkbox.js";export{SkyChip}from"./sky-chip/sky-chip.js";export{SkyCol}from"./sky-col/sky-col.js";export{SkyCombobox}from"./sky-combobox/sky-combobox.js";export{SkyDialog}from"./sky-dialog/sky-dialog.js";export{SkyDivider}from"./sky-divider/sky-divider.js";export{SkyFlexbox}from"./sky-flexbox/sky-flexbox.js";export{SkyFlexcol}from"./sky-flexcol/sky-flexcol.js";export{SkyForm}from"./sky-form/sky-form.js";export{SkyGrid}from"./sky-grid/sky-grid.js";export{SkyIcon}from"./sky-icon/sky-icon.js";export{SkyImage}from"./sky-image/sky-image.js";export{SkyInput}from"./sky-input/sky-input.js";export{SkyList}from"./sky-list/sky-list.js";export{SkyListitem}from"./sky-listitem/sky-listitem.js";export{SkyRadio}from"./sky-radio/sky-radio.js";export{SkyRow}from"./sky-row/sky-row.js";export{SkySheet,resolveSheetRadius}from"./sky-sheet/sky-sheet.js";export{SkySimpleTable}from"./sky-simple-table/sky-simple-table.js";export{SkyThemeProvider,defaultTheme,getCurrentTheme,getThemePreference,mergeTheme,onThemeChange,resolveActualTheme,themeContext}from"./sky-theme-provider/sky-theme-provider.js";export{applyPresetLayer,camelToKebab,captureInitialUserAttributes,clearAppliedPresetLayer,configContext,findNearestPresetsConfig,getPresetLayer,isUserSetProp,lookupPresetSection,markUserSetProp,mergePresetsConfig,presetKeyAliases,refreshUserAttributes,resolveComponentProps,toPresetTagKey}from"./helper/utils/component-presets.js";export{extractIconNames,fetchIconsForOffline,registerOfflineIcons}from"./helper/iconify-offline.js";export{resolveRadius}from"./helper/utils/size-resolver.js";
1
+ export{html}from"lit";export{AnimationController}from"./helper/controllers/animation-controller.js";export{CONTRAST_COLOR_SUPPORT_QUERY,ON_COLOR_FALLBACK_DARK,ON_COLOR_FALLBACK_LIGHT,contrastOnFill,contrastOverlay,contrastThemeInk,cssContrastColor,cssOnFill,cssOnFillEnhance,isLightFill,parseCssRgb,perceivedLuminance,relativeLuminance}from"./helper/utils/contrast-color.js";export{ColorResolver,DEFAULT_COLOR_TOKENS,colorResolver,createGradient,darkShade,fadeMix,hoverShade,isDefaultColorToken,lightShade,parseGradientSpec,resolveAccentColorForToken,resolveColor,resolveGradientStop,resolveInkColorForToken,resolveSemanticSurfaceKey,semanticSoftSurfaceTokens,skyBorderPrimaryShorthand,skyBorderWidthSolid,tuneSurfaceVariantForDefaultColor}from"./helper/utils/color-resolver.js";export{FormControlBase}from"./helper/internals/form-control-base.js";export{PopoverController}from"./helper/controllers/popover-controller.js";export{PresetController}from"./helper/controllers/preset-controller.js";export{SkyAlert}from"./sky-alert/sky-alert.js";export{SkyAppbar}from"./sky-appbar/sky-appbar.js";export{SkyAvatar}from"./sky-avatar/sky-avatar.js";export{SkyBadge}from"./sky-badge/sky-badge.js";export{SkyButton}from"./sky-button/sky-button.js";export{SkyCard}from"./sky-card/sky-card.js";export{SkyCheckbox}from"./sky-checkbox/sky-checkbox.js";export{SkyChip}from"./sky-chip/sky-chip.js";export{SkyCol}from"./sky-col/sky-col.js";export{SkyCombobox}from"./sky-combobox/sky-combobox.js";export{SkyDialog}from"./sky-dialog/sky-dialog.js";export{SkyDivider}from"./sky-divider/sky-divider.js";export{SkyFlexbox}from"./sky-flexbox/sky-flexbox.js";export{SkyFlexcol}from"./sky-flexcol/sky-flexcol.js";export{SkyForm}from"./sky-form/sky-form.js";export{SkyGrid}from"./sky-grid/sky-grid.js";export{SkyIcon}from"./sky-icon/sky-icon.js";export{SkyImage}from"./sky-image/sky-image.js";export{SkyInput}from"./sky-input/sky-input.js";export{SkyList}from"./sky-list/sky-list.js";export{SkyListitem}from"./sky-listitem/sky-listitem.js";export{SkyRadio}from"./sky-radio/sky-radio.js";export{SkyRow}from"./sky-row/sky-row.js";export{SkySheet,resolveSheetRadius}from"./sky-sheet/sky-sheet.js";export{SkySimpleTable}from"./sky-simple-table/sky-simple-table.js";export{SkyThemeProvider,defaultTheme,getCurrentTheme,getThemePreference,mergeTheme,onThemeChange,resolveActualTheme,themeContext}from"./sky-theme-provider/sky-theme-provider.js";export{applyPresetLayer,camelToKebab,captureBuiltInPropSnapshot,captureInitialUserAttributes,clearAppliedPresetLayer,configContext,finalizeBuiltInPropSnapshot,findNearestPresetsConfig,getPresetLayer,isUserSetProp,lookupPresetSection,markUserSetProp,mergePresetsConfig,presetKeyAliases,refreshUserAttributes,resolveComponentProps,toPresetTagKey}from"./helper/utils/component-presets.js";export{extractIconNames,fetchIconsForOffline,registerOfflineIcons}from"./helper/iconify-offline.js";export{resolveRadius}from"./helper/utils/size-resolver.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1148,11 +1148,6 @@ import{unsafeCSS as t,css as e,LitElement as i,html as s,nothing as o}from"lit";
1148
1148
  padding-inline-end: var(--sky-input-pad-x-sm);
1149
1149
  padding-inline-start: var(--sky-input-pad-x-sm);
1150
1150
  box-sizing: border-box;
1151
- position: relative;
1152
- z-index: 1;
1153
- /* Opaque rail so value text never shows through behind clear */
1154
- background: var(--sky-glass-solid);
1155
- isolation: isolate;
1156
1151
  }
1157
1152
 
1158
1153
  sky-icon.clear-button {