@findlane/browser 0.4.1 → 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/react/dialog.d.ts +3 -1
- package/dist/react/dialog.js +11 -11
- package/dist/react/styles.css +6 -0
- package/package.json +1 -1
package/dist/react/dialog.d.ts
CHANGED
|
@@ -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;
|
package/dist/react/dialog.js
CHANGED
|
@@ -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" })] })) }),
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
}
|
package/dist/react/styles.css
CHANGED
|
@@ -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.
|
|
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",
|