@memobit/libs 3.27.0 → 3.28.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.
@@ -1,24 +1,24 @@
1
1
  import './Dropdown.css';
2
2
  import { Icon as R } from "../Icon/Icon2.js";
3
- import { libMessages as qe } from "../../contexts/LanguageContext/libMessages.js";
4
- import { useMessages as Ge } from "../../hooks/useLanguage.js";
3
+ import { libMessages as Ge } from "../../contexts/LanguageContext/libMessages.js";
4
+ import { useMessages as Je } from "../../hooks/useLanguage.js";
5
5
  import { Button as be } from "../Button/Button2.js";
6
- import { Tooltip as Je } from "../Tooltip/Tooltip2.js";
7
- import { InputText as Qe } from "../InputText/InputText2.js";
6
+ import { Tooltip as Qe } from "../Tooltip/Tooltip2.js";
7
+ import { InputText as Xe } from "../InputText/InputText2.js";
8
8
  import { foldDiacritics as Ne } from "../../helpers/Search.js";
9
9
  /* empty css */
10
- import { useEffect as L, useId as Xe, useRef as O, useState as y } from "react";
10
+ import { useEffect as L, useId as Ye, useRef as O, useState as y } from "react";
11
11
  import { jsx as s, jsxs as b } from "react/jsx-runtime";
12
- import { createPortal as Ye } from "react-dom";
13
- import { caretDown as Ze, clear as $e } from "@memobit/icons";
14
- var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", disabled: N = !1, error: F, highlighted: Le = !1, id: ye, label: ee, maxVisibleSelectedLabels: Se = 1, multilineChips: Ie = !1, multiple: i = !1, name: $, onChange: p, onSearchChange: Ee, options: m, placeholder: Me, searchable: f = !0, searchValue: W, selectedCountDisplay: _ = "inline", showChips: H = !1, sortSelectedFirst: ne = !1, success: z, usePortal: k = !0, value: d, valueAsChip: De = !0 }) => {
15
- const S = Ge(qe), U = Me ?? S.selectOption, [u, v] = y(!1), [c, l] = y(W || ""), [a, te] = y(m), [I, E] = y(-1), [o, h] = y([]), [B, Re] = y({
12
+ import { createPortal as Ze } from "react-dom";
13
+ import { caretDown as Ve, clear as $e } from "@memobit/icons";
14
+ var hn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", clearable: Le = !0, disabled: N = !1, error: F, highlighted: ye = !1, id: Se, label: ee, maxVisibleSelectedLabels: Ie = 1, multilineChips: Ee = !1, multiple: i = !1, name: $, onChange: p, onSearchChange: Me, options: m, placeholder: De, searchable: f = !0, searchValue: W, selectedCountDisplay: _ = "inline", showChips: H = !1, sortSelectedFirst: ne = !1, success: z, usePortal: k = !0, value: d, valueAsChip: Re = !0 }) => {
15
+ const S = Je(Ge), U = De ?? S.selectOption, [u, v] = y(!1), [c, l] = y(W || ""), [a, te] = y(m), [I, E] = y(-1), [o, h] = y([]), [B, Be] = y({
16
16
  top: 0,
17
17
  bottom: 0,
18
18
  left: 0,
19
19
  width: 0,
20
20
  maxHeight: 300
21
- }), [K, Be] = y(!1), M = O(null), D = O([]), P = O(null), re = O(null), oe = Xe(), ie = ye ?? `dropdown-${oe}`, q = O(null), se = O(o);
21
+ }), [K, Te] = y(!1), M = O(null), D = O([]), P = O(null), re = O(null), oe = Ye(), ie = Se ?? `dropdown-${oe}`, q = O(null), se = O(o);
22
22
  L(() => {
23
23
  se.current = o;
24
24
  }), L(() => {
@@ -100,19 +100,19 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
100
100
  const n = () => {
101
101
  if (!M.current) return;
102
102
  const t = M.current.getBoundingClientRect(), r = window.visualViewport, g = r?.offsetTop ?? 0, Y = g + (r?.height ?? window.innerHeight), we = 300, Z = 8, V = Y - t.bottom, me = t.top - g, ge = V < we && me > V;
103
- if (Be(ge), k) {
104
- const Ue = Math.max(0, (ge ? me : V) - Z), A = re.current;
103
+ if (Te(ge), k) {
104
+ const Ke = Math.max(0, (ge ? me : V) - Z), A = re.current;
105
105
  if (A && C.current === null) {
106
- const Pe = A.style.width;
107
- A.style.width = "max-content", C.current = A.offsetWidth, A.style.width = Pe;
106
+ const qe = A.style.width;
107
+ A.style.width = "max-content", C.current = A.offsetWidth, A.style.width = qe;
108
108
  }
109
- const Ke = 360, ve = document.documentElement.clientWidth, xe = Math.max(t.width, Math.min(C.current ?? t.width, Ke, ve - 16));
110
- Re({
109
+ const Pe = 360, ve = document.documentElement.clientWidth, xe = Math.max(t.width, Math.min(C.current ?? t.width, Pe, ve - 16));
110
+ Be({
111
111
  top: t.bottom,
112
112
  bottom: window.innerHeight - t.top,
113
113
  left: Math.max(Z, Math.min(t.left, ve - Z - xe)),
114
114
  width: xe,
115
- maxHeight: Math.min(we, Ue)
115
+ maxHeight: Math.min(we, Ke)
116
116
  });
117
117
  }
118
118
  };
@@ -183,15 +183,15 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
183
183
  }, de = (n) => {
184
184
  const e = o.filter((t) => t.value !== n.value);
185
185
  h(e), p && (i ? (j.current = !0, p(e, $)) : (p(null, $), f || l("")));
186
- }, Te = () => {
186
+ }, Ae = () => {
187
187
  h([]), (!f || !i) && l(""), v(!1), p && p(i ? [] : null, $);
188
- }, Ae = (n) => {
189
- l(n), u || v(!0), Ee?.(n);
188
+ }, We = (n) => {
189
+ l(n), u || v(!0), Me?.(n);
190
190
  }, le = () => {
191
191
  N || (v(!0), !i && f && o.length > 0 && l(""), (i || f) && P.current?.focus());
192
- }, We = () => {
192
+ }, He = () => {
193
193
  N || (v(!u), u || (E(-1), !i && f && o.length > 0 && l(""), (i || f) && P.current?.focus()));
194
- }, He = (n) => {
194
+ }, je = (n) => {
195
195
  if (!N) {
196
196
  if (!u) {
197
197
  (n.key === "ArrowDown" || n.key === "Enter") && (v(!0), n.preventDefault());
@@ -222,16 +222,16 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
222
222
  i && c === "" && o.length > 0 && (n.preventDefault(), de(o[o.length - 1]));
223
223
  }
224
224
  }
225
- }, Q = (n) => o.some((e) => e.value === n.value), je = () => {
225
+ }, Q = (n) => o.some((e) => e.value === n.value), Ce = () => {
226
226
  if (o.length === 0) return "";
227
- const n = Math.max(1, Se);
227
+ const n = Math.max(1, Ie);
228
228
  if (o.length <= n) return o.map((r) => r.label).join(", ");
229
229
  const e = o.slice(0, n).map((r) => r.label).join(", "), t = o.length - n;
230
230
  return S.selectedWithOthers(e, t);
231
- }, Ce = () => i && H || f && u ? c : o.length > 0 ? i ? je() : o[0].label : "", Fe = () => i && H ? o.length > 0 ? "" : U : u && f ? U : o.length > 0 ? "" : U, _e = () => !i || o.length === 0 || _ === "none" ? null : _ === "floating" ? /* @__PURE__ */ s("div", {
231
+ }, Fe = () => i && H || f && u ? c : o.length > 0 ? i ? Ce() : o[0].label : "", _e = () => i && H ? o.length > 0 ? "" : U : u && f ? U : o.length > 0 ? "" : U, ze = () => !i || o.length === 0 || _ === "none" ? null : _ === "floating" ? /* @__PURE__ */ s("div", {
232
232
  className: "dropdown-selected-count",
233
233
  children: S.selectedCount(o.length)
234
- }) : null, ae = () => !!(w && c && c.trim() && !a.some((n) => n.label.toLowerCase() === c.toLowerCase() || n.value.toString() === c)), ze = () => {
234
+ }) : null, ae = () => !!(w && c && c.trim() && !a.some((n) => n.label.toLowerCase() === c.toLowerCase() || n.value.toString() === c)), Ue = () => {
235
235
  if (!u || N) return null;
236
236
  const n = /* @__PURE__ */ s("div", {
237
237
  ref: re,
@@ -318,10 +318,10 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
318
318
  children: S.noOptions
319
319
  })
320
320
  });
321
- return k ? Ye(n, document.body) : n;
322
- }, x = !i && o.length === 1 ? o[0] : null, T = De && !u && !i && o.length > 0, fe = !!(x?.icon && !c && !T), ue = !!(x?.suffixIcon && !T), X = i && H, pe = o.length > 0, he = f || w;
321
+ return k ? Ze(n, document.body) : n;
322
+ }, x = !i && o.length === 1 ? o[0] : null, T = Re && !u && !i && o.length > 0, fe = !!(x?.icon && !c && !T), ue = !!(x?.suffixIcon && !T), X = i && H, pe = Le && o.length > 0, he = f || w;
323
323
  return /* @__PURE__ */ b("div", {
324
- className: `dropdown-container ${F ? "dropdown-error" : ""} ${z ? "dropdown-success" : ""} ${Le ? "dropdown-highlighted" : ""} ${i ? "multiple" : ""} ${N ? "disabled" : ""} ${i ? `count-display-${_}` : ""} ${ke}`,
324
+ className: `dropdown-container ${F ? "dropdown-error" : ""} ${z ? "dropdown-success" : ""} ${ye ? "dropdown-highlighted" : ""} ${i ? "multiple" : ""} ${N ? "disabled" : ""} ${i ? `count-display-${_}` : ""} ${ke}`,
325
325
  ref: M,
326
326
  children: [
327
327
  ee && /* @__PURE__ */ s("label", {
@@ -330,7 +330,7 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
330
330
  children: ee
331
331
  }),
332
332
  /* @__PURE__ */ b("div", {
333
- className: `dropdown-input-container ${fe ? "dropdown-input-container--has-prefix-icon" : ""} ${ue ? "dropdown-input-container--has-suffix-icon" : ""} ${X ? "dropdown-input-container--chips" : ""} ${X && Ie ? "dropdown-input-container--chips-multiline" : ""} ${pe ? "dropdown-input-container--clearable" : ""}`,
333
+ className: `dropdown-input-container ${fe ? "dropdown-input-container--has-prefix-icon" : ""} ${ue ? "dropdown-input-container--has-suffix-icon" : ""} ${X ? "dropdown-input-container--chips" : ""} ${X && Ee ? "dropdown-input-container--chips-multiline" : ""} ${pe ? "dropdown-input-container--clearable" : ""}`,
334
334
  children: [
335
335
  fe && x?.icon && /* @__PURE__ */ s("span", {
336
336
  className: "dropdown-selected-icon dropdown-selected-icon--prefix",
@@ -349,7 +349,7 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
349
349
  children: [/* @__PURE__ */ s("span", {
350
350
  className: "dropdown-chip__label",
351
351
  children: n.label
352
- }), /* @__PURE__ */ s(Je, {
352
+ }), /* @__PURE__ */ s(Qe, {
353
353
  title: S.remove,
354
354
  children: /* @__PURE__ */ s("button", {
355
355
  type: "button",
@@ -362,14 +362,14 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
362
362
  })
363
363
  })]
364
364
  }, `dd-chip-${n.value}`)),
365
- /* @__PURE__ */ s(Qe, {
365
+ /* @__PURE__ */ s(Xe, {
366
366
  ref: P,
367
367
  id: ie,
368
- placeholder: T ? "" : Fe(),
369
- value: T ? "" : Ce(),
370
- onChange: he ? Ae : void 0,
368
+ placeholder: T ? "" : _e(),
369
+ value: T ? "" : Fe(),
370
+ onChange: he ? We : void 0,
371
371
  onClick: le,
372
- onKeyDown: He,
372
+ onKeyDown: je,
373
373
  autoComplete: "off",
374
374
  autoFocus: Oe,
375
375
  disabled: N,
@@ -386,7 +386,7 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
386
386
  className: "dropdown-action-button dropdown-clear-button",
387
387
  children: /* @__PURE__ */ s(be, {
388
388
  variant: "plain",
389
- onClick: Te,
389
+ onClick: Ae,
390
390
  disabled: N,
391
391
  children: $e
392
392
  })
@@ -395,17 +395,17 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
395
395
  className: `dropdown-action-button dropdown-toggle-button ${u ? "open" : ""}`,
396
396
  children: /* @__PURE__ */ s(be, {
397
397
  variant: "plain",
398
- onClick: We,
398
+ onClick: He,
399
399
  disabled: N,
400
- children: Ze
400
+ children: Ve
401
401
  })
402
402
  })
403
403
  ]
404
404
  }),
405
- _e()
405
+ ze()
406
406
  ]
407
407
  }),
408
- ze(),
408
+ Ue(),
409
409
  F && /* @__PURE__ */ s("span", {
410
410
  className: "dropdown-error-message",
411
411
  children: F
@@ -418,5 +418,5 @@ var pn = ({ allowCustomValue: w = !1, autofocus: Oe = !1, className: ke = "", di
418
418
  });
419
419
  };
420
420
  export {
421
- pn as Dropdown
421
+ hn as Dropdown
422
422
  };
@@ -0,0 +1 @@
1
+ .menu-bar{align-items:center;gap:var(--spacing-2);display:flex}.menu-bar__menu{position:relative}.menu-bar__title{padding:var(--spacing-4) var(--spacing-8);border-radius:var(--radius-sm);color:var(--body-color);font:inherit;font-size:var(--font-size-sm);cursor:default;background:0 0;border:none}.menu-bar__title:hover,.menu-bar__title--open{background:var(--list-hover-background-color)}.menu-bar__list{z-index:1200;min-width:200px;padding:var(--spacing-4);background:var(--popover-background-color);border:1px solid var(--popover-border-color);border-radius:var(--radius);box-shadow:0 var(--spacing-8) var(--spacing-24) var(--box-shadow);flex-direction:column;display:flex;position:absolute;top:100%;left:0}.menu-bar__item{justify-content:space-between;align-items:center;gap:var(--spacing-24);padding:var(--spacing-6) var(--spacing-8);border-radius:var(--radius-sm);color:var(--popover-color);font:inherit;font-size:var(--font-size-sm);text-align:left;white-space:nowrap;cursor:default;background:0 0;border:none;display:flex}.menu-bar__item:hover:not(:disabled){background:color-mix(in srgb, var(--body-accent-color) 16%, transparent)}.menu-bar__item:disabled{color:var(--body-color-muted);opacity:.6}.menu-bar__shortcut{color:var(--body-color-muted);font-size:var(--font-size-xs)}.menu-bar__separator{height:1px;margin:var(--spacing-4) var(--spacing-2);background:var(--delimiter-color)}
@@ -0,0 +1,46 @@
1
+ import './MenuBar.css';
2
+ /* empty css */
3
+ import { useEffect as d, useRef as m, useState as b } from "react";
4
+ import { jsx as a, jsxs as u } from "react/jsx-runtime";
5
+ var w = ({ menus: i, className: o }) => {
6
+ const [r, s] = b(null), l = m(null);
7
+ return d(() => {
8
+ if (r === null) return;
9
+ const n = (e) => {
10
+ e instanceof KeyboardEvent && e.key !== "Escape" || e instanceof MouseEvent && e.target instanceof Node && l.current?.contains(e.target) || s(null);
11
+ };
12
+ return window.addEventListener("mousedown", n), window.addEventListener("keydown", n), () => {
13
+ window.removeEventListener("mousedown", n), window.removeEventListener("keydown", n);
14
+ };
15
+ }, [r]), /* @__PURE__ */ a("div", {
16
+ className: `menu-bar${o ? ` ${o}` : ""}`,
17
+ ref: l,
18
+ children: i.map((n, e) => /* @__PURE__ */ u("div", {
19
+ className: "menu-bar__menu",
20
+ children: [/* @__PURE__ */ a("button", {
21
+ type: "button",
22
+ className: `menu-bar__title${r === e ? " menu-bar__title--open" : ""}`,
23
+ onClick: () => s(r === e ? null : e),
24
+ onMouseEnter: () => r !== null && s(e),
25
+ children: n.label
26
+ }), r === e && /* @__PURE__ */ a("div", {
27
+ className: "menu-bar__list",
28
+ children: n.entries.map((t, c) => t === "separator" ? /* @__PURE__ */ a("div", { className: "menu-bar__separator" }, `separator-${c}`) : /* @__PURE__ */ u("button", {
29
+ type: "button",
30
+ className: "menu-bar__item",
31
+ disabled: t.disabled,
32
+ onClick: () => {
33
+ s(null), t.onSelect();
34
+ },
35
+ children: [/* @__PURE__ */ a("span", { children: t.label }), t.shortcut && /* @__PURE__ */ a("span", {
36
+ className: "menu-bar__shortcut",
37
+ children: t.shortcut
38
+ })]
39
+ }, t.label))
40
+ })]
41
+ }, n.label))
42
+ });
43
+ };
44
+ export {
45
+ w as MenuBar
46
+ };
@@ -0,0 +1 @@
1
+ .tool-button--active.button,.tool-button--active.button:hover{background:var(--list-hover-background-color);color:var(--body-accent-color)}.tool-button--danger.button:not(:disabled),.tool-button--danger.button:not(:disabled):hover{color:var(--body-danger-color)}.tool-button--mirrored svg{transform:scaleX(-1)}.tool-button__badged{display:flex;position:relative}.tool-button__badged--disabled{opacity:.5}.tool-button__badge{padding:0 var(--spacing-2);border-radius:var(--radius-sm);background:var(--body-accent-color);color:var(--button-info-color);font-size:var(--font-size-xxs);font-weight:var(--font-weight-bold);line-height:var(--line-height-tight);pointer-events:none;position:absolute;bottom:0;right:0}
@@ -0,0 +1,36 @@
1
+ import './ToolButton.css';
2
+ import { Button as p } from "../Button/Button2.js";
3
+ import { Tooltip as d } from "../Tooltip/Tooltip2.js";
4
+ /* empty css */
5
+ import { jsx as t, jsxs as _ } from "react/jsx-runtime";
6
+ var v = ({ icon: r, hint: a, onClick: s, disabled: o, active: e, danger: i, mirrored: m, badge: n, hintPosition: u = "bottom", className: b }) => {
7
+ const c = [
8
+ "tool-button",
9
+ m && "tool-button--mirrored",
10
+ i && "tool-button--danger",
11
+ e && "tool-button--active",
12
+ b
13
+ ].filter(Boolean).join(" "), l = /* @__PURE__ */ t(p, {
14
+ variant: "plain",
15
+ size: "small",
16
+ icon: r,
17
+ onClick: s,
18
+ disabled: o,
19
+ className: c
20
+ });
21
+ return /* @__PURE__ */ t(d, {
22
+ title: a,
23
+ position: u,
24
+ disabled: o,
25
+ children: n ? /* @__PURE__ */ _("span", {
26
+ className: `tool-button__badged${o ? " tool-button__badged--disabled" : ""}`,
27
+ children: [l, /* @__PURE__ */ t("span", {
28
+ className: "tool-button__badge",
29
+ children: n
30
+ })]
31
+ }) : l
32
+ });
33
+ };
34
+ export {
35
+ v as ToolButton
36
+ };
@@ -0,0 +1 @@
1
+ .tool-palette{--tool-palette-slot:38px;align-items:center;gap:var(--spacing-12);padding:var(--spacing-8) var(--spacing-4);background:var(--card-background-color);border-right:1px solid var(--border-color);flex-direction:column;flex:none;display:flex}.tool-palette__tools{width:calc(var(--tool-palette-slot) * var(--tool-palette-columns));flex-wrap:wrap;display:flex}.tool-palette__slot{width:var(--tool-palette-slot);justify-content:center;display:flex;position:relative}.tool-palette__slot--grouped:after{right:var(--spacing-2);bottom:var(--spacing-2);border-bottom:var(--spacing-4) solid var(--body-color-muted);border-left:var(--spacing-4) solid transparent;content:"";pointer-events:none;width:0;height:0;position:absolute}.tool-palette__menu{min-width:200px;padding:var(--spacing-4);flex-direction:column;display:flex}.tool-palette__menu-item.button{justify-content:flex-start;width:100%}.tool-palette__menu-item--active.button{color:var(--body-accent-color)}.tool-palette__menu-label{text-align:left;flex:1}.tool-palette__menu-shortcut{margin-left:var(--spacing-24);color:var(--body-color-muted);font-size:var(--font-size-xs)}
@@ -0,0 +1,83 @@
1
+ import './ToolPalette.css';
2
+ import { Button as v } from "../Button/Button2.js";
3
+ import { ContextMenu as w } from "../ContextMenu/ContextMenu2.js";
4
+ import { ToolButton as j } from "../ToolButton/ToolButton2.js";
5
+ /* empty css */
6
+ import { useState as m } from "react";
7
+ import { jsx as e, jsxs as _ } from "react/jsx-runtime";
8
+ var D = ({ items: f, activeId: n, onSelect: x, columns: $ = 2, children: b, className: h }) => {
9
+ const c = /* @__PURE__ */ new Map();
10
+ for (const t of f) {
11
+ const o = t.group ?? t.id;
12
+ c.set(o, [...c.get(o) ?? [], t]);
13
+ }
14
+ const [y, C] = m({}), [s, a] = m(null), i = (t) => t.group ?? t.id, p = (t) => t.find((o) => o.id === n) ?? t.find((o) => o.id === y[i(t[0])]) ?? t[0], r = (t) => {
15
+ C((o) => ({
16
+ ...o,
17
+ [i(t)]: t.id
18
+ })), x(t.id);
19
+ }, N = (t) => {
20
+ const o = p(t);
21
+ o.id !== n || t.length === 1 ? r(o) : r(t[(t.indexOf(o) + 1) % t.length]);
22
+ }, k = (t, o) => {
23
+ t.preventDefault(), o.length > 1 && a({
24
+ group: o,
25
+ x: t.clientX,
26
+ y: t.clientY
27
+ });
28
+ }, u = (t) => t.shortcut ? `${t.label} (${t.shortcut})` : t.label, M = { "--tool-palette-columns": $ };
29
+ return /* @__PURE__ */ _("nav", {
30
+ className: `tool-palette${h ? ` ${h}` : ""}`,
31
+ style: M,
32
+ children: [
33
+ /* @__PURE__ */ e("div", {
34
+ className: "tool-palette__tools",
35
+ children: [...c.values()].map((t) => {
36
+ const o = p(t), d = t.filter((l) => l !== o).map((l) => l.label);
37
+ return /* @__PURE__ */ e("span", {
38
+ className: `tool-palette__slot${t.length > 1 ? " tool-palette__slot--grouped" : ""}`,
39
+ onContextMenu: (l) => k(l, t),
40
+ children: /* @__PURE__ */ e(j, {
41
+ icon: o.icon,
42
+ hint: d.length > 0 ? `${u(o)} · also ${d.join(", ")}` : u(o),
43
+ hintPosition: "right",
44
+ onClick: () => N(t),
45
+ active: o.id === n
46
+ })
47
+ }, i(o));
48
+ })
49
+ }),
50
+ b,
51
+ s && /* @__PURE__ */ e(w, {
52
+ position: {
53
+ x: s.x,
54
+ y: s.y
55
+ },
56
+ onClose: () => a(null),
57
+ autoClose: !0,
58
+ children: /* @__PURE__ */ e("div", {
59
+ className: "tool-palette__menu",
60
+ children: s.group.map((t) => /* @__PURE__ */ _(v, {
61
+ variant: "plain",
62
+ size: "small",
63
+ icon: t.icon,
64
+ className: `tool-palette__menu-item${t.id === n ? " tool-palette__menu-item--active" : ""}`,
65
+ onClick: () => {
66
+ a(null), r(t);
67
+ },
68
+ children: [/* @__PURE__ */ e("span", {
69
+ className: "tool-palette__menu-label",
70
+ children: t.label
71
+ }), t.shortcut && /* @__PURE__ */ e("span", {
72
+ className: "tool-palette__menu-shortcut",
73
+ children: t.shortcut
74
+ })]
75
+ }, t.id))
76
+ })
77
+ })
78
+ ]
79
+ });
80
+ };
81
+ export {
82
+ D as ToolPalette
83
+ };
@@ -1,108 +1,114 @@
1
1
  import './Tooltip.css';
2
2
  /* empty css */
3
- import { createContext as U, useCallback as F, useContext as W, useEffect as C, useRef as d, useState as M } from "react";
4
- import { Fragment as X, jsx as $, jsxs as I } from "react/jsx-runtime";
5
- import { createPortal as Y } from "react-dom";
6
- var j = U(null), re = ({ title: y, position: h = "top", delay: z = 200, children: V, disabled: E = !1, className: O = "", maxWidth: p, maxHeight: a }) => {
7
- const [g, u] = M(!1), [D, q] = M(0), w = W(j), [x, A] = M({
3
+ import { createContext as H, useCallback as F, useContext as tt, useEffect as C, useRef as w, useState as P } from "react";
4
+ import { Fragment as et, jsx as x, jsxs as V } from "react/jsx-runtime";
5
+ import { createPortal as rt } from "react-dom";
6
+ var j = H(null), lt = ({ title: y, position: c = "top", delay: z = 200, children: q, disabled: E = !1, className: A = "", maxWidth: p, maxHeight: f }) => {
7
+ const [g, u] = P(!1), [D, G] = P(0), m = tt(j), [d, J] = P({
8
8
  top: 0,
9
9
  left: 0
10
- }), c = d(null), n = d(null), l = d(null), f = d(null), m = d(!1), v = a !== void 0, b = v ? 150 : 0, B = !!y && !E, L = g && B && D === 0, N = g && B || D > 0, G = F((t) => {
11
- q((e) => Math.max(0, e + (t ? 1 : -1)));
10
+ }), s = w(null), n = w(null), a = w(null), h = w(null), v = w(!1), T = f !== void 0, M = T ? 150 : 0, B = !!y && !E, $ = g && B && D === 0, N = g && B || D > 0, K = F((e) => {
11
+ G((t) => Math.max(0, t + (e ? 1 : -1)));
12
12
  }, []);
13
13
  C(() => {
14
- if (!(!w || !N))
15
- return w(!0), () => w(!1);
16
- }, [N, w]);
17
- const T = F(() => {
18
- if (!l.current || !f.current) return;
19
- const t = l.current.firstElementChild?.getBoundingClientRect();
20
- let e = t && t.width > 0 ? t : l.current.getBoundingClientRect();
21
- if (e.width === 0 && e.height === 0) {
14
+ if (!(!m || !N))
15
+ return m(!0), () => m(!1);
16
+ }, [N, m]);
17
+ const R = F(() => {
18
+ if (!a.current || !h.current) return;
19
+ const e = a.current.firstElementChild?.getBoundingClientRect();
20
+ let t = e && e.width > 0 ? e : a.current.getBoundingClientRect();
21
+ if (t.width === 0 && t.height === 0) {
22
22
  const _ = document.createRange();
23
- _.selectNodeContents(l.current);
24
- const P = _.getBoundingClientRect();
25
- (P.width > 0 || P.height > 0) && (e = P);
23
+ _.selectNodeContents(a.current);
24
+ const L = _.getBoundingClientRect();
25
+ (L.width > 0 || L.height > 0) && (t = L);
26
26
  }
27
- const r = f.current.getBoundingClientRect(), R = 8;
27
+ const r = h.current.getBoundingClientRect(), b = 8;
28
28
  let o = 0, i = 0;
29
- switch (h) {
29
+ switch (c) {
30
30
  case "top":
31
- o = e.top - r.height - R, i = e.left + e.width / 2 - r.width / 2;
31
+ o = t.top - r.height - b, i = t.left + t.width / 2 - r.width / 2;
32
32
  break;
33
33
  case "bottom":
34
- o = e.bottom + R, i = e.left + e.width / 2 - r.width / 2;
34
+ o = t.bottom + b, i = t.left + t.width / 2 - r.width / 2;
35
35
  break;
36
36
  case "left":
37
- o = e.top + e.height / 2 - r.height / 2, i = e.left - r.width - R;
37
+ o = t.top + t.height / 2 - r.height / 2, i = t.left - r.width - b;
38
38
  break;
39
39
  case "right":
40
- o = e.top + e.height / 2 - r.height / 2, i = e.right + R;
40
+ o = t.top + t.height / 2 - r.height / 2, i = t.right + b;
41
41
  }
42
- const s = 8;
43
- i < s && (i = s), i + r.width > window.innerWidth - s && (i = window.innerWidth - r.width - s), o < s && (o = s), o + r.height > window.innerHeight - s && (o = window.innerHeight - r.height - s), A({
42
+ const l = 8;
43
+ i < l && (i = l), i + r.width > window.innerWidth - l && (i = window.innerWidth - r.width - l), o < l && (o = l), o + r.height > window.innerHeight - l && (o = window.innerHeight - r.height - l);
44
+ const k = 12, I = c === "top" || c === "bottom", X = I ? t.left + t.width / 2 - i : t.top + t.height / 2 - o, Y = I ? r.width : r.height, Z = Math.min(Math.max(X, k), Y - k);
45
+ J({
44
46
  top: o,
45
- left: i
47
+ left: i,
48
+ arrowOffset: Z
46
49
  });
47
- }, [h]), S = () => {
48
- E || m.current || (n.current && (clearTimeout(n.current), n.current = null), c.current = setTimeout(() => {
50
+ }, [c]), S = () => {
51
+ E || v.current || (n.current && (clearTimeout(n.current), n.current = null), s.current = setTimeout(() => {
49
52
  u(!0);
50
53
  }, z));
51
- }, k = () => {
52
- m.current || (c.current && clearTimeout(c.current), b > 0 ? n.current = setTimeout(() => u(!1), b) : u(!1));
53
- }, J = (t) => {
54
- t.pointerType !== "touch" && t.pointerType !== "pen" || E || (m.current = !0, c.current && (clearTimeout(c.current), c.current = null), t.stopPropagation(), u((e) => !e));
54
+ }, O = () => {
55
+ v.current || (s.current && clearTimeout(s.current), M > 0 ? n.current = setTimeout(() => u(!1), M) : u(!1));
56
+ }, Q = (e) => {
57
+ e.pointerType !== "touch" && e.pointerType !== "pen" || E || (v.current = !0, s.current && (clearTimeout(s.current), s.current = null), e.stopPropagation(), u((t) => !t));
55
58
  };
56
59
  C(() => {
57
- if (!L) return;
58
- const t = (e) => {
59
- e.target instanceof Node && f.current?.contains(e.target) || u(!1);
60
+ if (!$) return;
61
+ const e = (t) => {
62
+ t.target instanceof Node && h.current?.contains(t.target) || u(!1);
60
63
  };
61
- return T(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", T), () => {
62
- window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", T);
64
+ return R(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", R), () => {
65
+ window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", R);
63
66
  };
64
- }, [L, T]), C(() => {
67
+ }, [$, R]), C(() => {
65
68
  if (!g) return;
66
- const t = (e) => {
67
- l.current?.contains(e.target) || f.current?.contains(e.target) || u(!1);
69
+ const e = (t) => {
70
+ a.current?.contains(t.target) || h.current?.contains(t.target) || u(!1);
68
71
  };
69
- return document.addEventListener("pointerdown", t), () => {
70
- document.removeEventListener("pointerdown", t), m.current = !1;
72
+ return document.addEventListener("pointerdown", e), () => {
73
+ document.removeEventListener("pointerdown", e), v.current = !1;
71
74
  };
72
75
  }, [g]), C(() => () => {
73
- c.current && clearTimeout(c.current), n.current && clearTimeout(n.current);
76
+ s.current && clearTimeout(s.current), n.current && clearTimeout(n.current);
74
77
  }, []);
75
- const K = () => {
76
- v && n.current && (clearTimeout(n.current), n.current = null);
77
- }, Q = () => {
78
- v && (n.current = setTimeout(() => u(!1), b));
78
+ const U = () => {
79
+ T && n.current && (clearTimeout(n.current), n.current = null);
80
+ }, W = () => {
81
+ T && (n.current = setTimeout(() => u(!1), M));
79
82
  };
80
- return /* @__PURE__ */ I(X, { children: [/* @__PURE__ */ $("span", {
81
- ref: l,
83
+ return /* @__PURE__ */ V(et, { children: [/* @__PURE__ */ x("span", {
84
+ ref: a,
82
85
  className: "tooltip-trigger",
83
86
  onMouseEnter: S,
84
- onMouseLeave: k,
87
+ onMouseLeave: O,
85
88
  onFocus: S,
86
- onBlur: k,
87
- onPointerDown: J,
88
- children: /* @__PURE__ */ $(j.Provider, {
89
- value: G,
90
- children: V
89
+ onBlur: O,
90
+ onPointerDown: Q,
91
+ children: /* @__PURE__ */ x(j.Provider, {
92
+ value: K,
93
+ children: q
91
94
  })
92
- }), L && Y(/* @__PURE__ */ I("div", {
93
- ref: f,
94
- className: `tooltip tooltip--${h} ${v ? "tooltip--scrollable" : ""} ${O}`,
95
+ }), $ && rt(/* @__PURE__ */ V("div", {
96
+ ref: h,
97
+ className: `tooltip tooltip--${c} ${T ? "tooltip--scrollable" : ""} ${A}`,
95
98
  style: {
96
- top: `${x.top}px`,
97
- left: `${x.left}px`,
99
+ top: `${d.top}px`,
100
+ left: `${d.left}px`,
98
101
  ...p !== void 0 && { maxWidth: typeof p == "number" ? `${p}px` : p },
99
- ...a !== void 0 && { maxHeight: typeof a == "number" ? `${a}px` : a }
102
+ ...f !== void 0 && { maxHeight: typeof f == "number" ? `${f}px` : f }
100
103
  },
101
- onMouseEnter: K,
102
- onMouseLeave: Q,
103
- children: [y, /* @__PURE__ */ $("div", { className: `tooltip__arrow tooltip__arrow--${h}` })]
104
+ onMouseEnter: U,
105
+ onMouseLeave: W,
106
+ children: [y, /* @__PURE__ */ x("div", {
107
+ className: `tooltip__arrow tooltip__arrow--${c}`,
108
+ style: d.arrowOffset === void 0 ? void 0 : c === "top" || c === "bottom" ? { left: `${d.arrowOffset}px` } : { top: `${d.arrowOffset}px` }
109
+ })]
104
110
  }), document.body)] });
105
111
  };
106
112
  export {
107
- re as Tooltip
113
+ lt as Tooltip
108
114
  };
@@ -23,7 +23,7 @@ var r = (i) => {
23
23
  const o = {
24
24
  ...i,
25
25
  lib: d,
26
- libBuildNumber: 628,
26
+ libBuildNumber: 633,
27
27
  libCommit: n,
28
28
  libBuildDate: t
29
29
  };