xmlui 0.9.54 → 0.9.55

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmlui",
3
- "version": "0.9.54",
3
+ "version": "0.9.55",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "start-test-bed": "cd src/testing/infrastructure && xmlui start",
@@ -101,6 +101,7 @@ const ColorPicker_1 = require("./ColorPicker/ColorPicker");
101
101
  const RadioItem_1 = require("./RadioGroup/RadioItem");
102
102
  const InspectButton_1 = require("./InspectButton/InspectButton");
103
103
  const NestedApp_1 = require("./NestedApp/NestedApp");
104
+ const AppWithCodeView_1 = require("./NestedApp/AppWithCodeView");
104
105
  const CodeBlock_1 = require("./CodeBlock/CodeBlock");
105
106
  const BarChart_1 = require("./Charts/BarChart/BarChart");
106
107
  const DonutChart_1 = require("./Charts/DonutChart/DonutChart");
@@ -405,6 +406,7 @@ class ComponentRegistry {
405
406
  this.registerCoreComponent(CodeBlock_1.codeBlockComponentRenderer);
406
407
  // --- Nested app and related components
407
408
  this.registerCoreComponent(NestedApp_1.nestedAppComponentRenderer);
409
+ this.registerCoreComponent(AppWithCodeView_1.appWithCodeViewComponentRenderer);
408
410
  // --- New Bootstrap-inspired components
409
411
  this.registerCoreComponent(Carousel_1.carouselComponentRenderer);
410
412
  this.registerCoreComponent(Accordion_1.accordionComponentRenderer);
@@ -59,7 +59,6 @@ const HeadingNative_1 = require("../Heading/HeadingNative");
59
59
  const TextNative_1 = require("../Text/TextNative");
60
60
  const LinkNative_1 = require("../Link/LinkNative");
61
61
  const Toggle_1 = require("../Toggle/Toggle");
62
- const NestedAppNative_1 = require("../NestedApp/NestedAppNative");
63
62
  const highlight_code_1 = require("../CodeBlock/highlight-code");
64
63
  const ThemeContext_1 = require("../../components-core/theming/ThemeContext");
65
64
  const AppContext_1 = require("../../components-core/AppContext");
@@ -69,6 +68,7 @@ const IconNative_1 = __importDefault(require("../Icon/IconNative"));
69
68
  const TreeDisplayNative_1 = require("../TreeDisplay/TreeDisplayNative");
70
69
  const unist_util_visit_1 = require("unist-util-visit");
71
70
  const ExpandableItemNative_1 = require("../ExpandableItem/ExpandableItemNative");
71
+ const AppWithCodeViewNative_1 = __importDefault(require("../NestedApp/AppWithCodeViewNative"));
72
72
  // Default props for the Markdown component
73
73
  exports.defaultProps = {
74
74
  removeIndents: true,
@@ -232,15 +232,15 @@ exports.Markdown = (0, react_1.memo)(function Markdown({ removeIndents = exports
232
232
  return (0, jsx_runtime_1.jsx)("tfoot", { className: HtmlTags_module_scss_1.default.htmlTfoot, children: children });
233
233
  },
234
234
  samp(_a) {
235
+ var _b;
235
236
  var props = __rest(_a, []);
236
237
  const nestedProps = props;
238
+ const markdownContentBase64 = props === null || props === void 0 ? void 0 : props["data-pg-markdown"];
239
+ const markdownContent = markdownContentBase64 ? atob(markdownContentBase64) : "";
237
240
  const dataContentBase64 = props === null || props === void 0 ? void 0 : props["data-pg-content"];
238
- if (dataContentBase64 !== undefined) {
239
- const jsonContent = atob(dataContentBase64);
240
- const appProps = JSON.parse(jsonContent);
241
- return ((0, jsx_runtime_1.jsx)(NestedAppNative_1.IndexAwareNestedApp, { app: appProps.app, config: appProps.config, components: appProps.components, api: appProps.api, activeTheme: appProps.activeTheme, activeTone: appProps.activeTone, title: appProps.name, height: appProps.height, allowPlaygroundPopup: !appProps.noPopup }));
242
- }
243
- return ((0, jsx_runtime_1.jsx)(NestedAppNative_1.IndexAwareNestedApp, { app: nestedProps.app, config: nestedProps.config, components: nestedProps.components, api: nestedProps.api, activeTheme: nestedProps.activeTheme, activeTone: nestedProps.activeTone, title: nestedProps.title, height: nestedProps.height, allowPlaygroundPopup: true }));
241
+ const jsonContent = atob(dataContentBase64);
242
+ const appProps = JSON.parse(jsonContent);
243
+ return ((0, jsx_runtime_1.jsx)(AppWithCodeViewNative_1.default, { markdown: markdownContent, app: appProps.app, config: appProps.config, components: appProps.components, api: appProps.api, activeTheme: appProps.activeTheme, activeTone: appProps.activeTone, title: appProps.name, height: appProps.height, allowPlaygroundPopup: !appProps.noPopup, withFrame: appProps.noFrame ? false : true, sideBySide: (_b = appProps.sideBySide) !== null && _b !== void 0 ? _b : false }));
244
244
  },
245
245
  section(_a) {
246
246
  var { children } = _a, props = __rest(_a, ["children"]);
@@ -320,10 +320,10 @@ const Blockquote = ({ children, style }) => {
320
320
  // Get the child's text content
321
321
  const childText = extractTextContent(child.props.children);
322
322
  // Skip the first line which contains the summary
323
- const lines = childText.split('\n');
323
+ const lines = childText.split("\n");
324
324
  if (lines.length > 1) {
325
325
  // Create modified element with remaining content
326
- const remainingContent = lines.slice(1).join('\n');
326
+ const remainingContent = lines.slice(1).join("\n");
327
327
  if (remainingContent.trim()) {
328
328
  contentWithoutSummary.push(react_1.default.cloneElement(child, child.props, remainingContent));
329
329
  }
@@ -50,6 +50,14 @@ function parseSegmentProps(input) {
50
50
  if (/\bnoPopup\b/.test(input)) {
51
51
  segment.noPopup = true;
52
52
  }
53
+ // --- Match the "noFrame" flag
54
+ if (/\bnoFrame\b/.test(input)) {
55
+ segment.noFrame = true;
56
+ }
57
+ // --- Match the "sideBySide" flag
58
+ if (/\bsideBySide\b/.test(input)) {
59
+ segment.sideBySide = true;
60
+ }
53
61
  // Match the "highlights" pattern
54
62
  const highlightsMatch = input.match(/\{([^\}]+)\}/);
55
63
  if (highlightsMatch) {
@@ -179,7 +187,7 @@ function parsePlaygroundPattern(content) {
179
187
  }
180
188
  }
181
189
  function convertPlaygroundPatternToMarkdown(content) {
182
- var _a, _b, _c, _d, _e, _f, _g, _h;
190
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
183
191
  const pattern = parsePlaygroundPattern(content);
184
192
  // --- Determine max order for segments
185
193
  let maxOrder = 0;
@@ -208,7 +216,11 @@ function convertPlaygroundPatternToMarkdown(content) {
208
216
  }
209
217
  // --- Assemble the final markdown content
210
218
  let markdownContent = "";
211
- const pgContent = { noPopup: (_d = pattern.default) === null || _d === void 0 ? void 0 : _d.noPopup };
219
+ const pgContent = {
220
+ noPopup: (_d = pattern.default) === null || _d === void 0 ? void 0 : _d.noPopup,
221
+ noFrame: (_e = pattern.default) === null || _e === void 0 ? void 0 : _e.noFrame,
222
+ sideBySide: (_f = pattern.default) === null || _f === void 0 ? void 0 : _f.sideBySide
223
+ };
212
224
  // --- Extract optional playground attributes
213
225
  if (pattern.default.height) {
214
226
  pgContent.height = pattern.default.height;
@@ -220,15 +232,15 @@ function convertPlaygroundPatternToMarkdown(content) {
220
232
  for (let i = 0; i <= maxOrder; i++) {
221
233
  let segment;
222
234
  let type = "";
223
- if (((_e = pattern.app) === null || _e === void 0 ? void 0 : _e.order) === i) {
235
+ if (((_g = pattern.app) === null || _g === void 0 ? void 0 : _g.order) === i) {
224
236
  segment = pattern.app;
225
237
  type = "app";
226
238
  }
227
- else if (((_f = pattern.config) === null || _f === void 0 ? void 0 : _f.order) === i) {
239
+ else if (((_h = pattern.config) === null || _h === void 0 ? void 0 : _h.order) === i) {
228
240
  segment = pattern.config;
229
241
  type = "config";
230
242
  }
231
- else if (((_g = pattern.api) === null || _g === void 0 ? void 0 : _g.order) === i) {
243
+ else if (((_j = pattern.api) === null || _j === void 0 ? void 0 : _j.order) === i) {
232
244
  segment = pattern.api;
233
245
  type = "api";
234
246
  }
@@ -288,7 +300,7 @@ function convertPlaygroundPatternToMarkdown(content) {
288
300
  if (segment.display) {
289
301
  markdownContent += "```xmlui " + segmentAttrs + "\n" + segment.content + "```\n\n";
290
302
  }
291
- (_h = pgContent.components) !== null && _h !== void 0 ? _h : (pgContent.components = []);
303
+ (_k = pgContent.components) !== null && _k !== void 0 ? _k : (pgContent.components = []);
292
304
  pgContent.components.push(segment.content);
293
305
  break;
294
306
  case "desc":
@@ -298,9 +310,9 @@ function convertPlaygroundPatternToMarkdown(content) {
298
310
  }
299
311
  // --- Convert the JSON representation of pgContent to a base64 string
300
312
  const jsonString = JSON.stringify(pgContent);
301
- const base64String = btoa(jsonString);
302
- markdownContent += '<samp data-pg-content="' + base64String + '"></samp>\n\n';
303
- return markdownContent;
313
+ const base64ContentString = btoa(jsonString);
314
+ const base64MarkdownString = btoa(markdownContent);
315
+ return '<samp data-pg-content="' + base64ContentString + '" data-pg-markdown="' + base64MarkdownString + '"></samp>\n\n';
304
316
  }
305
317
  function observeTreeDisplay(content) {
306
318
  const startPattern = "```xmlui-tree";
@@ -0,0 +1,72 @@
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.appWithCodeViewComponentRenderer = exports.AppWithCodeViewMd = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const AppWithCodeView_module_scss_1 = __importDefault(require("./AppWithCodeView.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 AppWithCodeViewNative_1 = require("./AppWithCodeViewNative");
13
+ const defaultProps_1 = require("./defaultProps");
14
+ const COMP = "AppWithCodeView";
15
+ exports.AppWithCodeViewMd = (0, ComponentDefs_1.createMetadata)({
16
+ status: "experimental",
17
+ description: `The ${COMP} component displays a combination of markdown content and a nested xmlui app.
18
+ It supports both side-by-side and stacked layouts.`,
19
+ props: {
20
+ markdown: {
21
+ description: "The markdown content to be displayed alongside the app",
22
+ valueType: "string",
23
+ },
24
+ sideBySide: {
25
+ description: "Whether to render the markdown and app side by side or stacked vertically",
26
+ valueType: "boolean",
27
+ },
28
+ app: {
29
+ description: "The source markup of the app to be nested",
30
+ },
31
+ api: {
32
+ description: "This property defines an optional emulated API to be used with the nested app.",
33
+ },
34
+ components: {
35
+ description: "This property defines an optional list of components to be used with the nested app.",
36
+ defaultValue: defaultProps_1.defaultProps.components,
37
+ },
38
+ config: {
39
+ description: "You can define the nested app's configuration with this property.",
40
+ },
41
+ activeTheme: {
42
+ description: "This property defines the active theme for the nested app. " +
43
+ "If not set, the default theme is used.",
44
+ },
45
+ activeTone: {
46
+ description: "This property defines the active tone for the nested app. " +
47
+ "If not set, the default tone is used.",
48
+ },
49
+ title: {
50
+ description: "The optional title of the nested app. If not set, no title is displayed.",
51
+ },
52
+ height: {
53
+ description: "The height of the nested app. If not set, the height is determined automatically.",
54
+ },
55
+ allowPlaygroundPopup: {
56
+ description: "This property defines whether the nested app can be opened in the xmlui playground.",
57
+ valueType: "boolean",
58
+ defaultValue: defaultProps_1.defaultProps.allowPlaygroundPopup,
59
+ },
60
+ withFrame: {
61
+ description: "This property defines whether the nested app should be displayed with a frame.",
62
+ valueType: "boolean",
63
+ defaultValue: defaultProps_1.defaultProps.withFrame,
64
+ },
65
+ },
66
+ themeVars: (0, themeVars_1.parseScssVar)(AppWithCodeView_module_scss_1.default.themeVars),
67
+ defaultThemeVars: {},
68
+ });
69
+ exports.appWithCodeViewComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.AppWithCodeViewMd, ({ node, extractValue }) => {
70
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
71
+ return ((0, jsx_runtime_1.jsx)(AppWithCodeViewNative_1.AppWithCodeViewNative, { markdown: extractValue((_a = node.props) === null || _a === void 0 ? void 0 : _a.markdown), sideBySide: extractValue.asOptionalBoolean((_b = node.props) === null || _b === void 0 ? void 0 : _b.sideBySide), app: (_c = node.props) === null || _c === void 0 ? void 0 : _c.app, api: extractValue((_d = node.props) === null || _d === void 0 ? void 0 : _d.api), components: extractValue((_e = node.props) === null || _e === void 0 ? void 0 : _e.components), config: extractValue((_f = node.props) === null || _f === void 0 ? void 0 : _f.config), activeTheme: extractValue((_g = node.props) === null || _g === void 0 ? void 0 : _g.activeTheme), activeTone: extractValue((_h = node.props) === null || _h === void 0 ? void 0 : _h.activeTone), title: extractValue((_j = node.props) === null || _j === void 0 ? void 0 : _j.title), height: extractValue((_k = node.props) === null || _k === void 0 ? void 0 : _k.height), allowPlaygroundPopup: extractValue.asOptionalBoolean((_l = node.props) === null || _l === void 0 ? void 0 : _l.allowPlaygroundPopup), withFrame: extractValue.asOptionalBoolean((_m = node.props) === null || _m === void 0 ? void 0 : _m.withFrame) }));
72
+ });
@@ -0,0 +1,24 @@
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.AppWithCodeViewNative = AppWithCodeViewNative;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const AppWithCodeView_module_scss_1 = __importDefault(require("./AppWithCodeView.module.scss"));
9
+ const classnames_1 = __importDefault(require("classnames"));
10
+ const NestedAppNative_1 = require("./NestedAppNative");
11
+ const Markdown_1 = require("../Markdown/Markdown");
12
+ /**
13
+ * A component that displays markdown content on the left and a NestedApp on the right
14
+ */
15
+ function AppWithCodeViewNative({ markdown, sideBySide, app, api, components = [], config, activeTone, activeTheme, title, height, allowPlaygroundPopup, withFrame, }) {
16
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(AppWithCodeView_module_scss_1.default.container, {
17
+ [AppWithCodeView_module_scss_1.default.horizontal]: sideBySide,
18
+ [AppWithCodeView_module_scss_1.default.vertical]: !sideBySide,
19
+ }), children: [(0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)({ [AppWithCodeView_module_scss_1.default.column]: sideBySide }), children: (0, jsx_runtime_1.jsx)(Markdown_1.Markdown, { children: markdown }) }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)({ [AppWithCodeView_module_scss_1.default.column]: sideBySide }), children: (0, jsx_runtime_1.jsx)(NestedAppNative_1.NestedApp, { app: app, api: api, components: components, config: config, activeTone: activeTone, activeTheme: activeTheme, title: title, height: height, allowPlaygroundPopup: allowPlaygroundPopup, withFrame: sideBySide ? false : withFrame }) })] }));
20
+ }
21
+ /**
22
+ * Export a named default for easier imports
23
+ */
24
+ exports.default = AppWithCodeViewNative;
@@ -69,6 +69,6 @@ exports.NestedAppMd = (0, ComponentDefs_1.createMetadata)({
69
69
  },
70
70
  });
71
71
  exports.nestedAppComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.NestedAppMd, ({ node, extractValue }) => {
72
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
73
- return ((0, jsx_runtime_1.jsx)(NestedAppNative_1.IndexAwareNestedApp, { 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) }));
72
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
73
+ return ((0, jsx_runtime_1.jsx)(NestedAppNative_1.IndexAwareNestedApp, { 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), withFrame: extractValue.asOptionalBoolean((_k = node.props) === null || _k === void 0 ? void 0 : _k.withFrame) }));
74
74
  });
@@ -53,7 +53,7 @@ function IndexAwareNestedApp(props) {
53
53
  }
54
54
  return (0, jsx_runtime_1.jsx)(LazyNestedApp, Object.assign({}, props));
55
55
  }
56
- function NestedApp({ api, app, components = constants_1.EMPTY_ARRAY, config, activeTheme, activeTone, title, height, allowPlaygroundPopup = defaultProps_1.defaultProps.allowPlaygroundPopup, withFrame = defaultProps_1.defaultProps.withFrame, playgroundId, }) {
56
+ function NestedApp({ api, app, components = constants_1.EMPTY_ARRAY, config, activeTheme, activeTone, title, height, allowPlaygroundPopup = defaultProps_1.defaultProps.allowPlaygroundPopup, withFrame = defaultProps_1.defaultProps.withFrame, }) {
57
57
  const rootRef = (0, react_1.useRef)(null);
58
58
  const shadowRef = (0, react_1.useRef)(null);
59
59
  const contentRootRef = (0, react_1.useRef)(null);
@@ -1303,7 +1303,7 @@ declare type Message = ValueOrFunction<Renderable, Toast>;
1303
1303
  */
1304
1304
  declare type ModuleErrors = Record<string, ScriptParserErrorMessage[]>;
1305
1305
 
1306
- declare function NestedApp({ api, app, components, config, activeTheme, activeTone, title, height, allowPlaygroundPopup, withFrame, playgroundId, }: NestedAppProps): JSX_2.Element;
1306
+ declare function NestedApp({ api, app, components, config, activeTheme, activeTone, title, height, allowPlaygroundPopup, withFrame, }: NestedAppProps): JSX_2.Element;
1307
1307
 
1308
1308
  declare type NestedAppProps = {
1309
1309
  api?: any;
@@ -1316,7 +1316,6 @@ declare type NestedAppProps = {
1316
1316
  height?: string | number;
1317
1317
  allowPlaygroundPopup?: boolean;
1318
1318
  withFrame?: boolean;
1319
- playgroundId?: string;
1320
1319
  };
1321
1320
 
1322
1321
  declare type NO_ARG_EXPRESSION = typeof T_NO_ARG_EXPRESSION;