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,13 +1,14 @@
1
- import type { Component, DensityType, ElevationProps, RoundedType, SizeType } from '../../@types';
1
+ import type { ColorProps, Component, ElevationProps, RoundedType, SizeType } from '../../@types';
2
2
  import type { Snippet } from 'svelte';
3
3
  export interface ChipProps extends Component {
4
4
  ref?: HTMLElement | null;
5
5
  is?: 'div' | 'a' | 'input' | 'button';
6
6
  input?: boolean;
7
7
  href?: string;
8
- variant?: 'outline' | 'text' | 'filled';
9
- density?: DensityType;
8
+ variant?: 'filled' | 'tonal' | 'outline' | 'text' | 'plain' | 'surface';
9
+ density?: 'dense' | 'compact' | 'default' | 'comfortable' | 'spacious';
10
10
  rounded?: RoundedType | 'full';
11
+ interactive?: boolean;
11
12
  active?: boolean;
12
13
  loading?: boolean;
13
14
  disabled?: boolean;
@@ -23,6 +24,5 @@ export interface ChipProps extends Component {
23
24
  append?: Snippet;
24
25
  prepend?: Snippet;
25
26
  elevation?: ElevationProps;
26
- background?: string;
27
- color?: string;
27
+ color?: ColorProps;
28
28
  }
@@ -1,13 +1,12 @@
1
1
  <script lang="ts">
2
- import { makeComponentProps } from '../../html-mapped';
3
- import { useClassName, useStyles, disabledScroll, useElevation } from '../../utils';
2
+ import { disabledScroll, splitAriaAttrs, useComponentAttrs, useElevation } from '../../utils';
4
3
  import type { DialogProps } from './dialog.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
  open = $bindable(false),
@@ -16,42 +15,28 @@
16
15
  position = 'center',
17
16
  density = 'default',
18
17
  rounded = 'md',
19
- classContent = '',
18
+ classContent,
20
19
  color,
21
- background,
22
20
  elevation = '2',
23
21
  space,
24
22
  ...rest
25
23
  }: DialogProps = $props();
26
24
 
27
- let { classProps, styleProps, restProps } = $derived(
28
- makeComponentProps(rest as Record<string, unknown>)
25
+ let attrs = $derived(
26
+ useComponentAttrs(
27
+ 'kit-dialog',
28
+ {
29
+ className,
30
+ sClass,
31
+ styleAttr,
32
+ sStyle: space ? { '--kit-dialog-space': space, ...sStyle } : sStyle,
33
+ color
34
+ },
35
+ rest
36
+ )
29
37
  );
30
-
31
38
  let elevationState = $derived(useElevation(elevation));
32
-
33
- let componentClass = $derived(
34
- useClassName({
35
- baseClass: 'kit-dialog',
36
- className: `${className ?? ''}`.trim(),
37
- sClass,
38
- classProps
39
- })
40
- );
41
-
42
- let componentStyle = $derived(
43
- useStyles({
44
- styleAttr,
45
- sStyle,
46
- styleProps
47
- })
48
- );
49
-
50
- let contentClass = $derived(
51
- Array.isArray(classContent)
52
- ? classContent.filter(Boolean).join(' ')
53
- : `${classContent ?? ''}`.trim()
54
- );
39
+ let split = $derived(splitAriaAttrs(attrs.rest));
55
40
 
56
41
  $effect(() => {
57
42
  if (!ref) return;
@@ -95,35 +80,25 @@
95
80
  if (event.target !== ref || persistent) return;
96
81
  open = false;
97
82
  }
98
-
99
- let resolvedStyle = $derived(
100
- [
101
- componentStyle,
102
- color ? `--kit-dialog-fg:${color && `var(--kit-color-${color})`}` : '',
103
- background ? `--kit-dialog-bg:${background && `var(--kit-color-${background})`}` : '',
104
- space ? `--kit-dialog-space:${space}` : ''
105
- ]
106
- .filter(Boolean)
107
- .join('; ')
108
- );
109
83
  </script>
110
84
 
111
85
  <dialog
112
86
  bind:this={ref}
113
- class={componentClass}
114
- style={resolvedStyle}
87
+ class={attrs.class}
88
+ style={attrs.style}
115
89
  data-size={size}
116
90
  data-position={position}
117
91
  data-persistent={persistent}
92
+ data-density={density}
93
+ data-rounded={rounded}
94
+ {...split.aria}
118
95
  onclose={handleClose}
119
96
  oncancel={handleCancel}
120
97
  onclick={handleBackdropClick}
121
98
  >
122
99
  <div
123
- {...restProps}
124
- class={['kit-dialog__content', contentClass]}
125
- data-density={density}
126
- data-rounded={rounded}
100
+ {...split.others}
101
+ class={['kit-dialog__content', classContent]}
127
102
  data-elevation={elevationState.base}
128
103
  data-elevation-hover={elevationState.hover}
129
104
  data-elevation-active={elevationState.active}
@@ -133,135 +108,163 @@
133
108
  </div>
134
109
  </dialog>
135
110
 
136
- <style>
137
- .kit-dialog {
138
- border: 0;
139
- padding: 0;
140
- margin: auto;
141
- width: 100%;
142
- max-width: none;
143
- background: transparent;
144
- color: inherit;
145
- overflow: visible;
146
- }
111
+ <style>:where(.kit-dialog) {
112
+ --kit-dialog-color: initial;
113
+ --kit-dialog-on-color: initial;
114
+ --kit-dialog-active-fg: initial;
115
+ --kit-dialog-active-shade: initial;
116
+ --kit-dialog-hover-fg: initial;
117
+ --kit-dialog-pressed-fg: initial;
118
+ --kit-dialog-bg: var(--kit-dialog-color, var(--kit-color-surface-1));
119
+ --kit-dialog-fg: var(--kit-dialog-on-color, var(--kit-dialog-contrast, var(--kit-color-text)));
120
+ --kit-dialog-ink: var(--kit-dialog-color, var(--kit-color-text));
121
+ --kit-dialog-hover: color-mix(in oklab, var(--kit-dialog-bg), var(--kit-dialog-fg) 8%);
122
+ --kit-dialog-pressed: color-mix(in oklab, var(--kit-dialog-bg), var(--kit-dialog-fg) 14%);
123
+ --kit-dialog-soft: color-mix(in oklab, var(--kit-dialog-bg) 16%, transparent);
124
+ --kit-dialog-border: color-mix(in oklab, var(--kit-dialog-bg), var(--kit-dialog-fg) 20%);
125
+ --kit-dialog-active: color-mix(
126
+ in oklab,
127
+ var(--kit-dialog-color),
128
+ var(--kit-dialog-fg) var(--kit-dialog-active-shade, 14%)
129
+ );
130
+ }
131
+ @supports (color: color(from red srgb-linear r g b)) {
132
+ :where(.kit-dialog) {
133
+ --kit-dialog-contrast: color(from var(--kit-dialog-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);
134
+ }
135
+ }
136
+ :where(.kit-dialog) {
137
+ --kit-dialog-space: 1rem;
138
+ }
147
139
 
148
- .kit-dialog::backdrop {
149
- background: color-mix(in oklab, var(--kit-color-shadow), transparent 70%);
150
- backdrop-filter: blur(2px);
151
- }
140
+ .kit-dialog {
141
+ width: 100%;
142
+ max-width: none;
143
+ margin: auto;
144
+ padding: 0;
145
+ overflow: visible;
146
+ border: 0;
147
+ background: transparent;
148
+ color: inherit;
149
+ }
150
+ .kit-dialog::backdrop {
151
+ background: color-mix(in oklab, var(--kit-color-shadow), transparent 70%);
152
+ backdrop-filter: blur(2px);
153
+ }
154
+ .kit-dialog__content {
155
+ box-sizing: border-box;
156
+ width: min(100%, min(var(--kit-dialog-max), 100vw - 2rem));
157
+ max-height: calc(100dvh - 2rem);
158
+ margin: 0 auto;
159
+ padding: calc(var(--kit-dialog-p) + var(--kit-dialog-density-offset) / 2);
160
+ overflow: auto;
161
+ border: 0;
162
+ border-radius: var(--kit-dialog-radius);
163
+ background-color: var(--kit-dialog-bg);
164
+ color: var(--kit-dialog-fg);
165
+ }
166
+ .kit-dialog {
167
+ /**
168
+ * position
169
+ * @link https://lapikit.dev/docs/components/dialog#position
170
+ */
171
+ }
172
+ .kit-dialog:is([data-position=top], [data-position=top-left], [data-position=top-right]) {
173
+ margin-top: var(--kit-dialog-space);
174
+ margin-bottom: auto;
175
+ }
176
+ .kit-dialog:is([data-position=bottom], [data-position=bottom-left], [data-position=bottom-right]) {
177
+ margin-top: auto;
178
+ margin-bottom: var(--kit-dialog-space);
179
+ }
180
+ .kit-dialog:is([data-position=top-left], [data-position=center-left], [data-position=bottom-left]) .kit-dialog__content {
181
+ margin-left: var(--kit-dialog-space);
182
+ }
183
+ .kit-dialog:is([data-position=top-right], [data-position=center-right], [data-position=bottom-right]) .kit-dialog__content {
184
+ margin-right: var(--kit-dialog-space);
185
+ }
152
186
 
153
- /**
154
- * position
155
- * @link nothing...
156
- */
157
- .kit-dialog[data-position='top'],
158
- .kit-dialog[data-position='top-left'],
159
- .kit-dialog[data-position='top-right'] {
160
- margin-top: var(--kit-dialog-space, 1rem);
161
- margin-bottom: auto;
162
- }
163
- .kit-dialog[data-position='center'],
164
- .kit-dialog[data-position='center-left'],
165
- .kit-dialog[data-position='center-right'] {
166
- margin-top: auto;
167
- margin-bottom: auto;
168
- }
169
- .kit-dialog[data-position='bottom'],
170
- .kit-dialog[data-position='bottom-left'],
171
- .kit-dialog[data-position='bottom-right'] {
172
- margin-top: auto;
173
- margin-bottom: var(--kit-dialog-space, 1rem);
174
- }
175
- .kit-dialog[data-position='top-left'] .kit-dialog__content,
176
- .kit-dialog[data-position='center-left'] .kit-dialog__content,
177
- .kit-dialog[data-position='bottom-left'] .kit-dialog__content {
178
- margin-left: var(--kit-dialog-space, 1rem);
179
- }
180
- .kit-dialog[data-position='top-right'] .kit-dialog__content,
181
- .kit-dialog[data-position='center-right'] .kit-dialog__content,
182
- .kit-dialog[data-position='bottom-right'] .kit-dialog__content {
183
- margin-right: var(--kit-dialog-space, 1rem);
184
- }
187
+ /**
188
+ * size
189
+ * @link https://lapikit.dev/docs/components/dialog#size
190
+ */
191
+ :where(.kit-dialog[data-size=xs]) {
192
+ --kit-dialog-max: 20rem;
193
+ --kit-dialog-p: 0.75rem;
194
+ }
185
195
 
186
- /**
187
- * size
188
- * @link nothing...
189
- */
190
- .kit-dialog[data-size='xs'] {
191
- --kit-dialog-max: 20rem;
192
- --kit-dialog-p: 12px;
193
- }
196
+ :where(.kit-dialog[data-size=sm]) {
197
+ --kit-dialog-max: 24rem;
198
+ --kit-dialog-p: 0.875rem;
199
+ }
194
200
 
195
- .kit-dialog[data-size='sm'] {
196
- --kit-dialog-max: 24rem;
197
- --kit-dialog-p: 14px;
198
- }
201
+ :where(.kit-dialog[data-size=md]) {
202
+ --kit-dialog-max: 32rem;
203
+ --kit-dialog-p: 1rem;
204
+ }
199
205
 
200
- .kit-dialog[data-size='md'] {
201
- --kit-dialog-max: 32rem;
202
- --kit-dialog-p: 16px;
203
- }
206
+ :where(.kit-dialog[data-size=lg]) {
207
+ --kit-dialog-max: 42rem;
208
+ --kit-dialog-p: 1.25rem;
209
+ }
204
210
 
205
- .kit-dialog[data-size='lg'] {
206
- --kit-dialog-max: 42rem;
207
- --kit-dialog-p: 20px;
208
- }
211
+ :where(.kit-dialog[data-size=xl]) {
212
+ --kit-dialog-max: 56rem;
213
+ --kit-dialog-p: 1.5rem;
214
+ }
209
215
 
210
- .kit-dialog[data-size='xl'] {
211
- --kit-dialog-max: 56rem;
212
- --kit-dialog-p: 24px;
213
- }
216
+ /**
217
+ * rounded
218
+ * @link https://lapikit.dev/docs/customize
219
+ */
220
+ :where(.kit-dialog[data-rounded="0"]) {
221
+ --kit-dialog-radius: var(--kit-shape-none);
222
+ }
214
223
 
215
- .kit-dialog__content {
216
- --kit-dialog-fg: var(--kit-color-text);
217
- --kit-dialog-bg: var(--kit-color-surface-1);
218
-
219
- box-sizing: border-box;
220
- width: min(100%, min(var(--kit-dialog-max), calc(100vw - 2rem)));
221
- max-height: calc(100dvh - 2rem);
222
- overflow: auto;
223
- padding: calc(var(--kit-dialog-p) + var(--kit-dialog-density-offset) / 2);
224
- border: 0;
225
- border-radius: var(--kit-dialog-radius);
226
- background: var(--kit-dialog-bg);
227
- color: var(--kit-dialog-fg);
228
- margin: 0 auto;
229
- }
224
+ :where(.kit-dialog[data-rounded=xs]) {
225
+ --kit-dialog-radius: var(--kit-shape-xs);
226
+ }
230
227
 
231
- /**
232
- * density
233
- * @link no links
234
- */
235
- .kit-dialog__content[data-density='compact'] {
236
- --kit-dialog-density-offset: var(--kit-density-compact);
237
- }
238
- .kit-dialog__content[data-density='default'] {
239
- --kit-dialog-density-offset: var(--kit-density-default);
240
- }
241
- .kit-dialog__content[data-density='comfortable'] {
242
- --kit-dialog-density-offset: var(--kit-density-comfortable);
243
- }
228
+ :where(.kit-dialog[data-rounded=sm]) {
229
+ --kit-dialog-radius: var(--kit-shape-sm);
230
+ }
244
231
 
245
- /**
246
- * rounded
247
- * @link ...
248
- */
249
- .kit-dialog__content[data-rounded='0'] {
250
- --kit-dialog-radius: var(--kit-shape-none);
251
- }
252
- .kit-dialog__content[data-rounded='xs'] {
253
- --kit-dialog-radius: var(--kit-shape-xs);
254
- }
255
- .kit-dialog__content[data-rounded='sm'] {
256
- --kit-dialog-radius: var(--kit-shape-sm);
257
- }
258
- .kit-dialog__content[data-rounded='md'] {
259
- --kit-dialog-radius: var(--kit-shape-md);
260
- }
261
- .kit-dialog__content[data-rounded='lg'] {
262
- --kit-dialog-radius: var(--kit-shape-lg);
263
- }
264
- .kit-dialog__content[data-rounded='xl'] {
265
- --kit-dialog-radius: var(--kit-shape-xl);
266
- }
267
- </style>
232
+ :where(.kit-dialog[data-rounded=md]) {
233
+ --kit-dialog-radius: var(--kit-shape-md);
234
+ }
235
+
236
+ :where(.kit-dialog[data-rounded=lg]) {
237
+ --kit-dialog-radius: var(--kit-shape-lg);
238
+ }
239
+
240
+ :where(.kit-dialog[data-rounded=xl]) {
241
+ --kit-dialog-radius: var(--kit-shape-xl);
242
+ }
243
+
244
+ :where(.kit-dialog[data-rounded=full]) {
245
+ --kit-dialog-radius: var(--kit-shape-full);
246
+ }
247
+
248
+ /**
249
+ * density
250
+ * @link https://lapikit.dev/docs/components/dialog#density
251
+ */
252
+ :where(.kit-dialog[data-density=dense]) {
253
+ --kit-dialog-density-offset: var(--kit-density-dense);
254
+ }
255
+
256
+ :where(.kit-dialog[data-density=compact]) {
257
+ --kit-dialog-density-offset: var(--kit-density-compact);
258
+ }
259
+
260
+ :where(.kit-dialog[data-density=default]) {
261
+ --kit-dialog-density-offset: var(--kit-density-default);
262
+ }
263
+
264
+ :where(.kit-dialog[data-density=comfortable]) {
265
+ --kit-dialog-density-offset: var(--kit-density-comfortable);
266
+ }
267
+
268
+ :where(.kit-dialog[data-density=spacious]) {
269
+ --kit-dialog-density-offset: var(--kit-density-spacious);
270
+ }</style>
@@ -1,4 +1,5 @@
1
- import type { Component, DensityType, ElevationProps, RoundedType } from '../../@types';
1
+ import type { ClassValue } from 'svelte/elements';
2
+ import type { ColorProps, Component, ElevationProps, RoundedType } from '../../@types';
2
3
  type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
3
4
  type DialogPosition = 'top' | 'center' | 'bottom' | 'top-left' | 'top-right' | 'center-left' | 'center-right' | 'bottom-left' | 'bottom-right';
4
5
  export interface DialogProps extends Component {
@@ -7,11 +8,10 @@ export interface DialogProps extends Component {
7
8
  persistent?: boolean;
8
9
  size?: DialogSize;
9
10
  position?: DialogPosition;
10
- density?: DensityType;
11
- rounded?: RoundedType;
12
- classContent?: string | string[] | undefined;
13
- color?: string;
14
- background?: string;
11
+ density?: 'dense' | 'compact' | 'default' | 'comfortable' | 'spacious';
12
+ rounded?: RoundedType | 'full';
13
+ classContent?: ClassValue;
14
+ color?: ColorProps;
15
15
  elevation?: ElevationProps;
16
16
  space?: string;
17
17
  }