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,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.formComponentRenderer = exports.getByPath = void 0;
|
|
16
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const react_2 = require("react");
|
|
19
|
+
const Form_module_scss_1 = __importDefault(require("./Form.module.scss"));
|
|
20
|
+
const renderers_1 = require("@components-core/renderers");
|
|
21
|
+
const themeVars_1 = require("@components-core/theming/themeVars");
|
|
22
|
+
const immer_1 = __importDefault(require("immer"));
|
|
23
|
+
const FormContext_1 = require("./FormContext");
|
|
24
|
+
const Button_1 = require("@components/Button/Button");
|
|
25
|
+
const constants_1 = require("@components-core/constants");
|
|
26
|
+
const ValidationSummary_1 = require("@components/ValidationSummary/ValidationSummary");
|
|
27
|
+
const misc_1 = require("@components-core/utils/misc");
|
|
28
|
+
const Validations_1 = require("@components/FormItem/Validations");
|
|
29
|
+
const formActions_1 = require("@components/Form/formActions");
|
|
30
|
+
const ModalDialog_1 = require("@components/ModalDialog/ModalDialog");
|
|
31
|
+
const Text_1 = require("@components/Text/Text");
|
|
32
|
+
const Stack_1 = require("@components/Stack/Stack");
|
|
33
|
+
const descriptorHelper_1 = require("@components-core/descriptorHelper");
|
|
34
|
+
const setByPath = (obj, path, val) => {
|
|
35
|
+
const keys = path.split(".");
|
|
36
|
+
for (let i = 0; i < keys.length; i++) {
|
|
37
|
+
const currentKey = keys[i];
|
|
38
|
+
const nextKey = keys[i + 1];
|
|
39
|
+
if (typeof nextKey !== "undefined") {
|
|
40
|
+
obj[currentKey] = obj[currentKey] ? obj[currentKey] : {};
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
obj[currentKey] = val;
|
|
44
|
+
}
|
|
45
|
+
obj = obj[currentKey];
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const getByPath = (obj, path) => {
|
|
49
|
+
const keys = path.split(".");
|
|
50
|
+
let ret = obj;
|
|
51
|
+
for (let i = 0; i < keys.length; i++) {
|
|
52
|
+
ret = ret === null || ret === void 0 ? void 0 : ret[keys[i]];
|
|
53
|
+
}
|
|
54
|
+
return ret;
|
|
55
|
+
};
|
|
56
|
+
exports.getByPath = getByPath;
|
|
57
|
+
const formReducer = (0, immer_1.default)((state, action) => {
|
|
58
|
+
var _a, _b, _c, _d;
|
|
59
|
+
const { uid } = action.payload;
|
|
60
|
+
if (uid !== undefined && !state.interactionFlags[uid]) {
|
|
61
|
+
state.interactionFlags[uid] = {
|
|
62
|
+
isDirty: false,
|
|
63
|
+
invalidToValid: false,
|
|
64
|
+
isValidOnFocus: false,
|
|
65
|
+
isValidLostFocus: false,
|
|
66
|
+
focused: false,
|
|
67
|
+
forceShowValidationResult: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
switch (action.type) {
|
|
71
|
+
case formActions_1.FormActionKind.FIELD_INITIALIZED: {
|
|
72
|
+
setByPath(state.subject, uid, action.payload.value);
|
|
73
|
+
state.interactionFlags[uid].isDirty = false;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case formActions_1.FormActionKind.FIELD_VALUE_CHANGED: {
|
|
77
|
+
setByPath(state.subject, uid, action.payload.value);
|
|
78
|
+
state.interactionFlags[uid].isDirty = true;
|
|
79
|
+
state.interactionFlags[uid].forceShowValidationResult = false;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case formActions_1.FormActionKind.FIELD_VALIDATED: {
|
|
83
|
+
// it means no validation happened, ignore it
|
|
84
|
+
if (action.payload.validationResult.validations.length === 0) {
|
|
85
|
+
delete state.validationResults[uid];
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
const prevValid = (_a = state.validationResults[uid]) === null || _a === void 0 ? void 0 : _a.isValid;
|
|
89
|
+
//if it's a partial validation (without the async stuff), we leave the previous async validations there as a stale placeholder
|
|
90
|
+
if (action.payload.validationResult.partial) {
|
|
91
|
+
const mergedValidations = [
|
|
92
|
+
...action.payload.validationResult.validations,
|
|
93
|
+
...(((_b = state.validationResults[uid]) === null || _b === void 0 ? void 0 : _b.validations.filter((val) => val.async)) || []).map((val) => (Object.assign(Object.assign({}, val), { stale: true }))),
|
|
94
|
+
];
|
|
95
|
+
state.validationResults[uid] = Object.assign(Object.assign({}, action.payload.validationResult), { isValid: mergedValidations.find((val) => !val.isValid) === undefined, validations: mergedValidations });
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
state.validationResults[uid] = action.payload.validationResult;
|
|
99
|
+
}
|
|
100
|
+
state.interactionFlags[uid].invalidToValid = !prevValid && state.validationResults[uid].isValid;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case formActions_1.FormActionKind.FIELD_FOCUSED: {
|
|
104
|
+
state.interactionFlags[uid].isValidOnFocus = !!((_c = state.validationResults[uid]) === null || _c === void 0 ? void 0 : _c.isValid);
|
|
105
|
+
state.interactionFlags[uid].focused = true;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case formActions_1.FormActionKind.FIELD_LOST_FOCUS: {
|
|
109
|
+
state.interactionFlags[uid].isValidLostFocus = !!((_d = state.validationResults[uid]) === null || _d === void 0 ? void 0 : _d.isValid);
|
|
110
|
+
state.interactionFlags[uid].focused = false;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case formActions_1.FormActionKind.TRIED_TO_SUBMIT: {
|
|
114
|
+
Object.keys(state.interactionFlags).forEach((key) => {
|
|
115
|
+
state.interactionFlags[key].forceShowValidationResult = true;
|
|
116
|
+
});
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case formActions_1.FormActionKind.SUBMITTED: {
|
|
120
|
+
state.generalValidationResults = [];
|
|
121
|
+
state.interactionFlags = {};
|
|
122
|
+
Object.keys(state.validationResults).forEach((key) => {
|
|
123
|
+
var _a;
|
|
124
|
+
state.validationResults[key].validations = (_a = state.validationResults[key].validations) === null || _a === void 0 ? void 0 : _a.filter((validation) => !validation.fromBackend);
|
|
125
|
+
state.validationResults[key].isValid =
|
|
126
|
+
state.validationResults[key].validations.find((val) => !val.isValid) === undefined;
|
|
127
|
+
});
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case formActions_1.FormActionKind.BACKEND_VALIDATION_ARRIVED: {
|
|
131
|
+
state.generalValidationResults = action.payload.generalValidationResults;
|
|
132
|
+
Object.keys(state.validationResults).forEach((key) => {
|
|
133
|
+
var _a;
|
|
134
|
+
state.validationResults[key].validations = (_a = state.validationResults[key].validations) === null || _a === void 0 ? void 0 : _a.filter((validation) => !validation.fromBackend);
|
|
135
|
+
});
|
|
136
|
+
Object.entries(action.payload.fieldValidationResults).forEach(([field, singleValidationResults]) => {
|
|
137
|
+
var _a;
|
|
138
|
+
state.validationResults[field].validations = [
|
|
139
|
+
...(((_a = state.validationResults[field]) === null || _a === void 0 ? void 0 : _a.validations) || []),
|
|
140
|
+
...(singleValidationResults || []),
|
|
141
|
+
];
|
|
142
|
+
state.validationResults[field].isValid =
|
|
143
|
+
state.validationResults[field].validations.find((val) => !val.isValid) === undefined;
|
|
144
|
+
});
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
default:
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const initialState = {
|
|
151
|
+
subject: {},
|
|
152
|
+
validationResults: {},
|
|
153
|
+
generalValidationResults: [],
|
|
154
|
+
interactionFlags: {},
|
|
155
|
+
};
|
|
156
|
+
const Form = (0, react_2.forwardRef)(function ({ formState, dispatch, initialValue = constants_1.EMPTY_OBJECT, children, style, enabled = true, cancelLabel = "Cancel", saveLabel = "Save", swapCancelAndSave, onSubmit, onCancel, onReset, buttonRow, id, registerComponentApi, itemLabelBreak = true, itemLabelWidth, itemLabelPosition = "top", }, ref) {
|
|
157
|
+
const [confirmSubmitModalVisible, setConfirmSubmitModalVisible] = (0, react_2.useState)(false);
|
|
158
|
+
const formContextValue = (0, react_2.useMemo)(() => {
|
|
159
|
+
return {
|
|
160
|
+
itemLabelBreak,
|
|
161
|
+
itemLabelWidth,
|
|
162
|
+
itemLabelPosition,
|
|
163
|
+
subject: formState.subject,
|
|
164
|
+
originalSubject: initialValue,
|
|
165
|
+
validationResults: formState.validationResults,
|
|
166
|
+
interactionFlags: formState.interactionFlags,
|
|
167
|
+
dispatch,
|
|
168
|
+
};
|
|
169
|
+
}, [
|
|
170
|
+
dispatch,
|
|
171
|
+
formState.interactionFlags,
|
|
172
|
+
formState.subject,
|
|
173
|
+
formState.validationResults,
|
|
174
|
+
initialValue,
|
|
175
|
+
itemLabelBreak,
|
|
176
|
+
itemLabelPosition,
|
|
177
|
+
itemLabelWidth,
|
|
178
|
+
]);
|
|
179
|
+
const doSubmit = (0, misc_1.useEvent)((event) => __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
var _a;
|
|
181
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
182
|
+
if (!enabled) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
setConfirmSubmitModalVisible(false);
|
|
186
|
+
dispatch((0, formActions_1.triedToSubmit)());
|
|
187
|
+
const { error, warning } = (0, Validations_1.groupInvalidValidationResultsBySeverity)(Object.values(formState.validationResults));
|
|
188
|
+
if (error.length) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (warning.length && !confirmSubmitModalVisible) {
|
|
192
|
+
setConfirmSubmitModalVisible(true);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
yield (onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formState.subject, {
|
|
197
|
+
passAsDefaultBody: true,
|
|
198
|
+
}));
|
|
199
|
+
dispatch((0, formActions_1.formSubmitted)());
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
const generalValidationResults = [];
|
|
203
|
+
const fieldValidationResults = {};
|
|
204
|
+
if (e instanceof Error &&
|
|
205
|
+
"errorCategory" in e &&
|
|
206
|
+
e.errorCategory === "GenericBackendError" &&
|
|
207
|
+
((_a = e.details) === null || _a === void 0 ? void 0 : _a.issues) &&
|
|
208
|
+
Array.isArray(e.details.issues)) {
|
|
209
|
+
e.details.issues.forEach((issue) => {
|
|
210
|
+
const validationResult = {
|
|
211
|
+
isValid: false,
|
|
212
|
+
invalidMessage: issue.message,
|
|
213
|
+
severity: issue.severity || "error",
|
|
214
|
+
fromBackend: true,
|
|
215
|
+
};
|
|
216
|
+
if (issue.field !== undefined) {
|
|
217
|
+
fieldValidationResults[issue.field] = fieldValidationResults[issue.field] || [];
|
|
218
|
+
fieldValidationResults[issue.field].push(validationResult);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
generalValidationResults.push(validationResult);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
generalValidationResults.push({
|
|
227
|
+
isValid: false,
|
|
228
|
+
invalidMessage: e.message || "Couldn't save the form.",
|
|
229
|
+
severity: "error",
|
|
230
|
+
fromBackend: true,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
dispatch((0, formActions_1.backendValidationArrived)({
|
|
234
|
+
generalValidationResults,
|
|
235
|
+
fieldValidationResults,
|
|
236
|
+
}));
|
|
237
|
+
}
|
|
238
|
+
}));
|
|
239
|
+
const [key, setKey] = (0, react_2.useState)(1);
|
|
240
|
+
const doReset = (0, misc_1.useEvent)(() => {
|
|
241
|
+
setKey((prev) => prev + 1);
|
|
242
|
+
onReset === null || onReset === void 0 ? void 0 : onReset();
|
|
243
|
+
});
|
|
244
|
+
const cancelButton = ((0, jsx_runtime_1.jsx)(Button_1.Button, { type: "button", themeColor: "secondary", variant: "ghost", onClick: onCancel, children: cancelLabel }, "cancel"));
|
|
245
|
+
const submitButton = ((0, jsx_runtime_1.jsx)(Button_1.Button, { type: "submit", children: saveLabel }, "submit"));
|
|
246
|
+
(0, react_1.useEffect)(() => {
|
|
247
|
+
registerComponentApi === null || registerComponentApi === void 0 ? void 0 : registerComponentApi({
|
|
248
|
+
reset: doReset,
|
|
249
|
+
});
|
|
250
|
+
}, [doReset, registerComponentApi]);
|
|
251
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("form", { style: style, className: Form_module_scss_1.default.wrapper, onSubmit: doSubmit, onReset: doReset, id: id, ref: ref, children: [(0, jsx_runtime_1.jsx)(ValidationSummary_1.ValidationSummary, { generalValidationResults: formState.generalValidationResults }), (0, jsx_runtime_1.jsx)(FormContext_1.FormContext.Provider, { value: formContextValue, children: children }), buttonRow || ((0, jsx_runtime_1.jsxs)("div", { className: Form_module_scss_1.default.buttonRow, children: [swapCancelAndSave && [submitButton, cancelButton], !swapCancelAndSave && [cancelButton, submitButton]] }))] }, key), confirmSubmitModalVisible && ((0, jsx_runtime_1.jsx)(ModalDialog_1.ModalDialog, { onClose: () => setConfirmSubmitModalVisible(false), isInitiallyOpen: true, title: "Are you sure want to move forward?", children: (0, jsx_runtime_1.jsxs)(Stack_1.Stack, { orientation: "vertical", layout: { gap: "0.5rem" }, children: [(0, jsx_runtime_1.jsx)(Text_1.Text, { children: "The following warnings were found during validation. Please make sure you are willing to move forward despite these issues." }), (0, jsx_runtime_1.jsx)(ValidationSummary_1.ValidationSummary, { generalValidationResults: formState.generalValidationResults, fieldValidationResults: formState.validationResults }), (0, jsx_runtime_1.jsxs)(Stack_1.Stack, { orientation: "horizontal", horizontalAlignment: "end", layout: { gap: "1em" }, children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "ghost", themeColor: "secondary", onClick: () => setConfirmSubmitModalVisible(false), children: "No" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => doSubmit(), autoFocus: true, children: "Yes, proceed" })] })] }) }))] }));
|
|
252
|
+
});
|
|
253
|
+
Form.displayName = "Form";
|
|
254
|
+
const metadata = {
|
|
255
|
+
displayName: "Form",
|
|
256
|
+
description: "Manages editing, validating and saving compound data in the UI",
|
|
257
|
+
props: {
|
|
258
|
+
buttonRowTemplate: {
|
|
259
|
+
description: "The template encapsulating form buttons",
|
|
260
|
+
valueType: "ComponentDef",
|
|
261
|
+
},
|
|
262
|
+
subject: (0, descriptorHelper_1.desc)("The data structure managed by the form"),
|
|
263
|
+
swapCancelAndSave: (0, descriptorHelper_1.desc)("Swap the Cancel and Save buttons?"),
|
|
264
|
+
cancelLabel: (0, descriptorHelper_1.desc)("The label of the Cancel button"),
|
|
265
|
+
saveLabel: (0, descriptorHelper_1.desc)("The label of the Save button"),
|
|
266
|
+
},
|
|
267
|
+
events: {
|
|
268
|
+
submit: (0, descriptorHelper_1.desc)("Triggers when the form data is about to save"),
|
|
269
|
+
reset: (0, descriptorHelper_1.desc)("Triggers when the form data is about to reset"),
|
|
270
|
+
},
|
|
271
|
+
themeVars: (0, themeVars_1.parseScssVar)(Form_module_scss_1.default.themeVars),
|
|
272
|
+
defaultThemeVars: {
|
|
273
|
+
"gap-Form": "$space-4",
|
|
274
|
+
"gap-buttonRow-Form": "$space-4",
|
|
275
|
+
light: {
|
|
276
|
+
"color-bg-ValidationDisplay-error": "$color-danger-100",
|
|
277
|
+
"color-bg-ValidationDisplay-warning": "$color-warn-100",
|
|
278
|
+
"color-bg-ValidationDisplay-info": "$color-primary-100",
|
|
279
|
+
"color-bg-ValidationDisplay-valid": "$color-success-100",
|
|
280
|
+
"color-accent-ValidationDisplay-error": "$color-error",
|
|
281
|
+
"color-accent-ValidationDisplay-warning": "$color-warning",
|
|
282
|
+
"color-accent-ValidationDisplay-info": "$color-info",
|
|
283
|
+
"color-accent-ValidationDisplay-valid": "$color-valid",
|
|
284
|
+
"color-text-ValidationDisplay-error": "$color-error",
|
|
285
|
+
"color-text-ValidationDisplay-warning": "$color-warning",
|
|
286
|
+
"color-text-ValidationDisplay-info": "$color-info",
|
|
287
|
+
"color-text-ValidationDisplay-valid": "$color-valid",
|
|
288
|
+
},
|
|
289
|
+
dark: {
|
|
290
|
+
"color-bg-ValidationDisplay-error": "$color-danger-900",
|
|
291
|
+
"color-bg-ValidationDisplay-warning": "$color-warn-900",
|
|
292
|
+
"color-bg-ValidationDisplay-info": "$color-secondary-800",
|
|
293
|
+
"color-bg-ValidationDisplay-valid": "$color-success-900",
|
|
294
|
+
"color-accent-ValidationDisplay-error": "$color-danger-500",
|
|
295
|
+
"color-accent-ValidationDisplay-warning": "$color-warn-700",
|
|
296
|
+
"color-accent-ValidationDisplay-info": "$color-surface-200",
|
|
297
|
+
"color-accent-ValidationDisplay-valid": "$color-success-600",
|
|
298
|
+
"color-text-ValidationDisplay-error": "$color-danger-500",
|
|
299
|
+
"color-text-ValidationDisplay-warning": "$color-warn-700",
|
|
300
|
+
"color-text-ValidationDisplay-info": "$color-secondary-200",
|
|
301
|
+
"color-text-ValidationDisplay-valid": "$color-success-600",
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
function FormWithContextVar({ node, renderChild, extractValue, layoutCss, lookupEventHandler, registerComponentApi, }) {
|
|
306
|
+
const [formState, dispatch] = (0, react_2.useReducer)(formReducer, initialState);
|
|
307
|
+
const nodeWithItem = (0, react_2.useMemo)(() => {
|
|
308
|
+
return {
|
|
309
|
+
type: "Fragment",
|
|
310
|
+
vars: {
|
|
311
|
+
$subject: formState.subject,
|
|
312
|
+
},
|
|
313
|
+
children: node.children,
|
|
314
|
+
};
|
|
315
|
+
}, [formState.subject, node.children]);
|
|
316
|
+
return ((0, jsx_runtime_1.jsx)(Form, { itemLabelPosition: extractValue.asOptionalString(node.props.itemLabelPosition), itemLabelBreak: extractValue.asOptionalBoolean(node.props.itemLabelBreak), itemLabelWidth: extractValue.asOptionalString(node.props.itemLabelWidth), formState: formState, dispatch: dispatch, id: node.uid, style: layoutCss, cancelLabel: extractValue(node.props.cancelLabel), saveLabel: extractValue(node.props.saveLabel), swapCancelAndSave: extractValue.asOptionalBoolean(node.props.swapCancelAndSave, false), onSubmit: lookupEventHandler("submit"), onCancel: lookupEventHandler("cancel"), onReset: lookupEventHandler("reset"), initialValue: extractValue(node.props.subject), buttonRow: renderChild(node.props.buttonRowTemplate), registerComponentApi: registerComponentApi, children: renderChild(nodeWithItem) }));
|
|
317
|
+
}
|
|
318
|
+
exports.formComponentRenderer = (0, renderers_1.createComponentRenderer)("Form", ({ node, renderChild, extractValue, layoutCss, lookupEventHandler, registerComponentApi }) => {
|
|
319
|
+
return ((0, jsx_runtime_1.jsx)(FormWithContextVar, { node: node, renderChild: renderChild, extractValue: extractValue, lookupEventHandler: lookupEventHandler, layoutCss: layoutCss, registerComponentApi: registerComponentApi }));
|
|
320
|
+
}, metadata);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormContext = void 0;
|
|
4
|
+
exports.useFormContextPart = useFormContextPart;
|
|
5
|
+
const use_context_selector_1 = require("use-context-selector");
|
|
6
|
+
exports.FormContext = (0, use_context_selector_1.createContext)(undefined);
|
|
7
|
+
function useFormContextPart(selector) {
|
|
8
|
+
return (0, use_context_selector_1.useContextSelector)(exports.FormContext, selector);
|
|
9
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormActionKind = void 0;
|
|
4
|
+
exports.fieldInitialized = fieldInitialized;
|
|
5
|
+
exports.fieldChanged = fieldChanged;
|
|
6
|
+
exports.fieldFocused = fieldFocused;
|
|
7
|
+
exports.fieldLostFocus = fieldLostFocus;
|
|
8
|
+
exports.fieldValidated = fieldValidated;
|
|
9
|
+
exports.triedToSubmit = triedToSubmit;
|
|
10
|
+
exports.formSubmitted = formSubmitted;
|
|
11
|
+
exports.backendValidationArrived = backendValidationArrived;
|
|
12
|
+
var FormActionKind;
|
|
13
|
+
(function (FormActionKind) {
|
|
14
|
+
FormActionKind["FIELD_LOST_FOCUS"] = "FormActionKind:FIELD_LOST_FOCUS";
|
|
15
|
+
FormActionKind["FIELD_VALUE_CHANGED"] = "FormActionKind:FIELD_VALUE_CHANGED";
|
|
16
|
+
FormActionKind["FIELD_FOCUSED"] = "FormActionKind:FIELD_FOCUSED";
|
|
17
|
+
FormActionKind["FIELD_VALIDATED"] = "FormActionKind:FIELD_VALIDATED";
|
|
18
|
+
FormActionKind["FIELD_INITIALIZED"] = "FormActionKind:FIELD_INITIALIZED";
|
|
19
|
+
FormActionKind["TRIED_TO_SUBMIT"] = "FormActionKind:TRIED_TO_SUBMIT";
|
|
20
|
+
FormActionKind["BACKEND_VALIDATION_ARRIVED"] = "FormActionKind:BACKEND_VALIDATION_ARRIVED";
|
|
21
|
+
FormActionKind["SUBMITTED"] = "FormActionKind:SUBMITTED";
|
|
22
|
+
})(FormActionKind || (exports.FormActionKind = FormActionKind = {}));
|
|
23
|
+
function fieldInitialized(uid, value) {
|
|
24
|
+
return {
|
|
25
|
+
type: FormActionKind.FIELD_INITIALIZED,
|
|
26
|
+
payload: {
|
|
27
|
+
uid,
|
|
28
|
+
value,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function fieldChanged(uid, value) {
|
|
33
|
+
return {
|
|
34
|
+
type: FormActionKind.FIELD_VALUE_CHANGED,
|
|
35
|
+
payload: {
|
|
36
|
+
uid,
|
|
37
|
+
value,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function fieldFocused(uid) {
|
|
42
|
+
return {
|
|
43
|
+
type: FormActionKind.FIELD_FOCUSED,
|
|
44
|
+
payload: {
|
|
45
|
+
uid,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function fieldLostFocus(uid) {
|
|
50
|
+
return {
|
|
51
|
+
type: FormActionKind.FIELD_LOST_FOCUS,
|
|
52
|
+
payload: {
|
|
53
|
+
uid,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function fieldValidated(uid, validationResult) {
|
|
58
|
+
return {
|
|
59
|
+
type: FormActionKind.FIELD_VALIDATED,
|
|
60
|
+
payload: {
|
|
61
|
+
uid,
|
|
62
|
+
validationResult,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function triedToSubmit() {
|
|
67
|
+
return {
|
|
68
|
+
type: FormActionKind.TRIED_TO_SUBMIT,
|
|
69
|
+
payload: {},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function formSubmitted() {
|
|
73
|
+
return {
|
|
74
|
+
type: FormActionKind.SUBMITTED,
|
|
75
|
+
payload: {},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function backendValidationArrived({ generalValidationResults = [], fieldValidationResults = {} }) {
|
|
79
|
+
return {
|
|
80
|
+
type: FormActionKind.BACKEND_VALIDATION_ARRIVED,
|
|
81
|
+
payload: {
|
|
82
|
+
generalValidationResults,
|
|
83
|
+
fieldValidationResults
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.formItemComponentRenderer = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const renderers_1 = require("@components-core/renderers");
|
|
21
|
+
const themeVars_1 = require("@components-core/theming/themeVars");
|
|
22
|
+
const FormItem_module_scss_1 = __importDefault(require("./FormItem.module.scss"));
|
|
23
|
+
const FormContext_1 = require("@components/Form/FormContext");
|
|
24
|
+
const TextBox_1 = require("@components/TextBox/TextBox");
|
|
25
|
+
const Toggle_1 = require("@components/Toggle/Toggle");
|
|
26
|
+
const FileInput_1 = require("@components/FileInput/FileInput");
|
|
27
|
+
const NumberBox_1 = require("@components/NumberBox/NumberBox");
|
|
28
|
+
const Select_1 = require("@components/Select/Select");
|
|
29
|
+
const RadioGroup_1 = require("@components/RadioGroup/RadioGroup");
|
|
30
|
+
const HelperText_1 = require("@components/FormItem/HelperText");
|
|
31
|
+
const react_2 = require("@formkit/auto-animate/react");
|
|
32
|
+
const Validations_1 = require("./Validations");
|
|
33
|
+
const Combobox_1 = require("@components/Combobox/Combobox");
|
|
34
|
+
const MultiCombobox_1 = require("@components/MultiCombobox/MultiCombobox");
|
|
35
|
+
const formActions_1 = require("@components/Form/formActions");
|
|
36
|
+
const TextArea_1 = require("@components/TextArea/TextArea");
|
|
37
|
+
const misc_1 = require("@components-core/utils/misc");
|
|
38
|
+
const MultiSelect_1 = require("@components/MultiSelect/MultiSelect");
|
|
39
|
+
const ItemWithLabel_1 = require("./ItemWithLabel");
|
|
40
|
+
const DatePicker_1 = require("@components/DatePicker/DatePicker");
|
|
41
|
+
const Form_1 = require("@components/Form/Form");
|
|
42
|
+
const valueExtractor_1 = require("@components-core/container/valueExtractor");
|
|
43
|
+
const DEFAULT_LABEL_POSITIONS = {
|
|
44
|
+
checkbox: "right",
|
|
45
|
+
};
|
|
46
|
+
const FormItem = (0, react_1.memo)(function FormItem(_a) {
|
|
47
|
+
var { style, bindTo, type = "text", label, enabled = true, labelPosition, labelWidth, labelBreak = true, children, validations, onValidate, customValidationsDebounce, validationMode, registerComponentApi, syncToValidation = true, maxTextLength } = _a, rest = __rest(_a, ["style", "bindTo", "type", "label", "enabled", "labelPosition", "labelWidth", "labelBreak", "children", "validations", "onValidate", "customValidationsDebounce", "validationMode", "registerComponentApi", "syncToValidation", "maxTextLength"]);
|
|
48
|
+
const labelWidthValue = (0, FormContext_1.useFormContextPart)((value) => labelWidth || value.itemLabelWidth);
|
|
49
|
+
const labelBreakValue = (0, FormContext_1.useFormContextPart)((value) => (labelBreak !== undefined ? labelBreak : value.itemLabelBreak));
|
|
50
|
+
const labelPositionValue = (0, FormContext_1.useFormContextPart)((value) => labelPosition || value.itemLabelPosition || DEFAULT_LABEL_POSITIONS[type]);
|
|
51
|
+
const initialValueFromSubject = (0, FormContext_1.useFormContextPart)((value) => (0, Form_1.getByPath)(value.originalSubject, bindTo));
|
|
52
|
+
const initialValue = initialValueFromSubject === undefined ? rest.initialValue : initialValueFromSubject;
|
|
53
|
+
const value = (0, FormContext_1.useFormContextPart)((value) => (0, Form_1.getByPath)(value.subject, bindTo));
|
|
54
|
+
const validationResult = (0, FormContext_1.useFormContextPart)((value) => value.validationResults[bindTo]);
|
|
55
|
+
const dispatch = (0, FormContext_1.useFormContextPart)((value) => value.dispatch);
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
dispatch((0, formActions_1.fieldInitialized)(bindTo, initialValue));
|
|
58
|
+
}, [bindTo, dispatch, initialValue]);
|
|
59
|
+
(0, Validations_1.useValidation)(validations, onValidate, value, dispatch, bindTo, customValidationsDebounce);
|
|
60
|
+
const onStateChange = (0, react_1.useCallback)(({ value }) => {
|
|
61
|
+
dispatch((0, formActions_1.fieldChanged)(bindTo, value));
|
|
62
|
+
}, [bindTo, dispatch]);
|
|
63
|
+
const { validationStatus, isHelperTextShown } = (0, Validations_1.useValidationDisplay)(bindTo, value, validationResult, validationMode);
|
|
64
|
+
let formControl = null;
|
|
65
|
+
switch (type) {
|
|
66
|
+
case "combobox": {
|
|
67
|
+
formControl = ((0, jsx_runtime_1.jsx)(Combobox_1.Combobox, Object.assign({}, rest, { value: value, updateState: onStateChange, enabled: enabled, validationStatus: validationStatus, registerComponentApi: registerComponentApi, children: children })));
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case "multiCombobox": {
|
|
71
|
+
formControl = ((0, jsx_runtime_1.jsx)(MultiCombobox_1.MultiCombobox, Object.assign({}, rest, { value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: enabled, validationStatus: validationStatus, children: children })));
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case "select": {
|
|
75
|
+
formControl = ((0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({}, rest, { value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: enabled, validationStatus: validationStatus, children: children })));
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case "multiSelect": {
|
|
79
|
+
formControl = ((0, jsx_runtime_1.jsx)(MultiSelect_1.MultiSelect, Object.assign({}, rest, { value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: enabled, validationStatus: validationStatus, children: children })));
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "datePicker": {
|
|
83
|
+
formControl = ((0, jsx_runtime_1.jsx)(DatePicker_1.DatePicker, Object.assign({}, rest, { value: value, updateState: onStateChange,
|
|
84
|
+
// registerComponentApi={registerComponentApi}
|
|
85
|
+
enabled: enabled, validationStatus: validationStatus })));
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "radioGroup": {
|
|
89
|
+
formControl = ((0, jsx_runtime_1.jsx)(RadioGroup_1.RadioGroup, Object.assign({}, rest, { value: value, updateState: onStateChange,
|
|
90
|
+
// registerComponentApi={registerComponentApi}
|
|
91
|
+
enabled: enabled, validationStatus: validationStatus, children: children })));
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case "number":
|
|
95
|
+
case "integer": {
|
|
96
|
+
formControl = ((0, jsx_runtime_1.jsx)(NumberBox_1.NumberBox, Object.assign({}, rest, { value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: enabled, integersOnly: type === "integer", validationStatus: validationStatus, min: syncToValidation ? validations.minValue : undefined, max: syncToValidation ? validations.maxValue : undefined, maxLength: maxTextLength !== null && maxTextLength !== void 0 ? maxTextLength : (syncToValidation ? validations === null || validations === void 0 ? void 0 : validations.maxLength : undefined) })));
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case "switch":
|
|
100
|
+
case "checkbox": {
|
|
101
|
+
formControl = ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, Object.assign({}, rest, { value: value, updateState: onStateChange,
|
|
102
|
+
// registerComponentApi={registerComponentApi}
|
|
103
|
+
enabled: enabled, validationStatus: validationStatus, variant: type })));
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case "file": {
|
|
107
|
+
formControl = ((0, jsx_runtime_1.jsx)(FileInput_1.FileInput, Object.assign({}, rest, { value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: enabled, validationStatus: validationStatus, multiple: (0, valueExtractor_1.asOptionalBoolean)(rest.multiple, false) })));
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
case "text": {
|
|
111
|
+
formControl = ((0, jsx_runtime_1.jsx)(TextBox_1.TextBox, Object.assign({}, rest, { value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: enabled, validationStatus: validationStatus, maxLength: maxTextLength !== null && maxTextLength !== void 0 ? maxTextLength : (syncToValidation ? validations === null || validations === void 0 ? void 0 : validations.maxLength : undefined) })));
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case "password": {
|
|
115
|
+
formControl = ((0, jsx_runtime_1.jsx)(TextBox_1.TextBox, Object.assign({}, rest, { type: "password", value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: enabled, validationStatus: validationStatus, maxLength: maxTextLength !== null && maxTextLength !== void 0 ? maxTextLength : (syncToValidation ? validations === null || validations === void 0 ? void 0 : validations.maxLength : undefined) })));
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "textarea": {
|
|
119
|
+
formControl = ((0, jsx_runtime_1.jsx)(TextArea_1.TextArea, Object.assign({}, rest, { value: value, updateState: onStateChange, registerComponentApi: registerComponentApi, enabled: enabled, validationStatus: validationStatus, maxLength: maxTextLength !== null && maxTextLength !== void 0 ? maxTextLength : (syncToValidation ? validations === null || validations === void 0 ? void 0 : validations.maxLength : undefined) })));
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case "custom": {
|
|
123
|
+
formControl = children;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
default: {
|
|
127
|
+
console.warn(`unknown form item type ${type}`);
|
|
128
|
+
formControl = (0, jsx_runtime_1.jsx)("div", { children: value });
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const onFocus = (0, misc_1.useEvent)(() => {
|
|
133
|
+
dispatch((0, formActions_1.fieldFocused)(bindTo));
|
|
134
|
+
});
|
|
135
|
+
const onBlur = (0, misc_1.useEvent)(() => {
|
|
136
|
+
dispatch((0, formActions_1.fieldLostFocus)(bindTo));
|
|
137
|
+
});
|
|
138
|
+
const [animateContainerRef] = (0, react_2.useAutoAnimate)({ duration: 100 });
|
|
139
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(ItemWithLabel_1.ItemWithLabel, { labelPosition: labelPositionValue, label: label, labelWidth: labelWidthValue, labelBreak: labelBreakValue, enabled: enabled, required: validations.required, validationInProgress: validationResult === null || validationResult === void 0 ? void 0 : validationResult.partial, onFocus: onFocus, onBlur: onBlur, style: style, validationResult: (0, jsx_runtime_1.jsx)("div", { ref: animateContainerRef, children: isHelperTextShown &&
|
|
140
|
+
(validationResult === null || validationResult === void 0 ? void 0 : validationResult.validations.map((singleValidation, i) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [singleValidation.isValid && singleValidation.validMessage && ((0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { text: singleValidation.validMessage, status: "valid", style: { opacity: singleValidation.stale ? 0.5 : undefined } })), !singleValidation.isValid && singleValidation.invalidMessage && ((0, jsx_runtime_1.jsx)(HelperText_1.HelperText, { text: singleValidation.invalidMessage, status: singleValidation.severity, style: { opacity: singleValidation.stale ? 0.5 : undefined } }))] }, i)))) }), children: formControl }) }));
|
|
141
|
+
});
|
|
142
|
+
function CustomFormItem({ renderChild, node, bindTo, }) {
|
|
143
|
+
const value = (0, FormContext_1.useFormContextPart)((value) => (0, Form_1.getByPath)(value.subject, bindTo));
|
|
144
|
+
const validationResult = (0, FormContext_1.useFormContextPart)((value) => value.validationResults[bindTo]);
|
|
145
|
+
const dispatch = (0, FormContext_1.useFormContextPart)((value) => value.dispatch);
|
|
146
|
+
const decoratedMetadata = (0, react_1.useMemo)(() => {
|
|
147
|
+
return {
|
|
148
|
+
type: "Container",
|
|
149
|
+
uid: "formFieldContainer - " + bindTo,
|
|
150
|
+
vars: node.vars,
|
|
151
|
+
contextVars: {
|
|
152
|
+
$value: value,
|
|
153
|
+
$setValue: (newValue) => {
|
|
154
|
+
dispatch((0, formActions_1.fieldChanged)(bindTo, newValue));
|
|
155
|
+
},
|
|
156
|
+
$validationResult: validationResult,
|
|
157
|
+
},
|
|
158
|
+
children: node.children,
|
|
159
|
+
};
|
|
160
|
+
}, [bindTo, dispatch, node.children, node.vars, validationResult, value]);
|
|
161
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: renderChild(decoratedMetadata) });
|
|
162
|
+
}
|
|
163
|
+
const metadata = {
|
|
164
|
+
themeVars: (0, themeVars_1.parseScssVar)(FormItem_module_scss_1.default.themeVars),
|
|
165
|
+
defaultThemeVars: {
|
|
166
|
+
"color-text-FormItemLabel": "$color-text-primary",
|
|
167
|
+
"font-size-FormItemLabel": "$font-size-small",
|
|
168
|
+
"font-weight-FormItemLabel": "$font-weight-bold",
|
|
169
|
+
"font-style-FormItemLabel": "normal",
|
|
170
|
+
"text-transform-FormItemLabel": "none",
|
|
171
|
+
"color-text-FormItemLabel-requiredMark": "$color-danger-400",
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
exports.formItemComponentRenderer = (0, renderers_1.createComponentRenderer)("FormItem", ({ node, renderChild, extractValue, layoutCss, lookupEventHandler, lookupAction, registerComponentApi }) => {
|
|
175
|
+
const _a = node.props, { bindTo, autoFocus, label, labelPosition, labelWidth, labelBreak, enabled, required, type, requiredInvalidMessage, minLength, maxLength, lengthInvalidMessage, lengthInvalidSeverity, minValue, maxValue, rangeInvalidMessage, rangeInvalidSeverity, pattern, patternInvalidMessage, patternInvalidSeverity, regex, regexInvalidMessage, regexInvalidSeverity, customValidationsDebounce, validationMode, syncToValidation, maxTextLength } = _a, rest = __rest(_a, ["bindTo", "autoFocus", "label", "labelPosition", "labelWidth", "labelBreak", "enabled", "required", "type", "requiredInvalidMessage", "minLength", "maxLength", "lengthInvalidMessage", "lengthInvalidSeverity", "minValue", "maxValue", "rangeInvalidMessage", "rangeInvalidSeverity", "pattern", "patternInvalidMessage", "patternInvalidSeverity", "regex", "regexInvalidMessage", "regexInvalidSeverity", "customValidationsDebounce", "validationMode", "syncToValidation", "maxTextLength"]);
|
|
176
|
+
//extractValue works as a memoization mechanism too (if there's nothing to resolve, it won't produce a new object every time)
|
|
177
|
+
const resolvedValidationPropsAndEvents = extractValue({
|
|
178
|
+
required: extractValue.asOptionalBoolean(required),
|
|
179
|
+
requiredInvalidMessage: extractValue.asOptionalString(requiredInvalidMessage),
|
|
180
|
+
minLength: extractValue.asOptionalNumber(minLength),
|
|
181
|
+
maxLength: extractValue.asOptionalNumber(maxLength),
|
|
182
|
+
lengthInvalidMessage: extractValue.asOptionalString(lengthInvalidMessage),
|
|
183
|
+
lengthInvalidSeverity: (0, Validations_1.parseSeverity)(extractValue.asOptionalString(lengthInvalidSeverity)),
|
|
184
|
+
minValue: extractValue.asOptionalNumber(minValue),
|
|
185
|
+
maxValue: extractValue.asOptionalNumber(maxValue),
|
|
186
|
+
rangeInvalidMessage: extractValue.asOptionalString(rangeInvalidMessage),
|
|
187
|
+
rangeInvalidSeverity: (0, Validations_1.parseSeverity)(extractValue.asOptionalString(rangeInvalidSeverity)),
|
|
188
|
+
pattern: extractValue.asOptionalString(pattern),
|
|
189
|
+
patternInvalidMessage: extractValue.asOptionalString(patternInvalidMessage),
|
|
190
|
+
patternInvalidSeverity: (0, Validations_1.parseSeverity)(extractValue.asOptionalString(patternInvalidSeverity)),
|
|
191
|
+
regex: extractValue.asOptionalString(regex),
|
|
192
|
+
regexInvalidMessage: extractValue.asOptionalString(regexInvalidMessage),
|
|
193
|
+
regexInvalidSeverity: (0, Validations_1.parseSeverity)(extractValue.asOptionalString(regexInvalidSeverity)),
|
|
194
|
+
});
|
|
195
|
+
const nonLayoutCssProps = !layoutCss
|
|
196
|
+
? rest
|
|
197
|
+
: Object.fromEntries(Object.entries(rest).filter(([key, _]) => {
|
|
198
|
+
return !(layoutCss === null || layoutCss === void 0 ? void 0 : layoutCss.hasOwnProperty(key));
|
|
199
|
+
}));
|
|
200
|
+
const resolvedRestProps = extractValue(nonLayoutCssProps);
|
|
201
|
+
const formItemType = extractValue.asOptionalString(type);
|
|
202
|
+
const isCustomFormItem = formItemType === undefined && !!node.children;
|
|
203
|
+
return ((0, jsx_runtime_1.jsx)(FormItem, Object.assign({ style: layoutCss, labelBreak: extractValue.asOptionalBoolean(labelBreak), labelWidth: extractValue.asOptionalString(labelWidth), bindTo: extractValue.asString(bindTo), autoFocus: extractValue.asOptionalBoolean(autoFocus), enabled: extractValue.asOptionalBoolean(enabled), label: extractValue.asOptionalString(label), labelPosition: extractValue.asOptionalString(labelPosition), type: isCustomFormItem ? "custom" : formItemType, validations: resolvedValidationPropsAndEvents, onValidate: lookupEventHandler("validate"), customValidationsDebounce: extractValue.asOptionalNumber(customValidationsDebounce), validationMode: extractValue.asOptionalString(validationMode), registerComponentApi: registerComponentApi, syncToValidation: extractValue.asOptionalBoolean(syncToValidation), maxTextLength: extractValue(maxTextLength) }, resolvedRestProps, { children: isCustomFormItem ? ((0, jsx_runtime_1.jsx)(CustomFormItem, { renderChild: renderChild, node: node, bindTo: extractValue.asString(bindTo) })) : (renderChild(node.children)) })));
|
|
204
|
+
}, metadata);
|
|
@@ -0,0 +1,27 @@
|
|
|
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.HelperText = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const classnames_1 = __importDefault(require("@components-core/utils/classnames"));
|
|
9
|
+
const HelperText_module_scss_1 = __importDefault(require("./HelperText.module.scss"));
|
|
10
|
+
const WarningIcon_1 = require("@components/Icon/WarningIcon");
|
|
11
|
+
const ErrorIcon_1 = require("@components/Icon/ErrorIcon");
|
|
12
|
+
const HelperText = ({ text = "", status, style }) => {
|
|
13
|
+
const renderStatusIcon = () => {
|
|
14
|
+
if (status === "warning") {
|
|
15
|
+
return (0, jsx_runtime_1.jsx)(WarningIcon_1.WarningIcon, { color: "var(--xmlui-color-warning)" });
|
|
16
|
+
}
|
|
17
|
+
else if (status === "error") {
|
|
18
|
+
return (0, jsx_runtime_1.jsx)(ErrorIcon_1.ErrorIcon, { color: "var(--xmlui-color-error)" });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: style, className: (0, classnames_1.default)(HelperText_module_scss_1.default.helper, {
|
|
22
|
+
[HelperText_module_scss_1.default.valid]: status === "valid",
|
|
23
|
+
[HelperText_module_scss_1.default.warning]: status === "warning",
|
|
24
|
+
[HelperText_module_scss_1.default.error]: status === "error",
|
|
25
|
+
}), children: [status && (0, jsx_runtime_1.jsx)("div", { style: { flexShrink: 0 }, children: renderStatusIcon() }), text && (0, jsx_runtime_1.jsx)("div", { className: HelperText_module_scss_1.default.helperText, children: text })] }));
|
|
26
|
+
};
|
|
27
|
+
exports.HelperText = HelperText;
|