Skip to content

Commit

Permalink
fix(widgets): remove places widget (#6397)
Browse files Browse the repository at this point in the history
The places widget has long been deprecated, and is removed without replacement as no places service exists anymore.

As a userland solution if you're using the places widget, copy the removed `places.ts` file inside your own project and import it locally.

BREAKING CHANGE: the places widget no longer exists
  • Loading branch information
Haroenv committed Oct 18, 2024
1 parent 1cec9b6 commit bedf54d
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 755 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@
"jsdom-global": "3.0.2",
"lerna": "6.0.3",
"patch-package": "6.2.2",
"places.js": "1.17.1",
"prettier": "^2.4.1",
"prop-types": "15.6.2",
"react": "19.0.0",
Expand All @@ -143,7 +142,6 @@
"typescript": "5.5.2"
},
"resolutions": {
"places.js/algoliasearch": "5.1.1",
"brotli-size": "4.0.0",
"webpack": "4.47.0",
"babel-loader": "8.2.2"
Expand Down
6 changes: 0 additions & 6 deletions packages/instantsearch.js/.storybook/static/storybook.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,6 @@ body {
margin: 0 auto;
}

.algolia-places {
display: block !important;
width: 100%;
margin: 0 auto;
}

.my-custom-marker {
position: relative;
background-color: white;
Expand Down
1 change: 0 additions & 1 deletion packages/instantsearch.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"@storybook/html": "5.3.9",
"@types/scriptjs": "0.0.2",
"algoliasearch": "5.1.1",
"places.js": "1.17.1",
"scriptjs": "2.5.9",
"webpack": "4.47.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3133,10 +3133,6 @@ describe('initialUiState', () => {
menu: {
category: 'Hardware',
},
places: {
query: 'Paris',
position: '1,1',
},
// This is a UI parameter that is not supported by default but that
// can be added when using custom widgets. Having it in `initialUiState`
// makes sure that it doesn't throw if it happens.
Expand Down Expand Up @@ -3167,7 +3163,6 @@ To fully reflect the state, some widgets need to be added to the index "indexNam
- \`hierarchicalMenu\` needs one of these widgets: "hierarchicalMenu"
- \`range\` needs one of these widgets: "rangeInput", "rangeSlider"
- \`menu\` needs one of these widgets: "menu", "menuSelect"
- \`places\` needs one of these widgets: "places"
If you do not wish to display widgets but still want to support their search parameters, you can mount "virtual widgets" that don't render anything:
Expand Down
4 changes: 0 additions & 4 deletions packages/instantsearch.js/src/lib/utils/checkIndexUiState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ const stateToWidgetsMap: StateToWidgets = {
connectors: ['connectConfigure'],
widgets: ['ais.configure'],
},
places: {
connectors: [],
widgets: ['ais.places'],
},
};

type CheckIndexUiStateParams = {
Expand Down
7 changes: 1 addition & 6 deletions packages/instantsearch.js/src/types/render-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import type { SortByWidgetDescription } from '../connectors/sort-by/connectSortB
import type { StatsWidgetDescription } from '../connectors/stats/connectStats';
import type { ToggleRefinementWidgetDescription } from '../connectors/toggle-refinement/connectToggleRefinement';
import type { VoiceSearchWidgetDescription } from '../connectors/voice-search/connectVoiceSearch';
import type { PlacesWidgetDescription } from '../widgets/places/places';

type ConnectorRenderStates = AnswersWidgetDescription['indexRenderState'] &
AutocompleteWidgetDescription['indexRenderState'] &
Expand Down Expand Up @@ -51,11 +50,7 @@ type ConnectorRenderStates = AnswersWidgetDescription['indexRenderState'] &
ToggleRefinementWidgetDescription['indexRenderState'] &
VoiceSearchWidgetDescription['indexRenderState'];

type WidgetRenderStates = PlacesWidgetDescription['indexRenderState'];

export type IndexRenderState = Partial<
ConnectorRenderStates & WidgetRenderStates
>;
export type IndexRenderState = Partial<ConnectorRenderStates>;

export type RenderState = {
[indexId: string]: IndexRenderState;
Expand Down
5 changes: 1 addition & 4 deletions packages/instantsearch.js/src/types/ui-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type { SearchBoxWidgetDescription } from '../connectors/search-box/connec
import type { SortByWidgetDescription } from '../connectors/sort-by/connectSortBy';
import type { ToggleRefinementWidgetDescription } from '../connectors/toggle-refinement/connectToggleRefinement';
import type { VoiceSearchWidgetDescription } from '../connectors/voice-search/connectVoiceSearch';
import type { PlacesWidgetDescription } from '../widgets/places/places';

type ConnectorUiStates = AutocompleteWidgetDescription['indexUiState'] &
ConfigureWidgetDescription['indexUiState'] &
Expand All @@ -35,9 +34,7 @@ type ConnectorUiStates = AutocompleteWidgetDescription['indexUiState'] &
ToggleRefinementWidgetDescription['indexUiState'] &
VoiceSearchWidgetDescription['indexUiState'];

type WidgetUiStates = PlacesWidgetDescription['indexUiState'];

export type IndexUiState = Partial<ConnectorUiStates & WidgetUiStates>;
export type IndexUiState = Partial<ConnectorUiStates>;

export type UiState = {
[indexId: string]: IndexUiState;
Expand Down
2 changes: 0 additions & 2 deletions packages/instantsearch.js/src/types/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export type BuiltinTypes =
| 'ais.menu'
| 'ais.numericMenu'
| 'ais.pagination'
| 'ais.places'
| 'ais.poweredBy'
| 'ais.queryRules'
// @TODO: remove individual types for rangeSlider & rangeInput once updating checkIndexUiState
Expand Down Expand Up @@ -114,7 +113,6 @@ export type BuiltinWidgetTypes =
| 'ais.menuSelect'
| 'ais.numericMenu'
| 'ais.pagination'
| 'ais.places'
| 'ais.poweredBy'
| 'ais.queryRuleCustomData'
| 'ais.queryRuleContext'
Expand Down
10 changes: 0 additions & 10 deletions packages/instantsearch.js/src/widgets/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as widgets from '..';

import type { UnknownWidgetFactory, Widget } from '../../types';
import type { IndexWidget } from '../index/index';
import type { PlacesInstance } from 'places.js';

/**
* Checklist when adding a new widget
Expand Down Expand Up @@ -110,15 +109,6 @@ function initiateAllWidgets(): Array<[WidgetNames, Widget | IndexWidget]> {
},
});
}
case 'places': {
const places = widget as Widgets['places'];
// @ts-expect-error
const placesInstance: PlacesInstance = {};
return places({
container: document.createElement('input'),
placesReference: () => placesInstance,
});
}
case 'panel': {
const panel = widget as Widgets['panel'];
return panel()(widgets.hierarchicalMenu)({
Expand Down
1 change: 0 additions & 1 deletion packages/instantsearch.js/src/widgets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export { default as menuSelect } from './menu-select/menu-select';
export { default as numericMenu } from './numeric-menu/numeric-menu';
export { default as pagination } from './pagination/pagination';
export { default as panel } from './panel/panel';
export { default as places } from './places/places';
export { default as poweredBy } from './powered-by/powered-by';
export { default as queryRuleContext } from './query-rule-context/query-rule-context';
export { default as queryRuleCustomData } from './query-rule-custom-data/query-rule-custom-data';
Expand Down
Loading

0 comments on commit bedf54d

Please sign in to comment.