@softpak/components 21.1.0-beta.1 → 21.1.0-beta.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.
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { input, computed, output, viewChild, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import { ImpactStyle } from '@capacitor/haptics';
4
3
  import { IsSeverityPipe } from '@softpak/components/spx-pipes';
5
4
  import { NgClass } from '@angular/common';
5
+ import { SpxHaptics } from '@softpak/components/spx-haptics';
6
6
  import { SpxSeverityEnum } from '@softpak/components/spx-helpers';
7
7
 
8
8
  class SpxButtonComponent {
@@ -22,11 +22,7 @@ class SpxButtonComponent {
22
22
  this.spxClick = output();
23
23
  this.buttonRef = viewChild('buttonRef', ...(ngDevMode ? [{ debugName: "buttonRef" }] : []));
24
24
  this.SpxSeverity = SpxSeverityEnum;
25
- // For haptics
26
- this.isPressing = false;
27
- this.lastHaptic = 0;
28
- this.hapticCooldown = 120;
29
- //
25
+ this.spxHaptics = new SpxHaptics();
30
26
  this.hasShadowDom = (el) => {
31
27
  return !!el.shadowRoot && !!el.attachShadow;
32
28
  };
@@ -40,51 +36,23 @@ class SpxButtonComponent {
40
36
  if (this.spxDisabled()) {
41
37
  return;
42
38
  }
43
- this.isPressing = true;
44
- await this.safeHaptic(ImpactStyle.Medium);
39
+ this.spxHaptics.pressDown();
45
40
  };
46
- // global pointerup: check of de release binnen of buiten de knop is
47
41
  this.onDocumentPointerUp = async (event) => {
48
- if (!this.isPressing || this.spxDisabled()) {
42
+ if (this.spxDisabled()) {
49
43
  return;
50
44
  }
51
- this.isPressing = false;
52
45
  const btn = this.buttonRef()?.nativeElement;
53
46
  if (!btn) {
54
47
  return;
55
48
  }
56
- const inside = btn.contains(event.target);
57
- try {
58
- if (inside) {
59
- // OK haptic
60
- await this.safeHaptic(ImpactStyle.Heavy);
61
- }
62
- else {
63
- // Cancel haptic
64
- await this.safeHaptic(ImpactStyle.Light);
65
- }
66
- }
67
- catch {
68
- // Silence if no haptics
69
- }
49
+ const wasInsideElement = btn.contains(event.target);
50
+ this.spxHaptics.pointerUp(wasInsideElement);
70
51
  };
71
52
  }
72
53
  spxSetFocus() {
73
54
  this.buttonRef()?.nativeElement?.focus();
74
55
  }
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
- }
88
56
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SpxButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
89
57
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.0.8", 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 }); }
90
58
  }
@@ -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 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,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,aAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAU;AAC7B,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AAA,EACW,IAAI,EAAA,QAAA,EAAA,4qEAAA,EAAA;osCAgBoC,WAAW,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,mBAAA,EAAA,CAAA;sBAgC9D,YAAY;uBAAC,oBAAoB,EAAE,CAAC,QAAQ,CAAC;;;AE1EhD;;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';\nimport { SpxStorage, SpxStorageKeyEnum } from '@softpak/components/spx-storage';\n\nimport { IsSeverityPipe } from '@softpak/components/spx-pipes';\nimport { NgClass } from '@angular/common';\nimport { SpxHaptics } from '@softpak/components/spx-haptics';\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 private spxHaptics: SpxHaptics = new SpxHaptics();\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.spxHaptics.pressDown();\n };\n\n @HostListener('document:pointerup', ['$event'])\n onDocumentPointerUp = async (event: PointerEvent) => {\n if (this.spxDisabled()) {\n return;\n }\n\n const btn = this.buttonRef()?.nativeElement;\n if (!btn) {\n return;\n }\n\n const wasInsideElement = btn.contains(event.target as Node);\n this.spxHaptics.pointerUp(wasInsideElement);\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":";;;;;;;MA8Ba,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,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ACW,IAAI,EAAA,QAAA,EAAA,4qEAAA,EAAA;osCAgBoC,WAAW,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,mBAAA,EAAA,CAAA;sBAyB9D,YAAY;uBAAC,oBAAoB,EAAE,CAAC,QAAQ,CAAC;;;AErEhD;;AAEG;;;;"}
@@ -0,0 +1,54 @@
1
+ import { ImpactStyle, Haptics } from '@capacitor/haptics';
2
+ import { SpxStorage, SpxStorageKeyEnum } from '@softpak/components/spx-storage';
3
+
4
+ class SpxHaptics {
5
+ static { this.lastHaptic = 0; }
6
+ static { this.hapticCooldown = 120; }
7
+ constructor() {
8
+ this.touchAreaIsBeingPressed = false;
9
+ }
10
+ async pressDown() {
11
+ this.touchAreaIsBeingPressed = true;
12
+ await this.safeHaptic(ImpactStyle.Medium);
13
+ }
14
+ async pointerUp(wasInsideElement) {
15
+ if (!this.touchAreaIsBeingPressed) {
16
+ return;
17
+ }
18
+ try {
19
+ if (wasInsideElement) {
20
+ // OK haptic
21
+ await this.safeHaptic(ImpactStyle.Heavy);
22
+ }
23
+ else {
24
+ // Cancel haptic
25
+ await this.safeHaptic(ImpactStyle.Light);
26
+ }
27
+ }
28
+ catch {
29
+ // Silence if no haptics
30
+ }
31
+ }
32
+ async safeHaptic(style) {
33
+ if (!SpxStorage.getSetting(SpxStorageKeyEnum.noHaptics)) {
34
+ const now = performance.now();
35
+ if (now - SpxHaptics.lastHaptic < SpxHaptics.hapticCooldown) {
36
+ return;
37
+ }
38
+ SpxHaptics.lastHaptic = now;
39
+ try {
40
+ await Haptics.impact({ style });
41
+ }
42
+ catch {
43
+ // Silence if no haptics
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Generated bundle index. Do not edit.
51
+ */
52
+
53
+ export { SpxHaptics };
54
+ //# sourceMappingURL=softpak-components-spx-haptics.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"softpak-components-spx-haptics.mjs","sources":["../../../../projects/softpak/components/spx-haptics/src/spx-haptics.class.ts","../../../../projects/softpak/components/spx-haptics/softpak-components-spx-haptics.ts"],"sourcesContent":["import { Haptics, ImpactStyle } from \"@capacitor/haptics\";\nimport { SpxStorage, SpxStorageKeyEnum } from \"@softpak/components/spx-storage\";\n\nexport class SpxHaptics {\n private static lastHaptic = 0;\n private static hapticCooldown = 120;\n private touchAreaIsBeingPressed = false;\n\n constructor() {\n\n }\n\n public async pressDown() {\n this.touchAreaIsBeingPressed = true;\n await this.safeHaptic(ImpactStyle.Medium);\n }\n\n public async pointerUp(wasInsideElement: boolean) {\n if (!this.touchAreaIsBeingPressed) {\n return;\n }\n \n try {\n if (wasInsideElement) {\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 public async safeHaptic(style: ImpactStyle) {\n if (!SpxStorage.getSetting(SpxStorageKeyEnum.noHaptics)) {\n const now = performance.now();\n if (now - SpxHaptics.lastHaptic < SpxHaptics.hapticCooldown) {\n return;\n }\n SpxHaptics.lastHaptic = now;\n\n try {\n await Haptics.impact({ style });\n } catch {\n // Silence if no haptics\n }\n }\n }\n}\n\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAGa,UAAU,CAAA;aACJ,IAAA,CAAA,UAAU,GAAG,CAAH,CAAK;aACf,IAAA,CAAA,cAAc,GAAG,GAAH,CAAO;AAGpC,IAAA,WAAA,GAAA;QAFQ,IAAA,CAAA,uBAAuB,GAAG,KAAK;IAIvC;AAEO,IAAA,MAAM,SAAS,GAAA;AAClB,QAAA,IAAI,CAAC,uBAAuB,GAAG,IAAI;QACnC,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC;IAC7C;IAEO,MAAM,SAAS,CAAC,gBAAyB,EAAA;AAC5C,QAAA,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE;YAC/B;QACJ;AAEA,QAAA,IAAI;YACA,IAAI,gBAAgB,EAAE;;gBAElB,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC;YAC5C;iBAAO;;gBAEH,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC;YAC5C;QACJ;AAAE,QAAA,MAAM;;QAER;IACJ;IAEO,MAAM,UAAU,CAAC,KAAkB,EAAA;QACtC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE;AACrD,YAAA,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE;YAC7B,IAAI,GAAG,GAAG,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC,cAAc,EAAE;gBACzD;YACJ;AACA,YAAA,UAAU,CAAC,UAAU,GAAG,GAAG;AAE3B,YAAA,IAAI;gBACA,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;YACnC;AAAE,YAAA,MAAM;;YAER;QACJ;IACJ;;;ACjDJ;;AAEG;;;;"}
@@ -16,6 +16,7 @@ var SpxStorageKeyEnum;
16
16
  SpxStorageKeyEnum["release"] = "release";
17
17
  SpxStorageKeyEnum["patch"] = "patch";
18
18
  SpxStorageKeyEnum["username"] = "username";
19
+ SpxStorageKeyEnum["noHaptics"] = "noHaptics";
19
20
  })(SpxStorageKeyEnum || (SpxStorageKeyEnum = {}));
20
21
  ;
21
22
 
@@ -1 +1 @@
1
- {"version":3,"file":"softpak-components-spx-storage.mjs","sources":["../../../../projects/softpak/components/spx-storage/src/spx-storage-key.enum.ts","../../../../projects/softpak/components/spx-storage/src/spx-storage.class.ts","../../../../projects/softpak/components/spx-storage/softpak-components-spx-storage.ts"],"sourcesContent":["export enum SpxStorageKeyEnum {\n afterSignIn = 'afterSignIn',\n brand = 'brand',\n binaryVersionGroup = 'binaryVersionGroup',\n bundleVersion = 'bundleVersion',\n lastBinaryVersionGroup = 'lastBinaryVersionGroup',\n channelType = 'channelType',\n channelSettings = 'companySettings',\n liveUpdate = 'liveUpdate',\n platform = 'platform',\n platformVersion = 'platformVersion',\n token = 'token',\n updateInProgress = 'updateInProgress',\n randomDeviceId = 'randomDeviceId',\n release = 'release',\n patch = 'patch',\n username = 'username',\n};\n","import { SpxStorageKeyEnum } from './spx-storage-key.enum';\n\nexport class SpxStorage {\n private static get channelId() {\n return `${this.getSetting(SpxStorageKeyEnum.brand)?.toUpperCase()}_${this.getSetting(SpxStorageKeyEnum.channelType)?.toUpperCase()}`;\n }\n\n public static clearSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): void {\n localStorage.removeItem(key as string);\n }\n\n public static getSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): string | null {\n return localStorage.getItem(key as string);\n }\n\n public static setSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum, settingValue: string): void {\n localStorage.setItem(key as string, settingValue);\n }\n\n public static getChannelSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): string | undefined {\n let storageObj;\n const storageObjStr = localStorage.getItem(SpxStorageKeyEnum.channelSettings);\n\n if (storageObjStr) {\n storageObj = JSON.parse(storageObjStr);\n if (!storageObj[this.channelId]) {\n return undefined;\n }\n return storageObj[this.channelId][key];\n } else {\n return undefined;\n }\n }\n\n public static setChannelSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum, settingValue: any): void {\n const companySettings = this.getSetting(SpxStorageKeyEnum.channelSettings);\n let storageObj;\n\n if (companySettings) {\n storageObj = JSON.parse(companySettings);\n } else {\n storageObj = {};\n }\n\n if (!storageObj[this.channelId]) {\n storageObj[this.channelId] = {};\n }\n\n storageObj[this.channelId][key] = settingValue;\n this.setSetting(SpxStorageKeyEnum.channelSettings, JSON.stringify(storageObj));\n }\n}\n\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IAAY;AAAZ,CAAA,UAAY,iBAAi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CAAC;IAClF;AACH;;ACnDD;;AAEG;;;;"}
1
+ {"version":3,"file":"softpak-components-spx-storage.mjs","sources":["../../../../projects/softpak/components/spx-storage/src/spx-storage-key.enum.ts","../../../../projects/softpak/components/spx-storage/src/spx-storage.class.ts","../../../../projects/softpak/components/spx-storage/softpak-components-spx-storage.ts"],"sourcesContent":["export enum SpxStorageKeyEnum {\n afterSignIn = 'afterSignIn',\n brand = 'brand',\n binaryVersionGroup = 'binaryVersionGroup',\n bundleVersion = 'bundleVersion',\n lastBinaryVersionGroup = 'lastBinaryVersionGroup',\n channelType = 'channelType',\n channelSettings = 'companySettings',\n liveUpdate = 'liveUpdate',\n platform = 'platform',\n platformVersion = 'platformVersion',\n token = 'token',\n updateInProgress = 'updateInProgress',\n randomDeviceId = 'randomDeviceId',\n release = 'release',\n patch = 'patch',\n username = 'username',\n noHaptics = 'noHaptics',\n};\n","import { SpxStorageKeyEnum } from './spx-storage-key.enum';\n\nexport class SpxStorage {\n private static get channelId() {\n return `${this.getSetting(SpxStorageKeyEnum.brand)?.toUpperCase()}_${this.getSetting(SpxStorageKeyEnum.channelType)?.toUpperCase()}`;\n }\n\n public static clearSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): void {\n localStorage.removeItem(key as string);\n }\n\n public static getSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): string | null {\n return localStorage.getItem(key as string);\n }\n\n public static setSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum, settingValue: string): void {\n localStorage.setItem(key as string, settingValue);\n }\n\n public static getChannelSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum): string | undefined {\n let storageObj;\n const storageObjStr = localStorage.getItem(SpxStorageKeyEnum.channelSettings);\n\n if (storageObjStr) {\n storageObj = JSON.parse(storageObjStr);\n if (!storageObj[this.channelId]) {\n return undefined;\n }\n return storageObj[this.channelId][key];\n } else {\n return undefined;\n }\n }\n\n public static setChannelSetting<KeyEnum>(key: KeyEnum | SpxStorageKeyEnum, settingValue: any): void {\n const companySettings = this.getSetting(SpxStorageKeyEnum.channelSettings);\n let storageObj;\n\n if (companySettings) {\n storageObj = JSON.parse(companySettings);\n } else {\n storageObj = {};\n }\n\n if (!storageObj[this.channelId]) {\n storageObj[this.channelId] = {};\n }\n\n storageObj[this.channelId][key] = settingValue;\n this.setSetting(SpxStorageKeyEnum.channelSettings, JSON.stringify(storageObj));\n }\n}\n\n\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IAAY;AAAZ,CAAA,UAAY,iBAAiB,EAAA;AACzB,IAAA,iBAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,iBAAA,CAAA,oBAAA,CAAA,GAAA,oBAAyC;AACzC,IAAA,iBAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,iBAAA,CAAA,wBAAA,CAAA,GAAA,wBAAiD;AACjD,IAAA,iBAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,iBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC;AACnC,IAAA,iBAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,iBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACrB,IAAA,iBAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC;AACnC,IAAA,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,iBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,iBAAA,CAAA,gBAAA,CAAA,GAAA,gBAAiC;AACjC,IAAA,iBAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,iBAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;AACrB,IAAA,iBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;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AE;AACjB,YAAA,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;QAC5C;aAAO;YACH,UAAU,GAAG,EAAE;QACnB;QAEA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;AAC7B,YAAA,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;QACnC;QAEA,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,YAAY;AAC9C,QAAA,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAClF;AACH;;ACnDD;;AAEG;;;;"}
@@ -1,5 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { input, viewChild, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { SpxHaptics } from '@softpak/components/spx-haptics';
3
4
 
4
5
  class SpxSuggestionComponent {
5
6
  constructor() {
@@ -7,40 +8,25 @@ class SpxSuggestionComponent {
7
8
  this.spxFocused = input(...(ngDevMode ? [undefined, { debugName: "spxFocused" }] : []));
8
9
  this.spxSelected = input(...(ngDevMode ? [undefined, { debugName: "spxSelected" }] : []));
9
10
  this.spxTabbable = input(...(ngDevMode ? [undefined, { debugName: "spxTabbable" }] : []));
10
- this.isPressing = false;
11
11
  this.suggestionRef = viewChild('suggestionRef', ...(ngDevMode ? [{ debugName: "suggestionRef" }] : []));
12
+ this.spxHaptics = new SpxHaptics();
13
+ // For haptics
12
14
  this.handlePress = async () => {
13
- this.isPressing = true;
14
- try {
15
- // await Haptics.impact({ style: ImpactStyle.Light });
16
- }
17
- catch {
18
- // silence if haptics is not available
15
+ if (this.spxDisabled()) {
16
+ return;
19
17
  }
18
+ this.spxHaptics.pressDown();
20
19
  };
21
20
  this.onDocumentPointerUp = async (event) => {
22
- if (!this.isPressing) {
21
+ if (this.spxDisabled()) {
23
22
  return;
24
23
  }
25
- this.isPressing = false;
26
24
  const btn = this.suggestionRef()?.nativeElement;
27
25
  if (!btn) {
28
26
  return;
29
27
  }
30
- const inside = btn.contains(event.target);
31
- try {
32
- if (inside) {
33
- // OK haptic
34
- // await Haptics.impact({ style: ImpactStyle.Medium });
35
- }
36
- else {
37
- // Cancel haptic
38
- // await Haptics.impact({ style: ImpactStyle.Light });
39
- }
40
- }
41
- catch {
42
- // ignore
43
- }
28
+ const wasInsideElement = btn.contains(event.target);
29
+ this.spxHaptics.pointerUp(wasInsideElement);
44
30
  };
45
31
  }
46
32
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SpxSuggestionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
@@ -1 +1 @@
1
- {"version":3,"file":"softpak-components-spx-suggestion.mjs","sources":["../../../../projects/softpak/components/spx-suggestion/spx-suggestion.component.ts","../../../../projects/softpak/components/spx-suggestion/spx-suggestion.component.html","../../../../projects/softpak/components/spx-suggestion/softpak-components-spx-suggestion.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ElementRef, HostListener, input, viewChild } from '@angular/core';\nimport { Haptics, ImpactStyle } from '@capacitor/haptics';\n\n@Component({\n selector: 'spx-suggestion',\n standalone: true,\n templateUrl: './spx-suggestion.component.html',\n styleUrl: './spx-suggestion.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SpxSuggestionComponent {\n spxDisabled = input<boolean>();\n spxFocused = input<boolean>();\n spxSelected = input<boolean>();\n spxTabbable = input<boolean>();\n private isPressing = false;\n suggestionRef = viewChild<ElementRef<HTMLButtonElement>>('suggestionRef');\n\n handlePress = async () => {\n this.isPressing = true;\n try {\n // await Haptics.impact({ style: ImpactStyle.Light });\n } catch {\n // silence if haptics is not available\n }\n };\n\n @HostListener('document:pointerup', ['$event'])\n onDocumentPointerUp = async (event: PointerEvent) => {\n if (!this.isPressing) {\n return;\n }\n this.isPressing = false;\n\n const btn = this.suggestionRef()?.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.Medium });\n } else {\n // Cancel haptic\n // await Haptics.impact({ style: ImpactStyle.Light });\n }\n } catch {\n // ignore\n }\n };\n}\n","<button\n #suggestionRef\n type=\"button\"\n class=\"spx-suggestion block rounded text-gray-900 text-sm p-3 w-full text-left truncate outline-none\"\n [class.bg-sky-100]=\"!this.spxSelected() && !this.spxDisabled()\"\n [class.focus:ring-sky-300]=\"!this.spxSelected() && !this.spxDisabled()\"\n [class.hover:bg-sky-300]=\"!this.spxSelected() && !this.spxDisabled()\"\n [class.active:bg-sky-300]=\"!this.spxSelected() && !this.spxDisabled()\"\n [class.bg-gray-200]=\"this.spxDisabled() && !this.spxSelected()\"\n [class.bg-gray-400]=\"this.spxDisabled() && this.spxSelected()\"\n [class.cursor-not-allowed]=\"this.spxDisabled()\"\n [class.opacity-60]=\"this.spxDisabled()\"\n [class.bg-gradient-to-r]=\"this.spxSelected() && !this.spxDisabled()\"\n [class.from-teal-400]=\"this.spxSelected() && !this.spxDisabled()\"\n [class.to-teal-600]=\"this.spxSelected() && !this.spxDisabled()\"\n [class.font-bold]=\"this.spxSelected()\"\n [attr.tabindex]=\"this.spxTabbable() && !this.spxDisabled() ? 0 : -1\"\n [class.ring-2]=\"this.spxFocused() && this.spxTabbable() && !this.spxDisabled()\"\n [class.ring-offset-2]=\"this.spxFocused() && this.spxTabbable() && !this.spxDisabled()\"\n [class.ring-blue-500]=\"this.spxFocused() && this.spxTabbable() && !this.spxDisabled()\"\n (pointerdown)=\"this.handlePress()\">\n <div class=\"text-ellipsis overflow-hidden whitespace-nowrap\"><ng-content></ng-content></div>\n </button>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAUa,sBAAsB,CAAA;AAPnC,IAAA,WAAA,GAAA;QAQE,IAAA,CAAA,WAAW,GAAG,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AAA;8GA3CY,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAtB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,sBAAsB,y0BCVnC,s8CAsBW,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FDZE,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAPlC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,gBAAgB,EAAA,UAAA,EACd,IAAI,EAAA,eAAA,EAGC,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,s8CAAA,EAAA;ieAQU,eAAe,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,mBAAA,EAAA,CAAA;sBAWvE,YAAY;uBAAC,oBAAoB,EAAE,CAAC,QAAQ,CAAC;;;AE3BhD;;AAEG;;;;"}
1
+ {"version":3,"file":"softpak-components-spx-suggestion.mjs","sources":["../../../../projects/softpak/components/spx-suggestion/spx-suggestion.component.ts","../../../../projects/softpak/components/spx-suggestion/spx-suggestion.component.html","../../../../projects/softpak/components/spx-suggestion/softpak-components-spx-suggestion.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ElementRef, HostListener, input, viewChild } from '@angular/core';\n\nimport { SpxHaptics } from '@softpak/components/spx-haptics';\n\n@Component({\n selector: 'spx-suggestion',\n standalone: true,\n templateUrl: './spx-suggestion.component.html',\n styleUrl: './spx-suggestion.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SpxSuggestionComponent {\n spxDisabled = input<boolean>();\n spxFocused = input<boolean>();\n spxSelected = input<boolean>();\n spxTabbable = input<boolean>();\n suggestionRef = viewChild<ElementRef<HTMLButtonElement>>('suggestionRef');\n private spxHaptics: SpxHaptics = new SpxHaptics();\n\n // For haptics\n handlePress = async () => {\n if (this.spxDisabled()) {\n return;\n }\n this.spxHaptics.pressDown();\n };\n\n @HostListener('document:pointerup', ['$event'])\n onDocumentPointerUp = async (event: PointerEvent) => {\n if (this.spxDisabled()) {\n return;\n }\n\n const btn = this.suggestionRef()?.nativeElement;\n if (!btn) {\n return;\n }\n\n const wasInsideElement = btn.contains(event.target as Node);\n this.spxHaptics.pointerUp(wasInsideElement);\n };\n // End haptics\n}\n","<button\n #suggestionRef\n type=\"button\"\n class=\"spx-suggestion block rounded text-gray-900 text-sm p-3 w-full text-left truncate outline-none\"\n [class.bg-sky-100]=\"!this.spxSelected() && !this.spxDisabled()\"\n [class.focus:ring-sky-300]=\"!this.spxSelected() && !this.spxDisabled()\"\n [class.hover:bg-sky-300]=\"!this.spxSelected() && !this.spxDisabled()\"\n [class.active:bg-sky-300]=\"!this.spxSelected() && !this.spxDisabled()\"\n [class.bg-gray-200]=\"this.spxDisabled() && !this.spxSelected()\"\n [class.bg-gray-400]=\"this.spxDisabled() && this.spxSelected()\"\n [class.cursor-not-allowed]=\"this.spxDisabled()\"\n [class.opacity-60]=\"this.spxDisabled()\"\n [class.bg-gradient-to-r]=\"this.spxSelected() && !this.spxDisabled()\"\n [class.from-teal-400]=\"this.spxSelected() && !this.spxDisabled()\"\n [class.to-teal-600]=\"this.spxSelected() && !this.spxDisabled()\"\n [class.font-bold]=\"this.spxSelected()\"\n [attr.tabindex]=\"this.spxTabbable() && !this.spxDisabled() ? 0 : -1\"\n [class.ring-2]=\"this.spxFocused() && this.spxTabbable() && !this.spxDisabled()\"\n [class.ring-offset-2]=\"this.spxFocused() && this.spxTabbable() && !this.spxDisabled()\"\n [class.ring-blue-500]=\"this.spxFocused() && this.spxTabbable() && !this.spxDisabled()\"\n (pointerdown)=\"this.handlePress()\">\n <div class=\"text-ellipsis overflow-hidden whitespace-nowrap\"><ng-content></ng-content></div>\n </button>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAWa,sBAAsB,CAAA;AAPnC,IAAA,WAAA,GAAA;QAQE,IAAA,CAAA,WAAW,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,aAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAW;QAC9B,IAAA,CAAA,UAAU,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,YAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAW;QAC7B,IAAA,CAAA,WAAW,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,aAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAW;QAC9B,IAAA,CAAA,WAAW,GAAG,KAAK,CAAA,IAAA,SAAA,GAAA,CAAA,SAAA,EAAA,EAAA,SAAA,EAAA,aAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAW;AAC9B,QAAA,IAAA,CAAA,aAAa,GAAG,SAAS,CAAgC,eAAe,yDAAC;AACjE,QAAA,IAAA,CAAA,UAAU,GAAe,IAAI,UAAU,EAAE;;QAGjD,IAAA,CAAA,WAAW,GAAG,YAAW;AACvB,YAAA,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;gBACtB;YACF;AACA,YAAA,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;AAC7B,QAAA,CAAC;AAGD,QAAA,IAAA,CAAA,mBAAmB,GAAG,OAAO,KAAmB,KAAI;AAClD,YAAA,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;gBACtB;YACF;YAEA,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,EAAE,EAAE,aAAa;YAC/C,IAAI,CAAC,GAAG,EAAE;gBACR;YACF;YAEA,MAAM,gBAAgB,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC;AAC3D,YAAA,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,gBAAgB,CAAC;AAC7C,QAAA,CAAC;AAEF,IAAA;8GA/BY,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAtB,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,sBAAsB,y0BCXnC,s8CAsBW,EAAA,MAAA,EAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;2FDXE,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAPlC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,gBAAgB,EAAA,UAAA,EACd,IAAI,EAAA,eAAA,EAGC,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,s8CAAA,EAAA;ieAOU,eAAe,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,mBAAA,EAAA,CAAA;sBAWvE,YAAY;uBAAC,oBAAoB,EAAE,CAAC,QAAQ,CAAC;;;AE3BhD;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softpak/components",
3
- "version": "21.1.0-beta.1",
3
+ "version": "21.1.0-beta.2",
4
4
  "private": false,
5
5
  "peerDependencies": {
6
6
  "@angular/common": "21.x.x",
@@ -85,6 +85,10 @@
85
85
  "types": "./types/softpak-components-spx-form-view.d.ts",
86
86
  "default": "./fesm2022/softpak-components-spx-form-view.mjs"
87
87
  },
88
+ "./spx-haptics": {
89
+ "types": "./types/softpak-components-spx-haptics.d.ts",
90
+ "default": "./fesm2022/softpak-components-spx-haptics.mjs"
91
+ },
88
92
  "./spx-helpers": {
89
93
  "types": "./types/softpak-components-spx-helpers.d.ts",
90
94
  "default": "./fesm2022/softpak-components-spx-helpers.mjs"
@@ -18,15 +18,12 @@ declare class SpxButtonComponent {
18
18
  spxClick: _angular_core.OutputEmitterRef<void>;
19
19
  buttonRef: _angular_core.Signal<ElementRef<HTMLInputElement> | undefined>;
20
20
  SpxSeverity: typeof SpxSeverityEnum;
21
- private isPressing;
22
- private lastHaptic;
23
- private hapticCooldown;
21
+ private spxHaptics;
24
22
  hasShadowDom: (el: HTMLElement) => boolean;
25
23
  handleClick: () => void;
26
24
  spxSetFocus(): void;
27
25
  handlePress: () => Promise<void>;
28
26
  onDocumentPointerUp: (event: PointerEvent) => Promise<void>;
29
- private safeHaptic;
30
27
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<SpxButtonComponent, never>;
31
28
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<SpxButtonComponent, "spx-button", never, { "spxDisabled": { "alias": "spxDisabled"; "required": false; "isSignal": true; }; "spxClass": { "alias": "spxClass"; "required": false; "isSignal": true; }; "spxClassObject": { "alias": "spxClassObject"; "required": false; "isSignal": true; }; "spxForm": { "alias": "spxForm"; "required": false; "isSignal": true; }; "spxFullHeight": { "alias": "spxFullHeight"; "required": false; "isSignal": true; }; "spxFullWidth": { "alias": "spxFullWidth"; "required": false; "isSignal": true; }; "spxSeverity": { "alias": "spxSeverity"; "required": false; "isSignal": true; }; "spxSize": { "alias": "spxSize"; "required": false; "isSignal": true; }; "spxTabIndex": { "alias": "spxTabIndex"; "required": false; "isSignal": true; }; "spxType": { "alias": "spxType"; "required": false; "isSignal": true; }; "spxName": { "alias": "spxName"; "required": false; "isSignal": true; }; }, { "spxClick": "spxClick"; }, never, ["*"], true, never>;
32
29
  }
@@ -0,0 +1,13 @@
1
+ import { ImpactStyle } from '@capacitor/haptics';
2
+
3
+ declare class SpxHaptics {
4
+ private static lastHaptic;
5
+ private static hapticCooldown;
6
+ private touchAreaIsBeingPressed;
7
+ constructor();
8
+ pressDown(): Promise<void>;
9
+ pointerUp(wasInsideElement: boolean): Promise<void>;
10
+ safeHaptic(style: ImpactStyle): Promise<void>;
11
+ }
12
+
13
+ export { SpxHaptics };
@@ -14,7 +14,8 @@ declare enum SpxStorageKeyEnum {
14
14
  randomDeviceId = "randomDeviceId",
15
15
  release = "release",
16
16
  patch = "patch",
17
- username = "username"
17
+ username = "username",
18
+ noHaptics = "noHaptics"
18
19
  }
19
20
 
20
21
  declare class SpxStorage {
@@ -6,8 +6,8 @@ declare class SpxSuggestionComponent {
6
6
  spxFocused: _angular_core.InputSignal<boolean | undefined>;
7
7
  spxSelected: _angular_core.InputSignal<boolean | undefined>;
8
8
  spxTabbable: _angular_core.InputSignal<boolean | undefined>;
9
- private isPressing;
10
9
  suggestionRef: _angular_core.Signal<ElementRef<HTMLButtonElement> | undefined>;
10
+ private spxHaptics;
11
11
  handlePress: () => Promise<void>;
12
12
  onDocumentPointerUp: (event: PointerEvent) => Promise<void>;
13
13
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<SpxSuggestionComponent, never>;