@thalassic/ui 0.11.0 → 0.12.0
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/fesm2022/thalassic-ui.mjs +438 -335
- package/fesm2022/thalassic-ui.mjs.map +1 -1
- package/package.json +1 -1
- package/types/thalassic-ui.d.ts +199 -130
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, input, booleanAttribute, computed, Component, Directive, signal, contentChild, model,
|
|
2
|
+
import { InjectionToken, inject, input, booleanAttribute, computed, Component, Directive, signal, contentChild, model, ViewContainerRef, DestroyRef, viewChild, effect, forwardRef, Injectable, output, viewChildren, numberAttribute, contentChildren, isDevMode, TemplateRef, ElementRef, Renderer2, makeEnvironmentProviders } from '@angular/core';
|
|
3
3
|
import { LocationStrategy, NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
import { RouterLink, Router } from '@angular/router';
|
|
5
|
-
import { CdkDialogContainer, DialogRef, Dialog as Dialog$1 } from '@angular/cdk/dialog';
|
|
6
|
-
import { CdkPortalOutlet, TemplatePortal, ComponentPortal } from '@angular/cdk/portal';
|
|
7
|
-
import { format, startOfMonth, endOfMonth, eachDayOfInterval, endOfWeek, startOfWeek, subMonths, addMonths, isSameDay, isSameMonth, isToday, setMonth, subYears, addYears, getYear, getMonth, getHours, getMinutes, startOfDay, setHours, setMinutes, setYear } from 'date-fns';
|
|
8
5
|
import { Overlay } from '@angular/cdk/overlay';
|
|
6
|
+
import { TemplatePortal, CdkPortalOutlet, ComponentPortal } from '@angular/cdk/portal';
|
|
9
7
|
import { takeUntilDestroyed, rxResource, toObservable } from '@angular/core/rxjs-interop';
|
|
10
8
|
import { filter, throwError, map, shareReplay } from 'rxjs';
|
|
9
|
+
import { CdkDialogContainer, DialogRef, Dialog as Dialog$1 } from '@angular/cdk/dialog';
|
|
10
|
+
import { format, startOfMonth, endOfMonth, eachDayOfInterval, endOfWeek, startOfWeek, subMonths, addMonths, isSameDay, isSameMonth, isToday, setMonth, subYears, addYears, getYear, getMonth, getHours, getMinutes, startOfDay, setHours, setMinutes, setYear } from 'date-fns';
|
|
11
11
|
import { HttpClient } from '@angular/common/http';
|
|
12
12
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
13
13
|
import { CdkTable, CdkHeaderCell, CdkCell, CdkCellDef, CdkHeaderCellDef, CdkColumnDef, CdkHeaderRow, CdkHeaderRowDef, CdkRow, CdkRowDef } from '@angular/cdk/table';
|
|
@@ -247,7 +247,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
247
247
|
}, template: "@if (startIconTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ $implicit: context() }\" />\n}\n\n@if (label()) {\n {{ label() }}\n} @else {\n <ng-content></ng-content>\n}\n\n@if (endIconTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ $implicit: context() }\" />\n}\n" }]
|
|
248
248
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], startIconTemplate: [{ type: i0.ContentChild, args: ['startIcon', { isSignal: true }] }], endIconTemplate: [{ type: i0.ContentChild, args: ['endIcon', { isSignal: true }] }] } });
|
|
249
249
|
|
|
250
|
-
const FORM_CONTROL = new InjectionToken('FORM_CONTROL');
|
|
251
250
|
class FormControl {
|
|
252
251
|
// Models
|
|
253
252
|
touched = model(false, ...(ngDevMode ? [{ debugName: "touched" }] : []));
|
|
@@ -289,6 +288,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
289
288
|
type: Directive
|
|
290
289
|
}], propDecorators: { touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }, { type: i0.Output, args: ["touchedChange"] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], hidden: [{ type: i0.Input, args: [{ isSignal: true, alias: "hidden", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], pending: [{ type: i0.Input, args: [{ isSignal: true, alias: "pending", required: false }] }], dirty: [{ type: i0.Input, args: [{ isSignal: true, alias: "dirty", required: false }] }], errors: [{ type: i0.Input, args: [{ isSignal: true, alias: "errors", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }] } });
|
|
291
290
|
|
|
291
|
+
const FORM_CONTROL = new InjectionToken('FORM_CONTROL');
|
|
292
|
+
|
|
293
|
+
class ValueFormControl extends FormControl {
|
|
294
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ValueFormControl, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
295
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.1", type: ValueFormControl, isStandalone: true, usesInheritance: true, ngImport: i0 });
|
|
296
|
+
}
|
|
297
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ValueFormControl, decorators: [{
|
|
298
|
+
type: Directive
|
|
299
|
+
}] });
|
|
300
|
+
|
|
292
301
|
class CheckboxFormControl extends FormControl {
|
|
293
302
|
controlClasses = computed(() => {
|
|
294
303
|
const classes = this.baseControlClasses();
|
|
@@ -317,16 +326,341 @@ function normalizeOptions(options, keys) {
|
|
|
317
326
|
});
|
|
318
327
|
}
|
|
319
328
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
329
|
+
/**
|
|
330
|
+
* Shared base for controls that present a list of options and store the
|
|
331
|
+
* selected option values as an array (e.g. toggle group, chip group).
|
|
332
|
+
*
|
|
333
|
+
* Subclasses provide the visual shell plus the `type`/`unselectable` inputs
|
|
334
|
+
* (their defaults differ per component), while this base owns the selection
|
|
335
|
+
* state machine: value model, option normalization, and the toggle logic.
|
|
336
|
+
*/
|
|
337
|
+
class SelectionGroup extends ValueFormControl {
|
|
338
|
+
value = model([], ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
339
|
+
options = input([], ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
340
|
+
optionLabel = input(undefined, ...(ngDevMode ? [{ debugName: "optionLabel" }] : []));
|
|
341
|
+
optionValue = input(undefined, ...(ngDevMode ? [{ debugName: "optionValue" }] : []));
|
|
342
|
+
optionDisabled = input(undefined, ...(ngDevMode ? [{ debugName: "optionDisabled" }] : []));
|
|
343
|
+
normalizedOptions = computed(() => normalizeOptions(this.options(), {
|
|
344
|
+
label: this.optionLabel(),
|
|
345
|
+
value: this.optionValue(),
|
|
346
|
+
disabled: this.optionDisabled(),
|
|
347
|
+
}), ...(ngDevMode ? [{ debugName: "normalizedOptions" }] : []));
|
|
348
|
+
isSelected(optionValue) {
|
|
349
|
+
return this.value().includes(optionValue);
|
|
350
|
+
}
|
|
351
|
+
select(option) {
|
|
352
|
+
if (this.notInteractive() || option.disabled)
|
|
353
|
+
return;
|
|
354
|
+
if (this.type() === 'single') {
|
|
355
|
+
if (this.isSelected(option.value) && !this.unselectable())
|
|
356
|
+
return;
|
|
357
|
+
this.value.set(this.isSelected(option.value) ? [] : [option.value]);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (this.isSelected(option.value)) {
|
|
361
|
+
this.value.update(current => current.filter(item => item !== option.value));
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this.value.update(current => [...current, option.value]);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
onKeyboardSelect(event, option) {
|
|
368
|
+
event.preventDefault();
|
|
369
|
+
this.select(option);
|
|
370
|
+
}
|
|
371
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: SelectionGroup, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
372
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: SelectionGroup, isStandalone: true, inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, optionDisabled: { classPropertyName: "optionDisabled", publicName: "optionDisabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, usesInheritance: true, ngImport: i0 });
|
|
323
373
|
}
|
|
324
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type:
|
|
374
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: SelectionGroup, decorators: [{
|
|
325
375
|
type: Directive
|
|
326
|
-
}] });
|
|
376
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: false }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: false }] }], optionDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionDisabled", required: false }] }] } });
|
|
377
|
+
|
|
378
|
+
const TRANSPARENT_BACKDROP_CLASS = 'cdk-overlay-transparent-backdrop';
|
|
379
|
+
/**
|
|
380
|
+
* Owns the CDK-Overlay lifecycle shared by the library's connected overlay
|
|
381
|
+
* components (popover, menu, select): create/attach, dismissal wiring
|
|
382
|
+
* (backdrop / outside-pointer / Escape), `isOpen` state, and disposal. The
|
|
383
|
+
* positional and dismissal differences between components are expressed through
|
|
384
|
+
* {@link ConnectedOverlayConfig} rather than duplicated per component.
|
|
385
|
+
*
|
|
386
|
+
* Create one via {@link createOverlayManager} from a component field initializer
|
|
387
|
+
* so it is bound to the host's injection context.
|
|
388
|
+
*/
|
|
389
|
+
class OverlayManager {
|
|
390
|
+
_overlay = inject(Overlay);
|
|
391
|
+
_viewContainerRef = inject(ViewContainerRef);
|
|
392
|
+
_destroyRef = inject(DestroyRef);
|
|
393
|
+
_overlayRef = null;
|
|
394
|
+
_config = null;
|
|
395
|
+
_isOpen = signal(false, ...(ngDevMode ? [{ debugName: "_isOpen" }] : []));
|
|
396
|
+
isOpen = this._isOpen.asReadonly();
|
|
397
|
+
// Dispose the overlay with the host. Registered in a field initializer so no
|
|
398
|
+
// constructor is needed.
|
|
399
|
+
_teardown = this._destroyRef.onDestroy(() => this._dispose());
|
|
400
|
+
open(config) {
|
|
401
|
+
if (this._isOpen())
|
|
402
|
+
return;
|
|
403
|
+
this._config = config;
|
|
404
|
+
if (!this._overlayRef) {
|
|
405
|
+
this._overlayRef = this._overlay.create({
|
|
406
|
+
positionStrategy: this._buildPositionStrategy(config),
|
|
407
|
+
scrollStrategy: config.scrollStrategy === 'close'
|
|
408
|
+
? this._overlay.scrollStrategies.close()
|
|
409
|
+
: this._overlay.scrollStrategies.reposition(),
|
|
410
|
+
hasBackdrop: config.hasBackdrop ?? true,
|
|
411
|
+
backdropClass: config.backdropClass ?? TRANSPARENT_BACKDROP_CLASS,
|
|
412
|
+
...(config.panelClass != null && { panelClass: config.panelClass }),
|
|
413
|
+
});
|
|
414
|
+
this._wireDismissal(this._overlayRef, config);
|
|
415
|
+
}
|
|
416
|
+
if (config.minWidth != null) {
|
|
417
|
+
this._overlayRef.updateSize({ minWidth: config.minWidth });
|
|
418
|
+
}
|
|
419
|
+
this._overlayRef.attach(new TemplatePortal(config.content, this._viewContainerRef));
|
|
420
|
+
this._isOpen.set(true);
|
|
421
|
+
}
|
|
422
|
+
close() {
|
|
423
|
+
if (!this._isOpen())
|
|
424
|
+
return;
|
|
425
|
+
if (this._config?.reuse) {
|
|
426
|
+
this._overlayRef?.detach();
|
|
427
|
+
}
|
|
428
|
+
else {
|
|
429
|
+
this._overlayRef?.dispose();
|
|
430
|
+
this._overlayRef = null;
|
|
431
|
+
}
|
|
432
|
+
this._isOpen.set(false);
|
|
433
|
+
this._config?.onClose?.();
|
|
434
|
+
}
|
|
435
|
+
// Private
|
|
436
|
+
_buildPositionStrategy(config) {
|
|
437
|
+
let strategy = this._overlay
|
|
438
|
+
.position()
|
|
439
|
+
.flexibleConnectedTo(config.origin)
|
|
440
|
+
.withPositions(config.positions);
|
|
441
|
+
if (config.flexibleDimensions === false)
|
|
442
|
+
strategy = strategy.withFlexibleDimensions(false);
|
|
443
|
+
if (config.push === false)
|
|
444
|
+
strategy = strategy.withPush(false);
|
|
445
|
+
return strategy;
|
|
446
|
+
}
|
|
447
|
+
_wireDismissal(overlayRef, config) {
|
|
448
|
+
const hasBackdrop = config.hasBackdrop ?? true;
|
|
449
|
+
if (config.closeOnBackdropClick ?? hasBackdrop) {
|
|
450
|
+
overlayRef
|
|
451
|
+
.backdropClick()
|
|
452
|
+
.pipe(takeUntilDestroyed(this._destroyRef))
|
|
453
|
+
.subscribe(() => this.close());
|
|
454
|
+
}
|
|
455
|
+
if (config.closeOnOutsidePointer ?? !hasBackdrop) {
|
|
456
|
+
overlayRef
|
|
457
|
+
.outsidePointerEvents()
|
|
458
|
+
.pipe(takeUntilDestroyed(this._destroyRef), filter(event => event.type === 'click' || event.type === 'auxclick'))
|
|
459
|
+
.subscribe(() => this.close());
|
|
460
|
+
}
|
|
461
|
+
if (config.closeOnEscape ?? true) {
|
|
462
|
+
overlayRef
|
|
463
|
+
.keydownEvents()
|
|
464
|
+
.pipe(takeUntilDestroyed(this._destroyRef), filter(event => event.key === 'Escape'))
|
|
465
|
+
.subscribe(() => this.close());
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
_dispose() {
|
|
469
|
+
this._overlayRef?.dispose();
|
|
470
|
+
this._overlayRef = null;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Creates an {@link OverlayManager} bound to the current injection context.
|
|
475
|
+
* Call from a component/directive field initializer or constructor.
|
|
476
|
+
*/
|
|
477
|
+
function createOverlayManager() {
|
|
478
|
+
return new OverlayManager();
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Shared base for the single {@link Select} and {@link MultiSelect} controls.
|
|
483
|
+
* Owns everything the two listbox-combobox controls have in common: the option
|
|
484
|
+
* inputs, the connected overlay lifecycle, roving `aria-activedescendant`
|
|
485
|
+
* navigation, and the keyboard handler. The per-control differences (the value
|
|
486
|
+
* shape, the selected-state check, how the trigger label is built and what a
|
|
487
|
+
* commit does) are expressed through the abstract members below.
|
|
488
|
+
*/
|
|
489
|
+
class AbstractSelect extends ValueFormControl {
|
|
490
|
+
overlay = createOverlayManager();
|
|
491
|
+
triggerElement = viewChild('trigger', ...(ngDevMode ? [{ debugName: "triggerElement" }] : []));
|
|
492
|
+
panelTemplate = viewChild('panel', ...(ngDevMode ? [{ debugName: "panelTemplate" }] : []));
|
|
493
|
+
// Shared inputs (config-independent)
|
|
494
|
+
inputId = input(null, ...(ngDevMode ? [{ debugName: "inputId" }] : []));
|
|
495
|
+
options = input([], ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
496
|
+
optionLabel = input(undefined, ...(ngDevMode ? [{ debugName: "optionLabel" }] : []));
|
|
497
|
+
optionValue = input(undefined, ...(ngDevMode ? [{ debugName: "optionValue" }] : []));
|
|
498
|
+
optionDisabled = input(undefined, ...(ngDevMode ? [{ debugName: "optionDisabled" }] : []));
|
|
499
|
+
tabindex = input(0, ...(ngDevMode ? [{ debugName: "tabindex" }] : []));
|
|
500
|
+
isOpen = this.overlay.isOpen;
|
|
501
|
+
activeIndex = signal(-1, ...(ngDevMode ? [{ debugName: "activeIndex" }] : []));
|
|
502
|
+
normalizedOptions = computed(() => normalizeOptions(this.options(), {
|
|
503
|
+
label: this.optionLabel(),
|
|
504
|
+
value: this.optionValue(),
|
|
505
|
+
disabled: this.optionDisabled(),
|
|
506
|
+
}), ...(ngDevMode ? [{ debugName: "normalizedOptions" }] : []));
|
|
507
|
+
activeDescendantId = computed(() => {
|
|
508
|
+
const index = this.activeIndex();
|
|
509
|
+
if (index < 0)
|
|
510
|
+
return null;
|
|
511
|
+
return this.optionId(index);
|
|
512
|
+
}, ...(ngDevMode ? [{ debugName: "activeDescendantId" }] : []));
|
|
513
|
+
hostClasses = computed(() => {
|
|
514
|
+
const array = [this.hostClassBase];
|
|
515
|
+
if (this.isOpen())
|
|
516
|
+
array.push(`${this.hostClassBase}--open`);
|
|
517
|
+
array.push(`${this.CLASS_NAME}--${this.size()}`);
|
|
518
|
+
if (this.fluid())
|
|
519
|
+
array.push(`${this.CLASS_NAME}--fluid`);
|
|
520
|
+
return array.concat(this.controlClasses());
|
|
521
|
+
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
522
|
+
get listboxId() {
|
|
523
|
+
return `${this.uniqueId}-listbox`;
|
|
524
|
+
}
|
|
525
|
+
// Protected methods
|
|
526
|
+
open() {
|
|
527
|
+
const triggerElement = this.triggerElement();
|
|
528
|
+
const panelTemplate = this.panelTemplate();
|
|
529
|
+
if (this.notInteractive() || this.isOpen() || !triggerElement || !panelTemplate)
|
|
530
|
+
return;
|
|
531
|
+
this.overlay.open({
|
|
532
|
+
content: panelTemplate,
|
|
533
|
+
origin: triggerElement,
|
|
534
|
+
positions: [
|
|
535
|
+
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 4 },
|
|
536
|
+
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -4 },
|
|
537
|
+
],
|
|
538
|
+
flexibleDimensions: false,
|
|
539
|
+
push: false,
|
|
540
|
+
panelClass: this.panelClass,
|
|
541
|
+
// The control handles Escape itself via the trigger's keydown handler.
|
|
542
|
+
closeOnEscape: false,
|
|
543
|
+
minWidth: triggerElement.nativeElement.offsetWidth,
|
|
544
|
+
reuse: true,
|
|
545
|
+
onClose: () => {
|
|
546
|
+
this.activeIndex.set(-1);
|
|
547
|
+
const trigger = this.triggerElement();
|
|
548
|
+
if (trigger)
|
|
549
|
+
trigger.nativeElement.focus();
|
|
550
|
+
},
|
|
551
|
+
});
|
|
552
|
+
this.activeIndex.set(this.getInitialActiveIndex());
|
|
553
|
+
}
|
|
554
|
+
close() {
|
|
555
|
+
this.overlay.close();
|
|
556
|
+
}
|
|
557
|
+
toggle() {
|
|
558
|
+
if (this.isOpen()) {
|
|
559
|
+
this.close();
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
this.open();
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
onOptionHover(index, disabled) {
|
|
566
|
+
if (!disabled)
|
|
567
|
+
this.activeIndex.set(index);
|
|
568
|
+
}
|
|
569
|
+
onKeydown(event) {
|
|
570
|
+
if (event.key === 'ArrowDown') {
|
|
571
|
+
event.preventDefault();
|
|
572
|
+
if (this.isOpen()) {
|
|
573
|
+
this.moveActive(1);
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
this.open();
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
else if (event.key === 'ArrowUp') {
|
|
580
|
+
event.preventDefault();
|
|
581
|
+
if (this.isOpen()) {
|
|
582
|
+
this.moveActive(-1);
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
this.open();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
else if (event.key === 'Enter' || event.key === ' ') {
|
|
589
|
+
event.preventDefault();
|
|
590
|
+
if (!this.isOpen()) {
|
|
591
|
+
this.open();
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const active = this.normalizedOptions()[this.activeIndex()];
|
|
595
|
+
if (active && !active.disabled)
|
|
596
|
+
this.commitActiveOption(active);
|
|
597
|
+
}
|
|
598
|
+
else if (event.key === 'Home') {
|
|
599
|
+
if (!this.isOpen())
|
|
600
|
+
return;
|
|
601
|
+
event.preventDefault();
|
|
602
|
+
this.moveActiveToEdge(1);
|
|
603
|
+
}
|
|
604
|
+
else if (event.key === 'End') {
|
|
605
|
+
if (!this.isOpen())
|
|
606
|
+
return;
|
|
607
|
+
event.preventDefault();
|
|
608
|
+
this.moveActiveToEdge(-1);
|
|
609
|
+
}
|
|
610
|
+
else if (event.key === 'Escape') {
|
|
611
|
+
event.preventDefault();
|
|
612
|
+
if (this.isOpen())
|
|
613
|
+
this.close();
|
|
614
|
+
}
|
|
615
|
+
else if (event.key === 'Tab') {
|
|
616
|
+
if (this.isOpen())
|
|
617
|
+
this.close();
|
|
618
|
+
}
|
|
619
|
+
else if ((event.key === 'Delete' || event.key === 'Backspace') &&
|
|
620
|
+
this.clearable() &&
|
|
621
|
+
this.hasValue()) {
|
|
622
|
+
event.preventDefault();
|
|
623
|
+
this.clear();
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
optionId(index) {
|
|
627
|
+
return `${this.uniqueId}-option-${index}`;
|
|
628
|
+
}
|
|
629
|
+
// Private methods
|
|
630
|
+
moveActive(direction) {
|
|
631
|
+
const options = this.normalizedOptions();
|
|
632
|
+
let next = this.activeIndex() + direction;
|
|
633
|
+
while (next >= 0 && next < options.length) {
|
|
634
|
+
if (!options[next].disabled) {
|
|
635
|
+
this.activeIndex.set(next);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
next += direction;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
moveActiveToEdge(direction) {
|
|
642
|
+
const options = this.normalizedOptions();
|
|
643
|
+
let next = direction === 1 ? 0 : options.length - 1;
|
|
644
|
+
while (next >= 0 && next < options.length) {
|
|
645
|
+
if (!options[next].disabled) {
|
|
646
|
+
this.activeIndex.set(next);
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
next += direction;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: AbstractSelect, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
653
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.1", type: AbstractSelect, isStandalone: true, inputs: { inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, optionDisabled: { classPropertyName: "optionDisabled", publicName: "optionDisabled", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "triggerElement", first: true, predicate: ["trigger"], descendants: true, isSignal: true }, { propertyName: "panelTemplate", first: true, predicate: ["panel"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 });
|
|
654
|
+
}
|
|
655
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: AbstractSelect, decorators: [{
|
|
656
|
+
type: Directive
|
|
657
|
+
}], propDecorators: { triggerElement: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }], panelTemplate: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: false }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: false }] }], optionDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionDisabled", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
|
|
658
|
+
|
|
659
|
+
// Form control base classes
|
|
327
660
|
|
|
328
661
|
const DEFAULT_CHIP_CONTROL_CONFIG = {
|
|
329
662
|
checkedColor: undefined,
|
|
663
|
+
checkedVariant: undefined,
|
|
330
664
|
};
|
|
331
665
|
|
|
332
666
|
const CHIP_CONTROL_CONFIG = new InjectionToken('CHIP_CONTROL_CONFIG', {
|
|
@@ -339,6 +673,7 @@ class ChipControl extends CheckboxFormControl {
|
|
|
339
673
|
_chip = inject(Chip);
|
|
340
674
|
checked = model(false, ...(ngDevMode ? [{ debugName: "checked" }] : []));
|
|
341
675
|
checkedColor = input(this._config.checkedColor, ...(ngDevMode ? [{ debugName: "checkedColor" }] : []));
|
|
676
|
+
checkedVariant = input(this._config.checkedVariant, ...(ngDevMode ? [{ debugName: "checkedVariant" }] : []));
|
|
342
677
|
hostClasses = computed(() => {
|
|
343
678
|
const classes = ['tls-chip--control'];
|
|
344
679
|
if (this.checked()) {
|
|
@@ -346,6 +681,9 @@ class ChipControl extends CheckboxFormControl {
|
|
|
346
681
|
const color = this.checkedColor();
|
|
347
682
|
if (color)
|
|
348
683
|
classes.push(`tls-chip--checked-${color}`);
|
|
684
|
+
const variant = this.checkedVariant();
|
|
685
|
+
if (variant)
|
|
686
|
+
classes.push(`tls-chip--checked-${variant}`);
|
|
349
687
|
}
|
|
350
688
|
if (this.disabled())
|
|
351
689
|
classes.push('tls-chip--disabled');
|
|
@@ -373,7 +711,7 @@ class ChipControl extends CheckboxFormControl {
|
|
|
373
711
|
this.toggle();
|
|
374
712
|
}
|
|
375
713
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ChipControl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
376
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: ChipControl, isStandalone: true, selector: "tls-chip[tlsChipControl]", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, checkedColor: { classPropertyName: "checkedColor", publicName: "checkedColor", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange" }, host: { attributes: { "role": "checkbox" }, listeners: { "click": "toggle()", "blur": "touched.set(true)", "keydown.space": "onKeyboardToggle($event)", "keydown.enter": "onKeyboardToggle($event)" }, properties: { "class": "hostClasses()", "tabindex": "disabled() ? -1 : 0", "attr.aria-checked": "checked()", "attr.aria-disabled": "disabled()" } }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => ChipControl) }], usesInheritance: true, ngImport: i0 });
|
|
714
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.1", type: ChipControl, isStandalone: true, selector: "tls-chip[tlsChipControl]", inputs: { checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, checkedColor: { classPropertyName: "checkedColor", publicName: "checkedColor", isSignal: true, isRequired: false, transformFunction: null }, checkedVariant: { classPropertyName: "checkedVariant", publicName: "checkedVariant", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange" }, host: { attributes: { "role": "checkbox" }, listeners: { "click": "toggle()", "blur": "touched.set(true)", "keydown.space": "onKeyboardToggle($event)", "keydown.enter": "onKeyboardToggle($event)" }, properties: { "class": "hostClasses()", "tabindex": "disabled() ? -1 : 0", "attr.aria-checked": "checked()", "attr.aria-disabled": "disabled()" } }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => ChipControl) }], usesInheritance: true, ngImport: i0 });
|
|
377
715
|
}
|
|
378
716
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ChipControl, decorators: [{
|
|
379
717
|
type: Directive,
|
|
@@ -392,7 +730,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
392
730
|
},
|
|
393
731
|
providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => ChipControl) }],
|
|
394
732
|
}]
|
|
395
|
-
}], ctorParameters: () => [], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], checkedColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkedColor", required: false }] }] } });
|
|
733
|
+
}], ctorParameters: () => [], propDecorators: { checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], checkedColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkedColor", required: false }] }], checkedVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkedVariant", required: false }] }] } });
|
|
396
734
|
|
|
397
735
|
const DEFAULT_DIALOG_CONFIG = {
|
|
398
736
|
size: 'md',
|
|
@@ -666,119 +1004,16 @@ class Checkbox extends CheckboxFormControl {
|
|
|
666
1004
|
this.toggle();
|
|
667
1005
|
}
|
|
668
1006
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Checkbox, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
669
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Checkbox, isStandalone: true, selector: "tls-checkbox", inputs: { indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { indeterminate: "indeterminateChange", checked: "checkedChange" }, host: { attributes: { "role": "checkbox" }, properties: { "class": "hostClasses()", "tabindex": "-1" } }, usesInheritance: true, ngImport: i0, template: "<input\n type=\"checkbox\"\n class=\"tls-checkbox-input\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n (click)=\"toggle()\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardToggle($event)\"\n (keydown.enter)=\"onKeyboardToggle($event)\"\n/>\n<div class=\"tls-checkbox-icon\">\n @if (indeterminate()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M288-444v-72h384v72H288Z\" />\n </svg>\n } @else {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M400-301 240-461l51-51 109 109 269-269 51 51-320 320Z\" />\n </svg>\n }\n</div>\n" });
|
|
670
|
-
}
|
|
671
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Checkbox, decorators: [{
|
|
672
|
-
type: Component,
|
|
673
|
-
args: [{ selector: 'tls-checkbox', imports: [], host: {
|
|
674
|
-
role: 'checkbox',
|
|
675
|
-
'[class]': 'hostClasses()',
|
|
676
|
-
'[tabindex]': '-1',
|
|
677
|
-
}, template: "<input\n type=\"checkbox\"\n class=\"tls-checkbox-input\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n (click)=\"toggle()\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardToggle($event)\"\n (keydown.enter)=\"onKeyboardToggle($event)\"\n/>\n<div class=\"tls-checkbox-icon\">\n @if (indeterminate()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M288-444v-72h384v72H288Z\" />\n </svg>\n } @else {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M400-301 240-461l51-51 109 109 269-269 51 51-320 320Z\" />\n </svg>\n }\n</div>\n" }]
|
|
678
|
-
}], propDecorators: { indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }, { type: i0.Output, args: ["indeterminateChange"] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
|
|
679
|
-
|
|
680
|
-
const TRANSPARENT_BACKDROP_CLASS = 'cdk-overlay-transparent-backdrop';
|
|
681
|
-
/**
|
|
682
|
-
* Owns the CDK-Overlay lifecycle shared by the library's connected overlay
|
|
683
|
-
* components (popover, menu, select): create/attach, dismissal wiring
|
|
684
|
-
* (backdrop / outside-pointer / Escape), `isOpen` state, and disposal. The
|
|
685
|
-
* positional and dismissal differences between components are expressed through
|
|
686
|
-
* {@link ConnectedOverlayConfig} rather than duplicated per component.
|
|
687
|
-
*
|
|
688
|
-
* Create one via {@link createOverlayManager} from a component field initializer
|
|
689
|
-
* so it is bound to the host's injection context.
|
|
690
|
-
*/
|
|
691
|
-
class OverlayManager {
|
|
692
|
-
_overlay = inject(Overlay);
|
|
693
|
-
_viewContainerRef = inject(ViewContainerRef);
|
|
694
|
-
_destroyRef = inject(DestroyRef);
|
|
695
|
-
_overlayRef = null;
|
|
696
|
-
_config = null;
|
|
697
|
-
_isOpen = signal(false, ...(ngDevMode ? [{ debugName: "_isOpen" }] : []));
|
|
698
|
-
isOpen = this._isOpen.asReadonly();
|
|
699
|
-
// Dispose the overlay with the host. Registered in a field initializer so no
|
|
700
|
-
// constructor is needed.
|
|
701
|
-
_teardown = this._destroyRef.onDestroy(() => this._dispose());
|
|
702
|
-
open(config) {
|
|
703
|
-
if (this._isOpen())
|
|
704
|
-
return;
|
|
705
|
-
this._config = config;
|
|
706
|
-
if (!this._overlayRef) {
|
|
707
|
-
this._overlayRef = this._overlay.create({
|
|
708
|
-
positionStrategy: this._buildPositionStrategy(config),
|
|
709
|
-
scrollStrategy: config.scrollStrategy === 'close'
|
|
710
|
-
? this._overlay.scrollStrategies.close()
|
|
711
|
-
: this._overlay.scrollStrategies.reposition(),
|
|
712
|
-
hasBackdrop: config.hasBackdrop ?? true,
|
|
713
|
-
backdropClass: config.backdropClass ?? TRANSPARENT_BACKDROP_CLASS,
|
|
714
|
-
...(config.panelClass != null && { panelClass: config.panelClass }),
|
|
715
|
-
});
|
|
716
|
-
this._wireDismissal(this._overlayRef, config);
|
|
717
|
-
}
|
|
718
|
-
if (config.minWidth != null) {
|
|
719
|
-
this._overlayRef.updateSize({ minWidth: config.minWidth });
|
|
720
|
-
}
|
|
721
|
-
this._overlayRef.attach(new TemplatePortal(config.content, this._viewContainerRef));
|
|
722
|
-
this._isOpen.set(true);
|
|
723
|
-
}
|
|
724
|
-
close() {
|
|
725
|
-
if (!this._isOpen())
|
|
726
|
-
return;
|
|
727
|
-
if (this._config?.reuse) {
|
|
728
|
-
this._overlayRef?.detach();
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
this._overlayRef?.dispose();
|
|
732
|
-
this._overlayRef = null;
|
|
733
|
-
}
|
|
734
|
-
this._isOpen.set(false);
|
|
735
|
-
this._config?.onClose?.();
|
|
736
|
-
}
|
|
737
|
-
// Private
|
|
738
|
-
_buildPositionStrategy(config) {
|
|
739
|
-
let strategy = this._overlay
|
|
740
|
-
.position()
|
|
741
|
-
.flexibleConnectedTo(config.origin)
|
|
742
|
-
.withPositions(config.positions);
|
|
743
|
-
if (config.flexibleDimensions === false)
|
|
744
|
-
strategy = strategy.withFlexibleDimensions(false);
|
|
745
|
-
if (config.push === false)
|
|
746
|
-
strategy = strategy.withPush(false);
|
|
747
|
-
return strategy;
|
|
748
|
-
}
|
|
749
|
-
_wireDismissal(overlayRef, config) {
|
|
750
|
-
const hasBackdrop = config.hasBackdrop ?? true;
|
|
751
|
-
if (config.closeOnBackdropClick ?? hasBackdrop) {
|
|
752
|
-
overlayRef
|
|
753
|
-
.backdropClick()
|
|
754
|
-
.pipe(takeUntilDestroyed(this._destroyRef))
|
|
755
|
-
.subscribe(() => this.close());
|
|
756
|
-
}
|
|
757
|
-
if (config.closeOnOutsidePointer ?? !hasBackdrop) {
|
|
758
|
-
overlayRef
|
|
759
|
-
.outsidePointerEvents()
|
|
760
|
-
.pipe(takeUntilDestroyed(this._destroyRef), filter(event => event.type === 'click' || event.type === 'auxclick'))
|
|
761
|
-
.subscribe(() => this.close());
|
|
762
|
-
}
|
|
763
|
-
if (config.closeOnEscape ?? true) {
|
|
764
|
-
overlayRef
|
|
765
|
-
.keydownEvents()
|
|
766
|
-
.pipe(takeUntilDestroyed(this._destroyRef), filter(event => event.key === 'Escape'))
|
|
767
|
-
.subscribe(() => this.close());
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
_dispose() {
|
|
771
|
-
this._overlayRef?.dispose();
|
|
772
|
-
this._overlayRef = null;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Creates an {@link OverlayManager} bound to the current injection context.
|
|
777
|
-
* Call from a component/directive field initializer or constructor.
|
|
778
|
-
*/
|
|
779
|
-
function createOverlayManager() {
|
|
780
|
-
return new OverlayManager();
|
|
1007
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: Checkbox, isStandalone: true, selector: "tls-checkbox", inputs: { indeterminate: { classPropertyName: "indeterminate", publicName: "indeterminate", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { indeterminate: "indeterminateChange", checked: "checkedChange" }, host: { attributes: { "role": "checkbox" }, properties: { "class": "hostClasses()", "tabindex": "-1" } }, usesInheritance: true, ngImport: i0, template: "<input\n type=\"checkbox\"\n class=\"tls-checkbox-input\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n (click)=\"toggle()\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardToggle($event)\"\n (keydown.enter)=\"onKeyboardToggle($event)\"\n/>\n<div class=\"tls-checkbox-icon\">\n @if (indeterminate()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M288-444v-72h384v72H288Z\" />\n </svg>\n } @else {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M400-301 240-461l51-51 109 109 269-269 51 51-320 320Z\" />\n </svg>\n }\n</div>\n" });
|
|
781
1008
|
}
|
|
1009
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: Checkbox, decorators: [{
|
|
1010
|
+
type: Component,
|
|
1011
|
+
args: [{ selector: 'tls-checkbox', imports: [], host: {
|
|
1012
|
+
role: 'checkbox',
|
|
1013
|
+
'[class]': 'hostClasses()',
|
|
1014
|
+
'[tabindex]': '-1',
|
|
1015
|
+
}, template: "<input\n type=\"checkbox\"\n class=\"tls-checkbox-input\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n (click)=\"toggle()\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardToggle($event)\"\n (keydown.enter)=\"onKeyboardToggle($event)\"\n/>\n<div class=\"tls-checkbox-icon\">\n @if (indeterminate()) {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M288-444v-72h384v72H288Z\" />\n </svg>\n } @else {\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n height=\"20px\"\n viewBox=\"0 -960 960 960\"\n width=\"20px\"\n fill=\"currentColor\"\n >\n <path d=\"M400-301 240-461l51-51 109 109 269-269 51 51-320 320Z\" />\n </svg>\n }\n</div>\n" }]
|
|
1016
|
+
}], propDecorators: { indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }, { type: i0.Output, args: ["indeterminateChange"] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
|
|
782
1017
|
|
|
783
1018
|
const OVERLAY_POSITION_MAP = {
|
|
784
1019
|
top: {
|
|
@@ -1292,6 +1527,81 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
1292
1527
|
args: [{ selector: 'tls-date-time-picker', imports: [Calendar, MonthPicker, YearPicker, TimePicker, Popover, NgTemplateOutlet], host: { '[class]': 'hostClasses()' }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => DateTimePicker) }], template: "<ng-template #pickerTemplate>\n @switch (activeView()) {\n @case ('calendar') {\n <tls-calendar\n [viewDate]=\"viewDate()\"\n [selectedDate]=\"value()\"\n [weekStartsOn]=\"weekStartsOn()\"\n [weekDays]=\"weekDays()\"\n (daySelect)=\"onDaySelect($event)\"\n (viewDateChange)=\"onViewDateChange($event)\"\n (navigateUp)=\"activeView.set('month-picker')\"\n />\n }\n @case ('month-picker') {\n <tls-month-picker\n [viewDate]=\"viewDate()\"\n [selectedDate]=\"value()\"\n (monthSelect)=\"onMonthSelect($event)\"\n (viewDateChange)=\"onViewDateChange($event)\"\n (navigateUp)=\"activeView.set('year-picker')\"\n />\n }\n @case ('year-picker') {\n <tls-year-picker\n [viewDate]=\"viewDate()\"\n [selectedDate]=\"value()\"\n [yearsPerPage]=\"yearsPerPage()\"\n (yearSelect)=\"onYearSelect($event)\"\n (viewDateChange)=\"onViewDateChange($event)\"\n />\n }\n @case ('time-picker') {\n <tls-time-picker\n [value]=\"value()\"\n (timeChange)=\"onTimeChange($event)\"\n />\n }\n @case ('date-time') {\n <tls-calendar\n [viewDate]=\"viewDate()\"\n [selectedDate]=\"value()\"\n [weekStartsOn]=\"weekStartsOn()\"\n [weekDays]=\"weekDays()\"\n (daySelect)=\"onDaySelect($event)\"\n (viewDateChange)=\"onViewDateChange($event)\"\n (navigateUp)=\"activeView.set('month-picker')\"\n />\n <tls-time-picker\n [value]=\"value()\"\n (timeChange)=\"onTimeChange($event)\"\n />\n }\n }\n</ng-template>\n\n@if (inline()) {\n <div\n class=\"tls-date-time-picker__panel\"\n [class.tls-date-time-picker__panel--disabled]=\"disabled()\"\n [class.tls-date-time-picker__panel--readonly]=\"readonly()\"\n [class.tls-date-time-picker__panel--invalid]=\"invalid()\"\n >\n <ng-container [ngTemplateOutlet]=\"pickerTemplate\" />\n </div>\n} @else {\n <button\n type=\"button\"\n class=\"tls-date-time-picker__trigger\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"popoverRef.isOpen()\"\n [disabled]=\"disabled()\"\n (click)=\"popoverRef.toggle($event)\"\n (blur)=\"touched.set(true)\"\n >\n <span [class.tls-form-control__placeholder]=\"!value()\">{{ triggerLabel() }}</span>\n </button>\n <tls-popover #popoverRef position=\"bottom-start\">\n <ng-container [ngTemplateOutlet]=\"pickerTemplate\" />\n </tls-popover>\n}\n" }]
|
|
1293
1528
|
}], ctorParameters: () => [], propDecorators: { popoverComponent: [{ type: i0.ViewChild, args: ['popoverRef', { isSignal: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], inline: [{ type: i0.Input, args: [{ isSignal: true, alias: "inline", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], fluid: [{ type: i0.Input, args: [{ isSignal: true, alias: "fluid", required: false }] }], yearsPerPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "yearsPerPage", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], weekDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekDays", required: false }] }] } });
|
|
1294
1529
|
|
|
1530
|
+
const DEFAULT_CHIP_GROUP_CONFIG = {
|
|
1531
|
+
size: 'md',
|
|
1532
|
+
color: 'primary',
|
|
1533
|
+
checkedColor: undefined,
|
|
1534
|
+
variant: 'outlined',
|
|
1535
|
+
checkedVariant: undefined,
|
|
1536
|
+
orientation: 'horizontal',
|
|
1537
|
+
type: 'multiple',
|
|
1538
|
+
unselectable: false,
|
|
1539
|
+
rounded: false,
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
const CHIP_GROUP_CONFIG = new InjectionToken('CHIP_GROUP_CONFIG', {
|
|
1543
|
+
factory: () => DEFAULT_CHIP_GROUP_CONFIG,
|
|
1544
|
+
});
|
|
1545
|
+
|
|
1546
|
+
class ChipGroup extends SelectionGroup {
|
|
1547
|
+
_config = inject(CHIP_GROUP_CONFIG);
|
|
1548
|
+
CLASS_NAME = 'tls-chip-group';
|
|
1549
|
+
type = input(this._config.type, ...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
1550
|
+
unselectable = input(this._config.unselectable, { ...(ngDevMode ? { debugName: "unselectable" } : {}), transform: booleanAttribute });
|
|
1551
|
+
size = input(this._config.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
1552
|
+
color = input(this._config.color, ...(ngDevMode ? [{ debugName: "color" }] : []));
|
|
1553
|
+
checkedColor = input(this._config.checkedColor, ...(ngDevMode ? [{ debugName: "checkedColor" }] : []));
|
|
1554
|
+
variant = input(this._config.variant, ...(ngDevMode ? [{ debugName: "variant" }] : []));
|
|
1555
|
+
checkedVariant = input(this._config.checkedVariant, ...(ngDevMode ? [{ debugName: "checkedVariant" }] : []));
|
|
1556
|
+
orientation = input(this._config.orientation, ...(ngDevMode ? [{ debugName: "orientation" }] : []));
|
|
1557
|
+
rounded = input(this._config.rounded, { ...(ngDevMode ? { debugName: "rounded" } : {}), transform: booleanAttribute });
|
|
1558
|
+
startIconTemplate = contentChild('startIcon', ...(ngDevMode ? [{ debugName: "startIconTemplate" }] : []));
|
|
1559
|
+
endIconTemplate = contentChild('endIcon', ...(ngDevMode ? [{ debugName: "endIconTemplate" }] : []));
|
|
1560
|
+
labelTemplate = contentChild('label', ...(ngDevMode ? [{ debugName: "labelTemplate" }] : []));
|
|
1561
|
+
classes = computed(() => {
|
|
1562
|
+
const className = this.CLASS_NAME;
|
|
1563
|
+
const array = [className, `${className}--${this.orientation()}`];
|
|
1564
|
+
return array.concat(this.controlClasses());
|
|
1565
|
+
}, ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
1566
|
+
isDisabled(option) {
|
|
1567
|
+
return this.disabled() || option.disabled;
|
|
1568
|
+
}
|
|
1569
|
+
optionClasses(option) {
|
|
1570
|
+
const classes = ['tls-chip--control'];
|
|
1571
|
+
if (this.isSelected(option.value)) {
|
|
1572
|
+
classes.push('tls-chip--checked');
|
|
1573
|
+
const checkedColor = this.checkedColor();
|
|
1574
|
+
if (checkedColor)
|
|
1575
|
+
classes.push(`tls-chip--checked-${checkedColor}`);
|
|
1576
|
+
const checkedVariant = this.checkedVariant();
|
|
1577
|
+
if (checkedVariant)
|
|
1578
|
+
classes.push(`tls-chip--checked-${checkedVariant}`);
|
|
1579
|
+
}
|
|
1580
|
+
if (this.isDisabled(option))
|
|
1581
|
+
classes.push('tls-chip--disabled');
|
|
1582
|
+
return classes;
|
|
1583
|
+
}
|
|
1584
|
+
optionContext(option, index) {
|
|
1585
|
+
return {
|
|
1586
|
+
$implicit: {
|
|
1587
|
+
option,
|
|
1588
|
+
index,
|
|
1589
|
+
selected: this.isSelected(option.value),
|
|
1590
|
+
disabled: this.isDisabled(option),
|
|
1591
|
+
},
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ChipGroup, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
1595
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: ChipGroup, isStandalone: true, selector: "tls-chip-group", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, unselectable: { classPropertyName: "unselectable", publicName: "unselectable", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, checkedColor: { classPropertyName: "checkedColor", publicName: "checkedColor", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, checkedVariant: { classPropertyName: "checkedVariant", publicName: "checkedVariant", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "class": "classes()" } }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => ChipGroup) }], queries: [{ propertyName: "startIconTemplate", first: true, predicate: ["startIcon"], descendants: true, isSignal: true }, { propertyName: "endIconTemplate", first: true, predicate: ["endIcon"], descendants: true, isSignal: true }, { propertyName: "labelTemplate", first: true, predicate: ["label"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@for (option of normalizedOptions(); track option.value; let index = $index) {\n <tls-chip\n [color]=\"color()\"\n [variant]=\"variant()\"\n [size]=\"size()\"\n [rounded]=\"rounded()\"\n [class]=\"optionClasses(option)\"\n role=\"checkbox\"\n [attr.aria-checked]=\"isSelected(option.value)\"\n [attr.aria-disabled]=\"isDisabled(option)\"\n [tabindex]=\"isDisabled(option) ? -1 : 0\"\n (click)=\"select(option)\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardSelect($event, option)\"\n (keydown.enter)=\"onKeyboardSelect($event, option)\"\n >\n @if (startIconTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"optionContext(option, index)\"\n />\n }\n\n @if (labelTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"optionContext(option, index)\"\n />\n } @else {\n {{ option.label }}\n }\n\n @if (endIconTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"optionContext(option, index)\"\n />\n }\n </tls-chip>\n}\n\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: Chip, selector: "tls-chip", inputs: ["label", "color", "variant", "size", "rounded", "icon"] }] });
|
|
1596
|
+
}
|
|
1597
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ChipGroup, decorators: [{
|
|
1598
|
+
type: Component,
|
|
1599
|
+
args: [{ selector: 'tls-chip-group', imports: [NgTemplateOutlet, Chip], providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => ChipGroup) }], host: {
|
|
1600
|
+
role: 'group',
|
|
1601
|
+
'[class]': 'classes()',
|
|
1602
|
+
}, template: "@for (option of normalizedOptions(); track option.value; let index = $index) {\n <tls-chip\n [color]=\"color()\"\n [variant]=\"variant()\"\n [size]=\"size()\"\n [rounded]=\"rounded()\"\n [class]=\"optionClasses(option)\"\n role=\"checkbox\"\n [attr.aria-checked]=\"isSelected(option.value)\"\n [attr.aria-disabled]=\"isDisabled(option)\"\n [tabindex]=\"isDisabled(option) ? -1 : 0\"\n (click)=\"select(option)\"\n (blur)=\"touched.set(true)\"\n (keydown.space)=\"onKeyboardSelect($event, option)\"\n (keydown.enter)=\"onKeyboardSelect($event, option)\"\n >\n @if (startIconTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"optionContext(option, index)\"\n />\n }\n\n @if (labelTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"optionContext(option, index)\"\n />\n } @else {\n {{ option.label }}\n }\n\n @if (endIconTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"optionContext(option, index)\"\n />\n }\n </tls-chip>\n}\n\n" }]
|
|
1603
|
+
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], unselectable: [{ type: i0.Input, args: [{ isSignal: true, alias: "unselectable", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], checkedColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkedColor", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], checkedVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkedVariant", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], startIconTemplate: [{ type: i0.ContentChild, args: ['startIcon', { isSignal: true }] }], endIconTemplate: [{ type: i0.ContentChild, args: ['endIcon', { isSignal: true }] }], labelTemplate: [{ type: i0.ContentChild, args: ['label', { isSignal: true }] }] } });
|
|
1604
|
+
|
|
1295
1605
|
const DEFAULT_CHIP_INPUT_CONFIG = {
|
|
1296
1606
|
size: 'md',
|
|
1297
1607
|
placeholder: '',
|
|
@@ -1788,184 +2098,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
1788
2098
|
}, template: "<input\n type=\"radio\"\n class=\"tls-radio-button-input\"\n [id]=\"inputId()\"\n [name]=\"name()\"\n [tabindex]=\"tabindex()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n [checked]=\"checked()\"\n [value]=\"radioValue()\"\n (change)=\"check()\"\n (blur)=\"touched.set(true)\"\n/>\n<div class=\"tls-radio-button-circle\"></div>\n" }]
|
|
1789
2099
|
}], propDecorators: { radioValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "radioValue", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
|
|
1790
2100
|
|
|
1791
|
-
/**
|
|
1792
|
-
* Shared base for the single {@link Select} and {@link MultiSelect} controls.
|
|
1793
|
-
* Owns everything the two listbox-combobox controls have in common: the option
|
|
1794
|
-
* inputs, the connected overlay lifecycle, roving `aria-activedescendant`
|
|
1795
|
-
* navigation, and the keyboard handler. The per-control differences (the value
|
|
1796
|
-
* shape, the selected-state check, how the trigger label is built and what a
|
|
1797
|
-
* commit does) are expressed through the abstract members below.
|
|
1798
|
-
*/
|
|
1799
|
-
class AbstractSelect extends ValueFormControl {
|
|
1800
|
-
overlay = createOverlayManager();
|
|
1801
|
-
triggerElement = viewChild('trigger', ...(ngDevMode ? [{ debugName: "triggerElement" }] : []));
|
|
1802
|
-
panelTemplate = viewChild('panel', ...(ngDevMode ? [{ debugName: "panelTemplate" }] : []));
|
|
1803
|
-
// Shared inputs (config-independent)
|
|
1804
|
-
inputId = input(null, ...(ngDevMode ? [{ debugName: "inputId" }] : []));
|
|
1805
|
-
options = input([], ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
1806
|
-
optionLabel = input(undefined, ...(ngDevMode ? [{ debugName: "optionLabel" }] : []));
|
|
1807
|
-
optionValue = input(undefined, ...(ngDevMode ? [{ debugName: "optionValue" }] : []));
|
|
1808
|
-
optionDisabled = input(undefined, ...(ngDevMode ? [{ debugName: "optionDisabled" }] : []));
|
|
1809
|
-
tabindex = input(0, ...(ngDevMode ? [{ debugName: "tabindex" }] : []));
|
|
1810
|
-
isOpen = this.overlay.isOpen;
|
|
1811
|
-
activeIndex = signal(-1, ...(ngDevMode ? [{ debugName: "activeIndex" }] : []));
|
|
1812
|
-
normalizedOptions = computed(() => normalizeOptions(this.options(), {
|
|
1813
|
-
label: this.optionLabel(),
|
|
1814
|
-
value: this.optionValue(),
|
|
1815
|
-
disabled: this.optionDisabled(),
|
|
1816
|
-
}), ...(ngDevMode ? [{ debugName: "normalizedOptions" }] : []));
|
|
1817
|
-
activeDescendantId = computed(() => {
|
|
1818
|
-
const index = this.activeIndex();
|
|
1819
|
-
if (index < 0)
|
|
1820
|
-
return null;
|
|
1821
|
-
return this.optionId(index);
|
|
1822
|
-
}, ...(ngDevMode ? [{ debugName: "activeDescendantId" }] : []));
|
|
1823
|
-
hostClasses = computed(() => {
|
|
1824
|
-
const array = [this.hostClassBase];
|
|
1825
|
-
if (this.isOpen())
|
|
1826
|
-
array.push(`${this.hostClassBase}--open`);
|
|
1827
|
-
array.push(`${this.CLASS_NAME}--${this.size()}`);
|
|
1828
|
-
if (this.fluid())
|
|
1829
|
-
array.push(`${this.CLASS_NAME}--fluid`);
|
|
1830
|
-
return array.concat(this.controlClasses());
|
|
1831
|
-
}, ...(ngDevMode ? [{ debugName: "hostClasses" }] : []));
|
|
1832
|
-
get listboxId() {
|
|
1833
|
-
return `${this.uniqueId}-listbox`;
|
|
1834
|
-
}
|
|
1835
|
-
// Protected methods
|
|
1836
|
-
open() {
|
|
1837
|
-
const triggerElement = this.triggerElement();
|
|
1838
|
-
const panelTemplate = this.panelTemplate();
|
|
1839
|
-
if (this.notInteractive() || this.isOpen() || !triggerElement || !panelTemplate)
|
|
1840
|
-
return;
|
|
1841
|
-
this.overlay.open({
|
|
1842
|
-
content: panelTemplate,
|
|
1843
|
-
origin: triggerElement,
|
|
1844
|
-
positions: [
|
|
1845
|
-
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 4 },
|
|
1846
|
-
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -4 },
|
|
1847
|
-
],
|
|
1848
|
-
flexibleDimensions: false,
|
|
1849
|
-
push: false,
|
|
1850
|
-
panelClass: this.panelClass,
|
|
1851
|
-
// The control handles Escape itself via the trigger's keydown handler.
|
|
1852
|
-
closeOnEscape: false,
|
|
1853
|
-
minWidth: triggerElement.nativeElement.offsetWidth,
|
|
1854
|
-
reuse: true,
|
|
1855
|
-
onClose: () => {
|
|
1856
|
-
this.activeIndex.set(-1);
|
|
1857
|
-
const trigger = this.triggerElement();
|
|
1858
|
-
if (trigger)
|
|
1859
|
-
trigger.nativeElement.focus();
|
|
1860
|
-
},
|
|
1861
|
-
});
|
|
1862
|
-
this.activeIndex.set(this.getInitialActiveIndex());
|
|
1863
|
-
}
|
|
1864
|
-
close() {
|
|
1865
|
-
this.overlay.close();
|
|
1866
|
-
}
|
|
1867
|
-
toggle() {
|
|
1868
|
-
if (this.isOpen()) {
|
|
1869
|
-
this.close();
|
|
1870
|
-
}
|
|
1871
|
-
else {
|
|
1872
|
-
this.open();
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
onOptionHover(index, disabled) {
|
|
1876
|
-
if (!disabled)
|
|
1877
|
-
this.activeIndex.set(index);
|
|
1878
|
-
}
|
|
1879
|
-
onKeydown(event) {
|
|
1880
|
-
if (event.key === 'ArrowDown') {
|
|
1881
|
-
event.preventDefault();
|
|
1882
|
-
if (this.isOpen()) {
|
|
1883
|
-
this.moveActive(1);
|
|
1884
|
-
}
|
|
1885
|
-
else {
|
|
1886
|
-
this.open();
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
else if (event.key === 'ArrowUp') {
|
|
1890
|
-
event.preventDefault();
|
|
1891
|
-
if (this.isOpen()) {
|
|
1892
|
-
this.moveActive(-1);
|
|
1893
|
-
}
|
|
1894
|
-
else {
|
|
1895
|
-
this.open();
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
else if (event.key === 'Enter' || event.key === ' ') {
|
|
1899
|
-
event.preventDefault();
|
|
1900
|
-
if (!this.isOpen()) {
|
|
1901
|
-
this.open();
|
|
1902
|
-
return;
|
|
1903
|
-
}
|
|
1904
|
-
const active = this.normalizedOptions()[this.activeIndex()];
|
|
1905
|
-
if (active && !active.disabled)
|
|
1906
|
-
this.commitActiveOption(active);
|
|
1907
|
-
}
|
|
1908
|
-
else if (event.key === 'Home') {
|
|
1909
|
-
if (!this.isOpen())
|
|
1910
|
-
return;
|
|
1911
|
-
event.preventDefault();
|
|
1912
|
-
this.moveActiveToEdge(1);
|
|
1913
|
-
}
|
|
1914
|
-
else if (event.key === 'End') {
|
|
1915
|
-
if (!this.isOpen())
|
|
1916
|
-
return;
|
|
1917
|
-
event.preventDefault();
|
|
1918
|
-
this.moveActiveToEdge(-1);
|
|
1919
|
-
}
|
|
1920
|
-
else if (event.key === 'Escape') {
|
|
1921
|
-
event.preventDefault();
|
|
1922
|
-
if (this.isOpen())
|
|
1923
|
-
this.close();
|
|
1924
|
-
}
|
|
1925
|
-
else if (event.key === 'Tab') {
|
|
1926
|
-
if (this.isOpen())
|
|
1927
|
-
this.close();
|
|
1928
|
-
}
|
|
1929
|
-
else if ((event.key === 'Delete' || event.key === 'Backspace') &&
|
|
1930
|
-
this.clearable() &&
|
|
1931
|
-
this.hasValue()) {
|
|
1932
|
-
event.preventDefault();
|
|
1933
|
-
this.clear();
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
optionId(index) {
|
|
1937
|
-
return `${this.uniqueId}-option-${index}`;
|
|
1938
|
-
}
|
|
1939
|
-
// Private methods
|
|
1940
|
-
moveActive(direction) {
|
|
1941
|
-
const options = this.normalizedOptions();
|
|
1942
|
-
let next = this.activeIndex() + direction;
|
|
1943
|
-
while (next >= 0 && next < options.length) {
|
|
1944
|
-
if (!options[next].disabled) {
|
|
1945
|
-
this.activeIndex.set(next);
|
|
1946
|
-
return;
|
|
1947
|
-
}
|
|
1948
|
-
next += direction;
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
moveActiveToEdge(direction) {
|
|
1952
|
-
const options = this.normalizedOptions();
|
|
1953
|
-
let next = direction === 1 ? 0 : options.length - 1;
|
|
1954
|
-
while (next >= 0 && next < options.length) {
|
|
1955
|
-
if (!options[next].disabled) {
|
|
1956
|
-
this.activeIndex.set(next);
|
|
1957
|
-
return;
|
|
1958
|
-
}
|
|
1959
|
-
next += direction;
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: AbstractSelect, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
1963
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.1", type: AbstractSelect, isStandalone: true, inputs: { inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: false, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: false, transformFunction: null }, optionDisabled: { classPropertyName: "optionDisabled", publicName: "optionDisabled", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "triggerElement", first: true, predicate: ["trigger"], descendants: true, isSignal: true }, { propertyName: "panelTemplate", first: true, predicate: ["panel"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0 });
|
|
1964
|
-
}
|
|
1965
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: AbstractSelect, decorators: [{
|
|
1966
|
-
type: Directive
|
|
1967
|
-
}], propDecorators: { triggerElement: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }], panelTemplate: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: false }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: false }] }], optionDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionDisabled", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }] } });
|
|
1968
|
-
|
|
1969
2101
|
const DEFAULT_MULTI_SELECT_CONFIG = {
|
|
1970
2102
|
size: 'md',
|
|
1971
2103
|
placeholder: '',
|
|
@@ -2201,25 +2333,15 @@ const TOGGLE_GROUP_CONFIG = new InjectionToken('TOGGLE_GROUP_CONFIG', {
|
|
|
2201
2333
|
factory: () => DEFAULT_TOGGLE_GROUP_CONFIG,
|
|
2202
2334
|
});
|
|
2203
2335
|
|
|
2204
|
-
class ToggleGroup extends
|
|
2336
|
+
class ToggleGroup extends SelectionGroup {
|
|
2205
2337
|
_config = inject(TOGGLE_GROUP_CONFIG);
|
|
2206
2338
|
CLASS_NAME = 'tls-toggle-group';
|
|
2207
|
-
value = model([], ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
2208
|
-
options = input([], ...(ngDevMode ? [{ debugName: "options" }] : []));
|
|
2209
|
-
optionLabel = input(undefined, ...(ngDevMode ? [{ debugName: "optionLabel" }] : []));
|
|
2210
|
-
optionValue = input(undefined, ...(ngDevMode ? [{ debugName: "optionValue" }] : []));
|
|
2211
|
-
optionDisabled = input(undefined, ...(ngDevMode ? [{ debugName: "optionDisabled" }] : []));
|
|
2212
2339
|
type = input(this._config.type, ...(ngDevMode ? [{ debugName: "type" }] : []));
|
|
2213
2340
|
unselectable = input(this._config.unselectable, { ...(ngDevMode ? { debugName: "unselectable" } : {}), transform: booleanAttribute });
|
|
2214
2341
|
size = input(this._config.size, ...(ngDevMode ? [{ debugName: "size" }] : []));
|
|
2215
2342
|
color = input(this._config.color, ...(ngDevMode ? [{ debugName: "color" }] : []));
|
|
2216
2343
|
orientation = input(this._config.orientation, ...(ngDevMode ? [{ debugName: "orientation" }] : []));
|
|
2217
2344
|
optionTemplate = contentChild('option', ...(ngDevMode ? [{ debugName: "optionTemplate" }] : []));
|
|
2218
|
-
normalizedOptions = computed(() => normalizeOptions(this.options(), {
|
|
2219
|
-
label: this.optionLabel(),
|
|
2220
|
-
value: this.optionValue(),
|
|
2221
|
-
disabled: this.optionDisabled(),
|
|
2222
|
-
}), ...(ngDevMode ? [{ debugName: "normalizedOptions" }] : []));
|
|
2223
2345
|
classes = computed(() => {
|
|
2224
2346
|
const className = this.CLASS_NAME;
|
|
2225
2347
|
const array = [
|
|
@@ -2230,27 +2352,8 @@ class ToggleGroup extends ValueFormControl {
|
|
|
2230
2352
|
];
|
|
2231
2353
|
return array.concat(this.controlClasses());
|
|
2232
2354
|
}, ...(ngDevMode ? [{ debugName: "classes" }] : []));
|
|
2233
|
-
isSelected(optionValue) {
|
|
2234
|
-
return this.value().includes(optionValue);
|
|
2235
|
-
}
|
|
2236
|
-
select(option) {
|
|
2237
|
-
if (this.notInteractive() || option.disabled)
|
|
2238
|
-
return;
|
|
2239
|
-
if (this.type() === 'single') {
|
|
2240
|
-
if (this.isSelected(option.value) && !this.unselectable())
|
|
2241
|
-
return;
|
|
2242
|
-
this.value.set(this.isSelected(option.value) ? [] : [option.value]);
|
|
2243
|
-
return;
|
|
2244
|
-
}
|
|
2245
|
-
if (this.isSelected(option.value)) {
|
|
2246
|
-
this.value.update(current => current.filter(item => item !== option.value));
|
|
2247
|
-
}
|
|
2248
|
-
else {
|
|
2249
|
-
this.value.update(current => [...current, option.value]);
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
2355
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ToggleGroup, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2253
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: ToggleGroup, isStandalone: true, selector: "tls-toggle-group", inputs: {
|
|
2356
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.1", type: ToggleGroup, isStandalone: true, selector: "tls-toggle-group", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, unselectable: { classPropertyName: "unselectable", publicName: "unselectable", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "class": "classes()" } }, providers: [{ provide: FORM_CONTROL, useExisting: forwardRef(() => ToggleGroup) }], queries: [{ propertyName: "optionTemplate", first: true, predicate: ["option"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "@for (option of normalizedOptions(); track option.value) {\n <button\n type=\"button\"\n class=\"tls-toggle-group__option\"\n [class.tls-toggle-group__option--selected]=\"isSelected(option.value)\"\n [class.tls-toggle-group__option--disabled]=\"option.disabled\"\n [attr.aria-pressed]=\"isSelected(option.value)\"\n [disabled]=\"disabled() || option.disabled\"\n (click)=\"select(option)\"\n (blur)=\"touched.set(true)\"\n >\n @if (optionTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ $implicit: option }\" />\n } @else {\n {{ option.label }}\n }\n </button>\n}\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
|
|
2254
2357
|
}
|
|
2255
2358
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImport: i0, type: ToggleGroup, decorators: [{
|
|
2256
2359
|
type: Component,
|
|
@@ -2258,7 +2361,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
|
|
|
2258
2361
|
role: 'group',
|
|
2259
2362
|
'[class]': 'classes()',
|
|
2260
2363
|
}, template: "@for (option of normalizedOptions(); track option.value) {\n <button\n type=\"button\"\n class=\"tls-toggle-group__option\"\n [class.tls-toggle-group__option--selected]=\"isSelected(option.value)\"\n [class.tls-toggle-group__option--disabled]=\"option.disabled\"\n [attr.aria-pressed]=\"isSelected(option.value)\"\n [disabled]=\"disabled() || option.disabled\"\n (click)=\"select(option)\"\n (blur)=\"touched.set(true)\"\n >\n @if (optionTemplate(); as template) {\n <ng-container [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ $implicit: option }\" />\n } @else {\n {{ option.label }}\n }\n </button>\n}\n" }]
|
|
2261
|
-
}], propDecorators: {
|
|
2364
|
+
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], unselectable: [{ type: i0.Input, args: [{ isSignal: true, alias: "unselectable", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], optionTemplate: [{ type: i0.ContentChild, args: ['option', { isSignal: true }] }] } });
|
|
2262
2365
|
|
|
2263
2366
|
class IconService {
|
|
2264
2367
|
_http = inject(HttpClient);
|
|
@@ -3372,5 +3475,5 @@ const provideThalassicUIConfig = (config) => {
|
|
|
3372
3475
|
* Generated bundle index. Do not edit.
|
|
3373
3476
|
*/
|
|
3374
3477
|
|
|
3375
|
-
export { ALERT_CONFIG, Alert, BUTTON_CONFIG, Button, ButtonDirective, CHECKBOX_CONFIG, CHIP_CONFIG, CHIP_CONTROL_CONFIG, CHIP_INPUT_CONFIG, Checkbox, Chip, ChipControl, ChipInput, ContextMenuDirective, DATE_TIME_PICKER_CONFIG, DEFAULT_ALERT_CONFIG, DEFAULT_BUTTON_CONFIG, DEFAULT_CHECKBOX_CONFIG, DEFAULT_CHIP_CONFIG, DEFAULT_CHIP_CONTROL_CONFIG, DEFAULT_CHIP_INPUT_CONFIG, DEFAULT_DATE_TIME_PICKER_CONFIG, DEFAULT_DIALOG_CONFIG, DEFAULT_DIVIDER_CONFIG, DEFAULT_FILE_UPLOADER_CONFIG, DEFAULT_FORM_CONTROL_GROUP_CONFIG, DEFAULT_FORM_ITEM_CONFIG, DEFAULT_ICON_CONFIG, DEFAULT_INPUT_CONFIG, DEFAULT_LOADER_CONFIG, DEFAULT_MENU_CONFIG, DEFAULT_MULTI_SELECT_CONFIG, DEFAULT_PAGINATION_CONFIG, DEFAULT_PASSWORD_CONFIG, DEFAULT_PIN_INPUT_CONFIG, DEFAULT_POPOVER_CONFIG, DEFAULT_RADIO_BUTTON_CONFIG, DEFAULT_SELECT_CONFIG, DEFAULT_SKELETON_CONFIG, DEFAULT_STEPPER_CONFIG, DEFAULT_STEP_CONFIG, DEFAULT_SWITCH_CONFIG, DEFAULT_TABLE_CONFIG, DEFAULT_TABS_CONFIG, DEFAULT_TEXTAREA_CONFIG, DEFAULT_TOGGLE_GROUP_CONFIG, DEFAULT_TOOLTIP_CONFIG, DIALOG_CONFIG, DIVIDER_CONFIG, DateTimePicker, Dialog, DialogService, Divider, FILE_UPLOADER_CONFIG, FORM_CONTROL_GROUP_CONFIG, FORM_ITEM_CONFIG, FileUploader, FormControlAddon, FormControlGroup, FormItem, ICON_CONFIG, INPUT_CONFIG, Icon, Input, InputDirective, LOADER_CONFIG, Loader, MENU_CONFIG, MULTI_SELECT_CONFIG, Menu, MenuItemComponent, MenuTriggerDirective, MultiSelect, PAGINATION_CONFIG, PASSWORD_CONFIG, PIN_INPUT_CONFIG, POPOVER_CONFIG, Pagination, Password, PinInput, Popover, RADIO_BUTTON_CONFIG, RadioButton, SELECT_CONFIG, SKELETON_CONFIG, STEPPER_CONFIG, SWITCH_CONFIG, Select, Skeleton, Step, Stepper, Switch, TABLE_CONFIG, TABS_CONFIG, TEXTAREA_CONFIG, TOGGLE_GROUP_CONFIG, TOOLTIP_CONFIG, Tab, Table, TableColumn, Tabs, Textarea, ToggleGroup, TooltipDirective, provideThalassicUIConfig };
|
|
3478
|
+
export { ALERT_CONFIG, Alert, BUTTON_CONFIG, Button, ButtonDirective, CHECKBOX_CONFIG, CHIP_CONFIG, CHIP_CONTROL_CONFIG, CHIP_GROUP_CONFIG, CHIP_INPUT_CONFIG, Checkbox, Chip, ChipControl, ChipGroup, ChipInput, ContextMenuDirective, DATE_TIME_PICKER_CONFIG, DEFAULT_ALERT_CONFIG, DEFAULT_BUTTON_CONFIG, DEFAULT_CHECKBOX_CONFIG, DEFAULT_CHIP_CONFIG, DEFAULT_CHIP_CONTROL_CONFIG, DEFAULT_CHIP_GROUP_CONFIG, DEFAULT_CHIP_INPUT_CONFIG, DEFAULT_DATE_TIME_PICKER_CONFIG, DEFAULT_DIALOG_CONFIG, DEFAULT_DIVIDER_CONFIG, DEFAULT_FILE_UPLOADER_CONFIG, DEFAULT_FORM_CONTROL_GROUP_CONFIG, DEFAULT_FORM_ITEM_CONFIG, DEFAULT_ICON_CONFIG, DEFAULT_INPUT_CONFIG, DEFAULT_LOADER_CONFIG, DEFAULT_MENU_CONFIG, DEFAULT_MULTI_SELECT_CONFIG, DEFAULT_PAGINATION_CONFIG, DEFAULT_PASSWORD_CONFIG, DEFAULT_PIN_INPUT_CONFIG, DEFAULT_POPOVER_CONFIG, DEFAULT_RADIO_BUTTON_CONFIG, DEFAULT_SELECT_CONFIG, DEFAULT_SKELETON_CONFIG, DEFAULT_STEPPER_CONFIG, DEFAULT_STEP_CONFIG, DEFAULT_SWITCH_CONFIG, DEFAULT_TABLE_CONFIG, DEFAULT_TABS_CONFIG, DEFAULT_TEXTAREA_CONFIG, DEFAULT_TOGGLE_GROUP_CONFIG, DEFAULT_TOOLTIP_CONFIG, DIALOG_CONFIG, DIVIDER_CONFIG, DateTimePicker, Dialog, DialogService, Divider, FILE_UPLOADER_CONFIG, FORM_CONTROL_GROUP_CONFIG, FORM_ITEM_CONFIG, FileUploader, FormControlAddon, FormControlGroup, FormItem, ICON_CONFIG, INPUT_CONFIG, Icon, Input, InputDirective, LOADER_CONFIG, Loader, MENU_CONFIG, MULTI_SELECT_CONFIG, Menu, MenuItemComponent, MenuTriggerDirective, MultiSelect, PAGINATION_CONFIG, PASSWORD_CONFIG, PIN_INPUT_CONFIG, POPOVER_CONFIG, Pagination, Password, PinInput, Popover, RADIO_BUTTON_CONFIG, RadioButton, SELECT_CONFIG, SKELETON_CONFIG, STEPPER_CONFIG, SWITCH_CONFIG, Select, Skeleton, Step, Stepper, Switch, TABLE_CONFIG, TABS_CONFIG, TEXTAREA_CONFIG, TOGGLE_GROUP_CONFIG, TOOLTIP_CONFIG, Tab, Table, TableColumn, Tabs, Textarea, ToggleGroup, TooltipDirective, provideThalassicUIConfig };
|
|
3376
3479
|
//# sourceMappingURL=thalassic-ui.mjs.map
|