补充className
This commit is contained in:
parent
7cf3c8ed08
commit
19795b9b11
|
@ -153,7 +153,7 @@ export class AssociatedCheckboxes extends BaseCheckboxes<
|
||||||
: this.handleRetry.bind(this, selectdOption)
|
: this.handleRetry.bind(this, selectdOption)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Icon icon="reload" />
|
<Icon icon="reload" className="icon" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{selectdOption.loading ? (
|
{selectdOption.loading ? (
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import {ClassNamesFn, themeable} from '../theme';
|
import {ClassNamesFn, themeable} from '../theme';
|
||||||
import {Icon} from '..';
|
import {Icon} from '..';
|
||||||
import {loadScript, autobind, uuid} from '../utils/helper';
|
import {loadScript, autobind, uuid} from '../utils/helper';
|
||||||
import { threadId } from 'worker_threads';
|
import {threadId} from 'worker_threads';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
|
|
||||||
declare const BMap: any;
|
declare const BMap: any;
|
||||||
|
@ -43,7 +43,7 @@ export class BaiduMapPicker extends React.Component<
|
||||||
inputValue: '',
|
inputValue: '',
|
||||||
locs: [],
|
locs: [],
|
||||||
locIndex: -1,
|
locIndex: -1,
|
||||||
sugs: [],
|
sugs: []
|
||||||
};
|
};
|
||||||
|
|
||||||
id = uuid();
|
id = uuid();
|
||||||
|
@ -51,27 +51,29 @@ export class BaiduMapPicker extends React.Component<
|
||||||
placeholderInput: HTMLInputElement;
|
placeholderInput: HTMLInputElement;
|
||||||
map: any;
|
map: any;
|
||||||
ac: any;
|
ac: any;
|
||||||
search = debounce(() => {
|
search = debounce(
|
||||||
if (this.state.inputValue) {
|
() => {
|
||||||
this.ac?.search(this.state.inputValue);
|
if (this.state.inputValue) {
|
||||||
} else {
|
this.ac?.search(this.state.inputValue);
|
||||||
this.setState({
|
} else {
|
||||||
sugs: []
|
this.setState({
|
||||||
})
|
sugs: []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
250,
|
||||||
|
{
|
||||||
|
trailing: true,
|
||||||
|
leading: false
|
||||||
}
|
}
|
||||||
}, 250, {
|
);
|
||||||
trailing: true,
|
|
||||||
leading: false
|
|
||||||
});
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
if ((window as any).BMap) {
|
if ((window as any).BMap) {
|
||||||
this.initMap();
|
this.initMap();
|
||||||
} else {
|
} else {
|
||||||
loadScript(
|
loadScript(
|
||||||
`http://api.map.baidu.com/api?v=2.0&ak=${
|
`http://api.map.baidu.com/api?v=2.0&ak=${this.props.ak}&callback={{callback}}`
|
||||||
this.props.ak
|
|
||||||
}&callback={{callback}}`
|
|
||||||
).then(this.initMap);
|
).then(this.initMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +93,9 @@ export class BaiduMapPicker extends React.Component<
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
|
||||||
const value = this.props.value;
|
const value = this.props.value;
|
||||||
let point = value ? new BMap.Point(value.lng, value.lat) : new BMap.Point(116.404, 39.915);
|
let point = value
|
||||||
|
? new BMap.Point(value.lng, value.lat)
|
||||||
|
: new BMap.Point(116.404, 39.915);
|
||||||
map.centerAndZoom(point, 15);
|
map.centerAndZoom(point, 15);
|
||||||
|
|
||||||
const geolocationControl = new BMap.GeolocationControl();
|
const geolocationControl = new BMap.GeolocationControl();
|
||||||
|
@ -112,16 +116,26 @@ export class BaiduMapPicker extends React.Component<
|
||||||
this.ac = new BMap.Autocomplete({
|
this.ac = new BMap.Autocomplete({
|
||||||
input,
|
input,
|
||||||
location: map,
|
location: map,
|
||||||
onSearchComplete: (e:any) => {
|
onSearchComplete: (e: any) => {
|
||||||
// 说明已经销毁了。
|
// 说明已经销毁了。
|
||||||
if (!this.map) {
|
if (!this.map) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sugs:Array<string> = [];
|
const sugs: Array<string> = [];
|
||||||
if (Array.isArray(e.Ir)) {
|
if (Array.isArray(e.Ir)) {
|
||||||
e.Ir.forEach((item:any) => {
|
e.Ir.forEach((item: any) => {
|
||||||
sugs.push([item.province, item.city, item.district, item.street, item.business].filter(item => item).join(' '))
|
sugs.push(
|
||||||
|
[
|
||||||
|
item.province,
|
||||||
|
item.city,
|
||||||
|
item.district,
|
||||||
|
item.street,
|
||||||
|
item.business
|
||||||
|
]
|
||||||
|
.filter(item => item)
|
||||||
|
.join(' ')
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -172,53 +186,62 @@ export class BaiduMapPicker extends React.Component<
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState(
|
||||||
locIndex: index,
|
{
|
||||||
locs
|
locIndex: index,
|
||||||
}, () => {
|
locs
|
||||||
if (!select) {
|
},
|
||||||
return;
|
() => {
|
||||||
}
|
if (!select) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.props?.onChange({
|
this.props?.onChange({
|
||||||
address: locs[0].address,
|
address: locs[0].address,
|
||||||
lat: locs[0].lat,
|
lat: locs[0].lat,
|
||||||
lng: locs[0].lng,
|
lng: locs[0].lng,
|
||||||
city: locs[0].city
|
city: locs[0].city
|
||||||
})
|
});
|
||||||
});
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||||
this.setState({
|
this.setState(
|
||||||
inputValue: e.currentTarget.value
|
{
|
||||||
}, this.search);
|
inputValue: e.currentTarget.value
|
||||||
|
},
|
||||||
|
this.search
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
handleSelect(e: React.MouseEvent<HTMLElement>) {
|
handleSelect(e: React.MouseEvent<HTMLElement>) {
|
||||||
const index= parseInt(e.currentTarget.getAttribute('data-index')!, 10);
|
const index = parseInt(e.currentTarget.getAttribute('data-index')!, 10);
|
||||||
const loc = this.state.locs[index];
|
const loc = this.state.locs[index];
|
||||||
|
|
||||||
this.setState({
|
this.setState(
|
||||||
locIndex: index
|
{
|
||||||
}, () => {
|
locIndex: index
|
||||||
const point = new BMap.Point(loc.lng, loc.lat);
|
},
|
||||||
|
() => {
|
||||||
this.map.clearOverlays();
|
const point = new BMap.Point(loc.lng, loc.lat);
|
||||||
const mk = new BMap.Marker(point);
|
|
||||||
this.map.addOverlay(mk);
|
|
||||||
this.map.panTo(point);
|
|
||||||
|
|
||||||
this.props?.onChange({
|
this.map.clearOverlays();
|
||||||
address: loc.address.trim() || loc.title,
|
const mk = new BMap.Marker(point);
|
||||||
lat: loc.lat,
|
this.map.addOverlay(mk);
|
||||||
lng: loc.lng,
|
this.map.panTo(point);
|
||||||
city: loc.city
|
|
||||||
})
|
this.props?.onChange({
|
||||||
})
|
address: loc.address.trim() || loc.title,
|
||||||
|
lat: loc.lat,
|
||||||
|
lng: loc.lng,
|
||||||
|
city: loc.city
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
|
@ -228,18 +251,19 @@ export class BaiduMapPicker extends React.Component<
|
||||||
inputValue: value
|
inputValue: value
|
||||||
});
|
});
|
||||||
|
|
||||||
var local = new BMap.LocalSearch(this.map, { //智能搜索
|
var local = new BMap.LocalSearch(this.map, {
|
||||||
onSearchComplete: () => {
|
//智能搜索
|
||||||
|
onSearchComplete: () => {
|
||||||
const results = local.getResults();
|
const results = local.getResults();
|
||||||
const poi = results.getPoi(0);
|
const poi = results.getPoi(0);
|
||||||
this.setState({
|
this.setState({
|
||||||
inputValue: poi.title,
|
inputValue: poi.title,
|
||||||
sugs: []
|
sugs: []
|
||||||
});
|
});
|
||||||
this.getLocations(poi.point, true)
|
this.getLocations(poi.point, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
local.search(value);
|
local.search(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -251,34 +275,56 @@ export class BaiduMapPicker extends React.Component<
|
||||||
<div className={cx('MapPicker')}>
|
<div className={cx('MapPicker')}>
|
||||||
<div className={cx('MapPicker-search TextControl-control')}>
|
<div className={cx('MapPicker-search TextControl-control')}>
|
||||||
<div className={cx('TextControl-input')}>
|
<div className={cx('TextControl-input')}>
|
||||||
<input onChange={this.handleChange} value={inputValue} placeholder="搜索地点" />
|
<input
|
||||||
|
onChange={this.handleChange}
|
||||||
|
value={inputValue}
|
||||||
|
placeholder="搜索地点"
|
||||||
|
/>
|
||||||
<span>
|
<span>
|
||||||
<Icon icon="search" />
|
<Icon icon="search" className="icon" />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ref={this.mapRef} className={cx('MapPicker-map', {
|
<div
|
||||||
invisible: hasSug
|
ref={this.mapRef}
|
||||||
})} />
|
className={cx('MapPicker-map', {
|
||||||
|
invisible: hasSug
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
|
||||||
<div className={cx('MapPicker-result', {
|
<div
|
||||||
invisible: hasSug
|
className={cx('MapPicker-result', {
|
||||||
})}>
|
invisible: hasSug
|
||||||
|
})}
|
||||||
|
>
|
||||||
{locs.map((item, index) => (
|
{locs.map((item, index) => (
|
||||||
<div onClick={this.handleSelect} key={index} data-index={index} className={cx('MapPicker-item')}>
|
<div
|
||||||
|
onClick={this.handleSelect}
|
||||||
|
key={index}
|
||||||
|
data-index={index}
|
||||||
|
className={cx('MapPicker-item')}
|
||||||
|
>
|
||||||
<div className={cx('MapPicker-itemTitle')}>{item.title}</div>
|
<div className={cx('MapPicker-itemTitle')}>{item.title}</div>
|
||||||
<div className={cx('MapPicker-itemDesc')}>{item.address}</div>
|
<div className={cx('MapPicker-itemDesc')}>{item.address}</div>
|
||||||
{locIndex === index ? <Icon icon="success" /> : null}
|
{locIndex === index ? (
|
||||||
|
<Icon icon="success" className="icon" />
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{hasSug ? (
|
{hasSug ? (
|
||||||
<div className={cx('MapPicker-sug')}>
|
<div className={cx('MapPicker-sug')}>
|
||||||
{sugs.map(item =>
|
{sugs.map(item => (
|
||||||
<div onClick={this.handleSugSelect} className={cx('MapPicker-sugItem')} key={item}>{item}</div>
|
<div
|
||||||
)}
|
onClick={this.handleSugSelect}
|
||||||
|
className={cx('MapPicker-sugItem')}
|
||||||
|
key={item}
|
||||||
|
>
|
||||||
|
{item}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -108,7 +108,7 @@ export class ImageGallery extends React.Component<
|
||||||
className={cx('ImageGallery-close')}
|
className={cx('ImageGallery-close')}
|
||||||
onClick={this.close}
|
onClick={this.close}
|
||||||
>
|
>
|
||||||
<Icon icon="close" />
|
<Icon icon="close" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
{~index && items[index] ? (
|
{~index && items[index] ? (
|
||||||
<>
|
<>
|
||||||
|
@ -127,7 +127,7 @@ export class ImageGallery extends React.Component<
|
||||||
)}
|
)}
|
||||||
onClick={this.prev}
|
onClick={this.prev}
|
||||||
>
|
>
|
||||||
<Icon icon="prev" />
|
<Icon icon="prev" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
className={cx(
|
className={cx(
|
||||||
|
@ -136,7 +136,7 @@ export class ImageGallery extends React.Component<
|
||||||
)}
|
)}
|
||||||
onClick={this.next}
|
onClick={this.next}
|
||||||
>
|
>
|
||||||
<Icon icon="next" />
|
<Icon icon="next" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -146,7 +146,7 @@ export class ImageGallery extends React.Component<
|
||||||
{items.length > 1 ? (
|
{items.length > 1 ? (
|
||||||
<div className={cx('ImageGallery-footer')}>
|
<div className={cx('ImageGallery-footer')}>
|
||||||
<a className={cx('ImageGallery-prevList is-disabled')}>
|
<a className={cx('ImageGallery-prevList is-disabled')}>
|
||||||
<Icon icon="prev" />
|
<Icon icon="prev" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
<div className={cx('ImageGallery-itemsWrap')}>
|
<div className={cx('ImageGallery-itemsWrap')}>
|
||||||
<div className={cx('ImageGallery-items')}>
|
<div className={cx('ImageGallery-items')}>
|
||||||
|
@ -166,7 +166,7 @@ export class ImageGallery extends React.Component<
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a className={cx('ImageGallery-nextList is-disabled')}>
|
<a className={cx('ImageGallery-nextList is-disabled')}>
|
||||||
<Icon icon="next" />
|
<Icon icon="next" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
|
@ -172,7 +172,7 @@ export class LocationPicker extends React.Component<
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<a className={cx('LocationPicker-toggler')}>
|
<a className={cx('LocationPicker-toggler')}>
|
||||||
<Icon icon="location" />
|
<Icon icon="location" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<Overlay
|
<Overlay
|
||||||
|
|
|
@ -122,7 +122,7 @@ export class ResultBox extends React.Component<ResultBoxProps> {
|
||||||
{itemRender(item)}
|
{itemRender(item)}
|
||||||
</span>
|
</span>
|
||||||
<a data-index={index} onClick={this.removeItem}>
|
<a data-index={index} onClick={this.removeItem}>
|
||||||
<Icon icon="close" />
|
<Icon icon="close" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
|
|
|
@ -144,7 +144,10 @@ export class ResultList extends React.Component<ResultListProps> {
|
||||||
key={index}
|
key={index}
|
||||||
>
|
>
|
||||||
{sortable && !disabled && value.length > 1 ? (
|
{sortable && !disabled && value.length > 1 ? (
|
||||||
<Icon className={cx('Selections-dragbar')} icon="drag-bar" />
|
<Icon
|
||||||
|
className={cx('Selections-dragbar icon')}
|
||||||
|
icon="drag-bar"
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<label>{itemRender(option)}</label>
|
<label>{itemRender(option)}</label>
|
||||||
|
@ -155,7 +158,7 @@ export class ResultList extends React.Component<ResultListProps> {
|
||||||
data-index={index}
|
data-index={index}
|
||||||
onClick={this.handleRemove}
|
onClick={this.handleRemove}
|
||||||
>
|
>
|
||||||
<Icon icon="close" />
|
<Icon icon="close" className="icon" />
|
||||||
</a>
|
</a>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -418,7 +418,7 @@ export class Transfer extends React.Component<TransferProps, TransferState> {
|
||||||
<div className={cx('Transfer-mid')}>
|
<div className={cx('Transfer-mid')}>
|
||||||
{showArrow /*todo 需要改成确认模式,即:点了按钮才到右边 */ ? (
|
{showArrow /*todo 需要改成确认模式,即:点了按钮才到右边 */ ? (
|
||||||
<div className={cx('Transfer-arrow')}>
|
<div className={cx('Transfer-arrow')}>
|
||||||
<Icon icon="right-arrow" />
|
<Icon icon="right-arrow" className="icon" />
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1054,7 +1054,7 @@ export default class ComboControl extends React.Component<ComboProps> {
|
||||||
{dragIcon ? (
|
{dragIcon ? (
|
||||||
<i className={dragIcon} />
|
<i className={dragIcon} />
|
||||||
) : (
|
) : (
|
||||||
<Icon icon="drag-bar" />
|
<Icon icon="drag-bar" className="icon" />
|
||||||
)}
|
)}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -894,7 +894,7 @@ export class ListItem extends React.Component<ListItemProps> {
|
||||||
if (dragging) {
|
if (dragging) {
|
||||||
return (
|
return (
|
||||||
<div className={cx('ListItem-dragBtn')}>
|
<div className={cx('ListItem-dragBtn')}>
|
||||||
<Icon icon="drag-bar" />
|
<Icon icon="drag-bar" className="icon" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (selectable && !hideCheckToggler) {
|
} else if (selectable && !hideCheckToggler) {
|
||||||
|
|
|
@ -69,7 +69,10 @@ export class StatusField extends React.Component<StatusProps, object> {
|
||||||
|
|
||||||
if (svgIcon) {
|
if (svgIcon) {
|
||||||
viewValue = (
|
viewValue = (
|
||||||
<Icon icon={svgIcon} className={cx('Status-icon', itemClassName)} />
|
<Icon
|
||||||
|
icon={svgIcon}
|
||||||
|
className={cx('Status-icon icon', itemClassName)}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
} else if (itemClassName) {
|
} else if (itemClassName) {
|
||||||
viewValue = (
|
viewValue = (
|
||||||
|
|
Loading…
Reference in New Issue