@commercelayer/app-elements 3.3.1 → 3.5.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/{CodeEditorComponent-Ddvvj8Wz.js → CodeEditorComponent-D7Ft_AmY.js} +180 -170
- package/dist/{InputDateComponent-Djb2hJ5y.js → InputDateComponent-I7dZbTNi.js} +1 -1
- package/dist/helpers/useAppLinking.d.ts +28 -0
- package/dist/{main-mxu1NrZ9.js → main-CjrKXVQK.js} +9506 -9323
- package/dist/main.d.ts +1 -0
- package/dist/main.js +36 -35
- package/dist/ui/forms/CodeEditor/CodeEditorComponent.d.ts +1 -1
- package/package.json +3 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { j as se, I as Ee } from "./main-
|
|
3
|
-
import
|
|
2
|
+
import { j as se, I as Ee } from "./main-CjrKXVQK.js";
|
|
3
|
+
import V, { memo as ce, useState as U, useRef as y, useCallback as ue, useEffect as $, forwardRef as Ce } from "react";
|
|
4
4
|
function Ie(e, t, r) {
|
|
5
5
|
return t in e ? Object.defineProperty(e, t, {
|
|
6
6
|
value: r,
|
|
@@ -57,7 +57,7 @@ function De(e, t) {
|
|
|
57
57
|
if (!(typeof Symbol > "u" || !(Symbol.iterator in Object(e)))) {
|
|
58
58
|
var r = [], n = !0, i = !1, o = void 0;
|
|
59
59
|
try {
|
|
60
|
-
for (var a = e[Symbol.iterator](),
|
|
60
|
+
for (var a = e[Symbol.iterator](), s; !(n = (s = a.next()).done) && (r.push(s.value), !(t && r.length === t)); n = !0)
|
|
61
61
|
;
|
|
62
62
|
} catch (p) {
|
|
63
63
|
i = !0, o = p;
|
|
@@ -131,41 +131,41 @@ function H(e) {
|
|
|
131
131
|
for (var r = this, n = arguments.length, i = new Array(n), o = 0; o < n; o++)
|
|
132
132
|
i[o] = arguments[o];
|
|
133
133
|
return i.length >= e.length ? e.apply(this, i) : function() {
|
|
134
|
-
for (var a = arguments.length,
|
|
135
|
-
|
|
136
|
-
return t.apply(r, [].concat(i,
|
|
134
|
+
for (var a = arguments.length, s = new Array(a), p = 0; p < a; p++)
|
|
135
|
+
s[p] = arguments[p];
|
|
136
|
+
return t.apply(r, [].concat(i, s));
|
|
137
137
|
};
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function te(e) {
|
|
141
141
|
return {}.toString.call(e).includes("Object");
|
|
142
142
|
}
|
|
143
143
|
function qe(e) {
|
|
144
144
|
return !Object.keys(e).length;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function G(e) {
|
|
147
147
|
return typeof e == "function";
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function ze(e, t) {
|
|
150
150
|
return Object.prototype.hasOwnProperty.call(e, t);
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
return
|
|
154
|
-
return !
|
|
152
|
+
function Ve(e, t) {
|
|
153
|
+
return te(t) || D("changeType"), Object.keys(t).some(function(r) {
|
|
154
|
+
return !ze(e, r);
|
|
155
155
|
}) && D("changeField"), t;
|
|
156
156
|
}
|
|
157
157
|
function Ue(e) {
|
|
158
|
-
|
|
158
|
+
G(e) || D("selectorType");
|
|
159
159
|
}
|
|
160
160
|
function We(e) {
|
|
161
|
-
|
|
162
|
-
return !
|
|
161
|
+
G(e) || te(e) || D("handlerType"), te(e) && Object.values(e).some(function(t) {
|
|
162
|
+
return !G(t);
|
|
163
163
|
}) && D("handlersType");
|
|
164
164
|
}
|
|
165
|
-
function
|
|
166
|
-
e || D("initialIsRequired"),
|
|
165
|
+
function ke(e) {
|
|
166
|
+
e || D("initialIsRequired"), te(e) || D("initialType"), qe(e) && D("initialContent");
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function Fe(e, t) {
|
|
169
169
|
throw new Error(e[t] || e.default);
|
|
170
170
|
}
|
|
171
171
|
var He = {
|
|
@@ -178,37 +178,37 @@ var He = {
|
|
|
178
178
|
changeType: "provided value of changes should be an object",
|
|
179
179
|
changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
|
|
180
180
|
default: "an unknown error accured in `state-local` package"
|
|
181
|
-
}, D = H(
|
|
182
|
-
changes:
|
|
181
|
+
}, D = H(Fe)(He), X = {
|
|
182
|
+
changes: Ve,
|
|
183
183
|
selector: Ue,
|
|
184
184
|
handler: We,
|
|
185
|
-
initial:
|
|
185
|
+
initial: ke
|
|
186
186
|
};
|
|
187
187
|
function Be(e) {
|
|
188
188
|
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
189
|
-
|
|
189
|
+
X.initial(e), X.handler(t);
|
|
190
190
|
var r = {
|
|
191
191
|
current: e
|
|
192
|
-
}, n = H(Je)(r, t), i = H(Ge)(r), o = H(
|
|
193
|
-
function
|
|
194
|
-
var g = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(
|
|
195
|
-
return
|
|
192
|
+
}, n = H(Je)(r, t), i = H(Ge)(r), o = H(X.changes)(e), a = H(Ke)(r);
|
|
193
|
+
function s() {
|
|
194
|
+
var g = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(O) {
|
|
195
|
+
return O;
|
|
196
196
|
};
|
|
197
|
-
return
|
|
197
|
+
return X.selector(g), g(r.current);
|
|
198
198
|
}
|
|
199
199
|
function p(g) {
|
|
200
200
|
_e(n, i, o, a)(g);
|
|
201
201
|
}
|
|
202
|
-
return [
|
|
202
|
+
return [s, p];
|
|
203
203
|
}
|
|
204
204
|
function Ke(e, t) {
|
|
205
|
-
return
|
|
205
|
+
return G(t) ? t(e.current) : t;
|
|
206
206
|
}
|
|
207
207
|
function Ge(e, t) {
|
|
208
208
|
return e.current = he(he({}, e.current), t), t;
|
|
209
209
|
}
|
|
210
210
|
function Je(e, t, r) {
|
|
211
|
-
return
|
|
211
|
+
return G(t) ? t(e.current) : Object.keys(r).forEach(function(n) {
|
|
212
212
|
var i;
|
|
213
213
|
return (i = t[n]) === null || i === void 0 ? void 0 : i.call(t, e.current[n]);
|
|
214
214
|
}), r;
|
|
@@ -225,9 +225,9 @@ function Qe(e) {
|
|
|
225
225
|
for (var r = this, n = arguments.length, i = new Array(n), o = 0; o < n; o++)
|
|
226
226
|
i[o] = arguments[o];
|
|
227
227
|
return i.length >= e.length ? e.apply(this, i) : function() {
|
|
228
|
-
for (var a = arguments.length,
|
|
229
|
-
|
|
230
|
-
return t.apply(r, [].concat(i,
|
|
228
|
+
for (var a = arguments.length, s = new Array(a), p = 0; p < a; p++)
|
|
229
|
+
s[p] = arguments[p];
|
|
230
|
+
return t.apply(r, [].concat(i, s));
|
|
231
231
|
};
|
|
232
232
|
};
|
|
233
233
|
}
|
|
@@ -297,7 +297,7 @@ var at = Ye.create({
|
|
|
297
297
|
resolve: null,
|
|
298
298
|
reject: null,
|
|
299
299
|
monaco: null
|
|
300
|
-
}), ye = Ae(at, 2),
|
|
300
|
+
}), ye = Ae(at, 2), J = ye[0], ne = ye[1];
|
|
301
301
|
function ut(e) {
|
|
302
302
|
var t = nt.config(e), r = t.monaco, n = Le(t, ["monaco"]);
|
|
303
303
|
ne(function(i) {
|
|
@@ -308,7 +308,7 @@ function ut(e) {
|
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
310
|
function ct() {
|
|
311
|
-
var e =
|
|
311
|
+
var e = J(function(t) {
|
|
312
312
|
var r = t.monaco, n = t.isInitialized, i = t.resolve;
|
|
313
313
|
return {
|
|
314
314
|
monaco: r,
|
|
@@ -335,7 +335,7 @@ function st(e) {
|
|
|
335
335
|
return e && (t.src = e), t;
|
|
336
336
|
}
|
|
337
337
|
function ft(e) {
|
|
338
|
-
var t =
|
|
338
|
+
var t = J(function(n) {
|
|
339
339
|
var i = n.config, o = n.reject;
|
|
340
340
|
return {
|
|
341
341
|
config: i,
|
|
@@ -347,7 +347,7 @@ function ft(e) {
|
|
|
347
347
|
}, r.onerror = t.reject, r;
|
|
348
348
|
}
|
|
349
349
|
function dt() {
|
|
350
|
-
var e =
|
|
350
|
+
var e = J(function(r) {
|
|
351
351
|
var n = r.config, i = r.resolve, o = r.reject;
|
|
352
352
|
return {
|
|
353
353
|
config: n,
|
|
@@ -362,12 +362,12 @@ function dt() {
|
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
function Oe(e) {
|
|
365
|
-
|
|
365
|
+
J().monaco || ne({
|
|
366
366
|
monaco: e
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
369
|
function pt() {
|
|
370
|
-
return
|
|
370
|
+
return J(function(e) {
|
|
371
371
|
var t = e.monaco;
|
|
372
372
|
return t;
|
|
373
373
|
});
|
|
@@ -377,17 +377,17 @@ var oe = new Promise(function(e, t) {
|
|
|
377
377
|
resolve: e,
|
|
378
378
|
reject: t
|
|
379
379
|
});
|
|
380
|
-
}),
|
|
380
|
+
}), re = {
|
|
381
381
|
config: ut,
|
|
382
382
|
init: ct,
|
|
383
383
|
__getMonacoInstance: pt
|
|
384
384
|
}, gt = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, ae = gt, ht = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, mt = ht;
|
|
385
385
|
function vt({ children: e }) {
|
|
386
|
-
return
|
|
386
|
+
return V.createElement("div", { style: mt.container }, e);
|
|
387
387
|
}
|
|
388
388
|
var bt = vt, wt = bt;
|
|
389
389
|
function yt({ width: e, height: t, isEditorReady: r, loading: n, _ref: i, className: o, wrapperProps: a }) {
|
|
390
|
-
return
|
|
390
|
+
return V.createElement("section", { style: { ...ae.wrapper, width: e, height: t }, ...a }, !r && V.createElement(wt, null, n), V.createElement("div", { ref: i, style: { ...ae.fullWidth, ...!r && ae.hide }, className: o }));
|
|
391
391
|
}
|
|
392
392
|
var Ot = yt, je = ce(Ot);
|
|
393
393
|
function jt(e) {
|
|
@@ -395,7 +395,7 @@ function jt(e) {
|
|
|
395
395
|
}
|
|
396
396
|
var le = jt;
|
|
397
397
|
function Mt(e, t, r = !0) {
|
|
398
|
-
let n =
|
|
398
|
+
let n = y(!0);
|
|
399
399
|
$(n.current || !r ? () => {
|
|
400
400
|
n.current = !1;
|
|
401
401
|
} : e, t);
|
|
@@ -403,140 +403,140 @@ function Mt(e, t, r = !0) {
|
|
|
403
403
|
var E = Mt;
|
|
404
404
|
function B() {
|
|
405
405
|
}
|
|
406
|
-
function
|
|
407
|
-
return
|
|
406
|
+
function z(e, t, r, n) {
|
|
407
|
+
return Pt(e, n) || St(e, t, r, n);
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function Pt(e, t) {
|
|
410
410
|
return e.editor.getModel(Me(e, t));
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function St(e, t, r, n) {
|
|
413
413
|
return e.editor.createModel(t, r, n ? Me(e, n) : void 0);
|
|
414
414
|
}
|
|
415
415
|
function Me(e, t) {
|
|
416
416
|
return e.Uri.parse(t);
|
|
417
417
|
}
|
|
418
|
-
function Et({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: i, originalModelPath: o, modifiedModelPath: a, keepCurrentOriginalModel:
|
|
419
|
-
let [
|
|
418
|
+
function Et({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: i, originalModelPath: o, modifiedModelPath: a, keepCurrentOriginalModel: s = !1, keepCurrentModifiedModel: p = !1, theme: g = "light", loading: O = "Loading...", options: j = {}, height: T = "100%", width: L = "100%", className: Y, wrapperProps: I = {}, beforeMount: C = B, onMount: A = B }) {
|
|
419
|
+
let [M, R] = U(!1), [h, b] = U(!0), d = y(null), l = y(null), w = y(null), P = y(A), f = y(C), N = y(!1);
|
|
420
420
|
le(() => {
|
|
421
|
-
let u =
|
|
422
|
-
return u.then((
|
|
421
|
+
let u = re.init();
|
|
422
|
+
return u.then((m) => (l.current = m) && b(!1)).catch((m) => (m == null ? void 0 : m.type) !== "cancelation" && console.error("Monaco initialization: error:", m)), () => d.current ? W() : u.cancel();
|
|
423
423
|
}), E(() => {
|
|
424
|
-
if (d.current &&
|
|
425
|
-
let u = d.current.getOriginalEditor(),
|
|
426
|
-
|
|
424
|
+
if (d.current && l.current) {
|
|
425
|
+
let u = d.current.getOriginalEditor(), m = z(l.current, e || "", n || r || "text", o || "");
|
|
426
|
+
m !== u.getModel() && u.setModel(m);
|
|
427
427
|
}
|
|
428
|
-
}, [o],
|
|
429
|
-
if (d.current &&
|
|
430
|
-
let u = d.current.getModifiedEditor(),
|
|
431
|
-
|
|
428
|
+
}, [o], M), E(() => {
|
|
429
|
+
if (d.current && l.current) {
|
|
430
|
+
let u = d.current.getModifiedEditor(), m = z(l.current, t || "", i || r || "text", a || "");
|
|
431
|
+
m !== u.getModel() && u.setModel(m);
|
|
432
432
|
}
|
|
433
|
-
}, [a],
|
|
433
|
+
}, [a], M), E(() => {
|
|
434
434
|
let u = d.current.getModifiedEditor();
|
|
435
|
-
u.getOption(
|
|
436
|
-
}, [t],
|
|
437
|
-
var u,
|
|
438
|
-
(
|
|
439
|
-
}, [e],
|
|
440
|
-
let { original: u, modified:
|
|
441
|
-
|
|
442
|
-
}, [r, n, i],
|
|
435
|
+
u.getOption(l.current.editor.EditorOption.readOnly) ? u.setValue(t || "") : t !== u.getValue() && (u.executeEdits("", [{ range: u.getModel().getFullModelRange(), text: t || "", forceMoveMarkers: !0 }]), u.pushUndoStop());
|
|
436
|
+
}, [t], M), E(() => {
|
|
437
|
+
var u, m;
|
|
438
|
+
(m = (u = d.current) == null ? void 0 : u.getModel()) == null || m.original.setValue(e || "");
|
|
439
|
+
}, [e], M), E(() => {
|
|
440
|
+
let { original: u, modified: m } = d.current.getModel();
|
|
441
|
+
l.current.editor.setModelLanguage(u, n || r || "text"), l.current.editor.setModelLanguage(m, i || r || "text");
|
|
442
|
+
}, [r, n, i], M), E(() => {
|
|
443
443
|
var u;
|
|
444
|
-
(u =
|
|
445
|
-
}, [g],
|
|
444
|
+
(u = l.current) == null || u.editor.setTheme(g);
|
|
445
|
+
}, [g], M), E(() => {
|
|
446
446
|
var u;
|
|
447
|
-
(u = d.current) == null || u.updateOptions(
|
|
448
|
-
}, [
|
|
449
|
-
let
|
|
447
|
+
(u = d.current) == null || u.updateOptions(j);
|
|
448
|
+
}, [j], M);
|
|
449
|
+
let Z = ue(() => {
|
|
450
450
|
var x;
|
|
451
|
-
if (!
|
|
452
|
-
f.current(
|
|
453
|
-
let u =
|
|
454
|
-
(x = d.current) == null || x.setModel({ original: u, modified:
|
|
455
|
-
}, [r, t, i, e, n, o, a]),
|
|
451
|
+
if (!l.current) return;
|
|
452
|
+
f.current(l.current);
|
|
453
|
+
let u = z(l.current, e || "", n || r || "text", o || ""), m = z(l.current, t || "", i || r || "text", a || "");
|
|
454
|
+
(x = d.current) == null || x.setModel({ original: u, modified: m });
|
|
455
|
+
}, [r, t, i, e, n, o, a]), Q = ue(() => {
|
|
456
456
|
var u;
|
|
457
|
-
!N.current &&
|
|
458
|
-
}, [
|
|
457
|
+
!N.current && w.current && (d.current = l.current.editor.createDiffEditor(w.current, { automaticLayout: !0, ...j }), Z(), (u = l.current) == null || u.editor.setTheme(g), R(!0), N.current = !0);
|
|
458
|
+
}, [j, g, Z]);
|
|
459
459
|
$(() => {
|
|
460
|
-
|
|
461
|
-
}, [
|
|
462
|
-
!
|
|
463
|
-
}, [
|
|
460
|
+
M && P.current(d.current, l.current);
|
|
461
|
+
}, [M]), $(() => {
|
|
462
|
+
!h && !M && Q();
|
|
463
|
+
}, [h, M, Q]);
|
|
464
464
|
function W() {
|
|
465
|
-
var
|
|
466
|
-
let u = (
|
|
467
|
-
|
|
465
|
+
var m, x, _, k;
|
|
466
|
+
let u = (m = d.current) == null ? void 0 : m.getModel();
|
|
467
|
+
s || ((x = u == null ? void 0 : u.original) == null || x.dispose()), p || ((_ = u == null ? void 0 : u.modified) == null || _.dispose()), (k = d.current) == null || k.dispose();
|
|
468
468
|
}
|
|
469
|
-
return
|
|
469
|
+
return V.createElement(je, { width: L, height: T, isEditorReady: M, loading: O, _ref: w, className: Y, wrapperProps: I });
|
|
470
470
|
}
|
|
471
471
|
var Ct = Et;
|
|
472
472
|
ce(Ct);
|
|
473
473
|
function It() {
|
|
474
|
-
let [e, t] = U(
|
|
474
|
+
let [e, t] = U(re.__getMonacoInstance());
|
|
475
475
|
return le(() => {
|
|
476
476
|
let r;
|
|
477
|
-
return e || (r =
|
|
477
|
+
return e || (r = re.init(), r.then((n) => {
|
|
478
478
|
t(n);
|
|
479
479
|
})), () => r == null ? void 0 : r.cancel();
|
|
480
480
|
}), e;
|
|
481
481
|
}
|
|
482
482
|
var $t = It;
|
|
483
483
|
function Lt(e) {
|
|
484
|
-
let t =
|
|
484
|
+
let t = y();
|
|
485
485
|
return $(() => {
|
|
486
486
|
t.current = e;
|
|
487
487
|
}, [e]), t.current;
|
|
488
488
|
}
|
|
489
|
-
var At = Lt,
|
|
490
|
-
function xt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: i, path: o, theme: a = "light", line:
|
|
491
|
-
let [b, d] = U(!1), [
|
|
489
|
+
var At = Lt, ee = /* @__PURE__ */ new Map();
|
|
490
|
+
function xt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: i, path: o, theme: a = "light", line: s, loading: p = "Loading...", options: g = {}, overrideServices: O = {}, saveViewState: j = !0, keepCurrentModel: T = !1, width: L = "100%", height: Y = "100%", className: I, wrapperProps: C = {}, beforeMount: A = B, onMount: M = B, onChange: R, onValidate: h = B }) {
|
|
491
|
+
let [b, d] = U(!1), [l, w] = U(!0), P = y(null), f = y(null), N = y(null), Z = y(M), Q = y(A), W = y(), u = y(n), m = At(o), x = y(!1), _ = y(!1);
|
|
492
492
|
le(() => {
|
|
493
|
-
let c =
|
|
494
|
-
return c.then((v) => (
|
|
493
|
+
let c = re.init();
|
|
494
|
+
return c.then((v) => (P.current = v) && w(!1)).catch((v) => (v == null ? void 0 : v.type) !== "cancelation" && console.error("Monaco initialization: error:", v)), () => f.current ? Se() : c.cancel();
|
|
495
495
|
}), E(() => {
|
|
496
|
-
var v,
|
|
497
|
-
let c =
|
|
498
|
-
c !== ((v = f.current) == null ? void 0 : v.getModel()) && (
|
|
496
|
+
var v, S, F, q;
|
|
497
|
+
let c = z(P.current, e || n || "", t || i || "", o || r || "");
|
|
498
|
+
c !== ((v = f.current) == null ? void 0 : v.getModel()) && (j && ee.set(m, (S = f.current) == null ? void 0 : S.saveViewState()), (F = f.current) == null || F.setModel(c), j && ((q = f.current) == null || q.restoreViewState(ee.get(o))));
|
|
499
499
|
}, [o], b), E(() => {
|
|
500
500
|
var c;
|
|
501
501
|
(c = f.current) == null || c.updateOptions(g);
|
|
502
502
|
}, [g], b), E(() => {
|
|
503
|
-
!f.current || n === void 0 || (f.current.getOption(
|
|
503
|
+
!f.current || n === void 0 || (f.current.getOption(P.current.editor.EditorOption.readOnly) ? f.current.setValue(n) : n !== f.current.getValue() && (_.current = !0, f.current.executeEdits("", [{ range: f.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), f.current.pushUndoStop(), _.current = !1));
|
|
504
504
|
}, [n], b), E(() => {
|
|
505
|
-
var v,
|
|
505
|
+
var v, S;
|
|
506
506
|
let c = (v = f.current) == null ? void 0 : v.getModel();
|
|
507
|
-
c && i && ((
|
|
507
|
+
c && i && ((S = P.current) == null || S.editor.setModelLanguage(c, i));
|
|
508
508
|
}, [i], b), E(() => {
|
|
509
509
|
var c;
|
|
510
|
-
|
|
511
|
-
}, [
|
|
510
|
+
s !== void 0 && ((c = f.current) == null || c.revealLine(s));
|
|
511
|
+
}, [s], b), E(() => {
|
|
512
512
|
var c;
|
|
513
|
-
(c =
|
|
513
|
+
(c = P.current) == null || c.editor.setTheme(a);
|
|
514
514
|
}, [a], b);
|
|
515
|
-
let
|
|
515
|
+
let k = ue(() => {
|
|
516
516
|
var c;
|
|
517
|
-
if (!(!N.current || !
|
|
518
|
-
|
|
519
|
-
let v = o || r,
|
|
520
|
-
f.current = (c =
|
|
517
|
+
if (!(!N.current || !P.current) && !x.current) {
|
|
518
|
+
Q.current(P.current);
|
|
519
|
+
let v = o || r, S = z(P.current, n || e || "", t || i || "", v || "");
|
|
520
|
+
f.current = (c = P.current) == null ? void 0 : c.editor.create(N.current, { model: S, automaticLayout: !0, ...g }, O), j && f.current.restoreViewState(ee.get(v)), P.current.editor.setTheme(a), s !== void 0 && f.current.revealLine(s), d(!0), x.current = !0;
|
|
521
521
|
}
|
|
522
|
-
}, [e, t, r, n, i, o, g,
|
|
522
|
+
}, [e, t, r, n, i, o, g, O, j, a, s]);
|
|
523
523
|
$(() => {
|
|
524
|
-
b &&
|
|
524
|
+
b && Z.current(f.current, P.current);
|
|
525
525
|
}, [b]), $(() => {
|
|
526
|
-
!
|
|
527
|
-
}, [
|
|
526
|
+
!l && !b && k();
|
|
527
|
+
}, [l, b, k]), u.current = n, $(() => {
|
|
528
528
|
var c, v;
|
|
529
|
-
b && R && ((c = W.current) == null || c.dispose(), W.current = (v = f.current) == null ? void 0 : v.onDidChangeModelContent((
|
|
530
|
-
_.current || R(f.current.getValue(),
|
|
529
|
+
b && R && ((c = W.current) == null || c.dispose(), W.current = (v = f.current) == null ? void 0 : v.onDidChangeModelContent((S) => {
|
|
530
|
+
_.current || R(f.current.getValue(), S);
|
|
531
531
|
}));
|
|
532
532
|
}, [b, R]), $(() => {
|
|
533
533
|
if (b) {
|
|
534
|
-
let c =
|
|
535
|
-
var
|
|
536
|
-
let
|
|
537
|
-
if (
|
|
538
|
-
let q =
|
|
539
|
-
|
|
534
|
+
let c = P.current.editor.onDidChangeMarkers((v) => {
|
|
535
|
+
var F;
|
|
536
|
+
let S = (F = f.current.getModel()) == null ? void 0 : F.uri;
|
|
537
|
+
if (S && v.find((q) => q.path === S.path)) {
|
|
538
|
+
let q = P.current.editor.getModelMarkers({ resource: S });
|
|
539
|
+
h == null || h(q);
|
|
540
540
|
}
|
|
541
541
|
});
|
|
542
542
|
return () => {
|
|
@@ -545,12 +545,12 @@ function xt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, lan
|
|
|
545
545
|
}
|
|
546
546
|
return () => {
|
|
547
547
|
};
|
|
548
|
-
}, [b,
|
|
549
|
-
function
|
|
548
|
+
}, [b, h]);
|
|
549
|
+
function Se() {
|
|
550
550
|
var c, v;
|
|
551
|
-
(c = W.current) == null || c.dispose(), T ?
|
|
551
|
+
(c = W.current) == null || c.dispose(), T ? j && ee.set(o, f.current.saveViewState()) : (v = f.current.getModel()) == null || v.dispose(), f.current.dispose();
|
|
552
552
|
}
|
|
553
|
-
return
|
|
553
|
+
return V.createElement(je, { width: L, height: Y, isEditorReady: b, loading: p, _ref: N, className: I, wrapperProps: C });
|
|
554
554
|
}
|
|
555
555
|
var Dt = xt, Tt = ce(Dt), Rt = Tt;
|
|
556
556
|
const Nt = /* @__PURE__ */ (() => {
|
|
@@ -562,7 +562,7 @@ const Nt = /* @__PURE__ */ (() => {
|
|
|
562
562
|
fields: Object.entries(n.attributes.fields).filter(([a]) => !a.startsWith("_")),
|
|
563
563
|
relationships: Object.entries(n.attributes.relationships).filter(([a]) => !a.startsWith("_")).filter(
|
|
564
564
|
([, a]) => t.find(
|
|
565
|
-
(
|
|
565
|
+
(s) => s.id === Pe(a.class_name)
|
|
566
566
|
) != null
|
|
567
567
|
)
|
|
568
568
|
}
|
|
@@ -595,13 +595,13 @@ async function qt(e, t) {
|
|
|
595
595
|
const r = await Nt(), n = e.replace(/\.$/, "").split("."), i = n.shift();
|
|
596
596
|
return t ?? (t = r[i ?? ""]), n.reduce(
|
|
597
597
|
(o, a) => {
|
|
598
|
-
var g,
|
|
599
|
-
const
|
|
600
|
-
([
|
|
601
|
-
)) == null ? void 0 :
|
|
602
|
-
if (
|
|
598
|
+
var g, O;
|
|
599
|
+
const s = (O = (g = o.obj) == null ? void 0 : g.relationships.find(
|
|
600
|
+
([j]) => j === a
|
|
601
|
+
)) == null ? void 0 : O[1].class_name;
|
|
602
|
+
if (s == null)
|
|
603
603
|
return o;
|
|
604
|
-
const p = r[
|
|
604
|
+
const p = r[Pe(s)];
|
|
605
605
|
return p == null ? o : {
|
|
606
606
|
path: `${o.path == null ? "" : `${o.path}.`}${a}`,
|
|
607
607
|
obj: p
|
|
@@ -610,10 +610,10 @@ async function qt(e, t) {
|
|
|
610
610
|
{ path: t != null ? i ?? "" : "", obj: t }
|
|
611
611
|
);
|
|
612
612
|
}
|
|
613
|
-
function
|
|
613
|
+
function Pe(e) {
|
|
614
614
|
return e.replace(/([A-Z])/g, "_$1").replace(/^_/, "").toLowerCase();
|
|
615
615
|
}
|
|
616
|
-
const
|
|
616
|
+
const zt = Ut(500), Vt = Ce(
|
|
617
617
|
({
|
|
618
618
|
feedback: e,
|
|
619
619
|
hint: t,
|
|
@@ -622,54 +622,64 @@ const Vt = Ut(500), zt = Ce(
|
|
|
622
622
|
defaultValue: i,
|
|
623
623
|
readOnly: o,
|
|
624
624
|
value: a,
|
|
625
|
-
language:
|
|
625
|
+
language: s = "plaintext",
|
|
626
626
|
height: p = "220px",
|
|
627
627
|
jsonSchema: g = "none",
|
|
628
|
-
onValidate:
|
|
629
|
-
onValid:
|
|
628
|
+
onValidate: O,
|
|
629
|
+
onValid: j,
|
|
630
630
|
onChange: T,
|
|
631
631
|
...L
|
|
632
|
-
},
|
|
633
|
-
const I = $t(), C =
|
|
634
|
-
|
|
632
|
+
}, Y) => {
|
|
633
|
+
const I = $t(), C = y(), [A, M] = U(null), R = (h, b) => {
|
|
634
|
+
M(h), h.onDidPaste(() => {
|
|
635
635
|
var d;
|
|
636
|
-
(d =
|
|
637
|
-
}),
|
|
638
|
-
const d =
|
|
636
|
+
(d = h.getAction("editor.action.formatDocument")) == null || d.run();
|
|
637
|
+
}), h.onDidChangeModelContent(() => {
|
|
638
|
+
const d = h.getModel(), l = b.editor.getModelMarkers({
|
|
639
639
|
resource: d == null ? void 0 : d.uri
|
|
640
|
-
}),
|
|
641
|
-
|
|
642
|
-
|
|
640
|
+
}), w = h.getValue();
|
|
641
|
+
zt(() => {
|
|
642
|
+
O == null || O(l.length > 0 ? l : null), T == null || T(w), l.length === 0 && (j == null || j(w));
|
|
643
643
|
});
|
|
644
644
|
});
|
|
645
645
|
};
|
|
646
646
|
return $(() => (async function() {
|
|
647
647
|
var b, d;
|
|
648
|
-
const
|
|
649
|
-
if (I != null &&
|
|
648
|
+
const h = (b = A == null ? void 0 : A.getModel()) == null ? void 0 : b.uri.toString();
|
|
649
|
+
if (I != null && h != null && g != null) {
|
|
650
650
|
(d = C.current) == null || d.call(C);
|
|
651
|
-
const
|
|
651
|
+
const l = I.languages.json.jsonDefaults.diagnosticsOptions.schemas ?? [];
|
|
652
652
|
switch (g) {
|
|
653
653
|
case "none":
|
|
654
654
|
break;
|
|
655
|
+
case "organization-config": {
|
|
656
|
+
l.push({
|
|
657
|
+
schema: await fetch(
|
|
658
|
+
"https://provisioning.commercelayer.io/api/public/schemas/organization_config"
|
|
659
|
+
).then(async (w) => await w.json()).then((w) => K(w)),
|
|
660
|
+
uri: `file:///json-schema--${g}.json`,
|
|
661
|
+
fileMatch: [h]
|
|
662
|
+
});
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
655
665
|
case "order-rules": {
|
|
656
|
-
|
|
666
|
+
l.push({
|
|
657
667
|
schema: await fetch(
|
|
658
668
|
"https://core.commercelayer.io/api/public/schemas/order_rules"
|
|
659
|
-
).then(async (
|
|
669
|
+
).then(async (w) => await w.json()).then((w) => K(w)),
|
|
660
670
|
uri: `file:///json-schema--${g}.json`,
|
|
661
|
-
fileMatch: [
|
|
662
|
-
}), C.current = ve(I,
|
|
671
|
+
fileMatch: [h]
|
|
672
|
+
}), C.current = ve(I, h, ["order"]);
|
|
663
673
|
break;
|
|
664
674
|
}
|
|
665
675
|
case "price-rules": {
|
|
666
|
-
|
|
676
|
+
l.push({
|
|
667
677
|
schema: await fetch(
|
|
668
678
|
"https://core.commercelayer.io/api/public/schemas/price_rules"
|
|
669
|
-
).then(async (
|
|
679
|
+
).then(async (w) => await w.json()).then((w) => K(w)),
|
|
670
680
|
uri: `file:///json-schema--${g}.json`,
|
|
671
|
-
fileMatch: [
|
|
672
|
-
}), C.current = ve(I,
|
|
681
|
+
fileMatch: [h]
|
|
682
|
+
}), C.current = ve(I, h, ["price"]);
|
|
673
683
|
break;
|
|
674
684
|
}
|
|
675
685
|
}
|
|
@@ -678,12 +688,12 @@ const Vt = Ut(500), zt = Ce(
|
|
|
678
688
|
schemaRequest: "ignore",
|
|
679
689
|
schemaValidation: "error",
|
|
680
690
|
validate: !0,
|
|
681
|
-
schemas:
|
|
691
|
+
schemas: l
|
|
682
692
|
});
|
|
683
693
|
}
|
|
684
694
|
}(), () => {
|
|
685
|
-
var
|
|
686
|
-
(
|
|
695
|
+
var h;
|
|
696
|
+
(h = C.current) == null || h.call(C);
|
|
687
697
|
}), [I, A, g]), /* @__PURE__ */ se.jsx(
|
|
688
698
|
Ee,
|
|
689
699
|
{
|
|
@@ -698,7 +708,7 @@ const Vt = Ut(500), zt = Ce(
|
|
|
698
708
|
defaultPath: L.id ?? L.name,
|
|
699
709
|
className: "[&>.monaco-editor]:rounded [&>.monaco-editor>.overflow-guard]:rounded",
|
|
700
710
|
theme: "vs-dark",
|
|
701
|
-
language:
|
|
711
|
+
language: s,
|
|
702
712
|
height: p,
|
|
703
713
|
defaultValue: i,
|
|
704
714
|
value: a,
|
|
@@ -724,7 +734,7 @@ const Vt = Ut(500), zt = Ce(
|
|
|
724
734
|
);
|
|
725
735
|
}
|
|
726
736
|
);
|
|
727
|
-
|
|
737
|
+
Vt.displayName = "CodeEditor";
|
|
728
738
|
function Ut(e = 100) {
|
|
729
739
|
let t = null;
|
|
730
740
|
return function(n) {
|
|
@@ -733,10 +743,10 @@ function Ut(e = 100) {
|
|
|
733
743
|
}, e);
|
|
734
744
|
};
|
|
735
745
|
}
|
|
736
|
-
function
|
|
737
|
-
return typeof e != "object" || e === null ? e : Array.isArray(e) ? e.map((r) =>
|
|
746
|
+
function K(e, t) {
|
|
747
|
+
return typeof e != "object" || e === null ? e : Array.isArray(e) ? e.map((r) => K(r)) : Object.entries(e).reduce((r, [n, i]) => t !== "properties" && ["examples", "default"].includes(n) ? r : {
|
|
738
748
|
...r,
|
|
739
|
-
[n]:
|
|
749
|
+
[n]: K(i, n)
|
|
740
750
|
}, {});
|
|
741
751
|
}
|
|
742
752
|
function ve(e, t, r) {
|
|
@@ -756,10 +766,10 @@ function ve(e, t, r) {
|
|
|
756
766
|
suggestions: (await _t(
|
|
757
767
|
r,
|
|
758
768
|
p
|
|
759
|
-
)).map((
|
|
760
|
-
kind:
|
|
761
|
-
label:
|
|
762
|
-
insertText:
|
|
769
|
+
)).map((O) => ({
|
|
770
|
+
kind: O.type === "relationship" ? e.languages.CompletionItemKind.Module : e.languages.CompletionItemKind.Value,
|
|
771
|
+
label: O.value,
|
|
772
|
+
insertText: O.value,
|
|
763
773
|
// documentation: `Field: ${suggestion}`,
|
|
764
774
|
range: {
|
|
765
775
|
startLineNumber: i.lineNumber,
|
|
@@ -778,5 +788,5 @@ function ve(e, t, r) {
|
|
|
778
788
|
};
|
|
779
789
|
}
|
|
780
790
|
export {
|
|
781
|
-
|
|
791
|
+
Vt as CodeEditor
|
|
782
792
|
};
|