@haiilo/catalyst 0.7.4 → 0.8.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/dist/catalyst/catalyst.css +1 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js +1 -1
- package/dist/catalyst/p-2ad6f8d8.js +2 -0
- package/dist/catalyst/{p-7c06183a.js.map → p-2ad6f8d8.js.map} +1 -1
- package/dist/catalyst/p-3bbcb685.entry.js +12 -0
- package/dist/catalyst/p-3bbcb685.entry.js.map +1 -0
- package/dist/catalyst/p-659073b5.js +3 -0
- package/dist/catalyst/p-659073b5.js.map +1 -0
- package/dist/catalyst/{p-c7f3b231.js → p-6a8a4dc0.js} +2 -2
- package/dist/catalyst/{p-c7f3b231.js.map → p-6a8a4dc0.js.map} +0 -0
- package/dist/catalyst/{p-5616e2cd.js → p-6fce43dd.js} +2 -2
- package/dist/catalyst/{p-5616e2cd.js.map → p-6fce43dd.js.map} +0 -0
- package/dist/catalyst/{p-4254363e.entry.js → p-c0b4200d.entry.js} +2 -2
- package/dist/catalyst/{p-4254363e.entry.js.map → p-c0b4200d.entry.js.map} +0 -0
- package/dist/catalyst/{p-12486027.js → p-decdc6f1.js} +2 -2
- package/dist/catalyst/p-decdc6f1.js.map +1 -0
- package/dist/catalyst/p-f45bcfd6.js +2 -0
- package/dist/catalyst/p-f45bcfd6.js.map +1 -0
- package/dist/catalyst/scss/_mixins.scss +1 -1
- package/dist/catalyst/scss/_variables.scss +2 -0
- package/dist/catalyst/scss/fonts/{_fonts.mixins.scss → _fonts-mixins.scss} +0 -0
- package/dist/catalyst/scss/index.scss +4 -3
- package/dist/cjs/{app-globals-aa29ad72.js → app-globals-79765026.js} +3 -3
- package/dist/cjs/{app-globals-aa29ad72.js.map → app-globals-79765026.js.map} +1 -1
- package/dist/cjs/cat-alert_20.cjs.entry.js +12630 -0
- package/dist/cjs/cat-alert_20.cjs.entry.js.map +1 -0
- package/dist/cjs/{cat-form-hint-93a6936b.js → cat-form-hint-25fdfed5.js} +2 -2
- package/dist/cjs/{cat-form-hint-93a6936b.js.map → cat-form-hint-25fdfed5.js.map} +1 -1
- package/dist/cjs/{cat-icon-registry-49b11b51.js → cat-icon-registry-b015a65f.js} +37 -43
- package/dist/cjs/cat-icon-registry-b015a65f.js.map +1 -0
- package/dist/cjs/{cat-notification-156f4cf5.js → cat-notification-fe237312.js} +2 -2
- package/dist/cjs/{cat-notification-156f4cf5.js.map → cat-notification-fe237312.js.map} +1 -1
- package/dist/cjs/cat-textarea.cjs.entry.js +3 -3
- package/dist/cjs/catalyst.cjs.js +6 -6
- package/dist/cjs/catalyst.cjs.js.map +1 -1
- package/dist/cjs/{index-499bad41.js → index-936b777e.js} +10 -5
- package/dist/cjs/index-936b777e.js.map +1 -0
- package/dist/cjs/index.cjs.js +3 -3
- package/dist/cjs/loader.cjs.js +6 -6
- package/dist/cjs/loader.cjs.js.map +1 -1
- package/dist/cjs/{loglevel-c9b2d01f.js → loglevel-b5d158ad.js} +6 -1
- package/dist/cjs/loglevel-b5d158ad.js.map +1 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/cat-avatar/cat-avatar.js +2 -2
- package/dist/collection/components/cat-avatar/cat-avatar.js.map +1 -1
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js +35 -41
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.js +2 -2
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-modal/cat-modal.css +65 -0
- package/dist/collection/components/cat-modal/cat-modal.js +117 -0
- package/dist/collection/components/cat-modal/cat-modal.js.map +1 -0
- package/dist/collection/components/cat-select/cat-select.css +602 -0
- package/dist/collection/components/cat-select/cat-select.js +527 -0
- package/dist/collection/components/cat-select/cat-select.js.map +1 -0
- package/dist/collection/init.js +1 -1
- package/dist/collection/init.js.map +1 -1
- package/dist/collection/scss/_mixins.scss +1 -1
- package/dist/collection/scss/_variables.scss +2 -0
- package/dist/collection/scss/fonts/{_fonts.mixins.scss → _fonts-mixins.scss} +0 -0
- package/dist/collection/scss/index.scss +4 -3
- package/dist/components/cat-avatar.js +2 -2
- package/dist/components/cat-avatar.js.map +1 -1
- package/dist/components/cat-i18n-registry.js +35 -41
- package/dist/components/cat-i18n-registry.js.map +1 -1
- package/dist/components/cat-icon.js +1 -1
- package/dist/components/cat-icon2.js +56 -2
- package/dist/components/cat-icon2.js.map +1 -1
- package/dist/components/cat-input.js +2 -2
- package/dist/components/cat-input.js.map +1 -1
- package/dist/components/cat-menu.js +3 -742
- package/dist/components/cat-menu.js.map +1 -1
- package/dist/components/cat-modal.d.ts +11 -0
- package/dist/components/cat-modal.js +111 -0
- package/dist/components/cat-modal.js.map +1 -0
- package/dist/components/cat-select.d.ts +11 -0
- package/dist/components/cat-select.js +7788 -0
- package/dist/components/cat-select.js.map +1 -0
- package/dist/components/cat-toast-demo.js +549 -4
- package/dist/components/cat-toast-demo.js.map +1 -1
- package/dist/components/cat-tooltip.js +2 -1
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/first-tabbable.js +1 -1068
- package/dist/components/first-tabbable.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +1070 -0
- package/dist/components/floating-ui.dom.esm.js.map +1 -0
- package/dist/components/focus-trap.esm.js +746 -0
- package/dist/components/focus-trap.esm.js.map +1 -0
- package/dist/components/index.d.ts +21 -5
- package/dist/components/index.js +24 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/loglevel.js +5 -1
- package/dist/components/loglevel.js.map +1 -1
- package/dist/esm/{app-globals-cf55f7f5.js → app-globals-7d163b94.js} +3 -3
- package/dist/esm/{app-globals-cf55f7f5.js.map → app-globals-7d163b94.js.map} +1 -1
- package/dist/esm/cat-alert_20.entry.js +12607 -0
- package/dist/esm/cat-alert_20.entry.js.map +1 -0
- package/dist/esm/{cat-form-hint-dc443c7c.js → cat-form-hint-790d1e46.js} +2 -2
- package/dist/esm/{cat-form-hint-dc443c7c.js.map → cat-form-hint-790d1e46.js.map} +1 -1
- package/dist/esm/{cat-icon-registry-3ea75755.js → cat-icon-registry-dc1ef79a.js} +37 -43
- package/dist/esm/cat-icon-registry-dc1ef79a.js.map +1 -0
- package/dist/{components/cat-notification.js → esm/cat-notification-a9655c00.js} +2 -2
- package/dist/esm/{cat-notification-cd98c266.js.map → cat-notification-a9655c00.js.map} +1 -1
- package/dist/esm/cat-textarea.entry.js +3 -3
- package/dist/esm/catalyst.js +6 -6
- package/dist/esm/catalyst.js.map +1 -1
- package/dist/esm/{index-039e6f5f.js → index-41ceb7da.js} +10 -5
- package/dist/esm/index-41ceb7da.js.map +1 -0
- package/dist/esm/index.js +3 -3
- package/dist/esm/loader.js +6 -6
- package/dist/esm/loader.js.map +1 -1
- package/dist/esm/{loglevel-39a9e3f9.js → loglevel-c8b59c3a.js} +6 -2
- package/dist/{cjs/loglevel-c9b2d01f.js.map → esm/loglevel-c8b59c3a.js.map} +1 -1
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +9 -10
- package/dist/types/components/cat-modal/cat-modal.d.ts +20 -0
- package/dist/types/components/cat-select/cat-select.d.ts +84 -0
- package/dist/types/components.d.ts +184 -25
- package/package.json +11 -10
- package/dist/catalyst/p-12486027.js.map +0 -1
- package/dist/catalyst/p-12b96af6.js +0 -2
- package/dist/catalyst/p-12b96af6.js.map +0 -1
- package/dist/catalyst/p-2ec5c87a.js +0 -2
- package/dist/catalyst/p-2ec5c87a.js.map +0 -1
- package/dist/catalyst/p-7c06183a.js +0 -2
- package/dist/catalyst/p-dda85567.entry.js +0 -10
- package/dist/catalyst/p-dda85567.entry.js.map +0 -1
- package/dist/cjs/cat-alert_18.cjs.entry.js +0 -4831
- package/dist/cjs/cat-alert_18.cjs.entry.js.map +0 -1
- package/dist/cjs/cat-icon-registry-49b11b51.js.map +0 -1
- package/dist/cjs/index-499bad41.js.map +0 -1
- package/dist/components/cat-icon-registry.js +0 -59
- package/dist/components/cat-icon-registry.js.map +0 -1
- package/dist/components/cat-notification.js.map +0 -1
- package/dist/esm/cat-alert_18.entry.js +0 -4810
- package/dist/esm/cat-alert_18.entry.js.map +0 -1
- package/dist/esm/cat-icon-registry-3ea75755.js.map +0 -1
- package/dist/esm/cat-notification-cd98c266.js +0 -550
- package/dist/esm/index-039e6f5f.js.map +0 -1
- package/dist/esm/loglevel-39a9e3f9.js.map +0 -1
|
@@ -1,4810 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, c as createEvent, g as getElement } from './index-039e6f5f.js';
|
|
2
|
-
import { l as loglevel } from './loglevel-39a9e3f9.js';
|
|
3
|
-
import { C as CatFormHint } from './cat-form-hint-dc443c7c.js';
|
|
4
|
-
import { C as CatIconRegistry, a as CatI18nRegistry } from './cat-icon-registry-3ea75755.js';
|
|
5
|
-
import { N as NotificationsService } from './cat-notification-cd98c266.js';
|
|
6
|
-
|
|
7
|
-
const catAlertCss = ":host{display:block;margin-bottom:1rem}:host(:focus-visible){outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}:host([hidden]){display:none}.alert{font:inherit;color:rgb(var(--text));background-color:rgba(var(--bg), 0.1);box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);border-radius:0.25rem;padding:0.75rem 1rem}::slotted(:last-child){margin-bottom:0 !important}.alert-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.alert-secondary{--bg:105, 118, 135;--text:0, 0, 0;--border:105, 118, 135}.alert-success{--bg:0, 132, 88;--text:0, 132, 88;--border:0, 132, 88}.alert-warning{--bg:255, 206, 128;--text:159, 97, 0;--border:159, 97, 0}.alert-danger{--bg:217, 52, 13;--text:217, 52, 13;--border:217, 52, 13}";
|
|
8
|
-
|
|
9
|
-
const CatAlert = class {
|
|
10
|
-
constructor(hostRef) {
|
|
11
|
-
registerInstance(this, hostRef);
|
|
12
|
-
/**
|
|
13
|
-
* The color palette of the alert.
|
|
14
|
-
*/
|
|
15
|
-
this.color = 'primary';
|
|
16
|
-
}
|
|
17
|
-
render() {
|
|
18
|
-
return (h(Host, { tabindex: "0", role: this.role }, h("div", { part: "alert", class: {
|
|
19
|
-
alert: true,
|
|
20
|
-
[`alert-${this.color}`]: Boolean(this.color)
|
|
21
|
-
} }, h("slot", null))));
|
|
22
|
-
}
|
|
23
|
-
get role() {
|
|
24
|
-
switch (this.color) {
|
|
25
|
-
case 'danger':
|
|
26
|
-
case 'warning':
|
|
27
|
-
return 'alert';
|
|
28
|
-
default:
|
|
29
|
-
return 'status';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
CatAlert.style = catAlertCss;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Loads an image and wraps the result in a promise.
|
|
37
|
-
*
|
|
38
|
-
* @param src the image URL
|
|
39
|
-
* @returns a promise
|
|
40
|
-
*/
|
|
41
|
-
const loadImg = (src) => {
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
const image = new Image();
|
|
44
|
-
image.addEventListener('load', resolve);
|
|
45
|
-
image.addEventListener('error', reject);
|
|
46
|
-
image.src = src;
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const catAvatarCss = ":host{display:inline-block;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([hidden]){display:none}.avatar{display:flex;align-items:center;justify-content:center;border-radius:0.25rem;text-decoration:inherit;color:var(--cat-avatar-fill, white);background-color:var(--cat-avatar-bg, #697687);background-size:cover;background-position:center;white-space:nowrap;overflow:hidden}.avatar:focus-visible{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.avatar-round{border-radius:50%}.avatar-xs{width:var(--cat-avatar-size, 1.5rem);height:var(--cat-avatar-size, 1.5rem);line-height:var(--cat-avatar-size, 1.5rem);font-size:var(--cat-avatar-font-size, 0.75rem)}.avatar-s{width:var(--cat-avatar-size, 2rem);height:var(--cat-avatar-size, 2rem);line-height:var(--cat-avatar-size, 2rem);font-size:var(--cat-avatar-font-size, 0.875rem)}.avatar-m{width:var(--cat-avatar-size, 2.5rem);height:var(--cat-avatar-size, 2.5rem);line-height:var(--cat-avatar-size, 2.5rem);font-size:var(--cat-avatar-font-size, 0.9375rem)}.avatar-l{width:var(--cat-avatar-size, 3rem);height:var(--cat-avatar-size, 3rem);line-height:var(--cat-avatar-size, 3rem);font-size:var(--cat-avatar-font-size, 1.125rem)}.avatar-xl{width:var(--cat-avatar-size, 3.5rem);height:var(--cat-avatar-size, 3.5rem);line-height:var(--cat-avatar-size, 3.5rem);font-size:var(--cat-avatar-font-size, 1.25rem)}";
|
|
51
|
-
|
|
52
|
-
const CatAvatar = class {
|
|
53
|
-
constructor(hostRef) {
|
|
54
|
-
registerInstance(this, hostRef);
|
|
55
|
-
/**
|
|
56
|
-
* The size of the avatar.
|
|
57
|
-
*/
|
|
58
|
-
this.size = 'm';
|
|
59
|
-
/**
|
|
60
|
-
* Use round avatar edges.
|
|
61
|
-
*/
|
|
62
|
-
this.round = false;
|
|
63
|
-
/**
|
|
64
|
-
* The label of the avatar.
|
|
65
|
-
*/
|
|
66
|
-
this.label = '';
|
|
67
|
-
}
|
|
68
|
-
onSrcChanged(value) {
|
|
69
|
-
if (value) {
|
|
70
|
-
loadImg(value).then(() => (this.backgroundImage = `url(${value})`), () => (this.backgroundImage = undefined));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
this.backgroundImage = undefined;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
componentWillLoad() {
|
|
77
|
-
this.onSrcChanged(this.src);
|
|
78
|
-
}
|
|
79
|
-
componentWillRender() {
|
|
80
|
-
if (!this.label) {
|
|
81
|
-
loglevel.warn('[A11y] Missing ARIA label on avatar', this);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
render() {
|
|
85
|
-
if (this.url) {
|
|
86
|
-
return (h("a", { href: this.url, target: this.urlTarget, style: this.cssStyle, class: this.cssClass, "aria-label": this.label }, this.content));
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
return (h("span", { style: this.cssStyle, class: this.cssClass, "aria-label": this.label }, this.content));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
get content() {
|
|
93
|
-
return !this.backgroundImage
|
|
94
|
-
? [this.icon ? h("cat-icon", { icon: this.icon, size: this.size }) : this.getInitials()]
|
|
95
|
-
: [];
|
|
96
|
-
}
|
|
97
|
-
get cssStyle() {
|
|
98
|
-
return { 'background-image': this.backgroundImage };
|
|
99
|
-
}
|
|
100
|
-
get cssClass() {
|
|
101
|
-
return {
|
|
102
|
-
avatar: true,
|
|
103
|
-
'avatar-round': this.round,
|
|
104
|
-
[`avatar-${this.size}`]: Boolean(this.size)
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
getInitials() {
|
|
108
|
-
var _a;
|
|
109
|
-
return ((_a = this.initials) !== null && _a !== void 0 ? _a : this.label
|
|
110
|
-
.split(' ')
|
|
111
|
-
.map(n => n[0])
|
|
112
|
-
.join(''));
|
|
113
|
-
}
|
|
114
|
-
static get watchers() { return {
|
|
115
|
-
"src": ["onSrcChanged"]
|
|
116
|
-
}; }
|
|
117
|
-
};
|
|
118
|
-
CatAvatar.style = catAvatarCss;
|
|
119
|
-
|
|
120
|
-
const catBadgeCss = ":host{display:inline-flex;max-width:100%;vertical-align:baseline}:host([hidden]){display:none}.badge{font:inherit;flex:1 1 auto;display:inline-flex;align-items:center;justify-content:center;border-radius:0.125rem;text-decoration:none;width:100%;box-sizing:border-box;line-height:1;white-space:nowrap}.badge slot{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.badge-round{border-radius:10rem}.badge-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.badge-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);color:rgb(var(--text))}.badge-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.badge-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--border:105, 118, 135}.badge-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--border:0, 132, 88}.badge-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--border:159, 97, 0}.badge-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--border:217, 52, 13}.badge-xs{height:0.75rem;min-width:0.75rem;font-size:0.75rem;padding:0rem 0.25rem}.badge-s{height:1rem;min-width:1rem;font-size:0.75rem;padding:0.25rem 0.5rem}.badge-m{height:1.25rem;min-width:1.25rem;font-size:0.75rem;padding:0.5rem 0.75rem}.badge-l{height:1.5rem;min-width:1.5rem;font-size:0.875rem;padding:0.75rem 1rem}.badge-xl{height:1.75rem;min-width:1.75rem;font-size:0.9375rem;padding:1rem 1.25rem}.badge-pulse.badge-filled{animation:1.5s ease 0s infinite normal none running pulse}.badge-pulse.badge-outlined{animation:1.5s ease 0s infinite normal none running pulse-outlined}@keyframes pulse{0%{box-shadow:0 0 0 0 rgb(var(--bg))}70%{box-shadow:transparent 0 0 0 0.5rem}100%{box-shadow:transparent 0 0 0 0}}@keyframes pulse-outlined{0%{box-shadow:0 0 0 0 rgb(var(--bg)), inset 0 0 0 1px rgba(var(--border), 0.2)}70%{box-shadow:transparent 0 0 0 0.5rem, inset 0 0 0 1px rgba(var(--border), 0.2)}100%{box-shadow:transparent 0 0 0 0, inset 0 0 0 1px rgba(var(--border), 0.2)}}";
|
|
121
|
-
|
|
122
|
-
const CatBadge = class {
|
|
123
|
-
constructor(hostRef) {
|
|
124
|
-
registerInstance(this, hostRef);
|
|
125
|
-
/**
|
|
126
|
-
* The rendering style of the badge.
|
|
127
|
-
*/
|
|
128
|
-
this.variant = 'filled';
|
|
129
|
-
/**
|
|
130
|
-
* The color palette of the badge.
|
|
131
|
-
*/
|
|
132
|
-
this.color = 'primary';
|
|
133
|
-
/**
|
|
134
|
-
* The size of the badge.
|
|
135
|
-
*/
|
|
136
|
-
this.size = 'm';
|
|
137
|
-
/**
|
|
138
|
-
* Use round badge edges.
|
|
139
|
-
*/
|
|
140
|
-
this.round = false;
|
|
141
|
-
/**
|
|
142
|
-
* Draw attention to the badge with a subtle animation.
|
|
143
|
-
*/
|
|
144
|
-
this.pulse = false;
|
|
145
|
-
}
|
|
146
|
-
render() {
|
|
147
|
-
return (h("span", { part: "badge", class: {
|
|
148
|
-
badge: true,
|
|
149
|
-
'badge-round': this.round,
|
|
150
|
-
'badge-pulse': this.pulse,
|
|
151
|
-
[`badge-${this.variant}`]: Boolean(this.variant),
|
|
152
|
-
[`badge-${this.color}`]: Boolean(this.color),
|
|
153
|
-
[`badge-${this.size}`]: Boolean(this.size)
|
|
154
|
-
} }, h("slot", null)));
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
CatBadge.style = catBadgeCss;
|
|
158
|
-
|
|
159
|
-
const _breakpoints = ['xs', 's', 'm', 'l', 'xl'];
|
|
160
|
-
const Breakpoints = {
|
|
161
|
-
xs: '(max-width: 539.98px)',
|
|
162
|
-
s: '(max-width: 767.98px)',
|
|
163
|
-
m: '(max-width: 991.98px)',
|
|
164
|
-
l: '(max-width: 1199.98px)',
|
|
165
|
-
xl: '(max-width: 1399.98px)'
|
|
166
|
-
};
|
|
167
|
-
function isBreakpoint(value) {
|
|
168
|
-
return typeof value === 'string' && _breakpoints.includes(value);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// https://github.com/angular/components/blob/master/src/cdk/platform/platform.ts
|
|
172
|
-
// Whether the current platform supports the V8 Break Iterator. The V8 check
|
|
173
|
-
// is necessary to detect all Blink based browsers.
|
|
174
|
-
let hasV8BreakIterator;
|
|
175
|
-
// We need a try/catch around the reference to `Intl`, because accessing it in some cases can
|
|
176
|
-
// cause IE to throw. These cases are tied to particular versions of Windows and can happen if
|
|
177
|
-
// the consumer is providing a polyfilled `Map`. See:
|
|
178
|
-
// https://github.com/Microsoft/ChakraCore/issues/3189
|
|
179
|
-
// https://github.com/angular/components/issues/15687
|
|
180
|
-
try {
|
|
181
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
|
-
hasV8BreakIterator = typeof Intl !== 'undefined' && Intl.v8BreakIterator;
|
|
183
|
-
}
|
|
184
|
-
catch (_a) {
|
|
185
|
-
hasV8BreakIterator = false;
|
|
186
|
-
}
|
|
187
|
-
class Platform {
|
|
188
|
-
constructor() {
|
|
189
|
-
/** Whether the current browser is Microsoft Edge. */
|
|
190
|
-
this.EDGE = /(edge)/i.test(navigator.userAgent);
|
|
191
|
-
/** Whether the current rendering engine is Microsoft Trident. */
|
|
192
|
-
this.TRIDENT = /(msie|trident)/i.test(navigator.userAgent);
|
|
193
|
-
// EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.
|
|
194
|
-
/** Whether the current rendering engine is Blink. */
|
|
195
|
-
this.BLINK =
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
197
|
-
!!(window.chrome || hasV8BreakIterator) && typeof CSS !== 'undefined' && !this.EDGE && !this.TRIDENT;
|
|
198
|
-
// Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to
|
|
199
|
-
// ensure that Webkit runs standalone and is not used as another engine's base.
|
|
200
|
-
/** Whether the current rendering engine is WebKit. */
|
|
201
|
-
this.WEBKIT = /AppleWebKit/i.test(navigator.userAgent) && !this.BLINK && !this.EDGE && !this.TRIDENT;
|
|
202
|
-
/** Whether the current platform is Apple iOS. */
|
|
203
|
-
this.IOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window);
|
|
204
|
-
// It's difficult to detect the plain Gecko engine, because most of the browsers identify
|
|
205
|
-
// them self as Gecko-like browsers and modify the userAgent's according to that.
|
|
206
|
-
// Since we only cover one explicit Firefox case, we can simply check for Firefox
|
|
207
|
-
// instead of having an unstable check for Gecko.
|
|
208
|
-
/** Whether the current browser is Firefox. */
|
|
209
|
-
this.FIREFOX = /(firefox|minefield)/i.test(navigator.userAgent);
|
|
210
|
-
/** Whether the current platform is Android. */
|
|
211
|
-
// Trident on mobile adds the android platform to the userAgent to trick detections.
|
|
212
|
-
this.ANDROID = /android/i.test(navigator.userAgent) && !this.TRIDENT;
|
|
213
|
-
// Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake
|
|
214
|
-
// this and just place the Safari keyword in the userAgent. To be more safe about Safari every
|
|
215
|
-
// Safari browser should also use Webkit as its layout engine.
|
|
216
|
-
/** Whether the current browser is Safari. */
|
|
217
|
-
this.SAFARI = /safari/i.test(navigator.userAgent) && this.WEBKIT;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// https://github.com/angular/components/blob/master/src/cdk/layout/media-matcher.ts
|
|
222
|
-
/** Global registry for all dynamically-created, injected media queries. */
|
|
223
|
-
const mediaQueriesForWebkitCompatibility = new Set();
|
|
224
|
-
/** Style tag that holds all of the dynamically-created media queries. */
|
|
225
|
-
let mediaQueryStyleNode;
|
|
226
|
-
/** A utility for calling matchMedia queries. */
|
|
227
|
-
class MediaMatcher {
|
|
228
|
-
constructor() {
|
|
229
|
-
this._platform = new Platform();
|
|
230
|
-
this._matchMedia = window.matchMedia.bind(window);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Evaluates the given media query and returns the native MediaQueryList from which results
|
|
234
|
-
* can be retrieved.
|
|
235
|
-
* Confirms the layout engine will trigger for the selector query provided and returns the
|
|
236
|
-
* MediaQueryList for the query provided.
|
|
237
|
-
*/
|
|
238
|
-
matchMedia(query) {
|
|
239
|
-
if (this._platform.WEBKIT || this._platform.BLINK) {
|
|
240
|
-
createEmptyStyleRule(query);
|
|
241
|
-
}
|
|
242
|
-
return this._matchMedia(query);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Creates an empty stylesheet that is used to work around browser inconsistencies related to
|
|
247
|
-
* `matchMedia`. At the time of writing, it handles the following cases:
|
|
248
|
-
* 1. On WebKit browsers, a media query has to have at least one rule in order for `matchMedia`
|
|
249
|
-
* to fire. We work around it by declaring a dummy stylesheet with a `@media` declaration.
|
|
250
|
-
* 2. In some cases Blink browsers will stop firing the `matchMedia` listener if none of the rules
|
|
251
|
-
* inside the `@media` match existing elements on the page. We work around it by having one rule
|
|
252
|
-
* targeting the `body`. See https://github.com/angular/components/issues/23546.
|
|
253
|
-
*/
|
|
254
|
-
function createEmptyStyleRule(query) {
|
|
255
|
-
if (mediaQueriesForWebkitCompatibility.has(query)) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
try {
|
|
259
|
-
if (!mediaQueryStyleNode) {
|
|
260
|
-
mediaQueryStyleNode = document.createElement('style');
|
|
261
|
-
mediaQueryStyleNode.setAttribute('type', 'text/css');
|
|
262
|
-
document.head.appendChild(mediaQueryStyleNode);
|
|
263
|
-
}
|
|
264
|
-
if (mediaQueryStyleNode.sheet) {
|
|
265
|
-
mediaQueryStyleNode.sheet.insertRule(`@media ${query} {body{ }}`, 0);
|
|
266
|
-
mediaQueriesForWebkitCompatibility.add(query);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
catch (e) {
|
|
270
|
-
loglevel.error(e);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const catButtonCss = ":host{display:inline-block;max-width:100%;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([hidden]){display:none}.cat-button{position:relative;font:inherit;display:flex;align-items:center;justify-content:center;border:none;border-radius:0.25rem;text-decoration:none;width:100%;box-sizing:border-box;cursor:pointer;transition:color 0.13s linear, border-color 0.13s linear, background-color 0.13s linear, box-shadow 0.13s linear}.cat-button:focus-visible{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.cat-button-ellipsed .cat-button-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cat-button-disabled{cursor:not-allowed;opacity:0.65;filter:grayscale(100%)}.cat-button-round{border-radius:10rem}.cat-button-loading{cursor:default}.cat-button-loading cat-spinner{position:absolute}.cat-button-loading>*:not(cat-spinner){visibility:hidden}.cat-button-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.cat-button-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--base), 0.2);color:rgb(var(--text))}.cat-button-outlined:hover:not(.cat-button-disabled):not(.cat-button-loading){background-color:rgba(var(--base), 0.05)}.cat-button-outlined:active:not(.cat-button-disabled):not(.cat-button-loading){background-color:rgba(var(--base), 0.1)}.cat-button-text{background-color:transparent;color:rgb(var(--text));text-decoration:none}.cat-button-text:hover:not(.cat-button-disabled):not(.cat-button-loading){text-decoration:underline}.cat-button-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--base:var(--cat-primary-text, 32, 127, 138)}.cat-button-primary:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:var(--cat-primary-bg-hover, 28, 112, 122);--fill:var(--cat-primary-fill-hover, 255, 255, 255);--text:var(--cat-primary-text-hover, 28, 112, 122)}.cat-button-primary:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:var(--cat-primary-bg-active, 25, 101, 110);--fill:var(--cat-primary-fill-active, 255, 255, 255);--text:var(--cat-primary-text-active, 25, 101, 110)}.cat-button-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--base:105, 118, 135}.cat-button-secondary:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0}.cat-button-secondary:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0}.cat-button-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--base:0, 132, 88}.cat-button-success:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:0, 117, 78;--fill:255, 255, 255;--text:0, 117, 78}.cat-button-success:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:0, 105, 70;--fill:255, 255, 255;--text:0, 105, 70}.cat-button-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--base:159, 97, 0}.cat-button-warning:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:255, 214, 148;--fill:0, 0, 0;--text:159, 97, 0}.cat-button-warning:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:255, 222, 168;--fill:0, 0, 0;--text:159, 97, 0}.cat-button-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--base:217, 52, 13}.cat-button-danger:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:194, 46, 11;--fill:255, 255, 255;--text:194, 46, 11}.cat-button-danger:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:174, 42, 10;--fill:255, 255, 255;--text:174, 42, 10}.cat-button-xs{min-width:1.5rem;padding:0.25rem 0.25rem;font-size:0.875rem;line-height:1rem}.cat-button-xs .cat-button-prefix{margin-right:0.25rem}.cat-button-xs .cat-button-suffix{margin-left:0.25rem}.cat-button-xs.cat-button-icon{width:1.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-xs{padding-left:1rem;padding-right:1rem}.cat-button-s{min-width:2rem;padding:0.375rem 0.5rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-s .cat-button-prefix{margin-right:0.25rem}.cat-button-s .cat-button-suffix{margin-left:0.25rem}.cat-button-s cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-s.cat-button-icon{width:2rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-s{padding-left:1rem;padding-right:1rem}.cat-button-m{min-width:2.5rem;padding:0.625rem 0.75rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-m .cat-button-prefix{margin-right:0.25rem}.cat-button-m .cat-button-suffix{margin-left:0.25rem}.cat-button-m cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-m.cat-button-icon{width:2.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-m{padding-left:1rem;padding-right:1rem}.cat-button-l{min-width:3rem;padding:0.875rem 1rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-l .cat-button-prefix{margin-right:0.25rem}.cat-button-l .cat-button-suffix{margin-left:0.25rem}.cat-button-l cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-l.cat-button-icon{width:3rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-l{padding-left:1rem;padding-right:1rem}.cat-button-xl{min-width:3.5rem;padding:1rem 1.25rem;font-size:1.125rem;line-height:1.5rem}.cat-button-xl .cat-button-prefix{margin-right:0.25rem}.cat-button-xl .cat-button-suffix{margin-left:0.25rem}.cat-button-xl.cat-button-icon{width:3.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-xl{padding-left:1rem;padding-right:1rem}.cat-button-active::before{content:\"\";display:block;position:absolute;top:0;left:0;width:0.25rem;height:100%;background:rgb(var(--base))}:host-context(nav){width:100%}:host-context(nav) .cat-button{box-shadow:none;border-radius:0;justify-content:left}:host-context(nav) .cat-button:focus-visible{outline-offset:-2px}:host(.cat-text-left) .cat-button{justify-content:left}:host(.cat-text-right) .cat-button{justify-content:right}";
|
|
275
|
-
|
|
276
|
-
const CatButton = class {
|
|
277
|
-
constructor(hostRef) {
|
|
278
|
-
registerInstance(this, hostRef);
|
|
279
|
-
this.catClick = createEvent(this, "catClick", 7);
|
|
280
|
-
this.catFocus = createEvent(this, "catFocus", 7);
|
|
281
|
-
this.catBlur = createEvent(this, "catBlur", 7);
|
|
282
|
-
this._iconOnly = true;
|
|
283
|
-
/**
|
|
284
|
-
* The rendering style of the button.
|
|
285
|
-
*/
|
|
286
|
-
this.variant = 'outlined';
|
|
287
|
-
/**
|
|
288
|
-
* The color palette of the button.
|
|
289
|
-
*/
|
|
290
|
-
this.color = 'secondary';
|
|
291
|
-
/**
|
|
292
|
-
* Show an active status indicator on the left side of the button.
|
|
293
|
-
*/
|
|
294
|
-
this.active = false;
|
|
295
|
-
/**
|
|
296
|
-
* The size of the button.
|
|
297
|
-
*/
|
|
298
|
-
this.size = 'm';
|
|
299
|
-
/**
|
|
300
|
-
* Specifies that the button should be disabled. A disabled button is unusable
|
|
301
|
-
* and un-clickable. Corresponds with the native HTML disabled attribute.
|
|
302
|
-
*/
|
|
303
|
-
this.disabled = false;
|
|
304
|
-
/**
|
|
305
|
-
* Displays the button in a loading state with a spinner. Just like a disabled
|
|
306
|
-
* button, an inactive button is unusable and un-clickable. However, it
|
|
307
|
-
* retains the current focus state.
|
|
308
|
-
*/
|
|
309
|
-
this.loading = false;
|
|
310
|
-
/**
|
|
311
|
-
* Allows the button to submit a form.
|
|
312
|
-
*/
|
|
313
|
-
this.submit = false;
|
|
314
|
-
/**
|
|
315
|
-
* Disables ellipse overflowing button content.
|
|
316
|
-
*/
|
|
317
|
-
this.noEllipsis = false;
|
|
318
|
-
/**
|
|
319
|
-
* Use round button edges.
|
|
320
|
-
*/
|
|
321
|
-
this.round = false;
|
|
322
|
-
/**
|
|
323
|
-
* Hide the actual button content and only display the icon.
|
|
324
|
-
*/
|
|
325
|
-
this.iconOnly = false;
|
|
326
|
-
/**
|
|
327
|
-
* Display the icon on the right.
|
|
328
|
-
*/
|
|
329
|
-
this.iconRight = false;
|
|
330
|
-
}
|
|
331
|
-
onIconOnlyChanged(value) {
|
|
332
|
-
var _a, _b;
|
|
333
|
-
// teardown
|
|
334
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
335
|
-
(_a = this.mediaQueryList) === null || _a === void 0 ? void 0 : _a.removeEventListener('change', this.mediaQueryListener);
|
|
336
|
-
this.mediaQueryList = undefined;
|
|
337
|
-
this.mediaQueryListener = undefined;
|
|
338
|
-
// setup
|
|
339
|
-
if (isBreakpoint(value)) {
|
|
340
|
-
(_b = this.mediaMatcher) !== null && _b !== void 0 ? _b : (this.mediaMatcher = new MediaMatcher());
|
|
341
|
-
this.mediaQueryList = this.mediaMatcher.matchMedia(Breakpoints[value]);
|
|
342
|
-
this.mediaQueryListener = (event) => (this._iconOnly = event.matches);
|
|
343
|
-
this.mediaQueryList.addEventListener('change', this.mediaQueryListener);
|
|
344
|
-
this._iconOnly = this.mediaQueryList.matches;
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
this._iconOnly = value;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
componentWillLoad() {
|
|
351
|
-
this.onIconOnlyChanged(this.iconOnly);
|
|
352
|
-
}
|
|
353
|
-
componentWillRender() {
|
|
354
|
-
if (this.isIconButton && !this.a11yLabel) {
|
|
355
|
-
loglevel.warn('[A11y] Missing ARIA label on icon button', this);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
haltDisabledEvents(event) {
|
|
359
|
-
if (this.disabled || this.loading) {
|
|
360
|
-
event.preventDefault();
|
|
361
|
-
event.stopImmediatePropagation();
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Sets focus on the button. Use this method instead of `button.focus()`.
|
|
366
|
-
*
|
|
367
|
-
* @param options An optional object providing options to control aspects of
|
|
368
|
-
* the focusing process.
|
|
369
|
-
*/
|
|
370
|
-
async setFocus(options) {
|
|
371
|
-
this.button.focus(options);
|
|
372
|
-
}
|
|
373
|
-
render() {
|
|
374
|
-
var _a;
|
|
375
|
-
if (this.url) {
|
|
376
|
-
return (h("a", { ref: el => (this.button = el), href: this.disabled ? undefined : this.url, target: this.urlTarget, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
|
|
377
|
-
'cat-button': true,
|
|
378
|
-
'cat-button-icon': this.isIconButton,
|
|
379
|
-
'cat-button-round': this.round,
|
|
380
|
-
'cat-button-loading': this.loading,
|
|
381
|
-
'cat-button-disabled': this.disabled,
|
|
382
|
-
'cat-button-ellipsed': !this.noEllipsis && !this.isIconButton,
|
|
383
|
-
[`cat-button-${this.variant}`]: Boolean(this.variant),
|
|
384
|
-
[`cat-button-${this.color}`]: Boolean(this.color),
|
|
385
|
-
[`cat-button-${this.size}`]: Boolean(this.size)
|
|
386
|
-
}, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
return (h("button", { ref: el => (this.button = el), type: this.submit ? 'submit' : 'button', name: this.name, value: this.value, disabled: this.disabled, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
|
|
390
|
-
'cat-button': true,
|
|
391
|
-
'cat-button-active': this.active,
|
|
392
|
-
'cat-button-icon': this.isIconButton,
|
|
393
|
-
'cat-button-round': (_a = this.round) !== null && _a !== void 0 ? _a : this.isIconButton,
|
|
394
|
-
'cat-button-loading': this.loading,
|
|
395
|
-
'cat-button-disabled': this.disabled,
|
|
396
|
-
'cat-button-ellipsed': !this.noEllipsis && !this.isIconButton,
|
|
397
|
-
[`cat-button-${this.variant}`]: Boolean(this.variant),
|
|
398
|
-
[`cat-button-${this.color}`]: Boolean(this.color),
|
|
399
|
-
[`cat-button-${this.size}`]: Boolean(this.size)
|
|
400
|
-
}, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
get iconSize() {
|
|
404
|
-
switch (this.size) {
|
|
405
|
-
case 'xs':
|
|
406
|
-
return 's';
|
|
407
|
-
default:
|
|
408
|
-
return 'l';
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
get spinnerSize() {
|
|
412
|
-
switch (this.size) {
|
|
413
|
-
case 'xs':
|
|
414
|
-
return 'xs';
|
|
415
|
-
default:
|
|
416
|
-
return 'm';
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
get isIconButton() {
|
|
420
|
-
return Boolean(this.icon) && this._iconOnly;
|
|
421
|
-
}
|
|
422
|
-
get hasPrefixIcon() {
|
|
423
|
-
return Boolean(this.icon) && !this._iconOnly && !this.iconRight;
|
|
424
|
-
}
|
|
425
|
-
get hasSuffixIcon() {
|
|
426
|
-
return Boolean(this.icon) && !this._iconOnly && this.iconRight;
|
|
427
|
-
}
|
|
428
|
-
get content() {
|
|
429
|
-
return [
|
|
430
|
-
this.hasPrefixIcon ? (h("cat-icon", { icon: this.icon, size: this.iconSize, class: "cat-button-prefix", part: "prefix" })) : null,
|
|
431
|
-
this.isIconButton ? (h("cat-icon", { icon: this.icon, size: this.iconSize })) : (h("span", { class: "cat-button-content", part: "content" }, h("slot", null))),
|
|
432
|
-
this.hasSuffixIcon ? (h("cat-icon", { icon: this.icon, size: this.iconSize, class: "cat-button-suffix", part: "suffix" })) : null,
|
|
433
|
-
this.loading ? h("cat-spinner", { size: this.spinnerSize }) : null
|
|
434
|
-
];
|
|
435
|
-
}
|
|
436
|
-
onClick(event) {
|
|
437
|
-
this.catClick.emit(event);
|
|
438
|
-
}
|
|
439
|
-
onFocus(event) {
|
|
440
|
-
this.catFocus.emit(event);
|
|
441
|
-
}
|
|
442
|
-
onBlur(event) {
|
|
443
|
-
this.catBlur.emit(event);
|
|
444
|
-
}
|
|
445
|
-
static get watchers() { return {
|
|
446
|
-
"iconOnly": ["onIconOnlyChanged"]
|
|
447
|
-
}; }
|
|
448
|
-
};
|
|
449
|
-
CatButton.style = catButtonCss;
|
|
450
|
-
|
|
451
|
-
const catCardCss = ":host{display:block;margin-bottom:1rem;border-radius:0.5rem;background-color:white;padding:1.5rem}:host([hidden]){display:none}::slotted(nav){margin:-1rem -1.5rem !important}::slotted(:last-child){margin-bottom:0}";
|
|
452
|
-
|
|
453
|
-
const CatCard = class {
|
|
454
|
-
constructor(hostRef) {
|
|
455
|
-
registerInstance(this, hostRef);
|
|
456
|
-
}
|
|
457
|
-
render() {
|
|
458
|
-
return (h(Host, null, h("slot", null)));
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
CatCard.style = catCardCss;
|
|
462
|
-
|
|
463
|
-
const catCheckboxCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;margin:0}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{flex:0 1 auto;display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}input{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.box{flex:0 0 auto;display:flex;position:relative;height:1.25rem;width:1.25rem;background-color:white;border:1px solid #d7dbe0;border-radius:0.125rem;transition:background-color 0.13s ease, border-color 0.13s ease}.box svg{fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:16px;stroke-dashoffset:16px;transition:all 0.13s ease;width:70%;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%) scale(0.99)}:checked+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:checked+.box .check{stroke-dashoffset:0}:indeterminate+.box{background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-color:rgb(var(--cat-primary-bg, 32, 127, 138));stroke:rgb(var(--cat-primary-fill, 255, 255, 255))}:indeterminate+.box .dash{stroke-dashoffset:0}:focus-visible+.box{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.label{flex:1 1 auto}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
|
|
464
|
-
|
|
465
|
-
let nextUniqueId$6 = 0;
|
|
466
|
-
const CatCheckbox = class {
|
|
467
|
-
constructor(hostRef) {
|
|
468
|
-
registerInstance(this, hostRef);
|
|
469
|
-
this.catChange = createEvent(this, "catChange", 7);
|
|
470
|
-
this.catFocus = createEvent(this, "catFocus", 7);
|
|
471
|
-
this.catBlur = createEvent(this, "catBlur", 7);
|
|
472
|
-
this.id = `cat-checkbox-${nextUniqueId$6++}`;
|
|
473
|
-
this.hasSlottedLabel = false;
|
|
474
|
-
/**
|
|
475
|
-
* Checked state of the checkbox
|
|
476
|
-
*/
|
|
477
|
-
this.checked = false;
|
|
478
|
-
/**
|
|
479
|
-
* Disabled state of the checkbox
|
|
480
|
-
*/
|
|
481
|
-
this.disabled = false;
|
|
482
|
-
/**
|
|
483
|
-
* Indeterminate state of the checkbox
|
|
484
|
-
*/
|
|
485
|
-
this.indeterminate = false;
|
|
486
|
-
/**
|
|
487
|
-
* Label of the checkbox which is presented in the UI
|
|
488
|
-
*/
|
|
489
|
-
this.label = '';
|
|
490
|
-
/**
|
|
491
|
-
* Visually hide the label, but still show it to assistive technologies like screen readers.
|
|
492
|
-
*/
|
|
493
|
-
this.labelHidden = false;
|
|
494
|
-
/**
|
|
495
|
-
* Required state of the checkbox
|
|
496
|
-
*/
|
|
497
|
-
this.required = false;
|
|
498
|
-
}
|
|
499
|
-
componentDidLoad() {
|
|
500
|
-
if (this.input && this.indeterminate) {
|
|
501
|
-
this.input.indeterminate = true;
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
componentWillRender() {
|
|
505
|
-
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
506
|
-
if (!this.label && !this.hasSlottedLabel) {
|
|
507
|
-
loglevel.error('[A11y] Missing ARIA label on checkbox', this);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Sets focus on the checkbox. Use this method instead of `checkbox.focus()`.
|
|
512
|
-
*
|
|
513
|
-
* @param options An optional object providing options to control aspects of
|
|
514
|
-
* the focusing process.
|
|
515
|
-
*/
|
|
516
|
-
async setFocus(options) {
|
|
517
|
-
this.input.focus(options);
|
|
518
|
-
}
|
|
519
|
-
render() {
|
|
520
|
-
return (h(Host, null, h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } }, h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), h("span", { class: "box", "aria-hidden": "true", part: "checkbox" }, h("svg", { class: "check", viewBox: "0 0 12 10" }, h("polyline", { points: "1.5 6 4.5 9 10.5 1" })), h("svg", { class: "dash", viewBox: "0 0 12 10" }, h("polyline", { points: "1.5 5 10.5 5" }))), h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)), this.hintSection));
|
|
521
|
-
}
|
|
522
|
-
get hintSection() {
|
|
523
|
-
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
524
|
-
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
525
|
-
}
|
|
526
|
-
onInput(event) {
|
|
527
|
-
this.value = this.input.value;
|
|
528
|
-
this.catChange.emit(event);
|
|
529
|
-
}
|
|
530
|
-
onFocus(event) {
|
|
531
|
-
this.catFocus.emit(event);
|
|
532
|
-
}
|
|
533
|
-
onBlur(event) {
|
|
534
|
-
this.catBlur.emit(event);
|
|
535
|
-
}
|
|
536
|
-
get hostElement() { return getElement(this); }
|
|
537
|
-
};
|
|
538
|
-
CatCheckbox.style = catCheckboxCss;
|
|
539
|
-
|
|
540
|
-
const catIconCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([hidden]){display:none}span{display:inline-flex}svg{fill:currentColor;stroke:none;transform-origin:center center;height:1em;width:calc(var(--cat-icon-ratio, 1) * 1em)}.icon-xs svg{font-size:0.75rem}.icon-s svg{font-size:1rem}.icon-m svg{font-size:1.25rem}.icon-l svg{font-size:1.5rem}.icon-xl svg{font-size:1.75rem}";
|
|
541
|
-
|
|
542
|
-
const CatIcon = class {
|
|
543
|
-
constructor(hostRef) {
|
|
544
|
-
registerInstance(this, hostRef);
|
|
545
|
-
this.iconRegistry = CatIconRegistry.getInstance();
|
|
546
|
-
/**
|
|
547
|
-
* The name of the icon.
|
|
548
|
-
*/
|
|
549
|
-
this.icon = '';
|
|
550
|
-
/**
|
|
551
|
-
* The size of the icon.
|
|
552
|
-
*/
|
|
553
|
-
this.size = 'm';
|
|
554
|
-
}
|
|
555
|
-
render() {
|
|
556
|
-
return (h("span", { innerHTML: this.iconRegistry.getIcon(this.icon), "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', part: "icon", class: {
|
|
557
|
-
icon: true,
|
|
558
|
-
[`icon-${this.size}`]: this.size !== 'inline'
|
|
559
|
-
} }));
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
CatIcon.style = catIconCss;
|
|
563
|
-
|
|
564
|
-
const catInputCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;margin:0}:host{display:flex;flex-direction:column;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;margin-bottom:1rem}:host([hidden]){display:none}.input-wrapper{display:flex;align-items:stretch;gap:0.75rem;padding:0 0.75rem;height:2.5rem;overflow:hidden;background:white;border-radius:0.25rem;box-shadow:0 0 0 1px #d7dbe0;transition:box-shadow 0.13s linear}.input-wrapper.input-round{border-radius:10rem}.input-wrapper.input-disabled{background:#f8f8fb;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.input-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px #d7dbe0}.input-wrapper:not(.input-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.text-prefix,.text-suffix{display:inline-flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.text-prefix{border-right:1px solid #d7dbe0;padding-right:0.75rem}.text-suffix{border-left:1px solid #d7dbe0;padding-left:0.75rem}.icon-prefix,.icon-suffix{align-self:center}.input-inner-wrapper{display:flex;position:relative;flex:1 1 auto}input{font:inherit;margin:0;padding:0;width:100%;min-width:0;border:none;outline:none;background:none}.input-disabled input{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}input.has-clearable{padding-right:1.5rem}input::placeholder{color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.clearable{position:absolute;top:calc(50% - 1rem);right:-0.5rem}";
|
|
565
|
-
|
|
566
|
-
let nextUniqueId$5 = 0;
|
|
567
|
-
const CatInput = class {
|
|
568
|
-
constructor(hostRef) {
|
|
569
|
-
registerInstance(this, hostRef);
|
|
570
|
-
this.catChange = createEvent(this, "catChange", 7);
|
|
571
|
-
this.catFocus = createEvent(this, "catFocus", 7);
|
|
572
|
-
this.catBlur = createEvent(this, "catBlur", 7);
|
|
573
|
-
this.i18n = CatI18nRegistry.getInstance();
|
|
574
|
-
this.id = `cat-input-${nextUniqueId$5++}`;
|
|
575
|
-
this.hasSlottedLabel = false;
|
|
576
|
-
/**
|
|
577
|
-
* Whether the input should show a clear button.
|
|
578
|
-
*/
|
|
579
|
-
this.clearable = false;
|
|
580
|
-
/**
|
|
581
|
-
* Whether the input is disabled.
|
|
582
|
-
*/
|
|
583
|
-
this.disabled = false;
|
|
584
|
-
/**
|
|
585
|
-
* Display the icon on the right.
|
|
586
|
-
*/
|
|
587
|
-
this.iconRight = false;
|
|
588
|
-
/**
|
|
589
|
-
* The label for the input.
|
|
590
|
-
*/
|
|
591
|
-
this.label = '';
|
|
592
|
-
/**
|
|
593
|
-
* Visually hide the label, but still show it to assistive technologies like screen readers.
|
|
594
|
-
*/
|
|
595
|
-
this.labelHidden = false;
|
|
596
|
-
/**
|
|
597
|
-
* The name of the form control. Submitted with the form as part of a name/value pair.
|
|
598
|
-
*/
|
|
599
|
-
this.name = '';
|
|
600
|
-
/**
|
|
601
|
-
* The value is not editable.
|
|
602
|
-
*/
|
|
603
|
-
this.readonly = false;
|
|
604
|
-
/**
|
|
605
|
-
* A value is required or must be check for the form to be submittable.
|
|
606
|
-
*/
|
|
607
|
-
this.required = false;
|
|
608
|
-
/**
|
|
609
|
-
* Use round input edges.
|
|
610
|
-
*/
|
|
611
|
-
this.round = false;
|
|
612
|
-
/**
|
|
613
|
-
* Type of form control.
|
|
614
|
-
*/
|
|
615
|
-
this.type = 'text';
|
|
616
|
-
}
|
|
617
|
-
componentWillRender() {
|
|
618
|
-
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
619
|
-
if (!this.label && !this.hasSlottedLabel) {
|
|
620
|
-
loglevel.error('[A11y] Missing ARIA label on input', this);
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
/**
|
|
624
|
-
* Sets focus on the input. Use this method instead of `input.focus()`.
|
|
625
|
-
*
|
|
626
|
-
* @param options An optional object providing options to control aspects of
|
|
627
|
-
* the focusing process.
|
|
628
|
-
*/
|
|
629
|
-
async setFocus(options) {
|
|
630
|
-
this.input.focus(options);
|
|
631
|
-
}
|
|
632
|
-
/**
|
|
633
|
-
* Clear the input.
|
|
634
|
-
*/
|
|
635
|
-
async clear() {
|
|
636
|
-
this.value = '';
|
|
637
|
-
}
|
|
638
|
-
render() {
|
|
639
|
-
return (h(Host, null, (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, class: { hidden: this.labelHidden } }, h("span", { part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label, !this.required && (h("span", { class: "input-optional", "aria-hidden": "true" }, "(", this.i18n.getMessage('input.optional'), ")"))))), h("div", { class: {
|
|
640
|
-
'input-wrapper': true,
|
|
641
|
-
'input-round': this.round,
|
|
642
|
-
'input-disabled': this.disabled
|
|
643
|
-
}, onClick: () => this.input.focus() }, this.textPrefix && (h("span", { class: "text-prefix", part: "prefix" }, this.textPrefix)), this.icon && !this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-prefix", size: "l" }), h("div", { class: "input-inner-wrapper" }, h("input", { ref: el => (this.input = el), id: this.id, class: {
|
|
644
|
-
'has-clearable': this.clearable && !this.disabled
|
|
645
|
-
}, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.max, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, type: this.type, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), this.clearable && !this.disabled && this.value && (h("cat-button", { class: "clearable", icon: "cross-circle-outlined", "icon-only": "true", size: "s", variant: "text", "a11y-label": this.i18n.getMessage('input.clear'), onClick: this.clear.bind(this) }))), this.icon && this.iconRight && h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l" }), this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))), this.hintSection));
|
|
646
|
-
}
|
|
647
|
-
get hintSection() {
|
|
648
|
-
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
649
|
-
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
650
|
-
}
|
|
651
|
-
onInput(event) {
|
|
652
|
-
this.value = this.input.value;
|
|
653
|
-
this.catChange.emit(event);
|
|
654
|
-
}
|
|
655
|
-
onFocus(event) {
|
|
656
|
-
this.catFocus.emit(event);
|
|
657
|
-
}
|
|
658
|
-
onBlur(event) {
|
|
659
|
-
this.catBlur.emit(event);
|
|
660
|
-
}
|
|
661
|
-
get hostElement() { return getElement(this); }
|
|
662
|
-
};
|
|
663
|
-
CatInput.style = catInputCss;
|
|
664
|
-
|
|
665
|
-
function getSide(placement) {
|
|
666
|
-
return placement.split('-')[0];
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
function getAlignment(placement) {
|
|
670
|
-
return placement.split('-')[1];
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
function getMainAxisFromPlacement(placement) {
|
|
674
|
-
return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
function getLengthFromAxis(axis) {
|
|
678
|
-
return axis === 'y' ? 'height' : 'width';
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
682
|
-
let {
|
|
683
|
-
reference,
|
|
684
|
-
floating
|
|
685
|
-
} = _ref;
|
|
686
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
687
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
688
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
689
|
-
const length = getLengthFromAxis(mainAxis);
|
|
690
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
691
|
-
const side = getSide(placement);
|
|
692
|
-
const isVertical = mainAxis === 'x';
|
|
693
|
-
let coords;
|
|
694
|
-
|
|
695
|
-
switch (side) {
|
|
696
|
-
case 'top':
|
|
697
|
-
coords = {
|
|
698
|
-
x: commonX,
|
|
699
|
-
y: reference.y - floating.height
|
|
700
|
-
};
|
|
701
|
-
break;
|
|
702
|
-
|
|
703
|
-
case 'bottom':
|
|
704
|
-
coords = {
|
|
705
|
-
x: commonX,
|
|
706
|
-
y: reference.y + reference.height
|
|
707
|
-
};
|
|
708
|
-
break;
|
|
709
|
-
|
|
710
|
-
case 'right':
|
|
711
|
-
coords = {
|
|
712
|
-
x: reference.x + reference.width,
|
|
713
|
-
y: commonY
|
|
714
|
-
};
|
|
715
|
-
break;
|
|
716
|
-
|
|
717
|
-
case 'left':
|
|
718
|
-
coords = {
|
|
719
|
-
x: reference.x - floating.width,
|
|
720
|
-
y: commonY
|
|
721
|
-
};
|
|
722
|
-
break;
|
|
723
|
-
|
|
724
|
-
default:
|
|
725
|
-
coords = {
|
|
726
|
-
x: reference.x,
|
|
727
|
-
y: reference.y
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
switch (getAlignment(placement)) {
|
|
732
|
-
case 'start':
|
|
733
|
-
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
734
|
-
break;
|
|
735
|
-
|
|
736
|
-
case 'end':
|
|
737
|
-
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
738
|
-
break;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
return coords;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
746
|
-
* next to a reference element when it is given a certain positioning strategy.
|
|
747
|
-
*
|
|
748
|
-
* This export does not have any `platform` interface logic. You will need to
|
|
749
|
-
* write one for the platform you are using Floating UI with.
|
|
750
|
-
*/
|
|
751
|
-
|
|
752
|
-
const computePosition$1 = async (reference, floating, config) => {
|
|
753
|
-
const {
|
|
754
|
-
placement = 'bottom',
|
|
755
|
-
strategy = 'absolute',
|
|
756
|
-
middleware = [],
|
|
757
|
-
platform
|
|
758
|
-
} = config;
|
|
759
|
-
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
760
|
-
|
|
761
|
-
let rects = await platform.getElementRects({
|
|
762
|
-
reference,
|
|
763
|
-
floating,
|
|
764
|
-
strategy
|
|
765
|
-
});
|
|
766
|
-
let {
|
|
767
|
-
x,
|
|
768
|
-
y
|
|
769
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
770
|
-
let statefulPlacement = placement;
|
|
771
|
-
let middlewareData = {};
|
|
772
|
-
|
|
773
|
-
for (let i = 0; i < middleware.length; i++) {
|
|
774
|
-
|
|
775
|
-
const {
|
|
776
|
-
name,
|
|
777
|
-
fn
|
|
778
|
-
} = middleware[i];
|
|
779
|
-
const {
|
|
780
|
-
x: nextX,
|
|
781
|
-
y: nextY,
|
|
782
|
-
data,
|
|
783
|
-
reset
|
|
784
|
-
} = await fn({
|
|
785
|
-
x,
|
|
786
|
-
y,
|
|
787
|
-
initialPlacement: placement,
|
|
788
|
-
placement: statefulPlacement,
|
|
789
|
-
strategy,
|
|
790
|
-
middlewareData,
|
|
791
|
-
rects,
|
|
792
|
-
platform,
|
|
793
|
-
elements: {
|
|
794
|
-
reference,
|
|
795
|
-
floating
|
|
796
|
-
}
|
|
797
|
-
});
|
|
798
|
-
x = nextX != null ? nextX : x;
|
|
799
|
-
y = nextY != null ? nextY : y;
|
|
800
|
-
middlewareData = { ...middlewareData,
|
|
801
|
-
[name]: { ...middlewareData[name],
|
|
802
|
-
...data
|
|
803
|
-
}
|
|
804
|
-
};
|
|
805
|
-
|
|
806
|
-
if (reset) {
|
|
807
|
-
if (typeof reset === 'object') {
|
|
808
|
-
if (reset.placement) {
|
|
809
|
-
statefulPlacement = reset.placement;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
if (reset.rects) {
|
|
813
|
-
rects = reset.rects === true ? await platform.getElementRects({
|
|
814
|
-
reference,
|
|
815
|
-
floating,
|
|
816
|
-
strategy
|
|
817
|
-
}) : reset.rects;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
({
|
|
821
|
-
x,
|
|
822
|
-
y
|
|
823
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
i = -1;
|
|
827
|
-
continue;
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
return {
|
|
832
|
-
x,
|
|
833
|
-
y,
|
|
834
|
-
placement: statefulPlacement,
|
|
835
|
-
strategy,
|
|
836
|
-
middlewareData
|
|
837
|
-
};
|
|
838
|
-
};
|
|
839
|
-
|
|
840
|
-
function expandPaddingObject(padding) {
|
|
841
|
-
return {
|
|
842
|
-
top: 0,
|
|
843
|
-
right: 0,
|
|
844
|
-
bottom: 0,
|
|
845
|
-
left: 0,
|
|
846
|
-
...padding
|
|
847
|
-
};
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
function getSideObjectFromPadding(padding) {
|
|
851
|
-
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
852
|
-
top: padding,
|
|
853
|
-
right: padding,
|
|
854
|
-
bottom: padding,
|
|
855
|
-
left: padding
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
function rectToClientRect(rect) {
|
|
860
|
-
return { ...rect,
|
|
861
|
-
top: rect.y,
|
|
862
|
-
left: rect.x,
|
|
863
|
-
right: rect.x + rect.width,
|
|
864
|
-
bottom: rect.y + rect.height
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* Resolves with an object of overflow side offsets that determine how much the
|
|
870
|
-
* element is overflowing a given clipping boundary.
|
|
871
|
-
* - positive = overflowing the boundary by that number of pixels
|
|
872
|
-
* - negative = how many pixels left before it will overflow
|
|
873
|
-
* - 0 = lies flush with the boundary
|
|
874
|
-
* @see https://floating-ui.com/docs/detectOverflow
|
|
875
|
-
*/
|
|
876
|
-
async function detectOverflow(middlewareArguments, options) {
|
|
877
|
-
var _await$platform$isEle;
|
|
878
|
-
|
|
879
|
-
if (options === void 0) {
|
|
880
|
-
options = {};
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
const {
|
|
884
|
-
x,
|
|
885
|
-
y,
|
|
886
|
-
platform,
|
|
887
|
-
rects,
|
|
888
|
-
elements,
|
|
889
|
-
strategy
|
|
890
|
-
} = middlewareArguments;
|
|
891
|
-
const {
|
|
892
|
-
boundary = 'clippingAncestors',
|
|
893
|
-
rootBoundary = 'viewport',
|
|
894
|
-
elementContext = 'floating',
|
|
895
|
-
altBoundary = false,
|
|
896
|
-
padding = 0
|
|
897
|
-
} = options;
|
|
898
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
899
|
-
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
900
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
901
|
-
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
902
|
-
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
903
|
-
boundary,
|
|
904
|
-
rootBoundary,
|
|
905
|
-
strategy
|
|
906
|
-
}));
|
|
907
|
-
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
908
|
-
rect: elementContext === 'floating' ? { ...rects.floating,
|
|
909
|
-
x,
|
|
910
|
-
y
|
|
911
|
-
} : rects.reference,
|
|
912
|
-
offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
|
|
913
|
-
strategy
|
|
914
|
-
}) : rects[elementContext]); // positive = overflowing the clipping rect
|
|
915
|
-
// 0 or negative = within the clipping rect
|
|
916
|
-
|
|
917
|
-
return {
|
|
918
|
-
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
919
|
-
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
920
|
-
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
921
|
-
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
const hash$1 = {
|
|
926
|
-
left: 'right',
|
|
927
|
-
right: 'left',
|
|
928
|
-
bottom: 'top',
|
|
929
|
-
top: 'bottom'
|
|
930
|
-
};
|
|
931
|
-
function getOppositePlacement(placement) {
|
|
932
|
-
return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
936
|
-
if (rtl === void 0) {
|
|
937
|
-
rtl = false;
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
const alignment = getAlignment(placement);
|
|
941
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
942
|
-
const length = getLengthFromAxis(mainAxis);
|
|
943
|
-
let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
944
|
-
|
|
945
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
946
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
return {
|
|
950
|
-
main: mainAlignmentSide,
|
|
951
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
const hash = {
|
|
956
|
-
start: 'end',
|
|
957
|
-
end: 'start'
|
|
958
|
-
};
|
|
959
|
-
function getOppositeAlignmentPlacement(placement) {
|
|
960
|
-
return placement.replace(/start|end/g, matched => hash[matched]);
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
function getExpandedPlacements(placement) {
|
|
964
|
-
const oppositePlacement = getOppositePlacement(placement);
|
|
965
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
/**
|
|
969
|
-
* Changes the placement of the floating element to one that will fit if the
|
|
970
|
-
* initially specified `placement` does not.
|
|
971
|
-
* @see https://floating-ui.com/docs/flip
|
|
972
|
-
*/
|
|
973
|
-
const flip = function (options) {
|
|
974
|
-
if (options === void 0) {
|
|
975
|
-
options = {};
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
return {
|
|
979
|
-
name: 'flip',
|
|
980
|
-
options,
|
|
981
|
-
|
|
982
|
-
async fn(middlewareArguments) {
|
|
983
|
-
var _middlewareData$flip;
|
|
984
|
-
|
|
985
|
-
const {
|
|
986
|
-
placement,
|
|
987
|
-
middlewareData,
|
|
988
|
-
rects,
|
|
989
|
-
initialPlacement,
|
|
990
|
-
platform,
|
|
991
|
-
elements
|
|
992
|
-
} = middlewareArguments;
|
|
993
|
-
const {
|
|
994
|
-
mainAxis: checkMainAxis = true,
|
|
995
|
-
crossAxis: checkCrossAxis = true,
|
|
996
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
997
|
-
fallbackStrategy = 'bestFit',
|
|
998
|
-
flipAlignment = true,
|
|
999
|
-
...detectOverflowOptions
|
|
1000
|
-
} = options;
|
|
1001
|
-
const side = getSide(placement);
|
|
1002
|
-
const isBasePlacement = side === initialPlacement;
|
|
1003
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1004
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1005
|
-
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
1006
|
-
const overflows = [];
|
|
1007
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1008
|
-
|
|
1009
|
-
if (checkMainAxis) {
|
|
1010
|
-
overflows.push(overflow[side]);
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
if (checkCrossAxis) {
|
|
1014
|
-
const {
|
|
1015
|
-
main,
|
|
1016
|
-
cross
|
|
1017
|
-
} = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
1018
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
overflowsData = [...overflowsData, {
|
|
1022
|
-
placement,
|
|
1023
|
-
overflows
|
|
1024
|
-
}]; // One or more sides is overflowing
|
|
1025
|
-
|
|
1026
|
-
if (!overflows.every(side => side <= 0)) {
|
|
1027
|
-
var _middlewareData$flip$, _middlewareData$flip2;
|
|
1028
|
-
|
|
1029
|
-
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
|
|
1030
|
-
const nextPlacement = placements[nextIndex];
|
|
1031
|
-
|
|
1032
|
-
if (nextPlacement) {
|
|
1033
|
-
// Try next placement and re-run the lifecycle
|
|
1034
|
-
return {
|
|
1035
|
-
data: {
|
|
1036
|
-
index: nextIndex,
|
|
1037
|
-
overflows: overflowsData
|
|
1038
|
-
},
|
|
1039
|
-
reset: {
|
|
1040
|
-
placement: nextPlacement
|
|
1041
|
-
}
|
|
1042
|
-
};
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
let resetPlacement = 'bottom';
|
|
1046
|
-
|
|
1047
|
-
switch (fallbackStrategy) {
|
|
1048
|
-
case 'bestFit':
|
|
1049
|
-
{
|
|
1050
|
-
var _overflowsData$map$so;
|
|
1051
|
-
|
|
1052
|
-
const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
|
|
1053
|
-
|
|
1054
|
-
if (placement) {
|
|
1055
|
-
resetPlacement = placement;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
break;
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
case 'initialPlacement':
|
|
1062
|
-
resetPlacement = initialPlacement;
|
|
1063
|
-
break;
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
if (placement !== resetPlacement) {
|
|
1067
|
-
return {
|
|
1068
|
-
reset: {
|
|
1069
|
-
placement: resetPlacement
|
|
1070
|
-
}
|
|
1071
|
-
};
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
return {};
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
};
|
|
1079
|
-
};
|
|
1080
|
-
|
|
1081
|
-
function convertValueToCoords(placement, rects, value, rtl) {
|
|
1082
|
-
if (rtl === void 0) {
|
|
1083
|
-
rtl = false;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
const side = getSide(placement);
|
|
1087
|
-
const alignment = getAlignment(placement);
|
|
1088
|
-
const isVertical = getMainAxisFromPlacement(placement) === 'x';
|
|
1089
|
-
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
|
|
1090
|
-
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1091
|
-
const rawValue = typeof value === 'function' ? value({ ...rects,
|
|
1092
|
-
placement
|
|
1093
|
-
}) : value; // eslint-disable-next-line prefer-const
|
|
1094
|
-
|
|
1095
|
-
let {
|
|
1096
|
-
mainAxis,
|
|
1097
|
-
crossAxis,
|
|
1098
|
-
alignmentAxis
|
|
1099
|
-
} = typeof rawValue === 'number' ? {
|
|
1100
|
-
mainAxis: rawValue,
|
|
1101
|
-
crossAxis: 0,
|
|
1102
|
-
alignmentAxis: null
|
|
1103
|
-
} : {
|
|
1104
|
-
mainAxis: 0,
|
|
1105
|
-
crossAxis: 0,
|
|
1106
|
-
alignmentAxis: null,
|
|
1107
|
-
...rawValue
|
|
1108
|
-
};
|
|
1109
|
-
|
|
1110
|
-
if (alignment && typeof alignmentAxis === 'number') {
|
|
1111
|
-
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
return isVertical ? {
|
|
1115
|
-
x: crossAxis * crossAxisMulti,
|
|
1116
|
-
y: mainAxis * mainAxisMulti
|
|
1117
|
-
} : {
|
|
1118
|
-
x: mainAxis * mainAxisMulti,
|
|
1119
|
-
y: crossAxis * crossAxisMulti
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
/**
|
|
1123
|
-
* Displaces the floating element from its reference element.
|
|
1124
|
-
* @see https://floating-ui.com/docs/offset
|
|
1125
|
-
*/
|
|
1126
|
-
|
|
1127
|
-
const offset = function (value) {
|
|
1128
|
-
if (value === void 0) {
|
|
1129
|
-
value = 0;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
return {
|
|
1133
|
-
name: 'offset',
|
|
1134
|
-
options: value,
|
|
1135
|
-
|
|
1136
|
-
async fn(middlewareArguments) {
|
|
1137
|
-
const {
|
|
1138
|
-
x,
|
|
1139
|
-
y,
|
|
1140
|
-
placement,
|
|
1141
|
-
rects,
|
|
1142
|
-
platform,
|
|
1143
|
-
elements
|
|
1144
|
-
} = middlewareArguments;
|
|
1145
|
-
const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
|
|
1146
|
-
return {
|
|
1147
|
-
x: x + diffCoords.x,
|
|
1148
|
-
y: y + diffCoords.y,
|
|
1149
|
-
data: diffCoords
|
|
1150
|
-
};
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
};
|
|
1154
|
-
};
|
|
1155
|
-
|
|
1156
|
-
function isWindow(value) {
|
|
1157
|
-
return (value == null ? void 0 : value.toString()) === '[object Window]';
|
|
1158
|
-
}
|
|
1159
|
-
function getWindow(node) {
|
|
1160
|
-
if (node == null) {
|
|
1161
|
-
return window;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
if (!isWindow(node)) {
|
|
1165
|
-
const ownerDocument = node.ownerDocument;
|
|
1166
|
-
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
return node;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
function getComputedStyle$1(element) {
|
|
1173
|
-
return getWindow(element).getComputedStyle(element);
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
function getNodeName(node) {
|
|
1177
|
-
return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
function isHTMLElement(value) {
|
|
1181
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
1182
|
-
}
|
|
1183
|
-
function isElement(value) {
|
|
1184
|
-
return value instanceof getWindow(value).Element;
|
|
1185
|
-
}
|
|
1186
|
-
function isNode(value) {
|
|
1187
|
-
return value instanceof getWindow(value).Node;
|
|
1188
|
-
}
|
|
1189
|
-
function isShadowRoot(node) {
|
|
1190
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
1191
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
1192
|
-
}
|
|
1193
|
-
function isOverflowElement(element) {
|
|
1194
|
-
// Firefox wants us to check `-x` and `-y` variations as well
|
|
1195
|
-
const {
|
|
1196
|
-
overflow,
|
|
1197
|
-
overflowX,
|
|
1198
|
-
overflowY
|
|
1199
|
-
} = getComputedStyle$1(element);
|
|
1200
|
-
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
1201
|
-
}
|
|
1202
|
-
function isTableElement(element) {
|
|
1203
|
-
return ['table', 'td', 'th'].includes(getNodeName(element));
|
|
1204
|
-
}
|
|
1205
|
-
function isContainingBlock(element) {
|
|
1206
|
-
// TODO: Try and use feature detection here instead
|
|
1207
|
-
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
|
|
1208
|
-
const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
|
|
1209
|
-
// create a containing block.
|
|
1210
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1211
|
-
|
|
1212
|
-
return css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
|
|
1213
|
-
}
|
|
1214
|
-
function isLayoutViewport() {
|
|
1215
|
-
// Not Safari
|
|
1216
|
-
return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent); // Feature detection for this fails in various ways
|
|
1217
|
-
// • Always-visible scrollbar or not
|
|
1218
|
-
// • Width of <html>, etc.
|
|
1219
|
-
// const vV = win.visualViewport;
|
|
1220
|
-
// return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
const min = Math.min;
|
|
1224
|
-
const max = Math.max;
|
|
1225
|
-
const round = Math.round;
|
|
1226
|
-
|
|
1227
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
1228
|
-
if (includeScale === void 0) {
|
|
1229
|
-
includeScale = false;
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
if (isFixedStrategy === void 0) {
|
|
1233
|
-
isFixedStrategy = false;
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
const clientRect = element.getBoundingClientRect();
|
|
1237
|
-
let scaleX = 1;
|
|
1238
|
-
let scaleY = 1;
|
|
1239
|
-
|
|
1240
|
-
if (includeScale && isHTMLElement(element)) {
|
|
1241
|
-
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
1242
|
-
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
const win = isElement(element) ? getWindow(element) : window;
|
|
1246
|
-
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
1247
|
-
const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
|
|
1248
|
-
const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
|
|
1249
|
-
const width = clientRect.width / scaleX;
|
|
1250
|
-
const height = clientRect.height / scaleY;
|
|
1251
|
-
return {
|
|
1252
|
-
width,
|
|
1253
|
-
height,
|
|
1254
|
-
top: y,
|
|
1255
|
-
right: x + width,
|
|
1256
|
-
bottom: y + height,
|
|
1257
|
-
left: x,
|
|
1258
|
-
x,
|
|
1259
|
-
y
|
|
1260
|
-
};
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
function getDocumentElement(node) {
|
|
1264
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
function getNodeScroll(element) {
|
|
1268
|
-
if (isWindow(element)) {
|
|
1269
|
-
return {
|
|
1270
|
-
scrollLeft: element.pageXOffset,
|
|
1271
|
-
scrollTop: element.pageYOffset
|
|
1272
|
-
};
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
return {
|
|
1276
|
-
scrollLeft: element.scrollLeft,
|
|
1277
|
-
scrollTop: element.scrollTop
|
|
1278
|
-
};
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
function getWindowScrollBarX(element) {
|
|
1282
|
-
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1283
|
-
// incorrect for RTL.
|
|
1284
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
function isScaled(element) {
|
|
1288
|
-
const rect = getBoundingClientRect(element);
|
|
1289
|
-
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1293
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1294
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1295
|
-
const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
|
|
1296
|
-
let scroll = {
|
|
1297
|
-
scrollLeft: 0,
|
|
1298
|
-
scrollTop: 0
|
|
1299
|
-
};
|
|
1300
|
-
const offsets = {
|
|
1301
|
-
x: 0,
|
|
1302
|
-
y: 0
|
|
1303
|
-
};
|
|
1304
|
-
|
|
1305
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1306
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1307
|
-
scroll = getNodeScroll(offsetParent);
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
if (isHTMLElement(offsetParent)) {
|
|
1311
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1312
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1313
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1314
|
-
} else if (documentElement) {
|
|
1315
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
return {
|
|
1320
|
-
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1321
|
-
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1322
|
-
width: rect.width,
|
|
1323
|
-
height: rect.height
|
|
1324
|
-
};
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
function getParentNode(node) {
|
|
1328
|
-
if (getNodeName(node) === 'html') {
|
|
1329
|
-
return node;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
1333
|
-
// @ts-ignore
|
|
1334
|
-
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
1335
|
-
node.parentNode || ( // DOM Element detected
|
|
1336
|
-
isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
|
|
1337
|
-
getDocumentElement(node) // fallback
|
|
1338
|
-
|
|
1339
|
-
);
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
function getTrueOffsetParent(element) {
|
|
1343
|
-
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
|
1344
|
-
return null;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
return element.offsetParent;
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
function getContainingBlock(element) {
|
|
1351
|
-
let currentNode = getParentNode(element);
|
|
1352
|
-
|
|
1353
|
-
if (isShadowRoot(currentNode)) {
|
|
1354
|
-
currentNode = currentNode.host;
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
|
|
1358
|
-
if (isContainingBlock(currentNode)) {
|
|
1359
|
-
return currentNode;
|
|
1360
|
-
} else {
|
|
1361
|
-
currentNode = currentNode.parentNode;
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
return null;
|
|
1366
|
-
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1367
|
-
// such as table ancestors and cross browser bugs.
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
function getOffsetParent(element) {
|
|
1371
|
-
const window = getWindow(element);
|
|
1372
|
-
let offsetParent = getTrueOffsetParent(element);
|
|
1373
|
-
|
|
1374
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
1375
|
-
offsetParent = getTrueOffsetParent(offsetParent);
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
|
1379
|
-
return window;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
return offsetParent || getContainingBlock(element) || window;
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
function getDimensions(element) {
|
|
1386
|
-
if (isHTMLElement(element)) {
|
|
1387
|
-
return {
|
|
1388
|
-
width: element.offsetWidth,
|
|
1389
|
-
height: element.offsetHeight
|
|
1390
|
-
};
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
const rect = getBoundingClientRect(element);
|
|
1394
|
-
return {
|
|
1395
|
-
width: rect.width,
|
|
1396
|
-
height: rect.height
|
|
1397
|
-
};
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1401
|
-
let {
|
|
1402
|
-
rect,
|
|
1403
|
-
offsetParent,
|
|
1404
|
-
strategy
|
|
1405
|
-
} = _ref;
|
|
1406
|
-
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1407
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1408
|
-
|
|
1409
|
-
if (offsetParent === documentElement) {
|
|
1410
|
-
return rect;
|
|
1411
|
-
}
|
|
1412
|
-
|
|
1413
|
-
let scroll = {
|
|
1414
|
-
scrollLeft: 0,
|
|
1415
|
-
scrollTop: 0
|
|
1416
|
-
};
|
|
1417
|
-
const offsets = {
|
|
1418
|
-
x: 0,
|
|
1419
|
-
y: 0
|
|
1420
|
-
};
|
|
1421
|
-
|
|
1422
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
|
1423
|
-
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1424
|
-
scroll = getNodeScroll(offsetParent);
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
if (isHTMLElement(offsetParent)) {
|
|
1428
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1429
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1430
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1431
|
-
} // This doesn't appear to be need to be negated.
|
|
1432
|
-
// else if (documentElement) {
|
|
1433
|
-
// offsets.x = getWindowScrollBarX(documentElement);
|
|
1434
|
-
// }
|
|
1435
|
-
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
return { ...rect,
|
|
1439
|
-
x: rect.x - scroll.scrollLeft + offsets.x,
|
|
1440
|
-
y: rect.y - scroll.scrollTop + offsets.y
|
|
1441
|
-
};
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
function getViewportRect(element, strategy) {
|
|
1445
|
-
const win = getWindow(element);
|
|
1446
|
-
const html = getDocumentElement(element);
|
|
1447
|
-
const visualViewport = win.visualViewport;
|
|
1448
|
-
let width = html.clientWidth;
|
|
1449
|
-
let height = html.clientHeight;
|
|
1450
|
-
let x = 0;
|
|
1451
|
-
let y = 0;
|
|
1452
|
-
|
|
1453
|
-
if (visualViewport) {
|
|
1454
|
-
width = visualViewport.width;
|
|
1455
|
-
height = visualViewport.height;
|
|
1456
|
-
const layoutViewport = isLayoutViewport();
|
|
1457
|
-
|
|
1458
|
-
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
1459
|
-
x = visualViewport.offsetLeft;
|
|
1460
|
-
y = visualViewport.offsetTop;
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
return {
|
|
1465
|
-
width,
|
|
1466
|
-
height,
|
|
1467
|
-
x,
|
|
1468
|
-
y
|
|
1469
|
-
};
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
1473
|
-
|
|
1474
|
-
function getDocumentRect(element) {
|
|
1475
|
-
var _element$ownerDocumen;
|
|
1476
|
-
|
|
1477
|
-
const html = getDocumentElement(element);
|
|
1478
|
-
const scroll = getNodeScroll(element);
|
|
1479
|
-
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
1480
|
-
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
1481
|
-
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
1482
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1483
|
-
const y = -scroll.scrollTop;
|
|
1484
|
-
|
|
1485
|
-
if (getComputedStyle$1(body || html).direction === 'rtl') {
|
|
1486
|
-
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
return {
|
|
1490
|
-
width,
|
|
1491
|
-
height,
|
|
1492
|
-
x,
|
|
1493
|
-
y
|
|
1494
|
-
};
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
function getNearestOverflowAncestor(node) {
|
|
1498
|
-
const parentNode = getParentNode(node);
|
|
1499
|
-
|
|
1500
|
-
if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
|
|
1501
|
-
// @ts-ignore assume body is always available
|
|
1502
|
-
return node.ownerDocument.body;
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
|
-
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1506
|
-
return parentNode;
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
return getNearestOverflowAncestor(parentNode);
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
function getOverflowAncestors(node, list) {
|
|
1513
|
-
var _node$ownerDocument;
|
|
1514
|
-
|
|
1515
|
-
if (list === void 0) {
|
|
1516
|
-
list = [];
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1520
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
1521
|
-
const win = getWindow(scrollableAncestor);
|
|
1522
|
-
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
|
|
1523
|
-
const updatedList = list.concat(target);
|
|
1524
|
-
return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
|
|
1525
|
-
updatedList.concat(getOverflowAncestors(getParentNode(target)));
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
function contains(parent, child) {
|
|
1529
|
-
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
|
|
1530
|
-
|
|
1531
|
-
if (parent.contains(child)) {
|
|
1532
|
-
return true;
|
|
1533
|
-
} // then fallback to custom implementation with Shadow DOM support
|
|
1534
|
-
else if (rootNode && isShadowRoot(rootNode)) {
|
|
1535
|
-
let next = child;
|
|
1536
|
-
|
|
1537
|
-
do {
|
|
1538
|
-
// use `===` replace node.isSameNode()
|
|
1539
|
-
if (next && parent === next) {
|
|
1540
|
-
return true;
|
|
1541
|
-
} // @ts-ignore: need a better way to handle this...
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
next = next.parentNode || next.host;
|
|
1545
|
-
} while (next);
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
return false;
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
1552
|
-
const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
1553
|
-
const top = clientRect.top + element.clientTop;
|
|
1554
|
-
const left = clientRect.left + element.clientLeft;
|
|
1555
|
-
return {
|
|
1556
|
-
top,
|
|
1557
|
-
left,
|
|
1558
|
-
x: left,
|
|
1559
|
-
y: top,
|
|
1560
|
-
right: left + element.clientWidth,
|
|
1561
|
-
bottom: top + element.clientHeight,
|
|
1562
|
-
width: element.clientWidth,
|
|
1563
|
-
height: element.clientHeight
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
|
|
1568
|
-
if (clippingParent === 'viewport') {
|
|
1569
|
-
return rectToClientRect(getViewportRect(element, strategy));
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
if (isElement(clippingParent)) {
|
|
1573
|
-
return getInnerBoundingClientRect(clippingParent, strategy);
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
1577
|
-
} // A "clipping ancestor" is an overflowable container with the characteristic of
|
|
1578
|
-
// clipping (or hiding) overflowing elements with a position different from
|
|
1579
|
-
// `initial`
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
function getClippingAncestors(element) {
|
|
1583
|
-
const clippingAncestors = getOverflowAncestors(element);
|
|
1584
|
-
const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
|
|
1585
|
-
const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
1586
|
-
|
|
1587
|
-
if (!isElement(clipperElement)) {
|
|
1588
|
-
return [];
|
|
1589
|
-
} // @ts-ignore isElement check ensures we return Array<Element>
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
|
|
1593
|
-
} // Gets the maximum area that the element is visible in due to any number of
|
|
1594
|
-
// clipping ancestors
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
function getClippingRect(_ref) {
|
|
1598
|
-
let {
|
|
1599
|
-
element,
|
|
1600
|
-
boundary,
|
|
1601
|
-
rootBoundary,
|
|
1602
|
-
strategy
|
|
1603
|
-
} = _ref;
|
|
1604
|
-
const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
|
|
1605
|
-
const clippingAncestors = [...mainClippingAncestors, rootBoundary];
|
|
1606
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
1607
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1608
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1609
|
-
accRect.top = max(rect.top, accRect.top);
|
|
1610
|
-
accRect.right = min(rect.right, accRect.right);
|
|
1611
|
-
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1612
|
-
accRect.left = max(rect.left, accRect.left);
|
|
1613
|
-
return accRect;
|
|
1614
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1615
|
-
return {
|
|
1616
|
-
width: clippingRect.right - clippingRect.left,
|
|
1617
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
1618
|
-
x: clippingRect.left,
|
|
1619
|
-
y: clippingRect.top
|
|
1620
|
-
};
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
const platform = {
|
|
1624
|
-
getClippingRect,
|
|
1625
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1626
|
-
isElement,
|
|
1627
|
-
getDimensions,
|
|
1628
|
-
getOffsetParent,
|
|
1629
|
-
getDocumentElement,
|
|
1630
|
-
getElementRects: _ref => {
|
|
1631
|
-
let {
|
|
1632
|
-
reference,
|
|
1633
|
-
floating,
|
|
1634
|
-
strategy
|
|
1635
|
-
} = _ref;
|
|
1636
|
-
return {
|
|
1637
|
-
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
|
1638
|
-
floating: { ...getDimensions(floating),
|
|
1639
|
-
x: 0,
|
|
1640
|
-
y: 0
|
|
1641
|
-
}
|
|
1642
|
-
};
|
|
1643
|
-
},
|
|
1644
|
-
getClientRects: element => Array.from(element.getClientRects()),
|
|
1645
|
-
isRTL: element => getComputedStyle$1(element).direction === 'rtl'
|
|
1646
|
-
};
|
|
1647
|
-
|
|
1648
|
-
/**
|
|
1649
|
-
* Automatically updates the position of the floating element when necessary.
|
|
1650
|
-
* @see https://floating-ui.com/docs/autoUpdate
|
|
1651
|
-
*/
|
|
1652
|
-
function autoUpdate(reference, floating, update, options) {
|
|
1653
|
-
if (options === void 0) {
|
|
1654
|
-
options = {};
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
const {
|
|
1658
|
-
ancestorScroll: _ancestorScroll = true,
|
|
1659
|
-
ancestorResize: _ancestorResize = true,
|
|
1660
|
-
elementResize: _elementResize = true,
|
|
1661
|
-
animationFrame = false
|
|
1662
|
-
} = options;
|
|
1663
|
-
let cleanedUp = false;
|
|
1664
|
-
const ancestorScroll = _ancestorScroll && !animationFrame;
|
|
1665
|
-
const ancestorResize = _ancestorResize && !animationFrame;
|
|
1666
|
-
const elementResize = _elementResize && !animationFrame;
|
|
1667
|
-
const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
|
|
1668
|
-
ancestors.forEach(ancestor => {
|
|
1669
|
-
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
1670
|
-
passive: true
|
|
1671
|
-
});
|
|
1672
|
-
ancestorResize && ancestor.addEventListener('resize', update);
|
|
1673
|
-
});
|
|
1674
|
-
let observer = null;
|
|
1675
|
-
|
|
1676
|
-
if (elementResize) {
|
|
1677
|
-
observer = new ResizeObserver(update);
|
|
1678
|
-
isElement(reference) && observer.observe(reference);
|
|
1679
|
-
observer.observe(floating);
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
let frameId;
|
|
1683
|
-
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
1684
|
-
|
|
1685
|
-
if (animationFrame) {
|
|
1686
|
-
frameLoop();
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
function frameLoop() {
|
|
1690
|
-
if (cleanedUp) {
|
|
1691
|
-
return;
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
const nextRefRect = getBoundingClientRect(reference);
|
|
1695
|
-
|
|
1696
|
-
if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
|
|
1697
|
-
update();
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
|
-
prevRefRect = nextRefRect;
|
|
1701
|
-
frameId = requestAnimationFrame(frameLoop);
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
return () => {
|
|
1705
|
-
var _observer;
|
|
1706
|
-
|
|
1707
|
-
cleanedUp = true;
|
|
1708
|
-
ancestors.forEach(ancestor => {
|
|
1709
|
-
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
1710
|
-
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
1711
|
-
});
|
|
1712
|
-
(_observer = observer) == null ? void 0 : _observer.disconnect();
|
|
1713
|
-
observer = null;
|
|
1714
|
-
|
|
1715
|
-
if (animationFrame) {
|
|
1716
|
-
cancelAnimationFrame(frameId);
|
|
1717
|
-
}
|
|
1718
|
-
};
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
/**
|
|
1722
|
-
* Computes the `x` and `y` coordinates that will place the floating element
|
|
1723
|
-
* next to a reference element when it is given a certain CSS positioning
|
|
1724
|
-
* strategy.
|
|
1725
|
-
*/
|
|
1726
|
-
|
|
1727
|
-
const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
|
|
1728
|
-
platform,
|
|
1729
|
-
...options
|
|
1730
|
-
});
|
|
1731
|
-
|
|
1732
|
-
/*!
|
|
1733
|
-
* tabbable 5.3.1
|
|
1734
|
-
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
1735
|
-
*/
|
|
1736
|
-
var candidateSelectors = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]:not(slot)', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])', 'details>summary:first-of-type', 'details'];
|
|
1737
|
-
var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
|
|
1738
|
-
var NoElement = typeof Element === 'undefined';
|
|
1739
|
-
var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
1740
|
-
var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
|
|
1741
|
-
return element.getRootNode();
|
|
1742
|
-
} : function (element) {
|
|
1743
|
-
return element.ownerDocument;
|
|
1744
|
-
};
|
|
1745
|
-
/**
|
|
1746
|
-
* @param {Element} el container to check in
|
|
1747
|
-
* @param {boolean} includeContainer add container to check
|
|
1748
|
-
* @param {(node: Element) => boolean} filter filter candidates
|
|
1749
|
-
* @returns {Element[]}
|
|
1750
|
-
*/
|
|
1751
|
-
|
|
1752
|
-
var getCandidates = function getCandidates(el, includeContainer, filter) {
|
|
1753
|
-
var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
|
|
1754
|
-
|
|
1755
|
-
if (includeContainer && matches.call(el, candidateSelector)) {
|
|
1756
|
-
candidates.unshift(el);
|
|
1757
|
-
}
|
|
1758
|
-
|
|
1759
|
-
candidates = candidates.filter(filter);
|
|
1760
|
-
return candidates;
|
|
1761
|
-
};
|
|
1762
|
-
/**
|
|
1763
|
-
* @callback GetShadowRoot
|
|
1764
|
-
* @param {Element} element to check for shadow root
|
|
1765
|
-
* @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
|
|
1766
|
-
*/
|
|
1767
|
-
|
|
1768
|
-
/**
|
|
1769
|
-
* @typedef {Object} CandidatesScope
|
|
1770
|
-
* @property {Element} scope contains inner candidates
|
|
1771
|
-
* @property {Element[]} candidates
|
|
1772
|
-
*/
|
|
1773
|
-
|
|
1774
|
-
/**
|
|
1775
|
-
* @typedef {Object} IterativeOptions
|
|
1776
|
-
* @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
|
|
1777
|
-
* if a function, implies shadow support is enabled and either returns the shadow root of an element
|
|
1778
|
-
* or a boolean stating if it has an undisclosed shadow root
|
|
1779
|
-
* @property {(node: Element) => boolean} filter filter candidates
|
|
1780
|
-
* @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list
|
|
1781
|
-
*/
|
|
1782
|
-
|
|
1783
|
-
/**
|
|
1784
|
-
* @param {Element[]} elements list of element containers to match candidates from
|
|
1785
|
-
* @param {boolean} includeContainer add container list to check
|
|
1786
|
-
* @param {IterativeOptions} options
|
|
1787
|
-
* @returns {Array.<Element|CandidatesScope>}
|
|
1788
|
-
*/
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
|
|
1792
|
-
var candidates = [];
|
|
1793
|
-
var elementsToCheck = Array.from(elements);
|
|
1794
|
-
|
|
1795
|
-
while (elementsToCheck.length) {
|
|
1796
|
-
var element = elementsToCheck.shift();
|
|
1797
|
-
|
|
1798
|
-
if (element.tagName === 'SLOT') {
|
|
1799
|
-
// add shadow dom slot scope (slot itself cannot be focusable)
|
|
1800
|
-
var assigned = element.assignedElements();
|
|
1801
|
-
var content = assigned.length ? assigned : element.children;
|
|
1802
|
-
var nestedCandidates = getCandidatesIteratively(content, true, options);
|
|
1803
|
-
|
|
1804
|
-
if (options.flatten) {
|
|
1805
|
-
candidates.push.apply(candidates, nestedCandidates);
|
|
1806
|
-
} else {
|
|
1807
|
-
candidates.push({
|
|
1808
|
-
scope: element,
|
|
1809
|
-
candidates: nestedCandidates
|
|
1810
|
-
});
|
|
1811
|
-
}
|
|
1812
|
-
} else {
|
|
1813
|
-
// check candidate element
|
|
1814
|
-
var validCandidate = matches.call(element, candidateSelector);
|
|
1815
|
-
|
|
1816
|
-
if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
|
|
1817
|
-
candidates.push(element);
|
|
1818
|
-
} // iterate over shadow content if possible
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
|
|
1822
|
-
typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
|
|
1823
|
-
|
|
1824
|
-
if (shadowRoot) {
|
|
1825
|
-
// add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
|
|
1826
|
-
// shadow exists, so look at light dom children as fallback BUT create a scope for any
|
|
1827
|
-
// child candidates found because they're likely slotted elements (elements that are
|
|
1828
|
-
// children of the web component element (which has the shadow), in the light dom, but
|
|
1829
|
-
// slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
|
|
1830
|
-
// _after_ we return from this recursive call
|
|
1831
|
-
var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
|
|
1832
|
-
|
|
1833
|
-
if (options.flatten) {
|
|
1834
|
-
candidates.push.apply(candidates, _nestedCandidates);
|
|
1835
|
-
} else {
|
|
1836
|
-
candidates.push({
|
|
1837
|
-
scope: element,
|
|
1838
|
-
candidates: _nestedCandidates
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
|
-
} else {
|
|
1842
|
-
// there's not shadow so just dig into the element's (light dom) children
|
|
1843
|
-
// __without__ giving the element special scope treatment
|
|
1844
|
-
elementsToCheck.unshift.apply(elementsToCheck, element.children);
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
return candidates;
|
|
1850
|
-
};
|
|
1851
|
-
|
|
1852
|
-
var getTabindex = function getTabindex(node, isScope) {
|
|
1853
|
-
if (node.tabIndex < 0) {
|
|
1854
|
-
// in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
|
|
1855
|
-
// `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
|
|
1856
|
-
// yet they are still part of the regular tab order; in FF, they get a default
|
|
1857
|
-
// `tabIndex` of 0; since Chrome still puts those elements in the regular tab
|
|
1858
|
-
// order, consider their tab index to be 0.
|
|
1859
|
-
// Also browsers do not return `tabIndex` correctly for contentEditable nodes;
|
|
1860
|
-
// so if they don't have a tabindex attribute specifically set, assume it's 0.
|
|
1861
|
-
//
|
|
1862
|
-
// isScope is positive for custom element with shadow root or slot that by default
|
|
1863
|
-
// have tabIndex -1, but need to be sorted by document order in order for their
|
|
1864
|
-
// content to be inserted in the correct position
|
|
1865
|
-
if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || node.isContentEditable) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) {
|
|
1866
|
-
return 0;
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
return node.tabIndex;
|
|
1871
|
-
};
|
|
1872
|
-
|
|
1873
|
-
var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
|
|
1874
|
-
return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
|
|
1875
|
-
};
|
|
1876
|
-
|
|
1877
|
-
var isInput = function isInput(node) {
|
|
1878
|
-
return node.tagName === 'INPUT';
|
|
1879
|
-
};
|
|
1880
|
-
|
|
1881
|
-
var isHiddenInput = function isHiddenInput(node) {
|
|
1882
|
-
return isInput(node) && node.type === 'hidden';
|
|
1883
|
-
};
|
|
1884
|
-
|
|
1885
|
-
var isDetailsWithSummary = function isDetailsWithSummary(node) {
|
|
1886
|
-
var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
|
|
1887
|
-
return child.tagName === 'SUMMARY';
|
|
1888
|
-
});
|
|
1889
|
-
return r;
|
|
1890
|
-
};
|
|
1891
|
-
|
|
1892
|
-
var getCheckedRadio = function getCheckedRadio(nodes, form) {
|
|
1893
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
1894
|
-
if (nodes[i].checked && nodes[i].form === form) {
|
|
1895
|
-
return nodes[i];
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
};
|
|
1899
|
-
|
|
1900
|
-
var isTabbableRadio = function isTabbableRadio(node) {
|
|
1901
|
-
if (!node.name) {
|
|
1902
|
-
return true;
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
var radioScope = node.form || getRootNode(node);
|
|
1906
|
-
|
|
1907
|
-
var queryRadios = function queryRadios(name) {
|
|
1908
|
-
return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
|
|
1909
|
-
};
|
|
1910
|
-
|
|
1911
|
-
var radioSet;
|
|
1912
|
-
|
|
1913
|
-
if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
|
|
1914
|
-
radioSet = queryRadios(window.CSS.escape(node.name));
|
|
1915
|
-
} else {
|
|
1916
|
-
try {
|
|
1917
|
-
radioSet = queryRadios(node.name);
|
|
1918
|
-
} catch (err) {
|
|
1919
|
-
// eslint-disable-next-line no-console
|
|
1920
|
-
console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s', err.message);
|
|
1921
|
-
return false;
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
var checked = getCheckedRadio(radioSet, node.form);
|
|
1926
|
-
return !checked || checked === node;
|
|
1927
|
-
};
|
|
1928
|
-
|
|
1929
|
-
var isRadio = function isRadio(node) {
|
|
1930
|
-
return isInput(node) && node.type === 'radio';
|
|
1931
|
-
};
|
|
1932
|
-
|
|
1933
|
-
var isNonTabbableRadio = function isNonTabbableRadio(node) {
|
|
1934
|
-
return isRadio(node) && !isTabbableRadio(node);
|
|
1935
|
-
};
|
|
1936
|
-
|
|
1937
|
-
var isZeroArea = function isZeroArea(node) {
|
|
1938
|
-
var _node$getBoundingClie = node.getBoundingClientRect(),
|
|
1939
|
-
width = _node$getBoundingClie.width,
|
|
1940
|
-
height = _node$getBoundingClie.height;
|
|
1941
|
-
|
|
1942
|
-
return width === 0 && height === 0;
|
|
1943
|
-
};
|
|
1944
|
-
|
|
1945
|
-
var isHidden = function isHidden(node, _ref) {
|
|
1946
|
-
var displayCheck = _ref.displayCheck,
|
|
1947
|
-
getShadowRoot = _ref.getShadowRoot;
|
|
1948
|
-
|
|
1949
|
-
if (getComputedStyle(node).visibility === 'hidden') {
|
|
1950
|
-
return true;
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
|
|
1954
|
-
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
1955
|
-
|
|
1956
|
-
if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
|
|
1957
|
-
return true;
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
if (!displayCheck || displayCheck === 'full') {
|
|
1961
|
-
if (typeof getShadowRoot === 'function') {
|
|
1962
|
-
// figure out if we should consider the node to be in an undisclosed shadow and use the
|
|
1963
|
-
// 'non-zero-area' fallback
|
|
1964
|
-
var originalNode = node;
|
|
1965
|
-
|
|
1966
|
-
while (node) {
|
|
1967
|
-
var parentElement = node.parentElement;
|
|
1968
|
-
var rootNode = getRootNode(node);
|
|
1969
|
-
|
|
1970
|
-
if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
|
|
1971
|
-
) {
|
|
1972
|
-
// node has an undisclosed shadow which means we can only treat it as a black box, so we
|
|
1973
|
-
// fall back to a non-zero-area test
|
|
1974
|
-
return isZeroArea(node);
|
|
1975
|
-
} else if (node.assignedSlot) {
|
|
1976
|
-
// iterate up slot
|
|
1977
|
-
node = node.assignedSlot;
|
|
1978
|
-
} else if (!parentElement && rootNode !== node.ownerDocument) {
|
|
1979
|
-
// cross shadow boundary
|
|
1980
|
-
node = rootNode.host;
|
|
1981
|
-
} else {
|
|
1982
|
-
// iterate up normal dom
|
|
1983
|
-
node = parentElement;
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
node = originalNode;
|
|
1988
|
-
} // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
|
|
1989
|
-
// (i.e. it does not also presume that all nodes might have undisclosed shadows); or
|
|
1990
|
-
// it might be a falsy value, which means shadow DOM support is disabled
|
|
1991
|
-
// didn't find it sitting in an undisclosed shadow (or shadows are disabled) so now we
|
|
1992
|
-
// can just test to see if it would normally be visible or not
|
|
1993
|
-
// this works wherever the node is: if there's at least one client rect, it's
|
|
1994
|
-
// somehow displayed; it also covers the CSS 'display: contents' case where the
|
|
1995
|
-
// node itself is hidden in place of its contents; and there's no need to search
|
|
1996
|
-
// up the hierarchy either
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
return !node.getClientRects().length;
|
|
2000
|
-
} else if (displayCheck === 'non-zero-area') {
|
|
2001
|
-
return isZeroArea(node);
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
return false;
|
|
2005
|
-
}; // form fields (nested) inside a disabled fieldset are not focusable/tabbable
|
|
2006
|
-
// unless they are in the _first_ <legend> element of the top-most disabled
|
|
2007
|
-
// fieldset
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
|
|
2011
|
-
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
|
|
2012
|
-
var parentNode = node.parentElement; // check if `node` is contained in a disabled <fieldset>
|
|
2013
|
-
|
|
2014
|
-
while (parentNode) {
|
|
2015
|
-
if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
|
|
2016
|
-
// look for the first <legend> among the children of the disabled <fieldset>
|
|
2017
|
-
for (var i = 0; i < parentNode.children.length; i++) {
|
|
2018
|
-
var child = parentNode.children.item(i); // when the first <legend> (in document order) is found
|
|
2019
|
-
|
|
2020
|
-
if (child.tagName === 'LEGEND') {
|
|
2021
|
-
// if its parent <fieldset> is not nested in another disabled <fieldset>,
|
|
2022
|
-
// return whether `node` is a descendant of its first <legend>
|
|
2023
|
-
return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
|
|
2024
|
-
}
|
|
2025
|
-
} // the disabled <fieldset> containing `node` has no <legend>
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
return true;
|
|
2029
|
-
}
|
|
2030
|
-
|
|
2031
|
-
parentNode = parentNode.parentElement;
|
|
2032
|
-
}
|
|
2033
|
-
} // else, node's tabbable/focusable state should not be affected by a fieldset's
|
|
2034
|
-
// enabled/disabled state
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
return false;
|
|
2038
|
-
};
|
|
2039
|
-
|
|
2040
|
-
var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
|
|
2041
|
-
if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
|
|
2042
|
-
isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
2043
|
-
return false;
|
|
2044
|
-
}
|
|
2045
|
-
|
|
2046
|
-
return true;
|
|
2047
|
-
};
|
|
2048
|
-
|
|
2049
|
-
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
|
|
2050
|
-
if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
|
|
2051
|
-
return false;
|
|
2052
|
-
}
|
|
2053
|
-
|
|
2054
|
-
return true;
|
|
2055
|
-
};
|
|
2056
|
-
/**
|
|
2057
|
-
* @param {Array.<Element|CandidatesScope>} candidates
|
|
2058
|
-
* @returns Element[]
|
|
2059
|
-
*/
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
var sortByOrder = function sortByOrder(candidates) {
|
|
2063
|
-
var regularTabbables = [];
|
|
2064
|
-
var orderedTabbables = [];
|
|
2065
|
-
candidates.forEach(function (item, i) {
|
|
2066
|
-
var isScope = !!item.scope;
|
|
2067
|
-
var element = isScope ? item.scope : item;
|
|
2068
|
-
var candidateTabindex = getTabindex(element, isScope);
|
|
2069
|
-
var elements = isScope ? sortByOrder(item.candidates) : element;
|
|
2070
|
-
|
|
2071
|
-
if (candidateTabindex === 0) {
|
|
2072
|
-
isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
|
|
2073
|
-
} else {
|
|
2074
|
-
orderedTabbables.push({
|
|
2075
|
-
documentOrder: i,
|
|
2076
|
-
tabIndex: candidateTabindex,
|
|
2077
|
-
item: item,
|
|
2078
|
-
isScope: isScope,
|
|
2079
|
-
content: elements
|
|
2080
|
-
});
|
|
2081
|
-
}
|
|
2082
|
-
});
|
|
2083
|
-
return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
|
|
2084
|
-
sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
|
|
2085
|
-
return acc;
|
|
2086
|
-
}, []).concat(regularTabbables);
|
|
2087
|
-
};
|
|
2088
|
-
|
|
2089
|
-
var tabbable = function tabbable(el, options) {
|
|
2090
|
-
options = options || {};
|
|
2091
|
-
var candidates;
|
|
2092
|
-
|
|
2093
|
-
if (options.getShadowRoot) {
|
|
2094
|
-
candidates = getCandidatesIteratively([el], options.includeContainer, {
|
|
2095
|
-
filter: isNodeMatchingSelectorTabbable.bind(null, options),
|
|
2096
|
-
flatten: false,
|
|
2097
|
-
getShadowRoot: options.getShadowRoot
|
|
2098
|
-
});
|
|
2099
|
-
} else {
|
|
2100
|
-
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
return sortByOrder(candidates);
|
|
2104
|
-
};
|
|
2105
|
-
|
|
2106
|
-
var focusable = function focusable(el, options) {
|
|
2107
|
-
options = options || {};
|
|
2108
|
-
var candidates;
|
|
2109
|
-
|
|
2110
|
-
if (options.getShadowRoot) {
|
|
2111
|
-
candidates = getCandidatesIteratively([el], options.includeContainer, {
|
|
2112
|
-
filter: isNodeMatchingSelectorFocusable.bind(null, options),
|
|
2113
|
-
flatten: true,
|
|
2114
|
-
getShadowRoot: options.getShadowRoot
|
|
2115
|
-
});
|
|
2116
|
-
} else {
|
|
2117
|
-
candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
|
|
2118
|
-
}
|
|
2119
|
-
|
|
2120
|
-
return candidates;
|
|
2121
|
-
};
|
|
2122
|
-
|
|
2123
|
-
var isTabbable = function isTabbable(node, options) {
|
|
2124
|
-
options = options || {};
|
|
2125
|
-
|
|
2126
|
-
if (!node) {
|
|
2127
|
-
throw new Error('No node provided');
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
|
-
if (matches.call(node, candidateSelector) === false) {
|
|
2131
|
-
return false;
|
|
2132
|
-
}
|
|
2133
|
-
|
|
2134
|
-
return isNodeMatchingSelectorTabbable(options, node);
|
|
2135
|
-
};
|
|
2136
|
-
|
|
2137
|
-
var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
|
|
2138
|
-
|
|
2139
|
-
var isFocusable = function isFocusable(node, options) {
|
|
2140
|
-
options = options || {};
|
|
2141
|
-
|
|
2142
|
-
if (!node) {
|
|
2143
|
-
throw new Error('No node provided');
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
if (matches.call(node, focusableCandidateSelector) === false) {
|
|
2147
|
-
return false;
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
return isNodeMatchingSelectorFocusable(options, node);
|
|
2151
|
-
};
|
|
2152
|
-
|
|
2153
|
-
/*!
|
|
2154
|
-
* focus-trap 6.8.1
|
|
2155
|
-
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
2156
|
-
*/
|
|
2157
|
-
|
|
2158
|
-
function ownKeys(object, enumerableOnly) {
|
|
2159
|
-
var keys = Object.keys(object);
|
|
2160
|
-
|
|
2161
|
-
if (Object.getOwnPropertySymbols) {
|
|
2162
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
2163
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
2164
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2165
|
-
})), keys.push.apply(keys, symbols);
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
|
-
return keys;
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
|
-
function _objectSpread2(target) {
|
|
2172
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
2173
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
2174
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
2175
|
-
_defineProperty(target, key, source[key]);
|
|
2176
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
2177
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
return target;
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
function _defineProperty(obj, key, value) {
|
|
2185
|
-
if (key in obj) {
|
|
2186
|
-
Object.defineProperty(obj, key, {
|
|
2187
|
-
value: value,
|
|
2188
|
-
enumerable: true,
|
|
2189
|
-
configurable: true,
|
|
2190
|
-
writable: true
|
|
2191
|
-
});
|
|
2192
|
-
} else {
|
|
2193
|
-
obj[key] = value;
|
|
2194
|
-
}
|
|
2195
|
-
|
|
2196
|
-
return obj;
|
|
2197
|
-
}
|
|
2198
|
-
|
|
2199
|
-
var activeFocusTraps = function () {
|
|
2200
|
-
var trapQueue = [];
|
|
2201
|
-
return {
|
|
2202
|
-
activateTrap: function activateTrap(trap) {
|
|
2203
|
-
if (trapQueue.length > 0) {
|
|
2204
|
-
var activeTrap = trapQueue[trapQueue.length - 1];
|
|
2205
|
-
|
|
2206
|
-
if (activeTrap !== trap) {
|
|
2207
|
-
activeTrap.pause();
|
|
2208
|
-
}
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
var trapIndex = trapQueue.indexOf(trap);
|
|
2212
|
-
|
|
2213
|
-
if (trapIndex === -1) {
|
|
2214
|
-
trapQueue.push(trap);
|
|
2215
|
-
} else {
|
|
2216
|
-
// move this existing trap to the front of the queue
|
|
2217
|
-
trapQueue.splice(trapIndex, 1);
|
|
2218
|
-
trapQueue.push(trap);
|
|
2219
|
-
}
|
|
2220
|
-
},
|
|
2221
|
-
deactivateTrap: function deactivateTrap(trap) {
|
|
2222
|
-
var trapIndex = trapQueue.indexOf(trap);
|
|
2223
|
-
|
|
2224
|
-
if (trapIndex !== -1) {
|
|
2225
|
-
trapQueue.splice(trapIndex, 1);
|
|
2226
|
-
}
|
|
2227
|
-
|
|
2228
|
-
if (trapQueue.length > 0) {
|
|
2229
|
-
trapQueue[trapQueue.length - 1].unpause();
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
};
|
|
2233
|
-
}();
|
|
2234
|
-
|
|
2235
|
-
var isSelectableInput = function isSelectableInput(node) {
|
|
2236
|
-
return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
|
|
2237
|
-
};
|
|
2238
|
-
|
|
2239
|
-
var isEscapeEvent = function isEscapeEvent(e) {
|
|
2240
|
-
return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
|
|
2241
|
-
};
|
|
2242
|
-
|
|
2243
|
-
var isTabEvent = function isTabEvent(e) {
|
|
2244
|
-
return e.key === 'Tab' || e.keyCode === 9;
|
|
2245
|
-
};
|
|
2246
|
-
|
|
2247
|
-
var delay = function delay(fn) {
|
|
2248
|
-
return setTimeout(fn, 0);
|
|
2249
|
-
}; // Array.find/findIndex() are not supported on IE; this replicates enough
|
|
2250
|
-
// of Array.findIndex() for our needs
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
var findIndex = function findIndex(arr, fn) {
|
|
2254
|
-
var idx = -1;
|
|
2255
|
-
arr.every(function (value, i) {
|
|
2256
|
-
if (fn(value)) {
|
|
2257
|
-
idx = i;
|
|
2258
|
-
return false; // break
|
|
2259
|
-
}
|
|
2260
|
-
|
|
2261
|
-
return true; // next
|
|
2262
|
-
});
|
|
2263
|
-
return idx;
|
|
2264
|
-
};
|
|
2265
|
-
/**
|
|
2266
|
-
* Get an option's value when it could be a plain value, or a handler that provides
|
|
2267
|
-
* the value.
|
|
2268
|
-
* @param {*} value Option's value to check.
|
|
2269
|
-
* @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
|
|
2270
|
-
* @returns {*} The `value`, or the handler's returned value.
|
|
2271
|
-
*/
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
var valueOrHandler = function valueOrHandler(value) {
|
|
2275
|
-
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2276
|
-
params[_key - 1] = arguments[_key];
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
return typeof value === 'function' ? value.apply(void 0, params) : value;
|
|
2280
|
-
};
|
|
2281
|
-
|
|
2282
|
-
var getActualTarget = function getActualTarget(event) {
|
|
2283
|
-
// NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
|
|
2284
|
-
// shadow host. However, event.target.composedPath() will be an array of
|
|
2285
|
-
// nodes "clicked" from inner-most (the actual element inside the shadow) to
|
|
2286
|
-
// outer-most (the host HTML document). If we have access to composedPath(),
|
|
2287
|
-
// then use its first element; otherwise, fall back to event.target (and
|
|
2288
|
-
// this only works for an _open_ shadow DOM; otherwise,
|
|
2289
|
-
// composedPath()[0] === event.target always).
|
|
2290
|
-
return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
|
|
2291
|
-
};
|
|
2292
|
-
|
|
2293
|
-
var createFocusTrap = function createFocusTrap(elements, userOptions) {
|
|
2294
|
-
// SSR: a live trap shouldn't be created in this type of environment so this
|
|
2295
|
-
// should be safe code to execute if the `document` option isn't specified
|
|
2296
|
-
var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
|
|
2297
|
-
|
|
2298
|
-
var config = _objectSpread2({
|
|
2299
|
-
returnFocusOnDeactivate: true,
|
|
2300
|
-
escapeDeactivates: true,
|
|
2301
|
-
delayInitialFocus: true
|
|
2302
|
-
}, userOptions);
|
|
2303
|
-
|
|
2304
|
-
var state = {
|
|
2305
|
-
// containers given to createFocusTrap()
|
|
2306
|
-
// @type {Array<HTMLElement>}
|
|
2307
|
-
containers: [],
|
|
2308
|
-
// list of objects identifying tabbable nodes in `containers` in the trap
|
|
2309
|
-
// NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
|
|
2310
|
-
// is active, but the trap should never get to a state where there isn't at least one group
|
|
2311
|
-
// with at least one tabbable node in it (that would lead to an error condition that would
|
|
2312
|
-
// result in an error being thrown)
|
|
2313
|
-
// @type {Array<{
|
|
2314
|
-
// container: HTMLElement,
|
|
2315
|
-
// tabbableNodes: Array<HTMLElement>, // empty if none
|
|
2316
|
-
// focusableNodes: Array<HTMLElement>, // empty if none
|
|
2317
|
-
// firstTabbableNode: HTMLElement|null,
|
|
2318
|
-
// lastTabbableNode: HTMLElement|null,
|
|
2319
|
-
// nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
|
|
2320
|
-
// }>}
|
|
2321
|
-
containerGroups: [],
|
|
2322
|
-
// same order/length as `containers` list
|
|
2323
|
-
// references to objects in `containerGroups`, but only those that actually have
|
|
2324
|
-
// tabbable nodes in them
|
|
2325
|
-
// NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
|
|
2326
|
-
// the same length
|
|
2327
|
-
tabbableGroups: [],
|
|
2328
|
-
nodeFocusedBeforeActivation: null,
|
|
2329
|
-
mostRecentlyFocusedNode: null,
|
|
2330
|
-
active: false,
|
|
2331
|
-
paused: false,
|
|
2332
|
-
// timer ID for when delayInitialFocus is true and initial focus in this trap
|
|
2333
|
-
// has been delayed during activation
|
|
2334
|
-
delayInitialFocusTimer: undefined
|
|
2335
|
-
};
|
|
2336
|
-
var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later
|
|
2337
|
-
|
|
2338
|
-
/**
|
|
2339
|
-
* Gets a configuration option value.
|
|
2340
|
-
* @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
|
|
2341
|
-
* value will be taken from this object. Otherwise, value will be taken from base configuration.
|
|
2342
|
-
* @param {string} optionName Name of the option whose value is sought.
|
|
2343
|
-
* @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
|
|
2344
|
-
* IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
|
|
2345
|
-
*/
|
|
2346
|
-
|
|
2347
|
-
var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
|
|
2348
|
-
return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
|
|
2349
|
-
};
|
|
2350
|
-
/**
|
|
2351
|
-
* Finds the index of the container that contains the element.
|
|
2352
|
-
* @param {HTMLElement} element
|
|
2353
|
-
* @returns {number} Index of the container in either `state.containers` or
|
|
2354
|
-
* `state.containerGroups` (the order/length of these lists are the same); -1
|
|
2355
|
-
* if the element isn't found.
|
|
2356
|
-
*/
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
var findContainerIndex = function findContainerIndex(element) {
|
|
2360
|
-
// NOTE: search `containerGroups` because it's possible a group contains no tabbable
|
|
2361
|
-
// nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
|
|
2362
|
-
// and we still need to find the element in there
|
|
2363
|
-
return state.containerGroups.findIndex(function (_ref) {
|
|
2364
|
-
var container = _ref.container,
|
|
2365
|
-
tabbableNodes = _ref.tabbableNodes;
|
|
2366
|
-
return container.contains(element) || // fall back to explicit tabbable search which will take into consideration any
|
|
2367
|
-
// web components if the `tabbableOptions.getShadowRoot` option was used for
|
|
2368
|
-
// the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
|
|
2369
|
-
// look inside web components even if open)
|
|
2370
|
-
tabbableNodes.find(function (node) {
|
|
2371
|
-
return node === element;
|
|
2372
|
-
});
|
|
2373
|
-
});
|
|
2374
|
-
};
|
|
2375
|
-
/**
|
|
2376
|
-
* Gets the node for the given option, which is expected to be an option that
|
|
2377
|
-
* can be either a DOM node, a string that is a selector to get a node, `false`
|
|
2378
|
-
* (if a node is explicitly NOT given), or a function that returns any of these
|
|
2379
|
-
* values.
|
|
2380
|
-
* @param {string} optionName
|
|
2381
|
-
* @returns {undefined | false | HTMLElement | SVGElement} Returns
|
|
2382
|
-
* `undefined` if the option is not specified; `false` if the option
|
|
2383
|
-
* resolved to `false` (node explicitly not given); otherwise, the resolved
|
|
2384
|
-
* DOM node.
|
|
2385
|
-
* @throws {Error} If the option is set, not `false`, and is not, or does not
|
|
2386
|
-
* resolve to a node.
|
|
2387
|
-
*/
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
var getNodeForOption = function getNodeForOption(optionName) {
|
|
2391
|
-
var optionValue = config[optionName];
|
|
2392
|
-
|
|
2393
|
-
if (typeof optionValue === 'function') {
|
|
2394
|
-
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
2395
|
-
params[_key2 - 1] = arguments[_key2];
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
optionValue = optionValue.apply(void 0, params);
|
|
2399
|
-
}
|
|
2400
|
-
|
|
2401
|
-
if (!optionValue) {
|
|
2402
|
-
if (optionValue === undefined || optionValue === false) {
|
|
2403
|
-
return optionValue;
|
|
2404
|
-
} // else, empty string (invalid), null (invalid), 0 (invalid)
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
|
|
2408
|
-
}
|
|
2409
|
-
|
|
2410
|
-
var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
|
|
2411
|
-
|
|
2412
|
-
if (typeof optionValue === 'string') {
|
|
2413
|
-
node = doc.querySelector(optionValue); // resolve to node, or null if fails
|
|
2414
|
-
|
|
2415
|
-
if (!node) {
|
|
2416
|
-
throw new Error("`".concat(optionName, "` as selector refers to no known node"));
|
|
2417
|
-
}
|
|
2418
|
-
}
|
|
2419
|
-
|
|
2420
|
-
return node;
|
|
2421
|
-
};
|
|
2422
|
-
|
|
2423
|
-
var getInitialFocusNode = function getInitialFocusNode() {
|
|
2424
|
-
var node = getNodeForOption('initialFocus'); // false explicitly indicates we want no initialFocus at all
|
|
2425
|
-
|
|
2426
|
-
if (node === false) {
|
|
2427
|
-
return false;
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
if (node === undefined) {
|
|
2431
|
-
// option not specified: use fallback options
|
|
2432
|
-
if (findContainerIndex(doc.activeElement) >= 0) {
|
|
2433
|
-
node = doc.activeElement;
|
|
2434
|
-
} else {
|
|
2435
|
-
var firstTabbableGroup = state.tabbableGroups[0];
|
|
2436
|
-
var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode; // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
|
|
2437
|
-
|
|
2438
|
-
node = firstTabbableNode || getNodeForOption('fallbackFocus');
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
if (!node) {
|
|
2443
|
-
throw new Error('Your focus-trap needs to have at least one focusable element');
|
|
2444
|
-
}
|
|
2445
|
-
|
|
2446
|
-
return node;
|
|
2447
|
-
};
|
|
2448
|
-
|
|
2449
|
-
var updateTabbableNodes = function updateTabbableNodes() {
|
|
2450
|
-
state.containerGroups = state.containers.map(function (container) {
|
|
2451
|
-
var tabbableNodes = tabbable(container, config.tabbableOptions); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
|
|
2452
|
-
// are a superset of tabbable nodes
|
|
2453
|
-
|
|
2454
|
-
var focusableNodes = focusable(container, config.tabbableOptions);
|
|
2455
|
-
return {
|
|
2456
|
-
container: container,
|
|
2457
|
-
tabbableNodes: tabbableNodes,
|
|
2458
|
-
focusableNodes: focusableNodes,
|
|
2459
|
-
firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
|
|
2460
|
-
lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
|
|
2461
|
-
|
|
2462
|
-
/**
|
|
2463
|
-
* Finds the __tabbable__ node that follows the given node in the specified direction,
|
|
2464
|
-
* in this container, if any.
|
|
2465
|
-
* @param {HTMLElement} node
|
|
2466
|
-
* @param {boolean} [forward] True if going in forward tab order; false if going
|
|
2467
|
-
* in reverse.
|
|
2468
|
-
* @returns {HTMLElement|undefined} The next tabbable node, if any.
|
|
2469
|
-
*/
|
|
2470
|
-
nextTabbableNode: function nextTabbableNode(node) {
|
|
2471
|
-
var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
2472
|
-
// NOTE: If tabindex is positive (in order to manipulate the tab order separate
|
|
2473
|
-
// from the DOM order), this __will not work__ because the list of focusableNodes,
|
|
2474
|
-
// while it contains tabbable nodes, does not sort its nodes in any order other
|
|
2475
|
-
// than DOM order, because it can't: Where would you place focusable (but not
|
|
2476
|
-
// tabbable) nodes in that order? They have no order, because they aren't tabbale...
|
|
2477
|
-
// Support for positive tabindex is already broken and hard to manage (possibly
|
|
2478
|
-
// not supportable, TBD), so this isn't going to make things worse than they
|
|
2479
|
-
// already are, and at least makes things better for the majority of cases where
|
|
2480
|
-
// tabindex is either 0/unset or negative.
|
|
2481
|
-
// FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
|
|
2482
|
-
var nodeIdx = focusableNodes.findIndex(function (n) {
|
|
2483
|
-
return n === node;
|
|
2484
|
-
});
|
|
2485
|
-
|
|
2486
|
-
if (nodeIdx < 0) {
|
|
2487
|
-
return undefined;
|
|
2488
|
-
}
|
|
2489
|
-
|
|
2490
|
-
if (forward) {
|
|
2491
|
-
return focusableNodes.slice(nodeIdx + 1).find(function (n) {
|
|
2492
|
-
return isTabbable(n, config.tabbableOptions);
|
|
2493
|
-
});
|
|
2494
|
-
}
|
|
2495
|
-
|
|
2496
|
-
return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
|
|
2497
|
-
return isTabbable(n, config.tabbableOptions);
|
|
2498
|
-
});
|
|
2499
|
-
}
|
|
2500
|
-
};
|
|
2501
|
-
});
|
|
2502
|
-
state.tabbableGroups = state.containerGroups.filter(function (group) {
|
|
2503
|
-
return group.tabbableNodes.length > 0;
|
|
2504
|
-
}); // throw if no groups have tabbable nodes and we don't have a fallback focus node either
|
|
2505
|
-
|
|
2506
|
-
if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
|
|
2507
|
-
) {
|
|
2508
|
-
throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
|
|
2509
|
-
}
|
|
2510
|
-
};
|
|
2511
|
-
|
|
2512
|
-
var tryFocus = function tryFocus(node) {
|
|
2513
|
-
if (node === false) {
|
|
2514
|
-
return;
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
|
-
if (node === doc.activeElement) {
|
|
2518
|
-
return;
|
|
2519
|
-
}
|
|
2520
|
-
|
|
2521
|
-
if (!node || !node.focus) {
|
|
2522
|
-
tryFocus(getInitialFocusNode());
|
|
2523
|
-
return;
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
node.focus({
|
|
2527
|
-
preventScroll: !!config.preventScroll
|
|
2528
|
-
});
|
|
2529
|
-
state.mostRecentlyFocusedNode = node;
|
|
2530
|
-
|
|
2531
|
-
if (isSelectableInput(node)) {
|
|
2532
|
-
node.select();
|
|
2533
|
-
}
|
|
2534
|
-
};
|
|
2535
|
-
|
|
2536
|
-
var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
|
|
2537
|
-
var node = getNodeForOption('setReturnFocus', previousActiveElement);
|
|
2538
|
-
return node ? node : node === false ? false : previousActiveElement;
|
|
2539
|
-
}; // This needs to be done on mousedown and touchstart instead of click
|
|
2540
|
-
// so that it precedes the focus event.
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
var checkPointerDown = function checkPointerDown(e) {
|
|
2544
|
-
var target = getActualTarget(e);
|
|
2545
|
-
|
|
2546
|
-
if (findContainerIndex(target) >= 0) {
|
|
2547
|
-
// allow the click since it ocurred inside the trap
|
|
2548
|
-
return;
|
|
2549
|
-
}
|
|
2550
|
-
|
|
2551
|
-
if (valueOrHandler(config.clickOutsideDeactivates, e)) {
|
|
2552
|
-
// immediately deactivate the trap
|
|
2553
|
-
trap.deactivate({
|
|
2554
|
-
// if, on deactivation, we should return focus to the node originally-focused
|
|
2555
|
-
// when the trap was activated (or the configured `setReturnFocus` node),
|
|
2556
|
-
// then assume it's also OK to return focus to the outside node that was
|
|
2557
|
-
// just clicked, causing deactivation, as long as that node is focusable;
|
|
2558
|
-
// if it isn't focusable, then return focus to the original node focused
|
|
2559
|
-
// on activation (or the configured `setReturnFocus` node)
|
|
2560
|
-
// NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
|
|
2561
|
-
// which will result in the outside click setting focus to the node
|
|
2562
|
-
// that was clicked, whether it's focusable or not; by setting
|
|
2563
|
-
// `returnFocus: true`, we'll attempt to re-focus the node originally-focused
|
|
2564
|
-
// on activation (or the configured `setReturnFocus` node)
|
|
2565
|
-
returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
|
|
2566
|
-
});
|
|
2567
|
-
return;
|
|
2568
|
-
} // This is needed for mobile devices.
|
|
2569
|
-
// (If we'll only let `click` events through,
|
|
2570
|
-
// then on mobile they will be blocked anyways if `touchstart` is blocked.)
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
if (valueOrHandler(config.allowOutsideClick, e)) {
|
|
2574
|
-
// allow the click outside the trap to take place
|
|
2575
|
-
return;
|
|
2576
|
-
} // otherwise, prevent the click
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
e.preventDefault();
|
|
2580
|
-
}; // In case focus escapes the trap for some strange reason, pull it back in.
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
var checkFocusIn = function checkFocusIn(e) {
|
|
2584
|
-
var target = getActualTarget(e);
|
|
2585
|
-
var targetContained = findContainerIndex(target) >= 0; // In Firefox when you Tab out of an iframe the Document is briefly focused.
|
|
2586
|
-
|
|
2587
|
-
if (targetContained || target instanceof Document) {
|
|
2588
|
-
if (targetContained) {
|
|
2589
|
-
state.mostRecentlyFocusedNode = target;
|
|
2590
|
-
}
|
|
2591
|
-
} else {
|
|
2592
|
-
// escaped! pull it back in to where it just left
|
|
2593
|
-
e.stopImmediatePropagation();
|
|
2594
|
-
tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
|
|
2595
|
-
}
|
|
2596
|
-
}; // Hijack Tab events on the first and last focusable nodes of the trap,
|
|
2597
|
-
// in order to prevent focus from escaping. If it escapes for even a
|
|
2598
|
-
// moment it can end up scrolling the page and causing confusion so we
|
|
2599
|
-
// kind of need to capture the action at the keydown phase.
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
var checkTab = function checkTab(e) {
|
|
2603
|
-
var target = getActualTarget(e);
|
|
2604
|
-
updateTabbableNodes();
|
|
2605
|
-
var destinationNode = null;
|
|
2606
|
-
|
|
2607
|
-
if (state.tabbableGroups.length > 0) {
|
|
2608
|
-
// make sure the target is actually contained in a group
|
|
2609
|
-
// NOTE: the target may also be the container itself if it's focusable
|
|
2610
|
-
// with tabIndex='-1' and was given initial focus
|
|
2611
|
-
var containerIndex = findContainerIndex(target);
|
|
2612
|
-
var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
|
|
2613
|
-
|
|
2614
|
-
if (containerIndex < 0) {
|
|
2615
|
-
// target not found in any group: quite possible focus has escaped the trap,
|
|
2616
|
-
// so bring it back in to...
|
|
2617
|
-
if (e.shiftKey) {
|
|
2618
|
-
// ...the last node in the last group
|
|
2619
|
-
destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
|
|
2620
|
-
} else {
|
|
2621
|
-
// ...the first node in the first group
|
|
2622
|
-
destinationNode = state.tabbableGroups[0].firstTabbableNode;
|
|
2623
|
-
}
|
|
2624
|
-
} else if (e.shiftKey) {
|
|
2625
|
-
// REVERSE
|
|
2626
|
-
// is the target the first tabbable node in a group?
|
|
2627
|
-
var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
|
|
2628
|
-
var firstTabbableNode = _ref2.firstTabbableNode;
|
|
2629
|
-
return target === firstTabbableNode;
|
|
2630
|
-
});
|
|
2631
|
-
|
|
2632
|
-
if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
|
|
2633
|
-
// an exception case where the target is either the container itself, or
|
|
2634
|
-
// a non-tabbable node that was given focus (i.e. tabindex is negative
|
|
2635
|
-
// and user clicked on it or node was programmatically given focus)
|
|
2636
|
-
// and is not followed by any other tabbable node, in which
|
|
2637
|
-
// case, we should handle shift+tab as if focus were on the container's
|
|
2638
|
-
// first tabbable node, and go to the last tabbable node of the LAST group
|
|
2639
|
-
startOfGroupIndex = containerIndex;
|
|
2640
|
-
}
|
|
2641
|
-
|
|
2642
|
-
if (startOfGroupIndex >= 0) {
|
|
2643
|
-
// YES: then shift+tab should go to the last tabbable node in the
|
|
2644
|
-
// previous group (and wrap around to the last tabbable node of
|
|
2645
|
-
// the LAST group if it's the first tabbable node of the FIRST group)
|
|
2646
|
-
var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
|
|
2647
|
-
var destinationGroup = state.tabbableGroups[destinationGroupIndex];
|
|
2648
|
-
destinationNode = destinationGroup.lastTabbableNode;
|
|
2649
|
-
}
|
|
2650
|
-
} else {
|
|
2651
|
-
// FORWARD
|
|
2652
|
-
// is the target the last tabbable node in a group?
|
|
2653
|
-
var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
|
|
2654
|
-
var lastTabbableNode = _ref3.lastTabbableNode;
|
|
2655
|
-
return target === lastTabbableNode;
|
|
2656
|
-
});
|
|
2657
|
-
|
|
2658
|
-
if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
|
|
2659
|
-
// an exception case where the target is the container itself, or
|
|
2660
|
-
// a non-tabbable node that was given focus (i.e. tabindex is negative
|
|
2661
|
-
// and user clicked on it or node was programmatically given focus)
|
|
2662
|
-
// and is not followed by any other tabbable node, in which
|
|
2663
|
-
// case, we should handle tab as if focus were on the container's
|
|
2664
|
-
// last tabbable node, and go to the first tabbable node of the FIRST group
|
|
2665
|
-
lastOfGroupIndex = containerIndex;
|
|
2666
|
-
}
|
|
2667
|
-
|
|
2668
|
-
if (lastOfGroupIndex >= 0) {
|
|
2669
|
-
// YES: then tab should go to the first tabbable node in the next
|
|
2670
|
-
// group (and wrap around to the first tabbable node of the FIRST
|
|
2671
|
-
// group if it's the last tabbable node of the LAST group)
|
|
2672
|
-
var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
|
|
2673
|
-
|
|
2674
|
-
var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
|
|
2675
|
-
destinationNode = _destinationGroup.firstTabbableNode;
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
} else {
|
|
2679
|
-
// NOTE: the fallbackFocus option does not support returning false to opt-out
|
|
2680
|
-
destinationNode = getNodeForOption('fallbackFocus');
|
|
2681
|
-
}
|
|
2682
|
-
|
|
2683
|
-
if (destinationNode) {
|
|
2684
|
-
e.preventDefault();
|
|
2685
|
-
tryFocus(destinationNode);
|
|
2686
|
-
} // else, let the browser take care of [shift+]tab and move the focus
|
|
2687
|
-
|
|
2688
|
-
};
|
|
2689
|
-
|
|
2690
|
-
var checkKey = function checkKey(e) {
|
|
2691
|
-
if (isEscapeEvent(e) && valueOrHandler(config.escapeDeactivates, e) !== false) {
|
|
2692
|
-
e.preventDefault();
|
|
2693
|
-
trap.deactivate();
|
|
2694
|
-
return;
|
|
2695
|
-
}
|
|
2696
|
-
|
|
2697
|
-
if (isTabEvent(e)) {
|
|
2698
|
-
checkTab(e);
|
|
2699
|
-
return;
|
|
2700
|
-
}
|
|
2701
|
-
};
|
|
2702
|
-
|
|
2703
|
-
var checkClick = function checkClick(e) {
|
|
2704
|
-
if (valueOrHandler(config.clickOutsideDeactivates, e)) {
|
|
2705
|
-
return;
|
|
2706
|
-
}
|
|
2707
|
-
|
|
2708
|
-
var target = getActualTarget(e);
|
|
2709
|
-
|
|
2710
|
-
if (findContainerIndex(target) >= 0) {
|
|
2711
|
-
return;
|
|
2712
|
-
}
|
|
2713
|
-
|
|
2714
|
-
if (valueOrHandler(config.allowOutsideClick, e)) {
|
|
2715
|
-
return;
|
|
2716
|
-
}
|
|
2717
|
-
|
|
2718
|
-
e.preventDefault();
|
|
2719
|
-
e.stopImmediatePropagation();
|
|
2720
|
-
}; //
|
|
2721
|
-
// EVENT LISTENERS
|
|
2722
|
-
//
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
var addListeners = function addListeners() {
|
|
2726
|
-
if (!state.active) {
|
|
2727
|
-
return;
|
|
2728
|
-
} // There can be only one listening focus trap at a time
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
activeFocusTraps.activateTrap(trap); // Delay ensures that the focused element doesn't capture the event
|
|
2732
|
-
// that caused the focus trap activation.
|
|
2733
|
-
|
|
2734
|
-
state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
|
|
2735
|
-
tryFocus(getInitialFocusNode());
|
|
2736
|
-
}) : tryFocus(getInitialFocusNode());
|
|
2737
|
-
doc.addEventListener('focusin', checkFocusIn, true);
|
|
2738
|
-
doc.addEventListener('mousedown', checkPointerDown, {
|
|
2739
|
-
capture: true,
|
|
2740
|
-
passive: false
|
|
2741
|
-
});
|
|
2742
|
-
doc.addEventListener('touchstart', checkPointerDown, {
|
|
2743
|
-
capture: true,
|
|
2744
|
-
passive: false
|
|
2745
|
-
});
|
|
2746
|
-
doc.addEventListener('click', checkClick, {
|
|
2747
|
-
capture: true,
|
|
2748
|
-
passive: false
|
|
2749
|
-
});
|
|
2750
|
-
doc.addEventListener('keydown', checkKey, {
|
|
2751
|
-
capture: true,
|
|
2752
|
-
passive: false
|
|
2753
|
-
});
|
|
2754
|
-
return trap;
|
|
2755
|
-
};
|
|
2756
|
-
|
|
2757
|
-
var removeListeners = function removeListeners() {
|
|
2758
|
-
if (!state.active) {
|
|
2759
|
-
return;
|
|
2760
|
-
}
|
|
2761
|
-
|
|
2762
|
-
doc.removeEventListener('focusin', checkFocusIn, true);
|
|
2763
|
-
doc.removeEventListener('mousedown', checkPointerDown, true);
|
|
2764
|
-
doc.removeEventListener('touchstart', checkPointerDown, true);
|
|
2765
|
-
doc.removeEventListener('click', checkClick, true);
|
|
2766
|
-
doc.removeEventListener('keydown', checkKey, true);
|
|
2767
|
-
return trap;
|
|
2768
|
-
}; //
|
|
2769
|
-
// TRAP DEFINITION
|
|
2770
|
-
//
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
trap = {
|
|
2774
|
-
activate: function activate(activateOptions) {
|
|
2775
|
-
if (state.active) {
|
|
2776
|
-
return this;
|
|
2777
|
-
}
|
|
2778
|
-
|
|
2779
|
-
var onActivate = getOption(activateOptions, 'onActivate');
|
|
2780
|
-
var onPostActivate = getOption(activateOptions, 'onPostActivate');
|
|
2781
|
-
var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
|
|
2782
|
-
|
|
2783
|
-
if (!checkCanFocusTrap) {
|
|
2784
|
-
updateTabbableNodes();
|
|
2785
|
-
}
|
|
2786
|
-
|
|
2787
|
-
state.active = true;
|
|
2788
|
-
state.paused = false;
|
|
2789
|
-
state.nodeFocusedBeforeActivation = doc.activeElement;
|
|
2790
|
-
|
|
2791
|
-
if (onActivate) {
|
|
2792
|
-
onActivate();
|
|
2793
|
-
}
|
|
2794
|
-
|
|
2795
|
-
var finishActivation = function finishActivation() {
|
|
2796
|
-
if (checkCanFocusTrap) {
|
|
2797
|
-
updateTabbableNodes();
|
|
2798
|
-
}
|
|
2799
|
-
|
|
2800
|
-
addListeners();
|
|
2801
|
-
|
|
2802
|
-
if (onPostActivate) {
|
|
2803
|
-
onPostActivate();
|
|
2804
|
-
}
|
|
2805
|
-
};
|
|
2806
|
-
|
|
2807
|
-
if (checkCanFocusTrap) {
|
|
2808
|
-
checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
|
|
2809
|
-
return this;
|
|
2810
|
-
}
|
|
2811
|
-
|
|
2812
|
-
finishActivation();
|
|
2813
|
-
return this;
|
|
2814
|
-
},
|
|
2815
|
-
deactivate: function deactivate(deactivateOptions) {
|
|
2816
|
-
if (!state.active) {
|
|
2817
|
-
return this;
|
|
2818
|
-
}
|
|
2819
|
-
|
|
2820
|
-
clearTimeout(state.delayInitialFocusTimer); // noop if undefined
|
|
2821
|
-
|
|
2822
|
-
state.delayInitialFocusTimer = undefined;
|
|
2823
|
-
removeListeners();
|
|
2824
|
-
state.active = false;
|
|
2825
|
-
state.paused = false;
|
|
2826
|
-
activeFocusTraps.deactivateTrap(trap);
|
|
2827
|
-
var onDeactivate = getOption(deactivateOptions, 'onDeactivate');
|
|
2828
|
-
var onPostDeactivate = getOption(deactivateOptions, 'onPostDeactivate');
|
|
2829
|
-
var checkCanReturnFocus = getOption(deactivateOptions, 'checkCanReturnFocus');
|
|
2830
|
-
|
|
2831
|
-
if (onDeactivate) {
|
|
2832
|
-
onDeactivate();
|
|
2833
|
-
}
|
|
2834
|
-
|
|
2835
|
-
var returnFocus = getOption(deactivateOptions, 'returnFocus', 'returnFocusOnDeactivate');
|
|
2836
|
-
|
|
2837
|
-
var finishDeactivation = function finishDeactivation() {
|
|
2838
|
-
delay(function () {
|
|
2839
|
-
if (returnFocus) {
|
|
2840
|
-
tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
|
|
2841
|
-
}
|
|
2842
|
-
|
|
2843
|
-
if (onPostDeactivate) {
|
|
2844
|
-
onPostDeactivate();
|
|
2845
|
-
}
|
|
2846
|
-
});
|
|
2847
|
-
};
|
|
2848
|
-
|
|
2849
|
-
if (returnFocus && checkCanReturnFocus) {
|
|
2850
|
-
checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
|
|
2851
|
-
return this;
|
|
2852
|
-
}
|
|
2853
|
-
|
|
2854
|
-
finishDeactivation();
|
|
2855
|
-
return this;
|
|
2856
|
-
},
|
|
2857
|
-
pause: function pause() {
|
|
2858
|
-
if (state.paused || !state.active) {
|
|
2859
|
-
return this;
|
|
2860
|
-
}
|
|
2861
|
-
|
|
2862
|
-
state.paused = true;
|
|
2863
|
-
removeListeners();
|
|
2864
|
-
return this;
|
|
2865
|
-
},
|
|
2866
|
-
unpause: function unpause() {
|
|
2867
|
-
if (!state.paused || !state.active) {
|
|
2868
|
-
return this;
|
|
2869
|
-
}
|
|
2870
|
-
|
|
2871
|
-
state.paused = false;
|
|
2872
|
-
updateTabbableNodes();
|
|
2873
|
-
addListeners();
|
|
2874
|
-
return this;
|
|
2875
|
-
},
|
|
2876
|
-
updateContainerElements: function updateContainerElements(containerElements) {
|
|
2877
|
-
var elementsAsArray = [].concat(containerElements).filter(Boolean);
|
|
2878
|
-
state.containers = elementsAsArray.map(function (element) {
|
|
2879
|
-
return typeof element === 'string' ? doc.querySelector(element) : element;
|
|
2880
|
-
});
|
|
2881
|
-
|
|
2882
|
-
if (state.active) {
|
|
2883
|
-
updateTabbableNodes();
|
|
2884
|
-
}
|
|
2885
|
-
|
|
2886
|
-
return this;
|
|
2887
|
-
}
|
|
2888
|
-
}; // initialize container elements
|
|
2889
|
-
|
|
2890
|
-
trap.updateContainerElements(elements);
|
|
2891
|
-
return trap;
|
|
2892
|
-
};
|
|
2893
|
-
|
|
2894
|
-
const firstTabbable = (container) => {
|
|
2895
|
-
return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
|
|
2896
|
-
};
|
|
2897
|
-
|
|
2898
|
-
const catMenuCss = ":host{display:contents}:host([hidden]){display:none}.content{padding-top:0.5rem;padding-bottom:0.5rem;position:absolute;background:white;display:none;overflow:auto;-webkit-overflow-scrolling:touch;min-width:8rem;max-width:16rem;min-height:2rem;max-height:calc(100vh - 48px);box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2);border-radius:0.25rem;z-index:100}";
|
|
2899
|
-
|
|
2900
|
-
let nextUniqueId$4 = 0;
|
|
2901
|
-
const CatMenu = class {
|
|
2902
|
-
constructor(hostRef) {
|
|
2903
|
-
registerInstance(this, hostRef);
|
|
2904
|
-
this.catOpen = createEvent(this, "catOpen", 7);
|
|
2905
|
-
this.catClose = createEvent(this, "catClose", 7);
|
|
2906
|
-
this.id = nextUniqueId$4++;
|
|
2907
|
-
/**
|
|
2908
|
-
* The placement of the menu.
|
|
2909
|
-
*/
|
|
2910
|
-
this.placement = 'bottom-start';
|
|
2911
|
-
}
|
|
2912
|
-
clickHandler(event) {
|
|
2913
|
-
var _a;
|
|
2914
|
-
// hide menu on button click
|
|
2915
|
-
if (this.content && event.composedPath().includes(this.content)) {
|
|
2916
|
-
(_a = this.trap) === null || _a === void 0 ? void 0 : _a.deactivate();
|
|
2917
|
-
this.hide();
|
|
2918
|
-
}
|
|
2919
|
-
}
|
|
2920
|
-
componentDidLoad() {
|
|
2921
|
-
var _a, _b, _c, _d, _e;
|
|
2922
|
-
this.trigger = firstTabbable(this.triggerSlot);
|
|
2923
|
-
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', 'true');
|
|
2924
|
-
(_b = this.trigger) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', 'false');
|
|
2925
|
-
(_c = this.trigger) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-controls', this.contentId);
|
|
2926
|
-
(_d = this.content) === null || _d === void 0 ? void 0 : _d.setAttribute('id', this.contentId);
|
|
2927
|
-
if (this.trigger && this.content) {
|
|
2928
|
-
(_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('click', () => this.show());
|
|
2929
|
-
autoUpdate(this.trigger, this.content, () => this.update());
|
|
2930
|
-
}
|
|
2931
|
-
this.keyListener = event => {
|
|
2932
|
-
if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
2933
|
-
const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });
|
|
2934
|
-
const activeElement = firstTabbable(document.activeElement);
|
|
2935
|
-
const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
|
|
2936
|
-
const activeOff = event.key === 'ArrowDown' ? 1 : -1;
|
|
2937
|
-
const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
|
|
2938
|
-
targetElements[targetIdx].focus();
|
|
2939
|
-
event.preventDefault();
|
|
2940
|
-
}
|
|
2941
|
-
};
|
|
2942
|
-
document.addEventListener('keydown', this.keyListener);
|
|
2943
|
-
}
|
|
2944
|
-
disconnectedCallback() {
|
|
2945
|
-
if (this.keyListener) {
|
|
2946
|
-
document.removeEventListener('keydown', this.keyListener);
|
|
2947
|
-
}
|
|
2948
|
-
}
|
|
2949
|
-
render() {
|
|
2950
|
-
return (h(Host, null, h("slot", { name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { class: "content", ref: el => (this.content = el) }, h("slot", { name: "content" }))));
|
|
2951
|
-
}
|
|
2952
|
-
get contentId() {
|
|
2953
|
-
return `cat-menu-${this.id}`;
|
|
2954
|
-
}
|
|
2955
|
-
show() {
|
|
2956
|
-
var _a;
|
|
2957
|
-
if (this.content) {
|
|
2958
|
-
this.content.style.display = 'block';
|
|
2959
|
-
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'true');
|
|
2960
|
-
this.catOpen.emit();
|
|
2961
|
-
this.trap = this.trap
|
|
2962
|
-
? this.trap.updateContainerElements(this.content)
|
|
2963
|
-
: createFocusTrap(this.content, {
|
|
2964
|
-
tabbableOptions: {
|
|
2965
|
-
getShadowRoot: true
|
|
2966
|
-
},
|
|
2967
|
-
allowOutsideClick: true,
|
|
2968
|
-
clickOutsideDeactivates: event => !this.content || !event.composedPath().includes(this.content),
|
|
2969
|
-
onPostDeactivate: () => this.hide()
|
|
2970
|
-
});
|
|
2971
|
-
this.trap.activate();
|
|
2972
|
-
}
|
|
2973
|
-
}
|
|
2974
|
-
hide() {
|
|
2975
|
-
var _a;
|
|
2976
|
-
if (this.content) {
|
|
2977
|
-
this.content.style.display = '';
|
|
2978
|
-
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'false');
|
|
2979
|
-
this.catClose.emit();
|
|
2980
|
-
}
|
|
2981
|
-
}
|
|
2982
|
-
update() {
|
|
2983
|
-
if (this.trigger && this.content) {
|
|
2984
|
-
computePosition(this.trigger, this.content, {
|
|
2985
|
-
placement: this.placement,
|
|
2986
|
-
middleware: [offset(CatMenu.OFFSET), flip()]
|
|
2987
|
-
}).then(({ x, y }) => {
|
|
2988
|
-
if (this.content) {
|
|
2989
|
-
Object.assign(this.content.style, {
|
|
2990
|
-
left: `${x}px`,
|
|
2991
|
-
top: `${y}px`
|
|
2992
|
-
});
|
|
2993
|
-
}
|
|
2994
|
-
});
|
|
2995
|
-
}
|
|
2996
|
-
}
|
|
2997
|
-
};
|
|
2998
|
-
CatMenu.OFFSET = 4;
|
|
2999
|
-
CatMenu.style = catMenuCss;
|
|
3000
|
-
|
|
3001
|
-
const catRadioCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;margin:0}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;cursor:pointer}.radio{display:flex;position:relative}.circle{position:absolute;width:0.75rem;height:0.75rem;background-color:rgb(var(--cat-primary-bg, 32, 127, 138));border-radius:10rem;top:calc(50% - 0.375rem);left:calc(50% - 0.375rem);visibility:hidden}input{margin:0;width:1.25rem;height:1.25rem;appearance:none;background-color:white;border:1px solid #d7dbe0;border-radius:10rem;cursor:inherit}input:checked{border-color:rgb(var(--cat-primary-bg, 32, 127, 138))}input:checked+.circle{visibility:visible}input:focus-visible{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.is-disabled input{background-color:#f8f8fb}.is-disabled input:checked{border-color:#d7dbe0}.is-disabled .circle{background-color:#d7dbe0}";
|
|
3002
|
-
|
|
3003
|
-
let nextUniqueId$3 = 0;
|
|
3004
|
-
const CatRadio = class {
|
|
3005
|
-
constructor(hostRef) {
|
|
3006
|
-
registerInstance(this, hostRef);
|
|
3007
|
-
this.catChange = createEvent(this, "catChange", 7);
|
|
3008
|
-
this.catFocus = createEvent(this, "catFocus", 7);
|
|
3009
|
-
this.catBlur = createEvent(this, "catBlur", 7);
|
|
3010
|
-
this.id = `cat-radio-${++nextUniqueId$3}`;
|
|
3011
|
-
this.hasSlottedLabel = false;
|
|
3012
|
-
/**
|
|
3013
|
-
* Whether this radio is checked.
|
|
3014
|
-
*/
|
|
3015
|
-
this.checked = false;
|
|
3016
|
-
/**
|
|
3017
|
-
* Whether this radio is disabled.
|
|
3018
|
-
*/
|
|
3019
|
-
this.disabled = false;
|
|
3020
|
-
/**
|
|
3021
|
-
* The label of the radio that is visible.
|
|
3022
|
-
*/
|
|
3023
|
-
this.label = '';
|
|
3024
|
-
/**
|
|
3025
|
-
* Visually hide the label, but still show it to assistive technologies like screen readers.
|
|
3026
|
-
*/
|
|
3027
|
-
this.labelHidden = false;
|
|
3028
|
-
/**
|
|
3029
|
-
* Whether the radio is required.
|
|
3030
|
-
*/
|
|
3031
|
-
this.required = false;
|
|
3032
|
-
}
|
|
3033
|
-
componentWillRender() {
|
|
3034
|
-
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
3035
|
-
if (!this.label && !this.hasSlottedLabel) {
|
|
3036
|
-
loglevel.error('[A11y] Missing ARIA label on radio', this);
|
|
3037
|
-
}
|
|
3038
|
-
}
|
|
3039
|
-
/**
|
|
3040
|
-
* Sets focus on the radio. Use this method instead of `radio.focus()`.
|
|
3041
|
-
*
|
|
3042
|
-
* @param options An optional object providing options to control aspects of
|
|
3043
|
-
* the focusing process.
|
|
3044
|
-
*/
|
|
3045
|
-
async setFocus(options) {
|
|
3046
|
-
this.input.focus(options);
|
|
3047
|
-
}
|
|
3048
|
-
render() {
|
|
3049
|
-
return (h(Host, null, h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } }, h("span", { class: "radio" }, h("input", { ref: el => (this.input = el), id: this.id, type: "radio", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, onInput: this.onChange.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), h("span", { class: "circle" })), h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)), this.hintSection));
|
|
3050
|
-
}
|
|
3051
|
-
get hintSection() {
|
|
3052
|
-
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
3053
|
-
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
3054
|
-
}
|
|
3055
|
-
onChange(event) {
|
|
3056
|
-
this.value = this.input.value;
|
|
3057
|
-
this.catChange.emit(event);
|
|
3058
|
-
}
|
|
3059
|
-
onFocus(event) {
|
|
3060
|
-
this.catFocus.emit(event);
|
|
3061
|
-
}
|
|
3062
|
-
onBlur(event) {
|
|
3063
|
-
this.catBlur.emit(event);
|
|
3064
|
-
}
|
|
3065
|
-
get hostElement() { return getElement(this); }
|
|
3066
|
-
};
|
|
3067
|
-
CatRadio.style = catRadioCss;
|
|
3068
|
-
|
|
3069
|
-
function isFunction(value) {
|
|
3070
|
-
return typeof value === 'function';
|
|
3071
|
-
}
|
|
3072
|
-
|
|
3073
|
-
function createErrorClass(createImpl) {
|
|
3074
|
-
const _super = (instance) => {
|
|
3075
|
-
Error.call(instance);
|
|
3076
|
-
instance.stack = new Error().stack;
|
|
3077
|
-
};
|
|
3078
|
-
const ctorFunc = createImpl(_super);
|
|
3079
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
3080
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
3081
|
-
return ctorFunc;
|
|
3082
|
-
}
|
|
3083
|
-
|
|
3084
|
-
const UnsubscriptionError = createErrorClass((_super) => function UnsubscriptionErrorImpl(errors) {
|
|
3085
|
-
_super(this);
|
|
3086
|
-
this.message = errors
|
|
3087
|
-
? `${errors.length} errors occurred during unsubscription:
|
|
3088
|
-
${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
|
|
3089
|
-
: '';
|
|
3090
|
-
this.name = 'UnsubscriptionError';
|
|
3091
|
-
this.errors = errors;
|
|
3092
|
-
});
|
|
3093
|
-
|
|
3094
|
-
function arrRemove(arr, item) {
|
|
3095
|
-
if (arr) {
|
|
3096
|
-
const index = arr.indexOf(item);
|
|
3097
|
-
0 <= index && arr.splice(index, 1);
|
|
3098
|
-
}
|
|
3099
|
-
}
|
|
3100
|
-
|
|
3101
|
-
class Subscription {
|
|
3102
|
-
constructor(initialTeardown) {
|
|
3103
|
-
this.initialTeardown = initialTeardown;
|
|
3104
|
-
this.closed = false;
|
|
3105
|
-
this._parentage = null;
|
|
3106
|
-
this._finalizers = null;
|
|
3107
|
-
}
|
|
3108
|
-
unsubscribe() {
|
|
3109
|
-
let errors;
|
|
3110
|
-
if (!this.closed) {
|
|
3111
|
-
this.closed = true;
|
|
3112
|
-
const { _parentage } = this;
|
|
3113
|
-
if (_parentage) {
|
|
3114
|
-
this._parentage = null;
|
|
3115
|
-
if (Array.isArray(_parentage)) {
|
|
3116
|
-
for (const parent of _parentage) {
|
|
3117
|
-
parent.remove(this);
|
|
3118
|
-
}
|
|
3119
|
-
}
|
|
3120
|
-
else {
|
|
3121
|
-
_parentage.remove(this);
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
const { initialTeardown: initialFinalizer } = this;
|
|
3125
|
-
if (isFunction(initialFinalizer)) {
|
|
3126
|
-
try {
|
|
3127
|
-
initialFinalizer();
|
|
3128
|
-
}
|
|
3129
|
-
catch (e) {
|
|
3130
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
3131
|
-
}
|
|
3132
|
-
}
|
|
3133
|
-
const { _finalizers } = this;
|
|
3134
|
-
if (_finalizers) {
|
|
3135
|
-
this._finalizers = null;
|
|
3136
|
-
for (const finalizer of _finalizers) {
|
|
3137
|
-
try {
|
|
3138
|
-
execFinalizer(finalizer);
|
|
3139
|
-
}
|
|
3140
|
-
catch (err) {
|
|
3141
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
3142
|
-
if (err instanceof UnsubscriptionError) {
|
|
3143
|
-
errors = [...errors, ...err.errors];
|
|
3144
|
-
}
|
|
3145
|
-
else {
|
|
3146
|
-
errors.push(err);
|
|
3147
|
-
}
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
if (errors) {
|
|
3152
|
-
throw new UnsubscriptionError(errors);
|
|
3153
|
-
}
|
|
3154
|
-
}
|
|
3155
|
-
}
|
|
3156
|
-
add(teardown) {
|
|
3157
|
-
var _a;
|
|
3158
|
-
if (teardown && teardown !== this) {
|
|
3159
|
-
if (this.closed) {
|
|
3160
|
-
execFinalizer(teardown);
|
|
3161
|
-
}
|
|
3162
|
-
else {
|
|
3163
|
-
if (teardown instanceof Subscription) {
|
|
3164
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
3165
|
-
return;
|
|
3166
|
-
}
|
|
3167
|
-
teardown._addParent(this);
|
|
3168
|
-
}
|
|
3169
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
}
|
|
3173
|
-
_hasParent(parent) {
|
|
3174
|
-
const { _parentage } = this;
|
|
3175
|
-
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
3176
|
-
}
|
|
3177
|
-
_addParent(parent) {
|
|
3178
|
-
const { _parentage } = this;
|
|
3179
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
3180
|
-
}
|
|
3181
|
-
_removeParent(parent) {
|
|
3182
|
-
const { _parentage } = this;
|
|
3183
|
-
if (_parentage === parent) {
|
|
3184
|
-
this._parentage = null;
|
|
3185
|
-
}
|
|
3186
|
-
else if (Array.isArray(_parentage)) {
|
|
3187
|
-
arrRemove(_parentage, parent);
|
|
3188
|
-
}
|
|
3189
|
-
}
|
|
3190
|
-
remove(teardown) {
|
|
3191
|
-
const { _finalizers } = this;
|
|
3192
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
3193
|
-
if (teardown instanceof Subscription) {
|
|
3194
|
-
teardown._removeParent(this);
|
|
3195
|
-
}
|
|
3196
|
-
}
|
|
3197
|
-
}
|
|
3198
|
-
Subscription.EMPTY = (() => {
|
|
3199
|
-
const empty = new Subscription();
|
|
3200
|
-
empty.closed = true;
|
|
3201
|
-
return empty;
|
|
3202
|
-
})();
|
|
3203
|
-
const EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
3204
|
-
function isSubscription(value) {
|
|
3205
|
-
return (value instanceof Subscription ||
|
|
3206
|
-
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
3207
|
-
}
|
|
3208
|
-
function execFinalizer(finalizer) {
|
|
3209
|
-
if (isFunction(finalizer)) {
|
|
3210
|
-
finalizer();
|
|
3211
|
-
}
|
|
3212
|
-
else {
|
|
3213
|
-
finalizer.unsubscribe();
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
|
|
3217
|
-
const config = {
|
|
3218
|
-
onUnhandledError: null,
|
|
3219
|
-
onStoppedNotification: null,
|
|
3220
|
-
Promise: undefined,
|
|
3221
|
-
useDeprecatedSynchronousErrorHandling: false,
|
|
3222
|
-
useDeprecatedNextContext: false,
|
|
3223
|
-
};
|
|
3224
|
-
|
|
3225
|
-
const timeoutProvider = {
|
|
3226
|
-
setTimeout(handler, timeout, ...args) {
|
|
3227
|
-
const { delegate } = timeoutProvider;
|
|
3228
|
-
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
3229
|
-
return delegate.setTimeout(handler, timeout, ...args);
|
|
3230
|
-
}
|
|
3231
|
-
return setTimeout(handler, timeout, ...args);
|
|
3232
|
-
},
|
|
3233
|
-
clearTimeout(handle) {
|
|
3234
|
-
const { delegate } = timeoutProvider;
|
|
3235
|
-
return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
|
|
3236
|
-
},
|
|
3237
|
-
delegate: undefined,
|
|
3238
|
-
};
|
|
3239
|
-
|
|
3240
|
-
function reportUnhandledError(err) {
|
|
3241
|
-
timeoutProvider.setTimeout(() => {
|
|
3242
|
-
const { onUnhandledError } = config;
|
|
3243
|
-
if (onUnhandledError) {
|
|
3244
|
-
onUnhandledError(err);
|
|
3245
|
-
}
|
|
3246
|
-
else {
|
|
3247
|
-
throw err;
|
|
3248
|
-
}
|
|
3249
|
-
});
|
|
3250
|
-
}
|
|
3251
|
-
|
|
3252
|
-
function noop() { }
|
|
3253
|
-
|
|
3254
|
-
const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined))();
|
|
3255
|
-
function errorNotification(error) {
|
|
3256
|
-
return createNotification('E', undefined, error);
|
|
3257
|
-
}
|
|
3258
|
-
function nextNotification(value) {
|
|
3259
|
-
return createNotification('N', value, undefined);
|
|
3260
|
-
}
|
|
3261
|
-
function createNotification(kind, value, error) {
|
|
3262
|
-
return {
|
|
3263
|
-
kind,
|
|
3264
|
-
value,
|
|
3265
|
-
error,
|
|
3266
|
-
};
|
|
3267
|
-
}
|
|
3268
|
-
|
|
3269
|
-
function errorContext(cb) {
|
|
3270
|
-
{
|
|
3271
|
-
cb();
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
|
|
3275
|
-
class Subscriber extends Subscription {
|
|
3276
|
-
constructor(destination) {
|
|
3277
|
-
super();
|
|
3278
|
-
this.isStopped = false;
|
|
3279
|
-
if (destination) {
|
|
3280
|
-
this.destination = destination;
|
|
3281
|
-
if (isSubscription(destination)) {
|
|
3282
|
-
destination.add(this);
|
|
3283
|
-
}
|
|
3284
|
-
}
|
|
3285
|
-
else {
|
|
3286
|
-
this.destination = EMPTY_OBSERVER;
|
|
3287
|
-
}
|
|
3288
|
-
}
|
|
3289
|
-
static create(next, error, complete) {
|
|
3290
|
-
return new SafeSubscriber(next, error, complete);
|
|
3291
|
-
}
|
|
3292
|
-
next(value) {
|
|
3293
|
-
if (this.isStopped) {
|
|
3294
|
-
handleStoppedNotification(nextNotification(value), this);
|
|
3295
|
-
}
|
|
3296
|
-
else {
|
|
3297
|
-
this._next(value);
|
|
3298
|
-
}
|
|
3299
|
-
}
|
|
3300
|
-
error(err) {
|
|
3301
|
-
if (this.isStopped) {
|
|
3302
|
-
handleStoppedNotification(errorNotification(err), this);
|
|
3303
|
-
}
|
|
3304
|
-
else {
|
|
3305
|
-
this.isStopped = true;
|
|
3306
|
-
this._error(err);
|
|
3307
|
-
}
|
|
3308
|
-
}
|
|
3309
|
-
complete() {
|
|
3310
|
-
if (this.isStopped) {
|
|
3311
|
-
handleStoppedNotification(COMPLETE_NOTIFICATION, this);
|
|
3312
|
-
}
|
|
3313
|
-
else {
|
|
3314
|
-
this.isStopped = true;
|
|
3315
|
-
this._complete();
|
|
3316
|
-
}
|
|
3317
|
-
}
|
|
3318
|
-
unsubscribe() {
|
|
3319
|
-
if (!this.closed) {
|
|
3320
|
-
this.isStopped = true;
|
|
3321
|
-
super.unsubscribe();
|
|
3322
|
-
this.destination = null;
|
|
3323
|
-
}
|
|
3324
|
-
}
|
|
3325
|
-
_next(value) {
|
|
3326
|
-
this.destination.next(value);
|
|
3327
|
-
}
|
|
3328
|
-
_error(err) {
|
|
3329
|
-
try {
|
|
3330
|
-
this.destination.error(err);
|
|
3331
|
-
}
|
|
3332
|
-
finally {
|
|
3333
|
-
this.unsubscribe();
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
_complete() {
|
|
3337
|
-
try {
|
|
3338
|
-
this.destination.complete();
|
|
3339
|
-
}
|
|
3340
|
-
finally {
|
|
3341
|
-
this.unsubscribe();
|
|
3342
|
-
}
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
const _bind = Function.prototype.bind;
|
|
3346
|
-
function bind(fn, thisArg) {
|
|
3347
|
-
return _bind.call(fn, thisArg);
|
|
3348
|
-
}
|
|
3349
|
-
class ConsumerObserver {
|
|
3350
|
-
constructor(partialObserver) {
|
|
3351
|
-
this.partialObserver = partialObserver;
|
|
3352
|
-
}
|
|
3353
|
-
next(value) {
|
|
3354
|
-
const { partialObserver } = this;
|
|
3355
|
-
if (partialObserver.next) {
|
|
3356
|
-
try {
|
|
3357
|
-
partialObserver.next(value);
|
|
3358
|
-
}
|
|
3359
|
-
catch (error) {
|
|
3360
|
-
handleUnhandledError(error);
|
|
3361
|
-
}
|
|
3362
|
-
}
|
|
3363
|
-
}
|
|
3364
|
-
error(err) {
|
|
3365
|
-
const { partialObserver } = this;
|
|
3366
|
-
if (partialObserver.error) {
|
|
3367
|
-
try {
|
|
3368
|
-
partialObserver.error(err);
|
|
3369
|
-
}
|
|
3370
|
-
catch (error) {
|
|
3371
|
-
handleUnhandledError(error);
|
|
3372
|
-
}
|
|
3373
|
-
}
|
|
3374
|
-
else {
|
|
3375
|
-
handleUnhandledError(err);
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
complete() {
|
|
3379
|
-
const { partialObserver } = this;
|
|
3380
|
-
if (partialObserver.complete) {
|
|
3381
|
-
try {
|
|
3382
|
-
partialObserver.complete();
|
|
3383
|
-
}
|
|
3384
|
-
catch (error) {
|
|
3385
|
-
handleUnhandledError(error);
|
|
3386
|
-
}
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
}
|
|
3390
|
-
class SafeSubscriber extends Subscriber {
|
|
3391
|
-
constructor(observerOrNext, error, complete) {
|
|
3392
|
-
super();
|
|
3393
|
-
let partialObserver;
|
|
3394
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
3395
|
-
partialObserver = {
|
|
3396
|
-
next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined,
|
|
3397
|
-
error: error !== null && error !== void 0 ? error : undefined,
|
|
3398
|
-
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
3399
|
-
};
|
|
3400
|
-
}
|
|
3401
|
-
else {
|
|
3402
|
-
let context;
|
|
3403
|
-
if (this && config.useDeprecatedNextContext) {
|
|
3404
|
-
context = Object.create(observerOrNext);
|
|
3405
|
-
context.unsubscribe = () => this.unsubscribe();
|
|
3406
|
-
partialObserver = {
|
|
3407
|
-
next: observerOrNext.next && bind(observerOrNext.next, context),
|
|
3408
|
-
error: observerOrNext.error && bind(observerOrNext.error, context),
|
|
3409
|
-
complete: observerOrNext.complete && bind(observerOrNext.complete, context),
|
|
3410
|
-
};
|
|
3411
|
-
}
|
|
3412
|
-
else {
|
|
3413
|
-
partialObserver = observerOrNext;
|
|
3414
|
-
}
|
|
3415
|
-
}
|
|
3416
|
-
this.destination = new ConsumerObserver(partialObserver);
|
|
3417
|
-
}
|
|
3418
|
-
}
|
|
3419
|
-
function handleUnhandledError(error) {
|
|
3420
|
-
{
|
|
3421
|
-
reportUnhandledError(error);
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
function defaultErrorHandler(err) {
|
|
3425
|
-
throw err;
|
|
3426
|
-
}
|
|
3427
|
-
function handleStoppedNotification(notification, subscriber) {
|
|
3428
|
-
const { onStoppedNotification } = config;
|
|
3429
|
-
onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));
|
|
3430
|
-
}
|
|
3431
|
-
const EMPTY_OBSERVER = {
|
|
3432
|
-
closed: true,
|
|
3433
|
-
next: noop,
|
|
3434
|
-
error: defaultErrorHandler,
|
|
3435
|
-
complete: noop,
|
|
3436
|
-
};
|
|
3437
|
-
|
|
3438
|
-
const observable = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();
|
|
3439
|
-
|
|
3440
|
-
function identity(x) {
|
|
3441
|
-
return x;
|
|
3442
|
-
}
|
|
3443
|
-
|
|
3444
|
-
function pipeFromArray(fns) {
|
|
3445
|
-
if (fns.length === 0) {
|
|
3446
|
-
return identity;
|
|
3447
|
-
}
|
|
3448
|
-
if (fns.length === 1) {
|
|
3449
|
-
return fns[0];
|
|
3450
|
-
}
|
|
3451
|
-
return function piped(input) {
|
|
3452
|
-
return fns.reduce((prev, fn) => fn(prev), input);
|
|
3453
|
-
};
|
|
3454
|
-
}
|
|
3455
|
-
|
|
3456
|
-
class Observable {
|
|
3457
|
-
constructor(subscribe) {
|
|
3458
|
-
if (subscribe) {
|
|
3459
|
-
this._subscribe = subscribe;
|
|
3460
|
-
}
|
|
3461
|
-
}
|
|
3462
|
-
lift(operator) {
|
|
3463
|
-
const observable = new Observable();
|
|
3464
|
-
observable.source = this;
|
|
3465
|
-
observable.operator = operator;
|
|
3466
|
-
return observable;
|
|
3467
|
-
}
|
|
3468
|
-
subscribe(observerOrNext, error, complete) {
|
|
3469
|
-
const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
3470
|
-
errorContext(() => {
|
|
3471
|
-
const { operator, source } = this;
|
|
3472
|
-
subscriber.add(operator
|
|
3473
|
-
?
|
|
3474
|
-
operator.call(subscriber, source)
|
|
3475
|
-
: source
|
|
3476
|
-
?
|
|
3477
|
-
this._subscribe(subscriber)
|
|
3478
|
-
:
|
|
3479
|
-
this._trySubscribe(subscriber));
|
|
3480
|
-
});
|
|
3481
|
-
return subscriber;
|
|
3482
|
-
}
|
|
3483
|
-
_trySubscribe(sink) {
|
|
3484
|
-
try {
|
|
3485
|
-
return this._subscribe(sink);
|
|
3486
|
-
}
|
|
3487
|
-
catch (err) {
|
|
3488
|
-
sink.error(err);
|
|
3489
|
-
}
|
|
3490
|
-
}
|
|
3491
|
-
forEach(next, promiseCtor) {
|
|
3492
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
3493
|
-
return new promiseCtor((resolve, reject) => {
|
|
3494
|
-
const subscriber = new SafeSubscriber({
|
|
3495
|
-
next: (value) => {
|
|
3496
|
-
try {
|
|
3497
|
-
next(value);
|
|
3498
|
-
}
|
|
3499
|
-
catch (err) {
|
|
3500
|
-
reject(err);
|
|
3501
|
-
subscriber.unsubscribe();
|
|
3502
|
-
}
|
|
3503
|
-
},
|
|
3504
|
-
error: reject,
|
|
3505
|
-
complete: resolve,
|
|
3506
|
-
});
|
|
3507
|
-
this.subscribe(subscriber);
|
|
3508
|
-
});
|
|
3509
|
-
}
|
|
3510
|
-
_subscribe(subscriber) {
|
|
3511
|
-
var _a;
|
|
3512
|
-
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
3513
|
-
}
|
|
3514
|
-
[observable]() {
|
|
3515
|
-
return this;
|
|
3516
|
-
}
|
|
3517
|
-
pipe(...operations) {
|
|
3518
|
-
return pipeFromArray(operations)(this);
|
|
3519
|
-
}
|
|
3520
|
-
toPromise(promiseCtor) {
|
|
3521
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
3522
|
-
return new promiseCtor((resolve, reject) => {
|
|
3523
|
-
let value;
|
|
3524
|
-
this.subscribe((x) => (value = x), (err) => reject(err), () => resolve(value));
|
|
3525
|
-
});
|
|
3526
|
-
}
|
|
3527
|
-
}
|
|
3528
|
-
Observable.create = (subscribe) => {
|
|
3529
|
-
return new Observable(subscribe);
|
|
3530
|
-
};
|
|
3531
|
-
function getPromiseCtor(promiseCtor) {
|
|
3532
|
-
var _a;
|
|
3533
|
-
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
3534
|
-
}
|
|
3535
|
-
function isObserver(value) {
|
|
3536
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
3537
|
-
}
|
|
3538
|
-
function isSubscriber(value) {
|
|
3539
|
-
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
|
|
3540
|
-
}
|
|
3541
|
-
|
|
3542
|
-
function hasLift(source) {
|
|
3543
|
-
return isFunction(source === null || source === void 0 ? void 0 : source.lift);
|
|
3544
|
-
}
|
|
3545
|
-
function operate(init) {
|
|
3546
|
-
return (source) => {
|
|
3547
|
-
if (hasLift(source)) {
|
|
3548
|
-
return source.lift(function (liftedSource) {
|
|
3549
|
-
try {
|
|
3550
|
-
return init(liftedSource, this);
|
|
3551
|
-
}
|
|
3552
|
-
catch (err) {
|
|
3553
|
-
this.error(err);
|
|
3554
|
-
}
|
|
3555
|
-
});
|
|
3556
|
-
}
|
|
3557
|
-
throw new TypeError('Unable to lift unknown Observable type');
|
|
3558
|
-
};
|
|
3559
|
-
}
|
|
3560
|
-
|
|
3561
|
-
function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
|
|
3562
|
-
return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
|
|
3563
|
-
}
|
|
3564
|
-
class OperatorSubscriber extends Subscriber {
|
|
3565
|
-
constructor(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
|
|
3566
|
-
super(destination);
|
|
3567
|
-
this.onFinalize = onFinalize;
|
|
3568
|
-
this.shouldUnsubscribe = shouldUnsubscribe;
|
|
3569
|
-
this._next = onNext
|
|
3570
|
-
? function (value) {
|
|
3571
|
-
try {
|
|
3572
|
-
onNext(value);
|
|
3573
|
-
}
|
|
3574
|
-
catch (err) {
|
|
3575
|
-
destination.error(err);
|
|
3576
|
-
}
|
|
3577
|
-
}
|
|
3578
|
-
: super._next;
|
|
3579
|
-
this._error = onError
|
|
3580
|
-
? function (err) {
|
|
3581
|
-
try {
|
|
3582
|
-
onError(err);
|
|
3583
|
-
}
|
|
3584
|
-
catch (err) {
|
|
3585
|
-
destination.error(err);
|
|
3586
|
-
}
|
|
3587
|
-
finally {
|
|
3588
|
-
this.unsubscribe();
|
|
3589
|
-
}
|
|
3590
|
-
}
|
|
3591
|
-
: super._error;
|
|
3592
|
-
this._complete = onComplete
|
|
3593
|
-
? function () {
|
|
3594
|
-
try {
|
|
3595
|
-
onComplete();
|
|
3596
|
-
}
|
|
3597
|
-
catch (err) {
|
|
3598
|
-
destination.error(err);
|
|
3599
|
-
}
|
|
3600
|
-
finally {
|
|
3601
|
-
this.unsubscribe();
|
|
3602
|
-
}
|
|
3603
|
-
}
|
|
3604
|
-
: super._complete;
|
|
3605
|
-
}
|
|
3606
|
-
unsubscribe() {
|
|
3607
|
-
var _a;
|
|
3608
|
-
if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
|
|
3609
|
-
const { closed } = this;
|
|
3610
|
-
super.unsubscribe();
|
|
3611
|
-
!closed && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
}
|
|
3615
|
-
|
|
3616
|
-
const ObjectUnsubscribedError = createErrorClass((_super) => function ObjectUnsubscribedErrorImpl() {
|
|
3617
|
-
_super(this);
|
|
3618
|
-
this.name = 'ObjectUnsubscribedError';
|
|
3619
|
-
this.message = 'object unsubscribed';
|
|
3620
|
-
});
|
|
3621
|
-
|
|
3622
|
-
class Subject extends Observable {
|
|
3623
|
-
constructor() {
|
|
3624
|
-
super();
|
|
3625
|
-
this.closed = false;
|
|
3626
|
-
this.currentObservers = null;
|
|
3627
|
-
this.observers = [];
|
|
3628
|
-
this.isStopped = false;
|
|
3629
|
-
this.hasError = false;
|
|
3630
|
-
this.thrownError = null;
|
|
3631
|
-
}
|
|
3632
|
-
lift(operator) {
|
|
3633
|
-
const subject = new AnonymousSubject(this, this);
|
|
3634
|
-
subject.operator = operator;
|
|
3635
|
-
return subject;
|
|
3636
|
-
}
|
|
3637
|
-
_throwIfClosed() {
|
|
3638
|
-
if (this.closed) {
|
|
3639
|
-
throw new ObjectUnsubscribedError();
|
|
3640
|
-
}
|
|
3641
|
-
}
|
|
3642
|
-
next(value) {
|
|
3643
|
-
errorContext(() => {
|
|
3644
|
-
this._throwIfClosed();
|
|
3645
|
-
if (!this.isStopped) {
|
|
3646
|
-
if (!this.currentObservers) {
|
|
3647
|
-
this.currentObservers = Array.from(this.observers);
|
|
3648
|
-
}
|
|
3649
|
-
for (const observer of this.currentObservers) {
|
|
3650
|
-
observer.next(value);
|
|
3651
|
-
}
|
|
3652
|
-
}
|
|
3653
|
-
});
|
|
3654
|
-
}
|
|
3655
|
-
error(err) {
|
|
3656
|
-
errorContext(() => {
|
|
3657
|
-
this._throwIfClosed();
|
|
3658
|
-
if (!this.isStopped) {
|
|
3659
|
-
this.hasError = this.isStopped = true;
|
|
3660
|
-
this.thrownError = err;
|
|
3661
|
-
const { observers } = this;
|
|
3662
|
-
while (observers.length) {
|
|
3663
|
-
observers.shift().error(err);
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
});
|
|
3667
|
-
}
|
|
3668
|
-
complete() {
|
|
3669
|
-
errorContext(() => {
|
|
3670
|
-
this._throwIfClosed();
|
|
3671
|
-
if (!this.isStopped) {
|
|
3672
|
-
this.isStopped = true;
|
|
3673
|
-
const { observers } = this;
|
|
3674
|
-
while (observers.length) {
|
|
3675
|
-
observers.shift().complete();
|
|
3676
|
-
}
|
|
3677
|
-
}
|
|
3678
|
-
});
|
|
3679
|
-
}
|
|
3680
|
-
unsubscribe() {
|
|
3681
|
-
this.isStopped = this.closed = true;
|
|
3682
|
-
this.observers = this.currentObservers = null;
|
|
3683
|
-
}
|
|
3684
|
-
get observed() {
|
|
3685
|
-
var _a;
|
|
3686
|
-
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
3687
|
-
}
|
|
3688
|
-
_trySubscribe(subscriber) {
|
|
3689
|
-
this._throwIfClosed();
|
|
3690
|
-
return super._trySubscribe(subscriber);
|
|
3691
|
-
}
|
|
3692
|
-
_subscribe(subscriber) {
|
|
3693
|
-
this._throwIfClosed();
|
|
3694
|
-
this._checkFinalizedStatuses(subscriber);
|
|
3695
|
-
return this._innerSubscribe(subscriber);
|
|
3696
|
-
}
|
|
3697
|
-
_innerSubscribe(subscriber) {
|
|
3698
|
-
const { hasError, isStopped, observers } = this;
|
|
3699
|
-
if (hasError || isStopped) {
|
|
3700
|
-
return EMPTY_SUBSCRIPTION;
|
|
3701
|
-
}
|
|
3702
|
-
this.currentObservers = null;
|
|
3703
|
-
observers.push(subscriber);
|
|
3704
|
-
return new Subscription(() => {
|
|
3705
|
-
this.currentObservers = null;
|
|
3706
|
-
arrRemove(observers, subscriber);
|
|
3707
|
-
});
|
|
3708
|
-
}
|
|
3709
|
-
_checkFinalizedStatuses(subscriber) {
|
|
3710
|
-
const { hasError, thrownError, isStopped } = this;
|
|
3711
|
-
if (hasError) {
|
|
3712
|
-
subscriber.error(thrownError);
|
|
3713
|
-
}
|
|
3714
|
-
else if (isStopped) {
|
|
3715
|
-
subscriber.complete();
|
|
3716
|
-
}
|
|
3717
|
-
}
|
|
3718
|
-
asObservable() {
|
|
3719
|
-
const observable = new Observable();
|
|
3720
|
-
observable.source = this;
|
|
3721
|
-
return observable;
|
|
3722
|
-
}
|
|
3723
|
-
}
|
|
3724
|
-
Subject.create = (destination, source) => {
|
|
3725
|
-
return new AnonymousSubject(destination, source);
|
|
3726
|
-
};
|
|
3727
|
-
class AnonymousSubject extends Subject {
|
|
3728
|
-
constructor(destination, source) {
|
|
3729
|
-
super();
|
|
3730
|
-
this.destination = destination;
|
|
3731
|
-
this.source = source;
|
|
3732
|
-
}
|
|
3733
|
-
next(value) {
|
|
3734
|
-
var _a, _b;
|
|
3735
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
|
|
3736
|
-
}
|
|
3737
|
-
error(err) {
|
|
3738
|
-
var _a, _b;
|
|
3739
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
3740
|
-
}
|
|
3741
|
-
complete() {
|
|
3742
|
-
var _a, _b;
|
|
3743
|
-
(_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3744
|
-
}
|
|
3745
|
-
_subscribe(subscriber) {
|
|
3746
|
-
var _a, _b;
|
|
3747
|
-
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
|
|
3748
|
-
}
|
|
3749
|
-
}
|
|
3750
|
-
|
|
3751
|
-
const EMPTY = new Observable((subscriber) => subscriber.complete());
|
|
3752
|
-
|
|
3753
|
-
function isScheduler(value) {
|
|
3754
|
-
return value && isFunction(value.schedule);
|
|
3755
|
-
}
|
|
3756
|
-
|
|
3757
|
-
function last(arr) {
|
|
3758
|
-
return arr[arr.length - 1];
|
|
3759
|
-
}
|
|
3760
|
-
function popScheduler(args) {
|
|
3761
|
-
return isScheduler(last(args)) ? args.pop() : undefined;
|
|
3762
|
-
}
|
|
3763
|
-
function popNumber(args, defaultValue) {
|
|
3764
|
-
return typeof last(args) === 'number' ? args.pop() : defaultValue;
|
|
3765
|
-
}
|
|
3766
|
-
|
|
3767
|
-
/******************************************************************************
|
|
3768
|
-
Copyright (c) Microsoft Corporation.
|
|
3769
|
-
|
|
3770
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
3771
|
-
purpose with or without fee is hereby granted.
|
|
3772
|
-
|
|
3773
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
3774
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
3775
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
3776
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
3777
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3778
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3779
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
3780
|
-
***************************************************************************** */
|
|
3781
|
-
|
|
3782
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
3783
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3784
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3785
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
3786
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
3787
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
3788
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
3789
|
-
});
|
|
3790
|
-
}
|
|
3791
|
-
|
|
3792
|
-
function __values(o) {
|
|
3793
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3794
|
-
if (m) return m.call(o);
|
|
3795
|
-
if (o && typeof o.length === "number") return {
|
|
3796
|
-
next: function () {
|
|
3797
|
-
if (o && i >= o.length) o = void 0;
|
|
3798
|
-
return { value: o && o[i++], done: !o };
|
|
3799
|
-
}
|
|
3800
|
-
};
|
|
3801
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
3802
|
-
}
|
|
3803
|
-
|
|
3804
|
-
function __await(v) {
|
|
3805
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
3806
|
-
}
|
|
3807
|
-
|
|
3808
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
3809
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
3810
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
3811
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
3812
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
3813
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
3814
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
3815
|
-
function fulfill(value) { resume("next", value); }
|
|
3816
|
-
function reject(value) { resume("throw", value); }
|
|
3817
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
3818
|
-
}
|
|
3819
|
-
|
|
3820
|
-
function __asyncValues(o) {
|
|
3821
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
3822
|
-
var m = o[Symbol.asyncIterator], i;
|
|
3823
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
3824
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
3825
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
3826
|
-
}
|
|
3827
|
-
|
|
3828
|
-
const isArrayLike = ((x) => x && typeof x.length === 'number' && typeof x !== 'function');
|
|
3829
|
-
|
|
3830
|
-
function isPromise(value) {
|
|
3831
|
-
return isFunction(value === null || value === void 0 ? void 0 : value.then);
|
|
3832
|
-
}
|
|
3833
|
-
|
|
3834
|
-
function isInteropObservable(input) {
|
|
3835
|
-
return isFunction(input[observable]);
|
|
3836
|
-
}
|
|
3837
|
-
|
|
3838
|
-
function isAsyncIterable(obj) {
|
|
3839
|
-
return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
|
|
3840
|
-
}
|
|
3841
|
-
|
|
3842
|
-
function createInvalidObservableTypeError(input) {
|
|
3843
|
-
return new TypeError(`You provided ${input !== null && typeof input === 'object' ? 'an invalid object' : `'${input}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`);
|
|
3844
|
-
}
|
|
3845
|
-
|
|
3846
|
-
function getSymbolIterator() {
|
|
3847
|
-
if (typeof Symbol !== 'function' || !Symbol.iterator) {
|
|
3848
|
-
return '@@iterator';
|
|
3849
|
-
}
|
|
3850
|
-
return Symbol.iterator;
|
|
3851
|
-
}
|
|
3852
|
-
const iterator = getSymbolIterator();
|
|
3853
|
-
|
|
3854
|
-
function isIterable(input) {
|
|
3855
|
-
return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
|
|
3856
|
-
}
|
|
3857
|
-
|
|
3858
|
-
function readableStreamLikeToAsyncGenerator(readableStream) {
|
|
3859
|
-
return __asyncGenerator(this, arguments, function* readableStreamLikeToAsyncGenerator_1() {
|
|
3860
|
-
const reader = readableStream.getReader();
|
|
3861
|
-
try {
|
|
3862
|
-
while (true) {
|
|
3863
|
-
const { value, done } = yield __await(reader.read());
|
|
3864
|
-
if (done) {
|
|
3865
|
-
return yield __await(void 0);
|
|
3866
|
-
}
|
|
3867
|
-
yield yield __await(value);
|
|
3868
|
-
}
|
|
3869
|
-
}
|
|
3870
|
-
finally {
|
|
3871
|
-
reader.releaseLock();
|
|
3872
|
-
}
|
|
3873
|
-
});
|
|
3874
|
-
}
|
|
3875
|
-
function isReadableStreamLike(obj) {
|
|
3876
|
-
return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
|
|
3877
|
-
}
|
|
3878
|
-
|
|
3879
|
-
function innerFrom(input) {
|
|
3880
|
-
if (input instanceof Observable) {
|
|
3881
|
-
return input;
|
|
3882
|
-
}
|
|
3883
|
-
if (input != null) {
|
|
3884
|
-
if (isInteropObservable(input)) {
|
|
3885
|
-
return fromInteropObservable(input);
|
|
3886
|
-
}
|
|
3887
|
-
if (isArrayLike(input)) {
|
|
3888
|
-
return fromArrayLike(input);
|
|
3889
|
-
}
|
|
3890
|
-
if (isPromise(input)) {
|
|
3891
|
-
return fromPromise(input);
|
|
3892
|
-
}
|
|
3893
|
-
if (isAsyncIterable(input)) {
|
|
3894
|
-
return fromAsyncIterable(input);
|
|
3895
|
-
}
|
|
3896
|
-
if (isIterable(input)) {
|
|
3897
|
-
return fromIterable(input);
|
|
3898
|
-
}
|
|
3899
|
-
if (isReadableStreamLike(input)) {
|
|
3900
|
-
return fromReadableStreamLike(input);
|
|
3901
|
-
}
|
|
3902
|
-
}
|
|
3903
|
-
throw createInvalidObservableTypeError(input);
|
|
3904
|
-
}
|
|
3905
|
-
function fromInteropObservable(obj) {
|
|
3906
|
-
return new Observable((subscriber) => {
|
|
3907
|
-
const obs = obj[observable]();
|
|
3908
|
-
if (isFunction(obs.subscribe)) {
|
|
3909
|
-
return obs.subscribe(subscriber);
|
|
3910
|
-
}
|
|
3911
|
-
throw new TypeError('Provided object does not correctly implement Symbol.observable');
|
|
3912
|
-
});
|
|
3913
|
-
}
|
|
3914
|
-
function fromArrayLike(array) {
|
|
3915
|
-
return new Observable((subscriber) => {
|
|
3916
|
-
for (let i = 0; i < array.length && !subscriber.closed; i++) {
|
|
3917
|
-
subscriber.next(array[i]);
|
|
3918
|
-
}
|
|
3919
|
-
subscriber.complete();
|
|
3920
|
-
});
|
|
3921
|
-
}
|
|
3922
|
-
function fromPromise(promise) {
|
|
3923
|
-
return new Observable((subscriber) => {
|
|
3924
|
-
promise
|
|
3925
|
-
.then((value) => {
|
|
3926
|
-
if (!subscriber.closed) {
|
|
3927
|
-
subscriber.next(value);
|
|
3928
|
-
subscriber.complete();
|
|
3929
|
-
}
|
|
3930
|
-
}, (err) => subscriber.error(err))
|
|
3931
|
-
.then(null, reportUnhandledError);
|
|
3932
|
-
});
|
|
3933
|
-
}
|
|
3934
|
-
function fromIterable(iterable) {
|
|
3935
|
-
return new Observable((subscriber) => {
|
|
3936
|
-
for (const value of iterable) {
|
|
3937
|
-
subscriber.next(value);
|
|
3938
|
-
if (subscriber.closed) {
|
|
3939
|
-
return;
|
|
3940
|
-
}
|
|
3941
|
-
}
|
|
3942
|
-
subscriber.complete();
|
|
3943
|
-
});
|
|
3944
|
-
}
|
|
3945
|
-
function fromAsyncIterable(asyncIterable) {
|
|
3946
|
-
return new Observable((subscriber) => {
|
|
3947
|
-
process(asyncIterable, subscriber).catch((err) => subscriber.error(err));
|
|
3948
|
-
});
|
|
3949
|
-
}
|
|
3950
|
-
function fromReadableStreamLike(readableStream) {
|
|
3951
|
-
return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
|
|
3952
|
-
}
|
|
3953
|
-
function process(asyncIterable, subscriber) {
|
|
3954
|
-
var asyncIterable_1, asyncIterable_1_1;
|
|
3955
|
-
var e_1, _a;
|
|
3956
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
3957
|
-
try {
|
|
3958
|
-
for (asyncIterable_1 = __asyncValues(asyncIterable); asyncIterable_1_1 = yield asyncIterable_1.next(), !asyncIterable_1_1.done;) {
|
|
3959
|
-
const value = asyncIterable_1_1.value;
|
|
3960
|
-
subscriber.next(value);
|
|
3961
|
-
if (subscriber.closed) {
|
|
3962
|
-
return;
|
|
3963
|
-
}
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
3966
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3967
|
-
finally {
|
|
3968
|
-
try {
|
|
3969
|
-
if (asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return)) yield _a.call(asyncIterable_1);
|
|
3970
|
-
}
|
|
3971
|
-
finally { if (e_1) throw e_1.error; }
|
|
3972
|
-
}
|
|
3973
|
-
subscriber.complete();
|
|
3974
|
-
});
|
|
3975
|
-
}
|
|
3976
|
-
|
|
3977
|
-
function executeSchedule(parentSubscription, scheduler, work, delay = 0, repeat = false) {
|
|
3978
|
-
const scheduleSubscription = scheduler.schedule(function () {
|
|
3979
|
-
work();
|
|
3980
|
-
if (repeat) {
|
|
3981
|
-
parentSubscription.add(this.schedule(null, delay));
|
|
3982
|
-
}
|
|
3983
|
-
else {
|
|
3984
|
-
this.unsubscribe();
|
|
3985
|
-
}
|
|
3986
|
-
}, delay);
|
|
3987
|
-
parentSubscription.add(scheduleSubscription);
|
|
3988
|
-
if (!repeat) {
|
|
3989
|
-
return scheduleSubscription;
|
|
3990
|
-
}
|
|
3991
|
-
}
|
|
3992
|
-
|
|
3993
|
-
function observeOn(scheduler, delay = 0) {
|
|
3994
|
-
return operate((source, subscriber) => {
|
|
3995
|
-
source.subscribe(createOperatorSubscriber(subscriber, (value) => executeSchedule(subscriber, scheduler, () => subscriber.next(value), delay), () => executeSchedule(subscriber, scheduler, () => subscriber.complete(), delay), (err) => executeSchedule(subscriber, scheduler, () => subscriber.error(err), delay)));
|
|
3996
|
-
});
|
|
3997
|
-
}
|
|
3998
|
-
|
|
3999
|
-
function subscribeOn(scheduler, delay = 0) {
|
|
4000
|
-
return operate((source, subscriber) => {
|
|
4001
|
-
subscriber.add(scheduler.schedule(() => source.subscribe(subscriber), delay));
|
|
4002
|
-
});
|
|
4003
|
-
}
|
|
4004
|
-
|
|
4005
|
-
function scheduleObservable(input, scheduler) {
|
|
4006
|
-
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
4007
|
-
}
|
|
4008
|
-
|
|
4009
|
-
function schedulePromise(input, scheduler) {
|
|
4010
|
-
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
4011
|
-
}
|
|
4012
|
-
|
|
4013
|
-
function scheduleArray(input, scheduler) {
|
|
4014
|
-
return new Observable((subscriber) => {
|
|
4015
|
-
let i = 0;
|
|
4016
|
-
return scheduler.schedule(function () {
|
|
4017
|
-
if (i === input.length) {
|
|
4018
|
-
subscriber.complete();
|
|
4019
|
-
}
|
|
4020
|
-
else {
|
|
4021
|
-
subscriber.next(input[i++]);
|
|
4022
|
-
if (!subscriber.closed) {
|
|
4023
|
-
this.schedule();
|
|
4024
|
-
}
|
|
4025
|
-
}
|
|
4026
|
-
});
|
|
4027
|
-
});
|
|
4028
|
-
}
|
|
4029
|
-
|
|
4030
|
-
function scheduleIterable(input, scheduler) {
|
|
4031
|
-
return new Observable((subscriber) => {
|
|
4032
|
-
let iterator$1;
|
|
4033
|
-
executeSchedule(subscriber, scheduler, () => {
|
|
4034
|
-
iterator$1 = input[iterator]();
|
|
4035
|
-
executeSchedule(subscriber, scheduler, () => {
|
|
4036
|
-
let value;
|
|
4037
|
-
let done;
|
|
4038
|
-
try {
|
|
4039
|
-
({ value, done } = iterator$1.next());
|
|
4040
|
-
}
|
|
4041
|
-
catch (err) {
|
|
4042
|
-
subscriber.error(err);
|
|
4043
|
-
return;
|
|
4044
|
-
}
|
|
4045
|
-
if (done) {
|
|
4046
|
-
subscriber.complete();
|
|
4047
|
-
}
|
|
4048
|
-
else {
|
|
4049
|
-
subscriber.next(value);
|
|
4050
|
-
}
|
|
4051
|
-
}, 0, true);
|
|
4052
|
-
});
|
|
4053
|
-
return () => isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return();
|
|
4054
|
-
});
|
|
4055
|
-
}
|
|
4056
|
-
|
|
4057
|
-
function scheduleAsyncIterable(input, scheduler) {
|
|
4058
|
-
if (!input) {
|
|
4059
|
-
throw new Error('Iterable cannot be null');
|
|
4060
|
-
}
|
|
4061
|
-
return new Observable((subscriber) => {
|
|
4062
|
-
executeSchedule(subscriber, scheduler, () => {
|
|
4063
|
-
const iterator = input[Symbol.asyncIterator]();
|
|
4064
|
-
executeSchedule(subscriber, scheduler, () => {
|
|
4065
|
-
iterator.next().then((result) => {
|
|
4066
|
-
if (result.done) {
|
|
4067
|
-
subscriber.complete();
|
|
4068
|
-
}
|
|
4069
|
-
else {
|
|
4070
|
-
subscriber.next(result.value);
|
|
4071
|
-
}
|
|
4072
|
-
});
|
|
4073
|
-
}, 0, true);
|
|
4074
|
-
});
|
|
4075
|
-
});
|
|
4076
|
-
}
|
|
4077
|
-
|
|
4078
|
-
function scheduleReadableStreamLike(input, scheduler) {
|
|
4079
|
-
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
|
4080
|
-
}
|
|
4081
|
-
|
|
4082
|
-
function scheduled(input, scheduler) {
|
|
4083
|
-
if (input != null) {
|
|
4084
|
-
if (isInteropObservable(input)) {
|
|
4085
|
-
return scheduleObservable(input, scheduler);
|
|
4086
|
-
}
|
|
4087
|
-
if (isArrayLike(input)) {
|
|
4088
|
-
return scheduleArray(input, scheduler);
|
|
4089
|
-
}
|
|
4090
|
-
if (isPromise(input)) {
|
|
4091
|
-
return schedulePromise(input, scheduler);
|
|
4092
|
-
}
|
|
4093
|
-
if (isAsyncIterable(input)) {
|
|
4094
|
-
return scheduleAsyncIterable(input, scheduler);
|
|
4095
|
-
}
|
|
4096
|
-
if (isIterable(input)) {
|
|
4097
|
-
return scheduleIterable(input, scheduler);
|
|
4098
|
-
}
|
|
4099
|
-
if (isReadableStreamLike(input)) {
|
|
4100
|
-
return scheduleReadableStreamLike(input, scheduler);
|
|
4101
|
-
}
|
|
4102
|
-
}
|
|
4103
|
-
throw createInvalidObservableTypeError(input);
|
|
4104
|
-
}
|
|
4105
|
-
|
|
4106
|
-
function from(input, scheduler) {
|
|
4107
|
-
return scheduler ? scheduled(input, scheduler) : innerFrom(input);
|
|
4108
|
-
}
|
|
4109
|
-
|
|
4110
|
-
function map(project, thisArg) {
|
|
4111
|
-
return operate((source, subscriber) => {
|
|
4112
|
-
let index = 0;
|
|
4113
|
-
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
|
|
4114
|
-
subscriber.next(project.call(thisArg, value, index++));
|
|
4115
|
-
}));
|
|
4116
|
-
});
|
|
4117
|
-
}
|
|
4118
|
-
|
|
4119
|
-
const { isArray } = Array;
|
|
4120
|
-
function callOrApply(fn, args) {
|
|
4121
|
-
return isArray(args) ? fn(...args) : fn(args);
|
|
4122
|
-
}
|
|
4123
|
-
function mapOneOrManyArgs(fn) {
|
|
4124
|
-
return map(args => callOrApply(fn, args));
|
|
4125
|
-
}
|
|
4126
|
-
|
|
4127
|
-
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
4128
|
-
const buffer = [];
|
|
4129
|
-
let active = 0;
|
|
4130
|
-
let index = 0;
|
|
4131
|
-
let isComplete = false;
|
|
4132
|
-
const checkComplete = () => {
|
|
4133
|
-
if (isComplete && !buffer.length && !active) {
|
|
4134
|
-
subscriber.complete();
|
|
4135
|
-
}
|
|
4136
|
-
};
|
|
4137
|
-
const outerNext = (value) => (active < concurrent ? doInnerSub(value) : buffer.push(value));
|
|
4138
|
-
const doInnerSub = (value) => {
|
|
4139
|
-
expand && subscriber.next(value);
|
|
4140
|
-
active++;
|
|
4141
|
-
let innerComplete = false;
|
|
4142
|
-
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, (innerValue) => {
|
|
4143
|
-
onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
|
|
4144
|
-
if (expand) {
|
|
4145
|
-
outerNext(innerValue);
|
|
4146
|
-
}
|
|
4147
|
-
else {
|
|
4148
|
-
subscriber.next(innerValue);
|
|
4149
|
-
}
|
|
4150
|
-
}, () => {
|
|
4151
|
-
innerComplete = true;
|
|
4152
|
-
}, undefined, () => {
|
|
4153
|
-
if (innerComplete) {
|
|
4154
|
-
try {
|
|
4155
|
-
active--;
|
|
4156
|
-
while (buffer.length && active < concurrent) {
|
|
4157
|
-
const bufferedValue = buffer.shift();
|
|
4158
|
-
if (innerSubScheduler) {
|
|
4159
|
-
executeSchedule(subscriber, innerSubScheduler, () => doInnerSub(bufferedValue));
|
|
4160
|
-
}
|
|
4161
|
-
else {
|
|
4162
|
-
doInnerSub(bufferedValue);
|
|
4163
|
-
}
|
|
4164
|
-
}
|
|
4165
|
-
checkComplete();
|
|
4166
|
-
}
|
|
4167
|
-
catch (err) {
|
|
4168
|
-
subscriber.error(err);
|
|
4169
|
-
}
|
|
4170
|
-
}
|
|
4171
|
-
}));
|
|
4172
|
-
};
|
|
4173
|
-
source.subscribe(createOperatorSubscriber(subscriber, outerNext, () => {
|
|
4174
|
-
isComplete = true;
|
|
4175
|
-
checkComplete();
|
|
4176
|
-
}));
|
|
4177
|
-
return () => {
|
|
4178
|
-
additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
|
|
4179
|
-
};
|
|
4180
|
-
}
|
|
4181
|
-
|
|
4182
|
-
function mergeMap(project, resultSelector, concurrent = Infinity) {
|
|
4183
|
-
if (isFunction(resultSelector)) {
|
|
4184
|
-
return mergeMap((a, i) => map((b, ii) => resultSelector(a, b, i, ii))(innerFrom(project(a, i))), concurrent);
|
|
4185
|
-
}
|
|
4186
|
-
else if (typeof resultSelector === 'number') {
|
|
4187
|
-
concurrent = resultSelector;
|
|
4188
|
-
}
|
|
4189
|
-
return operate((source, subscriber) => mergeInternals(source, subscriber, project, concurrent));
|
|
4190
|
-
}
|
|
4191
|
-
|
|
4192
|
-
function mergeAll(concurrent = Infinity) {
|
|
4193
|
-
return mergeMap(identity, concurrent);
|
|
4194
|
-
}
|
|
4195
|
-
|
|
4196
|
-
const nodeEventEmitterMethods = ['addListener', 'removeListener'];
|
|
4197
|
-
const eventTargetMethods = ['addEventListener', 'removeEventListener'];
|
|
4198
|
-
const jqueryMethods = ['on', 'off'];
|
|
4199
|
-
function fromEvent(target, eventName, options, resultSelector) {
|
|
4200
|
-
if (isFunction(options)) {
|
|
4201
|
-
resultSelector = options;
|
|
4202
|
-
options = undefined;
|
|
4203
|
-
}
|
|
4204
|
-
if (resultSelector) {
|
|
4205
|
-
return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector));
|
|
4206
|
-
}
|
|
4207
|
-
const [add, remove] = isEventTarget(target)
|
|
4208
|
-
? eventTargetMethods.map((methodName) => (handler) => target[methodName](eventName, handler, options))
|
|
4209
|
-
:
|
|
4210
|
-
isNodeStyleEventEmitter(target)
|
|
4211
|
-
? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName))
|
|
4212
|
-
: isJQueryStyleEventEmitter(target)
|
|
4213
|
-
? jqueryMethods.map(toCommonHandlerRegistry(target, eventName))
|
|
4214
|
-
: [];
|
|
4215
|
-
if (!add) {
|
|
4216
|
-
if (isArrayLike(target)) {
|
|
4217
|
-
return mergeMap((subTarget) => fromEvent(subTarget, eventName, options))(innerFrom(target));
|
|
4218
|
-
}
|
|
4219
|
-
}
|
|
4220
|
-
if (!add) {
|
|
4221
|
-
throw new TypeError('Invalid event target');
|
|
4222
|
-
}
|
|
4223
|
-
return new Observable((subscriber) => {
|
|
4224
|
-
const handler = (...args) => subscriber.next(1 < args.length ? args : args[0]);
|
|
4225
|
-
add(handler);
|
|
4226
|
-
return () => remove(handler);
|
|
4227
|
-
});
|
|
4228
|
-
}
|
|
4229
|
-
function toCommonHandlerRegistry(target, eventName) {
|
|
4230
|
-
return (methodName) => (handler) => target[methodName](eventName, handler);
|
|
4231
|
-
}
|
|
4232
|
-
function isNodeStyleEventEmitter(target) {
|
|
4233
|
-
return isFunction(target.addListener) && isFunction(target.removeListener);
|
|
4234
|
-
}
|
|
4235
|
-
function isJQueryStyleEventEmitter(target) {
|
|
4236
|
-
return isFunction(target.on) && isFunction(target.off);
|
|
4237
|
-
}
|
|
4238
|
-
function isEventTarget(target) {
|
|
4239
|
-
return isFunction(target.addEventListener) && isFunction(target.removeEventListener);
|
|
4240
|
-
}
|
|
4241
|
-
|
|
4242
|
-
function merge(...args) {
|
|
4243
|
-
const scheduler = popScheduler(args);
|
|
4244
|
-
const concurrent = popNumber(args, Infinity);
|
|
4245
|
-
const sources = args;
|
|
4246
|
-
return !sources.length
|
|
4247
|
-
?
|
|
4248
|
-
EMPTY
|
|
4249
|
-
: sources.length === 1
|
|
4250
|
-
?
|
|
4251
|
-
innerFrom(sources[0])
|
|
4252
|
-
:
|
|
4253
|
-
mergeAll(concurrent)(from(sources, scheduler));
|
|
4254
|
-
}
|
|
4255
|
-
|
|
4256
|
-
function filter(predicate, thisArg) {
|
|
4257
|
-
return operate((source, subscriber) => {
|
|
4258
|
-
let index = 0;
|
|
4259
|
-
source.subscribe(createOperatorSubscriber(subscriber, (value) => predicate.call(thisArg, value, index++) && subscriber.next(value)));
|
|
4260
|
-
});
|
|
4261
|
-
}
|
|
4262
|
-
|
|
4263
|
-
function distinctUntilChanged(comparator, keySelector = identity) {
|
|
4264
|
-
comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;
|
|
4265
|
-
return operate((source, subscriber) => {
|
|
4266
|
-
let previousKey;
|
|
4267
|
-
let first = true;
|
|
4268
|
-
source.subscribe(createOperatorSubscriber(subscriber, (value) => {
|
|
4269
|
-
const currentKey = keySelector(value);
|
|
4270
|
-
if (first || !comparator(previousKey, currentKey)) {
|
|
4271
|
-
first = false;
|
|
4272
|
-
previousKey = currentKey;
|
|
4273
|
-
subscriber.next(value);
|
|
4274
|
-
}
|
|
4275
|
-
}));
|
|
4276
|
-
});
|
|
4277
|
-
}
|
|
4278
|
-
function defaultCompare(a, b) {
|
|
4279
|
-
return a === b;
|
|
4280
|
-
}
|
|
4281
|
-
|
|
4282
|
-
function takeUntil(notifier) {
|
|
4283
|
-
return operate((source, subscriber) => {
|
|
4284
|
-
innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, () => subscriber.complete(), noop));
|
|
4285
|
-
!subscriber.closed && source.subscribe(subscriber);
|
|
4286
|
-
});
|
|
4287
|
-
}
|
|
4288
|
-
|
|
4289
|
-
const catScrollableCss = ":host{overflow:hidden;position:relative;display:flex}:host([hidden]){display:none}.shadow-bottom,.shadow-right,.shadow-left,.shadow-top{position:absolute;transition:box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1)}.shadow-top{z-index:2;width:100%;top:0}.shadow-left{z-index:4;height:100%;left:0}.shadow-right{z-index:4;height:100%;right:0}.shadow-bottom{z-index:2;width:100%;bottom:0}.scrollable-wrapper{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none}.scrollable-wrapper.cat-scrollable-top .shadow-top,.scrollable-wrapper.cat-scrollable-bottom .shadow-bottom,.scrollable-wrapper.cat-scrollable-left .shadow-left,.scrollable-wrapper.cat-scrollable-right .shadow-right{box-shadow:0 0 4px 1px rgba(16, 29, 48, 0.2)}.scrollable-content{overflow:hidden;white-space:nowrap}.scrollable-content.scroll-x{overflow-x:auto}.scrollable-content.scroll-y{overflow-y:auto}.scrollable-content.no-overscroll{overscroll-behavior:contain}";
|
|
4290
|
-
|
|
4291
|
-
const CatScrollable = class {
|
|
4292
|
-
constructor(hostRef) {
|
|
4293
|
-
registerInstance(this, hostRef);
|
|
4294
|
-
this.scrolledTop = createEvent(this, "scrolledTop", 7);
|
|
4295
|
-
this.scrolledLeft = createEvent(this, "scrolledLeft", 7);
|
|
4296
|
-
this.scrolledRight = createEvent(this, "scrolledRight", 7);
|
|
4297
|
-
this.scrolledBottom = createEvent(this, "scrolledBottom", 7);
|
|
4298
|
-
this.init = new Subject();
|
|
4299
|
-
this.destroyed = new Subject();
|
|
4300
|
-
/** Flags to disable/enable scroll shadowX. */
|
|
4301
|
-
this.noShadowX = false;
|
|
4302
|
-
/** Flags to disable/enable scroll shadowY. */
|
|
4303
|
-
this.noShadowY = false;
|
|
4304
|
-
/** Flags to disable/enable overflowX. */
|
|
4305
|
-
this.noOverflowX = false;
|
|
4306
|
-
/** Flags to disable/enable overflowY. */
|
|
4307
|
-
this.noOverflowY = false;
|
|
4308
|
-
/** Flag to disable/enable overscroll behavior. */
|
|
4309
|
-
this.noOverscroll = false;
|
|
4310
|
-
/**
|
|
4311
|
-
* Flag to not fire an initial event after content initialization.
|
|
4312
|
-
*/
|
|
4313
|
-
this.noScrolledInit = false;
|
|
4314
|
-
/**
|
|
4315
|
-
* Buffer to be used to calculate the scroll distance.
|
|
4316
|
-
*/
|
|
4317
|
-
this.scrolledBuffer = 0;
|
|
4318
|
-
}
|
|
4319
|
-
componentDidRender() {
|
|
4320
|
-
if (this.scrollElement) {
|
|
4321
|
-
this.scrolled = fromEvent(this.scrollElement, 'scroll').pipe(takeUntil(this.destroyed));
|
|
4322
|
-
}
|
|
4323
|
-
this.attachEmitter('left', this.scrolledLeft, this.scrolledBuffer);
|
|
4324
|
-
this.attachEmitter('right', this.scrolledRight, this.scrolledBuffer);
|
|
4325
|
-
this.attachEmitter('bottom', this.scrolledBottom, this.scrolledBuffer);
|
|
4326
|
-
this.attachEmitter('top', this.scrolledTop, this.scrolledBuffer);
|
|
4327
|
-
merge(this.init, this.scrolled)
|
|
4328
|
-
.pipe(map(() => ({
|
|
4329
|
-
top: this.getScrollOffset('top') > 0,
|
|
4330
|
-
left: this.getScrollOffset('left') > 0,
|
|
4331
|
-
right: this.getScrollOffset('right') > 0,
|
|
4332
|
-
bottom: this.getScrollOffset('bottom') > 0
|
|
4333
|
-
})), distinctUntilChanged(), takeUntil(this.destroyed))
|
|
4334
|
-
.subscribe(({ top, left, right, bottom }) => {
|
|
4335
|
-
this.toggleClass('cat-scrollable-top', top);
|
|
4336
|
-
this.toggleClass('cat-scrollable-left', left);
|
|
4337
|
-
this.toggleClass('cat-scrollable-right', right);
|
|
4338
|
-
this.toggleClass('cat-scrollable-bottom', bottom);
|
|
4339
|
-
});
|
|
4340
|
-
}
|
|
4341
|
-
componentDidLoad() {
|
|
4342
|
-
if (!this.noScrolledInit) {
|
|
4343
|
-
this.init.next();
|
|
4344
|
-
}
|
|
4345
|
-
}
|
|
4346
|
-
disconnectedCallback() {
|
|
4347
|
-
this.init.complete();
|
|
4348
|
-
this.destroyed.next();
|
|
4349
|
-
this.destroyed.complete();
|
|
4350
|
-
}
|
|
4351
|
-
render() {
|
|
4352
|
-
return [
|
|
4353
|
-
h("div", { class: "scrollable-wrapper", ref: el => (this.scrollWrapperElement = el) }, !this.noShadowY && h("div", { class: "shadow-top" }), !this.noShadowX && h("div", { class: "shadow-left" }), !this.noShadowX && h("div", { class: "shadow-right" }), !this.noShadowY && h("div", { class: "shadow-bottom" })),
|
|
4354
|
-
h("div", { ref: el => (this.scrollElement = el), class: {
|
|
4355
|
-
'scrollable-content': true,
|
|
4356
|
-
'scroll-x': !this.noOverflowX,
|
|
4357
|
-
'scroll-y': !this.noOverflowY,
|
|
4358
|
-
'no-overscroll': this.noOverscroll
|
|
4359
|
-
} }, h("slot", null))
|
|
4360
|
-
];
|
|
4361
|
-
}
|
|
4362
|
-
attachEmitter(from, emitter, buffer) {
|
|
4363
|
-
merge(this.init, this.scrolled)
|
|
4364
|
-
.pipe(map(() => this.getScrollOffset(from)))
|
|
4365
|
-
.pipe(map(offset => offset <= buffer))
|
|
4366
|
-
.pipe(distinctUntilChanged())
|
|
4367
|
-
.pipe(filter(isLower => isLower))
|
|
4368
|
-
.pipe(takeUntil(this.destroyed))
|
|
4369
|
-
.subscribe(() => emitter.emit());
|
|
4370
|
-
}
|
|
4371
|
-
getScrollOffset(from) {
|
|
4372
|
-
if (this.scrollElement) {
|
|
4373
|
-
switch (from) {
|
|
4374
|
-
case 'top':
|
|
4375
|
-
return this.scrollElement.scrollTop;
|
|
4376
|
-
case 'left':
|
|
4377
|
-
return this.scrollElement.scrollLeft;
|
|
4378
|
-
case 'right':
|
|
4379
|
-
return this.scrollElement.scrollWidth - this.scrollElement.clientWidth - this.scrollElement.scrollLeft;
|
|
4380
|
-
case 'bottom':
|
|
4381
|
-
return this.scrollElement.scrollHeight - this.scrollElement.clientHeight - this.scrollElement.scrollTop;
|
|
4382
|
-
default:
|
|
4383
|
-
return 0;
|
|
4384
|
-
}
|
|
4385
|
-
}
|
|
4386
|
-
return 0;
|
|
4387
|
-
}
|
|
4388
|
-
toggleClass(name, value) {
|
|
4389
|
-
var _a, _b;
|
|
4390
|
-
if (value) {
|
|
4391
|
-
(_a = this.scrollWrapperElement) === null || _a === void 0 ? void 0 : _a.classList.add(name);
|
|
4392
|
-
}
|
|
4393
|
-
else {
|
|
4394
|
-
(_b = this.scrollWrapperElement) === null || _b === void 0 ? void 0 : _b.classList.remove(name);
|
|
4395
|
-
}
|
|
4396
|
-
}
|
|
4397
|
-
};
|
|
4398
|
-
CatScrollable.style = catScrollableCss;
|
|
4399
|
-
|
|
4400
|
-
const catSkeletonCss = ":host{display:flex;flex-direction:column;position:relative;--background:#ebecf0;--highlight:#d7dbe0;--speed:2s}:host([variant=square]),:host([variant=circle]){display:inline-flex}:host([hidden]){display:none}:host([variant=head]){margin-bottom:0.5rem}:host([variant=body]){margin-bottom:1rem}.skeleton{display:block;border-radius:0.25rem;background:var(--background)}.skeleton-circle{border-radius:10rem}.skeleton-xs.skeleton-rectangle{width:var(--width, 100%);height:var(--height, 1.5rem)}.skeleton-xs.skeleton-square,.skeleton-xs.skeleton-circle{width:var(--width, 1.5rem);height:var(--height, 1.5rem)}.skeleton-xs.skeleton-head,.skeleton-xs.skeleton-body{width:var(--width, var(--line-width, 100%))}.skeleton-xs.skeleton-head{height:calc(0.9375rem - 4px);margin:calc((1.25rem - 0.9375rem + 4px) * 0.5) 0}.skeleton-xs.skeleton-body{height:calc(0.75rem - 4px);margin:calc((1rem - 0.75rem + 4px) * 0.5) 0}.skeleton-s.skeleton-rectangle{width:var(--width, 100%);height:var(--height, 2rem)}.skeleton-s.skeleton-square,.skeleton-s.skeleton-circle{width:var(--width, 2rem);height:var(--height, 2rem)}.skeleton-s.skeleton-head,.skeleton-s.skeleton-body{width:var(--width, var(--line-width, 100%))}.skeleton-s.skeleton-head{height:calc(1.125rem - 4px);margin:calc((1.5rem - 1.125rem + 4px) * 0.5) 0}.skeleton-s.skeleton-body{height:calc(0.875rem - 4px);margin:calc((1rem - 0.875rem + 4px) * 0.5) 0}.skeleton-m.skeleton-rectangle{width:var(--width, 100%);height:var(--height, 2.5rem)}.skeleton-m.skeleton-square,.skeleton-m.skeleton-circle{width:var(--width, 2.5rem);height:var(--height, 2.5rem)}.skeleton-m.skeleton-head,.skeleton-m.skeleton-body{width:var(--width, var(--line-width, 100%))}.skeleton-m.skeleton-head{height:calc(1.25rem - 4px);margin:calc((1.5rem - 1.25rem + 4px) * 0.5) 0}.skeleton-m.skeleton-body{height:calc(0.9375rem - 4px);margin:calc((1.25rem - 0.9375rem + 4px) * 0.5) 0}.skeleton-l.skeleton-rectangle{width:var(--width, 100%);height:var(--height, 3rem)}.skeleton-l.skeleton-square,.skeleton-l.skeleton-circle{width:var(--width, 3rem);height:var(--height, 3rem)}.skeleton-l.skeleton-head,.skeleton-l.skeleton-body{width:var(--width, var(--line-width, 100%))}.skeleton-l.skeleton-head{height:calc(1.5rem - 4px);margin:calc((1.75rem - 1.5rem + 4px) * 0.5) 0}.skeleton-l.skeleton-body{height:calc(1.125rem - 4px);margin:calc((1.5rem - 1.125rem + 4px) * 0.5) 0}.skeleton-xl.skeleton-rectangle{width:var(--width, 100%);height:var(--height, 3.5rem)}.skeleton-xl.skeleton-square,.skeleton-xl.skeleton-circle{width:var(--width, 3.5rem);height:var(--height, 3.5rem)}.skeleton-xl.skeleton-head,.skeleton-xl.skeleton-body{width:var(--width, var(--line-width, 100%))}.skeleton-xl.skeleton-head{height:calc(1.75rem - 4px);margin:calc((2rem - 1.75rem + 4px) * 0.5) 0}.skeleton-xl.skeleton-body{height:calc(1.25rem - 4px);margin:calc((1.5rem - 1.25rem + 4px) * 0.5) 0}.skeleton-sheen{background:linear-gradient(90deg, var(--background) 33%, var(--highlight) 50%, var(--background) 66%) var(--background);background-size:300% 100%;animation:sheen var(--speed) ease-in-out infinite}.skeleton-pulse{position:relative;overflow:hidden}.skeleton-pulse::before{content:\"\";display:block;position:absolute;width:100%;height:100%;background-color:var(--highlight);animation:var(--speed) ease-in-out 0.5s infinite normal none running pulse;opacity:0}@keyframes sheen{0%{background-position:right}}@keyframes pulse{50%{opacity:1}}";
|
|
4401
|
-
|
|
4402
|
-
const CatSkeleton = class {
|
|
4403
|
-
constructor(hostRef) {
|
|
4404
|
-
registerInstance(this, hostRef);
|
|
4405
|
-
/**
|
|
4406
|
-
* The animation style of the skeleton.
|
|
4407
|
-
*/
|
|
4408
|
-
this.effect = 'sheen';
|
|
4409
|
-
/**
|
|
4410
|
-
* The rendering style of the skeleton.
|
|
4411
|
-
*/
|
|
4412
|
-
this.variant = 'rectangle';
|
|
4413
|
-
/**
|
|
4414
|
-
* The size of the skeleton. If the variant is set to "head", the size values
|
|
4415
|
-
* "xs" to "xl" translate to the head levels `h1` to `h5`.
|
|
4416
|
-
*/
|
|
4417
|
-
this.size = 'm';
|
|
4418
|
-
}
|
|
4419
|
-
render() {
|
|
4420
|
-
return (h(Host, null, Array.from(Array(this.count)).map(() => (h("div", { style: this.style, class: {
|
|
4421
|
-
skeleton: true,
|
|
4422
|
-
[`skeleton-${this.effect}`]: Boolean(this.effect),
|
|
4423
|
-
[`skeleton-${this.variant}`]: Boolean(this.variant),
|
|
4424
|
-
[`skeleton-${this.size}`]: Boolean(this.size)
|
|
4425
|
-
} })))));
|
|
4426
|
-
}
|
|
4427
|
-
get count() {
|
|
4428
|
-
switch (this.variant) {
|
|
4429
|
-
case 'head':
|
|
4430
|
-
return Math.max(1, this.lines || 1);
|
|
4431
|
-
case 'body':
|
|
4432
|
-
return Math.max(1, this.lines || 3);
|
|
4433
|
-
default:
|
|
4434
|
-
return 1;
|
|
4435
|
-
}
|
|
4436
|
-
}
|
|
4437
|
-
get style() {
|
|
4438
|
-
return this.variant === 'head' || this.variant === 'body'
|
|
4439
|
-
? {
|
|
4440
|
-
'--line-width': `${this.random(50, 100)}%`
|
|
4441
|
-
}
|
|
4442
|
-
: undefined;
|
|
4443
|
-
}
|
|
4444
|
-
random(min, max) {
|
|
4445
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
4446
|
-
}
|
|
4447
|
-
};
|
|
4448
|
-
CatSkeleton.style = catSkeletonCss;
|
|
4449
|
-
|
|
4450
|
-
const catSpinnerCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host[hidden]{display:none}span{display:inline-flex}svg{fill:none;stroke:currentColor;stroke-dasharray:135px;stroke-dashoffset:95px;stroke-linecap:round;stroke-width:5px;transform-origin:center center;animation:spin 0.75s cubic-bezier(0.4, 0.15, 0.6, 0.85) infinite;width:1em;height:1em}.spinner-xs svg{font-size:0.75rem}.spinner-s svg{font-size:1rem}.spinner-m svg{font-size:1.25rem}.spinner-l svg{font-size:1.5rem}.spinner-xl svg{font-size:1.75rem}@keyframes spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}";
|
|
4451
|
-
|
|
4452
|
-
const CatSpinner = class {
|
|
4453
|
-
constructor(hostRef) {
|
|
4454
|
-
registerInstance(this, hostRef);
|
|
4455
|
-
/**
|
|
4456
|
-
* The size of the spinner.
|
|
4457
|
-
*/
|
|
4458
|
-
this.size = 'm';
|
|
4459
|
-
}
|
|
4460
|
-
render() {
|
|
4461
|
-
return (h("span", { "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', class: {
|
|
4462
|
-
[`spinner-${this.size}`]: this.size !== 'inline'
|
|
4463
|
-
} }, h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48" }, h("circle", { cx: "24", cy: "24", r: "21.5" }))));
|
|
4464
|
-
}
|
|
4465
|
-
};
|
|
4466
|
-
CatSpinner.style = catSpinnerCss;
|
|
4467
|
-
|
|
4468
|
-
const catTabCss = ":host{display:block}:host([hidden]){display:none}";
|
|
4469
|
-
|
|
4470
|
-
let nextUniqueId$2 = 0;
|
|
4471
|
-
const CatTab = class {
|
|
4472
|
-
constructor(hostRef) {
|
|
4473
|
-
registerInstance(this, hostRef);
|
|
4474
|
-
this.tabClick = createEvent(this, "tabClick", 7);
|
|
4475
|
-
/**
|
|
4476
|
-
* The label of the tab.
|
|
4477
|
-
*/
|
|
4478
|
-
this.label = '';
|
|
4479
|
-
/**
|
|
4480
|
-
* Hide the actual button content and only display the tab.
|
|
4481
|
-
*/
|
|
4482
|
-
this.iconOnly = false;
|
|
4483
|
-
/**
|
|
4484
|
-
* Display the icon on the right.
|
|
4485
|
-
*/
|
|
4486
|
-
this.iconRight = false;
|
|
4487
|
-
/**
|
|
4488
|
-
* Specifies that the tab should be deactivated.
|
|
4489
|
-
*/
|
|
4490
|
-
this.deactivated = false;
|
|
4491
|
-
}
|
|
4492
|
-
connectedCallback() {
|
|
4493
|
-
if (!this.hostElement.id) {
|
|
4494
|
-
this.hostElement.id = `cat-tab-${nextUniqueId$2++}`;
|
|
4495
|
-
}
|
|
4496
|
-
}
|
|
4497
|
-
onClick(event) {
|
|
4498
|
-
this.tabClick.emit(event);
|
|
4499
|
-
}
|
|
4500
|
-
render() {
|
|
4501
|
-
return h(Host, null);
|
|
4502
|
-
}
|
|
4503
|
-
get hostElement() { return getElement(this); }
|
|
4504
|
-
};
|
|
4505
|
-
CatTab.style = catTabCss;
|
|
4506
|
-
|
|
4507
|
-
const catTabsCss = ":host{display:flex;flex-direction:row;box-shadow:inset 0 -1px 0 0 #d7dbe0}:host([hidden]){display:none}:host([tabs-align=center]){justify-content:center}:host([tabs-align=right]){justify-content:end}:host([tabs-align=justify]) cat-button{flex:1 0 auto}.tab{padding:0.5rem}.tab.tab-active{box-shadow:inset 0 -3px 0 0 #207f8a}";
|
|
4508
|
-
|
|
4509
|
-
const CatTabs = class {
|
|
4510
|
-
constructor(hostRef) {
|
|
4511
|
-
registerInstance(this, hostRef);
|
|
4512
|
-
this.tabs = [];
|
|
4513
|
-
this.buttons = [];
|
|
4514
|
-
/**
|
|
4515
|
-
* The ID of the active tab.
|
|
4516
|
-
*/
|
|
4517
|
-
this.activeTab = '';
|
|
4518
|
-
/**
|
|
4519
|
-
* The alignment of the tabs.
|
|
4520
|
-
*/
|
|
4521
|
-
this.tabsAlign = 'left';
|
|
4522
|
-
}
|
|
4523
|
-
onActiveTabChanged(newActiveTab) {
|
|
4524
|
-
const activeTab = this.tabs.find(value => value.id === newActiveTab);
|
|
4525
|
-
activeTab === null || activeTab === void 0 ? void 0 : activeTab.click();
|
|
4526
|
-
}
|
|
4527
|
-
componentWillLoad() {
|
|
4528
|
-
this.tabs = Array.from(this.hostElement.querySelectorAll('cat-tab'));
|
|
4529
|
-
if (this.tabs.length) {
|
|
4530
|
-
this.activeTabId = this.activeTab;
|
|
4531
|
-
}
|
|
4532
|
-
}
|
|
4533
|
-
onKeydown(event) {
|
|
4534
|
-
var _a;
|
|
4535
|
-
if (['ArrowDown', 'ArrowUp', 'ArrowRight', 'ArrowLeft'].includes(event.key)) {
|
|
4536
|
-
const targetElements = this.buttons.filter(button => !button.disabled);
|
|
4537
|
-
const activeElement = (_a = this.hostElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement;
|
|
4538
|
-
const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
|
|
4539
|
-
const activeOff = ['ArrowDown', 'ArrowRight'].includes(event.key) ? 1 : -1;
|
|
4540
|
-
const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
|
|
4541
|
-
targetElements[targetIdx].setFocus();
|
|
4542
|
-
event.preventDefault();
|
|
4543
|
-
}
|
|
4544
|
-
}
|
|
4545
|
-
render() {
|
|
4546
|
-
return (h(Host, null, this.tabs.map((tab) => {
|
|
4547
|
-
return (h("cat-button", { ref: el => el && this.updateButtonsRef(el), buttonId: tab.id, role: "tab", part: "tab", class: {
|
|
4548
|
-
tab: true,
|
|
4549
|
-
'tab-active': Boolean(this.activeTabId && tab.id === this.activeTabId)
|
|
4550
|
-
}, color: this.activeTabId && tab.id === this.activeTabId ? 'primary' : 'secondary', variant: "text", icon: tab.icon, iconOnly: tab.iconOnly, iconRight: tab.iconRight, url: tab.url, disabled: tab.deactivated, urlTarget: tab.urlTarget, onCatClick: () => (this.activeTabId = tab.id) }, tab.label));
|
|
4551
|
-
})));
|
|
4552
|
-
}
|
|
4553
|
-
updateButtonsRef(button) {
|
|
4554
|
-
const indexOf = this.buttons.indexOf(button);
|
|
4555
|
-
if (indexOf >= 0) {
|
|
4556
|
-
this.buttons[indexOf] = button;
|
|
4557
|
-
}
|
|
4558
|
-
else {
|
|
4559
|
-
this.buttons.push(button);
|
|
4560
|
-
}
|
|
4561
|
-
}
|
|
4562
|
-
get hostElement() { return getElement(this); }
|
|
4563
|
-
static get watchers() { return {
|
|
4564
|
-
"activeTabId": ["onActiveTabChanged"]
|
|
4565
|
-
}; }
|
|
4566
|
-
};
|
|
4567
|
-
CatTabs.style = catTabsCss;
|
|
4568
|
-
|
|
4569
|
-
const catToastDemoCss = ":host{display:block}";
|
|
4570
|
-
|
|
4571
|
-
const CatToastDemo = class {
|
|
4572
|
-
constructor(hostRef) {
|
|
4573
|
-
registerInstance(this, hostRef);
|
|
4574
|
-
}
|
|
4575
|
-
render() {
|
|
4576
|
-
return h("cat-button", { onClick: this.onClick.bind(this) }, "Show Notifications");
|
|
4577
|
-
}
|
|
4578
|
-
onClick() {
|
|
4579
|
-
const infoOptions = {
|
|
4580
|
-
position: 'top-left'
|
|
4581
|
-
};
|
|
4582
|
-
const errorOptions = {
|
|
4583
|
-
position: 'top-center',
|
|
4584
|
-
type: 'error'
|
|
4585
|
-
};
|
|
4586
|
-
const errorOptions2 = {
|
|
4587
|
-
position: 'bottom-left',
|
|
4588
|
-
type: 'error'
|
|
4589
|
-
};
|
|
4590
|
-
const successOptions3 = {
|
|
4591
|
-
position: 'bottom-right',
|
|
4592
|
-
type: 'success'
|
|
4593
|
-
};
|
|
4594
|
-
const template = document.createElement('template');
|
|
4595
|
-
template.innerHTML = `<div style="padding: 7px 30px 7px 10px">Custom HTML Node Content</div>`;
|
|
4596
|
-
const successOptions4 = {
|
|
4597
|
-
position: 'bottom-right',
|
|
4598
|
-
type: 'success',
|
|
4599
|
-
content: template.content.firstChild
|
|
4600
|
-
};
|
|
4601
|
-
NotificationsService.error('Default Click');
|
|
4602
|
-
NotificationsService.error('Long default title, long default title, long default title, long default title');
|
|
4603
|
-
NotificationsService.info('Info Click', 'Info message', infoOptions);
|
|
4604
|
-
NotificationsService.success('', ' ', successOptions4);
|
|
4605
|
-
NotificationsService.error('Error Title', ' ', errorOptions);
|
|
4606
|
-
NotificationsService.error('Error 2 Title', 'Very long message, Very long message, Very long message, Very long message, Very long message, Very long message, Very long message, Very long message, Very long message, Very long message,Very long message, Very long message, Very long message, Very long message, Very long message, ', errorOptions2);
|
|
4607
|
-
NotificationsService.success('Success Title - very long title without message', ' ', successOptions3);
|
|
4608
|
-
}
|
|
4609
|
-
};
|
|
4610
|
-
CatToastDemo.style = catToastDemoCss;
|
|
4611
|
-
|
|
4612
|
-
const catToggleCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;margin:0}:host{display:flex;flex-direction:column;gap:0.5rem;margin-bottom:1rem}:host([hidden]){display:none}label{flex:0 1 auto;display:flex;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;-webkit-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer}input{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.toggle{flex:0 0 auto;display:flex;align-items:center;justify-content:center;position:relative;width:2rem;height:1.25rem;border-radius:10rem;background-color:#d7dbe0;transition:background-color 0.13s ease}:checked+.toggle{background-color:rgb(var(--cat-primary-bg, 32, 127, 138))}:focus-visible+.toggle{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:1px}.toggle::after{content:\"\";position:absolute;width:1rem;height:1rem;background:#fff;border-radius:10rem;transform:translateX(calc(2px - 0.5rem));transition:transform 0.13s linear;box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2)}:checked+.toggle::after{transform:translateX(calc(-2px + 0.5rem))}.label{flex:1 1 auto}.is-hidden .label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.is-disabled{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
|
|
4613
|
-
|
|
4614
|
-
let nextUniqueId$1 = 0;
|
|
4615
|
-
const CatToggle = class {
|
|
4616
|
-
constructor(hostRef) {
|
|
4617
|
-
registerInstance(this, hostRef);
|
|
4618
|
-
this.catChange = createEvent(this, "catChange", 7);
|
|
4619
|
-
this.catFocus = createEvent(this, "catFocus", 7);
|
|
4620
|
-
this.catBlur = createEvent(this, "catBlur", 7);
|
|
4621
|
-
this.id = `cat-toggle-${nextUniqueId$1++}`;
|
|
4622
|
-
this.hasSlottedLabel = false;
|
|
4623
|
-
/**
|
|
4624
|
-
* Checked state of the toggle.
|
|
4625
|
-
*/
|
|
4626
|
-
this.checked = false;
|
|
4627
|
-
/**
|
|
4628
|
-
* Disabled state of the toggle.
|
|
4629
|
-
*/
|
|
4630
|
-
this.disabled = false;
|
|
4631
|
-
/**
|
|
4632
|
-
* The label of the toggle that is visible.
|
|
4633
|
-
*/
|
|
4634
|
-
this.label = '';
|
|
4635
|
-
/**
|
|
4636
|
-
* Visually hide the label, but still show it to assistive technologies like screen readers.
|
|
4637
|
-
*/
|
|
4638
|
-
this.labelHidden = false;
|
|
4639
|
-
/**
|
|
4640
|
-
* Required state of the toggle
|
|
4641
|
-
*/
|
|
4642
|
-
this.required = false;
|
|
4643
|
-
}
|
|
4644
|
-
componentWillRender() {
|
|
4645
|
-
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
4646
|
-
if (!this.label && !this.hasSlottedLabel) {
|
|
4647
|
-
loglevel.error('[A11y] Missing ARIA label on toggle', this);
|
|
4648
|
-
}
|
|
4649
|
-
}
|
|
4650
|
-
/**
|
|
4651
|
-
* Sets focus on the toggle. Use this method instead of `toggle.focus()`.
|
|
4652
|
-
*
|
|
4653
|
-
* @param options An optional object providing options to control aspects of
|
|
4654
|
-
* the focusing process.
|
|
4655
|
-
*/
|
|
4656
|
-
async setFocus(options) {
|
|
4657
|
-
this.input.focus(options);
|
|
4658
|
-
}
|
|
4659
|
-
render() {
|
|
4660
|
-
return (h(Host, null, h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } }, h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, class: "form-check-input", role: "switch", onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }), h("span", { class: "toggle", part: "toggle" }), h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)), this.hintSection));
|
|
4661
|
-
}
|
|
4662
|
-
get hintSection() {
|
|
4663
|
-
const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
|
|
4664
|
-
return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
|
|
4665
|
-
}
|
|
4666
|
-
onInput(event) {
|
|
4667
|
-
this.value = this.input.value;
|
|
4668
|
-
this.catChange.emit(event);
|
|
4669
|
-
}
|
|
4670
|
-
onFocus(event) {
|
|
4671
|
-
this.catFocus.emit(event);
|
|
4672
|
-
}
|
|
4673
|
-
onBlur(event) {
|
|
4674
|
-
this.catBlur.emit(event);
|
|
4675
|
-
}
|
|
4676
|
-
get hostElement() { return getElement(this); }
|
|
4677
|
-
};
|
|
4678
|
-
CatToggle.style = catToggleCss;
|
|
4679
|
-
|
|
4680
|
-
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
4681
|
-
|
|
4682
|
-
const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;font-weight:500;padding:0.75rem;background-color:white;border-radius:0.25rem;color:black;transition:opacity 0.25s linear, visibility 0.25s linear;visibility:hidden;opacity:0;box-shadow:rgba(0, 0, 0, 0.08) 0 1px 8px 0;border:1px solid #ebecf0;z-index:200;max-width:16rem}.tooltip-show{opacity:1;visibility:visible}.tooltip-trigger{display:inline-block}.tooltip-trigger:focus{outline:none}";
|
|
4683
|
-
|
|
4684
|
-
let nextUniqueId = 0;
|
|
4685
|
-
const CatTooltip = class {
|
|
4686
|
-
constructor(hostRef) {
|
|
4687
|
-
registerInstance(this, hostRef);
|
|
4688
|
-
this.id = `cat-tooltip-${nextUniqueId++}`;
|
|
4689
|
-
/**
|
|
4690
|
-
* The content of the tooltip.
|
|
4691
|
-
*/
|
|
4692
|
-
this.content = '';
|
|
4693
|
-
/**
|
|
4694
|
-
* Specifies that the tooltip should be disabled. A disabled tooltip is unusable,
|
|
4695
|
-
* and invisible. Corresponds with the native HTML disabled attribute.
|
|
4696
|
-
*/
|
|
4697
|
-
this.disabled = false;
|
|
4698
|
-
/**
|
|
4699
|
-
* The placement of the tooltip.
|
|
4700
|
-
*/
|
|
4701
|
-
this.placement = 'top';
|
|
4702
|
-
/**
|
|
4703
|
-
* The delay time for showing tooltip in ms.
|
|
4704
|
-
*/
|
|
4705
|
-
this.showDelay = 500;
|
|
4706
|
-
/**
|
|
4707
|
-
* The delay time for hiding tooltip in ms.
|
|
4708
|
-
*/
|
|
4709
|
-
this.hideDelay = 0;
|
|
4710
|
-
/**
|
|
4711
|
-
* The duration of tap to show the tooltip.
|
|
4712
|
-
*/
|
|
4713
|
-
this.longTouchDuration = 1000;
|
|
4714
|
-
}
|
|
4715
|
-
handleKeyDown({ key }) {
|
|
4716
|
-
key === 'Escape' && this.hideListener();
|
|
4717
|
-
}
|
|
4718
|
-
componentDidLoad() {
|
|
4719
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4720
|
-
this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;
|
|
4721
|
-
if (!this.isTabbable) {
|
|
4722
|
-
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
|
|
4723
|
-
}
|
|
4724
|
-
if (this.trigger && this.tooltip) {
|
|
4725
|
-
autoUpdate(this.trigger, this.tooltip, () => this.update());
|
|
4726
|
-
}
|
|
4727
|
-
if (isTouchDevice) {
|
|
4728
|
-
window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));
|
|
4729
|
-
(_b = this.trigger) === null || _b === void 0 ? void 0 : _b.addEventListener('touchstart', this.touchStartListener.bind(this));
|
|
4730
|
-
(_c = this.trigger) === null || _c === void 0 ? void 0 : _c.addEventListener('touchend', this.touchEndListener.bind(this));
|
|
4731
|
-
}
|
|
4732
|
-
else {
|
|
4733
|
-
(_d = this.trigger) === null || _d === void 0 ? void 0 : _d.addEventListener('focusin', this.showListener.bind(this));
|
|
4734
|
-
(_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('focusout', this.hideListener.bind(this));
|
|
4735
|
-
(_f = this.trigger) === null || _f === void 0 ? void 0 : _f.addEventListener('mouseenter', this.showListener.bind(this));
|
|
4736
|
-
(_g = this.trigger) === null || _g === void 0 ? void 0 : _g.addEventListener('mouseleave', this.hideListener.bind(this));
|
|
4737
|
-
}
|
|
4738
|
-
}
|
|
4739
|
-
disconnectedCallback() {
|
|
4740
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4741
|
-
if (isTouchDevice) {
|
|
4742
|
-
window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));
|
|
4743
|
-
(_a = this.trigger) === null || _a === void 0 ? void 0 : _a.removeEventListener('touchstart', this.touchStartListener.bind(this));
|
|
4744
|
-
(_b = this.trigger) === null || _b === void 0 ? void 0 : _b.removeEventListener('touchend', this.touchEndListener.bind(this));
|
|
4745
|
-
}
|
|
4746
|
-
else {
|
|
4747
|
-
(_c = this.trigger) === null || _c === void 0 ? void 0 : _c.removeEventListener('mouseenter', this.showListener.bind(this));
|
|
4748
|
-
(_d = this.trigger) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseleave', this.hideListener.bind(this));
|
|
4749
|
-
(_e = this.trigger) === null || _e === void 0 ? void 0 : _e.removeEventListener('focusin', this.showListener.bind(this));
|
|
4750
|
-
(_f = this.trigger) === null || _f === void 0 ? void 0 : _f.removeEventListener('focusout', this.hideListener.bind(this));
|
|
4751
|
-
}
|
|
4752
|
-
}
|
|
4753
|
-
render() {
|
|
4754
|
-
return (h(Host, null, h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, h("slot", null)), this.content && !this.disabled && (h("div", { ref: el => (this.tooltip = el), id: this.id, class: "tooltip" }, this.content))));
|
|
4755
|
-
}
|
|
4756
|
-
get isTabbable() {
|
|
4757
|
-
return firstTabbable(this.trigger);
|
|
4758
|
-
}
|
|
4759
|
-
update() {
|
|
4760
|
-
if (this.trigger && this.tooltip) {
|
|
4761
|
-
computePosition(this.trigger, this.tooltip, {
|
|
4762
|
-
placement: this.placement,
|
|
4763
|
-
middleware: [offset(CatTooltip.OFFSET), flip()]
|
|
4764
|
-
}).then(({ x, y }) => {
|
|
4765
|
-
if (this.tooltip) {
|
|
4766
|
-
Object.assign(this.tooltip.style, {
|
|
4767
|
-
left: `${Math.max(0, x)}px`,
|
|
4768
|
-
top: `${y}px`
|
|
4769
|
-
});
|
|
4770
|
-
}
|
|
4771
|
-
});
|
|
4772
|
-
}
|
|
4773
|
-
}
|
|
4774
|
-
showListener() {
|
|
4775
|
-
window.clearTimeout(this.hideTimeout);
|
|
4776
|
-
this.showTimeout = window.setTimeout(() => {
|
|
4777
|
-
var _a;
|
|
4778
|
-
(_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
|
|
4779
|
-
}, this.showDelay);
|
|
4780
|
-
}
|
|
4781
|
-
hideListener() {
|
|
4782
|
-
window.clearTimeout(this.showTimeout);
|
|
4783
|
-
this.hideTimeout = window.setTimeout(() => {
|
|
4784
|
-
var _a;
|
|
4785
|
-
(_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
|
|
4786
|
-
}, this.hideDelay);
|
|
4787
|
-
}
|
|
4788
|
-
touchStartListener(event) {
|
|
4789
|
-
event.stopPropagation();
|
|
4790
|
-
this.touchTimeout = window.setTimeout(() => {
|
|
4791
|
-
var _a;
|
|
4792
|
-
(_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
|
|
4793
|
-
}, this.longTouchDuration);
|
|
4794
|
-
}
|
|
4795
|
-
touchEndListener() {
|
|
4796
|
-
if (this.touchTimeout) {
|
|
4797
|
-
window.clearTimeout(this.touchTimeout);
|
|
4798
|
-
}
|
|
4799
|
-
}
|
|
4800
|
-
windowTouchStartListener() {
|
|
4801
|
-
var _a;
|
|
4802
|
-
(_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
|
|
4803
|
-
}
|
|
4804
|
-
};
|
|
4805
|
-
CatTooltip.OFFSET = 4;
|
|
4806
|
-
CatTooltip.style = catTooltipCss;
|
|
4807
|
-
|
|
4808
|
-
export { CatAlert as cat_alert, CatAvatar as cat_avatar, CatBadge as cat_badge, CatButton as cat_button, CatCard as cat_card, CatCheckbox as cat_checkbox, CatIcon as cat_icon, CatInput as cat_input, CatMenu as cat_menu, CatRadio as cat_radio, CatScrollable as cat_scrollable, CatSkeleton as cat_skeleton, CatSpinner as cat_spinner, CatTab as cat_tab, CatTabs as cat_tabs, CatToastDemo as cat_toast_demo, CatToggle as cat_toggle, CatTooltip as cat_tooltip };
|
|
4809
|
-
|
|
4810
|
-
//# sourceMappingURL=cat-alert_18.entry.js.map
|