@flightlesslabs/dodo-ui 0.6.6 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +28 -7
- package/dist/index.js +12 -2
- package/dist/stories/Home.mdx +1 -1
- package/dist/stories/components/Form/Button/Button.svelte +2 -2
- package/dist/stories/components/Form/Button/Button.svelte.d.ts +8 -5
- package/dist/stories/components/Form/FormControl/FormControl.svelte +3 -0
- package/dist/stories/components/Form/FormControl/FormControl.svelte.d.ts +1 -1
- package/dist/stories/components/Form/Label/Label.svelte +5 -2
- package/dist/stories/components/Form/Label/Label.svelte.d.ts +1 -1
- package/dist/stories/components/Form/Message/Message.svelte +5 -2
- package/dist/stories/components/Form/Message/Message.svelte.d.ts +1 -1
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +25 -32
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +5 -5
- package/dist/stories/components/Form/Select/Customize/Customize.stories.svelte +120 -0
- package/dist/stories/components/Form/Select/Customize/Customize.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Select/Events/Events.stories.svelte +138 -0
- package/dist/stories/components/Form/Select/Options/OptionFormat.mdx +40 -0
- package/dist/stories/components/Form/Select/Roundness/Roundness.stories.svelte +28 -0
- package/dist/stories/components/Form/Select/Roundness/Roundness.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Select/Select.stories.svelte +114 -0
- package/dist/stories/components/Form/Select/Select.stories.svelte.d.ts +22 -0
- package/dist/stories/components/Form/Select/Select.svelte +285 -0
- package/dist/stories/components/Form/Select/Select.svelte.d.ts +87 -0
- package/dist/stories/components/Form/Select/Size/Size.stories.svelte +24 -0
- package/dist/stories/components/Form/Select/Size/Size.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Select/WithIcon/WithIcon.stories.svelte +39 -0
- package/dist/stories/components/Form/Select/WithIcon/WithIcon.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte +9 -28
- package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +8 -5
- package/dist/stories/components/Layout/Menu/Menu.stories.svelte +65 -0
- package/dist/stories/components/Layout/Menu/Menu.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Layout/Menu/Menu.svelte +30 -0
- package/dist/stories/components/Layout/Menu/Menu.svelte.d.ts +23 -0
- package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.stories.svelte +30 -0
- package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.svelte +164 -0
- package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.svelte.d.ts +49 -0
- package/dist/stories/components/Layout/Menu/MenuItem/Size/Size.stories.svelte +16 -0
- package/dist/stories/components/Layout/Menu/MenuItem/Type/Type.stories.svelte +21 -0
- package/dist/stories/components/{Form/SimpleSelect/WithIcon/WithIcon.stories.svelte.d.ts → Layout/Menu/MenuItem/Type/Type.stories.svelte.d.ts} +3 -3
- package/dist/stories/components/Layout/Menu/Size/Size.stories.svelte +37 -0
- package/dist/stories/components/{Form/SimpleSelect/Roundness/Roundness.stories.svelte.d.ts → Layout/Menu/Size/Size.stories.svelte.d.ts} +3 -3
- package/dist/stories/components/Layout/Paper/Color/Color.stories.svelte +1 -1
- package/dist/stories/components/Layout/Paper/Paper.stories.svelte +1 -1
- package/dist/stories/components/Layout/Paper/Paper.svelte.d.ts +5 -5
- package/dist/stories/components/Layout/Separator/Color/Color.stories.svelte +19 -0
- package/dist/stories/components/Layout/Separator/Color/Color.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Layout/Separator/Separator.stories.svelte +26 -0
- package/dist/stories/components/Layout/Separator/Separator.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Layout/Separator/Separator.svelte +66 -0
- package/dist/stories/components/Layout/Separator/Separator.svelte.d.ts +22 -0
- package/dist/stories/components/Layout/Separator/utils/scss/mixins.scss +24 -0
- package/dist/stories/developer tools/components/DynamicInput/DynamicInput.stories.svelte +49 -0
- package/dist/stories/{components/Form/SimpleSelect/SimpleSelect.stories.svelte.d.ts → developer tools/components/DynamicInput/DynamicInput.stories.svelte.d.ts } +5 -7
- package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte +92 -0
- package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte.d.ts +60 -0
- package/dist/stories/{components/Form/SimpleSelect/Size/Size.stories.svelte → developer tools/components/DynamicInput/Size/Size.stories.svelte } +5 -8
- package/dist/stories/developer tools/components/DynamicInput/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +6 -2
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte.d.ts +1 -1
- package/dist/stories/developer tools/components/Popper/Popper.stories.svelte +119 -0
- package/dist/stories/developer tools/components/Popper/Popper.stories.svelte.d.ts +21 -0
- package/dist/stories/developer tools/components/Popper/Popper.svelte +77 -0
- package/dist/stories/developer tools/components/Popper/Popper.svelte.d.ts +50 -0
- package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.stories.svelte +60 -0
- package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.stories.svelte.d.ts +21 -0
- package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte +66 -0
- package/dist/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte.d.ts +34 -0
- package/dist/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.d.ts +21 -0
- package/dist/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.js +62 -0
- package/dist/stories/developer tools/components/Popper/Positions/AutoPosition/AutoPosition.stories.svelte +89 -0
- package/dist/stories/developer tools/components/Popper/Positions/AutoPosition/AutoPosition.stories.svelte.d.ts +18 -0
- package/dist/stories/developer tools/components/Popper/Positions/Positions.stories.svelte +111 -0
- package/dist/stories/developer tools/components/Popper/Positions/Positions.stories.svelte.d.ts +18 -0
- package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +3 -5
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +0 -4
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte +5 -2
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte.d.ts +1 -1
- package/dist/stories/developer tools/directives/clickOutside/clickOutside.d.ts +3 -0
- package/dist/stories/developer tools/directives/clickOutside/clickOutside.js +14 -0
- package/dist/stories/developer tools/directives/clickOutside/index.mdx +25 -0
- package/dist/styles/_z-index.css +9 -0
- package/dist/styles/global.css +1 -0
- package/dist/types/position.d.ts +4 -0
- package/dist/types/position.js +2 -0
- package/package.json +3 -3
- package/src/lib/index.ts +50 -9
- package/src/lib/stories/components/Form/Button/Button.svelte +14 -10
- package/src/lib/stories/components/Form/FormControl/FormControl.svelte +7 -4
- package/src/lib/stories/components/Form/Label/Label.svelte +4 -2
- package/src/lib/stories/components/Form/Message/Message.svelte +4 -2
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +48 -49
- package/src/lib/stories/components/Form/Select/Select.svelte +501 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.svelte +32 -59
- package/src/lib/stories/components/Layout/Menu/Menu.svelte +65 -0
- package/src/lib/stories/components/Layout/Menu/MenuItem/MenuItem.svelte +268 -0
- package/src/lib/stories/components/Layout/Paper/Paper.svelte +8 -9
- package/src/lib/stories/components/Layout/Separator/Separator.svelte +96 -0
- package/src/lib/stories/components/Layout/Separator/utils/scss/mixins.scss +24 -0
- package/src/lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte +195 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +5 -2
- package/src/lib/stories/developer tools/components/Popper/Popper.svelte +159 -0
- package/src/lib/stories/developer tools/components/Popper/PopperPopup/PopperPopup.svelte +120 -0
- package/src/lib/stories/developer tools/components/Popper/PopperPopup/utils/getPopupPosition.ts +87 -0
- package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte +4 -2
- package/src/lib/stories/developer tools/directives/clickOutside/clickOutside.ts +17 -0
- package/src/lib/styles/_z-index.css +9 -0
- package/src/lib/styles/global.css +1 -0
- package/src/lib/types/position.ts +5 -0
- package/dist/stories/components/Form/SimpleSelect/Events/Events.stories.svelte +0 -47
- package/dist/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte +0 -24
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte +0 -57
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte +0 -69
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte.d.ts +0 -51
- package/dist/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte +0 -36
- package/src/lib/stories/components/Form/SimpleSelect/SimpleSelect.svelte +0 -160
- /package/dist/stories/components/Form/{SimpleSelect → Select}/Events/Events.stories.svelte.d.ts +0 -0
- /package/dist/stories/components/{Form/SimpleSelect → Layout/Menu/MenuItem}/Size/Size.stories.svelte.d.ts +0 -0
|
@@ -9,18 +9,21 @@
|
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<script lang="ts">import InputEnclosure from '../../../developer tools/components/InputEnclosure/InputEnclosure.svelte';
|
|
12
|
+
import DynamicInput, {} from '../../../developer tools/components/DynamicInput/DynamicInput.svelte';
|
|
12
13
|
let { type = 'text', size = 'normal', roundness = 1, 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();
|
|
13
14
|
let focused = $state(false);
|
|
14
15
|
function onfocusMod(e) {
|
|
16
|
+
const eTyped = e;
|
|
15
17
|
focused = true;
|
|
16
18
|
if (onfocus) {
|
|
17
|
-
onfocus(
|
|
19
|
+
onfocus(eTyped);
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
function onblurMod(e) {
|
|
23
|
+
const eTyped = e;
|
|
21
24
|
focused = false;
|
|
22
25
|
if (onblur) {
|
|
23
|
-
onblur(
|
|
26
|
+
onblur(eTyped);
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
</script>
|
|
@@ -33,11 +36,12 @@ function onblurMod(e) {
|
|
|
33
36
|
class={['dodo-ui-TextInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
34
37
|
>
|
|
35
38
|
<InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
|
|
36
|
-
<
|
|
39
|
+
<DynamicInput
|
|
37
40
|
{type}
|
|
38
41
|
{name}
|
|
39
42
|
{id}
|
|
40
43
|
{disabled}
|
|
44
|
+
bind:ref
|
|
41
45
|
{oninput}
|
|
42
46
|
{onchange}
|
|
43
47
|
onfocus={onfocusMod}
|
|
@@ -46,32 +50,9 @@ function onblurMod(e) {
|
|
|
46
50
|
{oncopy}
|
|
47
51
|
{oncut}
|
|
48
52
|
{placeholder}
|
|
49
|
-
{readonly}
|
|
50
53
|
bind:value
|
|
51
|
-
|
|
54
|
+
{readonly}
|
|
55
|
+
variant="input"
|
|
52
56
|
/>
|
|
53
57
|
</InputEnclosure>
|
|
54
58
|
</div>
|
|
55
|
-
|
|
56
|
-
<style>.dodo-ui-TextInput input {
|
|
57
|
-
flex: 1;
|
|
58
|
-
border: 0;
|
|
59
|
-
outline: 0;
|
|
60
|
-
height: 100%;
|
|
61
|
-
background-color: transparent;
|
|
62
|
-
font-family: inherit;
|
|
63
|
-
color: inherit;
|
|
64
|
-
letter-spacing: 0.3px;
|
|
65
|
-
}
|
|
66
|
-
.dodo-ui-TextInput.size--normal input {
|
|
67
|
-
font-size: 1rem;
|
|
68
|
-
padding: 0 calc(var(--dodo-ui-space-small) * 2);
|
|
69
|
-
}
|
|
70
|
-
.dodo-ui-TextInput.size--small input {
|
|
71
|
-
padding: 0 var(--dodo-ui-space);
|
|
72
|
-
font-size: 0.9rem;
|
|
73
|
-
}
|
|
74
|
-
.dodo-ui-TextInput.size--large input {
|
|
75
|
-
font-size: 1.1rem;
|
|
76
|
-
padding: 0 calc(var(--dodo-ui-space) * 2);
|
|
77
|
-
}</style>
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { ComponentRoundness } from '../../../../types/roundness.js';
|
|
2
|
+
import type { ComponentSize } from '../../../../types/size.js';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { ChangeEventHandler, ClipboardEventHandler, FocusEventHandler, FormEventHandler } from 'svelte/elements';
|
|
1
5
|
export type TextInputType = 'text' | 'tel' | 'email' | 'password' | 'url' | 'number';
|
|
2
6
|
export declare const textInputTypeArray: TextInputType[];
|
|
3
7
|
export type TextInputFocusEvent = FocusEvent & {
|
|
@@ -6,11 +10,10 @@ export type TextInputFocusEvent = FocusEvent & {
|
|
|
6
10
|
export type TextInputClipboardEvent = ClipboardEvent & {
|
|
7
11
|
currentTarget: EventTarget & HTMLInputElement;
|
|
8
12
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
interface TextInputProps {
|
|
13
|
+
export type TextInputInputEvent = Event & {
|
|
14
|
+
currentTarget: EventTarget & HTMLInputElement;
|
|
15
|
+
};
|
|
16
|
+
export interface TextInputProps {
|
|
14
17
|
/** Input type? */
|
|
15
18
|
type?: TextInputType;
|
|
16
19
|
/** Input ref */
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import Menu from './Menu.svelte';
|
|
3
|
+
import MenuItem from './MenuItem/MenuItem.svelte';
|
|
4
|
+
import { Separator } from '../../../../index.js';
|
|
5
|
+
export const storyMenuArgTypes = {};
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: Menu,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyMenuArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<!-- Default Menu -->
|
|
15
|
+
<Story name="Default" asChild>
|
|
16
|
+
<Menu>
|
|
17
|
+
<MenuItem>Cut</MenuItem>
|
|
18
|
+
<MenuItem>Copy</MenuItem>
|
|
19
|
+
<MenuItem>Paste</MenuItem>
|
|
20
|
+
</Menu>
|
|
21
|
+
</Story>
|
|
22
|
+
|
|
23
|
+
<!-- Fixed width and height -->
|
|
24
|
+
<Story name="FixedSize" asChild>
|
|
25
|
+
<Menu width="200px" height="300px">
|
|
26
|
+
<MenuItem>Cut</MenuItem>
|
|
27
|
+
<MenuItem>Copy</MenuItem>
|
|
28
|
+
<MenuItem>Paste</MenuItem>
|
|
29
|
+
</Menu>
|
|
30
|
+
</Story>
|
|
31
|
+
|
|
32
|
+
<!-- MenuItems With Separator -->
|
|
33
|
+
<Story name="WithSeparator" asChild>
|
|
34
|
+
<Menu separator>
|
|
35
|
+
<MenuItem>Cut</MenuItem>
|
|
36
|
+
<MenuItem>Copy</MenuItem>
|
|
37
|
+
<MenuItem>Paste</MenuItem>
|
|
38
|
+
</Menu>
|
|
39
|
+
</Story>
|
|
40
|
+
|
|
41
|
+
<!-- MenuItems Grouped in Sections. [Separator](?path=/docs/components-layout-separator--docs) -->
|
|
42
|
+
<Story name="Sections" asChild>
|
|
43
|
+
<Menu width="200px">
|
|
44
|
+
<MenuItem>Cut</MenuItem>
|
|
45
|
+
<MenuItem>Cut Special</MenuItem>
|
|
46
|
+
<MenuItem>Cut Selected</MenuItem>
|
|
47
|
+
<Separator />
|
|
48
|
+
<MenuItem>Copy</MenuItem>
|
|
49
|
+
<MenuItem>Copy Special</MenuItem>
|
|
50
|
+
<MenuItem>Copy Selected</MenuItem>
|
|
51
|
+
<Separator />
|
|
52
|
+
<MenuItem>Paste</MenuItem>
|
|
53
|
+
<MenuItem>Paste Special</MenuItem>
|
|
54
|
+
<MenuItem>Paste Selected</MenuItem>
|
|
55
|
+
</Menu>
|
|
56
|
+
</Story>
|
|
57
|
+
|
|
58
|
+
<!-- MenuItems With some options disabled -->
|
|
59
|
+
<Story name="Disabled" asChild>
|
|
60
|
+
<Menu>
|
|
61
|
+
<MenuItem>Cut</MenuItem>
|
|
62
|
+
<MenuItem disabled>Copy</MenuItem>
|
|
63
|
+
<MenuItem>Paste</MenuItem>
|
|
64
|
+
</Menu>
|
|
65
|
+
</Story>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Menu from './Menu.svelte';
|
|
2
|
+
import type { StoryBookArgTypes } from '../../../../storybook-types.js';
|
|
3
|
+
export declare const storyMenuArgTypes: 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 Menu: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type Menu = InstanceType<typeof Menu>;
|
|
21
|
+
export default Menu;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts" module>import {} from 'svelte';
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<script lang="ts">import { setContext } from 'svelte';
|
|
5
|
+
let { children, id, class: className = '', width, height, ref = $bindable(), size, separator, } = $props();
|
|
6
|
+
setContext('MenuItemSize', () => size);
|
|
7
|
+
setContext('MenuItemSeparator', () => separator);
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<ul
|
|
11
|
+
class={['dodo-ui-Menu', className].join(' ')}
|
|
12
|
+
{id}
|
|
13
|
+
bind:this={ref}
|
|
14
|
+
style={`${width ? `width:${width};` : ''}
|
|
15
|
+
${height ? `height:${height};` : ''}
|
|
16
|
+
`}
|
|
17
|
+
>
|
|
18
|
+
{#if children}
|
|
19
|
+
{@render children()}
|
|
20
|
+
{/if}
|
|
21
|
+
</ul>
|
|
22
|
+
|
|
23
|
+
<style>.dodo-ui-Menu {
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: 0;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
overflow: inherit;
|
|
29
|
+
outline: 0;
|
|
30
|
+
}</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { ComponentSize } from '../../../../types/size.js';
|
|
3
|
+
export interface MenuProps {
|
|
4
|
+
/** Menu contents goes here */
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
/** Menu ref */
|
|
7
|
+
ref?: HTMLUListElement;
|
|
8
|
+
/** Custom css class */
|
|
9
|
+
class?: string;
|
|
10
|
+
/** Menu Width */
|
|
11
|
+
width?: string;
|
|
12
|
+
/** Menu Height */
|
|
13
|
+
height?: string;
|
|
14
|
+
/** How large should the Menu Items be? */
|
|
15
|
+
size?: ComponentSize;
|
|
16
|
+
/** Menu Separator */
|
|
17
|
+
separator?: boolean;
|
|
18
|
+
/** Id */
|
|
19
|
+
id?: string;
|
|
20
|
+
}
|
|
21
|
+
declare const Menu: import("svelte").Component<MenuProps, {}, "ref">;
|
|
22
|
+
type Menu = ReturnType<typeof Menu>;
|
|
23
|
+
export default Menu;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
2
|
+
import MenuItem, { menuItemTypeArray } from './MenuItem.svelte';
|
|
3
|
+
import { componentSizeArray } from '../../../../../types/size.js';
|
|
4
|
+
export const storyMenuItemArgTypes = {
|
|
5
|
+
type: {
|
|
6
|
+
control: { type: 'select' },
|
|
7
|
+
options: menuItemTypeArray,
|
|
8
|
+
},
|
|
9
|
+
size: {
|
|
10
|
+
control: { type: 'select' },
|
|
11
|
+
options: componentSizeArray,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
15
|
+
const { Story } = defineMeta({
|
|
16
|
+
component: MenuItem,
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
argTypes: storyMenuItemArgTypes,
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<!-- Default MenuItem -->
|
|
23
|
+
<Story name="Default">Menu Item</Story>
|
|
24
|
+
|
|
25
|
+
<!-- With Separator -->
|
|
26
|
+
<Story name="WithSeparator" args={{ separator: true }}>Menu Item</Story>
|
|
27
|
+
|
|
28
|
+
<Story name="Disabled" args={{ disabled: true }}>Menu Item</Story>
|
|
29
|
+
|
|
30
|
+
<Story name="Selected" args={{ selected: true }}>Menu Item</Story>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StoryBookArgTypes } from '../../../../../storybook-types.js';
|
|
2
|
+
import MenuItem from './MenuItem.svelte';
|
|
3
|
+
export declare const storyMenuItemArgTypes: 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 MenuItem: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type MenuItem = InstanceType<typeof MenuItem>;
|
|
21
|
+
export default MenuItem;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<script lang="ts" module>import {} from 'svelte';
|
|
2
|
+
export const menuItemTypeArray = ['text', 'button', 'link'];
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">import { getContext } from 'svelte';
|
|
6
|
+
let { children, id, class: className = '', type = 'text', href, download, hreflang, media, ping, rel, target, anchorMediaType, referrerpolicy, disabled = false, selected = false, separator: separatorInternal, onclick, size: sizeInternal, ref = $bindable(), } = $props();
|
|
7
|
+
const hover = false;
|
|
8
|
+
const sizeMenu = // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
(getContext('MenuItemSize') ? getContext('MenuItemSize')() : undefined);
|
|
10
|
+
const size = sizeMenu || sizeInternal || 'normal';
|
|
11
|
+
const separatorMenu = // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
(getContext('MenuItemSeparator') ? getContext('MenuItemSeparator')() : undefined);
|
|
13
|
+
const separator = separatorMenu !== undefined ? separatorMenu : separatorInternal || false;
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#snippet menuItemContent()}
|
|
17
|
+
{#if children}
|
|
18
|
+
{@render children()}
|
|
19
|
+
{/if}
|
|
20
|
+
{/snippet}
|
|
21
|
+
|
|
22
|
+
<li
|
|
23
|
+
class:disabled
|
|
24
|
+
class:separator
|
|
25
|
+
class:selected
|
|
26
|
+
class:hover
|
|
27
|
+
class={['dodo-ui-MenuItem', `size--${size}`, className].join(' ')}
|
|
28
|
+
{id}
|
|
29
|
+
bind:this={ref}
|
|
30
|
+
>
|
|
31
|
+
{#if type === 'link'}
|
|
32
|
+
<a
|
|
33
|
+
class:disabled
|
|
34
|
+
class:selected
|
|
35
|
+
class={['MenuItem-type', `MenuItem-type--${type}`, `size--${size}`].join(' ')}
|
|
36
|
+
{href}
|
|
37
|
+
{download}
|
|
38
|
+
{hreflang}
|
|
39
|
+
{media}
|
|
40
|
+
{ping}
|
|
41
|
+
{rel}
|
|
42
|
+
{target}
|
|
43
|
+
type={anchorMediaType}
|
|
44
|
+
{referrerpolicy}
|
|
45
|
+
>
|
|
46
|
+
{@render menuItemContent()}
|
|
47
|
+
</a>
|
|
48
|
+
{:else if type === 'button'}
|
|
49
|
+
<button
|
|
50
|
+
class:disabled
|
|
51
|
+
class:selected
|
|
52
|
+
class={['MenuItem-type', `MenuItem-type--${type}`, `size--${size}`].join(' ')}
|
|
53
|
+
{onclick}
|
|
54
|
+
{disabled}
|
|
55
|
+
>
|
|
56
|
+
{@render menuItemContent()}
|
|
57
|
+
</button>
|
|
58
|
+
{:else}
|
|
59
|
+
<div
|
|
60
|
+
class:disabled
|
|
61
|
+
class:selected
|
|
62
|
+
class={['MenuItem-type', `MenuItem-type--${type}`, `size--${size}`].join(' ')}
|
|
63
|
+
>
|
|
64
|
+
{@render menuItemContent()}
|
|
65
|
+
</div>
|
|
66
|
+
{/if}
|
|
67
|
+
</li>
|
|
68
|
+
|
|
69
|
+
<style>:global(:root) {
|
|
70
|
+
--dodo-ui-MenuItem-selected-bg: color-mix(
|
|
71
|
+
in oklab,
|
|
72
|
+
var(--dodo-color-neutral-800) 4%,
|
|
73
|
+
transparent
|
|
74
|
+
);
|
|
75
|
+
--dodo-ui-MenuItem-hover-bg: color-mix(in oklab, var(--dodo-color-neutral-800) 8%, transparent);
|
|
76
|
+
--dodo-ui-MenuItem-active-bg: color-mix(
|
|
77
|
+
in oklab,
|
|
78
|
+
var(--dodo-color-neutral-800) 11%,
|
|
79
|
+
transparent
|
|
80
|
+
);
|
|
81
|
+
--dodo-ui-MenuItem-separator-color: var(--dodo-color-neutral-300);
|
|
82
|
+
--dodo-ui-MenuItem-disabled-color: var(--dodo-color-neutral-400);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:global(.dodo-theme--dark) {
|
|
86
|
+
--dodo-ui-MenuItem-selected-bg: color-mix(
|
|
87
|
+
in oklab,
|
|
88
|
+
var(--dodo-color-neutral-800) 4%,
|
|
89
|
+
transparent
|
|
90
|
+
);
|
|
91
|
+
--dodo-ui-MenuItem-hover-bg: color-mix(in oklab, var(--dodo-color-neutral-800) 8%, transparent);
|
|
92
|
+
--dodo-ui-MenuItem-active-bg: color-mix(
|
|
93
|
+
in oklab,
|
|
94
|
+
var(--dodo-color-neutral-800) 15%,
|
|
95
|
+
transparent
|
|
96
|
+
);
|
|
97
|
+
--dodo-ui-MenuItem-separator-color: var(--dodo-color-neutral-300);
|
|
98
|
+
--dodo-ui-MenuItem-disabled-color: var(--dodo-color-neutral-500);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.dodo-ui-MenuItem {
|
|
102
|
+
display: flex;
|
|
103
|
+
margin: 0;
|
|
104
|
+
padding: 0;
|
|
105
|
+
user-select: none;
|
|
106
|
+
}
|
|
107
|
+
.dodo-ui-MenuItem.separator {
|
|
108
|
+
border-bottom: 1px solid var(--dodo-ui-MenuItem-separator-color);
|
|
109
|
+
}
|
|
110
|
+
.dodo-ui-MenuItem .MenuItem-type {
|
|
111
|
+
cursor: pointer;
|
|
112
|
+
transition: all 70ms;
|
|
113
|
+
text-decoration: none;
|
|
114
|
+
margin: 0;
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-wrap: wrap;
|
|
117
|
+
align-items: center;
|
|
118
|
+
border: 0;
|
|
119
|
+
outline: 0;
|
|
120
|
+
background-color: transparent;
|
|
121
|
+
color: inherit;
|
|
122
|
+
font-family: inherit;
|
|
123
|
+
width: 100%;
|
|
124
|
+
}
|
|
125
|
+
.dodo-ui-MenuItem .MenuItem-type.selected {
|
|
126
|
+
background-color: var(--dodo-ui-MenuItem-selected-bg);
|
|
127
|
+
}
|
|
128
|
+
.dodo-ui-MenuItem .MenuItem-type:hover {
|
|
129
|
+
background-color: var(--dodo-ui-MenuItem-hover-bg);
|
|
130
|
+
}
|
|
131
|
+
.dodo-ui-MenuItem .MenuItem-type:active {
|
|
132
|
+
background-color: var(--dodo-ui-MenuItem-active-bg);
|
|
133
|
+
}
|
|
134
|
+
.dodo-ui-MenuItem .MenuItem-type.size--normal {
|
|
135
|
+
min-height: var(--dodo-ui-element-height-normal);
|
|
136
|
+
font-size: 1rem;
|
|
137
|
+
padding: 0 calc(var(--dodo-ui-space-small) * 2);
|
|
138
|
+
}
|
|
139
|
+
.dodo-ui-MenuItem .MenuItem-type.size--small {
|
|
140
|
+
min-height: var(--dodo-ui-element-height-small);
|
|
141
|
+
padding: 0 var(--dodo-ui-space);
|
|
142
|
+
font-size: 0.9rem;
|
|
143
|
+
}
|
|
144
|
+
.dodo-ui-MenuItem .MenuItem-type.size--large {
|
|
145
|
+
min-height: var(--dodo-ui-element-height-large);
|
|
146
|
+
font-size: 1.1rem;
|
|
147
|
+
padding: 0 calc(var(--dodo-ui-space) * 2);
|
|
148
|
+
}
|
|
149
|
+
.dodo-ui-MenuItem .MenuItem-type.disabled {
|
|
150
|
+
cursor: initial;
|
|
151
|
+
background-color: transparent;
|
|
152
|
+
color: var(--dodo-ui-MenuItem-disabled-color);
|
|
153
|
+
}
|
|
154
|
+
.dodo-ui-MenuItem .MenuItem-type.disabled:hover {
|
|
155
|
+
background-color: transparent;
|
|
156
|
+
color: var(--dodo-ui-MenuItem-disabled-color);
|
|
157
|
+
}
|
|
158
|
+
.dodo-ui-MenuItem .MenuItem-type.disabled:active {
|
|
159
|
+
background-color: transparent;
|
|
160
|
+
color: var(--dodo-ui-MenuItem-disabled-color);
|
|
161
|
+
}
|
|
162
|
+
.dodo-ui-MenuItem.hover .MenuItem-type {
|
|
163
|
+
background-color: var(--dodo-ui-MenuItem-hover-bg);
|
|
164
|
+
}</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ButtonLinkReferrerpolicy, ButtonLinkTarget } from '../../../Form/Button/Button.svelte';
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
3
|
+
import type { MouseEventHandler } from 'svelte/elements';
|
|
4
|
+
export type MenuItemType = 'text' | 'button' | 'link';
|
|
5
|
+
export declare const menuItemTypeArray: MenuItemType[];
|
|
6
|
+
export interface MenuItemProps {
|
|
7
|
+
/** MenuItem contents goes here */
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
/** MenuItem ref */
|
|
10
|
+
ref?: HTMLLIElement;
|
|
11
|
+
/** Custom css class */
|
|
12
|
+
class?: string;
|
|
13
|
+
/** Id */
|
|
14
|
+
id?: string;
|
|
15
|
+
/** Menu Item type */
|
|
16
|
+
type?: MenuItemType;
|
|
17
|
+
/** Menu Item type */
|
|
18
|
+
selected?: boolean;
|
|
19
|
+
/** Separator */
|
|
20
|
+
separator?: boolean;
|
|
21
|
+
/** How large should the Menu Items be? */
|
|
22
|
+
size?: ComponentSize;
|
|
23
|
+
/** The onclick event handler */
|
|
24
|
+
onclick?: MouseEventHandler<HTMLButtonElement>;
|
|
25
|
+
/** disabled state */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** link href */
|
|
28
|
+
href?: string;
|
|
29
|
+
/** Link button: download */
|
|
30
|
+
download?: any;
|
|
31
|
+
/** Link button: hreflang */
|
|
32
|
+
hreflang?: string | undefined | null;
|
|
33
|
+
/** Link button: media */
|
|
34
|
+
media?: string | undefined | null;
|
|
35
|
+
/** Link button: ping */
|
|
36
|
+
ping?: string | undefined | null;
|
|
37
|
+
/** Link button: rel */
|
|
38
|
+
rel?: string | undefined | null;
|
|
39
|
+
/** Link button: target */
|
|
40
|
+
target?: ButtonLinkTarget;
|
|
41
|
+
/** Link button: Type */
|
|
42
|
+
anchorMediaType?: string | undefined | null;
|
|
43
|
+
/** Link button: referrerpolicy */
|
|
44
|
+
referrerpolicy?: ButtonLinkReferrerpolicy;
|
|
45
|
+
}
|
|
46
|
+
import type { ComponentSize } from '../../../../../types/size.js';
|
|
47
|
+
declare const MenuItem: import("svelte").Component<MenuItemProps, {}, "ref">;
|
|
48
|
+
type MenuItem = ReturnType<typeof MenuItem>;
|
|
49
|
+
export default MenuItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import MenuItem from '../MenuItem.svelte';
|
|
4
|
+
import { storyMenuItemArgTypes } from '../MenuItem.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: MenuItem,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyMenuItemArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Normal">Menu Item</Story>
|
|
15
|
+
<Story name="Small" args={{ size: 'small' }}>Menu Item</Story>
|
|
16
|
+
<Story name="Large" args={{ size: 'large' }}>Menu Item</Story>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import MenuItem from '../MenuItem.svelte';
|
|
4
|
+
import { storyMenuItemArgTypes } from '../MenuItem.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: MenuItem,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyMenuItemArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Text">Menu Item</Story>
|
|
15
|
+
<Story
|
|
16
|
+
name="Link"
|
|
17
|
+
args={{ type: 'link', href: 'https://www.w3schools.com/tags/tag_a.asp', target: '_blank' }}
|
|
18
|
+
>
|
|
19
|
+
Menu Item
|
|
20
|
+
</Story>
|
|
21
|
+
<Story name="Button" args={{ type: 'button', onclick: () => {} }}>Menu Item</Story>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export default
|
|
2
|
-
type
|
|
1
|
+
export default Type;
|
|
2
|
+
type Type = SvelteComponent<{
|
|
3
3
|
[x: string]: never;
|
|
4
4
|
}, {
|
|
5
5
|
[evt: string]: CustomEvent<any>;
|
|
6
6
|
}, {}> & {
|
|
7
7
|
$$bindings?: string | undefined;
|
|
8
8
|
};
|
|
9
|
-
declare const
|
|
9
|
+
declare const Type: $$__sveltets_2_IsomorphicComponent<{
|
|
10
10
|
[x: string]: never;
|
|
11
11
|
}, {
|
|
12
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Menu from '../Menu.svelte';
|
|
4
|
+
import { storyMenuArgTypes } from '../Menu.stories.svelte';
|
|
5
|
+
import MenuItem from '../MenuItem/MenuItem.svelte';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
component: Menu,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: storyMenuArgTypes,
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Story name="Normal" asChild>
|
|
16
|
+
<Menu>
|
|
17
|
+
<MenuItem>Cut</MenuItem>
|
|
18
|
+
<MenuItem>Copy</MenuItem>
|
|
19
|
+
<MenuItem>Paste</MenuItem>
|
|
20
|
+
</Menu>
|
|
21
|
+
</Story>
|
|
22
|
+
|
|
23
|
+
<Story name="Small" asChild>
|
|
24
|
+
<Menu size="small">
|
|
25
|
+
<MenuItem>Cut</MenuItem>
|
|
26
|
+
<MenuItem>Copy</MenuItem>
|
|
27
|
+
<MenuItem>Paste</MenuItem>
|
|
28
|
+
</Menu>
|
|
29
|
+
</Story>
|
|
30
|
+
|
|
31
|
+
<Story name="Large" asChild>
|
|
32
|
+
<Menu size="large">
|
|
33
|
+
<MenuItem>Cut</MenuItem>
|
|
34
|
+
<MenuItem>Copy</MenuItem>
|
|
35
|
+
<MenuItem>Paste</MenuItem>
|
|
36
|
+
</Menu>
|
|
37
|
+
</Story>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export default
|
|
2
|
-
type
|
|
1
|
+
export default Size;
|
|
2
|
+
type Size = SvelteComponent<{
|
|
3
3
|
[x: string]: never;
|
|
4
4
|
}, {
|
|
5
5
|
[evt: string]: CustomEvent<any>;
|
|
6
6
|
}, {}> & {
|
|
7
7
|
$$bindings?: string | undefined;
|
|
8
8
|
};
|
|
9
|
-
declare const
|
|
9
|
+
declare const Size: $$__sveltets_2_IsomorphicComponent<{
|
|
10
10
|
[x: string]: never;
|
|
11
11
|
}, {
|
|
12
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
Hola!
|
|
55
55
|
</Story>
|
|
56
56
|
|
|
57
|
-
<!-- Paper with Custom
|
|
57
|
+
<!-- Paper with Custom Background and Border colors -->
|
|
58
58
|
<Story
|
|
59
59
|
name="Custom Color"
|
|
60
60
|
args={{ height: '100px', customBackgroundColor: '#ffdfad', customBorderColor: '#fbc674' }}
|
|
@@ -37,7 +37,7 @@ const { Story } = defineMeta({
|
|
|
37
37
|
Hola!
|
|
38
38
|
</Story>
|
|
39
39
|
|
|
40
|
-
<!-- Paper with Custom
|
|
40
|
+
<!-- Paper with Custom Background and Border colors -->
|
|
41
41
|
<Story
|
|
42
42
|
name="Custom Color"
|
|
43
43
|
args={{ height: '100px', customBackgroundColor: '#ffdfad', customBorderColor: '#fbc674' }}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { type ComponentColor } from '../../../../types/colors.js';
|
|
2
|
-
export type PaperColor = 'default' | ComponentColor;
|
|
3
|
-
export declare const paperColorArray: PaperColor[];
|
|
4
1
|
import type { ComponentRoundness } from '../../../../types/roundness.js';
|
|
5
2
|
import type { ComponentShadow } from '../../../../types/shadow.js';
|
|
6
3
|
import type { ComponentWeight } from '../../../../types/weight.js';
|
|
7
|
-
import type
|
|
8
|
-
|
|
4
|
+
import { type ComponentColor } from '../../../../types/colors.js';
|
|
5
|
+
export type PaperColor = 'default' | ComponentColor;
|
|
6
|
+
export declare const paperColorArray: PaperColor[];
|
|
7
|
+
export interface PaperProps {
|
|
9
8
|
/** Paper contents goes here */
|
|
10
9
|
children?: Snippet;
|
|
11
10
|
/** Paper ref */
|
|
@@ -33,6 +32,7 @@ interface PaperProps {
|
|
|
33
32
|
/** Custom border color. Use CSS compatible value */
|
|
34
33
|
customBorderColor?: string;
|
|
35
34
|
}
|
|
35
|
+
import type { Snippet } from 'svelte';
|
|
36
36
|
declare const Paper: import("svelte").Component<PaperProps, {}, "ref">;
|
|
37
37
|
type Paper = ReturnType<typeof Paper>;
|
|
38
38
|
export default Paper;
|