@flightlesslabs/dodo-ui 0.3.0 → 0.4.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 -0
- package/dist/index.js +8 -0
- package/dist/stories/components/Form/Button/Button.svelte +4 -1
- package/dist/stories/components/Form/Button/Button.svelte.d.ts +4 -2
- package/dist/stories/components/Form/FormControl/FormControl.stories.svelte +27 -0
- package/dist/stories/components/Form/FormControl/FormControl.stories.svelte.d.ts +19 -0
- package/dist/stories/components/Form/FormControl/FormControl.svelte +34 -0
- package/dist/stories/components/Form/FormControl/FormControl.svelte.d.ts +20 -0
- package/dist/stories/components/Form/Label/Label.stories.svelte +21 -0
- package/dist/stories/components/Form/Label/Label.stories.svelte.d.ts +19 -0
- package/dist/stories/components/Form/Label/Label.svelte +19 -0
- package/dist/stories/components/Form/Label/Label.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Message/Message.stories.svelte +46 -0
- package/dist/stories/components/Form/Message/Message.stories.svelte.d.ts +19 -0
- package/dist/stories/components/Form/Message/Message.svelte +39 -0
- package/dist/stories/components/Form/Message/Message.svelte.d.ts +17 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +17 -1
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +11 -34
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +8 -4
- package/dist/stories/components/Form/TextInput/TextInput.stories.svelte +2 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte +3 -1
- package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +6 -2
- package/dist/stories/developer tools/Intro.mdx +7 -0
- package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +27 -0
- package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +29 -0
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte.d.ts +21 -0
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte +79 -0
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte.d.ts +26 -0
- package/package.json +30 -30
- package/src/lib/index.ts +13 -0
- package/src/lib/stories/components/Form/Button/Button.svelte +8 -2
- package/src/lib/stories/components/Form/FormControl/FormControl.stories.svelte +29 -0
- package/src/lib/stories/components/Form/FormControl/FormControl.svelte +67 -0
- package/src/lib/stories/components/Form/Label/Label.stories.svelte +23 -0
- package/src/lib/stories/components/Form/Label/Label.svelte +45 -0
- package/src/lib/stories/components/Form/Message/Message.stories.svelte +48 -0
- package/src/lib/stories/components/Form/Message/Message.svelte +71 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +17 -1
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +22 -45
- package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +2 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.svelte +9 -1
- package/src/lib/stories/developer tools/Intro.mdx +7 -0
- package/src/lib/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +27 -0
- package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +33 -0
- package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte +128 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import './styles/global.css';
|
|
2
2
|
export type { ComponentSize, ComponentRoundness, ComponentRoundnessFull } from './types.js';
|
|
3
|
+
/** developer tools: components: UtilityButton */
|
|
4
|
+
export { default as UtilityButton } from './stories/developer tools/components/UtilityButton/UtilityButton.svelte';
|
|
3
5
|
/** Form: Button */
|
|
4
6
|
export { default as Button } from './stories/components/Form/Button/Button.svelte';
|
|
5
7
|
export type { ButtonColor, ButtonRoundness, ButtonLinkTarget, ButtonLinkReferrerpolicy, } from './stories/components/Form/Button/Button.svelte';
|
|
@@ -9,3 +11,10 @@ export type { TextInputRoundness, TextInputType, TextInputFocusEvent, TextInputC
|
|
|
9
11
|
/** Form: PasswordInput */
|
|
10
12
|
export { default as PasswordInput } from './stories/components/Form/PasswordInput/PasswordInput.svelte';
|
|
11
13
|
export type { PasswordInputToggleEvent } from './stories/components/Form/PasswordInput/PasswordInput.svelte';
|
|
14
|
+
/** Form: Label */
|
|
15
|
+
export { default as Label } from './stories/components/Form/Label/Label.svelte';
|
|
16
|
+
/** Form: FormControl */
|
|
17
|
+
export { default as FormControl } from './stories/components/Form/FormControl/FormControl.svelte';
|
|
18
|
+
/** Form: Message */
|
|
19
|
+
export { default as Message } from './stories/components/Form/Message/Message.svelte';
|
|
20
|
+
export type { MessageColor } from './stories/components/Form/Message/Message.svelte';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import './styles/global.css';
|
|
2
|
+
/** developer tools: components: UtilityButton */
|
|
3
|
+
export { default as UtilityButton } from './stories/developer tools/components/UtilityButton/UtilityButton.svelte';
|
|
2
4
|
/** Form: Button */
|
|
3
5
|
export { default as Button } from './stories/components/Form/Button/Button.svelte';
|
|
4
6
|
/** Form: TextInput */
|
|
5
7
|
export { default as TextInput } from './stories/components/Form/TextInput/TextInput.svelte';
|
|
6
8
|
/** Form: PasswordInput */
|
|
7
9
|
export { default as PasswordInput } from './stories/components/Form/PasswordInput/PasswordInput.svelte';
|
|
10
|
+
/** Form: Label */
|
|
11
|
+
export { default as Label } from './stories/components/Form/Label/Label.svelte';
|
|
12
|
+
/** Form: FormControl */
|
|
13
|
+
export { default as FormControl } from './stories/components/Form/FormControl/FormControl.svelte';
|
|
14
|
+
/** Form: Message */
|
|
15
|
+
export { default as Message } from './stories/components/Form/Message/Message.svelte';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>export {};
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
|
-
<script lang="ts">
|
|
4
|
+
<script lang="ts">let { children, type = 'button', size = 'normal', color = 'default', roundness = '1x', variant = 'text', outline = false, compact = false, fullWidth = false, name, id, title, class: className = '', disabled = false, onclick, before, after, href, download, hreflang, media, ping, rel, target, anchorMediaType, referrerpolicy, _unsafeChildrenStringForTesting, ref = $bindable(), } = $props();
|
|
5
5
|
export {};
|
|
6
6
|
</script>
|
|
7
7
|
|
|
@@ -50,6 +50,7 @@ export {};
|
|
|
50
50
|
`roundness--${roundness}`,
|
|
51
51
|
className,
|
|
52
52
|
].join(' ')}
|
|
53
|
+
bind:this={ref}
|
|
53
54
|
>
|
|
54
55
|
{@render buttonContent()}
|
|
55
56
|
</a>
|
|
@@ -72,6 +73,7 @@ export {};
|
|
|
72
73
|
{title}
|
|
73
74
|
{disabled}
|
|
74
75
|
{onclick}
|
|
76
|
+
bind:this={ref}
|
|
75
77
|
>
|
|
76
78
|
{@render buttonContent()}
|
|
77
79
|
</button>
|
|
@@ -188,6 +190,7 @@ export {};
|
|
|
188
190
|
outline: 0;
|
|
189
191
|
color: inherit;
|
|
190
192
|
letter-spacing: 0.3px;
|
|
193
|
+
font-family: inherit;
|
|
191
194
|
}
|
|
192
195
|
.dodo-ui-Button.size--normal {
|
|
193
196
|
height: var(--dodo-ui-element-height-normal);
|
|
@@ -6,8 +6,10 @@ import type { ComponentRoundness, ComponentRoundnessFull, ComponentSize } from '
|
|
|
6
6
|
import type { Snippet } from 'svelte';
|
|
7
7
|
import type { MouseEventHandler } from 'svelte/elements';
|
|
8
8
|
interface ButtonProps {
|
|
9
|
-
/** Button contents goes here*/
|
|
9
|
+
/** Button contents goes here */
|
|
10
10
|
children?: Snippet;
|
|
11
|
+
/** Button ref */
|
|
12
|
+
ref?: HTMLButtonElement | HTMLAnchorElement;
|
|
11
13
|
/** Regular button or submit button? */
|
|
12
14
|
type?: 'button' | 'submit';
|
|
13
15
|
/** How large should the button be? */
|
|
@@ -61,6 +63,6 @@ interface ButtonProps {
|
|
|
61
63
|
/** Test: ⚠️ Unsafe Children String. Do Not use*/
|
|
62
64
|
_unsafeChildrenStringForTesting?: string;
|
|
63
65
|
}
|
|
64
|
-
declare const Button: import("svelte").Component<ButtonProps, {}, "">;
|
|
66
|
+
declare const Button: import("svelte").Component<ButtonProps, {}, "ref">;
|
|
65
67
|
type Button = ReturnType<typeof Button>;
|
|
66
68
|
export default Button;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import FormControl from './FormControl.svelte';
|
|
3
|
+
import TextInput from '../TextInput/TextInput.svelte';
|
|
4
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
component: FormControl,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
});
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<Story name="Default" args={{ label: 'Hello there' }} />
|
|
12
|
+
|
|
13
|
+
<Story name="Example TextInput" args={{ label: 'Whats your first name?' }}>
|
|
14
|
+
<FormControl label="Whats your first name?" for="first-name-01">
|
|
15
|
+
<TextInput placeholder="First name" id="first-name-01" />
|
|
16
|
+
</FormControl>
|
|
17
|
+
</Story>
|
|
18
|
+
|
|
19
|
+
<Story name="ErrorMessage" args={{ label: 'Whats your first name?' }}>
|
|
20
|
+
<FormControl
|
|
21
|
+
label="Whats your first name?"
|
|
22
|
+
for="first-name-02"
|
|
23
|
+
errorMessage="This is an error message"
|
|
24
|
+
>
|
|
25
|
+
<TextInput value="John Smith" id="first-name-02" error />
|
|
26
|
+
</FormControl>
|
|
27
|
+
</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import FormControl from './FormControl.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 FormControl: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type FormControl = InstanceType<typeof FormControl>;
|
|
19
|
+
export default FormControl;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">import Label from '../Label/Label.svelte';
|
|
2
|
+
import Message from '../Message/Message.svelte';
|
|
3
|
+
let { children, label, class: className = '', for: htmlFor, form, ref = $bindable(), errorMessage, } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<div class={['dodo-ui-FormControl', className].join(' ')} bind:this={ref}>
|
|
7
|
+
{#if label}
|
|
8
|
+
<div class="LabelSection">
|
|
9
|
+
<Label for={htmlFor} {form}>{label}</Label>
|
|
10
|
+
</div>
|
|
11
|
+
{/if}
|
|
12
|
+
<div class="content">
|
|
13
|
+
{#if children}
|
|
14
|
+
{@render children()}
|
|
15
|
+
{/if}
|
|
16
|
+
</div>
|
|
17
|
+
{#if errorMessage}
|
|
18
|
+
<div class="errorMessage">
|
|
19
|
+
<Message color="danger">{errorMessage}</Message>
|
|
20
|
+
</div>
|
|
21
|
+
{/if}
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<style>:global(:root) {
|
|
25
|
+
--dodo-ui-FormControl-LabelSection-gap: 8px;
|
|
26
|
+
--dodo-ui-FormControl-errorMessage-gap: 16px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.dodo-ui-FormControl .LabelSection {
|
|
30
|
+
margin-bottom: var(--dodo-ui-FormControl-LabelSection-gap);
|
|
31
|
+
}
|
|
32
|
+
.dodo-ui-FormControl .errorMessage {
|
|
33
|
+
margin-top: var(--dodo-ui-FormControl-errorMessage-gap);
|
|
34
|
+
}</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface FormControlProps {
|
|
3
|
+
/** FormControl contents goes here */
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
/** Label for FormControl */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** is there any associated Error Message ? */
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
/** Label ref */
|
|
10
|
+
ref?: HTMLDivElement;
|
|
11
|
+
/** id of the form element the label should be bound to */
|
|
12
|
+
for?: string;
|
|
13
|
+
/** Specifies which form the label belongs to */
|
|
14
|
+
form?: string;
|
|
15
|
+
/** Custom css class*/
|
|
16
|
+
class?: string;
|
|
17
|
+
}
|
|
18
|
+
declare const FormControl: import("svelte").Component<FormControlProps, {}, "ref">;
|
|
19
|
+
type FormControl = ReturnType<typeof FormControl>;
|
|
20
|
+
export default FormControl;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import Label from './Label.svelte';
|
|
3
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
4
|
+
const { Story } = defineMeta({
|
|
5
|
+
component: Label,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<!-- ⚠️ Test Label: Do not use! -->
|
|
11
|
+
<Story
|
|
12
|
+
name="Test Label"
|
|
13
|
+
args={{
|
|
14
|
+
_unsafeChildrenStringForTesting: 'This is a form label',
|
|
15
|
+
}}
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<!-- Label with default style -->
|
|
19
|
+
<Story name="Default">
|
|
20
|
+
<Label>This is a form label</Label>
|
|
21
|
+
</Story>
|
|
@@ -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,19 @@
|
|
|
1
|
+
<script lang="ts">let { children, class: className = '', for: htmlFor, form, _unsafeChildrenStringForTesting, ref = $bindable(), } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<label class={['dodo-ui-Label', className].join(' ')} for={htmlFor} {form} bind:this={ref}>
|
|
6
|
+
{#if children}
|
|
7
|
+
{@render children()}
|
|
8
|
+
{:else if _unsafeChildrenStringForTesting}
|
|
9
|
+
{_unsafeChildrenStringForTesting}
|
|
10
|
+
{/if}
|
|
11
|
+
</label>
|
|
12
|
+
|
|
13
|
+
<style>.dodo-ui-Label {
|
|
14
|
+
font-size: 0.95rem;
|
|
15
|
+
color: var(--dodo-color-default-700);
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
font-family: inherit;
|
|
19
|
+
}</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface LabelProps {
|
|
3
|
+
/** Label contents goes here */
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
/** Label ref */
|
|
6
|
+
ref?: HTMLLabelElement;
|
|
7
|
+
/** id of the form element the label should be bound to */
|
|
8
|
+
for?: string;
|
|
9
|
+
/** Specifies which form the label belongs to */
|
|
10
|
+
form?: string;
|
|
11
|
+
/** Custom css class*/
|
|
12
|
+
class?: string;
|
|
13
|
+
/** Test: ⚠️ Unsafe Children String. Do Not use*/
|
|
14
|
+
_unsafeChildrenStringForTesting?: string;
|
|
15
|
+
}
|
|
16
|
+
declare const Label: import("svelte").Component<LabelProps, {}, "ref">;
|
|
17
|
+
type Label = ReturnType<typeof Label>;
|
|
18
|
+
export default Label;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import Message from './Message.svelte';
|
|
3
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
4
|
+
const { Story } = defineMeta({
|
|
5
|
+
component: Message,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
argTypes: {
|
|
8
|
+
color: {
|
|
9
|
+
control: { type: 'select' },
|
|
10
|
+
options: ['default', 'primary', 'safe', 'warning', 'danger', 'info'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<!-- ⚠️ Test Message: Do not use! -->
|
|
17
|
+
<Story
|
|
18
|
+
name="Test Message"
|
|
19
|
+
args={{
|
|
20
|
+
_unsafeChildrenStringForTesting: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
|
|
21
|
+
}}
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
<Story name="Default">
|
|
25
|
+
<Message>Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
26
|
+
</Story>
|
|
27
|
+
|
|
28
|
+
<Story name="Primary" args={{ color: 'primary' }}>
|
|
29
|
+
<Message color="primary">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
30
|
+
</Story>
|
|
31
|
+
|
|
32
|
+
<Story name="Safe" args={{ color: 'safe' }}>
|
|
33
|
+
<Message color="safe">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
34
|
+
</Story>
|
|
35
|
+
|
|
36
|
+
<Story name="Warning" args={{ color: 'warning' }}>
|
|
37
|
+
<Message color="warning">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
38
|
+
</Story>
|
|
39
|
+
|
|
40
|
+
<Story name="Danger" args={{ color: 'danger' }}>
|
|
41
|
+
<Message color="danger">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
42
|
+
</Story>
|
|
43
|
+
|
|
44
|
+
<Story name="Info" args={{ color: 'info' }}>
|
|
45
|
+
<Message color="info">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
46
|
+
</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Message from './Message.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 Message: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Message = InstanceType<typeof Message>;
|
|
19
|
+
export default Message;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts" module>export {};
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<script lang="ts">let { children, class: className = '', color = 'default', ref = $bindable(), _unsafeChildrenStringForTesting, } = $props();
|
|
5
|
+
export {};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<div class={['dodo-ui-Message', `color--${color}`, className].join(' ')} bind:this={ref}>
|
|
9
|
+
{#if children}
|
|
10
|
+
{@render children()}
|
|
11
|
+
{:else if _unsafeChildrenStringForTesting}
|
|
12
|
+
{_unsafeChildrenStringForTesting}
|
|
13
|
+
{/if}
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<style>.dodo-ui-Message {
|
|
17
|
+
font-size: 1rem;
|
|
18
|
+
letter-spacing: 0.3px;
|
|
19
|
+
display: flex;
|
|
20
|
+
font-family: inherit;
|
|
21
|
+
}
|
|
22
|
+
.dodo-ui-Message.color--default {
|
|
23
|
+
color: var(--dodo-color-default-800);
|
|
24
|
+
}
|
|
25
|
+
.dodo-ui-Message.color--primary {
|
|
26
|
+
color: var(--dodo-color-primary-600);
|
|
27
|
+
}
|
|
28
|
+
.dodo-ui-Message.color--safe {
|
|
29
|
+
color: var(--dodo-color-safe-600);
|
|
30
|
+
}
|
|
31
|
+
.dodo-ui-Message.color--warning {
|
|
32
|
+
color: var(--dodo-color-warning-600);
|
|
33
|
+
}
|
|
34
|
+
.dodo-ui-Message.color--danger {
|
|
35
|
+
color: var(--dodo-color-danger-600);
|
|
36
|
+
}
|
|
37
|
+
.dodo-ui-Message.color--info {
|
|
38
|
+
color: var(--dodo-color-info-600);
|
|
39
|
+
}</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type MessageColor = 'default' | 'primary' | 'safe' | 'warning' | 'danger' | 'info';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
interface MessageProps {
|
|
4
|
+
/** Message contents goes here */
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
/** Message ref */
|
|
7
|
+
ref?: HTMLDivElement;
|
|
8
|
+
/** What color to use? */
|
|
9
|
+
color?: MessageColor;
|
|
10
|
+
/** Custom css class*/
|
|
11
|
+
class?: string;
|
|
12
|
+
/** Test: ⚠️ Unsafe Children String. Do Not use*/
|
|
13
|
+
_unsafeChildrenStringForTesting?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const Message: import("svelte").Component<MessageProps, {}, "ref">;
|
|
16
|
+
type Message = ReturnType<typeof Message>;
|
|
17
|
+
export default Message;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
2
|
import PasswordInput from './PasswordInput.svelte';
|
|
3
|
+
import Icon from '@iconify/svelte';
|
|
3
4
|
export const storyPasswordInputArgTypes = {
|
|
4
5
|
roundness: {
|
|
5
6
|
control: { type: 'select' },
|
|
@@ -34,4 +35,19 @@ const { Story } = defineMeta({
|
|
|
34
35
|
<Story name="No toggle" args={{ passwordToggle: false }} />
|
|
35
36
|
|
|
36
37
|
<!-- Show Password by default -->
|
|
37
|
-
<Story name="Show Password" args={{
|
|
38
|
+
<Story name="Show Password" args={{ passwordToggleState: true }} />
|
|
39
|
+
|
|
40
|
+
<Story name="Read only" args={{ readonly: true }} />
|
|
41
|
+
|
|
42
|
+
<!-- Show Password by default -->
|
|
43
|
+
<Story name="Custom toggle icon">
|
|
44
|
+
<PasswordInput value="Hello world!">
|
|
45
|
+
{#snippet customPasswordToggleIcon(toggle)}
|
|
46
|
+
{#if toggle}
|
|
47
|
+
<Icon icon="mingcute:eye-close-line" width="24" height="24" />
|
|
48
|
+
{:else}
|
|
49
|
+
<Icon icon="mingcute:eye-2-line" width="24" height="24" />
|
|
50
|
+
{/if}
|
|
51
|
+
{/snippet}
|
|
52
|
+
</PasswordInput>
|
|
53
|
+
</Story>
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
4
|
<script lang="ts">import Icon from '@iconify/svelte';
|
|
5
|
-
|
|
5
|
+
import UtilityButton from '../../../developer tools/components/UtilityButton/UtilityButton.svelte';
|
|
6
|
+
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();
|
|
6
7
|
let focused = $state(false);
|
|
7
|
-
let toggle = $state(
|
|
8
|
+
let toggle = $state(passwordToggleState);
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
let customPasswordToggleIconTyped = customPasswordToggleIcon;
|
|
8
11
|
function onfocusMod(e) {
|
|
9
12
|
focused = true;
|
|
10
13
|
if (onfocus) {
|
|
@@ -56,18 +59,20 @@ function ontoggleMod(e) {
|
|
|
56
59
|
{oncut}
|
|
57
60
|
{placeholder}
|
|
58
61
|
bind:value
|
|
62
|
+
bind:this={ref}
|
|
63
|
+
{readonly}
|
|
59
64
|
/>
|
|
60
65
|
|
|
61
66
|
{#if passwordToggle && !disabled}
|
|
62
|
-
<
|
|
63
|
-
{#if
|
|
64
|
-
{@render
|
|
67
|
+
<UtilityButton {size} title="Toggle password" class="passwordToggle" onclick={ontoggleMod}>
|
|
68
|
+
{#if customPasswordToggleIcon}
|
|
69
|
+
{@render customPasswordToggleIconTyped(toggle)}
|
|
65
70
|
{:else if toggle}
|
|
66
71
|
<Icon icon="mdi:eye-off" width="24" height="24" />
|
|
67
72
|
{:else}
|
|
68
73
|
<Icon icon="mdi:eye" width="24" height="24" />
|
|
69
74
|
{/if}
|
|
70
|
-
</
|
|
75
|
+
</UtilityButton>
|
|
71
76
|
{/if}
|
|
72
77
|
|
|
73
78
|
{#if after}
|
|
@@ -83,7 +88,6 @@ function ontoggleMod(e) {
|
|
|
83
88
|
--dodo-ui-PasswordInput-error-border-color: var(--dodo-color-danger-500);
|
|
84
89
|
--dodo-ui-PasswordInput-disabled-color: var(--dodo-color-default-400);
|
|
85
90
|
--dodo-ui-PasswordInput-disabled-bg: var(--dodo-color-default-200);
|
|
86
|
-
--dodo-ui-PasswordInput-ToggleButton-hover: var(--dodo-color-primary-700);
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
:global(.dodo-theme--dark) {
|
|
@@ -92,7 +96,6 @@ function ontoggleMod(e) {
|
|
|
92
96
|
--dodo-ui-PasswordInput-error-border-color: var(--dodo-color-danger-600);
|
|
93
97
|
--dodo-ui-PasswordInput-disabled-bg: var(--dodo-color-default-100);
|
|
94
98
|
--dodo-ui-PasswordInput-disabled-color: var(--dodo-color-default-500);
|
|
95
|
-
--dodo-ui-PasswordInput-ToggleButton-hover: var(--dodo-color-primary-600);
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
.dodo-ui-PasswordInput {
|
|
@@ -152,9 +155,6 @@ function ontoggleMod(e) {
|
|
|
152
155
|
margin-right: 12px;
|
|
153
156
|
margin-left: -4px;
|
|
154
157
|
}
|
|
155
|
-
.dodo-ui-PasswordInput.size--normal .passwordToggle {
|
|
156
|
-
width: var(--dodo-ui-element-height-normal);
|
|
157
|
-
}
|
|
158
158
|
.dodo-ui-PasswordInput.size--small {
|
|
159
159
|
height: var(--dodo-ui-element-height-small);
|
|
160
160
|
}
|
|
@@ -170,9 +170,6 @@ function ontoggleMod(e) {
|
|
|
170
170
|
margin-right: 8px;
|
|
171
171
|
margin-left: -2px;
|
|
172
172
|
}
|
|
173
|
-
.dodo-ui-PasswordInput.size--small .passwordToggle {
|
|
174
|
-
width: var(--dodo-ui-element-height-small);
|
|
175
|
-
}
|
|
176
173
|
.dodo-ui-PasswordInput.size--large {
|
|
177
174
|
height: var(--dodo-ui-element-height-large);
|
|
178
175
|
}
|
|
@@ -188,9 +185,6 @@ function ontoggleMod(e) {
|
|
|
188
185
|
margin-right: 14px;
|
|
189
186
|
margin-left: -4px;
|
|
190
187
|
}
|
|
191
|
-
.dodo-ui-PasswordInput.size--large .passwordToggle {
|
|
192
|
-
width: var(--dodo-ui-element-height-large);
|
|
193
|
-
}
|
|
194
188
|
.dodo-ui-PasswordInput.roundness--1x {
|
|
195
189
|
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
196
190
|
}
|
|
@@ -199,21 +193,4 @@ function ontoggleMod(e) {
|
|
|
199
193
|
}
|
|
200
194
|
.dodo-ui-PasswordInput.roundness--3x {
|
|
201
195
|
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
202
|
-
}
|
|
203
|
-
.dodo-ui-PasswordInput .passwordToggle {
|
|
204
|
-
background-color: transparent;
|
|
205
|
-
outline: 0;
|
|
206
|
-
border: 0;
|
|
207
|
-
display: inline-flex;
|
|
208
|
-
justify-content: center;
|
|
209
|
-
align-items: center;
|
|
210
|
-
height: 100%;
|
|
211
|
-
cursor: pointer;
|
|
212
|
-
padding: 0;
|
|
213
|
-
margin-right: 4px;
|
|
214
|
-
color: var(--dodo-color-default-700);
|
|
215
|
-
transition: all 150ms;
|
|
216
|
-
}
|
|
217
|
-
.dodo-ui-PasswordInput .passwordToggle:hover {
|
|
218
|
-
color: var(--dodo-ui-PasswordInput-ToggleButton-hover);
|
|
219
196
|
}</style>
|
|
@@ -9,12 +9,14 @@ import type { TextInputRoundness } from '../TextInput/TextInput.svelte';
|
|
|
9
9
|
interface PasswordInputProps {
|
|
10
10
|
/** How large should the button be? */
|
|
11
11
|
size?: ComponentSize;
|
|
12
|
+
/** Input ref */
|
|
13
|
+
ref?: HTMLInputElement;
|
|
12
14
|
/** Toggle Password */
|
|
13
15
|
passwordToggle?: boolean;
|
|
14
16
|
/** Default Password Toggle State */
|
|
15
|
-
|
|
17
|
+
passwordToggleState?: boolean;
|
|
16
18
|
/** Toggle Password Icon */
|
|
17
|
-
|
|
19
|
+
customPasswordToggleIcon?: (toggle: boolean) => Snippet;
|
|
18
20
|
/** How round should the border radius be? */
|
|
19
21
|
roundness?: TextInputRoundness;
|
|
20
22
|
/** Add a border around the button. Default True */
|
|
@@ -23,8 +25,10 @@ interface PasswordInputProps {
|
|
|
23
25
|
value?: string;
|
|
24
26
|
/** How round should the border radius be? */
|
|
25
27
|
placeholder?: string;
|
|
26
|
-
/**
|
|
28
|
+
/** disabled state */
|
|
27
29
|
disabled?: boolean;
|
|
30
|
+
/** Read only ? */
|
|
31
|
+
readonly?: boolean;
|
|
28
32
|
/** is there any associated Error ? */
|
|
29
33
|
error?: boolean;
|
|
30
34
|
/** Name */
|
|
@@ -54,6 +58,6 @@ interface PasswordInputProps {
|
|
|
54
58
|
/** ontoggle event handler */
|
|
55
59
|
ontoggle?: (e: PasswordInputToggleEvent) => void;
|
|
56
60
|
}
|
|
57
|
-
declare const PasswordInput: import("svelte").Component<PasswordInputProps, {}, "value">;
|
|
61
|
+
declare const PasswordInput: import("svelte").Component<PasswordInputProps, {}, "ref" | "value" | "passwordToggleState">;
|
|
58
62
|
type PasswordInput = ReturnType<typeof PasswordInput>;
|
|
59
63
|
export default PasswordInput;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>export {};
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
|
-
<script lang="ts">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, } = $props();
|
|
4
|
+
<script lang="ts">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
5
|
let focused = $state(false);
|
|
6
6
|
function onfocusMod(e) {
|
|
7
7
|
focused = true;
|
|
@@ -43,7 +43,9 @@ export {};
|
|
|
43
43
|
{oncopy}
|
|
44
44
|
{oncut}
|
|
45
45
|
{placeholder}
|
|
46
|
+
{readonly}
|
|
46
47
|
bind:value
|
|
48
|
+
bind:this={ref}
|
|
47
49
|
/>
|
|
48
50
|
{#if after}
|
|
49
51
|
<span class="content--after">
|
|
@@ -12,6 +12,8 @@ import type { ChangeEventHandler, ClipboardEventHandler, FocusEventHandler, Form
|
|
|
12
12
|
interface TextInputProps {
|
|
13
13
|
/** Input type? */
|
|
14
14
|
type?: TextInputType;
|
|
15
|
+
/** Input ref */
|
|
16
|
+
ref?: HTMLInputElement;
|
|
15
17
|
/** How large should the button be? */
|
|
16
18
|
size?: ComponentSize;
|
|
17
19
|
/** How round should the border radius be? */
|
|
@@ -22,8 +24,10 @@ interface TextInputProps {
|
|
|
22
24
|
value?: string;
|
|
23
25
|
/** How round should the border radius be? */
|
|
24
26
|
placeholder?: string;
|
|
25
|
-
/**
|
|
27
|
+
/** disabled state */
|
|
26
28
|
disabled?: boolean;
|
|
29
|
+
/** Read only ? */
|
|
30
|
+
readonly?: boolean;
|
|
27
31
|
/** is there any associated Error ? */
|
|
28
32
|
error?: boolean;
|
|
29
33
|
/** Name */
|
|
@@ -51,6 +55,6 @@ interface TextInputProps {
|
|
|
51
55
|
/** oncut event handler */
|
|
52
56
|
oncut?: ClipboardEventHandler<HTMLInputElement>;
|
|
53
57
|
}
|
|
54
|
-
declare const TextInput: import("svelte").Component<TextInputProps, {}, "value">;
|
|
58
|
+
declare const TextInput: import("svelte").Component<TextInputProps, {}, "ref" | "value">;
|
|
55
59
|
type TextInput = ReturnType<typeof TextInput>;
|
|
56
60
|
export default TextInput;
|