lapikit 0.7.3 → 0.7.4

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.
Files changed (67) hide show
  1. package/dist/@types/components.d.ts +1 -7
  2. package/dist/@types/dom.d.ts +4 -3
  3. package/dist/@types/props.d.ts +3 -3
  4. package/dist/animations/ripple.js +8 -2
  5. package/dist/components/accordion/accordion.svelte +192 -228
  6. package/dist/components/accordion/accordion.types.d.ts +5 -7
  7. package/dist/components/accordion/modules/accordion-item.svelte +144 -140
  8. package/dist/components/alert/alert.svelte +246 -293
  9. package/dist/components/alert/alert.types.d.ts +5 -5
  10. package/dist/components/app/app.svelte +25 -43
  11. package/dist/components/appbar/appbar.svelte +205 -190
  12. package/dist/components/appbar/appbar.types.d.ts +6 -6
  13. package/dist/components/aspect-ratio/aspect-ratio.svelte +43 -63
  14. package/dist/components/avatar/avatar.svelte +169 -161
  15. package/dist/components/avatar/avatar.types.d.ts +3 -4
  16. package/dist/components/btn/btn.svelte +431 -465
  17. package/dist/components/btn/btn.types.d.ts +5 -6
  18. package/dist/components/card/card.svelte +24 -23
  19. package/dist/components/card/card.types.d.ts +2 -2
  20. package/dist/components/card/modules/card-content.svelte +4 -1
  21. package/dist/components/card/modules/card-title.svelte +4 -1
  22. package/dist/components/chip/chip.svelte +416 -464
  23. package/dist/components/chip/chip.types.d.ts +5 -5
  24. package/dist/components/dialog/dialog.svelte +174 -171
  25. package/dist/components/dialog/dialog.types.d.ts +6 -6
  26. package/dist/components/dropdown/dropdown.svelte +149 -144
  27. package/dist/components/dropdown/dropdown.types.d.ts +4 -11
  28. package/dist/components/field/field.svelte +474 -0
  29. package/dist/components/field/field.svelte.d.ts +4 -0
  30. package/dist/components/field/field.types.d.ts +46 -0
  31. package/dist/components/field/field.types.js +1 -0
  32. package/dist/components/icon/icon.svelte +67 -96
  33. package/dist/components/icon/icon.types.d.ts +2 -1
  34. package/dist/components/index.d.ts +2 -0
  35. package/dist/components/index.js +1 -0
  36. package/dist/components/list/list.svelte +193 -194
  37. package/dist/components/list/list.types.d.ts +5 -7
  38. package/dist/components/list/modules/list-item.svelte +134 -147
  39. package/dist/components/modal/modal.svelte +239 -222
  40. package/dist/components/modal/modal.types.d.ts +6 -6
  41. package/dist/components/popover/popover.svelte +125 -127
  42. package/dist/components/popover/popover.types.d.ts +4 -11
  43. package/dist/components/separator/separator.svelte +56 -87
  44. package/dist/components/separator/separator.types.d.ts +1 -1
  45. package/dist/components/spacer/spacer.svelte +6 -25
  46. package/dist/components/textfield/textfield.svelte +94 -543
  47. package/dist/components/textfield/textfield.types.d.ts +13 -33
  48. package/dist/components/toolbar/toolbar.svelte +216 -211
  49. package/dist/components/toolbar/toolbar.types.d.ts +8 -9
  50. package/dist/components/tooltip/tooltip.svelte +201 -266
  51. package/dist/components/tooltip/tooltip.types.d.ts +3 -10
  52. package/dist/constants.js +1 -0
  53. package/dist/html-mapped.d.ts +1 -15
  54. package/dist/html-mapped.js +0 -19
  55. package/dist/labs/sheet/sheet.svelte +27 -22
  56. package/dist/utils/color.d.ts +2 -2
  57. package/dist/utils/color.js +2 -1
  58. package/dist/utils/components.d.ts +10 -10
  59. package/dist/utils/components.js +16 -75
  60. package/dist/utils/floating.d.ts +58 -0
  61. package/dist/utils/floating.js +131 -0
  62. package/dist/utils/index.d.ts +1 -0
  63. package/dist/utils/index.js +1 -0
  64. package/package.json +3 -3
  65. package/dist/components/dropdown/dropdown.svelte.js +0 -148
  66. package/dist/components/popover/popover.svelte.js +0 -134
  67. package/dist/components/tooltip/tooltip.svelte.js +0 -131
@@ -1,6 +1,5 @@
1
1
  <script lang="ts">
2
- import { useClassName, useElevation, useStyles } from '../../utils';
3
- import { makeComponentProps } from '../../html-mapped';
2
+ import { useComponentAttrs, useElevation } from '../../utils';
4
3
  import { ripple } from '../../animations';
5
4
  import type { ChipProps } from './chip.types.js';
6
5
 
@@ -8,13 +7,14 @@
8
7
  ref = $bindable(),
9
8
  is = 'div',
10
9
  children,
11
- class: className = '',
12
- style: styleAttr = '',
10
+ class: className,
11
+ style: styleAttr,
13
12
  's-class': sClass,
14
13
  's-style': sStyle,
15
14
  variant = 'filled',
16
15
  density = 'default',
17
16
  rounded = 'full',
17
+ interactive,
18
18
  loading,
19
19
  active = false,
20
20
  size = 'md',
@@ -32,486 +32,438 @@
32
32
  prepend,
33
33
  readonly = false,
34
34
  elevation,
35
- background,
36
35
  color,
37
36
  ...rest
38
37
  }: ChipProps = $props();
39
38
 
40
- let { classProps, styleProps, restProps } = $derived(
41
- makeComponentProps(rest as Record<string, unknown>)
39
+ let attrs = $derived(
40
+ useComponentAttrs('kit-chip', { className, sClass, styleAttr, sStyle, color, active }, rest)
42
41
  );
43
-
44
42
  let elevationState = $derived(useElevation(elevation));
45
-
46
- let componentClass = $derived(
47
- useClassName({
48
- baseClass: 'kit-chip',
49
- className: `${className ?? ''}`.trim(),
50
- sClass,
51
- classProps
52
- })
53
- );
54
-
55
- let componentStyle = $derived(
56
- useStyles({
57
- styleAttr,
58
- sStyle,
59
- styleProps
60
- })
43
+ let hasOutline = $derived(variant === 'outline' || variant === 'surface');
44
+
45
+ let isInput = $derived(!!input || is === 'input');
46
+ let isDisabled = $derived(!!disabled);
47
+ let isReadonly = $derived(!!readonly);
48
+ let isLocked = $derived(isDisabled || isReadonly);
49
+ let hasPressHandler = $derived(
50
+ ['onclick', 'onkeydown', 'onkeyup'].some((key) => typeof attrs.rest[key] === 'function')
61
51
  );
62
-
63
- const isInput = $derived(!!input);
64
- const isDisabled = $derived(!!disabled);
65
- const isReadonly = $derived(!!readonly);
66
- const isLocked = $derived(isDisabled || isReadonly);
67
-
68
- const hasOnClick = $derived(typeof restProps.onclick === 'function');
69
- const hasOnKeyDown = $derived(typeof restProps.onkeydown === 'function');
70
- const hasOnKeyUp = $derived(typeof restProps.onkeyup === 'function');
71
- const hasOnPressHandler = $derived(hasOnClick || hasOnKeyDown || hasOnKeyUp);
72
- const wantsActionTag = $derived(is === 'button' || is === 'a' || is === 'input');
73
-
74
- const tag = $derived(
75
- (href && 'a') ||
76
- (isInput && 'input') ||
77
- (wantsActionTag && is) ||
78
- (hasOnPressHandler && 'button') ||
79
- 'div'
80
- );
81
-
82
- const isInteractive = $derived(
83
- (tag === 'button' || tag === 'a' || isInput || hasOnPressHandler) && !isLocked
84
- );
85
- const inputWrapperTag = $derived(type === 'checkbox' || type === 'radio' ? 'label' : 'div');
86
- const resolvedHref = $derived(isLocked ? undefined : href);
87
- const resolvedDisabled = $derived((tag === 'button' && isLocked) || undefined);
88
-
89
- const resolvedType = $derived(tag !== 'button' ? type : (type ?? 'button'));
90
-
91
- let resolvedStyle = $derived(
92
- [
93
- componentStyle,
94
- color ? `--kit-chip-fg:${color && `var(--kit-color-${color})`}` : '',
95
- background ? `--kit-chip-bg:${background && `var(--kit-color-${background})`}` : ''
96
- ]
97
- .filter(Boolean)
98
- .join('; ')
52
+ let tag = $derived<'button' | 'a' | 'label' | 'div'>(
53
+ isInput
54
+ ? type === 'checkbox' || type === 'radio'
55
+ ? 'label'
56
+ : 'div'
57
+ : href || is === 'a'
58
+ ? 'a'
59
+ : is === 'button' || hasPressHandler
60
+ ? 'button'
61
+ : 'div'
99
62
  );
63
+ // undefined: detected (a, button, input, onclick...), true: forced, false: no visual feedback
64
+ let isInteractive = $derived((interactive ?? (tag !== 'div' || hasPressHandler)) && !isLocked);
65
+ let resolvedHref = $derived(tag === 'a' && !isLocked ? href : undefined);
66
+ let resolvedType = $derived(tag === 'button' ? (type ?? 'button') : undefined);
67
+ let resolvedDisabled = $derived(tag === 'button' ? isLocked : undefined);
68
+ let resolvedTabIndex = $derived(tag === 'a' && isLocked ? -1 : undefined);
100
69
  </script>
101
70
 
102
- {#if isInput}
103
- <svelte:element
104
- this={inputWrapperTag}
105
- bind:this={ref}
106
- class={componentClass}
107
- style={resolvedStyle}
108
- data-size={size}
109
- data-variant={variant}
110
- data-rounded={rounded}
111
- data-loading={loading}
112
- data-active={active}
113
- data-disabled={isDisabled}
114
- data-readonly={isReadonly}
115
- data-density={density}
116
- data-label-style={labelStyle}
117
- data-interactive={isInteractive}
118
- aria-busy={loading}
119
- aria-disabled={isLocked || undefined}
120
- data-elevation={elevationState.base}
121
- data-elevation-hover={elevationState.hover}
122
- data-elevation-active={elevationState.active}
123
- use:ripple={{
124
- component: 'chip',
125
- disabled: noRipple || isLocked
126
- }}
127
- >
128
- {#if variant === 'outline'}
129
- <span class="outline"></span>
130
- {/if}
71
+ <svelte:element
72
+ this={tag}
73
+ bind:this={ref}
74
+ class={attrs.class}
75
+ style={attrs.style}
76
+ href={resolvedHref}
77
+ type={resolvedType}
78
+ disabled={resolvedDisabled}
79
+ tabindex={resolvedTabIndex}
80
+ data-variant={variant}
81
+ data-size={size}
82
+ data-density={density}
83
+ data-rounded={rounded}
84
+ data-elevation={elevationState.base}
85
+ data-elevation-hover={elevationState.hover}
86
+ data-elevation-active={elevationState.active}
87
+ data-interactive={isInteractive}
88
+ data-active={active}
89
+ data-disabled={isDisabled}
90
+ data-readonly={isReadonly}
91
+ data-loading={loading}
92
+ data-label-style={labelStyle}
93
+ aria-busy={loading || undefined}
94
+ aria-disabled={isLocked || undefined}
95
+ use:ripple={{
96
+ component: 'chip',
97
+ disabled: noRipple || !isInteractive
98
+ }}
99
+ {...isInput ? {} : attrs.rest}
100
+ >
101
+ {#if hasOutline}
102
+ <span class="outline"></span>
103
+ {/if}
104
+
105
+ {#if isInput}
131
106
  <input
132
- {...restProps}
107
+ {...attrs.rest}
108
+ class="kit-chip__input"
109
+ data-ripple-host
133
110
  type={type || 'button'}
134
111
  {checked}
135
112
  {value}
136
113
  aria-label={String(label || value)}
137
114
  disabled={isLocked}
138
115
  />
139
- {#if loading}
140
- <span class="spinner">
141
- {#if load}
142
- {@render load?.()}
143
- {:else}
144
- ...
145
- {/if}
146
- </span>
147
- {/if}
148
- </svelte:element>
149
- {:else}
150
- <svelte:element
151
- this={tag}
152
- bind:this={ref}
153
- class={componentClass}
154
- style={resolvedStyle}
155
- type={resolvedType}
156
- href={resolvedHref}
157
- data-size={size}
158
- data-variant={variant}
159
- data-rounded={rounded}
160
- data-loading={loading}
161
- data-active={active}
162
- data-disabled={isDisabled}
163
- data-readonly={isReadonly}
164
- data-density={density}
165
- data-label-style={labelStyle}
166
- data-interactive={isInteractive}
167
- disabled={resolvedDisabled}
168
- aria-busy={loading}
169
- data-elevation={elevationState.base}
170
- data-elevation-hover={elevationState.hover}
171
- data-elevation-active={elevationState.active}
172
- aria-disabled={((tag === 'a' || tag === 'div') && isLocked) || undefined}
173
- tabindex={tag === 'a' && isLocked ? -1 : undefined}
174
- use:ripple={{
175
- component: 'chip',
176
- disabled: noRipple || !isInteractive
177
- }}
178
- // style:--kit-chip-fg={color && `var(--kit-color-${color})`}
179
- // style:--kit-chip-bg={background && `var(--kit-color-${background})`}
180
- {...restProps}
181
- >
182
- {#if variant === 'outline'}
183
- <span class="outline"></span>
184
- {/if}
185
-
116
+ {:else}
186
117
  <span class="kit-chip__inner">
187
118
  {#if prepend}
188
- <span class="kit-chip__prepend">
189
- {@render prepend?.()}
190
- </span>
119
+ <span class="kit-chip__prepend">{@render prepend()}</span>
120
+ {/if}
121
+ {#if children}
122
+ <span class="kit-chip__content">{@render children()}</span>
191
123
  {/if}
192
- <span class="kit-chip__content">
193
- {@render children?.()}
194
- </span>
195
124
  {#if append}
196
- <span class="kit-chip__append">
197
- {@render append?.()}
198
- </span>
125
+ <span class="kit-chip__append">{@render append()}</span>
199
126
  {/if}
200
127
  </span>
201
-
202
- {#if loading}
203
- <span class="spinner">
204
- {#if load}
205
- {@render load?.()}
206
- {:else}
207
- ...
208
- {/if}
209
- </span>
210
- {/if}
211
- </svelte:element>
212
- {/if}
213
-
214
- <style>
215
- input {
216
- border: 0;
217
- padding: 0;
218
- background: transparent;
219
- color: inherit;
220
- cursor: pointer;
221
- }
222
-
223
- button,
224
- input,
225
- select,
226
- textarea {
227
- font: inherit;
228
- color: inherit;
229
- }
230
-
231
- button {
232
- appearance: none;
233
- background: none;
234
- border: none;
235
- }
236
-
237
- .kit-chip {
238
- position: relative;
239
- display: inline-flex;
240
- box-sizing: border-box;
241
- align-items: center;
242
- justify-content: center;
243
- font-family: var(--kit-font);
244
- background: var(--kit-chip-bg);
245
- color: var(--kit-chip-fg);
246
- height: calc(var(--kit-chip-h) + var(--kit-chip-density-offset) / 2);
247
- padding-inline: calc(var(--kit-chip-p) + var(--kit-chip-density-offset) / 2);
248
- border-radius: var(--kit-chip-radius);
249
- text-decoration: none;
250
- white-space: nowrap;
251
- user-select: none;
252
- cursor: default;
253
- font-size: var(--kit-chip-font);
254
- border: 0;
255
- transition:
256
- background 150ms ease,
257
- transform 50ms ease;
258
- }
259
-
260
- .kit-chip[data-interactive='true'] {
261
- cursor: pointer;
262
- }
263
-
264
- .kit-chip[data-interactive='true']:hover {
265
- background: var(--kit-chip-hover-bg);
266
- color: var(--kit-chip-fg);
267
- text-decoration: var(--kit-chip-decoration);
268
- }
269
-
270
- .kit-chip[data-interactive='true']:active,
271
- .kit-chip[data-active='true'] {
272
- background: var(--kit-chip-active-bg);
273
- color: var(--kit-chip-fg);
274
- text-decoration: var(--kit-chip-decoration);
275
- transform: translateY(1px);
276
- }
277
-
278
- .kit-chip[data-active='true'][data-interactive='true']:hover {
279
- background: var(--kit-chip-hover-bg);
280
- color: var(--kit-chip-fg);
281
- text-decoration: var(--kit-chip-decoration);
282
- translate: 0 -1px;
283
- }
284
-
285
- :is(.kit-chip:focus-visible, .kit-chip:has(> input:focus-visible)) {
286
- outline: 2px solid var(--kit-color-focus);
287
- outline-offset: 2px;
288
- }
289
-
290
- .kit-chip > input:focus-visible {
291
- outline: none;
292
- box-shadow: none;
293
- }
294
-
295
- .kit-chip > :is(input[type='checkbox'], input[type='radio']) {
296
- appearance: none;
297
- margin: 0;
298
- cursor: pointer;
299
- }
300
-
301
- .kit-chip > :is(input[type='checkbox'], input[type='radio']):after {
302
- content: attr(aria-label);
303
- cursor: pointer;
304
- }
305
-
306
- .kit-chip[data-label-style='true'] {
307
- font-weight: 600;
308
- letter-spacing: 0.01em;
309
- text-transform: uppercase;
310
- }
311
-
312
- .kit-chip__inner {
313
- display: inline-flex;
314
- align-items: center;
315
- justify-content: center;
316
- gap: var(--kit-chip-gap);
317
- line-height: 1;
318
- }
319
-
320
- .kit-chip__content,
321
- .kit-chip__prepend,
322
- .kit-chip__append {
323
- display: inline-flex;
324
- align-items: center;
325
- justify-content: center;
326
- line-height: 1;
327
- font-weight: normal;
328
- }
329
-
330
- .kit-chip__content :global(.kit-icon),
331
- .kit-chip__prepend :global(.kit-icon),
332
- .kit-chip__append :global(.kit-icon) {
333
- display: inline-flex;
334
- align-items: center;
335
- justify-content: center;
336
- vertical-align: middle;
337
- }
338
-
339
- .kit-chip__content :global(svg),
340
- .kit-chip__prepend :global(svg),
341
- .kit-chip__append :global(svg),
342
- .kit-chip__content :global(img),
343
- .kit-chip__prepend :global(img),
344
- .kit-chip__append :global(img) {
345
- display: block;
346
- }
347
-
348
- .kit-chip[data-loading='true'] .kit-chip__inner,
349
- .kit-chip[data-loading='true'] input {
350
- opacity: 0;
351
- }
352
-
353
- .kit-chip[data-loading='true'] {
354
- pointer-events: none;
355
- user-select: none;
356
- }
357
-
358
- .spinner {
359
- position: absolute;
360
- inset: 0;
361
- display: flex;
362
- align-items: center;
363
- justify-content: center;
364
- }
365
-
366
- .kit-chip[data-readonly='true'],
367
- .kit-chip[data-disabled='true'] {
368
- pointer-events: none;
369
- user-select: none;
370
- cursor: default;
371
- }
372
-
373
- .kit-chip[data-disabled='true'] {
374
- background: color-mix(in oklab, var(--kit-chip-bg), transparent 70%);
375
- color: color-mix(in oklab, var(--kit-chip-fg), transparent 45%);
376
- }
377
-
378
- .kit-chip[data-disabled='true'] :global(.kit-icon),
379
- .kit-chip[data-readonly='true'] :global(.kit-icon) {
380
- color: color-mix(in oklab, var(--kit-chip-fg), transparent 45%) !important;
381
- --kit-icon-color: color-mix(in oklab, var(--kit-chip-fg), transparent 45%) !important;
382
- }
383
-
384
- .kit-chip[data-disabled='true'] :global(.kit-icon img),
385
- .kit-chip[data-disabled='true'] :global(.kit-icon .kit-icon__mask) {
386
- opacity: 0.7;
387
- filter: grayscale(0.2);
388
- }
389
- .kit-chip[data-readonly='true'] > input,
390
- .kit-chip[data-disabled='true'] > input {
391
- cursor: default;
392
- }
393
-
394
- /**
395
- * size
396
- * @link nothing...
397
- */
398
- .kit-chip[data-size='xs'] {
399
- --kit-chip-h: 20px;
400
- --kit-chip-p: 8px;
401
- --kit-chip-gap: var(--kit-space-compact);
402
- --kit-chip-font: 11px;
403
- }
404
- .kit-chip[data-size='xs'] :global(.kit-icon:not([data-size])) {
405
- --kit-icon-current-size: var(--kit-icon-size-xs);
406
- }
407
- .kit-chip[data-size='sm'] {
408
- --kit-chip-h: 24px;
409
- --kit-chip-p: 10px;
410
- --kit-chip-gap: var(--kit-space-default);
411
- --kit-chip-font: 12px;
412
- }
413
- .kit-chip[data-size='sm'] :global(.kit-icon:not([data-size])) {
414
- --kit-icon-current-size: var(--kit-icon-size-sm);
415
- }
416
-
417
- .kit-chip[data-size='md'] {
418
- --kit-chip-h: 32px;
419
- --kit-chip-p: 12px;
420
- --kit-chip-gap: var(--kit-space-default);
421
- --kit-chip-font: 13px;
422
- }
423
- .kit-chip[data-size='md'] :global(.kit-icon:not([data-size])) {
424
- --kit-icon-current-size: var(--kit-icon-size-md);
425
- }
426
-
427
- .kit-chip[data-size='lg'] {
428
- --kit-chip-h: 36px;
429
- --kit-chip-p: 14px;
430
- --kit-chip-gap: var(--kit-space-default);
431
- --kit-chip-font: 14px;
432
- }
433
- .kit-chip[data-size='lg'] :global(.kit-icon:not([data-size])) {
434
- --kit-icon-current-size: var(--kit-icon-size-lg);
435
- }
436
-
437
- .kit-chip[data-size='xl'] {
438
- --kit-chip-h: 40px;
439
- --kit-chip-p: 16px;
440
- --kit-chip-gap: var(--kit-space-comfortable);
441
- --kit-chip-font: 15px;
442
- }
443
- .kit-chip[data-size='xl'] :global(.kit-icon:not([data-size])) {
444
- --kit-icon-current-size: var(--kit-icon-size-xl);
445
- }
446
-
447
- /**
448
- * density
449
- * @link no links
450
- */
451
- .kit-chip[data-density='compact'] {
452
- --kit-chip-density-offset: var(--kit-density-compact);
453
- }
454
- .kit-chip[data-density='default'] {
455
- --kit-chip-density-offset: var(--kit-density-default);
456
- }
457
- .kit-chip[data-density='comfortable'] {
458
- --kit-chip-density-offset: var(--kit-density-comfortable);
459
- }
460
-
461
- /**
462
- * rounded
463
- * @link ...
464
- */
465
- .kit-chip[data-rounded='0'] {
466
- --kit-chip-radius: var(--kit-shape-none);
467
- }
468
- .kit-chip[data-rounded='xs'] {
469
- --kit-chip-radius: var(--kit-shape-xs);
470
- }
471
- .kit-chip[data-rounded='sm'] {
472
- --kit-chip-radius: var(--kit-shape-sm);
473
- }
474
- .kit-chip[data-rounded='md'] {
475
- --kit-chip-radius: var(--kit-shape-md);
476
- }
477
- .kit-chip[data-rounded='lg'] {
478
- --kit-chip-radius: var(--kit-shape-lg);
479
- }
480
- .kit-chip[data-rounded='xl'] {
481
- --kit-chip-radius: var(--kit-shape-xl);
482
- }
483
- .kit-chip[data-rounded='full'] {
484
- --kit-chip-radius: var(--kit-shape-full);
485
- }
486
-
487
- /**
488
- * variant
489
- * @link no links...
490
- */
491
- .kit-chip[data-variant='filled'] {
492
- --kit-chip-bg: var(--kit-color-surface-2);
493
- --kit-chip-fg: var(--kit-color-text);
494
-
495
- --kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-bg), black 10%);
496
- --kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-bg), black 16%);
497
- }
498
- .kit-chip[data-variant='outline'] {
499
- --kit-chip-bg: transparent;
500
- --kit-chip-fg: var(--kit-color-text);
501
- --kit-chip-bd: var(--kit-chip-fg);
502
-
503
- --kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 80%);
504
- --kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 92%);
505
- }
506
- .kit-chip[data-variant='text'] {
507
- --kit-chip-bg: transparent;
508
- --kit-chip-fg: var(--kit-color-text);
509
-
510
- --kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 80%);
511
- --kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 92%);
512
- }
513
-
514
- .kit-chip .outline {
515
- --outline-color: var(--kit-chip-bd);
516
- }
517
- </style>
128
+ {/if}
129
+
130
+ {#if loading}
131
+ <span class="kit-chip__spinner">
132
+ {#if load}
133
+ {@render load()}
134
+ {:else}
135
+ ...
136
+ {/if}
137
+ </span>
138
+ {/if}
139
+ </svelte:element>
140
+
141
+ <style>:where(.kit-chip) {
142
+ --kit-chip-color: initial;
143
+ --kit-chip-on-color: initial;
144
+ --kit-chip-active-fg: initial;
145
+ --kit-chip-active-shade: initial;
146
+ --kit-chip-hover-fg: initial;
147
+ --kit-chip-pressed-fg: initial;
148
+ --kit-chip-bg: var(--kit-chip-color, var(--kit-color-surface-2));
149
+ --kit-chip-fg: var(--kit-chip-on-color, var(--kit-chip-contrast, var(--kit-color-text)));
150
+ --kit-chip-ink: var(--kit-chip-color, var(--kit-color-text));
151
+ --kit-chip-hover: color-mix(in oklab, var(--kit-chip-bg), var(--kit-chip-fg) 8%);
152
+ --kit-chip-pressed: color-mix(in oklab, var(--kit-chip-bg), var(--kit-chip-fg) 14%);
153
+ --kit-chip-soft: color-mix(in oklab, var(--kit-chip-bg) 16%, transparent);
154
+ --kit-chip-border: color-mix(in oklab, var(--kit-chip-bg), var(--kit-chip-fg) 20%);
155
+ --kit-chip-active: color-mix(
156
+ in oklab,
157
+ var(--kit-chip-color),
158
+ var(--kit-chip-fg) var(--kit-chip-active-shade, 14%)
159
+ );
160
+ }
161
+ @supports (color: color(from red srgb-linear r g b)) {
162
+ :where(.kit-chip) {
163
+ --kit-chip-contrast: color(from var(--kit-chip-color) srgb-linear clamp(0, (0.1791 - (0.2126 * r + 0.7152 * g + 0.0722 * b)) * 100000, 1) clamp(0, (0.1791 - (0.2126 * r + 0.7152 * g + 0.0722 * b)) * 100000, 1) clamp(0, (0.1791 - (0.2126 * r + 0.7152 * g + 0.0722 * b)) * 100000, 1)/1);
164
+ }
165
+ }
166
+ :where(.kit-chip) {
167
+ --kit-chip-height: calc(var(--kit-chip-h) + var(--kit-chip-density-offset) / 2);
168
+ }
169
+
170
+ .kit-chip {
171
+ position: relative;
172
+ display: inline-flex;
173
+ box-sizing: border-box;
174
+ align-items: center;
175
+ justify-content: center;
176
+ height: var(--kit-chip-height);
177
+ padding-inline: calc(var(--kit-chip-p) + var(--kit-chip-density-offset) / 2);
178
+ border: 0;
179
+ border-radius: var(--kit-chip-radius);
180
+ background-color: var(--kit-chip-bg);
181
+ color: var(--kit-chip-fg);
182
+ font: inherit;
183
+ font-family: var(--kit-font);
184
+ font-size: var(--kit-chip-font);
185
+ text-decoration: none;
186
+ white-space: nowrap;
187
+ user-select: none;
188
+ transition-property: background-color, color, border-color, box-shadow;
189
+ transition-duration: var(--kit-animation-component);
190
+ transition-timing-function: ease;
191
+ }
192
+ @media (prefers-reduced-motion: reduce) {
193
+ .kit-chip {
194
+ transition: none;
195
+ }
196
+ }
197
+ .kit-chip__inner {
198
+ display: inline-flex;
199
+ align-items: center;
200
+ justify-content: center;
201
+ gap: var(--kit-chip-gap);
202
+ line-height: 1;
203
+ }
204
+ .kit-chip__content, .kit-chip__prepend, .kit-chip__append {
205
+ display: inline-flex;
206
+ align-items: center;
207
+ justify-content: center;
208
+ line-height: 1;
209
+ }
210
+ .kit-chip__content :global(.kit-icon), .kit-chip__prepend :global(.kit-icon), .kit-chip__append :global(.kit-icon) {
211
+ display: inline-flex;
212
+ align-items: center;
213
+ justify-content: center;
214
+ vertical-align: middle;
215
+ }
216
+ .kit-chip__content :global(svg),
217
+ .kit-chip__content :global(img), .kit-chip__prepend :global(svg),
218
+ .kit-chip__prepend :global(img), .kit-chip__append :global(svg),
219
+ .kit-chip__append :global(img) {
220
+ display: block;
221
+ }
222
+ .kit-chip__input {
223
+ margin: 0;
224
+ padding: 0;
225
+ border: 0;
226
+ background: transparent;
227
+ color: inherit;
228
+ font: inherit;
229
+ cursor: pointer;
230
+ }
231
+ .kit-chip__input:focus-visible {
232
+ outline: none;
233
+ }
234
+ .kit-chip__input:is([type=checkbox], [type=radio]) {
235
+ appearance: none;
236
+ }
237
+ .kit-chip__input:is([type=checkbox], [type=radio])::after {
238
+ content: attr(aria-label);
239
+ }
240
+ .kit-chip__spinner {
241
+ position: absolute;
242
+ inset: 0;
243
+ display: flex;
244
+ align-items: center;
245
+ justify-content: center;
246
+ }
247
+ .kit-chip:has(> .kit-chip__input:focus-visible) {
248
+ outline: 2px solid var(--kit-color-focus);
249
+ outline-offset: 2px;
250
+ }
251
+ .kit-chip[data-label-style=true] {
252
+ font-weight: 600;
253
+ letter-spacing: 0.01em;
254
+ text-transform: uppercase;
255
+ }
256
+ .kit-chip[data-loading=true] {
257
+ pointer-events: none;
258
+ }
259
+ .kit-chip[data-loading=true] .kit-chip__inner,
260
+ .kit-chip[data-loading=true] .kit-chip__input {
261
+ opacity: 0;
262
+ }
263
+ .kit-chip[data-readonly=true] {
264
+ pointer-events: none;
265
+ }
266
+ .kit-chip[data-readonly=true] .kit-chip__input {
267
+ cursor: default;
268
+ }
269
+
270
+ /* native resets: no background here, it would beat the background of .kit-chip */
271
+ button.kit-chip {
272
+ appearance: none;
273
+ }
274
+
275
+ /**
276
+ * size
277
+ * @link https://lapikit.dev/docs/components/chip#size
278
+ */
279
+ :where(.kit-chip[data-size=xs]) {
280
+ --kit-chip-h: 1.25rem;
281
+ --kit-chip-p: 0.5rem;
282
+ --kit-chip-gap: 0.25rem;
283
+ --kit-chip-font: 0.6875rem;
284
+ }
285
+ :where(.kit-chip[data-size=xs]) :global(.kit-icon[data-size='default']) {
286
+ --kit-icon-current-size: var(--kit-icon-size-xs);
287
+ }
288
+
289
+ :where(.kit-chip[data-size=sm]) {
290
+ --kit-chip-h: 1.5rem;
291
+ --kit-chip-p: 0.625rem;
292
+ --kit-chip-gap: 0.25rem;
293
+ --kit-chip-font: 0.75rem;
294
+ }
295
+ :where(.kit-chip[data-size=sm]) :global(.kit-icon[data-size='default']) {
296
+ --kit-icon-current-size: var(--kit-icon-size-sm);
297
+ }
298
+
299
+ :where(.kit-chip[data-size=md]) {
300
+ --kit-chip-h: 2rem;
301
+ --kit-chip-p: 0.75rem;
302
+ --kit-chip-gap: 0.375rem;
303
+ --kit-chip-font: var(--kit-font-xs);
304
+ }
305
+ :where(.kit-chip[data-size=md]) :global(.kit-icon[data-size='default']) {
306
+ --kit-icon-current-size: var(--kit-icon-size-md);
307
+ }
308
+
309
+ :where(.kit-chip[data-size=lg]) {
310
+ --kit-chip-h: 2.25rem;
311
+ --kit-chip-p: 0.875rem;
312
+ --kit-chip-gap: 0.375rem;
313
+ --kit-chip-font: var(--kit-font-sm);
314
+ }
315
+ :where(.kit-chip[data-size=lg]) :global(.kit-icon[data-size='default']) {
316
+ --kit-icon-current-size: var(--kit-icon-size-lg);
317
+ }
318
+
319
+ :where(.kit-chip[data-size=xl]) {
320
+ --kit-chip-h: 2.5rem;
321
+ --kit-chip-p: 1rem;
322
+ --kit-chip-gap: 0.5rem;
323
+ --kit-chip-font: var(--kit-font-md);
324
+ }
325
+ :where(.kit-chip[data-size=xl]) :global(.kit-icon[data-size='default']) {
326
+ --kit-icon-current-size: var(--kit-icon-size-xl);
327
+ }
328
+
329
+ /**
330
+ * variant
331
+ * @link https://lapikit.dev/docs/components/chip#variants
332
+ */
333
+ :where(.kit-chip[data-variant=tonal]) {
334
+ --kit-chip-bg: color-mix(in oklab, var(--kit-chip-ink) 16%, transparent);
335
+ --kit-chip-fg: var(--kit-chip-ink);
336
+ --kit-chip-border: transparent;
337
+ --kit-chip-active: color-mix(in oklab, var(--kit-chip-ink) 28%, transparent);
338
+ --kit-chip-active-fg: var(--kit-chip-ink);
339
+ }
340
+
341
+ :where(.kit-chip[data-variant=outline]) {
342
+ --kit-chip-bg: transparent;
343
+ --kit-chip-fg: var(--kit-chip-ink);
344
+ --kit-chip-border: var(--kit-chip-color, var(--kit-color-border));
345
+ --kit-chip-active: color-mix(in oklab, var(--kit-chip-ink) 14%, transparent);
346
+ --kit-chip-active-fg: var(--kit-chip-ink);
347
+ }
348
+
349
+ :where(.kit-chip[data-variant=surface]) {
350
+ --kit-chip-bg: color-mix(in oklab, var(--kit-chip-ink) 8%, transparent);
351
+ --kit-chip-fg: var(--kit-chip-ink);
352
+ --kit-chip-border: color-mix(in oklab, var(--kit-chip-ink) 35%, transparent);
353
+ --kit-chip-active: color-mix(in oklab, var(--kit-chip-ink) 18%, transparent);
354
+ --kit-chip-active-fg: var(--kit-chip-ink);
355
+ }
356
+
357
+ :where(.kit-chip[data-variant=text]) {
358
+ --kit-chip-bg: transparent;
359
+ --kit-chip-fg: var(--kit-chip-ink);
360
+ --kit-chip-border: transparent;
361
+ --kit-chip-active: color-mix(in oklab, var(--kit-chip-ink) 14%, transparent);
362
+ --kit-chip-active-fg: var(--kit-chip-ink);
363
+ }
364
+
365
+ :where(.kit-chip[data-variant=plain]) {
366
+ --kit-chip-bg: transparent;
367
+ --kit-chip-fg: var(--kit-chip-ink);
368
+ --kit-chip-border: transparent;
369
+ --kit-chip-hover: transparent;
370
+ --kit-chip-pressed: transparent;
371
+ --kit-chip-hover-fg: color-mix(in oklab, var(--kit-chip-fg) 72%, transparent);
372
+ --kit-chip-pressed-fg: color-mix(in oklab, var(--kit-chip-fg) 56%, transparent);
373
+ --kit-chip-active: transparent;
374
+ --kit-chip-active-fg: var(--kit-chip-color, var(--kit-color-accent));
375
+ }
376
+
377
+ :where(.kit-chip .outline) {
378
+ --outline-color: var(--kit-chip-border);
379
+ }
380
+
381
+ :where(.kit-chip[data-active=true], .kit-chip:has(> .kit-chip__input:checked)) {
382
+ --kit-chip-bg: var(--kit-chip-active, var(--kit-color-accent));
383
+ --kit-chip-fg: var(
384
+ --kit-chip-active-fg,
385
+ var(--kit-chip-on-color, var(--kit-chip-contrast, var(--kit-color-on-accent)))
386
+ );
387
+ }
388
+
389
+ /**
390
+ * interactive: hover, pressed, focus-visible and disabled
391
+ */
392
+ .kit-chip[data-interactive=true]:not([data-disabled=true]) {
393
+ cursor: pointer;
394
+ }
395
+ .kit-chip[data-interactive=true]:not([data-disabled=true]):hover {
396
+ background-color: var(--kit-chip-hover);
397
+ color: var(--kit-chip-hover-fg, var(--kit-chip-fg));
398
+ }
399
+ .kit-chip[data-interactive=true]:not([data-disabled=true]):active {
400
+ background-color: var(--kit-chip-pressed);
401
+ color: var(--kit-chip-pressed-fg, var(--kit-chip-fg));
402
+ }
403
+
404
+ .kit-chip:not([data-disabled=true]):focus-visible {
405
+ outline: 2px solid var(--kit-color-focus);
406
+ outline-offset: 2px;
407
+ }
408
+
409
+ .kit-chip[data-disabled=true] {
410
+ opacity: var(--kit-disabled-opacity, 0.55);
411
+ pointer-events: none;
412
+ user-select: none;
413
+ }
414
+
415
+ /**
416
+ * rounded
417
+ * @link https://lapikit.dev/docs/customize
418
+ */
419
+ :where(.kit-chip[data-rounded="0"]) {
420
+ --kit-chip-radius: var(--kit-shape-none);
421
+ }
422
+
423
+ :where(.kit-chip[data-rounded=xs]) {
424
+ --kit-chip-radius: var(--kit-shape-xs);
425
+ }
426
+
427
+ :where(.kit-chip[data-rounded=sm]) {
428
+ --kit-chip-radius: var(--kit-shape-sm);
429
+ }
430
+
431
+ :where(.kit-chip[data-rounded=md]) {
432
+ --kit-chip-radius: var(--kit-shape-md);
433
+ }
434
+
435
+ :where(.kit-chip[data-rounded=lg]) {
436
+ --kit-chip-radius: var(--kit-shape-lg);
437
+ }
438
+
439
+ :where(.kit-chip[data-rounded=xl]) {
440
+ --kit-chip-radius: var(--kit-shape-xl);
441
+ }
442
+
443
+ :where(.kit-chip[data-rounded=full]) {
444
+ --kit-chip-radius: var(--kit-shape-full);
445
+ }
446
+
447
+ /**
448
+ * density
449
+ * @link https://lapikit.dev/docs/components/chip#density
450
+ */
451
+ :where(.kit-chip[data-density=dense]) {
452
+ --kit-chip-density-offset: var(--kit-density-dense);
453
+ }
454
+
455
+ :where(.kit-chip[data-density=compact]) {
456
+ --kit-chip-density-offset: var(--kit-density-compact);
457
+ }
458
+
459
+ :where(.kit-chip[data-density=default]) {
460
+ --kit-chip-density-offset: var(--kit-density-default);
461
+ }
462
+
463
+ :where(.kit-chip[data-density=comfortable]) {
464
+ --kit-chip-density-offset: var(--kit-density-comfortable);
465
+ }
466
+
467
+ :where(.kit-chip[data-density=spacious]) {
468
+ --kit-chip-density-offset: var(--kit-density-spacious);
469
+ }</style>