/** * Component prop presets — global defaults + named bundles for sky-* CEs. * * Precedence (highest wins): * explicit user prop (attribute, framework property, or marked/diverged) → * named `preset` → provider `defaults` → built-in class default * * A named preset overlays `defaults` unless it sets `$inheritDefaults: false`, * in which case it is used standalone (keys it omits fall to the built-in). * * User-owned detection: * - attributes present before Lit's first reflect (and any attrs added later) * - props marked via `markUserSetProp` * - props the consumer changed after presets applied (divergence) * - props a framework set before first apply (current value ≠ constructor * snapshot from `captureBuiltInPropSnapshot` — covers Vue/React CE property * bindings that never create attributes). Overriding *back* to the exact * built-in default still needs an attribute or `markUserSetProp`. * * @see sky-config-provider */ /** Prop bag applied to a single component instance. */ export type ComponentPropBag = Record & { /** * Named presets only: set `false` to ignore `defaults[component]` and use * this bag standalone. Omitted / `true` keeps the default layering. */ $inheritDefaults?: boolean; }; /** * Config keys are custom element tag names (`sky-button`). * Short aliases without the `sky-` prefix (`button`) are also accepted. */ export type ComponentPresetKey = string; export type ComponentPresetsConfig = { /** Applied when the instance does not set the prop (no matching attribute). */ defaults?: Partial>; /** Named bundles selected via `preset="name"` on the instance. */ presets?: Partial>>; }; /** * Lookup aliases for a component key: tag name and short name. * `sky-button` ↔ `button`, `sky-button-group` ↔ `button-group`. */ export declare function presetKeyAliases(key: string): string[]; /** First matching bag under `defaults` / `presets` for any alias of `key`. */ export declare function lookupPresetSection(section: Partial> | null | undefined, key: string): T | undefined; /** * Canonical tag form for storage/docs: `button` → `sky-button`. * Already-tagged names are unchanged. */ export declare function toPresetTagKey(key: string): string; /** Lit context provided by ``. */ export declare const configContext: { __context__: ComponentPresetsConfig | null; }; /** camelCase / PascalCase → kebab-case attribute name. */ export declare function camelToKebab(name: string): string; /** * Snapshot host attributes once (call from controller `hostConnected`, before first update). * Declarative HTML / early `setAttribute` calls are treated as user-owned thereafter. */ export declare function captureInitialUserAttributes(host: HTMLElement): void; /** * Snapshot Lit `@property` values once during host construction (before frameworks * assign props). Later diffs against this map mark framework property bindings as * user-owned so presets do not overwrite them. * * Declare `PresetController` after the host's presettable `@property` fields so * those initials are already assigned when this runs. Keys still `undefined` are * filled by `finalizeBuiltInPropSnapshot` on connect (constructor-body defaults). */ export declare function captureBuiltInPropSnapshot(host: HTMLElement): void; /** * Fill snapshot entries that were still `undefined` when the controller * constructed (e.g. defaults assigned in the host `constructor` body after the * controller field). Does not overwrite defined snapshot values — those are the * true built-ins Vue/React may have already overridden by connect time. */ export declare function finalizeBuiltInPropSnapshot(host: HTMLElement): void; /** * Merge any attributes that appeared after connect (late framework bindings) * into the user-owned attribute snapshot. */ export declare function refreshUserAttributes(host: HTMLElement): void; /** * Mark a prop as consumer-owned so presets will not overwrite it. * Use for property-only bindings (no attribute) when needed. */ export declare function markUserSetProp(host: HTMLElement, prop: string): void; /** * True when the host had an attribute for this prop before/at apply time, * the prop was marked user-owned (explicit mark or post-apply divergence), * or a framework assigned a property that differs from the constructor snapshot * before presets first wrote that key. */ export declare function isUserSetProp(host: HTMLElement, prop: string): boolean; /** * Deep-merge parent + child preset configs. * Inner provider wins per component key, then per prop / named preset. */ export declare function mergePresetsConfig(parent: ComponentPresetsConfig | null | undefined, child: ComponentPresetsConfig | null | undefined): ComponentPresetsConfig; export type ResolveComponentPropsOptions> = { host: HTMLElement; componentKey: ComponentPresetKey; /** Value of the instance `preset` attribute/prop. */ presetName?: string | null; config?: ComponentPresetsConfig | null; /** Current instance values (class built-ins already applied). */ values: T; /** * Keys eligible for preset / default substitution. * Omit to apply every key present in the preset layer. */ keys?: Array; }; /** * True when `host` is rendered inside another `sky-*` component's shadow tree * (library chrome), not as slotted / light-DOM content. * * Slotted children keep `getRootNode() === document` (or an outer root), so * provider defaults still apply. Internals like `sky-button` inside `sky-table` * must not pick up app-level `defaults['sky-button']`. */ export declare function isSkyCompositeInternal(host: HTMLElement): boolean; /** * Walk ancestors for `` and deep-merge outer → inner. * Used when Lit context has not delivered a value yet (or as a reliable fallback). */ export declare function findNearestPresetsConfig(host: HTMLElement): ComponentPresetsConfig | null; /** * Resolve the active prop bag for a component: `defaults[key]` ← `presets[key][name]`. * Any prop key present in that bag can be applied to the instance. * * A named preset with `$inheritDefaults: false` is used standalone, so keys it * omits fall through to the component built-in instead of `defaults`. */ export declare function getPresetLayer(config: ComponentPresetsConfig | null | undefined, componentKey: ComponentPresetKey, presetName?: string | null): ComponentPropBag; export type ApplyPresetLayerOptions = { /** Extra keys never written from presets. */ skipKeys?: string[]; }; /** * Write every key from the preset layer onto the host (any component prop). * Skips user-owned attributes / props. Remembers prior values so removing a * key from the provider config restores the built-in / prior value. * * Before writing, detects divergence: if the host value no longer matches the * last preset-applied value, that prop is marked user-owned (property-only * overrides after first apply). Also locks in framework property bindings that * differ from the constructor snapshot before the first write for that key. * * @returns true if any host property changed */ export declare function applyPresetLayer(host: HTMLElement, layer: ComponentPropBag, options?: ApplyPresetLayerOptions): boolean; /** * Clear preset-applied props and restore saved built-ins (e.g. when paused in a group). */ export declare function clearAppliedPresetLayer(host: HTMLElement): boolean; /** * Resolve effective props for styling / behavior without mutating the host. * When `keys` is omitted, every key in the preset layer is considered. * Skips keys the user set via attributes. */ export declare function resolveComponentProps>(options: ResolveComponentPropsOptions): T;