@pie-players/pie-section-player-tools-shared 0.3.11 → 0.3.13

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.
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
2
  let {
3
3
  onPointerDown,
4
- handleClass = "absolute bottom-0 right-0 w-4 h-4 cursor-se-resize",
5
- iconClass = "w-full h-full text-base-content/30",
4
+ handleClass = "pie-panel-resize-handle",
5
+ iconClass = "pie-panel-resize-icon",
6
6
  } = $props<{
7
7
  onPointerDown?: (event: MouseEvent) => void;
8
8
  handleClass?: string;
@@ -16,6 +16,7 @@
16
16
  role="button"
17
17
  tabindex="0"
18
18
  title="Resize window"
19
+ aria-label="Resize window"
19
20
  >
20
21
  <svg class={iconClass} viewBox="0 0 16 16" fill="currentColor">
21
22
  <path d="M16 16V14H14V16H16Z" />
@@ -23,3 +24,29 @@
23
24
  <path d="M13 16V14H11V16H13Z" />
24
25
  </svg>
25
26
  </div>
27
+
28
+ <style>
29
+ .pie-panel-resize-handle {
30
+ position: absolute;
31
+ right: 0;
32
+ bottom: 0;
33
+ width: 12px;
34
+ height: 12px;
35
+ display: inline-flex;
36
+ align-items: center;
37
+ justify-content: center;
38
+ cursor: nwse-resize;
39
+ opacity: 0.82;
40
+ z-index: 2;
41
+ }
42
+
43
+ .pie-panel-resize-handle:hover {
44
+ opacity: 1;
45
+ }
46
+
47
+ .pie-panel-resize-icon {
48
+ width: 100%;
49
+ height: 100%;
50
+ color: color-mix(in srgb, var(--color-base-content, #334155) 30%, transparent);
51
+ }
52
+ </style>
@@ -0,0 +1,197 @@
1
+ <script lang="ts">
2
+ import { onDestroy, onMount, untrack } from "svelte";
3
+ import type { Snippet } from "svelte";
4
+ import PanelResizeHandle from "./PanelResizeHandle.svelte";
5
+ import PanelWindowControls from "./PanelWindowControls.svelte";
6
+ import {
7
+ claimNextFloatingPanelZIndex,
8
+ computePanelSizeFromViewport,
9
+ createFloatingPanelPointerController,
10
+ type FloatingPanelViewportSizing,
11
+ } from "./floating-panel.js";
12
+
13
+ let {
14
+ title,
15
+ ariaLabel = "Drag panel",
16
+ initialSizing,
17
+ minWidth = 320,
18
+ minHeight = 260,
19
+ defaultMinimized = false,
20
+ onClose,
21
+ className = "",
22
+ bodyClass = "",
23
+ headerClass = "",
24
+ children,
25
+ icon,
26
+ headerActions,
27
+ }: {
28
+ title: string;
29
+ ariaLabel?: string;
30
+ initialSizing: FloatingPanelViewportSizing;
31
+ minWidth?: number;
32
+ minHeight?: number;
33
+ defaultMinimized?: boolean;
34
+ onClose?: () => void;
35
+ className?: string;
36
+ bodyClass?: string;
37
+ headerClass?: string;
38
+ children?: Snippet;
39
+ icon?: Snippet;
40
+ headerActions?: Snippet;
41
+ } = $props();
42
+
43
+ let panelX = $state(16);
44
+ let panelY = $state(16);
45
+ let panelWidth = $state(420);
46
+ let panelHeight = $state(480);
47
+ let panelZIndex = $state(claimNextFloatingPanelZIndex());
48
+ let isMinimized = $state(untrack(() => defaultMinimized));
49
+
50
+ const pointerController = createFloatingPanelPointerController({
51
+ getState: () => ({
52
+ x: panelX,
53
+ y: panelY,
54
+ width: panelWidth,
55
+ height: panelHeight,
56
+ }),
57
+ setState: (next) => {
58
+ panelX = next.x;
59
+ panelY = next.y;
60
+ panelWidth = next.width;
61
+ panelHeight = next.height;
62
+ },
63
+ minWidth: untrack(() => minWidth),
64
+ minHeight: untrack(() => minHeight),
65
+ onFocus: () => {
66
+ panelZIndex = claimNextFloatingPanelZIndex();
67
+ },
68
+ });
69
+
70
+ function bringToFront(): void {
71
+ panelZIndex = claimNextFloatingPanelZIndex();
72
+ }
73
+
74
+ onMount(() => {
75
+ const initial = computePanelSizeFromViewport(
76
+ { width: window.innerWidth, height: window.innerHeight },
77
+ initialSizing,
78
+ );
79
+ panelX = initial.x;
80
+ panelY = initial.y;
81
+ panelWidth = initial.width;
82
+ panelHeight = initial.height;
83
+ });
84
+
85
+ onDestroy(() => {
86
+ pointerController.stop();
87
+ });
88
+
89
+ const resolvedPanelClass = $derived.by(() =>
90
+ ["pie-shared-floating-panel", className || ""].join(" ").trim(),
91
+ );
92
+ const resolvedBodyClass = $derived.by(() =>
93
+ ["pie-shared-floating-panel__body", bodyClass || ""].join(" ").trim(),
94
+ );
95
+ const resolvedHeaderClass = $derived.by(() =>
96
+ ["pie-shared-floating-panel__header", headerClass || ""].join(" ").trim(),
97
+ );
98
+ </script>
99
+
100
+ <section
101
+ class={resolvedPanelClass}
102
+ style={`left: ${panelX}px; top: ${panelY}px; width: ${panelWidth}px; z-index: ${panelZIndex}; ${
103
+ isMinimized ? "height: auto;" : `height: ${panelHeight}px;`
104
+ }`}
105
+ >
106
+ <header
107
+ class={resolvedHeaderClass}
108
+ onmousedown={(event: MouseEvent) => {
109
+ bringToFront();
110
+ pointerController.startDrag(event);
111
+ }}
112
+ role="button"
113
+ tabindex="0"
114
+ aria-label={ariaLabel}
115
+ >
116
+ <div class="pie-shared-floating-panel__header-main">
117
+ <div class="pie-shared-floating-panel__header-title-wrap">
118
+ {@render icon?.()}
119
+ <h3 class="pie-shared-floating-panel__title">{title}</h3>
120
+ </div>
121
+ {@render headerActions?.()}
122
+ </div>
123
+ <div class="pie-shared-floating-panel__header-controls">
124
+ <PanelWindowControls
125
+ minimized={isMinimized}
126
+ onToggle={() => (isMinimized = !isMinimized)}
127
+ onClose={onClose}
128
+ />
129
+ </div>
130
+ </header>
131
+
132
+ {#if !isMinimized}
133
+ <div class={resolvedBodyClass}>
134
+ {@render children?.()}
135
+ </div>
136
+ <PanelResizeHandle onPointerDown={(event: MouseEvent) => pointerController.startResize(event)} />
137
+ {/if}
138
+ </section>
139
+
140
+ <style>
141
+ .pie-shared-floating-panel {
142
+ position: fixed;
143
+ display: flex;
144
+ flex-direction: column;
145
+ background: var(--color-base-100, #fff);
146
+ color: var(--color-base-content, #1f2937);
147
+ border: 2px solid var(--color-base-300, #d1d5db);
148
+ border-radius: 8px;
149
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
150
+ overflow: hidden;
151
+ font-family: var(--pie-font-family, Inter, system-ui, sans-serif);
152
+ }
153
+
154
+ .pie-shared-floating-panel__header {
155
+ padding: 8px 16px;
156
+ display: flex;
157
+ align-items: center;
158
+ justify-content: space-between;
159
+ background: var(--color-base-200, #f3f4f6);
160
+ cursor: move;
161
+ user-select: none;
162
+ border-bottom: 1px solid var(--color-base-300, #d1d5db);
163
+ }
164
+
165
+ .pie-shared-floating-panel__header-main {
166
+ display: flex;
167
+ align-items: center;
168
+ gap: 8px;
169
+ min-width: 0;
170
+ flex: 1;
171
+ }
172
+
173
+ .pie-shared-floating-panel__header-title-wrap {
174
+ display: flex;
175
+ align-items: center;
176
+ gap: 8px;
177
+ min-width: 0;
178
+ }
179
+
180
+ .pie-shared-floating-panel__title {
181
+ margin: 0;
182
+ font-size: 0.95rem;
183
+ font-weight: 700;
184
+ }
185
+
186
+ .pie-shared-floating-panel__header-controls {
187
+ display: flex;
188
+ gap: 4px;
189
+ }
190
+
191
+ .pie-shared-floating-panel__body {
192
+ flex: 1;
193
+ min-height: 0;
194
+ display: flex;
195
+ flex-direction: column;
196
+ }
197
+ </style>
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -4,6 +4,7 @@ export type FloatingPanelState = {
4
4
  width: number;
5
5
  height: number;
6
6
  };
7
+ export declare function claimNextFloatingPanelZIndex(): number;
7
8
  export type FloatingPanelViewportSizing = {
8
9
  widthRatio: number;
9
10
  heightRatio: number;
@@ -26,6 +27,7 @@ type PointerControllerArgs = {
26
27
  minWidth: number;
27
28
  minHeight: number;
28
29
  padding?: number;
30
+ onFocus?: () => void;
29
31
  };
30
32
  export type FloatingPanelPointerController = {
31
33
  startDrag: (event: MouseEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"floating-panel.d.ts","sourceRoot":"","sources":["../floating-panel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAChC,CAAC,EAAE,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,KAAK,IAAI,CAAC;IACzC,IAAI,EAAE,MAAM,IAAI,CAAC;CACjB,CAAC;AAEF,wBAAgB,oCAAoC,CACnD,IAAI,EAAE,qBAAqB,GACzB,8BAA8B,CA+FhC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as PanelWindowControls } from './PanelWindowControls.svelte';
2
2
  export { default as PanelResizeHandle } from './PanelResizeHandle.svelte';
3
- export { createFloatingPanelPointerController, computePanelSizeFromViewport, type FloatingPanelPointerController, type FloatingPanelState, type FloatingPanelViewportSizing, } from './floating-panel.js';
3
+ export { default as SharedFloatingPanel } from './SharedFloatingPanel.svelte';
4
+ export { createFloatingPanelPointerController, computePanelSizeFromViewport, claimNextFloatingPanelZIndex, type FloatingPanelPointerController, type FloatingPanelState, type FloatingPanelViewportSizing, } from './floating-panel.js';
4
5
  export { getSectionControllerFromCoordinator, isMatchingSectionControllerLifecycleEvent, optionalIdsEqual, type SectionControllerLifecycleEventLike, type SectionControllerKeyLike, type ToolkitCoordinatorWithSectionController, } from './section-controller.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EACN,oCAAoC,EACpC,4BAA4B,EAC5B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,mCAAmC,EACnC,yCAAyC,EACzC,gBAAgB,EAChB,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAC7B,KAAK,uCAAuC,GAC5C,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EACN,oCAAoC,EACpC,4BAA4B,EAC5B,4BAA4B,EAC5B,KAAK,8BAA8B,EACnC,KAAK,kBAAkB,EACvB,KAAK,2BAA2B,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,mCAAmC,EACnC,yCAAyC,EACzC,gBAAgB,EAChB,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAC7B,KAAK,uCAAuC,GAC5C,MAAM,yBAAyB,CAAC"}