@smilodon/vue 1.4.6 → 1.4.11
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/COMPLETE-GUIDE.md +1621 -0
- package/README.md +105 -8
- package/dist/index.cjs +122 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +123 -10
- package/dist/index.js.map +1 -1
- package/dist/types/Select.vue.d.ts +42 -1
- package/dist/types/Select.vue.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,1621 @@
|
|
|
1
|
+
# @smilodon/vue - Complete Guide
|
|
2
|
+
|
|
3
|
+
**Production-ready, accessible Select component for Vue 3 applications**
|
|
4
|
+
|
|
5
|
+
This guide provides comprehensive documentation for using Smilodon Select in Vue 3 applications, covering all features, styling options, and advanced use cases.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
1. [Installation & Setup](#installation--setup)
|
|
12
|
+
2. [Nuxt & SSR Setup](#nuxt--ssr-setup)
|
|
13
|
+
3. [Basic Usage](#basic-usage)
|
|
14
|
+
4. [Complete Props Reference](#complete-props-reference)
|
|
15
|
+
5. [Input Formats](#input-formats)
|
|
16
|
+
6. [Single Selection](#single-selection)
|
|
17
|
+
7. [Multi-Selection](#multi-selection)
|
|
18
|
+
8. [Searchable Select](#searchable-select)
|
|
19
|
+
9. [Grouped Options](#grouped-options)
|
|
20
|
+
10. [Disabled States](#disabled-states)
|
|
21
|
+
11. [Event Handling](#event-handling)
|
|
22
|
+
12. [Styling & Theming](#styling--theming)
|
|
23
|
+
13. [Custom Renderers](#custom-renderers)
|
|
24
|
+
14. [Performance Optimization](#performance-optimization)
|
|
25
|
+
15. [TypeScript Integration](#typescript-integration)
|
|
26
|
+
16. [Composition API](#composition-api)
|
|
27
|
+
17. [Accessibility](#accessibility)
|
|
28
|
+
18. [Advanced Patterns](#advanced-patterns)
|
|
29
|
+
19. [Troubleshooting](#troubleshooting)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Installation & Setup
|
|
34
|
+
|
|
35
|
+
### Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @smilodon/vue @smilodon/core
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
or with yarn:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
yarn add @smilodon/vue @smilodon/core
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
or with pnpm:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pnpm add @smilodon/vue @smilodon/core
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Vue Configuration
|
|
54
|
+
|
|
55
|
+
If you see warnings about `enhanced-select` not being recognized, add this to your `vite.config.ts`:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { defineConfig } from 'vite';
|
|
59
|
+
import vue from '@vitejs/plugin-vue';
|
|
60
|
+
|
|
61
|
+
export default defineConfig({
|
|
62
|
+
plugins: [
|
|
63
|
+
vue({
|
|
64
|
+
template: {
|
|
65
|
+
compilerOptions: {
|
|
66
|
+
isCustomElement: (tag) => tag === 'enhanced-select'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Basic Import
|
|
75
|
+
|
|
76
|
+
```vue
|
|
77
|
+
<script setup lang="ts">
|
|
78
|
+
import { Select } from '@smilodon/vue';
|
|
79
|
+
import type { SelectItem } from '@smilodon/core';
|
|
80
|
+
</script>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Nuxt & SSR Setup
|
|
86
|
+
|
|
87
|
+
Vue works directly in Vite and standard SPA projects, but Nuxt requires one extra compiler-level decision: the underlying `enhanced-select` element must be treated as a custom element.
|
|
88
|
+
|
|
89
|
+
### `nuxt.config.ts`
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
export default defineNuxtConfig({
|
|
93
|
+
vue: {
|
|
94
|
+
compilerOptions: {
|
|
95
|
+
isCustomElement: (tag) => tag === 'enhanced-select',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Recommended client component structure
|
|
102
|
+
|
|
103
|
+
```vue
|
|
104
|
+
<script setup lang="ts">
|
|
105
|
+
import { computed, ref } from 'vue'
|
|
106
|
+
import { Select } from '@smilodon/vue'
|
|
107
|
+
|
|
108
|
+
const route = useRoute()
|
|
109
|
+
const value = ref<string | number>('')
|
|
110
|
+
|
|
111
|
+
const items = computed(() => [
|
|
112
|
+
{ value: 'nuxt', label: 'Nuxt' },
|
|
113
|
+
{ value: 'vue', label: 'Vue' },
|
|
114
|
+
{ value: route.name ?? 'current-route', label: 'Current Route Context' },
|
|
115
|
+
])
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<template>
|
|
119
|
+
<Select
|
|
120
|
+
v-model="value"
|
|
121
|
+
:items="items"
|
|
122
|
+
searchable
|
|
123
|
+
clearable
|
|
124
|
+
placeholder="Choose a framework"
|
|
125
|
+
/>
|
|
126
|
+
</template>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Fetching on the server, rendering on the client
|
|
130
|
+
|
|
131
|
+
```vue
|
|
132
|
+
<script setup lang="ts">
|
|
133
|
+
import { Select } from '@smilodon/vue'
|
|
134
|
+
|
|
135
|
+
const { data } = await useFetch('/api/countries')
|
|
136
|
+
const value = ref<string | number>('')
|
|
137
|
+
</script>
|
|
138
|
+
|
|
139
|
+
<template>
|
|
140
|
+
<Select
|
|
141
|
+
v-model="value"
|
|
142
|
+
:items="data ?? []"
|
|
143
|
+
searchable
|
|
144
|
+
placeholder="Choose a country"
|
|
145
|
+
/>
|
|
146
|
+
</template>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Nuxt production checklist
|
|
150
|
+
|
|
151
|
+
1. Register `enhanced-select` as a custom element in the Vue compiler path.
|
|
152
|
+
2. Keep direct DOM access inside `onMounted()`.
|
|
153
|
+
3. Pass plain serializable item arrays from server-side data loaders.
|
|
154
|
+
4. Prefer `virtualized` for large lists and provide `estimatedItemHeight` when option heights are visually stable.
|
|
155
|
+
5. Style the component with CSS variables and `::part()` instead of assuming access to internal markup.
|
|
156
|
+
|
|
157
|
+
### SSR and hydration guidance
|
|
158
|
+
|
|
159
|
+
- Rendering `Select` in a Nuxt page is fine when the compiler is configured correctly.
|
|
160
|
+
- The wrapper waits for the custom element runtime and then syncs props into the element.
|
|
161
|
+
- Avoid mutating element methods during SSR; use refs and imperative methods only after mount.
|
|
162
|
+
- If you provide async search, debounce network requests at the app layer and replace items through the component ref instead of rebuilding the entire page state.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Basic Usage
|
|
167
|
+
|
|
168
|
+
### Minimal Example (Composition API)
|
|
169
|
+
|
|
170
|
+
```vue
|
|
171
|
+
<script setup lang="ts">
|
|
172
|
+
import { ref } from 'vue';
|
|
173
|
+
import { Select } from '@smilodon/vue';
|
|
174
|
+
|
|
175
|
+
const selectedValue = ref<string | number>('');
|
|
176
|
+
const items = ['Apple', 'Banana', 'Cherry'];
|
|
177
|
+
</script>
|
|
178
|
+
|
|
179
|
+
<template>
|
|
180
|
+
<Select
|
|
181
|
+
:items="items"
|
|
182
|
+
v-model="selectedValue"
|
|
183
|
+
placeholder="Select a fruit..."
|
|
184
|
+
/>
|
|
185
|
+
</template>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### With Options API
|
|
189
|
+
|
|
190
|
+
```vue
|
|
191
|
+
<script lang="ts">
|
|
192
|
+
import { defineComponent } from 'vue';
|
|
193
|
+
import { Select } from '@smilodon/vue';
|
|
194
|
+
import type { SelectItem } from '@smilodon/core';
|
|
195
|
+
|
|
196
|
+
export default defineComponent({
|
|
197
|
+
components: { Select },
|
|
198
|
+
data() {
|
|
199
|
+
return {
|
|
200
|
+
selectedValue: '',
|
|
201
|
+
items: [
|
|
202
|
+
{ value: 'apple', label: 'Apple' },
|
|
203
|
+
{ value: 'banana', label: 'Banana' },
|
|
204
|
+
{ value: 'cherry', label: 'Cherry' },
|
|
205
|
+
] as SelectItem[]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
<template>
|
|
212
|
+
<Select
|
|
213
|
+
:items="items"
|
|
214
|
+
v-model="selectedValue"
|
|
215
|
+
placeholder="Select a fruit..."
|
|
216
|
+
/>
|
|
217
|
+
</template>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Complete Props Reference
|
|
223
|
+
|
|
224
|
+
### All Available Props
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
interface SelectProps {
|
|
228
|
+
// Required
|
|
229
|
+
items: SelectItem[] | string[] | number[];
|
|
230
|
+
|
|
231
|
+
// v-model binding
|
|
232
|
+
modelValue?: string | number | (string | number)[];
|
|
233
|
+
|
|
234
|
+
// Behavior
|
|
235
|
+
multiple?: boolean;
|
|
236
|
+
searchable?: boolean;
|
|
237
|
+
disabled?: boolean;
|
|
238
|
+
placeholder?: string;
|
|
239
|
+
|
|
240
|
+
// Display
|
|
241
|
+
maxHeight?: number;
|
|
242
|
+
estimatedItemHeight?: number;
|
|
243
|
+
|
|
244
|
+
// Styling
|
|
245
|
+
class?: string;
|
|
246
|
+
style?: Record<string, string | number>;
|
|
247
|
+
|
|
248
|
+
// Advanced
|
|
249
|
+
virtualization?: boolean;
|
|
250
|
+
customRenderer?: (item: SelectItem, index: number) => VNode;
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Props Details
|
|
255
|
+
|
|
256
|
+
| Prop | Type | Default | Description |
|
|
257
|
+
|------|------|---------|-------------|
|
|
258
|
+
| `items` | `SelectItem[] \| string[] \| number[]` | **Required** | Array of items to display |
|
|
259
|
+
| `modelValue` (`v-model`) | `string \| number \| array` | `undefined` | Current selected value(s) |
|
|
260
|
+
| `multiple` | `boolean` | `false` | Enable multi-selection |
|
|
261
|
+
| `searchable` | `boolean` | `true` | Enable search functionality |
|
|
262
|
+
| `disabled` | `boolean` | `false` | Disable the select |
|
|
263
|
+
| `placeholder` | `string` | `'Select...'` | Placeholder text |
|
|
264
|
+
| `maxHeight` | `number` | `300` | Max dropdown height (px) |
|
|
265
|
+
| `estimatedItemHeight` | `number` | `48` | Estimated item height for virtualization |
|
|
266
|
+
| `class` | `string` | `undefined` | CSS class name |
|
|
267
|
+
| `style` | `object` | `undefined` | Inline styles (CSS variables) |
|
|
268
|
+
| `virtualization` | `boolean` | `true` | Enable virtual scrolling |
|
|
269
|
+
| `customRenderer` | `function` | `undefined` | Custom option renderer |
|
|
270
|
+
|
|
271
|
+
### Events
|
|
272
|
+
|
|
273
|
+
| Event | Payload | Description |
|
|
274
|
+
|-------|---------|-------------|
|
|
275
|
+
| `update:modelValue` | `string \| number \| array` | Emitted when value changes |
|
|
276
|
+
| `open` | - | Emitted when dropdown opens |
|
|
277
|
+
| `close` | - | Emitted when dropdown closes |
|
|
278
|
+
| `search` | `query: string` | Emitted on search input |
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Input Formats
|
|
283
|
+
|
|
284
|
+
Smilodon accepts three input formats for maximum flexibility:
|
|
285
|
+
|
|
286
|
+
### 1. Object Array (SelectItem[])
|
|
287
|
+
|
|
288
|
+
```vue
|
|
289
|
+
<script setup lang="ts">
|
|
290
|
+
import { ref } from 'vue';
|
|
291
|
+
import { Select } from '@smilodon/vue';
|
|
292
|
+
import type { SelectItem } from '@smilodon/core';
|
|
293
|
+
|
|
294
|
+
const selectedValue = ref<string | number>('');
|
|
295
|
+
|
|
296
|
+
const items: SelectItem[] = [
|
|
297
|
+
{ value: 'us', label: 'United States' },
|
|
298
|
+
{ value: 'ca', label: 'Canada' },
|
|
299
|
+
{ value: 'mx', label: 'Mexico' },
|
|
300
|
+
];
|
|
301
|
+
</script>
|
|
302
|
+
|
|
303
|
+
<template>
|
|
304
|
+
<Select :items="items" v-model="selectedValue" />
|
|
305
|
+
</template>
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### 2. String Array (Auto-converted)
|
|
309
|
+
|
|
310
|
+
```vue
|
|
311
|
+
<script setup lang="ts">
|
|
312
|
+
import { ref } from 'vue';
|
|
313
|
+
import { Select } from '@smilodon/vue';
|
|
314
|
+
|
|
315
|
+
const selectedValue = ref('');
|
|
316
|
+
const items = ['Apple', 'Banana', 'Cherry', 'Date'];
|
|
317
|
+
</script>
|
|
318
|
+
|
|
319
|
+
<template>
|
|
320
|
+
<Select :items="items" v-model="selectedValue" />
|
|
321
|
+
</template>
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Automatically converted to:
|
|
325
|
+
```typescript
|
|
326
|
+
[
|
|
327
|
+
{ value: 'Apple', label: 'Apple' },
|
|
328
|
+
{ value: 'Banana', label: 'Banana' },
|
|
329
|
+
{ value: 'Cherry', label: 'Cherry' },
|
|
330
|
+
{ value: 'Date', label: 'Date' },
|
|
331
|
+
]
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### 3. Number Array (Auto-converted)
|
|
335
|
+
|
|
336
|
+
```vue
|
|
337
|
+
<script setup lang="ts">
|
|
338
|
+
import { ref } from 'vue';
|
|
339
|
+
import { Select } from '@smilodon/vue';
|
|
340
|
+
|
|
341
|
+
const selectedValue = ref<number>(0);
|
|
342
|
+
const items = [1, 2, 3, 5, 8, 13, 21];
|
|
343
|
+
</script>
|
|
344
|
+
|
|
345
|
+
<template>
|
|
346
|
+
<Select :items="items" v-model="selectedValue" />
|
|
347
|
+
</template>
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## Single Selection
|
|
353
|
+
|
|
354
|
+
### Basic Single Select
|
|
355
|
+
|
|
356
|
+
```vue
|
|
357
|
+
<script setup lang="ts">
|
|
358
|
+
import { ref } from 'vue';
|
|
359
|
+
import { Select } from '@smilodon/vue';
|
|
360
|
+
import type { SelectItem } from '@smilodon/core';
|
|
361
|
+
|
|
362
|
+
const country = ref<string | number>('');
|
|
363
|
+
|
|
364
|
+
const countries: SelectItem[] = [
|
|
365
|
+
{ value: 'us', label: 'United States' },
|
|
366
|
+
{ value: 'ca', label: 'Canada' },
|
|
367
|
+
{ value: 'uk', label: 'United Kingdom' },
|
|
368
|
+
{ value: 'au', label: 'Australia' },
|
|
369
|
+
];
|
|
370
|
+
</script>
|
|
371
|
+
|
|
372
|
+
<template>
|
|
373
|
+
<div>
|
|
374
|
+
<Select
|
|
375
|
+
:items="countries"
|
|
376
|
+
v-model="country"
|
|
377
|
+
placeholder="Select your country"
|
|
378
|
+
/>
|
|
379
|
+
|
|
380
|
+
<p v-if="country">Selected: {{ country }}</p>
|
|
381
|
+
</div>
|
|
382
|
+
</template>
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### With Form Integration
|
|
386
|
+
|
|
387
|
+
```vue
|
|
388
|
+
<script setup lang="ts">
|
|
389
|
+
import { ref, reactive } from 'vue';
|
|
390
|
+
import { Select } from '@smilodon/vue';
|
|
391
|
+
|
|
392
|
+
const formData = reactive({
|
|
393
|
+
name: '',
|
|
394
|
+
country: '',
|
|
395
|
+
language: '',
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
const handleSubmit = () => {
|
|
399
|
+
console.log('Form data:', formData);
|
|
400
|
+
};
|
|
401
|
+
</script>
|
|
402
|
+
|
|
403
|
+
<template>
|
|
404
|
+
<form @submit.prevent="handleSubmit">
|
|
405
|
+
<div>
|
|
406
|
+
<label>Name:</label>
|
|
407
|
+
<input v-model="formData.name" type="text" />
|
|
408
|
+
</div>
|
|
409
|
+
|
|
410
|
+
<div>
|
|
411
|
+
<label>Country:</label>
|
|
412
|
+
<Select
|
|
413
|
+
:items="['USA', 'Canada', 'Mexico', 'UK', 'Australia']"
|
|
414
|
+
v-model="formData.country"
|
|
415
|
+
placeholder="Select country"
|
|
416
|
+
/>
|
|
417
|
+
</div>
|
|
418
|
+
|
|
419
|
+
<div>
|
|
420
|
+
<label>Language:</label>
|
|
421
|
+
<Select
|
|
422
|
+
:items="['English', 'Spanish', 'French', 'German']"
|
|
423
|
+
v-model="formData.language"
|
|
424
|
+
placeholder="Select language"
|
|
425
|
+
/>
|
|
426
|
+
</div>
|
|
427
|
+
|
|
428
|
+
<button type="submit">Submit</button>
|
|
429
|
+
</form>
|
|
430
|
+
</template>
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Multi-Selection
|
|
436
|
+
|
|
437
|
+
### Basic Multi-Select
|
|
438
|
+
|
|
439
|
+
```vue
|
|
440
|
+
<script setup lang="ts">
|
|
441
|
+
import { ref } from 'vue';
|
|
442
|
+
import { Select } from '@smilodon/vue';
|
|
443
|
+
import type { SelectItem } from '@smilodon/core';
|
|
444
|
+
|
|
445
|
+
const languages = ref<(string | number)[]>([]);
|
|
446
|
+
|
|
447
|
+
const items: SelectItem[] = [
|
|
448
|
+
{ value: 'js', label: 'JavaScript' },
|
|
449
|
+
{ value: 'ts', label: 'TypeScript' },
|
|
450
|
+
{ value: 'py', label: 'Python' },
|
|
451
|
+
{ value: 'rs', label: 'Rust' },
|
|
452
|
+
{ value: 'go', label: 'Go' },
|
|
453
|
+
];
|
|
454
|
+
</script>
|
|
455
|
+
|
|
456
|
+
<template>
|
|
457
|
+
<div>
|
|
458
|
+
<Select
|
|
459
|
+
:items="items"
|
|
460
|
+
v-model="languages"
|
|
461
|
+
multiple
|
|
462
|
+
placeholder="Select programming languages"
|
|
463
|
+
/>
|
|
464
|
+
|
|
465
|
+
<div v-if="languages.length > 0">
|
|
466
|
+
<strong>Selected ({{ languages.length }}):</strong>
|
|
467
|
+
<ul>
|
|
468
|
+
<li v-for="lang in languages" :key="lang">{{ lang }}</li>
|
|
469
|
+
</ul>
|
|
470
|
+
</div>
|
|
471
|
+
<p v-else>No languages selected</p>
|
|
472
|
+
</div>
|
|
473
|
+
</template>
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Multi-Select with Limit
|
|
477
|
+
|
|
478
|
+
```vue
|
|
479
|
+
<script setup lang="ts">
|
|
480
|
+
import { ref, watch } from 'vue';
|
|
481
|
+
import { Select } from '@smilodon/vue';
|
|
482
|
+
|
|
483
|
+
const selected = ref<(string | number)[]>([]);
|
|
484
|
+
const maxSelections = 3;
|
|
485
|
+
|
|
486
|
+
watch(selected, (newValue) => {
|
|
487
|
+
if (newValue.length > maxSelections) {
|
|
488
|
+
selected.value = newValue.slice(0, maxSelections);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
</script>
|
|
492
|
+
|
|
493
|
+
<template>
|
|
494
|
+
<div>
|
|
495
|
+
<Select
|
|
496
|
+
:items="['Red', 'Blue', 'Green', 'Yellow', 'Purple', 'Orange']"
|
|
497
|
+
v-model="selected"
|
|
498
|
+
multiple
|
|
499
|
+
:placeholder="`Select up to ${maxSelections} colors`"
|
|
500
|
+
/>
|
|
501
|
+
<p>{{ selected.length }} / {{ maxSelections }} selected</p>
|
|
502
|
+
</div>
|
|
503
|
+
</template>
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## Searchable Select
|
|
509
|
+
|
|
510
|
+
### Basic Search
|
|
511
|
+
|
|
512
|
+
```vue
|
|
513
|
+
<script setup lang="ts">
|
|
514
|
+
import { ref } from 'vue';
|
|
515
|
+
import { Select } from '@smilodon/vue';
|
|
516
|
+
import type { SelectItem } from '@smilodon/core';
|
|
517
|
+
|
|
518
|
+
const country = ref<string | number>('');
|
|
519
|
+
|
|
520
|
+
// Large dataset
|
|
521
|
+
const countries: SelectItem[] = [
|
|
522
|
+
{ value: 'us', label: 'United States' },
|
|
523
|
+
{ value: 'ca', label: 'Canada' },
|
|
524
|
+
{ value: 'mx', label: 'Mexico' },
|
|
525
|
+
{ value: 'br', label: 'Brazil' },
|
|
526
|
+
{ value: 'ar', label: 'Argentina' },
|
|
527
|
+
// ... 200+ countries
|
|
528
|
+
];
|
|
529
|
+
</script>
|
|
530
|
+
|
|
531
|
+
<template>
|
|
532
|
+
<Select
|
|
533
|
+
:items="countries"
|
|
534
|
+
v-model="country"
|
|
535
|
+
searchable
|
|
536
|
+
placeholder="Search for a country..."
|
|
537
|
+
/>
|
|
538
|
+
</template>
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
### Search with Event Handler
|
|
542
|
+
|
|
543
|
+
```vue
|
|
544
|
+
<script setup lang="ts">
|
|
545
|
+
import { ref } from 'vue';
|
|
546
|
+
import { Select } from '@smilodon/vue';
|
|
547
|
+
|
|
548
|
+
const value = ref('');
|
|
549
|
+
const searchQuery = ref('');
|
|
550
|
+
|
|
551
|
+
const handleSearch = (query: string) => {
|
|
552
|
+
searchQuery.value = query;
|
|
553
|
+
console.log('Searching for:', query);
|
|
554
|
+
// Optionally trigger API call, analytics, etc.
|
|
555
|
+
};
|
|
556
|
+
</script>
|
|
557
|
+
|
|
558
|
+
<template>
|
|
559
|
+
<div>
|
|
560
|
+
<Select
|
|
561
|
+
:items="['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry']"
|
|
562
|
+
v-model="value"
|
|
563
|
+
searchable
|
|
564
|
+
@search="handleSearch"
|
|
565
|
+
placeholder="Type to search..."
|
|
566
|
+
/>
|
|
567
|
+
<p v-if="searchQuery">Current search: {{ searchQuery }}</p>
|
|
568
|
+
</div>
|
|
569
|
+
</template>
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
---
|
|
573
|
+
|
|
574
|
+
## Grouped Options
|
|
575
|
+
|
|
576
|
+
### Basic Groups
|
|
577
|
+
|
|
578
|
+
```vue
|
|
579
|
+
<script setup lang="ts">
|
|
580
|
+
import { ref } from 'vue';
|
|
581
|
+
import { Select } from '@smilodon/vue';
|
|
582
|
+
import type { SelectItem } from '@smilodon/core';
|
|
583
|
+
|
|
584
|
+
const value = ref<string | number>('');
|
|
585
|
+
|
|
586
|
+
const items: SelectItem[] = [
|
|
587
|
+
// Fruits group
|
|
588
|
+
{ value: 'apple', label: 'Apple', group: 'Fruits' },
|
|
589
|
+
{ value: 'banana', label: 'Banana', group: 'Fruits' },
|
|
590
|
+
{ value: 'cherry', label: 'Cherry', group: 'Fruits' },
|
|
591
|
+
|
|
592
|
+
// Vegetables group
|
|
593
|
+
{ value: 'carrot', label: 'Carrot', group: 'Vegetables' },
|
|
594
|
+
{ value: 'broccoli', label: 'Broccoli', group: 'Vegetables' },
|
|
595
|
+
{ value: 'spinach', label: 'Spinach', group: 'Vegetables' },
|
|
596
|
+
];
|
|
597
|
+
</script>
|
|
598
|
+
|
|
599
|
+
<template>
|
|
600
|
+
<Select
|
|
601
|
+
:items="items"
|
|
602
|
+
v-model="value"
|
|
603
|
+
placeholder="Select food..."
|
|
604
|
+
/>
|
|
605
|
+
</template>
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### Complex Grouped Structure
|
|
609
|
+
|
|
610
|
+
```vue
|
|
611
|
+
<script setup lang="ts">
|
|
612
|
+
import { ref, computed } from 'vue';
|
|
613
|
+
import { Select } from '@smilodon/vue';
|
|
614
|
+
import type { SelectItem } from '@smilodon/core';
|
|
615
|
+
|
|
616
|
+
const value = ref<string | number>('');
|
|
617
|
+
|
|
618
|
+
const technologies = computed<SelectItem[]>(() => [
|
|
619
|
+
// Frontend
|
|
620
|
+
{ value: 'react', label: 'React', group: 'Frontend' },
|
|
621
|
+
{ value: 'vue', label: 'Vue.js', group: 'Frontend' },
|
|
622
|
+
{ value: 'svelte', label: 'Svelte', group: 'Frontend' },
|
|
623
|
+
|
|
624
|
+
// Backend
|
|
625
|
+
{ value: 'node', label: 'Node.js', group: 'Backend' },
|
|
626
|
+
{ value: 'django', label: 'Django', group: 'Backend' },
|
|
627
|
+
{ value: 'rails', label: 'Ruby on Rails', group: 'Backend' },
|
|
628
|
+
|
|
629
|
+
// Database
|
|
630
|
+
{ value: 'postgres', label: 'PostgreSQL', group: 'Database' },
|
|
631
|
+
{ value: 'mongo', label: 'MongoDB', group: 'Database' },
|
|
632
|
+
{ value: 'redis', label: 'Redis', group: 'Database' },
|
|
633
|
+
]);
|
|
634
|
+
</script>
|
|
635
|
+
|
|
636
|
+
<template>
|
|
637
|
+
<Select
|
|
638
|
+
:items="technologies"
|
|
639
|
+
v-model="value"
|
|
640
|
+
searchable
|
|
641
|
+
placeholder="Select technology..."
|
|
642
|
+
/>
|
|
643
|
+
</template>
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
---
|
|
647
|
+
|
|
648
|
+
## Disabled States
|
|
649
|
+
|
|
650
|
+
### Disabled Select
|
|
651
|
+
|
|
652
|
+
```vue
|
|
653
|
+
<script setup lang="ts">
|
|
654
|
+
import { ref } from 'vue';
|
|
655
|
+
import { Select } from '@smilodon/vue';
|
|
656
|
+
|
|
657
|
+
const value = ref('');
|
|
658
|
+
</script>
|
|
659
|
+
|
|
660
|
+
<template>
|
|
661
|
+
<Select
|
|
662
|
+
:items="['Option 1', 'Option 2', 'Option 3']"
|
|
663
|
+
v-model="value"
|
|
664
|
+
disabled
|
|
665
|
+
placeholder="This select is disabled"
|
|
666
|
+
/>
|
|
667
|
+
</template>
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### Disabled Options
|
|
671
|
+
|
|
672
|
+
```vue
|
|
673
|
+
<script setup lang="ts">
|
|
674
|
+
import { ref } from 'vue';
|
|
675
|
+
import { Select } from '@smilodon/vue';
|
|
676
|
+
import type { SelectItem } from '@smilodon/core';
|
|
677
|
+
|
|
678
|
+
const value = ref<string | number>('');
|
|
679
|
+
|
|
680
|
+
const items: SelectItem[] = [
|
|
681
|
+
{ value: '1', label: 'Available Option 1' },
|
|
682
|
+
{ value: '2', label: 'Available Option 2' },
|
|
683
|
+
{ value: '3', label: 'Disabled Option', disabled: true },
|
|
684
|
+
{ value: '4', label: 'Available Option 3' },
|
|
685
|
+
{ value: '5', label: 'Disabled Option 2', disabled: true },
|
|
686
|
+
];
|
|
687
|
+
</script>
|
|
688
|
+
|
|
689
|
+
<template>
|
|
690
|
+
<Select
|
|
691
|
+
:items="items"
|
|
692
|
+
v-model="value"
|
|
693
|
+
placeholder="Some options are disabled"
|
|
694
|
+
/>
|
|
695
|
+
</template>
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
### Conditional Disabling
|
|
699
|
+
|
|
700
|
+
```vue
|
|
701
|
+
<script setup lang="ts">
|
|
702
|
+
import { ref } from 'vue';
|
|
703
|
+
import { Select } from '@smilodon/vue';
|
|
704
|
+
|
|
705
|
+
const value = ref('');
|
|
706
|
+
const isLoading = ref(false);
|
|
707
|
+
|
|
708
|
+
const handleChange = async () => {
|
|
709
|
+
isLoading.value = true;
|
|
710
|
+
// Simulate API call
|
|
711
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
712
|
+
isLoading.value = false;
|
|
713
|
+
};
|
|
714
|
+
</script>
|
|
715
|
+
|
|
716
|
+
<template>
|
|
717
|
+
<div>
|
|
718
|
+
<Select
|
|
719
|
+
:items="['Option 1', 'Option 2', 'Option 3']"
|
|
720
|
+
v-model="value"
|
|
721
|
+
:disabled="isLoading"
|
|
722
|
+
:placeholder="isLoading ? 'Loading...' : 'Select an option'"
|
|
723
|
+
@update:modelValue="handleChange"
|
|
724
|
+
/>
|
|
725
|
+
<p v-if="isLoading">Processing selection...</p>
|
|
726
|
+
</div>
|
|
727
|
+
</template>
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
---
|
|
731
|
+
|
|
732
|
+
## Event Handling
|
|
733
|
+
|
|
734
|
+
### All Events
|
|
735
|
+
|
|
736
|
+
```vue
|
|
737
|
+
<script setup lang="ts">
|
|
738
|
+
import { ref } from 'vue';
|
|
739
|
+
import { Select } from '@smilodon/vue';
|
|
740
|
+
|
|
741
|
+
const value = ref('');
|
|
742
|
+
const isOpen = ref(false);
|
|
743
|
+
const logs = ref<string[]>([]);
|
|
744
|
+
|
|
745
|
+
const addLog = (message: string) => {
|
|
746
|
+
const timestamp = new Date().toLocaleTimeString();
|
|
747
|
+
logs.value.push(`[${timestamp}] ${message}`);
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
const handleChange = (val: string | number | (string | number)[]) => {
|
|
751
|
+
addLog(`Changed to: ${val}`);
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
const handleOpen = () => {
|
|
755
|
+
isOpen.value = true;
|
|
756
|
+
addLog('Dropdown opened');
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
const handleClose = () => {
|
|
760
|
+
isOpen.value = false;
|
|
761
|
+
addLog('Dropdown closed');
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
const handleSearch = (query: string) => {
|
|
765
|
+
addLog(`Searching for: ${query}`);
|
|
766
|
+
};
|
|
767
|
+
</script>
|
|
768
|
+
|
|
769
|
+
<template>
|
|
770
|
+
<div>
|
|
771
|
+
<Select
|
|
772
|
+
:items="['Apple', 'Banana', 'Cherry']"
|
|
773
|
+
v-model="value"
|
|
774
|
+
@update:modelValue="handleChange"
|
|
775
|
+
@open="handleOpen"
|
|
776
|
+
@close="handleClose"
|
|
777
|
+
@search="handleSearch"
|
|
778
|
+
placeholder="Select a fruit"
|
|
779
|
+
/>
|
|
780
|
+
|
|
781
|
+
<div>
|
|
782
|
+
<p>Current value: {{ value || 'None' }}</p>
|
|
783
|
+
<p>Dropdown is: {{ isOpen ? 'Open' : 'Closed' }}</p>
|
|
784
|
+
</div>
|
|
785
|
+
|
|
786
|
+
<div>
|
|
787
|
+
<strong>Event Log:</strong>
|
|
788
|
+
<ul style="max-height: 200px; overflow: auto;">
|
|
789
|
+
<li v-for="(log, i) in logs" :key="i">{{ log }}</li>
|
|
790
|
+
</ul>
|
|
791
|
+
</div>
|
|
792
|
+
</div>
|
|
793
|
+
</template>
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
---
|
|
797
|
+
|
|
798
|
+
## Styling & Theming
|
|
799
|
+
|
|
800
|
+
### Inline Styles with CSS Variables
|
|
801
|
+
|
|
802
|
+
```vue
|
|
803
|
+
<script setup lang="ts">
|
|
804
|
+
import { ref } from 'vue';
|
|
805
|
+
import { Select } from '@smilodon/vue';
|
|
806
|
+
|
|
807
|
+
const value = ref('');
|
|
808
|
+
|
|
809
|
+
const customStyles = {
|
|
810
|
+
'--select-input-border': '2px solid #3b82f6',
|
|
811
|
+
'--select-input-border-radius': '8px',
|
|
812
|
+
'--select-input-focus-border': '#2563eb',
|
|
813
|
+
'--select-option-hover-bg': '#dbeafe',
|
|
814
|
+
'--select-option-selected-bg': '#3b82f6',
|
|
815
|
+
'--select-option-selected-color': 'white',
|
|
816
|
+
'--select-badge-bg': '#3b82f6',
|
|
817
|
+
};
|
|
818
|
+
</script>
|
|
819
|
+
|
|
820
|
+
<template>
|
|
821
|
+
<Select
|
|
822
|
+
:items="['Red', 'Blue', 'Green']"
|
|
823
|
+
v-model="value"
|
|
824
|
+
:style="customStyles"
|
|
825
|
+
/>
|
|
826
|
+
</template>
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
### Complete CSS Variables Reference
|
|
830
|
+
|
|
831
|
+
```vue
|
|
832
|
+
<script setup lang="ts">
|
|
833
|
+
import { ref } from 'vue';
|
|
834
|
+
import { Select } from '@smilodon/vue';
|
|
835
|
+
|
|
836
|
+
const value = ref('');
|
|
837
|
+
|
|
838
|
+
const allStyles = {
|
|
839
|
+
// Input Container
|
|
840
|
+
'--select-input-gap': '6px',
|
|
841
|
+
'--select-input-padding': '6px 52px 6px 8px',
|
|
842
|
+
'--select-input-min-height': '44px',
|
|
843
|
+
'--select-input-bg': 'white',
|
|
844
|
+
'--select-input-border': '1px solid #d1d5db',
|
|
845
|
+
'--select-input-border-radius': '6px',
|
|
846
|
+
'--select-input-focus-border': '#667eea',
|
|
847
|
+
'--select-input-focus-shadow': '0 0 0 3px rgba(102, 126, 234, 0.1)',
|
|
848
|
+
|
|
849
|
+
// Input Field
|
|
850
|
+
'--select-input-min-width': '120px',
|
|
851
|
+
'--select-input-field-padding': '4px',
|
|
852
|
+
'--select-input-font-size': '14px',
|
|
853
|
+
'--select-input-line-height': '1.5',
|
|
854
|
+
'--select-input-color': '#1f2937',
|
|
855
|
+
'--select-input-placeholder-color': '#9ca3af',
|
|
856
|
+
'--select-font-family': 'inherit',
|
|
857
|
+
|
|
858
|
+
// Dropdown Arrow
|
|
859
|
+
'--select-arrow-width': '40px',
|
|
860
|
+
'--select-arrow-size': '16px',
|
|
861
|
+
'--select-arrow-color': '#667eea',
|
|
862
|
+
'--select-arrow-hover-color': '#667eea',
|
|
863
|
+
'--select-arrow-hover-bg': 'rgba(102, 126, 234, 0.08)',
|
|
864
|
+
'--select-arrow-border-radius': '0 4px 4px 0',
|
|
865
|
+
|
|
866
|
+
// Separator Line
|
|
867
|
+
'--select-separator-position': '40px',
|
|
868
|
+
'--select-separator-width': '1px',
|
|
869
|
+
'--select-separator-height': '60%',
|
|
870
|
+
'--select-separator-gradient': 'linear-gradient(to bottom, transparent, #ccc, transparent)',
|
|
871
|
+
|
|
872
|
+
// Selection Badges (Multi-select)
|
|
873
|
+
'--select-badge-gap': '4px',
|
|
874
|
+
'--select-badge-padding': '4px 8px',
|
|
875
|
+
'--select-badge-margin': '2px',
|
|
876
|
+
'--select-badge-bg': '#667eea',
|
|
877
|
+
'--select-badge-color': 'white',
|
|
878
|
+
'--select-badge-border-radius': '4px',
|
|
879
|
+
'--select-badge-font-size': '13px',
|
|
880
|
+
|
|
881
|
+
// Badge Remove Button
|
|
882
|
+
'--select-badge-remove-size': '16px',
|
|
883
|
+
'--select-badge-remove-bg': 'rgba(255, 255, 255, 0.3)',
|
|
884
|
+
'--select-badge-remove-color': 'white',
|
|
885
|
+
'--select-badge-remove-font-size': '16px',
|
|
886
|
+
'--select-badge-remove-hover-bg': 'rgba(255, 255, 255, 0.5)',
|
|
887
|
+
|
|
888
|
+
// Dropdown
|
|
889
|
+
'--select-dropdown-margin-top': '4px',
|
|
890
|
+
'--select-dropdown-max-height': '300px',
|
|
891
|
+
'--select-dropdown-border-radius': '4px',
|
|
892
|
+
'--select-dropdown-bg': 'white',
|
|
893
|
+
'--select-dropdown-border': '1px solid #ccc',
|
|
894
|
+
'--select-dropdown-shadow': '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
895
|
+
|
|
896
|
+
// Options
|
|
897
|
+
'--select-options-bg': 'white',
|
|
898
|
+
'--select-option-padding': '8px 12px',
|
|
899
|
+
'--select-option-color': '#1f2937',
|
|
900
|
+
'--select-option-bg': 'white',
|
|
901
|
+
'--select-option-font-size': '14px',
|
|
902
|
+
'--select-option-hover-bg': '#f3f4f6',
|
|
903
|
+
'--select-option-selected-bg': '#e0e7ff',
|
|
904
|
+
'--select-option-selected-color': '#4338ca',
|
|
905
|
+
};
|
|
906
|
+
</script>
|
|
907
|
+
|
|
908
|
+
<template>
|
|
909
|
+
<Select
|
|
910
|
+
:items="['Option 1', 'Option 2', 'Option 3']"
|
|
911
|
+
v-model="value"
|
|
912
|
+
:style="allStyles"
|
|
913
|
+
/>
|
|
914
|
+
</template>
|
|
915
|
+
```
|
|
916
|
+
|
|
917
|
+
### Theme Examples
|
|
918
|
+
|
|
919
|
+
#### Bootstrap Theme
|
|
920
|
+
|
|
921
|
+
```vue
|
|
922
|
+
<script setup lang="ts">
|
|
923
|
+
import { ref } from 'vue';
|
|
924
|
+
import { Select } from '@smilodon/vue';
|
|
925
|
+
|
|
926
|
+
const value = ref('');
|
|
927
|
+
|
|
928
|
+
const bootstrapTheme = {
|
|
929
|
+
'--select-input-border': '1px solid #ced4da',
|
|
930
|
+
'--select-input-border-radius': '0.375rem',
|
|
931
|
+
'--select-input-focus-border': '#86b7fe',
|
|
932
|
+
'--select-input-focus-shadow': '0 0 0 0.25rem rgba(13, 110, 253, 0.25)',
|
|
933
|
+
'--select-option-hover-bg': '#e9ecef',
|
|
934
|
+
'--select-option-selected-bg': '#0d6efd',
|
|
935
|
+
'--select-option-selected-color': 'white',
|
|
936
|
+
'--select-badge-bg': '#0d6efd',
|
|
937
|
+
};
|
|
938
|
+
</script>
|
|
939
|
+
|
|
940
|
+
<template>
|
|
941
|
+
<Select
|
|
942
|
+
:items="['Option 1', 'Option 2', 'Option 3']"
|
|
943
|
+
v-model="value"
|
|
944
|
+
:style="bootstrapTheme"
|
|
945
|
+
/>
|
|
946
|
+
</template>
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
#### Material Design Theme
|
|
950
|
+
|
|
951
|
+
```vue
|
|
952
|
+
<script setup lang="ts">
|
|
953
|
+
import { ref } from 'vue';
|
|
954
|
+
import { Select } from '@smilodon/vue';
|
|
955
|
+
|
|
956
|
+
const value = ref('');
|
|
957
|
+
|
|
958
|
+
const materialTheme = {
|
|
959
|
+
'--select-input-border-radius': '4px',
|
|
960
|
+
'--select-input-focus-border': '#1976d2',
|
|
961
|
+
'--select-dropdown-shadow': '0 2px 4px rgba(0,0,0,0.2), 0 4px 5px rgba(0,0,0,0.14)',
|
|
962
|
+
'--select-option-padding': '16px',
|
|
963
|
+
'--select-option-hover-bg': 'rgba(0, 0, 0, 0.04)',
|
|
964
|
+
'--select-option-selected-bg': '#e3f2fd',
|
|
965
|
+
'--select-option-selected-color': '#1976d2',
|
|
966
|
+
'--select-badge-bg': '#1976d2',
|
|
967
|
+
'--select-badge-border-radius': '16px',
|
|
968
|
+
};
|
|
969
|
+
</script>
|
|
970
|
+
|
|
971
|
+
<template>
|
|
972
|
+
<Select
|
|
973
|
+
:items="['Option 1', 'Option 2', 'Option 3']"
|
|
974
|
+
v-model="value"
|
|
975
|
+
:style="materialTheme"
|
|
976
|
+
/>
|
|
977
|
+
</template>
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
#### Dark Mode Theme
|
|
981
|
+
|
|
982
|
+
```vue
|
|
983
|
+
<script setup lang="ts">
|
|
984
|
+
import { ref } from 'vue';
|
|
985
|
+
import { Select } from '@smilodon/vue';
|
|
986
|
+
|
|
987
|
+
const value = ref('');
|
|
988
|
+
|
|
989
|
+
const darkTheme = {
|
|
990
|
+
'--select-input-bg': '#1f2937',
|
|
991
|
+
'--select-input-border': '1px solid #4b5563',
|
|
992
|
+
'--select-input-color': '#f9fafb',
|
|
993
|
+
'--select-dropdown-bg': '#1f2937',
|
|
994
|
+
'--select-options-bg': '#1f2937',
|
|
995
|
+
'--select-option-color': '#f9fafb',
|
|
996
|
+
'--select-option-bg': '#1f2937',
|
|
997
|
+
'--select-option-hover-bg': '#374151',
|
|
998
|
+
'--select-option-selected-bg': '#3730a3',
|
|
999
|
+
'--select-badge-bg': '#4f46e5',
|
|
1000
|
+
};
|
|
1001
|
+
</script>
|
|
1002
|
+
|
|
1003
|
+
<template>
|
|
1004
|
+
<Select
|
|
1005
|
+
:items="['Option 1', 'Option 2', 'Option 3']"
|
|
1006
|
+
v-model="value"
|
|
1007
|
+
class="dark-mode"
|
|
1008
|
+
:style="darkTheme"
|
|
1009
|
+
/>
|
|
1010
|
+
</template>
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
### External CSS with Scoped Styles
|
|
1014
|
+
|
|
1015
|
+
```vue
|
|
1016
|
+
<script setup lang="ts">
|
|
1017
|
+
import { ref } from 'vue';
|
|
1018
|
+
import { Select } from '@smilodon/vue';
|
|
1019
|
+
|
|
1020
|
+
const value = ref('');
|
|
1021
|
+
</script>
|
|
1022
|
+
|
|
1023
|
+
<template>
|
|
1024
|
+
<Select
|
|
1025
|
+
:items="['Option 1', 'Option 2', 'Option 3']"
|
|
1026
|
+
v-model="value"
|
|
1027
|
+
class="custom-select"
|
|
1028
|
+
/>
|
|
1029
|
+
</template>
|
|
1030
|
+
|
|
1031
|
+
<style scoped>
|
|
1032
|
+
.custom-select {
|
|
1033
|
+
--select-input-border: 2px solid #10b981;
|
|
1034
|
+
--select-input-border-radius: 12px;
|
|
1035
|
+
--select-option-hover-bg: #d1fae5;
|
|
1036
|
+
--select-option-selected-bg: #10b981;
|
|
1037
|
+
--select-option-selected-color: white;
|
|
1038
|
+
--select-badge-bg: #10b981;
|
|
1039
|
+
--select-separator-gradient: linear-gradient(
|
|
1040
|
+
to bottom,
|
|
1041
|
+
transparent 0%,
|
|
1042
|
+
#10b981 20%,
|
|
1043
|
+
#10b981 80%,
|
|
1044
|
+
transparent 100%
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
</style>
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1050
|
+
---
|
|
1051
|
+
|
|
1052
|
+
## Custom Renderers
|
|
1053
|
+
|
|
1054
|
+
### Custom Option Renderer
|
|
1055
|
+
|
|
1056
|
+
```vue
|
|
1057
|
+
<script setup lang="ts">
|
|
1058
|
+
import { ref, h } from 'vue';
|
|
1059
|
+
import { Select } from '@smilodon/vue';
|
|
1060
|
+
import type { SelectItem } from '@smilodon/core';
|
|
1061
|
+
|
|
1062
|
+
interface User extends SelectItem {
|
|
1063
|
+
value: string;
|
|
1064
|
+
label: string;
|
|
1065
|
+
email: string;
|
|
1066
|
+
avatar: string;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
const selectedUser = ref<string | number>('');
|
|
1070
|
+
|
|
1071
|
+
const users: User[] = [
|
|
1072
|
+
{
|
|
1073
|
+
value: '1',
|
|
1074
|
+
label: 'John Doe',
|
|
1075
|
+
email: 'john@example.com',
|
|
1076
|
+
avatar: 'https://i.pravatar.cc/150?img=1'
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
value: '2',
|
|
1080
|
+
label: 'Jane Smith',
|
|
1081
|
+
email: 'jane@example.com',
|
|
1082
|
+
avatar: 'https://i.pravatar.cc/150?img=2'
|
|
1083
|
+
},
|
|
1084
|
+
];
|
|
1085
|
+
|
|
1086
|
+
const customRenderer = (item: SelectItem) => {
|
|
1087
|
+
const user = item as User;
|
|
1088
|
+
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '12px' } }, [
|
|
1089
|
+
h('img', {
|
|
1090
|
+
src: user.avatar,
|
|
1091
|
+
alt: user.label,
|
|
1092
|
+
style: { width: '32px', height: '32px', borderRadius: '50%' }
|
|
1093
|
+
}),
|
|
1094
|
+
h('div', {}, [
|
|
1095
|
+
h('div', { style: { fontWeight: '500' } }, user.label),
|
|
1096
|
+
h('div', { style: { fontSize: '12px', color: '#6b7280' } }, user.email)
|
|
1097
|
+
])
|
|
1098
|
+
]);
|
|
1099
|
+
};
|
|
1100
|
+
</script>
|
|
1101
|
+
|
|
1102
|
+
<template>
|
|
1103
|
+
<Select
|
|
1104
|
+
:items="users"
|
|
1105
|
+
v-model="selectedUser"
|
|
1106
|
+
:customRenderer="customRenderer"
|
|
1107
|
+
placeholder="Select a user"
|
|
1108
|
+
:estimatedItemHeight="60"
|
|
1109
|
+
/>
|
|
1110
|
+
</template>
|
|
1111
|
+
```
|
|
1112
|
+
|
|
1113
|
+
---
|
|
1114
|
+
|
|
1115
|
+
## Performance Optimization
|
|
1116
|
+
|
|
1117
|
+
### Virtualization for Large Datasets
|
|
1118
|
+
|
|
1119
|
+
```vue
|
|
1120
|
+
<script setup lang="ts">
|
|
1121
|
+
import { ref, computed } from 'vue';
|
|
1122
|
+
import { Select } from '@smilodon/vue';
|
|
1123
|
+
|
|
1124
|
+
const value = ref('');
|
|
1125
|
+
|
|
1126
|
+
// Generate 100,000 items
|
|
1127
|
+
const items = computed(() =>
|
|
1128
|
+
Array.from({ length: 100_000 }, (_, i) => ({
|
|
1129
|
+
value: `item-${i}`,
|
|
1130
|
+
label: `Item ${i + 1}`,
|
|
1131
|
+
}))
|
|
1132
|
+
);
|
|
1133
|
+
</script>
|
|
1134
|
+
|
|
1135
|
+
<template>
|
|
1136
|
+
<Select
|
|
1137
|
+
:items="items"
|
|
1138
|
+
v-model="value"
|
|
1139
|
+
:virtualization="true"
|
|
1140
|
+
:estimatedItemHeight="48"
|
|
1141
|
+
placeholder="Search 100k items..."
|
|
1142
|
+
searchable
|
|
1143
|
+
/>
|
|
1144
|
+
</template>
|
|
1145
|
+
```
|
|
1146
|
+
|
|
1147
|
+
### Computed Items
|
|
1148
|
+
|
|
1149
|
+
```vue
|
|
1150
|
+
<script setup lang="ts">
|
|
1151
|
+
import { ref, computed } from 'vue';
|
|
1152
|
+
import { Select } from '@smilodon/vue';
|
|
1153
|
+
import type { SelectItem } from '@smilodon/core';
|
|
1154
|
+
|
|
1155
|
+
const value = ref('');
|
|
1156
|
+
const searchFilter = ref('');
|
|
1157
|
+
|
|
1158
|
+
const rawItems: SelectItem[] = [
|
|
1159
|
+
{ value: '1', label: 'Apple' },
|
|
1160
|
+
{ value: '2', label: 'Banana' },
|
|
1161
|
+
{ value: '3', label: 'Cherry' },
|
|
1162
|
+
// ... many more items
|
|
1163
|
+
];
|
|
1164
|
+
|
|
1165
|
+
// Only recalculate when rawItems or searchFilter changes
|
|
1166
|
+
const filteredItems = computed(() => {
|
|
1167
|
+
if (!searchFilter.value) return rawItems;
|
|
1168
|
+
return rawItems.filter(item =>
|
|
1169
|
+
item.label.toLowerCase().includes(searchFilter.value.toLowerCase())
|
|
1170
|
+
);
|
|
1171
|
+
});
|
|
1172
|
+
</script>
|
|
1173
|
+
|
|
1174
|
+
<template>
|
|
1175
|
+
<Select
|
|
1176
|
+
:items="filteredItems"
|
|
1177
|
+
v-model="value"
|
|
1178
|
+
/>
|
|
1179
|
+
</template>
|
|
1180
|
+
```
|
|
1181
|
+
|
|
1182
|
+
---
|
|
1183
|
+
|
|
1184
|
+
## TypeScript Integration
|
|
1185
|
+
|
|
1186
|
+
### Full Type Safety
|
|
1187
|
+
|
|
1188
|
+
```vue
|
|
1189
|
+
<script setup lang="ts">
|
|
1190
|
+
import { ref } from 'vue';
|
|
1191
|
+
import { Select } from '@smilodon/vue';
|
|
1192
|
+
import type { SelectItem } from '@smilodon/core';
|
|
1193
|
+
|
|
1194
|
+
// Define your data type
|
|
1195
|
+
interface Product extends SelectItem {
|
|
1196
|
+
value: string;
|
|
1197
|
+
label: string;
|
|
1198
|
+
price: number;
|
|
1199
|
+
category: string;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
const selectedId = ref<string>('');
|
|
1203
|
+
|
|
1204
|
+
const products: Product[] = [
|
|
1205
|
+
{ value: 'p1', label: 'Laptop', price: 999, category: 'Electronics' },
|
|
1206
|
+
{ value: 'p2', label: 'Phone', price: 699, category: 'Electronics' },
|
|
1207
|
+
{ value: 'p3', label: 'Desk', price: 299, category: 'Furniture' },
|
|
1208
|
+
];
|
|
1209
|
+
|
|
1210
|
+
const handleChange = (value: string | number | (string | number)[]) => {
|
|
1211
|
+
selectedId.value = value as string;
|
|
1212
|
+
const product = products.find(p => p.value === value);
|
|
1213
|
+
if (product) {
|
|
1214
|
+
console.log('Selected product:', product.label, 'Price:', product.price);
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
</script>
|
|
1218
|
+
|
|
1219
|
+
<template>
|
|
1220
|
+
<Select
|
|
1221
|
+
:items="products"
|
|
1222
|
+
v-model="selectedId"
|
|
1223
|
+
@update:modelValue="handleChange"
|
|
1224
|
+
placeholder="Select a product"
|
|
1225
|
+
/>
|
|
1226
|
+
</template>
|
|
1227
|
+
```
|
|
1228
|
+
|
|
1229
|
+
### Generic Component
|
|
1230
|
+
|
|
1231
|
+
```vue
|
|
1232
|
+
<script setup lang="ts" generic="T extends SelectItem">
|
|
1233
|
+
import { ref, watch } from 'vue';
|
|
1234
|
+
import { Select } from '@smilodon/vue';
|
|
1235
|
+
import type { SelectItem } from '@smilodon/core';
|
|
1236
|
+
|
|
1237
|
+
interface Props {
|
|
1238
|
+
items: T[];
|
|
1239
|
+
label: string;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
const props = defineProps<Props>();
|
|
1243
|
+
|
|
1244
|
+
const emit = defineEmits<{
|
|
1245
|
+
select: [item: T];
|
|
1246
|
+
}>();
|
|
1247
|
+
|
|
1248
|
+
const selectedValue = ref<string | number>('');
|
|
1249
|
+
|
|
1250
|
+
watch(selectedValue, (newValue) => {
|
|
1251
|
+
const selected = props.items.find(item => item.value === newValue);
|
|
1252
|
+
if (selected) emit('select', selected);
|
|
1253
|
+
});
|
|
1254
|
+
</script>
|
|
1255
|
+
|
|
1256
|
+
<template>
|
|
1257
|
+
<div>
|
|
1258
|
+
<label>{{ label }}</label>
|
|
1259
|
+
<Select :items="items" v-model="selectedValue" />
|
|
1260
|
+
</div>
|
|
1261
|
+
</template>
|
|
1262
|
+
```
|
|
1263
|
+
|
|
1264
|
+
---
|
|
1265
|
+
|
|
1266
|
+
## Composition API
|
|
1267
|
+
|
|
1268
|
+
### Composable for Select Logic
|
|
1269
|
+
|
|
1270
|
+
```typescript
|
|
1271
|
+
// composables/useSelect.ts
|
|
1272
|
+
import { ref, computed } from 'vue';
|
|
1273
|
+
import type { SelectItem } from '@smilodon/core';
|
|
1274
|
+
|
|
1275
|
+
export function useSelect<T extends SelectItem>(initialItems: T[]) {
|
|
1276
|
+
const items = ref<T[]>(initialItems);
|
|
1277
|
+
const selectedValue = ref<string | number | (string | number)[]>('');
|
|
1278
|
+
const isOpen = ref(false);
|
|
1279
|
+
|
|
1280
|
+
const selectedItem = computed(() => {
|
|
1281
|
+
if (Array.isArray(selectedValue.value)) {
|
|
1282
|
+
return items.value.filter(item =>
|
|
1283
|
+
selectedValue.value.includes(item.value)
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1286
|
+
return items.value.find(item => item.value === selectedValue.value);
|
|
1287
|
+
});
|
|
1288
|
+
|
|
1289
|
+
const selectItem = (value: string | number | (string | number)[]) => {
|
|
1290
|
+
selectedValue.value = value;
|
|
1291
|
+
};
|
|
1292
|
+
|
|
1293
|
+
const clearSelection = () => {
|
|
1294
|
+
selectedValue.value = Array.isArray(selectedValue.value) ? [] : '';
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
return {
|
|
1298
|
+
items,
|
|
1299
|
+
selectedValue,
|
|
1300
|
+
selectedItem,
|
|
1301
|
+
isOpen,
|
|
1302
|
+
selectItem,
|
|
1303
|
+
clearSelection,
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
```
|
|
1307
|
+
|
|
1308
|
+
Usage:
|
|
1309
|
+
|
|
1310
|
+
```vue
|
|
1311
|
+
<script setup lang="ts">
|
|
1312
|
+
import { Select } from '@smilodon/vue';
|
|
1313
|
+
import { useSelect } from './composables/useSelect';
|
|
1314
|
+
|
|
1315
|
+
const {
|
|
1316
|
+
items,
|
|
1317
|
+
selectedValue,
|
|
1318
|
+
selectedItem,
|
|
1319
|
+
selectItem
|
|
1320
|
+
} = useSelect([
|
|
1321
|
+
{ value: '1', label: 'Option 1' },
|
|
1322
|
+
{ value: '2', label: 'Option 2' },
|
|
1323
|
+
{ value: '3', label: 'Option 3' },
|
|
1324
|
+
]);
|
|
1325
|
+
</script>
|
|
1326
|
+
|
|
1327
|
+
<template>
|
|
1328
|
+
<div>
|
|
1329
|
+
<Select
|
|
1330
|
+
:items="items"
|
|
1331
|
+
v-model="selectedValue"
|
|
1332
|
+
@update:modelValue="selectItem"
|
|
1333
|
+
/>
|
|
1334
|
+
<p v-if="selectedItem">Selected: {{ selectedItem.label }}</p>
|
|
1335
|
+
</div>
|
|
1336
|
+
</template>
|
|
1337
|
+
```
|
|
1338
|
+
|
|
1339
|
+
---
|
|
1340
|
+
|
|
1341
|
+
## Accessibility
|
|
1342
|
+
|
|
1343
|
+
Smilodon is WCAG 2.1 AAA compliant with full keyboard support:
|
|
1344
|
+
|
|
1345
|
+
### Keyboard Navigation
|
|
1346
|
+
|
|
1347
|
+
- **Tab** - Focus the select
|
|
1348
|
+
- **Enter/Space** - Open dropdown
|
|
1349
|
+
- **↑/↓** - Navigate options
|
|
1350
|
+
- **Home/End** - Jump to first/last option
|
|
1351
|
+
- **Escape** - Close dropdown
|
|
1352
|
+
- **Type** - Search options
|
|
1353
|
+
|
|
1354
|
+
### ARIA Attributes
|
|
1355
|
+
|
|
1356
|
+
The component automatically includes:
|
|
1357
|
+
- `role="combobox"`
|
|
1358
|
+
- `aria-expanded`
|
|
1359
|
+
- `aria-haspopup`
|
|
1360
|
+
- `aria-label` / `aria-labelledby`
|
|
1361
|
+
- `aria-activedescendant`
|
|
1362
|
+
- `aria-multiselectable` (when `multiple`)
|
|
1363
|
+
|
|
1364
|
+
### Screen Reader Support
|
|
1365
|
+
|
|
1366
|
+
```vue
|
|
1367
|
+
<script setup lang="ts">
|
|
1368
|
+
import { ref } from 'vue';
|
|
1369
|
+
import { Select } from '@smilodon/vue';
|
|
1370
|
+
|
|
1371
|
+
const country = ref('');
|
|
1372
|
+
</script>
|
|
1373
|
+
|
|
1374
|
+
<template>
|
|
1375
|
+
<div>
|
|
1376
|
+
<label id="country-label">Country</label>
|
|
1377
|
+
<Select
|
|
1378
|
+
:items="['USA', 'Canada', 'Mexico']"
|
|
1379
|
+
v-model="country"
|
|
1380
|
+
placeholder="Select your country"
|
|
1381
|
+
aria-labelledby="country-label"
|
|
1382
|
+
/>
|
|
1383
|
+
</div>
|
|
1384
|
+
</template>
|
|
1385
|
+
```
|
|
1386
|
+
|
|
1387
|
+
---
|
|
1388
|
+
|
|
1389
|
+
## Advanced Patterns
|
|
1390
|
+
|
|
1391
|
+
### Dependent Selects
|
|
1392
|
+
|
|
1393
|
+
```vue
|
|
1394
|
+
<script setup lang="ts">
|
|
1395
|
+
import { ref, watch } from 'vue';
|
|
1396
|
+
import { Select } from '@smilodon/vue';
|
|
1397
|
+
|
|
1398
|
+
const country = ref('');
|
|
1399
|
+
const state = ref('');
|
|
1400
|
+
const states = ref<string[]>([]);
|
|
1401
|
+
|
|
1402
|
+
const countries = ['USA', 'Canada', 'Mexico'];
|
|
1403
|
+
|
|
1404
|
+
watch(country, (newCountry) => {
|
|
1405
|
+
// Reset state when country changes
|
|
1406
|
+
state.value = '';
|
|
1407
|
+
|
|
1408
|
+
// Load states for selected country
|
|
1409
|
+
if (newCountry === 'USA') {
|
|
1410
|
+
states.value = ['California', 'Texas', 'New York', 'Florida'];
|
|
1411
|
+
} else if (newCountry === 'Canada') {
|
|
1412
|
+
states.value = ['Ontario', 'Quebec', 'British Columbia'];
|
|
1413
|
+
} else if (newCountry === 'Mexico') {
|
|
1414
|
+
states.value = ['Mexico City', 'Jalisco', 'Nuevo León'];
|
|
1415
|
+
} else {
|
|
1416
|
+
states.value = [];
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
</script>
|
|
1420
|
+
|
|
1421
|
+
<template>
|
|
1422
|
+
<div>
|
|
1423
|
+
<Select
|
|
1424
|
+
:items="countries"
|
|
1425
|
+
v-model="country"
|
|
1426
|
+
placeholder="Select country"
|
|
1427
|
+
/>
|
|
1428
|
+
|
|
1429
|
+
<Select
|
|
1430
|
+
:items="states"
|
|
1431
|
+
v-model="state"
|
|
1432
|
+
:disabled="!country"
|
|
1433
|
+
:placeholder="country ? 'Select state' : 'Select country first'"
|
|
1434
|
+
/>
|
|
1435
|
+
</div>
|
|
1436
|
+
</template>
|
|
1437
|
+
```
|
|
1438
|
+
|
|
1439
|
+
### Async Data Loading
|
|
1440
|
+
|
|
1441
|
+
```vue
|
|
1442
|
+
<script setup lang="ts">
|
|
1443
|
+
import { ref, onMounted } from 'vue';
|
|
1444
|
+
import { Select } from '@smilodon/vue';
|
|
1445
|
+
import type { SelectItem } from '@smilodon/core';
|
|
1446
|
+
|
|
1447
|
+
const items = ref<SelectItem[]>([]);
|
|
1448
|
+
const loading = ref(true);
|
|
1449
|
+
const value = ref('');
|
|
1450
|
+
|
|
1451
|
+
onMounted(async () => {
|
|
1452
|
+
loading.value = true;
|
|
1453
|
+
|
|
1454
|
+
// Simulate API call
|
|
1455
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
1456
|
+
|
|
1457
|
+
items.value = [
|
|
1458
|
+
{ value: '1', label: 'Option 1' },
|
|
1459
|
+
{ value: '2', label: 'Option 2' },
|
|
1460
|
+
{ value: '3', label: 'Option 3' },
|
|
1461
|
+
];
|
|
1462
|
+
|
|
1463
|
+
loading.value = false;
|
|
1464
|
+
});
|
|
1465
|
+
</script>
|
|
1466
|
+
|
|
1467
|
+
<template>
|
|
1468
|
+
<div>
|
|
1469
|
+
<div v-if="loading">Loading options...</div>
|
|
1470
|
+
<Select
|
|
1471
|
+
v-else
|
|
1472
|
+
:items="items"
|
|
1473
|
+
v-model="value"
|
|
1474
|
+
placeholder="Select an option"
|
|
1475
|
+
/>
|
|
1476
|
+
</div>
|
|
1477
|
+
</template>
|
|
1478
|
+
```
|
|
1479
|
+
|
|
1480
|
+
### With Pinia Store
|
|
1481
|
+
|
|
1482
|
+
```typescript
|
|
1483
|
+
// stores/selectStore.ts
|
|
1484
|
+
import { defineStore } from 'pinia';
|
|
1485
|
+
import type { SelectItem } from '@smilodon/core';
|
|
1486
|
+
|
|
1487
|
+
export const useSelectStore = defineStore('select', {
|
|
1488
|
+
state: () => ({
|
|
1489
|
+
items: [] as SelectItem[],
|
|
1490
|
+
selectedValue: '' as string | number,
|
|
1491
|
+
}),
|
|
1492
|
+
|
|
1493
|
+
actions: {
|
|
1494
|
+
setItems(newItems: SelectItem[]) {
|
|
1495
|
+
this.items = newItems;
|
|
1496
|
+
},
|
|
1497
|
+
|
|
1498
|
+
selectItem(value: string | number) {
|
|
1499
|
+
this.selectedValue = value;
|
|
1500
|
+
},
|
|
1501
|
+
|
|
1502
|
+
clearSelection() {
|
|
1503
|
+
this.selectedValue = '';
|
|
1504
|
+
},
|
|
1505
|
+
},
|
|
1506
|
+
});
|
|
1507
|
+
```
|
|
1508
|
+
|
|
1509
|
+
```vue
|
|
1510
|
+
<script setup lang="ts">
|
|
1511
|
+
import { Select } from '@smilodon/vue';
|
|
1512
|
+
import { useSelectStore } from './stores/selectStore';
|
|
1513
|
+
|
|
1514
|
+
const store = useSelectStore();
|
|
1515
|
+
|
|
1516
|
+
// Initialize items
|
|
1517
|
+
store.setItems([
|
|
1518
|
+
{ value: '1', label: 'Option 1' },
|
|
1519
|
+
{ value: '2', label: 'Option 2' },
|
|
1520
|
+
{ value: '3', label: 'Option 3' },
|
|
1521
|
+
]);
|
|
1522
|
+
</script>
|
|
1523
|
+
|
|
1524
|
+
<template>
|
|
1525
|
+
<Select
|
|
1526
|
+
:items="store.items"
|
|
1527
|
+
v-model="store.selectedValue"
|
|
1528
|
+
@update:modelValue="store.selectItem"
|
|
1529
|
+
/>
|
|
1530
|
+
</template>
|
|
1531
|
+
```
|
|
1532
|
+
|
|
1533
|
+
---
|
|
1534
|
+
|
|
1535
|
+
## Troubleshooting
|
|
1536
|
+
|
|
1537
|
+
### Common Issues
|
|
1538
|
+
|
|
1539
|
+
#### Issue: v-model not updating
|
|
1540
|
+
|
|
1541
|
+
```vue
|
|
1542
|
+
<!-- ❌ Wrong - typo in v-model -->
|
|
1543
|
+
<Select :items="items" v-modal="value" />
|
|
1544
|
+
|
|
1545
|
+
<!-- ✅ Correct -->
|
|
1546
|
+
<Select :items="items" v-model="value" />
|
|
1547
|
+
```
|
|
1548
|
+
|
|
1549
|
+
#### Issue: Multi-select type error
|
|
1550
|
+
|
|
1551
|
+
```vue
|
|
1552
|
+
<script setup lang="ts">
|
|
1553
|
+
// ❌ Wrong - value should be array for multiple
|
|
1554
|
+
const value = ref('');
|
|
1555
|
+
|
|
1556
|
+
// ✅ Correct
|
|
1557
|
+
const value = ref<(string | number)[]>([]);
|
|
1558
|
+
</script>
|
|
1559
|
+
|
|
1560
|
+
<template>
|
|
1561
|
+
<Select :items="items" v-model="value" multiple />
|
|
1562
|
+
</template>
|
|
1563
|
+
```
|
|
1564
|
+
|
|
1565
|
+
#### Issue: Warning about custom element
|
|
1566
|
+
|
|
1567
|
+
Add to `vite.config.ts`:
|
|
1568
|
+
|
|
1569
|
+
```typescript
|
|
1570
|
+
export default defineConfig({
|
|
1571
|
+
plugins: [
|
|
1572
|
+
vue({
|
|
1573
|
+
template: {
|
|
1574
|
+
compilerOptions: {
|
|
1575
|
+
isCustomElement: (tag) => tag === 'enhanced-select'
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
})
|
|
1579
|
+
]
|
|
1580
|
+
});
|
|
1581
|
+
```
|
|
1582
|
+
|
|
1583
|
+
### Performance Issues
|
|
1584
|
+
|
|
1585
|
+
If you experience slow rendering with large datasets:
|
|
1586
|
+
|
|
1587
|
+
1. Use `computed` for items array
|
|
1588
|
+
2. Enable virtualization (enabled by default)
|
|
1589
|
+
3. Increase `estimatedItemHeight` if items are taller than 48px
|
|
1590
|
+
|
|
1591
|
+
```vue
|
|
1592
|
+
<script setup lang="ts">
|
|
1593
|
+
import { computed } from 'vue';
|
|
1594
|
+
|
|
1595
|
+
const items = computed(() => generateLargeDataset());
|
|
1596
|
+
</script>
|
|
1597
|
+
|
|
1598
|
+
<template>
|
|
1599
|
+
<Select
|
|
1600
|
+
:items="items"
|
|
1601
|
+
v-model="value"
|
|
1602
|
+
:virtualization="true"
|
|
1603
|
+
:estimatedItemHeight="48"
|
|
1604
|
+
/>
|
|
1605
|
+
</template>
|
|
1606
|
+
```
|
|
1607
|
+
|
|
1608
|
+
---
|
|
1609
|
+
|
|
1610
|
+
## Additional Resources
|
|
1611
|
+
|
|
1612
|
+
- **Core Documentation**: [packages/core/README.md](../core/README.md)
|
|
1613
|
+
- **API Reference**: [docs/API-REFERENCE.md](../../docs/API-REFERENCE.md)
|
|
1614
|
+
- **Live Examples**: [Playground](../../playground)
|
|
1615
|
+
- **GitHub Issues**: [Report a bug](https://github.com/navidrezadoost/smilodon/issues)
|
|
1616
|
+
|
|
1617
|
+
---
|
|
1618
|
+
|
|
1619
|
+
**Built with ❤️ by the Smilodon team**
|
|
1620
|
+
|
|
1621
|
+
*Last updated: February 9, 2026 - v1.3.6*
|