@grafana/components 0.0.1
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 +201 -0
- package/README.md +3 -0
- package/dist/cjs/css/components.css +298 -0
- package/dist/cjs/index.cjs +3914 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +132 -0
- package/dist/esm/_virtual/hoist-non-react-statics.cjs.js +4 -0
- package/dist/esm/_virtual/hoist-non-react-statics.cjs.js.map +1 -0
- package/dist/esm/_virtual/index.js +4 -0
- package/dist/esm/_virtual/index.js.map +1 -0
- package/dist/esm/_virtual/react-is.development.js +4 -0
- package/dist/esm/_virtual/react-is.development.js.map +1 -0
- package/dist/esm/_virtual/react-is.production.min.js +4 -0
- package/dist/esm/_virtual/react-is.production.min.js.map +1 -0
- package/dist/esm/components/ColorModeProvider/ColorModeProvider.js +25 -0
- package/dist/esm/components/ColorModeProvider/ColorModeProvider.js.map +1 -0
- package/dist/esm/components/ComparisonBadge/ComparisonBadge.js +74 -0
- package/dist/esm/components/ComparisonBadge/ComparisonBadge.js.map +1 -0
- package/dist/esm/components/ComparisonBadge/ComparisonBadge.styles.js +112 -0
- package/dist/esm/components/ComparisonBadge/ComparisonBadge.styles.js.map +1 -0
- package/dist/esm/components/ComparisonTooltip/ComparisonTooltip.js +41 -0
- package/dist/esm/components/ComparisonTooltip/ComparisonTooltip.js.map +1 -0
- package/dist/esm/components/ComparisonTooltip/ComparisonTooltip.styles.js +61 -0
- package/dist/esm/components/ComparisonTooltip/ComparisonTooltip.styles.js.map +1 -0
- package/dist/esm/components/Popover/Popover.js +120 -0
- package/dist/esm/components/Popover/Popover.js.map +1 -0
- package/dist/esm/components/Popover/Popover.styles.js +30 -0
- package/dist/esm/components/Popover/Popover.styles.js.map +1 -0
- package/dist/esm/css/components.css +298 -0
- package/dist/esm/index.d.ts +132 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/utils/comparison.js +34 -0
- package/dist/esm/utils/comparison.js.map +1 -0
- package/dist/esm/utils/formatters.js +29 -0
- package/dist/esm/utils/formatters.js.map +1 -0
- package/package.json +118 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useRef, useId, useState, useCallback, cloneElement } from 'react';
|
|
3
|
+
import { useFloating, autoUpdate, useInteractions, useDismiss, useHover, useFocus, safePolygon, useTransitionStyles, FloatingArrow, flip, shift, offset, arrow } from '@floating-ui/react';
|
|
4
|
+
import { Portal } from '@grafana/ui';
|
|
5
|
+
import { getStyles } from './Popover.styles.js';
|
|
6
|
+
|
|
7
|
+
const POPOVER_OFFSET = 8;
|
|
8
|
+
const getMiddleware = ({
|
|
9
|
+
placement,
|
|
10
|
+
arrowRef
|
|
11
|
+
}) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const BOUNDARY_ELEMENT_ID = "floating-boundary";
|
|
14
|
+
const _flip = flip({
|
|
15
|
+
// Ensure we flip to the perpendicular axis if it doesn't fit
|
|
16
|
+
// on narrow viewports.
|
|
17
|
+
crossAxis: "alignment",
|
|
18
|
+
fallbackAxisSideDirection: "end",
|
|
19
|
+
boundary: (_a = document.getElementById(BOUNDARY_ELEMENT_ID)) != null ? _a : void 0
|
|
20
|
+
});
|
|
21
|
+
const middleware = (placement == null ? void 0 : placement.includes("-")) ? [_flip, shift()] : [shift(), _flip];
|
|
22
|
+
return [
|
|
23
|
+
offset(POPOVER_OFFSET),
|
|
24
|
+
...middleware,
|
|
25
|
+
arrow({
|
|
26
|
+
element: arrowRef
|
|
27
|
+
})
|
|
28
|
+
];
|
|
29
|
+
};
|
|
30
|
+
const Popover = forwardRef(
|
|
31
|
+
({
|
|
32
|
+
trigger,
|
|
33
|
+
children,
|
|
34
|
+
isOpen: isOpenControlled,
|
|
35
|
+
isInteractive = false,
|
|
36
|
+
placement = "bottom",
|
|
37
|
+
transitionDuration = 200,
|
|
38
|
+
hideDelay = 500
|
|
39
|
+
}, forwardedRef) => {
|
|
40
|
+
const arrowRef = useRef(null);
|
|
41
|
+
const closeTimer = useRef(void 0);
|
|
42
|
+
const popoverId = useId();
|
|
43
|
+
const [isOpenState, setOpen] = useState(isOpenControlled);
|
|
44
|
+
const [isDelayedOpen, setDelayedOpen] = useState(isOpenControlled);
|
|
45
|
+
const isOpen = isOpenControlled != null ? isOpenControlled : isOpenState;
|
|
46
|
+
const middleware = getMiddleware({ placement, arrowRef });
|
|
47
|
+
const styles = getStyles();
|
|
48
|
+
const { context, refs, floatingStyles } = useFloating({
|
|
49
|
+
open: isOpen,
|
|
50
|
+
placement,
|
|
51
|
+
onOpenChange: (open) => {
|
|
52
|
+
setOpen(open);
|
|
53
|
+
clearTimeout(closeTimer.current);
|
|
54
|
+
if (!open) {
|
|
55
|
+
closeTimer.current = setTimeout(() => {
|
|
56
|
+
setDelayedOpen(open);
|
|
57
|
+
}, transitionDuration + hideDelay);
|
|
58
|
+
} else {
|
|
59
|
+
setDelayedOpen(open);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
middleware,
|
|
63
|
+
whileElementsMounted: autoUpdate
|
|
64
|
+
});
|
|
65
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
66
|
+
useDismiss(context),
|
|
67
|
+
useHover(context, {
|
|
68
|
+
handleClose: isInteractive ? safePolygon() : void 0,
|
|
69
|
+
move: false,
|
|
70
|
+
delay: {
|
|
71
|
+
open: 0,
|
|
72
|
+
close: hideDelay
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
useFocus(context)
|
|
76
|
+
]);
|
|
77
|
+
const { styles: transitionStyles } = useTransitionStyles(context, {
|
|
78
|
+
duration: transitionDuration,
|
|
79
|
+
initial: ({ side }) => ({
|
|
80
|
+
opacity: 0,
|
|
81
|
+
transform: side === "top" || side === "bottom" ? `translateY(${POPOVER_OFFSET}px)` : `translateX(${POPOVER_OFFSET}px)`
|
|
82
|
+
}),
|
|
83
|
+
open: ({ side }) => ({
|
|
84
|
+
opacity: 1,
|
|
85
|
+
transform: side === "top" || side === "bottom" ? `translateY(0)` : `translateX(0)`
|
|
86
|
+
}),
|
|
87
|
+
close: ({ side }) => ({
|
|
88
|
+
opacity: 0,
|
|
89
|
+
transform: side === "top" || side === "bottom" ? `translateY(${POPOVER_OFFSET}px)` : `translateX(${POPOVER_OFFSET}px)`
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
const handleRef = useCallback(
|
|
93
|
+
(ref) => {
|
|
94
|
+
refs.setReference(ref);
|
|
95
|
+
if (typeof forwardedRef === "function") {
|
|
96
|
+
forwardedRef(ref);
|
|
97
|
+
} else if (forwardedRef) {
|
|
98
|
+
forwardedRef.current = ref;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
[forwardedRef, refs]
|
|
102
|
+
);
|
|
103
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
104
|
+
cloneElement(trigger, {
|
|
105
|
+
ref: handleRef,
|
|
106
|
+
tabIndex: 0,
|
|
107
|
+
"aria-describedby": isOpen ? popoverId : void 0,
|
|
108
|
+
...getReferenceProps()
|
|
109
|
+
}),
|
|
110
|
+
(isDelayedOpen || isOpen) && /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx("div", { ref: refs.setFloating, style: floatingStyles, ...getFloatingProps(), children: /* @__PURE__ */ jsxs("div", { style: transitionStyles, className: styles.shadow, children: [
|
|
111
|
+
/* @__PURE__ */ jsx(FloatingArrow, { className: styles.arrow, ref: arrowRef, context }),
|
|
112
|
+
/* @__PURE__ */ jsx("div", { id: popoverId, role: "tooltip", className: styles.container, children })
|
|
113
|
+
] }) }) })
|
|
114
|
+
] });
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
Popover.displayName = "Popover";
|
|
118
|
+
|
|
119
|
+
export { Popover };
|
|
120
|
+
//# sourceMappingURL=Popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.js","sources":["../../../../src/components/Popover/Popover.tsx"],"sourcesContent":["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"],"names":[],"mappings":";;;;;;AA0DA,MAAM,cAAA,GAAiB,CAAA;AAEvB,MAAM,gBAAgB,CAAC;AAAA,EACrB,SAAA;AAAA,EACA;AACF,CAAA,KAGM;AAlEN,EAAA,IAAA,EAAA;AAmEE,EAAA,MAAM,mBAAA,GAAsB,mBAAA;AAC5B,EAAA,MAAM,QAAQ,IAAA,CAAK;AAAA;AAAA;AAAA,IAGjB,SAAA,EAAW,WAAA;AAAA,IACX,yBAAA,EAA2B,KAAA;AAAA,IAC3B,QAAA,EAAA,CAAU,EAAA,GAAA,QAAA,CAAS,cAAA,CAAe,mBAAmB,MAA3C,IAAA,GAAA,EAAA,GAAgD;AAAA,GAC3D,CAAA;AAED,EAAA,MAAM,UAAA,GAAA,CAAa,SAAA,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAW,QAAA,CAAS,GAAA,CAAA,IAAO,CAAC,KAAA,EAAO,KAAA,EAAO,CAAA,GAAI,CAAC,KAAA,EAAM,EAAG,KAAK,CAAA;AAKhF,EAAA,OAAO;AAAA,IACL,OAAO,cAAc,CAAA;AAAA,IACrB,GAAG,UAAA;AAAA,IACH,KAAA,CAAM;AAAA,MACJ,OAAA,EAAS;AAAA,KACV;AAAA,GACH;AACF,CAAA;AAEO,MAAM,OAAA,GAAU,UAAA;AAAA,EACrB,CACE;AAAA,IACE,OAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,GAAgB,KAAA;AAAA,IAChB,SAAA,GAAY,QAAA;AAAA,IACZ,kBAAA,GAAqB,GAAA;AAAA,IACrB,SAAA,GAAY;AAAA,KAEd,YAAA,KACG;AACH,IAAA,MAAM,QAAA,GAAW,OAAO,IAAI,CAAA;AAC5B,IAAA,MAAM,UAAA,GAAa,OAA2B,MAAS,CAAA;AACvD,IAAA,MAAM,YAAY,KAAA,EAAM;AACxB,IAAA,MAAM,CAAC,WAAA,EAAa,OAAO,CAAA,GAAI,SAAS,gBAAgB,CAAA;AACxD,IAAA,MAAM,CAAC,aAAA,EAAe,cAAc,CAAA,GAAI,SAAS,gBAAgB,CAAA;AACjE,IAAA,MAAM,SAAS,gBAAA,IAAA,IAAA,GAAA,gBAAA,GAAoB,WAAA;AACnC,IAAA,MAAM,UAAA,GAAa,aAAA,CAAc,EAAE,SAAA,EAAW,UAAU,CAAA;AACxD,IAAA,MAAM,SAAS,SAAA,EAAU;AAEzB,IAAA,MAAM,EAAE,OAAA,EAAS,IAAA,EAAM,cAAA,KAAmB,WAAA,CAAY;AAAA,MACpD,IAAA,EAAM,MAAA;AAAA,MACN,SAAA;AAAA,MACA,YAAA,EAAc,CAAC,IAAA,KAAS;AACtB,QAAA,OAAA,CAAQ,IAAI,CAAA;AACZ,QAAA,YAAA,CAAa,WAAW,OAAO,CAAA;AAE/B,QAAA,IAAI,CAAC,IAAA,EAAM;AACT,UAAA,UAAA,CAAW,OAAA,GAAU,WAAW,MAAM;AACpC,YAAA,cAAA,CAAe,IAAI,CAAA;AAAA,UACrB,CAAA,EAAG,qBAAqB,SAAS,CAAA;AAAA,QACnC,CAAA,MAAO;AACL,UAAA,cAAA,CAAe,IAAI,CAAA;AAAA,QACrB;AAAA,MACF,CAAA;AAAA,MACA,UAAA;AAAA,MACA,oBAAA,EAAsB;AAAA,KACvB,CAAA;AAED,IAAA,MAAM,EAAE,iBAAA,EAAmB,gBAAA,EAAiB,GAAI,eAAA,CAAgB;AAAA,MAC9D,WAAW,OAAO,CAAA;AAAA,MAClB,SAAS,OAAA,EAAS;AAAA,QAChB,WAAA,EAAa,aAAA,GAAgB,WAAA,EAAY,GAAI,MAAA;AAAA,QAC7C,IAAA,EAAM,KAAA;AAAA,QACN,KAAA,EAAO;AAAA,UACL,IAAA,EAAM,CAAA;AAAA,UACN,KAAA,EAAO;AAAA;AACT,OACD,CAAA;AAAA,MACD,SAAS,OAAO;AAAA,KACjB,CAAA;AAED,IAAA,MAAM,EAAE,MAAA,EAAQ,gBAAA,EAAiB,GAAI,oBAAoB,OAAA,EAAS;AAAA,MAChE,QAAA,EAAU,kBAAA;AAAA,MACV,OAAA,EAAS,CAAC,EAAE,IAAA,EAAK,MAAO;AAAA,QACtB,OAAA,EAAS,CAAA;AAAA,QACT,SAAA,EACE,SAAS,KAAA,IAAS,IAAA,KAAS,WACvB,CAAA,WAAA,EAAc,cAAc,CAAA,GAAA,CAAA,GAC5B,CAAA,WAAA,EAAc,cAAc,CAAA,GAAA;AAAA,OACpC,CAAA;AAAA,MACA,IAAA,EAAM,CAAC,EAAE,IAAA,EAAK,MAAO;AAAA,QACnB,OAAA,EAAS,CAAA;AAAA,QACT,SAAA,EAAW,IAAA,KAAS,KAAA,IAAS,IAAA,KAAS,WAAW,CAAA,aAAA,CAAA,GAAkB,CAAA,aAAA;AAAA,OACrE,CAAA;AAAA,MACA,KAAA,EAAO,CAAC,EAAE,IAAA,EAAK,MAAO;AAAA,QACpB,OAAA,EAAS,CAAA;AAAA,QACT,SAAA,EACE,SAAS,KAAA,IAAS,IAAA,KAAS,WACvB,CAAA,WAAA,EAAc,cAAc,CAAA,GAAA,CAAA,GAC5B,CAAA,WAAA,EAAc,cAAc,CAAA,GAAA;AAAA,OACpC;AAAA,KACD,CAAA;AAED,IAAA,MAAM,SAAA,GAAY,WAAA;AAAA,MAChB,CAAC,GAAA,KAA4B;AAC3B,QAAA,IAAA,CAAK,aAAa,GAAG,CAAA;AAErB,QAAA,IAAI,OAAO,iBAAiB,UAAA,EAAY;AACtC,UAAA,YAAA,CAAa,GAAG,CAAA;AAAA,QAClB,WAAW,YAAA,EAAc;AACvB,UAAA,YAAA,CAAa,OAAA,GAAU,GAAA;AAAA,QACzB;AAAA,MACF,CAAA;AAAA,MACA,CAAC,cAAc,IAAI;AAAA,KACrB;AAEA,IAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EAEG,QAAA,EAAA;AAAA,MAAA,YAAA,CAAa,OAAA,EAAS;AAAA,QACrB,GAAA,EAAK,SAAA;AAAA,QACL,QAAA,EAAU,CAAA;AAAA,QACV,kBAAA,EAAoB,SAAS,SAAA,GAAY,MAAA;AAAA,QACzC,GAAG,iBAAA;AAAkB,OACtB,CAAA;AAAA,MAAA,CAEC,aAAA,IAAiB,2BACjB,GAAA,CAAC,MAAA,EAAA,EACC,8BAAC,KAAA,EAAA,EAAI,GAAA,EAAK,KAAK,WAAA,EAAa,KAAA,EAAO,gBAAiB,GAAG,gBAAA,IACrD,QAAA,kBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,OAAO,gBAAA,EAAkB,SAAA,EAAW,OAAO,MAAA,EAC9C,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,iBAAc,SAAA,EAAW,MAAA,CAAO,KAAA,EAAO,GAAA,EAAK,UAAU,OAAA,EAAkB,CAAA;AAAA,wBACzE,GAAA,CAAC,SAAI,EAAA,EAAI,SAAA,EAAW,MAAK,SAAA,EAAU,SAAA,EAAW,MAAA,CAAO,SAAA,EAClD,QAAA,EACH;AAAA,OAAA,EACF,GACF,CAAA,EACF;AAAA,KAAA,EAEJ,CAAA;AAAA,EAEJ;AACF;AAEA,OAAA,CAAQ,WAAA,GAAc,SAAA;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { css } from '@emotion/css';
|
|
2
|
+
import { getDesignTokens } from '../../node_modules/@grafana/design-tokens/dist/esm/lib/getDesignTokens/getDesignTokens.js';
|
|
3
|
+
|
|
4
|
+
const getStyles$1 = () => {
|
|
5
|
+
const {
|
|
6
|
+
legacy,
|
|
7
|
+
primitives: { spacing, typography }
|
|
8
|
+
} = getDesignTokens({ valueType: "css" });
|
|
9
|
+
const backgroundColor = legacy.colors.background.primary;
|
|
10
|
+
return {
|
|
11
|
+
arrow: css({
|
|
12
|
+
fill: backgroundColor
|
|
13
|
+
}),
|
|
14
|
+
shadow: css({
|
|
15
|
+
filter: `drop-shadow(${legacy.boxShadows.z2})`
|
|
16
|
+
}),
|
|
17
|
+
container: css({
|
|
18
|
+
backgroundColor,
|
|
19
|
+
borderRadius: `calc(${legacy.borderRadius.md} + ${spacing.xs})`,
|
|
20
|
+
padding: spacing.xs,
|
|
21
|
+
color: legacy.colors.text.primary,
|
|
22
|
+
fontFamily: typography.fontFamily.ui,
|
|
23
|
+
fontSize: typography.fontSize.ui.sm,
|
|
24
|
+
fontWeight: typography.fontWeight.medium
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { getStyles$1 as getStyles };
|
|
30
|
+
//# sourceMappingURL=Popover.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popover.styles.js","sources":["../../../../src/components/Popover/Popover.styles.ts"],"sourcesContent":["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"],"names":["getStyles"],"mappings":";;;AAGO,MAAMA,cAAY,MAAM;AAC7B,EAAA,MAAM;AAAA,IACJ,MAAA;AAAA,IACA,UAAA,EAAY,EAAE,OAAA,EAAS,UAAA;AAAW,GACpC,GAAI,eAAA,CAAgB,EAAE,SAAA,EAAW,OAAO,CAAA;AACxC,EAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,MAAA,CAAO,UAAA,CAAW,OAAA;AAEjD,EAAA,OAAO;AAAA,IACL,OAAO,GAAA,CAAI;AAAA,MACT,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,IACD,QAAQ,GAAA,CAAI;AAAA,MACV,MAAA,EAAQ,CAAA,YAAA,EAAe,MAAA,CAAO,UAAA,CAAW,EAAE,CAAA,CAAA;AAAA,KAC5C,CAAA;AAAA,IACD,WAAW,GAAA,CAAI;AAAA,MACb,eAAA;AAAA,MACA,cAAc,CAAA,KAAA,EAAQ,MAAA,CAAO,aAAa,EAAE,CAAA,GAAA,EAAM,QAAQ,EAAE,CAAA,CAAA,CAAA;AAAA,MAC5D,SAAS,OAAA,CAAQ,EAAA;AAAA,MACjB,KAAA,EAAO,MAAA,CAAO,MAAA,CAAO,IAAA,CAAK,OAAA;AAAA,MAC1B,UAAA,EAAY,WAAW,UAAA,CAAW,EAAA;AAAA,MAClC,QAAA,EAAU,UAAA,CAAW,QAAA,CAAS,EAAA,CAAG,EAAA;AAAA,MACjC,UAAA,EAAY,WAAW,UAAA,CAAW;AAAA,KACnC;AAAA,GACH;AACF;;;;"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Do not edit directly, this file was auto-generated.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--color-legacy-white: #ffffff;
|
|
7
|
+
--color-legacy-black: #000000;
|
|
8
|
+
--color-legacy-grey90: #fbfbfb;
|
|
9
|
+
--color-legacy-grey100: #f4f5f5;
|
|
10
|
+
--color-legacy-grey80: #d0d1d3;
|
|
11
|
+
--color-legacy-grey25: #2c3235;
|
|
12
|
+
--color-legacy-grey15: #22252b;
|
|
13
|
+
--color-legacy-grey10: #181b1f;
|
|
14
|
+
--color-legacy-grey05: #111217;
|
|
15
|
+
--color-legacy-blue-dark-main: #3d71d9;
|
|
16
|
+
--color-legacy-blue-dark-shade: #5a86de;
|
|
17
|
+
--color-legacy-blue-dark-text: #6e9fff;
|
|
18
|
+
--color-legacy-red-dark-main: #d10e5c;
|
|
19
|
+
--color-legacy-red-dark-text: #ff5286;
|
|
20
|
+
--color-legacy-red-dark-shade: #d73274;
|
|
21
|
+
--color-legacy-green-dark-main: #1a7f4b;
|
|
22
|
+
--color-legacy-green-dark-text: #6ccf8e;
|
|
23
|
+
--color-legacy-green-dark-shade: #3c9266;
|
|
24
|
+
--color-legacy-orange-dark-main: #ff9900;
|
|
25
|
+
--color-legacy-orange-dark-text: #fbad37;
|
|
26
|
+
--color-legacy-orange-dark-shade: #ffa826;
|
|
27
|
+
--color-legacy-blue-light-main: #3871dc;
|
|
28
|
+
--color-legacy-blue-light-shade: #2c5ab0;
|
|
29
|
+
--color-legacy-blue-light-text: #1f62e0;
|
|
30
|
+
--color-legacy-red-light-main: #e0226e;
|
|
31
|
+
--color-legacy-red-light-text: #cf0e5b;
|
|
32
|
+
--color-legacy-red-light-shade: #b31b58;
|
|
33
|
+
--color-legacy-green-light-main: #1b855e;
|
|
34
|
+
--color-legacy-green-light-text: #0a764e;
|
|
35
|
+
--color-legacy-green-light-shade: #156a4b;
|
|
36
|
+
--color-legacy-orange-light-main: #ff9900;
|
|
37
|
+
--color-legacy-orange-light-text: #b5510d;
|
|
38
|
+
--color-legacy-orange-light-shade: #cc7a00;
|
|
39
|
+
--color-legacy-white-base: #ccccdc;
|
|
40
|
+
--color-legacy-black-base: #24292e;
|
|
41
|
+
--color-legacy-orange-brand-gradient-a: #f55f3e;
|
|
42
|
+
--color-legacy-orange-brand-gradient-b: #ff8833;
|
|
43
|
+
--color-legacy-orange-brand-gradient-c: #f53e4c;
|
|
44
|
+
--color-legacy-grey10-opacity20: rgb(24 27 31 / 20%);
|
|
45
|
+
--color-legacy-grey10-opacity18: rgb(24 27 31 / 18%);
|
|
46
|
+
--color-legacy-black-opacity75: rgb(0 0 0 / 75%);
|
|
47
|
+
--color-legacy-white-base-opacity4: rgb(204 204 220 / 4%);
|
|
48
|
+
--color-legacy-white-base-opacity8: rgb(204 204 220 / 8%);
|
|
49
|
+
--color-legacy-white-base-opacity10: rgb(204 204 220 / 10%);
|
|
50
|
+
--color-legacy-white-base-opacity12: rgb(204 204 220 / 12%);
|
|
51
|
+
--color-legacy-white-base-opacity14: rgb(204 204 220 / 14%);
|
|
52
|
+
--color-legacy-white-base-opacity16: rgb(204 204 220 / 16%);
|
|
53
|
+
--color-legacy-white-base-opacity20: rgb(204 204 220 / 20%);
|
|
54
|
+
--color-legacy-white-base-opacity25: rgb(204 204 220 / 25%);
|
|
55
|
+
--color-legacy-white-base-opacity30: rgb(204 204 220 / 30%);
|
|
56
|
+
--color-legacy-white-base-opacity61: rgb(204 204 220 / 61%);
|
|
57
|
+
--color-legacy-white-base-opacity65: rgb(204 204 220 / 65%);
|
|
58
|
+
--color-legacy-blue-dark-main-opacity15: rgb(61 113 217 / 15%);
|
|
59
|
+
--color-legacy-blue-dark-text-opacity25: rgb(110 159 255 / 25%);
|
|
60
|
+
--color-legacy-red-dark-main-opacity15: rgb(209 14 92 / 15%);
|
|
61
|
+
--color-legacy-red-dark-text-opacity25: rgb(255 82 134 / 25%);
|
|
62
|
+
--color-legacy-green-dark-main-opacity15: rgb(26 127 75 / 15%);
|
|
63
|
+
--color-legacy-green-dark-text-opacity25: rgb(108 207 142 / 25%);
|
|
64
|
+
--color-legacy-orange-dark-main-opacity15: rgb(255 153 0 / 15%);
|
|
65
|
+
--color-legacy-orange-dark-text-opacity25: rgb(251 173 55 / 25%);
|
|
66
|
+
--color-legacy-black-base-opacity4: rgb(36 41 46 / 4%);
|
|
67
|
+
--color-legacy-black-base-opacity8: rgb(36 41 46 / 8%);
|
|
68
|
+
--color-legacy-black-base-opacity12: rgb(36 41 46 / 12%);
|
|
69
|
+
--color-legacy-black-base-opacity15: rgb(36 41 46 / 15%);
|
|
70
|
+
--color-legacy-black-base-opacity25: rgb(36 41 46 / 25%);
|
|
71
|
+
--color-legacy-black-base-opacity30: rgb(36 41 46 / 30%);
|
|
72
|
+
--color-legacy-black-base-opacity40: rgb(36 41 46 / 40%);
|
|
73
|
+
--color-legacy-black-base-opacity65: rgb(36 41 46 / 65%);
|
|
74
|
+
--color-legacy-black-base-opacity75: rgb(36 41 46 / 75%);
|
|
75
|
+
--color-legacy-blue-light-main-opacity15: rgb(56 113 220 / 15%);
|
|
76
|
+
--color-legacy-blue-light-text-opacity25: rgb(31 98 224 / 25%);
|
|
77
|
+
--color-legacy-red-light-main-opacity15: rgb(224 34 110 / 15%);
|
|
78
|
+
--color-legacy-red-light-text-opacity25: rgb(207 14 91 / 25%);
|
|
79
|
+
--color-legacy-green-light-main-opacity15: rgb(27 133 94 / 15%);
|
|
80
|
+
--color-legacy-green-light-text-opacity25: rgb(10 118 78 / 25%);
|
|
81
|
+
--color-legacy-orange-light-main-opacity15: rgb(255 153 0 / 15%);
|
|
82
|
+
--color-legacy-orange-light-text-opacity25: rgb(181 81 13 / 25%);
|
|
83
|
+
--border-radius-sm: 4px;
|
|
84
|
+
--border-radius-md: 6px;
|
|
85
|
+
--border-radius-lg: 10px;
|
|
86
|
+
--border-radius-pill: 9999px;
|
|
87
|
+
--border-radius-circle: 100%;
|
|
88
|
+
--typography-font-family-ui: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; /** Default UI font family */
|
|
89
|
+
--typography-font-family-monospace: 'Roboto Mono', monospace; /** Monospace font family */
|
|
90
|
+
--typography-font-size-ui-xs: 10px;
|
|
91
|
+
--typography-font-size-ui-sm: 12px;
|
|
92
|
+
--typography-font-size-ui-md: 14px;
|
|
93
|
+
--typography-font-size-ui-lg: 18px;
|
|
94
|
+
--typography-font-size-monospace-xs: 10px;
|
|
95
|
+
--typography-font-size-monospace-sm: 12px;
|
|
96
|
+
--typography-font-size-monospace-md: 14px;
|
|
97
|
+
--typography-font-size-monospace-lg: 18px;
|
|
98
|
+
--typography-font-weight-light: 300;
|
|
99
|
+
--typography-font-weight-normal: 400;
|
|
100
|
+
--typography-font-weight-medium: 500;
|
|
101
|
+
--typography-font-weight-bold: 700;
|
|
102
|
+
--spacing-zero: 0;
|
|
103
|
+
--spacing-xxs: 2px;
|
|
104
|
+
--spacing-xs: 4px;
|
|
105
|
+
--spacing-sm: 8px;
|
|
106
|
+
--spacing-md: 12px;
|
|
107
|
+
--spacing-lg: 16px;
|
|
108
|
+
--spacing-xl: 20px;
|
|
109
|
+
--spacing-xxl: 24px;
|
|
110
|
+
--spacing-xxxl: 32px;
|
|
111
|
+
--spacing-huge: 40px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* This file is generated automatically - do not edit it directly. To update its
|
|
116
|
+
* values, run yarn update:tokens
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
[data-color-mode='light'] {
|
|
120
|
+
--color-action-hover-opacity: 0.08;
|
|
121
|
+
--color-action-disabled-opacity: 0.38;
|
|
122
|
+
--color-primary-name: primary;
|
|
123
|
+
--color-secondary-name: secondary;
|
|
124
|
+
--color-info-name: info;
|
|
125
|
+
--color-error-name: error;
|
|
126
|
+
--color-success-name: success;
|
|
127
|
+
--color-warning-name: warning;
|
|
128
|
+
--color-text-primary: var(--color-legacy-black-base); /** Primary text color in light mode */
|
|
129
|
+
--color-text-secondary: var(
|
|
130
|
+
--color-legacy-black-base-opacity75
|
|
131
|
+
); /** Secondary text color in light mode */
|
|
132
|
+
--color-text-disabled: var(
|
|
133
|
+
--color-legacy-black-base-opacity65
|
|
134
|
+
); /** Secondary text color in light mode */
|
|
135
|
+
--color-text-max-contrast: var(--color-legacy-black); /** Max contrast text color in light mode */
|
|
136
|
+
--color-action-hover: var(--color-legacy-black-base-opacity12);
|
|
137
|
+
--color-action-selected: var(--color-legacy-black-base-opacity8);
|
|
138
|
+
--color-action-selected-border: var(--color-legacy-orange-light-main);
|
|
139
|
+
--color-action-focus: var(--color-legacy-black-base-opacity12);
|
|
140
|
+
--color-action-disabled-text: var(--color-legacy-black-base-opacity65);
|
|
141
|
+
--color-action-disabled-background: var(--color-legacy-black-base-opacity4);
|
|
142
|
+
--color-primary-main: var(--color-legacy-blue-light-main);
|
|
143
|
+
--color-primary-text: var(--color-legacy-blue-light-text);
|
|
144
|
+
--color-primary-border: var(--color-legacy-blue-light-text);
|
|
145
|
+
--color-primary-shade: var(--color-legacy-blue-light-shade);
|
|
146
|
+
--color-primary-transparent: var(--color-legacy-blue-light-main-opacity15);
|
|
147
|
+
--color-primary-contrast-text: var(--color-legacy-white);
|
|
148
|
+
--color-primary-border-transparent: var(--color-legacy-blue-light-text-opacity25);
|
|
149
|
+
--color-border-weak: var(--color-legacy-black-base-opacity12);
|
|
150
|
+
--color-border-medium: var(--color-legacy-black-base-opacity30);
|
|
151
|
+
--color-border-strong: var(--color-legacy-black-base-opacity40);
|
|
152
|
+
--color-secondary-main: var(--color-legacy-black-base-opacity8);
|
|
153
|
+
--color-secondary-shade: var(--color-legacy-black-base-opacity15);
|
|
154
|
+
--color-secondary-transparent: var(--color-legacy-black-base-opacity8);
|
|
155
|
+
--color-secondary-contrast-text: var(--color-legacy-black-base);
|
|
156
|
+
--color-secondary-border-transparent: var(--color-legacy-black-base-opacity25);
|
|
157
|
+
--color-info-main: var(--color-legacy-blue-light-main);
|
|
158
|
+
--color-info-text: var(--color-legacy-blue-light-text);
|
|
159
|
+
--color-info-border: var(--color-legacy-blue-light-text);
|
|
160
|
+
--color-info-shade: var(--color-legacy-blue-light-shade);
|
|
161
|
+
--color-info-transparent: var(--color-legacy-blue-light-main-opacity15);
|
|
162
|
+
--color-info-contrast-text: var(--color-legacy-white);
|
|
163
|
+
--color-info-border-transparent: var(--color-legacy-blue-light-text-opacity25);
|
|
164
|
+
--color-error-main: var(--color-legacy-red-light-main);
|
|
165
|
+
--color-error-text: var(--color-legacy-red-light-text);
|
|
166
|
+
--color-error-border: var(--color-legacy-red-light-text);
|
|
167
|
+
--color-error-shade: var(--color-legacy-red-light-shade);
|
|
168
|
+
--color-error-transparent: var(--color-legacy-red-light-main-opacity15);
|
|
169
|
+
--color-error-contrast-text: var(--color-legacy-white);
|
|
170
|
+
--color-error-border-transparent: var(--color-legacy-red-light-text-opacity25);
|
|
171
|
+
--color-success-main: var(--color-legacy-green-light-main);
|
|
172
|
+
--color-success-text: var(--color-legacy-green-light-text);
|
|
173
|
+
--color-success-border: var(--color-legacy-green-light-text);
|
|
174
|
+
--color-success-shade: var(--color-legacy-green-light-shade);
|
|
175
|
+
--color-success-transparent: var(--color-legacy-green-light-main-opacity15);
|
|
176
|
+
--color-success-contrast-text: var(--color-legacy-white);
|
|
177
|
+
--color-success-border-transparent: var(--color-legacy-green-light-text-opacity25);
|
|
178
|
+
--color-warning-main: var(--color-legacy-orange-light-main);
|
|
179
|
+
--color-warning-text: var(--color-legacy-orange-light-text);
|
|
180
|
+
--color-warning-border: var(--color-legacy-orange-light-text);
|
|
181
|
+
--color-warning-shade: var(--color-legacy-orange-light-shade);
|
|
182
|
+
--color-warning-transparent: var(--color-legacy-orange-light-main-opacity15);
|
|
183
|
+
--color-warning-contrast-text: var(--color-legacy-black);
|
|
184
|
+
--color-warning-border-transparent: var(--color-legacy-orange-light-text-opacity25);
|
|
185
|
+
--color-background-canvas: var(--color-legacy-grey90);
|
|
186
|
+
--color-background-primary: var(--color-legacy-white);
|
|
187
|
+
--color-background-secondary: var(--color-legacy-grey100);
|
|
188
|
+
--color-background-elevated: var(--color-legacy-white);
|
|
189
|
+
--color-gradients-brand-horizontal: linear-gradient(
|
|
190
|
+
270deg,
|
|
191
|
+
var(--color-legacy-orange-brand-gradient-b) 0%,
|
|
192
|
+
var(--color-legacy-orange-brand-gradient-c) 100%
|
|
193
|
+
);
|
|
194
|
+
--color-gradients-brand-vertical: linear-gradient(
|
|
195
|
+
0.01deg,
|
|
196
|
+
var(--color-legacy-orange-brand-gradient-c) -31.2%,
|
|
197
|
+
var(--color-legacy-orange-brand-gradient-b) 113.07%
|
|
198
|
+
);
|
|
199
|
+
--boxshadow-z1: 0 1px var(--spacing-xxs) var(--color-legacy-grey10-opacity20);
|
|
200
|
+
--boxshadow-z2: 0 var(--spacing-xs) var(--spacing-sm) var(--color-legacy-grey10-opacity20);
|
|
201
|
+
--boxshadow-z3: 0 var(--spacing-sm) var(--spacing-xxl) var(--color-legacy-grey10-opacity18);
|
|
202
|
+
--color-text-link: var(--color-text-primary); /** Link text color in light mode */
|
|
203
|
+
--color-secondary-text: var(--color-text-primary);
|
|
204
|
+
--color-secondary-border: var(--color-border-weak);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* This file is generated automatically - do not edit it directly. To update its
|
|
209
|
+
* values, run yarn update:tokens
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
[data-color-mode='dark'] {
|
|
213
|
+
--color-action-hover-opacity: 0.08;
|
|
214
|
+
--color-action-disabled-opacity: 0.38;
|
|
215
|
+
--color-primary-name: primary;
|
|
216
|
+
--color-secondary-name: secondary;
|
|
217
|
+
--color-info-name: info;
|
|
218
|
+
--color-error-name: error;
|
|
219
|
+
--color-success-name: success;
|
|
220
|
+
--color-warning-name: warning;
|
|
221
|
+
--color-text-primary: var(--color-legacy-white-base); /** Primary text color in dark mode */
|
|
222
|
+
--color-text-secondary: var(
|
|
223
|
+
--color-legacy-white-base-opacity65
|
|
224
|
+
); /** Secondary text color in dark mode */
|
|
225
|
+
--color-text-disabled: var(
|
|
226
|
+
--color-legacy-white-base-opacity61
|
|
227
|
+
); /** Secondary text color in dark mode */
|
|
228
|
+
--color-text-link: var(--color-legacy-blue-dark-text); /** Link text color in dark mode */
|
|
229
|
+
--color-text-max-contrast: var(--color-legacy-white); /** Max contrast text color in dark mode */
|
|
230
|
+
--color-action-hover: var(--color-legacy-white-base-opacity16);
|
|
231
|
+
--color-action-selected: var(--color-legacy-white-base-opacity12);
|
|
232
|
+
--color-action-selected-border: var(--color-legacy-orange-dark-main);
|
|
233
|
+
--color-action-focus: var(--color-legacy-white-base-opacity16);
|
|
234
|
+
--color-action-disabled-text: var(--color-legacy-white-base-opacity61);
|
|
235
|
+
--color-action-disabled-background: var(--color-legacy-white-base-opacity4);
|
|
236
|
+
--color-primary-main: var(--color-legacy-blue-dark-main);
|
|
237
|
+
--color-primary-text: var(--color-legacy-blue-dark-text);
|
|
238
|
+
--color-primary-border: var(--color-legacy-blue-dark-text);
|
|
239
|
+
--color-primary-shade: var(--color-legacy-blue-dark-shade);
|
|
240
|
+
--color-primary-transparent: var(--color-legacy-blue-dark-main-opacity15);
|
|
241
|
+
--color-primary-contrast-text: var(--color-legacy-white);
|
|
242
|
+
--color-primary-border-transparent: var(--color-legacy-blue-dark-text-opacity25);
|
|
243
|
+
--color-border-weak: var(--color-legacy-white-base-opacity12);
|
|
244
|
+
--color-border-medium: var(--color-legacy-white-base-opacity20);
|
|
245
|
+
--color-border-strong: var(--color-legacy-white-base-opacity30);
|
|
246
|
+
--color-secondary-main: var(--color-legacy-white-base-opacity10);
|
|
247
|
+
--color-secondary-shade: var(--color-legacy-white-base-opacity14);
|
|
248
|
+
--color-secondary-transparent: var(--color-legacy-white-base-opacity8);
|
|
249
|
+
--color-secondary-contrast-text: var(--color-legacy-white-base);
|
|
250
|
+
--color-secondary-border: var(--color-legacy-white-base-opacity8);
|
|
251
|
+
--color-secondary-border-transparent: var(--color-legacy-white-base-opacity25);
|
|
252
|
+
--color-info-main: var(--color-legacy-blue-dark-main);
|
|
253
|
+
--color-info-text: var(--color-legacy-blue-dark-text);
|
|
254
|
+
--color-info-border: var(--color-legacy-blue-dark-text);
|
|
255
|
+
--color-info-shade: var(--color-legacy-blue-dark-shade);
|
|
256
|
+
--color-info-transparent: var(--color-legacy-blue-dark-main-opacity15);
|
|
257
|
+
--color-info-contrast-text: var(--color-legacy-white);
|
|
258
|
+
--color-info-border-transparent: var(--color-legacy-blue-dark-text-opacity25);
|
|
259
|
+
--color-error-main: var(--color-legacy-red-dark-main);
|
|
260
|
+
--color-error-text: var(--color-legacy-red-dark-text);
|
|
261
|
+
--color-error-border: var(--color-legacy-red-dark-text);
|
|
262
|
+
--color-error-shade: var(--color-legacy-red-dark-shade);
|
|
263
|
+
--color-error-transparent: var(--color-legacy-red-dark-main-opacity15);
|
|
264
|
+
--color-error-contrast-text: var(--color-legacy-white);
|
|
265
|
+
--color-error-border-transparent: var(--color-legacy-red-dark-text-opacity25);
|
|
266
|
+
--color-success-main: var(--color-legacy-green-dark-main);
|
|
267
|
+
--color-success-text: var(--color-legacy-green-dark-text);
|
|
268
|
+
--color-success-border: var(--color-legacy-green-dark-text);
|
|
269
|
+
--color-success-shade: var(--color-legacy-green-dark-shade);
|
|
270
|
+
--color-success-transparent: var(--color-legacy-green-dark-main-opacity15);
|
|
271
|
+
--color-success-contrast-text: var(--color-legacy-white);
|
|
272
|
+
--color-success-border-transparent: var(--color-legacy-green-dark-text-opacity25);
|
|
273
|
+
--color-warning-main: var(--color-legacy-orange-dark-main);
|
|
274
|
+
--color-warning-text: var(--color-legacy-orange-dark-text);
|
|
275
|
+
--color-warning-border: var(--color-legacy-orange-dark-text);
|
|
276
|
+
--color-warning-shade: var(--color-legacy-orange-dark-shade);
|
|
277
|
+
--color-warning-transparent: var(--color-legacy-orange-dark-main-opacity15);
|
|
278
|
+
--color-warning-contrast-text: var(--color-legacy-black);
|
|
279
|
+
--color-warning-border-transparent: var(--color-legacy-orange-dark-text-opacity25);
|
|
280
|
+
--color-background-canvas: var(--color-legacy-grey05);
|
|
281
|
+
--color-background-primary: var(--color-legacy-grey10);
|
|
282
|
+
--color-background-secondary: var(--color-legacy-grey15);
|
|
283
|
+
--color-background-elevated: var(--color-legacy-grey15);
|
|
284
|
+
--color-gradients-brand-horizontal: linear-gradient(
|
|
285
|
+
270deg,
|
|
286
|
+
var(--color-legacy-orange-brand-gradient-a) 0%,
|
|
287
|
+
var(--color-legacy-orange-brand-gradient-b) 100%
|
|
288
|
+
);
|
|
289
|
+
--color-gradients-brand-vertical: linear-gradient(
|
|
290
|
+
0.01deg,
|
|
291
|
+
var(--color-legacy-orange-brand-gradient-a) 0.01%,
|
|
292
|
+
var(--color-legacy-orange-brand-gradient-b) 99.99%
|
|
293
|
+
);
|
|
294
|
+
--boxshadow-z1: 0 1px var(--spacing-xxs) var(--color-legacy-black-opacity75);
|
|
295
|
+
--boxshadow-z2: 0 var(--spacing-xs) var(--spacing-sm) var(--color-legacy-black-opacity75);
|
|
296
|
+
--boxshadow-z3: 0 var(--spacing-sm) var(--spacing-xxl) var(--color-legacy-black);
|
|
297
|
+
--color-secondary-text: var(--color-text-primary);
|
|
298
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { ReactNode, JSX } from 'react';
|
|
3
|
+
import { ThemeColorMode } from '@grafana/design-tokens';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { IconName } from '@grafana/ui';
|
|
6
|
+
import { Placement } from '@floating-ui/react';
|
|
7
|
+
|
|
8
|
+
interface ColorModeContextType {
|
|
9
|
+
colorMode: ThemeColorMode;
|
|
10
|
+
setColorMode: (colorMode: ThemeColorMode) => void;
|
|
11
|
+
}
|
|
12
|
+
interface ColorModeProviderProps {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
defaultColorMode?: ThemeColorMode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Provides a shared context for the currently-active theme color mode, and sets
|
|
18
|
+
* the data-color-mode attribute on the document element whenever it changes.
|
|
19
|
+
*/
|
|
20
|
+
declare const ColorModeProvider: react__default.FC<ColorModeProviderProps>;
|
|
21
|
+
/**
|
|
22
|
+
* Use this to query the active color mode, or to set it, e.g. with an effect
|
|
23
|
+
* hook within a component which explicitly changes the active color mode:
|
|
24
|
+
*
|
|
25
|
+
* useEffect(() => {
|
|
26
|
+
* setColorMode(colorMode);
|
|
27
|
+
* }, [colorMode]);
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
30
|
+
declare const useColorMode: () => ColorModeContextType;
|
|
31
|
+
|
|
32
|
+
interface PopoverProps {
|
|
33
|
+
/**
|
|
34
|
+
* Content used to trigger the Popover being displayed
|
|
35
|
+
*/
|
|
36
|
+
trigger: JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* Content to render within the Popover
|
|
39
|
+
*/
|
|
40
|
+
children: JSX.Element;
|
|
41
|
+
/**
|
|
42
|
+
* Should the popover be open? Implicitly means the popover visibility is
|
|
43
|
+
* controlled; if omitted, the popover target will control visibility
|
|
44
|
+
*/
|
|
45
|
+
isOpen?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Set to true if you want the tooltip to stay long enough so the user can
|
|
48
|
+
* move mouse over content to select text or click a link
|
|
49
|
+
*/
|
|
50
|
+
isInteractive?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Placement of the Popover relative to the trigger content
|
|
53
|
+
*/
|
|
54
|
+
placement?: Placement;
|
|
55
|
+
/**
|
|
56
|
+
* Transition duration for hide/show effects, in milliseconds
|
|
57
|
+
*/
|
|
58
|
+
transitionDuration?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Additional delay before hiding the popover after mouseout, in milliseconds
|
|
61
|
+
*/
|
|
62
|
+
hideDelay?: number;
|
|
63
|
+
}
|
|
64
|
+
declare const Popover: react.ForwardRefExoticComponent<PopoverProps & react.RefAttributes<HTMLElement>>;
|
|
65
|
+
|
|
66
|
+
interface ComparisonTooltipProps extends Omit<PopoverProps, 'children'> {
|
|
67
|
+
current?: string;
|
|
68
|
+
previous?: string;
|
|
69
|
+
previousLabel?: string;
|
|
70
|
+
currentLabel?: string;
|
|
71
|
+
title?: string;
|
|
72
|
+
currentIcon?: IconName;
|
|
73
|
+
previousIcon?: IconName;
|
|
74
|
+
hideDelay?: number;
|
|
75
|
+
}
|
|
76
|
+
declare const ComparisonTooltip: ({ trigger, placement, current, previous, previousLabel, currentLabel, title, currentIcon, previousIcon, hideDelay, }: ComparisonTooltipProps) => react_jsx_runtime.JSX.Element;
|
|
77
|
+
|
|
78
|
+
interface ComparisonBadgeProps extends Pick<ComparisonTooltipProps, 'currentLabel' | 'previousLabel' | 'placement'> {
|
|
79
|
+
current?: number | null;
|
|
80
|
+
previous?: number | null;
|
|
81
|
+
highlight?: boolean;
|
|
82
|
+
timeframeLabel?: string;
|
|
83
|
+
tooltip?: boolean;
|
|
84
|
+
}
|
|
85
|
+
declare const ComparisonBadge: ({ current, previous, currentLabel, previousLabel, placement, highlight, timeframeLabel, tooltip, }: ComparisonBadgeProps) => react_jsx_runtime.JSX.Element;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Shared utility functions for handling comparison calculations across components
|
|
89
|
+
*/
|
|
90
|
+
interface ComparisonResult {
|
|
91
|
+
hasComparison: boolean;
|
|
92
|
+
direction: 'up' | 'down' | 'neutral';
|
|
93
|
+
percentageChange: number;
|
|
94
|
+
percentageLabel: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Calculate comparison metrics between a current value and a baseline value
|
|
98
|
+
* @param current - The current value to compare
|
|
99
|
+
* @param baseline - The baseline value to compare against (optional)
|
|
100
|
+
* @returns ComparisonResult object with calculated metrics
|
|
101
|
+
*/
|
|
102
|
+
declare const calculateComparison: (current: number | undefined | null, baseline: number | undefined | null) => ComparisonResult;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Number formatting options
|
|
106
|
+
*/
|
|
107
|
+
interface FormatNumberOptions {
|
|
108
|
+
/** Decimal places (default: 2) */
|
|
109
|
+
decimals?: number;
|
|
110
|
+
/** Threshold for compact formatting (default: 1000) */
|
|
111
|
+
compactThreshold?: number;
|
|
112
|
+
/** Never use compact formatting (for precise displays) */
|
|
113
|
+
precise?: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Format numbers with optional compact notation (k, m, b)
|
|
117
|
+
* Components handle their own prefixes/suffixes ($ or %)
|
|
118
|
+
*
|
|
119
|
+
* @param value - The number to format (or 'loading' state)
|
|
120
|
+
* @param options - Formatting options
|
|
121
|
+
* @returns Formatted number string (no prefixes/suffixes)
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* formatNumber(1234) // "1.2k"
|
|
125
|
+
* formatNumber(1234, { precise: true }) // "1,234.00"
|
|
126
|
+
* formatNumber(1234, { decimals: 0 }) // "1k"
|
|
127
|
+
* formatNumber(999) // "999.00"
|
|
128
|
+
*/
|
|
129
|
+
declare const formatNumber: (value: number | string | "loading", options?: FormatNumberOptions) => string;
|
|
130
|
+
|
|
131
|
+
export { ColorModeProvider, ComparisonBadge, ComparisonTooltip, Popover, calculateComparison, formatNumber, useColorMode };
|
|
132
|
+
export type { ColorModeContextType, ColorModeProviderProps, ComparisonResult, ComparisonTooltipProps, FormatNumberOptions, PopoverProps };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ColorModeProvider, useColorMode } from './components/ColorModeProvider/ColorModeProvider.js';
|
|
2
|
+
export { ComparisonBadge } from './components/ComparisonBadge/ComparisonBadge.js';
|
|
3
|
+
export { ComparisonTooltip } from './components/ComparisonTooltip/ComparisonTooltip.js';
|
|
4
|
+
export { Popover } from './components/Popover/Popover.js';
|
|
5
|
+
export { calculateComparison } from './utils/comparison.js';
|
|
6
|
+
export { formatNumber } from './utils/formatters.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { formatNumber } from './formatters.js';
|
|
2
|
+
|
|
3
|
+
const calculateComparison = (current, baseline) => {
|
|
4
|
+
if (current === void 0 || current === null || baseline === void 0 || baseline === null || baseline === 0) {
|
|
5
|
+
return {
|
|
6
|
+
hasComparison: false,
|
|
7
|
+
direction: "neutral",
|
|
8
|
+
percentageChange: 0,
|
|
9
|
+
percentageLabel: ""
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
if (current === baseline) {
|
|
13
|
+
return {
|
|
14
|
+
hasComparison: true,
|
|
15
|
+
direction: "neutral",
|
|
16
|
+
percentageChange: 0,
|
|
17
|
+
percentageLabel: "0%"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const percentageChange = Math.abs((current - baseline) / baseline * 100);
|
|
21
|
+
const direction = current > baseline ? "up" : "down";
|
|
22
|
+
return {
|
|
23
|
+
hasComparison: true,
|
|
24
|
+
direction,
|
|
25
|
+
percentageChange,
|
|
26
|
+
percentageLabel: `${formatNumber(percentageChange, {
|
|
27
|
+
compactThreshold: 1e4,
|
|
28
|
+
decimals: 2
|
|
29
|
+
})}%`
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { calculateComparison };
|
|
34
|
+
//# sourceMappingURL=comparison.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparison.js","sources":["../../../src/utils/comparison.ts"],"sourcesContent":["/**\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"],"names":[],"mappings":";;AAmBO,MAAM,mBAAA,GAAsB,CACjC,OAAA,EACA,QAAA,KACqB;AAErB,EAAA,IACE,OAAA,KAAY,UACZ,OAAA,KAAY,IAAA,IACZ,aAAa,MAAA,IACb,QAAA,KAAa,IAAA,IACb,QAAA,KAAa,CAAA,EACb;AACA,IAAA,OAAO;AAAA,MACL,aAAA,EAAe,KAAA;AAAA,MACf,SAAA,EAAW,SAAA;AAAA,MACX,gBAAA,EAAkB,CAAA;AAAA,MAClB,eAAA,EAAiB;AAAA,KACnB;AAAA,EACF;AAGA,EAAA,IAAI,YAAY,QAAA,EAAU;AACxB,IAAA,OAAO;AAAA,MACL,aAAA,EAAe,IAAA;AAAA,MACf,SAAA,EAAW,SAAA;AAAA,MACX,gBAAA,EAAkB,CAAA;AAAA,MAClB,eAAA,EAAiB;AAAA,KACnB;AAAA,EACF;AAGA,EAAA,MAAM,mBAAmB,IAAA,CAAK,GAAA,CAAA,CAAM,OAAA,GAAU,QAAA,IAAY,WAAY,GAAG,CAAA;AACzE,EAAA,MAAM,SAAA,GAAY,OAAA,GAAU,QAAA,GAAW,IAAA,GAAO,MAAA;AAE9C,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,IAAA;AAAA,IACf,SAAA;AAAA,IACA,gBAAA;AAAA,IACA,eAAA,EAAiB,CAAA,EAAG,YAAA,CAAa,gBAAA,EAAkB;AAAA,MACjD,gBAAA,EAAkB,GAAA;AAAA,MAClB,QAAA,EAAU;AAAA,KACX,CAAC,CAAA,CAAA;AAAA,GACJ;AACF;;;;"}
|