@cuby-ui/cdk 0.0.180 → 0.0.182

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 (141) hide show
  1. package/constants/empty.d.ts +10 -0
  2. package/constants/handlers.d.ts +8 -0
  3. package/constants/index.d.ts +2 -0
  4. package/directives/active-zone/active-zone.directive.d.ts +22 -0
  5. package/directives/active-zone/index.d.ts +1 -0
  6. package/directives/hovered/hovered.directive.d.ts +7 -0
  7. package/directives/hovered/hovered.service.d.ts +12 -0
  8. package/directives/hovered/index.d.ts +2 -0
  9. package/directives/index.d.ts +2 -0
  10. package/directives/let.directive.d.ts +1 -1
  11. package/directives/target.directive.d.ts +1 -1
  12. package/esm2022/constants/empty.mjs +24 -0
  13. package/esm2022/constants/handlers.mjs +11 -0
  14. package/esm2022/constants/index.mjs +4 -0
  15. package/esm2022/directives/active-zone/active-zone.directive.mjs +72 -0
  16. package/esm2022/directives/active-zone/index.mjs +2 -0
  17. package/{esm2020 → esm2022}/directives/auto-resizing.directive.mjs +4 -4
  18. package/{esm2020 → esm2022}/directives/click-outside.directive.mjs +4 -4
  19. package/{esm2020 → esm2022}/directives/content-editable-value-accessor.directive.mjs +4 -4
  20. package/{esm2020 → esm2022}/directives/dimensions-observer.directive.mjs +4 -4
  21. package/{esm2020 → esm2022}/directives/element.directive.mjs +4 -4
  22. package/{esm2020 → esm2022}/directives/focus-trap.directive.mjs +4 -4
  23. package/esm2022/directives/hovered/hovered.directive.mjs +21 -0
  24. package/esm2022/directives/hovered/hovered.service.mjs +34 -0
  25. package/esm2022/directives/hovered/index.mjs +3 -0
  26. package/esm2022/directives/index.mjs +13 -0
  27. package/{esm2020 → esm2022}/directives/item.directive.mjs +4 -4
  28. package/{esm2020 → esm2022}/directives/let.directive.mjs +4 -4
  29. package/{esm2020 → esm2022}/directives/target.directive.mjs +4 -4
  30. package/esm2022/observables/if-map.mjs +5 -0
  31. package/esm2022/observables/index.mjs +5 -0
  32. package/esm2022/observables/typed-from-event.mjs +9 -0
  33. package/esm2022/observables/watch.mjs +6 -0
  34. package/esm2022/observables/zone.mjs +34 -0
  35. package/{esm2020 → esm2022}/pipes/filter.pipe.mjs +4 -4
  36. package/{esm2020 → esm2022}/services/destroy.service.mjs +4 -4
  37. package/esm2022/services/id.service.mjs +18 -0
  38. package/{esm2020 → esm2022}/services/popover.service.mjs +4 -4
  39. package/esm2022/tokens/active-element.mjs +54 -0
  40. package/esm2022/tokens/environment.mjs +45 -0
  41. package/esm2022/tokens/index.mjs +10 -0
  42. package/esm2022/tokens/navigator.mjs +6 -0
  43. package/esm2022/tokens/removed-element.mjs +19 -0
  44. package/esm2022/tokens/user-agent.mjs +6 -0
  45. package/esm2022/types/context.mjs +2 -0
  46. package/esm2022/types/handler.mjs +2 -0
  47. package/esm2022/types/index.mjs +9 -0
  48. package/esm2022/utils/dom/element-checks.mjs +20 -0
  49. package/esm2022/utils/dom/get-actual-target.mjs +7 -0
  50. package/esm2022/utils/dom/get-document-or-shadow-root.mjs +6 -0
  51. package/esm2022/utils/dom/get-element-obscurers.mjs +44 -0
  52. package/esm2022/utils/dom/index.mjs +7 -0
  53. package/esm2022/utils/dom/inject-element.mjs +5 -0
  54. package/esm2022/utils/index.mjs +7 -0
  55. package/esm2022/utils/math/clamp.mjs +11 -0
  56. package/esm2022/utils/math/index.mjs +2 -0
  57. package/esm2022/utils/miscellaneous/array-remove.mjs +4 -0
  58. package/esm2022/utils/miscellaneous/index.mjs +5 -0
  59. package/esm2022/utils/miscellaneous/is-present.mjs +4 -0
  60. package/esm2022/utils/miscellaneous/pure.mjs +81 -0
  61. package/esm2022/utils/miscellaneous/px.mjs +7 -0
  62. package/esm2022/utils/platform/index.mjs +2 -0
  63. package/esm2022/utils/platform/is-ios.mjs +6 -0
  64. package/fesm2022/cuby-ui-cdk.mjs +1067 -0
  65. package/fesm2022/cuby-ui-cdk.mjs.map +1 -0
  66. package/observables/if-map.d.ts +3 -0
  67. package/observables/index.d.ts +4 -0
  68. package/observables/typed-from-event.d.ts +16 -0
  69. package/observables/watch.d.ts +3 -0
  70. package/observables/zone.d.ts +7 -0
  71. package/package.json +10 -15
  72. package/tokens/active-element.d.ts +5 -0
  73. package/tokens/environment.d.ts +19 -0
  74. package/tokens/index.d.ts +5 -0
  75. package/tokens/navigator.d.ts +2 -0
  76. package/tokens/removed-element.d.ts +4 -0
  77. package/tokens/user-agent.d.ts +2 -0
  78. package/types/context.d.ts +3 -0
  79. package/types/handler.d.ts +4 -0
  80. package/types/index.d.ts +2 -0
  81. package/utils/dom/element-checks.d.ts +6 -0
  82. package/utils/dom/get-actual-target.d.ts +4 -0
  83. package/utils/dom/get-document-or-shadow-root.d.ts +1 -0
  84. package/utils/dom/get-element-obscurers.d.ts +9 -0
  85. package/utils/dom/index.d.ts +5 -1
  86. package/utils/dom/inject-element.d.ts +1 -0
  87. package/utils/index.d.ts +3 -0
  88. package/utils/math/clamp.d.ts +8 -0
  89. package/utils/math/index.d.ts +1 -0
  90. package/utils/miscellaneous/array-remove.d.ts +1 -0
  91. package/utils/miscellaneous/index.d.ts +4 -0
  92. package/utils/miscellaneous/is-present.d.ts +1 -0
  93. package/utils/miscellaneous/pure.d.ts +21 -0
  94. package/utils/miscellaneous/px.d.ts +4 -0
  95. package/utils/platform/index.d.ts +1 -0
  96. package/utils/platform/is-ios.d.ts +3 -0
  97. package/esm2020/constants/index.mjs +0 -2
  98. package/esm2020/directives/index.mjs +0 -11
  99. package/esm2020/services/id.service.mjs +0 -18
  100. package/esm2020/tokens/index.mjs +0 -5
  101. package/esm2020/types/index.mjs +0 -7
  102. package/esm2020/utils/dom/index.mjs +0 -3
  103. package/esm2020/utils/dom/is-html-element.mjs +0 -4
  104. package/esm2020/utils/index.mjs +0 -4
  105. package/fesm2015/cuby-ui-cdk.mjs +0 -572
  106. package/fesm2015/cuby-ui-cdk.mjs.map +0 -1
  107. package/fesm2020/cuby-ui-cdk.mjs +0 -579
  108. package/fesm2020/cuby-ui-cdk.mjs.map +0 -1
  109. package/utils/dom/is-html-element.d.ts +0 -1
  110. /package/{esm2020 → esm2022}/constants/svg-node-filter.mjs +0 -0
  111. /package/{esm2020 → esm2022}/cuby-ui-cdk.mjs +0 -0
  112. /package/{esm2020 → esm2022}/date-time/index.mjs +0 -0
  113. /package/{esm2020 → esm2022}/date-time/time.mjs +0 -0
  114. /package/{esm2020 → esm2022}/directives/let.context.mjs +0 -0
  115. /package/{esm2020 → esm2022}/index.mjs +0 -0
  116. /package/{esm2020 → esm2022}/interfaces/dimensions.mjs +0 -0
  117. /package/{esm2020 → esm2022}/interfaces/index.mjs +0 -0
  118. /package/{esm2020 → esm2022}/interfaces/on-change.mjs +0 -0
  119. /package/{esm2020 → esm2022}/interfaces/on-touched.mjs +0 -0
  120. /package/{esm2020 → esm2022}/pipes/index.mjs +0 -0
  121. /package/{esm2020 → esm2022}/services/index.mjs +0 -0
  122. /package/{esm2020 → esm2022}/tokens/history.mjs +0 -0
  123. /package/{esm2020 → esm2022}/tokens/local-storage.mjs +0 -0
  124. /package/{esm2020 → esm2022}/tokens/session-storage.mjs +0 -0
  125. /package/{esm2020 → esm2022}/tokens/window.mjs +0 -0
  126. /package/{esm2020 → esm2022}/types/date-time.mjs +0 -0
  127. /package/{esm2020 → esm2022}/types/input-type.mjs +0 -0
  128. /package/{esm2020 → esm2022}/types/mapper.mjs +0 -0
  129. /package/{esm2020 → esm2022}/types/matcher.mjs +0 -0
  130. /package/{esm2020 → esm2022}/types/nullable.mjs +0 -0
  131. /package/{esm2020 → esm2022}/types/value-of.mjs +0 -0
  132. /package/{esm2020 → esm2022}/utils/dom/contains-or-after.mjs +0 -0
  133. /package/{esm2020 → esm2022}/utils/focus/blur-native-focused.mjs +0 -0
  134. /package/{esm2020 → esm2022}/utils/focus/get-closest-focusable.mjs +0 -0
  135. /package/{esm2020 → esm2022}/utils/focus/get-native-focused.mjs +0 -0
  136. /package/{esm2020 → esm2022}/utils/focus/index.mjs +0 -0
  137. /package/{esm2020 → esm2022}/utils/focus/is-native-keyboard-focusable.mjs +0 -0
  138. /package/{esm2020 → esm2022}/utils/focus/is-native-mouse-focusable.mjs +0 -0
  139. /package/{esm2020 → esm2022}/utils/token/create-token.mjs +0 -0
  140. /package/{esm2020 → esm2022}/utils/token/index.mjs +0 -0
  141. /package/{esm2020 → esm2022}/utils/token/provide.mjs +0 -0
@@ -1,579 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, Injectable, ElementRef, Directive, HostListener, EventEmitter, Output, HostBinding, ViewContainerRef, TemplateRef, Input, Pipe } from '@angular/core';
3
- import { NgControl, NgModel, NG_VALUE_ACCESSOR } from '@angular/forms';
4
- import { Subject, Observable, takeUntil } from 'rxjs';
5
- import { DOCUMENT } from '@angular/common';
6
-
7
- const svgNodeFilter = {
8
- acceptNode(node) {
9
- return 'ownerSVGElement' in node
10
- ? NodeFilter.FILTER_REJECT
11
- : NodeFilter.FILTER_ACCEPT;
12
- },
13
- };
14
-
15
- class CuiTime {
16
- constructor(hours, minutes, seconds = 0, ms = 0) {
17
- this.hours = hours;
18
- this.minutes = minutes;
19
- this.seconds = seconds;
20
- this.ms = ms;
21
- }
22
- static fromString(time) {
23
- const hours = this.parseHours(time);
24
- const minutes = Number(time.slice(3, 5)) || 0;
25
- const seconds = Number(time.slice(6, 8)) || 0;
26
- const ms = Number(time.slice(9, 12)) || 0;
27
- return new CuiTime(hours, minutes, seconds, ms);
28
- }
29
- static fromPT(time) {
30
- let duration = time.trim().toUpperCase();
31
- if (!duration.startsWith('P')) {
32
- throw new Error('Invalid PT format: does not start with P');
33
- }
34
- duration = duration.substring(1);
35
- if (duration.startsWith('T')) {
36
- duration = duration.substring(1);
37
- }
38
- const regex = /(\d+(\.\d+)?)([HMS])/g;
39
- let match;
40
- let hours = 0, minutes = 0, seconds = 0, ms = 0;
41
- while ((match = regex.exec(duration)) !== null) {
42
- const value = parseFloat(match[1]);
43
- const unit = match[3];
44
- if (unit === 'H') {
45
- hours = value;
46
- }
47
- else if (unit === 'M') {
48
- minutes = value;
49
- }
50
- else if (unit === 'S') {
51
- seconds = Math.floor(value);
52
- ms = Math.round((value - seconds) * 1000);
53
- }
54
- }
55
- return new CuiTime(hours, minutes, seconds, ms);
56
- }
57
- static parseHours(time) {
58
- return Number(time.slice(0, 2));
59
- }
60
- toString(mode) {
61
- const needAddMs = mode?.startsWith('HH:MM:SS.MSS') || (!mode && this.ms > 0);
62
- const needAddSeconds = needAddMs || mode?.startsWith('HH:MM:SS') || (!mode && this.seconds > 0);
63
- const hhMm = `${this.formatTime(this.hours)}:${this.formatTime(this.minutes)}`;
64
- const ss = needAddSeconds ? `:${this.formatTime(this.seconds)}` : '';
65
- const mss = needAddMs ? `.${this.formatTime(this.ms, 3)}` : '';
66
- return `${hhMm}${ss}${mss}`;
67
- }
68
- toPT(mode) {
69
- let duration = 'PT';
70
- if (this.hours !== 0) {
71
- duration += `${this.hours}H`;
72
- }
73
- if (this.minutes !== 0) {
74
- duration += `${this.minutes}M`;
75
- }
76
- const totalSeconds = this.seconds + this.ms / 1000;
77
- if (totalSeconds !== 0 || duration === 'PT') {
78
- duration += `${parseFloat(totalSeconds.toFixed(3))}S`;
79
- }
80
- return duration;
81
- }
82
- formatTime(time, digits = 2) {
83
- return String(time).padStart(digits, '0');
84
- }
85
- }
86
-
87
- function cuiCreateToken(defaults) {
88
- return cuiCreateTokenFromFactory(() => defaults);
89
- }
90
- function cuiCreateTokenFromFactory(factory) {
91
- return new InjectionToken('', { factory });
92
- }
93
-
94
- function cuiProvide(provide, useExisting, multi = false) {
95
- return { provide, useExisting, multi };
96
- }
97
-
98
- const CUI_WINDOW = cuiCreateTokenFromFactory(() => {
99
- const { defaultView } = inject(DOCUMENT);
100
- if (!defaultView) {
101
- throw new Error('Window is not available');
102
- }
103
- return defaultView;
104
- });
105
-
106
- const CUI_HISTORY = cuiCreateTokenFromFactory(() => inject(CUI_WINDOW).history);
107
-
108
- const CUI_LOCAL_STORAGE = cuiCreateTokenFromFactory(() => inject(CUI_WINDOW).localStorage);
109
-
110
- const CUI_SESSION_STORAGE = cuiCreateTokenFromFactory(() => inject(CUI_WINDOW).sessionStorage);
111
-
112
- class CuiDestroyService extends Subject {
113
- ngOnDestroy() {
114
- this.next();
115
- this.complete();
116
- }
117
- }
118
- CuiDestroyService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiDestroyService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
119
- CuiDestroyService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiDestroyService });
120
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiDestroyService, decorators: [{
121
- type: Injectable
122
- }] });
123
-
124
- const CUI = 'cui_';
125
- class CuiIdService {
126
- generate() {
127
- return `${CUI}${CuiIdService.autoId++}${Date.now()}`;
128
- }
129
- }
130
- CuiIdService.autoId = 0;
131
- CuiIdService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiIdService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
132
- CuiIdService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiIdService, providedIn: 'root' });
133
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiIdService, decorators: [{
134
- type: Injectable,
135
- args: [{
136
- providedIn: 'root'
137
- }]
138
- }] });
139
-
140
- class CuiPopoverService {
141
- constructor(items, component, options = {}) {
142
- this.options = options;
143
- this.cuiIdService = inject(CuiIdService);
144
- this.items$ = inject(items);
145
- this.component = component;
146
- }
147
- open(content, options = {}) {
148
- return new Observable(observer => {
149
- const item = {
150
- ...this.options,
151
- ...options,
152
- $implicit: observer,
153
- id: this.cuiIdService.generate(),
154
- component: this.component,
155
- content: content,
156
- completeWith: (result) => {
157
- observer.next(result);
158
- observer.complete();
159
- },
160
- };
161
- this.items$.next([...this.items$.value, item]);
162
- return () => {
163
- this.items$.next(this.items$.value.filter(value => value !== item));
164
- };
165
- });
166
- }
167
- closeAll() {
168
- this.items$.next([]);
169
- }
170
- }
171
- CuiPopoverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiPopoverService, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
172
- CuiPopoverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiPopoverService });
173
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiPopoverService, decorators: [{
174
- type: Injectable
175
- }], ctorParameters: function () { return [{ type: undefined }, { type: undefined }, { type: undefined }]; } });
176
-
177
- class CuiAutoResizingDirective {
178
- constructor() {
179
- this.window = inject(CUI_WINDOW);
180
- this.element = inject(ElementRef).nativeElement;
181
- this.ngControl = inject(NgControl, { self: true, optional: true });
182
- this.ngModel = inject(NgModel, { self: true, optional: true });
183
- this.destroy$ = inject(CuiDestroyService, { self: true });
184
- this.elementStyles = this.element.style;
185
- }
186
- ngOnInit() {
187
- this.initNgControlValueChangeSubscription();
188
- this.initNgModelValueChangeSubscription();
189
- }
190
- ngAfterViewChecked() {
191
- this.resize();
192
- }
193
- onInput() {
194
- this.resize();
195
- }
196
- initNgControlValueChangeSubscription() {
197
- if (!this.ngControl) {
198
- return;
199
- }
200
- this.ngControl.valueChanges
201
- .pipe(takeUntil(this.destroy$))
202
- .subscribe(this.resize.bind(this));
203
- }
204
- initNgModelValueChangeSubscription() {
205
- if (!this.ngModel) {
206
- return;
207
- }
208
- this.ngModel.valueChanges
209
- .pipe(takeUntil(this.destroy$))
210
- .subscribe(this.resize.bind(this));
211
- }
212
- resize() {
213
- const { maxHeight: computedMaxHeight, borderTopWidth, borderBottomWidth } = this.window.getComputedStyle(this.element);
214
- this.elementStyles.height = 'auto';
215
- this.elementStyles.height =
216
- this.element.scrollHeight + parseFloat(borderTopWidth) + parseFloat(borderBottomWidth) + 'px';
217
- if (parseFloat(this.element.style.height) < parseFloat(computedMaxHeight)) {
218
- this.elementStyles.overflow = 'hidden';
219
- return;
220
- }
221
- this.elementStyles.overflowY = 'scroll';
222
- this.elementStyles.height = computedMaxHeight;
223
- }
224
- }
225
- CuiAutoResizingDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiAutoResizingDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
226
- CuiAutoResizingDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiAutoResizingDirective, isStandalone: true, selector: "textarea[cuiAutoResizing]", host: { listeners: { "input": "onInput()" } }, providers: [CuiDestroyService], ngImport: i0 });
227
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiAutoResizingDirective, decorators: [{
228
- type: Directive,
229
- args: [{
230
- standalone: true,
231
- selector: 'textarea[cuiAutoResizing]',
232
- providers: [CuiDestroyService]
233
- }]
234
- }], propDecorators: { onInput: [{
235
- type: HostListener,
236
- args: ['input']
237
- }] } });
238
-
239
- class CuiClickOutsideDirective {
240
- constructor() {
241
- this.element = inject(ElementRef).nativeElement;
242
- this.cuiClickOutside = new EventEmitter();
243
- }
244
- onClickOutside(target) {
245
- if (this.element.contains(target)) {
246
- return;
247
- }
248
- this.cuiClickOutside.emit(target);
249
- }
250
- }
251
- CuiClickOutsideDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiClickOutsideDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
252
- CuiClickOutsideDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiClickOutsideDirective, isStandalone: true, selector: "(cuiClickOutside)", outputs: { cuiClickOutside: "cuiClickOutside" }, host: { listeners: { "document:click": "onClickOutside($event.target)" } }, ngImport: i0 });
253
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiClickOutsideDirective, decorators: [{
254
- type: Directive,
255
- args: [{
256
- standalone: true,
257
- selector: '(cuiClickOutside)'
258
- }]
259
- }], propDecorators: { cuiClickOutside: [{
260
- type: Output
261
- }], onClickOutside: [{
262
- type: HostListener,
263
- args: ['document:click', ['$event.target']]
264
- }] } });
265
-
266
- class CuiDimensionsObserverDirective {
267
- constructor() {
268
- this.element = inject(ElementRef).nativeElement;
269
- this.observer = new ResizeObserver((entries) => {
270
- entries.forEach(() => this.cuiResizeObserver.emit({
271
- width: this.element.offsetWidth,
272
- height: this.element.offsetHeight
273
- }));
274
- });
275
- this.cuiResizeObserver = new EventEmitter();
276
- }
277
- ngOnInit() {
278
- this.observer.observe(this.element);
279
- }
280
- ngOnDestroy() {
281
- this.observer.disconnect();
282
- }
283
- }
284
- CuiDimensionsObserverDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiDimensionsObserverDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
285
- CuiDimensionsObserverDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiDimensionsObserverDirective, isStandalone: true, selector: "[cuiResizeObserver]", outputs: { cuiResizeObserver: "cuiResizeObserver" }, ngImport: i0 });
286
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiDimensionsObserverDirective, decorators: [{
287
- type: Directive,
288
- args: [{
289
- standalone: true,
290
- selector: '[cuiResizeObserver]'
291
- }]
292
- }], propDecorators: { cuiResizeObserver: [{
293
- type: Output
294
- }] } });
295
-
296
- class CuiContentEditableValueAccessorDirective {
297
- constructor() {
298
- this.element = inject(ElementRef).nativeElement;
299
- }
300
- writeValue(value) {
301
- this.element.innerText = value ?? '';
302
- }
303
- registerOnChange(fn) {
304
- this.onChange = fn;
305
- }
306
- registerOnTouched(fn) {
307
- this.onTouched = fn;
308
- }
309
- setDisabledState(isDisabled) {
310
- this.element.contentEditable = String(!isDisabled);
311
- }
312
- onInput() {
313
- this.onChange(this.element.innerHTML === '<br>' ? '' : this.element.innerText);
314
- }
315
- onBlur() {
316
- this.onTouched();
317
- }
318
- }
319
- CuiContentEditableValueAccessorDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiContentEditableValueAccessorDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
320
- CuiContentEditableValueAccessorDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiContentEditableValueAccessorDirective, isStandalone: true, selector: "[contenteditable][formControlName], [contenteditable][formControl], [contenteditable][ngModel]", host: { listeners: { "input": "onInput()", "blur": "onBlur()" } }, providers: [cuiProvide(NG_VALUE_ACCESSOR, CuiContentEditableValueAccessorDirective, true)], ngImport: i0 });
321
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiContentEditableValueAccessorDirective, decorators: [{
322
- type: Directive,
323
- args: [{
324
- standalone: true,
325
- selector: '[contenteditable][formControlName], [contenteditable][formControl], [contenteditable][ngModel]',
326
- providers: [cuiProvide(NG_VALUE_ACCESSOR, CuiContentEditableValueAccessorDirective, true)]
327
- }]
328
- }], propDecorators: { onInput: [{
329
- type: HostListener,
330
- args: ['input']
331
- }], onBlur: [{
332
- type: HostListener,
333
- args: ['blur']
334
- }] } });
335
-
336
- class CuiElementDirective {
337
- constructor() {
338
- this.nativeElement = inject((ElementRef)).nativeElement;
339
- return new ElementRef(this.nativeElement);
340
- }
341
- }
342
- CuiElementDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiElementDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
343
- CuiElementDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiElementDirective, isStandalone: true, selector: "[cuiElement]", exportAs: ["elementRef"], ngImport: i0 });
344
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiElementDirective, decorators: [{
345
- type: Directive,
346
- args: [{
347
- standalone: true,
348
- selector: '[cuiElement]',
349
- exportAs: 'elementRef',
350
- }]
351
- }], ctorParameters: function () { return []; } });
352
-
353
- function cuiContainsOrAfter(current, node) {
354
- try {
355
- return (current.contains(node) ||
356
- !!(node.compareDocumentPosition(current) & Node.DOCUMENT_POSITION_PRECEDING));
357
- }
358
- catch {
359
- return false;
360
- }
361
- }
362
-
363
- function cuiIsHTMLElement(node) {
364
- return !!node && node instanceof node.ownerDocument.defaultView.HTMLElement;
365
- }
366
-
367
- function cuiGetNativeFocused({ activeElement }) {
368
- if (!activeElement?.shadowRoot) {
369
- return activeElement;
370
- }
371
- let element = activeElement.shadowRoot.activeElement;
372
- while (element?.shadowRoot) {
373
- element = element.shadowRoot.activeElement;
374
- }
375
- return element;
376
- }
377
-
378
- function cuiBlurNativeFocused(document) {
379
- const activeElement = cuiGetNativeFocused(document);
380
- if (cuiIsHTMLElement(activeElement)) {
381
- activeElement.blur();
382
- }
383
- }
384
-
385
- function cuiIsNativeKeyboardFocusable(element) {
386
- if (element.hasAttribute('disabled') || element.getAttribute('tabIndex') === '-1') {
387
- return false;
388
- }
389
- if ((cuiIsHTMLElement(element) && element.isContentEditable) ||
390
- element.getAttribute('tabIndex') === '0') {
391
- return true;
392
- }
393
- switch (element.tagName) {
394
- case 'BUTTON':
395
- case 'SELECT':
396
- case 'TEXTAREA':
397
- return true;
398
- case 'VIDEO':
399
- case 'AUDIO':
400
- return element.hasAttribute('controls');
401
- case 'INPUT':
402
- return element.getAttribute('type') !== 'hidden';
403
- case 'A':
404
- case 'LINK':
405
- return element.hasAttribute('href');
406
- default:
407
- return false;
408
- }
409
- }
410
-
411
- function cuiIsNativeMouseFocusable(element) {
412
- return (!element.hasAttribute('disabled') &&
413
- (element.getAttribute('tabIndex') === '-1' ||
414
- cuiIsNativeKeyboardFocusable(element)));
415
- }
416
-
417
- function cuiGetClosestFocusable({ initial, root, previous = false, keyboard = true, }) {
418
- if (!root.ownerDocument) {
419
- return null;
420
- }
421
- const check = keyboard ? cuiIsNativeKeyboardFocusable : cuiIsNativeMouseFocusable;
422
- const treeWalker = root.ownerDocument.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, svgNodeFilter);
423
- treeWalker.currentNode = initial;
424
- while (previous ? treeWalker.previousNode() : treeWalker.nextNode()) {
425
- if (cuiIsHTMLElement(treeWalker.currentNode)) {
426
- initial = treeWalker.currentNode;
427
- }
428
- if (cuiIsHTMLElement(initial) && check(initial)) {
429
- return initial;
430
- }
431
- }
432
- return null;
433
- }
434
-
435
- class CuiFocusTrapDirective {
436
- constructor() {
437
- this.document = inject(DOCUMENT);
438
- this.element = inject(ElementRef).nativeElement;
439
- this.activeElement = cuiGetNativeFocused(this.document);
440
- this.tabIndex = 0;
441
- this.initElementFocus();
442
- }
443
- ngOnDestroy() {
444
- cuiBlurNativeFocused(this.document);
445
- Promise.resolve().then(() => {
446
- if (!cuiIsHTMLElement(this.activeElement)) {
447
- return;
448
- }
449
- this.activeElement.focus();
450
- });
451
- }
452
- onFocusIn(node) {
453
- if (cuiContainsOrAfter(this.element, node)) {
454
- return;
455
- }
456
- cuiGetClosestFocusable({
457
- initial: this.element,
458
- root: this.element,
459
- })?.focus();
460
- }
461
- initElementFocus() {
462
- Promise.resolve().then(() => this.element.focus());
463
- }
464
- }
465
- CuiFocusTrapDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiFocusTrapDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
466
- CuiFocusTrapDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiFocusTrapDirective, isStandalone: true, selector: "[cuiFocusTrap]", host: { listeners: { "window:focusin": "onFocusIn($event.target)" }, properties: { "tabIndex": "this.tabIndex" } }, ngImport: i0 });
467
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiFocusTrapDirective, decorators: [{
468
- type: Directive,
469
- args: [{
470
- standalone: true,
471
- selector: '[cuiFocusTrap]',
472
- }]
473
- }], ctorParameters: function () { return []; }, propDecorators: { tabIndex: [{
474
- type: HostBinding,
475
- args: ['tabIndex']
476
- }], onFocusIn: [{
477
- type: HostListener,
478
- args: ['window:focusin', ['$event.target']]
479
- }] } });
480
-
481
- class CuiItemDirective {
482
- }
483
- CuiItemDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
484
- CuiItemDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiItemDirective, isStandalone: true, selector: "[cuiItem]", ngImport: i0 });
485
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiItemDirective, decorators: [{
486
- type: Directive,
487
- args: [{
488
- standalone: true,
489
- selector: '[cuiItem]'
490
- }]
491
- }] });
492
-
493
- class CuiLetContext {
494
- constructor(internalDirectiveInstance) {
495
- this.internalDirectiveInstance = internalDirectiveInstance;
496
- }
497
- get $implicit() {
498
- return this.internalDirectiveInstance.cuiLet;
499
- }
500
- get cuiLet() {
501
- return this.internalDirectiveInstance.cuiLet;
502
- }
503
- }
504
-
505
- class CuiLetDirective {
506
- constructor() {
507
- inject(ViewContainerRef).createEmbeddedView(inject((TemplateRef)), new CuiLetContext(this));
508
- }
509
- static ngTemplateContextGuard(_dir, _ctx) {
510
- return true;
511
- }
512
- }
513
- CuiLetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiLetDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
514
- CuiLetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiLetDirective, isStandalone: true, selector: "[cuiLet]", inputs: { cuiLet: "cuiLet" }, ngImport: i0 });
515
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiLetDirective, decorators: [{
516
- type: Directive,
517
- args: [{
518
- standalone: true,
519
- selector: '[cuiLet]'
520
- }]
521
- }], ctorParameters: function () { return []; }, propDecorators: { cuiLet: [{
522
- type: Input
523
- }] } });
524
-
525
- class CuiTargetDirective {
526
- constructor() {
527
- this.clickListener = (event) => {
528
- this.clicked.emit(event);
529
- };
530
- this.clicked = new EventEmitter();
531
- }
532
- ngOnInit() {
533
- this.initClickListener();
534
- }
535
- ngOnDestroy() {
536
- this.destroyClickListener();
537
- }
538
- initClickListener() {
539
- this.ccTarget.addEventListener('click', this.clickListener);
540
- }
541
- destroyClickListener() {
542
- this.ccTarget.removeEventListener('click', this.clickListener);
543
- }
544
- }
545
- CuiTargetDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiTargetDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
546
- CuiTargetDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.10", type: CuiTargetDirective, isStandalone: true, selector: "[ccTarget]", inputs: { ccTarget: "ccTarget" }, outputs: { clicked: "clicked" }, ngImport: i0 });
547
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiTargetDirective, decorators: [{
548
- type: Directive,
549
- args: [{
550
- standalone: true,
551
- selector: '[ccTarget]',
552
- }]
553
- }], propDecorators: { ccTarget: [{
554
- type: Input
555
- }], clicked: [{
556
- type: Output
557
- }] } });
558
-
559
- class CuiFilterPipe {
560
- transform(items, matcher, ...args) {
561
- return items.filter(item => matcher(item, ...args));
562
- }
563
- }
564
- CuiFilterPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiFilterPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
565
- CuiFilterPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.10", ngImport: i0, type: CuiFilterPipe, isStandalone: true, name: "cuiFilter" });
566
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: CuiFilterPipe, decorators: [{
567
- type: Pipe,
568
- args: [{
569
- standalone: true,
570
- name: 'cuiFilter'
571
- }]
572
- }] });
573
-
574
- /**
575
- * Generated bundle index. Do not edit.
576
- */
577
-
578
- export { CUI_HISTORY, CUI_LOCAL_STORAGE, CUI_SESSION_STORAGE, CUI_WINDOW, CuiAutoResizingDirective, CuiClickOutsideDirective, CuiContentEditableValueAccessorDirective, CuiDestroyService, CuiDimensionsObserverDirective, CuiElementDirective, CuiFilterPipe, CuiFocusTrapDirective, CuiIdService, CuiItemDirective, CuiLetContext, CuiLetDirective, CuiPopoverService, CuiTargetDirective, CuiTime, cuiBlurNativeFocused, cuiContainsOrAfter, cuiCreateToken, cuiCreateTokenFromFactory, cuiGetClosestFocusable, cuiGetNativeFocused, cuiIsHTMLElement, cuiIsNativeKeyboardFocusable, cuiIsNativeMouseFocusable, cuiProvide, svgNodeFilter };
579
- //# sourceMappingURL=cuby-ui-cdk.mjs.map