@haiilo/catalyst 0.7.2 → 0.8.0

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