@grafana/scenes 5.14.0 → 5.14.1--canary.890.10722192103.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ function VariableValueInput({ model }) {
21
21
  id: key,
22
22
  placeholder: "Enter value",
23
23
  minWidth: 15,
24
- defaultValue: value,
24
+ value,
25
25
  loading,
26
26
  onBlur,
27
27
  onKeyDown
@@ -1 +1 @@
1
- {"version":3,"file":"VariableValueInput.js","sources":["../../../../src/variables/components/VariableValueInput.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\n\nimport { AutoSizeInput } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { TextBoxVariable } from '../variants/TextBoxVariable';\n\nexport function VariableValueInput({ model }: SceneComponentProps<TextBoxVariable>) {\n const { value, key, loading } = model.useState();\n\n const onBlur = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n model.setValue(e.currentTarget.value);\n },\n [model]\n );\n\n const onKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n model.setValue(e.currentTarget.value);\n }\n },\n [model]\n );\n\n return (\n <AutoSizeInput\n id={key}\n placeholder=\"Enter value\"\n minWidth={15}\n defaultValue={value}\n loading={loading}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n />\n );\n}\n"],"names":[],"mappings":";;;AAOgB,SAAA,kBAAA,CAAmB,EAAE,KAAA,EAA+C,EAAA;AAClF,EAAA,MAAM,EAAE,KAAO,EAAA,GAAA,EAAK,OAAQ,EAAA,GAAI,MAAM,QAAS,EAAA,CAAA;AAE/C,EAAA,MAAM,MAAS,GAAA,WAAA;AAAA,IACb,CAAC,CAA2C,KAAA;AAC1C,MAAM,KAAA,CAAA,QAAA,CAAS,CAAE,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,KACtC;AAAA,IACA,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AAEA,EAAA,MAAM,SAAY,GAAA,WAAA;AAAA,IAChB,CAAC,CAA6C,KAAA;AAC5C,MAAI,IAAA,CAAA,CAAE,QAAQ,OAAS,EAAA;AACrB,QAAM,KAAA,CAAA,QAAA,CAAS,CAAE,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,OACtC;AAAA,KACF;AAAA,IACA,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AAEA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA;AAAA,IACC,EAAI,EAAA,GAAA;AAAA,IACJ,WAAY,EAAA,aAAA;AAAA,IACZ,QAAU,EAAA,EAAA;AAAA,IACV,YAAc,EAAA,KAAA;AAAA,IACd,OAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"VariableValueInput.js","sources":["../../../../src/variables/components/VariableValueInput.tsx"],"sourcesContent":["import React, { useCallback } from 'react';\n\nimport { AutoSizeInput } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { TextBoxVariable } from '../variants/TextBoxVariable';\n\nexport function VariableValueInput({ model }: SceneComponentProps<TextBoxVariable>) {\n const { value, key, loading } = model.useState();\n\n const onBlur = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n model.setValue(e.currentTarget.value);\n },\n [model]\n );\n\n const onKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'Enter') {\n model.setValue(e.currentTarget.value);\n }\n },\n [model]\n );\n\n return (\n <AutoSizeInput\n id={key}\n placeholder=\"Enter value\"\n minWidth={15}\n value={value}\n loading={loading}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n />\n );\n}\n"],"names":[],"mappings":";;;AAOgB,SAAA,kBAAA,CAAmB,EAAE,KAAA,EAA+C,EAAA;AAClF,EAAA,MAAM,EAAE,KAAO,EAAA,GAAA,EAAK,OAAQ,EAAA,GAAI,MAAM,QAAS,EAAA,CAAA;AAE/C,EAAA,MAAM,MAAS,GAAA,WAAA;AAAA,IACb,CAAC,CAA2C,KAAA;AAC1C,MAAM,KAAA,CAAA,QAAA,CAAS,CAAE,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,KACtC;AAAA,IACA,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AAEA,EAAA,MAAM,SAAY,GAAA,WAAA;AAAA,IAChB,CAAC,CAA6C,KAAA;AAC5C,MAAI,IAAA,CAAA,CAAE,QAAQ,OAAS,EAAA;AACrB,QAAM,KAAA,CAAA,QAAA,CAAS,CAAE,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AAAA,OACtC;AAAA,KACF;AAAA,IACA,CAAC,KAAK,CAAA;AAAA,GACR,CAAA;AAEA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA;AAAA,IACC,EAAI,EAAA,GAAA;AAAA,IACJ,WAAY,EAAA,aAAA;AAAA,IACZ,QAAU,EAAA,EAAA;AAAA,IACV,KAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,GACF,CAAA,CAAA;AAEJ;;;;"}
@@ -45,12 +45,10 @@ class TextBoxVariable extends SceneObjectBase {
45
45
  return { [this.getKey()]: this.state.value };
46
46
  }
47
47
  updateFromUrl(values) {
48
- const update = {};
49
48
  const val = values[this.getKey()];
50
49
  if (typeof val === "string") {
51
- update.value = val;
50
+ this.setValue(val);
52
51
  }
53
- this.setState(update);
54
52
  }
55
53
  }
56
54
  TextBoxVariable.Component = ({ model }) => {
@@ -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: () => [this.getKey()] });\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 getUrlState() {\n return { [this.getKey()]: this.state.value };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const update: Partial<TextBoxVariableState> = {};\n const val = values[this.getKey()];\n if (typeof val === 'string') {\n update.value = val;\n }\n\n this.setState(update);\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,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,SAAA;AAAA,MACN,KAAO,EAAA,EAAA;AAAA,MACP,IAAM,EAAA,EAAA;AAAA,KAAA,EACH,YACJ,CAAA,CAAA,CAAA;AAED,IAAA,IAAA,CAAK,QAAW,GAAA,IAAI,wBAAyB,CAAA,IAAA,EAAM,EAAE,IAAA,EAAM,MAAM,CAAC,IAAK,CAAA,MAAA,EAAQ,CAAA,EAAG,CAAA,CAAA;AAAA,GACpF;AAAA,EAEO,QAA0B,GAAA;AAC/B,IAAA,OAAO,KAAK,KAAM,CAAA,KAAA,CAAA;AAAA,GACpB;AAAA,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,CAAA;AACjC,MAAA,IAAA,CAAK,YAAa,CAAA,IAAI,8BAA+B,CAAA,IAAI,GAAG,IAAI,CAAA,CAAA;AAAA,KAClE;AAAA,GACF;AAAA,EAEQ,MAAiB,GAAA;AACvB,IAAO,OAAA,CAAA,IAAA,EAAO,KAAK,KAAM,CAAA,IAAA,CAAA,CAAA,CAAA;AAAA,GAC3B;AAAA,EAEO,WAAc,GAAA;AACnB,IAAA,OAAO,EAAE,CAAC,IAAA,CAAK,QAAW,GAAA,IAAA,CAAK,MAAM,KAAM,EAAA,CAAA;AAAA,GAC7C;AAAA,EAEO,cAAc,MAA8B,EAAA;AACjD,IAAA,MAAM,SAAwC,EAAC,CAAA;AAC/C,IAAM,MAAA,GAAA,GAAM,MAAO,CAAA,IAAA,CAAK,MAAO,EAAA,CAAA,CAAA;AAC/B,IAAI,IAAA,OAAO,QAAQ,QAAU,EAAA;AAC3B,MAAA,MAAA,CAAO,KAAQ,GAAA,GAAA,CAAA;AAAA,KACjB;AAEA,IAAA,IAAA,CAAK,SAAS,MAAM,CAAA,CAAA;AAAA,GACtB;AAKF,CAAA;AA/Ca,eAAA,CA4CG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAkD,KAAA;AAC7E,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,kBAAA,EAAA;AAAA,IAAmB,KAAA;AAAA,GAAc,CAAA,CAAA;AAC3C,CAAA;;;;"}
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.getKey()] });\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 getUrlState() {\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,cAAA,CAAA;AAAA,MACJ,IAAM,EAAA,SAAA;AAAA,MACN,KAAO,EAAA,EAAA;AAAA,MACP,IAAM,EAAA,EAAA;AAAA,KAAA,EACH,YACJ,CAAA,CAAA,CAAA;AAED,IAAA,IAAA,CAAK,QAAW,GAAA,IAAI,wBAAyB,CAAA,IAAA,EAAM,EAAE,IAAA,EAAM,MAAM,CAAC,IAAK,CAAA,MAAA,EAAQ,CAAA,EAAG,CAAA,CAAA;AAAA,GACpF;AAAA,EAEO,QAA0B,GAAA;AAC/B,IAAA,OAAO,KAAK,KAAM,CAAA,KAAA,CAAA;AAAA,GACpB;AAAA,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,CAAA;AACjC,MAAA,IAAA,CAAK,YAAa,CAAA,IAAI,8BAA+B,CAAA,IAAI,GAAG,IAAI,CAAA,CAAA;AAAA,KAClE;AAAA,GACF;AAAA,EAEQ,MAAiB,GAAA;AACvB,IAAO,OAAA,CAAA,IAAA,EAAO,KAAK,KAAM,CAAA,IAAA,CAAA,CAAA,CAAA;AAAA,GAC3B;AAAA,EAEO,WAAc,GAAA;AACnB,IAAA,OAAO,EAAE,CAAC,IAAA,CAAK,QAAW,GAAA,IAAA,CAAK,MAAM,KAAM,EAAA,CAAA;AAAA,GAC7C;AAAA,EAEO,cAAc,MAA8B,EAAA;AACjD,IAAM,MAAA,GAAA,GAAM,MAAO,CAAA,IAAA,CAAK,MAAO,EAAA,CAAA,CAAA;AAE/B,IAAI,IAAA,OAAO,QAAQ,QAAU,EAAA;AAC3B,MAAA,IAAA,CAAK,SAAS,GAAG,CAAA,CAAA;AAAA,KACnB;AAAA,GACF;AAKF,CAAA;AA7Ca,eAAA,CA0CG,SAAY,GAAA,CAAC,EAAE,KAAA,EAAkD,KAAA;AAC7E,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,kBAAA,EAAA;AAAA,IAAmB,KAAA;AAAA,GAAc,CAAA,CAAA;AAC3C,CAAA;;;;"}
package/dist/index.js CHANGED
@@ -8813,7 +8813,7 @@ function VariableValueInput({ model }) {
8813
8813
  id: key,
8814
8814
  placeholder: "Enter value",
8815
8815
  minWidth: 15,
8816
- defaultValue: value,
8816
+ value,
8817
8817
  loading,
8818
8818
  onBlur,
8819
8819
  onKeyDown
@@ -8861,12 +8861,10 @@ class TextBoxVariable extends SceneObjectBase {
8861
8861
  return { [this.getKey()]: this.state.value };
8862
8862
  }
8863
8863
  updateFromUrl(values) {
8864
- const update = {};
8865
8864
  const val = values[this.getKey()];
8866
8865
  if (typeof val === "string") {
8867
- update.value = val;
8866
+ this.setValue(val);
8868
8867
  }
8869
- this.setState(update);
8870
8868
  }
8871
8869
  }
8872
8870
  TextBoxVariable.Component = ({ model }) => {