Commit 7a4b137
authored
feat(recommend): add Trending Facets widget (#6957)
* feat(recommend): add Trending Facets widget
Add the `trendingFacets` Recommend model widget across instantsearch.js
and React flavors. Unlike other Recommend widgets that return product
hits, Trending Facets returns facet values (e.g., trending brands or
categories) as a pure-display, read-only list.
New packages/exports:
- `connectTrendingFacets` connector (instantsearch.js)
- `trendingFacets` widget (instantsearch.js)
- `createTrendingFacetsComponent` UI component (instantsearch-ui-components)
- `useTrendingFacets` React hook (react-instantsearch-core)
- `<TrendingFacets>` React component (react-instantsearch)
- `TrendingFacetItem` type with `{ facetName, facetValue, _score }`
Key design decisions:
- Standalone UI component (not based on shared Recommend base)
- Strict `TrendingFacetItem` type, not wrapped in `Hit<>`
- No `sendEvent`/analytics in v1
- Supports `queryParameters`, `fallbackParameters`, `escapeHTML`,
`transformItems`, and full template customization (item/header/empty)
* fix: address Copilot review feedback
- Add exports to UMD entrypoints (connectors/index.umd.ts, widgets/index.umd.ts)
- Replace custom escapeFacetValue() with shared escape() from escape-html.ts
- Add runtime validation for required facetName option
* fix: add TrendingFacets to UMD exports and update test fixtures
- Add TrendingFacets to react-instantsearch UMD widget index
- Update all-widgets.test.tsx inline snapshot with TrendingFacets entry
- Add trendingFacets case to widgets index.test.ts (required facetName)
* fix: handle v4 TrendingFacetsQuery type gap for queryParameters/fallbackParameters
The v4 algoliasearch TrendingFacetsQuery type doesn't include
queryParameters or fallbackParameters (v5 does). Use `as any` at the
addTrendingFacets call boundary with a comment documenting the gap.
* update bundlesize
* test: add TrendingFacets to common test suite
- Add createTrendingFacetsSearchClient mock with facet-shaped fixture data
- Add common widget tests (options, links) for TrendingFacets
- Add common connector tests (options, state) for TrendingFacets
- Register in IS.js, React, and Vue (skipped) common test entry points
* fix: add TrendingFacets connector stub to Vue common tests1 parent 5289c69 commit 7a4b137
File tree
37 files changed
+2391
-2
lines changed- packages
- instantsearch-ui-components/src/components
- __tests__
- instantsearch.js/src
- __tests__
- connectors
- trending-facets
- __tests__
- types
- widgets
- __tests__
- trending-facets
- __tests__
- react-instantsearch-core/src
- connectors
- __tests__
- react-instantsearch/src
- __tests__
- widgets
- __tests__
- __utils__
- vue-instantsearch/src/__tests__
- tests
- common
- connectors
- trending-facets
- widgets
- trending-facets
- mocks/fixtures
37 files changed
+2391
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
Lines changed: 135 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
0 commit comments