xmlui 0.7.20 → 0.7.21
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/{apiInterceptorWorker-D3L7dpSV.mjs → apiInterceptorWorker-LRHkKnha.mjs} +1 -1
- package/dist/{grammar.tmLanguage-69iP6c5d.mjs → grammar.tmLanguage-DNepe_jP.mjs} +1 -1
- package/dist/index-5NLXyjX0.mjs +31055 -0
- package/dist/index.css +1 -1
- package/dist/scripts/bin/build-lib.js +1 -1
- package/dist/scripts/bin/index.js +2 -2
- package/dist/scripts/bin/start.js +23 -6
- package/dist/scripts/bin/viteConfig.js +1 -0
- package/dist/scripts/package.json +2 -1
- package/dist/scripts/src/abstractions/ExtensionDefs.js +2 -0
- package/dist/scripts/src/components/ComponentProvider.js +171 -148
- package/dist/scripts/src/components/FormItem/FormItemNative.js +1 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +33 -0
- package/dist/scripts/src/components/RawHtml/RawHtml.js +39 -0
- package/dist/scripts/src/components/RawHtml/RawHtmlNative.js +13 -0
- package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
- package/dist/scripts/src/components-core/LoaderComponent.js +1 -1
- package/dist/scripts/src/components-core/RestApiProxy.js +1 -1
- package/dist/scripts/src/components-core/StandaloneApp.js +19 -19
- package/dist/scripts/src/components-core/{StandaloneComponentManager.js → StandaloneExtensionManager.js} +6 -13
- package/dist/scripts/src/components-core/action/APICall.js +1 -1
- package/dist/scripts/src/components-core/loader/PageableLoader.js +4 -4
- package/dist/scripts/src/components-core/{AppRoot.js → rendering/AppContent.js} +60 -145
- package/dist/scripts/src/components-core/rendering/AppRoot.js +55 -0
- package/dist/scripts/src/components-core/rendering/AppWrapper.js +44 -0
- package/dist/scripts/src/components-core/{ComponentBed.js → rendering/ComponentAdapter.js} +8 -8
- package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +147 -0
- package/dist/scripts/src/components-core/rendering/Container.js +576 -0
- package/dist/scripts/src/components-core/rendering/ContainerWrapper.js +82 -0
- package/dist/scripts/src/components-core/{ErrorBoundary.js → rendering/ErrorBoundary.js} +9 -3
- package/dist/scripts/src/components-core/rendering/StateContainer.js +331 -0
- package/dist/scripts/src/components-core/{container → rendering}/buildProxy.js +11 -7
- package/dist/scripts/src/components-core/{container → rendering}/collectFnVarDeps.js +2 -2
- package/dist/scripts/src/components-core/{container → rendering}/reducer.js +3 -0
- package/dist/scripts/src/components-core/rendering/renderChild.js +81 -0
- package/dist/scripts/src/index.js +3 -6
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +193 -164
- package/dist/scripts/src/syntax/grammar.tmLanguage.json +1 -1
- package/dist/style.css +1 -1
- package/dist/xmlui-metadata.mjs +4216 -4232
- package/dist/xmlui-metadata.umd.js +16 -16
- package/dist/xmlui-standalone.umd.js +262 -290
- package/dist/xmlui.d.ts +36 -61
- package/dist/xmlui.mjs +1 -1
- package/package.json +2 -1
- package/dist/index-BYjaMGrD.mjs +0 -76804
- package/dist/scripts/src/components/BarChart/BarChart.js +0 -49
- package/dist/scripts/src/components/BarChart/BarChartNative.js +0 -176
- package/dist/scripts/src/components/Map/Map.js +0 -75
- package/dist/scripts/src/components/Map/world_countries.json +0 -45307
- package/dist/scripts/src/components/PieChart/PieChart.js +0 -45
- package/dist/scripts/src/components/PieChart/PieChartNative.js +0 -165
- package/dist/scripts/src/components/chart-color-schemes.js +0 -43
- package/dist/scripts/src/components-core/container/Container.js +0 -1186
- package/dist/scripts/src/components-core/container/ContainerComponentDef.js +0 -15
- /package/dist/scripts/src/components-core/{InvalidComponent.js → rendering/InvalidComponent.js} +0 -0
- /package/dist/scripts/src/components-core/{UnknownComponent.js → rendering/UnknownComponent.js} +0 -0
- /package/dist/scripts/src/components-core/{container → rendering}/valueExtractor.js +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rawHtmlComponentRenderer = exports.RawHtmlMd = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ComponentDefs_1 = require("@abstractions/ComponentDefs");
|
|
6
|
+
const renderers_1 = require("@components-core/renderers");
|
|
7
|
+
const RawHtmlNative_1 = require("./RawHtmlNative");
|
|
8
|
+
const COMP = "RawHtml";
|
|
9
|
+
const hostTypesMd = [
|
|
10
|
+
{
|
|
11
|
+
value: "div",
|
|
12
|
+
description: "Use a 'div' as the host element.",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: "span",
|
|
16
|
+
description: "Use a 'span' as the host element.",
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
exports.RawHtmlMd = (0, ComponentDefs_1.createMetadata)({
|
|
20
|
+
status: "experimental",
|
|
21
|
+
description: "This component injects a raw HTML string into the DOM.",
|
|
22
|
+
props: {
|
|
23
|
+
content: (0, ComponentDefs_1.d)("Specifies the raw HTML content to inject"),
|
|
24
|
+
hostElement: (0, ComponentDefs_1.d)("Specifies the host element to inject the content into.", hostTypesMd, "string", "span"),
|
|
25
|
+
},
|
|
26
|
+
events: {},
|
|
27
|
+
apis: {},
|
|
28
|
+
themeVars: [],
|
|
29
|
+
defaultThemeVars: {
|
|
30
|
+
light: {},
|
|
31
|
+
dark: {},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
exports.rawHtmlComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.RawHtmlMd, ({ node, extractValue, renderChild, layoutCss }) => {
|
|
35
|
+
const childText = renderChild(node.children);
|
|
36
|
+
const content = extractValue.asDisplayText(node.props.content) ||
|
|
37
|
+
(typeof childText === "string" ? childText : "");
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(RawHtmlNative_1.RawHtml, { content: content, hostElement: node.props.hostElement, style: layoutCss }));
|
|
39
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawHtml = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const RawHtml = ({ content, hostElement, style }) => {
|
|
6
|
+
if (hostElement === "div") {
|
|
7
|
+
return (0, jsx_runtime_1.jsx)("div", { style: style, dangerouslySetInnerHTML: { __html: content } });
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return (0, jsx_runtime_1.jsx)("span", { style: style, dangerouslySetInnerHTML: { __html: content } });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.RawHtml = RawHtml;
|
|
@@ -13,7 +13,7 @@ const classnames_1 = __importDefault(require("@components-core/utils/classnames"
|
|
|
13
13
|
const react_helmet_async_1 = require("react-helmet-async");
|
|
14
14
|
const react_dom_1 = require("react-dom");
|
|
15
15
|
const constants_1 = require("@components-core/constants");
|
|
16
|
-
const ErrorBoundary_1 = require("@components-core/ErrorBoundary");
|
|
16
|
+
const ErrorBoundary_1 = require("@components-core/rendering/ErrorBoundary");
|
|
17
17
|
const NotificationToast_1 = require("./NotificationToast");
|
|
18
18
|
const themeVars_1 = require("@components-core/theming/themeVars");
|
|
19
19
|
function getClassName(css) {
|
|
@@ -4,7 +4,7 @@ exports.LoaderComponent = LoaderComponent;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const ComponentRegistryContext_1 = require("@components/ComponentRegistryContext");
|
|
6
6
|
const containers_1 = require("./abstractions/containers");
|
|
7
|
-
const valueExtractor_1 = require("@components-core/
|
|
7
|
+
const valueExtractor_1 = require("@components-core/rendering/valueExtractor");
|
|
8
8
|
const hooks_1 = require("@components-core/utils/hooks");
|
|
9
9
|
function LoaderComponent({ node, state, dispatch, lookupAction, lookupSyncCallback, registerComponentApi, onUnmount, appContext, memoedVarsRef, }) {
|
|
10
10
|
const componentRegistry = (0, ComponentRegistryContext_1.useComponentRegistry)();
|
|
@@ -259,7 +259,7 @@ class RestApiProxy {
|
|
|
259
259
|
method: method,
|
|
260
260
|
headers: aggregatedHeaders,
|
|
261
261
|
signal: abortSignal,
|
|
262
|
-
body: requestBody
|
|
262
|
+
body: requestBody
|
|
263
263
|
};
|
|
264
264
|
if (onUploadProgress) {
|
|
265
265
|
console.log("Falling back to axios. Reason: onUploadProgress specified");
|
|
@@ -17,7 +17,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
17
17
|
const react_1 = require("react");
|
|
18
18
|
const client_1 = __importDefault(require("react-dom/client"));
|
|
19
19
|
require("../index.scss");
|
|
20
|
-
const AppRoot_1 =
|
|
20
|
+
const AppRoot_1 = require("@components-core/rendering/AppRoot");
|
|
21
21
|
const misc_1 = require("@components-core/utils/misc");
|
|
22
22
|
const ApiInterceptorProvider_1 = require("@components-core/interception/ApiInterceptorProvider");
|
|
23
23
|
const constants_1 = require("@components-core/constants");
|
|
@@ -28,6 +28,7 @@ const Parser_1 = require("../parsers/scripting/Parser");
|
|
|
28
28
|
const code_behind_collect_1 = require("../parsers/scripting/code-behind-collect");
|
|
29
29
|
const ComponentProvider_1 = require("@components/ComponentProvider");
|
|
30
30
|
const markup_check_1 = require("@components-core/markup-check");
|
|
31
|
+
const StandaloneExtensionManager_1 = __importDefault(require("./StandaloneExtensionManager"));
|
|
31
32
|
const ThemeProvider_1 = require("@components-core/theming/ThemeProvider");
|
|
32
33
|
const MAIN_FILE = "Main." + fileExtensions_1.componentFileExtension;
|
|
33
34
|
const MAIN_CODE_BEHIND_FILE = "Main." + fileExtensions_1.codeBehindFileExtension;
|
|
@@ -41,15 +42,12 @@ const CONFIG_FILE = "config.json";
|
|
|
41
42
|
* representation); ApiInterceptor can emulate some backend functionality
|
|
42
43
|
* running in the browser.
|
|
43
44
|
*/
|
|
44
|
-
function StandaloneApp({ appDef, decorateComponentsWithTestId, debugEnabled = false, runtime,
|
|
45
|
+
function StandaloneApp({ appDef, decorateComponentsWithTestId, debugEnabled = false, runtime, extensionManager, }) {
|
|
45
46
|
var _a;
|
|
46
|
-
const servedFromSingleFile = (0, react_1.useMemo)(() => {
|
|
47
|
-
return typeof window !== "undefined" && window.location.href.startsWith("file");
|
|
48
|
-
}, []);
|
|
49
47
|
// --- Fetch all files constituting the standalone app, including components,
|
|
50
48
|
// --- themes, and other artifacts. Display the app version numbers in the
|
|
51
49
|
// --- console.
|
|
52
|
-
const standaloneApp = useStandalone(appDef, runtime,
|
|
50
|
+
const standaloneApp = useStandalone(appDef, runtime, extensionManager);
|
|
53
51
|
usePrintVersionNumber(standaloneApp);
|
|
54
52
|
if (!standaloneApp) {
|
|
55
53
|
// --- Problems found, the standalone app cannot run
|
|
@@ -68,11 +66,10 @@ function StandaloneApp({ appDef, decorateComponentsWithTestId, debugEnabled = fa
|
|
|
68
66
|
(typeof window !== "undefined" ? window.XMLUI_MOCK_TEST_ID : false);
|
|
69
67
|
// --- An app can turn off the default hash routing.
|
|
70
68
|
const useHashBasedRouting = (_a = appGlobals === null || appGlobals === void 0 ? void 0 : appGlobals.useHashBasedRouting) !== null && _a !== void 0 ? _a : true;
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(ApiInterceptorProvider_1.ApiInterceptorProvider, { interceptor: mockedApi, useHashBasedRouting: useHashBasedRouting, children: (0, jsx_runtime_1.jsx)(AppRoot_1.
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(ApiInterceptorProvider_1.ApiInterceptorProvider, { interceptor: mockedApi, useHashBasedRouting: useHashBasedRouting, children: (0, jsx_runtime_1.jsx)(AppRoot_1.AppRoot, { decorateComponentsWithTestId: shouldDecorateWithTestId, node: entryPoint, standalone: true, debugEnabled: debugEnabled,
|
|
72
70
|
// @ts-ignore
|
|
73
|
-
routerBaseName: typeof window !== "undefined" ? window.__PUBLIC_PATH || "" : "", globalProps: Object.assign({ name: name }, (appGlobals || {})), defaultTheme: defaultTheme, defaultTone: defaultTone, resources: resources, resourceMap: resourceMap, sources: sources,
|
|
71
|
+
routerBaseName: typeof window !== "undefined" ? window.__PUBLIC_PATH || "" : "", globalProps: Object.assign({ name: name }, (appGlobals || {})), defaultTheme: defaultTheme, defaultTone: defaultTone, resources: resources, resourceMap: resourceMap, sources: sources, extensionManager: extensionManager, contributes: {
|
|
74
72
|
compoundComponents: components,
|
|
75
|
-
components: customComponents,
|
|
76
73
|
themes,
|
|
77
74
|
} }) }));
|
|
78
75
|
}
|
|
@@ -124,6 +121,7 @@ function parseCodeBehindResponse(response) {
|
|
|
124
121
|
parser.parseStatements();
|
|
125
122
|
}
|
|
126
123
|
catch (e) {
|
|
124
|
+
// throw new Error(`Failed to fetch ${response.url}`);
|
|
127
125
|
if (parser.errors.length > 0) {
|
|
128
126
|
return {
|
|
129
127
|
component: (0, xmlui_parser_1.errReportScriptError)(parser.errors[0], response.url),
|
|
@@ -288,7 +286,7 @@ function fetchWithoutCache(url) {
|
|
|
288
286
|
* @returns The prepared StandaloneAppDescription if the collection is
|
|
289
287
|
* successful; otherwise, null.
|
|
290
288
|
*/
|
|
291
|
-
function useStandalone(standaloneAppDef, runtime = constants_1.EMPTY_OBJECT,
|
|
289
|
+
function useStandalone(standaloneAppDef, runtime = constants_1.EMPTY_OBJECT, extensionManager) {
|
|
292
290
|
const [standaloneApp, setStandaloneApp] = (0, react_1.useState)(() => {
|
|
293
291
|
// --- Initialize the standalone app
|
|
294
292
|
const resolvedRuntime = resolveRuntime(runtime);
|
|
@@ -452,7 +450,7 @@ function useStandalone(standaloneAppDef, runtime = constants_1.EMPTY_OBJECT, com
|
|
|
452
450
|
// --- We may have components that are not in the configuration file.
|
|
453
451
|
// --- We need to load them and their code-behinds. First, we collect
|
|
454
452
|
// --- the components to load.
|
|
455
|
-
let componentsToLoad = collectMissingComponents(entryPointWithCodeBehind, componentsWithCodeBehinds, undefined,
|
|
453
|
+
let componentsToLoad = collectMissingComponents(entryPointWithCodeBehind, componentsWithCodeBehinds, undefined, extensionManager);
|
|
456
454
|
// --- Try to load the components referenced in the markup, collect
|
|
457
455
|
// --- those that failed
|
|
458
456
|
const componentsFailedToLoad = new Set();
|
|
@@ -496,7 +494,7 @@ function useStandalone(standaloneAppDef, runtime = constants_1.EMPTY_OBJECT, com
|
|
|
496
494
|
}));
|
|
497
495
|
const componentWrappers = yield Promise.all(componentPromises);
|
|
498
496
|
componentsWithCodeBehinds.push(...componentWrappers.filter((comp) => !!comp));
|
|
499
|
-
componentsToLoad = collectMissingComponents(entryPointWithCodeBehind, componentsWithCodeBehinds, componentsFailedToLoad,
|
|
497
|
+
componentsToLoad = collectMissingComponents(entryPointWithCodeBehind, componentsWithCodeBehinds, componentsFailedToLoad, extensionManager);
|
|
500
498
|
}
|
|
501
499
|
// --- Let's check for errors to display
|
|
502
500
|
const errorComponent = errorComponents.length > 0
|
|
@@ -520,9 +518,9 @@ function useStandalone(standaloneAppDef, runtime = constants_1.EMPTY_OBJECT, com
|
|
|
520
518
|
* @param componentsFailedToLoad The components that failed to load here
|
|
521
519
|
* @returns The components that are still missing
|
|
522
520
|
*/
|
|
523
|
-
function collectMissingComponents(entryPoint, components, componentsFailedToLoad = new Set(),
|
|
521
|
+
function collectMissingComponents(entryPoint, components, componentsFailedToLoad = new Set(), extensionManager) {
|
|
524
522
|
// --- Add the discovered compound components to the registry
|
|
525
|
-
const componentRegistry = new ComponentProvider_1.ComponentRegistry({ compoundComponents: components },
|
|
523
|
+
const componentRegistry = new ComponentProvider_1.ComponentRegistry({ compoundComponents: components }, extensionManager);
|
|
526
524
|
// --- Check the xmlui markup. This check will find all unloaded components
|
|
527
525
|
const result = (0, markup_check_1.checkXmlUiMarkup)(entryPoint, components, {
|
|
528
526
|
getComponentProps: (componentName) => {
|
|
@@ -543,11 +541,12 @@ function collectMissingComponents(entryPoint, components, componentsFailedToLoad
|
|
|
543
541
|
},
|
|
544
542
|
});
|
|
545
543
|
componentRegistry.destroy();
|
|
546
|
-
// --- Collect all missing components.
|
|
544
|
+
// --- Collect all missing components.
|
|
545
|
+
// Omit the components that failed to load and the ones that are not in #app-ns namespace
|
|
547
546
|
return new Set(result
|
|
548
547
|
.filter((r) => r.code === "M001")
|
|
549
|
-
.map((r) => r.args[0])
|
|
550
|
-
.filter((comp) => !componentsFailedToLoad.has(comp)));
|
|
548
|
+
.map((r) => r.args[0].replace("#app-ns.", ""))
|
|
549
|
+
.filter((comp) => !componentsFailedToLoad.has(comp) && !comp.includes(".")));
|
|
551
550
|
}
|
|
552
551
|
// --- This React hook logs the app's version number to the browser's console at startup
|
|
553
552
|
function usePrintVersionNumber(standaloneApp) {
|
|
@@ -573,7 +572,8 @@ let contentRoot = null;
|
|
|
573
572
|
* @param components The related component's runtime representation
|
|
574
573
|
* @returns The content's root element
|
|
575
574
|
*/
|
|
576
|
-
function startApp(runtime,
|
|
575
|
+
function startApp(runtime, extensions = [], extensionManager = new StandaloneExtensionManager_1.default()) {
|
|
576
|
+
extensionManager.registerExtension(extensions);
|
|
577
577
|
let rootElement = document.getElementById("root");
|
|
578
578
|
if (!rootElement) {
|
|
579
579
|
rootElement = document.createElement("div");
|
|
@@ -583,7 +583,7 @@ function startApp(runtime, components, componentManager) {
|
|
|
583
583
|
if (!contentRoot) {
|
|
584
584
|
contentRoot = client_1.default.createRoot(rootElement);
|
|
585
585
|
}
|
|
586
|
-
contentRoot.render((0, jsx_runtime_1.jsx)(StandaloneApp, { runtime: runtime,
|
|
586
|
+
contentRoot.render((0, jsx_runtime_1.jsx)(StandaloneApp, { runtime: runtime, extensionManager: extensionManager }));
|
|
587
587
|
return contentRoot;
|
|
588
588
|
}
|
|
589
589
|
exports.default = StandaloneApp;
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
* the xmlui component registry. The framework resolves the components used
|
|
6
6
|
* in an application markup with this registry.
|
|
7
7
|
*/
|
|
8
|
-
class
|
|
8
|
+
class StandaloneExtensionManager {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.subscriptions = new Set();
|
|
11
|
-
this.
|
|
11
|
+
this.registeredExtensions = [];
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* You can add a callback function invoked whenever a new component is added
|
|
@@ -19,7 +19,7 @@ class StandaloneComponentManager {
|
|
|
19
19
|
*/
|
|
20
20
|
subscribeToRegistrations(cb) {
|
|
21
21
|
this.subscriptions.add(cb);
|
|
22
|
-
this.
|
|
22
|
+
this.registeredExtensions.forEach((component) => {
|
|
23
23
|
cb(component);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -32,20 +32,13 @@ class StandaloneComponentManager {
|
|
|
32
32
|
unSubscribeFromRegistrations(cb) {
|
|
33
33
|
this.subscriptions.delete(cb);
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
* Use this function to add a new component to the registry. Adding a new
|
|
37
|
-
* component will invoke all callbacks that have already subscribed to the
|
|
38
|
-
* component registration.
|
|
39
|
-
* @param component The component to register. You can pass a single
|
|
40
|
-
* component or an array of components.
|
|
41
|
-
*/
|
|
42
|
-
registerComponent(component) {
|
|
35
|
+
registerExtension(component) {
|
|
43
36
|
(Array.isArray(component) ? component : [component]).forEach((component) => {
|
|
44
|
-
this.
|
|
37
|
+
this.registeredExtensions.push(component);
|
|
45
38
|
this.subscriptions.forEach((cb) => {
|
|
46
39
|
cb(component);
|
|
47
40
|
});
|
|
48
41
|
});
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
|
-
exports.default =
|
|
44
|
+
exports.default = StandaloneExtensionManager;
|
|
@@ -180,7 +180,7 @@ function callApi(_a, _b) {
|
|
|
180
180
|
//operation
|
|
181
181
|
headers, url, queryParams, rawBody, method, body, }, { resolveBindingExpressions } = {}) {
|
|
182
182
|
const uid = typeof actionUid === "symbol" ? actionUid : Symbol(actionUid);
|
|
183
|
-
const stateContext = Object.assign(Object.assign({},
|
|
183
|
+
const stateContext = Object.assign(Object.assign({}, state), params);
|
|
184
184
|
if (!(0, extractParam_1.shouldKeep)(when, stateContext, appContext)) {
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
@@ -197,13 +197,13 @@ function PageableLoader({ state, loader, loaderFn, queryId, registerComponentApi
|
|
|
197
197
|
//loader not loaded yet, we skip the update
|
|
198
198
|
return;
|
|
199
199
|
}
|
|
200
|
-
const originalFlatItems = oldData.pages.flatMap((d) => d
|
|
200
|
+
const originalFlatItems = oldData.pages.flatMap((d) => d);
|
|
201
201
|
const draft = (0, immer_1.createDraft)(oldData);
|
|
202
202
|
const flatItems = [];
|
|
203
203
|
for (let i = 0; i < draft.pages.length; i++) {
|
|
204
204
|
const page = draft.pages[i];
|
|
205
|
-
yield updater(page
|
|
206
|
-
flatItems.push(...page
|
|
205
|
+
yield updater(page);
|
|
206
|
+
flatItems.push(...page);
|
|
207
207
|
}
|
|
208
208
|
if (flatItems.length !== originalFlatItems.length) {
|
|
209
209
|
throw new Error("Use this method for update only. If you want to add or delete, call the addItem/deleteItem method.");
|
|
@@ -218,7 +218,7 @@ function PageableLoader({ state, loader, loaderFn, queryId, registerComponentApi
|
|
|
218
218
|
const oldData = (_a = appContext.queryClient) === null || _a === void 0 ? void 0 : _a.getQueryData(queryId);
|
|
219
219
|
const draft = (0, immer_1.createDraft)(oldData);
|
|
220
220
|
if (indexToInsert === undefined) {
|
|
221
|
-
draft.pages[draft.pages.length - 1].
|
|
221
|
+
draft.pages[draft.pages.length - 1].push(element);
|
|
222
222
|
}
|
|
223
223
|
else {
|
|
224
224
|
throw new Error("not implemented");
|
|
@@ -1,108 +1,33 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AppContent = AppContent;
|
|
39
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
40
|
-
const react_1 =
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const AppRoot_1 = require("./AppRoot");
|
|
10
|
+
const DebugViewProvider_1 = require("@components-core/DebugViewProvider");
|
|
11
|
+
const ComponentRegistryContext_1 = require("@components/ComponentRegistryContext");
|
|
41
12
|
const react_router_dom_1 = require("react-router-dom");
|
|
42
|
-
const
|
|
43
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
44
|
-
const lodash_es_1 = require("lodash-es");
|
|
45
|
-
const react_helmet_async_1 = require("react-helmet-async");
|
|
46
|
-
const react_hot_toast_1 = __importDefault(require("react-hot-toast"));
|
|
47
|
-
const immer_1 = require("immer");
|
|
48
|
-
const ErrorBoundary_1 = require("./ErrorBoundary");
|
|
49
|
-
const ThemeProvider_1 = __importDefault(require("@components-core//theming/ThemeProvider"));
|
|
50
|
-
const Container_1 = require("./container/Container");
|
|
51
|
-
const misc_1 = require("@components-core/utils/misc");
|
|
52
|
-
const constants_1 = require("@components-core/constants");
|
|
53
|
-
const IconProvider_1 = require("@components/IconProvider");
|
|
54
|
-
const date_fns_1 = require("date-fns");
|
|
55
|
-
const AppContext_1 = require("@components-core/AppContext");
|
|
56
|
-
const useApiInterceptorContext_1 = require("@components-core/interception/useApiInterceptorContext");
|
|
57
|
-
const themeVars_1 = require("@components-core/theming/themeVars");
|
|
58
|
-
const reportEngineError_1 = require("@components-core/reportEngineError");
|
|
13
|
+
const ConfirmationModalContextProvider_1 = require("@components/ModalDialog/ConfirmationModalContextProvider");
|
|
59
14
|
const ThemeContext_1 = require("@components-core/theming/ThemeContext");
|
|
60
|
-
const
|
|
61
|
-
const misc_utils_1 = require("./appContext/misc-utils");
|
|
62
|
-
const ComponentRegistryContext_1 = require("@components/ComponentRegistryContext");
|
|
15
|
+
const hooks_1 = require("@components-core/utils/hooks");
|
|
63
16
|
const abstractions_1 = require("@components-core/theming/abstractions");
|
|
64
|
-
const
|
|
65
|
-
const
|
|
17
|
+
const themeVars_1 = require("@components-core/theming/themeVars");
|
|
18
|
+
const useApiInterceptorContext_1 = require("@components-core/interception/useApiInterceptorContext");
|
|
19
|
+
const constants_1 = require("@components-core/constants");
|
|
66
20
|
const AppStateContext_1 = require("@components/App/AppStateContext");
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
defaultOptions: {
|
|
78
|
-
queries: {
|
|
79
|
-
refetchOnWindowFocus: false,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
// --- We pass these functions to the global app context
|
|
84
|
-
const DateUtils = {
|
|
85
|
-
differenceInMinutes: (date1, date2) => {
|
|
86
|
-
return (0, date_fns_1.differenceInMinutes)(new Date(date1), new Date(date2));
|
|
87
|
-
},
|
|
88
|
-
isSameDay: (dateLeft, dateRight) => {
|
|
89
|
-
// console.log("IS SAME DAY", dateLeft, dateRight);
|
|
90
|
-
if (!dateLeft || !dateRight) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
return (0, date_fns_1.isSameDay)(new Date(dateLeft), new Date(dateRight));
|
|
94
|
-
},
|
|
95
|
-
isToday: (date) => {
|
|
96
|
-
return (0, date_fns_1.isToday)(new Date(date));
|
|
97
|
-
},
|
|
98
|
-
isThisYear: (date) => {
|
|
99
|
-
return (0, date_fns_1.isThisYear)(new Date(date));
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
// --- We pass this funtion to the global app context
|
|
103
|
-
function signError(error) {
|
|
104
|
-
react_hot_toast_1.default.error(typeof error === "string" ? error : error.message || "Something went wrong");
|
|
105
|
-
}
|
|
21
|
+
const renderChild_1 = require("./renderChild");
|
|
22
|
+
const AppContext_1 = require("@components-core/AppContext");
|
|
23
|
+
const misc_1 = require("@components-core/utils/misc");
|
|
24
|
+
const date_fns_1 = require("date-fns");
|
|
25
|
+
const misc_utils_1 = require("@components-core/appContext/misc-utils");
|
|
26
|
+
const lodash_es_1 = require("lodash-es");
|
|
27
|
+
const react_hot_toast_1 = __importDefault(require("react-hot-toast"));
|
|
28
|
+
const package_json_1 = require("../../../package.json");
|
|
29
|
+
const date_functions_1 = require("@components-core/appContext/date-functions");
|
|
30
|
+
const math_function_1 = require("@components-core/appContext/math-function");
|
|
106
31
|
/**
|
|
107
32
|
* This component wraps the entire app into a container with these particular
|
|
108
33
|
* responsibilities:
|
|
@@ -116,7 +41,7 @@ function AppContent({ rootContainer, routerBaseName, globalProps, standalone, tr
|
|
|
116
41
|
const [loggedInUser, setLoggedInUser] = (0, react_1.useState)(null);
|
|
117
42
|
const debugView = (0, DebugViewProvider_1.useDebugView)();
|
|
118
43
|
const componentRegistry = (0, ComponentRegistryContext_1.useComponentRegistry)();
|
|
119
|
-
const navigate = (0,
|
|
44
|
+
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
120
45
|
const { confirm } = (0, ConfirmationModalContextProvider_1.useConfirm)();
|
|
121
46
|
// --- Prepare theme-related variables. We will use them to manage the selected theme
|
|
122
47
|
// --- and also pass them to the app context.
|
|
@@ -228,9 +153,9 @@ function AppContent({ rootContainer, routerBaseName, globalProps, standalone, tr
|
|
|
228
153
|
const isInIFrame = (0, hooks_1.useIsInIFrame)();
|
|
229
154
|
const isWindowFocused = (0, hooks_1.useIsWindowFocused)();
|
|
230
155
|
const apiInterceptorContext = (0, useApiInterceptorContext_1.useApiInterceptorContext)();
|
|
231
|
-
const location = (0,
|
|
156
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
232
157
|
const lastHash = (0, react_1.useRef)("");
|
|
233
|
-
//
|
|
158
|
+
// --- Listen to location change using useEffect with location as dependency
|
|
234
159
|
// https://jasonwatmore.com/react-router-v6-listen-to-location-route-change-without-history-listen
|
|
235
160
|
(0, react_1.useEffect)(() => {
|
|
236
161
|
if (location.hash) {
|
|
@@ -308,7 +233,7 @@ function AppContent({ rootContainer, routerBaseName, globalProps, standalone, tr
|
|
|
308
233
|
decorateComponentsWithTestId,
|
|
309
234
|
environment,
|
|
310
235
|
mediaSize,
|
|
311
|
-
queryClient,
|
|
236
|
+
queryClient: AppRoot_1.queryClient,
|
|
312
237
|
standalone }, date_functions_1.dateFunctions), math_function_1.mathFunctions), {
|
|
313
238
|
// --- File Utilities
|
|
314
239
|
formatFileSizeInBytes: misc_1.formatFileSizeInBytes,
|
|
@@ -373,52 +298,42 @@ function AppContent({ rootContainer, routerBaseName, globalProps, standalone, tr
|
|
|
373
298
|
update,
|
|
374
299
|
};
|
|
375
300
|
}, [appState, registerAppState, update]);
|
|
376
|
-
const
|
|
377
|
-
|
|
301
|
+
const memoedVarsRef = (0, react_1.useRef)(new Map());
|
|
302
|
+
const renderedRoot = (0, renderChild_1.renderChild)({
|
|
303
|
+
node: rootContainer,
|
|
304
|
+
state: constants_1.EMPTY_OBJECT,
|
|
305
|
+
dispatch: constants_1.noop,
|
|
306
|
+
appContext: undefined,
|
|
307
|
+
lookupAction: constants_1.noop,
|
|
308
|
+
lookupSyncCallback: constants_1.noop,
|
|
309
|
+
registerComponentApi: constants_1.noop,
|
|
310
|
+
renderChild: constants_1.noop,
|
|
311
|
+
statePartChanged: constants_1.noop,
|
|
312
|
+
cleanup: constants_1.noop,
|
|
313
|
+
memoedVarsRef,
|
|
314
|
+
});
|
|
315
|
+
return ((0, jsx_runtime_1.jsx)(AppContext_1.AppContext.Provider, { value: appContextValue, children: (0, jsx_runtime_1.jsx)(AppStateContext_1.AppStateContext.Provider, { value: appStateContextValue, children: renderedRoot }) }));
|
|
378
316
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return ((0, jsx_runtime_1.jsx)(react_1.default.StrictMode, { children: (0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { node: node, location: "root-outer", children: (0, jsx_runtime_1.jsxs)(react_query_1.QueryClientProvider, { client: queryClient, children: [(typeof window === "undefined" || process.env.VITE_REMIX) && dynamicChildren, !(typeof window === "undefined" || process.env.VITE_REMIX) && ((0, jsx_runtime_1.jsx)(Router, { basename: Router === react_router_dom_1.HashRouter ? undefined : baseName, children: dynamicChildren }))] }) }) }));
|
|
317
|
+
// --- We pass these functions to the global app context
|
|
318
|
+
const DateUtils = {
|
|
319
|
+
differenceInMinutes: (date1, date2) => {
|
|
320
|
+
return (0, date_fns_1.differenceInMinutes)(new Date(date1), new Date(date2));
|
|
321
|
+
},
|
|
322
|
+
isSameDay: (dateLeft, dateRight) => {
|
|
323
|
+
// console.log("IS SAME DAY", dateLeft, dateRight);
|
|
324
|
+
if (!dateLeft || !dateRight) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
return (0, date_fns_1.isSameDay)(new Date(dateLeft), new Date(dateRight));
|
|
328
|
+
},
|
|
329
|
+
isToday: (date) => {
|
|
330
|
+
return (0, date_fns_1.isToday)(new Date(date));
|
|
331
|
+
},
|
|
332
|
+
isThisYear: (date) => {
|
|
333
|
+
return (0, date_fns_1.isThisYear)(new Date(date));
|
|
334
|
+
},
|
|
398
335
|
};
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
* component.
|
|
403
|
-
*/
|
|
404
|
-
function AppRoot({ apiInterceptor, contributes, node, decorateComponentsWithTestId, debugEnabled, defaultTheme, defaultTone, resources, globalProps, standalone, trackContainerHeight, routerBaseName, previewMode, servedFromSingleFile, resourceMap, sources, componentManager, }) {
|
|
405
|
-
const rootNode = (0, react_1.useMemo)(() => {
|
|
406
|
-
const themedRoot = node.type === "Theme"
|
|
407
|
-
? Object.assign(Object.assign({}, node), { props: Object.assign(Object.assign({}, node.props), { root: true }) }) : {
|
|
408
|
-
type: "Theme",
|
|
409
|
-
props: {
|
|
410
|
-
root: true,
|
|
411
|
-
},
|
|
412
|
-
children: [node],
|
|
413
|
-
};
|
|
414
|
-
return {
|
|
415
|
-
type: "Container",
|
|
416
|
-
uid: "root",
|
|
417
|
-
children: [themedRoot],
|
|
418
|
-
uses: [],
|
|
419
|
-
};
|
|
420
|
-
}, [node]);
|
|
421
|
-
(0, reportEngineError_1.resetErrors)();
|
|
422
|
-
return ((0, jsx_runtime_1.jsx)(ComponentProvider_1.ComponentProvider, { contributes: contributes, componentManager: componentManager, children: (0, jsx_runtime_1.jsx)(DebugViewProvider_1.DebugViewProvider, { debugConfig: globalProps === null || globalProps === void 0 ? void 0 : globalProps.debug, children: (0, jsx_runtime_1.jsx)(AppWrapper, { resourceMap: resourceMap, apiInterceptor: apiInterceptor, node: rootNode, contributes: contributes, resources: resources, routerBaseName: routerBaseName, decorateComponentsWithTestId: decorateComponentsWithTestId, debugEnabled: debugEnabled, defaultTheme: defaultTheme, defaultTone: defaultTone, globalProps: globalProps, standalone: standalone, trackContainerHeight: trackContainerHeight, previewMode: previewMode, servedFromSingleFile: servedFromSingleFile, sources: sources }) }) }));
|
|
336
|
+
// --- We pass this funtion to the global app context
|
|
337
|
+
function signError(error) {
|
|
338
|
+
react_hot_toast_1.default.error(typeof error === "string" ? error : error.message || "Something went wrong");
|
|
423
339
|
}
|
|
424
|
-
exports.default = AppRoot;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.queryClient = void 0;
|
|
4
|
+
exports.AppRoot = AppRoot;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
8
|
+
const immer_1 = require("immer");
|
|
9
|
+
const reportEngineError_1 = require("@components-core/reportEngineError");
|
|
10
|
+
const ComponentProvider_1 = require("@components/ComponentProvider");
|
|
11
|
+
const DebugViewProvider_1 = require("../DebugViewProvider");
|
|
12
|
+
const AppWrapper_1 = require("./AppWrapper");
|
|
13
|
+
// --- We want to enable the produce method of `immer` on Map objects
|
|
14
|
+
(0, immer_1.enableMapSet)();
|
|
15
|
+
// --- We use this object in the app context to represent the `QlientQuery`
|
|
16
|
+
// --- of the react-query package.
|
|
17
|
+
exports.queryClient = new react_query_1.QueryClient({
|
|
18
|
+
defaultOptions: {
|
|
19
|
+
queries: {
|
|
20
|
+
refetchOnWindowFocus: false,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* This component is responsible for running a pre-compiled xmlui app. It
|
|
26
|
+
* receives the internal representation of the app markup and code (coming
|
|
27
|
+
* from either code-behind files or inlined markup expressions) and executes
|
|
28
|
+
* the app accordingly.
|
|
29
|
+
*/
|
|
30
|
+
function AppRoot({ apiInterceptor, contributes, node, decorateComponentsWithTestId, debugEnabled, defaultTheme, defaultTone, resources, globalProps, standalone, trackContainerHeight, routerBaseName, previewMode, resourceMap, sources, extensionManager, }) {
|
|
31
|
+
// --- Make sure, the root node is wrapped in a `Theme` component. Also,
|
|
32
|
+
// --- the root node must be wrapped in a `Container` component managing
|
|
33
|
+
// --- the app's top-level state.
|
|
34
|
+
const rootNode = (0, react_1.useMemo)(() => {
|
|
35
|
+
const themedRoot = node.type === "Theme"
|
|
36
|
+
? Object.assign(Object.assign({}, node), { props: Object.assign(Object.assign({}, node.props), { root: true }) }) : {
|
|
37
|
+
type: "Theme",
|
|
38
|
+
props: {
|
|
39
|
+
root: true,
|
|
40
|
+
},
|
|
41
|
+
children: [node],
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
type: "Container",
|
|
45
|
+
uid: "root",
|
|
46
|
+
children: [themedRoot],
|
|
47
|
+
uses: [],
|
|
48
|
+
};
|
|
49
|
+
}, [node]);
|
|
50
|
+
// --- Start with an error-free state
|
|
51
|
+
(0, reportEngineError_1.resetErrors)();
|
|
52
|
+
// --- Render the app providing a component registry (in which the engine finds a
|
|
53
|
+
// --- component definition by its name). Ensure the app has a context for debugging.
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(ComponentProvider_1.ComponentProvider, { contributes: contributes, extensionManager: extensionManager, children: (0, jsx_runtime_1.jsx)(DebugViewProvider_1.DebugViewProvider, { debugConfig: globalProps === null || globalProps === void 0 ? void 0 : globalProps.debug, children: (0, jsx_runtime_1.jsx)(AppWrapper_1.AppWrapper, { resourceMap: resourceMap, apiInterceptor: apiInterceptor, node: rootNode, contributes: contributes, resources: resources, routerBaseName: routerBaseName, decorateComponentsWithTestId: decorateComponentsWithTestId, debugEnabled: debugEnabled, defaultTheme: defaultTheme, defaultTone: defaultTone, globalProps: globalProps, standalone: standalone, trackContainerHeight: trackContainerHeight, previewMode: previewMode, sources: sources }) }) }));
|
|
55
|
+
}
|