@loomidev/floating-panel 0.2.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/LICENSE +21 -0
- package/README.md +389 -0
- package/custom-elements.json +804 -0
- package/dist/generated/styles.css.d.ts +3 -0
- package/dist/generated/styles.css.d.ts.map +1 -0
- package/dist/generated/styles.css.js +5 -0
- package/dist/generated/styles.css.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/loomi-floating-panel.d.ts +123 -0
- package/dist/loomi-floating-panel.d.ts.map +1 -0
- package/dist/loomi-floating-panel.js +591 -0
- package/dist/loomi-floating-panel.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.css.d.ts","sourceRoot":"","sources":["../../src/generated/styles.css.ts"],"names":[],"mappings":"AAGA,+EAA+E;AAC/E,eAAO,MAAM,eAAe,yBAAkxG,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Generated by @loomidev/floating-panel — do not edit by hand. Run `pnpm build` to regenerate.
|
|
2
|
+
import { unsafeCSS } from "lit";
|
|
3
|
+
/** Compiled, Shadow-DOM-scoped styles. Colors resolve via `var(--loomi-*)`. */
|
|
4
|
+
export const componentStyles = unsafeCSS("/*! tailwindcss v4.3.2 | MIT License | https://tailwindcss.com */\n@layer theme,base,components,utilities;:host{box-sizing:border-box;background:var(--loomi-surface);width:22rem;max-width:100dvw;height:26rem;max-height:100dvh;color:var(--loomi-text);border:1px solid var(--loomi-surface-border);border-radius:var(--loomi-panel-radius,.75rem);box-shadow:var(--loomi-shadow-elevated);z-index:var(--loomi-floating-panel-z-index,2147480000);animation:loomi-pop-in var(--loomi-floating-panel-duration,var(--loomi-motion-duration)) var(--loomi-motion-ease);flex-direction:column;display:none;position:fixed}:host([open]){display:flex}:host(.is-centered){animation-name:loomi-floating-panel-pop-centered;top:50%;left:50%;transform:translate(-50%,-50%)}:host(.is-dragging),:host(.is-resizing){-webkit-user-select:none;user-select:none;animation:none}:host([minimized]){height:auto!important}:host([minimized]) .loomi-body,:host([minimized]) .loomi-resize{display:none}:host([maximized]){border-radius:0;width:100dvw!important;height:100dvh!important;top:0!important;left:0!important}:host([maximized]) .loomi-resize{display:none}.loomi-header{border-bottom:1px solid var(--loomi-surface-border);touch-action:none;flex:none;align-items:center;gap:.35rem;padding:.65rem .5rem .65rem .9rem;display:flex}.loomi-header:not(.has-grip){cursor:move}.loomi-header:not(.has-grip):focus-visible{outline:2px solid var(--loomi-focus-ring-color);outline-offset:-2px}.loomi-grip{color:var(--loomi-text-faint);cursor:move;border-radius:.375rem;flex:none;justify-content:center;align-items:center;margin-left:-.3rem;padding:.3rem;display:inline-flex}.loomi-grip svg{width:1rem;height:1rem}.loomi-grip:focus-visible{outline:2px solid var(--loomi-focus-ring-color);outline-offset:-2px}.loomi-title{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;font-size:.95rem;font-weight:600;line-height:1.4;overflow:hidden}.loomi-header-actions{flex:none;align-items:center;gap:.1rem;display:flex}.loomi-header-btn{color:var(--loomi-text-faint);cursor:pointer;background:0 0;border:0;border-radius:.375rem;flex:none;justify-content:center;align-items:center;padding:.3rem;line-height:0;display:inline-flex}.loomi-header-btn:hover{color:var(--loomi-text-secondary);background:var(--loomi-surface-hover)}.loomi-header-btn:focus-visible{outline:2px solid var(--loomi-focus-ring-color);outline-offset:2px}.loomi-body{min-height:0;color:var(--loomi-text-secondary);flex:1;padding:1rem;line-height:1.6;overflow:auto}.loomi-resize{z-index:1;position:absolute}.loomi-resize:focus-visible{outline:2px solid var(--loomi-focus-ring-color);outline-offset:-2px;border-radius:.2rem}.dir-n,.dir-s{cursor:ns-resize;height:.5rem;left:.5rem;right:.5rem}.dir-n{top:-.25rem}.dir-s{bottom:-.25rem}.dir-e,.dir-w{cursor:ew-resize;width:.5rem;top:.5rem;bottom:.5rem}.dir-e{right:-.25rem}.dir-w{left:-.25rem}.dir-ne,.dir-nw,.dir-se,.dir-sw{width:.9rem;height:.9rem}.dir-ne{cursor:nesw-resize;top:-.25rem;right:-.25rem}.dir-nw{cursor:nwse-resize;top:-.25rem;left:-.25rem}.dir-se{cursor:nwse-resize;bottom:-.25rem;right:-.25rem}.dir-sw{cursor:nesw-resize;bottom:-.25rem;left:-.25rem}@media (max-width:30rem){.loomi-header{padding:.5rem .4rem .5rem .75rem}.loomi-body{padding:.75rem}}@keyframes loomi-floating-panel-pop-centered{0%{opacity:0;transform:translate(-50%,-50%)scale(.98)}}");
|
|
5
|
+
//# sourceMappingURL=styles.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.css.js","sourceRoot":"","sources":["../../src/generated/styles.css.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEhC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAC,owGAAowG,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { LoomiFloatingPanel, showLoomiFloatingPanel, hideLoomiFloatingPanel, type LoomiFloatingPanelMinimizeDetail, type LoomiFloatingPanelMaximizeDetail, type LoomiFloatingPanelDragDetail, type LoomiFloatingPanelResizeDetail, } from "./loomi-floating-panel.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,EACrC,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,GACpC,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,GAKvB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { nothing, type PropertyValues, type TemplateResult } from "lit";
|
|
2
|
+
import { LoomiElement } from "@loomidev/core";
|
|
3
|
+
import "@loomidev/icon/loomi-icon.js";
|
|
4
|
+
/** Open a floating panel by its `name`. */
|
|
5
|
+
export declare function showLoomiFloatingPanel(name: string): void;
|
|
6
|
+
/** Close a floating panel by its `name`. */
|
|
7
|
+
export declare function hideLoomiFloatingPanel(name: string): void;
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
showLoomiFloatingPanel: typeof showLoomiFloatingPanel;
|
|
11
|
+
hideLoomiFloatingPanel: typeof hideLoomiFloatingPanel;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `<loomi-floating-panel>` — a draggable, resizable panel that floats above the page,
|
|
16
|
+
* unanchored to any trigger. Open/close via `name` with `showLoomiFloatingPanel()` /
|
|
17
|
+
* `hideLoomiFloatingPanel()`, or the instance `show()` / `hide()` methods.
|
|
18
|
+
*
|
|
19
|
+
* @slot - The panel body.
|
|
20
|
+
* @fires open - Shown. @fires close - Dismissed.
|
|
21
|
+
* @fires loomi-drag - `detail: { top, left }` after the panel is moved.
|
|
22
|
+
* @fires loomi-resize - `detail: { top, left, width, height }` after the panel is resized.
|
|
23
|
+
* @fires loomi-minimize - `detail: { minimized }` when the minimize button is toggled.
|
|
24
|
+
* @fires loomi-maximize - `detail: { maximized }` when the maximize button (or header double-click) is toggled.
|
|
25
|
+
*/
|
|
26
|
+
export declare class LoomiFloatingPanel extends LoomiElement {
|
|
27
|
+
static styles: import("lit").CSSResultGroup[];
|
|
28
|
+
name: string;
|
|
29
|
+
title: string;
|
|
30
|
+
locale: string;
|
|
31
|
+
open: boolean;
|
|
32
|
+
showCloseIcon: boolean;
|
|
33
|
+
/** Enables the eight drag handles along the edges/corners. */
|
|
34
|
+
resizable: boolean;
|
|
35
|
+
/** Disables moving the panel by dragging (or arrow-keying) its header. */
|
|
36
|
+
noDrag: boolean;
|
|
37
|
+
/** Keeps the panel's edges within the viewport while dragging/resizing. */
|
|
38
|
+
bounded: boolean;
|
|
39
|
+
/** Shows a header button that collapses the panel to just its title bar. */
|
|
40
|
+
minimize: boolean;
|
|
41
|
+
/** Shows a header button that expands the panel to fill the viewport. */
|
|
42
|
+
maximize: boolean;
|
|
43
|
+
/** Restricts dragging to a dedicated grip in the header instead of the whole header. */
|
|
44
|
+
dragHandle: boolean;
|
|
45
|
+
/** Whether the panel is currently collapsed to its title bar. */
|
|
46
|
+
minimized: boolean;
|
|
47
|
+
/** Whether the panel is currently filling the viewport. */
|
|
48
|
+
maximized: boolean;
|
|
49
|
+
/** Initial position; any CSS length. Left unset, the panel opens centered. */
|
|
50
|
+
top: string;
|
|
51
|
+
left: string;
|
|
52
|
+
/** Initial size; any CSS length. Left unset, falls back to the stylesheet default. */
|
|
53
|
+
width: string;
|
|
54
|
+
height: string;
|
|
55
|
+
minWidth: number;
|
|
56
|
+
minHeight: number;
|
|
57
|
+
maxWidth: number;
|
|
58
|
+
maxHeight: number;
|
|
59
|
+
/** Persists position/size to `localStorage` under this key across reloads. */
|
|
60
|
+
autoSaveId: string;
|
|
61
|
+
/** Explicit pixel rect once the panel has been dragged/resized (or restored); `null` while it's still following the `top`/`left`/`width`/`height` attributes (or centered). */
|
|
62
|
+
private rect;
|
|
63
|
+
private hasLoadedPersisted;
|
|
64
|
+
/** The element focused before `show()` was called, restored when the panel closes. */
|
|
65
|
+
private previouslyFocused;
|
|
66
|
+
private originalParent;
|
|
67
|
+
private originalNextSibling;
|
|
68
|
+
connectedCallback(): void;
|
|
69
|
+
disconnectedCallback(): void;
|
|
70
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
71
|
+
show(): void;
|
|
72
|
+
hide(): void;
|
|
73
|
+
private bringToFront;
|
|
74
|
+
private moveToDocumentBody;
|
|
75
|
+
private restoreOriginalPosition;
|
|
76
|
+
private storageKey;
|
|
77
|
+
private loadPersistedRect;
|
|
78
|
+
private persistRect;
|
|
79
|
+
/** Applies `rect` (once the panel has moved/resized) or the raw `top`/`left`/`width`/`height` attributes directly to the host's inline style — the host itself is the visible, positioned box. */
|
|
80
|
+
private syncPosition;
|
|
81
|
+
private containsFocus;
|
|
82
|
+
private onKey;
|
|
83
|
+
/** Toggles the collapsed-to-title-bar state; turns off `maximized` first if it was on. */
|
|
84
|
+
private toggleMinimize;
|
|
85
|
+
/** Toggles the fill-the-viewport state; turns off `minimized` first if it was on. */
|
|
86
|
+
private toggleMaximize;
|
|
87
|
+
private onHeaderDoubleClick;
|
|
88
|
+
private onHeaderPointerDown;
|
|
89
|
+
private onHeaderKeyDown;
|
|
90
|
+
/** Resizes from `start` by pointer/keyboard delta `(dx, dy)`, re-anchoring the edge opposite the drag direction so it doesn't move once width/height clamp. */
|
|
91
|
+
private computeResizedRect;
|
|
92
|
+
private onResizePointerDown;
|
|
93
|
+
private onResizeKeyDown;
|
|
94
|
+
render(): TemplateResult | typeof nothing;
|
|
95
|
+
}
|
|
96
|
+
export interface LoomiFloatingPanelMinimizeDetail {
|
|
97
|
+
minimized: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface LoomiFloatingPanelMaximizeDetail {
|
|
100
|
+
maximized: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface LoomiFloatingPanelDragDetail {
|
|
103
|
+
top: number;
|
|
104
|
+
left: number;
|
|
105
|
+
}
|
|
106
|
+
export interface LoomiFloatingPanelResizeDetail {
|
|
107
|
+
top: number;
|
|
108
|
+
left: number;
|
|
109
|
+
width: number;
|
|
110
|
+
height: number;
|
|
111
|
+
}
|
|
112
|
+
declare global {
|
|
113
|
+
interface HTMLElementTagNameMap {
|
|
114
|
+
"loomi-floating-panel": LoomiFloatingPanel;
|
|
115
|
+
}
|
|
116
|
+
interface HTMLElementEventMap {
|
|
117
|
+
"loomi-minimize": CustomEvent<LoomiFloatingPanelMinimizeDetail>;
|
|
118
|
+
"loomi-maximize": CustomEvent<LoomiFloatingPanelMaximizeDetail>;
|
|
119
|
+
"loomi-drag": CustomEvent<LoomiFloatingPanelDragDetail>;
|
|
120
|
+
"loomi-resize": CustomEvent<LoomiFloatingPanelResizeDetail>;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=loomi-floating-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loomi-floating-panel.d.ts","sourceRoot":"","sources":["../src/loomi-floating-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAO,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAEnF,OAAO,EAAE,YAAY,EAAuB,MAAM,gBAAgB,CAAC;AACnE,OAAO,8BAA8B,CAAC;AA0CtC,2CAA2C;AAC3C,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEzD;AACD,4CAA4C;AAC5C,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAEzD;AAKD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,sBAAsB,EAAE,OAAO,sBAAsB,CAAC;QACtD,sBAAsB,EAAE,OAAO,sBAAsB,CAAC;KACvD;CACF;AAMD;;;;;;;;;;;GAWG;AACH,qBACa,kBAAmB,SAAQ,YAAY;IAClD,OAAgB,MAAM,iCAAgC;IAE1C,IAAI,SAAM;IACV,KAAK,SAAM;IACX,MAAM,SAAM;IACoB,IAAI,UAAS;IAEzD,aAAa,UAAQ;IACrB,8DAA8D;IACJ,SAAS,UAAQ;IAC3E,0EAA0E;IACvB,MAAM,UAAS;IAClE,2EAA2E;IACjB,OAAO,UAA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