@aglyn/aglyn 1.20.3 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +11 -11
- package/src/lib/app-utils/docs-index.generated.js +5 -5
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/native-besigner-back.d.ts +60 -0
- package/src/lib/app-utils/native-besigner-back.js +97 -0
- package/src/lib/app-utils/native-besigner-back.js.map +1 -0
- package/src/lib/app-utils/variables.js +13 -6
- package/src/lib/app-utils/variables.js.map +1 -1
- package/src/lib/foundation/definitions/components.types.d.ts +11 -0
- package/src/lib/foundation/definitions/components.types.js.map +1 -1
- package/src/lib/types/nodes.d.ts +18 -2
- package/src/lib/types/nodes.js.map +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* The Besigner's own way back inside the native apps (AGL-4056).
|
|
19
|
+
*
|
|
20
|
+
* In the apps the editor has no native head and no Done button: the editor's
|
|
21
|
+
* own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and
|
|
22
|
+
* back gesture all press it, so whatever that control does first (a prompt,
|
|
23
|
+
* a save) happens the same for every one of them. The control goes to the
|
|
24
|
+
* document's `/view`, which the apps read as "leave the editor".
|
|
25
|
+
*
|
|
26
|
+
* The apps reach the control by this id: native code clicks it from a script
|
|
27
|
+
* (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's
|
|
28
|
+
* hook clicks it for the keys the web view receives itself.
|
|
29
|
+
*/
|
|
30
|
+
export declare const NATIVE_BESIGNER_BACK_CONTROL_ID = "aglyn-besigner-back";
|
|
31
|
+
/** What a key event needs for the decision, so a spec can hand in a plain object. */
|
|
32
|
+
export interface BackKeyEvent {
|
|
33
|
+
key: string;
|
|
34
|
+
metaKey: boolean;
|
|
35
|
+
ctrlKey: boolean;
|
|
36
|
+
altKey: boolean;
|
|
37
|
+
shiftKey: boolean;
|
|
38
|
+
defaultPrevented: boolean;
|
|
39
|
+
target: EventTarget | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether a key leaves the editor through its back control: Esc on its own
|
|
43
|
+
* when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.
|
|
44
|
+
*
|
|
45
|
+
* Esc never leaves while a field has the focus, while something is open over
|
|
46
|
+
* the editor, or when the page already handled it (a pick in progress, an
|
|
47
|
+
* inline editor reverting): those are the Esc a person meant for them.
|
|
48
|
+
*/
|
|
49
|
+
export declare function backKeyLeavesEditor(event: BackKeyEvent, doc: Pick<Document, 'querySelectorAll'>, mac: boolean): boolean;
|
|
50
|
+
/** Presses the editor's back control; false when the page has none. */
|
|
51
|
+
export declare function pressBesignerBack(doc: Pick<Document, 'getElementById'>): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Inside the apps' web view, Esc and ⌘[ press the editor's back control.
|
|
54
|
+
* Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[
|
|
55
|
+
* exactly as they were.
|
|
56
|
+
*
|
|
57
|
+
* It listens after the page's own handlers (bubbling, on the window), so a
|
|
58
|
+
* handler that took the key first stops it reaching here.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useNativeBesignerBackKeys(enabled: boolean): void;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { useEffect } from "react";
|
|
17
|
+
/**
|
|
18
|
+
* The Besigner's own way back inside the native apps (AGL-4056).
|
|
19
|
+
*
|
|
20
|
+
* In the apps the editor has no native head and no Done button: the editor's
|
|
21
|
+
* own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and
|
|
22
|
+
* back gesture all press it, so whatever that control does first (a prompt,
|
|
23
|
+
* a save) happens the same for every one of them. The control goes to the
|
|
24
|
+
* document's `/view`, which the apps read as "leave the editor".
|
|
25
|
+
*
|
|
26
|
+
* The apps reach the control by this id: native code clicks it from a script
|
|
27
|
+
* (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's
|
|
28
|
+
* hook clicks it for the keys the web view receives itself.
|
|
29
|
+
*/ export const NATIVE_BESIGNER_BACK_CONTROL_ID = 'aglyn-besigner-back';
|
|
30
|
+
/** Whether `target` takes typing: a field, a select, or editable content. */ function takesTyping(target) {
|
|
31
|
+
const element = target;
|
|
32
|
+
if (!element || typeof element.tagName !== 'string') return false;
|
|
33
|
+
const tag = element.tagName.toLowerCase();
|
|
34
|
+
if (tag === 'input' || tag === 'textarea' || tag === 'select') return true;
|
|
35
|
+
return Boolean(element.isContentEditable) || (element.getAttribute == null ? void 0 : element.getAttribute.call(element, 'contenteditable')) === 'true';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Something open over the editor that Esc should close first: a dialog, a
|
|
39
|
+
* menu, a popover or a picker's list. MUI marks every one of them with these
|
|
40
|
+
* roles; one kept mounted while closed sits inside a hidden modal.
|
|
41
|
+
*/ const OPEN_OVER_EDITOR = '[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], .MuiPopover-root';
|
|
42
|
+
const CLOSED = '.MuiModal-hidden, [aria-hidden="true"], [hidden]';
|
|
43
|
+
function somethingOpenOverEditor(doc) {
|
|
44
|
+
return Array.from(doc.querySelectorAll(OPEN_OVER_EDITOR)).some((element)=>!element.closest(CLOSED));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Whether a key leaves the editor through its back control: Esc on its own
|
|
48
|
+
* when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.
|
|
49
|
+
*
|
|
50
|
+
* Esc never leaves while a field has the focus, while something is open over
|
|
51
|
+
* the editor, or when the page already handled it (a pick in progress, an
|
|
52
|
+
* inline editor reverting): those are the Esc a person meant for them.
|
|
53
|
+
*/ export function backKeyLeavesEditor(event, doc, mac) {
|
|
54
|
+
if (event.defaultPrevented) return false;
|
|
55
|
+
if (event.key === '[') {
|
|
56
|
+
const command = mac ? event.metaKey : event.ctrlKey;
|
|
57
|
+
return command && !event.altKey && !event.shiftKey;
|
|
58
|
+
}
|
|
59
|
+
if (event.key !== 'Escape' && event.key !== 'Esc') return false;
|
|
60
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return false;
|
|
61
|
+
if (takesTyping(event.target)) return false;
|
|
62
|
+
return !somethingOpenOverEditor(doc);
|
|
63
|
+
}
|
|
64
|
+
/** Presses the editor's back control; false when the page has none. */ export function pressBesignerBack(doc) {
|
|
65
|
+
const control = doc.getElementById(NATIVE_BESIGNER_BACK_CONTROL_ID);
|
|
66
|
+
if (!control) return false;
|
|
67
|
+
control.click();
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
/** Whether this browser is on a Mac (where ⌘ is the command key). */ function onMac() {
|
|
71
|
+
if (typeof navigator === 'undefined') return false;
|
|
72
|
+
return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || '');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Inside the apps' web view, Esc and ⌘[ press the editor's back control.
|
|
76
|
+
* Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[
|
|
77
|
+
* exactly as they were.
|
|
78
|
+
*
|
|
79
|
+
* It listens after the page's own handlers (bubbling, on the window), so a
|
|
80
|
+
* handler that took the key first stops it reaching here.
|
|
81
|
+
*/ export function useNativeBesignerBackKeys(enabled) {
|
|
82
|
+
useEffect(()=>{
|
|
83
|
+
if (!enabled || typeof window === 'undefined') return;
|
|
84
|
+
const mac = onMac();
|
|
85
|
+
const onKeyDown = (event)=>{
|
|
86
|
+
if (!backKeyLeavesEditor(event, document, mac)) return;
|
|
87
|
+
if (!pressBesignerBack(document)) return;
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
};
|
|
90
|
+
window.addEventListener('keydown', onKeyDown);
|
|
91
|
+
return ()=>window.removeEventListener('keydown', onKeyDown);
|
|
92
|
+
}, [
|
|
93
|
+
enabled
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=native-besigner-back.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/native-besigner-back.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react'\n\n/**\n * The Besigner's own way back inside the native apps (AGL-4056).\n *\n * In the apps the editor has no native head and no Done button: the editor's\n * own back control is the one way out, and the apps' Esc, ⌘[ (Ctrl+[) and\n * back gesture all press it, so whatever that control does first (a prompt,\n * a save) happens the same for every one of them. The control goes to the\n * document's `/view`, which the apps read as \"leave the editor\".\n *\n * The apps reach the control by this id: native code clicks it from a script\n * (`BesignerEntry.backScript` in the Swift and Kotlin kits), and this file's\n * hook clicks it for the keys the web view receives itself.\n */\nexport const NATIVE_BESIGNER_BACK_CONTROL_ID = 'aglyn-besigner-back'\n\n/** What a key event needs for the decision, so a spec can hand in a plain object. */\nexport interface BackKeyEvent {\n key: string\n metaKey: boolean\n ctrlKey: boolean\n altKey: boolean\n shiftKey: boolean\n defaultPrevented: boolean\n target: EventTarget | null\n}\n\n/** Whether `target` takes typing: a field, a select, or editable content. */\nfunction takesTyping(target: EventTarget | null): boolean {\n const element = target as HTMLElement | null\n if (!element || typeof element.tagName !== 'string') return false\n const tag = element.tagName.toLowerCase()\n if (tag === 'input' || tag === 'textarea' || tag === 'select') return true\n return Boolean(element.isContentEditable) || element.getAttribute?.('contenteditable') === 'true'\n}\n\n/**\n * Something open over the editor that Esc should close first: a dialog, a\n * menu, a popover or a picker's list. MUI marks every one of them with these\n * roles; one kept mounted while closed sits inside a hidden modal.\n */\nconst OPEN_OVER_EDITOR =\n '[role=\"dialog\"], [role=\"alertdialog\"], [role=\"menu\"], [role=\"listbox\"], .MuiPopover-root'\nconst CLOSED = '.MuiModal-hidden, [aria-hidden=\"true\"], [hidden]'\n\nfunction somethingOpenOverEditor(doc: Pick<Document, 'querySelectorAll'>): boolean {\n return Array.from(doc.querySelectorAll(OPEN_OVER_EDITOR)).some(\n (element) => !element.closest(CLOSED),\n )\n}\n\n/**\n * Whether a key leaves the editor through its back control: Esc on its own\n * when nothing else wanted it, or ⌘[ (Ctrl+[ off a Mac) at any time.\n *\n * Esc never leaves while a field has the focus, while something is open over\n * the editor, or when the page already handled it (a pick in progress, an\n * inline editor reverting): those are the Esc a person meant for them.\n */\nexport function backKeyLeavesEditor(\n event: BackKeyEvent,\n doc: Pick<Document, 'querySelectorAll'>,\n mac: boolean,\n): boolean {\n if (event.defaultPrevented) return false\n if (event.key === '[') {\n const command = mac ? event.metaKey : event.ctrlKey\n return command && !event.altKey && !event.shiftKey\n }\n if (event.key !== 'Escape' && event.key !== 'Esc') return false\n if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return false\n if (takesTyping(event.target)) return false\n return !somethingOpenOverEditor(doc)\n}\n\n/** Presses the editor's back control; false when the page has none. */\nexport function pressBesignerBack(doc: Pick<Document, 'getElementById'>): boolean {\n const control = doc.getElementById(NATIVE_BESIGNER_BACK_CONTROL_ID)\n if (!control) return false\n control.click()\n return true\n}\n\n/** Whether this browser is on a Mac (where ⌘ is the command key). */\nfunction onMac(): boolean {\n if (typeof navigator === 'undefined') return false\n return /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || '')\n}\n\n/**\n * Inside the apps' web view, Esc and ⌘[ press the editor's back control.\n * Off (`enabled` false) it adds nothing, so a browser tab keeps Esc and ⌘[\n * exactly as they were.\n *\n * It listens after the page's own handlers (bubbling, on the window), so a\n * handler that took the key first stops it reaching here.\n */\nexport function useNativeBesignerBackKeys(enabled: boolean): void {\n useEffect(() => {\n if (!enabled || typeof window === 'undefined') return\n const mac = onMac()\n const onKeyDown = (event: KeyboardEvent) => {\n if (!backKeyLeavesEditor(event, document, mac)) return\n if (!pressBesignerBack(document)) return\n event.preventDefault()\n }\n window.addEventListener('keydown', onKeyDown)\n return () => window.removeEventListener('keydown', onKeyDown)\n }, [enabled])\n}\n"],"names":["useEffect","NATIVE_BESIGNER_BACK_CONTROL_ID","takesTyping","target","element","tagName","tag","toLowerCase","Boolean","isContentEditable","getAttribute","OPEN_OVER_EDITOR","CLOSED","somethingOpenOverEditor","doc","Array","from","querySelectorAll","some","closest","backKeyLeavesEditor","event","mac","defaultPrevented","key","command","metaKey","ctrlKey","altKey","shiftKey","pressBesignerBack","control","getElementById","click","onMac","navigator","test","platform","userAgent","useNativeBesignerBackKeys","enabled","window","onKeyDown","document","preventDefault","addEventListener","removeEventListener"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,SAAS,QAAQ,QAAO;AAEjC;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC,kCAAkC,sBAAqB;AAapE,2EAA2E,GAC3E,SAASC,YAAYC,MAA0B;IAC7C,MAAMC,UAAUD;IAChB,IAAI,CAACC,WAAW,OAAOA,QAAQC,OAAO,KAAK,UAAU,OAAO;IAC5D,MAAMC,MAAMF,QAAQC,OAAO,CAACE,WAAW;IACvC,IAAID,QAAQ,WAAWA,QAAQ,cAAcA,QAAQ,UAAU,OAAO;IACtE,OAAOE,QAAQJ,QAAQK,iBAAiB,KAAKL,CAAAA,QAAQM,YAAY,oBAApBN,QAAQM,YAAY,MAApBN,SAAuB,wBAAuB;AAC7F;AAEA;;;;CAIC,GACD,MAAMO,mBACJ;AACF,MAAMC,SAAS;AAEf,SAASC,wBAAwBC,GAAuC;IACtE,OAAOC,MAAMC,IAAI,CAACF,IAAIG,gBAAgB,CAACN,mBAAmBO,IAAI,CAC5D,CAACd,UAAY,CAACA,QAAQe,OAAO,CAACP;AAElC;AAEA;;;;;;;CAOC,GACD,OAAO,SAASQ,oBACdC,KAAmB,EACnBP,GAAuC,EACvCQ,GAAY;IAEZ,IAAID,MAAME,gBAAgB,EAAE,OAAO;IACnC,IAAIF,MAAMG,GAAG,KAAK,KAAK;QACrB,MAAMC,UAAUH,MAAMD,MAAMK,OAAO,GAAGL,MAAMM,OAAO;QACnD,OAAOF,WAAW,CAACJ,MAAMO,MAAM,IAAI,CAACP,MAAMQ,QAAQ;IACpD;IACA,IAAIR,MAAMG,GAAG,KAAK,YAAYH,MAAMG,GAAG,KAAK,OAAO,OAAO;IAC1D,IAAIH,MAAMK,OAAO,IAAIL,MAAMM,OAAO,IAAIN,MAAMO,MAAM,IAAIP,MAAMQ,QAAQ,EAAE,OAAO;IAC7E,IAAI3B,YAAYmB,MAAMlB,MAAM,GAAG,OAAO;IACtC,OAAO,CAACU,wBAAwBC;AAClC;AAEA,qEAAqE,GACrE,OAAO,SAASgB,kBAAkBhB,GAAqC;IACrE,MAAMiB,UAAUjB,IAAIkB,cAAc,CAAC/B;IACnC,IAAI,CAAC8B,SAAS,OAAO;IACrBA,QAAQE,KAAK;IACb,OAAO;AACT;AAEA,mEAAmE,GACnE,SAASC;IACP,IAAI,OAAOC,cAAc,aAAa,OAAO;IAC7C,OAAO,uBAAuBC,IAAI,CAACD,UAAUE,QAAQ,IAAIF,UAAUG,SAAS,IAAI;AAClF;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,0BAA0BC,OAAgB;IACxDxC,UAAU;QACR,IAAI,CAACwC,WAAW,OAAOC,WAAW,aAAa;QAC/C,MAAMnB,MAAMY;QACZ,MAAMQ,YAAY,CAACrB;YACjB,IAAI,CAACD,oBAAoBC,OAAOsB,UAAUrB,MAAM;YAChD,IAAI,CAACQ,kBAAkBa,WAAW;YAClCtB,MAAMuB,cAAc;QACtB;QACAH,OAAOI,gBAAgB,CAAC,WAAWH;QACnC,OAAO,IAAMD,OAAOK,mBAAmB,CAAC,WAAWJ;IACrD,GAAG;QAACF;KAAQ;AACd"}
|
|
@@ -209,9 +209,12 @@ export const VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]{0,39}$/;
|
|
|
209
209
|
* option lists) pass through untouched; unsafe values in hrefs remain
|
|
210
210
|
* covered by the render-time SAFE_HREF/sanitizer checks.
|
|
211
211
|
*/ export function resolveNodesBindings(nodes, variables, functions = {}) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
// No early return for a site with no variables: its `{{var:id}}` tokens
|
|
213
|
+
// still have to render EMPTY (a deleted variable, a plugin connection that
|
|
214
|
+
// was disconnected), or the raw token reaches visitors. Only a node whose
|
|
215
|
+
// text actually changes is copied, so a page with nothing to resolve comes
|
|
216
|
+
// back as the same map.
|
|
217
|
+
let anyChanged = false;
|
|
215
218
|
const next = {};
|
|
216
219
|
for (const [id, node] of Object.entries(nodes)){
|
|
217
220
|
const props = node == null ? void 0 : node.props;
|
|
@@ -223,15 +226,19 @@ export const VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]{0,39}$/;
|
|
|
223
226
|
const nextProps = _extends({}, props);
|
|
224
227
|
for (const [key, value] of Object.entries(props)){
|
|
225
228
|
if (typeof value === 'string' && hasBindings(value)) {
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
const resolved = resolveBindings(value, variables, functions);
|
|
230
|
+
if (resolved !== value) {
|
|
231
|
+
nextProps[key] = resolved;
|
|
232
|
+
changed = true;
|
|
233
|
+
}
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
next[id] = changed ? _extends({}, node, {
|
|
231
237
|
props: nextProps
|
|
232
238
|
}) : node;
|
|
239
|
+
anyChanged = anyChanged || changed;
|
|
233
240
|
}
|
|
234
|
-
return next;
|
|
241
|
+
return anyChanged ? next : nodes;
|
|
235
242
|
}
|
|
236
243
|
|
|
237
244
|
//# sourceMappingURL=variables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/variables.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Token grammar shared with the picker/besigner (AGL-185/194): id-form\n// tokens only — legacy name resolution retired after the production\n// content migration ran clean.\nimport {\n FUNCTION_TOKEN_PATTERN,\n VARIABLE_ID_TOKEN_PATTERN,\n} from './binding-tokens'\nimport {\n evaluateExpression,\n evaluateHostFunction,\n functionReferencedNames,\n type HostFunction,\n} from './functions'\n\n/**\n * Host variables (Component Builder, AGL-91): typed values authored in the\n * console and bound into component text props with `{{name}}` — and, since\n * AGL-93, function results with `{{fn:name(args)}}`. Pure data module\n * shared by the console editor UI and the tenant compose pipeline.\n */\n\n/** Types from the mockup's Edit Variable dialog (\"Function\" lands with AGL-92). */\nexport type HostVariableType =\n | 'date'\n | 'time'\n | 'text'\n | 'number'\n | 'boolean'\n | 'dictionary'\n | 'collection'\n\nexport const HOST_VARIABLE_TYPE_LABELS: Record<HostVariableType, string> = {\n date: 'Date',\n time: 'Time',\n text: 'Plain text',\n number: 'Number',\n boolean: 'True/false (boolean)',\n dictionary: 'Dictionary (key: value)',\n collection: 'Collection list (values)',\n}\n\n/**\n * `hosts/{hostId}/variables/{id}` doc, as far as binding reads it.\n *\n * A COMPUTED variable also carries the reference its computing plugin reads\n * — which record produces its value — and `value` is then the fallback the\n * page shows when that record is gone or fails. Binding never reads the\n * reference; the plugin that computes the value types and reads its own\n * (`plugin-manager/computed-variables`).\n */\nexport interface HostVariable {\n /** Binding identifier — `{{name}}`. */\n name: string\n type: HostVariableType\n /** Persisted as a string; formatted per type at resolve time. */\n value?: string\n}\n\nexport const VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]{0,39}$/\n\n/** Whether `name` may name a variable or a function's parameter (`VARIABLE_NAME_PATTERN`). */\nexport function isVariableName(name: string): boolean {\n return VARIABLE_NAME_PATTERN.test(name)\n}\n\n/** Human-readable rendering of a variable's value for text interpolation. */\nexport function formatVariableValue(variable: HostVariable): string {\n const raw = variable.value ?? ''\n switch (variable.type) {\n case 'boolean':\n return raw === 'true' ? 'true' : 'false'\n case 'number': {\n const parsed = Number(raw)\n return Number.isFinite(parsed) ? String(parsed) : ''\n }\n case 'date': {\n const parsed = new Date(raw)\n return Number.isNaN(parsed.getTime())\n ? raw\n : parsed.toLocaleDateString(undefined, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n timeZone: 'UTC',\n })\n }\n case 'dictionary':\n case 'collection': {\n // Stored as JSON; render collections comma-joined and dictionaries\n // as `key: value` pairs so a bare {{name}} stays readable.\n try {\n const parsed = JSON.parse(raw)\n if (Array.isArray(parsed)) return parsed.map(String).join(', ')\n if (parsed && typeof parsed === 'object') {\n return Object.entries(parsed)\n .map(([key, value]) => `${key}: ${value}`)\n .join(', ')\n }\n } catch {\n // fall through to the raw string\n }\n return raw\n }\n case 'time':\n case 'text':\n default:\n return raw\n }\n}\n\n/** A function definition lookup keyed by function name (AGL-93). */\nexport type HostFunctionLookup = Record<string, HostFunction>\n\n/**\n * Variable values as an expression scope (numbers stay numeric). Keyed by\n * each doc's NAME regardless of how the lookup map is keyed (AGL-194:\n * maps are id-keyed now, but expressions reference variables by name).\n */\nfunction variableScope(\n variables: Record<string, HostVariable>,\n): Record<string, number | string | boolean> {\n const scope: Record<string, number | string | boolean> = {}\n for (const variable of Object.values(variables)) {\n if (!variable?.name) continue\n if (variable.type === 'number') {\n scope[variable.name] = Number(variable.value ?? 0)\n } else if (variable.type === 'boolean') {\n scope[variable.name] = variable.value === 'true'\n } else {\n scope[variable.name] = variable.value ?? ''\n }\n }\n return scope\n}\n\n/**\n * Replaces binding tokens with values (AGL-91/93/185/194): id forms\n * `{{var:id}}` / `{{fn:id(args)}}` resolve through id-keyed lookup maps.\n * Function args are expressions over literals and variable NAMES (the\n * scope keys by each doc's name). Unknown function refs keep the literal\n * token; unknown variable ids render empty; bare `{{name}}` strings are\n * plain text since the legacy fallback retired.\n */\nexport function resolveBindings(\n text: string,\n variables: Record<string, HostVariable>,\n functions: HostFunctionLookup = {},\n): string {\n const withVariableIds = text.replace(\n VARIABLE_ID_TOKEN_PATTERN,\n (_token, id) => {\n const variable = variables[String(id)]\n // Unknown ids render EMPTY, not literal (AGL-186): a raw doc id is\n // meaningless to visitors, unlike a readable legacy {{name}} token.\n return variable ? formatVariableValue(variable) : ''\n },\n )\n const withFunctions = withVariableIds.replace(\n FUNCTION_TOKEN_PATTERN,\n (token, rawName, rawArgs) => {\n const definition = functions[String(rawName).trim()]\n if (!definition) return token\n try {\n const scope = variableScope(variables)\n const argValues = String(rawArgs)\n .split(',')\n .map((argument) => argument.trim())\n .filter((argument) => argument.length > 0)\n .map((argument) => evaluateExpression(argument, scope))\n const args: Record<string, unknown> = {}\n definition.parameters?.forEach((parameter, index) => {\n args[parameter.name] = argValues[index]\n })\n // The site's variables are the function's outer scope (AGL-3202),\n // so `{{fn:id(25)}}` can price 25 sites without every rate being\n // passed in by position. Arguments still win over a variable of the\n // same name, as every parameter does.\n const result = evaluateHostFunction(definition, args, {\n globals: scope,\n })\n return result.ok ? String(result.value) : token\n } catch {\n return token\n }\n },\n )\n // Legacy {{name}} resolution retired (AGL-194): the production content\n // migration ran clean, so bare-name tokens are plain text now. Typing\n // them in the editor still works — save-time normalization converts\n // known names to id tokens before they persist.\n return withFunctions\n}\n\n/** Fast pre-check so binding-free content skips the walk entirely. */\nexport function hasBindings(text: string): boolean {\n return /\\{\\{/.test(text)\n}\n\n/**\n * The site variables ONE function reads, by name (AGL-3202).\n *\n * A widget runs in the visitor's browser, so whatever it may read has to be\n * on the page. Handing it the whole variable list would publish every value\n * a site holds to every page that places a calculator; this hands over the\n * names the function's own expressions use and nothing else. A name the\n * function declares itself is not a variable read — its parameter or local\n * shadows the variable — so it is not shipped either.\n */\nexport function functionGlobals(\n definition: HostFunction,\n variables: Record<string, HostVariable>,\n): Record<string, number | string | boolean> {\n const scope = variableScope(variables)\n const globals: Record<string, number | string | boolean> = {}\n for (const name of functionReferencedNames(definition)) {\n if (Object.prototype.hasOwnProperty.call(scope, name)) {\n globals[name] = scope[name]\n }\n }\n return globals\n}\n\n/**\n * Injects each function-running element's definition into its props at\n * compose time (AGL-93): the client runs the shared evaluator locally, so the\n * published page carries the definition instead of calling home. Unknown\n * names leave the node untouched (the element renders its editor\n * placeholder).\n *\n * Which elements run a function is DECLARED (AGL-3393): `bindings` maps a\n * component id to the prop that names its function, collected from each\n * plugin's `contributes.site.functionBindings`. Core names no element, so a\n * marketplace plugin's element is bound exactly as a first-party one is, and\n * an element nobody declared is never handed a definition.\n *\n * With `variables`, the site variables that function reads ride along as\n * `globals` (AGL-3202) — see {@link functionGlobals} for why it is only\n * those. The key is omitted when the function reads none, so a page built\n * before this existed serializes exactly as it did.\n */\nexport function attachFunctionDefinitions<T extends Record<string, any>>(\n nodes: T,\n functions: HostFunctionLookup,\n variables: Record<string, HostVariable>,\n bindings: Readonly<Record<string, string>>,\n): T {\n if (!Object.keys(functions).length || !Object.keys(bindings).length) {\n return nodes\n }\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const componentId = node?.componentId\n const prop =\n typeof componentId === 'string' &&\n Object.prototype.hasOwnProperty.call(bindings, componentId)\n ? bindings[componentId]\n : undefined\n const name = prop ? node?.props?.[prop] : undefined\n const definition = name ? functions[String(name).trim()] : undefined\n if (!definition) {\n next[id] = node\n continue\n }\n const globals = functionGlobals(definition, variables)\n next[id] = {\n ...node,\n props: {\n ...node.props,\n definition,\n ...(Object.keys(globals).length ? { globals } : {}),\n },\n }\n }\n return next as T\n}\n\n/**\n * Applies `resolveBindings` to every string prop across a normalized nodes\n * map (mutating a shallow copy). String props only — objects/arrays (sx,\n * option lists) pass through untouched; unsafe values in hrefs remain\n * covered by the render-time SAFE_HREF/sanitizer checks.\n */\nexport function resolveNodesBindings<T extends Record<string, any>>(\n nodes: T,\n variables: Record<string, HostVariable>,\n functions: HostFunctionLookup = {},\n): T {\n if (!Object.keys(variables).length && !Object.keys(functions).length) {\n return nodes\n }\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const props = node?.props\n if (!props) {\n next[id] = node\n continue\n }\n let changed = false\n const nextProps: Record<string, unknown> = { ...props }\n for (const [key, value] of Object.entries(props)) {\n if (typeof value === 'string' && hasBindings(value)) {\n nextProps[key] = resolveBindings(value, variables, functions)\n changed = true\n }\n }\n next[id] = changed ? { ...node, props: nextProps } : node\n }\n return next as T\n}\n"],"names":["FUNCTION_TOKEN_PATTERN","VARIABLE_ID_TOKEN_PATTERN","evaluateExpression","evaluateHostFunction","functionReferencedNames","HOST_VARIABLE_TYPE_LABELS","date","time","text","number","boolean","dictionary","collection","VARIABLE_NAME_PATTERN","isVariableName","name","test","formatVariableValue","variable","raw","value","type","parsed","Number","isFinite","String","Date","isNaN","getTime","toLocaleDateString","undefined","year","month","day","timeZone","JSON","parse","Array","isArray","map","join","Object","entries","key","variableScope","variables","scope","values","resolveBindings","functions","withVariableIds","replace","_token","id","withFunctions","token","rawName","rawArgs","definition","trim","argValues","split","argument","filter","length","args","parameters","forEach","parameter","index","result","globals","ok","hasBindings","functionGlobals","prototype","hasOwnProperty","call","attachFunctionDefinitions","nodes","bindings","keys","next","node","componentId","prop","props","resolveNodesBindings","changed","nextProps"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,uEAAuE;AACvE,oEAAoE;AACpE,+BAA+B;AAC/B,SACEA,sBAAsB,EACtBC,yBAAyB,QACpB,sBAAkB;AACzB,SACEC,kBAAkB,EAClBC,oBAAoB,EACpBC,uBAAuB,QAElB,iBAAa;AAmBpB,OAAO,MAAMC,4BAA8D;IACzEC,MAAM;IACNC,MAAM;IACNC,MAAM;IACNC,QAAQ;IACRC,SAAS;IACTC,YAAY;IACZC,YAAY;AACd,EAAC;AAmBD,OAAO,MAAMC,wBAAwB,gCAA+B;AAEpE,4FAA4F,GAC5F,OAAO,SAASC,eAAeC,IAAY;IACzC,OAAOF,sBAAsBG,IAAI,CAACD;AACpC;AAEA,2EAA2E,GAC3E,OAAO,SAASE,oBAAoBC,QAAsB;QAC5CA;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/app-utils/variables.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Token grammar shared with the picker/besigner (AGL-185/194): id-form\n// tokens only — legacy name resolution retired after the production\n// content migration ran clean.\nimport {\n FUNCTION_TOKEN_PATTERN,\n VARIABLE_ID_TOKEN_PATTERN,\n} from './binding-tokens'\nimport {\n evaluateExpression,\n evaluateHostFunction,\n functionReferencedNames,\n type HostFunction,\n} from './functions'\n\n/**\n * Host variables (Component Builder, AGL-91): typed values authored in the\n * console and bound into component text props with `{{name}}` — and, since\n * AGL-93, function results with `{{fn:name(args)}}`. Pure data module\n * shared by the console editor UI and the tenant compose pipeline.\n */\n\n/** Types from the mockup's Edit Variable dialog (\"Function\" lands with AGL-92). */\nexport type HostVariableType =\n | 'date'\n | 'time'\n | 'text'\n | 'number'\n | 'boolean'\n | 'dictionary'\n | 'collection'\n\nexport const HOST_VARIABLE_TYPE_LABELS: Record<HostVariableType, string> = {\n date: 'Date',\n time: 'Time',\n text: 'Plain text',\n number: 'Number',\n boolean: 'True/false (boolean)',\n dictionary: 'Dictionary (key: value)',\n collection: 'Collection list (values)',\n}\n\n/**\n * `hosts/{hostId}/variables/{id}` doc, as far as binding reads it.\n *\n * A COMPUTED variable also carries the reference its computing plugin reads\n * — which record produces its value — and `value` is then the fallback the\n * page shows when that record is gone or fails. Binding never reads the\n * reference; the plugin that computes the value types and reads its own\n * (`plugin-manager/computed-variables`).\n */\nexport interface HostVariable {\n /** Binding identifier — `{{name}}`. */\n name: string\n type: HostVariableType\n /** Persisted as a string; formatted per type at resolve time. */\n value?: string\n}\n\nexport const VARIABLE_NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]{0,39}$/\n\n/** Whether `name` may name a variable or a function's parameter (`VARIABLE_NAME_PATTERN`). */\nexport function isVariableName(name: string): boolean {\n return VARIABLE_NAME_PATTERN.test(name)\n}\n\n/** Human-readable rendering of a variable's value for text interpolation. */\nexport function formatVariableValue(variable: HostVariable): string {\n const raw = variable.value ?? ''\n switch (variable.type) {\n case 'boolean':\n return raw === 'true' ? 'true' : 'false'\n case 'number': {\n const parsed = Number(raw)\n return Number.isFinite(parsed) ? String(parsed) : ''\n }\n case 'date': {\n const parsed = new Date(raw)\n return Number.isNaN(parsed.getTime())\n ? raw\n : parsed.toLocaleDateString(undefined, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n timeZone: 'UTC',\n })\n }\n case 'dictionary':\n case 'collection': {\n // Stored as JSON; render collections comma-joined and dictionaries\n // as `key: value` pairs so a bare {{name}} stays readable.\n try {\n const parsed = JSON.parse(raw)\n if (Array.isArray(parsed)) return parsed.map(String).join(', ')\n if (parsed && typeof parsed === 'object') {\n return Object.entries(parsed)\n .map(([key, value]) => `${key}: ${value}`)\n .join(', ')\n }\n } catch {\n // fall through to the raw string\n }\n return raw\n }\n case 'time':\n case 'text':\n default:\n return raw\n }\n}\n\n/** A function definition lookup keyed by function name (AGL-93). */\nexport type HostFunctionLookup = Record<string, HostFunction>\n\n/**\n * Variable values as an expression scope (numbers stay numeric). Keyed by\n * each doc's NAME regardless of how the lookup map is keyed (AGL-194:\n * maps are id-keyed now, but expressions reference variables by name).\n */\nfunction variableScope(\n variables: Record<string, HostVariable>,\n): Record<string, number | string | boolean> {\n const scope: Record<string, number | string | boolean> = {}\n for (const variable of Object.values(variables)) {\n if (!variable?.name) continue\n if (variable.type === 'number') {\n scope[variable.name] = Number(variable.value ?? 0)\n } else if (variable.type === 'boolean') {\n scope[variable.name] = variable.value === 'true'\n } else {\n scope[variable.name] = variable.value ?? ''\n }\n }\n return scope\n}\n\n/**\n * Replaces binding tokens with values (AGL-91/93/185/194): id forms\n * `{{var:id}}` / `{{fn:id(args)}}` resolve through id-keyed lookup maps.\n * Function args are expressions over literals and variable NAMES (the\n * scope keys by each doc's name). Unknown function refs keep the literal\n * token; unknown variable ids render empty; bare `{{name}}` strings are\n * plain text since the legacy fallback retired.\n */\nexport function resolveBindings(\n text: string,\n variables: Record<string, HostVariable>,\n functions: HostFunctionLookup = {},\n): string {\n const withVariableIds = text.replace(\n VARIABLE_ID_TOKEN_PATTERN,\n (_token, id) => {\n const variable = variables[String(id)]\n // Unknown ids render EMPTY, not literal (AGL-186): a raw doc id is\n // meaningless to visitors, unlike a readable legacy {{name}} token.\n return variable ? formatVariableValue(variable) : ''\n },\n )\n const withFunctions = withVariableIds.replace(\n FUNCTION_TOKEN_PATTERN,\n (token, rawName, rawArgs) => {\n const definition = functions[String(rawName).trim()]\n if (!definition) return token\n try {\n const scope = variableScope(variables)\n const argValues = String(rawArgs)\n .split(',')\n .map((argument) => argument.trim())\n .filter((argument) => argument.length > 0)\n .map((argument) => evaluateExpression(argument, scope))\n const args: Record<string, unknown> = {}\n definition.parameters?.forEach((parameter, index) => {\n args[parameter.name] = argValues[index]\n })\n // The site's variables are the function's outer scope (AGL-3202),\n // so `{{fn:id(25)}}` can price 25 sites without every rate being\n // passed in by position. Arguments still win over a variable of the\n // same name, as every parameter does.\n const result = evaluateHostFunction(definition, args, {\n globals: scope,\n })\n return result.ok ? String(result.value) : token\n } catch {\n return token\n }\n },\n )\n // Legacy {{name}} resolution retired (AGL-194): the production content\n // migration ran clean, so bare-name tokens are plain text now. Typing\n // them in the editor still works — save-time normalization converts\n // known names to id tokens before they persist.\n return withFunctions\n}\n\n/** Fast pre-check so binding-free content skips the walk entirely. */\nexport function hasBindings(text: string): boolean {\n return /\\{\\{/.test(text)\n}\n\n/**\n * The site variables ONE function reads, by name (AGL-3202).\n *\n * A widget runs in the visitor's browser, so whatever it may read has to be\n * on the page. Handing it the whole variable list would publish every value\n * a site holds to every page that places a calculator; this hands over the\n * names the function's own expressions use and nothing else. A name the\n * function declares itself is not a variable read — its parameter or local\n * shadows the variable — so it is not shipped either.\n */\nexport function functionGlobals(\n definition: HostFunction,\n variables: Record<string, HostVariable>,\n): Record<string, number | string | boolean> {\n const scope = variableScope(variables)\n const globals: Record<string, number | string | boolean> = {}\n for (const name of functionReferencedNames(definition)) {\n if (Object.prototype.hasOwnProperty.call(scope, name)) {\n globals[name] = scope[name]\n }\n }\n return globals\n}\n\n/**\n * Injects each function-running element's definition into its props at\n * compose time (AGL-93): the client runs the shared evaluator locally, so the\n * published page carries the definition instead of calling home. Unknown\n * names leave the node untouched (the element renders its editor\n * placeholder).\n *\n * Which elements run a function is DECLARED (AGL-3393): `bindings` maps a\n * component id to the prop that names its function, collected from each\n * plugin's `contributes.site.functionBindings`. Core names no element, so a\n * marketplace plugin's element is bound exactly as a first-party one is, and\n * an element nobody declared is never handed a definition.\n *\n * With `variables`, the site variables that function reads ride along as\n * `globals` (AGL-3202) — see {@link functionGlobals} for why it is only\n * those. The key is omitted when the function reads none, so a page built\n * before this existed serializes exactly as it did.\n */\nexport function attachFunctionDefinitions<T extends Record<string, any>>(\n nodes: T,\n functions: HostFunctionLookup,\n variables: Record<string, HostVariable>,\n bindings: Readonly<Record<string, string>>,\n): T {\n if (!Object.keys(functions).length || !Object.keys(bindings).length) {\n return nodes\n }\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const componentId = node?.componentId\n const prop =\n typeof componentId === 'string' &&\n Object.prototype.hasOwnProperty.call(bindings, componentId)\n ? bindings[componentId]\n : undefined\n const name = prop ? node?.props?.[prop] : undefined\n const definition = name ? functions[String(name).trim()] : undefined\n if (!definition) {\n next[id] = node\n continue\n }\n const globals = functionGlobals(definition, variables)\n next[id] = {\n ...node,\n props: {\n ...node.props,\n definition,\n ...(Object.keys(globals).length ? { globals } : {}),\n },\n }\n }\n return next as T\n}\n\n/**\n * Applies `resolveBindings` to every string prop across a normalized nodes\n * map (mutating a shallow copy). String props only — objects/arrays (sx,\n * option lists) pass through untouched; unsafe values in hrefs remain\n * covered by the render-time SAFE_HREF/sanitizer checks.\n */\nexport function resolveNodesBindings<T extends Record<string, any>>(\n nodes: T,\n variables: Record<string, HostVariable>,\n functions: HostFunctionLookup = {},\n): T {\n // No early return for a site with no variables: its `{{var:id}}` tokens\n // still have to render EMPTY (a deleted variable, a plugin connection that\n // was disconnected), or the raw token reaches visitors. Only a node whose\n // text actually changes is copied, so a page with nothing to resolve comes\n // back as the same map.\n let anyChanged = false\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const props = node?.props\n if (!props) {\n next[id] = node\n continue\n }\n let changed = false\n const nextProps: Record<string, unknown> = { ...props }\n for (const [key, value] of Object.entries(props)) {\n if (typeof value === 'string' && hasBindings(value)) {\n const resolved = resolveBindings(value, variables, functions)\n if (resolved !== value) {\n nextProps[key] = resolved\n changed = true\n }\n }\n }\n next[id] = changed ? { ...node, props: nextProps } : node\n anyChanged = anyChanged || changed\n }\n return (anyChanged ? next : nodes) as T\n}\n"],"names":["FUNCTION_TOKEN_PATTERN","VARIABLE_ID_TOKEN_PATTERN","evaluateExpression","evaluateHostFunction","functionReferencedNames","HOST_VARIABLE_TYPE_LABELS","date","time","text","number","boolean","dictionary","collection","VARIABLE_NAME_PATTERN","isVariableName","name","test","formatVariableValue","variable","raw","value","type","parsed","Number","isFinite","String","Date","isNaN","getTime","toLocaleDateString","undefined","year","month","day","timeZone","JSON","parse","Array","isArray","map","join","Object","entries","key","variableScope","variables","scope","values","resolveBindings","functions","withVariableIds","replace","_token","id","withFunctions","token","rawName","rawArgs","definition","trim","argValues","split","argument","filter","length","args","parameters","forEach","parameter","index","result","globals","ok","hasBindings","functionGlobals","prototype","hasOwnProperty","call","attachFunctionDefinitions","nodes","bindings","keys","next","node","componentId","prop","props","resolveNodesBindings","anyChanged","changed","nextProps","resolved"],"mappings":";AAAA;;;;;;;;;;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AO;YACVJ,IAAI,CAAC7B,GAAG,GAAG8B;YACX;QACF;QACA,IAAIM,UAAU;QACd,MAAMC,YAAqC,aAAKJ;QAChD,KAAK,MAAM,CAAC3C,KAAKvB,MAAM,IAAIqB,OAAOC,OAAO,CAAC4C,OAAQ;YAChD,IAAI,OAAOlE,UAAU,YAAYqD,YAAYrD,QAAQ;gBACnD,MAAMuE,WAAW3C,gBAAgB5B,OAAOyB,WAAWI;gBACnD,IAAI0C,aAAavE,OAAO;oBACtBsE,SAAS,CAAC/C,IAAI,GAAGgD;oBACjBF,UAAU;gBACZ;YACF;QACF;QACAP,IAAI,CAAC7B,GAAG,GAAGoC,UAAU,aAAKN;YAAMG,OAAOI;aAAcP;QACrDK,aAAaA,cAAcC;IAC7B;IACA,OAAQD,aAAaN,OAAOH;AAC9B"}
|
|
@@ -155,6 +155,17 @@ export interface AglynComponentSchema<P = any> {
|
|
|
155
155
|
* keeps the Branch/Stem/Leaf seam swappable for everything else.
|
|
156
156
|
*/
|
|
157
157
|
positionalChildren?: FEATURE_FLAG;
|
|
158
|
+
/**
|
|
159
|
+
* Component takes its text as a plain string `children`: no child
|
|
160
|
+
* elements and no `<aglyn-text>` wrapper around it. For an element whose
|
|
161
|
+
* DOM allows text and nothing else, such as `<option>`, where React and
|
|
162
|
+
* the browser's parser both drop an element child, and with it the text.
|
|
163
|
+
*
|
|
164
|
+
* Not `selfClosing`, which means a void element (`<img>`) and strips
|
|
165
|
+
* `children` altogether: a Select Option flagged that way rendered every
|
|
166
|
+
* dropdown choice on every published site with no words.
|
|
167
|
+
*/
|
|
168
|
+
plainTextChildren?: FEATURE_FLAG;
|
|
158
169
|
};
|
|
159
170
|
/**
|
|
160
171
|
* Preset items are the available items to add to the canvas
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/aglyn/src/lib/foundation/definitions/components.types.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConditionDefinition,\n DataType,\n Validator,\n} from '@data-driven-forms/react-form-renderer'\nimport type {\n FieldActions,\n ResolvePropsFunction,\n} from '@data-driven-forms/react-form-renderer/common-types'\nimport type { SvgIconProps } from '@mui/material'\nimport type { MuiStyledOptions } from '@mui/system/createStyled'\nimport type { CANVAS_ROOT_ELEMENT_ID } from '../constants/canvas'\nimport type { ComponentCategory } from '../constants/components'\nimport type { FEATURE_FLAG, RICH_TEXT_COMMANDS } from '../constants/shared'\nimport type { AGLYN_OF, SYMBOL_TYPE } from '../constants/symbol'\n\nexport enum LinealDirectiveFlag {\n LIMIT_TO = 'limitedTo',\n DISALLOW = 'forbid',\n}\n\nexport type BundleId = string\nexport type PluginId = string\nexport type ComponentId = string\nexport type PresetId = string\nexport type NodeId = string\n\nexport type ComponentsLinealOrder = [\n directiveType: LinealDirectiveFlag,\n directiveDefinition:\n | Array<ComponentId>\n | { plugins?: Array<PluginId>; components: Array<ComponentId> }\n | { plugins: Array<PluginId>; components?: Array<ComponentId> },\n]\n\nexport type AglynNodeItemDenormalized<P = JSX.AnyProps> = AglynNodeSchema<P> & {\n nodes?: AglynNodeItemDenormalized[]\n}\n\nexport type AglynNodesList = Array<AglynNodeItemDenormalized>\n\nexport type AglynNodeHierarchy<$ID extends NodeId = NodeId> = [\n root: CANVAS_ROOT_ELEMENT_ID,\n ...nodes: [...ancestors: NodeId[], element: $ID],\n]\n\nexport interface AglynExoticComponent<PROPS = any, REF = any>\n extends JSX.ForwardRefExoticComponent<\n JSX.PropsWithoutRef<PROPS> & JSX.RefAttributes<REF>\n > {\n [AGLYN_OF]?: SYMBOL_TYPE\n aglyn?: boolean\n schema?: AglynComponentSchema<PROPS>\n}\n\nexport interface AglynComponentSchema<P = any> {\n $id: ComponentId\n pluginId?: BundleId\n kind?: 'element' | 'plaintext' | 'markdown'\n\n displayName: string\n title?: string\n subtitle?: string\n description?: string\n\n /**\n * Icon props for display around besigner\n */\n icon?: SvgIconProps\n /**\n * Options to be passed to styled(Component, \\{...styledOptions\\})\n */\n styledOptions?: MuiStyledOptions\n\n /**\n * Define a limitation for nodes allowed as direct descendents\n */\n restrictChildren?: ComponentsLinealOrder\n /**\n * Define a limitation for nodes allowed to be direct ancestors\n */\n restrictParent?: ComponentsLinealOrder\n\n /**\n * Filter props\n */\n resolveProps?: JSX.ResolveProps<AglynNodeItemDenormalized<P>>\n\n /**\n * Attribute fields to modify the contextual properties\n * New version\n */\n attributes?: AglynAttributeSchema[]\n\n /**\n * Which groups of formatting the inline rich-text toolbar offers for this\n * component (AGL-2557). Read only where `flags.richTextEditable` is on.\n *\n * Omitted means every group, which is what leaves Typography exactly as it\n * was. Naming a subset narrows the toolbar AND the commit: a surface that\n * offers neither lists nor links is phrasing-only, and the sanitizer holds\n * it to that whatever an author pastes in.\n */\n richTextCommands?: RICH_TEXT_COMMANDS[]\n\n /**\n * Feature flags\n */\n flags?: {\n /**\n * Disable the use of emotion styled\n */\n emotion?: FEATURE_FLAG\n /**\n * Can the nodes of this component type be cloned?\n */\n cloning?: FEATURE_FLAG\n /**\n * Allow dragging nodes of this component type\n */\n dragging?: FEATURE_FLAG\n /**\n * Allow dropping nodes inside nodes of this component type\n */\n dropping?: FEATURE_FLAG\n /**\n * Allow editing element attributes of this component type\n */\n editing?: FEATURE_FLAG\n /**\n * Allow removing nodes of this component type\n */\n removing?: FEATURE_FLAG\n /**\n * Describe nodes of this component type to be self-closing\n */\n selfClosing?: FEATURE_FLAG\n /**\n * Component renders its `children` prop as text content the editor may\n * edit directly (Attributes \"Text\" field, inline canvas editing).\n */\n textEditable?: FEATURE_FLAG\n /**\n * Component also accepts basic rich text (AGL-54): sanitized HTML in the\n * `html` prop with `children` as the plain-text fallback.\n */\n richTextEditable?: FEATURE_FLAG\n /**\n * Component reads its children POSITIONALLY (AGL-1237), so the renderer\n * must hand it one React child per node child instead of the single\n * `<Branch>` element it normally passes.\n *\n * MUI's Accordion does `const [summary, ...rest] = Children.toArray(children)`,\n * and `toArray` does not traverse into an element — so with the default\n * wrapping the summary swallowed the whole subtree and the Collapse got\n * nothing. Every accordion on every published site expanded to reveal an\n * empty panel while its content rendered unconditionally inside the\n * summary's `<h3>`.\n *\n * Opt in only for components with this contract; the wrapper is what\n * keeps the Branch/Stem/Leaf seam swappable for everything else.\n */\n positionalChildren?: FEATURE_FLAG\n }\n\n /**\n * Preset items are the available items to add to the canvas\n */\n presets?: AglynNodePresetSchema[]\n}\n\nexport type NodePresetData = Omit<AglynNodeSchema, '$id' | 'nodes'> & {\n $id?: NodeId\n nodes?: NodePresetData[]\n}\n\nexport type AglynNodePresetSchema = {\n $id: PresetId\n label: string\n componentId?: ComponentId\n pluginId?: BundleId\n description?: string\n icon?: SvgIconProps\n category?: string | ComponentCategory\n data: NodePresetData\n}\n\nexport enum FieldComponentType {\n /**\n * Per-breakpoint span editor (AGL-2486): a small row of breakpoint\n * controls (All / xs / sm / md / lg / xl), each offering a column count\n * plus MUI's `auto` and `grow` keywords. The persisted prop is still ONE\n * string in the syntax the Grid element already parses (`\"6\"`, `\"auto\"`,\n * `\"xs:12 md:6\"`) — this is an input affordance, not a shape change, so\n * renderers and existing documents stay untouched. A value the row cannot\n * model (a `{{token}}`, an unknown breakpoint) falls back to free text\n * rather than being clobbered.\n */\n BREAKPOINT_SPAN = 'breakpoint-span',\n BUTTON = 'button',\n BUTTON_GROUP = 'button-group',\n CHECKBOX = 'checkbox',\n COLOR_PICKER = 'color-picker',\n /**\n * Border editor (AGL-2486): a thickness box plus a plain-English line-style\n * picker (solid / dashed / dotted / double / no line). The persisted prop is\n * still ONE CSS shorthand string (`\"1px solid\"`, `\"none\"`, `\"\"`), so\n * renderers and existing documents stay untouched. A value the pair cannot\n * model (`thin solid`, `1px solid #f00`, a binding token) falls back to free\n * text rather than being clobbered, and flips back the moment the text is a\n * plain `<width> <style>` again.\n */\n CSS_BORDER = 'css-border',\n /**\n * CSS length editor (AGL-1219): a number box plus a unit picker sharing\n * the styles panel's unit list. The persisted prop is still ONE CSS\n * string (`\"920px\"`, `\"100%\"`, `\"auto\"`, `\"\"`) — this is an input\n * affordance, not a shape change, so renderers stay untouched. Values\n * the picker can't model (`calc(…)`, a binding token) fall back to free\n * text rather than being clobbered.\n */\n CSS_DIMENSION = 'css-dimension',\n /**\n * Background fill editor (AGL-1331): a fill-type switch (default / solid\n * / linear / radial) over an angle box and a colour-stop list, each stop\n * bindable to a palette token or a literal. The persisted prop is ONE CSS\n * string under `backgroundImage` — a solid fill writes the explicit\n * keyword `none` and leaves `backgroundColor` to do the job, while the\n * default choice writes nothing at all (AGL-1338: the two differ on a\n * component instance, where absence means \"keep the component's fill\") —\n * so renderers stay untouched. Values\n * the editor cannot model (`conic-gradient`, `to bottom right`, a stacked\n * image list) fall back to free text rather than being clobbered.\n */\n CSS_GRADIENT = 'css-gradient',\n /**\n * Row-and-column grid editor for the Table element (AGL-2543).\n *\n * The persisted prop is still ONE string — pipe-delimited rows with the\n * markdown divider carrying per-column alignment — so the renderer and\n * existing documents stay untouched, and a comparison table already\n * authored inside a Markdown element pastes straight in. This is the\n * affordance that makes the element no-code: without it an author edits\n * pipe syntax, which is the audience the besigner exists to spare.\n */\n DATA_TABLE = 'data-table',\n DATE_PICKER = 'date-picker',\n DUAL_LIST_SELECT = 'dual-list-select',\n FIELD_ARRAY = 'field-array',\n ICON_PICKER = 'icon-picker',\n /**\n * markdown-lite document editor (AGL-1616): the WYSIWYG the console\n * already ships for blog entries and marketplace listings, rendered as the\n * attribute's field. The persisted prop is still ONE markdown-lite string,\n * so every renderer stays untouched — this is an input affordance, not a\n * shape change. Declared by an attribute whose value is a whole document\n * rather than a line of text; a plain TEXTAREA meant the Privacy Policy\n * body was edited as a 13 KB raw paste (AGL-1594).\n */\n MARKDOWN = 'markdown',\n INPUT_ADDON_BUTTON_GROUP = 'input-addon-button-group',\n INPUT_ADDON_GROUP = 'input-addon-group',\n PLAIN_TEXT = 'plain-text',\n /**\n * Named-preset picker with a raw escape hatch (AGL-2486): the theme's own\n * answers first, then plain-English presets that PREVIEW themselves, then\n * Custom…. The persisted prop is whatever the property already stored — a\n * number where a bare number is a theme multiple, a CSS string otherwise —\n * and a stored value matching no preset opens the field in its custom state\n * holding that value rather than dropping it.\n */\n PRESET_CHOICE = 'preset-choice',\n RADIO = 'radio',\n /**\n * Select listing the host's screens; the editor resolves the options from\n * the host routing map at render time and writes the chosen screen id.\n */\n SCREEN_SELECT = 'screen-select',\n /**\n * Select listing the canvas's other elements (AGL-557): the editor\n * resolves options from the live canvas at edit time and persists the\n * node id — e.g. the form's reveal-on-submit target.\n */\n NODE_SELECT = 'node-select',\n /**\n * Id-based entity pickers (AGL-343/344): the editor resolves options\n * from EntityPickerContext at edit time and persists the entity id —\n * renames never break the reference.\n */\n /**\n * Select listing the plugins installed for this site (AGL-1030): the editor\n * resolves options from the install set the console publishes and persists\n * the listing id. A picker rather than a typed document id — the same reason\n * every other reference in the designer is one, and here it also removes the\n * \"is this installed?\" question by construction.\n */\n PLUGIN_SELECT = 'plugin-select',\n /**\n * A placed plugin's declared settings, rendered as real fields (AGL-1049).\n * Reads the sibling plugin selection to know which manifest to offer.\n */\n PLUGIN_SETTINGS = 'plugin-settings',\n PRODUCT_SELECT = 'product-select',\n COLLECTION_SELECT = 'collection-select',\n CATEGORY_SELECT = 'category-select',\n DATASET_SELECT = 'dataset-select',\n /**\n * Select listing the model fields of the nearest ancestor node's chosen\n * dataset (AGL-556): the editor resolves options from\n * EntityPickerContext.entityFields using the ancestor's `datasetId`\n * (or legacy `datasetName` matched by label) and persists the stable\n * model fieldId — field renames never break the mapping.\n */\n DATASET_FIELD_SELECT = 'dataset-field-select',\n /**\n * Select listing the host's form entities (`docs/specs/reusable-forms.md`\n * §2c): the editor resolves options from EntityPickerContext.forms and\n * persists the form id. The same id-first reasoning as every picker in this\n * family, and here it is load-bearing rather than convenient — the string\n * it replaces was the form's whole identity, so a rename split the\n * submission history it named.\n */\n FORM_SELECT = 'form-select',\n SELECT = 'select',\n SLIDER = 'slider',\n SUB_FORM = 'sub-form',\n SWITCH = 'switch',\n TAB_ITEM = 'tab-item',\n TABS = 'tabs',\n TEXT_FIELD = 'text-field',\n TEXTAREA = 'textarea',\n /**\n * Theme-scale combo box (AGL-2486): offers the THEME's own scale for a\n * property — `theme.typography` for font size and weight,\n * `theme.zIndex` for stacking — while still accepting any raw value\n * (`18px`, `1.25rem`, `700`, `1400`), because arbitrary values are\n * legitimate. The persisted value is a theme token PATH\n * (`h4.fontSize`, `fontWeightBold`, `appBar`), which MUI's sx system\n * resolves against the active theme exactly as it resolves\n * `color: 'primary.main'` — so the element keeps following the theme\n * instead of freezing the number it had when it was styled.\n */\n THEME_SCALE = 'theme-scale',\n TIME_PICKER = 'time-picker',\n TOGGLE_BUTTON = 'toggle-button',\n WIZARD = 'wizard',\n}\n\nexport enum FieldValidatorType {\n EXACT_LENGTH = 'exact-length',\n MAX_LENGTH = 'max-length',\n MAX_NUMBER_VALUE = 'max-number-value',\n MIN_ITEMS = 'min-items',\n MIN_LENGTH = 'min-length',\n MIN_NUMBER_VALUE = 'min-number-value',\n PATTERN = 'pattern',\n REQUIRED = 'required',\n URL = 'url',\n}\n\nexport type FieldDataType =\n | 'boolean'\n | 'float'\n | 'integer'\n | 'number'\n | 'string'\n\nexport interface AglynAttributeSchema extends Dictionary<any> {\n name: string\n dataType?: DataType\n component: string | FieldComponentType\n validate?: Validator[]\n condition?: ConditionDefinition | ConditionDefinition[]\n initializeOnMount?: boolean\n initialValue?: unknown\n clearedValue?: unknown\n clearOnUnmount?: boolean\n actions?: FieldActions\n resolveProps?: ResolvePropsFunction\n description?: string\n /**\n * The one kind of media library file this attribute holds (AGL-3716):\n * `image`, `video`, `pdf` or `audio`. Its \"Browse media\" picker lists and\n * uploads only that kind. Read by the editor, never handed to the field.\n */\n mediaKind?: 'image' | 'video' | 'pdf' | 'audio'\n}\n\nexport interface AglynNodeSchema<P = JSX.AnyProps> {\n $id: NodeId\n componentId: ComponentId\n pluginId?: BundleId\n parentId?: NodeId\n sx?: JSX.SxProps\n props?: P\n nodes?: NodeId[] | AglynNodeSchema[]\n}\n"],"names":["LinealDirectiveFlag","FieldComponentType","FieldValidatorType"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAkBD,OAAO,IAAA,AAAKA,6CAAAA;;;WAAAA;MAGX;AAwKD,OAAO,IAAA,AAAKC,4CAAAA;IACV;;;;;;;;;GASC;;;;;IAMD;;;;;;;;GAQC;IAED;;;;;;;GAOC;IAED;;;;;;;;;;;GAWC;IAED;;;;;;;;;GASC;;;;;IAMD;;;;;;;;GAQC;;;;IAKD;;;;;;;GAOC;;IAGD;;;GAGC;IAED;;;;GAIC;IAED;;;;GAIC,GACD;;;;;;GAMC;IAED;;;GAGC;;;;;IAMD;;;;;;GAMC;IAED;;;;;;;GAOC;;;;;;;;;IAUD;;;;;;;;;;GAUC;;;;WA1JSA;MA+JX;AAED,OAAO,IAAA,AAAKC,4CAAAA;;;;;;;;;;WAAAA;MAUX"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/aglyn/src/lib/foundation/definitions/components.types.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConditionDefinition,\n DataType,\n Validator,\n} from '@data-driven-forms/react-form-renderer'\nimport type {\n FieldActions,\n ResolvePropsFunction,\n} from '@data-driven-forms/react-form-renderer/common-types'\nimport type { SvgIconProps } from '@mui/material'\nimport type { MuiStyledOptions } from '@mui/system/createStyled'\nimport type { CANVAS_ROOT_ELEMENT_ID } from '../constants/canvas'\nimport type { ComponentCategory } from '../constants/components'\nimport type { FEATURE_FLAG, RICH_TEXT_COMMANDS } from '../constants/shared'\nimport type { AGLYN_OF, SYMBOL_TYPE } from '../constants/symbol'\n\nexport enum LinealDirectiveFlag {\n LIMIT_TO = 'limitedTo',\n DISALLOW = 'forbid',\n}\n\nexport type BundleId = string\nexport type PluginId = string\nexport type ComponentId = string\nexport type PresetId = string\nexport type NodeId = string\n\nexport type ComponentsLinealOrder = [\n directiveType: LinealDirectiveFlag,\n directiveDefinition:\n | Array<ComponentId>\n | { plugins?: Array<PluginId>; components: Array<ComponentId> }\n | { plugins: Array<PluginId>; components?: Array<ComponentId> },\n]\n\nexport type AglynNodeItemDenormalized<P = JSX.AnyProps> = AglynNodeSchema<P> & {\n nodes?: AglynNodeItemDenormalized[]\n}\n\nexport type AglynNodesList = Array<AglynNodeItemDenormalized>\n\nexport type AglynNodeHierarchy<$ID extends NodeId = NodeId> = [\n root: CANVAS_ROOT_ELEMENT_ID,\n ...nodes: [...ancestors: NodeId[], element: $ID],\n]\n\nexport interface AglynExoticComponent<PROPS = any, REF = any>\n extends JSX.ForwardRefExoticComponent<\n JSX.PropsWithoutRef<PROPS> & JSX.RefAttributes<REF>\n > {\n [AGLYN_OF]?: SYMBOL_TYPE\n aglyn?: boolean\n schema?: AglynComponentSchema<PROPS>\n}\n\nexport interface AglynComponentSchema<P = any> {\n $id: ComponentId\n pluginId?: BundleId\n kind?: 'element' | 'plaintext' | 'markdown'\n\n displayName: string\n title?: string\n subtitle?: string\n description?: string\n\n /**\n * Icon props for display around besigner\n */\n icon?: SvgIconProps\n /**\n * Options to be passed to styled(Component, \\{...styledOptions\\})\n */\n styledOptions?: MuiStyledOptions\n\n /**\n * Define a limitation for nodes allowed as direct descendents\n */\n restrictChildren?: ComponentsLinealOrder\n /**\n * Define a limitation for nodes allowed to be direct ancestors\n */\n restrictParent?: ComponentsLinealOrder\n\n /**\n * Filter props\n */\n resolveProps?: JSX.ResolveProps<AglynNodeItemDenormalized<P>>\n\n /**\n * Attribute fields to modify the contextual properties\n * New version\n */\n attributes?: AglynAttributeSchema[]\n\n /**\n * Which groups of formatting the inline rich-text toolbar offers for this\n * component (AGL-2557). Read only where `flags.richTextEditable` is on.\n *\n * Omitted means every group, which is what leaves Typography exactly as it\n * was. Naming a subset narrows the toolbar AND the commit: a surface that\n * offers neither lists nor links is phrasing-only, and the sanitizer holds\n * it to that whatever an author pastes in.\n */\n richTextCommands?: RICH_TEXT_COMMANDS[]\n\n /**\n * Feature flags\n */\n flags?: {\n /**\n * Disable the use of emotion styled\n */\n emotion?: FEATURE_FLAG\n /**\n * Can the nodes of this component type be cloned?\n */\n cloning?: FEATURE_FLAG\n /**\n * Allow dragging nodes of this component type\n */\n dragging?: FEATURE_FLAG\n /**\n * Allow dropping nodes inside nodes of this component type\n */\n dropping?: FEATURE_FLAG\n /**\n * Allow editing element attributes of this component type\n */\n editing?: FEATURE_FLAG\n /**\n * Allow removing nodes of this component type\n */\n removing?: FEATURE_FLAG\n /**\n * Describe nodes of this component type to be self-closing\n */\n selfClosing?: FEATURE_FLAG\n /**\n * Component renders its `children` prop as text content the editor may\n * edit directly (Attributes \"Text\" field, inline canvas editing).\n */\n textEditable?: FEATURE_FLAG\n /**\n * Component also accepts basic rich text (AGL-54): sanitized HTML in the\n * `html` prop with `children` as the plain-text fallback.\n */\n richTextEditable?: FEATURE_FLAG\n /**\n * Component reads its children POSITIONALLY (AGL-1237), so the renderer\n * must hand it one React child per node child instead of the single\n * `<Branch>` element it normally passes.\n *\n * MUI's Accordion does `const [summary, ...rest] = Children.toArray(children)`,\n * and `toArray` does not traverse into an element — so with the default\n * wrapping the summary swallowed the whole subtree and the Collapse got\n * nothing. Every accordion on every published site expanded to reveal an\n * empty panel while its content rendered unconditionally inside the\n * summary's `<h3>`.\n *\n * Opt in only for components with this contract; the wrapper is what\n * keeps the Branch/Stem/Leaf seam swappable for everything else.\n */\n positionalChildren?: FEATURE_FLAG\n /**\n * Component takes its text as a plain string `children`: no child\n * elements and no `<aglyn-text>` wrapper around it. For an element whose\n * DOM allows text and nothing else, such as `<option>`, where React and\n * the browser's parser both drop an element child, and with it the text.\n *\n * Not `selfClosing`, which means a void element (`<img>`) and strips\n * `children` altogether: a Select Option flagged that way rendered every\n * dropdown choice on every published site with no words.\n */\n plainTextChildren?: FEATURE_FLAG\n }\n\n /**\n * Preset items are the available items to add to the canvas\n */\n presets?: AglynNodePresetSchema[]\n}\n\nexport type NodePresetData = Omit<AglynNodeSchema, '$id' | 'nodes'> & {\n $id?: NodeId\n nodes?: NodePresetData[]\n}\n\nexport type AglynNodePresetSchema = {\n $id: PresetId\n label: string\n componentId?: ComponentId\n pluginId?: BundleId\n description?: string\n icon?: SvgIconProps\n category?: string | ComponentCategory\n data: NodePresetData\n}\n\nexport enum FieldComponentType {\n /**\n * Per-breakpoint span editor (AGL-2486): a small row of breakpoint\n * controls (All / xs / sm / md / lg / xl), each offering a column count\n * plus MUI's `auto` and `grow` keywords. The persisted prop is still ONE\n * string in the syntax the Grid element already parses (`\"6\"`, `\"auto\"`,\n * `\"xs:12 md:6\"`) — this is an input affordance, not a shape change, so\n * renderers and existing documents stay untouched. A value the row cannot\n * model (a `{{token}}`, an unknown breakpoint) falls back to free text\n * rather than being clobbered.\n */\n BREAKPOINT_SPAN = 'breakpoint-span',\n BUTTON = 'button',\n BUTTON_GROUP = 'button-group',\n CHECKBOX = 'checkbox',\n COLOR_PICKER = 'color-picker',\n /**\n * Border editor (AGL-2486): a thickness box plus a plain-English line-style\n * picker (solid / dashed / dotted / double / no line). The persisted prop is\n * still ONE CSS shorthand string (`\"1px solid\"`, `\"none\"`, `\"\"`), so\n * renderers and existing documents stay untouched. A value the pair cannot\n * model (`thin solid`, `1px solid #f00`, a binding token) falls back to free\n * text rather than being clobbered, and flips back the moment the text is a\n * plain `<width> <style>` again.\n */\n CSS_BORDER = 'css-border',\n /**\n * CSS length editor (AGL-1219): a number box plus a unit picker sharing\n * the styles panel's unit list. The persisted prop is still ONE CSS\n * string (`\"920px\"`, `\"100%\"`, `\"auto\"`, `\"\"`) — this is an input\n * affordance, not a shape change, so renderers stay untouched. Values\n * the picker can't model (`calc(…)`, a binding token) fall back to free\n * text rather than being clobbered.\n */\n CSS_DIMENSION = 'css-dimension',\n /**\n * Background fill editor (AGL-1331): a fill-type switch (default / solid\n * / linear / radial) over an angle box and a colour-stop list, each stop\n * bindable to a palette token or a literal. The persisted prop is ONE CSS\n * string under `backgroundImage` — a solid fill writes the explicit\n * keyword `none` and leaves `backgroundColor` to do the job, while the\n * default choice writes nothing at all (AGL-1338: the two differ on a\n * component instance, where absence means \"keep the component's fill\") —\n * so renderers stay untouched. Values\n * the editor cannot model (`conic-gradient`, `to bottom right`, a stacked\n * image list) fall back to free text rather than being clobbered.\n */\n CSS_GRADIENT = 'css-gradient',\n /**\n * Row-and-column grid editor for the Table element (AGL-2543).\n *\n * The persisted prop is still ONE string — pipe-delimited rows with the\n * markdown divider carrying per-column alignment — so the renderer and\n * existing documents stay untouched, and a comparison table already\n * authored inside a Markdown element pastes straight in. This is the\n * affordance that makes the element no-code: without it an author edits\n * pipe syntax, which is the audience the besigner exists to spare.\n */\n DATA_TABLE = 'data-table',\n DATE_PICKER = 'date-picker',\n DUAL_LIST_SELECT = 'dual-list-select',\n FIELD_ARRAY = 'field-array',\n ICON_PICKER = 'icon-picker',\n /**\n * markdown-lite document editor (AGL-1616): the WYSIWYG the console\n * already ships for blog entries and marketplace listings, rendered as the\n * attribute's field. The persisted prop is still ONE markdown-lite string,\n * so every renderer stays untouched — this is an input affordance, not a\n * shape change. Declared by an attribute whose value is a whole document\n * rather than a line of text; a plain TEXTAREA meant the Privacy Policy\n * body was edited as a 13 KB raw paste (AGL-1594).\n */\n MARKDOWN = 'markdown',\n INPUT_ADDON_BUTTON_GROUP = 'input-addon-button-group',\n INPUT_ADDON_GROUP = 'input-addon-group',\n PLAIN_TEXT = 'plain-text',\n /**\n * Named-preset picker with a raw escape hatch (AGL-2486): the theme's own\n * answers first, then plain-English presets that PREVIEW themselves, then\n * Custom…. The persisted prop is whatever the property already stored — a\n * number where a bare number is a theme multiple, a CSS string otherwise —\n * and a stored value matching no preset opens the field in its custom state\n * holding that value rather than dropping it.\n */\n PRESET_CHOICE = 'preset-choice',\n RADIO = 'radio',\n /**\n * Select listing the host's screens; the editor resolves the options from\n * the host routing map at render time and writes the chosen screen id.\n */\n SCREEN_SELECT = 'screen-select',\n /**\n * Select listing the canvas's other elements (AGL-557): the editor\n * resolves options from the live canvas at edit time and persists the\n * node id — e.g. the form's reveal-on-submit target.\n */\n NODE_SELECT = 'node-select',\n /**\n * Id-based entity pickers (AGL-343/344): the editor resolves options\n * from EntityPickerContext at edit time and persists the entity id —\n * renames never break the reference.\n */\n /**\n * Select listing the plugins installed for this site (AGL-1030): the editor\n * resolves options from the install set the console publishes and persists\n * the listing id. A picker rather than a typed document id — the same reason\n * every other reference in the designer is one, and here it also removes the\n * \"is this installed?\" question by construction.\n */\n PLUGIN_SELECT = 'plugin-select',\n /**\n * A placed plugin's declared settings, rendered as real fields (AGL-1049).\n * Reads the sibling plugin selection to know which manifest to offer.\n */\n PLUGIN_SETTINGS = 'plugin-settings',\n PRODUCT_SELECT = 'product-select',\n COLLECTION_SELECT = 'collection-select',\n CATEGORY_SELECT = 'category-select',\n DATASET_SELECT = 'dataset-select',\n /**\n * Select listing the model fields of the nearest ancestor node's chosen\n * dataset (AGL-556): the editor resolves options from\n * EntityPickerContext.entityFields using the ancestor's `datasetId`\n * (or legacy `datasetName` matched by label) and persists the stable\n * model fieldId — field renames never break the mapping.\n */\n DATASET_FIELD_SELECT = 'dataset-field-select',\n /**\n * Select listing the host's form entities (`docs/specs/reusable-forms.md`\n * §2c): the editor resolves options from EntityPickerContext.forms and\n * persists the form id. The same id-first reasoning as every picker in this\n * family, and here it is load-bearing rather than convenient — the string\n * it replaces was the form's whole identity, so a rename split the\n * submission history it named.\n */\n FORM_SELECT = 'form-select',\n SELECT = 'select',\n SLIDER = 'slider',\n SUB_FORM = 'sub-form',\n SWITCH = 'switch',\n TAB_ITEM = 'tab-item',\n TABS = 'tabs',\n TEXT_FIELD = 'text-field',\n TEXTAREA = 'textarea',\n /**\n * Theme-scale combo box (AGL-2486): offers the THEME's own scale for a\n * property — `theme.typography` for font size and weight,\n * `theme.zIndex` for stacking — while still accepting any raw value\n * (`18px`, `1.25rem`, `700`, `1400`), because arbitrary values are\n * legitimate. The persisted value is a theme token PATH\n * (`h4.fontSize`, `fontWeightBold`, `appBar`), which MUI's sx system\n * resolves against the active theme exactly as it resolves\n * `color: 'primary.main'` — so the element keeps following the theme\n * instead of freezing the number it had when it was styled.\n */\n THEME_SCALE = 'theme-scale',\n TIME_PICKER = 'time-picker',\n TOGGLE_BUTTON = 'toggle-button',\n WIZARD = 'wizard',\n}\n\nexport enum FieldValidatorType {\n EXACT_LENGTH = 'exact-length',\n MAX_LENGTH = 'max-length',\n MAX_NUMBER_VALUE = 'max-number-value',\n MIN_ITEMS = 'min-items',\n MIN_LENGTH = 'min-length',\n MIN_NUMBER_VALUE = 'min-number-value',\n PATTERN = 'pattern',\n REQUIRED = 'required',\n URL = 'url',\n}\n\nexport type FieldDataType =\n | 'boolean'\n | 'float'\n | 'integer'\n | 'number'\n | 'string'\n\nexport interface AglynAttributeSchema extends Dictionary<any> {\n name: string\n dataType?: DataType\n component: string | FieldComponentType\n validate?: Validator[]\n condition?: ConditionDefinition | ConditionDefinition[]\n initializeOnMount?: boolean\n initialValue?: unknown\n clearedValue?: unknown\n clearOnUnmount?: boolean\n actions?: FieldActions\n resolveProps?: ResolvePropsFunction\n description?: string\n /**\n * The one kind of media library file this attribute holds (AGL-3716):\n * `image`, `video`, `pdf` or `audio`. Its \"Browse media\" picker lists and\n * uploads only that kind. Read by the editor, never handed to the field.\n */\n mediaKind?: 'image' | 'video' | 'pdf' | 'audio'\n}\n\nexport interface AglynNodeSchema<P = JSX.AnyProps> {\n $id: NodeId\n componentId: ComponentId\n pluginId?: BundleId\n parentId?: NodeId\n sx?: JSX.SxProps\n props?: P\n nodes?: NodeId[] | AglynNodeSchema[]\n}\n"],"names":["LinealDirectiveFlag","FieldComponentType","FieldValidatorType"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAkBD,OAAO,IAAA,AAAKA,6CAAAA;;;WAAAA;MAGX;AAmLD,OAAO,IAAA,AAAKC,4CAAAA;IACV;;;;;;;;;GASC;;;;;IAMD;;;;;;;;GAQC;IAED;;;;;;;GAOC;IAED;;;;;;;;;;;GAWC;IAED;;;;;;;;;GASC;;;;;IAMD;;;;;;;;GAQC;;;;IAKD;;;;;;;GAOC;;IAGD;;;GAGC;IAED;;;;GAIC;IAED;;;;GAIC,GACD;;;;;;GAMC;IAED;;;GAGC;;;;;IAMD;;;;;;GAMC;IAED;;;;;;;GAOC;;;;;;;;;IAUD;;;;;;;;;;GAUC;;;;WA1JSA;MA+JX;AAED,OAAO,IAAA,AAAKC,4CAAAA;;;;;;;;;;WAAAA;MAUX"}
|
package/src/lib/types/nodes.d.ts
CHANGED
|
@@ -18,8 +18,13 @@ import type { ConditionDefinition, DataType, Validator } from '@data-driven-form
|
|
|
18
18
|
import type { FieldActions, ResolvePropsFunction } from '@data-driven-forms/react-form-renderer/common-types';
|
|
19
19
|
import type { MuiStyledOptions } from '@mui/system/createStyled';
|
|
20
20
|
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Minimal icon-props type used in component/preset schemas. Structurally
|
|
23
|
+
* compatible with @aglyn/shared-ui-jsx MdiIconProps, which draws `path` and
|
|
24
|
+
* takes no ReactNode children (only a `(d) => …` render function), so
|
|
25
|
+
* `children` is left out here too.
|
|
26
|
+
*/
|
|
27
|
+
export type MdiIconProps<D extends React.ElementType = 'svg', P = object> = Omit<SvgIconProps<D, P>, 'children'> & {
|
|
23
28
|
path?: string;
|
|
24
29
|
};
|
|
25
30
|
import type { ComponentId, ComponentsLinealOrder, NodeId, PresetId } from '../foundation';
|
|
@@ -609,6 +614,17 @@ export interface ComponentSchema<P = any> {
|
|
|
609
614
|
* the Branch/Stem/Leaf seam swappable for everything else.
|
|
610
615
|
*/
|
|
611
616
|
positionalChildren?: FEATURE_FLAG;
|
|
617
|
+
/**
|
|
618
|
+
* Component takes its text as a plain string `children`: no child
|
|
619
|
+
* elements and no `<aglyn-text>` wrapper around it. For an element whose
|
|
620
|
+
* DOM allows text and nothing else, such as `<option>`, where React and
|
|
621
|
+
* the browser's parser both drop an element child, and with it the text.
|
|
622
|
+
*
|
|
623
|
+
* Not `selfClosing`, which means a void element (`<img>`) and strips
|
|
624
|
+
* `children` altogether: a Select Option flagged that way rendered every
|
|
625
|
+
* dropdown choice on every published site with no words.
|
|
626
|
+
*/
|
|
627
|
+
plainTextChildren?: FEATURE_FLAG;
|
|
612
628
|
/**
|
|
613
629
|
* Nothing this component renders responds to the visitor until it is
|
|
614
630
|
* hydrated, beyond what its server HTML does on its own — copy, images,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/types/nodes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConditionDefinition,\n DataType,\n Validator,\n} from '@data-driven-forms/react-form-renderer'\nimport type {\n FieldActions,\n ResolvePropsFunction,\n} from '@data-driven-forms/react-form-renderer/common-types'\nimport type { MuiStyledOptions } from '@mui/system/createStyled'\nimport type { SvgIconProps } from '@mui/material/SvgIcon'\n/** Minimal icon-props type used in component/preset schemas. Structurally compatible with @aglyn/shared-ui-jsx MdiIconProps. */\nexport type MdiIconProps<D extends React.ElementType = 'svg', P = object> = SvgIconProps<D, P> & {\n path?: string\n}\nimport type {\n ComponentId,\n ComponentsLinealOrder,\n NodeId,\n PresetId,\n} from '../foundation'\nimport { ComponentCategory } from '../foundation/constants/components'\nimport type { ITimestamp } from '@aglyn/shared-util-timestamp'\nimport type React from 'react'\nimport type { ComponentClass, ComponentProps } from 'react'\nimport type { NODE_ROOT_ID } from '../canvas-manager'\nimport type { NodeInteraction } from '../app-utils/node-interactions'\n\nimport type {\n FEATURE_FLAG,\n FieldComponentType,\n RICH_TEXT_COMMANDS,\n} from '../foundation'\nimport type { PluginId } from '../plugin-manager'\nimport type { ElementContentMap, Node, Props, Taxonomic } from './ast'\nimport type { AglynDocument } from '../foundation'\nimport type { HostUid } from '../foundation'\n\ndeclare module './ast' {\n /**\n * This map registers all node types that may be used as top-level content in\n * the document.\n *\n * These types are accepted inside `root` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * // Allow using raw nodes defined by `rehype-raw`.\n * raw: Raw;\n * }\n * }\n */\n export interface RootContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n }\n\n /**\n * This map registers all node types that may be used as content in an\n * element.\n *\n * These types are accepted inside `element` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * custom: Custom;\n * }\n * }\n */\n export interface ElementContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n }\n}\n\n/**\n * This map registers all node types that may be used as content in an canvas\n * node.\n *\n * These types are accepted inside `element` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * custom: Custom;\n * }\n * }\n */\nexport interface CanvasNodeContentMap extends ElementContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n}\n\nexport type CanvasNodeContent = CanvasNodeContentMap[keyof CanvasNodeContentMap]\n\n/**\n * CanvasNode represents a the schema for building a JSX Element.\n */\nexport interface CanvasNode extends Node {\n /**\n * Represents this variant of a Node.\n */\n type: 'node'\n\n /**\n * List representing the children of a node.\n */\n children?: CanvasNodeContent[] | undefined\n\n /**\n * Represents the element's internal name defined by the user\n */\n name?: string | undefined\n\n /**\n * Represents the element's parent unique identifier\n */\n parentId?: string | undefined\n\n /**\n * Represents the elements' component unique identifier\n */\n componentId?: string | undefined\n\n /**\n * Represents the elements' components' plugin unique identifier\n */\n pluginId?: string | undefined\n\n /**\n * Represents information associated with the element.\n */\n props?: Props | undefined\n}\n\n/**\n * CanvasElement represents a living JSX Element\n */\nexport interface CanvasElement extends CanvasNode {\n /**\n * Represents the element's unique identifier\n */\n $id: string\n}\n\nexport type AbstractId = string\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface AbstractNodeSchema<P = JSX.AnyProps> extends CanvasNode {\n /**\n * The unique identifier for a node\n */\n $id: AbstractId\n title?: string\n displayName?: string\n description?: string\n\n children?: any\n nodes?: any\n\n /**\n * The node style properties for emotion\n */\n sx?: JSX.SxProps\n /**\n * The node props/attributes passed to the component\n */\n props?: P\n\n category?: any\n icon?: any\n\n createdAt?: ITimestamp\n updatedAt?: ITimestamp\n deletedAt?: ITimestamp\n}\n\n/**\n * CanvasPreset represents an encapsulated 'node' type as the root node for\n * crafting a living JSX Element\n */\nexport interface CanvasPreset extends Node, Taxonomic {\n /**\n * Represents this variant of a Node.\n */\n type: 'preset'\n\n /**\n * Represents the element's unique identifier\n */\n $id: string\n\n /**\n * Represents the elements' component unique identifier\n */\n componentId?: string | undefined\n\n /**\n * Represents the elements' components' plugin unique identifier\n */\n pluginId?: string | undefined\n\n /**\n * Represents information associated with the element.\n */\n props?: Props | undefined\n\n /**\n * Represents the element's internal name defined by the user\n */\n name?: string | undefined\n}\n\nexport type { NodeId }\n\n// @TODO ⚠️ Refactor for better adoption of hast\ntype PresetI = AglynDocument &\n Omit<AbstractNodeSchema<any>, 'type' | 'data'> &\n Omit<CanvasPreset, 'type' | 'data'>\n\ninterface PresetII extends PresetI {\n type: NodeType.PRESET | string\n}\n\nexport interface PresetSchema<P = JSX.AnyProps> extends PresetII {\n $id: PresetId\n pluginId?: PluginId\n displayName?: string\n description?: string\n category?: string | ComponentCategory\n /**\n * Extra words this element should be findable by in the element picker —\n * synonyms and the name people reach for when it is not the name we chose\n * (\"picture\" for Image, \"dropdown\" for Select).\n *\n * Search terms only; never rendered. A hit here ranks BELOW every hit on a\n * name, so a tag widens what the picker finds without letting a synonym\n * outrank the element actually called that (AGL-2486).\n */\n tags?: string[]\n /** Alias of {@link tags}; both are searched. */\n keywords?: string[]\n icon?: MdiIconProps\n data: NodeSchemaNested<P>\n /**\n * Interaction templates wired when the preset is inserted (AGL-589):\n * the host app resolves each `presetRef` marker to a freshly minted node\n * and persists the result. Presets that need hover choreography (a\n * primitive dropdown panel) ship working out of the box instead of asking\n * the user to author the interactions by hand.\n *\n * TEMPLATES, and named so. These are not interactions: they are\n * unresolved, they reference nodes that do not exist yet, and they are\n * consumed at insert time and never stored. What they resolve INTO lives\n * on the node as {@link NodeSchema.interactions}, and a `PresetSchema` is\n * assignable to a `NodeSchema` — so while the two shared a name, one of\n * them had to be wrong wherever a preset was passed as a node.\n */\n interactionTemplates?: PresetInteractionSchema[]\n}\n\n/**\n * A visibility step inside a {@link PresetSchema} interaction template.\n * Only the basic client visibility steps are expressible — presets\n * scaffold in-page choreography, never server automations.\n */\nexport interface PresetInteractionStepSchema {\n type: 'showElement' | 'hideElement' | 'toggleElement'\n /** `presetRef` of the preset node this step targets. */\n targetRef: string\n /** Optional grace delay, validated to 0–5000ms like the builder. */\n delayMs?: number\n /** Self-dismissal for steps that can reveal the target. */\n dismissOn?: Array<'escape' | 'outsideClick'>\n}\n\n/** An interaction template a preset wires on insert (AGL-589). */\nexport interface PresetInteractionSchema {\n name: string\n event: 'elementClick' | 'elementHoverEnter' | 'elementHoverLeave'\n /** `presetRef` of the preset node whose selector fires the trigger. */\n triggerRef: string\n steps: PresetInteractionStepSchema[]\n}\n\n// @TODO ⚠️ Refactor for better adoption of hast\ntype NodeI<P> = AglynDocument & Omit<AbstractNodeSchema<P>, 'type'>\n\nexport interface NodeSchema<P = JSX.AnyProps> extends NodeI<P> {\n type: NodeType | string\n /**\n * List of the children unique identifiers for the node\n */\n nodes?: NodeId[]\n /**\n * Class name to pass the DOM node, can also be defined in props\n */\n className?: string\n /**\n * Preset-authoring marker (AGL-589): names a node inside a preset's\n * `data` tree so the preset's interaction templates can reference it\n * (`triggerRef` / `targetRef`). Cloned onto the inserted node; inert\n * everywhere else.\n */\n presetRef?: string\n /**\n * Per-instance style overrides on a reusable-component instance node\n * (AGL-1306), keyed by target: `root` (see `STYLE_OVERRIDES_ROOT_KEY`)\n * addresses the component ROOT, and any other key is a DEFINITION-internal\n * node id addressing one leaf inside the component (AGL-1332). Each slice\n * is an sx-shaped record merged over that node's own sx at graft time\n * (`composeReusableComponentNodes` → `mergeNodeSx`), so one page's CTA can\n * switch to a white background AND repaint its headline without widening\n * the component's declared props or detaching.\n *\n * Keyed on the definition's id, never the grafted `cmp__{instance}__{def}`\n * id: the graft id is derived per placement, so it would not survive a\n * duplicate or a re-key, and the same component could not offer two\n * instances the same authoring vocabulary. A key naming a node the\n * definition no longer has is ignored — a component edited later degrades\n * to its own styling instead of taking a page down.\n *\n * A first-class node field, NOT a prop: `AglynNode`'s constructor drops\n * unknown top-level keys, and anything in `props` is spread onto the\n * instance's wrapper DOM element. Lives on the instance node in the\n * document that places it — it survives component republish and never\n * pins the instance to an old component version, because the graft\n * always merges it over the definition's CURRENT nodes.\n */\n styleOverrides?: Record<string, JSX.SxProps>\n /**\n * Per-instance ATTRIBUTE overrides on a reusable-component instance node\n * (AGL-1899) — the same addressing as {@link styleOverrides}, applied to\n * a node's props instead of its sx, so one placement can carry a\n * different button `variant`, `size` or `href` without the component\n * declaring a prop for it and without detaching.\n *\n * Merged **per named prop**: a slice replaces only the props it names and\n * leaves the definition's others alone, so a component that later adds a\n * prop still gives every existing instance the new default. That is\n * deliberately shallower than the sx merge next door — an sx slice\n * cascades because `@scheme dark` and breakpoint objects are themselves\n * selectors, whereas a prop value is one value, and half-merging two\n * objects that merely look alike (say a `slotProps`) would produce a\n * third thing neither side asked for.\n *\n * `sx` is refused here. Styling an instance already has a mechanism one\n * field up, and honouring both would leave two writers racing for one\n * rendered value with no rule to say which wins.\n *\n * Applied BEFORE `{{prop.*}}` substitution, so an override may itself be\n * written in tokens and still resolves, and an override on a prop the\n * definition binds to a declared prop wins — the more specific placement\n * beats the component's own default.\n */\n attrOverrides?: Record<string, Record<string, unknown>>\n /**\n * EDITOR-ONLY: a screen's per-page restyling of its layout's elements\n * (AGL-3286), parked on the screen canvas ROOT while the besigner is open.\n *\n * Stored on the screen VERSION as `layoutStyleOverrides`, never in `nodes`:\n * the editor injects it here on load and lifts it back out on save\n * (`injectLayoutStyleOverrides` / `extractLayoutStyleOverrides`). Carried on\n * the root so an edit is an undo step, marks the screen dirty and rides the\n * working draft like any other change. Composition ignores it — the screen\n * root is dropped when it is grafted into the layout's slot.\n */\n layoutStyleOverrides?: Record<string, Record<string, Record<string, unknown>>>\n /**\n * Interactions this element carries — the click, hover and\n * scroll-into-view choreography authored on it in the besigner.\n *\n * ## Why they live on the NODE\n *\n * They used to be rows in `hosts/{hostId}/actions`, bound to an element by\n * a `[data-aglyn=\"leaf:<id>\"]` selector — the same collection the Workflows\n * page lists. An interaction is not a site-wide automation, and storing it\n * as one had four consequences, every one of them a thing an author would\n * expect to work:\n *\n * - it was not versioned with the document, so it neither published nor\n * rolled back with the screen it belongs to;\n * - it did not travel with a component copied to another site, or packaged\n * into a template or a plugin — the element arrived inert;\n * - deleting the element left the action behind, pointing at a selector\n * nothing resolves;\n * - and a nav's hover choreography sat in the site's automation list\n * beside \"when an order is placed\", which is a different kind of thing.\n *\n * Host actions remain, and remain the right home for a genuine site event.\n * The split is the concept: an ACTION is something the site does, an\n * INTERACTION is something an element does.\n *\n * ## Shape\n *\n * Deliberately the same `SiteInteraction` a site-wide interaction is, so\n * nothing about the runtime changes: the selector is stamped from this\n * node's own id when the page is composed, and the compiled result is the\n * shape the client engine has always consumed. `trigger.selector` is\n * therefore ignored here — the node IS the selector.\n */\n interactions?: NodeInteraction[]\n /**\n * Hidden by the author — the eye on the element's hierarchy row.\n *\n * Renders `display: none` on the canvas AND on the published site. It is\n * the plain \"I do not want this on the page\" switch: no runtime, no\n * interaction, nothing reveals it. Showing it again is the same eye.\n *\n * ## Why a FIELD and not a style\n *\n * Because it has to override the element's own display rather than replace\n * it. An author who toggles the eye on a Stack laid out with\n * `display: flex` must get that flex back when they toggle it off, and\n * writing `display: none` into `node.sx` destroys the value it overwrote —\n * there is nothing left to restore. Composed LAST in `Leaf` instead, so it\n * wins on the cascade and the stored style is never touched.\n *\n * ## Not {@link ELEMENT_HIDDEN_CLASS}\n *\n * `aglyn-hidden` is a different thing wearing a similar name: it means\n * \"starts hidden, and an interaction shows it\" — a mega-menu panel, a\n * drawer. That class is part of a runtime contract (the show/hide steps\n * toggle it, and the canvas reveals it for designing), and it is bespoke to\n * that job. A visibility toggle that wrote it would enrol every hidden\n * element in a choreography it is not part of.\n */\n hidden?: boolean\n /**\n * The computed node parent (only for type completion)\n */\n readonly parent?: NodeSchema<any> | null\n /**\n * The computed node parent (only for type completion)\n */\n readonly children?: NodeSchema<any>[]\n /**\n * The computed index in parent nodes (only for type completion)\n */\n readonly index?: number | null\n /**\n * The computed label (only for type completion)\n */\n readonly labelShort?: string | undefined\n /**\n * The computed breadcrumb path (only for type completion)\n */\n readonly breadcrumbPath?: NodeBreadcrumbPath\n /**\n * The computed component schema (only for type completion)\n */\n readonly componentSchema?: ComponentSchema | undefined\n /**\n * The computed guard for of child nodes (only for type completion)\n */\n readonly hasNodes?: boolean\n /**\n * The computed property for the resolved props from component schema\n */\n readonly resolvedProps?: P\n}\n\nexport enum NodeType {\n NODE = 'node',\n TEXT = 'text',\n NUMBER = 'number',\n SCREEN = 'screen',\n REF = 'ref',\n PRESET = 'preset',\n}\n\nexport type NodeSchemaJSON<P = JSX.AnyProps> = Omit<\n NodeSchema<P>,\n | 'parent'\n | 'index'\n | 'labelShort'\n | 'breadcrumbPath'\n | 'componentSchema'\n | 'hasNodes'\n>\n\nexport type NodeSchemaNested<P = JSX.AnyProps> = Omit<\n NodeSchemaJSON<P>,\n 'nodes'\n> & { nodes?: NodeSchemaNested<any>[] }\n\nexport type NodesMap = Record<NodeId, NodeSchema<any>>\n\nexport type NodeBreadcrumbPath = [\n root: string & typeof NODE_ROOT_ID,\n ...nodes: [...ancestors: NodeId[], node: NodeId],\n]\n\nexport type ProcessableNodes =\n | NodeSchemaNested<any>[]\n | NodeSchemaNested<any>\n | Record<NodeId, NodeSchema>\n\nexport { ComponentCategory }\n\nexport type { ComponentId }\nexport type { PresetId }\n\nexport type ComponentFactory<\n P extends ComponentProps<C> | any = any,\n C extends keyof JSX.IntrinsicElements | JSX.ElementConstructor<any> = any,\n> = ComponentClass<P> | JSX.ElementConstructor<P> | keyof JSX.IntrinsicElements\n// | keyof JSX.IntrinsicElements[keyof JSX.IntrinsicElements]\n\nexport type { ComponentsLinealOrder }\n\n/**\n * What the Attributes panel knows about the element a field edits, handed to\n * an attribute's `resolveProps` as its fourth argument.\n *\n * data-driven-forms gives a field its own value and the form's values, which\n * are the element's props and nothing else. A rule about the element as a\n * whole needs more than that: whether a Link Container holds anything that\n * names its link depends on the elements inside it. So the panel adds the\n * node, and a lookup for the ids listed in its `nodes`.\n *\n * Absent wherever a field is drawn outside that panel, including a unit test\n * calling the function directly, so a `resolveProps` that reads it has to\n * treat a missing context as having nothing to say.\n */\nexport interface AttributeFieldContext {\n /** The element the Attributes panel is editing. */\n node: NodeSchema<any>\n /** An element of the same document by id, such as a child in `nodes`. */\n getNode: (id: NodeId) => NodeSchema<any> | undefined\n}\n\n/**\n * An attribute's `resolveProps`: the three arguments data-driven-forms\n * passes, then the {@link AttributeFieldContext} the Attributes panel adds.\n */\nexport type AttributeResolveProps = (\n ...args: [\n ...Parameters<ResolvePropsFunction>,\n context?: AttributeFieldContext,\n ]\n) => ReturnType<ResolvePropsFunction>\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface AttributeSchema extends Dictionary<any> {\n name: string\n dataType?: DataType\n component: string | FieldComponentType\n validate?: Validator[]\n condition?: ConditionDefinition | ConditionDefinition[]\n initializeOnMount?: boolean\n initialValue?: any\n clearedValue?: any\n clearOnUnmount?: boolean\n actions?: FieldActions\n resolveProps?: AttributeResolveProps\n description?: string\n}\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface ComponentSchema<P = any> {\n $id?: ComponentId\n pluginId?: PluginId\n kind?: 'element' | 'plaintext' | 'markdown'\n\n displayName: string\n title?: string\n subtitle?: string\n description?: string\n category?: string | ComponentCategory\n\n /**\n * Extra words this element should be findable by in the element picker —\n * synonyms and the name people reach for when it is not the name we chose\n * (\"picture\" for Image, \"dropdown\" for Select).\n *\n * Search terms only; never rendered. A hit here ranks BELOW every hit on a\n * name, so a tag widens what the picker finds without letting a synonym\n * outrank the element actually called that (AGL-2486).\n */\n tags?: string[]\n /** Alias of {@link tags}; both are searched. */\n keywords?: string[]\n\n /**\n * Icon props for display around besigner\n */\n icon?: MdiIconProps\n /**\n * Options to be passed to styled(Component, \\{...styledOptions\\})\n */\n styledOptions?: MuiStyledOptions\n\n /**\n * Define a limitation for nodes allowed as direct descendents\n */\n restrictChildren?: ComponentsLinealOrder\n /**\n * Define a limitation for nodes allowed to be direct ancestors\n */\n restrictParent?: ComponentsLinealOrder\n\n /**\n * Filter props\n */\n resolveProps?: JSX.ResolveProps<NodeSchema<P>>\n\n /**\n * Attribute fields to modify the contextual properties\n * New version\n */\n attributes?: AttributeSchema[]\n\n /**\n * Which groups of formatting the inline rich-text toolbar offers for this\n * component (AGL-2557). Read only where `flags.richTextEditable` is on.\n *\n * Omitted means every group, which is what leaves Typography exactly as it\n * was. Naming a subset narrows the toolbar AND the commit: a surface that\n * offers neither lists nor links is phrasing-only, and the sanitizer holds\n * it to that whatever an author pastes in.\n */\n richTextCommands?: RICH_TEXT_COMMANDS[]\n\n /**\n * Feature flags\n */\n flags?: {\n /**\n * Disable the use of emotion styled\n */\n emotion?: FEATURE_FLAG\n /**\n * Can the nodes of this component type be cloned?\n */\n cloning?: FEATURE_FLAG\n /**\n * Allow dragging nodes of this component type\n */\n dragging?: FEATURE_FLAG\n /**\n * Allow dropping nodes inside nodes of this component type\n */\n dropping?: FEATURE_FLAG\n /**\n * Allow editing element attributes of this component type\n */\n editing?: FEATURE_FLAG\n /**\n * Allow removing nodes of this component type\n */\n removing?: FEATURE_FLAG\n /**\n * Describe nodes of this component type to be self-closing\n */\n selfClosing?: FEATURE_FLAG\n /**\n * Component renders its `children` prop as text content the editor may\n * edit directly (Attributes \"Text\" field, inline canvas editing).\n */\n textEditable?: FEATURE_FLAG\n /**\n * Component also accepts basic rich text (AGL-54): the inline editor\n * upgrades to a formatting surface and commits sanitized HTML into the\n * `html` prop (with `children` kept as the plain-text fallback).\n */\n richTextEditable?: FEATURE_FLAG\n /**\n * Component reads its children POSITIONALLY (AGL-1237), so the renderer\n * hands it one React child per node child instead of the single `<Branch>`\n * element it normally passes.\n *\n * MUI's Accordion does `const [summary, ...rest] = Children.toArray(children)`,\n * and `toArray` does not traverse into an element — so with the default\n * wrapping the summary swallowed the whole subtree and the Collapse got\n * nothing. Every accordion on every published site expanded to reveal an\n * empty panel while its content rendered unconditionally inside the\n * summary's heading.\n *\n * Opt in only for components with this contract; the wrapper is what keeps\n * the Branch/Stem/Leaf seam swappable for everything else.\n */\n positionalChildren?: FEATURE_FLAG\n /**\n * Nothing this component renders responds to the visitor until it is\n * hydrated, beyond what its server HTML does on its own — copy, images,\n * layout, a plain `<a href>` (AGL-3581).\n *\n * On a published page, a subtree made ONLY of components declaring this\n * may keep its server HTML through hydration and render when the visitor\n * nears it, instead of hydrating with the rest of the page. One component\n * without it keeps its whole ancestry hydrating at once, so leave it off\n * anything with a handler, state or an effect a visitor could reach:\n * menus, toggles, forms, accordions, carousels, players.\n */\n lazyHydration?: FEATURE_FLAG\n /**\n * Renders its node children directly inside its root DOM element, adds\n * nothing of its own around or among them, and passes props it does not\n * know through to that element (AGL-3581).\n *\n * That is what lets a static subtree keep its server HTML: the renderer\n * hands such a component `dangerouslySetInnerHTML` in place of its\n * children while the page hydrates, so its root hydrates and its contents\n * are left exactly as the server sent them. A component that wraps,\n * joins or decorates its children (a divider between them, a ripple\n * after them) must not declare it — React refuses an element that has\n * both.\n */\n childrenInRoot?: FEATURE_FLAG\n }\n}\n\nexport type SchemasByCategory = Record<\n ComponentCategory | string,\n (ComponentSchema<any> | PresetSchema<any>)[]\n>\n\nexport interface ScreenSchema {\n nodes: NodeSchemaNested\n createdAt?: ITimestamp\n updatedAt?: ITimestamp\n hostId?: HostUid\n}\n"],"names":["ComponentCategory","NodeType"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAuBD,SAASA,iBAAiB,QAAQ,wCAAoC;AAictE,OAAO,IAAA,AAAKC,kCAAAA;;;;;;;WAAAA;MAOX;AA6BD,SAASD,iBAAiB,GAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/types/nodes.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ConditionDefinition,\n DataType,\n Validator,\n} from '@data-driven-forms/react-form-renderer'\nimport type {\n FieldActions,\n ResolvePropsFunction,\n} from '@data-driven-forms/react-form-renderer/common-types'\nimport type { MuiStyledOptions } from '@mui/system/createStyled'\nimport type { SvgIconProps } from '@mui/material/SvgIcon'\n/**\n * Minimal icon-props type used in component/preset schemas. Structurally\n * compatible with @aglyn/shared-ui-jsx MdiIconProps, which draws `path` and\n * takes no ReactNode children (only a `(d) => …` render function), so\n * `children` is left out here too.\n */\nexport type MdiIconProps<D extends React.ElementType = 'svg', P = object> = Omit<SvgIconProps<D, P>, 'children'> & {\n path?: string\n}\nimport type {\n ComponentId,\n ComponentsLinealOrder,\n NodeId,\n PresetId,\n} from '../foundation'\nimport { ComponentCategory } from '../foundation/constants/components'\nimport type { ITimestamp } from '@aglyn/shared-util-timestamp'\nimport type React from 'react'\nimport type { ComponentClass, ComponentProps } from 'react'\nimport type { NODE_ROOT_ID } from '../canvas-manager'\nimport type { NodeInteraction } from '../app-utils/node-interactions'\n\nimport type {\n FEATURE_FLAG,\n FieldComponentType,\n RICH_TEXT_COMMANDS,\n} from '../foundation'\nimport type { PluginId } from '../plugin-manager'\nimport type { ElementContentMap, Node, Props, Taxonomic } from './ast'\nimport type { AglynDocument } from '../foundation'\nimport type { HostUid } from '../foundation'\n\ndeclare module './ast' {\n /**\n * This map registers all node types that may be used as top-level content in\n * the document.\n *\n * These types are accepted inside `root` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * // Allow using raw nodes defined by `rehype-raw`.\n * raw: Raw;\n * }\n * }\n */\n export interface RootContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n }\n\n /**\n * This map registers all node types that may be used as content in an\n * element.\n *\n * These types are accepted inside `element` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * custom: Custom;\n * }\n * }\n */\n export interface ElementContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n }\n}\n\n/**\n * This map registers all node types that may be used as content in an canvas\n * node.\n *\n * These types are accepted inside `element` nodes.\n *\n * This interface can be augmented to register custom node types.\n *\n * @example\n * declare module 'hast' {\n * interface RootContentMap {\n * custom: Custom;\n * }\n * }\n */\nexport interface CanvasNodeContentMap extends ElementContentMap {\n canvasNode: CanvasNode\n canvasElement: CanvasElement\n}\n\nexport type CanvasNodeContent = CanvasNodeContentMap[keyof CanvasNodeContentMap]\n\n/**\n * CanvasNode represents a the schema for building a JSX Element.\n */\nexport interface CanvasNode extends Node {\n /**\n * Represents this variant of a Node.\n */\n type: 'node'\n\n /**\n * List representing the children of a node.\n */\n children?: CanvasNodeContent[] | undefined\n\n /**\n * Represents the element's internal name defined by the user\n */\n name?: string | undefined\n\n /**\n * Represents the element's parent unique identifier\n */\n parentId?: string | undefined\n\n /**\n * Represents the elements' component unique identifier\n */\n componentId?: string | undefined\n\n /**\n * Represents the elements' components' plugin unique identifier\n */\n pluginId?: string | undefined\n\n /**\n * Represents information associated with the element.\n */\n props?: Props | undefined\n}\n\n/**\n * CanvasElement represents a living JSX Element\n */\nexport interface CanvasElement extends CanvasNode {\n /**\n * Represents the element's unique identifier\n */\n $id: string\n}\n\nexport type AbstractId = string\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface AbstractNodeSchema<P = JSX.AnyProps> extends CanvasNode {\n /**\n * The unique identifier for a node\n */\n $id: AbstractId\n title?: string\n displayName?: string\n description?: string\n\n children?: any\n nodes?: any\n\n /**\n * The node style properties for emotion\n */\n sx?: JSX.SxProps\n /**\n * The node props/attributes passed to the component\n */\n props?: P\n\n category?: any\n icon?: any\n\n createdAt?: ITimestamp\n updatedAt?: ITimestamp\n deletedAt?: ITimestamp\n}\n\n/**\n * CanvasPreset represents an encapsulated 'node' type as the root node for\n * crafting a living JSX Element\n */\nexport interface CanvasPreset extends Node, Taxonomic {\n /**\n * Represents this variant of a Node.\n */\n type: 'preset'\n\n /**\n * Represents the element's unique identifier\n */\n $id: string\n\n /**\n * Represents the elements' component unique identifier\n */\n componentId?: string | undefined\n\n /**\n * Represents the elements' components' plugin unique identifier\n */\n pluginId?: string | undefined\n\n /**\n * Represents information associated with the element.\n */\n props?: Props | undefined\n\n /**\n * Represents the element's internal name defined by the user\n */\n name?: string | undefined\n}\n\nexport type { NodeId }\n\n// @TODO ⚠️ Refactor for better adoption of hast\ntype PresetI = AglynDocument &\n Omit<AbstractNodeSchema<any>, 'type' | 'data'> &\n Omit<CanvasPreset, 'type' | 'data'>\n\ninterface PresetII extends PresetI {\n type: NodeType.PRESET | string\n}\n\nexport interface PresetSchema<P = JSX.AnyProps> extends PresetII {\n $id: PresetId\n pluginId?: PluginId\n displayName?: string\n description?: string\n category?: string | ComponentCategory\n /**\n * Extra words this element should be findable by in the element picker —\n * synonyms and the name people reach for when it is not the name we chose\n * (\"picture\" for Image, \"dropdown\" for Select).\n *\n * Search terms only; never rendered. A hit here ranks BELOW every hit on a\n * name, so a tag widens what the picker finds without letting a synonym\n * outrank the element actually called that (AGL-2486).\n */\n tags?: string[]\n /** Alias of {@link tags}; both are searched. */\n keywords?: string[]\n icon?: MdiIconProps\n data: NodeSchemaNested<P>\n /**\n * Interaction templates wired when the preset is inserted (AGL-589):\n * the host app resolves each `presetRef` marker to a freshly minted node\n * and persists the result. Presets that need hover choreography (a\n * primitive dropdown panel) ship working out of the box instead of asking\n * the user to author the interactions by hand.\n *\n * TEMPLATES, and named so. These are not interactions: they are\n * unresolved, they reference nodes that do not exist yet, and they are\n * consumed at insert time and never stored. What they resolve INTO lives\n * on the node as {@link NodeSchema.interactions}, and a `PresetSchema` is\n * assignable to a `NodeSchema` — so while the two shared a name, one of\n * them had to be wrong wherever a preset was passed as a node.\n */\n interactionTemplates?: PresetInteractionSchema[]\n}\n\n/**\n * A visibility step inside a {@link PresetSchema} interaction template.\n * Only the basic client visibility steps are expressible — presets\n * scaffold in-page choreography, never server automations.\n */\nexport interface PresetInteractionStepSchema {\n type: 'showElement' | 'hideElement' | 'toggleElement'\n /** `presetRef` of the preset node this step targets. */\n targetRef: string\n /** Optional grace delay, validated to 0–5000ms like the builder. */\n delayMs?: number\n /** Self-dismissal for steps that can reveal the target. */\n dismissOn?: Array<'escape' | 'outsideClick'>\n}\n\n/** An interaction template a preset wires on insert (AGL-589). */\nexport interface PresetInteractionSchema {\n name: string\n event: 'elementClick' | 'elementHoverEnter' | 'elementHoverLeave'\n /** `presetRef` of the preset node whose selector fires the trigger. */\n triggerRef: string\n steps: PresetInteractionStepSchema[]\n}\n\n// @TODO ⚠️ Refactor for better adoption of hast\ntype NodeI<P> = AglynDocument & Omit<AbstractNodeSchema<P>, 'type'>\n\nexport interface NodeSchema<P = JSX.AnyProps> extends NodeI<P> {\n type: NodeType | string\n /**\n * List of the children unique identifiers for the node\n */\n nodes?: NodeId[]\n /**\n * Class name to pass the DOM node, can also be defined in props\n */\n className?: string\n /**\n * Preset-authoring marker (AGL-589): names a node inside a preset's\n * `data` tree so the preset's interaction templates can reference it\n * (`triggerRef` / `targetRef`). Cloned onto the inserted node; inert\n * everywhere else.\n */\n presetRef?: string\n /**\n * Per-instance style overrides on a reusable-component instance node\n * (AGL-1306), keyed by target: `root` (see `STYLE_OVERRIDES_ROOT_KEY`)\n * addresses the component ROOT, and any other key is a DEFINITION-internal\n * node id addressing one leaf inside the component (AGL-1332). Each slice\n * is an sx-shaped record merged over that node's own sx at graft time\n * (`composeReusableComponentNodes` → `mergeNodeSx`), so one page's CTA can\n * switch to a white background AND repaint its headline without widening\n * the component's declared props or detaching.\n *\n * Keyed on the definition's id, never the grafted `cmp__{instance}__{def}`\n * id: the graft id is derived per placement, so it would not survive a\n * duplicate or a re-key, and the same component could not offer two\n * instances the same authoring vocabulary. A key naming a node the\n * definition no longer has is ignored — a component edited later degrades\n * to its own styling instead of taking a page down.\n *\n * A first-class node field, NOT a prop: `AglynNode`'s constructor drops\n * unknown top-level keys, and anything in `props` is spread onto the\n * instance's wrapper DOM element. Lives on the instance node in the\n * document that places it — it survives component republish and never\n * pins the instance to an old component version, because the graft\n * always merges it over the definition's CURRENT nodes.\n */\n styleOverrides?: Record<string, JSX.SxProps>\n /**\n * Per-instance ATTRIBUTE overrides on a reusable-component instance node\n * (AGL-1899) — the same addressing as {@link styleOverrides}, applied to\n * a node's props instead of its sx, so one placement can carry a\n * different button `variant`, `size` or `href` without the component\n * declaring a prop for it and without detaching.\n *\n * Merged **per named prop**: a slice replaces only the props it names and\n * leaves the definition's others alone, so a component that later adds a\n * prop still gives every existing instance the new default. That is\n * deliberately shallower than the sx merge next door — an sx slice\n * cascades because `@scheme dark` and breakpoint objects are themselves\n * selectors, whereas a prop value is one value, and half-merging two\n * objects that merely look alike (say a `slotProps`) would produce a\n * third thing neither side asked for.\n *\n * `sx` is refused here. Styling an instance already has a mechanism one\n * field up, and honouring both would leave two writers racing for one\n * rendered value with no rule to say which wins.\n *\n * Applied BEFORE `{{prop.*}}` substitution, so an override may itself be\n * written in tokens and still resolves, and an override on a prop the\n * definition binds to a declared prop wins — the more specific placement\n * beats the component's own default.\n */\n attrOverrides?: Record<string, Record<string, unknown>>\n /**\n * EDITOR-ONLY: a screen's per-page restyling of its layout's elements\n * (AGL-3286), parked on the screen canvas ROOT while the besigner is open.\n *\n * Stored on the screen VERSION as `layoutStyleOverrides`, never in `nodes`:\n * the editor injects it here on load and lifts it back out on save\n * (`injectLayoutStyleOverrides` / `extractLayoutStyleOverrides`). Carried on\n * the root so an edit is an undo step, marks the screen dirty and rides the\n * working draft like any other change. Composition ignores it — the screen\n * root is dropped when it is grafted into the layout's slot.\n */\n layoutStyleOverrides?: Record<string, Record<string, Record<string, unknown>>>\n /**\n * Interactions this element carries — the click, hover and\n * scroll-into-view choreography authored on it in the besigner.\n *\n * ## Why they live on the NODE\n *\n * They used to be rows in `hosts/{hostId}/actions`, bound to an element by\n * a `[data-aglyn=\"leaf:<id>\"]` selector — the same collection the Workflows\n * page lists. An interaction is not a site-wide automation, and storing it\n * as one had four consequences, every one of them a thing an author would\n * expect to work:\n *\n * - it was not versioned with the document, so it neither published nor\n * rolled back with the screen it belongs to;\n * - it did not travel with a component copied to another site, or packaged\n * into a template or a plugin — the element arrived inert;\n * - deleting the element left the action behind, pointing at a selector\n * nothing resolves;\n * - and a nav's hover choreography sat in the site's automation list\n * beside \"when an order is placed\", which is a different kind of thing.\n *\n * Host actions remain, and remain the right home for a genuine site event.\n * The split is the concept: an ACTION is something the site does, an\n * INTERACTION is something an element does.\n *\n * ## Shape\n *\n * Deliberately the same `SiteInteraction` a site-wide interaction is, so\n * nothing about the runtime changes: the selector is stamped from this\n * node's own id when the page is composed, and the compiled result is the\n * shape the client engine has always consumed. `trigger.selector` is\n * therefore ignored here — the node IS the selector.\n */\n interactions?: NodeInteraction[]\n /**\n * Hidden by the author — the eye on the element's hierarchy row.\n *\n * Renders `display: none` on the canvas AND on the published site. It is\n * the plain \"I do not want this on the page\" switch: no runtime, no\n * interaction, nothing reveals it. Showing it again is the same eye.\n *\n * ## Why a FIELD and not a style\n *\n * Because it has to override the element's own display rather than replace\n * it. An author who toggles the eye on a Stack laid out with\n * `display: flex` must get that flex back when they toggle it off, and\n * writing `display: none` into `node.sx` destroys the value it overwrote —\n * there is nothing left to restore. Composed LAST in `Leaf` instead, so it\n * wins on the cascade and the stored style is never touched.\n *\n * ## Not {@link ELEMENT_HIDDEN_CLASS}\n *\n * `aglyn-hidden` is a different thing wearing a similar name: it means\n * \"starts hidden, and an interaction shows it\" — a mega-menu panel, a\n * drawer. That class is part of a runtime contract (the show/hide steps\n * toggle it, and the canvas reveals it for designing), and it is bespoke to\n * that job. A visibility toggle that wrote it would enrol every hidden\n * element in a choreography it is not part of.\n */\n hidden?: boolean\n /**\n * The computed node parent (only for type completion)\n */\n readonly parent?: NodeSchema<any> | null\n /**\n * The computed node parent (only for type completion)\n */\n readonly children?: NodeSchema<any>[]\n /**\n * The computed index in parent nodes (only for type completion)\n */\n readonly index?: number | null\n /**\n * The computed label (only for type completion)\n */\n readonly labelShort?: string | undefined\n /**\n * The computed breadcrumb path (only for type completion)\n */\n readonly breadcrumbPath?: NodeBreadcrumbPath\n /**\n * The computed component schema (only for type completion)\n */\n readonly componentSchema?: ComponentSchema | undefined\n /**\n * The computed guard for of child nodes (only for type completion)\n */\n readonly hasNodes?: boolean\n /**\n * The computed property for the resolved props from component schema\n */\n readonly resolvedProps?: P\n}\n\nexport enum NodeType {\n NODE = 'node',\n TEXT = 'text',\n NUMBER = 'number',\n SCREEN = 'screen',\n REF = 'ref',\n PRESET = 'preset',\n}\n\nexport type NodeSchemaJSON<P = JSX.AnyProps> = Omit<\n NodeSchema<P>,\n | 'parent'\n | 'index'\n | 'labelShort'\n | 'breadcrumbPath'\n | 'componentSchema'\n | 'hasNodes'\n>\n\nexport type NodeSchemaNested<P = JSX.AnyProps> = Omit<\n NodeSchemaJSON<P>,\n 'nodes'\n> & { nodes?: NodeSchemaNested<any>[] }\n\nexport type NodesMap = Record<NodeId, NodeSchema<any>>\n\nexport type NodeBreadcrumbPath = [\n root: string & typeof NODE_ROOT_ID,\n ...nodes: [...ancestors: NodeId[], node: NodeId],\n]\n\nexport type ProcessableNodes =\n | NodeSchemaNested<any>[]\n | NodeSchemaNested<any>\n | Record<NodeId, NodeSchema>\n\nexport { ComponentCategory }\n\nexport type { ComponentId }\nexport type { PresetId }\n\nexport type ComponentFactory<\n P extends ComponentProps<C> | any = any,\n C extends keyof JSX.IntrinsicElements | JSX.ElementConstructor<any> = any,\n> = ComponentClass<P> | JSX.ElementConstructor<P> | keyof JSX.IntrinsicElements\n// | keyof JSX.IntrinsicElements[keyof JSX.IntrinsicElements]\n\nexport type { ComponentsLinealOrder }\n\n/**\n * What the Attributes panel knows about the element a field edits, handed to\n * an attribute's `resolveProps` as its fourth argument.\n *\n * data-driven-forms gives a field its own value and the form's values, which\n * are the element's props and nothing else. A rule about the element as a\n * whole needs more than that: whether a Link Container holds anything that\n * names its link depends on the elements inside it. So the panel adds the\n * node, and a lookup for the ids listed in its `nodes`.\n *\n * Absent wherever a field is drawn outside that panel, including a unit test\n * calling the function directly, so a `resolveProps` that reads it has to\n * treat a missing context as having nothing to say.\n */\nexport interface AttributeFieldContext {\n /** The element the Attributes panel is editing. */\n node: NodeSchema<any>\n /** An element of the same document by id, such as a child in `nodes`. */\n getNode: (id: NodeId) => NodeSchema<any> | undefined\n}\n\n/**\n * An attribute's `resolveProps`: the three arguments data-driven-forms\n * passes, then the {@link AttributeFieldContext} the Attributes panel adds.\n */\nexport type AttributeResolveProps = (\n ...args: [\n ...Parameters<ResolvePropsFunction>,\n context?: AttributeFieldContext,\n ]\n) => ReturnType<ResolvePropsFunction>\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface AttributeSchema extends Dictionary<any> {\n name: string\n dataType?: DataType\n component: string | FieldComponentType\n validate?: Validator[]\n condition?: ConditionDefinition | ConditionDefinition[]\n initializeOnMount?: boolean\n initialValue?: any\n clearedValue?: any\n clearOnUnmount?: boolean\n actions?: FieldActions\n resolveProps?: AttributeResolveProps\n description?: string\n}\n\n// @TODO ⚠️ Refactor for better adoption of hast\nexport interface ComponentSchema<P = any> {\n $id?: ComponentId\n pluginId?: PluginId\n kind?: 'element' | 'plaintext' | 'markdown'\n\n displayName: string\n title?: string\n subtitle?: string\n description?: string\n category?: string | ComponentCategory\n\n /**\n * Extra words this element should be findable by in the element picker —\n * synonyms and the name people reach for when it is not the name we chose\n * (\"picture\" for Image, \"dropdown\" for Select).\n *\n * Search terms only; never rendered. A hit here ranks BELOW every hit on a\n * name, so a tag widens what the picker finds without letting a synonym\n * outrank the element actually called that (AGL-2486).\n */\n tags?: string[]\n /** Alias of {@link tags}; both are searched. */\n keywords?: string[]\n\n /**\n * Icon props for display around besigner\n */\n icon?: MdiIconProps\n /**\n * Options to be passed to styled(Component, \\{...styledOptions\\})\n */\n styledOptions?: MuiStyledOptions\n\n /**\n * Define a limitation for nodes allowed as direct descendents\n */\n restrictChildren?: ComponentsLinealOrder\n /**\n * Define a limitation for nodes allowed to be direct ancestors\n */\n restrictParent?: ComponentsLinealOrder\n\n /**\n * Filter props\n */\n resolveProps?: JSX.ResolveProps<NodeSchema<P>>\n\n /**\n * Attribute fields to modify the contextual properties\n * New version\n */\n attributes?: AttributeSchema[]\n\n /**\n * Which groups of formatting the inline rich-text toolbar offers for this\n * component (AGL-2557). Read only where `flags.richTextEditable` is on.\n *\n * Omitted means every group, which is what leaves Typography exactly as it\n * was. Naming a subset narrows the toolbar AND the commit: a surface that\n * offers neither lists nor links is phrasing-only, and the sanitizer holds\n * it to that whatever an author pastes in.\n */\n richTextCommands?: RICH_TEXT_COMMANDS[]\n\n /**\n * Feature flags\n */\n flags?: {\n /**\n * Disable the use of emotion styled\n */\n emotion?: FEATURE_FLAG\n /**\n * Can the nodes of this component type be cloned?\n */\n cloning?: FEATURE_FLAG\n /**\n * Allow dragging nodes of this component type\n */\n dragging?: FEATURE_FLAG\n /**\n * Allow dropping nodes inside nodes of this component type\n */\n dropping?: FEATURE_FLAG\n /**\n * Allow editing element attributes of this component type\n */\n editing?: FEATURE_FLAG\n /**\n * Allow removing nodes of this component type\n */\n removing?: FEATURE_FLAG\n /**\n * Describe nodes of this component type to be self-closing\n */\n selfClosing?: FEATURE_FLAG\n /**\n * Component renders its `children` prop as text content the editor may\n * edit directly (Attributes \"Text\" field, inline canvas editing).\n */\n textEditable?: FEATURE_FLAG\n /**\n * Component also accepts basic rich text (AGL-54): the inline editor\n * upgrades to a formatting surface and commits sanitized HTML into the\n * `html` prop (with `children` kept as the plain-text fallback).\n */\n richTextEditable?: FEATURE_FLAG\n /**\n * Component reads its children POSITIONALLY (AGL-1237), so the renderer\n * hands it one React child per node child instead of the single `<Branch>`\n * element it normally passes.\n *\n * MUI's Accordion does `const [summary, ...rest] = Children.toArray(children)`,\n * and `toArray` does not traverse into an element — so with the default\n * wrapping the summary swallowed the whole subtree and the Collapse got\n * nothing. Every accordion on every published site expanded to reveal an\n * empty panel while its content rendered unconditionally inside the\n * summary's heading.\n *\n * Opt in only for components with this contract; the wrapper is what keeps\n * the Branch/Stem/Leaf seam swappable for everything else.\n */\n positionalChildren?: FEATURE_FLAG\n /**\n * Component takes its text as a plain string `children`: no child\n * elements and no `<aglyn-text>` wrapper around it. For an element whose\n * DOM allows text and nothing else, such as `<option>`, where React and\n * the browser's parser both drop an element child, and with it the text.\n *\n * Not `selfClosing`, which means a void element (`<img>`) and strips\n * `children` altogether: a Select Option flagged that way rendered every\n * dropdown choice on every published site with no words.\n */\n plainTextChildren?: FEATURE_FLAG\n /**\n * Nothing this component renders responds to the visitor until it is\n * hydrated, beyond what its server HTML does on its own — copy, images,\n * layout, a plain `<a href>` (AGL-3581).\n *\n * On a published page, a subtree made ONLY of components declaring this\n * may keep its server HTML through hydration and render when the visitor\n * nears it, instead of hydrating with the rest of the page. One component\n * without it keeps its whole ancestry hydrating at once, so leave it off\n * anything with a handler, state or an effect a visitor could reach:\n * menus, toggles, forms, accordions, carousels, players.\n */\n lazyHydration?: FEATURE_FLAG\n /**\n * Renders its node children directly inside its root DOM element, adds\n * nothing of its own around or among them, and passes props it does not\n * know through to that element (AGL-3581).\n *\n * That is what lets a static subtree keep its server HTML: the renderer\n * hands such a component `dangerouslySetInnerHTML` in place of its\n * children while the page hydrates, so its root hydrates and its contents\n * are left exactly as the server sent them. A component that wraps,\n * joins or decorates its children (a divider between them, a ripple\n * after them) must not declare it — React refuses an element that has\n * both.\n */\n childrenInRoot?: FEATURE_FLAG\n }\n}\n\nexport type SchemasByCategory = Record<\n ComponentCategory | string,\n (ComponentSchema<any> | PresetSchema<any>)[]\n>\n\nexport interface ScreenSchema {\n nodes: NodeSchemaNested\n createdAt?: ITimestamp\n updatedAt?: ITimestamp\n hostId?: HostUid\n}\n"],"names":["ComponentCategory","NodeType"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GA4BD,SAASA,iBAAiB,QAAQ,wCAAoC;AAictE,OAAO,IAAA,AAAKC,kCAAAA;;;;;;;WAAAA;MAOX;AA6BD,SAASD,iBAAiB,GAAE"}
|