@ibis-design/svelte 0.2.0 → 0.6.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 +12 -2
- package/dist/components/buttons/Button.svelte +106 -0
- package/dist/components/buttons/Button.svelte.d.ts +69 -0
- package/dist/components/buttons/DropdownButton.svelte +91 -0
- package/dist/components/buttons/DropdownButton.svelte.d.ts +33 -0
- package/dist/components/buttons/PillTab.svelte +84 -0
- package/dist/components/buttons/PillTab.svelte.d.ts +55 -0
- package/dist/components/buttons/button.css +193 -0
- package/dist/components/buttons/dropdownButton.css +82 -0
- package/dist/components/buttons/pillTab.css +59 -0
- package/dist/components/containers/Banner.svelte +73 -0
- package/dist/components/containers/Banner.svelte.d.ts +16 -0
- package/dist/components/containers/Card.svelte +34 -0
- package/dist/components/containers/Card.svelte.d.ts +14 -0
- package/dist/components/containers/PillTabs.svelte +22 -0
- package/dist/components/containers/PillTabs.svelte.d.ts +6 -0
- package/dist/components/containers/TipIndicator.svelte +78 -0
- package/dist/components/containers/TipIndicator.svelte.d.ts +28 -0
- package/dist/components/containers/Toaster.svelte +75 -0
- package/dist/components/containers/Toaster.svelte.d.ts +16 -0
- package/dist/components/containers/Tooltip.svelte.d.ts +26 -0
- package/dist/components/containers/banner.css +155 -0
- package/dist/components/containers/tipIndicator.css +79 -0
- package/dist/components/containers/toaster.css +137 -0
- package/dist/components/containers/tooltip.css +0 -0
- package/dist/components/inputs/.gitkeep +0 -0
- package/dist/components/inputs/Checkbox.svelte +95 -0
- package/dist/components/inputs/Checkbox.svelte.d.ts +33 -0
- package/dist/components/inputs/Chips.svelte +104 -0
- package/dist/components/inputs/Chips.svelte.d.ts +48 -0
- package/dist/components/inputs/Dropdown.svelte +83 -0
- package/dist/components/inputs/Dropdown.svelte.d.ts +15 -0
- package/dist/components/inputs/Radio.svelte +109 -0
- package/dist/components/inputs/Radio.svelte.d.ts +49 -0
- package/dist/components/inputs/Switch.svelte +45 -0
- package/dist/components/inputs/Switch.svelte.d.ts +21 -0
- package/dist/components/inputs/TextArea.svelte +65 -0
- package/dist/components/inputs/TextArea.svelte.d.ts +14 -0
- package/dist/components/inputs/TextInput.svelte +273 -0
- package/dist/components/inputs/TextInput.svelte.d.ts +140 -0
- package/dist/components/inputs/TextLink.svelte +102 -0
- package/dist/components/inputs/TextLink.svelte.d.ts +21 -0
- package/dist/components/inputs/checkbox.css +103 -0
- package/dist/components/inputs/chips.css +76 -0
- package/dist/components/inputs/dropdown.css +106 -0
- package/dist/components/inputs/radio.css +108 -0
- package/dist/components/inputs/switch.css +68 -0
- package/dist/components/inputs/textInput.css +152 -0
- package/dist/components/inputs/textarea.css +91 -0
- package/dist/components/inputs/textlink.css +163 -0
- package/dist/index.d.ts +21 -8
- package/dist/index.js +36 -2000
- package/dist/layouts/AppLayout.svelte +83 -0
- package/dist/layouts/AppLayout.svelte.d.ts +20 -0
- package/dist/layouts/AuthLayout.svelte +63 -0
- package/dist/layouts/AuthLayout.svelte.d.ts +18 -0
- package/dist/layouts/DashboardLayout.svelte +88 -0
- package/dist/layouts/DashboardLayout.svelte.d.ts +20 -0
- package/dist/types/button.js +5 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +5 -0
- package/dist/types/layout.d.ts +1 -1
- package/dist/types/layout.js +1 -0
- package/package.json +49 -44
- package/dist/index.css +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/components/buttons/Button.svelte.d.ts +0 -1
- package/dist/lib/components/buttons/DropdownButton.svelte.d.ts +0 -1
- package/dist/lib/components/containers/Card.svelte.d.ts +0 -1
- package/dist/lib/layouts/AppLayout.svelte.d.ts +0 -1
- package/dist/lib/layouts/AuthLayout.svelte.d.ts +0 -1
- package/dist/lib/layouts/DashboardLayout.svelte.d.ts +0 -1
- /package/dist/{types/input.d.ts → components/containers/Tooltip.svelte} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "./radio.css";
|
|
2
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends HTMLInputAttributes {
|
|
4
|
+
/**
|
|
5
|
+
* The text label displayed next to the radio button, describing its purpose or option.
|
|
6
|
+
*/
|
|
7
|
+
label?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The value associated with the radio button.
|
|
11
|
+
*
|
|
12
|
+
* Determines which option is selected within a group of radio buttons.
|
|
13
|
+
*
|
|
14
|
+
* @default ""
|
|
15
|
+
*/
|
|
16
|
+
value: string | number;
|
|
17
|
+
/**
|
|
18
|
+
* The name of the radio button group.
|
|
19
|
+
*
|
|
20
|
+
* Radio buttons with the same `name` are grouped together, allowing only one to be selected at a time.
|
|
21
|
+
*
|
|
22
|
+
* @default undefined
|
|
23
|
+
*/
|
|
24
|
+
group?: string | number;
|
|
25
|
+
/**
|
|
26
|
+
* Determines the size of the radio button input.
|
|
27
|
+
*
|
|
28
|
+
* @default "md"
|
|
29
|
+
*/
|
|
30
|
+
inputSize?: "sm" | "md" | "lg";
|
|
31
|
+
/**
|
|
32
|
+
* Disables the radio button, preventing user interaction and applying disabled styles.
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Marks the radio button as invalid, applying error styles and showing error messages if provided.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
invalid?: boolean;
|
|
43
|
+
description?: string;
|
|
44
|
+
error?: string;
|
|
45
|
+
helpText?: string;
|
|
46
|
+
}
|
|
47
|
+
declare const Radio: import("svelte").Component<Props, {}, "group">;
|
|
48
|
+
type Radio = ReturnType<typeof Radio>;
|
|
49
|
+
export default Radio;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./switch.css";
|
|
3
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLInputAttributes {
|
|
6
|
+
id?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Determines whether the Switch is in the "on" (checked) or "off" (unchecked) state.
|
|
10
|
+
*
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Disables the Switch, preventing user interaction and applying disabled styles.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let { id, label, checked = $bindable(false), disabled = false, ...rest }: Props = $props();
|
|
23
|
+
|
|
24
|
+
const fallbackId = `ibis-switch-${Math.random().toString(36).slice(2)}`;
|
|
25
|
+
const inputId = $derived(id ?? fallbackId);
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div class="ibis-switch {disabled ? 'ibis-switch--disabled' : ''}">
|
|
29
|
+
<label class="ibis-switch__control" for={inputId}>
|
|
30
|
+
<input
|
|
31
|
+
{...rest}
|
|
32
|
+
id={inputId}
|
|
33
|
+
type="checkbox"
|
|
34
|
+
bind:checked
|
|
35
|
+
{disabled}
|
|
36
|
+
class="ibis-switch__input" />
|
|
37
|
+
<span class="ibis-switch__track">
|
|
38
|
+
<span class="ibis-switch__thumb"></span>
|
|
39
|
+
</span>
|
|
40
|
+
|
|
41
|
+
{#if label}
|
|
42
|
+
<span class="ibis-switch__label">{label}</span>
|
|
43
|
+
{/if}
|
|
44
|
+
</label>
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./switch.css";
|
|
2
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends HTMLInputAttributes {
|
|
4
|
+
id?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Determines whether the Switch is in the "on" (checked) or "off" (unchecked) state.
|
|
8
|
+
*
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Disables the Switch, preventing user interaction and applying disabled styles.
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const Switch: import("svelte").Component<Props, {}, "checked">;
|
|
20
|
+
type Switch = ReturnType<typeof Switch>;
|
|
21
|
+
export default Switch;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./textarea.css";
|
|
3
|
+
import type { HTMLTextareaAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
interface Props extends HTMLTextareaAttributes {
|
|
6
|
+
label?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
inputSize?: "sm" | "md" | "lg";
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
invalid?: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
rows?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
id,
|
|
17
|
+
label,
|
|
18
|
+
placeholder,
|
|
19
|
+
value = $bindable(""),
|
|
20
|
+
inputSize = "md",
|
|
21
|
+
disabled = false,
|
|
22
|
+
loading = false,
|
|
23
|
+
invalid = false,
|
|
24
|
+
error,
|
|
25
|
+
rows = 5,
|
|
26
|
+
...rest
|
|
27
|
+
}: Props = $props();
|
|
28
|
+
|
|
29
|
+
const fallbackId = `ibis-textarea-${Math.random().toString(36).slice(2)}`;
|
|
30
|
+
let textareaId = $derived(id ?? fallbackId);
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<div
|
|
34
|
+
class="ibis-input
|
|
35
|
+
ibis-input--{inputSize}
|
|
36
|
+
{disabled ? 'ibis-input--disabled' : ''}
|
|
37
|
+
{loading ? 'ibis-input--loading' : ''}
|
|
38
|
+
{invalid ? 'ibis-input--invalid' : ''}">
|
|
39
|
+
{#if label}
|
|
40
|
+
<label class="ibis-input__label" for={textareaId}>{label}</label>
|
|
41
|
+
{/if}
|
|
42
|
+
|
|
43
|
+
<div class="ibis-input__wrapper">
|
|
44
|
+
<textarea
|
|
45
|
+
{...rest}
|
|
46
|
+
id={textareaId}
|
|
47
|
+
bind:value
|
|
48
|
+
{placeholder}
|
|
49
|
+
{disabled}
|
|
50
|
+
{rows}
|
|
51
|
+
aria-invalid={invalid}
|
|
52
|
+
aria-busy={loading}
|
|
53
|
+
class="ibis-input__field"></textarea>
|
|
54
|
+
|
|
55
|
+
{#if loading}
|
|
56
|
+
<span class="ibis-input__loader" aria-hidden="true"></span>
|
|
57
|
+
{/if}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{#if invalid && error}
|
|
61
|
+
<div class="ibis-input__error" role="alert">
|
|
62
|
+
{error}
|
|
63
|
+
</div>
|
|
64
|
+
{/if}
|
|
65
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./textarea.css";
|
|
2
|
+
import type { HTMLTextareaAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends HTMLTextareaAttributes {
|
|
4
|
+
label?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
inputSize?: "sm" | "md" | "lg";
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
invalid?: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
rows?: number;
|
|
11
|
+
}
|
|
12
|
+
declare const TextArea: import("svelte").Component<Props, {}, "value">;
|
|
13
|
+
type TextArea = ReturnType<typeof TextArea>;
|
|
14
|
+
export default TextArea;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import "./textInput.css";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
5
|
+
|
|
6
|
+
interface Props extends HTMLInputAttributes {
|
|
7
|
+
/**
|
|
8
|
+
* The label for the input field.
|
|
9
|
+
*
|
|
10
|
+
* Provides a descriptive text for the input.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <TextInput label="Username" placeholder="Enter your username" />
|
|
14
|
+
*/
|
|
15
|
+
label?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The size of the input field.
|
|
18
|
+
*
|
|
19
|
+
* @default "md"
|
|
20
|
+
* @example
|
|
21
|
+
* - `sm`: <TextInput inputSize="sm" />
|
|
22
|
+
* - `md`: <TextInput inputSize="md" />
|
|
23
|
+
* - `lg`: <TextInput inputSize="lg" />
|
|
24
|
+
*/
|
|
25
|
+
inputSize?: "sm" | "md" | "lg";
|
|
26
|
+
/**
|
|
27
|
+
* Shows a loading spinner inside the input field and disables interaction.
|
|
28
|
+
*
|
|
29
|
+
* Use when the input is waiting for async data, such as validating a field
|
|
30
|
+
* against a server or fetching autocomplete suggestions.
|
|
31
|
+
*
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
loading?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Denotes the input field as invalid.
|
|
37
|
+
*
|
|
38
|
+
* @default false
|
|
39
|
+
* @example
|
|
40
|
+
* <TextInput invalid={true} error="Please enter a valid email address." />
|
|
41
|
+
*/
|
|
42
|
+
invalid?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* A short description displayed below the label.
|
|
45
|
+
*
|
|
46
|
+
* Use to provide additional context about what the field expects,
|
|
47
|
+
* such as format requirements or usage guidance.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* <TextInput label="Username" description="This will be publicly visible." />
|
|
51
|
+
*/
|
|
52
|
+
description?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The error message displayed when the input is invalid.
|
|
55
|
+
*
|
|
56
|
+
* Only rendered when both `invalid` is true and `error` is provided.
|
|
57
|
+
* Announced to screen readers via `role="alert"`.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* <TextInput invalid={true} error="This field is required." />
|
|
61
|
+
*/
|
|
62
|
+
error?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Helper text displayed below the input field.
|
|
65
|
+
*
|
|
66
|
+
* Use to provide supplementary guidance such as formatting hints or
|
|
67
|
+
* privacy notes. Not shown when the input is in an invalid state.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* <TextInput helpText="We'll never share your email with anyone else." />
|
|
71
|
+
*/
|
|
72
|
+
helpText?: string;
|
|
73
|
+
/**
|
|
74
|
+
* A Svelte Snippet rendered inside the input field, before the text.
|
|
75
|
+
*
|
|
76
|
+
* Use for complex content like icons or custom markup.
|
|
77
|
+
* For plain text, use `prefixText` instead.
|
|
78
|
+
* Cannot be used together with `prependSnippet`.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* {#snippet prefix()}<SearchIcon />{/snippet}
|
|
82
|
+
* <TextInput prefixSnippet={prefix} />
|
|
83
|
+
*/
|
|
84
|
+
prefixSnippet?: Snippet;
|
|
85
|
+
/**
|
|
86
|
+
* A Svelte Snippet rendered inside the input field, after the text.
|
|
87
|
+
*
|
|
88
|
+
* Use for complex content like icons or custom markup.
|
|
89
|
+
* For plain text, use `suffixText` instead.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* {#snippet suffix()}<EyeIcon />{/snippet}
|
|
93
|
+
* <TextInput suffixSnippet={suffix} />
|
|
94
|
+
*/
|
|
95
|
+
suffixSnippet?: Snippet;
|
|
96
|
+
/**
|
|
97
|
+
* A Svelte Snippet rendered outside and before the input field as an attached block.
|
|
98
|
+
*
|
|
99
|
+
* Use for complex content like icons or custom markup.
|
|
100
|
+
* For plain text, use `prependText` instead.
|
|
101
|
+
* Cannot be used together with `prefixSnippet`.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* {#snippet prepend()}<span>https://</span>{/snippet}
|
|
105
|
+
* <TextInput prependSnippet={prepend} />
|
|
106
|
+
*/
|
|
107
|
+
prependSnippet?: Snippet;
|
|
108
|
+
/**
|
|
109
|
+
* Plain text rendered inside the input field, before the text.
|
|
110
|
+
*
|
|
111
|
+
* Use for simple symbols or short strings like `$` or `@`.
|
|
112
|
+
* For complex content, use `prefixSnippet` instead.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* <TextInput prefixText="$" placeholder="0.00" />
|
|
116
|
+
*/
|
|
117
|
+
prefixText?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Plain text rendered inside the input field, after the text.
|
|
120
|
+
*
|
|
121
|
+
* Use for simple strings like units or currency codes, e.g. `EUR` or `kg`.
|
|
122
|
+
* For complex content, use `suffixSnippet` instead.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* <TextInput suffixText="EUR" placeholder="0.00" />
|
|
126
|
+
*/
|
|
127
|
+
suffixText?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Plain text rendered outside and before the input field as an attached block.
|
|
130
|
+
*
|
|
131
|
+
* Use for simple strings like `https://` or `+1`.
|
|
132
|
+
* For complex content, use `prependSnippet` instead.
|
|
133
|
+
* Cannot be used together with `prefixText`.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* <TextInput prependText="https://" placeholder="example.com" />
|
|
137
|
+
*/
|
|
138
|
+
prependText?: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
let {
|
|
142
|
+
id,
|
|
143
|
+
label,
|
|
144
|
+
placeholder,
|
|
145
|
+
value = $bindable(""),
|
|
146
|
+
type = "text",
|
|
147
|
+
inputSize = "md",
|
|
148
|
+
disabled = false,
|
|
149
|
+
loading = false,
|
|
150
|
+
invalid = false,
|
|
151
|
+
description,
|
|
152
|
+
error,
|
|
153
|
+
helpText,
|
|
154
|
+
prefixSnippet,
|
|
155
|
+
suffixSnippet,
|
|
156
|
+
prependSnippet,
|
|
157
|
+
prefixText,
|
|
158
|
+
suffixText,
|
|
159
|
+
prependText,
|
|
160
|
+
...rest
|
|
161
|
+
}: Props = $props();
|
|
162
|
+
|
|
163
|
+
const fallbackId = `ibis-input-${Math.random().toString(36).slice(2)}`;
|
|
164
|
+
const inputId = $derived(id ?? fallbackId);
|
|
165
|
+
|
|
166
|
+
const hasPrepend = $derived(!!prependSnippet || !!prependText);
|
|
167
|
+
|
|
168
|
+
$effect(() => {
|
|
169
|
+
if (prependSnippet && prefixSnippet) {
|
|
170
|
+
console.warn("Use either prependSnippet OR prefixSnippet, not both.");
|
|
171
|
+
}
|
|
172
|
+
if (prependSnippet && prependText) {
|
|
173
|
+
console.warn("prependSnippet takes priority over prependText when both are provided.");
|
|
174
|
+
}
|
|
175
|
+
if (prefixSnippet && prefixText) {
|
|
176
|
+
console.warn("prefixSnippet takes priority over prefixText when both are provided.");
|
|
177
|
+
}
|
|
178
|
+
if (suffixSnippet && suffixText) {
|
|
179
|
+
console.warn("suffixSnippet takes priority over suffixText when both are provided.");
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
</script>
|
|
183
|
+
|
|
184
|
+
<div
|
|
185
|
+
class="ibis-input
|
|
186
|
+
ibis-input--{inputSize}
|
|
187
|
+
{disabled ? 'ibis-input--disabled' : ''}
|
|
188
|
+
{loading ? 'ibis-input--loading' : ''}
|
|
189
|
+
{invalid ? 'ibis-input--invalid' : ''}">
|
|
190
|
+
{#if label}
|
|
191
|
+
<div class="ibis-input__label-wrapper">
|
|
192
|
+
<label class="ibis-input__label" for={inputId}>{label}</label>
|
|
193
|
+
|
|
194
|
+
{#if description}
|
|
195
|
+
<div class="ibis-input__description">
|
|
196
|
+
{description}
|
|
197
|
+
</div>
|
|
198
|
+
{/if}
|
|
199
|
+
</div>
|
|
200
|
+
{/if}
|
|
201
|
+
|
|
202
|
+
<div class="ibis-input__wrapper {hasPrepend ? 'ibis-input__wrapper--with-prepend' : ''}">
|
|
203
|
+
{#if prependSnippet || prependText}
|
|
204
|
+
<div class="ibis-input__prepend">
|
|
205
|
+
{#if prependSnippet}
|
|
206
|
+
{@render prependSnippet()}
|
|
207
|
+
{:else}
|
|
208
|
+
{prependText}
|
|
209
|
+
{/if}
|
|
210
|
+
</div>
|
|
211
|
+
{/if}
|
|
212
|
+
|
|
213
|
+
<div class="ibis-input__field-wrapper">
|
|
214
|
+
{#if prefixSnippet || prefixText}
|
|
215
|
+
<span class="ibis-input__prefix" aria-hidden="true">
|
|
216
|
+
{#if prefixSnippet}
|
|
217
|
+
{@render prefixSnippet?.()}
|
|
218
|
+
{:else}
|
|
219
|
+
{prefixText}
|
|
220
|
+
{/if}
|
|
221
|
+
</span>
|
|
222
|
+
{/if}
|
|
223
|
+
|
|
224
|
+
<input
|
|
225
|
+
{...rest}
|
|
226
|
+
id={inputId}
|
|
227
|
+
{type}
|
|
228
|
+
{placeholder}
|
|
229
|
+
bind:value
|
|
230
|
+
{disabled}
|
|
231
|
+
aria-invalid={invalid}
|
|
232
|
+
aria-busy={loading}
|
|
233
|
+
class="ibis-input__field" />
|
|
234
|
+
|
|
235
|
+
{#if suffixSnippet || suffixText}
|
|
236
|
+
<span class="ibis-input__suffix" aria-hidden="true">
|
|
237
|
+
{#if suffixSnippet}
|
|
238
|
+
{@render suffixSnippet?.()}
|
|
239
|
+
{:else}
|
|
240
|
+
{suffixText}
|
|
241
|
+
{/if}
|
|
242
|
+
</span>
|
|
243
|
+
{/if}
|
|
244
|
+
|
|
245
|
+
{#if loading}
|
|
246
|
+
<span class="ibis-input__loader" aria-hidden="true"></span>
|
|
247
|
+
{/if}
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
{#if invalid && error}
|
|
252
|
+
<div class="ibis-input__error" role="alert">
|
|
253
|
+
<svg
|
|
254
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
255
|
+
width="12"
|
|
256
|
+
height="12"
|
|
257
|
+
color="#b70c00"
|
|
258
|
+
fill="none"
|
|
259
|
+
viewBox="0 0 24 24"
|
|
260
|
+
><path
|
|
261
|
+
d="M22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12ZM12 6.25C12.4142 6.25 12.75 6.58579 12.75 7V13C12.75 13.4142 12.4142 13.75 12 13.75C11.5858 13.75 11.25 13.4142 11.25 13V7C11.25 6.58579 11.5858 6.25 12 6.25ZM12 17C12.5523 17 13 16.5523 13 16C13 15.4477 12.5523 15 12 15C11.4477 15 11 15.4477 11 16C11 16.5523 11.4477 17 12 17Z"
|
|
262
|
+
fill="currentColor"
|
|
263
|
+
fill-rule="evenodd"
|
|
264
|
+
clip-rule="evenodd"></path
|
|
265
|
+
></svg>
|
|
266
|
+
{error}
|
|
267
|
+
</div>
|
|
268
|
+
{:else if helpText}
|
|
269
|
+
<div class="ibis-input__help">
|
|
270
|
+
{helpText}
|
|
271
|
+
</div>
|
|
272
|
+
{/if}
|
|
273
|
+
</div>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import "./textInput.css";
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLInputAttributes } from "svelte/elements";
|
|
4
|
+
interface Props extends HTMLInputAttributes {
|
|
5
|
+
/**
|
|
6
|
+
* The label for the input field.
|
|
7
|
+
*
|
|
8
|
+
* Provides a descriptive text for the input.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <TextInput label="Username" placeholder="Enter your username" />
|
|
12
|
+
*/
|
|
13
|
+
label?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The size of the input field.
|
|
16
|
+
*
|
|
17
|
+
* @default "md"
|
|
18
|
+
* @example
|
|
19
|
+
* - `sm`: <TextInput inputSize="sm" />
|
|
20
|
+
* - `md`: <TextInput inputSize="md" />
|
|
21
|
+
* - `lg`: <TextInput inputSize="lg" />
|
|
22
|
+
*/
|
|
23
|
+
inputSize?: "sm" | "md" | "lg";
|
|
24
|
+
/**
|
|
25
|
+
* Shows a loading spinner inside the input field and disables interaction.
|
|
26
|
+
*
|
|
27
|
+
* Use when the input is waiting for async data, such as validating a field
|
|
28
|
+
* against a server or fetching autocomplete suggestions.
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Denotes the input field as invalid.
|
|
35
|
+
*
|
|
36
|
+
* @default false
|
|
37
|
+
* @example
|
|
38
|
+
* <TextInput invalid={true} error="Please enter a valid email address." />
|
|
39
|
+
*/
|
|
40
|
+
invalid?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* A short description displayed below the label.
|
|
43
|
+
*
|
|
44
|
+
* Use to provide additional context about what the field expects,
|
|
45
|
+
* such as format requirements or usage guidance.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* <TextInput label="Username" description="This will be publicly visible." />
|
|
49
|
+
*/
|
|
50
|
+
description?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The error message displayed when the input is invalid.
|
|
53
|
+
*
|
|
54
|
+
* Only rendered when both `invalid` is true and `error` is provided.
|
|
55
|
+
* Announced to screen readers via `role="alert"`.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* <TextInput invalid={true} error="This field is required." />
|
|
59
|
+
*/
|
|
60
|
+
error?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Helper text displayed below the input field.
|
|
63
|
+
*
|
|
64
|
+
* Use to provide supplementary guidance such as formatting hints or
|
|
65
|
+
* privacy notes. Not shown when the input is in an invalid state.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* <TextInput helpText="We'll never share your email with anyone else." />
|
|
69
|
+
*/
|
|
70
|
+
helpText?: string;
|
|
71
|
+
/**
|
|
72
|
+
* A Svelte Snippet rendered inside the input field, before the text.
|
|
73
|
+
*
|
|
74
|
+
* Use for complex content like icons or custom markup.
|
|
75
|
+
* For plain text, use `prefixText` instead.
|
|
76
|
+
* Cannot be used together with `prependSnippet`.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* {#snippet prefix()}<SearchIcon />{/snippet}
|
|
80
|
+
* <TextInput prefixSnippet={prefix} />
|
|
81
|
+
*/
|
|
82
|
+
prefixSnippet?: Snippet;
|
|
83
|
+
/**
|
|
84
|
+
* A Svelte Snippet rendered inside the input field, after the text.
|
|
85
|
+
*
|
|
86
|
+
* Use for complex content like icons or custom markup.
|
|
87
|
+
* For plain text, use `suffixText` instead.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* {#snippet suffix()}<EyeIcon />{/snippet}
|
|
91
|
+
* <TextInput suffixSnippet={suffix} />
|
|
92
|
+
*/
|
|
93
|
+
suffixSnippet?: Snippet;
|
|
94
|
+
/**
|
|
95
|
+
* A Svelte Snippet rendered outside and before the input field as an attached block.
|
|
96
|
+
*
|
|
97
|
+
* Use for complex content like icons or custom markup.
|
|
98
|
+
* For plain text, use `prependText` instead.
|
|
99
|
+
* Cannot be used together with `prefixSnippet`.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* {#snippet prepend()}<span>https://</span>{/snippet}
|
|
103
|
+
* <TextInput prependSnippet={prepend} />
|
|
104
|
+
*/
|
|
105
|
+
prependSnippet?: Snippet;
|
|
106
|
+
/**
|
|
107
|
+
* Plain text rendered inside the input field, before the text.
|
|
108
|
+
*
|
|
109
|
+
* Use for simple symbols or short strings like `$` or `@`.
|
|
110
|
+
* For complex content, use `prefixSnippet` instead.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* <TextInput prefixText="$" placeholder="0.00" />
|
|
114
|
+
*/
|
|
115
|
+
prefixText?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Plain text rendered inside the input field, after the text.
|
|
118
|
+
*
|
|
119
|
+
* Use for simple strings like units or currency codes, e.g. `EUR` or `kg`.
|
|
120
|
+
* For complex content, use `suffixSnippet` instead.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* <TextInput suffixText="EUR" placeholder="0.00" />
|
|
124
|
+
*/
|
|
125
|
+
suffixText?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Plain text rendered outside and before the input field as an attached block.
|
|
128
|
+
*
|
|
129
|
+
* Use for simple strings like `https://` or `+1`.
|
|
130
|
+
* For complex content, use `prependSnippet` instead.
|
|
131
|
+
* Cannot be used together with `prefixText`.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* <TextInput prependText="https://" placeholder="example.com" />
|
|
135
|
+
*/
|
|
136
|
+
prependText?: string;
|
|
137
|
+
}
|
|
138
|
+
declare const TextInput: import("svelte").Component<Props, {}, "value">;
|
|
139
|
+
type TextInput = ReturnType<typeof TextInput>;
|
|
140
|
+
export default TextInput;
|