@websline/system-components 0.0.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/README.md +0 -0
- package/dist/components/atoms/avatar/Avatar.svelte +78 -0
- package/dist/components/atoms/avatar/Avatar.svelte.d.ts +65 -0
- package/dist/components/atoms/avatar/avatar.variants.d.ts +37 -0
- package/dist/components/atoms/avatar/avatar.variants.js +20 -0
- package/dist/components/atoms/closeButton/CloseButton.svelte +92 -0
- package/dist/components/atoms/closeButton/CloseButton.svelte.d.ts +25 -0
- package/dist/components/atoms/closeButton/closeButton.variants.d.ts +37 -0
- package/dist/components/atoms/closeButton/closeButton.variants.js +21 -0
- package/dist/components/atoms/form/button/Button.svelte +67 -0
- package/dist/components/atoms/form/button/Button.svelte.d.ts +81 -0
- package/dist/components/atoms/form/button/button.variants.d.ts +58 -0
- package/dist/components/atoms/form/button/button.variants.js +82 -0
- package/dist/components/atoms/form/formField/FormField.svelte +69 -0
- package/dist/components/atoms/form/formField/FormField.svelte.d.ts +73 -0
- package/dist/components/atoms/form/helperText/HelperText.svelte +18 -0
- package/dist/components/atoms/form/helperText/HelperText.svelte.d.ts +15 -0
- package/dist/components/atoms/form/iconButton/IconButton.svelte +69 -0
- package/dist/components/atoms/form/iconButton/IconButton.svelte.d.ts +89 -0
- package/dist/components/atoms/form/iconButton/iconButton.variants.d.ts +64 -0
- package/dist/components/atoms/form/iconButton/iconButton.variants.js +91 -0
- package/dist/components/atoms/form/input/Input.svelte +65 -0
- package/dist/components/atoms/form/input/Input.svelte.d.ts +89 -0
- package/dist/components/atoms/form/input/input.variants.d.ts +22 -0
- package/dist/components/atoms/form/input/input.variants.js +15 -0
- package/dist/components/atoms/form/label/Label.svelte +36 -0
- package/dist/components/atoms/form/label/Label.svelte.d.ts +41 -0
- package/dist/components/atoms/form/textarea/Textarea.svelte +64 -0
- package/dist/components/atoms/form/textarea/Textarea.svelte.d.ts +89 -0
- package/dist/components/atoms/form/textarea/textarea.variants.d.ts +37 -0
- package/dist/components/atoms/form/textarea/textarea.variants.js +20 -0
- package/dist/components/atoms/icon/Icon.svelte +41 -0
- package/dist/components/atoms/icon/Icon.svelte.d.ts +21 -0
- package/dist/components/atoms/icon/components/Academy.svelte +27 -0
- package/dist/components/atoms/icon/components/Academy.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Bold.svelte +27 -0
- package/dist/components/atoms/icon/components/Bold.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Close.svelte +27 -0
- package/dist/components/atoms/icon/components/Close.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Italic.svelte +27 -0
- package/dist/components/atoms/icon/components/Italic.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Link.svelte +27 -0
- package/dist/components/atoms/icon/components/Link.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/ListOrdered.svelte +27 -0
- package/dist/components/atoms/icon/components/ListOrdered.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/ListUnordered.svelte +26 -0
- package/dist/components/atoms/icon/components/ListUnordered.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Refresh.svelte +27 -0
- package/dist/components/atoms/icon/components/Refresh.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Underline.svelte +26 -0
- package/dist/components/atoms/icon/components/Underline.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/index.d.ts +20 -0
- package/dist/components/atoms/icon/index.js +21 -0
- package/dist/components/atoms/loading/spinner/Spinner.svelte +40 -0
- package/dist/components/atoms/loading/spinner/Spinner.svelte.d.ts +25 -0
- package/dist/components/molecules/notification/Notification.svelte +42 -0
- package/dist/components/molecules/notification/Notification.svelte.d.ts +57 -0
- package/dist/components/molecules/notification/notification.variants.d.ts +67 -0
- package/dist/components/molecules/notification/notification.variants.js +30 -0
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte +144 -0
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte.d.ts +87 -0
- package/dist/components/molecules/richTextEditor/RichTextEditorToolbar.svelte +5 -0
- package/dist/components/molecules/richTextEditor/RichTextEditorToolbar.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/richTextEditor.variants.d.ts +64 -0
- package/dist/components/molecules/richTextEditor/richTextEditor.variants.js +30 -0
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte +61 -0
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte.d.ts +49 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte +47 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte.d.ts +25 -0
- package/dist/components/molecules/toggleGroup/toggleGroup.variants.d.ts +35 -0
- package/dist/components/molecules/toggleGroup/toggleGroup.variants.js +21 -0
- package/dist/components/molecules/toggleGroup/toggleGroupItem.variants.d.ts +110 -0
- package/dist/components/molecules/toggleGroup/toggleGroupItem.variants.js +69 -0
- package/dist/components/organisms/notificationGroup/NotificationGroup.svelte +68 -0
- package/dist/components/organisms/notificationGroup/NotificationGroup.svelte.d.ts +6 -0
- package/dist/components/organisms/notificationGroup/notificationGroup.variants.d.ts +24 -0
- package/dist/components/organisms/notificationGroup/notificationGroup.variants.js +11 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +32 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/notification.d.ts +1 -0
- package/dist/utils/notification.js +11 -0
- package/package.json +95 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { setContext } from "svelte";
|
|
3
|
+
import { tv } from "tailwind-variants";
|
|
4
|
+
import { HelperText, Label } from "../../../../index.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} Props
|
|
8
|
+
* @property {string} [class=""] Additional CSS classes for the form field
|
|
9
|
+
* @property {boolean} [error=false] Whether the form field has an error
|
|
10
|
+
* @property {string} [errorText=""] The error text for the form field
|
|
11
|
+
* @property {string} [helperText=""] The helper text for the form field
|
|
12
|
+
* @property {string} [id=""] The id attribute for the form field
|
|
13
|
+
* @property {string} [label=""] The label text for the form field
|
|
14
|
+
* @property {"stacked" | "inline"} [layout="stacked"] The layout of the input and label
|
|
15
|
+
* @property {boolean} [required=false] Whether the form field is required
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** @type {Props} */
|
|
19
|
+
let {
|
|
20
|
+
children,
|
|
21
|
+
class: className,
|
|
22
|
+
error = false,
|
|
23
|
+
errorText,
|
|
24
|
+
helperText,
|
|
25
|
+
id,
|
|
26
|
+
label,
|
|
27
|
+
layout = "stacked",
|
|
28
|
+
required = false,
|
|
29
|
+
} = $props();
|
|
30
|
+
|
|
31
|
+
const formFieldVariants = tv({
|
|
32
|
+
base: "grid gap-2",
|
|
33
|
+
variants: {
|
|
34
|
+
layout: {
|
|
35
|
+
inline: "sm:grid-cols-[minmax(120px,auto)_1fr] items-center",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
setContext("form-field-store", () => {
|
|
41
|
+
return {
|
|
42
|
+
error,
|
|
43
|
+
id,
|
|
44
|
+
required,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
let localHelperText = $derived.by(() => {
|
|
49
|
+
if (error && errorText) {
|
|
50
|
+
return errorText;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return helperText;
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<div class={formFieldVariants({ class: className, layout })}>
|
|
58
|
+
{#if label}
|
|
59
|
+
<Label for={id} {error}>{label}{required ? " *" : ""}</Label>
|
|
60
|
+
{/if}
|
|
61
|
+
|
|
62
|
+
{@render children?.()}
|
|
63
|
+
|
|
64
|
+
{#if localHelperText}
|
|
65
|
+
<HelperText class={layout === "inline" ? "sm:col-[2]" : ""} {error}>
|
|
66
|
+
{localHelperText}
|
|
67
|
+
</HelperText>
|
|
68
|
+
{/if}
|
|
69
|
+
</div>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export default FormField;
|
|
2
|
+
type FormField = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const FormField: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Additional CSS classes for the form field
|
|
9
|
+
*/
|
|
10
|
+
class?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the form field has an error
|
|
13
|
+
*/
|
|
14
|
+
error?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The error text for the form field
|
|
17
|
+
*/
|
|
18
|
+
errorText?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The helper text for the form field
|
|
21
|
+
*/
|
|
22
|
+
helperText?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The id attribute for the form field
|
|
25
|
+
*/
|
|
26
|
+
id?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The label text for the form field
|
|
29
|
+
*/
|
|
30
|
+
label?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The layout of the input and label
|
|
33
|
+
*/
|
|
34
|
+
layout?: "stacked" | "inline";
|
|
35
|
+
/**
|
|
36
|
+
* Whether the form field is required
|
|
37
|
+
*/
|
|
38
|
+
required?: boolean;
|
|
39
|
+
}, {}, "">;
|
|
40
|
+
type Props = {
|
|
41
|
+
/**
|
|
42
|
+
* Additional CSS classes for the form field
|
|
43
|
+
*/
|
|
44
|
+
class?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the form field has an error
|
|
47
|
+
*/
|
|
48
|
+
error?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The error text for the form field
|
|
51
|
+
*/
|
|
52
|
+
errorText?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The helper text for the form field
|
|
55
|
+
*/
|
|
56
|
+
helperText?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The id attribute for the form field
|
|
59
|
+
*/
|
|
60
|
+
id?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The label text for the form field
|
|
63
|
+
*/
|
|
64
|
+
label?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The layout of the input and label
|
|
67
|
+
*/
|
|
68
|
+
layout?: "stacked" | "inline";
|
|
69
|
+
/**
|
|
70
|
+
* Whether the form field is required
|
|
71
|
+
*/
|
|
72
|
+
required?: boolean;
|
|
73
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
let { children, class: className = "", error = false } = $props();
|
|
5
|
+
|
|
6
|
+
const helperTextVariants = tv({
|
|
7
|
+
base: "body-extra-small text-neutral-500",
|
|
8
|
+
variants: {
|
|
9
|
+
error: {
|
|
10
|
+
true: "text-red-500",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<p class={helperTextVariants({ class: className, error })}>
|
|
17
|
+
{@render children?.()}
|
|
18
|
+
</p>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default HelperText;
|
|
2
|
+
type HelperText = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const HelperText: import("svelte").Component<{
|
|
7
|
+
children: any;
|
|
8
|
+
class?: string;
|
|
9
|
+
error?: boolean;
|
|
10
|
+
}, {}, "">;
|
|
11
|
+
type $$ComponentProps = {
|
|
12
|
+
children: any;
|
|
13
|
+
class?: string;
|
|
14
|
+
error?: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Icon, Spinner } from "../../../../index.js";
|
|
3
|
+
import { iconButtonVariants } from "./iconButton.variants.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} Props
|
|
7
|
+
* @property {string} [as="button"] The HTML element to use for the button
|
|
8
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
9
|
+
* @property {"primary" | "secondary" | "success" | "danger"} [color="primary"] Button color
|
|
10
|
+
* @property {boolean} [disabled=false] Whether the button is disabled
|
|
11
|
+
* @property {boolean} [loading=false] Whether the button is in a loading state, for example after a form submission
|
|
12
|
+
* @property {string} [icon=""] Icon name
|
|
13
|
+
* @property {"circle" | "square"} [shape="round"] Button shape
|
|
14
|
+
* @property {"small" | "medium" | "large"} [size="medium"] Button size
|
|
15
|
+
* @property {string} [type="button"] Button type, e.g. "button", "submit", "reset"
|
|
16
|
+
* @property {"filled" | "outlined" | "transparent"} [variant="filled"] Button style
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** @type {Props} */
|
|
20
|
+
let {
|
|
21
|
+
as = "button",
|
|
22
|
+
class: className = "",
|
|
23
|
+
color = "primary",
|
|
24
|
+
disabled = false,
|
|
25
|
+
icon = "",
|
|
26
|
+
loading = false,
|
|
27
|
+
shape = "circle",
|
|
28
|
+
size = "medium",
|
|
29
|
+
type = "button",
|
|
30
|
+
variant = "filled",
|
|
31
|
+
...rest
|
|
32
|
+
} = $props();
|
|
33
|
+
|
|
34
|
+
let isButton = $derived(as === "button");
|
|
35
|
+
|
|
36
|
+
let tagSpecificProps = $derived.by(() => {
|
|
37
|
+
if (isButton) {
|
|
38
|
+
return {
|
|
39
|
+
disabled: disabled || loading,
|
|
40
|
+
type,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
"aria-disabled": disabled || loading ? "true" : undefined,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<svelte:element
|
|
51
|
+
this={as}
|
|
52
|
+
aria-busy={loading}
|
|
53
|
+
class={iconButtonVariants({
|
|
54
|
+
color,
|
|
55
|
+
class: className,
|
|
56
|
+
disabled,
|
|
57
|
+
loading,
|
|
58
|
+
shape,
|
|
59
|
+
size,
|
|
60
|
+
variant,
|
|
61
|
+
})}
|
|
62
|
+
{...tagSpecificProps}
|
|
63
|
+
{...rest}>
|
|
64
|
+
{#if loading}
|
|
65
|
+
<Spinner size="small" />
|
|
66
|
+
{:else}
|
|
67
|
+
<Icon name={icon} size={size === "large" ? 24 : 16} />
|
|
68
|
+
{/if}
|
|
69
|
+
</svelte:element>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export default IconButton;
|
|
2
|
+
type IconButton = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const IconButton: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* The HTML element to use for the button
|
|
9
|
+
*/
|
|
10
|
+
as?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes to apply to the component
|
|
13
|
+
*/
|
|
14
|
+
class?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Button color
|
|
17
|
+
*/
|
|
18
|
+
color?: "primary" | "secondary" | "success" | "danger";
|
|
19
|
+
/**
|
|
20
|
+
* Whether the button is disabled
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the button is in a loading state, for example after a form submission
|
|
25
|
+
*/
|
|
26
|
+
loading?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Icon name
|
|
29
|
+
*/
|
|
30
|
+
icon?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Button shape
|
|
33
|
+
*/
|
|
34
|
+
shape?: "circle" | "square";
|
|
35
|
+
/**
|
|
36
|
+
* Button size
|
|
37
|
+
*/
|
|
38
|
+
size?: "small" | "medium" | "large";
|
|
39
|
+
/**
|
|
40
|
+
* Button type, e.g. "button", "submit", "reset"
|
|
41
|
+
*/
|
|
42
|
+
type?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Button style
|
|
45
|
+
*/
|
|
46
|
+
variant?: "filled" | "outlined" | "transparent";
|
|
47
|
+
}, {}, "">;
|
|
48
|
+
type Props = {
|
|
49
|
+
/**
|
|
50
|
+
* The HTML element to use for the button
|
|
51
|
+
*/
|
|
52
|
+
as?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Additional CSS classes to apply to the component
|
|
55
|
+
*/
|
|
56
|
+
class?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Button color
|
|
59
|
+
*/
|
|
60
|
+
color?: "primary" | "secondary" | "success" | "danger";
|
|
61
|
+
/**
|
|
62
|
+
* Whether the button is disabled
|
|
63
|
+
*/
|
|
64
|
+
disabled?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the button is in a loading state, for example after a form submission
|
|
67
|
+
*/
|
|
68
|
+
loading?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Icon name
|
|
71
|
+
*/
|
|
72
|
+
icon?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Button shape
|
|
75
|
+
*/
|
|
76
|
+
shape?: "circle" | "square";
|
|
77
|
+
/**
|
|
78
|
+
* Button size
|
|
79
|
+
*/
|
|
80
|
+
size?: "small" | "medium" | "large";
|
|
81
|
+
/**
|
|
82
|
+
* Button type, e.g. "button", "submit", "reset"
|
|
83
|
+
*/
|
|
84
|
+
type?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Button style
|
|
87
|
+
*/
|
|
88
|
+
variant?: "filled" | "outlined" | "transparent";
|
|
89
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export const iconButtonVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
disabled: {
|
|
3
|
+
true: string;
|
|
4
|
+
};
|
|
5
|
+
loading: {
|
|
6
|
+
true: string;
|
|
7
|
+
};
|
|
8
|
+
shape: {
|
|
9
|
+
circle: string;
|
|
10
|
+
square: string;
|
|
11
|
+
};
|
|
12
|
+
size: {
|
|
13
|
+
small: string;
|
|
14
|
+
medium: string;
|
|
15
|
+
large: string;
|
|
16
|
+
};
|
|
17
|
+
variant: {
|
|
18
|
+
filled: string;
|
|
19
|
+
outlined: string;
|
|
20
|
+
transparent: string;
|
|
21
|
+
};
|
|
22
|
+
}, undefined, "inline-flex cursor-pointer transition duration-200 select-none", {
|
|
23
|
+
disabled: {
|
|
24
|
+
true: string;
|
|
25
|
+
};
|
|
26
|
+
loading: {
|
|
27
|
+
true: string;
|
|
28
|
+
};
|
|
29
|
+
shape: {
|
|
30
|
+
circle: string;
|
|
31
|
+
square: string;
|
|
32
|
+
};
|
|
33
|
+
size: {
|
|
34
|
+
small: string;
|
|
35
|
+
medium: string;
|
|
36
|
+
large: string;
|
|
37
|
+
};
|
|
38
|
+
variant: {
|
|
39
|
+
filled: string;
|
|
40
|
+
outlined: string;
|
|
41
|
+
transparent: string;
|
|
42
|
+
};
|
|
43
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
44
|
+
disabled: {
|
|
45
|
+
true: string;
|
|
46
|
+
};
|
|
47
|
+
loading: {
|
|
48
|
+
true: string;
|
|
49
|
+
};
|
|
50
|
+
shape: {
|
|
51
|
+
circle: string;
|
|
52
|
+
square: string;
|
|
53
|
+
};
|
|
54
|
+
size: {
|
|
55
|
+
small: string;
|
|
56
|
+
medium: string;
|
|
57
|
+
large: string;
|
|
58
|
+
};
|
|
59
|
+
variant: {
|
|
60
|
+
filled: string;
|
|
61
|
+
outlined: string;
|
|
62
|
+
transparent: string;
|
|
63
|
+
};
|
|
64
|
+
}, undefined, "inline-flex cursor-pointer transition duration-200 select-none", unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
|
|
3
|
+
const iconButtonVariants = tv({
|
|
4
|
+
base: "inline-flex cursor-pointer transition duration-200 select-none",
|
|
5
|
+
variants: {
|
|
6
|
+
disabled: {
|
|
7
|
+
true: "opacity-40 pointer-events-none",
|
|
8
|
+
},
|
|
9
|
+
loading: {
|
|
10
|
+
true: "pointer-events-none",
|
|
11
|
+
},
|
|
12
|
+
shape: {
|
|
13
|
+
circle: "rounded-full",
|
|
14
|
+
square: "rounded-sm",
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
small: "p-0.75",
|
|
18
|
+
medium: "p-1.75",
|
|
19
|
+
large: "p-2.75",
|
|
20
|
+
},
|
|
21
|
+
variant: {
|
|
22
|
+
filled: "border-transparent border-1",
|
|
23
|
+
outlined: "border-1",
|
|
24
|
+
transparent: "border-transparent border-1",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
compoundVariants: [
|
|
28
|
+
{
|
|
29
|
+
color: "primary",
|
|
30
|
+
variant: "filled",
|
|
31
|
+
class:
|
|
32
|
+
"bg-blue-500 text-white hover:bg-blue-600 dark:bg-blue-400 dark:hover:bg-blue-500",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
color: "primary",
|
|
36
|
+
variant: "outlined",
|
|
37
|
+
class:
|
|
38
|
+
"text-blue-500 border-blue-500 hover:bg-blue-600 hover:border-blue-600 hover:text-white dark:text-blue-400 dark:border-blue-400 dark:hover:bg-blue-500 dark:hover:border-blue-500",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
color: "secondary",
|
|
42
|
+
variant: "filled",
|
|
43
|
+
class:
|
|
44
|
+
"bg-neutral-900 text-white hover:bg-neutral-700 dark:bg-neutral-200 dark:text-neutral-900 dark:hover:bg-neutral-500 dark:hover:text-white",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
color: "secondary",
|
|
48
|
+
variant: "outlined",
|
|
49
|
+
class:
|
|
50
|
+
"text-neutral-900 hover:bg-neutral-900 hover:text-white hover:border-neutral-900 dark:border-white dark:text-white dark:hover:bg-neutral-200 dark:hover:border-neutral-200 dark:hover:text-inherit",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
color: "success",
|
|
54
|
+
variant: "filled",
|
|
55
|
+
class:
|
|
56
|
+
"bg-green-500 text-white hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-700",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
color: "success",
|
|
60
|
+
variant: "outlined",
|
|
61
|
+
class:
|
|
62
|
+
"text-green-500 border-green-500 hover:bg-green-700 hover:border-green-700 hover:text-white dark:text-green-500 dark:border-green-500 dark:hover:bg-green-700 dark:hover:border-green-700",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
color: "danger",
|
|
66
|
+
variant: "filled",
|
|
67
|
+
class:
|
|
68
|
+
"bg-red-500 text-white hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-700",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
color: "danger",
|
|
72
|
+
variant: "outlined",
|
|
73
|
+
class:
|
|
74
|
+
"text-red-500 border-red-500 hover:bg-red-700 hover:border-red-700 hover:text-white dark:text-red-500 dark:border-red-500 dark:hover:bg-red-700 dark:hover:border-red-700",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
shape: "square",
|
|
78
|
+
variant: "transparent",
|
|
79
|
+
class:
|
|
80
|
+
"bg-transparent hover:bg-neutral-300 dark:text-white dark:hover:bg-neutral-700",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
shape: "square",
|
|
84
|
+
variant: "filled",
|
|
85
|
+
class:
|
|
86
|
+
"bg-neutral-100 hover:bg-neutral-300 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:hover:bg-neutral-700",
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export { iconButtonVariants };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import { inputVariants } from "./input.variants.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} Props
|
|
7
|
+
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
8
|
+
* @property {boolean} [disabled=false] Whether the input is disabled
|
|
9
|
+
* @property {boolean} [error=false] Whether the input has an error state
|
|
10
|
+
* @property {string} [id=""] The ID of the input element
|
|
11
|
+
* @property {string} [name] The name of the input, used for form submission
|
|
12
|
+
* @property {string} [placeholder=""] Placeholder text for the input
|
|
13
|
+
* @property {boolean} [readonly=false] Whether the input is read-only
|
|
14
|
+
* @property {boolean} [required=false] Whether the input is required
|
|
15
|
+
* @property {string} [type="text"] The type of the input, e.g. "text", "password", "email"
|
|
16
|
+
* @property {string} [value=""] The value of the input, bound to the component
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** @type {Props} */
|
|
20
|
+
let {
|
|
21
|
+
class: className = "",
|
|
22
|
+
disabled = false,
|
|
23
|
+
error = false,
|
|
24
|
+
id = "",
|
|
25
|
+
name,
|
|
26
|
+
placeholder = "",
|
|
27
|
+
readonly = false,
|
|
28
|
+
required = false,
|
|
29
|
+
type = "text",
|
|
30
|
+
value = $bindable(),
|
|
31
|
+
...rest
|
|
32
|
+
} = $props();
|
|
33
|
+
|
|
34
|
+
let store = getContext("form-field-store");
|
|
35
|
+
|
|
36
|
+
let localValues = $derived.by(() => {
|
|
37
|
+
if (store) {
|
|
38
|
+
return {
|
|
39
|
+
...store(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
id,
|
|
45
|
+
error,
|
|
46
|
+
required,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<input
|
|
52
|
+
class={inputVariants({
|
|
53
|
+
class: className,
|
|
54
|
+
disabled,
|
|
55
|
+
error: localValues.error,
|
|
56
|
+
})}
|
|
57
|
+
{disabled}
|
|
58
|
+
id={localValues.id}
|
|
59
|
+
{name}
|
|
60
|
+
{placeholder}
|
|
61
|
+
{readonly}
|
|
62
|
+
required={localValues.required}
|
|
63
|
+
{type}
|
|
64
|
+
{...rest}
|
|
65
|
+
bind:value />
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export default Input;
|
|
2
|
+
type Input = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Input: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Additional CSS classes to apply to the component
|
|
9
|
+
*/
|
|
10
|
+
class?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether the input is disabled
|
|
13
|
+
*/
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the input has an error state
|
|
17
|
+
*/
|
|
18
|
+
error?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The ID of the input element
|
|
21
|
+
*/
|
|
22
|
+
id?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The name of the input, used for form submission
|
|
25
|
+
*/
|
|
26
|
+
name?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Placeholder text for the input
|
|
29
|
+
*/
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the input is read-only
|
|
33
|
+
*/
|
|
34
|
+
readonly?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the input is required
|
|
37
|
+
*/
|
|
38
|
+
required?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The type of the input, e.g. "text", "password", "email"
|
|
41
|
+
*/
|
|
42
|
+
type?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The value of the input, bound to the component
|
|
45
|
+
*/
|
|
46
|
+
value?: string;
|
|
47
|
+
}, {}, "value">;
|
|
48
|
+
type Props = {
|
|
49
|
+
/**
|
|
50
|
+
* Additional CSS classes to apply to the component
|
|
51
|
+
*/
|
|
52
|
+
class?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the input is disabled
|
|
55
|
+
*/
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the input has an error state
|
|
59
|
+
*/
|
|
60
|
+
error?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The ID of the input element
|
|
63
|
+
*/
|
|
64
|
+
id?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The name of the input, used for form submission
|
|
67
|
+
*/
|
|
68
|
+
name?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Placeholder text for the input
|
|
71
|
+
*/
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the input is read-only
|
|
75
|
+
*/
|
|
76
|
+
readonly?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the input is required
|
|
79
|
+
*/
|
|
80
|
+
required?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The type of the input, e.g. "text", "password", "email"
|
|
83
|
+
*/
|
|
84
|
+
type?: string;
|
|
85
|
+
/**
|
|
86
|
+
* The value of the input, bound to the component
|
|
87
|
+
*/
|
|
88
|
+
value?: string;
|
|
89
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const inputVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
disabled: {
|
|
3
|
+
true: string;
|
|
4
|
+
};
|
|
5
|
+
error: {
|
|
6
|
+
true: string;
|
|
7
|
+
};
|
|
8
|
+
}, undefined, "rounded px-4 body-default bg-transparent border border-neutral-500 text-neutral-800 placeholder-neutral-500 h-10 w-full outline-transparent focus:ring-1 focus:ring-blue-500 focus:border-blue-500 hover:border-neutral-800 transition-[border, outline] duration-300 dark:text-white dark:hover:border-neutral-200 dark:focus:ring-white dark:focus:border-white", {
|
|
9
|
+
disabled: {
|
|
10
|
+
true: string;
|
|
11
|
+
};
|
|
12
|
+
error: {
|
|
13
|
+
true: string;
|
|
14
|
+
};
|
|
15
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
16
|
+
disabled: {
|
|
17
|
+
true: string;
|
|
18
|
+
};
|
|
19
|
+
error: {
|
|
20
|
+
true: string;
|
|
21
|
+
};
|
|
22
|
+
}, undefined, "rounded px-4 body-default bg-transparent border border-neutral-500 text-neutral-800 placeholder-neutral-500 h-10 w-full outline-transparent focus:ring-1 focus:ring-blue-500 focus:border-blue-500 hover:border-neutral-800 transition-[border, outline] duration-300 dark:text-white dark:hover:border-neutral-200 dark:focus:ring-white dark:focus:border-white", unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
|
|
3
|
+
const inputVariants = tv({
|
|
4
|
+
base: "rounded px-4 body-default bg-transparent border border-neutral-500 text-neutral-800 placeholder-neutral-500 h-10 w-full outline-transparent focus:ring-1 focus:ring-blue-500 focus:border-blue-500 hover:border-neutral-800 transition-[border, outline] duration-300 dark:text-white dark:hover:border-neutral-200 dark:focus:ring-white dark:focus:border-white",
|
|
5
|
+
variants: {
|
|
6
|
+
disabled: {
|
|
7
|
+
true: "cursor-not-allowed opacity-50",
|
|
8
|
+
},
|
|
9
|
+
error: {
|
|
10
|
+
true: "border border-red-500 outline focus:ring-red-500 focus:border-red-500 outline-red-500 text-red-500",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export { inputVariants };
|