@grafana/scenes 6.27.1 → 6.27.3--canary.1189.16466706909.0
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/CHANGELOG.md +17 -0
- package/dist/esm/components/VizPanel/VizPanelMenu.js +1 -0
- package/dist/esm/components/VizPanel/VizPanelMenu.js.map +1 -1
- package/dist/esm/core/SceneTimeRange.js +5 -1
- package/dist/esm/core/SceneTimeRange.js.map +1 -1
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +5 -5
- package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
- package/dist/esm/variables/interpolation/formatRegistry.js +30 -0
- package/dist/esm/variables/interpolation/formatRegistry.js.map +1 -1
- package/dist/esm/variables/variants/TextBoxVariable.js +10 -1
- package/dist/esm/variables/variants/TextBoxVariable.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +50 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -12,7 +12,7 @@ class TextBoxVariable extends SceneObjectBase {
|
|
|
12
12
|
name: "",
|
|
13
13
|
...initialState
|
|
14
14
|
});
|
|
15
|
-
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () =>
|
|
15
|
+
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () => this.getKeys() });
|
|
16
16
|
}
|
|
17
17
|
getValue() {
|
|
18
18
|
return this.state.value;
|
|
@@ -26,7 +26,16 @@ class TextBoxVariable extends SceneObjectBase {
|
|
|
26
26
|
getKey() {
|
|
27
27
|
return `var-${this.state.name}`;
|
|
28
28
|
}
|
|
29
|
+
getKeys() {
|
|
30
|
+
if (this.state.skipUrlSync) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
return [this.getKey()];
|
|
34
|
+
}
|
|
29
35
|
getUrlState() {
|
|
36
|
+
if (this.state.skipUrlSync) {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
30
39
|
return { [this.getKey()]: this.state.value };
|
|
31
40
|
}
|
|
32
41
|
updateFromUrl(values) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBoxVariable.js","sources":["../../../../src/variables/variants/TextBoxVariable.tsx"],"sourcesContent":["import React from 'react';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObjectUrlValues } from '../../core/types';\nimport { SceneObjectUrlSyncConfig } from '../../services/SceneObjectUrlSyncConfig';\nimport { VariableValueInput } from '../components/VariableValueInput';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\n\nexport interface TextBoxVariableState extends SceneVariableState {\n value: string;\n}\n\nexport class TextBoxVariable\n extends SceneObjectBase<TextBoxVariableState>\n implements SceneVariable<TextBoxVariableState>\n{\n public constructor(initialState: Partial<TextBoxVariableState>) {\n super({\n type: 'textbox',\n value: '',\n name: '',\n ...initialState,\n });\n\n this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () =>
|
|
1
|
+
{"version":3,"file":"TextBoxVariable.js","sources":["../../../../src/variables/variants/TextBoxVariable.tsx"],"sourcesContent":["import React from 'react';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObjectUrlValues } from '../../core/types';\nimport { SceneObjectUrlSyncConfig } from '../../services/SceneObjectUrlSyncConfig';\nimport { VariableValueInput } from '../components/VariableValueInput';\nimport { SceneVariable, SceneVariableState, SceneVariableValueChangedEvent, VariableValue } from '../types';\n\nexport interface TextBoxVariableState extends SceneVariableState {\n value: string;\n}\n\nexport class TextBoxVariable\n extends SceneObjectBase<TextBoxVariableState>\n implements SceneVariable<TextBoxVariableState>\n{\n public constructor(initialState: Partial<TextBoxVariableState>) {\n super({\n type: 'textbox',\n value: '',\n name: '',\n ...initialState,\n });\n\n this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () => this.getKeys() });\n }\n\n public getValue(): VariableValue {\n return this.state.value;\n }\n\n public setValue(newValue: string) {\n if (newValue !== this.state.value) {\n this.setState({ value: newValue });\n this.publishEvent(new SceneVariableValueChangedEvent(this), true);\n }\n }\n\n private getKey(): string {\n return `var-${this.state.name}`;\n }\n\n public getKeys(): string[] {\n if (this.state.skipUrlSync) {\n return [];\n }\n\n return [this.getKey()];\n }\n\n public getUrlState() {\n if (this.state.skipUrlSync) {\n return {};\n }\n\n return { [this.getKey()]: this.state.value };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const val = values[this.getKey()];\n\n if (typeof val === 'string') {\n this.setValue(val);\n }\n }\n\n public static Component = ({ model }: SceneComponentProps<TextBoxVariable>) => {\n return <VariableValueInput model={model} />;\n };\n}\n"],"names":[],"mappings":";;;;;;AAWO,MAAM,wBACH,eAEV,CAAA;AAAA,EACS,YAAY,YAA6C,EAAA;AAC9D,IAAM,KAAA,CAAA;AAAA,MACJ,IAAM,EAAA,SAAA;AAAA,MACN,KAAO,EAAA,EAAA;AAAA,MACP,IAAM,EAAA,EAAA;AAAA,MACN,GAAG;AAAA,KACJ,CAAA;AAED,IAAK,IAAA,CAAA,QAAA,GAAW,IAAI,wBAAA,CAAyB,IAAM,EAAA,EAAE,MAAM,MAAM,IAAA,CAAK,OAAQ,EAAA,EAAG,CAAA;AAAA;AACnF,EAEO,QAA0B,GAAA;AAC/B,IAAA,OAAO,KAAK,KAAM,CAAA,KAAA;AAAA;AACpB,EAEO,SAAS,QAAkB,EAAA;AAChC,IAAI,IAAA,QAAA,KAAa,IAAK,CAAA,KAAA,CAAM,KAAO,EAAA;AACjC,MAAA,IAAA,CAAK,QAAS,CAAA,EAAE,KAAO,EAAA,QAAA,EAAU,CAAA;AACjC,MAAA,IAAA,CAAK,YAAa,CAAA,IAAI,8BAA+B,CAAA,IAAI,GAAG,IAAI,CAAA;AAAA;AAClE;AACF,EAEQ,MAAiB,GAAA;AACvB,IAAO,OAAA,CAAA,IAAA,EAAO,IAAK,CAAA,KAAA,CAAM,IAAI,CAAA,CAAA;AAAA;AAC/B,EAEO,OAAoB,GAAA;AACzB,IAAI,IAAA,IAAA,CAAK,MAAM,WAAa,EAAA;AAC1B,MAAA,OAAO,EAAC;AAAA;AAGV,IAAO,OAAA,CAAC,IAAK,CAAA,MAAA,EAAQ,CAAA;AAAA;AACvB,EAEO,WAAc,GAAA;AACnB,IAAI,IAAA,IAAA,CAAK,MAAM,WAAa,EAAA;AAC1B,MAAA,OAAO,EAAC;AAAA;AAGV,IAAO,OAAA,EAAE,CAAC,IAAK,CAAA,MAAA,EAAQ,GAAG,IAAA,CAAK,MAAM,KAAM,EAAA;AAAA;AAC7C,EAEO,cAAc,MAA8B,EAAA;AACjD,IAAA,MAAM,GAAM,GAAA,MAAA,CAAO,IAAK,CAAA,MAAA,EAAQ,CAAA;AAEhC,IAAI,IAAA,OAAO,QAAQ,QAAU,EAAA;AAC3B,MAAA,IAAA,CAAK,SAAS,GAAG,CAAA;AAAA;AACnB;AAMJ;AAzDa,eAAA,CAsDG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAkD,KAAA;AAC7E,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,sBAAmB,KAAc,EAAA,CAAA;AAC3C,CAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1152,6 +1152,7 @@ declare class TextBoxVariable extends SceneObjectBase<TextBoxVariableState> impl
|
|
|
1152
1152
|
getValue(): VariableValue;
|
|
1153
1153
|
setValue(newValue: string): void;
|
|
1154
1154
|
private getKey;
|
|
1155
|
+
getKeys(): string[];
|
|
1155
1156
|
getUrlState(): {
|
|
1156
1157
|
[x: string]: string;
|
|
1157
1158
|
};
|
package/dist/index.js
CHANGED
|
@@ -1214,9 +1214,12 @@ function getTimeWindow(time, timeWindow) {
|
|
|
1214
1214
|
};
|
|
1215
1215
|
}
|
|
1216
1216
|
function getValidTimeZone(timeZone) {
|
|
1217
|
-
if (timeZone === void 0
|
|
1217
|
+
if (timeZone === void 0) {
|
|
1218
1218
|
return void 0;
|
|
1219
1219
|
}
|
|
1220
|
+
if (lodash.isEmpty(timeZone)) {
|
|
1221
|
+
return runtime.config.bootData.user.timezone;
|
|
1222
|
+
}
|
|
1220
1223
|
if (timeZone === schema.defaultTimeZone) {
|
|
1221
1224
|
return timeZone;
|
|
1222
1225
|
}
|
|
@@ -1504,6 +1507,20 @@ const formatRegistry = new data.Registry(() => {
|
|
|
1504
1507
|
description: "SQL string quoting and commas for use in IN statements and other scenarios",
|
|
1505
1508
|
formatter: sqlStringFormatter
|
|
1506
1509
|
},
|
|
1510
|
+
{
|
|
1511
|
+
id: "join",
|
|
1512
|
+
// join not yet available in depended @grafana/schema version
|
|
1513
|
+
name: "Join",
|
|
1514
|
+
description: "Join values with a comma",
|
|
1515
|
+
formatter: (value, args) => {
|
|
1516
|
+
var _a;
|
|
1517
|
+
if (lodash.isArray(value)) {
|
|
1518
|
+
const separator = (_a = args[0]) != null ? _a : ",";
|
|
1519
|
+
return value.join(separator);
|
|
1520
|
+
}
|
|
1521
|
+
return String(value);
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1507
1524
|
{
|
|
1508
1525
|
id: schema.VariableFormatID.Date,
|
|
1509
1526
|
name: "Date",
|
|
@@ -1578,6 +1595,19 @@ const formatRegistry = new data.Registry(() => {
|
|
|
1578
1595
|
return formatQueryParameter(variable.state.name, value);
|
|
1579
1596
|
}
|
|
1580
1597
|
},
|
|
1598
|
+
{
|
|
1599
|
+
id: "customqueryparam",
|
|
1600
|
+
name: "Custom query parameter",
|
|
1601
|
+
description: "Format variables as URL parameters with custom name and value prefix. Example in multi-variable scenario A + B + C => p-foo=x-A&p-foo=x-B&p-foo=x-C.",
|
|
1602
|
+
formatter: (value, args, variable) => {
|
|
1603
|
+
const name = encodeURIComponentStrict(args[0] || variable.state.name);
|
|
1604
|
+
const valuePrefix = encodeURIComponentStrict(args[1] || "");
|
|
1605
|
+
if (Array.isArray(value)) {
|
|
1606
|
+
return value.map((v) => customFormatQueryParameter(name, v, valuePrefix)).join("&");
|
|
1607
|
+
}
|
|
1608
|
+
return customFormatQueryParameter(name, value, valuePrefix);
|
|
1609
|
+
}
|
|
1610
|
+
},
|
|
1581
1611
|
{
|
|
1582
1612
|
id: schema.VariableFormatID.UriEncode,
|
|
1583
1613
|
name: "Percent encode as URI",
|
|
@@ -1614,6 +1644,9 @@ const replaceSpecialCharactersToASCII = (value) => value.replace(/[!'()*]/g, (c)
|
|
|
1614
1644
|
function formatQueryParameter(name, value) {
|
|
1615
1645
|
return `var-${name}=${encodeURIComponentStrict(value)}`;
|
|
1616
1646
|
}
|
|
1647
|
+
function customFormatQueryParameter(name, value, valuePrefix = "") {
|
|
1648
|
+
return `${name}=${valuePrefix}${encodeURIComponentStrict(value)}`;
|
|
1649
|
+
}
|
|
1617
1650
|
const SQL_ESCAPE_MAP = {
|
|
1618
1651
|
"'": "''",
|
|
1619
1652
|
'"': '\\"'
|
|
@@ -5681,7 +5714,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5681
5714
|
}
|
|
5682
5715
|
(_e = this.state.originFilters) == null ? void 0 : _e.forEach((filter) => {
|
|
5683
5716
|
var _a2;
|
|
5684
|
-
this._originalValues.set(filter.key
|
|
5717
|
+
this._originalValues.set(`${filter.key}-${filter.origin}`, {
|
|
5685
5718
|
operator: filter.operator,
|
|
5686
5719
|
value: (_a2 = filter.values) != null ? _a2 : [filter.value]
|
|
5687
5720
|
});
|
|
@@ -5706,7 +5739,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5706
5739
|
const remainingFilters = [];
|
|
5707
5740
|
finalFilters.forEach((scopeFilter) => {
|
|
5708
5741
|
var _a2;
|
|
5709
|
-
this._originalValues.set(scopeFilter.key
|
|
5742
|
+
this._originalValues.set(`${scopeFilter.key}-${scopeFilter.origin}`, {
|
|
5710
5743
|
value: (_a2 = scopeFilter.values) != null ? _a2 : [scopeFilter.value],
|
|
5711
5744
|
operator: scopeFilter.operator
|
|
5712
5745
|
});
|
|
@@ -5777,7 +5810,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5777
5810
|
restorable: false
|
|
5778
5811
|
};
|
|
5779
5812
|
if (filter.restorable) {
|
|
5780
|
-
const originalFilter = this._originalValues.get(filter.key);
|
|
5813
|
+
const originalFilter = this._originalValues.get(`${filter.key}-${filter.origin}`);
|
|
5781
5814
|
if (!originalFilter) {
|
|
5782
5815
|
return;
|
|
5783
5816
|
}
|
|
@@ -5796,7 +5829,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5796
5829
|
var _a;
|
|
5797
5830
|
const { originFilters, filters, _wip } = this.state;
|
|
5798
5831
|
if (filter.origin) {
|
|
5799
|
-
const originalValues = this._originalValues.get(filter.key);
|
|
5832
|
+
const originalValues = this._originalValues.get(`${filter.key}-${filter.origin}`);
|
|
5800
5833
|
const updateValues = update.values || (update.value ? [update.value] : void 0);
|
|
5801
5834
|
if (updateValues && !lodash.isEqual(updateValues, originalValues == null ? void 0 : originalValues.value) || update.operator && update.operator !== (originalValues == null ? void 0 : originalValues.operator)) {
|
|
5802
5835
|
update.restorable = true;
|
|
@@ -5926,7 +5959,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
|
|
|
5926
5959
|
if (!f.matchAllFilter) {
|
|
5927
5960
|
f.nonApplicable = true;
|
|
5928
5961
|
}
|
|
5929
|
-
const originalValue = this._originalValues.get(f.key);
|
|
5962
|
+
const originalValue = this._originalValues.get(`${f.key}-${f.origin}`);
|
|
5930
5963
|
if (originalValue) {
|
|
5931
5964
|
originalValue.nonApplicable = true;
|
|
5932
5965
|
}
|
|
@@ -10443,7 +10476,7 @@ class TextBoxVariable extends SceneObjectBase {
|
|
|
10443
10476
|
name: "",
|
|
10444
10477
|
...initialState
|
|
10445
10478
|
});
|
|
10446
|
-
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () =>
|
|
10479
|
+
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: () => this.getKeys() });
|
|
10447
10480
|
}
|
|
10448
10481
|
getValue() {
|
|
10449
10482
|
return this.state.value;
|
|
@@ -10457,7 +10490,16 @@ class TextBoxVariable extends SceneObjectBase {
|
|
|
10457
10490
|
getKey() {
|
|
10458
10491
|
return `var-${this.state.name}`;
|
|
10459
10492
|
}
|
|
10493
|
+
getKeys() {
|
|
10494
|
+
if (this.state.skipUrlSync) {
|
|
10495
|
+
return [];
|
|
10496
|
+
}
|
|
10497
|
+
return [this.getKey()];
|
|
10498
|
+
}
|
|
10460
10499
|
getUrlState() {
|
|
10500
|
+
if (this.state.skipUrlSync) {
|
|
10501
|
+
return {};
|
|
10502
|
+
}
|
|
10461
10503
|
return { [this.getKey()]: this.state.value };
|
|
10462
10504
|
}
|
|
10463
10505
|
updateFromUrl(values) {
|
|
@@ -10886,6 +10928,7 @@ function VizPanelMenuRenderer({ model }) {
|
|
|
10886
10928
|
ui.Menu.Item,
|
|
10887
10929
|
{
|
|
10888
10930
|
key: item.text,
|
|
10931
|
+
role: "menuitem",
|
|
10889
10932
|
label: item.text,
|
|
10890
10933
|
icon: item.iconClassName,
|
|
10891
10934
|
childItems: item.subMenu ? renderItems(item.subMenu) : void 0,
|