@masmarino/gabarit 2.1.1 → 3.0.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/ACCESSIBILITY.md +4 -0
- package/README.md +29 -11
- package/accordion/package.json +4 -0
- package/alert/package.json +4 -0
- package/app-shell/package.json +4 -0
- package/auth/package.json +4 -0
- package/auth-activate/package.json +4 -0
- package/auth-login/package.json +4 -0
- package/auth-register/package.json +4 -0
- package/auth-reset-password/package.json +4 -0
- package/autocomplete/package.json +4 -0
- package/avatar/package.json +4 -0
- package/avatar-group/package.json +4 -0
- package/badge/package.json +4 -0
- package/bar-chart/package.json +4 -0
- package/breadcrumb/package.json +4 -0
- package/button/package.json +4 -0
- package/card/README.md +1 -0
- package/card/package.json +4 -0
- package/chart/package.json +4 -0
- package/checkbox/package.json +4 -0
- package/checkbox-group/package.json +4 -0
- package/command-palette/README.md +65 -0
- package/command-palette/package.json +4 -0
- package/confirm-danger-modal/package.json +4 -0
- package/copy-button/package.json +4 -0
- package/copy-field/package.json +4 -0
- package/date-picker/package.json +4 -0
- package/description-list/package.json +4 -0
- package/dimension-card/package.json +4 -0
- package/disclosure/package.json +4 -0
- package/divider/package.json +4 -0
- package/docs/package.json +4 -0
- package/drawer/package.json +4 -0
- package/empty-state/package.json +4 -0
- package/fesm2022/masmarino-gabarit-accordion.mjs +8 -8
- package/fesm2022/masmarino-gabarit-accordion.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-alert.mjs +5 -5
- package/fesm2022/masmarino-gabarit-alert.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-app-shell.mjs +10 -10
- package/fesm2022/masmarino-gabarit-app-shell.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-auth-activate.mjs +3 -3
- package/fesm2022/masmarino-gabarit-auth-login.mjs +3 -3
- package/fesm2022/masmarino-gabarit-auth-register.mjs +3 -3
- package/fesm2022/masmarino-gabarit-auth-reset-password.mjs +3 -3
- package/fesm2022/masmarino-gabarit-auth.mjs +12 -12
- package/fesm2022/masmarino-gabarit-autocomplete.mjs +5 -5
- package/fesm2022/masmarino-gabarit-autocomplete.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-avatar-group.mjs +5 -5
- package/fesm2022/masmarino-gabarit-avatar-group.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-avatar.mjs +3 -3
- package/fesm2022/masmarino-gabarit-badge.mjs +5 -5
- package/fesm2022/masmarino-gabarit-badge.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-bar-chart.mjs +6 -6
- package/fesm2022/masmarino-gabarit-breadcrumb.mjs +3 -3
- package/fesm2022/masmarino-gabarit-button.mjs +5 -5
- package/fesm2022/masmarino-gabarit-button.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-card.mjs +32 -13
- package/fesm2022/masmarino-gabarit-card.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-chart.mjs +23 -23
- package/fesm2022/masmarino-gabarit-chart.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-checkbox-group.mjs +3 -3
- package/fesm2022/masmarino-gabarit-checkbox.mjs +5 -5
- package/fesm2022/masmarino-gabarit-checkbox.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-command-palette.mjs +649 -0
- package/fesm2022/masmarino-gabarit-command-palette.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-confirm-danger-modal.mjs +3 -3
- package/fesm2022/masmarino-gabarit-copy-button.mjs +3 -3
- package/fesm2022/masmarino-gabarit-copy-field.mjs +3 -3
- package/fesm2022/masmarino-gabarit-date-picker.mjs +10 -10
- package/fesm2022/masmarino-gabarit-date-picker.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-description-list.mjs +3 -3
- package/fesm2022/masmarino-gabarit-dimension-card.mjs +3 -3
- package/fesm2022/masmarino-gabarit-disclosure.mjs +5 -5
- package/fesm2022/masmarino-gabarit-disclosure.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-divider.mjs +3 -3
- package/fesm2022/masmarino-gabarit-docs.mjs +26 -25
- package/fesm2022/masmarino-gabarit-docs.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-drawer.mjs +5 -5
- package/fesm2022/masmarino-gabarit-drawer.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-empty-state.mjs +3 -3
- package/fesm2022/masmarino-gabarit-file-upload.mjs +5 -5
- package/fesm2022/masmarino-gabarit-file-upload.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-format.mjs +9 -9
- package/fesm2022/masmarino-gabarit-funnel-chart.mjs +3 -3
- package/fesm2022/masmarino-gabarit-gauge-bar.mjs +5 -5
- package/fesm2022/masmarino-gabarit-gauge-bar.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-git-field.mjs +5 -5
- package/fesm2022/masmarino-gabarit-git-field.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-icon-marker.mjs +5 -5
- package/fesm2022/masmarino-gabarit-icon-marker.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-icon.mjs +6 -6
- package/fesm2022/masmarino-gabarit-input.mjs +5 -5
- package/fesm2022/masmarino-gabarit-input.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-job-graph.mjs +5 -5
- package/fesm2022/masmarino-gabarit-job-graph.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-job-status.mjs +3 -3
- package/fesm2022/masmarino-gabarit-line-chart.mjs +6 -6
- package/fesm2022/masmarino-gabarit-list-card.mjs +5 -5
- package/fesm2022/masmarino-gabarit-list-card.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-list-row.mjs +5 -5
- package/fesm2022/masmarino-gabarit-list-row.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-list-toolbar.mjs +5 -5
- package/fesm2022/masmarino-gabarit-list-toolbar.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-menu.mjs +13 -13
- package/fesm2022/masmarino-gabarit-menu.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-mfa-enrollment.mjs +12 -11
- package/fesm2022/masmarino-gabarit-mfa-enrollment.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-mfa-settings.mjs +4 -3
- package/fesm2022/masmarino-gabarit-mfa-settings.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-modal.mjs +5 -5
- package/fesm2022/masmarino-gabarit-modal.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-nav-tabs.mjs +8 -8
- package/fesm2022/masmarino-gabarit-nav-tabs.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-notification-dot.mjs +3 -3
- package/fesm2022/masmarino-gabarit-page-header.mjs +3 -3
- package/fesm2022/masmarino-gabarit-page-layout.mjs +3 -3
- package/fesm2022/masmarino-gabarit-pagination.mjs +5 -5
- package/fesm2022/masmarino-gabarit-pagination.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-panel.mjs +3 -3
- package/fesm2022/masmarino-gabarit-passkey-settings.mjs +4 -3
- package/fesm2022/masmarino-gabarit-passkey-settings.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-pie-chart.mjs +5 -5
- package/fesm2022/masmarino-gabarit-pie-chart.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-popover.mjs +3 -3
- package/fesm2022/masmarino-gabarit-radio-group.mjs +5 -5
- package/fesm2022/masmarino-gabarit-radio-group.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-save-status.mjs +3 -3
- package/fesm2022/masmarino-gabarit-search-bar.mjs +5 -5
- package/fesm2022/masmarino-gabarit-search-bar.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-secret-reveal.mjs +3 -3
- package/fesm2022/masmarino-gabarit-segmented-control.mjs +5 -5
- package/fesm2022/masmarino-gabarit-segmented-control.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-select.mjs +5 -5
- package/fesm2022/masmarino-gabarit-select.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-skeleton-list.mjs +3 -3
- package/fesm2022/masmarino-gabarit-skeleton.mjs +3 -3
- package/fesm2022/masmarino-gabarit-slider.mjs +5 -5
- package/fesm2022/masmarino-gabarit-slider.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-sparkline.mjs +3 -3
- package/fesm2022/masmarino-gabarit-spinner.mjs +3 -3
- package/fesm2022/masmarino-gabarit-stat-grid.mjs +5 -5
- package/fesm2022/masmarino-gabarit-stat-grid.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-stat-tile.mjs +10 -10
- package/fesm2022/masmarino-gabarit-stat-tile.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-stepper.mjs +5 -5
- package/fesm2022/masmarino-gabarit-stepper.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-switch.mjs +5 -5
- package/fesm2022/masmarino-gabarit-switch.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-table.mjs +5 -5
- package/fesm2022/masmarino-gabarit-table.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-tabs.mjs +8 -8
- package/fesm2022/masmarino-gabarit-tabs.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-tag-input.mjs +5 -5
- package/fesm2022/masmarino-gabarit-tag-input.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-tag.mjs +5 -5
- package/fesm2022/masmarino-gabarit-tag.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-textarea.mjs +5 -5
- package/fesm2022/masmarino-gabarit-textarea.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-timeline-chart.mjs +6 -6
- package/fesm2022/masmarino-gabarit-toaster.mjs +8 -8
- package/fesm2022/masmarino-gabarit-toaster.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-tooltip.mjs +5 -5
- package/fesm2022/masmarino-gabarit-tooltip.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-tree.mjs +5 -5
- package/fesm2022/masmarino-gabarit-tree.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-user-chip.mjs +3 -3
- package/fesm2022/masmarino-gabarit.mjs +3 -2
- package/fesm2022/masmarino-gabarit.mjs.map +1 -1
- package/file-upload/package.json +4 -0
- package/floating-panel/package.json +4 -0
- package/format/package.json +4 -0
- package/funnel-chart/package.json +4 -0
- package/gauge-bar/package.json +4 -0
- package/git-field/package.json +4 -0
- package/icon/package.json +4 -0
- package/icon-marker/package.json +4 -0
- package/input/package.json +4 -0
- package/job-graph/package.json +4 -0
- package/job-status/package.json +4 -0
- package/line-chart/package.json +4 -0
- package/list-card/package.json +4 -0
- package/list-row/package.json +4 -0
- package/list-toolbar/package.json +4 -0
- package/menu/package.json +4 -0
- package/mfa-enrollment/package.json +4 -0
- package/mfa-settings/package.json +4 -0
- package/modal/package.json +4 -0
- package/nav-tabs/package.json +4 -0
- package/notification-dot/package.json +4 -0
- package/package.json +6 -2
- package/page-header/package.json +4 -0
- package/page-layout/package.json +4 -0
- package/pagination/package.json +4 -0
- package/panel/package.json +4 -0
- package/passkey-settings/package.json +4 -0
- package/pie-chart/package.json +4 -0
- package/popover/package.json +4 -0
- package/radio-group/package.json +4 -0
- package/save-status/package.json +4 -0
- package/search-bar/package.json +4 -0
- package/secret-reveal/package.json +4 -0
- package/segmented-control/package.json +4 -0
- package/select/package.json +4 -0
- package/skeleton/package.json +4 -0
- package/skeleton-list/package.json +4 -0
- package/slider/package.json +4 -0
- package/sparkline/package.json +4 -0
- package/spinner/package.json +4 -0
- package/src/lib/tokens/_base.scss +4 -0
- package/src/lib/tokens/_depth.scss +53 -0
- package/src/lib/tokens/_palette.scss +5 -1
- package/src/lib/tokens/_semantic.scss +9 -3
- package/src/lib/tokens/_themes.scss +79 -4
- package/src/lib/tokens/_utilities.scss +25 -2
- package/src/lib/tokens/index.scss +1 -0
- package/stat-grid/package.json +4 -0
- package/stat-tile/package.json +4 -0
- package/stepper/package.json +4 -0
- package/switch/package.json +4 -0
- package/table/package.json +4 -0
- package/tabs/package.json +4 -0
- package/tag/package.json +4 -0
- package/tag-input/package.json +4 -0
- package/textarea/package.json +4 -0
- package/timeline-chart/package.json +4 -0
- package/toaster/package.json +4 -0
- package/tooltip/package.json +4 -0
- package/tree/package.json +4 -0
- package/types/masmarino-gabarit-avatar.d.ts +1 -1
- package/types/masmarino-gabarit-card.d.ts +7 -0
- package/types/masmarino-gabarit-chart.d.ts +0 -27
- package/types/masmarino-gabarit-command-palette.d.ts +218 -0
- package/types/masmarino-gabarit-date-picker.d.ts +0 -59
- package/types/masmarino-gabarit-line-chart.d.ts +0 -1
- package/types/masmarino-gabarit-nav-tabs.d.ts +0 -5
- package/types/masmarino-gabarit-pagination.d.ts +0 -1
- package/types/masmarino-gabarit-tree.d.ts +0 -1
- package/types/masmarino-gabarit.d.ts +3 -2
- package/user-chip/package.json +4 -0
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, HostListener, Injector, afterNextRender, afterRenderEffect, computed, effect, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
|
|
3
|
+
import { Icon } from "@masmarino/gabarit/icon";
|
|
4
|
+
import { Spinner } from "@masmarino/gabarit/spinner";
|
|
5
|
+
function normalize(text) {
|
|
6
|
+
return text.normalize("NFD").replace(/\p{Diacritic}/gu, "").toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
function matchCommand(item, query) {
|
|
9
|
+
const words = normalize(query).split(/\s+/).filter(Boolean);
|
|
10
|
+
if (words.length === 0) return 0;
|
|
11
|
+
const label = normalize(item.label);
|
|
12
|
+
const haystack = [
|
|
13
|
+
label,
|
|
14
|
+
normalize(item.description ?? ""),
|
|
15
|
+
...(item.keywords ?? []).map(normalize)
|
|
16
|
+
].join(" ");
|
|
17
|
+
if (!words.every((word) => haystack.includes(word))) return null;
|
|
18
|
+
const whole = words.join(" ");
|
|
19
|
+
if (label.startsWith(whole)) return 3;
|
|
20
|
+
if (label.split(/[\s/._-]+/).some((part) => part.startsWith(words[0]))) return 2;
|
|
21
|
+
return 1;
|
|
22
|
+
}
|
|
23
|
+
function parseShortcut(shortcut) {
|
|
24
|
+
const parts = shortcut.toLowerCase().split("+");
|
|
25
|
+
const key = parts.pop() ?? "";
|
|
26
|
+
return {
|
|
27
|
+
mod: parts.includes("mod"),
|
|
28
|
+
shift: parts.includes("shift"),
|
|
29
|
+
alt: parts.includes("alt"),
|
|
30
|
+
key
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function isApplePlatform() {
|
|
34
|
+
if (typeof navigator === "undefined") return false;
|
|
35
|
+
const platform = navigator.userAgentData?.platform ?? navigator.platform ?? "";
|
|
36
|
+
return /mac|iphone|ipad|ipod/i.test(platform || navigator.userAgent);
|
|
37
|
+
}
|
|
38
|
+
function isTyping(target) {
|
|
39
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
40
|
+
return target.isContentEditable || target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement;
|
|
41
|
+
}
|
|
42
|
+
function matchesShortcut(event, shortcut, apple = isApplePlatform()) {
|
|
43
|
+
const parsed = parseShortcut(shortcut);
|
|
44
|
+
const mod = apple ? event.metaKey : event.ctrlKey;
|
|
45
|
+
const otherMod = apple ? event.ctrlKey : event.metaKey;
|
|
46
|
+
if (parsed.mod !== mod || otherMod) return false;
|
|
47
|
+
if (parsed.alt !== event.altKey) return false;
|
|
48
|
+
if (parsed.shift && !event.shiftKey) return false;
|
|
49
|
+
if (!parsed.mod && !parsed.alt && isTyping(event.target)) return false;
|
|
50
|
+
return event.key.toLowerCase() === parsed.key;
|
|
51
|
+
}
|
|
52
|
+
function shortcutLabel(shortcut, apple = isApplePlatform()) {
|
|
53
|
+
const parsed = parseShortcut(shortcut);
|
|
54
|
+
const key = parsed.key.length === 1 ? parsed.key.toUpperCase() : parsed.key;
|
|
55
|
+
if (apple) return `${parsed.mod ? "⌘" : ""}${parsed.alt ? "⌥" : ""}${parsed.shift ? "⇧" : ""}${key}`;
|
|
56
|
+
return [
|
|
57
|
+
parsed.mod ? "Ctrl" : null,
|
|
58
|
+
parsed.alt ? "Alt" : null,
|
|
59
|
+
parsed.shift ? "Shift" : null,
|
|
60
|
+
key
|
|
61
|
+
].filter(Boolean).join(" ");
|
|
62
|
+
}
|
|
63
|
+
function ariaKeyshortcuts(shortcut, apple = isApplePlatform()) {
|
|
64
|
+
const parsed = parseShortcut(shortcut);
|
|
65
|
+
const key = parsed.key.length === 1 ? parsed.key.toUpperCase() : parsed.key;
|
|
66
|
+
return [
|
|
67
|
+
parsed.mod ? apple ? "Meta" : "Control" : null,
|
|
68
|
+
parsed.alt ? "Alt" : null,
|
|
69
|
+
parsed.shift ? "Shift" : null,
|
|
70
|
+
key
|
|
71
|
+
].filter(Boolean).join("+");
|
|
72
|
+
}
|
|
73
|
+
let nextPaletteId = 0;
|
|
74
|
+
var CommandPalette = class CommandPalette {
|
|
75
|
+
injector = inject(Injector);
|
|
76
|
+
open = model(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
|
|
77
|
+
groups = input([], ...ngDevMode ? [{ debugName: "groups" }] : /* istanbul ignore next */ []);
|
|
78
|
+
shortcuts = input(["mod+k"], ...ngDevMode ? [{ debugName: "shortcuts" }] : /* istanbul ignore next */ []);
|
|
79
|
+
maxItemsPerGroup = input(8, ...ngDevMode ? [{ debugName: "maxItemsPerGroup" }] : /* istanbul ignore next */ []);
|
|
80
|
+
placeholder = input("Search or jump to…", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
|
|
81
|
+
ariaLabel = input("Command palette", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
82
|
+
loading = input(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
|
|
83
|
+
loadingLabel = input("Searching…", ...ngDevMode ? [{ debugName: "loadingLabel" }] : /* istanbul ignore next */ []);
|
|
84
|
+
emptyMessage = input("No results", ...ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []);
|
|
85
|
+
navigateHint = input("Navigate", ...ngDevMode ? [{ debugName: "navigateHint" }] : /* istanbul ignore next */ []);
|
|
86
|
+
selectHint = input("Open", ...ngDevMode ? [{ debugName: "selectHint" }] : /* istanbul ignore next */ []);
|
|
87
|
+
closeHint = input("Close", ...ngDevMode ? [{ debugName: "closeHint" }] : /* istanbul ignore next */ []);
|
|
88
|
+
closeLabel = input("Close", ...ngDevMode ? [{ debugName: "closeLabel" }] : /* istanbul ignore next */ []);
|
|
89
|
+
resultsAnnouncement = input((count) => count === 1 ? "1 result" : `${count} results`, ...ngDevMode ? [{ debugName: "resultsAnnouncement" }] : /* istanbul ignore next */ []);
|
|
90
|
+
queryChange = output();
|
|
91
|
+
itemSelected = output();
|
|
92
|
+
id = `gbt-command-palette-${++nextPaletteId}`;
|
|
93
|
+
listId = `${this.id}-list`;
|
|
94
|
+
query = signal("", ...ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []);
|
|
95
|
+
activeIndex = signal(0, ...ngDevMode ? [{ debugName: "activeIndex" }] : /* istanbul ignore next */ []);
|
|
96
|
+
input = viewChild("input", ...ngDevMode ? [{ debugName: "input" }] : /* istanbul ignore next */ []);
|
|
97
|
+
list = viewChild("list", ...ngDevMode ? [{ debugName: "list" }] : /* istanbul ignore next */ []);
|
|
98
|
+
previouslyFocused = null;
|
|
99
|
+
visibleGroups = computed(() => {
|
|
100
|
+
const query = this.query().trim();
|
|
101
|
+
const max = this.maxItemsPerGroup();
|
|
102
|
+
let index = 0;
|
|
103
|
+
const groups = [];
|
|
104
|
+
this.groups().forEach((group, groupIndex) => {
|
|
105
|
+
let items = [...group.items];
|
|
106
|
+
if (group.filter !== false && query) items = items.map((item, order) => ({
|
|
107
|
+
item,
|
|
108
|
+
order,
|
|
109
|
+
score: matchCommand(item, query)
|
|
110
|
+
})).filter((entry) => entry.score !== null).sort((a, b) => b.score - a.score || a.order - b.order).slice(0, max).map((entry) => entry.item);
|
|
111
|
+
if (items.length === 0) return;
|
|
112
|
+
groups.push({
|
|
113
|
+
label: group.label,
|
|
114
|
+
labelId: `${this.id}-group-${groupIndex}`,
|
|
115
|
+
items: items.map((item) => ({
|
|
116
|
+
item,
|
|
117
|
+
index: index++
|
|
118
|
+
}))
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return groups;
|
|
122
|
+
}, ...ngDevMode ? [{ debugName: "visibleGroups" }] : /* istanbul ignore next */ []);
|
|
123
|
+
visibleItems = computed(() => this.visibleGroups().flatMap((group) => group.items.map((entry) => entry.item)), ...ngDevMode ? [{ debugName: "visibleItems" }] : /* istanbul ignore next */ []);
|
|
124
|
+
activeId = computed(() => {
|
|
125
|
+
const count = this.visibleItems().length;
|
|
126
|
+
return count > 0 ? this.optionId(Math.min(this.activeIndex(), count - 1)) : null;
|
|
127
|
+
}, ...ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []);
|
|
128
|
+
announcement = computed(() => this.loading() ? this.loadingLabel() : this.resultsAnnouncement()(this.visibleItems().length), ...ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []);
|
|
129
|
+
constructor() {
|
|
130
|
+
effect(() => {
|
|
131
|
+
if (this.open()) untracked(() => {
|
|
132
|
+
this.previouslyFocused = document.activeElement;
|
|
133
|
+
this.setQuery("");
|
|
134
|
+
afterNextRender(() => this.input()?.nativeElement.focus(), { injector: this.injector });
|
|
135
|
+
});
|
|
136
|
+
else if (this.previouslyFocused) {
|
|
137
|
+
const target = this.previouslyFocused;
|
|
138
|
+
this.previouslyFocused = null;
|
|
139
|
+
if (target.isConnected) target.focus();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
afterRenderEffect(() => {
|
|
143
|
+
const id = this.activeId();
|
|
144
|
+
if (!id) return;
|
|
145
|
+
this.list()?.nativeElement.querySelector(`#${CSS.escape(id)}`)?.scrollIntoView?.({ block: "nearest" });
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
show() {
|
|
149
|
+
this.open.set(true);
|
|
150
|
+
}
|
|
151
|
+
close() {
|
|
152
|
+
this.open.set(false);
|
|
153
|
+
}
|
|
154
|
+
onDocumentKeydown(event) {
|
|
155
|
+
if (event.defaultPrevented) return;
|
|
156
|
+
if (this.shortcuts().some((shortcut) => matchesShortcut(event, shortcut))) {
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
this.open.update((open) => !open);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
optionId(index) {
|
|
162
|
+
return `${this.id}-option-${index}`;
|
|
163
|
+
}
|
|
164
|
+
onInput(event) {
|
|
165
|
+
this.setQuery(event.target.value);
|
|
166
|
+
}
|
|
167
|
+
onKeydown(event) {
|
|
168
|
+
const count = this.visibleItems().length;
|
|
169
|
+
switch (event.key) {
|
|
170
|
+
case "Escape":
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
event.stopPropagation();
|
|
173
|
+
this.close();
|
|
174
|
+
return;
|
|
175
|
+
case "Tab":
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
return;
|
|
178
|
+
case "ArrowDown":
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
if (count > 0) this.activeIndex.update((index) => (index + 1) % count);
|
|
181
|
+
return;
|
|
182
|
+
case "ArrowUp":
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
if (count > 0) this.activeIndex.update((index) => (index - 1 + count) % count);
|
|
185
|
+
return;
|
|
186
|
+
case "Home":
|
|
187
|
+
case "End":
|
|
188
|
+
if (count > 0 && (event.ctrlKey || event.metaKey)) {
|
|
189
|
+
event.preventDefault();
|
|
190
|
+
this.activeIndex.set(event.key === "Home" ? 0 : count - 1);
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
case "Enter": {
|
|
194
|
+
const item = this.visibleItems()[Math.min(this.activeIndex(), count - 1)];
|
|
195
|
+
if (!item) return;
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
this.select(item);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
activate(index) {
|
|
203
|
+
this.activeIndex.set(index);
|
|
204
|
+
}
|
|
205
|
+
select(item) {
|
|
206
|
+
this.close();
|
|
207
|
+
this.itemSelected.emit(item);
|
|
208
|
+
}
|
|
209
|
+
onBackdropMousedown(event) {
|
|
210
|
+
if (event.target === event.currentTarget) this.close();
|
|
211
|
+
}
|
|
212
|
+
setQuery(query) {
|
|
213
|
+
this.query.set(query);
|
|
214
|
+
this.activeIndex.set(0);
|
|
215
|
+
this.queryChange.emit(query);
|
|
216
|
+
}
|
|
217
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
218
|
+
minVersion: "12.0.0",
|
|
219
|
+
version: "22.2.4",
|
|
220
|
+
ngImport: i0,
|
|
221
|
+
type: CommandPalette,
|
|
222
|
+
deps: [],
|
|
223
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
224
|
+
});
|
|
225
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
226
|
+
minVersion: "17.0.0",
|
|
227
|
+
version: "22.2.4",
|
|
228
|
+
type: CommandPalette,
|
|
229
|
+
isStandalone: true,
|
|
230
|
+
selector: "gbt-command-palette",
|
|
231
|
+
inputs: {
|
|
232
|
+
open: {
|
|
233
|
+
classPropertyName: "open",
|
|
234
|
+
publicName: "open",
|
|
235
|
+
isSignal: true,
|
|
236
|
+
isRequired: false,
|
|
237
|
+
transformFunction: null
|
|
238
|
+
},
|
|
239
|
+
groups: {
|
|
240
|
+
classPropertyName: "groups",
|
|
241
|
+
publicName: "groups",
|
|
242
|
+
isSignal: true,
|
|
243
|
+
isRequired: false,
|
|
244
|
+
transformFunction: null
|
|
245
|
+
},
|
|
246
|
+
shortcuts: {
|
|
247
|
+
classPropertyName: "shortcuts",
|
|
248
|
+
publicName: "shortcuts",
|
|
249
|
+
isSignal: true,
|
|
250
|
+
isRequired: false,
|
|
251
|
+
transformFunction: null
|
|
252
|
+
},
|
|
253
|
+
maxItemsPerGroup: {
|
|
254
|
+
classPropertyName: "maxItemsPerGroup",
|
|
255
|
+
publicName: "maxItemsPerGroup",
|
|
256
|
+
isSignal: true,
|
|
257
|
+
isRequired: false,
|
|
258
|
+
transformFunction: null
|
|
259
|
+
},
|
|
260
|
+
placeholder: {
|
|
261
|
+
classPropertyName: "placeholder",
|
|
262
|
+
publicName: "placeholder",
|
|
263
|
+
isSignal: true,
|
|
264
|
+
isRequired: false,
|
|
265
|
+
transformFunction: null
|
|
266
|
+
},
|
|
267
|
+
ariaLabel: {
|
|
268
|
+
classPropertyName: "ariaLabel",
|
|
269
|
+
publicName: "ariaLabel",
|
|
270
|
+
isSignal: true,
|
|
271
|
+
isRequired: false,
|
|
272
|
+
transformFunction: null
|
|
273
|
+
},
|
|
274
|
+
loading: {
|
|
275
|
+
classPropertyName: "loading",
|
|
276
|
+
publicName: "loading",
|
|
277
|
+
isSignal: true,
|
|
278
|
+
isRequired: false,
|
|
279
|
+
transformFunction: null
|
|
280
|
+
},
|
|
281
|
+
loadingLabel: {
|
|
282
|
+
classPropertyName: "loadingLabel",
|
|
283
|
+
publicName: "loadingLabel",
|
|
284
|
+
isSignal: true,
|
|
285
|
+
isRequired: false,
|
|
286
|
+
transformFunction: null
|
|
287
|
+
},
|
|
288
|
+
emptyMessage: {
|
|
289
|
+
classPropertyName: "emptyMessage",
|
|
290
|
+
publicName: "emptyMessage",
|
|
291
|
+
isSignal: true,
|
|
292
|
+
isRequired: false,
|
|
293
|
+
transformFunction: null
|
|
294
|
+
},
|
|
295
|
+
navigateHint: {
|
|
296
|
+
classPropertyName: "navigateHint",
|
|
297
|
+
publicName: "navigateHint",
|
|
298
|
+
isSignal: true,
|
|
299
|
+
isRequired: false,
|
|
300
|
+
transformFunction: null
|
|
301
|
+
},
|
|
302
|
+
selectHint: {
|
|
303
|
+
classPropertyName: "selectHint",
|
|
304
|
+
publicName: "selectHint",
|
|
305
|
+
isSignal: true,
|
|
306
|
+
isRequired: false,
|
|
307
|
+
transformFunction: null
|
|
308
|
+
},
|
|
309
|
+
closeHint: {
|
|
310
|
+
classPropertyName: "closeHint",
|
|
311
|
+
publicName: "closeHint",
|
|
312
|
+
isSignal: true,
|
|
313
|
+
isRequired: false,
|
|
314
|
+
transformFunction: null
|
|
315
|
+
},
|
|
316
|
+
closeLabel: {
|
|
317
|
+
classPropertyName: "closeLabel",
|
|
318
|
+
publicName: "closeLabel",
|
|
319
|
+
isSignal: true,
|
|
320
|
+
isRequired: false,
|
|
321
|
+
transformFunction: null
|
|
322
|
+
},
|
|
323
|
+
resultsAnnouncement: {
|
|
324
|
+
classPropertyName: "resultsAnnouncement",
|
|
325
|
+
publicName: "resultsAnnouncement",
|
|
326
|
+
isSignal: true,
|
|
327
|
+
isRequired: false,
|
|
328
|
+
transformFunction: null
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
outputs: {
|
|
332
|
+
open: "openChange",
|
|
333
|
+
queryChange: "queryChange",
|
|
334
|
+
itemSelected: "itemSelected"
|
|
335
|
+
},
|
|
336
|
+
host: { listeners: { "document:keydown": "onDocumentKeydown($event)" } },
|
|
337
|
+
viewQueries: [{
|
|
338
|
+
propertyName: "input",
|
|
339
|
+
first: true,
|
|
340
|
+
predicate: ["input"],
|
|
341
|
+
descendants: true,
|
|
342
|
+
isSignal: true
|
|
343
|
+
}, {
|
|
344
|
+
propertyName: "list",
|
|
345
|
+
first: true,
|
|
346
|
+
predicate: ["list"],
|
|
347
|
+
descendants: true,
|
|
348
|
+
isSignal: true
|
|
349
|
+
}],
|
|
350
|
+
ngImport: i0,
|
|
351
|
+
template: "@if (open()) {\n <div class=\"gbt-cp__backdrop\" (mousedown)=\"onBackdropMousedown($event)\">\n <div\n class=\"gbt-cp\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-label]=\"ariaLabel()\"\n (keydown)=\"onKeydown($event)\"\n >\n <div class=\"gbt-cp__field\">\n <gbt-icon name=\"search\" class=\"gbt-cp__field-icon\" aria-hidden=\"true\" />\n <input\n #input\n type=\"text\"\n class=\"gbt-cp__input\"\n role=\"combobox\"\n aria-expanded=\"true\"\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"activeId()\"\n [placeholder]=\"placeholder()\"\n [value]=\"query()\"\n (input)=\"onInput($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n @if (loading()) {\n <gbt-spinner size=\"sm\" [label]=\"loadingLabel()\" />\n }\n <!-- Shown on phones only: without a keyboard, nothing else closes a palette that fills the screen. -->\n <button\n type=\"button\"\n class=\"gbt-cp__close\"\n [attr.aria-label]=\"closeLabel()\"\n (click)=\"close()\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n </div>\n\n <!-- Clicking an option must not take the focus from the field. -->\n <div\n #list\n class=\"gbt-cp__list\"\n role=\"listbox\"\n [id]=\"listId\"\n [attr.aria-label]=\"ariaLabel()\"\n (mousedown)=\"$event.preventDefault()\"\n >\n @for (group of visibleGroups(); track group.labelId) {\n <div class=\"gbt-cp__group\" role=\"group\" [attr.aria-labelledby]=\"group.labelId\">\n <div class=\"gbt-cp__group-label\" [id]=\"group.labelId\">{{ group.label }}</div>\n @for (entry of group.items; track entry.item.id) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <div\n class=\"gbt-cp__item\"\n role=\"option\"\n [id]=\"optionId(entry.index)\"\n [attr.aria-selected]=\"optionId(entry.index) === activeId()\"\n [class.gbt-cp__item--active]=\"optionId(entry.index) === activeId()\"\n (mousemove)=\"activate(entry.index)\"\n (click)=\"select(entry.item)\"\n >\n @if (entry.item.icon) {\n <gbt-icon class=\"gbt-cp__item-icon\" [name]=\"entry.item.icon\" aria-hidden=\"true\" />\n }\n <span class=\"gbt-cp__item-text\">\n <span class=\"gbt-cp__item-label\">{{ entry.item.label }}</span>\n @if (entry.item.description) {\n <span class=\"gbt-cp__item-description\">{{ entry.item.description }}</span>\n }\n </span>\n @if (entry.item.shortcut?.length) {\n <span class=\"gbt-cp__item-shortcut\" aria-hidden=\"true\">\n @for (key of entry.item.shortcut; track $index) {\n <kbd class=\"gbt-cp__kbd\">{{ key }}</kbd>\n }\n </span>\n }\n </div>\n }\n </div>\n } @empty {\n <p class=\"gbt-cp__empty\">{{ loading() ? loadingLabel() : emptyMessage() }}</p>\n }\n </div>\n\n <div class=\"gbt-cp__footer\" aria-hidden=\"true\">\n <span class=\"gbt-cp__hint\"\n ><kbd class=\"gbt-cp__kbd\">↑</kbd><kbd class=\"gbt-cp__kbd\">↓</kbd\n >{{ navigateHint() }}</span\n >\n <span class=\"gbt-cp__hint\"><kbd class=\"gbt-cp__kbd\">↵</kbd>{{ selectHint() }}</span>\n <span class=\"gbt-cp__hint\"><kbd class=\"gbt-cp__kbd\">Esc</kbd>{{ closeHint() }}</span>\n </div>\n <div class=\"sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {{ announcement() }}\n </div>\n </div>\n </div>\n}\n",
|
|
352
|
+
styles: [".gbt-cp__backdrop{position:fixed;inset:0;z-index:1300;display:flex;justify-content:center;align-items:flex-start;padding:12vh 16px 16px;background:#0006;animation:gbt-cp-fade-in .15s cubic-bezier(.4,0,.2,1) both}.gbt-cp{display:flex;flex-direction:column;width:min(640px,100%);max-height:min(560px,76vh);overflow:hidden;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-lg);box-shadow:0 16px 48px #0000002e,0 4px 12px #00000014;animation:gbt-cp-rise .18s cubic-bezier(.4,0,.2,1) both}.gbt-cp__field{display:flex;flex:none;align-items:center;gap:10px;padding:0 16px;border-bottom:1px solid var(--border-color)}.gbt-cp__field-icon{flex:none;color:var(--text-secondary)}.gbt-cp__close{display:none;flex:none;align-items:center;justify-content:center;width:44px;height:44px;margin-inline-end:-12px;padding:0;border:none;border-radius:var(--gbt-radius-chip, var(--site-border-radius-xs));background:none;color:var(--text-secondary);cursor:pointer}.gbt-cp__close:hover{background:var(--bg-hover);color:var(--text-primary)}.gbt-cp__close:active{background:var(--bg-press);color:var(--text-primary)}.gbt-cp__close:focus-visible{outline:2px solid var(--gbt-focus-ring, var(--focus-ring));outline-offset:2px}.gbt-cp__input{flex:1;min-width:0;height:52px;padding:0;border:none;outline:none;background:transparent;color:var(--text-primary);font:inherit;font-size:16px}.gbt-cp__input::placeholder{color:var(--text-secondary)}.gbt-cp__list{flex:1 1 auto;min-height:0;overflow-y:auto;padding:6px;overscroll-behavior:contain}.gbt-cp__group+.gbt-cp__group{margin-top:4px}.gbt-cp__group-label{padding:8px 10px 4px;color:var(--text-secondary);font-size:12px;font-weight:600}.gbt-cp__item{display:flex;align-items:center;gap:10px;min-height:40px;padding:6px 10px;border-radius:var(--gbt-radius-menu, var(--site-border-radius-sm));color:var(--text-primary);cursor:pointer}.gbt-cp__item:hover{background:var(--bg-hover)}.gbt-cp__item:active{background:var(--bg-press)}.gbt-cp__item--active{background:color-mix(in srgb,var(--primary) 9%,transparent)}@media(forced-colors:active){.gbt-cp__item--active{outline:2px solid Highlight;outline-offset:-2px}}.gbt-cp__item-icon{flex:none;color:var(--text-secondary)}.gbt-cp__item--active .gbt-cp__item-icon{color:var(--primary)}.gbt-cp__item-text{display:flex;flex:1;align-items:baseline;gap:8px;min-width:0}.gbt-cp__item-label{flex:none;max-width:100%;overflow:hidden;font-size:14px;font-weight:500;white-space:nowrap;text-overflow:ellipsis}.gbt-cp__item-description{flex:1;min-width:0;overflow:hidden;color:var(--text-secondary);font-size:13px;white-space:nowrap;text-overflow:ellipsis}.gbt-cp__item-shortcut{display:inline-flex;flex:none;gap:4px}.gbt-cp__kbd{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 5px;box-sizing:border-box;border:1px solid var(--border-color);border-radius:var(--gbt-radius-chip, var(--site-border-radius-xs));background:var(--bg-panel, var(--bg-principal));color:var(--text-secondary);font-family:inherit;font-size:11px;font-weight:600;line-height:1}.gbt-cp__empty{margin:0;padding:32px 16px;color:var(--text-secondary);font-size:14px;text-align:center}.gbt-cp__footer{display:flex;flex:none;flex-wrap:wrap;gap:4px 16px;padding:8px 16px;border-top:1px solid var(--border-color);color:var(--text-secondary);font-size:12px}.gbt-cp__hint{display:inline-flex;align-items:center;gap:4px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}@media(max-width:599px){.gbt-cp__backdrop{padding:0}.gbt-cp{max-height:100dvh;border-width:0 0 1px;border-radius:0}.gbt-cp__item{min-height:44px}.gbt-cp__close{display:inline-flex}.gbt-cp__footer,.gbt-cp__item-shortcut{display:none}}@keyframes gbt-cp-fade-in{0%{opacity:0}}@keyframes gbt-cp-rise{0%{opacity:0;transform:translateY(-6px)}}@media(prefers-reduced-motion:reduce){.gbt-cp__backdrop,.gbt-cp{animation:none}}\n"],
|
|
353
|
+
dependencies: [{
|
|
354
|
+
kind: "component",
|
|
355
|
+
type: Icon,
|
|
356
|
+
selector: "gbt-icon",
|
|
357
|
+
inputs: ["name"]
|
|
358
|
+
}, {
|
|
359
|
+
kind: "component",
|
|
360
|
+
type: Spinner,
|
|
361
|
+
selector: "gbt-spinner",
|
|
362
|
+
inputs: ["size", "label"]
|
|
363
|
+
}],
|
|
364
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
368
|
+
minVersion: "12.0.0",
|
|
369
|
+
version: "22.2.4",
|
|
370
|
+
ngImport: i0,
|
|
371
|
+
type: CommandPalette,
|
|
372
|
+
decorators: [{
|
|
373
|
+
type: Component,
|
|
374
|
+
args: [{
|
|
375
|
+
selector: "gbt-command-palette",
|
|
376
|
+
standalone: true,
|
|
377
|
+
imports: [Icon, Spinner],
|
|
378
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
379
|
+
template: "@if (open()) {\n <div class=\"gbt-cp__backdrop\" (mousedown)=\"onBackdropMousedown($event)\">\n <div\n class=\"gbt-cp\"\n role=\"dialog\"\n aria-modal=\"true\"\n [attr.aria-label]=\"ariaLabel()\"\n (keydown)=\"onKeydown($event)\"\n >\n <div class=\"gbt-cp__field\">\n <gbt-icon name=\"search\" class=\"gbt-cp__field-icon\" aria-hidden=\"true\" />\n <input\n #input\n type=\"text\"\n class=\"gbt-cp__input\"\n role=\"combobox\"\n aria-expanded=\"true\"\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-controls]=\"listId\"\n [attr.aria-activedescendant]=\"activeId()\"\n [placeholder]=\"placeholder()\"\n [value]=\"query()\"\n (input)=\"onInput($event)\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n />\n @if (loading()) {\n <gbt-spinner size=\"sm\" [label]=\"loadingLabel()\" />\n }\n <!-- Shown on phones only: without a keyboard, nothing else closes a palette that fills the screen. -->\n <button\n type=\"button\"\n class=\"gbt-cp__close\"\n [attr.aria-label]=\"closeLabel()\"\n (click)=\"close()\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n </div>\n\n <!-- Clicking an option must not take the focus from the field. -->\n <div\n #list\n class=\"gbt-cp__list\"\n role=\"listbox\"\n [id]=\"listId\"\n [attr.aria-label]=\"ariaLabel()\"\n (mousedown)=\"$event.preventDefault()\"\n >\n @for (group of visibleGroups(); track group.labelId) {\n <div class=\"gbt-cp__group\" role=\"group\" [attr.aria-labelledby]=\"group.labelId\">\n <div class=\"gbt-cp__group-label\" [id]=\"group.labelId\">{{ group.label }}</div>\n @for (entry of group.items; track entry.item.id) {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->\n <div\n class=\"gbt-cp__item\"\n role=\"option\"\n [id]=\"optionId(entry.index)\"\n [attr.aria-selected]=\"optionId(entry.index) === activeId()\"\n [class.gbt-cp__item--active]=\"optionId(entry.index) === activeId()\"\n (mousemove)=\"activate(entry.index)\"\n (click)=\"select(entry.item)\"\n >\n @if (entry.item.icon) {\n <gbt-icon class=\"gbt-cp__item-icon\" [name]=\"entry.item.icon\" aria-hidden=\"true\" />\n }\n <span class=\"gbt-cp__item-text\">\n <span class=\"gbt-cp__item-label\">{{ entry.item.label }}</span>\n @if (entry.item.description) {\n <span class=\"gbt-cp__item-description\">{{ entry.item.description }}</span>\n }\n </span>\n @if (entry.item.shortcut?.length) {\n <span class=\"gbt-cp__item-shortcut\" aria-hidden=\"true\">\n @for (key of entry.item.shortcut; track $index) {\n <kbd class=\"gbt-cp__kbd\">{{ key }}</kbd>\n }\n </span>\n }\n </div>\n }\n </div>\n } @empty {\n <p class=\"gbt-cp__empty\">{{ loading() ? loadingLabel() : emptyMessage() }}</p>\n }\n </div>\n\n <div class=\"gbt-cp__footer\" aria-hidden=\"true\">\n <span class=\"gbt-cp__hint\"\n ><kbd class=\"gbt-cp__kbd\">↑</kbd><kbd class=\"gbt-cp__kbd\">↓</kbd\n >{{ navigateHint() }}</span\n >\n <span class=\"gbt-cp__hint\"><kbd class=\"gbt-cp__kbd\">↵</kbd>{{ selectHint() }}</span>\n <span class=\"gbt-cp__hint\"><kbd class=\"gbt-cp__kbd\">Esc</kbd>{{ closeHint() }}</span>\n </div>\n <div class=\"sr-only\" role=\"status\" aria-live=\"polite\" aria-atomic=\"true\">\n {{ announcement() }}\n </div>\n </div>\n </div>\n}\n",
|
|
380
|
+
styles: [".gbt-cp__backdrop{position:fixed;inset:0;z-index:1300;display:flex;justify-content:center;align-items:flex-start;padding:12vh 16px 16px;background:#0006;animation:gbt-cp-fade-in .15s cubic-bezier(.4,0,.2,1) both}.gbt-cp{display:flex;flex-direction:column;width:min(640px,100%);max-height:min(560px,76vh);overflow:hidden;background:var(--bg-principal);border:1px solid var(--border-color);border-radius:var(--site-border-radius-lg);box-shadow:0 16px 48px #0000002e,0 4px 12px #00000014;animation:gbt-cp-rise .18s cubic-bezier(.4,0,.2,1) both}.gbt-cp__field{display:flex;flex:none;align-items:center;gap:10px;padding:0 16px;border-bottom:1px solid var(--border-color)}.gbt-cp__field-icon{flex:none;color:var(--text-secondary)}.gbt-cp__close{display:none;flex:none;align-items:center;justify-content:center;width:44px;height:44px;margin-inline-end:-12px;padding:0;border:none;border-radius:var(--gbt-radius-chip, var(--site-border-radius-xs));background:none;color:var(--text-secondary);cursor:pointer}.gbt-cp__close:hover{background:var(--bg-hover);color:var(--text-primary)}.gbt-cp__close:active{background:var(--bg-press);color:var(--text-primary)}.gbt-cp__close:focus-visible{outline:2px solid var(--gbt-focus-ring, var(--focus-ring));outline-offset:2px}.gbt-cp__input{flex:1;min-width:0;height:52px;padding:0;border:none;outline:none;background:transparent;color:var(--text-primary);font:inherit;font-size:16px}.gbt-cp__input::placeholder{color:var(--text-secondary)}.gbt-cp__list{flex:1 1 auto;min-height:0;overflow-y:auto;padding:6px;overscroll-behavior:contain}.gbt-cp__group+.gbt-cp__group{margin-top:4px}.gbt-cp__group-label{padding:8px 10px 4px;color:var(--text-secondary);font-size:12px;font-weight:600}.gbt-cp__item{display:flex;align-items:center;gap:10px;min-height:40px;padding:6px 10px;border-radius:var(--gbt-radius-menu, var(--site-border-radius-sm));color:var(--text-primary);cursor:pointer}.gbt-cp__item:hover{background:var(--bg-hover)}.gbt-cp__item:active{background:var(--bg-press)}.gbt-cp__item--active{background:color-mix(in srgb,var(--primary) 9%,transparent)}@media(forced-colors:active){.gbt-cp__item--active{outline:2px solid Highlight;outline-offset:-2px}}.gbt-cp__item-icon{flex:none;color:var(--text-secondary)}.gbt-cp__item--active .gbt-cp__item-icon{color:var(--primary)}.gbt-cp__item-text{display:flex;flex:1;align-items:baseline;gap:8px;min-width:0}.gbt-cp__item-label{flex:none;max-width:100%;overflow:hidden;font-size:14px;font-weight:500;white-space:nowrap;text-overflow:ellipsis}.gbt-cp__item-description{flex:1;min-width:0;overflow:hidden;color:var(--text-secondary);font-size:13px;white-space:nowrap;text-overflow:ellipsis}.gbt-cp__item-shortcut{display:inline-flex;flex:none;gap:4px}.gbt-cp__kbd{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 5px;box-sizing:border-box;border:1px solid var(--border-color);border-radius:var(--gbt-radius-chip, var(--site-border-radius-xs));background:var(--bg-panel, var(--bg-principal));color:var(--text-secondary);font-family:inherit;font-size:11px;font-weight:600;line-height:1}.gbt-cp__empty{margin:0;padding:32px 16px;color:var(--text-secondary);font-size:14px;text-align:center}.gbt-cp__footer{display:flex;flex:none;flex-wrap:wrap;gap:4px 16px;padding:8px 16px;border-top:1px solid var(--border-color);color:var(--text-secondary);font-size:12px}.gbt-cp__hint{display:inline-flex;align-items:center;gap:4px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}@media(max-width:599px){.gbt-cp__backdrop{padding:0}.gbt-cp{max-height:100dvh;border-width:0 0 1px;border-radius:0}.gbt-cp__item{min-height:44px}.gbt-cp__close{display:inline-flex}.gbt-cp__footer,.gbt-cp__item-shortcut{display:none}}@keyframes gbt-cp-fade-in{0%{opacity:0}}@keyframes gbt-cp-rise{0%{opacity:0;transform:translateY(-6px)}}@media(prefers-reduced-motion:reduce){.gbt-cp__backdrop,.gbt-cp{animation:none}}\n"]
|
|
381
|
+
}]
|
|
382
|
+
}],
|
|
383
|
+
ctorParameters: () => [],
|
|
384
|
+
propDecorators: {
|
|
385
|
+
open: [{
|
|
386
|
+
type: i0.Input,
|
|
387
|
+
args: [{
|
|
388
|
+
isSignal: true,
|
|
389
|
+
alias: "open",
|
|
390
|
+
required: false
|
|
391
|
+
}]
|
|
392
|
+
}, {
|
|
393
|
+
type: i0.Output,
|
|
394
|
+
args: ["openChange"]
|
|
395
|
+
}],
|
|
396
|
+
groups: [{
|
|
397
|
+
type: i0.Input,
|
|
398
|
+
args: [{
|
|
399
|
+
isSignal: true,
|
|
400
|
+
alias: "groups",
|
|
401
|
+
required: false
|
|
402
|
+
}]
|
|
403
|
+
}],
|
|
404
|
+
shortcuts: [{
|
|
405
|
+
type: i0.Input,
|
|
406
|
+
args: [{
|
|
407
|
+
isSignal: true,
|
|
408
|
+
alias: "shortcuts",
|
|
409
|
+
required: false
|
|
410
|
+
}]
|
|
411
|
+
}],
|
|
412
|
+
maxItemsPerGroup: [{
|
|
413
|
+
type: i0.Input,
|
|
414
|
+
args: [{
|
|
415
|
+
isSignal: true,
|
|
416
|
+
alias: "maxItemsPerGroup",
|
|
417
|
+
required: false
|
|
418
|
+
}]
|
|
419
|
+
}],
|
|
420
|
+
placeholder: [{
|
|
421
|
+
type: i0.Input,
|
|
422
|
+
args: [{
|
|
423
|
+
isSignal: true,
|
|
424
|
+
alias: "placeholder",
|
|
425
|
+
required: false
|
|
426
|
+
}]
|
|
427
|
+
}],
|
|
428
|
+
ariaLabel: [{
|
|
429
|
+
type: i0.Input,
|
|
430
|
+
args: [{
|
|
431
|
+
isSignal: true,
|
|
432
|
+
alias: "ariaLabel",
|
|
433
|
+
required: false
|
|
434
|
+
}]
|
|
435
|
+
}],
|
|
436
|
+
loading: [{
|
|
437
|
+
type: i0.Input,
|
|
438
|
+
args: [{
|
|
439
|
+
isSignal: true,
|
|
440
|
+
alias: "loading",
|
|
441
|
+
required: false
|
|
442
|
+
}]
|
|
443
|
+
}],
|
|
444
|
+
loadingLabel: [{
|
|
445
|
+
type: i0.Input,
|
|
446
|
+
args: [{
|
|
447
|
+
isSignal: true,
|
|
448
|
+
alias: "loadingLabel",
|
|
449
|
+
required: false
|
|
450
|
+
}]
|
|
451
|
+
}],
|
|
452
|
+
emptyMessage: [{
|
|
453
|
+
type: i0.Input,
|
|
454
|
+
args: [{
|
|
455
|
+
isSignal: true,
|
|
456
|
+
alias: "emptyMessage",
|
|
457
|
+
required: false
|
|
458
|
+
}]
|
|
459
|
+
}],
|
|
460
|
+
navigateHint: [{
|
|
461
|
+
type: i0.Input,
|
|
462
|
+
args: [{
|
|
463
|
+
isSignal: true,
|
|
464
|
+
alias: "navigateHint",
|
|
465
|
+
required: false
|
|
466
|
+
}]
|
|
467
|
+
}],
|
|
468
|
+
selectHint: [{
|
|
469
|
+
type: i0.Input,
|
|
470
|
+
args: [{
|
|
471
|
+
isSignal: true,
|
|
472
|
+
alias: "selectHint",
|
|
473
|
+
required: false
|
|
474
|
+
}]
|
|
475
|
+
}],
|
|
476
|
+
closeHint: [{
|
|
477
|
+
type: i0.Input,
|
|
478
|
+
args: [{
|
|
479
|
+
isSignal: true,
|
|
480
|
+
alias: "closeHint",
|
|
481
|
+
required: false
|
|
482
|
+
}]
|
|
483
|
+
}],
|
|
484
|
+
closeLabel: [{
|
|
485
|
+
type: i0.Input,
|
|
486
|
+
args: [{
|
|
487
|
+
isSignal: true,
|
|
488
|
+
alias: "closeLabel",
|
|
489
|
+
required: false
|
|
490
|
+
}]
|
|
491
|
+
}],
|
|
492
|
+
resultsAnnouncement: [{
|
|
493
|
+
type: i0.Input,
|
|
494
|
+
args: [{
|
|
495
|
+
isSignal: true,
|
|
496
|
+
alias: "resultsAnnouncement",
|
|
497
|
+
required: false
|
|
498
|
+
}]
|
|
499
|
+
}],
|
|
500
|
+
queryChange: [{
|
|
501
|
+
type: i0.Output,
|
|
502
|
+
args: ["queryChange"]
|
|
503
|
+
}],
|
|
504
|
+
itemSelected: [{
|
|
505
|
+
type: i0.Output,
|
|
506
|
+
args: ["itemSelected"]
|
|
507
|
+
}],
|
|
508
|
+
input: [{
|
|
509
|
+
type: i0.ViewChild,
|
|
510
|
+
args: ["input", { isSignal: true }]
|
|
511
|
+
}],
|
|
512
|
+
list: [{
|
|
513
|
+
type: i0.ViewChild,
|
|
514
|
+
args: ["list", { isSignal: true }]
|
|
515
|
+
}],
|
|
516
|
+
onDocumentKeydown: [{
|
|
517
|
+
type: HostListener,
|
|
518
|
+
args: ["document:keydown", ["$event"]]
|
|
519
|
+
}]
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
var CommandPaletteTrigger = class CommandPaletteTrigger {
|
|
523
|
+
palette = input.required(...ngDevMode ? [{ debugName: "palette" }] : /* istanbul ignore next */ []);
|
|
524
|
+
label = input("Search or jump to…", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
525
|
+
shortcut = input("mod+k", ...ngDevMode ? [{ debugName: "shortcut" }] : /* istanbul ignore next */ []);
|
|
526
|
+
keys = computed(() => shortcutLabel(this.shortcut()), ...ngDevMode ? [{ debugName: "keys" }] : /* istanbul ignore next */ []);
|
|
527
|
+
keyshortcuts = computed(() => ariaKeyshortcuts(this.shortcut()), ...ngDevMode ? [{ debugName: "keyshortcuts" }] : /* istanbul ignore next */ []);
|
|
528
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
529
|
+
minVersion: "12.0.0",
|
|
530
|
+
version: "22.2.4",
|
|
531
|
+
ngImport: i0,
|
|
532
|
+
type: CommandPaletteTrigger,
|
|
533
|
+
deps: [],
|
|
534
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
535
|
+
});
|
|
536
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
537
|
+
minVersion: "17.1.0",
|
|
538
|
+
version: "22.2.4",
|
|
539
|
+
type: CommandPaletteTrigger,
|
|
540
|
+
isStandalone: true,
|
|
541
|
+
selector: "gbt-command-palette-trigger",
|
|
542
|
+
inputs: {
|
|
543
|
+
palette: {
|
|
544
|
+
classPropertyName: "palette",
|
|
545
|
+
publicName: "palette",
|
|
546
|
+
isSignal: true,
|
|
547
|
+
isRequired: true,
|
|
548
|
+
transformFunction: null
|
|
549
|
+
},
|
|
550
|
+
label: {
|
|
551
|
+
classPropertyName: "label",
|
|
552
|
+
publicName: "label",
|
|
553
|
+
isSignal: true,
|
|
554
|
+
isRequired: false,
|
|
555
|
+
transformFunction: null
|
|
556
|
+
},
|
|
557
|
+
shortcut: {
|
|
558
|
+
classPropertyName: "shortcut",
|
|
559
|
+
publicName: "shortcut",
|
|
560
|
+
isSignal: true,
|
|
561
|
+
isRequired: false,
|
|
562
|
+
transformFunction: null
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
ngImport: i0,
|
|
566
|
+
template: `
|
|
567
|
+
<button
|
|
568
|
+
type="button"
|
|
569
|
+
class="gbt-cp-trigger"
|
|
570
|
+
aria-haspopup="dialog"
|
|
571
|
+
[attr.aria-label]="label()"
|
|
572
|
+
[attr.aria-keyshortcuts]="keyshortcuts()"
|
|
573
|
+
(click)="palette().show()"
|
|
574
|
+
>
|
|
575
|
+
<gbt-icon name="search" class="gbt-cp-trigger__icon" aria-hidden="true" />
|
|
576
|
+
<span class="gbt-cp-trigger__label" aria-hidden="true">{{ label() }}</span>
|
|
577
|
+
<kbd class="gbt-cp-trigger__kbd" aria-hidden="true">{{ keys() }}</kbd>
|
|
578
|
+
</button>
|
|
579
|
+
`,
|
|
580
|
+
isInline: true,
|
|
581
|
+
styles: [":host{display:block;min-width:0}.gbt-cp-trigger{box-sizing:border-box;display:flex;align-items:center;gap:8px;width:100%;height:40px;padding:0 8px 0 12px;border:1px solid var(--border-color);border-radius:var(--gbt-radius-search, var(--site-border-radius-sm));background:var(--bg-principal);box-shadow:var(--gbt-depth-hollow);color:var(--text-secondary);font:inherit;font-size:14px;text-align:left;cursor:pointer;transition:border-color .15s cubic-bezier(.4,0,.2,1)}.gbt-cp-trigger:hover{border-color:var(--text-secondary);background-image:linear-gradient(var(--bg-hover),var(--bg-hover))}.gbt-cp-trigger:active{background-image:linear-gradient(var(--bg-press),var(--bg-press))}.gbt-cp-trigger:focus-visible{outline:2px solid var(--gbt-focus-ring, var(--focus-ring));outline-offset:2px}.gbt-cp-trigger__icon{flex:none}.gbt-cp-trigger__label{flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.gbt-cp-trigger__kbd{flex:none;padding:2px 6px;border:1px solid var(--border-color);border-radius:var(--gbt-radius-chip, var(--site-border-radius-xs));font-family:inherit;font-size:11px;font-weight:600;line-height:1.4}@media(max-width:599px){.gbt-cp-trigger{justify-content:center;width:44px;height:44px;padding:0;border-color:transparent;background:none;color:inherit}.gbt-cp-trigger__label,.gbt-cp-trigger__kbd{display:none}}@media(prefers-reduced-motion:reduce){.gbt-cp-trigger{transition:none}}\n"],
|
|
582
|
+
dependencies: [{
|
|
583
|
+
kind: "component",
|
|
584
|
+
type: Icon,
|
|
585
|
+
selector: "gbt-icon",
|
|
586
|
+
inputs: ["name"]
|
|
587
|
+
}],
|
|
588
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
592
|
+
minVersion: "12.0.0",
|
|
593
|
+
version: "22.2.4",
|
|
594
|
+
ngImport: i0,
|
|
595
|
+
type: CommandPaletteTrigger,
|
|
596
|
+
decorators: [{
|
|
597
|
+
type: Component,
|
|
598
|
+
args: [{
|
|
599
|
+
selector: "gbt-command-palette-trigger",
|
|
600
|
+
standalone: true,
|
|
601
|
+
imports: [Icon],
|
|
602
|
+
template: `
|
|
603
|
+
<button
|
|
604
|
+
type="button"
|
|
605
|
+
class="gbt-cp-trigger"
|
|
606
|
+
aria-haspopup="dialog"
|
|
607
|
+
[attr.aria-label]="label()"
|
|
608
|
+
[attr.aria-keyshortcuts]="keyshortcuts()"
|
|
609
|
+
(click)="palette().show()"
|
|
610
|
+
>
|
|
611
|
+
<gbt-icon name="search" class="gbt-cp-trigger__icon" aria-hidden="true" />
|
|
612
|
+
<span class="gbt-cp-trigger__label" aria-hidden="true">{{ label() }}</span>
|
|
613
|
+
<kbd class="gbt-cp-trigger__kbd" aria-hidden="true">{{ keys() }}</kbd>
|
|
614
|
+
</button>
|
|
615
|
+
`,
|
|
616
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
617
|
+
styles: [":host{display:block;min-width:0}.gbt-cp-trigger{box-sizing:border-box;display:flex;align-items:center;gap:8px;width:100%;height:40px;padding:0 8px 0 12px;border:1px solid var(--border-color);border-radius:var(--gbt-radius-search, var(--site-border-radius-sm));background:var(--bg-principal);box-shadow:var(--gbt-depth-hollow);color:var(--text-secondary);font:inherit;font-size:14px;text-align:left;cursor:pointer;transition:border-color .15s cubic-bezier(.4,0,.2,1)}.gbt-cp-trigger:hover{border-color:var(--text-secondary);background-image:linear-gradient(var(--bg-hover),var(--bg-hover))}.gbt-cp-trigger:active{background-image:linear-gradient(var(--bg-press),var(--bg-press))}.gbt-cp-trigger:focus-visible{outline:2px solid var(--gbt-focus-ring, var(--focus-ring));outline-offset:2px}.gbt-cp-trigger__icon{flex:none}.gbt-cp-trigger__label{flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.gbt-cp-trigger__kbd{flex:none;padding:2px 6px;border:1px solid var(--border-color);border-radius:var(--gbt-radius-chip, var(--site-border-radius-xs));font-family:inherit;font-size:11px;font-weight:600;line-height:1.4}@media(max-width:599px){.gbt-cp-trigger{justify-content:center;width:44px;height:44px;padding:0;border-color:transparent;background:none;color:inherit}.gbt-cp-trigger__label,.gbt-cp-trigger__kbd{display:none}}@media(prefers-reduced-motion:reduce){.gbt-cp-trigger{transition:none}}\n"]
|
|
618
|
+
}]
|
|
619
|
+
}],
|
|
620
|
+
propDecorators: {
|
|
621
|
+
palette: [{
|
|
622
|
+
type: i0.Input,
|
|
623
|
+
args: [{
|
|
624
|
+
isSignal: true,
|
|
625
|
+
alias: "palette",
|
|
626
|
+
required: true
|
|
627
|
+
}]
|
|
628
|
+
}],
|
|
629
|
+
label: [{
|
|
630
|
+
type: i0.Input,
|
|
631
|
+
args: [{
|
|
632
|
+
isSignal: true,
|
|
633
|
+
alias: "label",
|
|
634
|
+
required: false
|
|
635
|
+
}]
|
|
636
|
+
}],
|
|
637
|
+
shortcut: [{
|
|
638
|
+
type: i0.Input,
|
|
639
|
+
args: [{
|
|
640
|
+
isSignal: true,
|
|
641
|
+
alias: "shortcut",
|
|
642
|
+
required: false
|
|
643
|
+
}]
|
|
644
|
+
}]
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
export { CommandPalette, CommandPaletteTrigger, ariaKeyshortcuts, isApplePlatform, matchCommand, matchesShortcut, normalize, parseShortcut, shortcutLabel };
|
|
648
|
+
|
|
649
|
+
//# sourceMappingURL=masmarino-gabarit-command-palette.mjs.map
|