@grafana/scenes 5.14.2--canary.889.10737336517.0 → 5.14.2--canary.889.10738135842.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
|
|
1
1
|
import { cx, css } from '@emotion/css';
|
2
|
-
import { useStyles2, IconButton } from '@grafana/ui';
|
2
|
+
import { useStyles2, Tooltip, IconButton } from '@grafana/ui';
|
3
3
|
import React, { useState, useRef, useCallback, useEffect } from 'react';
|
4
4
|
import { AdHocCombobox } from './AdHocFiltersCombobox.js';
|
5
5
|
|
@@ -61,9 +61,15 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
|
|
61
61
|
"aria-label": `Edit filter with key ${keyLabel}`,
|
62
62
|
tabIndex: 0,
|
63
63
|
ref: pillWrapperRef
|
64
|
+
}, /* @__PURE__ */ React.createElement(Tooltip, {
|
65
|
+
show: valueLabel.length < 20 ? false : void 0,
|
66
|
+
content: /* @__PURE__ */ React.createElement("div", {
|
67
|
+
className: styles.tooltipText
|
68
|
+
}, valueLabel),
|
69
|
+
placement: "top"
|
64
70
|
}, /* @__PURE__ */ React.createElement("span", {
|
65
71
|
className: styles.pillText
|
66
|
-
}, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React.createElement(IconButton, {
|
72
|
+
}, keyLabel, " ", filter.operator, " ", valueLabel)), !readOnly ? /* @__PURE__ */ React.createElement(IconButton, {
|
67
73
|
onClick: (e) => {
|
68
74
|
e.stopPropagation();
|
69
75
|
model._removeFilter(filter);
|
@@ -123,7 +129,13 @@ const getStyles = (theme) => ({
|
|
123
129
|
}
|
124
130
|
}),
|
125
131
|
pillText: css({
|
126
|
-
|
132
|
+
maxWidth: "200px",
|
133
|
+
width: "100%",
|
134
|
+
textOverflow: "ellipsis",
|
135
|
+
overflow: "hidden"
|
136
|
+
}),
|
137
|
+
tooltipText: css({
|
138
|
+
textAlign: "center"
|
127
139
|
})
|
128
140
|
});
|
129
141
|
|
@@ -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, 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 focusOnInputRef?: () => void;\n}\n\nexport function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }: 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 // TODO remove when we're on the latest version of @grafana/data\n //@ts-expect-error\n const valueLabel = filter.valueLabels?.join(', ') || filter.values?.join(', ') || 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 className={styles.pillText}>\n
|
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, Tooltip } 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 focusOnInputRef?: () => void;\n}\n\nexport function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }: 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 // TODO remove when we're on the latest version of @grafana/data\n //@ts-expect-error\n const valueLabel = filter.valueLabels?.join(', ') || filter.values?.join(', ') || 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 <Tooltip\n show={valueLabel.length < 20 ? false : undefined}\n content={<div className={styles.tooltipText}>{valueLabel}</div>}\n placement=\"top\"\n >\n <span className={styles.pillText}>\n {keyLabel} {filter.operator} {valueLabel}\n </span>\n </Tooltip>\n {!readOnly ? (\n <IconButton\n onClick={(e) => {\n e.stopPropagation();\n model._removeFilter(filter);\n setTimeout(() => focusOnInputRef?.());\n }}\n onKeyDownCapture={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n e.stopPropagation();\n model._removeFilter(filter);\n setTimeout(() => focusOnInputRef?.());\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 pillText: css({\n maxWidth: '200px',\n width: '100%',\n textOverflow: 'ellipsis',\n overflow: 'hidden',\n }),\n tooltipText: css({\n textAlign: 'center',\n }),\n});\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAAS,gBAAgB,EAAE,MAAA,EAAQ,KAAO,EAAA,QAAA,EAAU,iBAA0B,EAAA;AAdrF,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAeE,EAAM,MAAA,MAAA,GAAS,WAAW,SAAS,CAAA,CAAA;AACnC,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CA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CAAA;;;;"}
|
package/dist/index.js
CHANGED
@@ -4549,9 +4549,15 @@ function AdHocFilterPill({ filter, model, readOnly, focusOnInputRef }) {
|
|
4549
4549
|
"aria-label": `Edit filter with key ${keyLabel}`,
|
4550
4550
|
tabIndex: 0,
|
4551
4551
|
ref: pillWrapperRef
|
4552
|
+
}, /* @__PURE__ */ React__default["default"].createElement(ui.Tooltip, {
|
4553
|
+
show: valueLabel.length < 20 ? false : void 0,
|
4554
|
+
content: /* @__PURE__ */ React__default["default"].createElement("div", {
|
4555
|
+
className: styles.tooltipText
|
4556
|
+
}, valueLabel),
|
4557
|
+
placement: "top"
|
4552
4558
|
}, /* @__PURE__ */ React__default["default"].createElement("span", {
|
4553
4559
|
className: styles.pillText
|
4554
|
-
}, keyLabel, " ", filter.operator, " ", valueLabel), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
|
4560
|
+
}, keyLabel, " ", filter.operator, " ", valueLabel)), !readOnly ? /* @__PURE__ */ React__default["default"].createElement(ui.IconButton, {
|
4555
4561
|
onClick: (e) => {
|
4556
4562
|
e.stopPropagation();
|
4557
4563
|
model._removeFilter(filter);
|
@@ -4611,7 +4617,13 @@ const getStyles$a = (theme) => ({
|
|
4611
4617
|
}
|
4612
4618
|
}),
|
4613
4619
|
pillText: css.css({
|
4614
|
-
|
4620
|
+
maxWidth: "200px",
|
4621
|
+
width: "100%",
|
4622
|
+
textOverflow: "ellipsis",
|
4623
|
+
overflow: "hidden"
|
4624
|
+
}),
|
4625
|
+
tooltipText: css.css({
|
4626
|
+
textAlign: "center"
|
4615
4627
|
})
|
4616
4628
|
});
|
4617
4629
|
|