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,499 @@
|
|
|
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.tableComponentRenderer = exports.Table = void 0;
|
|
16
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const fi_1 = require("react-icons/fi");
|
|
19
|
+
const react_table_1 = require("@tanstack/react-table");
|
|
20
|
+
const Table_module_scss_1 = __importDefault(require("./Table.module.scss"));
|
|
21
|
+
require("./react-table-config.d.ts");
|
|
22
|
+
const Button_1 = require("@components/Button/Button");
|
|
23
|
+
const Spinner_1 = require("@components/Spinner/Spinner");
|
|
24
|
+
const classnames_1 = __importDefault(require("@components-core/utils/classnames"));
|
|
25
|
+
const useRowSelection_1 = __importDefault(require("./useRowSelection"));
|
|
26
|
+
const Toggle_1 = require("@components/Toggle/Toggle");
|
|
27
|
+
const Icon_1 = require("@components/Icon/Icon");
|
|
28
|
+
const react_virtual_1 = require("@tanstack/react-virtual");
|
|
29
|
+
const lodash_es_1 = require("lodash-es");
|
|
30
|
+
const renderers_1 = require("@components-core/renderers");
|
|
31
|
+
const constants_1 = require("@components-core/constants");
|
|
32
|
+
const ScrollContext_1 = require("@components-core/ScrollContext");
|
|
33
|
+
const themeVars_1 = require("@components-core/theming/themeVars");
|
|
34
|
+
const descriptorHelper_1 = require("@components-core/descriptorHelper");
|
|
35
|
+
const TableContext_1 = require("../TableColumnDef/TableContext");
|
|
36
|
+
const immer_1 = __importDefault(require("immer"));
|
|
37
|
+
const misc_1 = require("@components-core/utils/misc");
|
|
38
|
+
const react_dom_1 = require("react-dom");
|
|
39
|
+
const hooks_1 = require("@components-core/utils/hooks");
|
|
40
|
+
function defaultIsRowDisabled(_) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const SELECT_COLUMN_WIDTH = 42;
|
|
44
|
+
const DEFAULT_PAGE_SIZES = [10, 50, 100];
|
|
45
|
+
//These are the important styles to make sticky column pinning work!
|
|
46
|
+
//Apply styles like this using your CSS strategy of choice with this kind of logic to head cells, data cells, footer cells, etc.
|
|
47
|
+
//View the index.css file for more needed styles such as border-collapse: separate
|
|
48
|
+
const getCommonPinningStyles = (column) => {
|
|
49
|
+
const isPinned = column.getIsPinned();
|
|
50
|
+
// const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
|
|
51
|
+
// const isFirstRightPinnedColumn = isPinned === "right" && column.getIsFirstColumn("right");
|
|
52
|
+
return {
|
|
53
|
+
// boxShadow: isLastLeftPinnedColumn
|
|
54
|
+
// ? "-4px 0 4px -4px gray inset"
|
|
55
|
+
// : isFirstRightPinnedColumn
|
|
56
|
+
// ? "4px 0 4px -4px gray inset"
|
|
57
|
+
// : undefined,
|
|
58
|
+
left: isPinned === "left" ? `${column.getStart("left")}px` : undefined,
|
|
59
|
+
right: isPinned === "right" ? `${column.getAfter("right")}px` : undefined,
|
|
60
|
+
opacity: isPinned ? 0.95 : undefined,
|
|
61
|
+
position: isPinned ? "sticky" : "relative",
|
|
62
|
+
backgroundColor: isPinned ? "inherit" : undefined,
|
|
63
|
+
zIndex: isPinned ? 1 : undefined,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const Table = ({ data = constants_1.EMPTY_ARRAY, columns = constants_1.EMPTY_ARRAY, isPaginated = false, loading = false, headerHeight, rowsSelectable = false, enableMultiRowSelection = true, pageSizes = DEFAULT_PAGE_SIZES, rowDisabledPredicate = defaultIsRowDisabled, sortBy, sortingDirection = "ascending", sortingDidChange, willSort, style, noDataRenderer, autoFocus = false, hideHeader = false, children, }) => {
|
|
67
|
+
var _a, _b, _c, _d;
|
|
68
|
+
const [stableColumns, setStableColumns] = (0, react_1.useState)(columns);
|
|
69
|
+
const wrapperRef = (0, react_1.useRef)(null);
|
|
70
|
+
const tableRef = (0, react_1.useRef)(null);
|
|
71
|
+
const estimatedHeightRef = (0, react_1.useRef)(null);
|
|
72
|
+
const safeColumns = (0, react_1.useMemo)(() => {
|
|
73
|
+
if (stableColumns) {
|
|
74
|
+
return stableColumns;
|
|
75
|
+
}
|
|
76
|
+
if (!data.length) {
|
|
77
|
+
return constants_1.EMPTY_ARRAY;
|
|
78
|
+
}
|
|
79
|
+
return Object.keys(data[0]).map((key) => ({ header: key, accessorKey: key }));
|
|
80
|
+
}, [stableColumns, data]);
|
|
81
|
+
(0, react_1.useEffect)(() => {
|
|
82
|
+
if (autoFocus) {
|
|
83
|
+
wrapperRef.current.focus();
|
|
84
|
+
}
|
|
85
|
+
}, [autoFocus]);
|
|
86
|
+
// --- Keep track of visible table rows
|
|
87
|
+
const [visibleItems, setVisibleItems] = (0, react_1.useState)(constants_1.EMPTY_ARRAY);
|
|
88
|
+
// --- Get the operations to manage selected rows in a table
|
|
89
|
+
const { toggleRow, checkAllRows, focusedIndex, onKeyDown, selectedRowIdMap, idKey } = (0, useRowSelection_1.default)(visibleItems);
|
|
90
|
+
// --- Create data with order information whenever the items in the table change
|
|
91
|
+
const dataWithOrder = (0, react_1.useMemo)(() => {
|
|
92
|
+
return data.map((item, index) => {
|
|
93
|
+
return Object.assign(Object.assign({}, item), { order: index + 1 });
|
|
94
|
+
});
|
|
95
|
+
}, [data]);
|
|
96
|
+
// --- Local or external sorting of data
|
|
97
|
+
const [_sortBy, _setSortBy] = (0, react_1.useState)(sortBy);
|
|
98
|
+
const [_sortingDirection, _setSortingDirection] = (0, react_1.useState)(sortingDirection);
|
|
99
|
+
(0, react_1.useEffect)(() => {
|
|
100
|
+
_setSortBy(sortBy);
|
|
101
|
+
}, [sortBy]);
|
|
102
|
+
(0, react_1.useEffect)(() => {
|
|
103
|
+
_setSortingDirection(sortingDirection);
|
|
104
|
+
}, [sortingDirection]);
|
|
105
|
+
const [sortedData, setSortedData] = (0, react_1.useState)(dataWithOrder);
|
|
106
|
+
(0, react_1.useEffect)(() => {
|
|
107
|
+
if (!_sortBy) {
|
|
108
|
+
setSortedData(dataWithOrder);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
+
const result = yield (willSort === null || willSort === void 0 ? void 0 : willSort(_sortBy, _sortingDirection));
|
|
113
|
+
if (result === false) {
|
|
114
|
+
setSortedData(dataWithOrder);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
setSortedData((0, lodash_es_1.orderBy)(dataWithOrder, _sortBy, _sortingDirection === "ascending" ? "asc" : "desc"));
|
|
118
|
+
}
|
|
119
|
+
}))();
|
|
120
|
+
}, [_sortBy, _sortingDirection, dataWithOrder, willSort]);
|
|
121
|
+
const _updateSorting = (0, react_1.useCallback)((header) => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
let newDirection = "ascending";
|
|
124
|
+
let newSortBy = (_a = header.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.accessorKey;
|
|
125
|
+
// The current key is the same as the last -> the user clicked on the same header twice
|
|
126
|
+
if (_sortBy === ((_b = header.column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.accessorKey)) {
|
|
127
|
+
// The last sorting direction was ascending -> make it descending
|
|
128
|
+
if (_sortingDirection === "ascending") {
|
|
129
|
+
newDirection = "descending";
|
|
130
|
+
// The last sorting direction was descending -> remove the sorting from the current key
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
newSortBy = undefined;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// --- Check if sorting is allowed
|
|
137
|
+
const result = yield (willSort === null || willSort === void 0 ? void 0 : willSort(newSortBy, newDirection));
|
|
138
|
+
if (result === false) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
_setSortingDirection(newDirection);
|
|
142
|
+
_setSortBy(newSortBy);
|
|
143
|
+
// External callback function is always called.
|
|
144
|
+
// Even if sorting is internal, we can notify other components through this callback
|
|
145
|
+
sortingDidChange === null || sortingDidChange === void 0 ? void 0 : sortingDidChange(newSortBy, newDirection);
|
|
146
|
+
}), [sortingDidChange, _sortBy, _sortingDirection]);
|
|
147
|
+
// --- Prepare column renderers according to columns defined in the table
|
|
148
|
+
const columnsWithCustomCell = (0, react_1.useMemo)(() => {
|
|
149
|
+
return safeColumns.map((col) => {
|
|
150
|
+
var _a, _b;
|
|
151
|
+
// --- Obtain column width information
|
|
152
|
+
const { width, starSizedWidth } = getColumnWidth(col.width, true, "width");
|
|
153
|
+
const { width: minWidth } = getColumnWidth(col.minWidth, false, "minWidth");
|
|
154
|
+
const { width: maxWidth } = getColumnWidth(col.maxWidth, false, "maxWidth");
|
|
155
|
+
const customColumn = Object.assign(Object.assign({}, col), { header: (_b = (_a = col.header) !== null && _a !== void 0 ? _a : col.accessorKey) !== null && _b !== void 0 ? _b : " ", size: width, minSize: minWidth, maxSize: maxWidth, enableResizing: col.canResize, enableSorting: col.canSort, enablePinning: col.pinTo !== undefined, meta: {
|
|
156
|
+
starSizedWidth,
|
|
157
|
+
pinTo: col.pinTo,
|
|
158
|
+
style: col.style,
|
|
159
|
+
accessorKey: col.accessorKey,
|
|
160
|
+
cellRenderer: col.cellRenderer,
|
|
161
|
+
} });
|
|
162
|
+
return customColumn;
|
|
163
|
+
function getColumnWidth(colWidth, allowStarSize, propName) {
|
|
164
|
+
let starSizedWidth;
|
|
165
|
+
let width;
|
|
166
|
+
if (typeof colWidth === "number") {
|
|
167
|
+
width = colWidth;
|
|
168
|
+
}
|
|
169
|
+
else if (typeof colWidth === "string") {
|
|
170
|
+
const oneStarSizedWidthMatch = colWidth.match(/^\s*\*\s*$/);
|
|
171
|
+
if (allowStarSize && oneStarSizedWidthMatch) {
|
|
172
|
+
starSizedWidth = "1*";
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const starSizedWidthMatch = colWidth.match(/^\s*(\d+)\s*\*\s*$/);
|
|
176
|
+
if (allowStarSize && starSizedWidthMatch) {
|
|
177
|
+
starSizedWidth = starSizedWidthMatch[1] + "*";
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const pixelWidthMatch = colWidth.match(/^\s*(\d+)\s*(px)?\s*$/);
|
|
181
|
+
if (pixelWidthMatch) {
|
|
182
|
+
width = Number(pixelWidthMatch[1]);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
throw new Error(`Invalid TableColumnDef '${propName}' value`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (width === undefined && starSizedWidth === undefined && allowStarSize) {
|
|
191
|
+
starSizedWidth = "1*";
|
|
192
|
+
}
|
|
193
|
+
return { width, starSizedWidth };
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}, [rowsSelectable, safeColumns]);
|
|
197
|
+
// --- Prepare column renderers according to columns defined in the table supporting optional row selection
|
|
198
|
+
const columnsWithSelectColumn = (0, react_1.useMemo)(() => {
|
|
199
|
+
// --- Extend the columns with a selection checkbox (indeterminate)
|
|
200
|
+
const selectColumn = {
|
|
201
|
+
id: "select",
|
|
202
|
+
size: SELECT_COLUMN_WIDTH,
|
|
203
|
+
enableResizing: false,
|
|
204
|
+
enablePinning: true,
|
|
205
|
+
meta: {
|
|
206
|
+
pinTo: "left",
|
|
207
|
+
},
|
|
208
|
+
header: ({ table }) => enableMultiRowSelection ? ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { className: Table_module_scss_1.default.checkBoxWrapper,
|
|
209
|
+
value: table.getIsAllRowsSelected(),
|
|
210
|
+
indeterminate: table.getIsSomeRowsSelected(),
|
|
211
|
+
onDidChange: (checked) => {
|
|
212
|
+
checkAllRows(checked);
|
|
213
|
+
} })) : null,
|
|
214
|
+
cell: ({ row }) => ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { className: Table_module_scss_1.default.checkBoxWrapper,
|
|
215
|
+
value: row.getIsSelected(),
|
|
216
|
+
indeterminate: row.getIsSomeSelected(),
|
|
217
|
+
onDidChange: () => {
|
|
218
|
+
toggleRow(row.original, { metaKey: enableMultiRowSelection });
|
|
219
|
+
} })),
|
|
220
|
+
};
|
|
221
|
+
return rowsSelectable ? [selectColumn, ...columnsWithCustomCell] : columnsWithCustomCell;
|
|
222
|
+
}, [columnsWithCustomCell, toggleRow, rowsSelectable, checkAllRows]);
|
|
223
|
+
// --- Set up page information (using the first page size option)
|
|
224
|
+
const [{ pageIndex, pageSize }, setPagination] = (0, react_1.useState)({
|
|
225
|
+
pageIndex: 0,
|
|
226
|
+
pageSize: pageSizes[0],
|
|
227
|
+
});
|
|
228
|
+
// --- Update pagination info whenever the pae size or page index changes
|
|
229
|
+
const pagination = (0, react_1.useMemo)(() => ({
|
|
230
|
+
pageIndex,
|
|
231
|
+
pageSize,
|
|
232
|
+
}), [pageIndex, pageSize]);
|
|
233
|
+
const [columnSizing, setColumnSizing] = (0, react_1.useState)({});
|
|
234
|
+
const columnPinning = (0, react_1.useMemo)(() => {
|
|
235
|
+
const left = [];
|
|
236
|
+
const right = [];
|
|
237
|
+
columnsWithSelectColumn.forEach((col) => {
|
|
238
|
+
var _a, _b;
|
|
239
|
+
if (((_a = col.meta) === null || _a === void 0 ? void 0 : _a.pinTo) === "right") {
|
|
240
|
+
right.push(col.id);
|
|
241
|
+
}
|
|
242
|
+
if (((_b = col.meta) === null || _b === void 0 ? void 0 : _b.pinTo) === "left") {
|
|
243
|
+
left.push(col.id);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
return {
|
|
247
|
+
left,
|
|
248
|
+
right,
|
|
249
|
+
};
|
|
250
|
+
}, [columnsWithSelectColumn]);
|
|
251
|
+
// --- Use the @tanstack/core-table component that manages a table
|
|
252
|
+
const table = (0, react_table_1.useReactTable)({
|
|
253
|
+
columns: columnsWithSelectColumn,
|
|
254
|
+
data: sortedData,
|
|
255
|
+
getCoreRowModel: (0, react_table_1.getCoreRowModel)(),
|
|
256
|
+
getPaginationRowModel: isPaginated ? (0, react_table_1.getPaginationRowModel)() : undefined,
|
|
257
|
+
enableRowSelection: rowsSelectable,
|
|
258
|
+
enableMultiRowSelection,
|
|
259
|
+
columnResizeMode: "onChange",
|
|
260
|
+
getRowId: (0, react_1.useCallback)((originalRow) => {
|
|
261
|
+
return originalRow[idKey] + "";
|
|
262
|
+
}, [idKey]),
|
|
263
|
+
state: (0, react_1.useMemo)(() => ({
|
|
264
|
+
pagination,
|
|
265
|
+
rowSelection: selectedRowIdMap,
|
|
266
|
+
columnSizing,
|
|
267
|
+
columnPinning,
|
|
268
|
+
}), [columnPinning, columnSizing, pagination, selectedRowIdMap]),
|
|
269
|
+
onColumnSizingChange: setColumnSizing,
|
|
270
|
+
onPaginationChange: setPagination,
|
|
271
|
+
});
|
|
272
|
+
// --- Select the set of visible rows whenever the table rows change
|
|
273
|
+
const rows = table.getRowModel().rows;
|
|
274
|
+
(0, react_1.useEffect)(() => {
|
|
275
|
+
setVisibleItems(rows.map((row) => row.original));
|
|
276
|
+
}, [rows]);
|
|
277
|
+
const scrollRef = (0, react_1.useContext)(ScrollContext_1.ScrollContext);
|
|
278
|
+
const hasOutsideScroll = scrollRef && (style === null || style === void 0 ? void 0 : style.maxHeight) === undefined && (style === null || style === void 0 ? void 0 : style.height) === undefined && (style === null || style === void 0 ? void 0 : style.flex) === undefined;
|
|
279
|
+
const myObserveElementOffset = (0, react_1.useCallback)((instance, cb) => {
|
|
280
|
+
return (0, react_virtual_1.observeElementOffset)(instance, (offset, isScrolling) => {
|
|
281
|
+
var _a;
|
|
282
|
+
//based on this: https://github.com/TanStack/virtual/issues/387
|
|
283
|
+
const parentContainerOffset = !hasOutsideScroll ? 0 : ((_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.offsetTop) || 0;
|
|
284
|
+
cb(offset - parentContainerOffset, isScrolling);
|
|
285
|
+
});
|
|
286
|
+
}, [hasOutsideScroll]);
|
|
287
|
+
const rowVirtualizer = (0, react_virtual_1.useVirtualizer)({
|
|
288
|
+
count: rows.length,
|
|
289
|
+
getScrollElement: (0, react_1.useCallback)(() => {
|
|
290
|
+
return hasOutsideScroll && (scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) ? scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current : wrapperRef.current;
|
|
291
|
+
}, [scrollRef, hasOutsideScroll]),
|
|
292
|
+
observeElementOffset: myObserveElementOffset,
|
|
293
|
+
estimateSize: (0, react_1.useCallback)(() => {
|
|
294
|
+
return estimatedHeightRef.current || 30;
|
|
295
|
+
}, []),
|
|
296
|
+
overscan: 5,
|
|
297
|
+
});
|
|
298
|
+
const paddingTop = rowVirtualizer.getVirtualItems().length > 0 ? ((_b = (_a = rowVirtualizer.getVirtualItems()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.start) || 0 : 0;
|
|
299
|
+
const paddingBottom = rowVirtualizer.getVirtualItems().length > 0
|
|
300
|
+
? rowVirtualizer.getTotalSize() -
|
|
301
|
+
(((_d = (_c = rowVirtualizer.getVirtualItems()) === null || _c === void 0 ? void 0 : _c[rowVirtualizer.getVirtualItems().length - 1]) === null || _d === void 0 ? void 0 : _d.end) || 0)
|
|
302
|
+
: 0;
|
|
303
|
+
const tableContextValue = (0, react_1.useMemo)(() => {
|
|
304
|
+
return {
|
|
305
|
+
registerColumn: (column) => {
|
|
306
|
+
setStableColumns((0, immer_1.default)((draft) => {
|
|
307
|
+
const existing = draft.findIndex((col) => col.id === column.id);
|
|
308
|
+
if (existing < 0) {
|
|
309
|
+
draft.push(column);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
draft[existing] = column;
|
|
313
|
+
}
|
|
314
|
+
draft.sort((a, b) => a.index - b.index);
|
|
315
|
+
}));
|
|
316
|
+
},
|
|
317
|
+
unRegisterColumn: (id) => {
|
|
318
|
+
setStableColumns((0, immer_1.default)((draft) => {
|
|
319
|
+
return draft.filter((col) => col.id !== id);
|
|
320
|
+
}));
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
}, []);
|
|
324
|
+
const hasData = data.length !== 0;
|
|
325
|
+
const touchedSizesRef = (0, react_1.useRef)({});
|
|
326
|
+
const columnSizeTouched = (0, react_1.useCallback)((id) => {
|
|
327
|
+
touchedSizesRef.current[id] = true;
|
|
328
|
+
}, []);
|
|
329
|
+
const recalculateStarSizes = (0, misc_1.useEvent)(() => {
|
|
330
|
+
if (!tableRef.current) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
let availableWidth = tableRef.current.clientWidth - 1;
|
|
334
|
+
// -1 to prevent horizontal scroll in scaled browsers (when you zoom in)
|
|
335
|
+
const widths = {};
|
|
336
|
+
const columnsWithoutSize = [];
|
|
337
|
+
const numberOfUnitsById = {};
|
|
338
|
+
table.getAllColumns().forEach((column) => {
|
|
339
|
+
var _a, _b;
|
|
340
|
+
if (column.columnDef.size !== undefined || touchedSizesRef.current[column.id]) {
|
|
341
|
+
availableWidth -= columnSizing[column.id] || column.columnDef.size || 0;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
columnsWithoutSize.push(column);
|
|
345
|
+
let units;
|
|
346
|
+
if ((_a = column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.starSizedWidth) {
|
|
347
|
+
units = Number((_b = column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.starSizedWidth.replace("*", "").trim()) || 1;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
units = 1;
|
|
351
|
+
}
|
|
352
|
+
numberOfUnitsById[column.id] = units;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
const numberOfAllUnits = Object.values(numberOfUnitsById).reduce((acc, val) => acc + val, 0);
|
|
356
|
+
columnsWithoutSize.forEach((column) => {
|
|
357
|
+
widths[column.id] = Math.floor(availableWidth * (numberOfUnitsById[column.id] / numberOfAllUnits));
|
|
358
|
+
});
|
|
359
|
+
(0, react_dom_1.flushSync)(() => {
|
|
360
|
+
setColumnSizing((prev) => {
|
|
361
|
+
return Object.assign(Object.assign({}, prev), widths);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
(0, hooks_1.useResizeObserver)(tableRef, recalculateStarSizes);
|
|
366
|
+
(0, hooks_1.useIsomorphicLayoutEffect)(() => {
|
|
367
|
+
queueMicrotask(() => {
|
|
368
|
+
recalculateStarSizes();
|
|
369
|
+
});
|
|
370
|
+
}, [recalculateStarSizes]);
|
|
371
|
+
return ((0, jsx_runtime_1.jsxs)(TableContext_1.TableContext.Provider, { value: tableContextValue, children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(Table_module_scss_1.default.wrapper, { [Table_module_scss_1.default.noScroll]: hasOutsideScroll }), tabIndex: -1, onKeyDown: onKeyDown, ref: wrapperRef, style: style, children: [loading && !hasData && ((0, jsx_runtime_1.jsx)("div", { className: Table_module_scss_1.default.loadingWrapper, children: (0, jsx_runtime_1.jsx)(Spinner_1.Spinner, {}) })), !loading &&
|
|
372
|
+
!hasData &&
|
|
373
|
+
(noDataRenderer ? noDataRenderer() : (0, jsx_runtime_1.jsx)("div", { className: Table_module_scss_1.default.noRows, children: "No data available" })), hasData && ((0, jsx_runtime_1.jsxs)("table", { className: Table_module_scss_1.default.table, ref: tableRef, children: [!hideHeader && ((0, jsx_runtime_1.jsx)("thead", { style: { height: headerHeight }, className: Table_module_scss_1.default.headerWrapper, children: table.getHeaderGroups().map((headerGroup, headerGroupIndex) => ((0, jsx_runtime_1.jsx)("tr", { className: (0, classnames_1.default)(Table_module_scss_1.default.headerRow, {
|
|
374
|
+
[Table_module_scss_1.default.allSelected]: table.getIsAllRowsSelected(),
|
|
375
|
+
}), children: headerGroup.headers.map((header, headerIndex) => {
|
|
376
|
+
var _a, _b;
|
|
377
|
+
const style = ((_a = header.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.style) || {};
|
|
378
|
+
const headerContent = ((0, jsx_runtime_1.jsxs)("div", { className: Table_module_scss_1.default.headerContent, style: style, children: [(0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext()), (0, jsx_runtime_1.jsx)("span", { style: { display: "inline-flex", minWidth: 12 }, children: header.column.columnDef.enableSorting &&
|
|
379
|
+
((_b = header.column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.accessorKey) === _sortBy ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: _sortingDirection === "ascending" ? ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "arrowup", size: "sm" })) : ((0, jsx_runtime_1.jsx)(Icon_1.Icon, { name: "arrowdown", size: "sm" })) })) : undefined })] }));
|
|
380
|
+
const size = header.getSize();
|
|
381
|
+
return ((0, jsx_runtime_1.jsxs)("th", { className: Table_module_scss_1.default.columnCell, colSpan: header.colSpan, style: Object.assign({ position: "relative", width: size }, getCommonPinningStyles(header.column)), children: [header.isPlaceholder ? null : header.column.columnDef.enableSorting ? ((0, jsx_runtime_1.jsx)("button", { className: Table_module_scss_1.default.clickableHeader, onClick: () => _updateSorting(header), children: headerContent })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: headerContent })), header.column.getCanResize() && ((0, jsx_runtime_1.jsx)("div", { onDoubleClick: () => {
|
|
382
|
+
touchedSizesRef.current[header.column.id] = false;
|
|
383
|
+
if (header.column.columnDef.size !== undefined) {
|
|
384
|
+
header.column.resetSize();
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
recalculateStarSizes();
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
onMouseDown: (event) => {
|
|
391
|
+
columnSizeTouched(header.column.id);
|
|
392
|
+
header.getResizeHandler()(event);
|
|
393
|
+
},
|
|
394
|
+
onTouchStart: (event) => {
|
|
395
|
+
columnSizeTouched(header.column.id);
|
|
396
|
+
header.getResizeHandler()(event);
|
|
397
|
+
},
|
|
398
|
+
className: (0, classnames_1.default)(Table_module_scss_1.default.resizer, {
|
|
399
|
+
[Table_module_scss_1.default.isResizing]: header.column.getIsResizing(),
|
|
400
|
+
}) }))] }, `${header.id}-${headerIndex}`));
|
|
401
|
+
}) }, `${headerGroup.id}-${headerGroupIndex}`))) })), (0, jsx_runtime_1.jsxs)("tbody", { className: Table_module_scss_1.default.tableBody, children: [paddingTop > 0 && ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { style: { height: `${paddingTop}px` } }) })), rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
|
402
|
+
const rowIndex = virtualRow.index;
|
|
403
|
+
const row = rows[rowIndex];
|
|
404
|
+
return ((0, jsx_runtime_1.jsx)("tr", { "data-index": rowIndex, className: (0, classnames_1.default)(Table_module_scss_1.default.row, {
|
|
405
|
+
[Table_module_scss_1.default.selected]: row.getIsSelected(),
|
|
406
|
+
[Table_module_scss_1.default.focused]: focusedIndex === rowIndex,
|
|
407
|
+
[Table_module_scss_1.default.disabled]: rowDisabledPredicate(row.original),
|
|
408
|
+
}), ref: (el) => {
|
|
409
|
+
if (el && estimatedHeightRef.current === null) {
|
|
410
|
+
estimatedHeightRef.current = Math.round(el.getBoundingClientRect().height);
|
|
411
|
+
}
|
|
412
|
+
rowVirtualizer.measureElement(el);
|
|
413
|
+
}, onClick: (event) => {
|
|
414
|
+
if (event.defaultPrevented) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
toggleRow(row.original, Object.assign(Object.assign({}, event), { metaKey: enableMultiRowSelection, shiftKey: enableMultiRowSelection ? event.shiftKey : false }));
|
|
418
|
+
}, children: row.getVisibleCells().map((cell, i) => {
|
|
419
|
+
var _a, _b;
|
|
420
|
+
const cellRenderer = (_b = (_a = cell.column.columnDef) === null || _a === void 0 ? void 0 : _a.meta) === null || _b === void 0 ? void 0 : _b.cellRenderer;
|
|
421
|
+
const size = cell.column.getSize();
|
|
422
|
+
return ((0, jsx_runtime_1.jsx)("td", { className: Table_module_scss_1.default.cell, style: Object.assign({
|
|
423
|
+
// width: size,
|
|
424
|
+
width: size }, getCommonPinningStyles(cell.column)), children: cellRenderer
|
|
425
|
+
? cellRenderer(cell.row.original)
|
|
426
|
+
: (0, react_table_1.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, `${cell.id}-${i}`));
|
|
427
|
+
}) }, `${row.id}-${rowIndex}`));
|
|
428
|
+
}), paddingBottom > 0 && ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { style: { height: `${paddingBottom}px` } }) }))] })] })), isPaginated && hasData && rows.length > 0 && (
|
|
429
|
+
// --- Render the pagination controls
|
|
430
|
+
(0, jsx_runtime_1.jsxs)("div", { className: Table_module_scss_1.default.pagination, children: [(0, jsx_runtime_1.jsx)("div", { style: { flex: 1 }, children: (0, jsx_runtime_1.jsxs)("span", { className: Table_module_scss_1.default.paginationLabel, children: ["Showing ", rows[0].original.order, " to ", rows[rows.length - 1].original.order, " of ", data.length, " entries"] }) }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: Table_module_scss_1.default.paginationLabel, children: "Rows per page" }), (0, jsx_runtime_1.jsx)("select", { className: Table_module_scss_1.default.paginationSelect, value: pageSize, onChange: (e) => {
|
|
431
|
+
table.setPageSize(Number(e.target.value));
|
|
432
|
+
}, children: pageSizes.map((pageSize) => ((0, jsx_runtime_1.jsx)("option", { value: pageSize, children: pageSize }, pageSize))) })] }), (0, jsx_runtime_1.jsxs)("div", { className: Table_module_scss_1.default.paginationButtons, children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => table.setPageIndex(0), disabled: !table.getCanPreviousPage(), type: "button", variant: "ghost", children: (0, jsx_runtime_1.jsx)(fi_1.FiChevronsLeft, {}) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => table.previousPage(), disabled: !table.getCanPreviousPage(), type: "button", variant: "ghost", children: (0, jsx_runtime_1.jsx)(fi_1.FiChevronLeft, {}) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => table.nextPage(), disabled: !table.getCanNextPage(), type: "button", variant: "ghost", children: (0, jsx_runtime_1.jsx)(fi_1.FiChevronRight, {}) }), (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => table.setPageIndex(table.getPageCount() - 1), disabled: !table.getCanNextPage(), type: "button", variant: "ghost", children: (0, jsx_runtime_1.jsx)(fi_1.FiChevronsRight, {}) })] })] }))] }), children] }));
|
|
433
|
+
};
|
|
434
|
+
exports.Table = Table;
|
|
435
|
+
const tableMetadata = {
|
|
436
|
+
displayName: "Table",
|
|
437
|
+
description: "A virtualized table component with columns and cells",
|
|
438
|
+
props: {
|
|
439
|
+
items: (0, descriptorHelper_1.desc)("The items of the table"),
|
|
440
|
+
isPaginated: (0, descriptorHelper_1.desc)("Is the table paginated?"),
|
|
441
|
+
loading: (0, descriptorHelper_1.desc)("Is the table being loaded?"),
|
|
442
|
+
headerHeight: (0, descriptorHelper_1.desc)("The height of the table header"),
|
|
443
|
+
rowsSelectable: (0, descriptorHelper_1.desc)("Does the table supports row selection?"),
|
|
444
|
+
pageSizes: (0, descriptorHelper_1.desc)("A list of available page sizes the paginator displays in the UI"),
|
|
445
|
+
rowDisabledPredicate: (0, descriptorHelper_1.desc)("A function determining if a particular row is to be disabled"),
|
|
446
|
+
noDataTemplate: {
|
|
447
|
+
description: "The template displayed when the table is empty",
|
|
448
|
+
valueType: "ComponentDef",
|
|
449
|
+
},
|
|
450
|
+
sortBy: (0, descriptorHelper_1.desc)("The name of the data field the table is sorted by"),
|
|
451
|
+
sortDirection: (0, descriptorHelper_1.desc)("The sorting direction (ascending/descending)"),
|
|
452
|
+
autoFocus: (0, descriptorHelper_1.desc)("Should the table have the focus automatically?"),
|
|
453
|
+
hideHeader: (0, descriptorHelper_1.desc)("Should the header be hidden?"),
|
|
454
|
+
},
|
|
455
|
+
themeVars: (0, themeVars_1.parseScssVar)(Table_module_scss_1.default.themeVars),
|
|
456
|
+
defaultThemeVars: {
|
|
457
|
+
"color-bg-Table": "$color-bg-primary",
|
|
458
|
+
"color-bg-row-Table--hover": "$color-primary-50",
|
|
459
|
+
"color-bg-selected-Table": "$color-primary-100",
|
|
460
|
+
"color-bg-selected-Table--hover": "$color-bg-row-Table--hover",
|
|
461
|
+
"color-bg-heading-Table": "$color-bg-Table",
|
|
462
|
+
"color-bg-heading-Table--hover": "$color-surface-100",
|
|
463
|
+
"color-bg-heading-Table--active": "$color-surface-200",
|
|
464
|
+
"color-bg-pagination-Table": "$color-bg-Table",
|
|
465
|
+
"padding-horizontal-heading-Table": "$space-4",
|
|
466
|
+
"padding-vertical-heading-Table": "$space-2",
|
|
467
|
+
"padding-heading-Table": "$padding-vertical-heading-Table $padding-horizontal-heading-Table",
|
|
468
|
+
"padding-horizontal-cell-Table": "$space-4",
|
|
469
|
+
"padding-vertical-cell-Table": "$space-2",
|
|
470
|
+
"padding-cell-Table": "$padding-vertical-cell-Table $padding-horizontal-cell-Table",
|
|
471
|
+
"color-border-cell-Table": "$color-border",
|
|
472
|
+
"thickness-border-cell-Table": "$space-0_5",
|
|
473
|
+
"style-border-cell-Table": "solid",
|
|
474
|
+
"border-cell-Table": "$thickness-border-cell-Table $style-border-cell-Table $color-border-cell-Table",
|
|
475
|
+
"color-outline-heading-Table--focus": "$color-outline--focus",
|
|
476
|
+
"thickness-outline-heading-Table--focus": "$thickness-outline--focus",
|
|
477
|
+
"style-outline-heading-Table--focus": "$style-outline--focus",
|
|
478
|
+
"offset-outline-heading-Table--focus": "$offset-outline--focus",
|
|
479
|
+
"color-text-heading-Table": "$color-text-primary",
|
|
480
|
+
"font-size-heading-Table": "$font-size-smaller",
|
|
481
|
+
"font-weight-heading-Table": "$font-weight-bold",
|
|
482
|
+
"transform-text-heading-Table": "uppercase",
|
|
483
|
+
dark: {
|
|
484
|
+
"color-bg-row-Table--hover": "$color-primary-900",
|
|
485
|
+
"color-bg-selected-Table": "$color-primary-800",
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* This function defines the renderer for the Heading component.
|
|
491
|
+
*/
|
|
492
|
+
exports.tableComponentRenderer = (0, renderers_1.createComponentRenderer)("Table", ({ extractValue, node, renderChild, lookupEventHandler, lookupSyncCallback, layoutCss }) => {
|
|
493
|
+
var _a, _b, _c;
|
|
494
|
+
const data = extractValue(node.props.items) || extractValue(node.props.data);
|
|
495
|
+
return ((0, jsx_runtime_1.jsx)(exports.Table, { data: data, pageSizes: extractValue(node.props.pageSizes), rowsSelectable: extractValue.asOptionalBoolean(node.props.rowsSelectable), noDataRenderer: node.props.noDataTemplate &&
|
|
496
|
+
(() => {
|
|
497
|
+
return renderChild(node.props.noDataTemplate);
|
|
498
|
+
}), loading: extractValue.asOptionalBoolean(node.props.loading), isPaginated: extractValue.asOptionalBoolean((_a = node.props) === null || _a === void 0 ? void 0 : _a.isPaginated), headerHeight: extractValue.asSize(node.props.headerHeight), rowDisabledPredicate: lookupSyncCallback(node.props.rowDisabledPredicate), sortBy: extractValue((_b = node.props) === null || _b === void 0 ? void 0 : _b.sortBy), sortingDirection: extractValue((_c = node.props) === null || _c === void 0 ? void 0 : _c.sortDirection), sortingDidChange: lookupEventHandler("sortingDidChange"), willSort: lookupEventHandler("willSort"), style: layoutCss, uid: node.uid, autoFocus: extractValue.asOptionalBoolean(node.props.autoFocus), hideHeader: extractValue.asOptionalBoolean(node.props.hideHeader), enableMultiRowSelection: extractValue.asOptionalBoolean(node.props.enableMultiRowSelection), children: renderChild(node.children) }));
|
|
499
|
+
}, tableMetadata);
|