xmlui 0.7.21 → 0.7.23
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-LRHkKnha.mjs → apiInterceptorWorker-BZ3Gd4mb.mjs} +25 -10
- package/dist/{grammar.tmLanguage-DNepe_jP.mjs → grammar.tmLanguage-JAlHWPqw.mjs} +1 -1
- package/dist/{index-5NLXyjX0.mjs → index-C9zkAour.mjs} +27520 -25814
- package/dist/index.css +1 -1
- package/dist/scripts/bin/build-lib.js +10 -4
- package/dist/scripts/bin/build.js +1 -4
- package/dist/scripts/bin/index.js +7 -7
- package/dist/scripts/bin/preview.js +19 -2
- package/dist/scripts/bin/start.js +2 -4
- package/dist/scripts/bin/viteConfig.js +2 -11
- package/dist/scripts/src/abstractions/ComponentDefs.js +2 -1
- package/dist/scripts/src/components/APICall/APICall.js +3 -3
- package/dist/scripts/src/components/APICall/APICallNative.js +2 -2
- package/dist/scripts/src/components/Accordion/Accordion.js +5 -5
- package/dist/scripts/src/components/Accordion/AccordionContext.js +1 -1
- package/dist/scripts/src/components/Accordion/AccordionItem.js +5 -5
- package/dist/scripts/src/components/Accordion/AccordionItemNative.js +3 -3
- package/dist/scripts/src/components/Accordion/AccordionNative.js +3 -3
- package/dist/scripts/src/components/Alert/Alert.js +4 -4
- package/dist/scripts/src/components/App/App.js +5 -5
- package/dist/scripts/src/components/App/AppNative.js +33 -34
- package/dist/scripts/src/components/App/Sheet.js +4 -4
- package/dist/scripts/src/components/AppHeader/AppHeader.js +6 -6
- package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +9 -9
- package/dist/scripts/src/components/AppState/AppState.js +2 -2
- package/dist/scripts/src/components/AppState/AppStateNative.js +2 -2
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +7 -7
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +29 -31
- package/dist/scripts/src/components/Avatar/Avatar.js +4 -4
- package/dist/scripts/src/components/Avatar/AvatarNative.js +1 -1
- package/dist/scripts/src/components/Backdrop/Backdrop.js +4 -4
- package/dist/scripts/src/components/Badge/Badge.js +5 -5
- package/dist/scripts/src/components/Badge/BadgeNative.js +5 -5
- package/dist/scripts/src/components/Bookmark/Bookmark.js +7 -3
- package/dist/scripts/src/components/Bookmark/BookmarkNative.js +6 -5
- package/dist/scripts/src/components/Breakout/Breakout.js +2 -2
- package/dist/scripts/src/components/Button/Button.js +6 -6
- package/dist/scripts/src/components/Button/ButtonNative.js +3 -3
- package/dist/scripts/src/components/ButtonGroup/ButtonGroup.js +5 -5
- package/dist/scripts/src/components/Card/Card.js +5 -5
- package/dist/scripts/src/components/Card/CardNative.js +7 -7
- package/dist/scripts/src/components/Carousel/Carousel.js +5 -5
- package/dist/scripts/src/components/Carousel/CarouselItem.js +3 -3
- package/dist/scripts/src/components/Carousel/CarouselItemNative.js +3 -3
- package/dist/scripts/src/components/Carousel/CarouselNative.js +6 -6
- package/dist/scripts/src/components/ChangeListener/ChangeListener.js +3 -3
- package/dist/scripts/src/components/ChangeListener/ChangeListenerNative.js +1 -1
- package/dist/scripts/src/components/Checkbox/Checkbox.js +6 -6
- package/dist/scripts/src/components/ColorPicker/ColorPicker.js +46 -0
- package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +54 -0
- package/dist/scripts/src/components/Column/Column.js +2 -2
- package/dist/scripts/src/components/Column/ColumnNative.js +2 -2
- package/dist/scripts/src/components/ComponentProvider.js +191 -97
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +4 -4
- package/dist/scripts/src/components/ContentSeparator/ContentSeparatorNative.js +1 -1
- package/dist/scripts/src/components/DatePicker/DatePicker.js +4 -4
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +18 -19
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +6 -6
- package/dist/scripts/src/components/DropdownMenu/DropdownMenuNative.js +5 -5
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +4 -4
- package/dist/scripts/src/components/EmojiSelector/EmojiSelectorNative.js +1 -1
- package/dist/scripts/src/components/FileInput/FileInput.js +6 -6
- package/dist/scripts/src/components/FileInput/FileInputNative.js +6 -6
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +3 -3
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZoneNative.js +6 -7
- package/dist/scripts/src/components/FlowLayout/FlowLayout.js +8 -6
- package/dist/scripts/src/components/FlowLayout/FlowLayoutNative.js +27 -16
- package/dist/scripts/src/components/Footer/Footer.js +4 -4
- package/dist/scripts/src/components/Footer/FooterNative.js +2 -2
- package/dist/scripts/src/components/Form/Form.js +5 -5
- package/dist/scripts/src/components/Form/FormNative.js +29 -29
- package/dist/scripts/src/components/FormItem/FormItem.js +4 -4
- package/dist/scripts/src/components/FormItem/FormItemNative.js +26 -16
- package/dist/scripts/src/components/FormItem/HelperText.js +3 -3
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +5 -6
- package/dist/scripts/src/components/FormItem/Validations.js +5 -5
- package/dist/scripts/src/components/FormSection/FormSection.js +2 -2
- package/dist/scripts/src/components/Heading/Heading.js +17 -4
- package/dist/scripts/src/components/Heading/HeadingNative.js +25 -14
- package/dist/scripts/src/components/HoverCard/HoverCard.js +3 -3
- package/dist/scripts/src/components/HoverCard/HovercardNative.js +1 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +1208 -19
- package/dist/scripts/src/components/Icon/Icon.js +3 -3
- package/dist/scripts/src/components/Icon/IconNative.js +3 -3
- package/dist/scripts/src/components/IconInfoCard/IconInfoCard.js +5 -4
- package/dist/scripts/src/components/IconProvider.js +49 -49
- package/dist/scripts/src/components/Image/Image.js +4 -4
- package/dist/scripts/src/components/Image/ImageNative.js +2 -2
- package/dist/scripts/src/components/Input/InputAdornment.js +3 -3
- package/dist/scripts/src/components/Items/Items.js +3 -3
- package/dist/scripts/src/components/Link/Link.js +6 -6
- package/dist/scripts/src/components/Link/LinkNative.js +29 -11
- package/dist/scripts/src/components/List/List.js +14 -16
- package/dist/scripts/src/components/List/ListNative.js +193 -223
- package/dist/scripts/src/components/Logo/Logo.js +2 -2
- package/dist/scripts/src/components/Logo/LogoNative.js +2 -2
- package/dist/scripts/src/components/Markdown/Markdown.js +3 -3
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +4 -4
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +5 -5
- package/dist/scripts/src/components/ModalDialog/ModalDialogNative.js +8 -8
- package/dist/scripts/src/components/NavGroup/NavGroup.js +6 -6
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +8 -8
- package/dist/scripts/src/components/NavLink/NavLink.js +5 -5
- package/dist/scripts/src/components/NavLink/NavLinkNative.js +6 -6
- package/dist/scripts/src/components/NavPanel/NavPanel.js +5 -5
- package/dist/scripts/src/components/NavPanel/NavPanelNative.js +6 -6
- package/dist/scripts/src/components/NoResult/NoResult.js +4 -4
- package/dist/scripts/src/components/NoResult/NoResultNative.js +2 -2
- package/dist/scripts/src/components/NumberBox/NumberBox.js +4 -4
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +7 -7
- package/dist/scripts/src/components/OffCanvas/OffCanvas.js +5 -5
- package/dist/scripts/src/components/OffCanvas/OffCanvasNative.js +2 -2
- package/dist/scripts/src/components/Option/Option.js +4 -4
- package/dist/scripts/src/components/PageHeader/PageHeader.js +2 -2
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +2 -2
- package/dist/scripts/src/components/Pages/Pages.js +3 -3
- package/dist/scripts/src/components/Pages/PagesNative.js +2 -2
- package/dist/scripts/src/components/PositionedContainer/PositionedContainer.js +3 -3
- package/dist/scripts/src/components/PositionedContainer/PositionedContainerNative.js +1 -1
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +3 -3
- package/dist/scripts/src/components/ProgressBar/ProgressBarNative.js +1 -1
- package/dist/scripts/src/components/Queue/Queue.js +3 -3
- package/dist/scripts/src/components/Queue/QueueNative.js +5 -5
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +4 -4
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +6 -6
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +2 -2
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapterNative.js +3 -3
- package/dist/scripts/src/components/Redirect/Redirect.js +2 -2
- package/dist/scripts/src/components/Select/Select.js +7 -7
- package/dist/scripts/src/components/Select/SelectNative.js +36 -37
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +2 -2
- package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +2 -2
- package/dist/scripts/src/components/Slider/Slider.js +40 -25
- package/dist/scripts/src/components/Slider/SliderNative.js +98 -3
- package/dist/scripts/src/components/SlotItem.js +2 -2
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +3 -3
- package/dist/scripts/src/components/Spinner/Spinner.js +3 -3
- package/dist/scripts/src/components/Spinner/SpinnerNative.js +3 -4
- package/dist/scripts/src/components/Splitter/Splitter.js +6 -6
- package/dist/scripts/src/components/Splitter/SplitterNative.js +3 -3
- package/dist/scripts/src/components/Stack/Stack.js +6 -6
- package/dist/scripts/src/components/Stack/StackNative.js +3 -3
- package/dist/scripts/src/components/StickyBox/StickyBox.js +3 -3
- package/dist/scripts/src/components/StickyBox/StickyBoxNative.js +1 -1
- package/dist/scripts/src/components/Switch/Switch.js +6 -6
- package/dist/scripts/src/components/Table/Table.js +9 -9
- package/dist/scripts/src/components/Table/TableNative.js +15 -15
- package/dist/scripts/src/components/Table/useRowSelection.js +4 -4
- package/dist/scripts/src/components/TableHeader/TableHeader.js +2 -2
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +7 -5
- package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +29 -24
- package/dist/scripts/src/components/Tabs/TabContext.js +1 -1
- package/dist/scripts/src/components/Tabs/TabItem.js +3 -3
- package/dist/scripts/src/components/Tabs/TabItemNative.js +2 -2
- package/dist/scripts/src/components/Tabs/Tabs.js +5 -5
- package/dist/scripts/src/components/Tabs/TabsNative.js +2 -2
- package/dist/scripts/src/components/Text/Text.js +5 -4
- package/dist/scripts/src/components/Text/TextNative.js +6 -7
- package/dist/scripts/src/components/TextArea/TextArea.js +4 -4
- package/dist/scripts/src/components/TextArea/TextAreaNative.js +6 -6
- package/dist/scripts/src/components/TextBox/TextBox.js +4 -4
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +5 -5
- package/dist/scripts/src/components/Theme/Theme.js +2 -2
- package/dist/scripts/src/components/Theme/ThemeNative.js +7 -7
- package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +11 -11
- package/dist/scripts/src/components/ThemeChanger/ToneChangerButton.js +5 -5
- package/dist/scripts/src/components/Toggle/Toggle.js +4 -4
- package/dist/scripts/src/components/Toolbar/Toolbar.js +2 -2
- package/dist/scripts/src/components/ToolbarButton/ToolbarButton.js +2 -2
- package/dist/scripts/src/components/Tree/TreeComponent.js +4 -4
- package/dist/scripts/src/components/Tree/TreeNative.js +2 -2
- package/dist/scripts/src/components/TrendLabel/TrendLabel.js +2 -2
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +8 -8
- package/dist/scripts/src/components/abstractions.js +6 -2
- package/dist/scripts/src/components/container-helpers.js +2 -2
- package/dist/scripts/src/components-core/CompoundComponent.js +2 -2
- package/dist/scripts/src/components-core/Fragment.js +2 -2
- package/dist/scripts/src/components-core/InspectorContext.js +5 -5
- package/dist/scripts/src/components-core/LoaderComponent.js +6 -3
- package/dist/scripts/src/components-core/RestApiProxy.js +4 -4
- package/dist/scripts/src/components-core/Slot.js +2 -2
- package/dist/scripts/src/components-core/TableOfContentsContext.js +12 -2
- package/dist/scripts/src/components-core/XmluiCodeHighlighter.js +2 -2
- package/dist/scripts/src/components-core/action/APICall.js +10 -10
- package/dist/scripts/src/components-core/action/FileDownloadAction.js +1 -1
- package/dist/scripts/src/components-core/action/FileUploadAction.js +3 -3
- package/dist/scripts/src/components-core/action/NavigateAction.js +1 -1
- package/dist/scripts/src/components-core/action/TimedAction.js +1 -1
- package/dist/scripts/src/components-core/component-hooks.js +2 -2
- package/dist/scripts/src/components-core/descriptorHelper.js +1 -0
- package/dist/scripts/src/components-core/loader/ApiLoader.js +5 -5
- package/dist/scripts/src/components-core/loader/DataLoader.js +18 -10
- package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +5 -5
- package/dist/scripts/src/components-core/loader/Loader.js +3 -3
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +5 -5
- package/dist/scripts/src/components-core/loader/PageableLoader.js +7 -4
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +21 -15
- package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +2 -2
- package/dist/scripts/src/components-core/rendering/Container.js +16 -16
- package/dist/scripts/src/components-core/rendering/ContainerWrapper.js +1 -1
- package/dist/scripts/src/components-core/rendering/InvalidComponent.js +1 -1
- package/dist/scripts/src/components-core/rendering/StateContainer.js +15 -15
- package/dist/scripts/src/components-core/rendering/reducer.js +1 -1
- package/dist/scripts/src/components-core/rendering/renderChild.js +1 -1
- package/dist/scripts/src/components-core/rendering/valueExtractor.js +4 -4
- package/dist/scripts/src/components-core/script-runner/asyncProxy.js +1 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +1 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +1 -1
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +2 -2
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +1 -1
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +3 -3
- package/dist/scripts/src/components-core/script-runner/syncProxy.js +1 -1
- package/dist/scripts/src/components-core/script-runner/visitors.js +1 -1
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +10 -10
- package/dist/scripts/src/components-core/theming/extendThemeUtils.js +1 -1
- package/dist/scripts/src/components-core/theming/layout-resolver.js +356 -0
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +1 -1
- package/dist/scripts/src/components-core/utils/DataLoaderQueryKeyGenerator.js +9 -3
- package/dist/scripts/src/components-core/utils/actionUtils.js +3 -3
- package/dist/scripts/src/components-core/utils/compound-utils.js +1 -1
- package/dist/scripts/src/components-core/utils/css-utils.js +2 -2
- package/dist/scripts/src/components-core/utils/extractParam.js +47 -3
- package/dist/scripts/src/components-core/utils/hooks.js +3 -3
- package/dist/scripts/src/parsers/scripting/modules.js +1 -1
- package/dist/scripts/src/parsers/style-parser/style-compiler.js +6 -2
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +14 -15
- package/dist/scripts/src/syntax/grammar.tmLanguage.json +1 -1
- package/dist/scripts/src/syntax/textMate/xmlui.json +27 -93
- package/dist/style.css +1 -1
- package/dist/xmlui-metadata.mjs +5438 -4508
- package/dist/xmlui-metadata.umd.js +23 -18
- package/dist/xmlui-standalone.umd.js +204 -193
- package/dist/xmlui.d.ts +3 -2
- package/dist/xmlui.mjs +1 -1
- package/package.json +3 -3
- package/dist/scripts/package.json +0 -210
- package/dist/scripts/src/components/Chart/Chart.js +0 -24
- package/dist/scripts/src/components/Chart/ChartNative.js +0 -165
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +0 -116
- package/dist/scripts/src/components/ModalDialog/Dialog.js +0 -20
- package/dist/scripts/src/components/Range/Range.js +0 -56
- package/dist/scripts/src/components/Range/RangeNative.js +0 -8
- package/dist/scripts/src/components/RawHtml/RawHtml.js +0 -39
- package/dist/scripts/src/components/RawHtml/RawHtmlNative.js +0 -13
- package/dist/scripts/src/components-core/StandaloneApp.js +0 -589
- package/dist/scripts/src/components-core/abstractions/standalone.js +0 -2
- package/dist/scripts/src/components-core/appContext/date-functions.js +0 -19
- package/dist/scripts/src/components-core/appContext/math-function.js +0 -27
- package/dist/scripts/src/components-core/appContext/misc-utils.js +0 -13
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +0 -198
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +0 -94
- package/dist/scripts/src/components-core/interception/Backend.js +0 -129
- package/dist/scripts/src/components-core/interception/Errors.js +0 -129
- package/dist/scripts/src/components-core/interception/InMemoryDb.js +0 -41
- package/dist/scripts/src/components-core/interception/IndexedDb.js +0 -205
- package/dist/scripts/src/components-core/interception/ReadonlyCollection.js +0 -145
- package/dist/scripts/src/components-core/interception/abstractions.js +0 -2
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +0 -46
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +0 -9
- package/dist/scripts/src/components-core/markup-check.js +0 -279
- package/dist/scripts/src/components-core/rendering/AppContent.js +0 -339
- package/dist/scripts/src/components-core/rendering/AppRoot.js +0 -55
- package/dist/scripts/src/components-core/rendering/AppWrapper.js +0 -44
- package/dist/scripts/src/components-core/utils/classnames.js +0 -58
- package/dist/scripts/src/components-core/utils/date-utils.js +0 -78
- package/dist/scripts/src/components-core/utils/request-params.js +0 -70
- package/dist/scripts/src/index.js +0 -66
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkXmlUiMarkup = checkXmlUiMarkup;
|
|
4
|
-
exports.visitComponent = visitComponent;
|
|
5
|
-
const ParameterParser_1 = require("./script-runner/ParameterParser");
|
|
6
|
-
const Parser_1 = require("../parsers/scripting/Parser");
|
|
7
|
-
const descriptorHelper_1 = require("./descriptorHelper");
|
|
8
|
-
const abstractions_1 = require("@components/abstractions");
|
|
9
|
-
/**
|
|
10
|
-
* This function checks the XMLUI markup for potential issues. It retrieves
|
|
11
|
-
* a list of errors and warnings.
|
|
12
|
-
* @param rootDef Root component definition
|
|
13
|
-
* @param components Components referenced in the XMLUI markup
|
|
14
|
-
* @param devMode Indicates if the check is performed in development mode
|
|
15
|
-
* @returns List of errors and warnings
|
|
16
|
-
*/
|
|
17
|
-
function checkXmlUiMarkup(rootDef, components, metadataHandler, devMode) {
|
|
18
|
-
const errorsCollected = [];
|
|
19
|
-
// --- Initialize the check
|
|
20
|
-
const continuation = {};
|
|
21
|
-
const componentIdsCollected = new Set();
|
|
22
|
-
const compoundIdsCollected = new Set();
|
|
23
|
-
// --- Visit the root component
|
|
24
|
-
if (rootDef) {
|
|
25
|
-
visitComponent(rootDef, null, componentDefVisitor, continuation, metadataHandler);
|
|
26
|
-
}
|
|
27
|
-
// --- Visit the compound components
|
|
28
|
-
if (!continuation.abort) {
|
|
29
|
-
for (const component of components) {
|
|
30
|
-
// --- Rule: Compound component name must be a valid JavaScript identifier
|
|
31
|
-
if (!isValidIdentifier(component.name)) {
|
|
32
|
-
reportError("M007", "Component", component.name);
|
|
33
|
-
}
|
|
34
|
-
// --- Rule: Compound component name cannot be 'Component'
|
|
35
|
-
if (component.name === "Component") {
|
|
36
|
-
reportError("M008", "Component", component.name);
|
|
37
|
-
}
|
|
38
|
-
// --- Rule: Compound component must not have the name of a registered component
|
|
39
|
-
if (metadataHandler.componentRegistered(component.name)) {
|
|
40
|
-
reportError("M009", "Component", component.name);
|
|
41
|
-
}
|
|
42
|
-
// --- Rule: Compound component name must be unique
|
|
43
|
-
if (compoundIdsCollected.has(component.name)) {
|
|
44
|
-
reportError("M010", "Component", component.name);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
compoundIdsCollected.add(component.name);
|
|
48
|
-
}
|
|
49
|
-
// --- Reset component ID scope
|
|
50
|
-
componentIdsCollected.clear();
|
|
51
|
-
// --- Visit the compount component's definition
|
|
52
|
-
visitComponent(component.component, null, componentDefVisitor, continuation, metadataHandler);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// --- Done.
|
|
56
|
-
return errorsCollected;
|
|
57
|
-
// --- This visitor checks the rules for a particular component
|
|
58
|
-
function componentDefVisitor(def, parent, before, continuation) {
|
|
59
|
-
var _a, _b, _c, _d, _e;
|
|
60
|
-
// --- This is the visitor function to check a ComponentDef markup
|
|
61
|
-
if (!before) {
|
|
62
|
-
// --- Do not visit the component definition after its children have been visited
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
// --- Rule: Component name must be registered
|
|
66
|
-
if (!metadataHandler.componentRegistered(def.type)) {
|
|
67
|
-
reportError("M001", (_a = parent === null || parent === void 0 ? void 0 : parent.type) !== null && _a !== void 0 ? _a : "Root", def.type);
|
|
68
|
-
// continuation.cancel = true;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
// --- Rule: an ID must be a valid JavaScript identifier
|
|
72
|
-
if (def.uid) {
|
|
73
|
-
if (!isValidIdentifier(def.uid)) {
|
|
74
|
-
reportError("M002", def.type, def.type, def.uid);
|
|
75
|
-
}
|
|
76
|
-
else if (componentIdsCollected.has(def.uid)) {
|
|
77
|
-
reportError("M003", def.type, def.uid);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
componentIdsCollected.add(def.uid);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// --- Check all props of the component
|
|
84
|
-
const propDescriptors = (_b = metadataHandler.getComponentProps(def.type)) !== null && _b !== void 0 ? _b : {};
|
|
85
|
-
const currentProps = (_c = def.props) !== null && _c !== void 0 ? _c : {};
|
|
86
|
-
for (const propName of Object.keys(currentProps)) {
|
|
87
|
-
const propDescriptor = propDescriptors[propName];
|
|
88
|
-
// --- Rule: The property must be defined in the component descriptor or be a layout option
|
|
89
|
-
// --- or the component must accept arbitrary properties
|
|
90
|
-
if (propDescriptor) {
|
|
91
|
-
// --- The property has a descriptor, so it is allowed.
|
|
92
|
-
// --- Rule: The property value must be parseable
|
|
93
|
-
const propValue = currentProps[propName];
|
|
94
|
-
if (typeof propValue === "string") {
|
|
95
|
-
try {
|
|
96
|
-
(0, ParameterParser_1.parseParameterString)(propValue);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
reportError("M006", def.type, propName, error.message);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
// --- The property has no descriptor.
|
|
105
|
-
const propParts = propName.split("-");
|
|
106
|
-
// --- Check for a layout property
|
|
107
|
-
const validProp =
|
|
108
|
-
// --- Layout property
|
|
109
|
-
(propParts.length === 1 && descriptorHelper_1.layoutOptionKeys.includes(propName)) ||
|
|
110
|
-
// --- Layout property with viewport size
|
|
111
|
-
(propParts.length === 2 &&
|
|
112
|
-
descriptorHelper_1.layoutOptionKeys.includes(propParts[0]) &&
|
|
113
|
-
abstractions_1.viewportSizeNames.includes(propParts[1])) ||
|
|
114
|
-
// --- Arbitrary property is allowed
|
|
115
|
-
metadataHandler.acceptArbitraryProps(def.type);
|
|
116
|
-
if (!validProp) {
|
|
117
|
-
// --- The component does not accept arbitrary properties and
|
|
118
|
-
// --- the property is not a layout option
|
|
119
|
-
reportError("M005", def.type, def.type, propName);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// --- Check all events of the component
|
|
124
|
-
const eventDescriptors = (_d = metadataHandler.getComponentEvents(def.type)) !== null && _d !== void 0 ? _d : {};
|
|
125
|
-
const currentEvents = (_e = def.events) !== null && _e !== void 0 ? _e : {};
|
|
126
|
-
for (const eventName of Object.keys(currentEvents)) {
|
|
127
|
-
const eventDescriptor = eventDescriptors[eventName];
|
|
128
|
-
// --- Rule: The event must be defined in the component descriptor
|
|
129
|
-
if (eventDescriptor) {
|
|
130
|
-
// --- The event has a descriptor, so it is allowed.
|
|
131
|
-
const eventValue = currentEvents[eventName];
|
|
132
|
-
if (typeof eventValue === "string") {
|
|
133
|
-
// --- Rule: The event value must be parseable
|
|
134
|
-
const parser = new Parser_1.Parser(eventValue);
|
|
135
|
-
try {
|
|
136
|
-
parser.parseStatements();
|
|
137
|
-
if (parser.errors.length > 0) {
|
|
138
|
-
reportError("M012", def.type, eventName, parser.errors[0].text);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
reportError("M012", def.type, eventName, error.message);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
reportError("M011", def.type, def.type, eventName);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
// --- Check the component validator
|
|
151
|
-
const componentValidator = metadataHandler.getComponentValidator(def.type);
|
|
152
|
-
if (componentValidator) {
|
|
153
|
-
const validationErrors = componentValidator(def, devMode);
|
|
154
|
-
if (validationErrors) {
|
|
155
|
-
if (Array.isArray(validationErrors)) {
|
|
156
|
-
for (const error of validationErrors) {
|
|
157
|
-
reportError("M013", def.type, error);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
reportError("M013", def.type, validationErrors);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Checks if a string is a valid JavaScript identifier.
|
|
168
|
-
* @param identifier The string to check.
|
|
169
|
-
* @returns True if the string is a valid identifier, false otherwise.
|
|
170
|
-
*/
|
|
171
|
-
function isValidIdentifier(identifier) {
|
|
172
|
-
const identifierRegex = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
173
|
-
return identifierRegex.test(identifier);
|
|
174
|
-
}
|
|
175
|
-
function reportError(code, name, ...args) {
|
|
176
|
-
_reportError(code, name, false, ...args);
|
|
177
|
-
}
|
|
178
|
-
function reportWarning(code, name, ...args) {
|
|
179
|
-
_reportError(code, name, true, ...args);
|
|
180
|
-
}
|
|
181
|
-
function _reportError(code, name, isWarning, ...args) {
|
|
182
|
-
var _a;
|
|
183
|
-
let errorText = (_a = errorMessages[code]) !== null && _a !== void 0 ? _a : "Unkonwn error";
|
|
184
|
-
if (args) {
|
|
185
|
-
args.forEach((a, idx) => (errorText = replace(errorText, `{${idx}}`, args[idx].toString())));
|
|
186
|
-
}
|
|
187
|
-
errorsCollected.push({ name, code, message: errorText, isWarning, args });
|
|
188
|
-
function replace(input, placeholder, replacement) {
|
|
189
|
-
do {
|
|
190
|
-
input = input.replace(placeholder, replacement);
|
|
191
|
-
} while (input.includes(placeholder));
|
|
192
|
-
return input;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
// --- This function visits a component, its nested components and children
|
|
197
|
-
function visitComponent(def, parent, visitor, continuation = {}, metadataHandler) {
|
|
198
|
-
var _a, _b, _c, _d;
|
|
199
|
-
// --- Visit the component (before)
|
|
200
|
-
visitor(def, parent, true, continuation);
|
|
201
|
-
if (continuation.abort || continuation.cancel) {
|
|
202
|
-
// --- Stop the visit
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
// --- Visit the properties with "ComponentDef" value
|
|
206
|
-
const propDescriptors = (_a = metadataHandler.getComponentProps(def.type)) !== null && _a !== void 0 ? _a : {};
|
|
207
|
-
const currentProps = (_b = def.props) !== null && _b !== void 0 ? _b : {};
|
|
208
|
-
for (const propName of Object.keys(currentProps)) {
|
|
209
|
-
const propDescriptor = propDescriptors[propName];
|
|
210
|
-
if (!propDescriptor) {
|
|
211
|
-
// --- No descriptor for the property, skip it
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
const propValue = currentProps[propName];
|
|
215
|
-
if (propDescriptor.type === "ComponentDef" && propValue.type) {
|
|
216
|
-
// --- This property holds a nested component, visit it
|
|
217
|
-
visitComponent(propValue, def, visitor, continuation, metadataHandler);
|
|
218
|
-
if (continuation.abort || continuation.cancel) {
|
|
219
|
-
// --- Stop the visit
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
// --- Visit events with nested components
|
|
225
|
-
const eventDescriptors = (_c = metadataHandler.getComponentEvents(def.type)) !== null && _c !== void 0 ? _c : {};
|
|
226
|
-
const currentEvents = (_d = def.events) !== null && _d !== void 0 ? _d : {};
|
|
227
|
-
for (const eventName of Object.keys(currentEvents)) {
|
|
228
|
-
const eventDescriptor = eventDescriptors[eventName];
|
|
229
|
-
if (!eventDescriptor) {
|
|
230
|
-
// --- No descriptor for the events, skip it
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
const eventValue = currentEvents[eventName];
|
|
234
|
-
if (typeof eventValue === "object" && eventValue.type) {
|
|
235
|
-
// --- This event holds a nested component, visit it
|
|
236
|
-
visitComponent(eventValue, def, visitor, continuation, metadataHandler);
|
|
237
|
-
if (continuation.abort) {
|
|
238
|
-
// --- Stop visiting this component
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (continuation.cancel) {
|
|
242
|
-
// --- Skip the remaining items
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
// --- Visit the component children
|
|
248
|
-
if (def.children) {
|
|
249
|
-
for (const child of def.children) {
|
|
250
|
-
visitComponent(child, def, visitor, continuation, metadataHandler);
|
|
251
|
-
if (continuation.abort) {
|
|
252
|
-
// --- Stop visiting this component
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
if (continuation.cancel) {
|
|
256
|
-
// --- Skip the remaining items
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
// --- Visit the component (after)
|
|
262
|
-
visitor(def, undefined, false, continuation);
|
|
263
|
-
}
|
|
264
|
-
// --- The error messages of error codes
|
|
265
|
-
const errorMessages = {
|
|
266
|
-
M001: "The component '{0}' is not registered",
|
|
267
|
-
M002: "The '{0}' element has an invalid id: '{1}'",
|
|
268
|
-
M003: "Invalid component identifier: '{0}'",
|
|
269
|
-
M004: "Duplicated component identifier: '{0}'",
|
|
270
|
-
M005: "The '{0}' element has an invalid property: '{1}'",
|
|
271
|
-
M006: "Parsing property value of '{0}' failed: {1}",
|
|
272
|
-
M007: "The name of a reusable component is invalid: '{0}'",
|
|
273
|
-
M008: "The name of a reusable component must not be '{0}', as it is a reserved name",
|
|
274
|
-
M009: "A reusable component cannot have the name of a registered component: '{0}'",
|
|
275
|
-
M010: "Duplicated reusable component name: '{0}'",
|
|
276
|
-
M011: "The '{0}' element has an invalid event: '{1}'",
|
|
277
|
-
M012: "Parsing event value of '{0}' failed: {1}",
|
|
278
|
-
M013: "Component validation failed: '{0}'",
|
|
279
|
-
};
|
|
@@ -1,339 +0,0 @@
|
|
|
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.AppContent = AppContent;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
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");
|
|
12
|
-
const react_router_dom_1 = require("react-router-dom");
|
|
13
|
-
const ConfirmationModalContextProvider_1 = require("@components/ModalDialog/ConfirmationModalContextProvider");
|
|
14
|
-
const ThemeContext_1 = require("@components-core/theming/ThemeContext");
|
|
15
|
-
const hooks_1 = require("@components-core/utils/hooks");
|
|
16
|
-
const abstractions_1 = require("@components-core/theming/abstractions");
|
|
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");
|
|
20
|
-
const AppStateContext_1 = require("@components/App/AppStateContext");
|
|
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");
|
|
31
|
-
/**
|
|
32
|
-
* This component wraps the entire app into a container with these particular
|
|
33
|
-
* responsibilities:
|
|
34
|
-
* - Managing the application state
|
|
35
|
-
* - Helping the app with viewport-related functionality (e.g., information
|
|
36
|
-
* of viewport size, supporting responsive apps)
|
|
37
|
-
* - Providing xmlui-defined methods and properties for apps, such as
|
|
38
|
-
* `activeThemeId`, `navigate`, `toast`, and many others.
|
|
39
|
-
*/
|
|
40
|
-
function AppContent({ rootContainer, routerBaseName, globalProps, standalone, trackContainerHeight, decorateComponentsWithTestId, debugEnabled, }) {
|
|
41
|
-
const [loggedInUser, setLoggedInUser] = (0, react_1.useState)(null);
|
|
42
|
-
const debugView = (0, DebugViewProvider_1.useDebugView)();
|
|
43
|
-
const componentRegistry = (0, ComponentRegistryContext_1.useComponentRegistry)();
|
|
44
|
-
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
45
|
-
const { confirm } = (0, ConfirmationModalContextProvider_1.useConfirm)();
|
|
46
|
-
// --- Prepare theme-related variables. We will use them to manage the selected theme
|
|
47
|
-
// --- and also pass them to the app context.
|
|
48
|
-
const { activeThemeId, activeThemeTone, setActiveThemeId, setActiveThemeTone, availableThemeIds, root, toggleThemeTone, } = (0, ThemeContext_1.useThemes)();
|
|
49
|
-
// --- Handle special key combinations to change the theme and tone
|
|
50
|
-
(0, hooks_1.useDocumentKeydown)((event) => {
|
|
51
|
-
// --- Alt + Ctrl + Shift + T changes the current theme
|
|
52
|
-
if (event.code === "KeyT" && event.altKey && event.ctrlKey && event.shiftKey) {
|
|
53
|
-
setActiveThemeId(availableThemeIds[(availableThemeIds.indexOf(activeThemeId) + 1) % availableThemeIds.length]);
|
|
54
|
-
}
|
|
55
|
-
// --- Alt + Ctrl + Shift + O changes the current theme tone
|
|
56
|
-
if (event.code === "KeyO" && event.altKey && event.ctrlKey && event.shiftKey) {
|
|
57
|
-
setActiveThemeTone(abstractions_1.ThemeToneKeys[(abstractions_1.ThemeToneKeys.indexOf(activeThemeTone) + 1) % abstractions_1.ThemeToneKeys.length]);
|
|
58
|
-
}
|
|
59
|
-
// --- Alt + Ctrl + Shift + S toggles the current state view
|
|
60
|
-
if (event.code === "KeyS" && event.altKey && event.ctrlKey && event.shiftKey) {
|
|
61
|
-
debugView.setDisplayStateView(!debugView.displayStateView);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
// --- We use the state variables to store the current media query values
|
|
65
|
-
const [maxWidthPhone, setMaxWidthPhone] = (0, react_1.useState)("0");
|
|
66
|
-
const [maxWidthPhoneLower, setMaxWidthPhoneLower] = (0, react_1.useState)("0");
|
|
67
|
-
const [maxWidthLandscapePhone, setMaxWidthLandscapePhone] = (0, react_1.useState)("0");
|
|
68
|
-
const [maxWidthLandscapePhoneLower, setMaxWidthLandscapePhoneLower] = (0, react_1.useState)("0");
|
|
69
|
-
const [maxWidthTablet, setMaxWidthTablet] = (0, react_1.useState)("0");
|
|
70
|
-
const [maxWidthTabletLower, setMaxWidthTabletLower] = (0, react_1.useState)("0");
|
|
71
|
-
const [maxWidthDesktop, setMaxWidthDesktop] = (0, react_1.useState)("0");
|
|
72
|
-
const [maxWidthDesktopLower, setMaxWidthDesktopLower] = (0, react_1.useState)("0");
|
|
73
|
-
const [maxWidthLargeDesktop, setMaxWidthLargeDesktop] = (0, react_1.useState)("0");
|
|
74
|
-
const [maxWidthLargeDesktopLower, setMaxWidthLargeDesktopLower] = (0, react_1.useState)("0");
|
|
75
|
-
// --- We create a lower dimension value for the media query using a range
|
|
76
|
-
const createLowerDimensionValue = (dimension) => {
|
|
77
|
-
const match = dimension.match(/^(\d+)px$/);
|
|
78
|
-
return match ? `${parseInt(match[1]) - 0.02}px` : "0";
|
|
79
|
-
};
|
|
80
|
-
// --- Whenever the size of the viewport changes, we update the values
|
|
81
|
-
// --- related to viewport size
|
|
82
|
-
const observer = (0, react_1.useRef)();
|
|
83
|
-
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
84
|
-
if (trackContainerHeight) {
|
|
85
|
-
if (root && root !== document.body) {
|
|
86
|
-
// --- We are already observing old element
|
|
87
|
-
if (observer === null || observer === void 0 ? void 0 : observer.current) {
|
|
88
|
-
observer.current.unobserve(root);
|
|
89
|
-
}
|
|
90
|
-
observer.current = new ResizeObserver((entries) => {
|
|
91
|
-
root.style.setProperty("--containerHeight", entries[0].contentRect.height + "px");
|
|
92
|
-
});
|
|
93
|
-
if (observer.current) {
|
|
94
|
-
observer.current.observe(root);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return () => {
|
|
99
|
-
if (observer === null || observer === void 0 ? void 0 : observer.current) {
|
|
100
|
-
observer.current.unobserve(root);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}, [root, observer, trackContainerHeight]);
|
|
104
|
-
// --- Whenever the application root DOM object or the active theme changes, we sync
|
|
105
|
-
// --- with the theme variable values (because we can't use css var in media queries)
|
|
106
|
-
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
107
|
-
const mwPhone = getComputedStyle(root).getPropertyValue((0, themeVars_1.getVarKey)("media-max-width-phone"));
|
|
108
|
-
setMaxWidthPhone(mwPhone);
|
|
109
|
-
setMaxWidthPhoneLower(createLowerDimensionValue(mwPhone));
|
|
110
|
-
const mwLandscapePhone = getComputedStyle(root).getPropertyValue((0, themeVars_1.getVarKey)("media-max-width-landscape-phone"));
|
|
111
|
-
setMaxWidthLandscapePhone(mwLandscapePhone);
|
|
112
|
-
setMaxWidthLandscapePhoneLower(createLowerDimensionValue(mwLandscapePhone));
|
|
113
|
-
const mwTablet = getComputedStyle(root).getPropertyValue((0, themeVars_1.getVarKey)("media-max-width-tablet"));
|
|
114
|
-
setMaxWidthTablet(mwTablet);
|
|
115
|
-
setMaxWidthTabletLower(createLowerDimensionValue(mwTablet));
|
|
116
|
-
const mwDesktop = getComputedStyle(root).getPropertyValue((0, themeVars_1.getVarKey)("media-max-width-desktop"));
|
|
117
|
-
setMaxWidthDesktop(mwDesktop);
|
|
118
|
-
setMaxWidthDesktopLower(createLowerDimensionValue(mwDesktop));
|
|
119
|
-
const mwLargeDesktop = getComputedStyle(root).getPropertyValue((0, themeVars_1.getVarKey)("media-max-width-large-desktop"));
|
|
120
|
-
setMaxWidthLargeDesktop(mwLargeDesktop);
|
|
121
|
-
setMaxWidthLargeDesktopLower(createLowerDimensionValue(mwLargeDesktop));
|
|
122
|
-
}, [activeThemeId, root]);
|
|
123
|
-
// --- Set viewport size information
|
|
124
|
-
const isViewportPhone = (0, hooks_1.useMediaQuery)(`(max-width: ${maxWidthPhoneLower})`);
|
|
125
|
-
const isViewportLandscapePhone = (0, hooks_1.useMediaQuery)(`(min-width: ${maxWidthPhone}) and (max-width: ${maxWidthLandscapePhoneLower})`);
|
|
126
|
-
const isViewportTablet = (0, hooks_1.useMediaQuery)(`(min-width: ${maxWidthLandscapePhone}) and (max-width: ${maxWidthTabletLower})`);
|
|
127
|
-
const isViewportDesktop = (0, hooks_1.useMediaQuery)(`(min-width: ${maxWidthTablet}) and (max-width: ${maxWidthDesktopLower})`);
|
|
128
|
-
const isViewportLargeDesktop = (0, hooks_1.useMediaQuery)(`(min-width: ${maxWidthDesktop}) and (max-width: ${maxWidthLargeDesktopLower})`);
|
|
129
|
-
let vpSize = "xs";
|
|
130
|
-
let vpSizeIndex = 0;
|
|
131
|
-
const isViewportXlDesktop = (0, hooks_1.useMediaQuery)(`(min-width: ${maxWidthLargeDesktop})`);
|
|
132
|
-
if (isViewportXlDesktop) {
|
|
133
|
-
vpSize = "xxl";
|
|
134
|
-
vpSizeIndex = 5;
|
|
135
|
-
}
|
|
136
|
-
else if (isViewportLargeDesktop) {
|
|
137
|
-
vpSize = "xl";
|
|
138
|
-
vpSizeIndex = 4;
|
|
139
|
-
}
|
|
140
|
-
else if (isViewportDesktop) {
|
|
141
|
-
vpSize = "lg";
|
|
142
|
-
vpSizeIndex = 3;
|
|
143
|
-
}
|
|
144
|
-
else if (isViewportTablet) {
|
|
145
|
-
vpSize = "md";
|
|
146
|
-
vpSizeIndex = 2;
|
|
147
|
-
}
|
|
148
|
-
else if (isViewportLandscapePhone) {
|
|
149
|
-
vpSize = "sm";
|
|
150
|
-
vpSizeIndex = 1;
|
|
151
|
-
}
|
|
152
|
-
// --- Collect information about the current environment
|
|
153
|
-
const isInIFrame = (0, hooks_1.useIsInIFrame)();
|
|
154
|
-
const isWindowFocused = (0, hooks_1.useIsWindowFocused)();
|
|
155
|
-
const apiInterceptorContext = (0, useApiInterceptorContext_1.useApiInterceptorContext)();
|
|
156
|
-
const location = (0, react_router_dom_1.useLocation)();
|
|
157
|
-
const lastHash = (0, react_1.useRef)("");
|
|
158
|
-
// --- Listen to location change using useEffect with location as dependency
|
|
159
|
-
// https://jasonwatmore.com/react-router-v6-listen-to-location-route-change-without-history-listen
|
|
160
|
-
(0, react_1.useEffect)(() => {
|
|
161
|
-
if (location.hash) {
|
|
162
|
-
lastHash.current = location.hash.slice(1); // safe hash for further use after navigation
|
|
163
|
-
}
|
|
164
|
-
if (lastHash.current) {
|
|
165
|
-
setTimeout(() => {
|
|
166
|
-
var _a;
|
|
167
|
-
(_a = document
|
|
168
|
-
.getElementById(lastHash.current)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: "instant", block: "start" });
|
|
169
|
-
lastHash.current = "";
|
|
170
|
-
}, 100);
|
|
171
|
-
}
|
|
172
|
-
}, [location]);
|
|
173
|
-
// --- We collect all the actions defined in the app and pass them to the app context
|
|
174
|
-
const Actions = (0, react_1.useMemo)(() => {
|
|
175
|
-
const ret = {
|
|
176
|
-
_SUPPORT_IMPLICIT_CONTEXT: true,
|
|
177
|
-
};
|
|
178
|
-
for (const [key, value] of componentRegistry.actionFunctions) {
|
|
179
|
-
ret[key] = value;
|
|
180
|
-
}
|
|
181
|
-
return ret;
|
|
182
|
-
}, [componentRegistry.actionFunctions]);
|
|
183
|
-
// --- We collect information about app embedding and pass it to the app context
|
|
184
|
-
const embed = (0, react_1.useMemo)(() => {
|
|
185
|
-
return {
|
|
186
|
-
isInIFrame: isInIFrame,
|
|
187
|
-
};
|
|
188
|
-
}, [isInIFrame]);
|
|
189
|
-
// --- We collect information about the current environment and pass it to the app context
|
|
190
|
-
const environment = (0, react_1.useMemo)(() => {
|
|
191
|
-
return {
|
|
192
|
-
isWindowFocused,
|
|
193
|
-
};
|
|
194
|
-
}, [isWindowFocused]);
|
|
195
|
-
// --- We collect information about the current media size and pass it to the app context
|
|
196
|
-
const mediaSize = (0, react_1.useMemo)(() => {
|
|
197
|
-
return {
|
|
198
|
-
phone: isViewportPhone,
|
|
199
|
-
landscapePhone: isViewportLandscapePhone,
|
|
200
|
-
tablet: isViewportTablet,
|
|
201
|
-
desktop: isViewportDesktop,
|
|
202
|
-
largeDesktop: isViewportLargeDesktop,
|
|
203
|
-
xlDesktop: isViewportXlDesktop,
|
|
204
|
-
smallScreen: isViewportPhone || isViewportLandscapePhone || isViewportTablet,
|
|
205
|
-
largeScreen: !(isViewportPhone || isViewportLandscapePhone || isViewportTablet),
|
|
206
|
-
size: vpSize,
|
|
207
|
-
sizeIndex: vpSizeIndex,
|
|
208
|
-
};
|
|
209
|
-
}, [
|
|
210
|
-
isViewportPhone,
|
|
211
|
-
isViewportLandscapePhone,
|
|
212
|
-
isViewportTablet,
|
|
213
|
-
isViewportDesktop,
|
|
214
|
-
isViewportLargeDesktop,
|
|
215
|
-
isViewportXlDesktop,
|
|
216
|
-
vpSize,
|
|
217
|
-
vpSizeIndex,
|
|
218
|
-
]);
|
|
219
|
-
// --- We extract the global properties from the app configuration and pass them to the app context
|
|
220
|
-
const appGlobals = (0, react_1.useMemo)(() => {
|
|
221
|
-
return globalProps ? Object.assign({}, globalProps) : constants_1.EMPTY_OBJECT;
|
|
222
|
-
}, [globalProps]);
|
|
223
|
-
// --- We assemble the app context object form the collected information
|
|
224
|
-
const appContextValue = (0, react_1.useMemo)(() => {
|
|
225
|
-
const ret = Object.assign(Object.assign(Object.assign(Object.assign({
|
|
226
|
-
// --- Engine-related
|
|
227
|
-
version: package_json_1.version,
|
|
228
|
-
// --- Actions namespace
|
|
229
|
-
Actions,
|
|
230
|
-
// --- App-specific
|
|
231
|
-
appGlobals,
|
|
232
|
-
debugEnabled,
|
|
233
|
-
decorateComponentsWithTestId,
|
|
234
|
-
environment,
|
|
235
|
-
mediaSize,
|
|
236
|
-
queryClient: AppRoot_1.queryClient,
|
|
237
|
-
standalone }, date_functions_1.dateFunctions), math_function_1.mathFunctions), {
|
|
238
|
-
// --- File Utilities
|
|
239
|
-
formatFileSizeInBytes: misc_1.formatFileSizeInBytes,
|
|
240
|
-
getFileExtension: misc_1.getFileExtension,
|
|
241
|
-
// --- Navigation-related
|
|
242
|
-
navigate,
|
|
243
|
-
routerBaseName,
|
|
244
|
-
// --- Notifications and dialogs
|
|
245
|
-
confirm,
|
|
246
|
-
signError,
|
|
247
|
-
toast: react_hot_toast_1.default,
|
|
248
|
-
// --- Theme-related
|
|
249
|
-
activeThemeId,
|
|
250
|
-
activeThemeTone,
|
|
251
|
-
availableThemeIds, setTheme: setActiveThemeId, setThemeTone: setActiveThemeTone, toggleThemeTone,
|
|
252
|
-
// --- User-related
|
|
253
|
-
loggedInUser,
|
|
254
|
-
setLoggedInUser,
|
|
255
|
-
delay: misc_1.delay,
|
|
256
|
-
DateUtils,
|
|
257
|
-
embed,
|
|
258
|
-
apiInterceptorContext, getPropertyByPath: lodash_es_1.get }), misc_utils_1.miscellaneousUtils);
|
|
259
|
-
return ret;
|
|
260
|
-
}, [
|
|
261
|
-
Actions,
|
|
262
|
-
activeThemeId,
|
|
263
|
-
activeThemeTone,
|
|
264
|
-
apiInterceptorContext,
|
|
265
|
-
availableThemeIds,
|
|
266
|
-
confirm,
|
|
267
|
-
debugEnabled,
|
|
268
|
-
decorateComponentsWithTestId,
|
|
269
|
-
embed,
|
|
270
|
-
environment,
|
|
271
|
-
appGlobals,
|
|
272
|
-
loggedInUser,
|
|
273
|
-
mediaSize,
|
|
274
|
-
navigate,
|
|
275
|
-
routerBaseName,
|
|
276
|
-
setActiveThemeId,
|
|
277
|
-
setActiveThemeTone,
|
|
278
|
-
toggleThemeTone,
|
|
279
|
-
standalone,
|
|
280
|
-
]);
|
|
281
|
-
// --- We prepare the helper infrastructure for the `AppState` component, which manages
|
|
282
|
-
// --- app-wide state using buckets (state sections).
|
|
283
|
-
const [appState, setAppState] = (0, react_1.useState)(constants_1.EMPTY_OBJECT);
|
|
284
|
-
const registerAppState = (0, react_1.useCallback)((bucket, initialValue) => {
|
|
285
|
-
setAppState((prev) => {
|
|
286
|
-
return Object.assign(Object.assign({}, prev), { [bucket]: initialValue });
|
|
287
|
-
});
|
|
288
|
-
}, []);
|
|
289
|
-
const update = (0, react_1.useCallback)((bucket, patch) => {
|
|
290
|
-
setAppState((prev) => {
|
|
291
|
-
return Object.assign(Object.assign({}, prev), { [bucket]: Object.assign(Object.assign({}, (prev[bucket] || {})), patch) });
|
|
292
|
-
});
|
|
293
|
-
}, []);
|
|
294
|
-
const appStateContextValue = (0, react_1.useMemo)(() => {
|
|
295
|
-
return {
|
|
296
|
-
registerAppState,
|
|
297
|
-
appState,
|
|
298
|
-
update,
|
|
299
|
-
};
|
|
300
|
-
}, [appState, registerAppState, update]);
|
|
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 }) }));
|
|
316
|
-
}
|
|
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
|
-
},
|
|
335
|
-
};
|
|
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");
|
|
339
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
}
|