melonykit 1.2.0 → 1.3.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/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as getClientSetting, i as routeTo, t as setClientSetting, r as useQuery } from "./browser-
|
|
1
|
+
export { n as getClientSetting, i as routeTo, t as setClientSetting, r as useQuery } from "./browser-KHAcpg01.js";
|
|
@@ -175,8 +175,16 @@ function g(e) {
|
|
|
175
175
|
return n(e) ? e.split("-").filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "";
|
|
176
176
|
}
|
|
177
177
|
//#endregion
|
|
178
|
+
//#region src/functions/_median.js
|
|
179
|
+
function _(e) {
|
|
180
|
+
if (!Array.isArray(e) || e.length === 0) return null;
|
|
181
|
+
for (let t of e) if (!Number.isFinite(t)) return null;
|
|
182
|
+
let t = [...e].sort((e, t) => e - t), n = Math.floor(t.length / 2);
|
|
183
|
+
return t.length % 2 == 0 ? (t[n - 1] + t[n]) / 2 : t[n];
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
178
186
|
//#region src/functions/_request.js
|
|
179
|
-
async function
|
|
187
|
+
async function v({ url: e, body: t, method: n = "POST", headers: r = {} } = {}) {
|
|
180
188
|
let i = n !== "GET" && t !== void 0 ? JSON.stringify(t) : void 0, a = await fetch(e, {
|
|
181
189
|
method: n,
|
|
182
190
|
headers: {
|
|
@@ -196,18 +204,31 @@ async function _({ url: e, body: t, method: n = "POST", headers: r = {} } = {})
|
|
|
196
204
|
return a.ok || (s.error = s.data ?? /* @__PURE__ */ Error(`Request failed with status ${a.status}.`)), s;
|
|
197
205
|
}
|
|
198
206
|
//#endregion
|
|
207
|
+
//#region src/functions/checks/_is-number.js
|
|
208
|
+
function y(e) {
|
|
209
|
+
return typeof e == "number" && Number.isFinite(e);
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/functions/_risk-reward.js
|
|
213
|
+
function b(e = {}) {
|
|
214
|
+
let { entry: t, exit: n, riskRatio: r = 20 } = e ?? {};
|
|
215
|
+
if (!y(t) || t <= 0 || !y(n) || n <= 0 || !y(r) || r <= 0) return null;
|
|
216
|
+
let i = (n - t) / t / (r / 100);
|
|
217
|
+
return Math.round(i * 10) / 10;
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
199
220
|
//#region src/functions/_size.js
|
|
200
|
-
function
|
|
221
|
+
function x(e) {
|
|
201
222
|
return e == null ? 0 : Array.isArray(e) || typeof e == "string" ? e.length : typeof e == "object" || typeof e == "function" ? Object.keys(e).length : 0;
|
|
202
223
|
}
|
|
203
224
|
//#endregion
|
|
204
225
|
//#region src/functions/_slugify.js
|
|
205
|
-
function
|
|
226
|
+
function S(e) {
|
|
206
227
|
return typeof e == "string" ? e.trim().toLowerCase().replace(/ä/g, "ae").replace(/ö/g, "oe").replace(/ü/g, "ue").replace(/ß/g, "ss").replace(/æ/g, "ae").replace(/œ/g, "oe").replace(/ø/g, "o").normalize("NFD").replace(/\p{Diacritic}/gu, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") : "";
|
|
207
228
|
}
|
|
208
229
|
//#endregion
|
|
209
230
|
//#region src/functions/_to-number.js
|
|
210
|
-
function
|
|
231
|
+
function C(e, t = null) {
|
|
211
232
|
let n = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
|
|
212
233
|
if (!Number.isFinite(n)) return null;
|
|
213
234
|
if (t == null) return n;
|
|
@@ -216,32 +237,27 @@ function b(e, t = null) {
|
|
|
216
237
|
}
|
|
217
238
|
//#endregion
|
|
218
239
|
//#region src/functions/checks/_is-array.js
|
|
219
|
-
function
|
|
240
|
+
function w(e) {
|
|
220
241
|
return Array.isArray(e);
|
|
221
242
|
}
|
|
222
243
|
//#endregion
|
|
223
244
|
//#region src/functions/checks/_is-empty-array.js
|
|
224
|
-
function
|
|
225
|
-
return
|
|
245
|
+
function T(e) {
|
|
246
|
+
return w(e) && e.length === 0;
|
|
226
247
|
}
|
|
227
248
|
//#endregion
|
|
228
249
|
//#region src/functions/checks/_is-function.js
|
|
229
|
-
function
|
|
250
|
+
function E(e) {
|
|
230
251
|
return typeof e == "function";
|
|
231
252
|
}
|
|
232
253
|
//#endregion
|
|
233
|
-
//#region src/functions/checks/_is-number.js
|
|
234
|
-
function w(e) {
|
|
235
|
-
return typeof e == "number" && Number.isFinite(e);
|
|
236
|
-
}
|
|
237
|
-
//#endregion
|
|
238
254
|
//#region src/functions/checks/_is-positive-number.js
|
|
239
|
-
function
|
|
240
|
-
return
|
|
255
|
+
function D(e) {
|
|
256
|
+
return y(e) && e > 0;
|
|
241
257
|
}
|
|
242
258
|
//#endregion
|
|
243
259
|
//#region src/functions/_create-cache.js
|
|
244
|
-
function
|
|
260
|
+
function O({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
|
|
245
261
|
let i = /* @__PURE__ */ new Map();
|
|
246
262
|
async function a(t, n) {
|
|
247
263
|
if (i.has(t)) return !1;
|
|
@@ -250,12 +266,12 @@ function E({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
|
|
|
250
266
|
...n,
|
|
251
267
|
createdAt: r,
|
|
252
268
|
lastUpdate: r
|
|
253
|
-
}),
|
|
269
|
+
}), E(e) && await e(t), !0;
|
|
254
270
|
}
|
|
255
271
|
async function o(e, n) {
|
|
256
272
|
if (!i.has(e) || typeof n != "function") return !1;
|
|
257
273
|
let r = i.get(e);
|
|
258
|
-
return await n(r), r.lastUpdate = Date.now(),
|
|
274
|
+
return await n(r), r.lastUpdate = Date.now(), E(t) && await t(e), !0;
|
|
259
275
|
}
|
|
260
276
|
function s(e) {
|
|
261
277
|
return i.get(e) ?? null;
|
|
@@ -272,10 +288,10 @@ function E({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
|
|
|
272
288
|
async function d(e) {
|
|
273
289
|
if (!i.has(e)) return !1;
|
|
274
290
|
let t = i.get(e);
|
|
275
|
-
return i.delete(e),
|
|
291
|
+
return i.delete(e), E(n) && await n(e, t), !0;
|
|
276
292
|
}
|
|
277
293
|
function f({ interval: e, checks: t, now: n = Date.now, setIntervalFn: r = setInterval } = {}) {
|
|
278
|
-
|
|
294
|
+
D(e) && w(t) && !T(t) && t.every((e) => E(e)) && E(n) && E(r) && r(async () => {
|
|
279
295
|
let e = n();
|
|
280
296
|
for (let [n, r] of i) t.some((t) => t(r, e)) && await d(n);
|
|
281
297
|
}, e)?.unref?.();
|
|
@@ -292,28 +308,28 @@ function E({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
|
|
|
292
308
|
}
|
|
293
309
|
//#endregion
|
|
294
310
|
//#region src/functions/checks/_is-nil.js
|
|
295
|
-
function
|
|
311
|
+
function k(e) {
|
|
296
312
|
return e == null;
|
|
297
313
|
}
|
|
298
314
|
//#endregion
|
|
299
315
|
//#region src/functions/checks/_is-object.js
|
|
300
|
-
function
|
|
301
|
-
return !
|
|
316
|
+
function A(e) {
|
|
317
|
+
return !k(e) && typeof e == "object" && !w(e);
|
|
302
318
|
}
|
|
303
319
|
//#endregion
|
|
304
320
|
//#region src/functions/checks/_is-empty-object.js
|
|
305
|
-
function
|
|
306
|
-
return
|
|
321
|
+
function j(e) {
|
|
322
|
+
return A(e) && Reflect.ownKeys(e).every((t) => !Object.prototype.propertyIsEnumerable.call(e, t));
|
|
307
323
|
}
|
|
308
324
|
//#endregion
|
|
309
325
|
//#region src/functions/checks/_is-empty-string.js
|
|
310
|
-
function
|
|
326
|
+
function M(e) {
|
|
311
327
|
return n(e) && e.trim().length === 0;
|
|
312
328
|
}
|
|
313
329
|
//#endregion
|
|
314
330
|
//#region src/functions/checks/_is-negative-number.js
|
|
315
|
-
function
|
|
316
|
-
return
|
|
331
|
+
function N(e) {
|
|
332
|
+
return y(e) && e < 0;
|
|
317
333
|
}
|
|
318
334
|
//#endregion
|
|
319
|
-
export {
|
|
335
|
+
export { t as C, n as S, _, k as a, i as b, E as c, C as d, S as f, v as g, y as h, A as i, T as l, b as m, M as n, O as o, x as p, j as r, D as s, N as t, w as u, g as v, r as x, d as y };
|
package/dist/functions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { x as camelCaseToTitleCase, C as convertHexToRgba, o as createCache, b as darkenHexColor, y as formatDate, u as isArray, l as isEmptyArray, r as isEmptyObject, n as isEmptyString, c as isFunction, t as isNegativeNumber, a as isNil, h as isNumber, i as isObject, s as isPositiveNumber, S as isString, v as kebabCaseToTitleCase, _ as median, g as request, m as riskReward, p as size, f as slugify, d as toNumber } from "./functions-Bh4m_uhq.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as e, t } from "./browser-
|
|
2
|
-
import { n,
|
|
1
|
+
import { n as e, t } from "./browser-KHAcpg01.js";
|
|
2
|
+
import { b as n, n as r } from "./functions-Bh4m_uhq.js";
|
|
3
3
|
import { useSignal as i } from "@preact/signals";
|
|
4
4
|
import { useEffect as a, useId as o, useRef as s } from "preact/hooks";
|
|
5
5
|
import { Fragment as c, jsx as l, jsxs as u } from "preact/jsx-runtime";
|
|
@@ -1009,84 +1009,84 @@ var At = {
|
|
|
1009
1009
|
};
|
|
1010
1010
|
//#endregion
|
|
1011
1011
|
//#region src/components/_button.jsx
|
|
1012
|
-
function jt({ type: e = "primary", label: t, iconName: n, isDisabled: r = !1, isLoading: a = !1,
|
|
1013
|
-
let
|
|
1014
|
-
function
|
|
1012
|
+
function jt({ type: e = "primary", label: t, iconName: n, isDisabled: r = !1, isLoading: a = !1, confirmation: o, onClick: s }) {
|
|
1013
|
+
let d = i(!1), f = d.value, p = f ? "cursor-question" : n, m = p || a, h = m && !t, g = i(null), _ = i(0), v = g.value, y = !!o, b = (y || !!s) && !r && !a && !f;
|
|
1014
|
+
function x(e) {
|
|
1015
1015
|
if (r || a) return;
|
|
1016
1016
|
e.stopPropagation(), e.preventDefault();
|
|
1017
1017
|
let t = e.currentTarget.getBoundingClientRect();
|
|
1018
|
-
|
|
1019
|
-
id:
|
|
1018
|
+
_.value += 1, g.value = {
|
|
1019
|
+
id: _.value,
|
|
1020
1020
|
x: e.clientX - t.left,
|
|
1021
1021
|
y: e.clientY - t.top,
|
|
1022
1022
|
size: Math.max(t.width, t.height) * 2
|
|
1023
|
-
},
|
|
1023
|
+
}, y ? d.value = !0 : s?.(e);
|
|
1024
1024
|
}
|
|
1025
|
-
function
|
|
1026
|
-
|
|
1025
|
+
function S(e) {
|
|
1026
|
+
d.value = !1, o?.onCancel?.(e);
|
|
1027
1027
|
}
|
|
1028
|
-
function
|
|
1029
|
-
|
|
1028
|
+
function C(e) {
|
|
1029
|
+
d.value = !1, (o?.onConfirm ?? s)?.(e);
|
|
1030
1030
|
}
|
|
1031
|
-
let
|
|
1031
|
+
let ee = /* @__PURE__ */ u("button", {
|
|
1032
1032
|
type: "button",
|
|
1033
1033
|
className: D(Nt.base, Nt[e] ?? Nt.neutral),
|
|
1034
|
-
"has-icon":
|
|
1035
|
-
"is-icon-only":
|
|
1036
|
-
"is-disabled": r ||
|
|
1034
|
+
"has-icon": m,
|
|
1035
|
+
"is-icon-only": h || void 0,
|
|
1036
|
+
"is-disabled": r || f || void 0,
|
|
1037
1037
|
"is-loading": a || void 0,
|
|
1038
|
-
"is-clickable":
|
|
1039
|
-
disabled: r || a ||
|
|
1040
|
-
onClick:
|
|
1038
|
+
"is-clickable": b || void 0,
|
|
1039
|
+
disabled: r || a || f,
|
|
1040
|
+
onClick: b ? x : void 0,
|
|
1041
1041
|
children: [
|
|
1042
|
-
|
|
1042
|
+
m && /* @__PURE__ */ l(c, { children: /* @__PURE__ */ l("div", {
|
|
1043
1043
|
className: Nt.icon,
|
|
1044
1044
|
children: a ? /* @__PURE__ */ l(wt, {
|
|
1045
1045
|
iconName: "loader",
|
|
1046
1046
|
isSpinning: !0,
|
|
1047
1047
|
size: "1rem"
|
|
1048
1048
|
}) : /* @__PURE__ */ l(wt, {
|
|
1049
|
-
iconName:
|
|
1049
|
+
iconName: p,
|
|
1050
1050
|
size: "1rem"
|
|
1051
1051
|
})
|
|
1052
1052
|
}) }),
|
|
1053
1053
|
t,
|
|
1054
|
-
|
|
1054
|
+
v && /* @__PURE__ */ l(c, { children: /* @__PURE__ */ l("span", {
|
|
1055
1055
|
className: Nt.ripple,
|
|
1056
1056
|
style: `
|
|
1057
|
-
left: ${
|
|
1058
|
-
top: ${
|
|
1059
|
-
width: ${
|
|
1060
|
-
height: ${
|
|
1057
|
+
left: ${v.x}px;
|
|
1058
|
+
top: ${v.y}px;
|
|
1059
|
+
width: ${v.size}px;
|
|
1060
|
+
height: ${v.size}px;
|
|
1061
1061
|
`,
|
|
1062
1062
|
onAnimationEnd: () => {
|
|
1063
|
-
|
|
1063
|
+
g.value?.id === v.id && (g.value = null);
|
|
1064
1064
|
}
|
|
1065
|
-
},
|
|
1065
|
+
}, v.id) })
|
|
1066
1066
|
]
|
|
1067
1067
|
});
|
|
1068
|
-
return
|
|
1068
|
+
return y ? /* @__PURE__ */ l(c, { children: /* @__PURE__ */ u(Ot, {
|
|
1069
1069
|
className: Nt.confirmation,
|
|
1070
|
-
trigger:
|
|
1071
|
-
isOpen:
|
|
1070
|
+
trigger: ee,
|
|
1071
|
+
isOpen: d.value,
|
|
1072
1072
|
origin: "bottom",
|
|
1073
|
-
width:
|
|
1073
|
+
width: o.width,
|
|
1074
1074
|
children: [/* @__PURE__ */ l(Et, {
|
|
1075
1075
|
size: "small",
|
|
1076
|
-
children:
|
|
1076
|
+
children: o.text
|
|
1077
1077
|
}), /* @__PURE__ */ u("div", {
|
|
1078
1078
|
className: Nt.confirmationActions,
|
|
1079
1079
|
children: [/* @__PURE__ */ l(jt, {
|
|
1080
1080
|
type: "neutral",
|
|
1081
1081
|
label: "Abbrechen",
|
|
1082
|
-
onClick:
|
|
1082
|
+
onClick: S
|
|
1083
1083
|
}), /* @__PURE__ */ l(jt, {
|
|
1084
1084
|
type: "secondary",
|
|
1085
1085
|
label: "Bestätigen",
|
|
1086
|
-
onClick:
|
|
1086
|
+
onClick: C
|
|
1087
1087
|
})]
|
|
1088
1088
|
})]
|
|
1089
|
-
}) }) : /* @__PURE__ */ l(c, { children:
|
|
1089
|
+
}) }) : /* @__PURE__ */ l(c, { children: ee });
|
|
1090
1090
|
}
|
|
1091
1091
|
var Mt = bt`
|
|
1092
1092
|
from {
|
|
@@ -1146,7 +1146,7 @@ var Mt = bt`
|
|
|
1146
1146
|
`,
|
|
1147
1147
|
secondary: O`
|
|
1148
1148
|
color: ${k.colors.fore.primary};
|
|
1149
|
-
border-color: ${
|
|
1149
|
+
border-color: ${n(k.colors.secondary, .2)};
|
|
1150
1150
|
background-color: ${k.colors.secondary};
|
|
1151
1151
|
`,
|
|
1152
1152
|
neutral: O`
|
|
@@ -1532,15 +1532,15 @@ var Ut = {
|
|
|
1532
1532
|
transition: width .3s ease;
|
|
1533
1533
|
`,
|
|
1534
1534
|
normal: O`
|
|
1535
|
-
border: solid 1px ${
|
|
1535
|
+
border: solid 1px ${n(k.colors.primary, .3)};
|
|
1536
1536
|
background-color: ${k.colors.primary};
|
|
1537
1537
|
`,
|
|
1538
1538
|
warn: O`
|
|
1539
|
-
border: solid 1px ${
|
|
1539
|
+
border: solid 1px ${n(k.colors.secondary, .2)};
|
|
1540
1540
|
background-color: ${k.colors.secondary};
|
|
1541
1541
|
`,
|
|
1542
1542
|
danger: O`
|
|
1543
|
-
border: solid 1px ${
|
|
1543
|
+
border: solid 1px ${n(k.colors.danger, .3)};
|
|
1544
1544
|
background-color: ${k.colors.danger};
|
|
1545
1545
|
`
|
|
1546
1546
|
};
|
|
@@ -1947,7 +1947,7 @@ var an = {
|
|
|
1947
1947
|
height: 1rem;
|
|
1948
1948
|
margin-top: -.375rem;
|
|
1949
1949
|
border-radius: 50%;
|
|
1950
|
-
border: solid 1px ${
|
|
1950
|
+
border: solid 1px ${n(k.colors.primary, .3)};
|
|
1951
1951
|
background-color: ${k.colors.primary};
|
|
1952
1952
|
transition: transform .15s ease;
|
|
1953
1953
|
}
|
|
@@ -2159,7 +2159,7 @@ var ln = bt`
|
|
|
2159
2159
|
--checked-background-color: ${k.colors.primary};
|
|
2160
2160
|
`,
|
|
2161
2161
|
secondary: O`
|
|
2162
|
-
--checked-border-color: ${
|
|
2162
|
+
--checked-border-color: ${n(k.colors.secondary, .2)};
|
|
2163
2163
|
--checked-background-color: ${k.colors.secondary};
|
|
2164
2164
|
`,
|
|
2165
2165
|
input: O`
|
|
@@ -2267,7 +2267,7 @@ var gn = {
|
|
|
2267
2267
|
background-color: ${k.colors.back.secondary};
|
|
2268
2268
|
|
|
2269
2269
|
&:before {
|
|
2270
|
-
border-color: ${
|
|
2270
|
+
border-color: ${n(k.colors.primary, .3)};
|
|
2271
2271
|
background-color: ${k.colors.primary};
|
|
2272
2272
|
transform: translate(${mn}px, -50%);
|
|
2273
2273
|
}
|
|
@@ -2306,16 +2306,16 @@ var gn = {
|
|
|
2306
2306
|
};
|
|
2307
2307
|
//#endregion
|
|
2308
2308
|
//#region src/components/_tag.jsx
|
|
2309
|
-
function _n({ className: e, variant: t = "normal", iconName:
|
|
2309
|
+
function _n({ className: e, variant: t = "normal", iconName: n = "", label: i }) {
|
|
2310
2310
|
return /* @__PURE__ */ l(c, { children: /* @__PURE__ */ u("div", {
|
|
2311
2311
|
className: D(vn.base, vn[t] ?? vn.normal, e),
|
|
2312
|
-
"has-icon": !n
|
|
2313
|
-
children: [
|
|
2312
|
+
"has-icon": !r(n),
|
|
2313
|
+
children: [n && /* @__PURE__ */ l(c, { children: /* @__PURE__ */ l(wt, {
|
|
2314
2314
|
className: O`
|
|
2315
2315
|
${k.extends.verticalCenter}
|
|
2316
2316
|
left: .4rem;
|
|
2317
2317
|
`,
|
|
2318
|
-
iconName:
|
|
2318
|
+
iconName: n,
|
|
2319
2319
|
size: ".9rem"
|
|
2320
2320
|
}) }), i]
|
|
2321
2321
|
}) });
|