@valbuild/ui 0.27.0 → 0.29.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/valbuild-ui.cjs.js +108 -28
- package/dist/valbuild-ui.esm.js +108 -28
- package/package.json +2 -2
- package/server/.tmp/assets/index-8e61e324.css +1 -0
- package/server/.tmp/assets/{index-3108ab2a.js → index-9616f8c2.js} +59 -59
- package/server/.tmp/index.html +2 -2
- package/server/dist/style.css +10 -3
- package/server/dist/valbuild-ui-main.cjs.js +172 -63
- package/server/dist/valbuild-ui-main.esm.js +172 -63
- package/server/dist/valbuild-ui-server.cjs.js +1 -1
- package/server/dist/valbuild-ui-server.esm.js +1 -1
- package/server/.tmp/assets/index-082e6676.css +0 -1
|
@@ -33724,6 +33724,42 @@ var ValApi = /* @__PURE__ */ function() {
|
|
|
33724
33724
|
value: function getEditUrl() {
|
|
33725
33725
|
return "".concat(this.host, "/static/edit");
|
|
33726
33726
|
}
|
|
33727
|
+
}, {
|
|
33728
|
+
key: "getLoginUrl",
|
|
33729
|
+
value: function getLoginUrl(redirectTo) {
|
|
33730
|
+
return "".concat(this.host, "/authorize?redirect_to=").concat(encodeURIComponent(redirectTo));
|
|
33731
|
+
}
|
|
33732
|
+
}, {
|
|
33733
|
+
key: "getPatches",
|
|
33734
|
+
value: function() {
|
|
33735
|
+
var _getPatches = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(_ref) {
|
|
33736
|
+
var patchIds, headers, patchIdsParam;
|
|
33737
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33738
|
+
while (1)
|
|
33739
|
+
switch (_context.prev = _context.next) {
|
|
33740
|
+
case 0:
|
|
33741
|
+
patchIds = _ref.patchIds, headers = _ref.headers;
|
|
33742
|
+
patchIdsParam = patchIds ? "?".concat(patchIds.map(function(id) {
|
|
33743
|
+
return "".concat(id, "=").concat(encodeURIComponent(id));
|
|
33744
|
+
}).join("&")) : "";
|
|
33745
|
+
return _context.abrupt("return", fetch("".concat(this.host, "/patches/~").concat(patchIdsParam), {
|
|
33746
|
+
headers: headers || {
|
|
33747
|
+
"Content-Type": "application/json"
|
|
33748
|
+
}
|
|
33749
|
+
}).then(function(res) {
|
|
33750
|
+
return parse$1(res);
|
|
33751
|
+
}));
|
|
33752
|
+
case 3:
|
|
33753
|
+
case "end":
|
|
33754
|
+
return _context.stop();
|
|
33755
|
+
}
|
|
33756
|
+
}, _callee, this);
|
|
33757
|
+
}));
|
|
33758
|
+
function getPatches(_x) {
|
|
33759
|
+
return _getPatches.apply(this, arguments);
|
|
33760
|
+
}
|
|
33761
|
+
return getPatches;
|
|
33762
|
+
}()
|
|
33727
33763
|
}, {
|
|
33728
33764
|
key: "postPatches",
|
|
33729
33765
|
value: function postPatches(moduleId, patches, headers) {
|
|
@@ -33746,8 +33782,8 @@ var ValApi = /* @__PURE__ */ function() {
|
|
|
33746
33782
|
}
|
|
33747
33783
|
}, {
|
|
33748
33784
|
key: "getModules",
|
|
33749
|
-
value: function getModules(
|
|
33750
|
-
var
|
|
33785
|
+
value: function getModules(_ref2) {
|
|
33786
|
+
var _ref2$patch = _ref2.patch, patch = _ref2$patch === void 0 ? false : _ref2$patch, _ref2$includeSchema = _ref2.includeSchema, includeSchema = _ref2$includeSchema === void 0 ? false : _ref2$includeSchema, _ref2$includeSource = _ref2.includeSource, includeSource = _ref2$includeSource === void 0 ? false : _ref2$includeSource, _ref2$treePath = _ref2.treePath, treePath = _ref2$treePath === void 0 ? "/" : _ref2$treePath, headers = _ref2.headers;
|
|
33751
33787
|
var params = new URLSearchParams();
|
|
33752
33788
|
params.set("patch", patch.toString());
|
|
33753
33789
|
params.set("schema", includeSchema.toString());
|
|
@@ -33761,52 +33797,52 @@ var ValApi = /* @__PURE__ */ function() {
|
|
|
33761
33797
|
}]);
|
|
33762
33798
|
return ValApi2;
|
|
33763
33799
|
}();
|
|
33764
|
-
function parse$1(
|
|
33800
|
+
function parse$1(_x2) {
|
|
33765
33801
|
return _parse.apply(this, arguments);
|
|
33766
33802
|
}
|
|
33767
33803
|
function _parse() {
|
|
33768
|
-
_parse = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function
|
|
33769
|
-
return _regeneratorRuntime().wrap(function
|
|
33804
|
+
_parse = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee2(res) {
|
|
33805
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
33770
33806
|
while (1)
|
|
33771
|
-
switch (
|
|
33807
|
+
switch (_context2.prev = _context2.next) {
|
|
33772
33808
|
case 0:
|
|
33773
|
-
|
|
33809
|
+
_context2.prev = 0;
|
|
33774
33810
|
if (!res.ok) {
|
|
33775
|
-
|
|
33811
|
+
_context2.next = 9;
|
|
33776
33812
|
break;
|
|
33777
33813
|
}
|
|
33778
|
-
|
|
33779
|
-
|
|
33814
|
+
_context2.t0 = result;
|
|
33815
|
+
_context2.next = 5;
|
|
33780
33816
|
return res.json();
|
|
33781
33817
|
case 5:
|
|
33782
|
-
|
|
33783
|
-
return
|
|
33818
|
+
_context2.t1 = _context2.sent;
|
|
33819
|
+
return _context2.abrupt("return", _context2.t0.ok.call(_context2.t0, _context2.t1));
|
|
33784
33820
|
case 9:
|
|
33785
|
-
|
|
33786
|
-
|
|
33787
|
-
|
|
33821
|
+
_context2.t2 = result;
|
|
33822
|
+
_context2.t3 = res.status;
|
|
33823
|
+
_context2.next = 13;
|
|
33788
33824
|
return res.text();
|
|
33789
33825
|
case 13:
|
|
33790
|
-
|
|
33791
|
-
|
|
33792
|
-
statusCode:
|
|
33793
|
-
message:
|
|
33826
|
+
_context2.t4 = _context2.sent;
|
|
33827
|
+
_context2.t5 = {
|
|
33828
|
+
statusCode: _context2.t3,
|
|
33829
|
+
message: _context2.t4
|
|
33794
33830
|
};
|
|
33795
|
-
return
|
|
33831
|
+
return _context2.abrupt("return", _context2.t2.err.call(_context2.t2, _context2.t5));
|
|
33796
33832
|
case 16:
|
|
33797
|
-
|
|
33833
|
+
_context2.next = 21;
|
|
33798
33834
|
break;
|
|
33799
33835
|
case 18:
|
|
33800
|
-
|
|
33801
|
-
|
|
33802
|
-
return
|
|
33803
|
-
message:
|
|
33836
|
+
_context2.prev = 18;
|
|
33837
|
+
_context2.t6 = _context2["catch"](0);
|
|
33838
|
+
return _context2.abrupt("return", err({
|
|
33839
|
+
message: _context2.t6 instanceof Error ? _context2.t6.message : "Unknown error"
|
|
33804
33840
|
}));
|
|
33805
33841
|
case 21:
|
|
33806
33842
|
case "end":
|
|
33807
|
-
return
|
|
33843
|
+
return _context2.stop();
|
|
33808
33844
|
}
|
|
33809
|
-
},
|
|
33845
|
+
}, _callee2, null, [[0, 18]]);
|
|
33810
33846
|
}));
|
|
33811
33847
|
return _parse.apply(this, arguments);
|
|
33812
33848
|
}
|
|
@@ -37761,6 +37797,26 @@ Tree.Node = ({
|
|
|
37761
37797
|
}) })
|
|
37762
37798
|
] });
|
|
37763
37799
|
};
|
|
37800
|
+
const MIME_TYPE_REGEX = /^data:(image\/(png|jpeg|jpg|gif|webp|bmp|tiff|ico|svg\+xml));base64,/;
|
|
37801
|
+
function getMimeType(base64Url) {
|
|
37802
|
+
const match = MIME_TYPE_REGEX.exec(base64Url);
|
|
37803
|
+
if (match && match[1]) {
|
|
37804
|
+
return match[1];
|
|
37805
|
+
}
|
|
37806
|
+
return;
|
|
37807
|
+
}
|
|
37808
|
+
function mimeTypeToFileExt(mimeType) {
|
|
37809
|
+
if (mimeType === "image/svg+xml") {
|
|
37810
|
+
return "svg";
|
|
37811
|
+
}
|
|
37812
|
+
if (mimeType === "image/vnd.microsoft.icon") {
|
|
37813
|
+
return "ico";
|
|
37814
|
+
}
|
|
37815
|
+
if (mimeType.startsWith("image/")) {
|
|
37816
|
+
return mimeType.slice("image/".length);
|
|
37817
|
+
}
|
|
37818
|
+
return mimeType;
|
|
37819
|
+
}
|
|
37764
37820
|
var LexicalList_dev = {};
|
|
37765
37821
|
var Lexical_dev = {};
|
|
37766
37822
|
var hasRequiredLexical_dev;
|
|
@@ -59205,26 +59261,6 @@ const Dropdown = ({
|
|
|
59205
59261
|
) });
|
|
59206
59262
|
};
|
|
59207
59263
|
const Dropdown$1 = Dropdown;
|
|
59208
|
-
const MIME_TYPE_REGEX = /^data:(image\/(png|jpeg|jpg|gif|webp|bmp|tiff|ico|svg\+xml));base64,/;
|
|
59209
|
-
function getMimeType(base64Url) {
|
|
59210
|
-
const match = MIME_TYPE_REGEX.exec(base64Url);
|
|
59211
|
-
if (match && match[1]) {
|
|
59212
|
-
return match[1];
|
|
59213
|
-
}
|
|
59214
|
-
return;
|
|
59215
|
-
}
|
|
59216
|
-
function mimeTypeToFileExt(mimeType) {
|
|
59217
|
-
if (mimeType === "image/svg+xml") {
|
|
59218
|
-
return "svg";
|
|
59219
|
-
}
|
|
59220
|
-
if (mimeType === "image/vnd.microsoft.icon") {
|
|
59221
|
-
return "ico";
|
|
59222
|
-
}
|
|
59223
|
-
if (mimeType.startsWith("image/")) {
|
|
59224
|
-
return mimeType.slice("image/".length);
|
|
59225
|
-
}
|
|
59226
|
-
return mimeType;
|
|
59227
|
-
}
|
|
59228
59264
|
const textEncoder$1 = new TextEncoder();
|
|
59229
59265
|
function readImage(ev) {
|
|
59230
59266
|
return new Promise((resolve, reject) => {
|
|
@@ -59245,6 +59281,7 @@ function readImage(ev) {
|
|
|
59245
59281
|
src: result2,
|
|
59246
59282
|
width: image.naturalWidth,
|
|
59247
59283
|
height: image.naturalHeight,
|
|
59284
|
+
filename: imageFile == null ? void 0 : imageFile.name,
|
|
59248
59285
|
sha256,
|
|
59249
59286
|
mimeType,
|
|
59250
59287
|
fileExt: mimeType && mimeTypeToFileExt(mimeType)
|
|
@@ -59252,6 +59289,7 @@ function readImage(ev) {
|
|
|
59252
59289
|
} else {
|
|
59253
59290
|
resolve({
|
|
59254
59291
|
src: result2,
|
|
59292
|
+
filename: imageFile == null ? void 0 : imageFile.name,
|
|
59255
59293
|
sha256
|
|
59256
59294
|
});
|
|
59257
59295
|
}
|
|
@@ -60711,7 +60749,7 @@ const Toolbar = ({
|
|
|
60711
60749
|
)
|
|
60712
60750
|
}
|
|
60713
60751
|
),
|
|
60714
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center justify-center", children: [
|
|
60752
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "flex items-center justify-center cursor-pointer", children: [
|
|
60715
60753
|
/* @__PURE__ */ jsxRuntimeExports.jsx(ImageIcon$1, {}),
|
|
60716
60754
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
60717
60755
|
"input",
|
|
@@ -61055,6 +61093,11 @@ const ChevronDown = createLucideIcon("ChevronDown", [
|
|
|
61055
61093
|
const ChevronLeft = createLucideIcon("ChevronLeft", [
|
|
61056
61094
|
["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]
|
|
61057
61095
|
]);
|
|
61096
|
+
const LogIn = createLucideIcon("LogIn", [
|
|
61097
|
+
["path", { d: "M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4", key: "u53s6r" }],
|
|
61098
|
+
["polyline", { points: "10 17 15 12 10 7", key: "1ail0h" }],
|
|
61099
|
+
["line", { x1: "15", x2: "3", y1: "12", y2: "12", key: "v6grx8" }]
|
|
61100
|
+
]);
|
|
61058
61101
|
const Maximize = createLucideIcon("Maximize", [
|
|
61059
61102
|
["path", { d: "M8 3H5a2 2 0 0 0-2 2v3", key: "1dcmit" }],
|
|
61060
61103
|
["path", { d: "M21 8V5a2 2 0 0 0-2-2h-3", key: "1e4gt3" }],
|
|
@@ -61081,6 +61124,10 @@ const Power = createLucideIcon("Power", [
|
|
|
61081
61124
|
["path", { d: "M12 2v10", key: "mnfbl" }],
|
|
61082
61125
|
["path", { d: "M18.4 6.6a9 9 0 1 1-12.77.04", key: "obofu9" }]
|
|
61083
61126
|
]);
|
|
61127
|
+
const Send = createLucideIcon("Send", [
|
|
61128
|
+
["path", { d: "m22 2-7 20-4-9-9-4Z", key: "1q3vgg" }],
|
|
61129
|
+
["path", { d: "M22 2 11 13", key: "nzbqef" }]
|
|
61130
|
+
]);
|
|
61084
61131
|
const Sun = createLucideIcon("Sun", [
|
|
61085
61132
|
["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
|
|
61086
61133
|
["path", { d: "M12 2v2", key: "tus03m" }],
|
|
@@ -61099,8 +61146,30 @@ const X = createLucideIcon("X", [
|
|
|
61099
61146
|
const className = "p-1 border rounded-full shadow border-accent";
|
|
61100
61147
|
const PREV_URL_KEY = "valbuild:urlBeforeNavigation";
|
|
61101
61148
|
function ValMenu({ api }) {
|
|
61102
|
-
const { theme: theme2, setTheme, editMode, setEditMode } = useValOverlayContext();
|
|
61103
|
-
|
|
61149
|
+
const { theme: theme2, setTheme, editMode, setEditMode, session } = useValOverlayContext();
|
|
61150
|
+
if (session.status === "success" && session.data === "not-authenticated") {
|
|
61151
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row items-center justify-center w-full h-full font-sans border-2 rounded-full gap-x-3 text-primary bg-background border-fill", children: /* @__PURE__ */ jsxRuntimeExports.jsx("a", { className, href: api.getLoginUrl(window.location.href), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center px-2 gap-x-2", children: [
|
|
61152
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Login" }),
|
|
61153
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(LogIn, { size: 18 })
|
|
61154
|
+
] }) }) });
|
|
61155
|
+
}
|
|
61156
|
+
const [patchCount, setPatchCount] = reactExports.useState();
|
|
61157
|
+
reactExports.useEffect(() => {
|
|
61158
|
+
if (session.status === "success" && session.data !== "not-authenticated") {
|
|
61159
|
+
api.getPatches({}).then((patchRes) => {
|
|
61160
|
+
if (result.isOk(patchRes)) {
|
|
61161
|
+
let patchCount2 = 0;
|
|
61162
|
+
for (const moduleId in patchRes.value) {
|
|
61163
|
+
patchCount2 += patchRes.value[moduleId].length;
|
|
61164
|
+
}
|
|
61165
|
+
setPatchCount(patchCount2);
|
|
61166
|
+
} else {
|
|
61167
|
+
console.error("Could not load patches", patchRes.error);
|
|
61168
|
+
}
|
|
61169
|
+
});
|
|
61170
|
+
}
|
|
61171
|
+
}, [session]);
|
|
61172
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(MenuContainer, { children: [
|
|
61104
61173
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
61105
61174
|
MenuButton,
|
|
61106
61175
|
{
|
|
@@ -61139,9 +61208,25 @@ function ValMenu({ api }) {
|
|
|
61139
61208
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-[24px] w-[24px] flex justify-center items-center", children: editMode === "full" ? /* @__PURE__ */ jsxRuntimeExports.jsx(Minimize, { size: 15 }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Maximize, { size: 15 }) })
|
|
61140
61209
|
}
|
|
61141
61210
|
),
|
|
61211
|
+
patchCount && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
61212
|
+
MenuButton,
|
|
61213
|
+
{
|
|
61214
|
+
onClick: () => {
|
|
61215
|
+
},
|
|
61216
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative h-[24px] w-[24px] flex justify-center items-center", children: [
|
|
61217
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute -right-[10px] -top-[10px] border border-border rounded-full px-1 font-sans text-xs bg-card text-accent", children: patchCount }),
|
|
61218
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Send, { size: 18 })
|
|
61219
|
+
] })
|
|
61220
|
+
}
|
|
61221
|
+
),
|
|
61142
61222
|
/* @__PURE__ */ jsxRuntimeExports.jsx("a", { className, href: api.getDisableUrl(), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-[24px] w-[24px] flex justify-center items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Power, { size: 18 }) }) })
|
|
61143
61223
|
] });
|
|
61144
61224
|
}
|
|
61225
|
+
function MenuContainer({
|
|
61226
|
+
children
|
|
61227
|
+
}) {
|
|
61228
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-row items-center justify-center w-full h-full px-2 py-2 font-sans border-2 rounded-full gap-x-3 text-primary bg-background border-fill", children });
|
|
61229
|
+
}
|
|
61145
61230
|
function MenuButton({
|
|
61146
61231
|
active,
|
|
61147
61232
|
onClick,
|
|
@@ -63632,7 +63717,7 @@ async function fromLexicalImageNode(node, files) {
|
|
|
63632
63717
|
[FILE_REF_PROP]: filePath,
|
|
63633
63718
|
metadata: {
|
|
63634
63719
|
width: node.width || 0,
|
|
63635
|
-
height: node.
|
|
63720
|
+
height: node.height || 0,
|
|
63636
63721
|
sha256: sha256 || ""
|
|
63637
63722
|
}
|
|
63638
63723
|
};
|
|
@@ -63643,7 +63728,7 @@ async function fromLexicalImageNode(node, files) {
|
|
|
63643
63728
|
[FILE_REF_PROP]: `/public${node.src.split("?")[0]}`,
|
|
63644
63729
|
metadata: {
|
|
63645
63730
|
width: node.width || 0,
|
|
63646
|
-
height: node.
|
|
63731
|
+
height: node.height || 0,
|
|
63647
63732
|
sha256: sha256 || ""
|
|
63648
63733
|
}
|
|
63649
63734
|
};
|
|
@@ -68140,25 +68225,35 @@ function ValFormField({
|
|
|
68140
68225
|
schema.type
|
|
68141
68226
|
] });
|
|
68142
68227
|
}
|
|
68143
|
-
|
|
68144
|
-
const pathParts = path.split("/");
|
|
68228
|
+
function createImagePatch(path, data, filename, metadata) {
|
|
68145
68229
|
if (!data || !metadata) {
|
|
68146
68230
|
return [];
|
|
68147
68231
|
}
|
|
68232
|
+
const shaSuffix = metadata.sha256.slice(0, 5);
|
|
68233
|
+
const newFilePath = function() {
|
|
68234
|
+
const mimeType = getMimeType(data) ?? "unknown";
|
|
68235
|
+
const newExt = mimeTypeToFileExt(mimeType);
|
|
68236
|
+
if (filename) {
|
|
68237
|
+
const filenameWithoutExt = filename.split(".").slice(0, -1).join(".") || filename;
|
|
68238
|
+
return `/public/${filenameWithoutExt}_${shaSuffix}.${newExt}`;
|
|
68239
|
+
}
|
|
68240
|
+
return `/public/${metadata.sha256}.${newExt}`;
|
|
68241
|
+
}();
|
|
68148
68242
|
return [
|
|
68149
68243
|
{
|
|
68150
68244
|
value: {
|
|
68151
|
-
|
|
68245
|
+
[FILE_REF_PROP]: newFilePath,
|
|
68246
|
+
[VAL_EXTENSION]: "file",
|
|
68152
68247
|
metadata
|
|
68153
68248
|
},
|
|
68154
68249
|
op: "replace",
|
|
68155
68250
|
path
|
|
68156
68251
|
},
|
|
68157
|
-
// update the contents of the file:
|
|
68158
68252
|
{
|
|
68159
68253
|
value: data,
|
|
68160
|
-
op: "
|
|
68161
|
-
path
|
|
68254
|
+
op: "file",
|
|
68255
|
+
path,
|
|
68256
|
+
filePath: newFilePath
|
|
68162
68257
|
}
|
|
68163
68258
|
];
|
|
68164
68259
|
}
|
|
@@ -68168,7 +68263,9 @@ function ImageField({
|
|
|
68168
68263
|
onSubmit,
|
|
68169
68264
|
registerPatchCallback
|
|
68170
68265
|
}) {
|
|
68171
|
-
const [data, setData] = reactExports.useState(
|
|
68266
|
+
const [data, setData] = reactExports.useState(
|
|
68267
|
+
null
|
|
68268
|
+
);
|
|
68172
68269
|
const [loading, setLoading] = reactExports.useState(false);
|
|
68173
68270
|
const [metadata, setMetadata] = reactExports.useState();
|
|
68174
68271
|
const [url, setUrl] = reactExports.useState();
|
|
@@ -68178,13 +68275,18 @@ function ImageField({
|
|
|
68178
68275
|
reactExports.useEffect(() => {
|
|
68179
68276
|
if (registerPatchCallback) {
|
|
68180
68277
|
registerPatchCallback(async (path2) => {
|
|
68181
|
-
return createImagePatch(
|
|
68278
|
+
return createImagePatch(
|
|
68279
|
+
path2,
|
|
68280
|
+
(data == null ? void 0 : data.src) ?? null,
|
|
68281
|
+
(data == null ? void 0 : data.filename) ?? null,
|
|
68282
|
+
metadata
|
|
68283
|
+
);
|
|
68182
68284
|
});
|
|
68183
68285
|
}
|
|
68184
68286
|
}, [data, defaultValue]);
|
|
68185
68287
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-4xl p-4", children: [
|
|
68186
68288
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: `img_input:${path}`, className: "", children: [
|
|
68187
|
-
data || url ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: data || url }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Empty" }),
|
|
68289
|
+
data || url ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: (data == null ? void 0 : data.src) || url }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Empty" }),
|
|
68188
68290
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
68189
68291
|
"input",
|
|
68190
68292
|
{
|
|
@@ -68193,7 +68295,7 @@ function ImageField({
|
|
|
68193
68295
|
hidden: true,
|
|
68194
68296
|
onChange: (ev) => {
|
|
68195
68297
|
readImage(ev).then((res) => {
|
|
68196
|
-
setData(res.src);
|
|
68298
|
+
setData({ src: res.src, filename: res.filename });
|
|
68197
68299
|
if (res.width && res.height) {
|
|
68198
68300
|
setMetadata({
|
|
68199
68301
|
sha256: res.sha256,
|
|
@@ -68219,7 +68321,14 @@ function ImageField({
|
|
|
68219
68321
|
onClick: () => {
|
|
68220
68322
|
setLoading(true);
|
|
68221
68323
|
onSubmit(
|
|
68222
|
-
(path2) =>
|
|
68324
|
+
(path2) => Promise.resolve(
|
|
68325
|
+
createImagePatch(
|
|
68326
|
+
path2,
|
|
68327
|
+
data.src,
|
|
68328
|
+
data.filename ?? null,
|
|
68329
|
+
metadata
|
|
68330
|
+
)
|
|
68331
|
+
)
|
|
68223
68332
|
).finally(() => {
|
|
68224
68333
|
setLoading(false);
|
|
68225
68334
|
setData(null);
|