Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cdd43e0
refactor(weB): import util methods from reactive lib
mohdashraf010897 Apr 7, 2022
8ca6b10
sync reactivecore post refacotring util methods
mohdashraf010897 Apr 7, 2022
16b07de
feat: accept render prop instead of renderAllData for ReactiveGoogleM…
mohdashraf010897 Apr 7, 2022
829ee3f
fix: rename renderData prop to renderItem
mohdashraf010897 Apr 7, 2022
6626e23
reafctor(web): import util from reactivecore and update lib version
mohdashraf010897 Apr 7, 2022
43e6a70
feat(maps): add onData callback event to GeoDistance-Dropdown/Slider
mohdashraf010897 Apr 7, 2022
c389665
feat: add render and renderITem props
mohdashraf010897 Apr 8, 2022
1410eeb
fix: render and renderItem prop usage for GeoDistanceDropdown
mohdashraf010897 Apr 8, 2022
ef1556e
Merge branch 'feat/upgrade-maps-lib' into feat-maps/render-api-changes
mohdashraf010897 Apr 8, 2022
98a9597
Merge branch 'feat/upgrade-maps-lib' into feat-maps/render-api-changes
mohdashraf010897 Apr 8, 2022
52d3ce0
fix: GeoDistanceDropdown renderItem method to handle null condition
mohdashraf010897 Apr 8, 2022
7547ba3
fix(maps): GeoDistanceDropdown renderItem null handling
mohdashraf010897 Apr 8, 2022
f3384cb
Merge branch 'feat/upgrade-maps-lib' into feat-maps/render-api-changes
mohdashraf010897 Apr 10, 2022
8bc556f
fix(maps): api for GeoDistanceDropdown renderItem prop
mohdashraf010897 Apr 10, 2022
989e6e0
Merge branch 'feat/upgrade-maps-lib' into feat-maps/render-api-changes
mohdashraf010897 Apr 12, 2022
7f45123
Merge branch 'feat/upgrade-maps-lib' into feat-maps/render-api-changes
mohdashraf010897 Apr 12, 2022
416e76e
v3.29.2-preview.1
mohdashraf010897 Apr 13, 2022
2b77185
v3.1.0-preview.1
mohdashraf010897 Apr 13, 2022
7c6350f
v3.1.0-preview.2
mohdashraf010897 Apr 14, 2022
968e93a
v3.1.0-preview.3
mohdashraf010897 Apr 14, 2022
4a4070e
v3.29.2-preview.2
mohdashraf010897 Apr 14, 2022
826feda
v3.29.2-preview.3
mohdashraf010897 Apr 14, 2022
820ac79
fix(web): bad imports from wrong path
mohdashraf010897 Apr 14, 2022
99662ae
fix: versioining
mohdashraf010897 Apr 14, 2022
d850aa3
Merge branch 'feat/upgrade-maps-lib' into feat-maps/render-api-changes
mohdashraf010897 Apr 14, 2022
ce8b572
fix(maps): revert package.json changes
mohdashraf010897 Apr 15, 2022
9f25eac
sync and update with next branch
mohdashraf010897 Apr 19, 2022
c084cfa
fix(maps): ReactiveMap example package.json conflict resolution
mohdashraf010897 Apr 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/maps/examples/ReactiveMap/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.4/leaflet.css"
rel="stylesheet"
/>
<script
type="text/javascript"
src="https://maps.google.com/maps/api/js?libraries=places"
></script>
</head>
<body>
<div id="root"></div>
Expand Down
2 changes: 1 addition & 1 deletion packages/maps/examples/ReactiveMap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
"build": "webpack -p --progress",
"start": "webpack-dev-server --hot --inline --progress --colors --port 8001"
}
}
}
3 changes: 2 additions & 1 deletion packages/maps/examples/ReactiveMap/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class App extends React.Component {
},
onPopoverClick: item => <div>{item.place}</div>,
showMapStyles: true,
renderData: result => ({
renderItem: result => ({
custom: (
<div
style={{
Expand All @@ -66,6 +66,7 @@ class App extends React.Component {
app="earthquakes"
url="https://a03a1cb71321:75b6603d-9456-4a5a-af6b-a487b309eb61@appbase-demo-ansible-abxiydt-arc.searchbase.io"
enableAppbase
mapKey="AIzaSyA9JzjtHeXg_C_hh_GdTBdLxREWdj3nsOU"
>
<div>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class App extends React.Component {
</div>
),
showMapStyles: true,
renderData: () => ({
renderItem: () => ({
custom: (
<div
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class App extends React.Component {
</div>
),
showMapStyles: true,
renderData: () => ({
renderItem: () => ({
custom: (
<div
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class App extends React.Component {
</div>
),
showMapStyles: true,
renderData: () => ({
renderItem: () => ({
custom: (
<div
style={{
Expand Down
52 changes: 52 additions & 0 deletions packages/maps/src/components/basic/GeoDistanceDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
getOptionsFromQuery,
updateCustomQuery,
updateDefaultQuery,
getComponent,
hasCustomRenderer,
} from '@appbaseio/reactivecore/lib/utils/helper';
import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
import types from '@appbaseio/reactivecore/lib/utils/types';
Expand Down Expand Up @@ -116,6 +118,14 @@ class GeoDistanceDropdown extends GeoCode {
}

componentDidUpdate(prevProps) {
if (this.props.onData) {
checkSomePropChange(this.props, prevProps, ['error', 'selectedValue'], () => {
this.props.onData({
value: this.props.selectedValue,
error: this.props.error,
});
});
}
checkSomePropChange(this.props, prevProps, getValidPropsKeys(this.props), () => {
this.props.updateComponentProps(
this.props.componentId,
Expand Down Expand Up @@ -498,6 +508,24 @@ class GeoDistanceDropdown extends GeoCode {
);
};

getComponent = (items, downshiftProps) => {
const {
error, isLoading, selectedValue, rawData,
} = this.props;
const data = {
error,
loading: isLoading,
value: selectedValue,
data: items || [],
rawData,
handleChange: this.onDistanceChange,
downshiftProps,
};
return getComponent(data, this.props);
};
get hasCustomRenderer() {
return hasCustomRenderer(this.props);
}
render() {
return (
<Container style={this.props.style} className={this.props.className}>
Expand All @@ -510,12 +538,26 @@ class GeoDistanceDropdown extends GeoCode {
<Dropdown
innerClass={this.props.innerClass}
items={this.props.data}
renderItem={
typeof this.props.renderItem === 'function'
? value =>
this.props.renderItem(
value,
this.getSelectedLabel(this.state.currentDistance)
? this.getSelectedLabel(this.state.currentDistance)
.label === value
: false,
)
: undefined
}
onChange={this.onDistanceChange}
selectedItem={this.getSelectedLabel(this.state.currentDistance)}
placeholder="Select distance"
keyField="label"
returnsObject
themePreset={this.props.themePreset}
hasCustomRenderer={this.hasCustomRenderer}
customRenderer={this.getComponent}
/>
</Container>
);
Expand Down Expand Up @@ -570,6 +612,12 @@ GeoDistanceDropdown.propTypes = {
unit: types.string,
URLParams: types.bool,
serviceOptions: types.props,
error: types.title,
onData: types.func,
render: types.func,
renderItem: types.func,
isLoading: types.bool,
rawData: types.rawData,
geocoder: types.any, // eslint-disable-line
};

Expand All @@ -582,6 +630,7 @@ GeoDistanceDropdown.defaultProps = {
countries: [],
autoLocation: true,
unit: 'mi',
isLoading: false,
};

const mapStateToProps = (state, props) => ({
Expand All @@ -591,6 +640,9 @@ const mapStateToProps = (state, props) => ({
&& state.selectedValues[props.componentId].value)
|| null,
themePreset: state.config.themePreset,
error: state.error[props.componentId],
isLoading: state.isLoading[props.componentId],
rawData: state.rawData[props.componentId],
});

const mapDispatchtoProps = dispatch => ({
Expand Down
11 changes: 11 additions & 0 deletions packages/maps/src/components/basic/GeoDistanceSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ class GeoDistanceSlider extends GeoCode {
}

componentDidUpdate(prevProps) {
if (this.props.onData) {
checkSomePropChange(this.props, prevProps, ['error', 'selectedValue'], () => {
this.props.onData({
value: this.props.selectedValue,
error: this.props.error,
});
});
}
checkSomePropChange(this.props, prevProps, getValidPropsKeys(this.props), () => {
this.props.updateComponentProps(
this.props.componentId,
Expand Down Expand Up @@ -583,6 +591,8 @@ GeoDistanceSlider.propTypes = {
unit: types.string,
URLParams: types.bool,
serviceOptions: types.props,
error: types.title,
onData: types.func,
geocoder: types.any, // eslint-disable-line
};

Expand All @@ -609,6 +619,7 @@ const mapStateToProps = (state, props) => ({
&& state.selectedValues[props.componentId].value)
|| null,
themePreset: state.config.themePreset,
error: state.error[props.componentId],
});

const mapDispatchtoProps = dispatch => ({
Expand Down
8 changes: 4 additions & 4 deletions packages/maps/src/components/result/GoogleMapMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class GoogleMapMarker extends React.Component {
render() {
const {
getPosition,
renderData,
renderItem,
defaultPin,
autoClosePopover,
handlePreserveCenter,
Expand All @@ -129,8 +129,8 @@ class GoogleMapMarker extends React.Component {
if (markerOnTop === marker._id) {
markerProps.zIndex = window.google.maps.Marker.MAX_ZINDEX + 1;
}
if (renderData) {
const data = renderData(marker);
if (renderItem) {
const data = renderItem(marker);

if ('label' in data) {
return (
Expand Down Expand Up @@ -207,7 +207,7 @@ const mapStateToProps = state => ({

GoogleMapMarker.propTypes = {
getPosition: types.func,
renderData: types.func,
renderItem: types.func,
defaultPin: types.string,
autoClosePopover: types.bool,
handlePreserveCenter: types.func,
Expand Down
2 changes: 1 addition & 1 deletion packages/maps/src/components/result/GoogleMapMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GoogleMapMarkers extends React.Component {
GoogleMapMarkers.propTypes = {
resultsToRender: types.hits,
getPosition: types.func,
renderData: types.func,
renderItem: types.func,
defaultPin: types.string,
autoClosePopover: types.bool,
handlePreserveCenter: types.func,
Expand Down
6 changes: 3 additions & 3 deletions packages/maps/src/components/result/ReactiveGoogleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ReactiveGoogleMap extends Component {
const markerProps = {
resultsToRender: params.resultsToRender,
getPosition: params.getPosition,
renderData: params.renderData,
renderItem: params.renderItem,
defaultPin: params.defaultPin,
autoClosePopover: params.autoClosePopover,
handlePreserveCenter: params.handlePreserveCenter,
Expand Down Expand Up @@ -198,8 +198,8 @@ ReactiveGoogleMap.propTypes = {
mapOptions: types.props,
markerProps: types.props,
markers: types.children,
renderAllData: types.func,
renderData: types.func,
render: types.func,
renderItem: types.func,
onPageChange: types.func,
onPopoverClick: types.func,
onData: types.func,
Expand Down
46 changes: 27 additions & 19 deletions packages/maps/src/components/result/ReactiveMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ import {
getClassName,
getResultStats,
checkSomePropChange,
getComponent,
hasCustomRenderer,
isFunction,
} from '@appbaseio/reactivecore/lib/utils/helper';
import types from '@appbaseio/reactivecore/lib/utils/types';
import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
import {
connect,
isFunction,
ReactReduxContext,
getValidPropsKeys,
} from '@appbaseio/reactivesearch/lib/utils';
import { connect, ReactReduxContext, getValidPropsKeys } from '@appbaseio/reactivesearch/lib/utils';
import Pagination from '@appbaseio/reactivesearch/lib/components/result/addons/Pagination';
import { Checkbox } from '@appbaseio/reactivesearch/lib/styles/FormControlList';
import geohash from 'ngeohash';
Expand Down Expand Up @@ -929,7 +927,7 @@ class ReactiveMap extends Component {
const resultsToRender = this.getResultsToRender();
const {
showMarkers,
renderData,
renderItem,
defaultPin,
onPopoverClick,
autoClosePopover,
Expand All @@ -942,7 +940,7 @@ class ReactiveMap extends Component {
getPosition: this.getPosition,
zoom: this.state.zoom,
showMarkers,
renderData,
renderItem,
defaultPin,
onPopoverClick,
autoClosePopover,
Expand All @@ -958,6 +956,23 @@ class ReactiveMap extends Component {
};
}

getComponent = () => {
const { error, isLoading } = this.props;
const data = {
error,
loading: isLoading,
loadMore: this.loadMore,
...this.getData(),
setPage: this.setPage,
renderMap: () => this.props.renderMap(this.mapParams),
renderPagination: this.renderPagination,
};
return getComponent(data, this.props);
};
get hasCustomRenderer() {
return hasCustomRenderer(this.props);
}

render() {
const style = {
width: '100%',
Expand All @@ -970,15 +985,8 @@ class ReactiveMap extends Component {
{this.renderError()}
{this.shouldRenderLoader ? this.props.loader : null}
{!this.shouldRenderLoader
&& (this.props.renderAllData
? this.props.renderAllData(
this.withClickIds(parseHits(this.props.hits)),
this.loadMore,
() => this.props.renderMap(this.mapParams),
this.renderPagination,
this.triggerAnalytics,
this.getData(),
) // prettier-ignore
&& (this.hasCustomRenderer
? this.getComponent() // prettier-ignore
: this.props.renderMap(this.mapParams))}
</div>
);
Expand Down Expand Up @@ -1032,8 +1040,8 @@ ReactiveMap.propTypes = {
mapProps: types.props,
markerProps: types.props,
markers: types.children,
renderAllData: types.func,
renderData: types.func,
render: types.func,
renderItem: types.func,
renderError: types.title,
onPageChange: types.func,
onError: types.func,
Expand Down
10 changes: 5 additions & 5 deletions packages/maps/src/components/result/ReactiveOpenStreetMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ReactiveOpenStreetMap extends Component {

getMarkers = ({
showMarkers,
renderData,
renderItem,
defaultPin,
onPopoverClick,
resultsToRender,
Expand All @@ -62,8 +62,8 @@ class ReactiveOpenStreetMap extends Component {
},
};

if (renderData) {
const data = renderData(item);
if (renderItem) {
const data = renderItem(item);

if ('label' in data) {
openStreetMarkerProps.icon = new DivIcon({
Expand Down Expand Up @@ -243,8 +243,8 @@ ReactiveOpenStreetMap.propTypes = {
onData: types.func,
renderError: types.title,
react: types.react,
renderData: types.func,
renderAllData: types.func,
renderItem: types.func,
render: types.func,
size: types.number,
sortBy: types.sortBy,
showMarkers: types.bool,
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivecore
Submodule reactivecore updated 0 files
Loading