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, useStyles } from '../../utils';
3
- import { makeComponentProps } from '../../html-mapped';
2
+ import { useComponentAttrs } from '../../utils';
4
3
  import type { AspectRatioProps, AspectRatioValue } from './aspect-ratio.types.js';
5
4
 
6
5
  const FALLBACK_RATIO = 16 / 9;
@@ -36,8 +35,8 @@
36
35
  ref = $bindable(),
37
36
  is = 'div',
38
37
  children = undefined,
39
- class: className = '',
40
- style: styleAttr = '',
38
+ class: className,
39
+ style: styleAttr,
41
40
  's-class': sClass,
42
41
  's-style': sStyle,
43
42
  ratio = undefined,
@@ -47,75 +46,56 @@
47
46
  ...rest
48
47
  }: AspectRatioProps = $props();
49
48
 
50
- let { classProps, styleProps, restProps } = $derived(
51
- makeComponentProps(rest as Record<string, unknown>)
52
- );
53
-
54
- let componentClass = $derived(
55
- useClassName({
56
- baseClass: 'kit-aspect-ratio',
57
- className: `${className ?? ''}`.trim(),
58
- sClass,
59
- classProps
60
- })
61
- );
62
-
63
- let componentStyle = $derived(
64
- useStyles({
65
- styleAttr,
66
- sStyle,
67
- styleProps
68
- })
69
- );
70
-
71
49
  let resolvedRatio = $derived(resolveRatio(ratio ?? aspectRatio));
50
+ let attrs = $derived(
51
+ useComponentAttrs(
52
+ 'kit-aspect-ratio',
53
+ {
54
+ className,
55
+ sClass,
56
+ styleAttr,
57
+ sStyle: { '--kit-aspect-ratio': String(resolvedRatio), '--kit-aspect-fit': fit, ...sStyle }
58
+ },
59
+ rest
60
+ )
61
+ );
72
62
  </script>
73
63
 
74
64
  <svelte:element
75
65
  this={is}
76
66
  bind:this={ref}
77
- class={componentClass}
78
- style={componentStyle}
67
+ class={attrs.class}
68
+ style={attrs.style}
79
69
  data-inline={inline}
80
- style:--kit-aspect-ratio={resolvedRatio}
81
- style:--kit-aspect-fit={fit}
82
- {...restProps}
70
+ {...attrs.rest}
83
71
  >
84
72
  <div class="kit-aspect-ratio__inner">
85
73
  {@render children?.()}
86
74
  </div>
87
75
  </svelte:element>
88
76
 
89
- <style>
90
- .kit-aspect-ratio {
91
- display: block;
92
- position: relative;
93
- width: 100%;
94
- max-width: 100%;
95
- overflow: hidden;
96
- aspect-ratio: var(--kit-aspect-ratio, 1.7777777778);
97
- }
98
-
99
- .kit-aspect-ratio[data-inline='true'] {
100
- display: inline-block;
101
- width: auto;
102
- }
103
-
104
- .kit-aspect-ratio__inner {
105
- position: absolute;
106
- inset: 0;
107
- width: 100%;
108
- height: 100%;
109
- }
110
-
111
- .kit-aspect-ratio :global(img),
112
- .kit-aspect-ratio :global(video),
113
- .kit-aspect-ratio :global(iframe),
114
- .kit-aspect-ratio :global(canvas),
115
- .kit-aspect-ratio :global(svg) {
116
- display: block;
117
- width: 100%;
118
- height: 100%;
119
- object-fit: var(--kit-aspect-fit, cover);
120
- }
121
- </style>
77
+ <style>.kit-aspect-ratio {
78
+ position: relative;
79
+ display: block;
80
+ width: 100%;
81
+ max-width: 100%;
82
+ overflow: hidden;
83
+ aspect-ratio: var(--kit-aspect-ratio, 1.7777777778);
84
+ }
85
+ .kit-aspect-ratio[data-inline=true] {
86
+ display: inline-block;
87
+ width: auto;
88
+ }
89
+ .kit-aspect-ratio__inner {
90
+ position: absolute;
91
+ inset: 0;
92
+ width: 100%;
93
+ height: 100%;
94
+ }
95
+ .kit-aspect-ratio__inner > :global(:is(img, video, iframe, canvas, svg, picture)),
96
+ .kit-aspect-ratio__inner > :global(picture > img) {
97
+ display: block;
98
+ width: 100%;
99
+ height: 100%;
100
+ object-fit: var(--kit-aspect-fit, cover);
101
+ }</style>
@@ -1,13 +1,12 @@
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 type { AvatarProps } from './avatar.types.js';
5
4
 
6
5
  let {
7
6
  ref = $bindable(),
8
7
  children = undefined,
9
- class: className = '',
10
- style: styleAttr = '',
8
+ class: className,
9
+ style: styleAttr,
11
10
  's-class': sClass,
12
11
  's-style': sStyle,
13
12
  label = undefined,
@@ -16,180 +15,189 @@
16
15
  rounded = 'full',
17
16
  elevation,
18
17
  color,
19
- background,
20
18
  ...rest
21
19
  }: AvatarProps = $props();
22
20
 
23
- let { classProps, styleProps, restProps } = $derived(
24
- makeComponentProps(rest as Record<string, unknown>)
21
+ let attrs = $derived(
22
+ useComponentAttrs('kit-avatar', { className, sClass, styleAttr, sStyle, color }, rest)
25
23
  );
26
-
27
- let componentClass = $derived(
28
- useClassName({
29
- baseClass: 'kit-avatar',
30
- className: `${className ?? ''}`.trim(),
31
- sClass,
32
- classProps
33
- })
34
- );
35
-
36
- let componentStyle = $derived(
37
- useStyles({
38
- styleAttr,
39
- sStyle,
40
- styleProps
41
- })
42
- );
43
-
44
24
  let elevationState = $derived(useElevation(elevation));
45
- let contentType = $derived(label && label.trim().length > 0 ? 'label' : children);
46
25
  let displayLabel = $derived(label?.trim() ?? '');
47
-
48
- let resolvedStyle = $derived(
49
- [
50
- componentStyle,
51
- color ? `--kit-avatar-fg:${color && `var(--kit-color-${color})`}` : '',
52
- background ? `--kit-avatar-bg:${background && `var(--kit-color-${background})`}` : ''
53
- ]
54
- .filter(Boolean)
55
- .join('; ')
56
- );
57
26
  </script>
58
27
 
59
- <svelte:element
60
- this={'div'}
28
+ <div
61
29
  bind:this={ref}
62
- class={componentClass}
63
- style={resolvedStyle}
64
- data-type={contentType}
30
+ class={attrs.class}
31
+ style={attrs.style}
32
+ data-type={displayLabel ? 'label' : 'content'}
65
33
  data-size={size}
66
34
  data-density={density}
67
35
  data-rounded={rounded}
68
36
  data-elevation={elevationState.base}
69
37
  data-elevation-hover={elevationState.hover}
70
38
  data-elevation-active={elevationState.active}
71
- {...restProps}
39
+ {...attrs.rest}
72
40
  >
73
- {#if contentType === 'label'}
41
+ {#if displayLabel}
74
42
  <span class="kit-avatar__label">{displayLabel}</span>
75
43
  {:else}
76
44
  {@render children?.()}
77
45
  {/if}
78
- </svelte:element>
79
-
80
- <style>
81
- .kit-avatar {
82
- --kit-avatar-bg: var(--kit-color-surface-3);
83
- --kit-avatar-fg: var(--kit-color-text);
84
-
85
- display: inline-flex;
86
- align-items: center;
87
- justify-content: center;
88
- width: calc(var(--kit-avatar-h) + var(--kit-avatar-density-offset) / 2);
89
- height: calc(var(--kit-avatar-h) + var(--kit-avatar-density-offset) / 2);
90
- overflow: hidden;
91
- background: var(--kit-avatar-bg);
92
- color: var(--kit-avatar-fg);
93
- border-radius: var(--kit-avatar-radius);
94
- border: 0;
95
- font-weight: 600;
96
- line-height: 1;
97
- user-select: none;
98
- transition:
99
- background 140ms ease,
100
- color 140ms ease,
101
- box-shadow 140ms ease,
102
- translate 140ms ease;
103
- }
104
-
105
- .kit-avatar[data-type='label'] {
106
- font-size: var(--kit-avatar-font-size);
107
- text-transform: uppercase;
108
- }
109
-
110
- .kit-avatar__label {
111
- display: inline-flex;
112
- align-items: center;
113
- justify-content: center;
114
- max-width: 100%;
115
- padding-inline: 0.25rem;
116
- }
117
-
118
- .kit-avatar :global(img) {
119
- display: block;
120
- width: 100%;
121
- height: 100%;
122
- object-fit: cover;
123
- }
124
-
125
- /**
126
- * rounded
127
- * @link ...
128
- */
129
- .kit-avatar[data-rounded='0'] {
130
- --kit-avatar-radius: var(--kit-shape-none);
131
- }
132
- .kit-avatar[data-rounded='xs'] {
133
- --kit-avatar-radius: var(--kit-shape-xs);
134
- }
135
- .kit-avatar[data-rounded='sm'] {
136
- --kit-avatar-radius: var(--kit-shape-sm);
137
- }
138
- .kit-avatar[data-rounded='md'] {
139
- --kit-avatar-radius: var(--kit-shape-md);
140
- }
141
- .kit-avatar[data-rounded='lg'] {
142
- --kit-avatar-radius: var(--kit-shape-lg);
143
- }
144
- .kit-avatar[data-rounded='xl'] {
145
- --kit-avatar-radius: var(--kit-shape-xl);
146
- }
147
-
148
- .kit-avatar[data-rounded='full'] {
149
- --kit-avatar-radius: var(--kit-shape-full);
150
- }
151
-
152
- /**
153
- * density
154
- * @link ...
155
- */
156
- .kit-avatar[data-density='compact'] {
157
- --kit-avatar-density-offset: var(--kit-density-compact);
158
- }
159
- .kit-avatar[data-density='default'] {
160
- --kit-avatar-density-offset: var(--kit-density-default);
161
- }
162
- .kit-avatar[data-density='comfortable'] {
163
- --kit-avatar-density-offset: var(--kit-density-comfortable);
164
- }
165
-
166
- /**
167
- * size
168
- * @link nothing...
169
- */
170
- .kit-avatar[data-size='xs'] {
171
- --kit-avatar-h: 32px;
172
- --kit-avatar-gap: var(--kit-space-compact);
173
- --kit-avatar-font: var(--kit-font-xs);
174
- }
175
- .kit-avatar[data-size='sm'] {
176
- --kit-avatar-h: 40px;
177
- --kit-avatar-gap: var(--kit-space-default);
178
- --kit-avatar-font: var(--kit-font-sm);
179
- }
180
- .kit-avatar[data-size='md'] {
181
- --kit-avatar-h: 48px;
182
- --kit-avatar-gap: var(--kit-space-default);
183
- --kit-avatar-font: var(--kit-font-md);
184
- }
185
- .kit-avatar[data-size='lg'] {
186
- --kit-avatar-h: 56px;
187
- --kit-avatar-gap: var(--kit-space-default);
188
- --kit-avatar-font: var(--kit-font-lg);
189
- }
190
- .kit-avatar[data-size='xl'] {
191
- --kit-avatar-h: 64px;
192
- --kit-avatar-gap: var(--kit-space-comfortable);
193
- --kit-avatar-font: var(--kit-font-xl);
194
- }
195
- </style>
46
+ </div>
47
+
48
+ <style>:where(.kit-avatar) {
49
+ --kit-avatar-color: initial;
50
+ --kit-avatar-on-color: initial;
51
+ --kit-avatar-active-fg: initial;
52
+ --kit-avatar-active-shade: initial;
53
+ --kit-avatar-hover-fg: initial;
54
+ --kit-avatar-pressed-fg: initial;
55
+ --kit-avatar-bg: var(--kit-avatar-color, var(--kit-color-surface-3));
56
+ --kit-avatar-fg: var(--kit-avatar-on-color, var(--kit-avatar-contrast, var(--kit-color-text)));
57
+ --kit-avatar-ink: var(--kit-avatar-color, var(--kit-color-text));
58
+ --kit-avatar-hover: color-mix(in oklab, var(--kit-avatar-bg), var(--kit-avatar-fg) 8%);
59
+ --kit-avatar-pressed: color-mix(in oklab, var(--kit-avatar-bg), var(--kit-avatar-fg) 14%);
60
+ --kit-avatar-soft: color-mix(in oklab, var(--kit-avatar-bg) 16%, transparent);
61
+ --kit-avatar-border: color-mix(in oklab, var(--kit-avatar-bg), var(--kit-avatar-fg) 20%);
62
+ --kit-avatar-active: color-mix(
63
+ in oklab,
64
+ var(--kit-avatar-color),
65
+ var(--kit-avatar-fg) var(--kit-avatar-active-shade, 14%)
66
+ );
67
+ }
68
+ @supports (color: color(from red srgb-linear r g b)) {
69
+ :where(.kit-avatar) {
70
+ --kit-avatar-contrast: color(from var(--kit-avatar-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);
71
+ }
72
+ }
73
+ :where(.kit-avatar) {
74
+ --kit-avatar-size: calc(var(--kit-avatar-h) + var(--kit-avatar-density-offset) / 2);
75
+ }
76
+
77
+ .kit-avatar {
78
+ display: inline-flex;
79
+ flex: none;
80
+ align-items: center;
81
+ justify-content: center;
82
+ box-sizing: border-box;
83
+ width: var(--kit-avatar-size);
84
+ height: var(--kit-avatar-size);
85
+ overflow: hidden;
86
+ border: 0;
87
+ border-radius: var(--kit-avatar-radius);
88
+ background-color: var(--kit-avatar-bg);
89
+ color: var(--kit-avatar-fg);
90
+ font-weight: 600;
91
+ line-height: 1;
92
+ user-select: none;
93
+ transition-property: background-color, color, box-shadow;
94
+ transition-duration: var(--kit-animation-component);
95
+ transition-timing-function: ease;
96
+ }
97
+ @media (prefers-reduced-motion: reduce) {
98
+ .kit-avatar {
99
+ transition: none;
100
+ }
101
+ }
102
+ .kit-avatar[data-type=label] {
103
+ font-size: var(--kit-avatar-font);
104
+ text-transform: uppercase;
105
+ }
106
+ .kit-avatar__label {
107
+ display: inline-flex;
108
+ align-items: center;
109
+ justify-content: center;
110
+ max-width: 100%;
111
+ padding-inline: 0.25rem;
112
+ }
113
+ .kit-avatar > :global(img) {
114
+ display: block;
115
+ width: 100%;
116
+ height: 100%;
117
+ object-fit: cover;
118
+ }
119
+
120
+ /**
121
+ * size
122
+ * @link https://lapikit.dev/docs/components/avatar#size
123
+ */
124
+ :where(.kit-avatar[data-size=xs]) {
125
+ --kit-avatar-h: 2rem;
126
+ --kit-avatar-font: var(--kit-font-xs);
127
+ }
128
+
129
+ :where(.kit-avatar[data-size=sm]) {
130
+ --kit-avatar-h: 2.5rem;
131
+ --kit-avatar-font: var(--kit-font-sm);
132
+ }
133
+
134
+ :where(.kit-avatar[data-size=md]) {
135
+ --kit-avatar-h: 3rem;
136
+ --kit-avatar-font: var(--kit-font-md);
137
+ }
138
+
139
+ :where(.kit-avatar[data-size=lg]) {
140
+ --kit-avatar-h: 3.5rem;
141
+ --kit-avatar-font: var(--kit-font-lg);
142
+ }
143
+
144
+ :where(.kit-avatar[data-size=xl]) {
145
+ --kit-avatar-h: 4rem;
146
+ --kit-avatar-font: var(--kit-font-xl);
147
+ }
148
+
149
+ /**
150
+ * rounded
151
+ * @link https://lapikit.dev/docs/customize
152
+ */
153
+ :where(.kit-avatar[data-rounded="0"]) {
154
+ --kit-avatar-radius: var(--kit-shape-none);
155
+ }
156
+
157
+ :where(.kit-avatar[data-rounded=xs]) {
158
+ --kit-avatar-radius: var(--kit-shape-xs);
159
+ }
160
+
161
+ :where(.kit-avatar[data-rounded=sm]) {
162
+ --kit-avatar-radius: var(--kit-shape-sm);
163
+ }
164
+
165
+ :where(.kit-avatar[data-rounded=md]) {
166
+ --kit-avatar-radius: var(--kit-shape-md);
167
+ }
168
+
169
+ :where(.kit-avatar[data-rounded=lg]) {
170
+ --kit-avatar-radius: var(--kit-shape-lg);
171
+ }
172
+
173
+ :where(.kit-avatar[data-rounded=xl]) {
174
+ --kit-avatar-radius: var(--kit-shape-xl);
175
+ }
176
+
177
+ :where(.kit-avatar[data-rounded=full]) {
178
+ --kit-avatar-radius: var(--kit-shape-full);
179
+ }
180
+
181
+ /**
182
+ * density
183
+ * @link https://lapikit.dev/docs/components/avatar#density
184
+ */
185
+ :where(.kit-avatar[data-density=dense]) {
186
+ --kit-avatar-density-offset: var(--kit-density-dense);
187
+ }
188
+
189
+ :where(.kit-avatar[data-density=compact]) {
190
+ --kit-avatar-density-offset: var(--kit-density-compact);
191
+ }
192
+
193
+ :where(.kit-avatar[data-density=default]) {
194
+ --kit-avatar-density-offset: var(--kit-density-default);
195
+ }
196
+
197
+ :where(.kit-avatar[data-density=comfortable]) {
198
+ --kit-avatar-density-offset: var(--kit-density-comfortable);
199
+ }
200
+
201
+ :where(.kit-avatar[data-density=spacious]) {
202
+ --kit-avatar-density-offset: var(--kit-density-spacious);
203
+ }</style>
@@ -1,11 +1,10 @@
1
- import type { Component, DensityType, ElevationProps, RoundedType, SizeType } from '../../@types';
1
+ import type { ColorProps, Component, ElevationProps, RoundedType, SizeType } from '../../@types';
2
2
  export interface AvatarProps extends Component {
3
3
  ref?: HTMLElement | null;
4
4
  label?: string;
5
5
  size?: SizeType;
6
- density?: DensityType;
6
+ density?: 'dense' | 'compact' | 'default' | 'comfortable' | 'spacious';
7
7
  rounded?: RoundedType | 'full';
8
8
  elevation?: ElevationProps;
9
- color?: string;
10
- background?: string;
9
+ color?: ColorProps;
11
10
  }