@hyalo/angular 0.1.0 → 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 (198) hide show
  1. package/CHANGELOG.md +95 -41
  2. package/README.md +46 -32
  3. package/fesm2022/hyalo-angular-accordion.mjs +6 -6
  4. package/fesm2022/hyalo-angular-accordion.mjs.map +1 -1
  5. package/fesm2022/hyalo-angular-alert.mjs +171 -0
  6. package/fesm2022/hyalo-angular-alert.mjs.map +1 -0
  7. package/fesm2022/hyalo-angular-aspect-ratio.mjs +64 -0
  8. package/fesm2022/hyalo-angular-aspect-ratio.mjs.map +1 -0
  9. package/fesm2022/hyalo-angular-avatar.mjs +169 -0
  10. package/fesm2022/hyalo-angular-avatar.mjs.map +1 -0
  11. package/fesm2022/hyalo-angular-badge.mjs +268 -0
  12. package/fesm2022/hyalo-angular-badge.mjs.map +1 -0
  13. package/fesm2022/hyalo-angular-bento.mjs +132 -0
  14. package/fesm2022/hyalo-angular-bento.mjs.map +1 -0
  15. package/fesm2022/hyalo-angular-blocks.mjs +985 -0
  16. package/fesm2022/hyalo-angular-blocks.mjs.map +1 -0
  17. package/fesm2022/hyalo-angular-border-beam.mjs +73 -0
  18. package/fesm2022/hyalo-angular-border-beam.mjs.map +1 -0
  19. package/fesm2022/hyalo-angular-breadcrumb.mjs +77 -0
  20. package/fesm2022/hyalo-angular-breadcrumb.mjs.map +1 -0
  21. package/fesm2022/hyalo-angular-button-group.mjs +90 -0
  22. package/fesm2022/hyalo-angular-button-group.mjs.map +1 -0
  23. package/fesm2022/hyalo-angular-button.mjs +4 -3
  24. package/fesm2022/hyalo-angular-button.mjs.map +1 -1
  25. package/fesm2022/hyalo-angular-card.mjs +2 -2
  26. package/fesm2022/hyalo-angular-card.mjs.map +1 -1
  27. package/fesm2022/hyalo-angular-carousel.mjs +709 -0
  28. package/fesm2022/hyalo-angular-carousel.mjs.map +1 -0
  29. package/fesm2022/hyalo-angular-chapter-nav.mjs +336 -0
  30. package/fesm2022/hyalo-angular-chapter-nav.mjs.map +1 -0
  31. package/fesm2022/hyalo-angular-chart-engine-DSJop6He.mjs +5 -0
  32. package/fesm2022/hyalo-angular-chart-engine-DSJop6He.mjs.map +1 -0
  33. package/fesm2022/hyalo-angular-chart.mjs +391 -0
  34. package/fesm2022/hyalo-angular-chart.mjs.map +1 -0
  35. package/fesm2022/hyalo-angular-choice.mjs +2 -1
  36. package/fesm2022/hyalo-angular-choice.mjs.map +1 -1
  37. package/fesm2022/hyalo-angular-code-block-highlight-B20d5C76.mjs +40 -0
  38. package/fesm2022/hyalo-angular-code-block-highlight-B20d5C76.mjs.map +1 -0
  39. package/fesm2022/hyalo-angular-code-block.mjs +161 -0
  40. package/fesm2022/hyalo-angular-code-block.mjs.map +1 -0
  41. package/fesm2022/hyalo-angular-command.mjs +193 -0
  42. package/fesm2022/hyalo-angular-command.mjs.map +1 -0
  43. package/fesm2022/hyalo-angular-copy.mjs +138 -0
  44. package/fesm2022/hyalo-angular-copy.mjs.map +1 -0
  45. package/fesm2022/hyalo-angular-core.mjs +424 -0
  46. package/fesm2022/hyalo-angular-core.mjs.map +1 -0
  47. package/fesm2022/hyalo-angular-description-list.mjs +57 -0
  48. package/fesm2022/hyalo-angular-description-list.mjs.map +1 -0
  49. package/fesm2022/hyalo-angular-dialog.mjs +51 -22
  50. package/fesm2022/hyalo-angular-dialog.mjs.map +1 -1
  51. package/fesm2022/hyalo-angular-divider.mjs +66 -0
  52. package/fesm2022/hyalo-angular-divider.mjs.map +1 -0
  53. package/fesm2022/hyalo-angular-empty-state.mjs +123 -0
  54. package/fesm2022/hyalo-angular-empty-state.mjs.map +1 -0
  55. package/fesm2022/hyalo-angular-field.mjs +41 -9
  56. package/fesm2022/hyalo-angular-field.mjs.map +1 -1
  57. package/fesm2022/hyalo-angular-filter.mjs +309 -0
  58. package/fesm2022/hyalo-angular-filter.mjs.map +1 -0
  59. package/fesm2022/hyalo-angular-hotspot.mjs +225 -0
  60. package/fesm2022/hyalo-angular-hotspot.mjs.map +1 -0
  61. package/fesm2022/hyalo-angular-hover-card.mjs +233 -0
  62. package/fesm2022/hyalo-angular-hover-card.mjs.map +1 -0
  63. package/fesm2022/hyalo-angular-icon.mjs +42 -0
  64. package/fesm2022/hyalo-angular-icon.mjs.map +1 -1
  65. package/fesm2022/hyalo-angular-image-compare.mjs +168 -0
  66. package/fesm2022/hyalo-angular-image-compare.mjs.map +1 -0
  67. package/fesm2022/hyalo-angular-interaction.mjs +32 -41
  68. package/fesm2022/hyalo-angular-interaction.mjs.map +1 -1
  69. package/fesm2022/hyalo-angular-kbd.mjs +41 -0
  70. package/fesm2022/hyalo-angular-kbd.mjs.map +1 -0
  71. package/fesm2022/hyalo-angular-lightbox.mjs +228 -0
  72. package/fesm2022/hyalo-angular-lightbox.mjs.map +1 -0
  73. package/fesm2022/hyalo-angular-link.mjs +42 -0
  74. package/fesm2022/hyalo-angular-link.mjs.map +1 -0
  75. package/fesm2022/hyalo-angular-list.mjs +131 -0
  76. package/fesm2022/hyalo-angular-list.mjs.map +1 -0
  77. package/fesm2022/hyalo-angular-marquee.mjs +197 -0
  78. package/fesm2022/hyalo-angular-marquee.mjs.map +1 -0
  79. package/fesm2022/hyalo-angular-menu.mjs +423 -0
  80. package/fesm2022/hyalo-angular-menu.mjs.map +1 -0
  81. package/fesm2022/hyalo-angular-mesh.mjs +126 -0
  82. package/fesm2022/hyalo-angular-mesh.mjs.map +1 -0
  83. package/fesm2022/hyalo-angular-motion.mjs +620 -0
  84. package/fesm2022/hyalo-angular-motion.mjs.map +1 -0
  85. package/fesm2022/hyalo-angular-navbar.mjs +1 -1
  86. package/fesm2022/hyalo-angular-navbar.mjs.map +1 -1
  87. package/fesm2022/hyalo-angular-navigation-menu.mjs +222 -0
  88. package/fesm2022/hyalo-angular-navigation-menu.mjs.map +1 -0
  89. package/fesm2022/hyalo-angular-number-ticker.mjs +174 -0
  90. package/fesm2022/hyalo-angular-number-ticker.mjs.map +1 -0
  91. package/fesm2022/hyalo-angular-overlay.mjs +71 -2
  92. package/fesm2022/hyalo-angular-overlay.mjs.map +1 -1
  93. package/fesm2022/hyalo-angular-pagination.mjs +187 -0
  94. package/fesm2022/hyalo-angular-pagination.mjs.map +1 -0
  95. package/fesm2022/hyalo-angular-popover.mjs +34 -5
  96. package/fesm2022/hyalo-angular-popover.mjs.map +1 -1
  97. package/fesm2022/hyalo-angular-progress.mjs +209 -0
  98. package/fesm2022/hyalo-angular-progress.mjs.map +1 -0
  99. package/fesm2022/hyalo-angular-progressive-blur.mjs +73 -0
  100. package/fesm2022/hyalo-angular-progressive-blur.mjs.map +1 -0
  101. package/fesm2022/hyalo-angular-refraction-renderer-5ZA-kfsA.mjs +186 -0
  102. package/fesm2022/hyalo-angular-refraction-renderer-5ZA-kfsA.mjs.map +1 -0
  103. package/fesm2022/hyalo-angular-refraction.mjs +178 -0
  104. package/fesm2022/hyalo-angular-refraction.mjs.map +1 -0
  105. package/fesm2022/hyalo-angular-scroll-area.mjs +93 -0
  106. package/fesm2022/hyalo-angular-scroll-area.mjs.map +1 -0
  107. package/fesm2022/hyalo-angular-scroll-to-top.mjs +127 -0
  108. package/fesm2022/hyalo-angular-scroll-to-top.mjs.map +1 -0
  109. package/fesm2022/hyalo-angular-segmented.mjs +1 -1
  110. package/fesm2022/hyalo-angular-segmented.mjs.map +1 -1
  111. package/fesm2022/hyalo-angular-select.mjs +112 -15
  112. package/fesm2022/hyalo-angular-select.mjs.map +1 -1
  113. package/fesm2022/hyalo-angular-sidebar.mjs +241 -0
  114. package/fesm2022/hyalo-angular-sidebar.mjs.map +1 -0
  115. package/fesm2022/hyalo-angular-skeleton.mjs +131 -0
  116. package/fesm2022/hyalo-angular-skeleton.mjs.map +1 -0
  117. package/fesm2022/hyalo-angular-sparkline.mjs +110 -0
  118. package/fesm2022/hyalo-angular-sparkline.mjs.map +1 -0
  119. package/fesm2022/hyalo-angular-split-text.mjs +126 -0
  120. package/fesm2022/hyalo-angular-split-text.mjs.map +1 -0
  121. package/fesm2022/hyalo-angular-stat.mjs +193 -0
  122. package/fesm2022/hyalo-angular-stat.mjs.map +1 -0
  123. package/fesm2022/hyalo-angular-stepper.mjs +254 -0
  124. package/fesm2022/hyalo-angular-stepper.mjs.map +1 -0
  125. package/fesm2022/hyalo-angular-table.mjs +335 -0
  126. package/fesm2022/hyalo-angular-table.mjs.map +1 -0
  127. package/fesm2022/hyalo-angular-tabs.mjs +1 -1
  128. package/fesm2022/hyalo-angular-tabs.mjs.map +1 -1
  129. package/fesm2022/hyalo-angular-theme.mjs +1 -1
  130. package/fesm2022/hyalo-angular-theme.mjs.map +1 -1
  131. package/fesm2022/hyalo-angular-timeline.mjs +157 -0
  132. package/fesm2022/hyalo-angular-timeline.mjs.map +1 -0
  133. package/fesm2022/hyalo-angular-toast.mjs +2 -1
  134. package/fesm2022/hyalo-angular-toast.mjs.map +1 -1
  135. package/fesm2022/hyalo-angular.mjs +2 -473
  136. package/package.json +198 -2
  137. package/styles/parts/field.css +44 -36
  138. package/styles/parts/glass.css +2 -0
  139. package/styles/parts/motion.css +19 -0
  140. package/styles/parts/typography.css +17 -0
  141. package/types/hyalo-angular-accordion.d.ts +1 -1
  142. package/types/hyalo-angular-alert.d.ts +47 -0
  143. package/types/hyalo-angular-aspect-ratio.d.ts +13 -0
  144. package/types/hyalo-angular-avatar.d.ts +39 -0
  145. package/types/hyalo-angular-badge.d.ts +82 -0
  146. package/types/hyalo-angular-bento.d.ts +25 -0
  147. package/types/hyalo-angular-blocks.d.ts +272 -0
  148. package/types/hyalo-angular-border-beam.d.ts +15 -0
  149. package/types/hyalo-angular-breadcrumb.d.ts +22 -0
  150. package/types/hyalo-angular-button-group.d.ts +19 -0
  151. package/types/hyalo-angular-button.d.ts +4 -3
  152. package/types/hyalo-angular-card.d.ts +1 -1
  153. package/types/hyalo-angular-carousel.d.ts +147 -0
  154. package/types/hyalo-angular-chapter-nav.d.ts +79 -0
  155. package/types/hyalo-angular-chart.d.ts +90 -0
  156. package/types/hyalo-angular-code-block.d.ts +46 -0
  157. package/types/hyalo-angular-command.d.ts +41 -0
  158. package/types/hyalo-angular-copy.d.ts +39 -0
  159. package/types/hyalo-angular-core.d.ts +210 -0
  160. package/types/hyalo-angular-description-list.d.ts +16 -0
  161. package/types/hyalo-angular-dialog.d.ts +2 -1
  162. package/types/hyalo-angular-divider.d.ts +12 -0
  163. package/types/hyalo-angular-empty-state.d.ts +30 -0
  164. package/types/hyalo-angular-field.d.ts +10 -4
  165. package/types/hyalo-angular-filter.d.ts +122 -0
  166. package/types/hyalo-angular-hotspot.d.ts +70 -0
  167. package/types/hyalo-angular-hover-card.d.ts +47 -0
  168. package/types/hyalo-angular-image-compare.d.ts +55 -0
  169. package/types/hyalo-angular-kbd.d.ts +5 -0
  170. package/types/hyalo-angular-lightbox.d.ts +67 -0
  171. package/types/hyalo-angular-link.d.ts +5 -0
  172. package/types/hyalo-angular-list.d.ts +30 -0
  173. package/types/hyalo-angular-marquee.d.ts +48 -0
  174. package/types/hyalo-angular-menu.d.ts +105 -0
  175. package/types/hyalo-angular-mesh.d.ts +36 -0
  176. package/types/hyalo-angular-motion.d.ts +218 -0
  177. package/types/hyalo-angular-navigation-menu.d.ts +47 -0
  178. package/types/hyalo-angular-number-ticker.d.ts +52 -0
  179. package/types/hyalo-angular-overlay.d.ts +9 -0
  180. package/types/hyalo-angular-pagination.d.ts +59 -0
  181. package/types/hyalo-angular-popover.d.ts +10 -0
  182. package/types/hyalo-angular-progress.d.ts +46 -0
  183. package/types/hyalo-angular-progressive-blur.d.ts +14 -0
  184. package/types/hyalo-angular-refraction.d.ts +46 -0
  185. package/types/hyalo-angular-scroll-area.d.ts +18 -0
  186. package/types/hyalo-angular-scroll-to-top.d.ts +31 -0
  187. package/types/hyalo-angular-segmented.d.ts +1 -1
  188. package/types/hyalo-angular-select.d.ts +49 -3
  189. package/types/hyalo-angular-sidebar.d.ts +57 -0
  190. package/types/hyalo-angular-skeleton.d.ts +34 -0
  191. package/types/hyalo-angular-sparkline.d.ts +19 -0
  192. package/types/hyalo-angular-split-text.d.ts +24 -0
  193. package/types/hyalo-angular-stat.d.ts +56 -0
  194. package/types/hyalo-angular-stepper.d.ts +63 -0
  195. package/types/hyalo-angular-table.d.ts +125 -0
  196. package/types/hyalo-angular-timeline.d.ts +36 -0
  197. package/types/hyalo-angular.d.ts +2 -345
  198. package/fesm2022/hyalo-angular.mjs.map +0 -1
@@ -1,473 +1,2 @@
1
- import * as i0 from "@angular/core";
2
- import { DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, PLATFORM_ID, afterNextRender, afterRenderEffect, computed, effect, inject, input, signal } from "@angular/core";
3
- import { FocusMonitor, _IdGenerator } from "@angular/cdk/a11y";
4
- import { isPlatformBrowser } from "@angular/common";
5
- const DEFAULTS = {
6
- material: "frosted",
7
- size: "md",
8
- tone: "primary"
9
- };
10
- const HY_CONFIG = new InjectionToken("HY_CONFIG", {
11
- providedIn: "root",
12
- factory: () => DEFAULTS
13
- });
14
- function provideHyalo(config = {}) {
15
- return {
16
- provide: HY_CONFIG,
17
- useFactory: () => {
18
- return {
19
- ...inject(HY_CONFIG, {
20
- skipSelf: true,
21
- optional: true
22
- }) ?? DEFAULTS,
23
- ...config
24
- };
25
- }
26
- };
27
- }
28
- function injectId(prefix) {
29
- return inject(_IdGenerator).getId(`hy-${prefix}-`);
30
- }
31
- function injectIsBrowser() {
32
- return isPlatformBrowser(inject(PLATFORM_ID));
33
- }
34
- function matchesMedia(query) {
35
- return typeof matchMedia === "function" && matchMedia(query).matches;
36
- }
37
- function detectFidelity(nav) {
38
- if (nav.connection?.saveData) return "low";
39
- const memory = nav.deviceMemory ?? 8;
40
- const cores = nav.hardwareConcurrency ?? 8;
41
- if (memory <= 2 || cores <= 2) return "low";
42
- if (memory <= 4 || cores <= 4 || matchesMedia("(pointer: coarse)")) return "medium";
43
- return "high";
44
- }
45
- var HyFidelity = class HyFidelity {
46
- config = inject(HY_CONFIG);
47
- document = inject(DOCUMENT);
48
- _tier = signal(this.config.fidelity ?? "medium", ...ngDevMode ? [{ debugName: "_tier" }] : /* istanbul ignore next */ []);
49
- overridden = !!this.config.fidelity;
50
- tier = this._tier.asReadonly();
51
- constructor() {
52
- if (!injectIsBrowser()) return;
53
- afterNextRender(() => {
54
- if (!this.overridden) this._tier.set(detectFidelity(navigator));
55
- });
56
- effect(() => this.document.documentElement.setAttribute("data-hy-fidelity", this._tier()));
57
- }
58
- setTier(tier) {
59
- this.overridden = true;
60
- this._tier.set(tier);
61
- }
62
- static ɵfac = i0.ɵɵngDeclareFactory({
63
- minVersion: "12.0.0",
64
- version: "22.2.3",
65
- ngImport: i0,
66
- type: HyFidelity,
67
- deps: [],
68
- target: i0.ɵɵFactoryTarget.Injectable
69
- });
70
- static ɵprov = i0.ɵɵngDeclareInjectable({
71
- minVersion: "12.0.0",
72
- version: "22.2.3",
73
- ngImport: i0,
74
- type: HyFidelity,
75
- providedIn: "root"
76
- });
77
- };
78
- i0.ɵɵngDeclareClassMetadata({
79
- minVersion: "12.0.0",
80
- version: "22.2.3",
81
- ngImport: i0,
82
- type: HyFidelity,
83
- decorators: [{
84
- type: Injectable,
85
- args: [{ providedIn: "root" }]
86
- }],
87
- ctorParameters: () => []
88
- });
89
- const MOTION = {
90
- settle: {
91
- duration: .44,
92
- ease: "power3.out",
93
- css: "cubic-bezier(0.215, 0.61, 0.355, 1)"
94
- },
95
- pop: {
96
- duration: .5,
97
- ease: "back.out(1.5)",
98
- css: "cubic-bezier(0.34, 1.56, 0.64, 1)"
99
- },
100
- quick: {
101
- duration: .22,
102
- ease: "power2.out",
103
- css: "cubic-bezier(0.25, 0.46, 0.45, 0.94)"
104
- },
105
- scene: {
106
- duration: .9,
107
- ease: "expo.out",
108
- css: "cubic-bezier(0.16, 1, 0.3, 1)"
109
- }
110
- };
111
- var HyMotion = class HyMotion {
112
- config = inject(HY_CONFIG);
113
- fidelity = inject(HyFidelity);
114
- document = inject(DOCUMENT);
115
- isBrowser = injectIsBrowser();
116
- _reduced = signal(false, ...ngDevMode ? [{ debugName: "_reduced" }] : /* istanbul ignore next */ []);
117
- gsapPromise;
118
- reduced = this._reduced.asReadonly();
119
- enabled = computed(() => !this._reduced() && this.fidelity.tier() !== "low", ...ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []);
120
- constructor() {
121
- if (!this.isBrowser || typeof matchMedia !== "function") return;
122
- const query = matchMedia("(prefers-reduced-motion: reduce)");
123
- const forced = this.document.documentElement.getAttribute("data-hy-motion");
124
- this._reduced.set(forced ? forced === "reduced" : query.matches);
125
- query.addEventListener("change", (event) => {
126
- if (!this.document.documentElement.hasAttribute("data-hy-motion")) this._reduced.set(event.matches);
127
- });
128
- }
129
- setReduced(reduced) {
130
- const root = this.document.documentElement;
131
- if (reduced === null) {
132
- root.removeAttribute("data-hy-motion");
133
- this._reduced.set(matchesMedia("(prefers-reduced-motion: reduce)"));
134
- return;
135
- }
136
- root.setAttribute("data-hy-motion", reduced ? "reduced" : "full");
137
- this._reduced.set(reduced);
138
- }
139
- gsap() {
140
- const loader = this.config.gsap;
141
- if (!this.isBrowser || !loader) return Promise.resolve(null);
142
- this.gsapPromise ??= loader().catch(() => null);
143
- return this.gsapPromise;
144
- }
145
- static ɵfac = i0.ɵɵngDeclareFactory({
146
- minVersion: "12.0.0",
147
- version: "22.2.3",
148
- ngImport: i0,
149
- type: HyMotion,
150
- deps: [],
151
- target: i0.ɵɵFactoryTarget.Injectable
152
- });
153
- static ɵprov = i0.ɵɵngDeclareInjectable({
154
- minVersion: "12.0.0",
155
- version: "22.2.3",
156
- ngImport: i0,
157
- type: HyMotion,
158
- providedIn: "root"
159
- });
160
- };
161
- i0.ɵɵngDeclareClassMetadata({
162
- minVersion: "12.0.0",
163
- version: "22.2.3",
164
- ngImport: i0,
165
- type: HyMotion,
166
- decorators: [{
167
- type: Injectable,
168
- args: [{ providedIn: "root" }]
169
- }],
170
- ctorParameters: () => []
171
- });
172
- const SPRINGS = {
173
- settle: {
174
- damping: 1,
175
- response: .4
176
- },
177
- momentum: {
178
- damping: .8,
179
- response: .3
180
- }
181
- };
182
- const STEP = 1 / 240;
183
- const REST_DELTA = .1;
184
- const REST_VELOCITY = 2;
185
- var HySpring = class {
186
- onUpdate;
187
- value;
188
- velocity = 0;
189
- target = 0;
190
- config = SPRINGS.settle;
191
- onRest = null;
192
- frame = 0;
193
- last = 0;
194
- constructor(initial, onUpdate) {
195
- this.onUpdate = onUpdate;
196
- this.value = initial;
197
- }
198
- get running() {
199
- return this.frame !== 0;
200
- }
201
- to(target, options = {}) {
202
- this.target = target;
203
- this.config = {
204
- damping: options.damping ?? SPRINGS.settle.damping,
205
- response: options.response ?? SPRINGS.settle.response
206
- };
207
- if (options.velocity !== void 0) this.velocity = options.velocity;
208
- this.onRest = options.onRest ?? null;
209
- if (this.frame) return;
210
- this.last = performance.now();
211
- this.frame = requestAnimationFrame(this.tick);
212
- }
213
- set(value) {
214
- this.stop();
215
- this.value = value;
216
- this.velocity = 0;
217
- this.onUpdate(value);
218
- }
219
- stop() {
220
- cancelAnimationFrame(this.frame);
221
- this.frame = 0;
222
- this.onRest = null;
223
- }
224
- tick = (now) => {
225
- const dt = Math.max(0, Math.min((now - this.last) / 1e3, 1 / 15));
226
- this.last = Math.max(now, this.last);
227
- const stiffness = (2 * Math.PI / this.config.response) ** 2;
228
- const friction = 4 * Math.PI * this.config.damping / this.config.response;
229
- const steps = Math.ceil(dt / Math.min(STEP, this.config.response / 60));
230
- const h = dt / steps;
231
- for (let i = 0; i < steps; i++) {
232
- this.velocity += (-stiffness * (this.value - this.target) - friction * this.velocity) * h;
233
- this.value += this.velocity * h;
234
- }
235
- if (Math.abs(this.velocity) < REST_VELOCITY && Math.abs(this.value - this.target) < REST_DELTA) {
236
- this.value = this.target;
237
- this.velocity = 0;
238
- this.frame = 0;
239
- const done = this.onRest;
240
- this.onRest = null;
241
- this.onUpdate(this.value);
242
- done?.();
243
- return;
244
- }
245
- this.onUpdate(this.value);
246
- this.frame = requestAnimationFrame(this.tick);
247
- };
248
- };
249
- function project(velocity, decelerationRate = .998) {
250
- return velocity / 1e3 * decelerationRate / (1 - decelerationRate);
251
- }
252
- function rubberband(overshoot, dimension, constant = .55) {
253
- if (dimension <= 0) return 0;
254
- const x = Math.abs(overshoot);
255
- return Math.sign(overshoot) * (x * dimension * constant) / (dimension + constant * x);
256
- }
257
- var HyVelocityTracker = class {
258
- samples = [];
259
- add(value, time = performance.now()) {
260
- this.samples.push({
261
- t: time,
262
- v: value
263
- });
264
- while (this.samples.length > 2 && time - (this.samples[0]?.t ?? time) > 100) this.samples.shift();
265
- }
266
- reset() {
267
- this.samples = [];
268
- }
269
- velocity(now = performance.now()) {
270
- const recent = this.samples.filter((s) => now - s.t <= 100);
271
- const first = recent[0];
272
- const last = recent[recent.length - 1];
273
- if (!first || !last || last.t === first.t) return 0;
274
- return (last.v - first.v) / (last.t - first.t) * 1e3;
275
- }
276
- };
277
- var HyMaterialDirective = class HyMaterialDirective {
278
- config = inject(HY_CONFIG);
279
- fidelity = inject(HyFidelity);
280
- material = input(void 0, {
281
- ...ngDevMode ? { debugName: "material" } : /* istanbul ignore next */ {},
282
- alias: "hyMaterial"
283
- });
284
- thickness = input("regular", ...ngDevMode ? [{ debugName: "thickness" }] : /* istanbul ignore next */ []);
285
- resolved = computed(() => {
286
- if (this.fidelity.tier() === "low") return "solid";
287
- return this.material() || this.config.material;
288
- }, ...ngDevMode ? [{ debugName: "resolved" }] : /* istanbul ignore next */ []);
289
- static ɵfac = i0.ɵɵngDeclareFactory({
290
- minVersion: "12.0.0",
291
- version: "22.2.3",
292
- ngImport: i0,
293
- type: HyMaterialDirective,
294
- deps: [],
295
- target: i0.ɵɵFactoryTarget.Directive
296
- });
297
- static ɵdir = i0.ɵɵngDeclareDirective({
298
- minVersion: "17.1.0",
299
- version: "22.2.3",
300
- type: HyMaterialDirective,
301
- isStandalone: true,
302
- selector: "[hyMaterial]",
303
- inputs: {
304
- material: {
305
- classPropertyName: "material",
306
- publicName: "hyMaterial",
307
- isSignal: true,
308
- isRequired: false,
309
- transformFunction: null
310
- },
311
- thickness: {
312
- classPropertyName: "thickness",
313
- publicName: "thickness",
314
- isSignal: true,
315
- isRequired: false,
316
- transformFunction: null
317
- }
318
- },
319
- host: {
320
- properties: {
321
- "attr.data-material": "resolved()",
322
- "attr.data-thickness": "thickness() === \"regular\" ? null : thickness()"
323
- },
324
- classAttribute: "hy-glass"
325
- },
326
- ngImport: i0
327
- });
328
- };
329
- i0.ɵɵngDeclareClassMetadata({
330
- minVersion: "12.0.0",
331
- version: "22.2.3",
332
- ngImport: i0,
333
- type: HyMaterialDirective,
334
- decorators: [{
335
- type: Directive,
336
- args: [{
337
- selector: "[hyMaterial]",
338
- host: {
339
- class: "hy-glass",
340
- "[attr.data-material]": "resolved()",
341
- "[attr.data-thickness]": "thickness() === \"regular\" ? null : thickness()"
342
- }
343
- }]
344
- }],
345
- propDecorators: {
346
- material: [{
347
- type: i0.Input,
348
- args: [{
349
- isSignal: true,
350
- alias: "hyMaterial",
351
- required: false
352
- }]
353
- }],
354
- thickness: [{
355
- type: i0.Input,
356
- args: [{
357
- isSignal: true,
358
- alias: "thickness",
359
- required: false
360
- }]
361
- }]
362
- }
363
- });
364
- var HyInteractive = class HyInteractive {
365
- host = inject(ElementRef);
366
- focusMonitor = inject(FocusMonitor);
367
- hovered = signal(false, ...ngDevMode ? [{ debugName: "hovered" }] : /* istanbul ignore next */ []);
368
- pressed = signal(false, ...ngDevMode ? [{ debugName: "pressed" }] : /* istanbul ignore next */ []);
369
- focusVisible = signal(false, ...ngDevMode ? [{ debugName: "focusVisible" }] : /* istanbul ignore next */ []);
370
- constructor() {
371
- afterNextRender(() => {
372
- this.focusMonitor.monitor(this.host).subscribe((origin) => {
373
- this.focusVisible.set(origin === "keyboard");
374
- });
375
- });
376
- inject(DestroyRef).onDestroy(() => this.focusMonitor.stopMonitoring(this.host));
377
- }
378
- onEnter(event) {
379
- if (event.pointerType !== "touch") this.hovered.set(true);
380
- }
381
- static ɵfac = i0.ɵɵngDeclareFactory({
382
- minVersion: "12.0.0",
383
- version: "22.2.3",
384
- ngImport: i0,
385
- type: HyInteractive,
386
- deps: [],
387
- target: i0.ɵɵFactoryTarget.Directive
388
- });
389
- static ɵdir = i0.ɵɵngDeclareDirective({
390
- minVersion: "14.0.0",
391
- version: "22.2.3",
392
- type: HyInteractive,
393
- isStandalone: true,
394
- selector: "[hyInteractive]",
395
- host: {
396
- listeners: {
397
- "pointerenter": "onEnter($event)",
398
- "pointerleave": "hovered.set(false); pressed.set(false)",
399
- "pointerdown": "pressed.set(true)",
400
- "pointerup": "pressed.set(false)",
401
- "pointercancel": "pressed.set(false)"
402
- },
403
- properties: {
404
- "attr.data-hover": "hovered() || null",
405
- "attr.data-press": "pressed() || null",
406
- "attr.data-focus-visible": "focusVisible() || null"
407
- }
408
- },
409
- ngImport: i0
410
- });
411
- };
412
- i0.ɵɵngDeclareClassMetadata({
413
- minVersion: "12.0.0",
414
- version: "22.2.3",
415
- ngImport: i0,
416
- type: HyInteractive,
417
- decorators: [{
418
- type: Directive,
419
- args: [{
420
- selector: "[hyInteractive]",
421
- host: {
422
- "[attr.data-hover]": "hovered() || null",
423
- "[attr.data-press]": "pressed() || null",
424
- "[attr.data-focus-visible]": "focusVisible() || null",
425
- "(pointerenter)": "onEnter($event)",
426
- "(pointerleave)": "hovered.set(false); pressed.set(false)",
427
- "(pointerdown)": "pressed.set(true)",
428
- "(pointerup)": "pressed.set(false)",
429
- "(pointercancel)": "pressed.set(false)"
430
- }
431
- }]
432
- }],
433
- ctorParameters: () => []
434
- });
435
- function trackIndicator(container, selected) {
436
- const ready = signal(false, ...ngDevMode ? [{ debugName: "ready" }] : /* istanbul ignore next */ []);
437
- const size = signal(0, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
438
- const destroyRef = inject(DestroyRef);
439
- afterNextRender(() => {
440
- const row = container()?.nativeElement;
441
- if (!row || typeof ResizeObserver !== "function") return;
442
- const observer = new ResizeObserver(() => size.update((v) => v + 1));
443
- observer.observe(row);
444
- destroyRef.onDestroy(() => observer.disconnect());
445
- });
446
- afterRenderEffect({
447
- earlyRead: () => {
448
- size();
449
- const row = container()?.nativeElement;
450
- const item = selected();
451
- if (!row || !item) return null;
452
- const rowRect = row.getBoundingClientRect();
453
- const rect = item.getBoundingClientRect();
454
- const scale = row.offsetWidth ? rowRect.width / row.offsetWidth : 1;
455
- return {
456
- row,
457
- x: (rect.left - rowRect.left) / scale + row.scrollLeft,
458
- size: rect.width / scale
459
- };
460
- },
461
- write: (measured) => {
462
- const m = measured();
463
- if (!m) return;
464
- m.row.style.setProperty("--hy-ind-x", `${m.x}px`);
465
- m.row.style.setProperty("--hy-ind-size", `${m.size}px`);
466
- if (!ready()) requestAnimationFrame(() => ready.set(true));
467
- }
468
- });
469
- return ready.asReadonly();
470
- }
471
- export { HY_CONFIG, HyFidelity, HyInteractive, HyMaterialDirective, HyMotion, HySpring, HyVelocityTracker, MOTION, SPRINGS, detectFidelity, injectId, project, provideHyalo, rubberband, injectIsBrowser as ɵinjectIsBrowser, matchesMedia as ɵmatchesMedia, trackIndicator as ɵtrackIndicator };
472
-
473
- //# sourceMappingURL=hyalo-angular.mjs.map
1
+ export * from "@hyalo/angular/core";
2
+ export * from "@hyalo/angular/motion";