podo-ui 0.9.7 → 1.0.2
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/cdn/podo-datepicker.css +1 -1
- package/cdn/podo-datepicker.js +1 -1
- package/cdn/podo-datepicker.min.css +1 -1
- package/cdn/podo-datepicker.min.js +1 -1
- package/cdn/podo-ui.css +4 -1
- package/cdn/podo-ui.min.css +1 -1
- package/dist/react/atom/editor.d.ts.map +1 -1
- package/dist/react/atom/editor.js +94 -2
- package/dist/svelte/actions/portal.d.ts +18 -0
- package/dist/svelte/actions/portal.js +42 -0
- package/dist/svelte/atom/Avatar.svelte +97 -0
- package/dist/svelte/atom/Avatar.svelte.d.ts +31 -0
- package/dist/svelte/atom/Button.svelte +86 -0
- package/dist/svelte/atom/Button.svelte.d.ts +26 -0
- package/dist/svelte/atom/Checkbox.svelte +56 -0
- package/dist/svelte/atom/Checkbox.svelte.d.ts +16 -0
- package/dist/svelte/atom/Chip.svelte +60 -0
- package/dist/svelte/atom/Chip.svelte.d.ts +25 -0
- package/dist/svelte/atom/Editor.svelte +1314 -0
- package/dist/svelte/atom/Editor.svelte.d.ts +30 -0
- package/dist/svelte/atom/EditorView.svelte +16 -0
- package/dist/svelte/atom/EditorView.svelte.d.ts +9 -0
- package/dist/svelte/atom/File.svelte +33 -0
- package/dist/svelte/atom/File.svelte.d.ts +14 -0
- package/dist/svelte/atom/Input.svelte +80 -0
- package/dist/svelte/atom/Input.svelte.d.ts +19 -0
- package/dist/svelte/atom/Label.svelte +43 -0
- package/dist/svelte/atom/Label.svelte.d.ts +19 -0
- package/dist/svelte/atom/Radio.svelte +69 -0
- package/dist/svelte/atom/Radio.svelte.d.ts +26 -0
- package/dist/svelte/atom/RadioGroup.svelte +46 -0
- package/dist/svelte/atom/RadioGroup.svelte.d.ts +16 -0
- package/dist/svelte/atom/Select.svelte +65 -0
- package/dist/svelte/atom/Select.svelte.d.ts +26 -0
- package/dist/svelte/atom/Textarea.svelte +53 -0
- package/dist/svelte/atom/Textarea.svelte.d.ts +13 -0
- package/dist/svelte/atom/Toggle.svelte +48 -0
- package/dist/svelte/atom/Toggle.svelte.d.ts +14 -0
- package/dist/svelte/atom/Tooltip.svelte +78 -0
- package/dist/svelte/atom/Tooltip.svelte.d.ts +23 -0
- package/dist/svelte/atom/avatar.module.scss +82 -0
- package/dist/svelte/atom/editor-view.module.scss +251 -0
- package/dist/svelte/atom/input.module.scss +98 -0
- package/dist/svelte/atom/textarea.module.scss +17 -0
- package/dist/svelte/atom/tooltip.module.scss +227 -0
- package/dist/svelte/index.d.ts +26 -0
- package/dist/svelte/index.js +30 -0
- package/dist/svelte/molecule/DatePicker.svelte +986 -0
- package/dist/svelte/molecule/DatePicker.svelte.d.ts +71 -0
- package/dist/svelte/molecule/Field.svelte +81 -0
- package/dist/svelte/molecule/Field.svelte.d.ts +26 -0
- package/dist/svelte/molecule/Pagination.svelte +95 -0
- package/dist/svelte/molecule/Pagination.svelte.d.ts +14 -0
- package/dist/svelte/molecule/Tab.svelte +69 -0
- package/dist/svelte/molecule/Tab.svelte.d.ts +26 -0
- package/dist/svelte/molecule/TabPanel.svelte +24 -0
- package/dist/svelte/molecule/TabPanel.svelte.d.ts +14 -0
- package/dist/svelte/molecule/Table.svelte +109 -0
- package/dist/svelte/molecule/Table.svelte.d.ts +54 -0
- package/dist/svelte/molecule/Toast.svelte +111 -0
- package/dist/svelte/molecule/Toast.svelte.d.ts +25 -0
- package/dist/svelte/molecule/ToastProvider.svelte +74 -0
- package/dist/svelte/molecule/ToastProvider.svelte.d.ts +8 -0
- package/dist/svelte/molecule/field.module.scss +22 -0
- package/dist/svelte/molecule/pagination.module.scss +61 -0
- package/dist/svelte/molecule/toast-container.module.scss +70 -0
- package/dist/svelte/molecule/toast.module.scss +12 -0
- package/dist/svelte/stores/toast.d.ts +45 -0
- package/dist/svelte/stores/toast.js +55 -0
- package/dist/svelte/stores/validation.d.ts +15 -0
- package/dist/svelte/stores/validation.js +38 -0
- package/global.scss +1 -0
- package/package.json +32 -5
- package/vite-fonts.scss +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export type ToolbarItem = 'undo-redo' | 'paragraph' | 'text-style' | 'color' | 'align' | 'list' | 'table' | 'link' | 'image' | 'youtube' | 'hr' | 'format' | 'code';
|
|
3
|
+
interface Props {
|
|
4
|
+
/** HTML content */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Editor width */
|
|
7
|
+
width?: string;
|
|
8
|
+
/** Editor height */
|
|
9
|
+
height?: string | 'contents';
|
|
10
|
+
/** Minimum height */
|
|
11
|
+
minHeight?: string;
|
|
12
|
+
/** Maximum height */
|
|
13
|
+
maxHeight?: string;
|
|
14
|
+
/** Allow resizing */
|
|
15
|
+
resizable?: boolean;
|
|
16
|
+
/** Change handler */
|
|
17
|
+
onchange?: (content: string) => void;
|
|
18
|
+
/** Zod validator */
|
|
19
|
+
validator?: z.ZodType<unknown>;
|
|
20
|
+
/** Placeholder text */
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
/** Toolbar items to show */
|
|
23
|
+
toolbar?: ToolbarItem[];
|
|
24
|
+
/** Additional class name */
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
type $$ComponentProps = Props & Record<string, unknown>;
|
|
28
|
+
declare const Editor: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
29
|
+
type Editor = ReturnType<typeof Editor>;
|
|
30
|
+
export default Editor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import styles from './editor-view.module.scss';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
/** HTML content to render */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Additional class name */
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { value, class: className = '' }: Props = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div class="{styles.editorView} {className}">
|
|
15
|
+
{@html value}
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** HTML content to render */
|
|
3
|
+
value: string;
|
|
4
|
+
/** Additional class name */
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const EditorView: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type EditorView = ReturnType<typeof EditorView>;
|
|
9
|
+
export default EditorView;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
interface Props extends Omit<HTMLInputAttributes, 'type'> {
|
|
5
|
+
/** Accepted file types (e.g., "image/*", ".pdf") */
|
|
6
|
+
accept?: string;
|
|
7
|
+
/** Allow multiple file selection */
|
|
8
|
+
multiple?: boolean;
|
|
9
|
+
/** Disabled state */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/** Element reference for bind:this */
|
|
12
|
+
element?: HTMLInputElement;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
accept,
|
|
17
|
+
multiple = false,
|
|
18
|
+
disabled = false,
|
|
19
|
+
class: className,
|
|
20
|
+
element = $bindable(),
|
|
21
|
+
...rest
|
|
22
|
+
}: Props = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<input
|
|
26
|
+
bind:this={element}
|
|
27
|
+
type="file"
|
|
28
|
+
{accept}
|
|
29
|
+
{multiple}
|
|
30
|
+
{disabled}
|
|
31
|
+
class={className}
|
|
32
|
+
{...rest}
|
|
33
|
+
/>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
interface Props extends Omit<HTMLInputAttributes, 'type'> {
|
|
3
|
+
/** Accepted file types (e.g., "image/*", ".pdf") */
|
|
4
|
+
accept?: string;
|
|
5
|
+
/** Allow multiple file selection */
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
/** Disabled state */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Element reference for bind:this */
|
|
10
|
+
element?: HTMLInputElement;
|
|
11
|
+
}
|
|
12
|
+
declare const File: import("svelte").Component<Props, {}, "element">;
|
|
13
|
+
type File = ReturnType<typeof File>;
|
|
14
|
+
export default File;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
import { createValidation } from '../stores/validation';
|
|
5
|
+
import styles from './input.module.scss';
|
|
6
|
+
|
|
7
|
+
interface Props extends HTMLInputAttributes {
|
|
8
|
+
/** Input value */
|
|
9
|
+
value?: string | number;
|
|
10
|
+
/** Zod validator */
|
|
11
|
+
validator?: z.ZodType<unknown>;
|
|
12
|
+
/** Left icon class name */
|
|
13
|
+
withIcon?: string;
|
|
14
|
+
/** Right icon class name */
|
|
15
|
+
withRightIcon?: string;
|
|
16
|
+
/** Unit text (e.g., "원", "kg") */
|
|
17
|
+
unit?: string;
|
|
18
|
+
/** Element reference for bind:this */
|
|
19
|
+
element?: HTMLInputElement;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
validator,
|
|
24
|
+
value = $bindable(''),
|
|
25
|
+
class: className = '',
|
|
26
|
+
withIcon,
|
|
27
|
+
withRightIcon,
|
|
28
|
+
unit,
|
|
29
|
+
type = 'text',
|
|
30
|
+
id,
|
|
31
|
+
element = $bindable(),
|
|
32
|
+
...rest
|
|
33
|
+
}: Props = $props();
|
|
34
|
+
|
|
35
|
+
const { message, statusClass, validate } = createValidation(validator);
|
|
36
|
+
|
|
37
|
+
let inputId = id || `input-${Math.random().toString(36).slice(2, 9)}`;
|
|
38
|
+
let errorId = `${inputId}-error`;
|
|
39
|
+
|
|
40
|
+
$effect(() => {
|
|
41
|
+
validate(value);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
let wrapperClass = $derived(
|
|
45
|
+
[className, withIcon && 'with-icon', withRightIcon && 'with-right-icon']
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.join(' ')
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
let inputClass = $derived([$statusClass, className].filter(Boolean).join(' '));
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<div class="{styles.style} {className}">
|
|
54
|
+
<div class={wrapperClass}>
|
|
55
|
+
{#if withIcon}
|
|
56
|
+
<i class={withIcon}></i>
|
|
57
|
+
{/if}
|
|
58
|
+
<input
|
|
59
|
+
bind:this={element}
|
|
60
|
+
id={inputId}
|
|
61
|
+
{type}
|
|
62
|
+
bind:value
|
|
63
|
+
class={inputClass}
|
|
64
|
+
aria-invalid={$statusClass === 'danger' ? true : undefined}
|
|
65
|
+
aria-describedby={$message ? errorId : rest['aria-describedby']}
|
|
66
|
+
{...rest}
|
|
67
|
+
/>
|
|
68
|
+
{#if withRightIcon}
|
|
69
|
+
<i class={withRightIcon}></i>
|
|
70
|
+
{/if}
|
|
71
|
+
{#if unit}
|
|
72
|
+
<span class="unit">{unit}</span>
|
|
73
|
+
{/if}
|
|
74
|
+
</div>
|
|
75
|
+
{#if validator && $message !== ''}
|
|
76
|
+
<div id={errorId} class="validator" role="alert">
|
|
77
|
+
{$message}
|
|
78
|
+
</div>
|
|
79
|
+
{/if}
|
|
80
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
interface Props extends HTMLInputAttributes {
|
|
4
|
+
/** Input value */
|
|
5
|
+
value?: string | number;
|
|
6
|
+
/** Zod validator */
|
|
7
|
+
validator?: z.ZodType<unknown>;
|
|
8
|
+
/** Left icon class name */
|
|
9
|
+
withIcon?: string;
|
|
10
|
+
/** Right icon class name */
|
|
11
|
+
withRightIcon?: string;
|
|
12
|
+
/** Unit text (e.g., "원", "kg") */
|
|
13
|
+
unit?: string;
|
|
14
|
+
/** Element reference for bind:this */
|
|
15
|
+
element?: HTMLInputElement;
|
|
16
|
+
}
|
|
17
|
+
declare const Input: import("svelte").Component<Props, {}, "value" | "element">;
|
|
18
|
+
type Input = ReturnType<typeof Input>;
|
|
19
|
+
export default Input;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { HTMLLabelAttributes } from 'svelte/elements';
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLLabelAttributes {
|
|
6
|
+
/** Label text content */
|
|
7
|
+
children: Snippet;
|
|
8
|
+
/** Size variant */
|
|
9
|
+
size?: 'sm' | 'md' | 'lg';
|
|
10
|
+
/** Semibold font weight */
|
|
11
|
+
semibold?: boolean;
|
|
12
|
+
/** Show required indicator (*) */
|
|
13
|
+
required?: boolean;
|
|
14
|
+
/** Disabled style */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Associated input id */
|
|
17
|
+
for?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
children,
|
|
22
|
+
size = 'md',
|
|
23
|
+
semibold = false,
|
|
24
|
+
required = false,
|
|
25
|
+
disabled = false,
|
|
26
|
+
for: htmlFor,
|
|
27
|
+
class: className = '',
|
|
28
|
+
...rest
|
|
29
|
+
}: Props = $props();
|
|
30
|
+
|
|
31
|
+
let labelClass = $derived(
|
|
32
|
+
[size !== 'md' && size, semibold && 'semibold', disabled && 'disabled', className]
|
|
33
|
+
.filter(Boolean)
|
|
34
|
+
.join(' ')
|
|
35
|
+
);
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<label for={htmlFor} class={labelClass || undefined} {...rest}>
|
|
39
|
+
{@render children()}
|
|
40
|
+
{#if required}
|
|
41
|
+
<span class="required">*</span>
|
|
42
|
+
{/if}
|
|
43
|
+
</label>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLLabelAttributes } from 'svelte/elements';
|
|
3
|
+
interface Props extends HTMLLabelAttributes {
|
|
4
|
+
/** Label text content */
|
|
5
|
+
children: Snippet;
|
|
6
|
+
/** Size variant */
|
|
7
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
/** Semibold font weight */
|
|
9
|
+
semibold?: boolean;
|
|
10
|
+
/** Show required indicator (*) */
|
|
11
|
+
required?: boolean;
|
|
12
|
+
/** Disabled style */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Associated input id */
|
|
15
|
+
for?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const Label: import("svelte").Component<Props, {}, "">;
|
|
18
|
+
type Label = ReturnType<typeof Label>;
|
|
19
|
+
export default Label;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export interface RadioGroupOption {
|
|
3
|
+
/** Option value */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Option label */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Disabled state */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
14
|
+
|
|
15
|
+
interface Props extends Omit<HTMLInputAttributes, 'type' | 'name' | 'value'> {
|
|
16
|
+
/** Checked state */
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
/** Group name (required for grouping) */
|
|
19
|
+
name: string;
|
|
20
|
+
/** Radio value */
|
|
21
|
+
value: string;
|
|
22
|
+
/** Label text */
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Disabled state */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** Element reference for bind:this */
|
|
27
|
+
element?: HTMLInputElement;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
checked = $bindable(false),
|
|
32
|
+
name,
|
|
33
|
+
value,
|
|
34
|
+
label,
|
|
35
|
+
disabled = false,
|
|
36
|
+
class: className,
|
|
37
|
+
element = $bindable(),
|
|
38
|
+
...rest
|
|
39
|
+
}: Props = $props();
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
{#if label}
|
|
43
|
+
<label>
|
|
44
|
+
<input
|
|
45
|
+
bind:this={element}
|
|
46
|
+
type="radio"
|
|
47
|
+
{name}
|
|
48
|
+
{value}
|
|
49
|
+
{checked}
|
|
50
|
+
onchange={(e) => checked = e.currentTarget.checked}
|
|
51
|
+
{disabled}
|
|
52
|
+
class={className}
|
|
53
|
+
{...rest}
|
|
54
|
+
/>
|
|
55
|
+
<span>{label}</span>
|
|
56
|
+
</label>
|
|
57
|
+
{:else}
|
|
58
|
+
<input
|
|
59
|
+
bind:this={element}
|
|
60
|
+
type="radio"
|
|
61
|
+
{name}
|
|
62
|
+
{value}
|
|
63
|
+
{checked}
|
|
64
|
+
onchange={(e) => checked = e.currentTarget.checked}
|
|
65
|
+
{disabled}
|
|
66
|
+
class={className}
|
|
67
|
+
{...rest}
|
|
68
|
+
/>
|
|
69
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface RadioGroupOption {
|
|
2
|
+
/** Option value */
|
|
3
|
+
value: string;
|
|
4
|
+
/** Option label */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Disabled state */
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
10
|
+
interface Props extends Omit<HTMLInputAttributes, 'type' | 'name' | 'value'> {
|
|
11
|
+
/** Checked state */
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
/** Group name (required for grouping) */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Radio value */
|
|
16
|
+
value: string;
|
|
17
|
+
/** Label text */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Disabled state */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Element reference for bind:this */
|
|
22
|
+
element?: HTMLInputElement;
|
|
23
|
+
}
|
|
24
|
+
declare const Radio: import("svelte").Component<Props, {}, "element" | "checked">;
|
|
25
|
+
type Radio = ReturnType<typeof Radio>;
|
|
26
|
+
export default Radio;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { RadioGroupOption } from './Radio.svelte';
|
|
3
|
+
import Radio from './Radio.svelte';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
/** Group name */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Current selected value */
|
|
9
|
+
value?: string;
|
|
10
|
+
/** Option list */
|
|
11
|
+
options: RadioGroupOption[];
|
|
12
|
+
/** Vertical layout */
|
|
13
|
+
vertical?: boolean;
|
|
14
|
+
/** Additional class name */
|
|
15
|
+
class?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
name,
|
|
20
|
+
value = $bindable(''),
|
|
21
|
+
options,
|
|
22
|
+
vertical = false,
|
|
23
|
+
class: className = '',
|
|
24
|
+
}: Props = $props();
|
|
25
|
+
|
|
26
|
+
let groupClass = $derived(
|
|
27
|
+
['radio-group', vertical && 'vertical', className].filter(Boolean).join(' ')
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
function handleChange(optionValue: string) {
|
|
31
|
+
value = optionValue;
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<div class={groupClass || undefined}>
|
|
36
|
+
{#each options as option (option.value)}
|
|
37
|
+
<Radio
|
|
38
|
+
{name}
|
|
39
|
+
value={option.value}
|
|
40
|
+
label={option.label}
|
|
41
|
+
checked={value === option.value}
|
|
42
|
+
disabled={option.disabled}
|
|
43
|
+
onchange={() => handleChange(option.value)}
|
|
44
|
+
/>
|
|
45
|
+
{/each}
|
|
46
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RadioGroupOption } from './Radio.svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Group name */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Current selected value */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** Option list */
|
|
8
|
+
options: RadioGroupOption[];
|
|
9
|
+
/** Vertical layout */
|
|
10
|
+
vertical?: boolean;
|
|
11
|
+
/** Additional class name */
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const RadioGroup: import("svelte").Component<Props, {}, "value">;
|
|
15
|
+
type RadioGroup = ReturnType<typeof RadioGroup>;
|
|
16
|
+
export default RadioGroup;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLSelectAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
export interface SelectOption {
|
|
5
|
+
/** Option value */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Option label */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Disabled state */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Props extends Omit<HTMLSelectAttributes, 'children'> {
|
|
14
|
+
/** Current value */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Option list */
|
|
17
|
+
options: SelectOption[];
|
|
18
|
+
/** Placeholder text */
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/** Disabled state */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** Left icon class name */
|
|
23
|
+
withIcon?: string;
|
|
24
|
+
/** Element reference for bind:this */
|
|
25
|
+
element?: HTMLSelectElement;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
value = $bindable(''),
|
|
30
|
+
options,
|
|
31
|
+
placeholder,
|
|
32
|
+
disabled = false,
|
|
33
|
+
withIcon,
|
|
34
|
+
class: className,
|
|
35
|
+
element = $bindable(),
|
|
36
|
+
...rest
|
|
37
|
+
}: Props = $props();
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
{#if withIcon}
|
|
41
|
+
<div class="with-icon">
|
|
42
|
+
<i class={withIcon}></i>
|
|
43
|
+
<select bind:this={element} bind:value {disabled} class={className} {...rest}>
|
|
44
|
+
{#if placeholder}
|
|
45
|
+
<option value="" disabled>{placeholder}</option>
|
|
46
|
+
{/if}
|
|
47
|
+
{#each options as option (option.value)}
|
|
48
|
+
<option value={option.value} disabled={option.disabled}>
|
|
49
|
+
{option.label}
|
|
50
|
+
</option>
|
|
51
|
+
{/each}
|
|
52
|
+
</select>
|
|
53
|
+
</div>
|
|
54
|
+
{:else}
|
|
55
|
+
<select bind:this={element} bind:value {disabled} class={className} {...rest}>
|
|
56
|
+
{#if placeholder}
|
|
57
|
+
<option value="" disabled>{placeholder}</option>
|
|
58
|
+
{/if}
|
|
59
|
+
{#each options as option (option.value)}
|
|
60
|
+
<option value={option.value} disabled={option.disabled}>
|
|
61
|
+
{option.label}
|
|
62
|
+
</option>
|
|
63
|
+
{/each}
|
|
64
|
+
</select>
|
|
65
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HTMLSelectAttributes } from 'svelte/elements';
|
|
2
|
+
export interface SelectOption {
|
|
3
|
+
/** Option value */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Option label */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Disabled state */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface Props extends Omit<HTMLSelectAttributes, 'children'> {
|
|
11
|
+
/** Current value */
|
|
12
|
+
value?: string;
|
|
13
|
+
/** Option list */
|
|
14
|
+
options: SelectOption[];
|
|
15
|
+
/** Placeholder text */
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
/** Disabled state */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** Left icon class name */
|
|
20
|
+
withIcon?: string;
|
|
21
|
+
/** Element reference for bind:this */
|
|
22
|
+
element?: HTMLSelectElement;
|
|
23
|
+
}
|
|
24
|
+
declare const Select: import("svelte").Component<Props, {}, "value" | "element">;
|
|
25
|
+
type Select = ReturnType<typeof Select>;
|
|
26
|
+
export default Select;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLTextareaAttributes } from 'svelte/elements';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
import { createValidation } from '../stores/validation';
|
|
5
|
+
import styles from './textarea.module.scss';
|
|
6
|
+
|
|
7
|
+
interface Props extends HTMLTextareaAttributes {
|
|
8
|
+
/** Textarea value */
|
|
9
|
+
value?: string;
|
|
10
|
+
/** Zod validator */
|
|
11
|
+
validator?: z.ZodType<unknown>;
|
|
12
|
+
/** Element reference for bind:this */
|
|
13
|
+
element?: HTMLTextAreaElement;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
validator,
|
|
18
|
+
value = $bindable(''),
|
|
19
|
+
class: className = '',
|
|
20
|
+
id,
|
|
21
|
+
element = $bindable(),
|
|
22
|
+
...rest
|
|
23
|
+
}: Props = $props();
|
|
24
|
+
|
|
25
|
+
const { message, statusClass, validate } = createValidation(validator);
|
|
26
|
+
|
|
27
|
+
let textareaId = id || `textarea-${Math.random().toString(36).slice(2, 9)}`;
|
|
28
|
+
let errorId = `${textareaId}-error`;
|
|
29
|
+
|
|
30
|
+
function handleKeyup() {
|
|
31
|
+
validate(value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let textareaClass = $derived([$statusClass, className].filter(Boolean).join(' '));
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<div class="{styles.style} {className}">
|
|
38
|
+
<textarea
|
|
39
|
+
bind:this={element}
|
|
40
|
+
id={textareaId}
|
|
41
|
+
bind:value
|
|
42
|
+
class={textareaClass}
|
|
43
|
+
onkeyup={handleKeyup}
|
|
44
|
+
aria-invalid={$statusClass === 'danger' ? true : undefined}
|
|
45
|
+
aria-describedby={$message ? errorId : rest['aria-describedby']}
|
|
46
|
+
{...rest}
|
|
47
|
+
></textarea>
|
|
48
|
+
{#if validator && $message !== ''}
|
|
49
|
+
<div id={errorId} class="validator" role="alert">
|
|
50
|
+
{$message}
|
|
51
|
+
</div>
|
|
52
|
+
{/if}
|
|
53
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HTMLTextareaAttributes } from 'svelte/elements';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
interface Props extends HTMLTextareaAttributes {
|
|
4
|
+
/** Textarea value */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** Zod validator */
|
|
7
|
+
validator?: z.ZodType<unknown>;
|
|
8
|
+
/** Element reference for bind:this */
|
|
9
|
+
element?: HTMLTextAreaElement;
|
|
10
|
+
}
|
|
11
|
+
declare const Textarea: import("svelte").Component<Props, {}, "value" | "element">;
|
|
12
|
+
type Textarea = ReturnType<typeof Textarea>;
|
|
13
|
+
export default Textarea;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
interface Props extends Omit<HTMLInputAttributes, 'type'> {
|
|
5
|
+
/** Checked state */
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
/** Label text */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Disabled state */
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/** Element reference for bind:this */
|
|
12
|
+
element?: HTMLInputElement;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
checked = $bindable(false),
|
|
17
|
+
label,
|
|
18
|
+
disabled = false,
|
|
19
|
+
class: className = '',
|
|
20
|
+
element = $bindable(),
|
|
21
|
+
...rest
|
|
22
|
+
}: Props = $props();
|
|
23
|
+
|
|
24
|
+
let toggleClass = $derived(['toggle', className].filter(Boolean).join(' '));
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
{#if label}
|
|
28
|
+
<label>
|
|
29
|
+
<input
|
|
30
|
+
bind:this={element}
|
|
31
|
+
type="checkbox"
|
|
32
|
+
class={toggleClass}
|
|
33
|
+
bind:checked
|
|
34
|
+
{disabled}
|
|
35
|
+
{...rest}
|
|
36
|
+
/>
|
|
37
|
+
<span>{label}</span>
|
|
38
|
+
</label>
|
|
39
|
+
{:else}
|
|
40
|
+
<input
|
|
41
|
+
bind:this={element}
|
|
42
|
+
type="checkbox"
|
|
43
|
+
class={toggleClass}
|
|
44
|
+
bind:checked
|
|
45
|
+
{disabled}
|
|
46
|
+
{...rest}
|
|
47
|
+
/>
|
|
48
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
interface Props extends Omit<HTMLInputAttributes, 'type'> {
|
|
3
|
+
/** Checked state */
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
/** Label text */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Disabled state */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Element reference for bind:this */
|
|
10
|
+
element?: HTMLInputElement;
|
|
11
|
+
}
|
|
12
|
+
declare const Toggle: import("svelte").Component<Props, {}, "element" | "checked">;
|
|
13
|
+
type Toggle = ReturnType<typeof Toggle>;
|
|
14
|
+
export default Toggle;
|