@grafana/scenes 5.24.0--canary.956.11776448023.0 → 5.24.0--canary.956.11779891409.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,7 +54,7 @@ function toSelectableValue(value, label) {
54
54
  };
55
55
  }
56
56
  function VariableValueSelect({ model }) {
57
- const { value, text, key, options, includeAll, isReadOnly, allowCustomValue } = model.useState();
57
+ const { value, text, key, options, includeAll, isReadOnly, allowCustomValue = true } = model.useState();
58
58
  const [inputValue, setInputValue] = useState("");
59
59
  const [hasCustomValue, setHasCustomValue] = useState(false);
60
60
  const selectValue = toSelectableValue(value, String(text));
@@ -86,7 +86,7 @@ function VariableValueSelect({ model }) {
86
86
  disabled: isReadOnly,
87
87
  value: selectValue,
88
88
  inputValue,
89
- allowCustomValue: allowCustomValue != null ? allowCustomValue : true,
89
+ allowCustomValue,
90
90
  virtualized: true,
91
91
  filterOption: filterNoOp,
92
92
  tabSelectsValue: false,
@@ -104,7 +104,7 @@ function VariableValueSelect({ model }) {
104
104
  });
105
105
  }
106
106
  function VariableValueSelectMulti({ model }) {
107
- const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue } = model.useState();
107
+ const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue = true } = model.useState();
108
108
  const arrayValue = useMemo(() => isArray(value) ? value : [value], [value]);
109
109
  const [uncommittedValue, setUncommittedValue] = useState(arrayValue);
110
110
  const [inputValue, setInputValue] = useState("");
@@ -139,7 +139,7 @@ function VariableValueSelectMulti({ model }) {
139
139
  maxVisibleValues: maxVisibleValues != null ? maxVisibleValues : 5,
140
140
  tabSelectsValue: false,
141
141
  virtualized: true,
142
- allowCustomValue: allowCustomValue != null ? allowCustomValue : true,
142
+ allowCustomValue,
143
143
  toggleAllOptions: {
144
144
  enabled: true,
145
145
  optionsFilter: filterAll,
@@ -1 +1 @@
1
- {"version":3,"file":"VariableValueSelect.js","sources":["../../../../src/variables/components/VariableValueSelect.tsx"],"sourcesContent":["import { isArray } from 'lodash';\nimport React, { RefCallback, useEffect, useMemo, useState } from 'react';\n\n//@ts-ignore\nimport { Checkbox, InputActionMeta, MultiSelect, Select, ToggleAllState, getSelectStyles, useStyles2, useTheme2 } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { MultiValueVariable } from '../variants/MultiValueVariable';\nimport { VariableValue, VariableValueSingle } from '../types';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { getOptionSearcher } from './getOptionSearcher';\n\nconst filterNoOp = () => true;\n\nconst filterAll = (v: SelectableValue<VariableValueSingle>) => v.value !== '$__all'\n\nconst determineToggleAllState = (\n selectedValues: Array<SelectableValue<VariableValueSingle>>,\n options: Array<SelectableValue<VariableValueSingle>>\n) => {\n if (selectedValues.length === options.filter(filterAll).length) {\n return ToggleAllState.allSelected;\n } else if (\n selectedValues.length === 0 ||\n (selectedValues.length === 1 && selectedValues[0] && selectedValues[0].value === '$__all')\n ) {\n return ToggleAllState.noneSelected;\n } else {\n return ToggleAllState.indeterminate;\n }\n};\n\nexport function toSelectableValue<T>(value: T, label?: string): SelectableValue<T> {\n return {\n value,\n label: label ?? String(value),\n };\n}\n\nexport function VariableValueSelect({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, text, key, options, includeAll, isReadOnly, allowCustomValue } = model.useState();\n const [inputValue, setInputValue] = useState('');\n const [hasCustomValue, setHasCustomValue] = useState(false);\n const selectValue = toSelectableValue(value, String(text));\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n return value;\n };\n\n const filteredOptions = optionSearcher(inputValue);\n\n const onOpenMenu = () => {\n if (hasCustomValue) {\n setInputValue(String(text));\n }\n };\n\n const onCloseMenu = () => {\n setInputValue('');\n };\n\n return (\n <Select<VariableValue>\n id={key}\n isValidNewOption={(inputValue) => inputValue.trim().length > 0}\n placeholder=\"Select value\"\n width=\"auto\"\n disabled={isReadOnly}\n value={selectValue}\n inputValue={inputValue}\n allowCustomValue={allowCustomValue ?? true}\n virtualized\n filterOption={filterNoOp}\n tabSelectsValue={false}\n onInputChange={onInputChange}\n onOpenMenu={onOpenMenu}\n onCloseMenu={onCloseMenu}\n options={filteredOptions}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`)}\n onChange={(newValue) => {\n model.changeValueTo(newValue.value!, newValue.label!);\n\n if (hasCustomValue !== newValue.__isNew__) {\n setHasCustomValue(newValue.__isNew__);\n }\n }}\n />\n );\n}\n\nexport function VariableValueSelectMulti({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue } = model.useState();\n const arrayValue = useMemo(() => (isArray(value) ? value : [value]), [value]);\n // To not trigger queries on every selection we store this state locally here and only update the variable onBlur\n const [uncommittedValue, setUncommittedValue] = useState(arrayValue);\n const [inputValue, setInputValue] = useState('');\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n // Detect value changes outside\n useEffect(() => {\n setUncommittedValue(arrayValue);\n }, [arrayValue]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n if (action === 'input-blur') {\n setInputValue('');\n return '';\n }\n\n return inputValue;\n };\n\n const placeholder = options.length > 0 ? 'Select value' : '';\n const filteredOptions = optionSearcher(inputValue);\n\n return (\n <MultiSelect<VariableValueSingle>\n id={key}\n placeholder={placeholder}\n width=\"auto\"\n inputValue={inputValue}\n disabled={isReadOnly}\n value={uncommittedValue}\n noMultiValueWrap={true}\n maxVisibleValues={maxVisibleValues ?? 5}\n tabSelectsValue={false}\n virtualized\n allowCustomValue={allowCustomValue ?? true}\n //@ts-ignore\n toggleAllOptions={{\n enabled: true,\n optionsFilter: filterAll,\n determineToggleAllState: determineToggleAllState,\n }}\n options={filteredOptions}\n closeMenuOnSelect={false}\n components={{ Option: OptionWithCheckbox }}\n isClearable={true}\n hideSelectedOptions={false}\n onInputChange={onInputChange}\n onBlur={() => {\n model.changeValueTo(uncommittedValue);\n }}\n filterOption={filterNoOp}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`)}\n onChange={(newValue, action) => {\n if (action.action === 'clear' && noValueOnClear) {\n model.changeValueTo([]);\n }\n setUncommittedValue(newValue.map((x) => x.value!));\n }}\n />\n );\n}\n\ninterface SelectMenuOptionProps<T> {\n isDisabled: boolean;\n isFocused: boolean;\n isSelected: boolean;\n innerProps: JSX.IntrinsicElements['div'];\n innerRef: RefCallback<HTMLDivElement>;\n renderOptionLabel?: (value: SelectableValue<T>) => JSX.Element;\n data: SelectableValue<T>;\n indeterminate: boolean; \n}\n\nexport const OptionWithCheckbox = ({\n children,\n data,\n innerProps,\n innerRef,\n isFocused,\n isSelected,\n indeterminate,\n renderOptionLabel,\n}: React.PropsWithChildren<SelectMenuOptionProps<unknown>>) => {\n // We are removing onMouseMove and onMouseOver from innerProps because they cause the whole\n // list to re-render everytime the user hovers over an option. This is a performance issue.\n // See https://github.com/JedWatson/react-select/issues/3128#issuecomment-451936743\n const { onMouseMove, onMouseOver, ...rest } = innerProps;\n const theme = useTheme2();\n const selectStyles = getSelectStyles(theme);\n const optionStyles = useStyles2(getOptionStyles);\n\n return (\n <div\n ref={innerRef}\n className={cx(selectStyles.option, isFocused && selectStyles.optionFocused)}\n {...rest}\n // TODO: use below selector once we update grafana dependencies to ^11.1.0\n // data-testid={selectors.components.Select.option}\n data-testid=\"data-testid Select option\"\n title={data.title}\n >\n <div className={optionStyles.checkbox}>\n <Checkbox indeterminate={indeterminate} value={isSelected} />\n </div>\n <div\n className={selectStyles.optionBody}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(\n data.label ?? String(data.value)\n )}\n >\n <span>{children}</span>\n </div>\n </div>\n );\n};\n\nOptionWithCheckbox.displayName = 'SelectMenuOptions';\n\nconst getOptionStyles = (theme: GrafanaTheme2) => ({\n checkbox: css({\n marginRight: theme.spacing(2),\n }),\n});\n\nexport function renderSelectForVariable(model: MultiValueVariable) {\n if (model.state.isMulti) {\n return <VariableValueSelectMulti model={model} />;\n } else {\n return <VariableValueSelect model={model} />;\n }\n}\n"],"names":["value","inputValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,aAAa,MAAM,IAAA,CAAA;AAEzB,MAAM,SAAY,GAAA,CAAC,CAA4C,KAAA,CAAA,CAAE,KAAU,KAAA,QAAA,CAAA;AAE3E,MAAM,uBAAA,GAA0B,CAC9B,cAAA,EACA,OACG,KAAA;AACH,EAAA,IAAI,eAAe,MAAW,KAAA,OAAA,CAAQ,MAAO,CAAA,SAAS,EAAE,MAAQ,EAAA;AAC9D,IAAA,OAAO,cAAe,CAAA,WAAA,CAAA;AAAA,GAEtB,MAAA,IAAA,cAAA,CAAe,MAAW,KAAA,CAAA,IACzB,cAAe,CAAA,MAAA,KAAW,CAAK,IAAA,cAAA,CAAe,CAAM,CAAA,IAAA,cAAA,CAAe,CAAG,CAAA,CAAA,KAAA,KAAU,QACjF,EAAA;AACA,IAAA,OAAO,cAAe,CAAA,YAAA,CAAA;AAAA,GACjB,MAAA;AACL,IAAA,OAAO,cAAe,CAAA,aAAA,CAAA;AAAA,GACxB;AACF,CAAA,CAAA;AAEgB,SAAA,iBAAA,CAAqB,OAAU,KAAoC,EAAA;AACjF,EAAO,OAAA;AAAA,IACL,KAAA;AAAA,IACA,KAAA,EAAO,KAAS,IAAA,IAAA,GAAA,KAAA,GAAA,MAAA,CAAO,KAAK,CAAA;AAAA,GAC9B,CAAA;AACF,C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,KACjC;AAAA,GAAA,kBAEC,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EAAM,QAAS,CAClB,CACF,CAAA,CAAA;AAEJ,EAAA;AAEA,kBAAA,CAAmB,WAAc,GAAA,mBAAA,CAAA;AAEjC,MAAM,eAAA,GAAkB,CAAC,KAA0B,MAAA;AAAA,EACjD,UAAU,GAAI,CAAA;AAAA,IACZ,WAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,CAAC,CAAA;AAAA,GAC7B,CAAA;AACH,CAAA,CAAA,CAAA;AAEO,SAAS,wBAAwB,KAA2B,EAAA;AACjE,EAAI,IAAA,KAAA,CAAM,MAAM,OAAS,EAAA;AACvB,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,wBAAA,EAAA;AAAA,MAAyB,KAAA;AAAA,KAAc,CAAA,CAAA;AAAA,GAC1C,MAAA;AACL,IAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA;AAAA,MAAoB,KAAA;AAAA,KAAc,CAAA,CAAA;AAAA,GAC5C;AACF;;;;"}
1
+ {"version":3,"file":"VariableValueSelect.js","sources":["../../../../src/variables/components/VariableValueSelect.tsx"],"sourcesContent":["import { isArray } from 'lodash';\nimport React, { RefCallback, useEffect, useMemo, useState } from 'react';\n\n//@ts-ignore\nimport { Checkbox, InputActionMeta, MultiSelect, Select, ToggleAllState, getSelectStyles, useStyles2, useTheme2 } from '@grafana/ui';\n\nimport { SceneComponentProps } from '../../core/types';\nimport { MultiValueVariable } from '../variants/MultiValueVariable';\nimport { VariableValue, VariableValueSingle } from '../types';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { GrafanaTheme2, SelectableValue } from '@grafana/data';\nimport { css, cx } from '@emotion/css';\nimport { getOptionSearcher } from './getOptionSearcher';\n\nconst filterNoOp = () => true;\n\nconst filterAll = (v: SelectableValue<VariableValueSingle>) => v.value !== '$__all'\n\nconst determineToggleAllState = (\n selectedValues: Array<SelectableValue<VariableValueSingle>>,\n options: Array<SelectableValue<VariableValueSingle>>\n) => {\n if (selectedValues.length === options.filter(filterAll).length) {\n return ToggleAllState.allSelected;\n } else if (\n selectedValues.length === 0 ||\n (selectedValues.length === 1 && selectedValues[0] && selectedValues[0].value === '$__all')\n ) {\n return ToggleAllState.noneSelected;\n } else {\n return ToggleAllState.indeterminate;\n }\n};\n\nexport function toSelectableValue<T>(value: T, label?: string): SelectableValue<T> {\n return {\n value,\n label: label ?? String(value),\n };\n}\n\nexport function VariableValueSelect({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, text, key, options, includeAll, isReadOnly, allowCustomValue = true } = model.useState();\n const [inputValue, setInputValue] = useState('');\n const [hasCustomValue, setHasCustomValue] = useState(false);\n const selectValue = toSelectableValue(value, String(text));\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n return value;\n };\n\n const filteredOptions = optionSearcher(inputValue);\n\n const onOpenMenu = () => {\n if (hasCustomValue) {\n setInputValue(String(text));\n }\n };\n\n const onCloseMenu = () => {\n setInputValue('');\n };\n\n return (\n <Select<VariableValue>\n id={key}\n isValidNewOption={(inputValue) => inputValue.trim().length > 0}\n placeholder=\"Select value\"\n width=\"auto\"\n disabled={isReadOnly}\n value={selectValue}\n inputValue={inputValue}\n allowCustomValue={allowCustomValue}\n virtualized\n filterOption={filterNoOp}\n tabSelectsValue={false}\n onInputChange={onInputChange}\n onOpenMenu={onOpenMenu}\n onCloseMenu={onCloseMenu}\n options={filteredOptions}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`)}\n onChange={(newValue) => {\n model.changeValueTo(newValue.value!, newValue.label!);\n\n if (hasCustomValue !== newValue.__isNew__) {\n setHasCustomValue(newValue.__isNew__);\n }\n }}\n />\n );\n}\n\nexport function VariableValueSelectMulti({ model }: SceneComponentProps<MultiValueVariable>) {\n const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue = true } = model.useState();\n const arrayValue = useMemo(() => (isArray(value) ? value : [value]), [value]);\n // To not trigger queries on every selection we store this state locally here and only update the variable onBlur\n const [uncommittedValue, setUncommittedValue] = useState(arrayValue);\n const [inputValue, setInputValue] = useState('');\n\n const optionSearcher = useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);\n\n // Detect value changes outside\n useEffect(() => {\n setUncommittedValue(arrayValue);\n }, [arrayValue]);\n\n const onInputChange = (value: string, { action }: InputActionMeta) => {\n if (action === 'input-change') {\n setInputValue(value);\n if (model.onSearchChange) {\n model.onSearchChange!(value);\n }\n return value;\n }\n\n if (action === 'input-blur') {\n setInputValue('');\n return '';\n }\n\n return inputValue;\n };\n\n const placeholder = options.length > 0 ? 'Select value' : '';\n const filteredOptions = optionSearcher(inputValue);\n\n return (\n <MultiSelect<VariableValueSingle>\n id={key}\n placeholder={placeholder}\n width=\"auto\"\n inputValue={inputValue}\n disabled={isReadOnly}\n value={uncommittedValue}\n noMultiValueWrap={true}\n maxVisibleValues={maxVisibleValues ?? 5}\n tabSelectsValue={false}\n virtualized\n allowCustomValue={allowCustomValue}\n //@ts-ignore\n toggleAllOptions={{\n enabled: true,\n optionsFilter: filterAll,\n determineToggleAllState: determineToggleAllState,\n }}\n options={filteredOptions}\n closeMenuOnSelect={false}\n components={{ Option: OptionWithCheckbox }}\n isClearable={true}\n hideSelectedOptions={false}\n onInputChange={onInputChange}\n onBlur={() => {\n model.changeValueTo(uncommittedValue);\n }}\n filterOption={filterNoOp}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`)}\n onChange={(newValue, action) => {\n if (action.action === 'clear' && noValueOnClear) {\n model.changeValueTo([]);\n }\n setUncommittedValue(newValue.map((x) => x.value!));\n }}\n />\n );\n}\n\ninterface SelectMenuOptionProps<T> {\n isDisabled: boolean;\n isFocused: boolean;\n isSelected: boolean;\n innerProps: JSX.IntrinsicElements['div'];\n innerRef: RefCallback<HTMLDivElement>;\n renderOptionLabel?: (value: SelectableValue<T>) => JSX.Element;\n data: SelectableValue<T>;\n indeterminate: boolean; \n}\n\nexport const OptionWithCheckbox = ({\n children,\n data,\n innerProps,\n innerRef,\n isFocused,\n isSelected,\n indeterminate,\n renderOptionLabel,\n}: React.PropsWithChildren<SelectMenuOptionProps<unknown>>) => {\n // We are removing onMouseMove and onMouseOver from innerProps because they cause the whole\n // list to re-render everytime the user hovers over an option. This is a performance issue.\n // See https://github.com/JedWatson/react-select/issues/3128#issuecomment-451936743\n const { onMouseMove, onMouseOver, ...rest } = innerProps;\n const theme = useTheme2();\n const selectStyles = getSelectStyles(theme);\n const optionStyles = useStyles2(getOptionStyles);\n\n return (\n <div\n ref={innerRef}\n className={cx(selectStyles.option, isFocused && selectStyles.optionFocused)}\n {...rest}\n // TODO: use below selector once we update grafana dependencies to ^11.1.0\n // data-testid={selectors.components.Select.option}\n data-testid=\"data-testid Select option\"\n title={data.title}\n >\n <div className={optionStyles.checkbox}>\n <Checkbox indeterminate={indeterminate} value={isSelected} />\n </div>\n <div\n className={selectStyles.optionBody}\n data-testid={selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownOptionTexts(\n data.label ?? String(data.value)\n )}\n >\n <span>{children}</span>\n </div>\n </div>\n );\n};\n\nOptionWithCheckbox.displayName = 'SelectMenuOptions';\n\nconst getOptionStyles = (theme: GrafanaTheme2) => ({\n checkbox: css({\n marginRight: theme.spacing(2),\n }),\n});\n\nexport function renderSelectForVariable(model: MultiValueVariable) {\n if (model.state.isMulti) {\n return <VariableValueSelectMulti model={model} />;\n } else {\n return <VariableValueSelect model={model} />;\n }\n}\n"],"names":["value","inputValue"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAM,aAAa,MAAM,IAAA,CAAA;AAEzB,MAAM,SAA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AA,uBAAQ,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA;AAAA,MAAoB,KAAA;AAAA,KAAc,CAAA,CAAA;AAAA,GAC5C;AACF;;;;"}
package/dist/index.js CHANGED
@@ -2596,7 +2596,7 @@ function toSelectableValue$2(value, label) {
2596
2596
  };
2597
2597
  }
2598
2598
  function VariableValueSelect({ model }) {
2599
- const { value, text, key, options, includeAll, isReadOnly, allowCustomValue } = model.useState();
2599
+ const { value, text, key, options, includeAll, isReadOnly, allowCustomValue = true } = model.useState();
2600
2600
  const [inputValue, setInputValue] = React.useState("");
2601
2601
  const [hasCustomValue, setHasCustomValue] = React.useState(false);
2602
2602
  const selectValue = toSelectableValue$2(value, String(text));
@@ -2628,7 +2628,7 @@ function VariableValueSelect({ model }) {
2628
2628
  disabled: isReadOnly,
2629
2629
  value: selectValue,
2630
2630
  inputValue,
2631
- allowCustomValue: allowCustomValue != null ? allowCustomValue : true,
2631
+ allowCustomValue,
2632
2632
  virtualized: true,
2633
2633
  filterOption: filterNoOp$2,
2634
2634
  tabSelectsValue: false,
@@ -2646,7 +2646,7 @@ function VariableValueSelect({ model }) {
2646
2646
  });
2647
2647
  }
2648
2648
  function VariableValueSelectMulti({ model }) {
2649
- const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue } = model.useState();
2649
+ const { value, options, key, maxVisibleValues, noValueOnClear, includeAll, isReadOnly, allowCustomValue = true } = model.useState();
2650
2650
  const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
2651
2651
  const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
2652
2652
  const [inputValue, setInputValue] = React.useState("");
@@ -2681,7 +2681,7 @@ function VariableValueSelectMulti({ model }) {
2681
2681
  maxVisibleValues: maxVisibleValues != null ? maxVisibleValues : 5,
2682
2682
  tabSelectsValue: false,
2683
2683
  virtualized: true,
2684
- allowCustomValue: allowCustomValue != null ? allowCustomValue : true,
2684
+ allowCustomValue,
2685
2685
  toggleAllOptions: {
2686
2686
  enabled: true,
2687
2687
  optionsFilter: filterAll,