@grafana/components 0.0.8 → 0.0.10

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.
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var runtime = require('@grafana/runtime');
6
7
  var react = require('react');
7
8
  require('@grafana/design-tokens/dist/css/legacy/primitives.css');
8
9
  require('@grafana/design-tokens/dist/css/legacy/colors.light.css');
@@ -11,7 +12,6 @@ var css = require('@emotion/css');
11
12
  var designTokens = require('@grafana/design-tokens');
12
13
  var ui = require('@grafana/ui');
13
14
  var react$1 = require('@floating-ui/react');
14
- var runtime = require('@grafana/runtime');
15
15
 
16
16
  const ColorModeContext = react.createContext(void 0);
17
17
  const ColorModeProvider = ({
@@ -33,6 +33,32 @@ const useColorMode = () => {
33
33
  return context;
34
34
  };
35
35
 
36
+ const getThemeColorMode = (isLight) => {
37
+ return isLight ? "light" : "dark";
38
+ };
39
+ const useColorModeChange = ({ getAppEvents, useTheme2 }) => {
40
+ const { setColorMode } = useColorMode();
41
+ const appEvents = getAppEvents();
42
+ appEvents.subscribe(runtime.ThemeChangedEvent, ({ payload }) => {
43
+ const { isLight: isLight2 } = payload;
44
+ const newColorMode2 = getThemeColorMode(isLight2);
45
+ console.log("ThemeChangedEvent", { colorMode: newColorMode2 });
46
+ setColorMode(newColorMode2);
47
+ });
48
+ const { isLight } = useTheme2();
49
+ const newColorMode = getThemeColorMode(isLight);
50
+ setColorMode(newColorMode);
51
+ };
52
+
53
+ const ColorModeChangeHandler = ({ children, getAppEvents, useTheme2 }) => {
54
+ useColorModeChange({ getAppEvents, useTheme2 });
55
+ return children;
56
+ };
57
+
58
+ const ColorMode = ({ children, getAppEvents, useTheme2 }) => {
59
+ return /* @__PURE__ */ jsxRuntime.jsx(ColorModeProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ColorModeChangeHandler, { getAppEvents, useTheme2, children }) });
60
+ };
61
+
36
62
  const formatNumber = (value, options = {}) => {
37
63
  const { decimals = 2, compactThreshold = 1e3, precise = false } = options;
38
64
  if (value === "loading") {
@@ -487,26 +513,8 @@ const ComparisonBadge = ({
487
513
  ] });
488
514
  };
489
515
 
490
- const getThemeColorMode = (isLight) => {
491
- return isLight ? "light" : "dark";
492
- };
493
- const useColorModeChange = ({
494
- getAppEvents,
495
- useTheme2
496
- }) => {
497
- const { setColorMode } = useColorMode();
498
- const appEvents = getAppEvents();
499
- appEvents.subscribe(runtime.ThemeChangedEvent, ({ payload }) => {
500
- const { isLight: isLight2 } = payload;
501
- const newColorMode2 = getThemeColorMode(isLight2);
502
- console.log("ThemeChangedEvent", { colorMode: newColorMode2 });
503
- setColorMode(newColorMode2);
504
- });
505
- const { isLight } = useTheme2();
506
- const newColorMode = getThemeColorMode(isLight);
507
- setColorMode(newColorMode);
508
- };
509
-
516
+ exports.ColorMode = ColorMode;
517
+ exports.ColorModeChangeHandler = ColorModeChangeHandler;
510
518
  exports.ColorModeProvider = ColorModeProvider;
511
519
  exports.ComparisonBadge = ComparisonBadge;
512
520
  exports.ComparisonTooltip = ComparisonTooltip;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/components/ColorModeProvider/ColorModeProvider.tsx","../../src/utils/formatters.ts","../../src/utils/comparison.ts","../../src/components/Popover/Popover.styles.ts","../../src/components/Popover/Popover.tsx","../../src/components/ComparisonTooltip/ComparisonTooltip.styles.ts","../../src/components/ComparisonTooltip/ComparisonTooltip.tsx","../../src/components/ComparisonBadge/ComparisonBadge.styles.ts","../../src/components/ComparisonBadge/ComparisonBadge.tsx","../../src/hooks/useColorModeChange.ts"],"sourcesContent":["import React, { createContext, useContext, useEffect, useState, ReactNode } from 'react';\nimport { ThemeColorMode } from '@grafana/design-tokens';\n\nimport '@grafana/design-tokens/dist/css/legacy/primitives.css';\nimport '@grafana/design-tokens/dist/css/legacy/colors.light.css';\nimport '@grafana/design-tokens/dist/css/legacy/colors.dark.css';\n\nexport interface ColorModeContextType {\n colorMode: ThemeColorMode;\n setColorMode: (colorMode: ThemeColorMode) => void;\n}\n\nexport interface ColorModeProviderProps {\n children: ReactNode;\n defaultColorMode?: ThemeColorMode;\n}\n\nconst ColorModeContext = createContext<ColorModeContextType | undefined>(undefined);\n\n/**\n * Provides a shared context for the currently-active theme color mode, and sets\n * the data-color-mode attribute on the document element whenever it changes.\n */\nexport const ColorModeProvider: React.FC<ColorModeProviderProps> = ({\n children,\n defaultColorMode = 'light',\n}) => {\n const [colorMode, setColorMode] = useState<ThemeColorMode>(defaultColorMode);\n\n useEffect(() => {\n console.log('ColorModeProvider', { colorMode });\n document.documentElement.setAttribute('data-color-mode', colorMode);\n }, [colorMode]);\n\n return (\n <ColorModeContext.Provider value={{ colorMode, setColorMode }}>\n {children}\n </ColorModeContext.Provider>\n );\n};\n\n/**\n * Use this to query the active color mode, or to set it, e.g. with an effect\n * hook within a component which explicitly changes the active color mode:\n *\n * useEffect(() => {\n * setColorMode(colorMode);\n * }, [colorMode]);\n *\n */\nexport const useColorMode = () => {\n const context = useContext(ColorModeContext);\n\n if (context === undefined) {\n throw new Error('useColorMode must be used within a ColorModeProvider');\n }\n\n return context;\n};\n","/**\n * Number formatting options\n */\nexport interface FormatNumberOptions {\n /** Decimal places (default: 2) */\n decimals?: number;\n /** Threshold for compact formatting (default: 1000) */\n compactThreshold?: number;\n /** Never use compact formatting (for precise displays) */\n precise?: boolean;\n}\n\n/**\n * Format numbers with optional compact notation (k, m, b)\n * Components handle their own prefixes/suffixes ($ or %)\n *\n * @param value - The number to format (or 'loading' state)\n * @param options - Formatting options\n * @returns Formatted number string (no prefixes/suffixes)\n *\n * @example\n * formatNumber(1234) // \"1.2k\"\n * formatNumber(1234, { precise: true }) // \"1,234.00\"\n * formatNumber(1234, { decimals: 0 }) // \"1k\"\n * formatNumber(999) // \"999.00\"\n */\nexport const formatNumber = (\n value: number | string | 'loading',\n options: FormatNumberOptions = {},\n): string => {\n const { decimals = 2, compactThreshold = 1000, precise = false } = options;\n\n if (value === 'loading') {\n return '';\n }\n\n const num = typeof value === 'string' ? parseFloat(value) : value;\n if (isNaN(num)) {\n return 'N/A';\n }\n\n const abs = Math.abs(num);\n\n // Use compact notation if above threshold and not precise\n if (!precise && abs >= compactThreshold) {\n const sign = num < 0 ? '-' : '';\n const absNum = Math.abs(num);\n // Always use 1 decimal place for compact notation for consistency\n if (absNum >= 1000000000) {\n return `${sign}${(absNum / 1000000000).toFixed(1)}b`;\n } else if (absNum >= 1000000) {\n return `${sign}${(absNum / 1000000).toFixed(1)}m`;\n } else if (absNum >= 1000) {\n return `${sign}${(absNum / 1000).toFixed(1)}k`;\n }\n }\n\n // Standard formatting with specified decimal places\n return num.toLocaleString('en-US', {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n};\n","/**\n * Shared utility functions for handling comparison calculations across components\n */\n\nimport { formatNumber } from './formatters';\n\nexport interface ComparisonResult {\n hasComparison: boolean;\n direction: 'up' | 'down' | 'neutral';\n percentageChange: number;\n percentageLabel: string;\n}\n\n/**\n * Calculate comparison metrics between a current value and a baseline value\n * @param current - The current value to compare\n * @param baseline - The baseline value to compare against (optional)\n * @returns ComparisonResult object with calculated metrics\n */\nexport const calculateComparison = (\n current: number | undefined | null,\n baseline: number | undefined | null,\n): ComparisonResult => {\n // If either value is missing, null, undefined, or baseline is 0, return neutral state\n if (\n current === undefined ||\n current === null ||\n baseline === undefined ||\n baseline === null ||\n baseline === 0\n ) {\n return {\n hasComparison: false,\n direction: 'neutral',\n percentageChange: 0,\n percentageLabel: '',\n };\n }\n\n // If values are equal, return neutral state\n if (current === baseline) {\n return {\n hasComparison: true,\n direction: 'neutral',\n percentageChange: 0,\n percentageLabel: '0%',\n };\n }\n\n // Calculate percentage change\n const percentageChange = Math.abs(((current - baseline) / baseline) * 100);\n const direction = current > baseline ? 'up' : 'down';\n\n return {\n hasComparison: true,\n direction,\n percentageChange,\n percentageLabel: `${formatNumber(percentageChange, {\n compactThreshold: 10000,\n decimals: 2,\n })}%`,\n };\n};\n","import { css } from '@emotion/css';\nimport { getDesignTokens } from '@grafana/design-tokens';\n\nexport const getStyles = () => {\n const {\n legacy,\n primitives: { spacing, typography },\n } = getDesignTokens({ valueType: 'css' });\n const backgroundColor = legacy.colors.background.primary;\n\n return {\n arrow: css({\n fill: backgroundColor,\n }),\n shadow: css({\n filter: `drop-shadow(${legacy.boxShadows.z2})`,\n }),\n container: css({\n backgroundColor,\n borderRadius: `calc(${legacy.borderRadius.md} + ${spacing.xs})`,\n padding: spacing.xs,\n color: legacy.colors.text.primary,\n fontFamily: typography.fontFamily.ui,\n fontSize: typography.fontSize.ui.sm,\n fontWeight: typography.fontWeight.medium,\n }),\n };\n};\n","import { forwardRef, cloneElement, useCallback, useId, useRef, useState, JSX } from 'react';\nimport {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n offset,\n Placement,\n safePolygon,\n shift,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { Portal } from '@grafana/ui';\nimport { getStyles } from './Popover.styles';\n\nexport interface PopoverProps {\n /**\n * Content used to trigger the Popover being displayed\n */\n trigger: JSX.Element;\n\n /**\n * Content to render within the Popover\n */\n children: JSX.Element;\n /**\n * Should the popover be open? Implicitly means the popover visibility is\n * controlled; if omitted, the popover target will control visibility\n */\n isOpen?: boolean;\n\n /**\n * Set to true if you want the tooltip to stay long enough so the user can\n * move mouse over content to select text or click a link\n */\n isInteractive?: boolean;\n\n /**\n * Placement of the Popover relative to the trigger content\n */\n placement?: Placement;\n\n /**\n * Transition duration for hide/show effects, in milliseconds\n */\n transitionDuration?: number;\n\n /**\n * Additional delay before hiding the popover after mouseout, in milliseconds\n */\n hideDelay?: number;\n}\n\nconst POPOVER_OFFSET = 8;\n\nconst getMiddleware = ({\n placement,\n arrowRef,\n}: {\n placement?: Placement;\n arrowRef: React.RefObject<null>;\n}) => {\n const BOUNDARY_ELEMENT_ID = 'floating-boundary';\n const _flip = flip({\n // Ensure we flip to the perpendicular axis if it doesn't fit\n // on narrow viewports.\n crossAxis: 'alignment',\n fallbackAxisSideDirection: 'end',\n boundary: document.getElementById(BOUNDARY_ELEMENT_ID) ?? undefined,\n });\n\n const middleware = placement?.includes('-') ? [_flip, shift()] : [shift(), _flip];\n\n // the order of middleware is important!\n // `arrow` should almost always be at the end\n // see https://floating-ui.com/docs/arrow#order\n return [\n offset(POPOVER_OFFSET),\n ...middleware,\n arrow({\n element: arrowRef,\n }),\n ];\n};\n\nexport const Popover = forwardRef<HTMLElement, PopoverProps>(\n (\n {\n trigger,\n children,\n isOpen: isOpenControlled,\n isInteractive = false,\n placement = 'bottom',\n transitionDuration = 200,\n hideDelay = 500,\n },\n forwardedRef,\n ) => {\n const arrowRef = useRef(null);\n const closeTimer = useRef<number | undefined>(undefined);\n const popoverId = useId();\n const [isOpenState, setOpen] = useState(isOpenControlled);\n const [isDelayedOpen, setDelayedOpen] = useState(isOpenControlled);\n const isOpen = isOpenControlled ?? isOpenState;\n const middleware = getMiddleware({ placement, arrowRef });\n const styles = getStyles();\n\n const { context, refs, floatingStyles } = useFloating({\n open: isOpen,\n placement,\n onOpenChange: (open) => {\n setOpen(open);\n clearTimeout(closeTimer.current);\n\n if (!open) {\n closeTimer.current = setTimeout(() => {\n setDelayedOpen(open);\n }, transitionDuration + hideDelay);\n } else {\n setDelayedOpen(open);\n }\n },\n middleware,\n whileElementsMounted: autoUpdate,\n });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useDismiss(context),\n useHover(context, {\n handleClose: isInteractive ? safePolygon() : undefined,\n move: false,\n delay: {\n open: 0,\n close: hideDelay,\n },\n }),\n useFocus(context),\n ]);\n\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: transitionDuration,\n initial: ({ side }) => ({\n opacity: 0,\n transform:\n side === 'top' || side === 'bottom'\n ? `translateY(${POPOVER_OFFSET}px)`\n : `translateX(${POPOVER_OFFSET}px)`,\n }),\n open: ({ side }) => ({\n opacity: 1,\n transform: side === 'top' || side === 'bottom' ? `translateY(0)` : `translateX(0)`,\n }),\n close: ({ side }) => ({\n opacity: 0,\n transform:\n side === 'top' || side === 'bottom'\n ? `translateY(${POPOVER_OFFSET}px)`\n : `translateX(${POPOVER_OFFSET}px)`,\n }),\n });\n\n const handleRef = useCallback(\n (ref: HTMLElement | null) => {\n refs.setReference(ref);\n\n if (typeof forwardedRef === 'function') {\n forwardedRef(ref);\n } else if (forwardedRef) {\n forwardedRef.current = ref;\n }\n },\n [forwardedRef, refs],\n );\n\n return (\n <>\n {/* element to trigger displaying the popover */}\n {cloneElement(trigger, {\n ref: handleRef,\n tabIndex: 0,\n 'aria-describedby': isOpen ? popoverId : undefined,\n ...getReferenceProps(),\n })}\n {/* content to render inside the popover when open */}\n {(isDelayedOpen || isOpen) && (\n <Portal>\n <div ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>\n <div style={transitionStyles} className={styles.shadow}>\n <FloatingArrow className={styles.arrow} ref={arrowRef} context={context} />\n <div id={popoverId} role=\"tooltip\" className={styles.container}>\n {children}\n </div>\n </div>\n </div>\n </Portal>\n )}\n </>\n );\n },\n);\n\nPopover.displayName = 'Popover';\n","import { css } from '@emotion/css';\nimport { getDesignTokens } from '@grafana/design-tokens';\n\nexport const getStyles = () => {\n const {\n legacy,\n primitives: { spacing, typography },\n } = getDesignTokens({ valueType: 'css' });\n\n return {\n wrapper: css({\n display: 'flex',\n flexDirection: 'column',\n gap: spacing.xs,\n }),\n heading: css({\n padding: `${spacing.sm} ${spacing.md}`,\n fontFamily: typography.fontFamily.ui,\n fontSize: typography.fontSize.ui.sm,\n fontWeight: typography.fontWeight.bold,\n color: legacy.colors.text.primary,\n background: legacy.colors.background.secondary,\n borderRadius: legacy.borderRadius.md,\n }),\n content: css({\n display: 'flex',\n gap: spacing.xs,\n }),\n section: css({\n display: 'flex',\n flex: 1,\n flexDirection: 'column',\n justifyContent: 'flex-end',\n gap: spacing.xs,\n background: legacy.colors.background.secondary,\n borderRadius: legacy.borderRadius.md,\n padding: `${spacing.sm} ${spacing.md}`,\n minWidth: `80px`,\n }),\n sectionTitle: css({\n fontFamily: typography.fontFamily.ui,\n fontSize: typography.fontSize.ui.sm,\n fontWeight: typography.fontWeight.medium,\n color: legacy.colors.text.primary,\n whiteSpace: 'nowrap',\n }),\n value: css({\n display: 'flex',\n alignItems: 'center',\n gap: spacing.xs,\n fontFamily: typography.fontFamily.monospace,\n fontSize: typography.fontSize.monospace.sm,\n color: legacy.colors.text.secondary,\n }),\n icon: css({\n flexShrink: 0,\n }),\n };\n};\n","import { Icon, IconName } from '@grafana/ui';\nimport { Popover, PopoverProps } from '../Popover';\nimport { getStyles } from './ComparisonTooltip.styles';\n\nexport interface ComparisonTooltipProps extends Omit<PopoverProps, 'children'> {\n current?: string;\n previous?: string;\n previousLabel?: string;\n currentLabel?: string;\n title?: string;\n currentIcon?: IconName;\n previousIcon?: IconName;\n hideDelay?: number;\n}\n\nexport const ComparisonTooltip = ({\n trigger,\n placement = 'top',\n current,\n previous,\n previousLabel,\n currentLabel = 'Current',\n title,\n currentIcon = 'eye',\n previousIcon = 'clock-nine',\n hideDelay,\n}: ComparisonTooltipProps) => {\n const styles = getStyles();\n\n return (\n <Popover trigger={trigger} placement={placement} hideDelay={hideDelay}>\n <div className={styles.wrapper}>\n {title && <div className={styles.heading}>{title}</div>}\n <div className={styles.content}>\n <div className={styles.section}>\n <div className={styles.sectionTitle}>{currentLabel}</div>\n <div className={styles.value}>\n <Icon name={currentIcon} size=\"sm\" className={styles.icon} />\n <span>{current || 'N/A'}</span>\n </div>\n </div>\n <div className={styles.section}>\n <div className={styles.sectionTitle}>{previousLabel}</div>\n <div className={styles.value}>\n <Icon name={previousIcon} size=\"sm\" className={styles.icon} />\n <span>{previous || 'N/A'}</span>\n </div>\n </div>\n </div>\n </div>\n </Popover>\n );\n};\n","import { css } from '@emotion/css';\nimport { CSSVariables, getDesignTokens } from '@grafana/design-tokens';\n\nexport const cssVariables = (): CSSVariables => {\n const { legacy } = getDesignTokens({ valueType: 'css' });\n\n return {\n dark: {\n 'comparison-badge-icon-background-color': legacy.colors.background.secondary,\n 'comparison-badge-icon-highlight-background-color': legacy.palette.whiteBaseOpacity10,\n },\n light: {\n 'comparison-badge-icon-background-color': legacy.colors.background.canvas,\n 'comparison-badge-icon-highlight-background-color': legacy.palette.blackBaseOpacity8,\n },\n };\n};\n\nconst BADGE_HEIGHT = 28;\nconst TREND_ICON_SIZE = 20;\n\nexport const getComparisonBadgeStyles = ({\n highlight,\n direction,\n tooltip,\n}: {\n highlight: boolean;\n direction: string;\n tooltip?: boolean;\n}) => {\n const {\n legacy,\n primitives: { spacing, typography },\n } = getDesignTokens({ valueType: 'css' });\n\n const labelColor = (() => {\n switch (true) {\n case highlight:\n case direction === 'up':\n return legacy.colors.text.maxContrast;\n default:\n return legacy.colors.primary.text;\n }\n })();\n\n return {\n container: css({\n boxSizing: 'border-box',\n background: 'transparent',\n borderRadius: legacy.borderRadius.pill,\n border: `1px solid\n ${highlight ? legacy.colors.border.strong : legacy.colors.border.weak}`,\n padding: `${spacing.xxs} ${spacing.sm} ${spacing.xxs} ${spacing.xxs}`,\n textAlign: 'left',\n display: 'inline-flex',\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n fontFamily: typography.fontFamily.ui,\n fontSize: typography.fontSize.ui.sm,\n height: `${BADGE_HEIGHT}px`,\n position: 'relative',\n transition: 'background 0.2s ease-in-out',\n ...(tooltip\n ? {\n cursor: 'pointer',\n '&:hover': {\n background: legacy.colors.background.secondary,\n },\n }\n : {}),\n }),\n clockIconWrapper: css({\n background: highlight\n ? 'var(--comparison-badge-icon-highlight-background-color)'\n : 'var(--comparison-badge-icon-background-color)',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '22px',\n height: '22px',\n borderRadius: legacy.borderRadius.pill,\n color: legacy.colors.text.primary,\n }),\n trendLabelContainer: css({\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n gap: spacing.xxs,\n paddingLeft: spacing.xxs,\n fontWeight: typography.fontWeight.medium,\n }),\n trendLabel: css({\n display: 'flex',\n alignItems: 'center',\n color: labelColor,\n lineHeight: `${BADGE_HEIGHT}px`,\n fontWeight: typography.fontWeight.medium,\n fontVariantNumeric: 'tabular-nums',\n }),\n timeframeLabel: css({\n color: highlight ? legacy.colors.text.maxContrast : legacy.colors.text.primary,\n paddingLeft: spacing.xxs,\n lineHeight: `${BADGE_HEIGHT}px`,\n fontWeight: typography.fontWeight.normal,\n }),\n trendIconWrapper: css({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '16px',\n height: '16px',\n }),\n trendIcon: css({\n width: `${TREND_ICON_SIZE}px`,\n height: `${TREND_ICON_SIZE}px`,\n }),\n dash: css({\n color: legacy.colors.text.secondary,\n }),\n };\n};\n","import { cx } from '@emotion/css';\nimport { GlobalCSSVariables } from '@grafana/design-tokens';\nimport { Icon, IconName } from '@grafana/ui';\nimport { calculateComparison } from '../../utils/comparison';\nimport { formatNumber } from '../../utils/formatters';\nimport { ComparisonTooltipProps, ComparisonTooltip } from '../ComparisonTooltip';\nimport { cssVariables, getComparisonBadgeStyles } from './ComparisonBadge.styles';\n\nconst formatCurrency = (value: number | undefined | null): string => {\n return !!value ? `$${formatNumber(value, { precise: true })}` : 'N/A';\n};\n\nexport interface ComparisonBadgeProps\n extends Pick<ComparisonTooltipProps, 'currentLabel' | 'previousLabel' | 'placement'> {\n current?: number | null;\n previous?: number | null;\n highlight?: boolean;\n timeframeLabel?: string;\n tooltip?: boolean;\n}\n\nconst DIRECTION_ICON: Record<'up' | 'down' | 'neutral', IconName> = {\n up: 'arrow-up',\n down: 'arrow-down',\n neutral: 'minus',\n};\n\nexport const ComparisonBadge = ({\n current,\n previous,\n currentLabel,\n previousLabel,\n placement,\n highlight = false,\n timeframeLabel,\n tooltip = true,\n}: ComparisonBadgeProps) => {\n const { direction, hasComparison, percentageLabel } = calculateComparison(current, previous);\n const styles = getComparisonBadgeStyles({ highlight, direction, tooltip });\n\n const directionIconStyle = (() => {\n switch (true) {\n case direction == 'neutral':\n return styles.dash;\n default:\n return undefined;\n }\n })();\n\n const badgeContent = (\n <div className={styles.container}>\n <div className={styles.clockIconWrapper}>\n <Icon name=\"clock-nine\" />\n </div>\n <div className={styles.trendLabelContainer}>\n <span className={styles.trendLabel}>\n <span className={styles.trendIconWrapper}>\n <Icon\n name={DIRECTION_ICON[direction]}\n className={cx(styles.trendIcon, directionIconStyle)}\n />\n </span>\n {hasComparison && percentageLabel && <>{percentageLabel}</>}\n </span>\n {timeframeLabel && (\n <span className={styles.timeframeLabel}>vs {timeframeLabel.toLowerCase()}</span>\n )}\n </div>\n </div>\n );\n\n return (\n <>\n <GlobalCSSVariables variables={cssVariables()} defaultColorMode={null} />\n {tooltip ? (\n <ComparisonTooltip\n trigger={badgeContent}\n current={formatCurrency(current)}\n previous={formatCurrency(previous)}\n currentLabel={currentLabel}\n previousLabel={previousLabel}\n placement={placement}\n />\n ) : (\n badgeContent\n )}\n </>\n );\n};\n","import type { EventBus, GrafanaTheme2 } from '@grafana/data';\nimport { ThemeChangedEvent } from '@grafana/runtime';\nimport type { ThemeColorMode } from '@grafana/design-tokens';\nimport { useColorMode } from '../components/ColorModeProvider/ColorModeProvider';\n\nconst getThemeColorMode = (isLight: boolean): ThemeColorMode => {\n return isLight ? 'light' : 'dark';\n};\n\n/**\n * This allows us to register an event listener for when the ThemeChangedEvent\n * is fired, and update the currently active color mode accordingly. It will\n * also determine the color mode on initial registration, and update the context\n * provider accordingly.\n */\nexport const useColorModeChange = ({\n getAppEvents,\n useTheme2,\n}: {\n getAppEvents: () => EventBus;\n useTheme2: () => GrafanaTheme2;\n}) => {\n const { setColorMode } = useColorMode();\n const appEvents = getAppEvents();\n\n appEvents.subscribe<ThemeChangedEvent>(ThemeChangedEvent, ({ payload }) => {\n const { isLight } = payload;\n const newColorMode = getThemeColorMode(isLight);\n\n console.log('ThemeChangedEvent', { colorMode: newColorMode });\n setColorMode(newColorMode);\n });\n\n /**\n * Longterm the current colorMode should ideally exist outside of useTheme2\n */\n const { isLight } = useTheme2();\n const newColorMode = getThemeColorMode(isLight);\n setColorMode(newColorMode);\n};\n"],"names":["createContext","useState","useEffect","jsx","useContext","getStyles","getDesignTokens","css","flip","shift","offset","arrow","forwardRef","useRef","useId","useFloating","autoUpdate","useInteractions","useDismiss","useHover","safePolygon","useFocus","useTransitionStyles","useCallback","jsxs","Fragment","cloneElement","Portal","FloatingArrow","Icon","cx","GlobalCSSVariables","ThemeChangedEvent","isLight","newColorMode"],"mappings":";;;;;;;;;;;;;;;AAiBA,MAAM,gBAAA,GAAmBA,oBAAgD,MAAS,CAAA;AAM3E,MAAM,oBAAsD,CAAC;AAAA,EAClE,QAAA;AAAA,EACA,gBAAA,GAAmB;AACrB,CAAA,KAAM;AACJ,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAIC,eAAyB,gBAAgB,CAAA;AAE3E,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,OAAA,CAAQ,GAAA,CAAI,mBAAA,EAAqB,EAAE,SAAA,EAAW,CAAA;AAC9C,IAAA,QAAA,CAAS,eAAA,CAAgB,YAAA,CAAa,iBAAA,EAAmB,SAAS,CAAA;AAAA,EACpE,CAAA,EAAG,CAAC,SAAS,CAAC,CAAA;AAEd,EAAA,uBACEC,cAAA,CAAC,iBAAiB,QAAA,EAAjB,EAA0B,OAAO,EAAE,SAAA,EAAW,YAAA,EAAa,EACzD,QAAA,EACH,CAAA;AAEJ;AAWO,MAAM,eAAe,MAAM;AAChC,EAAA,MAAM,OAAA,GAAUC,iBAAW,gBAAgB,CAAA;AAE3C,EAAA,IAAI,YAAY,MAAA,EAAW;AACzB,IAAA,MAAM,IAAI,MAAM,sDAAsD,CAAA;AAAA,EACxE;AAEA,EAAA,OAAO,OAAA;AACT;;AChCO,MAAM,YAAA,GA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C,iBAAA;AAAA,MAAA;AAAA,QACC,OAAA,EAAS,YAAA;AAAA,QACT,OAAA,EAAS,eAAe,OAAO,CAAA;AAAA,QAC/B,QAAA,EAAU,eAAe,QAAQ,CAAA;AAAA,QACjC,YAAA;AAAA,QACA,aAAA;AAAA,QACA;AAAA;AAAA,KACF,GAEA;AAAA,GAAA,EAEJ,CAAA;AAEJ;;ACnFA,MAAM,iBAAA,GAAoB,CAAC,OAAA,KAAqC;AAC9D,EAAA,OAAO,UAAU,OAAA,GAAU,MAAA;AAC7B,CAAA;AAQO,MAAM,qBAAqB,CAAC;AAAA,EACjC,YAAA;AAAA,EACA;AACF,CAAA,KAGM;AACJ,EAAA,MAAM,EAAE,YAAA,EAAa,GAAI,YAAA,EAAa;AACtC,EAAA,MAAM,YAAY,YAAA,EAAa;AAE/B,EAAA,SAAA,CAAU,SAAA,CAA6B6B,yBAAA,EAAmB,CAAC,EAAE,SAAQ,KAAM;AACzE,IAAA,MAAM,EAAE,OAAA,EAAAC,QAAAA,EAAQ,GAAI,OAAA;AACpB,IAAA,MAAMC,aAAAA,GAAe,kBAAkBD,QAAO,CAAA;AAE9C,IAAA,OAAA,CAAQ,GAAA,CAAI,mBAAA,EAAqB,EAAE,SAAA,EAAWC,eAAc,CAAA;AAC5D,IAAA,YAAA,CAAaA,aAAY,CAAA;AAAA,EAC3B,CAAC,CAAA;AAKD,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,SAAA,EAAU;AAC9B,EAAA,MAAM,YAAA,GAAe,kBAAkB,OAAO,CAAA;AAC9C,EAAA,YAAA,CAAa,YAAY,CAAA;AAC3B;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/components/ColorModeProvider/ColorModeProvider.tsx","../../src/hooks/useColorModeChange.ts","../../src/components/ColorModeChangeHandler/ColorModeChangeHandler.tsx","../../src/components/ColorMode/ColorMode.tsx","../../src/utils/formatters.ts","../../src/utils/comparison.ts","../../src/components/Popover/Popover.styles.ts","../../src/components/Popover/Popover.tsx","../../src/components/ComparisonTooltip/ComparisonTooltip.styles.ts","../../src/components/ComparisonTooltip/ComparisonTooltip.tsx","../../src/components/ComparisonBadge/ComparisonBadge.styles.ts","../../src/components/ComparisonBadge/ComparisonBadge.tsx"],"sourcesContent":["import React, { createContext, useContext, useEffect, useState, ReactNode } from 'react';\nimport { ThemeColorMode } from '@grafana/design-tokens';\n\nimport '@grafana/design-tokens/dist/css/legacy/primitives.css';\nimport '@grafana/design-tokens/dist/css/legacy/colors.light.css';\nimport '@grafana/design-tokens/dist/css/legacy/colors.dark.css';\n\nexport interface ColorModeContextType {\n colorMode: ThemeColorMode;\n setColorMode: (colorMode: ThemeColorMode) => void;\n}\n\nexport interface ColorModeProviderProps {\n children: ReactNode;\n defaultColorMode?: ThemeColorMode;\n}\n\nconst ColorModeContext = createContext<ColorModeContextType | undefined>(undefined);\n\n/**\n * Provides a shared context for the currently-active theme color mode, and sets\n * the data-color-mode attribute on the document element whenever it changes.\n */\nexport const ColorModeProvider: React.FC<ColorModeProviderProps> = ({\n children,\n defaultColorMode = 'light',\n}) => {\n const [colorMode, setColorMode] = useState<ThemeColorMode>(defaultColorMode);\n\n useEffect(() => {\n console.log('ColorModeProvider', { colorMode });\n document.documentElement.setAttribute('data-color-mode', colorMode);\n }, [colorMode]);\n\n return (\n <ColorModeContext.Provider value={{ colorMode, setColorMode }}>\n {children}\n </ColorModeContext.Provider>\n );\n};\n\n/**\n * Use this to query the active color mode, or to set it, e.g. with an effect\n * hook within a component which explicitly changes the active color mode:\n *\n * useEffect(() => {\n * setColorMode(colorMode);\n * }, [colorMode]);\n *\n */\nexport const useColorMode = () => {\n const context = useContext(ColorModeContext);\n\n if (context === undefined) {\n throw new Error('useColorMode must be used within a ColorModeProvider');\n }\n\n return context;\n};\n","import type { EventBus, GrafanaTheme2 } from '@grafana/data';\nimport { ThemeChangedEvent } from '@grafana/runtime';\nimport type { ThemeColorMode } from '@grafana/design-tokens';\nimport { useColorMode } from '../components/ColorModeProvider/ColorModeProvider';\n\nconst getThemeColorMode = (isLight: boolean): ThemeColorMode => {\n return isLight ? 'light' : 'dark';\n};\n\nexport interface ColorModeChangeProps {\n getAppEvents: () => EventBus;\n useTheme2: () => GrafanaTheme2;\n}\n\n/**\n * This allows us to register an event listener for when the ThemeChangedEvent\n * is fired, and update the currently active color mode accordingly. It will\n * also determine the color mode on initial registration, and update the context\n * provider accordingly.\n */\nexport const useColorModeChange = ({ getAppEvents, useTheme2 }: ColorModeChangeProps) => {\n const { setColorMode } = useColorMode();\n const appEvents = getAppEvents();\n\n appEvents.subscribe<ThemeChangedEvent>(ThemeChangedEvent, ({ payload }) => {\n const { isLight } = payload;\n const newColorMode = getThemeColorMode(isLight);\n\n console.log('ThemeChangedEvent', { colorMode: newColorMode });\n setColorMode(newColorMode);\n });\n\n /**\n * Longterm the current colorMode should ideally exist outside of useTheme2\n */\n const { isLight } = useTheme2();\n const newColorMode = getThemeColorMode(isLight);\n setColorMode(newColorMode);\n};\n","import React from 'react';\nimport { useColorModeChange, ColorModeChangeProps } from '../../hooks';\n\nexport type ColorModeWrapper = React.FC<ColorModeChangeProps & { children: React.ReactNode }>;\n\nexport const ColorModeChangeHandler: ColorModeWrapper = ({ children, getAppEvents, useTheme2 }) => {\n useColorModeChange({ getAppEvents, useTheme2 });\n\n return children;\n};\n","import { ColorModeWrapper, ColorModeChangeHandler } from '../ColorModeChangeHandler';\nimport { ColorModeProvider } from '../ColorModeProvider';\n\nexport const ColorMode: ColorModeWrapper = ({ children, getAppEvents, useTheme2 }) => {\n return (\n <ColorModeProvider>\n <ColorModeChangeHandler getAppEvents={getAppEvents} useTheme2={useTheme2}>\n {children}\n </ColorModeChangeHandler>\n </ColorModeProvider>\n );\n};\n","/**\n * Number formatting options\n */\nexport interface FormatNumberOptions {\n /** Decimal places (default: 2) */\n decimals?: number;\n /** Threshold for compact formatting (default: 1000) */\n compactThreshold?: number;\n /** Never use compact formatting (for precise displays) */\n precise?: boolean;\n}\n\n/**\n * Format numbers with optional compact notation (k, m, b)\n * Components handle their own prefixes/suffixes ($ or %)\n *\n * @param value - The number to format (or 'loading' state)\n * @param options - Formatting options\n * @returns Formatted number string (no prefixes/suffixes)\n *\n * @example\n * formatNumber(1234) // \"1.2k\"\n * formatNumber(1234, { precise: true }) // \"1,234.00\"\n * formatNumber(1234, { decimals: 0 }) // \"1k\"\n * formatNumber(999) // \"999.00\"\n */\nexport const formatNumber = (\n value: number | string | 'loading',\n options: FormatNumberOptions = {},\n): string => {\n const { decimals = 2, compactThreshold = 1000, precise = false } = options;\n\n if (value === 'loading') {\n return '';\n }\n\n const num = typeof value === 'string' ? parseFloat(value) : value;\n if (isNaN(num)) {\n return 'N/A';\n }\n\n const abs = Math.abs(num);\n\n // Use compact notation if above threshold and not precise\n if (!precise && abs >= compactThreshold) {\n const sign = num < 0 ? '-' : '';\n const absNum = Math.abs(num);\n // Always use 1 decimal place for compact notation for consistency\n if (absNum >= 1000000000) {\n return `${sign}${(absNum / 1000000000).toFixed(1)}b`;\n } else if (absNum >= 1000000) {\n return `${sign}${(absNum / 1000000).toFixed(1)}m`;\n } else if (absNum >= 1000) {\n return `${sign}${(absNum / 1000).toFixed(1)}k`;\n }\n }\n\n // Standard formatting with specified decimal places\n return num.toLocaleString('en-US', {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n });\n};\n","/**\n * Shared utility functions for handling comparison calculations across components\n */\n\nimport { formatNumber } from './formatters';\n\nexport interface ComparisonResult {\n hasComparison: boolean;\n direction: 'up' | 'down' | 'neutral';\n percentageChange: number;\n percentageLabel: string;\n}\n\n/**\n * Calculate comparison metrics between a current value and a baseline value\n * @param current - The current value to compare\n * @param baseline - The baseline value to compare against (optional)\n * @returns ComparisonResult object with calculated metrics\n */\nexport const calculateComparison = (\n current: number | undefined | null,\n baseline: number | undefined | null,\n): ComparisonResult => {\n // If either value is missing, null, undefined, or baseline is 0, return neutral state\n if (\n current === undefined ||\n current === null ||\n baseline === undefined ||\n baseline === null ||\n baseline === 0\n ) {\n return {\n hasComparison: false,\n direction: 'neutral',\n percentageChange: 0,\n percentageLabel: '',\n };\n }\n\n // If values are equal, return neutral state\n if (current === baseline) {\n return {\n hasComparison: true,\n direction: 'neutral',\n percentageChange: 0,\n percentageLabel: '0%',\n };\n }\n\n // Calculate percentage change\n const percentageChange = Math.abs(((current - baseline) / baseline) * 100);\n const direction = current > baseline ? 'up' : 'down';\n\n return {\n hasComparison: true,\n direction,\n percentageChange,\n percentageLabel: `${formatNumber(percentageChange, {\n compactThreshold: 10000,\n decimals: 2,\n })}%`,\n };\n};\n","import { css } from '@emotion/css';\nimport { getDesignTokens } from '@grafana/design-tokens';\n\nexport const getStyles = () => {\n const {\n legacy,\n primitives: { spacing, typography },\n } = getDesignTokens({ valueType: 'css' });\n const backgroundColor = legacy.colors.background.primary;\n\n return {\n arrow: css({\n fill: backgroundColor,\n }),\n shadow: css({\n filter: `drop-shadow(${legacy.boxShadows.z2})`,\n }),\n container: css({\n backgroundColor,\n borderRadius: `calc(${legacy.borderRadius.md} + ${spacing.xs})`,\n padding: spacing.xs,\n color: legacy.colors.text.primary,\n fontFamily: typography.fontFamily.ui,\n fontSize: typography.fontSize.ui.sm,\n fontWeight: typography.fontWeight.medium,\n }),\n };\n};\n","import { forwardRef, cloneElement, useCallback, useId, useRef, useState, JSX } from 'react';\nimport {\n arrow,\n autoUpdate,\n flip,\n FloatingArrow,\n offset,\n Placement,\n safePolygon,\n shift,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useTransitionStyles,\n} from '@floating-ui/react';\nimport { Portal } from '@grafana/ui';\nimport { getStyles } from './Popover.styles';\n\nexport interface PopoverProps {\n /**\n * Content used to trigger the Popover being displayed\n */\n trigger: JSX.Element;\n\n /**\n * Content to render within the Popover\n */\n children: JSX.Element;\n /**\n * Should the popover be open? Implicitly means the popover visibility is\n * controlled; if omitted, the popover target will control visibility\n */\n isOpen?: boolean;\n\n /**\n * Set to true if you want the tooltip to stay long enough so the user can\n * move mouse over content to select text or click a link\n */\n isInteractive?: boolean;\n\n /**\n * Placement of the Popover relative to the trigger content\n */\n placement?: Placement;\n\n /**\n * Transition duration for hide/show effects, in milliseconds\n */\n transitionDuration?: number;\n\n /**\n * Additional delay before hiding the popover after mouseout, in milliseconds\n */\n hideDelay?: number;\n}\n\nconst POPOVER_OFFSET = 8;\n\nconst getMiddleware = ({\n placement,\n arrowRef,\n}: {\n placement?: Placement;\n arrowRef: React.RefObject<null>;\n}) => {\n const BOUNDARY_ELEMENT_ID = 'floating-boundary';\n const _flip = flip({\n // Ensure we flip to the perpendicular axis if it doesn't fit\n // on narrow viewports.\n crossAxis: 'alignment',\n fallbackAxisSideDirection: 'end',\n boundary: document.getElementById(BOUNDARY_ELEMENT_ID) ?? undefined,\n });\n\n const middleware = placement?.includes('-') ? [_flip, shift()] : [shift(), _flip];\n\n // the order of middleware is important!\n // `arrow` should almost always be at the end\n // see https://floating-ui.com/docs/arrow#order\n return [\n offset(POPOVER_OFFSET),\n ...middleware,\n arrow({\n element: arrowRef,\n }),\n ];\n};\n\nexport const Popover = forwardRef<HTMLElement, PopoverProps>(\n (\n {\n trigger,\n children,\n isOpen: isOpenControlled,\n isInteractive = false,\n placement = 'bottom',\n transitionDuration = 200,\n hideDelay = 500,\n },\n forwardedRef,\n ) => {\n const arrowRef = useRef(null);\n const closeTimer = useRef<number | undefined>(undefined);\n const popoverId = useId();\n const [isOpenState, setOpen] = useState(isOpenControlled);\n const [isDelayedOpen, setDelayedOpen] = useState(isOpenControlled);\n const isOpen = isOpenControlled ?? isOpenState;\n const middleware = getMiddleware({ placement, arrowRef });\n const styles = getStyles();\n\n const { context, refs, floatingStyles } = useFloating({\n open: isOpen,\n placement,\n onOpenChange: (open) => {\n setOpen(open);\n clearTimeout(closeTimer.current);\n\n if (!open) {\n closeTimer.current = setTimeout(() => {\n setDelayedOpen(open);\n }, transitionDuration + hideDelay);\n } else {\n setDelayedOpen(open);\n }\n },\n middleware,\n whileElementsMounted: autoUpdate,\n });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useDismiss(context),\n useHover(context, {\n handleClose: isInteractive ? safePolygon() : undefined,\n move: false,\n delay: {\n open: 0,\n close: hideDelay,\n },\n }),\n useFocus(context),\n ]);\n\n const { styles: transitionStyles } = useTransitionStyles(context, {\n duration: transitionDuration,\n initial: ({ side }) => ({\n opacity: 0,\n transform:\n side === 'top' || side === 'bottom'\n ? `translateY(${POPOVER_OFFSET}px)`\n : `translateX(${POPOVER_OFFSET}px)`,\n }),\n open: ({ side }) => ({\n opacity: 1,\n transform: side === 'top' || side === 'bottom' ? `translateY(0)` : `translateX(0)`,\n }),\n close: ({ side }) => ({\n opacity: 0,\n transform:\n side === 'top' || side === 'bottom'\n ? `translateY(${POPOVER_OFFSET}px)`\n : `translateX(${POPOVER_OFFSET}px)`,\n }),\n });\n\n const handleRef = useCallback(\n (ref: HTMLElement | null) => {\n refs.setReference(ref);\n\n if (typeof forwardedRef === 'function') {\n forwardedRef(ref);\n } else if (forwardedRef) {\n forwardedRef.current = ref;\n }\n },\n [forwardedRef, refs],\n );\n\n return (\n <>\n {/* element to trigger displaying the popover */}\n {cloneElement(trigger, {\n ref: handleRef,\n tabIndex: 0,\n 'aria-describedby': isOpen ? popoverId : undefined,\n ...getReferenceProps(),\n })}\n {/* content to render inside the popover when open */}\n {(isDelayedOpen || isOpen) && (\n <Portal>\n <div ref={refs.setFloating} style={floatingStyles} {...getFloatingProps()}>\n <div style={transitionStyles} className={styles.shadow}>\n <FloatingArrow className={styles.arrow} ref={arrowRef} context={context} />\n <div id={popoverId} role=\"tooltip\" className={styles.container}>\n {children}\n </div>\n </div>\n </div>\n </Portal>\n )}\n </>\n );\n },\n);\n\nPopover.displayName = 'Popover';\n","import { css } from '@emotion/css';\nimport { getDesignTokens } from '@grafana/design-tokens';\n\nexport const getStyles = () => {\n const {\n legacy,\n primitives: { spacing, typography },\n } = getDesignTokens({ valueType: 'css' });\n\n return {\n wrapper: css({\n display: 'flex',\n flexDirection: 'column',\n gap: spacing.xs,\n }),\n heading: css({\n padding: `${spacing.sm} ${spacing.md}`,\n fontFamily: typography.fontFamily.ui,\n fontSize: typography.fontSize.ui.sm,\n fontWeight: typography.fontWeight.bold,\n color: legacy.colors.text.primary,\n background: legacy.colors.background.secondary,\n borderRadius: legacy.borderRadius.md,\n }),\n content: css({\n display: 'flex',\n gap: spacing.xs,\n }),\n section: css({\n display: 'flex',\n flex: 1,\n flexDirection: 'column',\n justifyContent: 'flex-end',\n gap: spacing.xs,\n background: legacy.colors.background.secondary,\n borderRadius: legacy.borderRadius.md,\n padding: `${spacing.sm} ${spacing.md}`,\n minWidth: `80px`,\n }),\n sectionTitle: css({\n fontFamily: typography.fontFamily.ui,\n fontSize: typography.fontSize.ui.sm,\n fontWeight: typography.fontWeight.medium,\n color: legacy.colors.text.primary,\n whiteSpace: 'nowrap',\n }),\n value: css({\n display: 'flex',\n alignItems: 'center',\n gap: spacing.xs,\n fontFamily: typography.fontFamily.monospace,\n fontSize: typography.fontSize.monospace.sm,\n color: legacy.colors.text.secondary,\n }),\n icon: css({\n flexShrink: 0,\n }),\n };\n};\n","import { Icon, IconName } from '@grafana/ui';\nimport { Popover, PopoverProps } from '../Popover';\nimport { getStyles } from './ComparisonTooltip.styles';\n\nexport interface ComparisonTooltipProps extends Omit<PopoverProps, 'children'> {\n current?: string;\n previous?: string;\n previousLabel?: string;\n currentLabel?: string;\n title?: string;\n currentIcon?: IconName;\n previousIcon?: IconName;\n hideDelay?: number;\n}\n\nexport const ComparisonTooltip = ({\n trigger,\n placement = 'top',\n current,\n previous,\n previousLabel,\n currentLabel = 'Current',\n title,\n currentIcon = 'eye',\n previousIcon = 'clock-nine',\n hideDelay,\n}: ComparisonTooltipProps) => {\n const styles = getStyles();\n\n return (\n <Popover trigger={trigger} placement={placement} hideDelay={hideDelay}>\n <div className={styles.wrapper}>\n {title && <div className={styles.heading}>{title}</div>}\n <div className={styles.content}>\n <div className={styles.section}>\n <div className={styles.sectionTitle}>{currentLabel}</div>\n <div className={styles.value}>\n <Icon name={currentIcon} size=\"sm\" className={styles.icon} />\n <span>{current || 'N/A'}</span>\n </div>\n </div>\n <div className={styles.section}>\n <div className={styles.sectionTitle}>{previousLabel}</div>\n <div className={styles.value}>\n <Icon name={previousIcon} size=\"sm\" className={styles.icon} />\n <span>{previous || 'N/A'}</span>\n </div>\n </div>\n </div>\n </div>\n </Popover>\n );\n};\n","import { css } from '@emotion/css';\nimport { CSSVariables, getDesignTokens } from '@grafana/design-tokens';\n\nexport const cssVariables = (): CSSVariables => {\n const { legacy } = getDesignTokens({ valueType: 'css' });\n\n return {\n dark: {\n 'comparison-badge-icon-background-color': legacy.colors.background.secondary,\n 'comparison-badge-icon-highlight-background-color': legacy.palette.whiteBaseOpacity10,\n },\n light: {\n 'comparison-badge-icon-background-color': legacy.colors.background.canvas,\n 'comparison-badge-icon-highlight-background-color': legacy.palette.blackBaseOpacity8,\n },\n };\n};\n\nconst BADGE_HEIGHT = 28;\nconst TREND_ICON_SIZE = 20;\n\nexport const getComparisonBadgeStyles = ({\n highlight,\n direction,\n tooltip,\n}: {\n highlight: boolean;\n direction: string;\n tooltip?: boolean;\n}) => {\n const {\n legacy,\n primitives: { spacing, typography },\n } = getDesignTokens({ valueType: 'css' });\n\n const labelColor = (() => {\n switch (true) {\n case highlight:\n case direction === 'up':\n return legacy.colors.text.maxContrast;\n default:\n return legacy.colors.primary.text;\n }\n })();\n\n return {\n container: css({\n boxSizing: 'border-box',\n background: 'transparent',\n borderRadius: legacy.borderRadius.pill,\n border: `1px solid\n ${highlight ? legacy.colors.border.strong : legacy.colors.border.weak}`,\n padding: `${spacing.xxs} ${spacing.sm} ${spacing.xxs} ${spacing.xxs}`,\n textAlign: 'left',\n display: 'inline-flex',\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n fontFamily: typography.fontFamily.ui,\n fontSize: typography.fontSize.ui.sm,\n height: `${BADGE_HEIGHT}px`,\n position: 'relative',\n transition: 'background 0.2s ease-in-out',\n ...(tooltip\n ? {\n cursor: 'pointer',\n '&:hover': {\n background: legacy.colors.background.secondary,\n },\n }\n : {}),\n }),\n clockIconWrapper: css({\n background: highlight\n ? 'var(--comparison-badge-icon-highlight-background-color)'\n : 'var(--comparison-badge-icon-background-color)',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '22px',\n height: '22px',\n borderRadius: legacy.borderRadius.pill,\n color: legacy.colors.text.primary,\n }),\n trendLabelContainer: css({\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n gap: spacing.xxs,\n paddingLeft: spacing.xxs,\n fontWeight: typography.fontWeight.medium,\n }),\n trendLabel: css({\n display: 'flex',\n alignItems: 'center',\n color: labelColor,\n lineHeight: `${BADGE_HEIGHT}px`,\n fontWeight: typography.fontWeight.medium,\n fontVariantNumeric: 'tabular-nums',\n }),\n timeframeLabel: css({\n color: highlight ? legacy.colors.text.maxContrast : legacy.colors.text.primary,\n paddingLeft: spacing.xxs,\n lineHeight: `${BADGE_HEIGHT}px`,\n fontWeight: typography.fontWeight.normal,\n }),\n trendIconWrapper: css({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: '16px',\n height: '16px',\n }),\n trendIcon: css({\n width: `${TREND_ICON_SIZE}px`,\n height: `${TREND_ICON_SIZE}px`,\n }),\n dash: css({\n color: legacy.colors.text.secondary,\n }),\n };\n};\n","import { cx } from '@emotion/css';\nimport { GlobalCSSVariables } from '@grafana/design-tokens';\nimport { Icon, IconName } from '@grafana/ui';\nimport { calculateComparison } from '../../utils/comparison';\nimport { formatNumber } from '../../utils/formatters';\nimport { ComparisonTooltipProps, ComparisonTooltip } from '../ComparisonTooltip';\nimport { cssVariables, getComparisonBadgeStyles } from './ComparisonBadge.styles';\n\nconst formatCurrency = (value: number | undefined | null): string => {\n return !!value ? `$${formatNumber(value, { precise: true })}` : 'N/A';\n};\n\nexport interface ComparisonBadgeProps\n extends Pick<ComparisonTooltipProps, 'currentLabel' | 'previousLabel' | 'placement'> {\n current?: number | null;\n previous?: number | null;\n highlight?: boolean;\n timeframeLabel?: string;\n tooltip?: boolean;\n}\n\nconst DIRECTION_ICON: Record<'up' | 'down' | 'neutral', IconName> = {\n up: 'arrow-up',\n down: 'arrow-down',\n neutral: 'minus',\n};\n\nexport const ComparisonBadge = ({\n current,\n previous,\n currentLabel,\n previousLabel,\n placement,\n highlight = false,\n timeframeLabel,\n tooltip = true,\n}: ComparisonBadgeProps) => {\n const { direction, hasComparison, percentageLabel } = calculateComparison(current, previous);\n const styles = getComparisonBadgeStyles({ highlight, direction, tooltip });\n\n const directionIconStyle = (() => {\n switch (true) {\n case direction == 'neutral':\n return styles.dash;\n default:\n return undefined;\n }\n })();\n\n const badgeContent = (\n <div className={styles.container}>\n <div className={styles.clockIconWrapper}>\n <Icon name=\"clock-nine\" />\n </div>\n <div className={styles.trendLabelContainer}>\n <span className={styles.trendLabel}>\n <span className={styles.trendIconWrapper}>\n <Icon\n name={DIRECTION_ICON[direction]}\n className={cx(styles.trendIcon, directionIconStyle)}\n />\n </span>\n {hasComparison && percentageLabel && <>{percentageLabel}</>}\n </span>\n {timeframeLabel && (\n <span className={styles.timeframeLabel}>vs {timeframeLabel.toLowerCase()}</span>\n )}\n </div>\n </div>\n );\n\n return (\n <>\n <GlobalCSSVariables variables={cssVariables()} defaultColorMode={null} />\n {tooltip ? (\n <ComparisonTooltip\n trigger={badgeContent}\n current={formatCurrency(current)}\n previous={formatCurrency(previous)}\n currentLabel={currentLabel}\n previousLabel={previousLabel}\n placement={placement}\n />\n ) : (\n badgeContent\n )}\n </>\n );\n};\n"],"names":["createContext","useState","useEffect","jsx","useContext","ThemeChangedEvent","isLight","newColorMode","getStyles","getDesignTokens","css","flip","shift","offset","arrow","forwardRef","useRef","useId","useFloating","autoUpdate","useInteractions","useDismiss","useHover","safePolygon","useFocus","useTransitionStyles","useCallback","jsxs","Fragment","cloneElement","Portal","FloatingArrow","Icon","cx","GlobalCS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AA,cAAA;AAAA,UAAC6B,OAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAM,eAAe,SAAS,CAAA;AAAA,YAC9B,SAAA,EAAWC,MAAA,CAAG,MAAA,CAAO,SAAA,EAAW,kBAAkB;AAAA;AAAA,SACpD,EACF,CAAA;AAAA,QACC,aAAA,IAAiB,eAAA,oBAAmB9B,cAAA,CAAAyB,mBAAA,EAAA,EAAG,QAAA,EAAA,eAAA,EAAgB;AAAA,OAAA,EAC1D,CAAA;AAAA,MACC,cAAA,oBACCD,eAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAW,OAAO,cAAA,EAAgB,QAAA,EAAA;AAAA,QAAA,KAAA;AAAA,QAAI,eAAe,WAAA;AAAY,OAAA,EAAE;AAAA,KAAA,EAE7E;AAAA,GAAA,EACF,CAAA;AAGF,EAAA,uBACEA,eAAA,CAAAC,mBAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAAzB,cAAA,CAAC+B,+BAAA,EAAA,EAAmB,SAAA,EAAW,YAAA,EAAa,EAAG,kBAAkB,IAAA,EAAM,CAAA;AAAA,IACtE,OAAA,mBACC/B,cAAA;AAAA,MAAC,iBAAA;AAAA,MAAA;AAAA,QACC,OAAA,EAAS,YAAA;AAAA,QACT,OAAA,EAAS,eAAe,OAAO,CAAA;AAAA,QAC/B,QAAA,EAAU,eAAe,QAAQ,CAAA;AAAA,QACjC,YAAA;AAAA,QACA,aAAA;AAAA,QACA;AAAA;AAAA,KACF,GAEA;AAAA,GAAA,EAEJ,CAAA;AAEJ;;;;;;;;;;;;;"}
@@ -1,10 +1,29 @@
1
- import * as react from 'react';
2
- import react__default, { ReactNode, JSX } from 'react';
1
+ import * as React from 'react';
2
+ import React__default, { ReactNode, JSX } from 'react';
3
+ import { EventBus, GrafanaTheme2 } from '@grafana/data';
3
4
  import { ThemeColorMode } from '@grafana/design-tokens';
4
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
6
  import { IconName } from '@grafana/ui';
6
7
  import { Placement } from '@floating-ui/react';
7
- import { EventBus, GrafanaTheme2 } from '@grafana/data';
8
+
9
+ interface ColorModeChangeProps {
10
+ getAppEvents: () => EventBus;
11
+ useTheme2: () => GrafanaTheme2;
12
+ }
13
+ /**
14
+ * This allows us to register an event listener for when the ThemeChangedEvent
15
+ * is fired, and update the currently active color mode accordingly. It will
16
+ * also determine the color mode on initial registration, and update the context
17
+ * provider accordingly.
18
+ */
19
+ declare const useColorModeChange: ({ getAppEvents, useTheme2 }: ColorModeChangeProps) => void;
20
+
21
+ type ColorModeWrapper = React__default.FC<ColorModeChangeProps & {
22
+ children: React__default.ReactNode;
23
+ }>;
24
+ declare const ColorModeChangeHandler: ColorModeWrapper;
25
+
26
+ declare const ColorMode: ColorModeWrapper;
8
27
 
9
28
  interface ColorModeContextType {
10
29
  colorMode: ThemeColorMode;
@@ -18,7 +37,7 @@ interface ColorModeProviderProps {
18
37
  * Provides a shared context for the currently-active theme color mode, and sets
19
38
  * the data-color-mode attribute on the document element whenever it changes.
20
39
  */
21
- declare const ColorModeProvider: react__default.FC<ColorModeProviderProps>;
40
+ declare const ColorModeProvider: React__default.FC<ColorModeProviderProps>;
22
41
  /**
23
42
  * Use this to query the active color mode, or to set it, e.g. with an effect
24
43
  * hook within a component which explicitly changes the active color mode:
@@ -62,7 +81,7 @@ interface PopoverProps {
62
81
  */
63
82
  hideDelay?: number;
64
83
  }
65
- declare const Popover: react.ForwardRefExoticComponent<PopoverProps & react.RefAttributes<HTMLElement>>;
84
+ declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<HTMLElement>>;
66
85
 
67
86
  interface ComparisonTooltipProps extends Omit<PopoverProps, 'children'> {
68
87
  current?: string;
@@ -85,17 +104,6 @@ interface ComparisonBadgeProps extends Pick<ComparisonTooltipProps, 'currentLabe
85
104
  }
86
105
  declare const ComparisonBadge: ({ current, previous, currentLabel, previousLabel, placement, highlight, timeframeLabel, tooltip, }: ComparisonBadgeProps) => react_jsx_runtime.JSX.Element;
87
106
 
88
- /**
89
- * This allows us to register an event listener for when the ThemeChangedEvent
90
- * is fired, and update the currently active color mode accordingly. It will
91
- * also determine the color mode on initial registration, and update the context
92
- * provider accordingly.
93
- */
94
- declare const useColorModeChange: ({ getAppEvents, useTheme2, }: {
95
- getAppEvents: () => EventBus;
96
- useTheme2: () => GrafanaTheme2;
97
- }) => void;
98
-
99
107
  /**
100
108
  * Shared utility functions for handling comparison calculations across components
101
109
  */
@@ -140,5 +148,5 @@ interface FormatNumberOptions {
140
148
  */
141
149
  declare const formatNumber: (value: number | string | "loading", options?: FormatNumberOptions) => string;
142
150
 
143
- export { ColorModeProvider, ComparisonBadge, ComparisonTooltip, Popover, calculateComparison, formatNumber, useColorMode, useColorModeChange };
144
- export type { ColorModeContextType, ColorModeProviderProps, ComparisonResult, ComparisonTooltipProps, FormatNumberOptions, PopoverProps };
151
+ export { ColorMode, ColorModeChangeHandler, ColorModeProvider, ComparisonBadge, ComparisonTooltip, Popover, calculateComparison, formatNumber, useColorMode, useColorModeChange };
152
+ export type { ColorModeChangeProps, ColorModeContextType, ColorModeProviderProps, ColorModeWrapper, ComparisonResult, ComparisonTooltipProps, FormatNumberOptions, PopoverProps };
@@ -0,0 +1,10 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { ColorModeChangeHandler } from '../ColorModeChangeHandler/ColorModeChangeHandler.js';
3
+ import { ColorModeProvider } from '../ColorModeProvider/ColorModeProvider.js';
4
+
5
+ const ColorMode = ({ children, getAppEvents, useTheme2 }) => {
6
+ return /* @__PURE__ */ jsx(ColorModeProvider, { children: /* @__PURE__ */ jsx(ColorModeChangeHandler, { getAppEvents, useTheme2, children }) });
7
+ };
8
+
9
+ export { ColorMode };
10
+ //# sourceMappingURL=ColorMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorMode.js","sources":["../../../../src/components/ColorMode/ColorMode.tsx"],"sourcesContent":["import { ColorModeWrapper, ColorModeChangeHandler } from '../ColorModeChangeHandler';\nimport { ColorModeProvider } from '../ColorModeProvider';\n\nexport const ColorMode: ColorModeWrapper = ({ children, getAppEvents, useTheme2 }) => {\n return (\n <ColorModeProvider>\n <ColorModeChangeHandler getAppEvents={getAppEvents} useTheme2={useTheme2}>\n {children}\n </ColorModeChangeHandler>\n </ColorModeProvider>\n );\n};\n"],"names":[],"mappings":";;;;AAGO,MAAM,YAA8B,CAAC,EAAE,QAAA,EAAU,YAAA,EAAc,WAAU,KAAM;AACpF,EAAA,2BACG,iBAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,0BAAuB,YAAA,EAA4B,SAAA,EACjD,UACH,CAAA,EACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,9 @@
1
+ import { useColorModeChange } from '../../hooks/useColorModeChange.js';
2
+
3
+ const ColorModeChangeHandler = ({ children, getAppEvents, useTheme2 }) => {
4
+ useColorModeChange({ getAppEvents, useTheme2 });
5
+ return children;
6
+ };
7
+
8
+ export { ColorModeChangeHandler };
9
+ //# sourceMappingURL=ColorModeChangeHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorModeChangeHandler.js","sources":["../../../../src/components/ColorModeChangeHandler/ColorModeChangeHandler.tsx"],"sourcesContent":["import React from 'react';\nimport { useColorModeChange, ColorModeChangeProps } from '../../hooks';\n\nexport type ColorModeWrapper = React.FC<ColorModeChangeProps & { children: React.ReactNode }>;\n\nexport const ColorModeChangeHandler: ColorModeWrapper = ({ children, getAppEvents, useTheme2 }) => {\n useColorModeChange({ getAppEvents, useTheme2 });\n\n return children;\n};\n"],"names":[],"mappings":";;AAKO,MAAM,yBAA2C,CAAC,EAAE,QAAA,EAAU,YAAA,EAAc,WAAU,KAAM;AACjG,EAAA,kBAAA,CAAmB,EAAE,YAAA,EAAc,SAAA,EAAW,CAAA;AAE9C,EAAA,OAAO,QAAA;AACT;;;;"}
@@ -4,10 +4,7 @@ import { useColorMode } from '../components/ColorModeProvider/ColorModeProvider.
4
4
  const getThemeColorMode = (isLight) => {
5
5
  return isLight ? "light" : "dark";
6
6
  };
7
- const useColorModeChange = ({
8
- getAppEvents,
9
- useTheme2
10
- }) => {
7
+ const useColorModeChange = ({ getAppEvents, useTheme2 }) => {
11
8
  const { setColorMode } = useColorMode();
12
9
  const appEvents = getAppEvents();
13
10
  appEvents.subscribe(ThemeChangedEvent, ({ payload }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useColorModeChange.js","sources":["../../../src/hooks/useColorModeChange.ts"],"sourcesContent":["import type { EventBus, GrafanaTheme2 } from '@grafana/data';\nimport { ThemeChangedEvent } from '@grafana/runtime';\nimport type { ThemeColorMode } from '@grafana/design-tokens';\nimport { useColorMode } from '../components/ColorModeProvider/ColorModeProvider';\n\nconst getThemeColorMode = (isLight: boolean): ThemeColorMode => {\n return isLight ? 'light' : 'dark';\n};\n\n/**\n * This allows us to register an event listener for when the ThemeChangedEvent\n * is fired, and update the currently active color mode accordingly. It will\n * also determine the color mode on initial registration, and update the context\n * provider accordingly.\n */\nexport const useColorModeChange = ({\n getAppEvents,\n useTheme2,\n}: {\n getAppEvents: () => EventBus;\n useTheme2: () => GrafanaTheme2;\n}) => {\n const { setColorMode } = useColorMode();\n const appEvents = getAppEvents();\n\n appEvents.subscribe<ThemeChangedEvent>(ThemeChangedEvent, ({ payload }) => {\n const { isLight } = payload;\n const newColorMode = getThemeColorMode(isLight);\n\n console.log('ThemeChangedEvent', { colorMode: newColorMode });\n setColorMode(newColorMode);\n });\n\n /**\n * Longterm the current colorMode should ideally exist outside of useTheme2\n */\n const { isLight } = useTheme2();\n const newColorMode = getThemeColorMode(isLight);\n setColorMode(newColorMode);\n};\n"],"names":["isLight","newColorMode"],"mappings":";;;AAKA,MAAM,iBAAA,GAAoB,CAAC,OAAA,KAAqC;AAC9D,EAAA,OAAO,UAAU,OAAA,GAAU,MAAA;AAC7B,CAAA;AAQO,MAAM,qBAAqB,CAAC;AAAA,EACjC,YAAA;AAAA,EACA;AACF,CAAA,KAGM;AACJ,EAAA,MAAM,EAAE,YAAA,EAAa,GAAI,YAAA,EAAa;AACtC,EAAA,MAAM,YAAY,YAAA,EAAa;AAE/B,EAAA,SAAA,CAAU,SAAA,CAA6B,iBAAA,EAAmB,CAAC,EAAE,SAAQ,KAAM;AACzE,IAAA,MAAM,EAAE,OAAA,EAAAA,QAAAA,EAAQ,GAAI,OAAA;AACpB,IAAA,MAAMC,aAAAA,GAAe,kBAAkBD,QAAO,CAAA;AAE9C,IAAA,OAAA,CAAQ,GAAA,CAAI,mBAAA,EAAqB,EAAE,SAAA,EAAWC,eAAc,CAAA;AAC5D,IAAA,YAAA,CAAaA,aAAY,CAAA;AAAA,EAC3B,CAAC,CAAA;AAKD,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,SAAA,EAAU;AAC9B,EAAA,MAAM,YAAA,GAAe,kBAAkB,OAAO,CAAA;AAC9C,EAAA,YAAA,CAAa,YAAY,CAAA;AAC3B;;;;"}
1
+ {"version":3,"file":"useColorModeChange.js","sources":["../../../src/hooks/useColorModeChange.ts"],"sourcesContent":["import type { EventBus, GrafanaTheme2 } from '@grafana/data';\nimport { ThemeChangedEvent } from '@grafana/runtime';\nimport type { ThemeColorMode } from '@grafana/design-tokens';\nimport { useColorMode } from '../components/ColorModeProvider/ColorModeProvider';\n\nconst getThemeColorMode = (isLight: boolean): ThemeColorMode => {\n return isLight ? 'light' : 'dark';\n};\n\nexport interface ColorModeChangeProps {\n getAppEvents: () => EventBus;\n useTheme2: () => GrafanaTheme2;\n}\n\n/**\n * This allows us to register an event listener for when the ThemeChangedEvent\n * is fired, and update the currently active color mode accordingly. It will\n * also determine the color mode on initial registration, and update the context\n * provider accordingly.\n */\nexport const useColorModeChange = ({ getAppEvents, useTheme2 }: ColorModeChangeProps) => {\n const { setColorMode } = useColorMode();\n const appEvents = getAppEvents();\n\n appEvents.subscribe<ThemeChangedEvent>(ThemeChangedEvent, ({ payload }) => {\n const { isLight } = payload;\n const newColorMode = getThemeColorMode(isLight);\n\n console.log('ThemeChangedEvent', { colorMode: newColorMode });\n setColorMode(newColorMode);\n });\n\n /**\n * Longterm the current colorMode should ideally exist outside of useTheme2\n */\n const { isLight } = useTheme2();\n const newColorMode = getThemeColorMode(isLight);\n setColorMode(newColorMode);\n};\n"],"names":["isLight","newColorMode"],"mappings":";;;AAKA,MAAM,iBAAA,GAAoB,CAAC,OAAA,KAAqC;AAC9D,EAAA,OAAO,UAAU,OAAA,GAAU,MAAA;AAC7B,CAAA;AAaO,MAAM,kBAAA,GAAqB,CAAC,EAAE,YAAA,EAAc,WAAU,KAA4B;AACvF,EAAA,MAAM,EAAE,YAAA,EAAa,GAAI,YAAA,EAAa;AACtC,EAAA,MAAM,YAAY,YAAA,EAAa;AAE/B,EAAA,SAAA,CAAU,SAAA,CAA6B,iBAAA,EAAmB,CAAC,EAAE,SAAQ,KAAM;AACzE,IAAA,MAAM,EAAE,OAAA,EAAAA,QAAAA,EAAQ,GAAI,OAAA;AACpB,IAAA,MAAMC,aAAAA,GAAe,kBAAkBD,QAAO,CAAA;AAE9C,IAAA,OAAA,CAAQ,GAAA,CAAI,mBAAA,EAAqB,EAAE,SAAA,EAAWC,eAAc,CAAA;AAC5D,IAAA,YAAA,CAAaA,aAAY,CAAA;AAAA,EAC3B,CAAC,CAAA;AAKD,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,SAAA,EAAU;AAC9B,EAAA,MAAM,YAAA,GAAe,kBAAkB,OAAO,CAAA;AAC9C,EAAA,YAAA,CAAa,YAAY,CAAA;AAC3B;;;;"}
@@ -1,10 +1,29 @@
1
- import * as react from 'react';
2
- import react__default, { ReactNode, JSX } from 'react';
1
+ import * as React from 'react';
2
+ import React__default, { ReactNode, JSX } from 'react';
3
+ import { EventBus, GrafanaTheme2 } from '@grafana/data';
3
4
  import { ThemeColorMode } from '@grafana/design-tokens';
4
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
6
  import { IconName } from '@grafana/ui';
6
7
  import { Placement } from '@floating-ui/react';
7
- import { EventBus, GrafanaTheme2 } from '@grafana/data';
8
+
9
+ interface ColorModeChangeProps {
10
+ getAppEvents: () => EventBus;
11
+ useTheme2: () => GrafanaTheme2;
12
+ }
13
+ /**
14
+ * This allows us to register an event listener for when the ThemeChangedEvent
15
+ * is fired, and update the currently active color mode accordingly. It will
16
+ * also determine the color mode on initial registration, and update the context
17
+ * provider accordingly.
18
+ */
19
+ declare const useColorModeChange: ({ getAppEvents, useTheme2 }: ColorModeChangeProps) => void;
20
+
21
+ type ColorModeWrapper = React__default.FC<ColorModeChangeProps & {
22
+ children: React__default.ReactNode;
23
+ }>;
24
+ declare const ColorModeChangeHandler: ColorModeWrapper;
25
+
26
+ declare const ColorMode: ColorModeWrapper;
8
27
 
9
28
  interface ColorModeContextType {
10
29
  colorMode: ThemeColorMode;
@@ -18,7 +37,7 @@ interface ColorModeProviderProps {
18
37
  * Provides a shared context for the currently-active theme color mode, and sets
19
38
  * the data-color-mode attribute on the document element whenever it changes.
20
39
  */
21
- declare const ColorModeProvider: react__default.FC<ColorModeProviderProps>;
40
+ declare const ColorModeProvider: React__default.FC<ColorModeProviderProps>;
22
41
  /**
23
42
  * Use this to query the active color mode, or to set it, e.g. with an effect
24
43
  * hook within a component which explicitly changes the active color mode:
@@ -62,7 +81,7 @@ interface PopoverProps {
62
81
  */
63
82
  hideDelay?: number;
64
83
  }
65
- declare const Popover: react.ForwardRefExoticComponent<PopoverProps & react.RefAttributes<HTMLElement>>;
84
+ declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<HTMLElement>>;
66
85
 
67
86
  interface ComparisonTooltipProps extends Omit<PopoverProps, 'children'> {
68
87
  current?: string;
@@ -85,17 +104,6 @@ interface ComparisonBadgeProps extends Pick<ComparisonTooltipProps, 'currentLabe
85
104
  }
86
105
  declare const ComparisonBadge: ({ current, previous, currentLabel, previousLabel, placement, highlight, timeframeLabel, tooltip, }: ComparisonBadgeProps) => react_jsx_runtime.JSX.Element;
87
106
 
88
- /**
89
- * This allows us to register an event listener for when the ThemeChangedEvent
90
- * is fired, and update the currently active color mode accordingly. It will
91
- * also determine the color mode on initial registration, and update the context
92
- * provider accordingly.
93
- */
94
- declare const useColorModeChange: ({ getAppEvents, useTheme2, }: {
95
- getAppEvents: () => EventBus;
96
- useTheme2: () => GrafanaTheme2;
97
- }) => void;
98
-
99
107
  /**
100
108
  * Shared utility functions for handling comparison calculations across components
101
109
  */
@@ -140,5 +148,5 @@ interface FormatNumberOptions {
140
148
  */
141
149
  declare const formatNumber: (value: number | string | "loading", options?: FormatNumberOptions) => string;
142
150
 
143
- export { ColorModeProvider, ComparisonBadge, ComparisonTooltip, Popover, calculateComparison, formatNumber, useColorMode, useColorModeChange };
144
- export type { ColorModeContextType, ColorModeProviderProps, ComparisonResult, ComparisonTooltipProps, FormatNumberOptions, PopoverProps };
151
+ export { ColorMode, ColorModeChangeHandler, ColorModeProvider, ComparisonBadge, ComparisonTooltip, Popover, calculateComparison, formatNumber, useColorMode, useColorModeChange };
152
+ export type { ColorModeChangeProps, ColorModeContextType, ColorModeProviderProps, ColorModeWrapper, ComparisonResult, ComparisonTooltipProps, FormatNumberOptions, PopoverProps };
package/dist/esm/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ export { ColorMode } from './components/ColorMode/ColorMode.js';
2
+ export { ColorModeChangeHandler } from './components/ColorModeChangeHandler/ColorModeChangeHandler.js';
1
3
  export { ColorModeProvider, useColorMode } from './components/ColorModeProvider/ColorModeProvider.js';
2
4
  export { ComparisonBadge } from './components/ComparisonBadge/ComparisonBadge.js';
3
5
  export { ComparisonTooltip } from './components/ComparisonTooltip/ComparisonTooltip.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Grafana Labs",
3
3
  "name": "@grafana/components",
4
4
  "license": "Apache-2.0",
5
- "version": "0.0.8",
5
+ "version": "0.0.10",
6
6
  "description": "Product Design Engineering Components for Grafana",
7
7
  "repository": {
8
8
  "type": "git",
@@ -65,7 +65,7 @@
65
65
  "@eslint/eslintrc": "^3.3.1",
66
66
  "@eslint/js": "^9.37.0",
67
67
  "@grafana/eslint-config": "^9.0.0",
68
- "@grafana/runtime": "^12.3.0",
68
+ "@grafana/runtime": "^11.5.3",
69
69
  "@grafana/tsconfig": "^2.0.1",
70
70
  "@rollup/plugin-commonjs": "^29",
71
71
  "@rollup/plugin-eslint": "^9.2.0",
@@ -107,9 +107,9 @@
107
107
  "@emotion/css": "^11.13.5",
108
108
  "@emotion/react": "^11.14.0",
109
109
  "@floating-ui/react": "^0.27.16",
110
- "@grafana/data": "^12.3.0",
110
+ "@grafana/data": "^11.5.3",
111
111
  "@grafana/design-tokens": "^0.0.26",
112
- "@grafana/ui": "^12.3.0",
112
+ "@grafana/ui": "^11.5.3",
113
113
  "react-useportal": "^1.0.19"
114
114
  },
115
115
  "peerDependencies": {