instantsearch.js 4.85.1 → 4.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -360,6 +360,14 @@ declare type AutocompleteWidgetParams<TItem extends BaseHit> = {
360
360
  */
361
361
  storageKey?: string;
362
362
  templates?: Partial<{
363
+ /**
364
+ * Template to use for the header, before the list of items.
365
+ */
366
+ header: Template<{
367
+ items: Array<{
368
+ query: string;
369
+ }>;
370
+ }>;
363
371
  /**
364
372
  * Template to use for each result. This template will receive an object containing a single record.
365
373
  */
@@ -371,6 +379,7 @@ declare type AutocompleteWidgetParams<TItem extends BaseHit> = {
371
379
  onRemoveRecentSearch: () => void;
372
380
  }>;
373
381
  }>;
382
+ cssClasses?: Partial<AutocompleteIndexClassNames>;
374
383
  };
375
384
  /**
376
385
  * Search parameters to apply to the autocomplete indices.
@@ -8154,7 +8163,7 @@ declare type SortByConnector = Connector<SortByWidgetDescription, SortByConnecto
8154
8163
 
8155
8164
  declare type SortByConnectorParams = {
8156
8165
  /**
8157
- * Array of objects defining the different indices to choose from.
8166
+ * Array of objects defining the different indices or strategies to choose from.
8158
8167
  */
8159
8168
  items: SortByItem[];
8160
8169
  /**
@@ -8163,6 +8172,8 @@ declare type SortByConnectorParams = {
8163
8172
  transformItems?: TransformItems<SortByItem>;
8164
8173
  };
8165
8174
 
8175
+ declare type SortByDefinition = SortByIndexDefinition | SortByStrategyDefinition;
8176
+
8166
8177
  declare type SortByDirection<TCriterion extends string> = TCriterion | `${TCriterion}:asc` | `${TCriterion}:desc`;
8167
8178
 
8168
8179
  declare type SortByIndexDefinition = {
@@ -8174,14 +8185,27 @@ declare type SortByIndexDefinition = {
8174
8185
  * The label of the index to display.
8175
8186
  */
8176
8187
  label: string;
8188
+ /**
8189
+ * Ensures mutual exclusivity with strategy.
8190
+ */
8191
+ strategy?: never;
8177
8192
  };
8178
8193
 
8179
8194
  /**
8180
8195
  * The **SortBy** connector provides the logic to build a custom widget that will display a
8181
- * list of indices. With Algolia, this is most commonly used for changing ranking strategy. This allows
8182
- * a user to change how the hits are being sorted.
8196
+ * list of indices or sorting strategies. With Algolia, this is most commonly used for changing
8197
+ * ranking strategy. This allows a user to change how the hits are being sorted.
8198
+ *
8199
+ * This connector supports two sorting modes:
8200
+ * 1. **Index-based (traditional)**: Uses the `value` property to switch between different indices.
8201
+ * This is the standard behavior for non-composition setups.
8202
+ *
8203
+ * 2. **Strategy-based (composition mode)**: Uses the `strategy` property to apply sorting strategies
8204
+ * via the `sortBy` search parameter. This is only available when using Algolia Compositions.
8205
+ *
8206
+ * Items can mix both types in the same widget, allowing for flexible sorting options.
8183
8207
  */
8184
- declare type SortByItem = {
8208
+ declare type SortByIndexItem = {
8185
8209
  /**
8186
8210
  * The name of the index to target.
8187
8211
  */
@@ -8190,23 +8214,32 @@ declare type SortByItem = {
8190
8214
  * The label of the index to display.
8191
8215
  */
8192
8216
  label: string;
8217
+ /**
8218
+ * Ensures mutual exclusivity with strategy.
8219
+ */
8220
+ strategy?: never;
8193
8221
  };
8194
8222
 
8223
+ declare type SortByItem = SortByIndexItem | SortByStrategyItem;
8224
+
8195
8225
  declare type SortByRenderState = {
8196
8226
  /**
8197
- * The initially selected index.
8227
+ * The initially selected index or strategy.
8198
8228
  */
8199
8229
  initialIndex?: string;
8200
8230
  /**
8201
- * The currently selected index.
8231
+ * The currently selected index or strategy.
8202
8232
  */
8203
8233
  currentRefinement: string;
8204
8234
  /**
8205
- * All the available indices
8235
+ * All the available indices and strategies
8206
8236
  */
8207
- options: SortByItem[];
8237
+ options: Array<{
8238
+ value: string;
8239
+ label: string;
8240
+ }>;
8208
8241
  /**
8209
- * Switches indices and triggers a new search.
8242
+ * Switches indices or strategies and triggers a new search.
8210
8243
  */
8211
8244
  refine: (value: string) => void;
8212
8245
  /**
@@ -8220,6 +8253,38 @@ declare type SortByRenderState = {
8220
8253
  canRefine: boolean;
8221
8254
  };
8222
8255
 
8256
+ declare type SortByStrategyDefinition = {
8257
+ /**
8258
+ * The name of the sorting strategy to use.
8259
+ * Only available in composition mode.
8260
+ */
8261
+ strategy: string;
8262
+ /**
8263
+ * The label of the strategy to display.
8264
+ */
8265
+ label: string;
8266
+ /**
8267
+ * Ensures mutual exclusivity with value.
8268
+ */
8269
+ value?: never;
8270
+ };
8271
+
8272
+ declare type SortByStrategyItem = {
8273
+ /**
8274
+ * The name of the sorting strategy to use.
8275
+ * Only available in composition mode.
8276
+ */
8277
+ strategy: string;
8278
+ /**
8279
+ * The label of the strategy to display.
8280
+ */
8281
+ label: string;
8282
+ /**
8283
+ * Ensures mutual exclusivity with value.
8284
+ */
8285
+ value?: never;
8286
+ };
8287
+
8223
8288
  declare type SortByWidget = WidgetFactory<SortByWidgetDescription & {
8224
8289
  $$widgetType: 'ais.sortBy';
8225
8290
  }, SortByConnectorParams, SortByWidgetParams>;
@@ -8256,9 +8321,9 @@ declare type SortByWidgetParams = {
8256
8321
  */
8257
8322
  container: string | HTMLElement;
8258
8323
  /**
8259
- * Array of objects defining the different indices to choose from.
8324
+ * Array of objects defining the different indices or strategies to choose from.
8260
8325
  */
8261
- items: SortByIndexDefinition[];
8326
+ items: SortByDefinition[];
8262
8327
  /**
8263
8328
  * CSS classes to be added.
8264
8329
  */