@webamoki/web-svelte 0.8.0 → 1.0.0
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 +83 -3
- package/dist/components/form/Button.svelte +24 -23
- package/dist/components/form/Button.svelte.d.ts +2 -2
- package/dist/components/form/Errors.svelte +13 -13
- package/dist/components/form/FieldWrapper.svelte +57 -55
- package/dist/components/form/FieldWrapper.svelte.d.ts +4 -4
- package/dist/components/form/Form.svelte +18 -14
- package/dist/components/form/Form.svelte.d.ts +31 -22
- package/dist/components/form/IconInputWrapper.svelte +30 -29
- package/dist/components/form/IconInputWrapper.svelte.d.ts +7 -7
- package/dist/components/form/fields/ChoiceField.svelte +45 -43
- package/dist/components/form/fields/ChoiceField.svelte.d.ts +28 -23
- package/dist/components/form/fields/ChoiceMultiField.svelte +44 -42
- package/dist/components/form/fields/ChoiceMultiField.svelte.d.ts +28 -23
- package/dist/components/form/fields/DateField.svelte +42 -40
- package/dist/components/form/fields/DateField.svelte.d.ts +29 -22
- package/dist/components/form/fields/HexColorField.svelte +21 -19
- package/dist/components/form/fields/HexColorField.svelte.d.ts +24 -19
- package/dist/components/form/fields/MessageField.svelte +39 -60
- package/dist/components/form/fields/MessageField.svelte.d.ts +33 -24
- package/dist/components/form/fields/NumberField.svelte +38 -36
- package/dist/components/form/fields/NumberField.svelte.d.ts +32 -23
- package/dist/components/form/fields/PasswordField.svelte +45 -39
- package/dist/components/form/fields/PasswordField.svelte.d.ts +28 -21
- package/dist/components/form/fields/SelectField.svelte +84 -79
- package/dist/components/form/fields/SelectField.svelte.d.ts +39 -26
- package/dist/components/form/fields/SelectMultiField.svelte +90 -85
- package/dist/components/form/fields/SelectMultiField.svelte.d.ts +38 -25
- package/dist/components/form/fields/TextField.svelte +31 -29
- package/dist/components/form/fields/TextField.svelte.d.ts +32 -23
- package/dist/components/form/fields/TextFieldNullable.svelte +49 -47
- package/dist/components/form/fields/TextFieldNullable.svelte.d.ts +32 -23
- package/dist/components/form/fields/TimeField.svelte +66 -64
- package/dist/components/form/fields/TimeField.svelte.d.ts +33 -24
- package/dist/components/form/fields/WeekdayChoiceField.svelte +37 -35
- package/dist/components/form/fields/WeekdayChoiceField.svelte.d.ts +27 -22
- package/dist/components/form/fields/WeekdayChoiceMultiField.svelte +37 -35
- package/dist/components/form/fields/WeekdayChoiceMultiField.svelte.d.ts +27 -22
- package/dist/components/showcase/CodeBlock.svelte +41 -41
- package/dist/components/showcase/Container.svelte +7 -7
- package/dist/components/showcase/Preview.svelte +4 -4
- package/dist/components/showcase/Sidebar.svelte +4 -4
- package/dist/components/showcase/SidebarLink.svelte +3 -3
- package/dist/components/ui/choice/Choice.svelte +25 -25
- package/dist/components/ui/choice/Choice.svelte.d.ts +7 -7
- package/dist/components/ui/choice/ChoiceInternal.svelte +73 -72
- package/dist/components/ui/choice/ChoiceInternal.svelte.d.ts +9 -9
- package/dist/components/ui/choice/ChoiceMulti.svelte +59 -56
- package/dist/components/ui/choice/ChoiceMulti.svelte.d.ts +7 -7
- package/dist/components/ui/choice/WeekdayChoice.svelte +22 -21
- package/dist/components/ui/choice/WeekdayChoice.svelte.d.ts +6 -6
- package/dist/components/ui/choice/WeekdayChoiceMulti.svelte +24 -22
- package/dist/components/ui/choice/WeekdayChoiceMulti.svelte.d.ts +6 -6
- package/dist/components/ui/context-menu/ContextMenu.svelte +51 -50
- package/dist/components/ui/context-menu/ContextMenu.svelte.d.ts +1 -1
- package/dist/components/ui/context-menu/ContextMenuContent.svelte +92 -91
- package/dist/components/ui/context-menu/ContextMenuItem.svelte +26 -25
- package/dist/components/ui/context-menu/ContextMenuItem.svelte.d.ts +1 -1
- package/dist/components/ui/context-menu/ContextMenuTrigger.svelte +16 -15
- package/dist/components/ui/context-menu/context-menu-state.svelte.d.ts +3 -3
- package/dist/components/ui/context-menu/context-menu-state.svelte.js +15 -15
- package/dist/components/ui/drag-drop/Draggable.svelte +73 -72
- package/dist/components/ui/drag-drop/Draggable.svelte.d.ts +2 -2
- package/dist/components/ui/drag-drop/Dropzone.svelte +56 -54
- package/dist/components/ui/drag-drop/Dropzone.svelte.d.ts +3 -3
- package/dist/components/ui/drag-drop/drag-manager.d.ts +2 -2
- package/dist/components/ui/drag-drop/drag-manager.js +9 -9
- package/dist/components/ui/index.d.ts +2 -2
- package/dist/components/ui/index.js +5 -5
- package/dist/components/ui/search/SearchBar.svelte +18 -18
- package/dist/components/ui/search/SearchBar.svelte.d.ts +2 -2
- package/dist/highlight.js +2 -2
- package/dist/server/form-handler.d.ts +12 -12
- package/dist/server/form-handler.js +17 -17
- package/dist/server/form-processor.d.ts +1 -1
- package/dist/server/form-processor.js +0 -1
- package/dist/shadcn/components/ui/button/button.svelte +72 -71
- package/dist/shadcn/components/ui/button/button.svelte.d.ts +23 -23
- package/dist/shadcn/components/ui/button/index.d.ts +1 -1
- package/dist/shadcn/components/ui/button/index.js +2 -2
- package/dist/shadcn/components/ui/input/index.d.ts +1 -1
- package/dist/shadcn/components/ui/input/index.js +2 -2
- package/dist/shadcn/components/ui/input/input.svelte +35 -32
- package/dist/shadcn/components/ui/input/input.svelte.d.ts +2 -2
- package/dist/shadcn/components/ui/select/index.d.ts +6 -6
- package/dist/shadcn/components/ui/select/index.js +7 -7
- package/dist/shadcn/components/ui/select/select-content.svelte +35 -34
- package/dist/shadcn/components/ui/select/select-content.svelte.d.ts +1 -1
- package/dist/shadcn/components/ui/select/select-group-heading.svelte +15 -14
- package/dist/shadcn/components/ui/select/select-group.svelte +2 -2
- package/dist/shadcn/components/ui/select/select-item.svelte +31 -31
- package/dist/shadcn/components/ui/select/select-label.svelte +14 -13
- package/dist/shadcn/components/ui/select/select-label.svelte.d.ts +1 -1
- package/dist/shadcn/components/ui/select/select-scroll-down-button.svelte +13 -13
- package/dist/shadcn/components/ui/select/select-scroll-up-button.svelte +13 -13
- package/dist/shadcn/components/ui/select/select-separator.svelte +13 -12
- package/dist/shadcn/components/ui/select/select-trigger.svelte +26 -26
- package/dist/shadcn/components/ui/select/select-trigger.svelte.d.ts +2 -2
- package/dist/shadcn/components/ui/separator/separator.svelte +14 -14
- package/dist/shadcn/components/ui/textarea/textarea.svelte +22 -21
- package/dist/shadcn/components/ui/textarea/textarea.svelte.d.ts +1 -1
- package/dist/shadcn/utils.d.ts +4 -4
- package/dist/utils/datetime/index.d.ts +66 -66
- package/dist/utils/datetime/index.js +124 -124
- package/dist/utils/email/README.md +60 -60
- package/dist/utils/email/aws-signer.d.ts +1 -1
- package/dist/utils/email/aws-signer.js +39 -39
- package/dist/utils/email/ses.d.ts +8 -8
- package/dist/utils/email/ses.js +9 -9
- package/dist/utils/form/index.d.ts +11 -11
- package/dist/utils/form/index.js +23 -24
- package/dist/utils/form/virtual-form.d.ts +5 -5
- package/dist/utils/form/virtual-form.js +58 -58
- package/dist/utils/search.d.ts +1 -1
- package/dist/utils/search.js +22 -22
- package/dist/utils/types/arktype.d.ts +2 -2
- package/dist/utils/types/arktype.js +3 -3
- package/dist/utils/types/db.d.ts +2 -1
- package/dist/utils/types/db.js +7 -7
- package/package.json +46 -31
|
@@ -1,96 +1,101 @@
|
|
|
1
1
|
<script
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
generics="I,V, K extends number | string,T extends Record<string, unknown>, U extends FormPath<T>, M"
|
|
3
|
+
lang="ts"
|
|
4
4
|
>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Select,
|
|
8
|
-
SelectContent,
|
|
9
|
-
SelectGroup,
|
|
10
|
-
SelectItem,
|
|
11
|
-
SelectLabel,
|
|
12
|
-
SelectTrigger
|
|
13
|
-
} from '../../../shadcn/components/ui/select/index.js';
|
|
14
|
-
import { cn } from '../../../shadcn/utils.js';
|
|
15
|
-
import type { Component } from 'svelte';
|
|
16
|
-
import type { FormPath } from 'sveltekit-superforms';
|
|
17
|
-
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
5
|
+
import type { Component } from 'svelte';
|
|
6
|
+
import type { FormPath } from 'sveltekit-superforms';
|
|
18
7
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
let {
|
|
31
|
-
values = $bindable([]),
|
|
32
|
-
class: className,
|
|
33
|
-
getKey: _getKey,
|
|
34
|
-
getLabel,
|
|
35
|
-
getValue,
|
|
36
|
-
onchange,
|
|
37
|
-
placeholder,
|
|
38
|
-
items,
|
|
39
|
-
icon,
|
|
40
|
-
...fieldProps
|
|
41
|
-
}: Props = $props();
|
|
42
|
-
let valueToItem: Map<V, I> = new Map(items.map((item) => [getValue(item), item] as const));
|
|
43
|
-
let keyToItem: Map<string, I> = new Map(items.map((item) => [getKey(item), item] as const));
|
|
8
|
+
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
9
|
+
import {
|
|
10
|
+
Select,
|
|
11
|
+
SelectContent,
|
|
12
|
+
SelectGroup,
|
|
13
|
+
SelectItem,
|
|
14
|
+
SelectLabel,
|
|
15
|
+
SelectTrigger
|
|
16
|
+
} from '../../../shadcn/components/ui/select/index.js';
|
|
17
|
+
import { cn } from '../../../shadcn/utils.js';
|
|
44
18
|
|
|
45
|
-
|
|
46
|
-
function getKey(item: I) {
|
|
47
|
-
const key = _getKey(item);
|
|
48
|
-
return key.toString();
|
|
49
|
-
}
|
|
19
|
+
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
50
20
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
21
|
+
interface Props extends FieldWrapperProps<T, U, M> {
|
|
22
|
+
class?: string;
|
|
23
|
+
getKey: (item: I) => K;
|
|
24
|
+
getLabel: (item: I) => string;
|
|
25
|
+
getValue: (item: I) => V;
|
|
26
|
+
icon?: Component;
|
|
27
|
+
items: readonly I[];
|
|
28
|
+
onchange?: (value: V[]) => void;
|
|
29
|
+
placeholder: string;
|
|
30
|
+
values?: V[];
|
|
31
|
+
}
|
|
32
|
+
let {
|
|
33
|
+
class: className,
|
|
34
|
+
getKey: _getKey,
|
|
35
|
+
getLabel,
|
|
36
|
+
getValue,
|
|
37
|
+
icon,
|
|
38
|
+
items,
|
|
39
|
+
onchange,
|
|
40
|
+
placeholder,
|
|
41
|
+
values = $bindable([]),
|
|
42
|
+
...fieldProps
|
|
43
|
+
}: Props = $props();
|
|
44
|
+
// Items property shouldn't be updated, ignore warning
|
|
45
|
+
// svelte-ignore state_referenced_locally
|
|
46
|
+
let valueToItem: Map<V, I> = new Map(items.map((item) => [getValue(item), item] as const));
|
|
47
|
+
// svelte-ignore state_referenced_locally
|
|
48
|
+
let keyToItem: Map<string, I> = new Map(items.map((item) => [getKey(item), item] as const));
|
|
57
49
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
values = newValues;
|
|
64
|
-
onchange?.(newValues);
|
|
65
|
-
}
|
|
50
|
+
// Enforce string key function
|
|
51
|
+
function getKey(item: I) {
|
|
52
|
+
const key = _getKey(item);
|
|
53
|
+
return key.toString();
|
|
54
|
+
}
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
function getKeyFromValue(): string[] {
|
|
57
|
+
return values.map((value) => {
|
|
58
|
+
const item = valueToItem.get(value)!;
|
|
59
|
+
return getKey(item)!;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function setValueFromKey(keys: string[]) {
|
|
64
|
+
const newValues: V[] = keys
|
|
65
|
+
.map((key) => keyToItem.get(key))
|
|
66
|
+
.filter((item): item is I => item !== undefined) // filter out missing keys
|
|
67
|
+
.map((item) => getValue(item));
|
|
68
|
+
values = newValues;
|
|
69
|
+
onchange?.(newValues);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getPreview() {
|
|
73
|
+
return values.length
|
|
74
|
+
? values.map((value) => getLabel(valueToItem.get(value)!)).join(', ')
|
|
75
|
+
: placeholder;
|
|
76
|
+
}
|
|
72
77
|
</script>
|
|
73
78
|
|
|
74
79
|
<FieldWrapper {...fieldProps}>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
{#snippet formElem(props)}
|
|
81
|
+
<Select type="multiple" {...props} bind:value={getKeyFromValue, setValueFromKey}>
|
|
82
|
+
<IconInputWrapper {icon}>
|
|
83
|
+
{#snippet children({ class: iconClass })}
|
|
84
|
+
<SelectTrigger class={cn('w-full cursor-pointer truncate', iconClass, className)}>
|
|
85
|
+
<span class="block truncate">
|
|
86
|
+
{getPreview()}
|
|
87
|
+
</span>
|
|
88
|
+
</SelectTrigger>
|
|
89
|
+
{/snippet}
|
|
90
|
+
</IconInputWrapper>
|
|
91
|
+
<SelectContent>
|
|
92
|
+
<SelectGroup>
|
|
93
|
+
<SelectLabel>{fieldProps.label}</SelectLabel>
|
|
94
|
+
{#each items as item (getKey(item))}
|
|
95
|
+
<SelectItem class="cursor-pointer" label={getLabel(item)} value={getKey(item)} />
|
|
96
|
+
{/each}
|
|
97
|
+
</SelectGroup>
|
|
98
|
+
</SelectContent>
|
|
99
|
+
</Select>
|
|
100
|
+
{/snippet}
|
|
96
101
|
</FieldWrapper>
|
|
@@ -1,37 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export default SelectMultiField;
|
|
2
|
+
type SelectMultiField<I, V, K extends number | string, T extends Record<string, unknown>, U extends FormPath<T>, M> = SvelteComponent<Props, {}, {}> & {
|
|
3
|
+
$$bindings?: "values" | undefined;
|
|
4
|
+
} & {};
|
|
5
|
+
declare const SelectMultiField: $$IsomorphicComponent;
|
|
6
|
+
import { FormPath } from 'sveltekit-superforms';
|
|
7
|
+
type Props = FieldWrapperProps<T, U, M> & {
|
|
8
|
+
class?: string | undefined;
|
|
9
|
+
getKey: (item: I) => K;
|
|
10
|
+
getLabel: (item: I) => string;
|
|
11
|
+
getValue: (item: I) => V;
|
|
12
|
+
icon?: Component<any, any, string> | undefined;
|
|
13
|
+
items: readonly I[];
|
|
14
|
+
onchange?: ((value: V[]) => void) | undefined;
|
|
15
|
+
placeholder: string;
|
|
16
|
+
values?: V[] | undefined;
|
|
17
|
+
};
|
|
18
|
+
interface $$IsomorphicComponent {
|
|
19
|
+
new <I, V, K extends number | string, T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import("svelte").ComponentConstructorOptions<ReturnType<__sveltets_Render<I, V, K, T, U, M>["props"]>>): import("svelte").SvelteComponent<ReturnType<__sveltets_Render<I, V, K, T, U, M>["props"]>, ReturnType<__sveltets_Render<I, V, K, T, U, M>["events"]>, ReturnType<__sveltets_Render<I, V, K, T, U, M>["slots"]>> & {
|
|
20
|
+
$$bindings?: ReturnType<__sveltets_Render<I, V, K, T, U, M>["bindings"]>;
|
|
21
|
+
} & ReturnType<__sveltets_Render<I, V, K, T, U, M>["exports"]>;
|
|
22
|
+
<I, V, K extends number | string, T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<I, V, K, T, U, M>["props"]> & {}): ReturnType<__sveltets_Render<I, V, K, T, U, M>["exports"]>;
|
|
23
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any, any, any, any>["bindings"]>;
|
|
24
|
+
}
|
|
25
|
+
declare class __sveltets_Render<I, V, K extends number | string, T extends Record<string, unknown>, U extends FormPath<T>, M> {
|
|
26
|
+
props(): ReturnType<typeof $$render<I, V, K, T, U, M>>["props"];
|
|
27
|
+
events(): ReturnType<typeof $$render<I, V, K, T, U, M>>["events"];
|
|
28
|
+
slots(): ReturnType<typeof $$render<I, V, K, T, U, M>>["slots"];
|
|
29
|
+
bindings(): "values";
|
|
30
|
+
exports(): {};
|
|
31
|
+
}
|
|
32
|
+
declare function $$render<I, V, K extends number | string, T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
|
|
5
33
|
props: FieldWrapperProps<T, U, M> & {
|
|
6
|
-
|
|
7
|
-
items: readonly I[];
|
|
34
|
+
class?: string;
|
|
8
35
|
getKey: (item: I) => K;
|
|
9
36
|
getLabel: (item: I) => string;
|
|
10
37
|
getValue: (item: I) => V;
|
|
38
|
+
icon?: Component;
|
|
39
|
+
items: readonly I[];
|
|
11
40
|
onchange?: (value: V[]) => void;
|
|
12
|
-
class?: string;
|
|
13
41
|
placeholder: string;
|
|
14
|
-
|
|
42
|
+
values?: V[];
|
|
15
43
|
};
|
|
16
44
|
exports: {};
|
|
17
45
|
bindings: "values";
|
|
18
46
|
slots: {};
|
|
19
47
|
events: {};
|
|
20
48
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
events(): ReturnType<typeof $$render<I, V, K, T, U, M>>['events'];
|
|
24
|
-
slots(): ReturnType<typeof $$render<I, V, K, T, U, M>>['slots'];
|
|
25
|
-
bindings(): "values";
|
|
26
|
-
exports(): {};
|
|
27
|
-
}
|
|
28
|
-
interface $$IsomorphicComponent {
|
|
29
|
-
new <I, V, K extends string | number, T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<I, V, K, T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<I, V, K, T, U, M>['props']>, ReturnType<__sveltets_Render<I, V, K, T, U, M>['events']>, ReturnType<__sveltets_Render<I, V, K, T, U, M>['slots']>> & {
|
|
30
|
-
$$bindings?: ReturnType<__sveltets_Render<I, V, K, T, U, M>['bindings']>;
|
|
31
|
-
} & ReturnType<__sveltets_Render<I, V, K, T, U, M>['exports']>;
|
|
32
|
-
<I, V, K extends string | number, T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<I, V, K, T, U, M>['props']> & {}): ReturnType<__sveltets_Render<I, V, K, T, U, M>['exports']>;
|
|
33
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any, any, any, any>['bindings']>;
|
|
34
|
-
}
|
|
35
|
-
declare const SelectMultiField: $$IsomorphicComponent;
|
|
36
|
-
type SelectMultiField<I, V, K extends string | number, T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof SelectMultiField<I, V, K, T, U, M>>;
|
|
37
|
-
export default SelectMultiField;
|
|
49
|
+
import { FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
50
|
+
import { Component } from 'svelte';
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { cn } from '../../../shadcn/utils.js';
|
|
5
|
-
import type { Component } from 'svelte';
|
|
6
|
-
import type { FormPath } from 'sveltekit-superforms';
|
|
7
|
-
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
1
|
+
<script generics="T extends Record<string, unknown>, U extends FormPath<T>, M" lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { FormPath } from 'sveltekit-superforms';
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
6
|
+
import { Input } from '../../../shadcn/components/ui/input/index.js';
|
|
7
|
+
import { cn } from '../../../shadcn/utils.js';
|
|
8
|
+
|
|
9
|
+
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
10
|
+
|
|
11
|
+
interface Props extends FieldWrapperProps<T, U, M> {
|
|
12
|
+
class?: string;
|
|
13
|
+
icon?: Component;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
type?: HTMLInputElement['type'];
|
|
16
|
+
value?: string;
|
|
17
|
+
}
|
|
18
|
+
let {
|
|
19
|
+
class: className,
|
|
20
|
+
icon,
|
|
21
|
+
placeholder,
|
|
22
|
+
type = 'text',
|
|
23
|
+
value = $bindable(),
|
|
24
|
+
...fieldProps
|
|
25
|
+
}: Props = $props();
|
|
24
26
|
</script>
|
|
25
27
|
|
|
26
28
|
<FieldWrapper {...fieldProps}>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
{#snippet formElem(props)}
|
|
30
|
+
<IconInputWrapper {icon}>
|
|
31
|
+
{#snippet children({ class: iconClass })}
|
|
32
|
+
<Input class={cn(iconClass, className)} {placeholder} {type} bind:value {...props} />
|
|
33
|
+
{/snippet}
|
|
34
|
+
</IconInputWrapper>
|
|
35
|
+
{/snippet}
|
|
34
36
|
</FieldWrapper>
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default TextField;
|
|
2
|
+
type TextField<T extends Record<string, unknown>, U extends FormPath<T>, M> = SvelteComponent<Props, {}, {}> & {
|
|
3
|
+
$$bindings?: "value" | undefined;
|
|
4
|
+
} & {};
|
|
5
|
+
declare const TextField: $$IsomorphicComponent;
|
|
6
|
+
import { FormPath } from 'sveltekit-superforms';
|
|
7
|
+
type Props = FieldWrapperProps<T, U, M> & {
|
|
8
|
+
class?: string | undefined;
|
|
9
|
+
icon?: Component<any, any, string> | undefined;
|
|
10
|
+
placeholder?: string | undefined;
|
|
11
|
+
type?: string | undefined;
|
|
12
|
+
value?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
interface $$IsomorphicComponent {
|
|
15
|
+
new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import("svelte").ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>["props"]>>): import("svelte").SvelteComponent<ReturnType<__sveltets_Render<T, U, M>["props"]>, ReturnType<__sveltets_Render<T, U, M>["events"]>, ReturnType<__sveltets_Render<T, U, M>["slots"]>> & {
|
|
16
|
+
$$bindings?: ReturnType<__sveltets_Render<T, U, M>["bindings"]>;
|
|
17
|
+
} & ReturnType<__sveltets_Render<T, U, M>["exports"]>;
|
|
18
|
+
<T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>["props"]> & {}): ReturnType<__sveltets_Render<T, U, M>["exports"]>;
|
|
19
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>["bindings"]>;
|
|
20
|
+
}
|
|
21
|
+
declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>, M> {
|
|
22
|
+
props(): ReturnType<typeof $$render<T, U, M>>["props"];
|
|
23
|
+
events(): ReturnType<typeof $$render<T, U, M>>["events"];
|
|
24
|
+
slots(): ReturnType<typeof $$render<T, U, M>>["slots"];
|
|
25
|
+
bindings(): "value";
|
|
26
|
+
exports(): {};
|
|
27
|
+
}
|
|
4
28
|
declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
|
|
5
29
|
props: FieldWrapperProps<T, U, M> & {
|
|
6
|
-
value?: string;
|
|
7
|
-
type?: HTMLInputElement["type"];
|
|
8
30
|
class?: string;
|
|
9
|
-
placeholder?: string;
|
|
10
31
|
icon?: Component;
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
type?: HTMLInputElement["type"];
|
|
34
|
+
value?: string;
|
|
11
35
|
};
|
|
12
36
|
exports: {};
|
|
13
37
|
bindings: "value";
|
|
14
38
|
slots: {};
|
|
15
39
|
events: {};
|
|
16
40
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
events(): ReturnType<typeof $$render<T, U, M>>['events'];
|
|
20
|
-
slots(): ReturnType<typeof $$render<T, U, M>>['slots'];
|
|
21
|
-
bindings(): "value";
|
|
22
|
-
exports(): {};
|
|
23
|
-
}
|
|
24
|
-
interface $$IsomorphicComponent {
|
|
25
|
-
new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, U, M>['props']>, ReturnType<__sveltets_Render<T, U, M>['events']>, ReturnType<__sveltets_Render<T, U, M>['slots']>> & {
|
|
26
|
-
$$bindings?: ReturnType<__sveltets_Render<T, U, M>['bindings']>;
|
|
27
|
-
} & ReturnType<__sveltets_Render<T, U, M>['exports']>;
|
|
28
|
-
<T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>['props']> & {}): ReturnType<__sveltets_Render<T, U, M>['exports']>;
|
|
29
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
|
|
30
|
-
}
|
|
31
|
-
declare const TextField: $$IsomorphicComponent;
|
|
32
|
-
type TextField<T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof TextField<T, U, M>>;
|
|
33
|
-
export default TextField;
|
|
41
|
+
import { FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
42
|
+
import { Component } from 'svelte';
|
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { Component } from 'svelte';
|
|
5
|
-
import type { FormPath } from 'sveltekit-superforms';
|
|
6
|
-
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
1
|
+
<script generics="T extends Record<string, unknown>, U extends FormPath<T>, M" lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { FormPath } from 'sveltekit-superforms';
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type?: HTMLInputElement['type'];
|
|
11
|
-
class?: string;
|
|
12
|
-
placeholder?: string;
|
|
13
|
-
icon?: Component;
|
|
14
|
-
}
|
|
15
|
-
let {
|
|
16
|
-
value = $bindable(),
|
|
17
|
-
type = 'text',
|
|
18
|
-
class: className,
|
|
19
|
-
placeholder,
|
|
20
|
-
icon,
|
|
21
|
-
...fieldProps
|
|
22
|
-
}: Props = $props();
|
|
5
|
+
import { Input } from '../../../shadcn/components/ui/input/index.js';
|
|
6
|
+
import { cn } from '../../../shadcn/utils.js';
|
|
23
7
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
9
|
+
|
|
10
|
+
interface Props extends FieldWrapperProps<T, U, M> {
|
|
11
|
+
class?: string;
|
|
12
|
+
icon?: Component;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
type?: HTMLInputElement['type'];
|
|
15
|
+
value?: null | string;
|
|
16
|
+
}
|
|
17
|
+
let {
|
|
18
|
+
class: className,
|
|
19
|
+
icon,
|
|
20
|
+
placeholder,
|
|
21
|
+
type = 'text',
|
|
22
|
+
value = $bindable(),
|
|
23
|
+
...fieldProps
|
|
24
|
+
}: Props = $props();
|
|
25
|
+
|
|
26
|
+
function get() {
|
|
27
|
+
if (!value) return '';
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
function set(raw: string | undefined) {
|
|
31
|
+
value = raw || null;
|
|
32
|
+
}
|
|
31
33
|
</script>
|
|
32
34
|
|
|
33
35
|
<FieldWrapper {...fieldProps}>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
{#snippet formElem(props)}
|
|
37
|
+
{#if icon}
|
|
38
|
+
{@const Icon = icon}
|
|
39
|
+
<div class="relative">
|
|
40
|
+
<div class="pointer-events-none absolute top-1/2 left-4 -translate-y-1/2 text-gray-500">
|
|
41
|
+
<Icon class="size-5" />
|
|
42
|
+
</div>
|
|
43
|
+
<Input
|
|
44
|
+
class={cn('pl-12', className)}
|
|
45
|
+
{placeholder}
|
|
46
|
+
{type}
|
|
47
|
+
bind:value={get, set}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
{:else}
|
|
52
|
+
<Input class={className} {placeholder} {type} bind:value={get, set} {...props} />
|
|
53
|
+
{/if}
|
|
54
|
+
{/snippet}
|
|
53
55
|
</FieldWrapper>
|
|
@@ -1,33 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default TextFieldNullable;
|
|
2
|
+
type TextFieldNullable<T extends Record<string, unknown>, U extends FormPath<T>, M> = SvelteComponent<Props, {}, {}> & {
|
|
3
|
+
$$bindings?: "value" | undefined;
|
|
4
|
+
} & {};
|
|
5
|
+
declare const TextFieldNullable: $$IsomorphicComponent;
|
|
6
|
+
import { FormPath } from 'sveltekit-superforms';
|
|
7
|
+
type Props = FieldWrapperProps<T, U, M> & {
|
|
8
|
+
class?: string | undefined;
|
|
9
|
+
icon?: Component<any, any, string> | undefined;
|
|
10
|
+
placeholder?: string | undefined;
|
|
11
|
+
type?: string | undefined;
|
|
12
|
+
value?: string | null | undefined;
|
|
13
|
+
};
|
|
14
|
+
interface $$IsomorphicComponent {
|
|
15
|
+
new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import("svelte").ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>["props"]>>): import("svelte").SvelteComponent<ReturnType<__sveltets_Render<T, U, M>["props"]>, ReturnType<__sveltets_Render<T, U, M>["events"]>, ReturnType<__sveltets_Render<T, U, M>["slots"]>> & {
|
|
16
|
+
$$bindings?: ReturnType<__sveltets_Render<T, U, M>["bindings"]>;
|
|
17
|
+
} & ReturnType<__sveltets_Render<T, U, M>["exports"]>;
|
|
18
|
+
<T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>["props"]> & {}): ReturnType<__sveltets_Render<T, U, M>["exports"]>;
|
|
19
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>["bindings"]>;
|
|
20
|
+
}
|
|
21
|
+
declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>, M> {
|
|
22
|
+
props(): ReturnType<typeof $$render<T, U, M>>["props"];
|
|
23
|
+
events(): ReturnType<typeof $$render<T, U, M>>["events"];
|
|
24
|
+
slots(): ReturnType<typeof $$render<T, U, M>>["slots"];
|
|
25
|
+
bindings(): "value";
|
|
26
|
+
exports(): {};
|
|
27
|
+
}
|
|
4
28
|
declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
|
|
5
29
|
props: FieldWrapperProps<T, U, M> & {
|
|
6
|
-
value?: string | null;
|
|
7
|
-
type?: HTMLInputElement["type"];
|
|
8
30
|
class?: string;
|
|
9
|
-
placeholder?: string;
|
|
10
31
|
icon?: Component;
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
type?: HTMLInputElement["type"];
|
|
34
|
+
value?: null | string;
|
|
11
35
|
};
|
|
12
36
|
exports: {};
|
|
13
37
|
bindings: "value";
|
|
14
38
|
slots: {};
|
|
15
39
|
events: {};
|
|
16
40
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
events(): ReturnType<typeof $$render<T, U, M>>['events'];
|
|
20
|
-
slots(): ReturnType<typeof $$render<T, U, M>>['slots'];
|
|
21
|
-
bindings(): "value";
|
|
22
|
-
exports(): {};
|
|
23
|
-
}
|
|
24
|
-
interface $$IsomorphicComponent {
|
|
25
|
-
new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, U, M>['props']>, ReturnType<__sveltets_Render<T, U, M>['events']>, ReturnType<__sveltets_Render<T, U, M>['slots']>> & {
|
|
26
|
-
$$bindings?: ReturnType<__sveltets_Render<T, U, M>['bindings']>;
|
|
27
|
-
} & ReturnType<__sveltets_Render<T, U, M>['exports']>;
|
|
28
|
-
<T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>['props']> & {}): ReturnType<__sveltets_Render<T, U, M>['exports']>;
|
|
29
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
|
|
30
|
-
}
|
|
31
|
-
declare const TextFieldNullable: $$IsomorphicComponent;
|
|
32
|
-
type TextFieldNullable<T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof TextFieldNullable<T, U, M>>;
|
|
33
|
-
export default TextFieldNullable;
|
|
41
|
+
import { FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
42
|
+
import { Component } from 'svelte';
|