@rebasepro/plugin-insights 0.0.1-canary.4f204c2
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/LICENSE +6 -0
- package/dist/common/src/collections/CollectionRegistry.d.ts +56 -0
- package/dist/common/src/collections/index.d.ts +1 -0
- package/dist/common/src/data/buildRebaseData.d.ts +14 -0
- package/dist/common/src/index.d.ts +3 -0
- package/dist/common/src/util/builders.d.ts +57 -0
- package/dist/common/src/util/callbacks.d.ts +6 -0
- package/dist/common/src/util/collections.d.ts +11 -0
- package/dist/common/src/util/common.d.ts +2 -0
- package/dist/common/src/util/conditions.d.ts +26 -0
- package/dist/common/src/util/entities.d.ts +58 -0
- package/dist/common/src/util/enums.d.ts +3 -0
- package/dist/common/src/util/index.d.ts +16 -0
- package/dist/common/src/util/navigation_from_path.d.ts +34 -0
- package/dist/common/src/util/navigation_utils.d.ts +20 -0
- package/dist/common/src/util/parent_references_from_path.d.ts +6 -0
- package/dist/common/src/util/paths.d.ts +14 -0
- package/dist/common/src/util/permissions.d.ts +5 -0
- package/dist/common/src/util/references.d.ts +2 -0
- package/dist/common/src/util/relations.d.ts +22 -0
- package/dist/common/src/util/resolutions.d.ts +72 -0
- package/dist/common/src/util/storage.d.ts +24 -0
- package/dist/core/src/components/AIIcon.d.ts +16 -0
- package/dist/core/src/components/ConfirmationDialog.d.ts +9 -0
- package/dist/core/src/components/Debug/UIReferenceView.d.ts +1 -0
- package/dist/core/src/components/Debug/UIStyleGuide.d.ts +1 -0
- package/dist/core/src/components/ErrorTooltip.d.ts +2 -0
- package/dist/core/src/components/ErrorView.d.ts +21 -0
- package/dist/core/src/components/LanguageToggle.d.ts +1 -0
- package/dist/core/src/components/LoginView/LoginView.d.ts +68 -0
- package/dist/core/src/components/LoginView/index.d.ts +2 -0
- package/dist/core/src/components/NotFoundPage.d.ts +1 -0
- package/dist/core/src/components/RebaseAuth.d.ts +10 -0
- package/dist/core/src/components/RebaseLogo.d.ts +7 -0
- package/dist/core/src/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/core/src/components/UserDisplay.d.ts +7 -0
- package/dist/core/src/components/UserSelectPopover.d.ts +62 -0
- package/dist/core/src/components/UserSettingsView.d.ts +1 -0
- package/dist/core/src/components/common/index.d.ts +6 -0
- package/dist/core/src/components/common/table_height.d.ts +5 -0
- package/dist/core/src/components/common/types.d.ts +63 -0
- package/dist/core/src/components/common/useColumnsIds.d.ts +9 -0
- package/dist/core/src/components/common/useDataTableController.d.ts +45 -0
- package/dist/core/src/components/common/useDebouncedData.d.ts +9 -0
- package/dist/core/src/components/common/useScrollRestoration.d.ts +14 -0
- package/dist/core/src/components/index.d.ts +16 -0
- package/dist/core/src/contexts/AdminModeController.d.ts +4 -0
- package/dist/core/src/contexts/AnalyticsContext.d.ts +3 -0
- package/dist/core/src/contexts/AuthControllerContext.d.ts +3 -0
- package/dist/core/src/contexts/CustomizationControllerContext.d.ts +3 -0
- package/dist/core/src/contexts/DataDriverContext.d.ts +3 -0
- package/dist/core/src/contexts/DatabaseAdminContext.d.ts +3 -0
- package/dist/core/src/contexts/DialogsProvider.d.ts +4 -0
- package/dist/core/src/contexts/EffectiveRoleController.d.ts +4 -0
- package/dist/core/src/contexts/InternalUserManagementContext.d.ts +3 -0
- package/dist/core/src/contexts/ModeController.d.ts +4 -0
- package/dist/core/src/contexts/RebaseClientInstanceContext.d.ts +6 -0
- package/dist/core/src/contexts/RebaseDataContext.d.ts +3 -0
- package/dist/core/src/contexts/SnackbarProvider.d.ts +2 -0
- package/dist/core/src/contexts/StorageSourceContext.d.ts +3 -0
- package/dist/core/src/contexts/UserConfigurationPersistenceContext.d.ts +3 -0
- package/dist/core/src/contexts/index.d.ts +13 -0
- package/dist/core/src/core/PluginLifecycleManager.d.ts +17 -0
- package/dist/core/src/core/PluginProviderStack.d.ts +21 -0
- package/dist/core/src/core/Rebase.d.ts +14 -0
- package/dist/core/src/core/RebaseProps.d.ts +136 -0
- package/dist/core/src/core/RebaseRouter.d.ts +4 -0
- package/dist/core/src/core/RebaseRoutes.d.ts +17 -0
- package/dist/core/src/core/index.d.ts +4 -0
- package/dist/core/src/hooks/ApiConfigContext.d.ts +24 -0
- package/dist/core/src/hooks/data/delete.d.ts +31 -0
- package/dist/core/src/hooks/data/save.d.ts +34 -0
- package/dist/core/src/hooks/data/useCollectionFetch.d.ts +51 -0
- package/dist/core/src/hooks/data/useData.d.ts +13 -0
- package/dist/core/src/hooks/data/useDataOrder.d.ts +12 -0
- package/dist/core/src/hooks/data/useEntityFetch.d.ts +38 -0
- package/dist/core/src/hooks/data/useRelationSelector.d.ts +52 -0
- package/dist/core/src/hooks/data/useUserSelector.d.ts +31 -0
- package/dist/core/src/hooks/index.d.ts +37 -0
- package/dist/core/src/hooks/useAdminModeController.d.ts +19 -0
- package/dist/core/src/hooks/useAnalyticsController.d.ts +5 -0
- package/dist/core/src/hooks/useAuthController.d.ts +11 -0
- package/dist/core/src/hooks/useAuthSubscription.d.ts +2 -0
- package/dist/core/src/hooks/useBackendStorageSource.d.ts +30 -0
- package/dist/core/src/hooks/useBridgeRegistration.d.ts +18 -0
- package/dist/core/src/hooks/useBrowserTitleAndIcon.d.ts +6 -0
- package/dist/core/src/hooks/useBuildAdminModeController.d.ts +6 -0
- package/dist/core/src/hooks/useBuildEffectiveRoleController.d.ts +8 -0
- package/dist/core/src/hooks/useBuildLocalConfigurationPersistence.d.ts +2 -0
- package/dist/core/src/hooks/useBuildModeController.d.ts +6 -0
- package/dist/core/src/hooks/useClipboard.d.ts +57 -0
- package/dist/core/src/hooks/useCollapsedGroups.d.ts +12 -0
- package/dist/core/src/hooks/useCustomizationController.d.ts +11 -0
- package/dist/core/src/hooks/useDialogsController.d.ts +11 -0
- package/dist/core/src/hooks/useEffectiveRoleController.d.ts +7 -0
- package/dist/core/src/hooks/useInternalUserManagementController.d.ts +12 -0
- package/dist/core/src/hooks/useLargeLayout.d.ts +1 -0
- package/dist/core/src/hooks/useModeController.d.ts +19 -0
- package/dist/core/src/hooks/usePermissions.d.ts +12 -0
- package/dist/core/src/hooks/useRebaseClient.d.ts +5 -0
- package/dist/core/src/hooks/useRebaseContext.d.ts +11 -0
- package/dist/core/src/hooks/useRebaseRegistry.d.ts +34 -0
- package/dist/core/src/hooks/useSlot.d.ts +18 -0
- package/dist/core/src/hooks/useSnackbarController.d.ts +20 -0
- package/dist/core/src/hooks/useStorageSource.d.ts +7 -0
- package/dist/core/src/hooks/useStudioBridge.d.ts +91 -0
- package/dist/core/src/hooks/useTranslation.d.ts +17 -0
- package/dist/core/src/hooks/useUnsavedChangesDialog.d.ts +12 -0
- package/dist/core/src/hooks/useUserConfigurationPersistence.d.ts +8 -0
- package/dist/core/src/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/core/src/i18n/RebaseI18nProvider.d.ts +33 -0
- package/dist/core/src/index.d.ts +15 -0
- package/dist/core/src/internal/common.d.ts +3 -0
- package/dist/core/src/internal/useRestoreScroll.d.ts +6 -0
- package/dist/core/src/locales/de.d.ts +2 -0
- package/dist/core/src/locales/en.d.ts +10 -0
- package/dist/core/src/locales/es.d.ts +10 -0
- package/dist/core/src/locales/fr.d.ts +2 -0
- package/dist/core/src/locales/hi.d.ts +2 -0
- package/dist/core/src/locales/it.d.ts +2 -0
- package/dist/core/src/locales/pt.d.ts +7 -0
- package/dist/core/src/util/constants.d.ts +1 -0
- package/dist/core/src/util/createFormexStub.d.ts +2 -0
- package/dist/core/src/util/entity_cache.d.ts +27 -0
- package/dist/core/src/util/enums.d.ts +5 -0
- package/dist/core/src/util/icon_list.d.ts +5 -0
- package/dist/core/src/util/icon_synonyms.d.ts +1 -0
- package/dist/core/src/util/icons.d.ts +20 -0
- package/dist/core/src/util/index.d.ts +10 -0
- package/dist/core/src/util/previews.d.ts +4 -0
- package/dist/core/src/util/useStorageUploadController.d.ts +38 -0
- package/dist/core/src/util/useTraceUpdate.d.ts +2 -0
- package/dist/formex/src/Field.d.ts +52 -0
- package/dist/formex/src/Formex.d.ts +7 -0
- package/dist/formex/src/index.d.ts +5 -0
- package/dist/formex/src/types.d.ts +40 -0
- package/dist/formex/src/useCreateFormex.d.ts +14 -0
- package/dist/formex/src/utils.d.ts +16 -0
- package/dist/index.es.js +945 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +944 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/plugin-insights/src/components/CollectionInsightsInline.d.ts +16 -0
- package/dist/plugin-insights/src/components/HomeCardInsightSlot.d.ts +16 -0
- package/dist/plugin-insights/src/components/HomeInsightsSlot.d.ts +13 -0
- package/dist/plugin-insights/src/components/InsightWidget.d.ts +19 -0
- package/dist/plugin-insights/src/components/InsightWidgetSkeleton.d.ts +20 -0
- package/dist/plugin-insights/src/components/InsightsScorecardView.d.ts +19 -0
- package/dist/plugin-insights/src/engine/InsightsCache.d.ts +18 -0
- package/dist/plugin-insights/src/engine/InsightsProvider.d.ts +22 -0
- package/dist/plugin-insights/src/engine/useInsightsData.d.ts +17 -0
- package/dist/plugin-insights/src/index.d.ts +8 -0
- package/dist/plugin-insights/src/types/engine.d.ts +79 -0
- package/dist/plugin-insights/src/types/index.d.ts +2 -0
- package/dist/plugin-insights/src/types/widgets.d.ts +59 -0
- package/dist/plugin-insights/src/useInsightsPlugin.d.ts +37 -0
- package/dist/types/src/controllers/analytics_controller.d.ts +7 -0
- package/dist/types/src/controllers/auth.d.ts +119 -0
- package/dist/types/src/controllers/client.d.ts +170 -0
- package/dist/types/src/controllers/collection_registry.d.ts +45 -0
- package/dist/types/src/controllers/customization_controller.d.ts +60 -0
- package/dist/types/src/controllers/data.d.ts +168 -0
- package/dist/types/src/controllers/data_driver.d.ts +160 -0
- package/dist/types/src/controllers/database_admin.d.ts +11 -0
- package/dist/types/src/controllers/dialogs_controller.d.ts +36 -0
- package/dist/types/src/controllers/effective_role.d.ts +4 -0
- package/dist/types/src/controllers/email.d.ts +34 -0
- package/dist/types/src/controllers/index.d.ts +18 -0
- package/dist/types/src/controllers/local_config_persistence.d.ts +20 -0
- package/dist/types/src/controllers/navigation.d.ts +213 -0
- package/dist/types/src/controllers/registry.d.ts +54 -0
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +67 -0
- package/dist/types/src/controllers/side_entity_controller.d.ts +90 -0
- package/dist/types/src/controllers/snackbar.d.ts +24 -0
- package/dist/types/src/controllers/storage.d.ts +171 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/rebase_context.d.ts +105 -0
- package/dist/types/src/types/backend.d.ts +536 -0
- package/dist/types/src/types/builders.d.ts +15 -0
- package/dist/types/src/types/chips.d.ts +5 -0
- package/dist/types/src/types/collections.d.ts +856 -0
- package/dist/types/src/types/cron.d.ts +102 -0
- package/dist/types/src/types/data_source.d.ts +64 -0
- package/dist/types/src/types/entities.d.ts +145 -0
- package/dist/types/src/types/entity_actions.d.ts +98 -0
- package/dist/types/src/types/entity_callbacks.d.ts +173 -0
- package/dist/types/src/types/entity_link_builder.d.ts +7 -0
- package/dist/types/src/types/entity_overrides.d.ts +10 -0
- package/dist/types/src/types/entity_views.d.ts +61 -0
- package/dist/types/src/types/export_import.d.ts +21 -0
- package/dist/types/src/types/index.d.ts +23 -0
- package/dist/types/src/types/locales.d.ts +4 -0
- package/dist/types/src/types/modify_collections.d.ts +5 -0
- package/dist/types/src/types/plugins.d.ts +279 -0
- package/dist/types/src/types/properties.d.ts +1176 -0
- package/dist/types/src/types/property_config.d.ts +70 -0
- package/dist/types/src/types/relations.d.ts +336 -0
- package/dist/types/src/types/slots.d.ts +252 -0
- package/dist/types/src/types/translations.d.ts +870 -0
- package/dist/types/src/types/user_management_delegate.d.ts +121 -0
- package/dist/types/src/types/websockets.d.ts +78 -0
- package/dist/types/src/users/index.d.ts +2 -0
- package/dist/types/src/users/roles.d.ts +22 -0
- package/dist/types/src/users/user.d.ts +46 -0
- package/dist/ui/src/components/Alert.d.ts +12 -0
- package/dist/ui/src/components/Autocomplete.d.ts +21 -0
- package/dist/ui/src/components/Avatar.d.ts +11 -0
- package/dist/ui/src/components/Badge.d.ts +8 -0
- package/dist/ui/src/components/BooleanSwitch.d.ts +14 -0
- package/dist/ui/src/components/BooleanSwitchWithLabel.d.ts +17 -0
- package/dist/ui/src/components/Button.d.ts +14 -0
- package/dist/ui/src/components/Card.d.ts +9 -0
- package/dist/ui/src/components/CenteredView.d.ts +9 -0
- package/dist/ui/src/components/Checkbox.d.ts +13 -0
- package/dist/ui/src/components/Chip.d.ts +26 -0
- package/dist/ui/src/components/CircularProgress.d.ts +5 -0
- package/dist/ui/src/components/CircularProgressCenter.d.ts +11 -0
- package/dist/ui/src/components/Collapse.d.ts +9 -0
- package/dist/ui/src/components/ColorPicker.d.ts +30 -0
- package/dist/ui/src/components/Container.d.ts +8 -0
- package/dist/ui/src/components/DateTimeField.d.ts +24 -0
- package/dist/ui/src/components/DebouncedTextField.d.ts +2 -0
- package/dist/ui/src/components/Dialog.d.ts +39 -0
- package/dist/ui/src/components/DialogActions.d.ts +7 -0
- package/dist/ui/src/components/DialogContent.d.ts +7 -0
- package/dist/ui/src/components/DialogTitle.d.ts +10 -0
- package/dist/ui/src/components/ErrorBoundary.d.ts +11 -0
- package/dist/ui/src/components/ExpandablePanel.d.ts +12 -0
- package/dist/ui/src/components/FileUpload.d.ts +23 -0
- package/dist/ui/src/components/IconButton.d.ts +12 -0
- package/dist/ui/src/components/InfoLabel.d.ts +5 -0
- package/dist/ui/src/components/InputLabel.d.ts +11 -0
- package/dist/ui/src/components/Label.d.ts +7 -0
- package/dist/ui/src/components/LoadingButton.d.ts +7 -0
- package/dist/ui/src/components/Markdown.d.ts +10 -0
- package/dist/ui/src/components/Menu.d.ts +23 -0
- package/dist/ui/src/components/Menubar.d.ts +80 -0
- package/dist/ui/src/components/MultiSelect.d.ts +48 -0
- package/dist/ui/src/components/Paper.d.ts +6 -0
- package/dist/ui/src/components/Popover.d.ts +24 -0
- package/dist/ui/src/components/RadioGroup.d.ts +28 -0
- package/dist/ui/src/components/ResizablePanels.d.ts +18 -0
- package/dist/ui/src/components/SearchBar.d.ts +22 -0
- package/dist/ui/src/components/Select.d.ts +43 -0
- package/dist/ui/src/components/Separator.d.ts +5 -0
- package/dist/ui/src/components/Sheet.d.ts +22 -0
- package/dist/ui/src/components/Skeleton.d.ts +6 -0
- package/dist/ui/src/components/Slider.d.ts +21 -0
- package/dist/ui/src/components/Table.d.ts +34 -0
- package/dist/ui/src/components/Tabs.d.ts +19 -0
- package/dist/ui/src/components/TextField.d.ts +58 -0
- package/dist/ui/src/components/TextareaAutosize.d.ts +43 -0
- package/dist/ui/src/components/ToggleButtonGroup.d.ts +30 -0
- package/dist/ui/src/components/Tooltip.d.ts +19 -0
- package/dist/ui/src/components/Typography.d.ts +36 -0
- package/dist/ui/src/components/VirtualTable/VirtualTable.d.ts +11 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableCell.d.ts +21 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableHeader.d.ts +29 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableHeaderRow.d.ts +2 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableProps.d.ts +243 -0
- package/dist/ui/src/components/VirtualTable/VirtualTableRow.d.ts +3 -0
- package/dist/ui/src/components/VirtualTable/index.d.ts +3 -0
- package/dist/ui/src/components/VirtualTable/types.d.ts +38 -0
- package/dist/ui/src/components/common/SelectInputLabel.d.ts +5 -0
- package/dist/ui/src/components/index.d.ts +53 -0
- package/dist/ui/src/hooks/PortalContainerContext.d.ts +31 -0
- package/dist/ui/src/hooks/index.d.ts +6 -0
- package/dist/ui/src/hooks/useDebounceCallback.d.ts +1 -0
- package/dist/ui/src/hooks/useDebounceValue.d.ts +1 -0
- package/dist/ui/src/hooks/useDebouncedCallback.d.ts +1 -0
- package/dist/ui/src/hooks/useInjectStyles.d.ts +7 -0
- package/dist/ui/src/hooks/useOutsideAlerter.d.ts +5 -0
- package/dist/ui/src/icons/GitHubIcon.d.ts +2 -0
- package/dist/ui/src/icons/HandleIcon.d.ts +1 -0
- package/dist/ui/src/icons/Icon.d.ts +20 -0
- package/dist/ui/src/icons/cool_icon_keys.d.ts +1 -0
- package/dist/ui/src/icons/icon_keys.d.ts +1 -0
- package/dist/ui/src/icons/index.d.ts +6 -0
- package/dist/ui/src/index.d.ts +5 -0
- package/dist/ui/src/styles.d.ts +12 -0
- package/dist/ui/src/util/chip_colors.d.ts +4 -0
- package/dist/ui/src/util/cls.d.ts +2 -0
- package/dist/ui/src/util/debounce.d.ts +10 -0
- package/dist/ui/src/util/hash.d.ts +1 -0
- package/dist/ui/src/util/index.d.ts +4 -0
- package/dist/ui/src/util/key_to_icon_component.d.ts +1 -0
- package/package.json +80 -0
- package/src/components/CollectionInsightsInline.tsx +30 -0
- package/src/components/HomeCardInsightSlot.tsx +36 -0
- package/src/components/HomeInsightsSlot.tsx +30 -0
- package/src/components/InsightWidget.tsx +65 -0
- package/src/components/InsightWidgetSkeleton.tsx +122 -0
- package/src/components/InsightsScorecardView.tsx +160 -0
- package/src/engine/InsightsCache.ts +52 -0
- package/src/engine/InsightsProvider.tsx +38 -0
- package/src/engine/useInsightsData.ts +100 -0
- package/src/index.ts +22 -0
- package/src/types/engine.ts +85 -0
- package/src/types/index.ts +5 -0
- package/src/types/widgets.ts +66 -0
- package/src/useInsightsPlugin.tsx +117 -0
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("react-compiler-runtime"), require("react"), require("@rebasepro/core"), require("@rebasepro/ui")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "react-compiler-runtime", "react", "@rebasepro/core", "@rebasepro/ui"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.Rebase = {}, global.jsxRuntime, global.reactCompilerRuntime, global.React, global.core, global.ui));
|
|
3
|
+
})(this, (function(exports2, jsxRuntime, reactCompilerRuntime, React, core, ui) {
|
|
4
|
+
"use strict";
|
|
5
|
+
class InsightsCache {
|
|
6
|
+
constructor(ttl = 6e4) {
|
|
7
|
+
this.ttl = ttl;
|
|
8
|
+
}
|
|
9
|
+
cache = /* @__PURE__ */ new Map();
|
|
10
|
+
inflight = /* @__PURE__ */ new Map();
|
|
11
|
+
get(key) {
|
|
12
|
+
const entry = this.cache.get(key);
|
|
13
|
+
if (!entry) return null;
|
|
14
|
+
if (Date.now() - entry.timestamp > this.ttl) {
|
|
15
|
+
this.cache.delete(key);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return entry.data;
|
|
19
|
+
}
|
|
20
|
+
set(key, data) {
|
|
21
|
+
this.cache.set(key, {
|
|
22
|
+
data,
|
|
23
|
+
timestamp: Date.now()
|
|
24
|
+
});
|
|
25
|
+
this.inflight.delete(key);
|
|
26
|
+
}
|
|
27
|
+
getInflight(key) {
|
|
28
|
+
return this.inflight.get(key) ?? null;
|
|
29
|
+
}
|
|
30
|
+
setInflight(key, promise) {
|
|
31
|
+
this.inflight.set(key, promise);
|
|
32
|
+
}
|
|
33
|
+
invalidate(key) {
|
|
34
|
+
if (key) {
|
|
35
|
+
this.cache.delete(key);
|
|
36
|
+
this.inflight.delete(key);
|
|
37
|
+
} else {
|
|
38
|
+
this.cache.clear();
|
|
39
|
+
this.inflight.clear();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const InsightsContext = React.createContext(null);
|
|
44
|
+
function InsightsProvider(t0) {
|
|
45
|
+
const $ = reactCompilerRuntime.c(7);
|
|
46
|
+
const {
|
|
47
|
+
cacheTTL,
|
|
48
|
+
children
|
|
49
|
+
} = t0;
|
|
50
|
+
let t1;
|
|
51
|
+
let t2;
|
|
52
|
+
if ($[0] !== cacheTTL) {
|
|
53
|
+
t2 = new InsightsCache(cacheTTL);
|
|
54
|
+
$[0] = cacheTTL;
|
|
55
|
+
$[1] = t2;
|
|
56
|
+
} else {
|
|
57
|
+
t2 = $[1];
|
|
58
|
+
}
|
|
59
|
+
t1 = t2;
|
|
60
|
+
const cache = t1;
|
|
61
|
+
let t3;
|
|
62
|
+
let t4;
|
|
63
|
+
if ($[2] !== cache) {
|
|
64
|
+
t4 = {
|
|
65
|
+
cache
|
|
66
|
+
};
|
|
67
|
+
$[2] = cache;
|
|
68
|
+
$[3] = t4;
|
|
69
|
+
} else {
|
|
70
|
+
t4 = $[3];
|
|
71
|
+
}
|
|
72
|
+
t3 = t4;
|
|
73
|
+
const value = t3;
|
|
74
|
+
let t5;
|
|
75
|
+
if ($[4] !== children || $[5] !== value) {
|
|
76
|
+
t5 = /* @__PURE__ */ jsxRuntime.jsx(InsightsContext.Provider, { value, children });
|
|
77
|
+
$[4] = children;
|
|
78
|
+
$[5] = value;
|
|
79
|
+
$[6] = t5;
|
|
80
|
+
} else {
|
|
81
|
+
t5 = $[6];
|
|
82
|
+
}
|
|
83
|
+
return t5;
|
|
84
|
+
}
|
|
85
|
+
function useInsightsEngine() {
|
|
86
|
+
return React.useContext(InsightsContext);
|
|
87
|
+
}
|
|
88
|
+
function useInsightsData(definition, collectionSlug) {
|
|
89
|
+
const $ = reactCompilerRuntime.c(16);
|
|
90
|
+
const engine = useInsightsEngine();
|
|
91
|
+
const cache = engine?.cache ?? null;
|
|
92
|
+
const {
|
|
93
|
+
initialLoading,
|
|
94
|
+
authLoading,
|
|
95
|
+
user,
|
|
96
|
+
loginSkipped
|
|
97
|
+
} = core.useAuthController();
|
|
98
|
+
const authReady = !initialLoading && !authLoading && (Boolean(user) || loginSkipped);
|
|
99
|
+
const [data, setData] = React.useState(null);
|
|
100
|
+
const [loading, setLoading] = React.useState(true);
|
|
101
|
+
const [error, setError] = React.useState(null);
|
|
102
|
+
const cacheKey = `${definition.id}:${collectionSlug ?? "global"}`;
|
|
103
|
+
let t0;
|
|
104
|
+
if ($[0] !== authReady || $[1] !== cache || $[2] !== cacheKey || $[3] !== definition) {
|
|
105
|
+
t0 = () => {
|
|
106
|
+
if (!authReady || !cache) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
let cancelled;
|
|
110
|
+
cancelled = false;
|
|
111
|
+
const cached = cache.get(cacheKey);
|
|
112
|
+
if (cached) {
|
|
113
|
+
setData(cached);
|
|
114
|
+
setLoading(false);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const inflight = cache.getInflight(cacheKey);
|
|
118
|
+
if (inflight) {
|
|
119
|
+
setLoading(true);
|
|
120
|
+
inflight.then((result) => {
|
|
121
|
+
if (!cancelled) {
|
|
122
|
+
setData(result);
|
|
123
|
+
}
|
|
124
|
+
}).catch((err) => {
|
|
125
|
+
if (!cancelled) {
|
|
126
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
127
|
+
}
|
|
128
|
+
}).finally(() => {
|
|
129
|
+
if (!cancelled) {
|
|
130
|
+
setLoading(false);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
setLoading(true);
|
|
136
|
+
setError(null);
|
|
137
|
+
const promise = definition.data();
|
|
138
|
+
cache.setInflight(cacheKey, promise);
|
|
139
|
+
promise.then((result_0) => {
|
|
140
|
+
cache.set(cacheKey, result_0);
|
|
141
|
+
if (!cancelled) {
|
|
142
|
+
setData(result_0);
|
|
143
|
+
}
|
|
144
|
+
}).catch((err_0) => {
|
|
145
|
+
if (!cancelled) {
|
|
146
|
+
setError(err_0 instanceof Error ? err_0 : new Error(String(err_0)));
|
|
147
|
+
}
|
|
148
|
+
}).finally(() => {
|
|
149
|
+
if (!cancelled) {
|
|
150
|
+
setLoading(false);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return () => {
|
|
154
|
+
cancelled = true;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
$[0] = authReady;
|
|
158
|
+
$[1] = cache;
|
|
159
|
+
$[2] = cacheKey;
|
|
160
|
+
$[3] = definition;
|
|
161
|
+
$[4] = t0;
|
|
162
|
+
} else {
|
|
163
|
+
t0 = $[4];
|
|
164
|
+
}
|
|
165
|
+
let t1;
|
|
166
|
+
if ($[5] !== authReady || $[6] !== cache || $[7] !== cacheKey || $[8] !== collectionSlug || $[9] !== definition.data || $[10] !== definition.id) {
|
|
167
|
+
t1 = [definition.id, definition.data, collectionSlug, cacheKey, cache, authReady];
|
|
168
|
+
$[5] = authReady;
|
|
169
|
+
$[6] = cache;
|
|
170
|
+
$[7] = cacheKey;
|
|
171
|
+
$[8] = collectionSlug;
|
|
172
|
+
$[9] = definition.data;
|
|
173
|
+
$[10] = definition.id;
|
|
174
|
+
$[11] = t1;
|
|
175
|
+
} else {
|
|
176
|
+
t1 = $[11];
|
|
177
|
+
}
|
|
178
|
+
React.useEffect(t0, t1);
|
|
179
|
+
let t2;
|
|
180
|
+
if ($[12] !== data || $[13] !== error || $[14] !== loading) {
|
|
181
|
+
t2 = {
|
|
182
|
+
data,
|
|
183
|
+
loading,
|
|
184
|
+
error
|
|
185
|
+
};
|
|
186
|
+
$[12] = data;
|
|
187
|
+
$[13] = error;
|
|
188
|
+
$[14] = loading;
|
|
189
|
+
$[15] = t2;
|
|
190
|
+
} else {
|
|
191
|
+
t2 = $[15];
|
|
192
|
+
}
|
|
193
|
+
return t2;
|
|
194
|
+
}
|
|
195
|
+
function formatNumber(value, format) {
|
|
196
|
+
if (value === null || value === void 0) return "N/A";
|
|
197
|
+
const options = {
|
|
198
|
+
style: format?.style ?? "decimal",
|
|
199
|
+
notation: format?.notation ?? "standard",
|
|
200
|
+
maximumFractionDigits: format?.decimals ?? 1,
|
|
201
|
+
minimumFractionDigits: format?.decimals ?? 1
|
|
202
|
+
};
|
|
203
|
+
if (format?.style === "currency") {
|
|
204
|
+
options.currency = format.currency ?? "USD";
|
|
205
|
+
}
|
|
206
|
+
let formatted = new Intl.NumberFormat("en-US", options).format(value);
|
|
207
|
+
if (format?.showSign && value > 0) {
|
|
208
|
+
formatted = "+" + formatted;
|
|
209
|
+
}
|
|
210
|
+
return formatted;
|
|
211
|
+
}
|
|
212
|
+
function InsightsScorecardView(t0) {
|
|
213
|
+
const $ = reactCompilerRuntime.c(58);
|
|
214
|
+
const {
|
|
215
|
+
config,
|
|
216
|
+
data,
|
|
217
|
+
title,
|
|
218
|
+
compact: t1,
|
|
219
|
+
embedded: t2
|
|
220
|
+
} = t0;
|
|
221
|
+
const compact = t1 === void 0 ? false : t1;
|
|
222
|
+
const embedded = t2 === void 0 ? false : t2;
|
|
223
|
+
const containerRef = React.useRef(null);
|
|
224
|
+
const [containerWidth, setContainerWidth] = React.useState(null);
|
|
225
|
+
let t3;
|
|
226
|
+
let t4;
|
|
227
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
228
|
+
t3 = () => {
|
|
229
|
+
if (!containerRef.current) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
setContainerWidth(containerRef.current.offsetWidth);
|
|
233
|
+
const observer = new ResizeObserver((entries) => {
|
|
234
|
+
for (const entry of entries) {
|
|
235
|
+
setContainerWidth(entry.contentRect.width);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
observer.observe(containerRef.current);
|
|
239
|
+
return () => observer.disconnect();
|
|
240
|
+
};
|
|
241
|
+
t4 = [];
|
|
242
|
+
$[0] = t3;
|
|
243
|
+
$[1] = t4;
|
|
244
|
+
} else {
|
|
245
|
+
t3 = $[0];
|
|
246
|
+
t4 = $[1];
|
|
247
|
+
}
|
|
248
|
+
React.useLayoutEffect(t3, t4);
|
|
249
|
+
const mainValue = data[config.value.field];
|
|
250
|
+
let t5;
|
|
251
|
+
if ($[2] !== config.value.format || $[3] !== mainValue) {
|
|
252
|
+
t5 = typeof mainValue === "number" ? formatNumber(mainValue, config.value.format) : String(mainValue ?? "N/A");
|
|
253
|
+
$[2] = config.value.format;
|
|
254
|
+
$[3] = mainValue;
|
|
255
|
+
$[4] = t5;
|
|
256
|
+
} else {
|
|
257
|
+
t5 = $[4];
|
|
258
|
+
}
|
|
259
|
+
const formattedValue = t5;
|
|
260
|
+
let comparisonElement = null;
|
|
261
|
+
if (config.comparison) {
|
|
262
|
+
const comparisonValue = data[config.comparison.field];
|
|
263
|
+
if (typeof comparisonValue === "number") {
|
|
264
|
+
let t62;
|
|
265
|
+
if ($[5] !== comparisonValue || $[6] !== config.comparison.format) {
|
|
266
|
+
t62 = formatNumber(comparisonValue, config.comparison.format);
|
|
267
|
+
$[5] = comparisonValue;
|
|
268
|
+
$[6] = config.comparison.format;
|
|
269
|
+
$[7] = t62;
|
|
270
|
+
} else {
|
|
271
|
+
t62 = $[7];
|
|
272
|
+
}
|
|
273
|
+
const formattedComparison = t62;
|
|
274
|
+
const isPositive = comparisonValue > 0;
|
|
275
|
+
const isNegative = comparisonValue < 0;
|
|
276
|
+
let colorClass = "text-surface-500 dark:text-surface-400";
|
|
277
|
+
if (config.comparison.intent === "increase_is_good") {
|
|
278
|
+
if (isPositive) {
|
|
279
|
+
colorClass = "text-emerald-500";
|
|
280
|
+
}
|
|
281
|
+
if (isNegative) {
|
|
282
|
+
colorClass = "text-red-500";
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
if (config.comparison.intent === "decrease_is_good") {
|
|
286
|
+
if (isPositive) {
|
|
287
|
+
colorClass = "text-red-500";
|
|
288
|
+
}
|
|
289
|
+
if (isNegative) {
|
|
290
|
+
colorClass = "text-emerald-500";
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const t72 = `font-medium ${compact ? "text-[10px]" : "text-xs"} ${colorClass}`;
|
|
295
|
+
let t82;
|
|
296
|
+
if ($[8] !== formattedComparison || $[9] !== t72) {
|
|
297
|
+
t82 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t72, children: formattedComparison });
|
|
298
|
+
$[8] = formattedComparison;
|
|
299
|
+
$[9] = t72;
|
|
300
|
+
$[10] = t82;
|
|
301
|
+
} else {
|
|
302
|
+
t82 = $[10];
|
|
303
|
+
}
|
|
304
|
+
comparisonElement = t82;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const isSmall = compact || containerWidth !== null && containerWidth < 200;
|
|
308
|
+
let t6;
|
|
309
|
+
if ($[11] !== config.icon || $[12] !== isSmall) {
|
|
310
|
+
t6 = config.icon ? core.getIcon(config.icon, "text-surface-400 dark:text-surface-500", void 0, isSmall ? 14 : 18) : null;
|
|
311
|
+
$[11] = config.icon;
|
|
312
|
+
$[12] = isSmall;
|
|
313
|
+
$[13] = t6;
|
|
314
|
+
} else {
|
|
315
|
+
t6 = $[13];
|
|
316
|
+
}
|
|
317
|
+
const iconElement = t6;
|
|
318
|
+
if (compact) {
|
|
319
|
+
let t72;
|
|
320
|
+
if ($[14] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
321
|
+
t72 = ui.cls("flex flex-col gap-0.5 px-2.5 py-2 rounded-md bg-transparent border min-w-0", ui.defaultBorderMixin);
|
|
322
|
+
$[14] = t72;
|
|
323
|
+
} else {
|
|
324
|
+
t72 = $[14];
|
|
325
|
+
}
|
|
326
|
+
let t82;
|
|
327
|
+
if ($[15] !== title) {
|
|
328
|
+
t82 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] uppercase tracking-wider text-surface-400 dark:text-surface-500 truncate", children: title });
|
|
329
|
+
$[15] = title;
|
|
330
|
+
$[16] = t82;
|
|
331
|
+
} else {
|
|
332
|
+
t82 = $[16];
|
|
333
|
+
}
|
|
334
|
+
let t92;
|
|
335
|
+
if ($[17] !== formattedValue) {
|
|
336
|
+
t92 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold tabular-nums text-surface-800 dark:text-surface-100", children: formattedValue });
|
|
337
|
+
$[17] = formattedValue;
|
|
338
|
+
$[18] = t92;
|
|
339
|
+
} else {
|
|
340
|
+
t92 = $[18];
|
|
341
|
+
}
|
|
342
|
+
let t102;
|
|
343
|
+
if ($[19] !== comparisonElement || $[20] !== t92) {
|
|
344
|
+
t102 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline gap-1.5", children: [
|
|
345
|
+
t92,
|
|
346
|
+
comparisonElement
|
|
347
|
+
] });
|
|
348
|
+
$[19] = comparisonElement;
|
|
349
|
+
$[20] = t92;
|
|
350
|
+
$[21] = t102;
|
|
351
|
+
} else {
|
|
352
|
+
t102 = $[21];
|
|
353
|
+
}
|
|
354
|
+
let t112;
|
|
355
|
+
if ($[22] !== t102 || $[23] !== t82) {
|
|
356
|
+
t112 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t72, children: [
|
|
357
|
+
t82,
|
|
358
|
+
t102
|
|
359
|
+
] });
|
|
360
|
+
$[22] = t102;
|
|
361
|
+
$[23] = t82;
|
|
362
|
+
$[24] = t112;
|
|
363
|
+
} else {
|
|
364
|
+
t112 = $[24];
|
|
365
|
+
}
|
|
366
|
+
return t112;
|
|
367
|
+
}
|
|
368
|
+
let t7;
|
|
369
|
+
if ($[25] !== embedded || $[26] !== isSmall) {
|
|
370
|
+
t7 = embedded ? `flex flex-col min-w-0 h-full ${isSmall ? "px-3.5 py-3" : "px-5 py-4"}` : ui.cls("rounded-lg flex flex-col min-w-0 bg-transparent border", ui.defaultBorderMixin, isSmall ? "px-3.5 py-3" : "px-5 py-4");
|
|
371
|
+
$[25] = embedded;
|
|
372
|
+
$[26] = isSmall;
|
|
373
|
+
$[27] = t7;
|
|
374
|
+
} else {
|
|
375
|
+
t7 = $[27];
|
|
376
|
+
}
|
|
377
|
+
const baseClass = t7;
|
|
378
|
+
let t8;
|
|
379
|
+
if ($[28] !== embedded || $[29] !== isSmall) {
|
|
380
|
+
t8 = embedded ? void 0 : {
|
|
381
|
+
minHeight: isSmall ? 68 : 92
|
|
382
|
+
};
|
|
383
|
+
$[28] = embedded;
|
|
384
|
+
$[29] = isSmall;
|
|
385
|
+
$[30] = t8;
|
|
386
|
+
} else {
|
|
387
|
+
t8 = $[30];
|
|
388
|
+
}
|
|
389
|
+
const t9 = `flex items-center justify-between ${isSmall ? "mb-1" : "mb-2"}`;
|
|
390
|
+
const t10 = `font-medium leading-snug truncate text-surface-500 dark:text-surface-400 ${isSmall ? "text-[11px]" : "text-xs"}`;
|
|
391
|
+
let t11;
|
|
392
|
+
if ($[31] !== t10 || $[32] !== title) {
|
|
393
|
+
t11 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t10, children: title });
|
|
394
|
+
$[31] = t10;
|
|
395
|
+
$[32] = title;
|
|
396
|
+
$[33] = t11;
|
|
397
|
+
} else {
|
|
398
|
+
t11 = $[33];
|
|
399
|
+
}
|
|
400
|
+
let t12;
|
|
401
|
+
if ($[34] !== config.dateRange || $[35] !== isSmall) {
|
|
402
|
+
t12 = config.dateRange && !isSmall && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-surface-400 dark:text-surface-500 truncate mt-0.5", children: config.dateRange });
|
|
403
|
+
$[34] = config.dateRange;
|
|
404
|
+
$[35] = isSmall;
|
|
405
|
+
$[36] = t12;
|
|
406
|
+
} else {
|
|
407
|
+
t12 = $[36];
|
|
408
|
+
}
|
|
409
|
+
let t13;
|
|
410
|
+
if ($[37] !== t11 || $[38] !== t12) {
|
|
411
|
+
t13 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
412
|
+
t11,
|
|
413
|
+
t12
|
|
414
|
+
] });
|
|
415
|
+
$[37] = t11;
|
|
416
|
+
$[38] = t12;
|
|
417
|
+
$[39] = t13;
|
|
418
|
+
} else {
|
|
419
|
+
t13 = $[39];
|
|
420
|
+
}
|
|
421
|
+
let t14;
|
|
422
|
+
if ($[40] !== iconElement) {
|
|
423
|
+
t14 = iconElement && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 shrink-0", children: iconElement });
|
|
424
|
+
$[40] = iconElement;
|
|
425
|
+
$[41] = t14;
|
|
426
|
+
} else {
|
|
427
|
+
t14 = $[41];
|
|
428
|
+
}
|
|
429
|
+
let t15;
|
|
430
|
+
if ($[42] !== t13 || $[43] !== t14 || $[44] !== t9) {
|
|
431
|
+
t15 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t9, children: [
|
|
432
|
+
t13,
|
|
433
|
+
t14
|
|
434
|
+
] });
|
|
435
|
+
$[42] = t13;
|
|
436
|
+
$[43] = t14;
|
|
437
|
+
$[44] = t9;
|
|
438
|
+
$[45] = t15;
|
|
439
|
+
} else {
|
|
440
|
+
t15 = $[45];
|
|
441
|
+
}
|
|
442
|
+
const t16 = `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"}`;
|
|
443
|
+
let t17;
|
|
444
|
+
if ($[46] !== formattedValue || $[47] !== t16) {
|
|
445
|
+
t17 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: t16, children: formattedValue });
|
|
446
|
+
$[46] = formattedValue;
|
|
447
|
+
$[47] = t16;
|
|
448
|
+
$[48] = t17;
|
|
449
|
+
} else {
|
|
450
|
+
t17 = $[48];
|
|
451
|
+
}
|
|
452
|
+
let t18;
|
|
453
|
+
if ($[49] !== comparisonElement || $[50] !== isSmall) {
|
|
454
|
+
t18 = comparisonElement && /* @__PURE__ */ jsxRuntime.jsx("div", { className: isSmall ? "mt-0.5" : "mt-1", children: comparisonElement });
|
|
455
|
+
$[49] = comparisonElement;
|
|
456
|
+
$[50] = isSmall;
|
|
457
|
+
$[51] = t18;
|
|
458
|
+
} else {
|
|
459
|
+
t18 = $[51];
|
|
460
|
+
}
|
|
461
|
+
let t19;
|
|
462
|
+
if ($[52] !== baseClass || $[53] !== t15 || $[54] !== t17 || $[55] !== t18 || $[56] !== t8) {
|
|
463
|
+
t19 = /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: baseClass, style: t8, children: [
|
|
464
|
+
t15,
|
|
465
|
+
t17,
|
|
466
|
+
t18
|
|
467
|
+
] });
|
|
468
|
+
$[52] = baseClass;
|
|
469
|
+
$[53] = t15;
|
|
470
|
+
$[54] = t17;
|
|
471
|
+
$[55] = t18;
|
|
472
|
+
$[56] = t8;
|
|
473
|
+
$[57] = t19;
|
|
474
|
+
} else {
|
|
475
|
+
t19 = $[57];
|
|
476
|
+
}
|
|
477
|
+
return t19;
|
|
478
|
+
}
|
|
479
|
+
InsightsScorecardView.displayName = "InsightsScorecardView";
|
|
480
|
+
function InsightWidgetSkeleton(t0) {
|
|
481
|
+
const $ = reactCompilerRuntime.c(35);
|
|
482
|
+
const {
|
|
483
|
+
config,
|
|
484
|
+
compact: t1,
|
|
485
|
+
embedded: t2
|
|
486
|
+
} = t0;
|
|
487
|
+
const compact = t1 === void 0 ? false : t1;
|
|
488
|
+
const embedded = t2 === void 0 ? false : t2;
|
|
489
|
+
const hasComparison = Boolean(config.comparison);
|
|
490
|
+
const hasIcon = Boolean(config.icon);
|
|
491
|
+
const hasDateRange = Boolean(config.dateRange);
|
|
492
|
+
if (compact) {
|
|
493
|
+
const t32 = 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";
|
|
494
|
+
const t42 = !embedded && ui.defaultBorderMixin;
|
|
495
|
+
let t52;
|
|
496
|
+
if ($[0] !== t32 || $[1] !== t42) {
|
|
497
|
+
t52 = ui.cls("animate-pulse", t32, t42);
|
|
498
|
+
$[0] = t32;
|
|
499
|
+
$[1] = t42;
|
|
500
|
+
$[2] = t52;
|
|
501
|
+
} else {
|
|
502
|
+
t52 = $[2];
|
|
503
|
+
}
|
|
504
|
+
let t62;
|
|
505
|
+
if ($[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
506
|
+
t62 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded-sm", style: {
|
|
507
|
+
height: 14,
|
|
508
|
+
width: 48
|
|
509
|
+
} });
|
|
510
|
+
$[3] = t62;
|
|
511
|
+
} else {
|
|
512
|
+
t62 = $[3];
|
|
513
|
+
}
|
|
514
|
+
let t72;
|
|
515
|
+
if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
516
|
+
t72 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded-sm", style: {
|
|
517
|
+
height: 20,
|
|
518
|
+
width: 40
|
|
519
|
+
} });
|
|
520
|
+
$[4] = t72;
|
|
521
|
+
} else {
|
|
522
|
+
t72 = $[4];
|
|
523
|
+
}
|
|
524
|
+
let t82;
|
|
525
|
+
if ($[5] !== hasComparison) {
|
|
526
|
+
t82 = hasComparison && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200/60 dark:bg-surface-700/60 rounded-sm", style: {
|
|
527
|
+
height: 14,
|
|
528
|
+
width: 28
|
|
529
|
+
} });
|
|
530
|
+
$[5] = hasComparison;
|
|
531
|
+
$[6] = t82;
|
|
532
|
+
} else {
|
|
533
|
+
t82 = $[6];
|
|
534
|
+
}
|
|
535
|
+
let t92;
|
|
536
|
+
if ($[7] !== t82) {
|
|
537
|
+
t92 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline gap-1.5", children: [
|
|
538
|
+
t72,
|
|
539
|
+
t82
|
|
540
|
+
] });
|
|
541
|
+
$[7] = t82;
|
|
542
|
+
$[8] = t92;
|
|
543
|
+
} else {
|
|
544
|
+
t92 = $[8];
|
|
545
|
+
}
|
|
546
|
+
let t102;
|
|
547
|
+
if ($[9] !== t52 || $[10] !== t92) {
|
|
548
|
+
t102 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t52, children: [
|
|
549
|
+
t62,
|
|
550
|
+
t92
|
|
551
|
+
] });
|
|
552
|
+
$[9] = t52;
|
|
553
|
+
$[10] = t92;
|
|
554
|
+
$[11] = t102;
|
|
555
|
+
} else {
|
|
556
|
+
t102 = $[11];
|
|
557
|
+
}
|
|
558
|
+
return t102;
|
|
559
|
+
}
|
|
560
|
+
const t3 = embedded ? "h-full px-5 py-4" : "rounded-lg bg-transparent border px-5 py-4";
|
|
561
|
+
const t4 = !embedded && ui.defaultBorderMixin;
|
|
562
|
+
let t5;
|
|
563
|
+
if ($[12] !== t3 || $[13] !== t4) {
|
|
564
|
+
t5 = ui.cls("animate-pulse", t3, t4);
|
|
565
|
+
$[12] = t3;
|
|
566
|
+
$[13] = t4;
|
|
567
|
+
$[14] = t5;
|
|
568
|
+
} else {
|
|
569
|
+
t5 = $[14];
|
|
570
|
+
}
|
|
571
|
+
let t6;
|
|
572
|
+
if ($[15] !== embedded) {
|
|
573
|
+
t6 = embedded ? void 0 : {
|
|
574
|
+
minHeight: 92
|
|
575
|
+
};
|
|
576
|
+
$[15] = embedded;
|
|
577
|
+
$[16] = t6;
|
|
578
|
+
} else {
|
|
579
|
+
t6 = $[16];
|
|
580
|
+
}
|
|
581
|
+
let t7;
|
|
582
|
+
if ($[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
583
|
+
t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded", style: {
|
|
584
|
+
height: 16,
|
|
585
|
+
width: "60%"
|
|
586
|
+
} });
|
|
587
|
+
$[17] = t7;
|
|
588
|
+
} else {
|
|
589
|
+
t7 = $[17];
|
|
590
|
+
}
|
|
591
|
+
let t8;
|
|
592
|
+
if ($[18] !== hasDateRange) {
|
|
593
|
+
t8 = hasDateRange && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200/60 dark:bg-surface-700/60 rounded mt-0.5", style: {
|
|
594
|
+
height: 14,
|
|
595
|
+
width: "40%"
|
|
596
|
+
} });
|
|
597
|
+
$[18] = hasDateRange;
|
|
598
|
+
$[19] = t8;
|
|
599
|
+
} else {
|
|
600
|
+
t8 = $[19];
|
|
601
|
+
}
|
|
602
|
+
let t9;
|
|
603
|
+
if ($[20] !== t8) {
|
|
604
|
+
t9 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-w-0", children: [
|
|
605
|
+
t7,
|
|
606
|
+
t8
|
|
607
|
+
] });
|
|
608
|
+
$[20] = t8;
|
|
609
|
+
$[21] = t9;
|
|
610
|
+
} else {
|
|
611
|
+
t9 = $[21];
|
|
612
|
+
}
|
|
613
|
+
let t10;
|
|
614
|
+
if ($[22] !== hasIcon) {
|
|
615
|
+
t10 = hasIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded ml-2 shrink-0", style: {
|
|
616
|
+
height: 18,
|
|
617
|
+
width: 18
|
|
618
|
+
} });
|
|
619
|
+
$[22] = hasIcon;
|
|
620
|
+
$[23] = t10;
|
|
621
|
+
} else {
|
|
622
|
+
t10 = $[23];
|
|
623
|
+
}
|
|
624
|
+
let t11;
|
|
625
|
+
if ($[24] !== t10 || $[25] !== t9) {
|
|
626
|
+
t11 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
|
|
627
|
+
t9,
|
|
628
|
+
t10
|
|
629
|
+
] });
|
|
630
|
+
$[24] = t10;
|
|
631
|
+
$[25] = t9;
|
|
632
|
+
$[26] = t11;
|
|
633
|
+
} else {
|
|
634
|
+
t11 = $[26];
|
|
635
|
+
}
|
|
636
|
+
let t12;
|
|
637
|
+
if ($[27] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
638
|
+
t12 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200 dark:bg-surface-700 rounded", style: {
|
|
639
|
+
height: 32,
|
|
640
|
+
width: "40%"
|
|
641
|
+
} });
|
|
642
|
+
$[27] = t12;
|
|
643
|
+
} else {
|
|
644
|
+
t12 = $[27];
|
|
645
|
+
}
|
|
646
|
+
let t13;
|
|
647
|
+
if ($[28] !== hasComparison) {
|
|
648
|
+
t13 = hasComparison && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-surface-200/60 dark:bg-surface-700/60 rounded mt-1", style: {
|
|
649
|
+
height: 16,
|
|
650
|
+
width: "25%"
|
|
651
|
+
} });
|
|
652
|
+
$[28] = hasComparison;
|
|
653
|
+
$[29] = t13;
|
|
654
|
+
} else {
|
|
655
|
+
t13 = $[29];
|
|
656
|
+
}
|
|
657
|
+
let t14;
|
|
658
|
+
if ($[30] !== t11 || $[31] !== t13 || $[32] !== t5 || $[33] !== t6) {
|
|
659
|
+
t14 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t5, style: t6, children: [
|
|
660
|
+
t11,
|
|
661
|
+
t12,
|
|
662
|
+
t13
|
|
663
|
+
] });
|
|
664
|
+
$[30] = t11;
|
|
665
|
+
$[31] = t13;
|
|
666
|
+
$[32] = t5;
|
|
667
|
+
$[33] = t6;
|
|
668
|
+
$[34] = t14;
|
|
669
|
+
} else {
|
|
670
|
+
t14 = $[34];
|
|
671
|
+
}
|
|
672
|
+
return t14;
|
|
673
|
+
}
|
|
674
|
+
InsightWidgetSkeleton.displayName = "InsightWidgetSkeleton";
|
|
675
|
+
function InsightWidget(t0) {
|
|
676
|
+
const $ = reactCompilerRuntime.c(21);
|
|
677
|
+
const {
|
|
678
|
+
definition,
|
|
679
|
+
collectionSlug,
|
|
680
|
+
compact: t1,
|
|
681
|
+
embedded: t2
|
|
682
|
+
} = t0;
|
|
683
|
+
const compact = t1 === void 0 ? false : t1;
|
|
684
|
+
const embedded = t2 === void 0 ? false : t2;
|
|
685
|
+
const {
|
|
686
|
+
data,
|
|
687
|
+
loading,
|
|
688
|
+
error
|
|
689
|
+
} = useInsightsData(definition, collectionSlug);
|
|
690
|
+
if (loading) {
|
|
691
|
+
let t32;
|
|
692
|
+
if ($[0] !== compact || $[1] !== definition.scorecard || $[2] !== embedded) {
|
|
693
|
+
t32 = /* @__PURE__ */ jsxRuntime.jsx(InsightWidgetSkeleton, { config: definition.scorecard, compact, embedded });
|
|
694
|
+
$[0] = compact;
|
|
695
|
+
$[1] = definition.scorecard;
|
|
696
|
+
$[2] = embedded;
|
|
697
|
+
$[3] = t32;
|
|
698
|
+
} else {
|
|
699
|
+
t32 = $[3];
|
|
700
|
+
}
|
|
701
|
+
return t32;
|
|
702
|
+
}
|
|
703
|
+
if (error) {
|
|
704
|
+
const t32 = `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"}`}`;
|
|
705
|
+
let t42;
|
|
706
|
+
if ($[4] !== definition.title) {
|
|
707
|
+
t42 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold mb-1", children: definition.title });
|
|
708
|
+
$[4] = definition.title;
|
|
709
|
+
$[5] = t42;
|
|
710
|
+
} else {
|
|
711
|
+
t42 = $[5];
|
|
712
|
+
}
|
|
713
|
+
let t5;
|
|
714
|
+
if ($[6] !== error.message) {
|
|
715
|
+
t5 = /* @__PURE__ */ jsxRuntime.jsx("div", { children: error.message });
|
|
716
|
+
$[6] = error.message;
|
|
717
|
+
$[7] = t5;
|
|
718
|
+
} else {
|
|
719
|
+
t5 = $[7];
|
|
720
|
+
}
|
|
721
|
+
let t6;
|
|
722
|
+
if ($[8] !== t32 || $[9] !== t42 || $[10] !== t5) {
|
|
723
|
+
t6 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t32, children: [
|
|
724
|
+
t42,
|
|
725
|
+
t5
|
|
726
|
+
] });
|
|
727
|
+
$[8] = t32;
|
|
728
|
+
$[9] = t42;
|
|
729
|
+
$[10] = t5;
|
|
730
|
+
$[11] = t6;
|
|
731
|
+
} else {
|
|
732
|
+
t6 = $[11];
|
|
733
|
+
}
|
|
734
|
+
return t6;
|
|
735
|
+
}
|
|
736
|
+
if (!data || data.rows.length === 0) {
|
|
737
|
+
const t32 = `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"}`}`;
|
|
738
|
+
let t42;
|
|
739
|
+
if ($[12] !== definition.title || $[13] !== t32) {
|
|
740
|
+
t42 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t32, children: [
|
|
741
|
+
definition.title,
|
|
742
|
+
" — No data"
|
|
743
|
+
] });
|
|
744
|
+
$[12] = definition.title;
|
|
745
|
+
$[13] = t32;
|
|
746
|
+
$[14] = t42;
|
|
747
|
+
} else {
|
|
748
|
+
t42 = $[14];
|
|
749
|
+
}
|
|
750
|
+
return t42;
|
|
751
|
+
}
|
|
752
|
+
const t3 = data.rows[0];
|
|
753
|
+
let t4;
|
|
754
|
+
if ($[15] !== compact || $[16] !== definition.scorecard || $[17] !== definition.title || $[18] !== embedded || $[19] !== t3) {
|
|
755
|
+
t4 = /* @__PURE__ */ jsxRuntime.jsx(InsightsScorecardView, { config: definition.scorecard, data: t3, title: definition.title, compact, embedded });
|
|
756
|
+
$[15] = compact;
|
|
757
|
+
$[16] = definition.scorecard;
|
|
758
|
+
$[17] = definition.title;
|
|
759
|
+
$[18] = embedded;
|
|
760
|
+
$[19] = t3;
|
|
761
|
+
$[20] = t4;
|
|
762
|
+
} else {
|
|
763
|
+
t4 = $[20];
|
|
764
|
+
}
|
|
765
|
+
return t4;
|
|
766
|
+
}
|
|
767
|
+
InsightWidget.displayName = "InsightWidget";
|
|
768
|
+
function HomeCardInsightSlot(t0) {
|
|
769
|
+
const $ = reactCompilerRuntime.c(8);
|
|
770
|
+
const {
|
|
771
|
+
slug,
|
|
772
|
+
insights
|
|
773
|
+
} = t0;
|
|
774
|
+
if (!insights || insights.length === 0) {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
777
|
+
let t1;
|
|
778
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
779
|
+
t1 = {
|
|
780
|
+
minHeight: 46
|
|
781
|
+
};
|
|
782
|
+
$[0] = t1;
|
|
783
|
+
} else {
|
|
784
|
+
t1 = $[0];
|
|
785
|
+
}
|
|
786
|
+
let t2;
|
|
787
|
+
if ($[1] !== insights || $[2] !== slug) {
|
|
788
|
+
let t32;
|
|
789
|
+
if ($[4] !== slug) {
|
|
790
|
+
t32 = (def) => /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def, collectionSlug: slug, compact: true }, def.id);
|
|
791
|
+
$[4] = slug;
|
|
792
|
+
$[5] = t32;
|
|
793
|
+
} else {
|
|
794
|
+
t32 = $[5];
|
|
795
|
+
}
|
|
796
|
+
t2 = insights.map(t32);
|
|
797
|
+
$[1] = insights;
|
|
798
|
+
$[2] = slug;
|
|
799
|
+
$[3] = t2;
|
|
800
|
+
} else {
|
|
801
|
+
t2 = $[3];
|
|
802
|
+
}
|
|
803
|
+
let t3;
|
|
804
|
+
if ($[6] !== t2) {
|
|
805
|
+
t3 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-1.5 mt-2", style: t1, children: t2 });
|
|
806
|
+
$[6] = t2;
|
|
807
|
+
$[7] = t3;
|
|
808
|
+
} else {
|
|
809
|
+
t3 = $[7];
|
|
810
|
+
}
|
|
811
|
+
return t3;
|
|
812
|
+
}
|
|
813
|
+
HomeCardInsightSlot.displayName = "HomeCardInsightSlot";
|
|
814
|
+
function HomeInsightsSlot(t0) {
|
|
815
|
+
const $ = reactCompilerRuntime.c(5);
|
|
816
|
+
const {
|
|
817
|
+
insights
|
|
818
|
+
} = t0;
|
|
819
|
+
if (!insights || insights.length === 0) {
|
|
820
|
+
return null;
|
|
821
|
+
}
|
|
822
|
+
let t1;
|
|
823
|
+
if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
|
|
824
|
+
t1 = {
|
|
825
|
+
minHeight: 92
|
|
826
|
+
};
|
|
827
|
+
$[0] = t1;
|
|
828
|
+
} else {
|
|
829
|
+
t1 = $[0];
|
|
830
|
+
}
|
|
831
|
+
let t2;
|
|
832
|
+
if ($[1] !== insights) {
|
|
833
|
+
t2 = insights.map(_temp$1);
|
|
834
|
+
$[1] = insights;
|
|
835
|
+
$[2] = t2;
|
|
836
|
+
} else {
|
|
837
|
+
t2 = $[2];
|
|
838
|
+
}
|
|
839
|
+
let t3;
|
|
840
|
+
if ($[3] !== t2) {
|
|
841
|
+
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 });
|
|
842
|
+
$[3] = t2;
|
|
843
|
+
$[4] = t3;
|
|
844
|
+
} else {
|
|
845
|
+
t3 = $[4];
|
|
846
|
+
}
|
|
847
|
+
return t3;
|
|
848
|
+
}
|
|
849
|
+
function _temp$1(def) {
|
|
850
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def }, def.id);
|
|
851
|
+
}
|
|
852
|
+
HomeInsightsSlot.displayName = "HomeInsightsSlot";
|
|
853
|
+
function CollectionInsightsInline(t0) {
|
|
854
|
+
const $ = reactCompilerRuntime.c(4);
|
|
855
|
+
const {
|
|
856
|
+
insights
|
|
857
|
+
} = t0;
|
|
858
|
+
if (!insights || insights.length === 0) {
|
|
859
|
+
return null;
|
|
860
|
+
}
|
|
861
|
+
let t1;
|
|
862
|
+
if ($[0] !== insights) {
|
|
863
|
+
t1 = insights.map(_temp);
|
|
864
|
+
$[0] = insights;
|
|
865
|
+
$[1] = t1;
|
|
866
|
+
} else {
|
|
867
|
+
t1 = $[1];
|
|
868
|
+
}
|
|
869
|
+
let t2;
|
|
870
|
+
if ($[2] !== t1) {
|
|
871
|
+
t2 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 pb-4", children: t1 });
|
|
872
|
+
$[2] = t1;
|
|
873
|
+
$[3] = t2;
|
|
874
|
+
} else {
|
|
875
|
+
t2 = $[3];
|
|
876
|
+
}
|
|
877
|
+
return t2;
|
|
878
|
+
}
|
|
879
|
+
function _temp(def) {
|
|
880
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InsightWidget, { definition: def }, def.id);
|
|
881
|
+
}
|
|
882
|
+
CollectionInsightsInline.displayName = "CollectionInsightsInline";
|
|
883
|
+
function useInsightsPlugin(config) {
|
|
884
|
+
const {
|
|
885
|
+
insights,
|
|
886
|
+
cacheTTL
|
|
887
|
+
} = config;
|
|
888
|
+
const slots = [];
|
|
889
|
+
if (insights.home && insights.home.length > 0) {
|
|
890
|
+
const homeInsights = insights.home;
|
|
891
|
+
slots.push({
|
|
892
|
+
slot: "home.children.start",
|
|
893
|
+
Component: (props) => /* @__PURE__ */ jsxRuntime.jsx(HomeInsightsSlot, { ...props, insights: homeInsights }),
|
|
894
|
+
order: 10
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
if (insights.collections) {
|
|
898
|
+
for (const [slug, defs] of Object.entries(insights.collections)) {
|
|
899
|
+
if (defs.length === 0) continue;
|
|
900
|
+
const collectionInsights = defs;
|
|
901
|
+
slots.push({
|
|
902
|
+
slot: "collection.insights",
|
|
903
|
+
Component: (props) => {
|
|
904
|
+
const path = props.path;
|
|
905
|
+
const collectionSlug = path?.split("/").filter(Boolean).pop() ?? "";
|
|
906
|
+
if (collectionSlug !== slug) return null;
|
|
907
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CollectionInsightsInline, { ...props, insights: collectionInsights });
|
|
908
|
+
},
|
|
909
|
+
order: 10
|
|
910
|
+
});
|
|
911
|
+
slots.push({
|
|
912
|
+
slot: "home.card.insight",
|
|
913
|
+
Component: (props) => {
|
|
914
|
+
const cardSlug = props.slug;
|
|
915
|
+
if (cardSlug !== slug) return null;
|
|
916
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HomeCardInsightSlot, { ...props, insights: collectionInsights });
|
|
917
|
+
},
|
|
918
|
+
order: 10
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
return {
|
|
923
|
+
key: "plugin-insights",
|
|
924
|
+
slots,
|
|
925
|
+
providers: [{
|
|
926
|
+
scope: "root",
|
|
927
|
+
Component: InsightsProvider,
|
|
928
|
+
props: {
|
|
929
|
+
cacheTTL
|
|
930
|
+
}
|
|
931
|
+
}]
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
exports2.InsightWidget = InsightWidget;
|
|
935
|
+
exports2.InsightWidgetSkeleton = InsightWidgetSkeleton;
|
|
936
|
+
exports2.InsightsCache = InsightsCache;
|
|
937
|
+
exports2.InsightsProvider = InsightsProvider;
|
|
938
|
+
exports2.InsightsScorecardView = InsightsScorecardView;
|
|
939
|
+
exports2.useInsightsData = useInsightsData;
|
|
940
|
+
exports2.useInsightsEngine = useInsightsEngine;
|
|
941
|
+
exports2.useInsightsPlugin = useInsightsPlugin;
|
|
942
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
943
|
+
}));
|
|
944
|
+
//# sourceMappingURL=index.umd.js.map
|