@indxsearch/intrface 4.0.0-beta.4 → 4.0.0-beta.5

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0-beta.5
4
+
5
+ ### Minor Changes
6
+
7
+ - ef833bd: `<SearchAgent mark>` marks the searches an AI agent's changes cause as an agent's, so your dataset's statistics count them beside the totals and Observr tells them from your visitors' searches. Off by default; a person's change searches unmarked as before. Needs Indx server 6.0.
8
+ - c711a85: New, experimental: `@indxsearch/intrface/agent` makes your search page one AI agents can read and operate, built on UI SDK's agent bridge. Wrap the page in `SearchAgent` and its parts in `AgentSearchText`, `AgentFacet`, `AgentRange`, `AgentSort` and `AgentResults`: an agent then sees the search text, each facet's values with their counts, the order and the results as data, and changes them the way a person does. Hand it to your own assistant with `useSearchAgent()`, or to the visitor's browser agent with `browser`. `allow` decides what an agent may do. A page that does not import it loads none of it; UI SDK is an optional dependency.
9
+ - 4625d04: New bindings for a search page built from components of your own: `useSearchTextBinding()`, `useFacetBinding(field)`, `useRangeBinding(field)`, `useSortBinding()` and `useResultsBinding(title)` each give a controlled component the search as a `value`, an `onValueChange` and its choices as `items`, so UI SDK's, Base UI's or Radix's components search, filter and sort as intrface's own parts do. With UI SDK's components inside `SearchAgent`, agents can use them too.
10
+ - 1e4c371: New `@indxsearch/intrface/core`: the search without React. `createSearch` holds what a search page holds, the text, the filters, the order and the results, and knows when to search and which answer to keep, so you can build an Indx search in Vue, Svelte or a plain page and get the same behaviour intrface's components have. Subscribe to it, render its snapshot, and call its actions. It imports no React and no styles. `SearchProvider` now runs on it, and nothing changes for a React page.
11
+ - 1e4c371: New `HierarchicalFilterPanel`: a category menu over one field per level, like InstantSearch's hierarchical menu. Choosing a category filters the search to it and opens its children; choosing it again goes back to its parent. Every level along the way keeps its other categories with their counts, so visitors can move sideways as well as down. Each level can hold its own name, or the whole path with a `separator` such as `" > "`. Taking a level away in the active filters takes the levels below it too. The search behind it is in `@indxsearch/intrface/core` as `setHierarchy`, so it works without React as well.
12
+ - 1e4c371: New `SearchPagination`: numbered pages for the result list. Each page fetches only its own records, so moving between pages is quick, and the count and filters stay as they are. A new search, filter or sort goes back to the first page. Pages stop at 5,000 results, and the last page says so when there are more. `SearchResults` takes `loadMore={false}` for pages that use numbered pages instead of Load more. Without React, `setPage` and `pageCount` are in `@indxsearch/intrface/core`. The number beside each result is now its place in the whole list, counted from 1, so page 3 of 20 starts at 41.
13
+ - 754ce42: New `SearchLayout`: put a search page together from intrface's parts, in one of three recipes. `component` for a search inside another page (on a systm Base, the filters on the right), `page` for a search page of its own (no background, the filters on the left) and `micro` for a search box in a site's header (its results in a panel under the field, with "See all"). Each area takes intrface's parts or your own, and each recipe draws filter panels and result rows for its ground. The filters fold behind a Filters button on narrow screens.
14
+ - 1feb6a4: Records whose keys are text, such as SKUs or ISBNs, are looked up and reported by their key. Each result carries `key`, the key as the data writes it, beside `documentKey`, and selects, conversions and the assistant's picks are sent by it. `convertResult` takes the key as text as well as the number. A dataset with number keys works exactly as before. Needs Indx server 6.0.
15
+
16
+ ### Patch Changes
17
+
18
+ - 8ceb7ef: A result row takes its inset, its divider and its chips' background from CSS custom properties (`--result-row-padding`, `--result-row-divider`, `--result-chip-background`), so on a plain page the rows divide visibly and line up with the search field. Unset, they look as before.
19
+ - Updated dependencies [8ceb7ef]
20
+ - Updated dependencies [1e4c371]
21
+ - Updated dependencies [1feb6a4]
22
+ - @indxsearch/systm@2.25.0-beta.2
23
+ - @indxsearch/indx-types@4.0.0-beta.3
24
+
3
25
  ## 4.0.0-beta.4
4
26
 
5
27
  ### Minor Changes
package/README.md CHANGED
@@ -265,6 +265,21 @@ import { BucketFilterPanel } from '@indxsearch/intrface';
265
265
 
266
266
  Each bucket is a range filter. Selected buckets on one field are ORed, so ticking two widens the result; across fields they AND as usual. Counts are summed from the field's facet values, so the field must be facetable for counts to show (filterable is enough for the filter itself).
267
267
 
268
+ ### Hierarchical Filters (Categories)
269
+
270
+ A category tree over one Filterable and Facetable field per level, from the top. Choosing a category
271
+ filters to it and opens its children; choosing it again goes back to its parent, and the other
272
+ categories at each level stay with their counts.
273
+
274
+ ```tsx
275
+ <HierarchicalFilterPanel label="Category" fields={['category.lvl0', 'category.lvl1', 'category.lvl2']} />
276
+ ```
277
+
278
+ A level may hold its own name ("Shoes") or the whole path ("Clothing > Shoes"); for the second, set
279
+ `separator=" > "` and the menu shows the last part. `limit` (10), `sortBy` (`'count'` or `'name'`)
280
+ and `showCount` work as on `ValueFilterPanel`. Without React: `search.setHierarchy(fields, path)`
281
+ from `@indxsearch/intrface/core`.
282
+
268
283
  ### Active Filters Display
269
284
 
270
285
  ```typescript
@@ -273,6 +288,19 @@ import { ActiveFiltersPanel } from '@indxsearch/intrface';
273
288
  <ActiveFiltersPanel />
274
289
  ```
275
290
 
291
+ ### Numbered Pages
292
+
293
+ ```typescript
294
+ import { SearchPagination, SearchResults } from '@indxsearch/intrface';
295
+
296
+ <SearchProvider maxResults={20} /* ... */>
297
+ <SearchResults resultsPerPage={20} loadMore={false}>{/* ... */}</SearchResults>
298
+ <SearchPagination onPageChange={() => window.scrollTo({ top: 0 })} />
299
+ </SearchProvider>
300
+ ```
301
+
302
+ Each page is a search for its own records, starting where the pages before it end; the count and the facets stay as they are. The page size is the provider's `maxResults`; keep `resultsPerPage` the same and turn off Load more. A new query, filter or sort goes back to the first page. A search ranks at most 5,000 records, so the pages stop there and the last one says so when the count is larger. Without React, the same is `setPage(n)` and `pageCount(state)` in `@indxsearch/intrface/core`.
303
+
276
304
  ## Full Example with Filters
277
305
 
278
306
  ```typescript
@@ -332,6 +360,45 @@ export default function AdvancedSearch() {
332
360
  }
333
361
  ```
334
362
 
363
+ ## Putting a page together: `SearchLayout`
364
+
365
+ `SearchLayout` arranges the parts for where your search lives, so you put a page together rather
366
+ than style one. Three recipes:
367
+
368
+ | Recipe | For | Shape |
369
+ |---|---|---|
370
+ | `component` (default) | a search inside another page | on a systm Base: the field in a header, the results under it, the filters column on the right |
371
+ | `page` | a search page of its own | no background: a title, the filters on the left, the field over the results |
372
+ | `micro` | a search box in a site's header | a small field; typing opens a panel under it with the top results and "See all" |
373
+
374
+ ```tsx
375
+ <SearchProvider url={url} team={team} dataset={dataset} preAuthenticatedToken={token}>
376
+ <SearchLayout
377
+ filters={<>
378
+ <ValueFilterPanel field="genres" label="Genres" />
379
+ <SortByPanel startCollapsed />
380
+ </>}
381
+ above={<ActiveFiltersPanel />}
382
+ results={<SearchResults>{film => <h3>{film.title}</h3>}</SearchResults>} />
383
+ </SearchProvider>
384
+
385
+ // In your site's header:
386
+ <SearchLayout recipe="micro"
387
+ results={<SearchResults resultsPerPage={5}>{film => film.title}</SearchResults>}
388
+ onAllResults={query => router.push(`/search?q=${encodeURIComponent(query)}`)} />
389
+ ```
390
+
391
+ Each area takes any content, so a part can be one of your own. `field` defaults to `SearchInput`,
392
+ `meta` goes beside it (a logo), `title` over a page, `above` between the field and the results (the
393
+ active filters, `AskOffer`). Sort is a panel among the filters, not a toolbar. Under 800px
394
+ (`narrowBelow`) the filters fold behind a Filters button.
395
+
396
+ Each recipe also draws the parts for its ground: filter panels as cards on a Base and as sections
397
+ between hairlines on a page, result rows lined up with the field. A page can set those itself
398
+ through CSS custom properties: `--filter-panel-background`, `--filter-panel-padding`,
399
+ `--filter-panel-radius`, `--filter-panel-gap`, `--filter-panel-divider`, `--result-row-padding`,
400
+ `--result-row-divider` and `--result-chip-background`.
401
+
335
402
  ## Search or ask
336
403
 
337
404
  When the dataset has Search or ask switched on (Indx server 6.0), the field also answers questions
@@ -418,7 +485,7 @@ articles it read (`onSourceClick` opens one in your page), and `actions` are you
418
485
  <SearchProvider url={url} team={team} dataset="help-articles" preAuthenticatedToken={token}>
419
486
  <AskChat intro="Ask about your account or billing." examples={['Can I get a refund?']}
420
487
  actions={[{ label: 'Talk to a person', onClick: openSupport }]}
421
- onSourceClick={s => router.push(`/help/${s.documentKey}`)} />
488
+ onSourceClick={s => router.push(`/help/${s.key ?? s.documentKey}`)} />
422
489
  </SearchProvider>
423
490
  ```
424
491
 
@@ -444,6 +511,99 @@ const flow = useAskFlow({ searchOrAsk: sor });
444
511
  {flow.waiting ? <p>The assistant is searching…</p> : <SearchResults searchOrAsk={sor} />}
445
512
  ```
446
513
 
514
+ ## Without React: `@indxsearch/intrface/core`
515
+
516
+ The search itself is not tied to React. `createSearch` holds the text, the filters, the order and
517
+ the results, sends the searches and drops the answers that came too late. `SearchProvider` is a thin
518
+ layer over it, and a Vue, Svelte or plain-page integration is the same: subscribe, render the
519
+ snapshot, call the actions. This entry imports no React and no styles.
520
+
521
+ ```ts
522
+ import { createSearch } from '@indxsearch/intrface/core';
523
+
524
+ const search = createSearch({
525
+ url: 'https://your-indx-server',
526
+ team: 'your-team',
527
+ dataset: 'products',
528
+ preAuthenticatedToken: token,
529
+ });
530
+
531
+ search.subscribe(() => {
532
+ const { state, isFetchingInitial } = search.getSnapshot();
533
+ render(state.results, state.facets, isFetchingInitial);
534
+ });
535
+ search.start();
536
+
537
+ input.addEventListener('input', e => search.setQuery((e.target as HTMLInputElement).value));
538
+ search.toggleFilter('category', 'shoes');
539
+ search.setSort('price', true);
540
+ ```
541
+
542
+ The snapshot is the same object until something changes, so it works with any store that compares
543
+ by reference (`useSyncExternalStore`, Svelte's `readable`, Vue's `shallowRef`). A search goes once
544
+ the current tick is over, so changes made together are all in it.
545
+
546
+ ## For AI agents: `@indxsearch/intrface/agent`
547
+
548
+ *Experimental.* AI agents are starting to search and shop on sites: a site's own assistant, or the
549
+ visitor's agent in the browser. `@indxsearch/intrface/agent` makes your search page one they can
550
+ read and operate as data rather than by clicking through screenshots. It is built on
551
+ [UI SDK](https://ui-sdk.dev/)'s agent bridge, which is in beta, so install it beside intrface:
552
+
553
+ ```bash
554
+ npm install @ui-sdk/core@0.1.0-beta.17 @ui-sdk/react@0.1.0-beta.17
555
+ ```
556
+
557
+ Wrap the page in `SearchAgent`, and each part you want agents to see in its `Agent…` wrapper. The
558
+ parts keep their look; an agent sees each by its label, with its value, its items and what it may
559
+ do, and changes it the way a person does, so your statistics and Search or ask see the same page.
560
+
561
+ ```tsx
562
+ import { SearchAgent, AgentSearchText, AgentFacet, AgentSort, AgentResults } from '@indxsearch/intrface/agent';
563
+
564
+ <SearchProvider url={url} team={team} dataset={dataset} preAuthenticatedToken={token}>
565
+ <SearchAgent browser={{ allow: () => true }}>
566
+ <AgentSearchText><SearchInput /></AgentSearchText>
567
+ <AgentFacet field="genres" label="Genres"><ValueFilterPanel field="genres" /></AgentFacet>
568
+ <AgentSort><SortByPanel /></AgentSort>
569
+ <AgentResults title={doc => doc.title}>
570
+ <SearchResults>{item => <h3>{item.title}</h3>}</SearchResults>
571
+ </AgentResults>
572
+ </SearchAgent>
573
+ </SearchProvider>
574
+ ```
575
+
576
+ - **The parts:** `AgentSearchText` (the search text), `AgentFacet` (a value facet's values with
577
+ their counts, ticked one by one as a person ticks them), `AgentRange` (a numeric range),
578
+ `AgentSort` (the order) and `AgentResults` (the results by name; a pick is reported as a click).
579
+ - **Your own assistant:** `useSearchAgent()` gives the bridge. `snapshot()` reads the page,
580
+ `act({ steps })` runs steps, and both are tools to hand a model.
581
+ - **The visitor's browser agent:** `browser={{ allow }}` hands the tools to it over WebMCP, where
582
+ the browser has it. Its `allow` decides each step that agent asks for.
583
+ - **Your rules:** `allow` on `SearchAgent` refuses or confirms any step, such as letting an agent
584
+ search but not filter.
585
+ - **Counted apart:** `<SearchAgent mark>` sends the searches an agent's changes cause with
586
+ `actor=agent`, so the statistics count agents' searches beside the totals. Off by default.
587
+
588
+ **Your own components:** for a page built from components of its own (UI SDK's, Base UI's,
589
+ Radix's), the bindings give each control the search as a `value`, an `onValueChange` and `items`:
590
+ `useSearchTextBinding()`, `useFacetBinding(field)`, `useRangeBinding(field)`, `useSortBinding()` and
591
+ `useResultsBinding(title)`, from the main entry. UI SDK's own components are visible to agents
592
+ already, so with them `SearchAgent` is all the page needs:
593
+
594
+ ```tsx
595
+ const text = useSearchTextBinding();
596
+ const brand = useFacetBinding('brand');
597
+
598
+ <Input aria-label="Search" value={text.value} onValueChange={text.onValueChange} />
599
+ <CheckboxGroup aria-label="Brand" value={brand.value} onValueChange={brand.onValueChange}>
600
+ {brand.items.map(i => <label key={i.value}><Checkbox value={i.value} />{i.label}</label>)}
601
+ </CheckboxGroup>
602
+ ```
603
+
604
+ A page that does not import `@indxsearch/intrface/agent` loads none of this, and UI SDK stays an
605
+ optional dependency.
606
+
447
607
  ## Search statistics
448
608
 
449
609
  The dataset's **Statistics** tab shows what people search for, what they find nothing for, and what they choose. The page takes part in two ways:
@@ -511,6 +671,7 @@ Two optional `SearchProvider` props shape what the statistics see:
511
671
  |------|------|----------|-------------|
512
672
  | `fields` | `string[]` | ✅ | Document fields to fetch |
513
673
  | `resultsPerPage` | `number` | ✅ | Results per page |
674
+ | `loadMore` | `boolean` | ❌ | The Load more button under the list. Default `true`; `false` where `SearchPagination` pages the list |
514
675
  | `parseArrayStrings` | `boolean` | ❌ | Convert string fields holding a JSON (`["a","b"]`) or Python-style (`['a', 'b']`) list literal into a `string[]` before `children` sees them. Default `false`; other strings are never altered. |
515
676
  | `children` | `(item: any, meta: SearchResultMeta) => ReactNode` | ✅ | Render function for each result. `meta.result` is the result (key, score, `position`) and `meta.select()` reports that the visitor chose it; see [Search statistics](#search-statistics) |
516
677
 
@@ -622,7 +783,7 @@ const { results, isLoading, error, search } = useVectorSearch(embeddingFn, {
622
783
  });
623
784
 
624
785
  await search('comfortable running shoes');
625
- // results: Array<{ document, documentKey, score }> | null
786
+ // results: Array<{ document, documentKey, key?, score }> | null
626
787
  ```
627
788
 
628
789
  ### useHybridSearch
@@ -641,7 +802,7 @@ const { results, isLoading, error, search } = useHybridSearch(embeddingFn, {
641
802
  });
642
803
 
643
804
  await search('comfortable running shoes');
644
- // results: Array<{ document, documentKey, score }> | null
805
+ // results: Array<{ document, documentKey, key?, score }> | null
645
806
  ```
646
807
 
647
808
  ## Additional Components
@@ -747,4 +908,4 @@ These components are also exported and can be used for custom layouts:
747
908
 
748
909
  ## Support
749
910
 
750
- - **Documentation:** [docs.indx.co](https://docs.indx.co)
911
+ - **Documentation:** [v6.docs.indx.co](https://v6.docs.indx.co) (Indx 6, in beta)
@@ -0,0 +1,43 @@
1
+ import { ReactNode } from 'react';
2
+ import { createAgent, AgentAction } from '@ui-sdk/core/agent';
3
+ /** A step an agent asks to run, for `allow` to decide: true runs it, false refuses it. */
4
+ export type AgentAllow = (step: AgentAction, options: {
5
+ signal: AbortSignal;
6
+ }) => boolean | Promise<boolean>;
7
+ /** The page's agent bridge: `snapshot`, `query` and `act`, also its tools by those names. */
8
+ export type SearchAgentBridge = ReturnType<typeof createAgent>;
9
+ export interface SearchAgentProps {
10
+ /** Decides each step your own agent takes on the page. Without it, every step runs. */
11
+ allow?: AgentAllow;
12
+ /** Hands the page's tools to the visitor's browser agent (WebMCP), where the browser has it.
13
+ * Its `allow` is required: that agent is not one you wrote, and it decides each step it asks
14
+ * for, after `allow` above. */
15
+ browser?: {
16
+ allow: AgentAllow;
17
+ };
18
+ /** Marks the searches an agent's changes cause as an agent's (`actor=agent`), so the dataset's
19
+ * statistics count them apart. Off by default. */
20
+ mark?: boolean;
21
+ /** The page: the agent hears the parts made inside it (AgentSearchText, AgentFacet …). */
22
+ children: ReactNode;
23
+ }
24
+ /**
25
+ * The search page to AI agents (25 Nov 2026, experimental while UI SDK is in beta): the parts wrapped
26
+ * in AgentSearchText, AgentFacet, AgentRange, AgentSort and AgentResults inside it can be read and
27
+ * operated as data through UI SDK's agent bridge, by your own assistant (`useSearchAgent`) or, with
28
+ * `browser`, by the visitor's browser agent. A change an agent makes takes the path a person's does.
29
+ * Inside a SearchProvider.
30
+ *
31
+ * ```tsx
32
+ * <SearchProvider ...>
33
+ * <SearchAgent browser={{ allow: () => true }}>
34
+ * <AgentSearchText><SearchInput /></AgentSearchText>
35
+ * <AgentFacet field="genres" label="Genres"><ValueFilterPanel field="genres" /></AgentFacet>
36
+ * </SearchAgent>
37
+ * </SearchProvider>
38
+ * ```
39
+ */
40
+ export declare function SearchAgent({ allow, browser, mark, children }: SearchAgentProps): import("react/jsx-runtime").JSX.Element;
41
+ /** The page's agent bridge, for your own assistant: `snapshot()` reads the page, `act({ steps })` runs
42
+ * steps, and the three are also tools to hand a model. Null outside a SearchAgent. */
43
+ export declare function useSearchAgent(): SearchAgentBridge | null;
@@ -0,0 +1,4 @@
1
+ export { SearchAgent, useSearchAgent } from './SearchAgent';
2
+ export type { SearchAgentProps, SearchAgentBridge, AgentAllow } from './SearchAgent';
3
+ export { AgentSearchText, AgentFacet, AgentRange, AgentSort, AgentResults } from './parts';
4
+ export type { AgentSearchTextProps, AgentFacetProps, AgentRangeProps, AgentSortProps, AgentResultsProps } from './parts';
@@ -0,0 +1,50 @@
1
+ import { ReactNode } from 'react';
2
+ export interface AgentSearchTextProps {
3
+ /** What the agent calls it. Default "Search". */
4
+ label?: string;
5
+ /** The field itself, e.g. `<SearchInput />`. */
6
+ children: ReactNode;
7
+ }
8
+ /** The search text to an agent: its value, and `setValue`, which searches as typing does. */
9
+ export declare function AgentSearchText({ label, children }: AgentSearchTextProps): import("react").JSX.Element | null;
10
+ export interface AgentFacetProps {
11
+ /** The field the facet is of. */
12
+ field: string;
13
+ /** What the agent calls it, like the panel's label. */
14
+ label: string;
15
+ /** The panel itself, e.g. `<ValueFilterPanel field="genres" />`. */
16
+ children: ReactNode;
17
+ }
18
+ /** A value facet to an agent: its values with their counts as items, the ticked ones its value;
19
+ * `toggle` and `setValue` tick as a person does, one value at a time. */
20
+ export declare function AgentFacet({ field, label, children }: AgentFacetProps): import("react").JSX.Element | null;
21
+ export interface AgentRangeProps {
22
+ /** The numeric field the range is of. */
23
+ field: string;
24
+ /** What the agent calls it, like the panel's label. */
25
+ label: string;
26
+ /** The panel itself, e.g. `<RangeFilterPanel field="price" />`. */
27
+ children: ReactNode;
28
+ }
29
+ /** A range to an agent: its limits as `{ min, max }`, the dataset's bounds beside them; `setValue`
30
+ * sets the range, `clear` takes it off. */
31
+ export declare function AgentRange({ field, label, children }: AgentRangeProps): import("react").JSX.Element | null;
32
+ export interface AgentSortProps {
33
+ /** What the agent calls it. Default "Sort by". */
34
+ label?: string;
35
+ /** The panel itself, e.g. `<SortByPanel />`. */
36
+ children: ReactNode;
37
+ }
38
+ /** The order to an agent: a sortable field as the value (empty for relevance), and the direction. */
39
+ export declare function AgentSort({ label, children }: AgentSortProps): import("react").JSX.Element | null;
40
+ export interface AgentResultsProps {
41
+ /** What the agent calls it. Default "Results". */
42
+ label?: string;
43
+ /** A result's name as the agent reads it: its title, its name. */
44
+ title: (document: unknown, position: number) => string;
45
+ /** The list itself, e.g. `<SearchResults>…</SearchResults>`. */
46
+ children: ReactNode;
47
+ }
48
+ /** The results to an agent: each by its place and name; `pick` chooses one as a person's click does,
49
+ * reported with selectResult so the statistics count it. */
50
+ export declare function AgentResults({ label, title, children }: AgentResultsProps): import("react").JSX.Element | null;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useBindings-D86anih2.js");let t=require("react"),n=require("react/jsx-runtime"),r=require("@ui-sdk/core/agent"),i=require("@ui-sdk/core"),a=require("@ui-sdk/react/primitive");var o=(0,t.createContext)(null);function s({allow:i,browser:a,mark:s=!1,children:c}){let[l]=(0,t.useState)(()=>(0,r.createAgent)(i?{allow:i}:{})),{setAgentMarking:u}=e.c();(0,t.useEffect)(()=>(u?.(s),()=>u?.(!1)),[s,u]);let d=a?.allow;return(0,t.useEffect)(()=>{if(d)return(0,r.registerTools)(l,{allow:d})},[l,d]),(0,n.jsx)(o.Provider,{value:l,children:c})}function c(){return(0,t.useContext)(o)}var l=(0,i.definePrimitive)({name:`search`,options:{value:`string`,onValueChange:`callback`},controlled:[`value`],state:e=>({value:e.value??``}),sync:e=>e.value===void 0?{}:{value:e.value},api:e=>{let t=(0,i.createChange)(e);return{setValue:e=>t(`value`,e,{reason:`imperative`})}},slots:e=>({root:e({})}),agent:{actions:[`setValue`]}}),u=(0,i.definePrimitive)({name:`facet`,options:{value:`value`,items:`value`,onValueChange:`callback`},controlled:[`value`],state:e=>({value:e.value??[],items:e.items??[]}),sync:e=>({...e.value===void 0?{}:{value:e.value},...e.items===void 0?{}:{items:e.items}}),api:e=>{let t=(0,i.createChange)(e),n=e=>t(`value`,e,{reason:`imperative`});return{setValue:e=>n(e),toggle:t=>{let r=e.store.get().value;return n(r.includes(t)?r.filter(e=>e!==t):[...r,t])}}},slots:e=>({root:e({})}),agent:{actions:[`setValue`,`toggle`]}}),d=(0,i.definePrimitive)({name:`range`,options:{value:`value`,bounds:`value`,onValueChange:`callback`},controlled:[`value`],state:e=>({value:e.value??null,bounds:e.bounds??null}),sync:e=>({...e.value===void 0?{}:{value:e.value},...e.bounds===void 0?{}:{bounds:e.bounds}}),api:e=>{let t=(0,i.createChange)(e);return{setValue:e=>t(`value`,e,{reason:`imperative`}),clear:()=>t(`value`,null,{reason:`imperative`})}},slots:e=>({root:e({})}),agent:{actions:[`setValue`,`clear`]}}),f=(0,i.definePrimitive)({name:`sort`,options:{value:`string`,ascending:`boolean`,items:`value`,onValueChange:`callback`,onAscendingChange:`callback`},controlled:[`value`,`ascending`],state:e=>({value:e.value??``,ascending:e.ascending??!0,items:e.items??[]}),sync:e=>({...e.value===void 0?{}:{value:e.value},...e.ascending===void 0?{}:{ascending:e.ascending},...e.items===void 0?{}:{items:e.items}}),api:e=>{let t=(0,i.createChange)(e);return{setValue:e=>t(`value`,e,{reason:`imperative`}),setAscending:e=>t(`ascending`,e,{reason:`imperative`})}},slots:e=>({root:e({})}),agent:{actions:[`setValue`,`setAscending`]}}),p=(0,i.definePrimitive)({name:`results`,options:{items:`value`,onPick:`callback`},state:e=>({items:e.items??[],value:null}),sync:e=>e.items===void 0?{}:{items:e.items},api:e=>{let t=(0,i.createChange)(e);return{items:()=>e.store.get().items,pick:n=>(t(`value`,n,{reason:`imperative`}),e.options().onPick?.(n),!0)}},slots:e=>({root:e({})}),agent:{actions:[`pick`],items:e=>e.items()}});function m({label:t=`Search`,children:n}){let r=(0,a.usePrimitive)(l,e.i());return(0,a.usePart)(r,`root`,{},{"aria-label":t,role:`search`,children:n},`div`)}function h({field:t,label:n,children:r}){let{value:i,items:o,onValueChange:s}=e.t(t),c=(0,a.usePrimitive)(u,{value:i,items:o.map(({value:e,label:t})=>({value:e,label:t})),onValueChange:s});return(0,a.usePart)(c,`root`,{},{"aria-label":n,role:`group`,children:r},`div`)}function g({field:t,label:n,children:r}){let i=(0,a.usePrimitive)(d,e.n(t));return(0,a.usePart)(i,`root`,{},{"aria-label":n,role:`group`,children:r},`div`)}function _({label:t=`Sort by`,children:n}){let{value:r,ascending:i,items:o,onValueChange:s,onAscendingChange:c}=e.a(),l=(0,a.usePrimitive)(f,{value:r,ascending:i,items:o,onValueChange:s,onAscendingChange:c});return(0,a.usePart)(l,`root`,{},{"aria-label":t,children:n},`div`)}function v({label:t=`Results`,title:n,children:r}){let{items:i,pick:o}=e.r(n),s=(0,a.usePrimitive)(p,{items:i,onPick:o});return(0,a.usePart)(s,`root`,{},{"aria-label":t,children:r},`div`)}exports.AgentFacet=h,exports.AgentRange=g,exports.AgentResults=v,exports.AgentSearchText=m,exports.AgentSort=_,exports.SearchAgent=s,exports.useSearchAgent=c;
@@ -0,0 +1,2 @@
1
+ export * from './agent/index.js'
2
+ export {}
@@ -0,0 +1,199 @@
1
+ import { a as e, c as t, i as n, n as r, r as i, t as a } from "./useBindings-DHMpO4Or.mjs";
2
+ import { createContext as o, useContext as s, useEffect as c, useState as l } from "react";
3
+ import { jsx as u } from "react/jsx-runtime";
4
+ import { createAgent as d, registerTools as f } from "@ui-sdk/core/agent";
5
+ import { createChange as p, definePrimitive as m } from "@ui-sdk/core";
6
+ import { usePart as h, usePrimitive as g } from "@ui-sdk/react/primitive";
7
+ // src/agent/SearchAgent.tsx
8
+ var _ = o(null);
9
+ function v({ allow: e, browser: n, mark: r = !1, children: i }) {
10
+ let [a] = l(() => d(e ? { allow: e } : {})), { setAgentMarking: o } = t();
11
+ c(() => (o?.(r), () => o?.(!1)), [r, o]);
12
+ let s = n?.allow;
13
+ return c(() => {
14
+ if (s) return f(a, { allow: s });
15
+ }, [a, s]), /* @__PURE__ */ u(_.Provider, {
16
+ value: a,
17
+ children: i
18
+ });
19
+ }
20
+ function y() {
21
+ return s(_);
22
+ }
23
+ // src/agent/parts.tsx
24
+ var b = m({
25
+ name: "search",
26
+ options: {
27
+ value: "string",
28
+ onValueChange: "callback"
29
+ },
30
+ controlled: ["value"],
31
+ state: (e) => ({ value: e.value ?? "" }),
32
+ sync: (e) => e.value === void 0 ? {} : { value: e.value },
33
+ api: (e) => {
34
+ let t = p(e);
35
+ return { setValue: (e) => t("value", e, { reason: "imperative" }) };
36
+ },
37
+ slots: (e) => ({ root: e({}) }),
38
+ agent: { actions: ["setValue"] }
39
+ }), x = m({
40
+ name: "facet",
41
+ options: {
42
+ value: "value",
43
+ items: "value",
44
+ onValueChange: "callback"
45
+ },
46
+ controlled: ["value"],
47
+ state: (e) => ({
48
+ value: e.value ?? [],
49
+ items: e.items ?? []
50
+ }),
51
+ sync: (e) => ({
52
+ ...e.value === void 0 ? {} : { value: e.value },
53
+ ...e.items === void 0 ? {} : { items: e.items }
54
+ }),
55
+ api: (e) => {
56
+ let t = p(e), n = (e) => t("value", e, { reason: "imperative" });
57
+ return {
58
+ setValue: (e) => n(e),
59
+ toggle: (t) => {
60
+ let r = e.store.get().value;
61
+ return n(r.includes(t) ? r.filter((e) => e !== t) : [...r, t]);
62
+ }
63
+ };
64
+ },
65
+ slots: (e) => ({ root: e({}) }),
66
+ agent: { actions: ["setValue", "toggle"] }
67
+ }), S = m({
68
+ name: "range",
69
+ options: {
70
+ value: "value",
71
+ bounds: "value",
72
+ onValueChange: "callback"
73
+ },
74
+ controlled: ["value"],
75
+ state: (e) => ({
76
+ value: e.value ?? null,
77
+ bounds: e.bounds ?? null
78
+ }),
79
+ sync: (e) => ({
80
+ ...e.value === void 0 ? {} : { value: e.value },
81
+ ...e.bounds === void 0 ? {} : { bounds: e.bounds }
82
+ }),
83
+ api: (e) => {
84
+ let t = p(e);
85
+ return {
86
+ setValue: (e) => t("value", e, { reason: "imperative" }),
87
+ clear: () => t("value", null, { reason: "imperative" })
88
+ };
89
+ },
90
+ slots: (e) => ({ root: e({}) }),
91
+ agent: { actions: ["setValue", "clear"] }
92
+ }), C = m({
93
+ name: "sort",
94
+ options: {
95
+ value: "string",
96
+ ascending: "boolean",
97
+ items: "value",
98
+ onValueChange: "callback",
99
+ onAscendingChange: "callback"
100
+ },
101
+ controlled: ["value", "ascending"],
102
+ state: (e) => ({
103
+ value: e.value ?? "",
104
+ ascending: e.ascending ?? !0,
105
+ items: e.items ?? []
106
+ }),
107
+ sync: (e) => ({
108
+ ...e.value === void 0 ? {} : { value: e.value },
109
+ ...e.ascending === void 0 ? {} : { ascending: e.ascending },
110
+ ...e.items === void 0 ? {} : { items: e.items }
111
+ }),
112
+ api: (e) => {
113
+ let t = p(e);
114
+ return {
115
+ setValue: (e) => t("value", e, { reason: "imperative" }),
116
+ setAscending: (e) => t("ascending", e, { reason: "imperative" })
117
+ };
118
+ },
119
+ slots: (e) => ({ root: e({}) }),
120
+ agent: { actions: ["setValue", "setAscending"] }
121
+ }), w = m({
122
+ name: "results",
123
+ options: {
124
+ items: "value",
125
+ onPick: "callback"
126
+ },
127
+ state: (e) => ({
128
+ items: e.items ?? [],
129
+ value: null
130
+ }),
131
+ sync: (e) => e.items === void 0 ? {} : { items: e.items },
132
+ api: (e) => {
133
+ let t = p(e);
134
+ return {
135
+ items: () => e.store.get().items,
136
+ pick: (n) => (t("value", n, { reason: "imperative" }), e.options().onPick?.(n), !0)
137
+ };
138
+ },
139
+ slots: (e) => ({ root: e({}) }),
140
+ agent: {
141
+ actions: ["pick"],
142
+ items: (e) => e.items()
143
+ }
144
+ });
145
+ function T({ label: e = "Search", children: t }) {
146
+ let r = g(b, n());
147
+ return h(r, "root", {}, {
148
+ "aria-label": e,
149
+ role: "search",
150
+ children: t
151
+ }, "div");
152
+ }
153
+ function E({ field: e, label: t, children: n }) {
154
+ let { value: r, items: i, onValueChange: o } = a(e), s = g(x, {
155
+ value: r,
156
+ items: i.map(({ value: e, label: t }) => ({
157
+ value: e,
158
+ label: t
159
+ })),
160
+ onValueChange: o
161
+ });
162
+ return h(s, "root", {}, {
163
+ "aria-label": t,
164
+ role: "group",
165
+ children: n
166
+ }, "div");
167
+ }
168
+ function D({ field: e, label: t, children: n }) {
169
+ let i = g(S, r(e));
170
+ return h(i, "root", {}, {
171
+ "aria-label": t,
172
+ role: "group",
173
+ children: n
174
+ }, "div");
175
+ }
176
+ function O({ label: t = "Sort by", children: n }) {
177
+ let { value: r, ascending: i, items: a, onValueChange: o, onAscendingChange: s } = e(), c = g(C, {
178
+ value: r,
179
+ ascending: i,
180
+ items: a,
181
+ onValueChange: o,
182
+ onAscendingChange: s
183
+ });
184
+ return h(c, "root", {}, {
185
+ "aria-label": t,
186
+ children: n
187
+ }, "div");
188
+ }
189
+ function k({ label: e = "Results", title: t, children: n }) {
190
+ let { items: r, pick: a } = i(t), o = g(w, {
191
+ items: r,
192
+ onPick: a
193
+ });
194
+ return h(o, "root", {}, {
195
+ "aria-label": e,
196
+ children: n
197
+ }, "div");
198
+ }
199
+ export { E as AgentFacet, D as AgentRange, k as AgentResults, T as AgentSearchText, O as AgentSort, v as SearchAgent, y as useSearchAgent };
@@ -0,0 +1,25 @@
1
+ import { default as React } from 'react';
2
+ export interface HierarchicalFilterPanelProps {
3
+ /** The levels from the top, one Filterable and Facetable field each: ['category.lvl0',
4
+ * 'category.lvl1', 'category.lvl2'], or a catalogue's own ['Lev.kat1', 'Lev.kat2', 'Lev.kat3']. */
5
+ fields: string[];
6
+ label?: string;
7
+ /** When a level holds its whole path ("Clothing > Shoes", Algolia's convention), what separates
8
+ * the parts, so the menu shows only the last. Left out, each level holds its own name. */
9
+ separator?: string;
10
+ /** Values listed per level before "Show more". Default 10. */
11
+ limit?: number;
12
+ /** Order within a level: by count (default) or by name. */
13
+ sortBy?: 'count' | 'name';
14
+ showCount?: boolean;
15
+ collapsible?: boolean;
16
+ startCollapsed?: boolean;
17
+ }
18
+ /**
19
+ * A category menu over level fields, as InstantSearch's hierarchicalMenu: the top level listed, the
20
+ * chosen category opened onto its children, and so on down. Choosing a category filters the search
21
+ * to it; choosing it again goes back to its parent. Every level along the path keeps its siblings
22
+ * with their counts (the search counts each chosen level apart), so the visitor can move sideways.
23
+ * (25 Nov 2026)
24
+ */
25
+ export declare const HierarchicalFilterPanel: React.FC<HierarchicalFilterPanelProps>;
@@ -0,0 +1,51 @@
1
+ import { default as React } from 'react';
2
+ /** How the search is arranged: in a Base inside someone else's page, as a page of its own, or as a
3
+ * search box in a site's header. */
4
+ export type SearchLayoutRecipe = 'component' | 'page' | 'micro';
5
+ /** The layout's own words. */
6
+ export interface SearchLayoutLabels {
7
+ filters: string;
8
+ allResults: (query: string) => string;
9
+ }
10
+ export interface SearchLayoutProps {
11
+ /** `component` (default): in a systm Base, the filters column on the right, for a search inside
12
+ * another page. `page`: a page of its own, no background, the filters on the left. `micro`: a
13
+ * search box for a site's header, its results in a panel under it. */
14
+ recipe?: SearchLayoutRecipe;
15
+ /** The search field. Default: intrface's SearchInput, at the micro size in `micro`. */
16
+ field?: React.ReactNode;
17
+ /** The results, e.g. `<SearchResults>…</SearchResults>`; in `micro`, a few of them. */
18
+ results: React.ReactNode;
19
+ /** The filter panels, sort among them as a panel (`<SortByPanel startCollapsed />`). Not in `micro`. */
20
+ filters?: React.ReactNode;
21
+ /** Between the field and the results: the active filters, Search or ask's AskOffer. */
22
+ above?: React.ReactNode;
23
+ /** Beside the field in `component`'s header: a logo, a link. */
24
+ meta?: React.ReactNode;
25
+ /** Over the `page` recipe: the catalogue's name. */
26
+ title?: React.ReactNode;
27
+ /** `micro`: the way to all the results, usually the search page with the query. Without it, no
28
+ * "See all" is offered. */
29
+ onAllResults?: (query: string) => void;
30
+ /** Under this width (px) the filters fold behind a Filters button. Default 800. */
31
+ narrowBelow?: number;
32
+ labels?: Partial<SearchLayoutLabels>;
33
+ className?: string;
34
+ }
35
+ /**
36
+ * A search page put together from intrface's parts, or your own (26 Nov 2026, Anders' guidelines from
37
+ * the mockup /composing-search). One component, three recipes: the same parts and search state,
38
+ * arranged for where the search lives. Each recipe also sets how filter panels and result rows are
39
+ * drawn on its ground (FilterPanelBase's `--filter-panel-*`, SearchResult's `--result-row-*`):
40
+ * cards on a Base, sections between hairlines on a page, tight rows in a header's panel. Every area
41
+ * takes any content, so a part can be swapped for one of your own.
42
+ *
43
+ * ```tsx
44
+ * <SearchProvider ...>
45
+ * <SearchLayout
46
+ * filters={<><ValueFilterPanel field="genres" label="Genres" /><SortByPanel startCollapsed /></>}
47
+ * results={<SearchResults>{film => <h3>{film.title}</h3>}</SearchResults>} />
48
+ * </SearchProvider>
49
+ * ```
50
+ */
51
+ export declare function SearchLayout({ recipe, field, results, filters, above, meta, title, onAllResults, narrowBelow, labels, className, }: SearchLayoutProps): import("react/jsx-runtime").JSX.Element;