@sky.ui/core 0.0.41 → 0.0.43

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.
Files changed (109) hide show
  1. package/dist/custom-elements.json +1277 -541
  2. package/dist/helper/controllers/animation-controller.d.ts +4 -4
  3. package/dist/helper/controllers/animation-controller.js.map +1 -1
  4. package/dist/helper/controllers/index.d.ts +1 -0
  5. package/dist/helper/controllers/index.js +1 -1
  6. package/dist/helper/controllers/popover-controller.d.ts +1 -1
  7. package/dist/helper/controllers/popover-controller.js.map +1 -1
  8. package/dist/helper/controllers/preset-controller.d.ts +55 -0
  9. package/dist/helper/controllers/preset-controller.js +2 -0
  10. package/dist/helper/controllers/preset-controller.js.map +1 -0
  11. package/dist/helper/iconify-offline.js.map +1 -1
  12. package/dist/helper/index.js +1 -1
  13. package/dist/helper/internals/form-control-base.d.ts +2 -2
  14. package/dist/helper/internals/form-control-base.js.map +1 -1
  15. package/dist/helper/styles/focus-ring.d.ts +10 -0
  16. package/dist/helper/styles/focus-ring.js +10 -0
  17. package/dist/helper/styles/focus-ring.js.map +1 -0
  18. package/dist/helper/utils/color-resolver.d.ts +0 -14
  19. package/dist/helper/utils/color-resolver.js +1 -1
  20. package/dist/helper/utils/color-resolver.js.map +1 -1
  21. package/dist/helper/utils/component-presets.d.ts +132 -0
  22. package/dist/helper/utils/component-presets.js +2 -0
  23. package/dist/helper/utils/component-presets.js.map +1 -0
  24. package/dist/helper/utils/contrast-color.d.ts +2 -2
  25. package/dist/helper/utils/contrast-color.js.map +1 -1
  26. package/dist/helper/utils/index.d.ts +1 -0
  27. package/dist/helper/utils/index.js +1 -1
  28. package/dist/helper/utils/size-resolver.js.map +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/sky-alert/sky-alert.d.ts +12 -4
  31. package/dist/sky-alert/sky-alert.js +4 -4
  32. package/dist/sky-alert/sky-alert.js.map +1 -1
  33. package/dist/sky-appbar/sky-appbar.d.ts +9 -3
  34. package/dist/sky-appbar/sky-appbar.js +4 -4
  35. package/dist/sky-appbar/sky-appbar.js.map +1 -1
  36. package/dist/sky-avatar/sky-avatar.d.ts +5 -1
  37. package/dist/sky-avatar/sky-avatar.js +7 -7
  38. package/dist/sky-avatar/sky-avatar.js.map +1 -1
  39. package/dist/sky-badge/sky-badge.d.ts +6 -2
  40. package/dist/sky-badge/sky-badge.js +6 -6
  41. package/dist/sky-badge/sky-badge.js.map +1 -1
  42. package/dist/sky-button/sky-button.d.ts +24 -4
  43. package/dist/sky-button/sky-button.js +9 -8
  44. package/dist/sky-button/sky-button.js.map +1 -1
  45. package/dist/sky-card/sky-card.d.ts +10 -2
  46. package/dist/sky-card/sky-card.js +4 -4
  47. package/dist/sky-card/sky-card.js.map +1 -1
  48. package/dist/sky-checkbox/sky-checkbox.d.ts +6 -3
  49. package/dist/sky-checkbox/sky-checkbox.js +47 -40
  50. package/dist/sky-checkbox/sky-checkbox.js.map +1 -1
  51. package/dist/sky-chip/sky-chip.d.ts +6 -2
  52. package/dist/sky-chip/sky-chip.js +10 -9
  53. package/dist/sky-chip/sky-chip.js.map +1 -1
  54. package/dist/sky-col/sky-col.d.ts +5 -1
  55. package/dist/sky-col/sky-col.js +4 -4
  56. package/dist/sky-col/sky-col.js.map +1 -1
  57. package/dist/sky-combobox/sky-combobox.d.ts +9 -2
  58. package/dist/sky-combobox/sky-combobox.js +27 -58
  59. package/dist/sky-combobox/sky-combobox.js.map +1 -1
  60. package/dist/sky-dialog/sky-dialog.d.ts +5 -1
  61. package/dist/sky-dialog/sky-dialog.js +3 -3
  62. package/dist/sky-dialog/sky-dialog.js.map +1 -1
  63. package/dist/sky-divider/sky-divider.d.ts +5 -1
  64. package/dist/sky-divider/sky-divider.js +5 -5
  65. package/dist/sky-divider/sky-divider.js.map +1 -1
  66. package/dist/sky-flexbox/sky-flexbox.d.ts +5 -1
  67. package/dist/sky-flexbox/sky-flexbox.js +4 -4
  68. package/dist/sky-flexbox/sky-flexbox.js.map +1 -1
  69. package/dist/sky-flexcol/sky-flexcol.d.ts +5 -1
  70. package/dist/sky-flexcol/sky-flexcol.js +2 -2
  71. package/dist/sky-flexcol/sky-flexcol.js.map +1 -1
  72. package/dist/sky-form/sky-form.d.ts +5 -1
  73. package/dist/sky-form/sky-form.js +2 -2
  74. package/dist/sky-form/sky-form.js.map +1 -1
  75. package/dist/sky-grid/sky-grid.d.ts +5 -1
  76. package/dist/sky-grid/sky-grid.js +3 -3
  77. package/dist/sky-grid/sky-grid.js.map +1 -1
  78. package/dist/sky-icon/sky-icon.d.ts +4 -1
  79. package/dist/sky-icon/sky-icon.js +4 -4
  80. package/dist/sky-icon/sky-icon.js.map +1 -1
  81. package/dist/sky-image/sky-image.d.ts +5 -1
  82. package/dist/sky-image/sky-image.js +5 -5
  83. package/dist/sky-image/sky-image.js.map +1 -1
  84. package/dist/sky-image/srcset-utils.js.map +1 -1
  85. package/dist/sky-input/sky-input.d.ts +5 -1
  86. package/dist/sky-input/sky-input.js +111 -111
  87. package/dist/sky-input/sky-input.js.map +1 -1
  88. package/dist/sky-list/sky-list.d.ts +5 -1
  89. package/dist/sky-list/sky-list.js +3 -3
  90. package/dist/sky-list/sky-list.js.map +1 -1
  91. package/dist/sky-listitem/sky-listitem.d.ts +5 -1
  92. package/dist/sky-listitem/sky-listitem.js +3 -3
  93. package/dist/sky-listitem/sky-listitem.js.map +1 -1
  94. package/dist/sky-radio/sky-radio.d.ts +8 -3
  95. package/dist/sky-radio/sky-radio.js +4 -3
  96. package/dist/sky-radio/sky-radio.js.map +1 -1
  97. package/dist/sky-row/sky-row.d.ts +4 -1
  98. package/dist/sky-row/sky-row.js +2 -2
  99. package/dist/sky-row/sky-row.js.map +1 -1
  100. package/dist/sky-sheet/sky-sheet.d.ts +7 -2
  101. package/dist/sky-sheet/sky-sheet.js +2 -2
  102. package/dist/sky-sheet/sky-sheet.js.map +1 -1
  103. package/dist/sky-simple-table/sky-simple-table.d.ts +5 -1
  104. package/dist/sky-simple-table/sky-simple-table.js +3 -3
  105. package/dist/sky-simple-table/sky-simple-table.js.map +1 -1
  106. package/dist/sky-theme-provider/sky-theme-provider.d.ts +1 -1
  107. package/dist/sky-theme-provider/sky-theme-provider.js +2 -2
  108. package/dist/sky-theme-provider/sky-theme-provider.js.map +1 -1
  109. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- import type { ReactiveController, ReactiveControllerHost } from "lit";
1
+ import type { ReactiveController, ReactiveControllerHost } from 'lit';
2
2
  /** Fill mode for WAAPI (KeyframeEffectOptions). */
3
- export type FillMode = "none" | "forwards" | "backwards" | "both";
3
+ export type FillMode = 'none' | 'forwards' | 'backwards' | 'both';
4
4
  /** Playback direction for WAAPI (KeyframeEffectOptions). */
5
- export type AnimationDirection = "normal" | "reverse" | "alternate" | "alternate-reverse";
5
+ export type AnimationDirection = 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
6
6
  /**
7
7
  * Options for a single animation run (Web Animations API).
8
8
  * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options
@@ -39,7 +39,7 @@ export interface AnimationControllerConfig {
39
39
  defaultFill?: FillMode;
40
40
  }
41
41
  /** Direction for slide presets. */
42
- export type SlideDirection = "up" | "down" | "left" | "right";
42
+ export type SlideDirection = 'up' | 'down' | 'left' | 'right';
43
43
  /**
44
44
  * AnimationController – consistent animations via the Web Animations API (WAAPI).
45
45
  *
@@ -1 +1 @@
1
- {"version":3,"file":"animation-controller.js","sources":["../../../src/helper/controllers/animation-controller.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from \"lit\";\r\n\r\n/** Fill mode for WAAPI (KeyframeEffectOptions). */\r\nexport type FillMode = \"none\" | \"forwards\" | \"backwards\" | \"both\";\r\n\r\n/** Playback direction for WAAPI (KeyframeEffectOptions). */\r\nexport type AnimationDirection =\r\n | \"normal\"\r\n | \"reverse\"\r\n | \"alternate\"\r\n | \"alternate-reverse\";\r\n\r\n/**\r\n * Options for a single animation run (Web Animations API).\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options\r\n */\r\nexport interface AnimationOptions {\r\n /** Duration in milliseconds. */\r\n duration?: number;\r\n /** Delay before start in milliseconds. */\r\n delay?: number;\r\n /** Easing function (CSS easing or cubic-bezier). */\r\n easing?: string;\r\n /** Fill mode: 'none' | 'forwards' | 'backwards' | 'both'. */\r\n fill?: FillMode;\r\n /** Number of iterations (default 1). */\r\n iterations?: number;\r\n /** Playback direction. */\r\n direction?: AnimationDirection;\r\n /** End delay in milliseconds. */\r\n endDelay?: number;\r\n /** Unique id for the animation (useful for canceling by id). */\r\n id?: string;\r\n}\r\n\r\n/**\r\n * Keyframes format accepted by Element.animate().\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats\r\n */\r\nexport type AnimationKeyframes =\r\n | Keyframe[]\r\n | PropertyIndexedKeyframes;\r\n\r\n/**\r\n * Configuration for the controller defaults (used when not overridden per call).\r\n */\r\nexport interface AnimationControllerConfig {\r\n defaultDuration?: number;\r\n defaultEasing?: string;\r\n defaultFill?: FillMode;\r\n}\r\n\r\n/** Direction for slide presets. */\r\nexport type SlideDirection = \"up\" | \"down\" | \"left\" | \"right\";\r\n\r\n/**\r\n * AnimationController – consistent animations via the Web Animations API (WAAPI).\r\n *\r\n * Use as a Lit ReactiveController so components get:\r\n * - Shared defaults (duration, easing, fill)\r\n * - Preset helpers: fadeIn, fadeOut, slideIn, slideOut, scaleIn, scaleOut\r\n * - Low-level animate() for custom keyframes\r\n * - Automatic cancellation of running animations when the host disconnects\r\n *\r\n * @example\r\n * ```ts\r\n * class MyPanel extends LitElement {\r\n * animation = new AnimationController(this, { defaultDuration: 200, defaultEasing: 'ease-out' });\r\n *\r\n * async open() {\r\n * await this.animation.fadeIn(this.panelEl);\r\n * }\r\n *\r\n * async close() {\r\n * await this.animation.fadeOut(this.panelEl);\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport class AnimationController implements ReactiveController {\r\n readonly host: ReactiveControllerHost;\r\n private readonly config: Required<AnimationControllerConfig>;\r\n private readonly running = new Set<Animation>();\r\n\r\n constructor(\r\n host: ReactiveControllerHost,\r\n config: AnimationControllerConfig = {},\r\n ) {\r\n this.host = host;\r\n this.config = {\r\n defaultDuration: config.defaultDuration ?? 200,\r\n defaultEasing: config.defaultEasing ?? \"ease-out\",\r\n defaultFill: config.defaultFill ?? \"forwards\",\r\n };\r\n host.addController(this);\r\n }\r\n\r\n hostDisconnected(): void {\r\n this.running.forEach((a) => {\r\n try {\r\n a.cancel();\r\n } catch {\r\n // ignore\r\n }\r\n });\r\n this.running.clear();\r\n }\r\n\r\n /**\r\n * Run a WAAPI animation on an element. Returns the Animation for chaining or await .finished.\r\n * Running animations are tracked and cancelled when the host disconnects.\r\n */\r\n animate(\r\n element: Element | null | undefined,\r\n keyframes: AnimationKeyframes,\r\n options: AnimationOptions = {},\r\n ): Animation | null {\r\n if (!element) return null;\r\n\r\n const duration = options.duration ?? this.config.defaultDuration;\r\n const easing = options.easing ?? this.config.defaultEasing;\r\n const fill = options.fill ?? this.config.defaultFill;\r\n\r\n const opts: KeyframeAnimationOptions = {\r\n duration,\r\n delay: options.delay ?? 0,\r\n easing,\r\n fill,\r\n iterations: options.iterations ?? 1,\r\n direction: options.direction ?? \"normal\",\r\n endDelay: options.endDelay ?? 0,\r\n id: options.id,\r\n };\r\n\r\n const animation = element.animate(keyframes as Keyframe[], opts);\r\n this.running.add(animation);\r\n animation.finished\r\n .then(() => this.running.delete(animation))\r\n .catch(() => this.running.delete(animation));\r\n return animation;\r\n }\r\n\r\n /**\r\n * Fade in: opacity 0 → 1.\r\n */\r\n fadeIn(\r\n element: Element | null | undefined,\r\n options: AnimationOptions = {},\r\n ): Animation | null {\r\n return this.animate(\r\n element,\r\n [{ opacity: 0 }, { opacity: 1 }],\r\n options,\r\n );\r\n }\r\n\r\n /**\r\n * Fade out: opacity 1 → 0.\r\n */\r\n fadeOut(\r\n element: Element | null | undefined,\r\n options: AnimationOptions = {},\r\n ): Animation | null {\r\n return this.animate(\r\n element,\r\n [{ opacity: 1 }, { opacity: 0 }],\r\n options,\r\n );\r\n }\r\n\r\n /**\r\n * Slide in from the given direction (translate from off-screen to 0).\r\n */\r\n slideIn(\r\n element: Element | null | undefined,\r\n options: AnimationOptions & { direction?: SlideDirection } = {},\r\n ): Animation | null {\r\n const dir = options.direction ?? \"down\";\r\n const [fromX, fromY] = slideOffset(dir, true);\r\n const keyframes: Keyframe[] = [\r\n { transform: `translate(${fromX}, ${fromY})` },\r\n { transform: \"translate(0, 0)\" },\r\n ];\r\n return this.animate(element, keyframes, options);\r\n }\r\n\r\n /**\r\n * Slide out toward the given direction (translate from 0 to off-screen).\r\n */\r\n slideOut(\r\n element: Element | null | undefined,\r\n options: AnimationOptions & { direction?: SlideDirection } = {},\r\n ): Animation | null {\r\n const dir = options.direction ?? \"up\";\r\n const [toX, toY] = slideOffset(dir, false);\r\n const keyframes: Keyframe[] = [\r\n { transform: \"translate(0, 0)\" },\r\n { transform: `translate(${toX}, ${toY})` },\r\n ];\r\n return this.animate(element, keyframes, options);\r\n }\r\n\r\n /**\r\n * Scale in: scale(0) or scale(0.9) → scale(1). Optionally combine with opacity.\r\n */\r\n scaleIn(\r\n element: Element | null | undefined,\r\n options: AnimationOptions & { fromScale?: number; opacity?: boolean } = {},\r\n ): Animation | null {\r\n const from = options.fromScale ?? 0.95;\r\n const withOpacity = options.opacity !== false;\r\n const keyframes: Keyframe[] = withOpacity\r\n ? [\r\n { transform: `scale(${from})`, opacity: 0 },\r\n { transform: \"scale(1)\", opacity: 1 },\r\n ]\r\n : [\r\n { transform: `scale(${from})` },\r\n { transform: \"scale(1)\" },\r\n ];\r\n return this.animate(element, keyframes, options);\r\n }\r\n\r\n /**\r\n * Scale out: scale(1) → scale(0.95) or custom. Optionally combine with opacity.\r\n */\r\n scaleOut(\r\n element: Element | null | undefined,\r\n options: AnimationOptions & { toScale?: number; opacity?: boolean } = {},\r\n ): Animation | null {\r\n const to = options.toScale ?? 0.95;\r\n const withOpacity = options.opacity !== false;\r\n const keyframes: Keyframe[] = withOpacity\r\n ? [\r\n { transform: \"scale(1)\", opacity: 1 },\r\n { transform: `scale(${to})`, opacity: 0 },\r\n ]\r\n : [\r\n { transform: \"scale(1)\" },\r\n { transform: `scale(${to})` },\r\n ];\r\n return this.animate(element, keyframes, options);\r\n }\r\n\r\n /**\r\n * Cancel a specific animation (e.g. one you stored from animate() or a preset).\r\n */\r\n cancel(animation: Animation): void {\r\n animation.cancel();\r\n this.running.delete(animation);\r\n }\r\n\r\n /**\r\n * Cancel all animations currently running for this controller.\r\n */\r\n cancelAll(): void {\r\n this.running.forEach((a) => {\r\n try {\r\n a.cancel();\r\n } catch {\r\n // ignore\r\n }\r\n });\r\n this.running.clear();\r\n }\r\n}\r\n\r\nfunction slideOffset(\r\n direction: SlideDirection,\r\n isIn: boolean,\r\n): [string, string] {\r\n const pct = \"100%\";\r\n switch (direction) {\r\n case \"up\":\r\n return [\"0\", isIn ? pct : `-${pct}`];\r\n case \"down\":\r\n return [\"0\", isIn ? `-${pct}` : pct];\r\n case \"left\":\r\n return [isIn ? pct : `-${pct}`, \"0\"];\r\n case \"right\":\r\n return [isIn ? `-${pct}` : pct, \"0\"];\r\n default:\r\n return [\"0\", isIn ? `-${pct}` : pct];\r\n }\r\n}\r\n"],"names":["AnimationController","constructor","host","config","this","running","Set","defaultDuration","defaultEasing","defaultFill","addController","hostDisconnected","forEach","a","cancel","clear","animate","element","keyframes","options","duration","easing","fill","opts","delay","iterations","direction","endDelay","id","animation","add","finished","then","delete","catch","fadeIn","opacity","fadeOut","slideIn","dir","fromX","fromY","slideOffset","transform","slideOut","toX","toY","scaleIn","from","fromScale","scaleOut","to","toScale","cancelAll","isIn","pct"],"mappings":"AA+EO,MAAMA,EAKX,WAAAC,CACEC,EACAC,EAAoC,IAJtCC,KAAiBC,YAAcC,IAM7BF,KAAKF,KAAOA,EACZE,KAAKD,OAAS,C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,EAAM,IAAIA,IAAO,KAClC,IAAK,QACH,MAAO,CAACD,EAAO,IAAIC,IAAQA,EAAK,KAItC"}
1
+ {"version":3,"file":"animation-controller.js","sources":["../../../src/helper/controllers/animation-controller.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\r\n\r\n/** Fill mode for WAAPI (KeyframeEffectOptions). */\r\nexport type FillMode = 'none' | 'forwards' | 'backwards' | 'both';\r\n\r\n/** Playback direction for WAAPI (KeyframeEffectOptions). */\r\nexport type AnimationDirection =\r\n 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';\r\n\r\n/**\r\n * Options for a single animation run (Web Animations API).\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyframeEffect/KeyframeEffect#options\r\n */\r\nexport interface AnimationOptions {\r\n /** Duration in milliseconds. */\r\n duration?: number;\r\n /** Delay before start in milliseconds. */\r\n delay?: number;\r\n /** Easing function (CSS easing or cubic-bezier). */\r\n easing?: string;\r\n /** Fill mode: 'none' | 'forwards' | 'backwards' | 'both'. */\r\n fill?: FillMode;\r\n /** Number of iterations (default 1). */\r\n iterations?: number;\r\n /** Playback direction. */\r\n direction?: AnimationDirection;\r\n /** End delay in milliseconds. */\r\n endDelay?: number;\r\n /** Unique id for the animation (useful for canceling by id). */\r\n id?: string;\r\n}\r\n\r\n/**\r\n * Keyframes format accepted by Element.animate().\r\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats\r\n */\r\nexport type AnimationKeyframes = Keyframe[] | PropertyIndexedKeyframes;\r\n\r\n/**\r\n * Configuration for the controller defaults (used when not overridden per call).\r\n */\r\nexport interface AnimationControllerConfig {\r\n defaultDuration?: number;\r\n defaultEasing?: string;\r\n defaultFill?: FillMode;\r\n}\r\n\r\n/** Direction for slide presets. */\r\nexport type SlideDirection = 'up' | 'down' | 'left' | 'right';\r\n\r\n/**\r\n * AnimationController – consistent animations via the Web Animations API (WAAPI).\r\n *\r\n * Use as a Lit ReactiveController so components get:\r\n * - Shared defaults (duration, easing, fill)\r\n * - Preset helpers: fadeIn, fadeOut, slideIn, slideOut, scaleIn, scaleOut\r\n * - Low-level animate() for custom keyframes\r\n * - Automatic cancellation of running animations when the host disconnects\r\n *\r\n * @example\r\n * ```ts\r\n * class MyPanel extends LitElement {\r\n * animation = new AnimationController(this, { defaultDuration: 200, defaultEasing: 'ease-out' });\r\n *\r\n * async open() {\r\n * await this.animation.fadeIn(this.panelEl);\r\n * }\r\n *\r\n * async close() {\r\n * await this.animation.fadeOut(this.panelEl);\r\n * }\r\n * }\r\n * ```\r\n */\r\nexport class AnimationController implements ReactiveController {\r\n readonly host: ReactiveControllerHost;\r\n private readonly config: Required<AnimationControllerConfig>;\r\n private readonly running = new Set<Animation>();\r\n\r\n constructor(\r\n host: ReactiveControllerHost,\r\n config: AnimationControllerConfig = {}\r\n ) {\r\n this.host = host;\r\n this.config = {\r\n defaultDuration: config.defaultDuration ?? 200,\r\n defaultEasing: config.defaultEasing ?? 'ease-out',\r\n defaultFill: config.defaultFill ?? 'forwards',\r\n };\r\n host.addController(this);\r\n }\r\n\r\n hostDisconnected(): void {\r\n this.running.forEach((a) => {\r\n try {\r\n a.cancel();\r\n } catch {\r\n // ignore\r\n }\r\n });\r\n this.running.clear();\r\n }\r\n\r\n /**\r\n * Run a WAAPI animation on an element. Returns the Animation for chaining or await .finished.\r\n * Running animations are tracked and cancelled when the host disconnects.\r\n */\r\n animate(\r\n element: Element | null | undefined,\r\n keyframes: AnimationKeyframes,\r\n options: AnimationOptions = {}\r\n ): Animation | null {\r\n if (!element) return null;\r\n\r\n const duration = options.duration ?? this.config.defaultDuration;\r\n const easing = options.easing ?? this.config.defaultEasing;\r\n const fill = options.fill ?? this.config.defaultFill;\r\n\r\n const opts: KeyframeAnimationOptions = {\r\n duration,\r\n delay: options.delay ?? 0,\r\n easing,\r\n fill,\r\n iterations: options.iterations ?? 1,\r\n direction: options.direction ?? 'normal',\r\n endDelay: options.endDelay ?? 0,\r\n id: options.id,\r\n };\r\n\r\n const animation = element.animate(keyframes as Keyframe[], opts);\r\n this.running.add(animation);\r\n animation.finished\r\n .then(() => this.running.delete(animation))\r\n .catch(() => this.running.delete(animation));\r\n return animation;\r\n }\r\n\r\n /**\r\n * Fade in: opacity 0 → 1.\r\n */\r\n fadeIn(\r\n element: Element | null | undefined,\r\n options: AnimationOptions = {}\r\n ): Animation | null {\r\n return this.animate(element, [{ opacity: 0 }, { opacity: 1 }], options);\r\n }\r\n\r\n /**\r\n * Fade out: opacity 1 → 0.\r\n */\r\n fadeOut(\r\n element: Element | null | undefined,\r\n options: AnimationOptions = {}\r\n ): Animation | null {\r\n return this.animate(element, [{ opacity: 1 }, { opacity: 0 }], options);\r\n }\r\n\r\n /**\r\n * Slide in from the given direction (translate from off-screen to 0).\r\n */\r\n slideIn(\r\n element: Element | null | undefined,\r\n options: AnimationOptions & { direction?: SlideDirection } = {}\r\n ): Animation | null {\r\n const dir = options.direction ?? 'down';\r\n const [fromX, fromY] = slideOffset(dir, true);\r\n const keyframes: Keyframe[] = [\r\n { transform: `translate(${fromX}, ${fromY})` },\r\n { transform: 'translate(0, 0)' },\r\n ];\r\n return this.animate(element, keyframes, options);\r\n }\r\n\r\n /**\r\n * Slide out toward the given direction (translate from 0 to off-screen).\r\n */\r\n slideOut(\r\n element: Element | null | undefined,\r\n options: AnimationOptions & { direction?: SlideDirection } = {}\r\n ): Animation | null {\r\n const dir = options.direction ?? 'up';\r\n const [toX, toY] = slideOffset(dir, false);\r\n const keyframes: Keyframe[] = [\r\n { transform: 'translate(0, 0)' },\r\n { transform: `translate(${toX}, ${toY})` },\r\n ];\r\n return this.animate(element, keyframes, options);\r\n }\r\n\r\n /**\r\n * Scale in: scale(0) or scale(0.9) → scale(1). Optionally combine with opacity.\r\n */\r\n scaleIn(\r\n element: Element | null | undefined,\r\n options: AnimationOptions & { fromScale?: number; opacity?: boolean } = {}\r\n ): Animation | null {\r\n const from = options.fromScale ?? 0.95;\r\n const withOpacity = options.opacity !== false;\r\n const keyframes: Keyframe[] = withOpacity\r\n ? [\r\n { transform: `scale(${from})`, opacity: 0 },\r\n { transform: 'scale(1)', opacity: 1 },\r\n ]\r\n : [{ transform: `scale(${from})` }, { transform: 'scale(1)' }];\r\n return this.animate(element, keyframes, options);\r\n }\r\n\r\n /**\r\n * Scale out: scale(1) → scale(0.95) or custom. Optionally combine with opacity.\r\n */\r\n scaleOut(\r\n element: Element | null | undefined,\r\n options: AnimationOptions & { toScale?: number; opacity?: boolean } = {}\r\n ): Animation | null {\r\n const to = options.toScale ?? 0.95;\r\n const withOpacity = options.opacity !== false;\r\n const keyframes: Keyframe[] = withOpacity\r\n ? [\r\n { transform: 'scale(1)', opacity: 1 },\r\n { transform: `scale(${to})`, opacity: 0 },\r\n ]\r\n : [{ transform: 'scale(1)' }, { transform: `scale(${to})` }];\r\n return this.animate(element, keyframes, options);\r\n }\r\n\r\n /**\r\n * Cancel a specific animation (e.g. one you stored from animate() or a preset).\r\n */\r\n cancel(animation: Animation): void {\r\n animation.cancel();\r\n this.running.delete(animation);\r\n }\r\n\r\n /**\r\n * Cancel all animations currently running for this controller.\r\n */\r\n cancelAll(): void {\r\n this.running.forEach((a) => {\r\n try {\r\n a.cancel();\r\n } catch {\r\n // ignore\r\n }\r\n });\r\n this.running.clear();\r\n }\r\n}\r\n\r\nfunction slideOffset(\r\n direction: SlideDirection,\r\n isIn: boolean\r\n): [string, string] {\r\n const pct = '100%';\r\n switch (direction) {\r\n case 'up':\r\n return ['0', isIn ? pct : `-${pct}`];\r\n case 'down':\r\n return ['0', isIn ? `-${pct}` : pct];\r\n case 'left':\r\n return [isIn ? pct : `-${pct}`, '0'];\r\n case 'right':\r\n return [isIn ? `-${pct}` : pct, '0'];\r\n default:\r\n return ['0', isIn ? `-${pct}` : pct];\r\n }\r\n}\r\n"],"names":["AnimationController","constructor","host","config","this","running","Set","defaultDuration","defaultEasing","defaultFill","addController","hostDisconnected","forEach","a","cancel","clear","animate","element","keyframes","options","duration","easing","fill","opts","delay","iterations","direction","endDelay","id","animation","add","finished","then","delete","catch","fadeIn","opacity","fadeOut","slideIn","dir","fromX","fromY","slideOffset","transform","slideOut","toX","toY","scaleIn","from","fromScale","scaleOut","to","toScale","cancelAll","isIn","pct"],"mappings":"AA0EO,MAAMA,EAKX,WAAAC,CACEC,EACAC,EAAoC,IAJtCC,KAAiBC,YAAcC,IAM7BF,KAAKF,KAAOA,EACZE,KAAKD,OAAS,CACZI,gBAAiBJ,EAAOI,iBAAmB,IAC3CC,cAAeL,EAAOK,eAAiB,WACvCC,YAAaN,EAAOM,aAAe,YAErCP,EAAKQ,cAAcN,KACrB,CAEA,gBAAAO,GACEP,KAAKC,QAAQO,QAASC,IACpB,IACEA,EAAEC,QACJ,CAAA,MAEA,IAEFV,KAAKC,QAAQU,OACf,CAMA,OAAAC,CACEC,EACAC,EACAC,EAA4B,CAAA,GAE5B,IAAKF,EAAS,OAAO,KAErB,MAAMG,EAAWD,EAAQC,UAAYhB,KAAKD,OAAOI,gBAC3Cc,EAASF,EAAQE,QAAUjB,KAAKD,OAAOK,cACvCc,EAAOH,EAAQG,MAAQlB,KAAKD,OAAOM,YAEnCc,EAAiC,CACrCH,WACAI,MAAOL,EAAQK,OAAS,EACxBH,SACAC,OACAG,WAAYN,EAAQM,YAAc,EAClCC,UAAWP,EAAQO,WAAa,SAChCC,SAAUR,EAAQQ,UAAY,EAC9BC,GAAIT,EAAQS,IAGRC,EAAYZ,EAAQD,QAAQE,EAAyBK,GAK3D,OAJAnB,KAAKC,QAAQyB,IAAID,GACjBA,EAAUE,SACPC,KAAK,IAAM5B,KAAKC,QAAQ4B,OAAOJ,IAC/BK,MAAM,IAAM9B,KAAKC,QAAQ4B,OAAOJ,IAC5BA,CACT,CAKA,MAAAM,CACElB,EACAE,EAA4B,IAE5B,OAAOf,KAAKY,QAAQC,EAAS,CAAC,CAAEmB,QAAS,GAAK,CAAEA,QAAS,IAAMjB,EACjE,CAKA,OAAAkB,CACEp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AQO,QAASC,IACpB,IACEA,EAAEC,QACJ,CAAA,MAEA,IAEFV,KAAKC,QAAQU,OACf,EAGF,SAAS2B,EACPhB,EACA4B,GAEA,MAAMC,EAAM,OACZ,OAAQ7B,GACN,IAAK,KACH,MAAO,CAAC,IAAK4B,EAAOC,EAAM,IAAIA,KAChC,IAAK,OAML,QACE,MAAO,CAAC,IAAKD,EAAO,IAAIC,IAAQA,GALlC,IAAK,OACH,MAAO,CAACD,EAAOC,EAAM,IAAIA,IAAO,KAClC,IAAK,QACH,MAAO,CAACD,EAAO,IAAIC,IAAQA,EAAK,KAItC"}
@@ -1,2 +1,3 @@
1
1
  export * from "./animation-controller";
2
2
  export * from "./popover-controller";
3
+ export * from "./preset-controller";
@@ -1,2 +1,2 @@
1
- export{AnimationController}from"./animation-controller.js";export{PopoverController}from"./popover-controller.js";
1
+ export{AnimationController}from"./animation-controller.js";export{PopoverController}from"./popover-controller.js";export{PresetController}from"./preset-controller.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -6,7 +6,7 @@ export type MaxWidthMode = "cap" | "fill";
6
6
  export type CloseReason = "api" | "toggle" | "escape" | "light-dismiss" | "group";
7
7
  type ArrowAlign = "center" | "start" | "end";
8
8
  type ScrollContainerMode = "auto" | "window";
9
- /** ✅ Presets: consumer only names it */
9
+ /** Named animation presets; consumer selects by name. */
10
10
  export type PopoverPreset = "none" | "fade" | "scale" | "slide" | "iosMenu" | "iosSheet" | "materialMenu" | "materialSheet" | "floaty" | "soft" | "sharp" | "blurIn" | "blurFade" | "zoomFromAnchor" | "zoomFromCorner" | "flip3d" | "card3d" | "tilt3d" | "depth3d" | "rotate3d" | "springy" | "bouncy" | "glide" | "pop" | "drop" | "grow";
11
11
  export type PopoverPresetConfig = {
12
12
  enterPx?: number;