@k2b/ui 0.56.0 → 0.57.1

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.
Files changed (40) hide show
  1. package/dist/browser/actions/SplitButton.js +5 -7
  2. package/dist/browser/actions/SplitButton.js.map +1 -1
  3. package/dist/browser/actions/ViewTabs.js +6 -5
  4. package/dist/browser/actions/ViewTabs.js.map +1 -1
  5. package/dist/browser/intl/messages.js +1 -1
  6. package/dist/browser/intl/messages.js.map +1 -1
  7. package/dist/browser/layout/FloatingWindow.js +416 -122
  8. package/dist/browser/layout/FloatingWindow.js.map +1 -1
  9. package/dist/browser/layout/PersonPopover.js +406 -0
  10. package/dist/browser/layout/PersonPopover.js.map +1 -0
  11. package/dist/browser/layout/floating-window-geometry.js +58 -2
  12. package/dist/browser/layout/floating-window-geometry.js.map +1 -1
  13. package/dist/browser/layout/floating-window-messages.js +12 -0
  14. package/dist/browser/layout/floating-window-messages.js.map +1 -1
  15. package/dist/browser/layout/index.js +1 -0
  16. package/dist/browser/layout/index.js.map +1 -1
  17. package/dist/ssr/actions/SplitButton.js +5 -7
  18. package/dist/ssr/actions/SplitButton.js.map +1 -1
  19. package/dist/ssr/actions/ViewTabs.js +6 -5
  20. package/dist/ssr/actions/ViewTabs.js.map +1 -1
  21. package/dist/ssr/intl/messages.js +1 -1
  22. package/dist/ssr/intl/messages.js.map +1 -1
  23. package/dist/ssr/layout/FloatingWindow.js +286 -73
  24. package/dist/ssr/layout/FloatingWindow.js.map +1 -1
  25. package/dist/ssr/layout/PersonPopover.js +248 -0
  26. package/dist/ssr/layout/PersonPopover.js.map +1 -0
  27. package/dist/ssr/layout/floating-window-geometry.js +58 -2
  28. package/dist/ssr/layout/floating-window-geometry.js.map +1 -1
  29. package/dist/ssr/layout/floating-window-messages.js +12 -0
  30. package/dist/ssr/layout/floating-window-messages.js.map +1 -1
  31. package/dist/ssr/layout/index.js +1 -0
  32. package/dist/ssr/layout/index.js.map +1 -1
  33. package/dist/styles.css +1 -1
  34. package/dist/types/actions/SplitButton.d.ts +2 -0
  35. package/dist/types/layout/FloatingWindow.d.ts +29 -1
  36. package/dist/types/layout/PersonPopover.d.ts +70 -0
  37. package/dist/types/layout/floating-window-geometry.d.ts +20 -3
  38. package/dist/types/layout/floating-window-messages.d.ts +6 -0
  39. package/dist/types/layout/index.d.ts +3 -2
  40. package/package.json +1 -1
@@ -1,31 +1,41 @@
1
1
  import { template as _$template } from "solid-js/web";
2
2
  import { delegateEvents as _$delegateEvents } from "solid-js/web";
3
3
  import { mergeProps as _$mergeProps } from "solid-js/web";
4
- import { memo as _$memo } from "solid-js/web";
5
- import { setStyleProperty as _$setStyleProperty } from "solid-js/web";
6
- import { style as _$style } from "solid-js/web";
7
4
  import { className as _$className } from "solid-js/web";
8
- import { effect as _$effect } from "solid-js/web";
9
- import { getNextElement as _$getNextElement } from "solid-js/web";
10
- import { runHydrationEvents as _$runHydrationEvents } from "solid-js/web";
11
5
  import { getNextMarker as _$getNextMarker } from "solid-js/web";
12
6
  import { insert as _$insert } from "solid-js/web";
13
- import { createComponent as _$createComponent } from "solid-js/web";
7
+ import { addEventListener as _$addEventListener } from "solid-js/web";
14
8
  import { setAttribute as _$setAttribute } from "solid-js/web";
15
9
  import { use as _$use } from "solid-js/web";
16
- var _tmpl$ = /*#__PURE__*/_$template(`<section role=dialog aria-modal=false tabindex=-1><header><!$><!/><button type=button data-window-move class=k2b-floating-window__title><span></span></button><button type=button class=k2b-icon-button><i class="ti ti-x"aria-hidden=true></i></button></header><div class=k2b-floating-window__body></div><!$><!/>`),
17
- _tmpl$2 = /*#__PURE__*/_$template(`<i aria-hidden=true>`),
18
- _tmpl$3 = /*#__PURE__*/_$template(`<button type=button class=k2b-floating-window__resize>`),
19
- _tmpl$4 = /*#__PURE__*/_$template(`<div class=k2b-floating-window__resize aria-hidden=true>`);
20
- import { createSignal, createUniqueId, onCleanup, onMount, Show } from "solid-js";
10
+ import { createComponent as _$createComponent } from "solid-js/web";
11
+ import { setStyleProperty as _$setStyleProperty } from "solid-js/web";
12
+ import { effect as _$effect } from "solid-js/web";
13
+ import { getNextElement as _$getNextElement } from "solid-js/web";
14
+ import { runHydrationEvents as _$runHydrationEvents } from "solid-js/web";
15
+ import { memo as _$memo } from "solid-js/web";
16
+ var _tmpl$ = /*#__PURE__*/_$template(`<div class=k2b-floating-window-scrim aria-hidden=true>`),
17
+ _tmpl$2 = /*#__PURE__*/_$template(`<span class=k2b-floating-window__status>`),
18
+ _tmpl$3 = /*#__PURE__*/_$template(`<div class=k2b-floating-window__actions>`),
19
+ _tmpl$4 = /*#__PURE__*/_$template(`<i class="ti ti-minus"aria-hidden=true>`),
20
+ _tmpl$5 = /*#__PURE__*/_$template(`<i aria-hidden=true>`),
21
+ _tmpl$6 = /*#__PURE__*/_$template(`<i class="ti ti-x"aria-hidden=true>`),
22
+ _tmpl$7 = /*#__PURE__*/_$template(`<section role=dialog tabindex=-1><header><!$><!/><div class=k2b-floating-window__heading><button type=button data-window-move class=k2b-floating-window__title><span></span></button><!$><!/></div><!$><!/><div class=k2b-floating-window__controls><!$><!/><!$><!/></div></header><div class=k2b-floating-window__body></div><!$><!/>`),
23
+ _tmpl$8 = /*#__PURE__*/_$template(`<button type=button class=k2b-floating-window__resize>`),
24
+ _tmpl$9 = /*#__PURE__*/_$template(`<div class=k2b-floating-window__resize aria-hidden=true>`);
25
+ import { createEffect, createMemo, createSignal, createUniqueId, on, onCleanup, onMount, Show, untrack } from "solid-js";
21
26
  import { Portal, render } from "solid-js/web";
27
+ import { IconButton } from "../actions/Button";
22
28
  import { returnFocus, ringOnReturn } from "../internal/focus-return";
23
29
  import { getK2bPortalRoot } from "../internal/portal";
24
30
  import { RenderErrorBoundary } from "../internal/render-error";
25
31
  import { suppressTextSelection } from "../internal/text-selection";
26
- import { FLOATING_WINDOW_VIEWPORT_GAP, fitFloatingWindowRect } from "./floating-window-geometry";
32
+ import { showTruncatedTitle } from "../internal/truncated-title";
33
+ import { FLOATING_WINDOW_BAR, FLOATING_WINDOW_VIEWPORT_GAP, fitFloatingWindowRect, layoutFloatingWindowDock, maximizedFloatingWindowRect } from "./floating-window-geometry";
27
34
  import { useFloatingWindowMessages } from "./floating-window-messages";
28
35
  export { fitFloatingWindowRect } from "./floating-window-geometry";
36
+
37
+ /** `minimized` is a bar at the bottom edge with the content kept alive; `maximized` covers the area above a scrim. */
38
+
29
39
  const MOBILE_BREAKPOINT = 640;
30
40
  const FLOATING_WINDOW_LAYER_BASE = 80;
31
41
  const activeLayers = [];
@@ -49,8 +59,13 @@ const bringLayerToFront = owner => {
49
59
  activeLayers.push(owner);
50
60
  syncLayers();
51
61
  };
52
- const isTopLayer = owner => activeLayers.at(-1) === owner;
62
+
63
+ /** Every docked window of the page, in the order the windows opened, so a row never reorders when one restores. */
64
+
65
+ const [dockMembers, setDockMembers] = createSignal([]);
53
66
  const clamp = (value, min, max) => Math.min(Math.max(value, min), Math.max(min, max));
67
+ const sameRect = (a, b) => a === b || !!a && !!b && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
68
+ const tabbable = 'a[href],button:not(:disabled),input:not(:disabled):not([type="hidden"]),select:not(:disabled),textarea:not(:disabled),[contenteditable="true"],[tabindex]:not([tabindex="-1"])';
54
69
  export default function FloatingWindow(props) {
55
70
  const floatingWindowMessages = useFloatingWindowMessages();
56
71
  const minWidth = () => props.minWidth ?? 360;
@@ -60,25 +75,105 @@ export default function FloatingWindow(props) {
60
75
  const layerOwner = {
61
76
  setLayer
62
77
  };
63
- const [rect, setRect] = createSignal({
64
- x: FLOATING_WINDOW_VIEWPORT_GAP,
65
- y: FLOATING_WINDOW_VIEWPORT_GAP,
66
- width: props.initialWidth ?? 720,
67
- height: props.initialHeight ?? 640
78
+ const [ownState, setOwnState] = createSignal(untrack(() => props.defaultState ?? "normal"));
79
+ const state = () => props.state ?? ownState();
80
+ const [areaElement, setAreaElement] = createSignal();
81
+ const [bounds, setBounds] = createSignal({
82
+ x: 0,
83
+ y: 0,
84
+ width: typeof window === "undefined" ? 1024 : window.innerWidth,
85
+ height: typeof window === "undefined" ? 768 : window.innerHeight,
86
+ radius: "0px"
68
87
  });
88
+ /** The place the person or the application gave the window; unset while it places itself. */
89
+ const [placed, setPlaced] = createSignal();
69
90
  const titleId = `k2b-floating-window-${createUniqueId()}`;
70
91
  let frame;
92
+ let titleButton;
93
+ let maximizeButton;
94
+ let body;
95
+ /** The last focused element of the content, where the focus returns when the window comes back from the bar. */
96
+ let contentFocus;
71
97
  let stopPointerInteraction;
72
- const fit = value => fitFloatingWindowRect(value, minWidth(), minHeight(), {
73
- width: window.innerWidth,
74
- height: window.innerHeight
98
+ const fit = value => fitFloatingWindowRect(value, minWidth(), minHeight(), bounds());
99
+ const ownSize = () => {
100
+ const area = bounds();
101
+ return fit({
102
+ x: area.x,
103
+ y: area.y,
104
+ width: props.initialWidth ?? 720,
105
+ height: props.initialHeight ?? 640
106
+ });
107
+ };
108
+ const docked = () => state() === "minimized" || state() === "normal" && !placed() && !mobile() && props.placement === "dock";
109
+ const dockMember = {
110
+ area: areaElement,
111
+ docked,
112
+ size: () => state() === "minimized" ? FLOATING_WINDOW_BAR : ownSize()
113
+ };
114
+ const dockRect = createMemo(() => {
115
+ if (!docked()) return undefined;
116
+ const row = dockMembers().filter(member => member.area() === areaElement() && member.docked());
117
+ return layoutFloatingWindowDock(row.map(member => member.size()), bounds())[row.indexOf(dockMember)];
118
+ });
119
+ /** The window's box, or nothing while it is a full-screen sheet on a phone. */
120
+ const frameRect = createMemo(() => {
121
+ if (mobile() && state() !== "minimized") return undefined;
122
+ if (state() === "maximized") return maximizedFloatingWindowRect(bounds());
123
+ const dock = dockRect();
124
+ if (dock) return dock;
125
+ const own = placed();
126
+ if (own) return own;
127
+ const size = ownSize();
128
+ const area = bounds();
129
+ return fit({
130
+ ...size,
131
+ x: area.x + (area.width - size.width) / 2,
132
+ y: area.y + (area.height - size.height) / 2
133
+ });
134
+ }, undefined, {
135
+ equals: sameRect
75
136
  });
137
+ const modal = () => state() === "maximized" || mobile() && state() === "normal";
76
138
  const front = () => bringLayerToFront(layerOwner);
77
139
  const stopActivePointerInteraction = () => stopPointerInteraction?.();
78
140
  const close = () => {
79
141
  stopActivePointerInteraction();
80
142
  props.onClose();
81
143
  };
144
+ const commitRect = next => {
145
+ setPlaced(next);
146
+ props.onRectChange?.(next);
147
+ };
148
+ const focusInside = () => {
149
+ const active = document.activeElement;
150
+ return active instanceof HTMLElement && frame?.contains(active) ? active : undefined;
151
+ };
152
+ const changeState = next => {
153
+ const previous = state();
154
+ if (next === previous) return;
155
+ stopActivePointerInteraction();
156
+ const hadFocus = focusInside();
157
+ setOwnState(next);
158
+ props.onStateChange?.(next);
159
+ front();
160
+ // The focus follows the window: onto the bar when it minimizes, back to where it was when the content returns.
161
+ queueMicrotask(() => {
162
+ if (state() !== next) return;
163
+ if (next === "minimized") {
164
+ if (hadFocus || document.activeElement === document.body) titleButton?.focus({
165
+ preventScroll: true
166
+ });
167
+ return;
168
+ }
169
+ const current = focusInside();
170
+ if (current && current !== titleButton) return;
171
+ const target = contentFocus?.isConnected && body?.contains(contentFocus) ? contentFocus : frame;
172
+ target?.focus({
173
+ preventScroll: true
174
+ });
175
+ });
176
+ };
82
177
  const trackPointerInteraction = (start, move) => {
83
178
  stopActivePointerInteraction();
84
179
  const pointerId = start.pointerId;
@@ -97,56 +192,118 @@ export default function FloatingWindow(props) {
97
192
  if (event.pointerId === pointerId) move(event);
98
193
  };
99
194
  const onEnd = event => {
100
- if (event.pointerId === pointerId) stop();
195
+ if (event.pointerId !== pointerId) return;
196
+ stop();
197
+ const current = placed();
198
+ if (current) props.onRectChange?.(current);
101
199
  };
102
200
  stopPointerInteraction = stop;
103
201
  window.addEventListener("pointermove", onMove);
104
202
  window.addEventListener("pointerup", onEnd);
105
203
  window.addEventListener("pointercancel", onEnd);
106
204
  };
205
+ createEffect(on(() => props.rect, rect => {
206
+ if (rect) setPlaced(fit(rect));
207
+ }));
107
208
  onMount(() => {
108
209
  registerLayer(layerOwner);
109
- const viewport = () => {
110
- const compact = window.innerWidth < MOBILE_BREAKPOINT;
111
- setMobile(compact);
112
- if (!compact) setRect(current => fit(current));
210
+ setDockMembers(members => [...members, dockMember]);
211
+ let observer;
212
+ const measure = () => {
213
+ const area = props.area?.() ?? undefined;
214
+ if (area !== areaElement()) {
215
+ observer?.disconnect();
216
+ if (area) observer?.observe(area);
217
+ setAreaElement(area);
218
+ }
219
+ const box = area?.getBoundingClientRect();
220
+ const next = box ? {
221
+ x: box.left,
222
+ y: box.top,
223
+ width: box.width,
224
+ height: box.height,
225
+ radius: getComputedStyle(area).borderRadius
226
+ } : {
227
+ x: 0,
228
+ y: 0,
229
+ width: window.innerWidth,
230
+ height: window.innerHeight,
231
+ radius: "0px"
232
+ };
233
+ const current = bounds();
234
+ if (next.x !== current.x || next.y !== current.y || next.width !== current.width || next.height !== current.height) setBounds(next);
235
+ setMobile(window.innerWidth < MOBILE_BREAKPOINT);
236
+ setPlaced(rect => rect ? fit(rect) : rect);
113
237
  };
114
- setRect(current => fit({
115
- ...current,
116
- x: (window.innerWidth - current.width) / 2,
117
- y: (window.innerHeight - current.height) / 2
118
- }));
119
- viewport();
238
+ observer = typeof ResizeObserver === "function" ? new ResizeObserver(measure) : undefined;
239
+ measure();
240
+ if (!placed() && props.placement !== "dock") {
241
+ const size = ownSize();
242
+ const area = bounds();
243
+ setPlaced(fit({
244
+ ...size,
245
+ x: area.x + (area.width - size.width) / 2,
246
+ y: area.y + (area.height - size.height) / 2
247
+ }));
248
+ }
120
249
  const escape = event => {
121
- if (event.defaultPrevented || event.key !== "Escape" || !isTopLayer(layerOwner)) return;
250
+ if (event.defaultPrevented || event.key !== "Escape" || state() === "minimized") return;
251
+ if (!(event.target instanceof Node && frame?.contains(event.target))) return;
122
252
  event.preventDefault();
123
- close();
253
+ if (state() === "maximized" && !mobile()) changeState("normal");else close();
124
254
  };
125
- window.addEventListener("resize", viewport);
255
+ window.addEventListener("resize", measure);
126
256
  window.addEventListener("keydown", escape);
127
- const focus = requestAnimationFrame(() => frame?.focus());
257
+ // The content may already have placed the focus, such as an editor that opened with the window.
258
+ const focus = requestAnimationFrame(() => {
259
+ if (state() !== "minimized" && !focusInside()) frame?.focus();
260
+ });
128
261
  onCleanup(() => {
129
262
  stopActivePointerInteraction();
263
+ observer?.disconnect();
130
264
  releaseLayer(layerOwner);
265
+ setDockMembers(members => members.filter(member => member !== dockMember));
131
266
  cancelAnimationFrame(focus);
132
- window.removeEventListener("resize", viewport);
267
+ window.removeEventListener("resize", measure);
133
268
  window.removeEventListener("keydown", escape);
134
269
  });
135
270
  });
136
- const moveBy = (deltaX, deltaY) => setRect(current => fit({
137
- ...current,
138
- x: current.x + deltaX,
139
- y: current.y + deltaY
140
- }));
271
+
272
+ /** While the window covers the area, Tab cycles inside it. */
273
+ const trapTab = event => {
274
+ if (event.key !== "Tab" || !modal() || !frame) return;
275
+ const stops = [...frame.querySelectorAll(tabbable)].filter(element => element.getClientRects().length > 0);
276
+ const first = stops[0];
277
+ const last = stops.at(-1);
278
+ if (!first || !last) return;
279
+ const active = document.activeElement;
280
+ if (event.shiftKey && (active === first || active === frame)) {
281
+ last.focus();
282
+ event.preventDefault();
283
+ } else if (!event.shiftKey && active === last) {
284
+ first.focus();
285
+ event.preventDefault();
286
+ }
287
+ };
288
+ const moveBy = (deltaX, deltaY) => {
289
+ const current = frameRect();
290
+ if (current) commitRect(fit({
291
+ ...current,
292
+ x: current.x + deltaX,
293
+ y: current.y + deltaY
294
+ }));
295
+ };
296
+ const movable = () => !mobile() && state() === "normal";
141
297
  const beginMove = event => {
142
- if (mobile() || event.button !== 0 || event.target.closest("button:not([data-window-move])")) return;
143
- const origin = rect();
298
+ if (!movable() || event.button !== 0 || event.target.closest("button:not([data-window-move])")) return;
299
+ const origin = frameRect();
300
+ if (!origin) return;
144
301
  const start = {
145
302
  x: event.clientX,
146
303
  y: event.clientY
147
304
  };
148
305
  front();
149
- const move = next => setRect(fit({
306
+ const move = next => setPlaced(fit({
150
307
  ...origin,
151
308
  x: origin.x + next.clientX - start.x,
152
309
  y: origin.y + next.clientY - start.y
@@ -154,8 +311,10 @@ export default function FloatingWindow(props) {
154
311
  trackPointerInteraction(event, move);
155
312
  event.preventDefault();
156
313
  };
157
- const resizeBy = (edge, deltaX, deltaY) => {
158
- const current = rect();
314
+ const resized = (edge, deltaX, deltaY) => {
315
+ const current = frameRect();
316
+ if (!current) return undefined;
317
+ const area = bounds();
159
318
  let {
160
319
  x,
161
320
  y,
@@ -163,33 +322,34 @@ export default function FloatingWindow(props) {
163
322
  height
164
323
  } = current;
165
324
  if (edge.includes("left")) {
166
- const next = clamp(width - deltaX, minWidth(), window.innerWidth - FLOATING_WINDOW_VIEWPORT_GAP - x);
325
+ const next = clamp(width - deltaX, minWidth(), area.x + area.width - FLOATING_WINDOW_VIEWPORT_GAP - x);
167
326
  x += width - next;
168
327
  width = next;
169
328
  }
170
329
  if (edge.includes("right")) width += deltaX;
171
330
  if (edge.includes("top")) {
172
- const next = clamp(height - deltaY, minHeight(), window.innerHeight - FLOATING_WINDOW_VIEWPORT_GAP - y);
331
+ const next = clamp(height - deltaY, minHeight(), area.y + area.height - FLOATING_WINDOW_VIEWPORT_GAP - y);
173
332
  y += height - next;
174
333
  height = next;
175
334
  }
176
335
  if (edge.includes("bottom")) height += deltaY;
177
- setRect(fit({
336
+ return fit({
178
337
  x,
179
338
  y,
180
339
  width,
181
340
  height
182
- }));
341
+ });
183
342
  };
184
343
  const beginResize = (edge, event) => {
185
- if (mobile() || event.button !== 0) return;
344
+ if (!movable() || event.button !== 0) return;
186
345
  let previous = {
187
346
  x: event.clientX,
188
347
  y: event.clientY
189
348
  };
190
349
  front();
191
350
  const move = next => {
192
- resizeBy(edge, next.clientX - previous.x, next.clientY - previous.y);
351
+ const rect = resized(edge, next.clientX - previous.x, next.clientY - previous.y);
352
+ if (rect) setPlaced(rect);
193
353
  previous = {
194
354
  x: next.clientX,
195
355
  y: next.clientY
@@ -199,6 +359,7 @@ export default function FloatingWindow(props) {
199
359
  event.preventDefault();
200
360
  };
201
361
  const arrows = (event, action) => {
362
+ if (!movable()) return;
202
363
  const step = event.shiftKey ? 24 : 8;
203
364
  const delta = event.key === "ArrowLeft" ? [-step, 0] : event.key === "ArrowRight" ? [step, 0] : event.key === "ArrowUp" ? [0, -step] : event.key === "ArrowDown" ? [0, step] : undefined;
204
365
  if (!delta) return;
@@ -206,100 +367,233 @@ export default function FloatingWindow(props) {
206
367
  event.preventDefault();
207
368
  };
208
369
  const handles = [["left", "ew-resize"], ["right", "ew-resize"], ["top", "ns-resize"], ["bottom", "ns-resize"], ["top-left", "nwse-resize"], ["top-right", "nesw-resize"], ["bottom-left", "nesw-resize"], ["bottom-right", "nwse-resize"]];
209
- const view = (() => {
210
- var _el$ = _$getNextElement(_tmpl$),
211
- _el$2 = _el$.firstChild,
212
- _el$6 = _el$2.firstChild,
213
- [_el$7, _co$] = _$getNextMarker(_el$6.nextSibling),
214
- _el$3 = _el$7.nextSibling,
215
- _el$4 = _el$3.firstChild,
216
- _el$5 = _el$3.nextSibling,
217
- _el$8 = _el$2.nextSibling,
218
- _el$9 = _el$8.nextSibling,
219
- [_el$0, _co$2] = _$getNextMarker(_el$9.nextSibling);
220
- _el$.$$pointerdown = front;
370
+ const titleLabel = () => state() === "minimized" ? floatingWindowMessages().restoreWindow({
371
+ title: props.title
372
+ }) : movable() ? floatingWindowMessages().moveWindow({
373
+ title: props.title
374
+ }) : props.title;
375
+ const view = [_$createComponent(Show, {
376
+ get when() {
377
+ return _$memo(() => state() === "maximized")() && !mobile();
378
+ },
379
+ get children() {
380
+ var _el$ = _$getNextElement(_tmpl$);
381
+ _el$.$$click = () => changeState("normal");
382
+ _$effect(_p$ => {
383
+ var _v$ = `${bounds().x}px`,
384
+ _v$2 = `${bounds().y}px`,
385
+ _v$3 = `${bounds().width}px`,
386
+ _v$4 = `${bounds().height}px`,
387
+ _v$5 = bounds().radius,
388
+ _v$6 = layer();
389
+ _v$ !== _p$.e && _$setStyleProperty(_el$, "left", _p$.e = _v$);
390
+ _v$2 !== _p$.t && _$setStyleProperty(_el$, "top", _p$.t = _v$2);
391
+ _v$3 !== _p$.a && _$setStyleProperty(_el$, "width", _p$.a = _v$3);
392
+ _v$4 !== _p$.o && _$setStyleProperty(_el$, "height", _p$.o = _v$4);
393
+ _v$5 !== _p$.i && _$setStyleProperty(_el$, "border-radius", _p$.i = _v$5);
394
+ _v$6 !== _p$.n && _$setStyleProperty(_el$, "z-index", _p$.n = _v$6);
395
+ return _p$;
396
+ }, {
397
+ e: undefined,
398
+ t: undefined,
399
+ a: undefined,
400
+ o: undefined,
401
+ i: undefined,
402
+ n: undefined
403
+ });
404
+ _$runHydrationEvents();
405
+ return _el$;
406
+ }
407
+ }), (() => {
408
+ var _el$2 = _$getNextElement(_tmpl$7),
409
+ _el$3 = _el$2.firstChild,
410
+ _el$17 = _el$3.firstChild,
411
+ [_el$18, _co$4] = _$getNextMarker(_el$17.nextSibling),
412
+ _el$4 = _el$18.nextSibling,
413
+ _el$5 = _el$4.firstChild,
414
+ _el$6 = _el$5.firstChild,
415
+ _el$8 = _el$5.nextSibling,
416
+ [_el$9, _co$] = _$getNextMarker(_el$8.nextSibling),
417
+ _el$19 = _el$4.nextSibling,
418
+ [_el$20, _co$5] = _$getNextMarker(_el$19.nextSibling),
419
+ _el$1 = _el$20.nextSibling,
420
+ _el$13 = _el$1.firstChild,
421
+ [_el$14, _co$2] = _$getNextMarker(_el$13.nextSibling),
422
+ _el$15 = _el$14.nextSibling,
423
+ [_el$16, _co$3] = _$getNextMarker(_el$15.nextSibling),
424
+ _el$21 = _el$3.nextSibling,
425
+ _el$22 = _el$21.nextSibling,
426
+ [_el$23, _co$6] = _$getNextMarker(_el$22.nextSibling);
427
+ _el$2.$$focusin = event => {
428
+ if (event.target instanceof HTMLElement && body?.contains(event.target)) contentFocus = event.target;
429
+ };
430
+ _el$2.$$keydown = trapTab;
431
+ _el$2.$$pointerdown = front;
221
432
  var _ref$ = frame;
222
- typeof _ref$ === "function" ? _$use(_ref$, _el$) : frame = _el$;
223
- _$setAttribute(_el$, "aria-labelledby", titleId);
224
- _el$2.$$pointerdown = beginMove;
225
- _$insert(_el$2, _$createComponent(Show, {
433
+ typeof _ref$ === "function" ? _$use(_ref$, _el$2) : frame = _el$2;
434
+ _$setAttribute(_el$2, "aria-labelledby", titleId);
435
+ _el$3.$$pointerdown = beginMove;
436
+ _$insert(_el$3, _$createComponent(Show, {
226
437
  get when() {
227
438
  return props.icon;
228
439
  },
229
440
  children: icon => (() => {
230
- var _el$1 = _$getNextElement(_tmpl$2);
231
- _$effect(() => _$className(_el$1, icon()));
232
- return _el$1;
441
+ var _el$24 = _$getNextElement(_tmpl$5);
442
+ _$effect(() => _$className(_el$24, icon()));
443
+ return _el$24;
233
444
  })()
234
- }), _el$7, _co$);
235
- _el$3.$$keydown = event => arrows(event, moveBy);
236
- _$setAttribute(_el$4, "id", titleId);
237
- _$insert(_el$4, () => props.title);
238
- _el$5.$$click = close;
239
- _$insert(_el$8, () => props.children);
240
- _$insert(_el$, _$createComponent(Show, {
445
+ }), _el$18, _co$4);
446
+ _el$5.$$keydown = event => arrows(event, moveBy);
447
+ _el$5.$$click = () => {
448
+ if (state() === "minimized") changeState("normal");
449
+ };
450
+ var _ref$2 = titleButton;
451
+ typeof _ref$2 === "function" ? _$use(_ref$2, _el$5) : titleButton = _el$5;
452
+ _$addEventListener(_el$6, "pointerenter", showTruncatedTitle);
453
+ _$setAttribute(_el$6, "id", titleId);
454
+ _$insert(_el$6, () => props.title);
455
+ _$insert(_el$4, _$createComponent(Show, {
456
+ get when() {
457
+ return _$memo(() => props.status !== undefined)() && state() !== "minimized";
458
+ },
459
+ get children() {
460
+ var _el$7 = _$getNextElement(_tmpl$2);
461
+ _$insert(_el$7, () => props.status);
462
+ return _el$7;
463
+ }
464
+ }), _el$9, _co$);
465
+ _$insert(_el$3, _$createComponent(Show, {
466
+ get when() {
467
+ return _$memo(() => props.actions !== undefined)() && state() !== "minimized";
468
+ },
469
+ get children() {
470
+ var _el$0 = _$getNextElement(_tmpl$3);
471
+ _$insert(_el$0, () => props.actions);
472
+ return _el$0;
473
+ }
474
+ }), _el$20, _co$5);
475
+ _$insert(_el$1, _$createComponent(Show, {
241
476
  get when() {
242
477
  return !mobile();
243
478
  },
479
+ get children() {
480
+ return [_$createComponent(Show, {
481
+ get when() {
482
+ return state() !== "minimized";
483
+ },
484
+ get children() {
485
+ return _$createComponent(IconButton, {
486
+ size: "sm",
487
+ get label() {
488
+ return floatingWindowMessages().minimizeWindow;
489
+ },
490
+ onClick: () => changeState("minimized"),
491
+ get children() {
492
+ return _$getNextElement(_tmpl$4);
493
+ }
494
+ });
495
+ }
496
+ }), _$createComponent(IconButton, {
497
+ ref(r$) {
498
+ var _ref$3 = maximizeButton;
499
+ typeof _ref$3 === "function" ? _ref$3(r$) : maximizeButton = r$;
500
+ },
501
+ size: "sm",
502
+ get label() {
503
+ return _$memo(() => state() === "maximized")() ? floatingWindowMessages().restoreSize : floatingWindowMessages().maximizeWindow;
504
+ },
505
+ onClick: () => changeState(state() === "maximized" ? "normal" : "maximized"),
506
+ get children() {
507
+ var _el$11 = _$getNextElement(_tmpl$5);
508
+ _$effect(() => _$className(_el$11, state() === "maximized" ? "ti ti-arrows-diagonal-minimize-2" : "ti ti-arrows-diagonal"));
509
+ return _el$11;
510
+ }
511
+ })];
512
+ }
513
+ }), _el$14, _co$2);
514
+ _$insert(_el$1, _$createComponent(IconButton, {
515
+ size: "sm",
516
+ "class": "k2b-floating-window__close",
517
+ get label() {
518
+ return floatingWindowMessages().closeWindow;
519
+ },
520
+ onClick: close,
521
+ get children() {
522
+ return _$getNextElement(_tmpl$6);
523
+ }
524
+ }), _el$16, _co$3);
525
+ var _ref$4 = body;
526
+ typeof _ref$4 === "function" ? _$use(_ref$4, _el$21) : body = _el$21;
527
+ _$insert(_el$21, () => props.children);
528
+ _$insert(_el$2, _$createComponent(Show, {
529
+ get when() {
530
+ return movable();
531
+ },
244
532
  get children() {
245
533
  return handles.map(([edge, cursor]) => edge === "bottom-right" ? (() => {
246
- var _el$10 = _$getNextElement(_tmpl$3);
247
- _el$10.$$keydown = event => arrows(event, (x, y) => resizeBy(edge, x, y));
248
- _el$10.$$pointerdown = event => beginResize(edge, event);
249
- _$setAttribute(_el$10, "data-edge", edge);
250
- _$setStyleProperty(_el$10, "cursor", cursor);
251
- _$effect(() => _$setAttribute(_el$10, "aria-label", floatingWindowMessages().resizeWindow));
534
+ var _el$25 = _$getNextElement(_tmpl$8);
535
+ _el$25.$$keydown = event => arrows(event, (x, y) => {
536
+ const rect = resized(edge, x, y);
537
+ if (rect) commitRect(rect);
538
+ });
539
+ _el$25.$$pointerdown = event => beginResize(edge, event);
540
+ _$setAttribute(_el$25, "data-edge", edge);
541
+ _$setStyleProperty(_el$25, "cursor", cursor);
542
+ _$effect(() => _$setAttribute(_el$25, "aria-label", floatingWindowMessages().resizeWindow));
252
543
  _$runHydrationEvents();
253
- return _el$10;
544
+ return _el$25;
254
545
  })() : // Cloud exposes a single keyboard-resizable corner; the remaining
255
546
  // edges stay pointer-only so the window adds one tab stop, not eight.
256
547
  (() => {
257
- var _el$11 = _$getNextElement(_tmpl$4);
258
- _el$11.$$pointerdown = event => beginResize(edge, event);
259
- _$setAttribute(_el$11, "data-edge", edge);
260
- _$setStyleProperty(_el$11, "cursor", cursor);
548
+ var _el$26 = _$getNextElement(_tmpl$9);
549
+ _el$26.$$pointerdown = event => beginResize(edge, event);
550
+ _$setAttribute(_el$26, "data-edge", edge);
551
+ _$setStyleProperty(_el$26, "cursor", cursor);
261
552
  _$runHydrationEvents();
262
- return _el$11;
553
+ return _el$26;
263
554
  })());
264
555
  }
265
- }), _el$0, _co$2);
556
+ }), _el$23, _co$6);
266
557
  _$effect(_p$ => {
267
- var _v$ = `k2b-floating-window ${props.class ?? ""}`,
268
- _v$2 = mobile() ? "true" : undefined,
269
- _v$3 = mobile() ? {
270
- "--k2b-window-accent": props.accent,
271
- inset: "0.5rem",
272
- width: "auto",
273
- height: "auto",
274
- "z-index": layer()
275
- } : {
276
- "--k2b-window-accent": props.accent,
277
- left: `${rect().x}px`,
278
- top: `${rect().y}px`,
279
- width: `${rect().width}px`,
280
- height: `${rect().height}px`,
281
- "z-index": layer()
282
- },
283
- _v$4 = floatingWindowMessages().moveWindow({
284
- title: props.title
285
- }),
286
- _v$5 = floatingWindowMessages().closeWindow;
287
- _v$ !== _p$.e && _$className(_el$, _p$.e = _v$);
288
- _v$2 !== _p$.t && _$setAttribute(_el$, "data-mobile", _p$.t = _v$2);
289
- _p$.a = _$style(_el$, _v$3, _p$.a);
290
- _v$4 !== _p$.o && _$setAttribute(_el$3, "aria-label", _p$.o = _v$4);
291
- _v$5 !== _p$.i && _$setAttribute(_el$5, "aria-label", _p$.i = _v$5);
558
+ var _v$7 = `k2b-floating-window ${props.class ?? ""}`,
559
+ _v$8 = mobile() ? "true" : undefined,
560
+ _v$9 = state(),
561
+ _v$0 = props.accent,
562
+ _v$1 = frameRect() ? `${frameRect().x}px` : undefined,
563
+ _v$10 = frameRect() ? `${frameRect().y}px` : undefined,
564
+ _v$11 = frameRect() ? `${frameRect().width}px` : undefined,
565
+ _v$12 = frameRect() ? `${frameRect().height}px` : undefined,
566
+ _v$13 = layer(),
567
+ _v$14 = modal() ? "true" : "false",
568
+ _v$15 = titleLabel();
569
+ _v$7 !== _p$.e && _$className(_el$2, _p$.e = _v$7);
570
+ _v$8 !== _p$.t && _$setAttribute(_el$2, "data-mobile", _p$.t = _v$8);
571
+ _v$9 !== _p$.a && _$setAttribute(_el$2, "data-state", _p$.a = _v$9);
572
+ _v$0 !== _p$.o && _$setStyleProperty(_el$2, "--k2b-window-accent", _p$.o = _v$0);
573
+ _v$1 !== _p$.i && _$setStyleProperty(_el$2, "left", _p$.i = _v$1);
574
+ _v$10 !== _p$.n && _$setStyleProperty(_el$2, "top", _p$.n = _v$10);
575
+ _v$11 !== _p$.s && _$setStyleProperty(_el$2, "width", _p$.s = _v$11);
576
+ _v$12 !== _p$.h && _$setStyleProperty(_el$2, "height", _p$.h = _v$12);
577
+ _v$13 !== _p$.r && _$setStyleProperty(_el$2, "z-index", _p$.r = _v$13);
578
+ _v$14 !== _p$.d && _$setAttribute(_el$2, "aria-modal", _p$.d = _v$14);
579
+ _v$15 !== _p$.l && _$setAttribute(_el$5, "aria-label", _p$.l = _v$15);
292
580
  return _p$;
293
581
  }, {
294
582
  e: undefined,
295
583
  t: undefined,
296
584
  a: undefined,
297
585
  o: undefined,
298
- i: undefined
586
+ i: undefined,
587
+ n: undefined,
588
+ s: undefined,
589
+ h: undefined,
590
+ r: undefined,
591
+ d: undefined,
592
+ l: undefined
299
593
  });
300
594
  _$runHydrationEvents();
301
- return _el$;
302
- })();
595
+ return _el$2;
596
+ })()];
303
597
  return _$createComponent(Portal, {
304
598
  get mount() {
305
599
  return typeof document === "undefined" ? undefined : getK2bPortalRoot(props.resolveScope?.());
@@ -336,5 +630,5 @@ export const openFloatingWindow = (view, options) => {
336
630
  })), owner);
337
631
  return close;
338
632
  };
339
- _$delegateEvents(["pointerdown", "keydown", "click"]);
633
+ _$delegateEvents(["click", "pointerdown", "keydown", "focusin"]);
340
634
  //# sourceMappingURL=FloatingWindow.js.map