@grafana/scenes 5.11.1--canary.830.10618954979.0 → 5.11.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +13 -0
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js +12 -14
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js +6 -2
- package/dist/esm/variables/adhoc/AdHocFiltersCombobox/DropdownItem.js.map +1 -1
- package/dist/index.js +17 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# v5.11.1 (Fri Aug 30 2024)
|
2
|
+
|
3
|
+
#### 🐛 Bug Fix
|
4
|
+
|
5
|
+
- AdHocFiltersVariable - new ad hoc filters UI [#830](https://github.com/grafana/scenes/pull/830) ([@Sergej-Vlasov](https://github.com/Sergej-Vlasov) [@bfmatei](https://github.com/bfmatei))
|
6
|
+
|
7
|
+
#### Authors: 2
|
8
|
+
|
9
|
+
- [@Sergej-Vlasov](https://github.com/Sergej-Vlasov)
|
10
|
+
- Bogdan Matei ([@bfmatei](https://github.com/bfmatei))
|
11
|
+
|
12
|
+
---
|
13
|
+
|
1
14
|
# v5.11.0 (Thu Aug 29 2024)
|
2
15
|
|
3
16
|
#### 🚀 Enhancement
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import { cx, css } from '@emotion/css';
|
2
2
|
import { useStyles2, IconButton } from '@grafana/ui';
|
3
|
-
import React, { useState, useRef, useCallback } from 'react';
|
4
|
-
import { flushSync } from 'react-dom';
|
3
|
+
import React, { useState, useRef, useCallback, useEffect } from 'react';
|
5
4
|
import { AdHocCombobox } from './AdHocFiltersCombobox.js';
|
6
5
|
|
7
6
|
var __defProp = Object.defineProperty;
|
@@ -27,29 +26,28 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
27
26
|
var _a, _b, _c;
|
28
27
|
const styles = useStyles2(getStyles);
|
29
28
|
const [viewMode, setViewMode] = useState(true);
|
29
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
30
30
|
const pillWrapperRef = useRef(null);
|
31
31
|
const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
|
32
32
|
const valueLabel = (_c = (_b = filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter.value;
|
33
33
|
const handleChangeViewMode = useCallback(
|
34
34
|
(event) => {
|
35
|
-
var _a2;
|
36
35
|
event == null ? void 0 : event.stopPropagation();
|
37
36
|
if (readOnly) {
|
38
37
|
return;
|
39
38
|
}
|
40
|
-
|
41
|
-
|
42
|
-
setViewMode((mode) => {
|
43
|
-
viewMode2 = mode;
|
44
|
-
return !mode;
|
45
|
-
});
|
46
|
-
});
|
47
|
-
if (!viewMode2) {
|
48
|
-
(_a2 = pillWrapperRef.current) == null ? void 0 : _a2.focus();
|
49
|
-
}
|
39
|
+
setShouldFocus(!viewMode);
|
40
|
+
setViewMode(!viewMode);
|
50
41
|
},
|
51
|
-
[readOnly]
|
42
|
+
[readOnly, viewMode]
|
52
43
|
);
|
44
|
+
useEffect(() => {
|
45
|
+
var _a2;
|
46
|
+
if (shouldFocus) {
|
47
|
+
(_a2 = pillWrapperRef.current) == null ? void 0 : _a2.focus();
|
48
|
+
setShouldFocus(false);
|
49
|
+
}
|
50
|
+
}, [shouldFocus]);
|
53
51
|
if (viewMode) {
|
54
52
|
return /* @__PURE__ */ React.createElement("div", {
|
55
53
|
className: cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly }),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AdHocFilterPill.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2, IconButton } from '@grafana/ui';\nimport React, { useState, useRef, useCallback
|
1
|
+
{"version":3,"file":"AdHocFilterPill.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/AdHocFilterPill.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2, IconButton } from '@grafana/ui';\nimport React, { useState, useRef, useCallback, useEffect } from 'react';\nimport { AdHocCombobox } from './AdHocFiltersCombobox';\nimport { AdHocFilterWithLabels, AdHocFiltersVariable } from '../AdHocFiltersVariable';\n\ninterface Props {\n filter: AdHocFilterWithLabels;\n model: AdHocFiltersVariable;\n readOnly?: boolean;\n}\n\nexport function AdHocFilterPill({ filter, model, readOnly }: Props) {\n const styles = useStyles2(getStyles);\n const [viewMode, setViewMode] = useState(true);\n const [shouldFocus, setShouldFocus] = useState(false);\n const pillWrapperRef = useRef<HTMLDivElement>(null);\n\n const keyLabel = filter.keyLabel ?? filter.key;\n const valueLabel = filter.valueLabels?.[0] ?? filter.value;\n\n const handleChangeViewMode = useCallback(\n (event?: React.MouseEvent) => {\n event?.stopPropagation();\n if (readOnly) {\n return;\n }\n\n setShouldFocus(!viewMode);\n setViewMode(!viewMode);\n },\n [readOnly, viewMode]\n );\n\n useEffect(() => {\n if (shouldFocus) {\n pillWrapperRef.current?.focus();\n setShouldFocus(false);\n }\n }, [shouldFocus]);\n\n if (viewMode) {\n return (\n <div\n className={cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly })}\n onClick={handleChangeViewMode}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n handleChangeViewMode();\n }\n }}\n role=\"button\"\n aria-label={`Edit filter with key ${keyLabel}`}\n tabIndex={0}\n ref={pillWrapperRef}\n >\n <span>\n {keyLabel} {filter.operator} {valueLabel}\n </span>\n {!readOnly ? (\n <IconButton\n onClick={(e) => {\n e.stopPropagation();\n model._removeFilter(filter);\n }}\n onKeyDownCapture={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n model._removeFilter(filter);\n }\n }}\n name=\"times\"\n size=\"md\"\n className={styles.removeButton}\n tooltip={`Remove filter with key ${keyLabel}`}\n />\n ) : null}\n </div>\n );\n }\n\n return <AdHocCombobox filter={filter} model={model} handleChangeViewMode={handleChangeViewMode} />;\n}\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n combinedFilterPill: css({\n display: 'flex',\n alignItems: 'center',\n background: theme.colors.action.selected,\n borderRadius: theme.shape.radius.default,\n border: `1px solid ${theme.colors.border.weak}`,\n padding: theme.spacing(0.125, 0, 0.125, 1),\n color: theme.colors.text.primary,\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n minHeight: theme.spacing(2.75),\n ...theme.typography.bodySmall,\n fontWeight: theme.typography.fontWeightBold,\n cursor: 'pointer',\n\n '&:hover': {\n background: theme.colors.action.hover,\n },\n }),\n readOnlyCombinedFilter: css({\n paddingRight: theme.spacing(1),\n cursor: 'text',\n '&:hover': {\n background: theme.colors.action.selected,\n },\n }),\n removeButton: css({\n marginInline: theme.spacing(0.5),\n cursor: 'pointer',\n '&:hover': {\n color: theme.colors.text.primary,\n },\n }),\n});\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaO,SAAS,eAAgB,CAAA,EAAE,MAAQ,EAAA,KAAA,EAAO,UAAmB,EAAA;AAbpE,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAcE,EAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA,CAAA;AACnC,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAS,IAAI,CAAA,CAAA;AAC7C,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AACpD,EAAM,MAAA,cAAA,GAAiB,OAAuB,IAAI,CAAA,CAAA;AAElD,EAAA,MAAM,QAAW,GAAA,CAAA,EAAA,GAAA,MAAA,CAAO,QAAP,KAAA,IAAA,GAAA,EAAA,GAAmB,MAAO,CAAA,GAAA,CAAA;AAC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AA,KAC3B;AAAA,GACD,CAAA;AACH,CAAA,CAAA;;;;"}
|
@@ -87,10 +87,14 @@ const getStyles = (theme) => ({
|
|
87
87
|
})
|
88
88
|
});
|
89
89
|
const LoadingOptionsPlaceholder = () => {
|
90
|
-
return /* @__PURE__ */ React.createElement(DropdownItem,
|
90
|
+
return /* @__PURE__ */ React.createElement(DropdownItem, {
|
91
|
+
onClick: (e) => e.stopPropagation()
|
92
|
+
}, "Loading options...");
|
91
93
|
};
|
92
94
|
const NoOptionsPlaceholder = () => {
|
93
|
-
return /* @__PURE__ */ React.createElement(DropdownItem,
|
95
|
+
return /* @__PURE__ */ React.createElement(DropdownItem, {
|
96
|
+
onClick: (e) => e.stopPropagation()
|
97
|
+
}, "No options found");
|
94
98
|
};
|
95
99
|
const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
|
96
100
|
return /* @__PURE__ */ React.createElement(DropdownItem, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DropdownItem.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/DropdownItem.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2 } from '@grafana/ui';\nimport React, { forwardRef, useId } from 'react';\n\ninterface DropdownItemProps {\n children: React.ReactNode;\n active?: boolean;\n addGroupBottomBorder?: boolean;\n}\n\nexport const DropdownItem = forwardRef<HTMLDivElement, DropdownItemProps & React.HTMLProps<HTMLDivElement>>(\n function DropdownItem({ children, active, addGroupBottomBorder, ...rest }, ref) {\n const styles = useStyles2(getStyles);\n const id = useId();\n return (\n <div\n ref={ref}\n role=\"option\"\n id={id}\n aria-selected={active}\n className={cx(styles.option, active && styles.optionFocused, addGroupBottomBorder && styles.groupBottomBorder)}\n {...rest}\n >\n <div className={styles.optionBody} data-testid={`data-testid ad hoc filter option value ${children}`}>\n <span>{children}</span>\n </div>\n </div>\n );\n }\n);\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n option: css({\n label: 'grafana-select-option',\n top: 0,\n left: 0,\n width: '100%',\n position: 'absolute',\n padding: theme.spacing(1),\n display: 'flex',\n alignItems: 'center',\n flexDirection: 'row',\n flexShrink: 0,\n whiteSpace: 'nowrap',\n cursor: 'pointer',\n '&:hover': {\n background: theme.colors.action.hover,\n '@media (forced-colors: active), (prefers-contrast: more)': {\n border: `1px solid ${theme.colors.primary.border}`,\n },\n },\n }),\n optionFocused: css({\n label: 'grafana-select-option-focused',\n background: theme.colors.action.focus,\n '@media (forced-colors: active), (prefers-contrast: more)': {\n border: `1px solid ${theme.colors.primary.border}`,\n },\n }),\n optionBody: css({\n label: 'grafana-select-option-body',\n display: 'flex',\n fontWeight: theme.typography.fontWeightMedium,\n flexDirection: 'column',\n flexGrow: 1,\n }),\n groupBottomBorder: css({\n borderBottom: `1px solid ${theme.colors.border.weak}`,\n }),\n});\n\nexport const LoadingOptionsPlaceholder = () => {\n return <DropdownItem>Loading options...</DropdownItem>;\n};\n\nexport const NoOptionsPlaceholder = () => {\n return <DropdownItem>No options found</DropdownItem>;\n};\n\nexport const OptionsErrorPlaceholder = ({ handleFetchOptions }: { handleFetchOptions: () => void }) => {\n return (\n <DropdownItem onClick={handleFetchOptions}>An error has occurred fetching labels. Click to retry</DropdownItem>\n );\n};\n"],"names":["DropdownItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,YAAe,GAAA,UAAA;AAAA,EAC1B,SAASA,aAAa,CAAA,EAAA,EAAqD,GAAK,EAAA;AAA1D,IAAE,IAAA,EAAA,GAAA,EAAA,EAAA,EAAA,QAAA,EAAU,QAAQ,oBAZ5C,EAAA,GAYwB,IAA6C,IAA7C,GAAA,SAAA,CAAA,EAAA,EAA6C,CAA3C,UAAA,EAAU,QAAQ,EAAA,sBAAA,CAAA,CAAA,CAAA;AACxC,IAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA,CAAA;AACnC,IAAA,MAAM,KAAK,KAAM,EAAA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,CAAA;AAAA,OAC5C;AAAA,KACF;AAAA,GACD,CAAA;AAAA,EACD,eAAe,GAAI,CAAA;AAAA,IACjB,KAAO,EAAA,+BAAA;AAAA,IACP,UAAA,EAAY,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,KAAA;AAAA,IAChC,0DAA4D,EAAA;AAAA,MAC1D,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,MAAA,CAAO,OAAQ,CAAA,MAAA,CAAA,CAAA;AAAA,KAC5C;AAAA,GACD,CAAA;AAAA,EACD,YAAY,GAAI,CAAA;AAAA,IACd,KAAO,EAAA,4BAAA;AAAA,IACP,OAAS,EAAA,MAAA;AAAA,IACT,UAAA,EAAY,MAAM,UAAW,CAAA,gBAAA;AAAA,IAC7B,aAAe,EAAA,QAAA;AAAA,IACf,QAAU,EAAA,CAAA;AAAA,GACX,CAAA;AAAA,EACD,mBAAmB,GAAI,CAAA;AAAA,IACrB,YAAc,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,MAAA,CAAO,MAAO,CAAA,IAAA,CAAA,CAAA;AAAA,GAChD,CAAA;AACH,CAAA,CAAA,CAAA;AAEO,MAAM,4BAA4B,MAAM;AAC7C,
|
1
|
+
{"version":3,"file":"DropdownItem.js","sources":["../../../../../src/variables/adhoc/AdHocFiltersCombobox/DropdownItem.tsx"],"sourcesContent":["import { css, cx } from '@emotion/css';\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { useStyles2 } from '@grafana/ui';\nimport React, { forwardRef, useId } from 'react';\n\ninterface DropdownItemProps {\n children: React.ReactNode;\n active?: boolean;\n addGroupBottomBorder?: boolean;\n}\n\nexport const DropdownItem = forwardRef<HTMLDivElement, DropdownItemProps & React.HTMLProps<HTMLDivElement>>(\n function DropdownItem({ children, active, addGroupBottomBorder, ...rest }, ref) {\n const styles = useStyles2(getStyles);\n const id = useId();\n return (\n <div\n ref={ref}\n role=\"option\"\n id={id}\n aria-selected={active}\n className={cx(styles.option, active && styles.optionFocused, addGroupBottomBorder && styles.groupBottomBorder)}\n {...rest}\n >\n <div className={styles.optionBody} data-testid={`data-testid ad hoc filter option value ${children}`}>\n <span>{children}</span>\n </div>\n </div>\n );\n }\n);\n\nconst getStyles = (theme: GrafanaTheme2) => ({\n option: css({\n label: 'grafana-select-option',\n top: 0,\n left: 0,\n width: '100%',\n position: 'absolute',\n padding: theme.spacing(1),\n display: 'flex',\n alignItems: 'center',\n flexDirection: 'row',\n flexShrink: 0,\n whiteSpace: 'nowrap',\n cursor: 'pointer',\n '&:hover': {\n background: theme.colors.action.hover,\n '@media (forced-colors: active), (prefers-contrast: more)': {\n border: `1px solid ${theme.colors.primary.border}`,\n },\n },\n }),\n optionFocused: css({\n label: 'grafana-select-option-focused',\n background: theme.colors.action.focus,\n '@media (forced-colors: active), (prefers-contrast: more)': {\n border: `1px solid ${theme.colors.primary.border}`,\n },\n }),\n optionBody: css({\n label: 'grafana-select-option-body',\n display: 'flex',\n fontWeight: theme.typography.fontWeightMedium,\n flexDirection: 'column',\n flexGrow: 1,\n }),\n groupBottomBorder: css({\n borderBottom: `1px solid ${theme.colors.border.weak}`,\n }),\n});\n\nexport const LoadingOptionsPlaceholder = () => {\n return <DropdownItem onClick={(e) => e.stopPropagation()}>Loading options...</DropdownItem>;\n};\n\nexport const NoOptionsPlaceholder = () => {\n return <DropdownItem onClick={(e) => e.stopPropagation()}>No options found</DropdownItem>;\n};\n\nexport const OptionsErrorPlaceholder = ({ handleFetchOptions }: { handleFetchOptions: () => void }) => {\n return (\n <DropdownItem onClick={handleFetchOptions}>An error has occurred fetching labels. Click to retry</DropdownItem>\n );\n};\n"],"names":["DropdownItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,YAAe,GAAA,UAAA;AAAA,EAC1B,SAASA,aAAa,CAAA,EAAA,EAAqD,GAAK,EAAA;AAA1D,IAAE,IAAA,EAAA,GAAA,EAAA,EAAA,EAAA,QAAA,EAAU,QAAQ,oBAZ5C,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,CAAM,KAAA,CAAA,CAAE,eAAgB,EAAA;AAAA,GAAA,EAAG,kBAAgB,CAAA,CAAA;AAC5E,EAAA;AAEO,MAAM,uBAA0B,GAAA,CAAC,EAAE,kBAAA,EAA6D,KAAA;AACrG,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA;AAAA,IAAa,OAAS,EAAA,kBAAA;AAAA,GAAA,EAAoB,uDAAqD,CAAA,CAAA;AAEpG;;;;"}
|
package/dist/index.js
CHANGED
@@ -14,7 +14,6 @@ var ui = require('@grafana/ui');
|
|
14
14
|
var e2eSelectors = require('@grafana/e2e-selectors');
|
15
15
|
var css = require('@emotion/css');
|
16
16
|
var uFuzzy = require('@leeoniya/ufuzzy');
|
17
|
-
var reactDom = require('react-dom');
|
18
17
|
var react = require('@floating-ui/react');
|
19
18
|
var reactVirtual = require('@tanstack/react-virtual');
|
20
19
|
var reactUse = require('react-use');
|
@@ -3646,10 +3645,14 @@ const getStyles$c = (theme) => ({
|
|
3646
3645
|
})
|
3647
3646
|
});
|
3648
3647
|
const LoadingOptionsPlaceholder = () => {
|
3649
|
-
return /* @__PURE__ */ React__default["default"].createElement(DropdownItem,
|
3648
|
+
return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
|
3649
|
+
onClick: (e) => e.stopPropagation()
|
3650
|
+
}, "Loading options...");
|
3650
3651
|
};
|
3651
3652
|
const NoOptionsPlaceholder = () => {
|
3652
|
-
return /* @__PURE__ */ React__default["default"].createElement(DropdownItem,
|
3653
|
+
return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
|
3654
|
+
onClick: (e) => e.stopPropagation()
|
3655
|
+
}, "No options found");
|
3653
3656
|
};
|
3654
3657
|
const OptionsErrorPlaceholder = ({ handleFetchOptions }) => {
|
3655
3658
|
return /* @__PURE__ */ React__default["default"].createElement(DropdownItem, {
|
@@ -4201,29 +4204,28 @@ function AdHocFilterPill({ filter, model, readOnly }) {
|
|
4201
4204
|
var _a, _b, _c;
|
4202
4205
|
const styles = ui.useStyles2(getStyles$a);
|
4203
4206
|
const [viewMode, setViewMode] = React.useState(true);
|
4207
|
+
const [shouldFocus, setShouldFocus] = React.useState(false);
|
4204
4208
|
const pillWrapperRef = React.useRef(null);
|
4205
4209
|
const keyLabel = (_a = filter.keyLabel) != null ? _a : filter.key;
|
4206
4210
|
const valueLabel = (_c = (_b = filter.valueLabels) == null ? void 0 : _b[0]) != null ? _c : filter.value;
|
4207
4211
|
const handleChangeViewMode = React.useCallback(
|
4208
4212
|
(event) => {
|
4209
|
-
var _a2;
|
4210
4213
|
event == null ? void 0 : event.stopPropagation();
|
4211
4214
|
if (readOnly) {
|
4212
4215
|
return;
|
4213
4216
|
}
|
4214
|
-
|
4215
|
-
|
4216
|
-
setViewMode((mode) => {
|
4217
|
-
viewMode2 = mode;
|
4218
|
-
return !mode;
|
4219
|
-
});
|
4220
|
-
});
|
4221
|
-
if (!viewMode2) {
|
4222
|
-
(_a2 = pillWrapperRef.current) == null ? void 0 : _a2.focus();
|
4223
|
-
}
|
4217
|
+
setShouldFocus(!viewMode);
|
4218
|
+
setViewMode(!viewMode);
|
4224
4219
|
},
|
4225
|
-
[readOnly]
|
4220
|
+
[readOnly, viewMode]
|
4226
4221
|
);
|
4222
|
+
React.useEffect(() => {
|
4223
|
+
var _a2;
|
4224
|
+
if (shouldFocus) {
|
4225
|
+
(_a2 = pillWrapperRef.current) == null ? void 0 : _a2.focus();
|
4226
|
+
setShouldFocus(false);
|
4227
|
+
}
|
4228
|
+
}, [shouldFocus]);
|
4227
4229
|
if (viewMode) {
|
4228
4230
|
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
4229
4231
|
className: css.cx(styles.combinedFilterPill, { [styles.readOnlyCombinedFilter]: readOnly }),
|