pdm-ui-kit 0.1.39 → 0.1.40
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/esm2020/lib/components/select/select.component.mjs +81 -62
- package/esm2020/lib/pdm-ui-kit.module.mjs +5 -4
- package/fesm2015/pdm-ui-kit.mjs +83 -63
- package/fesm2015/pdm-ui-kit.mjs.map +1 -1
- package/fesm2020/pdm-ui-kit.mjs +82 -62
- package/fesm2020/pdm-ui-kit.mjs.map +1 -1
- package/lib/components/select/select.component.d.ts +13 -11
- package/lib/pdm-ui-kit.module.d.ts +2 -1
- package/package.json +3 -2
package/fesm2015/pdm-ui-kit.mjs
CHANGED
|
@@ -2,9 +2,12 @@ import * as i1 from '@angular/common';
|
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { EventEmitter, Component, ChangeDetectionStrategy, Input, Output, HostListener, ViewChild, ViewChildren, NgModule } from '@angular/core';
|
|
5
|
+
import * as i1$2 from '@angular/cdk/overlay';
|
|
6
|
+
import { OverlayModule } from '@angular/cdk/overlay';
|
|
5
7
|
import { icons } from 'lucide';
|
|
6
8
|
import * as i1$1 from '@angular/platform-browser';
|
|
7
9
|
import { format } from 'date-fns';
|
|
10
|
+
import { TemplatePortal } from '@angular/cdk/portal';
|
|
8
11
|
|
|
9
12
|
class PdmAccordionComponent {
|
|
10
13
|
constructor() {
|
|
@@ -3250,9 +3253,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
3250
3253
|
}] } });
|
|
3251
3254
|
|
|
3252
3255
|
class PdmSelectComponent {
|
|
3253
|
-
constructor(elementRef, cdr) {
|
|
3256
|
+
constructor(elementRef, cdr, overlay, viewContainerRef) {
|
|
3254
3257
|
this.elementRef = elementRef;
|
|
3255
3258
|
this.cdr = cdr;
|
|
3259
|
+
this.overlay = overlay;
|
|
3260
|
+
this.viewContainerRef = viewContainerRef;
|
|
3256
3261
|
this.id = '';
|
|
3257
3262
|
this.value = '';
|
|
3258
3263
|
this.options = [];
|
|
@@ -3261,9 +3266,12 @@ class PdmSelectComponent {
|
|
|
3261
3266
|
this.className = '';
|
|
3262
3267
|
this.placeholder = 'Select an option';
|
|
3263
3268
|
this.open = false;
|
|
3264
|
-
this.panelPlacement = 'bottom';
|
|
3265
|
-
this.panelMaxHeightPx = null;
|
|
3266
3269
|
this.valueChange = new EventEmitter();
|
|
3270
|
+
this.overlayRef = null;
|
|
3271
|
+
this.backdropSub = null;
|
|
3272
|
+
}
|
|
3273
|
+
ngOnDestroy() {
|
|
3274
|
+
this.destroyOverlay();
|
|
3267
3275
|
}
|
|
3268
3276
|
get selectedOption() {
|
|
3269
3277
|
return this.options.find((option) => option.value === this.value);
|
|
@@ -3272,22 +3280,15 @@ class PdmSelectComponent {
|
|
|
3272
3280
|
var _a;
|
|
3273
3281
|
return ((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.label) || this.placeholder;
|
|
3274
3282
|
}
|
|
3275
|
-
get panelClasses() {
|
|
3276
|
-
return [
|
|
3277
|
-
'absolute left-0 z-50 w-full overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md',
|
|
3278
|
-
this.panelPlacement === 'top' ? 'bottom-[calc(100%+4px)]' : 'top-[calc(100%+4px)]'
|
|
3279
|
-
];
|
|
3280
|
-
}
|
|
3281
3283
|
toggle() {
|
|
3282
3284
|
if (this.disabled)
|
|
3283
3285
|
return;
|
|
3284
|
-
this.open = !this.open;
|
|
3285
3286
|
if (this.open) {
|
|
3286
|
-
this.
|
|
3287
|
-
|
|
3287
|
+
this.closePanel();
|
|
3288
|
+
}
|
|
3289
|
+
else {
|
|
3290
|
+
this.openPanel();
|
|
3288
3291
|
}
|
|
3289
|
-
this.panelPlacement = 'bottom';
|
|
3290
|
-
this.panelMaxHeightPx = null;
|
|
3291
3292
|
}
|
|
3292
3293
|
onChange(event) {
|
|
3293
3294
|
this.valueChange.emit(event.target.value);
|
|
@@ -3296,52 +3297,80 @@ class PdmSelectComponent {
|
|
|
3296
3297
|
if (option.disabled)
|
|
3297
3298
|
return;
|
|
3298
3299
|
this.valueChange.emit(option.value);
|
|
3299
|
-
this.
|
|
3300
|
-
}
|
|
3301
|
-
onDocumentClick(event) {
|
|
3302
|
-
if (!this.open)
|
|
3303
|
-
return;
|
|
3304
|
-
if (!this.elementRef.nativeElement.contains(event.target)) {
|
|
3305
|
-
this.open = false;
|
|
3306
|
-
}
|
|
3300
|
+
this.closePanel();
|
|
3307
3301
|
}
|
|
3308
3302
|
onEscape() {
|
|
3309
|
-
this.
|
|
3303
|
+
this.closePanel();
|
|
3310
3304
|
}
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
schedulePanelPlacementUpdate() {
|
|
3315
|
-
setTimeout(() => this.updatePanelPlacement());
|
|
3316
|
-
}
|
|
3317
|
-
updatePanelPlacement() {
|
|
3318
|
-
var _a, _b;
|
|
3319
|
-
if (!this.open)
|
|
3305
|
+
openPanel() {
|
|
3306
|
+
var _a;
|
|
3307
|
+
if (this.overlayRef)
|
|
3320
3308
|
return;
|
|
3321
3309
|
const triggerEl = (_a = this.triggerRef) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
3322
|
-
|
|
3323
|
-
if (!triggerEl || !panelEl || typeof window === 'undefined') {
|
|
3310
|
+
if (!triggerEl)
|
|
3324
3311
|
return;
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
const
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3312
|
+
this.open = true;
|
|
3313
|
+
this.cdr.markForCheck();
|
|
3314
|
+
const positionStrategy = this.overlay
|
|
3315
|
+
.position()
|
|
3316
|
+
.flexibleConnectedTo(triggerEl)
|
|
3317
|
+
.withPositions([
|
|
3318
|
+
{
|
|
3319
|
+
originX: 'start',
|
|
3320
|
+
originY: 'bottom',
|
|
3321
|
+
overlayX: 'start',
|
|
3322
|
+
overlayY: 'top',
|
|
3323
|
+
offsetY: 4
|
|
3324
|
+
},
|
|
3325
|
+
{
|
|
3326
|
+
originX: 'start',
|
|
3327
|
+
originY: 'top',
|
|
3328
|
+
overlayX: 'start',
|
|
3329
|
+
overlayY: 'bottom',
|
|
3330
|
+
offsetY: -4
|
|
3331
|
+
}
|
|
3332
|
+
])
|
|
3333
|
+
.withFlexibleDimensions(false)
|
|
3334
|
+
.withPush(true);
|
|
3335
|
+
this.overlayRef = this.overlay.create({
|
|
3336
|
+
positionStrategy,
|
|
3337
|
+
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
|
3338
|
+
width: triggerEl.offsetWidth
|
|
3339
|
+
});
|
|
3340
|
+
const portal = new TemplatePortal(this.panelTemplateRef, this.viewContainerRef);
|
|
3341
|
+
this.overlayRef.attach(portal);
|
|
3342
|
+
this.backdropSub = this.overlayRef.outsidePointerEvents().subscribe((event) => {
|
|
3343
|
+
const target = event.target;
|
|
3344
|
+
if (!triggerEl.contains(target)) {
|
|
3345
|
+
this.closePanel();
|
|
3346
|
+
}
|
|
3347
|
+
});
|
|
3348
|
+
this.cdr.markForCheck();
|
|
3349
|
+
}
|
|
3350
|
+
closePanel() {
|
|
3351
|
+
if (!this.overlayRef)
|
|
3352
|
+
return;
|
|
3353
|
+
this.open = false;
|
|
3354
|
+
this.destroyOverlay();
|
|
3336
3355
|
this.cdr.markForCheck();
|
|
3337
3356
|
}
|
|
3357
|
+
destroyOverlay() {
|
|
3358
|
+
if (this.backdropSub) {
|
|
3359
|
+
this.backdropSub.unsubscribe();
|
|
3360
|
+
this.backdropSub = null;
|
|
3361
|
+
}
|
|
3362
|
+
if (this.overlayRef) {
|
|
3363
|
+
this.overlayRef.dispose();
|
|
3364
|
+
this.overlayRef = null;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3338
3367
|
}
|
|
3339
|
-
PdmSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmSelectComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
3340
|
-
PdmSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: PdmSelectComponent, selector: "pdm-select", inputs: { id: "id", value: "value", options: "options", disabled: "disabled", invalid: "invalid", className: "className", placeholder: "placeholder" }, outputs: { valueChange: "valueChange" }, host: { listeners: { "document:
|
|
3368
|
+
PdmSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmSelectComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1$2.Overlay }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
3369
|
+
PdmSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: PdmSelectComponent, selector: "pdm-select", inputs: { id: "id", value: "value", options: "options", disabled: "disabled", invalid: "invalid", className: "className", placeholder: "placeholder" }, outputs: { valueChange: "valueChange" }, host: { listeners: { "document:keydown.escape": "onEscape()" } }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["triggerEl"], descendants: true }, { propertyName: "panelTemplateRef", first: true, predicate: ["panelTemplate"], descendants: true }], ngImport: i0, template: "<div [ngClass]=\"['relative', className || 'w-full']\">\n <button\n #triggerEl\n type=\"button\"\n [id]=\"id\"\n [disabled]=\"disabled\"\n [attr.aria-invalid]=\"invalid\"\n [attr.aria-expanded]=\"open\"\n [attr.data-state]=\"open ? 'open' : 'closed'\"\n aria-haspopup=\"listbox\"\n (click)=\"toggle()\"\n [ngClass]=\"[\n 'border-input focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 aria-invalid:ring-2 aria-invalid:ring-destructive aria-invalid:border-destructive flex h-9 w-full appearance-none items-center justify-between rounded-md border bg-background px-3 py-2 text-sm shadow-sm outline-none disabled:cursor-not-allowed disabled:opacity-50',\n ]\"\n >\n <span\n [ngClass]=\"[\n 'min-w-0 flex-1 truncate text-left leading-5',\n selectedOption\n ? 'font-medium text-foreground'\n : 'font-normal text-muted-foreground',\n ]\"\n >\n {{ selectedLabel }}\n </span>\n <pdm-icon\n name=\"chevron-down\"\n [size]=\"16\"\n className=\"shrink-0 text-muted-foreground\"\n ></pdm-icon>\n </button>\n\n <select\n class=\"sr-only\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [value]=\"value\"\n (change)=\"onChange($event)\"\n >\n <option\n *ngFor=\"let option of options\"\n [value]=\"option.value\"\n [disabled]=\"option.disabled\"\n >\n {{ option.label }}\n </option>\n </select>\n</div>\n\n<ng-template #panelTemplate>\n <div\n role=\"listbox\"\n [attr.aria-labelledby]=\"id || null\"\n class=\"overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md max-h-96\"\n >\n <button\n *ngFor=\"let option of options\"\n type=\"button\"\n role=\"option\"\n [attr.aria-selected]=\"option.value === value\"\n [disabled]=\"option.disabled\"\n (click)=\"selectOption(option)\"\n [ngClass]=\"[\n 'flex w-full appearance-none items-center justify-between rounded-sm border-0 bg-transparent px-2 py-1.5 text-left text-sm outline-none transition-colors',\n option.disabled\n ? 'cursor-not-allowed opacity-50'\n : 'hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground',\n option.value === value ? 'text-foreground' : '',\n ]\"\n >\n <span class=\"min-w-0 flex-1 truncate leading-5\">{{ option.label }}</span>\n <span\n *ngIf=\"option.value === value\"\n class=\"ml-2 flex shrink-0 items-center justify-end\"\n >\n <pdm-icon\n name=\"check\"\n [size]=\"16\"\n className=\"shrink-0 text-current\"\n ></pdm-icon>\n </span>\n </button>\n </div>\n</ng-template>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: PdmIconComponent, selector: "pdm-icon", inputs: ["name", "library", "assetUrl", "size", "strokeWidth", "className", "ariaLabel", "decorative"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3341
3370
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmSelectComponent, decorators: [{
|
|
3342
3371
|
type: Component,
|
|
3343
|
-
args: [{ selector: 'pdm-select', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [ngClass]=\"['relative', className || 'w-full']\">\n <button\n #triggerEl\n type=\"button\"\n [id]=\"id\"\n [disabled]=\"disabled\"\n [attr.aria-invalid]=\"invalid\"\n [attr.aria-expanded]=\"open\"\n [attr.data-state]=\"open ? 'open' : 'closed'\"\n aria-haspopup=\"listbox\"\n (click)=\"toggle()\"\n [ngClass]=\"[\n 'border-input focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 aria-invalid:ring-2 aria-invalid:ring-destructive aria-invalid:border-destructive flex h-9 w-full appearance-none items-center justify-between rounded-md border bg-background px-3 py-2 text-sm shadow-sm outline-none disabled:cursor-not-allowed disabled:opacity-50',\n ]\"\n >\n <span\n [ngClass]=\"[\n 'min-w-0 flex-1 truncate text-left leading-5',\n selectedOption\n ? 'font-medium text-foreground'\n : 'font-normal text-muted-foreground',\n ]\"\n >\n {{ selectedLabel }}\n </span>\n <pdm-icon\n name=\"chevron-down\"\n [size]=\"16\"\n className=\"shrink-0 text-muted-foreground\"\n ></pdm-icon>\n </button>\n\n <
|
|
3344
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { id: [{
|
|
3372
|
+
args: [{ selector: 'pdm-select', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div [ngClass]=\"['relative', className || 'w-full']\">\n <button\n #triggerEl\n type=\"button\"\n [id]=\"id\"\n [disabled]=\"disabled\"\n [attr.aria-invalid]=\"invalid\"\n [attr.aria-expanded]=\"open\"\n [attr.data-state]=\"open ? 'open' : 'closed'\"\n aria-haspopup=\"listbox\"\n (click)=\"toggle()\"\n [ngClass]=\"[\n 'border-input focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 aria-invalid:ring-2 aria-invalid:ring-destructive aria-invalid:border-destructive flex h-9 w-full appearance-none items-center justify-between rounded-md border bg-background px-3 py-2 text-sm shadow-sm outline-none disabled:cursor-not-allowed disabled:opacity-50',\n ]\"\n >\n <span\n [ngClass]=\"[\n 'min-w-0 flex-1 truncate text-left leading-5',\n selectedOption\n ? 'font-medium text-foreground'\n : 'font-normal text-muted-foreground',\n ]\"\n >\n {{ selectedLabel }}\n </span>\n <pdm-icon\n name=\"chevron-down\"\n [size]=\"16\"\n className=\"shrink-0 text-muted-foreground\"\n ></pdm-icon>\n </button>\n\n <select\n class=\"sr-only\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [value]=\"value\"\n (change)=\"onChange($event)\"\n >\n <option\n *ngFor=\"let option of options\"\n [value]=\"option.value\"\n [disabled]=\"option.disabled\"\n >\n {{ option.label }}\n </option>\n </select>\n</div>\n\n<ng-template #panelTemplate>\n <div\n role=\"listbox\"\n [attr.aria-labelledby]=\"id || null\"\n class=\"overflow-y-auto rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md max-h-96\"\n >\n <button\n *ngFor=\"let option of options\"\n type=\"button\"\n role=\"option\"\n [attr.aria-selected]=\"option.value === value\"\n [disabled]=\"option.disabled\"\n (click)=\"selectOption(option)\"\n [ngClass]=\"[\n 'flex w-full appearance-none items-center justify-between rounded-sm border-0 bg-transparent px-2 py-1.5 text-left text-sm outline-none transition-colors',\n option.disabled\n ? 'cursor-not-allowed opacity-50'\n : 'hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground',\n option.value === value ? 'text-foreground' : '',\n ]\"\n >\n <span class=\"min-w-0 flex-1 truncate leading-5\">{{ option.label }}</span>\n <span\n *ngIf=\"option.value === value\"\n class=\"ml-2 flex shrink-0 items-center justify-end\"\n >\n <pdm-icon\n name=\"check\"\n [size]=\"16\"\n className=\"shrink-0 text-current\"\n ></pdm-icon>\n </span>\n </button>\n </div>\n</ng-template>\n" }]
|
|
3373
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1$2.Overlay }, { type: i0.ViewContainerRef }]; }, propDecorators: { id: [{
|
|
3345
3374
|
type: Input
|
|
3346
3375
|
}], value: [{
|
|
3347
3376
|
type: Input
|
|
@@ -3360,21 +3389,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
3360
3389
|
}], triggerRef: [{
|
|
3361
3390
|
type: ViewChild,
|
|
3362
3391
|
args: ['triggerEl']
|
|
3363
|
-
}],
|
|
3392
|
+
}], panelTemplateRef: [{
|
|
3364
3393
|
type: ViewChild,
|
|
3365
|
-
args: ['
|
|
3366
|
-
}], onDocumentClick: [{
|
|
3367
|
-
type: HostListener,
|
|
3368
|
-
args: ['document:click', ['$event']]
|
|
3394
|
+
args: ['panelTemplate']
|
|
3369
3395
|
}], onEscape: [{
|
|
3370
3396
|
type: HostListener,
|
|
3371
3397
|
args: ['document:keydown.escape']
|
|
3372
|
-
}], onViewportChange: [{
|
|
3373
|
-
type: HostListener,
|
|
3374
|
-
args: ['window:resize']
|
|
3375
|
-
}, {
|
|
3376
|
-
type: HostListener,
|
|
3377
|
-
args: ['window:scroll']
|
|
3378
3398
|
}] } });
|
|
3379
3399
|
|
|
3380
3400
|
class PdmPaginationComponent {
|
|
@@ -4393,7 +4413,7 @@ PdmUiKitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
|
|
|
4393
4413
|
PdmTextareaComponent,
|
|
4394
4414
|
PdmToggleComponent,
|
|
4395
4415
|
PdmToggleGroupComponent,
|
|
4396
|
-
PdmTooltipComponent], imports: [CommonModule], exports: [PdmAccordionComponent,
|
|
4416
|
+
PdmTooltipComponent], imports: [CommonModule, OverlayModule], exports: [PdmAccordionComponent,
|
|
4397
4417
|
PdmAlertComponent,
|
|
4398
4418
|
PdmAlertDialogComponent,
|
|
4399
4419
|
PdmAspectRatioComponent,
|
|
@@ -4450,11 +4470,11 @@ PdmUiKitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
|
|
|
4450
4470
|
PdmToggleComponent,
|
|
4451
4471
|
PdmToggleGroupComponent,
|
|
4452
4472
|
PdmTooltipComponent] });
|
|
4453
|
-
PdmUiKitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmUiKitModule, imports: [CommonModule] });
|
|
4473
|
+
PdmUiKitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmUiKitModule, imports: [CommonModule, OverlayModule] });
|
|
4454
4474
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: PdmUiKitModule, decorators: [{
|
|
4455
4475
|
type: NgModule,
|
|
4456
4476
|
args: [{
|
|
4457
|
-
imports: [CommonModule],
|
|
4477
|
+
imports: [CommonModule, OverlayModule],
|
|
4458
4478
|
declarations: COMPONENTS,
|
|
4459
4479
|
exports: COMPONENTS
|
|
4460
4480
|
}]
|