@reshape-biotech/design-system 0.0.52 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/activity/Activity.stories.svelte +21 -8
- package/dist/components/activity/Activity.svelte +49 -9
- package/dist/components/activity/Activity.svelte.d.ts +1 -1
- package/dist/components/avatar/Avatar.stories.svelte +7 -17
- package/dist/components/avatar/Avatar.svelte +2 -2
- package/dist/components/avatar/Avatar.svelte.d.ts +2 -2
- package/dist/components/banner/Banner.stories.svelte +5 -5
- package/dist/components/button/Button.stories.svelte +54 -21
- package/dist/components/button/Button.svelte +58 -11
- package/dist/components/button/Button.svelte.d.ts +4 -3
- package/dist/components/card/Card.stories.svelte +130 -0
- package/dist/components/card/Card.stories.svelte.d.ts +19 -0
- package/dist/components/card/Card.svelte +25 -0
- package/dist/components/card/Card.svelte.d.ts +10 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/checkbox/Checkbox.stories.svelte +22 -0
- package/dist/components/checkbox/Checkbox.stories.svelte.d.ts +19 -0
- package/dist/components/checkbox/Checkbox.svelte +24 -0
- package/dist/components/checkbox/Checkbox.svelte.d.ts +5 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/collapsible/Collapsible.stories.svelte +5 -4
- package/dist/components/collapsible/components/collapsible-trigger.svelte +1 -1
- package/dist/components/combobox/Combobox.stories.svelte +7 -5
- package/dist/components/combobox/components/combobox-add.svelte +2 -1
- package/dist/components/combobox/components/combobox-content.svelte +4 -0
- package/dist/components/combobox/types.d.ts +2 -0
- package/dist/components/datepicker/DatePicker.stories.svelte +8 -14
- package/dist/components/divider/Divider.stories.svelte +1 -3
- package/dist/components/divider/Divider.svelte +8 -2
- package/dist/components/divider/Divider.svelte.d.ts +2 -0
- package/dist/components/drawer/Drawer.stories.svelte +3 -3
- package/dist/components/dropdown/Dropdown.stories.svelte +8 -8
- package/dist/components/empty-content/EmptyContent.stories.svelte +2 -2
- package/dist/components/graphs/bar-chart/BarChart.stories.svelte +81 -0
- package/dist/components/graphs/bar-chart/BarChart.stories.svelte.d.ts +19 -0
- package/dist/components/graphs/bar-chart/BarChart.svelte +136 -0
- package/dist/components/graphs/bar-chart/BarChart.svelte.d.ts +15 -0
- package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte +42 -0
- package/dist/components/graphs/bar-chart/StackedBarChart.stories.svelte.d.ts +19 -0
- package/dist/components/graphs/bar-chart/StackedBarChart.svelte +177 -0
- package/dist/components/graphs/bar-chart/StackedBarChart.svelte.d.ts +16 -0
- package/dist/components/graphs/chart/Chart.stories.svelte +31 -23
- package/dist/components/graphs/chart/Chart.svelte +104 -32
- package/dist/components/graphs/chart/Chart.svelte.d.ts +15 -5
- package/dist/components/graphs/index.d.ts +3 -0
- package/dist/components/graphs/index.js +3 -0
- package/dist/components/graphs/line/LineChart.stories.svelte +107 -15
- package/dist/components/graphs/line/LineChart.svelte +90 -51
- package/dist/components/graphs/line/LineChart.svelte.d.ts +6 -13
- package/dist/components/graphs/matrix/Matrix.stories.svelte +156 -0
- package/dist/components/graphs/matrix/Matrix.stories.svelte.d.ts +19 -0
- package/dist/components/graphs/matrix/Matrix.svelte +149 -0
- package/dist/components/graphs/matrix/Matrix.svelte.d.ts +24 -0
- package/dist/components/graphs/matrix/index.d.ts +3 -0
- package/dist/components/graphs/matrix/index.js +3 -0
- package/dist/components/graphs/multiline/MultiLineChart.stories.svelte +130 -18
- package/dist/components/graphs/multiline/MultiLineChart.svelte +187 -50
- package/dist/components/graphs/multiline/MultiLineChart.svelte.d.ts +9 -12
- package/dist/components/graphs/scatterplot/Scatterplot.stories.svelte +68 -41
- package/dist/components/graphs/scatterplot/Scatterplot.svelte +312 -45
- package/dist/components/graphs/scatterplot/Scatterplot.svelte.d.ts +23 -13
- package/dist/components/graphs/utils/tooltipFormatter.d.ts +10 -0
- package/dist/components/graphs/utils/tooltipFormatter.js +52 -0
- package/dist/components/icon-button/IconButton.stories.svelte +6 -6
- package/dist/components/icon-button/IconButton.svelte +50 -9
- package/dist/components/icon-button/IconButton.svelte.d.ts +3 -5
- package/dist/components/icons/AnalysisIcon.stories.svelte +15 -21
- package/dist/components/icons/AnalysisIcon.svelte +53 -43
- package/dist/components/icons/Icon.stories.svelte +4 -4
- package/dist/components/icons/Icon.svelte +1 -1
- package/dist/components/icons/PrincipalIcon.svelte +96 -0
- package/dist/components/icons/PrincipalIcon.svelte.d.ts +10 -0
- package/dist/components/icons/custom/Halo.svelte +14 -8
- package/dist/components/icons/custom/Halo.svelte.d.ts +7 -25
- package/dist/components/icons/custom/Well.svelte +14 -6
- package/dist/components/icons/custom/Well.svelte.d.ts +7 -25
- package/dist/components/icons/index.d.ts +3 -2
- package/dist/components/icons/index.js +26 -0
- package/dist/components/input/Input.stories.svelte +16 -22
- package/dist/components/input/Input.svelte +140 -134
- package/dist/components/input/Input.svelte.d.ts +12 -13
- package/dist/components/label/Label.stories.svelte +28 -0
- package/dist/components/label/Label.stories.svelte.d.ts +19 -0
- package/dist/components/label/Label.svelte +17 -0
- package/dist/components/label/Label.svelte.d.ts +9 -0
- package/dist/components/list/List.stories.svelte +3 -3
- package/dist/components/logo/Logo.stories.svelte +1 -1
- package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte +125 -0
- package/dist/components/manual-cfu-counter/ManualCFUCounter.stories.svelte.d.ts +3 -0
- package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte +577 -0
- package/dist/components/manual-cfu-counter/ManualCFUCounter.svelte.d.ts +16 -0
- package/dist/components/manual-cfu-counter/index.d.ts +1 -0
- package/dist/components/manual-cfu-counter/index.js +1 -0
- package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte +22 -0
- package/dist/components/manual-cfu-counter/test/ManualCFUCounterTestWrapper.svelte.d.ts +19 -0
- package/dist/components/markdown/Markdown.stories.svelte +1 -1
- package/dist/components/markdown/Markdown.svelte +1 -1
- package/dist/components/modal/Modal.stories.svelte +2 -2
- package/dist/components/modal/Modal.svelte +27 -22
- package/dist/components/modal/Modal.svelte.d.ts +4 -1
- package/dist/components/notification-popup/NotificationPopup.stories.svelte +1 -1
- package/dist/components/pill/Pill.stories.svelte +13 -0
- package/dist/components/pill/Pill.stories.svelte.d.ts +19 -0
- package/dist/components/progress-circle/ProgressCircle.stories.svelte +15 -0
- package/dist/components/progress-circle/ProgressCircle.stories.svelte.d.ts +19 -0
- package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte +28 -0
- package/dist/components/required-status-indicator/RequiredStatusIndicator.stories.svelte.d.ts +19 -0
- package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte +22 -0
- package/dist/components/required-status-indicator/RequiredStatusIndicator.svelte.d.ts +8 -0
- package/dist/components/required-status-indicator/index.d.ts +1 -0
- package/dist/components/required-status-indicator/index.js +1 -0
- package/dist/components/segmented-control-buttons/SegmentedControlButtons.stories.svelte +3 -3
- package/dist/components/select/Select.stories.svelte +12 -12
- package/dist/components/select/Select.svelte +0 -2
- package/dist/components/select-new/Select.stories.svelte +219 -0
- package/dist/components/select-new/Select.stories.svelte.d.ts +19 -0
- package/dist/components/select-new/components/Group.svelte +23 -0
- package/dist/components/select-new/components/Group.svelte.d.ts +10 -0
- package/dist/components/select-new/components/MultiSelectTrigger.svelte +66 -0
- package/dist/components/select-new/components/MultiSelectTrigger.svelte.d.ts +17 -0
- package/dist/components/select-new/components/SelectContent.svelte +33 -0
- package/dist/components/select-new/components/SelectContent.svelte.d.ts +10 -0
- package/dist/components/select-new/components/SelectGroupHeading.svelte +19 -0
- package/dist/components/select-new/components/SelectGroupHeading.svelte.d.ts +9 -0
- package/dist/components/select-new/components/SelectItem.svelte +41 -0
- package/dist/components/select-new/components/SelectItem.svelte.d.ts +9 -0
- package/dist/components/select-new/components/SelectTrigger.svelte +48 -0
- package/dist/components/select-new/components/SelectTrigger.svelte.d.ts +12 -0
- package/dist/components/select-new/index.d.ts +10 -0
- package/dist/components/select-new/index.js +12 -0
- package/dist/components/select-new/types.d.ts +25 -0
- package/dist/components/select-new/types.js +1 -0
- package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte +92 -0
- package/dist/components/sjsf-wrappers/SjsfNumberInputWrapper.svelte.d.ts +3 -0
- package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte +65 -0
- package/dist/components/sjsf-wrappers/SjsfTextInputWrapper.svelte.d.ts +3 -0
- package/dist/components/sjsf-wrappers/index.d.ts +2 -0
- package/dist/components/sjsf-wrappers/index.js +2 -0
- package/dist/components/sjsf-wrappers/sjsfCustomTheme.d.ts +2 -0
- package/dist/components/sjsf-wrappers/sjsfCustomTheme.js +8 -0
- package/dist/components/skeleton-loader/SkeletonLoader.stories.svelte +4 -4
- package/dist/components/slider/Slider.stories.svelte +4 -4
- package/dist/components/spinner/Spinner.stories.svelte +13 -0
- package/dist/components/spinner/Spinner.stories.svelte.d.ts +19 -0
- package/dist/components/stat-card/StatCard.stories.svelte +27 -19
- package/dist/components/stat-card/StatCard.svelte +100 -6
- package/dist/components/stat-card/StatCard.svelte.d.ts +3 -0
- package/dist/components/status-badge/StatusBadge.stories.svelte +6 -6
- package/dist/components/status-badge/StatusBadge.svelte +5 -3
- package/dist/components/table/Table.stories.svelte +1 -1
- package/dist/components/table/components/Td.svelte +3 -2
- package/dist/components/table/components/Td.svelte.d.ts +1 -0
- package/dist/components/table/components/Tr.svelte +3 -2
- package/dist/components/table/components/Tr.svelte.d.ts +1 -0
- package/dist/components/tabs/Tabs.stories.svelte +1 -1
- package/dist/components/tag/Tag.stories.svelte +38 -7
- package/dist/components/tag/Tag.svelte +34 -21
- package/dist/components/tag/Tag.svelte.d.ts +1 -1
- package/dist/components/textarea/Textarea.stories.svelte +97 -0
- package/dist/components/textarea/Textarea.stories.svelte.d.ts +19 -0
- package/dist/components/textarea/Textarea.svelte +94 -0
- package/dist/components/textarea/Textarea.svelte.d.ts +17 -0
- package/dist/components/textarea/index.d.ts +1 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/toggle/Toggle.stories.svelte +1 -1
- package/dist/components/toggle/Toggle.svelte +3 -2
- package/dist/components/toggle/Toggle.svelte.d.ts +1 -0
- package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte +173 -0
- package/dist/components/toggle-icon-button/ToggleIconButton.stories.svelte.d.ts +19 -0
- package/dist/components/toggle-icon-button/ToggleIconButton.svelte +117 -0
- package/dist/components/toggle-icon-button/ToggleIconButton.svelte.d.ts +15 -0
- package/dist/components/toggle-icon-button/index.d.ts +3 -0
- package/dist/components/toggle-icon-button/index.js +3 -0
- package/dist/components/tooltip/Tooltip.stories.svelte +6 -6
- package/dist/components/tooltip/Tooltip.svelte +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/tailwind-safelist.js +2 -0
- package/dist/tailwind.preset.d.ts +2 -0
- package/dist/tokens.d.ts +4 -0
- package/dist/tokens.js +3 -1
- package/package.json +1 -2
|
@@ -22,33 +22,25 @@
|
|
|
22
22
|
let textareaValue = '';
|
|
23
23
|
</script>
|
|
24
24
|
|
|
25
|
-
<Story name="Base"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<Story name="XSmall">
|
|
29
|
-
<Input bind:value autofocus size="xs" />
|
|
30
|
-
</Story>
|
|
31
|
-
<Story name="Small">
|
|
32
|
-
<Input bind:value autofocus size="sm" />
|
|
33
|
-
</Story>
|
|
25
|
+
<Story name="Base" args={{ autofocus: true, value: 'Hello' }} />
|
|
26
|
+
|
|
27
|
+
<Story name="XSmall" args={{ size: 'xs' }} />
|
|
34
28
|
|
|
35
|
-
<Story name="
|
|
29
|
+
<Story name="Small" args={{ size: 'sm' }} />
|
|
30
|
+
|
|
31
|
+
<Story name="Login" asChild>
|
|
36
32
|
<div class="flex flex-col gap-2">
|
|
37
33
|
<Input bind:value={email} label="Email" type="text" required id="email-select" autofocus />
|
|
38
34
|
<Input bind:value={password} label="Password" id="password-select" type="password" required />
|
|
39
35
|
</div>
|
|
40
36
|
</Story>
|
|
41
37
|
|
|
42
|
-
<Story
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type="textarea"
|
|
47
|
-
placeholder="Add a description..."
|
|
48
|
-
/>
|
|
49
|
-
</Story>
|
|
38
|
+
<Story
|
|
39
|
+
name="Textarea"
|
|
40
|
+
args={{ label: 'Description', type: 'textarea', placeholder: 'Add a description...' }}
|
|
41
|
+
/>
|
|
50
42
|
|
|
51
|
-
<Story name="Prefix">
|
|
43
|
+
<Story name="Prefix" asChild>
|
|
52
44
|
<Input value="Bob">
|
|
53
45
|
{#snippet prefix()}
|
|
54
46
|
<div>Mr.</div>
|
|
@@ -56,7 +48,7 @@
|
|
|
56
48
|
</Input>
|
|
57
49
|
</Story>
|
|
58
50
|
|
|
59
|
-
<Story name="Suffix">
|
|
51
|
+
<Story name="Suffix" asChild>
|
|
60
52
|
<Input value="30">
|
|
61
53
|
{#snippet suffix()}
|
|
62
54
|
<div>± 1°C</div>
|
|
@@ -64,7 +56,7 @@
|
|
|
64
56
|
</Input>
|
|
65
57
|
</Story>
|
|
66
58
|
|
|
67
|
-
<Story name="Prefix & Suffix">
|
|
59
|
+
<Story name="Prefix & Suffix" asChild>
|
|
68
60
|
<Input value="9001">
|
|
69
61
|
{#snippet prefix()}
|
|
70
62
|
<div>$</div>
|
|
@@ -75,7 +67,7 @@
|
|
|
75
67
|
</Input>
|
|
76
68
|
</Story>
|
|
77
69
|
|
|
78
|
-
<Story name="Validation">
|
|
70
|
+
<Story name="Validation" asChild>
|
|
79
71
|
<Input value="Focus me, then click away" validator={(val) => val.toString().length < 10}>
|
|
80
72
|
{#snippet prefix({ valid })}
|
|
81
73
|
<div>
|
|
@@ -91,3 +83,5 @@
|
|
|
91
83
|
{/snippet}
|
|
92
84
|
</Input>
|
|
93
85
|
</Story>
|
|
86
|
+
|
|
87
|
+
<Story name="Clearable" args={{ clearable: true, value: 'Focus me, then click away' }} />
|
|
@@ -1,204 +1,210 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { IconButton } from '../icon-button';
|
|
4
|
+
import { Icon } from '../icons';
|
|
5
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
6
|
|
|
4
|
-
interface
|
|
7
|
+
interface InputProps extends Omit<HTMLInputAttributes, 'size' | 'prefix' | 'suffix'> {
|
|
5
8
|
label?: string | null;
|
|
6
|
-
value: string | number;
|
|
7
|
-
type?: 'text' | 'password' | 'textarea' | 'number';
|
|
8
|
-
name?: string;
|
|
9
|
-
required?: boolean;
|
|
10
|
-
autofocus?: boolean;
|
|
11
|
-
placeholder?: string;
|
|
12
9
|
id?: string | undefined;
|
|
13
10
|
validator?: (a: string | number) => boolean;
|
|
14
|
-
onBlur?: (e: Event) => void;
|
|
15
|
-
onkeydown?: (e: KeyboardEvent) => void;
|
|
16
11
|
prefix?: Snippet<[any]>;
|
|
17
12
|
suffix?: Snippet;
|
|
18
13
|
error?: Snippet;
|
|
19
|
-
input?: HTMLInputElement
|
|
20
|
-
maxlength?: number | null;
|
|
14
|
+
input?: HTMLInputElement;
|
|
21
15
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'dynamic';
|
|
22
|
-
|
|
16
|
+
transparent?: boolean;
|
|
17
|
+
clearable?: boolean;
|
|
18
|
+
onclear?: () => void;
|
|
19
|
+
class?: string;
|
|
20
|
+
oninput?: (event: Event) => void;
|
|
21
|
+
onblur?: (event: FocusEvent) => void;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
let {
|
|
26
25
|
label = null,
|
|
27
26
|
value = $bindable(),
|
|
28
27
|
type = 'text',
|
|
29
|
-
required = false,
|
|
30
|
-
autofocus = false,
|
|
31
|
-
placeholder = '',
|
|
32
|
-
id = undefined,
|
|
33
|
-
name,
|
|
34
28
|
validator = (_) => {
|
|
35
29
|
return true;
|
|
36
30
|
},
|
|
37
|
-
onBlur = () => {},
|
|
38
|
-
onkeydown = () => {},
|
|
39
31
|
prefix,
|
|
40
32
|
suffix,
|
|
41
33
|
error,
|
|
42
34
|
input = $bindable(),
|
|
43
|
-
maxlength = null,
|
|
44
35
|
size = 'md',
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
transparent = false,
|
|
37
|
+
clearable = false,
|
|
38
|
+
onclear = () => {},
|
|
39
|
+
class: className,
|
|
40
|
+
oninput,
|
|
41
|
+
onblur,
|
|
42
|
+
...rest
|
|
43
|
+
}: InputProps = $props();
|
|
44
|
+
|
|
45
|
+
export function focus() {
|
|
46
|
+
input?.focus();
|
|
47
|
+
}
|
|
47
48
|
|
|
48
49
|
let valid = $state(true);
|
|
49
50
|
|
|
50
|
-
const inputId =
|
|
51
|
-
|
|
51
|
+
const inputId = crypto.randomUUID();
|
|
52
|
+
const id = $derived(rest.id ?? inputId);
|
|
52
53
|
function handleInput(event: Event) {
|
|
53
|
-
if (readonly) return;
|
|
54
|
-
const target = event.target as
|
|
54
|
+
if (rest.readonly) return;
|
|
55
|
+
const target = event.target as HTMLInputElement;
|
|
55
56
|
value = target.value;
|
|
56
|
-
|
|
57
|
-
if (type === 'textarea') {
|
|
58
|
-
autoResizeTextarea(target as HTMLTextAreaElement);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function autoResizeTextarea(textarea: HTMLTextAreaElement) {
|
|
62
|
-
// Set a maximum height for the textarea (e.g., 200px)
|
|
63
|
-
const maxHeight = 200;
|
|
64
|
-
|
|
65
|
-
// Reset height to auto to get the correct scrollHeight
|
|
66
|
-
textarea.style.height = 'auto';
|
|
67
|
-
|
|
68
|
-
// If scrollHeight is less than maxHeight, set height to scrollHeight
|
|
69
|
-
// Otherwise, set height to maxHeight and enable scrolling
|
|
70
|
-
if (textarea.scrollHeight < maxHeight) {
|
|
71
|
-
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
72
|
-
textarea.style.overflowY = 'hidden';
|
|
73
|
-
} else {
|
|
74
|
-
textarea.style.height = `${maxHeight}px`;
|
|
75
|
-
textarea.style.overflowY = 'auto';
|
|
76
|
-
}
|
|
57
|
+
oninput?.(event);
|
|
77
58
|
}
|
|
78
59
|
|
|
79
|
-
function handleBlur(event:
|
|
60
|
+
function handleBlur(event: FocusEvent & { currentTarget: EventTarget & HTMLInputElement }) {
|
|
80
61
|
valid = validator(value);
|
|
81
|
-
|
|
62
|
+
onblur?.(event);
|
|
82
63
|
}
|
|
83
64
|
</script>
|
|
84
65
|
|
|
85
66
|
<div class="w-full">
|
|
86
67
|
{#if label}
|
|
87
|
-
<label for={id ?? inputId} class="block px-1 py-2 text-sm text-secondary">
|
|
68
|
+
<label for={id ?? inputId} class="block px-1 py-2 text-sm text-secondary">
|
|
69
|
+
{label}
|
|
70
|
+
{#if rest.required}
|
|
71
|
+
<span class="ml-0.5 text-danger">*</span>
|
|
72
|
+
{/if}
|
|
73
|
+
</label>
|
|
88
74
|
{/if}
|
|
75
|
+
|
|
89
76
|
<div
|
|
90
77
|
class="flex w-full items-center gap-1 rounded-lg border border-input bg-surface shadow-input size-{size}"
|
|
78
|
+
class:border-transparent={transparent}
|
|
79
|
+
class:shadow-input={!transparent}
|
|
91
80
|
class:!border-error={!valid}
|
|
92
81
|
>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
oninput={handleInput}
|
|
126
|
-
onblur={handleBlur}
|
|
127
|
-
{onkeydown}
|
|
128
|
-
bind:this={input}
|
|
129
|
-
{value}
|
|
130
|
-
{autofocus}
|
|
131
|
-
{placeholder}
|
|
132
|
-
{maxlength}
|
|
133
|
-
{readonly}
|
|
134
|
-
/>
|
|
135
|
-
<div class="whitespace-nowrap text-secondary">
|
|
136
|
-
{@render suffix?.()}
|
|
137
|
-
</div>
|
|
82
|
+
<div class="whitespace-nowrap text-secondary">
|
|
83
|
+
{@render prefix?.({ valid })}
|
|
84
|
+
</div>
|
|
85
|
+
<input
|
|
86
|
+
{id}
|
|
87
|
+
class="inline leading-none"
|
|
88
|
+
class:has-text={value}
|
|
89
|
+
class:has-placeholder={rest.placeholder}
|
|
90
|
+
aria-label={label}
|
|
91
|
+
{type}
|
|
92
|
+
oninput={handleInput}
|
|
93
|
+
onblur={handleBlur}
|
|
94
|
+
bind:this={input}
|
|
95
|
+
bind:value
|
|
96
|
+
{...rest}
|
|
97
|
+
/>
|
|
98
|
+
<div class="whitespace-nowrap text-secondary">
|
|
99
|
+
{@render suffix?.()}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
{#if clearable && value}
|
|
103
|
+
<IconButton
|
|
104
|
+
variant="transparent"
|
|
105
|
+
size="xs"
|
|
106
|
+
onclick={() => {
|
|
107
|
+
value = '';
|
|
108
|
+
input?.focus();
|
|
109
|
+
onclear();
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
<Icon iconName="X" />
|
|
113
|
+
</IconButton>
|
|
138
114
|
{/if}
|
|
139
115
|
</div>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
{/if}
|
|
116
|
+
|
|
117
|
+
{@render error?.()}
|
|
143
118
|
</div>
|
|
144
119
|
|
|
145
120
|
<style>
|
|
146
|
-
input
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
121
|
+
input {
|
|
122
|
+
|
|
123
|
+
width: 100%;
|
|
124
|
+
|
|
125
|
+
resize: none;
|
|
126
|
+
|
|
127
|
+
outline: 2px solid transparent;
|
|
128
|
+
|
|
129
|
+
outline-offset: 2px
|
|
153
130
|
}
|
|
154
131
|
|
|
155
132
|
div:not(:focus-within):hover {
|
|
156
|
-
|
|
133
|
+
|
|
134
|
+
border-color: #5750ee40
|
|
157
135
|
}
|
|
158
136
|
|
|
159
137
|
div:focus-within {
|
|
160
|
-
|
|
161
|
-
|
|
138
|
+
|
|
139
|
+
--tw-border-opacity: 1;
|
|
140
|
+
|
|
141
|
+
border-color: rgb(87 80 238 / var(--tw-border-opacity, 1))
|
|
162
142
|
}
|
|
163
143
|
|
|
164
144
|
.size-xs {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
145
|
+
|
|
146
|
+
height: 1.5rem;
|
|
147
|
+
|
|
148
|
+
padding: 0.5rem;
|
|
149
|
+
|
|
150
|
+
font-size: 0.75rem;
|
|
151
|
+
|
|
152
|
+
line-height: 1rem
|
|
169
153
|
}
|
|
170
154
|
|
|
171
155
|
.size-sm {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
156
|
+
|
|
157
|
+
height: 2rem;
|
|
158
|
+
|
|
159
|
+
padding-left: 0.75rem;
|
|
160
|
+
|
|
161
|
+
padding-right: 0.75rem;
|
|
162
|
+
|
|
163
|
+
padding-top: 0.5rem;
|
|
164
|
+
|
|
165
|
+
padding-bottom: 0.5rem
|
|
177
166
|
}
|
|
178
167
|
|
|
179
168
|
.size-md {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
169
|
+
|
|
170
|
+
height: 2.5rem;
|
|
171
|
+
|
|
172
|
+
padding-left: 0.75rem;
|
|
173
|
+
|
|
174
|
+
padding-right: 0.75rem;
|
|
175
|
+
|
|
176
|
+
padding-top: 0.5rem;
|
|
177
|
+
|
|
178
|
+
padding-bottom: 0.5rem
|
|
185
179
|
}
|
|
186
180
|
|
|
187
181
|
.size-lg {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
182
|
+
|
|
183
|
+
height: 3rem;
|
|
184
|
+
|
|
185
|
+
padding-left: 0.75rem;
|
|
186
|
+
|
|
187
|
+
padding-right: 0.75rem;
|
|
188
|
+
|
|
189
|
+
padding-top: 0.75rem;
|
|
190
|
+
|
|
191
|
+
padding-bottom: 0.75rem;
|
|
192
|
+
|
|
193
|
+
font-size: 1rem;
|
|
194
|
+
|
|
195
|
+
line-height: 1.5rem
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
.size-dynamic {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
|
|
200
|
+
height: auto;
|
|
201
|
+
|
|
202
|
+
padding-left: 0.75rem;
|
|
203
|
+
|
|
204
|
+
padding-right: 0.75rem;
|
|
205
|
+
|
|
206
|
+
padding-top: 0.5rem;
|
|
207
|
+
|
|
208
|
+
padding-bottom: 0.5rem
|
|
203
209
|
}
|
|
204
210
|
</style>
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
|
|
2
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
interface InputProps extends Omit<HTMLInputAttributes, 'size' | 'prefix' | 'suffix'> {
|
|
3
4
|
label?: string | null;
|
|
4
|
-
value: string | number;
|
|
5
|
-
type?: 'text' | 'password' | 'textarea' | 'number';
|
|
6
|
-
name?: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
autofocus?: boolean;
|
|
9
|
-
placeholder?: string;
|
|
10
5
|
id?: string | undefined;
|
|
11
6
|
validator?: (a: string | number) => boolean;
|
|
12
|
-
onBlur?: (e: Event) => void;
|
|
13
|
-
onkeydown?: (e: KeyboardEvent) => void;
|
|
14
7
|
prefix?: Snippet<[any]>;
|
|
15
8
|
suffix?: Snippet;
|
|
16
9
|
error?: Snippet;
|
|
17
|
-
input?: HTMLInputElement
|
|
18
|
-
maxlength?: number | null;
|
|
10
|
+
input?: HTMLInputElement;
|
|
19
11
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'dynamic';
|
|
20
|
-
|
|
12
|
+
transparent?: boolean;
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
onclear?: () => void;
|
|
15
|
+
class?: string;
|
|
16
|
+
oninput?: (event: Event) => void;
|
|
17
|
+
onblur?: (event: FocusEvent) => void;
|
|
21
18
|
}
|
|
22
|
-
declare const Input: import("svelte").Component<
|
|
19
|
+
declare const Input: import("svelte").Component<InputProps, {
|
|
20
|
+
focus: () => void;
|
|
21
|
+
}, "value" | "input">;
|
|
23
22
|
type Input = ReturnType<typeof Input>;
|
|
24
23
|
export default Input;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Label from './Label.svelte';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'Design System/Label',
|
|
7
|
+
component: Label,
|
|
8
|
+
argTypes: {
|
|
9
|
+
text: { control: 'text' },
|
|
10
|
+
forId: { control: 'text' },
|
|
11
|
+
required: { control: 'boolean' },
|
|
12
|
+
class: { control: 'text' }
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Story name="Default" args={{ text: 'Email Address', forId: 'email' }} />
|
|
18
|
+
|
|
19
|
+
<Story name="Required" args={{ text: 'Password', forId: 'password', required: true }} />
|
|
20
|
+
|
|
21
|
+
<Story
|
|
22
|
+
name="With Custom Class"
|
|
23
|
+
args={{
|
|
24
|
+
text: 'Custom Styled Label',
|
|
25
|
+
forId: 'custom',
|
|
26
|
+
class: 'text-lg text-primary font-bold'
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Label from './Label.svelte';
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Label: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Label = InstanceType<typeof Label>;
|
|
19
|
+
export default Label;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
forId: string;
|
|
4
|
+
text: string;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { forId, text, required = false, class: className }: Props = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<label for={forId} class="block text-sm text-secondary {className ?? ''}">
|
|
13
|
+
{text}
|
|
14
|
+
{#if required}
|
|
15
|
+
<span class="ml-0.5 text-danger">*</span>
|
|
16
|
+
{/if}
|
|
17
|
+
</label>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
];
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
|
-
<Story name="Default" args={{}}>
|
|
21
|
+
<Story name="Default" args={{}} asChild>
|
|
22
22
|
<List {items}>
|
|
23
23
|
{#snippet item(item)}
|
|
24
24
|
<div class="flex min-h-2 flex-row gap-2">
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
</List>
|
|
53
53
|
</Story>
|
|
54
54
|
|
|
55
|
-
<Story name="Compact" args={{ variant: 'compact' }}>
|
|
55
|
+
<Story name="Compact" args={{ variant: 'compact' }} asChild>
|
|
56
56
|
<List {items} variant="compact">
|
|
57
57
|
{#snippet item(item)}
|
|
58
58
|
<div class="flex min-h-2 flex-row gap-2">
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
</List>
|
|
87
87
|
</Story>
|
|
88
88
|
|
|
89
|
-
<Story name="Loading">
|
|
89
|
+
<Story name="Loading" asChild>
|
|
90
90
|
<List variant="compact" items={[{}, {}, {}]}>
|
|
91
91
|
{#snippet item({})}
|
|
92
92
|
<div class="flex h-8 w-full items-center">
|