lapikit 0.4.11 → 0.4.13
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/dist/labs/compiler/components.js +14 -0
- package/dist/labs/components/appbar/appbar.svelte +196 -0
- package/dist/labs/components/appbar/appbar.svelte.d.ts +4 -0
- package/dist/labs/components/appbar/appbar.types.d.ts +16 -0
- package/dist/labs/components/appbar/appbar.types.js +1 -0
- package/dist/labs/components/dropdown/dropdown.svelte +249 -0
- package/dist/labs/components/dropdown/dropdown.svelte.d.ts +4 -0
- package/dist/labs/components/dropdown/dropdown.svelte.js +148 -0
- package/dist/labs/components/dropdown/dropdown.types.d.ts +28 -0
- package/dist/labs/components/dropdown/dropdown.types.js +1 -0
- package/dist/labs/components/index.d.ts +8 -0
- package/dist/labs/components/index.js +8 -0
- package/dist/labs/components/list/list.svelte +190 -0
- package/dist/labs/components/list/list.svelte.d.ts +4 -0
- package/dist/labs/components/list/list.types.d.ts +30 -0
- package/dist/labs/components/list/list.types.js +1 -0
- package/dist/labs/components/list/modules/list-item.svelte +195 -0
- package/dist/labs/components/list/modules/list-item.svelte.d.ts +4 -0
- package/dist/labs/components/popover/popover.svelte +188 -0
- package/dist/labs/components/popover/popover.svelte.d.ts +4 -0
- package/dist/labs/components/popover/popover.svelte.js +134 -0
- package/dist/labs/components/popover/popover.types.d.ts +22 -0
- package/dist/labs/components/popover/popover.types.js +1 -0
- package/dist/labs/components/textfield/textfield.svelte +587 -0
- package/dist/labs/components/textfield/textfield.svelte.d.ts +4 -0
- package/dist/labs/components/textfield/textfield.types.d.ts +41 -0
- package/dist/labs/components/textfield/textfield.types.js +1 -0
- package/dist/labs/components/toolbar/toolbar.svelte +262 -0
- package/dist/labs/components/toolbar/toolbar.svelte.d.ts +4 -0
- package/dist/labs/components/toolbar/toolbar.types.d.ts +21 -0
- package/dist/labs/components/toolbar/toolbar.types.js +1 -0
- package/dist/labs/components/tooltip/tooltip.svelte +372 -0
- package/dist/labs/components/tooltip/tooltip.svelte.d.ts +4 -0
- package/dist/labs/components/tooltip/tooltip.svelte.js +131 -0
- package/dist/labs/components/tooltip/tooltip.types.d.ts +26 -0
- package/dist/labs/components/tooltip/tooltip.types.js +1 -0
- package/dist/labs/utils/index.d.ts +1 -0
- package/dist/labs/utils/index.js +1 -0
- package/dist/labs/utils/outside.d.ts +5 -0
- package/dist/labs/utils/outside.js +34 -0
- package/dist/labs/utils/types/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useClassName, useStyles } from '../../utils/index.js';
|
|
3
|
+
import { makeComponentProps } from '../../compiler/mapped-code.js';
|
|
4
|
+
import Icon from '../icon/icon.svelte';
|
|
5
|
+
import type { TextfieldProps } from './textfield.types.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(),
|
|
9
|
+
prepend,
|
|
10
|
+
append,
|
|
11
|
+
prependInner,
|
|
12
|
+
appendInner,
|
|
13
|
+
value = $bindable(),
|
|
14
|
+
type = 'text',
|
|
15
|
+
density = 'default',
|
|
16
|
+
size = 'md',
|
|
17
|
+
variant = 'filled',
|
|
18
|
+
placeholder,
|
|
19
|
+
light = false,
|
|
20
|
+
dark = false,
|
|
21
|
+
counter = false,
|
|
22
|
+
min,
|
|
23
|
+
max,
|
|
24
|
+
prefix,
|
|
25
|
+
suffix,
|
|
26
|
+
message,
|
|
27
|
+
messagePrefix,
|
|
28
|
+
messageSuffix,
|
|
29
|
+
clearable = false,
|
|
30
|
+
persistentClear = false,
|
|
31
|
+
disabled = false,
|
|
32
|
+
error = false,
|
|
33
|
+
errorMessage,
|
|
34
|
+
persistentMessage = false,
|
|
35
|
+
hideSpinButtons = false,
|
|
36
|
+
readonly = false,
|
|
37
|
+
color,
|
|
38
|
+
background,
|
|
39
|
+
rounded,
|
|
40
|
+
class: className = '',
|
|
41
|
+
style: styleAttr = '',
|
|
42
|
+
's-class': sClass,
|
|
43
|
+
's-style': sStyle,
|
|
44
|
+
name,
|
|
45
|
+
id,
|
|
46
|
+
autocomplete,
|
|
47
|
+
inputmode,
|
|
48
|
+
...rest
|
|
49
|
+
}: TextfieldProps = $props();
|
|
50
|
+
|
|
51
|
+
let safeVariant = $derived(
|
|
52
|
+
variant === 'filled' || variant === 'outline' || variant === 'text' ? variant : 'filled'
|
|
53
|
+
);
|
|
54
|
+
let safeSize = $derived(
|
|
55
|
+
size === 'default'
|
|
56
|
+
? 'md'
|
|
57
|
+
: size === 'xs' || size === 'sm' || size === 'md' || size === 'lg' || size === 'xl'
|
|
58
|
+
? size
|
|
59
|
+
: 'md'
|
|
60
|
+
);
|
|
61
|
+
let safeDensity = $derived(
|
|
62
|
+
density === 'compact' || density === 'comfortable' || density === 'default'
|
|
63
|
+
? density
|
|
64
|
+
: 'default'
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
let { classProps, styleProps, restProps } = $derived(
|
|
68
|
+
makeComponentProps(rest as Record<string, unknown>)
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
let componentClass = $derived(
|
|
72
|
+
useClassName({
|
|
73
|
+
baseClass: 'kit-textfield',
|
|
74
|
+
className: `${className ?? ''}`.trim(),
|
|
75
|
+
sClass,
|
|
76
|
+
classProps
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
let componentStyle = $derived(
|
|
81
|
+
useStyles({
|
|
82
|
+
styleAttr,
|
|
83
|
+
sStyle,
|
|
84
|
+
styleProps
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
let mergedStyle = $derived(
|
|
89
|
+
[
|
|
90
|
+
componentStyle,
|
|
91
|
+
background ? `--kit-textfield-background:${background}` : '',
|
|
92
|
+
color ? `--kit-textfield-color:${color}` : '',
|
|
93
|
+
typeof rounded === 'string' && rounded.includes('px')
|
|
94
|
+
? `--kit-textfield-radius:${rounded}`
|
|
95
|
+
: ''
|
|
96
|
+
]
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
.join('; ')
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
let counterValue = $state(0);
|
|
102
|
+
let displayMessage = $state(false);
|
|
103
|
+
let displayClear = $state(false);
|
|
104
|
+
let inputRef = $state<HTMLInputElement | null>(null);
|
|
105
|
+
|
|
106
|
+
const inputClear = () => {
|
|
107
|
+
value = '';
|
|
108
|
+
inputRef?.focus();
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const handleFocus = () => {
|
|
112
|
+
if (!error && !persistentMessage) displayMessage = true;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const handleBlur = () => {
|
|
116
|
+
if (!error && !persistentMessage) displayMessage = false;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
$effect(() => {
|
|
120
|
+
if (persistentMessage || error) displayMessage = true;
|
|
121
|
+
else displayMessage = false;
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
$effect(() => {
|
|
125
|
+
const valueStr = value?.toString() || '';
|
|
126
|
+
|
|
127
|
+
if (valueStr && typeof max === 'number' && max > 0 && valueStr.length > max) {
|
|
128
|
+
const truncated = valueStr.slice(0, max);
|
|
129
|
+
if (typeof value === 'number') {
|
|
130
|
+
const numValue = Number(truncated);
|
|
131
|
+
value = Number.isNaN(numValue) ? 0 : numValue;
|
|
132
|
+
} else {
|
|
133
|
+
value = truncated;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
counterValue = valueStr.length;
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
$effect(() => {
|
|
141
|
+
if (persistentClear) displayClear = true;
|
|
142
|
+
else displayClear = !!(`${value ?? ''}`.length > 0);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
let messageValue = $derived(error ? errorMessage || message : message);
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<div
|
|
149
|
+
bind:this={ref}
|
|
150
|
+
class={componentClass}
|
|
151
|
+
style={mergedStyle}
|
|
152
|
+
{...restProps}
|
|
153
|
+
data-size={safeSize}
|
|
154
|
+
data-variant={safeVariant}
|
|
155
|
+
data-density={safeDensity}
|
|
156
|
+
data-light={light || undefined}
|
|
157
|
+
data-dark={dark || undefined}
|
|
158
|
+
data-disabled={disabled}
|
|
159
|
+
data-readonly={readonly}
|
|
160
|
+
data-error={error}
|
|
161
|
+
data-hide-spin-buttons={type === 'number' && hideSpinButtons}
|
|
162
|
+
data-rounded={rounded}
|
|
163
|
+
>
|
|
164
|
+
{#if prepend}
|
|
165
|
+
<div class="kit-textfield__prepend">
|
|
166
|
+
{@render prepend?.()}
|
|
167
|
+
</div>
|
|
168
|
+
{/if}
|
|
169
|
+
|
|
170
|
+
<div class="kit-textfield__control">
|
|
171
|
+
<div class="kit-textfield__field">
|
|
172
|
+
{#if safeVariant === 'outline' || safeVariant === 'filled'}
|
|
173
|
+
<span class="outline"></span>
|
|
174
|
+
{/if}
|
|
175
|
+
{#if safeVariant === 'text'}
|
|
176
|
+
<span class="line"></span>
|
|
177
|
+
{/if}
|
|
178
|
+
|
|
179
|
+
{#if prependInner}
|
|
180
|
+
<div class="kit-textfield__prepend-inner">
|
|
181
|
+
{@render prependInner?.()}
|
|
182
|
+
</div>
|
|
183
|
+
{/if}
|
|
184
|
+
|
|
185
|
+
<div class="kit-textfield__input-wrap">
|
|
186
|
+
{#if prefix}
|
|
187
|
+
<span class="kit-textfield__prefix">{prefix}</span>
|
|
188
|
+
{/if}
|
|
189
|
+
|
|
190
|
+
<input
|
|
191
|
+
bind:this={inputRef}
|
|
192
|
+
bind:value
|
|
193
|
+
{id}
|
|
194
|
+
{name}
|
|
195
|
+
{type}
|
|
196
|
+
{placeholder}
|
|
197
|
+
{autocomplete}
|
|
198
|
+
{inputmode}
|
|
199
|
+
size="1"
|
|
200
|
+
maxlength={max}
|
|
201
|
+
minlength={min}
|
|
202
|
+
{disabled}
|
|
203
|
+
{readonly}
|
|
204
|
+
aria-invalid={error || undefined}
|
|
205
|
+
aria-describedby={messageValue ? `${id ?? name ?? 'textfield'}-message` : undefined}
|
|
206
|
+
onfocus={handleFocus}
|
|
207
|
+
onblur={handleBlur}
|
|
208
|
+
/>
|
|
209
|
+
|
|
210
|
+
{#if suffix}
|
|
211
|
+
<span class="kit-textfield__suffix">{suffix}</span>
|
|
212
|
+
{/if}
|
|
213
|
+
</div>
|
|
214
|
+
|
|
215
|
+
{#if clearable}
|
|
216
|
+
<button
|
|
217
|
+
type="button"
|
|
218
|
+
class="kit-textfield__clear"
|
|
219
|
+
data-visible={displayClear}
|
|
220
|
+
aria-label="Clear input"
|
|
221
|
+
onclick={inputClear}
|
|
222
|
+
>
|
|
223
|
+
<Icon name="mgc_close_circle_fill" />
|
|
224
|
+
</button>
|
|
225
|
+
{/if}
|
|
226
|
+
|
|
227
|
+
{#if appendInner}
|
|
228
|
+
<div class="kit-textfield__append-inner">
|
|
229
|
+
{@render appendInner?.()}
|
|
230
|
+
</div>
|
|
231
|
+
{/if}
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
{#if append}
|
|
236
|
+
<div class="kit-textfield__append">
|
|
237
|
+
{@render append?.()}
|
|
238
|
+
</div>
|
|
239
|
+
{/if}
|
|
240
|
+
|
|
241
|
+
<div class="kit-textfield__message" data-visible={displayMessage}>
|
|
242
|
+
<div
|
|
243
|
+
class="kit-textfield__message-inner"
|
|
244
|
+
data-error={error || undefined}
|
|
245
|
+
id={messageValue ? `${id ?? name ?? 'textfield'}-message` : undefined}
|
|
246
|
+
>
|
|
247
|
+
{#if messagePrefix}
|
|
248
|
+
<div class="kit-textfield__message-prefix">{messagePrefix}</div>
|
|
249
|
+
{/if}
|
|
250
|
+
{#if messageValue}
|
|
251
|
+
<div class="kit-textfield__message-text">{messageValue}</div>
|
|
252
|
+
{/if}
|
|
253
|
+
{#if counter || messageSuffix}
|
|
254
|
+
<div class="kit-textfield__message-suffix">
|
|
255
|
+
{#if counter}
|
|
256
|
+
{counterValue}{max ? `/${max}` : ''}
|
|
257
|
+
{:else if messageSuffix}
|
|
258
|
+
{messageSuffix}
|
|
259
|
+
{/if}
|
|
260
|
+
</div>
|
|
261
|
+
{/if}
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
|
|
266
|
+
<style>
|
|
267
|
+
button,
|
|
268
|
+
input {
|
|
269
|
+
font: inherit;
|
|
270
|
+
color: inherit;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
input {
|
|
274
|
+
appearance: none;
|
|
275
|
+
background: transparent;
|
|
276
|
+
border: 0;
|
|
277
|
+
padding: 0;
|
|
278
|
+
margin: 0;
|
|
279
|
+
outline: none;
|
|
280
|
+
box-shadow: none;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
button {
|
|
284
|
+
appearance: none;
|
|
285
|
+
background: none;
|
|
286
|
+
border: 0;
|
|
287
|
+
padding: 0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.kit-textfield {
|
|
291
|
+
--kit-textfield-background: var(--kit-surface-2);
|
|
292
|
+
--kit-textfield-color: var(--kit-fg);
|
|
293
|
+
--kit-textfield-border: color-mix(in oklab, var(--kit-textfield-color), transparent 84%);
|
|
294
|
+
--kit-textfield-radius: 8px;
|
|
295
|
+
--kit-textfield-font-size: 14px;
|
|
296
|
+
--kit-textfield-gap-base: 8px;
|
|
297
|
+
--kit-textfield-px-base: 14px;
|
|
298
|
+
--kit-textfield-py-base: 12px;
|
|
299
|
+
--kit-textfield-message-offset-base: 8px;
|
|
300
|
+
--kit-textfield-density-gap-adjust: 0px;
|
|
301
|
+
--kit-textfield-density-px-adjust: 0px;
|
|
302
|
+
--kit-textfield-density-py-adjust: 0px;
|
|
303
|
+
--kit-textfield-density-message-adjust: 0px;
|
|
304
|
+
--kit-textfield-gap: calc(
|
|
305
|
+
var(--kit-textfield-gap-base) + var(--kit-textfield-density-gap-adjust)
|
|
306
|
+
);
|
|
307
|
+
--kit-textfield-px: calc(var(--kit-textfield-px-base) + var(--kit-textfield-density-px-adjust));
|
|
308
|
+
--kit-textfield-py: calc(var(--kit-textfield-py-base) + var(--kit-textfield-density-py-adjust));
|
|
309
|
+
--kit-textfield-message-offset: calc(
|
|
310
|
+
var(--kit-textfield-message-offset-base) + var(--kit-textfield-density-message-adjust)
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
display: grid;
|
|
314
|
+
grid-template-areas:
|
|
315
|
+
'prepend control append'
|
|
316
|
+
'. message .';
|
|
317
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
318
|
+
grid-template-rows: auto auto;
|
|
319
|
+
align-items: start;
|
|
320
|
+
column-gap: 16px;
|
|
321
|
+
width: 100%;
|
|
322
|
+
font-size: var(--kit-textfield-font-size);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.kit-textfield[data-size='xs'] {
|
|
326
|
+
--kit-textfield-font-size: 12px;
|
|
327
|
+
--kit-textfield-gap-base: 6px;
|
|
328
|
+
--kit-textfield-px-base: 10px;
|
|
329
|
+
--kit-textfield-py-base: 8px;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.kit-textfield[data-size='sm'] {
|
|
333
|
+
--kit-textfield-font-size: 13px;
|
|
334
|
+
--kit-textfield-gap-base: 6px;
|
|
335
|
+
--kit-textfield-px-base: 12px;
|
|
336
|
+
--kit-textfield-py-base: 10px;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.kit-textfield[data-size='md'] {
|
|
340
|
+
--kit-textfield-font-size: 14px;
|
|
341
|
+
--kit-textfield-gap-base: 8px;
|
|
342
|
+
--kit-textfield-px-base: 14px;
|
|
343
|
+
--kit-textfield-py-base: 12px;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.kit-textfield[data-size='lg'] {
|
|
347
|
+
--kit-textfield-font-size: 15px;
|
|
348
|
+
--kit-textfield-gap-base: 10px;
|
|
349
|
+
--kit-textfield-px-base: 16px;
|
|
350
|
+
--kit-textfield-py-base: 14px;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.kit-textfield[data-size='xl'] {
|
|
354
|
+
--kit-textfield-font-size: 16px;
|
|
355
|
+
--kit-textfield-gap-base: 12px;
|
|
356
|
+
--kit-textfield-px-base: 18px;
|
|
357
|
+
--kit-textfield-py-base: 16px;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.kit-textfield[data-density='compact'] {
|
|
361
|
+
--kit-textfield-density-gap-adjust: -1px;
|
|
362
|
+
--kit-textfield-density-px-adjust: -2px;
|
|
363
|
+
--kit-textfield-density-py-adjust: -2px;
|
|
364
|
+
--kit-textfield-density-message-adjust: -2px;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.kit-textfield[data-density='comfortable'] {
|
|
368
|
+
--kit-textfield-density-gap-adjust: 1px;
|
|
369
|
+
--kit-textfield-density-px-adjust: 2px;
|
|
370
|
+
--kit-textfield-density-py-adjust: 2px;
|
|
371
|
+
--kit-textfield-density-message-adjust: 2px;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.kit-textfield[data-variant='filled'] .kit-textfield__field {
|
|
375
|
+
background: var(--kit-textfield-background);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.kit-textfield[data-variant='outline'] .kit-textfield__field {
|
|
379
|
+
background: color-mix(in oklab, var(--kit-textfield-background), transparent 90%);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.kit-textfield[data-variant='text'] .kit-textfield__field {
|
|
383
|
+
background: transparent;
|
|
384
|
+
border-radius: 0;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.kit-textfield[data-light='true'] {
|
|
388
|
+
--kit-textfield-background: color-mix(in oklab, white 88%, var(--kit-surface-1));
|
|
389
|
+
--kit-textfield-color: var(--kit-fg);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.kit-textfield[data-dark='true'] {
|
|
393
|
+
--kit-textfield-background: color-mix(in oklab, black 72%, var(--kit-surface-3));
|
|
394
|
+
--kit-textfield-color: white;
|
|
395
|
+
--kit-textfield-border: color-mix(in oklab, white, transparent 74%);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.kit-textfield[data-disabled='true'] {
|
|
399
|
+
opacity: var(--kit-disabled-opacity, 0.55);
|
|
400
|
+
pointer-events: none;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.kit-textfield[data-readonly='true'] input {
|
|
404
|
+
cursor: default;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.kit-textfield[data-hide-spin-buttons='true'] input[type='number'] {
|
|
408
|
+
appearance: textfield;
|
|
409
|
+
-moz-appearance: textfield;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.kit-textfield[data-hide-spin-buttons='true'] input[type='number']::-webkit-inner-spin-button,
|
|
413
|
+
.kit-textfield[data-hide-spin-buttons='true'] input[type='number']::-webkit-outer-spin-button {
|
|
414
|
+
appearance: none;
|
|
415
|
+
-webkit-appearance: none;
|
|
416
|
+
margin: 0;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.kit-textfield[data-rounded='0'] {
|
|
420
|
+
--kit-textfield-radius: 0;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.kit-textfield[data-rounded='xs'] {
|
|
424
|
+
--kit-textfield-radius: 2px;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.kit-textfield[data-rounded='sm'] {
|
|
428
|
+
--kit-textfield-radius: 4px;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.kit-textfield[data-rounded='md'] {
|
|
432
|
+
--kit-textfield-radius: 8px;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
.kit-textfield[data-rounded='lg'] {
|
|
436
|
+
--kit-textfield-radius: 16px;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.kit-textfield[data-rounded='xl'] {
|
|
440
|
+
--kit-textfield-radius: 99999px;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.kit-textfield__prepend,
|
|
444
|
+
.kit-textfield__append {
|
|
445
|
+
display: flex;
|
|
446
|
+
align-items: center;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.kit-textfield__prepend {
|
|
450
|
+
grid-area: prepend;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
.kit-textfield__append {
|
|
454
|
+
grid-area: append;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.kit-textfield__control {
|
|
458
|
+
grid-area: control;
|
|
459
|
+
display: flex;
|
|
460
|
+
min-width: 0;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.kit-textfield__field {
|
|
464
|
+
position: relative;
|
|
465
|
+
display: flex;
|
|
466
|
+
align-items: center;
|
|
467
|
+
gap: var(--kit-textfield-gap);
|
|
468
|
+
width: 100%;
|
|
469
|
+
min-width: 0;
|
|
470
|
+
padding: var(--kit-textfield-py) var(--kit-textfield-px);
|
|
471
|
+
border-radius: var(--kit-textfield-radius);
|
|
472
|
+
color: var(--kit-textfield-color);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.kit-textfield__prepend-inner,
|
|
476
|
+
.kit-textfield__append-inner {
|
|
477
|
+
position: relative;
|
|
478
|
+
z-index: 1;
|
|
479
|
+
display: inline-flex;
|
|
480
|
+
align-items: center;
|
|
481
|
+
flex: 0 0 auto;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
.kit-textfield__input-wrap {
|
|
485
|
+
position: relative;
|
|
486
|
+
z-index: 1;
|
|
487
|
+
display: flex;
|
|
488
|
+
align-items: center;
|
|
489
|
+
gap: 6px;
|
|
490
|
+
flex: 1 1 auto;
|
|
491
|
+
min-width: 0;
|
|
492
|
+
width: 100%;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
.kit-textfield__input-wrap input {
|
|
496
|
+
flex: 1 1 auto;
|
|
497
|
+
width: 100%;
|
|
498
|
+
min-width: 0;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.kit-textfield__prefix,
|
|
502
|
+
.kit-textfield__suffix {
|
|
503
|
+
display: inline-flex;
|
|
504
|
+
align-items: center;
|
|
505
|
+
white-space: nowrap;
|
|
506
|
+
color: color-mix(in oklab, currentColor, transparent 20%);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.kit-textfield__clear {
|
|
510
|
+
position: relative;
|
|
511
|
+
z-index: 1;
|
|
512
|
+
display: inline-flex;
|
|
513
|
+
align-items: center;
|
|
514
|
+
justify-content: center;
|
|
515
|
+
flex: 0 0 auto;
|
|
516
|
+
cursor: pointer;
|
|
517
|
+
opacity: 0;
|
|
518
|
+
pointer-events: none;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
.kit-textfield__clear[data-visible='true'] {
|
|
522
|
+
opacity: 1;
|
|
523
|
+
pointer-events: auto;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.kit-textfield .outline,
|
|
527
|
+
.kit-textfield .line {
|
|
528
|
+
pointer-events: none;
|
|
529
|
+
position: absolute;
|
|
530
|
+
left: 0;
|
|
531
|
+
right: 0;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.kit-textfield .outline {
|
|
535
|
+
--outline-color: var(--kit-textfield-border);
|
|
536
|
+
top: 0;
|
|
537
|
+
bottom: 0;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.kit-textfield .line {
|
|
541
|
+
bottom: 0;
|
|
542
|
+
height: 1px;
|
|
543
|
+
background: var(--kit-textfield-border);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
.kit-textfield[data-error='true'] .outline {
|
|
547
|
+
--outline-color: var(--kit-danger, hsl(5 80% 55%));
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.kit-textfield[data-error='true'] .line {
|
|
551
|
+
background: var(--kit-danger, hsl(5 80% 55%));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.kit-textfield__message {
|
|
555
|
+
grid-area: message;
|
|
556
|
+
padding-top: var(--kit-textfield-message-offset);
|
|
557
|
+
padding-inline: var(--kit-textfield-px);
|
|
558
|
+
font-size: 12px;
|
|
559
|
+
opacity: 0;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.kit-textfield__message[data-visible='true'] {
|
|
563
|
+
opacity: 1;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.kit-textfield__message-inner {
|
|
567
|
+
display: grid;
|
|
568
|
+
grid-template-columns: max-content minmax(0, 1fr) max-content;
|
|
569
|
+
gap: var(--kit-textfield-gap);
|
|
570
|
+
align-items: start;
|
|
571
|
+
min-height: 14px;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.kit-textfield__message-inner[data-error='true'] {
|
|
575
|
+
color: var(--kit-danger, hsl(5 80% 55%));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.kit-textfield__message-prefix,
|
|
579
|
+
.kit-textfield__message-suffix {
|
|
580
|
+
line-height: 1.2;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.kit-textfield__message-text {
|
|
584
|
+
line-height: 1.2;
|
|
585
|
+
word-break: break-word;
|
|
586
|
+
}
|
|
587
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Component, RoundedType, SizeType } from '../../utils/types/index.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
+
export interface TextfieldProps extends Component {
|
|
5
|
+
ref?: HTMLElement | null;
|
|
6
|
+
dark?: boolean;
|
|
7
|
+
light?: boolean;
|
|
8
|
+
value?: string | number;
|
|
9
|
+
type?: 'text' | 'email' | 'password' | 'number';
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
counter?: boolean;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
variant?: 'outline' | 'text' | 'filled';
|
|
15
|
+
density?: 'compact' | 'comfortable' | 'default';
|
|
16
|
+
error?: boolean;
|
|
17
|
+
errorMessage?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
color?: string;
|
|
20
|
+
background?: string;
|
|
21
|
+
size?: SizeType;
|
|
22
|
+
rounded?: RoundedType | string;
|
|
23
|
+
readonly?: boolean;
|
|
24
|
+
hideSpinButtons?: boolean;
|
|
25
|
+
persistentMessage?: boolean;
|
|
26
|
+
persistentClear?: boolean;
|
|
27
|
+
clearable?: boolean;
|
|
28
|
+
message?: string;
|
|
29
|
+
messagePrefix?: string;
|
|
30
|
+
messageSuffix?: string;
|
|
31
|
+
append?: Snippet;
|
|
32
|
+
prepend?: Snippet;
|
|
33
|
+
prependInner?: Snippet;
|
|
34
|
+
appendInner?: Snippet;
|
|
35
|
+
prefix?: string;
|
|
36
|
+
suffix?: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
id?: string;
|
|
39
|
+
autocomplete?: HTMLInputAttributes['autocomplete'];
|
|
40
|
+
inputmode?: HTMLInputAttributes['inputmode'];
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|