@nanahoshi/mona-ui 0.27.2 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/api/chart.md +2 -2
- package/docs/api/locales.md +8 -0
- package/docs/api/popup.md +1 -1
- package/docs/api/theme.md +2 -2
- package/docs/chart.md +14 -0
- package/docs/editor.md +2 -0
- package/docs/installation.md +147 -15
- package/docs/introduction.md +37 -15
- package/docs/theming-built-in-themes.md +67 -0
- package/docs/theming-custom-colors.md +274 -0
- package/docs/theming-custom-themes.md +168 -0
- package/docs/theming.md +164 -248
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
- package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2071 -1573
- package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
- package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
- package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
- package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
- package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
- package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
- package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +599 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales.mjs +61 -77
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
- package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
- package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
- package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
- package/llms.txt +7 -3
- package/locales/pl-pl/package.json +4 -0
- package/locales/pl-pl/pl-pl.messages.json +536 -0
- package/package.json +66 -23
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
- package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
- package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
- package/types/nanahoshi-mona-ui-button.d.ts +227 -166
- package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
- package/types/nanahoshi-mona-ui-card.d.ts +125 -111
- package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
- package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
- package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
- package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
- package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
- package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
- package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
- package/types/nanahoshi-mona-ui-command.d.ts +279 -191
- package/types/nanahoshi-mona-ui-common.d.ts +354 -385
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
- package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
- package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
- package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
- package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
- package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
- package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
- package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
- package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
- package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
- package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
- package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
- package/types/nanahoshi-mona-ui-label.d.ts +108 -78
- package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
- package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
- package/types/nanahoshi-mona-ui-list.d.ts +2 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +540 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales.d.ts +18 -19
- package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
- package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
- package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
- package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
- package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
- package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
- package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
- package/types/nanahoshi-mona-ui-query.d.ts +82 -88
- package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
- package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
- package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
- package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
- package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
- package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
- package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
- package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
- package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
- package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
- package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
- package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
- package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
- package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
- package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
- package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
- package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
- package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
- package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
- package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
- package/types/nanahoshi-mona-ui-window.d.ts +494 -399
- package/types/nanahoshi-mona-ui.d.ts +1 -2
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
|
@@ -1,162 +1,183 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { DOCUMENT, DestroyRef, Directive, ElementRef, InjectionToken, Renderer2, afterEveryRender, computed, effect, inject, input, signal, untracked } from "@angular/core";
|
|
3
|
+
import { Observable, debounceTime, filter, map, merge, scan, take, timer } from "rxjs";
|
|
4
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
5
|
+
var AttributeBinderDirective = class AttributeBinderDirective {
|
|
6
|
+
#element;
|
|
7
|
+
#previousKeys;
|
|
8
|
+
#renderer;
|
|
9
|
+
constructor() {
|
|
10
|
+
this.#element = inject(ElementRef);
|
|
11
|
+
this.#previousKeys = /* @__PURE__ */ new Set();
|
|
12
|
+
this.#renderer = inject(Renderer2);
|
|
13
|
+
this.attributes = input({}, {
|
|
14
|
+
...ngDevMode ? { debugName: "attributes" } : /* istanbul ignore next */ {},
|
|
15
|
+
alias: "monaAttributeBinder"
|
|
16
|
+
});
|
|
17
|
+
effect(() => {
|
|
18
|
+
const attributes = this.attributes();
|
|
19
|
+
const nextKeys = new Set(Object.keys(attributes));
|
|
20
|
+
for (const prevKey of this.#previousKeys) if (!nextKeys.has(prevKey)) this.#renderer.removeAttribute(this.#element.nativeElement, prevKey);
|
|
21
|
+
for (const [key, value] of Object.entries(attributes)) if (value == null || value === false) this.#renderer.removeAttribute(this.#element.nativeElement, key);
|
|
22
|
+
else {
|
|
23
|
+
const attributeValue = typeof value === "boolean" ? String(value) : value;
|
|
24
|
+
this.#renderer.setAttribute(this.#element.nativeElement, key, attributeValue);
|
|
25
|
+
}
|
|
26
|
+
this.#previousKeys.clear();
|
|
27
|
+
for (const key of nextKeys) this.#previousKeys.add(key);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
static {
|
|
31
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
32
|
+
minVersion: "12.0.0",
|
|
33
|
+
version: "22.2.6",
|
|
34
|
+
ngImport: i0,
|
|
35
|
+
type: AttributeBinderDirective,
|
|
36
|
+
deps: [],
|
|
37
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
static {
|
|
41
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
42
|
+
minVersion: "17.1.0",
|
|
43
|
+
version: "22.2.6",
|
|
44
|
+
type: AttributeBinderDirective,
|
|
45
|
+
isStandalone: true,
|
|
46
|
+
selector: "[monaAttributeBinder]",
|
|
47
|
+
inputs: { attributes: {
|
|
48
|
+
classPropertyName: "attributes",
|
|
49
|
+
publicName: "monaAttributeBinder",
|
|
50
|
+
isSignal: true,
|
|
51
|
+
isRequired: false,
|
|
52
|
+
transformFunction: null
|
|
53
|
+
} },
|
|
54
|
+
ngImport: i0
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
59
|
+
minVersion: "12.0.0",
|
|
60
|
+
version: "22.2.6",
|
|
61
|
+
ngImport: i0,
|
|
62
|
+
type: AttributeBinderDirective,
|
|
63
|
+
decorators: [{
|
|
64
|
+
type: Directive,
|
|
65
|
+
args: [{ selector: "[monaAttributeBinder]" }]
|
|
66
|
+
}],
|
|
67
|
+
ctorParameters: () => [],
|
|
68
|
+
propDecorators: { attributes: [{
|
|
69
|
+
type: i0.Input,
|
|
70
|
+
args: [{
|
|
71
|
+
isSignal: true,
|
|
72
|
+
alias: "monaAttributeBinder",
|
|
73
|
+
required: false
|
|
74
|
+
}]
|
|
75
|
+
}] }
|
|
76
|
+
});
|
|
50
77
|
const isValidHex = (hex) => {
|
|
51
|
-
|
|
78
|
+
return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(hex);
|
|
52
79
|
};
|
|
53
|
-
|
|
54
80
|
const hex2rgba = (hex) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
let r = 0, g = 0, b = 0, a = 255;
|
|
82
|
+
if (hex.length == 4 || hex.length == 5) {
|
|
83
|
+
r = parseInt(hex[1] + hex[1], 16);
|
|
84
|
+
g = parseInt(hex[2] + hex[2], 16);
|
|
85
|
+
b = parseInt(hex[3] + hex[3], 16);
|
|
86
|
+
if (hex.length == 5) a = parseInt(hex[4] + hex[4], 16);
|
|
87
|
+
} else if (hex.length == 7 || hex.length == 9) {
|
|
88
|
+
r = parseInt(hex.slice(1, 3), 16);
|
|
89
|
+
g = parseInt(hex.slice(3, 5), 16);
|
|
90
|
+
b = parseInt(hex.slice(5, 7), 16);
|
|
91
|
+
if (hex.length == 9) a = parseInt(hex.slice(7, 9), 16);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
r,
|
|
95
|
+
g,
|
|
96
|
+
b,
|
|
97
|
+
a
|
|
98
|
+
};
|
|
73
99
|
};
|
|
74
|
-
|
|
75
100
|
const hsla2hsva = (hue, saturation, lightness, alpha) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
if (hue == null || saturation == null || lightness == null) return {
|
|
102
|
+
h: 0,
|
|
103
|
+
s: 0,
|
|
104
|
+
v: 0,
|
|
105
|
+
a: 255
|
|
106
|
+
};
|
|
107
|
+
const h = hue;
|
|
108
|
+
const s = saturation / 100;
|
|
109
|
+
const l = lightness / 100;
|
|
110
|
+
const v = l + s * Math.min(l, 1 - l);
|
|
111
|
+
return {
|
|
112
|
+
h,
|
|
113
|
+
s: (v === 0 ? 0 : 2 * (1 - l / v)) * 100,
|
|
114
|
+
v: v * 100,
|
|
115
|
+
a: alpha ?? 255
|
|
116
|
+
};
|
|
90
117
|
};
|
|
91
|
-
|
|
92
118
|
const hsva2rgba = (hue, saturation, value, alpha) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
119
|
+
if (hue == null || saturation == null || value == null) return {
|
|
120
|
+
r: 0,
|
|
121
|
+
g: 0,
|
|
122
|
+
b: 0,
|
|
123
|
+
a: 255
|
|
124
|
+
};
|
|
125
|
+
const h = hue;
|
|
126
|
+
const s = saturation / 100;
|
|
127
|
+
const v = value / 100;
|
|
128
|
+
const f = (n, k = (n + h / 60) % 6) => v - v * s * Math.max(0, Math.min(k, 4 - k, 1));
|
|
129
|
+
return {
|
|
130
|
+
r: Math.round(f(5) * 255),
|
|
131
|
+
g: Math.round(f(3) * 255),
|
|
132
|
+
b: Math.round(f(1) * 255),
|
|
133
|
+
a: alpha ?? 255
|
|
134
|
+
};
|
|
106
135
|
};
|
|
107
|
-
|
|
108
136
|
const toHexByte = (value) => {
|
|
109
|
-
|
|
110
|
-
return byte.toString(16).padStart(2, "0");
|
|
137
|
+
return Math.min(255, Math.max(0, Math.round(value))).toString(16).padStart(2, "0");
|
|
111
138
|
};
|
|
112
139
|
const rgba2hex = (r, g, b, a) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const aHex = toHexByte(a);
|
|
117
|
-
return `#${toHexByte(r)}${toHexByte(g)}${toHexByte(b)}${aHex !== "ff" ? aHex : ""}`;
|
|
140
|
+
if (r == null || g == null || b == null || a == null) return "";
|
|
141
|
+
const aHex = toHexByte(a);
|
|
142
|
+
return `#${toHexByte(r)}${toHexByte(g)}${toHexByte(b)}${aHex !== "ff" ? aHex : ""}`;
|
|
118
143
|
};
|
|
119
|
-
|
|
120
144
|
const rgba2hsla = (red, green, blue, alpha) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
a: alpha ?? 255
|
|
157
|
-
};
|
|
145
|
+
if (red == null || green == null || blue == null) return {
|
|
146
|
+
h: 0,
|
|
147
|
+
s: 0,
|
|
148
|
+
l: 0,
|
|
149
|
+
a: 255
|
|
150
|
+
};
|
|
151
|
+
const r = red / 255;
|
|
152
|
+
const g = green / 255;
|
|
153
|
+
const b = blue / 255;
|
|
154
|
+
const max = Math.max(r, g, b);
|
|
155
|
+
const min = Math.min(r, g, b);
|
|
156
|
+
let h = 0;
|
|
157
|
+
let s;
|
|
158
|
+
const l = (max + min) / 2;
|
|
159
|
+
const d = max - min;
|
|
160
|
+
if (d === 0) h = s = 0;
|
|
161
|
+
else {
|
|
162
|
+
s = l > .5 ? d / (2 - max - min) : d / (max + min);
|
|
163
|
+
switch (max) {
|
|
164
|
+
case r:
|
|
165
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
166
|
+
break;
|
|
167
|
+
case g:
|
|
168
|
+
h = (b - r) / d + 2;
|
|
169
|
+
break;
|
|
170
|
+
case b: h = (r - g) / d + 4;
|
|
171
|
+
}
|
|
172
|
+
h /= 6;
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
h: Math.round(h * 3600) / 10,
|
|
176
|
+
s: Math.round(s * 1e3) / 10,
|
|
177
|
+
l: Math.round(l * 1e3) / 10,
|
|
178
|
+
a: alpha ?? 255
|
|
179
|
+
};
|
|
158
180
|
};
|
|
159
|
-
|
|
160
181
|
const NUMBER = "[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?";
|
|
161
182
|
const SEPARATOR = "(?:\\s*,\\s*|\\s+)";
|
|
162
183
|
const ALPHA = `(?:\\s*[,/]\\s*(${NUMBER}%?))?`;
|
|
@@ -164,534 +185,335 @@ const RGB_PATTERN = new RegExp(`^rgba?\\(\\s*(${NUMBER}%?)${SEPARATOR}(${NUMBER}
|
|
|
164
185
|
const HSL_PATTERN = new RegExp(`^hsla?\\(\\s*(${NUMBER})(?:deg)?${SEPARATOR}(${NUMBER})%?${SEPARATOR}(${NUMBER})%?${ALPHA}\\s*\\)$`, "i");
|
|
165
186
|
const clamp = (value, max) => Math.min(max, Math.max(0, value));
|
|
166
187
|
const parseAlpha = (text) => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const opacity = text.endsWith("%") ? parseFloat(text) / 100 : parseFloat(text);
|
|
171
|
-
return Math.round(clamp(opacity, 1) * 255);
|
|
188
|
+
if (text === void 0) return 255;
|
|
189
|
+
const opacity = text.endsWith("%") ? parseFloat(text) / 100 : parseFloat(text);
|
|
190
|
+
return Math.round(clamp(opacity, 1) * 255);
|
|
172
191
|
};
|
|
173
192
|
const parseRgbChannel = (text) => {
|
|
174
|
-
|
|
175
|
-
|
|
193
|
+
const channel = text.endsWith("%") ? parseFloat(text) / 100 * 255 : parseFloat(text);
|
|
194
|
+
return Math.round(clamp(channel, 255));
|
|
176
195
|
};
|
|
177
196
|
const parseFunctionalColor = (color) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
return null;
|
|
197
|
+
const rgb = RGB_PATTERN.exec(color);
|
|
198
|
+
if (rgb) return {
|
|
199
|
+
r: parseRgbChannel(rgb[1]),
|
|
200
|
+
g: parseRgbChannel(rgb[2]),
|
|
201
|
+
b: parseRgbChannel(rgb[3]),
|
|
202
|
+
a: parseAlpha(rgb[4])
|
|
203
|
+
};
|
|
204
|
+
const hsl = HSL_PATTERN.exec(color);
|
|
205
|
+
if (hsl) {
|
|
206
|
+
const hue = (parseFloat(hsl[1]) % 360 + 360) % 360;
|
|
207
|
+
const hsv = hsla2hsva(hue, clamp(parseFloat(hsl[2]), 100), clamp(parseFloat(hsl[3]), 100), parseAlpha(hsl[4]));
|
|
208
|
+
return hsva2rgba(hsv.h, hsv.s, hsv.v, hsv.a);
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
194
211
|
};
|
|
195
|
-
/**
|
|
196
|
-
* Asks the browser about everything else it can paint: color names, `transparent`, `oklch()`, `color-mix()` and so on.
|
|
197
|
-
* A color the browser rejects leaves `fillStyle` as it was, so it reads differently from two starting points.
|
|
198
|
-
*/
|
|
199
212
|
const readThroughCanvas = (color, document) => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
context.clearRect(0, 0, 1, 1);
|
|
221
|
-
context.fillRect(0, 0, 1, 1);
|
|
222
|
-
const [r, g, b, a] = context.getImageData(0, 0, 1, 1).data;
|
|
223
|
-
return { r, g, b, a };
|
|
213
|
+
const context = document.createElement("canvas").getContext?.("2d", { willReadFrequently: true });
|
|
214
|
+
if (!context) return null;
|
|
215
|
+
context.fillStyle = "#000000";
|
|
216
|
+
context.fillStyle = color;
|
|
217
|
+
const fromBlack = context.fillStyle;
|
|
218
|
+
context.fillStyle = "#ffffff";
|
|
219
|
+
context.fillStyle = color;
|
|
220
|
+
if (typeof fromBlack !== "string" || context.fillStyle !== fromBlack) return null;
|
|
221
|
+
if (isValidHex(fromBlack)) return hex2rgba(fromBlack);
|
|
222
|
+
const legacy = parseFunctionalColor(fromBlack);
|
|
223
|
+
if (legacy) return legacy;
|
|
224
|
+
context.clearRect(0, 0, 1, 1);
|
|
225
|
+
context.fillRect(0, 0, 1, 1);
|
|
226
|
+
const [r, g, b, a] = context.getImageData(0, 0, 1, 1).data;
|
|
227
|
+
return {
|
|
228
|
+
r,
|
|
229
|
+
g,
|
|
230
|
+
b,
|
|
231
|
+
a
|
|
232
|
+
};
|
|
224
233
|
};
|
|
225
|
-
/**
|
|
226
|
-
* Reads a CSS color. Hex, `rgb()` and `hsl()` in both their comma and space forms need nothing but the text; with a
|
|
227
|
-
* `document`, anything else the browser can paint is read through a canvas.
|
|
228
|
-
* @returns The channels, each from 0 to 255, or null when the text isn't a color.
|
|
229
|
-
*/
|
|
230
234
|
const parseColor = (text, document) => {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (isValidHex(color)) {
|
|
236
|
-
return hex2rgba(color);
|
|
237
|
-
}
|
|
238
|
-
return parseFunctionalColor(color) ?? (document ? readThroughCanvas(color, document) : null);
|
|
235
|
+
const color = text.trim();
|
|
236
|
+
if (!color) return null;
|
|
237
|
+
if (isValidHex(color)) return hex2rgba(color);
|
|
238
|
+
return parseFunctionalColor(color) ?? (document ? readThroughCanvas(color, document) : null);
|
|
239
239
|
};
|
|
240
|
-
/**
|
|
241
|
-
* A key that is equal for two spellings of the same color, such as `#ABC`, `#aabbcc` and `rgb(170, 187, 204)`. Text that
|
|
242
|
-
* can't be read as a color only compares equal to itself, ignoring case.
|
|
243
|
-
*/
|
|
244
240
|
const colorKey = (text, document) => {
|
|
245
|
-
|
|
246
|
-
|
|
241
|
+
const color = parseColor(text, document);
|
|
242
|
+
return color ? rgba2hex(color.r, color.g, color.b, color.a) : text.trim().toLowerCase();
|
|
247
243
|
};
|
|
248
|
-
/**
|
|
249
|
-
* The shortest opacity, as CSS writes it, that still reads back as the same 8-bit alpha. A saved `0.5` stays `0.5`.
|
|
250
|
-
*/
|
|
251
244
|
const formatAlpha = (alpha) => {
|
|
252
|
-
|
|
253
|
-
|
|
245
|
+
const short = Math.round(alpha / 255 * 100) / 100;
|
|
246
|
+
return Math.round(short * 255) === alpha ? short : Math.round(alpha / 255 * 1e3) / 1e3;
|
|
254
247
|
};
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Hue, saturation and value are left unrounded, so converting to RGB and back returns the same color. Round them for
|
|
258
|
-
* display only.
|
|
259
|
-
*/
|
|
260
248
|
const rgba2hsva = (r, g, b, a) => {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
const tokensOf = (element, attribute) => (element.getAttribute(attribute) ?? "").split(/\s+/).filter(token => token !== "");
|
|
294
|
-
/**
|
|
295
|
-
* Adds `id` to an id-list attribute such as `aria-describedby`, keeping the ids already there.
|
|
296
|
-
*/
|
|
249
|
+
if (r == null || g == null || b == null) return {
|
|
250
|
+
h: 0,
|
|
251
|
+
s: 0,
|
|
252
|
+
v: 0,
|
|
253
|
+
a: 255
|
|
254
|
+
};
|
|
255
|
+
r = r / 255;
|
|
256
|
+
g = g / 255;
|
|
257
|
+
b = b / 255;
|
|
258
|
+
const max = Math.max(r, g, b);
|
|
259
|
+
const min = Math.min(r, g, b);
|
|
260
|
+
let h = 0;
|
|
261
|
+
const v = max;
|
|
262
|
+
const d = max - min;
|
|
263
|
+
const s = max === 0 ? 0 : d / max;
|
|
264
|
+
if (max !== min) {
|
|
265
|
+
if (max === r) h = (g - b) / d + (g < b ? 6 : 0);
|
|
266
|
+
else if (max === g) h = (b - r) / d + 2;
|
|
267
|
+
else if (max === b) h = (r - g) / d + 4;
|
|
268
|
+
h /= 6;
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
h: h * 360,
|
|
272
|
+
s: s * 100,
|
|
273
|
+
v: v * 100,
|
|
274
|
+
a: a ?? 255
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
const tokensOf = (element, attribute) => (element.getAttribute(attribute) ?? "").split(/\s+/).filter((token) => token !== "");
|
|
297
278
|
const addAriaReference = (element, attribute, id) => {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
element.setAttribute(attribute, [...tokens, id].join(" "));
|
|
301
|
-
}
|
|
279
|
+
const tokens = tokensOf(element, attribute);
|
|
280
|
+
if (!tokens.includes(id)) element.setAttribute(attribute, [...tokens, id].join(" "));
|
|
302
281
|
};
|
|
303
|
-
/**
|
|
304
|
-
* Removes `id` from an id-list attribute, and the attribute itself once it holds no ids.
|
|
305
|
-
*/
|
|
306
282
|
const removeAriaReference = (element, attribute, id) => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
else {
|
|
312
|
-
element.removeAttribute(attribute);
|
|
313
|
-
}
|
|
283
|
+
const tokens = tokensOf(element, attribute).filter((token) => token !== id);
|
|
284
|
+
if (tokens.length) element.setAttribute(attribute, tokens.join(" "));
|
|
285
|
+
else element.removeAttribute(attribute);
|
|
314
286
|
};
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Generates a unique control ID for an element.
|
|
318
|
-
* The ID consists of the `mona-` prefix followed by a random hexadecimal string.
|
|
319
|
-
* It contains only characters that are safe in CSS selectors, so it can be used with `querySelector("#…")` unescaped.
|
|
320
|
-
* @param {number} [level=0] - The nesting level of the element. This increases the length of the generated ID.
|
|
321
|
-
* @param {number} [length=7] - The base length of the random part of the ID.
|
|
322
|
-
* @returns {string} A unique control ID string for use for elements.
|
|
323
|
-
*/
|
|
324
287
|
const createElementControlId = (level = 0, length = 7) => {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const chars = "0123456789abcdef";
|
|
337
|
-
for (let i = 0; i < idLength; i++) {
|
|
338
|
-
hex += chars[Math.floor(Math.random() * 16)];
|
|
339
|
-
}
|
|
340
|
-
return `${prefix}${hex}`;
|
|
288
|
+
const idLength = length + level;
|
|
289
|
+
const prefix = "mona-";
|
|
290
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
291
|
+
const array = new Uint8Array(Math.ceil(idLength / 2));
|
|
292
|
+
crypto.getRandomValues(array);
|
|
293
|
+
return `${prefix}${Array.from(array, (byte) => byte.toString(16).padStart(2, "0")).join("").substring(0, idLength)}`;
|
|
294
|
+
}
|
|
295
|
+
let hex = "";
|
|
296
|
+
const chars = "0123456789abcdef";
|
|
297
|
+
for (let i = 0; i < idLength; i++) hex += chars[Math.floor(Math.random() * 16)];
|
|
298
|
+
return `${prefix}${hex}`;
|
|
341
299
|
};
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Whether the enclosing `mona-fieldset` is disabled. A native `<fieldset disabled>` reaches only native controls,
|
|
345
|
-
* so the fieldset also provides this for controls that draw their own focusable element.
|
|
346
|
-
*/
|
|
347
300
|
const MONA_FIELDSET_DISABLED = new InjectionToken("MONA_FIELDSET_DISABLED");
|
|
348
|
-
/**
|
|
349
|
-
* Combines a control's own `disabled` with the enclosing `mona-fieldset`. Call it from an injection context.
|
|
350
|
-
*
|
|
351
|
-
* @param disabled Reads the control's own disabled state. It runs lazily, so it may read an input declared later.
|
|
352
|
-
*/
|
|
353
301
|
function injectEffectiveDisabled(disabled) {
|
|
354
|
-
|
|
355
|
-
|
|
302
|
+
const fieldsetDisabled = inject(MONA_FIELDSET_DISABLED, { optional: true });
|
|
303
|
+
return computed(() => disabled() || (fieldsetDisabled?.() ?? false));
|
|
356
304
|
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Provided by `mona-label` to the content it wraps.
|
|
360
|
-
*/
|
|
361
305
|
const MONA_LABEL = new InjectionToken("MONA_LABEL");
|
|
362
|
-
/**
|
|
363
|
-
* Connects a control to a `mona-label` or `label[monaLabel]` that names it, by wrapping it or through `[for]`.
|
|
364
|
-
*/
|
|
365
306
|
function injectLabelAssociation(options) {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
};
|
|
307
|
+
const context = options.wrapped === false ? null : inject(MONA_LABEL, { optional: true });
|
|
308
|
+
const fromTarget = signal(null, ...ngDevMode ? [{ debugName: "fromTarget" }] : /* istanbul ignore next */ []);
|
|
309
|
+
const { activate } = options;
|
|
310
|
+
if (context && activate) {
|
|
311
|
+
const element = inject(ElementRef).nativeElement;
|
|
312
|
+
const named = () => !!options.ariaLabel() || !!options.ariaLabelledBy();
|
|
313
|
+
inject(DestroyRef).onDestroy(context.register({
|
|
314
|
+
activate,
|
|
315
|
+
element,
|
|
316
|
+
named
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
labelledBy: computed(() => {
|
|
321
|
+
const explicit = options.ariaLabelledBy();
|
|
322
|
+
if (explicit) return explicit;
|
|
323
|
+
if (options.ariaLabel()) return null;
|
|
324
|
+
return fromTarget() ?? context?.captionId() ?? null;
|
|
325
|
+
}),
|
|
326
|
+
setLabelledBy: (id) => fromTarget.set(id)
|
|
327
|
+
};
|
|
388
328
|
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Whether a closing popup may move focus back to its trigger without taking it from somewhere the user put it.
|
|
392
|
-
* That holds while focus is on the page itself or inside one of `containers`, usually the trigger and the popup.
|
|
393
|
-
* A click on another field that closed the popup, or a Tab out of it, must leave focus where it went.
|
|
394
|
-
* This is the rule the CDK dialog uses.
|
|
395
|
-
*/
|
|
396
329
|
function focusCanReturn(document, ...containers) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
return containers.some(container => container?.contains(activeElement));
|
|
330
|
+
const activeElement = document.activeElement;
|
|
331
|
+
if (activeElement == null || activeElement === document.body) return true;
|
|
332
|
+
return containers.some((container) => container?.contains(activeElement));
|
|
402
333
|
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Focuses an element given directly, by reference, or by a selector inside `host`, and returns it (or `null` when the
|
|
406
|
-
* selector matches nothing).
|
|
407
|
-
*/
|
|
408
334
|
function focusElement(host, element) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
? element
|
|
413
|
-
: host.querySelector(element);
|
|
414
|
-
target?.focus();
|
|
415
|
-
return target;
|
|
335
|
+
const target = element instanceof ElementRef ? element.nativeElement : element instanceof HTMLElement ? element : host.querySelector(element);
|
|
336
|
+
target?.focus();
|
|
337
|
+
return target;
|
|
416
338
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
* How many open modal overlays made each element inert. An element is made inert by the first and released by the
|
|
420
|
-
* last, so closing one of two stacked modals leaves the page behind the other one inert.
|
|
421
|
-
*/
|
|
422
|
-
const inertCounts = new WeakMap();
|
|
423
|
-
/**
|
|
424
|
-
* Elements left alone: they hold no content, announce for everyone (live regions, CDK's live announcer), or hold the
|
|
425
|
-
* popups a modal opens. A modal in the overlay container has that container on its own path, so this only matters for
|
|
426
|
-
* one in the page.
|
|
427
|
-
*/
|
|
428
|
-
const isExempt = (element) => element instanceof HTMLScriptElement ||
|
|
429
|
-
element instanceof HTMLStyleElement ||
|
|
430
|
-
element instanceof HTMLTemplateElement ||
|
|
431
|
-
element.hasAttribute("aria-live") ||
|
|
432
|
-
element.classList.contains("cdk-overlay-backdrop") ||
|
|
433
|
-
element.classList.contains("cdk-overlay-container");
|
|
434
|
-
/**
|
|
435
|
-
* Makes everything outside a modal overlay inert, so assistive technology, the pointer and Tab can't reach the page
|
|
436
|
-
* behind it. Walking up from `element` to `<body>`, every sibling is made inert, except that inside the CDK overlay
|
|
437
|
-
* container only the overlays opened before this one are: popups opened later (a dropdown inside the dialog) stay
|
|
438
|
-
* usable. Elements that were inert already are left as they are.
|
|
439
|
-
* @param element the overlay's host element (the CDK overlay wrapper)
|
|
440
|
-
* @param options what to leave alone, and where to stop
|
|
441
|
-
* @returns the function that releases what this call made inert
|
|
442
|
-
*/
|
|
339
|
+
const inertCounts = /* @__PURE__ */ new WeakMap();
|
|
340
|
+
const isExempt = (element) => element instanceof HTMLScriptElement || element instanceof HTMLStyleElement || element instanceof HTMLTemplateElement || element.hasAttribute("aria-live") || element.classList.contains("cdk-overlay-backdrop") || element.classList.contains("cdk-overlay-container");
|
|
443
341
|
const inertOutside = (element, options = {}) => {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
released = true;
|
|
478
|
-
for (const sibling of acquired) {
|
|
479
|
-
const count = (inertCounts.get(sibling) ?? 1) - 1;
|
|
480
|
-
if (count <= 0) {
|
|
481
|
-
inertCounts.delete(sibling);
|
|
482
|
-
sibling.removeAttribute("inert");
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
inertCounts.set(sibling, count);
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
};
|
|
342
|
+
const body = element.ownerDocument.body;
|
|
343
|
+
const acquired = [];
|
|
344
|
+
let node = element;
|
|
345
|
+
while (node && node !== body && node !== options.stopAt && node.parentElement) {
|
|
346
|
+
const parent = node.parentElement;
|
|
347
|
+
const onlyEarlier = parent.classList.contains("cdk-overlay-container");
|
|
348
|
+
for (const sibling of Array.from(parent.children)) {
|
|
349
|
+
if (sibling === node) {
|
|
350
|
+
if (onlyEarlier) break;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
if (isExempt(sibling) || options.keep?.(sibling)) continue;
|
|
354
|
+
const count = inertCounts.get(sibling) ?? 0;
|
|
355
|
+
if (count === 0 && sibling.hasAttribute("inert")) continue;
|
|
356
|
+
inertCounts.set(sibling, count + 1);
|
|
357
|
+
if (count === 0) sibling.setAttribute("inert", "");
|
|
358
|
+
acquired.push(sibling);
|
|
359
|
+
}
|
|
360
|
+
node = parent;
|
|
361
|
+
}
|
|
362
|
+
let released = false;
|
|
363
|
+
return () => {
|
|
364
|
+
if (released) return;
|
|
365
|
+
released = true;
|
|
366
|
+
for (const sibling of acquired) {
|
|
367
|
+
const count = (inertCounts.get(sibling) ?? 1) - 1;
|
|
368
|
+
if (count <= 0) {
|
|
369
|
+
inertCounts.delete(sibling);
|
|
370
|
+
sibling.removeAttribute("inert");
|
|
371
|
+
} else inertCounts.set(sibling, count);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
489
374
|
};
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* The text of the elements an `aria-labelledby` value points to, joined with spaces, for names built from a
|
|
493
|
-
* component's name ("Filter {name}"). It's read after every render, so it follows the labelling elements' text.
|
|
494
|
-
* Call it in an injection context.
|
|
495
|
-
* @param ids Returns the space-separated element ids.
|
|
496
|
-
*/
|
|
497
375
|
function injectLabelledByText(ids) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
376
|
+
const document = inject(DOCUMENT);
|
|
377
|
+
const text = signal("", ...ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []);
|
|
378
|
+
afterEveryRender({ read: () => {
|
|
379
|
+
const value = ids().split(/\s+/).filter((id) => id.length > 0).map((id) => document.getElementById(id)?.textContent?.replace(/\s+/g, " ").trim() ?? "").filter((part) => part.length > 0).join(" ");
|
|
380
|
+
if (value !== untracked(text)) text.set(value);
|
|
381
|
+
} });
|
|
382
|
+
return text.asReadonly();
|
|
383
|
+
}
|
|
384
|
+
function createPageScrollBlockStrategy(document, block) {
|
|
385
|
+
return {
|
|
386
|
+
attach: (overlayRef) => block.attach(overlayRef),
|
|
387
|
+
disable: () => block.disable(),
|
|
388
|
+
enable: () => {
|
|
389
|
+
if (rootScrollsVertically(document)) block.enable();
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function rootScrollsVertically(document) {
|
|
394
|
+
const view = document.defaultView;
|
|
395
|
+
if (!view) return false;
|
|
396
|
+
const rootOverflow = view.getComputedStyle(document.documentElement).overflowY;
|
|
397
|
+
const overflow = rootOverflow === "visible" && document.body ? view.getComputedStyle(document.body).overflowY : rootOverflow;
|
|
398
|
+
return overflow !== "hidden" && overflow !== "clip";
|
|
515
399
|
}
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Places a global overlay through its position strategy, so later `updatePosition()` calls (a direction change, a
|
|
519
|
-
* resize) keep it where it is instead of resetting inline styles. Each axis is independent: a `top` alone keeps the
|
|
520
|
-
* overlay centered horizontally. Centering follows the overlay's size as it grows or shrinks.
|
|
521
|
-
*/
|
|
522
400
|
const positionGlobalOverlay = (overlayRef, position) => {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
strategy.centerVertically();
|
|
538
|
-
}
|
|
539
|
-
overlayRef.updatePosition();
|
|
540
|
-
};
|
|
541
|
-
|
|
401
|
+
const strategy = overlayRef.getConfig().positionStrategy;
|
|
402
|
+
if (!isGlobalPositionStrategy(strategy)) return;
|
|
403
|
+
if (position.left != null) strategy.left(`${position.left}px`);
|
|
404
|
+
else strategy.centerHorizontally();
|
|
405
|
+
if (position.top != null) strategy.top(`${position.top}px`);
|
|
406
|
+
else strategy.centerVertically();
|
|
407
|
+
overlayRef.updatePosition();
|
|
408
|
+
};
|
|
409
|
+
function isGlobalPositionStrategy(strategy) {
|
|
410
|
+
const candidate = strategy;
|
|
411
|
+
return typeof candidate?.centerHorizontally === "function" && typeof candidate.centerVertically === "function" && typeof candidate.left === "function" && typeof candidate.top === "function";
|
|
412
|
+
}
|
|
542
413
|
const rxFromResize = (target, options) => {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return () => resizeObserver.disconnect();
|
|
554
|
-
});
|
|
414
|
+
return new Observable((observer) => {
|
|
415
|
+
const elements = target instanceof Element ? [target] : Array.from(target ?? []);
|
|
416
|
+
for (const element of elements) if (!(element instanceof Element)) {
|
|
417
|
+
observer.error(/* @__PURE__ */ new TypeError("target must be an Element or an iterable of Elements"));
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const resizeObserver = new ResizeObserver((entries) => observer.next(entries));
|
|
421
|
+
for (const element of elements) resizeObserver.observe(element, options);
|
|
422
|
+
return () => resizeObserver.disconnect();
|
|
423
|
+
});
|
|
555
424
|
};
|
|
556
|
-
|
|
557
|
-
/** Marks the controls the toolbar manages, so they are still found once their Tab stop is set to -1. */
|
|
558
425
|
const ITEM_MARKER = "data-mona-toolbar-item";
|
|
559
426
|
const ITEM_SELECTOR = `:is(button, input, select, textarea, a[href], [tabindex]):not([tabindex='-1']), [${ITEM_MARKER}]`;
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
427
|
+
const BUTTON_LIKE_INPUT_TYPES = /* @__PURE__ */ new Set([
|
|
428
|
+
"button",
|
|
429
|
+
"checkbox",
|
|
430
|
+
"color",
|
|
431
|
+
"file",
|
|
432
|
+
"image",
|
|
433
|
+
"radio",
|
|
434
|
+
"reset",
|
|
435
|
+
"submit"
|
|
436
|
+
]);
|
|
437
|
+
const HORIZONTAL_KEY_ROLES = /* @__PURE__ */ new Set([
|
|
438
|
+
"radiogroup",
|
|
439
|
+
"searchbox",
|
|
440
|
+
"slider",
|
|
441
|
+
"spinbutton",
|
|
442
|
+
"tablist",
|
|
443
|
+
"textbox"
|
|
444
|
+
]);
|
|
564
445
|
function usesHorizontalArrows(element) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
return true;
|
|
570
|
-
}
|
|
571
|
-
const role = element.getAttribute("role");
|
|
572
|
-
return role != null && HORIZONTAL_KEY_ROLES.has(role);
|
|
446
|
+
if (element instanceof HTMLInputElement) return !BUTTON_LIKE_INPUT_TYPES.has(element.type);
|
|
447
|
+
if (element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement || element.isContentEditable) return true;
|
|
448
|
+
const role = element.getAttribute("role");
|
|
449
|
+
return role != null && HORIZONTAL_KEY_ROLES.has(role);
|
|
573
450
|
}
|
|
574
451
|
function isUnavailable(element) {
|
|
575
|
-
|
|
576
|
-
element instanceof HTMLInputElement ||
|
|
577
|
-
element instanceof HTMLSelectElement ||
|
|
578
|
-
element instanceof HTMLTextAreaElement) &&
|
|
579
|
-
element.disabled;
|
|
580
|
-
return (disabled ||
|
|
581
|
-
element.hasAttribute("disabled") ||
|
|
582
|
-
element.getAttribute("aria-disabled") === "true" ||
|
|
583
|
-
element.closest("[hidden], [aria-hidden='true']") != null);
|
|
452
|
+
return (element instanceof HTMLButtonElement || element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) && element.disabled || element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true" || element.closest("[hidden], [aria-hidden='true']") != null;
|
|
584
453
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
642
|
-
this.#active = targets[nextIndex];
|
|
643
|
-
this.sync();
|
|
644
|
-
targets[nextIndex].focus();
|
|
645
|
-
}
|
|
646
|
-
/** Gives the active control the Tab stop and takes it from the others. */
|
|
647
|
-
sync() {
|
|
648
|
-
const targets = this.#targets();
|
|
649
|
-
if (targets.length === 0) {
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
const itemIndex = this.#active == null ? -1 : targets.indexOf(this.#active);
|
|
653
|
-
const activeIndex = itemIndex !== -1 ? itemIndex : Math.min(this.#activeIndex, targets.length - 1);
|
|
654
|
-
this.#active = targets[activeIndex];
|
|
655
|
-
this.#activeIndex = activeIndex;
|
|
656
|
-
for (const [index, target] of targets.entries()) {
|
|
657
|
-
const tabIndex = index === activeIndex ? "0" : "-1";
|
|
658
|
-
if (target.getAttribute("tabindex") !== tabIndex) {
|
|
659
|
-
target.setAttribute("tabindex", tabIndex);
|
|
660
|
-
}
|
|
661
|
-
if (!target.hasAttribute(ITEM_MARKER)) {
|
|
662
|
-
target.setAttribute(ITEM_MARKER, "");
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
#targets() {
|
|
667
|
-
const element = this.#element();
|
|
668
|
-
if (element == null) {
|
|
669
|
-
return [];
|
|
670
|
-
}
|
|
671
|
-
const candidates = Array.from(element.querySelectorAll(ITEM_SELECTOR)).filter(candidate => !isUnavailable(candidate));
|
|
672
|
-
return candidates.filter(candidate => !candidates.some(other => other !== candidate && other.contains(candidate)));
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
|
|
454
|
+
var RovingToolbar = class {
|
|
455
|
+
#element;
|
|
456
|
+
#active = null;
|
|
457
|
+
#activeIndex = 0;
|
|
458
|
+
constructor(element) {
|
|
459
|
+
this.#element = element;
|
|
460
|
+
}
|
|
461
|
+
onFocusIn(event) {
|
|
462
|
+
const target = event.target;
|
|
463
|
+
const item = this.#targets().find((candidate) => candidate === target || candidate.contains(target));
|
|
464
|
+
if (item != null && item !== this.#active) {
|
|
465
|
+
this.#active = item;
|
|
466
|
+
this.sync();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
onKeydown(event) {
|
|
470
|
+
const key = event.key;
|
|
471
|
+
if (key !== "ArrowLeft" && key !== "ArrowRight" && key !== "Home" && key !== "End") return;
|
|
472
|
+
const target = event.target;
|
|
473
|
+
if (event.defaultPrevented || event.isComposing || event.altKey || event.ctrlKey || event.metaKey || usesHorizontalArrows(target)) return;
|
|
474
|
+
const targets = this.#targets();
|
|
475
|
+
const currentIndex = targets.findIndex((item) => item === target || item.contains(target));
|
|
476
|
+
if (currentIndex === -1) return;
|
|
477
|
+
event.preventDefault();
|
|
478
|
+
let nextIndex;
|
|
479
|
+
if (key === "Home") nextIndex = 0;
|
|
480
|
+
else if (key === "End") nextIndex = targets.length - 1;
|
|
481
|
+
else {
|
|
482
|
+
const element = this.#element();
|
|
483
|
+
const rtl = element?.ownerDocument.defaultView?.getComputedStyle(element).direction === "rtl";
|
|
484
|
+
nextIndex = (currentIndex + (key === "ArrowRight" !== rtl ? 1 : -1) + targets.length) % targets.length;
|
|
485
|
+
}
|
|
486
|
+
this.#active = targets[nextIndex];
|
|
487
|
+
this.sync();
|
|
488
|
+
targets[nextIndex].focus();
|
|
489
|
+
}
|
|
490
|
+
sync() {
|
|
491
|
+
const targets = this.#targets();
|
|
492
|
+
if (targets.length === 0) return;
|
|
493
|
+
const itemIndex = this.#active == null ? -1 : targets.indexOf(this.#active);
|
|
494
|
+
const activeIndex = itemIndex !== -1 ? itemIndex : Math.min(this.#activeIndex, targets.length - 1);
|
|
495
|
+
this.#active = targets[activeIndex];
|
|
496
|
+
this.#activeIndex = activeIndex;
|
|
497
|
+
for (const [index, target] of targets.entries()) {
|
|
498
|
+
const tabIndex = index === activeIndex ? "0" : "-1";
|
|
499
|
+
if (target.getAttribute("tabindex") !== tabIndex) target.setAttribute("tabindex", tabIndex);
|
|
500
|
+
if (!target.hasAttribute(ITEM_MARKER)) target.setAttribute(ITEM_MARKER, "");
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
#targets() {
|
|
504
|
+
const element = this.#element();
|
|
505
|
+
if (element == null) return [];
|
|
506
|
+
const candidates = Array.from(element.querySelectorAll(ITEM_SELECTOR)).filter((candidate) => !isUnavailable(candidate));
|
|
507
|
+
return candidates.filter((candidate) => !candidates.some((other) => other !== candidate && other.contains(candidate)));
|
|
508
|
+
}
|
|
509
|
+
};
|
|
676
510
|
const rxTimeout = (destroyRef, fn, delay = 0) => {
|
|
677
|
-
|
|
678
|
-
.pipe(takeUntilDestroyed(destroyRef), take(1))
|
|
679
|
-
.subscribe(() => fn());
|
|
511
|
+
timer(delay).pipe(takeUntilDestroyed(destroyRef), take(1)).subscribe(() => fn());
|
|
680
512
|
};
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* What says a row is selected besides its tint, which is faint in every theme and gone in forced colors. The row
|
|
684
|
-
* has to be positioned.
|
|
685
|
-
*/
|
|
686
513
|
const themeSelectionBarClasses = `
|
|
687
514
|
before:absolute before:inset-y-0 before:start-0 before:w-0.5 before:bg-(--color-selected-border)
|
|
688
515
|
before:forced-color-adjust-none forced-colors:before:bg-[Highlight]
|
|
689
516
|
`;
|
|
690
|
-
/**
|
|
691
|
-
* A border in the text's color for a selected control, drawn only when the user asks for more contrast or forced colors
|
|
692
|
-
* are on. Elsewhere the fill says it alone. A control with a border of its own adds `after:-inset-px`, so this one
|
|
693
|
-
* replaces it.
|
|
694
|
-
*/
|
|
695
517
|
const themeSelectionBorderClasses = `
|
|
696
518
|
relative
|
|
697
519
|
after:pointer-events-none after:absolute after:inset-0
|
|
@@ -725,415 +547,308 @@ const themeOverlaySurfaceClasses = `
|
|
|
725
547
|
[background-color:var(--mona-effect-overlay-background-color,var(--color-surface-overlay))]
|
|
726
548
|
${themeOverlayBackdropClasses}
|
|
727
549
|
`;
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* How long a popup opened by hovering waits after the pointer leaves its anchor, so the pointer can cross the gap
|
|
731
|
-
* onto the popup and stay there (WCAG 1.4.13, Content on Hover or Focus).
|
|
732
|
-
*/
|
|
733
550
|
const HOVER_GRACE = 100;
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
this.#hideTimer = null;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
#clearShow() {
|
|
876
|
-
if (this.#showTimer != null) {
|
|
877
|
-
clearTimeout(this.#showTimer);
|
|
878
|
-
this.#showTimer = null;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
#release() {
|
|
882
|
-
this.#panelCleanup?.();
|
|
883
|
-
this.#panelCleanup = null;
|
|
884
|
-
this.#panelHovered = false;
|
|
885
|
-
this.#anchor = null;
|
|
886
|
-
this.#cancelHide();
|
|
887
|
-
}
|
|
888
|
-
#scheduleHide(source) {
|
|
889
|
-
this.#cancelHide();
|
|
890
|
-
const delay = Math.max(this.#config.hideDelay(), source === "pointer" ? HOVER_GRACE : 0);
|
|
891
|
-
const hide = () => {
|
|
892
|
-
this.#hideTimer = null;
|
|
893
|
-
if (this.#anchor) {
|
|
894
|
-
this.#release();
|
|
895
|
-
this.#config.hide();
|
|
896
|
-
}
|
|
897
|
-
};
|
|
898
|
-
if (delay > 0) {
|
|
899
|
-
this.#hideTimer = setTimeout(hide, delay);
|
|
900
|
-
}
|
|
901
|
-
else {
|
|
902
|
-
hide();
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
#setActive(source, active) {
|
|
906
|
-
if (source === "pointer") {
|
|
907
|
-
this.#hovered = active;
|
|
908
|
-
}
|
|
909
|
-
else {
|
|
910
|
-
this.#focused = active;
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
#show(anchor) {
|
|
914
|
-
this.#showTimer = null;
|
|
915
|
-
this.#pending = null;
|
|
916
|
-
if (this.#anchor && this.#anchor !== anchor) {
|
|
917
|
-
this.#release();
|
|
918
|
-
this.#config.hide();
|
|
919
|
-
}
|
|
920
|
-
this.#config.show(anchor);
|
|
921
|
-
}
|
|
922
|
-
/** The anchor whose popup is open, if any. */
|
|
923
|
-
get anchor() {
|
|
924
|
-
return this.#anchor;
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
* Feeds a {@link HoverIntent} from pointer and focus events delegated on `root`, so anchors added, removed or
|
|
929
|
-
* re-rendered later need no listeners of their own. Touch pointers are ignored: a tap that focuses the anchor shows
|
|
930
|
-
* the popup through focus instead, and it isn't hidden again by the pointer leaving after the tap.
|
|
931
|
-
* @param resolve the anchor an event target belongs to, or `null`
|
|
932
|
-
* @returns the function that removes the listeners
|
|
933
|
-
*/
|
|
551
|
+
var HoverIntent = class {
|
|
552
|
+
#config;
|
|
553
|
+
#anchor = null;
|
|
554
|
+
#dismissed = null;
|
|
555
|
+
#focused = false;
|
|
556
|
+
#hideTimer = null;
|
|
557
|
+
#hovered = false;
|
|
558
|
+
#panelCleanup = null;
|
|
559
|
+
#panelHovered = false;
|
|
560
|
+
#pending = null;
|
|
561
|
+
#showTimer = null;
|
|
562
|
+
#tracked = null;
|
|
563
|
+
constructor(config) {
|
|
564
|
+
this.#config = config;
|
|
565
|
+
}
|
|
566
|
+
closed(anchor, dismissed = false) {
|
|
567
|
+
if (this.#anchor !== anchor) return;
|
|
568
|
+
if (dismissed && (this.#hovered || this.#focused)) this.#dismissed = anchor;
|
|
569
|
+
this.#release();
|
|
570
|
+
}
|
|
571
|
+
dispose() {
|
|
572
|
+
this.#clearShow();
|
|
573
|
+
this.#cancelHide();
|
|
574
|
+
this.#release();
|
|
575
|
+
this.#pending = null;
|
|
576
|
+
this.#tracked = null;
|
|
577
|
+
this.#dismissed = null;
|
|
578
|
+
}
|
|
579
|
+
enter(anchor, source) {
|
|
580
|
+
if (anchor !== this.#tracked) {
|
|
581
|
+
this.#tracked = anchor;
|
|
582
|
+
this.#hovered = false;
|
|
583
|
+
this.#focused = false;
|
|
584
|
+
}
|
|
585
|
+
this.#setActive(source, true);
|
|
586
|
+
if (this.#dismissed === anchor) return;
|
|
587
|
+
this.#dismissed = null;
|
|
588
|
+
this.#cancelHide();
|
|
589
|
+
if (this.#anchor === anchor || this.#pending === anchor) return;
|
|
590
|
+
this.#clearShow();
|
|
591
|
+
this.#pending = anchor;
|
|
592
|
+
const delay = this.#config.showDelay();
|
|
593
|
+
if (delay > 0) this.#showTimer = setTimeout(() => this.#show(anchor), delay);
|
|
594
|
+
else this.#show(anchor);
|
|
595
|
+
}
|
|
596
|
+
hideNow() {
|
|
597
|
+
this.#clearShow();
|
|
598
|
+
this.#pending = null;
|
|
599
|
+
this.#cancelHide();
|
|
600
|
+
if (this.#anchor) {
|
|
601
|
+
this.#release();
|
|
602
|
+
this.#config.hide();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
leave(anchor, source) {
|
|
606
|
+
if (anchor !== this.#tracked) return;
|
|
607
|
+
this.#setActive(source, false);
|
|
608
|
+
if (this.#hovered || this.#focused) return;
|
|
609
|
+
if (this.#dismissed === anchor) {
|
|
610
|
+
this.#dismissed = null;
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
if (this.#pending === anchor) {
|
|
614
|
+
this.#clearShow();
|
|
615
|
+
this.#pending = null;
|
|
616
|
+
}
|
|
617
|
+
if (this.#anchor === anchor && !this.#panelHovered) this.#scheduleHide(source);
|
|
618
|
+
}
|
|
619
|
+
opened(anchor, panel) {
|
|
620
|
+
this.#release();
|
|
621
|
+
this.#anchor = anchor;
|
|
622
|
+
if (!panel) return;
|
|
623
|
+
const enter = (event) => {
|
|
624
|
+
if (event.pointerType === "touch") return;
|
|
625
|
+
this.#panelHovered = true;
|
|
626
|
+
this.#cancelHide();
|
|
627
|
+
};
|
|
628
|
+
const leave = (event) => {
|
|
629
|
+
if (event.pointerType === "touch") return;
|
|
630
|
+
this.#panelHovered = false;
|
|
631
|
+
if (this.#anchor === anchor && !this.#hovered && !this.#focused) this.#scheduleHide("pointer");
|
|
632
|
+
};
|
|
633
|
+
panel.addEventListener("pointerenter", enter);
|
|
634
|
+
panel.addEventListener("pointerleave", leave);
|
|
635
|
+
this.#panelCleanup = () => {
|
|
636
|
+
panel.removeEventListener("pointerenter", enter);
|
|
637
|
+
panel.removeEventListener("pointerleave", leave);
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
#cancelHide() {
|
|
641
|
+
if (this.#hideTimer != null) {
|
|
642
|
+
clearTimeout(this.#hideTimer);
|
|
643
|
+
this.#hideTimer = null;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
#clearShow() {
|
|
647
|
+
if (this.#showTimer != null) {
|
|
648
|
+
clearTimeout(this.#showTimer);
|
|
649
|
+
this.#showTimer = null;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
#release() {
|
|
653
|
+
this.#panelCleanup?.();
|
|
654
|
+
this.#panelCleanup = null;
|
|
655
|
+
this.#panelHovered = false;
|
|
656
|
+
this.#anchor = null;
|
|
657
|
+
this.#cancelHide();
|
|
658
|
+
}
|
|
659
|
+
#scheduleHide(source) {
|
|
660
|
+
this.#cancelHide();
|
|
661
|
+
const delay = Math.max(this.#config.hideDelay(), source === "pointer" ? 100 : 0);
|
|
662
|
+
const hide = () => {
|
|
663
|
+
this.#hideTimer = null;
|
|
664
|
+
if (this.#anchor) {
|
|
665
|
+
this.#release();
|
|
666
|
+
this.#config.hide();
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
if (delay > 0) this.#hideTimer = setTimeout(hide, delay);
|
|
670
|
+
else hide();
|
|
671
|
+
}
|
|
672
|
+
#setActive(source, active) {
|
|
673
|
+
if (source === "pointer") this.#hovered = active;
|
|
674
|
+
else this.#focused = active;
|
|
675
|
+
}
|
|
676
|
+
#show(anchor) {
|
|
677
|
+
this.#showTimer = null;
|
|
678
|
+
this.#pending = null;
|
|
679
|
+
if (this.#anchor && this.#anchor !== anchor) {
|
|
680
|
+
this.#release();
|
|
681
|
+
this.#config.hide();
|
|
682
|
+
}
|
|
683
|
+
this.#config.show(anchor);
|
|
684
|
+
}
|
|
685
|
+
get anchor() {
|
|
686
|
+
return this.#anchor;
|
|
687
|
+
}
|
|
688
|
+
};
|
|
934
689
|
const listenForHover = (root, resolve, intent) => {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
}
|
|
966
|
-
};
|
|
967
|
-
root.addEventListener("pointerover", over);
|
|
968
|
-
root.addEventListener("pointerout", out);
|
|
969
|
-
root.addEventListener("focusin", focusIn);
|
|
970
|
-
root.addEventListener("focusout", focusOut);
|
|
971
|
-
return () => {
|
|
972
|
-
root.removeEventListener("pointerover", over);
|
|
973
|
-
root.removeEventListener("pointerout", out);
|
|
974
|
-
root.removeEventListener("focusin", focusIn);
|
|
975
|
-
root.removeEventListener("focusout", focusOut);
|
|
976
|
-
};
|
|
690
|
+
const anchorOf = (target) => target instanceof Element ? resolve(target) : null;
|
|
691
|
+
const stillInside = (anchor, to) => to instanceof Node && anchor.contains(to);
|
|
692
|
+
const over = (event) => {
|
|
693
|
+
if (event.pointerType === "touch") return;
|
|
694
|
+
const anchor = anchorOf(event.target);
|
|
695
|
+
if (anchor) intent.enter(anchor, "pointer");
|
|
696
|
+
};
|
|
697
|
+
const out = (event) => {
|
|
698
|
+
if (event.pointerType === "touch") return;
|
|
699
|
+
const anchor = anchorOf(event.target);
|
|
700
|
+
if (anchor && !stillInside(anchor, event.relatedTarget)) intent.leave(anchor, "pointer");
|
|
701
|
+
};
|
|
702
|
+
const focusIn = (event) => {
|
|
703
|
+
const anchor = anchorOf(event.target);
|
|
704
|
+
if (anchor) intent.enter(anchor, "focus");
|
|
705
|
+
};
|
|
706
|
+
const focusOut = (event) => {
|
|
707
|
+
const anchor = anchorOf(event.target);
|
|
708
|
+
if (anchor && !stillInside(anchor, event.relatedTarget)) intent.leave(anchor, "focus");
|
|
709
|
+
};
|
|
710
|
+
root.addEventListener("pointerover", over);
|
|
711
|
+
root.addEventListener("pointerout", out);
|
|
712
|
+
root.addEventListener("focusin", focusIn);
|
|
713
|
+
root.addEventListener("focusout", focusOut);
|
|
714
|
+
return () => {
|
|
715
|
+
root.removeEventListener("pointerover", over);
|
|
716
|
+
root.removeEventListener("pointerout", out);
|
|
717
|
+
root.removeEventListener("focusin", focusIn);
|
|
718
|
+
root.removeEventListener("focusout", focusOut);
|
|
719
|
+
};
|
|
977
720
|
};
|
|
978
|
-
/**
|
|
979
|
-
* Calls `callback` once `element` leaves the document, for a popup that would otherwise stay anchored to nothing.
|
|
980
|
-
* @returns the function that stops watching
|
|
981
|
-
*/
|
|
982
721
|
const onDisconnect = (element, callback) => {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
722
|
+
const view = element.ownerDocument.defaultView;
|
|
723
|
+
if (!view?.MutationObserver) return () => void 0;
|
|
724
|
+
const observer = new view.MutationObserver(() => {
|
|
725
|
+
if (!element.isConnected) {
|
|
726
|
+
observer.disconnect();
|
|
727
|
+
callback();
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
observer.observe(element.ownerDocument.body, {
|
|
731
|
+
childList: true,
|
|
732
|
+
subtree: true
|
|
733
|
+
});
|
|
734
|
+
return () => observer.disconnect();
|
|
995
735
|
};
|
|
996
|
-
|
|
997
736
|
const OPPOSITE = {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
737
|
+
bottom: "top",
|
|
738
|
+
left: "right",
|
|
739
|
+
right: "left",
|
|
740
|
+
top: "bottom"
|
|
1002
741
|
};
|
|
1003
742
|
const resolveOverlaySide = (side, direction) => {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
743
|
+
if (side === "start") return direction === "rtl" ? "right" : "left";
|
|
744
|
+
if (side === "end") return direction === "rtl" ? "left" : "right";
|
|
745
|
+
return side;
|
|
746
|
+
};
|
|
747
|
+
const position = (origin, overlay, offsetX, offsetY) => ({
|
|
748
|
+
...origin,
|
|
749
|
+
...overlay,
|
|
750
|
+
offsetX,
|
|
751
|
+
offsetY
|
|
752
|
+
});
|
|
1012
753
|
const positionFor = (side, gap, direction) => {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
754
|
+
const left = direction === "rtl" ? "end" : "start";
|
|
755
|
+
const right = direction === "rtl" ? "start" : "end";
|
|
756
|
+
switch (side) {
|
|
757
|
+
case "top": return position({
|
|
758
|
+
originX: "center",
|
|
759
|
+
originY: "top"
|
|
760
|
+
}, {
|
|
761
|
+
overlayX: "center",
|
|
762
|
+
overlayY: "bottom"
|
|
763
|
+
}, 0, -gap);
|
|
764
|
+
case "bottom": return position({
|
|
765
|
+
originX: "center",
|
|
766
|
+
originY: "bottom"
|
|
767
|
+
}, {
|
|
768
|
+
overlayX: "center",
|
|
769
|
+
overlayY: "top"
|
|
770
|
+
}, 0, gap);
|
|
771
|
+
case "left": return position({
|
|
772
|
+
originX: left,
|
|
773
|
+
originY: "center"
|
|
774
|
+
}, {
|
|
775
|
+
overlayX: right,
|
|
776
|
+
overlayY: "center"
|
|
777
|
+
}, -gap, 0);
|
|
778
|
+
case "right": return position({
|
|
779
|
+
originX: right,
|
|
780
|
+
originY: "center"
|
|
781
|
+
}, {
|
|
782
|
+
overlayX: left,
|
|
783
|
+
overlayY: "center"
|
|
784
|
+
}, gap, 0);
|
|
785
|
+
}
|
|
1026
786
|
};
|
|
1027
|
-
/**
|
|
1028
|
-
* Positions for a popup centered on `side` of its anchor, flipping to the opposite side when it doesn't fit. Each
|
|
1029
|
-
* position carries its own offset, so the gap stays between the popup and its anchor after a flip.
|
|
1030
|
-
* @param gap the distance between the anchor and the popup, in pixels
|
|
1031
|
-
* @param direction the overlay's direction
|
|
1032
|
-
*/
|
|
1033
787
|
const overlaySidePositions = (side, gap, direction) => [positionFor(side, gap, direction), positionFor(OPPOSITE[side], gap, direction)];
|
|
1034
|
-
/**
|
|
1035
|
-
* The physical side of its anchor a popup ended up on, from the position the overlay chose.
|
|
1036
|
-
*/
|
|
1037
788
|
const sideOfPosition = (position, direction) => {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
if (position.overlayY === "top" && position.overlayX === "center") {
|
|
1042
|
-
return "bottom";
|
|
1043
|
-
}
|
|
1044
|
-
// A popup to the anchor's right touches it with its left edge: the overlay's start in LTR, its end in RTL.
|
|
1045
|
-
const leftEdge = position.overlayX === (direction === "rtl" ? "end" : "start");
|
|
1046
|
-
return leftEdge ? "right" : "left";
|
|
789
|
+
if (position.overlayY === "bottom" && position.overlayX === "center") return "top";
|
|
790
|
+
if (position.overlayY === "top" && position.overlayX === "center") return "bottom";
|
|
791
|
+
return position.overlayX === (direction === "rtl" ? "end" : "start") ? "right" : "left";
|
|
1047
792
|
};
|
|
1048
|
-
|
|
1049
793
|
const restoreOverlayScroll = (overlayRef, element) => {
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
});
|
|
1061
|
-
});
|
|
794
|
+
requestAnimationFrame(() => {
|
|
795
|
+
const scrollableContent = findScrollableElement(overlayRef.overlayElement);
|
|
796
|
+
const scrollTop = scrollableContent?.scrollTop ?? 0;
|
|
797
|
+
const width = element.getBoundingClientRect().width;
|
|
798
|
+
overlayRef.updatePosition();
|
|
799
|
+
overlayRef.updateSize({ width });
|
|
800
|
+
requestAnimationFrame(() => {
|
|
801
|
+
if (scrollableContent) scrollableContent.scrollTop = scrollTop;
|
|
802
|
+
});
|
|
803
|
+
});
|
|
1062
804
|
};
|
|
1063
805
|
const findScrollableElement = (container) => {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
return scrollable;
|
|
1071
|
-
}
|
|
1072
|
-
if (container.scrollHeight > container.clientHeight) {
|
|
1073
|
-
return container;
|
|
1074
|
-
}
|
|
1075
|
-
return null;
|
|
806
|
+
const virtualViewport = container.querySelector(".cdk-virtual-scroll-viewport");
|
|
807
|
+
if (virtualViewport) return virtualViewport;
|
|
808
|
+
const scrollable = container.querySelector("ul, [style*='overflow']");
|
|
809
|
+
if (scrollable && scrollable.scrollHeight > scrollable.clientHeight) return scrollable;
|
|
810
|
+
if (container.scrollHeight > container.clientHeight) return container;
|
|
811
|
+
return null;
|
|
1076
812
|
};
|
|
1077
|
-
|
|
1078
|
-
/**
|
|
1079
|
-
* Converts a number or a string into a CSS-compliant value.
|
|
1080
|
-
* - If the input is a number (e.g., 100), it appends 'px'.
|
|
1081
|
-
* - If the input is a numeric string (e.g., "100"), it appends 'px'.
|
|
1082
|
-
* - If the input is a string with a unit (e.g., "100px", "10rem"), it returns it as is.
|
|
1083
|
-
*
|
|
1084
|
-
* @param value The number or string to convert.
|
|
1085
|
-
* @returns A CSS-compliant string value.
|
|
1086
|
-
*/
|
|
1087
813
|
const toCssValue = (value) => {
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
if (typeof value === "number" || isFinite(Number(value))) {
|
|
1092
|
-
return value === 0 ? "0" : `${value}px`;
|
|
1093
|
-
}
|
|
1094
|
-
return String(value);
|
|
814
|
+
if (value == null || typeof value === "string" && value.trim() === "") return "";
|
|
815
|
+
if (typeof value === "number" || isFinite(Number(value))) return value === 0 ? "0" : `${value}px`;
|
|
816
|
+
return String(value);
|
|
1095
817
|
};
|
|
1096
|
-
|
|
1097
818
|
var NavigationKeys;
|
|
1098
|
-
(function
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
819
|
+
(function(NavigationKeys) {
|
|
820
|
+
NavigationKeys["ArrowUp"] = "ArrowUp";
|
|
821
|
+
NavigationKeys["ArrowDown"] = "ArrowDown";
|
|
822
|
+
NavigationKeys["ArrowLeft"] = "ArrowLeft";
|
|
823
|
+
NavigationKeys["ArrowRight"] = "ArrowRight";
|
|
824
|
+
NavigationKeys["Enter"] = "Enter";
|
|
825
|
+
NavigationKeys["Escape"] = "Escape";
|
|
826
|
+
NavigationKeys["Home"] = "Home";
|
|
827
|
+
NavigationKeys["End"] = "End";
|
|
828
|
+
NavigationKeys["PageDown"] = "PageDown";
|
|
829
|
+
NavigationKeys["PageUp"] = "PageUp";
|
|
830
|
+
NavigationKeys["Space"] = " ";
|
|
1110
831
|
})(NavigationKeys || (NavigationKeys = {}));
|
|
1111
832
|
const navigationKeysList = Object.values(NavigationKeys);
|
|
1112
833
|
const isNavigationKey = (key) => {
|
|
1113
|
-
|
|
834
|
+
return navigationKeysList.includes(key);
|
|
1114
835
|
};
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* Returns whether a `KeyboardEvent.key` value should feed typeahead.
|
|
1118
|
-
* Any single letter or digit in any script counts, plus space, `-` and `_`.
|
|
1119
|
-
*/
|
|
1120
836
|
const isTypeaheadKey = (key, modifiers) => {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
}
|
|
1124
|
-
return /^[\p{L}\p{M}\p{N}\-_\s]$/u.test(key);
|
|
837
|
+
if (modifiers?.ctrlKey || modifiers?.metaKey || modifiers?.altKey) return false;
|
|
838
|
+
return /^[\p{L}\p{M}\p{N}\-_\s]$/u.test(key);
|
|
1125
839
|
};
|
|
1126
|
-
/** How long typeahead waits after the last key before it starts a new search, in milliseconds. */
|
|
1127
840
|
const TYPEAHEAD_RESET_DELAY = 200;
|
|
1128
841
|
const setupTypeahead = (typeaheadKey$) => {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
};
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
842
|
+
const resetTrigger$ = typeaheadKey$.pipe(debounceTime(200), map(() => ({
|
|
843
|
+
type: "reset",
|
|
844
|
+
value: ""
|
|
845
|
+
})));
|
|
846
|
+
const keypress$ = typeaheadKey$.pipe(map((key) => ({
|
|
847
|
+
type: "key",
|
|
848
|
+
value: key
|
|
849
|
+
})));
|
|
850
|
+
return merge(keypress$, resetTrigger$).pipe(scan((buffer, action) => action.type === "reset" ? "" : buffer + action.value.toLowerCase(), ""), filter((buffer) => buffer.length > 0));
|
|
851
|
+
};
|
|
852
|
+
export { AttributeBinderDirective, HOVER_GRACE, HoverIntent, MONA_FIELDSET_DISABLED, MONA_LABEL, NavigationKeys, RovingToolbar, TYPEAHEAD_RESET_DELAY, addAriaReference, colorKey, createElementControlId, createPageScrollBlockStrategy, focusCanReturn, focusElement, formatAlpha, hex2rgba, hsla2hsva, hsva2rgba, inertOutside, injectEffectiveDisabled, injectLabelAssociation, injectLabelledByText, isNavigationKey, isTypeaheadKey, isValidHex, listenForHover, navigationKeysList, onDisconnect, overlaySidePositions, parseColor, positionGlobalOverlay, removeAriaReference, resolveOverlaySide, restoreOverlayScroll, rgba2hex, rgba2hsla, rgba2hsva, rxFromResize, rxTimeout, setupTypeahead, sideOfPosition, themeControlBackdropClasses, themeControlSurfaceClasses, themeOverlayBackdropClasses, themeOverlaySurfaceClasses, themeRaisedBackdropClasses, themeRaisedSurfaceClasses, themeSelectionBarClasses, themeSelectionBorderClasses, toCssValue };
|
|
1137
853
|
|
|
1138
|
-
|
|
1139
|
-
//# sourceMappingURL=nanahoshi-mona-ui-internal.mjs.map
|
|
854
|
+
//# sourceMappingURL=nanahoshi-mona-ui-internal.mjs.map
|