reifyui 0.6.2 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +525 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +513 -77
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/src/components/FileCard.jsx +64 -0
- package/src/components/FilePreview.jsx +207 -0
- package/src/components/FileTypeIcon.jsx +48 -0
- package/src/components/form.jsx +82 -0
- package/src/components/icons.jsx +2 -0
- package/src/index.js +10 -2
- package/src/sheet/SheetGrid.jsx +33 -4
- package/styles/file.css +129 -0
- package/styles/form.css +65 -0
- package/styles/sheet.css +6 -2
package/dist/index.cjs
CHANGED
|
@@ -16,21 +16,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (
|
|
19
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
20
20
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
21
|
// file that has been converted to a CommonJS file using a Babel-
|
|
22
22
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
23
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !
|
|
25
|
-
|
|
24
|
+
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
25
|
+
mod2
|
|
26
26
|
));
|
|
27
|
-
var __toCommonJS = (
|
|
27
|
+
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
|
28
28
|
|
|
29
29
|
// src/index.js
|
|
30
30
|
var src_exports = {};
|
|
31
31
|
__export(src_exports, {
|
|
32
32
|
AssistantTurn: () => AssistantTurn,
|
|
33
33
|
AuthForm: () => AuthForm,
|
|
34
|
+
Button: () => Button,
|
|
34
35
|
Card: () => Card,
|
|
35
36
|
Carousel: () => Carousel,
|
|
36
37
|
ChatMessages: () => ChatMessages,
|
|
@@ -42,10 +43,17 @@ __export(src_exports, {
|
|
|
42
43
|
Composer: () => Composer,
|
|
43
44
|
DEFAULT_STATUS_LABELS: () => DEFAULT_STATUS_LABELS,
|
|
44
45
|
DialogHost: () => DialogHost,
|
|
46
|
+
Field: () => Field,
|
|
47
|
+
FileCard: () => FileCard,
|
|
48
|
+
FilePreview: () => FilePreview,
|
|
49
|
+
FileTypeIcon: () => FileTypeIcon,
|
|
50
|
+
FormActions: () => FormActions,
|
|
45
51
|
GOOGLE_ENABLED: () => GOOGLE_ENABLED,
|
|
46
52
|
GoogleButton: () => GoogleButton,
|
|
47
53
|
IcCheck: () => IcCheck,
|
|
48
54
|
IcDoc: () => IcDoc,
|
|
55
|
+
IcDownload: () => IcDownload,
|
|
56
|
+
IcEye: () => IcEye,
|
|
49
57
|
IcGlobe: () => IcGlobe,
|
|
50
58
|
IcList: () => IcList,
|
|
51
59
|
IcMic: () => IcMic,
|
|
@@ -61,14 +69,17 @@ __export(src_exports, {
|
|
|
61
69
|
IcThink: () => IcThink,
|
|
62
70
|
IcTool: () => IcTool,
|
|
63
71
|
IcX: () => IcX,
|
|
72
|
+
Input: () => Input,
|
|
64
73
|
Modal: () => Modal,
|
|
65
74
|
PaneResizer: () => PaneResizer,
|
|
66
75
|
Popover: () => Popover,
|
|
67
76
|
SESSION_EVENT: () => SESSION_EVENT,
|
|
68
77
|
SearchField: () => SearchField,
|
|
78
|
+
Select: () => Select,
|
|
69
79
|
SheetGrid: () => SheetGrid,
|
|
70
80
|
Svg: () => Svg,
|
|
71
81
|
TaskList: () => TaskList,
|
|
82
|
+
Textarea: () => Textarea,
|
|
72
83
|
ToolGroup: () => ToolGroup,
|
|
73
84
|
ToolRow: () => ToolRow,
|
|
74
85
|
UserTurn: () => UserTurn,
|
|
@@ -82,7 +93,9 @@ __export(src_exports, {
|
|
|
82
93
|
createConversationStore: () => createConversationStore,
|
|
83
94
|
createDictation: () => createDictation,
|
|
84
95
|
createResponsesDispatcher: () => createResponsesDispatcher,
|
|
96
|
+
extOf: () => extOf,
|
|
85
97
|
fetchBalance: () => fetchBalance,
|
|
98
|
+
fitRowHeights: () => fitRowHeights,
|
|
86
99
|
getSession: () => getSession,
|
|
87
100
|
getToken: () => getToken,
|
|
88
101
|
googleSignIn: () => googleSignIn,
|
|
@@ -406,6 +419,15 @@ var IcPanelRight = ({ size = 17 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx
|
|
|
406
419
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
|
|
407
420
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15 4v16" })
|
|
408
421
|
] });
|
|
422
|
+
var IcDownload = ({ size = 16 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Svg, { s: size, children: [
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
424
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M7 10l5 5 5-5" }),
|
|
425
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 15V3" })
|
|
426
|
+
] });
|
|
427
|
+
var IcEye = ({ size = 15 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Svg, { s: size, children: [
|
|
428
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7z" }),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "12", r: "3" })
|
|
430
|
+
] });
|
|
409
431
|
|
|
410
432
|
// src/components/toolMeta.js
|
|
411
433
|
function humanize(s) {
|
|
@@ -1342,8 +1364,8 @@ function canonicalLang(tag) {
|
|
|
1342
1364
|
var _ready = /* @__PURE__ */ new Map();
|
|
1343
1365
|
function ensureLanguage(name) {
|
|
1344
1366
|
if (!_ready.has(name)) {
|
|
1345
|
-
const p = Promise.all([loadHljs(), GRAMMARS[name]()]).then(([hljs,
|
|
1346
|
-
if (!hljs.getLanguage(name)) hljs.registerLanguage(name,
|
|
1367
|
+
const p = Promise.all([loadHljs(), GRAMMARS[name]()]).then(([hljs, mod2]) => {
|
|
1368
|
+
if (!hljs.getLanguage(name)) hljs.registerLanguage(name, mod2.default || mod2);
|
|
1347
1369
|
return hljs;
|
|
1348
1370
|
}).catch(() => null);
|
|
1349
1371
|
_ready.set(name, p);
|
|
@@ -1788,7 +1810,7 @@ function PromptBody({ spec, onClose, t, titleId }) {
|
|
|
1788
1810
|
const [value, setValue] = (0, import_react12.useState)(spec.defaultValue ?? "");
|
|
1789
1811
|
const [err, setErr] = (0, import_react12.useState)(null);
|
|
1790
1812
|
const inputId = (0, import_react12.useId)();
|
|
1791
|
-
const
|
|
1813
|
+
const Field2 = spec.multiline ? "textarea" : "input";
|
|
1792
1814
|
const submit = () => {
|
|
1793
1815
|
const invalid = spec.validate?.(value);
|
|
1794
1816
|
if (invalid) {
|
|
@@ -1807,7 +1829,7 @@ function PromptBody({ spec, onClose, t, titleId }) {
|
|
|
1807
1829
|
spec.message ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "rui-dlg-msg", children: spec.message }) : null,
|
|
1808
1830
|
spec.label ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { className: "rui-dlg-label", htmlFor: inputId, children: spec.label }) : null,
|
|
1809
1831
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1810
|
-
|
|
1832
|
+
Field2,
|
|
1811
1833
|
{
|
|
1812
1834
|
id: inputId,
|
|
1813
1835
|
className: `rui-dlg-input${err ? " is-err" : ""}`,
|
|
@@ -2119,7 +2141,7 @@ var GOOGLE_ENABLED = !!CLIENT_ID;
|
|
|
2119
2141
|
|
|
2120
2142
|
// src/auth/AuthForm.jsx
|
|
2121
2143
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2122
|
-
function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
2144
|
+
function AuthForm({ onDone, subtitle: subtitle2, brand = null, productName = "" }) {
|
|
2123
2145
|
const [mode, setMode] = (0, import_react14.useState)("signin");
|
|
2124
2146
|
const [email, setEmail] = (0, import_react14.useState)("");
|
|
2125
2147
|
const [password, setPassword] = (0, import_react14.useState)("");
|
|
@@ -2195,7 +2217,7 @@ function AuthForm({ onDone, subtitle, brand = null, productName = "" }) {
|
|
|
2195
2217
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("form", { onSubmit: submit, children: [
|
|
2196
2218
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "logo", children: brand }),
|
|
2197
2219
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h1", { children: mode === "register" ? "Create your account" : mode === "forgot" ? "Reset password" : "Sign in" }),
|
|
2198
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." :
|
|
2220
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "sub", children: mode === "register" ? "Get started in seconds." : mode === "forgot" ? "We will email you a reset link." : subtitle2 || "Welcome back." }),
|
|
2199
2221
|
mode === "forgot" ? resetSent ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2200
2222
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "auth-note", children: [
|
|
2201
2223
|
"If an account exists for ",
|
|
@@ -2747,6 +2769,7 @@ function SheetGrid({
|
|
|
2747
2769
|
rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2748
2770
|
"tr",
|
|
2749
2771
|
{
|
|
2772
|
+
"data-row-id": row.id,
|
|
2750
2773
|
style: {
|
|
2751
2774
|
...rowHeight(row) ? { height: rowHeight(row) } : null,
|
|
2752
2775
|
"--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
|
|
@@ -2788,6 +2811,7 @@ function SheetGrid({
|
|
|
2788
2811
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2789
2812
|
"td",
|
|
2790
2813
|
{
|
|
2814
|
+
"data-col-id": col.id,
|
|
2791
2815
|
className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
|
|
2792
2816
|
style: peer ? { boxShadow: `inset 0 0 0 2px ${peer.color}` } : void 0,
|
|
2793
2817
|
onClick: (e) => {
|
|
@@ -2824,29 +2848,22 @@ function SheetGrid({
|
|
|
2824
2848
|
)
|
|
2825
2849
|
] }),
|
|
2826
2850
|
peer && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "shg-peer-flag", style: { background: peer.color }, children: peer.name }),
|
|
2827
|
-
isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2828
|
-
|
|
2829
|
-
{
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
},
|
|
2844
|
-
children: "\u25B6"
|
|
2845
|
-
}
|
|
2846
|
-
)
|
|
2847
|
-
] })
|
|
2848
|
-
}
|
|
2849
|
-
)
|
|
2851
|
+
isEditing ? renderEditor(col) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "shg-val", children: custom !== void 0 ? custom : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
2852
|
+
computed && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(StatusDot, { status: c.status }),
|
|
2853
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CellValue, { cell: c, col, fetchBlobUrl, onOpenResource }),
|
|
2854
|
+
computed && !readOnly && onRunCell && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2855
|
+
"button",
|
|
2856
|
+
{
|
|
2857
|
+
className: "shg-runcell",
|
|
2858
|
+
title: "Run this cell",
|
|
2859
|
+
onClick: (e) => {
|
|
2860
|
+
e.stopPropagation();
|
|
2861
|
+
onRunCell(row.id, col.id);
|
|
2862
|
+
},
|
|
2863
|
+
children: "\u25B6"
|
|
2864
|
+
}
|
|
2865
|
+
)
|
|
2866
|
+
] }) })
|
|
2850
2867
|
]
|
|
2851
2868
|
},
|
|
2852
2869
|
col.id
|
|
@@ -3055,6 +3072,21 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
|
|
|
3055
3072
|
}
|
|
3056
3073
|
);
|
|
3057
3074
|
}
|
|
3075
|
+
function fitRowHeights(container, { rowIds, min = 34, max = 320, padding = 12 } = {}) {
|
|
3076
|
+
if (!container) return {};
|
|
3077
|
+
const out = {};
|
|
3078
|
+
const rows = container.querySelectorAll("tr[data-row-id]");
|
|
3079
|
+
for (const tr of rows) {
|
|
3080
|
+
const id = tr.getAttribute("data-row-id");
|
|
3081
|
+
if (rowIds && !rowIds.includes(id)) continue;
|
|
3082
|
+
let tallest = 0;
|
|
3083
|
+
for (const cell of tr.querySelectorAll("td[data-col-id] .shg-val")) {
|
|
3084
|
+
tallest = Math.max(tallest, cell.scrollHeight);
|
|
3085
|
+
}
|
|
3086
|
+
if (tallest) out[id] = Math.min(max, Math.max(min, Math.round(tallest + padding)));
|
|
3087
|
+
}
|
|
3088
|
+
return out;
|
|
3089
|
+
}
|
|
3058
3090
|
function defaultCellText(cell) {
|
|
3059
3091
|
const v = cell?.value;
|
|
3060
3092
|
if (v == null) return "";
|
|
@@ -3091,15 +3123,419 @@ function sheetToAoA(sheet, { cellText = defaultCellValue } = {}) {
|
|
|
3091
3123
|
];
|
|
3092
3124
|
}
|
|
3093
3125
|
|
|
3094
|
-
// src/components/
|
|
3095
|
-
var import_react16 =
|
|
3126
|
+
// src/components/FileTypeIcon.jsx
|
|
3127
|
+
var import_react16 = require("react");
|
|
3096
3128
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3129
|
+
function extOf(name) {
|
|
3130
|
+
const m = String(name || "").toLowerCase().match(/\.([a-z0-9]+)$/);
|
|
3131
|
+
return m ? m[1] : "";
|
|
3132
|
+
}
|
|
3133
|
+
var mod = null;
|
|
3134
|
+
var tried = false;
|
|
3135
|
+
function FileTypeIcon({ name, size = 36 }) {
|
|
3136
|
+
const [, force] = (0, import_react16.useState)(0);
|
|
3137
|
+
const ext = extOf(name);
|
|
3138
|
+
(0, import_react16.useEffect)(() => {
|
|
3139
|
+
if (tried || mod) return;
|
|
3140
|
+
tried = true;
|
|
3141
|
+
import("react-file-icon").then((m) => {
|
|
3142
|
+
mod = m;
|
|
3143
|
+
force((n) => n + 1);
|
|
3144
|
+
}).catch(() => {
|
|
3145
|
+
});
|
|
3146
|
+
}, []);
|
|
3147
|
+
const box = { width: size, height: Math.round(size * 1.16), display: "inline-block", flex: "0 0 auto" };
|
|
3148
|
+
if (!mod) {
|
|
3149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "uic-fileglyph", style: box, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "uic-fileglyph-ext", children: (ext || "file").slice(0, 4) }) });
|
|
3150
|
+
}
|
|
3151
|
+
const { FileIcon, defaultStyles } = mod;
|
|
3152
|
+
const style = defaultStyles?.[ext] || {};
|
|
3153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { style: box, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FileIcon, { extension: ext || void 0, ...style }) });
|
|
3154
|
+
}
|
|
3155
|
+
|
|
3156
|
+
// src/components/FileCard.jsx
|
|
3157
|
+
var import_react17 = require("react");
|
|
3158
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3159
|
+
function subtitle(name, origin, bytes) {
|
|
3160
|
+
const parts = [(extOf(name) || "file").toUpperCase()];
|
|
3161
|
+
if (origin) parts.push(origin);
|
|
3162
|
+
if (bytes != null) parts.push(bytesLabel2(bytes));
|
|
3163
|
+
return parts.join(" \xB7 ");
|
|
3164
|
+
}
|
|
3165
|
+
function bytesLabel2(n) {
|
|
3166
|
+
if (n == null) return "";
|
|
3167
|
+
if (n < 1024) return `${n} B`;
|
|
3168
|
+
if (n < 1048576) return `${Math.round(n / 1024)} KB`;
|
|
3169
|
+
return `${(n / 1048576).toFixed(1)} MB`;
|
|
3170
|
+
}
|
|
3171
|
+
function FileCard({
|
|
3172
|
+
name,
|
|
3173
|
+
origin,
|
|
3174
|
+
bytes,
|
|
3175
|
+
onPreview,
|
|
3176
|
+
onDownload,
|
|
3177
|
+
compact = false,
|
|
3178
|
+
className = ""
|
|
3179
|
+
}) {
|
|
3180
|
+
const open = onPreview ? (e) => {
|
|
3181
|
+
e.stopPropagation();
|
|
3182
|
+
onPreview();
|
|
3183
|
+
} : void 0;
|
|
3184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3185
|
+
"div",
|
|
3186
|
+
{
|
|
3187
|
+
className: "uic-filecard" + (compact ? " is-compact" : "") + (open ? " is-clickable" : "") + (className ? " " + className : ""),
|
|
3188
|
+
onClick: open,
|
|
3189
|
+
role: open ? "button" : void 0,
|
|
3190
|
+
tabIndex: open ? 0 : void 0,
|
|
3191
|
+
onKeyDown: open ? (e) => {
|
|
3192
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
3193
|
+
e.preventDefault();
|
|
3194
|
+
open(e);
|
|
3195
|
+
}
|
|
3196
|
+
} : void 0,
|
|
3197
|
+
title: name,
|
|
3198
|
+
children: [
|
|
3199
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "uic-filecard-ic", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FileTypeIcon, { name, size: compact ? 20 : 30 }) }),
|
|
3200
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { className: "uic-filecard-meta", children: [
|
|
3201
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "uic-filecard-name", children: name }),
|
|
3202
|
+
!compact && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "uic-filecard-sub", children: subtitle(name, origin, bytes) })
|
|
3203
|
+
] }),
|
|
3204
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react17.Fragment, { children: [
|
|
3205
|
+
onDownload && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3206
|
+
"button",
|
|
3207
|
+
{
|
|
3208
|
+
type: "button",
|
|
3209
|
+
className: "uic-filecard-btn",
|
|
3210
|
+
"aria-label": `Download ${name}`,
|
|
3211
|
+
title: "Download",
|
|
3212
|
+
onClick: (e) => {
|
|
3213
|
+
e.stopPropagation();
|
|
3214
|
+
onDownload();
|
|
3215
|
+
},
|
|
3216
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(IcDownload, {})
|
|
3217
|
+
}
|
|
3218
|
+
),
|
|
3219
|
+
onPreview && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3220
|
+
"button",
|
|
3221
|
+
{
|
|
3222
|
+
type: "button",
|
|
3223
|
+
className: "uic-filecard-btn",
|
|
3224
|
+
"aria-label": `Preview ${name}`,
|
|
3225
|
+
title: "Preview",
|
|
3226
|
+
onClick: open,
|
|
3227
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(IcEye, {})
|
|
3228
|
+
}
|
|
3229
|
+
)
|
|
3230
|
+
] })
|
|
3231
|
+
]
|
|
3232
|
+
}
|
|
3233
|
+
);
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
// src/components/FilePreview.jsx
|
|
3237
|
+
var import_react18 = require("react");
|
|
3238
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3239
|
+
var LANG = {
|
|
3240
|
+
js: "javascript",
|
|
3241
|
+
mjs: "javascript",
|
|
3242
|
+
cjs: "javascript",
|
|
3243
|
+
jsx: "javascript",
|
|
3244
|
+
ts: "typescript",
|
|
3245
|
+
tsx: "typescript",
|
|
3246
|
+
py: "python",
|
|
3247
|
+
rb: "ruby",
|
|
3248
|
+
go: "go",
|
|
3249
|
+
rs: "rust",
|
|
3250
|
+
java: "java",
|
|
3251
|
+
c: "c",
|
|
3252
|
+
h: "c",
|
|
3253
|
+
cpp: "cpp",
|
|
3254
|
+
hpp: "cpp",
|
|
3255
|
+
cs: "csharp",
|
|
3256
|
+
php: "php",
|
|
3257
|
+
swift: "swift",
|
|
3258
|
+
kt: "kotlin",
|
|
3259
|
+
scala: "scala",
|
|
3260
|
+
sh: "bash",
|
|
3261
|
+
bash: "bash",
|
|
3262
|
+
zsh: "bash",
|
|
3263
|
+
sql: "sql",
|
|
3264
|
+
css: "css",
|
|
3265
|
+
scss: "scss",
|
|
3266
|
+
less: "less",
|
|
3267
|
+
html: "xml",
|
|
3268
|
+
htm: "xml",
|
|
3269
|
+
xml: "xml",
|
|
3270
|
+
svg: "xml",
|
|
3271
|
+
json: "json",
|
|
3272
|
+
yaml: "yaml",
|
|
3273
|
+
yml: "yaml",
|
|
3274
|
+
toml: "ini",
|
|
3275
|
+
ini: "ini",
|
|
3276
|
+
r: "r",
|
|
3277
|
+
lua: "lua",
|
|
3278
|
+
pl: "perl",
|
|
3279
|
+
dockerfile: "dockerfile",
|
|
3280
|
+
diff: "diff"
|
|
3281
|
+
};
|
|
3282
|
+
var OFFICE = /* @__PURE__ */ new Set(["pptx", "ppt", "pptm", "odp", "doc", "docx", "odt", "rtf"]);
|
|
3283
|
+
var SHEET = /* @__PURE__ */ new Set(["xls", "xlsx", "xlsm", "xlsb", "ods"]);
|
|
3284
|
+
function kindOf(name, mime = "") {
|
|
3285
|
+
const e = extOf(name);
|
|
3286
|
+
if (mime.startsWith("image/") || /^(png|jpe?g|gif|webp|svg|bmp|ico|avif)$/.test(e)) return "image";
|
|
3287
|
+
if (mime === "application/pdf" || e === "pdf") return "pdf";
|
|
3288
|
+
if (mime.startsWith("video/") || ["mp4", "webm", "mov", "m4v"].includes(e)) return "video";
|
|
3289
|
+
if (mime.startsWith("audio/") || ["mp3", "wav", "ogg", "m4a", "flac"].includes(e)) return "audio";
|
|
3290
|
+
if (e === "csv" || e === "tsv") return "csv";
|
|
3291
|
+
if (e === "md" || e === "markdown") return "markdown";
|
|
3292
|
+
if (SHEET.has(e)) return "sheet";
|
|
3293
|
+
if (OFFICE.has(e)) return "office";
|
|
3294
|
+
if (mime.startsWith("text/") || LANG[e] || /^(txt|log|env|conf|cfg|gitignore)$/.test(e)) return "code";
|
|
3295
|
+
return "binary";
|
|
3296
|
+
}
|
|
3297
|
+
function delimitedToRows(text, sep) {
|
|
3298
|
+
return text.split(/\r?\n/).filter((l) => l.length).slice(0, 1e3).map((line) => {
|
|
3299
|
+
const out = [];
|
|
3300
|
+
let cur = "";
|
|
3301
|
+
let q = false;
|
|
3302
|
+
for (const ch of line) {
|
|
3303
|
+
if (ch === '"') q = !q;
|
|
3304
|
+
else if (ch === sep && !q) {
|
|
3305
|
+
out.push(cur);
|
|
3306
|
+
cur = "";
|
|
3307
|
+
} else cur += ch;
|
|
3308
|
+
}
|
|
3309
|
+
out.push(cur);
|
|
3310
|
+
return out.map((c) => c.replace(/^"|"$/g, ""));
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
function Grid({ rows }) {
|
|
3314
|
+
if (!rows?.length) return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-empty", children: "This file is empty." });
|
|
3315
|
+
const [head, ...body] = rows;
|
|
3316
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-sheet", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("table", { children: [
|
|
3317
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { children: head.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("th", { children: c }, i)) }) }),
|
|
3318
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tbody", { children: body.map((r, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("tr", { children: r.map((c, j) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("td", { children: c }, j)) }, i)) })
|
|
3319
|
+
] }) });
|
|
3320
|
+
}
|
|
3321
|
+
var defaultDownload = (url, name) => {
|
|
3322
|
+
const a = document.createElement("a");
|
|
3323
|
+
a.href = url;
|
|
3324
|
+
a.download = name;
|
|
3325
|
+
a.rel = "noreferrer";
|
|
3326
|
+
document.body.appendChild(a);
|
|
3327
|
+
a.click();
|
|
3328
|
+
a.remove();
|
|
3329
|
+
};
|
|
3330
|
+
function FilePreview({
|
|
3331
|
+
file,
|
|
3332
|
+
onClose,
|
|
3333
|
+
fetchFile,
|
|
3334
|
+
officePdfUrl,
|
|
3335
|
+
renderMarkdown,
|
|
3336
|
+
onDownload,
|
|
3337
|
+
title
|
|
3338
|
+
}) {
|
|
3339
|
+
const { url, name } = file || {};
|
|
3340
|
+
const [st, setSt] = (0, import_react18.useState)({ kind: "loading" });
|
|
3341
|
+
const [tab, setTab] = (0, import_react18.useState)(0);
|
|
3342
|
+
(0, import_react18.useEffect)(() => {
|
|
3343
|
+
if (!url) return void 0;
|
|
3344
|
+
let alive = true;
|
|
3345
|
+
let obj;
|
|
3346
|
+
setSt({ kind: "loading" });
|
|
3347
|
+
setTab(0);
|
|
3348
|
+
const get = fetchFile || ((u) => fetch(u, { cache: "no-store" }));
|
|
3349
|
+
(async () => {
|
|
3350
|
+
const res = await get(url);
|
|
3351
|
+
if (!res.ok) throw new Error(`${res.status}`);
|
|
3352
|
+
const mime = (res.headers.get("content-type") || "").toLowerCase();
|
|
3353
|
+
const kind = kindOf(name, mime);
|
|
3354
|
+
if (kind === "office") {
|
|
3355
|
+
if (!officePdfUrl) {
|
|
3356
|
+
setSt({ kind: "binary", error: "This format has no inline preview here \u2014 download it to open it." });
|
|
3357
|
+
return;
|
|
3358
|
+
}
|
|
3359
|
+
const r = await get(officePdfUrl(url));
|
|
3360
|
+
if (!r.ok) throw new Error(`${r.status}`);
|
|
3361
|
+
obj = URL.createObjectURL(await r.blob());
|
|
3362
|
+
if (alive) setSt({ kind: "pdf", objUrl: obj });
|
|
3363
|
+
return;
|
|
3364
|
+
}
|
|
3365
|
+
if (kind === "sheet") {
|
|
3366
|
+
try {
|
|
3367
|
+
const buf = await res.arrayBuffer();
|
|
3368
|
+
const XLSX = await import("xlsx");
|
|
3369
|
+
const wb = XLSX.read(buf, { type: "array" });
|
|
3370
|
+
const sheets = wb.SheetNames.map((n) => {
|
|
3371
|
+
const ws = wb.Sheets[n] || {};
|
|
3372
|
+
const filled = Boolean(ws["!ref"]);
|
|
3373
|
+
return { name: n, filled, rows: filled ? XLSX.utils.sheet_to_json(ws, { header: 1, raw: false }) : [] };
|
|
3374
|
+
});
|
|
3375
|
+
const first = sheets.findIndex((s) => s.filled);
|
|
3376
|
+
if (alive) {
|
|
3377
|
+
setTab(first < 0 ? 0 : first);
|
|
3378
|
+
setSt({ kind: "sheet", sheets });
|
|
3379
|
+
}
|
|
3380
|
+
} catch (e) {
|
|
3381
|
+
if (alive) setSt({ kind: "binary", error: `This spreadsheet couldn\u2019t be read (${String(e?.message || "parse failed").slice(0, 80)}).` });
|
|
3382
|
+
}
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
if (kind === "csv" || kind === "markdown" || kind === "code") {
|
|
3386
|
+
const text = await res.text();
|
|
3387
|
+
if (!alive) return;
|
|
3388
|
+
if (kind === "csv") setSt({ kind: "csv", rows: delimitedToRows(text, extOf(name) === "tsv" ? " " : ",") });
|
|
3389
|
+
else setSt({ kind, text: text.slice(0, 4e5) });
|
|
3390
|
+
return;
|
|
3391
|
+
}
|
|
3392
|
+
if (kind === "binary") {
|
|
3393
|
+
if (alive) setSt({ kind: "binary" });
|
|
3394
|
+
return;
|
|
3395
|
+
}
|
|
3396
|
+
obj = URL.createObjectURL(await res.blob());
|
|
3397
|
+
if (alive) setSt({ kind, objUrl: obj });
|
|
3398
|
+
})().catch(() => {
|
|
3399
|
+
if (alive) setSt({ kind: "binary", error: "Could not load this file." });
|
|
3400
|
+
});
|
|
3401
|
+
return () => {
|
|
3402
|
+
alive = false;
|
|
3403
|
+
if (obj) URL.revokeObjectURL(obj);
|
|
3404
|
+
};
|
|
3405
|
+
}, [url, name, fetchFile, officePdfUrl]);
|
|
3406
|
+
const download = () => onDownload ? onDownload(url, name) : defaultDownload(url, name);
|
|
3407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("aside", { className: "uic-fp", "aria-label": title || `Preview of ${name}`, children: [
|
|
3408
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("header", { className: "uic-fp-head", children: [
|
|
3409
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "uic-fp-ic", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FileTypeIcon, { name, size: 20 }) }),
|
|
3410
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "uic-fp-name", title: name, children: name }),
|
|
3411
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3412
|
+
"button",
|
|
3413
|
+
{
|
|
3414
|
+
type: "button",
|
|
3415
|
+
className: "uic-fp-btn",
|
|
3416
|
+
"aria-label": `Download ${name}`,
|
|
3417
|
+
title: "Download",
|
|
3418
|
+
onClick: download,
|
|
3419
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(IcDownload, {})
|
|
3420
|
+
}
|
|
3421
|
+
),
|
|
3422
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3423
|
+
"button",
|
|
3424
|
+
{
|
|
3425
|
+
type: "button",
|
|
3426
|
+
className: "uic-fp-btn",
|
|
3427
|
+
"aria-label": "Close preview",
|
|
3428
|
+
title: "Close",
|
|
3429
|
+
onClick: onClose,
|
|
3430
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(IcX, { size: 18 })
|
|
3431
|
+
}
|
|
3432
|
+
)
|
|
3433
|
+
] }),
|
|
3434
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "uic-fp-body", children: [
|
|
3435
|
+
st.kind === "loading" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-pad", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "uic-skel uic-fp-skel" }) }),
|
|
3436
|
+
st.kind === "image" && st.objUrl && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("img", { className: "uic-fp-img", src: st.objUrl, alt: name }) }),
|
|
3437
|
+
st.kind === "pdf" && st.objUrl && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("iframe", { className: "uic-fp-frame", src: st.objUrl, title: name }),
|
|
3438
|
+
st.kind === "video" && st.objUrl && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("video", { className: "uic-fp-media", src: st.objUrl, controls: true }) }),
|
|
3439
|
+
st.kind === "audio" && st.objUrl && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("audio", { src: st.objUrl, controls: true }) }),
|
|
3440
|
+
st.kind === "markdown" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-doc", children: renderMarkdown ? renderMarkdown(st.text || "") : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("pre", { className: "uic-fp-pre", children: st.text }) }),
|
|
3441
|
+
st.kind === "code" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CodeBlock, { code: st.text || "", lang: LANG[extOf(name)] || "plaintext" }),
|
|
3442
|
+
st.kind === "csv" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Grid, { rows: st.rows }),
|
|
3443
|
+
st.kind === "sheet" && st.sheets && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "uic-fp-xlsx", children: [
|
|
3444
|
+
st.sheets[tab]?.filled ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Grid, { rows: st.sheets[tab].rows }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-empty", children: "This sheet is empty." }),
|
|
3445
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-tabs", children: st.sheets.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3446
|
+
"button",
|
|
3447
|
+
{
|
|
3448
|
+
type: "button",
|
|
3449
|
+
className: "uic-fp-tab" + (i === tab ? " is-on" : "") + (s.filled ? "" : " is-empty"),
|
|
3450
|
+
onClick: () => setTab(i),
|
|
3451
|
+
title: s.filled ? s.name : `${s.name} (empty)`,
|
|
3452
|
+
children: s.name
|
|
3453
|
+
},
|
|
3454
|
+
s.name + i
|
|
3455
|
+
)) })
|
|
3456
|
+
] }),
|
|
3457
|
+
st.kind === "binary" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "uic-fp-center", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "uic-fp-fallback", children: [
|
|
3458
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FileTypeIcon, { name, size: 56 }),
|
|
3459
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { children: st.error || "No inline preview for this file type." }),
|
|
3460
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("button", { type: "button", className: "uic-fp-dl", onClick: download, children: "Download" })
|
|
3461
|
+
] }) })
|
|
3462
|
+
] })
|
|
3463
|
+
] });
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
// src/components/form.jsx
|
|
3467
|
+
var import_react19 = require("react");
|
|
3468
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3469
|
+
function Field({ label, hint, error, htmlFor, required, children, className = "" }) {
|
|
3470
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "uic-field" + (error ? " is-error" : "") + (className ? " " + className : ""), children: [
|
|
3471
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "uic-field-label", htmlFor, children: [
|
|
3472
|
+
label,
|
|
3473
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "uic-field-req", "aria-hidden": "true", children: "*" })
|
|
3474
|
+
] }),
|
|
3475
|
+
children,
|
|
3476
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "uic-field-err", children: error }) : hint ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "uic-field-hint", children: hint }) : null
|
|
3477
|
+
] });
|
|
3478
|
+
}
|
|
3479
|
+
function withField(Control) {
|
|
3480
|
+
return function Fielded({ label, hint, error, required, id, className, ...rest }) {
|
|
3481
|
+
const auto = (0, import_react19.useId)();
|
|
3482
|
+
const inputId = id || auto;
|
|
3483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Field, { label, hint, error, required, htmlFor: inputId, className, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Control, { id: inputId, invalid: !!error, required, ...rest }) });
|
|
3484
|
+
};
|
|
3485
|
+
}
|
|
3486
|
+
function BareInput({ invalid, ...rest }) {
|
|
3487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { className: "uic-input" + (invalid ? " is-error" : ""), "aria-invalid": invalid || void 0, ...rest });
|
|
3488
|
+
}
|
|
3489
|
+
function BareTextarea({ invalid, rows = 4, ...rest }) {
|
|
3490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3491
|
+
"textarea",
|
|
3492
|
+
{
|
|
3493
|
+
className: "uic-input uic-textarea" + (invalid ? " is-error" : ""),
|
|
3494
|
+
rows,
|
|
3495
|
+
"aria-invalid": invalid || void 0,
|
|
3496
|
+
...rest
|
|
3497
|
+
}
|
|
3498
|
+
);
|
|
3499
|
+
}
|
|
3500
|
+
function BareSelect({ invalid, options = [], placeholder, ...rest }) {
|
|
3501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "uic-select-wrap", children: [
|
|
3502
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
3503
|
+
"select",
|
|
3504
|
+
{
|
|
3505
|
+
className: "uic-input uic-select" + (invalid ? " is-error" : ""),
|
|
3506
|
+
"aria-invalid": invalid || void 0,
|
|
3507
|
+
...rest,
|
|
3508
|
+
children: [
|
|
3509
|
+
placeholder && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: placeholder }),
|
|
3510
|
+
options.map((o) => {
|
|
3511
|
+
const opt = typeof o === "string" ? { value: o, label: o } : o;
|
|
3512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: opt.value, disabled: opt.disabled, children: opt.label }, opt.value);
|
|
3513
|
+
})
|
|
3514
|
+
]
|
|
3515
|
+
}
|
|
3516
|
+
),
|
|
3517
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "uic-select-chev", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Chevron, { dir: "down", size: 14 }) })
|
|
3518
|
+
] });
|
|
3519
|
+
}
|
|
3520
|
+
var Input = withField(BareInput);
|
|
3521
|
+
var Textarea = withField(BareTextarea);
|
|
3522
|
+
var Select = withField(BareSelect);
|
|
3523
|
+
function FormActions({ children, align = "end", className = "" }) {
|
|
3524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `uic-form-actions is-${align}${className ? " " + className : ""}`, children });
|
|
3525
|
+
}
|
|
3526
|
+
function Button({ variant = "default", size = "md", type = "button", className = "", ...rest }) {
|
|
3527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type, className: `uic-btn is-${variant} is-${size}${className ? " " + className : ""}`, ...rest });
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
// src/components/Carousel.jsx
|
|
3531
|
+
var import_react20 = __toESM(require("react"), 1);
|
|
3532
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3097
3533
|
var EDGE = 2;
|
|
3098
3534
|
function Carousel(props) {
|
|
3099
3535
|
const { label, step, children, classNames = {} } = props;
|
|
3100
|
-
const ref = (0,
|
|
3101
|
-
const [edges, setEdges] = (0,
|
|
3102
|
-
const measure = (0,
|
|
3536
|
+
const ref = (0, import_react20.useRef)(null);
|
|
3537
|
+
const [edges, setEdges] = (0, import_react20.useState)({ start: true, end: true, overflow: false });
|
|
3538
|
+
const measure = (0, import_react20.useCallback)(() => {
|
|
3103
3539
|
const el = ref.current;
|
|
3104
3540
|
if (!el) return;
|
|
3105
3541
|
const overflow = el.scrollWidth - el.clientWidth > EDGE;
|
|
@@ -3109,7 +3545,7 @@ function Carousel(props) {
|
|
|
3109
3545
|
end: el.scrollLeft >= el.scrollWidth - el.clientWidth - EDGE
|
|
3110
3546
|
});
|
|
3111
3547
|
}, []);
|
|
3112
|
-
(0,
|
|
3548
|
+
(0, import_react20.useEffect)(() => {
|
|
3113
3549
|
const el = ref.current;
|
|
3114
3550
|
if (!el) return void 0;
|
|
3115
3551
|
measure();
|
|
@@ -3123,8 +3559,8 @@ function Carousel(props) {
|
|
|
3123
3559
|
if (!el) return;
|
|
3124
3560
|
el.scrollBy({ left: dir * (step || Math.round(el.clientWidth * 0.9)), behavior: "smooth" });
|
|
3125
3561
|
};
|
|
3126
|
-
return /* @__PURE__ */ (0,
|
|
3127
|
-
edges.overflow ? /* @__PURE__ */ (0,
|
|
3562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: ["uic-carousel-wrap", classNames.root || ""].filter(Boolean).join(" "), children: [
|
|
3563
|
+
edges.overflow ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3128
3564
|
"button",
|
|
3129
3565
|
{
|
|
3130
3566
|
type: "button",
|
|
@@ -3132,10 +3568,10 @@ function Carousel(props) {
|
|
|
3132
3568
|
onClick: () => scroll(-1),
|
|
3133
3569
|
disabled: edges.start,
|
|
3134
3570
|
"aria-label": `Scroll ${label} left`,
|
|
3135
|
-
children: /* @__PURE__ */ (0,
|
|
3571
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Chevron, { dir: "left" })
|
|
3136
3572
|
}
|
|
3137
3573
|
) : null,
|
|
3138
|
-
/* @__PURE__ */ (0,
|
|
3574
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3139
3575
|
"div",
|
|
3140
3576
|
{
|
|
3141
3577
|
className: ["uic-carousel", classNames.viewport || ""].filter(Boolean).join(" "),
|
|
@@ -3146,7 +3582,7 @@ function Carousel(props) {
|
|
|
3146
3582
|
children
|
|
3147
3583
|
}
|
|
3148
3584
|
),
|
|
3149
|
-
edges.overflow ? /* @__PURE__ */ (0,
|
|
3585
|
+
edges.overflow ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3150
3586
|
"button",
|
|
3151
3587
|
{
|
|
3152
3588
|
type: "button",
|
|
@@ -3154,42 +3590,42 @@ function Carousel(props) {
|
|
|
3154
3590
|
onClick: () => scroll(1),
|
|
3155
3591
|
disabled: edges.end,
|
|
3156
3592
|
"aria-label": `Scroll ${label} right`,
|
|
3157
|
-
children: /* @__PURE__ */ (0,
|
|
3593
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Chevron, { dir: "right" })
|
|
3158
3594
|
}
|
|
3159
3595
|
) : null
|
|
3160
3596
|
] });
|
|
3161
3597
|
}
|
|
3162
3598
|
|
|
3163
3599
|
// src/components/Card.jsx
|
|
3164
|
-
var
|
|
3165
|
-
var
|
|
3600
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
3601
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3166
3602
|
function Card(props) {
|
|
3167
|
-
const { art, title, subtitle, onClick, selected = false, overlay, actions, classNames = {} } = props;
|
|
3168
|
-
const foot = /* @__PURE__ */ (0,
|
|
3169
|
-
/* @__PURE__ */ (0,
|
|
3170
|
-
|
|
3603
|
+
const { art, title, subtitle: subtitle2, onClick, selected = false, overlay, actions, classNames = {} } = props;
|
|
3604
|
+
const foot = /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "uic-card-foot", children: [
|
|
3605
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-card-name", children: title }),
|
|
3606
|
+
subtitle2 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-card-sub", children: subtitle2 }) : null
|
|
3171
3607
|
] });
|
|
3172
|
-
return /* @__PURE__ */ (0,
|
|
3173
|
-
onClick ? /* @__PURE__ */ (0,
|
|
3174
|
-
/* @__PURE__ */ (0,
|
|
3608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: ["uic-card", selected ? "is-selected" : "", classNames.root || ""].filter(Boolean).join(" "), children: [
|
|
3609
|
+
onClick ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("button", { type: "button", className: "uic-card-main", onClick, "aria-pressed": selected || void 0, children: [
|
|
3610
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-card-art", children: art }),
|
|
3175
3611
|
foot
|
|
3176
|
-
] }) : /* @__PURE__ */ (0,
|
|
3177
|
-
/* @__PURE__ */ (0,
|
|
3612
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "uic-card-main", children: [
|
|
3613
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "uic-card-art", children: art }),
|
|
3178
3614
|
foot
|
|
3179
3615
|
] }),
|
|
3180
|
-
overlay ? /* @__PURE__ */ (0,
|
|
3181
|
-
actions ? /* @__PURE__ */ (0,
|
|
3616
|
+
overlay ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "uic-card-overlay", children: overlay }) : null,
|
|
3617
|
+
actions ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "uic-card-actions", children: actions }) : null
|
|
3182
3618
|
] });
|
|
3183
3619
|
}
|
|
3184
3620
|
|
|
3185
3621
|
// src/components/SearchField.jsx
|
|
3186
|
-
var
|
|
3187
|
-
var
|
|
3622
|
+
var import_react22 = __toESM(require("react"), 1);
|
|
3623
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3188
3624
|
function SearchField(props) {
|
|
3189
3625
|
const { value, onChange, placeholder, clearLabel = "Clear search", className } = props;
|
|
3190
|
-
return /* @__PURE__ */ (0,
|
|
3191
|
-
/* @__PURE__ */ (0,
|
|
3192
|
-
/* @__PURE__ */ (0,
|
|
3626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: ["uic-search", className || ""].filter(Boolean).join(" "), children: [
|
|
3627
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "uic-search-ic", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(IcSearch, {}) }),
|
|
3628
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
3193
3629
|
"input",
|
|
3194
3630
|
{
|
|
3195
3631
|
type: "search",
|
|
@@ -3199,14 +3635,14 @@ function SearchField(props) {
|
|
|
3199
3635
|
onChange: (e) => onChange(e.target.value)
|
|
3200
3636
|
}
|
|
3201
3637
|
),
|
|
3202
|
-
value ? /* @__PURE__ */ (0,
|
|
3638
|
+
value ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: "uic-search-x", "aria-label": clearLabel, onClick: () => onChange(""), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(IcX, { size: 12 }) }) : null
|
|
3203
3639
|
] });
|
|
3204
3640
|
}
|
|
3205
3641
|
|
|
3206
3642
|
// src/components/Popover.jsx
|
|
3207
|
-
var
|
|
3643
|
+
var import_react23 = __toESM(require("react"), 1);
|
|
3208
3644
|
var import_react_dom3 = require("react-dom");
|
|
3209
|
-
var
|
|
3645
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3210
3646
|
var GAP = 6;
|
|
3211
3647
|
var MARGIN = 8;
|
|
3212
3648
|
function Popover(props) {
|
|
@@ -3221,9 +3657,9 @@ function Popover(props) {
|
|
|
3221
3657
|
className,
|
|
3222
3658
|
label
|
|
3223
3659
|
} = props;
|
|
3224
|
-
const popRef = (0,
|
|
3225
|
-
const [pos, setPos] = (0,
|
|
3226
|
-
(0,
|
|
3660
|
+
const popRef = (0, import_react23.useRef)(null);
|
|
3661
|
+
const [pos, setPos] = (0, import_react23.useState)(null);
|
|
3662
|
+
(0, import_react23.useEffect)(() => {
|
|
3227
3663
|
if (!open) {
|
|
3228
3664
|
setPos(null);
|
|
3229
3665
|
return void 0;
|
|
@@ -3250,7 +3686,7 @@ function Popover(props) {
|
|
|
3250
3686
|
window.removeEventListener("scroll", place, true);
|
|
3251
3687
|
};
|
|
3252
3688
|
}, [open, anchorRef, width, minHeight, placement]);
|
|
3253
|
-
(0,
|
|
3689
|
+
(0, import_react23.useEffect)(() => {
|
|
3254
3690
|
if (!open) return void 0;
|
|
3255
3691
|
const onDown = (e) => {
|
|
3256
3692
|
if (popRef.current?.contains(e.target)) return;
|
|
@@ -3260,11 +3696,11 @@ function Popover(props) {
|
|
|
3260
3696
|
document.addEventListener("pointerdown", onDown);
|
|
3261
3697
|
return () => document.removeEventListener("pointerdown", onDown);
|
|
3262
3698
|
}, [open, anchorRef, onClose]);
|
|
3263
|
-
const escape = (0,
|
|
3699
|
+
const escape = (0, import_react23.useCallback)(() => onClose?.(), [onClose]);
|
|
3264
3700
|
useOverlayEscape(open, escape);
|
|
3265
3701
|
if (!open || !pos || typeof document === "undefined") return null;
|
|
3266
3702
|
return (0, import_react_dom3.createPortal)(
|
|
3267
|
-
/* @__PURE__ */ (0,
|
|
3703
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3268
3704
|
"div",
|
|
3269
3705
|
{
|
|
3270
3706
|
ref: popRef,
|
|
@@ -3280,9 +3716,9 @@ function Popover(props) {
|
|
|
3280
3716
|
}
|
|
3281
3717
|
|
|
3282
3718
|
// src/components/Modal.jsx
|
|
3283
|
-
var
|
|
3719
|
+
var import_react24 = __toESM(require("react"), 1);
|
|
3284
3720
|
var import_react_dom4 = require("react-dom");
|
|
3285
|
-
var
|
|
3721
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3286
3722
|
function Modal(props) {
|
|
3287
3723
|
const {
|
|
3288
3724
|
open,
|
|
@@ -3296,10 +3732,10 @@ function Modal(props) {
|
|
|
3296
3732
|
children,
|
|
3297
3733
|
classNames = {}
|
|
3298
3734
|
} = props;
|
|
3299
|
-
const titleId = (0,
|
|
3300
|
-
const escape = (0,
|
|
3735
|
+
const titleId = (0, import_react24.useId)();
|
|
3736
|
+
const escape = (0, import_react24.useCallback)(() => onClose?.(), [onClose]);
|
|
3301
3737
|
useOverlayEscape(open, escape);
|
|
3302
|
-
(0,
|
|
3738
|
+
(0, import_react24.useEffect)(() => {
|
|
3303
3739
|
if (!open || typeof document === "undefined") return void 0;
|
|
3304
3740
|
const prev = document.body.style.overflow;
|
|
3305
3741
|
document.body.style.overflow = "hidden";
|
|
@@ -3312,12 +3748,12 @@ function Modal(props) {
|
|
|
3312
3748
|
if (e.target === e.currentTarget) onClose?.();
|
|
3313
3749
|
};
|
|
3314
3750
|
return (0, import_react_dom4.createPortal)(
|
|
3315
|
-
/* @__PURE__ */ (0,
|
|
3751
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3316
3752
|
"div",
|
|
3317
3753
|
{
|
|
3318
3754
|
className: ["uic-modal-backdrop", classNames.backdrop || ""].filter(Boolean).join(" "),
|
|
3319
3755
|
onMouseDown: onBackdrop,
|
|
3320
|
-
children: /* @__PURE__ */ (0,
|
|
3756
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
3321
3757
|
"div",
|
|
3322
3758
|
{
|
|
3323
3759
|
className: ["uic-modal", `is-${size}`, classNames.root || ""].filter(Boolean).join(" "),
|
|
@@ -3326,15 +3762,15 @@ function Modal(props) {
|
|
|
3326
3762
|
"aria-modal": "true",
|
|
3327
3763
|
"aria-labelledby": labelledBy || (title ? titleId : void 0),
|
|
3328
3764
|
children: [
|
|
3329
|
-
title || actions ? /* @__PURE__ */ (0,
|
|
3330
|
-
/* @__PURE__ */ (0,
|
|
3331
|
-
title ? /* @__PURE__ */ (0,
|
|
3332
|
-
description ? /* @__PURE__ */ (0,
|
|
3765
|
+
title || actions ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "uic-modal-h", children: [
|
|
3766
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "uic-modal-title", children: [
|
|
3767
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h3", { id: titleId, children: title }) : null,
|
|
3768
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { children: description }) : null
|
|
3333
3769
|
] }),
|
|
3334
3770
|
actions,
|
|
3335
|
-
/* @__PURE__ */ (0,
|
|
3771
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("button", { type: "button", className: "uic-modal-x", "aria-label": "Close", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(IcX, { size: 18 }) })
|
|
3336
3772
|
] }) : null,
|
|
3337
|
-
/* @__PURE__ */ (0,
|
|
3773
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: ["uic-modal-b", classNames.body || ""].filter(Boolean).join(" "), children })
|
|
3338
3774
|
]
|
|
3339
3775
|
}
|
|
3340
3776
|
)
|
|
@@ -3345,15 +3781,15 @@ function Modal(props) {
|
|
|
3345
3781
|
}
|
|
3346
3782
|
|
|
3347
3783
|
// src/hooks/useTypewriter.js
|
|
3348
|
-
var
|
|
3784
|
+
var import_react25 = require("react");
|
|
3349
3785
|
var CHAR_MS = 26;
|
|
3350
3786
|
var HOLD_MS = 2600;
|
|
3351
3787
|
function useTypewriter(phrases, { active = true } = {}) {
|
|
3352
3788
|
const list = phrases && phrases.length ? phrases : [""];
|
|
3353
|
-
const [text, setText] = (0,
|
|
3354
|
-
const listRef = (0,
|
|
3789
|
+
const [text, setText] = (0, import_react25.useState)(list[0]);
|
|
3790
|
+
const listRef = (0, import_react25.useRef)(list);
|
|
3355
3791
|
listRef.current = list;
|
|
3356
|
-
(0,
|
|
3792
|
+
(0, import_react25.useEffect)(() => {
|
|
3357
3793
|
if (!active) return void 0;
|
|
3358
3794
|
if (typeof window === "undefined") return void 0;
|
|
3359
3795
|
if (window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches) {
|