@mrintel/villain-ui 0.3.0 → 0.7.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/LICENSE +21 -21
- package/README.md +3490 -1296
- package/dist/components/buttons/Button.svelte +27 -33
- package/dist/components/buttons/Button.svelte.d.ts +4 -1
- package/dist/components/buttons/ButtonGroup.svelte +17 -30
- package/dist/components/buttons/FloatingActionButton.svelte +20 -44
- package/dist/components/buttons/FloatingActionButton.svelte.d.ts +2 -1
- package/dist/components/buttons/IconButton.svelte +23 -53
- package/dist/components/buttons/IconButton.svelte.d.ts +2 -1
- package/dist/components/buttons/LinkButton.svelte +24 -37
- package/dist/components/buttons/LinkButton.svelte.d.ts +4 -1
- package/dist/components/buttons/buttonClasses.d.ts +5 -0
- package/dist/components/buttons/buttonClasses.js +8 -3
- package/dist/components/cards/Card.svelte +54 -46
- package/dist/components/cards/Card.svelte.d.ts +9 -2
- package/dist/components/cards/Container.svelte +17 -33
- package/dist/components/cards/Divider.svelte +36 -52
- package/dist/components/cards/Divider.svelte.d.ts +2 -0
- package/dist/components/cards/Grid.svelte +55 -44
- package/dist/components/cards/Panel.svelte +18 -32
- package/dist/components/cards/Panel.svelte.d.ts +2 -1
- package/dist/components/cards/SectionHeader.svelte +24 -38
- package/dist/components/cards/SectionHeader.svelte.d.ts +1 -0
- package/dist/components/data/Avatar.svelte +48 -67
- package/dist/components/data/Badge.svelte +45 -32
- package/dist/components/data/Badge.svelte.d.ts +7 -1
- package/dist/components/data/CalendarGrid.svelte +433 -0
- package/dist/components/data/CalendarGrid.svelte.d.ts +25 -0
- package/dist/components/data/CalendarGrid.types.d.ts +7 -0
- package/dist/components/data/CalendarGrid.types.js +1 -0
- package/dist/components/data/CodeBlock.svelte +119 -121
- package/dist/components/data/CodeBlock.svelte.d.ts +8 -0
- package/dist/components/data/List.svelte +87 -64
- package/dist/components/data/List.svelte.d.ts +7 -0
- package/dist/components/data/Pagination.svelte +121 -123
- package/dist/components/data/Pagination.svelte.d.ts +5 -0
- package/dist/components/data/Sparkline.svelte +117 -0
- package/dist/components/data/Sparkline.svelte.d.ts +43 -0
- package/dist/components/data/Stat.svelte +92 -103
- package/dist/components/data/Table.svelte +443 -76
- package/dist/components/data/Table.svelte.d.ts +23 -2
- package/dist/components/data/Table.types.d.ts +14 -0
- package/dist/components/data/Table.types.js +1 -0
- package/dist/components/data/Tag.svelte +51 -53
- package/dist/components/data/Tag.svelte.d.ts +5 -1
- package/dist/components/data/index.d.ts +4 -0
- package/dist/components/data/index.js +2 -0
- package/dist/components/forms/Checkbox.svelte +39 -51
- package/dist/components/forms/Checkbox.svelte.d.ts +3 -1
- package/dist/components/forms/DatePicker.svelte +61 -0
- package/dist/components/forms/DatePicker.svelte.d.ts +15 -0
- package/dist/components/forms/DateTimePicker.svelte +63 -0
- package/dist/components/forms/DateTimePicker.svelte.d.ts +16 -0
- package/dist/components/forms/FileUpload.svelte +136 -164
- package/dist/components/forms/FileUpload.svelte.d.ts +1 -0
- package/dist/components/forms/Input.svelte +284 -57
- package/dist/components/forms/Input.svelte.d.ts +10 -3
- package/dist/components/forms/InputGroup.svelte +7 -7
- package/dist/components/forms/RadioGroup.svelte +77 -87
- package/dist/components/forms/RadioGroup.svelte.d.ts +3 -1
- package/dist/components/forms/RangeSlider.svelte +90 -116
- package/dist/components/forms/Select.svelte +106 -71
- package/dist/components/forms/Select.svelte.d.ts +3 -1
- package/dist/components/forms/Step.svelte +25 -0
- package/dist/components/forms/Step.svelte.d.ts +12 -0
- package/dist/components/forms/StepContext.d.ts +3 -0
- package/dist/components/forms/StepContext.js +5 -0
- package/dist/components/forms/Stepper.types.d.ts +37 -0
- package/dist/components/forms/Stepper.types.js +1 -0
- package/dist/components/forms/StepperForm.svelte +183 -0
- package/dist/components/forms/StepperForm.svelte.d.ts +17 -0
- package/dist/components/forms/Switch.svelte +44 -56
- package/dist/components/forms/Switch.svelte.d.ts +3 -1
- package/dist/components/forms/Textarea.svelte +52 -57
- package/dist/components/forms/Textarea.svelte.d.ts +3 -1
- package/dist/components/forms/TimePicker.svelte +63 -0
- package/dist/components/forms/TimePicker.svelte.d.ts +16 -0
- package/dist/components/forms/formClasses.d.ts +3 -0
- package/dist/components/forms/formClasses.js +3 -0
- package/dist/components/forms/index.d.ts +6 -0
- package/dist/components/forms/index.js +5 -0
- package/dist/components/navigation/Breadcrumbs.svelte +56 -59
- package/dist/components/navigation/Breadcrumbs.svelte.d.ts +1 -0
- package/dist/components/navigation/ContextMenu.svelte +133 -83
- package/dist/components/navigation/ContextMenu.svelte.d.ts +8 -1
- package/dist/components/navigation/DropdownMenu.svelte +139 -80
- package/dist/components/navigation/DropdownMenu.svelte.d.ts +8 -1
- package/dist/components/navigation/Menu.svelte +72 -48
- package/dist/components/navigation/Navbar.svelte +111 -32
- package/dist/components/navigation/Navbar.svelte.d.ts +6 -0
- package/dist/components/navigation/Sidebar.svelte +236 -35
- package/dist/components/navigation/Sidebar.svelte.d.ts +2 -0
- package/dist/components/navigation/Stepper.svelte +204 -0
- package/dist/components/navigation/Stepper.svelte.d.ts +34 -0
- package/dist/components/navigation/Tabs.svelte +86 -54
- package/dist/components/navigation/Tabs.svelte.d.ts +5 -1
- package/dist/components/navigation/index.d.ts +1 -0
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/overlays/Alert.svelte +81 -99
- package/dist/components/overlays/Alert.svelte.d.ts +5 -1
- package/dist/components/overlays/CommandPalette.svelte +182 -217
- package/dist/components/overlays/Drawer.svelte +158 -167
- package/dist/components/overlays/Drawer.svelte.d.ts +3 -1
- package/dist/components/overlays/Dropdown.svelte +62 -30
- package/dist/components/overlays/Dropdown.svelte.d.ts +2 -0
- package/dist/components/overlays/Modal.svelte +125 -130
- package/dist/components/overlays/Modal.svelte.d.ts +3 -1
- package/dist/components/overlays/Popover.svelte +106 -131
- package/dist/components/overlays/ProgressBar.svelte +29 -45
- package/dist/components/overlays/SkeletonLoader.svelte +66 -82
- package/dist/components/overlays/Spinner.svelte +33 -43
- package/dist/components/overlays/Toast.svelte +111 -140
- package/dist/components/overlays/Toast.svelte.d.ts +3 -0
- package/dist/components/overlays/Tooltip.svelte +94 -115
- package/dist/components/overlays/Tooltip.svelte.d.ts +3 -1
- package/dist/components/typography/Code.svelte +10 -14
- package/dist/components/typography/Heading.svelte +15 -22
- package/dist/components/typography/Heading.svelte.d.ts +1 -0
- package/dist/components/typography/Text.svelte +21 -24
- package/dist/components/typography/Text.svelte.d.ts +2 -1
- package/dist/components/utilities/Accordion.svelte +54 -67
- package/dist/components/utilities/Accordion.svelte.d.ts +4 -1
- package/dist/components/utilities/Carousel.svelte +124 -152
- package/dist/components/utilities/Collapse.svelte +46 -60
- package/dist/components/utilities/Hero.svelte +42 -0
- package/dist/components/utilities/Hero.svelte.d.ts +10 -0
- package/dist/components/utilities/Portal.svelte +47 -72
- package/dist/components/utilities/ScrollArea.svelte +33 -41
- package/dist/components/utilities/SystemConsole.svelte +310 -0
- package/dist/components/utilities/SystemConsole.svelte.d.ts +20 -0
- package/dist/components/utilities/SystemInterface.svelte +726 -0
- package/dist/components/utilities/SystemInterface.svelte.d.ts +19 -0
- package/dist/components/utilities/index.d.ts +4 -0
- package/dist/components/utilities/index.js +3 -0
- package/dist/components/utilities/utilities.types.d.ts +46 -0
- package/dist/components/utilities/utilities.types.js +4 -0
- package/dist/index.d.ts +57 -5
- package/dist/index.js +5 -5
- package/dist/theme.css +2889 -218
- package/package.json +83 -76
|
@@ -1,57 +1,284 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{
|
|
1
|
+
<script lang="ts">import { createId } from '../../lib/internal/id.js';
|
|
2
|
+
import { baseInputClasses, focusClasses, disabledClasses, } from './formClasses';
|
|
3
|
+
let { type = 'text', name, value = $bindable(''), placeholder, disabled = false, error = false, label, id = createId('input'), oninput, iconBefore, iconAfter, validate, validationMessage, showValidation = true, class: className = '', } = $props();
|
|
4
|
+
// Built-in validation patterns
|
|
5
|
+
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
6
|
+
const urlPattern = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
|
|
7
|
+
const telPattern = /^[\d\s\-\+\(\)]+$/;
|
|
8
|
+
// Validation logic
|
|
9
|
+
let validationError = $state(null);
|
|
10
|
+
function performValidation(val) {
|
|
11
|
+
if (!val || val === '') {
|
|
12
|
+
validationError = null;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
// Custom validation function
|
|
16
|
+
if (validate) {
|
|
17
|
+
const result = validate(val);
|
|
18
|
+
if (result === true) {
|
|
19
|
+
validationError = null;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
else if (typeof result === 'string') {
|
|
23
|
+
validationError = result;
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
validationError = validationMessage || 'Invalid input';
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Built-in validation based on type
|
|
32
|
+
const stringVal = String(val);
|
|
33
|
+
switch (type) {
|
|
34
|
+
case 'email':
|
|
35
|
+
if (!emailPattern.test(stringVal)) {
|
|
36
|
+
validationError = validationMessage || 'Please enter a valid email address';
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
case 'url':
|
|
41
|
+
if (!urlPattern.test(stringVal)) {
|
|
42
|
+
validationError = validationMessage || 'Please enter a valid URL';
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
case 'tel':
|
|
47
|
+
if (!telPattern.test(stringVal)) {
|
|
48
|
+
validationError = validationMessage || 'Please enter a valid phone number';
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
validationError = null;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
// Validate on value change
|
|
57
|
+
$effect(() => {
|
|
58
|
+
if (value !== undefined && value !== '') {
|
|
59
|
+
performValidation(value);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const hasError = $derived(error || (validationError !== null));
|
|
63
|
+
const errorClasses = $derived(hasError ? 'error-state' : '');
|
|
64
|
+
function increment() {
|
|
65
|
+
if (disabled || type !== 'number')
|
|
66
|
+
return;
|
|
67
|
+
value = Number(value || 0) + 1;
|
|
68
|
+
}
|
|
69
|
+
function decrement() {
|
|
70
|
+
if (disabled || type !== 'number')
|
|
71
|
+
return;
|
|
72
|
+
value = Number(value || 0) - 1;
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
{#if label}
|
|
77
|
+
<div>
|
|
78
|
+
<label for={id} class="text-text-soft text-sm mb-2 block">
|
|
79
|
+
{label}
|
|
80
|
+
</label>
|
|
81
|
+
<div class="relative flex items-center">
|
|
82
|
+
<!-- BEFORE ICON -->
|
|
83
|
+
{#if iconBefore}
|
|
84
|
+
<span
|
|
85
|
+
class="absolute left-4 z-10 inline-flex items-center justify-center text-text-soft pointer-events-none"
|
|
86
|
+
>
|
|
87
|
+
{@render iconBefore()}
|
|
88
|
+
</span>
|
|
89
|
+
{/if}
|
|
90
|
+
|
|
91
|
+
<!-- INPUT FIELD -->
|
|
92
|
+
<input
|
|
93
|
+
{type}
|
|
94
|
+
{name}
|
|
95
|
+
{id}
|
|
96
|
+
{placeholder}
|
|
97
|
+
{disabled}
|
|
98
|
+
bind:value
|
|
99
|
+
{oninput}
|
|
100
|
+
class="{baseInputClasses} {focusClasses} {errorClasses} {disabled
|
|
101
|
+
? disabledClasses
|
|
102
|
+
: ''} {className}"
|
|
103
|
+
class:pl-12={iconBefore}
|
|
104
|
+
class:pr-12={iconAfter || type === 'number'}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<!-- AFTER ICON (non-number) -->
|
|
108
|
+
{#if iconAfter && type !== 'number'}
|
|
109
|
+
<span
|
|
110
|
+
class="absolute right-4 z-10 inline-flex items-center justify-center text-text-soft pointer-events-none"
|
|
111
|
+
>
|
|
112
|
+
{@render iconAfter()}
|
|
113
|
+
</span>
|
|
114
|
+
{/if}
|
|
115
|
+
|
|
116
|
+
<!-- CUSTOM ARROWS (NUMBER INPUT ONLY) -->
|
|
117
|
+
{#if type === 'number'}
|
|
118
|
+
<div class="number-arrows">
|
|
119
|
+
<button
|
|
120
|
+
type="button"
|
|
121
|
+
onclick={increment}
|
|
122
|
+
class="arrow-btn arrow-up"
|
|
123
|
+
tabindex="-1"
|
|
124
|
+
>
|
|
125
|
+
▲
|
|
126
|
+
</button>
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
onclick={decrement}
|
|
130
|
+
class="arrow-btn arrow-down"
|
|
131
|
+
tabindex="-1"
|
|
132
|
+
>
|
|
133
|
+
▼
|
|
134
|
+
</button>
|
|
135
|
+
</div>
|
|
136
|
+
{/if}
|
|
137
|
+
</div>
|
|
138
|
+
{#if showValidation && validationError}
|
|
139
|
+
<p class="text-error text-xs mt-1.5">
|
|
140
|
+
{validationError}
|
|
141
|
+
</p>
|
|
142
|
+
{/if}
|
|
143
|
+
</div>
|
|
144
|
+
{:else}
|
|
145
|
+
<div>
|
|
146
|
+
<div class="relative flex items-center">
|
|
147
|
+
{#if iconBefore}
|
|
148
|
+
<span
|
|
149
|
+
class="absolute left-4 z-10 inline-flex items-center justify-center text-text-soft pointer-events-none"
|
|
150
|
+
>
|
|
151
|
+
{@render iconBefore()}
|
|
152
|
+
</span>
|
|
153
|
+
{/if}
|
|
154
|
+
|
|
155
|
+
<input
|
|
156
|
+
{type}
|
|
157
|
+
{name}
|
|
158
|
+
{id}
|
|
159
|
+
{placeholder}
|
|
160
|
+
{disabled}
|
|
161
|
+
bind:value
|
|
162
|
+
{oninput}
|
|
163
|
+
class="{baseInputClasses} {focusClasses} {errorClasses} {disabled
|
|
164
|
+
? disabledClasses
|
|
165
|
+
: ''} {className}"
|
|
166
|
+
class:pl-12={iconBefore}
|
|
167
|
+
class:pr-12={iconAfter || type === 'number'}
|
|
168
|
+
/>
|
|
169
|
+
|
|
170
|
+
{#if iconAfter && type !== 'number'}
|
|
171
|
+
<span
|
|
172
|
+
class="absolute right-4 z-10 inline-flex items-center justify-center text-text-soft pointer-events-none"
|
|
173
|
+
>
|
|
174
|
+
{@render iconAfter()}
|
|
175
|
+
</span>
|
|
176
|
+
{/if}
|
|
177
|
+
|
|
178
|
+
{#if type === 'number'}
|
|
179
|
+
<div class="number-arrows">
|
|
180
|
+
<button
|
|
181
|
+
type="button"
|
|
182
|
+
onclick={increment}
|
|
183
|
+
class="arrow-btn arrow-up"
|
|
184
|
+
tabindex="-1"
|
|
185
|
+
>
|
|
186
|
+
▲
|
|
187
|
+
</button>
|
|
188
|
+
<button
|
|
189
|
+
type="button"
|
|
190
|
+
onclick={decrement}
|
|
191
|
+
class="arrow-btn arrow-down"
|
|
192
|
+
tabindex="-1"
|
|
193
|
+
>
|
|
194
|
+
▼
|
|
195
|
+
</button>
|
|
196
|
+
</div>
|
|
197
|
+
{/if}
|
|
198
|
+
</div>
|
|
199
|
+
{#if showValidation && validationError}
|
|
200
|
+
<p class="text-error text-xs mt-1.5">
|
|
201
|
+
{validationError}
|
|
202
|
+
</p>
|
|
203
|
+
{/if}
|
|
204
|
+
</div>
|
|
205
|
+
{/if}
|
|
206
|
+
|
|
207
|
+
<style>
|
|
208
|
+
.number-arrows {
|
|
209
|
+
position: absolute;
|
|
210
|
+
top: 0;
|
|
211
|
+
right: 0;
|
|
212
|
+
height: 100%;
|
|
213
|
+
width: 2.25rem; /* doesn't overlap your icons */
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-direction: column;
|
|
216
|
+
border-left: 1px solid var(--color-border-strong);
|
|
217
|
+
background: color-mix(in srgb, var(--color-accent) 8%, transparent);
|
|
218
|
+
border-radius: 0 var(--radius-md) var(--radius-md) 0;
|
|
219
|
+
overflow: hidden;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.arrow-btn {
|
|
223
|
+
flex: 1;
|
|
224
|
+
display: flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
justify-content: center;
|
|
227
|
+
background: transparent;
|
|
228
|
+
color: var(--color-text-soft);
|
|
229
|
+
font-size: 0.7rem;
|
|
230
|
+
cursor: pointer;
|
|
231
|
+
transition: all 120ms var(--ease-sharp);
|
|
232
|
+
user-select: none;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.arrow-btn:hover {
|
|
236
|
+
background: var(--color-accent-overlay-20);
|
|
237
|
+
color: var(--color-accent-soft);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.arrow-btn:active {
|
|
241
|
+
background: var(--color-accent-overlay-30);
|
|
242
|
+
color: var(--color-accent);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.arrow-btn:disabled,
|
|
246
|
+
.arrow-btn[disabled] {
|
|
247
|
+
opacity: 0.4;
|
|
248
|
+
cursor: not-allowed;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/* Remove default browser arrows */
|
|
252
|
+
input[type='number']::-webkit-inner-spin-button,
|
|
253
|
+
input[type='number']::-webkit-outer-spin-button {
|
|
254
|
+
-webkit-appearance: none;
|
|
255
|
+
margin: 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
input[type='number'] {
|
|
259
|
+
-moz-appearance: textfield;
|
|
260
|
+
appearance: textfield;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* Color input styling */
|
|
264
|
+
input[type='color'] {
|
|
265
|
+
width: 60px;
|
|
266
|
+
min-width: 60px;
|
|
267
|
+
min-height: 3rem;
|
|
268
|
+
padding: 0.375rem;
|
|
269
|
+
cursor: pointer;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
input[type='color']::-webkit-color-swatch-wrapper {
|
|
273
|
+
padding: 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
input[type='color']::-webkit-color-swatch {
|
|
277
|
+
border: 1px solid var(--color-border-strong);
|
|
278
|
+
border-radius: calc(var(--radius-md) - 2px);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
input[type='color']::-moz-color-swatch {
|
|
282
|
+
border: 1px solid var(--color-border-strong);
|
|
283
|
+
border-radius: calc(var(--radius-md) - 2px);
|
|
284
|
+
}</style>
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
interface Props {
|
|
2
|
-
type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url';
|
|
3
|
-
|
|
1
|
+
export interface Props {
|
|
2
|
+
type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'color' | 'search';
|
|
3
|
+
name?: string;
|
|
4
|
+
value?: string | number;
|
|
4
5
|
placeholder?: string;
|
|
5
6
|
disabled?: boolean;
|
|
6
7
|
error?: boolean;
|
|
7
8
|
label?: string;
|
|
8
9
|
id?: string;
|
|
9
10
|
oninput?: (event: Event) => void;
|
|
11
|
+
iconBefore?: import('svelte').Snippet;
|
|
12
|
+
iconAfter?: import('svelte').Snippet;
|
|
13
|
+
validate?: (value: string | number) => boolean | string;
|
|
14
|
+
validationMessage?: string;
|
|
15
|
+
showValidation?: boolean;
|
|
16
|
+
class?: string;
|
|
10
17
|
}
|
|
11
18
|
declare const Input: import("svelte").Component<Props, {}, "value">;
|
|
12
19
|
type Input = ReturnType<typeof Input>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<div class="flex items-stretch rounded-[var(--radius-lg)] overflow-hidden
|
|
6
|
-
<slot />
|
|
7
|
-
</div>
|
|
1
|
+
<script lang="ts">"use strict";
|
|
2
|
+
// No props needed for standard slot usage
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div class="flex items-stretch rounded-[var(--radius-lg)] overflow-hidden panel-raised [&>*:not(:first-child)]:ml-[-1px] [&>*:not(:first-child):not(:last-child)]:rounded-none [&>*:first-child]:rounded-r-none [&>*:last-child]:rounded-l-none">
|
|
6
|
+
<slot />
|
|
7
|
+
</div>
|
|
@@ -1,87 +1,77 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{#if
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
left: 50%;
|
|
79
|
-
top: 50%;
|
|
80
|
-
transform: translate(-50%, -50%);
|
|
81
|
-
width: 0.625rem;
|
|
82
|
-
height: 0.625rem;
|
|
83
|
-
border-radius: var(--radius-pill);
|
|
84
|
-
background: var(--color-accent);
|
|
85
|
-
box-shadow: var(--shadow-accent-glow);
|
|
86
|
-
}
|
|
87
|
-
</style>
|
|
1
|
+
<script lang="ts">let { value = $bindable(''), options, name, disabled = false, orientation = 'vertical', label, onchange, class: className = '' } = $props();
|
|
2
|
+
const containerClasses = $derived(orientation === 'vertical' ? 'flex flex-col gap-3' : 'flex flex-row gap-4');
|
|
3
|
+
export {};
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
{#if label}
|
|
7
|
+
<fieldset class="{disabled ? 'opacity-50' : ''} {className}">
|
|
8
|
+
<legend class="text-[var(--color-text-soft)] text-sm mb-3 block">
|
|
9
|
+
{label}
|
|
10
|
+
</legend>
|
|
11
|
+
<div class={containerClasses}>
|
|
12
|
+
{#each options as option}
|
|
13
|
+
{@const radioId = `${name}-${option.value}`}
|
|
14
|
+
<label for={radioId} class="flex items-center gap-2 cursor-pointer {disabled ? 'cursor-not-allowed' : ''}">
|
|
15
|
+
<input
|
|
16
|
+
type="radio"
|
|
17
|
+
id={radioId}
|
|
18
|
+
{name}
|
|
19
|
+
value={option.value}
|
|
20
|
+
{disabled}
|
|
21
|
+
bind:group={value}
|
|
22
|
+
onchange={onchange}
|
|
23
|
+
class="w-6 h-6 rounded-[var(--radius-pill)] border-2 border-[var(--color-border-strong)] bg-transparent appearance-none transition-all duration-200 ease-[var(--ease-luxe)] cursor-pointer checked:border-[var(--color-accent)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent)] focus:ring-offset-2 focus:ring-offset-[var(--color-base-1)] relative {disabled ? 'cursor-not-allowed' : ''}"
|
|
24
|
+
/>
|
|
25
|
+
{#if option.iconBefore}
|
|
26
|
+
<span class="inline-flex items-center justify-center text-text-soft">
|
|
27
|
+
{@render option.iconBefore()}
|
|
28
|
+
</span>
|
|
29
|
+
{/if}
|
|
30
|
+
<span class="text-[var(--color-text)] text-sm select-none">
|
|
31
|
+
{option.label}
|
|
32
|
+
</span>
|
|
33
|
+
</label>
|
|
34
|
+
{/each}
|
|
35
|
+
</div>
|
|
36
|
+
</fieldset>
|
|
37
|
+
{:else}
|
|
38
|
+
<div class="{containerClasses} {className}">
|
|
39
|
+
{#each options as option}
|
|
40
|
+
{@const radioId = `${name}-${option.value}`}
|
|
41
|
+
<label for={radioId} class="flex items-center gap-2 cursor-pointer {disabled ? 'opacity-50 cursor-not-allowed' : ''}">
|
|
42
|
+
<input
|
|
43
|
+
type="radio"
|
|
44
|
+
id={radioId}
|
|
45
|
+
{name}
|
|
46
|
+
value={option.value}
|
|
47
|
+
{disabled}
|
|
48
|
+
bind:group={value}
|
|
49
|
+
onchange={onchange}
|
|
50
|
+
class="w-6 h-6 rounded-[var(--radius-pill)] border-2 border-[var(--color-border-strong)] bg-transparent appearance-none transition-all duration-200 ease-[var(--ease-luxe)] cursor-pointer checked:border-[var(--color-accent)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent)] focus:ring-offset-2 focus:ring-offset-[var(--color-base-1)] relative {disabled ? 'cursor-not-allowed' : ''}"
|
|
51
|
+
/>
|
|
52
|
+
{#if option.iconBefore}
|
|
53
|
+
<span class="inline-flex items-center justify-center text-text-soft">
|
|
54
|
+
{@render option.iconBefore()}
|
|
55
|
+
</span>
|
|
56
|
+
{/if}
|
|
57
|
+
<span class="text-[var(--color-text)] text-sm select-none">
|
|
58
|
+
{option.label}
|
|
59
|
+
</span>
|
|
60
|
+
</label>
|
|
61
|
+
{/each}
|
|
62
|
+
</div>
|
|
63
|
+
{/if}
|
|
64
|
+
|
|
65
|
+
<style>
|
|
66
|
+
input[type="radio"]:checked::after {
|
|
67
|
+
content: '';
|
|
68
|
+
position: absolute;
|
|
69
|
+
left: 50%;
|
|
70
|
+
top: 50%;
|
|
71
|
+
transform: translate(-50%, -50%);
|
|
72
|
+
width: 0.75rem;
|
|
73
|
+
height: 0.75rem;
|
|
74
|
+
border-radius: var(--radius-pill);
|
|
75
|
+
background: var(--color-accent);
|
|
76
|
+
box-shadow: var(--shadow-accent-glow);
|
|
77
|
+
}</style>
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
interface Props {
|
|
1
|
+
export interface Props {
|
|
2
2
|
value?: string;
|
|
3
3
|
options: Array<{
|
|
4
4
|
value: string;
|
|
5
5
|
label: string;
|
|
6
|
+
iconBefore?: import('svelte').Snippet;
|
|
6
7
|
}>;
|
|
7
8
|
name: string;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
orientation?: 'vertical' | 'horizontal';
|
|
10
11
|
label?: string;
|
|
11
12
|
onchange?: (event: Event) => void;
|
|
13
|
+
class?: string;
|
|
12
14
|
}
|
|
13
15
|
declare const RadioGroup: import("svelte").Component<Props, {}, "value">;
|
|
14
16
|
type RadioGroup = ReturnType<typeof RadioGroup>;
|