xmlui 0.4.0
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/Pdf-DeGhSMXe.mjs +19537 -0
- package/dist/Pdf.css +1 -0
- package/dist/apiInterceptorWorker-CwuUhYyc.mjs +9229 -0
- package/dist/array-USo-Szhp.mjs +12 -0
- package/dist/index-C24dkfpd.mjs +1434 -0
- package/dist/index-ao27SnVp.mjs +145185 -0
- package/dist/index.css +1 -0
- package/dist/nivo-bar.es-CWh0ZlxB.mjs +1666 -0
- package/dist/nivo-geo.es-BTqNt5Db.mjs +1579 -0
- package/dist/nivo-legends.es-BuIxHGSU.mjs +6916 -0
- package/dist/nivo-pie.es-BvCBFA0L.mjs +700 -0
- package/dist/react-apexcharts.min-DqWuDOyO.mjs +8881 -0
- package/dist/scripts/bin/bootstrap.js +11 -0
- package/dist/scripts/bin/build.js +256 -0
- package/dist/scripts/bin/index.js +88 -0
- package/dist/scripts/bin/preview.js +27 -0
- package/dist/scripts/bin/start.js +41 -0
- package/dist/scripts/bin/vite-ueml-plugin.js +113 -0
- package/dist/scripts/bin/viteConfig.js +112 -0
- package/dist/scripts/src/abstractions/ActionDefs.js +2 -0
- package/dist/scripts/src/abstractions/AppContextDefs.js +2 -0
- package/dist/scripts/src/abstractions/BlockScope.js +4 -0
- package/dist/scripts/src/abstractions/ComponentDefs.js +2 -0
- package/dist/scripts/src/abstractions/ComponentDescriptorDefs.js +2 -0
- package/dist/scripts/src/abstractions/ContainerDefs.js +2 -0
- package/dist/scripts/src/abstractions/FunctionDefs.js +2 -0
- package/dist/scripts/src/abstractions/RendererDefs.js +2 -0
- package/dist/scripts/src/abstractions/scripting/ScriptParserError.js +2 -0
- package/dist/scripts/src/abstractions/scripting/ScriptingSourceTree.js +2 -0
- package/dist/scripts/src/abstractions/scripting/Token.js +110 -0
- package/dist/scripts/src/components/App/App.js +253 -0
- package/dist/scripts/src/components/App/AppLayoutContext.js +9 -0
- package/dist/scripts/src/components/App/AppStateContext.js +9 -0
- package/dist/scripts/src/components/App/Sheet.js +89 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.js +121 -0
- package/dist/scripts/src/components/AppState/AppState.js +29 -0
- package/dist/scripts/src/components/Avatar/Avatar.js +81 -0
- package/dist/scripts/src/components/Badge/Badge.js +56 -0
- package/dist/scripts/src/components/BarChart/BarChart.js +199 -0
- package/dist/scripts/src/components/Bookmark/Bookmark.js +11 -0
- package/dist/scripts/src/components/Button/Button.js +196 -0
- package/dist/scripts/src/components/Card/Card.js +65 -0
- package/dist/scripts/src/components/ChangeListener/ChangeListener.js +43 -0
- package/dist/scripts/src/components/Chart/Chart.js +158 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.js +43 -0
- package/dist/scripts/src/components/Combobox/Combobox.js +145 -0
- package/dist/scripts/src/components/ComponentProvider.js +357 -0
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +40 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.js +196 -0
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +175 -0
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +56 -0
- package/dist/scripts/src/components/FileInput/FileInput.js +127 -0
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +106 -0
- package/dist/scripts/src/components/FlowLayout/FlowLayout.js +139 -0
- package/dist/scripts/src/components/Footer/Footer.js +42 -0
- package/dist/scripts/src/components/Form/Form.js +320 -0
- package/dist/scripts/src/components/Form/FormContext.js +9 -0
- package/dist/scripts/src/components/Form/formActions.js +86 -0
- package/dist/scripts/src/components/FormItem/FormItem.js +204 -0
- package/dist/scripts/src/components/FormItem/HelperText.js +27 -0
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +39 -0
- package/dist/scripts/src/components/FormItem/Validations.js +346 -0
- package/dist/scripts/src/components/FormSection/FormSection.js +45 -0
- package/dist/scripts/src/components/Heading/Heading.js +206 -0
- package/dist/scripts/src/components/HoverCard/HoverCard.js +45 -0
- package/dist/scripts/src/components/Icon/ApiIcon.js +10 -0
- package/dist/scripts/src/components/Icon/Attach.js +10 -0
- package/dist/scripts/src/components/Icon/Binding.js +11 -0
- package/dist/scripts/src/components/Icon/BoardIcon.js +7 -0
- package/dist/scripts/src/components/Icon/BoxIcon.js +10 -0
- package/dist/scripts/src/components/Icon/CheckIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronLeft.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronRight.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
- package/dist/scripts/src/components/Icon/CodeFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/CodeSandbox.js +10 -0
- package/dist/scripts/src/components/Icon/CompactListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ContentCopyIcon.js +7 -0
- package/dist/scripts/src/components/Icon/DatabaseIcon.js +11 -0
- package/dist/scripts/src/components/Icon/DocFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/DocIcon.js +10 -0
- package/dist/scripts/src/components/Icon/DotMenuHorizontalIcon.js +7 -0
- package/dist/scripts/src/components/Icon/DotMenuIcon.js +7 -0
- package/dist/scripts/src/components/Icon/EmailIcon.js +7 -0
- package/dist/scripts/src/components/Icon/EmptyFolderIcon.js +10 -0
- package/dist/scripts/src/components/Icon/ErrorIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ExpressionIcon.js +10 -0
- package/dist/scripts/src/components/Icon/FillPlusCricleIcon.js +7 -0
- package/dist/scripts/src/components/Icon/FilterIcon.js +10 -0
- package/dist/scripts/src/components/Icon/FolderIcon.js +10 -0
- package/dist/scripts/src/components/Icon/GlobeIcon.js +7 -0
- package/dist/scripts/src/components/Icon/HomeIcon.js +7 -0
- package/dist/scripts/src/components/Icon/HyperLinkIcon.js +7 -0
- package/dist/scripts/src/components/Icon/Icon.js +101 -0
- package/dist/scripts/src/components/Icon/ImageFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/LinkIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/LooseListIcon.js +7 -0
- package/dist/scripts/src/components/Icon/MoonIcon.js +10 -0
- package/dist/scripts/src/components/Icon/MoreOptionsIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PDFIcon.js +10 -0
- package/dist/scripts/src/components/Icon/PenIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PhoneIcon.js +7 -0
- package/dist/scripts/src/components/Icon/PhotoIcon.js +10 -0
- package/dist/scripts/src/components/Icon/PlusIcon.js +7 -0
- package/dist/scripts/src/components/Icon/SearchIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ShareIcon.js +10 -0
- package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
- package/dist/scripts/src/components/Icon/TrashIcon.js +7 -0
- package/dist/scripts/src/components/Icon/TxtIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UnknownFileIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UnlinkIcon.js +10 -0
- package/dist/scripts/src/components/Icon/UserIcon.js +7 -0
- package/dist/scripts/src/components/Icon/WarningIcon.js +7 -0
- package/dist/scripts/src/components/Icon/XlsIcon.js +10 -0
- package/dist/scripts/src/components/IconProvider.js +249 -0
- package/dist/scripts/src/components/IconRegistryContext.js +307 -0
- package/dist/scripts/src/components/Image/Image.js +34 -0
- package/dist/scripts/src/components/Input/InputAdornment.js +14 -0
- package/dist/scripts/src/components/Input/input-abstractions.js +44 -0
- package/dist/scripts/src/components/Items/Items.js +48 -0
- package/dist/scripts/src/components/Link/Link.js +72 -0
- package/dist/scripts/src/components/List/List.js +442 -0
- package/dist/scripts/src/components/Logo/Logo.js +25 -0
- package/dist/scripts/src/components/Map/Map.js +60 -0
- package/dist/scripts/src/components/Map/world_countries.json +45307 -0
- package/dist/scripts/src/components/Markdown/Markdown.js +120 -0
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +106 -0
- package/dist/scripts/src/components/ModalDialog/Dialog.js +20 -0
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +145 -0
- package/dist/scripts/src/components/MultiCombobox/MultiCombobox.js +249 -0
- package/dist/scripts/src/components/MultiSelect/MultiSelect.js +192 -0
- package/dist/scripts/src/components/NavGroup/NavGroup.js +113 -0
- package/dist/scripts/src/components/NavLink/NavLink.js +115 -0
- package/dist/scripts/src/components/NavPanel/NavPanel.js +101 -0
- package/dist/scripts/src/components/NoResult/NoResult.js +39 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.js +373 -0
- package/dist/scripts/src/components/Option/Option.js +41 -0
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +22 -0
- package/dist/scripts/src/components/Pages/Pages.js +74 -0
- package/dist/scripts/src/components/Pdf/LazyPdf.js +44 -0
- package/dist/scripts/src/components/Pdf/Pdf.js +19 -0
- package/dist/scripts/src/components/PieChart/PieChart.js +184 -0
- package/dist/scripts/src/components/PositionedContainer/PositionedContainer.js +29 -0
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +38 -0
- package/dist/scripts/src/components/Queue/Queue.js +286 -0
- package/dist/scripts/src/components/Queue/queueActions.js +87 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +144 -0
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +147 -0
- package/dist/scripts/src/components/Redirect/Redirect.js +10 -0
- package/dist/scripts/src/components/Select/Select.js +139 -0
- package/dist/scripts/src/components/Select/SelectContext.js +45 -0
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +88 -0
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.js +22 -0
- package/dist/scripts/src/components/Spinner/Spinner.js +59 -0
- package/dist/scripts/src/components/Splitter/Splitter.js +205 -0
- package/dist/scripts/src/components/Splitter/utils.js +17 -0
- package/dist/scripts/src/components/Stack/Stack.js +117 -0
- package/dist/scripts/src/components/StickyBox/StickyBox.js +33 -0
- package/dist/scripts/src/components/Switch/Switch.js +50 -0
- package/dist/scripts/src/components/Table/Table.js +499 -0
- package/dist/scripts/src/components/Table/useRowSelection.js +169 -0
- package/dist/scripts/src/components/TableColumnDef/TableColumnDef.js +44 -0
- package/dist/scripts/src/components/TableColumnDef/TableContext.js +12 -0
- package/dist/scripts/src/components/Tabs/Tabs.js +85 -0
- package/dist/scripts/src/components/Text/Text.js +175 -0
- package/dist/scripts/src/components/TextArea/TextArea.js +194 -0
- package/dist/scripts/src/components/TextArea/TextAreaResizable.js +63 -0
- package/dist/scripts/src/components/TextArea/useComposedRef.js +50 -0
- package/dist/scripts/src/components/TextBox/TextBox.js +145 -0
- package/dist/scripts/src/components/Theme/NotificationToast.js +39 -0
- package/dist/scripts/src/components/Theme/Theme.js +153 -0
- package/dist/scripts/src/components/ThemeChanger/ThemeChanger.js +125 -0
- package/dist/scripts/src/components/Toggle/Toggle.js +88 -0
- package/dist/scripts/src/components/Tree/TreeComponent.js +79 -0
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +59 -0
- package/dist/scripts/src/components/ViewComponentRegistryContext.js +34 -0
- package/dist/scripts/src/components/abstractions.js +2 -0
- package/dist/scripts/src/components/chart-color-schemes.js +43 -0
- package/dist/scripts/src/components/component-utils.js +32 -0
- package/dist/scripts/src/components/container-helpers.js +18 -0
- package/dist/scripts/src/components-core/ApiBoundComponent.js +189 -0
- package/dist/scripts/src/components-core/AppContext.js +17 -0
- package/dist/scripts/src/components-core/ChildrenSlot.js +10 -0
- package/dist/scripts/src/components-core/Component.js +280 -0
- package/dist/scripts/src/components-core/ComponentDecorator.js +63 -0
- package/dist/scripts/src/components-core/CompoundComponent.js +132 -0
- package/dist/scripts/src/components-core/EngineError.js +91 -0
- package/dist/scripts/src/components-core/ErrorBoundary.js +58 -0
- package/dist/scripts/src/components-core/Fragment.js +14 -0
- package/dist/scripts/src/components-core/InvalidComponent.js +15 -0
- package/dist/scripts/src/components-core/LoaderComponent.js +78 -0
- package/dist/scripts/src/components-core/RestApiProxy.js +341 -0
- package/dist/scripts/src/components-core/RootComponent.js +272 -0
- package/dist/scripts/src/components-core/RouteContext.js +45 -0
- package/dist/scripts/src/components-core/ScrollContext.js +9 -0
- package/dist/scripts/src/components-core/UnknownComponent.js +15 -0
- package/dist/scripts/src/components-core/abstractions/ComponentRenderer.js +2 -0
- package/dist/scripts/src/components-core/abstractions/LoaderRenderer.js +2 -0
- package/dist/scripts/src/components-core/abstractions/containers.js +18 -0
- package/dist/scripts/src/components-core/abstractions/treeAbstractions.js +2 -0
- package/dist/scripts/src/components-core/action/ApiAction.js +276 -0
- package/dist/scripts/src/components-core/action/DownloadFileAction.js +80 -0
- package/dist/scripts/src/components-core/action/NavigateAction.js +20 -0
- package/dist/scripts/src/components-core/action/TimedAction.js +21 -0
- package/dist/scripts/src/components-core/action/UploadAction.js +88 -0
- package/dist/scripts/src/components-core/action/actions.js +15 -0
- package/dist/scripts/src/components-core/appContext/date-functions.js +19 -0
- package/dist/scripts/src/components-core/appContext/misc-utils.js +12 -0
- package/dist/scripts/src/components-core/component-hooks.js +25 -0
- package/dist/scripts/src/components-core/constants.js +18 -0
- package/dist/scripts/src/components-core/container/Container.js +1110 -0
- package/dist/scripts/src/components-core/container/ContainerComponentDef.js +16 -0
- package/dist/scripts/src/components-core/container/buildProxy.js +54 -0
- package/dist/scripts/src/components-core/container/collectFnVarDeps.js +26 -0
- package/dist/scripts/src/components-core/container/valueExtractor.js +195 -0
- package/dist/scripts/src/components-core/descriptorHelper.js +75 -0
- package/dist/scripts/src/components-core/interception/abstractions.js +2 -0
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +9 -0
- package/dist/scripts/src/components-core/loader/ApiLoader.js +46 -0
- package/dist/scripts/src/components-core/loader/DataLoader.js +160 -0
- package/dist/scripts/src/components-core/loader/ExternalDataLoader.js +52 -0
- package/dist/scripts/src/components-core/loader/Loader.js +115 -0
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +32 -0
- package/dist/scripts/src/components-core/loader/PageableLoader.js +240 -0
- package/dist/scripts/src/components-core/renderers.js +45 -0
- package/dist/scripts/src/components-core/reportEngineError.js +59 -0
- package/dist/scripts/src/components-core/script-runner/BindingTreeEvaluationContext.js +35 -0
- package/dist/scripts/src/components-core/script-runner/ICustomOperations.js +34 -0
- package/dist/scripts/src/components-core/script-runner/LogicalThread.js +2 -0
- package/dist/scripts/src/components-core/script-runner/LoopScope.js +2 -0
- package/dist/scripts/src/components-core/script-runner/ParameterParser.js +117 -0
- package/dist/scripts/src/components-core/script-runner/TryScope.js +2 -0
- package/dist/scripts/src/components-core/script-runner/asyncProxy.js +96 -0
- package/dist/scripts/src/components-core/script-runner/bannedFunctions.js +34 -0
- package/dist/scripts/src/components-core/script-runner/custom-operations-registry.js +40 -0
- package/dist/scripts/src/components-core/script-runner/custom-ui-data.js +40 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +551 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-common.js +498 -0
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +434 -0
- package/dist/scripts/src/components-core/script-runner/modules.js +250 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-async.js +818 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-common.js +193 -0
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +740 -0
- package/dist/scripts/src/components-core/script-runner/statement-queue.js +62 -0
- package/dist/scripts/src/components-core/script-runner/visitors.js +352 -0
- package/dist/scripts/src/components-core/theming/ThemeContext.js +43 -0
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +334 -0
- package/dist/scripts/src/components-core/theming/abstractions.js +11 -0
- package/dist/scripts/src/components-core/theming/extendThemeUtils.js +114 -0
- package/dist/scripts/src/components-core/theming/hvar.js +105 -0
- package/dist/scripts/src/components-core/theming/themeVars.js +62 -0
- package/dist/scripts/src/components-core/theming/themes/base-utils.js +31 -0
- package/dist/scripts/src/components-core/theming/themes/palette.js +53 -0
- package/dist/scripts/src/components-core/theming/themes/root.js +257 -0
- package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
- package/dist/scripts/src/components-core/theming/themes/theme-colors.js +407 -0
- package/dist/scripts/src/components-core/theming/themes/xmlui.js +32 -0
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +286 -0
- package/dist/scripts/src/components-core/utils/DataLoaderQueryKeyGenerator.js +34 -0
- package/dist/scripts/src/components-core/utils/LruCache.js +184 -0
- package/dist/scripts/src/components-core/utils/actionUtils.js +32 -0
- package/dist/scripts/src/components-core/utils/classnames.js +58 -0
- package/dist/scripts/src/components-core/utils/css-utils.js +127 -0
- package/dist/scripts/src/components-core/utils/date-utils.js +78 -0
- package/dist/scripts/src/components-core/utils/extractParam.js +148 -0
- package/dist/scripts/src/components-core/utils/hooks.js +221 -0
- package/dist/scripts/src/components-core/utils/mergeProps.js +45 -0
- package/dist/scripts/src/components-core/utils/misc.js +460 -0
- package/dist/scripts/src/components-core/utils/statementUtils.js +205 -0
- package/dist/scripts/src/components-core/utils/treeUtils.js +48 -0
- package/dist/scripts/src/components-core/xmlui-parser.js +52 -0
- package/dist/scripts/src/parsers/scripting/InputStream.js +59 -0
- package/dist/scripts/src/parsers/scripting/Lexer.js +1028 -0
- package/dist/scripts/src/parsers/scripting/Parser.js +2647 -0
- package/dist/scripts/src/parsers/scripting/ParserError.js +46 -0
- package/dist/scripts/src/parsers/scripting/TokenTrait.js +109 -0
- package/dist/scripts/src/parsers/scripting/code-behind-collect.js +118 -0
- package/dist/scripts/src/parsers/scripting/tree-visitor.js +602 -0
- package/dist/scripts/src/parsers/style-parser/StyleInputStream.js +39 -0
- package/dist/scripts/src/parsers/style-parser/StyleLexer.js +621 -0
- package/dist/scripts/src/parsers/style-parser/StyleParser.js +1000 -0
- package/dist/scripts/src/parsers/style-parser/errors.js +37 -0
- package/dist/scripts/src/parsers/style-parser/source-tree.js +2 -0
- package/dist/scripts/src/parsers/style-parser/style-compiler.js +513 -0
- package/dist/scripts/src/parsers/style-parser/tokens.js +42 -0
- package/dist/scripts/src/parsers/ueml/ParserError.js +54 -0
- package/dist/scripts/src/parsers/ueml/UemlHelper.js +579 -0
- package/dist/scripts/src/parsers/ueml/UemlInputStream.js +59 -0
- package/dist/scripts/src/parsers/ueml/UemlLexer.js +868 -0
- package/dist/scripts/src/parsers/ueml/UemlParser.js +1439 -0
- package/dist/scripts/src/parsers/ueml/UemlToken.js +24 -0
- package/dist/scripts/src/parsers/ueml/fileExtensions.js +6 -0
- package/dist/scripts/src/parsers/ueml/source-tree.js +2 -0
- package/dist/scripts/src/parsers/ueml/ueml-tree.js +2 -0
- package/dist/scripts/src/parsers/xmlui-parser/CharacterCodes.js +136 -0
- package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +100 -0
- package/dist/scripts/src/parsers/xmlui-parser/parser.js +476 -0
- package/dist/scripts/src/parsers/xmlui-parser/scanner.js +415 -0
- package/dist/scripts/src/parsers/xmlui-parser/syntax-kind.js +106 -0
- package/dist/scripts/src/parsers/xmlui-parser/syntax-node.js +2 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +922 -0
- package/dist/scripts/src/parsers/xmlui-parser/utils.js +83 -0
- package/dist/xmlui.es.d.ts +1667 -0
- package/dist/xmlui.es.js +17 -0
- package/dist/xmlui.umd.js +1589 -0
- package/package.json +175 -0
|
@@ -0,0 +1,334 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.useCompiledTheme = useCompiledTheme;
|
|
36
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
37
|
+
const abstractions_1 = require("./abstractions");
|
|
38
|
+
const react_1 = require("react");
|
|
39
|
+
const transformThemeVars_1 = require("./transformThemeVars");
|
|
40
|
+
const misc_1 = require("@components-core/utils/misc");
|
|
41
|
+
const hvar_1 = require("@components-core/theming/hvar");
|
|
42
|
+
const ThemeContext_1 = require("@components-core/theming/ThemeContext");
|
|
43
|
+
const themeVars_1 = __importStar(require("@components-core/theming/themeVars"));
|
|
44
|
+
const constants_1 = require("@components-core/constants");
|
|
45
|
+
const extendThemeUtils_1 = require("@components-core/theming/extendThemeUtils");
|
|
46
|
+
const ViewComponentRegistryContext_1 = require("@components/ViewComponentRegistryContext");
|
|
47
|
+
const xmlui_1 = require("@components-core/theming/themes/xmlui");
|
|
48
|
+
const solid_1 = require("@components-core/theming/themes/solid");
|
|
49
|
+
const hooks_1 = require("@components-core/utils/hooks");
|
|
50
|
+
function useCompiledTheme(activeTheme, activeTone, themes = constants_1.EMPTY_ARRAY, resources = constants_1.EMPTY_OBJECT, resourceMap = constants_1.EMPTY_OBJECT) {
|
|
51
|
+
const componentRegistry = (0, ViewComponentRegistryContext_1.useComponentRegistry)();
|
|
52
|
+
const { componentThemeVars, componentDefaultThemeVars } = componentRegistry;
|
|
53
|
+
const themeDefChain = (0, react_1.useMemo)(() => {
|
|
54
|
+
if (activeTheme) {
|
|
55
|
+
return (0, extendThemeUtils_1.collectThemeChainByExtends)(activeTheme, themes, componentDefaultThemeVars);
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}, [activeTheme, componentDefaultThemeVars, themes]);
|
|
59
|
+
const allResources = (0, react_1.useMemo)(() => {
|
|
60
|
+
let mergedResources = {};
|
|
61
|
+
themeDefChain === null || themeDefChain === void 0 ? void 0 : themeDefChain.forEach((theme) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
mergedResources = Object.assign(Object.assign(Object.assign({}, mergedResources), theme.resources), (_b = (_a = theme.tones) === null || _a === void 0 ? void 0 : _a[activeTone]) === null || _b === void 0 ? void 0 : _b.resources);
|
|
64
|
+
});
|
|
65
|
+
return Object.assign(Object.assign({}, resources), mergedResources);
|
|
66
|
+
}, [themeDefChain, resources, activeTone]);
|
|
67
|
+
const allFonts = (0, react_1.useMemo)(() => {
|
|
68
|
+
const ret = [];
|
|
69
|
+
Object.entries(allResources).forEach(([key, value]) => {
|
|
70
|
+
if (key.startsWith("font.")) {
|
|
71
|
+
ret === null || ret === void 0 ? void 0 : ret.push(value);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return ret;
|
|
75
|
+
}, [allResources]);
|
|
76
|
+
const getResourceUrl = (0, react_1.useCallback)((resourceString) => {
|
|
77
|
+
let resourceUrl = resourceString;
|
|
78
|
+
if (resourceString === null || resourceString === void 0 ? void 0 : resourceString.startsWith("resource:")) {
|
|
79
|
+
const resourceName = resourceString === null || resourceString === void 0 ? void 0 : resourceString.replace("resource:", "");
|
|
80
|
+
resourceUrl = allResources[resourceName];
|
|
81
|
+
}
|
|
82
|
+
if (!resourceUrl) {
|
|
83
|
+
return resourceUrl;
|
|
84
|
+
}
|
|
85
|
+
if (resourceMap[resourceUrl]) {
|
|
86
|
+
return resourceMap[resourceUrl];
|
|
87
|
+
}
|
|
88
|
+
if (resourceUrl.startsWith("/") &&
|
|
89
|
+
resourceMap[resourceUrl.substring(1)]) {
|
|
90
|
+
return resourceMap[resourceUrl.substring(1)];
|
|
91
|
+
}
|
|
92
|
+
return (0, misc_1.normalizePath)(resourceUrl);
|
|
93
|
+
}, [allResources, resourceMap]);
|
|
94
|
+
const fontLinks = (0, react_1.useMemo)(() => {
|
|
95
|
+
return ((allFonts === null || allFonts === void 0 ? void 0 : allFonts.filter((theme) => typeof theme === "string")) ||
|
|
96
|
+
[]);
|
|
97
|
+
}, [allFonts]);
|
|
98
|
+
const themeDefChainVars = (0, react_1.useMemo)(() => {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
if (!(themeDefChain === null || themeDefChain === void 0 ? void 0 : themeDefChain.length)) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
let mergedThemeVars = {};
|
|
104
|
+
themeDefChain === null || themeDefChain === void 0 ? void 0 : themeDefChain.forEach((theme) => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
mergedThemeVars = Object.assign(Object.assign(Object.assign({}, mergedThemeVars), theme.themeVars), (_b = (_a = theme.tones) === null || _a === void 0 ? void 0 : _a[activeTone]) === null || _b === void 0 ? void 0 : _b.themeVars);
|
|
107
|
+
});
|
|
108
|
+
//we put the generated theme vars before the last item in the chain
|
|
109
|
+
return [
|
|
110
|
+
...themeDefChain
|
|
111
|
+
.map((themeDef) => {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
return (Object.assign(Object.assign({}, themeDef.themeVars), (_b = (_a = themeDef.tones) === null || _a === void 0 ? void 0 : _a[activeTone]) === null || _b === void 0 ? void 0 : _b.themeVars));
|
|
114
|
+
})
|
|
115
|
+
.slice(0, themeDefChain.length - 1),
|
|
116
|
+
Object.assign(Object.assign(Object.assign(Object.assign({}, (0, transformThemeVars_1.generateBaseSpacings)(mergedThemeVars)), (0, transformThemeVars_1.generateBaseFontSizes)(mergedThemeVars)), (0, transformThemeVars_1.generateBaseTones)(mergedThemeVars)), (0, transformThemeVars_1.generateButtonTones)(mergedThemeVars)),
|
|
117
|
+
Object.assign({}, (0, extendThemeUtils_1.expandTheme)(Object.assign(Object.assign({}, themeDefChain[themeDefChain.length - 1].themeVars), (_b = (_a = themeDefChain[themeDefChain.length - 1].tones) === null || _a === void 0 ? void 0 : _a[activeTone]) === null || _b === void 0 ? void 0 : _b.themeVars))) || {},
|
|
118
|
+
];
|
|
119
|
+
}, [activeTone, themeDefChain]);
|
|
120
|
+
const allThemeVarsWithResolvedHierarchicalVars = (0, react_1.useMemo)(() => {
|
|
121
|
+
let mergedThemeVars = {};
|
|
122
|
+
themeDefChainVars === null || themeDefChainVars === void 0 ? void 0 : themeDefChainVars.forEach((theme) => {
|
|
123
|
+
mergedThemeVars = Object.assign(Object.assign({}, mergedThemeVars), theme);
|
|
124
|
+
});
|
|
125
|
+
const resolvedThemeVarsFromChains = {};
|
|
126
|
+
new Set([
|
|
127
|
+
...Object.keys(themeVars_1.default.themeVars),
|
|
128
|
+
...componentThemeVars,
|
|
129
|
+
]).forEach((themeVar) => {
|
|
130
|
+
const result = (0, hvar_1.matchThemeVar)(themeVar, themeDefChainVars);
|
|
131
|
+
if (result &&
|
|
132
|
+
result.forValue &&
|
|
133
|
+
result.matchedValue &&
|
|
134
|
+
result.forValue !== result.matchedValue) {
|
|
135
|
+
resolvedThemeVarsFromChains[result.forValue] = `$${result.matchedValue}`;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return resolveThemeVarsWithCssVars(Object.assign(Object.assign({}, mergedThemeVars), resolvedThemeVarsFromChains));
|
|
139
|
+
}, [componentThemeVars, themeDefChainVars]);
|
|
140
|
+
const themeCssVars = (0, react_1.useMemo)(() => {
|
|
141
|
+
const ret = {};
|
|
142
|
+
Object.entries(allThemeVarsWithResolvedHierarchicalVars).forEach(([key, value]) => {
|
|
143
|
+
const themeKey = `--${themeVars_1.default.keyPrefix}-${key}`;
|
|
144
|
+
if (value) {
|
|
145
|
+
ret[themeKey] = value;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
return ret;
|
|
149
|
+
}, [allThemeVarsWithResolvedHierarchicalVars]);
|
|
150
|
+
const getThemeVar = (0, react_1.useCallback)((varName) => {
|
|
151
|
+
return (0, transformThemeVars_1.resolveThemeVar)(varName, allThemeVarsWithResolvedHierarchicalVars);
|
|
152
|
+
}, [allThemeVarsWithResolvedHierarchicalVars]);
|
|
153
|
+
(0, react_1.useEffect)(() => {
|
|
154
|
+
allFonts.forEach((font) => __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
if (typeof font !== "string") {
|
|
156
|
+
const resolvedSrc = getResourceUrl(font.src);
|
|
157
|
+
let src = `url(${resolvedSrc})`;
|
|
158
|
+
if (font.format) {
|
|
159
|
+
src = `${src} format('${font.format}')`;
|
|
160
|
+
}
|
|
161
|
+
const ff = new FontFace(font.fontFamily, src, {
|
|
162
|
+
weight: font.fontWeight,
|
|
163
|
+
style: font.fontStyle,
|
|
164
|
+
display: font.fontDisplay,
|
|
165
|
+
});
|
|
166
|
+
try {
|
|
167
|
+
const loadedFontFace = yield ff.load();
|
|
168
|
+
document.fonts.add(loadedFontFace);
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
console.error("loading fonts failed", e);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}));
|
|
175
|
+
}, [themeDefChain, getResourceUrl, allFonts]);
|
|
176
|
+
return {
|
|
177
|
+
getResourceUrl,
|
|
178
|
+
fontLinks,
|
|
179
|
+
allThemeVarsWithResolvedHierarchicalVars,
|
|
180
|
+
themeCssVars,
|
|
181
|
+
getThemeVar,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const builtInThemes = [
|
|
185
|
+
xmlui_1.XmlUiThemeDefinition,
|
|
186
|
+
xmlui_1.XmlUiBlueThemeDefinition,
|
|
187
|
+
xmlui_1.XmlUiGreenThemeDefinition,
|
|
188
|
+
xmlui_1.XmlUiGrayThemeDefinition,
|
|
189
|
+
xmlui_1.XmlUiOrangeThemeDefinition,
|
|
190
|
+
xmlui_1.XmlUiPurpleThemeDefinition,
|
|
191
|
+
solid_1.SolidThemeDefinition,
|
|
192
|
+
];
|
|
193
|
+
// theme-overriding properties change.
|
|
194
|
+
function ThemeProvider({ children, themes: custThemes = constants_1.EMPTY_ARRAY, defaultTheme = "xmlui", defaultTone = "light", resources = constants_1.EMPTY_OBJECT, resourceMap = constants_1.EMPTY_OBJECT, }) {
|
|
195
|
+
const [activeThemeTone, setActiveThemeTone] = (0, react_1.useState)(() => {
|
|
196
|
+
if (!defaultTone) {
|
|
197
|
+
return abstractions_1.ThemeToneKeys[0];
|
|
198
|
+
}
|
|
199
|
+
return defaultTone;
|
|
200
|
+
});
|
|
201
|
+
const themes = (0, react_1.useMemo)(() => {
|
|
202
|
+
return [...builtInThemes, ...custThemes];
|
|
203
|
+
}, [custThemes]);
|
|
204
|
+
const availableThemeIds = (0, react_1.useMemo)(() => {
|
|
205
|
+
const customThemeUids = themes.map((theme) => theme.id);
|
|
206
|
+
return [
|
|
207
|
+
...new Set([
|
|
208
|
+
...customThemeUids,
|
|
209
|
+
"solid",
|
|
210
|
+
"xmlui",
|
|
211
|
+
"xmlui-blue",
|
|
212
|
+
"xmlui-green",
|
|
213
|
+
"xmlui-gray",
|
|
214
|
+
"xmlui-orange",
|
|
215
|
+
"xmlui-purple",
|
|
216
|
+
]),
|
|
217
|
+
];
|
|
218
|
+
}, [themes]);
|
|
219
|
+
const [activeThemeId, setActiveThemeId] = (0, react_1.useState)(() => {
|
|
220
|
+
if (!defaultTheme) {
|
|
221
|
+
return availableThemeIds[0];
|
|
222
|
+
}
|
|
223
|
+
return defaultTheme;
|
|
224
|
+
});
|
|
225
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
226
|
+
//we sync the activeThemeId with the default theme (mostly for HMR)
|
|
227
|
+
if (defaultTheme && availableThemeIds.includes(defaultTheme)) {
|
|
228
|
+
setActiveThemeId(defaultTheme);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
setActiveThemeId(availableThemeIds[0]);
|
|
232
|
+
}
|
|
233
|
+
}, [availableThemeIds, defaultTheme]);
|
|
234
|
+
const activeTheme = (0, react_1.useMemo)(() => {
|
|
235
|
+
let foundTheme;
|
|
236
|
+
if (activeThemeId) {
|
|
237
|
+
foundTheme = themes.find((theme) => theme.id === activeThemeId);
|
|
238
|
+
}
|
|
239
|
+
if (!foundTheme) {
|
|
240
|
+
throw new Error(`Theme ${activeThemeId} not found, available themes: ${availableThemeIds}`);
|
|
241
|
+
}
|
|
242
|
+
return foundTheme;
|
|
243
|
+
}, [activeThemeId, availableThemeIds, themes]);
|
|
244
|
+
const { allThemeVarsWithResolvedHierarchicalVars, themeCssVars, getResourceUrl, getThemeVar, } = useCompiledTheme(activeTheme, activeThemeTone, themes, resources, resourceMap);
|
|
245
|
+
const [root, setRoot] = (0, react_1.useState)(typeof document === "undefined" ? undefined : document.body);
|
|
246
|
+
const themeValue = (0, react_1.useMemo)(() => {
|
|
247
|
+
const themeVal = {
|
|
248
|
+
root,
|
|
249
|
+
setRoot,
|
|
250
|
+
themes,
|
|
251
|
+
resources,
|
|
252
|
+
resourceMap,
|
|
253
|
+
activeThemeId,
|
|
254
|
+
activeThemeTone,
|
|
255
|
+
setActiveThemeId,
|
|
256
|
+
setActiveThemeTone,
|
|
257
|
+
availableThemeIds,
|
|
258
|
+
activeTheme,
|
|
259
|
+
};
|
|
260
|
+
return themeVal;
|
|
261
|
+
}, [
|
|
262
|
+
activeTheme,
|
|
263
|
+
activeThemeId,
|
|
264
|
+
activeThemeTone,
|
|
265
|
+
availableThemeIds,
|
|
266
|
+
resourceMap,
|
|
267
|
+
resources,
|
|
268
|
+
root,
|
|
269
|
+
themes,
|
|
270
|
+
]);
|
|
271
|
+
const currentThemeContextValue = (0, react_1.useMemo)(() => {
|
|
272
|
+
const themeVal = {
|
|
273
|
+
root,
|
|
274
|
+
activeThemeId,
|
|
275
|
+
activeThemeTone: activeThemeTone,
|
|
276
|
+
activeTheme,
|
|
277
|
+
themeStyles: themeCssVars,
|
|
278
|
+
themeVars: allThemeVarsWithResolvedHierarchicalVars,
|
|
279
|
+
getResourceUrl,
|
|
280
|
+
getThemeVar,
|
|
281
|
+
};
|
|
282
|
+
return themeVal;
|
|
283
|
+
}, [
|
|
284
|
+
activeTheme,
|
|
285
|
+
activeThemeId,
|
|
286
|
+
activeThemeTone,
|
|
287
|
+
allThemeVarsWithResolvedHierarchicalVars,
|
|
288
|
+
getResourceUrl,
|
|
289
|
+
getThemeVar,
|
|
290
|
+
root,
|
|
291
|
+
themeCssVars,
|
|
292
|
+
]);
|
|
293
|
+
return ((0, jsx_runtime_1.jsx)(ThemeContext_1.ThemesContext.Provider, { value: themeValue, children: (0, jsx_runtime_1.jsx)(ThemeContext_1.ThemeContext.Provider, { value: currentThemeContextValue, children: children }) }));
|
|
294
|
+
}
|
|
295
|
+
function resolveThemeVarsWithCssVars(theme) {
|
|
296
|
+
if (!theme) {
|
|
297
|
+
return {};
|
|
298
|
+
}
|
|
299
|
+
const ret = {};
|
|
300
|
+
Object.keys(theme).forEach((key) => {
|
|
301
|
+
ret[key] = resolveThemeVarToCssVars(key, theme);
|
|
302
|
+
});
|
|
303
|
+
return ret;
|
|
304
|
+
function resolveThemeVarToCssVars(varName, theme) {
|
|
305
|
+
const value = theme[varName];
|
|
306
|
+
if (typeof value === "string" && value.includes("$")) {
|
|
307
|
+
return replaceThemeVar(value);
|
|
308
|
+
}
|
|
309
|
+
return value;
|
|
310
|
+
}
|
|
311
|
+
function replaceThemeVar(input) {
|
|
312
|
+
const regex = /\$([a-zA-Z0-9_-]+)/gi;
|
|
313
|
+
let matches = input.matchAll(regex);
|
|
314
|
+
//we go from 1, because result[1] is the whole stuff
|
|
315
|
+
if (matches) {
|
|
316
|
+
let ret = input;
|
|
317
|
+
for (let match of matches) {
|
|
318
|
+
const varName = match[1];
|
|
319
|
+
if (varName) {
|
|
320
|
+
ret = ret.replace(match[0], `var(${(0, themeVars_1.getVarKey)(varName)})`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return ret;
|
|
324
|
+
}
|
|
325
|
+
// for (let i = 1; i < (result?.length || 0); i++) {
|
|
326
|
+
// const varName = result?.[i];
|
|
327
|
+
// if(varName){
|
|
328
|
+
// return input.replace(regex, `var(${getVarKey(varName)})`);
|
|
329
|
+
// }
|
|
330
|
+
// }
|
|
331
|
+
return input;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
exports.default = ThemeProvider;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INITIAL_THEME_TONE = exports.ThemeToneKeys = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Each theme can have a light or a dark tone.
|
|
6
|
+
*/
|
|
7
|
+
exports.ThemeToneKeys = ["light", "dark"];
|
|
8
|
+
/**
|
|
9
|
+
* Initial theme tone value. Easier to modify if needed
|
|
10
|
+
*/
|
|
11
|
+
exports.INITIAL_THEME_TONE = "light";
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectThemeChainByExtends = collectThemeChainByExtends;
|
|
4
|
+
exports.expandTheme = expandTheme;
|
|
5
|
+
const lodash_es_1 = require("lodash-es");
|
|
6
|
+
const root_1 = require("@components-core/theming/themes/root");
|
|
7
|
+
function collectExtends(cTheme, allThemes) {
|
|
8
|
+
if (!cTheme) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
if (!cTheme.extends) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const arrayExtends = typeof cTheme.extends === "string" ? [cTheme.extends] : cTheme.extends;
|
|
15
|
+
const ret = [];
|
|
16
|
+
arrayExtends.forEach((ext) => {
|
|
17
|
+
const parentTheme = allThemes.find((theme) => theme.id === ext);
|
|
18
|
+
if (parentTheme) {
|
|
19
|
+
ret.push(...collectExtends(parentTheme, allThemes));
|
|
20
|
+
ret.push(parentTheme);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return ret;
|
|
24
|
+
}
|
|
25
|
+
function collectThemeChainByExtends(customTheme, allThemes, componentDefaultThemeVars) {
|
|
26
|
+
const rootThemeVars = (0, lodash_es_1.cloneDeep)(root_1.RootThemeDefinition.themeVars) || {};
|
|
27
|
+
const rootTones = (0, lodash_es_1.cloneDeep)(root_1.RootThemeDefinition.tones) || {};
|
|
28
|
+
Object.entries(componentDefaultThemeVars).forEach(([key, value]) => {
|
|
29
|
+
if (typeof value === "string") {
|
|
30
|
+
rootThemeVars[key] = value;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
Object.entries(value).forEach(([themeVarKey, themeVarVal]) => {
|
|
34
|
+
if (!rootTones[key]) {
|
|
35
|
+
rootTones[key] = { themeVars: {} };
|
|
36
|
+
}
|
|
37
|
+
rootTones[key].themeVars = Object.assign(Object.assign({}, rootTones[key].themeVars), { [themeVarKey]: themeVarVal });
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const root = {
|
|
42
|
+
id: "root",
|
|
43
|
+
themeVars: rootThemeVars,
|
|
44
|
+
resources: {},
|
|
45
|
+
tones: rootTones,
|
|
46
|
+
};
|
|
47
|
+
return [root, ...collectExtends(customTheme, allThemes), customTheme];
|
|
48
|
+
}
|
|
49
|
+
// --- Extends an existing theme with expanding theme variables
|
|
50
|
+
function expandTheme(newTheme) {
|
|
51
|
+
const result = {};
|
|
52
|
+
if (!newTheme) {
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
// --- Iterate through new theme variables
|
|
56
|
+
Object.keys(newTheme).forEach((key) => {
|
|
57
|
+
// --- Set the theme variable
|
|
58
|
+
result[key] = newTheme[key];
|
|
59
|
+
// --- Check for variables to extend
|
|
60
|
+
Object.keys(themeVariableExpansion).forEach((keyToCheck) => {
|
|
61
|
+
if (!key.startsWith(keyToCheck + "-"))
|
|
62
|
+
return;
|
|
63
|
+
// --- Candidate for extension
|
|
64
|
+
const varPart = key.substring(keyToCheck.length);
|
|
65
|
+
const keysToExtend = themeVariableExpansion[keyToCheck];
|
|
66
|
+
if (keysToExtend.some((kte) => key.startsWith(kte + "-")))
|
|
67
|
+
return;
|
|
68
|
+
keysToExtend.forEach((keyToExtend) => {
|
|
69
|
+
const fullKey = keyToExtend + varPart;
|
|
70
|
+
result[fullKey] = newTheme[key];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
// --- Done.
|
|
75
|
+
return Object.assign(Object.assign({}, result), newTheme);
|
|
76
|
+
}
|
|
77
|
+
const themeVariableExpansion = {
|
|
78
|
+
padding: ["padding-horizontal", "padding-vertical", "padding-top", "padding-right", "padding-bottom", "padding-left"],
|
|
79
|
+
"padding-horizontal": ["padding-left", "padding-right"],
|
|
80
|
+
"padding-vertical": ["padding-top", "padding-bottom"],
|
|
81
|
+
border: ["border-horizontal", "border-vertical", "border-top", "border-right", "border-bottom", "border-left"],
|
|
82
|
+
"border-horizontal": ["border-left", "border-right"],
|
|
83
|
+
"border-vertical": ["border-top", "border-bottom"],
|
|
84
|
+
"color-border": [
|
|
85
|
+
"color-border-horizontal",
|
|
86
|
+
"color-border-vertical",
|
|
87
|
+
"color-border-top",
|
|
88
|
+
"color-border-right",
|
|
89
|
+
"color-border-bottom",
|
|
90
|
+
"color-border-left",
|
|
91
|
+
],
|
|
92
|
+
"color-border-horizontal": ["color-border-left", "color-border-right"],
|
|
93
|
+
"color-border-vertical": ["color-border-top", "color-border-bottom"],
|
|
94
|
+
"thickness-border": [
|
|
95
|
+
"thickness-border-horizontal",
|
|
96
|
+
"thickness-border-vertical",
|
|
97
|
+
"thickness-border-top",
|
|
98
|
+
"thickness-border-right",
|
|
99
|
+
"thickness-border-bottom",
|
|
100
|
+
"thickness-border-left",
|
|
101
|
+
],
|
|
102
|
+
"thickness-border-horizontal": ["thickness-border-left", "thickness-border-right"],
|
|
103
|
+
"thickness-border-vertical": ["thickness-border-top", "thickness-border-bottom"],
|
|
104
|
+
"style-border": [
|
|
105
|
+
"style-border-horizontal",
|
|
106
|
+
"style-border-vertical",
|
|
107
|
+
"style-border-top",
|
|
108
|
+
"style-border-right",
|
|
109
|
+
"style-border-bottom",
|
|
110
|
+
"style-border-left",
|
|
111
|
+
],
|
|
112
|
+
"style-border-horizontal": ["style-border-left", "style-border-right"],
|
|
113
|
+
"style-border-vertical": ["style-border-top", "style-border-bottom"],
|
|
114
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseHVar = parseHVar;
|
|
4
|
+
exports.matchThemeVar = matchThemeVar;
|
|
5
|
+
const parsedHVarCache = {};
|
|
6
|
+
//extremely dummy solution, will come back later
|
|
7
|
+
function parseHVar(input) {
|
|
8
|
+
if (parsedHVarCache[input] !== undefined) {
|
|
9
|
+
return parsedHVarCache[input];
|
|
10
|
+
}
|
|
11
|
+
// Split the input string into parts using regex
|
|
12
|
+
const parts = input.split(/-[A-Z]+/);
|
|
13
|
+
if (parts.length !== 2) {
|
|
14
|
+
parsedHVarCache[input] = null;
|
|
15
|
+
return parsedHVarCache[input];
|
|
16
|
+
}
|
|
17
|
+
const firstPart = parts[0];
|
|
18
|
+
const classessParts = firstPart.split(":");
|
|
19
|
+
const attribute = classessParts[classessParts.length - 1];
|
|
20
|
+
const classes = classessParts.length > 1 ? classessParts.slice(0, classessParts.length - 1) : [];
|
|
21
|
+
const secondPart = input.substring(firstPart.length + 1);
|
|
22
|
+
const [compName, ...rest] = secondPart.split("-");
|
|
23
|
+
const traitsAndStates = secondPart.substring(compName.length).split("--");
|
|
24
|
+
const states = [];
|
|
25
|
+
const traits = [];
|
|
26
|
+
traitsAndStates.forEach((part) => {
|
|
27
|
+
if (!part.includes("-") && part) {
|
|
28
|
+
states.push(part);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
part.split("-").forEach((trait) => {
|
|
32
|
+
if (trait) {
|
|
33
|
+
traits.push(trait);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
parsedHVarCache[input] = {
|
|
39
|
+
classes: classes,
|
|
40
|
+
attribute: attribute,
|
|
41
|
+
component: compName,
|
|
42
|
+
traits: traits,
|
|
43
|
+
states: states,
|
|
44
|
+
};
|
|
45
|
+
return parsedHVarCache[input];
|
|
46
|
+
}
|
|
47
|
+
function createCombinations(arr = []) {
|
|
48
|
+
const stateCombinations = [];
|
|
49
|
+
for (let i = 1; i <= arr.length; i++) {
|
|
50
|
+
for (let j = 0; j <= arr.length - i; j++) {
|
|
51
|
+
stateCombinations.push(arr.slice(j, j + i));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return stateCombinations.sort((a, b) => b.length - a.length);
|
|
55
|
+
}
|
|
56
|
+
function matchThemeVar(themeVar, availableThemeVars = []) {
|
|
57
|
+
const hvar = parseHVar(themeVar);
|
|
58
|
+
if (!hvar) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const stateCombinations = createCombinations(hvar.states);
|
|
62
|
+
const traitCombinations = createCombinations(hvar.traits);
|
|
63
|
+
const sortedTraitCombinations = [];
|
|
64
|
+
traitCombinations.forEach((traitComb) => {
|
|
65
|
+
let result = "";
|
|
66
|
+
traitComb.forEach((t) => {
|
|
67
|
+
result = `${result}-${t}`;
|
|
68
|
+
});
|
|
69
|
+
sortedTraitCombinations.push(result);
|
|
70
|
+
});
|
|
71
|
+
sortedTraitCombinations.push("");
|
|
72
|
+
const sortedStateCombinations = [];
|
|
73
|
+
stateCombinations.forEach((stateComb) => {
|
|
74
|
+
let result = "";
|
|
75
|
+
stateComb.forEach((s) => {
|
|
76
|
+
result = `${result}--${s}`;
|
|
77
|
+
});
|
|
78
|
+
sortedStateCombinations.push(result);
|
|
79
|
+
});
|
|
80
|
+
sortedStateCombinations.push("");
|
|
81
|
+
const componentParts = [hvar.component, ...hvar.classes];
|
|
82
|
+
const from = [];
|
|
83
|
+
sortedStateCombinations.forEach((stateComb) => {
|
|
84
|
+
sortedTraitCombinations.forEach((traitComb) => {
|
|
85
|
+
componentParts.forEach((componentPart) => {
|
|
86
|
+
from.push(`${hvar.attribute}-${componentPart}${traitComb}${stateComb}`);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
let matchedValue;
|
|
91
|
+
for (let i = availableThemeVars.length - 1; i >= 0; i--) {
|
|
92
|
+
const themeVars = availableThemeVars[i];
|
|
93
|
+
let foundValue = from.find((themeVar) => themeVars[themeVar] !== undefined);
|
|
94
|
+
if (foundValue) {
|
|
95
|
+
matchedValue = foundValue;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const forValue = from[0];
|
|
100
|
+
return {
|
|
101
|
+
forValue: forValue,
|
|
102
|
+
matchedValue: matchedValue,
|
|
103
|
+
from: from,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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.parseScssVar = parseScssVar;
|
|
7
|
+
exports.getVarKey = getVarKey;
|
|
8
|
+
/**
|
|
9
|
+
* The sole purpose of this module is to provide an object with the available keys of theme SCSS variables and the
|
|
10
|
+
* prefix of the theme.
|
|
11
|
+
*/
|
|
12
|
+
const themeVars_module_scss_1 = __importDefault(require("./themeVars.module.scss"));
|
|
13
|
+
/**
|
|
14
|
+
* This function extracts CSS variables from the specified SCSS input. It uses a hack to convert the CSS input to JSON
|
|
15
|
+
* and then calls a JSON parser to create the desired object.
|
|
16
|
+
* @param scssStr The scss input
|
|
17
|
+
*/
|
|
18
|
+
function parseScssVar(scssStr) {
|
|
19
|
+
if (!scssStr || typeof scssStr !== typeof "") {
|
|
20
|
+
return scssStr;
|
|
21
|
+
}
|
|
22
|
+
// Lists and maps are surrounded by single quotes, e.g. "'[ \"string in list\", 5, \"5px\" ]'"
|
|
23
|
+
// Remove them if they exist so they can be parsed correctly.
|
|
24
|
+
let jsValue = scssStr.replace(/(^['"])|(['"]$)/g, "");
|
|
25
|
+
try {
|
|
26
|
+
// JSON-formatted string from within SCSS file
|
|
27
|
+
return JSON.parse(jsValue);
|
|
28
|
+
}
|
|
29
|
+
catch (errorParsingJsonGeneratedInUtilScssFile) {
|
|
30
|
+
try {
|
|
31
|
+
// Value was likely an SCSS literal string; attempt parsing it manually.
|
|
32
|
+
// Example: inspect($my-map) => '(num: 10, numWithUnits: 5px, str: hello, color: #fff, "keyAsStr": false, other: null)'
|
|
33
|
+
return JSON.parse(scssStr
|
|
34
|
+
.replace("(", "{")
|
|
35
|
+
.replace(")", "}")
|
|
36
|
+
// JSON values: convert any collection of word characters followed by a comma or bracket to a string
|
|
37
|
+
.replace(/: ?([^,}]+)([,}])/g, ': "$1"$2')
|
|
38
|
+
// JSON keys: space/bracket/comma as first character, not already a string, anything not colon or
|
|
39
|
+
// space (rules out JSON values), ended by colon
|
|
40
|
+
.replace(/([\s{,])(?!")([^:\s]+)+:/g, '$1"$2":'));
|
|
41
|
+
}
|
|
42
|
+
catch (errorParsingScssStringLiteral) {
|
|
43
|
+
return jsValue;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
let keyPrefix = parseScssVar(themeVars_module_scss_1.default.keyPrefix) || "";
|
|
48
|
+
let vars = parseScssVar(themeVars_module_scss_1.default.themeVars);
|
|
49
|
+
/**
|
|
50
|
+
* Export the desired SCSS variables and prefix
|
|
51
|
+
*/
|
|
52
|
+
const theme = {
|
|
53
|
+
keyPrefix: keyPrefix,
|
|
54
|
+
themeVars: vars,
|
|
55
|
+
};
|
|
56
|
+
function getVarKey(varName) {
|
|
57
|
+
if (keyPrefix) {
|
|
58
|
+
return `--${keyPrefix}-${varName}`;
|
|
59
|
+
}
|
|
60
|
+
return `--${varName}`;
|
|
61
|
+
}
|
|
62
|
+
exports.default = theme;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paddingSubject = paddingSubject;
|
|
4
|
+
exports.borderSubject = borderSubject;
|
|
5
|
+
function paddingSubject(name, valueSpec) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7
|
+
return {
|
|
8
|
+
[`padding-left-${name}`]: (_a = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.left) !== null && _a !== void 0 ? _a : `$padding-horizontal-${name}`,
|
|
9
|
+
[`padding-right-${name}`]: (_b = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.right) !== null && _b !== void 0 ? _b : `$padding-horizontal-${name}`,
|
|
10
|
+
[`padding-top-${name}`]: (_c = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.top) !== null && _c !== void 0 ? _c : `$padding-vertical-${name}`,
|
|
11
|
+
[`padding-bottom-${name}`]: (_d = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.bottom) !== null && _d !== void 0 ? _d : `$padding-vertical-${name}`,
|
|
12
|
+
[`padding-horizontal-${name}`]: (_e = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.horizontal) !== null && _e !== void 0 ? _e : "",
|
|
13
|
+
[`padding-vertical-${name}`]: (_f = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.vertical) !== null && _f !== void 0 ? _f : "",
|
|
14
|
+
[`padding-${name}`]: (_g = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all) !== null && _g !== void 0 ? _g : `$padding-top-${name} $padding-right-${name} $padding-bottom-${name} $padding-left-${name}`,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function borderSubject(name, valueSpec) {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
19
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ [`radius-${name}`]: "$radius" }, borderEdgeSubject("left", (_b = (_a = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.left) !== null && _a !== void 0 ? _a : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.horizontal) !== null && _b !== void 0 ? _b : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all)), borderEdgeSubject("right", (_d = (_c = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.right) !== null && _c !== void 0 ? _c : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.horizontal) !== null && _d !== void 0 ? _d : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all)), borderEdgeSubject("top", (_f = (_e = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.top) !== null && _e !== void 0 ? _e : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.vertical) !== null && _f !== void 0 ? _f : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all)), borderEdgeSubject("bottom", (_h = (_g = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.bottom) !== null && _g !== void 0 ? _g : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.vertical) !== null && _h !== void 0 ? _h : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all)), borderEdgeSubject("horizontal", (_j = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.horizontal) !== null && _j !== void 0 ? _j : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all)), borderEdgeSubject("vertical", (_k = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.vertical) !== null && _k !== void 0 ? _k : valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all)), { [`color-border-${name}`]: (_m = (_l = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all) === null || _l === void 0 ? void 0 : _l.color) !== null && _m !== void 0 ? _m : "", [`thickness-border-${name}`]: (_p = (_o = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all) === null || _o === void 0 ? void 0 : _o.thickness) !== null && _p !== void 0 ? _p : "", [`style-border-${name}`]: (_r = (_q = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all) === null || _q === void 0 ? void 0 : _q.style) !== null && _r !== void 0 ? _r : "", [`border-${name}`]: `${(_t = (_s = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all) === null || _s === void 0 ? void 0 : _s.thickness) !== null && _t !== void 0 ? _t : `$thickness-border-${name}`} ` +
|
|
20
|
+
`${(_v = (_u = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all) === null || _u === void 0 ? void 0 : _u.style) !== null && _v !== void 0 ? _v : `$style-border-${name}`} ` +
|
|
21
|
+
`${(_x = (_w = valueSpec === null || valueSpec === void 0 ? void 0 : valueSpec.all) === null || _w === void 0 ? void 0 : _w.color) !== null && _x !== void 0 ? _x : `$color-border-${name}`} ` });
|
|
22
|
+
function borderEdgeSubject(edge, edgeSpec) {
|
|
23
|
+
var _a, _b, _c, _d;
|
|
24
|
+
return {
|
|
25
|
+
[`color-border-${edge}-${name}`]: (_a = edgeSpec === null || edgeSpec === void 0 ? void 0 : edgeSpec.color) !== null && _a !== void 0 ? _a : "",
|
|
26
|
+
[`thickness-border-${edge}-${name}`]: (_b = edgeSpec === null || edgeSpec === void 0 ? void 0 : edgeSpec.thickness) !== null && _b !== void 0 ? _b : "",
|
|
27
|
+
[`style-border-${edge}-${name}`]: (_c = edgeSpec === null || edgeSpec === void 0 ? void 0 : edgeSpec.style) !== null && _c !== void 0 ? _c : "",
|
|
28
|
+
[`border-${edge}-${name}`]: (_d = edgeSpec === null || edgeSpec === void 0 ? void 0 : edgeSpec.all) !== null && _d !== void 0 ? _d : `$thickness-border-${edge}-${name} $style-border-${edge}-${name} $color-border-${edge}-${name}`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|