@flightlesslabs/dodo-ui 0.3.0 → 0.5.0

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