@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.
- 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/components/Tooltip/Tooltip2.js +72 -66
- 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 +2 -2
- package/dist/version.json +4 -4
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
.color-picker{gap:var(--spacing-12);border:1px solid var(--delimiter-color);border-radius:var(--radius);padding:var(--spacing-16);background:var(--card-background-color);flex-direction:column;width:320px;display:flex}.color-picker__swatches{gap:var(--spacing-6);flex-direction:column;display:flex}.color-picker__swatches-label{font-size:var(--font-size-xxs);color:var(--body-sub-title-color)}.color-picker__swatches-row{gap:var(--spacing-6);flex-wrap:wrap;display:flex}.color-picker__swatch{width:var(--spacing-20);height:var(--spacing-20);border:1px solid color-mix(in srgb, var(--body-color) 30%, transparent);cursor:pointer;transition:transform var(--transition-fast);border-radius:50%;padding:0}.color-picker__swatch:hover{transform:scale(1.15)}.color-picker__swatch.is-selected{outline:2px solid var(--body-accent-color);outline-offset:2px}.color-picker__preview{border-radius:var(--radius);border:1px solid var(--delimiter-color);width:100%;height:40px}.color-picker__controls{gap:var(--spacing-12);flex-direction:column;display:flex}.color-picker__sv{border-radius:var(--radius);cursor:crosshair;touch-action:none;-webkit-user-select:none;user-select:none;
|
|
1
|
+
.color-picker{gap:var(--spacing-12);border:1px solid var(--delimiter-color);border-radius:var(--radius);padding:var(--spacing-16);background:var(--card-background-color);flex-direction:column;width:320px;display:flex}.color-picker--bare{background:0 0;border:none;width:100%;padding:0}.color-picker__swatches{gap:var(--spacing-6);flex-direction:column;display:flex}.color-picker__swatches-label{font-size:var(--font-size-xxs);color:var(--body-sub-title-color)}.color-picker__swatches-row{gap:var(--spacing-6);flex-wrap:wrap;display:flex}.color-picker__swatch{width:var(--spacing-20);height:var(--spacing-20);border:1px solid color-mix(in srgb, var(--body-color) 30%, transparent);cursor:pointer;transition:transform var(--transition-fast);border-radius:50%;padding:0}.color-picker__swatch:hover{transform:scale(1.15)}.color-picker__swatch.is-selected{outline:2px solid var(--body-accent-color);outline-offset:2px}.color-picker__preview{border-radius:var(--radius);border:1px solid var(--delimiter-color);width:100%;height:40px}.color-picker__controls{gap:var(--spacing-12);flex-direction:column;display:flex}.color-picker__sv{width:100%;height:var(--color-picker-field-height,180px);border-radius:var(--radius);cursor:crosshair;touch-action:none;-webkit-user-select:none;user-select:none;position:relative;overflow:hidden}.color-picker__sv-white,.color-picker__sv-black{position:absolute;inset:0}.color-picker__sv-white{background:linear-gradient(90deg,#fff,#fff0)}.color-picker__sv-black{background:linear-gradient(#0000,#000)}.color-picker__sv-handle{border:2px solid #fff;border-radius:50%;width:12px;height:12px;position:absolute;transform:translate(-6px,-6px);box-shadow:0 0 0 1px #0000004d}.color-picker__slider input[type=range]{width:100%}.color-picker__mode-toggle{gap:var(--spacing-8);display:flex}.color-picker__mode-toggle .button{padding:6px 10px}.color-picker__mode-toggle .button.is-active{border:1px solid var(--body-accent-color);color:var(--body-accent-color)}.color-picker__fields{gap:var(--spacing-8);grid-template-columns:1fr;display:grid}.color-picker__fields .input-text-wrapper,.color-picker__fields .input-number-wrapper{width:100%}.color-picker__fields--rgb,.color-picker__fields--hsl,.color-picker__fields--hex{grid-template-columns:repeat(3,1fr)}.color-picker__fields--hex .input-text-wrapper{grid-column:span 3}
|
|
@@ -1,137 +1,137 @@
|
|
|
1
1
|
import './ColorPicker.css';
|
|
2
2
|
import { Button as H } from "../Button/Button2.js";
|
|
3
|
-
import { Tooltip as
|
|
3
|
+
import { Tooltip as X } from "../Tooltip/Tooltip2.js";
|
|
4
4
|
import { InputNumber as N } from "../InputNumber/InputNumber2.js";
|
|
5
|
-
import { InputText as
|
|
5
|
+
import { InputText as Y } from "../InputText/InputText2.js";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import { useEffect as
|
|
8
|
-
import { jsx as
|
|
9
|
-
var k = (
|
|
10
|
-
const
|
|
11
|
-
if (![3, 6].includes(
|
|
12
|
-
const
|
|
13
|
-
return Number.isNaN(
|
|
14
|
-
r:
|
|
15
|
-
g:
|
|
16
|
-
b:
|
|
7
|
+
import { useEffect as A, useMemo as F, useRef as I, useState as y } from "react";
|
|
8
|
+
import { jsx as i, jsxs as b } from "react/jsx-runtime";
|
|
9
|
+
var k = (o, a, m) => Math.min(m, Math.max(a, o)), x = (o) => {
|
|
10
|
+
const a = o.replace("#", "").trim();
|
|
11
|
+
if (![3, 6].includes(a.length)) return null;
|
|
12
|
+
const m = a.length === 3 ? a.split("").map((c) => c + c).join("") : a, l = parseInt(m, 16);
|
|
13
|
+
return Number.isNaN(l) ? null : {
|
|
14
|
+
r: l >> 16 & 255,
|
|
15
|
+
g: l >> 8 & 255,
|
|
16
|
+
b: l & 255
|
|
17
17
|
};
|
|
18
|
-
}, L = (
|
|
19
|
-
const
|
|
20
|
-
return `#${
|
|
21
|
-
}, R = ({ r:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
].map((
|
|
26
|
-
const
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
const
|
|
18
|
+
}, L = (o) => {
|
|
19
|
+
const a = o.trim().replace("#", "").toLowerCase();
|
|
20
|
+
return `#${a.length === 3 ? a.split("").map((m) => m + m).join("") : a}`;
|
|
21
|
+
}, R = ({ r: o, g: a, b: m }) => `#${[
|
|
22
|
+
o,
|
|
23
|
+
a,
|
|
24
|
+
m
|
|
25
|
+
].map((l) => k(Math.round(l), 0, 255).toString(16).padStart(2, "0")).join("")}`, v = ({ r: o, g: a, b: m }) => {
|
|
26
|
+
const l = o / 255, c = a / 255, r = m / 255, n = Math.max(l, c, r), h = n - Math.min(l, c, r);
|
|
27
|
+
let t = 0;
|
|
28
|
+
h !== 0 && (n === l ? t = (c - r) / h % 6 : n === c ? t = (r - l) / h + 2 : t = (l - c) / h + 4, t = Math.round(t * 60), t < 0 && (t += 360));
|
|
29
|
+
const s = n === 0 ? 0 : h / n, d = n;
|
|
30
30
|
return {
|
|
31
|
-
h:
|
|
32
|
-
s: Math.round(
|
|
33
|
-
v: Math.round(
|
|
31
|
+
h: t,
|
|
32
|
+
s: Math.round(s * 100),
|
|
33
|
+
v: Math.round(d * 100)
|
|
34
34
|
};
|
|
35
|
-
}, E = ({ h:
|
|
36
|
-
const
|
|
37
|
-
let
|
|
38
|
-
return
|
|
39
|
-
r: Math.round((
|
|
40
|
-
g: Math.round((
|
|
41
|
-
b: Math.round((
|
|
35
|
+
}, E = ({ h: o, s: a, v: m }) => {
|
|
36
|
+
const l = a / 100, c = m / 100, r = c * l, n = r * (1 - Math.abs(o / 60 % 2 - 1)), h = c - r;
|
|
37
|
+
let t = 0, s = 0, d = 0;
|
|
38
|
+
return o < 60 ? (t = r, s = n) : o < 120 ? (t = n, s = r) : o < 180 ? (s = r, d = n) : o < 240 ? (s = n, d = r) : o < 300 ? (t = n, d = r) : (t = r, d = n), {
|
|
39
|
+
r: Math.round((t + h) * 255),
|
|
40
|
+
g: Math.round((s + h) * 255),
|
|
41
|
+
b: Math.round((d + h) * 255)
|
|
42
42
|
};
|
|
43
|
-
},
|
|
44
|
-
const
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
const
|
|
43
|
+
}, U = ({ r: o, g: a, b: m }) => {
|
|
44
|
+
const l = o / 255, c = a / 255, r = m / 255, n = Math.max(l, c, r), h = Math.min(l, c, r), t = n - h;
|
|
45
|
+
let s = 0;
|
|
46
|
+
t !== 0 && (n === l ? s = (c - r) / t % 6 : n === c ? s = (r - l) / t + 2 : s = (l - c) / t + 4, s = Math.round(s * 60), s < 0 && (s += 360));
|
|
47
|
+
const d = (n + h) / 2, M = t === 0 ? 0 : t / (1 - Math.abs(2 * d - 1));
|
|
48
48
|
return {
|
|
49
|
-
h:
|
|
49
|
+
h: s,
|
|
50
50
|
s: Math.round(M * 100),
|
|
51
|
-
l: Math.round(
|
|
51
|
+
l: Math.round(d * 100)
|
|
52
52
|
};
|
|
53
|
-
}, T = ({ h:
|
|
54
|
-
const
|
|
55
|
-
let
|
|
56
|
-
return
|
|
57
|
-
r: Math.round((
|
|
58
|
-
g: Math.round((
|
|
59
|
-
b: Math.round((
|
|
53
|
+
}, T = ({ h: o, s: a, l: m }) => {
|
|
54
|
+
const l = a / 100, c = m / 100, r = (1 - Math.abs(2 * c - 1)) * l, n = r * (1 - Math.abs(o / 60 % 2 - 1)), h = c - r / 2;
|
|
55
|
+
let t = 0, s = 0, d = 0;
|
|
56
|
+
return o < 60 ? (t = r, s = n) : o < 120 ? (t = n, s = r) : o < 180 ? (s = r, d = n) : o < 240 ? (s = n, d = r) : o < 300 ? (t = n, d = r) : (t = r, d = n), {
|
|
57
|
+
r: Math.round((t + h) * 255),
|
|
58
|
+
g: Math.round((s + h) * 255),
|
|
59
|
+
b: Math.round((d + h) * 255)
|
|
60
60
|
};
|
|
61
|
-
},
|
|
62
|
-
const [
|
|
61
|
+
}, ee = ({ value: o = "#4e79a7", onChange: a, swatches: m, swatchesLabel: l = "Already in use", bare: c = !1 }) => {
|
|
62
|
+
const [r, n] = y("hex"), h = F(() => {
|
|
63
63
|
const e = /* @__PURE__ */ new Set();
|
|
64
|
-
return (
|
|
64
|
+
return (m ?? []).forEach((p) => {
|
|
65
65
|
const u = x(p);
|
|
66
66
|
u && e.add(R(u));
|
|
67
67
|
}), [...e];
|
|
68
|
-
}, [
|
|
69
|
-
const e = x(
|
|
68
|
+
}, [m]), [t, s] = y(() => {
|
|
69
|
+
const e = x(o) || {
|
|
70
70
|
r: 78,
|
|
71
71
|
g: 121,
|
|
72
72
|
b: 167
|
|
73
73
|
};
|
|
74
74
|
return v(e);
|
|
75
|
-
}), [
|
|
76
|
-
|
|
77
|
-
const e = x(
|
|
78
|
-
e && (
|
|
79
|
-
}, [
|
|
75
|
+
}), [d, M] = y(() => x(o) ? L(o) : null), S = I(null), $ = I(t);
|
|
76
|
+
$.current = t, A(() => {
|
|
77
|
+
const e = x(o);
|
|
78
|
+
e && (s(v(e)), M(L(o)));
|
|
79
|
+
}, [o]);
|
|
80
80
|
const g = (e) => {
|
|
81
81
|
const p = {
|
|
82
82
|
h: k(e.h, 0, 360),
|
|
83
83
|
s: k(e.s, 0, 100),
|
|
84
84
|
v: k(e.v, 0, 100)
|
|
85
85
|
};
|
|
86
|
-
|
|
86
|
+
s(p), M(null);
|
|
87
87
|
const u = R(E(p));
|
|
88
|
-
|
|
89
|
-
},
|
|
88
|
+
a?.(u);
|
|
89
|
+
}, j = (e) => {
|
|
90
90
|
const p = x(e);
|
|
91
|
-
p && (
|
|
92
|
-
},
|
|
93
|
-
const u =
|
|
91
|
+
p && (s(v(p)), M(L(e)), a?.(e));
|
|
92
|
+
}, B = (e, p) => {
|
|
93
|
+
const u = S.current?.getBoundingClientRect();
|
|
94
94
|
if (!u) return;
|
|
95
|
-
const w = k(e - u.left, 0, u.width),
|
|
95
|
+
const w = k(e - u.left, 0, u.width), z = k(p - u.top, 0, u.height), D = Math.round(w / u.width * 100), G = Math.round(100 - z / u.height * 100);
|
|
96
96
|
g({
|
|
97
|
-
h:
|
|
98
|
-
s:
|
|
99
|
-
v:
|
|
97
|
+
h: $.current.h,
|
|
98
|
+
s: D,
|
|
99
|
+
v: G
|
|
100
100
|
});
|
|
101
|
-
},
|
|
101
|
+
}, P = (e) => {
|
|
102
102
|
e.preventDefault();
|
|
103
103
|
try {
|
|
104
104
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
105
105
|
} catch {
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
const p = (w) =>
|
|
107
|
+
B(e.clientX, e.clientY);
|
|
108
|
+
const p = (w) => B(w.clientX, w.clientY), u = () => {
|
|
109
109
|
window.removeEventListener("pointermove", p), window.removeEventListener("pointerup", u), window.removeEventListener("pointercancel", u);
|
|
110
110
|
};
|
|
111
111
|
window.addEventListener("pointermove", p), window.addEventListener("pointerup", u), window.addEventListener("pointercancel", u);
|
|
112
|
-
}, f =
|
|
112
|
+
}, f = d ? x(d) ?? E(t) : E(t), C = d ?? R(f), _ = U(f);
|
|
113
113
|
return /* @__PURE__ */ b("div", {
|
|
114
|
-
className: "color-picker"
|
|
114
|
+
className: `color-picker${c ? " color-picker--bare" : ""}`,
|
|
115
115
|
children: [
|
|
116
|
-
|
|
116
|
+
h.length > 0 && /* @__PURE__ */ b("div", {
|
|
117
117
|
className: "color-picker__swatches",
|
|
118
|
-
children: [/* @__PURE__ */
|
|
118
|
+
children: [/* @__PURE__ */ i("span", {
|
|
119
119
|
className: "color-picker__swatches-label",
|
|
120
|
-
children:
|
|
121
|
-
}), /* @__PURE__ */
|
|
120
|
+
children: l
|
|
121
|
+
}), /* @__PURE__ */ i("div", {
|
|
122
122
|
className: "color-picker__swatches-row",
|
|
123
|
-
children:
|
|
123
|
+
children: h.map((e) => /* @__PURE__ */ i(X, {
|
|
124
124
|
title: e,
|
|
125
|
-
children: /* @__PURE__ */
|
|
125
|
+
children: /* @__PURE__ */ i("button", {
|
|
126
126
|
className: `color-picker__swatch${e === C.toLowerCase() ? " is-selected" : ""}`,
|
|
127
|
-
onClick: () =>
|
|
127
|
+
onClick: () => j(e),
|
|
128
128
|
style: { backgroundColor: e },
|
|
129
129
|
type: "button"
|
|
130
130
|
})
|
|
131
131
|
}, e))
|
|
132
132
|
})]
|
|
133
133
|
}),
|
|
134
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ i("div", {
|
|
135
135
|
className: "color-picker__preview",
|
|
136
136
|
style: { backgroundColor: C }
|
|
137
137
|
}),
|
|
@@ -139,29 +139,29 @@ var k = (t, i, h) => Math.min(h, Math.max(i, t)), x = (t) => {
|
|
|
139
139
|
className: "color-picker__controls",
|
|
140
140
|
children: [/* @__PURE__ */ b("div", {
|
|
141
141
|
className: "color-picker__sv",
|
|
142
|
-
ref:
|
|
143
|
-
style: { backgroundColor: `hsl(${
|
|
144
|
-
onPointerDown:
|
|
142
|
+
ref: S,
|
|
143
|
+
style: { backgroundColor: `hsl(${t.h}, 100%, 50%)` },
|
|
144
|
+
onPointerDown: P,
|
|
145
145
|
children: [
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */
|
|
146
|
+
/* @__PURE__ */ i("div", { className: "color-picker__sv-white" }),
|
|
147
|
+
/* @__PURE__ */ i("div", { className: "color-picker__sv-black" }),
|
|
148
|
+
/* @__PURE__ */ i("div", {
|
|
149
149
|
className: "color-picker__sv-handle",
|
|
150
150
|
style: {
|
|
151
|
-
left: `${
|
|
152
|
-
top: `${100 -
|
|
151
|
+
left: `${t.s}%`,
|
|
152
|
+
top: `${100 - t.v}%`
|
|
153
153
|
}
|
|
154
154
|
})
|
|
155
155
|
]
|
|
156
|
-
}), /* @__PURE__ */
|
|
156
|
+
}), /* @__PURE__ */ i("div", {
|
|
157
157
|
className: "color-picker__slider",
|
|
158
|
-
children: /* @__PURE__ */
|
|
158
|
+
children: /* @__PURE__ */ i("input", {
|
|
159
159
|
type: "range",
|
|
160
160
|
min: 0,
|
|
161
161
|
max: 360,
|
|
162
|
-
value:
|
|
162
|
+
value: t.h,
|
|
163
163
|
onChange: (e) => g({
|
|
164
|
-
...
|
|
164
|
+
...t,
|
|
165
165
|
h: Number(e.target.value)
|
|
166
166
|
})
|
|
167
167
|
})
|
|
@@ -170,40 +170,40 @@ var k = (t, i, h) => Math.min(h, Math.max(i, t)), x = (t) => {
|
|
|
170
170
|
/* @__PURE__ */ b("div", {
|
|
171
171
|
className: "color-picker__mode-toggle",
|
|
172
172
|
children: [
|
|
173
|
-
/* @__PURE__ */
|
|
173
|
+
/* @__PURE__ */ i(H, {
|
|
174
174
|
variant: "plain",
|
|
175
|
-
className:
|
|
176
|
-
onClick: () =>
|
|
175
|
+
className: r === "hex" ? "is-active" : "",
|
|
176
|
+
onClick: () => n("hex"),
|
|
177
177
|
children: "Hex"
|
|
178
178
|
}),
|
|
179
|
-
/* @__PURE__ */
|
|
179
|
+
/* @__PURE__ */ i(H, {
|
|
180
180
|
variant: "plain",
|
|
181
|
-
className:
|
|
182
|
-
onClick: () =>
|
|
181
|
+
className: r === "rgb" ? "is-active" : "",
|
|
182
|
+
onClick: () => n("rgb"),
|
|
183
183
|
children: "RGB"
|
|
184
184
|
}),
|
|
185
|
-
/* @__PURE__ */
|
|
185
|
+
/* @__PURE__ */ i(H, {
|
|
186
186
|
variant: "plain",
|
|
187
|
-
className:
|
|
188
|
-
onClick: () =>
|
|
187
|
+
className: r === "hsl" ? "is-active" : "",
|
|
188
|
+
onClick: () => n("hsl"),
|
|
189
189
|
children: "HSL"
|
|
190
190
|
})
|
|
191
191
|
]
|
|
192
192
|
}),
|
|
193
|
-
|
|
193
|
+
r === "hex" && /* @__PURE__ */ i("div", {
|
|
194
194
|
className: "color-picker__fields color-picker__fields--hex",
|
|
195
|
-
children: /* @__PURE__ */
|
|
195
|
+
children: /* @__PURE__ */ i(Y, {
|
|
196
196
|
label: "Hex",
|
|
197
197
|
value: C,
|
|
198
198
|
onChange: (e) => {
|
|
199
|
-
x(e) &&
|
|
199
|
+
x(e) && j(e.startsWith("#") ? e : `#${e}`);
|
|
200
200
|
}
|
|
201
201
|
})
|
|
202
202
|
}),
|
|
203
|
-
|
|
203
|
+
r === "rgb" && /* @__PURE__ */ b("div", {
|
|
204
204
|
className: "color-picker__fields color-picker__fields--rgb",
|
|
205
205
|
children: [
|
|
206
|
-
/* @__PURE__ */
|
|
206
|
+
/* @__PURE__ */ i(N, {
|
|
207
207
|
label: "R",
|
|
208
208
|
min: 0,
|
|
209
209
|
max: 255,
|
|
@@ -213,7 +213,7 @@ var k = (t, i, h) => Math.min(h, Math.max(i, t)), x = (t) => {
|
|
|
213
213
|
r: e ?? 0
|
|
214
214
|
}))
|
|
215
215
|
}),
|
|
216
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ i(N, {
|
|
217
217
|
label: "G",
|
|
218
218
|
min: 0,
|
|
219
219
|
max: 255,
|
|
@@ -223,7 +223,7 @@ var k = (t, i, h) => Math.min(h, Math.max(i, t)), x = (t) => {
|
|
|
223
223
|
g: e ?? 0
|
|
224
224
|
}))
|
|
225
225
|
}),
|
|
226
|
-
/* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ i(N, {
|
|
227
227
|
label: "B",
|
|
228
228
|
min: 0,
|
|
229
229
|
max: 255,
|
|
@@ -235,10 +235,10 @@ var k = (t, i, h) => Math.min(h, Math.max(i, t)), x = (t) => {
|
|
|
235
235
|
})
|
|
236
236
|
]
|
|
237
237
|
}),
|
|
238
|
-
|
|
238
|
+
r === "hsl" && /* @__PURE__ */ b("div", {
|
|
239
239
|
className: "color-picker__fields color-picker__fields--hsl",
|
|
240
240
|
children: [
|
|
241
|
-
/* @__PURE__ */
|
|
241
|
+
/* @__PURE__ */ i(N, {
|
|
242
242
|
label: "H",
|
|
243
243
|
min: 0,
|
|
244
244
|
max: 360,
|
|
@@ -251,7 +251,7 @@ var k = (t, i, h) => Math.min(h, Math.max(i, t)), x = (t) => {
|
|
|
251
251
|
g(v(p));
|
|
252
252
|
}
|
|
253
253
|
}),
|
|
254
|
-
/* @__PURE__ */
|
|
254
|
+
/* @__PURE__ */ i(N, {
|
|
255
255
|
label: "S",
|
|
256
256
|
min: 0,
|
|
257
257
|
max: 100,
|
|
@@ -264,7 +264,7 @@ var k = (t, i, h) => Math.min(h, Math.max(i, t)), x = (t) => {
|
|
|
264
264
|
g(v(p));
|
|
265
265
|
}
|
|
266
266
|
}),
|
|
267
|
-
/* @__PURE__ */
|
|
267
|
+
/* @__PURE__ */ i(N, {
|
|
268
268
|
label: "L",
|
|
269
269
|
min: 0,
|
|
270
270
|
max: 100,
|
|
@@ -283,5 +283,5 @@ var k = (t, i, h) => Math.min(h, Math.max(i, t)), x = (t) => {
|
|
|
283
283
|
});
|
|
284
284
|
};
|
|
285
285
|
export {
|
|
286
|
-
|
|
286
|
+
ee as ColorPicker
|
|
287
287
|
};
|
|
@@ -1,53 +1,66 @@
|
|
|
1
1
|
import './ContextMenu.css';
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { useEffect as M, useRef as k, useState as p } from "react";
|
|
4
|
+
import { Fragment as F, jsx as x, jsxs as E } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as H } from "react-dom";
|
|
6
|
+
var f = (n, t) => t ? {
|
|
7
|
+
top: t.y,
|
|
8
|
+
bottom: t.y,
|
|
9
|
+
left: t.x
|
|
10
|
+
} : n ? n.getBoundingClientRect() : null, A = ({ target: n, position: t, onClose: d, children: h, autoClose: y = !1 }) => {
|
|
11
|
+
const c = k(null), [b, v] = p(!1), [w, g] = p(() => {
|
|
12
|
+
const i = f(n, t);
|
|
13
|
+
return i ? {
|
|
14
|
+
top: `${i.bottom}px`,
|
|
15
|
+
left: `${i.left}px`,
|
|
13
16
|
opacity: 0
|
|
17
|
+
} : { opacity: 0 };
|
|
18
|
+
}), u = t?.x, s = t?.y;
|
|
19
|
+
M(() => {
|
|
20
|
+
const i = u === void 0 || s === void 0 ? null : {
|
|
21
|
+
x: u,
|
|
22
|
+
y: s
|
|
14
23
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!e || !c.current) return;
|
|
18
|
-
const n = requestAnimationFrame(() => {
|
|
24
|
+
if (!f(n, i) || !c.current) return;
|
|
25
|
+
const $ = requestAnimationFrame(() => {
|
|
19
26
|
if (!c.current) return;
|
|
20
|
-
const m =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
const m = f(n, i);
|
|
28
|
+
if (!m) return;
|
|
29
|
+
const l = c.current.getBoundingClientRect(), a = document.documentElement.clientWidth || window.innerWidth, C = document.documentElement.clientHeight || window.innerHeight, e = 8;
|
|
30
|
+
let o = m.bottom, r = m.left;
|
|
31
|
+
r + l.width > a - e && (r = Math.max(e, a - l.width - e)), r < e && (r = e), o + l.height > C - e && (o = Math.max(e, m.top - l.height)), o < e && (o = e), g({
|
|
32
|
+
top: `${o}px`,
|
|
33
|
+
left: `${r}px`,
|
|
25
34
|
opacity: 1
|
|
26
|
-
}),
|
|
35
|
+
}), v(!0);
|
|
27
36
|
});
|
|
28
37
|
return () => {
|
|
29
|
-
cancelAnimationFrame(
|
|
38
|
+
cancelAnimationFrame($);
|
|
30
39
|
};
|
|
31
|
-
}, [
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
}, [
|
|
41
|
+
n,
|
|
42
|
+
u,
|
|
43
|
+
s
|
|
44
|
+
]);
|
|
45
|
+
const R = (i) => {
|
|
46
|
+
y && d?.();
|
|
34
47
|
};
|
|
35
|
-
return
|
|
48
|
+
return !n && !t ? null : H(/* @__PURE__ */ E(F, { children: [/* @__PURE__ */ x("div", {
|
|
36
49
|
style: {
|
|
37
50
|
position: "fixed",
|
|
38
51
|
inset: 0,
|
|
39
52
|
zIndex: 1190
|
|
40
53
|
},
|
|
41
54
|
className: "memobit-context-menu-back-drop",
|
|
42
|
-
onClick:
|
|
43
|
-
}), /* @__PURE__ */
|
|
55
|
+
onClick: d
|
|
56
|
+
}), /* @__PURE__ */ x("div", {
|
|
44
57
|
ref: c,
|
|
45
|
-
className: `memobit-context-menu ${
|
|
46
|
-
style:
|
|
47
|
-
onClick:
|
|
48
|
-
children:
|
|
49
|
-
})] }), document.body)
|
|
58
|
+
className: `memobit-context-menu ${b ? "memobit-context-menu--visible" : ""}`,
|
|
59
|
+
style: w,
|
|
60
|
+
onClick: R,
|
|
61
|
+
children: h
|
|
62
|
+
})] }), document.body);
|
|
50
63
|
};
|
|
51
64
|
export {
|
|
52
|
-
|
|
65
|
+
A as ContextMenu
|
|
53
66
|
};
|