@smilodon/vue 1.0.7 â 1.1.0
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 +832 -23
- package/dist/index.cjs +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,18 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
Production-ready, accessible select component for Vue 3 applications.
|
|
4
4
|
|
|
5
|
+
## ð Documentation
|
|
6
|
+
|
|
7
|
+
**For comprehensive documentation covering all features, styling options, and advanced patterns:**
|
|
8
|
+
|
|
9
|
+
ð **[Complete Vue Guide](./COMPLETE-GUIDE.md)** ð
|
|
10
|
+
|
|
11
|
+
The complete guide includes:
|
|
12
|
+
- â
All 60+ CSS variables for complete customization
|
|
13
|
+
- â
Vue 3-specific patterns (Composition API, v-model, computed)
|
|
14
|
+
- â
Complete API reference with TypeScript types
|
|
15
|
+
- â
Pinia store integration examples
|
|
16
|
+
- â
Custom renderers with h() function and VNodes
|
|
17
|
+
- â
Theme examples and styling techniques
|
|
18
|
+
- â
Advanced patterns (dependent selects, async onMounted)
|
|
19
|
+
- â
Troubleshooting and accessibility information
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
5
23
|
## Features
|
|
6
24
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
25
|
+
- â
**Vue 3 Native** - Built for Vue 3 with Composition API and `<script setup>` support
|
|
26
|
+
- â
**v-model Support** - Two-way binding that feels natural in Vue
|
|
27
|
+
- â
**Fully Typed** - Complete TypeScript support with detailed type definitions
|
|
28
|
+
- â
**Single & Multi-select** - One prop to switch modes
|
|
29
|
+
- â
**Searchable** - Built-in filtering with customizable behavior
|
|
30
|
+
- â
**Infinite Scroll** - Handle massive datasets efficiently
|
|
31
|
+
- â
**Virtual Scrolling** - Render only visible items for performance
|
|
32
|
+
- â
**Grouped Options** - Organize items into categories
|
|
33
|
+
- â
**Accessible** - WCAG 2.1 AAA compliant, full keyboard navigation
|
|
34
|
+
- â
**Flexible Input** - Accepts SelectItem objects, string arrays, or number arrays
|
|
35
|
+
- â
**Customizable** - Custom renderers, styles, and behaviors
|
|
36
|
+
- â
**Tiny Bundle** - Optimized for production
|
|
17
37
|
|
|
18
38
|
## Installation
|
|
19
39
|
|
|
@@ -21,15 +41,29 @@ Production-ready, accessible select component for Vue 3 applications.
|
|
|
21
41
|
npm install @smilodon/vue @smilodon/core
|
|
22
42
|
```
|
|
23
43
|
|
|
44
|
+
or
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
yarn add @smilodon/vue @smilodon/core
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
or
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm add @smilodon/vue @smilodon/core
|
|
54
|
+
```
|
|
55
|
+
|
|
24
56
|
## Quick Start
|
|
25
57
|
|
|
26
58
|
```vue
|
|
27
|
-
<script setup>
|
|
59
|
+
<script setup lang="ts">
|
|
28
60
|
import { ref } from 'vue';
|
|
29
61
|
import { Select } from '@smilodon/vue';
|
|
62
|
+
import type { SelectItem } from '@smilodon/core';
|
|
30
63
|
|
|
31
|
-
const selectedValue = ref('');
|
|
32
|
-
|
|
64
|
+
const selectedValue = ref<string | number>('');
|
|
65
|
+
|
|
66
|
+
const items: SelectItem[] = [
|
|
33
67
|
{ value: 'apple', label: 'Apple' },
|
|
34
68
|
{ value: 'banana', label: 'Banana' },
|
|
35
69
|
{ value: 'cherry', label: 'Cherry' },
|
|
@@ -51,12 +85,14 @@ const items = [
|
|
|
51
85
|
### Basic Single Select
|
|
52
86
|
|
|
53
87
|
```vue
|
|
54
|
-
<script setup>
|
|
88
|
+
<script setup lang="ts">
|
|
55
89
|
import { ref } from 'vue';
|
|
56
90
|
import { Select } from '@smilodon/vue';
|
|
91
|
+
import type { SelectItem } from '@smilodon/core';
|
|
57
92
|
|
|
58
|
-
const
|
|
59
|
-
|
|
93
|
+
const selectedValue = ref<string | number>('');
|
|
94
|
+
|
|
95
|
+
const items: SelectItem[] = [
|
|
60
96
|
{ value: '1', label: 'Option 1' },
|
|
61
97
|
{ value: '2', label: 'Option 2' },
|
|
62
98
|
{ value: '3', label: 'Option 3' },
|
|
@@ -64,17 +100,181 @@ const items = [
|
|
|
64
100
|
</script>
|
|
65
101
|
|
|
66
102
|
<template>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
103
|
+
<Select
|
|
104
|
+
:items="items"
|
|
105
|
+
v-model="selectedValue"
|
|
106
|
+
placeholder="Choose an option"
|
|
107
|
+
/>
|
|
108
|
+
|
|
109
|
+
<div v-if="selectedValue">
|
|
110
|
+
Selected: {{ selectedValue }}
|
|
111
|
+
</div>
|
|
112
|
+
</template>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### String Array Input (Auto-converted)
|
|
116
|
+
|
|
117
|
+
The Select component accepts string arrays and automatically converts them to the SelectItem format:
|
|
118
|
+
|
|
119
|
+
```vue
|
|
120
|
+
<script setup lang="ts">
|
|
121
|
+
import { ref } from 'vue';
|
|
122
|
+
import { Select } from '@smilodon/vue';
|
|
123
|
+
|
|
124
|
+
const selectedFruits = ref<Array<string | number>>([]);
|
|
125
|
+
|
|
126
|
+
const fruits = ['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry', 'Fig', 'Grape', 'Honeydew'];
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<template>
|
|
130
|
+
<Select
|
|
131
|
+
:items="fruits"
|
|
132
|
+
v-model="selectedFruits"
|
|
133
|
+
placeholder="Select fruits..."
|
|
134
|
+
searchable
|
|
135
|
+
multiple
|
|
136
|
+
/>
|
|
137
|
+
|
|
138
|
+
<div v-if="selectedFruits.length">
|
|
139
|
+
Selected: {{ selectedFruits.join(', ') }}
|
|
140
|
+
</div>
|
|
141
|
+
</template>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Note:** String arrays are automatically converted to `SelectItem` objects where both `value` and `label` equal the string:
|
|
145
|
+
- `"Apple"` becomes `{ value: "Apple", label: "Apple" }`
|
|
146
|
+
|
|
147
|
+
### Number Array Input (Auto-converted)
|
|
148
|
+
|
|
149
|
+
```vue
|
|
150
|
+
<script setup lang="ts">
|
|
151
|
+
import { ref } from 'vue';
|
|
152
|
+
import { Select } from '@smilodon/vue';
|
|
153
|
+
|
|
154
|
+
const selectedNumber = ref<string | number>(0);
|
|
155
|
+
|
|
156
|
+
const fibonacciNumbers = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
|
|
157
|
+
</script>
|
|
158
|
+
|
|
159
|
+
<template>
|
|
160
|
+
<Select
|
|
161
|
+
:items="fibonacciNumbers"
|
|
162
|
+
v-model="selectedNumber"
|
|
163
|
+
placeholder="Select a Fibonacci number"
|
|
164
|
+
/>
|
|
165
|
+
|
|
166
|
+
<div v-if="selectedNumber">
|
|
167
|
+
Selected: {{ selectedNumber }}
|
|
74
168
|
</div>
|
|
75
169
|
</template>
|
|
76
170
|
```
|
|
77
171
|
|
|
172
|
+
**Note:** Number arrays are automatically converted to `SelectItem` objects:
|
|
173
|
+
- `42` becomes `{ value: 42, label: "42" }`
|
|
174
|
+
|
|
175
|
+
## Complete Examples
|
|
176
|
+
|
|
177
|
+
## Complete Examples
|
|
178
|
+
|
|
179
|
+
### Multi-Select with Groups
|
|
180
|
+
|
|
181
|
+
```vue
|
|
182
|
+
<script setup lang="ts">
|
|
183
|
+
import { ref } from 'vue';
|
|
184
|
+
import { Select } from '@smilodon/vue';
|
|
185
|
+
import type { SelectItem } from '@smilodon/core';
|
|
186
|
+
|
|
187
|
+
const selectedValues = ref<Array<string | number>>([]);
|
|
188
|
+
|
|
189
|
+
const groupedItems: SelectItem[] = [
|
|
190
|
+
{ value: 'apple', label: 'Apple', group: 'Fruits' },
|
|
191
|
+
{ value: 'banana', label: 'Banana', group: 'Fruits' },
|
|
192
|
+
{ value: 'carrot', label: 'Carrot', group: 'Vegetables' },
|
|
193
|
+
{ value: 'broccoli', label: 'Broccoli', group: 'Vegetables' },
|
|
194
|
+
];
|
|
195
|
+
</script>
|
|
196
|
+
|
|
197
|
+
<template>
|
|
198
|
+
<Select
|
|
199
|
+
:items="groupedItems"
|
|
200
|
+
v-model="selectedValues"
|
|
201
|
+
placeholder="Select items..."
|
|
202
|
+
searchable
|
|
203
|
+
multiple
|
|
204
|
+
/>
|
|
205
|
+
|
|
206
|
+
<div v-if="selectedValues.length">
|
|
207
|
+
Selected ({{ selectedValues.length }}): {{ selectedValues.join(', ') }}
|
|
208
|
+
</div>
|
|
209
|
+
</template>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Searchable Multi-Select (50 items)
|
|
213
|
+
|
|
214
|
+
```vue
|
|
215
|
+
<script setup lang="ts">
|
|
216
|
+
import { ref } from 'vue';
|
|
217
|
+
import { Select } from '@smilodon/vue';
|
|
218
|
+
import type { SelectItem } from '@smilodon/core';
|
|
219
|
+
|
|
220
|
+
const selectedValues = ref<Array<string | number>>([]);
|
|
221
|
+
|
|
222
|
+
// Generate 50 items
|
|
223
|
+
const items: SelectItem[] = Array.from({ length: 50 }, (_, i) => ({
|
|
224
|
+
value: `item-${i + 1}`,
|
|
225
|
+
label: `Item ${i + 1}`,
|
|
226
|
+
}));
|
|
227
|
+
</script>
|
|
228
|
+
|
|
229
|
+
<template>
|
|
230
|
+
<Select
|
|
231
|
+
:items="items"
|
|
232
|
+
v-model="selectedValues"
|
|
233
|
+
placeholder="Search and select..."
|
|
234
|
+
searchable
|
|
235
|
+
multiple
|
|
236
|
+
/>
|
|
237
|
+
|
|
238
|
+
<div v-if="selectedValues.length">
|
|
239
|
+
Selected: {{ selectedValues.length }} items
|
|
240
|
+
</div>
|
|
241
|
+
</template>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Large Dataset with Virtual Scrolling (1000 items)
|
|
245
|
+
|
|
246
|
+
```vue
|
|
247
|
+
<script setup lang="ts">
|
|
248
|
+
import { ref } from 'vue';
|
|
249
|
+
import { Select } from '@smilodon/vue';
|
|
250
|
+
import type { SelectItem } from '@smilodon/core';
|
|
251
|
+
|
|
252
|
+
const selectedValue = ref<string | number>('');
|
|
253
|
+
|
|
254
|
+
// Generate 1000 items
|
|
255
|
+
const largeDataset: SelectItem[] = Array.from({ length: 1000 }, (_, i) => ({
|
|
256
|
+
value: `item-${i + 1}`,
|
|
257
|
+
label: `Item ${i + 1} - Large Dataset`,
|
|
258
|
+
}));
|
|
259
|
+
</script>
|
|
260
|
+
|
|
261
|
+
<template>
|
|
262
|
+
<Select
|
|
263
|
+
:items="largeDataset"
|
|
264
|
+
v-model="selectedValue"
|
|
265
|
+
placeholder="Select from 1000 items..."
|
|
266
|
+
searchable
|
|
267
|
+
:virtualScroll="true"
|
|
268
|
+
/>
|
|
269
|
+
|
|
270
|
+
<div v-if="selectedValue">
|
|
271
|
+
Selected: {{ selectedValue }}
|
|
272
|
+
</div>
|
|
273
|
+
</template>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
78
278
|
### Multi-Select
|
|
79
279
|
|
|
80
280
|
```vue
|
|
@@ -285,6 +485,615 @@ function clearSelection() {
|
|
|
285
485
|
</template>
|
|
286
486
|
```
|
|
287
487
|
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## ðŊ Two Ways to Specify Options
|
|
491
|
+
|
|
492
|
+
Smilodon Vue provides **two powerful approaches** for defining select options, each optimized for different use cases:
|
|
493
|
+
|
|
494
|
+
### Method 1: Data-Driven (Object Arrays) ð
|
|
495
|
+
|
|
496
|
+
**Use when**: You have structured data and want simple, declarative option rendering.
|
|
497
|
+
|
|
498
|
+
**Advantages**:
|
|
499
|
+
- â
Simple and declarative - Vue-friendly
|
|
500
|
+
- â
Auto-conversion from strings/numbers
|
|
501
|
+
- â
Perfect for basic dropdowns
|
|
502
|
+
- â
Works seamlessly with Vue reactivity
|
|
503
|
+
- â
Extremely performant (millions of items)
|
|
504
|
+
- â
Built-in search and filtering
|
|
505
|
+
- â
Full TypeScript type safety
|
|
506
|
+
|
|
507
|
+
**Examples**:
|
|
508
|
+
|
|
509
|
+
```vue
|
|
510
|
+
<script setup lang="ts">
|
|
511
|
+
import { ref } from 'vue';
|
|
512
|
+
import { Select } from '@smilodon/vue';
|
|
513
|
+
|
|
514
|
+
// Example 1: Simple object array
|
|
515
|
+
const value = ref('');
|
|
516
|
+
|
|
517
|
+
const items = [
|
|
518
|
+
{ value: '1', label: 'Apple' },
|
|
519
|
+
{ value: '2', label: 'Banana' },
|
|
520
|
+
{ value: '3', label: 'Cherry' }
|
|
521
|
+
];
|
|
522
|
+
</script>
|
|
523
|
+
|
|
524
|
+
<template>
|
|
525
|
+
<Select
|
|
526
|
+
:items="items"
|
|
527
|
+
v-model="value"
|
|
528
|
+
placeholder="Select a fruit..."
|
|
529
|
+
/>
|
|
530
|
+
</template>
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
```vue
|
|
534
|
+
<script setup lang="ts">
|
|
535
|
+
import { ref } from 'vue';
|
|
536
|
+
import { Select } from '@smilodon/vue';
|
|
537
|
+
|
|
538
|
+
// Example 2: With metadata and disabled options
|
|
539
|
+
const country = ref('');
|
|
540
|
+
|
|
541
|
+
const countries = [
|
|
542
|
+
{ value: 'us', label: 'United States', disabled: false },
|
|
543
|
+
{ value: 'ca', label: 'Canada', disabled: false },
|
|
544
|
+
{ value: 'mx', label: 'Mexico', disabled: true }
|
|
545
|
+
];
|
|
546
|
+
</script>
|
|
547
|
+
|
|
548
|
+
<template>
|
|
549
|
+
<Select
|
|
550
|
+
:items="countries"
|
|
551
|
+
v-model="country"
|
|
552
|
+
placeholder="Select a country..."
|
|
553
|
+
/>
|
|
554
|
+
</template>
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
```vue
|
|
558
|
+
<script setup lang="ts">
|
|
559
|
+
import { ref } from 'vue';
|
|
560
|
+
import { Select } from '@smilodon/vue';
|
|
561
|
+
|
|
562
|
+
// Example 3: With grouping
|
|
563
|
+
const food = ref('');
|
|
564
|
+
|
|
565
|
+
const foods = [
|
|
566
|
+
{ value: 'apple', label: 'Apple', group: 'Fruits' },
|
|
567
|
+
{ value: 'banana', label: 'Banana', group: 'Fruits' },
|
|
568
|
+
{ value: 'carrot', label: 'Carrot', group: 'Vegetables' },
|
|
569
|
+
{ value: 'broccoli', label: 'Broccoli', group: 'Vegetables' }
|
|
570
|
+
];
|
|
571
|
+
</script>
|
|
572
|
+
|
|
573
|
+
<template>
|
|
574
|
+
<Select
|
|
575
|
+
:items="foods"
|
|
576
|
+
v-model="food"
|
|
577
|
+
placeholder="Select food..."
|
|
578
|
+
/>
|
|
579
|
+
</template>
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
```vue
|
|
583
|
+
<script setup lang="ts">
|
|
584
|
+
import { ref } from 'vue';
|
|
585
|
+
import { Select } from '@smilodon/vue';
|
|
586
|
+
|
|
587
|
+
// Example 4: Auto-conversion from strings
|
|
588
|
+
const color = ref('');
|
|
589
|
+
const colors = ['Red', 'Green', 'Blue', 'Yellow'];
|
|
590
|
+
</script>
|
|
591
|
+
|
|
592
|
+
<template>
|
|
593
|
+
<Select
|
|
594
|
+
:items="colors"
|
|
595
|
+
v-model="color"
|
|
596
|
+
placeholder="Select a color..."
|
|
597
|
+
/>
|
|
598
|
+
</template>
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
```vue
|
|
602
|
+
<script setup lang="ts">
|
|
603
|
+
import { ref } from 'vue';
|
|
604
|
+
import { Select } from '@smilodon/vue';
|
|
605
|
+
|
|
606
|
+
// Example 5: Auto-conversion from numbers
|
|
607
|
+
const size = ref<number | string>('');
|
|
608
|
+
const sizes = [10, 20, 30, 40, 50];
|
|
609
|
+
</script>
|
|
610
|
+
|
|
611
|
+
<template>
|
|
612
|
+
<Select
|
|
613
|
+
:items="sizes"
|
|
614
|
+
v-model="size"
|
|
615
|
+
placeholder="Select size..."
|
|
616
|
+
/>
|
|
617
|
+
</template>
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
```vue
|
|
621
|
+
<script setup lang="ts">
|
|
622
|
+
import { ref, computed } from 'vue';
|
|
623
|
+
import { Select } from '@smilodon/vue';
|
|
624
|
+
|
|
625
|
+
// Example 6: Large datasets with computed
|
|
626
|
+
const id = ref('');
|
|
627
|
+
|
|
628
|
+
const items = computed(() =>
|
|
629
|
+
Array.from({ length: 100_000 }, (_, i) => ({
|
|
630
|
+
value: i.toString(),
|
|
631
|
+
label: `Item ${i + 1}`
|
|
632
|
+
}))
|
|
633
|
+
);
|
|
634
|
+
</script>
|
|
635
|
+
|
|
636
|
+
<template>
|
|
637
|
+
<Select
|
|
638
|
+
:items="items"
|
|
639
|
+
v-model="id"
|
|
640
|
+
virtualized
|
|
641
|
+
placeholder="Select from 100K items..."
|
|
642
|
+
/>
|
|
643
|
+
</template>
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
### Method 2: Component-Driven (Custom Renderers) ðĻ
|
|
647
|
+
|
|
648
|
+
**Use when**: You need rich, interactive option content with custom rendering.
|
|
649
|
+
|
|
650
|
+
**Advantages**:
|
|
651
|
+
- â
Full control over option rendering
|
|
652
|
+
- â
Use Vue's render function (h())
|
|
653
|
+
- â
Rich content (images, icons, badges, multi-line text)
|
|
654
|
+
- â
Custom styling with scoped CSS
|
|
655
|
+
- â
Reactive data binding
|
|
656
|
+
- â
Conditional rendering based on item data
|
|
657
|
+
- â
Access to Vue's composition API
|
|
658
|
+
- â
Perfect for complex UIs (user cards, product listings, etc.)
|
|
659
|
+
|
|
660
|
+
**How it works**: Provide a `customRenderer` function that uses Vue's `h()` function to return a VNode.
|
|
661
|
+
|
|
662
|
+
**Examples**:
|
|
663
|
+
|
|
664
|
+
```vue
|
|
665
|
+
<script setup lang="ts">
|
|
666
|
+
import { ref, h } from 'vue';
|
|
667
|
+
import { Select, SelectItem } from '@smilodon/vue';
|
|
668
|
+
|
|
669
|
+
// Example 1: Simple custom template with icons
|
|
670
|
+
interface Language extends SelectItem {
|
|
671
|
+
icon: string;
|
|
672
|
+
description: string;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const lang = ref('');
|
|
676
|
+
|
|
677
|
+
const languages: Language[] = [
|
|
678
|
+
{ value: 'js', label: 'JavaScript', icon: 'ðĻ', description: 'Dynamic scripting language' },
|
|
679
|
+
{ value: 'py', label: 'Python', icon: 'ð', description: 'General-purpose programming' },
|
|
680
|
+
{ value: 'rs', label: 'Rust', icon: 'ðĶ', description: 'Systems programming language' }
|
|
681
|
+
];
|
|
682
|
+
|
|
683
|
+
const languageRenderer = (item: Language, index: number) => {
|
|
684
|
+
return h('div', { style: 'display: flex; align-items: center; gap: 12px;' }, [
|
|
685
|
+
h('span', { style: 'font-size: 24px;' }, item.icon),
|
|
686
|
+
h('div', [
|
|
687
|
+
h('div', { style: 'font-weight: 600;' }, item.label),
|
|
688
|
+
h('div', { style: 'font-size: 12px; color: #6b7280;' }, item.description)
|
|
689
|
+
])
|
|
690
|
+
]);
|
|
691
|
+
};
|
|
692
|
+
</script>
|
|
693
|
+
|
|
694
|
+
<template>
|
|
695
|
+
<Select
|
|
696
|
+
:items="languages"
|
|
697
|
+
v-model="lang"
|
|
698
|
+
:custom-renderer="languageRenderer"
|
|
699
|
+
placeholder="Select a language..."
|
|
700
|
+
/>
|
|
701
|
+
</template>
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
```vue
|
|
705
|
+
<script setup lang="ts">
|
|
706
|
+
import { ref, h } from 'vue';
|
|
707
|
+
import { Select, SelectItem } from '@smilodon/vue';
|
|
708
|
+
|
|
709
|
+
// Example 2: User selection with avatars
|
|
710
|
+
interface User extends SelectItem {
|
|
711
|
+
email: string;
|
|
712
|
+
avatar: string;
|
|
713
|
+
role: 'Admin' | 'User' | 'Moderator';
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
const userId = ref('');
|
|
717
|
+
|
|
718
|
+
const users: User[] = [
|
|
719
|
+
{
|
|
720
|
+
value: '1',
|
|
721
|
+
label: 'John Doe',
|
|
722
|
+
email: 'john@example.com',
|
|
723
|
+
avatar: 'https://i.pravatar.cc/150?img=1',
|
|
724
|
+
role: 'Admin'
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
value: '2',
|
|
728
|
+
label: 'Jane Smith',
|
|
729
|
+
email: 'jane@example.com',
|
|
730
|
+
avatar: 'https://i.pravatar.cc/150?img=2',
|
|
731
|
+
role: 'User'
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
value: '3',
|
|
735
|
+
label: 'Bob Johnson',
|
|
736
|
+
email: 'bob@example.com',
|
|
737
|
+
avatar: 'https://i.pravatar.cc/150?img=3',
|
|
738
|
+
role: 'Moderator'
|
|
739
|
+
}
|
|
740
|
+
];
|
|
741
|
+
|
|
742
|
+
const userRenderer = (item: User) => {
|
|
743
|
+
return h('div', { style: 'display: flex; align-items: center; gap: 12px; padding: 4px 0;' }, [
|
|
744
|
+
h('img', {
|
|
745
|
+
src: item.avatar,
|
|
746
|
+
alt: item.label,
|
|
747
|
+
style: 'width: 40px; height: 40px; border-radius: 50%; object-fit: cover;'
|
|
748
|
+
}),
|
|
749
|
+
h('div', { style: 'flex: 1;' }, [
|
|
750
|
+
h('div', { style: 'font-weight: 600; color: #1f2937;' }, item.label),
|
|
751
|
+
h('div', { style: 'font-size: 13px; color: #6b7280;' }, item.email)
|
|
752
|
+
]),
|
|
753
|
+
h('span', {
|
|
754
|
+
style: `
|
|
755
|
+
padding: 4px 8px;
|
|
756
|
+
background: ${item.role === 'Admin' ? '#dbeafe' : '#f3f4f6'};
|
|
757
|
+
color: ${item.role === 'Admin' ? '#1e40af' : '#374151'};
|
|
758
|
+
border-radius: 12px;
|
|
759
|
+
font-size: 11px;
|
|
760
|
+
font-weight: 600;
|
|
761
|
+
`
|
|
762
|
+
}, item.role)
|
|
763
|
+
]);
|
|
764
|
+
};
|
|
765
|
+
</script>
|
|
766
|
+
|
|
767
|
+
<template>
|
|
768
|
+
<Select
|
|
769
|
+
:items="users"
|
|
770
|
+
v-model="userId"
|
|
771
|
+
:custom-renderer="userRenderer"
|
|
772
|
+
placeholder="Select a user..."
|
|
773
|
+
/>
|
|
774
|
+
</template>
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
```vue
|
|
778
|
+
<script setup lang="ts">
|
|
779
|
+
import { ref, h } from 'vue';
|
|
780
|
+
import { Select, SelectItem } from '@smilodon/vue';
|
|
781
|
+
|
|
782
|
+
// Example 3: Product selection with images and pricing
|
|
783
|
+
interface Product extends SelectItem {
|
|
784
|
+
price: number;
|
|
785
|
+
stock: number;
|
|
786
|
+
image: string;
|
|
787
|
+
badge?: string;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
const productId = ref('');
|
|
791
|
+
|
|
792
|
+
const products: Product[] = [
|
|
793
|
+
{
|
|
794
|
+
value: 'p1',
|
|
795
|
+
label: 'Premium Laptop',
|
|
796
|
+
price: 1299.99,
|
|
797
|
+
stock: 15,
|
|
798
|
+
image: 'https://via.placeholder.com/60',
|
|
799
|
+
badge: 'Best Seller'
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
value: 'p2',
|
|
803
|
+
label: 'Wireless Mouse',
|
|
804
|
+
price: 29.99,
|
|
805
|
+
stock: 150,
|
|
806
|
+
image: 'https://via.placeholder.com/60'
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
value: 'p3',
|
|
810
|
+
label: 'Mechanical Keyboard',
|
|
811
|
+
price: 89.99,
|
|
812
|
+
stock: 0,
|
|
813
|
+
image: 'https://via.placeholder.com/60',
|
|
814
|
+
badge: 'Out of Stock'
|
|
815
|
+
}
|
|
816
|
+
];
|
|
817
|
+
|
|
818
|
+
const productRenderer = (item: Product) => {
|
|
819
|
+
return h('div', {
|
|
820
|
+
style: `display: flex; align-items: center; gap: 12px; opacity: ${item.stock === 0 ? '0.5' : '1'};`
|
|
821
|
+
}, [
|
|
822
|
+
h('img', {
|
|
823
|
+
src: item.image,
|
|
824
|
+
alt: item.label,
|
|
825
|
+
style: 'width: 60px; height: 60px; border-radius: 8px; object-fit: cover; border: 1px solid #e5e7eb;'
|
|
826
|
+
}),
|
|
827
|
+
h('div', { style: 'flex: 1;' }, [
|
|
828
|
+
h('div', { style: 'display: flex; align-items: center; gap: 8px;' }, [
|
|
829
|
+
h('span', { style: 'font-weight: 600; color: #1f2937;' }, item.label),
|
|
830
|
+
item.badge && h('span', {
|
|
831
|
+
style: `
|
|
832
|
+
padding: 2px 6px;
|
|
833
|
+
background: ${item.badge === 'Best Seller' ? '#dcfce7' : '#fee2e2'};
|
|
834
|
+
color: ${item.badge === 'Best Seller' ? '#166534' : '#991b1b'};
|
|
835
|
+
border-radius: 4px;
|
|
836
|
+
font-size: 10px;
|
|
837
|
+
font-weight: 600;
|
|
838
|
+
`
|
|
839
|
+
}, item.badge)
|
|
840
|
+
]),
|
|
841
|
+
h('div', {
|
|
842
|
+
style: 'margin-top: 4px; display: flex; justify-content: space-between; align-items: center;'
|
|
843
|
+
}, [
|
|
844
|
+
h('span', { style: 'font-size: 16px; font-weight: 700; color: #059669;' }, `$${item.price.toFixed(2)}`),
|
|
845
|
+
h('span', { style: 'font-size: 12px; color: #6b7280;' },
|
|
846
|
+
item.stock > 0 ? `${item.stock} in stock` : 'Out of stock'
|
|
847
|
+
)
|
|
848
|
+
])
|
|
849
|
+
])
|
|
850
|
+
]);
|
|
851
|
+
};
|
|
852
|
+
</script>
|
|
853
|
+
|
|
854
|
+
<template>
|
|
855
|
+
<Select
|
|
856
|
+
:items="products"
|
|
857
|
+
v-model="productId"
|
|
858
|
+
:custom-renderer="productRenderer"
|
|
859
|
+
placeholder="Select a product..."
|
|
860
|
+
/>
|
|
861
|
+
</template>
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
```vue
|
|
865
|
+
<script setup lang="ts">
|
|
866
|
+
import { ref, h } from 'vue';
|
|
867
|
+
import { Select, SelectItem } from '@smilodon/vue';
|
|
868
|
+
|
|
869
|
+
// Example 4: Status indicators with conditional styling
|
|
870
|
+
interface Task extends SelectItem {
|
|
871
|
+
status: 'completed' | 'in-progress' | 'pending';
|
|
872
|
+
priority: 'high' | 'medium' | 'low';
|
|
873
|
+
assignee: string;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
const taskId = ref('');
|
|
877
|
+
|
|
878
|
+
const tasks: Task[] = [
|
|
879
|
+
{ value: 't1', label: 'Design Homepage', status: 'completed', priority: 'high', assignee: 'John' },
|
|
880
|
+
{ value: 't2', label: 'API Integration', status: 'in-progress', priority: 'high', assignee: 'Jane' },
|
|
881
|
+
{ value: 't3', label: 'Write Documentation', status: 'pending', priority: 'medium', assignee: 'Bob' },
|
|
882
|
+
{ value: 't4', label: 'Bug Fixes', status: 'in-progress', priority: 'low', assignee: 'Alice' }
|
|
883
|
+
];
|
|
884
|
+
|
|
885
|
+
const statusConfig = {
|
|
886
|
+
'completed': { bg: '#dcfce7', color: '#166534', icon: 'â' },
|
|
887
|
+
'in-progress': { bg: '#dbeafe', color: '#1e40af', icon: 'âģ' },
|
|
888
|
+
'pending': { bg: '#fef3c7', color: '#92400e', icon: 'â' }
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
const priorityColors = {
|
|
892
|
+
'high': '#ef4444',
|
|
893
|
+
'medium': '#f59e0b',
|
|
894
|
+
'low': '#10b981'
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
const taskRenderer = (item: Task) => {
|
|
898
|
+
const status = statusConfig[item.status];
|
|
899
|
+
return h('div', { style: 'display: flex; align-items: center; gap: 10px; padding: 4px 0;' }, [
|
|
900
|
+
h('div', {
|
|
901
|
+
style: `
|
|
902
|
+
width: 24px;
|
|
903
|
+
height: 24px;
|
|
904
|
+
border-radius: 50%;
|
|
905
|
+
background: ${status.bg};
|
|
906
|
+
color: ${status.color};
|
|
907
|
+
display: flex;
|
|
908
|
+
align-items: center;
|
|
909
|
+
justify-content: center;
|
|
910
|
+
font-weight: bold;
|
|
911
|
+
`
|
|
912
|
+
}, status.icon),
|
|
913
|
+
h('div', { style: 'flex: 1;' }, [
|
|
914
|
+
h('div', { style: 'font-weight: 600; color: #1f2937;' }, item.label),
|
|
915
|
+
h('div', { style: 'font-size: 12px; color: #6b7280; margin-top: 2px;' }, `Assigned to ${item.assignee}`)
|
|
916
|
+
]),
|
|
917
|
+
h('div', {
|
|
918
|
+
style: `
|
|
919
|
+
width: 8px;
|
|
920
|
+
height: 8px;
|
|
921
|
+
border-radius: 50%;
|
|
922
|
+
background: ${priorityColors[item.priority]};
|
|
923
|
+
`,
|
|
924
|
+
title: `${item.priority} priority`
|
|
925
|
+
})
|
|
926
|
+
]);
|
|
927
|
+
};
|
|
928
|
+
</script>
|
|
929
|
+
|
|
930
|
+
<template>
|
|
931
|
+
<Select
|
|
932
|
+
:items="tasks"
|
|
933
|
+
v-model="taskId"
|
|
934
|
+
:custom-renderer="taskRenderer"
|
|
935
|
+
placeholder="Select a task..."
|
|
936
|
+
/>
|
|
937
|
+
</template>
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
```vue
|
|
941
|
+
<script setup lang="ts">
|
|
942
|
+
import { ref, h } from 'vue';
|
|
943
|
+
import { Select, SelectItem } from '@smilodon/vue';
|
|
944
|
+
|
|
945
|
+
// Example 5: Using HTML string (simpler alternative)
|
|
946
|
+
interface Tag extends SelectItem {
|
|
947
|
+
color: string;
|
|
948
|
+
count: number;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
const tag = ref('');
|
|
952
|
+
|
|
953
|
+
const tags: Tag[] = [
|
|
954
|
+
{ value: 'react', label: 'React', color: 'blue', count: 1250 },
|
|
955
|
+
{ value: 'vue', label: 'Vue', color: 'green', count: 850 },
|
|
956
|
+
{ value: 'angular', label: 'Angular', color: 'red', count: 420 }
|
|
957
|
+
];
|
|
958
|
+
|
|
959
|
+
// Using HTML string renderer (returned from custom prop)
|
|
960
|
+
const tagRenderer = (item: Tag) => {
|
|
961
|
+
return `
|
|
962
|
+
<div style="display: flex; align-items: center; justify-content: space-between; padding: 8px;">
|
|
963
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
964
|
+
<span style="width: 12px; height: 12px; border-radius: 50%; background: ${item.color};"></span>
|
|
965
|
+
<span style="font-weight: 600; color: #1f2937;">${item.label}</span>
|
|
966
|
+
</div>
|
|
967
|
+
<span style="font-size: 14px; color: #6b7280;">${item.count} posts</span>
|
|
968
|
+
</div>
|
|
969
|
+
`;
|
|
970
|
+
};
|
|
971
|
+
</script>
|
|
972
|
+
|
|
973
|
+
<template>
|
|
974
|
+
<Select
|
|
975
|
+
:items="tags"
|
|
976
|
+
v-model="tag"
|
|
977
|
+
:option-template="tagRenderer"
|
|
978
|
+
placeholder="Select a tag..."
|
|
979
|
+
/>
|
|
980
|
+
</template>
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
### Comparison: When to Use Each Method
|
|
984
|
+
|
|
985
|
+
| Feature | Method 1: Object Arrays | Method 2: Custom Renderers |
|
|
986
|
+
|---------|------------------------|---------------------------|
|
|
987
|
+
| **Setup Complexity** | â Simple | ââ Moderate |
|
|
988
|
+
| **Rendering Speed** | âââ Fastest | ââ Fast |
|
|
989
|
+
| **Visual Customization** | ââ Limited | âââ Unlimited |
|
|
990
|
+
| **Vue Integration** | âââ Seamless | âââ Seamless |
|
|
991
|
+
| **Reactivity** | âââ Full | âââ Full |
|
|
992
|
+
| **TypeScript Support** | âââ Full | âââ Full |
|
|
993
|
+
| **Performance (1M items)** | âââ Excellent | ââ Good |
|
|
994
|
+
| **Learning Curve** | â Easy | ââ Medium |
|
|
995
|
+
|
|
996
|
+
**Best Practices**:
|
|
997
|
+
|
|
998
|
+
â
**Use Method 1 (Object Arrays) when**:
|
|
999
|
+
- You need simple text-based options
|
|
1000
|
+
- Performance is critical (millions of items)
|
|
1001
|
+
- You want minimal code
|
|
1002
|
+
- Built-in search/filter is sufficient
|
|
1003
|
+
- Working with external APIs returning plain data
|
|
1004
|
+
|
|
1005
|
+
â
**Use Method 2 (Custom Renderers) when**:
|
|
1006
|
+
- You need images, icons, or badges
|
|
1007
|
+
- Options require multiple lines of text
|
|
1008
|
+
- Custom styling/layout is important
|
|
1009
|
+
- Conditional rendering based on data
|
|
1010
|
+
- Rich user experience is priority
|
|
1011
|
+
- Need reactive computed properties in rendering
|
|
1012
|
+
|
|
1013
|
+
### Combining Both Methods
|
|
1014
|
+
|
|
1015
|
+
You can start with Method 1 and add Method 2 later as your UI evolves:
|
|
1016
|
+
|
|
1017
|
+
```vue
|
|
1018
|
+
<script setup lang="ts">
|
|
1019
|
+
import { ref, h } from 'vue';
|
|
1020
|
+
import { Select } from '@smilodon/vue';
|
|
1021
|
+
|
|
1022
|
+
const value = ref('');
|
|
1023
|
+
|
|
1024
|
+
// Start simple
|
|
1025
|
+
const items = ['Option 1', 'Option 2', 'Option 3'];
|
|
1026
|
+
|
|
1027
|
+
// Later, add custom rendering without changing items
|
|
1028
|
+
const customRenderer = (item: any, index: number) => {
|
|
1029
|
+
return h('div', {
|
|
1030
|
+
style: `padding: 8px; background: ${index % 2 ? '#f9fafb' : 'white'};`
|
|
1031
|
+
}, [
|
|
1032
|
+
h('strong', item.label || item)
|
|
1033
|
+
]);
|
|
1034
|
+
};
|
|
1035
|
+
</script>
|
|
1036
|
+
|
|
1037
|
+
<template>
|
|
1038
|
+
<Select
|
|
1039
|
+
:items="items"
|
|
1040
|
+
v-model="value"
|
|
1041
|
+
:custom-renderer="customRenderer"
|
|
1042
|
+
/>
|
|
1043
|
+
</template>
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
### Performance Tips
|
|
1047
|
+
|
|
1048
|
+
**For Method 1**:
|
|
1049
|
+
- Use `computed` to memoize large item arrays
|
|
1050
|
+
- Enable `virtualized` prop for 1000+ items
|
|
1051
|
+
- Enable `infiniteScroll` for dynamic loading
|
|
1052
|
+
|
|
1053
|
+
**For Method 2**:
|
|
1054
|
+
- Keep renderer function pure (no side effects)
|
|
1055
|
+
- Use `computed` for derived data
|
|
1056
|
+
- Avoid heavy computations in renderer
|
|
1057
|
+
- Cache renderer functions when possible
|
|
1058
|
+
|
|
1059
|
+
```vue
|
|
1060
|
+
<script setup lang="ts">
|
|
1061
|
+
import { ref, computed, h } from 'vue';
|
|
1062
|
+
import { Select } from '@smilodon/vue';
|
|
1063
|
+
|
|
1064
|
+
const value = ref('');
|
|
1065
|
+
|
|
1066
|
+
// Memoize items with computed
|
|
1067
|
+
const items = computed(() =>
|
|
1068
|
+
Array.from({ length: 10000 }, (_, i) => ({
|
|
1069
|
+
value: i.toString(),
|
|
1070
|
+
label: `Item ${i + 1}`,
|
|
1071
|
+
description: `Description for item ${i + 1}`
|
|
1072
|
+
}))
|
|
1073
|
+
);
|
|
1074
|
+
|
|
1075
|
+
// Pure renderer function
|
|
1076
|
+
const renderer = (item: any, index: number) => {
|
|
1077
|
+
return h('div', [
|
|
1078
|
+
h('div', { style: 'font-weight: 600;' }, item.label),
|
|
1079
|
+
h('div', { style: 'font-size: 12px; color: #666;' }, item.description)
|
|
1080
|
+
]);
|
|
1081
|
+
};
|
|
1082
|
+
</script>
|
|
1083
|
+
|
|
1084
|
+
<template>
|
|
1085
|
+
<Select
|
|
1086
|
+
:items="items"
|
|
1087
|
+
v-model="value"
|
|
1088
|
+
:custom-renderer="renderer"
|
|
1089
|
+
virtualized
|
|
1090
|
+
:estimated-item-height="60"
|
|
1091
|
+
/>
|
|
1092
|
+
</template>
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
---
|
|
1096
|
+
|
|
288
1097
|
## API Reference
|
|
289
1098
|
|
|
290
1099
|
### Props
|
package/dist/index.cjs
CHANGED
|
@@ -107,9 +107,14 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
107
107
|
currentValue,
|
|
108
108
|
(newValue) => {
|
|
109
109
|
safeCall((el) => {
|
|
110
|
+
var _a;
|
|
110
111
|
if (newValue !== void 0) {
|
|
111
|
-
const
|
|
112
|
-
|
|
112
|
+
const currentSelected = ((_a = el.getSelectedValues) == null ? void 0 : _a.call(el)) || [];
|
|
113
|
+
const newValues = Array.isArray(newValue) ? newValue : [newValue];
|
|
114
|
+
const hasChanged = currentSelected.length !== newValues.length || !currentSelected.every((v, i) => v === newValues[i]);
|
|
115
|
+
if (hasChanged) {
|
|
116
|
+
el.setSelectedValues(newValues);
|
|
117
|
+
}
|
|
113
118
|
}
|
|
114
119
|
});
|
|
115
120
|
},
|
|
@@ -279,7 +284,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
279
284
|
}
|
|
280
285
|
return target;
|
|
281
286
|
};
|
|
282
|
-
const Select = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
287
|
+
const Select = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-66a277ce"]]);
|
|
283
288
|
exports.Select = Select;
|
|
284
289
|
exports.default = Select;
|
|
285
290
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/Select.vue"],"sourcesContent":["<!--\n Smilodon Select Component for Vue 3\n \n A production-ready, accessible select component with advanced features:\n - Single and multi-select modes\n - Searchable with client or server-side filtering\n - Infinite scroll and virtual scrolling for large datasets\n - Grouped options\n - Custom rendering\n - Full keyboard navigation\n - WCAG 2.1 AAA compliant\n \n @example\n <Select\n :items=\"items\"\n v-model=\"selectedValue\"\n searchable\n placeholder=\"Select an option...\"\n />\n-->\n\n<template>\n <enhanced-select\n ref=\"selectRef\"\n :class=\"className\"\n :style=\"style\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, watch, onMounted, onBeforeUnmount, computed } from 'vue';\nimport type {\n SelectEventDetail,\n OpenEventDetail,\n CloseEventDetail,\n SearchEventDetail,\n ChangeEventDetail,\n LoadMoreEventDetail,\n GroupedItem,\n} from '@smilodon/core';\n\nexport interface SelectItem {\n value: string | number;\n label: string;\n disabled?: boolean;\n group?: string;\n [key: string]: any;\n}\n\nexport interface SelectProps {\n /** Array of items to display in the select */\n items?: SelectItem[];\n /** Grouped items (alternative to items) */\n groupedItems?: GroupedItem[];\n /** Selected value(s) - for v-model binding */\n modelValue?: string | number | (string | number)[];\n /** Default value for uncontrolled mode */\n defaultValue?: string | number | (string | number)[];\n /** Enable multi-select mode */\n multiple?: boolean;\n /** Enable search functionality */\n searchable?: boolean;\n /** Placeholder text */\n placeholder?: string;\n /** Disable the select */\n disabled?: boolean;\n /** Mark as required */\n required?: boolean;\n /** Show error state */\n error?: boolean;\n /** Enable infinite scroll */\n infiniteScroll?: boolean;\n /** Number of items per page (for infinite scroll) */\n pageSize?: number;\n /** Enable virtual scrolling */\n virtualized?: boolean;\n /** Maximum number of selections (for multi-select) */\n maxSelections?: number;\n /** Dropdown placement */\n placement?: 'bottom' | 'top' | 'auto';\n /** Custom CSS class */\n className?: string;\n /** Custom inline styles */\n style?: Record<string, string>;\n /** Enable expandable dropdown */\n expandable?: boolean;\n}\n\nexport interface SelectEmits {\n /** Emitted when selection changes - for v-model */\n (e: 'update:modelValue', value: string | number | (string | number)[]): void;\n /** Emitted when selection changes with full details */\n (e: 'change', value: string | number | (string | number)[], selectedItems: SelectItem[]): void;\n /** Emitted when an item is selected */\n (e: 'select', item: SelectItem, index: number): void;\n /** Emitted when dropdown opens */\n (e: 'open'): void;\n /** Emitted when dropdown closes */\n (e: 'close'): void;\n /** Emitted when search query changes */\n (e: 'search', query: string): void;\n /** Emitted when more items are requested (infinite scroll) */\n (e: 'loadMore', page: number): void;\n /** Emitted when user creates a new item (if enabled) */\n (e: 'create', value: string): void;\n}\n\nconst props = withDefaults(defineProps<SelectProps>(), {\n items: () => [],\n multiple: false,\n searchable: false,\n disabled: false,\n required: false,\n error: false,\n infiniteScroll: false,\n pageSize: 50,\n virtualized: true,\n placement: 'auto',\n});\n\nconst emit = defineEmits<SelectEmits>();\n\nconst selectRef = ref<HTMLElement | null>(null);\nconst isElementReady = ref(false);\nconst internalValue = ref<string | number | (string | number)[] | undefined>(\n props.defaultValue\n);\n\nconst waitForUpgrade = async () => {\n if (typeof window === 'undefined') return;\n\n // Ensure the module is loaded (it registers the custom element on import)\n if (!customElements.get('enhanced-select')) {\n await import('@smilodon/core');\n }\n\n const el = selectRef.value as any;\n if (!el) return;\n\n // Wait until the element is upgraded and its methods exist.\n // In some environments, the tag can be defined but the particular instance\n // hasn't been upgraded yet when watchers/mounted run.\n try {\n await customElements.whenDefined('enhanced-select');\n } catch {\n // ignore\n }\n\n // Retry a few frames to let the browser upgrade the instance.\n for (let i = 0; i < 5; i++) {\n const candidate = selectRef.value as any;\n if (candidate && typeof candidate.setItems === 'function') {\n isElementReady.value = true;\n return;\n }\n await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));\n }\n\n isElementReady.value = typeof (selectRef.value as any)?.setItems === 'function';\n};\n\nconst safeCall = (fn: (el: any) => void) => {\n const el = selectRef.value as any;\n if (!el || !isElementReady.value) return;\n fn(el);\n};\n\n// Check if component is controlled\nconst isControlled = computed(() => props.modelValue !== undefined);\n\n// Get current value\nconst currentValue = computed(() =>\n isControlled.value ? props.modelValue : internalValue.value\n);\n\n// Sync items to web component\nwatch(\n () => props.items,\n (newItems) => {\n safeCall((el) => {\n if (newItems) el.setItems(newItems);\n });\n },\n { deep: true }\n);\n\n// Sync grouped items to web component\nwatch(\n () => props.groupedItems,\n (newGroups) => {\n safeCall((el) => {\n if (newGroups) el.setGroupedItems(newGroups);\n });\n },\n { deep: true }\n);\n\n// Sync value to web component\nwatch(\n currentValue,\n (newValue) => {\n safeCall((el) => {\n if (newValue !== undefined) {\n const values = Array.isArray(newValue) ? newValue : [newValue];\n el.setSelectedValues(values);\n }\n });\n },\n { immediate: true }\n);\n\n// Sync configuration\nconst updateConfig = () => {\n safeCall((el) => {\n const config = {\n searchable: props.searchable,\n placeholder: props.placeholder,\n enabled: !props.disabled,\n virtualize: props.virtualized,\n selection: {\n mode: props.multiple ? 'multi' : 'single',\n maxSelections: props.maxSelections,\n },\n infiniteScroll: {\n enabled: props.infiniteScroll,\n pageSize: props.pageSize,\n },\n expandable: {\n enabled: props.expandable,\n },\n };\n\n el.updateConfig(config);\n });\n};\n\nwatch(\n [\n () => props.searchable,\n () => props.placeholder,\n () => props.disabled,\n () => props.multiple,\n () => props.maxSelections,\n () => props.infiniteScroll,\n () => props.pageSize,\n () => props.virtualized,\n () => props.expandable,\n ],\n updateConfig\n);\n\n// Event handlers\nconst handleSelect = (e: Event) => {\n const customEvent = e as CustomEvent<SelectEventDetail>;\n const { item, index } = customEvent.detail;\n emit('select', item as SelectItem, index);\n};\n\nconst handleChange = (e: Event) => {\n const customEvent = e as CustomEvent<ChangeEventDetail>;\n const { selectedItems, selectedValues } = customEvent.detail;\n\n const values = selectedValues as (string | number)[];\n\n // Update internal value in uncontrolled mode\n if (!isControlled.value) {\n internalValue.value = props.multiple ? values : values[0];\n }\n\n // Emit events\n const value = props.multiple ? values : values[0];\n emit('update:modelValue', value);\n emit('change', value, selectedItems as SelectItem[]);\n};\n\nconst handleOpen = () => {\n emit('open');\n};\n\nconst handleClose = () => {\n emit('close');\n};\n\nconst handleSearch = (e: Event) => {\n const customEvent = e as CustomEvent<SearchEventDetail>;\n emit('search', customEvent.detail.query);\n};\n\nconst handleLoadMore = (e: Event) => {\n const customEvent = e as CustomEvent<LoadMoreEventDetail>;\n emit('loadMore', customEvent.detail.page);\n};\n\nconst handleCreate = (e: Event) => {\n const customEvent = e as CustomEvent<{ value: string }>;\n emit('create', customEvent.detail.value);\n};\n\n// Setup event listeners\nonMounted(async () => {\n await waitForUpgrade();\n if (!selectRef.value || !isElementReady.value) return;\n\n const element = selectRef.value as any;\n\n // Initial configuration\n updateConfig();\n\n if (props.placement) {\n element.setAttribute('placement', props.placement);\n }\n\n // Set initial items\n if (props.items?.length) {\n element.setItems(props.items);\n }\n if (props.groupedItems?.length) {\n element.setGroupedItems(props.groupedItems);\n }\n\n // Set initial value\n if (currentValue.value !== undefined) {\n const values = Array.isArray(currentValue.value)\n ? currentValue.value\n : [currentValue.value];\n element.setSelectedValues(values);\n }\n\n // Add event listeners\n element.addEventListener('select', handleSelect as EventListener);\n element.addEventListener('change', handleChange as EventListener);\n element.addEventListener('open', handleOpen as EventListener);\n element.addEventListener('close', handleClose as EventListener);\n element.addEventListener('search', handleSearch as EventListener);\n element.addEventListener('loadMore', handleLoadMore as EventListener);\n element.addEventListener('create', handleCreate as EventListener);\n});\n\nonBeforeUnmount(() => {\n if (!selectRef.value) return;\n\n const element = selectRef.value;\n\n // Remove event listeners\n element.removeEventListener('select', handleSelect as EventListener);\n element.removeEventListener('change', handleChange as EventListener);\n element.removeEventListener('open', handleOpen as EventListener);\n element.removeEventListener('close', handleClose as EventListener);\n element.removeEventListener('search', handleSearch as EventListener);\n element.removeEventListener('loadMore', handleLoadMore as EventListener);\n element.removeEventListener('create', handleCreate as EventListener);\n});\n\n// Expose imperative API\ndefineExpose({\n /** Open the dropdown */\n open: () => {\n (selectRef.value as any)?.open();\n },\n /** Close the dropdown */\n close: () => {\n (selectRef.value as any)?.close();\n },\n /** Focus the select */\n focus: () => {\n selectRef.value?.focus();\n },\n /** Set items programmatically */\n setItems: (items: SelectItem[]) => {\n (selectRef.value as any)?.setItems(items);\n },\n /** Set grouped items programmatically */\n setGroupedItems: (groups: GroupedItem[]) => {\n (selectRef.value as any)?.setGroupedItems(groups);\n },\n /** Clear selection */\n clear: () => {\n (selectRef.value as any)?.setSelectedValues([]);\n if (!isControlled.value) {\n internalValue.value = props.multiple ? [] : undefined;\n }\n const value = props.multiple ? [] : '';\n emit('update:modelValue', value);\n emit('change', value, []);\n },\n});\n</script>\n\n<style scoped>\n/* Component uses web component styling from @smilodon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AC5C;AAAA;AAAA,MAEA,OAAO,MAAM;;AACV,wBAAU,UAAV,mBAAyB,kBAAkB;AAC5C,YAAI,CAAC,aAAa,OAAO;AACvB,wBAAc,QAAQ,MAAM,WAAW,CAAA,IAAK;AAAA,QAC9C;AACA,cAAM,QAAQ,MAAM,WAAW,CAAA,IAAK;AACpC,aAAK,qBAAqB,KAAK;AAC/B,aAAK,UAAU,OAAO,EAAE;AAAA,MAC1B;AAAA,IAAA,CACD;;;8BA3WCC,IAAAA,YAIE,4BAAA;AAAA,iBAHI;AAAA,QAAJ,KAAI;AAAA,QACH,0BAAO,QAAA,SAAS;AAAA,QAChB,0BAAO,QAAA,KAAK;AAAA,MAAA;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/Select.vue"],"sourcesContent":["<!--\n Smilodon Select Component for Vue 3\n \n A production-ready, accessible select component with advanced features:\n - Single and multi-select modes\n - Searchable with client or server-side filtering\n - Infinite scroll and virtual scrolling for large datasets\n - Grouped options\n - Custom rendering\n - Full keyboard navigation\n - WCAG 2.1 AAA compliant\n \n @example\n <Select\n :items=\"items\"\n v-model=\"selectedValue\"\n searchable\n placeholder=\"Select an option...\"\n />\n-->\n\n<template>\n <enhanced-select\n ref=\"selectRef\"\n :class=\"className\"\n :style=\"style\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, watch, onMounted, onBeforeUnmount, computed } from 'vue';\nimport type {\n SelectEventDetail,\n OpenEventDetail,\n CloseEventDetail,\n SearchEventDetail,\n ChangeEventDetail,\n LoadMoreEventDetail,\n GroupedItem,\n} from '@smilodon/core';\n\nexport interface SelectItem {\n value: string | number;\n label: string;\n disabled?: boolean;\n group?: string;\n [key: string]: any;\n}\n\nexport interface SelectProps {\n /** Array of items to display in the select */\n items?: SelectItem[];\n /** Grouped items (alternative to items) */\n groupedItems?: GroupedItem[];\n /** Selected value(s) - for v-model binding */\n modelValue?: string | number | (string | number)[];\n /** Default value for uncontrolled mode */\n defaultValue?: string | number | (string | number)[];\n /** Enable multi-select mode */\n multiple?: boolean;\n /** Enable search functionality */\n searchable?: boolean;\n /** Placeholder text */\n placeholder?: string;\n /** Disable the select */\n disabled?: boolean;\n /** Mark as required */\n required?: boolean;\n /** Show error state */\n error?: boolean;\n /** Enable infinite scroll */\n infiniteScroll?: boolean;\n /** Number of items per page (for infinite scroll) */\n pageSize?: number;\n /** Enable virtual scrolling */\n virtualized?: boolean;\n /** Maximum number of selections (for multi-select) */\n maxSelections?: number;\n /** Dropdown placement */\n placement?: 'bottom' | 'top' | 'auto';\n /** Custom CSS class */\n className?: string;\n /** Custom inline styles */\n style?: Record<string, string>;\n /** Enable expandable dropdown */\n expandable?: boolean;\n}\n\nexport interface SelectEmits {\n /** Emitted when selection changes - for v-model */\n (e: 'update:modelValue', value: string | number | (string | number)[]): void;\n /** Emitted when selection changes with full details */\n (e: 'change', value: string | number | (string | number)[], selectedItems: SelectItem[]): void;\n /** Emitted when an item is selected */\n (e: 'select', item: SelectItem, index: number): void;\n /** Emitted when dropdown opens */\n (e: 'open'): void;\n /** Emitted when dropdown closes */\n (e: 'close'): void;\n /** Emitted when search query changes */\n (e: 'search', query: string): void;\n /** Emitted when more items are requested (infinite scroll) */\n (e: 'loadMore', page: number): void;\n /** Emitted when user creates a new item (if enabled) */\n (e: 'create', value: string): void;\n}\n\nconst props = withDefaults(defineProps<SelectProps>(), {\n items: () => [],\n multiple: false,\n searchable: false,\n disabled: false,\n required: false,\n error: false,\n infiniteScroll: false,\n pageSize: 50,\n virtualized: true,\n placement: 'auto',\n});\n\nconst emit = defineEmits<SelectEmits>();\n\nconst selectRef = ref<HTMLElement | null>(null);\nconst isElementReady = ref(false);\nconst internalValue = ref<string | number | (string | number)[] | undefined>(\n props.defaultValue\n);\n\nconst waitForUpgrade = async () => {\n if (typeof window === 'undefined') return;\n\n // Ensure the module is loaded (it registers the custom element on import)\n if (!customElements.get('enhanced-select')) {\n await import('@smilodon/core');\n }\n\n const el = selectRef.value as any;\n if (!el) return;\n\n // Wait until the element is upgraded and its methods exist.\n // In some environments, the tag can be defined but the particular instance\n // hasn't been upgraded yet when watchers/mounted run.\n try {\n await customElements.whenDefined('enhanced-select');\n } catch {\n // ignore\n }\n\n // Retry a few frames to let the browser upgrade the instance.\n for (let i = 0; i < 5; i++) {\n const candidate = selectRef.value as any;\n if (candidate && typeof candidate.setItems === 'function') {\n isElementReady.value = true;\n return;\n }\n await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));\n }\n\n isElementReady.value = typeof (selectRef.value as any)?.setItems === 'function';\n};\n\nconst safeCall = (fn: (el: any) => void) => {\n const el = selectRef.value as any;\n if (!el || !isElementReady.value) return;\n fn(el);\n};\n\n// Check if component is controlled\nconst isControlled = computed(() => props.modelValue !== undefined);\n\n// Get current value\nconst currentValue = computed(() =>\n isControlled.value ? props.modelValue : internalValue.value\n);\n\n// Sync items to web component\nwatch(\n () => props.items,\n (newItems) => {\n safeCall((el) => {\n if (newItems) el.setItems(newItems);\n });\n },\n { deep: true }\n);\n\n// Sync grouped items to web component\nwatch(\n () => props.groupedItems,\n (newGroups) => {\n safeCall((el) => {\n if (newGroups) el.setGroupedItems(newGroups);\n });\n },\n { deep: true }\n);\n\n// Sync value to web component\nwatch(\n currentValue,\n (newValue) => {\n safeCall((el) => {\n if (newValue !== undefined) {\n // Get current selected values from the element to avoid infinite loop\n const currentSelected = el.getSelectedValues?.() || [];\n const newValues = Array.isArray(newValue) ? newValue : [newValue];\n \n // Only update if values have actually changed\n const hasChanged = \n currentSelected.length !== newValues.length ||\n !currentSelected.every((v: any, i: number) => v === newValues[i]);\n \n if (hasChanged) {\n el.setSelectedValues(newValues);\n }\n }\n });\n },\n { immediate: true }\n);\n\n// Sync configuration\nconst updateConfig = () => {\n safeCall((el) => {\n const config = {\n searchable: props.searchable,\n placeholder: props.placeholder,\n enabled: !props.disabled,\n virtualize: props.virtualized,\n selection: {\n mode: props.multiple ? 'multi' : 'single',\n maxSelections: props.maxSelections,\n },\n infiniteScroll: {\n enabled: props.infiniteScroll,\n pageSize: props.pageSize,\n },\n expandable: {\n enabled: props.expandable,\n },\n };\n\n el.updateConfig(config);\n });\n};\n\nwatch(\n [\n () => props.searchable,\n () => props.placeholder,\n () => props.disabled,\n () => props.multiple,\n () => props.maxSelections,\n () => props.infiniteScroll,\n () => props.pageSize,\n () => props.virtualized,\n () => props.expandable,\n ],\n updateConfig\n);\n\n// Event handlers\nconst handleSelect = (e: Event) => {\n const customEvent = e as CustomEvent<SelectEventDetail>;\n const { item, index } = customEvent.detail;\n emit('select', item as SelectItem, index);\n};\n\nconst handleChange = (e: Event) => {\n const customEvent = e as CustomEvent<ChangeEventDetail>;\n const { selectedItems, selectedValues } = customEvent.detail;\n\n const values = selectedValues as (string | number)[];\n\n // Update internal value in uncontrolled mode\n if (!isControlled.value) {\n internalValue.value = props.multiple ? values : values[0];\n }\n\n // Emit events\n const value = props.multiple ? values : values[0];\n emit('update:modelValue', value);\n emit('change', value, selectedItems as SelectItem[]);\n};\n\nconst handleOpen = () => {\n emit('open');\n};\n\nconst handleClose = () => {\n emit('close');\n};\n\nconst handleSearch = (e: Event) => {\n const customEvent = e as CustomEvent<SearchEventDetail>;\n emit('search', customEvent.detail.query);\n};\n\nconst handleLoadMore = (e: Event) => {\n const customEvent = e as CustomEvent<LoadMoreEventDetail>;\n emit('loadMore', customEvent.detail.page);\n};\n\nconst handleCreate = (e: Event) => {\n const customEvent = e as CustomEvent<{ value: string }>;\n emit('create', customEvent.detail.value);\n};\n\n// Setup event listeners\nonMounted(async () => {\n await waitForUpgrade();\n if (!selectRef.value || !isElementReady.value) return;\n\n const element = selectRef.value as any;\n\n // Initial configuration\n updateConfig();\n\n if (props.placement) {\n element.setAttribute('placement', props.placement);\n }\n\n // Set initial items\n if (props.items?.length) {\n element.setItems(props.items);\n }\n if (props.groupedItems?.length) {\n element.setGroupedItems(props.groupedItems);\n }\n\n // Set initial value\n if (currentValue.value !== undefined) {\n const values = Array.isArray(currentValue.value)\n ? currentValue.value\n : [currentValue.value];\n element.setSelectedValues(values);\n }\n\n // Add event listeners\n element.addEventListener('select', handleSelect as EventListener);\n element.addEventListener('change', handleChange as EventListener);\n element.addEventListener('open', handleOpen as EventListener);\n element.addEventListener('close', handleClose as EventListener);\n element.addEventListener('search', handleSearch as EventListener);\n element.addEventListener('loadMore', handleLoadMore as EventListener);\n element.addEventListener('create', handleCreate as EventListener);\n});\n\nonBeforeUnmount(() => {\n if (!selectRef.value) return;\n\n const element = selectRef.value;\n\n // Remove event listeners\n element.removeEventListener('select', handleSelect as EventListener);\n element.removeEventListener('change', handleChange as EventListener);\n element.removeEventListener('open', handleOpen as EventListener);\n element.removeEventListener('close', handleClose as EventListener);\n element.removeEventListener('search', handleSearch as EventListener);\n element.removeEventListener('loadMore', handleLoadMore as EventListener);\n element.removeEventListener('create', handleCreate as EventListener);\n});\n\n// Expose imperative API\ndefineExpose({\n /** Open the dropdown */\n open: () => {\n (selectRef.value as any)?.open();\n },\n /** Close the dropdown */\n close: () => {\n (selectRef.value as any)?.close();\n },\n /** Focus the select */\n focus: () => {\n selectRef.value?.focus();\n },\n /** Set items programmatically */\n setItems: (items: SelectItem[]) => {\n (selectRef.value as any)?.setItems(items);\n },\n /** Set grouped items programmatically */\n setGroupedItems: (groups: GroupedItem[]) => {\n (selectRef.value as any)?.setGroupedItems(groups);\n },\n /** Clear selection */\n clear: () => {\n (selectRef.value as any)?.setSelectedValues([]);\n if (!isControlled.value) {\n internalValue.value = props.multiple ? [] : undefined;\n }\n const value = props.multiple ? [] : '';\n emit('update:modelValue', value);\n emit('change', value, []);\n },\n});\n</script>\n\n<style scoped>\n/* Component uses web component styling from @smilodon/core */\n</style>\n"],"names":["ref","computed","watch","onMounted","onBeforeUnmount","_createBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GA,UAAM,QAAQ;AAad,UAAM,OAAO;AAEb,UAAM,YAAYA,IAAAA,IAAwB,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C;AAAA;AAAA,MAEA,OAAO,MAAM;;AACV,wBAAU,UAAV,mBAAyB,kBAAkB;AAC5C,YAAI,CAAC,aAAa,OAAO;AACvB,wBAAc,QAAQ,MAAM,WAAW,CAAA,IAAK;AAAA,QAC9C;AACA,cAAM,QAAQ,MAAM,WAAW,CAAA,IAAK;AACpC,aAAK,qBAAqB,KAAK;AAC/B,aAAK,UAAU,OAAO,EAAE;AAAA,MAC1B;AAAA,IAAA,CACD;;;8BArXCC,IAAAA,YAIE,4BAAA;AAAA,iBAHI;AAAA,QAAJ,KAAI;AAAA,QACH,0BAAO,QAAA,SAAS;AAAA,QAChB,0BAAO,QAAA,KAAK;AAAA,MAAA;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -83,9 +83,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
83
83
|
currentValue,
|
|
84
84
|
(newValue) => {
|
|
85
85
|
safeCall((el) => {
|
|
86
|
+
var _a;
|
|
86
87
|
if (newValue !== void 0) {
|
|
87
|
-
const
|
|
88
|
-
|
|
88
|
+
const currentSelected = ((_a = el.getSelectedValues) == null ? void 0 : _a.call(el)) || [];
|
|
89
|
+
const newValues = Array.isArray(newValue) ? newValue : [newValue];
|
|
90
|
+
const hasChanged = currentSelected.length !== newValues.length || !currentSelected.every((v, i) => v === newValues[i]);
|
|
91
|
+
if (hasChanged) {
|
|
92
|
+
el.setSelectedValues(newValues);
|
|
93
|
+
}
|
|
89
94
|
}
|
|
90
95
|
});
|
|
91
96
|
},
|
|
@@ -255,7 +260,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
255
260
|
}
|
|
256
261
|
return target;
|
|
257
262
|
};
|
|
258
|
-
const Select = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
263
|
+
const Select = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-66a277ce"]]);
|
|
259
264
|
export {
|
|
260
265
|
Select,
|
|
261
266
|
Select as default
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/Select.vue"],"sourcesContent":["<!--\n Smilodon Select Component for Vue 3\n \n A production-ready, accessible select component with advanced features:\n - Single and multi-select modes\n - Searchable with client or server-side filtering\n - Infinite scroll and virtual scrolling for large datasets\n - Grouped options\n - Custom rendering\n - Full keyboard navigation\n - WCAG 2.1 AAA compliant\n \n @example\n <Select\n :items=\"items\"\n v-model=\"selectedValue\"\n searchable\n placeholder=\"Select an option...\"\n />\n-->\n\n<template>\n <enhanced-select\n ref=\"selectRef\"\n :class=\"className\"\n :style=\"style\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, watch, onMounted, onBeforeUnmount, computed } from 'vue';\nimport type {\n SelectEventDetail,\n OpenEventDetail,\n CloseEventDetail,\n SearchEventDetail,\n ChangeEventDetail,\n LoadMoreEventDetail,\n GroupedItem,\n} from '@smilodon/core';\n\nexport interface SelectItem {\n value: string | number;\n label: string;\n disabled?: boolean;\n group?: string;\n [key: string]: any;\n}\n\nexport interface SelectProps {\n /** Array of items to display in the select */\n items?: SelectItem[];\n /** Grouped items (alternative to items) */\n groupedItems?: GroupedItem[];\n /** Selected value(s) - for v-model binding */\n modelValue?: string | number | (string | number)[];\n /** Default value for uncontrolled mode */\n defaultValue?: string | number | (string | number)[];\n /** Enable multi-select mode */\n multiple?: boolean;\n /** Enable search functionality */\n searchable?: boolean;\n /** Placeholder text */\n placeholder?: string;\n /** Disable the select */\n disabled?: boolean;\n /** Mark as required */\n required?: boolean;\n /** Show error state */\n error?: boolean;\n /** Enable infinite scroll */\n infiniteScroll?: boolean;\n /** Number of items per page (for infinite scroll) */\n pageSize?: number;\n /** Enable virtual scrolling */\n virtualized?: boolean;\n /** Maximum number of selections (for multi-select) */\n maxSelections?: number;\n /** Dropdown placement */\n placement?: 'bottom' | 'top' | 'auto';\n /** Custom CSS class */\n className?: string;\n /** Custom inline styles */\n style?: Record<string, string>;\n /** Enable expandable dropdown */\n expandable?: boolean;\n}\n\nexport interface SelectEmits {\n /** Emitted when selection changes - for v-model */\n (e: 'update:modelValue', value: string | number | (string | number)[]): void;\n /** Emitted when selection changes with full details */\n (e: 'change', value: string | number | (string | number)[], selectedItems: SelectItem[]): void;\n /** Emitted when an item is selected */\n (e: 'select', item: SelectItem, index: number): void;\n /** Emitted when dropdown opens */\n (e: 'open'): void;\n /** Emitted when dropdown closes */\n (e: 'close'): void;\n /** Emitted when search query changes */\n (e: 'search', query: string): void;\n /** Emitted when more items are requested (infinite scroll) */\n (e: 'loadMore', page: number): void;\n /** Emitted when user creates a new item (if enabled) */\n (e: 'create', value: string): void;\n}\n\nconst props = withDefaults(defineProps<SelectProps>(), {\n items: () => [],\n multiple: false,\n searchable: false,\n disabled: false,\n required: false,\n error: false,\n infiniteScroll: false,\n pageSize: 50,\n virtualized: true,\n placement: 'auto',\n});\n\nconst emit = defineEmits<SelectEmits>();\n\nconst selectRef = ref<HTMLElement | null>(null);\nconst isElementReady = ref(false);\nconst internalValue = ref<string | number | (string | number)[] | undefined>(\n props.defaultValue\n);\n\nconst waitForUpgrade = async () => {\n if (typeof window === 'undefined') return;\n\n // Ensure the module is loaded (it registers the custom element on import)\n if (!customElements.get('enhanced-select')) {\n await import('@smilodon/core');\n }\n\n const el = selectRef.value as any;\n if (!el) return;\n\n // Wait until the element is upgraded and its methods exist.\n // In some environments, the tag can be defined but the particular instance\n // hasn't been upgraded yet when watchers/mounted run.\n try {\n await customElements.whenDefined('enhanced-select');\n } catch {\n // ignore\n }\n\n // Retry a few frames to let the browser upgrade the instance.\n for (let i = 0; i < 5; i++) {\n const candidate = selectRef.value as any;\n if (candidate && typeof candidate.setItems === 'function') {\n isElementReady.value = true;\n return;\n }\n await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));\n }\n\n isElementReady.value = typeof (selectRef.value as any)?.setItems === 'function';\n};\n\nconst safeCall = (fn: (el: any) => void) => {\n const el = selectRef.value as any;\n if (!el || !isElementReady.value) return;\n fn(el);\n};\n\n// Check if component is controlled\nconst isControlled = computed(() => props.modelValue !== undefined);\n\n// Get current value\nconst currentValue = computed(() =>\n isControlled.value ? props.modelValue : internalValue.value\n);\n\n// Sync items to web component\nwatch(\n () => props.items,\n (newItems) => {\n safeCall((el) => {\n if (newItems) el.setItems(newItems);\n });\n },\n { deep: true }\n);\n\n// Sync grouped items to web component\nwatch(\n () => props.groupedItems,\n (newGroups) => {\n safeCall((el) => {\n if (newGroups) el.setGroupedItems(newGroups);\n });\n },\n { deep: true }\n);\n\n// Sync value to web component\nwatch(\n currentValue,\n (newValue) => {\n safeCall((el) => {\n if (newValue !== undefined) {\n const values = Array.isArray(newValue) ? newValue : [newValue];\n el.setSelectedValues(values);\n }\n });\n },\n { immediate: true }\n);\n\n// Sync configuration\nconst updateConfig = () => {\n safeCall((el) => {\n const config = {\n searchable: props.searchable,\n placeholder: props.placeholder,\n enabled: !props.disabled,\n virtualize: props.virtualized,\n selection: {\n mode: props.multiple ? 'multi' : 'single',\n maxSelections: props.maxSelections,\n },\n infiniteScroll: {\n enabled: props.infiniteScroll,\n pageSize: props.pageSize,\n },\n expandable: {\n enabled: props.expandable,\n },\n };\n\n el.updateConfig(config);\n });\n};\n\nwatch(\n [\n () => props.searchable,\n () => props.placeholder,\n () => props.disabled,\n () => props.multiple,\n () => props.maxSelections,\n () => props.infiniteScroll,\n () => props.pageSize,\n () => props.virtualized,\n () => props.expandable,\n ],\n updateConfig\n);\n\n// Event handlers\nconst handleSelect = (e: Event) => {\n const customEvent = e as CustomEvent<SelectEventDetail>;\n const { item, index } = customEvent.detail;\n emit('select', item as SelectItem, index);\n};\n\nconst handleChange = (e: Event) => {\n const customEvent = e as CustomEvent<ChangeEventDetail>;\n const { selectedItems, selectedValues } = customEvent.detail;\n\n const values = selectedValues as (string | number)[];\n\n // Update internal value in uncontrolled mode\n if (!isControlled.value) {\n internalValue.value = props.multiple ? values : values[0];\n }\n\n // Emit events\n const value = props.multiple ? values : values[0];\n emit('update:modelValue', value);\n emit('change', value, selectedItems as SelectItem[]);\n};\n\nconst handleOpen = () => {\n emit('open');\n};\n\nconst handleClose = () => {\n emit('close');\n};\n\nconst handleSearch = (e: Event) => {\n const customEvent = e as CustomEvent<SearchEventDetail>;\n emit('search', customEvent.detail.query);\n};\n\nconst handleLoadMore = (e: Event) => {\n const customEvent = e as CustomEvent<LoadMoreEventDetail>;\n emit('loadMore', customEvent.detail.page);\n};\n\nconst handleCreate = (e: Event) => {\n const customEvent = e as CustomEvent<{ value: string }>;\n emit('create', customEvent.detail.value);\n};\n\n// Setup event listeners\nonMounted(async () => {\n await waitForUpgrade();\n if (!selectRef.value || !isElementReady.value) return;\n\n const element = selectRef.value as any;\n\n // Initial configuration\n updateConfig();\n\n if (props.placement) {\n element.setAttribute('placement', props.placement);\n }\n\n // Set initial items\n if (props.items?.length) {\n element.setItems(props.items);\n }\n if (props.groupedItems?.length) {\n element.setGroupedItems(props.groupedItems);\n }\n\n // Set initial value\n if (currentValue.value !== undefined) {\n const values = Array.isArray(currentValue.value)\n ? currentValue.value\n : [currentValue.value];\n element.setSelectedValues(values);\n }\n\n // Add event listeners\n element.addEventListener('select', handleSelect as EventListener);\n element.addEventListener('change', handleChange as EventListener);\n element.addEventListener('open', handleOpen as EventListener);\n element.addEventListener('close', handleClose as EventListener);\n element.addEventListener('search', handleSearch as EventListener);\n element.addEventListener('loadMore', handleLoadMore as EventListener);\n element.addEventListener('create', handleCreate as EventListener);\n});\n\nonBeforeUnmount(() => {\n if (!selectRef.value) return;\n\n const element = selectRef.value;\n\n // Remove event listeners\n element.removeEventListener('select', handleSelect as EventListener);\n element.removeEventListener('change', handleChange as EventListener);\n element.removeEventListener('open', handleOpen as EventListener);\n element.removeEventListener('close', handleClose as EventListener);\n element.removeEventListener('search', handleSearch as EventListener);\n element.removeEventListener('loadMore', handleLoadMore as EventListener);\n element.removeEventListener('create', handleCreate as EventListener);\n});\n\n// Expose imperative API\ndefineExpose({\n /** Open the dropdown */\n open: () => {\n (selectRef.value as any)?.open();\n },\n /** Close the dropdown */\n close: () => {\n (selectRef.value as any)?.close();\n },\n /** Focus the select */\n focus: () => {\n selectRef.value?.focus();\n },\n /** Set items programmatically */\n setItems: (items: SelectItem[]) => {\n (selectRef.value as any)?.setItems(items);\n },\n /** Set grouped items programmatically */\n setGroupedItems: (groups: GroupedItem[]) => {\n (selectRef.value as any)?.setGroupedItems(groups);\n },\n /** Clear selection */\n clear: () => {\n (selectRef.value as any)?.setSelectedValues([]);\n if (!isControlled.value) {\n internalValue.value = props.multiple ? [] : undefined;\n }\n const value = props.multiple ? [] : '';\n emit('update:modelValue', value);\n emit('change', value, []);\n },\n});\n</script>\n\n<style scoped>\n/* Component uses web component styling from @smilodon/core */\n</style>\n"],"names":["_createBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2GA,UAAM,QAAQ;AAad,UAAM,OAAO;AAEb,UAAM,YAAY,IAAwB,IAAI;AAC9C,UAAM,iBAAiB,IAAI,KAAK;AAChC,UAAM,gBAAgB;AAAA,MACpB,MAAM;AAAA,IAAA;AAGR,UAAM,iBAAiB,YAAY;;AACjC,UAAI,OAAO,WAAW,YAAa;AAGnC,UAAI,CAAC,eAAe,IAAI,iBAAiB,GAAG;AAC1C,cAAM,OAAO,gBAAgB;AAAA,MAC/B;AAEA,YAAM,KAAK,UAAU;AACrB,UAAI,CAAC,GAAI;AAKT,UAAI;AACF,cAAM,eAAe,YAAY,iBAAiB;AAAA,MACpD,QAAQ;AAAA,MAER;AAGA,eAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,cAAM,YAAY,UAAU;AAC5B,YAAI,aAAa,OAAO,UAAU,aAAa,YAAY;AACzD,yBAAe,QAAQ;AACvB;AAAA,QACF;AACA,cAAM,IAAI,QAAc,CAAC,YAAY,sBAAsB,MAAM,QAAA,CAAS,CAAC;AAAA,MAC7E;AAEA,qBAAe,QAAQ,SAAQ,eAAU,UAAV,mBAAyB,cAAa;AAA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;AAAA,MAEA,OAAO,MAAM;;AACV,wBAAU,UAAV,mBAAyB;AAAA,MAC5B;AAAA;AAAA,MAEA,OAAO,MAAM;;AACX,wBAAU,UAAV,mBAAiB;AAAA,MACnB;AAAA;AAAA,MAEA,UAAU,CAAC,UAAwB;;AAChC,wBAAU,UAAV,mBAAyB,SAAS;AAAA,MACrC;AAAA;AAAA,MAEA,iBAAiB,CAAC,WAA0B;;AACzC,wBAAU,UAAV,mBAAyB,gBAAgB;AAAA,MAC5C;AAAA;AAAA,MAEA,OAAO,MAAM;;AACV,wBAAU,UAAV,mBAAyB,kBAAkB;AAC5C,YAAI,CAAC,aAAa,OAAO;AACvB,wBAAc,QAAQ,MAAM,WAAW,CAAA,IAAK;AAAA,QAC9C;AACA,cAAM,QAAQ,MAAM,WAAW,CAAA,IAAK;AACpC,aAAK,qBAAqB,KAAK;AAC/B,aAAK,UAAU,OAAO,EAAE;AAAA,MAC1B;AAAA,IAAA,CACD;;;0BA3WCA,YAIE,4BAAA;AAAA,iBAHI;AAAA,QAAJ,KAAI;AAAA,QACH,sBAAO,QAAA,SAAS;AAAA,QAChB,sBAAO,QAAA,KAAK;AAAA,MAAA;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/Select.vue"],"sourcesContent":["<!--\n Smilodon Select Component for Vue 3\n \n A production-ready, accessible select component with advanced features:\n - Single and multi-select modes\n - Searchable with client or server-side filtering\n - Infinite scroll and virtual scrolling for large datasets\n - Grouped options\n - Custom rendering\n - Full keyboard navigation\n - WCAG 2.1 AAA compliant\n \n @example\n <Select\n :items=\"items\"\n v-model=\"selectedValue\"\n searchable\n placeholder=\"Select an option...\"\n />\n-->\n\n<template>\n <enhanced-select\n ref=\"selectRef\"\n :class=\"className\"\n :style=\"style\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, watch, onMounted, onBeforeUnmount, computed } from 'vue';\nimport type {\n SelectEventDetail,\n OpenEventDetail,\n CloseEventDetail,\n SearchEventDetail,\n ChangeEventDetail,\n LoadMoreEventDetail,\n GroupedItem,\n} from '@smilodon/core';\n\nexport interface SelectItem {\n value: string | number;\n label: string;\n disabled?: boolean;\n group?: string;\n [key: string]: any;\n}\n\nexport interface SelectProps {\n /** Array of items to display in the select */\n items?: SelectItem[];\n /** Grouped items (alternative to items) */\n groupedItems?: GroupedItem[];\n /** Selected value(s) - for v-model binding */\n modelValue?: string | number | (string | number)[];\n /** Default value for uncontrolled mode */\n defaultValue?: string | number | (string | number)[];\n /** Enable multi-select mode */\n multiple?: boolean;\n /** Enable search functionality */\n searchable?: boolean;\n /** Placeholder text */\n placeholder?: string;\n /** Disable the select */\n disabled?: boolean;\n /** Mark as required */\n required?: boolean;\n /** Show error state */\n error?: boolean;\n /** Enable infinite scroll */\n infiniteScroll?: boolean;\n /** Number of items per page (for infinite scroll) */\n pageSize?: number;\n /** Enable virtual scrolling */\n virtualized?: boolean;\n /** Maximum number of selections (for multi-select) */\n maxSelections?: number;\n /** Dropdown placement */\n placement?: 'bottom' | 'top' | 'auto';\n /** Custom CSS class */\n className?: string;\n /** Custom inline styles */\n style?: Record<string, string>;\n /** Enable expandable dropdown */\n expandable?: boolean;\n}\n\nexport interface SelectEmits {\n /** Emitted when selection changes - for v-model */\n (e: 'update:modelValue', value: string | number | (string | number)[]): void;\n /** Emitted when selection changes with full details */\n (e: 'change', value: string | number | (string | number)[], selectedItems: SelectItem[]): void;\n /** Emitted when an item is selected */\n (e: 'select', item: SelectItem, index: number): void;\n /** Emitted when dropdown opens */\n (e: 'open'): void;\n /** Emitted when dropdown closes */\n (e: 'close'): void;\n /** Emitted when search query changes */\n (e: 'search', query: string): void;\n /** Emitted when more items are requested (infinite scroll) */\n (e: 'loadMore', page: number): void;\n /** Emitted when user creates a new item (if enabled) */\n (e: 'create', value: string): void;\n}\n\nconst props = withDefaults(defineProps<SelectProps>(), {\n items: () => [],\n multiple: false,\n searchable: false,\n disabled: false,\n required: false,\n error: false,\n infiniteScroll: false,\n pageSize: 50,\n virtualized: true,\n placement: 'auto',\n});\n\nconst emit = defineEmits<SelectEmits>();\n\nconst selectRef = ref<HTMLElement | null>(null);\nconst isElementReady = ref(false);\nconst internalValue = ref<string | number | (string | number)[] | undefined>(\n props.defaultValue\n);\n\nconst waitForUpgrade = async () => {\n if (typeof window === 'undefined') return;\n\n // Ensure the module is loaded (it registers the custom element on import)\n if (!customElements.get('enhanced-select')) {\n await import('@smilodon/core');\n }\n\n const el = selectRef.value as any;\n if (!el) return;\n\n // Wait until the element is upgraded and its methods exist.\n // In some environments, the tag can be defined but the particular instance\n // hasn't been upgraded yet when watchers/mounted run.\n try {\n await customElements.whenDefined('enhanced-select');\n } catch {\n // ignore\n }\n\n // Retry a few frames to let the browser upgrade the instance.\n for (let i = 0; i < 5; i++) {\n const candidate = selectRef.value as any;\n if (candidate && typeof candidate.setItems === 'function') {\n isElementReady.value = true;\n return;\n }\n await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));\n }\n\n isElementReady.value = typeof (selectRef.value as any)?.setItems === 'function';\n};\n\nconst safeCall = (fn: (el: any) => void) => {\n const el = selectRef.value as any;\n if (!el || !isElementReady.value) return;\n fn(el);\n};\n\n// Check if component is controlled\nconst isControlled = computed(() => props.modelValue !== undefined);\n\n// Get current value\nconst currentValue = computed(() =>\n isControlled.value ? props.modelValue : internalValue.value\n);\n\n// Sync items to web component\nwatch(\n () => props.items,\n (newItems) => {\n safeCall((el) => {\n if (newItems) el.setItems(newItems);\n });\n },\n { deep: true }\n);\n\n// Sync grouped items to web component\nwatch(\n () => props.groupedItems,\n (newGroups) => {\n safeCall((el) => {\n if (newGroups) el.setGroupedItems(newGroups);\n });\n },\n { deep: true }\n);\n\n// Sync value to web component\nwatch(\n currentValue,\n (newValue) => {\n safeCall((el) => {\n if (newValue !== undefined) {\n // Get current selected values from the element to avoid infinite loop\n const currentSelected = el.getSelectedValues?.() || [];\n const newValues = Array.isArray(newValue) ? newValue : [newValue];\n \n // Only update if values have actually changed\n const hasChanged = \n currentSelected.length !== newValues.length ||\n !currentSelected.every((v: any, i: number) => v === newValues[i]);\n \n if (hasChanged) {\n el.setSelectedValues(newValues);\n }\n }\n });\n },\n { immediate: true }\n);\n\n// Sync configuration\nconst updateConfig = () => {\n safeCall((el) => {\n const config = {\n searchable: props.searchable,\n placeholder: props.placeholder,\n enabled: !props.disabled,\n virtualize: props.virtualized,\n selection: {\n mode: props.multiple ? 'multi' : 'single',\n maxSelections: props.maxSelections,\n },\n infiniteScroll: {\n enabled: props.infiniteScroll,\n pageSize: props.pageSize,\n },\n expandable: {\n enabled: props.expandable,\n },\n };\n\n el.updateConfig(config);\n });\n};\n\nwatch(\n [\n () => props.searchable,\n () => props.placeholder,\n () => props.disabled,\n () => props.multiple,\n () => props.maxSelections,\n () => props.infiniteScroll,\n () => props.pageSize,\n () => props.virtualized,\n () => props.expandable,\n ],\n updateConfig\n);\n\n// Event handlers\nconst handleSelect = (e: Event) => {\n const customEvent = e as CustomEvent<SelectEventDetail>;\n const { item, index } = customEvent.detail;\n emit('select', item as SelectItem, index);\n};\n\nconst handleChange = (e: Event) => {\n const customEvent = e as CustomEvent<ChangeEventDetail>;\n const { selectedItems, selectedValues } = customEvent.detail;\n\n const values = selectedValues as (string | number)[];\n\n // Update internal value in uncontrolled mode\n if (!isControlled.value) {\n internalValue.value = props.multiple ? values : values[0];\n }\n\n // Emit events\n const value = props.multiple ? values : values[0];\n emit('update:modelValue', value);\n emit('change', value, selectedItems as SelectItem[]);\n};\n\nconst handleOpen = () => {\n emit('open');\n};\n\nconst handleClose = () => {\n emit('close');\n};\n\nconst handleSearch = (e: Event) => {\n const customEvent = e as CustomEvent<SearchEventDetail>;\n emit('search', customEvent.detail.query);\n};\n\nconst handleLoadMore = (e: Event) => {\n const customEvent = e as CustomEvent<LoadMoreEventDetail>;\n emit('loadMore', customEvent.detail.page);\n};\n\nconst handleCreate = (e: Event) => {\n const customEvent = e as CustomEvent<{ value: string }>;\n emit('create', customEvent.detail.value);\n};\n\n// Setup event listeners\nonMounted(async () => {\n await waitForUpgrade();\n if (!selectRef.value || !isElementReady.value) return;\n\n const element = selectRef.value as any;\n\n // Initial configuration\n updateConfig();\n\n if (props.placement) {\n element.setAttribute('placement', props.placement);\n }\n\n // Set initial items\n if (props.items?.length) {\n element.setItems(props.items);\n }\n if (props.groupedItems?.length) {\n element.setGroupedItems(props.groupedItems);\n }\n\n // Set initial value\n if (currentValue.value !== undefined) {\n const values = Array.isArray(currentValue.value)\n ? currentValue.value\n : [currentValue.value];\n element.setSelectedValues(values);\n }\n\n // Add event listeners\n element.addEventListener('select', handleSelect as EventListener);\n element.addEventListener('change', handleChange as EventListener);\n element.addEventListener('open', handleOpen as EventListener);\n element.addEventListener('close', handleClose as EventListener);\n element.addEventListener('search', handleSearch as EventListener);\n element.addEventListener('loadMore', handleLoadMore as EventListener);\n element.addEventListener('create', handleCreate as EventListener);\n});\n\nonBeforeUnmount(() => {\n if (!selectRef.value) return;\n\n const element = selectRef.value;\n\n // Remove event listeners\n element.removeEventListener('select', handleSelect as EventListener);\n element.removeEventListener('change', handleChange as EventListener);\n element.removeEventListener('open', handleOpen as EventListener);\n element.removeEventListener('close', handleClose as EventListener);\n element.removeEventListener('search', handleSearch as EventListener);\n element.removeEventListener('loadMore', handleLoadMore as EventListener);\n element.removeEventListener('create', handleCreate as EventListener);\n});\n\n// Expose imperative API\ndefineExpose({\n /** Open the dropdown */\n open: () => {\n (selectRef.value as any)?.open();\n },\n /** Close the dropdown */\n close: () => {\n (selectRef.value as any)?.close();\n },\n /** Focus the select */\n focus: () => {\n selectRef.value?.focus();\n },\n /** Set items programmatically */\n setItems: (items: SelectItem[]) => {\n (selectRef.value as any)?.setItems(items);\n },\n /** Set grouped items programmatically */\n setGroupedItems: (groups: GroupedItem[]) => {\n (selectRef.value as any)?.setGroupedItems(groups);\n },\n /** Clear selection */\n clear: () => {\n (selectRef.value as any)?.setSelectedValues([]);\n if (!isControlled.value) {\n internalValue.value = props.multiple ? [] : undefined;\n }\n const value = props.multiple ? [] : '';\n emit('update:modelValue', value);\n emit('change', value, []);\n },\n});\n</script>\n\n<style scoped>\n/* Component uses web component styling from @smilodon/core */\n</style>\n"],"names":["_createBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2GA,UAAM,QAAQ;AAad,UAAM,OAAO;AAEb,UAAM,YAAY,IAAwB,IAAI;AAC9C,UAAM,iBAAiB,IAAI,KAAK;AAChC,UAAM,gBAAgB;AAAA,MACpB,MAAM;AAAA,IAAA;AAGR,UAAM,iBAAiB,YAAY;;AACjC,UAAI,OAAO,WAAW,YAAa;AAGnC,UAAI,CAAC,eAAe,IAAI,iBAAiB,GAAG;AAC1C,cAAM,OAAO,gBAAgB;AAAA,MAC/B;AAEA,YAAM,KAAK,UAAU;AACrB,UAAI,CAAC,GAAI;AAKT,UAAI;AACF,cAAM,eAAe,YAAY,iBAAiB;AAAA,MACpD,QAAQ;AAAA,MAER;AAGA,eAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,cAAM,YAAY,UAAU;AAC5B,YAAI,aAAa,OAAO,UAAU,aAAa,YAAY;AACzD,yBAAe,QAAQ;AACvB;AAAA,QACF;AACA,cAAM,IAAI,QAAc,CAAC,YAAY,sBAAsB,MAAM,QAAA,CAAS,CAAC;AAAA,MAC7E;AAEA,qBAAe,QAAQ,SAAQ,eAAU,UAAV,mBAAyB,cAAa;AAAA,IACvE;AAEA,UAAM,WAAW,CAAC,OAA0B;AAC1C,YAAM,KAAK,UAAU;AACrB,UAAI,CAAC,MAAM,CAAC,eAAe,MAAO;AAClC,SAAG,EAAE;AAAA,IACP;AAGA,UAAM,eAAe,SAAS,MAAM,MAAM,eAAe,MAAS;AAGlE,UAAM,eAAe;AAAA,MAAS,MAC5B,aAAa,QAAQ,MAAM,aAAa,cAAc;AAAA,IAAA;AAIxD;AAAA,MACE,MAAM,MAAM;AAAA,MACZ,CAAC,aAAa;AACZ,iBAAS,CAAC,OAAO;AACf,cAAI,SAAU,I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