Skip to content

Commit

Permalink
implement widgetType
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed Jan 13, 2021
1 parent a160210 commit 7d06cbc
Show file tree
Hide file tree
Showing 32 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/types/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export type Widget<
| 'ais.index'
| 'ais.infiniteHits'
| 'ais.menu'
| 'ais.menuSelect'
| 'ais.numericMenu'
| 'ais.pagination'
| 'ais.places'
Expand Down
1 change: 1 addition & 0 deletions src/widgets/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ For the migration, visit https://www.algolia.com/doc/guides/building-search-ui/u

return {
$$type: 'ais.analytics',
$$widgetType: 'ais.analytics',

init() {
if (triggerOnUIInteraction === true) {
Expand Down
1 change: 1 addition & 0 deletions src/widgets/breadcrumb/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const breadcrumb: BreadcrumbWidget = function breadcrumb(widgetOptions) {

return {
...makeWidget({ attributes, separator, rootPath, transformItems }),
$$widgetType: 'ais.breadcrumb',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/clear-refinements/clear-refinements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const clearRefinements: ClearRefinementsWidget = widgetOptions => {
excludedAttributes,
transformItems,
}),
$$widgetType: 'ais.clearRefinements',
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const configureRelatedItems: ConfigureRelatedItemsWidget = function configureRel

return {
...makeWidget(widgetParams),
$$widgetType: 'ais.configureRelatedItems',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/configure/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const configure: ConfigureWidget = function configure(widgetParams) {

return {
...makeWidget({ searchParameters: widgetParams }),
$$widgetType: 'ais.configure',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/current-refinements/current-refinements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const currentRefinements: CurrentRefinementsWidget = function currentRefinements
excludedAttributes,
transformItems,
}),
$$widgetType: 'ais.currentRefinements',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/geo-search/geo-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ const geoSearch = widgetOptions => {
enableClearMapRefinement,
enableRefineControl,
}),
$$widgetType: 'ais.geoSearch',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/hierarchical-menu/hierarchical-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,6 @@ export default function hierarchicalMenu(widgetOptions) {
sortBy,
transformItems,
}),
$$widgetType: 'ais.hierarchicalMenu',
};
}
1 change: 1 addition & 0 deletions src/widgets/hits-per-page/hits-per-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const hitsPerPage: HitsPerPageWidget = function hitsPerPage(widgetOptions) {

return {
...makeWidget({ items, transformItems }),
$$widgetType: 'ais.hitsPerPage',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/hits/hits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const hits: HitsWidget = function hits(widgetOptions) {

return {
...makeWidget({ escapeHTML, transformItems }),
$$widgetType: 'ais.hits',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ const index = (props: IndexProps): Index => {

return {
$$type: 'ais.index',
$$widgetType: 'ais.index',

getIndexName() {
return indexName;
Expand Down
1 change: 1 addition & 0 deletions src/widgets/infinite-hits/infinite-hits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ const infiniteHits: InfiniteHitsWidget = widgetOptions => {
showPrevious,
cache,
}),
$$widgetType: 'ais.infiniteHits',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/menu-select/menu-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@ export default function menuSelect(widgetOptions) {

return {
...makeWidget({ attribute, limit, sortBy, transformItems }),
$$widgetType: 'ais.menuSelect',
};
}
1 change: 1 addition & 0 deletions src/widgets/menu/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,6 @@ export default function menu(widgetOptions) {
sortBy,
transformItems,
}),
$$widgetType: 'ais.menu',
};
}
1 change: 1 addition & 0 deletions src/widgets/numeric-menu/numeric-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const numericMenu: NumericMenuWidget = function numericMenu(widgetOptions) {
items,
transformItems,
}),
$$widgetType: 'ais.numericMenu',
};
};

Expand Down
1 change: 1 addition & 0 deletions src/widgets/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,6 @@ export default function pagination(widgetOptions) {

return {
...makeWidget({ totalPages, padding }),
$$widgetType: 'ais.pagination',
};
}
1 change: 1 addition & 0 deletions src/widgets/places/places.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const placesWidget: PlacesWidget = (widgetParams: PlacesWidgetParams) => {

return {
$$type: 'ais.places',
$$widgetType: 'ais.places',

init({ helper }) {
placesAutocomplete.on('change', (eventOptions: ChangeEvent) => {
Expand Down
1 change: 1 addition & 0 deletions src/widgets/powered-by/powered-by.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ export default function poweredBy(widgetOptions) {

return {
...makeWidget({ theme }),
$$widgetType: 'ais.poweredBy',
};
}
1 change: 1 addition & 0 deletions src/widgets/query-rule-context/query-rule-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const queryRuleContext: QueryRuleContext = (
...connectQueryRules<QueryRuleContextWidgetParams>(noop)(widgetParams),

$$type: 'ais.queryRuleContext',
$$widgetType: 'ais.queryRuleContext',
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const queryRuleCustomData: QueryRuleCustomDataWidget = widgetOptions => {
}),

$$type: 'ais.queryRuleCustomData',
$$widgetType: 'ais.queryRuleCustomData',
};
};

Expand Down
2 changes: 1 addition & 1 deletion src/widgets/range-input/__tests__/range-input-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/range-input

expect(widget).toEqual(
expect.objectContaining({
$$type: 'ais.range',
$$type: 'ais.rangeInput',
$$widgetType: 'ais.rangeInput',
})
);
Expand Down
1 change: 1 addition & 0 deletions src/widgets/range-input/range-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export default function rangeInput(widgetOptions) {
precision,
}),

$$type: 'ais.rangeInput',
$$widgetType: 'ais.rangeInput',
};
}
2 changes: 1 addition & 1 deletion src/widgets/range-slider/__tests__/range-slider-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/range-slide

expect(widget).toEqual(
expect.objectContaining({
$$type: 'ais.range',
$$type: 'ais.rangeSlider',
$$widgetType: 'ais.rangeSlider',
})
);
Expand Down
1 change: 1 addition & 0 deletions src/widgets/range-slider/range-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export default function rangeSlider(widgetOptions) {
return {
...makeWidget({ attribute, min, max, precision }),

$$type: 'ais.rangeSlider',
$$widgetType: 'ais.rangeSlider',
};
}
1 change: 1 addition & 0 deletions src/widgets/rating-menu/rating-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@ export default function ratingMenu(widgetOptions) {

return {
...makeWidget({ attribute, max }),
$$widgetType: 'ais.ratingMenu',
};
}
1 change: 1 addition & 0 deletions src/widgets/refinement-list/refinement-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,6 @@ export default function refinementList(widgetOptions) {
escapeFacetValues,
transformItems,
}),
$$widgetType: 'ais.refinementList',
};
}
1 change: 1 addition & 0 deletions src/widgets/search-box/search-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@ export default function searchBox(widgetOptions) {

return {
...makeWidget({ queryHook }),
$$widgetType: 'ais.searchBox',
};
}
1 change: 1 addition & 0 deletions src/widgets/sort-by/sort-by.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,6 @@ export default function sortBy(widgetOptions) {

return {
...makeWidget({ items, transformItems }),
$$widgetType: 'ais.sortBy',
};
}
1 change: 1 addition & 0 deletions src/widgets/stats/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@ export default function stats(widgetOptions) {

return {
...makeWidget(),
$$widgetType: 'ais.stats',
};
}
1 change: 1 addition & 0 deletions src/widgets/toggle-refinement/toggle-refinement.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,6 @@ export default function toggleRefinement(widgetOptions) {

return {
...makeWidget({ attribute, on, off }),
$$widgetType: 'ais.toggleRefinement',
};
}
1 change: 1 addition & 0 deletions src/widgets/voice-search/voice-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const voiceSearch: VoiceSearch = widgetOptions => {
additionalQueryParameters,
createVoiceSearchHelper,
}),
$$widgetType: 'ais.voiceSearch',
};
};

Expand Down

0 comments on commit 7d06cbc

Please sign in to comment.