@findlane/browser 0.4.0 → 0.4.2

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/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export type SearchRequest = {
13
13
  facetStats?: string[];
14
14
  /** Hits per request: 1–50 (default 20). */
15
15
  limit?: number;
16
- /** Up to 1,000. */
16
+ /** Up to 5,000. */
17
17
  offset?: number;
18
18
  attributesToRetrieve?: string[];
19
19
  /** "page" (default) counts only the returned page when a query matches more; "exact" counts every match. */
@@ -5,7 +5,9 @@ export type SearchDialogProps<T> = Omit<SearchBoxProps<T>, "autoFocus"> & {
5
5
  trigger?: ReactNode;
6
6
  /** Open with ⌘K (Ctrl+K elsewhere) and "/" (default true). */
7
7
  shortcuts?: boolean;
8
+ /** Shown at the bottom of the open dialog, such as keyboard hints or a credit. */
9
+ footer?: ReactNode;
8
10
  };
9
11
  /** A search button that opens a dialog with a search box, as on docs sites; ⌘K and "/" open it too.
10
12
  * The dialog is the browser's own, so focus stays in it and the page behind can't be used. */
11
- export declare function SearchDialog<T = Record<string, unknown>>({ trigger, shortcuts, placeholder, label, action, renderHit, empty, seeAll, className, ...options }: SearchDialogProps<T>): import("react").JSX.Element;
13
+ export declare function SearchDialog<T = Record<string, unknown>>({ trigger, shortcuts, footer, placeholder, label, action, renderHit, empty, seeAll, className, ...options }: SearchDialogProps<T>): import("react").JSX.Element;
@@ -6,7 +6,7 @@ import { useAutocomplete } from "./use-autocomplete.js";
6
6
  const onMac = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
7
7
  /** A search button that opens a dialog with a search box, as on docs sites; ⌘K and "/" open it too.
8
8
  * The dialog is the browser's own, so focus stays in it and the page behind can't be used. */
9
- export function SearchDialog({ trigger, shortcuts = true, placeholder, label = "Search", action, renderHit, empty, seeAll, className, ...options }) {
9
+ export function SearchDialog({ trigger, shortcuts = true, footer, placeholder, label = "Search", action, renderHit, empty, seeAll, className, ...options }) {
10
10
  const dialog = useRef(null);
11
11
  const [open, setOpen] = useState(false);
12
12
  const close = () => dialog.current?.close();
@@ -48,16 +48,16 @@ export function SearchDialog({ trigger, shortcuts = true, placeholder, label = "
48
48
  window.addEventListener("keydown", onKey);
49
49
  return () => window.removeEventListener("keydown", onKey);
50
50
  }, [shortcuts]);
51
- return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: className, "data-findlane-dialog-trigger": "", "aria-haspopup": "dialog", onClick: show, children: trigger ?? (_jsxs(_Fragment, { children: [_jsx("span", { children: label }), shortcuts && _jsx("kbd", { "aria-hidden": "true", children: mac ? "⌘K" : "Ctrl K" })] })) }), _jsx("dialog", { ref: dialog, "data-findlane-dialog": "", "aria-label": label, onClose: () => setOpen(false),
51
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: className, "data-findlane-dialog-trigger": "", "aria-haspopup": "dialog", onClick: show, children: trigger ?? (_jsxs(_Fragment, { children: [_jsx("span", { children: label }), shortcuts && _jsx("kbd", { "aria-hidden": "true", children: mac ? "⌘K" : "Ctrl K" })] })) }), _jsxs("dialog", { ref: dialog, "data-findlane-dialog": "", "aria-label": label, onClose: () => setOpen(false),
52
52
  // A click on the backdrop lands on the dialog itself.
53
53
  onClick: (event) => { if (event.target === event.currentTarget)
54
- close(); }, children: open && (_jsxs("div", { "data-findlane-searchbox": "", "data-open": box.isOpen || undefined, children: [_jsx("form", { role: "search", onSubmit: (event) => event.preventDefault(), children: _jsx("input", { type: "search", placeholder: placeholder, "aria-label": label, autoFocus: true, ...box.getInputProps({
55
- // Escape closes the dialog rather than only the suggestions.
56
- onKeyDown: (event) => {
57
- if (event.key === "Escape") {
58
- event.preventDefault();
59
- close();
60
- }
61
- },
62
- }) }) }), box.isOpen && (_jsx(Suggestions, { box: box, label: label, action: action, renderHit: renderHit, empty: empty, seeAll: seeAll }))] })) })] }));
54
+ close(); }, children: [open && (_jsxs("div", { "data-findlane-searchbox": "", "data-open": box.isOpen || undefined, children: [_jsx("form", { role: "search", onSubmit: (event) => event.preventDefault(), children: _jsx("input", { type: "search", placeholder: placeholder, "aria-label": label, autoFocus: true, ...box.getInputProps({
55
+ // Escape closes the dialog rather than only the suggestions.
56
+ onKeyDown: (event) => {
57
+ if (event.key === "Escape") {
58
+ event.preventDefault();
59
+ close();
60
+ }
61
+ },
62
+ }) }) }), box.isOpen && (_jsx(Suggestions, { box: box, label: label, action: action, renderHit: renderHit, empty: empty, seeAll: seeAll }))] })), open && footer && _jsx("div", { "data-findlane-dialog-footer": "", children: footer })] })] }));
63
63
  }
@@ -114,7 +114,7 @@ export declare function useLoadMore(): {
114
114
  shown: number;
115
115
  total: number;
116
116
  };
117
- /** Numbered pages, from 0. The API returns hits up to the 1,000th offset, so pages stop there. */
117
+ /** Numbered pages, from 0. The API returns hits up to the 5,000th offset, so pages stop there. */
118
118
  export declare function usePagination(): {
119
119
  page: number;
120
120
  pages: number;
@@ -208,7 +208,7 @@ export function useLoadMore() {
208
208
  total: results?.response.total ?? 0,
209
209
  };
210
210
  }
211
- /** Numbered pages, from 0. The API returns hits up to the 1,000th offset, so pages stop there. */
211
+ /** Numbered pages, from 0. The API returns hits up to the 5,000th offset, so pages stop there. */
212
212
  export function usePagination() {
213
213
  const [{ state, results }, store] = useSnapshot();
214
214
  const pageSize = store.settings.pageSize ?? 20;
@@ -33,7 +33,7 @@ export type SearchConfig = {
33
33
  };
34
34
  export declare const emptyState: SearchState;
35
35
  /** The API's largest offset. */
36
- export declare const maxOffset = 1000;
36
+ export declare const maxOffset = 5000;
37
37
  /** The request behind a state. A facet with selections is counted without them
38
38
  * (`disjunctiveFacets`), so its other values stay listed and can be added. */
39
39
  export declare function planSearch(config: SearchConfig, state: SearchState): SearchRequest;
@@ -1,6 +1,6 @@
1
1
  export const emptyState = { q: "", refinements: {}, filters: {}, page: 0 };
2
2
  /** The API's largest offset. */
3
- export const maxOffset = 1000;
3
+ export const maxOffset = 5000;
4
4
  /** The request behind a state. A facet with selections is counted without them
5
5
  * (`disjunctiveFacets`), so its other values stay listed and can be added. */
6
6
  export function planSearch(config, state) {
@@ -125,6 +125,12 @@
125
125
  :where([data-findlane-dialog] > [data-findlane-searchbox]) {
126
126
  padding: 12px;
127
127
  }
128
+ :where([data-findlane-dialog-footer]) {
129
+ padding: 8px 12px;
130
+ color: var(--findlane-muted, color-mix(in srgb, currentColor 60%, transparent));
131
+ font-size: 0.85em;
132
+ border-top: 1px solid var(--findlane-border, color-mix(in srgb, currentColor 10%, transparent));
133
+ }
128
134
  /* In the dialog, suggestions sit under the input instead of floating over the page. */
129
135
  :where([data-findlane-dialog] [data-findlane-panel]) {
130
136
  position: static;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@findlane/browser",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Findlane browser SDK: fast, typo-tolerant public search from the browser with an index's public ID, plus React hooks and components.",
5
5
  "keywords": ["findlane", "search", "full-text search", "typo tolerance", "instant search", "ecommerce search", "browser", "react", "autocomplete"],
6
6
  "license": "MIT",