@commercelayer/app-elements 2.10.1 → 2.11.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-C9x2Ium1.js +780 -0
- package/dist/{InputDateComponent-nCNyqqLQ.js → InputDateComponent-MvTeBGCJ.js} +1 -1
- package/dist/{main-CBSTK6gX.js → main-D2LHr3Fk.js} +4714 -4670
- package/dist/main.d.ts +1 -0
- package/dist/main.js +176 -174
- package/dist/style.css +1 -1
- package/dist/ui/forms/CodeEditor/CodeEditor.d.ts +2 -0
- package/dist/ui/forms/CodeEditor/CodeEditorComponent.d.ts +32 -0
- package/dist/ui/forms/CodeEditor/HookedCodeEditor.d.ts +8 -0
- package/dist/ui/forms/CodeEditor/fetchCoreResourcesSuggestions.d.ts +28 -0
- package/dist/ui/forms/CodeEditor/fetchCoreResourcesSuggestions.test.d.ts +1 -0
- package/dist/ui/forms/CodeEditor/index.d.ts +3 -0
- package/package.json +2 -1
|
@@ -0,0 +1,780 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { j as se, I as Ee } from "./main-D2LHr3Fk.js";
|
|
3
|
+
import q, { memo as ce, useState as V, useRef as w, useCallback as ue, useEffect as $, forwardRef as Ie } from "react";
|
|
4
|
+
function Ce(e, t, r) {
|
|
5
|
+
return t in e ? Object.defineProperty(e, t, {
|
|
6
|
+
value: r,
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
configurable: !0,
|
|
9
|
+
writable: !0
|
|
10
|
+
}) : e[t] = r, e;
|
|
11
|
+
}
|
|
12
|
+
function fe(e, t) {
|
|
13
|
+
var r = Object.keys(e);
|
|
14
|
+
if (Object.getOwnPropertySymbols) {
|
|
15
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
16
|
+
t && (n = n.filter(function(i) {
|
|
17
|
+
return Object.getOwnPropertyDescriptor(e, i).enumerable;
|
|
18
|
+
})), r.push.apply(r, n);
|
|
19
|
+
}
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
22
|
+
function de(e) {
|
|
23
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
24
|
+
var r = arguments[t] != null ? arguments[t] : {};
|
|
25
|
+
t % 2 ? fe(Object(r), !0).forEach(function(n) {
|
|
26
|
+
Ce(e, n, r[n]);
|
|
27
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : fe(Object(r)).forEach(function(n) {
|
|
28
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return e;
|
|
32
|
+
}
|
|
33
|
+
function $e(e, t) {
|
|
34
|
+
if (e == null) return {};
|
|
35
|
+
var r = {}, n = Object.keys(e), i, o;
|
|
36
|
+
for (o = 0; o < n.length; o++)
|
|
37
|
+
i = n[o], !(t.indexOf(i) >= 0) && (r[i] = e[i]);
|
|
38
|
+
return r;
|
|
39
|
+
}
|
|
40
|
+
function Le(e, t) {
|
|
41
|
+
if (e == null) return {};
|
|
42
|
+
var r = $e(e, t), n, i;
|
|
43
|
+
if (Object.getOwnPropertySymbols) {
|
|
44
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
45
|
+
for (i = 0; i < o.length; i++)
|
|
46
|
+
n = o[i], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]);
|
|
47
|
+
}
|
|
48
|
+
return r;
|
|
49
|
+
}
|
|
50
|
+
function Ae(e, t) {
|
|
51
|
+
return De(e) || xe(e, t) || Te(e, t) || Re();
|
|
52
|
+
}
|
|
53
|
+
function De(e) {
|
|
54
|
+
if (Array.isArray(e)) return e;
|
|
55
|
+
}
|
|
56
|
+
function xe(e, t) {
|
|
57
|
+
if (!(typeof Symbol > "u" || !(Symbol.iterator in Object(e)))) {
|
|
58
|
+
var r = [], n = !0, i = !1, o = void 0;
|
|
59
|
+
try {
|
|
60
|
+
for (var a = e[Symbol.iterator](), f; !(n = (f = a.next()).done) && (r.push(f.value), !(t && r.length === t)); n = !0)
|
|
61
|
+
;
|
|
62
|
+
} catch (s) {
|
|
63
|
+
i = !0, o = s;
|
|
64
|
+
} finally {
|
|
65
|
+
try {
|
|
66
|
+
!n && a.return != null && a.return();
|
|
67
|
+
} finally {
|
|
68
|
+
if (i) throw o;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return r;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function Te(e, t) {
|
|
75
|
+
if (e) {
|
|
76
|
+
if (typeof e == "string") return pe(e, t);
|
|
77
|
+
var r = Object.prototype.toString.call(e).slice(8, -1);
|
|
78
|
+
if (r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set") return Array.from(e);
|
|
79
|
+
if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return pe(e, t);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function pe(e, t) {
|
|
83
|
+
(t == null || t > e.length) && (t = e.length);
|
|
84
|
+
for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
|
|
85
|
+
return n;
|
|
86
|
+
}
|
|
87
|
+
function Re() {
|
|
88
|
+
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
89
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
90
|
+
}
|
|
91
|
+
function Ne(e, t, r) {
|
|
92
|
+
return t in e ? Object.defineProperty(e, t, {
|
|
93
|
+
value: r,
|
|
94
|
+
enumerable: !0,
|
|
95
|
+
configurable: !0,
|
|
96
|
+
writable: !0
|
|
97
|
+
}) : e[t] = r, e;
|
|
98
|
+
}
|
|
99
|
+
function ge(e, t) {
|
|
100
|
+
var r = Object.keys(e);
|
|
101
|
+
if (Object.getOwnPropertySymbols) {
|
|
102
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
103
|
+
t && (n = n.filter(function(i) {
|
|
104
|
+
return Object.getOwnPropertyDescriptor(e, i).enumerable;
|
|
105
|
+
})), r.push.apply(r, n);
|
|
106
|
+
}
|
|
107
|
+
return r;
|
|
108
|
+
}
|
|
109
|
+
function he(e) {
|
|
110
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
111
|
+
var r = arguments[t] != null ? arguments[t] : {};
|
|
112
|
+
t % 2 ? ge(Object(r), !0).forEach(function(n) {
|
|
113
|
+
Ne(e, n, r[n]);
|
|
114
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ge(Object(r)).forEach(function(n) {
|
|
115
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return e;
|
|
119
|
+
}
|
|
120
|
+
function _e() {
|
|
121
|
+
for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
|
|
122
|
+
t[r] = arguments[r];
|
|
123
|
+
return function(n) {
|
|
124
|
+
return t.reduceRight(function(i, o) {
|
|
125
|
+
return o(i);
|
|
126
|
+
}, n);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function H(e) {
|
|
130
|
+
return function t() {
|
|
131
|
+
for (var r = this, n = arguments.length, i = new Array(n), o = 0; o < n; o++)
|
|
132
|
+
i[o] = arguments[o];
|
|
133
|
+
return i.length >= e.length ? e.apply(this, i) : function() {
|
|
134
|
+
for (var a = arguments.length, f = new Array(a), s = 0; s < a; s++)
|
|
135
|
+
f[s] = arguments[s];
|
|
136
|
+
return t.apply(r, [].concat(i, f));
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function ee(e) {
|
|
141
|
+
return {}.toString.call(e).includes("Object");
|
|
142
|
+
}
|
|
143
|
+
function qe(e) {
|
|
144
|
+
return !Object.keys(e).length;
|
|
145
|
+
}
|
|
146
|
+
function K(e) {
|
|
147
|
+
return typeof e == "function";
|
|
148
|
+
}
|
|
149
|
+
function Ve(e, t) {
|
|
150
|
+
return Object.prototype.hasOwnProperty.call(e, t);
|
|
151
|
+
}
|
|
152
|
+
function ze(e, t) {
|
|
153
|
+
return ee(t) || x("changeType"), Object.keys(t).some(function(r) {
|
|
154
|
+
return !Ve(e, r);
|
|
155
|
+
}) && x("changeField"), t;
|
|
156
|
+
}
|
|
157
|
+
function Ue(e) {
|
|
158
|
+
K(e) || x("selectorType");
|
|
159
|
+
}
|
|
160
|
+
function We(e) {
|
|
161
|
+
K(e) || ee(e) || x("handlerType"), ee(e) && Object.values(e).some(function(t) {
|
|
162
|
+
return !K(t);
|
|
163
|
+
}) && x("handlersType");
|
|
164
|
+
}
|
|
165
|
+
function Fe(e) {
|
|
166
|
+
e || x("initialIsRequired"), ee(e) || x("initialType"), qe(e) && x("initialContent");
|
|
167
|
+
}
|
|
168
|
+
function ke(e, t) {
|
|
169
|
+
throw new Error(e[t] || e.default);
|
|
170
|
+
}
|
|
171
|
+
var He = {
|
|
172
|
+
initialIsRequired: "initial state is required",
|
|
173
|
+
initialType: "initial state should be an object",
|
|
174
|
+
initialContent: "initial state shouldn't be an empty object",
|
|
175
|
+
handlerType: "handler should be an object or a function",
|
|
176
|
+
handlersType: "all handlers should be a functions",
|
|
177
|
+
selectorType: "selector should be a function",
|
|
178
|
+
changeType: "provided value of changes should be an object",
|
|
179
|
+
changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
|
|
180
|
+
default: "an unknown error accured in `state-local` package"
|
|
181
|
+
}, x = H(ke)(He), Q = {
|
|
182
|
+
changes: ze,
|
|
183
|
+
selector: Ue,
|
|
184
|
+
handler: We,
|
|
185
|
+
initial: Fe
|
|
186
|
+
};
|
|
187
|
+
function Be(e) {
|
|
188
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
189
|
+
Q.initial(e), Q.handler(t);
|
|
190
|
+
var r = {
|
|
191
|
+
current: e
|
|
192
|
+
}, n = H(Je)(r, t), i = H(Ge)(r), o = H(Q.changes)(e), a = H(Ke)(r);
|
|
193
|
+
function f() {
|
|
194
|
+
var v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(y) {
|
|
195
|
+
return y;
|
|
196
|
+
};
|
|
197
|
+
return Q.selector(v), v(r.current);
|
|
198
|
+
}
|
|
199
|
+
function s(v) {
|
|
200
|
+
_e(n, i, o, a)(v);
|
|
201
|
+
}
|
|
202
|
+
return [f, s];
|
|
203
|
+
}
|
|
204
|
+
function Ke(e, t) {
|
|
205
|
+
return K(t) ? t(e.current) : t;
|
|
206
|
+
}
|
|
207
|
+
function Ge(e, t) {
|
|
208
|
+
return e.current = he(he({}, e.current), t), t;
|
|
209
|
+
}
|
|
210
|
+
function Je(e, t, r) {
|
|
211
|
+
return K(t) ? t(e.current) : Object.keys(r).forEach(function(n) {
|
|
212
|
+
var i;
|
|
213
|
+
return (i = t[n]) === null || i === void 0 ? void 0 : i.call(t, e.current[n]);
|
|
214
|
+
}), r;
|
|
215
|
+
}
|
|
216
|
+
var Ye = {
|
|
217
|
+
create: Be
|
|
218
|
+
}, Ze = {
|
|
219
|
+
paths: {
|
|
220
|
+
vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
function Qe(e) {
|
|
224
|
+
return function t() {
|
|
225
|
+
for (var r = this, n = arguments.length, i = new Array(n), o = 0; o < n; o++)
|
|
226
|
+
i[o] = arguments[o];
|
|
227
|
+
return i.length >= e.length ? e.apply(this, i) : function() {
|
|
228
|
+
for (var a = arguments.length, f = new Array(a), s = 0; s < a; s++)
|
|
229
|
+
f[s] = arguments[s];
|
|
230
|
+
return t.apply(r, [].concat(i, f));
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function Xe(e) {
|
|
235
|
+
return {}.toString.call(e).includes("Object");
|
|
236
|
+
}
|
|
237
|
+
function et(e) {
|
|
238
|
+
return e || me("configIsRequired"), Xe(e) || me("configType"), e.urls ? (tt(), {
|
|
239
|
+
paths: {
|
|
240
|
+
vs: e.urls.monacoBase
|
|
241
|
+
}
|
|
242
|
+
}) : e;
|
|
243
|
+
}
|
|
244
|
+
function tt() {
|
|
245
|
+
console.warn(be.deprecation);
|
|
246
|
+
}
|
|
247
|
+
function rt(e, t) {
|
|
248
|
+
throw new Error(e[t] || e.default);
|
|
249
|
+
}
|
|
250
|
+
var be = {
|
|
251
|
+
configIsRequired: "the configuration object is required",
|
|
252
|
+
configType: "the configuration object should be an object",
|
|
253
|
+
default: "an unknown error accured in `@monaco-editor/loader` package",
|
|
254
|
+
deprecation: `Deprecation warning!
|
|
255
|
+
You are using deprecated way of configuration.
|
|
256
|
+
|
|
257
|
+
Instead of using
|
|
258
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
259
|
+
use
|
|
260
|
+
monaco.config({ paths: { vs: '...' } })
|
|
261
|
+
|
|
262
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
263
|
+
`
|
|
264
|
+
}, me = Qe(rt)(be), nt = {
|
|
265
|
+
config: et
|
|
266
|
+
}, it = function() {
|
|
267
|
+
for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
|
|
268
|
+
r[n] = arguments[n];
|
|
269
|
+
return function(i) {
|
|
270
|
+
return r.reduceRight(function(o, a) {
|
|
271
|
+
return a(o);
|
|
272
|
+
}, i);
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
function we(e, t) {
|
|
276
|
+
return Object.keys(t).forEach(function(r) {
|
|
277
|
+
t[r] instanceof Object && e[r] && Object.assign(t[r], we(e[r], t[r]));
|
|
278
|
+
}), de(de({}, e), t);
|
|
279
|
+
}
|
|
280
|
+
var ot = {
|
|
281
|
+
type: "cancelation",
|
|
282
|
+
msg: "operation is manually canceled"
|
|
283
|
+
};
|
|
284
|
+
function ie(e) {
|
|
285
|
+
var t = !1, r = new Promise(function(n, i) {
|
|
286
|
+
e.then(function(o) {
|
|
287
|
+
return t ? i(ot) : n(o);
|
|
288
|
+
}), e.catch(i);
|
|
289
|
+
});
|
|
290
|
+
return r.cancel = function() {
|
|
291
|
+
return t = !0;
|
|
292
|
+
}, r;
|
|
293
|
+
}
|
|
294
|
+
var at = Ye.create({
|
|
295
|
+
config: Ze,
|
|
296
|
+
isInitialized: !1,
|
|
297
|
+
resolve: null,
|
|
298
|
+
reject: null,
|
|
299
|
+
monaco: null
|
|
300
|
+
}), ye = Ae(at, 2), G = ye[0], ne = ye[1];
|
|
301
|
+
function ut(e) {
|
|
302
|
+
var t = nt.config(e), r = t.monaco, n = Le(t, ["monaco"]);
|
|
303
|
+
ne(function(i) {
|
|
304
|
+
return {
|
|
305
|
+
config: we(i.config, n),
|
|
306
|
+
monaco: r
|
|
307
|
+
};
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function ct() {
|
|
311
|
+
var e = G(function(t) {
|
|
312
|
+
var r = t.monaco, n = t.isInitialized, i = t.resolve;
|
|
313
|
+
return {
|
|
314
|
+
monaco: r,
|
|
315
|
+
isInitialized: n,
|
|
316
|
+
resolve: i
|
|
317
|
+
};
|
|
318
|
+
});
|
|
319
|
+
if (!e.isInitialized) {
|
|
320
|
+
if (ne({
|
|
321
|
+
isInitialized: !0
|
|
322
|
+
}), e.monaco)
|
|
323
|
+
return e.resolve(e.monaco), ie(oe);
|
|
324
|
+
if (window.monaco && window.monaco.editor)
|
|
325
|
+
return Oe(window.monaco), e.resolve(window.monaco), ie(oe);
|
|
326
|
+
it(lt, ft)(dt);
|
|
327
|
+
}
|
|
328
|
+
return ie(oe);
|
|
329
|
+
}
|
|
330
|
+
function lt(e) {
|
|
331
|
+
return document.body.appendChild(e);
|
|
332
|
+
}
|
|
333
|
+
function st(e) {
|
|
334
|
+
var t = document.createElement("script");
|
|
335
|
+
return e && (t.src = e), t;
|
|
336
|
+
}
|
|
337
|
+
function ft(e) {
|
|
338
|
+
var t = G(function(n) {
|
|
339
|
+
var i = n.config, o = n.reject;
|
|
340
|
+
return {
|
|
341
|
+
config: i,
|
|
342
|
+
reject: o
|
|
343
|
+
};
|
|
344
|
+
}), r = st("".concat(t.config.paths.vs, "/loader.js"));
|
|
345
|
+
return r.onload = function() {
|
|
346
|
+
return e();
|
|
347
|
+
}, r.onerror = t.reject, r;
|
|
348
|
+
}
|
|
349
|
+
function dt() {
|
|
350
|
+
var e = G(function(r) {
|
|
351
|
+
var n = r.config, i = r.resolve, o = r.reject;
|
|
352
|
+
return {
|
|
353
|
+
config: n,
|
|
354
|
+
resolve: i,
|
|
355
|
+
reject: o
|
|
356
|
+
};
|
|
357
|
+
}), t = window.require;
|
|
358
|
+
t.config(e.config), t(["vs/editor/editor.main"], function(r) {
|
|
359
|
+
Oe(r), e.resolve(r);
|
|
360
|
+
}, function(r) {
|
|
361
|
+
e.reject(r);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function Oe(e) {
|
|
365
|
+
G().monaco || ne({
|
|
366
|
+
monaco: e
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function pt() {
|
|
370
|
+
return G(function(e) {
|
|
371
|
+
var t = e.monaco;
|
|
372
|
+
return t;
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
var oe = new Promise(function(e, t) {
|
|
376
|
+
return ne({
|
|
377
|
+
resolve: e,
|
|
378
|
+
reject: t
|
|
379
|
+
});
|
|
380
|
+
}), te = {
|
|
381
|
+
config: ut,
|
|
382
|
+
init: ct,
|
|
383
|
+
__getMonacoInstance: pt
|
|
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
|
+
function vt({ children: e }) {
|
|
386
|
+
return q.createElement("div", { style: mt.container }, e);
|
|
387
|
+
}
|
|
388
|
+
var bt = vt, wt = bt;
|
|
389
|
+
function yt({ width: e, height: t, isEditorReady: r, loading: n, _ref: i, className: o, wrapperProps: a }) {
|
|
390
|
+
return q.createElement("section", { style: { ...ae.wrapper, width: e, height: t }, ...a }, !r && q.createElement(wt, null, n), q.createElement("div", { ref: i, style: { ...ae.fullWidth, ...!r && ae.hide }, className: o }));
|
|
391
|
+
}
|
|
392
|
+
var Ot = yt, je = ce(Ot);
|
|
393
|
+
function jt(e) {
|
|
394
|
+
$(e, []);
|
|
395
|
+
}
|
|
396
|
+
var le = jt;
|
|
397
|
+
function Mt(e, t, r = !0) {
|
|
398
|
+
let n = w(!0);
|
|
399
|
+
$(n.current || !r ? () => {
|
|
400
|
+
n.current = !1;
|
|
401
|
+
} : e, t);
|
|
402
|
+
}
|
|
403
|
+
var P = Mt;
|
|
404
|
+
function B() {
|
|
405
|
+
}
|
|
406
|
+
function _(e, t, r, n) {
|
|
407
|
+
return St(e, n) || Pt(e, t, r, n);
|
|
408
|
+
}
|
|
409
|
+
function St(e, t) {
|
|
410
|
+
return e.editor.getModel(Me(e, t));
|
|
411
|
+
}
|
|
412
|
+
function Pt(e, t, r, n) {
|
|
413
|
+
return e.editor.createModel(t, r, n ? Me(e, n) : void 0);
|
|
414
|
+
}
|
|
415
|
+
function Me(e, t) {
|
|
416
|
+
return e.Uri.parse(t);
|
|
417
|
+
}
|
|
418
|
+
function Et({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: i, originalModelPath: o, modifiedModelPath: a, keepCurrentOriginalModel: f = !1, keepCurrentModifiedModel: s = !1, theme: v = "light", loading: y = "Loading...", options: O = {}, height: L = "100%", width: J = "100%", className: C, wrapperProps: E = {}, beforeMount: A = B, onMount: z = B }) {
|
|
419
|
+
let [j, b] = V(!1), [I, d] = V(!0), g = w(null), c = w(null), U = w(null), M = w(z), p = w(A), T = w(!1);
|
|
420
|
+
le(() => {
|
|
421
|
+
let u = te.init();
|
|
422
|
+
return u.then((h) => (c.current = h) && d(!1)).catch((h) => (h == null ? void 0 : h.type) !== "cancelation" && console.error("Monaco initialization: error:", h)), () => g.current ? W() : u.cancel();
|
|
423
|
+
}), P(() => {
|
|
424
|
+
if (g.current && c.current) {
|
|
425
|
+
let u = g.current.getOriginalEditor(), h = _(c.current, e || "", n || r || "text", o || "");
|
|
426
|
+
h !== u.getModel() && u.setModel(h);
|
|
427
|
+
}
|
|
428
|
+
}, [o], j), P(() => {
|
|
429
|
+
if (g.current && c.current) {
|
|
430
|
+
let u = g.current.getModifiedEditor(), h = _(c.current, t || "", i || r || "text", a || "");
|
|
431
|
+
h !== u.getModel() && u.setModel(h);
|
|
432
|
+
}
|
|
433
|
+
}, [a], j), P(() => {
|
|
434
|
+
let u = g.current.getModifiedEditor();
|
|
435
|
+
u.getOption(c.current.editor.EditorOption.readOnly) ? u.setValue(t || "") : t !== u.getValue() && (u.executeEdits("", [{ range: u.getModel().getFullModelRange(), text: t || "", forceMoveMarkers: !0 }]), u.pushUndoStop());
|
|
436
|
+
}, [t], j), P(() => {
|
|
437
|
+
var u, h;
|
|
438
|
+
(h = (u = g.current) == null ? void 0 : u.getModel()) == null || h.original.setValue(e || "");
|
|
439
|
+
}, [e], j), P(() => {
|
|
440
|
+
let { original: u, modified: h } = g.current.getModel();
|
|
441
|
+
c.current.editor.setModelLanguage(u, n || r || "text"), c.current.editor.setModelLanguage(h, i || r || "text");
|
|
442
|
+
}, [r, n, i], j), P(() => {
|
|
443
|
+
var u;
|
|
444
|
+
(u = c.current) == null || u.editor.setTheme(v);
|
|
445
|
+
}, [v], j), P(() => {
|
|
446
|
+
var u;
|
|
447
|
+
(u = g.current) == null || u.updateOptions(O);
|
|
448
|
+
}, [O], j);
|
|
449
|
+
let Y = ue(() => {
|
|
450
|
+
var D;
|
|
451
|
+
if (!c.current) return;
|
|
452
|
+
p.current(c.current);
|
|
453
|
+
let u = _(c.current, e || "", n || r || "text", o || ""), h = _(c.current, t || "", i || r || "text", a || "");
|
|
454
|
+
(D = g.current) == null || D.setModel({ original: u, modified: h });
|
|
455
|
+
}, [r, t, i, e, n, o, a]), Z = ue(() => {
|
|
456
|
+
var u;
|
|
457
|
+
!T.current && U.current && (g.current = c.current.editor.createDiffEditor(U.current, { automaticLayout: !0, ...O }), Y(), (u = c.current) == null || u.editor.setTheme(v), b(!0), T.current = !0);
|
|
458
|
+
}, [O, v, Y]);
|
|
459
|
+
$(() => {
|
|
460
|
+
j && M.current(g.current, c.current);
|
|
461
|
+
}, [j]), $(() => {
|
|
462
|
+
!I && !j && Z();
|
|
463
|
+
}, [I, j, Z]);
|
|
464
|
+
function W() {
|
|
465
|
+
var h, D, R, F;
|
|
466
|
+
let u = (h = g.current) == null ? void 0 : h.getModel();
|
|
467
|
+
f || ((D = u == null ? void 0 : u.original) == null || D.dispose()), s || ((R = u == null ? void 0 : u.modified) == null || R.dispose()), (F = g.current) == null || F.dispose();
|
|
468
|
+
}
|
|
469
|
+
return q.createElement(je, { width: J, height: L, isEditorReady: j, loading: y, _ref: U, className: C, wrapperProps: E });
|
|
470
|
+
}
|
|
471
|
+
var It = Et;
|
|
472
|
+
ce(It);
|
|
473
|
+
function Ct() {
|
|
474
|
+
let [e, t] = V(te.__getMonacoInstance());
|
|
475
|
+
return le(() => {
|
|
476
|
+
let r;
|
|
477
|
+
return e || (r = te.init(), r.then((n) => {
|
|
478
|
+
t(n);
|
|
479
|
+
})), () => r == null ? void 0 : r.cancel();
|
|
480
|
+
}), e;
|
|
481
|
+
}
|
|
482
|
+
var $t = Ct;
|
|
483
|
+
function Lt(e) {
|
|
484
|
+
let t = w();
|
|
485
|
+
return $(() => {
|
|
486
|
+
t.current = e;
|
|
487
|
+
}, [e]), t.current;
|
|
488
|
+
}
|
|
489
|
+
var At = Lt, X = /* @__PURE__ */ new Map();
|
|
490
|
+
function Dt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: i, path: o, theme: a = "light", line: f, loading: s = "Loading...", options: v = {}, overrideServices: y = {}, saveViewState: O = !0, keepCurrentModel: L = !1, width: J = "100%", height: C = "100%", className: E, wrapperProps: A = {}, beforeMount: z = B, onMount: j = B, onChange: b, onValidate: I = B }) {
|
|
491
|
+
let [d, g] = V(!1), [c, U] = V(!0), M = w(null), p = w(null), T = w(null), Y = w(j), Z = w(z), W = w(), u = w(n), h = At(o), D = w(!1), R = w(!1);
|
|
492
|
+
le(() => {
|
|
493
|
+
let l = te.init();
|
|
494
|
+
return l.then((m) => (M.current = m) && U(!1)).catch((m) => (m == null ? void 0 : m.type) !== "cancelation" && console.error("Monaco initialization: error:", m)), () => p.current ? Pe() : l.cancel();
|
|
495
|
+
}), P(() => {
|
|
496
|
+
var m, S, k, N;
|
|
497
|
+
let l = _(M.current, e || n || "", t || i || "", o || r || "");
|
|
498
|
+
l !== ((m = p.current) == null ? void 0 : m.getModel()) && (O && X.set(h, (S = p.current) == null ? void 0 : S.saveViewState()), (k = p.current) == null || k.setModel(l), O && ((N = p.current) == null || N.restoreViewState(X.get(o))));
|
|
499
|
+
}, [o], d), P(() => {
|
|
500
|
+
var l;
|
|
501
|
+
(l = p.current) == null || l.updateOptions(v);
|
|
502
|
+
}, [v], d), P(() => {
|
|
503
|
+
!p.current || n === void 0 || (p.current.getOption(M.current.editor.EditorOption.readOnly) ? p.current.setValue(n) : n !== p.current.getValue() && (R.current = !0, p.current.executeEdits("", [{ range: p.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), p.current.pushUndoStop(), R.current = !1));
|
|
504
|
+
}, [n], d), P(() => {
|
|
505
|
+
var m, S;
|
|
506
|
+
let l = (m = p.current) == null ? void 0 : m.getModel();
|
|
507
|
+
l && i && ((S = M.current) == null || S.editor.setModelLanguage(l, i));
|
|
508
|
+
}, [i], d), P(() => {
|
|
509
|
+
var l;
|
|
510
|
+
f !== void 0 && ((l = p.current) == null || l.revealLine(f));
|
|
511
|
+
}, [f], d), P(() => {
|
|
512
|
+
var l;
|
|
513
|
+
(l = M.current) == null || l.editor.setTheme(a);
|
|
514
|
+
}, [a], d);
|
|
515
|
+
let F = ue(() => {
|
|
516
|
+
var l;
|
|
517
|
+
if (!(!T.current || !M.current) && !D.current) {
|
|
518
|
+
Z.current(M.current);
|
|
519
|
+
let m = o || r, S = _(M.current, n || e || "", t || i || "", m || "");
|
|
520
|
+
p.current = (l = M.current) == null ? void 0 : l.editor.create(T.current, { model: S, automaticLayout: !0, ...v }, y), O && p.current.restoreViewState(X.get(m)), M.current.editor.setTheme(a), f !== void 0 && p.current.revealLine(f), g(!0), D.current = !0;
|
|
521
|
+
}
|
|
522
|
+
}, [e, t, r, n, i, o, v, y, O, a, f]);
|
|
523
|
+
$(() => {
|
|
524
|
+
d && Y.current(p.current, M.current);
|
|
525
|
+
}, [d]), $(() => {
|
|
526
|
+
!c && !d && F();
|
|
527
|
+
}, [c, d, F]), u.current = n, $(() => {
|
|
528
|
+
var l, m;
|
|
529
|
+
d && b && ((l = W.current) == null || l.dispose(), W.current = (m = p.current) == null ? void 0 : m.onDidChangeModelContent((S) => {
|
|
530
|
+
R.current || b(p.current.getValue(), S);
|
|
531
|
+
}));
|
|
532
|
+
}, [d, b]), $(() => {
|
|
533
|
+
if (d) {
|
|
534
|
+
let l = M.current.editor.onDidChangeMarkers((m) => {
|
|
535
|
+
var k;
|
|
536
|
+
let S = (k = p.current.getModel()) == null ? void 0 : k.uri;
|
|
537
|
+
if (S && m.find((N) => N.path === S.path)) {
|
|
538
|
+
let N = M.current.editor.getModelMarkers({ resource: S });
|
|
539
|
+
I == null || I(N);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
return () => {
|
|
543
|
+
l == null || l.dispose();
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
return () => {
|
|
547
|
+
};
|
|
548
|
+
}, [d, I]);
|
|
549
|
+
function Pe() {
|
|
550
|
+
var l, m;
|
|
551
|
+
(l = W.current) == null || l.dispose(), L ? O && X.set(o, p.current.saveViewState()) : (m = p.current.getModel()) == null || m.dispose(), p.current.dispose();
|
|
552
|
+
}
|
|
553
|
+
return q.createElement(je, { width: J, height: C, isEditorReady: d, loading: s, _ref: T, className: E, wrapperProps: A });
|
|
554
|
+
}
|
|
555
|
+
var xt = Dt, Tt = ce(xt), Rt = Tt;
|
|
556
|
+
const Nt = /* @__PURE__ */ (() => {
|
|
557
|
+
let e;
|
|
558
|
+
return async () => (e != null || (e = await fetch("https://core.commercelayer.io/api/public/resources").then(async (t) => await t.json()).then(
|
|
559
|
+
({ data: t }) => t.reduce((r, n, i, o) => ({
|
|
560
|
+
...r,
|
|
561
|
+
[n.id]: {
|
|
562
|
+
fields: Object.entries(n.attributes.fields).filter(([a]) => !a.startsWith("_")),
|
|
563
|
+
relationships: Object.entries(n.attributes.relationships).filter(([a]) => !a.startsWith("_")).filter(
|
|
564
|
+
([, a]) => t.find(
|
|
565
|
+
(f) => f.id === Se(a.class_name)
|
|
566
|
+
) != null
|
|
567
|
+
)
|
|
568
|
+
}
|
|
569
|
+
}), {})
|
|
570
|
+
).catch((t) => {
|
|
571
|
+
throw t;
|
|
572
|
+
})), e);
|
|
573
|
+
})();
|
|
574
|
+
async function _t(e, t) {
|
|
575
|
+
var i, o;
|
|
576
|
+
if (!new RegExp(`^(${e.join("|")})(.|$)`).test(t))
|
|
577
|
+
return e.map((a) => ({
|
|
578
|
+
value: a,
|
|
579
|
+
type: "relationship"
|
|
580
|
+
}));
|
|
581
|
+
const r = await qt(t);
|
|
582
|
+
return [].concat(
|
|
583
|
+
((i = r.obj) == null ? void 0 : i.fields.map(([a]) => ({
|
|
584
|
+
value: `${r.path}.${a}`,
|
|
585
|
+
type: "field"
|
|
586
|
+
}))) ?? []
|
|
587
|
+
).concat(
|
|
588
|
+
((o = r.obj) == null ? void 0 : o.relationships.map(([a]) => ({
|
|
589
|
+
value: `${r.path}.${a}`,
|
|
590
|
+
type: "relationship"
|
|
591
|
+
}))) ?? []
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
async function qt(e, t) {
|
|
595
|
+
const r = await Nt(), n = e.replace(/\.$/, "").split("."), i = n.shift();
|
|
596
|
+
return t ?? (t = r[i ?? ""]), n.reduce(
|
|
597
|
+
(o, a) => {
|
|
598
|
+
var v, y;
|
|
599
|
+
const f = (y = (v = o.obj) == null ? void 0 : v.relationships.find(
|
|
600
|
+
([O]) => O === a
|
|
601
|
+
)) == null ? void 0 : y[1].class_name;
|
|
602
|
+
if (f == null)
|
|
603
|
+
return o;
|
|
604
|
+
const s = r[Se(f)];
|
|
605
|
+
return s == null ? o : {
|
|
606
|
+
path: `${o.path == null ? "" : `${o.path}.`}${a}`,
|
|
607
|
+
obj: s
|
|
608
|
+
};
|
|
609
|
+
},
|
|
610
|
+
{ path: t != null ? i ?? "" : "", obj: t }
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
function Se(e) {
|
|
614
|
+
return e.replace(/([A-Z])/g, "_$1").replace(/^_/, "").toLowerCase();
|
|
615
|
+
}
|
|
616
|
+
const Vt = Ut(500), zt = Ie(
|
|
617
|
+
({
|
|
618
|
+
feedback: e,
|
|
619
|
+
hint: t,
|
|
620
|
+
inline: r,
|
|
621
|
+
label: n,
|
|
622
|
+
defaultValue: i,
|
|
623
|
+
value: o,
|
|
624
|
+
language: a = "plaintext",
|
|
625
|
+
height: f = "220px",
|
|
626
|
+
jsonSchema: s = "none",
|
|
627
|
+
onValidate: v,
|
|
628
|
+
onValid: y,
|
|
629
|
+
onChange: O,
|
|
630
|
+
...L
|
|
631
|
+
}, J) => {
|
|
632
|
+
const C = $t(), E = w(), [A, z] = V(null), j = (b, I) => {
|
|
633
|
+
z(b), b.onDidPaste(() => {
|
|
634
|
+
var d;
|
|
635
|
+
(d = b.getAction("editor.action.formatDocument")) == null || d.run();
|
|
636
|
+
}), b.onDidChangeModelDecorations(() => {
|
|
637
|
+
const d = b.getModel(), g = I.editor.getModelMarkers({
|
|
638
|
+
resource: d == null ? void 0 : d.uri
|
|
639
|
+
}), c = b.getValue();
|
|
640
|
+
Vt(() => {
|
|
641
|
+
v == null || v(g.length > 0 ? g : null), O == null || O(c), g.length === 0 && (y == null || y(c));
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
return $(() => (async function() {
|
|
646
|
+
var I, d;
|
|
647
|
+
const b = (I = A == null ? void 0 : A.getModel()) == null ? void 0 : I.uri.toString();
|
|
648
|
+
if (C != null && b != null && s != null) {
|
|
649
|
+
(d = E.current) == null || d.call(E);
|
|
650
|
+
const g = C.languages.json.jsonDefaults.diagnosticsOptions.schemas ?? [];
|
|
651
|
+
switch (s) {
|
|
652
|
+
case "none":
|
|
653
|
+
break;
|
|
654
|
+
case "order-rules": {
|
|
655
|
+
g.push({
|
|
656
|
+
schema: await fetch(
|
|
657
|
+
"https://core.commercelayer.io/api/public/schemas/order_rules"
|
|
658
|
+
).then(async (c) => await c.json()).then((c) => re(c)),
|
|
659
|
+
uri: `file:///json-schema--${s}.json`,
|
|
660
|
+
fileMatch: [b]
|
|
661
|
+
}), E.current = ve(C, b, ["order"]);
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
case "price-rules": {
|
|
665
|
+
g.push({
|
|
666
|
+
schema: await fetch(
|
|
667
|
+
"https://core.commercelayer.io/api/public/schemas/price_rules"
|
|
668
|
+
).then(async (c) => await c.json()).then((c) => re(c)),
|
|
669
|
+
uri: `file:///json-schema--${s}.json`,
|
|
670
|
+
fileMatch: [b]
|
|
671
|
+
}), E.current = ve(C, b, ["price"]);
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
C.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
676
|
+
enableSchemaRequest: !0,
|
|
677
|
+
schemaRequest: "ignore",
|
|
678
|
+
schemaValidation: "error",
|
|
679
|
+
validate: !0,
|
|
680
|
+
schemas: g
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
}(), () => {
|
|
684
|
+
var b;
|
|
685
|
+
(b = E.current) == null || b.call(E);
|
|
686
|
+
}), [C, A, s]), /* @__PURE__ */ se.jsx(
|
|
687
|
+
Ee,
|
|
688
|
+
{
|
|
689
|
+
label: n,
|
|
690
|
+
hint: t,
|
|
691
|
+
feedback: e,
|
|
692
|
+
name: L.id ?? L.name,
|
|
693
|
+
inline: r,
|
|
694
|
+
children: /* @__PURE__ */ se.jsx(
|
|
695
|
+
Rt,
|
|
696
|
+
{
|
|
697
|
+
defaultPath: L.id ?? L.name,
|
|
698
|
+
className: "[&>.monaco-editor]:rounded [&>.monaco-editor>.overflow-guard]:rounded",
|
|
699
|
+
theme: "vs-dark",
|
|
700
|
+
language: a,
|
|
701
|
+
height: f,
|
|
702
|
+
defaultValue: i,
|
|
703
|
+
value: o,
|
|
704
|
+
onMount: j,
|
|
705
|
+
options: {
|
|
706
|
+
quickSuggestions: !0,
|
|
707
|
+
readOnly: !1,
|
|
708
|
+
automaticLayout: !0,
|
|
709
|
+
insertSpaces: !0,
|
|
710
|
+
tabSize: 2,
|
|
711
|
+
lineNumbers: "on",
|
|
712
|
+
padding: { top: 18, bottom: 18 },
|
|
713
|
+
scrollBeyondLastLine: !1,
|
|
714
|
+
pasteAs: { enabled: !0 },
|
|
715
|
+
minimap: {
|
|
716
|
+
enabled: !1
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
)
|
|
721
|
+
}
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
);
|
|
725
|
+
zt.displayName = "CodeEditor";
|
|
726
|
+
function Ut(e = 100) {
|
|
727
|
+
let t = null;
|
|
728
|
+
return function(n) {
|
|
729
|
+
t !== null && clearTimeout(t), t = setTimeout(() => {
|
|
730
|
+
n(), t = null;
|
|
731
|
+
}, e);
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
function re(e, t) {
|
|
735
|
+
return typeof e != "object" || e === null ? e : Array.isArray(e) ? e.map((r) => re(r)) : Object.entries(e).reduce((r, [n, i]) => t !== "properties" && ["examples", "default"].includes(n) ? r : {
|
|
736
|
+
...r,
|
|
737
|
+
[n]: re(i, n)
|
|
738
|
+
}, {});
|
|
739
|
+
}
|
|
740
|
+
function ve(e, t, r) {
|
|
741
|
+
return e.languages.registerCompletionItemProvider("json", {
|
|
742
|
+
triggerCharacters: ['"', ":", "."],
|
|
743
|
+
provideCompletionItems: async function(n, i) {
|
|
744
|
+
if (n.uri.toString() !== t.toString())
|
|
745
|
+
return {
|
|
746
|
+
suggestions: []
|
|
747
|
+
};
|
|
748
|
+
const o = n.getWordUntilPosition(i), a = n.getLineContent(i.lineNumber).substring(0, i.column - 1);
|
|
749
|
+
if (/"(field|selector)"\s*:\s*"[^"]*$/.test(a)) {
|
|
750
|
+
const s = o.word;
|
|
751
|
+
if (s != null)
|
|
752
|
+
return {
|
|
753
|
+
incomplete: !1,
|
|
754
|
+
suggestions: (await _t(
|
|
755
|
+
r,
|
|
756
|
+
s
|
|
757
|
+
)).map((y) => ({
|
|
758
|
+
kind: y.type === "relationship" ? e.languages.CompletionItemKind.Module : e.languages.CompletionItemKind.Value,
|
|
759
|
+
label: y.value,
|
|
760
|
+
insertText: y.value,
|
|
761
|
+
// documentation: `Field: ${suggestion}`,
|
|
762
|
+
range: {
|
|
763
|
+
startLineNumber: i.lineNumber,
|
|
764
|
+
startColumn: o.startColumn,
|
|
765
|
+
endLineNumber: i.lineNumber,
|
|
766
|
+
endColumn: o.endColumn
|
|
767
|
+
}
|
|
768
|
+
}))
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
suggestions: []
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
}).dispose = () => {
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
export {
|
|
779
|
+
zt as CodeEditor
|
|
780
|
+
};
|