flufi-ui 0.0.0-stage → 0.1.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/chunk-6G3G7N5D.js +179 -0
- package/dist/chunk-CE4YXNWV.js +144 -0
- package/dist/chunk-EIYU7IQC.js +79 -0
- package/dist/chunk-PGRDIABO.js +1629 -0
- package/dist/chunk-TUAWAX6H.js +0 -0
- package/dist/common/index.d.ts +27 -0
- package/dist/common/index.js +41 -0
- package/dist/components/index.css +732 -0
- package/dist/components/index.d.ts +368 -0
- package/dist/components/index.js +128 -0
- package/dist/index.css +840 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +229 -0
- package/dist/mime-rhdyiokw.d.ts +60 -0
- package/dist/misc-BNzd_rCz.d.ts +4 -0
- package/dist/style.css +840 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.js +66 -0
- package/package.json +46 -4
- package/README.md +0 -3
|
@@ -0,0 +1,1629 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MOBILE,
|
|
3
|
+
addClass,
|
|
4
|
+
addStyles,
|
|
5
|
+
addTitle,
|
|
6
|
+
joinPathParts,
|
|
7
|
+
removeDuplicates,
|
|
8
|
+
splitFilePath,
|
|
9
|
+
splitPath,
|
|
10
|
+
syncWrap
|
|
11
|
+
} from "./chunk-CE4YXNWV.js";
|
|
12
|
+
import {
|
|
13
|
+
CalendarDate,
|
|
14
|
+
isMaybeLoaded,
|
|
15
|
+
isSignal,
|
|
16
|
+
maybeLoadedIsLoaded,
|
|
17
|
+
maybeLoadedUnwrap,
|
|
18
|
+
resolveMaybeAsyncFunc,
|
|
19
|
+
resolveMaybeFunc,
|
|
20
|
+
resolveSignalish
|
|
21
|
+
} from "./chunk-6G3G7N5D.js";
|
|
22
|
+
|
|
23
|
+
// src/components/Button/Button.tsx
|
|
24
|
+
import { jsx } from "preact/jsx-runtime";
|
|
25
|
+
function Button(props) {
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
"button",
|
|
28
|
+
{
|
|
29
|
+
class: addClass(
|
|
30
|
+
"button",
|
|
31
|
+
props.buttonClass,
|
|
32
|
+
props.variant && `variant-${props.variant}`,
|
|
33
|
+
props.centered && "centered",
|
|
34
|
+
props.extraPadding && "extra-padding",
|
|
35
|
+
props.noPadding && "no-padding",
|
|
36
|
+
props.class
|
|
37
|
+
),
|
|
38
|
+
disabled: props.disabled,
|
|
39
|
+
title: props.title,
|
|
40
|
+
role: props.role,
|
|
41
|
+
tabIndex: props.tabIndex,
|
|
42
|
+
onClick: props.onClick ?? (() => {
|
|
43
|
+
console.warn("text button has no onClick");
|
|
44
|
+
}),
|
|
45
|
+
children: props.children
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function TextButton(props) {
|
|
50
|
+
return /* @__PURE__ */ jsx(Button, { ...props, buttonClass: "text-button" });
|
|
51
|
+
}
|
|
52
|
+
function IconButton(props) {
|
|
53
|
+
return /* @__PURE__ */ jsx(Button, { ...props, buttonClass: "icon-button" });
|
|
54
|
+
}
|
|
55
|
+
function TextIconButton(props) {
|
|
56
|
+
return /* @__PURE__ */ jsx(Button, { ...props, buttonClass: "text-icon-button" });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/components/Button/LinkButton.tsx
|
|
60
|
+
import { jsx as jsx2 } from "preact/jsx-runtime";
|
|
61
|
+
function LinkButton(props) {
|
|
62
|
+
return /* @__PURE__ */ jsx2(
|
|
63
|
+
"a",
|
|
64
|
+
{
|
|
65
|
+
class: addClass(
|
|
66
|
+
"button",
|
|
67
|
+
props.buttonClass,
|
|
68
|
+
props.variant && `variant-${props.variant}`,
|
|
69
|
+
props.centered && "centered",
|
|
70
|
+
props.extraPadding && "extra-padding",
|
|
71
|
+
props.noPadding && "no-padding",
|
|
72
|
+
props.class
|
|
73
|
+
),
|
|
74
|
+
href: props.href,
|
|
75
|
+
onClick: props.onClick,
|
|
76
|
+
role: props.role,
|
|
77
|
+
tabIndex: props.tabIndex,
|
|
78
|
+
children: props.children
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function TextLinkButton(props) {
|
|
83
|
+
return /* @__PURE__ */ jsx2(LinkButton, { ...props, buttonClass: "text-button" });
|
|
84
|
+
}
|
|
85
|
+
function IconLinkButton(props) {
|
|
86
|
+
return /* @__PURE__ */ jsx2(LinkButton, { ...props, buttonClass: "icon-button" });
|
|
87
|
+
}
|
|
88
|
+
function TextIconLinkButton(props) {
|
|
89
|
+
return /* @__PURE__ */ jsx2(LinkButton, { ...props, buttonClass: "text-icon-button" });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/components/CalendarInput/CalendarInput.tsx
|
|
93
|
+
import { useSignal as useSignal3 } from "@preact/signals";
|
|
94
|
+
import { useEffect as useEffect2, useState as useState2 } from "preact/hooks";
|
|
95
|
+
import { Calendar, ChevronLeft, ChevronRight } from "lucide-preact";
|
|
96
|
+
|
|
97
|
+
// src/components/Container/Container.tsx
|
|
98
|
+
import { jsx as jsx3 } from "preact/jsx-runtime";
|
|
99
|
+
var getClasses = (props) => addClass(
|
|
100
|
+
"container",
|
|
101
|
+
props.horizontal && "horizontal",
|
|
102
|
+
props.vertical && "vertical",
|
|
103
|
+
props.no_gap && "no-gap",
|
|
104
|
+
props.text_gap && "text-gap",
|
|
105
|
+
props.extra_gap && "extra-gap",
|
|
106
|
+
props.centered_x && "centered-x",
|
|
107
|
+
props.centered_y && "centered-y",
|
|
108
|
+
props.box && "box",
|
|
109
|
+
props.wrap && "wrap",
|
|
110
|
+
props.class
|
|
111
|
+
);
|
|
112
|
+
function Container(props) {
|
|
113
|
+
return /* @__PURE__ */ jsx3("div", { class: getClasses(props), ...props.other, children: props.children });
|
|
114
|
+
}
|
|
115
|
+
function MainContainer(props) {
|
|
116
|
+
return /* @__PURE__ */ jsx3("main", { class: getClasses(props), ...props.other, children: props.children });
|
|
117
|
+
}
|
|
118
|
+
function HeaderContainer(props) {
|
|
119
|
+
return /* @__PURE__ */ jsx3("header", { class: getClasses(props), ...props.other, children: props.children });
|
|
120
|
+
}
|
|
121
|
+
function FooterContainer(props) {
|
|
122
|
+
return /* @__PURE__ */ jsx3("footer", { class: getClasses(props), ...props.other, children: props.children });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/components/Popout/Popout.tsx
|
|
126
|
+
import { useSignal } from "@preact/signals";
|
|
127
|
+
import { useEffect, useRef, useState } from "preact/hooks";
|
|
128
|
+
import { createPortal } from "preact/compat";
|
|
129
|
+
import { jsx as jsx4, jsxs } from "preact/jsx-runtime";
|
|
130
|
+
function PopoutContainer(props) {
|
|
131
|
+
const open = props.open ?? useSignal(false);
|
|
132
|
+
const [rect, setRect] = useState(null);
|
|
133
|
+
const anchorRef = useRef(null);
|
|
134
|
+
const popoutRef = useRef(null);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (!open)
|
|
137
|
+
return;
|
|
138
|
+
function updateRect() {
|
|
139
|
+
setRect(anchorRef.current?.getBoundingClientRect() ?? null);
|
|
140
|
+
}
|
|
141
|
+
function onPointerDown(e) {
|
|
142
|
+
const target = e.target;
|
|
143
|
+
if (anchorRef.current?.contains(target))
|
|
144
|
+
return;
|
|
145
|
+
if (popoutRef.current?.contains(target))
|
|
146
|
+
return;
|
|
147
|
+
open.value = false;
|
|
148
|
+
}
|
|
149
|
+
function onKeyDown(e) {
|
|
150
|
+
if (e.key === "Escape")
|
|
151
|
+
open.value = false;
|
|
152
|
+
}
|
|
153
|
+
updateRect();
|
|
154
|
+
document.addEventListener("mousedown", onPointerDown);
|
|
155
|
+
document.addEventListener("keydown", onKeyDown);
|
|
156
|
+
window.addEventListener("resize", updateRect);
|
|
157
|
+
window.addEventListener("scroll", updateRect, true);
|
|
158
|
+
return () => {
|
|
159
|
+
document.removeEventListener("mousedown", onPointerDown);
|
|
160
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
161
|
+
window.removeEventListener("resize", updateRect);
|
|
162
|
+
window.removeEventListener("scroll", updateRect, true);
|
|
163
|
+
};
|
|
164
|
+
}, [open]);
|
|
165
|
+
return /* @__PURE__ */ jsxs("div", { ref: anchorRef, class: addClass(
|
|
166
|
+
"popout-container",
|
|
167
|
+
open.value && "open",
|
|
168
|
+
props.class
|
|
169
|
+
), children: [
|
|
170
|
+
props.children,
|
|
171
|
+
open.value && rect && createPortal(
|
|
172
|
+
/* @__PURE__ */ jsx4(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
ref: popoutRef,
|
|
176
|
+
class: addClass(
|
|
177
|
+
"popout",
|
|
178
|
+
MOBILE.value && "mobile-popout",
|
|
179
|
+
props.popoutClass
|
|
180
|
+
),
|
|
181
|
+
style: {
|
|
182
|
+
top: (() => {
|
|
183
|
+
const popoutHeight = popoutRef.current?.getBoundingClientRect().height ?? 0;
|
|
184
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
185
|
+
const spaceAbove = rect.top;
|
|
186
|
+
if (spaceBelow >= popoutHeight + 5 || spaceBelow >= spaceAbove)
|
|
187
|
+
return rect.bottom + 5;
|
|
188
|
+
return rect.top - popoutHeight - 5;
|
|
189
|
+
})(),
|
|
190
|
+
left: rect.left,
|
|
191
|
+
width: rect.width - 2
|
|
192
|
+
},
|
|
193
|
+
children: props.popout()
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
document.body
|
|
197
|
+
)
|
|
198
|
+
] });
|
|
199
|
+
}
|
|
200
|
+
function PopoutTextButton(props) {
|
|
201
|
+
const open = props.open ?? useSignal(false);
|
|
202
|
+
return /* @__PURE__ */ jsx4(PopoutContainer, { ...props, class: addClass(props.class, "popout-button"), open, children: /* @__PURE__ */ jsx4(
|
|
203
|
+
TextButton,
|
|
204
|
+
{
|
|
205
|
+
class: props.buttonClass,
|
|
206
|
+
onClick: () => open.value = !open.peek(),
|
|
207
|
+
disabled: props.disabled,
|
|
208
|
+
extraPadding: props.extraPadding,
|
|
209
|
+
centered: props.centered,
|
|
210
|
+
variant: props.variant,
|
|
211
|
+
title: props.title,
|
|
212
|
+
children: props.children
|
|
213
|
+
}
|
|
214
|
+
) });
|
|
215
|
+
}
|
|
216
|
+
function PopoutIconButton(props) {
|
|
217
|
+
const open = props.open ?? useSignal(false);
|
|
218
|
+
return /* @__PURE__ */ jsx4(PopoutContainer, { ...props, class: addClass(props.class, "popout-button"), open, children: /* @__PURE__ */ jsx4(
|
|
219
|
+
IconButton,
|
|
220
|
+
{
|
|
221
|
+
class: props.buttonClass,
|
|
222
|
+
onClick: () => open.value = !open.peek(),
|
|
223
|
+
disabled: props.disabled,
|
|
224
|
+
extraPadding: props.extraPadding,
|
|
225
|
+
centered: props.centered,
|
|
226
|
+
variant: props.variant,
|
|
227
|
+
title: props.title,
|
|
228
|
+
children: props.children
|
|
229
|
+
}
|
|
230
|
+
) });
|
|
231
|
+
}
|
|
232
|
+
function PopoutTextIconButton(props) {
|
|
233
|
+
const open = props.open ?? useSignal(false);
|
|
234
|
+
return /* @__PURE__ */ jsx4(PopoutContainer, { ...props, class: addClass(props.class, "popout-button"), open, children: /* @__PURE__ */ jsx4(
|
|
235
|
+
TextIconButton,
|
|
236
|
+
{
|
|
237
|
+
class: props.buttonClass,
|
|
238
|
+
onClick: () => open.value = !open.peek(),
|
|
239
|
+
disabled: props.disabled,
|
|
240
|
+
extraPadding: props.extraPadding,
|
|
241
|
+
centered: props.centered,
|
|
242
|
+
variant: props.variant,
|
|
243
|
+
title: props.title,
|
|
244
|
+
children: props.children
|
|
245
|
+
}
|
|
246
|
+
) });
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/components/Input/Input.tsx
|
|
250
|
+
import { useSignal as useSignal2 } from "@preact/signals";
|
|
251
|
+
import { useRef as useRef2 } from "preact/hooks";
|
|
252
|
+
import { jsx as jsx5 } from "preact/jsx-runtime";
|
|
253
|
+
function Input(props) {
|
|
254
|
+
const internalRef = useRef2(null);
|
|
255
|
+
const inputRef = props.inputRef ?? internalRef;
|
|
256
|
+
let value;
|
|
257
|
+
if (props.value == null)
|
|
258
|
+
value = useSignal2("");
|
|
259
|
+
else if (isSignal(props.value))
|
|
260
|
+
value = props.value;
|
|
261
|
+
else
|
|
262
|
+
value = useSignal2(props.value);
|
|
263
|
+
return /* @__PURE__ */ jsx5(
|
|
264
|
+
"input",
|
|
265
|
+
{
|
|
266
|
+
class: addClass(
|
|
267
|
+
"input",
|
|
268
|
+
props.class
|
|
269
|
+
),
|
|
270
|
+
ref: inputRef,
|
|
271
|
+
value: value.value,
|
|
272
|
+
placeholder: props.placeholder,
|
|
273
|
+
onInput: (ev) => {
|
|
274
|
+
value.value = ev.currentTarget.value;
|
|
275
|
+
props.onInput?.(value.peek());
|
|
276
|
+
if (props.dirty)
|
|
277
|
+
props.dirty.value = true;
|
|
278
|
+
},
|
|
279
|
+
onBlur: (ev) => props.onUnFocus?.(ev, value.peek()),
|
|
280
|
+
onKeyDown: (ev) => {
|
|
281
|
+
if (ev.key == "Enter") {
|
|
282
|
+
ev.preventDefault();
|
|
283
|
+
props.onEnter?.(value.peek());
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/components/CalendarInput/CalendarInput.tsx
|
|
291
|
+
import { jsx as jsx6, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
292
|
+
var MONTH_NAMES = [
|
|
293
|
+
"January",
|
|
294
|
+
"February",
|
|
295
|
+
"March",
|
|
296
|
+
"April",
|
|
297
|
+
"May",
|
|
298
|
+
"June",
|
|
299
|
+
"July",
|
|
300
|
+
"August",
|
|
301
|
+
"September",
|
|
302
|
+
"October",
|
|
303
|
+
"November",
|
|
304
|
+
"December"
|
|
305
|
+
];
|
|
306
|
+
var WEEKDAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
|
|
307
|
+
function daysInMonth(year, month) {
|
|
308
|
+
return new Date(year, month, 0).getDate();
|
|
309
|
+
}
|
|
310
|
+
function firstOffset(year, month) {
|
|
311
|
+
return (new Date(year, month - 1, 1).getDay() + 6) % 7;
|
|
312
|
+
}
|
|
313
|
+
function CalendarInput(props) {
|
|
314
|
+
let value;
|
|
315
|
+
if (props.value == null)
|
|
316
|
+
value = useSignal3(null);
|
|
317
|
+
else if (isSignal(props.value))
|
|
318
|
+
value = props.value;
|
|
319
|
+
else
|
|
320
|
+
value = useSignal3(props.value);
|
|
321
|
+
const popoutOpen = useSignal3(false);
|
|
322
|
+
const now = /* @__PURE__ */ new Date();
|
|
323
|
+
const initial = value.peek();
|
|
324
|
+
const [viewYear, setViewYear] = useState2(initial?.year ?? now.getFullYear());
|
|
325
|
+
const [viewMonth, setViewMonth] = useState2(initial?.month ?? now.getMonth() + 1);
|
|
326
|
+
const inputText = useSignal3(value.value?.toString() ?? "");
|
|
327
|
+
function updateView() {
|
|
328
|
+
const parts = (value.peek() ?? CalendarDate.now()).parts;
|
|
329
|
+
setViewYear(parts.year);
|
|
330
|
+
setViewMonth(parts.month);
|
|
331
|
+
}
|
|
332
|
+
useEffect2(() => {
|
|
333
|
+
updateView();
|
|
334
|
+
}, [popoutOpen.value]);
|
|
335
|
+
function commit(next, dontClose, dontSetInput) {
|
|
336
|
+
value.value = next;
|
|
337
|
+
props.onChange?.(value.peek());
|
|
338
|
+
if (!dontSetInput) {
|
|
339
|
+
inputText.value = next?.toDisplayString() ?? "";
|
|
340
|
+
} else {
|
|
341
|
+
updateView();
|
|
342
|
+
}
|
|
343
|
+
if (props.dirty)
|
|
344
|
+
props.dirty.value = true;
|
|
345
|
+
if (!dontClose)
|
|
346
|
+
popoutOpen.value = false;
|
|
347
|
+
}
|
|
348
|
+
function pickDay(day) {
|
|
349
|
+
commit(CalendarDate.fromParts(viewYear, viewMonth, day));
|
|
350
|
+
}
|
|
351
|
+
function stepMonth(delta) {
|
|
352
|
+
let m = viewMonth + delta;
|
|
353
|
+
let y = viewYear;
|
|
354
|
+
if (m < 1) {
|
|
355
|
+
m = 12;
|
|
356
|
+
y -= 1;
|
|
357
|
+
} else if (m > 12) {
|
|
358
|
+
m = 1;
|
|
359
|
+
y += 1;
|
|
360
|
+
}
|
|
361
|
+
setViewMonth(m);
|
|
362
|
+
setViewYear(y);
|
|
363
|
+
}
|
|
364
|
+
const selected = value.value;
|
|
365
|
+
const cells = [
|
|
366
|
+
...Array(firstOffset(viewYear, viewMonth)).fill(null),
|
|
367
|
+
...Array.from({ length: daysInMonth(viewYear, viewMonth) }, (_, i) => i + 1)
|
|
368
|
+
];
|
|
369
|
+
return /* @__PURE__ */ jsxs2(
|
|
370
|
+
PopoutTextButton,
|
|
371
|
+
{
|
|
372
|
+
class: addClass("calendar-input", props.class),
|
|
373
|
+
buttonClass: "input",
|
|
374
|
+
open: popoutOpen,
|
|
375
|
+
popoutClass: "calendar-input-popout",
|
|
376
|
+
popout: () => /* @__PURE__ */ jsxs2(Container, { children: [
|
|
377
|
+
/* @__PURE__ */ jsxs2(HeaderContainer, { horizontal: true, children: [
|
|
378
|
+
/* @__PURE__ */ jsx6(IconButton, { title: "Previous month", onClick: () => stepMonth(-1), children: /* @__PURE__ */ jsx6(ChevronLeft, { size: 15 }) }),
|
|
379
|
+
/* @__PURE__ */ jsxs2("span", { children: [
|
|
380
|
+
MONTH_NAMES[viewMonth - 1],
|
|
381
|
+
" ",
|
|
382
|
+
viewYear
|
|
383
|
+
] }),
|
|
384
|
+
/* @__PURE__ */ jsx6(IconButton, { title: "Next month", onClick: () => stepMonth(1), children: /* @__PURE__ */ jsx6(ChevronRight, { size: 15 }) })
|
|
385
|
+
] }),
|
|
386
|
+
/* @__PURE__ */ jsx6(
|
|
387
|
+
Input,
|
|
388
|
+
{
|
|
389
|
+
value: inputText,
|
|
390
|
+
placeholder: "DD/MM/YYYY",
|
|
391
|
+
onInput: (input) => {
|
|
392
|
+
const date = CalendarDate.parseDateInput(input);
|
|
393
|
+
if (date)
|
|
394
|
+
commit(date, true, true);
|
|
395
|
+
},
|
|
396
|
+
onUnFocus: () => {
|
|
397
|
+
const date = CalendarDate.parseDateInput(inputText.peek());
|
|
398
|
+
if (date)
|
|
399
|
+
commit(date, true);
|
|
400
|
+
},
|
|
401
|
+
onEnter: () => {
|
|
402
|
+
const date = CalendarDate.parseDateInput(inputText.peek());
|
|
403
|
+
commit(date);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
/* @__PURE__ */ jsxs2(MainContainer, { children: [
|
|
408
|
+
WEEKDAYS.map((d) => /* @__PURE__ */ jsx6("span", { class: "weekday", children: d }, d)),
|
|
409
|
+
cells.map((day, i) => day == null ? /* @__PURE__ */ jsx6("span", {}, `blank-${i}`) : /* @__PURE__ */ jsx6(
|
|
410
|
+
TextButton,
|
|
411
|
+
{
|
|
412
|
+
class: addClass(
|
|
413
|
+
"day",
|
|
414
|
+
selected?.isSame(CalendarDate.fromParts(viewYear, viewMonth, day)) && "selected",
|
|
415
|
+
CalendarDate.fromParts(viewYear, viewMonth, day).isSame(CalendarDate.now()) && "today"
|
|
416
|
+
),
|
|
417
|
+
disabled: props.filter == "after" && CalendarDate.fromParts(viewYear, viewMonth, day).isBefore(CalendarDate.now()) || props.filter == "before" && CalendarDate.fromParts(viewYear, viewMonth, day).isAfter(CalendarDate.now()),
|
|
418
|
+
onClick: () => pickDay(day),
|
|
419
|
+
children: day
|
|
420
|
+
},
|
|
421
|
+
`day-${day}`
|
|
422
|
+
))
|
|
423
|
+
] }),
|
|
424
|
+
/* @__PURE__ */ jsxs2(FooterContainer, { horizontal: true, children: [
|
|
425
|
+
/* @__PURE__ */ jsx6(TextButton, { onClick: () => {
|
|
426
|
+
const date = CalendarDate.now();
|
|
427
|
+
setViewYear(date.year);
|
|
428
|
+
setViewMonth(date.month);
|
|
429
|
+
value.value = date;
|
|
430
|
+
}, children: "Today" }),
|
|
431
|
+
value.value != null && /* @__PURE__ */ jsx6(TextButton, { onClick: () => commit(null), children: "Clear" })
|
|
432
|
+
] })
|
|
433
|
+
] }),
|
|
434
|
+
children: [
|
|
435
|
+
/* @__PURE__ */ jsx6("span", { class: value.value == null ? "placeholder" : void 0, children: value.value?.toDisplayString() ?? props.placeholder ?? "Select date..." }),
|
|
436
|
+
/* @__PURE__ */ jsx6(Calendar, { size: 15 })
|
|
437
|
+
]
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// src/components/ClickFade/ClickFade.tsx
|
|
443
|
+
import { useSignal as useSignal4 } from "@preact/signals";
|
|
444
|
+
import { jsxs as jsxs3 } from "preact/jsx-runtime";
|
|
445
|
+
function ClickFade(props) {
|
|
446
|
+
let faded;
|
|
447
|
+
if (props.faded == null)
|
|
448
|
+
faded = useSignal4(false);
|
|
449
|
+
else if (isSignal(props.faded))
|
|
450
|
+
faded = props.faded;
|
|
451
|
+
else
|
|
452
|
+
faded = useSignal4(props.faded);
|
|
453
|
+
return /* @__PURE__ */ jsxs3(
|
|
454
|
+
"button",
|
|
455
|
+
{
|
|
456
|
+
class: addClass(
|
|
457
|
+
"click-faded",
|
|
458
|
+
faded.value && "fade"
|
|
459
|
+
),
|
|
460
|
+
onClick: () => {
|
|
461
|
+
faded.value = true;
|
|
462
|
+
props.onFade?.();
|
|
463
|
+
},
|
|
464
|
+
children: [
|
|
465
|
+
resolveMaybeFunc(props.before),
|
|
466
|
+
resolveMaybeFunc(props.after)
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// src/components/Conditional.tsx
|
|
473
|
+
import { createContext } from "preact";
|
|
474
|
+
import { useContext } from "preact/hooks";
|
|
475
|
+
import { jsx as jsx7 } from "preact/jsx-runtime";
|
|
476
|
+
function If(props) {
|
|
477
|
+
if (resolveSignalish(resolveMaybeFunc(props.cond)))
|
|
478
|
+
return resolveMaybeFunc(props.children);
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
var SwitchValue = createContext(null);
|
|
482
|
+
function Switch(props) {
|
|
483
|
+
return /* @__PURE__ */ jsx7(SwitchValue.Provider, { value: resolveSignalish(resolveMaybeFunc(props.value)), children: props.children });
|
|
484
|
+
}
|
|
485
|
+
function Case(props) {
|
|
486
|
+
const value = useContext(SwitchValue);
|
|
487
|
+
if (value == props.value)
|
|
488
|
+
return resolveMaybeFunc(props.children);
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
var BranchValue = createContext(false);
|
|
492
|
+
function Branch(props) {
|
|
493
|
+
return /* @__PURE__ */ jsx7(BranchValue.Provider, { value: !!resolveSignalish(resolveMaybeFunc(props.cond)), children: props.children });
|
|
494
|
+
}
|
|
495
|
+
function Then(props) {
|
|
496
|
+
const value = useContext(BranchValue);
|
|
497
|
+
if (value)
|
|
498
|
+
return resolveMaybeFunc(props.children);
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
function Else(props) {
|
|
502
|
+
const value = useContext(BranchValue);
|
|
503
|
+
if (!value)
|
|
504
|
+
return resolveMaybeFunc(props.children);
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// src/components/Content/Content.tsx
|
|
509
|
+
import { jsx as jsx8 } from "preact/jsx-runtime";
|
|
510
|
+
function Content(props) {
|
|
511
|
+
return /* @__PURE__ */ jsx8("main", { class: addClass(
|
|
512
|
+
props.class && `content-${props.class}`,
|
|
513
|
+
props.wrapped && "wrapped",
|
|
514
|
+
props.centered && "centered"
|
|
515
|
+
), children: props.wrapped ? /* @__PURE__ */ jsx8("div", { children: props.children }) : props.children });
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// src/components/ContextMenu/ContextMenu.tsx
|
|
519
|
+
import { render } from "preact";
|
|
520
|
+
import { createPortal as createPortal2 } from "preact/compat";
|
|
521
|
+
import { useLayoutEffect, useRef as useRef3 } from "preact/hooks";
|
|
522
|
+
|
|
523
|
+
// src/components/Text/Text.tsx
|
|
524
|
+
import { jsx as jsx9 } from "preact/jsx-runtime";
|
|
525
|
+
function Text(props) {
|
|
526
|
+
const content = resolveSignalish(props.content);
|
|
527
|
+
return content != null && /* @__PURE__ */ jsx9("span", { class: addClass(
|
|
528
|
+
"text",
|
|
529
|
+
props.big && "big",
|
|
530
|
+
props.extra_big && "extra-big",
|
|
531
|
+
props.dim && "dim",
|
|
532
|
+
props.dark && "dark",
|
|
533
|
+
props.selectable && "selectable",
|
|
534
|
+
props.class
|
|
535
|
+
), children: content });
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/components/ContextMenu/position.ts
|
|
539
|
+
function getContextMenuPlacement(target, size, viewport) {
|
|
540
|
+
const margin = 8;
|
|
541
|
+
const gap = 6;
|
|
542
|
+
const maxWidth = Math.max(0, viewport.width - margin * 2);
|
|
543
|
+
const maxHeight = Math.max(0, viewport.height - margin * 2);
|
|
544
|
+
const width = Math.min(size.width, maxWidth);
|
|
545
|
+
const height = Math.min(size.height, maxHeight);
|
|
546
|
+
const clampX = (x) => Math.max(margin, Math.min(x, viewport.width - margin - width));
|
|
547
|
+
const clampY = (y, h = height) => Math.max(margin, Math.min(y, viewport.height - margin - h));
|
|
548
|
+
if (!("bottom" in target)) {
|
|
549
|
+
const left = target.x + width > viewport.width - margin ? target.x - width : target.x;
|
|
550
|
+
const top = target.y + height > viewport.height - margin ? target.y - height : target.y;
|
|
551
|
+
return { left: clampX(left), top: clampY(top), maxHeight };
|
|
552
|
+
}
|
|
553
|
+
const below = Math.max(0, viewport.height - margin - target.bottom - gap);
|
|
554
|
+
const above = Math.max(0, target.top - margin - gap);
|
|
555
|
+
if (height <= below)
|
|
556
|
+
return { left: clampX(target.left), top: clampY(target.bottom + gap), maxHeight: below };
|
|
557
|
+
if (height <= above)
|
|
558
|
+
return { left: clampX(target.left), top: clampY(target.top - gap - height), maxHeight: above };
|
|
559
|
+
if (target.right + gap + width <= viewport.width - margin)
|
|
560
|
+
return { left: clampX(target.right + gap), top: clampY(target.top), maxHeight };
|
|
561
|
+
if (target.left - gap - width >= margin)
|
|
562
|
+
return { left: clampX(target.left - gap - width), top: clampY(target.top), maxHeight };
|
|
563
|
+
const available = Math.min(maxHeight, Math.max(below, above));
|
|
564
|
+
if (available > 0) {
|
|
565
|
+
const top = below >= above ? target.bottom + gap : target.top - gap - available;
|
|
566
|
+
return { left: clampX(target.left), top: clampY(top, available), maxHeight: available };
|
|
567
|
+
}
|
|
568
|
+
return { left: clampX(target.left), top: margin, maxHeight };
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// src/components/ContextMenu/ContextMenu.tsx
|
|
572
|
+
import { jsx as jsx10, jsxs as jsxs4 } from "preact/jsx-runtime";
|
|
573
|
+
var currentMenu;
|
|
574
|
+
var pointerPosition;
|
|
575
|
+
if (typeof window !== "undefined") {
|
|
576
|
+
const trackPointer = (event) => {
|
|
577
|
+
pointerPosition = { x: event.clientX, y: event.clientY };
|
|
578
|
+
};
|
|
579
|
+
window.addEventListener("pointermove", trackPointer, { passive: true });
|
|
580
|
+
window.addEventListener("pointerdown", trackPointer, { passive: true });
|
|
581
|
+
}
|
|
582
|
+
function closeMenu(menu, restoreFocus) {
|
|
583
|
+
if (currentMenu !== menu)
|
|
584
|
+
return;
|
|
585
|
+
currentMenu = void 0;
|
|
586
|
+
render(null, menu.host);
|
|
587
|
+
menu.host.remove();
|
|
588
|
+
if (restoreFocus && menu.previousFocus instanceof HTMLElement && menu.previousFocus.isConnected)
|
|
589
|
+
menu.previousFocus.focus({ preventScroll: true });
|
|
590
|
+
}
|
|
591
|
+
function closeContextMenu() {
|
|
592
|
+
if (currentMenu)
|
|
593
|
+
closeMenu(currentMenu, true);
|
|
594
|
+
}
|
|
595
|
+
function openMenu(items, target) {
|
|
596
|
+
const previousFocus = currentMenu && document.activeElement?.closest(".context-menu") ? currentMenu.previousFocus : document.activeElement;
|
|
597
|
+
if (currentMenu)
|
|
598
|
+
closeMenu(currentMenu, false);
|
|
599
|
+
if (items.length === 0 || target instanceof Element && !target.isConnected)
|
|
600
|
+
return;
|
|
601
|
+
const menu = {
|
|
602
|
+
host: document.createElement("div"),
|
|
603
|
+
previousFocus
|
|
604
|
+
};
|
|
605
|
+
currentMenu = menu;
|
|
606
|
+
document.body.appendChild(menu.host);
|
|
607
|
+
render(/* @__PURE__ */ jsx10(ContextMenu, { items, target, instance: menu }), menu.host);
|
|
608
|
+
}
|
|
609
|
+
function openContextMenu(items, position) {
|
|
610
|
+
if (position && "preventDefault" in position)
|
|
611
|
+
position.preventDefault();
|
|
612
|
+
const point = position && "clientX" in position ? { x: position.clientX, y: position.clientY } : position;
|
|
613
|
+
openMenu(items, point ?? pointerPosition ?? { x: window.innerWidth / 2, y: window.innerHeight / 2 });
|
|
614
|
+
}
|
|
615
|
+
function openContextMenuOn(items, element) {
|
|
616
|
+
openMenu(items, element);
|
|
617
|
+
}
|
|
618
|
+
function ContextMenu(props) {
|
|
619
|
+
const menuRef = useRef3(null);
|
|
620
|
+
useLayoutEffect(() => {
|
|
621
|
+
const menu = menuRef.current;
|
|
622
|
+
const anchor = props.target instanceof Element ? props.target : void 0;
|
|
623
|
+
const getButtons = () => [...menu.querySelectorAll("button:not(:disabled)")];
|
|
624
|
+
const close = (restoreFocus) => closeMenu(props.instance, restoreFocus);
|
|
625
|
+
let frame = 0;
|
|
626
|
+
const updatePosition = () => {
|
|
627
|
+
if (anchor && !anchor.isConnected) {
|
|
628
|
+
close(false);
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
const rect = menu.getBoundingClientRect();
|
|
632
|
+
const target = props.target instanceof Element ? props.target.getBoundingClientRect() : props.target;
|
|
633
|
+
const placement = getContextMenuPlacement(
|
|
634
|
+
target,
|
|
635
|
+
{ width: rect.width, height: menu.scrollHeight + menu.offsetHeight - menu.clientHeight },
|
|
636
|
+
{ width: document.documentElement.clientWidth, height: window.innerHeight }
|
|
637
|
+
);
|
|
638
|
+
Object.assign(menu.style, {
|
|
639
|
+
left: `${placement.left}px`,
|
|
640
|
+
top: `${placement.top}px`,
|
|
641
|
+
maxHeight: `${placement.maxHeight}px`,
|
|
642
|
+
visibility: "visible"
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
const schedulePosition = () => {
|
|
646
|
+
cancelAnimationFrame(frame);
|
|
647
|
+
frame = requestAnimationFrame(updatePosition);
|
|
648
|
+
};
|
|
649
|
+
const onOutside = (event) => {
|
|
650
|
+
if (event.target instanceof Node && !menu.contains(event.target))
|
|
651
|
+
close(false);
|
|
652
|
+
};
|
|
653
|
+
const onScroll = (event) => {
|
|
654
|
+
if (!(event.target instanceof Node) || !menu.contains(event.target))
|
|
655
|
+
schedulePosition();
|
|
656
|
+
};
|
|
657
|
+
const onKeyDown = (event) => {
|
|
658
|
+
if (event.key === "Escape") {
|
|
659
|
+
event.preventDefault();
|
|
660
|
+
event.stopPropagation();
|
|
661
|
+
close(true);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (event.key === "Tab") {
|
|
665
|
+
close(true);
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key))
|
|
669
|
+
return;
|
|
670
|
+
event.preventDefault();
|
|
671
|
+
const buttons = getButtons();
|
|
672
|
+
if (!buttons.length)
|
|
673
|
+
return;
|
|
674
|
+
const current = buttons.indexOf(document.activeElement);
|
|
675
|
+
let index = 0;
|
|
676
|
+
switch (event.key) {
|
|
677
|
+
case "Home":
|
|
678
|
+
index = 0;
|
|
679
|
+
break;
|
|
680
|
+
case "End":
|
|
681
|
+
index = buttons.length - 1;
|
|
682
|
+
break;
|
|
683
|
+
case "ArrowDown":
|
|
684
|
+
index = (current + 1) % buttons.length;
|
|
685
|
+
break;
|
|
686
|
+
case "ArrowUp":
|
|
687
|
+
index = current < 0 ? buttons.length - 1 : (current - 1 + buttons.length) % buttons.length;
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
buttons[index].focus();
|
|
691
|
+
};
|
|
692
|
+
updatePosition();
|
|
693
|
+
(getButtons()[0] ?? menu).focus({ preventScroll: true });
|
|
694
|
+
const observer = new ResizeObserver(schedulePosition);
|
|
695
|
+
observer.observe(menu);
|
|
696
|
+
if (anchor)
|
|
697
|
+
observer.observe(anchor);
|
|
698
|
+
document.addEventListener("pointerdown", onOutside, true);
|
|
699
|
+
document.addEventListener("contextmenu", onOutside, true);
|
|
700
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
701
|
+
window.addEventListener("resize", schedulePosition);
|
|
702
|
+
window.addEventListener("scroll", onScroll, true);
|
|
703
|
+
return () => {
|
|
704
|
+
cancelAnimationFrame(frame);
|
|
705
|
+
observer.disconnect();
|
|
706
|
+
document.removeEventListener("pointerdown", onOutside, true);
|
|
707
|
+
document.removeEventListener("contextmenu", onOutside, true);
|
|
708
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
709
|
+
window.removeEventListener("resize", schedulePosition);
|
|
710
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
711
|
+
};
|
|
712
|
+
}, []);
|
|
713
|
+
return createPortal2(
|
|
714
|
+
/* @__PURE__ */ jsx10(
|
|
715
|
+
Container,
|
|
716
|
+
{
|
|
717
|
+
class: "context-menu popout",
|
|
718
|
+
no_gap: true,
|
|
719
|
+
other: {
|
|
720
|
+
ref: menuRef,
|
|
721
|
+
role: "menu",
|
|
722
|
+
"aria-label": "Context menu",
|
|
723
|
+
tabIndex: -1,
|
|
724
|
+
onContextMenu: (event) => event.preventDefault()
|
|
725
|
+
},
|
|
726
|
+
children: props.items.map((item, index) => /* @__PURE__ */ jsx10(ContextMenuItemView, { item, instance: props.instance }, index))
|
|
727
|
+
}
|
|
728
|
+
),
|
|
729
|
+
document.body
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
function ContextMenuItemView({ item, instance }) {
|
|
733
|
+
if (item === "---" || typeof item !== "string" && item.type === "separator")
|
|
734
|
+
return /* @__PURE__ */ jsx10("div", { class: "context-menu-separator", role: "separator" });
|
|
735
|
+
if (typeof item === "string" || item.type === "header") {
|
|
736
|
+
const label = typeof item === "string" ? item : item.label;
|
|
737
|
+
return /* @__PURE__ */ jsx10(Container, { class: "context-menu-header", other: { role: "presentation" }, children: renderLabel(label, true) });
|
|
738
|
+
}
|
|
739
|
+
const MenuButton = "href" in item ? item.icon ? TextIconLinkButton : TextLinkButton : item.icon ? TextIconButton : TextButton;
|
|
740
|
+
return /* @__PURE__ */ jsxs4(
|
|
741
|
+
MenuButton,
|
|
742
|
+
{
|
|
743
|
+
role: "menuitem",
|
|
744
|
+
tabIndex: -1,
|
|
745
|
+
variant: item.variant,
|
|
746
|
+
disabled: item.disabled,
|
|
747
|
+
href: "href" in item ? item.href : "",
|
|
748
|
+
onClick: (event) => {
|
|
749
|
+
closeMenu(instance, true);
|
|
750
|
+
if ("click" in item)
|
|
751
|
+
item.click(event);
|
|
752
|
+
},
|
|
753
|
+
children: [
|
|
754
|
+
item.icon,
|
|
755
|
+
renderLabel(item.label ?? "Button")
|
|
756
|
+
]
|
|
757
|
+
}
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
function renderLabel(label, dim = false) {
|
|
761
|
+
return typeof label === "string" || typeof label === "number" ? /* @__PURE__ */ jsx10(Text, { content: label, dim }) : label;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// src/components/DotSeperator/DotSeperator.tsx
|
|
765
|
+
import { jsx as jsx11 } from "preact/jsx-runtime";
|
|
766
|
+
function DotSeperator(props) {
|
|
767
|
+
return /* @__PURE__ */ jsx11("span", { class: addClass(
|
|
768
|
+
"dot-seperator",
|
|
769
|
+
props.noMargin && "no-margin",
|
|
770
|
+
props.containerTextMargin && "container-text-margin"
|
|
771
|
+
) });
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// src/components/FileIcon.tsx
|
|
775
|
+
import {
|
|
776
|
+
Folder,
|
|
777
|
+
FileSymlink,
|
|
778
|
+
Terminal,
|
|
779
|
+
Image,
|
|
780
|
+
Film,
|
|
781
|
+
Music,
|
|
782
|
+
Braces,
|
|
783
|
+
Code,
|
|
784
|
+
Settings,
|
|
785
|
+
FileText,
|
|
786
|
+
FileCode,
|
|
787
|
+
File,
|
|
788
|
+
FileArchive,
|
|
789
|
+
Type,
|
|
790
|
+
Database,
|
|
791
|
+
Binary,
|
|
792
|
+
FileQuestion
|
|
793
|
+
} from "lucide-preact";
|
|
794
|
+
import { jsx as jsx12 } from "preact/jsx-runtime";
|
|
795
|
+
function getFileIcon(category) {
|
|
796
|
+
switch (category) {
|
|
797
|
+
case "directory":
|
|
798
|
+
return Folder;
|
|
799
|
+
case "symlink":
|
|
800
|
+
return FileSymlink;
|
|
801
|
+
case "bash":
|
|
802
|
+
return Terminal;
|
|
803
|
+
case "image":
|
|
804
|
+
return Image;
|
|
805
|
+
case "video":
|
|
806
|
+
return Film;
|
|
807
|
+
case "audio":
|
|
808
|
+
return Music;
|
|
809
|
+
case "json":
|
|
810
|
+
return Braces;
|
|
811
|
+
case "code":
|
|
812
|
+
return Code;
|
|
813
|
+
case "config":
|
|
814
|
+
return Settings;
|
|
815
|
+
case "markdown":
|
|
816
|
+
return FileCode;
|
|
817
|
+
case "text":
|
|
818
|
+
return FileText;
|
|
819
|
+
case "document":
|
|
820
|
+
return File;
|
|
821
|
+
case "archive":
|
|
822
|
+
return FileArchive;
|
|
823
|
+
case "font":
|
|
824
|
+
return Type;
|
|
825
|
+
case "database":
|
|
826
|
+
return Database;
|
|
827
|
+
case "binary":
|
|
828
|
+
return Binary;
|
|
829
|
+
case "other":
|
|
830
|
+
return FileQuestion;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
function FileIcon(props) {
|
|
834
|
+
const Icon = getFileIcon(props.category);
|
|
835
|
+
return /* @__PURE__ */ jsx12(Icon, { size: props.size });
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// src/components/FilePath.tsx
|
|
839
|
+
import { Fragment, jsx as jsx13, jsxs as jsxs5 } from "preact/jsx-runtime";
|
|
840
|
+
function FilePath(props) {
|
|
841
|
+
const parts = splitFilePath(props.path);
|
|
842
|
+
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
843
|
+
/* @__PURE__ */ jsx13(Text, { content: parts[0] + parts[1] }),
|
|
844
|
+
parts[2] && /* @__PURE__ */ jsx13(Text, { class: "type", dim: true, content: "." + parts[2] })
|
|
845
|
+
] });
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
// src/components/Label/Label.tsx
|
|
849
|
+
import { jsx as jsx14 } from "preact/jsx-runtime";
|
|
850
|
+
function Label(props) {
|
|
851
|
+
return /* @__PURE__ */ jsx14("span", { class: "label", children: props.text });
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// src/components/FormalInput/FormalInput.tsx
|
|
855
|
+
import { jsx as jsx15, jsxs as jsxs6 } from "preact/jsx-runtime";
|
|
856
|
+
function FormalInput(props) {
|
|
857
|
+
return /* @__PURE__ */ jsxs6(Container, { class: "formal-input", children: [
|
|
858
|
+
/* @__PURE__ */ jsx15(Label, { text: props.label }),
|
|
859
|
+
props.children
|
|
860
|
+
] });
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// src/components/Header/Header.tsx
|
|
864
|
+
import { jsx as jsx16 } from "preact/jsx-runtime";
|
|
865
|
+
function Header1(props) {
|
|
866
|
+
return /* @__PURE__ */ jsx16(
|
|
867
|
+
"h1",
|
|
868
|
+
{
|
|
869
|
+
class: addClass(
|
|
870
|
+
"header",
|
|
871
|
+
props.underline && "underline",
|
|
872
|
+
props.class
|
|
873
|
+
),
|
|
874
|
+
children: props.children
|
|
875
|
+
}
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
function Header2(props) {
|
|
879
|
+
return /* @__PURE__ */ jsx16(
|
|
880
|
+
"h2",
|
|
881
|
+
{
|
|
882
|
+
class: addClass(
|
|
883
|
+
"header",
|
|
884
|
+
props.underline && "underline",
|
|
885
|
+
props.class
|
|
886
|
+
),
|
|
887
|
+
children: props.children
|
|
888
|
+
}
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
function Header3(props) {
|
|
892
|
+
return /* @__PURE__ */ jsx16(
|
|
893
|
+
"h3",
|
|
894
|
+
{
|
|
895
|
+
class: addClass(
|
|
896
|
+
"header",
|
|
897
|
+
props.underline && "underline",
|
|
898
|
+
props.class
|
|
899
|
+
),
|
|
900
|
+
children: props.children
|
|
901
|
+
}
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
function MiniHeader(props) {
|
|
905
|
+
return /* @__PURE__ */ jsx16(
|
|
906
|
+
"h6",
|
|
907
|
+
{
|
|
908
|
+
class: addClass(
|
|
909
|
+
"header",
|
|
910
|
+
"mini-header",
|
|
911
|
+
props.dim && "dim",
|
|
912
|
+
props.class
|
|
913
|
+
),
|
|
914
|
+
children: props.children
|
|
915
|
+
}
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// src/components/Image/Image.tsx
|
|
920
|
+
import { useEffect as useEffect3, useRef as useRef4, useState as useState3 } from "preact/hooks";
|
|
921
|
+
import { jsx as jsx17 } from "preact/jsx-runtime";
|
|
922
|
+
function Image2(props) {
|
|
923
|
+
const [src, setSrc] = useState3();
|
|
924
|
+
const lastSrc = useRef4();
|
|
925
|
+
useEffect3(() => {
|
|
926
|
+
if (lastSrc.current)
|
|
927
|
+
URL.revokeObjectURL(lastSrc.current);
|
|
928
|
+
const newSrc = resolveSignalish(props.src);
|
|
929
|
+
if (newSrc == null)
|
|
930
|
+
return;
|
|
931
|
+
if (typeof newSrc == "string") {
|
|
932
|
+
setSrc(newSrc);
|
|
933
|
+
lastSrc.current = newSrc;
|
|
934
|
+
} else {
|
|
935
|
+
const newObjectURL = URL.createObjectURL(newSrc);
|
|
936
|
+
setSrc(newObjectURL);
|
|
937
|
+
lastSrc.current = newObjectURL;
|
|
938
|
+
}
|
|
939
|
+
}, [props.src]);
|
|
940
|
+
return /* @__PURE__ */ jsx17(
|
|
941
|
+
"img",
|
|
942
|
+
{
|
|
943
|
+
src,
|
|
944
|
+
class: props.class,
|
|
945
|
+
loading: addTitle(props.lazy && "lazy"),
|
|
946
|
+
style: addStyles(
|
|
947
|
+
props.size != null && {
|
|
948
|
+
width: props.size + "px",
|
|
949
|
+
height: props.size + "px"
|
|
950
|
+
},
|
|
951
|
+
props.max_size != null && {
|
|
952
|
+
maxWidth: props.max_size + "px",
|
|
953
|
+
maxHeight: props.max_size + "px"
|
|
954
|
+
}
|
|
955
|
+
)
|
|
956
|
+
}
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// src/components/ImageInput/ImageInput.tsx
|
|
961
|
+
import { useRef as useRef5 } from "preact/hooks";
|
|
962
|
+
import { useSignal as useSignal5 } from "@preact/signals";
|
|
963
|
+
import { CloudUpload } from "lucide-preact";
|
|
964
|
+
import { jsx as jsx18, jsxs as jsxs7 } from "preact/jsx-runtime";
|
|
965
|
+
function ImageInput(props) {
|
|
966
|
+
const inputRef = useRef5();
|
|
967
|
+
let value;
|
|
968
|
+
if (props.value == null)
|
|
969
|
+
value = useSignal5(null);
|
|
970
|
+
else if (isSignal(props.value))
|
|
971
|
+
value = props.value;
|
|
972
|
+
else
|
|
973
|
+
value = useSignal5(props.value);
|
|
974
|
+
return /* @__PURE__ */ jsxs7(
|
|
975
|
+
"div",
|
|
976
|
+
{
|
|
977
|
+
class: addClass(
|
|
978
|
+
"image-input",
|
|
979
|
+
value.value != null && "has-image",
|
|
980
|
+
props.class
|
|
981
|
+
),
|
|
982
|
+
style: addStyles({
|
|
983
|
+
"--width": (props.width ?? props.size ?? 100) + "px",
|
|
984
|
+
"--height": (props.height ?? props.size ?? 100) + "px"
|
|
985
|
+
}),
|
|
986
|
+
onClick: () => {
|
|
987
|
+
inputRef.current?.click();
|
|
988
|
+
},
|
|
989
|
+
children: [
|
|
990
|
+
/* @__PURE__ */ jsx18(
|
|
991
|
+
"input",
|
|
992
|
+
{
|
|
993
|
+
ref: inputRef,
|
|
994
|
+
type: "file",
|
|
995
|
+
accept: "image/*",
|
|
996
|
+
hidden: true,
|
|
997
|
+
onInput: () => {
|
|
998
|
+
const file = inputRef.current.files?.[0] ?? null;
|
|
999
|
+
value.value = file;
|
|
1000
|
+
props.onInput?.(value.peek());
|
|
1001
|
+
if (props.dirty)
|
|
1002
|
+
props.dirty.value = true;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
),
|
|
1006
|
+
/* @__PURE__ */ jsxs7(Branch, { cond: value, children: [
|
|
1007
|
+
/* @__PURE__ */ jsx18(Then, { children: () => /* @__PURE__ */ jsx18(
|
|
1008
|
+
Image2,
|
|
1009
|
+
{
|
|
1010
|
+
src: value,
|
|
1011
|
+
class: "preview"
|
|
1012
|
+
}
|
|
1013
|
+
) }),
|
|
1014
|
+
/* @__PURE__ */ jsx18(Else, { children: props.children ?? /* @__PURE__ */ jsx18(CloudUpload, { size: 16 }) })
|
|
1015
|
+
] })
|
|
1016
|
+
]
|
|
1017
|
+
}
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// src/components/Input/Textarea.tsx
|
|
1022
|
+
import { useSignal as useSignal6 } from "@preact/signals";
|
|
1023
|
+
import { useRef as useRef6 } from "preact/hooks";
|
|
1024
|
+
import { jsx as jsx19 } from "preact/jsx-runtime";
|
|
1025
|
+
function Textarea(props) {
|
|
1026
|
+
const inputRef = useRef6();
|
|
1027
|
+
let value;
|
|
1028
|
+
if (props.value == null)
|
|
1029
|
+
value = useSignal6("");
|
|
1030
|
+
else if (isSignal(props.value))
|
|
1031
|
+
value = props.value;
|
|
1032
|
+
else
|
|
1033
|
+
value = useSignal6(props.value);
|
|
1034
|
+
return /* @__PURE__ */ jsx19(
|
|
1035
|
+
"textarea",
|
|
1036
|
+
{
|
|
1037
|
+
class: addClass(
|
|
1038
|
+
"input",
|
|
1039
|
+
props.class
|
|
1040
|
+
),
|
|
1041
|
+
ref: inputRef,
|
|
1042
|
+
value: value.value,
|
|
1043
|
+
rows: props.rows ?? 1,
|
|
1044
|
+
onInput: () => {
|
|
1045
|
+
value.value = inputRef.current.value;
|
|
1046
|
+
props.onInput?.(value.peek());
|
|
1047
|
+
if (props.dirty)
|
|
1048
|
+
props.dirty.value = true;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
// src/components/Loading/Loading.tsx
|
|
1055
|
+
import { useEffect as useEffect4, useState as useState4 } from "preact/hooks";
|
|
1056
|
+
|
|
1057
|
+
// src/components/Throbber/Throbber.tsx
|
|
1058
|
+
import { Loader2 } from "lucide-preact";
|
|
1059
|
+
import { jsx as jsx20 } from "preact/jsx-runtime";
|
|
1060
|
+
function Throbber(props) {
|
|
1061
|
+
return /* @__PURE__ */ jsx20("span", { class: "throbber", children: /* @__PURE__ */ jsx20(Loader2, { size: props.size }) });
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
// src/components/Loading/Loading.tsx
|
|
1065
|
+
import { jsx as jsx21, jsxs as jsxs8 } from "preact/jsx-runtime";
|
|
1066
|
+
function Loading(props) {
|
|
1067
|
+
const [loaded, setLoaded] = useState4(false);
|
|
1068
|
+
{
|
|
1069
|
+
const out = resolveMaybeFunc(props.loaded);
|
|
1070
|
+
if (!(out instanceof Promise)) {
|
|
1071
|
+
setLoaded(resolveSignalish(out));
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
useEffect4(syncWrap(async () => {
|
|
1075
|
+
let data = resolveSignalish(await resolveMaybeAsyncFunc(props.loaded));
|
|
1076
|
+
setLoaded(data);
|
|
1077
|
+
}), [props.loaded]);
|
|
1078
|
+
return loaded ? resolveMaybeFunc(props.children ?? null) : /* @__PURE__ */ jsxs8("div", { class: addClass("loading", props.class), children: [
|
|
1079
|
+
/* @__PURE__ */ jsx21(Throbber, { size: props.throbber_size }),
|
|
1080
|
+
loaded && /* @__PURE__ */ jsx21("p", { children: loaded })
|
|
1081
|
+
] });
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// src/components/PathInput/PathInput.tsx
|
|
1085
|
+
import { useSignal as useSignal7 } from "@preact/signals";
|
|
1086
|
+
import { Fragment as Fragment2 } from "preact";
|
|
1087
|
+
import { useEffect as useEffect5, useRef as useRef7 } from "preact/hooks";
|
|
1088
|
+
import { ChevronRight as ChevronRight2 } from "lucide-preact";
|
|
1089
|
+
import { jsx as jsx22, jsxs as jsxs9 } from "preact/jsx-runtime";
|
|
1090
|
+
function PathInput(props) {
|
|
1091
|
+
let parts;
|
|
1092
|
+
if (props.value == null)
|
|
1093
|
+
parts = useSignal7(["~", "Documents", "Projects"]);
|
|
1094
|
+
else if (isSignal(props.value))
|
|
1095
|
+
parts = useSignal7(splitPath(props.value.peek()));
|
|
1096
|
+
else
|
|
1097
|
+
parts = useSignal7(splitPath(props.value));
|
|
1098
|
+
let combined;
|
|
1099
|
+
if (isSignal(props.value))
|
|
1100
|
+
combined = props.value;
|
|
1101
|
+
else
|
|
1102
|
+
combined = useSignal7(joinPathParts(parts.peek()));
|
|
1103
|
+
const editing = props.editing ?? useSignal7(false);
|
|
1104
|
+
const inputRef = useRef7(null);
|
|
1105
|
+
const pathRef = useRef7(null);
|
|
1106
|
+
function commit(newParts) {
|
|
1107
|
+
parts.value = newParts;
|
|
1108
|
+
const str = joinPathParts(newParts);
|
|
1109
|
+
combined.value = str;
|
|
1110
|
+
if (props.onChange)
|
|
1111
|
+
props.onChange(str);
|
|
1112
|
+
}
|
|
1113
|
+
function focus() {
|
|
1114
|
+
inputRef.current?.focus();
|
|
1115
|
+
const end = combined.peek().length;
|
|
1116
|
+
inputRef.current?.setSelectionRange(end, end);
|
|
1117
|
+
}
|
|
1118
|
+
useEffect5(() => {
|
|
1119
|
+
if (!isSignal(props.value)) return;
|
|
1120
|
+
return props.value.subscribe((val) => {
|
|
1121
|
+
if (!editing.peek()) parts.value = splitPath(val);
|
|
1122
|
+
});
|
|
1123
|
+
}, [props.value]);
|
|
1124
|
+
useEffect5(() => {
|
|
1125
|
+
const el = pathRef.current;
|
|
1126
|
+
if (!el) return;
|
|
1127
|
+
requestAnimationFrame(() => {
|
|
1128
|
+
el.scrollTo({
|
|
1129
|
+
left: el.scrollWidth,
|
|
1130
|
+
behavior: "smooth"
|
|
1131
|
+
});
|
|
1132
|
+
});
|
|
1133
|
+
}, [parts.value]);
|
|
1134
|
+
return /* @__PURE__ */ jsx22(Container, { horizontal: true, class: "path-input", children: /* @__PURE__ */ jsx22(
|
|
1135
|
+
ClickFade,
|
|
1136
|
+
{
|
|
1137
|
+
faded: editing,
|
|
1138
|
+
onFade: focus,
|
|
1139
|
+
before: /* @__PURE__ */ jsx22(Container, { horizontal: true, class: "input", centered_y: true, other: { ref: pathRef }, children: parts.value.map((p, i) => /* @__PURE__ */ jsxs9(Fragment2, { children: [
|
|
1140
|
+
/* @__PURE__ */ jsx22(
|
|
1141
|
+
Button,
|
|
1142
|
+
{
|
|
1143
|
+
variant: "always-transparent",
|
|
1144
|
+
onClick: (e) => {
|
|
1145
|
+
e.stopImmediatePropagation();
|
|
1146
|
+
commit(parts.peek().slice(0, i + 1));
|
|
1147
|
+
},
|
|
1148
|
+
children: /* @__PURE__ */ jsx22(
|
|
1149
|
+
Text,
|
|
1150
|
+
{
|
|
1151
|
+
content: p
|
|
1152
|
+
}
|
|
1153
|
+
)
|
|
1154
|
+
}
|
|
1155
|
+
),
|
|
1156
|
+
/* @__PURE__ */ jsx22(If, { cond: i < parts.value.length - 1, children: /* @__PURE__ */ jsx22(ChevronRight2, { size: 12 }) })
|
|
1157
|
+
] }, i)) }),
|
|
1158
|
+
after: /* @__PURE__ */ jsx22(
|
|
1159
|
+
Input,
|
|
1160
|
+
{
|
|
1161
|
+
inputRef,
|
|
1162
|
+
value: combined,
|
|
1163
|
+
onEnter: (data) => {
|
|
1164
|
+
editing.value = false;
|
|
1165
|
+
commit(splitPath(data));
|
|
1166
|
+
},
|
|
1167
|
+
onUnFocus: (ev, data) => {
|
|
1168
|
+
editing.value = false;
|
|
1169
|
+
ev.stopImmediatePropagation();
|
|
1170
|
+
ev.preventDefault();
|
|
1171
|
+
commit(splitPath(data));
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
)
|
|
1175
|
+
}
|
|
1176
|
+
) });
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// src/components/SelectBox/SelectBox.tsx
|
|
1180
|
+
import { useSignal as useSignal8 } from "@preact/signals";
|
|
1181
|
+
import { ChevronDown } from "lucide-preact";
|
|
1182
|
+
import { jsx as jsx23, jsxs as jsxs10 } from "preact/jsx-runtime";
|
|
1183
|
+
function SelectBox(props) {
|
|
1184
|
+
let value;
|
|
1185
|
+
if (props.value == null)
|
|
1186
|
+
value = useSignal8(null);
|
|
1187
|
+
else if (isSignal(props.value))
|
|
1188
|
+
value = props.value;
|
|
1189
|
+
else
|
|
1190
|
+
value = useSignal8(props.value);
|
|
1191
|
+
const popoutOpen = useSignal8(false);
|
|
1192
|
+
const temp_options = resolveSignalish(props.options);
|
|
1193
|
+
const options = isMaybeLoaded(temp_options) ? maybeLoadedIsLoaded(temp_options) ? maybeLoadedUnwrap(temp_options) : null : temp_options;
|
|
1194
|
+
const selected = options != null ? options.find(
|
|
1195
|
+
(option) => option.value === value.value
|
|
1196
|
+
) : null;
|
|
1197
|
+
function select(next) {
|
|
1198
|
+
value.value = next;
|
|
1199
|
+
props.onChange?.(next);
|
|
1200
|
+
if (props.dirty)
|
|
1201
|
+
props.dirty.value = true;
|
|
1202
|
+
popoutOpen.value = false;
|
|
1203
|
+
}
|
|
1204
|
+
return /* @__PURE__ */ jsxs10(
|
|
1205
|
+
PopoutTextButton,
|
|
1206
|
+
{
|
|
1207
|
+
class: addClass(
|
|
1208
|
+
"select-box",
|
|
1209
|
+
props.flat && "flat",
|
|
1210
|
+
props.class
|
|
1211
|
+
),
|
|
1212
|
+
buttonClass: "input",
|
|
1213
|
+
open: popoutOpen,
|
|
1214
|
+
popoutClass: "select-box-popout",
|
|
1215
|
+
popout: () => /* @__PURE__ */ jsx23(Container, { children: /* @__PURE__ */ jsx23(Loading, { loaded: options != null, throbber_size: 15, children: () => options.map((option) => /* @__PURE__ */ jsx23(
|
|
1216
|
+
TextButton,
|
|
1217
|
+
{
|
|
1218
|
+
class: addClass(
|
|
1219
|
+
option.value === props.value && "selected"
|
|
1220
|
+
),
|
|
1221
|
+
onClick: () => select(option.value),
|
|
1222
|
+
children: resolveSignalish(option.label)
|
|
1223
|
+
}
|
|
1224
|
+
)) }) }),
|
|
1225
|
+
children: [
|
|
1226
|
+
/* @__PURE__ */ jsx23("span", { class: addClass(
|
|
1227
|
+
selected == null && "default"
|
|
1228
|
+
), children: selected?.label ?? "Select..." }),
|
|
1229
|
+
/* @__PURE__ */ jsx23(ChevronDown, { size: 15 })
|
|
1230
|
+
]
|
|
1231
|
+
}
|
|
1232
|
+
);
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// src/components/Seperator/Seperator.tsx
|
|
1236
|
+
import { jsx as jsx24 } from "preact/jsx-runtime";
|
|
1237
|
+
function Seperator() {
|
|
1238
|
+
return /* @__PURE__ */ jsx24("div", { class: "seperator" });
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// src/components/Slider/Slider.tsx
|
|
1242
|
+
import { useSignal as useSignal9 } from "@preact/signals";
|
|
1243
|
+
import { useEffect as useEffect6, useRef as useRef8 } from "preact/hooks";
|
|
1244
|
+
import { jsx as jsx25, jsxs as jsxs11 } from "preact/jsx-runtime";
|
|
1245
|
+
function Slider(props) {
|
|
1246
|
+
let start = props.start ?? 0;
|
|
1247
|
+
let end = props.end ?? 1;
|
|
1248
|
+
let value;
|
|
1249
|
+
if (props.value == null)
|
|
1250
|
+
value = useSignal9(0);
|
|
1251
|
+
else if (isSignal(props.value))
|
|
1252
|
+
value = props.value;
|
|
1253
|
+
else
|
|
1254
|
+
value = useSignal9(props.value);
|
|
1255
|
+
const ref = useRef8(null);
|
|
1256
|
+
const dragging = props.dragging ?? useSignal9(false);
|
|
1257
|
+
useEffect6(() => {
|
|
1258
|
+
dragging.subscribe((d) => {
|
|
1259
|
+
if (d)
|
|
1260
|
+
document.addEventListener("pointermove", updateFromEvent);
|
|
1261
|
+
else
|
|
1262
|
+
document.removeEventListener("pointermove", updateFromEvent);
|
|
1263
|
+
});
|
|
1264
|
+
return () => {
|
|
1265
|
+
document.removeEventListener("pointermove", updateFromEvent);
|
|
1266
|
+
};
|
|
1267
|
+
}, []);
|
|
1268
|
+
function update(val) {
|
|
1269
|
+
if (props.step)
|
|
1270
|
+
val = Math.round(val / props.step) * props.step;
|
|
1271
|
+
val = Math.max(start, Math.min(end, val));
|
|
1272
|
+
value.value = val;
|
|
1273
|
+
props.onChange?.(val);
|
|
1274
|
+
if (props.dirty)
|
|
1275
|
+
props.dirty.value = true;
|
|
1276
|
+
}
|
|
1277
|
+
function updateFromEvent(e) {
|
|
1278
|
+
const slider = ref.current;
|
|
1279
|
+
if (!slider)
|
|
1280
|
+
throw `no current ref for slider`;
|
|
1281
|
+
const rect = slider.getBoundingClientRect();
|
|
1282
|
+
const progress = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
1283
|
+
update(progress * (end - start) + start);
|
|
1284
|
+
}
|
|
1285
|
+
let percentValue = (value.value - start) / (end - start);
|
|
1286
|
+
return /* @__PURE__ */ jsx25(
|
|
1287
|
+
"div",
|
|
1288
|
+
{
|
|
1289
|
+
ref,
|
|
1290
|
+
class: addClass(
|
|
1291
|
+
"slider",
|
|
1292
|
+
props.class
|
|
1293
|
+
),
|
|
1294
|
+
onPointerDown: (e) => {
|
|
1295
|
+
dragging.value = true;
|
|
1296
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
1297
|
+
updateFromEvent(e);
|
|
1298
|
+
},
|
|
1299
|
+
onPointerUp: (e) => {
|
|
1300
|
+
dragging.value = false;
|
|
1301
|
+
updateFromEvent(e);
|
|
1302
|
+
},
|
|
1303
|
+
onWheel: (e) => {
|
|
1304
|
+
e.preventDefault();
|
|
1305
|
+
const step = props.step ?? (end - start) / 100;
|
|
1306
|
+
const direction = Math.sign(e.deltaY);
|
|
1307
|
+
update(value.value - direction * step * (props.scroll_speed ?? 1));
|
|
1308
|
+
},
|
|
1309
|
+
children: /* @__PURE__ */ jsxs11("div", { children: [
|
|
1310
|
+
/* @__PURE__ */ jsx25(
|
|
1311
|
+
"div",
|
|
1312
|
+
{
|
|
1313
|
+
class: "progress",
|
|
1314
|
+
style: {
|
|
1315
|
+
width: percentValue * 100 + "%"
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
),
|
|
1319
|
+
/* @__PURE__ */ jsx25("div", { class: "handle" })
|
|
1320
|
+
] })
|
|
1321
|
+
}
|
|
1322
|
+
);
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
// src/components/Table/Table.tsx
|
|
1326
|
+
import { jsx as jsx26 } from "preact/jsx-runtime";
|
|
1327
|
+
function Table(props) {
|
|
1328
|
+
return /* @__PURE__ */ jsx26("table", { class: addClass("table", props.class), children: props.children });
|
|
1329
|
+
}
|
|
1330
|
+
function TableHead(props) {
|
|
1331
|
+
return /* @__PURE__ */ jsx26("thead", { class: props.class, children: props.children });
|
|
1332
|
+
}
|
|
1333
|
+
function TableBody(props) {
|
|
1334
|
+
return /* @__PURE__ */ jsx26("tbody", { class: props.class, children: props.children });
|
|
1335
|
+
}
|
|
1336
|
+
function TableRow(props) {
|
|
1337
|
+
return /* @__PURE__ */ jsx26("tr", { class: props.class, children: props.children });
|
|
1338
|
+
}
|
|
1339
|
+
function TableCell(props) {
|
|
1340
|
+
return /* @__PURE__ */ jsx26("td", { class: props.class, children: props.children });
|
|
1341
|
+
}
|
|
1342
|
+
function TableHeader(props) {
|
|
1343
|
+
return /* @__PURE__ */ jsx26("th", { class: props.class, children: props.children });
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// src/components/Tabs/Tabs.tsx
|
|
1347
|
+
import { useSignal as useSignal10 } from "@preact/signals";
|
|
1348
|
+
import { X } from "lucide-preact";
|
|
1349
|
+
import { jsx as jsx27, jsxs as jsxs12 } from "preact/jsx-runtime";
|
|
1350
|
+
function Tabs(props) {
|
|
1351
|
+
let value;
|
|
1352
|
+
if (isSignal(props.value))
|
|
1353
|
+
value = props.value;
|
|
1354
|
+
else
|
|
1355
|
+
value = useSignal10(props.value);
|
|
1356
|
+
return /* @__PURE__ */ jsx27("div", { class: addClass(
|
|
1357
|
+
"tabs"
|
|
1358
|
+
), children: props.tabs.map((t) => /* @__PURE__ */ jsx27(
|
|
1359
|
+
Tab,
|
|
1360
|
+
{
|
|
1361
|
+
name: t.name,
|
|
1362
|
+
selected: t.value == value.value,
|
|
1363
|
+
onClose: t.onClose,
|
|
1364
|
+
onClick: () => {
|
|
1365
|
+
value.value = t.value;
|
|
1366
|
+
props.onChange?.(t.value);
|
|
1367
|
+
if (props.dirty)
|
|
1368
|
+
props.dirty.value = true;
|
|
1369
|
+
}
|
|
1370
|
+
},
|
|
1371
|
+
String(t.value)
|
|
1372
|
+
)) });
|
|
1373
|
+
}
|
|
1374
|
+
function Tab(props) {
|
|
1375
|
+
return /* @__PURE__ */ jsxs12(Branch, { cond: props.onClose != null, children: [
|
|
1376
|
+
/* @__PURE__ */ jsx27(Then, { children: /* @__PURE__ */ jsxs12(Container, { horizontal: true, no_gap: true, centered_y: true, class: addClass("tab-with-close", props.selected && "selected"), children: [
|
|
1377
|
+
/* @__PURE__ */ jsx27("button", { class: "tab-label", onClick: props.onClick, children: /* @__PURE__ */ jsx27(Text, { content: props.name }) }),
|
|
1378
|
+
/* @__PURE__ */ jsx27(IconButton, { class: "tab-close", title: `Close ${props.name}`, onClick: (event) => {
|
|
1379
|
+
event.stopPropagation();
|
|
1380
|
+
props.onClose?.();
|
|
1381
|
+
}, children: /* @__PURE__ */ jsx27(X, { size: 14 }) })
|
|
1382
|
+
] }) }),
|
|
1383
|
+
/* @__PURE__ */ jsx27(Else, { children: /* @__PURE__ */ jsx27(
|
|
1384
|
+
"button",
|
|
1385
|
+
{
|
|
1386
|
+
type: "button",
|
|
1387
|
+
class: addClass(props.selected && "selected"),
|
|
1388
|
+
onClick: props.onClick,
|
|
1389
|
+
children: /* @__PURE__ */ jsx27("span", { children: props.name })
|
|
1390
|
+
}
|
|
1391
|
+
) })
|
|
1392
|
+
] });
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
// src/components/TagList/TagList.tsx
|
|
1396
|
+
import { X as X2 } from "lucide-preact";
|
|
1397
|
+
import { jsx as jsx28, jsxs as jsxs13 } from "preact/jsx-runtime";
|
|
1398
|
+
function TagList(props) {
|
|
1399
|
+
return /* @__PURE__ */ jsx28("div", { class: "tag-list", children: resolveSignalish(props.tags).map((t) => /* @__PURE__ */ jsx28(
|
|
1400
|
+
Tag,
|
|
1401
|
+
{
|
|
1402
|
+
tag: t
|
|
1403
|
+
}
|
|
1404
|
+
)) });
|
|
1405
|
+
}
|
|
1406
|
+
function Tag(props) {
|
|
1407
|
+
return /* @__PURE__ */ jsxs13("div", { class: addClass(
|
|
1408
|
+
"tag",
|
|
1409
|
+
props.small && "small"
|
|
1410
|
+
), children: [
|
|
1411
|
+
/* @__PURE__ */ jsx28("span", { children: props.tag }),
|
|
1412
|
+
props.onDelete && /* @__PURE__ */ jsx28("button", { onClick: props.onDelete, children: /* @__PURE__ */ jsx28(X2, { size: 13 }) })
|
|
1413
|
+
] });
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
// src/components/TagList/TagListInput.tsx
|
|
1417
|
+
import { useSignal as useSignal11 } from "@preact/signals";
|
|
1418
|
+
import { useRef as useRef9, useState as useState5 } from "preact/hooks";
|
|
1419
|
+
import { jsx as jsx29, jsxs as jsxs14 } from "preact/jsx-runtime";
|
|
1420
|
+
function TagListInput(props) {
|
|
1421
|
+
let value;
|
|
1422
|
+
if (props.value == null)
|
|
1423
|
+
value = useSignal11([]);
|
|
1424
|
+
else if (isSignal(props.value))
|
|
1425
|
+
value = props.value;
|
|
1426
|
+
else
|
|
1427
|
+
value = useSignal11(props.value);
|
|
1428
|
+
const inputRef = useRef9();
|
|
1429
|
+
const [inputValue, setInputValue] = useState5("");
|
|
1430
|
+
return /* @__PURE__ */ jsxs14("div", { class: "tag-list", children: [
|
|
1431
|
+
value.value.map((t, i) => /* @__PURE__ */ jsx29(
|
|
1432
|
+
Tag,
|
|
1433
|
+
{
|
|
1434
|
+
tag: t,
|
|
1435
|
+
onDelete: () => {
|
|
1436
|
+
value.value = value.peek().filter((_, index) => index !== i);
|
|
1437
|
+
props.onChange?.(value.peek());
|
|
1438
|
+
if (props.dirty)
|
|
1439
|
+
props.dirty.value = true;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
)),
|
|
1443
|
+
/* @__PURE__ */ jsx29(
|
|
1444
|
+
"input",
|
|
1445
|
+
{
|
|
1446
|
+
ref: inputRef,
|
|
1447
|
+
value: inputValue,
|
|
1448
|
+
onInput: () => {
|
|
1449
|
+
setInputValue(inputRef.current.value);
|
|
1450
|
+
},
|
|
1451
|
+
placeholder: props.inputPlaceholder,
|
|
1452
|
+
onKeyDown: (ev) => {
|
|
1453
|
+
if (ev.key == "Enter") {
|
|
1454
|
+
ev.preventDefault();
|
|
1455
|
+
const newTag = inputRef.current.value.trim();
|
|
1456
|
+
if (!newTag)
|
|
1457
|
+
return;
|
|
1458
|
+
if (!value.peek().includes(newTag)) {
|
|
1459
|
+
value.value = removeDuplicates([
|
|
1460
|
+
...value.peek(),
|
|
1461
|
+
...newTag.split(",").filter((t) => t.trim()).map((t) => t.toLowerCase())
|
|
1462
|
+
]);
|
|
1463
|
+
props.onChange?.(value.peek());
|
|
1464
|
+
if (props.dirty)
|
|
1465
|
+
props.dirty.value = true;
|
|
1466
|
+
}
|
|
1467
|
+
setInputValue("");
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
)
|
|
1472
|
+
] });
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
// src/components/UploadBox/UploadBox.tsx
|
|
1476
|
+
import { useEffect as useEffect7, useRef as useRef10, useState as useState6 } from "preact/hooks";
|
|
1477
|
+
import { jsx as jsx30, jsxs as jsxs15 } from "preact/jsx-runtime";
|
|
1478
|
+
function UploadBox(props) {
|
|
1479
|
+
const inputRef = useRef10(null);
|
|
1480
|
+
const [dragging, setDragging] = useState6(false);
|
|
1481
|
+
function handleFiles(files) {
|
|
1482
|
+
files = Array.from(files);
|
|
1483
|
+
if (!props.addFile)
|
|
1484
|
+
console.warn("upload box has no addFile function assigned");
|
|
1485
|
+
for (let i = 0; i < files.length; i++) {
|
|
1486
|
+
props.addFile?.(files[i]);
|
|
1487
|
+
;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
useEffect7(() => {
|
|
1491
|
+
const onPaste = (e) => {
|
|
1492
|
+
const files = e.clipboardData?.files;
|
|
1493
|
+
if (files && files.length > 0)
|
|
1494
|
+
handleFiles(files);
|
|
1495
|
+
};
|
|
1496
|
+
window.addEventListener("paste", onPaste);
|
|
1497
|
+
return () => {
|
|
1498
|
+
window.removeEventListener("paste", onPaste);
|
|
1499
|
+
};
|
|
1500
|
+
}, []);
|
|
1501
|
+
return /* @__PURE__ */ jsxs15(
|
|
1502
|
+
"div",
|
|
1503
|
+
{
|
|
1504
|
+
class: addClass(
|
|
1505
|
+
"upload-box",
|
|
1506
|
+
dragging && "dragging",
|
|
1507
|
+
props.class
|
|
1508
|
+
),
|
|
1509
|
+
onClick: () => inputRef.current?.click(),
|
|
1510
|
+
onDragOver: (e) => {
|
|
1511
|
+
e.preventDefault();
|
|
1512
|
+
setDragging(true);
|
|
1513
|
+
},
|
|
1514
|
+
onDragEnter: (e) => {
|
|
1515
|
+
e.preventDefault();
|
|
1516
|
+
setDragging(true);
|
|
1517
|
+
},
|
|
1518
|
+
onDragLeave: (e) => {
|
|
1519
|
+
if (e.currentTarget === e.target) {
|
|
1520
|
+
setDragging(false);
|
|
1521
|
+
}
|
|
1522
|
+
},
|
|
1523
|
+
onDrop: (e) => {
|
|
1524
|
+
e.preventDefault();
|
|
1525
|
+
setDragging(false);
|
|
1526
|
+
if (e.dataTransfer?.files)
|
|
1527
|
+
handleFiles(e.dataTransfer.files);
|
|
1528
|
+
},
|
|
1529
|
+
children: [
|
|
1530
|
+
/* @__PURE__ */ jsx30(
|
|
1531
|
+
"input",
|
|
1532
|
+
{
|
|
1533
|
+
ref: inputRef,
|
|
1534
|
+
type: "file",
|
|
1535
|
+
multiple: true,
|
|
1536
|
+
hidden: true,
|
|
1537
|
+
accept: props.mime && props.mime.join(","),
|
|
1538
|
+
onChange: (e) => {
|
|
1539
|
+
const input = e.currentTarget;
|
|
1540
|
+
if (input.files)
|
|
1541
|
+
handleFiles(input.files);
|
|
1542
|
+
input.value = "";
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
),
|
|
1546
|
+
props.children
|
|
1547
|
+
]
|
|
1548
|
+
}
|
|
1549
|
+
);
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// src/components/WrapList/WrapList.tsx
|
|
1553
|
+
import { jsx as jsx31 } from "preact/jsx-runtime";
|
|
1554
|
+
function WrapList(props) {
|
|
1555
|
+
return /* @__PURE__ */ jsx31(
|
|
1556
|
+
"div",
|
|
1557
|
+
{
|
|
1558
|
+
class: "wrap-list",
|
|
1559
|
+
style: {
|
|
1560
|
+
"--min-size": (props.min_size ?? 150) + "px"
|
|
1561
|
+
},
|
|
1562
|
+
children: props.children
|
|
1563
|
+
}
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
export {
|
|
1568
|
+
Button,
|
|
1569
|
+
TextButton,
|
|
1570
|
+
IconButton,
|
|
1571
|
+
TextIconButton,
|
|
1572
|
+
LinkButton,
|
|
1573
|
+
TextLinkButton,
|
|
1574
|
+
IconLinkButton,
|
|
1575
|
+
TextIconLinkButton,
|
|
1576
|
+
Container,
|
|
1577
|
+
MainContainer,
|
|
1578
|
+
HeaderContainer,
|
|
1579
|
+
FooterContainer,
|
|
1580
|
+
PopoutContainer,
|
|
1581
|
+
PopoutTextButton,
|
|
1582
|
+
PopoutIconButton,
|
|
1583
|
+
PopoutTextIconButton,
|
|
1584
|
+
Input,
|
|
1585
|
+
CalendarInput,
|
|
1586
|
+
ClickFade,
|
|
1587
|
+
If,
|
|
1588
|
+
Switch,
|
|
1589
|
+
Case,
|
|
1590
|
+
Branch,
|
|
1591
|
+
Then,
|
|
1592
|
+
Else,
|
|
1593
|
+
Content,
|
|
1594
|
+
Text,
|
|
1595
|
+
closeContextMenu,
|
|
1596
|
+
openContextMenu,
|
|
1597
|
+
openContextMenuOn,
|
|
1598
|
+
DotSeperator,
|
|
1599
|
+
getFileIcon,
|
|
1600
|
+
FileIcon,
|
|
1601
|
+
FilePath,
|
|
1602
|
+
Label,
|
|
1603
|
+
FormalInput,
|
|
1604
|
+
Header1,
|
|
1605
|
+
Header2,
|
|
1606
|
+
Header3,
|
|
1607
|
+
MiniHeader,
|
|
1608
|
+
Image2 as Image,
|
|
1609
|
+
ImageInput,
|
|
1610
|
+
Textarea,
|
|
1611
|
+
Throbber,
|
|
1612
|
+
Loading,
|
|
1613
|
+
PathInput,
|
|
1614
|
+
SelectBox,
|
|
1615
|
+
Seperator,
|
|
1616
|
+
Slider,
|
|
1617
|
+
Table,
|
|
1618
|
+
TableHead,
|
|
1619
|
+
TableBody,
|
|
1620
|
+
TableRow,
|
|
1621
|
+
TableCell,
|
|
1622
|
+
TableHeader,
|
|
1623
|
+
Tabs,
|
|
1624
|
+
TagList,
|
|
1625
|
+
Tag,
|
|
1626
|
+
TagListInput,
|
|
1627
|
+
UploadBox,
|
|
1628
|
+
WrapList
|
|
1629
|
+
};
|