@softpak/components 20.13.0 → 20.13.2
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/softpak-components-spx-button.mjs +24 -11
- package/fesm2022/softpak-components-spx-button.mjs.map +1 -1
- package/fesm2022/softpak-components-spx-inputs.mjs.map +1 -1
- package/fesm2022/softpak-components-spx-suggestion.mjs +43 -4
- package/fesm2022/softpak-components-spx-suggestion.mjs.map +1 -1
- package/package.json +42 -42
- package/spx-button/index.d.ts +5 -2
- package/spx-suggestion/index.d.ts +5 -0
- package/spx-update/index.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { input, computed, output, viewChild, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
-
import {
|
|
3
|
+
import { ImpactStyle, Haptics } from '@capacitor/haptics';
|
|
4
4
|
import { IsSeverityPipe } from '@softpak/components/spx-pipes';
|
|
5
5
|
import { NgClass } from '@angular/common';
|
|
6
6
|
import { SpxSeverityEnum } from '@softpak/components/spx-helpers';
|
|
@@ -19,10 +19,14 @@ class SpxButtonComponent {
|
|
|
19
19
|
this.spxType = input('submit', ...(ngDevMode ? [{ debugName: "spxType" }] : []));
|
|
20
20
|
this.mappedName = computed(() => this.spxName() ?? undefined, ...(ngDevMode ? [{ debugName: "mappedName" }] : []));
|
|
21
21
|
this.spxName = input(...(ngDevMode ? [undefined, { debugName: "spxName" }] : []));
|
|
22
|
-
this.isPressing = false;
|
|
23
22
|
this.spxClick = output();
|
|
24
23
|
this.buttonRef = viewChild('buttonRef', ...(ngDevMode ? [{ debugName: "buttonRef" }] : []));
|
|
25
24
|
this.SpxSeverity = SpxSeverityEnum;
|
|
25
|
+
// For haptics
|
|
26
|
+
this.isPressing = false;
|
|
27
|
+
this.lastHaptic = 0;
|
|
28
|
+
this.hapticCooldown = 120;
|
|
29
|
+
//
|
|
26
30
|
this.hasShadowDom = (el) => {
|
|
27
31
|
return !!el.shadowRoot && !!el.attachShadow;
|
|
28
32
|
};
|
|
@@ -31,17 +35,13 @@ class SpxButtonComponent {
|
|
|
31
35
|
this.spxClick.emit();
|
|
32
36
|
}
|
|
33
37
|
};
|
|
38
|
+
// For haptics
|
|
34
39
|
this.handlePress = async () => {
|
|
35
40
|
if (this.spxDisabled()) {
|
|
36
41
|
return;
|
|
37
42
|
}
|
|
38
43
|
this.isPressing = true;
|
|
39
|
-
|
|
40
|
-
await Haptics.impact({ style: ImpactStyle.Medium });
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
// silence if haptics is not available
|
|
44
|
-
}
|
|
44
|
+
await this.safeHaptic(ImpactStyle.Medium);
|
|
45
45
|
};
|
|
46
46
|
// global pointerup: check of de release binnen of buiten de knop is
|
|
47
47
|
this.onDocumentPointerUp = async (event) => {
|
|
@@ -57,21 +57,34 @@ class SpxButtonComponent {
|
|
|
57
57
|
try {
|
|
58
58
|
if (inside) {
|
|
59
59
|
// OK haptic
|
|
60
|
-
await
|
|
60
|
+
await this.safeHaptic(ImpactStyle.Heavy);
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
// Cancel haptic
|
|
64
|
-
await
|
|
64
|
+
await this.safeHaptic(ImpactStyle.Light);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
catch {
|
|
68
|
-
//
|
|
68
|
+
// Silence if no haptics
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
spxSetFocus() {
|
|
73
73
|
this.buttonRef()?.nativeElement?.focus();
|
|
74
74
|
}
|
|
75
|
+
async safeHaptic(style) {
|
|
76
|
+
const now = performance.now();
|
|
77
|
+
if (now - this.lastHaptic < this.hapticCooldown) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.lastHaptic = now;
|
|
81
|
+
try {
|
|
82
|
+
await Haptics.impact({ style });
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Silence if no haptics
|
|
86
|
+
}
|
|
87
|
+
}
|
|
75
88
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.3", ngImport: i0, type: SpxButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
76
89
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.2.3", type: SpxButtonComponent, isStandalone: true, selector: "spx-button", inputs: { spxDisabled: { classPropertyName: "spxDisabled", publicName: "spxDisabled", isSignal: true, isRequired: false, transformFunction: null }, spxClass: { classPropertyName: "spxClass", publicName: "spxClass", isSignal: true, isRequired: false, transformFunction: null }, spxClassObject: { classPropertyName: "spxClassObject", publicName: "spxClassObject", isSignal: true, isRequired: false, transformFunction: null }, spxForm: { classPropertyName: "spxForm", publicName: "spxForm", isSignal: true, isRequired: false, transformFunction: null }, spxFullHeight: { classPropertyName: "spxFullHeight", publicName: "spxFullHeight", isSignal: true, isRequired: false, transformFunction: null }, spxFullWidth: { classPropertyName: "spxFullWidth", publicName: "spxFullWidth", isSignal: true, isRequired: false, transformFunction: null }, spxSeverity: { classPropertyName: "spxSeverity", publicName: "spxSeverity", isSignal: true, isRequired: false, transformFunction: null }, spxSize: { classPropertyName: "spxSize", publicName: "spxSize", isSignal: true, isRequired: false, transformFunction: null }, spxTabIndex: { classPropertyName: "spxTabIndex", publicName: "spxTabIndex", isSignal: true, isRequired: false, transformFunction: null }, spxType: { classPropertyName: "spxType", publicName: "spxType", isSignal: true, isRequired: false, transformFunction: null }, spxName: { classPropertyName: "spxName", publicName: "spxName", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { spxClick: "spxClick" }, host: { listeners: { "document:pointerup": "onDocumentPointerUp($event)" }, properties: { "class.block": "spxFullWidth()", "class.h-full": "spxFullHeight()", "class.w-full": "spxFullWidth()" } }, viewQueries: [{ propertyName: "buttonRef", first: true, predicate: ["buttonRef"], descendants: true, isSignal: true }], ngImport: i0, template: "<button\n #buttonRef\n class=\"border border-transparent font-bold px-4 relative rounded text-center text-white focus:outline-none focus:ring-2 focus:ring-offset-2 bg-gradient-to-r\"\n [class.h-full]=\"this.spxFullHeight()\"\n [class.w-full]=\"this.spxFullWidth()\"\n [class.bg-blue-600]=\"!this.spxSeverity() || (this.spxSeverity() | isSeverity: SpxSeverity.info)\"\n [class.focus:ring-blue-600]=\"!this.spxSeverity() || (this.spxSeverity() | isSeverity: SpxSeverity.info)\"\n [class.from-red-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.to-red-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.focus:ring-red-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.from-lime-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.to-lime-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.focus:ring-lime-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.from-amber-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.to-amber-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.focus:ring-amber-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.py-2]=\"!this.spxSize() || this.spxSize() === 'lg'\"\n [class.py-4]=\"!this.spxSize() || this.spxSize() === 'xl'\"\n [class.text-xl]=\"this.spxSize() === 'xl'\"\n [class.text-lg]=\"this.spxSize() === 'lg'\"\n [class.cursor-pointer]=\"!this.spxDisabled()\"\n [class.cursor-not-allowed]=\"this.spxDisabled()\"\n [class.opacity-50]=\"this.spxDisabled()\"\n [class.focus:ring-0]=\"this.spxDisabled()\"\n [ngClass]=\"this.spxClass() ? this.spxClass() : undefined\"\n [attr.disabled]=\"this.spxDisabled() ? this.spxDisabled() : undefined\"\n [attr.form]=\"this.spxForm() ? this.spxForm() : undefined\"\n [attr.name]=\"this.mappedName()\"\n [attr.tabindex]=\"this.spxTabIndex() ? this.spxTabIndex() : undefined\"\n [attr.type]=\"this.spxType() ? this.spxType() : undefined\"\n (pointerdown)=\"this.handlePress()\"\n (click)=\"this.handleClick()\"\n part=\"button\">\n <ng-content></ng-content>\n </button>", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: IsSeverityPipe, name: "isSeverity" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
77
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"softpak-components-spx-button.mjs","sources":["../../../../projects/softpak/components/spx-button/spx-button.component.ts","../../../../projects/softpak/components/spx-button/spx-button.component.html","../../../../projects/softpak/components/spx-button/softpak-components-spx-button.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n HostListener,\n computed,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { Haptics, ImpactStyle } from '@capacitor/haptics';\n\nimport { IsSeverityPipe } from '@softpak/components/spx-pipes';\nimport { NgClass } from '@angular/common';\nimport { SpxSeverityEnum } from '@softpak/components/spx-helpers';\n\n@Component({\n selector: 'spx-button',\n imports: [NgClass, IsSeverityPipe],\n templateUrl: './spx-button.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '[class.block]': 'spxFullWidth()',\n '[class.h-full]': 'spxFullHeight()',\n '[class.w-full]': 'spxFullWidth()',\n },\n standalone: true,\n})\nexport class SpxButtonComponent {\n readonly spxDisabled = input(false);\n readonly spxClass = input<string>();\n readonly spxClassObject = input<object>();\n readonly spxForm = input<string>();\n readonly spxFullHeight = input<boolean>();\n readonly spxFullWidth = input<boolean>();\n readonly spxSeverity = input<SpxSeverityEnum | undefined>(SpxSeverityEnum.info);\n readonly spxSize = input<'lg' | 'xl'>('lg');\n readonly spxTabIndex = input<number>();\n readonly spxType = input<'button' | 'submit'>('submit');\n protected mappedName = computed(() => this.spxName() ?? undefined);\n readonly spxName = input<string>();\n isPressing = false;\n spxClick = output();\n buttonRef = viewChild<ElementRef<HTMLInputElement>>('buttonRef');\n SpxSeverity = SpxSeverityEnum;\n\n hasShadowDom = (el: HTMLElement) => {\n return !!el.shadowRoot && !!(el as any).attachShadow;\n };\n handleClick = () => {\n if (!this.spxDisabled()) {\n this.spxClick.emit();\n }\n };\n\n handlePress = async () => {\n if (this.spxDisabled()) {\n return;\n }\n this.isPressing = true;\n try {\n await Haptics.impact({ style: ImpactStyle.Medium });\n } catch {\n // silence if haptics is not available\n }\n };\n\n // global pointerup: check of de release binnen of buiten de knop is\n @HostListener('document:pointerup', ['$event'])\n onDocumentPointerUp = async (event: PointerEvent) => {\n if (!this.isPressing || this.spxDisabled()) {\n return;\n }\n this.isPressing = false;\n\n const btn = this.buttonRef()?.nativeElement;\n if (!btn) {\n return;\n }\n\n const inside = btn.contains(event.target as Node);\n\n try {\n if (inside) {\n // OK haptic\n await Haptics.impact({ style: ImpactStyle.Heavy });\n } else {\n // Cancel haptic\n await Haptics.impact({ style: ImpactStyle.Light });\n }\n } catch {\n // ignore\n }\n };\n\n spxSetFocus(): void {\n this.buttonRef()?.nativeElement?.focus();\n }\n}\n","<button\n #buttonRef\n class=\"border border-transparent font-bold px-4 relative rounded text-center text-white focus:outline-none focus:ring-2 focus:ring-offset-2 bg-gradient-to-r\"\n [class.h-full]=\"this.spxFullHeight()\"\n [class.w-full]=\"this.spxFullWidth()\"\n [class.bg-blue-600]=\"!this.spxSeverity() || (this.spxSeverity() | isSeverity: SpxSeverity.info)\"\n [class.focus:ring-blue-600]=\"!this.spxSeverity() || (this.spxSeverity() | isSeverity: SpxSeverity.info)\"\n [class.from-red-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.to-red-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.focus:ring-red-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.from-lime-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.to-lime-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.focus:ring-lime-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.from-amber-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.to-amber-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.focus:ring-amber-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.py-2]=\"!this.spxSize() || this.spxSize() === 'lg'\"\n [class.py-4]=\"!this.spxSize() || this.spxSize() === 'xl'\"\n [class.text-xl]=\"this.spxSize() === 'xl'\"\n [class.text-lg]=\"this.spxSize() === 'lg'\"\n [class.cursor-pointer]=\"!this.spxDisabled()\"\n [class.cursor-not-allowed]=\"this.spxDisabled()\"\n [class.opacity-50]=\"this.spxDisabled()\"\n [class.focus:ring-0]=\"this.spxDisabled()\"\n [ngClass]=\"this.spxClass() ? this.spxClass() : undefined\"\n [attr.disabled]=\"this.spxDisabled() ? this.spxDisabled() : undefined\"\n [attr.form]=\"this.spxForm() ? this.spxForm() : undefined\"\n [attr.name]=\"this.mappedName()\"\n [attr.tabindex]=\"this.spxTabIndex() ? this.spxTabIndex() : undefined\"\n [attr.type]=\"this.spxType() ? this.spxType() : undefined\"\n (pointerdown)=\"this.handlePress()\"\n (click)=\"this.handleClick()\"\n part=\"button\">\n <ng-content></ng-content>\n </button>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MA4Ba,kBAAkB,CAAA;AAZ/B,IAAA,WAAA,GAAA;AAaW,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAC,KAAK,uDAAC;QAC1B,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,UAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;QAC1B,IAAA,CAAA,cAAc,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAA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,QAAA,EAAA,EAAA,EAAA,QAAA,EC5B/B,4qEAkCW,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EDhBC,OAAO,+EAAE,cAAc,EAAA,IAAA,EAAA,YAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FAUtB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAZ9B,SAAS;+BACE,YAAY,EAAA,OAAA,EACb,CAAC,OAAO,EAAE,cAAc,CAAC,EAAA,eAAA,EAEjB,uBAAuB,CAAC,MAAM,EAAA,IAAA,EACzC;AACJ,wBAAA,eAAe,EAAE,gBAAgB;AACjC,wBAAA,gBAAgB,EAAE,iBAAiB;AACnC,wBAAA,gBAAgB,EAAE,gBAAgB;AACnC,qBAAA,EAAA,UAAA,EACW,IAAI,EAAA,QAAA,EAAA,4qEAAA,EAAA;8BA2ChB,mBAAmB,EAAA,CAAA;sBADlB,YAAY;uBAAC,oBAAoB,EAAE,CAAC,QAAQ,CAAC;;;AEpEhD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"softpak-components-spx-button.mjs","sources":["../../../../projects/softpak/components/spx-button/spx-button.component.ts","../../../../projects/softpak/components/spx-button/spx-button.component.html","../../../../projects/softpak/components/spx-button/softpak-components-spx-button.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n HostListener,\n computed,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { Haptics, ImpactStyle } from '@capacitor/haptics';\n\nimport { IsSeverityPipe } from '@softpak/components/spx-pipes';\nimport { NgClass } from '@angular/common';\nimport { SpxSeverityEnum } from '@softpak/components/spx-helpers';\n\n@Component({\n selector: 'spx-button',\n imports: [NgClass, IsSeverityPipe],\n templateUrl: './spx-button.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n '[class.block]': 'spxFullWidth()',\n '[class.h-full]': 'spxFullHeight()',\n '[class.w-full]': 'spxFullWidth()',\n },\n standalone: true,\n})\nexport class SpxButtonComponent {\n readonly spxDisabled = input(false);\n readonly spxClass = input<string>();\n readonly spxClassObject = input<object>();\n readonly spxForm = input<string>();\n readonly spxFullHeight = input<boolean>();\n readonly spxFullWidth = input<boolean>();\n readonly spxSeverity = input<SpxSeverityEnum | undefined>(SpxSeverityEnum.info);\n readonly spxSize = input<'lg' | 'xl'>('lg');\n readonly spxTabIndex = input<number>();\n readonly spxType = input<'button' | 'submit'>('submit');\n protected mappedName = computed(() => this.spxName() ?? undefined);\n readonly spxName = input<string>();\n spxClick = output();\n buttonRef = viewChild<ElementRef<HTMLInputElement>>('buttonRef');\n SpxSeverity = SpxSeverityEnum;\n\n // For haptics\n private isPressing = false;\n private lastHaptic = 0;\n private hapticCooldown = 120;\n //\n\n hasShadowDom = (el: HTMLElement) => {\n return !!el.shadowRoot && !!(el as any).attachShadow;\n };\n handleClick = () => {\n if (!this.spxDisabled()) {\n this.spxClick.emit();\n }\n };\n\n spxSetFocus(): void {\n this.buttonRef()?.nativeElement?.focus();\n }\n\n // For haptics\n handlePress = async () => {\n if (this.spxDisabled()) {\n return;\n }\n this.isPressing = true;\n await this.safeHaptic(ImpactStyle.Medium);\n };\n\n // global pointerup: check of de release binnen of buiten de knop is\n @HostListener('document:pointerup', ['$event'])\n onDocumentPointerUp = async (event: PointerEvent) => {\n if (!this.isPressing || this.spxDisabled()) {\n return;\n }\n this.isPressing = false;\n\n const btn = this.buttonRef()?.nativeElement;\n if (!btn) {\n return;\n }\n\n const inside = btn.contains(event.target as Node);\n\n try {\n if (inside) {\n // OK haptic\n await this.safeHaptic(ImpactStyle.Heavy);\n } else {\n // Cancel haptic\n await this.safeHaptic(ImpactStyle.Light);\n }\n } catch {\n // Silence if no haptics\n }\n };\n\n private async safeHaptic(style: ImpactStyle) {\n const now = performance.now();\n if (now - this.lastHaptic < this.hapticCooldown) {\n return;\n }\n this.lastHaptic = now;\n\n try {\n await Haptics.impact({ style });\n } catch {\n // Silence if no haptics\n }\n }\n // End haptics\n}\n","<button\n #buttonRef\n class=\"border border-transparent font-bold px-4 relative rounded text-center text-white focus:outline-none focus:ring-2 focus:ring-offset-2 bg-gradient-to-r\"\n [class.h-full]=\"this.spxFullHeight()\"\n [class.w-full]=\"this.spxFullWidth()\"\n [class.bg-blue-600]=\"!this.spxSeverity() || (this.spxSeverity() | isSeverity: SpxSeverity.info)\"\n [class.focus:ring-blue-600]=\"!this.spxSeverity() || (this.spxSeverity() | isSeverity: SpxSeverity.info)\"\n [class.from-red-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.to-red-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.focus:ring-red-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.error\"\n [class.from-lime-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.to-lime-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.focus:ring-lime-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.success\"\n [class.from-amber-400]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.to-amber-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.focus:ring-amber-600]=\"this.spxSeverity() | isSeverity: SpxSeverity.warning\"\n [class.py-2]=\"!this.spxSize() || this.spxSize() === 'lg'\"\n [class.py-4]=\"!this.spxSize() || this.spxSize() === 'xl'\"\n [class.text-xl]=\"this.spxSize() === 'xl'\"\n [class.text-lg]=\"this.spxSize() === 'lg'\"\n [class.cursor-pointer]=\"!this.spxDisabled()\"\n [class.cursor-not-allowed]=\"this.spxDisabled()\"\n [class.opacity-50]=\"this.spxDisabled()\"\n [class.focus:ring-0]=\"this.spxDisabled()\"\n [ngClass]=\"this.spxClass() ? this.spxClass() : undefined\"\n [attr.disabled]=\"this.spxDisabled() ? this.spxDisabled() : undefined\"\n [attr.form]=\"this.spxForm() ? this.spxForm() : undefined\"\n [attr.name]=\"this.mappedName()\"\n [attr.tabindex]=\"this.spxTabIndex() ? this.spxTabIndex() : undefined\"\n [attr.type]=\"this.spxType() ? this.spxType() : undefined\"\n (pointerdown)=\"this.handlePress()\"\n (click)=\"this.handleClick()\"\n part=\"button\">\n <ng-content></ng-content>\n </button>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MA4Ba,kBAAkB,CAAA;AAZ/B,IAAA,WAAA,GAAA;AAaW,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAC,KAAK,uDAAC;QAC1B,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,UAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;QAC1B,IAAA,CAAA,cAAc,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,gBAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;QAChC,IAAA,CAAA,OAAO,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;QACzB,IAAA,CAAA,aAAa,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,eAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAW;QAChC,IAAA,CAAA,YAAY,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,cAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAW;AAC/B,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAA8B,eAAe,CAAC,IAAI,uDAAC;AACtE,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAc,IAAI,mDAAC;QAClC,IAAA,CAAA,WAAW,GAAG,KAAK,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