@hyalo/angular 0.0.0-stage → 0.3.1

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 (229) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/LICENSE +21 -0
  3. package/README.md +45 -2
  4. package/fesm2022/hyalo-angular-accordion.mjs +230 -0
  5. package/fesm2022/hyalo-angular-accordion.mjs.map +1 -0
  6. package/fesm2022/hyalo-angular-alert.mjs +171 -0
  7. package/fesm2022/hyalo-angular-alert.mjs.map +1 -0
  8. package/fesm2022/hyalo-angular-aspect-ratio.mjs +64 -0
  9. package/fesm2022/hyalo-angular-aspect-ratio.mjs.map +1 -0
  10. package/fesm2022/hyalo-angular-avatar.mjs +169 -0
  11. package/fesm2022/hyalo-angular-avatar.mjs.map +1 -0
  12. package/fesm2022/hyalo-angular-badge.mjs +268 -0
  13. package/fesm2022/hyalo-angular-badge.mjs.map +1 -0
  14. package/fesm2022/hyalo-angular-bento.mjs +132 -0
  15. package/fesm2022/hyalo-angular-bento.mjs.map +1 -0
  16. package/fesm2022/hyalo-angular-blocks.mjs +985 -0
  17. package/fesm2022/hyalo-angular-blocks.mjs.map +1 -0
  18. package/fesm2022/hyalo-angular-border-beam.mjs +73 -0
  19. package/fesm2022/hyalo-angular-border-beam.mjs.map +1 -0
  20. package/fesm2022/hyalo-angular-breadcrumb.mjs +77 -0
  21. package/fesm2022/hyalo-angular-breadcrumb.mjs.map +1 -0
  22. package/fesm2022/hyalo-angular-button-group.mjs +90 -0
  23. package/fesm2022/hyalo-angular-button-group.mjs.map +1 -0
  24. package/fesm2022/hyalo-angular-button.mjs +204 -0
  25. package/fesm2022/hyalo-angular-button.mjs.map +1 -0
  26. package/fesm2022/hyalo-angular-card.mjs +221 -0
  27. package/fesm2022/hyalo-angular-card.mjs.map +1 -0
  28. package/fesm2022/hyalo-angular-carousel.mjs +709 -0
  29. package/fesm2022/hyalo-angular-carousel.mjs.map +1 -0
  30. package/fesm2022/hyalo-angular-chapter-nav.mjs +336 -0
  31. package/fesm2022/hyalo-angular-chapter-nav.mjs.map +1 -0
  32. package/fesm2022/hyalo-angular-chart-engine-DSJop6He.mjs +5 -0
  33. package/fesm2022/hyalo-angular-chart-engine-DSJop6He.mjs.map +1 -0
  34. package/fesm2022/hyalo-angular-chart.mjs +391 -0
  35. package/fesm2022/hyalo-angular-chart.mjs.map +1 -0
  36. package/fesm2022/hyalo-angular-choice.mjs +789 -0
  37. package/fesm2022/hyalo-angular-choice.mjs.map +1 -0
  38. package/fesm2022/hyalo-angular-code-block-highlight-B20d5C76.mjs +40 -0
  39. package/fesm2022/hyalo-angular-code-block-highlight-B20d5C76.mjs.map +1 -0
  40. package/fesm2022/hyalo-angular-code-block.mjs +161 -0
  41. package/fesm2022/hyalo-angular-code-block.mjs.map +1 -0
  42. package/fesm2022/hyalo-angular-command.mjs +193 -0
  43. package/fesm2022/hyalo-angular-command.mjs.map +1 -0
  44. package/fesm2022/hyalo-angular-copy.mjs +138 -0
  45. package/fesm2022/hyalo-angular-copy.mjs.map +1 -0
  46. package/fesm2022/hyalo-angular-core.mjs +424 -0
  47. package/fesm2022/hyalo-angular-core.mjs.map +1 -0
  48. package/fesm2022/hyalo-angular-description-list.mjs +57 -0
  49. package/fesm2022/hyalo-angular-description-list.mjs.map +1 -0
  50. package/fesm2022/hyalo-angular-dialog.mjs +600 -0
  51. package/fesm2022/hyalo-angular-dialog.mjs.map +1 -0
  52. package/fesm2022/hyalo-angular-divider.mjs +66 -0
  53. package/fesm2022/hyalo-angular-divider.mjs.map +1 -0
  54. package/fesm2022/hyalo-angular-empty-state.mjs +123 -0
  55. package/fesm2022/hyalo-angular-empty-state.mjs.map +1 -0
  56. package/fesm2022/hyalo-angular-field.mjs +344 -0
  57. package/fesm2022/hyalo-angular-field.mjs.map +1 -0
  58. package/fesm2022/hyalo-angular-filter.mjs +309 -0
  59. package/fesm2022/hyalo-angular-filter.mjs.map +1 -0
  60. package/fesm2022/hyalo-angular-hotspot.mjs +225 -0
  61. package/fesm2022/hyalo-angular-hotspot.mjs.map +1 -0
  62. package/fesm2022/hyalo-angular-hover-card.mjs +233 -0
  63. package/fesm2022/hyalo-angular-hover-card.mjs.map +1 -0
  64. package/fesm2022/hyalo-angular-icon.mjs +385 -0
  65. package/fesm2022/hyalo-angular-icon.mjs.map +1 -0
  66. package/fesm2022/hyalo-angular-image-compare.mjs +168 -0
  67. package/fesm2022/hyalo-angular-image-compare.mjs.map +1 -0
  68. package/fesm2022/hyalo-angular-interaction.mjs +446 -0
  69. package/fesm2022/hyalo-angular-interaction.mjs.map +1 -0
  70. package/fesm2022/hyalo-angular-kbd.mjs +41 -0
  71. package/fesm2022/hyalo-angular-kbd.mjs.map +1 -0
  72. package/fesm2022/hyalo-angular-lightbox.mjs +228 -0
  73. package/fesm2022/hyalo-angular-lightbox.mjs.map +1 -0
  74. package/fesm2022/hyalo-angular-link.mjs +42 -0
  75. package/fesm2022/hyalo-angular-link.mjs.map +1 -0
  76. package/fesm2022/hyalo-angular-list.mjs +131 -0
  77. package/fesm2022/hyalo-angular-list.mjs.map +1 -0
  78. package/fesm2022/hyalo-angular-marquee.mjs +197 -0
  79. package/fesm2022/hyalo-angular-marquee.mjs.map +1 -0
  80. package/fesm2022/hyalo-angular-menu.mjs +423 -0
  81. package/fesm2022/hyalo-angular-menu.mjs.map +1 -0
  82. package/fesm2022/hyalo-angular-mesh.mjs +126 -0
  83. package/fesm2022/hyalo-angular-mesh.mjs.map +1 -0
  84. package/fesm2022/hyalo-angular-motion.mjs +620 -0
  85. package/fesm2022/hyalo-angular-motion.mjs.map +1 -0
  86. package/fesm2022/hyalo-angular-navbar.mjs +343 -0
  87. package/fesm2022/hyalo-angular-navbar.mjs.map +1 -0
  88. package/fesm2022/hyalo-angular-navigation-menu.mjs +222 -0
  89. package/fesm2022/hyalo-angular-navigation-menu.mjs.map +1 -0
  90. package/fesm2022/hyalo-angular-number-ticker.mjs +174 -0
  91. package/fesm2022/hyalo-angular-number-ticker.mjs.map +1 -0
  92. package/fesm2022/hyalo-angular-overlay.mjs +163 -0
  93. package/fesm2022/hyalo-angular-overlay.mjs.map +1 -0
  94. package/fesm2022/hyalo-angular-pagination.mjs +187 -0
  95. package/fesm2022/hyalo-angular-pagination.mjs.map +1 -0
  96. package/fesm2022/hyalo-angular-popover-overlay-kit-6wPwnxln.mjs +3 -0
  97. package/fesm2022/hyalo-angular-popover.mjs +516 -0
  98. package/fesm2022/hyalo-angular-popover.mjs.map +1 -0
  99. package/fesm2022/hyalo-angular-progress.mjs +209 -0
  100. package/fesm2022/hyalo-angular-progress.mjs.map +1 -0
  101. package/fesm2022/hyalo-angular-progressive-blur.mjs +73 -0
  102. package/fesm2022/hyalo-angular-progressive-blur.mjs.map +1 -0
  103. package/fesm2022/hyalo-angular-refraction-renderer-5ZA-kfsA.mjs +186 -0
  104. package/fesm2022/hyalo-angular-refraction-renderer-5ZA-kfsA.mjs.map +1 -0
  105. package/fesm2022/hyalo-angular-refraction.mjs +178 -0
  106. package/fesm2022/hyalo-angular-refraction.mjs.map +1 -0
  107. package/fesm2022/hyalo-angular-scroll-area.mjs +93 -0
  108. package/fesm2022/hyalo-angular-scroll-area.mjs.map +1 -0
  109. package/fesm2022/hyalo-angular-scroll-to-top.mjs +127 -0
  110. package/fesm2022/hyalo-angular-scroll-to-top.mjs.map +1 -0
  111. package/fesm2022/hyalo-angular-segmented.mjs +223 -0
  112. package/fesm2022/hyalo-angular-segmented.mjs.map +1 -0
  113. package/fesm2022/hyalo-angular-select.mjs +561 -0
  114. package/fesm2022/hyalo-angular-select.mjs.map +1 -0
  115. package/fesm2022/hyalo-angular-sidebar.mjs +241 -0
  116. package/fesm2022/hyalo-angular-sidebar.mjs.map +1 -0
  117. package/fesm2022/hyalo-angular-skeleton.mjs +131 -0
  118. package/fesm2022/hyalo-angular-skeleton.mjs.map +1 -0
  119. package/fesm2022/hyalo-angular-sparkline.mjs +110 -0
  120. package/fesm2022/hyalo-angular-sparkline.mjs.map +1 -0
  121. package/fesm2022/hyalo-angular-split-text.mjs +126 -0
  122. package/fesm2022/hyalo-angular-split-text.mjs.map +1 -0
  123. package/fesm2022/hyalo-angular-stat.mjs +193 -0
  124. package/fesm2022/hyalo-angular-stat.mjs.map +1 -0
  125. package/fesm2022/hyalo-angular-stepper.mjs +254 -0
  126. package/fesm2022/hyalo-angular-stepper.mjs.map +1 -0
  127. package/fesm2022/hyalo-angular-table.mjs +335 -0
  128. package/fesm2022/hyalo-angular-table.mjs.map +1 -0
  129. package/fesm2022/hyalo-angular-tabs.mjs +324 -0
  130. package/fesm2022/hyalo-angular-tabs.mjs.map +1 -0
  131. package/fesm2022/hyalo-angular-theme.mjs +94 -0
  132. package/fesm2022/hyalo-angular-theme.mjs.map +1 -0
  133. package/fesm2022/hyalo-angular-timeline.mjs +157 -0
  134. package/fesm2022/hyalo-angular-timeline.mjs.map +1 -0
  135. package/fesm2022/hyalo-angular-toast.mjs +323 -0
  136. package/fesm2022/hyalo-angular-toast.mjs.map +1 -0
  137. package/fesm2022/hyalo-angular.mjs +2 -0
  138. package/package.json +329 -3
  139. package/styles/hyalo-core.css +25 -0
  140. package/styles/hyalo.css +17 -0
  141. package/styles/overlays/dialog.css +9 -0
  142. package/styles/overlays/popover.css +9 -0
  143. package/styles/overlays/select.css +9 -0
  144. package/styles/overlays/toast.css +8 -0
  145. package/styles/palettes/aurora.css +47 -0
  146. package/styles/palettes/ember.css +47 -0
  147. package/styles/palettes/graphite.css +47 -0
  148. package/styles/palettes/ocean.css +47 -0
  149. package/styles/palettes/orchid.css +47 -0
  150. package/styles/palettes/rose.css +47 -0
  151. package/styles/parts/card.css +49 -0
  152. package/styles/parts/dialog.css +116 -0
  153. package/styles/parts/drawer.css +124 -0
  154. package/styles/parts/field.css +44 -0
  155. package/styles/parts/glass.css +139 -0
  156. package/styles/parts/motion.css +101 -0
  157. package/styles/parts/navbar.css +55 -0
  158. package/styles/parts/popover.css +27 -0
  159. package/styles/parts/presence.css +55 -0
  160. package/styles/parts/reset.css +42 -0
  161. package/styles/parts/select.css +46 -0
  162. package/styles/parts/themes.css +105 -0
  163. package/styles/parts/toast.css +128 -0
  164. package/styles/parts/tokens.css +151 -0
  165. package/styles/parts/typography.css +81 -0
  166. package/types/hyalo-angular-accordion.d.ts +74 -0
  167. package/types/hyalo-angular-alert.d.ts +47 -0
  168. package/types/hyalo-angular-aspect-ratio.d.ts +13 -0
  169. package/types/hyalo-angular-avatar.d.ts +39 -0
  170. package/types/hyalo-angular-badge.d.ts +82 -0
  171. package/types/hyalo-angular-bento.d.ts +25 -0
  172. package/types/hyalo-angular-blocks.d.ts +272 -0
  173. package/types/hyalo-angular-border-beam.d.ts +15 -0
  174. package/types/hyalo-angular-breadcrumb.d.ts +22 -0
  175. package/types/hyalo-angular-button-group.d.ts +19 -0
  176. package/types/hyalo-angular-button.d.ts +89 -0
  177. package/types/hyalo-angular-card.d.ts +61 -0
  178. package/types/hyalo-angular-carousel.d.ts +147 -0
  179. package/types/hyalo-angular-chapter-nav.d.ts +79 -0
  180. package/types/hyalo-angular-chart.d.ts +90 -0
  181. package/types/hyalo-angular-choice.d.ts +259 -0
  182. package/types/hyalo-angular-code-block.d.ts +46 -0
  183. package/types/hyalo-angular-command.d.ts +41 -0
  184. package/types/hyalo-angular-copy.d.ts +39 -0
  185. package/types/hyalo-angular-core.d.ts +210 -0
  186. package/types/hyalo-angular-description-list.d.ts +16 -0
  187. package/types/hyalo-angular-dialog.d.ts +171 -0
  188. package/types/hyalo-angular-divider.d.ts +12 -0
  189. package/types/hyalo-angular-empty-state.d.ts +30 -0
  190. package/types/hyalo-angular-field.d.ts +141 -0
  191. package/types/hyalo-angular-filter.d.ts +122 -0
  192. package/types/hyalo-angular-hotspot.d.ts +70 -0
  193. package/types/hyalo-angular-hover-card.d.ts +47 -0
  194. package/types/hyalo-angular-icon.d.ts +122 -0
  195. package/types/hyalo-angular-image-compare.d.ts +55 -0
  196. package/types/hyalo-angular-interaction.d.ts +131 -0
  197. package/types/hyalo-angular-kbd.d.ts +5 -0
  198. package/types/hyalo-angular-lightbox.d.ts +67 -0
  199. package/types/hyalo-angular-link.d.ts +5 -0
  200. package/types/hyalo-angular-list.d.ts +30 -0
  201. package/types/hyalo-angular-marquee.d.ts +48 -0
  202. package/types/hyalo-angular-menu.d.ts +105 -0
  203. package/types/hyalo-angular-mesh.d.ts +36 -0
  204. package/types/hyalo-angular-motion.d.ts +218 -0
  205. package/types/hyalo-angular-navbar.d.ts +110 -0
  206. package/types/hyalo-angular-navigation-menu.d.ts +47 -0
  207. package/types/hyalo-angular-number-ticker.d.ts +52 -0
  208. package/types/hyalo-angular-overlay.d.ts +40 -0
  209. package/types/hyalo-angular-pagination.d.ts +59 -0
  210. package/types/hyalo-angular-popover.d.ts +152 -0
  211. package/types/hyalo-angular-progress.d.ts +46 -0
  212. package/types/hyalo-angular-progressive-blur.d.ts +14 -0
  213. package/types/hyalo-angular-refraction.d.ts +46 -0
  214. package/types/hyalo-angular-scroll-area.d.ts +18 -0
  215. package/types/hyalo-angular-scroll-to-top.d.ts +31 -0
  216. package/types/hyalo-angular-segmented.d.ts +79 -0
  217. package/types/hyalo-angular-select.d.ts +176 -0
  218. package/types/hyalo-angular-sidebar.d.ts +57 -0
  219. package/types/hyalo-angular-skeleton.d.ts +34 -0
  220. package/types/hyalo-angular-sparkline.d.ts +19 -0
  221. package/types/hyalo-angular-split-text.d.ts +24 -0
  222. package/types/hyalo-angular-stat.d.ts +56 -0
  223. package/types/hyalo-angular-stepper.d.ts +63 -0
  224. package/types/hyalo-angular-table.d.ts +125 -0
  225. package/types/hyalo-angular-tabs.d.ts +102 -0
  226. package/types/hyalo-angular-theme.d.ts +46 -0
  227. package/types/hyalo-angular-timeline.d.ts +36 -0
  228. package/types/hyalo-angular-toast.d.ts +79 -0
  229. package/types/hyalo-angular.d.ts +2 -0
@@ -0,0 +1,620 @@
1
+ import * as i0 from "@angular/core";
2
+ import { DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, Injector, afterNextRender, computed, effect, inject, input, numberAttribute, signal } from "@angular/core";
3
+ import { HY_CONFIG, HyFidelity, ɵinjectIsBrowser, ɵmatchesMedia } from "@hyalo/angular/core";
4
+ const MOTION = {
5
+ settle: {
6
+ duration: .44,
7
+ ease: "power3.out",
8
+ css: "cubic-bezier(0.215, 0.61, 0.355, 1)"
9
+ },
10
+ pop: {
11
+ duration: .5,
12
+ ease: "back.out(1.5)",
13
+ css: "cubic-bezier(0.34, 1.56, 0.64, 1)"
14
+ },
15
+ quick: {
16
+ duration: .22,
17
+ ease: "power2.out",
18
+ css: "cubic-bezier(0.25, 0.46, 0.45, 0.94)"
19
+ },
20
+ scene: {
21
+ duration: .9,
22
+ ease: "expo.out",
23
+ css: "cubic-bezier(0.16, 1, 0.3, 1)"
24
+ }
25
+ };
26
+ var HyMotion = class HyMotion {
27
+ config = inject(HY_CONFIG);
28
+ fidelity = inject(HyFidelity);
29
+ document = inject(DOCUMENT);
30
+ isBrowser = ɵinjectIsBrowser();
31
+ _reduced = signal(false, ...ngDevMode ? [{ debugName: "_reduced" }] : /* istanbul ignore next */ []);
32
+ gsapPromise;
33
+ reduced = this._reduced.asReadonly();
34
+ enabled = computed(() => !this._reduced() && this.fidelity.tier() !== "low", ...ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []);
35
+ constructor() {
36
+ if (!this.isBrowser || typeof matchMedia !== "function") return;
37
+ const query = matchMedia("(prefers-reduced-motion: reduce)");
38
+ const update = () => this._reduced.set(query.matches || this.document.documentElement.getAttribute("data-hy-motion") === "reduced");
39
+ update();
40
+ query.addEventListener("change", update);
41
+ inject(DestroyRef).onDestroy(() => query.removeEventListener("change", update));
42
+ }
43
+ setReduced(reduced) {
44
+ const root = this.document.documentElement;
45
+ if (reduced === null) {
46
+ root.removeAttribute("data-hy-motion");
47
+ this._reduced.set(ɵmatchesMedia("(prefers-reduced-motion: reduce)"));
48
+ return;
49
+ }
50
+ root.setAttribute("data-hy-motion", reduced ? "reduced" : "full");
51
+ this._reduced.set(reduced || ɵmatchesMedia("(prefers-reduced-motion: reduce)"));
52
+ }
53
+ gsap() {
54
+ const loader = this.config.gsap;
55
+ if (!this.isBrowser || !loader) return Promise.resolve(null);
56
+ this.gsapPromise ??= loader().catch(() => null);
57
+ return this.gsapPromise;
58
+ }
59
+ static ɵfac = i0.ɵɵngDeclareFactory({
60
+ minVersion: "12.0.0",
61
+ version: "22.2.3",
62
+ ngImport: i0,
63
+ type: HyMotion,
64
+ deps: [],
65
+ target: i0.ɵɵFactoryTarget.Injectable
66
+ });
67
+ static ɵprov = i0.ɵɵngDeclareInjectable({
68
+ minVersion: "12.0.0",
69
+ version: "22.2.3",
70
+ ngImport: i0,
71
+ type: HyMotion,
72
+ providedIn: "root"
73
+ });
74
+ };
75
+ i0.ɵɵngDeclareClassMetadata({
76
+ minVersion: "12.0.0",
77
+ version: "22.2.3",
78
+ ngImport: i0,
79
+ type: HyMotion,
80
+ decorators: [{
81
+ type: Injectable,
82
+ args: [{ providedIn: "root" }]
83
+ }],
84
+ ctorParameters: () => []
85
+ });
86
+ const SPRINGS = {
87
+ settle: {
88
+ damping: 1,
89
+ response: .4
90
+ },
91
+ momentum: {
92
+ damping: .8,
93
+ response: .3
94
+ }
95
+ };
96
+ const STEP = 1 / 240;
97
+ const MIN_RESPONSE = 1 / 60;
98
+ const MAX_STEPS = 240;
99
+ function assertFinite(value, name) {
100
+ if (!Number.isFinite(value)) throw new RangeError(`HySpring: ${name} must be finite.`);
101
+ }
102
+ const REST_DELTA = .1;
103
+ const REST_VELOCITY = 2;
104
+ var HySpring = class {
105
+ onUpdate;
106
+ value;
107
+ velocity = 0;
108
+ target = 0;
109
+ config = SPRINGS.settle;
110
+ onRest = null;
111
+ frame = 0;
112
+ last = 0;
113
+ constructor(initial, onUpdate) {
114
+ this.onUpdate = onUpdate;
115
+ assertFinite(initial, "initial value");
116
+ this.value = initial;
117
+ }
118
+ get running() {
119
+ return this.frame !== 0;
120
+ }
121
+ to(target, options = {}) {
122
+ const damping = options.damping ?? SPRINGS.settle.damping;
123
+ const response = options.response ?? SPRINGS.settle.response;
124
+ const velocity = options.velocity ?? this.velocity;
125
+ assertFinite(target, "target");
126
+ assertFinite(this.value, "current value");
127
+ assertFinite(velocity, "velocity");
128
+ if (!Number.isFinite(damping) || damping <= 0) throw new RangeError("HySpring: damping must be finite and greater than zero.");
129
+ if (!Number.isFinite(response) || response < MIN_RESPONSE) throw new RangeError("HySpring: response must be finite and at least 1/60 second.");
130
+ this.target = target;
131
+ this.config = {
132
+ damping,
133
+ response
134
+ };
135
+ this.velocity = velocity;
136
+ this.onRest = options.onRest ?? null;
137
+ if (this.frame) return;
138
+ this.last = -1;
139
+ this.frame = requestAnimationFrame(this.tick);
140
+ }
141
+ set(value) {
142
+ assertFinite(value, "value");
143
+ this.stop();
144
+ this.value = value;
145
+ this.velocity = 0;
146
+ this.onUpdate(value);
147
+ }
148
+ stop() {
149
+ cancelAnimationFrame(this.frame);
150
+ this.frame = 0;
151
+ this.onRest = null;
152
+ }
153
+ tick = (now) => {
154
+ const dt = this.last < 0 ? 1 / 60 : Math.max(0, Math.min((now - this.last) / 1e3, 1 / 15));
155
+ this.last = Math.max(now, this.last);
156
+ const stiffness = (2 * Math.PI / this.config.response) ** 2;
157
+ const friction = 4 * Math.PI * this.config.damping / this.config.response;
158
+ const steps = Math.max(1, Math.min(MAX_STEPS, Math.ceil(dt / Math.min(STEP, this.config.response / 60))));
159
+ const h = dt / steps;
160
+ for (let i = 0; i < steps; i++) {
161
+ this.velocity += (-stiffness * (this.value - this.target) - friction * this.velocity) * h;
162
+ this.value += this.velocity * h;
163
+ }
164
+ if (!Number.isFinite(this.value) || !Number.isFinite(this.velocity) || Math.abs(this.velocity) < REST_VELOCITY && Math.abs(this.value - this.target) < REST_DELTA) {
165
+ this.value = this.target;
166
+ this.velocity = 0;
167
+ this.frame = 0;
168
+ const done = this.onRest;
169
+ this.onRest = null;
170
+ this.onUpdate(this.value);
171
+ done?.();
172
+ return;
173
+ }
174
+ this.onUpdate(this.value);
175
+ this.frame = requestAnimationFrame(this.tick);
176
+ };
177
+ };
178
+ function project(velocity, decelerationRate = .998) {
179
+ return velocity / 1e3 * decelerationRate / (1 - decelerationRate);
180
+ }
181
+ function rubberband(overshoot, dimension, constant = .55) {
182
+ if (dimension <= 0) return 0;
183
+ const x = Math.abs(overshoot);
184
+ return Math.sign(overshoot) * (x * dimension * constant) / (dimension + constant * x);
185
+ }
186
+ var HyVelocityTracker = class {
187
+ samples = [];
188
+ add(value, time = performance.now()) {
189
+ this.samples.push({
190
+ t: time,
191
+ v: value
192
+ });
193
+ while (this.samples.length > 2 && time - (this.samples[0]?.t ?? time) > 100) this.samples.shift();
194
+ }
195
+ reset() {
196
+ this.samples = [];
197
+ }
198
+ velocity(now = performance.now()) {
199
+ const recent = this.samples.filter((s) => now - s.t <= 100);
200
+ const first = recent[0];
201
+ const last = recent[recent.length - 1];
202
+ if (!first || !last || last.t === first.t) return 0;
203
+ return (last.v - first.v) / (last.t - first.t) * 1e3;
204
+ }
205
+ };
206
+ function injectHyVisibility() {
207
+ const host = inject(ElementRef).nativeElement;
208
+ const destroy = inject(DestroyRef);
209
+ const visible = signal(false, ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
210
+ afterNextRender(() => {
211
+ const doc = host.ownerDocument;
212
+ let intersects = typeof IntersectionObserver !== "function";
213
+ const update = () => visible.set(intersects && doc.visibilityState !== "hidden");
214
+ const observer = typeof IntersectionObserver === "function" ? new IntersectionObserver((entries) => {
215
+ intersects = entries.some((entry) => entry.isIntersecting);
216
+ update();
217
+ }) : null;
218
+ observer?.observe(host);
219
+ update();
220
+ doc.addEventListener("visibilitychange", update);
221
+ destroy.onDestroy(() => {
222
+ observer?.disconnect();
223
+ doc.removeEventListener("visibilitychange", update);
224
+ });
225
+ });
226
+ return visible.asReadonly();
227
+ }
228
+ var HySceneLight = class HySceneLight {
229
+ document = inject(DOCUMENT);
230
+ motion = inject(HyMotion);
231
+ entries = /* @__PURE__ */ new Map();
232
+ observers = /* @__PURE__ */ new Map();
233
+ resize;
234
+ abort;
235
+ event;
236
+ frame = 0;
237
+ dirty = true;
238
+ constructor() {
239
+ effect(() => {
240
+ if (!this.motion.enabled()) this.reset();
241
+ });
242
+ inject(DestroyRef).onDestroy(() => {
243
+ this.reset();
244
+ this.abort?.abort();
245
+ this.resize?.disconnect();
246
+ this.observers.forEach((o) => o.disconnect());
247
+ });
248
+ }
249
+ register(host, handlers, scene = false, root = null) {
250
+ if (typeof IntersectionObserver !== "function" || !this.document.defaultView?.matchMedia("(hover: hover) and (pointer: fine)").matches) return () => handlers.destroy?.();
251
+ this.start();
252
+ const entry = {
253
+ host,
254
+ handlers,
255
+ scene,
256
+ active: false,
257
+ intersecting: false
258
+ };
259
+ const group = this.entries.get(host) ?? [];
260
+ group.push(entry);
261
+ this.entries.set(host, group);
262
+ let observer = this.observers.get(root);
263
+ if (!observer) {
264
+ observer = new IntersectionObserver((changes) => {
265
+ for (const change of changes) for (const item of this.entries.get(change.target) ?? []) {
266
+ item.intersecting = change.isIntersecting;
267
+ item.rect = void 0;
268
+ if (!item.intersecting) this.leave(item);
269
+ }
270
+ this.schedule();
271
+ }, { root });
272
+ this.observers.set(root, observer);
273
+ }
274
+ observer.observe(host);
275
+ this.resize?.observe(host);
276
+ return () => {
277
+ this.leave(entry);
278
+ handlers.destroy?.();
279
+ const remaining = (this.entries.get(host) ?? []).filter((item) => item !== entry);
280
+ if (remaining.length) this.entries.set(host, remaining);
281
+ else {
282
+ this.entries.delete(host);
283
+ this.observers.forEach((o) => o.unobserve(host));
284
+ this.resize?.unobserve(host);
285
+ }
286
+ if (!this.entries.size) {
287
+ this.reset();
288
+ this.abort?.abort();
289
+ this.abort = void 0;
290
+ this.resize?.disconnect();
291
+ this.resize = void 0;
292
+ this.observers.forEach((o) => o.disconnect());
293
+ this.observers.clear();
294
+ }
295
+ };
296
+ }
297
+ start() {
298
+ if (this.abort) return;
299
+ const options = {
300
+ passive: true,
301
+ capture: true,
302
+ signal: (this.abort = new AbortController()).signal
303
+ };
304
+ this.document.addEventListener("pointermove", (event) => {
305
+ if (event.pointerType === "touch") return;
306
+ this.event = event;
307
+ this.schedule();
308
+ }, options);
309
+ this.document.addEventListener("pointerout", (event) => {
310
+ if (!event.relatedTarget) this.reset();
311
+ }, options);
312
+ this.document.addEventListener("pointercancel", () => this.reset(), options);
313
+ this.document.addEventListener("scroll", () => {
314
+ this.dirty = true;
315
+ this.schedule();
316
+ }, options);
317
+ this.document.defaultView?.addEventListener("resize", () => {
318
+ this.dirty = true;
319
+ this.schedule();
320
+ }, options);
321
+ this.document.addEventListener("visibilitychange", () => {
322
+ if (this.document.hidden) this.reset();
323
+ }, options);
324
+ this.resize = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
325
+ this.dirty = true;
326
+ this.schedule();
327
+ }) : void 0;
328
+ }
329
+ schedule() {
330
+ if (!this.frame && this.event && this.motion.enabled() && !this.document.hidden) this.frame = requestAnimationFrame(() => this.draw());
331
+ }
332
+ draw() {
333
+ this.frame = 0;
334
+ const event = this.event;
335
+ if (!event || !this.motion.enabled() || this.document.hidden) return;
336
+ const work = [];
337
+ const inactive = [];
338
+ for (const group of this.entries.values()) for (const entry of group) {
339
+ if (!entry.intersecting || !entry.host.isConnected || work.length >= 64) {
340
+ inactive.push(entry);
341
+ continue;
342
+ }
343
+ if (this.dirty || !entry.rect) entry.rect = entry.host.getBoundingClientRect();
344
+ const rect = entry.rect;
345
+ const inside = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
346
+ work.push({
347
+ entry,
348
+ rect,
349
+ inside
350
+ });
351
+ }
352
+ this.dirty = false;
353
+ for (const entry of inactive) this.leave(entry);
354
+ for (const { entry, rect, inside } of work) {
355
+ if (!inside && !entry.scene) {
356
+ this.leave(entry);
357
+ continue;
358
+ }
359
+ if (!rect.width || !rect.height) continue;
360
+ if (!entry.active) {
361
+ entry.active = true;
362
+ entry.handlers.enter?.(event, rect);
363
+ }
364
+ entry.handlers.move(event, rect);
365
+ }
366
+ }
367
+ leave(entry) {
368
+ if (entry.active) {
369
+ entry.active = false;
370
+ entry.handlers.leave?.();
371
+ }
372
+ }
373
+ reset() {
374
+ if (this.frame) cancelAnimationFrame(this.frame);
375
+ this.frame = 0;
376
+ this.event = void 0;
377
+ for (const group of this.entries.values()) for (const entry of group) this.leave(entry);
378
+ }
379
+ static ɵfac = i0.ɵɵngDeclareFactory({
380
+ minVersion: "12.0.0",
381
+ version: "22.2.3",
382
+ ngImport: i0,
383
+ type: HySceneLight,
384
+ deps: [],
385
+ target: i0.ɵɵFactoryTarget.Injectable
386
+ });
387
+ static ɵprov = i0.ɵɵngDeclareInjectable({
388
+ minVersion: "12.0.0",
389
+ version: "22.2.3",
390
+ ngImport: i0,
391
+ type: HySceneLight,
392
+ providedIn: "root"
393
+ });
394
+ };
395
+ i0.ɵɵngDeclareClassMetadata({
396
+ minVersion: "12.0.0",
397
+ version: "22.2.3",
398
+ ngImport: i0,
399
+ type: HySceneLight,
400
+ decorators: [{
401
+ type: Injectable,
402
+ args: [{ providedIn: "root" }]
403
+ }],
404
+ ctorParameters: () => []
405
+ });
406
+ var HySceneLightDirective = class HySceneLightDirective {
407
+ constructor() {
408
+ const host = inject(ElementRef).nativeElement;
409
+ const scene = inject(HySceneLight), destroy = inject(DestroyRef);
410
+ afterNextRender(() => {
411
+ let lastX = "", lastY = "";
412
+ const unregister = scene.register(host, {
413
+ move: (event, rect) => {
414
+ const x = `${((event.clientX - rect.left) / rect.width * 100).toFixed(1)}%`;
415
+ const y = `${((event.clientY - rect.top) / rect.height * 100).toFixed(1)}%`;
416
+ if (x !== lastX) host.style.setProperty("--hy-px", lastX = x);
417
+ if (y !== lastY) host.style.setProperty("--hy-py", lastY = y);
418
+ host.style.setProperty("--hy-glow", "0.18");
419
+ },
420
+ leave: () => host.style.setProperty("--hy-glow", "0")
421
+ }, true);
422
+ destroy.onDestroy(unregister);
423
+ });
424
+ }
425
+ static ɵfac = i0.ɵɵngDeclareFactory({
426
+ minVersion: "12.0.0",
427
+ version: "22.2.3",
428
+ ngImport: i0,
429
+ type: HySceneLightDirective,
430
+ deps: [],
431
+ target: i0.ɵɵFactoryTarget.Directive
432
+ });
433
+ static ɵdir = i0.ɵɵngDeclareDirective({
434
+ minVersion: "14.0.0",
435
+ version: "22.2.3",
436
+ type: HySceneLightDirective,
437
+ isStandalone: true,
438
+ selector: "[hySceneLight]",
439
+ ngImport: i0
440
+ });
441
+ };
442
+ i0.ɵɵngDeclareClassMetadata({
443
+ minVersion: "12.0.0",
444
+ version: "22.2.3",
445
+ ngImport: i0,
446
+ type: HySceneLightDirective,
447
+ decorators: [{
448
+ type: Directive,
449
+ args: [{ selector: "[hySceneLight]" }]
450
+ }],
451
+ ctorParameters: () => []
452
+ });
453
+ var HyFlip = class HyFlip {
454
+ host = inject(ElementRef).nativeElement;
455
+ motion = inject(HyMotion);
456
+ injector = inject(Injector);
457
+ destroy = inject(DestroyRef);
458
+ animation;
459
+ generation = 0;
460
+ constructor() {
461
+ effect(() => {
462
+ if (!this.motion.enabled()) this.animation?.cancel();
463
+ });
464
+ this.destroy.onDestroy(() => {
465
+ this.generation++;
466
+ this.animation?.cancel();
467
+ });
468
+ }
469
+ run(change) {
470
+ const generation = ++this.generation;
471
+ this.animation?.cancel();
472
+ const before = this.host.getBoundingClientRect();
473
+ change();
474
+ if (!this.motion.enabled() || typeof this.host.animate !== "function") return;
475
+ afterNextRender(() => {
476
+ if (this.destroy.destroyed || generation !== this.generation || !this.motion.enabled()) return;
477
+ const after = this.host.getBoundingClientRect();
478
+ if (!after.width || !after.height) return;
479
+ this.animation = this.host.animate([{
480
+ transform: `translate(${before.left - after.left}px, ${before.top - after.top}px) scale(${before.width / after.width}, ${before.height / after.height})`,
481
+ transformOrigin: "top left"
482
+ }, {
483
+ transform: "none",
484
+ transformOrigin: "top left"
485
+ }], {
486
+ duration: MOTION.quick.duration * 1e3,
487
+ easing: MOTION.settle.css,
488
+ composite: "add"
489
+ });
490
+ }, { injector: this.injector });
491
+ }
492
+ static ɵfac = i0.ɵɵngDeclareFactory({
493
+ minVersion: "12.0.0",
494
+ version: "22.2.3",
495
+ ngImport: i0,
496
+ type: HyFlip,
497
+ deps: [],
498
+ target: i0.ɵɵFactoryTarget.Directive
499
+ });
500
+ static ɵdir = i0.ɵɵngDeclareDirective({
501
+ minVersion: "14.0.0",
502
+ version: "22.2.3",
503
+ type: HyFlip,
504
+ isStandalone: true,
505
+ selector: "[hyFlip]",
506
+ exportAs: ["hyFlip"],
507
+ ngImport: i0
508
+ });
509
+ };
510
+ i0.ɵɵngDeclareClassMetadata({
511
+ minVersion: "12.0.0",
512
+ version: "22.2.3",
513
+ ngImport: i0,
514
+ type: HyFlip,
515
+ decorators: [{
516
+ type: Directive,
517
+ args: [{
518
+ selector: "[hyFlip]",
519
+ exportAs: "hyFlip"
520
+ }]
521
+ }],
522
+ ctorParameters: () => []
523
+ });
524
+ var HyStagger = class HyStagger {
525
+ hyStagger = input(50, {
526
+ ...ngDevMode ? { debugName: "hyStagger" } : /* istanbul ignore next */ {},
527
+ transform: (value) => numberAttribute(value, 50)
528
+ });
529
+ host = inject(ElementRef).nativeElement;
530
+ visible = injectHyVisibility();
531
+ motion = inject(HyMotion);
532
+ seen = /* @__PURE__ */ new WeakSet();
533
+ animations = /* @__PURE__ */ new Set();
534
+ constructor() {
535
+ const destroy = inject(DestroyRef);
536
+ const animate = () => {
537
+ let index = 0;
538
+ for (const child of Array.from(this.host.children)) {
539
+ if (this.seen.has(child)) continue;
540
+ this.seen.add(child);
541
+ if (!this.motion.enabled() || typeof child.animate !== "function") continue;
542
+ const animation = child.animate([{
543
+ opacity: 0,
544
+ transform: "translateY(8px)"
545
+ }, {
546
+ opacity: 1,
547
+ transform: "none"
548
+ }], {
549
+ duration: MOTION.quick.duration * 1e3,
550
+ delay: Math.min(300, index++ * Math.max(0, Math.min(80, this.hyStagger()))),
551
+ easing: MOTION.settle.css,
552
+ fill: "backwards",
553
+ composite: "add"
554
+ });
555
+ this.animations.add(animation);
556
+ animation.finished.then(() => this.animations.delete(animation), () => this.animations.delete(animation));
557
+ }
558
+ };
559
+ effect(() => {
560
+ if (!this.motion.enabled() || !this.visible()) {
561
+ this.animations.forEach((a) => a.cancel());
562
+ this.animations.clear();
563
+ }
564
+ if (this.visible()) animate();
565
+ });
566
+ afterNextRender(() => {
567
+ const observer = new MutationObserver(() => {
568
+ if (this.visible()) animate();
569
+ });
570
+ observer.observe(this.host, { childList: true });
571
+ destroy.onDestroy(() => observer.disconnect());
572
+ });
573
+ destroy.onDestroy(() => this.animations.forEach((a) => a.cancel()));
574
+ }
575
+ static ɵfac = i0.ɵɵngDeclareFactory({
576
+ minVersion: "12.0.0",
577
+ version: "22.2.3",
578
+ ngImport: i0,
579
+ type: HyStagger,
580
+ deps: [],
581
+ target: i0.ɵɵFactoryTarget.Directive
582
+ });
583
+ static ɵdir = i0.ɵɵngDeclareDirective({
584
+ minVersion: "17.1.0",
585
+ version: "22.2.3",
586
+ type: HyStagger,
587
+ isStandalone: true,
588
+ selector: "[hyStagger]",
589
+ inputs: { hyStagger: {
590
+ classPropertyName: "hyStagger",
591
+ publicName: "hyStagger",
592
+ isSignal: true,
593
+ isRequired: false,
594
+ transformFunction: null
595
+ } },
596
+ ngImport: i0
597
+ });
598
+ };
599
+ i0.ɵɵngDeclareClassMetadata({
600
+ minVersion: "12.0.0",
601
+ version: "22.2.3",
602
+ ngImport: i0,
603
+ type: HyStagger,
604
+ decorators: [{
605
+ type: Directive,
606
+ args: [{ selector: "[hyStagger]" }]
607
+ }],
608
+ ctorParameters: () => [],
609
+ propDecorators: { hyStagger: [{
610
+ type: i0.Input,
611
+ args: [{
612
+ isSignal: true,
613
+ alias: "hyStagger",
614
+ required: false
615
+ }]
616
+ }] }
617
+ });
618
+ export { HyFlip, HyMotion, HySceneLight, HySceneLightDirective, HySpring, HyStagger, HyVelocityTracker, MOTION, SPRINGS, injectHyVisibility, project, rubberband };
619
+
620
+ //# sourceMappingURL=hyalo-angular-motion.mjs.map