@memobit/libs 3.27.0 → 3.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ColorPicker/ColorPicker.css +1 -1
- package/dist/components/ColorPicker/ColorPicker2.js +114 -114
- package/dist/components/ContextMenu/ContextMenu2.js +46 -33
- package/dist/components/Dropdown/Dropdown2.js +42 -42
- package/dist/components/MenuBar/MenuBar.css +1 -0
- package/dist/components/MenuBar/MenuBar2.js +46 -0
- package/dist/components/ToolButton/ToolButton.css +1 -0
- package/dist/components/ToolButton/ToolButton2.js +36 -0
- package/dist/components/ToolPalette/ToolPalette.css +1 -0
- package/dist/components/ToolPalette/ToolPalette2.js +83 -0
- package/dist/helpers/VersionInfo.js +1 -1
- package/dist/index.d.ts +89 -2
- package/dist/index.js +191 -185
- package/dist/memobit-icons.json +3 -0
- package/dist/version.js +1 -1
- package/dist/version.json +4 -4
- package/package.json +1 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import './Dropdown.css';
|
|
2
2
|
import { Icon as R } from "../Icon/Icon2.js";
|
|
3
|
-
import { libMessages as
|
|
4
|
-
import { useMessages as
|
|
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
|
|
7
|
-
import { InputText as
|
|
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
|
|
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
|
|
13
|
-
import { caretDown as
|
|
14
|
-
var
|
|
15
|
-
const S = Ge
|
|
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,
|
|
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 (
|
|
104
|
-
const
|
|
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
|
|
107
|
-
A.style.width = "max-content", C.current = A.offsetWidth, A.style.width =
|
|
106
|
+
const qe = A.style.width;
|
|
107
|
+
A.style.width = "max-content", C.current = A.offsetWidth, A.style.width = qe;
|
|
108
108
|
}
|
|
109
|
-
const
|
|
110
|
-
|
|
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,
|
|
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
|
-
},
|
|
186
|
+
}, Ae = () => {
|
|
187
187
|
h([]), (!f || !i) && l(""), v(!1), p && p(i ? [] : null, $);
|
|
188
|
-
},
|
|
189
|
-
l(n), u || v(!0),
|
|
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
|
-
},
|
|
192
|
+
}, He = () => {
|
|
193
193
|
N || (v(!u), u || (E(-1), !i && f && o.length > 0 && l(""), (i || f) && P.current?.focus()));
|
|
194
|
-
},
|
|
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),
|
|
225
|
+
}, Q = (n) => o.some((e) => e.value === n.value), Ce = () => {
|
|
226
226
|
if (o.length === 0) return "";
|
|
227
|
-
const n = Math.max(1,
|
|
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
|
-
},
|
|
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)),
|
|
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 ?
|
|
322
|
-
}, x = !i && o.length === 1 ? o[0] : null, T =
|
|
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" : ""} ${
|
|
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 &&
|
|
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(
|
|
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(
|
|
365
|
+
/* @__PURE__ */ s(Xe, {
|
|
366
366
|
ref: P,
|
|
367
367
|
id: ie,
|
|
368
|
-
placeholder: T ? "" :
|
|
369
|
-
value: T ? "" :
|
|
370
|
-
onChange: he ?
|
|
368
|
+
placeholder: T ? "" : _e(),
|
|
369
|
+
value: T ? "" : Fe(),
|
|
370
|
+
onChange: he ? We : void 0,
|
|
371
371
|
onClick: le,
|
|
372
|
-
onKeyDown:
|
|
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:
|
|
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:
|
|
398
|
+
onClick: He,
|
|
399
399
|
disabled: N,
|
|
400
|
-
children:
|
|
400
|
+
children: Ve
|
|
401
401
|
})
|
|
402
402
|
})
|
|
403
403
|
]
|
|
404
404
|
}),
|
|
405
|
-
|
|
405
|
+
ze()
|
|
406
406
|
]
|
|
407
407
|
}),
|
|
408
|
-
|
|
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
|
-
|
|
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
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -619,6 +619,11 @@ export declare interface ColorPickerProps {
|
|
|
619
619
|
*/
|
|
620
620
|
swatches?: string[];
|
|
621
621
|
swatchesLabel?: string;
|
|
622
|
+
/**
|
|
623
|
+
* Without the card around it (border, padding, background) and as wide as its container: for a picker that
|
|
624
|
+
* sits in a side panel rather than a popover. The gradient's height follows `--color-picker-field-height`.
|
|
625
|
+
*/
|
|
626
|
+
bare?: boolean;
|
|
622
627
|
}
|
|
623
628
|
|
|
624
629
|
export declare interface ColProps {
|
|
@@ -708,13 +713,22 @@ export declare interface ConfirmPopoverProps {
|
|
|
708
713
|
offset?: number;
|
|
709
714
|
}
|
|
710
715
|
|
|
711
|
-
export declare const ContextMenu: ({ target, onClose, children, autoClose }: ContextMenuProps) => ReactPortal | null;
|
|
716
|
+
export declare const ContextMenu: ({ target, position, onClose, children, autoClose }: ContextMenuProps) => ReactPortal | null;
|
|
712
717
|
|
|
713
718
|
declare interface ContextMenuProps {
|
|
714
719
|
autoClose?: boolean;
|
|
715
720
|
children: ReactElement;
|
|
716
721
|
onClose?: () => void;
|
|
717
|
-
|
|
722
|
+
/** The element the menu opens below. Not needed when `position` is given. */
|
|
723
|
+
target?: EventTarget | null;
|
|
724
|
+
/**
|
|
725
|
+
* Opens the menu at a point in the viewport instead of below an element: pass a right-click's `clientX` and
|
|
726
|
+
* `clientY` for a menu at the cursor. Wins over `target` when both are given.
|
|
727
|
+
*/
|
|
728
|
+
position?: {
|
|
729
|
+
x: number;
|
|
730
|
+
y: number;
|
|
731
|
+
} | null;
|
|
718
732
|
}
|
|
719
733
|
|
|
720
734
|
export declare interface ContextToastAction {
|
|
@@ -1487,6 +1501,8 @@ declare interface DropdownProps {
|
|
|
1487
1501
|
allowCustomValue?: boolean;
|
|
1488
1502
|
autofocus?: boolean;
|
|
1489
1503
|
className?: string;
|
|
1504
|
+
/** Shows the clear (×) button once something is selected. Turn it off when a value must always be set. Defaults to true. */
|
|
1505
|
+
clearable?: boolean;
|
|
1490
1506
|
disabled?: boolean;
|
|
1491
1507
|
error?: string;
|
|
1492
1508
|
highlighted?: boolean;
|
|
@@ -2628,6 +2644,29 @@ export declare const matchesKeyFilter: (filterValue: string | string[] | null |
|
|
|
2628
2644
|
|
|
2629
2645
|
export declare const matchStringsByLogicalOperator: (searchItems: string[], targetString: string, operator: LogicalOperator) => boolean;
|
|
2630
2646
|
|
|
2647
|
+
/**
|
|
2648
|
+
* A desktop menu bar: File, Edit, Image… A click opens a menu; while one is open, hovering another switches to it,
|
|
2649
|
+
* as in Windows. Esc or a click elsewhere closes it. Shortcuts are only shown: handling the keys is the app's job.
|
|
2650
|
+
*/
|
|
2651
|
+
export declare const MenuBar: ({ menus, className }: MenuBarProps) => JSX.Element;
|
|
2652
|
+
|
|
2653
|
+
export declare type MenuBarEntry = {
|
|
2654
|
+
label: string;
|
|
2655
|
+
shortcut?: string;
|
|
2656
|
+
onSelect: () => void;
|
|
2657
|
+
disabled?: boolean;
|
|
2658
|
+
} | 'separator';
|
|
2659
|
+
|
|
2660
|
+
export declare interface MenuBarMenu {
|
|
2661
|
+
label: string;
|
|
2662
|
+
entries: MenuBarEntry[];
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
export declare interface MenuBarProps {
|
|
2666
|
+
menus: MenuBarMenu[];
|
|
2667
|
+
className?: string;
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2631
2670
|
export declare const MenuHamburger: FC<MenuHamburgerProps>;
|
|
2632
2671
|
|
|
2633
2672
|
export declare interface MenuHamburgerItem {
|
|
@@ -3738,6 +3777,54 @@ export declare interface ToolbarSortValue {
|
|
|
3738
3777
|
field: string;
|
|
3739
3778
|
}
|
|
3740
3779
|
|
|
3780
|
+
/** An icon-only toolbar button, its label in a Tooltip rather than a native title. */
|
|
3781
|
+
export declare const ToolButton: ({ icon, hint, onClick, disabled, active, danger, mirrored, badge, hintPosition, className }: ToolButtonProps) => JSX.Element;
|
|
3782
|
+
|
|
3783
|
+
export declare interface ToolButtonProps {
|
|
3784
|
+
icon: IconName | ReactElement;
|
|
3785
|
+
/** What it does, with its shortcut if any ("Rotate right (Ctrl+R)"), shown in a Tooltip. */
|
|
3786
|
+
hint: string;
|
|
3787
|
+
onClick: () => void;
|
|
3788
|
+
disabled?: boolean;
|
|
3789
|
+
/** Shown pressed: the current tool, or a toggle that is on. */
|
|
3790
|
+
active?: boolean;
|
|
3791
|
+
/** Red, for the destructive action of a toolbar. */
|
|
3792
|
+
danger?: boolean;
|
|
3793
|
+
/** Flips the icon, e.g. to turn a clockwise arrow into the counter-clockwise one. */
|
|
3794
|
+
mirrored?: boolean;
|
|
3795
|
+
/** A short tag on the icon's corner that sets it apart from the plain action, e.g. "WEB" on a floppy. */
|
|
3796
|
+
badge?: string;
|
|
3797
|
+
hintPosition?: TooltipPosition;
|
|
3798
|
+
className?: string;
|
|
3799
|
+
}
|
|
3800
|
+
|
|
3801
|
+
/**
|
|
3802
|
+
* A tool column, as in an image editor. Items that share a group share a slot showing the one last used: clicking the
|
|
3803
|
+
* slot again moves to the next item of the group, right-clicking lists them all. A corner mark shows which slots hold more.
|
|
3804
|
+
*/
|
|
3805
|
+
export declare const ToolPalette: ({ items, activeId, onSelect, columns, children, className }: ToolPaletteProps) => JSX.Element;
|
|
3806
|
+
|
|
3807
|
+
export declare interface ToolPaletteItem {
|
|
3808
|
+
id: string;
|
|
3809
|
+
label: string;
|
|
3810
|
+
icon: IconName | ReactElement;
|
|
3811
|
+
/** Shown in the hint and the group menu, e.g. "M". */
|
|
3812
|
+
shortcut?: string;
|
|
3813
|
+
/** Items with the same group share one slot, as Photoshop's marquees do. Defaults to the item's own id. */
|
|
3814
|
+
group?: string;
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
export declare interface ToolPaletteProps {
|
|
3818
|
+
items: ToolPaletteItem[];
|
|
3819
|
+
activeId: string;
|
|
3820
|
+
onSelect: (id: string) => void;
|
|
3821
|
+
/** Slots per row. Defaults to 2, which keeps a long set of tools on screen in a small window. */
|
|
3822
|
+
columns?: number;
|
|
3823
|
+
/** Shown under the tools, e.g. the foreground and background colours. */
|
|
3824
|
+
children?: ReactNode;
|
|
3825
|
+
className?: string;
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3741
3828
|
export declare const Tooltip: default_2.FC<TooltipProps>;
|
|
3742
3829
|
|
|
3743
3830
|
export declare type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
|