@orangelogic/myos-gen1 1.0.0-alpha.6 → 1.0.0-alpha.8
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/{autocomplete-R6DME2OB.js → autocomplete-TWBUFBPK.js} +1 -1
- package/dist/{chunk-66SV6MPF.js → chunk-F6THHPXZ.js} +114 -106
- package/dist/{date-HIILR4IG.js → date-MILP7DAY.js} +1 -1
- package/dist/{menu-WZ4WC2IN.js → menu-DLZOBFXB.js} +1 -1
- package/dist/{rich-text-S76EGP2P.js → rich-text-EFOTPYBP.js} +1 -1
- package/dist/runtime/index.d.ts +19 -4
- package/dist/runtime/index.js +82 -52
- package/dist/runtime/lazy-renderers.d.ts +20 -4
- package/dist/runtime/mount.d.ts +2 -1
- package/dist/runtime/renderer-families.json +8 -8
- package/dist/runtime/renderer-loaders.d.ts +2 -2
- package/dist/runtime/runtime-instance.d.ts +29 -0
- package/dist/{select-D5QBUQE6.js → select-GAAOKMWC.js} +1 -1
- package/dist/{tab-menu-PBUFHDEE.js → tab-menu-AIXU7FUG.js} +1 -1
- package/dist/{webcomponent-5RFJIIY6.js → webcomponent-GL3RN3YI.js} +1 -1
- package/dist/{widgets-7MLUBX4G.js → widgets-JZWFRF3E.js} +1 -1
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-BTZWYDJT.js";
|
|
7
7
|
|
|
8
8
|
// packages/gen1/src/runtime/lazy-renderers.tsx
|
|
9
|
-
import { useEffect, useReducer, useState } from "react";
|
|
9
|
+
import { createContext, useContext, useEffect, useReducer, useState } from "react";
|
|
10
10
|
|
|
11
11
|
// packages/gen1/src/runtime/renderer-families.json
|
|
12
12
|
var renderer_families_default = {
|
|
@@ -27,10 +27,36 @@ var renderer_families_default = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// packages/gen1/src/runtime/lazy-renderers.tsx
|
|
30
|
-
|
|
31
|
-
function
|
|
32
|
-
|
|
30
|
+
import { jsx } from "react/jsx-runtime";
|
|
31
|
+
function createRendererRegistry(loaders) {
|
|
32
|
+
const loaded = /* @__PURE__ */ new Map();
|
|
33
|
+
const pending = /* @__PURE__ */ new Map();
|
|
34
|
+
function load(name) {
|
|
35
|
+
let promise = pending.get(name);
|
|
36
|
+
if (!promise) {
|
|
37
|
+
promise = Promise.resolve().then(() => loaders[name]()).then((module) => {
|
|
38
|
+
loaded.set(name, module);
|
|
39
|
+
return module;
|
|
40
|
+
}, (error) => {
|
|
41
|
+
pending.delete(name);
|
|
42
|
+
throw error;
|
|
43
|
+
});
|
|
44
|
+
pending.set(name, promise);
|
|
45
|
+
}
|
|
46
|
+
return promise;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
get(name) {
|
|
50
|
+
return loaded.get(name);
|
|
51
|
+
},
|
|
52
|
+
load,
|
|
53
|
+
/** Loads this runtime's families in parallel; rejects when any fails to load. */
|
|
54
|
+
async loadRendererFamilies(names = rendererFamilyNames) {
|
|
55
|
+
await Promise.all(names.map((name) => load(name)));
|
|
56
|
+
}
|
|
57
|
+
};
|
|
33
58
|
}
|
|
59
|
+
var RendererRegistryContext = createContext(void 0);
|
|
34
60
|
var rendererFamilyNames = Object.freeze(Object.keys(renderer_families_default.families));
|
|
35
61
|
var families = renderer_families_default.families;
|
|
36
62
|
var field = (value, name) => Boolean(value[name]);
|
|
@@ -55,37 +81,19 @@ function rendererFamiliesOf(unit) {
|
|
|
55
81
|
visitUnit(unit);
|
|
56
82
|
return rendererFamilyNames.filter((name) => found.has(name));
|
|
57
83
|
}
|
|
58
|
-
var loaded = /* @__PURE__ */ new Map();
|
|
59
|
-
var pending = /* @__PURE__ */ new Map();
|
|
60
|
-
function load(name) {
|
|
61
|
-
let promise = pending.get(name);
|
|
62
|
-
if (!promise) {
|
|
63
|
-
const loader = loaders?.[name];
|
|
64
|
-
promise = (loader ? loader() : Promise.reject(Error("Gen1 renderer loaders are not registered"))).then(
|
|
65
|
-
(module) => {
|
|
66
|
-
loaded.set(name, module);
|
|
67
|
-
return module;
|
|
68
|
-
},
|
|
69
|
-
(error) => {
|
|
70
|
-
pending.delete(name);
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
pending.set(name, promise);
|
|
75
|
-
}
|
|
76
|
-
return promise;
|
|
77
|
-
}
|
|
78
|
-
async function loadRendererFamilies(names = rendererFamilyNames) {
|
|
79
|
-
await Promise.all(names.map((name) => load(name)));
|
|
80
|
-
}
|
|
81
84
|
function Deferred({ family, render, fallback }) {
|
|
82
|
-
const
|
|
85
|
+
const registry = useContext(RendererRegistryContext);
|
|
86
|
+
if (!registry) throw Error("Gen1 renderer registry is missing");
|
|
87
|
+
return /* @__PURE__ */ jsx(DeferredFamily, { registry, family, render, fallback }, family);
|
|
88
|
+
}
|
|
89
|
+
function DeferredFamily({ registry, family, render, fallback }) {
|
|
90
|
+
const module = registry.get(family);
|
|
83
91
|
const [failed, setFailed] = useState(false);
|
|
84
92
|
const [, arrived] = useReducer((count) => count + 1, 0);
|
|
85
93
|
useEffect(() => {
|
|
86
94
|
if (module || failed) return;
|
|
87
95
|
let live = true;
|
|
88
|
-
load(family).then(() => {
|
|
96
|
+
registry.load(family).then(() => {
|
|
89
97
|
if (live) arrived();
|
|
90
98
|
}, () => {
|
|
91
99
|
if (live) setFailed(true);
|
|
@@ -93,7 +101,7 @@ function Deferred({ family, render, fallback }) {
|
|
|
93
101
|
return () => {
|
|
94
102
|
live = false;
|
|
95
103
|
};
|
|
96
|
-
}, [family, module, failed]);
|
|
104
|
+
}, [registry, family, module, failed]);
|
|
97
105
|
return module ? render(module) : failed ? fallback() : null;
|
|
98
106
|
}
|
|
99
107
|
|
|
@@ -113,9 +121,9 @@ import { CxTypography as CxTypography2 } from "@orangelogic/design-system-react/
|
|
|
113
121
|
import { CxTooltip as CxTooltip2 } from "@orangelogic/design-system-react/tooltip";
|
|
114
122
|
|
|
115
123
|
// packages/gen1/src/runtime/extended-events.tsx
|
|
116
|
-
import { useContext, useEffect as useEffect2, useRef } from "react";
|
|
124
|
+
import { useContext as useContext2, useEffect as useEffect2, useRef } from "react";
|
|
117
125
|
import { CxTooltip } from "@orangelogic/design-system-react/tooltip";
|
|
118
|
-
import { jsx } from "react/jsx-runtime";
|
|
126
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
119
127
|
var basicEvents = {
|
|
120
128
|
over: "mouseover",
|
|
121
129
|
out: "mouseout",
|
|
@@ -130,7 +138,7 @@ function hasExtendedEvents(triggers) {
|
|
|
130
138
|
}
|
|
131
139
|
function EventBoundary({ control, unit, host, children }) {
|
|
132
140
|
const root = useRef(null);
|
|
133
|
-
const store =
|
|
141
|
+
const store = useContext2(UnitStoreContext);
|
|
134
142
|
const triggers = unit.triggers[control.id];
|
|
135
143
|
const disabled = control.disabled || control.readOnly;
|
|
136
144
|
useEffect2(() => {
|
|
@@ -255,13 +263,13 @@ function EventBoundary({ control, unit, host, children }) {
|
|
|
255
263
|
cancelTimers();
|
|
256
264
|
};
|
|
257
265
|
}, [control, unit, host, triggers, disabled, store]);
|
|
258
|
-
const content = /* @__PURE__ */
|
|
266
|
+
const content = /* @__PURE__ */ jsx2("span", { ref: root, style: { display: "contents" }, children });
|
|
259
267
|
if (!triggers?.some((trigger) => trigger === "tooltipShown" || trigger === "tooltipMasked")) return content;
|
|
260
268
|
const title = control.tooltip || control.description || "";
|
|
261
|
-
return /* @__PURE__ */
|
|
269
|
+
return /* @__PURE__ */ jsx2(
|
|
262
270
|
CxTooltip,
|
|
263
271
|
{
|
|
264
|
-
content: control.html ? /* @__PURE__ */
|
|
272
|
+
content: control.html ? /* @__PURE__ */ jsx2("span", { dangerouslySetInnerHTML: { __html: title } }) : title,
|
|
265
273
|
disabled: disabled || !title,
|
|
266
274
|
hoist: true,
|
|
267
275
|
onShow: () => {
|
|
@@ -294,7 +302,7 @@ import { useCallback, useSyncExternalStore } from "react";
|
|
|
294
302
|
import { CxBox } from "@orangelogic/design-system-react/box";
|
|
295
303
|
import { CxButton } from "@orangelogic/design-system-react/button";
|
|
296
304
|
import { CxTypography } from "@orangelogic/design-system-react/typography";
|
|
297
|
-
import { jsx as
|
|
305
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
298
306
|
function ParameterEditorView({ control, unit, ctx }) {
|
|
299
307
|
const subscribe = useCallback((notify) => ctx.host.subscribe(ctx.host.unitId, notify), [ctx.host]);
|
|
300
308
|
const snapshot = useCallback(() => ctx.host.getParameterReset?.(unit.id, control.id) ?? false, [ctx.host, unit.id, control.id]);
|
|
@@ -303,21 +311,21 @@ function ParameterEditorView({ control, unit, ctx }) {
|
|
|
303
311
|
const disabled = control.disabled || control.readOnly;
|
|
304
312
|
const actions = unit.triggers[control.id] ?? [];
|
|
305
313
|
return /* @__PURE__ */ jsxs(CxBox, { className: "uic-parameter", "data-parameter-reset": reset || void 0, children: [
|
|
306
|
-
!parameter.hideInput && /* @__PURE__ */
|
|
307
|
-
parameter.hideInput && /* @__PURE__ */
|
|
308
|
-
parameter.info && /* @__PURE__ */
|
|
309
|
-
parameter.comment && /* @__PURE__ */
|
|
314
|
+
!parameter.hideInput && /* @__PURE__ */ jsx3(ControlView, { control: { ...control, parameter: void 0, readOnly: control.readOnly || parameter.readOnly }, unit, ctx }),
|
|
315
|
+
parameter.hideInput && /* @__PURE__ */ jsx3(CxTypography, { children: /* @__PURE__ */ jsx3(Text, { value: control.label, html: control.html }) }),
|
|
316
|
+
parameter.info && /* @__PURE__ */ jsx3(CxTypography, { children: /* @__PURE__ */ jsx3(Text, { value: parameter.info, html: true }) }),
|
|
317
|
+
parameter.comment && /* @__PURE__ */ jsx3(
|
|
310
318
|
CxButton,
|
|
311
319
|
{
|
|
312
320
|
variant: "text",
|
|
313
321
|
disabled,
|
|
314
322
|
"data-control-id": control.id,
|
|
315
323
|
onClick: () => ctx.host.fire(unit.id, control.id, "parameter-details"),
|
|
316
|
-
children: /* @__PURE__ */
|
|
324
|
+
children: /* @__PURE__ */ jsx3(Text, { value: parameter.comment, html: true })
|
|
317
325
|
}
|
|
318
326
|
),
|
|
319
327
|
/* @__PURE__ */ jsxs(CxBox, { children: [
|
|
320
|
-
parameter.detailsLabel !== void 0 && actions.includes("parameter-details") && /* @__PURE__ */
|
|
328
|
+
parameter.detailsLabel !== void 0 && actions.includes("parameter-details") && /* @__PURE__ */ jsx3(
|
|
321
329
|
CxButton,
|
|
322
330
|
{
|
|
323
331
|
variant: "text",
|
|
@@ -327,7 +335,7 @@ function ParameterEditorView({ control, unit, ctx }) {
|
|
|
327
335
|
children: parameter.detailsLabel
|
|
328
336
|
}
|
|
329
337
|
),
|
|
330
|
-
parameter.resolveLabel !== void 0 && actions.includes("parameter-resolve") && /* @__PURE__ */
|
|
338
|
+
parameter.resolveLabel !== void 0 && actions.includes("parameter-resolve") && /* @__PURE__ */ jsx3(
|
|
331
339
|
CxButton,
|
|
332
340
|
{
|
|
333
341
|
variant: "text",
|
|
@@ -337,7 +345,7 @@ function ParameterEditorView({ control, unit, ctx }) {
|
|
|
337
345
|
children: parameter.resolveLabel
|
|
338
346
|
}
|
|
339
347
|
),
|
|
340
|
-
parameter.resetLabel !== void 0 && actions.includes("parameter-reset") && /* @__PURE__ */
|
|
348
|
+
parameter.resetLabel !== void 0 && actions.includes("parameter-reset") && /* @__PURE__ */ jsx3(
|
|
341
349
|
CxButton,
|
|
342
350
|
{
|
|
343
351
|
variant: reset ? "primary" : "text",
|
|
@@ -372,7 +380,7 @@ import { CxProgressBar } from "@orangelogic/design-system-react/progress-bar";
|
|
|
372
380
|
// packages/gen1/src/runtime/free-html.tsx
|
|
373
381
|
import { useLayoutEffect, useRef as useRef2, useState as useState2 } from "react";
|
|
374
382
|
import { createPortal } from "react-dom";
|
|
375
|
-
import { jsx as
|
|
383
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
376
384
|
function FreeHtmlView({ control, unit, ctx }) {
|
|
377
385
|
const surface = useRef2(null);
|
|
378
386
|
const markup = useRef2(null);
|
|
@@ -398,8 +406,8 @@ function FreeHtmlView({ control, unit, ctx }) {
|
|
|
398
406
|
"aria-disabled": control.disabled || control.readOnly || void 0,
|
|
399
407
|
inert: control.disabled || control.readOnly || void 0,
|
|
400
408
|
children: [
|
|
401
|
-
control.css && /* @__PURE__ */
|
|
402
|
-
/* @__PURE__ */
|
|
409
|
+
control.css && /* @__PURE__ */ jsx4("style", { children: control.css }),
|
|
410
|
+
/* @__PURE__ */ jsx4("div", { ref: markup, dangerouslySetInnerHTML: { __html: control.markup } }),
|
|
403
411
|
control.items?.map((child) => {
|
|
404
412
|
const target = targets.get(child.id);
|
|
405
413
|
return target ? createPortal(ctx.renderUnit(child, ctx), target, child.id) : null;
|
|
@@ -410,18 +418,18 @@ function FreeHtmlView({ control, unit, ctx }) {
|
|
|
410
418
|
}
|
|
411
419
|
|
|
412
420
|
// packages/gen1/src/runtime/controls.tsx
|
|
413
|
-
import { Fragment as Fragment2, jsx as
|
|
421
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
414
422
|
function iconName(icon, fallback = "") {
|
|
415
423
|
const name = (icon ?? "").split(/\s+/).filter((token) => token && !/^fa-(lg|xs|sm|[1-9]x|fw)$/i.test(token)).join(" ");
|
|
416
424
|
return name || fallback;
|
|
417
425
|
}
|
|
418
426
|
function Text({ value, html }) {
|
|
419
427
|
if (!value) return null;
|
|
420
|
-
return html ? /* @__PURE__ */
|
|
428
|
+
return html ? /* @__PURE__ */ jsx5("span", { dangerouslySetInnerHTML: { __html: value } }) : /* @__PURE__ */ jsx5(Fragment2, { children: value });
|
|
421
429
|
}
|
|
422
430
|
var Items = memo(function Items2({ items, unit, ctx }) {
|
|
423
|
-
if (unit.contextMenu && items === unit.view) return /* @__PURE__ */
|
|
424
|
-
return /* @__PURE__ */
|
|
431
|
+
if (unit.contextMenu && items === unit.view) return /* @__PURE__ */ jsx5(Deferred, { family: "menu", render: (m) => /* @__PURE__ */ jsx5(m.ContextMenu, { items, unit, host: ctx.host }), fallback: () => null });
|
|
432
|
+
return /* @__PURE__ */ jsx5(Fragment2, { children: items.map((item) => isUnit(item) ? /* @__PURE__ */ jsx5(Fragment, { children: ctx.renderUnit(item, ctx) }, item.id) : isDropdownPanel(unit, item.id) ? null : /* @__PURE__ */ jsx5(ControlView, { control: item, unit, ctx }, item.id)) });
|
|
425
433
|
});
|
|
426
434
|
function activate(control, unit, ctx, event) {
|
|
427
435
|
if (control.disabled || control.readOnly) {
|
|
@@ -462,9 +470,9 @@ function Group({ control, unit, ctx }) {
|
|
|
462
470
|
useEffect3(() => {
|
|
463
471
|
sent.current = false;
|
|
464
472
|
}, [control, unit.triggers[control.id]]);
|
|
465
|
-
return /* @__PURE__ */
|
|
473
|
+
return /* @__PURE__ */ jsx5(DismissBoundary, { disabled: inactive, onOutside: (event) => {
|
|
466
474
|
if (!sent.current) sent.current = ctx.host.fire(unit.id, control.id, "clickOut", { domEvent: event });
|
|
467
|
-
}, children: /* @__PURE__ */
|
|
475
|
+
}, children: /* @__PURE__ */ jsx5(
|
|
468
476
|
CxBox2,
|
|
469
477
|
{
|
|
470
478
|
className: `uic-group uic-group--${control.id}`,
|
|
@@ -491,31 +499,31 @@ function Group({ control, unit, ctx }) {
|
|
|
491
499
|
event.stopPropagation();
|
|
492
500
|
ctx.host.fire(unit.id, control.id, "click", { domEvent: event.nativeEvent });
|
|
493
501
|
},
|
|
494
|
-
children: foldOpen !== void 0 ? /* @__PURE__ */
|
|
502
|
+
children: foldOpen !== void 0 ? /* @__PURE__ */ jsx5(
|
|
495
503
|
CxDetails,
|
|
496
504
|
{
|
|
497
505
|
open: foldOpen,
|
|
498
506
|
disabled: control.disabled || control.readOnly,
|
|
499
507
|
"data-control-id": control.id,
|
|
500
508
|
rootProps: { className: "uic-fold" },
|
|
501
|
-
summary: /* @__PURE__ */
|
|
509
|
+
summary: /* @__PURE__ */ jsx5(Text, { value: !foldOpen && control.closedLabel ? control.closedLabel : control.label, html: control.html }),
|
|
502
510
|
onOpenChange: (detail) => {
|
|
503
511
|
if (detail.value === foldOpen || detail.reason === "prop") return;
|
|
504
512
|
setFoldOpen(detail.value);
|
|
505
513
|
const trigger = detail.value ? "openFold" : "closeFold";
|
|
506
514
|
if (unit.triggers[control.id]?.includes(trigger)) ctx.host.fire(unit.id, control.id, trigger);
|
|
507
515
|
},
|
|
508
|
-
children: /* @__PURE__ */
|
|
516
|
+
children: /* @__PURE__ */ jsx5(Items, { items: control.disabled || control.readOnly ? control.items.map((item) => isUnit(item) ? item : { ...item, disabled: true }) : control.items, unit, ctx })
|
|
509
517
|
}
|
|
510
518
|
) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
511
|
-
control.label && /* @__PURE__ */
|
|
512
|
-
/* @__PURE__ */
|
|
519
|
+
control.label && /* @__PURE__ */ jsx5(CxTypography2, { variant: "h6", children: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }) }),
|
|
520
|
+
/* @__PURE__ */ jsx5(Items, { items: control.disabled || control.readOnly ? control.items.map((item) => isUnit(item) ? item : { ...item, disabled: true }) : control.items, unit, ctx })
|
|
513
521
|
] })
|
|
514
522
|
}
|
|
515
523
|
) });
|
|
516
524
|
}
|
|
517
525
|
var ControlView = memo(function ControlView2({ control, unit, ctx }) {
|
|
518
|
-
return hasExtendedEvents(unit.triggers[control.id]) ? /* @__PURE__ */
|
|
526
|
+
return hasExtendedEvents(unit.triggers[control.id]) ? /* @__PURE__ */ jsx5(EventBoundary, { control, unit, host: ctx.host, children: /* @__PURE__ */ jsx5(ControlBody, { control, unit, ctx }) }) : /* @__PURE__ */ jsx5(ControlBody, { control, unit, ctx });
|
|
519
527
|
});
|
|
520
528
|
var ControlBody = memo(function ControlBody2({ control, unit, ctx }) {
|
|
521
529
|
const fire = useFire(ctx.host, unit.id, unit.triggers);
|
|
@@ -526,27 +534,27 @@ var ControlBody = memo(function ControlBody2({ control, unit, ctx }) {
|
|
|
526
534
|
onMouseEnter: () => setHovered(true),
|
|
527
535
|
onMouseLeave: () => setHovered(false)
|
|
528
536
|
};
|
|
529
|
-
const deferred = (family, render) => /* @__PURE__ */
|
|
530
|
-
if (control.parameter) return /* @__PURE__ */
|
|
531
|
-
if (control.submenu) return deferred("menu", (m) => /* @__PURE__ */
|
|
537
|
+
const deferred = (family, render) => /* @__PURE__ */ jsx5(Deferred, { family, render, fallback: () => /* @__PURE__ */ jsx5(Unsupported, { control, detail: "renderer:" + family }) });
|
|
538
|
+
if (control.parameter) return /* @__PURE__ */ jsx5(ParameterEditorView, { control, unit, ctx });
|
|
539
|
+
if (control.submenu) return deferred("menu", (m) => /* @__PURE__ */ jsx5(m.DropdownControl, { control, unit, ctx }));
|
|
532
540
|
switch (control.kind) {
|
|
533
541
|
case "group":
|
|
534
|
-
if (control.contextMenu) return deferred("menu", (m) => /* @__PURE__ */
|
|
535
|
-
if (control.menu) return deferred("menu", (m) => /* @__PURE__ */
|
|
536
|
-
if (control.tabMenu && !unit.triggers[control.id]?.length && !control.hoverOnly) return deferred("tab-menu", (m) => /* @__PURE__ */
|
|
537
|
-
return /* @__PURE__ */
|
|
542
|
+
if (control.contextMenu) return deferred("menu", (m) => /* @__PURE__ */ jsx5(m.ContextMenuControl, { control, unit, ctx }));
|
|
543
|
+
if (control.menu) return deferred("menu", (m) => /* @__PURE__ */ jsx5(m.MenuContents, { control, unit, ctx }));
|
|
544
|
+
if (control.tabMenu && !unit.triggers[control.id]?.length && !control.hoverOnly) return deferred("tab-menu", (m) => /* @__PURE__ */ jsx5(m.TabMenu, { control, unit, ctx }));
|
|
545
|
+
return /* @__PURE__ */ jsx5(Group, { control, unit, ctx });
|
|
538
546
|
case "label": {
|
|
539
|
-
const content = /* @__PURE__ */
|
|
547
|
+
const content = /* @__PURE__ */ jsx5(Text, { value: control.text, html: control.html });
|
|
540
548
|
if (unit.triggers[control.id]?.includes("click")) {
|
|
541
|
-
return /* @__PURE__ */
|
|
549
|
+
return /* @__PURE__ */ jsx5(CxButton2, { variant: "text", className: "uic-label-action", "data-control-id": control.id, disabled, onClick: (event) => fire(control.id, "click", { domEvent: event.nativeEvent }), children: content });
|
|
542
550
|
}
|
|
543
|
-
return /* @__PURE__ */
|
|
551
|
+
return /* @__PURE__ */ jsx5(CxTypography2, { variant: control.headingLevel ? `h${control.headingLevel}` : "body2", className: `uic-label uic-label--${control.id}`, "data-control-id": control.id, rootProps: { title: control.description }, children: content });
|
|
544
552
|
}
|
|
545
553
|
case "button": {
|
|
546
554
|
const name = control.ariaLabel || control.attributes?.["aria-label"] || control.tooltip || control.label || "";
|
|
547
555
|
const title = (disabled ? control.disabledTooltip : void 0) || control.tooltip || control.description;
|
|
548
556
|
if (control.icon && !control.label && !control.href) {
|
|
549
|
-
return /* @__PURE__ */
|
|
557
|
+
return /* @__PURE__ */ jsx5(CxTooltip2, { content: /* @__PURE__ */ jsx5(Text, { value: title, html: control.html }), disabled: !title || unit.triggers[control.id]?.some((trigger) => trigger === "tooltipShown" || trigger === "tooltipMasked"), hoist: true, children: /* @__PURE__ */ jsx5("span", { children: /* @__PURE__ */ jsx5(
|
|
550
558
|
CxIconButton,
|
|
551
559
|
{
|
|
552
560
|
...control.attributes,
|
|
@@ -563,7 +571,7 @@ var ControlBody = memo(function ControlBody2({ control, unit, ctx }) {
|
|
|
563
571
|
}
|
|
564
572
|
) }) });
|
|
565
573
|
}
|
|
566
|
-
return /* @__PURE__ */
|
|
574
|
+
return /* @__PURE__ */ jsx5(
|
|
567
575
|
CxButton2,
|
|
568
576
|
{
|
|
569
577
|
...control.attributes,
|
|
@@ -580,57 +588,57 @@ var ControlBody = memo(function ControlBody2({ control, unit, ctx }) {
|
|
|
580
588
|
title: title ?? control.attributes?.title,
|
|
581
589
|
"aria-label": control.ariaLabel ?? control.attributes?.["aria-label"],
|
|
582
590
|
onClick: (event) => activate(control, unit, ctx, event),
|
|
583
|
-
children: control.label ? /* @__PURE__ */
|
|
591
|
+
children: control.label ? /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }) : name
|
|
584
592
|
}
|
|
585
593
|
);
|
|
586
594
|
}
|
|
587
595
|
case "link":
|
|
588
|
-
return /* @__PURE__ */
|
|
596
|
+
return /* @__PURE__ */ jsx5(CxButton2, { ...control.attributes, variant: "text", href: control.href, target: control.target, rel: control.rel, download: control.download, disabled, onClick: (event) => activate(control, unit, ctx, event), className: "uic-link", "data-control-id": control.id, children: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }) });
|
|
589
597
|
case "image": {
|
|
590
|
-
const image = /* @__PURE__ */
|
|
591
|
-
return unit.triggers[control.id]?.includes("click") ? /* @__PURE__ */
|
|
598
|
+
const image = /* @__PURE__ */ jsx5(CxImage, { src: control.src, alt: control.alt ?? control.label ?? "", className: `uic-image uic-image--${control.id}`, "data-control-id": control.id });
|
|
599
|
+
return unit.triggers[control.id]?.includes("click") ? /* @__PURE__ */ jsx5(CxButton2, { variant: "text", disabled, "aria-label": control.ariaLabel || control.alt || control.label, onClick: (event) => activate(control, unit, ctx, event), children: image }) : image;
|
|
592
600
|
}
|
|
593
601
|
case "text":
|
|
594
602
|
case "password":
|
|
595
|
-
return /* @__PURE__ */
|
|
603
|
+
return /* @__PURE__ */ jsx5(TextInput, { control, unit, ctx });
|
|
596
604
|
case "textarea":
|
|
597
|
-
if (control.wysiwyg) return deferred("rich-text", (m) => /* @__PURE__ */
|
|
598
|
-
return /* @__PURE__ */
|
|
605
|
+
if (control.wysiwyg) return deferred("rich-text", (m) => /* @__PURE__ */ jsx5(m.RichTextInput, { control, unit, ctx }));
|
|
606
|
+
return /* @__PURE__ */ jsx5(TextareaInput, { control, unit, ctx });
|
|
599
607
|
case "checkbox":
|
|
600
|
-
return /* @__PURE__ */
|
|
608
|
+
return /* @__PURE__ */ jsx5(CheckboxInput, { control, unit, ctx });
|
|
601
609
|
case "select":
|
|
602
610
|
case "radio":
|
|
603
|
-
return deferred("select", (m) => /* @__PURE__ */
|
|
611
|
+
return deferred("select", (m) => /* @__PURE__ */ jsx5(m.SelectInput, { control, unit, ctx }));
|
|
604
612
|
case "date":
|
|
605
|
-
return deferred("date", (m) => /* @__PURE__ */
|
|
613
|
+
return deferred("date", (m) => /* @__PURE__ */ jsx5(m.DateInput, { control, unit, ctx }));
|
|
606
614
|
case "autocomplete":
|
|
607
|
-
return deferred("autocomplete", (m) => /* @__PURE__ */
|
|
615
|
+
return deferred("autocomplete", (m) => /* @__PURE__ */ jsx5(m.AutocompleteInput, { control, unit, ctx }));
|
|
608
616
|
case "html":
|
|
609
|
-
return /* @__PURE__ */
|
|
617
|
+
return /* @__PURE__ */ jsx5(FreeHtmlView, { control, unit, ctx });
|
|
610
618
|
case "webcomponent":
|
|
611
|
-
return deferred("webcomponent", (m) => /* @__PURE__ */
|
|
619
|
+
return deferred("webcomponent", (m) => /* @__PURE__ */ jsx5(m.WebComponentView, { control, unit, ctx }));
|
|
612
620
|
case "rating":
|
|
613
|
-
return deferred("widgets", (m) => /* @__PURE__ */
|
|
621
|
+
return deferred("widgets", (m) => /* @__PURE__ */ jsx5(m.RatingControl, { control, unit, ctx }));
|
|
614
622
|
case "iframe":
|
|
615
|
-
return deferred("widgets", (m) => /* @__PURE__ */
|
|
623
|
+
return deferred("widgets", (m) => /* @__PURE__ */ jsx5(m.IframeControl, { control }));
|
|
616
624
|
case "time":
|
|
617
|
-
return deferred("widgets", (m) => /* @__PURE__ */
|
|
625
|
+
return deferred("widgets", (m) => /* @__PURE__ */ jsx5(m.TimeControl, { control }));
|
|
618
626
|
case "progress":
|
|
619
|
-
return /* @__PURE__ */
|
|
627
|
+
return /* @__PURE__ */ jsx5(CxProgressBar, { "data-control-id": control.id, value: control.value, label: control.ariaLabel ?? control.label ?? "" });
|
|
620
628
|
case "chart":
|
|
621
|
-
return /* @__PURE__ */
|
|
629
|
+
return /* @__PURE__ */ jsx5(Unsupported, { control, detail: "chart" });
|
|
622
630
|
case "media":
|
|
623
|
-
if (unsupportedMediaTypes.has(control.mediaType)) return /* @__PURE__ */
|
|
624
|
-
return deferred("media", (m) => /* @__PURE__ */
|
|
631
|
+
if (unsupportedMediaTypes.has(control.mediaType)) return /* @__PURE__ */ jsx5(Unsupported, { control, detail: `media:${control.mediaType}` });
|
|
632
|
+
return deferred("media", (m) => /* @__PURE__ */ jsx5(m.MediaView, { control, unit, host: ctx.host }));
|
|
625
633
|
case "table":
|
|
626
|
-
return deferred("table", (m) => /* @__PURE__ */
|
|
634
|
+
return deferred("table", (m) => /* @__PURE__ */ jsx5(m.TableInput, { control, unit, ctx }));
|
|
627
635
|
default:
|
|
628
|
-
return /* @__PURE__ */
|
|
636
|
+
return /* @__PURE__ */ jsx5(Unsupported, { control, detail: control.type });
|
|
629
637
|
}
|
|
630
638
|
}, (previous, next) => previous.control === next.control && previous.ctx === next.ctx && previous.unit.id === next.unit.id && (next.control.kind !== "group" && next.control.kind !== "webcomponent" && next.control.kind !== "html" || previous.unit === next.unit) && (!next.control.submenu || previous.unit === next.unit) && previous.unit.inputs[previous.control.id] === next.unit.inputs[next.control.id] && previous.unit.triggers[previous.control.id] === next.unit.triggers[next.control.id]);
|
|
631
639
|
var unsupportedMediaTypes = /* @__PURE__ */ new Set(["video", "document"]);
|
|
632
640
|
function Unsupported({ control, detail }) {
|
|
633
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ jsx5(CxAlert, { open: true, variant: "warning", className: "uic-unsupported", "data-control-id": control.id, "data-unsupported": detail, children: /* @__PURE__ */ jsx5(Text, { value: control.label || control.ariaLabel, html: control.html }) });
|
|
634
642
|
}
|
|
635
643
|
function inputAccessibility(control) {
|
|
636
644
|
return {
|
|
@@ -641,7 +649,7 @@ function inputAccessibility(control) {
|
|
|
641
649
|
function TextInput({ control, unit, ctx }) {
|
|
642
650
|
const [value, setValue] = useControlValue(ctx.host, unit.id, control.id, unit.inputs[control.id]);
|
|
643
651
|
const fire = useFire(ctx.host, unit.id, unit.triggers);
|
|
644
|
-
return /* @__PURE__ */
|
|
652
|
+
return /* @__PURE__ */ jsx5(
|
|
645
653
|
CxInput,
|
|
646
654
|
{
|
|
647
655
|
...inputAccessibility(control),
|
|
@@ -650,7 +658,7 @@ function TextInput({ control, unit, ctx }) {
|
|
|
650
658
|
autoComplete: control.kind === "password" ? "new-password" : "on",
|
|
651
659
|
autoFocus: control.autoFocus,
|
|
652
660
|
invalid: Boolean(control.warning),
|
|
653
|
-
label: /* @__PURE__ */
|
|
661
|
+
label: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }),
|
|
654
662
|
helpText: control.warning || control.description,
|
|
655
663
|
value,
|
|
656
664
|
placeholder: control.placeholder,
|
|
@@ -669,8 +677,8 @@ function TextInput({ control, unit, ctx }) {
|
|
|
669
677
|
function TextareaInput({ control, unit, ctx }) {
|
|
670
678
|
const [value, setValue] = useControlValue(ctx.host, unit.id, control.id, unit.inputs[control.id]);
|
|
671
679
|
const fire = useFire(ctx.host, unit.id, unit.triggers);
|
|
672
|
-
if (control.wysiwyg) return /* @__PURE__ */
|
|
673
|
-
return /* @__PURE__ */
|
|
680
|
+
if (control.wysiwyg) return /* @__PURE__ */ jsx5(Unsupported, { control, detail: "wysiwyg" });
|
|
681
|
+
return /* @__PURE__ */ jsx5(
|
|
674
682
|
CxTextarea,
|
|
675
683
|
{
|
|
676
684
|
...inputAccessibility(control),
|
|
@@ -678,7 +686,7 @@ function TextareaInput({ control, unit, ctx }) {
|
|
|
678
686
|
"data-control-id": control.id,
|
|
679
687
|
autoFocus: control.autoFocus,
|
|
680
688
|
invalid: Boolean(control.warning),
|
|
681
|
-
label: /* @__PURE__ */
|
|
689
|
+
label: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }),
|
|
682
690
|
helpText: control.warning || control.description,
|
|
683
691
|
value,
|
|
684
692
|
placeholder: control.placeholder,
|
|
@@ -697,7 +705,7 @@ function CheckboxInput({ control, unit, ctx }) {
|
|
|
697
705
|
const [value, setValue] = useControlValue(ctx.host, unit.id, control.id, unit.inputs[control.id]);
|
|
698
706
|
const fire = useFire(ctx.host, unit.id, unit.triggers);
|
|
699
707
|
const Checkbox = control.appearance === "switch" ? CxSwitch : CxCheckbox;
|
|
700
|
-
return /* @__PURE__ */
|
|
708
|
+
return /* @__PURE__ */ jsx5(
|
|
701
709
|
Checkbox,
|
|
702
710
|
{
|
|
703
711
|
"data-control-id": control.id,
|
|
@@ -711,21 +719,21 @@ function CheckboxInput({ control, unit, ctx }) {
|
|
|
711
719
|
const trigger = unit.triggers[control.id]?.includes("click") ? "click" : "change";
|
|
712
720
|
if (unit.triggers[control.id]?.includes(trigger)) fire(control.id, trigger);
|
|
713
721
|
},
|
|
714
|
-
children: /* @__PURE__ */
|
|
722
|
+
children: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html })
|
|
715
723
|
}
|
|
716
724
|
);
|
|
717
725
|
}
|
|
718
726
|
var CREATE_ENTRY_VALUE = "%CREATE_ENTRY%";
|
|
719
727
|
|
|
720
728
|
export {
|
|
721
|
-
registerRendererLoaders,
|
|
722
|
-
rendererFamilyNames,
|
|
723
|
-
rendererFamiliesOf,
|
|
724
|
-
loadRendererFamilies,
|
|
725
729
|
hasExtendedEvents,
|
|
726
730
|
EventBoundary,
|
|
727
731
|
findMenu,
|
|
728
732
|
isDropdownPanel,
|
|
733
|
+
createRendererRegistry,
|
|
734
|
+
RendererRegistryContext,
|
|
735
|
+
rendererFamilyNames,
|
|
736
|
+
rendererFamiliesOf,
|
|
729
737
|
iconName,
|
|
730
738
|
Text,
|
|
731
739
|
Items,
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
export { activate, CREATE_ENTRY_VALUE, defaultAction,
|
|
1
|
+
export { activate, CREATE_ENTRY_VALUE, defaultAction, iconName, Text, type RenderContext } from './controls';
|
|
2
2
|
export { useControlValue, useFire, useInputValue } from './host-hooks';
|
|
3
|
-
export { coreDesignSystemEntries
|
|
4
|
-
export {
|
|
3
|
+
export { coreDesignSystemEntries } from './mount';
|
|
4
|
+
export { rendererFamiliesOf, rendererFamilyNames, type RendererFamily } from './lazy-renderers';
|
|
5
5
|
export { createUnitStore, isUnit, useUnit, type UnitStore } from './unit-store';
|
|
6
|
-
export { flatten,
|
|
6
|
+
export { flatten, withIcon, type Flat } from './units';
|
|
7
|
+
export declare const ControlView: import("react").NamedExoticComponent<{
|
|
8
|
+
control: import("../contracts/unit").Node;
|
|
9
|
+
unit: import("../contracts/unit").Unit;
|
|
10
|
+
ctx: import("./controls").RenderContext;
|
|
11
|
+
}>, Items: import("react").NamedExoticComponent<{
|
|
12
|
+
items: readonly import("../contracts/unit").ViewNode[];
|
|
13
|
+
unit: import("../contracts/unit").Unit;
|
|
14
|
+
ctx: import("./controls").RenderContext;
|
|
15
|
+
}>, InlinedUnit: import("react").NamedExoticComponent<{
|
|
16
|
+
unit: import("../contracts/unit").Unit;
|
|
17
|
+
ctx: import("./controls").RenderContext;
|
|
18
|
+
}>, renderUnit: typeof import("./units").renderUnit, createMount: (Root: import("react").ComponentType<{
|
|
19
|
+
store: import("./unit-store").UnitStore;
|
|
20
|
+
host: import("../contracts/unit").HostBridge;
|
|
21
|
+
}>) => import("../contracts/unit").Mount, loadRendererFamilies: (names?: readonly import("./lazy-renderers").RendererFamily[]) => Promise<void>;
|
package/dist/runtime/index.js
CHANGED
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
CREATE_ENTRY_VALUE,
|
|
6
6
|
ControlView,
|
|
7
7
|
Items,
|
|
8
|
+
RendererRegistryContext,
|
|
8
9
|
Text,
|
|
9
10
|
activate,
|
|
11
|
+
createRendererRegistry,
|
|
10
12
|
defaultAction,
|
|
11
13
|
iconName,
|
|
12
|
-
loadRendererFamilies,
|
|
13
|
-
registerRendererLoaders,
|
|
14
14
|
rendererFamiliesOf,
|
|
15
15
|
rendererFamilyNames
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-F6THHPXZ.js";
|
|
17
17
|
import {
|
|
18
18
|
UnitStoreContext,
|
|
19
19
|
createUnitStore,
|
|
@@ -24,19 +24,33 @@ import {
|
|
|
24
24
|
useUnit
|
|
25
25
|
} from "../chunk-BTZWYDJT.js";
|
|
26
26
|
|
|
27
|
-
// packages/gen1/src/runtime/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
// packages/gen1/src/runtime/runtime-instance.tsx
|
|
28
|
+
import { memo as memo2, useContext } from "react";
|
|
29
|
+
|
|
30
|
+
// packages/gen1/src/runtime/units.tsx
|
|
31
|
+
import { memo } from "react";
|
|
32
|
+
import { CxBox } from "@orangelogic/design-system-react/box";
|
|
33
|
+
import { jsx } from "react/jsx-runtime";
|
|
34
|
+
function flatten(items, into = { controls: /* @__PURE__ */ new Map(), units: [] }) {
|
|
35
|
+
for (const item of items) {
|
|
36
|
+
if (isUnit(item)) into.units.push(item);
|
|
37
|
+
else if (item.kind === "group") {
|
|
38
|
+
into.controls.set(item.id, item);
|
|
39
|
+
flatten(item.items, into);
|
|
40
|
+
} else into.controls.set(item.id, item);
|
|
41
|
+
}
|
|
42
|
+
return into;
|
|
43
|
+
}
|
|
44
|
+
function withIcon(control, icon) {
|
|
45
|
+
return control.icon ? control : { ...control, icon };
|
|
46
|
+
}
|
|
47
|
+
function renderUnit(child, ctx) {
|
|
48
|
+
if (child.kind === "component") return /* @__PURE__ */ jsx("slot", { name: `unit:${child.id}` });
|
|
49
|
+
return /* @__PURE__ */ jsx(InlinedUnit, { unit: child, ctx });
|
|
50
|
+
}
|
|
51
|
+
var InlinedUnit = memo(function InlinedUnit2({ unit, ctx }) {
|
|
52
|
+
return /* @__PURE__ */ jsx(CxBox, { className: "uic-inlined", "data-unit-id": unit.id, onKeyDown: (event) => defaultAction(event, unit, ctx), children: /* @__PURE__ */ jsx(Items, { items: unit.view, unit, ctx }) });
|
|
53
|
+
});
|
|
40
54
|
|
|
41
55
|
// packages/gen1/src/runtime/mount.tsx
|
|
42
56
|
import { createDesignSystemRoot, prepareDesignSystemContainer } from "@orangelogic/design-system-react/integrations/mount-screen";
|
|
@@ -44,23 +58,23 @@ import { createDesignSystemRoot, prepareDesignSystemContainer } from "@orangelog
|
|
|
44
58
|
// packages/gen1/src/runtime/localization.tsx
|
|
45
59
|
import { useMemo } from "react";
|
|
46
60
|
import { DesignSystemProvider } from "@orangelogic/design-system-react/foundation";
|
|
47
|
-
import { jsx } from "react/jsx-runtime";
|
|
61
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
48
62
|
function UnitLocalization({ strings, children }) {
|
|
49
63
|
const messages = useMemo(() => Object.fromEntries(uiStringKeys.map((key) => [key, typeof strings?.[key] === "string" ? strings[key] : ""])), [strings]);
|
|
50
64
|
const required = '"' + messages.required.replace(/[\\"\n\r\f]/g, (value) => "\\" + value.charCodeAt(0).toString(16) + " ") + '"';
|
|
51
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ jsx2(DesignSystemProvider, { messages, rootProps: { style: { display: "contents", "--cx-input-required-content": required } }, children });
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
// packages/gen1/src/runtime/mount.tsx
|
|
55
|
-
import { jsx as
|
|
69
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
56
70
|
var coreDesignSystemEntries = ["foundation", "alert", "avatar", "box", "button", "checkbox", "switch", "radio", "radio-group", "dynamic-select", "icon", "icon-button", "image", "input", "input-date-picker", "input-date-range-picker", "option", "select", "textarea", "tooltip", "typography", "tab", "tab-group", "rating", "iframe", "timecode", "progress-bar", "dropdown", "menu", "menu-item", "popup", "tab-panel", "audio", "rich-text", "table", "menu-label", "details"];
|
|
57
|
-
function createMount(Root) {
|
|
71
|
+
function createMount(Root, registry) {
|
|
58
72
|
function LocalizedRoot({ store, host }) {
|
|
59
73
|
const unit = useUnit(store);
|
|
60
|
-
return /* @__PURE__ */
|
|
74
|
+
return /* @__PURE__ */ jsx3(UnitLocalization, { strings: unit.uiStrings, children: /* @__PURE__ */ jsx3(Root, { store, host }) });
|
|
61
75
|
}
|
|
62
76
|
return async (container, { unit, host, styleSheets }) => {
|
|
63
|
-
await loadRendererFamilies(rendererFamiliesOf(unit));
|
|
77
|
+
await registry.loadRendererFamilies(rendererFamiliesOf(unit));
|
|
64
78
|
const scope = container.shadowRoot ?? (styleSheets ? container.attachShadow({ mode: "open" }) : container);
|
|
65
79
|
if (scope.childNodes.length) throw Error("Component container is occupied.");
|
|
66
80
|
const shadow = scope instanceof ShadowRoot ? scope : void 0;
|
|
@@ -91,7 +105,7 @@ function createMount(Root) {
|
|
|
91
105
|
const update = (next) => {
|
|
92
106
|
if (!mounted) return;
|
|
93
107
|
if (next.id !== unit.id) throw Error("Replacement unit does not belong to this mount.");
|
|
94
|
-
loadRendererFamilies(rendererFamiliesOf(next)).catch(() => void 0);
|
|
108
|
+
registry.loadRendererFamilies(rendererFamiliesOf(next)).catch(() => void 0);
|
|
95
109
|
store.set(next);
|
|
96
110
|
};
|
|
97
111
|
const unmount = () => {
|
|
@@ -112,7 +126,7 @@ function createMount(Root) {
|
|
|
112
126
|
try {
|
|
113
127
|
root = createDesignSystemRoot(surface.element, { overlayContainer: surface.overlays, provider });
|
|
114
128
|
unsubscribe = host.subscribe(unit.id, update);
|
|
115
|
-
root.render(/* @__PURE__ */
|
|
129
|
+
root.render(/* @__PURE__ */ jsx3(RendererRegistryContext.Provider, { value: registry, children: /* @__PURE__ */ jsx3(UnitStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsx3(LocalizedRoot, { store, host }) }) }));
|
|
116
130
|
} catch (error) {
|
|
117
131
|
unmount();
|
|
118
132
|
throw error;
|
|
@@ -124,49 +138,65 @@ function createMount(Root) {
|
|
|
124
138
|
};
|
|
125
139
|
}
|
|
126
140
|
|
|
127
|
-
// packages/gen1/src/runtime/
|
|
128
|
-
import {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
else if (item.kind === "group") {
|
|
135
|
-
into.controls.set(item.id, item);
|
|
136
|
-
flatten(item.items, into);
|
|
137
|
-
} else into.controls.set(item.id, item);
|
|
141
|
+
// packages/gen1/src/runtime/runtime-instance.tsx
|
|
142
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
143
|
+
function createRuntime(loaders) {
|
|
144
|
+
const registry = createRendererRegistry(loaders);
|
|
145
|
+
function Boundary({ children }) {
|
|
146
|
+
const inherited = useContext(RendererRegistryContext);
|
|
147
|
+
return /* @__PURE__ */ jsx4(RendererRegistryContext.Provider, { value: inherited ?? registry, children });
|
|
138
148
|
}
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
const ControlView3 = memo2(function ControlView4(props) {
|
|
150
|
+
return /* @__PURE__ */ jsx4(Boundary, { children: /* @__PURE__ */ jsx4(ControlView, { ...props }) });
|
|
151
|
+
});
|
|
152
|
+
const Items3 = memo2(function Items4(props) {
|
|
153
|
+
return /* @__PURE__ */ jsx4(Boundary, { children: /* @__PURE__ */ jsx4(Items, { ...props }) });
|
|
154
|
+
});
|
|
155
|
+
const InlinedUnit4 = memo2(function InlinedUnit5(props) {
|
|
156
|
+
return /* @__PURE__ */ jsx4(Boundary, { children: /* @__PURE__ */ jsx4(InlinedUnit, { ...props }) });
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
ControlView: ControlView3,
|
|
160
|
+
Items: Items3,
|
|
161
|
+
InlinedUnit: InlinedUnit4,
|
|
162
|
+
renderUnit: ((child, ctx) => /* @__PURE__ */ jsx4(Boundary, { children: renderUnit(child, ctx) })),
|
|
163
|
+
createMount: (Root) => createMount(Root, registry),
|
|
164
|
+
loadRendererFamilies: registry.loadRendererFamilies
|
|
165
|
+
};
|
|
147
166
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
167
|
+
|
|
168
|
+
// packages/gen1/src/runtime/renderer-loaders.ts
|
|
169
|
+
var rendererLoaders = {
|
|
170
|
+
select: () => import("../select-GAAOKMWC.js"),
|
|
171
|
+
date: () => import("../date-MILP7DAY.js"),
|
|
172
|
+
autocomplete: () => import("../autocomplete-TWBUFBPK.js"),
|
|
173
|
+
"rich-text": () => import("../rich-text-EFOTPYBP.js"),
|
|
174
|
+
table: () => import("../table-FELNJICP.js"),
|
|
175
|
+
media: () => import("../media-IECUTXW5.js"),
|
|
176
|
+
webcomponent: () => import("../webcomponent-GL3RN3YI.js"),
|
|
177
|
+
widgets: () => import("../widgets-JZWFRF3E.js"),
|
|
178
|
+
menu: () => import("../menu-DLZOBFXB.js"),
|
|
179
|
+
"tab-menu": () => import("../tab-menu-AIXU7FUG.js")
|
|
180
|
+
};
|
|
151
181
|
|
|
152
182
|
// packages/gen1/src/runtime/index.ts
|
|
153
|
-
|
|
183
|
+
var { ControlView: ControlView2, Items: Items2, InlinedUnit: InlinedUnit3, renderUnit: renderUnit2, createMount: createMount2, loadRendererFamilies } = createRuntime(rendererLoaders);
|
|
154
184
|
export {
|
|
155
185
|
CREATE_ENTRY_VALUE,
|
|
156
|
-
ControlView,
|
|
157
|
-
InlinedUnit,
|
|
158
|
-
Items,
|
|
186
|
+
ControlView2 as ControlView,
|
|
187
|
+
InlinedUnit3 as InlinedUnit,
|
|
188
|
+
Items2 as Items,
|
|
159
189
|
Text,
|
|
160
190
|
activate,
|
|
161
191
|
coreDesignSystemEntries,
|
|
162
|
-
createMount,
|
|
192
|
+
createMount2 as createMount,
|
|
163
193
|
createUnitStore,
|
|
164
194
|
defaultAction,
|
|
165
195
|
flatten,
|
|
166
196
|
iconName,
|
|
167
197
|
isUnit,
|
|
168
198
|
loadRendererFamilies,
|
|
169
|
-
renderUnit,
|
|
199
|
+
renderUnit2 as renderUnit,
|
|
170
200
|
rendererFamiliesOf,
|
|
171
201
|
rendererFamilyNames,
|
|
172
202
|
useControlValue,
|
|
@@ -18,13 +18,29 @@ type RendererModule<F extends RendererFamily> = RendererModules[F];
|
|
|
18
18
|
export type RendererLoaders = {
|
|
19
19
|
readonly [F in RendererFamily]: () => Promise<RendererModules[F]>;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Renderers outside the always-loaded core, one module per family. The delivery graph exposes each family module as an
|
|
23
|
+
* entry node, so a host that knows the unit fetches only the families `rendererFamiliesOf` reports, in one batch.
|
|
24
|
+
* The dynamic imports live in the runtime entry module (renderer-loaders.ts), which no family imports: a family
|
|
25
|
+
* importing the module that imports it would be a cycle, which verified blob-URL loading cannot materialize.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createRendererRegistry(loaders: RendererLoaders): {
|
|
28
|
+
get<F extends RendererFamily>(name: F): RendererModule<F> | undefined;
|
|
29
|
+
load: <F extends RendererFamily>(name: F) => Promise<RendererModule<F>>;
|
|
30
|
+
/** Loads this runtime's families in parallel; rejects when any fails to load. */
|
|
31
|
+
loadRendererFamilies(names?: readonly RendererFamily[]): Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
export type RendererRegistry = ReturnType<typeof createRendererRegistry>;
|
|
34
|
+
export declare const RendererRegistryContext: import("react").Context<{
|
|
35
|
+
get<F extends RendererFamily>(name: F): RendererModule<F> | undefined;
|
|
36
|
+
load: <F extends RendererFamily>(name: F) => Promise<RendererModule<F>>;
|
|
37
|
+
/** Loads this runtime's families in parallel; rejects when any fails to load. */
|
|
38
|
+
loadRendererFamilies(names?: readonly RendererFamily[]): Promise<void>;
|
|
39
|
+
} | undefined>;
|
|
22
40
|
/** The renderer families, in a fixed order. */
|
|
23
41
|
export declare const rendererFamilyNames: readonly (keyof RendererModules)[];
|
|
24
42
|
/** Families the unit's own view and its inlined VForms render; a nested component unit is its own mount. */
|
|
25
43
|
export declare function rendererFamiliesOf(unit: Unit): RendererFamily[];
|
|
26
|
-
/** Loads the families in parallel; rejects when any of them fails to load. */
|
|
27
|
-
export declare function loadRendererFamilies(names?: readonly RendererFamily[]): Promise<void>;
|
|
28
44
|
/**
|
|
29
45
|
* Renders from a family module. A mount preloads its unit's families, so this renders synchronously; a family first
|
|
30
46
|
* needed by a later update renders nothing until it arrives, and the fallback if it cannot load.
|
|
@@ -33,5 +49,5 @@ export declare function Deferred<F extends RendererFamily>({ family, render, fal
|
|
|
33
49
|
family: F;
|
|
34
50
|
render: (module: RendererModule<F>) => ReactNode;
|
|
35
51
|
fallback: () => ReactNode;
|
|
36
|
-
}):
|
|
52
|
+
}): import("react").JSX.Element;
|
|
37
53
|
export {};
|
package/dist/runtime/mount.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
2
|
import type { HostBridge, Mount } from '../contracts/unit';
|
|
3
3
|
import { type UnitStore } from './unit-store';
|
|
4
|
+
import { type RendererRegistry } from './lazy-renderers';
|
|
4
5
|
/** Design-system entries the core controls render with; a component exports these plus its own as `designSystemEntries`. */
|
|
5
6
|
export declare const coreDesignSystemEntries: readonly ["foundation", "alert", "avatar", "box", "button", "checkbox", "switch", "radio", "radio-group", "dynamic-select", "icon", "icon-button", "image", "input", "input-date-picker", "input-date-range-picker", "option", "select", "textarea", "tooltip", "typography", "tab", "tab-group", "rating", "iframe", "timecode", "progress-bar", "dropdown", "menu", "menu-item", "popup", "tab-panel", "audio", "rich-text", "table", "menu-label", "details"];
|
|
6
7
|
/** The host-facing `mount` of a component whose root renders from the unit store. */
|
|
7
8
|
export declare function createMount(Root: ComponentType<{
|
|
8
9
|
store: UnitStore;
|
|
9
10
|
host: HostBridge;
|
|
10
|
-
}
|
|
11
|
+
}>, registry: RendererRegistry): Mount;
|
|
@@ -114,13 +114,13 @@
|
|
|
114
114
|
"modules": {
|
|
115
115
|
"table": "table-FELNJICP.js",
|
|
116
116
|
"media": "media-IECUTXW5.js",
|
|
117
|
-
"webcomponent": "webcomponent-
|
|
118
|
-
"widgets": "widgets-
|
|
119
|
-
"menu": "menu-
|
|
120
|
-
"tab-menu": "tab-menu-
|
|
121
|
-
"select": "select-
|
|
122
|
-
"date": "date-
|
|
123
|
-
"autocomplete": "autocomplete-
|
|
124
|
-
"rich-text": "rich-text-
|
|
117
|
+
"webcomponent": "webcomponent-GL3RN3YI.js",
|
|
118
|
+
"widgets": "widgets-JZWFRF3E.js",
|
|
119
|
+
"menu": "menu-DLZOBFXB.js",
|
|
120
|
+
"tab-menu": "tab-menu-AIXU7FUG.js",
|
|
121
|
+
"select": "select-GAAOKMWC.js",
|
|
122
|
+
"date": "date-MILP7DAY.js",
|
|
123
|
+
"autocomplete": "autocomplete-TWBUFBPK.js",
|
|
124
|
+
"rich-text": "rich-text-EFOTPYBP.js"
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RendererLoaders } from './lazy-renderers';
|
|
2
2
|
/**
|
|
3
|
-
* Imported only by the runtime entry, which
|
|
4
|
-
*
|
|
3
|
+
* Imported only by the runtime entry, which creates its own registry. Keep these imports out of the shared core:
|
|
4
|
+
* each host-rewritten runtime may bind a different set of families, while sharing the core and React context.
|
|
5
5
|
*/
|
|
6
6
|
export declare const rendererLoaders: RendererLoaders;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import type { HostBridge, Mount } from '../contracts/unit';
|
|
3
|
+
import * as controls from './controls';
|
|
4
|
+
import * as units from './units';
|
|
5
|
+
import type { UnitStore } from './unit-store';
|
|
6
|
+
import { type RendererLoaders } from './lazy-renderers';
|
|
7
|
+
/** One instance per evaluated runtime entry, even when its core chunk is shared with other graph bindings. */
|
|
8
|
+
export declare function createRuntime(loaders: RendererLoaders): {
|
|
9
|
+
ControlView: import("react").NamedExoticComponent<{
|
|
10
|
+
control: import("../contracts/unit").Node;
|
|
11
|
+
unit: import("../contracts/unit").Unit;
|
|
12
|
+
ctx: controls.RenderContext;
|
|
13
|
+
}>;
|
|
14
|
+
Items: import("react").NamedExoticComponent<{
|
|
15
|
+
items: readonly import("../contracts/unit").ViewNode[];
|
|
16
|
+
unit: import("../contracts/unit").Unit;
|
|
17
|
+
ctx: controls.RenderContext;
|
|
18
|
+
}>;
|
|
19
|
+
InlinedUnit: import("react").NamedExoticComponent<{
|
|
20
|
+
unit: import("../contracts/unit").Unit;
|
|
21
|
+
ctx: controls.RenderContext;
|
|
22
|
+
}>;
|
|
23
|
+
renderUnit: typeof units.renderUnit;
|
|
24
|
+
createMount: (Root: ComponentType<{
|
|
25
|
+
store: UnitStore;
|
|
26
|
+
host: HostBridge;
|
|
27
|
+
}>) => Mount;
|
|
28
|
+
loadRendererFamilies: (names?: readonly import("./lazy-renderers").RendererFamily[]) => Promise<void>;
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orangelogic/myos-gen1",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"files": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"gen1-build": "./scripts/build.mjs"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@orangelogic/design-system-react": "1.0.0-alpha.
|
|
48
|
+
"@orangelogic/design-system-react": "1.0.0-alpha.8",
|
|
49
49
|
"react": "^19.3.0",
|
|
50
50
|
"react-dom": "^19.3.0"
|
|
51
51
|
},
|