@r2digisolutions/ui 0.14.1 → 0.15.1
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/index.d.ts +2 -1
- package/dist/components/index.js +2 -1
- package/dist/components/ui/Input/Input.svelte +29 -0
- package/dist/components/ui/Input/Input.svelte.d.ts +4 -0
- package/dist/components/ui/Input/type.d.ts +67 -0
- package/dist/components/ui/Input/type.js +1 -0
- package/dist/components/ui/Label/Label.svelte +1 -1
- package/dist/components/ui/Label/Label.svelte.d.ts +1 -1
- package/package.json +1 -1
|
@@ -14,4 +14,5 @@ import Button from './ui/Button/Button.svelte';
|
|
|
14
14
|
import Heading from './ui/Heading/Heading.svelte';
|
|
15
15
|
import Label from './ui/Label/Label.svelte';
|
|
16
16
|
import Field from './ui/Field/Field.svelte';
|
|
17
|
-
|
|
17
|
+
import Input from './ui/Input/Input.svelte';
|
|
18
|
+
export { Alert, Avatar, Button, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Container, Field, Section, Loading, TableList, Heading, Label, Input };
|
package/dist/components/index.js
CHANGED
|
@@ -14,4 +14,5 @@ import Button from './ui/Button/Button.svelte';
|
|
|
14
14
|
import Heading from './ui/Heading/Heading.svelte';
|
|
15
15
|
import Label from './ui/Label/Label.svelte';
|
|
16
16
|
import Field from './ui/Field/Field.svelte';
|
|
17
|
-
|
|
17
|
+
import Input from './ui/Input/Input.svelte';
|
|
18
|
+
export { Alert, Avatar, Button, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Container, Field, Section, Loading, TableList, Heading, Label, Input };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IFileInputProps, Props } from './type.js';
|
|
3
|
+
|
|
4
|
+
const { onchange, type = 'text', ...props }: Props = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<input
|
|
8
|
+
{...props}
|
|
9
|
+
onchange={(e) => {
|
|
10
|
+
const value = e.currentTarget.value;
|
|
11
|
+
|
|
12
|
+
if (type === 'number') {
|
|
13
|
+
const parsed = value.trim() === '' ? null : Number(value);
|
|
14
|
+
(onchange as (value: number | null, e: Event) => void)?.(parsed, e);
|
|
15
|
+
} else if (type === 'file') {
|
|
16
|
+
const inputEl = e.currentTarget as HTMLInputElement;
|
|
17
|
+
const files = inputEl.files;
|
|
18
|
+
|
|
19
|
+
const fileValue = (props as IFileInputProps).multiple
|
|
20
|
+
? Array.from(files ?? [])
|
|
21
|
+
: (files?.[0] ?? null);
|
|
22
|
+
|
|
23
|
+
(onchange as (value: File | File[] | null, e: Event) => void)?.(fileValue, e);
|
|
24
|
+
} else {
|
|
25
|
+
(onchange as (value: string | null, e: Event) => void)?.(value || null, e);
|
|
26
|
+
}
|
|
27
|
+
}}
|
|
28
|
+
class="block w-full rounded-lg border border-gray-300 py-3 pr-3 pl-10 transition-colors focus:border-transparent focus:ring-2 focus:ring-purple-500"
|
|
29
|
+
/>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ClassValue } from "svelte/elements";
|
|
2
|
+
export type Type = 'email' | 'password' | 'text' | 'tel' | 'number' | 'time' | 'url' | 'search' | 'date' | 'datetime-local' | 'color' | 'file';
|
|
3
|
+
interface Base<TValue = unknown> {
|
|
4
|
+
autocomplete?: 'on' | 'off';
|
|
5
|
+
name?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
class?: ClassValue;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
autofocus?: boolean;
|
|
11
|
+
value?: TValue;
|
|
12
|
+
onchange?: (value: TValue, e: Event) => void;
|
|
13
|
+
onkeydown?: (e: KeyboardEvent) => void;
|
|
14
|
+
onkeyup?: (e: KeyboardEvent) => void;
|
|
15
|
+
onclick?: (e: MouseEvent) => void;
|
|
16
|
+
onfocus?: (e: FocusEvent) => void;
|
|
17
|
+
onblur?: (e: FocusEvent) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface ITextInputProps extends Base<string | null> {
|
|
20
|
+
type: 'text';
|
|
21
|
+
minlength?: number;
|
|
22
|
+
maxlength?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface IUrlInputProps extends Base<string | null> {
|
|
25
|
+
type: 'url' | 'search';
|
|
26
|
+
}
|
|
27
|
+
export interface IEmailInputProps extends Base<string | null> {
|
|
28
|
+
type: 'email';
|
|
29
|
+
}
|
|
30
|
+
export interface IPasswordInputProps extends Base<string | null> {
|
|
31
|
+
type: 'password';
|
|
32
|
+
}
|
|
33
|
+
export interface INumberInputProps extends Base<number | null> {
|
|
34
|
+
type: 'number';
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
step?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface ITelInputProps extends Base<string | null> {
|
|
40
|
+
type: 'tel';
|
|
41
|
+
}
|
|
42
|
+
export interface ITimeInputProps extends Base<string | null> {
|
|
43
|
+
type: 'time';
|
|
44
|
+
}
|
|
45
|
+
export interface IFileInputProps extends Base<File | null> {
|
|
46
|
+
type: 'file';
|
|
47
|
+
accept?: string;
|
|
48
|
+
multiple?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface IDateInputProps extends Base<string | null> {
|
|
51
|
+
type: 'date' | 'datetime-local';
|
|
52
|
+
}
|
|
53
|
+
export interface IColorInputProps extends Base<string | null> {
|
|
54
|
+
type: 'color';
|
|
55
|
+
}
|
|
56
|
+
export type Props = ITextInputProps | IUrlInputProps | IEmailInputProps | IPasswordInputProps | INumberInputProps | ITelInputProps | ITimeInputProps | IFileInputProps | IColorInputProps | IDateInputProps;
|
|
57
|
+
export type InputTypeValueMap = {
|
|
58
|
+
text: string;
|
|
59
|
+
url: string;
|
|
60
|
+
search: string;
|
|
61
|
+
email: string;
|
|
62
|
+
password: string;
|
|
63
|
+
tel: number;
|
|
64
|
+
number: number;
|
|
65
|
+
};
|
|
66
|
+
export type ValueFromType<T extends keyof InputTypeValueMap> = InputTypeValueMap[T];
|
|
67
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|