lapikit 0.7.3 → 0.7.5

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