@etoile-dev/react 0.1.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/LICENSE +21 -0
- package/README.md +361 -0
- package/dist/Search.d.ts +36 -0
- package/dist/Search.js +31 -0
- package/dist/components/SearchIcon.d.ts +22 -0
- package/dist/components/SearchIcon.js +17 -0
- package/dist/components/SearchInput.d.ts +28 -0
- package/dist/components/SearchInput.js +35 -0
- package/dist/components/SearchKbd.d.ts +30 -0
- package/dist/components/SearchKbd.js +24 -0
- package/dist/components/SearchResult.d.ts +30 -0
- package/dist/components/SearchResult.js +39 -0
- package/dist/components/SearchResultThumbnail.d.ts +36 -0
- package/dist/components/SearchResultThumbnail.js +37 -0
- package/dist/components/SearchResults.d.ts +38 -0
- package/dist/components/SearchResults.js +52 -0
- package/dist/components/SearchRoot.d.ts +43 -0
- package/dist/components/SearchRoot.js +84 -0
- package/dist/context/SearchContext.d.ts +51 -0
- package/dist/context/SearchContext.js +36 -0
- package/dist/hooks/useSearch.d.ts +55 -0
- package/dist/hooks/useSearch.js +116 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +12 -0
- package/dist/styles.css +301 -0
- package/dist/types.d.ts +33 -0
- package/dist/types.js +1 -0
- package/package.json +58 -0
package/dist/styles.css
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Étoile React - Default Theme
|
|
3
|
+
* A minimal, elegant theme.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import "@etoile-dev/react/styles.css";
|
|
7
|
+
* <div className="etoile-search">...</div>
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/* CSS Variables */
|
|
11
|
+
.etoile-search {
|
|
12
|
+
--etoile-bg: #ffffff;
|
|
13
|
+
--etoile-bg-subtle: #fafafa;
|
|
14
|
+
--etoile-border: #e4e4e7;
|
|
15
|
+
--etoile-border-hover: #d4d4d8;
|
|
16
|
+
--etoile-text: #09090b;
|
|
17
|
+
--etoile-text-muted: #71717a;
|
|
18
|
+
--etoile-text-placeholder: #a1a1aa;
|
|
19
|
+
--etoile-accent: #18181b;
|
|
20
|
+
--etoile-accent-foreground: #fafafa;
|
|
21
|
+
--etoile-ring: #18181b;
|
|
22
|
+
--etoile-selected: #f4f4f5;
|
|
23
|
+
--etoile-radius: 12px;
|
|
24
|
+
--etoile-radius-sm: 8px;
|
|
25
|
+
--etoile-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
26
|
+
--etoile-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
27
|
+
--etoile-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
28
|
+
|
|
29
|
+
position: relative;
|
|
30
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Dark mode */
|
|
34
|
+
.etoile-search.dark,
|
|
35
|
+
.dark .etoile-search {
|
|
36
|
+
--etoile-bg: #09090b;
|
|
37
|
+
--etoile-bg-subtle: #18181b;
|
|
38
|
+
--etoile-border: #27272a;
|
|
39
|
+
--etoile-border-hover: #3f3f46;
|
|
40
|
+
--etoile-text: #fafafa;
|
|
41
|
+
--etoile-text-muted: #a1a1aa;
|
|
42
|
+
--etoile-text-placeholder: #71717a;
|
|
43
|
+
--etoile-accent: #fafafa;
|
|
44
|
+
--etoile-accent-foreground: #18181b;
|
|
45
|
+
--etoile-ring: #d4d4d8;
|
|
46
|
+
--etoile-selected: #27272a;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* ============================================
|
|
50
|
+
Search Input
|
|
51
|
+
============================================ */
|
|
52
|
+
|
|
53
|
+
.etoile-search input[role="combobox"] {
|
|
54
|
+
width: 100%;
|
|
55
|
+
height: 44px;
|
|
56
|
+
padding: 0 16px;
|
|
57
|
+
background: var(--etoile-bg);
|
|
58
|
+
border: 1px solid var(--etoile-border);
|
|
59
|
+
border-radius: var(--etoile-radius);
|
|
60
|
+
color: var(--etoile-text);
|
|
61
|
+
font-size: 15px;
|
|
62
|
+
font-weight: 450;
|
|
63
|
+
outline: none;
|
|
64
|
+
transition: all var(--etoile-transition);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.etoile-search input[role="combobox"]::placeholder {
|
|
68
|
+
color: var(--etoile-text-placeholder);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.etoile-search input[role="combobox"]:hover {
|
|
72
|
+
border-color: var(--etoile-border-hover);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.etoile-search input[role="combobox"]:focus {
|
|
76
|
+
border-color: var(--etoile-ring);
|
|
77
|
+
box-shadow: 0 0 0 3px rgb(24 24 27 / 0.1);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.dark .etoile-search input[role="combobox"]:focus,
|
|
81
|
+
.etoile-search.dark input[role="combobox"]:focus {
|
|
82
|
+
box-shadow: 0 0 0 3px rgb(212 212 216 / 0.15);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* ============================================
|
|
86
|
+
Search Results Container
|
|
87
|
+
============================================ */
|
|
88
|
+
|
|
89
|
+
.etoile-search [role="listbox"] {
|
|
90
|
+
position: absolute;
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: 4px;
|
|
94
|
+
top: calc(100% + 8px);
|
|
95
|
+
left: 0;
|
|
96
|
+
right: 0;
|
|
97
|
+
z-index: 50;
|
|
98
|
+
max-height: 300px;
|
|
99
|
+
overflow-y: auto;
|
|
100
|
+
padding: 6px;
|
|
101
|
+
background: var(--etoile-bg);
|
|
102
|
+
border: 1px solid var(--etoile-border);
|
|
103
|
+
border-radius: var(--etoile-radius);
|
|
104
|
+
box-shadow: var(--etoile-shadow-lg);
|
|
105
|
+
|
|
106
|
+
/* Smooth entrance animation */
|
|
107
|
+
animation: etoile-fade-in 150ms ease-out;
|
|
108
|
+
|
|
109
|
+
/* Hide scrollbar */
|
|
110
|
+
scrollbar-width: none;
|
|
111
|
+
-ms-overflow-style: none;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.etoile-search [role="listbox"]::-webkit-scrollbar {
|
|
115
|
+
display: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@keyframes etoile-fade-in {
|
|
119
|
+
from {
|
|
120
|
+
opacity: 0;
|
|
121
|
+
transform: translateY(-4px) scale(0.98);
|
|
122
|
+
}
|
|
123
|
+
to {
|
|
124
|
+
opacity: 1;
|
|
125
|
+
transform: translateY(0) scale(1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* ============================================
|
|
130
|
+
Search Result Item
|
|
131
|
+
============================================ */
|
|
132
|
+
|
|
133
|
+
.etoile-search [role="option"] {
|
|
134
|
+
display: flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
gap: 16px;
|
|
137
|
+
padding: 10px 12px;
|
|
138
|
+
border-radius: var(--etoile-radius-sm);
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
outline: none;
|
|
141
|
+
transition: background-color var(--etoile-transition);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.etoile-search [role="option"]:hover,
|
|
145
|
+
.etoile-search [role="option"][data-selected="true"] {
|
|
146
|
+
background: var(--etoile-selected);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.etoile-search [role="option"]:active {
|
|
150
|
+
background: var(--etoile-border);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* ============================================
|
|
154
|
+
Search Result Thumbnail
|
|
155
|
+
============================================ */
|
|
156
|
+
|
|
157
|
+
.etoile-search [role="option"] img {
|
|
158
|
+
width: 40px;
|
|
159
|
+
height: 40px;
|
|
160
|
+
object-fit: cover;
|
|
161
|
+
border-radius: var(--etoile-radius-sm);
|
|
162
|
+
background: var(--etoile-bg-subtle);
|
|
163
|
+
flex-shrink: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* ============================================
|
|
167
|
+
Search Result Content
|
|
168
|
+
============================================ */
|
|
169
|
+
|
|
170
|
+
.etoile-search .etoile-result-content {
|
|
171
|
+
display: flex;
|
|
172
|
+
flex-direction: column;
|
|
173
|
+
gap: 1px;
|
|
174
|
+
flex: 1;
|
|
175
|
+
min-width: 0;
|
|
176
|
+
text-align: left;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.etoile-search .etoile-result-title {
|
|
180
|
+
font-size: 14px;
|
|
181
|
+
font-weight: 500;
|
|
182
|
+
color: var(--etoile-text);
|
|
183
|
+
line-height: 1.3;
|
|
184
|
+
overflow: hidden;
|
|
185
|
+
text-overflow: ellipsis;
|
|
186
|
+
white-space: nowrap;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.etoile-search .etoile-result-subtitle {
|
|
190
|
+
font-size: 13px;
|
|
191
|
+
font-weight: 500;
|
|
192
|
+
color: var(--etoile-text-muted);
|
|
193
|
+
line-height: 1.3;
|
|
194
|
+
overflow: hidden;
|
|
195
|
+
text-overflow: ellipsis;
|
|
196
|
+
white-space: nowrap;
|
|
197
|
+
text-transform: capitalize;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* ============================================
|
|
201
|
+
Empty State
|
|
202
|
+
============================================ */
|
|
203
|
+
|
|
204
|
+
.etoile-search .etoile-empty {
|
|
205
|
+
padding: 24px 16px;
|
|
206
|
+
text-align: center;
|
|
207
|
+
color: var(--etoile-text-muted);
|
|
208
|
+
font-size: 14px;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* ============================================
|
|
212
|
+
Loading State
|
|
213
|
+
============================================ */
|
|
214
|
+
|
|
215
|
+
.etoile-search .etoile-loading {
|
|
216
|
+
display: flex;
|
|
217
|
+
align-items: center;
|
|
218
|
+
justify-content: center;
|
|
219
|
+
padding: 16px;
|
|
220
|
+
color: var(--etoile-text-muted);
|
|
221
|
+
font-size: 14px;
|
|
222
|
+
gap: 8px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.etoile-search .etoile-spinner {
|
|
226
|
+
width: 16px;
|
|
227
|
+
height: 16px;
|
|
228
|
+
border: 2px solid var(--etoile-border);
|
|
229
|
+
border-top-color: var(--etoile-text-muted);
|
|
230
|
+
border-radius: 50%;
|
|
231
|
+
animation: etoile-spin 600ms linear infinite;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@keyframes etoile-spin {
|
|
235
|
+
to {
|
|
236
|
+
transform: rotate(360deg);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* ============================================
|
|
241
|
+
Keyboard Shortcut Badge
|
|
242
|
+
============================================ */
|
|
243
|
+
|
|
244
|
+
.etoile-search .etoile-kbd {
|
|
245
|
+
display: inline-flex;
|
|
246
|
+
align-items: center;
|
|
247
|
+
justify-content: center;
|
|
248
|
+
height: 20px;
|
|
249
|
+
padding: 0 4px;
|
|
250
|
+
background: var(--etoile-bg-subtle);
|
|
251
|
+
border: 1px solid var(--etoile-border);
|
|
252
|
+
border-radius: 6px;
|
|
253
|
+
color: var(--etoile-text-placeholder);
|
|
254
|
+
font-size: 11px;
|
|
255
|
+
font-family: inherit;
|
|
256
|
+
pointer-events: none;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* ============================================
|
|
260
|
+
Utility: Input with Icon
|
|
261
|
+
============================================ */
|
|
262
|
+
|
|
263
|
+
.etoile-search .etoile-input-wrapper {
|
|
264
|
+
position: relative;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.etoile-search .etoile-input-wrapper svg {
|
|
268
|
+
position: absolute;
|
|
269
|
+
top: 50%;
|
|
270
|
+
left: 14px;
|
|
271
|
+
transform: translateY(-50%);
|
|
272
|
+
width: 18px;
|
|
273
|
+
height: 18px;
|
|
274
|
+
color: var(--etoile-text-muted);
|
|
275
|
+
pointer-events: none;
|
|
276
|
+
transition: color var(--etoile-transition);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.etoile-search .etoile-input-wrapper:focus-within svg {
|
|
280
|
+
color: var(--etoile-text);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.etoile-search .etoile-input-wrapper input[role="combobox"] {
|
|
284
|
+
padding-left: 42px;
|
|
285
|
+
padding-right: 48px;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.etoile-search .etoile-input-wrapper .etoile-kbd {
|
|
289
|
+
position: absolute;
|
|
290
|
+
top: 50%;
|
|
291
|
+
right: 10px;
|
|
292
|
+
transform: translateY(-50%);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* ============================================
|
|
296
|
+
Utility: Input without Icon (just kbd)
|
|
297
|
+
============================================ */
|
|
298
|
+
|
|
299
|
+
.etoile-search .etoile-input-wrapper:not(:has(svg)) input[role="combobox"] {
|
|
300
|
+
padding-left: 16px;
|
|
301
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search result data returned from Étoile API.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const result: SearchResultData = {
|
|
7
|
+
* external_id: "starry-night",
|
|
8
|
+
* title: "The Starry Night",
|
|
9
|
+
* collection: "paintings",
|
|
10
|
+
* score: 0.95,
|
|
11
|
+
* content: "A swirling night sky over a village...",
|
|
12
|
+
* metadata: {
|
|
13
|
+
* artist: "Vincent van Gogh",
|
|
14
|
+
* year: 1889,
|
|
15
|
+
* url: "https://example.com/starry-night"
|
|
16
|
+
* }
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export type SearchResultData = {
|
|
21
|
+
/** Unique identifier for the result */
|
|
22
|
+
external_id: string;
|
|
23
|
+
/** Title of the result */
|
|
24
|
+
title: string;
|
|
25
|
+
/** Collection this result belongs to */
|
|
26
|
+
collection: string;
|
|
27
|
+
/** Relevance score (0-1, higher is more relevant) */
|
|
28
|
+
score: number;
|
|
29
|
+
/** Text content of the result */
|
|
30
|
+
content?: string;
|
|
31
|
+
/** Custom metadata attached to the result */
|
|
32
|
+
metadata: Record<string, unknown>;
|
|
33
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@etoile-dev/react",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Official React primitives for Étoile - Headless, composable search components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"etoile",
|
|
7
|
+
"react",
|
|
8
|
+
"search",
|
|
9
|
+
"ai",
|
|
10
|
+
"semantic-search",
|
|
11
|
+
"headless",
|
|
12
|
+
"ui",
|
|
13
|
+
"components",
|
|
14
|
+
"primitives",
|
|
15
|
+
"typescript"
|
|
16
|
+
],
|
|
17
|
+
"author": "Etoile",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"homepage": "https://etoile.dev",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/etoile-dev/etoile-react.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/etoile-dev/etoile-react/issues"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./styles.css": "./dist/styles.css"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc && cp src/styles.css dist/styles.css",
|
|
45
|
+
"clean": "rm -rf dist",
|
|
46
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": ">=18"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@etoile-dev/client": "^0.1.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/react": "^18.0.0",
|
|
56
|
+
"typescript": "^5.0.0"
|
|
57
|
+
}
|
|
58
|
+
}
|