@cute-widgets/base 20.0.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 (183) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/LICENSE.md +191 -0
  3. package/README.md +190 -0
  4. package/abstract/index.d.ts +327 -0
  5. package/alert/index.d.ts +68 -0
  6. package/autocomplete/index.d.ts +442 -0
  7. package/badge/index.d.ts +26 -0
  8. package/bottom-sheet/index.d.ts +231 -0
  9. package/button/index.d.ts +182 -0
  10. package/button-toggle/index.d.ts +225 -0
  11. package/card/index.d.ts +163 -0
  12. package/checkbox/index.d.ts +174 -0
  13. package/chips/index.d.ts +963 -0
  14. package/collapse/index.d.ts +97 -0
  15. package/core/animation/index.d.ts +43 -0
  16. package/core/datetime/index.d.ts +404 -0
  17. package/core/directives/index.d.ts +168 -0
  18. package/core/error/index.d.ts +74 -0
  19. package/core/index.d.ts +1039 -0
  20. package/core/interfaces/index.d.ts +114 -0
  21. package/core/layout/index.d.ts +53 -0
  22. package/core/line/index.d.ts +37 -0
  23. package/core/nav/index.d.ts +321 -0
  24. package/core/observers/index.d.ts +124 -0
  25. package/core/option/index.d.ts +185 -0
  26. package/core/pipes/index.d.ts +53 -0
  27. package/core/ripple/index.d.ts +66 -0
  28. package/core/testing/index.d.ts +154 -0
  29. package/core/theming/index.d.ts +118 -0
  30. package/core/types/index.d.ts +53 -0
  31. package/core/utils/index.d.ts +129 -0
  32. package/cute-widgets-base-20.0.1.tgz +0 -0
  33. package/datepicker/index.d.ts +1817 -0
  34. package/dialog/index.d.ts +484 -0
  35. package/divider/index.d.ts +24 -0
  36. package/expansion/README.md +8 -0
  37. package/expansion/index.d.ts +308 -0
  38. package/fesm2022/cute-widgets-base-abstract.mjs +547 -0
  39. package/fesm2022/cute-widgets-base-abstract.mjs.map +1 -0
  40. package/fesm2022/cute-widgets-base-alert.mjs +198 -0
  41. package/fesm2022/cute-widgets-base-alert.mjs.map +1 -0
  42. package/fesm2022/cute-widgets-base-autocomplete.mjs +1217 -0
  43. package/fesm2022/cute-widgets-base-autocomplete.mjs.map +1 -0
  44. package/fesm2022/cute-widgets-base-badge.mjs +75 -0
  45. package/fesm2022/cute-widgets-base-badge.mjs.map +1 -0
  46. package/fesm2022/cute-widgets-base-bottom-sheet.mjs +416 -0
  47. package/fesm2022/cute-widgets-base-bottom-sheet.mjs.map +1 -0
  48. package/fesm2022/cute-widgets-base-button-toggle.mjs +640 -0
  49. package/fesm2022/cute-widgets-base-button-toggle.mjs.map +1 -0
  50. package/fesm2022/cute-widgets-base-button.mjs +546 -0
  51. package/fesm2022/cute-widgets-base-button.mjs.map +1 -0
  52. package/fesm2022/cute-widgets-base-card.mjs +471 -0
  53. package/fesm2022/cute-widgets-base-card.mjs.map +1 -0
  54. package/fesm2022/cute-widgets-base-checkbox.mjs +390 -0
  55. package/fesm2022/cute-widgets-base-checkbox.mjs.map +1 -0
  56. package/fesm2022/cute-widgets-base-chips.mjs +2360 -0
  57. package/fesm2022/cute-widgets-base-chips.mjs.map +1 -0
  58. package/fesm2022/cute-widgets-base-collapse.mjs +259 -0
  59. package/fesm2022/cute-widgets-base-collapse.mjs.map +1 -0
  60. package/fesm2022/cute-widgets-base-core-animation.mjs +53 -0
  61. package/fesm2022/cute-widgets-base-core-animation.mjs.map +1 -0
  62. package/fesm2022/cute-widgets-base-core-datetime.mjs +568 -0
  63. package/fesm2022/cute-widgets-base-core-datetime.mjs.map +1 -0
  64. package/fesm2022/cute-widgets-base-core-directives.mjs +404 -0
  65. package/fesm2022/cute-widgets-base-core-directives.mjs.map +1 -0
  66. package/fesm2022/cute-widgets-base-core-error.mjs +105 -0
  67. package/fesm2022/cute-widgets-base-core-error.mjs.map +1 -0
  68. package/fesm2022/cute-widgets-base-core-interfaces.mjs +22 -0
  69. package/fesm2022/cute-widgets-base-core-interfaces.mjs.map +1 -0
  70. package/fesm2022/cute-widgets-base-core-layout.mjs +74 -0
  71. package/fesm2022/cute-widgets-base-core-layout.mjs.map +1 -0
  72. package/fesm2022/cute-widgets-base-core-line.mjs +87 -0
  73. package/fesm2022/cute-widgets-base-core-line.mjs.map +1 -0
  74. package/fesm2022/cute-widgets-base-core-nav.mjs +863 -0
  75. package/fesm2022/cute-widgets-base-core-nav.mjs.map +1 -0
  76. package/fesm2022/cute-widgets-base-core-observers.mjs +304 -0
  77. package/fesm2022/cute-widgets-base-core-observers.mjs.map +1 -0
  78. package/fesm2022/cute-widgets-base-core-option.mjs +373 -0
  79. package/fesm2022/cute-widgets-base-core-option.mjs.map +1 -0
  80. package/fesm2022/cute-widgets-base-core-pipes.mjs +97 -0
  81. package/fesm2022/cute-widgets-base-core-pipes.mjs.map +1 -0
  82. package/fesm2022/cute-widgets-base-core-ripple.mjs +172 -0
  83. package/fesm2022/cute-widgets-base-core-ripple.mjs.map +1 -0
  84. package/fesm2022/cute-widgets-base-core-testing.mjs +210 -0
  85. package/fesm2022/cute-widgets-base-core-testing.mjs.map +1 -0
  86. package/fesm2022/cute-widgets-base-core-theming.mjs +314 -0
  87. package/fesm2022/cute-widgets-base-core-theming.mjs.map +1 -0
  88. package/fesm2022/cute-widgets-base-core-types.mjs +22 -0
  89. package/fesm2022/cute-widgets-base-core-types.mjs.map +1 -0
  90. package/fesm2022/cute-widgets-base-core-utils.mjs +257 -0
  91. package/fesm2022/cute-widgets-base-core-utils.mjs.map +1 -0
  92. package/fesm2022/cute-widgets-base-core.mjs +1600 -0
  93. package/fesm2022/cute-widgets-base-core.mjs.map +1 -0
  94. package/fesm2022/cute-widgets-base-datepicker.mjs +4827 -0
  95. package/fesm2022/cute-widgets-base-datepicker.mjs.map +1 -0
  96. package/fesm2022/cute-widgets-base-dialog.mjs +1046 -0
  97. package/fesm2022/cute-widgets-base-dialog.mjs.map +1 -0
  98. package/fesm2022/cute-widgets-base-divider.mjs +86 -0
  99. package/fesm2022/cute-widgets-base-divider.mjs.map +1 -0
  100. package/fesm2022/cute-widgets-base-expansion.mjs +623 -0
  101. package/fesm2022/cute-widgets-base-expansion.mjs.map +1 -0
  102. package/fesm2022/cute-widgets-base-form-field.mjs +969 -0
  103. package/fesm2022/cute-widgets-base-form-field.mjs.map +1 -0
  104. package/fesm2022/cute-widgets-base-grid-list.mjs +715 -0
  105. package/fesm2022/cute-widgets-base-grid-list.mjs.map +1 -0
  106. package/fesm2022/cute-widgets-base-icon.mjs +1105 -0
  107. package/fesm2022/cute-widgets-base-icon.mjs.map +1 -0
  108. package/fesm2022/cute-widgets-base-input.mjs +726 -0
  109. package/fesm2022/cute-widgets-base-input.mjs.map +1 -0
  110. package/fesm2022/cute-widgets-base-layout-container.mjs +95 -0
  111. package/fesm2022/cute-widgets-base-layout-container.mjs.map +1 -0
  112. package/fesm2022/cute-widgets-base-layout-stack.mjs +166 -0
  113. package/fesm2022/cute-widgets-base-layout-stack.mjs.map +1 -0
  114. package/fesm2022/cute-widgets-base-layout.mjs +250 -0
  115. package/fesm2022/cute-widgets-base-layout.mjs.map +1 -0
  116. package/fesm2022/cute-widgets-base-list.mjs +1557 -0
  117. package/fesm2022/cute-widgets-base-list.mjs.map +1 -0
  118. package/fesm2022/cute-widgets-base-menu.mjs +1283 -0
  119. package/fesm2022/cute-widgets-base-menu.mjs.map +1 -0
  120. package/fesm2022/cute-widgets-base-navbar.mjs +359 -0
  121. package/fesm2022/cute-widgets-base-navbar.mjs.map +1 -0
  122. package/fesm2022/cute-widgets-base-paginator.mjs +485 -0
  123. package/fesm2022/cute-widgets-base-paginator.mjs.map +1 -0
  124. package/fesm2022/cute-widgets-base-progress.mjs +321 -0
  125. package/fesm2022/cute-widgets-base-progress.mjs.map +1 -0
  126. package/fesm2022/cute-widgets-base-radio.mjs +637 -0
  127. package/fesm2022/cute-widgets-base-radio.mjs.map +1 -0
  128. package/fesm2022/cute-widgets-base-select.mjs +1208 -0
  129. package/fesm2022/cute-widgets-base-select.mjs.map +1 -0
  130. package/fesm2022/cute-widgets-base-sidenav.mjs +1095 -0
  131. package/fesm2022/cute-widgets-base-sidenav.mjs.map +1 -0
  132. package/fesm2022/cute-widgets-base-slider.mjs +99 -0
  133. package/fesm2022/cute-widgets-base-slider.mjs.map +1 -0
  134. package/fesm2022/cute-widgets-base-snack-bar.mjs +897 -0
  135. package/fesm2022/cute-widgets-base-snack-bar.mjs.map +1 -0
  136. package/fesm2022/cute-widgets-base-sort.mjs +639 -0
  137. package/fesm2022/cute-widgets-base-sort.mjs.map +1 -0
  138. package/fesm2022/cute-widgets-base-spinner.mjs +154 -0
  139. package/fesm2022/cute-widgets-base-spinner.mjs.map +1 -0
  140. package/fesm2022/cute-widgets-base-stepper.mjs +673 -0
  141. package/fesm2022/cute-widgets-base-stepper.mjs.map +1 -0
  142. package/fesm2022/cute-widgets-base-table.mjs +1023 -0
  143. package/fesm2022/cute-widgets-base-table.mjs.map +1 -0
  144. package/fesm2022/cute-widgets-base-tabs.mjs +729 -0
  145. package/fesm2022/cute-widgets-base-tabs.mjs.map +1 -0
  146. package/fesm2022/cute-widgets-base-timepicker.mjs +965 -0
  147. package/fesm2022/cute-widgets-base-timepicker.mjs.map +1 -0
  148. package/fesm2022/cute-widgets-base-toolbar.mjs +120 -0
  149. package/fesm2022/cute-widgets-base-toolbar.mjs.map +1 -0
  150. package/fesm2022/cute-widgets-base-tooltip.mjs +947 -0
  151. package/fesm2022/cute-widgets-base-tooltip.mjs.map +1 -0
  152. package/fesm2022/cute-widgets-base-tree.mjs +598 -0
  153. package/fesm2022/cute-widgets-base-tree.mjs.map +1 -0
  154. package/fesm2022/cute-widgets-base.mjs +68 -0
  155. package/fesm2022/cute-widgets-base.mjs.map +1 -0
  156. package/form-field/index.d.ts +401 -0
  157. package/grid-list/index.d.ts +361 -0
  158. package/icon/index.d.ts +477 -0
  159. package/index.d.ts +3 -0
  160. package/input/index.d.ts +256 -0
  161. package/layout/container/index.d.ts +31 -0
  162. package/layout/index.d.ts +78 -0
  163. package/layout/stack/index.d.ts +52 -0
  164. package/list/index.d.ts +659 -0
  165. package/menu/index.d.ts +497 -0
  166. package/navbar/index.d.ts +91 -0
  167. package/package.json +279 -0
  168. package/paginator/index.d.ts +216 -0
  169. package/progress/index.d.ts +130 -0
  170. package/radio/index.d.ts +259 -0
  171. package/select/index.d.ts +426 -0
  172. package/sidenav/index.d.ts +369 -0
  173. package/slider/index.d.ts +48 -0
  174. package/snack-bar/index.d.ts +374 -0
  175. package/sort/index.d.ts +334 -0
  176. package/spinner/index.d.ts +70 -0
  177. package/stepper/index.d.ts +295 -0
  178. package/table/index.d.ts +395 -0
  179. package/tabs/index.d.ts +307 -0
  180. package/timepicker/index.d.ts +350 -0
  181. package/toolbar/index.d.ts +36 -0
  182. package/tooltip/index.d.ts +299 -0
  183. package/tree/index.d.ts +314 -0
@@ -0,0 +1,1600 @@
1
+ import { MediaMatcher } from '@angular/cdk/layout';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, inject, ANIMATION_MODULE_TYPE, Directive, NgModule, signal, computed, HostListener, Input, APP_ID, Injectable, LOCALE_ID, isDevMode, Pipe, SecurityContext, DOCUMENT } from '@angular/core';
4
+ import { startWith, take } from 'rxjs/operators';
5
+ import { CommonModule } from '@angular/common';
6
+ import { firstValueFrom, fromEvent, Subject } from 'rxjs';
7
+ import { DomSanitizer } from '@angular/platform-browser';
8
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
9
+
10
+ /** Injection token used to configure the animations in CuteWidgets. */
11
+ const CUTE_WIDGETS_ANIMATIONS = new InjectionToken('CUTE_WIDGETS_ANIMATIONS');
12
+ /**
13
+ * @deprecated No longer used, will be removed.
14
+ * @breaking-change 21.0.0
15
+ * @docs-private
16
+ */
17
+ class AnimationCurves {
18
+ static { this.STANDARD_CURVE = 'cubic-bezier(0.4,0.0,0.2,1)'; }
19
+ static { this.DECELERATION_CURVE = 'cubic-bezier(0.0,0.0,0.2,1)'; }
20
+ static { this.ACCELERATION_CURVE = 'cubic-bezier(0.4,0.0,1,1)'; }
21
+ static { this.SHARP_CURVE = 'cubic-bezier(0.4,0.0,0.6,1)'; }
22
+ }
23
+ /**
24
+ * @deprecated No longer used, will be removed.
25
+ * @breaking-change 21.0.0
26
+ * @docs-private
27
+ */
28
+ class AnimationDurations {
29
+ static { this.COMPLEX = '375ms'; }
30
+ static { this.ENTERING = '225ms'; }
31
+ static { this.EXITING = '195ms'; }
32
+ }
33
+ let reducedMotion = null;
34
+ /**
35
+ * Gets the configured animations state.
36
+ * @docs-private
37
+ */
38
+ function _getAnimationsState() {
39
+ if (inject(CUTE_WIDGETS_ANIMATIONS, { optional: true })?.animationsDisabled ||
40
+ inject(ANIMATION_MODULE_TYPE, { optional: true }) === 'NoopAnimations') {
41
+ return 'di-disabled';
42
+ }
43
+ reducedMotion ??= inject(MediaMatcher).matchMedia('(prefers-reduced-motion)').matches;
44
+ return reducedMotion ? 'reduced-motion' : 'enabled';
45
+ }
46
+ /**
47
+ * Returns whether animations have been disabled by DI. Must be called in a DI context.
48
+ * @docs-private
49
+ */
50
+ function _animationsDisabled() {
51
+ return _getAnimationsState() !== 'enabled';
52
+ }
53
+
54
+ /**
55
+ * @license Apache-2.0
56
+ *
57
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
58
+ *
59
+ * You may not use this file except in compliance with the License
60
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
61
+ */
62
+ /**
63
+ * Bootstrap media-queries, or `breakpoints`.
64
+ * PascalCase is being used as Breakpoints is used like an enum.
65
+ */
66
+ const bsBreakpoints = {
67
+ SmallAndDown: '(max-width: 575.98px)',
68
+ MediumAndDown: '(max-width: 767.98px)',
69
+ LargeAndDown: '(max-width: 991.98px)',
70
+ XLargeAndDown: '(max-width: 1199.98px)',
71
+ XXLargeAndDown: '(max-width: 1399.98px)',
72
+ XSmall: '(max-width: 575.98px)',
73
+ Small: '(min-width: 576px) and (max-width: 767.98px)',
74
+ Medium: '(min-width: 768px) and (max-width: 991.98px)',
75
+ Large: '(min-width: 992px) and (max-width: 1199.98px)',
76
+ XLarge: '(min-width: 1200px) and (max-width: 1399.98px)',
77
+ XXLarge: '(min-width: 1400px)',
78
+ get grid() {
79
+ return { xs: 0, sm: 576, md: 768, lg: 992, xl: 1200, xxl: 1400 };
80
+ },
81
+ get xs() { return this.XSmall; },
82
+ get sm() { return this.Small; },
83
+ get md() { return this.Medium; },
84
+ get lg() { return this.Large; },
85
+ get xl() { return this.XLarge; },
86
+ get xxl() { return this.XXLarge; },
87
+ /**
88
+ * Gets the object's property name of the media-query by its value
89
+ * @param query The media-query text
90
+ * @returns The property name of the media-query or _undefined_ if it was not found
91
+ */
92
+ getQueryName(query) {
93
+ let res;
94
+ if (query) {
95
+ for (const key in this) {
96
+ if (this[key] === query) {
97
+ res = key;
98
+ break;
99
+ }
100
+ }
101
+ }
102
+ return res;
103
+ },
104
+ /**
105
+ * Gets the breakpoint label by Bootstrap's breakpoint abbreviation
106
+ * @param code Bootstrap's breakpoint abbreviation
107
+ * @returns More descriptive text of the abbreviation
108
+ */
109
+ getLabel(code) {
110
+ switch (code) {
111
+ case "xs": return "XSmall";
112
+ case "sm": return "Small";
113
+ case "md": return "Medium";
114
+ case "lg": return "Large";
115
+ case "xl": return "XLarge";
116
+ case "xxl": return "XXLarge";
117
+ }
118
+ return "";
119
+ }
120
+ };
121
+
122
+ /**
123
+ * @license Apache-2.0
124
+ *
125
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
126
+ *
127
+ * You may not use this file except in compliance with the License
128
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
129
+ *
130
+ * This code is a modification of the `@angular/material` original
131
+ * code licensed under MIT-style License (https://angular.dev/license).
132
+ */
133
+ /**
134
+ * Shared directive to count lines inside a text area, such as a list item.
135
+ * Line elements can be extracted with a @ContentChildren(CuteLine) query, then
136
+ * counted by checking the query list's length.
137
+ */
138
+ class CuteLine {
139
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteLine, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
140
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteLine, isStandalone: true, selector: "[cute-line], [cuteLine]", host: { classAttribute: "cute-line" }, ngImport: i0 }); }
141
+ }
142
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteLine, decorators: [{
143
+ type: Directive,
144
+ args: [{
145
+ selector: '[cute-line], [cuteLine]',
146
+ host: { 'class': 'cute-line' },
147
+ standalone: true,
148
+ }]
149
+ }] });
150
+ /**
151
+ * Helper that takes a query list of lines and sets the correct class on the host.
152
+ */
153
+ function setLines(lines, element, prefix = 'cute') {
154
+ // Note: doesn't need to unsubscribe, because `changes`
155
+ // gets completed by Angular when the view is destroyed.
156
+ lines.changes.pipe(startWith(lines)).subscribe(({ length }) => {
157
+ setClass(element, `${prefix}-2-line`, false);
158
+ setClass(element, `${prefix}-3-line`, false);
159
+ setClass(element, `${prefix}-multi-line`, false);
160
+ if (length === 2 || length === 3) {
161
+ setClass(element, `${prefix}-${length}-line`, true);
162
+ }
163
+ else if (length > 3) {
164
+ setClass(element, `${prefix}-multi-line`, true);
165
+ }
166
+ });
167
+ }
168
+ /** Adds or removes a class from an element. */
169
+ function setClass(element, className, isAdd) {
170
+ element.nativeElement.classList.toggle(className, isAdd);
171
+ }
172
+
173
+ /**
174
+ * @license Apache-2.0
175
+ *
176
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
177
+ *
178
+ * You may not use this file except in compliance with the License
179
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
180
+ */
181
+ const TYPES = [
182
+ CuteLine
183
+ ];
184
+ class CuteLineModule {
185
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteLineModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
186
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteLineModule, imports: [CommonModule, CuteLine], exports: [CuteLine] }); }
187
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteLineModule, imports: [CommonModule] }); }
188
+ }
189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteLineModule, decorators: [{
190
+ type: NgModule,
191
+ args: [{
192
+ imports: [CommonModule, ...TYPES],
193
+ exports: TYPES,
194
+ declarations: [],
195
+ }]
196
+ }] });
197
+
198
+ /**
199
+ * @license Apache-2.0
200
+ *
201
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
202
+ *
203
+ * You may not use this file except in compliance with the License
204
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
205
+ */
206
+ const RIPPLE_CLASS_NAME = "cute-ripple-element";
207
+ class Ripple {
208
+ constructor(target) {
209
+ this._active = signal(false, ...(ngDevMode ? [{ debugName: "_active" }] : []));
210
+ this._disabled = false;
211
+ this.isActive = computed(() => this._active(), ...(ngDevMode ? [{ debugName: "isActive" }] : []));
212
+ this._target = target;
213
+ }
214
+ get disabled() { return this._disabled; }
215
+ set disabled(v) { this._disabled = v; }
216
+ stop() {
217
+ if (this._target) {
218
+ const existingRipple = this._target.getElementsByClassName(RIPPLE_CLASS_NAME)[0];
219
+ if (existingRipple) {
220
+ existingRipple.parentElement?.remove();
221
+ }
222
+ }
223
+ this._active.set(false);
224
+ }
225
+ launch(event, options) {
226
+ if (this.disabled) {
227
+ return;
228
+ }
229
+ if (this.isActive()) {
230
+ this.stop();
231
+ }
232
+ if (this._target && event) {
233
+ const rect = this._target.getBoundingClientRect();
234
+ const parent = document.createElement("div");
235
+ parent.style.position = "absolute";
236
+ parent.style.top = "0";
237
+ parent.style.right = "0";
238
+ parent.style.bottom = "0";
239
+ parent.style.left = "0";
240
+ parent.style.overflow = "hidden";
241
+ parent.style.borderRadius = "inherit";
242
+ parent.style.transform = "perspective(0)";
243
+ parent.ariaHidden = "true";
244
+ parent.classList.add("cute-ripple");
245
+ const circle = document.createElement("span");
246
+ const diameter = Math.max(rect.width, rect.height);
247
+ const radius = diameter / 2;
248
+ circle.style.width = circle.style.height = `${diameter}px`;
249
+ if (options?.centered) {
250
+ circle.style.left = `${rect.width / 2 - radius}px`;
251
+ circle.style.top = `${rect.height / 2 - radius}px`;
252
+ }
253
+ else {
254
+ circle.style.left = `${event.clientX - rect.left - radius}px`;
255
+ circle.style.top = `${event.clientY - rect.top - radius}px`;
256
+ }
257
+ if (options?.color) {
258
+ circle.style.setProperty("--cute-ripple-bg-color", options.color);
259
+ }
260
+ if (options?.duration) {
261
+ circle.style.setProperty("--cute-ripple-duration", String(options.duration));
262
+ }
263
+ circle.classList.add(RIPPLE_CLASS_NAME);
264
+ parent.appendChild(circle);
265
+ this._target.appendChild(parent);
266
+ this._active.set(true);
267
+ Promise.any([
268
+ firstValueFrom(fromEvent(circle, "animationend").pipe(take(1))),
269
+ firstValueFrom(fromEvent(circle, "animationcancel").pipe(take(1))),
270
+ //firstValueFrom(fromEvent(document, "mouseup").pipe(take(1))),
271
+ ]).then(() => {
272
+ circle.parentElement?.remove();
273
+ this._active.set(false);
274
+ });
275
+ }
276
+ }
277
+ }
278
+
279
+ /**
280
+ * @license Apache-2.0
281
+ *
282
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
283
+ *
284
+ * You may not use this file except in compliance with the License
285
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
286
+ */
287
+ class RippleManager {
288
+ static { this._ripples = new WeakMap(); }
289
+ static getInstance(target) {
290
+ return RippleManager.createRipple(target);
291
+ }
292
+ static createRipple(target) {
293
+ if (!target) {
294
+ throw new Error("'target' is required when instantiating a Ripple object");
295
+ }
296
+ let ripple = this._ripples.get(target);
297
+ if (!ripple) {
298
+ ripple = new RippleImpl(target);
299
+ this._ripples.set(target, ripple);
300
+ }
301
+ return ripple;
302
+ }
303
+ static removeRipple(target) {
304
+ if (target) {
305
+ let ripple = this._ripples.get(target);
306
+ if (ripple) {
307
+ ripple.stop();
308
+ }
309
+ this._ripples.delete(target);
310
+ }
311
+ }
312
+ }
313
+ class RippleImpl extends Ripple {
314
+ constructor(target) {
315
+ super(target);
316
+ }
317
+ }
318
+
319
+ /**
320
+ * @license Apache-2.0
321
+ *
322
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
323
+ *
324
+ * You may not use this file except in compliance with the License
325
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
326
+ */
327
+ class CuteRipple /* extends ... */ {
328
+ onMouseDown(event) {
329
+ if (this._ripple) {
330
+ this._ripple.launch(event, this.rippleOptions);
331
+ }
332
+ }
333
+ constructor(_elemRef) {
334
+ this._elemRef = _elemRef;
335
+ this._ripple = RippleManager.createRipple(_elemRef.nativeElement);
336
+ }
337
+ ngOnDestroy() {
338
+ RippleManager.removeRipple(this._elemRef.nativeElement);
339
+ }
340
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRipple /* extends ... */, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
341
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteRipple /* extends ... */, isStandalone: true, selector: "[cuteRipple]", inputs: { rippleOptions: ["cuteRipple", "rippleOptions"] }, host: { listeners: { "mousedown": "onMouseDown($event)" } }, exportAs: ["cuteRipple"], ngImport: i0 }); }
342
+ }
343
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteRipple /* extends ... */, decorators: [{
344
+ type: Directive,
345
+ args: [{
346
+ selector: '[cuteRipple]',
347
+ exportAs: 'cuteRipple',
348
+ host: {},
349
+ standalone: true,
350
+ }]
351
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { rippleOptions: [{
352
+ type: Input,
353
+ args: ["cuteRipple"]
354
+ }], onMouseDown: [{
355
+ type: HostListener,
356
+ args: ["mousedown", ['$event']]
357
+ }] } });
358
+
359
+ /**
360
+ * @license Apache-2.0
361
+ *
362
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
363
+ *
364
+ * You may not use this file except in compliance with the License
365
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
366
+ */
367
+
368
+ /**
369
+ * @license Apache-2.0
370
+ *
371
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
372
+ *
373
+ * You may not use this file except in compliance with the License
374
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
375
+ */
376
+
377
+ /**
378
+ * @license Apache-2.0
379
+ *
380
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
381
+ *
382
+ * You may not use this file except in compliance with the License
383
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
384
+ */
385
+
386
+ /**
387
+ * @license Apache-2.0
388
+ *
389
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
390
+ *
391
+ * You may not use this file except in compliance with the License
392
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
393
+ */
394
+
395
+ /**
396
+ * @license Apache-2.0
397
+ *
398
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
399
+ *
400
+ * You may not use this file except in compliance with the License
401
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
402
+ */
403
+ /**
404
+ * Gets transition duration total value
405
+ * @param element Source HTML element
406
+ * @returns Duration with delay time in milliseconds
407
+ */
408
+ function getOverallTransitionDuration(element) {
409
+ return getTransitionDelay(element) + getTransitionDuration(element);
410
+ }
411
+ /**
412
+ * Gets transition duration value
413
+ * @param element Source HTML element
414
+ * @returns Duration time in milliseconds
415
+ */
416
+ function getTransitionDuration(element) {
417
+ const { transitionDuration } = window.getComputedStyle(element);
418
+ const durationInMilliseconds = transitionDuration.toLowerCase().endsWith("ms");
419
+ const transitionDurationMs = parseFloat(transitionDuration) * (durationInMilliseconds ? 1 : 1000);
420
+ return (transitionDurationMs);
421
+ }
422
+ /**
423
+ * Gets duration to wait before starting transition
424
+ * @param element Source HTML element
425
+ * @returns Delay time in milliseconds
426
+ */
427
+ function getTransitionDelay(element) {
428
+ const { transitionDelay } = window.getComputedStyle(element);
429
+ const delayInMilliseconds = transitionDelay.toLowerCase().endsWith("ms");
430
+ const transitionDelayMs = parseFloat(transitionDelay) * (delayInMilliseconds ? 1 : 1000);
431
+ return (transitionDelayMs);
432
+ }
433
+
434
+ /**
435
+ * @license Apache-2.0
436
+ *
437
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
438
+ *
439
+ * You may not use this file except in compliance with the License
440
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
441
+ */
442
+ function createValueToken(value) {
443
+ return createFactoryToken(() => value);
444
+ }
445
+ function createFactoryToken(factory) {
446
+ return new InjectionToken(`createFactoryToken`, { factory });
447
+ }
448
+
449
+ /**
450
+ * Forcibly starts the process of downloading and saving the file.
451
+ * @param blobData Data to save
452
+ * @param filename File name to save. Default is `download`.
453
+ */
454
+ function saveAs(blobData, filename) {
455
+ const link = document.createElement("a");
456
+ link.href = URL.createObjectURL(blobData);
457
+ link.download = filename || "download";
458
+ link.click();
459
+ URL.revokeObjectURL(link.href);
460
+ }
461
+ /**
462
+ * Exports data from HTML table to MS Excel format text
463
+ * @param tableIdOrElem HTML table's `id` value or `ElementRef` object
464
+ * @param options Export options
465
+ */
466
+ function exportToExcel(tableIdOrElem, options = { filename: 'records.xls' }) {
467
+ let tableElem;
468
+ if (typeof tableIdOrElem === "string") {
469
+ tableElem = document.getElementById(tableIdOrElem);
470
+ }
471
+ else {
472
+ tableElem = tableIdOrElem.nativeElement;
473
+ }
474
+ if (tableElem && tableElem instanceof HTMLTableElement) {
475
+ //const tableHTML = encodeURIComponent(tableElem.outerHTML.replace(/ or .*?>/g, '>'));
476
+ const tableHTML = tableElem.outerHTML.replace(/ or .*?>/g, '>');
477
+ const blobData = new Blob([tableHTML], { type: '{type: application/vnd.ms-excel' });
478
+ saveAs(blobData, options?.filename);
479
+ }
480
+ }
481
+ /**
482
+ * Exports data from HTML table to CSV format text
483
+ * @param tableIdOrElem HTML table's `id` value or `ElementRef` object
484
+ * @param options Export options
485
+ */
486
+ function exportToCSV(tableIdOrElem, options = { filename: 'records.csv' }) {
487
+ let tableElem;
488
+ if (typeof tableIdOrElem === "string") {
489
+ tableElem = document.getElementById(tableIdOrElem);
490
+ }
491
+ else {
492
+ tableElem = tableIdOrElem.nativeElement;
493
+ }
494
+ if (tableElem && tableElem instanceof HTMLTableElement) {
495
+ const rows = tableElem.querySelectorAll("tr");
496
+ let csv = [];
497
+ let keys = [];
498
+ if (rows.length > 0 && options && options.columns?.length) {
499
+ const headers = rows[0].querySelectorAll("th");
500
+ headers.forEach((header, key) => {
501
+ if (options.columns.findIndex((name) => {
502
+ const loweredName = name.toLowerCase();
503
+ return header.innerText.toLowerCase() == loweredName || header.classList.contains("cdk-column-" + loweredName);
504
+ }) >= 0) {
505
+ keys.push(key);
506
+ }
507
+ });
508
+ }
509
+ const appendCells = (cells) => {
510
+ const rowText = Array.from(cells).map(cell => cell.innerText);
511
+ csv.push(rowText.join(options?.delimiter ?? ","));
512
+ };
513
+ if (keys.length > 0) {
514
+ rows.forEach((row) => {
515
+ const allCells = row.querySelectorAll("th,td");
516
+ let cells = [];
517
+ allCells.forEach((cell, key) => {
518
+ if (keys.indexOf(key) >= 0) {
519
+ cells.push(cell);
520
+ }
521
+ });
522
+ appendCells(cells);
523
+ });
524
+ }
525
+ else {
526
+ rows.forEach((row) => {
527
+ appendCells(row.querySelectorAll("th,td"));
528
+ });
529
+ }
530
+ const blobData = new Blob([csv.join("\n")], { type: "text/csv;charset=utf-8;" });
531
+ saveAs(blobData, options?.filename);
532
+ }
533
+ }
534
+
535
+ /**
536
+ * @license Apache-2.0
537
+ *
538
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
539
+ *
540
+ * You may not use this file except in compliance with the License
541
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
542
+ *
543
+ * This code is a modification of the `@angular/material` original
544
+ * code licensed under MIT-style License (https://angular.dev/license).
545
+ */
546
+ /**
547
+ * Keeps track of the ID count per prefix. This helps us make the IDs a bit more deterministic
548
+ * like they were before the service was introduced. Note that ideally we wouldn't have to do
549
+ * this, but there are some internal tests that rely on the IDs.
550
+ */
551
+ const counters = {};
552
+ /** Service that generates unique IDs for DOM nodes. */
553
+ class IdGenerator {
554
+ constructor() {
555
+ this._appId = inject(APP_ID);
556
+ }
557
+ /**
558
+ * Generates a unique ID with a specific prefix.
559
+ * @param prefix Prefix to add to the ID.
560
+ */
561
+ getId(prefix) {
562
+ // Omit the app ID if it's the default `ng`. Since the vast majority of pages have one
563
+ // Angular app on them, we can reduce the number of breakages by not adding it.
564
+ if (this._appId !== 'ng') {
565
+ prefix += this._appId;
566
+ }
567
+ if (!counters.hasOwnProperty(prefix)) {
568
+ counters[prefix] = 0;
569
+ }
570
+ return `${prefix}${counters[prefix]++}`;
571
+ }
572
+ /**
573
+ * Generates UUID (ver.4) string using simple algorithm based on random value only
574
+ */
575
+ getUUID() {
576
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
577
+ .replace(/[xy]/g, (c) => {
578
+ const r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
579
+ return v.toString(16);
580
+ });
581
+ }
582
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: IdGenerator, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
583
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: IdGenerator, providedIn: 'root' }); }
584
+ }
585
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: IdGenerator, decorators: [{
586
+ type: Injectable,
587
+ args: [{ providedIn: 'root' }]
588
+ }] });
589
+
590
+ /**
591
+ * @license Apache-2.0
592
+ *
593
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
594
+ *
595
+ * You may not use this file except in compliance with the License
596
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
597
+ */
598
+ /**
599
+ * A class with static methods specifically designed for scheduling tasks in the browser.
600
+ */
601
+ class Scheduler {
602
+ /** Yielding to the main thread in the browser. */
603
+ static async yield() {
604
+ const globalScheduler = globalThis.scheduler;
605
+ if (globalScheduler?.yield) {
606
+ return globalScheduler.yield();
607
+ }
608
+ // Fall back to yielding with setTimeout.
609
+ return new Promise(resolve => {
610
+ setTimeout(resolve, 0);
611
+ });
612
+ }
613
+ /**
614
+ * Resolves a promise after the delay time in milliseconds
615
+ * @param ms Number of milliseconds to wait
616
+ *
617
+ * @see {@link delay}
618
+ */
619
+ static async wait(ms) {
620
+ const startNow = performance.now();
621
+ while ((performance.now() - startNow) < ms) {
622
+ await Scheduler.yield();
623
+ }
624
+ }
625
+ /**
626
+ * Adding a task to be scheduled according to their priority.
627
+ * @param callback Function to run
628
+ * @param options Scheduler options
629
+ *
630
+ * @see {@link async.post}
631
+ */
632
+ static async postTask(callback, options) {
633
+ const globalScheduler = globalThis.scheduler;
634
+ if (globalScheduler?.postTask) {
635
+ return globalScheduler.postTask(callback, options);
636
+ }
637
+ return new Promise((resolve) => {
638
+ setTimeout(() => resolve(callback()), options?.delay ?? 0);
639
+ });
640
+ }
641
+ }
642
+
643
+ /**
644
+ * @license Apache-2.0
645
+ *
646
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
647
+ *
648
+ * You may not use this file except in compliance with the License
649
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
650
+ *
651
+ * This code is a modification of the `@angular/material` original
652
+ * code licensed under MIT-style License (https://angular.dev/license).
653
+ */
654
+ /** InjectionToken for datepicker that can be used to override default locale code. */
655
+ const CUTE_DATE_LOCALE = new InjectionToken('CUTE_DATE_LOCALE', {
656
+ providedIn: 'root',
657
+ factory: CUTE_DATE_LOCALE_FACTORY,
658
+ });
659
+ /**
660
+ * @docs-private
661
+ * @deprecated No longer used, will be removed.
662
+ * @breaking-change 21.0.0
663
+ */
664
+ function CUTE_DATE_LOCALE_FACTORY() {
665
+ return inject(LOCALE_ID);
666
+ }
667
+ const NOT_IMPLEMENTED = 'Method not implemented';
668
+ /** Adapts type `D` to be usable as a date by cdk-based components that work with dates. */
669
+ class DateAdapter {
670
+ constructor() {
671
+ this._localeChanges = new Subject();
672
+ /** A stream that emits when the locale changes. */
673
+ this.localeChanges = this._localeChanges;
674
+ }
675
+ /**
676
+ * Sets the time of one date to the time of another.
677
+ * @param target Date whose time will be set.
678
+ * @param hours New hours to set on the date object.
679
+ * @param minutes New minutes to set on the date object.
680
+ * @param seconds New seconds to set on the date object.
681
+ */
682
+ setTime(target, hours, minutes, seconds) {
683
+ throw new Error(NOT_IMPLEMENTED);
684
+ }
685
+ /**
686
+ * Gets the hours component of the given date.
687
+ * @param date The date to extract the hours from.
688
+ */
689
+ getHours(date) {
690
+ throw new Error(NOT_IMPLEMENTED);
691
+ }
692
+ /**
693
+ * Gets the minutes component of the given date.
694
+ * @param date The date to extract the minutes from.
695
+ */
696
+ getMinutes(date) {
697
+ throw new Error(NOT_IMPLEMENTED);
698
+ }
699
+ /**
700
+ * Gets the seconds component of the given date.
701
+ * @param date The date to extract the seconds from.
702
+ */
703
+ getSeconds(date) {
704
+ throw new Error(NOT_IMPLEMENTED);
705
+ }
706
+ /**
707
+ * Parses a date with a specific time from a user-provided value.
708
+ * @param value The value to parse.
709
+ * @param parseFormat The expected format of the value being parsed
710
+ * (type is implementation-dependent).
711
+ */
712
+ parseTime(value, parseFormat) {
713
+ throw new Error(NOT_IMPLEMENTED);
714
+ }
715
+ /**
716
+ * Adds an amount of seconds to the specified date.
717
+ * @param date Date to which to add the seconds.
718
+ * @param amount Amount of seconds to add to the date.
719
+ */
720
+ addSeconds(date, amount) {
721
+ throw new Error(NOT_IMPLEMENTED);
722
+ }
723
+ /**
724
+ * Given a potential date object, returns that same date object if it is
725
+ * a valid date, or `null` if it's not a valid date.
726
+ * @param obj The object to check.
727
+ * @returns A date or `null`.
728
+ */
729
+ getValidDateOrNull(obj) {
730
+ return this.isDateInstance(obj) && this.isValid(obj) ? obj : null;
731
+ }
732
+ /**
733
+ * Attempts to deserialize a value to a valid date object. This is different from parsing in that
734
+ * deserialize should only accept non-ambiguous, locale-independent formats (e.g. a ISO 8601
735
+ * string). The default implementation does not allow any deserialization, it simply checks that
736
+ * the given value is already a valid date object or null. The `<mat-datepicker>` will call this
737
+ * method on all of its `@Input()` properties that accept dates. It is therefore possible to
738
+ * support passing values from your backend directly to these properties by overriding this method
739
+ * to also deserialize the format used by your backend.
740
+ * @param value The value to be deserialized into a date object.
741
+ * @returns The deserialized date object, either a valid date, null if the value can be
742
+ * deserialized into a null date (e.g. the empty string), or an invalid date.
743
+ */
744
+ deserialize(value) {
745
+ if (value == null || (this.isDateInstance(value) && this.isValid(value))) {
746
+ return value;
747
+ }
748
+ return this.invalid();
749
+ }
750
+ /**
751
+ * Sets the locale used for all dates.
752
+ * @param locale The new locale.
753
+ */
754
+ setLocale(locale) {
755
+ this.locale = locale;
756
+ this._localeChanges.next();
757
+ }
758
+ /**
759
+ * Compares two dates.
760
+ * @param first The first date to compare.
761
+ * @param second The second date to compare.
762
+ * @returns 0 if the dates are equal, a number less than 0 if the first date is earlier,
763
+ * a number greater than 0 if the first date is later.
764
+ */
765
+ compareDate(first, second) {
766
+ return (this.getYear(first) - this.getYear(second) ||
767
+ this.getMonth(first) - this.getMonth(second) ||
768
+ this.getDate(first) - this.getDate(second));
769
+ }
770
+ /**
771
+ * Compares the time values of two dates.
772
+ * @param first First date to compare.
773
+ * @param second Second date to compare.
774
+ * @returns 0 if the times are equal, a number less than 0 if the first time is earlier,
775
+ * a number greater than 0 if the first time is later.
776
+ */
777
+ compareTime(first, second) {
778
+ return (this.getHours(first) - this.getHours(second) ||
779
+ this.getMinutes(first) - this.getMinutes(second) ||
780
+ this.getSeconds(first) - this.getSeconds(second));
781
+ }
782
+ /**
783
+ * Checks if two dates are equal.
784
+ * @param first The first date to check.
785
+ * @param second The second date to check.
786
+ * @returns Whether the two dates are equal.
787
+ * Null dates are considered equal to other null dates.
788
+ */
789
+ sameDate(first, second) {
790
+ if (first && second) {
791
+ let firstValid = this.isValid(first);
792
+ let secondValid = this.isValid(second);
793
+ if (firstValid && secondValid) {
794
+ return !this.compareDate(first, second);
795
+ }
796
+ return firstValid == secondValid;
797
+ }
798
+ return first == second;
799
+ }
800
+ /**
801
+ * Checks if the times of two dates are equal.
802
+ * @param first The first date to check.
803
+ * @param second The second date to check.
804
+ * @returns Whether the times of the two dates are equal.
805
+ * Null dates are considered equal to other null dates.
806
+ */
807
+ sameTime(first, second) {
808
+ if (first && second) {
809
+ const firstValid = this.isValid(first);
810
+ const secondValid = this.isValid(second);
811
+ if (firstValid && secondValid) {
812
+ return !this.compareTime(first, second);
813
+ }
814
+ return firstValid == secondValid;
815
+ }
816
+ return first == second;
817
+ }
818
+ /**
819
+ * Clamp the given date between min and max dates.
820
+ * @param date The date to clamp.
821
+ * @param min The minimum value to allow. If null or omitted, no min is enforced.
822
+ * @param max The maximum value to allow. If null or omitted, no max is enforced.
823
+ * @returns `min` if `date` is less than `min`, `max` if date is greater than `max`,
824
+ * otherwise `date`.
825
+ */
826
+ clampDate(date, min, max) {
827
+ if (min && this.compareDate(date, min) < 0) {
828
+ return min;
829
+ }
830
+ if (max && this.compareDate(date, max) > 0) {
831
+ return max;
832
+ }
833
+ return date;
834
+ }
835
+ }
836
+
837
+ /**
838
+ * @license Apache-2.0
839
+ *
840
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
841
+ *
842
+ * You may not use this file except in compliance with the License
843
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
844
+ *
845
+ * This code is a modification of the `@angular/material` original
846
+ * code licensed under MIT-style License (https://angular.dev/license).
847
+ */
848
+ const CUTE_DATE_FORMATS = new InjectionToken('cute-date-formats');
849
+
850
+ /**
851
+ * @license Apache-2.0
852
+ *
853
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
854
+ *
855
+ * You may not use this file except in compliance with the License
856
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
857
+ *
858
+ * This code is a modification of the `@angular/material` original
859
+ * code licensed under MIT-style License (https://angular.dev/license).
860
+ */
861
+ /**
862
+ * Matches strings that have the form of a valid RFC 3339 string
863
+ * (https://tools.ietf.org/html/rfc3339). Note that the string may not actually be a valid date
864
+ * because the regex will match strings and without of bounds month, date, etc.
865
+ */
866
+ const ISO_8601_REGEX = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;
867
+ /**
868
+ * Matches a time string. Supported formats:
869
+ * - {{hours}}:{{minutes}}
870
+ * - {{hours}}:{{minutes}}:{{seconds}}
871
+ * - {{hours}}:{{minutes}} AM/PM
872
+ * - {{hours}}:{{minutes}}:{{seconds}} AM/PM
873
+ * - {{hours}}.{{minutes}}
874
+ * - {{hours}}.{{minutes}}.{{seconds}}
875
+ * - {{hours}}.{{minutes}} AM/PM
876
+ * - {{hours}}.{{minutes}}.{{seconds}} AM/PM
877
+ */
878
+ const TIME_REGEX = /^(\d?\d)[:.](\d?\d)(?:[:.](\d?\d))?\s*(AM|PM)?$/i;
879
+ /** Creates an array and fills it with values. */
880
+ function range(length, valueFunction) {
881
+ const valuesArray = Array(length);
882
+ for (let i = 0; i < length; i++) {
883
+ valuesArray[i] = valueFunction(i);
884
+ }
885
+ return valuesArray;
886
+ }
887
+ /** Adapts the native JS Date for use with cdk-based components that work with dates. */
888
+ class NativeDateAdapter extends DateAdapter {
889
+ constructor() {
890
+ super();
891
+ /** The injected locale. */
892
+ this._cuteDateLocale = inject(CUTE_DATE_LOCALE, { optional: true });
893
+ const cuteDateLocale = inject(CUTE_DATE_LOCALE, { optional: true });
894
+ if (cuteDateLocale !== undefined) {
895
+ this._cuteDateLocale = cuteDateLocale;
896
+ }
897
+ super.setLocale(this._cuteDateLocale);
898
+ }
899
+ getYear(date) { return date.getFullYear(); }
900
+ getMonth(date) { return date.getMonth(); }
901
+ getDate(date) { return date.getDate(); }
902
+ getDayOfWeek(date) { return date.getDay(); }
903
+ getMonthNames(style) {
904
+ const dtf = new Intl.DateTimeFormat(this.locale, { month: style, timeZone: 'utc' });
905
+ return range(12, i => this._format(dtf, new Date(2017, i, 1)));
906
+ }
907
+ getDateNames() {
908
+ const dtf = new Intl.DateTimeFormat(this.locale, { day: 'numeric', timeZone: 'utc' });
909
+ return range(31, i => this._format(dtf, new Date(2017, 0, i + 1)));
910
+ }
911
+ getDayOfWeekNames(style) {
912
+ const dtf = new Intl.DateTimeFormat(this.locale, { weekday: style, timeZone: 'utc' });
913
+ return range(7, i => this._format(dtf, new Date(2017, 0, i + 1)));
914
+ }
915
+ getYearName(date) {
916
+ const dtf = new Intl.DateTimeFormat(this.locale, { year: 'numeric', timeZone: 'utc' });
917
+ return this._format(dtf, date);
918
+ }
919
+ getFirstDayOfWeek() {
920
+ // At the time of writing `Intl.Locale` isn't available
921
+ // in the internal types, so we need to cast to `any`.
922
+ if (typeof Intl !== 'undefined' && Intl.Locale) {
923
+ const locale = new Intl.Locale(this.locale);
924
+ // Some browsers implement a `getWeekInfo` method while others have a `weekInfo` getter.
925
+ // Note that this isn't supported in all browsers, so we need to null check it.
926
+ const firstDay = (locale.getWeekInfo?.() || locale.weekInfo)?.firstDay ?? 0;
927
+ // `weekInfo.firstDay` is a number between 1 and 7 where, starting from Monday,
928
+ // whereas our representation is 0 to 6 where 0 is Sunday, so we need to normalize it.
929
+ return firstDay === 7 ? 0 : firstDay;
930
+ }
931
+ // Default to Sunday if the browser doesn't provide the week information.
932
+ return 0;
933
+ }
934
+ getNumDaysInMonth(date) {
935
+ return this.getDate(this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + 1, 0));
936
+ }
937
+ clone(date) {
938
+ return new Date(date.getTime());
939
+ }
940
+ createDate(year, month, date) {
941
+ if (isDevMode()) {
942
+ // Check for invalid month and date (except upper bound on date which we have to check after
943
+ // creating the Date).
944
+ if (month < 0 || month > 11) {
945
+ throw Error(`Invalid month index "${month}". Month index has to be between 0 and 11.`);
946
+ }
947
+ if (date < 1) {
948
+ throw Error(`Invalid date "${date}". Date has to be greater than 0.`);
949
+ }
950
+ }
951
+ let result = this._createDateWithOverflow(year, month, date);
952
+ // Check that the date wasn't above the upper bound for the month, causing the month to overflow
953
+ if (result.getMonth() != month && isDevMode()) {
954
+ throw Error(`Invalid date "${date}" for month with index "${month}".`);
955
+ }
956
+ return result;
957
+ }
958
+ today() {
959
+ return new Date();
960
+ }
961
+ parse(value, parseFormat) {
962
+ // We have no way using the native JS Date to set the parse format or locale, so we ignore these
963
+ // parameters.
964
+ if (typeof value == 'number') {
965
+ return new Date(value);
966
+ }
967
+ return value ? new Date(Date.parse(value)) : null;
968
+ }
969
+ format(date, displayFormat) {
970
+ if (!this.isValid(date)) {
971
+ throw Error('NativeDateAdapter: Cannot format invalid date.');
972
+ }
973
+ const dtf = new Intl.DateTimeFormat(this.locale, { ...displayFormat, timeZone: 'utc' });
974
+ return this._format(dtf, date);
975
+ }
976
+ addCalendarYears(date, years) {
977
+ return this.addCalendarMonths(date, years * 12);
978
+ }
979
+ addCalendarMonths(date, months) {
980
+ let newDate = this._createDateWithOverflow(this.getYear(date), this.getMonth(date) + months, this.getDate(date));
981
+ // It's possible to wind up in the wrong month if the original month has more days than the new
982
+ // month. In this case we want to go to the last day of the desired month.
983
+ // Note: the additional + 12 % 12 ensures we end up with a positive number, since JS % doesn't
984
+ // guarantee this.
985
+ if (this.getMonth(newDate) != (((this.getMonth(date) + months) % 12) + 12) % 12) {
986
+ newDate = this._createDateWithOverflow(this.getYear(newDate), this.getMonth(newDate), 0);
987
+ }
988
+ return newDate;
989
+ }
990
+ addCalendarDays(date, days) {
991
+ return this._createDateWithOverflow(this.getYear(date), this.getMonth(date), this.getDate(date) + days);
992
+ }
993
+ toIso8601(date) {
994
+ return [
995
+ date.getUTCFullYear(),
996
+ this._2digit(date.getUTCMonth() + 1),
997
+ this._2digit(date.getUTCDate()),
998
+ ].join('-');
999
+ }
1000
+ /**
1001
+ * Returns the given value if given a valid Date or null. Deserializes valid ISO 8601 strings
1002
+ * (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into null. Returns an
1003
+ * invalid date for all other values.
1004
+ */
1005
+ deserialize(value) {
1006
+ if (typeof value === 'string') {
1007
+ if (!value) {
1008
+ return null;
1009
+ }
1010
+ // The `Date` constructor accepts formats other than ISO 8601, so we need to make sure the
1011
+ // string is the right format first.
1012
+ if (ISO_8601_REGEX.test(value)) {
1013
+ let date = new Date(value);
1014
+ if (this.isValid(date)) {
1015
+ return date;
1016
+ }
1017
+ }
1018
+ }
1019
+ return super.deserialize(value);
1020
+ }
1021
+ isDateInstance(obj) {
1022
+ return obj instanceof Date;
1023
+ }
1024
+ isValid(date) {
1025
+ return !isNaN(date.getTime());
1026
+ }
1027
+ invalid() {
1028
+ return new Date(NaN);
1029
+ }
1030
+ setTime(target, hours, minutes, seconds) {
1031
+ if (isDevMode()) {
1032
+ if (!inRange(hours, 0, 23)) {
1033
+ throw Error(`Invalid hours "${hours}". Hours value must be between 0 and 23.`);
1034
+ }
1035
+ if (!inRange(minutes, 0, 59)) {
1036
+ throw Error(`Invalid minutes "${minutes}". Minutes value must be between 0 and 59.`);
1037
+ }
1038
+ if (!inRange(seconds, 0, 59)) {
1039
+ throw Error(`Invalid seconds "${seconds}". Seconds value must be between 0 and 59.`);
1040
+ }
1041
+ }
1042
+ const clone = this.clone(target);
1043
+ clone.setHours(hours, minutes, seconds, 0);
1044
+ return clone;
1045
+ }
1046
+ getHours(date) {
1047
+ return date.getHours();
1048
+ }
1049
+ getMinutes(date) {
1050
+ return date.getMinutes();
1051
+ }
1052
+ getSeconds(date) {
1053
+ return date.getSeconds();
1054
+ }
1055
+ parseTime(userValue, parseFormat) {
1056
+ if (typeof userValue !== 'string') {
1057
+ return userValue instanceof Date ? new Date(userValue.getTime()) : null;
1058
+ }
1059
+ const value = userValue.trim();
1060
+ if (value.length === 0) {
1061
+ return null;
1062
+ }
1063
+ // Attempt to parse the value directly.
1064
+ let result = this._parseTimeString(value);
1065
+ // Some locales add extra characters around the time, but are otherwise parseable
1066
+ // (e.g. `00:05 ч.` in bg-BG). Try replacing all non-number and non-colon characters.
1067
+ if (result === null) {
1068
+ const withoutExtras = value.replace(/[^0-9:(AM|PM)]/gi, '').trim();
1069
+ if (withoutExtras.length > 0) {
1070
+ result = this._parseTimeString(withoutExtras);
1071
+ }
1072
+ }
1073
+ return result || this.invalid();
1074
+ }
1075
+ addSeconds(date, amount) {
1076
+ return new Date(date.getTime() + amount * 1000);
1077
+ }
1078
+ /** Creates a date but allows the month and date to overflow. */
1079
+ _createDateWithOverflow(year, month, date) {
1080
+ // Passing the year to the constructor causes year numbers <100 to be converted to 19xx.
1081
+ // To work around this, we use `setFullYear` and `setHours` instead.
1082
+ const d = new Date();
1083
+ d.setFullYear(year, month, date);
1084
+ d.setHours(0, 0, 0, 0);
1085
+ return d;
1086
+ }
1087
+ /**
1088
+ * Pads a number to make it two digits.
1089
+ * @param n The number to pad.
1090
+ * @returns The padded number.
1091
+ */
1092
+ _2digit(n) {
1093
+ return ('00' + n).slice(-2);
1094
+ }
1095
+ /**
1096
+ * When converting a Date object to string, javascript built-in functions may return wrong
1097
+ * results because it applies its internal DST rules. The DST rules around the world change
1098
+ * very frequently, and the current valid rule is not always valid in previous years though.
1099
+ * We work around this problem building a new Date object which has its internal UTC
1100
+ * representation with the local date and time.
1101
+ * @param dtf Intl.DateTimeFormat object, containing the desired string format. It must have
1102
+ * timeZone set to 'utc' to work fine.
1103
+ * @param date Date from which we want to get the string representation according to dtf
1104
+ * @returns A Date object with its UTC representation based on the passed in date info
1105
+ */
1106
+ _format(dtf, date) {
1107
+ // Passing the year to the constructor causes year numbers <100 to be converted to 19xx.
1108
+ // To work around this, we use `setUTCFullYear` and `setUTCHours` instead.
1109
+ const d = new Date();
1110
+ d.setUTCFullYear(date.getFullYear(), date.getMonth(), date.getDate());
1111
+ d.setUTCHours(date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
1112
+ return dtf.format(d);
1113
+ }
1114
+ /**
1115
+ * Attempts to parse a time string into a date object. Returns null if it cannot be parsed.
1116
+ * @param value Time string to parse.
1117
+ */
1118
+ _parseTimeString(value) {
1119
+ // Note: we can technically rely on the browser for the time parsing by generating
1120
+ // an ISO string and appending the string to the end of it. We don't do it, because
1121
+ // browsers aren't consistent in what they support. Some examples:
1122
+ // - Safari doesn't support AM/PM.
1123
+ // - Firefox produces a valid date object if the time string has overflows (e.g. 12:75) while
1124
+ // other browsers produce an invalid date.
1125
+ // - Safari doesn't allow padded numbers.
1126
+ const parsed = value.toUpperCase().match(TIME_REGEX);
1127
+ if (parsed) {
1128
+ let hours = parseInt(parsed[1]);
1129
+ const minutes = parseInt(parsed[2]);
1130
+ let seconds = parsed[3] == null ? undefined : parseInt(parsed[3]);
1131
+ const amPm = parsed[4];
1132
+ if (hours === 12) {
1133
+ hours = amPm === 'AM' ? 0 : hours;
1134
+ }
1135
+ else if (amPm === 'PM') {
1136
+ hours += 12;
1137
+ }
1138
+ if (inRange(hours, 0, 23) &&
1139
+ inRange(minutes, 0, 59) &&
1140
+ (seconds == null || inRange(seconds, 0, 59))) {
1141
+ return this.setTime(this.today(), hours, minutes, seconds || 0);
1142
+ }
1143
+ }
1144
+ return null;
1145
+ }
1146
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NativeDateAdapter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1147
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NativeDateAdapter }); }
1148
+ }
1149
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NativeDateAdapter, decorators: [{
1150
+ type: Injectable
1151
+ }], ctorParameters: () => [] });
1152
+ /** Checks whether a number is within a certain range. */
1153
+ function inRange(value, min, max) {
1154
+ return !isNaN(value) && value >= min && value <= max;
1155
+ }
1156
+
1157
+ const CUTE_NATIVE_DATE_FORMATS = {
1158
+ parse: {
1159
+ dateInput: null,
1160
+ timeInput: null,
1161
+ },
1162
+ display: {
1163
+ dateInput: { year: 'numeric', month: 'numeric', day: 'numeric' },
1164
+ timeInput: { hour: 'numeric', minute: 'numeric' },
1165
+ monthYearLabel: { year: 'numeric', month: 'short' },
1166
+ dateA11yLabel: { year: 'numeric', month: 'long', day: 'numeric' },
1167
+ monthYearA11yLabel: { year: 'numeric', month: 'long' },
1168
+ timeOptionLabel: { hour: 'numeric', minute: 'numeric' },
1169
+ },
1170
+ };
1171
+
1172
+ class NativeDateModule {
1173
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NativeDateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1174
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: NativeDateModule }); }
1175
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NativeDateModule, providers: [{ provide: DateAdapter, useClass: NativeDateAdapter }] }); }
1176
+ }
1177
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: NativeDateModule, decorators: [{
1178
+ type: NgModule,
1179
+ args: [{
1180
+ providers: [{ provide: DateAdapter, useClass: NativeDateAdapter }],
1181
+ }]
1182
+ }] });
1183
+ class CuteNativeDateModule {
1184
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteNativeDateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1185
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteNativeDateModule }); }
1186
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteNativeDateModule, providers: [provideNativeDateAdapter()] }); }
1187
+ }
1188
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteNativeDateModule, decorators: [{
1189
+ type: NgModule,
1190
+ args: [{
1191
+ providers: [provideNativeDateAdapter()],
1192
+ }]
1193
+ }] });
1194
+ function provideNativeDateAdapter(formats = CUTE_NATIVE_DATE_FORMATS) {
1195
+ return [
1196
+ { provide: DateAdapter, useClass: NativeDateAdapter },
1197
+ { provide: CUTE_DATE_FORMATS, useValue: formats },
1198
+ ];
1199
+ }
1200
+
1201
+ /**
1202
+ * @license Apache-2.0
1203
+ *
1204
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
1205
+ *
1206
+ * You may not use this file except in compliance with the License
1207
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
1208
+ */
1209
+ /**
1210
+ * Bypass security and trust the given value to be a safe resource.
1211
+ * > WARNING: calling this method with untrusted user data exposes your application to XSS security risks!
1212
+ * @example
1213
+ * ```html
1214
+ * <img [src]="item.source | safe:'url'" alt="Item image"/>
1215
+ * ```
1216
+ */
1217
+ class CuteSafePipe {
1218
+ constructor() {
1219
+ this.sanitizer = inject(DomSanitizer);
1220
+ }
1221
+ transform(value, type = "html") {
1222
+ if (typeof value === "string") {
1223
+ switch (type.toLowerCase()) {
1224
+ case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
1225
+ case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
1226
+ case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
1227
+ case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
1228
+ case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
1229
+ default: throw new Error(`Invalid safe type specified: ${type}`);
1230
+ }
1231
+ }
1232
+ return "";
1233
+ }
1234
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSafePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1235
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteSafePipe, isStandalone: true, name: "safe" }); }
1236
+ }
1237
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSafePipe, decorators: [{
1238
+ type: Pipe,
1239
+ args: [{
1240
+ name: 'safe'
1241
+ }]
1242
+ }] });
1243
+
1244
+ /**
1245
+ * @license Apache-2.0
1246
+ *
1247
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
1248
+ *
1249
+ * You may not use this file except in compliance with the License
1250
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
1251
+ */
1252
+ /**
1253
+ * Gets a safe value from either a known safe value or a value with unknown safety.
1254
+ *
1255
+ * @example
1256
+ * ```html
1257
+ * <div [innerHTML]="item.htmlContent | sanitize:'html'"></div>
1258
+ * ```
1259
+ */
1260
+ class CuteSanitizePipe {
1261
+ constructor() {
1262
+ this.sanitizer = inject(DomSanitizer);
1263
+ }
1264
+ transform(value, context = 'html') {
1265
+ if (typeof value === "string") {
1266
+ switch (context.toLowerCase()) {
1267
+ case 'html': return this.sanitizer.sanitize(SecurityContext.HTML, value);
1268
+ case 'style': return this.sanitizer.sanitize(SecurityContext.STYLE, value);
1269
+ case 'script': return this.sanitizer.sanitize(SecurityContext.SCRIPT, value);
1270
+ case 'url': return this.sanitizer.sanitize(SecurityContext.URL, value);
1271
+ case 'resourceUrl': return this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, value);
1272
+ case 'none': return this.sanitizer.sanitize(SecurityContext.NONE, value);
1273
+ default: throw new Error(`Invalid security context specified: ${context}`);
1274
+ }
1275
+ }
1276
+ return "";
1277
+ }
1278
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSanitizePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
1279
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.15", ngImport: i0, type: CuteSanitizePipe, isStandalone: true, name: "sanitize" }); }
1280
+ }
1281
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteSanitizePipe, decorators: [{
1282
+ type: Pipe,
1283
+ args: [{
1284
+ name: 'sanitize'
1285
+ }]
1286
+ }] });
1287
+
1288
+ /**
1289
+ * @license Apache-2.0
1290
+ *
1291
+ * Copyright (c) 2025 CuteWidgets Team. All Rights Reserved.
1292
+ *
1293
+ * You may not use this file except in compliance with the License
1294
+ * that can be found at http://www.apache.org/licenses/LICENSE-2.0
1295
+ */
1296
+ /**
1297
+ * `CuteWidgets` supports standard Bootstrap 5 theme colors - `ThemeColor` type. But to account
1298
+ * miscellaneous use cases of usage this colors in components CuteWidgets add extended definition of
1299
+ * latter - `RichThemeColor`. Rich color is the standard color name plus "-emphasis" or "-contrast" suffix at the end.
1300
+ * Depending on the context of applying color, the result CSS-class can be `.text-*`, `.text-bg-*` or ended with
1301
+ * `-emphasis` or `-subtle` suffixes.
1302
+ */
1303
+ /** Bootstrap theme colors */
1304
+ const Palette = ["primary", "secondary", "success", "danger", "warning", "info", "light", "dark", "link", "tertiary"];
1305
+ /**
1306
+ * Whether a string is a valid theme color name
1307
+ * @param str Text case-sensitive value
1308
+ * @returns _true_ if `str` is a valid color name, otherwise _false_
1309
+ */
1310
+ function isThemeColor(str) {
1311
+ if (str) {
1312
+ return Palette.indexOf(str) !== -1;
1313
+ }
1314
+ return false;
1315
+ }
1316
+ /**
1317
+ * Whether a string is a valid rich or base theme color name.
1318
+ * @param str Case-sensitive text value of the color name.
1319
+ * @returns _true_ if `str` is a valid rich color name, otherwise _false_.
1320
+ */
1321
+ function isRichThemeColor(str) {
1322
+ if (str) {
1323
+ if (isExtendedColor(str)) {
1324
+ str = getBaseColor(str);
1325
+ }
1326
+ return isThemeColor(str);
1327
+ }
1328
+ return false;
1329
+ }
1330
+ /**
1331
+ * Transforms a string to `ThemeColor` type.
1332
+ * @param color Color value to transform
1333
+ * @returns _ThemeColor_'s value or _undefined_, if the `color` has an invalid value.
1334
+ */
1335
+ function toThemeColor(color) {
1336
+ if (typeof color === "string") {
1337
+ color = color.trim().toLowerCase();
1338
+ if (isExtendedColor(color)) {
1339
+ color = getBaseColor(color);
1340
+ }
1341
+ if (isThemeColor(color)) {
1342
+ return color;
1343
+ }
1344
+ }
1345
+ return undefined;
1346
+ }
1347
+ /**
1348
+ * To `_RichThemeColor_` transformer function.
1349
+ * @param color Color value to transform into rich color type.
1350
+ * @returns _RichThemeColor_ value or _undefined_ if `color` is invalid.
1351
+ */
1352
+ function toRichThemeColor(color) {
1353
+ if (typeof color === "string") {
1354
+ color = color.trim().toLowerCase();
1355
+ if (isRichThemeColor(color)) {
1356
+ return color;
1357
+ }
1358
+ }
1359
+ return undefined;
1360
+ }
1361
+ /**
1362
+ * Returns a valid Bootstrap's `.text-*` CSS class.
1363
+ * @param color Color palette to transform into CSS-class.
1364
+ */
1365
+ function toTextCssClass(color) {
1366
+ const richThemeColor = toRichThemeColor(color);
1367
+ if (richThemeColor) {
1368
+ if (richThemeColor.startsWith("tertiary")) {
1369
+ // Bootstrap 5 has no ".text-tertiary-*" classes, so we return following
1370
+ return "text-body-tertiary";
1371
+ }
1372
+ let themeColor;
1373
+ if (isExtendedColor(richThemeColor)) {
1374
+ themeColor = getBaseColor(richThemeColor);
1375
+ if (richThemeColor.endsWith("-emphasis")) {
1376
+ return `text-${themeColor}-emphasis`;
1377
+ }
1378
+ // contrast
1379
+ return `text-bg-${themeColor}`;
1380
+ }
1381
+ themeColor = richThemeColor;
1382
+ return `text-${themeColor}`;
1383
+ }
1384
+ return "";
1385
+ }
1386
+ /**
1387
+ * Returns a valid Bootstrap's `.bg-*` or `.text-bg-*` CSS class name.
1388
+ * @param color Value to transform into CSS-class.
1389
+ */
1390
+ function toBgCssClass(color) {
1391
+ const richThemeColor = toRichThemeColor(color);
1392
+ if (richThemeColor) {
1393
+ if (richThemeColor.startsWith("tertiary")) {
1394
+ // Bootstrap 5 has no 'tertiary-subtle'/'bg-tertiary' classes, so we return following
1395
+ return "bg-body-tertiary";
1396
+ }
1397
+ let themeColor;
1398
+ if (isExtendedColor(richThemeColor)) {
1399
+ themeColor = getBaseColor(richThemeColor);
1400
+ if (richThemeColor.endsWith("-emphasis")) {
1401
+ return `bg-${themeColor}-subtle`;
1402
+ }
1403
+ // contrast
1404
+ return `text-bg-${themeColor}`;
1405
+ }
1406
+ themeColor = richThemeColor;
1407
+ // Simple background
1408
+ return `bg-${themeColor}`;
1409
+ }
1410
+ return "";
1411
+ }
1412
+ /**
1413
+ * Set a background color with contrasting foreground color.
1414
+ * @param color Color palette to transform into CSS-class.
1415
+ * @returns A valid Bootstrap's `.text-bg-*` CSS-class
1416
+ */
1417
+ function toTextBgCssClass(color) {
1418
+ const richThemeColor = toRichThemeColor(color);
1419
+ if (richThemeColor) {
1420
+ if (richThemeColor.startsWith("tertiary")) {
1421
+ return "text-body-tertiary";
1422
+ }
1423
+ let themeColor;
1424
+ if (isExtendedColor(richThemeColor)) {
1425
+ themeColor = getBaseColor(richThemeColor);
1426
+ }
1427
+ else {
1428
+ themeColor = richThemeColor;
1429
+ }
1430
+ return "text-bg-" + themeColor;
1431
+ }
1432
+ return "";
1433
+ }
1434
+ /**
1435
+ * Returns a valid Bootstrap's `.text-*` or `.text-bg-*` CSS class.
1436
+ * @param color Color value to transform into CSS-class.
1437
+ */
1438
+ function toColorCssClass(color) {
1439
+ if (color) {
1440
+ if (color.endsWith("-contrast")) {
1441
+ return toTextBgCssClass(color);
1442
+ }
1443
+ return toTextCssClass(color);
1444
+ }
1445
+ return "";
1446
+ }
1447
+ /**
1448
+ * Extracts `ThemeColor` from the `RichThemeColor`.
1449
+ * @param color Rich color
1450
+ * @returns Base theme color.
1451
+ * @internal
1452
+ */
1453
+ function getBaseColor(color) {
1454
+ let dashPos = color.indexOf("-");
1455
+ if (dashPos >= 0) {
1456
+ return color.slice(0, dashPos);
1457
+ }
1458
+ return color;
1459
+ }
1460
+ /** Whether the specified color is extended counterpart of the standard palette color. */
1461
+ function isExtendedColor(color) {
1462
+ return color.endsWith("-emphasis") || color.endsWith("-contrast");
1463
+ }
1464
+ const CUTE_THEME_COLOR = new InjectionToken("CUTE_THEME_COLOR");
1465
+ class CuteThemeColor /* extends ... */ {
1466
+ colorClass() {
1467
+ return toColorCssClass(this.color);
1468
+ }
1469
+ bgClass() {
1470
+ return toBgCssClass(this.color);
1471
+ }
1472
+ textBgClass() {
1473
+ return toTextBgCssClass(this.color);
1474
+ }
1475
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteThemeColor /* extends ... */, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1476
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.15", type: CuteThemeColor /* extends ... */, isStandalone: true, selector: "[cuteThemeColor]", inputs: { color: ["cuteThemeColor", "color"] }, providers: [{ provide: CUTE_THEME_COLOR, useExisting: CuteThemeColor }], exportAs: ["cuteThemeColor"], ngImport: i0 }); }
1477
+ }
1478
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteThemeColor /* extends ... */, decorators: [{
1479
+ type: Directive,
1480
+ args: [{
1481
+ selector: '[cuteThemeColor]',
1482
+ exportAs: 'cuteThemeColor',
1483
+ host: {},
1484
+ providers: [{ provide: CUTE_THEME_COLOR, useExisting: CuteThemeColor }],
1485
+ }]
1486
+ }], propDecorators: { color: [{
1487
+ type: Input,
1488
+ args: ["cuteThemeColor"]
1489
+ }] } });
1490
+
1491
+ const PREFERS_COLOR_SCHEME = '(prefers-color-scheme: dark)';
1492
+ const THEME_ATTR_NAME = "data-bs-theme";
1493
+ class CuteThemeService {
1494
+ constructor() {
1495
+ this._document = inject(DOCUMENT);
1496
+ this._mediaChange = new Subject();
1497
+ /** Observable that can be used to receive `MediaMatcher`'s _change_ event. */
1498
+ this.change = this._mediaChange.asObservable();
1499
+ const mediaMatcher = inject(MediaMatcher);
1500
+ this._mediaQueryList = mediaMatcher.matchMedia(PREFERS_COLOR_SCHEME);
1501
+ fromEvent(this._mediaQueryList, "change")
1502
+ .pipe(takeUntilDestroyed())
1503
+ .subscribe(event => {
1504
+ const storedTheme = this.getStoredTheme();
1505
+ if (storedTheme !== 'light' && storedTheme !== 'dark') {
1506
+ this.setTheme(this.getPreferredTheme(), false);
1507
+ }
1508
+ this._mediaChange.next(event);
1509
+ });
1510
+ fromEvent(window, "DOMContentLoaded")
1511
+ .pipe(takeUntilDestroyed())
1512
+ .subscribe(() => {
1513
+ this.setTheme(this.getPreferredTheme());
1514
+ });
1515
+ }
1516
+ getStoredTheme() {
1517
+ const theme = localStorage.getItem('theme');
1518
+ if (theme && ["light", "dark", "auto"].includes(theme)) {
1519
+ return theme;
1520
+ }
1521
+ return null;
1522
+ }
1523
+ setStoredTheme(theme) {
1524
+ return localStorage.setItem('theme', theme);
1525
+ }
1526
+ /** Returns the user's preferred color mode. */
1527
+ getPreferredTheme() {
1528
+ const storedTheme = this.getStoredTheme();
1529
+ if (storedTheme) {
1530
+ return storedTheme;
1531
+ }
1532
+ return this.getCurrentTheme();
1533
+ }
1534
+ /** Returns the browser's color theme. */
1535
+ getCurrentTheme() {
1536
+ return this._mediaQueryList.matches ? 'dark' : 'light';
1537
+ }
1538
+ /** Whether is the dark theme currently selected. */
1539
+ isDarkTheme() {
1540
+ return this.getTheme() == "dark";
1541
+ }
1542
+ /** Whether is the light theme currently selected. */
1543
+ isLightTheme() {
1544
+ return !this.isDarkTheme();
1545
+ }
1546
+ /** Returns the Bootstrap's color theme. */
1547
+ getTheme() {
1548
+ const docElem = this._document.documentElement;
1549
+ let attrValue = docElem.getAttribute(THEME_ATTR_NAME);
1550
+ if (attrValue == null) {
1551
+ attrValue = this.getCurrentTheme();
1552
+ }
1553
+ return attrValue;
1554
+ }
1555
+ /**
1556
+ * Changes the default color mode (theme) of all pages in the website with the opportunity of auto-detection.
1557
+ * @param theme Desired color theme.
1558
+ * @param emitEvent Emulate event emitting. Default is _true_.
1559
+ */
1560
+ setTheme(theme, emitEvent = true) {
1561
+ const docElem = this._document.documentElement;
1562
+ let matches;
1563
+ if (theme === 'auto') {
1564
+ matches = this._mediaQueryList.matches;
1565
+ docElem.setAttribute(THEME_ATTR_NAME, (matches ? 'dark' : 'light'));
1566
+ }
1567
+ else {
1568
+ matches = (theme === "dark");
1569
+ docElem.setAttribute(THEME_ATTR_NAME, theme);
1570
+ }
1571
+ this.setStoredTheme(theme);
1572
+ if (emitEvent) {
1573
+ // dispatch artificial (not trusted) change event
1574
+ this._mediaQueryList.dispatchEvent(new MediaQueryListEvent("change", { matches, media: this._mediaQueryList.media }));
1575
+ }
1576
+ }
1577
+ ngOnDestroy() {
1578
+ this._mediaChange.complete();
1579
+ }
1580
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteThemeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1581
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteThemeService, providedIn: "root" }); }
1582
+ }
1583
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: CuteThemeService, decorators: [{
1584
+ type: Injectable,
1585
+ args: [{
1586
+ providedIn: "root"
1587
+ }]
1588
+ }], ctorParameters: () => [] });
1589
+
1590
+ /*
1591
+ * Core API Surface of widgets
1592
+ */
1593
+ //export * from './event-plugins';
1594
+
1595
+ /**
1596
+ * Generated bundle index. Do not edit.
1597
+ */
1598
+
1599
+ export { AnimationCurves, AnimationDurations, CUTE_DATE_FORMATS, CUTE_DATE_LOCALE, CUTE_DATE_LOCALE_FACTORY, CUTE_NATIVE_DATE_FORMATS, CUTE_THEME_COLOR, CUTE_WIDGETS_ANIMATIONS, CuteLine, CuteLineModule, CuteNativeDateModule, CuteRipple, CuteSafePipe, CuteSanitizePipe, CuteThemeColor, CuteThemeService, DateAdapter, IdGenerator, NativeDateAdapter, NativeDateModule, Ripple, RippleManager, Scheduler, _animationsDisabled, _getAnimationsState, bsBreakpoints, createFactoryToken, createValueToken, exportToCSV, exportToExcel, getOverallTransitionDuration, getTransitionDelay, getTransitionDuration, isRichThemeColor, isThemeColor, provideNativeDateAdapter, saveAs, setLines, toBgCssClass, toColorCssClass, toRichThemeColor, toTextBgCssClass, toTextCssClass, toThemeColor };
1600
+ //# sourceMappingURL=cute-widgets-base-core.mjs.map