@vertesia/ui 0.56.0 → 0.57.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/lib/esm/core/components/Avatar.js +31 -0
- package/lib/esm/core/components/Avatar.js.map +1 -0
- package/lib/esm/core/components/Badge.js +62 -0
- package/lib/esm/core/components/Badge.js.map +1 -0
- package/lib/esm/core/components/Button.js +32 -0
- package/lib/esm/core/components/Button.js.map +1 -0
- package/lib/esm/core/components/Center.js +6 -0
- package/lib/esm/core/components/Center.js.map +1 -0
- package/lib/esm/core/components/ComboBox.js +356 -0
- package/lib/esm/core/components/ComboBox.js.map +1 -0
- package/lib/esm/core/components/ConfirmModal.js +10 -0
- package/lib/esm/core/components/ConfirmModal.js.map +1 -0
- package/lib/esm/core/components/DeleteModal.js +28 -0
- package/lib/esm/core/components/DeleteModal.js.map +1 -0
- package/lib/esm/core/components/Divider.js +6 -0
- package/lib/esm/core/components/Divider.js.map +1 -0
- package/lib/esm/core/components/Dropdown.js +16 -0
- package/lib/esm/core/components/Dropdown.js.map +1 -0
- package/lib/esm/core/components/DropdownList.js +9 -0
- package/lib/esm/core/components/DropdownList.js.map +1 -0
- package/lib/esm/core/components/EmptyCollection.js +7 -0
- package/lib/esm/core/components/EmptyCollection.js.map +1 -0
- package/lib/esm/core/components/FileUpload.js +119 -0
- package/lib/esm/core/components/FileUpload.js.map +1 -0
- package/lib/esm/core/components/Input.js +16 -0
- package/lib/esm/core/components/Input.js.map +1 -0
- package/lib/esm/core/components/InputList.js +42 -0
- package/lib/esm/core/components/InputList.js.map +1 -0
- package/lib/esm/core/components/Link.js +13 -0
- package/lib/esm/core/components/Link.js.map +1 -0
- package/lib/esm/core/components/MenuList.js +23 -0
- package/lib/esm/core/components/MenuList.js.map +1 -0
- package/lib/esm/core/components/MessageBox.js +66 -0
- package/lib/esm/core/components/MessageBox.js.map +1 -0
- package/lib/esm/core/components/Modal.js +26 -0
- package/lib/esm/core/components/Modal.js.map +1 -0
- package/lib/esm/core/components/NumberInput.js +43 -0
- package/lib/esm/core/components/NumberInput.js.map +1 -0
- package/lib/esm/core/components/Portal.js +28 -0
- package/lib/esm/core/components/Portal.js.map +1 -0
- package/lib/esm/core/components/RadioGroup.js +34 -0
- package/lib/esm/core/components/RadioGroup.js.map +1 -0
- package/lib/esm/core/components/SelectBox.js +68 -0
- package/lib/esm/core/components/SelectBox.js.map +1 -0
- package/lib/esm/core/components/SelectList.js +47 -0
- package/lib/esm/core/components/SelectList.js.map +1 -0
- package/lib/esm/core/components/SelectStack.js +8 -0
- package/lib/esm/core/components/SelectStack.js.map +1 -0
- package/lib/esm/core/components/SidePanel.js +33 -0
- package/lib/esm/core/components/SidePanel.js.map +1 -0
- package/lib/esm/core/components/Spinner.js +18 -0
- package/lib/esm/core/components/Spinner.js.map +1 -0
- package/lib/esm/core/components/Switch.js +12 -0
- package/lib/esm/core/components/Switch.js.map +1 -0
- package/lib/esm/core/components/Textarea.js +15 -0
- package/lib/esm/core/components/Textarea.js.map +1 -0
- package/lib/esm/core/components/index.js +34 -0
- package/lib/esm/core/components/index.js.map +1 -0
- package/lib/esm/core/components/libs/utils.js +6 -0
- package/lib/esm/core/components/libs/utils.js.map +1 -0
- package/lib/esm/core/components/libs/visuallyHidden.js +16 -0
- package/lib/esm/core/components/libs/visuallyHidden.js.map +1 -0
- package/lib/esm/core/components/popup/Popup.js +60 -0
- package/lib/esm/core/components/popup/Popup.js.map +1 -0
- package/lib/esm/core/components/popup/PopupController.js +149 -0
- package/lib/esm/core/components/popup/PopupController.js.map +1 -0
- package/lib/esm/core/components/popup/index.js +4 -0
- package/lib/esm/core/components/popup/index.js.map +1 -0
- package/lib/esm/core/components/popup/position.js +221 -0
- package/lib/esm/core/components/popup/position.js.map +1 -0
- package/lib/esm/core/components/popup/utils.js +74 -0
- package/lib/esm/core/components/popup/utils.js.map +1 -0
- package/lib/esm/core/components/shadcn/breadcrumb.js +30 -0
- package/lib/esm/core/components/shadcn/breadcrumb.js.map +1 -0
- package/lib/esm/core/components/shadcn/button.js +45 -0
- package/lib/esm/core/components/shadcn/button.js.map +1 -0
- package/lib/esm/core/components/shadcn/calendar.js +46 -0
- package/lib/esm/core/components/shadcn/calendar.js.map +1 -0
- package/lib/esm/core/components/shadcn/card.js +17 -0
- package/lib/esm/core/components/shadcn/card.js.map +1 -0
- package/lib/esm/core/components/shadcn/checkbox.js +10 -0
- package/lib/esm/core/components/shadcn/checkbox.js.map +1 -0
- package/lib/esm/core/components/shadcn/command.js +30 -0
- package/lib/esm/core/components/shadcn/command.js.map +1 -0
- package/lib/esm/core/components/shadcn/dialog.js +61 -0
- package/lib/esm/core/components/shadcn/dialog.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/animateChangeInHeight.js +23 -0
- package/lib/esm/core/components/shadcn/filters/animateChangeInHeight.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/comboBox.js +82 -0
- package/lib/esm/core/components/shadcn/filters/comboBox.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/dateFilter.js +31 -0
- package/lib/esm/core/components/shadcn/filters/dateFilter.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/filterBar.js +140 -0
- package/lib/esm/core/components/shadcn/filters/filterBar.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/filters.js +42 -0
- package/lib/esm/core/components/shadcn/filters/filters.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/index.js +6 -0
- package/lib/esm/core/components/shadcn/filters/index.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/selectFilter.js +58 -0
- package/lib/esm/core/components/shadcn/filters/selectFilter.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/textFilter.js +20 -0
- package/lib/esm/core/components/shadcn/filters/textFilter.js.map +1 -0
- package/lib/esm/core/components/shadcn/filters/types.js +10 -0
- package/lib/esm/core/components/shadcn/filters/types.js.map +1 -0
- package/lib/esm/core/components/shadcn/heading.js +17 -0
- package/lib/esm/core/components/shadcn/heading.js.map +1 -0
- package/lib/esm/core/components/shadcn/index.js +22 -0
- package/lib/esm/core/components/shadcn/index.js.map +1 -0
- package/lib/esm/core/components/shadcn/input.js +38 -0
- package/lib/esm/core/components/shadcn/input.js.map +1 -0
- package/lib/esm/core/components/shadcn/label.js +11 -0
- package/lib/esm/core/components/shadcn/label.js.map +1 -0
- package/lib/esm/core/components/shadcn/popover.js +50 -0
- package/lib/esm/core/components/shadcn/popover.js.map +1 -0
- package/lib/esm/core/components/shadcn/selectBox.js +62 -0
- package/lib/esm/core/components/shadcn/selectBox.js.map +1 -0
- package/lib/esm/core/components/shadcn/separator.js +8 -0
- package/lib/esm/core/components/shadcn/separator.js.map +1 -0
- package/lib/esm/core/components/shadcn/tabs.js +77 -0
- package/lib/esm/core/components/shadcn/tabs.js.map +1 -0
- package/lib/esm/core/components/shadcn/text.js +30 -0
- package/lib/esm/core/components/shadcn/text.js.map +1 -0
- package/lib/esm/core/components/shadcn/theme/ThemeProvider.js +38 -0
- package/lib/esm/core/components/shadcn/theme/ThemeProvider.js.map +1 -0
- package/lib/esm/core/components/shadcn/theme/ThemeSwitcher.js +13 -0
- package/lib/esm/core/components/shadcn/theme/ThemeSwitcher.js.map +1 -0
- package/lib/esm/core/components/shadcn/tooltip.js +14 -0
- package/lib/esm/core/components/shadcn/tooltip.js.map +1 -0
- package/lib/esm/core/components/styles.js +10 -0
- package/lib/esm/core/components/styles.js.map +1 -0
- package/lib/esm/core/components/table/index.js +20 -0
- package/lib/esm/core/components/table/index.js.map +1 -0
- package/lib/esm/core/components/tabs/Tabs.js +78 -0
- package/lib/esm/core/components/tabs/Tabs.js.map +1 -0
- package/lib/esm/core/components/tabs/TabsContext.js +7 -0
- package/lib/esm/core/components/tabs/TabsContext.js.map +1 -0
- package/lib/esm/core/components/tabs/index.js +3 -0
- package/lib/esm/core/components/tabs/index.js.map +1 -0
- package/lib/esm/core/components/toast/NotificationPanel.js +37 -0
- package/lib/esm/core/components/toast/NotificationPanel.js.map +1 -0
- package/lib/esm/core/components/toast/ToastContext.js +7 -0
- package/lib/esm/core/components/toast/ToastContext.js.map +1 -0
- package/lib/esm/core/components/toast/ToastProps.js +2 -0
- package/lib/esm/core/components/toast/ToastProps.js.map +1 -0
- package/lib/esm/core/components/toast/ToastProvider.js +13 -0
- package/lib/esm/core/components/toast/ToastProvider.js.map +1 -0
- package/lib/esm/core/components/toast/index.js +3 -0
- package/lib/esm/core/components/toast/index.js.map +1 -0
- package/lib/esm/core/hooks/CompositeState.js +118 -0
- package/lib/esm/core/hooks/CompositeState.js.map +1 -0
- package/lib/esm/core/hooks/SharedState.js +64 -0
- package/lib/esm/core/hooks/SharedState.js.map +1 -0
- package/lib/esm/core/hooks/index.js +14 -0
- package/lib/esm/core/hooks/index.js.map +1 -0
- package/lib/esm/core/hooks/useClickOutside.js +29 -0
- package/lib/esm/core/hooks/useClickOutside.js.map +1 -0
- package/lib/esm/core/hooks/useCopyToClipboard.js +23 -0
- package/lib/esm/core/hooks/useCopyToClipboard.js.map +1 -0
- package/lib/esm/core/hooks/useDarkMode.js +11 -0
- package/lib/esm/core/hooks/useDarkMode.js.map +1 -0
- package/lib/esm/core/hooks/useDebounce.js +14 -0
- package/lib/esm/core/hooks/useDebounce.js.map +1 -0
- package/lib/esm/core/hooks/useEventSource.js +31 -0
- package/lib/esm/core/hooks/useEventSource.js.map +1 -0
- package/lib/esm/core/hooks/useFetch.js +40 -0
- package/lib/esm/core/hooks/useFetch.js.map +1 -0
- package/lib/esm/core/hooks/useFlag.js +13 -0
- package/lib/esm/core/hooks/useFlag.js.map +1 -0
- package/lib/esm/core/hooks/useIntersectionObserver.js +34 -0
- package/lib/esm/core/hooks/useIntersectionObserver.js.map +1 -0
- package/lib/esm/core/hooks/useIsFistRendering.js +14 -0
- package/lib/esm/core/hooks/useIsFistRendering.js.map +1 -0
- package/lib/esm/core/hooks/useSafeLayoutEffect.js +4 -0
- package/lib/esm/core/hooks/useSafeLayoutEffect.js.map +1 -0
- package/lib/esm/core/hooks/useSharedValue.js +21 -0
- package/lib/esm/core/hooks/useSharedValue.js.map +1 -0
- package/lib/esm/core/index.js +3 -0
- package/lib/esm/core/index.js.map +1 -0
- package/lib/esm/env/index.js +69 -0
- package/lib/esm/env/index.js.map +1 -0
- package/lib/esm/features/activity-doc/ActivityDoc.js +71 -0
- package/lib/esm/features/activity-doc/ActivityDoc.js.map +1 -0
- package/lib/esm/features/activity-doc/index.js +2 -0
- package/lib/esm/features/activity-doc/index.js.map +1 -0
- package/lib/esm/features/index.js +2 -2
- package/lib/esm/features/index.js.map +1 -1
- package/lib/esm/features/permissions/SecureButton.js +13 -0
- package/lib/esm/features/permissions/SecureButton.js.map +1 -0
- package/lib/esm/features/permissions/SecureSidebarItem.js +14 -0
- package/lib/esm/features/permissions/SecureSidebarItem.js.map +1 -0
- package/lib/esm/features/permissions/UserPermissionsProvider.js +86 -0
- package/lib/esm/features/permissions/UserPermissionsProvider.js.map +1 -0
- package/lib/esm/features/permissions/helpers.js +12 -0
- package/lib/esm/features/permissions/helpers.js.map +1 -0
- package/lib/esm/features/permissions/index.js +5 -0
- package/lib/esm/features/permissions/index.js.map +1 -0
- package/lib/esm/layout/AppLayout.js +46 -0
- package/lib/esm/layout/AppLayout.js.map +1 -0
- package/lib/esm/layout/FullHeightLayout.js +20 -0
- package/lib/esm/layout/FullHeightLayout.js.map +1 -0
- package/lib/esm/layout/Navbar.js +40 -0
- package/lib/esm/layout/Navbar.js.map +1 -0
- package/lib/esm/layout/Sidebar.js +35 -0
- package/lib/esm/layout/Sidebar.js.map +1 -0
- package/lib/esm/layout/SidebarContext.js +10 -0
- package/lib/esm/layout/SidebarContext.js.map +1 -0
- package/lib/esm/layout/TitleBar.js +5 -0
- package/lib/esm/layout/TitleBar.js.map +1 -0
- package/lib/esm/layout/index.js +7 -0
- package/lib/esm/layout/index.js.map +1 -0
- package/lib/esm/router/FixLinks.js +23 -0
- package/lib/esm/router/FixLinks.js.map +1 -0
- package/lib/esm/router/HistoryNavigator.js +149 -0
- package/lib/esm/router/HistoryNavigator.js.map +1 -0
- package/lib/esm/router/Nav.js +26 -0
- package/lib/esm/router/Nav.js.map +1 -0
- package/lib/esm/router/NestedNavigationContext.js +19 -0
- package/lib/esm/router/NestedNavigationContext.js.map +1 -0
- package/lib/esm/router/NestedRouterProvider.js +44 -0
- package/lib/esm/router/NestedRouterProvider.js.map +1 -0
- package/lib/esm/router/PathMatcher.js +159 -0
- package/lib/esm/router/PathMatcher.js.map +1 -0
- package/lib/esm/router/PathWithParams.js +34 -0
- package/lib/esm/router/PathWithParams.js.map +1 -0
- package/lib/esm/router/Route404.js +18 -0
- package/lib/esm/router/Route404.js.map +1 -0
- package/lib/esm/router/RouteComponent.js +32 -0
- package/lib/esm/router/RouteComponent.js.map +1 -0
- package/lib/esm/router/Router.js +161 -0
- package/lib/esm/router/Router.js.map +1 -0
- package/lib/esm/router/RouterProvider.js +41 -0
- package/lib/esm/router/RouterProvider.js.map +1 -0
- package/lib/esm/router/index.js +10 -5
- package/lib/esm/router/index.js.map +1 -1
- package/lib/esm/router/path.js +137 -0
- package/lib/esm/router/path.js.map +1 -0
- package/lib/esm/session/TypeRegistry.js +24 -0
- package/lib/esm/session/TypeRegistry.js.map +1 -0
- package/lib/esm/session/UserSession.js +191 -0
- package/lib/esm/session/UserSession.js.map +1 -0
- package/lib/esm/session/UserSessionProvider.js +161 -0
- package/lib/esm/session/UserSessionProvider.js.map +1 -0
- package/lib/esm/session/auth/composable.js +162 -0
- package/lib/esm/session/auth/composable.js.map +1 -0
- package/lib/esm/session/auth/firebase.js +151 -0
- package/lib/esm/session/auth/firebase.js.map +1 -0
- package/lib/esm/session/auth/useAuthState.js +49 -0
- package/lib/esm/session/auth/useAuthState.js.map +1 -0
- package/lib/esm/session/index.js +6 -2
- package/lib/esm/session/index.js.map +1 -1
- package/lib/esm/session/useUXTracking.js +29 -0
- package/lib/esm/session/useUXTracking.js.map +1 -0
- package/lib/esm/widgets/codemirror/CodeMirrorEditor.js +103 -0
- package/lib/esm/widgets/codemirror/CodeMirrorEditor.js.map +1 -0
- package/lib/esm/widgets/codemirror/CodemirrorStateSingleton.js +33 -0
- package/lib/esm/widgets/codemirror/CodemirrorStateSingleton.js.map +1 -0
- package/lib/esm/widgets/codemirror/index.js +2 -0
- package/lib/esm/widgets/codemirror/index.js.map +1 -0
- package/lib/esm/widgets/form/Form.js +102 -0
- package/lib/esm/widgets/form/Form.js.map +1 -0
- package/lib/esm/widgets/form/FormContext.js +29 -0
- package/lib/esm/widgets/form/FormContext.js.map +1 -0
- package/lib/esm/widgets/form/ManagedObject.js +283 -0
- package/lib/esm/widgets/form/ManagedObject.js.map +1 -0
- package/lib/esm/widgets/form/fields.js +11 -0
- package/lib/esm/widgets/form/fields.js.map +1 -0
- package/lib/esm/widgets/form/index.js +7 -0
- package/lib/esm/widgets/form/index.js.map +1 -0
- package/lib/esm/widgets/form/inputs.js +36 -0
- package/lib/esm/widgets/form/inputs.js.map +1 -0
- package/lib/esm/widgets/form/schema.js +191 -0
- package/lib/esm/widgets/form/schema.js.map +1 -0
- package/lib/esm/widgets/index.js +6 -0
- package/lib/esm/widgets/index.js.map +1 -0
- package/lib/esm/widgets/json-view/JSONCode.js +157 -0
- package/lib/esm/widgets/json-view/JSONCode.js.map +1 -0
- package/lib/esm/widgets/json-view/JSONDisplay.js +10 -0
- package/lib/esm/widgets/json-view/JSONDisplay.js.map +1 -0
- package/lib/esm/widgets/json-view/JSONView.js +106 -0
- package/lib/esm/widgets/json-view/JSONView.js.map +1 -0
- package/lib/esm/widgets/json-view/index.js +4 -0
- package/lib/esm/widgets/json-view/index.js.map +1 -0
- package/lib/esm/widgets/json-view/types.js +2 -0
- package/lib/esm/widgets/json-view/types.js.map +1 -0
- package/lib/esm/widgets/schema-editor/JSONSchemaEditorModal.js +50 -0
- package/lib/esm/widgets/schema-editor/JSONSchemaEditorModal.js.map +1 -0
- package/lib/esm/widgets/schema-editor/ManagedSchema.js +303 -0
- package/lib/esm/widgets/schema-editor/ManagedSchema.js.map +1 -0
- package/lib/esm/widgets/schema-editor/editor/Editable.js +111 -0
- package/lib/esm/widgets/schema-editor/editor/Editable.js.map +1 -0
- package/lib/esm/widgets/schema-editor/editor/EditableSchemaProperty.js +8 -0
- package/lib/esm/widgets/schema-editor/editor/EditableSchemaProperty.js.map +1 -0
- package/lib/esm/widgets/schema-editor/editor/PropertyEditor.js +81 -0
- package/lib/esm/widgets/schema-editor/editor/PropertyEditor.js.map +1 -0
- package/lib/esm/widgets/schema-editor/editor/PropertyViewer.js +7 -0
- package/lib/esm/widgets/schema-editor/editor/PropertyViewer.js.map +1 -0
- package/lib/esm/widgets/schema-editor/editor/SchemaContext.js +9 -0
- package/lib/esm/widgets/schema-editor/editor/SchemaContext.js.map +1 -0
- package/lib/esm/widgets/schema-editor/editor/SchemaEditor.js +84 -0
- package/lib/esm/widgets/schema-editor/editor/SchemaEditor.js.map +1 -0
- package/lib/esm/widgets/schema-editor/index.js +8 -0
- package/lib/esm/widgets/schema-editor/index.js.map +1 -0
- package/lib/esm/widgets/schema-editor/json-schema4-utils.js +188 -0
- package/lib/esm/widgets/schema-editor/json-schema4-utils.js.map +1 -0
- package/lib/esm/widgets/schema-editor/type-signature.js +30 -0
- package/lib/esm/widgets/schema-editor/type-signature.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/Attributes/index.js +11 -0
- package/lib/esm/widgets/xml-viewer/components/Attributes/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/CDataTag/index.js +8 -0
- package/lib/esm/widgets/xml-viewer/components/CDataTag/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/CollapseIcon/index.js +11 -0
- package/lib/esm/widgets/xml-viewer/components/CollapseIcon/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/CommentTag/index.js +11 -0
- package/lib/esm/widgets/xml-viewer/components/CommentTag/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/DeclarationTag/index.js +9 -0
- package/lib/esm/widgets/xml-viewer/components/DeclarationTag/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/Elements/index.js +36 -0
- package/lib/esm/widgets/xml-viewer/components/Elements/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/InvalidXml/index.js +5 -0
- package/lib/esm/widgets/xml-viewer/components/InvalidXml/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/Tag/index.js +13 -0
- package/lib/esm/widgets/xml-viewer/components/Tag/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/TextElement/index.js +13 -0
- package/lib/esm/widgets/xml-viewer/components/TextElement/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/XMLViewer.js +30 -0
- package/lib/esm/widgets/xml-viewer/components/XMLViewer.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/components/types.js +2 -0
- package/lib/esm/widgets/xml-viewer/components/types.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/constants/index.js +17 -0
- package/lib/esm/widgets/xml-viewer/constants/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/context/xml-viewer-context.js +10 -0
- package/lib/esm/widgets/xml-viewer/context/xml-viewer-context.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/helpers/index.js +40 -0
- package/lib/esm/widgets/xml-viewer/helpers/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/hooks/useCollapsible.js +22 -0
- package/lib/esm/widgets/xml-viewer/hooks/useCollapsible.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/hooks/useXMLViewer.js +31 -0
- package/lib/esm/widgets/xml-viewer/hooks/useXMLViewer.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/index.js +3 -0
- package/lib/esm/widgets/xml-viewer/index.js.map +1 -0
- package/lib/esm/widgets/xml-viewer/types/index.js +2 -0
- package/lib/esm/widgets/xml-viewer/types/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/core/components/Avatar.d.ts +15 -0
- package/lib/types/core/components/Badge.d.ts +20 -0
- package/lib/types/core/components/Button.d.ts +13 -0
- package/lib/types/core/components/Center.d.ts +7 -0
- package/lib/types/core/components/ComboBox.d.ts +123 -0
- package/lib/types/core/components/ConfirmModal.d.ts +10 -0
- package/lib/types/core/components/DeleteModal.d.ts +10 -0
- package/lib/types/core/components/Divider.d.ts +5 -0
- package/lib/types/core/components/Dropdown.d.ts +14 -0
- package/lib/types/core/components/DropdownList.d.ts +12 -0
- package/lib/types/core/components/EmptyCollection.d.ts +8 -0
- package/lib/types/core/components/FileUpload.d.ts +28 -0
- package/lib/types/core/components/Input.d.ts +8 -0
- package/lib/types/core/components/InputList.d.ts +10 -0
- package/lib/types/core/components/Link.d.ts +6 -0
- package/lib/types/core/components/MenuList.d.ts +13 -0
- package/lib/types/core/components/MessageBox.d.ts +35 -0
- package/lib/types/core/components/Modal.d.ts +29 -0
- package/lib/types/core/components/NumberInput.d.ts +15 -0
- package/lib/types/core/components/Portal.d.ts +5 -0
- package/lib/types/core/components/RadioGroup.d.ts +25 -0
- package/lib/types/core/components/SelectBox.d.ts +35 -0
- package/lib/types/core/components/SelectList.d.ts +17 -0
- package/lib/types/core/components/SelectStack.d.ts +12 -0
- package/lib/types/core/components/SidePanel.d.ts +8 -0
- package/lib/types/core/components/Spinner.d.ts +6 -0
- package/lib/types/core/components/Switch.d.ts +9 -0
- package/lib/types/core/components/Textarea.d.ts +7 -0
- package/lib/types/core/components/index.d.ts +37 -0
- package/lib/types/core/components/libs/utils.d.ts +2 -0
- package/lib/types/core/components/libs/visuallyHidden.d.ts +6 -0
- package/lib/types/core/components/popup/Popup.d.ts +25 -0
- package/lib/types/core/components/popup/PopupController.d.ts +40 -0
- package/lib/types/core/components/popup/index.d.ts +3 -0
- package/lib/types/core/components/popup/position.d.ts +58 -0
- package/lib/types/core/components/popup/utils.d.ts +29 -0
- package/lib/types/core/components/shadcn/breadcrumb.d.ts +13 -0
- package/lib/types/core/components/shadcn/button.d.ts +15 -0
- package/lib/types/core/components/shadcn/calendar.d.ts +10 -0
- package/lib/types/core/components/shadcn/card.d.ts +8 -0
- package/lib/types/core/components/shadcn/checkbox.d.ts +4 -0
- package/lib/types/core/components/shadcn/command.d.ts +80 -0
- package/lib/types/core/components/shadcn/dialog.d.ts +34 -0
- package/lib/types/core/components/shadcn/filters/animateChangeInHeight.d.ts +6 -0
- package/lib/types/core/components/shadcn/filters/comboBox.d.ts +17 -0
- package/lib/types/core/components/shadcn/filters/dateFilter.d.ts +14 -0
- package/lib/types/core/components/shadcn/filters/filterBar.d.ts +9 -0
- package/lib/types/core/components/shadcn/filters/filters.d.ts +9 -0
- package/lib/types/core/components/shadcn/filters/index.d.ts +5 -0
- package/lib/types/core/components/shadcn/filters/selectFilter.d.ts +11 -0
- package/lib/types/core/components/shadcn/filters/textFilter.d.ts +12 -0
- package/lib/types/core/components/shadcn/filters/types.d.ts +26 -0
- package/lib/types/core/components/shadcn/heading.d.ts +5 -0
- package/lib/types/core/components/shadcn/index.d.ts +21 -0
- package/lib/types/core/components/shadcn/input.d.ts +16 -0
- package/lib/types/core/components/shadcn/label.d.ts +7 -0
- package/lib/types/core/components/shadcn/popover.d.ts +16 -0
- package/lib/types/core/components/shadcn/selectBox.d.ts +21 -0
- package/lib/types/core/components/shadcn/separator.d.ts +4 -0
- package/lib/types/core/components/shadcn/tabs.d.ts +26 -0
- package/lib/types/core/components/shadcn/text.d.ts +10 -0
- package/lib/types/core/components/shadcn/theme/ThemeProvider.d.ts +13 -0
- package/lib/types/core/components/shadcn/theme/ThemeSwitcher.d.ts +9 -0
- package/lib/types/core/components/shadcn/tooltip.d.ts +19 -0
- package/lib/types/core/components/styles.d.ts +6 -0
- package/lib/types/core/components/table/index.d.ts +13 -0
- package/lib/types/core/components/tabs/Tabs.d.ts +24 -0
- package/lib/types/core/components/tabs/TabsContext.d.ts +16 -0
- package/lib/types/core/components/tabs/index.d.ts +2 -0
- package/lib/types/core/components/toast/NotificationPanel.d.ts +7 -0
- package/lib/types/core/components/toast/ToastContext.d.ts +5 -0
- package/lib/types/core/components/toast/ToastProps.d.ts +6 -0
- package/lib/types/core/components/toast/ToastProvider.d.ts +5 -0
- package/lib/types/core/components/toast/index.d.ts +2 -0
- package/lib/types/core/hooks/CompositeState.d.ts +27 -0
- package/lib/types/core/hooks/SharedState.d.ts +9 -0
- package/lib/types/core/hooks/index.d.ts +13 -0
- package/lib/types/core/hooks/useClickOutside.d.ts +7 -0
- package/lib/types/core/hooks/useCopyToClipboard.d.ts +4 -0
- package/lib/types/core/hooks/useDarkMode.d.ts +1 -0
- package/lib/types/core/hooks/useDebounce.d.ts +1 -0
- package/lib/types/core/hooks/useEventSource.d.ts +1 -0
- package/lib/types/core/hooks/useFetch.d.ts +23 -0
- package/lib/types/core/hooks/useFlag.d.ts +8 -0
- package/lib/types/core/hooks/useIntersectionObserver.d.ts +13 -0
- package/lib/types/core/hooks/useIsFistRendering.d.ts +1 -0
- package/lib/types/core/hooks/useSafeLayoutEffect.d.ts +3 -0
- package/lib/types/core/hooks/useSharedValue.d.ts +11 -0
- package/lib/types/core/index.d.ts +2 -0
- package/lib/types/env/index.d.ts +70 -0
- package/lib/types/features/activity-doc/ActivityDoc.d.ts +13 -0
- package/lib/types/features/activity-doc/index.d.ts +1 -0
- package/lib/types/features/index.d.ts +2 -0
- package/lib/types/features/permissions/SecureButton.d.ts +7 -0
- package/lib/types/features/permissions/SecureSidebarItem.d.ts +7 -0
- package/lib/types/features/permissions/UserPermissionsProvider.d.ts +19 -0
- package/lib/types/features/permissions/helpers.d.ts +4 -0
- package/lib/types/features/permissions/index.d.ts +4 -0
- package/lib/types/layout/AppLayout.d.ts +12 -0
- package/lib/types/layout/FullHeightLayout.d.ts +26 -0
- package/lib/types/layout/Navbar.d.ts +32 -0
- package/lib/types/layout/Sidebar.d.ts +29 -0
- package/lib/types/layout/SidebarContext.d.ts +8 -0
- package/lib/types/layout/TitleBar.d.ts +5 -0
- package/lib/types/layout/index.d.ts +6 -0
- package/lib/types/router/FixLinks.d.ts +6 -0
- package/lib/types/router/HistoryNavigator.d.ts +55 -0
- package/lib/types/router/Nav.d.ts +28 -0
- package/lib/types/router/NestedNavigationContext.d.ts +8 -0
- package/lib/types/router/NestedRouterProvider.d.ts +13 -0
- package/lib/types/router/PathMatcher.d.ts +35 -0
- package/lib/types/router/PathWithParams.d.ts +8 -0
- package/lib/types/router/Route404.d.ts +3 -0
- package/lib/types/router/RouteComponent.d.ts +5 -0
- package/lib/types/router/Router.d.ts +73 -0
- package/lib/types/router/RouterProvider.d.ts +14 -0
- package/lib/types/router/index.d.ts +10 -4
- package/lib/types/router/path.d.ts +7 -0
- package/lib/types/session/TypeRegistry.d.ts +9 -0
- package/lib/types/session/UserSession.d.ts +39 -0
- package/lib/types/session/UserSessionProvider.d.ts +6 -0
- package/lib/types/session/auth/composable.d.ts +25 -0
- package/lib/types/session/auth/firebase.d.ts +9 -0
- package/lib/types/session/auth/useAuthState.d.ts +9 -0
- package/lib/types/session/index.d.ts +6 -0
- package/lib/types/session/useUXTracking.d.ts +5 -0
- package/lib/types/widgets/codemirror/CodeMirrorEditor.d.ts +22 -0
- package/lib/types/widgets/codemirror/CodemirrorStateSingleton.d.ts +14 -0
- package/lib/types/widgets/codemirror/index.d.ts +1 -0
- package/lib/types/widgets/form/Form.d.ts +20 -0
- package/lib/types/widgets/form/FormContext.d.ts +16 -0
- package/lib/types/widgets/form/ManagedObject.d.ts +81 -0
- package/lib/types/widgets/form/fields.d.ts +15 -0
- package/lib/types/widgets/form/index.d.ts +6 -0
- package/lib/types/widgets/form/inputs.d.ts +7 -0
- package/lib/types/widgets/form/schema.d.ts +45 -0
- package/lib/types/widgets/index.d.ts +5 -0
- package/lib/types/widgets/json-view/JSONCode.d.ts +21 -0
- package/lib/types/widgets/json-view/JSONDisplay.d.ts +7 -0
- package/lib/types/widgets/json-view/JSONView.d.ts +6 -0
- package/lib/types/widgets/json-view/index.d.ts +4 -0
- package/lib/types/widgets/json-view/types.d.ts +7 -0
- package/lib/types/widgets/schema-editor/JSONSchemaEditorModal.d.ts +9 -0
- package/lib/types/widgets/schema-editor/ManagedSchema.d.ts +74 -0
- package/lib/types/widgets/schema-editor/editor/Editable.d.ts +39 -0
- package/lib/types/widgets/schema-editor/editor/EditableSchemaProperty.d.ts +7 -0
- package/lib/types/widgets/schema-editor/editor/PropertyEditor.d.ts +4 -0
- package/lib/types/widgets/schema-editor/editor/PropertyViewer.d.ts +3 -0
- package/lib/types/widgets/schema-editor/editor/SchemaContext.d.ts +2 -0
- package/lib/types/widgets/schema-editor/editor/SchemaEditor.d.ts +8 -0
- package/lib/types/widgets/schema-editor/index.d.ts +7 -0
- package/lib/types/widgets/schema-editor/json-schema4-utils.d.ts +15 -0
- package/lib/types/widgets/schema-editor/type-signature.d.ts +18 -0
- package/lib/types/widgets/xml-viewer/components/Attributes/index.d.ts +5 -0
- package/lib/types/widgets/xml-viewer/components/CDataTag/index.d.ts +7 -0
- package/lib/types/widgets/xml-viewer/components/CollapseIcon/index.d.ts +4 -0
- package/lib/types/widgets/xml-viewer/components/CommentTag/index.d.ts +8 -0
- package/lib/types/widgets/xml-viewer/components/DeclarationTag/index.d.ts +7 -0
- package/lib/types/widgets/xml-viewer/components/Elements/index.d.ts +7 -0
- package/lib/types/widgets/xml-viewer/components/InvalidXml/index.d.ts +1 -0
- package/lib/types/widgets/xml-viewer/components/Tag/index.d.ts +12 -0
- package/lib/types/widgets/xml-viewer/components/TextElement/index.d.ts +7 -0
- package/lib/types/widgets/xml-viewer/components/XMLViewer.d.ts +2 -0
- package/lib/types/widgets/xml-viewer/components/types.d.ts +103 -0
- package/lib/types/widgets/xml-viewer/constants/index.d.ts +16 -0
- package/lib/types/widgets/xml-viewer/context/xml-viewer-context.d.ts +3 -0
- package/lib/types/widgets/xml-viewer/helpers/index.d.ts +12 -0
- package/lib/types/widgets/xml-viewer/hooks/useCollapsible.d.ts +14 -0
- package/lib/types/widgets/xml-viewer/hooks/useXMLViewer.d.ts +9 -0
- package/lib/types/widgets/xml-viewer/index.d.ts +2 -0
- package/lib/types/widgets/xml-viewer/types/index.d.ts +15 -0
- package/lib/vertesia-ui-core.js +2 -0
- package/lib/vertesia-ui-core.js.map +1 -0
- package/lib/vertesia-ui-env.js +2 -0
- package/lib/vertesia-ui-env.js.map +1 -0
- package/lib/vertesia-ui-features.js +1 -1
- package/lib/vertesia-ui-features.js.map +1 -1
- package/lib/vertesia-ui-layout.js +2 -0
- package/lib/vertesia-ui-layout.js.map +1 -0
- package/lib/vertesia-ui-router.js +1 -1
- package/lib/vertesia-ui-router.js.map +1 -1
- package/lib/vertesia-ui-session.js +1 -1
- package/lib/vertesia-ui-session.js.map +1 -1
- package/lib/vertesia-ui-widgets.js +2 -0
- package/lib/vertesia-ui-widgets.js.map +1 -0
- package/package.json +80 -19
- package/src/code/index.ts +1 -1
- package/src/core/components/Avatar.tsx +67 -0
- package/src/core/components/Badge.tsx +114 -0
- package/src/core/components/Button.tsx +63 -0
- package/src/core/components/Center.tsx +12 -0
- package/src/core/components/ComboBox.tsx +488 -0
- package/src/core/components/ConfirmModal.tsx +51 -0
- package/src/core/components/DeleteModal.tsx +45 -0
- package/src/core/components/Divider.tsx +11 -0
- package/src/core/components/Dropdown.tsx +63 -0
- package/src/core/components/DropdownList.tsx +72 -0
- package/src/core/components/EmptyCollection.tsx +39 -0
- package/src/core/components/FileUpload.tsx +196 -0
- package/src/core/components/Input.tsx +43 -0
- package/src/core/components/InputList.tsx +75 -0
- package/src/core/components/Link.tsx +16 -0
- package/src/core/components/MenuList.tsx +44 -0
- package/src/core/components/MessageBox.tsx +96 -0
- package/src/core/components/Modal.tsx +144 -0
- package/src/core/components/NumberInput.tsx +64 -0
- package/src/core/components/Portal.tsx +33 -0
- package/src/core/components/RadioGroup.tsx +100 -0
- package/src/core/components/SelectBox.tsx +189 -0
- package/src/core/components/SelectList.tsx +85 -0
- package/src/core/components/SelectStack.tsx +63 -0
- package/src/core/components/SidePanel.tsx +104 -0
- package/src/core/components/Spinner.tsx +33 -0
- package/src/core/components/Switch.tsx +29 -0
- package/src/core/components/Textarea.tsx +25 -0
- package/src/core/components/index.ts +39 -0
- package/src/core/components/libs/utils.tsx +6 -0
- package/src/core/components/libs/visuallyHidden.tsx +25 -0
- package/src/core/components/popup/Popup.tsx +94 -0
- package/src/core/components/popup/PopupController.ts +182 -0
- package/src/core/components/popup/index.ts +3 -0
- package/src/core/components/popup/position.ts +277 -0
- package/src/core/components/popup/utils.ts +82 -0
- package/src/core/components/shadcn/breadcrumb.tsx +174 -0
- package/src/core/components/shadcn/button.tsx +95 -0
- package/src/core/components/shadcn/calendar.tsx +87 -0
- package/src/core/components/shadcn/card.tsx +76 -0
- package/src/core/components/shadcn/checkbox.tsx +30 -0
- package/src/core/components/shadcn/command.tsx +155 -0
- package/src/core/components/shadcn/dialog.tsx +230 -0
- package/src/core/components/shadcn/filters/animateChangeInHeight.tsx +41 -0
- package/src/core/components/shadcn/filters/comboBox.tsx +251 -0
- package/src/core/components/shadcn/filters/dateFilter.tsx +65 -0
- package/src/core/components/shadcn/filters/filterBar.tsx +262 -0
- package/src/core/components/shadcn/filters/filters.tsx +110 -0
- package/src/core/components/shadcn/filters/index.ts +5 -0
- package/src/core/components/shadcn/filters/selectFilter.tsx +91 -0
- package/src/core/components/shadcn/filters/textFilter.tsx +59 -0
- package/src/core/components/shadcn/filters/types.ts +29 -0
- package/src/core/components/shadcn/heading.tsx +23 -0
- package/src/core/components/shadcn/index.ts +22 -0
- package/src/core/components/shadcn/input.tsx +89 -0
- package/src/core/components/shadcn/label.tsx +31 -0
- package/src/core/components/shadcn/popover.tsx +115 -0
- package/src/core/components/shadcn/selectBox.tsx +186 -0
- package/src/core/components/shadcn/separator.tsx +29 -0
- package/src/core/components/shadcn/tabs.tsx +218 -0
- package/src/core/components/shadcn/text.tsx +33 -0
- package/src/core/components/shadcn/theme/ThemeProvider.tsx +73 -0
- package/src/core/components/shadcn/theme/ThemeSwitcher.tsx +35 -0
- package/src/core/components/shadcn/tooltip.tsx +57 -0
- package/src/core/components/styles.ts +11 -0
- package/src/core/components/table/index.tsx +49 -0
- package/src/core/components/tabs/Tabs.tsx +132 -0
- package/src/core/components/tabs/TabsContext.ts +25 -0
- package/src/core/components/tabs/index.ts +2 -0
- package/src/core/components/toast/NotificationPanel.tsx +91 -0
- package/src/core/components/toast/ToastContext.ts +12 -0
- package/src/core/components/toast/ToastProps.ts +6 -0
- package/src/core/components/toast/ToastProvider.tsx +26 -0
- package/src/core/components/toast/index.ts +2 -0
- package/src/core/hooks/CompositeState.tsx +142 -0
- package/src/core/hooks/SharedState.tsx +69 -0
- package/src/core/hooks/index.ts +13 -0
- package/src/core/hooks/useClickOutside.tsx +29 -0
- package/src/core/hooks/useCopyToClipboard.tsx +28 -0
- package/src/core/hooks/useDarkMode.ts +11 -0
- package/src/core/hooks/useDebounce.tsx +15 -0
- package/src/core/hooks/useEventSource.ts +35 -0
- package/src/core/hooks/useFetch.ts +51 -0
- package/src/core/hooks/useFlag.tsx +13 -0
- package/src/core/hooks/useIntersectionObserver.tsx +40 -0
- package/src/core/hooks/useIsFistRendering.ts +17 -0
- package/src/core/hooks/useSafeLayoutEffect.ts +5 -0
- package/src/core/hooks/useSharedValue.ts +22 -0
- package/src/core/index.ts +2 -0
- package/src/env/index.ts +116 -0
- package/src/features/activity-doc/ActivityDoc.tsx +199 -0
- package/src/features/activity-doc/index.ts +1 -0
- package/src/features/index.ts +2 -1
- package/src/features/permissions/SecureButton.tsx +18 -0
- package/src/features/permissions/SecureSidebarItem.tsx +19 -0
- package/src/features/permissions/UserPermissionsProvider.tsx +102 -0
- package/src/features/permissions/helpers.ts +16 -0
- package/src/features/permissions/index.ts +4 -0
- package/src/layout/AppLayout.tsx +132 -0
- package/src/layout/FullHeightLayout.tsx +74 -0
- package/src/layout/Navbar.tsx +127 -0
- package/src/layout/Sidebar.tsx +129 -0
- package/src/layout/SidebarContext.ts +17 -0
- package/src/layout/TitleBar.tsx +7 -0
- package/src/layout/index.ts +6 -0
- package/src/router/FixLinks.tsx +28 -0
- package/src/router/HistoryNavigator.ts +178 -0
- package/src/router/Nav.tsx +55 -0
- package/src/router/NestedNavigationContext.tsx +32 -0
- package/src/router/NestedRouterProvider.tsx +64 -0
- package/src/router/PathMatcher.ts +166 -0
- package/src/router/PathWithParams.ts +34 -0
- package/src/router/Route404.tsx +18 -0
- package/src/router/RouteComponent.tsx +41 -0
- package/src/router/Router.tsx +216 -0
- package/src/router/RouterProvider.tsx +55 -0
- package/src/router/index.ts +10 -8
- package/src/router/path.ts +151 -0
- package/src/session/TypeRegistry.ts +27 -0
- package/src/session/UserSession.ts +227 -0
- package/src/session/UserSessionProvider.tsx +170 -0
- package/src/session/auth/composable.ts +190 -0
- package/src/session/auth/firebase.ts +160 -0
- package/src/session/auth/useAuthState.ts +61 -0
- package/src/session/index.ts +6 -1
- package/src/session/useUXTracking.tsx +38 -0
- package/src/widgets/codemirror/CodeMirrorEditor.tsx +121 -0
- package/src/widgets/codemirror/CodemirrorStateSingleton.tsx +39 -0
- package/src/widgets/codemirror/index.ts +2 -0
- package/src/widgets/form/Form.tsx +194 -0
- package/src/widgets/form/FormContext.ts +38 -0
- package/src/widgets/form/ManagedObject.ts +332 -0
- package/src/widgets/form/fields.tsx +34 -0
- package/src/widgets/form/index.ts +6 -0
- package/src/widgets/form/inputs.tsx +44 -0
- package/src/widgets/form/schema.ts +215 -0
- package/src/widgets/index.ts +5 -0
- package/src/widgets/json-view/JSONCode.tsx +176 -0
- package/src/widgets/json-view/JSONDisplay.tsx +24 -0
- package/src/widgets/json-view/JSONView.tsx +183 -0
- package/src/widgets/json-view/index.ts +4 -0
- package/src/widgets/json-view/types.ts +5 -0
- package/src/widgets/schema-editor/JSONSchemaEditorModal.tsx +68 -0
- package/src/widgets/schema-editor/ManagedSchema.ts +340 -0
- package/src/widgets/schema-editor/editor/Editable.tsx +252 -0
- package/src/widgets/schema-editor/editor/EditableSchemaProperty.tsx +15 -0
- package/src/widgets/schema-editor/editor/PropertyEditor.tsx +150 -0
- package/src/widgets/schema-editor/editor/PropertyViewer.tsx +15 -0
- package/src/widgets/schema-editor/editor/SchemaContext.tsx +9 -0
- package/src/widgets/schema-editor/editor/SchemaEditor.test.ts +48 -0
- package/src/widgets/schema-editor/editor/SchemaEditor.tsx +161 -0
- package/src/widgets/schema-editor/index.ts +7 -0
- package/src/widgets/schema-editor/json-schema4-utils.ts +187 -0
- package/src/widgets/schema-editor/type-signature.ts +39 -0
- package/src/widgets/xml-viewer/components/Attributes/index.tsx +27 -0
- package/src/widgets/xml-viewer/components/CDataTag/index.tsx +21 -0
- package/src/widgets/xml-viewer/components/CollapseIcon/index.tsx +32 -0
- package/src/widgets/xml-viewer/components/CommentTag/index.tsx +30 -0
- package/src/widgets/xml-viewer/components/DeclarationTag/index.tsx +23 -0
- package/src/widgets/xml-viewer/components/Elements/index.tsx +83 -0
- package/src/widgets/xml-viewer/components/InvalidXml/index.tsx +3 -0
- package/src/widgets/xml-viewer/components/Tag/index.tsx +47 -0
- package/src/widgets/xml-viewer/components/TextElement/index.tsx +28 -0
- package/src/widgets/xml-viewer/components/XMLViewer.tsx +53 -0
- package/src/widgets/xml-viewer/components/types.ts +104 -0
- package/src/widgets/xml-viewer/constants/index.ts +17 -0
- package/src/widgets/xml-viewer/context/xml-viewer-context.ts +12 -0
- package/src/widgets/xml-viewer/helpers/index.ts +56 -0
- package/src/widgets/xml-viewer/hooks/useCollapsible.ts +28 -0
- package/src/widgets/xml-viewer/hooks/useXMLViewer.ts +34 -0
- package/src/widgets/xml-viewer/index.ts +2 -0
- package/src/widgets/xml-viewer/types/index.ts +21 -0
- package/lib/esm/components/index.js +0 -3
- package/lib/esm/components/index.js.map +0 -1
- package/lib/types/components/index.d.ts +0 -0
- package/lib/vertesia-ui-components.js +0 -2
- package/lib/vertesia-ui-components.js.map +0 -1
- package/src/components/index.ts +0 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { createContext, useContext, useEffect } from "react";
|
|
2
|
+
import { HistoryNavigator, LocationChangeEvent, NavigateOptions } from "./HistoryNavigator";
|
|
3
|
+
import { PathMatch, PathMatcher } from "./PathMatcher";
|
|
4
|
+
import { isRootPath, joinPath } from "./path";
|
|
5
|
+
|
|
6
|
+
export type LazyImportFn = () => Promise<any>;
|
|
7
|
+
export interface ComponentRoute {
|
|
8
|
+
path: string;
|
|
9
|
+
Component: React.ComponentType<any>;
|
|
10
|
+
}
|
|
11
|
+
export interface LazyComponentRoute {
|
|
12
|
+
path: string;
|
|
13
|
+
LazyComponent: LazyImportFn;
|
|
14
|
+
}
|
|
15
|
+
export type Route = ComponentRoute | LazyComponentRoute;
|
|
16
|
+
|
|
17
|
+
export interface RouteMatch extends PathMatch<Route> {
|
|
18
|
+
state: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface NavigationPrompt {
|
|
22
|
+
message: string;
|
|
23
|
+
when?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export abstract class BaseRouter {
|
|
27
|
+
// the path to use when navigating to the root of the router
|
|
28
|
+
index?: string;
|
|
29
|
+
matcher: PathMatcher<Route> = new PathMatcher();
|
|
30
|
+
constructor(routes: Route[], index?: string) {
|
|
31
|
+
this.index = index;
|
|
32
|
+
for (const route of routes) {
|
|
33
|
+
this.matcher.addPath(route.path, route);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
abstract getTopRouter(): Router;
|
|
38
|
+
|
|
39
|
+
match(path: string): PathMatch<Route> | null {
|
|
40
|
+
const useIndex = isRootPath(path) && this.index;
|
|
41
|
+
return this.matcher.match(useIndex ? this.index! : path);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
abstract navigate(path: string, options?: NavigateOptions): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class Router extends BaseRouter {
|
|
48
|
+
prompt?: NavigationPrompt;
|
|
49
|
+
observer?: (event: LocationChangeEvent) => void;
|
|
50
|
+
navigator: HistoryNavigator = new HistoryNavigator();
|
|
51
|
+
constructor(routes: Route[], updateState: (route: RouteMatch | null) => void) {
|
|
52
|
+
super(routes);
|
|
53
|
+
this.navigator.addListener((event: LocationChangeEvent) => {
|
|
54
|
+
if (event.isCancelable && this.prompt && !!this.prompt.when) {
|
|
55
|
+
if (!window.confirm(this.prompt.message)) return;
|
|
56
|
+
}
|
|
57
|
+
if (this.observer) {
|
|
58
|
+
this.observer(event);
|
|
59
|
+
}
|
|
60
|
+
// only process afterChange events
|
|
61
|
+
if (event.name === "afterChange") {
|
|
62
|
+
const match = this.match(event.location.pathname);
|
|
63
|
+
if (match && match.value) {
|
|
64
|
+
updateState({
|
|
65
|
+
...match,
|
|
66
|
+
state: event.state,
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
updateState(null);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getTopRouter(): Router {
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Subsequent navigations will preserve the given params in the query string.
|
|
81
|
+
* Use null to clear the sticky params.
|
|
82
|
+
* @param params
|
|
83
|
+
*/
|
|
84
|
+
setStickyParams(params: Record<string, string> | null) {
|
|
85
|
+
this.navigator.stickyParams = params != null ? params : undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
withObserver(observer?: ((event: LocationChangeEvent) => void) | undefined) {
|
|
89
|
+
this.observer = observer;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
start() {
|
|
94
|
+
this.navigator.start();
|
|
95
|
+
// initialize with the current location
|
|
96
|
+
this.navigator.firePageLoad();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
stop() {
|
|
100
|
+
this.navigator.stop();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
navigate(path: string, options?: NavigateOptions) {
|
|
104
|
+
this.navigator.navigate(path, options);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class NestedRouter extends BaseRouter {
|
|
109
|
+
constructor(
|
|
110
|
+
public parent: BaseRouter,
|
|
111
|
+
public basePath: string,
|
|
112
|
+
routes: Route[],
|
|
113
|
+
) {
|
|
114
|
+
super(routes);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
getTopRouter(): Router {
|
|
118
|
+
if (this.parent instanceof Router) {
|
|
119
|
+
return this.parent;
|
|
120
|
+
} else {
|
|
121
|
+
return (this.parent as NestedRouter).getTopRouter();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
navigate(path: string, options?: NavigateOptions | undefined): void {
|
|
126
|
+
// base path is nested by default in a NestedRouter unless explicitly set to false by caller
|
|
127
|
+
const isBasePathNested = options?.isBasePathNested ?? true;
|
|
128
|
+
let basePath: string;
|
|
129
|
+
|
|
130
|
+
if (isBasePathNested) {
|
|
131
|
+
const childBasePath = options?.basePath;
|
|
132
|
+
// e.g. "/store" + "/objects/123" => "/store/objects/123"
|
|
133
|
+
basePath = childBasePath ? joinPath(this.basePath, childBasePath) : this.basePath;
|
|
134
|
+
} else {
|
|
135
|
+
// e.g. "/store" + "/studio" => "/studio"
|
|
136
|
+
basePath = options?.basePath ?? this.basePath;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.parent.navigate(path, {
|
|
140
|
+
...options,
|
|
141
|
+
basePath,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface RouterContext {
|
|
147
|
+
location: Location;
|
|
148
|
+
route: Route;
|
|
149
|
+
router: BaseRouter;
|
|
150
|
+
params: Record<string, string>;
|
|
151
|
+
state: any;
|
|
152
|
+
/**
|
|
153
|
+
* The path that matched the route. For wildcard `/*` paths this does not include the wildcard part.
|
|
154
|
+
* You can get the wildcard path from `remainingPath`.
|
|
155
|
+
*/
|
|
156
|
+
matchedRoutePath: string;
|
|
157
|
+
remainingPath?: string;
|
|
158
|
+
navigate: (path: string, options?: NavigateOptions) => void;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const ReactRouterContext = createContext<RouterContext | undefined>(undefined);
|
|
162
|
+
export { ReactRouterContext };
|
|
163
|
+
|
|
164
|
+
export function useRouterContext() {
|
|
165
|
+
const ctx = useContext(ReactRouterContext);
|
|
166
|
+
if (!ctx) {
|
|
167
|
+
throw new Error("useRouter must be used within a RouterProvider");
|
|
168
|
+
}
|
|
169
|
+
return ctx;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function useNavigate() {
|
|
173
|
+
const { navigate } = useRouterContext();
|
|
174
|
+
return navigate;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
type UseParamsReturn<T> = T extends string ? string : Record<string, string>;
|
|
178
|
+
export function useParams<T>(arg?: T): UseParamsReturn<T> {
|
|
179
|
+
const { params } = useRouterContext();
|
|
180
|
+
if (arg) {
|
|
181
|
+
return params[arg as string] as UseParamsReturn<T>;
|
|
182
|
+
} else {
|
|
183
|
+
return params as UseParamsReturn<T>;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function useLocation() {
|
|
188
|
+
const { location } = useRouterContext();
|
|
189
|
+
return location;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function useNavigationPrompt(prompt: NavigationPrompt) {
|
|
193
|
+
const { router } = useRouterContext();
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
router.getTopRouter().prompt = prompt;
|
|
196
|
+
return () => {
|
|
197
|
+
router.getTopRouter().prompt = undefined;
|
|
198
|
+
};
|
|
199
|
+
}, []);
|
|
200
|
+
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
if (prompt.when) {
|
|
203
|
+
const doBlock = prompt.when;
|
|
204
|
+
const listener = function (ev: Event) {
|
|
205
|
+
if (doBlock) {
|
|
206
|
+
ev.preventDefault();
|
|
207
|
+
(ev as any).returnValue = "";
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
window.addEventListener("beforeunload", listener);
|
|
211
|
+
return () => {
|
|
212
|
+
window.removeEventListener("beforeunload", listener);
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}, [prompt.when]);
|
|
216
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useSafeLayoutEffect } from "@vertesia/ui/core";
|
|
2
|
+
//import { useSafeLayoutEffect } from "../core";
|
|
3
|
+
import React, { useMemo, useState } from "react";
|
|
4
|
+
import { RouteComponent } from "./RouteComponent";
|
|
5
|
+
import { ReactRouterContext, Route, Router, RouterContext } from "./Router";
|
|
6
|
+
import { createRoute404 } from "./Route404";
|
|
7
|
+
import { LocationChangeEvent, NavigateOptions } from "./HistoryNavigator";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
interface RouterProviderProps {
|
|
11
|
+
routes: Route[],
|
|
12
|
+
/**
|
|
13
|
+
* The path to use for the root resource. Defaults to '/'. Cannot contains path variables or wildcards
|
|
14
|
+
*/
|
|
15
|
+
index?: string;
|
|
16
|
+
children?: React.ReactNode
|
|
17
|
+
onChange?: (event: LocationChangeEvent) => void;
|
|
18
|
+
}
|
|
19
|
+
export function RouterProvider({ routes, index, onChange, children }: RouterProviderProps) {
|
|
20
|
+
const [state, setState] = useState<RouterContext | undefined>(undefined);
|
|
21
|
+
const router = useMemo(() => {
|
|
22
|
+
if (typeof window === 'undefined') return null;
|
|
23
|
+
const router = new Router(routes, (match) => {
|
|
24
|
+
if (match === null) {
|
|
25
|
+
match = createRoute404();
|
|
26
|
+
}
|
|
27
|
+
setState({
|
|
28
|
+
location: window.location,
|
|
29
|
+
route: match.value,
|
|
30
|
+
params: match.params,
|
|
31
|
+
state: match.state,
|
|
32
|
+
router: router,
|
|
33
|
+
matchedRoutePath: '/' + match.matchedSegments.join('/'),
|
|
34
|
+
remainingPath: match.remainingSegments ? '/' + match.remainingSegments.join('/') : undefined,
|
|
35
|
+
navigate: (to: string, options?: NavigateOptions) => {
|
|
36
|
+
return router.navigate(to, options);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}).withObserver(onChange);
|
|
40
|
+
router.index = index;
|
|
41
|
+
return router;
|
|
42
|
+
}, []);
|
|
43
|
+
useSafeLayoutEffect(() => {
|
|
44
|
+
router && router.start();
|
|
45
|
+
return () => {
|
|
46
|
+
router && router.stop();
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
return state && (
|
|
51
|
+
<ReactRouterContext.Provider value={state}>
|
|
52
|
+
{children ? children : <RouteComponent />}
|
|
53
|
+
</ReactRouterContext.Provider>
|
|
54
|
+
)
|
|
55
|
+
}
|
package/src/router/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export * from "./FixLinks.js"
|
|
2
|
+
export * from "./HistoryNavigator.js"
|
|
3
|
+
export * from "./Nav.js"
|
|
4
|
+
export * from "./NestedNavigationContext.js"
|
|
5
|
+
export * from "./NestedRouterProvider.js"
|
|
6
|
+
export * as Path from "./path.js"
|
|
7
|
+
export * from "./PathMatcher.js"
|
|
8
|
+
export * from "./RouteComponent.js"
|
|
9
|
+
export * from "./Router.js"
|
|
10
|
+
export * from "./RouterProvider.js"
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export type PathMatchParams = Record<string, string> & {
|
|
2
|
+
_?: string[];
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function isRootPath(path: string) {
|
|
6
|
+
return path === '/' || path === '';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function joinPath(path1: string, path2: string) {
|
|
10
|
+
if (path1.endsWith('/') && path2.startsWith('/')) {
|
|
11
|
+
path2 = path1 + path2.substring(1);
|
|
12
|
+
} else if (path1.endsWith('/')) {
|
|
13
|
+
path2 = path1 + path2;
|
|
14
|
+
} else if (path2.startsWith('/')) {
|
|
15
|
+
path2 = path1 + path2;
|
|
16
|
+
} else {
|
|
17
|
+
path2 = path1 + '/' + path2;
|
|
18
|
+
}
|
|
19
|
+
return path2;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getPathSegments(path: string) {
|
|
23
|
+
if (path === '' || path === '/') {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
let s = 0, e = path.length;
|
|
27
|
+
if (path.startsWith('./')) {
|
|
28
|
+
s = 2;
|
|
29
|
+
} else if (path.startsWith('/')) {
|
|
30
|
+
s = 1;
|
|
31
|
+
}
|
|
32
|
+
if (path.endsWith('/')) {
|
|
33
|
+
e = path.length - 1;
|
|
34
|
+
}
|
|
35
|
+
return (s > 0 || e < path.length ? path.substring(s, e) : path).split('/');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function toSegments(path: string | string[]) {
|
|
39
|
+
if (typeof path === 'string') {
|
|
40
|
+
return getPathSegments(path);
|
|
41
|
+
} else if (Array.isArray(path)) {
|
|
42
|
+
return path;
|
|
43
|
+
} else {
|
|
44
|
+
throw new Error(`Unsupported path object: ${path}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// export class Path {
|
|
49
|
+
|
|
50
|
+
// static parse(path: string, abs = false) {
|
|
51
|
+
// if (abs !== undefined) {
|
|
52
|
+
// abs = path.startsWith('/');
|
|
53
|
+
// }
|
|
54
|
+
// return new Path(getPathSegments(path), abs);
|
|
55
|
+
// }
|
|
56
|
+
|
|
57
|
+
// constructor(public segments: string[], public isAbsolute = false) {
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
// getParameters() {
|
|
61
|
+
// const out = [];
|
|
62
|
+
// for (const segment of this.segments) {
|
|
63
|
+
// if (segment[0] === ':') {
|
|
64
|
+
// out.push(segment.substring(1));
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
// if (this.segments[this.segments.length - 1] === '*') {
|
|
68
|
+
// out.push('_');
|
|
69
|
+
// }
|
|
70
|
+
// return out;
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
// resolveParameters(path: string) {
|
|
74
|
+
// const params: PathMatchParams = {};
|
|
75
|
+
// const resolvedSegments = getPathSegments(path);
|
|
76
|
+
// if (resolvedSegments.length < this.segments.length) {
|
|
77
|
+
// return null;
|
|
78
|
+
// }
|
|
79
|
+
// const segments = this.segments;
|
|
80
|
+
// for (let i = 0, l = segments.length; i < l; i++) {
|
|
81
|
+
// const seg = segments[i];
|
|
82
|
+
// if (seg[0] === ':') {
|
|
83
|
+
// params[seg.substring(1)] = resolvedSegments[i];
|
|
84
|
+
// }
|
|
85
|
+
// }
|
|
86
|
+
// if (resolvedSegments.length - this.segments.length) {
|
|
87
|
+
// params._ = resolvedSegments.slice(this.segments.length);
|
|
88
|
+
// }
|
|
89
|
+
// return params;
|
|
90
|
+
// }
|
|
91
|
+
|
|
92
|
+
// match(path: string | string[] | Path) {
|
|
93
|
+
// const segments = toSegments(path);
|
|
94
|
+
// if (segments.length < this.segments.length) {
|
|
95
|
+
// return false;
|
|
96
|
+
// }
|
|
97
|
+
// let params: PathMatchParams | undefined;
|
|
98
|
+
// const mySegments = this.segments;
|
|
99
|
+
// for (let i = 0, l = mySegments.length; i < l; i++) {
|
|
100
|
+
// const segment = mySegments[i];
|
|
101
|
+
// if (segment === ':') {
|
|
102
|
+
// if (!params) params = {};
|
|
103
|
+
// params[segment.substring(1)] = segment;
|
|
104
|
+
// } else if (segment !== segments[i]) {
|
|
105
|
+
// if (i === l - 1 && segment === '*') {
|
|
106
|
+
// if (!params) params = {};
|
|
107
|
+
// params._ = segments.slice(i);
|
|
108
|
+
// return params;
|
|
109
|
+
// }
|
|
110
|
+
// return false;
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
|
+
// return params ? params : false;
|
|
114
|
+
// }
|
|
115
|
+
|
|
116
|
+
// join(path: Path | string | string[]) {
|
|
117
|
+
// const segments = toSegments(path);
|
|
118
|
+
// return new Path(this.segments.concat(segments), this.isAbsolute);
|
|
119
|
+
// }
|
|
120
|
+
|
|
121
|
+
// getRelativePath(path: Path | string | string[], asAbsolute: boolean = false) {
|
|
122
|
+
// const segments = toSegments(path);
|
|
123
|
+
// const extraSegmentsCount = segments.length - this.segments.length;
|
|
124
|
+
// if (extraSegmentsCount <= 0) {
|
|
125
|
+
// return null;
|
|
126
|
+
// }
|
|
127
|
+
// return new Path(segments.slice(this.segments.length), asAbsolute);
|
|
128
|
+
// }
|
|
129
|
+
|
|
130
|
+
// prependSegments(segments: string[]) {
|
|
131
|
+
// this.segments = segments.concat(this.segments);
|
|
132
|
+
// }
|
|
133
|
+
|
|
134
|
+
// appendSegments(segments: string[]) {
|
|
135
|
+
// this.segments = this.segments.concat(segments);
|
|
136
|
+
// }
|
|
137
|
+
|
|
138
|
+
// toAbsolutePath() {
|
|
139
|
+
// return '/' + this.segments.join('/');
|
|
140
|
+
// }
|
|
141
|
+
|
|
142
|
+
// toRelativePath() {
|
|
143
|
+
// return this.segments.join('/');
|
|
144
|
+
// }
|
|
145
|
+
|
|
146
|
+
// toString() {
|
|
147
|
+
// const path = this.segments.join('/');
|
|
148
|
+
// return this.isAbsolute ? '/' + path : path;
|
|
149
|
+
// }
|
|
150
|
+
|
|
151
|
+
// }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ContentObjectTypeItem } from "@vertesia/common";
|
|
2
|
+
|
|
3
|
+
export class TypeRegistry {
|
|
4
|
+
map: Record<string, ContentObjectTypeItem> = {};
|
|
5
|
+
constructor(public types: ContentObjectTypeItem[]) {
|
|
6
|
+
//sort types
|
|
7
|
+
types.sort((a, b) => a.name.localeCompare(b.name))
|
|
8
|
+
for (const type of types) {
|
|
9
|
+
this.map[type.id] = type;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getType(id: string) {
|
|
14
|
+
return this.map[id];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getTypeLayout(id: string) {
|
|
18
|
+
const type = this.map[id];
|
|
19
|
+
return type ? type.table_layout : undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getTypeName(id: string) {
|
|
23
|
+
const type = this.map[id];
|
|
24
|
+
return type ? type.name : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { jwtDecode } from 'jwt-decode';
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
import { VertesiaClient } from '@vertesia/client';
|
|
5
|
+
import { AuthTokenPayload } from '@vertesia/common';
|
|
6
|
+
import { Env } from '@vertesia/ui/env';
|
|
7
|
+
|
|
8
|
+
import { getComposableToken } from './auth/composable';
|
|
9
|
+
import { getFirebaseAuth } from './auth/firebase';
|
|
10
|
+
import { TypeRegistry } from './TypeRegistry';
|
|
11
|
+
|
|
12
|
+
export const LastSelectedAccountId_KEY = 'composableai.lastSelectedAccountId';
|
|
13
|
+
export const LastSelectedProjectId_KEY = 'composableai.lastSelectedProjectId';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class UserSession {
|
|
17
|
+
|
|
18
|
+
isLoading = true;
|
|
19
|
+
client: VertesiaClient;
|
|
20
|
+
authError?: Error;
|
|
21
|
+
authToken?: AuthTokenPayload;
|
|
22
|
+
typeRegistry?: TypeRegistry;
|
|
23
|
+
setSession?: (session: UserSession) => void;
|
|
24
|
+
lastSelectedAccount?: string | null;
|
|
25
|
+
lastSelectedProject?: string | null;
|
|
26
|
+
onboardingComplete?: boolean;
|
|
27
|
+
|
|
28
|
+
constructor(client?: VertesiaClient, setSession?: (session: UserSession) => void) {
|
|
29
|
+
|
|
30
|
+
if (client) {
|
|
31
|
+
this.client = client;
|
|
32
|
+
} else {
|
|
33
|
+
this.client = new VertesiaClient({
|
|
34
|
+
serverUrl: Env.endpoints.studio,
|
|
35
|
+
storeUrl: Env.endpoints.zeno,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (setSession) {
|
|
40
|
+
this.setSession = setSession;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.logout = this.logout.bind(this);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get store() {
|
|
47
|
+
return this.client.store;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get user() { //compatibility
|
|
51
|
+
return this.authToken;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get account() { //compatibility
|
|
55
|
+
return this.authToken?.account;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get project() {
|
|
59
|
+
return this.authToken?.project;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get accounts() { //compatibility
|
|
63
|
+
return this.authToken?.accounts;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get authCallback() {
|
|
67
|
+
return this.rawAuthToken.then(token => `Bearer ${token}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get rawAuthToken() {
|
|
71
|
+
return getComposableToken().then(res => {
|
|
72
|
+
const token = res?.rawToken
|
|
73
|
+
if (!token) {
|
|
74
|
+
throw new Error('No token available');
|
|
75
|
+
}
|
|
76
|
+
this.authToken = jwtDecode(token) as unknown as AuthTokenPayload;
|
|
77
|
+
return token;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
signOut() { //compatibility
|
|
82
|
+
this.logout();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
getAccount() {
|
|
86
|
+
return this.authToken?.account;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async login(token: string) {
|
|
90
|
+
this.authError = undefined;
|
|
91
|
+
this.isLoading = false;
|
|
92
|
+
this.client.withAuthCallback(() => this.authCallback)
|
|
93
|
+
this.authToken = jwtDecode(token) as unknown as AuthTokenPayload;
|
|
94
|
+
console.log(`Logging in as ${this.authToken?.name} with account ${this.authToken?.account.name} (${this.authToken?.account.id}, and project ${this.authToken?.project?.name} (${this.authToken?.project?.id})`);
|
|
95
|
+
|
|
96
|
+
//store selected account in local storage
|
|
97
|
+
localStorage.setItem(LastSelectedAccountId_KEY, this.authToken.account.id);
|
|
98
|
+
localStorage.setItem(LastSelectedProjectId_KEY + '-' + this.authToken.account.id, this.authToken.project?.id ?? '');
|
|
99
|
+
// notify the host app of the login
|
|
100
|
+
Env.onLogin?.(this.authToken);
|
|
101
|
+
|
|
102
|
+
// Independent async calls
|
|
103
|
+
await Promise.all([
|
|
104
|
+
this._loadTypes(),
|
|
105
|
+
this.fetchOnboardingStatus(),
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
return Promise.resolve();
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
isLoggedIn() {
|
|
113
|
+
return !!this.authToken;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
logout() {
|
|
118
|
+
console.log('Logging out');
|
|
119
|
+
if (this.authToken) {
|
|
120
|
+
getFirebaseAuth().signOut();
|
|
121
|
+
}
|
|
122
|
+
this.authError = undefined;
|
|
123
|
+
this.isLoading = false;
|
|
124
|
+
this.authToken = undefined;
|
|
125
|
+
this.typeRegistry = undefined;
|
|
126
|
+
this.setSession = undefined;
|
|
127
|
+
this.client.withAuthCallback(undefined);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async switchAccount(targetAccountId: string) {
|
|
131
|
+
localStorage.setItem(LastSelectedAccountId_KEY, targetAccountId);
|
|
132
|
+
if (this) {
|
|
133
|
+
if (this.account && this.project) {
|
|
134
|
+
localStorage.setItem(LastSelectedProjectId_KEY + '-' + this.account.id, this.project.id);
|
|
135
|
+
} else if (this.account) {
|
|
136
|
+
localStorage.removeItem(LastSelectedProjectId_KEY + '-' + this.account.id);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
window.location.replace('/?a=' + targetAccountId);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async switchProject(targetProjectId: string) {
|
|
144
|
+
if (this.account) {
|
|
145
|
+
localStorage.setItem(LastSelectedProjectId_KEY + '-' + this.account.id, targetProjectId);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
window.location.replace('/?a=' + this.account?.id + '&p=' + targetProjectId);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async _loadTypes() {
|
|
152
|
+
if (this.project) {
|
|
153
|
+
return this.store.types.list({}, { layout: true }).then(types => this.typeRegistry = new TypeRegistry(types)).catch(err => {
|
|
154
|
+
console.error('Failed to fetch object types', err);
|
|
155
|
+
throw err;
|
|
156
|
+
})
|
|
157
|
+
} else {
|
|
158
|
+
console.log('No project selected');
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async reloadTypes() {
|
|
163
|
+
return this._loadTypes().then(() => {
|
|
164
|
+
this.setSession?.(this.clone());
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async fetchAccounts() {
|
|
169
|
+
return this.client.accounts.list().then(accounts => {
|
|
170
|
+
if (!this.authToken) {
|
|
171
|
+
throw new Error('No token available');
|
|
172
|
+
}
|
|
173
|
+
this.authToken.accounts = accounts;
|
|
174
|
+
this.setSession?.(this.clone());
|
|
175
|
+
}).catch(err => {
|
|
176
|
+
console.error('Failed to fetch accounts', err);
|
|
177
|
+
throw err;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async fetchOnboardingStatus(): Promise<boolean> {
|
|
182
|
+
if (this.onboardingComplete) {
|
|
183
|
+
console.log('Onboarding already completed');
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
const previousStatus = this.onboardingComplete;
|
|
187
|
+
try {
|
|
188
|
+
const onboarding = await this.client.account.onboardingProgress();
|
|
189
|
+
this.onboardingComplete = Object.values(onboarding).every(value => value === true);
|
|
190
|
+
if (previousStatus !== this.onboardingComplete) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
this.setSession?.(this.clone());
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error('Error fetching onboarding status:', error);
|
|
196
|
+
this.onboardingComplete = false;
|
|
197
|
+
this.setSession?.(this.clone());
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
clone() {
|
|
203
|
+
const session = new UserSession(this.client);
|
|
204
|
+
session.isLoading = this.isLoading;
|
|
205
|
+
session.authError = this.authError;
|
|
206
|
+
session.authToken = this.authToken;
|
|
207
|
+
session.setSession = this.setSession;
|
|
208
|
+
session.lastSelectedAccount = this.lastSelectedAccount;
|
|
209
|
+
session.switchAccount = this.switchAccount;
|
|
210
|
+
session.typeRegistry = this.typeRegistry;
|
|
211
|
+
session.onboardingComplete = this.onboardingComplete;
|
|
212
|
+
return session;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const UserSessionContext = createContext<UserSession>(undefined as any);
|
|
217
|
+
|
|
218
|
+
export function useUserSession() {
|
|
219
|
+
const session = useContext(UserSessionContext);
|
|
220
|
+
|
|
221
|
+
if (!session) {
|
|
222
|
+
throw new Error('useUserSession must be used within a UserSessionProvider');
|
|
223
|
+
}
|
|
224
|
+
return session;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export { UserSession, UserSessionContext };
|