@rebasepro/plugin-insights 0.5.0 → 0.6.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/{plugin-insights/src/components → components}/CollectionInsightsInline.d.ts +2 -1
- package/dist/{plugin-insights/src/components → components}/HomeCardInsightSlot.d.ts +3 -2
- package/dist/{plugin-insights/src/components → components}/HomeInsightsSlot.d.ts +3 -2
- package/dist/{plugin-insights/src/components → components}/InsightWidget.d.ts +3 -2
- package/dist/{plugin-insights/src/components → components}/InsightWidgetSkeleton.d.ts +3 -2
- package/dist/{plugin-insights/src/components → components}/InsightsScorecardView.d.ts +3 -2
- package/dist/{plugin-insights/src/engine → engine}/InsightsProvider.d.ts +2 -2
- package/dist/{plugin-insights/src/index.d.ts → index.d.ts} +1 -1
- package/dist/index.es.js +583 -1072
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +645 -1096
- package/dist/index.umd.js.map +1 -1
- package/package.json +19 -14
- package/src/components/CollectionInsightsInline.tsx +3 -3
- package/src/components/HomeCardInsightSlot.tsx +1 -1
- package/src/components/HomeInsightsSlot.tsx +1 -1
- package/src/components/InsightWidget.tsx +4 -2
- package/src/components/InsightWidgetSkeleton.tsx +21 -13
- package/src/components/InsightsScorecardView.tsx +2 -2
- package/src/engine/InsightsCache.test.ts +5 -3
- package/src/engine/InsightsCache.ts +3 -2
- package/src/engine/useInsightsData.ts +3 -1
- package/src/index.ts +1 -1
- package/src/useInsightsPlugin.tsx +68 -65
- package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
- package/dist/common/src/collections/default-collections.d.ts +0 -9
- package/dist/common/src/collections/index.d.ts +0 -2
- package/dist/common/src/data/buildRebaseData.d.ts +0 -14
- package/dist/common/src/data/query_builder.d.ts +0 -55
- package/dist/common/src/index.d.ts +0 -4
- package/dist/common/src/util/builders.d.ts +0 -57
- package/dist/common/src/util/callbacks.d.ts +0 -6
- package/dist/common/src/util/collections.d.ts +0 -11
- package/dist/common/src/util/common.d.ts +0 -2
- package/dist/common/src/util/conditions.d.ts +0 -26
- package/dist/common/src/util/entities.d.ts +0 -58
- package/dist/common/src/util/enums.d.ts +0 -3
- package/dist/common/src/util/index.d.ts +0 -16
- package/dist/common/src/util/navigation_from_path.d.ts +0 -34
- package/dist/common/src/util/navigation_utils.d.ts +0 -20
- package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
- package/dist/common/src/util/paths.d.ts +0 -14
- package/dist/common/src/util/permissions.d.ts +0 -14
- package/dist/common/src/util/references.d.ts +0 -2
- package/dist/common/src/util/relations.d.ts +0 -22
- package/dist/common/src/util/resolutions.d.ts +0 -72
- package/dist/common/src/util/storage.d.ts +0 -24
- package/dist/core/src/components/AIIcon.d.ts +0 -16
- package/dist/core/src/components/BootstrapAdminBanner.d.ts +0 -4
- package/dist/core/src/components/ConfirmationDialog.d.ts +0 -9
- package/dist/core/src/components/Debug/UIReferenceView.d.ts +0 -1
- package/dist/core/src/components/Debug/UIStyleGuide.d.ts +0 -1
- package/dist/core/src/components/ErrorTooltip.d.ts +0 -2
- package/dist/core/src/components/ErrorView.d.ts +0 -21
- package/dist/core/src/components/LanguageToggle.d.ts +0 -1
- package/dist/core/src/components/LoginView/LoginView.d.ts +0 -109
- package/dist/core/src/components/LoginView/index.d.ts +0 -2
- package/dist/core/src/components/NotFoundPage.d.ts +0 -1
- package/dist/core/src/components/RebaseAuth.d.ts +0 -10
- package/dist/core/src/components/RebaseLogo.d.ts +0 -7
- package/dist/core/src/components/UnsavedChangesDialog.d.ts +0 -9
- package/dist/core/src/components/UserDisplay.d.ts +0 -7
- package/dist/core/src/components/UserSelectPopover.d.ts +0 -62
- package/dist/core/src/components/UserSettingsView.d.ts +0 -1
- package/dist/core/src/components/common/index.d.ts +0 -6
- package/dist/core/src/components/common/table_height.d.ts +0 -5
- package/dist/core/src/components/common/types.d.ts +0 -66
- package/dist/core/src/components/common/useColumnsIds.d.ts +0 -9
- package/dist/core/src/components/common/useDataTableController.d.ts +0 -45
- package/dist/core/src/components/common/useDebouncedData.d.ts +0 -9
- package/dist/core/src/components/common/useScrollRestoration.d.ts +0 -14
- package/dist/core/src/components/index.d.ts +0 -17
- package/dist/core/src/contexts/AdminModeController.d.ts +0 -4
- package/dist/core/src/contexts/AnalyticsContext.d.ts +0 -3
- package/dist/core/src/contexts/AuthControllerContext.d.ts +0 -3
- package/dist/core/src/contexts/CustomizationControllerContext.d.ts +0 -3
- package/dist/core/src/contexts/DataDriverContext.d.ts +0 -3
- package/dist/core/src/contexts/DatabaseAdminContext.d.ts +0 -3
- package/dist/core/src/contexts/DialogsProvider.d.ts +0 -4
- package/dist/core/src/contexts/EffectiveRoleController.d.ts +0 -4
- package/dist/core/src/contexts/InternalUserManagementContext.d.ts +0 -3
- package/dist/core/src/contexts/ModeController.d.ts +0 -4
- package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +0 -6
- package/dist/core/src/contexts/RebaseDataContext.d.ts +0 -3
- package/dist/core/src/contexts/SnackbarProvider.d.ts +0 -2
- package/dist/core/src/contexts/StorageSourceContext.d.ts +0 -3
- package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +0 -3
- package/dist/core/src/contexts/index.d.ts +0 -13
- package/dist/core/src/core/PluginLifecycleManager.d.ts +0 -17
- package/dist/core/src/core/PluginProviderStack.d.ts +0 -21
- package/dist/core/src/core/Rebase.d.ts +0 -14
- package/dist/core/src/core/RebaseProps.d.ts +0 -147
- package/dist/core/src/core/RebaseRouter.d.ts +0 -4
- package/dist/core/src/core/RebaseRoutes.d.ts +0 -17
- package/dist/core/src/core/index.d.ts +0 -4
- package/dist/core/src/hooks/ApiConfigContext.d.ts +0 -24
- package/dist/core/src/hooks/data/delete.d.ts +0 -31
- package/dist/core/src/hooks/data/save.d.ts +0 -34
- package/dist/core/src/hooks/data/useCollectionFetch.d.ts +0 -62
- package/dist/core/src/hooks/data/useData.d.ts +0 -13
- package/dist/core/src/hooks/data/useDataOrder.d.ts +0 -12
- package/dist/core/src/hooks/data/useEntityFetch.d.ts +0 -43
- package/dist/core/src/hooks/data/useRelationSelector.d.ts +0 -52
- package/dist/core/src/hooks/data/useUserSelector.d.ts +0 -31
- package/dist/core/src/hooks/index.d.ts +0 -37
- package/dist/core/src/hooks/useAdminModeController.d.ts +0 -19
- package/dist/core/src/hooks/useAnalyticsController.d.ts +0 -5
- package/dist/core/src/hooks/useAuthController.d.ts +0 -11
- package/dist/core/src/hooks/useAuthSubscription.d.ts +0 -2
- package/dist/core/src/hooks/useBackendStorageSource.d.ts +0 -30
- package/dist/core/src/hooks/useBridgeRegistration.d.ts +0 -18
- package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +0 -6
- package/dist/core/src/hooks/useBuildAdminModeController.d.ts +0 -6
- package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +0 -8
- package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +0 -2
- package/dist/core/src/hooks/useBuildModeController.d.ts +0 -6
- package/dist/core/src/hooks/useClipboard.d.ts +0 -57
- package/dist/core/src/hooks/useCollapsedGroups.d.ts +0 -27
- package/dist/core/src/hooks/useCustomizationController.d.ts +0 -11
- package/dist/core/src/hooks/useDialogsController.d.ts +0 -11
- package/dist/core/src/hooks/useEffectiveRoleController.d.ts +0 -7
- package/dist/core/src/hooks/useInternalUserManagementController.d.ts +0 -12
- package/dist/core/src/hooks/useLargeLayout.d.ts +0 -1
- package/dist/core/src/hooks/useModeController.d.ts +0 -19
- package/dist/core/src/hooks/usePermissions.d.ts +0 -12
- package/dist/core/src/hooks/useRebaseClient.d.ts +0 -5
- package/dist/core/src/hooks/useRebaseContext.d.ts +0 -11
- package/dist/core/src/hooks/useRebaseRegistry.d.ts +0 -34
- package/dist/core/src/hooks/useResolvedComponent.d.ts +0 -47
- package/dist/core/src/hooks/useSlot.d.ts +0 -18
- package/dist/core/src/hooks/useSnackbarController.d.ts +0 -20
- package/dist/core/src/hooks/useStorageSource.d.ts +0 -7
- package/dist/core/src/hooks/useStudioBridge.d.ts +0 -91
- package/dist/core/src/hooks/useTranslation.d.ts +0 -17
- package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +0 -12
- package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +0 -8
- package/dist/core/src/i18n/RebaseI18nProvider.d.ts +0 -33
- package/dist/core/src/index.d.ts +0 -15
- package/dist/core/src/internal/common.d.ts +0 -3
- package/dist/core/src/internal/useRestoreScroll.d.ts +0 -6
- package/dist/core/src/locales/de.d.ts +0 -2
- package/dist/core/src/locales/en.d.ts +0 -10
- package/dist/core/src/locales/es.d.ts +0 -10
- package/dist/core/src/locales/fr.d.ts +0 -2
- package/dist/core/src/locales/hi.d.ts +0 -2
- package/dist/core/src/locales/it.d.ts +0 -2
- package/dist/core/src/locales/pt.d.ts +0 -7
- package/dist/core/src/util/constants.d.ts +0 -1
- package/dist/core/src/util/createFormexStub.d.ts +0 -2
- package/dist/core/src/util/entity_cache.d.ts +0 -22
- package/dist/core/src/util/enums.d.ts +0 -5
- package/dist/core/src/util/icon_list.d.ts +0 -5
- package/dist/core/src/util/icons.d.ts +0 -20
- package/dist/core/src/util/index.d.ts +0 -8
- package/dist/core/src/util/previews.d.ts +0 -4
- package/dist/core/src/util/useStorageUploadController.d.ts +0 -38
- package/dist/formex/src/Field.d.ts +0 -52
- package/dist/formex/src/Formex.d.ts +0 -7
- package/dist/formex/src/index.d.ts +0 -5
- package/dist/formex/src/types.d.ts +0 -40
- package/dist/formex/src/useCreateFormex.d.ts +0 -14
- package/dist/formex/src/utils.d.ts +0 -16
- package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
- package/dist/types/src/controllers/auth.d.ts +0 -104
- package/dist/types/src/controllers/client.d.ts +0 -168
- package/dist/types/src/controllers/collection_registry.d.ts +0 -46
- package/dist/types/src/controllers/customization_controller.d.ts +0 -60
- package/dist/types/src/controllers/data.d.ts +0 -207
- package/dist/types/src/controllers/data_driver.d.ts +0 -218
- package/dist/types/src/controllers/database_admin.d.ts +0 -11
- package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
- package/dist/types/src/controllers/effective_role.d.ts +0 -4
- package/dist/types/src/controllers/email.d.ts +0 -36
- package/dist/types/src/controllers/index.d.ts +0 -18
- package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
- package/dist/types/src/controllers/navigation.d.ts +0 -225
- package/dist/types/src/controllers/registry.d.ts +0 -63
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
- package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
- package/dist/types/src/controllers/snackbar.d.ts +0 -24
- package/dist/types/src/controllers/storage.d.ts +0 -171
- package/dist/types/src/index.d.ts +0 -4
- package/dist/types/src/rebase_context.d.ts +0 -122
- package/dist/types/src/types/auth_adapter.d.ts +0 -301
- package/dist/types/src/types/backend.d.ts +0 -571
- package/dist/types/src/types/backend_hooks.d.ts +0 -172
- package/dist/types/src/types/builders.d.ts +0 -15
- package/dist/types/src/types/chips.d.ts +0 -5
- package/dist/types/src/types/collections.d.ts +0 -961
- package/dist/types/src/types/component_ref.d.ts +0 -47
- package/dist/types/src/types/cron.d.ts +0 -102
- package/dist/types/src/types/data_source.d.ts +0 -64
- package/dist/types/src/types/database_adapter.d.ts +0 -94
- package/dist/types/src/types/entities.d.ts +0 -145
- package/dist/types/src/types/entity_actions.d.ts +0 -104
- package/dist/types/src/types/entity_callbacks.d.ts +0 -173
- package/dist/types/src/types/entity_link_builder.d.ts +0 -7
- package/dist/types/src/types/entity_overrides.d.ts +0 -10
- package/dist/types/src/types/entity_views.d.ts +0 -87
- package/dist/types/src/types/export_import.d.ts +0 -21
- package/dist/types/src/types/formex.d.ts +0 -40
- package/dist/types/src/types/index.d.ts +0 -28
- package/dist/types/src/types/locales.d.ts +0 -4
- package/dist/types/src/types/modify_collections.d.ts +0 -5
- package/dist/types/src/types/plugins.d.ts +0 -282
- package/dist/types/src/types/properties.d.ts +0 -1173
- package/dist/types/src/types/property_config.d.ts +0 -74
- package/dist/types/src/types/relations.d.ts +0 -336
- package/dist/types/src/types/slots.d.ts +0 -262
- package/dist/types/src/types/translations.d.ts +0 -900
- package/dist/types/src/types/user_management_delegate.d.ts +0 -86
- package/dist/types/src/types/websockets.d.ts +0 -78
- package/dist/types/src/users/index.d.ts +0 -1
- package/dist/types/src/users/user.d.ts +0 -50
- package/dist/ui/src/components/Alert.d.ts +0 -12
- package/dist/ui/src/components/Autocomplete.d.ts +0 -21
- package/dist/ui/src/components/Avatar.d.ts +0 -11
- package/dist/ui/src/components/Badge.d.ts +0 -8
- package/dist/ui/src/components/BooleanSwitch.d.ts +0 -14
- package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +0 -17
- package/dist/ui/src/components/Button.d.ts +0 -14
- package/dist/ui/src/components/Card.d.ts +0 -8
- package/dist/ui/src/components/CenteredView.d.ts +0 -9
- package/dist/ui/src/components/Checkbox.d.ts +0 -13
- package/dist/ui/src/components/Chip.d.ts +0 -26
- package/dist/ui/src/components/CircularProgress.d.ts +0 -5
- package/dist/ui/src/components/CircularProgressCenter.d.ts +0 -11
- package/dist/ui/src/components/Collapse.d.ts +0 -9
- package/dist/ui/src/components/ColorPicker.d.ts +0 -30
- package/dist/ui/src/components/Container.d.ts +0 -8
- package/dist/ui/src/components/DateTimeField.d.ts +0 -24
- package/dist/ui/src/components/DebouncedTextField.d.ts +0 -2
- package/dist/ui/src/components/Dialog.d.ts +0 -39
- package/dist/ui/src/components/DialogActions.d.ts +0 -7
- package/dist/ui/src/components/DialogContent.d.ts +0 -7
- package/dist/ui/src/components/DialogTitle.d.ts +0 -10
- package/dist/ui/src/components/ErrorBoundary.d.ts +0 -33
- package/dist/ui/src/components/ExpandablePanel.d.ts +0 -12
- package/dist/ui/src/components/FileUpload.d.ts +0 -23
- package/dist/ui/src/components/FilterChip.d.ts +0 -34
- package/dist/ui/src/components/IconButton.d.ts +0 -12
- package/dist/ui/src/components/InfoLabel.d.ts +0 -5
- package/dist/ui/src/components/InputLabel.d.ts +0 -11
- package/dist/ui/src/components/Label.d.ts +0 -7
- package/dist/ui/src/components/LoadingButton.d.ts +0 -7
- package/dist/ui/src/components/Markdown.d.ts +0 -10
- package/dist/ui/src/components/Menu.d.ts +0 -23
- package/dist/ui/src/components/Menubar.d.ts +0 -80
- package/dist/ui/src/components/MultiSelect.d.ts +0 -48
- package/dist/ui/src/components/Paper.d.ts +0 -6
- package/dist/ui/src/components/Popover.d.ts +0 -24
- package/dist/ui/src/components/RadioGroup.d.ts +0 -28
- package/dist/ui/src/components/ResizablePanels.d.ts +0 -18
- package/dist/ui/src/components/SearchBar.d.ts +0 -26
- package/dist/ui/src/components/Select.d.ts +0 -43
- package/dist/ui/src/components/Separator.d.ts +0 -5
- package/dist/ui/src/components/Sheet.d.ts +0 -22
- package/dist/ui/src/components/Skeleton.d.ts +0 -6
- package/dist/ui/src/components/Slider.d.ts +0 -21
- package/dist/ui/src/components/Table.d.ts +0 -34
- package/dist/ui/src/components/Tabs.d.ts +0 -19
- package/dist/ui/src/components/TextField.d.ts +0 -58
- package/dist/ui/src/components/TextareaAutosize.d.ts +0 -43
- package/dist/ui/src/components/ToggleButtonGroup.d.ts +0 -30
- package/dist/ui/src/components/Tooltip.d.ts +0 -19
- package/dist/ui/src/components/Typography.d.ts +0 -36
- package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +0 -11
- package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +0 -21
- package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +0 -29
- package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +0 -2
- package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +0 -249
- package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +0 -3
- package/dist/ui/src/components/VirtualTable/index.d.ts +0 -3
- package/dist/ui/src/components/VirtualTable/types.d.ts +0 -38
- package/dist/ui/src/components/common/SelectInputLabel.d.ts +0 -5
- package/dist/ui/src/components/index.d.ts +0 -58
- package/dist/ui/src/hooks/PortalContainerContext.d.ts +0 -31
- package/dist/ui/src/hooks/index.d.ts +0 -6
- package/dist/ui/src/hooks/useDebounceCallback.d.ts +0 -1
- package/dist/ui/src/hooks/useDebounceValue.d.ts +0 -1
- package/dist/ui/src/hooks/useDebouncedCallback.d.ts +0 -1
- package/dist/ui/src/hooks/useInjectStyles.d.ts +0 -7
- package/dist/ui/src/hooks/useOutsideAlerter.d.ts +0 -5
- package/dist/ui/src/icons/GitHubIcon.d.ts +0 -2
- package/dist/ui/src/icons/HandleIcon.d.ts +0 -1
- package/dist/ui/src/icons/Icon.d.ts +0 -20
- package/dist/ui/src/icons/cool_icon_keys.d.ts +0 -1
- package/dist/ui/src/icons/icon_keys.d.ts +0 -1
- package/dist/ui/src/icons/index.d.ts +0 -8
- package/dist/ui/src/index.d.ts +0 -5
- package/dist/ui/src/styles.d.ts +0 -12
- package/dist/ui/src/util/chip_colors.d.ts +0 -4
- package/dist/ui/src/util/cls.d.ts +0 -2
- package/dist/ui/src/util/debounce.d.ts +0 -10
- package/dist/ui/src/util/hash.d.ts +0 -1
- package/dist/ui/src/util/index.d.ts +0 -4
- package/dist/ui/src/util/key_to_icon_component.d.ts +0 -1
- /package/dist/{plugin-insights/src/engine → engine}/InsightsCache.d.ts +0 -0
- /package/dist/{plugin-insights/src/engine → engine}/useInsightsData.d.ts +0 -0
- /package/dist/{plugin-insights/src/types → types}/engine.d.ts +0 -0
- /package/dist/{plugin-insights/src/types → types}/index.d.ts +0 -0
- /package/dist/{plugin-insights/src/types → types}/widgets.d.ts +0 -0
- /package/dist/{plugin-insights/src/useInsightsPlugin.d.ts → useInsightsPlugin.d.ts} +0 -0
package/dist/index.umd.js
CHANGED
|
@@ -1,1097 +1,646 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
} else {
|
|
648
|
-
t5 = $[9];
|
|
649
|
-
}
|
|
650
|
-
const t6 = `flex items-center justify-between ${isSmall ? "mb-1" : "mb-2"}`;
|
|
651
|
-
let t7;
|
|
652
|
-
if ($[10] !== titleHeight) {
|
|
653
|
-
t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded", style: {
|
|
654
|
-
height: titleHeight,
|
|
655
|
-
width: "60%"
|
|
656
|
-
} });
|
|
657
|
-
$[10] = titleHeight;
|
|
658
|
-
$[11] = t7;
|
|
659
|
-
} else {
|
|
660
|
-
t7 = $[11];
|
|
661
|
-
}
|
|
662
|
-
let t8;
|
|
663
|
-
if ($[12] !== hasDateRange || $[13] !== isSmall) {
|
|
664
|
-
t8 = hasDateRange && !isSmall && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200/60 dark:bg-surface-700/60 rounded mt-0.5", style: {
|
|
665
|
-
height: 14,
|
|
666
|
-
width: "40%"
|
|
667
|
-
} });
|
|
668
|
-
$[12] = hasDateRange;
|
|
669
|
-
$[13] = isSmall;
|
|
670
|
-
$[14] = t8;
|
|
671
|
-
} else {
|
|
672
|
-
t8 = $[14];
|
|
673
|
-
}
|
|
674
|
-
let t9;
|
|
675
|
-
if ($[15] !== t7 || $[16] !== t8) {
|
|
676
|
-
t9 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
677
|
-
t7,
|
|
678
|
-
t8
|
|
679
|
-
] });
|
|
680
|
-
$[15] = t7;
|
|
681
|
-
$[16] = t8;
|
|
682
|
-
$[17] = t9;
|
|
683
|
-
} else {
|
|
684
|
-
t9 = $[17];
|
|
685
|
-
}
|
|
686
|
-
let t10;
|
|
687
|
-
if ($[18] !== hasIcon || $[19] !== iconSize) {
|
|
688
|
-
t10 = hasIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded", style: {
|
|
689
|
-
height: iconSize,
|
|
690
|
-
width: iconSize
|
|
691
|
-
} }) });
|
|
692
|
-
$[18] = hasIcon;
|
|
693
|
-
$[19] = iconSize;
|
|
694
|
-
$[20] = t10;
|
|
695
|
-
} else {
|
|
696
|
-
t10 = $[20];
|
|
697
|
-
}
|
|
698
|
-
let t11;
|
|
699
|
-
if ($[21] !== t10 || $[22] !== t6 || $[23] !== t9) {
|
|
700
|
-
t11 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t6, children: [
|
|
701
|
-
t9,
|
|
702
|
-
t10
|
|
703
|
-
] });
|
|
704
|
-
$[21] = t10;
|
|
705
|
-
$[22] = t6;
|
|
706
|
-
$[23] = t9;
|
|
707
|
-
$[24] = t11;
|
|
708
|
-
} else {
|
|
709
|
-
t11 = $[24];
|
|
710
|
-
}
|
|
711
|
-
let t12;
|
|
712
|
-
if ($[25] !== valueHeight) {
|
|
713
|
-
t12 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded", style: {
|
|
714
|
-
height: valueHeight,
|
|
715
|
-
width: "40%"
|
|
716
|
-
} });
|
|
717
|
-
$[25] = valueHeight;
|
|
718
|
-
$[26] = t12;
|
|
719
|
-
} else {
|
|
720
|
-
t12 = $[26];
|
|
721
|
-
}
|
|
722
|
-
let t13;
|
|
723
|
-
if ($[27] !== hasComparison || $[28] !== isSmall) {
|
|
724
|
-
t13 = hasComparison && /* @__PURE__ */ jsxRuntime.jsx("div", { className: isSmall ? "mt-0.5" : "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200/60 dark:bg-surface-700/60 rounded", style: {
|
|
725
|
-
height: 16,
|
|
726
|
-
width: "25%"
|
|
727
|
-
} }) });
|
|
728
|
-
$[27] = hasComparison;
|
|
729
|
-
$[28] = isSmall;
|
|
730
|
-
$[29] = t13;
|
|
731
|
-
} else {
|
|
732
|
-
t13 = $[29];
|
|
733
|
-
}
|
|
734
|
-
let t14;
|
|
735
|
-
if ($[30] !== t11 || $[31] !== t12 || $[32] !== t13 || $[33] !== t3 || $[34] !== t4 || $[35] !== t5) {
|
|
736
|
-
t14 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: t3, className: t4, style: t5, children: [
|
|
737
|
-
t11,
|
|
738
|
-
t12,
|
|
739
|
-
t13
|
|
740
|
-
] });
|
|
741
|
-
$[30] = t11;
|
|
742
|
-
$[31] = t12;
|
|
743
|
-
$[32] = t13;
|
|
744
|
-
$[33] = t3;
|
|
745
|
-
$[34] = t4;
|
|
746
|
-
$[35] = t5;
|
|
747
|
-
$[36] = t14;
|
|
748
|
-
} else {
|
|
749
|
-
t14 = $[36];
|
|
750
|
-
}
|
|
751
|
-
return t14;
|
|
752
|
-
}
|
|
753
|
-
InsightWidgetSkeleton.displayName = "InsightWidgetSkeleton";
|
|
754
|
-
function computeFixedHeight(config) {
|
|
755
|
-
let h = 86.5;
|
|
756
|
-
if (config.dateRange) h += 16;
|
|
757
|
-
if (config.comparison) h += 20;
|
|
758
|
-
return Math.ceil(h);
|
|
759
|
-
}
|
|
760
|
-
function InsightWidget(t0) {
|
|
761
|
-
const $ = reactCompilerRuntime.c(37);
|
|
762
|
-
const {
|
|
763
|
-
definition,
|
|
764
|
-
collectionSlug,
|
|
765
|
-
path,
|
|
766
|
-
parentCollectionSlugs,
|
|
767
|
-
compact: t1,
|
|
768
|
-
embedded: t2
|
|
769
|
-
} = t0;
|
|
770
|
-
const compact = t1 === void 0 ? false : t1;
|
|
771
|
-
const embedded = t2 === void 0 ? false : t2;
|
|
772
|
-
let t3;
|
|
773
|
-
if ($[0] !== collectionSlug || $[1] !== parentCollectionSlugs || $[2] !== path) {
|
|
774
|
-
t3 = {
|
|
775
|
-
path,
|
|
776
|
-
collectionSlug,
|
|
777
|
-
parentCollectionSlugs
|
|
778
|
-
};
|
|
779
|
-
$[0] = collectionSlug;
|
|
780
|
-
$[1] = parentCollectionSlugs;
|
|
781
|
-
$[2] = path;
|
|
782
|
-
$[3] = t3;
|
|
783
|
-
} else {
|
|
784
|
-
t3 = $[3];
|
|
785
|
-
}
|
|
786
|
-
const {
|
|
787
|
-
data,
|
|
788
|
-
loading,
|
|
789
|
-
error
|
|
790
|
-
} = useInsightsData(definition, t3);
|
|
791
|
-
let t4;
|
|
792
|
-
if ($[4] !== compact || $[5] !== definition.scorecard || $[6] !== embedded) {
|
|
793
|
-
t4 = !compact && !embedded ? computeFixedHeight(definition.scorecard) : void 0;
|
|
794
|
-
$[4] = compact;
|
|
795
|
-
$[5] = definition.scorecard;
|
|
796
|
-
$[6] = embedded;
|
|
797
|
-
$[7] = t4;
|
|
798
|
-
} else {
|
|
799
|
-
t4 = $[7];
|
|
800
|
-
}
|
|
801
|
-
const fixedHeight = t4;
|
|
802
|
-
if (loading) {
|
|
803
|
-
let t52;
|
|
804
|
-
if ($[8] !== compact || $[9] !== definition.scorecard || $[10] !== embedded || $[11] !== fixedHeight) {
|
|
805
|
-
t52 = /* @__PURE__ */ jsxRuntime.jsx(InsightWidgetSkeleton, { config: definition.scorecard, compact, embedded, fixedHeight });
|
|
806
|
-
$[8] = compact;
|
|
807
|
-
$[9] = definition.scorecard;
|
|
808
|
-
$[10] = embedded;
|
|
809
|
-
$[11] = fixedHeight;
|
|
810
|
-
$[12] = t52;
|
|
811
|
-
} else {
|
|
812
|
-
t52 = $[12];
|
|
813
|
-
}
|
|
814
|
-
return t52;
|
|
815
|
-
}
|
|
816
|
-
if (error) {
|
|
817
|
-
const t52 = `text-red-500/70 dark:text-red-400/70 text-[0.8125rem] ${embedded ? "px-5 py-4 h-full" : `rounded-lg bg-red-500/5 dark:bg-red-400/5 border border-red-500/10 dark:border-red-400/10 ${compact ? "px-3.5 py-3" : "px-5 py-4"}`}`;
|
|
818
|
-
let t62;
|
|
819
|
-
if ($[13] !== fixedHeight) {
|
|
820
|
-
t62 = fixedHeight ? {
|
|
821
|
-
height: fixedHeight
|
|
822
|
-
} : void 0;
|
|
823
|
-
$[13] = fixedHeight;
|
|
824
|
-
$[14] = t62;
|
|
825
|
-
} else {
|
|
826
|
-
t62 = $[14];
|
|
827
|
-
}
|
|
828
|
-
let t7;
|
|
829
|
-
if ($[15] !== definition.title) {
|
|
830
|
-
t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold mb-1", children: definition.title });
|
|
831
|
-
$[15] = definition.title;
|
|
832
|
-
$[16] = t7;
|
|
833
|
-
} else {
|
|
834
|
-
t7 = $[16];
|
|
835
|
-
}
|
|
836
|
-
let t8;
|
|
837
|
-
if ($[17] !== error.message) {
|
|
838
|
-
t8 = /* @__PURE__ */ jsxRuntime.jsx("div", { children: error.message });
|
|
839
|
-
$[17] = error.message;
|
|
840
|
-
$[18] = t8;
|
|
841
|
-
} else {
|
|
842
|
-
t8 = $[18];
|
|
843
|
-
}
|
|
844
|
-
let t9;
|
|
845
|
-
if ($[19] !== t52 || $[20] !== t62 || $[21] !== t7 || $[22] !== t8) {
|
|
846
|
-
t9 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t52, style: t62, children: [
|
|
847
|
-
t7,
|
|
848
|
-
t8
|
|
849
|
-
] });
|
|
850
|
-
$[19] = t52;
|
|
851
|
-
$[20] = t62;
|
|
852
|
-
$[21] = t7;
|
|
853
|
-
$[22] = t8;
|
|
854
|
-
$[23] = t9;
|
|
855
|
-
} else {
|
|
856
|
-
t9 = $[23];
|
|
857
|
-
}
|
|
858
|
-
return t9;
|
|
859
|
-
}
|
|
860
|
-
if (!data || data.rows.length === 0) {
|
|
861
|
-
const t52 = `text-surface-400 dark:text-surface-500 text-[0.8125rem] ${embedded ? "px-5 py-4 h-full" : `rounded-lg bg-surface-100 dark:bg-surface-800 border border-surface-200 dark:border-surface-700 ${compact ? "px-3.5 py-3" : "px-5 py-4"}`}`;
|
|
862
|
-
let t62;
|
|
863
|
-
if ($[24] !== fixedHeight) {
|
|
864
|
-
t62 = fixedHeight ? {
|
|
865
|
-
height: fixedHeight
|
|
866
|
-
} : void 0;
|
|
867
|
-
$[24] = fixedHeight;
|
|
868
|
-
$[25] = t62;
|
|
869
|
-
} else {
|
|
870
|
-
t62 = $[25];
|
|
871
|
-
}
|
|
872
|
-
let t7;
|
|
873
|
-
if ($[26] !== definition.title || $[27] !== t52 || $[28] !== t62) {
|
|
874
|
-
t7 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t52, style: t62, children: [
|
|
875
|
-
definition.title,
|
|
876
|
-
" — No data"
|
|
877
|
-
] });
|
|
878
|
-
$[26] = definition.title;
|
|
879
|
-
$[27] = t52;
|
|
880
|
-
$[28] = t62;
|
|
881
|
-
$[29] = t7;
|
|
882
|
-
} else {
|
|
883
|
-
t7 = $[29];
|
|
884
|
-
}
|
|
885
|
-
return t7;
|
|
886
|
-
}
|
|
887
|
-
const t5 = data.rows[0];
|
|
888
|
-
let t6;
|
|
889
|
-
if ($[30] !== compact || $[31] !== definition.scorecard || $[32] !== definition.title || $[33] !== embedded || $[34] !== fixedHeight || $[35] !== t5) {
|
|
890
|
-
t6 = /* @__PURE__ */ jsxRuntime.jsx(InsightsScorecardView, { config: definition.scorecard, data: t5, title: definition.title, compact, embedded, fixedHeight });
|
|
891
|
-
$[30] = compact;
|
|
892
|
-
$[31] = definition.scorecard;
|
|
893
|
-
$[32] = definition.title;
|
|
894
|
-
$[33] = embedded;
|
|
895
|
-
$[34] = fixedHeight;
|
|
896
|
-
$[35] = t5;
|
|
897
|
-
$[36] = t6;
|
|
898
|
-
} else {
|
|
899
|
-
t6 = $[36];
|
|
900
|
-
}
|
|
901
|
-
return t6;
|
|
902
|
-
}
|
|
903
|
-
InsightWidget.displayName = "InsightWidget";
|
|
904
|
-
function HomeCardInsightSlot(t0) {
|
|
905
|
-
const $ = reactCompilerRuntime.c(10);
|
|
906
|
-
const {
|
|
907
|
-
slug,
|
|
908
|
-
insights
|
|
909
|
-
} = t0;
|
|
910
|
-
if (!insights || insights.length === 0) {
|
|
911
|
-
return null;
|
|
912
|
-
}
|
|
913
|
-
const estimatedRows = Math.ceil(insights.length / 2);
|
|
914
|
-
const minHeight = estimatedRows * 42 + (estimatedRows - 1) * 6;
|
|
915
|
-
let t1;
|
|
916
|
-
if ($[0] !== minHeight) {
|
|
917
|
-
t1 = {
|
|
918
|
-
minHeight
|
|
919
|
-
};
|
|
920
|
-
$[0] = minHeight;
|
|
921
|
-
$[1] = t1;
|
|
922
|
-
} else {
|
|
923
|
-
t1 = $[1];
|
|
924
|
-
}
|
|
925
|
-
let t2;
|
|
926
|
-
if ($[2] !== insights || $[3] !== slug) {
|
|
927
|
-
let t32;
|
|
928
|
-
if ($[5] !== slug) {
|
|
929
|
-
t32 = (def) => /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def, collectionSlug: slug, compact: true }, def.id);
|
|
930
|
-
$[5] = slug;
|
|
931
|
-
$[6] = t32;
|
|
932
|
-
} else {
|
|
933
|
-
t32 = $[6];
|
|
934
|
-
}
|
|
935
|
-
t2 = insights.map(t32);
|
|
936
|
-
$[2] = insights;
|
|
937
|
-
$[3] = slug;
|
|
938
|
-
$[4] = t2;
|
|
939
|
-
} else {
|
|
940
|
-
t2 = $[4];
|
|
941
|
-
}
|
|
942
|
-
let t3;
|
|
943
|
-
if ($[7] !== t1 || $[8] !== t2) {
|
|
944
|
-
t3 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-1.5 mt-2", style: t1, children: t2 });
|
|
945
|
-
$[7] = t1;
|
|
946
|
-
$[8] = t2;
|
|
947
|
-
$[9] = t3;
|
|
948
|
-
} else {
|
|
949
|
-
t3 = $[9];
|
|
950
|
-
}
|
|
951
|
-
return t3;
|
|
952
|
-
}
|
|
953
|
-
HomeCardInsightSlot.displayName = "HomeCardInsightSlot";
|
|
954
|
-
function HomeInsightsSlot(t0) {
|
|
955
|
-
const $ = reactCompilerRuntime.c(5);
|
|
956
|
-
const {
|
|
957
|
-
insights
|
|
958
|
-
} = t0;
|
|
959
|
-
if (!insights || insights.length === 0) {
|
|
960
|
-
return null;
|
|
961
|
-
}
|
|
962
|
-
let t1;
|
|
963
|
-
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
964
|
-
t1 = {
|
|
965
|
-
minHeight: 92
|
|
966
|
-
};
|
|
967
|
-
$[0] = t1;
|
|
968
|
-
} else {
|
|
969
|
-
t1 = $[0];
|
|
970
|
-
}
|
|
971
|
-
let t2;
|
|
972
|
-
if ($[1] !== insights) {
|
|
973
|
-
t2 = insights.map(_temp);
|
|
974
|
-
$[1] = insights;
|
|
975
|
-
$[2] = t2;
|
|
976
|
-
} else {
|
|
977
|
-
t2 = $[2];
|
|
978
|
-
}
|
|
979
|
-
let t3;
|
|
980
|
-
if ($[3] !== t2) {
|
|
981
|
-
t3 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 pb-6", style: t1, children: t2 });
|
|
982
|
-
$[3] = t2;
|
|
983
|
-
$[4] = t3;
|
|
984
|
-
} else {
|
|
985
|
-
t3 = $[4];
|
|
986
|
-
}
|
|
987
|
-
return t3;
|
|
988
|
-
}
|
|
989
|
-
function _temp(def) {
|
|
990
|
-
return /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def }, def.id);
|
|
991
|
-
}
|
|
992
|
-
HomeInsightsSlot.displayName = "HomeInsightsSlot";
|
|
993
|
-
function CollectionInsightsInline(t0) {
|
|
994
|
-
const $ = reactCompilerRuntime.c(11);
|
|
995
|
-
const {
|
|
996
|
-
insights,
|
|
997
|
-
path,
|
|
998
|
-
parentCollectionSlugs,
|
|
999
|
-
parentEntityIds
|
|
1000
|
-
} = t0;
|
|
1001
|
-
if (!insights || insights.length === 0) {
|
|
1002
|
-
return null;
|
|
1003
|
-
}
|
|
1004
|
-
let t1;
|
|
1005
|
-
if ($[0] !== insights || $[1] !== parentCollectionSlugs || $[2] !== parentEntityIds || $[3] !== path) {
|
|
1006
|
-
let t22;
|
|
1007
|
-
if ($[5] !== parentCollectionSlugs || $[6] !== parentEntityIds || $[7] !== path) {
|
|
1008
|
-
t22 = (def) => /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def, path, parentCollectionSlugs, parentEntityIds }, def.id);
|
|
1009
|
-
$[5] = parentCollectionSlugs;
|
|
1010
|
-
$[6] = parentEntityIds;
|
|
1011
|
-
$[7] = path;
|
|
1012
|
-
$[8] = t22;
|
|
1013
|
-
} else {
|
|
1014
|
-
t22 = $[8];
|
|
1015
|
-
}
|
|
1016
|
-
t1 = insights.map(t22);
|
|
1017
|
-
$[0] = insights;
|
|
1018
|
-
$[1] = parentCollectionSlugs;
|
|
1019
|
-
$[2] = parentEntityIds;
|
|
1020
|
-
$[3] = path;
|
|
1021
|
-
$[4] = t1;
|
|
1022
|
-
} else {
|
|
1023
|
-
t1 = $[4];
|
|
1024
|
-
}
|
|
1025
|
-
let t2;
|
|
1026
|
-
if ($[9] !== t1) {
|
|
1027
|
-
t2 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 pb-4", children: t1 });
|
|
1028
|
-
$[9] = t1;
|
|
1029
|
-
$[10] = t2;
|
|
1030
|
-
} else {
|
|
1031
|
-
t2 = $[10];
|
|
1032
|
-
}
|
|
1033
|
-
return t2;
|
|
1034
|
-
}
|
|
1035
|
-
CollectionInsightsInline.displayName = "CollectionInsightsInline";
|
|
1036
|
-
function useInsightsPlugin(config) {
|
|
1037
|
-
const {
|
|
1038
|
-
insights,
|
|
1039
|
-
cacheTTL
|
|
1040
|
-
} = config;
|
|
1041
|
-
const slots = [];
|
|
1042
|
-
if (insights.home && insights.home.length > 0) {
|
|
1043
|
-
const homeInsights = insights.home;
|
|
1044
|
-
slots.push({
|
|
1045
|
-
slot: "home.children.start",
|
|
1046
|
-
Component: (props) => /* @__PURE__ */ jsxRuntime.jsx(HomeInsightsSlot, { ...props, insights: homeInsights }),
|
|
1047
|
-
order: 10
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1050
|
-
if (insights.collections) {
|
|
1051
|
-
for (const [slug, defs] of Object.entries(insights.collections)) {
|
|
1052
|
-
if (defs.length === 0) continue;
|
|
1053
|
-
const collectionInsights = defs;
|
|
1054
|
-
slots.push({
|
|
1055
|
-
slot: "collection.insights",
|
|
1056
|
-
Component: (props) => {
|
|
1057
|
-
const path = props.path;
|
|
1058
|
-
const collectionSlug = path?.split("/").filter(Boolean).pop() ?? "";
|
|
1059
|
-
if (collectionSlug !== slug) return null;
|
|
1060
|
-
return /* @__PURE__ */ jsxRuntime.jsx(CollectionInsightsInline, { ...props, insights: collectionInsights });
|
|
1061
|
-
},
|
|
1062
|
-
order: 10
|
|
1063
|
-
});
|
|
1064
|
-
slots.push({
|
|
1065
|
-
slot: "home.card.insight",
|
|
1066
|
-
Component: (props) => {
|
|
1067
|
-
const cardSlug = props.slug;
|
|
1068
|
-
if (cardSlug !== slug) return null;
|
|
1069
|
-
return /* @__PURE__ */ jsxRuntime.jsx(HomeCardInsightSlot, { ...props, insights: collectionInsights });
|
|
1070
|
-
},
|
|
1071
|
-
order: 10
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
return {
|
|
1076
|
-
key: "plugin-insights",
|
|
1077
|
-
slots,
|
|
1078
|
-
providers: [{
|
|
1079
|
-
scope: "root",
|
|
1080
|
-
Component: InsightsProvider,
|
|
1081
|
-
props: {
|
|
1082
|
-
cacheTTL
|
|
1083
|
-
}
|
|
1084
|
-
}]
|
|
1085
|
-
};
|
|
1086
|
-
}
|
|
1087
|
-
exports2.InsightWidget = InsightWidget;
|
|
1088
|
-
exports2.InsightWidgetSkeleton = InsightWidgetSkeleton;
|
|
1089
|
-
exports2.InsightsCache = InsightsCache;
|
|
1090
|
-
exports2.InsightsProvider = InsightsProvider;
|
|
1091
|
-
exports2.InsightsScorecardView = InsightsScorecardView;
|
|
1092
|
-
exports2.useInsightsData = useInsightsData;
|
|
1093
|
-
exports2.useInsightsEngine = useInsightsEngine;
|
|
1094
|
-
exports2.useInsightsPlugin = useInsightsPlugin;
|
|
1095
|
-
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
1096
|
-
}));
|
|
1097
|
-
//# sourceMappingURL=index.umd.js.map
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react/jsx-runtime"), require("@rebasepro/core"), require("@rebasepro/ui")) : typeof define === "function" && define.amd ? define([
|
|
3
|
+
"exports",
|
|
4
|
+
"react",
|
|
5
|
+
"react/jsx-runtime",
|
|
6
|
+
"@rebasepro/core",
|
|
7
|
+
"@rebasepro/ui"
|
|
8
|
+
], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.Rebase = {}, global.react, global.react_jsx_runtime, global._rebasepro_core, global._rebasepro_ui));
|
|
9
|
+
})(this, function(exports, react, react_jsx_runtime, _rebasepro_core, _rebasepro_ui) {
|
|
10
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
//#region \0rolldown/runtime.js
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
+
key = keys[i];
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
+
get: ((k) => from[k]).bind(null, key),
|
|
23
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
+
value: mod,
|
|
30
|
+
enumerable: true
|
|
31
|
+
}) : target, mod));
|
|
32
|
+
//#endregion
|
|
33
|
+
react = __toESM(react, 1);
|
|
34
|
+
//#region src/engine/InsightsCache.ts
|
|
35
|
+
/**
|
|
36
|
+
* In-memory cache for insight query results.
|
|
37
|
+
* Supports TTL-based expiry and inflight request deduplication
|
|
38
|
+
* to prevent redundant network requests when multiple widgets
|
|
39
|
+
* share the same query.
|
|
40
|
+
*/
|
|
41
|
+
var InsightsCache = class {
|
|
42
|
+
ttl;
|
|
43
|
+
cache = /* @__PURE__ */ new Map();
|
|
44
|
+
inflight = /* @__PURE__ */ new Map();
|
|
45
|
+
constructor(ttl = 6e4) {
|
|
46
|
+
this.ttl = ttl;
|
|
47
|
+
}
|
|
48
|
+
get(key) {
|
|
49
|
+
const entry = this.cache.get(key);
|
|
50
|
+
if (!entry) return null;
|
|
51
|
+
if (Date.now() - entry.timestamp > this.ttl) {
|
|
52
|
+
this.cache.delete(key);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return entry.data;
|
|
56
|
+
}
|
|
57
|
+
set(key, data) {
|
|
58
|
+
this.cache.set(key, {
|
|
59
|
+
data,
|
|
60
|
+
timestamp: Date.now()
|
|
61
|
+
});
|
|
62
|
+
this.inflight.delete(key);
|
|
63
|
+
}
|
|
64
|
+
getInflight(key) {
|
|
65
|
+
return this.inflight.get(key) ?? null;
|
|
66
|
+
}
|
|
67
|
+
setInflight(key, promise) {
|
|
68
|
+
this.inflight.set(key, promise);
|
|
69
|
+
}
|
|
70
|
+
invalidate(key) {
|
|
71
|
+
if (key) {
|
|
72
|
+
this.cache.delete(key);
|
|
73
|
+
this.inflight.delete(key);
|
|
74
|
+
} else {
|
|
75
|
+
this.cache.clear();
|
|
76
|
+
this.inflight.clear();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/engine/InsightsProvider.tsx
|
|
82
|
+
var InsightsContext = (0, react.createContext)(null);
|
|
83
|
+
/**
|
|
84
|
+
* Root-level provider for the insights data engine.
|
|
85
|
+
* Injected automatically by the plugin via `providers: [{ scope: "root" }]`.
|
|
86
|
+
*
|
|
87
|
+
* Manages a single `InsightsCache` instance shared by all insight widgets
|
|
88
|
+
* for TTL-based caching and inflight request deduplication.
|
|
89
|
+
*/
|
|
90
|
+
function InsightsProvider({ cacheTTL, children }) {
|
|
91
|
+
const cache = (0, react.useMemo)(() => new InsightsCache(cacheTTL), [cacheTTL]);
|
|
92
|
+
const value = (0, react.useMemo)(() => ({ cache }), [cache]);
|
|
93
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InsightsContext.Provider, {
|
|
94
|
+
value,
|
|
95
|
+
children
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Access the insights cache (for advanced usage).
|
|
100
|
+
* Returns null when called outside of an `InsightsProvider`
|
|
101
|
+
* (e.g. during auth-loading phase before plugin providers mount).
|
|
102
|
+
*/
|
|
103
|
+
function useInsightsEngine() {
|
|
104
|
+
return (0, react.useContext)(InsightsContext);
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/engine/useInsightsData.ts
|
|
108
|
+
/**
|
|
109
|
+
* Hook that fetches and caches data for a single insight definition.
|
|
110
|
+
*
|
|
111
|
+
* Calls the definition's own `data()` callback and manages:
|
|
112
|
+
* - TTL-based caching via InsightsCache
|
|
113
|
+
* - Inflight request deduplication (multiple mounts of the same widget)
|
|
114
|
+
* - Loading and error state management
|
|
115
|
+
*
|
|
116
|
+
* @param definition - The insight to fetch data for
|
|
117
|
+
* @param collectionSlug - Optional collection context for cache key scoping
|
|
118
|
+
*/
|
|
119
|
+
function useInsightsData(definition, context) {
|
|
120
|
+
const cache = useInsightsEngine()?.cache ?? null;
|
|
121
|
+
const { initialLoading, authLoading, user, loginSkipped } = (0, _rebasepro_core.useAuthController)();
|
|
122
|
+
const authReady = !initialLoading && !authLoading && (Boolean(user) || loginSkipped);
|
|
123
|
+
const [data, setData] = (0, react.useState)(null);
|
|
124
|
+
const [loading, setLoading] = (0, react.useState)(true);
|
|
125
|
+
const [error, setError] = (0, react.useState)(null);
|
|
126
|
+
const cacheKey = `${definition.id}:${context.path ?? context.collectionSlug ?? "global"}`;
|
|
127
|
+
(0, react.useEffect)(() => {
|
|
128
|
+
if (!authReady || !cache) return;
|
|
129
|
+
let cancelled = false;
|
|
130
|
+
const cached = cache.get(cacheKey);
|
|
131
|
+
if (cached) {
|
|
132
|
+
setData(cached);
|
|
133
|
+
setLoading(false);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const inflight = cache.getInflight(cacheKey);
|
|
137
|
+
if (inflight) {
|
|
138
|
+
setLoading(true);
|
|
139
|
+
inflight.then((result) => {
|
|
140
|
+
if (!cancelled) setData(result);
|
|
141
|
+
}).catch((err) => {
|
|
142
|
+
if (!cancelled) setError(err instanceof Error ? err : new Error(String(err)));
|
|
143
|
+
}).finally(() => {
|
|
144
|
+
if (!cancelled) setLoading(false);
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
setLoading(true);
|
|
149
|
+
setError(null);
|
|
150
|
+
const promise = definition.data(context);
|
|
151
|
+
cache.setInflight(cacheKey, promise);
|
|
152
|
+
promise.then((result) => {
|
|
153
|
+
cache.set(cacheKey, result);
|
|
154
|
+
if (!cancelled) setData(result);
|
|
155
|
+
}).catch((err) => {
|
|
156
|
+
cache.invalidate(cacheKey);
|
|
157
|
+
if (!cancelled) setError(err instanceof Error ? err : new Error(String(err)));
|
|
158
|
+
}).finally(() => {
|
|
159
|
+
if (!cancelled) setLoading(false);
|
|
160
|
+
});
|
|
161
|
+
return () => {
|
|
162
|
+
cancelled = true;
|
|
163
|
+
};
|
|
164
|
+
}, [
|
|
165
|
+
definition.id,
|
|
166
|
+
definition.data,
|
|
167
|
+
context.path,
|
|
168
|
+
context.collectionSlug,
|
|
169
|
+
cacheKey,
|
|
170
|
+
cache,
|
|
171
|
+
authReady
|
|
172
|
+
]);
|
|
173
|
+
return {
|
|
174
|
+
data,
|
|
175
|
+
loading,
|
|
176
|
+
error
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/components/InsightsScorecardView.tsx
|
|
181
|
+
function formatNumber(value, format) {
|
|
182
|
+
if (value === null || value === void 0) return "N/A";
|
|
183
|
+
const options = {
|
|
184
|
+
style: format?.style ?? "decimal",
|
|
185
|
+
notation: format?.notation ?? "standard",
|
|
186
|
+
maximumFractionDigits: format?.decimals ?? 1,
|
|
187
|
+
minimumFractionDigits: format?.decimals ?? 1
|
|
188
|
+
};
|
|
189
|
+
if (format?.style === "currency") options.currency = format.currency ?? "USD";
|
|
190
|
+
let formatted = new Intl.NumberFormat("en-US", options).format(value);
|
|
191
|
+
if (format?.showSign && value > 0) formatted = "+" + formatted;
|
|
192
|
+
return formatted;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Scorecard widget for the Rebase design system.
|
|
196
|
+
*
|
|
197
|
+
* Renders a single KPI metric with optional comparison value and icon.
|
|
198
|
+
* Uses Tailwind `dark:` classes — no JS dark mode detection.
|
|
199
|
+
* Icons are resolved via `getIcon` from `@rebasepro/core`.
|
|
200
|
+
*/
|
|
201
|
+
function InsightsScorecardView({ config, data, title, compact = false, embedded = false, fixedHeight }) {
|
|
202
|
+
const containerRef = (0, react.useRef)(null);
|
|
203
|
+
const [containerWidth, setContainerWidth] = (0, react.useState)(null);
|
|
204
|
+
react.default.useLayoutEffect(() => {
|
|
205
|
+
if (!containerRef.current) return;
|
|
206
|
+
setContainerWidth(containerRef.current.offsetWidth);
|
|
207
|
+
const observer = new ResizeObserver((entries) => {
|
|
208
|
+
for (const entry of entries) setContainerWidth(entry.contentRect.width);
|
|
209
|
+
});
|
|
210
|
+
observer.observe(containerRef.current);
|
|
211
|
+
return () => observer.disconnect();
|
|
212
|
+
}, []);
|
|
213
|
+
const mainValue = data[config.value.field];
|
|
214
|
+
const formattedValue = typeof mainValue === "number" ? formatNumber(mainValue, config.value.format) : String(mainValue ?? "N/A");
|
|
215
|
+
let comparisonElement = null;
|
|
216
|
+
if (config.comparison) {
|
|
217
|
+
const comparisonValue = data[config.comparison.field];
|
|
218
|
+
if (typeof comparisonValue === "number") {
|
|
219
|
+
const formattedComparison = formatNumber(comparisonValue, config.comparison.format);
|
|
220
|
+
const isPositive = comparisonValue > 0;
|
|
221
|
+
const isNegative = comparisonValue < 0;
|
|
222
|
+
let colorClass = "text-surface-500 dark:text-surface-400";
|
|
223
|
+
if (config.comparison.intent === "increase_is_good") {
|
|
224
|
+
if (isPositive) colorClass = "text-emerald-500";
|
|
225
|
+
if (isNegative) colorClass = "text-red-500";
|
|
226
|
+
} else if (config.comparison.intent === "decrease_is_good") {
|
|
227
|
+
if (isPositive) colorClass = "text-red-500";
|
|
228
|
+
if (isNegative) colorClass = "text-emerald-500";
|
|
229
|
+
}
|
|
230
|
+
comparisonElement = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
231
|
+
className: `font-medium ${compact ? "text-[10px]" : "text-xs"} ${colorClass}`,
|
|
232
|
+
children: formattedComparison
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const isSmall = compact || containerWidth !== null && containerWidth < 200;
|
|
237
|
+
const iconElement = config.icon ? (0, _rebasepro_core.getIcon)(config.icon, "text-surface-400 dark:text-surface-500", void 0, isSmall ? 14 : 18) : null;
|
|
238
|
+
if (compact) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
239
|
+
className: (0, _rebasepro_ui.cls)("flex flex-col gap-0.5 px-2.5 py-2 rounded-md bg-transparent border min-w-0", _rebasepro_ui.defaultBorderMixin),
|
|
240
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
241
|
+
className: "text-[10px] uppercase tracking-wider text-surface-400 dark:text-surface-500 truncate",
|
|
242
|
+
children: title
|
|
243
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
244
|
+
className: "flex items-baseline gap-1.5",
|
|
245
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
246
|
+
className: "text-sm font-semibold tabular-nums text-surface-800 dark:text-surface-100",
|
|
247
|
+
children: formattedValue
|
|
248
|
+
}), comparisonElement]
|
|
249
|
+
})]
|
|
250
|
+
});
|
|
251
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
252
|
+
ref: containerRef,
|
|
253
|
+
className: embedded ? `flex flex-col min-w-0 h-full ${isSmall ? "px-3.5 py-3" : "px-5 py-4"}` : (0, _rebasepro_ui.cls)("rounded-lg flex flex-col min-w-0 bg-transparent border", _rebasepro_ui.defaultBorderMixin, isSmall ? "px-3.5 py-3" : "px-5 py-4"),
|
|
254
|
+
style: embedded ? void 0 : fixedHeight ? { height: fixedHeight } : { minHeight: isSmall ? 68 : 92 },
|
|
255
|
+
children: [
|
|
256
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
257
|
+
className: `flex items-center justify-between ${isSmall ? "mb-1" : "mb-2"}`,
|
|
258
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
259
|
+
className: "flex flex-col min-w-0",
|
|
260
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
261
|
+
className: `font-medium leading-snug truncate text-surface-500 dark:text-surface-400 ${isSmall ? "text-[11px]" : "text-xs"}`,
|
|
262
|
+
children: title
|
|
263
|
+
}), config.dateRange && !isSmall && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
264
|
+
className: "text-[10px] text-surface-400 dark:text-surface-500 truncate mt-0.5",
|
|
265
|
+
children: config.dateRange
|
|
266
|
+
})]
|
|
267
|
+
}), iconElement && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
268
|
+
className: "ml-2 shrink-0",
|
|
269
|
+
children: iconElement
|
|
270
|
+
})]
|
|
271
|
+
}),
|
|
272
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
273
|
+
className: `font-semibold leading-tight tracking-tight break-all text-surface-800 dark:text-surface-100 ${isSmall ? "text-lg" : containerWidth !== null && containerWidth < 300 ? "text-xl" : "text-2xl"}`,
|
|
274
|
+
children: formattedValue
|
|
275
|
+
}),
|
|
276
|
+
comparisonElement && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
277
|
+
className: isSmall ? "mt-0.5" : "mt-1",
|
|
278
|
+
children: comparisonElement
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
InsightsScorecardView.displayName = "InsightsScorecardView";
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/components/InsightWidgetSkeleton.tsx
|
|
286
|
+
/**
|
|
287
|
+
* Skeleton loader for scorecard insight widgets — displays animated
|
|
288
|
+
* shimmer placeholders that exactly match the final rendered layout
|
|
289
|
+
* of InsightsScorecardView for a given config, preventing layout shift.
|
|
290
|
+
*
|
|
291
|
+
* The skeleton receives the scorecard config so it can conditionally
|
|
292
|
+
* render placeholder lines for comparison, dateRange, and icon —
|
|
293
|
+
* only when the loaded view will also render them.
|
|
294
|
+
*
|
|
295
|
+
* The standard skeleton mirrors InsightsScorecardView's responsive
|
|
296
|
+
* container-width breakpoints (ResizeObserver → isSmall / isMedium)
|
|
297
|
+
* and uses placeholder heights that exactly match the **computed**
|
|
298
|
+
* Tailwind line-heights (accounting for `leading-*` overrides).
|
|
299
|
+
* This guarantees a pixel-perfect skeleton → loaded transition.
|
|
300
|
+
*/
|
|
301
|
+
function InsightWidgetSkeleton({ config, compact = false, embedded = false, fixedHeight }) {
|
|
302
|
+
const hasComparison = Boolean(config.comparison);
|
|
303
|
+
const hasIcon = Boolean(config.icon);
|
|
304
|
+
const hasDateRange = Boolean(config.dateRange);
|
|
305
|
+
if (compact) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
306
|
+
className: (0, _rebasepro_ui.cls)("animate-pulse", embedded ? "h-full px-2.5 py-2" : "flex flex-col gap-0.5 rounded-md bg-transparent border min-w-0 px-2.5 py-2", !embedded && _rebasepro_ui.defaultBorderMixin),
|
|
307
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
308
|
+
className: "bg-surface-200 dark:bg-surface-700 rounded-sm",
|
|
309
|
+
style: {
|
|
310
|
+
height: 14,
|
|
311
|
+
width: 48
|
|
312
|
+
}
|
|
313
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
314
|
+
className: "flex items-baseline gap-1.5",
|
|
315
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
316
|
+
className: "bg-surface-200 dark:bg-surface-700 rounded-sm",
|
|
317
|
+
style: {
|
|
318
|
+
height: 20,
|
|
319
|
+
width: 40
|
|
320
|
+
}
|
|
321
|
+
}), hasComparison && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
322
|
+
className: "bg-surface-200/60 dark:bg-surface-700/60 rounded-sm",
|
|
323
|
+
style: {
|
|
324
|
+
height: 14,
|
|
325
|
+
width: 28
|
|
326
|
+
}
|
|
327
|
+
})]
|
|
328
|
+
})]
|
|
329
|
+
});
|
|
330
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StandardSkeleton, {
|
|
331
|
+
hasComparison,
|
|
332
|
+
hasIcon,
|
|
333
|
+
hasDateRange,
|
|
334
|
+
embedded,
|
|
335
|
+
fixedHeight
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Inner component for the standard scorecard skeleton.
|
|
340
|
+
*
|
|
341
|
+
* Mirrors InsightsScorecardView's layout by:
|
|
342
|
+
* 1. Using the same ResizeObserver + containerWidth pattern for
|
|
343
|
+
* responsive breakpoints (isSmall < 200px, isMedium < 300px).
|
|
344
|
+
* 2. Using placeholder heights derived from the exact computed
|
|
345
|
+
* Tailwind line-heights that InsightsScorecardView renders.
|
|
346
|
+
* 3. Matching all container classes, margins, paddings, and flex
|
|
347
|
+
* layout properties identically.
|
|
348
|
+
*/
|
|
349
|
+
function StandardSkeleton({ hasComparison, hasIcon, hasDateRange, embedded, fixedHeight }) {
|
|
350
|
+
const containerRef = (0, react.useRef)(null);
|
|
351
|
+
const [containerWidth, setContainerWidth] = (0, react.useState)(null);
|
|
352
|
+
react.default.useLayoutEffect(() => {
|
|
353
|
+
if (!containerRef.current) return;
|
|
354
|
+
setContainerWidth(containerRef.current.offsetWidth);
|
|
355
|
+
const observer = new ResizeObserver((entries) => {
|
|
356
|
+
for (const entry of entries) setContainerWidth(entry.contentRect.width);
|
|
357
|
+
});
|
|
358
|
+
observer.observe(containerRef.current);
|
|
359
|
+
return () => observer.disconnect();
|
|
360
|
+
}, []);
|
|
361
|
+
const isSmall = containerWidth !== null && containerWidth < 200;
|
|
362
|
+
const titleHeight = isSmall ? 15 : 16.5;
|
|
363
|
+
const valueHeight = isSmall ? 22.5 : containerWidth !== null && containerWidth < 300 ? 25 : 30;
|
|
364
|
+
const comparisonHeight = 16;
|
|
365
|
+
const iconSize = isSmall ? 14 : 18;
|
|
366
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
367
|
+
ref: containerRef,
|
|
368
|
+
className: (0, _rebasepro_ui.cls)("animate-pulse", embedded ? `flex flex-col min-w-0 h-full ${isSmall ? "px-3.5 py-3" : "px-5 py-4"}` : (0, _rebasepro_ui.cls)("rounded-lg flex flex-col min-w-0 bg-transparent border", _rebasepro_ui.defaultBorderMixin, isSmall ? "px-3.5 py-3" : "px-5 py-4")),
|
|
369
|
+
style: embedded ? void 0 : fixedHeight ? { height: fixedHeight } : { minHeight: isSmall ? 68 : 92 },
|
|
370
|
+
children: [
|
|
371
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
372
|
+
className: `flex items-center justify-between ${isSmall ? "mb-1" : "mb-2"}`,
|
|
373
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
374
|
+
className: "flex flex-col min-w-0",
|
|
375
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
376
|
+
className: "bg-surface-200 dark:bg-surface-700 rounded",
|
|
377
|
+
style: {
|
|
378
|
+
height: titleHeight,
|
|
379
|
+
width: "60%"
|
|
380
|
+
}
|
|
381
|
+
}), hasDateRange && !isSmall && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
382
|
+
className: "bg-surface-200/60 dark:bg-surface-700/60 rounded mt-0.5",
|
|
383
|
+
style: {
|
|
384
|
+
height: 14,
|
|
385
|
+
width: "40%"
|
|
386
|
+
}
|
|
387
|
+
})]
|
|
388
|
+
}), hasIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
389
|
+
className: "ml-2 shrink-0",
|
|
390
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
391
|
+
className: "bg-surface-200 dark:bg-surface-700 rounded",
|
|
392
|
+
style: {
|
|
393
|
+
height: iconSize,
|
|
394
|
+
width: iconSize
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
})]
|
|
398
|
+
}),
|
|
399
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
400
|
+
className: "bg-surface-200 dark:bg-surface-700 rounded",
|
|
401
|
+
style: {
|
|
402
|
+
height: valueHeight,
|
|
403
|
+
width: "40%"
|
|
404
|
+
}
|
|
405
|
+
}),
|
|
406
|
+
hasComparison && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
407
|
+
className: isSmall ? "mt-0.5" : "mt-1",
|
|
408
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
409
|
+
className: "bg-surface-200/60 dark:bg-surface-700/60 rounded",
|
|
410
|
+
style: {
|
|
411
|
+
height: comparisonHeight,
|
|
412
|
+
width: "25%"
|
|
413
|
+
}
|
|
414
|
+
})
|
|
415
|
+
})
|
|
416
|
+
]
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
InsightWidgetSkeleton.displayName = "InsightWidgetSkeleton";
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/components/InsightWidget.tsx
|
|
422
|
+
/**
|
|
423
|
+
* Compute a deterministic fixed height for a standard scorecard based
|
|
424
|
+
* on which optional elements the config declares. This eliminates
|
|
425
|
+
* layout shift between skeleton and loaded states.
|
|
426
|
+
*
|
|
427
|
+
* Breakdown (non-compact, non-small):
|
|
428
|
+
* py-4 padding: 16 + 16 = 32
|
|
429
|
+
* title row: 16.5 (text-xs leading-snug)
|
|
430
|
+
* mb-2 margin: 8
|
|
431
|
+
* value: 30 (text-2xl leading-tight)
|
|
432
|
+
* ---
|
|
433
|
+
* base: 86.5
|
|
434
|
+
* + dateRange: +16 (14px text + 2px mt-0.5)
|
|
435
|
+
* + comparison: +20 (16px text + 4px mt-1)
|
|
436
|
+
*/
|
|
437
|
+
function computeFixedHeight(config) {
|
|
438
|
+
let h = 86.5;
|
|
439
|
+
if (config.dateRange) h += 16;
|
|
440
|
+
if (config.comparison) h += 20;
|
|
441
|
+
return Math.ceil(h);
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Single insight widget orchestrator.
|
|
445
|
+
*
|
|
446
|
+
* Wraps skeleton and loaded states in a fixed-height container
|
|
447
|
+
* (computed from the scorecard config) to prevent layout shift.
|
|
448
|
+
*
|
|
449
|
+
* All theme-awareness is handled via Tailwind `dark:` classes.
|
|
450
|
+
*/
|
|
451
|
+
function InsightWidget({ definition, collectionSlug, path, parentCollectionSlugs, parentEntityIds, compact = false, embedded = false }) {
|
|
452
|
+
const { data, loading, error } = useInsightsData(definition, {
|
|
453
|
+
path,
|
|
454
|
+
collectionSlug,
|
|
455
|
+
parentCollectionSlugs
|
|
456
|
+
});
|
|
457
|
+
const fixedHeight = !compact && !embedded ? computeFixedHeight(definition.scorecard) : void 0;
|
|
458
|
+
if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InsightWidgetSkeleton, {
|
|
459
|
+
config: definition.scorecard,
|
|
460
|
+
compact,
|
|
461
|
+
embedded,
|
|
462
|
+
fixedHeight
|
|
463
|
+
});
|
|
464
|
+
if (error) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
465
|
+
className: `text-red-500/70 dark:text-red-400/70 text-[0.8125rem] ${embedded ? "px-5 py-4 h-full" : `rounded-lg bg-red-500/5 dark:bg-red-400/5 border border-red-500/10 dark:border-red-400/10 ${compact ? "px-3.5 py-3" : "px-5 py-4"}`}`,
|
|
466
|
+
style: fixedHeight ? { height: fixedHeight } : void 0,
|
|
467
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
468
|
+
className: "font-semibold mb-1",
|
|
469
|
+
children: definition.title
|
|
470
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: error.message })]
|
|
471
|
+
});
|
|
472
|
+
if (!data || data.rows.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
473
|
+
className: `text-surface-400 dark:text-surface-500 text-[0.8125rem] ${embedded ? "px-5 py-4 h-full" : `rounded-lg bg-surface-100 dark:bg-surface-800 border border-surface-200 dark:border-surface-700 ${compact ? "px-3.5 py-3" : "px-5 py-4"}`}`,
|
|
474
|
+
style: fixedHeight ? { height: fixedHeight } : void 0,
|
|
475
|
+
children: [definition.title, " — No data"]
|
|
476
|
+
});
|
|
477
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InsightsScorecardView, {
|
|
478
|
+
config: definition.scorecard,
|
|
479
|
+
data: data.rows[0],
|
|
480
|
+
title: definition.title,
|
|
481
|
+
compact,
|
|
482
|
+
embedded,
|
|
483
|
+
fixedHeight
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
InsightWidget.displayName = "InsightWidget";
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region src/components/HomeCardInsightSlot.tsx
|
|
489
|
+
/**
|
|
490
|
+
* Renders compact insight widgets inline within a home page collection card.
|
|
491
|
+
* Injected via the `home.card.insight` slot.
|
|
492
|
+
*
|
|
493
|
+
* Uses a horizontal flex layout so multiple cards sit side by side.
|
|
494
|
+
*/
|
|
495
|
+
function HomeCardInsightSlot({ slug, insights }) {
|
|
496
|
+
if (!insights || insights.length === 0) return null;
|
|
497
|
+
const estimatedRows = Math.ceil(insights.length / 2);
|
|
498
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
499
|
+
className: "flex flex-wrap items-center gap-1.5 mt-2",
|
|
500
|
+
style: { minHeight: estimatedRows * 42 + (estimatedRows - 1) * 6 },
|
|
501
|
+
children: insights.map((def) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InsightWidget, {
|
|
502
|
+
definition: def,
|
|
503
|
+
collectionSlug: slug,
|
|
504
|
+
compact: true
|
|
505
|
+
}, def.id))
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
HomeCardInsightSlot.displayName = "HomeCardInsightSlot";
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/components/HomeInsightsSlot.tsx
|
|
511
|
+
/**
|
|
512
|
+
* Scorecard insights panel rendered at the top of the home page.
|
|
513
|
+
* Injected via the `home.children.start` slot.
|
|
514
|
+
*
|
|
515
|
+
* Renders scorecards in a responsive grid (up to 4 columns).
|
|
516
|
+
*/
|
|
517
|
+
function HomeInsightsSlot({ insights }) {
|
|
518
|
+
if (!insights || insights.length === 0) return null;
|
|
519
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
520
|
+
className: "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 pb-6",
|
|
521
|
+
style: { minHeight: 92 },
|
|
522
|
+
children: insights.map((def) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InsightWidget, { definition: def }, def.id))
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
HomeInsightsSlot.displayName = "HomeInsightsSlot";
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/components/CollectionInsightsInline.tsx
|
|
528
|
+
/**
|
|
529
|
+
* Renders scorecard insight widgets inline within a collection's list view,
|
|
530
|
+
* positioned below the title and above the main data list.
|
|
531
|
+
*
|
|
532
|
+
* Injected via the `collection.insights` slot.
|
|
533
|
+
*/
|
|
534
|
+
function CollectionInsightsInline({ insights, path, parentCollectionSlugs, parentEntityIds }) {
|
|
535
|
+
if (!insights || insights.length === 0) return null;
|
|
536
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
537
|
+
className: "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 pb-4",
|
|
538
|
+
children: insights.map((def) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InsightWidget, {
|
|
539
|
+
definition: def,
|
|
540
|
+
path,
|
|
541
|
+
parentCollectionSlugs,
|
|
542
|
+
parentEntityIds
|
|
543
|
+
}, def.id))
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
CollectionInsightsInline.displayName = "CollectionInsightsInline";
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/useInsightsPlugin.tsx
|
|
549
|
+
/**
|
|
550
|
+
* Creates the Insights plugin for Rebase.
|
|
551
|
+
*
|
|
552
|
+
* This plugin injects scorecard widgets into key UI locations:
|
|
553
|
+
* - **Home page header**: KPI overview via `home.children.start` slot
|
|
554
|
+
* - **Collection list view**: Scorecards inline (below title, above list) via `collection.insights` slot
|
|
555
|
+
* - **Home page cards**: Compact scorecard metrics auto-extracted from collection insights via `home.card.insight` slot
|
|
556
|
+
*
|
|
557
|
+
* Collection-level insights (`collections.<slug>`) are the single source of truth:
|
|
558
|
+
* scorecards render in the collection list view and are automatically extracted
|
|
559
|
+
* to show as compact widgets on the corresponding home page card.
|
|
560
|
+
*
|
|
561
|
+
* Each insight owns its own `data()` callback — use the Rebase client SDK,
|
|
562
|
+
* call a custom function, or hit any external API. Full flexibility, zero new endpoints.
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* ```typescript
|
|
566
|
+
* import { useInsightsPlugin } from "@rebasepro/plugin-insights";
|
|
567
|
+
*
|
|
568
|
+
* const insightsPlugin = useInsightsPlugin({
|
|
569
|
+
* cacheTTL: 120_000,
|
|
570
|
+
* insights: {
|
|
571
|
+
* home: [
|
|
572
|
+
* { id: "revenue", title: "Revenue", data: async () => ..., scorecard: { ... } },
|
|
573
|
+
* ],
|
|
574
|
+
* collections: {
|
|
575
|
+
* orders: [
|
|
576
|
+
* { id: "total", title: "Total Orders", data: async () => ..., scorecard: { ... } },
|
|
577
|
+
* ],
|
|
578
|
+
* },
|
|
579
|
+
* },
|
|
580
|
+
* });
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
function useInsightsPlugin(config) {
|
|
584
|
+
const { insights, cacheTTL } = config;
|
|
585
|
+
return react.default.useMemo(() => {
|
|
586
|
+
const slots = [];
|
|
587
|
+
if (insights.home && insights.home.length > 0) {
|
|
588
|
+
const homeInsights = insights.home;
|
|
589
|
+
slots.push({
|
|
590
|
+
slot: "home.children.start",
|
|
591
|
+
Component: (props) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HomeInsightsSlot, {
|
|
592
|
+
...props,
|
|
593
|
+
insights: homeInsights
|
|
594
|
+
}),
|
|
595
|
+
order: 10
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
if (insights.collections) for (const [slug, defs] of Object.entries(insights.collections)) {
|
|
599
|
+
if (defs.length === 0) continue;
|
|
600
|
+
const collectionInsights = defs;
|
|
601
|
+
slots.push({
|
|
602
|
+
slot: "collection.insights",
|
|
603
|
+
Component: (props) => {
|
|
604
|
+
if ((props.path?.split("/").filter(Boolean).pop() ?? "") !== slug) return null;
|
|
605
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollectionInsightsInline, {
|
|
606
|
+
...props,
|
|
607
|
+
insights: collectionInsights
|
|
608
|
+
});
|
|
609
|
+
},
|
|
610
|
+
order: 10
|
|
611
|
+
});
|
|
612
|
+
slots.push({
|
|
613
|
+
slot: "home.card.insight",
|
|
614
|
+
Component: (props) => {
|
|
615
|
+
if (props.slug !== slug) return null;
|
|
616
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HomeCardInsightSlot, {
|
|
617
|
+
...props,
|
|
618
|
+
insights: collectionInsights
|
|
619
|
+
});
|
|
620
|
+
},
|
|
621
|
+
order: 10
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
key: "plugin-insights",
|
|
626
|
+
slots,
|
|
627
|
+
providers: [{
|
|
628
|
+
scope: "root",
|
|
629
|
+
Component: InsightsProvider,
|
|
630
|
+
props: { cacheTTL }
|
|
631
|
+
}]
|
|
632
|
+
};
|
|
633
|
+
}, [insights, cacheTTL]);
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
exports.InsightWidget = InsightWidget;
|
|
637
|
+
exports.InsightWidgetSkeleton = InsightWidgetSkeleton;
|
|
638
|
+
exports.InsightsCache = InsightsCache;
|
|
639
|
+
exports.InsightsProvider = InsightsProvider;
|
|
640
|
+
exports.InsightsScorecardView = InsightsScorecardView;
|
|
641
|
+
exports.useInsightsData = useInsightsData;
|
|
642
|
+
exports.useInsightsEngine = useInsightsEngine;
|
|
643
|
+
exports.useInsightsPlugin = useInsightsPlugin;
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
//# sourceMappingURL=index.umd.js.map
|