@objectifthunes/whiteboard 0.2.1 → 0.2.2

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/dist/index.d.ts CHANGED
@@ -213,7 +213,7 @@ export declare function Inline({ as, justify, className, ...props }: InlineProps
213
213
 
214
214
  declare interface InlineProps extends HTMLAttributes<HTMLElement> {
215
215
  as?: ElementType;
216
- justify?: 'start' | 'between';
216
+ justify?: 'start' | 'between' | 'end';
217
217
  }
218
218
 
219
219
  export declare const Input: ForwardRefExoticComponent<InputProps & RefAttributes<HTMLInputElement>>;
@@ -278,13 +278,9 @@ export declare function MutedText({ as, size, className, ...props }: TypographyP
278
278
 
279
279
  declare type MutedTextSize = 'xs' | 'sm' | 'md';
280
280
 
281
- export declare function PageCard({ children }: {
282
- children: ReactNode;
283
- }): JSX_2.Element;
281
+ export declare function PageCard({ children, className, ...props }: HTMLAttributes<HTMLDivElement>): JSX_2.Element;
284
282
 
285
- export declare function PageShell({ children }: {
286
- children: ReactNode;
287
- }): JSX_2.Element;
283
+ export declare function PageShell({ children, className, ...props }: HTMLAttributes<HTMLElement>): JSX_2.Element;
288
284
 
289
285
  export declare function PageTitle({ as, className, ...props }: TypographyProps): ReactElement<any, string | JSXElementConstructor<any>>;
290
286
 
package/dist/index.js CHANGED
@@ -97,10 +97,10 @@ function ue(e) {
97
97
  }
98
98
  function Ne(e, t, r = 60) {
99
99
  if (e.size === 0) return null;
100
- let s = 1 / 0, i = 1 / 0, u = -1 / 0, w = -1 / 0;
100
+ let s = 1 / 0, a = 1 / 0, u = -1 / 0, w = -1 / 0;
101
101
  for (const v of e.values())
102
- s = Math.min(s, v.x), i = Math.min(i, v.y), u = Math.max(u, v.x + v.width), w = Math.max(w, v.y + v.height);
103
- const f = u - s + r * 2, m = w - i + r * 2, g = t.width || window.innerWidth, h = t.height || window.innerHeight, M = Math.min(g / f, h / m, 1.5), k = (s + u) / 2, _ = (i + w) / 2;
102
+ s = Math.min(s, v.x), a = Math.min(a, v.y), u = Math.max(u, v.x + v.width), w = Math.max(w, v.y + v.height);
103
+ const f = u - s + r * 2, m = w - a + r * 2, g = t.width || window.innerWidth, h = t.height || window.innerHeight, M = Math.min(g / f, h / m, 1.5), k = (s + u) / 2, _ = (a + w) / 2;
104
104
  return {
105
105
  scale: Math.min(3, Math.max(0.2, M)),
106
106
  offset: {
@@ -110,15 +110,15 @@ function Ne(e, t, r = 60) {
110
110
  };
111
111
  }
112
112
  function Ve(e, t, r = 40, s = 1.5) {
113
- const i = t.width || window.innerWidth, u = t.height || window.innerHeight, w = Math.max(1, e.width), f = Math.max(1, e.height), m = Math.min(
114
- (i - r * 2) / w,
113
+ const a = t.width || window.innerWidth, u = t.height || window.innerHeight, w = Math.max(1, e.width), f = Math.max(1, e.height), m = Math.min(
114
+ (a - r * 2) / w,
115
115
  (u - r * 2) / f,
116
116
  s
117
117
  ), g = Math.min(3, Math.max(0.2, m));
118
118
  return {
119
119
  scale: g,
120
120
  offset: {
121
- x: i / 2 - (e.x + w / 2) * g,
121
+ x: a / 2 - (e.x + w / 2) * g,
122
122
  y: u / 2 - (e.y + f / 2) * g
123
123
  }
124
124
  };
@@ -137,7 +137,7 @@ const p = Xe((e, t) => ({
137
137
  setViewportSize: (r) => e({ viewportSize: r }),
138
138
  setSnapToGrid: (r) => e((s) => ({ snapToGrid: typeof r == "function" ? r(s.snapToGrid) : r })),
139
139
  register: (r, s) => {
140
- t().panels.set(r, s), e((i) => ({ registryVersion: i.registryVersion + 1 }));
140
+ t().panels.set(r, s), e((a) => ({ registryVersion: a.registryVersion + 1 }));
141
141
  },
142
142
  unregister: (r) => {
143
143
  t().panels.delete(r), e((s) => ({ registryVersion: s.registryVersion + 1 }));
@@ -149,13 +149,13 @@ const p = Xe((e, t) => ({
149
149
  t().resetFns.delete(r);
150
150
  },
151
151
  fitToContent: () => {
152
- const { panels: r, viewportSize: s } = t(), i = Ne(r, s);
153
- i && e({ scale: i.scale, offset: i.offset });
152
+ const { panels: r, viewportSize: s } = t(), a = Ne(r, s);
153
+ a && e({ scale: a.scale, offset: a.offset });
154
154
  },
155
155
  focusPanel: (r, s) => {
156
- const { viewportSize: i } = t(), u = Ve(
156
+ const { viewportSize: a } = t(), u = Ve(
157
157
  r,
158
- i,
158
+ a,
159
159
  (s == null ? void 0 : s.padding) ?? 40,
160
160
  (s == null ? void 0 : s.maxScale) ?? 1.5
161
161
  );
@@ -164,7 +164,7 @@ const p = Xe((e, t) => ({
164
164
  resetWidgets: () => {
165
165
  for (const s of t().resetFns.values()) s();
166
166
  const r = (s = 0) => {
167
- const { panels: i, viewportSize: u } = t(), w = Ne(i, u);
167
+ const { panels: a, viewportSize: u } = t(), w = Ne(a, u);
168
168
  if (w) {
169
169
  e({ scale: w.scale, offset: w.offset });
170
170
  return;
@@ -184,7 +184,7 @@ const p = Xe((e, t) => ({
184
184
  })
185
185
  }));
186
186
  function je({ extraActions: e }) {
187
- const t = p((h) => h.scale), r = p((h) => h.viewportSize), s = p((h) => h.snapToGrid), i = p((h) => h.setScale), u = p((h) => h.setOffset), w = p((h) => h.setSnapToGrid), f = p((h) => h.fitToContent), m = p((h) => h.resetWidgets);
187
+ const t = p((h) => h.scale), r = p((h) => h.viewportSize), s = p((h) => h.snapToGrid), a = p((h) => h.setScale), u = p((h) => h.setOffset), w = p((h) => h.setSnapToGrid), f = p((h) => h.fitToContent), m = p((h) => h.resetWidgets);
188
188
  X(() => {
189
189
  s && window.dispatchEvent(new Event("whiteboard-snap-now"));
190
190
  }, [s]);
@@ -193,7 +193,7 @@ function je({ extraActions: e }) {
193
193
  u((P) => ({
194
194
  x: _ - (_ - P.x) * k,
195
195
  y: v - (v - P.y) * k
196
- })), i(M);
196
+ })), a(M);
197
197
  };
198
198
  return /* @__PURE__ */ d(
199
199
  "div",
@@ -228,32 +228,32 @@ function je({ extraActions: e }) {
228
228
  }
229
229
  const ee = 200, te = 150, de = 40, xe = 1;
230
230
  function Ue({ loading: e = !1 }) {
231
- p((a) => a.registryVersion);
232
- const t = p((a) => a.offset), r = p((a) => a.scale), s = p((a) => a.viewportSize), i = p((a) => a.panels), u = p((a) => a.setOffset), w = p((a) => a.setScale), f = p((a) => a.focusPanel), m = S(null), g = S(!1), h = S(null), k = Array.from(i.entries()).filter(([, a]) => Number.isFinite(a.width) && Number.isFinite(a.height)), _ = k.map(([, a]) => a);
231
+ p((o) => o.registryVersion);
232
+ const t = p((o) => o.offset), r = p((o) => o.scale), s = p((o) => o.viewportSize), a = p((o) => o.panels), u = p((o) => o.setOffset), w = p((o) => o.setScale), f = p((o) => o.focusPanel), m = S(null), g = S(!1), h = S(null), k = Array.from(a.entries()).filter(([, o]) => Number.isFinite(o.width) && Number.isFinite(o.height)), _ = k.map(([, o]) => o);
233
233
  if (e || _.length === 0)
234
234
  return /* @__PURE__ */ n("div", { className: "minimap minimap--loading", style: { width: ee, height: te }, children: /* @__PURE__ */ n("div", { className: "minimap__loading", children: /* @__PURE__ */ n(fe, { size: 14, className: "icon-spin" }) }) });
235
235
  const v = s.width || window.innerWidth, P = s.height || window.innerHeight, L = v / r, B = P / r, $ = -t.x / r, V = -t.y / r;
236
236
  let F = 1 / 0, c = 1 / 0, R = -1 / 0, W = -1 / 0;
237
- for (const a of _)
238
- F = Math.min(F, a.x), c = Math.min(c, a.y), R = Math.max(R, a.x + a.width), W = Math.max(W, a.y + a.height);
237
+ for (const o of _)
238
+ F = Math.min(F, o.x), c = Math.min(c, o.y), R = Math.max(R, o.x + o.width), W = Math.max(W, o.y + o.height);
239
239
  F -= de, c -= de, R += de, W += de;
240
- const C = Math.max(xe, R - F), O = Math.max(xe, W - c), z = Math.min(ee / C, te / O), E = C * z, U = O * z, Z = (ee - E) / 2, D = (te - U) / 2, q = (a) => Z + (a - F) * z, j = (a) => D + (a - c) * z, Q = (a, y) => {
240
+ const C = Math.max(xe, R - F), O = Math.max(xe, W - c), z = Math.min(ee / C, te / O), E = C * z, U = O * z, Z = (ee - E) / 2, D = (te - U) / 2, q = (o) => Z + (o - F) * z, j = (o) => D + (o - c) * z, Q = (o, y) => {
241
241
  if (!m.current) return;
242
- const x = m.current.getBoundingClientRect(), G = Math.min(ee, Math.max(0, a - x.left)), A = Math.min(te, Math.max(0, y - x.top)), ae = Math.min(E + Z, Math.max(Z, G)), ie = Math.min(U + D, Math.max(D, A)), oe = (ae - Z) / z + F, ce = (ie - D) / z + c;
243
- return { worldX: oe, worldY: ce };
244
- }, K = (a, y, x) => {
242
+ const x = m.current.getBoundingClientRect(), G = Math.min(ee, Math.max(0, o - x.left)), A = Math.min(te, Math.max(0, y - x.top)), ae = Math.min(E + Z, Math.max(Z, G)), oe = Math.min(U + D, Math.max(D, A)), ie = (ae - Z) / z + F, ce = (oe - D) / z + c;
243
+ return { worldX: ie, worldY: ce };
244
+ }, K = (o, y, x) => {
245
245
  const G = Math.min(3, Math.max(0.2, x));
246
246
  w(G), u({
247
- x: v / 2 - a * G,
247
+ x: v / 2 - o * G,
248
248
  y: P / 2 - y * G
249
249
  });
250
- }, se = (a, y) => {
251
- const x = Q(a, y);
250
+ }, se = (o, y) => {
251
+ const x = Q(o, y);
252
252
  x && K(x.worldX, x.worldY, r);
253
- }, be = (a) => {
254
- a.stopPropagation(), a.preventDefault(), g.current = !0, a.currentTarget.setPointerCapture(a.pointerId), se(a.clientX, a.clientY);
255
- }, o = (a) => {
256
- g.current && se(a.clientX, a.clientY);
253
+ }, be = (o) => {
254
+ o.stopPropagation(), o.preventDefault(), g.current = !0, o.currentTarget.setPointerCapture(o.pointerId), se(o.clientX, o.clientY);
255
+ }, i = (o) => {
256
+ g.current && se(o.clientX, o.clientY);
257
257
  }, b = () => {
258
258
  g.current = !1;
259
259
  };
@@ -262,14 +262,14 @@ function Ue({ loading: e = !1 }) {
262
262
  {
263
263
  ref: m,
264
264
  onPointerDown: be,
265
- onPointerMove: o,
265
+ onPointerMove: i,
266
266
  onPointerUp: b,
267
267
  onPointerCancel: b,
268
- onWheel: (a) => {
269
- a.preventDefault(), a.stopPropagation();
270
- const y = Q(a.clientX, a.clientY);
268
+ onWheel: (o) => {
269
+ o.preventDefault(), o.stopPropagation();
270
+ const y = Q(o.clientX, o.clientY);
271
271
  if (!y) return;
272
- const x = a.deltaY > 0 ? 0.9 : 1.1;
272
+ const x = o.deltaY > 0 ? 0.9 : 1.1;
273
273
  K(y.worldX, y.worldY, r * x);
274
274
  },
275
275
  className: "minimap",
@@ -278,7 +278,7 @@ function Ue({ loading: e = !1 }) {
278
278
  height: te
279
279
  },
280
280
  children: [
281
- k.map(([a, y]) => /* @__PURE__ */ n(
281
+ k.map(([o, y]) => /* @__PURE__ */ n(
282
282
  "div",
283
283
  {
284
284
  className: "minimap__panel",
@@ -288,11 +288,11 @@ function Ue({ loading: e = !1 }) {
288
288
  onPointerUp: (x) => {
289
289
  x.stopPropagation();
290
290
  const G = Date.now(), A = h.current;
291
- if (A && A.id === a && G - A.time < 300) {
291
+ if (A && A.id === o && G - A.time < 300) {
292
292
  x.preventDefault(), f(y, { padding: y.focusPadding, maxScale: y.focusMaxScale }), h.current = null;
293
293
  return;
294
294
  }
295
- h.current = { id: a, time: G };
295
+ h.current = { id: o, time: G };
296
296
  },
297
297
  onDoubleClick: (x) => {
298
298
  x.preventDefault(), x.stopPropagation(), f(y, { padding: y.focusPadding, maxScale: y.focusMaxScale });
@@ -304,7 +304,7 @@ function Ue({ loading: e = !1 }) {
304
304
  height: Math.max(1, y.height * z)
305
305
  }
306
306
  },
307
- a
307
+ o
308
308
  )),
309
309
  /* @__PURE__ */ n(
310
310
  "div",
@@ -323,7 +323,7 @@ function Ue({ loading: e = !1 }) {
323
323
  );
324
324
  }
325
325
  function xt({ children: e, showMinimap: t = !0, minimapLoading: r = !1, extraActions: s }) {
326
- const i = p((c) => c.offset), u = p((c) => c.scale), w = p((c) => c.registryVersion), f = p((c) => c.viewportSize), m = p((c) => c.setOffset), g = p((c) => c.setScale), h = p((c) => c.setViewportSize), M = S(null), k = S(!1), _ = S({ x: 0, y: 0 }), v = S(null), P = S(u), L = S(!1);
326
+ const a = p((c) => c.offset), u = p((c) => c.scale), w = p((c) => c.registryVersion), f = p((c) => c.viewportSize), m = p((c) => c.setOffset), g = p((c) => c.setScale), h = p((c) => c.setViewportSize), M = S(null), k = S(!1), _ = S({ x: 0, y: 0 }), v = S(null), P = S(u), L = S(!1);
327
327
  X(() => () => {
328
328
  p.getState().resetSession();
329
329
  }, []), X(() => {
@@ -384,7 +384,7 @@ function xt({ children: e, showMinimap: t = !0, minimapLoading: r = !1, extraAct
384
384
  "div",
385
385
  {
386
386
  className: "whiteboard-canvas",
387
- style: { transform: `translate(${i.x}px, ${i.y}px) scale(${u})` },
387
+ style: { transform: `translate(${a.x}px, ${a.y}px) scale(${u})` },
388
388
  children: [
389
389
  /* @__PURE__ */ n("div", { className: "whiteboard-grid", "aria-hidden": !0 }),
390
390
  e
@@ -401,7 +401,7 @@ const St = Te(function({
401
401
  title: t,
402
402
  defaultPosition: r,
403
403
  width: s = 300,
404
- className: i,
404
+ className: a,
405
405
  trackRect: u,
406
406
  focusable: w,
407
407
  focusPadding: f = 40,
@@ -409,74 +409,74 @@ const St = Te(function({
409
409
  headerActions: g,
410
410
  children: h
411
411
  }) {
412
- const M = Re(), [k, _] = Se(r), v = S(!1), P = S(k), L = S(null), B = S(null), $ = p((o) => o.scale), V = p((o) => o.snapToGrid), F = p((o) => o.snapGridSize), c = p((o) => o.register), R = p((o) => o.unregister), W = p((o) => o.registerReset), C = p((o) => o.unregisterReset), O = p((o) => o.focusPanel), z = S($), E = S(!1), U = S(20), Z = S(r), D = S(null), q = S(null);
412
+ const M = Re(), [k, _] = Se(r), v = S(!1), P = S(k), L = S(null), B = S(null), $ = p((i) => i.scale), V = p((i) => i.snapToGrid), F = p((i) => i.snapGridSize), c = p((i) => i.register), R = p((i) => i.unregister), W = p((i) => i.registerReset), C = p((i) => i.unregisterReset), O = p((i) => i.focusPanel), z = S($), E = S(!1), U = S(20), Z = S(r), D = S(null), q = S(null);
413
413
  X(() => {
414
414
  z.current = $;
415
415
  }, [$]), X(() => {
416
416
  E.current = V, U.current = F;
417
417
  }, [V, F]), X(() => {
418
- const o = () => {
418
+ const i = () => {
419
419
  const b = U.current;
420
420
  _((N) => {
421
- const a = {
421
+ const o = {
422
422
  x: Math.round(N.x / b) * b,
423
423
  y: Math.round(N.y / b) * b
424
424
  };
425
- return a.x === N.x && a.y === N.y ? N : a;
425
+ return o.x === N.x && o.y === N.y ? N : o;
426
426
  });
427
427
  };
428
- return window.addEventListener("whiteboard-snap-now", o), () => window.removeEventListener("whiteboard-snap-now", o);
428
+ return window.addEventListener("whiteboard-snap-now", i), () => window.removeEventListener("whiteboard-snap-now", i);
429
429
  }, []), X(() => {
430
430
  P.current = k;
431
431
  }, [k]);
432
432
  const j = H(() => {
433
- const o = L.current;
434
- if (!o) return;
433
+ const i = L.current;
434
+ if (!i) return;
435
435
  const b = {
436
436
  x: P.current.x,
437
437
  y: P.current.y,
438
- width: o.offsetWidth,
439
- height: o.offsetHeight,
438
+ width: i.offsetWidth,
439
+ height: i.offsetHeight,
440
440
  focusPadding: f,
441
441
  focusMaxScale: m
442
442
  }, N = B.current;
443
443
  N && N.x === b.x && N.y === b.y && N.width === b.width && N.height === b.height && N.focusPadding === b.focusPadding && N.focusMaxScale === b.focusMaxScale || (B.current = b, c(M, b), u && (u.current = b));
444
444
  }, [m, f, M, c, u]), Q = H(() => {
445
- const o = L.current;
446
- return o ? {
445
+ const i = L.current;
446
+ return i ? {
447
447
  x: P.current.x,
448
448
  y: P.current.y,
449
- width: o.offsetWidth,
450
- height: o.offsetHeight,
449
+ width: i.offsetWidth,
450
+ height: i.offsetHeight,
451
451
  focusPadding: f,
452
452
  focusMaxScale: m
453
453
  } : null;
454
454
  }, [m, f]), K = H(() => {
455
- const o = Q();
456
- o && O(o, { padding: f, maxScale: m });
455
+ const i = Q();
456
+ i && O(i, { padding: f, maxScale: m });
457
457
  }, [O, f, m, Q]);
458
458
  X(() => (W(M, () => _(Z.current)), () => {
459
- var o;
460
- (o = D.current) == null || o.call(D), R(M), C(M), B.current = null;
459
+ var i;
460
+ (i = D.current) == null || i.call(D), R(M), C(M), B.current = null;
461
461
  }), [M, W, R, C]), We(() => {
462
462
  j();
463
463
  }, [k.x, k.y, s, j]), X(() => {
464
- const o = L.current;
465
- if (!o || typeof ResizeObserver > "u") return;
464
+ const i = L.current;
465
+ if (!i || typeof ResizeObserver > "u") return;
466
466
  const b = new ResizeObserver(() => {
467
467
  j();
468
468
  });
469
- return b.observe(o), () => b.disconnect();
469
+ return b.observe(i), () => b.disconnect();
470
470
  }, [j]);
471
- const se = H((o) => {
471
+ const se = H((i) => {
472
472
  var ae;
473
- if (o.button !== 0) return;
473
+ if (i.button !== 0) return;
474
474
  v.current = !0;
475
- const b = o.clientX, N = o.clientY, a = P.current.x, y = P.current.y, x = z.current;
476
- o.preventDefault(), o.stopPropagation(), o.target.setPointerCapture(o.pointerId);
477
- const G = (ie) => {
475
+ const b = i.clientX, N = i.clientY, o = P.current.x, y = P.current.y, x = z.current;
476
+ i.preventDefault(), i.stopPropagation(), i.target.setPointerCapture(i.pointerId);
477
+ const G = (oe) => {
478
478
  if (!v.current) return;
479
- const oe = a + (ie.clientX - b) / x, ce = y + (ie.clientY - N) / x, le = U.current, Ce = E.current ? Math.round(oe / le) * le : oe, ze = E.current ? Math.round(ce / le) * le : ce;
479
+ const ie = o + (oe.clientX - b) / x, ce = y + (oe.clientY - N) / x, le = U.current, Ce = E.current ? Math.round(ie / le) * le : ie, ze = E.current ? Math.round(ce / le) * le : ce;
480
480
  _({
481
481
  x: Ce,
482
482
  y: ze
@@ -485,29 +485,29 @@ const St = Te(function({
485
485
  v.current = !1, window.removeEventListener("pointermove", G), window.removeEventListener("pointerup", A), D.current = null;
486
486
  };
487
487
  (ae = D.current) == null || ae.call(D), window.addEventListener("pointermove", G), window.addEventListener("pointerup", A), D.current = A;
488
- }, []), be = i ? `floating-panel ${i}` : "floating-panel";
488
+ }, []), be = a ? `floating-panel ${a}` : "floating-panel";
489
489
  return /* @__PURE__ */ d(
490
490
  "div",
491
491
  {
492
492
  ref: L,
493
493
  className: be,
494
494
  style: { left: k.x, top: k.y, width: s },
495
- onPointerDown: (o) => o.stopPropagation(),
496
- onPointerUp: (o) => {
495
+ onPointerDown: (i) => i.stopPropagation(),
496
+ onPointerUp: (i) => {
497
497
  if (v.current) return;
498
498
  const b = Date.now(), N = q.current;
499
499
  if (N && b - N.time < 300) {
500
- const a = o.clientX - N.x, y = o.clientY - N.y;
501
- if (a * a + y * y < 100) {
502
- o.stopPropagation(), K(), q.current = null;
500
+ const o = i.clientX - N.x, y = i.clientY - N.y;
501
+ if (o * o + y * y < 100) {
502
+ i.stopPropagation(), K(), q.current = null;
503
503
  return;
504
504
  }
505
505
  }
506
- q.current = { time: b, x: o.clientX, y: o.clientY };
506
+ q.current = { time: b, x: i.clientX, y: i.clientY };
507
507
  },
508
- onWheel: (o) => o.stopPropagation(),
509
- onDoubleClick: (o) => {
510
- o.stopPropagation(), K();
508
+ onWheel: (i) => i.stopPropagation(),
509
+ onDoubleClick: (i) => {
510
+ i.stopPropagation(), K();
511
511
  },
512
512
  children: [
513
513
  /* @__PURE__ */ d("div", { onPointerDown: se, className: "floating-panel__header", children: [
@@ -519,7 +519,7 @@ const St = Te(function({
519
519
  type: "button",
520
520
  className: "wb-btn wb-btn--secondary wb-btn--icon-only floating-panel__focus",
521
521
  onClick: K,
522
- onPointerDown: (o) => o.stopPropagation(),
522
+ onPointerDown: (i) => i.stopPropagation(),
523
523
  title: "Focus on this panel",
524
524
  "aria-label": "Focus on this panel",
525
525
  children: /* @__PURE__ */ n(Ae, { size: 14 })
@@ -542,7 +542,7 @@ function _t({
542
542
  title: t,
543
543
  message: r,
544
544
  onConfirm: s,
545
- onCancel: i,
545
+ onCancel: a,
546
546
  confirmLabel: u = "Confirm",
547
547
  loading: w,
548
548
  error: f
@@ -550,11 +550,11 @@ function _t({
550
550
  return X(() => {
551
551
  if (!e) return;
552
552
  const m = (g) => {
553
- g.key === "Escape" && i();
553
+ g.key === "Escape" && a();
554
554
  };
555
555
  return window.addEventListener("keydown", m), () => window.removeEventListener("keydown", m);
556
- }, [e, i]), !e || typeof document > "u" ? null : Ye(
557
- /* @__PURE__ */ n("div", { className: "confirm-modal-overlay", onMouseDown: i, children: /* @__PURE__ */ d(
556
+ }, [e, a]), !e || typeof document > "u" ? null : Ye(
557
+ /* @__PURE__ */ n("div", { className: "confirm-modal-overlay", onMouseDown: a, children: /* @__PURE__ */ d(
558
558
  "div",
559
559
  {
560
560
  className: "confirm-modal",
@@ -568,12 +568,12 @@ function _t({
568
568
  /* @__PURE__ */ n(Oe, { size: 16 }),
569
569
  t
570
570
  ] }),
571
- /* @__PURE__ */ n("button", { type: "button", className: "wb-btn wb-btn--secondary wb-btn--icon-only", onClick: i, "aria-label": "Close dialog", children: /* @__PURE__ */ n(Me, { size: 14 }) })
571
+ /* @__PURE__ */ n("button", { type: "button", className: "wb-btn wb-btn--secondary wb-btn--icon-only", onClick: a, "aria-label": "Close dialog", children: /* @__PURE__ */ n(Me, { size: 14 }) })
572
572
  ] }),
573
573
  /* @__PURE__ */ n("p", { className: "confirm-modal__message", children: r }),
574
574
  f && /* @__PURE__ */ n("div", { className: "wb-alert wb-alert--error", children: f }),
575
575
  /* @__PURE__ */ d("div", { className: "wb-btn-row", children: [
576
- /* @__PURE__ */ n("button", { type: "button", className: "wb-btn wb-btn--secondary", onClick: i, children: "Cancel" }),
576
+ /* @__PURE__ */ n("button", { type: "button", className: "wb-btn wb-btn--secondary", onClick: a, children: "Cancel" }),
577
577
  /* @__PURE__ */ n("button", { type: "button", className: "wb-btn wb-btn--danger", onClick: s, disabled: w, children: w ? "Deleting..." : /* @__PURE__ */ d(re, { children: [
578
578
  /* @__PURE__ */ n(He, { size: 14 }),
579
579
  u
@@ -613,7 +613,7 @@ function Ct({
613
613
  y: r = 40,
614
614
  gap: s = 20
615
615
  }) {
616
- const i = ye(() => {
616
+ const a = ye(() => {
617
617
  const f = {};
618
618
  for (const [m, g] of Object.entries(e))
619
619
  f[m] = ue(g);
@@ -628,11 +628,11 @@ function Ct({
628
628
  ), w = ye(() => {
629
629
  const f = {};
630
630
  let m = u.startX;
631
- for (const [g, h] of Object.entries(i))
631
+ for (const [g, h] of Object.entries(a))
632
632
  f[g] = { x: m, y: u.y }, m += h + u.gap;
633
633
  return f;
634
- }, [u.gap, u.startX, u.y, i]);
635
- return { layout: u, panelWidth: i, positions: w };
634
+ }, [u.gap, u.startX, u.y, a]);
635
+ return { layout: u, panelWidth: a, positions: w };
636
636
  }
637
637
  function l(...e) {
638
638
  return e.filter(Boolean).join(" ");
@@ -654,7 +654,7 @@ const qe = {
654
654
  variant: t = "primary",
655
655
  fullWidth: r = !1,
656
656
  iconOnly: s = !1,
657
- loading: i = !1,
657
+ loading: a = !1,
658
658
  disabled: u,
659
659
  className: w,
660
660
  children: f,
@@ -666,9 +666,9 @@ const qe = {
666
666
  {
667
667
  ref: h,
668
668
  className: l(qe[t], r && "full-width-btn", s && "icon-only-btn", w),
669
- disabled: u || i,
669
+ disabled: u || a,
670
670
  ...g,
671
- children: i ? /* @__PURE__ */ d(re, { children: [
671
+ children: a ? /* @__PURE__ */ d(re, { children: [
672
672
  /* @__PURE__ */ n(fe, { size: 14, className: "icon-spin" }),
673
673
  m || f
674
674
  ] }) : f
@@ -762,25 +762,25 @@ function Xt({
762
762
  onChange: r,
763
763
  className: s
764
764
  }) {
765
- return /* @__PURE__ */ n(pe, { className: l("choice-list", s), children: e.map((i) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(
765
+ return /* @__PURE__ */ n(pe, { className: l("choice-list", s), children: e.map((a) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(
766
766
  Qe,
767
767
  {
768
- active: t === i.value,
769
- onClick: () => r(i.value),
770
- disabled: i.disabled,
771
- "data-has-description": i.description ? "true" : "false",
772
- children: i.description ? /* @__PURE__ */ d("span", { className: "choice-card__row", children: [
773
- /* @__PURE__ */ n("span", { className: "choice-card__label", children: i.label }),
774
- /* @__PURE__ */ n("span", { className: "choice-card__description", children: i.description })
775
- ] }) : /* @__PURE__ */ n("span", { className: "choice-card__label", children: i.label })
768
+ active: t === a.value,
769
+ onClick: () => r(a.value),
770
+ disabled: a.disabled,
771
+ "data-has-description": a.description ? "true" : "false",
772
+ children: a.description ? /* @__PURE__ */ d("span", { className: "choice-card__row", children: [
773
+ /* @__PURE__ */ n("span", { className: "choice-card__label", children: a.label }),
774
+ /* @__PURE__ */ n("span", { className: "choice-card__description", children: a.description })
775
+ ] }) : /* @__PURE__ */ n("span", { className: "choice-card__label", children: a.label })
776
776
  }
777
- ) }, i.value)) });
777
+ ) }, a.value)) });
778
778
  }
779
779
  function Yt({ count: e = 4, className: t, withDescription: r = !1 }) {
780
- return /* @__PURE__ */ n(pe, { className: l("choice-list", t), "aria-hidden": !0, children: Array.from({ length: e }).map((s, i) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ d("div", { className: "choice-card", children: [
780
+ return /* @__PURE__ */ n(pe, { className: l("choice-list", t), "aria-hidden": !0, children: Array.from({ length: e }).map((s, a) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ d("div", { className: "choice-card", children: [
781
781
  /* @__PURE__ */ n(we, { className: l("skeleton-title--sm", !r && "skeleton-choice-label") }),
782
782
  r ? /* @__PURE__ */ n(ge, { short: !0 }) : null
783
- ] }) }, `choice-skeleton-${i}`)) });
783
+ ] }) }, `choice-skeleton-${a}`)) });
784
784
  }
785
785
  function Ft({ className: e, ...t }) {
786
786
  return /* @__PURE__ */ n("div", { className: l("coord-grid", e), ...t });
@@ -832,13 +832,13 @@ function Lt({ as: e = "h1", className: t, ...r }) {
832
832
  ...r
833
833
  });
834
834
  }
835
- function it({ as: e = "span", className: t, ...r }) {
835
+ function ot({ as: e = "span", className: t, ...r }) {
836
836
  return T(e, {
837
837
  className: l("widget-section__title", t),
838
838
  ...r
839
839
  });
840
840
  }
841
- function ot({ as: e = "p", className: t, ...r }) {
841
+ function it({ as: e = "p", className: t, ...r }) {
842
842
  return T(e, {
843
843
  className: l("widget-section__description", t),
844
844
  ...r
@@ -859,7 +859,7 @@ function At({
859
859
  label: t,
860
860
  htmlFor: r,
861
861
  hint: s,
862
- error: i,
862
+ error: a,
863
863
  layout: u = "stack",
864
864
  className: w,
865
865
  children: f,
@@ -875,7 +875,7 @@ function At({
875
875
  t ? /* @__PURE__ */ n(ct, { htmlFor: r, children: t }) : null,
876
876
  f,
877
877
  s ? /* @__PURE__ */ n(_e, { size: "xs", children: s }) : null,
878
- i ? /* @__PURE__ */ n("p", { className: "field-error", children: i }) : null
878
+ a ? /* @__PURE__ */ n("p", { className: "field-error", children: a }) : null
879
879
  ] })
880
880
  );
881
881
  }
@@ -888,12 +888,12 @@ function Ot({ isGenerating: e, children: t, message: r }) {
888
888
  ] })
889
889
  ] });
890
890
  }
891
- function Ht({ as: e = "span", icon: t, className: r, children: s, ...i }) {
891
+ function Ht({ as: e = "span", icon: t, className: r, children: s, ...a }) {
892
892
  return T(
893
893
  e,
894
894
  {
895
895
  className: l("inline-row", r),
896
- ...i
896
+ ...a
897
897
  },
898
898
  /* @__PURE__ */ d(re, { children: [
899
899
  t,
@@ -906,19 +906,19 @@ function Bt({
906
906
  alt: t,
907
907
  placeholder: r = "No image",
908
908
  size: s = "md",
909
- fit: i = "contain",
909
+ fit: a = "contain",
910
910
  onImageError: u,
911
911
  className: w,
912
912
  ...f
913
913
  }) {
914
- const [m, g] = Se(null), h = !!(e && m === e), M = l("image-thumb", `image-thumb--${s}`, `image-thumb--fit-${i}`, w);
914
+ const [m, g] = Se(null), h = !!(e && m === e), M = l("image-thumb", `image-thumb--${s}`, `image-thumb--fit-${a}`, w);
915
915
  return /* @__PURE__ */ n("div", { className: M, ...f, children: e && !h ? /* @__PURE__ */ n(
916
916
  "img",
917
917
  {
918
918
  src: e,
919
919
  alt: t,
920
920
  className: "image-thumb__img",
921
- style: { objectFit: i, objectPosition: "center" },
921
+ style: { objectFit: a, objectPosition: "center" },
922
922
  onError: () => {
923
923
  g(e), u == null || u();
924
924
  }
@@ -932,7 +932,7 @@ function lt({
932
932
  ...s
933
933
  }) {
934
934
  return T(e ?? "div", {
935
- className: l(t === "between" ? "space-between" : "inline-row", r),
935
+ className: l(t === "between" ? "space-between" : t === "end" ? "space-end" : "inline-row", r),
936
936
  ...s
937
937
  });
938
938
  }
@@ -957,11 +957,11 @@ function Vt({ label: e = "Loading...", className: t }) {
957
957
  e
958
958
  ] });
959
959
  }
960
- function jt({ children: e }) {
961
- return /* @__PURE__ */ n("main", { className: "page-shell", children: e });
960
+ function jt({ children: e, className: t, ...r }) {
961
+ return /* @__PURE__ */ n("main", { className: l("page-shell", t), ...r, children: e });
962
962
  }
963
- function Ut({ children: e }) {
964
- return /* @__PURE__ */ n("div", { className: "page-card", children: e });
963
+ function Ut({ children: e, className: t, ...r }) {
964
+ return /* @__PURE__ */ n("div", { className: l("page-card", t), ...r, children: e });
965
965
  }
966
966
  function Zt({ onClick: e, label: t = "Close" }) {
967
967
  return /* @__PURE__ */ d(Ke, { variant: "secondary", className: "panel-close-btn", onClick: e, children: [
@@ -969,14 +969,14 @@ function Zt({ onClick: e, label: t = "Close" }) {
969
969
  t
970
970
  ] });
971
971
  }
972
- function qt({ heading: e, description: t, actions: r, className: s, children: i, ...u }) {
972
+ function qt({ heading: e, description: t, actions: r, className: s, children: a, ...u }) {
973
973
  return /* @__PURE__ */ d("section", { className: l("widget-section", s), ...u, children: [
974
974
  e || r ? /* @__PURE__ */ d("header", { className: r ? "title-row" : void 0, children: [
975
- e ? /* @__PURE__ */ n(it, { children: e }) : null,
975
+ e ? /* @__PURE__ */ n(ot, { children: e }) : null,
976
976
  r
977
977
  ] }) : null,
978
- t ? /* @__PURE__ */ n(ot, { children: t }) : null,
979
- i
978
+ t ? /* @__PURE__ */ n(it, { children: t }) : null,
979
+ a
980
980
  ] });
981
981
  }
982
982
  function Kt({ icon: e, label: t }) {
@@ -1024,15 +1024,15 @@ function wt({ className: e, ...t }) {
1024
1024
  const tn = me(function({ className: t, ...r }, s) {
1025
1025
  return /* @__PURE__ */ n("textarea", { ref: s, className: l(t), ...r });
1026
1026
  });
1027
- function nn({ className: e, theme: t = "light", onToggle: r, lightIcon: s, darkIcon: i }) {
1028
- return /* @__PURE__ */ n("button", { className: e, onClick: r, title: `Switch to ${t === "light" ? "dark" : "light"} mode`, "aria-label": "Toggle theme", children: t === "light" ? i ?? /* @__PURE__ */ n(Be, {}) : s ?? /* @__PURE__ */ n($e, {}) });
1027
+ function nn({ className: e, theme: t = "light", onToggle: r, lightIcon: s, darkIcon: a }) {
1028
+ return /* @__PURE__ */ n("button", { className: e, onClick: r, title: `Switch to ${t === "light" ? "dark" : "light"} mode`, "aria-label": "Toggle theme", children: t === "light" ? a ?? /* @__PURE__ */ n(Be, {}) : s ?? /* @__PURE__ */ n($e, {}) });
1029
1029
  }
1030
1030
  function rn({ className: e, ...t }) {
1031
1031
  return /* @__PURE__ */ n("div", { className: l("title-row", e), ...t });
1032
1032
  }
1033
1033
  function sn({ inputs: e = 1, showButton: t = !0, className: r, ...s }) {
1034
1034
  return /* @__PURE__ */ d(J, { className: r, ...s, children: [
1035
- Array.from({ length: e }).map((i, u) => /* @__PURE__ */ n(tt, {}, `panel-form-input-${u}`)),
1035
+ Array.from({ length: e }).map((a, u) => /* @__PURE__ */ n(tt, {}, `panel-form-input-${u}`)),
1036
1036
  t && /* @__PURE__ */ n(ve, {})
1037
1037
  ] });
1038
1038
  }
@@ -1134,8 +1134,8 @@ export {
1134
1134
  Jt as PickerGrid,
1135
1135
  ln as PickerGridSkeleton,
1136
1136
  Qt as Pill,
1137
- ot as SectionDescription,
1138
- it as SectionTitle,
1137
+ it as SectionDescription,
1138
+ ot as SectionTitle,
1139
1139
  en as Select,
1140
1140
  nt as SelectSkeleton,
1141
1141
  I as Skeleton,
@@ -647,6 +647,13 @@ button.chip:hover {
647
647
  gap: 0.5rem;
648
648
  }
649
649
 
650
+ .space-end {
651
+ display: flex;
652
+ align-items: center;
653
+ justify-content: flex-end;
654
+ gap: 0.36rem;
655
+ }
656
+
650
657
  .list-reset {
651
658
  margin: 0;
652
659
  padding: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectifthunes/whiteboard",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Pan/zoom whiteboard canvas with draggable panels, minimap, snap-to-grid, and zoom controls",
5
5
  "license": "MIT",
6
6
  "type": "module",