Skip to content

Commit

Permalink
fix(helpers): remove deprecated helpers (#6403)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove instantsearch.highlight, instantsearch.reverseHighlight, instantsearch.snippet, instantsearch.reverseSnippet. Instead use the `components` available from a template
BREAKING CHANGE: remove instantsearch.insights, instead use sendEvent
BREAKING CHANGE: remove instantsearch.getInsightsAnonymousUserToken
  • Loading branch information
Haroenv committed Oct 24, 2024
1 parent 978243a commit 81599db
Show file tree
Hide file tree
Showing 43 changed files with 67 additions and 3,248 deletions.
4 changes: 2 additions & 2 deletions examples/js/media/src/widgets/Articles.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { formatDistanceToNow } from 'date-fns';
import { html, render } from 'htm/preact';
import { Hit } from 'instantsearch.js';
import { Hit as AlgoliaHit } from 'instantsearch.js';
import { connectInfiniteHits } from 'instantsearch.js/es/connectors';
import { Snippet, Highlight } from 'instantsearch.js/es/helpers/components';

type Result = Hit<{
type Result = AlgoliaHit<{
slug: string;
primary_category: {
slug: string;
Expand Down
9 changes: 1 addition & 8 deletions packages/instantsearch.js/src/__tests__/index-es-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,10 @@ describe('instantsearch()', () => {
`);
});

it('includes the helper functions', () => {
it("includes what's expected", () => {
expect(Object.keys(instantsearch)).toMatchInlineSnapshot(`
[
"version",
"createInfiniteHitsSessionStorageCache",
"highlight",
"reverseHighlight",
"snippet",
"reverseSnippet",
"insights",
"getInsightsAnonymousUserToken",
]
`);
});
Expand Down
7 changes: 1 addition & 6 deletions packages/instantsearch.js/src/__tests__/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('instantsearch()', () => {
});
});

it('includes the API and the helper functions', () => {
it('includes the API', () => {
expect(Object.keys(instantsearch)).toMatchInlineSnapshot(`
[
"version",
Expand All @@ -30,11 +30,6 @@ describe('instantsearch()', () => {
"stateMappings",
"templates",
"createInfiniteHitsSessionStorageCache",
"highlight",
"reverseHighlight",
"snippet",
"reverseSnippet",
"insights",
]
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { cx } from 'instantsearch-ui-components';
import { h } from 'preact';

import { createInsightsEventHandler } from '../../lib/insights/listener';
import { warning } from '../../lib/utils';
import Template from '../Template/Template';

Expand Down Expand Up @@ -80,7 +79,7 @@ const DefaultBanner = ({
const InfiniteHits = ({
results,
hits,
insights,

sendEvent,
hasShowPrevious,
showPrevious,
Expand All @@ -91,17 +90,9 @@ const InfiniteHits = ({
templateProps,
banner,
}: InfiniteHitsProps) => {
const handleInsightsClick = createInsightsEventHandler({
insights,
sendEvent,
});

if (results.hits.length === 0) {
return (
<div
className={cx(cssClasses.root, cssClasses.emptyRoot)}
onClick={handleInsightsClick}
>
<div className={cx(cssClasses.root, cssClasses.emptyRoot)}>
{banner &&
(templateProps.templates.banner ? (
<Template
Expand Down Expand Up @@ -167,12 +158,10 @@ const InfiniteHits = ({
rootTagName="li"
rootProps={{
className: cssClasses.item,
onClick: (event: MouseEvent) => {
handleInsightsClick(event);
onClick: () => {
sendEvent('click:internal', hit, 'Hit Clicked');
},
onAuxClick: (event: MouseEvent) => {
handleInsightsClick(event);
onAuxClick: () => {
sendEvent('click:internal', hit, 'Hit Clicked');
},
}}
Expand Down

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions packages/instantsearch.js/src/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ export { default as connectClearRefinements } from './clear-refinements/connectC
export { default as connectCurrentRefinements } from './current-refinements/connectCurrentRefinements';
export { default as connectHierarchicalMenu } from './hierarchical-menu/connectHierarchicalMenu';
export { default as connectHits } from './hits/connectHits';
export { default as connectHitsWithInsights } from './hits/connectHitsWithInsights';
export { default as connectHitsPerPage } from './hits-per-page/connectHitsPerPage';
export { default as connectInfiniteHits } from './infinite-hits/connectInfiniteHits';
export { default as connectInfiniteHitsWithInsights } from './infinite-hits/connectInfiniteHitsWithInsights';
export { default as connectMenu } from './menu/connectMenu';
export { default as connectNumericMenu } from './numeric-menu/connectNumericMenu';
export { default as connectPagination } from './pagination/connectPagination';
Expand Down

This file was deleted.

Loading

0 comments on commit 81599db

Please sign in to comment.