@syware/jlib 0.0.0-stage → 0.1.3
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/LICENSE +21 -0
- package/README.md +133 -2
- package/dist/all.d.ts +1 -0
- package/dist/all.js +75 -0
- package/dist/atoms/jl-avatar.css_raw.js +3 -0
- package/dist/atoms/jl-avatar.d.ts +52 -0
- package/dist/atoms/jl-avatar.js +167 -0
- package/dist/atoms/jl-badge.css_raw.js +3 -0
- package/dist/atoms/jl-badge.d.ts +32 -0
- package/dist/atoms/jl-badge.js +60 -0
- package/dist/atoms/jl-button.css_raw.js +3 -0
- package/dist/atoms/jl-button.d.ts +70 -0
- package/dist/atoms/jl-button.js +146 -0
- package/dist/atoms/jl-checkbox.css_raw.js +3 -0
- package/dist/atoms/jl-checkbox.d.ts +61 -0
- package/dist/atoms/jl-checkbox.js +149 -0
- package/dist/atoms/jl-chip.css_raw.js +3 -0
- package/dist/atoms/jl-chip.d.ts +59 -0
- package/dist/atoms/jl-chip.js +164 -0
- package/dist/atoms/jl-divider.css_raw.js +3 -0
- package/dist/atoms/jl-divider.d.ts +26 -0
- package/dist/atoms/jl-divider.js +59 -0
- package/dist/atoms/jl-icon.css_raw.js +3 -0
- package/dist/atoms/jl-icon.d.ts +25 -0
- package/dist/atoms/jl-icon.js +41 -0
- package/dist/atoms/jl-input.css_raw.js +3 -0
- package/dist/atoms/jl-input.d.ts +112 -0
- package/dist/atoms/jl-input.js +202 -0
- package/dist/atoms/jl-kbd.css_raw.js +3 -0
- package/dist/atoms/jl-kbd.d.ts +17 -0
- package/dist/atoms/jl-kbd.js +62 -0
- package/dist/atoms/jl-link.css_raw.js +3 -0
- package/dist/atoms/jl-link.d.ts +37 -0
- package/dist/atoms/jl-link.js +86 -0
- package/dist/atoms/jl-progress-ring.css_raw.js +3 -0
- package/dist/atoms/jl-progress-ring.d.ts +49 -0
- package/dist/atoms/jl-progress-ring.js +132 -0
- package/dist/atoms/jl-progress.css_raw.js +3 -0
- package/dist/atoms/jl-progress.d.ts +43 -0
- package/dist/atoms/jl-progress.js +109 -0
- package/dist/atoms/jl-rating.css_raw.js +3 -0
- package/dist/atoms/jl-rating.d.ts +73 -0
- package/dist/atoms/jl-rating.js +184 -0
- package/dist/atoms/jl-select.css_raw.js +3 -0
- package/dist/atoms/jl-select.d.ts +70 -0
- package/dist/atoms/jl-select.js +146 -0
- package/dist/atoms/jl-skeleton.css_raw.js +3 -0
- package/dist/atoms/jl-skeleton.d.ts +34 -0
- package/dist/atoms/jl-skeleton.js +63 -0
- package/dist/atoms/jl-slider.css_raw.js +3 -0
- package/dist/atoms/jl-slider.d.ts +65 -0
- package/dist/atoms/jl-slider.js +143 -0
- package/dist/atoms/jl-spinner.css_raw.js +3 -0
- package/dist/atoms/jl-spinner.d.ts +16 -0
- package/dist/atoms/jl-spinner.js +26 -0
- package/dist/atoms/jl-switch.css_raw.js +3 -0
- package/dist/atoms/jl-switch.d.ts +57 -0
- package/dist/atoms/jl-switch.js +125 -0
- package/dist/atoms/jl-textarea.css_raw.js +3 -0
- package/dist/atoms/jl-textarea.d.ts +81 -0
- package/dist/atoms/jl-textarea.js +148 -0
- package/dist/base/jl-element.d.ts +16 -0
- package/dist/base/jl-element.js +35 -0
- package/dist/base/jl-form-control.d.ts +29 -0
- package/dist/base/jl-form-control.js +44 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.js +72 -0
- package/dist/lib/arrow.d.ts +6 -0
- package/dist/lib/arrow.js +15 -0
- package/dist/lib/attributes.d.ts +9 -0
- package/dist/lib/attributes.js +22 -0
- package/dist/lib/avatar.d.ts +11 -0
- package/dist/lib/avatar.js +37 -0
- package/dist/lib/calendar.d.ts +48 -0
- package/dist/lib/calendar.js +166 -0
- package/dist/lib/css-length.d.ts +2 -0
- package/dist/lib/css-length.js +8 -0
- package/dist/lib/define.d.ts +9 -0
- package/dist/lib/define.js +9 -0
- package/dist/lib/dom.d.ts +4 -0
- package/dist/lib/dom.js +16 -0
- package/dist/lib/files.d.ts +18 -0
- package/dist/lib/files.js +89 -0
- package/dist/lib/floating.d.ts +13 -0
- package/dist/lib/floating.js +127 -0
- package/dist/lib/fuzzy.d.ts +26 -0
- package/dist/lib/fuzzy.js +149 -0
- package/dist/lib/highlight.d.ts +5 -0
- package/dist/lib/highlight.js +267 -0
- package/dist/lib/hotkey.d.ts +9 -0
- package/dist/lib/hotkey.js +101 -0
- package/dist/lib/icon-set.d.ts +95 -0
- package/dist/lib/icon-set.js +97 -0
- package/dist/lib/icons.d.ts +12 -0
- package/dist/lib/icons.js +39 -0
- package/dist/lib/indicator.d.ts +6 -0
- package/dist/lib/indicator.js +18 -0
- package/dist/lib/keep-in-view.d.ts +5 -0
- package/dist/lib/keep-in-view.js +15 -0
- package/dist/lib/key-shortcut.d.ts +20 -0
- package/dist/lib/key-shortcut.js +100 -0
- package/dist/lib/keycaps.d.ts +8 -0
- package/dist/lib/keycaps.js +162 -0
- package/dist/lib/locale.d.ts +4 -0
- package/dist/lib/locale.js +13 -0
- package/dist/lib/nav-tree.d.ts +9 -0
- package/dist/lib/nav-tree.js +30 -0
- package/dist/lib/numeric.d.ts +20 -0
- package/dist/lib/numeric.js +50 -0
- package/dist/lib/option-filter.d.ts +29 -0
- package/dist/lib/option-filter.js +108 -0
- package/dist/lib/option-groups.d.ts +6 -0
- package/dist/lib/option-groups.js +26 -0
- package/dist/lib/options.d.ts +5 -0
- package/dist/lib/options.js +24 -0
- package/dist/lib/pagination.d.ts +9 -0
- package/dist/lib/pagination.js +52 -0
- package/dist/lib/palette.d.ts +8 -0
- package/dist/lib/palette.js +46 -0
- package/dist/lib/progress.d.ts +20 -0
- package/dist/lib/progress.js +33 -0
- package/dist/lib/rating.d.ts +7 -0
- package/dist/lib/rating.js +26 -0
- package/dist/lib/roving-index.d.ts +10 -0
- package/dist/lib/roving-index.js +32 -0
- package/dist/lib/roving.d.ts +11 -0
- package/dist/lib/roving.js +21 -0
- package/dist/lib/slots.d.ts +2 -0
- package/dist/lib/slots.js +6 -0
- package/dist/lib/sparkline.d.ts +11 -0
- package/dist/lib/sparkline.js +42 -0
- package/dist/lib/split.d.ts +12 -0
- package/dist/lib/split.js +37 -0
- package/dist/lib/surface.d.ts +7 -0
- package/dist/lib/surface.js +28 -0
- package/dist/lib/table.d.ts +30 -0
- package/dist/lib/table.js +110 -0
- package/dist/lib/tags.d.ts +14 -0
- package/dist/lib/tags.js +29 -0
- package/dist/lib/text.d.ts +5 -0
- package/dist/lib/text.js +13 -0
- package/dist/lib/tokens.d.ts +5 -0
- package/dist/lib/tokens.js +15 -0
- package/dist/lib/tree.d.ts +16 -0
- package/dist/lib/tree.js +89 -0
- package/dist/lib/trend.d.ts +3 -0
- package/dist/lib/trend.js +15 -0
- package/dist/lib/trigger.d.ts +11 -0
- package/dist/lib/trigger.js +34 -0
- package/dist/molecules/jl-accordion-item.css_raw.js +3 -0
- package/dist/molecules/jl-accordion-item.d.ts +34 -0
- package/dist/molecules/jl-accordion-item.js +82 -0
- package/dist/molecules/jl-accordion.css_raw.js +3 -0
- package/dist/molecules/jl-accordion.d.ts +27 -0
- package/dist/molecules/jl-accordion.js +61 -0
- package/dist/molecules/jl-alert.css_raw.js +3 -0
- package/dist/molecules/jl-alert.d.ts +38 -0
- package/dist/molecules/jl-alert.js +131 -0
- package/dist/molecules/jl-avatar-group.css_raw.js +3 -0
- package/dist/molecules/jl-avatar-group.d.ts +28 -0
- package/dist/molecules/jl-avatar-group.js +69 -0
- package/dist/molecules/jl-breadcrumb.css_raw.js +3 -0
- package/dist/molecules/jl-breadcrumb.d.ts +35 -0
- package/dist/molecules/jl-breadcrumb.js +126 -0
- package/dist/molecules/jl-calendar.css_raw.js +3 -0
- package/dist/molecules/jl-calendar.d.ts +101 -0
- package/dist/molecules/jl-calendar.js +314 -0
- package/dist/molecules/jl-card.css_raw.js +3 -0
- package/dist/molecules/jl-card.d.ts +46 -0
- package/dist/molecules/jl-card.js +172 -0
- package/dist/molecules/jl-code-block.css_raw.js +3 -0
- package/dist/molecules/jl-code-block.d.ts +44 -0
- package/dist/molecules/jl-code-block.js +106 -0
- package/dist/molecules/jl-combobox.css_raw.js +3 -0
- package/dist/molecules/jl-combobox.d.ts +120 -0
- package/dist/molecules/jl-combobox.js +450 -0
- package/dist/molecules/jl-copy-button.css_raw.js +3 -0
- package/dist/molecules/jl-copy-button.d.ts +31 -0
- package/dist/molecules/jl-copy-button.js +69 -0
- package/dist/molecules/jl-date-picker.css_raw.js +3 -0
- package/dist/molecules/jl-date-picker.d.ts +109 -0
- package/dist/molecules/jl-date-picker.js +322 -0
- package/dist/molecules/jl-empty.css_raw.js +3 -0
- package/dist/molecules/jl-empty.d.ts +32 -0
- package/dist/molecules/jl-empty.js +94 -0
- package/dist/molecules/jl-field.css_raw.js +3 -0
- package/dist/molecules/jl-field.d.ts +49 -0
- package/dist/molecules/jl-field.js +147 -0
- package/dist/molecules/jl-file-drop.css_raw.js +3 -0
- package/dist/molecules/jl-file-drop.d.ts +93 -0
- package/dist/molecules/jl-file-drop.js +366 -0
- package/dist/molecules/jl-list-item.css_raw.js +3 -0
- package/dist/molecules/jl-list-item.d.ts +56 -0
- package/dist/molecules/jl-list-item.js +176 -0
- package/dist/molecules/jl-menu.css_raw.js +3 -0
- package/dist/molecules/jl-menu.d.ts +62 -0
- package/dist/molecules/jl-menu.js +288 -0
- package/dist/molecules/jl-number-input.css_raw.js +3 -0
- package/dist/molecules/jl-number-input.d.ts +81 -0
- package/dist/molecules/jl-number-input.js +220 -0
- package/dist/molecules/jl-pagination.css_raw.js +3 -0
- package/dist/molecules/jl-pagination.d.ts +59 -0
- package/dist/molecules/jl-pagination.js +172 -0
- package/dist/molecules/jl-popover.css_raw.js +3 -0
- package/dist/molecules/jl-popover.d.ts +49 -0
- package/dist/molecules/jl-popover.js +152 -0
- package/dist/molecules/jl-radio-group.css_raw.js +3 -0
- package/dist/molecules/jl-radio-group.d.ts +71 -0
- package/dist/molecules/jl-radio-group.js +202 -0
- package/dist/molecules/jl-search.css_raw.js +3 -0
- package/dist/molecules/jl-search.d.ts +71 -0
- package/dist/molecules/jl-search.js +210 -0
- package/dist/molecules/jl-segmented.css_raw.js +3 -0
- package/dist/molecules/jl-segmented.d.ts +65 -0
- package/dist/molecules/jl-segmented.js +187 -0
- package/dist/molecules/jl-stat.css_raw.js +3 -0
- package/dist/molecules/jl-stat.d.ts +55 -0
- package/dist/molecules/jl-stat.js +169 -0
- package/dist/molecules/jl-steps.css_raw.js +3 -0
- package/dist/molecules/jl-steps.d.ts +44 -0
- package/dist/molecules/jl-steps.js +118 -0
- package/dist/molecules/jl-tab-panel.css_raw.js +3 -0
- package/dist/molecules/jl-tab-panel.d.ts +35 -0
- package/dist/molecules/jl-tab-panel.js +35 -0
- package/dist/molecules/jl-tabs.css_raw.js +3 -0
- package/dist/molecules/jl-tabs.d.ts +51 -0
- package/dist/molecules/jl-tabs.js +198 -0
- package/dist/molecules/jl-tag-input.css_raw.js +3 -0
- package/dist/molecules/jl-tag-input.d.ts +103 -0
- package/dist/molecules/jl-tag-input.js +429 -0
- package/dist/molecules/jl-timeline.css_raw.js +3 -0
- package/dist/molecules/jl-timeline.d.ts +28 -0
- package/dist/molecules/jl-timeline.js +81 -0
- package/dist/molecules/jl-toast.css_raw.js +3 -0
- package/dist/molecules/jl-toast.d.ts +75 -0
- package/dist/molecules/jl-toast.js +274 -0
- package/dist/molecules/jl-tooltip.css_raw.js +3 -0
- package/dist/molecules/jl-tooltip.d.ts +44 -0
- package/dist/molecules/jl-tooltip.js +160 -0
- package/dist/organisms/jl-command-palette.css_raw.js +3 -0
- package/dist/organisms/jl-command-palette.d.ts +60 -0
- package/dist/organisms/jl-command-palette.js +285 -0
- package/dist/organisms/jl-confirm.css_raw.js +3 -0
- package/dist/organisms/jl-confirm.d.ts +56 -0
- package/dist/organisms/jl-confirm.js +132 -0
- package/dist/organisms/jl-dialog.css_raw.js +3 -0
- package/dist/organisms/jl-dialog.d.ts +43 -0
- package/dist/organisms/jl-dialog.js +120 -0
- package/dist/organisms/jl-drawer.css_raw.js +3 -0
- package/dist/organisms/jl-drawer.d.ts +50 -0
- package/dist/organisms/jl-drawer.js +141 -0
- package/dist/organisms/jl-navbar.css_raw.js +3 -0
- package/dist/organisms/jl-navbar.d.ts +32 -0
- package/dist/organisms/jl-navbar.js +121 -0
- package/dist/organisms/jl-page-header.css_raw.js +3 -0
- package/dist/organisms/jl-page-header.d.ts +26 -0
- package/dist/organisms/jl-page-header.js +85 -0
- package/dist/organisms/jl-side-nav.css_raw.js +3 -0
- package/dist/organisms/jl-side-nav.d.ts +60 -0
- package/dist/organisms/jl-side-nav.js +269 -0
- package/dist/organisms/jl-table.css_raw.js +3 -0
- package/dist/organisms/jl-table.d.ts +109 -0
- package/dist/organisms/jl-table.js +318 -0
- package/dist/organisms/jl-toaster.css_raw.js +3 -0
- package/dist/organisms/jl-toaster.d.ts +48 -0
- package/dist/organisms/jl-toaster.js +142 -0
- package/dist/organisms/jl-tree.css_raw.js +3 -0
- package/dist/organisms/jl-tree.d.ts +59 -0
- package/dist/organisms/jl-tree.js +198 -0
- package/dist/styles/base.css_raw.js +3 -0
- package/dist/styles/control.css_raw.js +3 -0
- package/dist/styles/floating.css_raw.js +3 -0
- package/dist/styles/shared.d.ts +8 -0
- package/dist/styles/shared.js +14 -0
- package/dist/styles/tokens.css_raw.js +3 -0
- package/dist/templates/jl-app-shell.css_raw.js +3 -0
- package/dist/templates/jl-app-shell.d.ts +37 -0
- package/dist/templates/jl-app-shell.js +150 -0
- package/dist/templates/jl-split-view.css_raw.js +3 -0
- package/dist/templates/jl-split-view.d.ts +49 -0
- package/dist/templates/jl-split-view.js +149 -0
- package/dist/tokens.css +188 -0
- package/dist/types/calendar.types.d.ts +11 -0
- package/dist/types/files.types.d.ts +23 -0
- package/dist/types/floating.types.d.ts +13 -0
- package/dist/types/fuzzy.types.d.ts +10 -0
- package/dist/types/highlight.types.d.ts +6 -0
- package/dist/types/hotkey.types.d.ts +19 -0
- package/dist/types/jl-accordion.types.d.ts +2 -0
- package/dist/types/jl-avatar.types.d.ts +10 -0
- package/dist/types/jl-breadcrumb.types.d.ts +6 -0
- package/dist/types/jl-button.types.d.ts +3 -0
- package/dist/types/jl-card.types.d.ts +2 -0
- package/dist/types/jl-chip.types.d.ts +1 -0
- package/dist/types/jl-combobox.types.d.ts +8 -0
- package/dist/types/jl-command-palette.types.d.ts +22 -0
- package/dist/types/jl-confirm.types.d.ts +10 -0
- package/dist/types/jl-dialog.types.d.ts +1 -0
- package/dist/types/jl-divider.types.d.ts +2 -0
- package/dist/types/jl-drawer.types.d.ts +4 -0
- package/dist/types/jl-empty.types.d.ts +2 -0
- package/dist/types/jl-field.types.d.ts +2 -0
- package/dist/types/jl-input.types.d.ts +1 -0
- package/dist/types/jl-link.types.d.ts +2 -0
- package/dist/types/jl-menu.types.d.ts +22 -0
- package/dist/types/jl-navbar.types.d.ts +6 -0
- package/dist/types/jl-progress.types.d.ts +3 -0
- package/dist/types/jl-radio-group.types.d.ts +10 -0
- package/dist/types/jl-segmented.types.d.ts +7 -0
- package/dist/types/jl-select.types.d.ts +12 -0
- package/dist/types/jl-side-nav.types.d.ts +17 -0
- package/dist/types/jl-skeleton.types.d.ts +2 -0
- package/dist/types/jl-slider.types.d.ts +5 -0
- package/dist/types/jl-split-view.types.d.ts +2 -0
- package/dist/types/jl-stat.types.d.ts +2 -0
- package/dist/types/jl-steps.types.d.ts +8 -0
- package/dist/types/jl-switch.types.d.ts +1 -0
- package/dist/types/jl-table.types.d.ts +30 -0
- package/dist/types/jl-tabs.types.d.ts +2 -0
- package/dist/types/jl-timeline.types.d.ts +10 -0
- package/dist/types/jl-toast.types.d.ts +2 -0
- package/dist/types/jl-toaster.types.d.ts +23 -0
- package/dist/types/jl-tree.types.d.ts +26 -0
- package/dist/types/key-shortcut.types.d.ts +9 -0
- package/dist/types/keycaps.types.d.ts +7 -0
- package/dist/types/option-filter.types.d.ts +10 -0
- package/dist/types/options.types.d.ts +4 -0
- package/dist/types/pagination.types.d.ts +8 -0
- package/dist/types/roving-index.types.d.ts +2 -0
- package/dist/types/sparkline.types.d.ts +11 -0
- package/package.json +102 -4
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { BASE_STYLES } from "../styles/shared.js";
|
|
2
|
+
import { JlElement } from "../base/jl-element.js";
|
|
3
|
+
import { oneOf } from "../lib/attributes.js";
|
|
4
|
+
import { registerIcons } from "../lib/icons.js";
|
|
5
|
+
import { TONE_ICONS } from "../lib/options.js";
|
|
6
|
+
import { JlIcon } from "../atoms/jl-icon.js";
|
|
7
|
+
import { JlButton } from "../atoms/jl-button.js";
|
|
8
|
+
import jl_toast_default from "./jl-toast.css_raw.js";
|
|
9
|
+
import { css } from "@jadis/core";
|
|
10
|
+
import { CircleCheck, CircleX, Info, Sparkles, TriangleAlert, X } from "lucide";
|
|
11
|
+
import { jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
12
|
+
// src/molecules/jl-toast.tsx
|
|
13
|
+
registerIcons({
|
|
14
|
+
"circle-check": CircleCheck,
|
|
15
|
+
"circle-x": CircleX,
|
|
16
|
+
info: Info,
|
|
17
|
+
sparkles: Sparkles,
|
|
18
|
+
"triangle-alert": TriangleAlert,
|
|
19
|
+
x: X
|
|
20
|
+
});
|
|
21
|
+
var TOAST_TONES = [
|
|
22
|
+
"neutral",
|
|
23
|
+
"ok",
|
|
24
|
+
"warn",
|
|
25
|
+
"danger",
|
|
26
|
+
"info"
|
|
27
|
+
];
|
|
28
|
+
var ICON_SIZE = 18;
|
|
29
|
+
var ENTER_MS = 240;
|
|
30
|
+
var LEAVE_MS = 180;
|
|
31
|
+
var ENTER_OFFSET = "--jl-toast-enter";
|
|
32
|
+
var DEFAULT_OFFSET = "8px";
|
|
33
|
+
var EASE = "cubic-bezier(0.2, 0.7, 0.2, 1)";
|
|
34
|
+
var REDUCED_MOTION = "(prefers-reduced-motion: reduce)";
|
|
35
|
+
var TOASTER = "jl-toaster";
|
|
36
|
+
/** Alone on a page, a toast announces itself: danger interrupts, the others wait their turn. */
|
|
37
|
+
var STANDALONE_ROLES = {
|
|
38
|
+
danger: "alert",
|
|
39
|
+
info: "status",
|
|
40
|
+
neutral: "status",
|
|
41
|
+
ok: "status",
|
|
42
|
+
warn: "status"
|
|
43
|
+
};
|
|
44
|
+
var prefersReducedMotion = () => window.matchMedia(REDUCED_MOTION).matches;
|
|
45
|
+
/**
|
|
46
|
+
* One notification: a heading, a line of text, an icon in its tone's colour, and maybe an action such as "Undo".
|
|
47
|
+
* With a `duration` it closes by itself, a thin line showing the time left; hovering or focusing it pauses the
|
|
48
|
+
* line. It emits `dismiss` once it has closed. Most pages call `toast()` rather than writing it.
|
|
49
|
+
*/
|
|
50
|
+
var JlToast = class extends JlElement {
|
|
51
|
+
static selector = "jl-toast";
|
|
52
|
+
events = this.useEvents();
|
|
53
|
+
tone = this.useChange("neutral", (value) => {
|
|
54
|
+
this.reflect("tone", value);
|
|
55
|
+
this.renderIcon();
|
|
56
|
+
this.renderRole();
|
|
57
|
+
}, {
|
|
58
|
+
attribute: "tone",
|
|
59
|
+
parse: oneOf(TOAST_TONES, "neutral")
|
|
60
|
+
});
|
|
61
|
+
heading = this.useChange("", (value) => {
|
|
62
|
+
this._refs.heading.textContent = value;
|
|
63
|
+
this._refs.heading.hidden = value === "";
|
|
64
|
+
}, { attribute: "heading" });
|
|
65
|
+
text = this.useChange("", (value) => {
|
|
66
|
+
this._refs.text.textContent = value;
|
|
67
|
+
this._refs.text.hidden = value === "";
|
|
68
|
+
}, { attribute: "text" });
|
|
69
|
+
/** An icon name; the tone's icon when empty. */
|
|
70
|
+
icon = this.useChange("", () => this.renderIcon(), { attribute: "icon" });
|
|
71
|
+
/** Shows a close button. */
|
|
72
|
+
closable = this.useChange(false, (value) => {
|
|
73
|
+
this._refs.close.hidden = !value;
|
|
74
|
+
}, { attribute: "closable" });
|
|
75
|
+
/** The text of a quiet button that emits `action`, then closes the toast. */
|
|
76
|
+
actionLabel = this.useChange("", (value) => {
|
|
77
|
+
this._refs.action.label.set(value);
|
|
78
|
+
this._refs.action.hidden = value === "";
|
|
79
|
+
}, { attribute: "action-label" });
|
|
80
|
+
/** How long it stays, in milliseconds; 0 keeps it until it is closed. */
|
|
81
|
+
duration = this.useChange(0, () => this.startTimer(), { attribute: "duration" });
|
|
82
|
+
_timer = {
|
|
83
|
+
animation: null,
|
|
84
|
+
entered: false
|
|
85
|
+
};
|
|
86
|
+
_hold = {
|
|
87
|
+
focus: false,
|
|
88
|
+
pointer: false
|
|
89
|
+
};
|
|
90
|
+
_refs = this.useRefs((ref) => ({
|
|
91
|
+
action: ref(".action"),
|
|
92
|
+
bar: ref(".bar"),
|
|
93
|
+
close: ref(".close"),
|
|
94
|
+
heading: ref(".heading"),
|
|
95
|
+
icon: ref(".icon"),
|
|
96
|
+
progress: ref(".progress"),
|
|
97
|
+
text: ref(".text"),
|
|
98
|
+
toast: ref(".toast")
|
|
99
|
+
}));
|
|
100
|
+
/** Closes the toast: it leaves, hides, then emits `dismiss`. */
|
|
101
|
+
dismiss() {
|
|
102
|
+
if (this.hidden || this.hasAttribute("leaving")) return;
|
|
103
|
+
this.stopTimer();
|
|
104
|
+
this.reflect("leaving", true);
|
|
105
|
+
const done = () => this.finishLeaving();
|
|
106
|
+
if (!this.isConnected || prefersReducedMotion()) {
|
|
107
|
+
done();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const offset = this.enterOffset();
|
|
111
|
+
this._refs.toast.animate([{ opacity: 1 }, {
|
|
112
|
+
opacity: 0,
|
|
113
|
+
transform: `translateY(${offset}) scale(0.97)`
|
|
114
|
+
}], {
|
|
115
|
+
duration: LEAVE_MS,
|
|
116
|
+
easing: EASE,
|
|
117
|
+
fill: "forwards"
|
|
118
|
+
}).finished.then(done, done);
|
|
119
|
+
}
|
|
120
|
+
/** Shows a dismissed toast again, with its time from the start. */
|
|
121
|
+
show() {
|
|
122
|
+
this.hidden = false;
|
|
123
|
+
this._timer.entered = false;
|
|
124
|
+
this.whenRendered(() => {
|
|
125
|
+
this.enter();
|
|
126
|
+
this.startTimer();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
templateHtml() {
|
|
130
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
131
|
+
class: "toast",
|
|
132
|
+
attrs: { part: "base" },
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ jsx(JlIcon, {
|
|
135
|
+
class: "icon",
|
|
136
|
+
size: ICON_SIZE
|
|
137
|
+
}),
|
|
138
|
+
/* @__PURE__ */ jsxs("div", {
|
|
139
|
+
class: "content",
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsx("p", {
|
|
142
|
+
class: "heading",
|
|
143
|
+
hidden: true
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsx("p", {
|
|
146
|
+
class: "text",
|
|
147
|
+
hidden: true
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ jsx("slot", {})
|
|
150
|
+
]
|
|
151
|
+
}),
|
|
152
|
+
/* @__PURE__ */ jsxs("div", {
|
|
153
|
+
class: "buttons",
|
|
154
|
+
children: [/* @__PURE__ */ jsx(JlButton, {
|
|
155
|
+
class: "action",
|
|
156
|
+
variant: "ghost",
|
|
157
|
+
size: "sm",
|
|
158
|
+
hidden: true
|
|
159
|
+
}), /* @__PURE__ */ jsx(JlButton, {
|
|
160
|
+
class: "close",
|
|
161
|
+
variant: "ghost",
|
|
162
|
+
size: "sm",
|
|
163
|
+
icon: "x",
|
|
164
|
+
hint: "Close",
|
|
165
|
+
hidden: true
|
|
166
|
+
})]
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ jsx("div", {
|
|
169
|
+
class: "progress",
|
|
170
|
+
"aria-hidden": "true",
|
|
171
|
+
hidden: true,
|
|
172
|
+
children: /* @__PURE__ */ jsx("div", { class: "bar" })
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
templateCss() {
|
|
178
|
+
return css`${BASE_STYLES}${jl_toast_default}`;
|
|
179
|
+
}
|
|
180
|
+
onConnect() {
|
|
181
|
+
this._refs.close.events.register("press", () => this.dismiss());
|
|
182
|
+
this._refs.action.events.register("press", () => {
|
|
183
|
+
this.events.emit("action");
|
|
184
|
+
this.dismiss();
|
|
185
|
+
});
|
|
186
|
+
this.on(this, "pointerenter", () => this.hold("pointer", true));
|
|
187
|
+
this.on(this, "pointerleave", () => this.hold("pointer", false));
|
|
188
|
+
this.on(this, "focusin", () => this.hold("focus", true));
|
|
189
|
+
this.on(this, "focusout", (event) => this.hold("focus", this.holdsFocus(event.relatedTarget)));
|
|
190
|
+
this.renderRole();
|
|
191
|
+
this.enter();
|
|
192
|
+
this.resumeTimer();
|
|
193
|
+
}
|
|
194
|
+
onDisconnect() {
|
|
195
|
+
this._timer.animation?.pause();
|
|
196
|
+
}
|
|
197
|
+
/** The way in, once per showing; WAAPI so that the toaster moving in the top layer does not replay it. */
|
|
198
|
+
enter() {
|
|
199
|
+
if (this._timer.entered || this.hidden) return;
|
|
200
|
+
this._timer.entered = true;
|
|
201
|
+
if (prefersReducedMotion()) return;
|
|
202
|
+
const offset = this.enterOffset();
|
|
203
|
+
this._refs.toast.animate([{
|
|
204
|
+
opacity: 0,
|
|
205
|
+
transform: `translateY(${offset}) scale(0.98)`
|
|
206
|
+
}, { opacity: 1 }], {
|
|
207
|
+
duration: ENTER_MS,
|
|
208
|
+
easing: EASE
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
enterOffset() {
|
|
212
|
+
return getComputedStyle(this).getPropertyValue(ENTER_OFFSET).trim() || DEFAULT_OFFSET;
|
|
213
|
+
}
|
|
214
|
+
finishLeaving() {
|
|
215
|
+
this.reflect("leaving", false);
|
|
216
|
+
this.hidden = true;
|
|
217
|
+
this.events.emit("dismiss");
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The time left is the progress line's own animation: pausing it pauses the countdown, and it is not cut short by
|
|
221
|
+
* reduced motion the way CSS animations are.
|
|
222
|
+
*/
|
|
223
|
+
startTimer() {
|
|
224
|
+
this.stopTimer();
|
|
225
|
+
const duration = this.duration.get();
|
|
226
|
+
this._refs.progress.hidden = duration <= 0;
|
|
227
|
+
if (duration <= 0 || !this.isConnected || this.hidden) return;
|
|
228
|
+
const animation = this._refs.bar.animate([{ transform: "scaleX(1)" }, { transform: "scaleX(0)" }], {
|
|
229
|
+
duration,
|
|
230
|
+
easing: "linear",
|
|
231
|
+
fill: "forwards"
|
|
232
|
+
});
|
|
233
|
+
animation.finished.then(() => this.dismiss(), () => void 0);
|
|
234
|
+
this._timer.animation = animation;
|
|
235
|
+
this.resumeTimer();
|
|
236
|
+
}
|
|
237
|
+
stopTimer() {
|
|
238
|
+
this._timer.animation?.cancel();
|
|
239
|
+
this._timer.animation = null;
|
|
240
|
+
}
|
|
241
|
+
resumeTimer() {
|
|
242
|
+
const animation = this._timer.animation;
|
|
243
|
+
if (animation === null) return;
|
|
244
|
+
const held = this._hold.pointer || this._hold.focus;
|
|
245
|
+
this.reflect("paused", held);
|
|
246
|
+
if (held) {
|
|
247
|
+
animation.pause();
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
animation.play();
|
|
251
|
+
}
|
|
252
|
+
hold(reason, on) {
|
|
253
|
+
this._hold[reason] = on;
|
|
254
|
+
this.resumeTimer();
|
|
255
|
+
}
|
|
256
|
+
/** Whether the focus, moving to `next`, stays in the toast (its buttons, or what the page slotted in it). */
|
|
257
|
+
holdsFocus(next) {
|
|
258
|
+
return next instanceof Node && (next === this || this.contains(next) || this._refs.toast.contains(next));
|
|
259
|
+
}
|
|
260
|
+
renderIcon() {
|
|
261
|
+
const icon = this.icon.get();
|
|
262
|
+
this._refs.icon.name.set(icon === "" ? TONE_ICONS[this.tone.get()] : icon);
|
|
263
|
+
}
|
|
264
|
+
/** Inside a toaster, its live region announces the toast; alone, the toast is its own. */
|
|
265
|
+
renderRole() {
|
|
266
|
+
if (this.closest(TOASTER) !== null) {
|
|
267
|
+
this._refs.toast.removeAttribute("role");
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this._refs.toast.setAttribute("role", STANDALONE_ROLES[this.tone.get()]);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
JlToast.register();
|
|
274
|
+
export { JlToast, TOAST_TONES };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// src/molecules/jl-tooltip.css?raw
|
|
2
|
+
var jl_tooltip_default = ":host {\n display: inline-flex;\n vertical-align: middle;\n}\n\n/* Ink on the page's ground: dark on a light theme, light on a dark one. */\n.bubble {\n max-width: min(260px, calc(100vw - 16px));\n padding: 6px 9px;\n border-radius: var(--jl-radius-xs);\n background: var(--jl-text);\n color: var(--jl-bg);\n font-size: var(--jl-font-xs);\n font-weight: 550;\n line-height: 1.4;\n box-shadow: var(--jl-shadow);\n pointer-events: auto;\n}\n\n.arrow {\n position: absolute;\n width: 8px;\n height: 8px;\n border-radius: 1px;\n background: inherit;\n rotate: 45deg;\n}\n\n.bubble[data-placement^=\"top\"] .arrow {\n top: 100%;\n left: var(--arrow, 50%);\n translate: -50% -50%;\n}\n\n.bubble[data-placement^=\"bottom\"] .arrow {\n bottom: 100%;\n left: var(--arrow, 50%);\n translate: -50% 50%;\n}\n\n.bubble[data-placement^=\"left\"] .arrow {\n top: var(--arrow, 50%);\n left: 100%;\n translate: -50% -50%;\n}\n\n.bubble[data-placement^=\"right\"] .arrow {\n top: var(--arrow, 50%);\n right: 100%;\n translate: 50% -50%;\n}\n";
|
|
3
|
+
export { jl_tooltip_default as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { JlElement } from '../base/jl-element';
|
|
2
|
+
import type { Placement } from '../types/floating.types';
|
|
3
|
+
/**
|
|
4
|
+
* A short hint in a dark bubble by its trigger (the slotted element): it shows on hover and on keyboard focus after
|
|
5
|
+
* a `delay`, and hides on leave, blur and Escape. The trigger gets the text as its accessible description.
|
|
6
|
+
*/
|
|
7
|
+
export declare class JlTooltip extends JlElement {
|
|
8
|
+
static readonly selector = "jl-tooltip";
|
|
9
|
+
readonly text: Readonly<Readonly<{
|
|
10
|
+
get(): string;
|
|
11
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
12
|
+
}>>;
|
|
13
|
+
/** Where the bubble goes; it flips to the other side when there is no room. */
|
|
14
|
+
readonly placement: Readonly<Readonly<{
|
|
15
|
+
get(): Placement;
|
|
16
|
+
set(setter: ((prevState: Placement) => Placement) | Placement): void;
|
|
17
|
+
}>>;
|
|
18
|
+
/** How long the pointer or the focus stays on the trigger before the bubble shows, in milliseconds. */
|
|
19
|
+
readonly delay: Readonly<Readonly<{
|
|
20
|
+
get(): number;
|
|
21
|
+
set(setter: number | ((prevState: number) => number)): void;
|
|
22
|
+
}>>;
|
|
23
|
+
private readonly _state;
|
|
24
|
+
private readonly _refs;
|
|
25
|
+
templateHtml(): Node;
|
|
26
|
+
templateCss(): string;
|
|
27
|
+
onConnect(): void;
|
|
28
|
+
onDisconnect(): void;
|
|
29
|
+
/** Shows the bubble now. */
|
|
30
|
+
show(): void;
|
|
31
|
+
/** Hides the bubble now. */
|
|
32
|
+
hide(): void;
|
|
33
|
+
private close;
|
|
34
|
+
private trigger;
|
|
35
|
+
private isOpen;
|
|
36
|
+
private scheduleShow;
|
|
37
|
+
private scheduleHide;
|
|
38
|
+
private open;
|
|
39
|
+
private reposition;
|
|
40
|
+
private placeArrow;
|
|
41
|
+
private renderText;
|
|
42
|
+
/** Gives the trigger the text as its description, and takes it back from a trigger that left. */
|
|
43
|
+
private describeTrigger;
|
|
44
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { BASE_STYLES, FLOATING_STYLES } from "../styles/shared.js";
|
|
2
|
+
import { JlElement } from "../base/jl-element.js";
|
|
3
|
+
import { clampedNumber, oneOf } from "../lib/attributes.js";
|
|
4
|
+
import { PLACEMENTS, followAnchor, placeFloating } from "../lib/floating.js";
|
|
5
|
+
import { accessibleTarget, deepActiveElement } from "../lib/trigger.js";
|
|
6
|
+
import { arrowOffset } from "../lib/arrow.js";
|
|
7
|
+
import jl_tooltip_default from "./jl-tooltip.css_raw.js";
|
|
8
|
+
import { css } from "@jadis/core";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "@jadis/core/jsx-runtime";
|
|
10
|
+
// src/molecules/jl-tooltip.tsx
|
|
11
|
+
var DEFAULT_DELAY_MS = 300;
|
|
12
|
+
var MAX_DELAY_MS = 1e4;
|
|
13
|
+
var HIDE_GRACE_MS = 120;
|
|
14
|
+
var GAP = 9;
|
|
15
|
+
var ARROW_MARGIN = 10;
|
|
16
|
+
var DESCRIPTION = "aria-description";
|
|
17
|
+
var sideOf = (placement) => placement.split("-")[0];
|
|
18
|
+
/**
|
|
19
|
+
* A short hint in a dark bubble by its trigger (the slotted element): it shows on hover and on keyboard focus after
|
|
20
|
+
* a `delay`, and hides on leave, blur and Escape. The trigger gets the text as its accessible description.
|
|
21
|
+
*/
|
|
22
|
+
var JlTooltip = class extends JlElement {
|
|
23
|
+
static selector = "jl-tooltip";
|
|
24
|
+
text = this.useChange("", (value) => this.renderText(value), { attribute: "text" });
|
|
25
|
+
/** Where the bubble goes; it flips to the other side when there is no room. */
|
|
26
|
+
placement = this.useChange("top", () => this.reposition(), {
|
|
27
|
+
attribute: "placement",
|
|
28
|
+
parse: oneOf(PLACEMENTS, "top")
|
|
29
|
+
});
|
|
30
|
+
/** How long the pointer or the focus stays on the trigger before the bubble shows, in milliseconds. */
|
|
31
|
+
delay = this.useChange(DEFAULT_DELAY_MS, () => void 0, {
|
|
32
|
+
attribute: "delay",
|
|
33
|
+
parse: clampedNumber(DEFAULT_DELAY_MS, 0, MAX_DELAY_MS)
|
|
34
|
+
});
|
|
35
|
+
_state = {
|
|
36
|
+
described: null,
|
|
37
|
+
following: new AbortController(),
|
|
38
|
+
hideTimer: 0,
|
|
39
|
+
showTimer: 0
|
|
40
|
+
};
|
|
41
|
+
_refs = this.useRefs((ref) => ({
|
|
42
|
+
bubble: ref(".bubble"),
|
|
43
|
+
slot: ref("slot"),
|
|
44
|
+
text: ref(".text")
|
|
45
|
+
}));
|
|
46
|
+
templateHtml() {
|
|
47
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("slot", {}), /* @__PURE__ */ jsxs("div", {
|
|
48
|
+
class: "floating bubble",
|
|
49
|
+
popover: "manual",
|
|
50
|
+
role: "tooltip",
|
|
51
|
+
attrs: { part: "base" },
|
|
52
|
+
children: [/* @__PURE__ */ jsx("span", { class: "text" }), /* @__PURE__ */ jsx("span", { class: "arrow" })]
|
|
53
|
+
})] });
|
|
54
|
+
}
|
|
55
|
+
templateCss() {
|
|
56
|
+
return css`${BASE_STYLES}${FLOATING_STYLES}${jl_tooltip_default}`;
|
|
57
|
+
}
|
|
58
|
+
onConnect() {
|
|
59
|
+
this.describeTrigger();
|
|
60
|
+
this.on(this._refs.slot, "slotchange", () => this.describeTrigger());
|
|
61
|
+
this.on(this, "pointerenter", () => this.scheduleShow());
|
|
62
|
+
this.on(this, "pointerleave", () => this.scheduleHide());
|
|
63
|
+
this.on(this, "pointerdown", () => this.close());
|
|
64
|
+
this.on(this, "focusin", () => {
|
|
65
|
+
if (deepActiveElement(document)?.matches(":focus-visible") === true) this.scheduleShow();
|
|
66
|
+
});
|
|
67
|
+
this.on(this, "focusout", () => this.close());
|
|
68
|
+
}
|
|
69
|
+
onDisconnect() {
|
|
70
|
+
this.close();
|
|
71
|
+
}
|
|
72
|
+
/** Shows the bubble now. */
|
|
73
|
+
show() {
|
|
74
|
+
this.whenRendered(() => this.open());
|
|
75
|
+
}
|
|
76
|
+
/** Hides the bubble now. */
|
|
77
|
+
hide() {
|
|
78
|
+
this.whenRendered(() => this.close());
|
|
79
|
+
}
|
|
80
|
+
close() {
|
|
81
|
+
window.clearTimeout(this._state.showTimer);
|
|
82
|
+
window.clearTimeout(this._state.hideTimer);
|
|
83
|
+
this._state.following.abort();
|
|
84
|
+
const bubble = this._refs.bubble;
|
|
85
|
+
if (bubble.matches(":popover-open")) bubble.hidePopover();
|
|
86
|
+
}
|
|
87
|
+
trigger() {
|
|
88
|
+
return this._refs.slot.assignedElements({ flatten: true })[0] ?? this;
|
|
89
|
+
}
|
|
90
|
+
isOpen() {
|
|
91
|
+
return this._refs.bubble.matches(":popover-open");
|
|
92
|
+
}
|
|
93
|
+
scheduleShow() {
|
|
94
|
+
window.clearTimeout(this._state.hideTimer);
|
|
95
|
+
if (this.isOpen()) return;
|
|
96
|
+
window.clearTimeout(this._state.showTimer);
|
|
97
|
+
this._state.showTimer = window.setTimeout(() => this.open(), this.delay.get());
|
|
98
|
+
}
|
|
99
|
+
scheduleHide() {
|
|
100
|
+
window.clearTimeout(this._state.showTimer);
|
|
101
|
+
window.clearTimeout(this._state.hideTimer);
|
|
102
|
+
this._state.hideTimer = window.setTimeout(() => this.close(), HIDE_GRACE_MS);
|
|
103
|
+
}
|
|
104
|
+
open() {
|
|
105
|
+
if (this.text.get() === "" || this.isOpen()) return;
|
|
106
|
+
const bubble = this._refs.bubble;
|
|
107
|
+
bubble.showPopover();
|
|
108
|
+
const following = new AbortController();
|
|
109
|
+
this._state.following = following;
|
|
110
|
+
followAnchor(this.trigger(), bubble, this.placement.get(), following.signal, GAP);
|
|
111
|
+
window.addEventListener("scroll", () => this.placeArrow(), {
|
|
112
|
+
capture: true,
|
|
113
|
+
passive: true,
|
|
114
|
+
signal: following.signal
|
|
115
|
+
});
|
|
116
|
+
window.addEventListener("resize", () => this.placeArrow(), {
|
|
117
|
+
passive: true,
|
|
118
|
+
signal: following.signal
|
|
119
|
+
});
|
|
120
|
+
document.addEventListener("keydown", (event) => {
|
|
121
|
+
if (event.key === "Escape") this.close();
|
|
122
|
+
}, { signal: following.signal });
|
|
123
|
+
this.placeArrow();
|
|
124
|
+
}
|
|
125
|
+
reposition() {
|
|
126
|
+
if (!this.isOpen()) return;
|
|
127
|
+
placeFloating(this.trigger(), this._refs.bubble, this.placement.get(), GAP);
|
|
128
|
+
this.placeArrow();
|
|
129
|
+
}
|
|
130
|
+
placeArrow() {
|
|
131
|
+
const bubble = this._refs.bubble;
|
|
132
|
+
const placement = bubble.dataset.placement ?? this.placement.get();
|
|
133
|
+
const offset = arrowOffset(this.trigger().getBoundingClientRect(), bubble.getBoundingClientRect(), sideOf(placement), ARROW_MARGIN);
|
|
134
|
+
bubble.style.setProperty("--arrow", `${offset}px`);
|
|
135
|
+
}
|
|
136
|
+
renderText(text) {
|
|
137
|
+
this._refs.text.textContent = text;
|
|
138
|
+
this.describeTrigger();
|
|
139
|
+
if (text === "") {
|
|
140
|
+
this.close();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.reposition();
|
|
144
|
+
}
|
|
145
|
+
/** Gives the trigger the text as its description, and takes it back from a trigger that left. */
|
|
146
|
+
describeTrigger() {
|
|
147
|
+
const target = accessibleTarget(this.trigger());
|
|
148
|
+
const previous = this._state.described;
|
|
149
|
+
if (previous !== null && previous !== target) previous.removeAttribute(DESCRIPTION);
|
|
150
|
+
this._state.described = target;
|
|
151
|
+
const text = this.text.get();
|
|
152
|
+
if (text === "" || target === this) {
|
|
153
|
+
target.removeAttribute(DESCRIPTION);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
target.setAttribute(DESCRIPTION, text);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
JlTooltip.register();
|
|
160
|
+
export { JlTooltip };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// src/organisms/jl-command-palette.css?raw
|
|
2
|
+
var jl_command_palette_default = ":host {\n display: contents;\n}\n\ndialog {\n flex-direction: column;\n width: min(620px, calc(100vw - 24px));\n max-width: none;\n max-height: min(520px, calc(100dvh - 24vh));\n margin: 12vh auto auto;\n padding: 0;\n overflow: hidden;\n border: 1px solid var(--jl-line);\n border-radius: var(--jl-radius-lg);\n background: var(--jl-surface);\n color: var(--jl-text);\n font-size: var(--jl-font-md);\n box-shadow: var(--jl-shadow-lg);\n}\n\ndialog[open] {\n display: flex;\n animation: drop var(--jl-fast) var(--jl-ease);\n}\n\ndialog::backdrop {\n background: var(--jl-scrim);\n backdrop-filter: blur(2px);\n}\n\n.search {\n display: flex;\n flex: none;\n align-items: center;\n gap: 10px;\n height: 52px;\n padding: 0 14px 0 16px;\n border-bottom: 1px solid var(--jl-line);\n}\n\n.search-icon {\n color: var(--jl-faint);\n}\n\ninput {\n flex: 1;\n min-width: 0;\n height: 100%;\n padding: 0;\n border: none;\n outline: none;\n background: none;\n font-size: 15px;\n}\n\ninput::placeholder {\n color: var(--jl-faint);\n}\n\ninput:focus-visible {\n box-shadow: none;\n}\n\nkbd {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 20px;\n height: 20px;\n padding: 0 5px;\n border: 1px solid var(--jl-line-strong);\n border-bottom-width: 2px;\n border-radius: var(--jl-radius-xs);\n background: var(--jl-surface);\n color: var(--jl-muted);\n font-size: 11px;\n font-weight: 500;\n line-height: 1;\n}\n\n.results {\n flex: 1;\n min-height: 0;\n padding: 6px;\n overflow-y: auto;\n overscroll-behavior: contain;\n scroll-padding: 6px;\n}\n\n[role=\"group\"] + [role=\"group\"] {\n margin-top: 4px;\n padding-top: 4px;\n border-top: 1px solid var(--jl-line-soft);\n}\n\n.group-label {\n padding: 8px 10px 4px;\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n font-weight: 600;\n}\n\n.option {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 38px;\n padding: 0 10px;\n border-radius: var(--jl-radius-sm);\n color: var(--jl-text-2);\n cursor: pointer;\n}\n\n.option[aria-selected=\"true\"] {\n background: var(--jl-accent-soft);\n color: var(--jl-text);\n}\n\n.option-icon {\n flex: none;\n width: 16px;\n color: var(--jl-muted);\n}\n\n.option[aria-selected=\"true\"] .option-icon {\n color: var(--jl-accent);\n}\n\n.option-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\nmark {\n background: none;\n color: var(--jl-accent);\n font-weight: 700;\n}\n\n.keys {\n display: inline-flex;\n flex: none;\n gap: 3px;\n}\n\n.empty {\n padding: 36px 16px;\n color: var(--jl-muted);\n text-align: center;\n}\n\nfooter {\n display: flex;\n flex: none;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 16px;\n padding: 8px 16px;\n border-top: 1px solid var(--jl-line);\n background: var(--jl-surface-2);\n color: var(--jl-muted);\n font-size: var(--jl-font-xs);\n}\n\n.hint,\n.hotkey-keys {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n\n.hotkey-hint {\n margin-left: auto;\n}\n\n@media (width < 520px) {\n dialog {\n margin-top: 12px;\n max-height: calc(100dvh - 24px);\n }\n\n .hotkey-hint {\n display: none;\n }\n}\n\n@keyframes drop {\n from {\n opacity: 0;\n transform: translateY(-6px) scale(0.98);\n }\n}\n";
|
|
3
|
+
export { jl_command_palette_default as default };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { JlElement } from '../base/jl-element';
|
|
2
|
+
import type { PaletteCommand } from '../types/jl-command-palette.types';
|
|
3
|
+
/**
|
|
4
|
+
* A search box over every command of an app, opened by ⌘K (Ctrl+K off Apple) or `show()`. Typing filters the
|
|
5
|
+
* commands by their letters in order, best matches first, under their groups; arrows move, Enter runs the command
|
|
6
|
+
* (`select` with its id) and Escape closes. It sits near the top of the window, on the browser's modal `<dialog>`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class JlCommandPalette extends JlElement {
|
|
9
|
+
static readonly selector = "jl-command-palette";
|
|
10
|
+
readonly events: Readonly<import("@jadis/core").UseEventsHandler<{
|
|
11
|
+
select: string;
|
|
12
|
+
open: undefined;
|
|
13
|
+
close: undefined;
|
|
14
|
+
}>>;
|
|
15
|
+
readonly commands: Readonly<Readonly<{
|
|
16
|
+
get(): PaletteCommand[];
|
|
17
|
+
set(setter: PaletteCommand[] | ((prevState: PaletteCommand[]) => PaletteCommand[])): void;
|
|
18
|
+
}>>;
|
|
19
|
+
readonly open: Readonly<Readonly<{
|
|
20
|
+
get(): boolean;
|
|
21
|
+
set(setter: boolean | ((prevState: boolean) => boolean)): void;
|
|
22
|
+
}>>;
|
|
23
|
+
readonly placeholder: Readonly<Readonly<{
|
|
24
|
+
get(): string;
|
|
25
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
26
|
+
}>>;
|
|
27
|
+
/** The keys that open and close it from anywhere on the page; `none` for no keys. `mod` is ⌘ or Ctrl. */
|
|
28
|
+
readonly hotkey: Readonly<Readonly<{
|
|
29
|
+
get(): string;
|
|
30
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
31
|
+
}>>;
|
|
32
|
+
/** What it says when nothing matches. */
|
|
33
|
+
readonly emptyText: Readonly<Readonly<{
|
|
34
|
+
get(): string;
|
|
35
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
36
|
+
}>>;
|
|
37
|
+
/** The dialog's name for screen readers. */
|
|
38
|
+
readonly label: Readonly<Readonly<{
|
|
39
|
+
get(): string;
|
|
40
|
+
set(setter: string | ((prevState: string) => string)): void;
|
|
41
|
+
}>>;
|
|
42
|
+
private readonly _state;
|
|
43
|
+
private readonly _refs;
|
|
44
|
+
show(): void;
|
|
45
|
+
close(): void;
|
|
46
|
+
templateHtml(): Node;
|
|
47
|
+
templateCss(): string;
|
|
48
|
+
onConnect(): void;
|
|
49
|
+
private toggleOnHotkey;
|
|
50
|
+
private navigate;
|
|
51
|
+
private indexOf;
|
|
52
|
+
private move;
|
|
53
|
+
private choose;
|
|
54
|
+
private renderOpen;
|
|
55
|
+
private renderHotkey;
|
|
56
|
+
private renderResults;
|
|
57
|
+
private groupNode;
|
|
58
|
+
private optionNode;
|
|
59
|
+
private activate;
|
|
60
|
+
}
|