@smilodon/vanilla 1.0.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 +439 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +132 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
# @smilodon/vanilla
|
|
2
|
+
|
|
3
|
+
Vanilla JavaScript/TypeScript helpers for Smilodon Select. Part of the [Smilodon](https://github.com/navidrezadoost/smilodon) UI toolkit.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✨ **Simple API** - Easy-to-use helper functions for vanilla JS
|
|
8
|
+
- 🔍 **Zero Dependencies** - Only requires @smilodon/core
|
|
9
|
+
- ♿ **Fully Accessible** - WCAG 2.1 AAA compliant
|
|
10
|
+
- ⚡ **Tiny Bundle** - < 1KB gzipped
|
|
11
|
+
- 🔧 **TypeScript** - Full type safety included
|
|
12
|
+
- 📦 **Tree-Shakeable** - Import only what you need
|
|
13
|
+
- 🎯 **Web Standards** - Built on native Web Components
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @smilodon/vanilla @smilodon/core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### Using the Helper Function
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { createSelect } from '@smilodon/vanilla';
|
|
27
|
+
|
|
28
|
+
const select = createSelect({
|
|
29
|
+
items: [
|
|
30
|
+
{ value: '1', label: 'Apple' },
|
|
31
|
+
{ value: '2', label: 'Banana' },
|
|
32
|
+
{ value: '3', label: 'Cherry' },
|
|
33
|
+
],
|
|
34
|
+
placeholder: 'Select a fruit...',
|
|
35
|
+
onChange: (value, items) => {
|
|
36
|
+
console.log('Selected:', value, items);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
document.body.appendChild(select);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Using the Web Component Directly
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<!DOCTYPE html>
|
|
47
|
+
<html>
|
|
48
|
+
<head>
|
|
49
|
+
<script type="module">
|
|
50
|
+
import '@smilodon/core';
|
|
51
|
+
import { initSelect } from '@smilodon/vanilla';
|
|
52
|
+
|
|
53
|
+
const select = document.querySelector('enhanced-select');
|
|
54
|
+
|
|
55
|
+
initSelect(select, {
|
|
56
|
+
items: [
|
|
57
|
+
{ value: 'js', label: 'JavaScript' },
|
|
58
|
+
{ value: 'ts', label: 'TypeScript' },
|
|
59
|
+
{ value: 'py', label: 'Python' },
|
|
60
|
+
],
|
|
61
|
+
value: 'js'
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
</head>
|
|
65
|
+
<body>
|
|
66
|
+
<enhanced-select placeholder="Select a language..."></enhanced-select>
|
|
67
|
+
</body>
|
|
68
|
+
</html>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
### Searchable Select
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { createSelect } from '@smilodon/vanilla';
|
|
77
|
+
|
|
78
|
+
const select = createSelect({
|
|
79
|
+
items: [
|
|
80
|
+
{ value: 'us', label: 'United States' },
|
|
81
|
+
{ value: 'ca', label: 'Canada' },
|
|
82
|
+
{ value: 'mx', label: 'Mexico' },
|
|
83
|
+
],
|
|
84
|
+
searchable: true,
|
|
85
|
+
placeholder: 'Search countries...',
|
|
86
|
+
onChange: (value) => console.log('Country:', value)
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
document.getElementById('app').appendChild(select);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Multi-Select
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { createSelect } from '@smilodon/vanilla';
|
|
96
|
+
|
|
97
|
+
const select = createSelect({
|
|
98
|
+
items: [
|
|
99
|
+
{ value: 'js', label: 'JavaScript' },
|
|
100
|
+
{ value: 'ts', label: 'TypeScript' },
|
|
101
|
+
{ value: 'py', label: 'Python' },
|
|
102
|
+
],
|
|
103
|
+
multiple: true,
|
|
104
|
+
placeholder: 'Select languages...',
|
|
105
|
+
onChange: (values) => {
|
|
106
|
+
console.log('Selected languages:', values);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
document.getElementById('app').appendChild(select);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Grouped Options
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import { createSelect } from '@smilodon/vanilla';
|
|
117
|
+
|
|
118
|
+
const select = createSelect({
|
|
119
|
+
groupedItems: [
|
|
120
|
+
{
|
|
121
|
+
group: 'Fruits',
|
|
122
|
+
items: [
|
|
123
|
+
{ value: 'apple', label: 'Apple' },
|
|
124
|
+
{ value: 'banana', label: 'Banana' },
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
group: 'Vegetables',
|
|
129
|
+
items: [
|
|
130
|
+
{ value: 'carrot', label: 'Carrot' },
|
|
131
|
+
{ value: 'potato', label: 'Potato' },
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
onChange: (value) => console.log('Food:', value)
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
document.getElementById('app').appendChild(select);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Infinite Scroll
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { createSelect, setItems } from '@smilodon/vanilla';
|
|
145
|
+
|
|
146
|
+
let items = generateItems(1, 50);
|
|
147
|
+
let page = 1;
|
|
148
|
+
|
|
149
|
+
const select = createSelect({
|
|
150
|
+
items,
|
|
151
|
+
infiniteScroll: true,
|
|
152
|
+
pageSize: 50,
|
|
153
|
+
placeholder: 'Scroll to load more...',
|
|
154
|
+
onLoadMore: (pageNum) => {
|
|
155
|
+
page++;
|
|
156
|
+
const newItems = generateItems(page * 50 + 1, (page + 1) * 50);
|
|
157
|
+
items = [...items, ...newItems];
|
|
158
|
+
setItems(select, items);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
function generateItems(start, end) {
|
|
163
|
+
return Array.from({ length: end - start + 1 }, (_, i) => ({
|
|
164
|
+
value: start + i,
|
|
165
|
+
label: `Item ${start + i}`,
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
document.getElementById('app').appendChild(select);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Virtual Scrolling (Large Datasets)
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import { createSelect } from '@smilodon/vanilla';
|
|
176
|
+
|
|
177
|
+
// Generate 100,000 items
|
|
178
|
+
const items = Array.from({ length: 100000 }, (_, i) => ({
|
|
179
|
+
value: i + 1,
|
|
180
|
+
label: `Item ${i + 1}`,
|
|
181
|
+
}));
|
|
182
|
+
|
|
183
|
+
const select = createSelect({
|
|
184
|
+
items,
|
|
185
|
+
virtualized: true,
|
|
186
|
+
searchable: true,
|
|
187
|
+
placeholder: '100k items with virtual scrolling...'
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
document.getElementById('app').appendChild(select);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Server-Side Search
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import { createSelect, setItems } from '@smilodon/vanilla';
|
|
197
|
+
|
|
198
|
+
const select = createSelect({
|
|
199
|
+
searchable: true,
|
|
200
|
+
placeholder: 'Type to search...',
|
|
201
|
+
onSearch: async (query) => {
|
|
202
|
+
if (!query) {
|
|
203
|
+
setItems(select, []);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const response = await fetch(`/api/search?q=${query}`);
|
|
208
|
+
const data = await response.json();
|
|
209
|
+
setItems(select, data.results);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
document.getElementById('app').appendChild(select);
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Programmatic Control
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
import { createSelect, getValue, setValue, clear, open, close } from '@smilodon/vanilla';
|
|
220
|
+
|
|
221
|
+
const select = createSelect({
|
|
222
|
+
items: [
|
|
223
|
+
{ value: 'draft', label: 'Draft' },
|
|
224
|
+
{ value: 'published', label: 'Published' },
|
|
225
|
+
{ value: 'archived', label: 'Archived' },
|
|
226
|
+
]
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Add to DOM
|
|
230
|
+
document.getElementById('app').appendChild(select);
|
|
231
|
+
|
|
232
|
+
// Programmatic API
|
|
233
|
+
document.getElementById('btn-open').addEventListener('click', () => {
|
|
234
|
+
open(select);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
document.getElementById('btn-close').addEventListener('click', () => {
|
|
238
|
+
close(select);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
document.getElementById('btn-set').addEventListener('click', () => {
|
|
242
|
+
setValue(select, 'published');
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
document.getElementById('btn-get').addEventListener('click', () => {
|
|
246
|
+
console.log('Current value:', getValue(select));
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
document.getElementById('btn-clear').addEventListener('click', () => {
|
|
250
|
+
clear(select);
|
|
251
|
+
});
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### With Event Listeners
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
import { createSelect } from '@smilodon/vanilla';
|
|
258
|
+
|
|
259
|
+
const select = createSelect({
|
|
260
|
+
items: [...],
|
|
261
|
+
onChange: (value, items) => {
|
|
262
|
+
console.log('Value changed:', value);
|
|
263
|
+
console.log('Selected items:', items);
|
|
264
|
+
},
|
|
265
|
+
onSelect: (item, index) => {
|
|
266
|
+
console.log('Item selected:', item, 'at index:', index);
|
|
267
|
+
},
|
|
268
|
+
onOpen: () => {
|
|
269
|
+
console.log('Dropdown opened');
|
|
270
|
+
},
|
|
271
|
+
onClose: () => {
|
|
272
|
+
console.log('Dropdown closed');
|
|
273
|
+
},
|
|
274
|
+
onSearch: (query) => {
|
|
275
|
+
console.log('Search query:', query);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
document.getElementById('app').appendChild(select);
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Custom Styling
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { createSelect } from '@smilodon/vanilla';
|
|
286
|
+
|
|
287
|
+
const select = createSelect({
|
|
288
|
+
items: [...],
|
|
289
|
+
className: 'my-custom-select',
|
|
290
|
+
style: {
|
|
291
|
+
width: '300px',
|
|
292
|
+
marginTop: '20px',
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
document.getElementById('app').appendChild(select);
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
```css
|
|
300
|
+
/* Custom CSS variables */
|
|
301
|
+
.my-custom-select {
|
|
302
|
+
--select-border-color: #3b82f6;
|
|
303
|
+
--select-focus-border-color: #1d4ed8;
|
|
304
|
+
--select-background: #f9fafb;
|
|
305
|
+
--select-text-color: #111827;
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## API Reference
|
|
310
|
+
|
|
311
|
+
### `createSelect(options)`
|
|
312
|
+
|
|
313
|
+
Creates and returns a new select element.
|
|
314
|
+
|
|
315
|
+
**Options:**
|
|
316
|
+
|
|
317
|
+
| Option | Type | Default | Description |
|
|
318
|
+
|--------|------|---------|-------------|
|
|
319
|
+
| `items` | `SelectItem[]` | `[]` | Array of selectable items |
|
|
320
|
+
| `groupedItems` | `GroupedItem[]` | `undefined` | Grouped items array |
|
|
321
|
+
| `value` | `string \| number \| Array` | `undefined` | Initial value |
|
|
322
|
+
| `multiple` | `boolean` | `false` | Enable multi-select |
|
|
323
|
+
| `searchable` | `boolean` | `false` | Enable search/filter |
|
|
324
|
+
| `placeholder` | `string` | `''` | Placeholder text |
|
|
325
|
+
| `disabled` | `boolean` | `false` | Disable the select |
|
|
326
|
+
| `required` | `boolean` | `false` | Mark as required |
|
|
327
|
+
| `error` | `boolean` | `false` | Show error state |
|
|
328
|
+
| `infiniteScroll` | `boolean` | `false` | Enable infinite scroll |
|
|
329
|
+
| `pageSize` | `number` | `50` | Items per page |
|
|
330
|
+
| `virtualized` | `boolean` | `true` | Enable virtual scrolling |
|
|
331
|
+
| `maxSelections` | `number` | `undefined` | Max selections |
|
|
332
|
+
| `placement` | `'bottom' \| 'top' \| 'auto'` | `'auto'` | Dropdown placement |
|
|
333
|
+
| `className` | `string` | `''` | Custom CSS class |
|
|
334
|
+
| `style` | `CSSStyleDeclaration` | `{}` | Inline styles |
|
|
335
|
+
| `onChange` | `(value, items) => void` | `undefined` | Change callback |
|
|
336
|
+
| `onSelect` | `(item, index) => void` | `undefined` | Select callback |
|
|
337
|
+
| `onOpen` | `() => void` | `undefined` | Open callback |
|
|
338
|
+
| `onClose` | `() => void` | `undefined` | Close callback |
|
|
339
|
+
| `onSearch` | `(query) => void` | `undefined` | Search callback |
|
|
340
|
+
| `onLoadMore` | `(page) => void` | `undefined` | Load more callback |
|
|
341
|
+
| `onCreate` | `(value) => void` | `undefined` | Create callback |
|
|
342
|
+
|
|
343
|
+
**Returns:** `HTMLElement`
|
|
344
|
+
|
|
345
|
+
### `initSelect(element, options)`
|
|
346
|
+
|
|
347
|
+
Initialize an existing select element in the DOM.
|
|
348
|
+
|
|
349
|
+
**Parameters:**
|
|
350
|
+
- `element: HTMLElement` - The select element
|
|
351
|
+
- `options: { items?, groupedItems?, value? }` - Initialization options
|
|
352
|
+
|
|
353
|
+
### `getValue(element)`
|
|
354
|
+
|
|
355
|
+
Get the selected value(s).
|
|
356
|
+
|
|
357
|
+
**Returns:** `string | number | (string | number)[]`
|
|
358
|
+
|
|
359
|
+
### `setValue(element, value)`
|
|
360
|
+
|
|
361
|
+
Set the selected value(s).
|
|
362
|
+
|
|
363
|
+
**Parameters:**
|
|
364
|
+
- `element: HTMLElement`
|
|
365
|
+
- `value: string | number | (string | number)[]`
|
|
366
|
+
|
|
367
|
+
### `clear(element)`
|
|
368
|
+
|
|
369
|
+
Clear the selection.
|
|
370
|
+
|
|
371
|
+
### `open(element)`
|
|
372
|
+
|
|
373
|
+
Open the dropdown.
|
|
374
|
+
|
|
375
|
+
### `close(element)`
|
|
376
|
+
|
|
377
|
+
Close the dropdown.
|
|
378
|
+
|
|
379
|
+
### `setItems(element, items)`
|
|
380
|
+
|
|
381
|
+
Update the items.
|
|
382
|
+
|
|
383
|
+
**Parameters:**
|
|
384
|
+
- `element: HTMLElement`
|
|
385
|
+
- `items: SelectItem[]`
|
|
386
|
+
|
|
387
|
+
### `setGroupedItems(element, groups)`
|
|
388
|
+
|
|
389
|
+
Update the grouped items.
|
|
390
|
+
|
|
391
|
+
**Parameters:**
|
|
392
|
+
- `element: HTMLElement`
|
|
393
|
+
- `groups: GroupedItem[]`
|
|
394
|
+
|
|
395
|
+
### Types
|
|
396
|
+
|
|
397
|
+
```typescript
|
|
398
|
+
interface SelectItem {
|
|
399
|
+
value: string | number;
|
|
400
|
+
label: string;
|
|
401
|
+
disabled?: boolean;
|
|
402
|
+
group?: string;
|
|
403
|
+
[key: string]: any;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
interface GroupedItem {
|
|
407
|
+
group: string;
|
|
408
|
+
items: SelectItem[];
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Styling
|
|
413
|
+
|
|
414
|
+
The component uses CSS variables for customization:
|
|
415
|
+
|
|
416
|
+
```css
|
|
417
|
+
enhanced-select {
|
|
418
|
+
--select-border-color: #d1d5db;
|
|
419
|
+
--select-focus-border-color: #3b82f6;
|
|
420
|
+
--select-background: white;
|
|
421
|
+
--select-text-color: #1f2937;
|
|
422
|
+
--select-placeholder-color: #9ca3af;
|
|
423
|
+
--select-option-hover-background: #f3f4f6;
|
|
424
|
+
--select-option-selected-background: #eff6ff;
|
|
425
|
+
--select-border-radius: 0.375rem;
|
|
426
|
+
--select-padding: 0.5rem 0.75rem;
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
## Browser Support
|
|
431
|
+
|
|
432
|
+
- Chrome/Edge 90+
|
|
433
|
+
- Firefox 88+
|
|
434
|
+
- Safari 14+
|
|
435
|
+
- Opera 76+
|
|
436
|
+
|
|
437
|
+
## License
|
|
438
|
+
|
|
439
|
+
MIT © [Navid Rezadoost](https://github.com/navidrezadoost)
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.clear=function(e){var t;const s=e;null==(t=s.setSelectedValues)||t.call(s,[])},exports.close=function(e){var t;const s=e;null==(t=s.close)||t.call(s)},exports.createSelect=function(e){const t=document.createElement("enhanced-select");if(e.placeholder&&t.setAttribute("placeholder",e.placeholder),e.disabled&&t.setAttribute("disabled",""),e.required&&t.setAttribute("required",""),e.error&&t.setAttribute("error",""),e.searchable&&t.setAttribute("searchable",""),e.multiple&&t.setAttribute("multiple",""),e.virtualized&&t.setAttribute("virtualized",""),e.infiniteScroll&&t.setAttribute("infinite-scroll",""),e.pageSize&&t.setAttribute("page-size",String(e.pageSize)),e.maxSelections&&t.setAttribute("max-selections",String(e.maxSelections)),e.placement&&t.setAttribute("placement",e.placement),e.className&&(t.className=e.className),e.style&&Object.assign(t.style,e.style),e.items&&t.setItems(e.items),e.groupedItems&&t.setGroupedItems(e.groupedItems),void 0!==e.value){const s=Array.isArray(e.value)?e.value:[e.value];t.setSelectedValues(s)}return e.onChange&&t.addEventListener("change",t=>{const s=t,{selectedItems:l,selectedValues:n}=s.detail,r=e.multiple?n:n[0];e.onChange(r,l)}),e.onSelect&&t.addEventListener("select",t=>{const s=t;e.onSelect(s.detail.item,s.detail.index)}),e.onOpen&&t.addEventListener("open",e.onOpen),e.onClose&&t.addEventListener("close",e.onClose),e.onSearch&&t.addEventListener("search",t=>{const s=t;e.onSearch(s.detail.query)}),e.onLoadMore&&t.addEventListener("loadMore",t=>{const s=t;e.onLoadMore(s.detail.page)}),e.onCreate&&t.addEventListener("create",t=>{const s=t;e.onCreate(s.detail.value)}),t},exports.getValue=function(e){var t;const s=e,l=(null==(t=s.getSelectedValues)?void 0:t.call(s))||[];return e.hasAttribute("multiple")?l:l[0]},exports.initSelect=function(e,t){const s=e;if(t.items&&s.setItems(t.items),t.groupedItems&&s.setGroupedItems(t.groupedItems),void 0!==t.value){const e=Array.isArray(t.value)?t.value:[t.value];s.setSelectedValues(e)}},exports.open=function(e){var t;const s=e;null==(t=s.open)||t.call(s)},exports.setGroupedItems=function(e,t){var s;const l=e;null==(s=l.setGroupedItems)||s.call(l,t)},exports.setItems=function(e,t){var s;const l=e;null==(s=l.setItems)||s.call(l,t)},exports.setValue=function(e,t){var s;const l=e,n=Array.isArray(t)?t:[t];null==(s=l.setSelectedValues)||s.call(l,n)};
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["/**\n * Smilodon Vanilla - Simple helpers for using Smilodon Select with vanilla JavaScript/TypeScript\n * \n * This package provides convenience functions and utilities for working with\n * the Smilodon Select web component in vanilla JavaScript applications.\n */\n\n/**\n * Select item interface\n */\nexport interface SelectItem {\n value: string | number;\n label: string;\n disabled?: boolean;\n group?: string;\n [key: string]: any;\n}\n\n/**\n * Grouped items interface\n */\nexport interface GroupedItem {\n group: string;\n items: SelectItem[];\n}\n\n/**\n * Create a select element with options\n */\nexport function createSelect(options: {\n items?: SelectItem[];\n groupedItems?: GroupedItem[];\n value?: string | number | (string | number)[];\n multiple?: boolean;\n searchable?: boolean;\n placeholder?: string;\n disabled?: boolean;\n required?: boolean;\n error?: boolean;\n infiniteScroll?: boolean;\n pageSize?: number;\n virtualized?: boolean;\n maxSelections?: number;\n placement?: 'bottom' | 'top' | 'auto';\n className?: string;\n style?: Partial<CSSStyleDeclaration>;\n onChange?: (value: any, items: any[]) => void;\n onSelect?: (item: any, index: number) => void;\n onOpen?: () => void;\n onClose?: () => void;\n onSearch?: (query: string) => void;\n onLoadMore?: (page: number) => void;\n onCreate?: (value: string) => void;\n}): HTMLElement {\n const select = document.createElement('enhanced-select') as any;\n\n // Set attributes\n if (options.placeholder) select.setAttribute('placeholder', options.placeholder);\n if (options.disabled) select.setAttribute('disabled', '');\n if (options.required) select.setAttribute('required', '');\n if (options.error) select.setAttribute('error', '');\n if (options.searchable) select.setAttribute('searchable', '');\n if (options.multiple) select.setAttribute('multiple', '');\n if (options.virtualized) select.setAttribute('virtualized', '');\n if (options.infiniteScroll) select.setAttribute('infinite-scroll', '');\n if (options.pageSize) select.setAttribute('page-size', String(options.pageSize));\n if (options.maxSelections) select.setAttribute('max-selections', String(options.maxSelections));\n if (options.placement) select.setAttribute('placement', options.placement);\n\n // Set class name\n if (options.className) {\n select.className = options.className;\n }\n\n // Set inline styles\n if (options.style) {\n Object.assign(select.style, options.style);\n }\n\n // Set items\n if (options.items) {\n select.setItems(options.items);\n }\n if (options.groupedItems) {\n select.setGroupedItems(options.groupedItems);\n }\n\n // Set initial value\n if (options.value !== undefined) {\n const values = Array.isArray(options.value) ? options.value : [options.value];\n select.setSelectedValues(values);\n }\n\n // Add event listeners\n if (options.onChange) {\n select.addEventListener('change', (e: Event) => {\n const event = e as CustomEvent;\n const { selectedItems, selectedValues } = event.detail;\n const value = options.multiple ? selectedValues : selectedValues[0];\n options.onChange!(value, selectedItems);\n });\n }\n\n if (options.onSelect) {\n select.addEventListener('select', (e: Event) => {\n const event = e as CustomEvent;\n options.onSelect!(event.detail.item, event.detail.index);\n });\n }\n\n if (options.onOpen) {\n select.addEventListener('open', options.onOpen);\n }\n\n if (options.onClose) {\n select.addEventListener('close', options.onClose);\n }\n\n if (options.onSearch) {\n select.addEventListener('search', (e: Event) => {\n const event = e as CustomEvent;\n options.onSearch!(event.detail.query);\n });\n }\n\n if (options.onLoadMore) {\n select.addEventListener('loadMore', (e: Event) => {\n const event = e as CustomEvent;\n options.onLoadMore!(event.detail.page);\n });\n }\n\n if (options.onCreate) {\n select.addEventListener('create', (e: Event) => {\n const event = e as CustomEvent;\n options.onCreate!(event.detail.value);\n });\n }\n\n return select;\n}\n\n/**\n * Initialize a select element that already exists in the DOM\n */\nexport function initSelect(\n element: HTMLElement,\n options: {\n items?: SelectItem[];\n groupedItems?: GroupedItem[];\n value?: string | number | (string | number)[];\n }\n): void {\n const select = element as any;\n\n if (options.items) {\n select.setItems(options.items);\n }\n\n if (options.groupedItems) {\n select.setGroupedItems(options.groupedItems);\n }\n\n if (options.value !== undefined) {\n const values = Array.isArray(options.value) ? options.value : [options.value];\n select.setSelectedValues(values);\n }\n}\n\n/**\n * Get the selected value(s) from a select element\n */\nexport function getValue(element: HTMLElement): any {\n const select = element as any;\n const values = select.getSelectedValues?.() || [];\n const multiple = element.hasAttribute('multiple');\n return multiple ? values : values[0];\n}\n\n/**\n * Set the selected value(s) for a select element\n */\nexport function setValue(\n element: HTMLElement,\n value: string | number | (string | number)[]\n): void {\n const select = element as any;\n const values = Array.isArray(value) ? value : [value];\n select.setSelectedValues?.(values);\n}\n\n/**\n * Clear the selection\n */\nexport function clear(element: HTMLElement): void {\n const select = element as any;\n select.setSelectedValues?.([]);\n}\n\n/**\n * Open the dropdown\n */\nexport function open(element: HTMLElement): void {\n const select = element as any;\n select.open?.();\n}\n\n/**\n * Close the dropdown\n */\nexport function close(element: HTMLElement): void {\n const select = element as any;\n select.close?.();\n}\n\n/**\n * Update items\n */\nexport function setItems(element: HTMLElement, items: SelectItem[]): void {\n const select = element as any;\n select.setItems?.(items);\n}\n\n/**\n * Update grouped items\n */\nexport function setGroupedItems(element: HTMLElement, groups: GroupedItem[]): void {\n const select = element as any;\n select.setGroupedItems?.(groups);\n}\n\n// Re-export types from core for convenience\nexport type {\n SelectEventDetail,\n ChangeEventDetail,\n SearchEventDetail,\n LoadMoreEventDetail,\n} from '@smilodon/core';\n"],"names":["element","select","_a","setSelectedValues","close","call","options","document","createElement","placeholder","setAttribute","disabled","required","error","searchable","multiple","virtualized","infiniteScroll","pageSize","String","maxSelections","placement","className","style","Object","assign","items","setItems","groupedItems","setGroupedItems","value","values","Array","isArray","onChange","addEventListener","e","event","selectedItems","selectedValues","detail","onSelect","item","index","onOpen","onClose","onSearch","query","onLoadMore","page","onCreate","getSelectedValues","hasAttribute","open","groups"],"mappings":"8FAkMO,SAAeA,SACpB,MAAMC,EAASD,EACf,OAAAE,EAAAD,EAAOE,6BAAoB,GAC7B,gBAaO,SAAeH,SACpB,MAAMC,EAASD,EACf,OAAAE,EAAAD,EAAOG,QAAPF,EAAAG,KAAAJ,EACF,uBAxLO,SAAsBK,GAyB3B,MAAML,EAASM,SAASC,cAAc,mBAkCtC,GA/BIF,EAAQG,aAAaR,EAAOS,aAAa,cAAeJ,EAAQG,aAChEH,EAAQK,UAAUV,EAAOS,aAAa,WAAY,IAClDJ,EAAQM,UAAUX,EAAOS,aAAa,WAAY,IAClDJ,EAAQO,OAAOZ,EAAOS,aAAa,QAAS,IAC5CJ,EAAQQ,YAAYb,EAAOS,aAAa,aAAc,IACtDJ,EAAQS,UAAUd,EAAOS,aAAa,WAAY,IAClDJ,EAAQU,aAAaf,EAAOS,aAAa,cAAe,IACxDJ,EAAQW,gBAAgBhB,EAAOS,aAAa,kBAAmB,IAC/DJ,EAAQY,UAAUjB,EAAOS,aAAa,YAAaS,OAAOb,EAAQY,WAClEZ,EAAQc,eAAenB,EAAOS,aAAa,iBAAkBS,OAAOb,EAAQc,gBAC5Ed,EAAQe,WAAWpB,EAAOS,aAAa,YA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AAD,EAAOkD,wBAAP,EAAAjD,EAAAG,KAAAJ,KAAgC,GAE/C,OADiBD,EAAQoD,aAAa,YACpBrB,EAASA,EAAO,EACpC,qBAhCO,SACL/B,EACAM,GAMA,MAAML,EAASD,EAUf,GARIM,EAAQoB,OACVzB,EAAO0B,SAASrB,EAAQoB,OAGtBpB,EAAQsB,cACV3B,EAAO4B,gBAAgBvB,EAAQsB,mBAGX,IAAlBtB,EAAQwB,MAAqB,CAC/B,MAAMC,EAASC,MAAMC,QAAQ3B,EAAQwB,OAASxB,EAAQwB,MAAQ,CAACxB,EAAQwB,OACvE7B,EAAOE,kBAAkB4B,EAC3B,CACF,eAmCO,SAAc/B,SACnB,MAAMC,EAASD,EACf,OAAAE,EAAAD,EAAOoD,OAAPnD,EAAAG,KAAAJ,EACF,0BAqBO,SAAyBD,EAAsBsD,SACpD,MAAMrD,EAASD,EACf,OAAAE,EAAAD,EAAO4B,kBAAP3B,EAAAG,KAAAJ,EAAyBqD,EAC3B,mBAXO,SAAkBtD,EAAsB0B,SAC7C,MAAMzB,EAASD,EACf,OAAAE,EAAAD,EAAO0B,WAAPzB,EAAAG,KAAAJ,EAAkByB,EACpB,mBAvCO,SACL1B,EACA8B,SAEA,MAAM7B,EAASD,EACT+B,EAASC,MAAMC,QAAQH,GAASA,EAAQ,CAACA,GAC/C,OAAA5B,EAAAD,EAAOE,oBAAPD,EAAAG,KAAAJ,EAA2B8B,EAC7B"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
function createSelect(options) {
|
|
2
|
+
const select = document.createElement("enhanced-select");
|
|
3
|
+
if (options.placeholder) select.setAttribute("placeholder", options.placeholder);
|
|
4
|
+
if (options.disabled) select.setAttribute("disabled", "");
|
|
5
|
+
if (options.required) select.setAttribute("required", "");
|
|
6
|
+
if (options.error) select.setAttribute("error", "");
|
|
7
|
+
if (options.searchable) select.setAttribute("searchable", "");
|
|
8
|
+
if (options.multiple) select.setAttribute("multiple", "");
|
|
9
|
+
if (options.virtualized) select.setAttribute("virtualized", "");
|
|
10
|
+
if (options.infiniteScroll) select.setAttribute("infinite-scroll", "");
|
|
11
|
+
if (options.pageSize) select.setAttribute("page-size", String(options.pageSize));
|
|
12
|
+
if (options.maxSelections) select.setAttribute("max-selections", String(options.maxSelections));
|
|
13
|
+
if (options.placement) select.setAttribute("placement", options.placement);
|
|
14
|
+
if (options.className) {
|
|
15
|
+
select.className = options.className;
|
|
16
|
+
}
|
|
17
|
+
if (options.style) {
|
|
18
|
+
Object.assign(select.style, options.style);
|
|
19
|
+
}
|
|
20
|
+
if (options.items) {
|
|
21
|
+
select.setItems(options.items);
|
|
22
|
+
}
|
|
23
|
+
if (options.groupedItems) {
|
|
24
|
+
select.setGroupedItems(options.groupedItems);
|
|
25
|
+
}
|
|
26
|
+
if (options.value !== void 0) {
|
|
27
|
+
const values = Array.isArray(options.value) ? options.value : [options.value];
|
|
28
|
+
select.setSelectedValues(values);
|
|
29
|
+
}
|
|
30
|
+
if (options.onChange) {
|
|
31
|
+
select.addEventListener("change", (e) => {
|
|
32
|
+
const event = e;
|
|
33
|
+
const { selectedItems, selectedValues } = event.detail;
|
|
34
|
+
const value = options.multiple ? selectedValues : selectedValues[0];
|
|
35
|
+
options.onChange(value, selectedItems);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (options.onSelect) {
|
|
39
|
+
select.addEventListener("select", (e) => {
|
|
40
|
+
const event = e;
|
|
41
|
+
options.onSelect(event.detail.item, event.detail.index);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (options.onOpen) {
|
|
45
|
+
select.addEventListener("open", options.onOpen);
|
|
46
|
+
}
|
|
47
|
+
if (options.onClose) {
|
|
48
|
+
select.addEventListener("close", options.onClose);
|
|
49
|
+
}
|
|
50
|
+
if (options.onSearch) {
|
|
51
|
+
select.addEventListener("search", (e) => {
|
|
52
|
+
const event = e;
|
|
53
|
+
options.onSearch(event.detail.query);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (options.onLoadMore) {
|
|
57
|
+
select.addEventListener("loadMore", (e) => {
|
|
58
|
+
const event = e;
|
|
59
|
+
options.onLoadMore(event.detail.page);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (options.onCreate) {
|
|
63
|
+
select.addEventListener("create", (e) => {
|
|
64
|
+
const event = e;
|
|
65
|
+
options.onCreate(event.detail.value);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return select;
|
|
69
|
+
}
|
|
70
|
+
function initSelect(element, options) {
|
|
71
|
+
const select = element;
|
|
72
|
+
if (options.items) {
|
|
73
|
+
select.setItems(options.items);
|
|
74
|
+
}
|
|
75
|
+
if (options.groupedItems) {
|
|
76
|
+
select.setGroupedItems(options.groupedItems);
|
|
77
|
+
}
|
|
78
|
+
if (options.value !== void 0) {
|
|
79
|
+
const values = Array.isArray(options.value) ? options.value : [options.value];
|
|
80
|
+
select.setSelectedValues(values);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function getValue(element) {
|
|
84
|
+
var _a;
|
|
85
|
+
const select = element;
|
|
86
|
+
const values = ((_a = select.getSelectedValues) == null ? void 0 : _a.call(select)) || [];
|
|
87
|
+
const multiple = element.hasAttribute("multiple");
|
|
88
|
+
return multiple ? values : values[0];
|
|
89
|
+
}
|
|
90
|
+
function setValue(element, value) {
|
|
91
|
+
var _a;
|
|
92
|
+
const select = element;
|
|
93
|
+
const values = Array.isArray(value) ? value : [value];
|
|
94
|
+
(_a = select.setSelectedValues) == null ? void 0 : _a.call(select, values);
|
|
95
|
+
}
|
|
96
|
+
function clear(element) {
|
|
97
|
+
var _a;
|
|
98
|
+
const select = element;
|
|
99
|
+
(_a = select.setSelectedValues) == null ? void 0 : _a.call(select, []);
|
|
100
|
+
}
|
|
101
|
+
function open(element) {
|
|
102
|
+
var _a;
|
|
103
|
+
const select = element;
|
|
104
|
+
(_a = select.open) == null ? void 0 : _a.call(select);
|
|
105
|
+
}
|
|
106
|
+
function close(element) {
|
|
107
|
+
var _a;
|
|
108
|
+
const select = element;
|
|
109
|
+
(_a = select.close) == null ? void 0 : _a.call(select);
|
|
110
|
+
}
|
|
111
|
+
function setItems(element, items) {
|
|
112
|
+
var _a;
|
|
113
|
+
const select = element;
|
|
114
|
+
(_a = select.setItems) == null ? void 0 : _a.call(select, items);
|
|
115
|
+
}
|
|
116
|
+
function setGroupedItems(element, groups) {
|
|
117
|
+
var _a;
|
|
118
|
+
const select = element;
|
|
119
|
+
(_a = select.setGroupedItems) == null ? void 0 : _a.call(select, groups);
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
clear,
|
|
123
|
+
close,
|
|
124
|
+
createSelect,
|
|
125
|
+
getValue,
|
|
126
|
+
initSelect,
|
|
127
|
+
open,
|
|
128
|
+
setGroupedItems,
|
|
129
|
+
setItems,
|
|
130
|
+
setValue
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["/**\n * Smilodon Vanilla - Simple helpers for using Smilodon Select with vanilla JavaScript/TypeScript\n * \n * This package provides convenience functions and utilities for working with\n * the Smilodon Select web component in vanilla JavaScript applications.\n */\n\n/**\n * Select item interface\n */\nexport interface SelectItem {\n value: string | number;\n label: string;\n disabled?: boolean;\n group?: string;\n [key: string]: any;\n}\n\n/**\n * Grouped items interface\n */\nexport interface GroupedItem {\n group: string;\n items: SelectItem[];\n}\n\n/**\n * Create a select element with options\n */\nexport function createSelect(options: {\n items?: SelectItem[];\n groupedItems?: GroupedItem[];\n value?: string | number | (string | number)[];\n multiple?: boolean;\n searchable?: boolean;\n placeholder?: string;\n disabled?: boolean;\n required?: boolean;\n error?: boolean;\n infiniteScroll?: boolean;\n pageSize?: number;\n virtualized?: boolean;\n maxSelections?: number;\n placement?: 'bottom' | 'top' | 'auto';\n className?: string;\n style?: Partial<CSSStyleDeclaration>;\n onChange?: (value: any, items: any[]) => void;\n onSelect?: (item: any, index: number) => void;\n onOpen?: () => void;\n onClose?: () => void;\n onSearch?: (query: string) => void;\n onLoadMore?: (page: number) => void;\n onCreate?: (value: string) => void;\n}): HTMLElement {\n const select = document.createElement('enhanced-select') as any;\n\n // Set attributes\n if (options.placeholder) select.setAttribute('placeholder', options.placeholder);\n if (options.disabled) select.setAttribute('disabled', '');\n if (options.required) select.setAttribute('required', '');\n if (options.error) select.setAttribute('error', '');\n if (options.searchable) select.setAttribute('searchable', '');\n if (options.multiple) select.setAttribute('multiple', '');\n if (options.virtualized) select.setAttribute('virtualized', '');\n if (options.infiniteScroll) select.setAttribute('infinite-scroll', '');\n if (options.pageSize) select.setAttribute('page-size', String(options.pageSize));\n if (options.maxSelections) select.setAttribute('max-selections', String(options.maxSelections));\n if (options.placement) select.setAttribute('placement', options.placement);\n\n // Set class name\n if (options.className) {\n select.className = options.className;\n }\n\n // Set inline styles\n if (options.style) {\n Object.assign(select.style, options.style);\n }\n\n // Set items\n if (options.items) {\n select.setItems(options.items);\n }\n if (options.groupedItems) {\n select.setGroupedItems(options.groupedItems);\n }\n\n // Set initial value\n if (options.value !== undefined) {\n const values = Array.isArray(options.value) ? options.value : [options.value];\n select.setSelectedValues(values);\n }\n\n // Add event listeners\n if (options.onChange) {\n select.addEventListener('change', (e: Event) => {\n const event = e as CustomEvent;\n const { selectedItems, selectedValues } = event.detail;\n const value = options.multiple ? selectedValues : selectedValues[0];\n options.onChange!(value, selectedItems);\n });\n }\n\n if (options.onSelect) {\n select.addEventListener('select', (e: Event) => {\n const event = e as CustomEvent;\n options.onSelect!(event.detail.item, event.detail.index);\n });\n }\n\n if (options.onOpen) {\n select.addEventListener('open', options.onOpen);\n }\n\n if (options.onClose) {\n select.addEventListener('close', options.onClose);\n }\n\n if (options.onSearch) {\n select.addEventListener('search', (e: Event) => {\n const event = e as CustomEvent;\n options.onSearch!(event.detail.query);\n });\n }\n\n if (options.onLoadMore) {\n select.addEventListener('loadMore', (e: Event) => {\n const event = e as CustomEvent;\n options.onLoadMore!(event.detail.page);\n });\n }\n\n if (options.onCreate) {\n select.addEventListener('create', (e: Event) => {\n const event = e as CustomEvent;\n options.onCreate!(event.detail.value);\n });\n }\n\n return select;\n}\n\n/**\n * Initialize a select element that already exists in the DOM\n */\nexport function initSelect(\n element: HTMLElement,\n options: {\n items?: SelectItem[];\n groupedItems?: GroupedItem[];\n value?: string | number | (string | number)[];\n }\n): void {\n const select = element as any;\n\n if (options.items) {\n select.setItems(options.items);\n }\n\n if (options.groupedItems) {\n select.setGroupedItems(options.groupedItems);\n }\n\n if (options.value !== undefined) {\n const values = Array.isArray(options.value) ? options.value : [options.value];\n select.setSelectedValues(values);\n }\n}\n\n/**\n * Get the selected value(s) from a select element\n */\nexport function getValue(element: HTMLElement): any {\n const select = element as any;\n const values = select.getSelectedValues?.() || [];\n const multiple = element.hasAttribute('multiple');\n return multiple ? values : values[0];\n}\n\n/**\n * Set the selected value(s) for a select element\n */\nexport function setValue(\n element: HTMLElement,\n value: string | number | (string | number)[]\n): void {\n const select = element as any;\n const values = Array.isArray(value) ? value : [value];\n select.setSelectedValues?.(values);\n}\n\n/**\n * Clear the selection\n */\nexport function clear(element: HTMLElement): void {\n const select = element as any;\n select.setSelectedValues?.([]);\n}\n\n/**\n * Open the dropdown\n */\nexport function open(element: HTMLElement): void {\n const select = element as any;\n select.open?.();\n}\n\n/**\n * Close the dropdown\n */\nexport function close(element: HTMLElement): void {\n const select = element as any;\n select.close?.();\n}\n\n/**\n * Update items\n */\nexport function setItems(element: HTMLElement, items: SelectItem[]): void {\n const select = element as any;\n select.setItems?.(items);\n}\n\n/**\n * Update grouped items\n */\nexport function setGroupedItems(element: HTMLElement, groups: GroupedItem[]): void {\n const select = element as any;\n select.setGroupedItems?.(groups);\n}\n\n// Re-export types from core for convenience\nexport type {\n SelectEventDetail,\n ChangeEventDetail,\n SearchEventDetail,\n LoadMoreEventDetail,\n} from '@smilodon/core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K;AAC5E,WAAO,kBAAkB,MAAM;AAAA,EACjC;AACF;AAKO,SAAS,SAAS,SAA2B;AA/I7C;AAgJL,QAAM,SAAS;AACf,QAAM,WAAS,YAAO,sBAAP,oCAAgC,CAAA;AAC/C,QAAM,WAAW,QAAQ,aAAa,UAAU;AAChD,SAAO,WAAW,SAAS,OAAO,CAAC;AACrC;AAKO,SAAS,SACd,SACA,OACM;AA5JD;AA6JL,QAAM,SAAS;AACf,QAAM,SAAS,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AACpD,eAAO,sBAAP,gCAA2B;AAC7B;AAKO,SAAS,MAAM,SAA4B;AArK3C;AAsKL,QAAM,SAAS;AACf,eAAO,sBAAP,gCAA2B;AAC7B;AAKO,SAAS,KAAK,SAA4B;AA7K1C;AA8KL,QAAM,SAAS;AACf,eAAO,SAAP;AACF;AAKO,SAAS,MAAM,SAA4B;AArL3C;AAsLL,QAAM,SAAS;AACf,eAAO,UAAP;AACF;AAKO,SAAS,SAAS,SAAsB,OAA2B;AA7LnE;AA8LL,QAAM,SAAS;AACf,eAAO,aAAP,gCAAkB;AACpB;AAKO,SAAS,gBAAgB,SAAsB,QAA6B;AArM5E;AAsML,QAAM,SAAS;AACf,eAAO,oBAAP,gCAAyB;AAC3B;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@smilodon/vanilla",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Vanilla JavaScript helpers for Smilodon Select - part of the Smilodon UI toolkit",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc --emitDeclarationOnly --outDir dist/types && vite build",
|
|
22
|
+
"size": "gzip -c dist/index.mjs | wc -c",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@smilodon/core": "^1.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^5.6.2",
|
|
30
|
+
"vite": "^5.4.11"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"vanilla",
|
|
34
|
+
"javascript",
|
|
35
|
+
"typescript",
|
|
36
|
+
"select",
|
|
37
|
+
"dropdown",
|
|
38
|
+
"combobox",
|
|
39
|
+
"autocomplete",
|
|
40
|
+
"virtualization",
|
|
41
|
+
"infinite-scroll",
|
|
42
|
+
"accessibility",
|
|
43
|
+
"wcag",
|
|
44
|
+
"a11y",
|
|
45
|
+
"smilodon",
|
|
46
|
+
"web-component"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/navidrezadoost/smilodon.git",
|
|
51
|
+
"directory": "packages/vanilla"
|
|
52
|
+
},
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/navidrezadoost/smilodon/issues"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/navidrezadoost/smilodon#readme",
|
|
57
|
+
"author": "Navid Rezadoost <navidrezadoost07@gmail.com>",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"sideEffects": false,
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18",
|
|
62
|
+
"npm": ">=9"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public",
|
|
66
|
+
"registry": "https://registry.npmjs.org/"
|
|
67
|
+
}
|
|
68
|
+
}
|