@svelte-atoms/core 1.0.0-alpha.23 → 1.0.0-alpha.25
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/README.md +645 -645
- package/dist/components/accordion/accordion-root.svelte.d.ts +2 -2
- package/dist/components/alert/alert-actions.svelte.d.ts +1 -0
- package/dist/components/alert/alert-close-button.svelte.d.ts +1 -0
- package/dist/components/alert/alert-content.svelte.d.ts +1 -0
- package/dist/components/atom/html-atom.svelte +151 -4
- package/dist/components/atom/html-atom.svelte.d.ts +4 -2
- package/dist/components/atom/types.d.ts +7 -0
- package/dist/components/button/button.stories.svelte +57 -17
- package/dist/components/button/button.stories.svelte.d.ts +6 -14
- package/dist/components/checkbox/checkbox.svelte.d.ts +1 -1
- package/dist/components/combobox/combobox-root.svelte.d.ts +2 -2
- package/dist/components/datagrid/datagrid.stories.svelte +75 -75
- package/dist/components/drawer/drawer-backdrop.svelte.d.ts +1 -0
- package/dist/components/icon/icon.svelte.d.ts +1 -0
- package/dist/components/input/input-placeholder.svelte +56 -56
- package/dist/components/input/input-placeholder.svelte.d.ts +1 -0
- package/dist/components/input/input-root.svelte +79 -79
- package/dist/components/input/input-root.svelte.d.ts +1 -0
- package/dist/components/input/input-value.svelte +113 -113
- package/dist/components/input/input-value.svelte.d.ts +1 -1
- package/dist/components/input/input.stories.svelte +38 -38
- package/dist/components/label/label.svelte.d.ts +1 -0
- package/dist/components/layer/layer-inner.svelte.d.ts +1 -0
- package/dist/components/layer/layer-root.svelte.d.ts +1 -0
- package/dist/components/popover/popover-arrow.svelte.d.ts +1 -0
- package/dist/components/portal/portal-inner.svelte.d.ts +1 -0
- package/dist/components/portal/portal-root.svelte.d.ts +1 -0
- package/dist/components/portal/teleport.svelte.d.ts +1 -0
- package/dist/components/radio/radio.svelte.d.ts +2 -2
- package/dist/components/root/root.svelte +121 -103
- package/dist/components/root/root.svelte.d.ts +1 -0
- package/dist/components/stack/stack-root.svelte.d.ts +1 -0
- package/dist/components/toast/toast-description.svelte.d.ts +1 -0
- package/dist/components/toast/toast-root.svelte.d.ts +1 -0
- package/dist/components/toast/toast-title.svelte.d.ts +1 -0
- package/dist/components/tree/tree-header.svelte.d.ts +1 -0
- package/dist/context/preset.svelte.d.ts +3 -0
- package/dist/runes/index.d.ts +3 -0
- package/dist/runes/index.js +3 -0
- package/dist/runes/reduced-motion.svelte.d.ts +23 -0
- package/dist/runes/reduced-motion.svelte.js +41 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/variant.d.ts +213 -0
- package/dist/utils/variant.js +137 -0
- package/llm/composition.md +395 -0
- package/llm/crafting.md +838 -0
- package/llm/motion.md +970 -0
- package/llm/philosophy.md +23 -0
- package/llm/preset-variant-integration.md +516 -0
- package/llm/preset.md +383 -0
- package/llm/styling.md +216 -0
- package/llm/usage.md +46 -0
- package/llm/variants.md +712 -0
- package/package.json +2 -1
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import { InputBond } from './bond.svelte';
|
|
4
|
-
import {
|
|
5
|
-
HtmlAtom,
|
|
6
|
-
type ElementType,
|
|
7
|
-
type HtmlAtomProps,
|
|
8
|
-
type Base
|
|
9
|
-
} from '../atom';
|
|
10
|
-
|
|
11
|
-
type Element = ElementType<E>;
|
|
12
|
-
|
|
13
|
-
const bond = InputBond.get();
|
|
14
|
-
|
|
15
|
-
let {
|
|
16
|
-
class: klass = '',
|
|
17
|
-
children = undefined,
|
|
18
|
-
...restProps
|
|
19
|
-
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
20
|
-
|
|
21
|
-
const placeholderProps = $derived({
|
|
22
|
-
...bond?.placeholder(),
|
|
23
|
-
...restProps
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const shouldShowPlaceholder = $derived.by(() => {
|
|
27
|
-
const type = bond?.elements?.input?.type ?? '';
|
|
28
|
-
|
|
29
|
-
if (['radio', 'checkbox'].includes(type)) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (['files'].includes(type)) {
|
|
34
|
-
return !bond?.state.props.files?.length;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.log(!bond?.state.props.value);
|
|
38
|
-
|
|
39
|
-
return !bond?.state.props.value;
|
|
40
|
-
});
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
{#if shouldShowPlaceholder}
|
|
44
|
-
<HtmlAtom
|
|
45
|
-
preset="input.placeholder"
|
|
46
|
-
class={[
|
|
47
|
-
'pointer-events-none absolute inset-0 flex h-full w-full items-center px-1 leading-1 outline-none',
|
|
48
|
-
'$preset',
|
|
49
|
-
klass
|
|
50
|
-
]}
|
|
51
|
-
style="left:{bond?.elements?.input?.offsetLeft ?? 0}px"
|
|
52
|
-
{...placeholderProps}
|
|
53
|
-
>
|
|
54
|
-
{@render children?.()}
|
|
55
|
-
</HtmlAtom>
|
|
56
|
-
{/if}
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { InputBond } from './bond.svelte';
|
|
4
|
+
import {
|
|
5
|
+
HtmlAtom,
|
|
6
|
+
type ElementType,
|
|
7
|
+
type HtmlAtomProps,
|
|
8
|
+
type Base
|
|
9
|
+
} from '../atom';
|
|
10
|
+
|
|
11
|
+
type Element = ElementType<E>;
|
|
12
|
+
|
|
13
|
+
const bond = InputBond.get();
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
class: klass = '',
|
|
17
|
+
children = undefined,
|
|
18
|
+
...restProps
|
|
19
|
+
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
20
|
+
|
|
21
|
+
const placeholderProps = $derived({
|
|
22
|
+
...bond?.placeholder(),
|
|
23
|
+
...restProps
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const shouldShowPlaceholder = $derived.by(() => {
|
|
27
|
+
const type = bond?.elements?.input?.type ?? '';
|
|
28
|
+
|
|
29
|
+
if (['radio', 'checkbox'].includes(type)) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (['files'].includes(type)) {
|
|
34
|
+
return !bond?.state.props.files?.length;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(!bond?.state.props.value);
|
|
38
|
+
|
|
39
|
+
return !bond?.state.props.value;
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
{#if shouldShowPlaceholder}
|
|
44
|
+
<HtmlAtom
|
|
45
|
+
preset="input.placeholder"
|
|
46
|
+
class={[
|
|
47
|
+
'pointer-events-none absolute inset-0 flex h-full w-full items-center px-1 leading-1 outline-none',
|
|
48
|
+
'$preset',
|
|
49
|
+
klass
|
|
50
|
+
]}
|
|
51
|
+
style="left:{bond?.elements?.input?.offsetLeft ?? 0}px"
|
|
52
|
+
{...placeholderProps}
|
|
53
|
+
>
|
|
54
|
+
{@render children?.()}
|
|
55
|
+
</HtmlAtom>
|
|
56
|
+
{/if}
|
|
@@ -17,6 +17,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
|
|
|
17
17
|
bond?: import("../..").Bond;
|
|
18
18
|
base?: B | undefined;
|
|
19
19
|
preset?: import("../..").ModuleName | (string & {});
|
|
20
|
+
variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
20
21
|
} & HTMLAttributes<ElementType<E>>;
|
|
21
22
|
exports: {};
|
|
22
23
|
bindings: "";
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import { InputBond, InputState, type InputStateProps } from './bond.svelte';
|
|
4
|
-
import { defineProperty, defineState, toClassValue } from '../../utils';
|
|
5
|
-
import {
|
|
6
|
-
HtmlAtom,
|
|
7
|
-
type ElementType,
|
|
8
|
-
type HtmlAtomProps,
|
|
9
|
-
type Base
|
|
10
|
-
} from '../atom';
|
|
11
|
-
|
|
12
|
-
type Element = ElementType<E>;
|
|
13
|
-
|
|
14
|
-
let {
|
|
15
|
-
class: klass = '',
|
|
16
|
-
value,
|
|
17
|
-
checked = undefined,
|
|
18
|
-
files = [],
|
|
19
|
-
preset = 'input',
|
|
20
|
-
children = undefined,
|
|
21
|
-
factory = _factory,
|
|
22
|
-
...restProps
|
|
23
|
-
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
24
|
-
|
|
25
|
-
const bondProps = defineState<InputStateProps>([
|
|
26
|
-
defineProperty(
|
|
27
|
-
'value',
|
|
28
|
-
() => value,
|
|
29
|
-
(v) => {
|
|
30
|
-
value = v;
|
|
31
|
-
}
|
|
32
|
-
),
|
|
33
|
-
|
|
34
|
-
defineProperty(
|
|
35
|
-
'checked',
|
|
36
|
-
() => checked,
|
|
37
|
-
(v) => {
|
|
38
|
-
checked = v;
|
|
39
|
-
}
|
|
40
|
-
),
|
|
41
|
-
|
|
42
|
-
defineProperty(
|
|
43
|
-
'files',
|
|
44
|
-
() => files,
|
|
45
|
-
(v) => {
|
|
46
|
-
files = [...v];
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
]);
|
|
50
|
-
const bond = _factory(bondProps).share();
|
|
51
|
-
|
|
52
|
-
const rootProps = $derived({
|
|
53
|
-
...bond.root(),
|
|
54
|
-
...restProps
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
function _factory(props: typeof bondProps) {
|
|
58
|
-
const bondState = new InputState(() => props);
|
|
59
|
-
|
|
60
|
-
return new InputBond(bondState);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function getBond() {
|
|
64
|
-
return bond;
|
|
65
|
-
}
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
<HtmlAtom
|
|
69
|
-
{preset}
|
|
70
|
-
class={[
|
|
71
|
-
'border-border text-foreground bg-input relative flex h-10 items-center overflow-hidden rounded-md border',
|
|
72
|
-
'$preset',
|
|
73
|
-
klass
|
|
74
|
-
]}
|
|
75
|
-
{bond}
|
|
76
|
-
{...rootProps}
|
|
77
|
-
>
|
|
78
|
-
{@render children?.({ input: bond })}
|
|
79
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { InputBond, InputState, type InputStateProps } from './bond.svelte';
|
|
4
|
+
import { defineProperty, defineState, toClassValue } from '../../utils';
|
|
5
|
+
import {
|
|
6
|
+
HtmlAtom,
|
|
7
|
+
type ElementType,
|
|
8
|
+
type HtmlAtomProps,
|
|
9
|
+
type Base
|
|
10
|
+
} from '../atom';
|
|
11
|
+
|
|
12
|
+
type Element = ElementType<E>;
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
class: klass = '',
|
|
16
|
+
value,
|
|
17
|
+
checked = undefined,
|
|
18
|
+
files = [],
|
|
19
|
+
preset = 'input',
|
|
20
|
+
children = undefined,
|
|
21
|
+
factory = _factory,
|
|
22
|
+
...restProps
|
|
23
|
+
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
24
|
+
|
|
25
|
+
const bondProps = defineState<InputStateProps>([
|
|
26
|
+
defineProperty(
|
|
27
|
+
'value',
|
|
28
|
+
() => value,
|
|
29
|
+
(v) => {
|
|
30
|
+
value = v;
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
|
|
34
|
+
defineProperty(
|
|
35
|
+
'checked',
|
|
36
|
+
() => checked,
|
|
37
|
+
(v) => {
|
|
38
|
+
checked = v;
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
|
|
42
|
+
defineProperty(
|
|
43
|
+
'files',
|
|
44
|
+
() => files,
|
|
45
|
+
(v) => {
|
|
46
|
+
files = [...v];
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
]);
|
|
50
|
+
const bond = _factory(bondProps).share();
|
|
51
|
+
|
|
52
|
+
const rootProps = $derived({
|
|
53
|
+
...bond.root(),
|
|
54
|
+
...restProps
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
function _factory(props: typeof bondProps) {
|
|
58
|
+
const bondState = new InputState(() => props);
|
|
59
|
+
|
|
60
|
+
return new InputBond(bondState);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getBond() {
|
|
64
|
+
return bond;
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<HtmlAtom
|
|
69
|
+
{preset}
|
|
70
|
+
class={[
|
|
71
|
+
'border-border text-foreground bg-input relative flex h-10 items-center overflow-hidden rounded-md border',
|
|
72
|
+
'$preset',
|
|
73
|
+
klass
|
|
74
|
+
]}
|
|
75
|
+
{bond}
|
|
76
|
+
{...rootProps}
|
|
77
|
+
>
|
|
78
|
+
{@render children?.({ input: bond })}
|
|
79
|
+
</HtmlAtom>
|
|
@@ -18,6 +18,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
|
|
|
18
18
|
bond?: import("../..").Bond;
|
|
19
19
|
base?: B | undefined;
|
|
20
20
|
preset?: import("../..").ModuleName | (string & {});
|
|
21
|
+
variants?: import("../../utils").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
21
22
|
} & HTMLAttributes<ElementType<E>>;
|
|
22
23
|
exports: {
|
|
23
24
|
getBond: () => InputBond;
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
export type InputPortals = 'input.l0' | 'input.l1' | 'input.l2' | 'input.l3';
|
|
3
|
-
|
|
4
|
-
export type InputProps = {
|
|
5
|
-
value?: ClassValue;
|
|
6
|
-
files?: File[];
|
|
7
|
-
date?: Date | null;
|
|
8
|
-
number?: number;
|
|
9
|
-
checked?: boolean;
|
|
10
|
-
class?: string;
|
|
11
|
-
type?: HTMLInputTypeAttribute | null;
|
|
12
|
-
preset?: PresetModuleName | (string & {});
|
|
13
|
-
children?: Snippet<[]>;
|
|
14
|
-
};
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
import type { Snippet } from 'svelte';
|
|
19
|
-
import type { HTMLInputTypeAttribute } from 'svelte/elements';
|
|
20
|
-
import { on } from '../../attachments/event.svelte';
|
|
21
|
-
import { getPreset } from '../../context';
|
|
22
|
-
import { cn, toClassValue, type ClassValue } from '../../utils';
|
|
23
|
-
import type { PresetModuleName } from '../../context/preset.svelte';
|
|
24
|
-
import { InputBond } from './bond.svelte';
|
|
25
|
-
|
|
26
|
-
const bond = InputBond.get();
|
|
27
|
-
|
|
28
|
-
let {
|
|
29
|
-
value = $bindable(),
|
|
30
|
-
files = $bindable(),
|
|
31
|
-
date = $bindable(),
|
|
32
|
-
number = $bindable(),
|
|
33
|
-
checked = $bindable(),
|
|
34
|
-
class: klass = '',
|
|
35
|
-
type = 'text',
|
|
36
|
-
preset: presetKey = 'input.value',
|
|
37
|
-
onchange = undefined,
|
|
38
|
-
oninput = undefined,
|
|
39
|
-
...restProps
|
|
40
|
-
}: InputProps = $props();
|
|
41
|
-
|
|
42
|
-
const preset = getPreset(presetKey as PresetModuleName)?.apply(bond, [bond]);
|
|
43
|
-
|
|
44
|
-
const valueProps = $derived({
|
|
45
|
-
...(bond?.input?.() ?? {}),
|
|
46
|
-
...restProps
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
function handleChange(ev: CustomEvent) {
|
|
50
|
-
if (!onchange) return;
|
|
51
|
-
|
|
52
|
-
onchange?.(ev, {
|
|
53
|
-
value: value,
|
|
54
|
-
files: files,
|
|
55
|
-
date: date,
|
|
56
|
-
number: number,
|
|
57
|
-
checked: checked,
|
|
58
|
-
event: ev
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function handleInput(ev: InputEvent) {
|
|
63
|
-
if (!oninput) return;
|
|
64
|
-
|
|
65
|
-
const currentTarget = ev.currentTarget as HTMLInputElement;
|
|
66
|
-
|
|
67
|
-
if (type === 'number') {
|
|
68
|
-
number = currentTarget.valueAsNumber;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (type === 'date' || type == 'time' || type === 'datetime-local' || type === 'date-local') {
|
|
72
|
-
date = currentTarget.valueAsDate;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
oninput?.(ev, {
|
|
76
|
-
value: value,
|
|
77
|
-
files: files,
|
|
78
|
-
date: date,
|
|
79
|
-
number: number,
|
|
80
|
-
checked: checked,
|
|
81
|
-
event: ev
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
</script>
|
|
85
|
-
|
|
86
|
-
<input
|
|
87
|
-
{type}
|
|
88
|
-
bind:value={
|
|
89
|
-
() => value,
|
|
90
|
-
(v) => {
|
|
91
|
-
value = v;
|
|
92
|
-
if (bond) {
|
|
93
|
-
bond.state.props.value = v;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
class={cn(
|
|
98
|
-
'h-full w-full flex-1 bg-transparent px-2 leading-1 outline-none',
|
|
99
|
-
preset?.class,
|
|
100
|
-
toClassValue(klass, bond)
|
|
101
|
-
)}
|
|
102
|
-
onchange={handleChange}
|
|
103
|
-
oninput={handleInput}
|
|
104
|
-
{...valueProps}
|
|
105
|
-
{@attach (node) => {
|
|
106
|
-
if (type === 'file') {
|
|
107
|
-
return on('input', () => {
|
|
108
|
-
files = Array.from(node.files || []);
|
|
109
|
-
bond!.state.props.files = files;
|
|
110
|
-
})(node);
|
|
111
|
-
}
|
|
112
|
-
}}
|
|
113
|
-
/>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type InputPortals = 'input.l0' | 'input.l1' | 'input.l2' | 'input.l3';
|
|
3
|
+
|
|
4
|
+
export type InputProps = {
|
|
5
|
+
value?: ClassValue;
|
|
6
|
+
files?: File[];
|
|
7
|
+
date?: Date | null;
|
|
8
|
+
number?: number;
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
class?: string;
|
|
11
|
+
type?: HTMLInputTypeAttribute | null;
|
|
12
|
+
preset?: PresetModuleName | (string & {});
|
|
13
|
+
children?: Snippet<[]>;
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import type { Snippet } from 'svelte';
|
|
19
|
+
import type { HTMLInputTypeAttribute } from 'svelte/elements';
|
|
20
|
+
import { on } from '../../attachments/event.svelte';
|
|
21
|
+
import { getPreset } from '../../context';
|
|
22
|
+
import { cn, toClassValue, type ClassValue } from '../../utils';
|
|
23
|
+
import type { PresetModuleName } from '../../context/preset.svelte';
|
|
24
|
+
import { InputBond } from './bond.svelte';
|
|
25
|
+
|
|
26
|
+
const bond = InputBond.get();
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
value = $bindable(),
|
|
30
|
+
files = $bindable(),
|
|
31
|
+
date = $bindable(),
|
|
32
|
+
number = $bindable(),
|
|
33
|
+
checked = $bindable(),
|
|
34
|
+
class: klass = '',
|
|
35
|
+
type = 'text',
|
|
36
|
+
preset: presetKey = 'input.value',
|
|
37
|
+
onchange = undefined,
|
|
38
|
+
oninput = undefined,
|
|
39
|
+
...restProps
|
|
40
|
+
}: InputProps = $props();
|
|
41
|
+
|
|
42
|
+
const preset = getPreset(presetKey as PresetModuleName)?.apply(bond, [bond]);
|
|
43
|
+
|
|
44
|
+
const valueProps = $derived({
|
|
45
|
+
...(bond?.input?.() ?? {}),
|
|
46
|
+
...restProps
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function handleChange(ev: CustomEvent) {
|
|
50
|
+
if (!onchange) return;
|
|
51
|
+
|
|
52
|
+
onchange?.(ev, {
|
|
53
|
+
value: value,
|
|
54
|
+
files: files,
|
|
55
|
+
date: date,
|
|
56
|
+
number: number,
|
|
57
|
+
checked: checked,
|
|
58
|
+
event: ev
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function handleInput(ev: InputEvent) {
|
|
63
|
+
if (!oninput) return;
|
|
64
|
+
|
|
65
|
+
const currentTarget = ev.currentTarget as HTMLInputElement;
|
|
66
|
+
|
|
67
|
+
if (type === 'number') {
|
|
68
|
+
number = currentTarget.valueAsNumber;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (type === 'date' || type == 'time' || type === 'datetime-local' || type === 'date-local') {
|
|
72
|
+
date = currentTarget.valueAsDate;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
oninput?.(ev, {
|
|
76
|
+
value: value,
|
|
77
|
+
files: files,
|
|
78
|
+
date: date,
|
|
79
|
+
number: number,
|
|
80
|
+
checked: checked,
|
|
81
|
+
event: ev
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<input
|
|
87
|
+
{type}
|
|
88
|
+
bind:value={
|
|
89
|
+
() => value,
|
|
90
|
+
(v) => {
|
|
91
|
+
value = v;
|
|
92
|
+
if (bond) {
|
|
93
|
+
bond.state.props.value = v;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
class={cn(
|
|
98
|
+
'h-full w-full flex-1 bg-transparent px-2 leading-1 outline-none',
|
|
99
|
+
preset?.class,
|
|
100
|
+
toClassValue(klass, bond)
|
|
101
|
+
)}
|
|
102
|
+
onchange={handleChange}
|
|
103
|
+
oninput={handleInput}
|
|
104
|
+
{...valueProps}
|
|
105
|
+
{@attach (node) => {
|
|
106
|
+
if (type === 'file') {
|
|
107
|
+
return on('input', () => {
|
|
108
|
+
files = Array.from(node.files || []);
|
|
109
|
+
bond!.state.props.files = files;
|
|
110
|
+
})(node);
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
@@ -14,6 +14,6 @@ import type { Snippet } from 'svelte';
|
|
|
14
14
|
import type { HTMLInputTypeAttribute } from 'svelte/elements';
|
|
15
15
|
import { type ClassValue } from '../../utils';
|
|
16
16
|
import type { PresetModuleName } from '../../context/preset.svelte';
|
|
17
|
-
declare const InputValue: import("svelte").Component<InputProps, {}, "number" | "
|
|
17
|
+
declare const InputValue: import("svelte").Component<InputProps, {}, "number" | "value" | "date" | "checked" | "files">;
|
|
18
18
|
type InputValue = ReturnType<typeof InputValue>;
|
|
19
19
|
export default InputValue;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Input as AInput } from '.';
|
|
4
|
-
import Root from '../root/root.svelte';
|
|
5
|
-
import { Label } from '../label';
|
|
6
|
-
|
|
7
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
-
const { Story } = defineMeta({
|
|
9
|
-
title: 'Atoms/Input',
|
|
10
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
11
|
-
|
|
12
|
-
parameters: {
|
|
13
|
-
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
-
layout: 'fullscreen'
|
|
15
|
-
},
|
|
16
|
-
args: {}
|
|
17
|
-
});
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<script lang="ts">
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<Story name="Input" args={{}}>
|
|
24
|
-
<Root class="p-4">
|
|
25
|
-
<div class="flex flex-col">
|
|
26
|
-
<Label for="price-input">Price</Label>
|
|
27
|
-
<AInput.Root>
|
|
28
|
-
<AInput.Icon class="text-foreground box-content px-0">$</AInput.Icon>
|
|
29
|
-
<AInput.Value id="price-input" class="border-border box-content border-x px-2 py-2">
|
|
30
|
-
<!-- -->
|
|
31
|
-
</AInput.Value>
|
|
32
|
-
<AInput.Icon class="text-foreground box-content px-2">.00</AInput.Icon>
|
|
33
|
-
|
|
34
|
-
<AInput.Placeholder class="text-foreground/20 pl-2">Hello World</AInput.Placeholder>
|
|
35
|
-
</AInput.Root>
|
|
36
|
-
</div>
|
|
37
|
-
</Root>
|
|
38
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Input as AInput } from '.';
|
|
4
|
+
import Root from '../root/root.svelte';
|
|
5
|
+
import { Label } from '../label';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'Atoms/Input',
|
|
10
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
11
|
+
|
|
12
|
+
parameters: {
|
|
13
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
+
layout: 'fullscreen'
|
|
15
|
+
},
|
|
16
|
+
args: {}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Story name="Input" args={{}}>
|
|
24
|
+
<Root class="p-4">
|
|
25
|
+
<div class="flex flex-col">
|
|
26
|
+
<Label for="price-input">Price</Label>
|
|
27
|
+
<AInput.Root>
|
|
28
|
+
<AInput.Icon class="text-foreground box-content px-0">$</AInput.Icon>
|
|
29
|
+
<AInput.Value id="price-input" class="border-border box-content border-x px-2 py-2">
|
|
30
|
+
<!-- -->
|
|
31
|
+
</AInput.Value>
|
|
32
|
+
<AInput.Icon class="text-foreground box-content px-2">.00</AInput.Icon>
|
|
33
|
+
|
|
34
|
+
<AInput.Placeholder class="text-foreground/20 pl-2">Hello World</AInput.Placeholder>
|
|
35
|
+
</AInput.Root>
|
|
36
|
+
</div>
|
|
37
|
+
</Root>
|
|
38
|
+
</Story>
|
|
@@ -22,6 +22,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'label', B ext
|
|
|
22
22
|
bond?: import("../..").Bond;
|
|
23
23
|
base?: B | undefined;
|
|
24
24
|
preset?: import("../..").ModuleName | (string & {});
|
|
25
|
+
variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
25
26
|
} & {
|
|
26
27
|
for?: string | null;
|
|
27
28
|
children?: Snippet<[]>;
|
|
@@ -17,6 +17,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
|
|
|
17
17
|
bond?: import("../..").Bond;
|
|
18
18
|
base?: B | undefined;
|
|
19
19
|
preset?: import("../..").ModuleName | (string & {});
|
|
20
|
+
variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
20
21
|
} & HTMLAttributes<ElementType<E>>;
|
|
21
22
|
exports: {};
|
|
22
23
|
bindings: "";
|
|
@@ -17,6 +17,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
|
|
|
17
17
|
bond?: import("../..").Bond;
|
|
18
18
|
base?: B | undefined;
|
|
19
19
|
preset?: import("../..").ModuleName | (string & {});
|
|
20
|
+
variants?: import("../../utils").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
20
21
|
} & HTMLAttributes<ElementType<E>>;
|
|
21
22
|
exports: {
|
|
22
23
|
getBond: () => any;
|
|
@@ -18,6 +18,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
|
|
|
18
18
|
bond?: import("../..").Bond;
|
|
19
19
|
base?: B | undefined;
|
|
20
20
|
preset?: import("../..").ModuleName | (string & {});
|
|
21
|
+
variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
21
22
|
} & HTMLAttributes<HTMLElementTagNameMap[E]>;
|
|
22
23
|
exports: {};
|
|
23
24
|
bindings: "";
|
|
@@ -17,6 +17,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
|
|
|
17
17
|
bond?: import("../..").Bond;
|
|
18
18
|
base?: B | undefined;
|
|
19
19
|
preset?: import("../..").ModuleName | (string & {});
|
|
20
|
+
variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
20
21
|
} & HTMLAttributes<ElementType<E>>;
|
|
21
22
|
exports: {};
|
|
22
23
|
bindings: "";
|
|
@@ -24,6 +24,7 @@ declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B exten
|
|
|
24
24
|
bond?: import("../..").Bond;
|
|
25
25
|
base?: B | undefined;
|
|
26
26
|
preset?: import("../..").ModuleName | (string & {});
|
|
27
|
+
variants?: import("../../utils").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
27
28
|
} & {
|
|
28
29
|
id: RootPortals | (string & {});
|
|
29
30
|
children?: Snippet;
|
|
@@ -21,6 +21,7 @@ declare function $$render<E extends HtmlElementTagName = 'div', B extends Base =
|
|
|
21
21
|
bond?: import("../..").Bond;
|
|
22
22
|
base?: B | undefined;
|
|
23
23
|
preset?: import("../..").ModuleName | (string & {});
|
|
24
|
+
variants?: import("../..").VariantDefinition<any> | ((bond: import("../..").Bond, variantProps: Record<string, any>) => Record<string, any>);
|
|
24
25
|
} & {
|
|
25
26
|
portal?: string;
|
|
26
27
|
} & HTMLAttributes<HtmlElementType<E>>;
|