@flightlesslabs/dodo-ui 0.4.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/dist/index.d.ts +9 -1
- package/dist/index.js +6 -0
- package/dist/stories/components/Form/Button/Button.stories.svelte +1 -1
- package/dist/stories/components/Form/Button/Button.svelte +37 -37
- package/dist/stories/components/Form/Button/Button.svelte.d.ts +1 -1
- package/dist/stories/components/Form/Button/Color/Color.stories.svelte +9 -7
- package/dist/stories/components/Form/FormControl/FormControl.svelte +1 -1
- package/dist/stories/components/Form/Message/Color/Color.stories.svelte +36 -0
- package/dist/stories/components/Form/Message/Color/Color.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/Message/Message.stories.svelte +11 -26
- package/dist/stories/components/Form/Message/Message.stories.svelte.d.ts +2 -0
- package/dist/stories/components/Form/Message/Message.svelte +17 -6
- package/dist/stories/components/Form/Message/Message.svelte.d.ts +4 -1
- package/dist/stories/components/Form/Message/Size/Size.stories.svelte +24 -0
- package/dist/stories/components/Form/Message/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +32 -130
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +2 -3
- package/dist/stories/components/Form/SimpleSelect/Events/Events.stories.svelte +74 -0
- package/dist/stories/components/Form/SimpleSelect/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte +24 -0
- package/dist/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte +59 -0
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte.d.ts +23 -0
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte +69 -0
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte.d.ts +50 -0
- package/dist/stories/components/Form/SimpleSelect/Size/Size.stories.svelte +20 -0
- package/dist/stories/components/Form/SimpleSelect/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte +36 -0
- package/dist/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte +22 -120
- package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +1 -2
- package/dist/stories/components/Layout/Paper/Paper.stories.svelte +32 -0
- package/dist/stories/components/Layout/Paper/Paper.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Layout/Paper/Paper.svelte +52 -0
- package/dist/stories/components/Layout/Paper/Paper.svelte.d.ts +23 -0
- package/dist/stories/components/Layout/Paper/Roundness/Roundness.stories.svelte +30 -0
- package/dist/stories/components/Layout/Paper/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Layout/Paper/Shadow/Shadow.stories.svelte +42 -0
- package/dist/stories/components/Layout/Paper/Shadow/Shadow.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte +34 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte.d.ts +21 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +120 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte.d.ts +29 -0
- package/dist/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte +20 -0
- package/dist/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte +16 -0
- package/dist/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte +47 -0
- package/dist/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
- package/dist/stories/philosophy/Colors/utils/color.js +1 -1
- package/dist/styles/_colors.css +26 -26
- package/dist/styles/_shadow.css +39 -0
- package/dist/styles/global.css +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/lib/index.ts +17 -1
- package/src/lib/stories/components/Form/Button/Button.stories.svelte +1 -1
- package/src/lib/stories/components/Form/Button/Button.svelte +4 -4
- package/src/lib/stories/components/Form/Button/Color/Color.stories.svelte +9 -7
- package/src/lib/stories/components/Form/FormControl/FormControl.svelte +1 -1
- package/src/lib/stories/components/Form/Message/Color/Color.stories.svelte +36 -0
- package/src/lib/stories/components/Form/Message/Message.stories.svelte +13 -26
- package/src/lib/stories/components/Form/Message/Message.svelte +28 -7
- package/src/lib/stories/components/Form/Message/Size/Size.stories.svelte +24 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +35 -157
- package/src/lib/stories/components/Form/SimpleSelect/Events/Events.stories.svelte +79 -0
- package/src/lib/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte +24 -0
- package/src/lib/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte +64 -0
- package/src/lib/stories/components/Form/SimpleSelect/SimpleSelect.svelte +159 -0
- package/src/lib/stories/components/Form/SimpleSelect/Size/Size.stories.svelte +20 -0
- package/src/lib/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte +36 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.svelte +22 -143
- package/src/lib/stories/components/Layout/Paper/Paper.stories.svelte +36 -0
- package/src/lib/stories/components/Layout/Paper/Paper.svelte +91 -0
- package/src/lib/stories/components/Layout/Paper/Roundness/Roundness.stories.svelte +30 -0
- package/src/lib/stories/components/Layout/Paper/Shadow/Shadow.stories.svelte +42 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte +38 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +198 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte +20 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte +47 -0
- package/src/lib/styles/_colors.css +26 -26
- package/src/lib/styles/_shadow.css +39 -0
- package/src/lib/styles/global.css +1 -0
- package/src/lib/types.ts +1 -0
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<script lang="ts">import Icon from '@iconify/svelte';
|
|
5
5
|
import UtilityButton from '../../../developer tools/components/UtilityButton/UtilityButton.svelte';
|
|
6
|
+
import InputEnclosure from '../../../developer tools/components/InputEnclosure/InputEnclosure.svelte';
|
|
6
7
|
let { size = 'normal', roundness = '1x', outline = true, name, id, class: className = '', disabled = false, oninput, onchange, onblur, onfocus, onpaste, oncopy, oncut, before, after, customPasswordToggleIcon, error = false, passwordToggle = true, passwordToggleState = $bindable(), value = $bindable(), placeholder, ontoggle, ref = $bindable(), readonly = false, } = $props();
|
|
7
8
|
let focused = $state(false);
|
|
8
9
|
let toggle = $state(passwordToggleState);
|
|
@@ -40,72 +41,40 @@ function ontoggleMod(e) {
|
|
|
40
41
|
class:toggle
|
|
41
42
|
class={['dodo-ui-PasswordInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
42
43
|
>
|
|
43
|
-
{
|
|
44
|
-
<
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
bind:value
|
|
62
|
-
bind:this={ref}
|
|
63
|
-
{readonly}
|
|
64
|
-
/>
|
|
44
|
+
<InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
|
|
45
|
+
<input
|
|
46
|
+
type={passwordToggle && toggle ? 'text' : 'password'}
|
|
47
|
+
{name}
|
|
48
|
+
{id}
|
|
49
|
+
{disabled}
|
|
50
|
+
{oninput}
|
|
51
|
+
{onchange}
|
|
52
|
+
onfocus={onfocusMod}
|
|
53
|
+
onblur={onblurMod}
|
|
54
|
+
{onpaste}
|
|
55
|
+
{oncopy}
|
|
56
|
+
{oncut}
|
|
57
|
+
{placeholder}
|
|
58
|
+
bind:value
|
|
59
|
+
bind:this={ref}
|
|
60
|
+
{readonly}
|
|
61
|
+
/>
|
|
65
62
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{#if after}
|
|
79
|
-
<span class="content--after">
|
|
80
|
-
{@render after()}
|
|
81
|
-
</span>
|
|
82
|
-
{/if}
|
|
63
|
+
{#if passwordToggle && !disabled}
|
|
64
|
+
<UtilityButton {size} title="Toggle password" class="passwordToggle" onclick={ontoggleMod}>
|
|
65
|
+
{#if customPasswordToggleIcon}
|
|
66
|
+
{@render customPasswordToggleIconTyped(toggle)}
|
|
67
|
+
{:else if toggle}
|
|
68
|
+
<Icon icon="mdi:eye-off" width="24" height="24" />
|
|
69
|
+
{:else}
|
|
70
|
+
<Icon icon="mdi:eye" width="24" height="24" />
|
|
71
|
+
{/if}
|
|
72
|
+
</UtilityButton>
|
|
73
|
+
{/if}
|
|
74
|
+
</InputEnclosure>
|
|
83
75
|
</div>
|
|
84
76
|
|
|
85
|
-
<style
|
|
86
|
-
--dodo-ui-PasswordInput-border-color: var(--dodo-color-default-500);
|
|
87
|
-
--dodo-ui-PasswordInput-focus-border-color: var(--dodo-color-primary-500);
|
|
88
|
-
--dodo-ui-PasswordInput-error-border-color: var(--dodo-color-danger-500);
|
|
89
|
-
--dodo-ui-PasswordInput-disabled-color: var(--dodo-color-default-400);
|
|
90
|
-
--dodo-ui-PasswordInput-disabled-bg: var(--dodo-color-default-200);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
:global(.dodo-theme--dark) {
|
|
94
|
-
--dodo-ui-PasswordInput-border-color: var(--dodo-color-default-600);
|
|
95
|
-
--dodo-ui-PasswordInput-focus-border-color: var(--dodo-color-primary-600);
|
|
96
|
-
--dodo-ui-PasswordInput-error-border-color: var(--dodo-color-danger-600);
|
|
97
|
-
--dodo-ui-PasswordInput-disabled-bg: var(--dodo-color-default-100);
|
|
98
|
-
--dodo-ui-PasswordInput-disabled-color: var(--dodo-color-default-500);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.dodo-ui-PasswordInput {
|
|
102
|
-
display: flex;
|
|
103
|
-
overflow: hidden;
|
|
104
|
-
color: var(--dodo-color-default-800);
|
|
105
|
-
transition: all 150ms;
|
|
106
|
-
border: 0;
|
|
107
|
-
}
|
|
108
|
-
.dodo-ui-PasswordInput input {
|
|
77
|
+
<style>.dodo-ui-PasswordInput input {
|
|
109
78
|
flex: 1;
|
|
110
79
|
border: 0;
|
|
111
80
|
outline: 0;
|
|
@@ -115,82 +84,15 @@ function ontoggleMod(e) {
|
|
|
115
84
|
color: inherit;
|
|
116
85
|
letter-spacing: 0.3px;
|
|
117
86
|
}
|
|
118
|
-
.dodo-ui-PasswordInput.outline {
|
|
119
|
-
border-style: solid;
|
|
120
|
-
border-width: var(--dodo-ui-element-border-width);
|
|
121
|
-
border-color: var(--dodo-ui-PasswordInput-border-color);
|
|
122
|
-
}
|
|
123
|
-
.dodo-ui-PasswordInput.focused {
|
|
124
|
-
border-color: var(--dodo-ui-PasswordInput-focus-border-color);
|
|
125
|
-
}
|
|
126
|
-
.dodo-ui-PasswordInput.error {
|
|
127
|
-
border-color: var(--dodo-ui-PasswordInput-error-border-color);
|
|
128
|
-
}
|
|
129
|
-
.dodo-ui-PasswordInput.disabled {
|
|
130
|
-
cursor: initial;
|
|
131
|
-
background-color: var(--dodo-ui-PasswordInput-disabled-bg);
|
|
132
|
-
color: var(--dodo-ui-PasswordInput-disabled-color);
|
|
133
|
-
border-color: var(--dodo-ui-PasswordInput-disabled-bg);
|
|
134
|
-
}
|
|
135
|
-
.dodo-ui-PasswordInput .content--after:empty, .dodo-ui-PasswordInput .content--before:empty {
|
|
136
|
-
display: none;
|
|
137
|
-
}
|
|
138
|
-
.dodo-ui-PasswordInput .content--after, .dodo-ui-PasswordInput .content--before {
|
|
139
|
-
display: inline-flex;
|
|
140
|
-
height: 100%;
|
|
141
|
-
align-items: center;
|
|
142
|
-
}
|
|
143
|
-
.dodo-ui-PasswordInput.size--normal {
|
|
144
|
-
height: var(--dodo-ui-element-height-normal);
|
|
145
|
-
}
|
|
146
87
|
.dodo-ui-PasswordInput.size--normal input {
|
|
147
88
|
font-size: 1rem;
|
|
148
89
|
padding: 0 12px;
|
|
149
90
|
}
|
|
150
|
-
.dodo-ui-PasswordInput.size--normal .content--before {
|
|
151
|
-
margin-left: 12px;
|
|
152
|
-
margin-right: -4px;
|
|
153
|
-
}
|
|
154
|
-
.dodo-ui-PasswordInput.size--normal .content--after {
|
|
155
|
-
margin-right: 12px;
|
|
156
|
-
margin-left: -4px;
|
|
157
|
-
}
|
|
158
|
-
.dodo-ui-PasswordInput.size--small {
|
|
159
|
-
height: var(--dodo-ui-element-height-small);
|
|
160
|
-
}
|
|
161
91
|
.dodo-ui-PasswordInput.size--small input {
|
|
162
92
|
padding: 0 8px;
|
|
163
93
|
font-size: 0.9rem;
|
|
164
94
|
}
|
|
165
|
-
.dodo-ui-PasswordInput.size--small .content--before {
|
|
166
|
-
margin-left: 8px;
|
|
167
|
-
margin-right: -2px;
|
|
168
|
-
}
|
|
169
|
-
.dodo-ui-PasswordInput.size--small .content--after {
|
|
170
|
-
margin-right: 8px;
|
|
171
|
-
margin-left: -2px;
|
|
172
|
-
}
|
|
173
|
-
.dodo-ui-PasswordInput.size--large {
|
|
174
|
-
height: var(--dodo-ui-element-height-large);
|
|
175
|
-
}
|
|
176
95
|
.dodo-ui-PasswordInput.size--large input {
|
|
177
96
|
font-size: 1.1rem;
|
|
178
97
|
padding: 0 14px;
|
|
179
|
-
}
|
|
180
|
-
.dodo-ui-PasswordInput.size--large .content--before {
|
|
181
|
-
margin-left: 14px;
|
|
182
|
-
margin-right: -4px;
|
|
183
|
-
}
|
|
184
|
-
.dodo-ui-PasswordInput.size--large .content--after {
|
|
185
|
-
margin-right: 14px;
|
|
186
|
-
margin-left: -4px;
|
|
187
|
-
}
|
|
188
|
-
.dodo-ui-PasswordInput.roundness--1x {
|
|
189
|
-
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
190
|
-
}
|
|
191
|
-
.dodo-ui-PasswordInput.roundness--2x {
|
|
192
|
-
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
193
|
-
}
|
|
194
|
-
.dodo-ui-PasswordInput.roundness--3x {
|
|
195
|
-
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
196
98
|
}</style>
|
|
@@ -2,10 +2,9 @@ export type PasswordInputToggleEvent = {
|
|
|
2
2
|
event: Event;
|
|
3
3
|
toggle: boolean;
|
|
4
4
|
};
|
|
5
|
-
import type { ComponentSize } from '../../../../types.js';
|
|
5
|
+
import type { ComponentRoundness, ComponentSize } from '../../../../types.js';
|
|
6
6
|
import type { Snippet } from 'svelte';
|
|
7
7
|
import type { ChangeEventHandler, ClipboardEventHandler, FocusEventHandler, FormEventHandler } from 'svelte/elements';
|
|
8
|
-
import type { TextInputRoundness } from '../TextInput/TextInput.svelte';
|
|
9
8
|
interface PasswordInputProps {
|
|
10
9
|
/** How large should the button be? */
|
|
11
10
|
size?: ComponentSize;
|
|
@@ -18,7 +17,7 @@ interface PasswordInputProps {
|
|
|
18
17
|
/** Toggle Password Icon */
|
|
19
18
|
customPasswordToggleIcon?: (toggle: boolean) => Snippet;
|
|
20
19
|
/** How round should the border radius be? */
|
|
21
|
-
roundness?:
|
|
20
|
+
roundness?: ComponentRoundness | false;
|
|
22
21
|
/** Add a border around the button. Default True */
|
|
23
22
|
outline?: boolean;
|
|
24
23
|
/** Input value */
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import {} from '../SimpleSelect.svelte';
|
|
3
|
+
import SimpleSelect from '../SimpleSelect.svelte';
|
|
4
|
+
import { storySimpleSelectArgTypes, storySimpleSelectOptions, } from '../SimpleSelect.stories.svelte';
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
component: SimpleSelect,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: storySimpleSelectArgTypes,
|
|
10
|
+
args: { options: storySimpleSelectOptions },
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story
|
|
15
|
+
name="Change"
|
|
16
|
+
args={{
|
|
17
|
+
onchange: (e: Event) => {
|
|
18
|
+
const target = e.target as HTMLSelectElement;
|
|
19
|
+
|
|
20
|
+
console.log('onChange Event', target.value);
|
|
21
|
+
},
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
<SimpleSelect
|
|
25
|
+
onchange={(e: Event) => {
|
|
26
|
+
const target = e.target as HTMLSelectElement;
|
|
27
|
+
|
|
28
|
+
console.log('onchange Event', target.value);
|
|
29
|
+
}}
|
|
30
|
+
options={storySimpleSelectOptions}
|
|
31
|
+
/>
|
|
32
|
+
</Story>
|
|
33
|
+
|
|
34
|
+
<!-- `e: SimpleSelectFocusEvent` -->
|
|
35
|
+
<Story
|
|
36
|
+
name="Focus"
|
|
37
|
+
args={{
|
|
38
|
+
onfocus: (e: SimpleSelectFocusEvent) => {
|
|
39
|
+
const target = e.target as HTMLSelectElement;
|
|
40
|
+
|
|
41
|
+
console.log('onfocus Event', target);
|
|
42
|
+
},
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<SimpleSelect
|
|
46
|
+
onfocus={(e: SimpleSelectFocusEvent) => {
|
|
47
|
+
const target = e.target as HTMLSelectElement;
|
|
48
|
+
|
|
49
|
+
console.log('onfocus Event', target);
|
|
50
|
+
}}
|
|
51
|
+
options={storySimpleSelectOptions}
|
|
52
|
+
/>
|
|
53
|
+
</Story>
|
|
54
|
+
|
|
55
|
+
<!-- `e: SimpleSelectFocusEvent` -->
|
|
56
|
+
<Story
|
|
57
|
+
name="Blur"
|
|
58
|
+
args={{
|
|
59
|
+
onblur: (e: SimpleSelectFocusEvent) => {
|
|
60
|
+
const target = e.target as HTMLSelectElement;
|
|
61
|
+
|
|
62
|
+
console.log('onblur Event', target);
|
|
63
|
+
},
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<SimpleSelect
|
|
67
|
+
onblur={(e: SimpleSelectFocusEvent) => {
|
|
68
|
+
const target = e.target as HTMLSelectElement;
|
|
69
|
+
|
|
70
|
+
console.log('onblur Event', target);
|
|
71
|
+
}}
|
|
72
|
+
options={storySimpleSelectOptions}
|
|
73
|
+
/>
|
|
74
|
+
</Story>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
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> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const Events: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type Events = InstanceType<typeof Events>;
|
|
18
|
+
export default Events;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import SimpleSelect from '../SimpleSelect.svelte';
|
|
4
|
+
import {
|
|
5
|
+
storySimpleSelectArgTypes,
|
|
6
|
+
storySimpleSelectOptions,
|
|
7
|
+
} from '../SimpleSelect.stories.svelte';
|
|
8
|
+
|
|
9
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
10
|
+
const { Story } = defineMeta({
|
|
11
|
+
component: SimpleSelect,
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
argTypes: storySimpleSelectArgTypes,
|
|
14
|
+
args: { options: storySimpleSelectOptions },
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Story name="Roundness 1x" />
|
|
19
|
+
|
|
20
|
+
<Story name="Roundness 2x" args={{ roundness: '2x' }} />
|
|
21
|
+
|
|
22
|
+
<Story name="Roundness 3x" args={{ roundness: '3x' }} />
|
|
23
|
+
|
|
24
|
+
<Story name="Roundness False" args={{ roundness: false }} />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default Roundness;
|
|
2
|
+
type Roundness = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const Roundness: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
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> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import {} from './SimpleSelect.svelte';
|
|
3
|
+
import SimpleSelect from './SimpleSelect.svelte';
|
|
4
|
+
export const storySimpleSelectArgTypes = {
|
|
5
|
+
type: {
|
|
6
|
+
control: { type: 'select' },
|
|
7
|
+
options: ['text', 'tel', 'email', 'password', 'url', 'number'],
|
|
8
|
+
},
|
|
9
|
+
roundness: {
|
|
10
|
+
control: { type: 'select' },
|
|
11
|
+
options: [false, '1x', '2x', '3x'],
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
control: { type: 'select' },
|
|
15
|
+
options: ['normal', 'small', 'large'],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export const storySimpleSelectOptions = [
|
|
19
|
+
{
|
|
20
|
+
value: 'volvo',
|
|
21
|
+
label: 'Volvo',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: 'saab',
|
|
25
|
+
label: 'Saab',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: 'mercedes',
|
|
29
|
+
label: 'Mercedes',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: 'audi',
|
|
33
|
+
label: 'Audi',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: 'opel',
|
|
37
|
+
label: 'Opel',
|
|
38
|
+
disabled: true,
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
42
|
+
const { Story } = defineMeta({
|
|
43
|
+
component: SimpleSelect,
|
|
44
|
+
tags: ['autodocs'],
|
|
45
|
+
argTypes: storySimpleSelectArgTypes,
|
|
46
|
+
args: { options: storySimpleSelectOptions },
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<!-- SimpleSelect with default style -->
|
|
51
|
+
<Story name="Default" />
|
|
52
|
+
|
|
53
|
+
<Story name="Placeholder" args={{ value: '', placeholder: 'Type something...' }} />
|
|
54
|
+
|
|
55
|
+
<Story name="No Outline" args={{ outline: false }} />
|
|
56
|
+
|
|
57
|
+
<Story name="Error" args={{ error: true }} />
|
|
58
|
+
|
|
59
|
+
<Story name="Disabled" args={{ disabled: true }} />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SimpleSelectOption } from './SimpleSelect.svelte';
|
|
2
|
+
import type { StoryBookArgTypes } from '../../../../storybook-types.js';
|
|
3
|
+
import SimpleSelect from './SimpleSelect.svelte';
|
|
4
|
+
export declare const storySimpleSelectArgTypes: StoryBookArgTypes;
|
|
5
|
+
export declare const storySimpleSelectOptions: SimpleSelectOption[];
|
|
6
|
+
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> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
16
|
+
};
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
18
|
+
}
|
|
19
|
+
declare const SimpleSelect: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {}, string>;
|
|
22
|
+
type SimpleSelect = InstanceType<typeof SimpleSelect>;
|
|
23
|
+
export default SimpleSelect;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script lang="ts" module>export {};
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<script lang="ts">import InputEnclosure from '../../../developer tools/components/InputEnclosure/InputEnclosure.svelte';
|
|
5
|
+
let { size = 'normal', roundness = '1x', outline = true, name, id, class: className = '', disabled = false, onchange, onblur, onfocus, before, after, error = false, value, placeholder, ref = $bindable(), options, } = $props();
|
|
6
|
+
let focused = $state(false);
|
|
7
|
+
function onfocusMod(e) {
|
|
8
|
+
focused = true;
|
|
9
|
+
if (onfocus) {
|
|
10
|
+
onfocus(e);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function onblurMod(e) {
|
|
14
|
+
focused = false;
|
|
15
|
+
if (onblur) {
|
|
16
|
+
onblur(e);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div
|
|
22
|
+
class:outline
|
|
23
|
+
class:disabled
|
|
24
|
+
class:error
|
|
25
|
+
class:focused
|
|
26
|
+
class={['dodo-ui-SimpleSelect', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
27
|
+
>
|
|
28
|
+
<InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
|
|
29
|
+
<select
|
|
30
|
+
{name}
|
|
31
|
+
{id}
|
|
32
|
+
{disabled}
|
|
33
|
+
{onchange}
|
|
34
|
+
onfocus={onfocusMod}
|
|
35
|
+
onblur={onblurMod}
|
|
36
|
+
{placeholder}
|
|
37
|
+
bind:this={ref}
|
|
38
|
+
>
|
|
39
|
+
{#each options as option (option.value)}
|
|
40
|
+
<option value={option.value} disabled={option.disabled} selected={value === option.value}>
|
|
41
|
+
{option.label}
|
|
42
|
+
</option>
|
|
43
|
+
{/each}
|
|
44
|
+
</select>
|
|
45
|
+
</InputEnclosure>
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<style>.dodo-ui-SimpleSelect select {
|
|
49
|
+
flex: 1;
|
|
50
|
+
border: 0;
|
|
51
|
+
outline: 0;
|
|
52
|
+
height: 100%;
|
|
53
|
+
background-color: transparent;
|
|
54
|
+
font-family: inherit;
|
|
55
|
+
color: inherit;
|
|
56
|
+
letter-spacing: 0.3px;
|
|
57
|
+
}
|
|
58
|
+
.dodo-ui-SimpleSelect.size--normal select {
|
|
59
|
+
font-size: 1rem;
|
|
60
|
+
padding: 0 12px;
|
|
61
|
+
}
|
|
62
|
+
.dodo-ui-SimpleSelect.size--small select {
|
|
63
|
+
padding: 0 8px;
|
|
64
|
+
font-size: 0.9rem;
|
|
65
|
+
}
|
|
66
|
+
.dodo-ui-SimpleSelect.size--large select {
|
|
67
|
+
font-size: 1.1rem;
|
|
68
|
+
padding: 0 14px;
|
|
69
|
+
}</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type SimpleSelectFocusEvent = FocusEvent & {
|
|
2
|
+
currentTarget: EventTarget & HTMLSelectElement;
|
|
3
|
+
};
|
|
4
|
+
export type SimpleSelectOption = {
|
|
5
|
+
value: string;
|
|
6
|
+
label: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
import type { ComponentRoundness, ComponentSize } from '../../../../types.js';
|
|
10
|
+
import type { Snippet } from 'svelte';
|
|
11
|
+
import type { ChangeEventHandler, FocusEventHandler } from 'svelte/elements';
|
|
12
|
+
interface SimpleSelectProps {
|
|
13
|
+
/** Select ref */
|
|
14
|
+
ref?: HTMLSelectElement;
|
|
15
|
+
/** How large should the button be? */
|
|
16
|
+
size?: ComponentSize;
|
|
17
|
+
/** How round should the border radius be? */
|
|
18
|
+
roundness?: ComponentRoundness | false;
|
|
19
|
+
/** How round should the border radius be? */
|
|
20
|
+
options: SimpleSelectOption[];
|
|
21
|
+
/** Add a border around the button. Default True */
|
|
22
|
+
outline?: boolean;
|
|
23
|
+
/** Select value */
|
|
24
|
+
value?: string;
|
|
25
|
+
/** How round should the border radius be? */
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/** disabled state */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** is there any associated Error ? */
|
|
30
|
+
error?: boolean;
|
|
31
|
+
/** Name */
|
|
32
|
+
name?: string;
|
|
33
|
+
/** Id */
|
|
34
|
+
id?: string;
|
|
35
|
+
/** Icon before button content */
|
|
36
|
+
before?: Snippet;
|
|
37
|
+
/** Icon after button content */
|
|
38
|
+
after?: Snippet;
|
|
39
|
+
/** Custom css class*/
|
|
40
|
+
class?: string;
|
|
41
|
+
/** onchange event handler */
|
|
42
|
+
onchange?: ChangeEventHandler<HTMLSelectElement>;
|
|
43
|
+
/** onblur event handler */
|
|
44
|
+
onblur?: FocusEventHandler<HTMLSelectElement>;
|
|
45
|
+
/** onfocus event handler */
|
|
46
|
+
onfocus?: FocusEventHandler<HTMLSelectElement>;
|
|
47
|
+
}
|
|
48
|
+
declare const SimpleSelect: import("svelte").Component<SimpleSelectProps, {}, "ref">;
|
|
49
|
+
type SimpleSelect = ReturnType<typeof SimpleSelect>;
|
|
50
|
+
export default SimpleSelect;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import SimpleSelect from '../SimpleSelect.svelte';
|
|
4
|
+
import {
|
|
5
|
+
storySimpleSelectArgTypes,
|
|
6
|
+
storySimpleSelectOptions,
|
|
7
|
+
} from '../SimpleSelect.stories.svelte';
|
|
8
|
+
|
|
9
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
10
|
+
const { Story } = defineMeta({
|
|
11
|
+
component: SimpleSelect,
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
argTypes: storySimpleSelectArgTypes,
|
|
14
|
+
args: { options: storySimpleSelectOptions },
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Story name="Normal" />
|
|
19
|
+
<Story name="Small" args={{ size: 'small' }} />
|
|
20
|
+
<Story name="Large" args={{ size: 'large' }} />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default Size;
|
|
2
|
+
type Size = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const Size: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
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> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Icon from '@iconify/svelte';
|
|
4
|
+
|
|
5
|
+
import SimpleSelect from '../SimpleSelect.svelte';
|
|
6
|
+
import {
|
|
7
|
+
storySimpleSelectArgTypes,
|
|
8
|
+
storySimpleSelectOptions,
|
|
9
|
+
} from '../SimpleSelect.stories.svelte';
|
|
10
|
+
|
|
11
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
12
|
+
const { Story } = defineMeta({
|
|
13
|
+
component: SimpleSelect,
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
argTypes: storySimpleSelectArgTypes,
|
|
16
|
+
args: { options: storySimpleSelectOptions },
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<!-- SimpleSelect icon in front. -->
|
|
21
|
+
<Story name="Icon Before">
|
|
22
|
+
<SimpleSelect options={storySimpleSelectOptions}>
|
|
23
|
+
{#snippet before()}
|
|
24
|
+
<Icon icon="material-symbols:content-copy" />
|
|
25
|
+
{/snippet}
|
|
26
|
+
</SimpleSelect>
|
|
27
|
+
</Story>
|
|
28
|
+
|
|
29
|
+
<!-- SimpleSelect icon in front. -->
|
|
30
|
+
<Story name="Icon After">
|
|
31
|
+
<SimpleSelect options={storySimpleSelectOptions}>
|
|
32
|
+
{#snippet after()}
|
|
33
|
+
<Icon icon="material-symbols:download-2" />
|
|
34
|
+
{/snippet}
|
|
35
|
+
</SimpleSelect>
|
|
36
|
+
</Story>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default WithIcon;
|
|
2
|
+
type WithIcon = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const WithIcon: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
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> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|