xmlui 0.9.23 → 0.9.30
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/lib/apiInterceptorWorker-D8UVXhKa.mjs +818 -0
- package/dist/{index-B8C8yAZL.mjs → lib/index-BF7GNHsi.mjs} +12083 -3320
- package/dist/{style.css → lib/index.css} +7587 -5788
- package/dist/lib/language-server-web-worker.d.ts +655 -0
- package/dist/{language-server-web-worker.mjs → lib/language-server-web-worker.mjs} +1 -1
- package/dist/lib/language-server.d.ts +657 -0
- package/dist/{language-server.mjs → lib/language-server.mjs} +1 -1
- package/dist/lib/lint-CYAUfk0_.mjs +168 -0
- package/dist/lib/metadata-utils-CCIMqe69.mjs +466 -0
- package/dist/{server-common-DW5h7Q34.mjs → lib/server-common-B0FCNpIT.mjs} +4427 -1758
- package/dist/{lint-EcgF-9Wr.mjs → lib/transform-DC0Gy6qw.mjs} +1246 -540
- package/dist/{xmlui-parser.d.ts → lib/xmlui-parser.d.ts} +682 -4
- package/dist/{xmlui-parser.mjs → lib/xmlui-parser.mjs} +49 -48
- package/dist/{xmlui.d.ts → lib/xmlui.d.ts} +641 -1
- package/dist/{xmlui.mjs → lib/xmlui.mjs} +10 -10
- package/dist/{index.css → metadata/style.css} +6657 -6948
- package/dist/{xmlui-metadata.mjs → metadata/xmlui-metadata.mjs} +2703 -2553
- package/dist/{xmlui-metadata.umd.js → metadata/xmlui-metadata.umd.js} +2705 -2555
- package/dist/scripts/package.json +245 -0
- package/dist/scripts/src/components/App/App.js +0 -2
- package/dist/scripts/src/components/App/AppNative.js +22 -12
- package/dist/scripts/src/components/AppHeader/AppHeader.js +1 -1
- package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +4 -5
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +5 -2
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +13 -10
- package/dist/scripts/src/components/Bookmark/BookmarkNative.js +7 -3
- package/dist/scripts/src/components/CodeBlock/CodeBlock.js +35 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +101 -0
- package/dist/scripts/src/components/CodeBlock/highlight-code.js +203 -0
- package/dist/scripts/src/components/ComponentProvider.js +5 -0
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +1 -0
- package/dist/scripts/src/components/Footer/FooterNative.js +2 -1
- package/dist/scripts/src/components/Form/FormNative.js +34 -18
- package/dist/scripts/src/components/FormItem/FormItem.js +5 -2
- package/dist/scripts/src/components/FormItem/FormItemNative.js +3 -3
- package/dist/scripts/src/components/Heading/Heading.js +16 -0
- package/dist/scripts/src/components/Heading/HeadingNative.js +2 -2
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +11 -7
- package/dist/scripts/src/components/Icon/DarkToLightIcon.js +10 -0
- package/dist/scripts/src/components/Icon/LightToDark.js +10 -0
- package/dist/scripts/src/components/IconProvider.js +4 -0
- package/dist/scripts/src/components/Image/ImageNative.js +1 -1
- package/dist/scripts/src/components/Link/Link.js +5 -5
- package/dist/scripts/src/components/List/ListNative.js +1 -1
- package/dist/scripts/src/components/Markdown/Markdown.js +56 -16
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +73 -80
- package/dist/scripts/src/components/Markdown/highlight-code.js +160 -0
- package/dist/scripts/src/components/Markdown/parse-binding-expr.js +60 -0
- package/dist/scripts/src/components/Markdown/utils.js +282 -0
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +116 -0
- package/dist/scripts/src/components/ModalDialog/Dialog.js +20 -0
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +2 -2
- package/dist/scripts/src/components/NestedApp/NestedApp.js +61 -0
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +125 -0
- package/dist/scripts/src/components/NestedApp/Tooltip.js +46 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.js +4 -1
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +2 -2
- package/dist/scripts/src/components/Option/Option.js +3 -2
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +2 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +17 -1
- package/dist/scripts/src/components/Select/Select.js +5 -3
- package/dist/scripts/src/components/Select/SelectNative.js +53 -42
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +1 -1
- package/dist/scripts/src/components/Spinner/Spinner.js +0 -1
- package/dist/scripts/src/components/Switch/Switch.js +5 -3
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +1 -0
- package/dist/scripts/src/components/Text/Text.js +10 -4
- package/dist/scripts/src/components/Text/TextNative.js +5 -1
- package/dist/scripts/src/components/TextBox/TextBox.js +6 -1
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +2 -2
- package/dist/scripts/src/components/Theme/ThemeNative.js +7 -3
- package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.js +1 -3
- package/dist/scripts/src/components-core/RestApiProxy.js +10 -7
- package/dist/scripts/src/components-core/TableOfContentsContext.js +1 -1
- package/dist/scripts/src/components-core/appContext/date-functions.js +23 -0
- package/dist/scripts/src/components-core/appContext/math-function.js +27 -0
- package/dist/scripts/src/components-core/appContext/misc-utils.js +13 -0
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +199 -0
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +94 -0
- package/dist/scripts/src/components-core/interception/Backend.js +128 -0
- package/dist/scripts/src/components-core/interception/Errors.js +129 -0
- package/dist/scripts/src/components-core/interception/InMemoryDb.js +41 -0
- package/dist/scripts/src/components-core/interception/IndexedDb.js +207 -0
- package/dist/scripts/src/components-core/interception/ReadonlyCollection.js +145 -0
- package/dist/scripts/src/components-core/interception/abstractions.js +2 -0
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +46 -0
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +9 -0
- package/dist/scripts/src/components-core/rendering/AppContent.js +336 -0
- package/dist/scripts/src/components-core/rendering/AppRoot.js +84 -0
- package/dist/scripts/src/components-core/rendering/AppWrapper.js +49 -0
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +17 -7
- package/dist/scripts/src/components-core/rendering/Container.js +2 -1
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +2 -7
- package/dist/scripts/src/components-core/theming/themes/root.js +1 -0
- package/dist/scripts/src/components-core/utils/date-utils.js +78 -0
- package/dist/scripts/src/components-core/utils/hooks.js +26 -0
- package/dist/scripts/src/components-core/utils/misc.js +1 -1
- package/dist/scripts/src/components-core/utils/request-params.js +70 -0
- package/dist/scripts/src/logging/LoggerContext.js +22 -0
- package/dist/scripts/src/logging/LoggerInitializer.js +14 -0
- package/dist/scripts/src/logging/LoggerService.js +60 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +7 -0
- package/dist/standalone/xmlui-standalone.es.d.ts +2812 -0
- package/dist/{xmlui-standalone.umd.js → standalone/xmlui-standalone.umd.js} +34881 -31402
- package/package.json +31 -34
- package/dist/apiInterceptorWorker-DZyEgCvB.mjs +0 -8447
- package/dist/language-server-web-worker.d.ts +0 -22
- package/dist/language-server.d.ts +0 -24
- package/dist/parser-CBXS8ft2.mjs +0 -1196
- /package/dist/{core-XLM8cuFP.mjs → lib/core-XLM8cuFP.mjs} +0 -0
- /package/dist/{grammar.tmLanguage-CiEHpsbo.mjs → lib/grammar.tmLanguage-CiEHpsbo.mjs} +0 -0
- /package/dist/{wasm-DDgzZJey.mjs → lib/wasm-DDgzZJey.mjs} +0 -0
- /package/dist/{xmlui-h2uM9PUY.mjs → lib/xmlui-h2uM9PUY.mjs} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseBindingExpression = parseBindingExpression;
|
|
4
|
+
const ScriptingSourceTree_1 = require("../../abstractions/scripting/ScriptingSourceTree");
|
|
5
|
+
/**
|
|
6
|
+
* Finds and evaluates given binding expressions in markdown text.
|
|
7
|
+
* The binding expressions are of the form `@{...}`.
|
|
8
|
+
* @param text The markdown text
|
|
9
|
+
* @param extractValue The function to resolve binding expressions
|
|
10
|
+
* @returns the parsed text with resolved binding expressions
|
|
11
|
+
*/
|
|
12
|
+
function parseBindingExpression(text, extractValue) {
|
|
13
|
+
// Remove empty @{} expressions first
|
|
14
|
+
text = text.replaceAll(/(?<!\\)\@\{\s*\}/g, "");
|
|
15
|
+
// The (?<!\\) is a "negative lookbehind" in regex that ensures that
|
|
16
|
+
// if escaping the @{...} expression like this: \@{...}, we don't match it
|
|
17
|
+
const regex = /(?<!\\)\@\{((?:[^{}]|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*)\}/g;
|
|
18
|
+
const result = text.replace(regex, (_, expr) => {
|
|
19
|
+
const extracted = extractValue(`{${expr}}`);
|
|
20
|
+
const resultExpr = mapByType(extracted);
|
|
21
|
+
// The result expression might be an object, in that case we stringify it here,
|
|
22
|
+
// at the last step, so that there are no unnecessary apostrophes
|
|
23
|
+
return typeof resultExpr === "object" && resultExpr !== null
|
|
24
|
+
? JSON.stringify(resultExpr)
|
|
25
|
+
: resultExpr;
|
|
26
|
+
});
|
|
27
|
+
return result;
|
|
28
|
+
// ---
|
|
29
|
+
function mapByType(extracted) {
|
|
30
|
+
if (extracted === null) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
else if (extracted === undefined || typeof extracted === "undefined") {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
else if (typeof extracted === "object") {
|
|
37
|
+
const arrowFuncResult = parseArrowFunc(extracted);
|
|
38
|
+
if (arrowFuncResult) {
|
|
39
|
+
return arrowFuncResult;
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(extracted)) {
|
|
42
|
+
return extracted;
|
|
43
|
+
}
|
|
44
|
+
return Object.fromEntries(Object.entries(extracted).map(([key, value]) => {
|
|
45
|
+
return [key, mapByType(value)];
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return extracted;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function parseArrowFunc(extracted) {
|
|
53
|
+
if (extracted.hasOwnProperty("type") &&
|
|
54
|
+
extracted.type === ScriptingSourceTree_1.T_ARROW_EXPRESSION &&
|
|
55
|
+
(extracted === null || extracted === void 0 ? void 0 : extracted._ARROW_EXPR_)) {
|
|
56
|
+
return "[xmlui function]";
|
|
57
|
+
}
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.observePlaygroundPattern = observePlaygroundPattern;
|
|
4
|
+
exports.parseSegmentProps = parseSegmentProps;
|
|
5
|
+
exports.parsePlaygroundPattern = parsePlaygroundPattern;
|
|
6
|
+
exports.convertPlaygroundPatternToMarkdown = convertPlaygroundPatternToMarkdown;
|
|
7
|
+
function observePlaygroundPattern(content) {
|
|
8
|
+
const startPattern = "```xmlui-pg";
|
|
9
|
+
const endPattern = "```";
|
|
10
|
+
const startIndex = content.indexOf(startPattern);
|
|
11
|
+
if (startIndex === -1) {
|
|
12
|
+
return null; // No match for the start pattern
|
|
13
|
+
}
|
|
14
|
+
// Find the end of the start pattern
|
|
15
|
+
const startContentIndex = content.indexOf("\n", startIndex);
|
|
16
|
+
if (startContentIndex === -1) {
|
|
17
|
+
return null; // Malformed pattern, no newline after start
|
|
18
|
+
}
|
|
19
|
+
// Search for the end pattern after the start content
|
|
20
|
+
let endIndex = startContentIndex;
|
|
21
|
+
while (endIndex !== -1) {
|
|
22
|
+
endIndex = content.indexOf(endPattern, endIndex + 1);
|
|
23
|
+
if (endIndex !== -1) {
|
|
24
|
+
// Check if the end pattern is not part of {pg-content} (escaped with backticks)
|
|
25
|
+
const precedingChar = content[endIndex - 1];
|
|
26
|
+
if (precedingChar !== "\\") {
|
|
27
|
+
return [
|
|
28
|
+
startIndex,
|
|
29
|
+
endIndex + endPattern.length,
|
|
30
|
+
content.substring(startIndex, endIndex + endPattern.length),
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null; // No valid end pattern found
|
|
36
|
+
}
|
|
37
|
+
function parseSegmentProps(input) {
|
|
38
|
+
const segment = {};
|
|
39
|
+
// --- Match the "display" flag
|
|
40
|
+
if (/\bdisplay\b/.test(input)) {
|
|
41
|
+
segment.display = true;
|
|
42
|
+
}
|
|
43
|
+
// --- Match the "copy" flag
|
|
44
|
+
if (/\bcopy\b/.test(input)) {
|
|
45
|
+
segment.copy = true;
|
|
46
|
+
}
|
|
47
|
+
// --- Match the "noPopup" flag
|
|
48
|
+
if (/\bnoPopup\b/.test(input)) {
|
|
49
|
+
segment.noPopup = true;
|
|
50
|
+
}
|
|
51
|
+
// Match the "highlights" pattern
|
|
52
|
+
const highlightsMatch = input.match(/\{([^\}]+)\}/);
|
|
53
|
+
if (highlightsMatch) {
|
|
54
|
+
const highlights = highlightsMatch[1].split(",").map((range) => {
|
|
55
|
+
if (range.includes("-")) {
|
|
56
|
+
const [start, end] = range.split("-").map(Number);
|
|
57
|
+
return [start, end]; // Represent ranges as [start, end]
|
|
58
|
+
}
|
|
59
|
+
return Number(range); // Represent single numbers as numbers
|
|
60
|
+
});
|
|
61
|
+
segment.highlights = highlights;
|
|
62
|
+
}
|
|
63
|
+
// Match the "filename" property
|
|
64
|
+
const filenameMatch = input.match(/\bfilename="([^"]+)"/);
|
|
65
|
+
if (filenameMatch) {
|
|
66
|
+
segment.filename = filenameMatch[1];
|
|
67
|
+
}
|
|
68
|
+
// Match the "name" property
|
|
69
|
+
const nameMatch = input.match(/\bname="([^"]+)"/);
|
|
70
|
+
if (nameMatch) {
|
|
71
|
+
segment.name = nameMatch[1];
|
|
72
|
+
}
|
|
73
|
+
// Match the "height" property
|
|
74
|
+
const heightMatch = input.match(/\bheight="([^"]+)"/);
|
|
75
|
+
if (heightMatch) {
|
|
76
|
+
segment.height = heightMatch[1];
|
|
77
|
+
}
|
|
78
|
+
return segment;
|
|
79
|
+
}
|
|
80
|
+
function parsePlaygroundPattern(content) {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
82
|
+
const pattern = {};
|
|
83
|
+
const match = observePlaygroundPattern(content);
|
|
84
|
+
if (!match) {
|
|
85
|
+
return pattern;
|
|
86
|
+
}
|
|
87
|
+
// --- Extract the pattern content
|
|
88
|
+
const [_startIndex, _endIndex, patternContent] = match;
|
|
89
|
+
const lines = patternContent.split("\n");
|
|
90
|
+
pattern.default = parseSegmentProps(lines[0].trim());
|
|
91
|
+
let segmentContent = "";
|
|
92
|
+
let currentMode = "";
|
|
93
|
+
let foundSegment = false;
|
|
94
|
+
let order = 0;
|
|
95
|
+
for (let i = 1; i < lines.length - 1; i++) {
|
|
96
|
+
const line = lines[i];
|
|
97
|
+
if (line.startsWith("---app")) {
|
|
98
|
+
const appSegment = parseSegmentProps(line);
|
|
99
|
+
pattern.app = Object.assign({}, appSegment);
|
|
100
|
+
closeCurrentMode("app");
|
|
101
|
+
}
|
|
102
|
+
else if (line.startsWith("---comp")) {
|
|
103
|
+
closeCurrentMode("comp");
|
|
104
|
+
const compSegment = parseSegmentProps(line);
|
|
105
|
+
(_a = pattern.components) !== null && _a !== void 0 ? _a : (pattern.components = []);
|
|
106
|
+
pattern.components.push(compSegment);
|
|
107
|
+
}
|
|
108
|
+
else if (line.startsWith("---config")) {
|
|
109
|
+
const configSegment = parseSegmentProps(line);
|
|
110
|
+
(_b = pattern.config) !== null && _b !== void 0 ? _b : (pattern.config = Object.assign({}, configSegment));
|
|
111
|
+
closeCurrentMode("config");
|
|
112
|
+
}
|
|
113
|
+
else if (line.startsWith("---api")) {
|
|
114
|
+
const apiSegment = parseSegmentProps(line);
|
|
115
|
+
(_c = pattern.api) !== null && _c !== void 0 ? _c : (pattern.api = Object.assign({}, apiSegment));
|
|
116
|
+
closeCurrentMode("api");
|
|
117
|
+
}
|
|
118
|
+
else if (line.startsWith("---desc")) {
|
|
119
|
+
closeCurrentMode("desc");
|
|
120
|
+
const descSegment = parseSegmentProps(line);
|
|
121
|
+
(_d = pattern.descriptions) !== null && _d !== void 0 ? _d : (pattern.descriptions = []);
|
|
122
|
+
pattern.descriptions.push(descSegment);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Append the line to the current segment content
|
|
126
|
+
segmentContent += line + "\n";
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// --- Handle the last segment
|
|
130
|
+
if (foundSegment) {
|
|
131
|
+
closeCurrentMode("");
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
pattern.app = Object.assign(Object.assign({}, pattern.default), { content: segmentContent, order });
|
|
135
|
+
}
|
|
136
|
+
return pattern;
|
|
137
|
+
function closeCurrentMode(newMode) {
|
|
138
|
+
foundSegment = true;
|
|
139
|
+
switch (currentMode) {
|
|
140
|
+
case "app":
|
|
141
|
+
pattern.app.content = segmentContent;
|
|
142
|
+
pattern.app.order = order++;
|
|
143
|
+
break;
|
|
144
|
+
case "comp":
|
|
145
|
+
pattern.components[pattern.components.length - 1].content = segmentContent;
|
|
146
|
+
pattern.components[pattern.components.length - 1].order = order++;
|
|
147
|
+
break;
|
|
148
|
+
case "config":
|
|
149
|
+
pattern.config.content = segmentContent;
|
|
150
|
+
pattern.config.order = order++;
|
|
151
|
+
break;
|
|
152
|
+
case "api":
|
|
153
|
+
pattern.api.content = segmentContent;
|
|
154
|
+
pattern.api.order = order++;
|
|
155
|
+
break;
|
|
156
|
+
case "desc":
|
|
157
|
+
pattern.descriptions[pattern.descriptions.length - 1].content = segmentContent;
|
|
158
|
+
pattern.descriptions[pattern.descriptions.length - 1].order = order++;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
segmentContent = "";
|
|
162
|
+
currentMode = newMode;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function convertPlaygroundPatternToMarkdown(content) {
|
|
166
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
167
|
+
const pattern = parsePlaygroundPattern(content);
|
|
168
|
+
// --- Determine max order for segments
|
|
169
|
+
let maxOrder = 0;
|
|
170
|
+
if (((_a = pattern.app) === null || _a === void 0 ? void 0 : _a.order) > maxOrder) {
|
|
171
|
+
maxOrder = pattern.app.order;
|
|
172
|
+
}
|
|
173
|
+
if (((_b = pattern.config) === null || _b === void 0 ? void 0 : _b.order) > maxOrder) {
|
|
174
|
+
maxOrder = pattern.config.order;
|
|
175
|
+
}
|
|
176
|
+
if (((_c = pattern.api) === null || _c === void 0 ? void 0 : _c.order) > maxOrder) {
|
|
177
|
+
maxOrder = pattern.api.order;
|
|
178
|
+
}
|
|
179
|
+
if (pattern.descriptions) {
|
|
180
|
+
pattern.descriptions.forEach((desc) => {
|
|
181
|
+
if (desc.order > maxOrder) {
|
|
182
|
+
maxOrder = desc.order;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (pattern.components) {
|
|
187
|
+
pattern.components.forEach((comp) => {
|
|
188
|
+
if (comp.order > maxOrder) {
|
|
189
|
+
maxOrder = comp.order;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
// --- Assemble the final markdown content
|
|
194
|
+
let markdownContent = "";
|
|
195
|
+
const pgContent = { noPopup: (_d = pattern.default) === null || _d === void 0 ? void 0 : _d.noPopup };
|
|
196
|
+
// --- Extract optional playground attributes
|
|
197
|
+
if (pattern.default.height) {
|
|
198
|
+
pgContent.height = pattern.default.height;
|
|
199
|
+
}
|
|
200
|
+
if (pattern.default.name) {
|
|
201
|
+
pgContent.name = pattern.default.name;
|
|
202
|
+
}
|
|
203
|
+
// --- Iterate through segments
|
|
204
|
+
for (let i = 0; i <= maxOrder; i++) {
|
|
205
|
+
let segment;
|
|
206
|
+
let type = "";
|
|
207
|
+
if (((_e = pattern.app) === null || _e === void 0 ? void 0 : _e.order) === i) {
|
|
208
|
+
segment = pattern.app;
|
|
209
|
+
type = "app";
|
|
210
|
+
}
|
|
211
|
+
else if (((_f = pattern.config) === null || _f === void 0 ? void 0 : _f.order) === i) {
|
|
212
|
+
segment = pattern.config;
|
|
213
|
+
type = "config";
|
|
214
|
+
}
|
|
215
|
+
else if (((_g = pattern.api) === null || _g === void 0 ? void 0 : _g.order) === i) {
|
|
216
|
+
segment = pattern.api;
|
|
217
|
+
type = "api";
|
|
218
|
+
}
|
|
219
|
+
if (!segment && pattern.descriptions) {
|
|
220
|
+
const descSegment = pattern.descriptions.find((desc) => desc.order === i);
|
|
221
|
+
if (descSegment) {
|
|
222
|
+
segment = descSegment;
|
|
223
|
+
type = "desc";
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (!segment && pattern.components) {
|
|
227
|
+
const compSegment = pattern.components.find((comp) => comp.order === i);
|
|
228
|
+
if (compSegment) {
|
|
229
|
+
segment = compSegment;
|
|
230
|
+
type = "comp";
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (segment === undefined) {
|
|
234
|
+
continue; // Skip if no segment found
|
|
235
|
+
}
|
|
236
|
+
// --- Assemble the app
|
|
237
|
+
// --- Assemble segment attributes
|
|
238
|
+
let segmentAttrs = `${segment.copy ? "copy" : ""} ` +
|
|
239
|
+
`${segment.filename ? `filename="${segment.filename}"` : ""} ` +
|
|
240
|
+
`${segment.name ? `name="${segment.name}"` : ""}`;
|
|
241
|
+
if (segment.highlights && segment.highlights.length > 0) {
|
|
242
|
+
const highlights = segment.highlights
|
|
243
|
+
.map((highlight) => Array.isArray(highlight) ? `${highlight[0]}-${highlight[1]}` : highlight)
|
|
244
|
+
.join(",");
|
|
245
|
+
segmentAttrs += `{${highlights}}`;
|
|
246
|
+
}
|
|
247
|
+
segmentAttrs = segmentAttrs.trim().replace(/\s+/g, " ");
|
|
248
|
+
switch (type) {
|
|
249
|
+
case "app":
|
|
250
|
+
if (segment.display) {
|
|
251
|
+
markdownContent += "```xmlui " + segmentAttrs + "\n" + segment.content + "```\n\n";
|
|
252
|
+
}
|
|
253
|
+
pgContent.app = segment.content;
|
|
254
|
+
break;
|
|
255
|
+
case "config":
|
|
256
|
+
if (segment.display) {
|
|
257
|
+
markdownContent += "```json " + segmentAttrs + "\n" + segment.content + "```\n\n";
|
|
258
|
+
}
|
|
259
|
+
pgContent.config = segment.content;
|
|
260
|
+
break;
|
|
261
|
+
case "api":
|
|
262
|
+
// --- Never display API segments
|
|
263
|
+
pgContent.api = segment.content;
|
|
264
|
+
break;
|
|
265
|
+
case "comp":
|
|
266
|
+
if (segment.display) {
|
|
267
|
+
markdownContent += "```xmlui " + segmentAttrs + "\n" + segment.content + "```\n\n";
|
|
268
|
+
}
|
|
269
|
+
(_h = pgContent.components) !== null && _h !== void 0 ? _h : (pgContent.components = []);
|
|
270
|
+
pgContent.components.push(segment.content);
|
|
271
|
+
break;
|
|
272
|
+
case "desc":
|
|
273
|
+
markdownContent += segment.content + "\n";
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// --- Convert the JSON representation of pgContent to a base64 string
|
|
278
|
+
const jsonString = JSON.stringify(pgContent);
|
|
279
|
+
const base64String = btoa(jsonString);
|
|
280
|
+
markdownContent += '<samp data-pg-content="' + base64String + '"></samp>\n\n';
|
|
281
|
+
return markdownContent;
|
|
282
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.ConfirmationModalContextProvider = exports.useConfirm = void 0;
|
|
46
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
47
|
+
const react_1 = __importStar(require("react"));
|
|
48
|
+
const ButtonNative_1 = require("../Button/ButtonNative");
|
|
49
|
+
const StackNative_1 = require("../Stack/StackNative");
|
|
50
|
+
const Dialog_1 = require("./Dialog");
|
|
51
|
+
const ConfirmationModalContext = react_1.default.createContext({
|
|
52
|
+
confirm: (title, message, actionLabel) => __awaiter(void 0, void 0, void 0, function* () { return false; }),
|
|
53
|
+
});
|
|
54
|
+
const useConfirm = () => (0, react_1.useContext)(ConfirmationModalContext);
|
|
55
|
+
exports.useConfirm = useConfirm;
|
|
56
|
+
const ConfirmationModalContextProvider = ({ children }) => {
|
|
57
|
+
// State
|
|
58
|
+
const [showConfirmationModal, setShowConfirmationModal] = (0, react_1.useState)(false);
|
|
59
|
+
const [title, setTitle] = (0, react_1.useState)("Are you sure?");
|
|
60
|
+
const [message, setMessage] = (0, react_1.useState)();
|
|
61
|
+
const [buttons, setButtons] = (0, react_1.useState)([]);
|
|
62
|
+
// Refs and other
|
|
63
|
+
const resolver = (0, react_1.useRef)(null);
|
|
64
|
+
const buttonsRef = (0, react_1.useRef)(null);
|
|
65
|
+
(0, react_1.useEffect)(() => {
|
|
66
|
+
if (showConfirmationModal) {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
var _a;
|
|
69
|
+
const focusable = (_a = buttonsRef.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll("button");
|
|
70
|
+
if (focusable) {
|
|
71
|
+
focusable[focusable.length - 1].focus();
|
|
72
|
+
}
|
|
73
|
+
}, 0);
|
|
74
|
+
}
|
|
75
|
+
}, [showConfirmationModal]);
|
|
76
|
+
const handleShow = (0, react_1.useCallback)((title, message, actionLabel) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
if (typeof title === "string") {
|
|
78
|
+
setTitle(title);
|
|
79
|
+
setButtons([
|
|
80
|
+
{
|
|
81
|
+
label: actionLabel || "Ok",
|
|
82
|
+
value: true,
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
setMessage(message);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
setTitle(title.title);
|
|
89
|
+
setButtons(title.buttons);
|
|
90
|
+
setMessage(title.message);
|
|
91
|
+
}
|
|
92
|
+
setShowConfirmationModal(true);
|
|
93
|
+
return new Promise(function (resolve) {
|
|
94
|
+
resolver.current = resolve;
|
|
95
|
+
});
|
|
96
|
+
}), []);
|
|
97
|
+
const handleOk = (0, react_1.useCallback)((value) => {
|
|
98
|
+
resolver.current && resolver.current(value);
|
|
99
|
+
setShowConfirmationModal(false);
|
|
100
|
+
}, []);
|
|
101
|
+
const handleCancel = (0, react_1.useCallback)(() => {
|
|
102
|
+
resolver.current && resolver.current(false);
|
|
103
|
+
setShowConfirmationModal(false);
|
|
104
|
+
}, []);
|
|
105
|
+
const contextValue = (0, react_1.useMemo)(() => {
|
|
106
|
+
return {
|
|
107
|
+
confirm: handleShow,
|
|
108
|
+
};
|
|
109
|
+
}, [handleShow]);
|
|
110
|
+
return ((0, jsx_runtime_1.jsxs)(ConfirmationModalContext.Provider, { value: contextValue, children: [children, showConfirmationModal && ((0, jsx_runtime_1.jsx)(Dialog_1.Dialog, { title: title, description: message, isOpen: true, onClose: handleCancel, buttons: (0, jsx_runtime_1.jsxs)(StackNative_1.Stack, { orientation: "horizontal", horizontalAlignment: "end", style: { width: "100%", gap: "1em" }, ref: buttonsRef, children: [(0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: "ghost", themeColor: "secondary", size: "sm", onClick: handleCancel, children: "Cancel" }), buttons.length > 1 ? (0, jsx_runtime_1.jsx)("div", { style: { flex: 1 } }) : undefined, buttons.map(({ label, value, variant = "solid", themeColor = "attention" }, index) => {
|
|
111
|
+
return ((0, jsx_runtime_1.jsx)(ButtonNative_1.Button, { variant: variant, themeColor: themeColor, size: "sm", type: "submit", onClick: () => {
|
|
112
|
+
handleOk(value);
|
|
113
|
+
}, children: label }, index));
|
|
114
|
+
})] }) }))] }));
|
|
115
|
+
};
|
|
116
|
+
exports.ConfirmationModalContextProvider = ConfirmationModalContextProvider;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Dialog = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const Dialog_module_scss_1 = __importDefault(require("./Dialog.module.scss"));
|
|
9
|
+
const TextNative_1 = require("../Text/TextNative");
|
|
10
|
+
const ModalDialogNative_1 = require("./ModalDialogNative");
|
|
11
|
+
/**
|
|
12
|
+
* Dialog component that is customizable with action buttons. The children prop accepts React elements.
|
|
13
|
+
*
|
|
14
|
+
* Note that clicking outside of the dialog or pressing Escape will call the onClose function.
|
|
15
|
+
* Thus, if you want to stop that from firing, do so in the onClose function from outside.
|
|
16
|
+
*/
|
|
17
|
+
const Dialog = ({ title, description, children, isOpen, onClose, buttons, }) => {
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(ModalDialogNative_1.ModalDialog, { onClose: onClose, isInitiallyOpen: isOpen, title: title, children: [(0, jsx_runtime_1.jsxs)("div", { className: Dialog_module_scss_1.default.dialogContent, children: [(0, jsx_runtime_1.jsx)("div", { id: "dialogDesc", children: (0, jsx_runtime_1.jsx)(TextNative_1.Text, { children: description }) }), children] }), !!buttons && (0, jsx_runtime_1.jsx)("footer", { className: Dialog_module_scss_1.default.dialogActions, children: buttons })] }));
|
|
19
|
+
};
|
|
20
|
+
exports.Dialog = Dialog;
|
|
@@ -18,8 +18,8 @@ const NavPanelNative_1 = require("../NavPanel/NavPanelNative");
|
|
|
18
18
|
exports.defaultProps = {
|
|
19
19
|
iconHorizontalExpanded: "chevronleft",
|
|
20
20
|
iconHorizontalCollapsed: "chevronright",
|
|
21
|
-
iconVerticalExpanded: "
|
|
22
|
-
iconVerticalCollapsed: "
|
|
21
|
+
iconVerticalExpanded: "chevrondown",
|
|
22
|
+
iconVerticalCollapsed: "chevronright",
|
|
23
23
|
};
|
|
24
24
|
const NavGroupContext = (0, react_1.createContext)({
|
|
25
25
|
level: -1,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.nestedAppComponentRenderer = exports.NestedAppMd = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const NestedApp_module_scss_1 = __importDefault(require("./NestedApp.module.scss"));
|
|
9
|
+
const ComponentDefs_1 = require("../../abstractions/ComponentDefs");
|
|
10
|
+
const renderers_1 = require("../../components-core/renderers");
|
|
11
|
+
const themeVars_1 = require("../../components-core/theming/themeVars");
|
|
12
|
+
const NestedAppNative_1 = require("./NestedAppNative");
|
|
13
|
+
const COMP = "NestedApp";
|
|
14
|
+
exports.NestedAppMd = (0, ComponentDefs_1.createMetadata)({
|
|
15
|
+
description: `The ${COMP} component allows you to nest an entire xmlui app into another one.
|
|
16
|
+
`,
|
|
17
|
+
props: {
|
|
18
|
+
app: {
|
|
19
|
+
description: "The source markup of the app to be nested",
|
|
20
|
+
},
|
|
21
|
+
api: {
|
|
22
|
+
description: "This property defines an optional emulated API to be used with the nested app.",
|
|
23
|
+
},
|
|
24
|
+
components: {
|
|
25
|
+
description: "This property defines an optional list of components to be used with the nested app.",
|
|
26
|
+
},
|
|
27
|
+
config: {
|
|
28
|
+
description: "You can define the nested app's configuration with this property.",
|
|
29
|
+
},
|
|
30
|
+
activeTheme: {
|
|
31
|
+
description: "This property defines the active theme for the nested app.",
|
|
32
|
+
},
|
|
33
|
+
activeTone: {
|
|
34
|
+
description: "This property defines the active tone for the nested app.",
|
|
35
|
+
},
|
|
36
|
+
title: {
|
|
37
|
+
description: "The title of the nested app.",
|
|
38
|
+
},
|
|
39
|
+
height: {
|
|
40
|
+
description: "The height of the nested app.",
|
|
41
|
+
},
|
|
42
|
+
allowPlaygroundPopup: {
|
|
43
|
+
description: "This property defines whether the nested app can be opened in the xmlui playground.",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
themeVars: (0, themeVars_1.parseScssVar)(NestedApp_module_scss_1.default.themeVars),
|
|
47
|
+
defaultThemeVars: {
|
|
48
|
+
[`marginTop-${COMP}`]: "$space-3",
|
|
49
|
+
[`marginBottom-${COMP}`]: "$space-3",
|
|
50
|
+
[`padding-${COMP}`]: "$space-4",
|
|
51
|
+
[`paddingTop-${COMP}`]: "$space-3",
|
|
52
|
+
[`borderRadius-${COMP}`]: "$space-4",
|
|
53
|
+
[`backgroundColor-frame-${COMP}`]: "$color-primary-100",
|
|
54
|
+
[`gap-frame-${COMP}`]: "$space-4",
|
|
55
|
+
[`fontWeight-header-${COMP}`]: "$fontWeight-bold",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
exports.nestedAppComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.NestedAppMd, ({ node, extractValue }) => {
|
|
59
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
60
|
+
return ((0, jsx_runtime_1.jsx)(NestedAppNative_1.NestedApp, { app: (_a = node.props) === null || _a === void 0 ? void 0 : _a.app, api: extractValue((_b = node.props) === null || _b === void 0 ? void 0 : _b.api), components: extractValue((_c = node.props) === null || _c === void 0 ? void 0 : _c.components), config: extractValue((_d = node.props) === null || _d === void 0 ? void 0 : _d.config), activeTheme: extractValue((_e = node.props) === null || _e === void 0 ? void 0 : _e.activeTheme), activeTone: extractValue((_f = node.props) === null || _f === void 0 ? void 0 : _f.activeTone), title: extractValue((_g = node.props) === null || _g === void 0 ? void 0 : _g.title), height: extractValue((_h = node.props) === null || _h === void 0 ? void 0 : _h.height), allowPlaygroundPopup: extractValue.asOptionalBoolean((_j = node.props) === null || _j === void 0 ? void 0 : _j.allowPlaygroundPopup) }));
|
|
61
|
+
});
|