@aspect-ops/exon-ui 0.0.3 → 0.2.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 +929 -54
- package/dist/components/Accordion/Accordion.svelte +79 -0
- package/dist/components/Accordion/Accordion.svelte.d.ts +10 -0
- package/dist/components/Accordion/AccordionItem.svelte +198 -0
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +10 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/Accordion/index.js +2 -0
- package/dist/components/Carousel/Carousel.svelte +454 -0
- package/dist/components/Carousel/Carousel.svelte.d.ts +14 -0
- package/dist/components/Carousel/CarouselSlide.svelte +22 -0
- package/dist/components/Carousel/CarouselSlide.svelte.d.ts +7 -0
- package/dist/components/Carousel/index.d.ts +2 -0
- package/dist/components/Carousel/index.js +2 -0
- package/dist/components/Chip/Chip.svelte +461 -0
- package/dist/components/Chip/Chip.svelte.d.ts +17 -0
- package/dist/components/Chip/ChipGroup.svelte +76 -0
- package/dist/components/Chip/ChipGroup.svelte.d.ts +9 -0
- package/dist/components/Chip/index.d.ts +2 -0
- package/dist/components/Chip/index.js +2 -0
- package/dist/components/DatePicker/DatePicker.svelte +746 -0
- package/dist/components/DatePicker/DatePicker.svelte.d.ts +19 -0
- package/dist/components/DatePicker/index.d.ts +1 -0
- package/dist/components/DatePicker/index.js +1 -0
- package/dist/components/FileUpload/FileUpload.svelte +484 -0
- package/dist/components/FileUpload/FileUpload.svelte.d.ts +16 -0
- package/dist/components/FileUpload/index.d.ts +1 -0
- package/dist/components/FileUpload/index.js +1 -0
- package/dist/components/Image/Image.svelte +223 -0
- package/dist/components/Image/Image.svelte.d.ts +19 -0
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Image/index.js +1 -0
- package/dist/components/NumberInput/NumberInput.svelte +293 -0
- package/dist/components/NumberInput/NumberInput.svelte.d.ts +16 -0
- package/dist/components/NumberInput/index.d.ts +1 -0
- package/dist/components/NumberInput/index.js +1 -0
- package/dist/components/OTPInput/OTPInput.svelte +312 -0
- package/dist/components/OTPInput/OTPInput.svelte.d.ts +57 -0
- package/dist/components/OTPInput/index.d.ts +1 -0
- package/dist/components/OTPInput/index.js +1 -0
- package/dist/components/Pagination/Pagination.svelte +243 -0
- package/dist/components/Pagination/Pagination.svelte.d.ts +10 -0
- package/dist/components/Pagination/index.d.ts +1 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/Rating/Rating.svelte +316 -0
- package/dist/components/Rating/Rating.svelte.d.ts +16 -0
- package/dist/components/Rating/index.d.ts +1 -0
- package/dist/components/Rating/index.js +1 -0
- package/dist/components/SearchInput/SearchInput.svelte +480 -0
- package/dist/components/SearchInput/SearchInput.svelte.d.ts +22 -0
- package/dist/components/SearchInput/index.d.ts +1 -0
- package/dist/components/SearchInput/index.js +1 -0
- package/dist/components/Slider/Slider.svelte +324 -0
- package/dist/components/Slider/Slider.svelte.d.ts +14 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Slider/index.js +1 -0
- package/dist/components/Stepper/Stepper.svelte +100 -0
- package/dist/components/Stepper/Stepper.svelte.d.ts +11 -0
- package/dist/components/Stepper/StepperStep.svelte +391 -0
- package/dist/components/Stepper/StepperStep.svelte.d.ts +13 -0
- package/dist/components/Stepper/index.d.ts +2 -0
- package/dist/components/Stepper/index.js +2 -0
- package/dist/components/TimePicker/TimePicker.svelte +803 -0
- package/dist/components/TimePicker/TimePicker.svelte.d.ts +17 -0
- package/dist/components/TimePicker/index.d.ts +1 -0
- package/dist/components/TimePicker/index.js +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.svelte +91 -0
- package/dist/components/ToggleGroup/ToggleGroup.svelte.d.ts +13 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.svelte +158 -0
- package/dist/components/ToggleGroup/ToggleGroupItem.svelte.d.ts +9 -0
- package/dist/components/ToggleGroup/index.d.ts +3 -0
- package/dist/components/ToggleGroup/index.js +2 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +12 -0
- package/dist/types/data-display.d.ts +68 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/input.d.ts +82 -0
- package/dist/types/input.js +2 -0
- package/dist/types/navigation.d.ts +15 -0
- package/package.json +1 -1
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ChipVariant, ChipColor, ChipSize } from '../../types/index.js';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
variant?: ChipVariant;
|
|
6
|
+
color?: ChipColor;
|
|
7
|
+
size?: ChipSize;
|
|
8
|
+
removable?: boolean;
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
class?: string;
|
|
12
|
+
onclick?: () => void;
|
|
13
|
+
onremove?: () => void;
|
|
14
|
+
children?: import('svelte').Snippet;
|
|
15
|
+
leadingIcon?: import('svelte').Snippet;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
variant = 'filled',
|
|
20
|
+
color = 'default',
|
|
21
|
+
size = 'md',
|
|
22
|
+
removable = false,
|
|
23
|
+
selected = false,
|
|
24
|
+
disabled = false,
|
|
25
|
+
class: className = '',
|
|
26
|
+
onclick,
|
|
27
|
+
onremove,
|
|
28
|
+
children,
|
|
29
|
+
leadingIcon
|
|
30
|
+
}: Props = $props();
|
|
31
|
+
|
|
32
|
+
const isClickable = $derived(!!onclick && !disabled);
|
|
33
|
+
|
|
34
|
+
function handleClick() {
|
|
35
|
+
if (!disabled && onclick) {
|
|
36
|
+
onclick();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function handleRemove(event: MouseEvent) {
|
|
41
|
+
event.stopPropagation();
|
|
42
|
+
if (!disabled && onremove) {
|
|
43
|
+
onremove();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function handleKeydown(event: KeyboardEvent) {
|
|
48
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
handleClick();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
56
|
+
<span
|
|
57
|
+
class="chip chip--{variant} chip--{color} chip--{size} {selected
|
|
58
|
+
? 'chip--selected'
|
|
59
|
+
: ''} {isClickable ? 'chip--clickable' : ''} {disabled ? 'chip--disabled' : ''} {className}"
|
|
60
|
+
role={isClickable ? 'button' : undefined}
|
|
61
|
+
aria-pressed={isClickable ? selected : undefined}
|
|
62
|
+
aria-disabled={disabled || undefined}
|
|
63
|
+
tabindex={isClickable && !disabled ? 0 : -1}
|
|
64
|
+
onclick={isClickable ? handleClick : undefined}
|
|
65
|
+
onkeydown={isClickable ? handleKeydown : undefined}
|
|
66
|
+
>
|
|
67
|
+
{#if leadingIcon}
|
|
68
|
+
<span class="chip__icon" aria-hidden="true">
|
|
69
|
+
{@render leadingIcon()}
|
|
70
|
+
</span>
|
|
71
|
+
{/if}
|
|
72
|
+
<span class="chip__label">
|
|
73
|
+
{#if children}
|
|
74
|
+
{@render children()}
|
|
75
|
+
{/if}
|
|
76
|
+
</span>
|
|
77
|
+
{#if removable}
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
class="chip__remove"
|
|
81
|
+
onclick={handleRemove}
|
|
82
|
+
aria-label="Remove"
|
|
83
|
+
{disabled}
|
|
84
|
+
>
|
|
85
|
+
×
|
|
86
|
+
</button>
|
|
87
|
+
{/if}
|
|
88
|
+
</span>
|
|
89
|
+
|
|
90
|
+
<style>
|
|
91
|
+
.chip {
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: var(--space-xs, 0.25rem);
|
|
95
|
+
min-height: var(--touch-target-min, 44px);
|
|
96
|
+
padding: 0.25rem 0.75rem;
|
|
97
|
+
border: 1px solid transparent;
|
|
98
|
+
border-radius: var(--radius-full, 9999px);
|
|
99
|
+
font-family: inherit;
|
|
100
|
+
font-size: var(--text-sm, 0.875rem);
|
|
101
|
+
font-weight: 500;
|
|
102
|
+
line-height: 1;
|
|
103
|
+
white-space: nowrap;
|
|
104
|
+
transition: all var(--transition-fast, 150ms ease);
|
|
105
|
+
-webkit-tap-highlight-color: transparent;
|
|
106
|
+
background: transparent;
|
|
107
|
+
text-align: left;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.chip__label {
|
|
111
|
+
flex: 1;
|
|
112
|
+
min-width: 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.chip__icon {
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
justify-content: center;
|
|
119
|
+
flex-shrink: 0;
|
|
120
|
+
width: 1rem;
|
|
121
|
+
height: 1rem;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.chip__remove {
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
justify-content: center;
|
|
128
|
+
flex-shrink: 0;
|
|
129
|
+
width: 2.75rem;
|
|
130
|
+
height: 2.75rem;
|
|
131
|
+
margin: -0.25rem -0.25rem -0.25rem 0;
|
|
132
|
+
padding: 0;
|
|
133
|
+
border: none;
|
|
134
|
+
border-radius: var(--radius-full, 9999px);
|
|
135
|
+
background: transparent;
|
|
136
|
+
font-family: inherit;
|
|
137
|
+
font-size: 1.25rem;
|
|
138
|
+
line-height: 1;
|
|
139
|
+
color: inherit;
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
transition: background-color var(--transition-fast, 150ms ease);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.chip__remove:hover:not(:disabled) {
|
|
145
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.chip__remove:focus-visible {
|
|
149
|
+
outline: 2px solid currentColor;
|
|
150
|
+
outline-offset: 2px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.chip__remove:disabled {
|
|
154
|
+
opacity: 0.5;
|
|
155
|
+
cursor: not-allowed;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* Clickable state */
|
|
159
|
+
.chip--clickable {
|
|
160
|
+
cursor: pointer;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.chip--clickable:focus-visible {
|
|
164
|
+
outline: 2px solid var(--color-primary, #3b82f6);
|
|
165
|
+
outline-offset: 2px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* Disabled state */
|
|
169
|
+
.chip--disabled {
|
|
170
|
+
opacity: 0.5;
|
|
171
|
+
cursor: not-allowed;
|
|
172
|
+
pointer-events: none;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/* Size variants - all meet 44px touch target */
|
|
176
|
+
.chip--sm {
|
|
177
|
+
min-height: var(--touch-target-min, 44px);
|
|
178
|
+
padding: 0.25rem 0.75rem;
|
|
179
|
+
font-size: var(--text-xs, 0.75rem);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.chip--sm .chip__icon {
|
|
183
|
+
width: 0.875rem;
|
|
184
|
+
height: 0.875rem;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.chip--sm .chip__remove {
|
|
188
|
+
width: 2.5rem;
|
|
189
|
+
height: 2.5rem;
|
|
190
|
+
font-size: 1rem;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.chip--md {
|
|
194
|
+
min-height: var(--touch-target-min, 44px);
|
|
195
|
+
padding: 0.375rem 1rem;
|
|
196
|
+
font-size: var(--text-sm, 0.875rem);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.chip--md .chip__icon {
|
|
200
|
+
width: 1rem;
|
|
201
|
+
height: 1rem;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.chip--md .chip__remove {
|
|
205
|
+
width: 2.75rem;
|
|
206
|
+
height: 2.75rem;
|
|
207
|
+
font-size: 1.25rem;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.chip--lg {
|
|
211
|
+
min-height: 3rem;
|
|
212
|
+
padding: 0.5rem 1.25rem;
|
|
213
|
+
font-size: var(--text-base, 1rem);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.chip--lg .chip__icon {
|
|
217
|
+
width: 1.25rem;
|
|
218
|
+
height: 1.25rem;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.chip--lg .chip__remove {
|
|
222
|
+
width: 3rem;
|
|
223
|
+
height: 3rem;
|
|
224
|
+
font-size: 1.5rem;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* Filled variant - default */
|
|
228
|
+
.chip--filled.chip--default {
|
|
229
|
+
background: var(--color-bg-muted, #f3f4f6);
|
|
230
|
+
color: var(--color-text, #1f2937);
|
|
231
|
+
border-color: transparent;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.chip--filled.chip--default.chip--clickable:hover:not(.chip--disabled) {
|
|
235
|
+
background: var(--color-border, #e5e7eb);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.chip--filled.chip--default .chip__remove:hover:not(:disabled) {
|
|
239
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.chip--filled.chip--primary {
|
|
243
|
+
background: var(--color-primary, #3b82f6);
|
|
244
|
+
color: var(--color-text-inverse, #ffffff);
|
|
245
|
+
border-color: transparent;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.chip--filled.chip--primary.chip--clickable:hover:not(.chip--disabled) {
|
|
249
|
+
background: var(--color-primary-hover, #2563eb);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.chip--filled.chip--primary .chip__remove:hover:not(:disabled) {
|
|
253
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.chip--filled.chip--success {
|
|
257
|
+
background: var(--color-success, #10b981);
|
|
258
|
+
color: var(--color-text-inverse, #ffffff);
|
|
259
|
+
border-color: transparent;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.chip--filled.chip--success.chip--clickable:hover:not(.chip--disabled) {
|
|
263
|
+
background: var(--color-success-hover, #059669);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.chip--filled.chip--success .chip__remove:hover:not(:disabled) {
|
|
267
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.chip--filled.chip--warning {
|
|
271
|
+
background: var(--color-warning, #f59e0b);
|
|
272
|
+
color: var(--color-text, #1f2937);
|
|
273
|
+
border-color: transparent;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.chip--filled.chip--warning.chip--clickable:hover:not(.chip--disabled) {
|
|
277
|
+
background: var(--color-warning-hover, #d97706);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.chip--filled.chip--warning .chip__remove:hover:not(:disabled) {
|
|
281
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.chip--filled.chip--error {
|
|
285
|
+
background: var(--color-error, #ef4444);
|
|
286
|
+
color: var(--color-text-inverse, #ffffff);
|
|
287
|
+
border-color: transparent;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.chip--filled.chip--error.chip--clickable:hover:not(.chip--disabled) {
|
|
291
|
+
background: var(--color-error-hover, #dc2626);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.chip--filled.chip--error .chip__remove:hover:not(:disabled) {
|
|
295
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* Outlined variant */
|
|
299
|
+
.chip--outlined.chip--default {
|
|
300
|
+
background: transparent;
|
|
301
|
+
color: var(--color-text, #1f2937);
|
|
302
|
+
border-color: var(--color-border, #e5e7eb);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.chip--outlined.chip--default.chip--clickable:hover:not(.chip--disabled) {
|
|
306
|
+
background: var(--color-bg-muted, #f3f4f6);
|
|
307
|
+
border-color: var(--color-border-hover, #d1d5db);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.chip--outlined.chip--default .chip__remove:hover:not(:disabled) {
|
|
311
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.chip--outlined.chip--primary {
|
|
315
|
+
background: transparent;
|
|
316
|
+
color: var(--color-primary, #3b82f6);
|
|
317
|
+
border-color: var(--color-primary, #3b82f6);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.chip--outlined.chip--primary.chip--clickable:hover:not(.chip--disabled) {
|
|
321
|
+
background: rgba(59, 130, 246, 0.1);
|
|
322
|
+
border-color: var(--color-primary-hover, #2563eb);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.chip--outlined.chip--primary .chip__remove:hover:not(:disabled) {
|
|
326
|
+
background-color: rgba(59, 130, 246, 0.1);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.chip--outlined.chip--success {
|
|
330
|
+
background: transparent;
|
|
331
|
+
color: var(--color-success, #10b981);
|
|
332
|
+
border-color: var(--color-success, #10b981);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.chip--outlined.chip--success.chip--clickable:hover:not(.chip--disabled) {
|
|
336
|
+
background: rgba(16, 185, 129, 0.1);
|
|
337
|
+
border-color: var(--color-success-hover, #059669);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.chip--outlined.chip--success .chip__remove:hover:not(:disabled) {
|
|
341
|
+
background-color: rgba(16, 185, 129, 0.1);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.chip--outlined.chip--warning {
|
|
345
|
+
background: transparent;
|
|
346
|
+
color: var(--color-warning, #f59e0b);
|
|
347
|
+
border-color: var(--color-warning, #f59e0b);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.chip--outlined.chip--warning.chip--clickable:hover:not(.chip--disabled) {
|
|
351
|
+
background: rgba(245, 158, 11, 0.1);
|
|
352
|
+
border-color: var(--color-warning-hover, #d97706);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.chip--outlined.chip--warning .chip__remove:hover:not(:disabled) {
|
|
356
|
+
background-color: rgba(245, 158, 11, 0.1);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.chip--outlined.chip--error {
|
|
360
|
+
background: transparent;
|
|
361
|
+
color: var(--color-error, #ef4444);
|
|
362
|
+
border-color: var(--color-error, #ef4444);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.chip--outlined.chip--error.chip--clickable:hover:not(.chip--disabled) {
|
|
366
|
+
background: rgba(239, 68, 68, 0.1);
|
|
367
|
+
border-color: var(--color-error-hover, #dc2626);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.chip--outlined.chip--error .chip__remove:hover:not(:disabled) {
|
|
371
|
+
background-color: rgba(239, 68, 68, 0.1);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/* Soft variant */
|
|
375
|
+
.chip--soft.chip--default {
|
|
376
|
+
background: rgba(107, 114, 128, 0.1);
|
|
377
|
+
color: var(--color-text, #1f2937);
|
|
378
|
+
border-color: transparent;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.chip--soft.chip--default.chip--clickable:hover:not(.chip--disabled) {
|
|
382
|
+
background: rgba(107, 114, 128, 0.2);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.chip--soft.chip--default .chip__remove:hover:not(:disabled) {
|
|
386
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.chip--soft.chip--primary {
|
|
390
|
+
background: rgba(59, 130, 246, 0.15);
|
|
391
|
+
color: var(--color-primary, #3b82f6);
|
|
392
|
+
border-color: transparent;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.chip--soft.chip--primary.chip--clickable:hover:not(.chip--disabled) {
|
|
396
|
+
background: rgba(59, 130, 246, 0.25);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.chip--soft.chip--primary .chip__remove:hover:not(:disabled) {
|
|
400
|
+
background-color: rgba(59, 130, 246, 0.2);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.chip--soft.chip--success {
|
|
404
|
+
background: rgba(16, 185, 129, 0.15);
|
|
405
|
+
color: var(--color-success, #10b981);
|
|
406
|
+
border-color: transparent;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.chip--soft.chip--success.chip--clickable:hover:not(.chip--disabled) {
|
|
410
|
+
background: rgba(16, 185, 129, 0.25);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.chip--soft.chip--success .chip__remove:hover:not(:disabled) {
|
|
414
|
+
background-color: rgba(16, 185, 129, 0.2);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.chip--soft.chip--warning {
|
|
418
|
+
background: rgba(245, 158, 11, 0.15);
|
|
419
|
+
color: var(--color-warning, #f59e0b);
|
|
420
|
+
border-color: transparent;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.chip--soft.chip--warning.chip--clickable:hover:not(.chip--disabled) {
|
|
424
|
+
background: rgba(245, 158, 11, 0.25);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.chip--soft.chip--warning .chip__remove:hover:not(:disabled) {
|
|
428
|
+
background-color: rgba(245, 158, 11, 0.2);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.chip--soft.chip--error {
|
|
432
|
+
background: rgba(239, 68, 68, 0.15);
|
|
433
|
+
color: var(--color-error, #ef4444);
|
|
434
|
+
border-color: transparent;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.chip--soft.chip--error.chip--clickable:hover:not(.chip--disabled) {
|
|
438
|
+
background: rgba(239, 68, 68, 0.25);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
.chip--soft.chip--error .chip__remove:hover:not(:disabled) {
|
|
442
|
+
background-color: rgba(239, 68, 68, 0.2);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/* Selected state */
|
|
446
|
+
.chip--selected.chip--outlined,
|
|
447
|
+
.chip--selected.chip--soft {
|
|
448
|
+
border-width: 2px;
|
|
449
|
+
padding: calc(0.375rem - 1px) calc(1rem - 1px);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
.chip--selected.chip--outlined.chip--sm,
|
|
453
|
+
.chip--selected.chip--soft.chip--sm {
|
|
454
|
+
padding: calc(0.25rem - 1px) calc(0.75rem - 1px);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.chip--selected.chip--outlined.chip--lg,
|
|
458
|
+
.chip--selected.chip--soft.chip--lg {
|
|
459
|
+
padding: calc(0.5rem - 1px) calc(1.25rem - 1px);
|
|
460
|
+
}
|
|
461
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChipVariant, ChipColor, ChipSize } from '../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
variant?: ChipVariant;
|
|
4
|
+
color?: ChipColor;
|
|
5
|
+
size?: ChipSize;
|
|
6
|
+
removable?: boolean;
|
|
7
|
+
selected?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
class?: string;
|
|
10
|
+
onclick?: () => void;
|
|
11
|
+
onremove?: () => void;
|
|
12
|
+
children?: import('svelte').Snippet;
|
|
13
|
+
leadingIcon?: import('svelte').Snippet;
|
|
14
|
+
}
|
|
15
|
+
declare const Chip: import("svelte").Component<Props, {}, "">;
|
|
16
|
+
type Chip = ReturnType<typeof Chip>;
|
|
17
|
+
export default Chip;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setContext } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
value?: string | string[];
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
class?: string;
|
|
8
|
+
children?: import('svelte').Snippet;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
value = $bindable([]),
|
|
13
|
+
multiple = false,
|
|
14
|
+
class: className = '',
|
|
15
|
+
children
|
|
16
|
+
}: Props = $props();
|
|
17
|
+
|
|
18
|
+
// Normalize value to always be an array internally
|
|
19
|
+
let selectedValues = $derived.by(() => {
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
return value ? [value] : [];
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
function isSelected(chipValue: string): boolean {
|
|
27
|
+
return selectedValues.includes(chipValue);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function toggleSelection(chipValue: string) {
|
|
31
|
+
if (multiple) {
|
|
32
|
+
// Multiple selection mode
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
if (selectedValues.includes(chipValue)) {
|
|
35
|
+
value = selectedValues.filter((v) => v !== chipValue);
|
|
36
|
+
} else {
|
|
37
|
+
value = [...selectedValues, chipValue];
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
// Convert to array if not already
|
|
41
|
+
value = selectedValues.includes(chipValue) ? [] : [chipValue];
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
// Single selection mode
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
value = selectedValues.includes(chipValue) ? [] : [chipValue];
|
|
47
|
+
} else {
|
|
48
|
+
value = value === chipValue ? '' : chipValue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Provide context for child chips
|
|
54
|
+
setContext('chipGroup', {
|
|
55
|
+
isSelected,
|
|
56
|
+
toggleSelection,
|
|
57
|
+
get multiple() {
|
|
58
|
+
return multiple;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<div class="chip-group {className}" role="group">
|
|
64
|
+
{#if children}
|
|
65
|
+
{@render children()}
|
|
66
|
+
{/if}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
.chip-group {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-wrap: wrap;
|
|
73
|
+
gap: var(--space-sm, 0.5rem);
|
|
74
|
+
align-items: center;
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
value?: string | string[];
|
|
3
|
+
multiple?: boolean;
|
|
4
|
+
class?: string;
|
|
5
|
+
children?: import('svelte').Snippet;
|
|
6
|
+
}
|
|
7
|
+
declare const ChipGroup: import("svelte").Component<Props, {}, "value">;
|
|
8
|
+
type ChipGroup = ReturnType<typeof ChipGroup>;
|
|
9
|
+
export default ChipGroup;
|