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.
Files changed (58) hide show
  1. package/dist/{apiInterceptorWorker-D3L7dpSV.mjs → apiInterceptorWorker-LRHkKnha.mjs} +1 -1
  2. package/dist/{grammar.tmLanguage-69iP6c5d.mjs → grammar.tmLanguage-DNepe_jP.mjs} +1 -1
  3. package/dist/index-5NLXyjX0.mjs +31055 -0
  4. package/dist/index.css +1 -1
  5. package/dist/scripts/bin/build-lib.js +1 -1
  6. package/dist/scripts/bin/index.js +2 -2
  7. package/dist/scripts/bin/start.js +23 -6
  8. package/dist/scripts/bin/viteConfig.js +1 -0
  9. package/dist/scripts/package.json +2 -1
  10. package/dist/scripts/src/abstractions/ExtensionDefs.js +2 -0
  11. package/dist/scripts/src/components/ComponentProvider.js +171 -148
  12. package/dist/scripts/src/components/FormItem/FormItemNative.js +1 -1
  13. package/dist/scripts/src/components/HtmlTags/HtmlTags.js +33 -0
  14. package/dist/scripts/src/components/RawHtml/RawHtml.js +39 -0
  15. package/dist/scripts/src/components/RawHtml/RawHtmlNative.js +13 -0
  16. package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
  17. package/dist/scripts/src/components-core/LoaderComponent.js +1 -1
  18. package/dist/scripts/src/components-core/RestApiProxy.js +1 -1
  19. package/dist/scripts/src/components-core/StandaloneApp.js +19 -19
  20. package/dist/scripts/src/components-core/{StandaloneComponentManager.js → StandaloneExtensionManager.js} +6 -13
  21. package/dist/scripts/src/components-core/action/APICall.js +1 -1
  22. package/dist/scripts/src/components-core/loader/PageableLoader.js +4 -4
  23. package/dist/scripts/src/components-core/{AppRoot.js → rendering/AppContent.js} +60 -145
  24. package/dist/scripts/src/components-core/rendering/AppRoot.js +55 -0
  25. package/dist/scripts/src/components-core/rendering/AppWrapper.js +44 -0
  26. package/dist/scripts/src/components-core/{ComponentBed.js → rendering/ComponentAdapter.js} +8 -8
  27. package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +147 -0
  28. package/dist/scripts/src/components-core/rendering/Container.js +576 -0
  29. package/dist/scripts/src/components-core/rendering/ContainerWrapper.js +82 -0
  30. package/dist/scripts/src/components-core/{ErrorBoundary.js → rendering/ErrorBoundary.js} +9 -3
  31. package/dist/scripts/src/components-core/rendering/StateContainer.js +331 -0
  32. package/dist/scripts/src/components-core/{container → rendering}/buildProxy.js +11 -7
  33. package/dist/scripts/src/components-core/{container → rendering}/collectFnVarDeps.js +2 -2
  34. package/dist/scripts/src/components-core/{container → rendering}/reducer.js +3 -0
  35. package/dist/scripts/src/components-core/rendering/renderChild.js +81 -0
  36. package/dist/scripts/src/index.js +3 -6
  37. package/dist/scripts/src/parsers/xmlui-parser/transform.js +193 -164
  38. package/dist/scripts/src/syntax/grammar.tmLanguage.json +1 -1
  39. package/dist/style.css +1 -1
  40. package/dist/xmlui-metadata.mjs +4216 -4232
  41. package/dist/xmlui-metadata.umd.js +16 -16
  42. package/dist/xmlui-standalone.umd.js +262 -290
  43. package/dist/xmlui.d.ts +36 -61
  44. package/dist/xmlui.mjs +1 -1
  45. package/package.json +2 -1
  46. package/dist/index-BYjaMGrD.mjs +0 -76804
  47. package/dist/scripts/src/components/BarChart/BarChart.js +0 -49
  48. package/dist/scripts/src/components/BarChart/BarChartNative.js +0 -176
  49. package/dist/scripts/src/components/Map/Map.js +0 -75
  50. package/dist/scripts/src/components/Map/world_countries.json +0 -45307
  51. package/dist/scripts/src/components/PieChart/PieChart.js +0 -45
  52. package/dist/scripts/src/components/PieChart/PieChartNative.js +0 -165
  53. package/dist/scripts/src/components/chart-color-schemes.js +0 -43
  54. package/dist/scripts/src/components-core/container/Container.js +0 -1186
  55. package/dist/scripts/src/components-core/container/ContainerComponentDef.js +0 -15
  56. /package/dist/scripts/src/components-core/{InvalidComponent.js → rendering/InvalidComponent.js} +0 -0
  57. /package/dist/scripts/src/components-core/{UnknownComponent.js → rendering/UnknownComponent.js} +0 -0
  58. /package/dist/scripts/src/components-core/{container → rendering}/valueExtractor.js +0 -0
@@ -0,0 +1,44 @@
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.AppWrapper = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const AppRoot_1 = require("./AppRoot");
9
+ const constants_1 = require("@components-core/constants");
10
+ const react_helmet_async_1 = require("react-helmet-async");
11
+ const IconProvider_1 = require("@components/IconProvider");
12
+ const ThemeProvider_1 = __importDefault(require("@components-core/theming/ThemeProvider"));
13
+ const InspectorContext_1 = require("@components-core/InspectorContext");
14
+ const ConfirmationModalContextProvider_1 = require("@components/ModalDialog/ConfirmationModalContextProvider");
15
+ const AppContent_1 = require("./AppContent");
16
+ const react_router_dom_1 = require("react-router-dom");
17
+ const react_1 = __importDefault(require("react"));
18
+ const ErrorBoundary_1 = require("./ErrorBoundary");
19
+ const react_query_1 = require("@tanstack/react-query");
20
+ /**
21
+ * This component wraps the application into other layers of (nested) components
22
+ * that provide app functionality and services requiring unique interaction with
23
+ * the browser or the React environment.
24
+ */
25
+ const AppWrapper = ({ node, previewMode = false, routerBaseName: baseName = "", contributes = constants_1.EMPTY_OBJECT, globalProps, standalone, trackContainerHeight, decorateComponentsWithTestId, debugEnabled, defaultTheme, defaultTone, resources, resourceMap, sources, }) => {
26
+ var _a;
27
+ if (previewMode) {
28
+ // --- Prevent leaking the meta items to the parent document,
29
+ // --- if it lives in an iframe (e.g. docs)
30
+ react_helmet_async_1.HelmetProvider.canUseDOM = false;
31
+ }
32
+ // --- Set a few default properties
33
+ const siteName = (globalProps === null || globalProps === void 0 ? void 0 : globalProps.name) || "XMLUI app";
34
+ const useHashBasedRouting = (_a = globalProps === null || globalProps === void 0 ? void 0 : globalProps.useHashBasedRouting) !== null && _a !== void 0 ? _a : true;
35
+ // --- The children of the AppWrapper component are the components that
36
+ // --- provide the app functionality and services. These components are
37
+ // --- wrapped in other components that provide the necessary environment
38
+ // --- for the app to run.
39
+ const dynamicChildren = ((0, jsx_runtime_1.jsxs)(react_helmet_async_1.HelmetProvider, { children: [(0, jsx_runtime_1.jsx)(react_helmet_async_1.Helmet, { defaultTitle: siteName, titleTemplate: `%s | ${siteName}` }), (0, jsx_runtime_1.jsx)(IconProvider_1.IconProvider, { children: (0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { resourceMap: resourceMap, themes: contributes.themes, defaultTheme: defaultTheme, defaultTone: defaultTone, resources: resources, children: (0, jsx_runtime_1.jsx)(InspectorContext_1.InspectorProvider, { sources: sources, children: (0, jsx_runtime_1.jsx)(ConfirmationModalContextProvider_1.ConfirmationModalContextProvider, { children: (0, jsx_runtime_1.jsx)(AppContent_1.AppContent, { rootContainer: node, routerBaseName: baseName, globalProps: globalProps, standalone: standalone, trackContainerHeight: trackContainerHeight, decorateComponentsWithTestId: decorateComponentsWithTestId, debugEnabled: debugEnabled }) }) }) }) })] }));
40
+ // --- Select the router type for the app
41
+ const Router = previewMode ? react_router_dom_1.MemoryRouter : useHashBasedRouting ? react_router_dom_1.HashRouter : react_router_dom_1.BrowserRouter;
42
+ 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: AppRoot_1.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 }))] }) }) }));
43
+ };
44
+ exports.AppWrapper = AppWrapper;
@@ -52,22 +52,22 @@ const react_1 = __importStar(require("react"));
52
52
  const UnknownComponent_1 = __importDefault(require("./UnknownComponent"));
53
53
  const InvalidComponent_1 = __importDefault(require("./InvalidComponent"));
54
54
  const lodash_es_1 = require("lodash-es");
55
- const extractParam_1 = require("./utils/extractParam");
55
+ const extractParam_1 = require("../utils/extractParam");
56
56
  const ThemeContext_1 = require("@components-core/theming/ThemeContext");
57
57
  const mergeProps_1 = require("@components-core/utils/mergeProps");
58
58
  const ComponentDecorator_1 = __importDefault(require("@components-core/ComponentDecorator"));
59
- const valueExtractor_1 = require("@components-core/container/valueExtractor");
59
+ const valueExtractor_1 = require("@components-core/rendering/valueExtractor");
60
60
  const constants_1 = require("@components-core/constants");
61
61
  const ComponentRegistryContext_1 = require("@components/ComponentRegistryContext");
62
62
  const react_compose_refs_1 = require("@radix-ui/react-compose-refs");
63
63
  const ApiBoundComponent_1 = require("@components-core/ApiBoundComponent");
64
- const hooks_1 = require("./utils/hooks");
65
- const containers_1 = require("./abstractions/containers");
64
+ const hooks_1 = require("../utils/hooks");
65
+ const containers_1 = require("../abstractions/containers");
66
66
  const InspectorContext_1 = require("@components-core/InspectorContext");
67
67
  const SlotItem_1 = require("@components/SlotItem");
68
68
  const descriptorHelper_1 = require("@components-core/descriptorHelper");
69
- const style_compiler_1 = require("../parsers/style-parser/style-compiler");
70
- const event_handlers_1 = require("./event-handlers");
69
+ const style_compiler_1 = require("../../parsers/style-parser/style-compiler");
70
+ const event_handlers_1 = require("../event-handlers");
71
71
  /**
72
72
  * This component's primary responsibility is to transform a particular component definition
73
73
  * into its React representation using the current rendering context.
@@ -76,7 +76,7 @@ const event_handlers_1 = require("./event-handlers");
76
76
  * current rendering context). The modified version uses a stable reference to the layout context
77
77
  * and provides a cleanup function (`onUnmount`) to call when the component is about to be disposed.
78
78
  */
79
- const ComponentBed = (0, react_1.forwardRef)(function ComponentBed(_a, ref) {
79
+ const ComponentAdapter = (0, react_1.forwardRef)(function ComponentAdapter(_a, ref) {
80
80
  var _b;
81
81
  var { node, state, appContext, dispatch, lookupAction, lookupSyncCallback, renderChild, registerComponentApi, layoutContextRef, parentRenderContext, memoedVarsRef, onUnmount, uidInfoRef } = _a, rest = __rest(_a, ["node", "state", "appContext", "dispatch", "lookupAction", "lookupSyncCallback", "renderChild", "registerComponentApi", "layoutContextRef", "parentRenderContext", "memoedVarsRef", "onUnmount", "uidInfoRef"]);
82
82
  // --- Make sure the component definition has `props` and `events` properties
@@ -327,4 +327,4 @@ function getApiBoundItems(items, ...type) {
327
327
  }
328
328
  return ret;
329
329
  }
330
- exports.default = ComponentBed;
330
+ exports.default = ComponentAdapter;
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ComponentWrapper = void 0;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const react_1 = require("react");
20
+ const ComponentAdapter_1 = __importDefault(require("./ComponentAdapter"));
21
+ const extractParam_1 = require("@components-core/utils/extractParam");
22
+ const ContainerWrapper_1 = require("./ContainerWrapper");
23
+ /**
24
+ * The ComponentNode it the outermost React component wrapping an xmlui component.
25
+ */
26
+ exports.ComponentWrapper = (0, react_1.memo)((0, react_1.forwardRef)(function ComponentWrapper(_a, ref) {
27
+ var _b;
28
+ var { node, resolvedKey, state, dispatch, appContext, lookupAction, lookupSyncCallback, registerComponentApi, renderChild, statePartChanged, layoutContext, parentRenderContext, memoedVarsRef, cleanup, uidInfoRef } = _a, rest = __rest(_a, ["node", "resolvedKey", "state", "dispatch", "appContext", "lookupAction", "lookupSyncCallback", "registerComponentApi", "renderChild", "statePartChanged", "layoutContext", "parentRenderContext", "memoedVarsRef", "cleanup", "uidInfoRef"]);
29
+ // --- We pass the layout context to the child components, so we need to
30
+ // --- make sure that it is stable
31
+ const stableLayoutContext = (0, react_1.useRef)(layoutContext);
32
+ // --- Transform the various data sources within the xmlui component definition
33
+ const nodeWithTransformedLoaders = (0, react_1.useMemo)(() => {
34
+ // --- If we have a DataSource child, we transform it to a loader on the node
35
+ let transformed = transformNodeWithChildDatasource(node);
36
+ transformed = transformNodeWithDataSourceRefProp(transformed, uidInfoRef);
37
+ transformed = transformNodeWithRawDataProp(transformed);
38
+ return transformed;
39
+ }, [node, uidInfoRef]);
40
+ // --- String values in the "data" prop are treated as URLs. This boolean
41
+ // --- indicates whether the "data" prop is a string or not.
42
+ const resolvedDataPropIsString = (0, react_1.useMemo)(() => {
43
+ var _a;
44
+ const resolvedDataProp = (0, extractParam_1.extractParam)(state, (_a = nodeWithTransformedLoaders.props) === null || _a === void 0 ? void 0 : _a.data, appContext, true);
45
+ return typeof resolvedDataProp === "string";
46
+ }, [appContext, (_b = nodeWithTransformedLoaders.props) === null || _b === void 0 ? void 0 : _b.data, state]);
47
+ // --- If the "data" prop is a string, we transform it to a DataSource component
48
+ // --- so that it can be fetched.
49
+ const nodeWithTransformedDatasourceProp = (0, react_1.useMemo)(() => {
50
+ return transformNodeWithDataProp(nodeWithTransformedLoaders, resolvedDataPropIsString, uidInfoRef);
51
+ }, [nodeWithTransformedLoaders, resolvedDataPropIsString, uidInfoRef]);
52
+ if ((0, ContainerWrapper_1.isContainerLike)(nodeWithTransformedDatasourceProp)) {
53
+ // --- This component should be rendered as a container
54
+ return ((0, jsx_runtime_1.jsx)(ContainerWrapper_1.ContainerWrapper, { resolvedKey: resolvedKey, node: nodeWithTransformedDatasourceProp, parentState: state, parentDispatch: dispatch, layoutContextRef: stableLayoutContext, parentRenderContext: parentRenderContext, parentStatePartChanged: statePartChanged, parentRegisterComponentApi: registerComponentApi, uidInfoRef: uidInfoRef, ref: ref }));
55
+ }
56
+ else {
57
+ // --- This component should be rendered as a regular component
58
+ return ((0, jsx_runtime_1.jsx)(ComponentAdapter_1.default, Object.assign({ onUnmount: cleanup, memoedVarsRef: memoedVarsRef, node: nodeWithTransformedDatasourceProp, state: state, dispatch: dispatch, appContext: appContext, lookupAction: lookupAction, lookupSyncCallback: lookupSyncCallback, registerComponentApi: registerComponentApi, renderChild: renderChild, parentRenderContext: parentRenderContext, layoutContextRef: stableLayoutContext, ref: ref, uidInfoRef: uidInfoRef }, rest)));
59
+ }
60
+ }));
61
+ // --- Create a DataLoader component for each DataSource child within the
62
+ // --- xmlui component
63
+ function transformNodeWithChildDatasource(node) {
64
+ var _a;
65
+ let didResolve = false;
66
+ let loaders = node.loaders;
67
+ let children = undefined;
68
+ (_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
69
+ if ((child === null || child === void 0 ? void 0 : child.type) === "DataSource") {
70
+ didResolve = true;
71
+ if (!loaders) {
72
+ loaders = [];
73
+ }
74
+ loaders.push({
75
+ uid: child.uid,
76
+ type: "DataLoader",
77
+ props: child.props,
78
+ events: child.events,
79
+ when: child.when,
80
+ });
81
+ }
82
+ else {
83
+ if (!children) {
84
+ children = [];
85
+ }
86
+ children.push(child);
87
+ }
88
+ });
89
+ // --- Return the transform node with the collected loaders
90
+ // --- (or the original one)
91
+ return didResolve
92
+ ? Object.assign(Object.assign({}, node), { children,
93
+ loaders }) : node;
94
+ }
95
+ // --- Properties may use loaders. We transform all of them to the virtual
96
+ // --- DataSourceRef component type.
97
+ function transformNodeWithDataSourceRefProp(node, uidInfoRef) {
98
+ if (!node.props) {
99
+ return node;
100
+ }
101
+ let ret = Object.assign({}, node);
102
+ let resolved = false;
103
+ Object.entries(node.props).forEach(([key, value]) => {
104
+ let uidInfoForDatasource;
105
+ try {
106
+ uidInfoForDatasource = (0, extractParam_1.extractParam)(uidInfoRef.current, value);
107
+ }
108
+ catch (e) { }
109
+ if ((uidInfoForDatasource === null || uidInfoForDatasource === void 0 ? void 0 : uidInfoForDatasource.type) === "loader") {
110
+ resolved = true;
111
+ ret = Object.assign(Object.assign({}, ret), { props: Object.assign(Object.assign({}, ret.props), { [key]: {
112
+ type: "DataSourceRef",
113
+ uid: uidInfoForDatasource.uid,
114
+ } }) });
115
+ }
116
+ });
117
+ // --- Done
118
+ return resolved ? ret : node;
119
+ }
120
+ // --- If the "data" prop is a string, we transform it to a DataSource component
121
+ function transformNodeWithDataProp(node, resolvedDataPropIsString, uidInfoRef) {
122
+ var _a;
123
+ if (!((_a = node.props) === null || _a === void 0 ? void 0 : _a.__DATA_RESOLVED) &&
124
+ node.props &&
125
+ "data" in node.props &&
126
+ resolvedDataPropIsString) {
127
+ // --- We skip the transformation if the data property is a binding expression
128
+ // --- for a loader value
129
+ if ((0, extractParam_1.extractParam)(uidInfoRef.current, node.props.data) === "loaderValue") {
130
+ return node;
131
+ }
132
+ return Object.assign(Object.assign({}, node), { props: Object.assign(Object.assign({}, node.props), { data: {
133
+ type: "DataSource",
134
+ props: {
135
+ url: node.props.data,
136
+ },
137
+ } }) });
138
+ }
139
+ return node;
140
+ }
141
+ // --- We consider the "raw_data" prop as a resolved data value
142
+ function transformNodeWithRawDataProp(node) {
143
+ if (node.props && "raw_data" in node.props) {
144
+ return Object.assign(Object.assign({}, node), { props: Object.assign(Object.assign({}, node.props), { __DATA_RESOLVED: true, data: node.props.raw_data }) });
145
+ }
146
+ return node;
147
+ }