@flightlesslabs/dodo-ui 0.4.0 → 0.5.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 +6 -1
- package/dist/index.js +4 -0
- 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 +14 -3
- package/dist/stories/components/Form/Message/Message.svelte.d.ts +3 -0
- 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/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/package.json +1 -1
- package/src/lib/index.ts +10 -1
- 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 +23 -2
- 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/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
|
@@ -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
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script lang="ts" module>export {};
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
|
-
<script lang="ts">
|
|
4
|
+
<script lang="ts">import InputEnclosure from '../../../developer tools/components/InputEnclosure/InputEnclosure.svelte';
|
|
5
|
+
let { type = 'text', size = 'normal', roundness = '1x', outline = true, name, id, class: className = '', disabled = false, oninput, onchange, onblur, onfocus, onpaste, oncopy, oncut, before, after, error = false, value = $bindable(), placeholder, ref = $bindable(), readonly = false, } = $props();
|
|
5
6
|
let focused = $state(false);
|
|
6
7
|
function onfocusMod(e) {
|
|
7
8
|
focused = true;
|
|
@@ -15,7 +16,6 @@ function onblurMod(e) {
|
|
|
15
16
|
onblur(e);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
export {};
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<div
|
|
@@ -25,59 +25,28 @@ export {};
|
|
|
25
25
|
class:focused
|
|
26
26
|
class={['dodo-ui-TextInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
27
27
|
>
|
|
28
|
-
{
|
|
29
|
-
<
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
bind:value
|
|
48
|
-
bind:this={ref}
|
|
49
|
-
/>
|
|
50
|
-
{#if after}
|
|
51
|
-
<span class="content--after">
|
|
52
|
-
{@render after()}
|
|
53
|
-
</span>
|
|
54
|
-
{/if}
|
|
28
|
+
<InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
|
|
29
|
+
<input
|
|
30
|
+
{type}
|
|
31
|
+
{name}
|
|
32
|
+
{id}
|
|
33
|
+
{disabled}
|
|
34
|
+
{oninput}
|
|
35
|
+
{onchange}
|
|
36
|
+
onfocus={onfocusMod}
|
|
37
|
+
onblur={onblurMod}
|
|
38
|
+
{onpaste}
|
|
39
|
+
{oncopy}
|
|
40
|
+
{oncut}
|
|
41
|
+
{placeholder}
|
|
42
|
+
{readonly}
|
|
43
|
+
bind:value
|
|
44
|
+
bind:this={ref}
|
|
45
|
+
/>
|
|
46
|
+
</InputEnclosure>
|
|
55
47
|
</div>
|
|
56
48
|
|
|
57
|
-
<style
|
|
58
|
-
--dodo-ui-TextInput-border-color: var(--dodo-color-default-500);
|
|
59
|
-
--dodo-ui-TextInput-focus-border-color: var(--dodo-color-primary-500);
|
|
60
|
-
--dodo-ui-TextInput-error-border-color: var(--dodo-color-danger-500);
|
|
61
|
-
--dodo-ui-TextInput-disabled-color: var(--dodo-color-default-400);
|
|
62
|
-
--dodo-ui-TextInput-disabled-bg: var(--dodo-color-default-200);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
:global(.dodo-theme--dark) {
|
|
66
|
-
--dodo-ui-TextInput-border-color: var(--dodo-color-default-600);
|
|
67
|
-
--dodo-ui-TextInput-focus-border-color: var(--dodo-color-primary-600);
|
|
68
|
-
--dodo-ui-TextInput-error-border-color: var(--dodo-color-danger-600);
|
|
69
|
-
--dodo-ui-TextInput-disabled-bg: var(--dodo-color-default-100);
|
|
70
|
-
--dodo-ui-TextInput-disabled-color: var(--dodo-color-default-500);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.dodo-ui-TextInput {
|
|
74
|
-
display: flex;
|
|
75
|
-
overflow: hidden;
|
|
76
|
-
color: var(--dodo-color-default-800);
|
|
77
|
-
transition: all 150ms;
|
|
78
|
-
border: 0;
|
|
79
|
-
}
|
|
80
|
-
.dodo-ui-TextInput input {
|
|
49
|
+
<style>.dodo-ui-TextInput input {
|
|
81
50
|
flex: 1;
|
|
82
51
|
border: 0;
|
|
83
52
|
outline: 0;
|
|
@@ -87,82 +56,15 @@ export {};
|
|
|
87
56
|
color: inherit;
|
|
88
57
|
letter-spacing: 0.3px;
|
|
89
58
|
}
|
|
90
|
-
.dodo-ui-TextInput.outline {
|
|
91
|
-
border-style: solid;
|
|
92
|
-
border-width: var(--dodo-ui-element-border-width);
|
|
93
|
-
border-color: var(--dodo-ui-TextInput-border-color);
|
|
94
|
-
}
|
|
95
|
-
.dodo-ui-TextInput.focused {
|
|
96
|
-
border-color: var(--dodo-ui-TextInput-focus-border-color);
|
|
97
|
-
}
|
|
98
|
-
.dodo-ui-TextInput.error {
|
|
99
|
-
border-color: var(--dodo-ui-TextInput-error-border-color);
|
|
100
|
-
}
|
|
101
|
-
.dodo-ui-TextInput.disabled {
|
|
102
|
-
cursor: initial;
|
|
103
|
-
background-color: var(--dodo-ui-TextInput-disabled-bg);
|
|
104
|
-
color: var(--dodo-ui-TextInput-disabled-color);
|
|
105
|
-
border-color: var(--dodo-ui-TextInput-disabled-bg);
|
|
106
|
-
}
|
|
107
|
-
.dodo-ui-TextInput .content--after:empty, .dodo-ui-TextInput .content--before:empty {
|
|
108
|
-
display: none;
|
|
109
|
-
}
|
|
110
|
-
.dodo-ui-TextInput .content--after, .dodo-ui-TextInput .content--before {
|
|
111
|
-
display: inline-flex;
|
|
112
|
-
height: 100%;
|
|
113
|
-
align-items: center;
|
|
114
|
-
}
|
|
115
|
-
.dodo-ui-TextInput.size--normal {
|
|
116
|
-
height: var(--dodo-ui-element-height-normal);
|
|
117
|
-
}
|
|
118
59
|
.dodo-ui-TextInput.size--normal input {
|
|
119
60
|
font-size: 1rem;
|
|
120
61
|
padding: 0 12px;
|
|
121
62
|
}
|
|
122
|
-
.dodo-ui-TextInput.size--normal .content--before {
|
|
123
|
-
margin-left: 12px;
|
|
124
|
-
margin-right: -4px;
|
|
125
|
-
}
|
|
126
|
-
.dodo-ui-TextInput.size--normal .content--after {
|
|
127
|
-
margin-right: 12px;
|
|
128
|
-
margin-left: -4px;
|
|
129
|
-
}
|
|
130
|
-
.dodo-ui-TextInput.size--small {
|
|
131
|
-
height: var(--dodo-ui-element-height-small);
|
|
132
|
-
}
|
|
133
63
|
.dodo-ui-TextInput.size--small input {
|
|
134
64
|
padding: 0 8px;
|
|
135
65
|
font-size: 0.9rem;
|
|
136
66
|
}
|
|
137
|
-
.dodo-ui-TextInput.size--small .content--before {
|
|
138
|
-
margin-left: 8px;
|
|
139
|
-
margin-right: -2px;
|
|
140
|
-
}
|
|
141
|
-
.dodo-ui-TextInput.size--small .content--after {
|
|
142
|
-
margin-right: 8px;
|
|
143
|
-
margin-left: -2px;
|
|
144
|
-
}
|
|
145
|
-
.dodo-ui-TextInput.size--large {
|
|
146
|
-
height: var(--dodo-ui-element-height-large);
|
|
147
|
-
}
|
|
148
67
|
.dodo-ui-TextInput.size--large input {
|
|
149
68
|
font-size: 1.1rem;
|
|
150
69
|
padding: 0 14px;
|
|
151
|
-
}
|
|
152
|
-
.dodo-ui-TextInput.size--large .content--before {
|
|
153
|
-
margin-left: 14px;
|
|
154
|
-
margin-right: -4px;
|
|
155
|
-
}
|
|
156
|
-
.dodo-ui-TextInput.size--large .content--after {
|
|
157
|
-
margin-right: 14px;
|
|
158
|
-
margin-left: -4px;
|
|
159
|
-
}
|
|
160
|
-
.dodo-ui-TextInput.roundness--1x {
|
|
161
|
-
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
162
|
-
}
|
|
163
|
-
.dodo-ui-TextInput.roundness--2x {
|
|
164
|
-
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
165
|
-
}
|
|
166
|
-
.dodo-ui-TextInput.roundness--3x {
|
|
167
|
-
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
168
70
|
}</style>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type TextInputRoundness = ComponentRoundness | false;
|
|
2
1
|
export type TextInputType = 'text' | 'tel' | 'email' | 'password' | 'url' | 'number';
|
|
3
2
|
export type TextInputFocusEvent = FocusEvent & {
|
|
4
3
|
currentTarget: EventTarget & HTMLInputElement;
|
|
@@ -17,7 +16,7 @@ interface TextInputProps {
|
|
|
17
16
|
/** How large should the button be? */
|
|
18
17
|
size?: ComponentSize;
|
|
19
18
|
/** How round should the border radius be? */
|
|
20
|
-
roundness?:
|
|
19
|
+
roundness?: ComponentRoundness | false;
|
|
21
20
|
/** Add a border around the button. Default True */
|
|
22
21
|
outline?: boolean;
|
|
23
22
|
/** Input value */
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import InputEnclosure from './InputEnclosure.svelte';
|
|
3
|
+
export const storyInputEnclosureArgTypes = {
|
|
4
|
+
roundness: {
|
|
5
|
+
control: { type: 'select' },
|
|
6
|
+
options: [false, '1x', '2x', '3x'],
|
|
7
|
+
},
|
|
8
|
+
size: {
|
|
9
|
+
control: { type: 'select' },
|
|
10
|
+
options: ['normal', 'small', 'large'],
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
14
|
+
const { Story } = defineMeta({
|
|
15
|
+
component: InputEnclosure,
|
|
16
|
+
tags: ['autodocs'],
|
|
17
|
+
argTypes: storyInputEnclosureArgTypes,
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<!-- An ensloure for Form Inputs [TextInput](?path=/docs/components-form-textinput--docs) -->
|
|
22
|
+
<Story name="Default" />
|
|
23
|
+
|
|
24
|
+
<Story name="Focused" args={{ focused: true }} />
|
|
25
|
+
|
|
26
|
+
<Story name="Error" args={{ error: true }} />
|
|
27
|
+
|
|
28
|
+
<Story name="Disabled" args={{ disabled: true }} />
|
|
29
|
+
|
|
30
|
+
<Story name="Input example">
|
|
31
|
+
<InputEnclosure>
|
|
32
|
+
<input type="text" style="flex: 1; border: 0;" placeholder="Enter name" />
|
|
33
|
+
</InputEnclosure>
|
|
34
|
+
</Story>
|
package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import InputEnclosure from './InputEnclosure.svelte';
|
|
2
|
+
import type { StoryBookArgTypes } from '../../../../storybook-types.js';
|
|
3
|
+
export declare const storyInputEnclosureArgTypes: StoryBookArgTypes;
|
|
4
|
+
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> {
|
|
5
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
+
$$bindings?: Bindings;
|
|
7
|
+
} & Exports;
|
|
8
|
+
(internal: unknown, props: {
|
|
9
|
+
$$events?: Events;
|
|
10
|
+
$$slots?: Slots;
|
|
11
|
+
}): Exports & {
|
|
12
|
+
$set?: any;
|
|
13
|
+
$on?: any;
|
|
14
|
+
};
|
|
15
|
+
z_$$bindings?: Bindings;
|
|
16
|
+
}
|
|
17
|
+
declare const InputEnclosure: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type InputEnclosure = InstanceType<typeof InputEnclosure>;
|
|
21
|
+
export default InputEnclosure;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script lang="ts">let { size = 'normal', roundness = '1x', outline = true, class: className = '', disabled = false, before, after, error = false, focused = false, children, ref = $bindable(), } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div
|
|
6
|
+
class:outline
|
|
7
|
+
class:disabled
|
|
8
|
+
class:error
|
|
9
|
+
class:focused
|
|
10
|
+
class={['dodo-ui-InputEnclosure', `size--${size}`, `roundness--${roundness}`, className].join(
|
|
11
|
+
' ',
|
|
12
|
+
)}
|
|
13
|
+
bind:this={ref}
|
|
14
|
+
>
|
|
15
|
+
{#if before}
|
|
16
|
+
<span class="content--before">
|
|
17
|
+
{@render before()}
|
|
18
|
+
</span>
|
|
19
|
+
{/if}
|
|
20
|
+
|
|
21
|
+
{#if children}
|
|
22
|
+
{@render children()}
|
|
23
|
+
{/if}
|
|
24
|
+
{#if after}
|
|
25
|
+
<span class="content--after">
|
|
26
|
+
{@render after()}
|
|
27
|
+
</span>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<style>:global(:root) {
|
|
32
|
+
--dodo-ui-InputEnclosure-border-color: var(--dodo-color-default-500);
|
|
33
|
+
--dodo-ui-InputEnclosure-focus-border-color: var(--dodo-color-primary-500);
|
|
34
|
+
--dodo-ui-InputEnclosure-error-border-color: var(--dodo-color-danger-500);
|
|
35
|
+
--dodo-ui-InputEnclosure-disabled-color: var(--dodo-color-default-400);
|
|
36
|
+
--dodo-ui-InputEnclosure-disabled-bg: var(--dodo-color-default-200);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:global(.dodo-theme--dark) {
|
|
40
|
+
--dodo-ui-InputEnclosure-border-color: var(--dodo-color-default-600);
|
|
41
|
+
--dodo-ui-InputEnclosure-focus-border-color: var(--dodo-color-primary-600);
|
|
42
|
+
--dodo-ui-InputEnclosure-error-border-color: var(--dodo-color-danger-600);
|
|
43
|
+
--dodo-ui-InputEnclosure-disabled-bg: var(--dodo-color-default-100);
|
|
44
|
+
--dodo-ui-InputEnclosure-disabled-color: var(--dodo-color-default-500);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.dodo-ui-InputEnclosure {
|
|
48
|
+
display: flex;
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
color: var(--dodo-color-default-800);
|
|
51
|
+
transition: all 150ms;
|
|
52
|
+
border: 0;
|
|
53
|
+
}
|
|
54
|
+
.dodo-ui-InputEnclosure.outline {
|
|
55
|
+
border-style: solid;
|
|
56
|
+
border-width: var(--dodo-ui-element-border-width);
|
|
57
|
+
border-color: var(--dodo-ui-InputEnclosure-border-color);
|
|
58
|
+
}
|
|
59
|
+
.dodo-ui-InputEnclosure.focused {
|
|
60
|
+
border-color: var(--dodo-ui-InputEnclosure-focus-border-color);
|
|
61
|
+
}
|
|
62
|
+
.dodo-ui-InputEnclosure.error {
|
|
63
|
+
border-color: var(--dodo-ui-InputEnclosure-error-border-color);
|
|
64
|
+
}
|
|
65
|
+
.dodo-ui-InputEnclosure.disabled {
|
|
66
|
+
cursor: initial;
|
|
67
|
+
background-color: var(--dodo-ui-InputEnclosure-disabled-bg);
|
|
68
|
+
color: var(--dodo-ui-InputEnclosure-disabled-color);
|
|
69
|
+
border-color: var(--dodo-ui-InputEnclosure-disabled-bg);
|
|
70
|
+
}
|
|
71
|
+
.dodo-ui-InputEnclosure .content--after:empty, .dodo-ui-InputEnclosure .content--before:empty {
|
|
72
|
+
display: none;
|
|
73
|
+
}
|
|
74
|
+
.dodo-ui-InputEnclosure .content--after, .dodo-ui-InputEnclosure .content--before {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
height: 100%;
|
|
77
|
+
align-items: center;
|
|
78
|
+
}
|
|
79
|
+
.dodo-ui-InputEnclosure.size--normal {
|
|
80
|
+
height: var(--dodo-ui-element-height-normal);
|
|
81
|
+
}
|
|
82
|
+
.dodo-ui-InputEnclosure.size--normal .content--before {
|
|
83
|
+
margin-left: 12px;
|
|
84
|
+
margin-right: -4px;
|
|
85
|
+
}
|
|
86
|
+
.dodo-ui-InputEnclosure.size--normal .content--after {
|
|
87
|
+
margin-right: 12px;
|
|
88
|
+
margin-left: -4px;
|
|
89
|
+
}
|
|
90
|
+
.dodo-ui-InputEnclosure.size--small {
|
|
91
|
+
height: var(--dodo-ui-element-height-small);
|
|
92
|
+
}
|
|
93
|
+
.dodo-ui-InputEnclosure.size--small .content--before {
|
|
94
|
+
margin-left: 8px;
|
|
95
|
+
margin-right: -2px;
|
|
96
|
+
}
|
|
97
|
+
.dodo-ui-InputEnclosure.size--small .content--after {
|
|
98
|
+
margin-right: 8px;
|
|
99
|
+
margin-left: -2px;
|
|
100
|
+
}
|
|
101
|
+
.dodo-ui-InputEnclosure.size--large {
|
|
102
|
+
height: var(--dodo-ui-element-height-large);
|
|
103
|
+
}
|
|
104
|
+
.dodo-ui-InputEnclosure.size--large .content--before {
|
|
105
|
+
margin-left: 14px;
|
|
106
|
+
margin-right: -4px;
|
|
107
|
+
}
|
|
108
|
+
.dodo-ui-InputEnclosure.size--large .content--after {
|
|
109
|
+
margin-right: 14px;
|
|
110
|
+
margin-left: -4px;
|
|
111
|
+
}
|
|
112
|
+
.dodo-ui-InputEnclosure.roundness--1x {
|
|
113
|
+
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
114
|
+
}
|
|
115
|
+
.dodo-ui-InputEnclosure.roundness--2x {
|
|
116
|
+
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
117
|
+
}
|
|
118
|
+
.dodo-ui-InputEnclosure.roundness--3x {
|
|
119
|
+
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
120
|
+
}</style>
|