@splunk/dynamic-editors 0.38.1 → 0.38.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/DynamicEditor.js +1 -1
- package/DynamicEditor.js.map +1 -1
- package/containers/EditorItem.js +1 -1
- package/containers/EditorItem.js.map +1 -1
- package/containers/EditorLayout.js +1 -1
- package/containers/EditorLayout.js.map +1 -1
- package/containers/EditorLayoutItem.js +1 -1
- package/containers/EditorLayoutItem.js.map +1 -1
- package/editors/AdvancedConfigCard.js.map +1 -1
- package/editors/ArrayOfStringsEditor.js.map +1 -1
- package/editors/CheckboxEditor.js.map +1 -1
- package/editors/ColorEditor.js.map +1 -1
- package/editors/ColumnMultiSelectionByFieldNameEditor.js.map +1 -1
- package/editors/ColumnMultiSelectionEditor.js.map +1 -1
- package/editors/ColumnSelectionEditor.js.map +1 -1
- package/editors/DynamicColorEditor.js.map +1 -1
- package/editors/DynamicColorEditorWithPrecedence.js.map +1 -1
- package/editors/DynamicItemEditor.js.map +1 -1
- package/editors/ImageEditor.js.map +1 -1
- package/editors/MultiColorPickerEditor.js.map +1 -1
- package/editors/NumberEditor.js.map +1 -1
- package/editors/PercentEditor.js.map +1 -1
- package/editors/PresetSelectorEditor.js.map +1 -1
- package/editors/RadioBarEditor.js.map +1 -1
- package/editors/SelectEditor.js.map +1 -1
- package/editors/SeriesColorsByFieldEditor.js.map +1 -1
- package/editors/SeriesColorsEditor.js.map +1 -1
- package/editors/SliderEditor.js.map +1 -1
- package/editors/StaticItemEditor.js.map +1 -1
- package/editors/TableColumnFormatterEditor.js +1 -1
- package/editors/TableColumnFormatterEditor.js.map +1 -1
- package/editors/TableDynamicColorEditor.js.map +1 -1
- package/editors/TextAreaEditor.js.map +1 -1
- package/editors/TextEditor.js.map +1 -1
- package/editors/ThresholdEditor.js.map +1 -1
- package/editors/ToggleEditor.js.map +1 -1
- package/editors/useColumnSelectorFooterMessage.js.map +1 -1
- package/package.json +17 -17
- package/shared/AdvancedControlGroup.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnMultiSelectionByFieldNameEditor.js","mappings":";;;;g1BAAA,mBACA,WACA,aAEA,UACA,UACA,UACA,UACA,aAEa,EAAAA,YAAc,yCAO3B,MAAMC,EAAoF,GAEpFC,EAAwC,EAC1CC,OACAC,QACAC,QACAC,gBAAgB,MAChBC,aACAC,cAAa,EACbC,cAAa,EACbC,UACAC,qBACAC,gBAAgBX,EAChBY,eAGA,MAAMC,GAAa,IAAAC,eAAc,CAAEJ,qBAAoBK,cAAe,aAGhE,SAAEC,EAAQ,UAAEC,EAAS,UAAEC,IAAc,IAAAC,UACvC,KAAM,IAAAC,wBAAuBP,IAC7B,CAACA,IAECQ,GAAW,IAAAF,UAAQ,IAAMF,GAAaD,GAAYR,GAAY,CAACQ,EAAUR,EAAYS,KAGrF,QAAEK,EAAO,OAAEC,IAAW,IAAAJ,UAAQ,KAAMN,aAAU,EAAVA,EAAYW,OAAQ,CAAEF,QAAS,GAAIC,OAAQ,KAAM,CAACV,IACtFY,GAAkB,IAAAN,UAAQ,KAAM,IAAAO,6BAA4BJ,EAASC,IAAS,CAACD,EAASC,IAExFI,GAAa,IAAAR,UACf,KACI,IAAAS,oBACIzB,EACAsB,EAAgBI,KAAIC,GAASA,EAAM5B,SAE3C,CAACC,EAAOsB,IAGNM,GAAwB,IAAAC,cAC1B,CAACC,GAASC,aACNtB,EAASqB,EAAO/B,EAAMgC,EAAO,GAEjC,CAACtB,EAAUV,IAGf,OACI,wBAAC,UAAY,aACE,GAAG,EAAAH,eAAeG,IAC7BE,MAAOA,EACPC,cAAeA,EACfC,WAAYA,EACZG,QAASA,EACTF,WAAYA,GAEZ,wBAAC,UAAW,aACG,GAAG,EAAAR,sBAAsBG,IACpCU,SAAUmB,EACVG,OAAQP,EACRN,SAAUA,EACVc,iBAAkBjB,EAClBkB,SAAO,GAENX,EAAgBI,KAAIC,G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C,QAASI,GAGpEL,EAAOC,OACf,CCnB0BI,CAAoB,M","sources":["webpack://@splunk/dynamic-editors/./src/editors/ColumnMultiSelectionByFieldNameEditor.tsx","webpack://@splunk/dynamic-editors/./src/hooks/useDataSource.tsx","webpack://@splunk/dynamic-editors/./src/interfaces/BaseEditorProps.ts","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/./src/utils/columnSelectionUtils.ts","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/Multiselect\"","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 \"@splunk/visualization-context/DataSourceContext\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualizations-shared/dataSourceUtils\"","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 React, { useCallback, useMemo } from 'react';\nimport T from 'prop-types';\nimport Multiselect from '@splunk/react-ui/Multiselect';\nimport { DataType } from '@splunk/visualization-encoding/DataPrimitive';\nimport { getDataSourceStateInfo } from '@splunk/visualizations-shared/dataSourceUtils';\nimport { BaseEditorProps, BaseEditorPropTypes } from '../interfaces/BaseEditorProps';\nimport { useDataSource } from '../hooks/useDataSource';\nimport { getAvailableFieldsWithTypes, sanitizeFieldNames } from '../utils/columnSelectionUtils';\nimport ControlGroup from '../shared/AdvancedControlGroup';\n\nexport const EDITOR_NAME = 'columnMultiSelectionByFieldName-editor';\ninterface ColumnMultiSelectionByFieldNameEditorProps extends BaseEditorProps {\n tooltip?: boolean;\n filterByTypes?: DataType[];\n isAdvanced?: boolean;\n}\n\nconst defaultFilterByTypes: ColumnMultiSelectionByFieldNameEditorProps['filterByTypes'] = [];\n\nconst ColumnMultiSelectionByFieldNameEditor = ({\n name,\n value,\n label,\n labelPosition = 'top',\n labelWidth,\n isAdvanced = false,\n isDisabled = false,\n tooltip,\n dataSourceBindings,\n filterByTypes = defaultFilterByTypes,\n onChange,\n}: ColumnMultiSelectionByFieldNameEditorProps): JSX.Element => {\n // fetch dataSource fields\n const dataSource = useDataSource({ dataSourceBindings, dataSourceKey: 'primary' });\n\n // disable editor when necessary\n const { hasError, isMissing, isLoading } = useMemo(\n () => getDataSourceStateInfo(dataSource),\n [dataSource]\n );\n const disabled = useMemo(() => isMissing || hasError || isDisabled, [hasError, isDisabled, isMissing]);\n\n // get field types\n const { columns, fields } = useMemo(() => dataSource?.data || { columns: [], fields: [] }, [dataSource]);\n const fieldsWithTypes = useMemo(() => getAvailableFieldsWithTypes(columns, fields), [columns, fields]);\n\n const fieldNames = useMemo(\n () =>\n sanitizeFieldNames(\n value,\n fieldsWithTypes.map(field => field.name)\n ),\n [value, fieldsWithTypes]\n );\n\n const handleFieldNameChange = useCallback(\n (event, { values }): void => {\n onChange(event, name, values);\n },\n [onChange, name]\n );\n\n return (\n <ControlGroup\n data-test={`${EDITOR_NAME}-${name}`}\n label={label}\n labelPosition={labelPosition}\n labelWidth={labelWidth}\n tooltip={tooltip}\n isAdvanced={isAdvanced}\n >\n <Multiselect\n data-test={`${EDITOR_NAME}-select-${name}`}\n onChange={handleFieldNameChange}\n values={fieldNames}\n disabled={disabled}\n isLoadingOptions={isLoading}\n compact\n >\n {fieldsWithTypes.map(field => (\n <Multiselect.Option\n data-test={`${EDITOR_NAME}-option-${field.name}`}\n key={field.name}\n value={field.name}\n label={`${field.name} (${field.type})`}\n disabled={filterByTypes.length > 0 && !filterByTypes.find(f => f === field.type)}\n />\n ))}\n </Multiselect>\n </ControlGroup>\n );\n};\n\nColumnMultiSelectionByFieldNameEditor.propTypes = {\n ...BaseEditorPropTypes,\n tooltip: T.bool,\n labelPosition: T.oneOf(['top', 'left']),\n isAdvanced: T.bool,\n isDisabled: T.bool,\n};\n\nexport default ColumnMultiSelectionByFieldNameEditor;\n","import { useState, useEffect, useContext } from 'react';\nimport DataSourceContext, {\n type BindingsSnapshot,\n type DataSourceApi,\n} from '@splunk/visualization-context/DataSourceContext';\nimport { get, isFunction } from 'lodash';\n\ninterface UseDataSourceParams {\n dataSourceBindings: BindingsSnapshot;\n dataSourceKey: string;\n}\n// @TODO(pwied): use DataSource interface in return type (w/o dependency on @splunk/visualizations)\nexport const useDataSource = ({\n dataSourceBindings,\n dataSourceKey,\n}: UseDataSourceParams): BindingsSnapshot => {\n const dataSourceApi = useContext<DataSourceApi>(DataSourceContext);\n const [dataSource, setDataSource] = useState<BindingsSnapshot>();\n useEffect((): (() => void) => {\n if (!get(dataSourceBindings, dataSourceKey)) {\n setDataSource(null);\n return () => undefined;\n }\n const unsubscribe =\n isFunction(dataSourceApi.subscribe) &&\n dataSourceApi.subscribe(dataSourceKey, (snapshot): void => setDataSource(snapshot));\n return () => {\n if (unsubscribe) {\n unsubscribe();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataSourceBindings]);\n return dataSource;\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, 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, { 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","import { _ } from '@splunk/ui-utils/i18n';\nimport {\n inferDataTypeFromData,\n canInferTypeFromMeta,\n getDataTypeForMeta,\n} from '@splunk/visualization-encoding/utils/types';\n\nexport interface FieldTuple {\n name: string;\n type: string;\n}\n\nexport const getAvailableFieldsWithTypes = (\n columns: unknown[][],\n fields: { name: string; type?: string }[]\n): FieldTuple[] => {\n const fieldsWithType = fields.map((field, index) => {\n const { name } = field;\n const inferredType = canInferTypeFromMeta(field)\n ? getDataTypeForMeta(field)\n : inferDataTypeFromData(columns[index]);\n return {\n name,\n type: inferredType,\n };\n });\n return fieldsWithType;\n};\n\nexport const getFilteredFields = (availableFieldsWithTypes: FieldTuple[], filter: string): FieldTuple[] => {\n return availableFieldsWithTypes.filter((field): boolean => field.name.indexOf(filter) !== -1);\n};\n\nexport const sanitizeFieldNames = (value: unknown, fieldNames: string[]): string[] => {\n if (typeof value === 'string' && fieldNames.includes(value)) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(name => fieldNames.includes(name));\n }\n return [];\n};\n\nexport const getPlaceholderMessage = ({\n hasError,\n isLoading,\n isMissing,\n defaultMessage = 'Select a field from data source',\n}: {\n hasError: boolean;\n isLoading: boolean;\n isMissing: boolean;\n defaultMessage?: string;\n}): string => {\n if (isMissing) {\n return _('Set up data source to select');\n }\n if (hasError) {\n return _('Please set up valid data source to select');\n }\n if (isLoading) {\n return _('Loading data source...');\n }\n return _(defaultMessage);\n};\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/Multiselect\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@splunk/visualization-context/DataSourceContext\");","module.exports = require(\"@splunk/visualization-encoding/utils/types\");","module.exports = require(\"@splunk/visualizations-shared/dataSourceUtils\");","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__(9172);\n"],"names":["EDITOR_NAME","defaultFilterByTypes","ColumnMultiSelectionByFieldNameEditor","name","value","label","labelPosition","labelWidth","isAdvanced","isDisabled","tooltip","dataSourceBindings","filterByTypes","onChange","dataSource","useDataSource","dataSourceKey","hasError","isMissing","isLoading","useMemo","getDataSourceStateInfo","disabled","columns","fields","data","fieldsWithTypes","getAvailableFieldsWithTypes","fieldNames","sanitizeFieldNames","map","field","handleFieldNameChange","useCallback","event","values","isLoadingOptions","compact","Option","key","type","length","find","f","propTypes","BaseEditorPropTypes","bool","oneOf","dataSourceApi","useContext","setDataSource","useState","useEffect","get","unsubscribe","isFunction","subscribe","snapshot","T","string","isRequired","oneOfType","object","arrayOf","context","number","func","options","optionsSchema","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","hideLabel","help","style","error","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","filter","Boolean","child","cloneElement","flex","index","canInferTypeFromMeta","getDataTypeForMeta","inferDataTypeFromData","getFilteredFields","availableFieldsWithTypes","indexOf","includes","Array","isArray","getPlaceholderMessage","defaultMessage","module","exports","require","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"ColumnMultiSelectionByFieldNameEditor.js","mappings":";;;;g1BAAA,mBACA,WACA,aAEA,UACA,UAEA,UACA,UACA,aAEa,EAAAA,YAAc,yCAO3B,MAAMC,EAAoF,GAEpFC,EAAwC,EAC1CC,OACAC,QACAC,QACAC,gBAAgB,MAChBC,aACAC,cAAa,EACbC,cAAa,EACbC,UACAC,qBACAC,gBAAgBX,EAChBY,eAGA,MAAMC,GAAa,IAAAC,eAAc,CAAEJ,qBAAoBK,cAAe,aAGhE,SAAEC,EAAQ,UAAEC,EAAS,UAAEC,IAAc,IAAAC,UACvC,KAAM,IAAAC,wBAAuBP,IAC7B,CAACA,IAECQ,GAAW,IAAAF,UAAQ,IAAMF,GAAaD,GAAYR,GAAY,CAACQ,EAAUR,EAAYS,KAGrF,QAAEK,EAAO,OAAEC,IAAW,IAAAJ,UAAQ,KAAMN,aAAU,EAAVA,EAAYW,OAAQ,CAAEF,QAAS,GAAIC,OAAQ,KAAM,CAACV,IACtFY,GAAkB,IAAAN,UAAQ,KAAM,IAAAO,6BAA4BJ,EAASC,IAAS,CAACD,EAASC,IAExFI,GAAa,IAAAR,UACf,KACI,IAAAS,oBACIzB,EACAsB,EAAgBI,KAAIC,GAASA,EAAM5B,SAE3C,CAACC,EAAOsB,IAGNM,GAAwB,IAAAC,cAC1B,CAACC,GAASC,aACNtB,EAASqB,EAAO/B,EAAMgC,EAAO,GAEjC,CAACtB,EAAUV,IAGf,OACI,wBAAC,UAAY,aACE,GAAG,EAAAH,eAAeG,IAC7BE,MAAOA,EACPC,cAAeA,EACfC,WAAYA,EACZG,QAASA,EACTF,WAAYA,GAEZ,wBAAC,UAAW,aACG,GAAG,EAAAR,sBAAsBG,IACpCU,SAAUmB,EACVG,OAAQP,EACRN,SAAUA,EACVc,iBAAkBjB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GAAUI,KAAKV,EAAOC,QAASD,EAAQA,EAAOC,QAASI,GAGpEL,EAAOC,OACf,CCnB0BI,CAAoB,M","sources":["webpack://@splunk/dynamic-editors/./src/editors/ColumnMultiSelectionByFieldNameEditor.tsx","webpack://@splunk/dynamic-editors/./src/hooks/useDataSource.tsx","webpack://@splunk/dynamic-editors/./src/interfaces/BaseEditorProps.ts","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/./src/utils/columnSelectionUtils.ts","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/Multiselect\"","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 \"@splunk/visualization-context/DataSourceContext\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualizations-shared/dataSourceUtils\"","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 React, { useCallback, useMemo } from 'react';\nimport T from 'prop-types';\nimport Multiselect from '@splunk/react-ui/Multiselect';\nimport { DataType } from '@splunk/visualization-encoding/DataPrimitive';\nimport { getDataSourceStateInfo } from '@splunk/visualizations-shared/dataSourceUtils';\nimport { BaseEditorPropTypes } from '../interfaces/BaseEditorProps';\nimport type { BaseEditorProps } from '../interfaces/BaseEditorProps';\nimport { useDataSource } from '../hooks/useDataSource';\nimport { getAvailableFieldsWithTypes, sanitizeFieldNames } from '../utils/columnSelectionUtils';\nimport ControlGroup from '../shared/AdvancedControlGroup';\n\nexport const EDITOR_NAME = 'columnMultiSelectionByFieldName-editor';\ninterface ColumnMultiSelectionByFieldNameEditorProps extends BaseEditorProps {\n tooltip?: boolean;\n filterByTypes?: DataType[];\n isAdvanced?: boolean;\n}\n\nconst defaultFilterByTypes: ColumnMultiSelectionByFieldNameEditorProps['filterByTypes'] = [];\n\nconst ColumnMultiSelectionByFieldNameEditor = ({\n name,\n value,\n label,\n labelPosition = 'top',\n labelWidth,\n isAdvanced = false,\n isDisabled = false,\n tooltip,\n dataSourceBindings,\n filterByTypes = defaultFilterByTypes,\n onChange,\n}: ColumnMultiSelectionByFieldNameEditorProps): JSX.Element => {\n // fetch dataSource fields\n const dataSource = useDataSource({ dataSourceBindings, dataSourceKey: 'primary' });\n\n // disable editor when necessary\n const { hasError, isMissing, isLoading } = useMemo(\n () => getDataSourceStateInfo(dataSource),\n [dataSource]\n );\n const disabled = useMemo(() => isMissing || hasError || isDisabled, [hasError, isDisabled, isMissing]);\n\n // get field types\n const { columns, fields } = useMemo(() => dataSource?.data || { columns: [], fields: [] }, [dataSource]);\n const fieldsWithTypes = useMemo(() => getAvailableFieldsWithTypes(columns, fields), [columns, fields]);\n\n const fieldNames = useMemo(\n () =>\n sanitizeFieldNames(\n value,\n fieldsWithTypes.map(field => field.name)\n ),\n [value, fieldsWithTypes]\n );\n\n const handleFieldNameChange = useCallback(\n (event, { values }): void => {\n onChange(event, name, values);\n },\n [onChange, name]\n );\n\n return (\n <ControlGroup\n data-test={`${EDITOR_NAME}-${name}`}\n label={label}\n labelPosition={labelPosition}\n labelWidth={labelWidth}\n tooltip={tooltip}\n isAdvanced={isAdvanced}\n >\n <Multiselect\n data-test={`${EDITOR_NAME}-select-${name}`}\n onChange={handleFieldNameChange}\n values={fieldNames}\n disabled={disabled}\n isLoadingOptions={isLoading}\n compact\n >\n {fieldsWithTypes.map(field => (\n <Multiselect.Option\n data-test={`${EDITOR_NAME}-option-${field.name}`}\n key={field.name}\n value={field.name}\n label={`${field.name} (${field.type})`}\n disabled={filterByTypes.length > 0 && !filterByTypes.find(f => f === field.type)}\n />\n ))}\n </Multiselect>\n </ControlGroup>\n );\n};\n\nColumnMultiSelectionByFieldNameEditor.propTypes = {\n ...BaseEditorPropTypes,\n tooltip: T.bool,\n labelPosition: T.oneOf(['top', 'left']),\n isAdvanced: T.bool,\n isDisabled: T.bool,\n};\n\nexport default ColumnMultiSelectionByFieldNameEditor;\n","import { useState, useEffect, useContext } from 'react';\nimport DataSourceContext, {\n type BindingsSnapshot,\n type DataSourceApi,\n} from '@splunk/visualization-context/DataSourceContext';\nimport { get, isFunction } from 'lodash';\n\ninterface UseDataSourceParams {\n dataSourceBindings: BindingsSnapshot;\n dataSourceKey: string;\n}\n// @TODO(pwied): use DataSource interface in return type (w/o dependency on @splunk/visualizations)\nexport const useDataSource = ({\n dataSourceBindings,\n dataSourceKey,\n}: UseDataSourceParams): BindingsSnapshot => {\n const dataSourceApi = useContext<DataSourceApi>(DataSourceContext);\n const [dataSource, setDataSource] = useState<BindingsSnapshot>();\n useEffect((): (() => void) => {\n if (!get(dataSourceBindings, dataSourceKey)) {\n setDataSource(null);\n return () => undefined;\n }\n const unsubscribe =\n isFunction(dataSourceApi.subscribe) &&\n dataSourceApi.subscribe(dataSourceKey, (snapshot): void => setDataSource(snapshot));\n return () => {\n if (unsubscribe) {\n unsubscribe();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataSourceBindings]);\n return dataSource;\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","import { _ } from '@splunk/ui-utils/i18n';\nimport {\n inferDataTypeFromData,\n canInferTypeFromMeta,\n getDataTypeForMeta,\n} from '@splunk/visualization-encoding/utils/types';\n\nexport interface FieldTuple {\n name: string;\n type: string;\n}\n\nexport const getAvailableFieldsWithTypes = (\n columns: unknown[][],\n fields: { name: string; type?: string }[]\n): FieldTuple[] => {\n const fieldsWithType = fields.map((field, index) => {\n const { name } = field;\n const inferredType = canInferTypeFromMeta(field)\n ? getDataTypeForMeta(field)\n : inferDataTypeFromData(columns[index]);\n return {\n name,\n type: inferredType,\n };\n });\n return fieldsWithType;\n};\n\nexport const getFilteredFields = (availableFieldsWithTypes: FieldTuple[], filter: string): FieldTuple[] => {\n return availableFieldsWithTypes.filter((field): boolean => field.name.indexOf(filter) !== -1);\n};\n\nexport const sanitizeFieldNames = (value: unknown, fieldNames: string[]): string[] => {\n if (typeof value === 'string' && fieldNames.includes(value)) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(name => fieldNames.includes(name));\n }\n return [];\n};\n\nexport const getPlaceholderMessage = ({\n hasError,\n isLoading,\n isMissing,\n defaultMessage = 'Select a field from data source',\n}: {\n hasError: boolean;\n isLoading: boolean;\n isMissing: boolean;\n defaultMessage?: string;\n}): string => {\n if (isMissing) {\n return _('Set up data source to select');\n }\n if (hasError) {\n return _('Please set up valid data source to select');\n }\n if (isLoading) {\n return _('Loading data source...');\n }\n return _(defaultMessage);\n};\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/Multiselect\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@splunk/visualization-context/DataSourceContext\");","module.exports = require(\"@splunk/visualization-encoding/utils/types\");","module.exports = require(\"@splunk/visualizations-shared/dataSourceUtils\");","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__(9172);\n"],"names":["EDITOR_NAME","defaultFilterByTypes","ColumnMultiSelectionByFieldNameEditor","name","value","label","labelPosition","labelWidth","isAdvanced","isDisabled","tooltip","dataSourceBindings","filterByTypes","onChange","dataSource","useDataSource","dataSourceKey","hasError","isMissing","isLoading","useMemo","getDataSourceStateInfo","disabled","columns","fields","data","fieldsWithTypes","getAvailableFieldsWithTypes","fieldNames","sanitizeFieldNames","map","field","handleFieldNameChange","useCallback","event","values","isLoadingOptions","compact","Option","key","type","length","find","f","propTypes","BaseEditorPropTypes","bool","oneOf","dataSourceApi","useContext","setDataSource","useState","useEffect","get","unsubscribe","isFunction","subscribe","snapshot","T","string","isRequired","oneOfType","object","arrayOf","context","number","func","options","optionsSchema","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","hideLabel","help","style","error","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","filter","Boolean","child","cloneElement","flex","index","canInferTypeFromMeta","getDataTypeForMeta","inferDataTypeFromData","getFilteredFields","availableFieldsWithTypes","indexOf","includes","Array","isArray","getPlaceholderMessage","defaultMessage","module","exports","require","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call"],"sourceRoot":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnMultiSelectionEditor.js","mappings":";;;;42BAAA,mBACA,WACA,aACA,UACA,UACA,UAEA,UACA,UACA,UACA,aACA,UASMA,EAAS,+BACR,EAAAC,qBAAmB,CACtBC,cAAeC,EAAEC,OAAOC,WACxBC,aAAcH,EAAEI,KAChBC,eAAgBL,EAAEM,QAAQN,EAAEC,QAC5BM,cAAeP,EAAEM,QAAQN,EAAEC,QAC3BO,yBAA0BR,EAAES,OAGnB,EAAAC,WAAcC,IAAoC,MAC3D,OAAW,QAAX,EAAAA,aAAK,EAALA,EAAOC,YAAI,eAAEC,WAAW,OAAuB,UAAfF,EAAMC,IAAgB,EAE7C,EAAAE,2BAAuF,EAChGF,OACAG,QACAC,QAAQ,GACRC,gBAAgB,MAChBlB,gBAAgB,UAChBmB,qBACAf,eAAe,CAACgB,GAAyDA,GACzEC,WACAC,aACAC,aACAd,4BAA2B,EAC3BD,gBACAF,qBAEA,MAAMkB,GAAa,IAAAC,eAAc,CAAEN,qBAAoBnB,mBACjD,QAAE0B,EAAO,OAAEC,IAAWH,aAAU,EAAVA,EAAYI,OAAQ,CAAEF,QAAS,GAAIC,OAAQ,IACjEE,GAAqB,IAAAC,UACvB,IACIrB,EACMe,EACA,OAAD,wBACQA,GAAU,CACbI,KAAM,CACFD,OAAQA,EAAOI,QAAQnB,KAA6B,IAAAD,YAAWC,KAC/Dc,QAASA,EAAQK,QAAO,CAACC,EAASC,MAAe,IAAAtB,YAAWgB,EAAOM,UAGrF,CAACP,EAASF,EAAYG,EAAQlB,KAE1BiB,QAASQ,EAAiBP,OAAQQ,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MultiSelectionEditor.tsx","webpack://@splunk/dynamic-editors/./src/editors/useColumnSelectorFooterMessage.tsx","webpack://@splunk/dynamic-editors/./src/hooks/useDataSource.tsx","webpack://@splunk/dynamic-editors/./src/interfaces/BaseEditorProps.ts","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/./src/shared/ColumnSelectorFooterMessage.tsx","webpack://@splunk/dynamic-editors/./src/utils/columnSelectionUtils.ts","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/Multiselect\"","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/format\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/ui-utils/i18n\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-context/DataSourceContext\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/dsl\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualizations-shared/dataSourceUtils\"","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 React, { useState, useCallback, useMemo } from 'react';\nimport * as T from 'prop-types';\nimport Multiselect from '@splunk/react-ui/Multiselect';\nimport { get } from 'lodash';\nimport { getFieldsFromDSL } from '@splunk/visualization-encoding/utils/dsl';\nimport { getDataSourceStateInfo } from '@splunk/visualizations-shared/dataSourceUtils';\nimport { DataType } from '@splunk/visualization-encoding/DataPrimitive';\nimport { BaseEditorProps, BaseEditorPropTypes } from '../interfaces/BaseEditorProps';\nimport { useDataSource } from '../hooks/useDataSource';\nimport { getAvailableFieldsWithTypes, getPlaceholderMessage } from '../utils/columnSelectionUtils';\nimport ControlGroup from '../shared/AdvancedControlGroup';\nimport { useColumnSelectorFooterMessage } from './useColumnSelectorFooterMessage';\n\ninterface ColumnMultiSelectionEditorProps extends BaseEditorProps {\n dataSourceKey: string;\n prepareValue?: (id: Record<string, any>) => Record<string, any>;\n excludeByNames?: string[];\n filterByTypes?: DataType[];\n shouldShowInternalFields?: boolean;\n}\nconst propTypes: Record<keyof ColumnMultiSelectionEditorProps, T.Validator<any>> = {\n ...BaseEditorPropTypes,\n dataSourceKey: T.string.isRequired,\n prepareValue: T.func,\n excludeByNames: T.arrayOf(T.string),\n filterByTypes: T.arrayOf(T.string),\n shouldShowInternalFields: T.bool,\n};\n\nexport const isInternal = (field: { name: string }): boolean =>\n field?.name?.startsWith('_') && field.name !== '_time';\n\nexport const ColumnMultiSelectionEditor: React.FunctionComponent<ColumnMultiSelectionEditorProps> = ({\n name,\n value,\n label = '',\n labelPosition = 'top',\n dataSourceKey = 'primary',\n dataSourceBindings,\n prepareValue = (id: Record<string, unknown>): Record<string, unknown> => id,\n onChange,\n isAdvanced,\n isDisabled,\n shouldShowInternalFields = true,\n filterByTypes,\n excludeByNames,\n}) => {\n const dataSource = useDataSource({ dataSourceBindings, dataSourceKey });\n const { columns, fields } = dataSource?.data || { columns: [], fields: [] };\n const adjustedDataSource = useMemo(\n () =>\n shouldShowInternalFields\n ? dataSource\n : {\n ...dataSource,\n data: {\n fields: fields.filter((field: { name: string }) => !isInternal(field)),\n columns: columns.filter((_c: any, i: number) => !isInternal(fields[i])),\n },\n },\n [columns, dataSource, fields, shouldShowInternalFields]\n );\n const { columns: adjustedColumns, fields: adjustedFields } = get(adjustedDataSource, 'data') || {\n columns: [],\n fields: [],\n };\n const availableFieldsWithTypes = useMemo(\n () => getAvailableFieldsWithTypes(adjustedColumns, adjustedFields),\n [adjustedColumns, adjustedFields]\n );\n const [filter, setFilter] = useState('');\n // return `value` if `value` is undefined or null so editor shows placeholder message\n const fieldNames = useMemo(\n () =>\n value == null\n ? value\n : getFieldsFromDSL(value, {\n [dataSourceKey]: adjustedDataSource,\n }),\n [adjustedDataSource, dataSourceKey, value]\n );\n const [selectedFields, setSelectedFields] = useState<string[]>(fieldNames || []);\n\n React.useEffect((): void => {\n if (fieldNames?.length) {\n setSelectedFields(fieldNames);\n }\n }, [fieldNames]);\n\n const filteredFields = availableFieldsWithTypes.filter(\n (field): boolean => field.name.indexOf(filter) !== -1\n );\n const footerMessage = useColumnSelectorFooterMessage({\n availableFields: availableFieldsWithTypes,\n filteredFields,\n filter,\n selectedFields,\n });\n\n const handleValuesChange = useCallback(\n (event, { values: selectedValues }): void => {\n setSelectedFields(selectedValues);\n const seriesNamesStr = `'${selectedValues.join(\"','\")}'`;\n const update = prepareValue({\n options: {\n [name]: `> ${dataSourceKey} | frameBySeriesNames(${seriesNamesStr})`,\n },\n });\n onChange(event, update);\n },\n [dataSourceKey, name, onChange, prepareValue]\n );\n\n const handleFilterChange = useCallback((e, { keyword }): void => {\n setFilter(keyword);\n }, []);\n\n const { hasError, isMissing, isLoading } = getDataSourceStateInfo(dataSource);\n const disabled = isMissing || hasError || isDisabled;\n const placeholderMessage = getPlaceholderMessage({\n isMissing,\n isLoading,\n hasError,\n defaultMessage: 'Select field(s) from data source',\n });\n return (\n <ControlGroup label={label} labelPosition={labelPosition} isAdvanced={isAdvanced}>\n <Multiselect\n data-test=\"ColumnMultiSelectionEditor\"\n disabled={disabled}\n values={selectedFields}\n onChange={handleValuesChange}\n onFilterChange={handleFilterChange}\n footerMessage={footerMessage}\n placeholder={placeholderMessage}\n isLoadingOptions={isLoading}\n error={hasError}\n compact\n >\n {filteredFields.map(field => (\n <Multiselect.Option\n key={field.name}\n label={`${field.name} (${field.type})`}\n value={field.name}\n disabled={\n (filterByTypes?.length && !filterByTypes.find(f => f === field.type)) ||\n excludeByNames?.includes(field.name)\n }\n />\n ))}\n </Multiselect>\n </ControlGroup>\n );\n};\nColumnMultiSelectionEditor.propTypes = propTypes;\n\nexport default ColumnMultiSelectionEditor;\n","import React, { useMemo } from 'react';\nimport { ColumnSelectorFooterMessage } from '../shared/ColumnSelectorFooterMessage';\nimport { FieldTuple } from '../utils/columnSelectionUtils';\n\ntype ObjectWithName = {\n name: string;\n [key: string]: string;\n};\n\ntype Fields = FieldTuple[] | ObjectWithName[];\n\ninterface FooterMessageProps {\n noSelectedFieldsInfo?: boolean;\n filter: string;\n availableFields: Fields;\n selectedFields?: string[];\n filteredFields: Fields;\n}\n\nexport const useColumnSelectorFooterMessage = ({\n filter,\n availableFields,\n selectedFields,\n filteredFields,\n noSelectedFieldsInfo = false,\n}: FooterMessageProps) => {\n const selectedFilteredFields = useMemo(() => {\n if (!selectedFields || !filteredFields) return [];\n\n const validSelectedFields = new Set(\n selectedFields.filter(field => field !== '' && field !== undefined)\n );\n\n return filteredFields.filter(item => validSelectedFields.has(item.name));\n }, [selectedFields, filteredFields]);\n\n // make sure to display only 'No matches' text when there is no result of filtering\n if (filter && !filteredFields.length) {\n return null;\n }\n\n return (\n <ColumnSelectorFooterMessage\n noSelectedFieldsInfo={noSelectedFieldsInfo}\n numSelected={selectedFilteredFields?.length} // if no filter is applied filteredFields equal availableFields\n numFiltered={filteredFields.length}\n numAvailable={availableFields.length}\n filter={filter}\n />\n );\n};\n","import { useState, useEffect, useContext } from 'react';\nimport DataSourceContext, {\n type BindingsSnapshot,\n type DataSourceApi,\n} from '@splunk/visualization-context/DataSourceContext';\nimport { get, isFunction } from 'lodash';\n\ninterface UseDataSourceParams {\n dataSourceBindings: BindingsSnapshot;\n dataSourceKey: string;\n}\n// @TODO(pwied): use DataSource interface in return type (w/o dependency on @splunk/visualizations)\nexport const useDataSource = ({\n dataSourceBindings,\n dataSourceKey,\n}: UseDataSourceParams): BindingsSnapshot => {\n const dataSourceApi = useContext<DataSourceApi>(DataSourceContext);\n const [dataSource, setDataSource] = useState<BindingsSnapshot>();\n useEffect((): (() => void) => {\n if (!get(dataSourceBindings, dataSourceKey)) {\n setDataSource(null);\n return () => undefined;\n }\n const unsubscribe =\n isFunction(dataSourceApi.subscribe) &&\n dataSourceApi.subscribe(dataSourceKey, (snapshot): void => setDataSource(snapshot));\n return () => {\n if (unsubscribe) {\n unsubscribe();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataSourceBindings]);\n return dataSource;\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, 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, { 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","import * as React from 'react';\nimport { sprintf } from '@splunk/ui-utils/format';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport { useMemo } from 'react';\n\ninterface FooterProps {\n filter: string;\n numSelected?: number;\n numFiltered: number;\n numAvailable: number;\n noSelectedFieldsInfo?: boolean; // it is needed for AddColumn component which has different logic than other selection editors\n}\n\nexport const ColumnSelectorFooterMessage = ({\n numSelected,\n numFiltered,\n numAvailable,\n filter,\n noSelectedFieldsInfo,\n}: FooterProps) => {\n const footerMessageText = useMemo(() => {\n if (filter) {\n if (noSelectedFieldsInfo) {\n return sprintf(_('%(filtered)d filtered from %(available)d fields'), {\n filtered: numFiltered,\n available: numAvailable,\n });\n }\n return sprintf(_('%(selected)d selected from %(filtered)d filtered'), {\n selected: numSelected,\n filtered: numFiltered,\n });\n }\n return noSelectedFieldsInfo\n ? sprintf(_('%(shown)d of %(available)d fields'), {\n shown: numFiltered,\n available: numAvailable,\n })\n : sprintf(_('%(selected)d selected from %(available)d'), {\n selected: numSelected,\n available: numAvailable,\n });\n }, [filter, noSelectedFieldsInfo, numFiltered, numAvailable, numSelected]);\n\n return (\n <span data-test=\"footer-message\" aria-live=\"polite\" aria-atomic=\"true\">\n {footerMessageText}\n </span>\n );\n};\n","import { _ } from '@splunk/ui-utils/i18n';\nimport {\n inferDataTypeFromData,\n canInferTypeFromMeta,\n getDataTypeForMeta,\n} from '@splunk/visualization-encoding/utils/types';\n\nexport interface FieldTuple {\n name: string;\n type: string;\n}\n\nexport const getAvailableFieldsWithTypes = (\n columns: unknown[][],\n fields: { name: string; type?: string }[]\n): FieldTuple[] => {\n const fieldsWithType = fields.map((field, index) => {\n const { name } = field;\n const inferredType = canInferTypeFromMeta(field)\n ? getDataTypeForMeta(field)\n : inferDataTypeFromData(columns[index]);\n return {\n name,\n type: inferredType,\n };\n });\n return fieldsWithType;\n};\n\nexport const getFilteredFields = (availableFieldsWithTypes: FieldTuple[], filter: string): FieldTuple[] => {\n return availableFieldsWithTypes.filter((field): boolean => field.name.indexOf(filter) !== -1);\n};\n\nexport const sanitizeFieldNames = (value: unknown, fieldNames: string[]): string[] => {\n if (typeof value === 'string' && fieldNames.includes(value)) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(name => fieldNames.includes(name));\n }\n return [];\n};\n\nexport const getPlaceholderMessage = ({\n hasError,\n isLoading,\n isMissing,\n defaultMessage = 'Select a field from data source',\n}: {\n hasError: boolean;\n isLoading: boolean;\n isMissing: boolean;\n defaultMessage?: string;\n}): string => {\n if (isMissing) {\n return _('Set up data source to select');\n }\n if (hasError) {\n return _('Please set up valid data source to select');\n }\n if (isLoading) {\n return _('Loading data source...');\n }\n return _(defaultMessage);\n};\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/Multiselect\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/format\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@splunk/visualization-context/DataSourceContext\");","module.exports = require(\"@splunk/visualization-encoding/utils/dsl\");","module.exports = require(\"@splunk/visualization-encoding/utils/types\");","module.exports = require(\"@splunk/visualizations-shared/dataSourceUtils\");","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__(4942);\n"],"names":["propTypes","BaseEditorPropTypes","dataSourceKey","T","string","isRequired","prepareValue","func","excludeByNames","arrayOf","filterByTypes","shouldShowInternalFields","bool","isInternal","field","name","startsWith","ColumnMultiSelectionEditor","value","label","labelPosition","dataSourceBindings","id","onChange","isAdvanced","isDisabled","dataSource","useDataSource","columns","fields","data","adjustedDataSource","useMemo","filter","_c","i","adjustedColumns","adjustedFields","get","availableFieldsWithTypes","getAvailableFieldsWithTypes","setFilter","useState","fieldNames","getFieldsFromDSL","selectedFields","setSelectedFields","useEffect","length","filteredFields","indexOf","footerMessage","useColumnSelectorFooterMessage","availableFields","handleValuesChange","useCallback","event","values","selectedValues","seriesNamesStr","join","update","options","handleFilterChange","e","keyword","hasError","isMissing","isLoading","getDataSourceStateInfo","disabled","placeholderMessage","getPlaceholderMessage","defaultMessage","onFilterChange","placeholder","isLoadingOptions","error","compact","map","Option","key","type","find","f","includes","noSelectedFieldsInfo","selectedFilteredFields","validSelectedFields","Set","undefined","item","has","ColumnSelectorFooterMessage","numSelected","numFiltered","numAvailable","dataSourceApi","useContext","setDataSource","unsubscribe","isFunction","subscribe","snapshot","oneOfType","object","context","oneOf","labelWidth","number","optionsSchema","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","hideLabel","tooltip","help","style","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","Boolean","child","cloneElement","flex","footerMessageText","sprintf","filtered","available","selected","shown","index","canInferTypeFromMeta","getDataTypeForMeta","inferDataTypeFromData","getFilteredFields","sanitizeFieldNames","Array","isArray","module","exports","require","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"ColumnMultiSelectionEditor.js","mappings":";;;;42BAAA,mBACA,WACA,aACA,UACA,UACA,UAEA,UAEA,UACA,UACA,aACA,UASMA,EAAS,+BACR,EAAAC,qBAAmB,CACtBC,cAAeC,EAAEC,OAAOC,WACxBC,aAAcH,EAAEI,KAChBC,eAAgBL,EAAEM,QAAQN,EAAEC,QAC5BM,cAAeP,EAAEM,QAAQN,EAAEC,QAC3BO,yBAA0BR,EAAES,OAGnB,EAAAC,WAAcC,IAAoC,MAC3D,OAAW,QAAX,EAAAA,aAAK,EAALA,EAAOC,YAAI,eAAEC,WAAW,OAAuB,UAAfF,EAAMC,IAAgB,EAE7C,EAAAE,2BAAuF,EAChGF,OACAG,QACAC,QAAQ,GACRC,gBAAgB,MAChBlB,gBAAgB,UAChBmB,qBACAf,eAAe,CAACgB,GAAyDA,GACzEC,WACAC,aACAC,aACAd,4BAA2B,EAC3BD,g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AAUC,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,QAAqBrE,IAAjBsE,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,M","sources":["webpack://@splunk/dynamic-editors/./src/editors/ColumnMultiSelectionEditor.tsx","webpack://@splunk/dynamic-editors/./src/editors/useColumnSelectorFooterMessage.tsx","webpack://@splunk/dynamic-editors/./src/hooks/useDataSource.tsx","webpack://@splunk/dynamic-editors/./src/interfaces/BaseEditorProps.ts","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/./src/shared/ColumnSelectorFooterMessage.tsx","webpack://@splunk/dynamic-editors/./src/utils/columnSelectionUtils.ts","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/Multiselect\"","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/format\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/ui-utils/i18n\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-context/DataSourceContext\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/dsl\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualizations-shared/dataSourceUtils\"","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 React, { useState, useCallback, useMemo } from 'react';\nimport * as T from 'prop-types';\nimport Multiselect from '@splunk/react-ui/Multiselect';\nimport { get } from 'lodash';\nimport { getFieldsFromDSL } from '@splunk/visualization-encoding/utils/dsl';\nimport { getDataSourceStateInfo } from '@splunk/visualizations-shared/dataSourceUtils';\nimport { DataType } from '@splunk/visualization-encoding/DataPrimitive';\nimport { BaseEditorPropTypes } from '../interfaces/BaseEditorProps';\nimport type { BaseEditorProps } from '../interfaces/BaseEditorProps';\nimport { useDataSource } from '../hooks/useDataSource';\nimport { getAvailableFieldsWithTypes, getPlaceholderMessage } from '../utils/columnSelectionUtils';\nimport ControlGroup from '../shared/AdvancedControlGroup';\nimport { useColumnSelectorFooterMessage } from './useColumnSelectorFooterMessage';\n\ninterface ColumnMultiSelectionEditorProps extends BaseEditorProps {\n dataSourceKey: string;\n prepareValue?: (id: Record<string, any>) => Record<string, any>;\n excludeByNames?: string[];\n filterByTypes?: DataType[];\n shouldShowInternalFields?: boolean;\n}\nconst propTypes: Record<keyof ColumnMultiSelectionEditorProps, T.Validator<any>> = {\n ...BaseEditorPropTypes,\n dataSourceKey: T.string.isRequired,\n prepareValue: T.func,\n excludeByNames: T.arrayOf(T.string),\n filterByTypes: T.arrayOf(T.string),\n shouldShowInternalFields: T.bool,\n};\n\nexport const isInternal = (field: { name: string }): boolean =>\n field?.name?.startsWith('_') && field.name !== '_time';\n\nexport const ColumnMultiSelectionEditor: React.FunctionComponent<ColumnMultiSelectionEditorProps> = ({\n name,\n value,\n label = '',\n labelPosition = 'top',\n dataSourceKey = 'primary',\n dataSourceBindings,\n prepareValue = (id: Record<string, unknown>): Record<string, unknown> => id,\n onChange,\n isAdvanced,\n isDisabled,\n shouldShowInternalFields = true,\n filterByTypes,\n excludeByNames,\n}) => {\n const dataSource = useDataSource({ dataSourceBindings, dataSourceKey });\n const { columns, fields } = dataSource?.data || { columns: [], fields: [] };\n const adjustedDataSource = useMemo(\n () =>\n shouldShowInternalFields\n ? dataSource\n : {\n ...dataSource,\n data: {\n fields: fields.filter((field: { name: string }) => !isInternal(field)),\n columns: columns.filter((_c: any, i: number) => !isInternal(fields[i])),\n },\n },\n [columns, dataSource, fields, shouldShowInternalFields]\n );\n const { columns: adjustedColumns, fields: adjustedFields } = get(adjustedDataSource, 'data') || {\n columns: [],\n fields: [],\n };\n const availableFieldsWithTypes = useMemo(\n () => getAvailableFieldsWithTypes(adjustedColumns, adjustedFields),\n [adjustedColumns, adjustedFields]\n );\n const [filter, setFilter] = useState('');\n // return `value` if `value` is undefined or null so editor shows placeholder message\n const fieldNames = useMemo(\n () =>\n value == null\n ? value\n : getFieldsFromDSL(value, {\n [dataSourceKey]: adjustedDataSource,\n }),\n [adjustedDataSource, dataSourceKey, value]\n );\n const [selectedFields, setSelectedFields] = useState<string[]>(fieldNames || []);\n\n React.useEffect((): void => {\n if (fieldNames?.length) {\n setSelectedFields(fieldNames);\n }\n }, [fieldNames]);\n\n const filteredFields = availableFieldsWithTypes.filter(\n (field): boolean => field.name.indexOf(filter) !== -1\n );\n const footerMessage = useColumnSelectorFooterMessage({\n availableFields: availableFieldsWithTypes,\n filteredFields,\n filter,\n selectedFields,\n });\n\n const handleValuesChange = useCallback(\n (event, { values: selectedValues }): void => {\n setSelectedFields(selectedValues);\n const seriesNamesStr = `'${selectedValues.join(\"','\")}'`;\n const update = prepareValue({\n options: {\n [name]: `> ${dataSourceKey} | frameBySeriesNames(${seriesNamesStr})`,\n },\n });\n onChange(event, update);\n },\n [dataSourceKey, name, onChange, prepareValue]\n );\n\n const handleFilterChange = useCallback((e, { keyword }): void => {\n setFilter(keyword);\n }, []);\n\n const { hasError, isMissing, isLoading } = getDataSourceStateInfo(dataSource);\n const disabled = isMissing || hasError || isDisabled;\n const placeholderMessage = getPlaceholderMessage({\n isMissing,\n isLoading,\n hasError,\n defaultMessage: 'Select field(s) from data source',\n });\n return (\n <ControlGroup label={label} labelPosition={labelPosition} isAdvanced={isAdvanced}>\n <Multiselect\n data-test=\"ColumnMultiSelectionEditor\"\n disabled={disabled}\n values={selectedFields}\n onChange={handleValuesChange}\n onFilterChange={handleFilterChange}\n footerMessage={footerMessage}\n placeholder={placeholderMessage}\n isLoadingOptions={isLoading}\n error={hasError}\n compact\n >\n {filteredFields.map(field => (\n <Multiselect.Option\n key={field.name}\n label={`${field.name} (${field.type})`}\n value={field.name}\n disabled={\n (filterByTypes?.length && !filterByTypes.find(f => f === field.type)) ||\n excludeByNames?.includes(field.name)\n }\n />\n ))}\n </Multiselect>\n </ControlGroup>\n );\n};\nColumnMultiSelectionEditor.propTypes = propTypes;\n\nexport default ColumnMultiSelectionEditor;\n","import React, { useMemo } from 'react';\nimport { ColumnSelectorFooterMessage } from '../shared/ColumnSelectorFooterMessage';\nimport type { FieldTuple } from '../utils/columnSelectionUtils';\n\ntype ObjectWithName = {\n name: string;\n [key: string]: string;\n};\n\ntype Fields = FieldTuple[] | ObjectWithName[];\n\ninterface FooterMessageProps {\n noSelectedFieldsInfo?: boolean;\n filter: string;\n availableFields: Fields;\n selectedFields?: string[];\n filteredFields: Fields;\n}\n\nexport const useColumnSelectorFooterMessage = ({\n filter,\n availableFields,\n selectedFields,\n filteredFields,\n noSelectedFieldsInfo = false,\n}: FooterMessageProps) => {\n const selectedFilteredFields = useMemo(() => {\n if (!selectedFields || !filteredFields) return [];\n\n const validSelectedFields = new Set(\n selectedFields.filter(field => field !== '' && field !== undefined)\n );\n\n return filteredFields.filter(item => validSelectedFields.has(item.name));\n }, [selectedFields, filteredFields]);\n\n // make sure to display only 'No matches' text when there is no result of filtering\n if (filter && !filteredFields.length) {\n return null;\n }\n\n return (\n <ColumnSelectorFooterMessage\n noSelectedFieldsInfo={noSelectedFieldsInfo}\n numSelected={selectedFilteredFields?.length} // if no filter is applied filteredFields equal availableFields\n numFiltered={filteredFields.length}\n numAvailable={availableFields.length}\n filter={filter}\n />\n );\n};\n","import { useState, useEffect, useContext } from 'react';\nimport DataSourceContext, {\n type BindingsSnapshot,\n type DataSourceApi,\n} from '@splunk/visualization-context/DataSourceContext';\nimport { get, isFunction } from 'lodash';\n\ninterface UseDataSourceParams {\n dataSourceBindings: BindingsSnapshot;\n dataSourceKey: string;\n}\n// @TODO(pwied): use DataSource interface in return type (w/o dependency on @splunk/visualizations)\nexport const useDataSource = ({\n dataSourceBindings,\n dataSourceKey,\n}: UseDataSourceParams): BindingsSnapshot => {\n const dataSourceApi = useContext<DataSourceApi>(DataSourceContext);\n const [dataSource, setDataSource] = useState<BindingsSnapshot>();\n useEffect((): (() => void) => {\n if (!get(dataSourceBindings, dataSourceKey)) {\n setDataSource(null);\n return () => undefined;\n }\n const unsubscribe =\n isFunction(dataSourceApi.subscribe) &&\n dataSourceApi.subscribe(dataSourceKey, (snapshot): void => setDataSource(snapshot));\n return () => {\n if (unsubscribe) {\n unsubscribe();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataSourceBindings]);\n return dataSource;\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","import * as React from 'react';\nimport { sprintf } from '@splunk/ui-utils/format';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport { useMemo } from 'react';\n\ninterface FooterProps {\n filter: string;\n numSelected?: number;\n numFiltered: number;\n numAvailable: number;\n noSelectedFieldsInfo?: boolean; // it is needed for AddColumn component which has different logic than other selection editors\n}\n\nexport const ColumnSelectorFooterMessage = ({\n numSelected,\n numFiltered,\n numAvailable,\n filter,\n noSelectedFieldsInfo,\n}: FooterProps) => {\n const footerMessageText = useMemo(() => {\n if (filter) {\n if (noSelectedFieldsInfo) {\n return sprintf(_('%(filtered)d filtered from %(available)d fields'), {\n filtered: numFiltered,\n available: numAvailable,\n });\n }\n return sprintf(_('%(selected)d selected from %(filtered)d filtered'), {\n selected: numSelected,\n filtered: numFiltered,\n });\n }\n return noSelectedFieldsInfo\n ? sprintf(_('%(shown)d of %(available)d fields'), {\n shown: numFiltered,\n available: numAvailable,\n })\n : sprintf(_('%(selected)d selected from %(available)d'), {\n selected: numSelected,\n available: numAvailable,\n });\n }, [filter, noSelectedFieldsInfo, numFiltered, numAvailable, numSelected]);\n\n return (\n <span data-test=\"footer-message\" aria-live=\"polite\" aria-atomic=\"true\">\n {footerMessageText}\n </span>\n );\n};\n","import { _ } from '@splunk/ui-utils/i18n';\nimport {\n inferDataTypeFromData,\n canInferTypeFromMeta,\n getDataTypeForMeta,\n} from '@splunk/visualization-encoding/utils/types';\n\nexport interface FieldTuple {\n name: string;\n type: string;\n}\n\nexport const getAvailableFieldsWithTypes = (\n columns: unknown[][],\n fields: { name: string; type?: string }[]\n): FieldTuple[] => {\n const fieldsWithType = fields.map((field, index) => {\n const { name } = field;\n const inferredType = canInferTypeFromMeta(field)\n ? getDataTypeForMeta(field)\n : inferDataTypeFromData(columns[index]);\n return {\n name,\n type: inferredType,\n };\n });\n return fieldsWithType;\n};\n\nexport const getFilteredFields = (availableFieldsWithTypes: FieldTuple[], filter: string): FieldTuple[] => {\n return availableFieldsWithTypes.filter((field): boolean => field.name.indexOf(filter) !== -1);\n};\n\nexport const sanitizeFieldNames = (value: unknown, fieldNames: string[]): string[] => {\n if (typeof value === 'string' && fieldNames.includes(value)) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(name => fieldNames.includes(name));\n }\n return [];\n};\n\nexport const getPlaceholderMessage = ({\n hasError,\n isLoading,\n isMissing,\n defaultMessage = 'Select a field from data source',\n}: {\n hasError: boolean;\n isLoading: boolean;\n isMissing: boolean;\n defaultMessage?: string;\n}): string => {\n if (isMissing) {\n return _('Set up data source to select');\n }\n if (hasError) {\n return _('Please set up valid data source to select');\n }\n if (isLoading) {\n return _('Loading data source...');\n }\n return _(defaultMessage);\n};\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/Multiselect\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/format\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@splunk/visualization-context/DataSourceContext\");","module.exports = require(\"@splunk/visualization-encoding/utils/dsl\");","module.exports = require(\"@splunk/visualization-encoding/utils/types\");","module.exports = require(\"@splunk/visualizations-shared/dataSourceUtils\");","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__(4942);\n"],"names":["propTypes","BaseEditorPropTypes","dataSourceKey","T","string","isRequired","prepareValue","func","excludeByNames","arrayOf","filterByTypes","shouldShowInternalFields","bool","isInternal","field","name","startsWith","ColumnMultiSelectionEditor","value","label","labelPosition","dataSourceBindings","id","onChange","isAdvanced","isDisabled","dataSource","useDataSource","columns","fields","data","adjustedDataSource","useMemo","filter","_c","i","adjustedColumns","adjustedFields","get","availableFieldsWithTypes","getAvailableFieldsWithTypes","setFilter","useState","fieldNames","getFieldsFromDSL","selectedFields","setSelectedFields","useEffect","length","filteredFields","indexOf","footerMessage","useColumnSelectorFooterMessage","availableFields","handleValuesChange","useCallback","event","values","selectedValues","seriesNamesStr","join","update","options","handleFilterChange","e","keyword","hasError","isMissing","isLoading","getDataSourceStateInfo","disabled","placeholderMessage","getPlaceholderMessage","defaultMessage","onFilterChange","placeholder","isLoadingOptions","error","compact","map","Option","key","type","find","f","includes","noSelectedFieldsInfo","selectedFilteredFields","validSelectedFields","Set","undefined","item","has","ColumnSelectorFooterMessage","numSelected","numFiltered","numAvailable","dataSourceApi","useContext","setDataSource","unsubscribe","isFunction","subscribe","snapshot","oneOfType","object","context","oneOf","labelWidth","number","optionsSchema","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","hideLabel","tooltip","help","style","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","Boolean","child","cloneElement","flex","footerMessageText","sprintf","filtered","available","selected","shown","index","canInferTypeFromMeta","getDataTypeForMeta","inferDataTypeFromData","getFilteredFields","sanitizeFieldNames","Array","isArray","module","exports","require","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"sourceRoot":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnSelectionEditor.js","mappings":";;;;01BAAA,mBACA,WACA,a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AUC,QAAQ,Q,UCAzBF,EAAOC,QAAUC,QAAQ,oB,GCCrBC,EAA2B,CAAC,ECEhC,IAAIC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqB9E,IAAjB+E,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,M","sources":["webpack://@splunk/dynamic-editors/./src/editors/ColumnSelectionEditor.tsx","webpack://@splunk/dynamic-editors/./src/editors/useColumnSelectorFooterMessage.tsx","webpack://@splunk/dynamic-editors/./src/hooks/useDataSource.tsx","webpack://@splunk/dynamic-editors/./src/interfaces/BaseEditorProps.ts","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/./src/shared/ColumnSelectorFooterMessage.tsx","webpack://@splunk/dynamic-editors/./src/shared/dimensionConstants.ts","webpack://@splunk/dynamic-editors/./src/utils/columnSelectionUtils.ts","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/Select\"","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/format\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/ui-utils/i18n\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-context/DataSourceContext\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/dsl\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualizations-shared/dataSourceUtils\"","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 React, { useState, useCallback } from 'react';\nimport * as T from 'prop-types';\nimport Select from '@splunk/react-ui/Select';\nimport { getFieldsFromDSL } from '@splunk/visualization-encoding/utils/dsl';\nimport { getDataSourceStateInfo } from '@splunk/visualizations-shared/dataSourceUtils';\nimport { DataType } from '@splunk/visualization-encoding/DataPrimitive';\nimport { BaseEditorProps, BaseEditorPropTypes } from '../interfaces/BaseEditorProps';\nimport { useDataSource } from '../hooks/useDataSource';\nimport { getAvailableFieldsWithTypes, getPlaceholderMessage } from '../utils/columnSelectionUtils';\nimport ControlGroup from '../shared/AdvancedControlGroup';\nimport { editorStyle } from '../shared/dimensionConstants';\nimport { useColumnSelectorFooterMessage } from './useColumnSelectorFooterMessage';\n\ninterface ColumnSelectionEditorProps extends BaseEditorProps {\n dataSourceKey: string;\n prepareValue?: (id: Record<string, any>) => Record<string, any>;\n filterByTypes?: DataType[];\n tooltip?: string;\n}\nconst propTypes: Record<keyof ColumnSelectionEditorProps, T.Validator<any>> = {\n ...BaseEditorPropTypes,\n dataSourceKey: T.string.isRequired,\n prepareValue: T.func,\n filterByTypes: T.arrayOf(T.string),\n tooltip: T.string,\n};\nexport const ColumnSelectionEditor: React.FunctionComponent<ColumnSelectionEditorProps> = ({\n name,\n value,\n label = '',\n labelPosition = 'top',\n dataSourceKey = 'primary',\n dataSourceBindings,\n prepareValue = (id: Record<string, unknown>): Record<string, unknown> => id,\n onChange,\n isAdvanced,\n isDisabled,\n filterByTypes,\n tooltip,\n}) => {\n const dataSource = useDataSource({ dataSourceBindings, dataSourceKey });\n const { columns, fields } = dataSource?.data || { columns: [], fields: [] };\n const availableFieldsWithTypes = getAvailableFieldsWithTypes(columns, fields);\n // return `value` if `value` is undefined or null so editor shows placeholder message\n const fieldName =\n value == null\n ? value\n : getFieldsFromDSL(value, {\n [dataSourceKey]: dataSource,\n })[0] || '';\n const [selectedField, setSelectedField] = useState(fieldName);\n React.useEffect((): void => {\n setSelectedField(fieldName);\n }, [fieldName]);\n const [filter, setFilter] = useState('');\n const filteredFields = availableFieldsWithTypes.filter(\n (field): boolean => field.name.indexOf(filter) !== -1\n );\n const footerMessage = useColumnSelectorFooterMessage({\n availableFields: availableFieldsWithTypes,\n selectedFields: [selectedField],\n filteredFields,\n filter,\n });\n\n const handleValueChange = useCallback(\n (event, { value: selectedValue }): void => {\n setSelectedField(selectedValue);\n const update = prepareValue({\n options: {\n [name]: `> ${dataSourceKey} | seriesByName('${selectedValue}')`,\n },\n });\n onChange(event, update);\n },\n [dataSourceKey, name, onChange, prepareValue]\n );\n\n const handleFilterChange = useCallback((e, { keyword }): void => {\n setFilter(keyword);\n }, []);\n const { hasError, isMissing, isLoading } = getDataSourceStateInfo(dataSource);\n const disabled = isMissing || hasError || isDisabled;\n const placeholderMessage = getPlaceholderMessage({ isMissing, isLoading, hasError });\n\n return (\n <ControlGroup label={label} labelPosition={labelPosition} tooltip={tooltip} isAdvanced={isAdvanced}>\n <Select\n data-test=\"ColumnSelectionEditor\"\n value={selectedField}\n onFilterChange={handleFilterChange}\n onChange={handleValueChange}\n footerMessage={footerMessage}\n disabled={disabled}\n placeholder={placeholderMessage}\n isLoadingOptions={isLoading}\n error={hasError}\n style={editorStyle}\n filter\n >\n {filteredFields.map(field => (\n <Select.Option\n key={field.name}\n label={`${field.name} (${field.type})`}\n value={field.name}\n disabled={!!filterByTypes?.length && !filterByTypes.find(f => f === field.type)}\n />\n ))}\n </Select>\n </ControlGroup>\n );\n};\nColumnSelectionEditor.propTypes = propTypes;\n\nexport default ColumnSelectionEditor;\n","import React, { useMemo } from 'react';\nimport { ColumnSelectorFooterMessage } from '../shared/ColumnSelectorFooterMessage';\nimport { FieldTuple } from '../utils/columnSelectionUtils';\n\ntype ObjectWithName = {\n name: string;\n [key: string]: string;\n};\n\ntype Fields = FieldTuple[] | ObjectWithName[];\n\ninterface FooterMessageProps {\n noSelectedFieldsInfo?: boolean;\n filter: string;\n availableFields: Fields;\n selectedFields?: string[];\n filteredFields: Fields;\n}\n\nexport const useColumnSelectorFooterMessage = ({\n filter,\n availableFields,\n selectedFields,\n filteredFields,\n noSelectedFieldsInfo = false,\n}: FooterMessageProps) => {\n const selectedFilteredFields = useMemo(() => {\n if (!selectedFields || !filteredFields) return [];\n\n const validSelectedFields = new Set(\n selectedFields.filter(field => field !== '' && field !== undefined)\n );\n\n return filteredFields.filter(item => validSelectedFields.has(item.name));\n }, [selectedFields, filteredFields]);\n\n // make sure to display only 'No matches' text when there is no result of filtering\n if (filter && !filteredFields.length) {\n return null;\n }\n\n return (\n <ColumnSelectorFooterMessage\n noSelectedFieldsInfo={noSelectedFieldsInfo}\n numSelected={selectedFilteredFields?.length} // if no filter is applied filteredFields equal availableFields\n numFiltered={filteredFields.length}\n numAvailable={availableFields.length}\n filter={filter}\n />\n );\n};\n","import { useState, useEffect, useContext } from 'react';\nimport DataSourceContext, {\n type BindingsSnapshot,\n type DataSourceApi,\n} from '@splunk/visualization-context/DataSourceContext';\nimport { get, isFunction } from 'lodash';\n\ninterface UseDataSourceParams {\n dataSourceBindings: BindingsSnapshot;\n dataSourceKey: string;\n}\n// @TODO(pwied): use DataSource interface in return type (w/o dependency on @splunk/visualizations)\nexport const useDataSource = ({\n dataSourceBindings,\n dataSourceKey,\n}: UseDataSourceParams): BindingsSnapshot => {\n const dataSourceApi = useContext<DataSourceApi>(DataSourceContext);\n const [dataSource, setDataSource] = useState<BindingsSnapshot>();\n useEffect((): (() => void) => {\n if (!get(dataSourceBindings, dataSourceKey)) {\n setDataSource(null);\n return () => undefined;\n }\n const unsubscribe =\n isFunction(dataSourceApi.subscribe) &&\n dataSourceApi.subscribe(dataSourceKey, (snapshot): void => setDataSource(snapshot));\n return () => {\n if (unsubscribe) {\n unsubscribe();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataSourceBindings]);\n return dataSource;\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, 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, { 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","import * as React from 'react';\nimport { sprintf } from '@splunk/ui-utils/format';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport { useMemo } from 'react';\n\ninterface FooterProps {\n filter: string;\n numSelected?: number;\n numFiltered: number;\n numAvailable: number;\n noSelectedFieldsInfo?: boolean; // it is needed for AddColumn component which has different logic than other selection editors\n}\n\nexport const ColumnSelectorFooterMessage = ({\n numSelected,\n numFiltered,\n numAvailable,\n filter,\n noSelectedFieldsInfo,\n}: FooterProps) => {\n const footerMessageText = useMemo(() => {\n if (filter) {\n if (noSelectedFieldsInfo) {\n return sprintf(_('%(filtered)d filtered from %(available)d fields'), {\n filtered: numFiltered,\n available: numAvailable,\n });\n }\n return sprintf(_('%(selected)d selected from %(filtered)d filtered'), {\n selected: numSelected,\n filtered: numFiltered,\n });\n }\n return noSelectedFieldsInfo\n ? sprintf(_('%(shown)d of %(available)d fields'), {\n shown: numFiltered,\n available: numAvailable,\n })\n : sprintf(_('%(selected)d selected from %(available)d'), {\n selected: numSelected,\n available: numAvailable,\n });\n }, [filter, noSelectedFieldsInfo, numFiltered, numAvailable, numSelected]);\n\n return (\n <span data-test=\"footer-message\" aria-live=\"polite\" aria-atomic=\"true\">\n {footerMessageText}\n </span>\n );\n};\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","import { _ } from '@splunk/ui-utils/i18n';\nimport {\n inferDataTypeFromData,\n canInferTypeFromMeta,\n getDataTypeForMeta,\n} from '@splunk/visualization-encoding/utils/types';\n\nexport interface FieldTuple {\n name: string;\n type: string;\n}\n\nexport const getAvailableFieldsWithTypes = (\n columns: unknown[][],\n fields: { name: string; type?: string }[]\n): FieldTuple[] => {\n const fieldsWithType = fields.map((field, index) => {\n const { name } = field;\n const inferredType = canInferTypeFromMeta(field)\n ? getDataTypeForMeta(field)\n : inferDataTypeFromData(columns[index]);\n return {\n name,\n type: inferredType,\n };\n });\n return fieldsWithType;\n};\n\nexport const getFilteredFields = (availableFieldsWithTypes: FieldTuple[], filter: string): FieldTuple[] => {\n return availableFieldsWithTypes.filter((field): boolean => field.name.indexOf(filter) !== -1);\n};\n\nexport const sanitizeFieldNames = (value: unknown, fieldNames: string[]): string[] => {\n if (typeof value === 'string' && fieldNames.includes(value)) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(name => fieldNames.includes(name));\n }\n return [];\n};\n\nexport const getPlaceholderMessage = ({\n hasError,\n isLoading,\n isMissing,\n defaultMessage = 'Select a field from data source',\n}: {\n hasError: boolean;\n isLoading: boolean;\n isMissing: boolean;\n defaultMessage?: string;\n}): string => {\n if (isMissing) {\n return _('Set up data source to select');\n }\n if (hasError) {\n return _('Please set up valid data source to select');\n }\n if (isLoading) {\n return _('Loading data source...');\n }\n return _(defaultMessage);\n};\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/Select\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/format\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@splunk/visualization-context/DataSourceContext\");","module.exports = require(\"@splunk/visualization-encoding/utils/dsl\");","module.exports = require(\"@splunk/visualization-encoding/utils/types\");","module.exports = require(\"@splunk/visualizations-shared/dataSourceUtils\");","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__(5731);\n"],"names":["propTypes","BaseEditorPropTypes","dataSourceKey","T","string","isRequired","prepareValue","func","filterByTypes","arrayOf","tooltip","ColumnSelectionEditor","name","value","label","labelPosition","dataSourceBindings","id","onChange","isAdvanced","isDisabled","dataSource","useDataSource","columns","fields","data","availableFieldsWithTypes","getAvailableFieldsWithTypes","fieldName","getFieldsFromDSL","selectedField","setSelectedField","useState","useEffect","filter","setFilter","filteredFields","field","indexOf","footerMessage","useColumnSelectorFooterMessage","availableFields","selectedFields","handleValueChange","useCallback","event","selectedValue","update","options","handleFilterChange","e","keyword","hasError","isMissing","isLoading","getDataSourceStateInfo","disabled","placeholderMessage","getPlaceholderMessage","onFilterChange","placeholder","isLoadingOptions","error","style","editorStyle","map","Option","key","type","length","find","f","noSelectedFieldsInfo","selectedFilteredFields","useMemo","validSelectedFields","Set","undefined","item","has","ColumnSelectorFooterMessage","numSelected","numFiltered","numAvailable","dataSourceApi","useContext","setDataSource","get","unsubscribe","isFunction","subscribe","snapshot","oneOfType","object","context","oneOf","labelWidth","number","bool","optionsSchema","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","hideLabel","help","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","Boolean","child","cloneElement","flex","footerMessageText","sprintf","filtered","available","selected","shown","FLYOUT_PADDING","COLUMN_FLYOUT_PADDING","FLYOUT_WIDTH","VERTICAL_EDITOR_SPACING","DROPDOWN_MENU_WIDTH","width","index","canInferTypeFromMeta","getDataTypeForMeta","inferDataTypeFromData","getFilteredFields","sanitizeFieldNames","fieldNames","includes","Array","isArray","defaultMessage","module","exports","require","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"ColumnSelectionEditor.js","mappings":";;;;01BAAA,mBACA,WACA,aACA,UACA,UAEA,UAEA,UACA,UACA,aACA,UACA,UAQMA,EAAS,+BACR,EAAAC,qBAAmB,CACtBC,cAAeC,EAAEC,OAAOC,WACxBC,aAAcH,EAAEI,KAChBC,cAAeL,EAAEM,QAAQN,EAAEC,QAC3BM,QAASP,EAAEC,SAEF,EAAAO,sBAA6E,EACtFC,OACAC,QACAC,QAAQ,GACRC,gBAAgB,MAChBb,gBAAgB,UAChBc,qBACAV,eAAe,CAACW,GAAyDA,GACzEC,WACAC,aACAC,aACAZ,gBACAE,cAEA,MAAMW,GAAa,IAAAC,eAAc,CAAEN,qBAAoBd,mBACjD,QAAEqB,EAAO,OAAEC,IAAWH,aAAU,EAAVA,EAAYI,OAAQ,CAAEF,QAAS,GAAIC,OAAQ,IACjEE,GAA2B,IAAAC,6BAA4BJ,EAASC,GAEhEI,EACO,MAATf,EACMA,GACA,IAAAgB,kB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,GAAQoI,EAAWC,SAASrI,KAE7C,GAGE,EAAA8C,sBAAwB,EACjCN,WACAE,YACAD,YACA+F,iBAAiB,qCAOb/F,GACO,IAAAyD,GAAE,gCAET1D,GACO,IAAA0D,GAAE,6CAETxD,GACO,IAAAwD,GAAE,2BAEN,IAAAA,GAAEsC,E,WC/DbC,EAAOC,QAAUC,QAAQ,8C,WCAzBF,EAAOC,QAAUC,QAAQ,0B,WCAzBF,EAAOC,QAAUC,QAAQ,gC,WCAzBF,EAAOC,QAAUC,QAAQ,0B,WCAzBF,EAAOC,QAAUC,QAAQ,2B,WCAzBF,EAAOC,QAAUC,QAAQ,iB,WCAzBF,EAAOC,QAAUC,QAAQ,0B,WCAzBF,EAAOC,QAAUC,QAAQ,wB,WCAzBF,EAAOC,QAAUC,QAAQ,kD,WCAzBF,EAAOC,QAAUC,QAAQ,2C,WCAzBF,EAAOC,QAAUC,QAAQ,6C,WCAzBF,EAAOC,QAAUC,QAAQ,gD,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,QAAqB9E,IAAjB+E,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,M","sources":["webpack://@splunk/dynamic-editors/./src/editors/ColumnSelectionEditor.tsx","webpack://@splunk/dynamic-editors/./src/editors/useColumnSelectorFooterMessage.tsx","webpack://@splunk/dynamic-editors/./src/hooks/useDataSource.tsx","webpack://@splunk/dynamic-editors/./src/interfaces/BaseEditorProps.ts","webpack://@splunk/dynamic-editors/./src/shared/AdvancedControlGroup.tsx","webpack://@splunk/dynamic-editors/./src/shared/ColumnSelectorFooterMessage.tsx","webpack://@splunk/dynamic-editors/./src/shared/dimensionConstants.ts","webpack://@splunk/dynamic-editors/./src/utils/columnSelectionUtils.ts","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/Select\"","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/format\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/ui-utils/i18n\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-context/DataSourceContext\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/dsl\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualization-encoding/utils/types\"","webpack://@splunk/dynamic-editors/external commonjs2 \"@splunk/visualizations-shared/dataSourceUtils\"","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 React, { useState, useCallback } from 'react';\nimport * as T from 'prop-types';\nimport Select from '@splunk/react-ui/Select';\nimport { getFieldsFromDSL } from '@splunk/visualization-encoding/utils/dsl';\nimport { getDataSourceStateInfo } from '@splunk/visualizations-shared/dataSourceUtils';\nimport { DataType } from '@splunk/visualization-encoding/DataPrimitive';\nimport { BaseEditorPropTypes } from '../interfaces/BaseEditorProps';\nimport type { BaseEditorProps } from '../interfaces/BaseEditorProps';\nimport { useDataSource } from '../hooks/useDataSource';\nimport { getAvailableFieldsWithTypes, getPlaceholderMessage } from '../utils/columnSelectionUtils';\nimport ControlGroup from '../shared/AdvancedControlGroup';\nimport { editorStyle } from '../shared/dimensionConstants';\nimport { useColumnSelectorFooterMessage } from './useColumnSelectorFooterMessage';\n\ninterface ColumnSelectionEditorProps extends BaseEditorProps {\n dataSourceKey: string;\n prepareValue?: (id: Record<string, any>) => Record<string, any>;\n filterByTypes?: DataType[];\n tooltip?: string;\n}\nconst propTypes: Record<keyof ColumnSelectionEditorProps, T.Validator<any>> = {\n ...BaseEditorPropTypes,\n dataSourceKey: T.string.isRequired,\n prepareValue: T.func,\n filterByTypes: T.arrayOf(T.string),\n tooltip: T.string,\n};\nexport const ColumnSelectionEditor: React.FunctionComponent<ColumnSelectionEditorProps> = ({\n name,\n value,\n label = '',\n labelPosition = 'top',\n dataSourceKey = 'primary',\n dataSourceBindings,\n prepareValue = (id: Record<string, unknown>): Record<string, unknown> => id,\n onChange,\n isAdvanced,\n isDisabled,\n filterByTypes,\n tooltip,\n}) => {\n const dataSource = useDataSource({ dataSourceBindings, dataSourceKey });\n const { columns, fields } = dataSource?.data || { columns: [], fields: [] };\n const availableFieldsWithTypes = getAvailableFieldsWithTypes(columns, fields);\n // return `value` if `value` is undefined or null so editor shows placeholder message\n const fieldName =\n value == null\n ? value\n : getFieldsFromDSL(value, {\n [dataSourceKey]: dataSource,\n })[0] || '';\n const [selectedField, setSelectedField] = useState(fieldName);\n React.useEffect((): void => {\n setSelectedField(fieldName);\n }, [fieldName]);\n const [filter, setFilter] = useState('');\n const filteredFields = availableFieldsWithTypes.filter(\n (field): boolean => field.name.indexOf(filter) !== -1\n );\n const footerMessage = useColumnSelectorFooterMessage({\n availableFields: availableFieldsWithTypes,\n selectedFields: [selectedField],\n filteredFields,\n filter,\n });\n\n const handleValueChange = useCallback(\n (event, { value: selectedValue }): void => {\n setSelectedField(selectedValue);\n const update = prepareValue({\n options: {\n [name]: `> ${dataSourceKey} | seriesByName('${selectedValue}')`,\n },\n });\n onChange(event, update);\n },\n [dataSourceKey, name, onChange, prepareValue]\n );\n\n const handleFilterChange = useCallback((e, { keyword }): void => {\n setFilter(keyword);\n }, []);\n const { hasError, isMissing, isLoading } = getDataSourceStateInfo(dataSource);\n const disabled = isMissing || hasError || isDisabled;\n const placeholderMessage = getPlaceholderMessage({ isMissing, isLoading, hasError });\n\n return (\n <ControlGroup label={label} labelPosition={labelPosition} tooltip={tooltip} isAdvanced={isAdvanced}>\n <Select\n data-test=\"ColumnSelectionEditor\"\n value={selectedField}\n onFilterChange={handleFilterChange}\n onChange={handleValueChange}\n footerMessage={footerMessage}\n disabled={disabled}\n placeholder={placeholderMessage}\n isLoadingOptions={isLoading}\n error={hasError}\n style={editorStyle}\n filter\n >\n {filteredFields.map(field => (\n <Select.Option\n key={field.name}\n label={`${field.name} (${field.type})`}\n value={field.name}\n disabled={!!filterByTypes?.length && !filterByTypes.find(f => f === field.type)}\n />\n ))}\n </Select>\n </ControlGroup>\n );\n};\nColumnSelectionEditor.propTypes = propTypes;\n\nexport default ColumnSelectionEditor;\n","import React, { useMemo } from 'react';\nimport { ColumnSelectorFooterMessage } from '../shared/ColumnSelectorFooterMessage';\nimport type { FieldTuple } from '../utils/columnSelectionUtils';\n\ntype ObjectWithName = {\n name: string;\n [key: string]: string;\n};\n\ntype Fields = FieldTuple[] | ObjectWithName[];\n\ninterface FooterMessageProps {\n noSelectedFieldsInfo?: boolean;\n filter: string;\n availableFields: Fields;\n selectedFields?: string[];\n filteredFields: Fields;\n}\n\nexport const useColumnSelectorFooterMessage = ({\n filter,\n availableFields,\n selectedFields,\n filteredFields,\n noSelectedFieldsInfo = false,\n}: FooterMessageProps) => {\n const selectedFilteredFields = useMemo(() => {\n if (!selectedFields || !filteredFields) return [];\n\n const validSelectedFields = new Set(\n selectedFields.filter(field => field !== '' && field !== undefined)\n );\n\n return filteredFields.filter(item => validSelectedFields.has(item.name));\n }, [selectedFields, filteredFields]);\n\n // make sure to display only 'No matches' text when there is no result of filtering\n if (filter && !filteredFields.length) {\n return null;\n }\n\n return (\n <ColumnSelectorFooterMessage\n noSelectedFieldsInfo={noSelectedFieldsInfo}\n numSelected={selectedFilteredFields?.length} // if no filter is applied filteredFields equal availableFields\n numFiltered={filteredFields.length}\n numAvailable={availableFields.length}\n filter={filter}\n />\n );\n};\n","import { useState, useEffect, useContext } from 'react';\nimport DataSourceContext, {\n type BindingsSnapshot,\n type DataSourceApi,\n} from '@splunk/visualization-context/DataSourceContext';\nimport { get, isFunction } from 'lodash';\n\ninterface UseDataSourceParams {\n dataSourceBindings: BindingsSnapshot;\n dataSourceKey: string;\n}\n// @TODO(pwied): use DataSource interface in return type (w/o dependency on @splunk/visualizations)\nexport const useDataSource = ({\n dataSourceBindings,\n dataSourceKey,\n}: UseDataSourceParams): BindingsSnapshot => {\n const dataSourceApi = useContext<DataSourceApi>(DataSourceContext);\n const [dataSource, setDataSource] = useState<BindingsSnapshot>();\n useEffect((): (() => void) => {\n if (!get(dataSourceBindings, dataSourceKey)) {\n setDataSource(null);\n return () => undefined;\n }\n const unsubscribe =\n isFunction(dataSourceApi.subscribe) &&\n dataSourceApi.subscribe(dataSourceKey, (snapshot): void => setDataSource(snapshot));\n return () => {\n if (unsubscribe) {\n unsubscribe();\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataSourceBindings]);\n return dataSource;\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","import * as React from 'react';\nimport { sprintf } from '@splunk/ui-utils/format';\nimport { _ } from '@splunk/ui-utils/i18n';\nimport { useMemo } from 'react';\n\ninterface FooterProps {\n filter: string;\n numSelected?: number;\n numFiltered: number;\n numAvailable: number;\n noSelectedFieldsInfo?: boolean; // it is needed for AddColumn component which has different logic than other selection editors\n}\n\nexport const ColumnSelectorFooterMessage = ({\n numSelected,\n numFiltered,\n numAvailable,\n filter,\n noSelectedFieldsInfo,\n}: FooterProps) => {\n const footerMessageText = useMemo(() => {\n if (filter) {\n if (noSelectedFieldsInfo) {\n return sprintf(_('%(filtered)d filtered from %(available)d fields'), {\n filtered: numFiltered,\n available: numAvailable,\n });\n }\n return sprintf(_('%(selected)d selected from %(filtered)d filtered'), {\n selected: numSelected,\n filtered: numFiltered,\n });\n }\n return noSelectedFieldsInfo\n ? sprintf(_('%(shown)d of %(available)d fields'), {\n shown: numFiltered,\n available: numAvailable,\n })\n : sprintf(_('%(selected)d selected from %(available)d'), {\n selected: numSelected,\n available: numAvailable,\n });\n }, [filter, noSelectedFieldsInfo, numFiltered, numAvailable, numSelected]);\n\n return (\n <span data-test=\"footer-message\" aria-live=\"polite\" aria-atomic=\"true\">\n {footerMessageText}\n </span>\n );\n};\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","import { _ } from '@splunk/ui-utils/i18n';\nimport {\n inferDataTypeFromData,\n canInferTypeFromMeta,\n getDataTypeForMeta,\n} from '@splunk/visualization-encoding/utils/types';\n\nexport interface FieldTuple {\n name: string;\n type: string;\n}\n\nexport const getAvailableFieldsWithTypes = (\n columns: unknown[][],\n fields: { name: string; type?: string }[]\n): FieldTuple[] => {\n const fieldsWithType = fields.map((field, index) => {\n const { name } = field;\n const inferredType = canInferTypeFromMeta(field)\n ? getDataTypeForMeta(field)\n : inferDataTypeFromData(columns[index]);\n return {\n name,\n type: inferredType,\n };\n });\n return fieldsWithType;\n};\n\nexport const getFilteredFields = (availableFieldsWithTypes: FieldTuple[], filter: string): FieldTuple[] => {\n return availableFieldsWithTypes.filter((field): boolean => field.name.indexOf(filter) !== -1);\n};\n\nexport const sanitizeFieldNames = (value: unknown, fieldNames: string[]): string[] => {\n if (typeof value === 'string' && fieldNames.includes(value)) {\n return [value];\n }\n if (Array.isArray(value)) {\n return value.filter(name => fieldNames.includes(name));\n }\n return [];\n};\n\nexport const getPlaceholderMessage = ({\n hasError,\n isLoading,\n isMissing,\n defaultMessage = 'Select a field from data source',\n}: {\n hasError: boolean;\n isLoading: boolean;\n isMissing: boolean;\n defaultMessage?: string;\n}): string => {\n if (isMissing) {\n return _('Set up data source to select');\n }\n if (hasError) {\n return _('Please set up valid data source to select');\n }\n if (isLoading) {\n return _('Loading data source...');\n }\n return _(defaultMessage);\n};\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/Select\");","module.exports = require(\"@splunk/react-ui/Tooltip\");","module.exports = require(\"@splunk/themes\");","module.exports = require(\"@splunk/ui-utils/format\");","module.exports = require(\"@splunk/ui-utils/i18n\");","module.exports = require(\"@splunk/visualization-context/DataSourceContext\");","module.exports = require(\"@splunk/visualization-encoding/utils/dsl\");","module.exports = require(\"@splunk/visualization-encoding/utils/types\");","module.exports = require(\"@splunk/visualizations-shared/dataSourceUtils\");","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__(5731);\n"],"names":["propTypes","BaseEditorPropTypes","dataSourceKey","T","string","isRequired","prepareValue","func","filterByTypes","arrayOf","tooltip","ColumnSelectionEditor","name","value","label","labelPosition","dataSourceBindings","id","onChange","isAdvanced","isDisabled","dataSource","useDataSource","columns","fields","data","availableFieldsWithTypes","getAvailableFieldsWithTypes","fieldName","getFieldsFromDSL","selectedField","setSelectedField","useState","useEffect","filter","setFilter","filteredFields","field","indexOf","footerMessage","useColumnSelectorFooterMessage","availableFields","selectedFields","handleValueChange","useCallback","event","selectedValue","update","options","handleFilterChange","e","keyword","hasError","isMissing","isLoading","getDataSourceStateInfo","disabled","placeholderMessage","getPlaceholderMessage","onFilterChange","placeholder","isLoadingOptions","error","style","editorStyle","map","Option","key","type","length","find","f","noSelectedFieldsInfo","selectedFilteredFields","useMemo","validSelectedFields","Set","undefined","item","has","ColumnSelectorFooterMessage","numSelected","numFiltered","numAvailable","dataSourceApi","useContext","setDataSource","get","unsubscribe","isFunction","subscribe","snapshot","oneOfType","object","context","oneOf","labelWidth","number","bool","optionsSchema","ControlGroupContainer","variables","spacingMedium","StyledToolTip","StyledAdvancedConfigButton","contentColorActive","interactiveColorOverlayDrag","AdvancedConfigButton","onClick","content","_","icon","appearance","AdvancedControlGroup","dataTest","children","hideLabel","help","controlsLayout","onAdvancedConfigButtonClick","Children","toArray","Boolean","child","cloneElement","flex","footerMessageText","sprintf","filtered","available","selected","shown","FLYOUT_PADDING","COLUMN_FLYOUT_PADDING","FLYOUT_WIDTH","VERTICAL_EDITOR_SPACING","DROPDOWN_MENU_WIDTH","width","index","canInferTypeFromMeta","getDataTypeForMeta","inferDataTypeFromData","getFilteredFields","sanitizeFieldNames","fieldNames","includes","Array","isArray","defaultMessage","module","exports","require","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","call"],"sourceRoot":""}
|