@flightlesslabs/dodo-ui 0.7.2 → 0.9.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 +18 -2
- package/dist/index.js +11 -0
- package/dist/stories/components/Form/NumericInput/Events/Events.stories.svelte +126 -0
- package/dist/stories/components/Form/NumericInput/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/NumericInput/NumericInput.stories.svelte +79 -0
- package/dist/stories/components/Form/NumericInput/NumericInput.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Form/NumericInput/NumericInput.svelte +161 -0
- package/dist/stories/components/Form/NumericInput/NumericInput.svelte.d.ts +69 -0
- package/dist/stories/components/Form/NumericInput/Validation/Validation.stories.svelte +84 -0
- package/dist/stories/components/Form/NumericInput/Validation/Validation.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte +27 -6
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +5 -3
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +7 -1
- package/dist/stories/components/Form/Select/Customize/Customize.stories.svelte +16 -1
- package/dist/stories/components/Form/Select/DropDownArrow/DropDownArrow.stories.svelte +59 -0
- package/dist/stories/components/Form/Select/DropDownArrow/DropDownArrow.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Select/Events/Events.stories.svelte +27 -0
- package/dist/stories/components/Form/Select/Positions/AutoPosition/AutoPosition.stories.svelte +54 -0
- package/dist/stories/components/Form/Select/Positions/AutoPosition/AutoPosition.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Select/Positions/Positions.stories.svelte +83 -0
- package/dist/stories/components/Form/Select/Positions/Positions.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Select/Select.svelte +110 -123
- package/dist/stories/components/Form/Select/Select.svelte.d.ts +22 -3
- package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte +27 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte +5 -3
- package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +10 -1
- package/dist/stories/components/Layout/Menu/DynamicMenu/Customize/Customize.stories.svelte +28 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/Customize/Customize.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.stories.svelte +51 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.stories.svelte.d.ts +22 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte +129 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte.d.ts +81 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/Events/Events.stories.svelte +46 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/KeybaordNavigation/KeybaordNavigation.stories.svelte +27 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/KeybaordNavigation/KeybaordNavigation.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Layout/Menu/DynamicMenu/Options/OptionFormat.mdx +72 -0
- package/dist/stories/components/Layout/Menu/MenuItem/MenuItem.svelte.d.ts +1 -1
- package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte +23 -4
- package/dist/stories/developer tools/components/DynamicInput/DynamicInput.svelte.d.ts +13 -2
- package/dist/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte +115 -0
- package/dist/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.d.ts +13 -0
- package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.js +26 -0
- package/dist/stories/developer tools/helpers/Numbers/cleanNumericString/index.mdx +20 -0
- package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/index.mdx +71 -0
- package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.d.ts +51 -0
- package/dist/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.js +96 -0
- package/dist/stories/developer tools/helpers/logger/index.mdx +63 -0
- package/dist/stories/developer tools/helpers/logger/logger.d.ts +24 -0
- package/dist/stories/developer tools/helpers/logger/logger.js +31 -0
- package/package.json +15 -17
- package/src/lib/index.ts +33 -0
- package/src/lib/stories/Home.mdx +59 -0
- package/src/lib/stories/assets/dark-theme-toggle.png +0 -0
- package/src/lib/stories/components/Form/Button/Button.stories.svelte +61 -0
- package/src/lib/stories/components/Form/Button/Color/Color.stories.svelte +43 -0
- package/src/lib/stories/components/Form/Button/Events/Events.stories.svelte +36 -0
- package/src/lib/stories/components/Form/Button/IconButton/IconButton.stories.svelte +43 -0
- package/src/lib/stories/components/Form/Button/Roundness/Roundness.stories.svelte +23 -0
- package/src/lib/stories/components/Form/Button/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/components/Form/Button/Variant/Variant.stories.svelte +18 -0
- package/src/lib/stories/components/Form/FormControl/FormControl.stories.svelte +28 -0
- package/src/lib/stories/components/Form/Label/Label.stories.svelte +13 -0
- package/src/lib/stories/components/Form/Message/Color/Color.stories.svelte +36 -0
- package/src/lib/stories/components/Form/Message/Message.stories.svelte +27 -0
- package/src/lib/stories/components/Form/Message/Size/Size.stories.svelte +22 -0
- package/src/lib/stories/components/Form/NumericInput/Events/Events.stories.svelte +134 -0
- package/src/lib/stories/components/Form/NumericInput/NumericInput.stories.svelte +84 -0
- package/src/lib/stories/components/Form/NumericInput/NumericInput.svelte +286 -0
- package/src/lib/stories/components/Form/NumericInput/Validation/Validation.stories.svelte +87 -0
- package/src/lib/stories/components/Form/PasswordInput/Events/Events.stories.svelte +132 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +59 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +15 -3
- package/src/lib/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
- package/src/lib/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
- package/src/lib/stories/components/Form/Select/Customize/Customize.stories.svelte +139 -0
- package/src/lib/stories/components/Form/Select/DropDownArrow/DropDownArrow.stories.svelte +63 -0
- package/src/lib/stories/components/Form/Select/Events/Events.stories.svelte +174 -0
- package/src/lib/stories/components/Form/Select/Options/OptionFormat.mdx +40 -0
- package/src/lib/stories/components/Form/Select/Positions/AutoPosition/AutoPosition.stories.svelte +58 -0
- package/src/lib/stories/components/Form/Select/Positions/Positions.stories.svelte +87 -0
- package/src/lib/stories/components/Form/Select/Roundness/Roundness.stories.svelte +32 -0
- package/src/lib/stories/components/Form/Select/Select.stories.svelte +121 -0
- package/src/lib/stories/components/Form/Select/Select.svelte +166 -146
- package/src/lib/stories/components/Form/Select/Size/Size.stories.svelte +28 -0
- package/src/lib/stories/components/Form/Select/WithIcon/WithIcon.stories.svelte +43 -0
- package/src/lib/stories/components/Form/TextInput/Events/Events.stories.svelte +125 -0
- package/src/lib/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
- package/src/lib/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +43 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.svelte +18 -3
- package/src/lib/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
- package/src/lib/stories/components/Layout/Menu/DynamicMenu/Customize/Customize.stories.svelte +30 -0
- package/src/lib/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.stories.svelte +56 -0
- package/src/lib/stories/components/Layout/Menu/DynamicMenu/DynamicMenu.svelte +262 -0
- package/src/lib/stories/components/Layout/Menu/DynamicMenu/Events/Events.stories.svelte +48 -0
- package/src/lib/stories/components/Layout/Menu/DynamicMenu/KeybaordNavigation/KeybaordNavigation.stories.svelte +29 -0
- package/src/lib/stories/components/Layout/Menu/DynamicMenu/Options/OptionFormat.mdx +72 -0
- package/src/lib/stories/components/Layout/Menu/Menu.stories.svelte +69 -0
- package/src/lib/stories/components/Layout/Menu/MenuItem/MenuItem.stories.svelte +34 -0
- package/src/lib/stories/components/Layout/Menu/MenuItem/MenuItem.svelte +1 -1
- package/src/lib/stories/components/Layout/Menu/MenuItem/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/components/Layout/Menu/MenuItem/Type/Type.stories.svelte +21 -0
- package/src/lib/stories/components/Layout/Menu/Size/Size.stories.svelte +37 -0
- package/src/lib/stories/components/Layout/Paper/Color/Color.stories.svelte +63 -0
- package/src/lib/stories/components/Layout/Paper/Paper.stories.svelte +50 -0
- package/src/lib/stories/components/Layout/Paper/Roundness/Roundness.stories.svelte +25 -0
- package/src/lib/stories/components/Layout/Paper/Shadow/Shadow.stories.svelte +24 -0
- package/src/lib/stories/components/Layout/Separator/Color/Color.stories.svelte +19 -0
- package/src/lib/stories/components/Layout/Separator/Separator.stories.svelte +30 -0
- package/src/lib/stories/developer tools/Intro.mdx +9 -0
- package/src/lib/stories/developer tools/components/DynamicInput/DynamicInput.stories.svelte +53 -0
- package/src/lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte +43 -3
- package/src/lib/stories/developer tools/components/DynamicInput/Events/Events.stories.svelte +121 -0
- package/src/lib/stories/developer tools/components/DynamicInput/Size/Size.stories.svelte +17 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte +38 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte +20 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte +47 -0
- package/src/lib/stories/developer tools/components/Popper/Popper.stories.svelte +124 -0
- package/src/lib/stories/developer tools/components/Popper/PopperPopup/PopperPopup.stories.svelte +64 -0
- package/src/lib/stories/developer tools/components/Popper/Positions/AutoPosition/AutoPosition.stories.svelte +92 -0
- package/src/lib/stories/developer tools/components/Popper/Positions/Positions.stories.svelte +114 -0
- package/src/lib/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +25 -0
- package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +30 -0
- package/src/lib/stories/developer tools/directives/clickOutside/index.mdx +25 -0
- package/src/lib/stories/developer tools/helpers/Numbers/cleanNumericString/cleanNumericString.ts +27 -0
- package/src/lib/stories/developer tools/helpers/Numbers/cleanNumericString/index.mdx +20 -0
- package/src/lib/stories/developer tools/helpers/Numbers/isValidNumberValue/index.mdx +71 -0
- package/src/lib/stories/developer tools/helpers/Numbers/isValidNumberValue/isValidNumberValue.ts +156 -0
- package/src/lib/stories/developer tools/helpers/logger/index.mdx +63 -0
- package/src/lib/stories/developer tools/helpers/logger/logger.ts +46 -0
- package/src/lib/stories/developer tools/philosophy/Colors/Colors.mdx +43 -0
- package/src/lib/stories/developer tools/philosophy/Colors/Colors.stories.svelte +22 -0
- package/src/lib/stories/developer tools/philosophy/Colors/Opacity.stories.svelte +11 -0
- package/src/lib/stories/developer tools/philosophy/Themes.mdx +23 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Select, { type SelectOption } from '../Select.svelte';
|
|
4
|
+
import { selectOptions, storySelectArgTypes } from '../Select.stories.svelte';
|
|
5
|
+
import { Menu } from '$lib/index.js';
|
|
6
|
+
import MenuItem from '$lib/stories/components/Layout/Menu/MenuItem/MenuItem.svelte';
|
|
7
|
+
import Icon from '@iconify/svelte';
|
|
8
|
+
|
|
9
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
10
|
+
const { Story } = defineMeta({
|
|
11
|
+
component: Select,
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
argTypes: storySelectArgTypes,
|
|
14
|
+
parameters: {
|
|
15
|
+
docs: {
|
|
16
|
+
story: {
|
|
17
|
+
height: '400px',
|
|
18
|
+
inline: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const options = selectOptions;
|
|
25
|
+
|
|
26
|
+
let value = $state<SelectOption>(options[0]);
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<!-- Format look and feel of input content. -->
|
|
30
|
+
<Story name="CustomInput" asChild>
|
|
31
|
+
<Select {options} {value} onselect={(val: SelectOption) => (value = val)}>
|
|
32
|
+
{#snippet customInputContent(selectedOption)}
|
|
33
|
+
{selectedOption.label} 💯💯💯
|
|
34
|
+
{/snippet}
|
|
35
|
+
</Select>
|
|
36
|
+
</Story>
|
|
37
|
+
|
|
38
|
+
<!-- Format look and feel Dropdown Arrow icon -->
|
|
39
|
+
<Story name="CustomDropdownArrowIcon" asChild>
|
|
40
|
+
<Select {options} {value} onselect={(val: SelectOption) => (value = val)}>
|
|
41
|
+
{#snippet customDropdownArrowIcon(open)}
|
|
42
|
+
{#if open}
|
|
43
|
+
<Icon icon="mingcute:up-fill" width="24" height="24" />
|
|
44
|
+
{:else}
|
|
45
|
+
<Icon icon="mingcute:down-fill" width="24" height="24" />
|
|
46
|
+
{/if}
|
|
47
|
+
{/snippet}
|
|
48
|
+
</Select>
|
|
49
|
+
</Story>
|
|
50
|
+
|
|
51
|
+
<!-- Format look and feel of Popper menu item. -->
|
|
52
|
+
<Story name="CustomMenuItem" asChild>
|
|
53
|
+
<Select {options} {value} onselect={(val: SelectOption) => (value = val)}>
|
|
54
|
+
{#snippet customMenuItemContent(selectedOption, selected)}
|
|
55
|
+
{selected ? '✅' : ''} {selectedOption.label} 💯
|
|
56
|
+
{/snippet}
|
|
57
|
+
</Select>
|
|
58
|
+
</Story>
|
|
59
|
+
|
|
60
|
+
<!-- Format look and feel of Popper menu item Placeholder. -->
|
|
61
|
+
<Story name="CustomMenuItemPlaceholder" asChild>
|
|
62
|
+
<Select {options} {value} searchable onselect={(val: SelectOption) => (value = val)}>
|
|
63
|
+
{#snippet customPlaceholderMenuItemContent()}
|
|
64
|
+
🤚🤚🤚🤚 Nothing found....
|
|
65
|
+
{/snippet}
|
|
66
|
+
</Select>
|
|
67
|
+
</Story>
|
|
68
|
+
|
|
69
|
+
<!-- Format look and feel of Popup. -->
|
|
70
|
+
<Story name="CustomPopup" asChild>
|
|
71
|
+
<Select {options} {value}>
|
|
72
|
+
{#snippet customPopupContent(options, selectedOption, onselect)}
|
|
73
|
+
<Menu size="small" separator>
|
|
74
|
+
{#each options as option (option.value)}
|
|
75
|
+
<MenuItem
|
|
76
|
+
type="button"
|
|
77
|
+
disabled={option.disabled}
|
|
78
|
+
selected={selectedOption.value === option.value}
|
|
79
|
+
onclick={() => onselect(option)}
|
|
80
|
+
>
|
|
81
|
+
<b>{option.label}</b>
|
|
82
|
+
</MenuItem>
|
|
83
|
+
{/each}
|
|
84
|
+
</Menu>
|
|
85
|
+
{/snippet}
|
|
86
|
+
</Select>
|
|
87
|
+
</Story>
|
|
88
|
+
|
|
89
|
+
<!-- Format look and feel of Popup [Paper](?path=/docs/components-layout-paper--docs) -->
|
|
90
|
+
<Story
|
|
91
|
+
name="PaperProps"
|
|
92
|
+
args={{
|
|
93
|
+
options,
|
|
94
|
+
value,
|
|
95
|
+
paperProps: {
|
|
96
|
+
color: 'danger',
|
|
97
|
+
},
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
|
|
101
|
+
<!-- Format look and feel of [Popper](?path=/docs/developer-tools-components-popper--docs). We have incrased popupOffsetY in this example. -->
|
|
102
|
+
<Story
|
|
103
|
+
name="PopperProps"
|
|
104
|
+
args={{
|
|
105
|
+
options,
|
|
106
|
+
value,
|
|
107
|
+
popperProps: {
|
|
108
|
+
popupOffsetY: 40,
|
|
109
|
+
},
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
|
|
113
|
+
<!-- Format look and feel of Popup [Menu](?path=/docs/components-layout-menu--docs) -->
|
|
114
|
+
<Story
|
|
115
|
+
name="MenuProps"
|
|
116
|
+
args={{
|
|
117
|
+
options,
|
|
118
|
+
value,
|
|
119
|
+
menuProps: {
|
|
120
|
+
separator: true,
|
|
121
|
+
size: 'large',
|
|
122
|
+
},
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
|
|
126
|
+
<!-- Format look and feel of Popup [MenuItem](?path=/docs/components-layout-menu-menuitem--docs) -->
|
|
127
|
+
<Story
|
|
128
|
+
name="MenuItemProps"
|
|
129
|
+
args={{
|
|
130
|
+
options,
|
|
131
|
+
value,
|
|
132
|
+
menuItemProps: {
|
|
133
|
+
size: 'small',
|
|
134
|
+
type: 'link',
|
|
135
|
+
href: 'https://developer.mozilla.org/en-US/',
|
|
136
|
+
target: '_blank',
|
|
137
|
+
},
|
|
138
|
+
}}
|
|
139
|
+
/>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Select, { type SelectOption } from '../Select.svelte';
|
|
4
|
+
import { selectOptions, storySelectArgTypes } from '../Select.stories.svelte';
|
|
5
|
+
import Icon from '@iconify/svelte';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
component: Select,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: storySelectArgTypes,
|
|
12
|
+
parameters: {
|
|
13
|
+
docs: {
|
|
14
|
+
story: {
|
|
15
|
+
height: '400px',
|
|
16
|
+
inline: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const options = selectOptions;
|
|
23
|
+
|
|
24
|
+
let value = $state<SelectOption>(options[0]);
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<Story
|
|
28
|
+
name="PositionAfter"
|
|
29
|
+
args={{ options, value, onselect: (val: SelectOption) => (value = val) }}
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
<Story
|
|
33
|
+
name="PositionBefore"
|
|
34
|
+
args={{
|
|
35
|
+
options,
|
|
36
|
+
value,
|
|
37
|
+
onselect: (val: SelectOption) => (value = val),
|
|
38
|
+
dropdownArrowPosition: 'before',
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<Story
|
|
43
|
+
name="HideArrow"
|
|
44
|
+
args={{
|
|
45
|
+
options,
|
|
46
|
+
value,
|
|
47
|
+
onselect: (val: SelectOption) => (value = val),
|
|
48
|
+
dropdownArrowPosition: false,
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<!-- Format look and feel Dropdown Arrow icon -->
|
|
53
|
+
<Story name="CustomDropdownArrowIcon" asChild>
|
|
54
|
+
<Select {options} {value} onselect={(val: SelectOption) => (value = val)}>
|
|
55
|
+
{#snippet customDropdownArrowIcon(open)}
|
|
56
|
+
{#if open}
|
|
57
|
+
<Icon icon="mingcute:up-fill" width="24" height="24" />
|
|
58
|
+
{:else}
|
|
59
|
+
<Icon icon="mingcute:down-fill" width="24" height="24" />
|
|
60
|
+
{/if}
|
|
61
|
+
{/snippet}
|
|
62
|
+
</Select>
|
|
63
|
+
</Story>
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { selectOptions, storySelectArgTypes } from '../Select.stories.svelte';
|
|
4
|
+
import Select, { type SelectOption } from '../Select.svelte';
|
|
5
|
+
import type { TextInputClipboardEvent } from '../../TextInput/TextInput.svelte';
|
|
6
|
+
import type {
|
|
7
|
+
DynamicInputFocusEvent,
|
|
8
|
+
DynamicInputKeyboardEvent,
|
|
9
|
+
} from '$lib/stories/developer tools/components/DynamicInput/DynamicInput.svelte';
|
|
10
|
+
|
|
11
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
12
|
+
const { Story } = defineMeta({
|
|
13
|
+
component: Select,
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
argTypes: storySelectArgTypes,
|
|
16
|
+
parameters: {
|
|
17
|
+
docs: {
|
|
18
|
+
story: {
|
|
19
|
+
height: '400px',
|
|
20
|
+
inline: false,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const options = selectOptions;
|
|
27
|
+
|
|
28
|
+
let value = $state<SelectOption>(options[0]);
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<Story
|
|
32
|
+
name="SelectEvent"
|
|
33
|
+
args={{
|
|
34
|
+
options,
|
|
35
|
+
value,
|
|
36
|
+
onselect: (val: SelectOption) => {
|
|
37
|
+
console.log('Select Event', val);
|
|
38
|
+
},
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<Story
|
|
43
|
+
name="Clear"
|
|
44
|
+
args={{
|
|
45
|
+
options,
|
|
46
|
+
value,
|
|
47
|
+
onclear: () => {
|
|
48
|
+
console.log('Clear Event');
|
|
49
|
+
},
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
<Story
|
|
54
|
+
name="Input"
|
|
55
|
+
args={{
|
|
56
|
+
options,
|
|
57
|
+
value,
|
|
58
|
+
searchable: true,
|
|
59
|
+
oninput: (e: Event) => {
|
|
60
|
+
const target = e.target as HTMLInputElement;
|
|
61
|
+
|
|
62
|
+
console.log('Input Event', target.value);
|
|
63
|
+
},
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
<Story
|
|
68
|
+
name="Change"
|
|
69
|
+
args={{
|
|
70
|
+
options,
|
|
71
|
+
value,
|
|
72
|
+
searchable: true,
|
|
73
|
+
onchange: (e: Event) => {
|
|
74
|
+
const target = e.target as HTMLInputElement;
|
|
75
|
+
|
|
76
|
+
console.log('onChange Event', target.value);
|
|
77
|
+
},
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<Story
|
|
82
|
+
name="Focus"
|
|
83
|
+
args={{
|
|
84
|
+
options,
|
|
85
|
+
value,
|
|
86
|
+
onfocus: (e: DynamicInputFocusEvent) => {
|
|
87
|
+
const target = e.target as HTMLInputElement | HTMLButtonElement;
|
|
88
|
+
|
|
89
|
+
console.log('onfocus Event', target);
|
|
90
|
+
},
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
|
|
94
|
+
<Story
|
|
95
|
+
name="Blur"
|
|
96
|
+
args={{
|
|
97
|
+
options,
|
|
98
|
+
value,
|
|
99
|
+
onblur: (e: DynamicInputFocusEvent) => {
|
|
100
|
+
const target = e.target as HTMLInputElement | HTMLButtonElement;
|
|
101
|
+
|
|
102
|
+
console.log('onblur Event', target);
|
|
103
|
+
},
|
|
104
|
+
}}
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
<Story
|
|
108
|
+
name="Copy"
|
|
109
|
+
args={{
|
|
110
|
+
options,
|
|
111
|
+
value,
|
|
112
|
+
searchable: true,
|
|
113
|
+
oncopy: (e: TextInputClipboardEvent) => {
|
|
114
|
+
const target = e.target as HTMLInputElement;
|
|
115
|
+
|
|
116
|
+
console.log('oncopy Event', target);
|
|
117
|
+
},
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
<Story
|
|
122
|
+
name="Cut"
|
|
123
|
+
args={{
|
|
124
|
+
options,
|
|
125
|
+
value,
|
|
126
|
+
searchable: true,
|
|
127
|
+
oncut: (e: TextInputClipboardEvent) => {
|
|
128
|
+
const target = e.target as HTMLInputElement;
|
|
129
|
+
|
|
130
|
+
console.log('oncut Event', target);
|
|
131
|
+
},
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
|
|
135
|
+
<Story
|
|
136
|
+
name="Paste"
|
|
137
|
+
args={{
|
|
138
|
+
options,
|
|
139
|
+
value,
|
|
140
|
+
searchable: true,
|
|
141
|
+
onpaste: (e: TextInputClipboardEvent) => {
|
|
142
|
+
const target = e.target as HTMLInputElement;
|
|
143
|
+
|
|
144
|
+
console.log('onpaste Event', target);
|
|
145
|
+
},
|
|
146
|
+
}}
|
|
147
|
+
/>
|
|
148
|
+
|
|
149
|
+
<Story
|
|
150
|
+
name="KeyDown"
|
|
151
|
+
args={{
|
|
152
|
+
onkeydown: (e: DynamicInputKeyboardEvent) => {
|
|
153
|
+
console.log('onkeydown Event', e.key);
|
|
154
|
+
},
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
|
|
158
|
+
<Story
|
|
159
|
+
name="KeyPress"
|
|
160
|
+
args={{
|
|
161
|
+
onkeypress: (e: DynamicInputKeyboardEvent) => {
|
|
162
|
+
console.log('onkeypress Event', e.key);
|
|
163
|
+
},
|
|
164
|
+
}}
|
|
165
|
+
/>
|
|
166
|
+
|
|
167
|
+
<Story
|
|
168
|
+
name="KeyUp"
|
|
169
|
+
args={{
|
|
170
|
+
onkeyup: (e: DynamicInputKeyboardEvent) => {
|
|
171
|
+
console.log('onkeyup Event', e.key);
|
|
172
|
+
},
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Source } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
# Option Format
|
|
4
|
+
|
|
5
|
+
## SelectOption
|
|
6
|
+
|
|
7
|
+
<Source
|
|
8
|
+
dark
|
|
9
|
+
language="ts"
|
|
10
|
+
code={`
|
|
11
|
+
type SelectOption = {
|
|
12
|
+
value: string | number | boolean | null | undefined;
|
|
13
|
+
label: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
`}
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
## Example values
|
|
20
|
+
|
|
21
|
+
<Source
|
|
22
|
+
dark
|
|
23
|
+
language="ts"
|
|
24
|
+
code={`
|
|
25
|
+
const options: SelectOption[] = [
|
|
26
|
+
{
|
|
27
|
+
value: 1,
|
|
28
|
+
label: 'One',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
value: 2,
|
|
32
|
+
label: 'Two',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
value: 3,
|
|
36
|
+
label: 'Three',
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
`}
|
|
40
|
+
/>
|
package/src/lib/stories/components/Form/Select/Positions/AutoPosition/AutoPosition.stories.svelte
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { selectOptions, storySelectArgTypes } from '../../Select.stories.svelte';
|
|
4
|
+
import Select, { type SelectOption } from '../../Select.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: Select,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storySelectArgTypes,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
story: {
|
|
14
|
+
height: '200px',
|
|
15
|
+
inline: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const options = selectOptions;
|
|
22
|
+
|
|
23
|
+
let value = $state<SelectOption>(options[0]);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<!-- Positions will auto adjust depending on the space on top and bottom -->
|
|
27
|
+
<Story
|
|
28
|
+
name="PositionAutoAdjust"
|
|
29
|
+
args={{
|
|
30
|
+
options,
|
|
31
|
+
value,
|
|
32
|
+
onselect: (val: SelectOption) => (value = val),
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
<!-- Positions will not auto adjust if you use `lockPoistions` -->
|
|
37
|
+
<Story
|
|
38
|
+
name="LockPoistions"
|
|
39
|
+
args={{
|
|
40
|
+
options,
|
|
41
|
+
value,
|
|
42
|
+
onselect: (val: SelectOption) => (value = val),
|
|
43
|
+
popupPositionY: 'top',
|
|
44
|
+
lockPoistions: true,
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<!-- you can also adjust `popperHeightForVerticalPosition` to achive the same -->
|
|
49
|
+
<Story
|
|
50
|
+
name="HeightForVerticalPosition"
|
|
51
|
+
args={{
|
|
52
|
+
options,
|
|
53
|
+
value,
|
|
54
|
+
onselect: (val: SelectOption) => (value = val),
|
|
55
|
+
popupPositionY: 'top',
|
|
56
|
+
popperHeightForVerticalPosition: 3,
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { selectOptions, storySelectArgTypes } from '../Select.stories.svelte';
|
|
4
|
+
import Select, { type SelectOption } from '../Select.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: Select,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storySelectArgTypes,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: 'centered',
|
|
13
|
+
docs: {
|
|
14
|
+
story: {
|
|
15
|
+
height: '600px',
|
|
16
|
+
inline: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const options = selectOptions;
|
|
23
|
+
|
|
24
|
+
let value = $state<SelectOption>(options[0]);
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<Story
|
|
28
|
+
name="BottomLeft"
|
|
29
|
+
args={{ options, value, onselect: (val: SelectOption) => (value = val), popupMaxHeight: '200px' }}
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
<Story
|
|
33
|
+
name="BottomCenter"
|
|
34
|
+
args={{
|
|
35
|
+
options,
|
|
36
|
+
value,
|
|
37
|
+
onselect: (val: SelectOption) => (value = val),
|
|
38
|
+
popupPositionX: 'center',
|
|
39
|
+
popupMaxHeight: '200px',
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
|
|
43
|
+
<Story
|
|
44
|
+
name="BottomRight"
|
|
45
|
+
args={{
|
|
46
|
+
options,
|
|
47
|
+
value,
|
|
48
|
+
onselect: (val: SelectOption) => (value = val),
|
|
49
|
+
popupPositionX: 'right',
|
|
50
|
+
popupMaxHeight: '200px',
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<Story
|
|
55
|
+
name="TopLeft"
|
|
56
|
+
args={{
|
|
57
|
+
options,
|
|
58
|
+
value,
|
|
59
|
+
onselect: (val: SelectOption) => (value = val),
|
|
60
|
+
popupPositionY: 'top',
|
|
61
|
+
popupMaxHeight: '200px',
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
<Story
|
|
66
|
+
name="TopCenter"
|
|
67
|
+
args={{
|
|
68
|
+
options,
|
|
69
|
+
value,
|
|
70
|
+
onselect: (val: SelectOption) => (value = val),
|
|
71
|
+
popupPositionY: 'top',
|
|
72
|
+
popupPositionX: 'center',
|
|
73
|
+
popupMaxHeight: '200px',
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<Story
|
|
78
|
+
name="TopRight"
|
|
79
|
+
args={{
|
|
80
|
+
options,
|
|
81
|
+
value,
|
|
82
|
+
onselect: (val: SelectOption) => (value = val),
|
|
83
|
+
popupPositionY: 'top',
|
|
84
|
+
popupPositionX: 'right',
|
|
85
|
+
popupMaxHeight: '200px',
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Select, { type SelectOption } from '../Select.svelte';
|
|
4
|
+
import { selectOptions, storySelectArgTypes } from '../Select.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: Select,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storySelectArgTypes,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
story: {
|
|
14
|
+
height: '400px',
|
|
15
|
+
inline: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const options = selectOptions;
|
|
22
|
+
|
|
23
|
+
let value = $state<SelectOption>(options[0]);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Story name="Roundness 1" args={{ options, value }} />
|
|
27
|
+
|
|
28
|
+
<Story name="Roundness 2" args={{ options, value, roundness: 2 }} />
|
|
29
|
+
|
|
30
|
+
<Story name="Roundness 3" args={{ options, value, roundness: 3 }} />
|
|
31
|
+
|
|
32
|
+
<Story name="Roundness 0" args={{ options, value, roundness: 0 }} />
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Select, { type SelectOption } from './Select.svelte';
|
|
4
|
+
import type { StoryBookArgTypes } from '$lib/storybook-types.js';
|
|
5
|
+
import { componentRoundnessArray } from '$lib/types/roundness.js';
|
|
6
|
+
import { componentSizeArray } from '$lib/types/size.js';
|
|
7
|
+
|
|
8
|
+
export const storySelectArgTypes: StoryBookArgTypes = {
|
|
9
|
+
roundness: {
|
|
10
|
+
control: { type: 'select' },
|
|
11
|
+
options: componentRoundnessArray,
|
|
12
|
+
},
|
|
13
|
+
size: {
|
|
14
|
+
control: { type: 'select' },
|
|
15
|
+
options: componentSizeArray,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
20
|
+
const { Story } = defineMeta({
|
|
21
|
+
component: Select,
|
|
22
|
+
tags: ['autodocs'],
|
|
23
|
+
argTypes: storySelectArgTypes,
|
|
24
|
+
parameters: {
|
|
25
|
+
docs: {
|
|
26
|
+
story: {
|
|
27
|
+
height: '400px',
|
|
28
|
+
inline: false,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const selectOptions: SelectOption[] = [
|
|
35
|
+
{
|
|
36
|
+
value: 1,
|
|
37
|
+
label: 'One',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: 2,
|
|
41
|
+
label: 'Two',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
value: 3,
|
|
45
|
+
label: 'Three',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: 4,
|
|
49
|
+
label: 'Four',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
value: 5,
|
|
53
|
+
label: 'Five',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
value: 6,
|
|
57
|
+
label: 'Six',
|
|
58
|
+
disabled: true,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: 7,
|
|
62
|
+
label: 'Seven',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
value: 8,
|
|
66
|
+
label: 'Eight',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
value: 9,
|
|
70
|
+
label: 'Nine',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const options = selectOptions;
|
|
75
|
+
|
|
76
|
+
let value = $state<SelectOption | undefined>(options[0]);
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<!-- Select with default style -->
|
|
80
|
+
<Story name="Default" asChild>
|
|
81
|
+
<Select {options} {value} onselect={(val: SelectOption) => (value = val)} />
|
|
82
|
+
</Story>
|
|
83
|
+
|
|
84
|
+
<Story name="Searchable" asChild>
|
|
85
|
+
<Select
|
|
86
|
+
{options}
|
|
87
|
+
{value}
|
|
88
|
+
searchable
|
|
89
|
+
optionsPlaceholder="No results"
|
|
90
|
+
onselect={(val: SelectOption) => (value = val)}
|
|
91
|
+
/>
|
|
92
|
+
</Story>
|
|
93
|
+
|
|
94
|
+
<Story name="Clearable" asChild>
|
|
95
|
+
<Select
|
|
96
|
+
{options}
|
|
97
|
+
{value}
|
|
98
|
+
clearable
|
|
99
|
+
onselect={(val: SelectOption) => (value = val)}
|
|
100
|
+
onclear={() => (value = undefined)}
|
|
101
|
+
placeholder="Select option"
|
|
102
|
+
/>
|
|
103
|
+
</Story>
|
|
104
|
+
|
|
105
|
+
<Story name="PopupMaxHeight" asChild>
|
|
106
|
+
<Select
|
|
107
|
+
{options}
|
|
108
|
+
{value}
|
|
109
|
+
onselect={(val: SelectOption) => (value = val)}
|
|
110
|
+
popupMaxHeight="200px"
|
|
111
|
+
/>
|
|
112
|
+
</Story>
|
|
113
|
+
|
|
114
|
+
<!-- Format look and feel of input content. [More Customizations](?path=/docs/components-form-select-customize--docs) -->
|
|
115
|
+
<Story name="CustomInputContent" asChild>
|
|
116
|
+
<Select {options} {value} onselect={(val: SelectOption) => (value = val)}>
|
|
117
|
+
{#snippet customInputContent(selectedOption)}
|
|
118
|
+
{selectedOption.label} 💯💯💯
|
|
119
|
+
{/snippet}
|
|
120
|
+
</Select>
|
|
121
|
+
</Story>
|