uisv 0.0.13 → 0.0.15
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/components/alert.svelte +8 -2
- package/dist/components/alert.svelte.d.ts +2 -2
- package/dist/components/badge.svelte +18 -18
- package/dist/components/badge.svelte.d.ts +2 -2
- package/dist/components/banner.svelte +8 -2
- package/dist/components/banner.svelte.d.ts +2 -2
- package/dist/components/breadcrumb.svelte +75 -0
- package/dist/components/breadcrumb.svelte.d.ts +38 -0
- package/dist/components/button.svelte +415 -0
- package/dist/components/{button/index.d.ts → button.svelte.d.ts} +9 -4
- package/dist/components/calendar.svelte +99 -0
- package/dist/components/calendar.svelte.d.ts +16 -0
- package/dist/components/card.svelte +11 -10
- package/dist/components/card.svelte.d.ts +2 -1
- package/dist/components/collapsible.svelte +76 -0
- package/dist/components/collapsible.svelte.d.ts +15 -0
- package/dist/components/icon.svelte +58 -0
- package/dist/components/icon.svelte.d.ts +8 -0
- package/dist/components/index.d.ts +18 -3
- package/dist/components/index.js +18 -3
- package/dist/components/input-number.svelte +175 -0
- package/dist/components/input-number.svelte.d.ts +38 -0
- package/dist/components/input-time.svelte +233 -0
- package/dist/components/input-time.svelte.d.ts +53 -0
- package/dist/components/input.svelte +285 -0
- package/dist/components/{input/index.d.ts → input.svelte.d.ts} +6 -5
- package/dist/components/kbd.svelte +35 -35
- package/dist/components/kbd.svelte.d.ts +2 -2
- package/dist/components/pin-input.svelte +20 -20
- package/dist/components/pin-input.svelte.d.ts +2 -2
- package/dist/components/placeholder.svelte +1 -1
- package/dist/components/select.svelte +2 -2
- package/dist/components/select.svelte.d.ts +2 -2
- package/dist/components/seperator.svelte +212 -0
- package/dist/components/seperator.svelte.d.ts +22 -0
- package/dist/components/tabs.svelte +1 -2
- package/dist/date.d.ts +1 -0
- package/dist/date.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/utilities.svelte.d.ts +7 -0
- package/dist/utilities.svelte.js +20 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +24 -39
- package/package.json +41 -49
- package/dist/components/button/button.svelte +0 -105
- package/dist/components/button/button.svelte.d.ts +0 -4
- package/dist/components/button/index.js +0 -4
- package/dist/components/button/style.d.ts +0 -148
- package/dist/components/button/style.js +0 -248
- package/dist/components/input/index.js +0 -2
- package/dist/components/input/input.svelte +0 -103
- package/dist/components/input/input.svelte.d.ts +0 -4
- package/dist/components/input/style.d.ts +0 -316
- package/dist/components/input/style.js +0 -128
- package/dist/components/input-time/index.d.ts +0 -375
- package/dist/components/input-time/index.js +0 -144
- package/dist/components/input-time/input-time.svelte +0 -39
- package/dist/components/input-time/input-time.svelte.d.ts +0 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ButtonProps } from '../index.js';
|
|
2
|
+
import { Collapsible } from 'bits-ui';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
export type CollapsibleProps = ButtonProps & {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
class?: ClassNameValue;
|
|
8
|
+
ui?: {
|
|
9
|
+
root?: ClassNameValue;
|
|
10
|
+
content?: ClassNameValue;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare const Collapsible: import("svelte").Component<CollapsibleProps, {}, "open">;
|
|
14
|
+
type Collapsible = ReturnType<typeof Collapsible>;
|
|
15
|
+
export default Collapsible;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
3
|
+
import type { Component } from 'svelte';
|
|
4
|
+
import { useStyle, isComponent } from '../index.js';
|
|
5
|
+
import { useDebounce, watch } from 'runed';
|
|
6
|
+
|
|
7
|
+
export type IconProps = SvelteHTMLElements['base'] & {
|
|
8
|
+
name: string | Component;
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
let { class: classname, name, ...rest }: IconProps = $props();
|
|
14
|
+
|
|
15
|
+
let css_style = $state('');
|
|
16
|
+
|
|
17
|
+
const resolve = useDebounce(async () => {
|
|
18
|
+
if (typeof name !== 'string') return (css_style = '');
|
|
19
|
+
const url = `https://api.iconify.design/${name.replace(/^i-/, '')}.svg`;
|
|
20
|
+
let svg = await (await fetch(url)).text();
|
|
21
|
+
if (svg === 'Not found') return (css_style = '');
|
|
22
|
+
css_style = `@layer components {
|
|
23
|
+
.${name.replace(':', '\\:')} {
|
|
24
|
+
--un-icon: url('data:image/svg+xml,${svg
|
|
25
|
+
.replaceAll(/[\n\t]/g, '')
|
|
26
|
+
.replaceAll('"', '\"')
|
|
27
|
+
.replace('<', '%3C')
|
|
28
|
+
.replace('>', '%3E')}');
|
|
29
|
+
display: inline-block;
|
|
30
|
+
width: 1em;
|
|
31
|
+
height: 1em;
|
|
32
|
+
background-color: currentColor;
|
|
33
|
+
-webkit-mask-image: var(--un-icon);
|
|
34
|
+
mask-image: var(--un-icon);
|
|
35
|
+
-webkit-mask-repeat: no-repeat;
|
|
36
|
+
mask-repeat: no-repeat;
|
|
37
|
+
-webkit-mask-size: 100% 100%;
|
|
38
|
+
mask-size: 100% 100%;
|
|
39
|
+
}
|
|
40
|
+
}`;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
watch(
|
|
44
|
+
() => name,
|
|
45
|
+
() => {
|
|
46
|
+
resolve();
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
useStyle(() => css_style);
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
{#if typeof name === 'string' && name.length > 0}
|
|
54
|
+
<div {...rest as SvelteHTMLElements['div']} class={[name, classname]}></div>
|
|
55
|
+
{:else if isComponent(name)}
|
|
56
|
+
{@const Icon = name}
|
|
57
|
+
<Icon {...rest} />
|
|
58
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
export type IconProps = SvelteHTMLElements['base'] & {
|
|
4
|
+
name: string | Component;
|
|
5
|
+
};
|
|
6
|
+
declare const Icon: Component<IconProps, {}, "">;
|
|
7
|
+
type Icon = ReturnType<typeof Icon>;
|
|
8
|
+
export default Icon;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export * from './button
|
|
2
|
-
export
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './button.svelte';
|
|
2
|
+
export { default as Button } from './button.svelte';
|
|
3
|
+
export * from './badge.svelte';
|
|
4
|
+
export { default as Input } from './input.svelte';
|
|
5
|
+
export * from './badge.svelte';
|
|
6
|
+
export { default as InputTime } from './input-time.svelte';
|
|
4
7
|
export * from './badge.svelte';
|
|
5
8
|
export { default as Badge } from './badge.svelte';
|
|
6
9
|
export * from './alert.svelte';
|
|
@@ -40,3 +43,15 @@ export * from './color-picker.svelte';
|
|
|
40
43
|
export { default as ColorPicker } from './color-picker.svelte';
|
|
41
44
|
export * from './select.svelte';
|
|
42
45
|
export { default as Select } from './select.svelte';
|
|
46
|
+
export * from './collapsible.svelte';
|
|
47
|
+
export { default as Collapsible } from './collapsible.svelte';
|
|
48
|
+
export * from './placeholder.svelte';
|
|
49
|
+
export { default as Placeholder } from './placeholder.svelte';
|
|
50
|
+
export * from './seperator.svelte';
|
|
51
|
+
export { default as Seperator } from './seperator.svelte';
|
|
52
|
+
export * from './icon.svelte';
|
|
53
|
+
export { default as Icon } from './icon.svelte';
|
|
54
|
+
export * from './breadcrumb.svelte';
|
|
55
|
+
export { default as Breadcrumb } from './breadcrumb.svelte';
|
|
56
|
+
export * from './input-number.svelte';
|
|
57
|
+
export { default as InputNumber } from './input-number.svelte';
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export * from './button
|
|
2
|
-
export
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './button.svelte';
|
|
2
|
+
export { default as Button } from './button.svelte';
|
|
3
|
+
export * from './badge.svelte';
|
|
4
|
+
export { default as Input } from './input.svelte';
|
|
5
|
+
export * from './badge.svelte';
|
|
6
|
+
export { default as InputTime } from './input-time.svelte';
|
|
4
7
|
export * from './badge.svelte';
|
|
5
8
|
export { default as Badge } from './badge.svelte';
|
|
6
9
|
export * from './alert.svelte';
|
|
@@ -40,3 +43,15 @@ export * from './color-picker.svelte';
|
|
|
40
43
|
export { default as ColorPicker } from './color-picker.svelte';
|
|
41
44
|
export * from './select.svelte';
|
|
42
45
|
export { default as Select } from './select.svelte';
|
|
46
|
+
export * from './collapsible.svelte';
|
|
47
|
+
export { default as Collapsible } from './collapsible.svelte';
|
|
48
|
+
export * from './placeholder.svelte';
|
|
49
|
+
export { default as Placeholder } from './placeholder.svelte';
|
|
50
|
+
export * from './seperator.svelte';
|
|
51
|
+
export { default as Seperator } from './seperator.svelte';
|
|
52
|
+
export * from './icon.svelte';
|
|
53
|
+
export { default as Icon } from './icon.svelte';
|
|
54
|
+
export * from './breadcrumb.svelte';
|
|
55
|
+
export { default as Breadcrumb } from './breadcrumb.svelte';
|
|
56
|
+
export * from './input-number.svelte';
|
|
57
|
+
export { default as InputNumber } from './input-number.svelte';
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
type ButtonProps,
|
|
5
|
+
type PropColor,
|
|
6
|
+
type PropSize,
|
|
7
|
+
type PropVariant,
|
|
8
|
+
} from '../index.js';
|
|
9
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
10
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
11
|
+
import { tv } from 'tailwind-variants';
|
|
12
|
+
import Accordion from './accordion.svelte';
|
|
13
|
+
import { useId } from 'bits-ui';
|
|
14
|
+
|
|
15
|
+
export type InputNumberProps = Omit<SvelteHTMLElements['input'], 'size' | 'value'> & {
|
|
16
|
+
value?: number;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
color?: PropColor;
|
|
19
|
+
variant?: Exclude<PropVariant, 'solid'>;
|
|
20
|
+
size?: PropSize;
|
|
21
|
+
highlight?: boolean;
|
|
22
|
+
fixed?: boolean;
|
|
23
|
+
orientation?: 'vertical' | 'horizontal';
|
|
24
|
+
increment?: boolean | Omit<ButtonProps, 'href'>;
|
|
25
|
+
decrement?: boolean | Omit<ButtonProps, 'href'>;
|
|
26
|
+
autofocus?: boolean | number;
|
|
27
|
+
min?: number;
|
|
28
|
+
max?: number;
|
|
29
|
+
step?: number;
|
|
30
|
+
stepsnapping?: number;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
required?: boolean;
|
|
33
|
+
id?: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
format?: Intl.NumberFormatOptions;
|
|
36
|
+
wheelchange?: boolean;
|
|
37
|
+
invertwheelchange?: boolean;
|
|
38
|
+
focusonchange?: boolean;
|
|
39
|
+
autocomplete?: 'on' | 'off' | string;
|
|
40
|
+
ui?: {
|
|
41
|
+
root?: ClassNameValue;
|
|
42
|
+
base?: ClassNameValue;
|
|
43
|
+
increment?: ClassNameValue;
|
|
44
|
+
decrement?: ClassNameValue;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<script lang="ts">
|
|
50
|
+
let {
|
|
51
|
+
value = $bindable(),
|
|
52
|
+
placeholder,
|
|
53
|
+
color = 'primary',
|
|
54
|
+
variant = 'outline',
|
|
55
|
+
size = 'md',
|
|
56
|
+
highlight,
|
|
57
|
+
fixed,
|
|
58
|
+
orientation = 'horizontal',
|
|
59
|
+
increment = true,
|
|
60
|
+
decrement = true,
|
|
61
|
+
autofocus,
|
|
62
|
+
min,
|
|
63
|
+
max,
|
|
64
|
+
step,
|
|
65
|
+
stepsnapping,
|
|
66
|
+
disabled,
|
|
67
|
+
required,
|
|
68
|
+
format,
|
|
69
|
+
wheelchange = true,
|
|
70
|
+
invertwheelchange,
|
|
71
|
+
focusonchange,
|
|
72
|
+
autocomplete,
|
|
73
|
+
ui = {},
|
|
74
|
+
...rest
|
|
75
|
+
}: InputNumberProps = $props();
|
|
76
|
+
const id = useId('uisv-in');
|
|
77
|
+
|
|
78
|
+
const variants = $derived(
|
|
79
|
+
tv({
|
|
80
|
+
slots: {
|
|
81
|
+
root: 'inline-flex relative items-center',
|
|
82
|
+
base: 'outline-none',
|
|
83
|
+
increment: '',
|
|
84
|
+
decrement: '',
|
|
85
|
+
},
|
|
86
|
+
variants: {
|
|
87
|
+
size: {
|
|
88
|
+
xs: {},
|
|
89
|
+
sm: {},
|
|
90
|
+
md: {},
|
|
91
|
+
lg: {},
|
|
92
|
+
xl: {},
|
|
93
|
+
},
|
|
94
|
+
variant: {
|
|
95
|
+
outline: {},
|
|
96
|
+
subtle: {},
|
|
97
|
+
soft: {},
|
|
98
|
+
ghost: {},
|
|
99
|
+
none: {},
|
|
100
|
+
},
|
|
101
|
+
color: {
|
|
102
|
+
primary: {},
|
|
103
|
+
surface: {},
|
|
104
|
+
info: {},
|
|
105
|
+
success: {},
|
|
106
|
+
warning: {},
|
|
107
|
+
error: {},
|
|
108
|
+
},
|
|
109
|
+
orientation: {
|
|
110
|
+
horizontal: {},
|
|
111
|
+
vertical: {},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
compoundVariants: [
|
|
115
|
+
{
|
|
116
|
+
color: 'primary',
|
|
117
|
+
class: { base: 'bg-pimary-500' },
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
})({ color, size, orientation, variant }),
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
$effect(() => {
|
|
124
|
+
if (typeof value === 'string') value = parseInt(value) || undefined;
|
|
125
|
+
});
|
|
126
|
+
</script>
|
|
127
|
+
|
|
128
|
+
<div class={variants.root({ class: ui.root })}>
|
|
129
|
+
<input
|
|
130
|
+
{...rest}
|
|
131
|
+
{id}
|
|
132
|
+
tabindex="0"
|
|
133
|
+
bind:value
|
|
134
|
+
type="text"
|
|
135
|
+
inputmode="decimal"
|
|
136
|
+
{autocomplete}
|
|
137
|
+
autocorrect="off"
|
|
138
|
+
spellcheck="false"
|
|
139
|
+
{placeholder}
|
|
140
|
+
{max}
|
|
141
|
+
{min}
|
|
142
|
+
{step}
|
|
143
|
+
class={variants.base({ class: ui.base })}
|
|
144
|
+
/>
|
|
145
|
+
|
|
146
|
+
{#if orientation === 'horizontal'}
|
|
147
|
+
{@render crements()}
|
|
148
|
+
{:else}
|
|
149
|
+
<div class="flex flex-col position">
|
|
150
|
+
{@render crements()}
|
|
151
|
+
</div>
|
|
152
|
+
{/if}
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
{#snippet crements()}
|
|
156
|
+
{#if increment}
|
|
157
|
+
<Button
|
|
158
|
+
variant="link"
|
|
159
|
+
icon="i-lucide:minus"
|
|
160
|
+
onclick={() => {
|
|
161
|
+
value = value === undefined ? 0 : value - 1;
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
{/if}
|
|
165
|
+
|
|
166
|
+
{#if increment}
|
|
167
|
+
<Button
|
|
168
|
+
variant="link"
|
|
169
|
+
icon="i-lucide:plus"
|
|
170
|
+
onclick={() => {
|
|
171
|
+
value = value === undefined ? 0 : value + 1;
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
{/if}
|
|
175
|
+
{/snippet}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ButtonProps, type PropColor, type PropSize, type PropVariant } from '../index.js';
|
|
2
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
export type InputNumberProps = Omit<SvelteHTMLElements['input'], 'size' | 'value'> & {
|
|
5
|
+
value?: number;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
color?: PropColor;
|
|
8
|
+
variant?: Exclude<PropVariant, 'solid'>;
|
|
9
|
+
size?: PropSize;
|
|
10
|
+
highlight?: boolean;
|
|
11
|
+
fixed?: boolean;
|
|
12
|
+
orientation?: 'vertical' | 'horizontal';
|
|
13
|
+
increment?: boolean | Omit<ButtonProps, 'href'>;
|
|
14
|
+
decrement?: boolean | Omit<ButtonProps, 'href'>;
|
|
15
|
+
autofocus?: boolean | number;
|
|
16
|
+
min?: number;
|
|
17
|
+
max?: number;
|
|
18
|
+
step?: number;
|
|
19
|
+
stepsnapping?: number;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
id?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
format?: Intl.NumberFormatOptions;
|
|
25
|
+
wheelchange?: boolean;
|
|
26
|
+
invertwheelchange?: boolean;
|
|
27
|
+
focusonchange?: boolean;
|
|
28
|
+
autocomplete?: 'on' | 'off' | string;
|
|
29
|
+
ui?: {
|
|
30
|
+
root?: ClassNameValue;
|
|
31
|
+
base?: ClassNameValue;
|
|
32
|
+
increment?: ClassNameValue;
|
|
33
|
+
decrement?: ClassNameValue;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
declare const InputNumber: import("svelte").Component<InputNumberProps, {}, "value">;
|
|
37
|
+
type InputNumber = ReturnType<typeof InputNumber>;
|
|
38
|
+
export default InputNumber;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { type PropColor, type PropVariant } from '../index.js';
|
|
3
|
+
import type { Component, Snippet } from 'svelte';
|
|
4
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
|
+
import { tv } from 'tailwind-variants';
|
|
6
|
+
import { Time } from '../date.js';
|
|
7
|
+
|
|
8
|
+
export { default as InputTime } from './input-time.svelte';
|
|
9
|
+
|
|
10
|
+
export type InputTimeProps = {
|
|
11
|
+
id?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
hourcycle?: 12 | 24;
|
|
14
|
+
max?: Time;
|
|
15
|
+
min?: Time;
|
|
16
|
+
/**
|
|
17
|
+
* The placeholder text when the input is empty.
|
|
18
|
+
*/
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @default primary
|
|
22
|
+
*/
|
|
23
|
+
color?: PropColor;
|
|
24
|
+
/**
|
|
25
|
+
* @default outline
|
|
26
|
+
*/
|
|
27
|
+
variant?: Exclude<PropVariant, 'solid'>;
|
|
28
|
+
/**
|
|
29
|
+
* @default md
|
|
30
|
+
*/
|
|
31
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
32
|
+
/**
|
|
33
|
+
* @default off
|
|
34
|
+
*/
|
|
35
|
+
autocomplete?: 'on' | 'off';
|
|
36
|
+
/**
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
autofocus?: boolean | number;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Highlight the ring color like a focus state.
|
|
43
|
+
*/
|
|
44
|
+
highlight?: boolean;
|
|
45
|
+
value?: Time;
|
|
46
|
+
icon?: string | Snippet | Component;
|
|
47
|
+
ui?: {
|
|
48
|
+
root?: ClassNameValue;
|
|
49
|
+
leading?: ClassNameValue;
|
|
50
|
+
icon?: ClassNameValue;
|
|
51
|
+
trailing?: ClassNameValue;
|
|
52
|
+
segment?: ClassNameValue;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<script lang="ts">
|
|
58
|
+
import { TimeField } from 'bits-ui';
|
|
59
|
+
|
|
60
|
+
let {
|
|
61
|
+
hourcycle = 12,
|
|
62
|
+
value = $bindable(),
|
|
63
|
+
color = 'primary',
|
|
64
|
+
variant = 'outline',
|
|
65
|
+
size = 'md',
|
|
66
|
+
icon,
|
|
67
|
+
disabled,
|
|
68
|
+
highlight,
|
|
69
|
+
ui = {},
|
|
70
|
+
...rest
|
|
71
|
+
}: InputTimeProps = $props();
|
|
72
|
+
|
|
73
|
+
const variants = $derived(
|
|
74
|
+
tv({
|
|
75
|
+
slots: {
|
|
76
|
+
root: 'inline-flex items-center rounded transition-all ring ring-inset ring-transparent',
|
|
77
|
+
leading: 'text-muted',
|
|
78
|
+
trailing: 'text-muted',
|
|
79
|
+
icon: '',
|
|
80
|
+
segment: [
|
|
81
|
+
'rounded text-center outline-hidden transition-all focus:bg-surface-accented shrink',
|
|
82
|
+
'aria-[valuetext="Empty"]:text-dimmed data-[segment="literal"]:(text-muted px-1) data-invalid:text-error data-disabled:(cursor-not-allowed opacity-75)',
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
variants: {
|
|
86
|
+
fieldGroup: {
|
|
87
|
+
horizontal: {
|
|
88
|
+
root: '',
|
|
89
|
+
},
|
|
90
|
+
vertical: {
|
|
91
|
+
root: '',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
size: {
|
|
95
|
+
xs: {
|
|
96
|
+
root: 'px-2 h-6 text-xs',
|
|
97
|
+
leading: 'ps-2',
|
|
98
|
+
trailing: 'pe-2',
|
|
99
|
+
icon: 'size-4',
|
|
100
|
+
segment: 'px-1',
|
|
101
|
+
},
|
|
102
|
+
sm: {
|
|
103
|
+
root: 'px-2.5 h-7 text-xs',
|
|
104
|
+
leading: 'ps-2.5',
|
|
105
|
+
trailing: 'pe-2.5',
|
|
106
|
+
icon: 'size-4',
|
|
107
|
+
segment: 'px-1',
|
|
108
|
+
},
|
|
109
|
+
md: {
|
|
110
|
+
root: 'px-2.5 h-8 text-sm',
|
|
111
|
+
leading: 'ps-2.5',
|
|
112
|
+
trailing: 'pe-2.5',
|
|
113
|
+
icon: 'size-5',
|
|
114
|
+
segment: 'px-2',
|
|
115
|
+
},
|
|
116
|
+
lg: {
|
|
117
|
+
root: 'px-3 h-9 text-sm',
|
|
118
|
+
leading: 'ps-3',
|
|
119
|
+
trailing: 'pe-3',
|
|
120
|
+
icon: 'size-5',
|
|
121
|
+
segment: 'px-3',
|
|
122
|
+
},
|
|
123
|
+
xl: {
|
|
124
|
+
root: 'px-3 h-10 text-base',
|
|
125
|
+
leading: 'ps-3',
|
|
126
|
+
trailing: 'pe-3',
|
|
127
|
+
icon: 'size-6',
|
|
128
|
+
segment: 'px-3',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
variant: {
|
|
132
|
+
outline: { root: 'ring ring-surface-accented' },
|
|
133
|
+
soft: {
|
|
134
|
+
root: 'bg-surface-muted hover:bg-surface-elevated focus-within:bg-surface-elevated',
|
|
135
|
+
},
|
|
136
|
+
subtle: { root: 'ring ring-accented' },
|
|
137
|
+
ghost: { root: 'hover:bg-surface-elevated focus-within:bg-surface-elevated' },
|
|
138
|
+
none: { root: '' },
|
|
139
|
+
},
|
|
140
|
+
color: {
|
|
141
|
+
primary: { root: '' },
|
|
142
|
+
surface: { root: '' },
|
|
143
|
+
info: { root: '' },
|
|
144
|
+
success: { root: '' },
|
|
145
|
+
warning: { root: '' },
|
|
146
|
+
error: { root: '' },
|
|
147
|
+
},
|
|
148
|
+
leading: {
|
|
149
|
+
false: { leading: 'hidden' },
|
|
150
|
+
},
|
|
151
|
+
trailing: {
|
|
152
|
+
false: { trailing: 'hidden' },
|
|
153
|
+
},
|
|
154
|
+
loading: {
|
|
155
|
+
true: '',
|
|
156
|
+
},
|
|
157
|
+
highlight: {
|
|
158
|
+
true: '',
|
|
159
|
+
},
|
|
160
|
+
type: {
|
|
161
|
+
file: 'file:me-1.5 file:font-medium file:text-muted file:outline-none',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
compoundVariants: [
|
|
165
|
+
{
|
|
166
|
+
color: 'primary',
|
|
167
|
+
variant: ['outline', 'subtle'],
|
|
168
|
+
highlight: true,
|
|
169
|
+
class: {
|
|
170
|
+
root: 'ring-primary-500 ring-2',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
color: 'surface',
|
|
175
|
+
variant: ['outline', 'subtle'],
|
|
176
|
+
highlight: true,
|
|
177
|
+
class: {
|
|
178
|
+
root: 'ring-surface-800 ring-2',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
color: 'info',
|
|
183
|
+
variant: ['outline', 'subtle'],
|
|
184
|
+
highlight: true,
|
|
185
|
+
class: {
|
|
186
|
+
root: 'ring-info-500 ring-2',
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
color: 'success',
|
|
191
|
+
variant: ['outline', 'subtle'],
|
|
192
|
+
highlight: true,
|
|
193
|
+
class: {
|
|
194
|
+
root: 'ring-success-500 ring-2',
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
color: 'warning',
|
|
199
|
+
variant: ['outline', 'subtle'],
|
|
200
|
+
highlight: true,
|
|
201
|
+
class: {
|
|
202
|
+
root: 'ring-warning-500 ring-2',
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
color: 'error',
|
|
207
|
+
variant: ['outline', 'subtle'],
|
|
208
|
+
highlight: true,
|
|
209
|
+
class: {
|
|
210
|
+
root: 'ring-error-500 ring-2',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
})({
|
|
215
|
+
size,
|
|
216
|
+
color,
|
|
217
|
+
variant,
|
|
218
|
+
highlight,
|
|
219
|
+
}),
|
|
220
|
+
);
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<TimeField.Root bind:value hourCycle={hourcycle}>
|
|
224
|
+
<TimeField.Input name="hello" class={variants.root({ class: ui.root })}>
|
|
225
|
+
{#snippet children({ segments })}
|
|
226
|
+
{#each segments as { part, value }, i (part + i)}
|
|
227
|
+
<TimeField.Segment {part} class={variants.segment({ class: ui.segment })}>
|
|
228
|
+
{value}
|
|
229
|
+
</TimeField.Segment>
|
|
230
|
+
{/each}
|
|
231
|
+
{/snippet}
|
|
232
|
+
</TimeField.Input>
|
|
233
|
+
</TimeField.Root>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type PropColor, type PropVariant } from '../index.js';
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import { Time } from '../date.js';
|
|
5
|
+
export { default as InputTime } from './input-time.svelte';
|
|
6
|
+
export type InputTimeProps = {
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
hourcycle?: 12 | 24;
|
|
10
|
+
max?: Time;
|
|
11
|
+
min?: Time;
|
|
12
|
+
/**
|
|
13
|
+
* The placeholder text when the input is empty.
|
|
14
|
+
*/
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
/**
|
|
17
|
+
* @default primary
|
|
18
|
+
*/
|
|
19
|
+
color?: PropColor;
|
|
20
|
+
/**
|
|
21
|
+
* @default outline
|
|
22
|
+
*/
|
|
23
|
+
variant?: Exclude<PropVariant, 'solid'>;
|
|
24
|
+
/**
|
|
25
|
+
* @default md
|
|
26
|
+
*/
|
|
27
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
28
|
+
/**
|
|
29
|
+
* @default off
|
|
30
|
+
*/
|
|
31
|
+
autocomplete?: 'on' | 'off';
|
|
32
|
+
/**
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
autofocus?: boolean | number;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Highlight the ring color like a focus state.
|
|
39
|
+
*/
|
|
40
|
+
highlight?: boolean;
|
|
41
|
+
value?: Time;
|
|
42
|
+
icon?: string | Snippet | Component;
|
|
43
|
+
ui?: {
|
|
44
|
+
root?: ClassNameValue;
|
|
45
|
+
leading?: ClassNameValue;
|
|
46
|
+
icon?: ClassNameValue;
|
|
47
|
+
trailing?: ClassNameValue;
|
|
48
|
+
segment?: ClassNameValue;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
declare const InputTime: Component<InputTimeProps, {}, "value">;
|
|
52
|
+
type InputTime = ReturnType<typeof InputTime>;
|
|
53
|
+
export default InputTime;
|