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,179 @@
|
|
|
1
|
+
// src/types/signalish.ts
|
|
2
|
+
function isSignal(value) {
|
|
3
|
+
return value !== null && typeof value === "object" && "value" in value;
|
|
4
|
+
}
|
|
5
|
+
function resolveSignalish(signalish) {
|
|
6
|
+
if (isSignal(signalish))
|
|
7
|
+
return signalish.value;
|
|
8
|
+
return signalish;
|
|
9
|
+
}
|
|
10
|
+
function peekSignalish(signalish) {
|
|
11
|
+
if (isSignal(signalish))
|
|
12
|
+
return signalish.peek();
|
|
13
|
+
return signalish;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/types/date.ts
|
|
17
|
+
var CalendarDate = class _CalendarDate {
|
|
18
|
+
constructor(date) {
|
|
19
|
+
this.date = date;
|
|
20
|
+
}
|
|
21
|
+
static now() {
|
|
22
|
+
return _CalendarDate.fromDate(/* @__PURE__ */ new Date());
|
|
23
|
+
}
|
|
24
|
+
static fromString(value) {
|
|
25
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
26
|
+
if (!match) {
|
|
27
|
+
throw new Error(`invalid calendar date ${value}`);
|
|
28
|
+
}
|
|
29
|
+
const year = Number(match[1]);
|
|
30
|
+
const month = Number(match[2]);
|
|
31
|
+
const day = Number(match[3]);
|
|
32
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
33
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) {
|
|
34
|
+
throw new Error(`invalid calendar date ${value}`);
|
|
35
|
+
}
|
|
36
|
+
return new _CalendarDate(date);
|
|
37
|
+
}
|
|
38
|
+
static fromParts(year, month, day) {
|
|
39
|
+
return _CalendarDate.fromString(
|
|
40
|
+
`${year.toString().padStart(4, "0")}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
static fromDate(date) {
|
|
44
|
+
return new _CalendarDate(
|
|
45
|
+
new Date(Date.UTC(
|
|
46
|
+
date.getFullYear(),
|
|
47
|
+
date.getMonth(),
|
|
48
|
+
date.getDate()
|
|
49
|
+
))
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
static parseDateInput(input) {
|
|
53
|
+
const match = input.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{2}|\d{4})$/);
|
|
54
|
+
if (!match)
|
|
55
|
+
return null;
|
|
56
|
+
let day = Number(match[1]);
|
|
57
|
+
let month = Number(match[2]);
|
|
58
|
+
let year = Number(match[3]);
|
|
59
|
+
if (match[3].length === 2)
|
|
60
|
+
year += year >= 50 ? 1900 : 2e3;
|
|
61
|
+
try {
|
|
62
|
+
const date = _CalendarDate.fromParts(year, month, day);
|
|
63
|
+
if (date.year !== year || date.month !== month || date.day !== day)
|
|
64
|
+
return null;
|
|
65
|
+
return date;
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
toString() {
|
|
71
|
+
const year = this.date.getUTCFullYear();
|
|
72
|
+
const month = String(this.date.getUTCMonth() + 1).padStart(2, "0");
|
|
73
|
+
const day = String(this.date.getUTCDate()).padStart(2, "0");
|
|
74
|
+
return `${year}-${month}-${day}`;
|
|
75
|
+
}
|
|
76
|
+
toDisplayString() {
|
|
77
|
+
return `${this.day.toString().padStart(2, "0")}/${this.month.toString().padStart(2, "0")}/${this.year.toString().padStart(4, "0")}`;
|
|
78
|
+
}
|
|
79
|
+
toDate() {
|
|
80
|
+
return new Date(this.date);
|
|
81
|
+
}
|
|
82
|
+
compare(other) {
|
|
83
|
+
return this.date.getTime() - other.date.getTime();
|
|
84
|
+
}
|
|
85
|
+
isBefore(other) {
|
|
86
|
+
return this.compare(other) < 0;
|
|
87
|
+
}
|
|
88
|
+
isAfter(other) {
|
|
89
|
+
return this.compare(other) > 0;
|
|
90
|
+
}
|
|
91
|
+
isSame(other) {
|
|
92
|
+
return this.compare(other) === 0;
|
|
93
|
+
}
|
|
94
|
+
isBeforeOrEqual(other) {
|
|
95
|
+
return this.compare(other) <= 0;
|
|
96
|
+
}
|
|
97
|
+
isAfterOrEqual(other) {
|
|
98
|
+
return this.compare(other) >= 0;
|
|
99
|
+
}
|
|
100
|
+
get year() {
|
|
101
|
+
return this.date.getUTCFullYear();
|
|
102
|
+
}
|
|
103
|
+
get month() {
|
|
104
|
+
return this.date.getUTCMonth() + 1;
|
|
105
|
+
}
|
|
106
|
+
get day() {
|
|
107
|
+
return this.date.getUTCDate();
|
|
108
|
+
}
|
|
109
|
+
get parts() {
|
|
110
|
+
return {
|
|
111
|
+
year: this.year,
|
|
112
|
+
month: this.month,
|
|
113
|
+
day: this.day
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/types/maybefunc.ts
|
|
119
|
+
function resolveMaybeFunc(maybe_func) {
|
|
120
|
+
if (typeof maybe_func == "function")
|
|
121
|
+
return maybe_func();
|
|
122
|
+
return maybe_func;
|
|
123
|
+
}
|
|
124
|
+
async function resolveMaybeAsyncFunc(maybe_func) {
|
|
125
|
+
if (typeof maybe_func == "function")
|
|
126
|
+
return await maybe_func();
|
|
127
|
+
return maybe_func;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/types/maybeloaded.ts
|
|
131
|
+
import { computed } from "@preact/signals";
|
|
132
|
+
var loaded = (val) => ["maybeloaded", true, val];
|
|
133
|
+
var notLoaded = () => ["maybeloaded", false];
|
|
134
|
+
var maybeLoadedIsLoaded = (value) => value[1];
|
|
135
|
+
var maybeLoadedIsNotLoaded = (value) => !value[1];
|
|
136
|
+
var maybeLoadedUnwrap = (value) => {
|
|
137
|
+
if (maybeLoadedIsLoaded(value))
|
|
138
|
+
return value[2];
|
|
139
|
+
throw "value not loaded";
|
|
140
|
+
};
|
|
141
|
+
var maybeLoadedMap = (value, fn) => {
|
|
142
|
+
console.log("val", value[2]);
|
|
143
|
+
if (maybeLoadedIsLoaded(value))
|
|
144
|
+
return loaded(fn(value[2]));
|
|
145
|
+
return notLoaded();
|
|
146
|
+
};
|
|
147
|
+
var convertPossibleNullishToMaybeLoaded = (value) => {
|
|
148
|
+
const val = peekSignalish(value);
|
|
149
|
+
if (val != null)
|
|
150
|
+
return loaded(val);
|
|
151
|
+
return notLoaded();
|
|
152
|
+
};
|
|
153
|
+
var convertPossibleNullishSignalToMaybeLoaded = (value) => {
|
|
154
|
+
return computed(() => {
|
|
155
|
+
const val = value.value;
|
|
156
|
+
if (val != null)
|
|
157
|
+
return loaded(val);
|
|
158
|
+
return notLoaded();
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
var isMaybeLoaded = (value) => Array.isArray(value) && value[0] == "maybeloaded";
|
|
162
|
+
|
|
163
|
+
export {
|
|
164
|
+
isSignal,
|
|
165
|
+
resolveSignalish,
|
|
166
|
+
peekSignalish,
|
|
167
|
+
CalendarDate,
|
|
168
|
+
resolveMaybeFunc,
|
|
169
|
+
resolveMaybeAsyncFunc,
|
|
170
|
+
loaded,
|
|
171
|
+
notLoaded,
|
|
172
|
+
maybeLoadedIsLoaded,
|
|
173
|
+
maybeLoadedIsNotLoaded,
|
|
174
|
+
maybeLoadedUnwrap,
|
|
175
|
+
maybeLoadedMap,
|
|
176
|
+
convertPossibleNullishToMaybeLoaded,
|
|
177
|
+
convertPossibleNullishSignalToMaybeLoaded,
|
|
178
|
+
isMaybeLoaded
|
|
179
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// src/common/utils.ts
|
|
2
|
+
function addClass(...args) {
|
|
3
|
+
return args.filter((a) => a != null && a != false).reduce((acc, c) => {
|
|
4
|
+
if (acc == null)
|
|
5
|
+
return c;
|
|
6
|
+
return `${acc} ${c}`;
|
|
7
|
+
}, void 0);
|
|
8
|
+
}
|
|
9
|
+
function addTitle(...args) {
|
|
10
|
+
return args.filter((a) => a != null && a != false).reduce((acc, c) => {
|
|
11
|
+
if (acc == null)
|
|
12
|
+
return c;
|
|
13
|
+
return `${acc} ${c}`;
|
|
14
|
+
}, void 0);
|
|
15
|
+
}
|
|
16
|
+
function addStyles(...args) {
|
|
17
|
+
return args.filter((a) => a != null && a != false).reduce((acc, c) => {
|
|
18
|
+
if (acc == null)
|
|
19
|
+
return c;
|
|
20
|
+
return {
|
|
21
|
+
...acc,
|
|
22
|
+
...c
|
|
23
|
+
};
|
|
24
|
+
}, void 0);
|
|
25
|
+
}
|
|
26
|
+
var syncWrap = (func) => (() => {
|
|
27
|
+
func();
|
|
28
|
+
});
|
|
29
|
+
function removeIndent(input) {
|
|
30
|
+
const lines = input.split("\n");
|
|
31
|
+
while (lines[0]?.trim() == "")
|
|
32
|
+
lines.shift();
|
|
33
|
+
while (lines[lines.length - 1]?.trim() == "")
|
|
34
|
+
lines.pop();
|
|
35
|
+
const nonEmpty = lines.filter((l) => l.trim() !== "");
|
|
36
|
+
if (nonEmpty.length === 0)
|
|
37
|
+
return input;
|
|
38
|
+
const minIndent = Math.min(
|
|
39
|
+
...nonEmpty.map((l) => l.match(/^ */)[0].length)
|
|
40
|
+
);
|
|
41
|
+
return lines.map((l) => l.slice(minIndent)).join("\n");
|
|
42
|
+
}
|
|
43
|
+
function isNearBottom(container, distance = 50) {
|
|
44
|
+
return container.scrollHeight - container.scrollTop - container.clientHeight < distance;
|
|
45
|
+
}
|
|
46
|
+
function isNearTop(container, distance = 50) {
|
|
47
|
+
return container.scrollTop < distance;
|
|
48
|
+
}
|
|
49
|
+
function calcHeight(elem, offset = 0) {
|
|
50
|
+
elem.style.height = "auto";
|
|
51
|
+
elem.style.height = elem.scrollHeight - elem.offsetHeight + elem.clientHeight + offset + "px";
|
|
52
|
+
}
|
|
53
|
+
function createQuery(...attrs) {
|
|
54
|
+
return attrs.filter((a) => a != null && a != false).reduce((acc, c) => {
|
|
55
|
+
if (!c[1])
|
|
56
|
+
return acc;
|
|
57
|
+
let val;
|
|
58
|
+
if (Array.isArray(c[1]))
|
|
59
|
+
val = c[1].map((a) => encodeURIComponent(a.toString())).join(",");
|
|
60
|
+
else
|
|
61
|
+
val = encodeURIComponent(c[1].toString());
|
|
62
|
+
if (acc)
|
|
63
|
+
return `${acc}&${c[0]}=${val}`;
|
|
64
|
+
return `?${c[0]}=${val}`;
|
|
65
|
+
}, "");
|
|
66
|
+
}
|
|
67
|
+
function splitPath(path) {
|
|
68
|
+
const parts = [];
|
|
69
|
+
if (path.startsWith("/")) {
|
|
70
|
+
parts.push("/");
|
|
71
|
+
path = path.slice(1);
|
|
72
|
+
}
|
|
73
|
+
if (path)
|
|
74
|
+
parts.push(...path.split(/\/|\\/).filter((p) => !!p));
|
|
75
|
+
return parts;
|
|
76
|
+
}
|
|
77
|
+
function joinPathParts(parts) {
|
|
78
|
+
let str = "";
|
|
79
|
+
if (parts[0] == "/") {
|
|
80
|
+
str += "/";
|
|
81
|
+
parts = parts.slice(1);
|
|
82
|
+
}
|
|
83
|
+
str += parts.join("/");
|
|
84
|
+
return str;
|
|
85
|
+
}
|
|
86
|
+
function joinPath(base, other) {
|
|
87
|
+
if (!base.endsWith("/"))
|
|
88
|
+
base = base + "/";
|
|
89
|
+
return base + other;
|
|
90
|
+
}
|
|
91
|
+
function splitFilePath(path) {
|
|
92
|
+
const slash = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
|
|
93
|
+
const dir = path.slice(0, slash + 1);
|
|
94
|
+
const filename = path.slice(slash + 1);
|
|
95
|
+
const dot = filename.lastIndexOf(".");
|
|
96
|
+
if (dot <= 0)
|
|
97
|
+
return [dir, filename];
|
|
98
|
+
return [dir, filename.slice(0, dot), filename.slice(dot + 1)];
|
|
99
|
+
}
|
|
100
|
+
function addExt(path, ext) {
|
|
101
|
+
if (ext)
|
|
102
|
+
return `${path}.${ext}`;
|
|
103
|
+
return path;
|
|
104
|
+
}
|
|
105
|
+
var removeDuplicates = (arr) => [...new Set(arr)];
|
|
106
|
+
function tryExtractName(file) {
|
|
107
|
+
if (/^\d+\s*[-.]\s*/.test(file))
|
|
108
|
+
file = file.match(/^\d+\s*[-.]\s*(.*)/)?.[1] ?? file;
|
|
109
|
+
if (/\.\w+$/.test(file))
|
|
110
|
+
file = file.replace(/\.\w+$/, "");
|
|
111
|
+
return file;
|
|
112
|
+
}
|
|
113
|
+
var iterate = (count, func) => Array(count).fill(null).map((_, i) => func != null ? func(i) : void 0);
|
|
114
|
+
|
|
115
|
+
// src/common/state.ts
|
|
116
|
+
import { signal } from "@preact/signals";
|
|
117
|
+
var isMobile = () => typeof window !== "undefined" && window.innerWidth < 800;
|
|
118
|
+
var MOBILE = signal(isMobile());
|
|
119
|
+
if (typeof window !== "undefined") {
|
|
120
|
+
window.addEventListener("resize", () => {
|
|
121
|
+
MOBILE.value = isMobile();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
addClass,
|
|
127
|
+
addTitle,
|
|
128
|
+
addStyles,
|
|
129
|
+
syncWrap,
|
|
130
|
+
removeIndent,
|
|
131
|
+
isNearBottom,
|
|
132
|
+
isNearTop,
|
|
133
|
+
calcHeight,
|
|
134
|
+
createQuery,
|
|
135
|
+
splitPath,
|
|
136
|
+
joinPathParts,
|
|
137
|
+
joinPath,
|
|
138
|
+
splitFilePath,
|
|
139
|
+
addExt,
|
|
140
|
+
removeDuplicates,
|
|
141
|
+
tryExtractName,
|
|
142
|
+
iterate,
|
|
143
|
+
MOBILE
|
|
144
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// src/types/mime.ts
|
|
2
|
+
var isMime = (value) => /^\w+\/\w+$/.test(value);
|
|
3
|
+
var imageMimeTypes = [
|
|
4
|
+
"image/apng",
|
|
5
|
+
"image/avif",
|
|
6
|
+
"image/bmp",
|
|
7
|
+
"image/gif",
|
|
8
|
+
"image/jpeg",
|
|
9
|
+
"image/png",
|
|
10
|
+
"image/svg+xml",
|
|
11
|
+
"image/tiff",
|
|
12
|
+
"image/webp",
|
|
13
|
+
"image/x-icon",
|
|
14
|
+
"image/heic",
|
|
15
|
+
"image/heif"
|
|
16
|
+
];
|
|
17
|
+
var audioMimeTypes = [
|
|
18
|
+
"audio/aac",
|
|
19
|
+
"audio/flac",
|
|
20
|
+
"audio/midi",
|
|
21
|
+
"audio/mpeg",
|
|
22
|
+
"audio/ogg",
|
|
23
|
+
"audio/opus",
|
|
24
|
+
"audio/wav",
|
|
25
|
+
"audio/webm",
|
|
26
|
+
"audio/mp4",
|
|
27
|
+
"audio/x-m4a",
|
|
28
|
+
"audio/x-wav"
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// src/types/result.ts
|
|
32
|
+
var ok = (val) => ["result", true, val];
|
|
33
|
+
var err = (val) => ["result", false, val];
|
|
34
|
+
var resultIsOk = (result) => result[1];
|
|
35
|
+
var resultIsErr = (result) => !result[1];
|
|
36
|
+
var resultUnwrap = (result) => {
|
|
37
|
+
if (resultIsOk(result))
|
|
38
|
+
return result[2];
|
|
39
|
+
throw `result err ${result[2]}`;
|
|
40
|
+
};
|
|
41
|
+
var resultUnwrapErr = (result) => {
|
|
42
|
+
if (resultIsErr(result))
|
|
43
|
+
return result[2];
|
|
44
|
+
throw `result ok ${result[2]}`;
|
|
45
|
+
};
|
|
46
|
+
var resultMap = (result, fn) => {
|
|
47
|
+
if (resultIsOk(result))
|
|
48
|
+
return ok(fn(result[1]));
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
var resultMapErr = (result, fn) => {
|
|
52
|
+
if (resultIsErr(result))
|
|
53
|
+
return err(fn(result[1]));
|
|
54
|
+
return result;
|
|
55
|
+
};
|
|
56
|
+
var resultEqual = (a, b) => a[1] == b[1] && a[2] == b[2];
|
|
57
|
+
var isResult = (value) => Array.isArray(value) && value[0] == "result";
|
|
58
|
+
|
|
59
|
+
// src/types/uuid.ts
|
|
60
|
+
var generateUuid = () => crypto.randomUUID();
|
|
61
|
+
var isUuid = (value) => /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
isMime,
|
|
65
|
+
imageMimeTypes,
|
|
66
|
+
audioMimeTypes,
|
|
67
|
+
ok,
|
|
68
|
+
err,
|
|
69
|
+
resultIsOk,
|
|
70
|
+
resultIsErr,
|
|
71
|
+
resultUnwrap,
|
|
72
|
+
resultUnwrapErr,
|
|
73
|
+
resultMap,
|
|
74
|
+
resultMapErr,
|
|
75
|
+
resultEqual,
|
|
76
|
+
isResult,
|
|
77
|
+
generateUuid,
|
|
78
|
+
isUuid
|
|
79
|
+
};
|