@splunk/dynamic-editors 0.42.1 → 0.43.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +33 -94
  2. package/DynamicEditor.js +82 -85
  3. package/DynamicEditor.js.map +1 -1
  4. package/containers/EditorItem.js +88 -91
  5. package/containers/EditorItem.js.map +1 -1
  6. package/containers/EditorLayout.js +96 -99
  7. package/containers/EditorLayout.js.map +1 -1
  8. package/containers/EditorLayoutItem.js +73 -76
  9. package/containers/EditorLayoutItem.js.map +1 -1
  10. package/editors/AdvancedConfigCard.js.map +1 -1
  11. package/editors/ArrayOfStringsEditor.js +4 -4
  12. package/editors/ArrayOfStringsEditor.js.map +1 -1
  13. package/editors/CheckboxEditor.js.map +1 -1
  14. package/editors/ColorEditor.js +1 -1
  15. package/editors/ColorEditor.js.map +1 -1
  16. package/editors/ColumnMultiSelectionByFieldNameEditor.js.map +1 -1
  17. package/editors/ColumnMultiSelectionEditor.js +4 -4
  18. package/editors/ColumnMultiSelectionEditor.js.map +1 -1
  19. package/editors/ColumnSelectionEditor.js +4 -4
  20. package/editors/ColumnSelectionEditor.js.map +1 -1
  21. package/editors/CustomizedInSourceEditor.js +4 -4
  22. package/editors/CustomizedInSourceEditor.js.map +1 -1
  23. package/editors/DynamicColorEditor.js +40 -40
  24. package/editors/DynamicColorEditor.js.map +1 -1
  25. package/editors/DynamicColorEditorWithPrecedence.js +24 -24
  26. package/editors/DynamicColorEditorWithPrecedence.js.map +1 -1
  27. package/editors/DynamicItemEditor.js +4 -4
  28. package/editors/DynamicItemEditor.js.map +1 -1
  29. package/editors/ImageEditor.js.map +1 -1
  30. package/editors/MarkdownEditor.js +14 -17
  31. package/editors/MarkdownEditor.js.map +1 -1
  32. package/editors/MultiColorPickerEditor.js +3 -3
  33. package/editors/MultiColorPickerEditor.js.map +1 -1
  34. package/editors/NetworkGraphDynamicColorEditor.js +40 -40
  35. package/editors/NetworkGraphDynamicColorEditor.js.map +1 -1
  36. package/editors/NumberEditor.js.map +1 -1
  37. package/editors/PercentEditor.js.map +1 -1
  38. package/editors/PresetSelectorEditor.js +1 -1
  39. package/editors/PresetSelectorEditor.js.map +1 -1
  40. package/editors/RadioBarEditor.js.map +1 -1
  41. package/editors/SelectEditor.js.map +1 -1
  42. package/editors/SeriesColorsByFieldEditor.js +3 -3
  43. package/editors/SeriesColorsByFieldEditor.js.map +1 -1
  44. package/editors/SeriesColorsEditor.js +8 -8
  45. package/editors/SeriesColorsEditor.js.map +1 -1
  46. package/editors/SliderEditor.js +3 -3
  47. package/editors/SliderEditor.js.map +1 -1
  48. package/editors/StaticItemEditor.js.map +1 -1
  49. package/editors/TableColumnFormatterEditor.js +114 -117
  50. package/editors/TableColumnFormatterEditor.js.map +1 -1
  51. package/editors/TableDynamicColorEditor.js +24 -24
  52. package/editors/TableDynamicColorEditor.js.map +1 -1
  53. package/editors/TextAreaEditor.js.map +1 -1
  54. package/editors/TextEditor.js.map +1 -1
  55. package/editors/ThresholdEditor.js.map +1 -1
  56. package/editors/ToggleEditor.js.map +1 -1
  57. package/package.json +5 -5
  58. package/shared/AdvancedControlGroup.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SliderEditor.js","mappings":";;;;g1BAAA,mBACA,WACA,YACA,aACA,aACA,aACA,UAEA,UAEMA,EAAc,CAAEC,UAAW,GAAIC,SAAU,EAAGC,WAAY,GAExDC,GAAe,aAAO,UAAO;;;;EA2B7BC,EAAS,+BACR,EAAAC,qBAAmB,CACtBC,KAAMC,EAAEC,OACRC,IAAKF,EAAEG,OACPC,SAAUJ,EAAEK,UAAU,CAACL,EAAEM,QAASN,EAAEC,SACpCM,IAAKP,EAAEG,OACPK,SAAUR,EAAEK,UAAU,CAACL,EAAEM,QAASN,EAAEC,SACpCQ,KAAMT,EAAEG,OACRO,UAAWV,EAAEW,MAAM,CAAC,QAAS,SAAU,SACvCC,MAAOZ,EAAEG,OACTU,aAA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CAChC5D,MAAO,CAAE8D,KAAM,OAG3Bb,EACLpB,EAAa,wBAAC,EAAAY,qBAAoB,CAACrE,MAAOA,EAAOsE,QAASY,IAAkC,MAIrGP,EAAqB9F,UAAY,CAI7B+C,MAAO5C,EAAEqE,OAITI,WAAYzE,EAAE0E,KAIdY,QAAStF,EAAEwE,KAIX0B,4BAA6BlG,EAAEwE,MAGnC,UAAemB,C,WChJfgB,EAAOC,QAAUC,QAAQ,8C,WCAzBF,EAAOC,QAAUC,QAAQ,0B,WCAzBF,EAAOC,QAAUC,QAAQ,gC,WCAzBF,EAAOC,QAAUC,QAAQ,0B,WCAzBF,EAAOC,QAAUC,QAAQ,0B,WCAzBF,EAAOC,QAAUC,QAAQ,2B,WCAzBF,EAAOC,QAAUC,QAAQ,iB,WCAzBF,EAAOC,QAAUC,QAAQ,wB,WCAzBF,EAAOC,QAAUC,QAAQ,S,SCAzBF,EAAOC,QAAUC,QAAQ,a,WCAzBF,EAAOC,QAAUC,QAAQ,Q,UCAzBF,EAAOC,QAAUC,QAAQ,oB,GCCrBC,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqB5E,IAAjB6E,EACH,OAAOA,EAAaN,QAGrB,IAAID,EAASG,EAAyBG,GAAY,CAGjDL,QAAS,CAAC,GAOX,OAHAO,EAAoBF,GAAUG,KAAKT,EAAOC,QAASD,EAAQA,EAAOC,QAASI,GAGpEL,EAAOC,OACf,CCnB0BI,CAAoB,K","sources":["webpack://@splunk/dynamic-editors/./src/editors/SliderEditor.tsx","webpack://@splunk/dynamic-editors/./src/hooks/useNumberInput.ts","webpack://@splunk/dynamic-editors/./src/interfaces/BaseEditorProps.ts","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-icons/SlidersDoubleHorizontal\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Button\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/ControlGroup\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Number\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Slider\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Tooltip\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/themes\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/ui-utils/i18n\"","webpack://@splunk/dynamic-editors/external commonjs2 \"lodash\"","webpack://@splunk/dynamic-editors/external commonjs2 \"prop-types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"react\"","webpack://@splunk/dynamic-editors/external commonjs2 \"styled-components\"","webpack://@splunk/dynamic-editors/webpack/bootstrap","webpack://@splunk/dynamic-editors/webpack/startup"],"sourcesContent":["import * as React from 'react';\nimport * as T from 'prop-types';\nimport styled from 'styled-components';\nimport Slider from '@splunk/react-ui/Slider';\nimport NumberInput from '@splunk/react-ui/Number';\nimport ControlGroup from '../shared/AdvancedControlGroup';\nimport { BaseEditorPropTypes } from '../interfaces/BaseEditorProps';\nimport type { BaseEditorProps } from '../interfaces/BaseEditorProps';\nimport { useNumberInput } from '../hooks/useNumberInput';\n\nconst numberStyle = { flexBasis: 92, flexGrow: 0, flexShrink: 0 };\n\nconst StyledSlider = styled(Slider)`\n div:has(> [data-test='bar']) {\n min-width: 0;\n }\n`;\n\ninterface SliderEditorProps extends BaseEditorProps {\n /** help text under controls */\n help?: string;\n /** max value for slider */\n max?: number;\n /** label for max value */\n maxLabel?: React.ReactNode;\n /** min value for slider */\n min?: number;\n /** label for min value */\n minLabel?: React.ReactNode;\n /** units to skip when moving slider */\n step?: number;\n /** display sections for drag bar */\n stepMarks?: 'focus' | 'always' | 'none';\n /** current value of field */\n value: number;\n /** default value of the option */\n defaultValue?: number;\n}\n\nconst propTypes: Record<keyof SliderEditorProps, T.Validator<any>> = {\n ...BaseEditorPropTypes,\n help: T.string,\n max: T.number,\n maxLabel: T.oneOfType([T.element, T.string]),\n min: T.number,\n minLabel: T.oneOfType([T.element, T.string]),\n step: T.number,\n stepMarks: T.oneOf(['focus', 'always', 'none']),\n value: T.number,\n defaultValue: T.number,\n};\n\nexport const SliderEditor = ({\n help,\n isDisabled = false,\n label,\n labelPosition = 'top',\n labelWidth,\n max,\n maxLabel = null,\n min,\n minLabel = null,\n name,\n onChange,\n step,\n stepMarks = 'focus',\n value = null,\n defaultValue,\n}: SliderEditorProps): JSX.Element => {\n const handleSliderChange = React.useCallback(\n (event, { value: v }) => {\n // emit onChange if value is a number\n if (parseFloat(v) || v === 0) {\n onChange(event, name, v);\n }\n },\n [onChange, name]\n );\n const handleNumberChange = React.useCallback(\n (event, v) => {\n // emit onChange if value is a number\n if (parseFloat(v) || v === 0) {\n onChange(event, name, v);\n }\n },\n [onChange, name]\n );\n\n const { currentValue, handleChange, handleBlur, handleFocus, handleKeyPress } = useNumberInput({\n value,\n min,\n max,\n defaultValue,\n onValueChange: handleNumberChange,\n });\n\n // if there is no value show input as blank by passing undefined\n const displayValue = currentValue != null ? Number(currentValue) : undefined;\n\n // stepMarks = 'none'is not valid for react-ui/Slider\n const suiStepMarks = stepMarks === 'none' ? 'never' : stepMarks;\n return (\n <ControlGroup label={label} labelPosition={labelPosition} labelWidth={labelWidth} help={help}>\n <StyledSlider\n data-test={name}\n min={min}\n minLabel={minLabel}\n max={max}\n maxLabel={maxLabel}\n step={step}\n stepMarks={suiStepMarks}\n value={displayValue}\n disabled={isDisabled}\n onChange={handleSliderChange}\n />\n <NumberInput\n inline\n min={min}\n max={max}\n step={step}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyPress}\n value={displayValue}\n disabled={isDisabled}\n style={numberStyle}\n />\n </ControlGroup>\n );\n};\nSliderEditor.propTypes = propTypes;\n\nexport default SliderEditor;\n","import type React from 'react';\nimport { useCallback, useRef, useLayoutEffect, useState, useMemo } from 'react';\nimport {\n type NumberBlurHandler,\n type NumberChangeHandler,\n type NumberFocusHandler,\n type NumberPropsBase,\n} from '@splunk/react-ui/Number';\nimport { clamp, debounce, noop } from 'lodash';\n\nexport type OnValueChangeType = (e: Parameters<NumberChangeHandler>[0], newValue?: string | number) => void;\n\ninterface UseNumberInputArgs extends Pick<NumberPropsBase, 'value' | 'defaultValue' | 'min' | 'max'> {\n onValueChange: OnValueChangeType;\n}\n\nexport const useNumberInput = ({\n min = Number.NEGATIVE_INFINITY,\n max = Number.POSITIVE_INFINITY,\n value,\n defaultValue,\n onValueChange = noop,\n}: UseNumberInputArgs) => {\n const [currentValue, setCurrentValue] = useState(value);\n const isFocusedRef = useRef(false);\n\n const commitValue = useCallback(\n (e, newValue?: string | number) => {\n if (newValue == null) {\n // if we're clearing the input, revert local state back to default or old value\n setCurrentValue(defaultValue ?? value);\n }\n\n onValueChange(e, newValue);\n },\n [defaultValue, onValueChange, value]\n );\n\n const handleChangeDebounced = useMemo(\n () => debounce<NumberChangeHandler>((e, payload) => commitValue(e, payload.value), 250),\n [commitValue]\n );\n\n useLayoutEffect(() => {\n // layout effect prevents double-render during external change to derived state\n setCurrentValue(value);\n }, [value]);\n\n const handleChange = useCallback<NumberChangeHandler>(\n (e, payload) => {\n setCurrentValue(payload.value);\n if (isFocusedRef.current) {\n // if focus is in the text box of the number input, don't commit the state yet\n // this includes being focused inside the text box and using UP + DOWN arrow keys to increment/decrement. It will only\n // commit the value on blur or Enter key.\n return;\n }\n\n // if the focus is outside, it's because the user is clicking the increment/decrement buttons directly\n handleChangeDebounced(e, payload);\n },\n [handleChangeDebounced]\n );\n\n const handleBlur = useCallback<NumberBlurHandler>(\n e => {\n isFocusedRef.current = false;\n if (value !== currentValue) {\n commitValue(e, currentValue);\n }\n },\n [currentValue, commitValue, value]\n );\n\n const handleFocus = useCallback<NumberFocusHandler>(() => {\n isFocusedRef.current = true;\n }, []);\n\n const handleKeyPress = useCallback<React.KeyboardEventHandler<HTMLInputElement>>(\n e => {\n if (typeof e.key === 'string' && e.key.toLowerCase() === 'enter') {\n const targetValue = (e.target as HTMLInputElement)?.value;\n const eventValue = targetValue ? Number(targetValue) : undefined;\n\n // the raw input value will not have min/max clamp applied from the SUINumber component\n const clampedValue = typeof eventValue === 'number' ? clamp(eventValue, min, max) : undefined;\n\n if (value !== clampedValue) {\n commitValue(e, clampedValue);\n }\n }\n // if pressing the ESC key, revert value to the initial one before editing\n if (typeof e.key === 'string' && e.key.toLowerCase() === 'escape') {\n // This key doesn't work with Chrome 75\n setCurrentValue(value);\n }\n },\n [commitValue, value, min, max]\n );\n\n return {\n handleChange,\n handleBlur,\n handleFocus,\n handleKeyPress,\n currentValue,\n };\n};\n","import * as T from 'prop-types';\nimport type { JSONSchema7 } from 'json-schema';\n\nexport interface BaseEditorProps {\n name: string;\n value: any;\n onChange?: (...args: any[]) => void;\n label?: string; // @TODO(pwied): this should not live in editor props\n labelPosition?: 'top' | 'left'; // ^^^\n context?: Record<string, any>;\n labelWidth?: number;\n isAdvanced?: boolean;\n isDisabled?: boolean;\n dataSourceBindings?: Record<string, any>;\n options?: { [k: string]: any };\n optionsSchema?: {\n [key: string]: JSONSchema7;\n };\n}\n\nexport const BaseEditorPropTypes: Record<keyof BaseEditorProps, T.Validator<any>> = {\n name: T.string.isRequired,\n value: T.oneOfType([T.string, T.object, T.arrayOf(T.string)]),\n context: T.object,\n label: T.string,\n labelPosition: T.oneOf(['top', 'left']),\n labelWidth: T.number,\n onChange: T.func,\n isAdvanced: T.bool,\n isDisabled: T.bool,\n dataSourceBindings: T.object,\n options: T.object,\n optionsSchema: T.object,\n};\n","import React, { Children, cloneElement } from 'react';\nimport type { ReactElement } from 'react';\nimport * as T from 'prop-types';\nimport styled from 'styled-components';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport AdvancedConfigIcon from '@splunk/react-icons/SlidersDoubleHorizontal';\nimport { variables } from '@splunk/themes';\nimport Tooltip from '@splunk/react-ui/Tooltip';\nimport Button, { ButtonClickHandler, ButtonProps } from '@splunk/react-ui/Button';\nimport SUIControlGroup from '@splunk/react-ui/ControlGroup';\nimport type { ControlGroupPropsBase } from '@splunk/react-ui/ControlGroup';\n\ninterface AdvancedControlGroupProps extends Omit<ControlGroupPropsBase, 'splunkTheme'> {\n 'data-test'?: string;\n style?: Record<string, string | number>;\n isAdvanced?: boolean;\n onClick?: React.MouseEventHandler<HTMLDivElement>;\n onAdvancedConfigButtonClick?: ButtonClickHandler;\n}\n\ninterface AdvancedConfigButtonProps {\n label?: string;\n onClick?: ButtonClickHandler;\n}\n\n// remove all surrounding margins. let parent add padding\nconst ControlGroupContainer = styled(SUIControlGroup)`\n margin-top: 0;\n padding: 0;\n // adjust bottom margin according to theme\n margin-bottom: ${variables.spacingMedium};\n width: 100%;\n\n // remove top margin of the first component in control group\n &:first-child {\n margin-top: 0;\n }\n\n // remove bottom margin of the last component in control group\n &:last-child {\n margin-bottom: 0;\n }\n // remove top padding on label of the first control group\n [data-test='label']:first-of-type {\n padding-top: 0;\n }\n`;\n\n// override tooltip to set desired config button style\nconst StyledToolTip = styled(Tooltip)`\n display: flex;\n > span {\n display: flex;\n width: 35px;\n }\n`;\n\nconst StyledAdvancedConfigButton = styled(Button)<ButtonProps>`\n color: ${variables.contentColorActive} !important;\n &:hover {\n background-color: ${variables.interactiveColorOverlayDrag} !important;\n }\n`;\n\nexport const AdvancedConfigButton = ({\n label = '',\n onClick,\n}: AdvancedConfigButtonProps): React.ReactElement => {\n return (\n <StyledToolTip\n data-test={`${label}-advanced-config-button-tooltip`}\n content={_('Advanced configurations')}\n >\n <StyledAdvancedConfigButton\n data-test={`${label}-advanced-config-button`}\n icon={<AdvancedConfigIcon data-test={`${label}-advanced-config-button-icon`} />}\n appearance=\"subtle\"\n onClick={onClick}\n />\n </StyledToolTip>\n );\n};\n\nconst AdvancedControlGroup = ({\n 'data-test': dataTest,\n children,\n isAdvanced = false,\n label,\n hideLabel,\n labelPosition,\n labelWidth,\n tooltip,\n help,\n style,\n error,\n controlsLayout,\n onClick,\n onAdvancedConfigButtonClick,\n}: AdvancedControlGroupProps): React.ReactElement => (\n <ControlGroupContainer\n data-test={dataTest ?? 'control-group'}\n label={label}\n hideLabel={hideLabel}\n labelPosition={labelPosition}\n labelWidth={labelWidth}\n tooltip={tooltip}\n help={help}\n error={error}\n style={style}\n onClick={onClick}\n controlsLayout={controlsLayout}\n >\n {isAdvanced\n ? Children.toArray(children)\n .filter(Boolean)\n .map(child =>\n cloneElement(child as ReactElement, {\n style: { flex: 1 },\n })\n )\n : children}\n {isAdvanced ? <AdvancedConfigButton label={label} onClick={onAdvancedConfigButtonClick} /> : null}\n </ControlGroupContainer>\n);\n\nAdvancedControlGroup.propTypes = {\n /**\n * Style overriding SUI ControlGroup\n */\n style: T.object,\n /**\n * Whether the current editor is enabled with advanced configurations\n */\n isAdvanced: T.bool,\n /**\n * Callback for editor click\n */\n onClick: T.func,\n /**\n * Callback for advanced config button click\n */\n onAdvancedConfigButtonClick: T.func,\n};\n\nexport default AdvancedControlGroup;\n","module.exports = require(\"@splunk/react-icons/SlidersDoubleHorizontal\");","module.exports = require(\"@splunk/react-ui/Button\");","module.exports = require(\"@splunk/react-ui/ControlGroup\");","module.exports = require(\"@splunk/react-ui/Number\");","module.exports = require(\"@splunk/react-ui/Slider\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"lodash\");","module.exports = require(\"prop-types\");","module.exports = require(\"react\");","module.exports = require(\"styled-components\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(148);\n"],"names":["numberStyle","flexBasis","flexGrow","flexShrink","StyledSlider","propTypes","BaseEditorPropTypes","help","T","string","max","number","maxLabel","oneOfType","element","min","minLabel","step","stepMarks","oneOf","value","defaultValue","SliderEditor","isDisabled","label","labelPosition","labelWidth","name","onChange","handleSliderChange","React","useCallback","event","v","parseFloat","handleNumberChange","currentValue","handleChange","handleBlur","handleFocus","handleKeyPress","useNumberInput","onValueChange","displayValue","Number","undefined","suiStepMarks","disabled","inline","onBlur","onFocus","onKeyDown","style","NEGATIVE_INFINITY","POSITIVE_INFINITY","noop","setCurrentValue","useState","isFocusedRef","useRef","commitValue","e","newValue","handleChangeDebounced","useMemo","debounce","payload","useLayoutEffect","current","key","toLowerCase","targetValue","target","eventValue","clampedValue","clamp","isRequired","object","arrayOf","context","func","isAdvanced","bool","dataSourceBindings","options","optionsSchema","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","hideLabel","tooltip","error","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","filter","Boolean","map","child","cloneElement","flex","module","exports","require","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"sourceRoot":""}
1
+ {"version":3,"file":"SliderEditor.js","mappings":";;;;g1BAAA,mBACA,YACA,aACA,aACA,aAEA,UAEMA,EAAc,CAAEC,UAAW,GAAIC,SAAU,EAAGC,WAAY,GAExDC,GAAe,aAAO,UAAO;;;;EA2BtB,EAAAC,aAAe,EACxBC,OACAC,cAAa,EACbC,QACAC,gBAAgB,MAChBC,aACAC,MACAC,WAAW,K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QAAUC,QAAQ,a,WCAzBF,EAAOC,QAAUC,QAAQ,Q,UCAzBF,EAAOC,QAAUC,QAAQ,oB,GCCrBC,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBxE,IAAjByE,EACH,OAAOA,EAAaN,QAGrB,IAAID,EAASG,EAAyBG,GAAY,CAGjDL,QAAS,CAAC,GAOX,OAHAO,EAAoBF,GAAUG,KAAKT,EAAOC,QAASD,EAAQA,EAAOC,QAASI,GAGpEL,EAAOC,OACf,CCnB0BI,CAAoB,K","sources":["webpack://@splunk/dynamic-editors/./src/editors/SliderEditor.tsx","webpack://@splunk/dynamic-editors/./src/hooks/useNumberInput.ts","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-icons/SlidersDoubleHorizontal\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Button\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/ControlGroup\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Number\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Slider\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Tooltip\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/themes\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/ui-utils/i18n\"","webpack://@splunk/dynamic-editors/external commonjs2 \"lodash\"","webpack://@splunk/dynamic-editors/external commonjs2 \"prop-types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"react\"","webpack://@splunk/dynamic-editors/external commonjs2 \"styled-components\"","webpack://@splunk/dynamic-editors/webpack/bootstrap","webpack://@splunk/dynamic-editors/webpack/startup"],"sourcesContent":["import * as React from 'react';\nimport styled from 'styled-components';\nimport Slider from '@splunk/react-ui/Slider';\nimport NumberInput from '@splunk/react-ui/Number';\nimport ControlGroup from '../shared/AdvancedControlGroup';\nimport type { BaseEditorProps } from '../interfaces/BaseEditorProps';\nimport { useNumberInput } from '../hooks/useNumberInput';\n\nconst numberStyle = { flexBasis: 92, flexGrow: 0, flexShrink: 0 };\n\nconst StyledSlider = styled(Slider)`\n div:has(> [data-test='bar']) {\n min-width: 0;\n }\n`;\n\ninterface SliderEditorProps extends BaseEditorProps {\n /** help text under controls */\n help?: string;\n /** max value for slider */\n max?: number;\n /** label for max value */\n maxLabel?: React.ReactNode;\n /** min value for slider */\n min?: number;\n /** label for min value */\n minLabel?: React.ReactNode;\n /** units to skip when moving slider */\n step?: number;\n /** display sections for drag bar */\n stepMarks?: 'focus' | 'always' | 'none';\n /** current value of field */\n value: number;\n /** default value of the option */\n defaultValue?: number;\n}\n\nexport const SliderEditor = ({\n help,\n isDisabled = false,\n label,\n labelPosition = 'top',\n labelWidth,\n max,\n maxLabel = null,\n min,\n minLabel = null,\n name,\n onChange,\n step,\n stepMarks = 'focus',\n value = null,\n defaultValue,\n}: SliderEditorProps): JSX.Element => {\n const handleSliderChange = React.useCallback(\n (event, { value: v }) => {\n // emit onChange if value is a number\n if (parseFloat(v) || v === 0) {\n onChange(event, name, v);\n }\n },\n [onChange, name]\n );\n const handleNumberChange = React.useCallback(\n (event, v) => {\n // emit onChange if value is a number\n if (parseFloat(v) || v === 0) {\n onChange(event, name, v);\n }\n },\n [onChange, name]\n );\n\n const { currentValue, handleChange, handleBlur, handleFocus, handleKeyPress } = useNumberInput({\n value,\n min,\n max,\n defaultValue,\n onValueChange: handleNumberChange,\n });\n\n // if there is no value show input as blank by passing undefined\n const displayValue = currentValue != null ? Number(currentValue) : undefined;\n\n // stepMarks = 'none'is not valid for react-ui/Slider\n const suiStepMarks = stepMarks === 'none' ? 'never' : stepMarks;\n return (\n <ControlGroup label={label} labelPosition={labelPosition} labelWidth={labelWidth} help={help}>\n <StyledSlider\n data-test={name}\n min={min}\n minLabel={minLabel}\n max={max}\n maxLabel={maxLabel}\n step={step}\n stepMarks={suiStepMarks}\n value={displayValue}\n disabled={isDisabled}\n onChange={handleSliderChange}\n />\n <NumberInput\n inline\n min={min}\n max={max}\n step={step}\n onChange={handleChange}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onKeyDown={handleKeyPress}\n value={displayValue}\n disabled={isDisabled}\n style={numberStyle}\n />\n </ControlGroup>\n );\n};\n\nexport default SliderEditor;\n","import type React from 'react';\nimport { useCallback, useRef, useLayoutEffect, useState, useMemo } from 'react';\nimport {\n type NumberBlurHandler,\n type NumberChangeHandler,\n type NumberFocusHandler,\n type NumberPropsBase,\n} from '@splunk/react-ui/Number';\nimport { clamp, debounce, noop } from 'lodash';\n\nexport type OnValueChangeType = (e: Parameters<NumberChangeHandler>[0], newValue?: string | number) => void;\n\ninterface UseNumberInputArgs extends Pick<NumberPropsBase, 'value' | 'defaultValue' | 'min' | 'max'> {\n onValueChange: OnValueChangeType;\n}\n\nexport const useNumberInput = ({\n min = Number.NEGATIVE_INFINITY,\n max = Number.POSITIVE_INFINITY,\n value,\n defaultValue,\n onValueChange = noop,\n}: UseNumberInputArgs) => {\n const [currentValue, setCurrentValue] = useState(value);\n const isFocusedRef = useRef(false);\n\n const commitValue = useCallback(\n (e, newValue?: string | number) => {\n if (newValue == null) {\n // if we're clearing the input, revert local state back to default or old value\n setCurrentValue(defaultValue ?? value);\n }\n\n onValueChange(e, newValue);\n },\n [defaultValue, onValueChange, value]\n );\n\n const handleChangeDebounced = useMemo(\n () => debounce<NumberChangeHandler>((e, payload) => commitValue(e, payload.value), 250),\n [commitValue]\n );\n\n useLayoutEffect(() => {\n // layout effect prevents double-render during external change to derived state\n setCurrentValue(value);\n }, [value]);\n\n const handleChange = useCallback<NumberChangeHandler>(\n (e, payload) => {\n setCurrentValue(payload.value);\n if (isFocusedRef.current) {\n // if focus is in the text box of the number input, don't commit the state yet\n // this includes being focused inside the text box and using UP + DOWN arrow keys to increment/decrement. It will only\n // commit the value on blur or Enter key.\n return;\n }\n\n // if the focus is outside, it's because the user is clicking the increment/decrement buttons directly\n handleChangeDebounced(e, payload);\n },\n [handleChangeDebounced]\n );\n\n const handleBlur = useCallback<NumberBlurHandler>(\n e => {\n isFocusedRef.current = false;\n if (value !== currentValue) {\n commitValue(e, currentValue);\n }\n },\n [currentValue, commitValue, value]\n );\n\n const handleFocus = useCallback<NumberFocusHandler>(() => {\n isFocusedRef.current = true;\n }, []);\n\n const handleKeyPress = useCallback<React.KeyboardEventHandler<HTMLInputElement>>(\n e => {\n if (typeof e.key === 'string' && e.key.toLowerCase() === 'enter') {\n const targetValue = (e.target as HTMLInputElement)?.value;\n const eventValue = targetValue ? Number(targetValue) : undefined;\n\n // the raw input value will not have min/max clamp applied from the SUINumber component\n const clampedValue = typeof eventValue === 'number' ? clamp(eventValue, min, max) : undefined;\n\n if (value !== clampedValue) {\n commitValue(e, clampedValue);\n }\n }\n // if pressing the ESC key, revert value to the initial one before editing\n if (typeof e.key === 'string' && e.key.toLowerCase() === 'escape') {\n // This key doesn't work with Chrome 75\n setCurrentValue(value);\n }\n },\n [commitValue, value, min, max]\n );\n\n return {\n handleChange,\n handleBlur,\n handleFocus,\n handleKeyPress,\n currentValue,\n };\n};\n","import React, { Children, cloneElement } from 'react';\nimport type { ReactElement } from 'react';\nimport * as T from 'prop-types';\nimport styled from 'styled-components';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport AdvancedConfigIcon from '@splunk/react-icons/SlidersDoubleHorizontal';\nimport { variables } from '@splunk/themes';\nimport Tooltip from '@splunk/react-ui/Tooltip';\nimport type { ButtonClickHandler, ButtonProps } from '@splunk/react-ui/Button';\nimport Button from '@splunk/react-ui/Button';\nimport SUIControlGroup from '@splunk/react-ui/ControlGroup';\nimport type { ControlGroupPropsBase } from '@splunk/react-ui/ControlGroup';\n\ninterface AdvancedControlGroupProps extends Omit<ControlGroupPropsBase, 'splunkTheme'> {\n 'data-test'?: string;\n style?: Record<string, string | number>;\n isAdvanced?: boolean;\n onClick?: React.MouseEventHandler<HTMLDivElement>;\n onAdvancedConfigButtonClick?: ButtonClickHandler;\n}\n\ninterface AdvancedConfigButtonProps {\n label?: string;\n onClick?: ButtonClickHandler;\n}\n\n// remove all surrounding margins. let parent add padding\nconst ControlGroupContainer = styled(SUIControlGroup)`\n margin-top: 0;\n padding: 0;\n // adjust bottom margin according to theme\n margin-bottom: ${variables.spacingMedium};\n width: 100%;\n\n // remove top margin of the first component in control group\n &:first-child {\n margin-top: 0;\n }\n\n // remove bottom margin of the last component in control group\n &:last-child {\n margin-bottom: 0;\n }\n // remove top padding on label of the first control group\n [data-test='label']:first-of-type {\n padding-top: 0;\n }\n`;\n\n// override tooltip to set desired config button style\nconst StyledToolTip = styled(Tooltip)`\n display: flex;\n > span {\n display: flex;\n width: 35px;\n }\n`;\n\nconst StyledAdvancedConfigButton = styled(Button)<ButtonProps>`\n color: ${variables.contentColorActive} !important;\n &:hover {\n background-color: ${variables.interactiveColorOverlayDrag} !important;\n }\n`;\n\nexport const AdvancedConfigButton = ({\n label = '',\n onClick,\n}: AdvancedConfigButtonProps): React.ReactElement => {\n return (\n <StyledToolTip\n data-test={`${label}-advanced-config-button-tooltip`}\n content={_('Advanced configurations')}\n >\n <StyledAdvancedConfigButton\n data-test={`${label}-advanced-config-button`}\n icon={<AdvancedConfigIcon data-test={`${label}-advanced-config-button-icon`} />}\n appearance=\"subtle\"\n onClick={onClick}\n />\n </StyledToolTip>\n );\n};\n\nconst AdvancedControlGroup = ({\n 'data-test': dataTest,\n children,\n isAdvanced = false,\n label,\n hideLabel,\n labelPosition,\n labelWidth,\n tooltip,\n help,\n style,\n error,\n controlsLayout,\n onClick,\n onAdvancedConfigButtonClick,\n}: AdvancedControlGroupProps): React.ReactElement => (\n <ControlGroupContainer\n data-test={dataTest ?? 'control-group'}\n label={label}\n hideLabel={hideLabel}\n labelPosition={labelPosition}\n labelWidth={labelWidth}\n tooltip={tooltip}\n help={help}\n error={error}\n style={style}\n onClick={onClick}\n controlsLayout={controlsLayout}\n >\n {isAdvanced\n ? Children.toArray(children)\n .filter(Boolean)\n .map(child =>\n cloneElement(child as ReactElement, {\n style: { flex: 1 },\n })\n )\n : children}\n {isAdvanced ? <AdvancedConfigButton label={label} onClick={onAdvancedConfigButtonClick} /> : null}\n </ControlGroupContainer>\n);\n\nAdvancedControlGroup.propTypes = {\n /**\n * Style overriding SUI ControlGroup\n */\n style: T.object,\n /**\n * Whether the current editor is enabled with advanced configurations\n */\n isAdvanced: T.bool,\n /**\n * Callback for editor click\n */\n onClick: T.func,\n /**\n * Callback for advanced config button click\n */\n onAdvancedConfigButtonClick: T.func,\n};\n\nexport default AdvancedControlGroup;\n","module.exports = require(\"@splunk/react-icons/SlidersDoubleHorizontal\");","module.exports = require(\"@splunk/react-ui/Button\");","module.exports = require(\"@splunk/react-ui/ControlGroup\");","module.exports = require(\"@splunk/react-ui/Number\");","module.exports = require(\"@splunk/react-ui/Slider\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"lodash\");","module.exports = require(\"prop-types\");","module.exports = require(\"react\");","module.exports = require(\"styled-components\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(148);\n"],"names":["numberStyle","flexBasis","flexGrow","flexShrink","StyledSlider","SliderEditor","help","isDisabled","label","labelPosition","labelWidth","max","maxLabel","min","minLabel","name","onChange","step","stepMarks","value","defaultValue","handleSliderChange","React","useCallback","event","v","parseFloat","handleNumberChange","currentValue","handleChange","handleBlur","handleFocus","handleKeyPress","useNumberInput","onValueChange","displayValue","Number","undefined","suiStepMarks","disabled","inline","onBlur","onFocus","onKeyDown","style","NEGATIVE_INFINITY","POSITIVE_INFINITY","noop","setCurrentValue","useState","isFocusedRef","useRef","commitValue","e","newValue","handleChangeDebounced","useMemo","debounce","payload","useLayoutEffect","current","key","toLowerCase","targetValue","target","eventValue","clampedValue","clamp","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","isAdvanced","hideLabel","tooltip","error","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","filter","Boolean","map","child","cloneElement","flex","propTypes","T","object","bool","func","module","exports","require","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"StaticItemEditor.js","mappings":";;;;6GAAA,MAAM,EAA+BA,QAAQ,kD,yeCO7C,MAAMC,EAAoB,CAAC,EAErBC,EAAaC,IAgBb,IAhBc,SAChBC,EAAQ,KACRC,EAAI,MACJC,EAAQ,GAAE,MACVC,EAAK,cACLC,EAAgB,MAAK,WACrBC,EAAU,WACVC,EAAaT,EAAiB,UAC9BU,GAAY,EAAK,WACjBC,EAAU,WACVC,GAAa,EAAK,KAClBC,EAAI,QACJC,EAAO,SACPC,EAAQ,MACRC,GAEHd,EADMe,EAAUC,IAAAhB,EAAAiB,GAEb,MAAOC,EAAKC,IAAiBC,EAAAA,EAAAA,UAASjB,GAEhCkB,GAAiBC,EAAAA,EAAAA,cACnBC,GAAiC,mBAAbV,EAA0BA,EAAS,CAAEV,MAAOoB,IAAc,MAC9E,CAACV,KA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jD,cAAeiD,IAAAA,MAAQ,CAAC,MAAO,SAI/BzC,SAAUyC,IAAAA,MAGd,S","sources":["webpack://@splunk/dynamic-editors/external commonjs2 \"@babel/runtime/helpers/objectWithoutProperties\"","webpack://@splunk/dynamic-editors/./src/editors/TextEditor.jsx","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/./src/shared/dimensionConstants.ts","webpack://@splunk/dynamic-editors/external commonjs2 \"@babel/runtime/helpers/defineProperty\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@babel/runtime/helpers/extends\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-icons/SlidersDoubleHorizontal\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Button\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/ControlGroup\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/FormRows\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Text\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Tooltip\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/themes\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/ui-utils/i18n\"","webpack://@splunk/dynamic-editors/external commonjs2 \"lodash\"","webpack://@splunk/dynamic-editors/external commonjs2 \"prop-types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"react\"","webpack://@splunk/dynamic-editors/external commonjs2 \"styled-components\"","webpack://@splunk/dynamic-editors/webpack/bootstrap","webpack://@splunk/dynamic-editors/webpack/runtime/compat get default export","webpack://@splunk/dynamic-editors/webpack/runtime/define property getters","webpack://@splunk/dynamic-editors/webpack/runtime/hasOwnProperty shorthand","webpack://@splunk/dynamic-editors/webpack/runtime/make namespace object","webpack://@splunk/dynamic-editors/./src/editors/StaticItemEditor.jsx"],"sourcesContent":["const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@babel/runtime/helpers/objectWithoutProperties\");","import React, { useState, useCallback, useEffect, useMemo } from 'react';\nimport T from 'prop-types';\nimport { debounce } from 'lodash';\nimport Text from '@splunk/react-ui/Text';\nimport ControlGroup from '../shared/AdvancedControlGroup';\nimport { editorStyle } from '../shared/dimensionConstants';\n\nconst defaultLabelStyle = {};\n\nconst TextEditor = ({\n onChange,\n name,\n value = '',\n label,\n labelPosition = 'top',\n labelWidth,\n labelStyle = defaultLabelStyle,\n hideLabel = false,\n isAdvanced,\n isDisabled = false,\n help,\n tooltip,\n validate,\n error,\n ...otherProps\n}) => {\n const [val, setValueState] = useState(value);\n\n const handleValidate = useCallback(\n newValue => (typeof validate === 'function' ? validate({ value: newValue }) : null),\n [validate]\n );\n const [errorState, setErrorState] = useState(handleValidate(value));\n const debouncedHandleValidate = useMemo(\n () =>\n debounce(newVal => {\n setErrorState(handleValidate(newVal));\n }, 250),\n [handleValidate]\n );\n\n useEffect(\n () => () => {\n // cancel debounce on component unmount\n debouncedHandleValidate.cancel();\n },\n [debouncedHandleValidate]\n );\n\n useEffect(() => {\n setValueState(value);\n setErrorState(handleValidate(value));\n }, [handleValidate, value]);\n\n const handleChange = useCallback(\n (_event, { value: v }) => {\n setValueState(v);\n debouncedHandleValidate(v);\n },\n [debouncedHandleValidate]\n );\n\n const handleBlur = useCallback(\n event => {\n const newVal = val.trim();\n if (newVal === value) {\n return;\n }\n const newError = handleValidate(newVal);\n // set error if there is one, or clear an existing error\n setErrorState(newError);\n if (!newError) {\n // only change value if there is no validation error\n onChange(event, name, newVal);\n }\n },\n [val, value, handleValidate, onChange, name]\n );\n\n const handleKeyPress = useCallback(\n event => {\n if (event.key === 'Enter') {\n handleBlur(event);\n }\n },\n [handleBlur]\n );\n\n const style = useMemo(\n () =>\n !label || label === ''\n ? {\n ...labelStyle,\n }\n : labelStyle,\n [label, labelStyle]\n );\n\n return (\n <ControlGroup\n label={label}\n labelPosition={labelPosition}\n labelWidth={labelWidth}\n style={style}\n hideLabel={hideLabel}\n help={help}\n tooltip={tooltip}\n error={errorState?.message || error}\n isAdvanced={isAdvanced}\n >\n <Text\n key={value}\n data-test={name}\n style={editorStyle}\n onChange={handleChange}\n onKeyDown={handleKeyPress}\n onBlur={handleBlur}\n value={val}\n disabled={isDisabled}\n canClear\n {...otherProps}\n error={!!errorState || error}\n />\n </ControlGroup>\n );\n};\n\nTextEditor.propTypes = {\n /**\n * Callback when changing the text value\n *\n * @param {SyntheticEvent} event The react `SyntheticEvent`\n * @param {string} name The option name\n * @param {string} value The option value\n */\n onChange: T.func.isRequired,\n /**\n * The option name\n */\n name: T.string.isRequired,\n /**\n * A human readable label for the option\n */\n label: T.string.isRequired,\n /**\n * The option value\n */\n value: T.string,\n /**\n * Label position\n */\n labelPosition: T.oneOf(['top', 'left']),\n /**\n * Label width\n */\n labelWidth: T.number,\n /**\n * Styles to be passed to the ControlGroup\n */\n labelStyle: T.object,\n /**\n * Visually hide the label, but render it for screen readers\n */\n hideLabel: T.bool,\n /**\n * As advanced editor to show advanced config button\n */\n isAdvanced: T.bool,\n /**\n * Disabled state of component\n */\n isDisabled: T.bool,\n /**\n * Validate the value of the editor\n */\n validate: T.func,\n /**\n * If the input should display error state\n */\n error: T.bool,\n /**\n * Text to display under the the input\n */\n help: T.string,\n /**\n * Text to display in a tooltip next to the label\n */\n tooltip: T.string,\n};\n\nexport default TextEditor;\n","import React, { Children, cloneElement } from 'react';\nimport type { ReactElement } from 'react';\nimport * as T from 'prop-types';\nimport styled from 'styled-components';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport AdvancedConfigIcon from '@splunk/react-icons/SlidersDoubleHorizontal';\nimport { variables } from '@splunk/themes';\nimport Tooltip from '@splunk/react-ui/Tooltip';\nimport Button, { ButtonClickHandler, ButtonProps } from '@splunk/react-ui/Button';\nimport SUIControlGroup from '@splunk/react-ui/ControlGroup';\nimport type { ControlGroupPropsBase } from '@splunk/react-ui/ControlGroup';\n\ninterface AdvancedControlGroupProps extends Omit<ControlGroupPropsBase, 'splunkTheme'> {\n 'data-test'?: string;\n style?: Record<string, string | number>;\n isAdvanced?: boolean;\n onClick?: React.MouseEventHandler<HTMLDivElement>;\n onAdvancedConfigButtonClick?: ButtonClickHandler;\n}\n\ninterface AdvancedConfigButtonProps {\n label?: string;\n onClick?: ButtonClickHandler;\n}\n\n// remove all surrounding margins. let parent add padding\nconst ControlGroupContainer = styled(SUIControlGroup)`\n margin-top: 0;\n padding: 0;\n // adjust bottom margin according to theme\n margin-bottom: ${variables.spacingMedium};\n width: 100%;\n\n // remove top margin of the first component in control group\n &:first-child {\n margin-top: 0;\n }\n\n // remove bottom margin of the last component in control group\n &:last-child {\n margin-bottom: 0;\n }\n // remove top padding on label of the first control group\n [data-test='label']:first-of-type {\n padding-top: 0;\n }\n`;\n\n// override tooltip to set desired config button style\nconst StyledToolTip = styled(Tooltip)`\n display: flex;\n > span {\n display: flex;\n width: 35px;\n }\n`;\n\nconst StyledAdvancedConfigButton = styled(Button)<ButtonProps>`\n color: ${variables.contentColorActive} !important;\n &:hover {\n background-color: ${variables.interactiveColorOverlayDrag} !important;\n }\n`;\n\nexport const AdvancedConfigButton = ({\n label = '',\n onClick,\n}: AdvancedConfigButtonProps): React.ReactElement => {\n return (\n <StyledToolTip\n data-test={`${label}-advanced-config-button-tooltip`}\n content={_('Advanced configurations')}\n >\n <StyledAdvancedConfigButton\n data-test={`${label}-advanced-config-button`}\n icon={<AdvancedConfigIcon data-test={`${label}-advanced-config-button-icon`} />}\n appearance=\"subtle\"\n onClick={onClick}\n />\n </StyledToolTip>\n );\n};\n\nconst AdvancedControlGroup = ({\n 'data-test': dataTest,\n children,\n isAdvanced = false,\n label,\n hideLabel,\n labelPosition,\n labelWidth,\n tooltip,\n help,\n style,\n error,\n controlsLayout,\n onClick,\n onAdvancedConfigButtonClick,\n}: AdvancedControlGroupProps): React.ReactElement => (\n <ControlGroupContainer\n data-test={dataTest ?? 'control-group'}\n label={label}\n hideLabel={hideLabel}\n labelPosition={labelPosition}\n labelWidth={labelWidth}\n tooltip={tooltip}\n help={help}\n error={error}\n style={style}\n onClick={onClick}\n controlsLayout={controlsLayout}\n >\n {isAdvanced\n ? Children.toArray(children)\n .filter(Boolean)\n .map(child =>\n cloneElement(child as ReactElement, {\n style: { flex: 1 },\n })\n )\n : children}\n {isAdvanced ? <AdvancedConfigButton label={label} onClick={onAdvancedConfigButtonClick} /> : null}\n </ControlGroupContainer>\n);\n\nAdvancedControlGroup.propTypes = {\n /**\n * Style overriding SUI ControlGroup\n */\n style: T.object,\n /**\n * Whether the current editor is enabled with advanced configurations\n */\n isAdvanced: T.bool,\n /**\n * Callback for editor click\n */\n onClick: T.func,\n /**\n * Callback for advanced config button click\n */\n onAdvancedConfigButtonClick: T.func,\n};\n\nexport default AdvancedControlGroup;\n","export const FLYOUT_PADDING = 21;\nexport const COLUMN_FLYOUT_PADDING = 16;\nexport const FLYOUT_WIDTH = 344;\n\nexport const VERTICAL_EDITOR_SPACING = 16;\n\nexport const DROPDOWN_MENU_WIDTH = 327;\n\nexport const editorStyle = { width: '100%' };\n","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"@babel/runtime/helpers/extends\");","module.exports = require(\"@splunk/react-icons/SlidersDoubleHorizontal\");","module.exports = require(\"@splunk/react-ui/Button\");","module.exports = require(\"@splunk/react-ui/ControlGroup\");","module.exports = require(\"@splunk/react-ui/FormRows\");","module.exports = require(\"@splunk/react-ui/Text\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"lodash\");","module.exports = require(\"prop-types\");","module.exports = require(\"react\");","module.exports = require(\"styled-components\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import React, { useCallback, useState, useEffect } from 'react';\nimport T from 'prop-types';\nimport styled from 'styled-components';\nimport { isEqual, uniqBy } from 'lodash';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport FormRows from '@splunk/react-ui/FormRows';\nimport TextEditor from './TextEditor';\nimport ControlGroup from '../shared/AdvancedControlGroup';\n\nconst RowContainer = styled.div`\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 10px;\n [data-test='control-group'] {\n margin: 0;\n }\n`;\n\nconst formRowHeader = (\n <RowContainer>\n <span data-test=\"form-row-header-label\">{_('Label')}</span>\n <span data-test=\"form-row-header-value\">{_('Value')}</span>\n </RowContainer>\n);\n\n/**\n * Remove an item from an array, return a new array\n * @param {Array} items The list of items\n * @param {Number} index The index of the item to remove\n * @returns {Array} list of items without the item at the specified index\n */\nconst removeItem = (items, index) => items.filter((_item, idx) => idx !== index);\n\n/**\n * Detect when a list of static items contains an invalid entry\n * @param {StaticItem[]} items List of static items\n * @returns {Boolean} true when no label or value is an empty string\n */\nconst isValid = items =>\n // exit early when an error found\n !items.some(\n ({ label, value }) =>\n typeof label !== 'string' ||\n label.trim() === '' ||\n typeof value !== 'string' ||\n value.trim() === ''\n ) &&\n uniqBy(items, item => item.value).length === items.length &&\n uniqBy(items, item => item.label).length === items.length;\n\n/**\n * Detect if a label or value in the list is an error case\n * @param {String} value either an item label or value\n * @param {StaticItem[]} items List of all items\n * @param {label | value} key The StaticItem key to check\n */\nconst isItemError = (value, items, key) => {\n // Just have an invalid type\n if (typeof value !== 'string' || value.trim() === '') {\n return true;\n }\n\n // Check the value is unique\n return items.filter(i => i[key] === value).length > 1;\n};\n\nconst isLabelError = (label, items) => isItemError(label, items, 'label');\nconst isValueError = (value, items) => isItemError(value, items, 'value');\n\nconst InputContainer = styled.div`\n width: 100%;\n`;\n\nconst defaultValue = [];\n\nconst StaticItemEditor = ({\n onChange,\n name,\n value = defaultValue,\n labelPosition = 'top',\n label = '',\n validate,\n}) => {\n const [staticItems, setItems] = useState(value);\n const [nextIndex, setIndex] = useState(value.length);\n\n useEffect(() => {\n setItems(value);\n if (value.length > nextIndex) {\n setIndex(value.length);\n }\n }, [value, nextIndex]);\n\n const handleChange = useCallback(\n newItems => {\n if (!isEqual(newItems, value) && isValid(newItems)) {\n // don't save newItems to state,\n // as this component will get a prop change as a result of the onChange call\n onChange(null, name, newItems);\n } else {\n // save invalid values so UI updates.\n setItems(newItems);\n }\n },\n [value, name, onChange]\n );\n\n const handleRequestRemove = useCallback(\n (_evt, { index }) => {\n const newItems = removeItem(staticItems, index);\n\n handleChange(newItems);\n },\n [staticItems, handleChange]\n );\n\n const handleRequestMove = useCallback(\n ({ fromIndex, toIndex }) => {\n const item = staticItems[fromIndex];\n const newItems = removeItem(staticItems, fromIndex);\n\n newItems.splice(toIndex, 0, item);\n handleChange(newItems);\n },\n [staticItems, handleChange]\n );\n\n const handleItemChange = useCallback(\n (idx, key) =>\n (_evt, _name, val = '') => {\n const item = staticItems[idx];\n const newItems = [...staticItems];\n\n newItems.splice(idx, 1, { ...item, [key]: val.trim() });\n handleChange(newItems);\n },\n [staticItems, handleChange]\n );\n\n const handleRequestAdd = useCallback(() => {\n const newItems = staticItems.concat({\n label: `Label ${nextIndex}`,\n value: `menu_v${nextIndex}`,\n });\n\n setIndex(nextIndex + 1);\n handleChange(newItems);\n }, [staticItems, nextIndex, handleChange]);\n\n const rows = staticItems.map((item, idx) => {\n const { label: l, value: v } = item;\n return (\n <FormRows.Row\n index={idx}\n // eslint-disable-next-line react/no-array-index-key\n key={`${l}_${v}_${idx}`} // NOSONAR\n onRequestRemove={handleRequestRemove}\n >\n <RowContainer>\n <TextEditor\n label={_('Label')}\n hideLabel\n value={l}\n onChange={handleItemChange(idx, 'label')}\n name=\"item-label-editor\"\n error={isLabelError(l, staticItems)}\n validate={validate}\n />\n <TextEditor\n label={_('Value')}\n hideLabel\n value={v}\n onChange={handleItemChange(idx, 'value')}\n name=\"item-value-editor\"\n error={isValueError(v, staticItems)}\n validate={validate}\n />\n </RowContainer>\n </FormRows.Row>\n );\n });\n\n return (\n <ControlGroup label={label} labelPosition={labelPosition}>\n <InputContainer>\n <FormRows\n addLabel={_('Add new')}\n header={formRowHeader}\n onRequestAdd={handleRequestAdd}\n onRequestMove={handleRequestMove}\n >\n {rows}\n </FormRows>\n </InputContainer>\n </ControlGroup>\n );\n};\n\nStaticItemEditor.propTypes = {\n /**\n * Callback when changing the text value\n *\n * onChange function has the following properties\n * @param {SyntheticEvent} event The react `SyntheticEvent`\n * @param {String} name The option name\n * @param {StaticItem[]} value The option value\n */\n onChange: T.func.isRequired,\n /**\n * The option name\n */\n name: T.string.isRequired,\n /**\n * A human readable label for the option\n */\n label: T.string,\n /**\n * The option value\n */\n value: T.arrayOf(T.exact({ label: T.string, value: T.string })),\n /**\n * Label position\n */\n labelPosition: T.oneOf(['top', 'left']),\n /**\n * Validate the value of the editor\n */\n validate: T.func,\n};\n\nexport default StaticItemEditor;\n"],"names":["require","defaultLabelStyle","TextEditor","_ref","onChange","name","value","label","labelPosition","labelWidth","labelStyle","hideLabel","isAdvanced","isDisabled","help","tooltip","validate","error","otherProps","_objectWithoutProperties","_excluded","val","setValueState","useState","handleValidate","useCallback","newValue","errorState","setErrorState","debouncedHandleValidate","useMemo","debounce","newVal","useEffect","cancel","handleChange","_event","v","handleBlur","event","trim","newError","handleKeyPress","key","style","_objectSpread","React","ControlGroup","message","Text","_extends","editorStyle","onKeyDown","onBlur","disabled","canClear","propTypes","T","isRequired","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","filter","Boolean","map","child","cloneElement","flex","object","bool","func","width","module","exports","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call","n","getter","__esModule","d","a","definition","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","r","Symbol","toStringTag","RowContainer","styled","formRowHeader","removeItem","items","index","_item","idx","isItemError","i","length","isLabelError","isValueError","InputContainer","defaultValue","StaticItemEditor","staticItems","setItems","nextIndex","setIndex","newItems","isEqual","some","uniqBy","item","handleRequestRemove","_evt","handleRequestMove","fromIndex","toIndex","splice","handleItemChange","_name","handleRequestAdd","concat","rows","l","FormRows","onRequestRemove","addLabel","header","onRequestAdd","onRequestMove"],"sourceRoot":""}
1
+ {"version":3,"file":"StaticItemEditor.js","mappings":";;;;6GAAA,MAAM,EAA+BA,QAAQ,kD,yeCO7C,MAAMC,EAAoB,CAAC,EAErBC,EAAaC,IAgBb,IAhBc,SAChBC,EAAQ,KACRC,EAAI,MACJC,EAAQ,GAAE,MACVC,EAAK,cACLC,EAAgB,MAAK,WACrBC,EAAU,WACVC,EAA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,CACLE,UAAUtF,EAAAA,EAAAA,GAAE,WACZuF,OAAQtC,EACRuC,aAAcR,EACdS,cAAef,GAEdQ,IAGE,EAIvBpB,EAAiB3E,UAAY,CASzBpD,SAAUqD,IAAAA,KAAOC,WAIjBrD,KAAMoD,IAAAA,OAASC,WAIfnD,MAAOkD,IAAAA,OAIPnD,MAAOmD,IAAAA,QAAUA,IAAAA,MAAQ,CAAElD,MAAOkD,IAAAA,OAAUnD,MAAOmD,IAAAA,UAInDjD,cAAeiD,IAAAA,MAAQ,CAAC,MAAO,SAI/BzC,SAAUyC,IAAAA,MAGd,S","sources":["webpack://@splunk/dynamic-editors/external commonjs2 \"@babel/runtime/helpers/objectWithoutProperties\"","webpack://@splunk/dynamic-editors/./src/editors/TextEditor.jsx","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/./src/shared/dimensionConstants.ts","webpack://@splunk/dynamic-editors/external commonjs2 \"@babel/runtime/helpers/defineProperty\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@babel/runtime/helpers/extends\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-icons/SlidersDoubleHorizontal\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Button\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/ControlGroup\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/FormRows\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Text\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/react-ui/Tooltip\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/themes\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/ui-utils/i18n\"","webpack://@splunk/dynamic-editors/external commonjs2 \"lodash\"","webpack://@splunk/dynamic-editors/external commonjs2 \"prop-types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"react\"","webpack://@splunk/dynamic-editors/external commonjs2 \"styled-components\"","webpack://@splunk/dynamic-editors/webpack/bootstrap","webpack://@splunk/dynamic-editors/webpack/runtime/compat get default export","webpack://@splunk/dynamic-editors/webpack/runtime/define property getters","webpack://@splunk/dynamic-editors/webpack/runtime/hasOwnProperty shorthand","webpack://@splunk/dynamic-editors/webpack/runtime/make namespace object","webpack://@splunk/dynamic-editors/./src/editors/StaticItemEditor.jsx"],"sourcesContent":["const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@babel/runtime/helpers/objectWithoutProperties\");","import React, { useState, useCallback, useEffect, useMemo } from 'react';\nimport T from 'prop-types';\nimport { debounce } from 'lodash';\nimport Text from '@splunk/react-ui/Text';\nimport ControlGroup from '../shared/AdvancedControlGroup';\nimport { editorStyle } from '../shared/dimensionConstants';\n\nconst defaultLabelStyle = {};\n\nconst TextEditor = ({\n onChange,\n name,\n value = '',\n label,\n labelPosition = 'top',\n labelWidth,\n labelStyle = defaultLabelStyle,\n hideLabel = false,\n isAdvanced,\n isDisabled = false,\n help,\n tooltip,\n validate,\n error,\n ...otherProps\n}) => {\n const [val, setValueState] = useState(value);\n\n const handleValidate = useCallback(\n newValue => (typeof validate === 'function' ? validate({ value: newValue }) : null),\n [validate]\n );\n const [errorState, setErrorState] = useState(handleValidate(value));\n const debouncedHandleValidate = useMemo(\n () =>\n debounce(newVal => {\n setErrorState(handleValidate(newVal));\n }, 250),\n [handleValidate]\n );\n\n useEffect(\n () => () => {\n // cancel debounce on component unmount\n debouncedHandleValidate.cancel();\n },\n [debouncedHandleValidate]\n );\n\n useEffect(() => {\n setValueState(value);\n setErrorState(handleValidate(value));\n }, [handleValidate, value]);\n\n const handleChange = useCallback(\n (_event, { value: v }) => {\n setValueState(v);\n debouncedHandleValidate(v);\n },\n [debouncedHandleValidate]\n );\n\n const handleBlur = useCallback(\n event => {\n const newVal = val.trim();\n if (newVal === value) {\n return;\n }\n const newError = handleValidate(newVal);\n // set error if there is one, or clear an existing error\n setErrorState(newError);\n if (!newError) {\n // only change value if there is no validation error\n onChange(event, name, newVal);\n }\n },\n [val, value, handleValidate, onChange, name]\n );\n\n const handleKeyPress = useCallback(\n event => {\n if (event.key === 'Enter') {\n handleBlur(event);\n }\n },\n [handleBlur]\n );\n\n const style = useMemo(\n () =>\n !label || label === ''\n ? {\n ...labelStyle,\n }\n : labelStyle,\n [label, labelStyle]\n );\n\n return (\n <ControlGroup\n label={label}\n labelPosition={labelPosition}\n labelWidth={labelWidth}\n style={style}\n hideLabel={hideLabel}\n help={help}\n tooltip={tooltip}\n error={errorState?.message || error}\n isAdvanced={isAdvanced}\n >\n <Text\n key={value}\n data-test={name}\n style={editorStyle}\n onChange={handleChange}\n onKeyDown={handleKeyPress}\n onBlur={handleBlur}\n value={val}\n disabled={isDisabled}\n canClear\n {...otherProps}\n error={!!errorState || error}\n />\n </ControlGroup>\n );\n};\n\nTextEditor.propTypes = {\n /**\n * Callback when changing the text value\n *\n * @param {SyntheticEvent} event The react `SyntheticEvent`\n * @param {string} name The option name\n * @param {string} value The option value\n */\n onChange: T.func.isRequired,\n /**\n * The option name\n */\n name: T.string.isRequired,\n /**\n * A human readable label for the option\n */\n label: T.string.isRequired,\n /**\n * The option value\n */\n value: T.string,\n /**\n * Label position\n */\n labelPosition: T.oneOf(['top', 'left']),\n /**\n * Label width\n */\n labelWidth: T.number,\n /**\n * Styles to be passed to the ControlGroup\n */\n labelStyle: T.object,\n /**\n * Visually hide the label, but render it for screen readers\n */\n hideLabel: T.bool,\n /**\n * As advanced editor to show advanced config button\n */\n isAdvanced: T.bool,\n /**\n * Disabled state of component\n */\n isDisabled: T.bool,\n /**\n * Validate the value of the editor\n */\n validate: T.func,\n /**\n * If the input should display error state\n */\n error: T.bool,\n /**\n * Text to display under the the input\n */\n help: T.string,\n /**\n * Text to display in a tooltip next to the label\n */\n tooltip: T.string,\n};\n\nexport default TextEditor;\n","import React, { Children, cloneElement } from 'react';\nimport type { ReactElement } from 'react';\nimport * as T from 'prop-types';\nimport styled from 'styled-components';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport AdvancedConfigIcon from '@splunk/react-icons/SlidersDoubleHorizontal';\nimport { variables } from '@splunk/themes';\nimport Tooltip from '@splunk/react-ui/Tooltip';\nimport type { ButtonClickHandler, ButtonProps } from '@splunk/react-ui/Button';\nimport Button from '@splunk/react-ui/Button';\nimport SUIControlGroup from '@splunk/react-ui/ControlGroup';\nimport type { ControlGroupPropsBase } from '@splunk/react-ui/ControlGroup';\n\ninterface AdvancedControlGroupProps extends Omit<ControlGroupPropsBase, 'splunkTheme'> {\n 'data-test'?: string;\n style?: Record<string, string | number>;\n isAdvanced?: boolean;\n onClick?: React.MouseEventHandler<HTMLDivElement>;\n onAdvancedConfigButtonClick?: ButtonClickHandler;\n}\n\ninterface AdvancedConfigButtonProps {\n label?: string;\n onClick?: ButtonClickHandler;\n}\n\n// remove all surrounding margins. let parent add padding\nconst ControlGroupContainer = styled(SUIControlGroup)`\n margin-top: 0;\n padding: 0;\n // adjust bottom margin according to theme\n margin-bottom: ${variables.spacingMedium};\n width: 100%;\n\n // remove top margin of the first component in control group\n &:first-child {\n margin-top: 0;\n }\n\n // remove bottom margin of the last component in control group\n &:last-child {\n margin-bottom: 0;\n }\n // remove top padding on label of the first control group\n [data-test='label']:first-of-type {\n padding-top: 0;\n }\n`;\n\n// override tooltip to set desired config button style\nconst StyledToolTip = styled(Tooltip)`\n display: flex;\n > span {\n display: flex;\n width: 35px;\n }\n`;\n\nconst StyledAdvancedConfigButton = styled(Button)<ButtonProps>`\n color: ${variables.contentColorActive} !important;\n &:hover {\n background-color: ${variables.interactiveColorOverlayDrag} !important;\n }\n`;\n\nexport const AdvancedConfigButton = ({\n label = '',\n onClick,\n}: AdvancedConfigButtonProps): React.ReactElement => {\n return (\n <StyledToolTip\n data-test={`${label}-advanced-config-button-tooltip`}\n content={_('Advanced configurations')}\n >\n <StyledAdvancedConfigButton\n data-test={`${label}-advanced-config-button`}\n icon={<AdvancedConfigIcon data-test={`${label}-advanced-config-button-icon`} />}\n appearance=\"subtle\"\n onClick={onClick}\n />\n </StyledToolTip>\n );\n};\n\nconst AdvancedControlGroup = ({\n 'data-test': dataTest,\n children,\n isAdvanced = false,\n label,\n hideLabel,\n labelPosition,\n labelWidth,\n tooltip,\n help,\n style,\n error,\n controlsLayout,\n onClick,\n onAdvancedConfigButtonClick,\n}: AdvancedControlGroupProps): React.ReactElement => (\n <ControlGroupContainer\n data-test={dataTest ?? 'control-group'}\n label={label}\n hideLabel={hideLabel}\n labelPosition={labelPosition}\n labelWidth={labelWidth}\n tooltip={tooltip}\n help={help}\n error={error}\n style={style}\n onClick={onClick}\n controlsLayout={controlsLayout}\n >\n {isAdvanced\n ? Children.toArray(children)\n .filter(Boolean)\n .map(child =>\n cloneElement(child as ReactElement, {\n style: { flex: 1 },\n })\n )\n : children}\n {isAdvanced ? <AdvancedConfigButton label={label} onClick={onAdvancedConfigButtonClick} /> : null}\n </ControlGroupContainer>\n);\n\nAdvancedControlGroup.propTypes = {\n /**\n * Style overriding SUI ControlGroup\n */\n style: T.object,\n /**\n * Whether the current editor is enabled with advanced configurations\n */\n isAdvanced: T.bool,\n /**\n * Callback for editor click\n */\n onClick: T.func,\n /**\n * Callback for advanced config button click\n */\n onAdvancedConfigButtonClick: T.func,\n};\n\nexport default AdvancedControlGroup;\n","export const FLYOUT_PADDING = 21;\nexport const COLUMN_FLYOUT_PADDING = 16;\nexport const FLYOUT_WIDTH = 344;\n\nexport const VERTICAL_EDITOR_SPACING = 16;\n\nexport const DROPDOWN_MENU_WIDTH = 327;\n\nexport const editorStyle = { width: '100%' };\n","module.exports = require(\"@babel/runtime/helpers/defineProperty\");","module.exports = require(\"@babel/runtime/helpers/extends\");","module.exports = require(\"@splunk/react-icons/SlidersDoubleHorizontal\");","module.exports = require(\"@splunk/react-ui/Button\");","module.exports = require(\"@splunk/react-ui/ControlGroup\");","module.exports = require(\"@splunk/react-ui/FormRows\");","module.exports = require(\"@splunk/react-ui/Text\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"lodash\");","module.exports = require(\"prop-types\");","module.exports = require(\"react\");","module.exports = require(\"styled-components\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import React, { useCallback, useState, useEffect } from 'react';\nimport T from 'prop-types';\nimport styled from 'styled-components';\nimport { isEqual, uniqBy } from 'lodash';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport FormRows from '@splunk/react-ui/FormRows';\nimport TextEditor from './TextEditor';\nimport ControlGroup from '../shared/AdvancedControlGroup';\n\nconst RowContainer = styled.div`\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 10px;\n [data-test='control-group'] {\n margin: 0;\n }\n`;\n\nconst formRowHeader = (\n <RowContainer>\n <span data-test=\"form-row-header-label\">{_('Label')}</span>\n <span data-test=\"form-row-header-value\">{_('Value')}</span>\n </RowContainer>\n);\n\n/**\n * Remove an item from an array, return a new array\n * @param {Array} items The list of items\n * @param {Number} index The index of the item to remove\n * @returns {Array} list of items without the item at the specified index\n */\nconst removeItem = (items, index) => items.filter((_item, idx) => idx !== index);\n\n/**\n * Detect when a list of static items contains an invalid entry\n * @param {StaticItem[]} items List of static items\n * @returns {Boolean} true when no label or value is an empty string\n */\nconst isValid = items =>\n // exit early when an error found\n !items.some(\n ({ label, value }) =>\n typeof label !== 'string' ||\n label.trim() === '' ||\n typeof value !== 'string' ||\n value.trim() === ''\n ) &&\n uniqBy(items, item => item.value).length === items.length &&\n uniqBy(items, item => item.label).length === items.length;\n\n/**\n * Detect if a label or value in the list is an error case\n * @param {String} value either an item label or value\n * @param {StaticItem[]} items List of all items\n * @param {label | value} key The StaticItem key to check\n */\nconst isItemError = (value, items, key) => {\n // Just have an invalid type\n if (typeof value !== 'string' || value.trim() === '') {\n return true;\n }\n\n // Check the value is unique\n return items.filter(i => i[key] === value).length > 1;\n};\n\nconst isLabelError = (label, items) => isItemError(label, items, 'label');\nconst isValueError = (value, items) => isItemError(value, items, 'value');\n\nconst InputContainer = styled.div`\n width: 100%;\n`;\n\nconst defaultValue = [];\n\nconst StaticItemEditor = ({\n onChange,\n name,\n value = defaultValue,\n labelPosition = 'top',\n label = '',\n validate,\n}) => {\n const [staticItems, setItems] = useState(value);\n const [nextIndex, setIndex] = useState(value.length);\n\n useEffect(() => {\n setItems(value);\n if (value.length > nextIndex) {\n setIndex(value.length);\n }\n }, [value, nextIndex]);\n\n const handleChange = useCallback(\n newItems => {\n if (!isEqual(newItems, value) && isValid(newItems)) {\n // don't save newItems to state,\n // as this component will get a prop change as a result of the onChange call\n onChange(null, name, newItems);\n } else {\n // save invalid values so UI updates.\n setItems(newItems);\n }\n },\n [value, name, onChange]\n );\n\n const handleRequestRemove = useCallback(\n (_evt, { index }) => {\n const newItems = removeItem(staticItems, index);\n\n handleChange(newItems);\n },\n [staticItems, handleChange]\n );\n\n const handleRequestMove = useCallback(\n ({ fromIndex, toIndex }) => {\n const item = staticItems[fromIndex];\n const newItems = removeItem(staticItems, fromIndex);\n\n newItems.splice(toIndex, 0, item);\n handleChange(newItems);\n },\n [staticItems, handleChange]\n );\n\n const handleItemChange = useCallback(\n (idx, key) =>\n (_evt, _name, val = '') => {\n const item = staticItems[idx];\n const newItems = [...staticItems];\n\n newItems.splice(idx, 1, { ...item, [key]: val.trim() });\n handleChange(newItems);\n },\n [staticItems, handleChange]\n );\n\n const handleRequestAdd = useCallback(() => {\n const newItems = staticItems.concat({\n label: `Label ${nextIndex}`,\n value: `menu_v${nextIndex}`,\n });\n\n setIndex(nextIndex + 1);\n handleChange(newItems);\n }, [staticItems, nextIndex, handleChange]);\n\n const rows = staticItems.map((item, idx) => {\n const { label: l, value: v } = item;\n return (\n <FormRows.Row\n index={idx}\n // eslint-disable-next-line react/no-array-index-key\n key={`${l}_${v}_${idx}`} // NOSONAR\n onRequestRemove={handleRequestRemove}\n >\n <RowContainer>\n <TextEditor\n label={_('Label')}\n hideLabel\n value={l}\n onChange={handleItemChange(idx, 'label')}\n name=\"item-label-editor\"\n error={isLabelError(l, staticItems)}\n validate={validate}\n />\n <TextEditor\n label={_('Value')}\n hideLabel\n value={v}\n onChange={handleItemChange(idx, 'value')}\n name=\"item-value-editor\"\n error={isValueError(v, staticItems)}\n validate={validate}\n />\n </RowContainer>\n </FormRows.Row>\n );\n });\n\n return (\n <ControlGroup label={label} labelPosition={labelPosition}>\n <InputContainer>\n <FormRows\n addLabel={_('Add new')}\n header={formRowHeader}\n onRequestAdd={handleRequestAdd}\n onRequestMove={handleRequestMove}\n >\n {rows}\n </FormRows>\n </InputContainer>\n </ControlGroup>\n );\n};\n\nStaticItemEditor.propTypes = {\n /**\n * Callback when changing the text value\n *\n * onChange function has the following properties\n * @param {SyntheticEvent} event The react `SyntheticEvent`\n * @param {String} name The option name\n * @param {StaticItem[]} value The option value\n */\n onChange: T.func.isRequired,\n /**\n * The option name\n */\n name: T.string.isRequired,\n /**\n * A human readable label for the option\n */\n label: T.string,\n /**\n * The option value\n */\n value: T.arrayOf(T.exact({ label: T.string, value: T.string })),\n /**\n * Label position\n */\n labelPosition: T.oneOf(['top', 'left']),\n /**\n * Validate the value of the editor\n */\n validate: T.func,\n};\n\nexport default StaticItemEditor;\n"],"names":["require","defaultLabelStyle","TextEditor","_ref","onChange","name","value","label","labelPosition","labelWidth","labelStyle","hideLabel","isAdvanced","isDisabled","help","tooltip","validate","error","otherProps","_objectWithoutProperties","_excluded","val","setValueState","useState","handleValidate","useCallback","newValue","errorState","setErrorState","debouncedHandleValidate","useMemo","debounce","newVal","useEffect","cancel","handleChange","_event","v","handleBlur","event","trim","newError","handleKeyPress","key","style","_objectSpread","React","ControlGroup","message","Text","_extends","editorStyle","onKeyDown","onBlur","disabled","canClear","propTypes","T","isRequired","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","filter","Boolean","map","child","cloneElement","flex","object","bool","func","width","module","exports","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call","n","getter","__esModule","d","a","definition","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","r","Symbol","toStringTag","RowContainer","styled","formRowHeader","removeItem","items","index","_item","idx","isItemError","i","length","isLabelError","isValueError","InputContainer","defaultValue","StaticItemEditor","staticItems","setItems","nextIndex","setIndex","newItems","isEqual","some","uniqBy","item","handleRequestRemove","_evt","handleRequestMove","fromIndex","toIndex","splice","handleItemChange","_name","handleRequestAdd","concat","rows","l","FormRows","onRequestRemove","addLabel","header","onRequestAdd","onRequestMove"],"sourceRoot":""}