@acorex/cdk 22.1.8 → 22.2.0-next.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/auto-follow-scroll/README.md +9 -0
- package/fesm2022/acorex-cdk-accordion.mjs +19 -19
- package/fesm2022/acorex-cdk-accordion.mjs.map +1 -1
- package/fesm2022/acorex-cdk-auto-follow-scroll.mjs +187 -0
- package/fesm2022/acorex-cdk-auto-follow-scroll.mjs.map +1 -0
- package/fesm2022/acorex-cdk-carousel.mjs +25 -7
- package/fesm2022/acorex-cdk-carousel.mjs.map +1 -1
- package/fesm2022/acorex-cdk-clipboard.mjs +6 -6
- package/fesm2022/acorex-cdk-clipboard.mjs.map +1 -1
- package/fesm2022/acorex-cdk-common.mjs +146 -92
- package/fesm2022/acorex-cdk-common.mjs.map +1 -1
- package/fesm2022/acorex-cdk-dom.mjs +3 -3
- package/fesm2022/acorex-cdk-dom.mjs.map +1 -1
- package/fesm2022/acorex-cdk-drag-drop.mjs +158 -68
- package/fesm2022/acorex-cdk-drag-drop.mjs.map +1 -1
- package/fesm2022/acorex-cdk-drawer.mjs +11 -11
- package/fesm2022/acorex-cdk-drawer.mjs.map +1 -1
- package/fesm2022/acorex-cdk-focus-trap.mjs +3 -3
- package/fesm2022/acorex-cdk-focus-trap.mjs.map +1 -1
- package/fesm2022/acorex-cdk-full-screen.mjs +26 -147
- package/fesm2022/acorex-cdk-full-screen.mjs.map +1 -1
- package/fesm2022/acorex-cdk-gesture.mjs +30 -4
- package/fesm2022/acorex-cdk-gesture.mjs.map +1 -1
- package/fesm2022/acorex-cdk-highlight.mjs +8 -78
- package/fesm2022/acorex-cdk-highlight.mjs.map +1 -1
- package/fesm2022/acorex-cdk-horizontal-scroll.mjs +27 -10
- package/fesm2022/acorex-cdk-horizontal-scroll.mjs.map +1 -1
- package/fesm2022/acorex-cdk-input-mask.mjs +3 -3
- package/fesm2022/acorex-cdk-input-mask.mjs.map +1 -1
- package/fesm2022/acorex-cdk-list-navigation.mjs +10 -10
- package/fesm2022/acorex-cdk-list-navigation.mjs.map +1 -1
- package/fesm2022/acorex-cdk-outline.mjs +277 -74
- package/fesm2022/acorex-cdk-outline.mjs.map +1 -1
- package/fesm2022/acorex-cdk-overlay.mjs +224 -21
- package/fesm2022/acorex-cdk-overlay.mjs.map +1 -1
- package/fesm2022/acorex-cdk-pan-view.mjs +3 -3
- package/fesm2022/acorex-cdk-pan-view.mjs.map +1 -1
- package/fesm2022/acorex-cdk-qrcode.mjs.map +1 -1
- package/fesm2022/acorex-cdk-resizable.mjs +483 -200
- package/fesm2022/acorex-cdk-resizable.mjs.map +1 -1
- package/fesm2022/acorex-cdk-selection.mjs +10 -10
- package/fesm2022/acorex-cdk-selection.mjs.map +1 -1
- package/fesm2022/acorex-cdk-shimmer.mjs +220 -0
- package/fesm2022/acorex-cdk-shimmer.mjs.map +1 -0
- package/fesm2022/acorex-cdk-sliding-item.mjs +3 -3
- package/fesm2022/acorex-cdk-sliding-item.mjs.map +1 -1
- package/fesm2022/acorex-cdk-sticky.mjs +3 -3
- package/fesm2022/acorex-cdk-sticky.mjs.map +1 -1
- package/fesm2022/acorex-cdk-uploader.mjs +9 -9
- package/fesm2022/acorex-cdk-uploader.mjs.map +1 -1
- package/fesm2022/acorex-cdk-viewport-guard.mjs +616 -0
- package/fesm2022/acorex-cdk-viewport-guard.mjs.map +1 -0
- package/fesm2022/acorex-cdk-virtual-scroll.mjs +10 -10
- package/fesm2022/acorex-cdk-virtual-scroll.mjs.map +1 -1
- package/fesm2022/acorex-cdk-wysiwyg.mjs +689 -37
- package/fesm2022/acorex-cdk-wysiwyg.mjs.map +1 -1
- package/fesm2022/acorex-cdk-z-index.mjs +3 -3
- package/fesm2022/acorex-cdk-z-index.mjs.map +1 -1
- package/fesm2022/acorex-cdk.mjs.map +1 -1
- package/package.json +23 -7
- package/shimmer/README.md +11 -0
- package/types/acorex-cdk-auto-follow-scroll.d.ts +72 -0
- package/types/acorex-cdk-carousel.d.ts +2 -0
- package/types/acorex-cdk-clipboard.d.ts +1 -1
- package/types/acorex-cdk-common.d.ts +36 -19
- package/types/acorex-cdk-drag-drop.d.ts +43 -17
- package/types/acorex-cdk-full-screen.d.ts +18 -43
- package/types/acorex-cdk-gesture.d.ts +11 -1
- package/types/acorex-cdk-highlight.d.ts +1 -28
- package/types/acorex-cdk-horizontal-scroll.d.ts +3 -0
- package/types/acorex-cdk-outline.d.ts +20 -0
- package/types/acorex-cdk-overlay.d.ts +60 -4
- package/types/acorex-cdk-resizable.d.ts +80 -38
- package/types/acorex-cdk-shimmer.d.ts +68 -0
- package/types/acorex-cdk-uploader.d.ts +1 -1
- package/types/acorex-cdk-viewport-guard.d.ts +99 -0
- package/types/acorex-cdk-wysiwyg.d.ts +118 -14
- package/wysiwyg/README.md +3 -1
- package/fesm2022/acorex-cdk-double-click.mjs +0 -178
- package/fesm2022/acorex-cdk-double-click.mjs.map +0 -1
- package/types/acorex-cdk-double-click.d.ts +0 -66
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, ChangeDetectionStrategy, Component, inject, ApplicationRef, EnvironmentInjector, DestroyRef, DOCUMENT, PLATFORM_ID, NgZone, signal, effect, untracked, createComponent, Injectable, ElementRef, afterNextRender, TemplateRef, Directive, contentChild, booleanAttribute } from '@angular/core';
|
|
3
|
+
import { AXTranslationService } from '@acorex/core/translation';
|
|
4
|
+
import { NgTemplateOutlet, isPlatformBrowser } from '@angular/common';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
|
|
7
|
+
class AXViewportGuardOverlayComponent {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.guard = input(null, /* @ts-ignore */
|
|
10
|
+
...(ngDevMode ? [{ debugName: "guard" }] : /* istanbul ignore next */ []));
|
|
11
|
+
}
|
|
12
|
+
context(view) {
|
|
13
|
+
const message = {
|
|
14
|
+
kind: view.kind,
|
|
15
|
+
orientation: view.orientation,
|
|
16
|
+
kicker: view.kicker,
|
|
17
|
+
title: view.title,
|
|
18
|
+
message: view.message,
|
|
19
|
+
hint: view.hint,
|
|
20
|
+
};
|
|
21
|
+
return { $implicit: message, message };
|
|
22
|
+
}
|
|
23
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXViewportGuardOverlayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
24
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.6", type: AXViewportGuardOverlayComponent, isStandalone: true, selector: "ax-viewport-guard-overlay", inputs: { guard: { classPropertyName: "guard", publicName: "guard", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "ax-vg-host" }, ngImport: i0, template: `
|
|
25
|
+
@if (guard(); as view) {
|
|
26
|
+
<div
|
|
27
|
+
class="ax-vg"
|
|
28
|
+
role="alertdialog"
|
|
29
|
+
aria-modal="true"
|
|
30
|
+
tabindex="0"
|
|
31
|
+
[attr.aria-labelledby]="view.template ? null : 'ax-vg-title'"
|
|
32
|
+
[attr.aria-describedby]="view.template ? null : 'ax-vg-message'"
|
|
33
|
+
[attr.aria-label]="view.template ? view.title : null"
|
|
34
|
+
>
|
|
35
|
+
@if (view.template; as template) {
|
|
36
|
+
<ng-container [ngTemplateOutlet]="template" [ngTemplateOutletContext]="context(view)" />
|
|
37
|
+
} @else {
|
|
38
|
+
<section class="ax-vg__card" [attr.data-kind]="view.kind">
|
|
39
|
+
<div
|
|
40
|
+
class="ax-vg__art"
|
|
41
|
+
[class.ax-vg__art--portrait]="view.kind === 'orientation' && view.orientation === 'portrait'"
|
|
42
|
+
[class.ax-vg__art--landscape]="view.kind === 'orientation' && view.orientation === 'landscape'"
|
|
43
|
+
aria-hidden="true"
|
|
44
|
+
>
|
|
45
|
+
@switch (view.kind) {
|
|
46
|
+
@case ('size') {
|
|
47
|
+
<svg class="ax-vg__glyph" viewBox="0 0 64 64" fill="none">
|
|
48
|
+
<rect x="18" y="18" width="28" height="28" rx="6" stroke="currentColor" stroke-width="2.25" />
|
|
49
|
+
<path
|
|
50
|
+
d="M10 18V10h8M54 18V10h-8M10 46v8h8M54 46v8h-8"
|
|
51
|
+
stroke="currentColor"
|
|
52
|
+
stroke-width="2.25"
|
|
53
|
+
stroke-linecap="round"
|
|
54
|
+
stroke-linejoin="round"
|
|
55
|
+
/>
|
|
56
|
+
</svg>
|
|
57
|
+
}
|
|
58
|
+
@case ('orientation') {
|
|
59
|
+
<svg class="ax-vg__orbit" viewBox="0 0 64 64" fill="none">
|
|
60
|
+
<path
|
|
61
|
+
d="M32 54A22 22 0 1 1 48.4 17.3"
|
|
62
|
+
stroke="currentColor"
|
|
63
|
+
stroke-width="2.4"
|
|
64
|
+
stroke-linecap="round"
|
|
65
|
+
/>
|
|
66
|
+
<path d="M52.7 22.1 45 19.5 50.9 14.1Z" fill="currentColor" />
|
|
67
|
+
</svg>
|
|
68
|
+
<svg class="ax-vg__phone" viewBox="0 0 64 64" fill="none">
|
|
69
|
+
<rect x="24" y="12" width="16" height="40" rx="4" stroke="currentColor" stroke-width="2.25" />
|
|
70
|
+
<path d="M29 18h6" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" />
|
|
71
|
+
<circle cx="32" cy="45" r="1.35" fill="currentColor" />
|
|
72
|
+
</svg>
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
</div>
|
|
76
|
+
<div class="ax-vg__copy">
|
|
77
|
+
<p class="ax-vg__kicker">{{ view.kicker }}</p>
|
|
78
|
+
<h2 id="ax-vg-title" class="ax-vg__title">{{ view.title }}</h2>
|
|
79
|
+
<p id="ax-vg-message" class="ax-vg__message">{{ view.message }}</p>
|
|
80
|
+
<p class="ax-vg__hint">{{ view.hint }}</p>
|
|
81
|
+
</div>
|
|
82
|
+
</section>
|
|
83
|
+
}
|
|
84
|
+
</div>
|
|
85
|
+
}
|
|
86
|
+
`, isInline: true, styles: [":host{position:fixed;inset:0;z-index:2147483000;display:block;overflow:auto;overscroll-behavior:none;color:#141414;color:rgba(var(--ax-sys-color-on-surface),1);background-color:#f4f4f5;background-image:radial-gradient(ellipse 90% 55% at 50% -12%,rgba(var(--ax-sys-color-warning-200),.7),transparent 58%),radial-gradient(ellipse 46% 38% at 100% 100%,rgba(var(--ax-sys-color-primary-200),.38),transparent 60%),linear-gradient(rgba(var(--ax-sys-color-surface),.94),rgba(var(--ax-sys-color-surface),.94));-webkit-font-smoothing:antialiased}.ax-vg{box-sizing:border-box;min-height:100%;display:grid;place-items:center;padding:max(1.25rem,env(safe-area-inset-top)) max(1.25rem,env(safe-area-inset-right)) max(1.25rem,env(safe-area-inset-bottom)) max(1.25rem,env(safe-area-inset-left))}.ax-vg:focus{outline:none}.ax-vg__card{box-sizing:border-box;width:min(26.5rem,100%);display:flex;flex-direction:column;align-items:center;text-align:center;gap:clamp(.9rem,2.6vh,1.35rem);padding:clamp(1.35rem,4.2vw,2.15rem);border-radius:clamp(1.25rem,3vw,1.75rem);background:#ffffffeb;background:rgba(var(--ax-sys-color-lightest-surface),.92);border:1px solid rgba(226,226,226,.9);border:1px solid rgba(var(--ax-sys-color-border-lightest-surface),.95);box-shadow:inset 0 1px #ffffff8c,0 18px 50px #0a0a0a1f;-webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px);animation:ax-viewport-guard-in .32s cubic-bezier(.2,.8,.2,1)}.ax-vg__art{position:relative;width:clamp(4.75rem,22vw,6.5rem);height:clamp(4.75rem,22vw,6.5rem);flex:none;display:grid;place-items:center;border-radius:1.5rem;color:#8a4b00;color:rgba(var(--ax-sys-color-warning-800),1);background:#fff4dc;background:radial-gradient(circle at 50% 38%,rgba(var(--ax-sys-color-warning-50),1),rgba(var(--ax-sys-color-warning-100),1));box-shadow:inset 0 0 0 1px rgba(var(--ax-sys-color-warning-200),.95)}.ax-vg__glyph{width:64%;height:64%;animation:ax-viewport-guard-pulse 2.6s ease-in-out infinite}.ax-vg__orbit,.ax-vg__phone{position:absolute;width:auto;height:auto}.ax-vg__orbit{inset:10%;opacity:.9}.ax-vg__phone{inset:27%;transform-origin:center}.ax-vg__art--portrait .ax-vg__phone{animation:ax-viewport-guard-to-portrait 2.6s ease-in-out infinite}.ax-vg__art--landscape .ax-vg__phone{animation:ax-viewport-guard-to-landscape 2.6s ease-in-out infinite}.ax-vg__copy{width:100%;min-width:0}.ax-vg__kicker{display:inline-flex;margin:0 0 .55rem;padding:.18rem .65rem;border-radius:999px;background:rgba(var(--ax-sys-color-warning-100),1);color:rgba(var(--ax-sys-color-warning-900),1);font-size:.75rem;font-weight:600;line-height:1.4}.ax-vg__title{margin:0;font-size:clamp(1.25rem,1.6vw + .85rem,1.7rem);font-weight:700;line-height:1.28;text-wrap:balance}.ax-vg__message{margin:.55rem 0 0;font-size:clamp(.9rem,.5vw + .78rem,1.02rem);line-height:1.6;color:#141414b8;color:rgba(var(--ax-sys-color-on-surface),.72);text-wrap:pretty}.ax-vg__hint{display:inline-flex;align-items:center;justify-content:center;margin:1rem 0 0;padding:.42rem .8rem;border-radius:999px;background:rgba(var(--ax-sys-color-warning-50),1);color:rgba(var(--ax-sys-color-warning-900),1);font-size:clamp(.75rem,.4vw + .68rem,.84rem);font-weight:600;line-height:1.3}@media(max-height:540px){.ax-vg__card{flex-direction:row;align-items:center;text-align:start;width:min(42rem,100%);gap:1rem;padding:1rem 1.15rem;border-radius:1.35rem}.ax-vg__art{width:4.15rem;height:4.15rem;border-radius:1.15rem}.ax-vg__copy{flex:1;width:auto}.ax-vg__kicker{margin-bottom:.35rem}.ax-vg__message{margin-top:.35rem}.ax-vg__hint{margin-top:.7rem}}@media(max-width:380px){.ax-vg{padding:max(.85rem,env(safe-area-inset-top)) max(.85rem,env(safe-area-inset-right)) max(.85rem,env(safe-area-inset-bottom)) max(.85rem,env(safe-area-inset-left))}.ax-vg__card{padding:1.15rem 1rem;border-radius:1.2rem}}@media(max-height:540px)and (max-width:560px){.ax-vg__title{font-size:1.05rem}.ax-vg__message{font-size:.84rem;line-height:1.45}.ax-vg__hint{margin-top:.55rem;padding:.32rem .65rem}}@media(max-height:340px){.ax-vg__kicker{display:none}.ax-vg__art{width:3.25rem;height:3.25rem}}@media(prefers-reduced-motion:reduce){.ax-vg__card,.ax-vg__glyph,.ax-vg__phone{animation:none}.ax-vg__art--portrait .ax-vg__phone{transform:rotate(0)}.ax-vg__art--landscape .ax-vg__phone{transform:rotate(90deg)}}@keyframes ax-viewport-guard-pulse{0%,to{transform:scale(1)}50%{transform:scale(1.06)}}@keyframes ax-viewport-guard-in{0%{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}@keyframes ax-viewport-guard-to-portrait{0%,18%{transform:rotate(90deg)}46%,70%{transform:rotate(0)}to{transform:rotate(90deg)}}@keyframes ax-viewport-guard-to-landscape{0%,18%{transform:rotate(0)}46%,70%{transform:rotate(90deg)}to{transform:rotate(0)}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
87
|
+
}
|
|
88
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXViewportGuardOverlayComponent, decorators: [{
|
|
89
|
+
type: Component,
|
|
90
|
+
args: [{ selector: 'ax-viewport-guard-overlay', changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet], host: {
|
|
91
|
+
class: 'ax-vg-host',
|
|
92
|
+
}, template: `
|
|
93
|
+
@if (guard(); as view) {
|
|
94
|
+
<div
|
|
95
|
+
class="ax-vg"
|
|
96
|
+
role="alertdialog"
|
|
97
|
+
aria-modal="true"
|
|
98
|
+
tabindex="0"
|
|
99
|
+
[attr.aria-labelledby]="view.template ? null : 'ax-vg-title'"
|
|
100
|
+
[attr.aria-describedby]="view.template ? null : 'ax-vg-message'"
|
|
101
|
+
[attr.aria-label]="view.template ? view.title : null"
|
|
102
|
+
>
|
|
103
|
+
@if (view.template; as template) {
|
|
104
|
+
<ng-container [ngTemplateOutlet]="template" [ngTemplateOutletContext]="context(view)" />
|
|
105
|
+
} @else {
|
|
106
|
+
<section class="ax-vg__card" [attr.data-kind]="view.kind">
|
|
107
|
+
<div
|
|
108
|
+
class="ax-vg__art"
|
|
109
|
+
[class.ax-vg__art--portrait]="view.kind === 'orientation' && view.orientation === 'portrait'"
|
|
110
|
+
[class.ax-vg__art--landscape]="view.kind === 'orientation' && view.orientation === 'landscape'"
|
|
111
|
+
aria-hidden="true"
|
|
112
|
+
>
|
|
113
|
+
@switch (view.kind) {
|
|
114
|
+
@case ('size') {
|
|
115
|
+
<svg class="ax-vg__glyph" viewBox="0 0 64 64" fill="none">
|
|
116
|
+
<rect x="18" y="18" width="28" height="28" rx="6" stroke="currentColor" stroke-width="2.25" />
|
|
117
|
+
<path
|
|
118
|
+
d="M10 18V10h8M54 18V10h-8M10 46v8h8M54 46v8h-8"
|
|
119
|
+
stroke="currentColor"
|
|
120
|
+
stroke-width="2.25"
|
|
121
|
+
stroke-linecap="round"
|
|
122
|
+
stroke-linejoin="round"
|
|
123
|
+
/>
|
|
124
|
+
</svg>
|
|
125
|
+
}
|
|
126
|
+
@case ('orientation') {
|
|
127
|
+
<svg class="ax-vg__orbit" viewBox="0 0 64 64" fill="none">
|
|
128
|
+
<path
|
|
129
|
+
d="M32 54A22 22 0 1 1 48.4 17.3"
|
|
130
|
+
stroke="currentColor"
|
|
131
|
+
stroke-width="2.4"
|
|
132
|
+
stroke-linecap="round"
|
|
133
|
+
/>
|
|
134
|
+
<path d="M52.7 22.1 45 19.5 50.9 14.1Z" fill="currentColor" />
|
|
135
|
+
</svg>
|
|
136
|
+
<svg class="ax-vg__phone" viewBox="0 0 64 64" fill="none">
|
|
137
|
+
<rect x="24" y="12" width="16" height="40" rx="4" stroke="currentColor" stroke-width="2.25" />
|
|
138
|
+
<path d="M29 18h6" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" />
|
|
139
|
+
<circle cx="32" cy="45" r="1.35" fill="currentColor" />
|
|
140
|
+
</svg>
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
</div>
|
|
144
|
+
<div class="ax-vg__copy">
|
|
145
|
+
<p class="ax-vg__kicker">{{ view.kicker }}</p>
|
|
146
|
+
<h2 id="ax-vg-title" class="ax-vg__title">{{ view.title }}</h2>
|
|
147
|
+
<p id="ax-vg-message" class="ax-vg__message">{{ view.message }}</p>
|
|
148
|
+
<p class="ax-vg__hint">{{ view.hint }}</p>
|
|
149
|
+
</div>
|
|
150
|
+
</section>
|
|
151
|
+
}
|
|
152
|
+
</div>
|
|
153
|
+
}
|
|
154
|
+
`, styles: [":host{position:fixed;inset:0;z-index:2147483000;display:block;overflow:auto;overscroll-behavior:none;color:#141414;color:rgba(var(--ax-sys-color-on-surface),1);background-color:#f4f4f5;background-image:radial-gradient(ellipse 90% 55% at 50% -12%,rgba(var(--ax-sys-color-warning-200),.7),transparent 58%),radial-gradient(ellipse 46% 38% at 100% 100%,rgba(var(--ax-sys-color-primary-200),.38),transparent 60%),linear-gradient(rgba(var(--ax-sys-color-surface),.94),rgba(var(--ax-sys-color-surface),.94));-webkit-font-smoothing:antialiased}.ax-vg{box-sizing:border-box;min-height:100%;display:grid;place-items:center;padding:max(1.25rem,env(safe-area-inset-top)) max(1.25rem,env(safe-area-inset-right)) max(1.25rem,env(safe-area-inset-bottom)) max(1.25rem,env(safe-area-inset-left))}.ax-vg:focus{outline:none}.ax-vg__card{box-sizing:border-box;width:min(26.5rem,100%);display:flex;flex-direction:column;align-items:center;text-align:center;gap:clamp(.9rem,2.6vh,1.35rem);padding:clamp(1.35rem,4.2vw,2.15rem);border-radius:clamp(1.25rem,3vw,1.75rem);background:#ffffffeb;background:rgba(var(--ax-sys-color-lightest-surface),.92);border:1px solid rgba(226,226,226,.9);border:1px solid rgba(var(--ax-sys-color-border-lightest-surface),.95);box-shadow:inset 0 1px #ffffff8c,0 18px 50px #0a0a0a1f;-webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px);animation:ax-viewport-guard-in .32s cubic-bezier(.2,.8,.2,1)}.ax-vg__art{position:relative;width:clamp(4.75rem,22vw,6.5rem);height:clamp(4.75rem,22vw,6.5rem);flex:none;display:grid;place-items:center;border-radius:1.5rem;color:#8a4b00;color:rgba(var(--ax-sys-color-warning-800),1);background:#fff4dc;background:radial-gradient(circle at 50% 38%,rgba(var(--ax-sys-color-warning-50),1),rgba(var(--ax-sys-color-warning-100),1));box-shadow:inset 0 0 0 1px rgba(var(--ax-sys-color-warning-200),.95)}.ax-vg__glyph{width:64%;height:64%;animation:ax-viewport-guard-pulse 2.6s ease-in-out infinite}.ax-vg__orbit,.ax-vg__phone{position:absolute;width:auto;height:auto}.ax-vg__orbit{inset:10%;opacity:.9}.ax-vg__phone{inset:27%;transform-origin:center}.ax-vg__art--portrait .ax-vg__phone{animation:ax-viewport-guard-to-portrait 2.6s ease-in-out infinite}.ax-vg__art--landscape .ax-vg__phone{animation:ax-viewport-guard-to-landscape 2.6s ease-in-out infinite}.ax-vg__copy{width:100%;min-width:0}.ax-vg__kicker{display:inline-flex;margin:0 0 .55rem;padding:.18rem .65rem;border-radius:999px;background:rgba(var(--ax-sys-color-warning-100),1);color:rgba(var(--ax-sys-color-warning-900),1);font-size:.75rem;font-weight:600;line-height:1.4}.ax-vg__title{margin:0;font-size:clamp(1.25rem,1.6vw + .85rem,1.7rem);font-weight:700;line-height:1.28;text-wrap:balance}.ax-vg__message{margin:.55rem 0 0;font-size:clamp(.9rem,.5vw + .78rem,1.02rem);line-height:1.6;color:#141414b8;color:rgba(var(--ax-sys-color-on-surface),.72);text-wrap:pretty}.ax-vg__hint{display:inline-flex;align-items:center;justify-content:center;margin:1rem 0 0;padding:.42rem .8rem;border-radius:999px;background:rgba(var(--ax-sys-color-warning-50),1);color:rgba(var(--ax-sys-color-warning-900),1);font-size:clamp(.75rem,.4vw + .68rem,.84rem);font-weight:600;line-height:1.3}@media(max-height:540px){.ax-vg__card{flex-direction:row;align-items:center;text-align:start;width:min(42rem,100%);gap:1rem;padding:1rem 1.15rem;border-radius:1.35rem}.ax-vg__art{width:4.15rem;height:4.15rem;border-radius:1.15rem}.ax-vg__copy{flex:1;width:auto}.ax-vg__kicker{margin-bottom:.35rem}.ax-vg__message{margin-top:.35rem}.ax-vg__hint{margin-top:.7rem}}@media(max-width:380px){.ax-vg{padding:max(.85rem,env(safe-area-inset-top)) max(.85rem,env(safe-area-inset-right)) max(.85rem,env(safe-area-inset-bottom)) max(.85rem,env(safe-area-inset-left))}.ax-vg__card{padding:1.15rem 1rem;border-radius:1.2rem}}@media(max-height:540px)and (max-width:560px){.ax-vg__title{font-size:1.05rem}.ax-vg__message{font-size:.84rem;line-height:1.45}.ax-vg__hint{margin-top:.55rem;padding:.32rem .65rem}}@media(max-height:340px){.ax-vg__kicker{display:none}.ax-vg__art{width:3.25rem;height:3.25rem}}@media(prefers-reduced-motion:reduce){.ax-vg__card,.ax-vg__glyph,.ax-vg__phone{animation:none}.ax-vg__art--portrait .ax-vg__phone{transform:rotate(0)}.ax-vg__art--landscape .ax-vg__phone{transform:rotate(90deg)}}@keyframes ax-viewport-guard-pulse{0%,to{transform:scale(1)}50%{transform:scale(1.06)}}@keyframes ax-viewport-guard-in{0%{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}@keyframes ax-viewport-guard-to-portrait{0%,18%{transform:rotate(90deg)}46%,70%{transform:rotate(0)}to{transform:rotate(90deg)}}@keyframes ax-viewport-guard-to-landscape{0%,18%{transform:rotate(0)}46%,70%{transform:rotate(90deg)}to{transform:rotate(0)}}\n"] }]
|
|
155
|
+
}], propDecorators: { guard: [{ type: i0.Input, args: [{ isSignal: true, alias: "guard", required: false }] }] } });
|
|
156
|
+
|
|
157
|
+
const PHONE_SHORT_SIDE = 540;
|
|
158
|
+
const EMPTY_SNAPSHOT = { width: 0, height: 0, portrait: true, phone: false, ready: false };
|
|
159
|
+
class AXViewportGuardPresenter {
|
|
160
|
+
constructor() {
|
|
161
|
+
this.appRef = inject(ApplicationRef);
|
|
162
|
+
this.environmentInjector = inject(EnvironmentInjector);
|
|
163
|
+
this.destroyRef = inject(DestroyRef);
|
|
164
|
+
this.document = inject(DOCUMENT);
|
|
165
|
+
this.platformId = inject(PLATFORM_ID);
|
|
166
|
+
this.zone = inject(NgZone);
|
|
167
|
+
this.translation = inject(AXTranslationService);
|
|
168
|
+
this.requests = signal(new Map(), /* @ts-ignore */
|
|
169
|
+
...(ngDevMode ? [{ debugName: "requests" }] : /* istanbul ignore next */ []));
|
|
170
|
+
this.lang = signal(this.translation.getActiveLang(), /* @ts-ignore */
|
|
171
|
+
...(ngDevMode ? [{ debugName: "lang" }] : /* istanbul ignore next */ []));
|
|
172
|
+
this.snapshot = signal(EMPTY_SNAPSHOT, /* @ts-ignore */
|
|
173
|
+
...(ngDevMode ? [{ debugName: "snapshot" }] : /* istanbul ignore next */ []));
|
|
174
|
+
this.viewRef = null;
|
|
175
|
+
this.listening = false;
|
|
176
|
+
this.bodyOverflow = null;
|
|
177
|
+
this.focusedKey = '';
|
|
178
|
+
this.translation.langChanges$.pipe(takeUntilDestroyed()).subscribe((lang) => this.lang.set(lang));
|
|
179
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
effect(() => {
|
|
183
|
+
const view = this.activeView();
|
|
184
|
+
untracked(() => this.sync(view));
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
ensureListening() {
|
|
188
|
+
if (this.listening || !isPlatformBrowser(this.platformId)) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const win = this.document.defaultView;
|
|
192
|
+
if (!win) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
this.listening = true;
|
|
196
|
+
const portrait = win.matchMedia('(orientation: portrait)');
|
|
197
|
+
const publish = () => this.zone.run(() => this.snapshot.set(readViewport(win)));
|
|
198
|
+
const publishSoon = () => {
|
|
199
|
+
publish();
|
|
200
|
+
win.requestAnimationFrame(publish);
|
|
201
|
+
};
|
|
202
|
+
publish();
|
|
203
|
+
win.addEventListener('resize', publish, { passive: true });
|
|
204
|
+
win.visualViewport?.addEventListener('resize', publish);
|
|
205
|
+
win.addEventListener('orientationchange', publishSoon);
|
|
206
|
+
portrait.addEventListener('change', publishSoon);
|
|
207
|
+
this.destroyRef.onDestroy(() => {
|
|
208
|
+
win.removeEventListener('resize', publish);
|
|
209
|
+
win.visualViewport?.removeEventListener('resize', publish);
|
|
210
|
+
win.removeEventListener('orientationchange', publishSoon);
|
|
211
|
+
portrait.removeEventListener('change', publishSoon);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
claim(id, request) {
|
|
215
|
+
this.requests.update((current) => {
|
|
216
|
+
const existing = current.get(id);
|
|
217
|
+
if (!request && !existing) {
|
|
218
|
+
return current;
|
|
219
|
+
}
|
|
220
|
+
if (request && existing && sameRequest(existing, request)) {
|
|
221
|
+
return current;
|
|
222
|
+
}
|
|
223
|
+
const next = new Map(current);
|
|
224
|
+
if (request) {
|
|
225
|
+
next.set(id, request);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
next.delete(id);
|
|
229
|
+
}
|
|
230
|
+
return next;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
activeView() {
|
|
234
|
+
this.lang();
|
|
235
|
+
const request = pickRequest(this.requests());
|
|
236
|
+
if (!request) {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
return request.kind === 'size' ? this.sizeView(request) : this.orientationView(request);
|
|
240
|
+
}
|
|
241
|
+
sizeView(request) {
|
|
242
|
+
const copy = request.message;
|
|
243
|
+
const width = request.minWidth > 0 ? String(request.minWidth) : '';
|
|
244
|
+
const height = request.minHeight != null && request.minHeight > 0 ? String(request.minHeight) : '';
|
|
245
|
+
const params = {
|
|
246
|
+
width: isolate(width),
|
|
247
|
+
height: isolate(height),
|
|
248
|
+
size: isolate(width && height ? `${width} × ${height}` : width || height),
|
|
249
|
+
};
|
|
250
|
+
const hintKey = width && height ? 'hint' : height ? 'hint-height' : 'hint-width';
|
|
251
|
+
return {
|
|
252
|
+
kind: 'size',
|
|
253
|
+
orientation: null,
|
|
254
|
+
kicker: this.part(copy?.kicker, 'viewport-guard.size.kicker'),
|
|
255
|
+
title: this.part(copy?.title, 'viewport-guard.size.title'),
|
|
256
|
+
message: this.part(copy?.message, 'viewport-guard.size.message'),
|
|
257
|
+
hint: this.part(copy?.hint, `viewport-guard.size.${hintKey}`, params),
|
|
258
|
+
template: request.template,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
orientationView(request) {
|
|
262
|
+
const copy = request.message;
|
|
263
|
+
const mode = request.orientation;
|
|
264
|
+
return {
|
|
265
|
+
kind: 'orientation',
|
|
266
|
+
orientation: mode,
|
|
267
|
+
kicker: this.part(copy?.kicker, 'viewport-guard.orientation.kicker'),
|
|
268
|
+
title: this.part(copy?.title, `viewport-guard.orientation.title-${mode}`),
|
|
269
|
+
message: this.part(copy?.message, `viewport-guard.orientation.message-${mode}`),
|
|
270
|
+
hint: this.part(copy?.hint, `viewport-guard.orientation.hint-${mode}`),
|
|
271
|
+
template: request.template,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
part(custom, key, params) {
|
|
275
|
+
const source = custom?.trim() || key;
|
|
276
|
+
return this.translation.translateSync(source, { scope: 'acorex', params });
|
|
277
|
+
}
|
|
278
|
+
sync(view) {
|
|
279
|
+
if (!view) {
|
|
280
|
+
this.teardown();
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
this.lockScroll();
|
|
284
|
+
const ref = this.ensureView();
|
|
285
|
+
ref.setInput('guard', view);
|
|
286
|
+
ref.changeDetectorRef.detectChanges();
|
|
287
|
+
this.focus(view);
|
|
288
|
+
}
|
|
289
|
+
ensureView() {
|
|
290
|
+
if (this.viewRef) {
|
|
291
|
+
return this.viewRef;
|
|
292
|
+
}
|
|
293
|
+
const ref = createComponent(AXViewportGuardOverlayComponent, { environmentInjector: this.environmentInjector });
|
|
294
|
+
this.appRef.attachView(ref.hostView);
|
|
295
|
+
const host = ref.location.nativeElement;
|
|
296
|
+
const body = this.document.body;
|
|
297
|
+
const fontFamily = body ? this.document.defaultView?.getComputedStyle(body).fontFamily : '';
|
|
298
|
+
if (fontFamily) {
|
|
299
|
+
host.style.fontFamily = fontFamily;
|
|
300
|
+
}
|
|
301
|
+
this.document.documentElement.appendChild(host);
|
|
302
|
+
this.viewRef = ref;
|
|
303
|
+
return ref;
|
|
304
|
+
}
|
|
305
|
+
focus(view) {
|
|
306
|
+
const key = `${view.kind}|${view.orientation}|${view.title}|${view.message}|${view.hint}`;
|
|
307
|
+
if (key === this.focusedKey) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.focusedKey = key;
|
|
311
|
+
queueMicrotask(() => {
|
|
312
|
+
const dialog = this.viewRef?.location.nativeElement.querySelector('[role="alertdialog"]');
|
|
313
|
+
dialog?.focus({ preventScroll: true });
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
lockScroll() {
|
|
317
|
+
const body = this.document.body;
|
|
318
|
+
if (!body || this.bodyOverflow !== null) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
this.bodyOverflow = body.style.overflow;
|
|
322
|
+
body.style.overflow = 'hidden';
|
|
323
|
+
}
|
|
324
|
+
teardown() {
|
|
325
|
+
this.focusedKey = '';
|
|
326
|
+
const body = this.document.body;
|
|
327
|
+
if (body && this.bodyOverflow !== null) {
|
|
328
|
+
body.style.overflow = this.bodyOverflow;
|
|
329
|
+
this.bodyOverflow = null;
|
|
330
|
+
}
|
|
331
|
+
if (!this.viewRef) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
this.appRef.detachView(this.viewRef.hostView);
|
|
335
|
+
this.viewRef.destroy();
|
|
336
|
+
this.viewRef = null;
|
|
337
|
+
}
|
|
338
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXViewportGuardPresenter, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
339
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXViewportGuardPresenter, providedIn: 'root' }); }
|
|
340
|
+
}
|
|
341
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXViewportGuardPresenter, decorators: [{
|
|
342
|
+
type: Injectable,
|
|
343
|
+
args: [{ providedIn: 'root' }]
|
|
344
|
+
}], ctorParameters: () => [] });
|
|
345
|
+
let nextGuardId = 0;
|
|
346
|
+
/** Wires a directive to the shared overlay. Call from the directive constructor. */
|
|
347
|
+
function connectViewportGuard(prefix, active) {
|
|
348
|
+
const host = inject(ElementRef).nativeElement;
|
|
349
|
+
const presenter = inject(AXViewportGuardPresenter);
|
|
350
|
+
const platformId = inject(PLATFORM_ID);
|
|
351
|
+
const destroyRef = inject(DestroyRef);
|
|
352
|
+
const id = `${prefix}-${++nextGuardId}`;
|
|
353
|
+
if (!isPlatformBrowser(platformId)) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
afterNextRender(() => presenter.ensureListening());
|
|
357
|
+
effect(() => {
|
|
358
|
+
const request = active();
|
|
359
|
+
untracked(() => {
|
|
360
|
+
presenter.claim(id, request);
|
|
361
|
+
if (request) {
|
|
362
|
+
lockHost(host, id);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
unlockHost(host, id);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
destroyRef.onDestroy(() => {
|
|
370
|
+
presenter.claim(id, null);
|
|
371
|
+
unlockHost(host, id);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
function readViewport(win) {
|
|
375
|
+
const coarse = win.matchMedia('(pointer: coarse)').matches;
|
|
376
|
+
const shortSide = Math.min(win.screen.width, win.screen.height);
|
|
377
|
+
const dpr = win.devicePixelRatio || 1;
|
|
378
|
+
const cssShortSide = shortSide > PHONE_SHORT_SIDE && dpr > 1 && shortSide / dpr <= PHONE_SHORT_SIDE ? shortSide / dpr : shortSide;
|
|
379
|
+
return {
|
|
380
|
+
width: Math.round(win.innerWidth),
|
|
381
|
+
height: Math.round(win.innerHeight),
|
|
382
|
+
portrait: win.matchMedia('(orientation: portrait)').matches,
|
|
383
|
+
phone: coarse && cssShortSide <= PHONE_SHORT_SIDE,
|
|
384
|
+
ready: true,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function pickRequest(requests) {
|
|
388
|
+
let size = null;
|
|
389
|
+
let orientation = null;
|
|
390
|
+
for (const request of requests.values()) {
|
|
391
|
+
if (request.kind === 'size') {
|
|
392
|
+
const wider = size != null && request.minWidth > size.minWidth;
|
|
393
|
+
const taller = size != null && request.minWidth === size.minWidth && (request.minHeight ?? 0) > (size.minHeight ?? 0);
|
|
394
|
+
if (!size || wider || taller) {
|
|
395
|
+
size = request;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
orientation ??= request;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return size ?? orientation;
|
|
403
|
+
}
|
|
404
|
+
function sameRequest(left, right) {
|
|
405
|
+
if (left.kind !== right.kind || left.template !== right.template || !sameMessage(left.message, right.message)) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
if (left.kind === 'size' && right.kind === 'size') {
|
|
409
|
+
return left.minWidth === right.minWidth && left.minHeight === right.minHeight;
|
|
410
|
+
}
|
|
411
|
+
return left.kind === 'orientation' && right.kind === 'orientation' && left.orientation === right.orientation;
|
|
412
|
+
}
|
|
413
|
+
function sameMessage(left, right) {
|
|
414
|
+
return (left?.kicker === right?.kicker &&
|
|
415
|
+
left?.title === right?.title &&
|
|
416
|
+
left?.message === right?.message &&
|
|
417
|
+
left?.hint === right?.hint);
|
|
418
|
+
}
|
|
419
|
+
function isolate(value) {
|
|
420
|
+
return value ? `\u2066${value}\u2069` : '';
|
|
421
|
+
}
|
|
422
|
+
const hostLocks = new WeakMap();
|
|
423
|
+
function lockHost(element, token) {
|
|
424
|
+
let state = hostLocks.get(element);
|
|
425
|
+
if (!state) {
|
|
426
|
+
state = {
|
|
427
|
+
tokens: new Set(),
|
|
428
|
+
display: element.style.getPropertyValue('display'),
|
|
429
|
+
inert: element.hasAttribute('inert'),
|
|
430
|
+
ariaHidden: element.getAttribute('aria-hidden'),
|
|
431
|
+
};
|
|
432
|
+
hostLocks.set(element, state);
|
|
433
|
+
}
|
|
434
|
+
state.tokens.add(token);
|
|
435
|
+
element.style.setProperty('display', 'none', 'important');
|
|
436
|
+
element.setAttribute('inert', '');
|
|
437
|
+
element.setAttribute('aria-hidden', 'true');
|
|
438
|
+
}
|
|
439
|
+
function unlockHost(element, token) {
|
|
440
|
+
const state = hostLocks.get(element);
|
|
441
|
+
if (!state) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
state.tokens.delete(token);
|
|
445
|
+
if (state.tokens.size > 0) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
if (state.display) {
|
|
449
|
+
element.style.setProperty('display', state.display);
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
element.style.removeProperty('display');
|
|
453
|
+
}
|
|
454
|
+
if (state.inert) {
|
|
455
|
+
element.setAttribute('inert', '');
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
element.removeAttribute('inert');
|
|
459
|
+
}
|
|
460
|
+
if (state.ariaHidden == null) {
|
|
461
|
+
element.removeAttribute('aria-hidden');
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
element.setAttribute('aria-hidden', state.ariaHidden);
|
|
465
|
+
}
|
|
466
|
+
hostLocks.delete(element);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Types an `ng-template` whose `let-message` is the resolved guard copy.
|
|
471
|
+
*
|
|
472
|
+
* ```html
|
|
473
|
+
* <ng-template #warning axViewportGuardTemplate let-message>
|
|
474
|
+
* <h2>{{ message.title }}</h2>
|
|
475
|
+
* <p>{{ message.message }}</p>
|
|
476
|
+
* </ng-template>
|
|
477
|
+
*
|
|
478
|
+
* <div axMinViewport="1024" [template]="warning"></div>
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
class AXViewportGuardTemplateDirective {
|
|
482
|
+
constructor() {
|
|
483
|
+
this.template = inject((TemplateRef));
|
|
484
|
+
}
|
|
485
|
+
static ngTemplateContextGuard(_directive, _context) {
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXViewportGuardTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
489
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.6", type: AXViewportGuardTemplateDirective, isStandalone: true, selector: "ng-template[axViewportGuardTemplate]", ngImport: i0 }); }
|
|
490
|
+
}
|
|
491
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXViewportGuardTemplateDirective, decorators: [{
|
|
492
|
+
type: Directive,
|
|
493
|
+
args: [{
|
|
494
|
+
selector: 'ng-template[axViewportGuardTemplate]',
|
|
495
|
+
}]
|
|
496
|
+
}] });
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Hides the host when the viewport is smaller than the given size.
|
|
500
|
+
*
|
|
501
|
+
* ```html
|
|
502
|
+
* <div axMinViewport="1024" [minHeight]="640" [message]="copy" [template]="warning"></div>
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
class AXMinViewportDirective {
|
|
506
|
+
constructor() {
|
|
507
|
+
/** Minimum viewport width in CSS pixels. */
|
|
508
|
+
this.minWidth = input(0, { ...(ngDevMode ? { debugName: "minWidth" } : /* istanbul ignore next */ {}), alias: 'axMinViewport', transform: pxInput });
|
|
509
|
+
/** Minimum viewport height in CSS pixels. Omitted heights are ignored. */
|
|
510
|
+
this.minHeight = input(null, { ...(ngDevMode ? { debugName: "minHeight" } : /* istanbul ignore next */ {}), transform: optionalPxInput });
|
|
511
|
+
/** Replaces any part of the default translated warning. */
|
|
512
|
+
this.message = input(null, /* @ts-ignore */
|
|
513
|
+
...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
|
|
514
|
+
/** Custom warning. `let-message` receives the resolved copy. */
|
|
515
|
+
this.template = input(null, /* @ts-ignore */
|
|
516
|
+
...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
|
|
517
|
+
this.presenter = inject(AXViewportGuardPresenter);
|
|
518
|
+
this.projectedTemplate = contentChild(AXViewportGuardTemplateDirective, { ...(ngDevMode ? { debugName: "projectedTemplate" } : /* istanbul ignore next */ {}), descendants: true });
|
|
519
|
+
connectViewportGuard('size', () => this.request());
|
|
520
|
+
}
|
|
521
|
+
request() {
|
|
522
|
+
const message = this.message();
|
|
523
|
+
const template = this.template() ?? this.projectedTemplate()?.template ?? null;
|
|
524
|
+
const viewport = this.presenter.snapshot();
|
|
525
|
+
const minWidth = this.minWidth();
|
|
526
|
+
const minHeight = this.minHeight();
|
|
527
|
+
if (!viewport.ready) {
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
const blocked = (minWidth > 0 && viewport.width < minWidth) ||
|
|
531
|
+
(minHeight != null && minHeight > 0 && viewport.height < minHeight);
|
|
532
|
+
return blocked ? { kind: 'size', minWidth, minHeight, message, template } : null;
|
|
533
|
+
}
|
|
534
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXMinViewportDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
535
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "22.1.6", type: AXMinViewportDirective, isStandalone: true, selector: "[axMinViewport]", inputs: { minWidth: { classPropertyName: "minWidth", publicName: "axMinViewport", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "projectedTemplate", first: true, predicate: AXViewportGuardTemplateDirective, descendants: true, isSignal: true }], exportAs: ["axMinViewport"], ngImport: i0 }); }
|
|
536
|
+
}
|
|
537
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXMinViewportDirective, decorators: [{
|
|
538
|
+
type: Directive,
|
|
539
|
+
args: [{
|
|
540
|
+
selector: '[axMinViewport]',
|
|
541
|
+
exportAs: 'axMinViewport',
|
|
542
|
+
}]
|
|
543
|
+
}], ctorParameters: () => [], propDecorators: { minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "axMinViewport", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }], projectedTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => AXViewportGuardTemplateDirective), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
544
|
+
function pxInput(value) {
|
|
545
|
+
if (value == null || value === '') {
|
|
546
|
+
return 0;
|
|
547
|
+
}
|
|
548
|
+
const parsed = Number(value);
|
|
549
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
550
|
+
}
|
|
551
|
+
function optionalPxInput(value) {
|
|
552
|
+
if (value == null || value === '') {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
const parsed = Number(value);
|
|
556
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* On a phone, hides the host when the device is not in the required orientation.
|
|
561
|
+
*
|
|
562
|
+
* ```html
|
|
563
|
+
* <div axOrientationLock="landscape" [message]="copy" [template]="warning"></div>
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
class AXOrientationLockDirective {
|
|
567
|
+
constructor() {
|
|
568
|
+
/** Orientation that keeps the page visible. */
|
|
569
|
+
this.orientation = input.required({ ...(ngDevMode ? { debugName: "orientation" } : /* istanbul ignore next */ {}), alias: 'axOrientationLock' });
|
|
570
|
+
/**
|
|
571
|
+
* Limits the guard to phones. Set to false to apply it on every device.
|
|
572
|
+
*
|
|
573
|
+
* @defaultValue true
|
|
574
|
+
*/
|
|
575
|
+
this.phonesOnly = input(true, { ...(ngDevMode ? { debugName: "phonesOnly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
576
|
+
/** Replaces any part of the default translated warning. */
|
|
577
|
+
this.message = input(null, /* @ts-ignore */
|
|
578
|
+
...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
|
|
579
|
+
/** Custom warning. `let-message` receives the resolved copy. */
|
|
580
|
+
this.template = input(null, /* @ts-ignore */
|
|
581
|
+
...(ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []));
|
|
582
|
+
this.presenter = inject(AXViewportGuardPresenter);
|
|
583
|
+
this.projectedTemplate = contentChild(AXViewportGuardTemplateDirective, { ...(ngDevMode ? { debugName: "projectedTemplate" } : /* istanbul ignore next */ {}), descendants: true });
|
|
584
|
+
connectViewportGuard('orientation', () => this.request());
|
|
585
|
+
}
|
|
586
|
+
request() {
|
|
587
|
+
const orientation = this.orientation();
|
|
588
|
+
const message = this.message();
|
|
589
|
+
const template = this.template() ?? this.projectedTemplate()?.template ?? null;
|
|
590
|
+
const viewport = this.presenter.snapshot();
|
|
591
|
+
if ((orientation !== 'portrait' && orientation !== 'landscape') || !viewport.ready) {
|
|
592
|
+
return null;
|
|
593
|
+
}
|
|
594
|
+
if (this.phonesOnly() && !viewport.phone) {
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
const current = viewport.portrait ? 'portrait' : 'landscape';
|
|
598
|
+
return current === orientation ? null : { kind: 'orientation', orientation, message, template };
|
|
599
|
+
}
|
|
600
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXOrientationLockDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
601
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "22.1.6", type: AXOrientationLockDirective, isStandalone: true, selector: "[axOrientationLock]", inputs: { orientation: { classPropertyName: "orientation", publicName: "axOrientationLock", isSignal: true, isRequired: true, transformFunction: null }, phonesOnly: { classPropertyName: "phonesOnly", publicName: "phonesOnly", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "projectedTemplate", first: true, predicate: AXViewportGuardTemplateDirective, descendants: true, isSignal: true }], exportAs: ["axOrientationLock"], ngImport: i0 }); }
|
|
602
|
+
}
|
|
603
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: AXOrientationLockDirective, decorators: [{
|
|
604
|
+
type: Directive,
|
|
605
|
+
args: [{
|
|
606
|
+
selector: '[axOrientationLock]',
|
|
607
|
+
exportAs: 'axOrientationLock',
|
|
608
|
+
}]
|
|
609
|
+
}], ctorParameters: () => [], propDecorators: { orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "axOrientationLock", required: true }] }], phonesOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "phonesOnly", required: false }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }], projectedTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => AXViewportGuardTemplateDirective), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Generated bundle index. Do not edit.
|
|
613
|
+
*/
|
|
614
|
+
|
|
615
|
+
export { AXMinViewportDirective, AXOrientationLockDirective, AXViewportGuardTemplateDirective };
|
|
616
|
+
//# sourceMappingURL=acorex-cdk-viewport-guard.mjs.map
|