// Copyright (c) 2022 Uber Technologies, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. import React, {Component} from 'react'; import {FormattedMessage, injectIntl, WrappedComponentProps} from 'react-intl'; import {PanelLabel, PanelLabelWrapper, SidePanelSection} from 'components/common/styled-components'; import InfoHelperFactory from 'components/common/info-helper'; import DimensionScaleSelector from './dimension-scale-selector'; import {camelize} from 'utils/utils'; import FieldSelectorFactory from '../../common/field-selector'; import {Field} from 'utils/table-utils/kepler-table'; import ColorDimensionScaleSelectorFactory from './color-dimension-scale-selector'; type VisConfigByFieldSelectorProps = { channel: string; fields: Field[]; id: string; property: string; showScale: boolean; showScaleCustomizable: boolean; updateField: ( val: readonly (string | number | boolean | object)[] | string | number | boolean | object | null ) => void; updateScale: ( val: readonly (string | number | boolean | object)[] | string | number | boolean | object | null ) => void; updateCustomPalette: Function; scaleType?: string; selectedField?: Field; description?: string; label?: string; placeholder?: string; scaleOptions: string[]; isLoading?: boolean; fieldsAggregated?: boolean; aggregator?: string; } & WrappedComponentProps; VisConfigByFieldSelectorFactory.deps = [ InfoHelperFactory, FieldSelectorFactory, ColorDimensionScaleSelectorFactory ]; function VisConfigByFieldSelectorFactory( InfoHelper: ReturnType, FieldSelector: ReturnType, ColorDimensionScaleSelector: ReturnType ) { class VisConfigByFieldSelector extends Component { _updateVisByField = ( val: | readonly (string | number | boolean | object)[] | string | number | boolean | object | null ) => { this.props.updateField(val); }; _onFieldSelectorFocused = () => { this.setState({fieldSelectorActive: true}); }; _onFieldSelectorBlur = () => { this.setState({fieldSelectorActive: false}); }; render() { const { property, showScale, showScaleCustomizable, selectedField, description, label, intl, scaleOptions = [], // @ts-expect-error domain, // @ts-expect-error range } = this.props; return ( {/* @ts-expect-error */} {(label && ) || ( )} {description && ( )} {showScale && !this.props.isLoading ? (
) : null} {showScaleCustomizable && !this.props.isLoading && (
} // @ts-expect-error scaleType={this.props.scaleType} // @ts-expect-error options={scaleOptions} domain={domain} range={range} // @ts-expect-error onSelect={this.props.updateScale} // @ts-expect-error onSetCustomPalette={this.props.updateCustomPalette} />
)}
); } } return injectIntl(VisConfigByFieldSelector); } export default VisConfigByFieldSelectorFactory;