@garagem-ai/site-sdk 0.3.0 → 0.4.1
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/README.md +59 -3
- package/dist/index.d.mts +27 -361
- package/dist/index.d.ts +27 -361
- package/dist/index.js +530 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +493 -46
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +163 -0
- package/dist/react.d.ts +163 -0
- package/dist/react.js +2124 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +2083 -0
- package/dist/react.mjs.map +1 -0
- package/dist/search-engine-D4EZkNrQ.d.mts +468 -0
- package/dist/search-engine-D4EZkNrQ.d.ts +468 -0
- package/package.json +42 -4
- package/src/fetchers.ts +27 -18
- package/src/index.ts +44 -0
- package/src/internal/url.ts +14 -0
- package/src/listing-card-model.ts +90 -0
- package/src/presentation.ts +79 -0
- package/src/react/cn.ts +3 -0
- package/src/react/filter-panel.tsx +248 -0
- package/src/react/icons.tsx +46 -0
- package/src/react/index.ts +26 -0
- package/src/react/listing-card.tsx +86 -0
- package/src/react/search-chrome.tsx +73 -0
- package/src/react/search-page.tsx +465 -0
- package/src/react/search-pagination.tsx +120 -0
- package/src/react/search-query-form.tsx +81 -0
- package/src/react/search.css +717 -0
- package/src/react/styles/index.ts +1 -0
- package/src/react/styles/search-chrome-css.generated.ts +5 -0
- package/src/react/styles/search-chrome-styles.tsx +12 -0
- package/src/react/types.ts +106 -0
- package/src/react/use-public-search.ts +304 -0
- package/src/search-engine.ts +483 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { FormEvent, ReactElement, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
import { SearchClearIcon, SearchLensIcon } from "./icons";
|
|
6
|
+
|
|
7
|
+
export type SearchQueryFormProps = {
|
|
8
|
+
value: string;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
onSubmit: () => void;
|
|
11
|
+
onClear: () => void;
|
|
12
|
+
className?: string;
|
|
13
|
+
iconClassName?: string;
|
|
14
|
+
searchIcon?: ReactNode;
|
|
15
|
+
clearIcon?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function SearchQueryForm({
|
|
19
|
+
value,
|
|
20
|
+
onChange,
|
|
21
|
+
onSubmit,
|
|
22
|
+
onClear,
|
|
23
|
+
className,
|
|
24
|
+
iconClassName,
|
|
25
|
+
searchIcon,
|
|
26
|
+
clearIcon,
|
|
27
|
+
}: SearchQueryFormProps): ReactElement {
|
|
28
|
+
function handleSubmit(event: FormEvent) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
onSubmit();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<form
|
|
35
|
+
role="search"
|
|
36
|
+
data-slot="search-query"
|
|
37
|
+
onSubmit={handleSubmit}
|
|
38
|
+
className={className}
|
|
39
|
+
>
|
|
40
|
+
<label htmlFor="garagem-search-q" data-slot="search-label">
|
|
41
|
+
Busca
|
|
42
|
+
</label>
|
|
43
|
+
<div data-slot="search-query-field">
|
|
44
|
+
<input
|
|
45
|
+
id="garagem-search-q"
|
|
46
|
+
name="q"
|
|
47
|
+
type="text"
|
|
48
|
+
inputMode="search"
|
|
49
|
+
autoComplete="off"
|
|
50
|
+
enterKeyHint="search"
|
|
51
|
+
value={value}
|
|
52
|
+
onChange={(event) => onChange(event.target.value)}
|
|
53
|
+
placeholder="Busque por bairro, rua ou código"
|
|
54
|
+
data-slot="search-query-input"
|
|
55
|
+
/>
|
|
56
|
+
<div data-slot="search-query-actions">
|
|
57
|
+
{value ? (
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
title="Limpar busca"
|
|
61
|
+
aria-label="Limpar busca"
|
|
62
|
+
onClick={onClear}
|
|
63
|
+
data-slot="search-icon-button"
|
|
64
|
+
data-kind="clear"
|
|
65
|
+
>
|
|
66
|
+
{clearIcon ?? <SearchClearIcon className={iconClassName} />}
|
|
67
|
+
</button>
|
|
68
|
+
) : null}
|
|
69
|
+
<button
|
|
70
|
+
type="submit"
|
|
71
|
+
title="Buscar"
|
|
72
|
+
aria-label="Buscar"
|
|
73
|
+
data-slot="search-icon-button"
|
|
74
|
+
>
|
|
75
|
+
{searchIcon ?? <SearchLensIcon className={iconClassName} />}
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</form>
|
|
80
|
+
);
|
|
81
|
+
}
|