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