@taiga-ui/core 5.0.0-rc.3 → 5.0.0-rc.4
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.
- package/components/calendar/calendar-sheet.component.d.ts +8 -15
- package/components/calendar/calendar-spin.component.d.ts +5 -8
- package/components/calendar/calendar-year.component.d.ts +11 -19
- package/components/calendar/calendar.component.d.ts +7 -9
- package/components/data-list/data-list.component.d.ts +1 -0
- package/components/input/input.directive.d.ts +2 -0
- package/fesm2022/taiga-ui-core-components-button.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-button.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-calendar.mjs +84 -174
- package/fesm2022/taiga-ui-core-components-calendar.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-cell.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-cell.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-checkbox.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-data-list.mjs +10 -4
- package/fesm2022/taiga-ui-core-components-data-list.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-error.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-error.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-icon.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-icon.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-input.mjs +4 -2
- package/fesm2022/taiga-ui-core-components-input.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-label.mjs +3 -3
- package/fesm2022/taiga-ui-core-components-label.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-link.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-loader.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-loader.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-notification.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-notification.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-radio.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-root.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-root.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-slider.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-slider.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-spin-button.mjs +2 -2
- package/fesm2022/taiga-ui-core-components-spin-button.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-textfield.mjs +8 -8
- package/fesm2022/taiga-ui-core-components-textfield.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-components-title.mjs +3 -3
- package/fesm2022/taiga-ui-core-components-title.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-directives-appearance.mjs +3 -3
- package/fesm2022/taiga-ui-core-directives-group.mjs +3 -3
- package/fesm2022/taiga-ui-core-directives-icons.mjs +3 -3
- package/fesm2022/taiga-ui-core-directives-icons.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-portals-alert.mjs +2 -2
- package/fesm2022/taiga-ui-core-portals-alert.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-portals-dialog.mjs +2 -2
- package/fesm2022/taiga-ui-core-portals-dialog.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-portals-dropdown.mjs +165 -113
- package/fesm2022/taiga-ui-core-portals-dropdown.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-portals-hint.mjs +3 -3
- package/fesm2022/taiga-ui-core-portals-hint.mjs.map +1 -1
- package/fesm2022/taiga-ui-core-portals-popup.mjs +2 -2
- package/fesm2022/taiga-ui-core-portals-popup.mjs.map +1 -1
- package/package.json +4 -4
- package/portals/dropdown/dropdown-a11y.directive.d.ts +10 -0
- package/portals/dropdown/dropdown-close.directive.d.ts +3 -3
- package/portals/dropdown/dropdown-open.directive.d.ts +4 -3
- package/portals/dropdown/dropdown-selection.directive.d.ts +1 -0
- package/portals/dropdown/dropdown.d.ts +2 -1
- package/portals/dropdown/dropdown.directive.d.ts +5 -5
- package/portals/dropdown/index.d.ts +1 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Directive, InjectionToken, Optional, Self, SkipSelf, inject, ChangeDetectorRef, effect, signal, INJECTOR, input,
|
|
2
|
+
import { Injectable, Directive, InjectionToken, Optional, Self, SkipSelf, inject, ChangeDetectorRef, effect, signal, INJECTOR, input, TemplateRef, computed, forwardRef, ChangeDetectionStrategy, Component, contentChild, ElementRef, model, PLATFORM_ID, ViewContainerRef } from '@angular/core';
|
|
3
3
|
import { outputFromObservable, takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
4
4
|
import { EMPTY_CLIENT_RECT, TUI_TRUE_HANDLER, CHAR_ZERO_WIDTH_SPACE, CHAR_NO_BREAK_SPACE } from '@taiga-ui/cdk/constants';
|
|
5
5
|
import * as i1 from '@taiga-ui/cdk/directives/active-zone';
|
|
6
6
|
import { TuiActiveZone } from '@taiga-ui/cdk/directives/active-zone';
|
|
7
7
|
import * as i2 from '@taiga-ui/cdk/directives/animated';
|
|
8
8
|
import { TuiAnimated } from '@taiga-ui/cdk/directives/animated';
|
|
9
|
-
import { tuiInjectElement, tuiGetActualTarget,
|
|
9
|
+
import { tuiInjectElement, tuiGetActualTarget, tuiIsElement, tuiIsElementEditable, tuiIsHTMLElement, tuiPointToClientRect, tuiIsTextNode, tuiIsTextfield } from '@taiga-ui/cdk/utils/dom';
|
|
10
10
|
import { tuiClamp } from '@taiga-ui/cdk/utils/math';
|
|
11
|
-
import { tuiPx, tuiSetSignal, tuiIsString } from '@taiga-ui/cdk/utils/miscellaneous';
|
|
11
|
+
import { tuiGenerateId, tuiPx, tuiSetSignal, tuiIsString } from '@taiga-ui/cdk/utils/miscellaneous';
|
|
12
12
|
import { TuiDriverDirective, TuiPositionAccessor, tuiFallbackAccessor, TuiRectAccessor, tuiAsVehicle, tuiPositionAccessorFor, tuiRectAccessorFor, tuiAsDriver, tuiAsRectAccessor, TuiDriver, tuiAsPositionAccessor } from '@taiga-ui/core/classes';
|
|
13
13
|
import { TuiScrollbar } from '@taiga-ui/core/components/scrollbar';
|
|
14
14
|
import { TuiVisualViewportService, TuiPositionService } from '@taiga-ui/core/services';
|
|
@@ -16,16 +16,16 @@ import { TUI_VIEWPORT, TUI_DARK_MODE, TUI_SELECTION_STREAM } from '@taiga-ui/cor
|
|
|
16
16
|
import { PolymorpheusComponent, PolymorpheusTemplate, PolymorpheusOutlet } from '@taiga-ui/polymorpheus';
|
|
17
17
|
import { BehaviorSubject, Subject, distinctUntilChanged, throttleTime, takeWhile, map, merge, filter, EMPTY, switchMap, delay, startWith, takeUntil, fromEvent, of, tap, share, combineLatest } from 'rxjs';
|
|
18
18
|
import { coerceArray } from '@angular/cdk/coercion';
|
|
19
|
-
import { tuiZonefreeScheduler,
|
|
19
|
+
import { tuiZonefreeScheduler, tuiIfMap, tuiCloseWatcher, tuiTypedFromEvent, tuiStopPropagation, tuiZoneOptimized } from '@taiga-ui/cdk/observables';
|
|
20
20
|
import { TuiPopupService } from '@taiga-ui/core/portals/popup';
|
|
21
21
|
import { tuiCheckFixedPosition, tuiGetWordRange } from '@taiga-ui/core/utils/dom';
|
|
22
22
|
import { tuiProvide, tuiCreateOptions, tuiDirectiveBinding } from '@taiga-ui/cdk/utils/di';
|
|
23
23
|
import { tuiOverrideOptions, tuiIsEditingKey } from '@taiga-ui/core/utils/miscellaneous';
|
|
24
|
-
import {
|
|
25
|
-
import { WA_IS_TOUCH } from '@ng-web-apis/platform';
|
|
24
|
+
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
26
25
|
import * as i1$1 from '@taiga-ui/cdk/directives/obscured';
|
|
27
26
|
import { TuiObscured } from '@taiga-ui/cdk/directives/obscured';
|
|
28
27
|
import { tuiIsFocusable, tuiGetClosestFocusable, tuiIsFocusedIn, tuiGetFocused } from '@taiga-ui/cdk/utils/focus';
|
|
28
|
+
import { WA_IS_TOUCH } from '@ng-web-apis/platform';
|
|
29
29
|
|
|
30
30
|
class TuiDropdownDriver extends BehaviorSubject {
|
|
31
31
|
constructor() {
|
|
@@ -194,22 +194,25 @@ class TuiDropdownDirective {
|
|
|
194
194
|
this.toggle(false);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
|
+
this.id = tuiGenerateId();
|
|
197
198
|
this.ref = signal(null);
|
|
198
199
|
this.el = tuiInjectElement();
|
|
199
200
|
this.type = 'dropdown';
|
|
200
201
|
this.component = new PolymorpheusComponent(inject(TUI_DROPDOWN_COMPONENT), inject(INJECTOR));
|
|
201
|
-
this.
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
this.content = input(null, {
|
|
203
|
+
alias: 'tuiDropdown',
|
|
204
|
+
transform: (content) => content instanceof TemplateRef
|
|
204
205
|
? new PolymorpheusTemplate(content, this.cdr)
|
|
205
|
-
: content
|
|
206
|
+
: content,
|
|
206
207
|
});
|
|
207
208
|
}
|
|
208
209
|
get position() {
|
|
209
210
|
return tuiCheckFixedPosition(this.el) ? 'fixed' : 'absolute';
|
|
210
211
|
}
|
|
211
212
|
ngAfterViewChecked() {
|
|
212
|
-
this.
|
|
213
|
+
if (this.ref()) {
|
|
214
|
+
this.refresh$.next();
|
|
215
|
+
}
|
|
213
216
|
}
|
|
214
217
|
ngOnDestroy() {
|
|
215
218
|
this.toggle(false);
|
|
@@ -226,12 +229,11 @@ class TuiDropdownDirective {
|
|
|
226
229
|
this.ref.set(null);
|
|
227
230
|
ref.destroy();
|
|
228
231
|
}
|
|
229
|
-
|
|
230
|
-
this.cdr.markForCheck();
|
|
232
|
+
this.ref()?.location.nativeElement.setAttribute('id', this.id);
|
|
231
233
|
this.drivers.forEach((driver) => driver?.next(show));
|
|
232
234
|
}
|
|
233
235
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
234
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.18", type: TuiDropdownDirective, isStandalone: true, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: {
|
|
236
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.18", type: TuiDropdownDirective, isStandalone: true, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: { content: { classPropertyName: "content", publicName: "tuiDropdown", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.tui-dropdown-open": "ref()" } }, providers: [tuiAsVehicle(TuiDropdownDirective)], exportAs: ["tuiDropdown"], hostDirectives: [{ directive: TuiDropdownDriverDirective }, { directive: TuiDropdownPosition, outputs: ["tuiDropdownDirectionChange", "tuiDropdownDirectionChange"] }], ngImport: i0 }); }
|
|
235
237
|
}
|
|
236
238
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownDirective, decorators: [{
|
|
237
239
|
type: Directive,
|
|
@@ -250,6 +252,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
250
252
|
}]
|
|
251
253
|
}] });
|
|
252
254
|
|
|
255
|
+
const MAX_WIDTH_GAP = 16; // 8px min gap from each side
|
|
253
256
|
/**
|
|
254
257
|
* @description:
|
|
255
258
|
* This component is used to show template in a portal
|
|
@@ -283,6 +286,7 @@ class TuiDropdownComponent {
|
|
|
283
286
|
const { left = 0, top = 0 } = this.position === 'fixed' ? {} : parent;
|
|
284
287
|
const rect = this.accessor.getClientRect();
|
|
285
288
|
const viewport = this.viewport.getClientRect();
|
|
289
|
+
const zoom = this.directive.el.currentCSSZoom || 1;
|
|
286
290
|
const above = rect.top - viewport.top - 2 * offset;
|
|
287
291
|
const below = viewport.top + viewport.height - y - offset;
|
|
288
292
|
const available = y > rect.bottom ? below : above;
|
|
@@ -293,12 +297,12 @@ class TuiDropdownComponent {
|
|
|
293
297
|
x -= left;
|
|
294
298
|
return {
|
|
295
299
|
position: this.position,
|
|
296
|
-
top: tuiPx(Math.round(Math.max(y, offset - top))),
|
|
297
|
-
left: tuiPx(Math.round(x)),
|
|
298
|
-
maxHeight: tuiPx(Math.round(height)),
|
|
299
|
-
width: limitWidth === 'fixed' ? tuiPx(Math.round(rect.width)) : '',
|
|
300
|
-
minWidth: limitWidth === 'min' ? tuiPx(Math.round(rect.width)) : '',
|
|
301
|
-
maxWidth: tuiPx(Math.round(viewport.width) -
|
|
300
|
+
top: tuiPx(Math.round(Math.max(y, offset - top) / zoom)),
|
|
301
|
+
left: tuiPx(Math.round(x / zoom)),
|
|
302
|
+
maxHeight: tuiPx(Math.round(height / zoom)),
|
|
303
|
+
width: limitWidth === 'fixed' ? tuiPx(Math.round(rect.width / zoom)) : '',
|
|
304
|
+
minWidth: limitWidth === 'min' ? tuiPx(Math.round(rect.width / zoom)) : '',
|
|
305
|
+
maxWidth: tuiPx(Math.round(viewport.width / zoom) - MAX_WIDTH_GAP),
|
|
302
306
|
};
|
|
303
307
|
}
|
|
304
308
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -320,88 +324,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
320
324
|
}, template: "<tui-scrollbar class=\"t-scroll\">\n <div\n *polymorpheusOutlet=\"directive.content() as text; context: {$implicit: close}\"\n class=\"t-primitive\"\n >\n {{ text }}\n </div>\n</tui-scrollbar>\n", styles: [":host{position:absolute;display:flex;box-shadow:var(--tui-shadow-medium);color:var(--tui-text-primary);background:var(--tui-background-elevation-3);border-radius:var(--tui-radius-m);overflow:hidden;border:1px solid var(--tui-border-normal);box-sizing:border-box;isolation:isolate;pointer-events:auto;--tui-from: translateY(-1rem)}:host:has(tui-data-list[data-size=l]){border-radius:var(--tui-radius-l)}:host.tui-enter,:host.tui-leave{animation-name:tuiFade,tuiSlide}:host:not([style*=top]){visibility:hidden}.t-scroll{flex-grow:1;max-inline-size:calc(100% + 2px);inline-size:max-content;overscroll-behavior:none;margin:-1px}.t-primitive{padding:1rem}\n"] }]
|
|
321
325
|
}] });
|
|
322
326
|
|
|
323
|
-
class TuiDropdownContent {
|
|
324
|
-
constructor() {
|
|
325
|
-
this.directive = inject(TuiDropdownDirective);
|
|
326
|
-
tuiSetSignal(this.directive.tuiDropdown, inject(TemplateRef));
|
|
327
|
-
if (isPlatformBrowser(inject(PLATFORM_ID)) &&
|
|
328
|
-
this.directive.el.matches(':focus-within')) {
|
|
329
|
-
this.directive.toggle(true);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
ngOnDestroy() {
|
|
333
|
-
tuiSetSignal(this.directive.tuiDropdown, null);
|
|
334
|
-
}
|
|
335
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
336
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: TuiDropdownContent, isStandalone: true, selector: "ng-template[tuiDropdown]", ngImport: i0 }); }
|
|
337
|
-
}
|
|
338
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownContent, decorators: [{
|
|
339
|
-
type: Directive,
|
|
340
|
-
args: [{ selector: 'ng-template[tuiDropdown]' }]
|
|
341
|
-
}], ctorParameters: () => [] });
|
|
342
|
-
|
|
343
|
-
class TuiDropdownContext extends TuiRectAccessor {
|
|
344
|
-
constructor() {
|
|
345
|
-
super(...arguments);
|
|
346
|
-
this.isTouch = inject(WA_IS_TOUCH);
|
|
347
|
-
this.currentRect = EMPTY_CLIENT_RECT;
|
|
348
|
-
this.userSelect = computed(() => (this.isTouch() ? 'none' : null));
|
|
349
|
-
this.activeZone = inject(TuiActiveZone);
|
|
350
|
-
this.driver = inject(TuiDropdownDriver);
|
|
351
|
-
this.doc = inject(DOCUMENT);
|
|
352
|
-
this.sub = merge(tuiTypedFromEvent(this.doc, 'pointerdown'), tuiTypedFromEvent(this.doc, 'keydown').pipe(filter(({ key }) => key === 'Escape')), tuiTypedFromEvent(this.doc, 'contextmenu', { capture: true }))
|
|
353
|
-
.pipe(filter((event) => this.driver.value &&
|
|
354
|
-
!this.activeZone.contains(tuiGetActualTarget(event))), tuiZoneOptimized(), takeUntilDestroyed())
|
|
355
|
-
.subscribe(() => {
|
|
356
|
-
this.driver.next(false);
|
|
357
|
-
this.currentRect = EMPTY_CLIENT_RECT;
|
|
358
|
-
});
|
|
359
|
-
this.type = 'dropdown';
|
|
360
|
-
}
|
|
361
|
-
getClientRect() {
|
|
362
|
-
return this.currentRect;
|
|
363
|
-
}
|
|
364
|
-
onContextMenu(x, y) {
|
|
365
|
-
this.currentRect = tuiPointToClientRect(x, y);
|
|
366
|
-
this.driver.next(true);
|
|
367
|
-
}
|
|
368
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownContext, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
369
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: TuiDropdownContext, isStandalone: true, selector: "[tuiDropdownContext]", host: { listeners: { "longtap": "onContextMenu($event.detail.clientX, $event.detail.clientY)" }, properties: { "style.user-select": "userSelect()", "style.-webkit-user-select": "userSelect()", "style.-webkit-touch-callout": "userSelect()" } }, providers: [
|
|
370
|
-
TuiActiveZone,
|
|
371
|
-
TuiDropdownDriver,
|
|
372
|
-
tuiAsDriver(TuiDropdownDriver),
|
|
373
|
-
tuiAsRectAccessor(TuiDropdownContext),
|
|
374
|
-
], usesInheritance: true, ngImport: i0 }); }
|
|
375
|
-
}
|
|
376
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownContext, decorators: [{
|
|
377
|
-
type: Directive,
|
|
378
|
-
args: [{
|
|
379
|
-
selector: '[tuiDropdownContext]',
|
|
380
|
-
providers: [
|
|
381
|
-
TuiActiveZone,
|
|
382
|
-
TuiDropdownDriver,
|
|
383
|
-
tuiAsDriver(TuiDropdownDriver),
|
|
384
|
-
tuiAsRectAccessor(TuiDropdownContext),
|
|
385
|
-
],
|
|
386
|
-
host: {
|
|
387
|
-
'[style.user-select]': 'userSelect()',
|
|
388
|
-
'[style.-webkit-user-select]': 'userSelect()',
|
|
389
|
-
'[style.-webkit-touch-callout]': 'userSelect()',
|
|
390
|
-
'(longtap)': 'onContextMenu($event.detail.clientX, $event.detail.clientY)',
|
|
391
|
-
},
|
|
392
|
-
}]
|
|
393
|
-
}] });
|
|
394
|
-
|
|
395
|
-
/** Default values for hint options */
|
|
396
|
-
const TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS = {
|
|
397
|
-
showDelay: 200,
|
|
398
|
-
hideDelay: 500,
|
|
399
|
-
};
|
|
400
|
-
/**
|
|
401
|
-
* Default parameters for dropdown hover directive
|
|
402
|
-
*/
|
|
403
|
-
const [TUI_DROPDOWN_HOVER_OPTIONS, tuiDropdownHoverOptionsProvider] = tuiCreateOptions(TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS);
|
|
404
|
-
|
|
405
327
|
class TuiDropdownClose {
|
|
406
328
|
constructor() {
|
|
407
329
|
this.el = tuiInjectElement();
|
|
@@ -516,7 +438,7 @@ class TuiDropdownOpen {
|
|
|
516
438
|
focusable?.focus();
|
|
517
439
|
}
|
|
518
440
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownOpen, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
519
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "19.2.18", type: TuiDropdownOpen, isStandalone: true, selector: "[tuiDropdown][tuiDropdownAuto],[tuiDropdown][tuiDropdownOpen],[tuiDropdown][tuiDropdownOpenChange]", inputs: { enabled: { classPropertyName: "enabled", publicName: "tuiDropdownEnabled", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "tuiDropdownOpen", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { open: "tuiDropdownOpenChange" }, host: { listeners: { "click": "onClick($event.target)", "keydown.arrowDown": "onArrow($event, false)", "keydown.arrowUp": "onArrow($event, true)", "tuiActiveZoneChange": "0", "tuiDropdownClose": "toggle(false)" } }, providers: [TuiDropdownDriver, tuiAsDriver(TuiDropdownDriver)], queries: [{ propertyName: "dropdownHost", first: true, predicate: ["tuiDropdownHost"], descendants: true, read: ElementRef, isSignal: true }], hostDirectives: [{ directive: i1$1.TuiObscured }, { directive: TuiDropdownClose, outputs: ["tuiDropdownClose", "tuiDropdownClose"] }, { directive: i1.TuiActiveZone, inputs: ["tuiActiveZoneParent", "tuiActiveZoneParent"], outputs: ["tuiActiveZoneChange", "tuiActiveZoneChange"] }], ngImport: i0 }); }
|
|
441
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "19.2.18", type: TuiDropdownOpen, isStandalone: true, selector: "[tuiDropdown][tuiDropdownAuto],[tuiDropdown][tuiDropdownOpen],[tuiDropdown][tuiDropdownOpenChange]", inputs: { enabled: { classPropertyName: "enabled", publicName: "tuiDropdownEnabled", isSignal: true, isRequired: false, transformFunction: null }, open: { classPropertyName: "open", publicName: "tuiDropdownOpen", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { open: "tuiDropdownOpenChange" }, host: { listeners: { "click": "onClick($event.target)", "keydown.arrowDown": "onArrow($event, false)", "keydown.arrowUp": "onArrow($event, true)", "tuiActiveZoneChange": "0", "tuiDropdownClose": "toggle(false)" } }, providers: [TuiDropdownDriver, tuiAsDriver(TuiDropdownDriver)], queries: [{ propertyName: "dropdownHost", first: true, predicate: ["tuiDropdownHost"], descendants: true, read: ElementRef, isSignal: true }], hostDirectives: [{ directive: i1$1.TuiObscured }, { directive: i0.forwardRef(() => TuiDropdownA11y), inputs: ["tuiDropdownRole", "tuiDropdownRole"] }, { directive: TuiDropdownClose, outputs: ["tuiDropdownClose", "tuiDropdownClose"] }, { directive: i1.TuiActiveZone, inputs: ["tuiActiveZoneParent", "tuiActiveZoneParent"], outputs: ["tuiActiveZoneChange", "tuiActiveZoneChange"] }], ngImport: i0 }); }
|
|
520
442
|
}
|
|
521
443
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownOpen, decorators: [{
|
|
522
444
|
type: Directive,
|
|
@@ -525,10 +447,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
525
447
|
providers: [TuiDropdownDriver, tuiAsDriver(TuiDropdownDriver)],
|
|
526
448
|
hostDirectives: [
|
|
527
449
|
TuiObscured,
|
|
528
|
-
{
|
|
529
|
-
|
|
530
|
-
outputs: ['tuiDropdownClose'],
|
|
531
|
-
},
|
|
450
|
+
{ directive: forwardRef(() => TuiDropdownA11y), inputs: ['tuiDropdownRole'] },
|
|
451
|
+
{ directive: TuiDropdownClose, outputs: ['tuiDropdownClose'] },
|
|
532
452
|
{
|
|
533
453
|
directive: TuiActiveZone,
|
|
534
454
|
inputs: ['tuiActiveZoneParent'],
|
|
@@ -546,6 +466,118 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
546
466
|
}]
|
|
547
467
|
}] });
|
|
548
468
|
|
|
469
|
+
class TuiDropdownA11y {
|
|
470
|
+
constructor() {
|
|
471
|
+
this.el = tuiInjectElement();
|
|
472
|
+
this.dropdown = inject(TuiDropdownDirective);
|
|
473
|
+
this.open = inject(forwardRef(() => TuiDropdownOpen), { self: true, optional: true });
|
|
474
|
+
this.tuiDropdownRole = input('listbox');
|
|
475
|
+
this.sync = effect(() => {
|
|
476
|
+
const content = this.dropdown.content();
|
|
477
|
+
const dropdown = this.dropdown.ref();
|
|
478
|
+
const host = this.open?.host || this.el;
|
|
479
|
+
host.setAttribute('aria-expanded', String(!!dropdown));
|
|
480
|
+
host.setAttribute('aria-controls', this.dropdown.id);
|
|
481
|
+
host.setAttribute('aria-haspopup', this.tuiDropdownRole());
|
|
482
|
+
dropdown?.location.nativeElement.setAttribute('role', this.tuiDropdownRole());
|
|
483
|
+
if (content) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
host.removeAttribute('aria-expanded');
|
|
487
|
+
host.removeAttribute('aria-controls');
|
|
488
|
+
host.removeAttribute('aria-haspopup');
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownA11y, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
492
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.18", type: TuiDropdownA11y, isStandalone: true, selector: "[tuiDropdownA11y]", inputs: { tuiDropdownRole: { classPropertyName: "tuiDropdownRole", publicName: "tuiDropdownRole", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
493
|
+
}
|
|
494
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownA11y, decorators: [{
|
|
495
|
+
type: Directive,
|
|
496
|
+
args: [{ selector: '[tuiDropdownA11y]' }]
|
|
497
|
+
}] });
|
|
498
|
+
|
|
499
|
+
class TuiDropdownContent {
|
|
500
|
+
constructor() {
|
|
501
|
+
this.directive = inject(TuiDropdownDirective);
|
|
502
|
+
tuiSetSignal(this.directive.content, inject(TemplateRef));
|
|
503
|
+
if (isPlatformBrowser(inject(PLATFORM_ID)) &&
|
|
504
|
+
this.directive.el.matches(':focus-within')) {
|
|
505
|
+
this.directive.toggle(true);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
ngOnDestroy() {
|
|
509
|
+
tuiSetSignal(this.directive.content, null);
|
|
510
|
+
}
|
|
511
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
512
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: TuiDropdownContent, isStandalone: true, selector: "ng-template[tuiDropdown]", ngImport: i0 }); }
|
|
513
|
+
}
|
|
514
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownContent, decorators: [{
|
|
515
|
+
type: Directive,
|
|
516
|
+
args: [{ selector: 'ng-template[tuiDropdown]' }]
|
|
517
|
+
}], ctorParameters: () => [] });
|
|
518
|
+
|
|
519
|
+
class TuiDropdownContext extends TuiRectAccessor {
|
|
520
|
+
constructor() {
|
|
521
|
+
super(...arguments);
|
|
522
|
+
this.isTouch = inject(WA_IS_TOUCH);
|
|
523
|
+
this.currentRect = EMPTY_CLIENT_RECT;
|
|
524
|
+
this.userSelect = computed(() => (this.isTouch() ? 'none' : null));
|
|
525
|
+
this.activeZone = inject(TuiActiveZone);
|
|
526
|
+
this.driver = inject(TuiDropdownDriver);
|
|
527
|
+
this.doc = inject(DOCUMENT);
|
|
528
|
+
this.sub = merge(tuiTypedFromEvent(this.doc, 'pointerdown'), tuiTypedFromEvent(this.doc, 'keydown').pipe(filter(({ key }) => key === 'Escape')), tuiTypedFromEvent(this.doc, 'contextmenu', { capture: true }))
|
|
529
|
+
.pipe(filter((event) => this.driver.value &&
|
|
530
|
+
!this.activeZone.contains(tuiGetActualTarget(event))), tuiZoneOptimized(), takeUntilDestroyed())
|
|
531
|
+
.subscribe(() => {
|
|
532
|
+
this.driver.next(false);
|
|
533
|
+
this.currentRect = EMPTY_CLIENT_RECT;
|
|
534
|
+
});
|
|
535
|
+
this.type = 'dropdown';
|
|
536
|
+
}
|
|
537
|
+
getClientRect() {
|
|
538
|
+
return this.currentRect;
|
|
539
|
+
}
|
|
540
|
+
onContextMenu(x, y) {
|
|
541
|
+
this.currentRect = tuiPointToClientRect(x, y);
|
|
542
|
+
this.driver.next(true);
|
|
543
|
+
}
|
|
544
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownContext, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
545
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.18", type: TuiDropdownContext, isStandalone: true, selector: "[tuiDropdownContext]", host: { listeners: { "longtap": "onContextMenu($event.detail.clientX, $event.detail.clientY)" }, properties: { "style.user-select": "userSelect()", "style.-webkit-user-select": "userSelect()", "style.-webkit-touch-callout": "userSelect()" } }, providers: [
|
|
546
|
+
TuiActiveZone,
|
|
547
|
+
TuiDropdownDriver,
|
|
548
|
+
tuiAsDriver(TuiDropdownDriver),
|
|
549
|
+
tuiAsRectAccessor(TuiDropdownContext),
|
|
550
|
+
], usesInheritance: true, ngImport: i0 }); }
|
|
551
|
+
}
|
|
552
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownContext, decorators: [{
|
|
553
|
+
type: Directive,
|
|
554
|
+
args: [{
|
|
555
|
+
selector: '[tuiDropdownContext]',
|
|
556
|
+
providers: [
|
|
557
|
+
TuiActiveZone,
|
|
558
|
+
TuiDropdownDriver,
|
|
559
|
+
tuiAsDriver(TuiDropdownDriver),
|
|
560
|
+
tuiAsRectAccessor(TuiDropdownContext),
|
|
561
|
+
],
|
|
562
|
+
host: {
|
|
563
|
+
'[style.user-select]': 'userSelect()',
|
|
564
|
+
'[style.-webkit-user-select]': 'userSelect()',
|
|
565
|
+
'[style.-webkit-touch-callout]': 'userSelect()',
|
|
566
|
+
'(longtap)': 'onContextMenu($event.detail.clientX, $event.detail.clientY)',
|
|
567
|
+
},
|
|
568
|
+
}]
|
|
569
|
+
}] });
|
|
570
|
+
|
|
571
|
+
/** Default values for hint options */
|
|
572
|
+
const TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS = {
|
|
573
|
+
showDelay: 200,
|
|
574
|
+
hideDelay: 500,
|
|
575
|
+
};
|
|
576
|
+
/**
|
|
577
|
+
* Default parameters for dropdown hover directive
|
|
578
|
+
*/
|
|
579
|
+
const [TUI_DROPDOWN_HOVER_OPTIONS, tuiDropdownHoverOptionsProvider] = tuiCreateOptions(TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS);
|
|
580
|
+
|
|
549
581
|
class TuiDropdownHover extends TuiDriver {
|
|
550
582
|
constructor() {
|
|
551
583
|
super((subscriber) => this.stream$.subscribe(subscriber));
|
|
@@ -683,13 +715,20 @@ class TuiDropdownSelection extends TuiDriver {
|
|
|
683
715
|
inject(TUI_SELECTION_STREAM).pipe(map(() => this.getRange()), filter((range) => this.isValid(range)), distinctUntilChanged((x, y) => x.startOffset === y.startOffset &&
|
|
684
716
|
x.endOffset === y.endOffset &&
|
|
685
717
|
x.commonAncestorContainer === y.commonAncestorContainer)),
|
|
686
|
-
|
|
687
|
-
|
|
718
|
+
merge(fromEvent(this.el, 'scroll', { passive: true, capture: true })).pipe(throttleTime(16, undefined, { leading: false, trailing: true }), startWith(0)),
|
|
719
|
+
]).pipe(tap(([, range]) => {
|
|
688
720
|
this.range =
|
|
689
|
-
|
|
721
|
+
this.el.contains(range.commonAncestorContainer) &&
|
|
722
|
+
tuiIsTextNode(range.commonAncestorContainer)
|
|
690
723
|
? range
|
|
691
724
|
: this.range;
|
|
692
|
-
|
|
725
|
+
}), map(([handler, range]) => {
|
|
726
|
+
const contained = this.el.contains(range.commonAncestorContainer);
|
|
727
|
+
const valid = contained && handler(this.range);
|
|
728
|
+
const visible = valid || this.inDropdown(range);
|
|
729
|
+
const active = tuiGetFocused(this.doc);
|
|
730
|
+
const textfield = active && tuiIsTextfield(active) && this.el.contains(active);
|
|
731
|
+
return visible && textfield ? this.isCaretVisible(this.range) : visible;
|
|
693
732
|
}));
|
|
694
733
|
this.range = isPlatformBrowser(inject(PLATFORM_ID))
|
|
695
734
|
? new Range()
|
|
@@ -790,6 +829,18 @@ class TuiDropdownSelection extends TuiDriver {
|
|
|
790
829
|
this.ghost = ghost;
|
|
791
830
|
return ghost;
|
|
792
831
|
}
|
|
832
|
+
isCaretVisible(range) {
|
|
833
|
+
const caret = range.getBoundingClientRect();
|
|
834
|
+
const host = this.ghostHost.getBoundingClientRect();
|
|
835
|
+
const styles = getComputedStyle(this.ghostHost);
|
|
836
|
+
const fontSize = parseFloat(styles.fontSize) || 16;
|
|
837
|
+
const lineHeight = parseFloat(styles.lineHeight) || fontSize * 1.2;
|
|
838
|
+
const visibleTop = Math.max(caret.top, host.top);
|
|
839
|
+
const visibleBottom = Math.min(caret.bottom, host.bottom);
|
|
840
|
+
const visibleHeight = Math.max(0, visibleBottom - visibleTop);
|
|
841
|
+
const threshold = lineHeight * 0.5;
|
|
842
|
+
return visibleHeight >= threshold;
|
|
843
|
+
}
|
|
793
844
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: TuiDropdownSelection, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
794
845
|
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.18", type: TuiDropdownSelection, isStandalone: true, selector: "[tuiDropdownSelection]", inputs: { tuiDropdownSelection: { classPropertyName: "tuiDropdownSelection", publicName: "tuiDropdownSelection", isSignal: true, isRequired: false, transformFunction: null }, tuiDropdownSelectionPosition: { classPropertyName: "tuiDropdownSelectionPosition", publicName: "tuiDropdownSelectionPosition", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
795
846
|
tuiAsDriver(TuiDropdownSelection),
|
|
@@ -812,6 +863,7 @@ const TuiDropdown = [
|
|
|
812
863
|
TuiDropdownDriverDirective,
|
|
813
864
|
TuiDropdownDirective,
|
|
814
865
|
TuiDropdownComponent,
|
|
866
|
+
TuiDropdownA11y,
|
|
815
867
|
TuiDropdownOpen,
|
|
816
868
|
TuiDropdownManual,
|
|
817
869
|
TuiDropdownHover,
|
|
@@ -823,7 +875,7 @@ const TuiDropdown = [
|
|
|
823
875
|
];
|
|
824
876
|
|
|
825
877
|
function tuiDropdown(value) {
|
|
826
|
-
return tuiDirectiveBinding(TuiDropdownDirective, '
|
|
878
|
+
return tuiDirectiveBinding(TuiDropdownDirective, 'content', value, {});
|
|
827
879
|
}
|
|
828
880
|
function tuiDropdownEnabled(value) {
|
|
829
881
|
return tuiDirectiveBinding(TuiDropdownOpen, 'enabled', value, {});
|
|
@@ -877,5 +929,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
877
929
|
* Generated bundle index. Do not edit.
|
|
878
930
|
*/
|
|
879
931
|
|
|
880
|
-
export { TUI_DROPDOWN_COMPONENT, TUI_DROPDOWN_CONTEXT, TUI_DROPDOWN_DEFAULT_OPTIONS, TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS, TUI_DROPDOWN_HOVER_OPTIONS, TUI_DROPDOWN_OPTIONS, TuiDropdown, TuiDropdownAuto, TuiDropdownClose, TuiDropdownComponent, TuiDropdownContent, TuiDropdownContext, TuiDropdownDirective, TuiDropdownDriver, TuiDropdownDriverDirective, TuiDropdownFixed, TuiDropdownHover, TuiDropdownManual, TuiDropdownOpen, TuiDropdownOptionsDirective, TuiDropdownPosition, TuiDropdownPositionSided, TuiDropdownSelection, TuiWithDropdownOpen, tuiDropdown, tuiDropdownEnabled, tuiDropdownHoverOptionsProvider, tuiDropdownOptionsProvider };
|
|
932
|
+
export { TUI_DROPDOWN_COMPONENT, TUI_DROPDOWN_CONTEXT, TUI_DROPDOWN_DEFAULT_OPTIONS, TUI_DROPDOWN_HOVER_DEFAULT_OPTIONS, TUI_DROPDOWN_HOVER_OPTIONS, TUI_DROPDOWN_OPTIONS, TuiDropdown, TuiDropdownA11y, TuiDropdownAuto, TuiDropdownClose, TuiDropdownComponent, TuiDropdownContent, TuiDropdownContext, TuiDropdownDirective, TuiDropdownDriver, TuiDropdownDriverDirective, TuiDropdownFixed, TuiDropdownHover, TuiDropdownManual, TuiDropdownOpen, TuiDropdownOptionsDirective, TuiDropdownPosition, TuiDropdownPositionSided, TuiDropdownSelection, TuiWithDropdownOpen, tuiDropdown, tuiDropdownEnabled, tuiDropdownHoverOptionsProvider, tuiDropdownOptionsProvider };
|
|
881
933
|
//# sourceMappingURL=taiga-ui-core-portals-dropdown.mjs.map
|