xmlui 0.10.10 → 0.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{metadata/apiInterceptorWorker-Bb5-fQup.mjs → lib/apiInterceptorWorker-DPgtUtdA.mjs} +5870 -3195
- package/dist/lib/index-BuIblMfO.mjs +50034 -0
- package/dist/lib/index.css +1 -1
- package/dist/lib/initMock-CV-9AUzP.mjs +843 -0
- package/dist/lib/language-server-web-worker.mjs +8 -7
- package/dist/lib/language-server.mjs +6 -6
- package/dist/lib/{metadata-utils-gIOZMGG7.mjs → metadata-utils-DzONZF-e.mjs} +159 -114
- package/dist/lib/scss/components-core/theming/_themes.scss +6 -7
- package/dist/lib/{server-common-BfCSNpXG.mjs → server-common-Dsyp3-Ro.mjs} +14497 -10458
- package/dist/lib/syntax-monaco.mjs +14 -11
- package/dist/lib/syntax-textmate.d.ts +2 -2
- package/dist/lib/syntax-textmate.mjs +128 -109
- package/dist/lib/transform-CBz7TQJh.mjs +7375 -0
- package/dist/lib/xmlui-parser.mjs +49 -49
- package/dist/lib/xmlui-serializer-Bf9bdvlV.mjs +667 -0
- package/dist/lib/xmlui.d.ts +3 -2
- package/dist/lib/xmlui.mjs +43 -43
- package/dist/{lib/apiInterceptorWorker-DH8wqOVq.mjs → metadata/apiInterceptorWorker-BmKP8bnq.mjs} +5432 -3502
- package/dist/metadata/collectedComponentMetadata-Cdi6AFD3.mjs +55851 -0
- package/dist/metadata/initMock-B7OlSKKb.mjs +843 -0
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +3 -3
- package/dist/metadata/xmlui-metadata.umd.js +207 -419
- package/dist/scripts/package.json +3 -1
- package/dist/scripts/src/components/APICall/APICall.js +4 -4
- package/dist/scripts/src/components/Accordion/Accordion.js +1 -1
- package/dist/scripts/src/components/Animation/AnimationNative.js +259 -0
- package/dist/scripts/src/components/App/App.js +10 -0
- package/dist/scripts/src/components/App/AppNative.js +23 -2
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +1 -1
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +5 -4
- package/dist/scripts/src/components/Button/Button.js +1 -1
- package/dist/scripts/src/components/Charts/AreaChart/AreaChart.js +92 -0
- package/dist/scripts/src/components/Charts/AreaChart/AreaChartNative.js +127 -0
- package/dist/scripts/src/components/Charts/BarChart/BarChartNative.js +85 -81
- package/dist/scripts/src/components/Charts/RadarChart/RadarChart.js +92 -0
- package/dist/scripts/src/components/Charts/RadarChart/RadarChartNative.js +125 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.js +2 -1
- package/dist/scripts/src/components/ComponentProvider.js +4 -0
- package/dist/scripts/src/components/DataSource/DataSource.js +124 -0
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/scripts/src/components/Footer/Footer.js +1 -1
- package/dist/scripts/src/components/FormItem/FormItem.js +1 -1
- package/dist/scripts/src/components/Heading/Heading.js +83 -28
- package/dist/scripts/src/components/Heading/HeadingNative.js +10 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +1 -1
- package/dist/scripts/src/components/Image/ImageNative.js +13 -0
- package/dist/scripts/src/components/NavLink/NavLink.js +1 -1
- package/dist/scripts/src/components/Option/Option.js +2 -2
- package/dist/scripts/src/components/Option/OptionNative.js +12 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +7 -3
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +20 -5
- package/dist/scripts/src/components/RadioGroup/RadioItemNative.js +2 -1
- package/dist/scripts/src/components/Select/Select.js +1 -1
- package/dist/scripts/src/components/Select/SelectNative.js +1 -1
- package/dist/scripts/src/components/Switch/Switch.js +2 -1
- package/dist/scripts/src/components/Table/Table.js +1 -1
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +1 -1
- package/dist/scripts/src/components/Text/Text.js +32 -14
- package/dist/scripts/src/components/Text/TextNative.js +17 -5
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +1 -1
- package/dist/scripts/src/components/Toggle/Toggle.js +2 -2
- package/dist/scripts/src/components/abstractions.js +2 -1
- package/dist/scripts/src/components/collectedComponentMetadata.js +316 -0
- package/dist/scripts/src/components-core/RestApiProxy.js +3 -1
- package/dist/scripts/src/components-core/StandaloneApp.js +823 -0
- package/dist/scripts/src/components-core/markup-check.js +279 -0
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +36 -16
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +4 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +4 -1
- package/dist/scripts/src/components-core/theming/themes/root.js +30 -17
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +14 -7
- package/dist/scripts/src/components-core/xmlui-parser.js +60 -43
- package/dist/scripts/src/index.js +120 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +15 -4
- package/dist/standalone/xmlui-standalone.es.d.ts +4 -2
- package/dist/standalone/xmlui-standalone.umd.js +319 -823
- package/package.json +3 -1
- package/src/syntax/textMate/xmlui.tmLanguage.json +2 -2
- package/dist/lib/index-C71PAj7E.mjs +0 -38677
- package/dist/lib/initMock-Bvbl2Pa3.mjs +0 -571
- package/dist/lib/transform-SMWeyMoq.mjs +0 -5391
- package/dist/lib/xmlui-serializer-a0O0jFY-.mjs +0 -497
- package/dist/metadata/collectedComponentMetadata-Dn91__HO.mjs +0 -43087
- package/dist/metadata/initMock-ghNfStAu.mjs +0 -571
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkXmlUiMarkup = checkXmlUiMarkup;
|
|
4
|
+
exports.visitComponent = visitComponent;
|
|
5
|
+
const ParameterParser_1 = require("./script-runner/ParameterParser");
|
|
6
|
+
const Parser_1 = require("../parsers/scripting/Parser");
|
|
7
|
+
const descriptorHelper_1 = require("./descriptorHelper");
|
|
8
|
+
const abstractions_1 = require("../components/abstractions");
|
|
9
|
+
/**
|
|
10
|
+
* This function checks the XMLUI markup for potential issues. It retrieves
|
|
11
|
+
* a list of errors and warnings.
|
|
12
|
+
* @param rootDef Root component definition
|
|
13
|
+
* @param components Components referenced in the XMLUI markup
|
|
14
|
+
* @param devMode Indicates if the check is performed in development mode
|
|
15
|
+
* @returns List of errors and warnings
|
|
16
|
+
*/
|
|
17
|
+
function checkXmlUiMarkup(rootDef, components, metadataHandler, devMode) {
|
|
18
|
+
const errorsCollected = [];
|
|
19
|
+
// --- Initialize the check
|
|
20
|
+
const continuation = {};
|
|
21
|
+
const componentIdsCollected = new Set();
|
|
22
|
+
const compoundIdsCollected = new Set();
|
|
23
|
+
// --- Visit the root component
|
|
24
|
+
if (rootDef) {
|
|
25
|
+
visitComponent(rootDef, null, componentDefVisitor, continuation, metadataHandler);
|
|
26
|
+
}
|
|
27
|
+
// --- Visit the compound components
|
|
28
|
+
if (!continuation.abort) {
|
|
29
|
+
for (const component of components) {
|
|
30
|
+
// --- Rule: Compound component name must be a valid JavaScript identifier
|
|
31
|
+
if (!isValidIdentifier(component.name)) {
|
|
32
|
+
reportError("M007", "Component", component.name);
|
|
33
|
+
}
|
|
34
|
+
// --- Rule: Compound component name cannot be 'Component'
|
|
35
|
+
if (component.name === "Component") {
|
|
36
|
+
reportError("M008", "Component", component.name);
|
|
37
|
+
}
|
|
38
|
+
// --- Rule: Compound component must not have the name of a registered component
|
|
39
|
+
if (metadataHandler.componentRegistered(component.name)) {
|
|
40
|
+
reportError("M009", "Component", component.name);
|
|
41
|
+
}
|
|
42
|
+
// --- Rule: Compound component name must be unique
|
|
43
|
+
if (compoundIdsCollected.has(component.name)) {
|
|
44
|
+
reportError("M010", "Component", component.name);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
compoundIdsCollected.add(component.name);
|
|
48
|
+
}
|
|
49
|
+
// --- Reset component ID scope
|
|
50
|
+
componentIdsCollected.clear();
|
|
51
|
+
// --- Visit the compount component's definition
|
|
52
|
+
visitComponent(component.component, null, componentDefVisitor, continuation, metadataHandler);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// --- Done.
|
|
56
|
+
return errorsCollected;
|
|
57
|
+
// --- This visitor checks the rules for a particular component
|
|
58
|
+
function componentDefVisitor(def, parent, before, continuation) {
|
|
59
|
+
var _a, _b, _c, _d, _e;
|
|
60
|
+
// --- This is the visitor function to check a ComponentDef markup
|
|
61
|
+
if (!before) {
|
|
62
|
+
// --- Do not visit the component definition after its children have been visited
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// --- Rule: Component name must be registered
|
|
66
|
+
if (!metadataHandler.componentRegistered(def.type)) {
|
|
67
|
+
reportError("M001", (_a = parent === null || parent === void 0 ? void 0 : parent.type) !== null && _a !== void 0 ? _a : "Root", def.type);
|
|
68
|
+
// continuation.cancel = true;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// --- Rule: an ID must be a valid JavaScript identifier
|
|
72
|
+
if (def.uid) {
|
|
73
|
+
if (!isValidIdentifier(def.uid)) {
|
|
74
|
+
reportError("M002", def.type, def.type, def.uid);
|
|
75
|
+
}
|
|
76
|
+
else if (componentIdsCollected.has(def.uid)) {
|
|
77
|
+
reportError("M003", def.type, def.uid);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
componentIdsCollected.add(def.uid);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// --- Check all props of the component
|
|
84
|
+
const propDescriptors = (_b = metadataHandler.getComponentProps(def.type)) !== null && _b !== void 0 ? _b : {};
|
|
85
|
+
const currentProps = (_c = def.props) !== null && _c !== void 0 ? _c : {};
|
|
86
|
+
for (const propName of Object.keys(currentProps)) {
|
|
87
|
+
const propDescriptor = propDescriptors[propName];
|
|
88
|
+
// --- Rule: The property must be defined in the component descriptor or be a layout option
|
|
89
|
+
// --- or the component must accept arbitrary properties
|
|
90
|
+
if (propDescriptor) {
|
|
91
|
+
// --- The property has a descriptor, so it is allowed.
|
|
92
|
+
// --- Rule: The property value must be parseable
|
|
93
|
+
const propValue = currentProps[propName];
|
|
94
|
+
if (typeof propValue === "string") {
|
|
95
|
+
try {
|
|
96
|
+
(0, ParameterParser_1.parseParameterString)(propValue);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
reportError("M006", def.type, propName, error.message);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// --- The property has no descriptor.
|
|
105
|
+
const propParts = propName.split("-");
|
|
106
|
+
// --- Check for a layout property
|
|
107
|
+
const validProp =
|
|
108
|
+
// --- Layout property
|
|
109
|
+
(propParts.length === 1 && descriptorHelper_1.layoutOptionKeys.includes(propName)) ||
|
|
110
|
+
// --- Layout property with viewport size
|
|
111
|
+
(propParts.length === 2 &&
|
|
112
|
+
descriptorHelper_1.layoutOptionKeys.includes(propParts[0]) &&
|
|
113
|
+
abstractions_1.viewportSizeNames.includes(propParts[1])) ||
|
|
114
|
+
// --- Arbitrary property is allowed
|
|
115
|
+
metadataHandler.acceptArbitraryProps(def.type);
|
|
116
|
+
if (!validProp) {
|
|
117
|
+
// --- The component does not accept arbitrary properties and
|
|
118
|
+
// --- the property is not a layout option
|
|
119
|
+
reportError("M005", def.type, def.type, propName);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// --- Check all events of the component
|
|
124
|
+
const eventDescriptors = (_d = metadataHandler.getComponentEvents(def.type)) !== null && _d !== void 0 ? _d : {};
|
|
125
|
+
const currentEvents = (_e = def.events) !== null && _e !== void 0 ? _e : {};
|
|
126
|
+
for (const eventName of Object.keys(currentEvents)) {
|
|
127
|
+
const eventDescriptor = eventDescriptors[eventName];
|
|
128
|
+
// --- Rule: The event must be defined in the component descriptor
|
|
129
|
+
if (eventDescriptor) {
|
|
130
|
+
// --- The event has a descriptor, so it is allowed.
|
|
131
|
+
const eventValue = currentEvents[eventName];
|
|
132
|
+
if (typeof eventValue === "string") {
|
|
133
|
+
// --- Rule: The event value must be parseable
|
|
134
|
+
const parser = new Parser_1.Parser(eventValue);
|
|
135
|
+
try {
|
|
136
|
+
parser.parseStatements();
|
|
137
|
+
if (parser.errors.length > 0) {
|
|
138
|
+
reportError("M012", def.type, eventName, parser.errors[0].text);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
reportError("M012", def.type, eventName, error.message);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
reportError("M011", def.type, def.type, eventName);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// --- Check the component validator
|
|
151
|
+
const componentValidator = metadataHandler.getComponentValidator(def.type);
|
|
152
|
+
if (componentValidator) {
|
|
153
|
+
const validationErrors = componentValidator(def, devMode);
|
|
154
|
+
if (validationErrors) {
|
|
155
|
+
if (Array.isArray(validationErrors)) {
|
|
156
|
+
for (const error of validationErrors) {
|
|
157
|
+
reportError("M013", def.type, error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
reportError("M013", def.type, validationErrors);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Checks if a string is a valid JavaScript identifier.
|
|
168
|
+
* @param identifier The string to check.
|
|
169
|
+
* @returns True if the string is a valid identifier, false otherwise.
|
|
170
|
+
*/
|
|
171
|
+
function isValidIdentifier(identifier) {
|
|
172
|
+
const identifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
173
|
+
return identifierRegex.test(identifier);
|
|
174
|
+
}
|
|
175
|
+
function reportError(code, name, ...args) {
|
|
176
|
+
_reportError(code, name, false, ...args);
|
|
177
|
+
}
|
|
178
|
+
function reportWarning(code, name, ...args) {
|
|
179
|
+
_reportError(code, name, true, ...args);
|
|
180
|
+
}
|
|
181
|
+
function _reportError(code, name, isWarning, ...args) {
|
|
182
|
+
var _a;
|
|
183
|
+
let errorText = (_a = errorMessages[code]) !== null && _a !== void 0 ? _a : "Unkonwn error";
|
|
184
|
+
if (args) {
|
|
185
|
+
args.forEach((a, idx) => (errorText = replace(errorText, `{${idx}}`, args[idx].toString())));
|
|
186
|
+
}
|
|
187
|
+
errorsCollected.push({ name, code, message: errorText, isWarning, args });
|
|
188
|
+
function replace(input, placeholder, replacement) {
|
|
189
|
+
do {
|
|
190
|
+
input = input.replace(placeholder, replacement);
|
|
191
|
+
} while (input.includes(placeholder));
|
|
192
|
+
return input;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// --- This function visits a component, its nested components and children
|
|
197
|
+
function visitComponent(def, parent, visitor, continuation = {}, metadataHandler) {
|
|
198
|
+
var _a, _b, _c, _d;
|
|
199
|
+
// --- Visit the component (before)
|
|
200
|
+
visitor(def, parent, true, continuation);
|
|
201
|
+
if (continuation.abort || continuation.cancel) {
|
|
202
|
+
// --- Stop the visit
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
// --- Visit the properties with "ComponentDef" value
|
|
206
|
+
const propDescriptors = (_a = metadataHandler.getComponentProps(def.type)) !== null && _a !== void 0 ? _a : {};
|
|
207
|
+
const currentProps = (_b = def.props) !== null && _b !== void 0 ? _b : {};
|
|
208
|
+
for (const propName of Object.keys(currentProps)) {
|
|
209
|
+
const propDescriptor = propDescriptors[propName];
|
|
210
|
+
if (!propDescriptor) {
|
|
211
|
+
// --- No descriptor for the property, skip it
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const propValue = currentProps[propName];
|
|
215
|
+
if (propDescriptor.type === "ComponentDef" && propValue.type) {
|
|
216
|
+
// --- This property holds a nested component, visit it
|
|
217
|
+
visitComponent(propValue, def, visitor, continuation, metadataHandler);
|
|
218
|
+
if (continuation.abort || continuation.cancel) {
|
|
219
|
+
// --- Stop the visit
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// --- Visit events with nested components
|
|
225
|
+
const eventDescriptors = (_c = metadataHandler.getComponentEvents(def.type)) !== null && _c !== void 0 ? _c : {};
|
|
226
|
+
const currentEvents = (_d = def.events) !== null && _d !== void 0 ? _d : {};
|
|
227
|
+
for (const eventName of Object.keys(currentEvents)) {
|
|
228
|
+
const eventDescriptor = eventDescriptors[eventName];
|
|
229
|
+
if (!eventDescriptor) {
|
|
230
|
+
// --- No descriptor for the events, skip it
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const eventValue = currentEvents[eventName];
|
|
234
|
+
if (typeof eventValue === "object" && eventValue.type) {
|
|
235
|
+
// --- This event holds a nested component, visit it
|
|
236
|
+
visitComponent(eventValue, def, visitor, continuation, metadataHandler);
|
|
237
|
+
if (continuation.abort) {
|
|
238
|
+
// --- Stop visiting this component
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (continuation.cancel) {
|
|
242
|
+
// --- Skip the remaining items
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// --- Visit the component children
|
|
248
|
+
if (def.children) {
|
|
249
|
+
for (const child of def.children) {
|
|
250
|
+
visitComponent(child, def, visitor, continuation, metadataHandler);
|
|
251
|
+
if (continuation.abort) {
|
|
252
|
+
// --- Stop visiting this component
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (continuation.cancel) {
|
|
256
|
+
// --- Skip the remaining items
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// --- Visit the component (after)
|
|
262
|
+
visitor(def, undefined, false, continuation);
|
|
263
|
+
}
|
|
264
|
+
// --- The error messages of error codes
|
|
265
|
+
const errorMessages = {
|
|
266
|
+
M001: "The component '{0}' is not registered",
|
|
267
|
+
M002: "The '{0}' element has an invalid id: '{1}'",
|
|
268
|
+
M003: "Invalid component identifier: '{0}'",
|
|
269
|
+
M004: "Duplicated component identifier: '{0}'",
|
|
270
|
+
M005: "The '{0}' element has an invalid property: '{1}'",
|
|
271
|
+
M006: "Parsing property value of '{0}' failed: {1}",
|
|
272
|
+
M007: "The name of a reusable component is invalid: '{0}'",
|
|
273
|
+
M008: "The name of a reusable component must not be '{0}', as it is a reserved name",
|
|
274
|
+
M009: "A reusable component cannot have the name of a registered component: '{0}'",
|
|
275
|
+
M010: "Duplicated reusable component name: '{0}'",
|
|
276
|
+
M011: "The '{0}' element has an invalid event: '{1}'",
|
|
277
|
+
M012: "Parsing event value of '{0}' failed: {1}",
|
|
278
|
+
M013: "Component validation failed: '{0}'",
|
|
279
|
+
};
|
|
@@ -70,6 +70,7 @@ const InvalidComponent_1 = __importDefault(require("./InvalidComponent"));
|
|
|
70
70
|
const layout_resolver_1 = require("../theming/layout-resolver");
|
|
71
71
|
const TooltipNative_1 = require("../../components/Tooltip/TooltipNative");
|
|
72
72
|
const StyleContext_1 = require("../theming/StyleContext");
|
|
73
|
+
const AnimationNative_1 = require("../../components/Animation/AnimationNative");
|
|
73
74
|
/**
|
|
74
75
|
* This component's primary responsibility is to transform a particular component definition
|
|
75
76
|
* into its React representation using the current rendering context.
|
|
@@ -147,12 +148,17 @@ const ComponentAdapter = (0, react_1.forwardRef)(function ComponentAdapter(_a, r
|
|
|
147
148
|
// --- Set up the mouse event handlers for the component
|
|
148
149
|
const mouseEventHandlers = (0, event_handlers_1.useMouseEventHandlers)(memoedLookupEventHandler, (descriptor === null || descriptor === void 0 ? void 0 : descriptor.nonVisual) || isApiBound);
|
|
149
150
|
// --- Use the current theme to obtain resources and collect theme variables
|
|
150
|
-
const { getResourceUrl
|
|
151
|
+
const { getResourceUrl } = (0, ThemeContext_1.useTheme)();
|
|
151
152
|
// --- Obtain a function that can extract a resource URL from a logical URL
|
|
152
153
|
const extractResourceUrl = (0, react_1.useCallback)((url) => {
|
|
153
154
|
const extractedUrl = valueExtractor(url);
|
|
155
|
+
if (typeof extractedUrl !== "string" || extractedUrl.trim() === "") {
|
|
156
|
+
console.warn(`Component '${safeNode.type}': ` +
|
|
157
|
+
`the extracted resource URL is not a valid string: value ${extractedUrl}, type ${typeof extractedUrl}`);
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
154
160
|
return getResourceUrl(extractedUrl);
|
|
155
|
-
}, [getResourceUrl, valueExtractor]);
|
|
161
|
+
}, [getResourceUrl, valueExtractor, safeNode.type]);
|
|
156
162
|
// --- Collect and compile the layout property values
|
|
157
163
|
const { cssProps } = (0, react_1.useMemo)(() => {
|
|
158
164
|
const resolvedLayoutProps = {};
|
|
@@ -170,6 +176,13 @@ const ComponentAdapter = (0, react_1.forwardRef)(function ComponentAdapter(_a, r
|
|
|
170
176
|
// });
|
|
171
177
|
}, [appContext.mediaSize, layoutContextRef, safeNode.props, valueExtractor]);
|
|
172
178
|
// const className = useComponentStyle(cssProps);
|
|
179
|
+
// --- Check if the component has a tooltip property
|
|
180
|
+
const tooltipText = (0, react_1.useMemo)(() => { var _a; return valueExtractor((_a = safeNode.props) === null || _a === void 0 ? void 0 : _a.tooltip, true); }, [safeNode.props, valueExtractor]);
|
|
181
|
+
// --- Check if the component has a tooltip property
|
|
182
|
+
const tooltipMarkdown = (0, react_1.useMemo)(() => { var _a; return valueExtractor((_a = safeNode.props) === null || _a === void 0 ? void 0 : _a.tooltipMarkdown, true); }, [safeNode.props, valueExtractor]);
|
|
183
|
+
const tooltipOptions = (0, react_1.useMemo)(() => { var _a; return valueExtractor((_a = safeNode.props) === null || _a === void 0 ? void 0 : _a.tooltipOptions, true); }, [safeNode.props, valueExtractor]);
|
|
184
|
+
const animation = (0, react_1.useMemo)(() => { var _a; return valueExtractor((_a = safeNode.props) === null || _a === void 0 ? void 0 : _a.animation, true); }, [safeNode.props, valueExtractor]);
|
|
185
|
+
const animationOptions = (0, react_1.useMemo)(() => { var _a; return valueExtractor((_a = safeNode.props) === null || _a === void 0 ? void 0 : _a.animationOptions, true); }, [safeNode.props, valueExtractor]);
|
|
173
186
|
// --- As compileLayout generates new cssProps and nonCssProps objects every time, we need to
|
|
174
187
|
// --- memoize them using shallow comparison to avoid unnecessary re-renders.
|
|
175
188
|
const stableLayoutCss = (0, hooks_1.useShallowCompareMemoize)(cssProps);
|
|
@@ -267,20 +280,27 @@ const ComponentAdapter = (0, react_1.forwardRef)(function ComponentAdapter(_a, r
|
|
|
267
280
|
? (0, react_1.cloneElement)(renderedNode, null, children)
|
|
268
281
|
: renderedNode;
|
|
269
282
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
const applyWrappers = (node) => {
|
|
284
|
+
// --- Handle animations and tooltips together
|
|
285
|
+
if (animation && (tooltipMarkdown || tooltipText)) {
|
|
286
|
+
const parsedOptions = (0, TooltipNative_1.parseTooltipOptions)(tooltipOptions);
|
|
287
|
+
const parsedAnimationOptions = (0, AnimationNative_1.parseAnimationOptions)(animationOptions);
|
|
288
|
+
return ((0, jsx_runtime_1.jsx)(TooltipNative_1.Tooltip, Object.assign({ text: tooltipText, markdown: tooltipMarkdown }, parsedOptions, { children: (0, jsx_runtime_1.jsx)(AnimationNative_1.Animation, Object.assign({ animation: (0, AnimationNative_1.parseAnimation)(animation) }, parsedAnimationOptions, { children: node })) })));
|
|
289
|
+
}
|
|
290
|
+
// --- Handle animation
|
|
291
|
+
if (animation) {
|
|
292
|
+
const parsedAnimationOptions = (0, AnimationNative_1.parseAnimationOptions)(animationOptions);
|
|
293
|
+
return ((0, jsx_runtime_1.jsx)(AnimationNative_1.Animation, Object.assign({ animation: (0, AnimationNative_1.parseAnimation)(animation) }, parsedAnimationOptions, { children: node })));
|
|
294
|
+
}
|
|
295
|
+
// --- Handle tooltip
|
|
296
|
+
if (tooltipMarkdown || tooltipText) {
|
|
297
|
+
const parsedOptions = (0, TooltipNative_1.parseTooltipOptions)(tooltipOptions);
|
|
298
|
+
return ((0, jsx_runtime_1.jsx)(TooltipNative_1.Tooltip, Object.assign({ text: tooltipText, markdown: tooltipMarkdown }, parsedOptions, { children: node })));
|
|
299
|
+
}
|
|
300
|
+
// --- No wrappers needed
|
|
301
|
+
return node;
|
|
302
|
+
};
|
|
303
|
+
return applyWrappers(nodeToRender);
|
|
284
304
|
});
|
|
285
305
|
/**
|
|
286
306
|
* This function renders the content of a slot. If the slot is named, it looks for a template
|
|
@@ -601,7 +601,10 @@ function evalTemplateLiteralAsync(evaluator, thisStack, expr, evalContext, threa
|
|
|
601
601
|
const evaledValue = yield completeExprValue(expr.segments[i], thread);
|
|
602
602
|
segmentValues[i] = evaledValue;
|
|
603
603
|
}
|
|
604
|
-
|
|
604
|
+
const value = (0, eval_tree_common_1.evalTemplateLiteralCore)(segmentValues);
|
|
605
|
+
(0, eval_tree_common_1.setExprValue)(expr, { value }, thread);
|
|
606
|
+
thisStack.push(value);
|
|
607
|
+
return value;
|
|
605
608
|
});
|
|
606
609
|
}
|
|
607
610
|
function completeExprValue(expr, thread) {
|
|
@@ -134,7 +134,10 @@ function evalTemplateLiteral(evaluator, thisStack, expr, evalContext, thread) {
|
|
|
134
134
|
thisStack.pop();
|
|
135
135
|
return evaledValue;
|
|
136
136
|
});
|
|
137
|
-
|
|
137
|
+
const value = (0, eval_tree_common_1.evalTemplateLiteralCore)(segmentValues);
|
|
138
|
+
(0, eval_tree_common_1.setExprValue)(expr, { value }, thread);
|
|
139
|
+
thisStack.push(value);
|
|
140
|
+
return value;
|
|
138
141
|
}
|
|
139
142
|
function evalMemberAccess(evaluator, thisStack, expr, evalContext, thread) {
|
|
140
143
|
evaluator(thisStack, expr.obj, evalContext, thread);
|
|
@@ -127,13 +127,6 @@ exports.RootThemeDefinition = {
|
|
|
127
127
|
"color-valid": "$color-success-600",
|
|
128
128
|
"color-warning": "$color-warn-700",
|
|
129
129
|
"color-error": "$color-danger-500",
|
|
130
|
-
// --- Default line height values (relative to the base unit, "space-base")
|
|
131
|
-
"lineHeight-none": "1",
|
|
132
|
-
"lineHeight-tight": "1.25",
|
|
133
|
-
"lineHeight-snug": "1.375",
|
|
134
|
-
"lineHeight-normal": "1.5",
|
|
135
|
-
"lineHeight-relaxed": "1.625",
|
|
136
|
-
"lineHeight-loose": "2",
|
|
137
130
|
// --- The sans-serif font set
|
|
138
131
|
"fontFamily-sans-serif": "'Inter', -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif",
|
|
139
132
|
// --- The monospace font set
|
|
@@ -154,18 +147,38 @@ exports.RootThemeDefinition = {
|
|
|
154
147
|
// --- The app's default font family
|
|
155
148
|
"fontFamily": "$fontFamily-sans-serif",
|
|
156
149
|
// --- Various font sizes (relative to the current context)
|
|
157
|
-
"fontSize-gigantic": "3rem",
|
|
158
|
-
"fontSize-larger": "2.15rem",
|
|
159
|
-
"fontSize-large": "1.5rem",
|
|
160
|
-
"fontSize-medium": "1.25rem",
|
|
161
|
-
"fontSize-semimedium": "1.125rem",
|
|
162
|
-
"fontSize-normal": "1rem",
|
|
163
|
-
"fontSize-small": "0.875rem",
|
|
164
|
-
"fontSize-code": "0.85rem",
|
|
165
|
-
"fontSize-smaller": "0.75rem",
|
|
166
150
|
"fontSize-tiny": "0.625rem",
|
|
151
|
+
"fontSize-xs": "0.75rem",
|
|
152
|
+
"fontSize-code": "0.85rem",
|
|
153
|
+
"fontSize-sm": "0.875rem",
|
|
154
|
+
"fontSize-base": "1rem",
|
|
155
|
+
"fontSize-lg": "1.125rem",
|
|
156
|
+
"fontSize-xl": "1.25rem",
|
|
157
|
+
"fontSize-2xl": "1.5rem",
|
|
158
|
+
"fontSize-3xl": "1.875rem",
|
|
159
|
+
"fontSize-4xl": "2.25rem",
|
|
160
|
+
"fontSize-5xl": "3rem",
|
|
161
|
+
"fontSize-6xl": "3.75rem",
|
|
162
|
+
"fontSize-7xl": "4.5rem",
|
|
163
|
+
"fontSize-8xl": "6rem",
|
|
164
|
+
"fontSize-9xl": "8rem",
|
|
165
|
+
// --- Various line height values
|
|
166
|
+
"lineHeight-tiny": "calc(0.85 / 0.625)", // 1.36
|
|
167
|
+
"lineHeight-xs": "calc(1 / 0.75)", // 1.33
|
|
168
|
+
"lineHeight-sm": "calc(1.25 / 0.875)", // 1.43
|
|
169
|
+
"lineHeight-base": "calc(1.5 / 1)", // 1.5
|
|
170
|
+
"lineHeight-lg": "calc(1.75 / 1.125)", // 1.56
|
|
171
|
+
"lineHeight-xl": "calc(1.75 / 1.25)", // 1.4
|
|
172
|
+
"lineHeight-2xl": "calc(2 / 1.5)", // 1.33
|
|
173
|
+
"lineHeight-3xl": "calc(2.25 / 1.875)", // 1.2
|
|
174
|
+
"lineHeight-4xl": "calc(2.5 / 2.25)", // 1.11
|
|
175
|
+
"lineHeight-5xl": "1",
|
|
176
|
+
"lineHeight-6xl": "1",
|
|
177
|
+
"lineHeight-7xl": "1",
|
|
178
|
+
"lineHeight-8xl": "1",
|
|
179
|
+
"lineHeight-9xl": "1",
|
|
167
180
|
// --- The default font size
|
|
168
|
-
"fontSize": "$fontSize-
|
|
181
|
+
"fontSize": "$fontSize-base",
|
|
169
182
|
// --- Predefined gap sizes
|
|
170
183
|
"gap-none": "$space-0",
|
|
171
184
|
"gap-tight": "$space-2",
|
|
@@ -88,14 +88,21 @@ function generateBaseFontSizes(theme) {
|
|
|
88
88
|
return {};
|
|
89
89
|
}
|
|
90
90
|
const ret = {};
|
|
91
|
-
ret[`fontSize-large`] = `${1.5 * baseNum}${baseUnit}`;
|
|
92
|
-
ret[`fontSize-medium`] = `${1.25 * baseNum}${baseUnit}`;
|
|
93
|
-
ret[`fontSize-semimedium`] = `${1.125 * baseNum}${baseUnit}`;
|
|
94
|
-
ret[`fontSize-normal`] = base;
|
|
95
|
-
ret[`fontSize-small`] = `${0.875 * baseNum}${baseUnit}`;
|
|
96
|
-
ret[`fontSize-code`] = `${0.85 * baseNum}${baseUnit}`;
|
|
97
|
-
ret[`fontSize-smaller`] = `${0.75 * baseNum}${baseUnit}`;
|
|
98
91
|
ret[`fontSize-tiny`] = `${0.625 * baseNum}${baseUnit}`;
|
|
92
|
+
ret[`fontSize-xs`] = `${0.75 * baseNum}${baseUnit}`;
|
|
93
|
+
ret[`fontSize-code`] = `${0.85 * baseNum}${baseUnit}`;
|
|
94
|
+
ret[`fontSize-sm`] = `${0.875 * baseNum}${baseUnit}`;
|
|
95
|
+
ret[`fontSize-base`] = base;
|
|
96
|
+
ret[`fontSize-lg`] = `${1.125 * baseNum}${baseUnit}`;
|
|
97
|
+
ret[`fontSize-xl`] = `${1.25 * baseNum}${baseUnit}`;
|
|
98
|
+
ret[`fontSize-2xl`] = `${1.5 * baseNum}${baseUnit}`;
|
|
99
|
+
ret[`fontSize-3xl`] = `${1.875 * baseNum}${baseUnit}`;
|
|
100
|
+
ret[`fontSize-4xl`] = `${2.25 * baseNum}${baseUnit}`;
|
|
101
|
+
ret[`fontSize-5xl`] = `${3 * baseNum}${baseUnit}`;
|
|
102
|
+
ret[`fontSize-6xl`] = `${3.75 * baseNum}${baseUnit}`;
|
|
103
|
+
ret[`fontSize-7xl`] = `${4.5 * baseNum}${baseUnit}`;
|
|
104
|
+
ret[`fontSize-8xl`] = `${6 * baseNum}${baseUnit}`;
|
|
105
|
+
ret[`fontSize-9xl`] = `${8 * baseNum}${baseUnit}`;
|
|
99
106
|
return ret;
|
|
100
107
|
}
|
|
101
108
|
function generateTextFontSizes(theme) {
|