@orangelogic/myos-gen1 1.0.0-alpha.7 → 1.0.0-alpha.9
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/README.md +4 -0
- package/contracts/unit/2/unit.ts +10 -0
- package/dist/{autocomplete-R6DME2OB.js → autocomplete-X6EHYE3C.js} +1 -1
- package/dist/{chunk-66SV6MPF.js → chunk-AK4GIOIA.js} +145 -108
- package/dist/contracts/unit.d.ts +10 -0
- package/dist/{date-HIILR4IG.js → date-3ERTXTH6.js} +1 -1
- package/dist/{menu-WZ4WC2IN.js → menu-3VTEQUFY.js} +1 -1
- package/dist/{rich-text-S76EGP2P.js → rich-text-WW3QDJRD.js} +1 -1
- package/dist/runtime/index.css +6 -0
- 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/parameter-input-context.d.ts +5 -0
- 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-ZHDSD2DT.js} +1 -1
- package/dist/{tab-menu-PBUFHDEE.js → tab-menu-BCHQQXDF.js} +1 -1
- package/dist/{webcomponent-5RFJIIY6.js → webcomponent-WSHWI6TX.js} +1 -1
- package/dist/{widgets-7MLUBX4G.js → widgets-ZTPJN5LP.js} +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -53,3 +53,7 @@ Consumers own component implementations, registry publication, release manifests
|
|
|
53
53
|
The scroll binding resolves its owning control through native display:contents wrappers and ignores nested control scrolls. Use `discoverComponents(componentProjectRoot)` with an explicit project root; standalone builds use `checkBoundaries`, while `checkLayout` remains the legacy bare-component layout checker. The emitted stylesheet is `mount.css`; Release assembly should consume `mount.css` and include it in the source-digest recipe.
|
|
54
54
|
|
|
55
55
|
`buildComponent({root, project})` accepts an explicit shared dependency manifest for bare first-party components; source ownership remains confined to `root`. Standalone consumers omit `project`. The distribution includes `protocols/dotnet/*` for the registry's project reference.
|
|
56
|
+
|
|
57
|
+
Parameter textareas start at one row and use the textarea atom's content autosizing, including shrinking after a host refresh or cancel. Ordinary textareas retain the atom's four-row/manual-resize defaults; password parameters retain password input privacy. The atom owns horizontal padding so its native resize grip reaches the control edge in manual mode, while labels keep the same text inset.
|
|
58
|
+
|
|
59
|
+
Protocol 2 parameter editors may carry optional `origin` presentation metadata: `kind` (`profile`, `local-session` or `user-session`), safe hexadecimal `color`, optional `inherited` and optional profile `depth` (0..255). Cortex resolves visibility, precedence and the configured palette. The runtime draws the origin line without accepting arbitrary CSS or changing parameter actions; inherited origins use a dashed line and current origins a solid line. Older units without metadata show no line. Protocol 1 remains frozen. This restores the compact legacy parameter-text behavior and configured origin meaning without copying legacy skin classes into React.
|
package/contracts/unit/2/unit.ts
CHANGED
|
@@ -56,6 +56,16 @@ export interface NodeBase {
|
|
|
56
56
|
export interface ParameterEditor {
|
|
57
57
|
readonly detailsLabel?: string; readonly resetLabel?: string; readonly resolveLabel?: string;
|
|
58
58
|
readonly comment?: string; readonly info?: string; readonly hideInput?: boolean; readonly readOnly?: boolean;
|
|
59
|
+
/** Effective configured origin indicator. Absent on older units or when the legacy indicator is hidden. */
|
|
60
|
+
readonly origin?: ParameterOrigin;
|
|
61
|
+
}
|
|
62
|
+
export interface ParameterOrigin {
|
|
63
|
+
readonly kind: 'profile' | 'local-session' | 'user-session';
|
|
64
|
+
/** Canonical hexadecimal color; never a CSS declaration or a skin class. */
|
|
65
|
+
readonly color: string;
|
|
66
|
+
readonly inherited?: boolean;
|
|
67
|
+
/** Profile depth in the bounded range 0..255. */
|
|
68
|
+
readonly depth?: number;
|
|
59
69
|
}
|
|
60
70
|
export interface InputNode extends NodeBase {
|
|
61
71
|
readonly required?: boolean; readonly autoFocus?: boolean; readonly warning?: string;
|
|
@@ -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,12 +101,12 @@ 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
|
|
|
100
108
|
// packages/gen1/src/runtime/controls.tsx
|
|
101
|
-
import { Fragment, memo, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
109
|
+
import { Fragment, memo, useContext as useContext3, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
102
110
|
import { CxAlert } from "@orangelogic/design-system-react/alert";
|
|
103
111
|
import { CxBox as CxBox2 } from "@orangelogic/design-system-react/box";
|
|
104
112
|
import { CxButton as CxButton2 } from "@orangelogic/design-system-react/button";
|
|
@@ -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: () => {
|
|
@@ -290,34 +298,59 @@ function isGroupHit(target, group, unit) {
|
|
|
290
298
|
}
|
|
291
299
|
|
|
292
300
|
// packages/gen1/src/runtime/parameter-editor.tsx
|
|
293
|
-
import { useCallback, useSyncExternalStore } from "react";
|
|
301
|
+
import { useCallback, useMemo, 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
|
-
|
|
305
|
+
|
|
306
|
+
// packages/gen1/src/runtime/parameter-input-context.ts
|
|
307
|
+
import { createContext as createContext2 } from "react";
|
|
308
|
+
var ParameterInputContext = createContext2(void 0);
|
|
309
|
+
|
|
310
|
+
// packages/gen1/src/runtime/parameter-editor.tsx
|
|
311
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
312
|
+
var maximumParameterOriginDepth = 255;
|
|
313
|
+
function isParameterOrigin(value) {
|
|
314
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
315
|
+
const origin = value;
|
|
316
|
+
return ["profile", "local-session", "user-session"].includes(origin.kind) && typeof origin.color === "string" && /^#(?:[\da-f]{6}|[\da-f]{8})$/i.test(origin.color) && (origin.inherited === void 0 || typeof origin.inherited === "boolean") && (origin.depth === void 0 || Number.isInteger(origin.depth) && origin.depth >= 0 && origin.depth <= maximumParameterOriginDepth);
|
|
317
|
+
}
|
|
298
318
|
function ParameterEditorView({ control, unit, ctx }) {
|
|
299
319
|
const subscribe = useCallback((notify) => ctx.host.subscribe(ctx.host.unitId, notify), [ctx.host]);
|
|
300
320
|
const snapshot = useCallback(() => ctx.host.getParameterReset?.(unit.id, control.id) ?? false, [ctx.host, unit.id, control.id]);
|
|
301
321
|
const reset = useSyncExternalStore(subscribe, snapshot);
|
|
302
322
|
const parameter = control.parameter;
|
|
323
|
+
const inputScope = useMemo(() => ({ unitId: unit.id, controlId: control.id }), [unit.id, control.id]);
|
|
324
|
+
const input = { ...control, parameter: void 0, readOnly: control.readOnly || parameter.readOnly };
|
|
325
|
+
const origin = parameter.origin;
|
|
303
326
|
const disabled = control.disabled || control.readOnly;
|
|
304
327
|
const actions = unit.triggers[control.id] ?? [];
|
|
305
328
|
return /* @__PURE__ */ jsxs(CxBox, { className: "uic-parameter", "data-parameter-reset": reset || void 0, children: [
|
|
306
|
-
!parameter.hideInput && /* @__PURE__ */
|
|
307
|
-
parameter.hideInput && /* @__PURE__ */
|
|
308
|
-
|
|
309
|
-
|
|
329
|
+
!parameter.hideInput && /* @__PURE__ */ jsx3(ParameterInputContext.Provider, { value: inputScope, children: /* @__PURE__ */ jsx3(ControlView, { control: input, unit, ctx }) }),
|
|
330
|
+
parameter.hideInput && /* @__PURE__ */ jsx3(CxTypography, { children: /* @__PURE__ */ jsx3(Text, { value: control.label, html: control.html }) }),
|
|
331
|
+
isParameterOrigin(origin) && /* @__PURE__ */ jsx3(
|
|
332
|
+
CxBox,
|
|
333
|
+
{
|
|
334
|
+
className: "uic-parameter-origin",
|
|
335
|
+
"aria-hidden": "true",
|
|
336
|
+
"data-parameter-origin": origin.kind,
|
|
337
|
+
"data-parameter-inherited": origin.inherited || void 0,
|
|
338
|
+
style: { borderBlockEndColor: origin.color }
|
|
339
|
+
}
|
|
340
|
+
),
|
|
341
|
+
parameter.info && /* @__PURE__ */ jsx3(CxTypography, { children: /* @__PURE__ */ jsx3(Text, { value: parameter.info, html: true }) }),
|
|
342
|
+
parameter.comment && /* @__PURE__ */ jsx3(
|
|
310
343
|
CxButton,
|
|
311
344
|
{
|
|
312
345
|
variant: "text",
|
|
313
346
|
disabled,
|
|
314
347
|
"data-control-id": control.id,
|
|
315
348
|
onClick: () => ctx.host.fire(unit.id, control.id, "parameter-details"),
|
|
316
|
-
children: /* @__PURE__ */
|
|
349
|
+
children: /* @__PURE__ */ jsx3(Text, { value: parameter.comment, html: true })
|
|
317
350
|
}
|
|
318
351
|
),
|
|
319
352
|
/* @__PURE__ */ jsxs(CxBox, { children: [
|
|
320
|
-
parameter.detailsLabel !== void 0 && actions.includes("parameter-details") && /* @__PURE__ */
|
|
353
|
+
parameter.detailsLabel !== void 0 && actions.includes("parameter-details") && /* @__PURE__ */ jsx3(
|
|
321
354
|
CxButton,
|
|
322
355
|
{
|
|
323
356
|
variant: "text",
|
|
@@ -327,7 +360,7 @@ function ParameterEditorView({ control, unit, ctx }) {
|
|
|
327
360
|
children: parameter.detailsLabel
|
|
328
361
|
}
|
|
329
362
|
),
|
|
330
|
-
parameter.resolveLabel !== void 0 && actions.includes("parameter-resolve") && /* @__PURE__ */
|
|
363
|
+
parameter.resolveLabel !== void 0 && actions.includes("parameter-resolve") && /* @__PURE__ */ jsx3(
|
|
331
364
|
CxButton,
|
|
332
365
|
{
|
|
333
366
|
variant: "text",
|
|
@@ -337,7 +370,7 @@ function ParameterEditorView({ control, unit, ctx }) {
|
|
|
337
370
|
children: parameter.resolveLabel
|
|
338
371
|
}
|
|
339
372
|
),
|
|
340
|
-
parameter.resetLabel !== void 0 && actions.includes("parameter-reset") && /* @__PURE__ */
|
|
373
|
+
parameter.resetLabel !== void 0 && actions.includes("parameter-reset") && /* @__PURE__ */ jsx3(
|
|
341
374
|
CxButton,
|
|
342
375
|
{
|
|
343
376
|
variant: reset ? "primary" : "text",
|
|
@@ -372,7 +405,7 @@ import { CxProgressBar } from "@orangelogic/design-system-react/progress-bar";
|
|
|
372
405
|
// packages/gen1/src/runtime/free-html.tsx
|
|
373
406
|
import { useLayoutEffect, useRef as useRef2, useState as useState2 } from "react";
|
|
374
407
|
import { createPortal } from "react-dom";
|
|
375
|
-
import { jsx as
|
|
408
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
376
409
|
function FreeHtmlView({ control, unit, ctx }) {
|
|
377
410
|
const surface = useRef2(null);
|
|
378
411
|
const markup = useRef2(null);
|
|
@@ -398,8 +431,8 @@ function FreeHtmlView({ control, unit, ctx }) {
|
|
|
398
431
|
"aria-disabled": control.disabled || control.readOnly || void 0,
|
|
399
432
|
inert: control.disabled || control.readOnly || void 0,
|
|
400
433
|
children: [
|
|
401
|
-
control.css && /* @__PURE__ */
|
|
402
|
-
/* @__PURE__ */
|
|
434
|
+
control.css && /* @__PURE__ */ jsx4("style", { children: control.css }),
|
|
435
|
+
/* @__PURE__ */ jsx4("div", { ref: markup, dangerouslySetInnerHTML: { __html: control.markup } }),
|
|
403
436
|
control.items?.map((child) => {
|
|
404
437
|
const target = targets.get(child.id);
|
|
405
438
|
return target ? createPortal(ctx.renderUnit(child, ctx), target, child.id) : null;
|
|
@@ -410,18 +443,18 @@ function FreeHtmlView({ control, unit, ctx }) {
|
|
|
410
443
|
}
|
|
411
444
|
|
|
412
445
|
// packages/gen1/src/runtime/controls.tsx
|
|
413
|
-
import { Fragment as Fragment2, jsx as
|
|
446
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
414
447
|
function iconName(icon, fallback = "") {
|
|
415
448
|
const name = (icon ?? "").split(/\s+/).filter((token) => token && !/^fa-(lg|xs|sm|[1-9]x|fw)$/i.test(token)).join(" ");
|
|
416
449
|
return name || fallback;
|
|
417
450
|
}
|
|
418
451
|
function Text({ value, html }) {
|
|
419
452
|
if (!value) return null;
|
|
420
|
-
return html ? /* @__PURE__ */
|
|
453
|
+
return html ? /* @__PURE__ */ jsx5("span", { dangerouslySetInnerHTML: { __html: value } }) : /* @__PURE__ */ jsx5(Fragment2, { children: value });
|
|
421
454
|
}
|
|
422
455
|
var Items = memo(function Items2({ items, unit, ctx }) {
|
|
423
|
-
if (unit.contextMenu && items === unit.view) return /* @__PURE__ */
|
|
424
|
-
return /* @__PURE__ */
|
|
456
|
+
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 });
|
|
457
|
+
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
458
|
});
|
|
426
459
|
function activate(control, unit, ctx, event) {
|
|
427
460
|
if (control.disabled || control.readOnly) {
|
|
@@ -462,9 +495,9 @@ function Group({ control, unit, ctx }) {
|
|
|
462
495
|
useEffect3(() => {
|
|
463
496
|
sent.current = false;
|
|
464
497
|
}, [control, unit.triggers[control.id]]);
|
|
465
|
-
return /* @__PURE__ */
|
|
498
|
+
return /* @__PURE__ */ jsx5(DismissBoundary, { disabled: inactive, onOutside: (event) => {
|
|
466
499
|
if (!sent.current) sent.current = ctx.host.fire(unit.id, control.id, "clickOut", { domEvent: event });
|
|
467
|
-
}, children: /* @__PURE__ */
|
|
500
|
+
}, children: /* @__PURE__ */ jsx5(
|
|
468
501
|
CxBox2,
|
|
469
502
|
{
|
|
470
503
|
className: `uic-group uic-group--${control.id}`,
|
|
@@ -491,31 +524,31 @@ function Group({ control, unit, ctx }) {
|
|
|
491
524
|
event.stopPropagation();
|
|
492
525
|
ctx.host.fire(unit.id, control.id, "click", { domEvent: event.nativeEvent });
|
|
493
526
|
},
|
|
494
|
-
children: foldOpen !== void 0 ? /* @__PURE__ */
|
|
527
|
+
children: foldOpen !== void 0 ? /* @__PURE__ */ jsx5(
|
|
495
528
|
CxDetails,
|
|
496
529
|
{
|
|
497
530
|
open: foldOpen,
|
|
498
531
|
disabled: control.disabled || control.readOnly,
|
|
499
532
|
"data-control-id": control.id,
|
|
500
533
|
rootProps: { className: "uic-fold" },
|
|
501
|
-
summary: /* @__PURE__ */
|
|
534
|
+
summary: /* @__PURE__ */ jsx5(Text, { value: !foldOpen && control.closedLabel ? control.closedLabel : control.label, html: control.html }),
|
|
502
535
|
onOpenChange: (detail) => {
|
|
503
536
|
if (detail.value === foldOpen || detail.reason === "prop") return;
|
|
504
537
|
setFoldOpen(detail.value);
|
|
505
538
|
const trigger = detail.value ? "openFold" : "closeFold";
|
|
506
539
|
if (unit.triggers[control.id]?.includes(trigger)) ctx.host.fire(unit.id, control.id, trigger);
|
|
507
540
|
},
|
|
508
|
-
children: /* @__PURE__ */
|
|
541
|
+
children: /* @__PURE__ */ jsx5(Items, { items: control.disabled || control.readOnly ? control.items.map((item) => isUnit(item) ? item : { ...item, disabled: true }) : control.items, unit, ctx })
|
|
509
542
|
}
|
|
510
543
|
) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
511
|
-
control.label && /* @__PURE__ */
|
|
512
|
-
/* @__PURE__ */
|
|
544
|
+
control.label && /* @__PURE__ */ jsx5(CxTypography2, { variant: "h6", children: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }) }),
|
|
545
|
+
/* @__PURE__ */ jsx5(Items, { items: control.disabled || control.readOnly ? control.items.map((item) => isUnit(item) ? item : { ...item, disabled: true }) : control.items, unit, ctx })
|
|
513
546
|
] })
|
|
514
547
|
}
|
|
515
548
|
) });
|
|
516
549
|
}
|
|
517
550
|
var ControlView = memo(function ControlView2({ control, unit, ctx }) {
|
|
518
|
-
return hasExtendedEvents(unit.triggers[control.id]) ? /* @__PURE__ */
|
|
551
|
+
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
552
|
});
|
|
520
553
|
var ControlBody = memo(function ControlBody2({ control, unit, ctx }) {
|
|
521
554
|
const fire = useFire(ctx.host, unit.id, unit.triggers);
|
|
@@ -526,27 +559,27 @@ var ControlBody = memo(function ControlBody2({ control, unit, ctx }) {
|
|
|
526
559
|
onMouseEnter: () => setHovered(true),
|
|
527
560
|
onMouseLeave: () => setHovered(false)
|
|
528
561
|
};
|
|
529
|
-
const deferred = (family, render) => /* @__PURE__ */
|
|
530
|
-
if (control.parameter) return /* @__PURE__ */
|
|
531
|
-
if (control.submenu) return deferred("menu", (m) => /* @__PURE__ */
|
|
562
|
+
const deferred = (family, render) => /* @__PURE__ */ jsx5(Deferred, { family, render, fallback: () => /* @__PURE__ */ jsx5(Unsupported, { control, detail: "renderer:" + family }) });
|
|
563
|
+
if (control.parameter) return /* @__PURE__ */ jsx5(ParameterEditorView, { control, unit, ctx });
|
|
564
|
+
if (control.submenu) return deferred("menu", (m) => /* @__PURE__ */ jsx5(m.DropdownControl, { control, unit, ctx }));
|
|
532
565
|
switch (control.kind) {
|
|
533
566
|
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__ */
|
|
567
|
+
if (control.contextMenu) return deferred("menu", (m) => /* @__PURE__ */ jsx5(m.ContextMenuControl, { control, unit, ctx }));
|
|
568
|
+
if (control.menu) return deferred("menu", (m) => /* @__PURE__ */ jsx5(m.MenuContents, { control, unit, ctx }));
|
|
569
|
+
if (control.tabMenu && !unit.triggers[control.id]?.length && !control.hoverOnly) return deferred("tab-menu", (m) => /* @__PURE__ */ jsx5(m.TabMenu, { control, unit, ctx }));
|
|
570
|
+
return /* @__PURE__ */ jsx5(Group, { control, unit, ctx });
|
|
538
571
|
case "label": {
|
|
539
|
-
const content = /* @__PURE__ */
|
|
572
|
+
const content = /* @__PURE__ */ jsx5(Text, { value: control.text, html: control.html });
|
|
540
573
|
if (unit.triggers[control.id]?.includes("click")) {
|
|
541
|
-
return /* @__PURE__ */
|
|
574
|
+
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
575
|
}
|
|
543
|
-
return /* @__PURE__ */
|
|
576
|
+
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
577
|
}
|
|
545
578
|
case "button": {
|
|
546
579
|
const name = control.ariaLabel || control.attributes?.["aria-label"] || control.tooltip || control.label || "";
|
|
547
580
|
const title = (disabled ? control.disabledTooltip : void 0) || control.tooltip || control.description;
|
|
548
581
|
if (control.icon && !control.label && !control.href) {
|
|
549
|
-
return /* @__PURE__ */
|
|
582
|
+
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
583
|
CxIconButton,
|
|
551
584
|
{
|
|
552
585
|
...control.attributes,
|
|
@@ -563,7 +596,7 @@ var ControlBody = memo(function ControlBody2({ control, unit, ctx }) {
|
|
|
563
596
|
}
|
|
564
597
|
) }) });
|
|
565
598
|
}
|
|
566
|
-
return /* @__PURE__ */
|
|
599
|
+
return /* @__PURE__ */ jsx5(
|
|
567
600
|
CxButton2,
|
|
568
601
|
{
|
|
569
602
|
...control.attributes,
|
|
@@ -580,57 +613,57 @@ var ControlBody = memo(function ControlBody2({ control, unit, ctx }) {
|
|
|
580
613
|
title: title ?? control.attributes?.title,
|
|
581
614
|
"aria-label": control.ariaLabel ?? control.attributes?.["aria-label"],
|
|
582
615
|
onClick: (event) => activate(control, unit, ctx, event),
|
|
583
|
-
children: control.label ? /* @__PURE__ */
|
|
616
|
+
children: control.label ? /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }) : name
|
|
584
617
|
}
|
|
585
618
|
);
|
|
586
619
|
}
|
|
587
620
|
case "link":
|
|
588
|
-
return /* @__PURE__ */
|
|
621
|
+
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
622
|
case "image": {
|
|
590
|
-
const image = /* @__PURE__ */
|
|
591
|
-
return unit.triggers[control.id]?.includes("click") ? /* @__PURE__ */
|
|
623
|
+
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 });
|
|
624
|
+
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
625
|
}
|
|
593
626
|
case "text":
|
|
594
627
|
case "password":
|
|
595
|
-
return /* @__PURE__ */
|
|
628
|
+
return /* @__PURE__ */ jsx5(TextInput, { control, unit, ctx });
|
|
596
629
|
case "textarea":
|
|
597
|
-
if (control.wysiwyg) return deferred("rich-text", (m) => /* @__PURE__ */
|
|
598
|
-
return /* @__PURE__ */
|
|
630
|
+
if (control.wysiwyg) return deferred("rich-text", (m) => /* @__PURE__ */ jsx5(m.RichTextInput, { control, unit, ctx }));
|
|
631
|
+
return /* @__PURE__ */ jsx5(TextareaInput, { control, unit, ctx });
|
|
599
632
|
case "checkbox":
|
|
600
|
-
return /* @__PURE__ */
|
|
633
|
+
return /* @__PURE__ */ jsx5(CheckboxInput, { control, unit, ctx });
|
|
601
634
|
case "select":
|
|
602
635
|
case "radio":
|
|
603
|
-
return deferred("select", (m) => /* @__PURE__ */
|
|
636
|
+
return deferred("select", (m) => /* @__PURE__ */ jsx5(m.SelectInput, { control, unit, ctx }));
|
|
604
637
|
case "date":
|
|
605
|
-
return deferred("date", (m) => /* @__PURE__ */
|
|
638
|
+
return deferred("date", (m) => /* @__PURE__ */ jsx5(m.DateInput, { control, unit, ctx }));
|
|
606
639
|
case "autocomplete":
|
|
607
|
-
return deferred("autocomplete", (m) => /* @__PURE__ */
|
|
640
|
+
return deferred("autocomplete", (m) => /* @__PURE__ */ jsx5(m.AutocompleteInput, { control, unit, ctx }));
|
|
608
641
|
case "html":
|
|
609
|
-
return /* @__PURE__ */
|
|
642
|
+
return /* @__PURE__ */ jsx5(FreeHtmlView, { control, unit, ctx });
|
|
610
643
|
case "webcomponent":
|
|
611
|
-
return deferred("webcomponent", (m) => /* @__PURE__ */
|
|
644
|
+
return deferred("webcomponent", (m) => /* @__PURE__ */ jsx5(m.WebComponentView, { control, unit, ctx }));
|
|
612
645
|
case "rating":
|
|
613
|
-
return deferred("widgets", (m) => /* @__PURE__ */
|
|
646
|
+
return deferred("widgets", (m) => /* @__PURE__ */ jsx5(m.RatingControl, { control, unit, ctx }));
|
|
614
647
|
case "iframe":
|
|
615
|
-
return deferred("widgets", (m) => /* @__PURE__ */
|
|
648
|
+
return deferred("widgets", (m) => /* @__PURE__ */ jsx5(m.IframeControl, { control }));
|
|
616
649
|
case "time":
|
|
617
|
-
return deferred("widgets", (m) => /* @__PURE__ */
|
|
650
|
+
return deferred("widgets", (m) => /* @__PURE__ */ jsx5(m.TimeControl, { control }));
|
|
618
651
|
case "progress":
|
|
619
|
-
return /* @__PURE__ */
|
|
652
|
+
return /* @__PURE__ */ jsx5(CxProgressBar, { "data-control-id": control.id, value: control.value, label: control.ariaLabel ?? control.label ?? "" });
|
|
620
653
|
case "chart":
|
|
621
|
-
return /* @__PURE__ */
|
|
654
|
+
return /* @__PURE__ */ jsx5(Unsupported, { control, detail: "chart" });
|
|
622
655
|
case "media":
|
|
623
|
-
if (unsupportedMediaTypes.has(control.mediaType)) return /* @__PURE__ */
|
|
624
|
-
return deferred("media", (m) => /* @__PURE__ */
|
|
656
|
+
if (unsupportedMediaTypes.has(control.mediaType)) return /* @__PURE__ */ jsx5(Unsupported, { control, detail: `media:${control.mediaType}` });
|
|
657
|
+
return deferred("media", (m) => /* @__PURE__ */ jsx5(m.MediaView, { control, unit, host: ctx.host }));
|
|
625
658
|
case "table":
|
|
626
|
-
return deferred("table", (m) => /* @__PURE__ */
|
|
659
|
+
return deferred("table", (m) => /* @__PURE__ */ jsx5(m.TableInput, { control, unit, ctx }));
|
|
627
660
|
default:
|
|
628
|
-
return /* @__PURE__ */
|
|
661
|
+
return /* @__PURE__ */ jsx5(Unsupported, { control, detail: control.type });
|
|
629
662
|
}
|
|
630
663
|
}, (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
664
|
var unsupportedMediaTypes = /* @__PURE__ */ new Set(["video", "document"]);
|
|
632
665
|
function Unsupported({ control, detail }) {
|
|
633
|
-
return /* @__PURE__ */
|
|
666
|
+
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
667
|
}
|
|
635
668
|
function inputAccessibility(control) {
|
|
636
669
|
return {
|
|
@@ -641,7 +674,7 @@ function inputAccessibility(control) {
|
|
|
641
674
|
function TextInput({ control, unit, ctx }) {
|
|
642
675
|
const [value, setValue] = useControlValue(ctx.host, unit.id, control.id, unit.inputs[control.id]);
|
|
643
676
|
const fire = useFire(ctx.host, unit.id, unit.triggers);
|
|
644
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ jsx5(
|
|
645
678
|
CxInput,
|
|
646
679
|
{
|
|
647
680
|
...inputAccessibility(control),
|
|
@@ -650,7 +683,7 @@ function TextInput({ control, unit, ctx }) {
|
|
|
650
683
|
autoComplete: control.kind === "password" ? "new-password" : "on",
|
|
651
684
|
autoFocus: control.autoFocus,
|
|
652
685
|
invalid: Boolean(control.warning),
|
|
653
|
-
label: /* @__PURE__ */
|
|
686
|
+
label: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }),
|
|
654
687
|
helpText: control.warning || control.description,
|
|
655
688
|
value,
|
|
656
689
|
placeholder: control.placeholder,
|
|
@@ -667,18 +700,22 @@ function TextInput({ control, unit, ctx }) {
|
|
|
667
700
|
);
|
|
668
701
|
}
|
|
669
702
|
function TextareaInput({ control, unit, ctx }) {
|
|
703
|
+
const parameterInput = useContext3(ParameterInputContext);
|
|
704
|
+
const autoSize = parameterInput?.unitId === unit.id && parameterInput.controlId === control.id;
|
|
670
705
|
const [value, setValue] = useControlValue(ctx.host, unit.id, control.id, unit.inputs[control.id]);
|
|
671
706
|
const fire = useFire(ctx.host, unit.id, unit.triggers);
|
|
672
|
-
if (control.wysiwyg) return /* @__PURE__ */
|
|
673
|
-
return /* @__PURE__ */
|
|
707
|
+
if (control.wysiwyg) return /* @__PURE__ */ jsx5(Unsupported, { control, detail: "wysiwyg" });
|
|
708
|
+
return /* @__PURE__ */ jsx5(
|
|
674
709
|
CxTextarea,
|
|
675
710
|
{
|
|
676
711
|
...inputAccessibility(control),
|
|
712
|
+
rows: autoSize ? 1 : void 0,
|
|
713
|
+
resize: autoSize ? "auto" : void 0,
|
|
677
714
|
maxLength: control.maxLength && control.maxLength > 0 ? control.maxLength : void 0,
|
|
678
715
|
"data-control-id": control.id,
|
|
679
716
|
autoFocus: control.autoFocus,
|
|
680
717
|
invalid: Boolean(control.warning),
|
|
681
|
-
label: /* @__PURE__ */
|
|
718
|
+
label: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html }),
|
|
682
719
|
helpText: control.warning || control.description,
|
|
683
720
|
value,
|
|
684
721
|
placeholder: control.placeholder,
|
|
@@ -697,7 +734,7 @@ function CheckboxInput({ control, unit, ctx }) {
|
|
|
697
734
|
const [value, setValue] = useControlValue(ctx.host, unit.id, control.id, unit.inputs[control.id]);
|
|
698
735
|
const fire = useFire(ctx.host, unit.id, unit.triggers);
|
|
699
736
|
const Checkbox = control.appearance === "switch" ? CxSwitch : CxCheckbox;
|
|
700
|
-
return /* @__PURE__ */
|
|
737
|
+
return /* @__PURE__ */ jsx5(
|
|
701
738
|
Checkbox,
|
|
702
739
|
{
|
|
703
740
|
"data-control-id": control.id,
|
|
@@ -711,21 +748,21 @@ function CheckboxInput({ control, unit, ctx }) {
|
|
|
711
748
|
const trigger = unit.triggers[control.id]?.includes("click") ? "click" : "change";
|
|
712
749
|
if (unit.triggers[control.id]?.includes(trigger)) fire(control.id, trigger);
|
|
713
750
|
},
|
|
714
|
-
children: /* @__PURE__ */
|
|
751
|
+
children: /* @__PURE__ */ jsx5(Text, { value: control.label, html: control.html })
|
|
715
752
|
}
|
|
716
753
|
);
|
|
717
754
|
}
|
|
718
755
|
var CREATE_ENTRY_VALUE = "%CREATE_ENTRY%";
|
|
719
756
|
|
|
720
757
|
export {
|
|
721
|
-
registerRendererLoaders,
|
|
722
|
-
rendererFamilyNames,
|
|
723
|
-
rendererFamiliesOf,
|
|
724
|
-
loadRendererFamilies,
|
|
725
758
|
hasExtendedEvents,
|
|
726
759
|
EventBoundary,
|
|
727
760
|
findMenu,
|
|
728
761
|
isDropdownPanel,
|
|
762
|
+
createRendererRegistry,
|
|
763
|
+
RendererRegistryContext,
|
|
764
|
+
rendererFamilyNames,
|
|
765
|
+
rendererFamiliesOf,
|
|
729
766
|
iconName,
|
|
730
767
|
Text,
|
|
731
768
|
Items,
|
package/dist/contracts/unit.d.ts
CHANGED
|
@@ -58,6 +58,16 @@ export interface ParameterEditor {
|
|
|
58
58
|
readonly info?: string;
|
|
59
59
|
readonly hideInput?: boolean;
|
|
60
60
|
readonly readOnly?: boolean;
|
|
61
|
+
/** Effective configured origin indicator. Absent on older units or when the legacy indicator is hidden. */
|
|
62
|
+
readonly origin?: ParameterOrigin;
|
|
63
|
+
}
|
|
64
|
+
export interface ParameterOrigin {
|
|
65
|
+
readonly kind: 'profile' | 'local-session' | 'user-session';
|
|
66
|
+
/** Canonical hexadecimal color; never a CSS declaration or a skin class. */
|
|
67
|
+
readonly color: string;
|
|
68
|
+
readonly inherited?: boolean;
|
|
69
|
+
/** Profile depth in the bounded range 0..255. */
|
|
70
|
+
readonly depth?: number;
|
|
61
71
|
}
|
|
62
72
|
export interface InputNode extends NodeBase {
|
|
63
73
|
readonly required?: boolean;
|
package/dist/runtime/index.css
CHANGED
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-AK4GIOIA.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-ZHDSD2DT.js"),
|
|
171
|
+
date: () => import("../date-3ERTXTH6.js"),
|
|
172
|
+
autocomplete: () => import("../autocomplete-X6EHYE3C.js"),
|
|
173
|
+
"rich-text": () => import("../rich-text-WW3QDJRD.js"),
|
|
174
|
+
table: () => import("../table-FELNJICP.js"),
|
|
175
|
+
media: () => import("../media-IECUTXW5.js"),
|
|
176
|
+
webcomponent: () => import("../webcomponent-WSHWI6TX.js"),
|
|
177
|
+
widgets: () => import("../widgets-ZTPJN5LP.js"),
|
|
178
|
+
menu: () => import("../menu-3VTEQUFY.js"),
|
|
179
|
+
"tab-menu": () => import("../tab-menu-BCHQQXDF.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-WSHWI6TX.js",
|
|
118
|
+
"widgets": "widgets-ZTPJN5LP.js",
|
|
119
|
+
"menu": "menu-3VTEQUFY.js",
|
|
120
|
+
"tab-menu": "tab-menu-BCHQQXDF.js",
|
|
121
|
+
"select": "select-ZHDSD2DT.js",
|
|
122
|
+
"date": "date-3ERTXTH6.js",
|
|
123
|
+
"autocomplete": "autocomplete-X6EHYE3C.js",
|
|
124
|
+
"rich-text": "rich-text-WW3QDJRD.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.9",
|
|
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.9",
|
|
49
49
|
"react": "^19.3.0",
|
|
50
50
|
"react-dom": "^19.3.0"
|
|
51
51
|
},
|