@grafana/components 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +94 -24
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +31 -6
- package/dist/esm/components/ComparisonBadge/ComparisonBadge.styles.js +2 -2
- package/dist/esm/components/ComparisonTooltip/ComparisonTooltip.styles.js +2 -2
- package/dist/esm/components/GenericSkeleton/GenericSkeleton.styles.js +3 -3
- package/dist/esm/components/GenericSkeleton/GenericSkeleton.styles.js.map +1 -1
- package/dist/esm/components/Popover/Popover.styles.js +2 -2
- package/dist/esm/components/StackedChart/StackedChart.js +8 -2
- package/dist/esm/components/StackedChart/StackedChart.js.map +1 -1
- package/dist/esm/components/StackedChart/StackedChart.styles.js +2 -2
- package/dist/esm/components/StackedChart/common.js +4 -0
- package/dist/esm/components/StackedChart/common.js.map +1 -0
- package/dist/esm/components/StackedChartNoData/StackedChartNoData.js +27 -0
- package/dist/esm/components/StackedChartNoData/StackedChartNoData.js.map +1 -0
- package/dist/esm/components/StackedChartNoData/StackedChartNoData.styles.js +44 -0
- package/dist/esm/components/StackedChartNoData/StackedChartNoData.styles.js.map +1 -0
- package/dist/esm/components/StackedChartSegment/StackedChartSegment.styles.js +2 -2
- package/dist/esm/components/StackedChartSegmentTooltip/StackedChartSegmentTooltip.js +6 -3
- package/dist/esm/components/StackedChartSegmentTooltip/StackedChartSegmentTooltip.js.map +1 -1
- package/dist/esm/components/StackedChartSegmentTooltip/StackedChartSegmentTooltip.styles.js +2 -2
- package/dist/esm/components/StackedChartSkeleton/StackedChartSkeleton.js +4 -1
- package/dist/esm/components/StackedChartSkeleton/StackedChartSkeleton.js.map +1 -1
- package/dist/esm/components/StackedChartSkeleton/StackedChartSkeleton.styles.js +2 -2
- package/dist/esm/components/StackedChartSkeleton/StackedChartSkeleton.styles.js.map +1 -1
- package/dist/esm/index.d.ts +31 -6
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -139,7 +139,7 @@ const calculateComparison = (current, baseline) => {
|
|
|
139
139
|
};
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
const getStyles$
|
|
142
|
+
const getStyles$7 = () => {
|
|
143
143
|
const {
|
|
144
144
|
legacy,
|
|
145
145
|
primitives: { spacing, typography }
|
|
@@ -204,7 +204,7 @@ const Popover = React.forwardRef(
|
|
|
204
204
|
const [isDelayedOpen, setDelayedOpen] = React.useState(isOpenControlled);
|
|
205
205
|
const isOpen = isOpenControlled != null ? isOpenControlled : isOpenState;
|
|
206
206
|
const middleware = getMiddleware({ placement, arrowRef });
|
|
207
|
-
const styles = getStyles$
|
|
207
|
+
const styles = getStyles$7();
|
|
208
208
|
const { context, refs, floatingStyles } = react.useFloating({
|
|
209
209
|
open: isOpen,
|
|
210
210
|
placement,
|
|
@@ -290,7 +290,7 @@ const Popover = React.forwardRef(
|
|
|
290
290
|
);
|
|
291
291
|
Popover.displayName = "Popover";
|
|
292
292
|
|
|
293
|
-
const getStyles$
|
|
293
|
+
const getStyles$6 = () => {
|
|
294
294
|
const {
|
|
295
295
|
legacy,
|
|
296
296
|
primitives: { spacing, typography }
|
|
@@ -358,7 +358,7 @@ const ComparisonTooltip = ({
|
|
|
358
358
|
previousIcon = "clock-nine",
|
|
359
359
|
hideDelay
|
|
360
360
|
}) => {
|
|
361
|
-
const styles = getStyles$
|
|
361
|
+
const styles = getStyles$6();
|
|
362
362
|
return /* @__PURE__ */ jsxRuntime.jsx(Popover, { trigger, placement, hideDelay, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.wrapper, children: [
|
|
363
363
|
title && /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.heading, children: title }),
|
|
364
364
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.content, children: [
|
|
@@ -380,7 +380,7 @@ const ComparisonTooltip = ({
|
|
|
380
380
|
] }) });
|
|
381
381
|
};
|
|
382
382
|
|
|
383
|
-
const cssVariables$
|
|
383
|
+
const cssVariables$2 = () => {
|
|
384
384
|
const { legacy } = designTokens.getDesignTokens({ valueType: "css" });
|
|
385
385
|
return {
|
|
386
386
|
dark: {
|
|
@@ -537,7 +537,7 @@ const ComparisonBadge = ({
|
|
|
537
537
|
] })
|
|
538
538
|
] });
|
|
539
539
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
540
|
-
/* @__PURE__ */ jsxRuntime.jsx(designTokens.GlobalCSSVariables, { variables: cssVariables$
|
|
540
|
+
/* @__PURE__ */ jsxRuntime.jsx(designTokens.GlobalCSSVariables, { variables: cssVariables$2(), defaultColorMode: null }),
|
|
541
541
|
tooltip ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
542
542
|
ComparisonTooltip,
|
|
543
543
|
{
|
|
@@ -553,7 +553,7 @@ const ComparisonBadge = ({
|
|
|
553
553
|
] });
|
|
554
554
|
};
|
|
555
555
|
|
|
556
|
-
const cssVariables = () => {
|
|
556
|
+
const cssVariables$1 = () => {
|
|
557
557
|
const { legacy } = designTokens.getDesignTokens({ valueType: "css" });
|
|
558
558
|
return {
|
|
559
559
|
dark: {
|
|
@@ -572,7 +572,7 @@ const shimmer = css.keyframes({
|
|
|
572
572
|
transform: "translateX(100%);"
|
|
573
573
|
}
|
|
574
574
|
});
|
|
575
|
-
const getStyles$
|
|
575
|
+
const getStyles$5 = (animationDuration) => {
|
|
576
576
|
return css.css({
|
|
577
577
|
display: "flex",
|
|
578
578
|
width: "100%",
|
|
@@ -596,9 +596,9 @@ const getStyles$4 = (animationDuration) => {
|
|
|
596
596
|
};
|
|
597
597
|
|
|
598
598
|
const GenericSkeleton = ({ animationDuration = 2 }) => {
|
|
599
|
-
const styles = getStyles$
|
|
599
|
+
const styles = getStyles$5(animationDuration);
|
|
600
600
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
601
|
-
/* @__PURE__ */ jsxRuntime.jsx(designTokens.GlobalCSSVariables, { variables: cssVariables(), defaultColorMode: null }),
|
|
601
|
+
/* @__PURE__ */ jsxRuntime.jsx(designTokens.GlobalCSSVariables, { variables: cssVariables$1(), defaultColorMode: null }),
|
|
602
602
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles })
|
|
603
603
|
] });
|
|
604
604
|
};
|
|
@@ -623,7 +623,7 @@ const getSegmentStyles = () => css.css({
|
|
|
623
623
|
display: "flex",
|
|
624
624
|
height: "100%"
|
|
625
625
|
});
|
|
626
|
-
const getStyles$
|
|
626
|
+
const getStyles$4 = ({
|
|
627
627
|
index,
|
|
628
628
|
state = "default"
|
|
629
629
|
}) => {
|
|
@@ -661,7 +661,7 @@ const _StackedChartSegment = ({
|
|
|
661
661
|
"div",
|
|
662
662
|
{
|
|
663
663
|
ref,
|
|
664
|
-
className: clsx__default.default(getStyles$
|
|
664
|
+
className: clsx__default.default(getStyles$4({ state, index }), getSegmentStyles()),
|
|
665
665
|
onMouseOver: onMouseOver && onMouseOver({ ref, categoryId }),
|
|
666
666
|
onMouseOut: onMouseOut && onMouseOut({ ref, categoryId }),
|
|
667
667
|
style: { width }
|
|
@@ -671,7 +671,7 @@ const _StackedChartSegment = ({
|
|
|
671
671
|
_StackedChartSegment.displayName = "StackedChartSegment";
|
|
672
672
|
const StackedChartSegment = React__default.default.forwardRef(_StackedChartSegment);
|
|
673
673
|
|
|
674
|
-
const getStyles$
|
|
674
|
+
const getStyles$3 = ({ height }) => {
|
|
675
675
|
const {
|
|
676
676
|
primitives: { spacing }
|
|
677
677
|
} = designTokens.getDesignTokens({ valueType: "css" });
|
|
@@ -685,7 +685,7 @@ const getStyles$2 = ({ height }) => {
|
|
|
685
685
|
};
|
|
686
686
|
};
|
|
687
687
|
|
|
688
|
-
const getStyles$
|
|
688
|
+
const getStyles$2 = (index) => {
|
|
689
689
|
const {
|
|
690
690
|
legacy,
|
|
691
691
|
primitives: { spacing, typography }
|
|
@@ -732,9 +732,12 @@ const getStyles$1 = (index) => {
|
|
|
732
732
|
};
|
|
733
733
|
};
|
|
734
734
|
|
|
735
|
-
const defaultContentFormatter = ({
|
|
735
|
+
const defaultContentFormatter$1 = ({
|
|
736
|
+
value,
|
|
737
|
+
colorClassName
|
|
738
|
+
}) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
736
739
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: colorClassName, children: [
|
|
737
|
-
value,
|
|
740
|
+
value.toFixed(1),
|
|
738
741
|
"%"
|
|
739
742
|
] }),
|
|
740
743
|
" of total usage"
|
|
@@ -747,10 +750,10 @@ const StackedChartSegmentTooltip = ({
|
|
|
747
750
|
value,
|
|
748
751
|
total = 100,
|
|
749
752
|
index,
|
|
750
|
-
formatContent = defaultContentFormatter,
|
|
753
|
+
formatContent = defaultContentFormatter$1,
|
|
751
754
|
virtualElement
|
|
752
755
|
}) => {
|
|
753
|
-
const styles = getStyles$
|
|
756
|
+
const styles = getStyles$2(index);
|
|
754
757
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
755
758
|
Popover,
|
|
756
759
|
{
|
|
@@ -766,7 +769,7 @@ const StackedChartSegmentTooltip = ({
|
|
|
766
769
|
);
|
|
767
770
|
};
|
|
768
771
|
|
|
769
|
-
const getStyles = (height) => {
|
|
772
|
+
const getStyles$1 = (height) => {
|
|
770
773
|
return css.css({
|
|
771
774
|
width: "100%",
|
|
772
775
|
height: `${height}px`,
|
|
@@ -775,20 +778,84 @@ const getStyles = (height) => {
|
|
|
775
778
|
});
|
|
776
779
|
};
|
|
777
780
|
|
|
778
|
-
const
|
|
779
|
-
|
|
781
|
+
const STACKED_CHART_DEFAULT_HEIGHT = 24;
|
|
782
|
+
|
|
783
|
+
const StackedChartSkeleton = ({
|
|
784
|
+
height = STACKED_CHART_DEFAULT_HEIGHT
|
|
785
|
+
}) => {
|
|
786
|
+
const styles = getStyles$1(height);
|
|
780
787
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles, children: /* @__PURE__ */ jsxRuntime.jsx(GenericSkeleton, {}) });
|
|
781
788
|
};
|
|
782
789
|
|
|
790
|
+
const cssVariables = () => {
|
|
791
|
+
const { legacy } = designTokens.getDesignTokens({ valueType: "css" });
|
|
792
|
+
return {
|
|
793
|
+
dark: {
|
|
794
|
+
"stacked-chart-no-data-background-color": legacy.palette.blackBaseOpacity15
|
|
795
|
+
},
|
|
796
|
+
light: {
|
|
797
|
+
"stacked-chart-no-data-background-color": legacy.palette.blackBaseOpacity4
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
const getStyles = (height) => {
|
|
802
|
+
const {
|
|
803
|
+
legacy,
|
|
804
|
+
primitives: { typography, spacing }
|
|
805
|
+
} = designTokens.getDesignTokens({ valueType: "css" });
|
|
806
|
+
return {
|
|
807
|
+
container: css.css({
|
|
808
|
+
display: "flex",
|
|
809
|
+
flex: 1,
|
|
810
|
+
width: "100%",
|
|
811
|
+
height: `${height}px`,
|
|
812
|
+
alignItems: "center",
|
|
813
|
+
justifyContent: "center",
|
|
814
|
+
gap: spacing.sm,
|
|
815
|
+
borderRadius: legacy.borderRadius.md,
|
|
816
|
+
color: legacy.colors.text.secondary,
|
|
817
|
+
fontFamily: typography.fontFamily.ui,
|
|
818
|
+
fontSize: typography.fontSize.ui.sm,
|
|
819
|
+
paddingTop: spacing.xxs,
|
|
820
|
+
background: "var(--stacked-chart-no-data-background-color)"
|
|
821
|
+
}),
|
|
822
|
+
label: css.css({
|
|
823
|
+
fontWeight: typography.fontWeight.medium,
|
|
824
|
+
textTransform: "lowercase"
|
|
825
|
+
})
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
const defaultContentFormatter = ({ period, className }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
830
|
+
"No data for ",
|
|
831
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className, children: period })
|
|
832
|
+
] });
|
|
833
|
+
const StackedChartNoData = ({
|
|
834
|
+
height = STACKED_CHART_DEFAULT_HEIGHT,
|
|
835
|
+
period = "current",
|
|
836
|
+
formatMessage = defaultContentFormatter
|
|
837
|
+
}) => {
|
|
838
|
+
const styles = getStyles(height);
|
|
839
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
840
|
+
/* @__PURE__ */ jsxRuntime.jsx(designTokens.GlobalCSSVariables, { variables: cssVariables(), defaultColorMode: null }),
|
|
841
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.container, children: [
|
|
842
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Icon, { name: "exclamation-triangle", size: "sm" }),
|
|
843
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatMessage({ period, className: styles.label }) })
|
|
844
|
+
] })
|
|
845
|
+
] });
|
|
846
|
+
};
|
|
847
|
+
|
|
783
848
|
const StackedChart = ({
|
|
784
849
|
categories: _categories,
|
|
785
850
|
highlightedCategoryId: initialHighlightedCategoryId,
|
|
786
851
|
isSkeleton = false,
|
|
787
852
|
isDimmed = false,
|
|
788
853
|
sortOrder = "largest-first",
|
|
789
|
-
height =
|
|
854
|
+
height = STACKED_CHART_DEFAULT_HEIGHT,
|
|
790
855
|
onSegmentMouseOver,
|
|
791
|
-
onSegmentMouseOut
|
|
856
|
+
onSegmentMouseOut,
|
|
857
|
+
period = "current",
|
|
858
|
+
formatNoDataMessage
|
|
792
859
|
}) => {
|
|
793
860
|
if (isSkeleton || !_categories) return /* @__PURE__ */ jsxRuntime.jsx(StackedChartSkeleton, { height });
|
|
794
861
|
let highlightedSegmentRef = React.useRef(null);
|
|
@@ -826,7 +893,7 @@ const StackedChart = ({
|
|
|
826
893
|
}
|
|
827
894
|
return roundedTotal;
|
|
828
895
|
}, [categories]);
|
|
829
|
-
const styles = getStyles$
|
|
896
|
+
const styles = getStyles$3({ height });
|
|
830
897
|
const onMouseOver = ({ ref, categoryId }) => () => {
|
|
831
898
|
clearTimeout(timer.current);
|
|
832
899
|
setHovered(true);
|
|
@@ -844,6 +911,8 @@ const StackedChart = ({
|
|
|
844
911
|
}, 50);
|
|
845
912
|
if (onSegmentMouseOut) onSegmentMouseOut({ ref, categoryId });
|
|
846
913
|
};
|
|
914
|
+
if (initialHighlightedCategoryId && Object.keys(categories).indexOf(initialHighlightedCategoryId) === -1)
|
|
915
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StackedChartNoData, { height, period, formatMessage: formatNoDataMessage });
|
|
847
916
|
const highlightedCategory = initialHighlightedCategoryId ? {
|
|
848
917
|
...categories[initialHighlightedCategoryId],
|
|
849
918
|
index: Object.keys(categories).indexOf(initialHighlightedCategoryId)
|
|
@@ -937,6 +1006,7 @@ exports.ComparisonTooltip = ComparisonTooltip;
|
|
|
937
1006
|
exports.GenericSkeleton = GenericSkeleton;
|
|
938
1007
|
exports.Popover = Popover;
|
|
939
1008
|
exports.StackedChart = StackedChart;
|
|
1009
|
+
exports.StackedChartNoData = StackedChartNoData;
|
|
940
1010
|
exports.StackedChartSegment = StackedChartSegment;
|
|
941
1011
|
exports.StackedChartSegmentTooltip = StackedChartSegmentTooltip;
|
|
942
1012
|
exports.StackedChartSkeleton = StackedChartSkeleton;
|