@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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type {
|
|
3
|
+
ButtonLinkReferrerpolicy,
|
|
4
|
+
ButtonLinkTarget,
|
|
5
|
+
} from '$lib/stories/components/Form/Button/Button.svelte';
|
|
6
|
+
import { type Snippet } from 'svelte';
|
|
7
|
+
import type { MouseEventHandler } from 'svelte/elements';
|
|
8
|
+
|
|
9
|
+
export type MenuItemType = 'text' | 'button' | 'link';
|
|
10
|
+
|
|
11
|
+
export const menuItemTypeArray: MenuItemType[] = ['text', 'button', 'link'];
|
|
12
|
+
|
|
13
|
+
export interface MenuItemProps {
|
|
14
|
+
/** MenuItem contents goes here */
|
|
15
|
+
children?: Snippet;
|
|
16
|
+
/** MenuItem ref */
|
|
17
|
+
ref?: HTMLLIElement;
|
|
18
|
+
/** Custom css class */
|
|
19
|
+
class?: string;
|
|
20
|
+
/** Id */
|
|
21
|
+
id?: string;
|
|
22
|
+
/** Menu Item type */
|
|
23
|
+
type?: MenuItemType;
|
|
24
|
+
/** Menu Item type */
|
|
25
|
+
selected?: boolean;
|
|
26
|
+
/** Separator */
|
|
27
|
+
separator?: boolean;
|
|
28
|
+
/** How large should the Menu Items be? */
|
|
29
|
+
size?: ComponentSize;
|
|
30
|
+
/** The onclick event handler */
|
|
31
|
+
onclick?: MouseEventHandler<HTMLButtonElement>;
|
|
32
|
+
/** disabled state */
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
/** link href */
|
|
35
|
+
href?: string;
|
|
36
|
+
/** Link button: download */
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
download?: any;
|
|
39
|
+
/** Link button: hreflang */
|
|
40
|
+
hreflang?: string | undefined | null;
|
|
41
|
+
/** Link button: media */
|
|
42
|
+
media?: string | undefined | null;
|
|
43
|
+
/** Link button: ping */
|
|
44
|
+
ping?: string | undefined | null;
|
|
45
|
+
/** Link button: rel */
|
|
46
|
+
rel?: string | undefined | null;
|
|
47
|
+
/** Link button: target */
|
|
48
|
+
target?: ButtonLinkTarget;
|
|
49
|
+
/** Link button: Type */
|
|
50
|
+
anchorMediaType?: string | undefined | null;
|
|
51
|
+
/** Link button: referrerpolicy */
|
|
52
|
+
referrerpolicy?: ButtonLinkReferrerpolicy;
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<script lang="ts">
|
|
57
|
+
import { getContext } from 'svelte';
|
|
58
|
+
import type { ComponentSize } from '$lib/types/size.js';
|
|
59
|
+
|
|
60
|
+
let {
|
|
61
|
+
children,
|
|
62
|
+
id,
|
|
63
|
+
class: className = '',
|
|
64
|
+
type = 'text',
|
|
65
|
+
href,
|
|
66
|
+
download,
|
|
67
|
+
hreflang,
|
|
68
|
+
media,
|
|
69
|
+
ping,
|
|
70
|
+
rel,
|
|
71
|
+
target,
|
|
72
|
+
anchorMediaType,
|
|
73
|
+
referrerpolicy,
|
|
74
|
+
disabled = false,
|
|
75
|
+
selected = false,
|
|
76
|
+
separator: separatorInternal,
|
|
77
|
+
onclick,
|
|
78
|
+
size: sizeInternal,
|
|
79
|
+
ref = $bindable<HTMLLIElement>(),
|
|
80
|
+
}: MenuItemProps = $props();
|
|
81
|
+
|
|
82
|
+
const hover = false;
|
|
83
|
+
|
|
84
|
+
const sizeMenu = // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
(getContext<any>('MenuItemSize') ? getContext<any>('MenuItemSize')() : undefined) as
|
|
86
|
+
| ComponentSize
|
|
87
|
+
| undefined;
|
|
88
|
+
const size = sizeMenu || sizeInternal || 'normal';
|
|
89
|
+
|
|
90
|
+
const separatorMenu = // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
(getContext<any>('MenuItemSeparator') ? getContext<any>('MenuItemSeparator')() : undefined) as
|
|
92
|
+
| boolean
|
|
93
|
+
| undefined;
|
|
94
|
+
const separator = separatorMenu !== undefined ? separatorMenu : separatorInternal || false;
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
{#snippet menuItemContent()}
|
|
98
|
+
{#if children}
|
|
99
|
+
{@render children()}
|
|
100
|
+
{/if}
|
|
101
|
+
{/snippet}
|
|
102
|
+
|
|
103
|
+
<li
|
|
104
|
+
class:disabled
|
|
105
|
+
class:separator
|
|
106
|
+
class:selected
|
|
107
|
+
class:hover
|
|
108
|
+
class={['dodo-ui-MenuItem', `size--${size}`, className].join(' ')}
|
|
109
|
+
{id}
|
|
110
|
+
bind:this={ref}
|
|
111
|
+
>
|
|
112
|
+
{#if type === 'link'}
|
|
113
|
+
<a
|
|
114
|
+
class:disabled
|
|
115
|
+
class:selected
|
|
116
|
+
class={['MenuItem-type', `MenuItem-type--${type}`, `size--${size}`].join(' ')}
|
|
117
|
+
{href}
|
|
118
|
+
{download}
|
|
119
|
+
{hreflang}
|
|
120
|
+
{media}
|
|
121
|
+
{ping}
|
|
122
|
+
{rel}
|
|
123
|
+
{target}
|
|
124
|
+
type={anchorMediaType}
|
|
125
|
+
{referrerpolicy}
|
|
126
|
+
>
|
|
127
|
+
{@render menuItemContent()}
|
|
128
|
+
</a>
|
|
129
|
+
{:else if type === 'button'}
|
|
130
|
+
<button
|
|
131
|
+
class:disabled
|
|
132
|
+
class:selected
|
|
133
|
+
class={['MenuItem-type', `MenuItem-type--${type}`, `size--${size}`].join(' ')}
|
|
134
|
+
{onclick}
|
|
135
|
+
{disabled}
|
|
136
|
+
>
|
|
137
|
+
{@render menuItemContent()}
|
|
138
|
+
</button>
|
|
139
|
+
{:else}
|
|
140
|
+
<div
|
|
141
|
+
class:disabled
|
|
142
|
+
class:selected
|
|
143
|
+
class={['MenuItem-type', `MenuItem-type--${type}`, `size--${size}`].join(' ')}
|
|
144
|
+
>
|
|
145
|
+
{@render menuItemContent()}
|
|
146
|
+
</div>
|
|
147
|
+
{/if}
|
|
148
|
+
</li>
|
|
149
|
+
|
|
150
|
+
<style lang="scss">
|
|
151
|
+
:global(:root) {
|
|
152
|
+
--dodo-ui-MenuItem-selected-bg: color-mix(
|
|
153
|
+
in oklab,
|
|
154
|
+
var(--dodo-color-neutral-800) 4%,
|
|
155
|
+
transparent
|
|
156
|
+
);
|
|
157
|
+
--dodo-ui-MenuItem-hover-bg: color-mix(in oklab, var(--dodo-color-neutral-800) 8%, transparent);
|
|
158
|
+
--dodo-ui-MenuItem-active-bg: color-mix(
|
|
159
|
+
in oklab,
|
|
160
|
+
var(--dodo-color-neutral-800) 11%,
|
|
161
|
+
transparent
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
--dodo-ui-MenuItem-separator-color: var(--dodo-color-neutral-300);
|
|
165
|
+
|
|
166
|
+
--dodo-ui-MenuItem-disabled-color: var(--dodo-color-neutral-400);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
:global(.dodo-theme--dark) {
|
|
170
|
+
--dodo-ui-MenuItem-selected-bg: color-mix(
|
|
171
|
+
in oklab,
|
|
172
|
+
var(--dodo-color-neutral-800) 4%,
|
|
173
|
+
transparent
|
|
174
|
+
);
|
|
175
|
+
--dodo-ui-MenuItem-hover-bg: color-mix(in oklab, var(--dodo-color-neutral-800) 8%, transparent);
|
|
176
|
+
--dodo-ui-MenuItem-active-bg: color-mix(
|
|
177
|
+
in oklab,
|
|
178
|
+
var(--dodo-color-neutral-800) 15%,
|
|
179
|
+
transparent
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
--dodo-ui-MenuItem-separator-color: var(--dodo-color-neutral-300);
|
|
183
|
+
|
|
184
|
+
--dodo-ui-MenuItem-disabled-color: var(--dodo-color-neutral-500);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.dodo-ui-MenuItem {
|
|
188
|
+
display: flex;
|
|
189
|
+
margin: 0;
|
|
190
|
+
padding: 0;
|
|
191
|
+
user-select: none;
|
|
192
|
+
|
|
193
|
+
&.separator {
|
|
194
|
+
border-bottom: 1px solid var(--dodo-ui-MenuItem-separator-color);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.MenuItem-type {
|
|
198
|
+
cursor: pointer;
|
|
199
|
+
transition: all 70ms;
|
|
200
|
+
text-decoration: none;
|
|
201
|
+
margin: 0;
|
|
202
|
+
display: flex;
|
|
203
|
+
flex-wrap: wrap;
|
|
204
|
+
align-items: center;
|
|
205
|
+
border: 0;
|
|
206
|
+
outline: 0;
|
|
207
|
+
background-color: transparent;
|
|
208
|
+
color: inherit;
|
|
209
|
+
font-family: inherit;
|
|
210
|
+
width: 100%;
|
|
211
|
+
|
|
212
|
+
&.selected {
|
|
213
|
+
background-color: var(--dodo-ui-MenuItem-selected-bg);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
&:hover {
|
|
217
|
+
background-color: var(--dodo-ui-MenuItem-hover-bg);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
&:active {
|
|
221
|
+
background-color: var(--dodo-ui-MenuItem-active-bg);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
&.size {
|
|
225
|
+
&--normal {
|
|
226
|
+
min-height: var(--dodo-ui-element-height-normal);
|
|
227
|
+
font-size: 1rem;
|
|
228
|
+
padding: 0 calc(var(--dodo-ui-space-small) * 2);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
&--small {
|
|
232
|
+
min-height: var(--dodo-ui-element-height-small);
|
|
233
|
+
padding: 0 var(--dodo-ui-space);
|
|
234
|
+
font-size: 0.9rem;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
&--large {
|
|
238
|
+
min-height: var(--dodo-ui-element-height-large);
|
|
239
|
+
font-size: 1.1rem;
|
|
240
|
+
padding: 0 calc(var(--dodo-ui-space) * 2);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
&.disabled {
|
|
245
|
+
cursor: initial;
|
|
246
|
+
|
|
247
|
+
background-color: transparent;
|
|
248
|
+
color: var(--dodo-ui-MenuItem-disabled-color);
|
|
249
|
+
|
|
250
|
+
&:hover {
|
|
251
|
+
background-color: transparent;
|
|
252
|
+
color: var(--dodo-ui-MenuItem-disabled-color);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
&:active {
|
|
256
|
+
background-color: transparent;
|
|
257
|
+
color: var(--dodo-ui-MenuItem-disabled-color);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
&.hover {
|
|
263
|
+
.MenuItem-type {
|
|
264
|
+
background-color: var(--dodo-ui-MenuItem-hover-bg);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
</style>
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import type { ComponentRoundness } from '$lib/types/roundness.js';
|
|
3
|
+
import type { ComponentShadow } from '$lib/types/shadow.js';
|
|
4
|
+
import type { ComponentWeight } from '$lib/types/weight.js';
|
|
2
5
|
import {
|
|
3
6
|
componentColorPriorityArray,
|
|
4
7
|
componentColorSeverityArray,
|
|
@@ -12,16 +15,8 @@
|
|
|
12
15
|
...componentColorPriorityArray,
|
|
13
16
|
...componentColorSeverityArray,
|
|
14
17
|
];
|
|
15
|
-
</script>
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
import type { ComponentRoundness } from '$lib/types/roundness.js';
|
|
19
|
-
import type { ComponentShadow } from '$lib/types/shadow.js';
|
|
20
|
-
import type { ComponentWeight } from '$lib/types/weight.js';
|
|
21
|
-
|
|
22
|
-
import type { Snippet } from 'svelte';
|
|
23
|
-
|
|
24
|
-
interface PaperProps {
|
|
19
|
+
export interface PaperProps {
|
|
25
20
|
/** Paper contents goes here */
|
|
26
21
|
children?: Snippet;
|
|
27
22
|
/** Paper ref */
|
|
@@ -49,6 +44,10 @@
|
|
|
49
44
|
/** Custom border color. Use CSS compatible value */
|
|
50
45
|
customBorderColor?: string;
|
|
51
46
|
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<script lang="ts">
|
|
50
|
+
import type { Snippet } from 'svelte';
|
|
52
51
|
|
|
53
52
|
let {
|
|
54
53
|
children,
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { ComponentColor } from '$lib/types/colors.js';
|
|
3
|
+
|
|
4
|
+
export type SeparatorOrientation = 'horizontal' | 'vertical';
|
|
5
|
+
|
|
6
|
+
export const separatorOrientationArray: SeparatorOrientation[] = ['horizontal', 'vertical'];
|
|
7
|
+
|
|
8
|
+
export interface SeparatorProps {
|
|
9
|
+
/** Separator ref */
|
|
10
|
+
ref?: HTMLDivElement;
|
|
11
|
+
/** Custom css class */
|
|
12
|
+
class?: string;
|
|
13
|
+
/** Id */
|
|
14
|
+
id?: string;
|
|
15
|
+
/** What color to use? */
|
|
16
|
+
color?: ComponentColor;
|
|
17
|
+
/** Separator Width */
|
|
18
|
+
width?: string;
|
|
19
|
+
/** Separator Height */
|
|
20
|
+
height?: string;
|
|
21
|
+
/** Separator orientation, 'horizontal', 'vertical'*/
|
|
22
|
+
orientation?: SeparatorOrientation;
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
let {
|
|
28
|
+
id,
|
|
29
|
+
class: className = '',
|
|
30
|
+
orientation = 'horizontal',
|
|
31
|
+
color = 'neutral',
|
|
32
|
+
ref = $bindable<HTMLDivElement>(),
|
|
33
|
+
width,
|
|
34
|
+
height,
|
|
35
|
+
}: SeparatorProps = $props();
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div
|
|
39
|
+
class={['dodo-ui-Separator', `color--${color}`, `orientation--${orientation}`, className].join(
|
|
40
|
+
' ',
|
|
41
|
+
)}
|
|
42
|
+
{id}
|
|
43
|
+
style={`${width ? `width:${width};` : ''}
|
|
44
|
+
${height ? `height:${height};` : ''}
|
|
45
|
+
`}
|
|
46
|
+
bind:this={ref}
|
|
47
|
+
></div>
|
|
48
|
+
|
|
49
|
+
<style lang="scss">
|
|
50
|
+
@use 'utils/scss/mixins.scss' as *;
|
|
51
|
+
|
|
52
|
+
:global(:root) {
|
|
53
|
+
@include generate-dodo-ui-separator-colors(neutral);
|
|
54
|
+
@include generate-dodo-ui-separator-colors(primary);
|
|
55
|
+
@include generate-dodo-ui-separator-colors(secondary);
|
|
56
|
+
@include generate-dodo-ui-separator-colors(safe);
|
|
57
|
+
@include generate-dodo-ui-separator-colors(warning);
|
|
58
|
+
@include generate-dodo-ui-separator-colors(danger);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:global(.dodo-theme--dark) {
|
|
62
|
+
@include generate-dodo-ui-separator-colors-dark(neutral);
|
|
63
|
+
@include generate-dodo-ui-separator-colors-dark(primary);
|
|
64
|
+
@include generate-dodo-ui-separator-colors-dark(secondary);
|
|
65
|
+
@include generate-dodo-ui-separator-colors-dark(safe);
|
|
66
|
+
@include generate-dodo-ui-separator-colors-dark(warning);
|
|
67
|
+
@include generate-dodo-ui-separator-colors-dark(danger);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.dodo-ui-Separator {
|
|
71
|
+
&.color {
|
|
72
|
+
@include generate-dodo-ui-separator-color(neutral);
|
|
73
|
+
@include generate-dodo-ui-separator-color(primary);
|
|
74
|
+
@include generate-dodo-ui-separator-color(secondary);
|
|
75
|
+
@include generate-dodo-ui-separator-color(safe);
|
|
76
|
+
@include generate-dodo-ui-separator-color(warning);
|
|
77
|
+
@include generate-dodo-ui-separator-color(danger);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&.orientation {
|
|
81
|
+
&--horizontal {
|
|
82
|
+
display: flex;
|
|
83
|
+
height: var(--dodo-ui-element-border-width);
|
|
84
|
+
width: 100%;
|
|
85
|
+
margin: calc(var(--dodo-ui-space) * 1) 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&--vertical {
|
|
89
|
+
display: inline-flex;
|
|
90
|
+
height: 100%;
|
|
91
|
+
width: var(--dodo-ui-element-border-width);
|
|
92
|
+
margin: 0 calc(var(--dodo-ui-space) * 1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// Mixin: generate-dodo-ui-button-colors
|
|
2
|
+
/// Generates CSS custom properties for Dodo UI button styles (text & solid)
|
|
3
|
+
/// across different interaction states (default, hover, active).
|
|
4
|
+
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
5
|
+
@mixin generate-dodo-ui-separator-colors($color-name) {
|
|
6
|
+
--dodo-ui-Separator-color-#{$color-name}: var(--dodo-color-#{$color-name}-300);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/// Mixin: generate-dodo-ui-button-colors
|
|
10
|
+
/// Generates CSS custom properties for Dodo UI button styles (text & solid)
|
|
11
|
+
/// across different interaction states (default, hover, active).
|
|
12
|
+
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
13
|
+
@mixin generate-dodo-ui-separator-colors-dark($color-name) {
|
|
14
|
+
--dodo-ui-Separator-color-#{$color-name}: var(--dodo-color-#{$color-name}-300);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// Mixin: generate-dodo-ui-button-color
|
|
18
|
+
/// Auto-generates .color--[theme] > .variant--text & .variant--solid styles
|
|
19
|
+
/// @param {String} $theme - e.g., default, safe, danger, etc.
|
|
20
|
+
@mixin generate-dodo-ui-separator-color($theme) {
|
|
21
|
+
&--#{$theme} {
|
|
22
|
+
background-color: var(--dodo-ui-Separator-color-#{$theme});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { type ComponentSize, type TextInputType } from '$lib/index.js';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type {
|
|
5
|
+
ChangeEventHandler,
|
|
6
|
+
ClipboardEventHandler,
|
|
7
|
+
FocusEventHandler,
|
|
8
|
+
FormEventHandler,
|
|
9
|
+
MouseEventHandler,
|
|
10
|
+
} from 'svelte/elements';
|
|
11
|
+
|
|
12
|
+
export type DynamicInputVariant = 'input' | 'button';
|
|
13
|
+
|
|
14
|
+
export const dynamicInputVariantArray: DynamicInputVariant[] = ['input', 'button'];
|
|
15
|
+
|
|
16
|
+
export type DynamicInputClickEvent = MouseEvent & {
|
|
17
|
+
currentTarget: EventTarget & HTMLButtonElement;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type DynamicInputFocusEvent = FocusEvent & {
|
|
21
|
+
currentTarget: EventTarget & (HTMLInputElement | HTMLButtonElement);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export interface DynamicInputProps {
|
|
25
|
+
/** How large should the button be? */
|
|
26
|
+
size?: ComponentSize;
|
|
27
|
+
/** Input type? */
|
|
28
|
+
type?: TextInputType;
|
|
29
|
+
/** Input ref */
|
|
30
|
+
ref?: HTMLInputElement | HTMLButtonElement;
|
|
31
|
+
/** Input value */
|
|
32
|
+
value?: string | number;
|
|
33
|
+
/** variant */
|
|
34
|
+
variant?: DynamicInputVariant;
|
|
35
|
+
/** How round should the border radius be? */
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
/** disabled state */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** Read only ? */
|
|
40
|
+
readonly?: boolean;
|
|
41
|
+
/** Name */
|
|
42
|
+
name?: string;
|
|
43
|
+
/** Id */
|
|
44
|
+
id?: string;
|
|
45
|
+
/** Icon before button content */
|
|
46
|
+
before?: Snippet;
|
|
47
|
+
/** Icon after button content */
|
|
48
|
+
after?: Snippet;
|
|
49
|
+
/** Custom css class*/
|
|
50
|
+
class?: string;
|
|
51
|
+
/** The onclick event handler */
|
|
52
|
+
onclick?: MouseEventHandler<HTMLButtonElement>;
|
|
53
|
+
/** oninput event handler */
|
|
54
|
+
oninput?: FormEventHandler<HTMLInputElement>;
|
|
55
|
+
/** onchange event handler */
|
|
56
|
+
onchange?: ChangeEventHandler<HTMLInputElement>;
|
|
57
|
+
/** onblur event handler */
|
|
58
|
+
onblur?: FocusEventHandler<HTMLInputElement | HTMLButtonElement>;
|
|
59
|
+
/** onfocus event handler */
|
|
60
|
+
onfocus?: FocusEventHandler<HTMLInputElement | HTMLButtonElement>;
|
|
61
|
+
/** onpaste event handler */
|
|
62
|
+
onpaste?: ClipboardEventHandler<HTMLInputElement>;
|
|
63
|
+
/** oncopy event handler */
|
|
64
|
+
oncopy?: ClipboardEventHandler<HTMLInputElement>;
|
|
65
|
+
/** oncut event handler */
|
|
66
|
+
oncut?: ClipboardEventHandler<HTMLInputElement>;
|
|
67
|
+
/** custom Content Formatting for variant button */
|
|
68
|
+
customInputContent?: (value: string | number) => Snippet;
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<script lang="ts">
|
|
73
|
+
let {
|
|
74
|
+
type = 'text',
|
|
75
|
+
name,
|
|
76
|
+
id,
|
|
77
|
+
class: className = '',
|
|
78
|
+
disabled = false,
|
|
79
|
+
onchange,
|
|
80
|
+
oninput,
|
|
81
|
+
onblur,
|
|
82
|
+
onfocus,
|
|
83
|
+
onpaste,
|
|
84
|
+
oncopy,
|
|
85
|
+
oncut,
|
|
86
|
+
value = $bindable<string | number>(),
|
|
87
|
+
placeholder,
|
|
88
|
+
ref = $bindable<HTMLInputElement | HTMLButtonElement>(),
|
|
89
|
+
readonly = false,
|
|
90
|
+
variant = 'input',
|
|
91
|
+
size = 'normal',
|
|
92
|
+
onclick,
|
|
93
|
+
customInputContent,
|
|
94
|
+
}: DynamicInputProps = $props();
|
|
95
|
+
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
+
let customInputContentTyped = customInputContent as any;
|
|
98
|
+
|
|
99
|
+
function onclickMod(e: DynamicInputClickEvent) {
|
|
100
|
+
if (onfocus) {
|
|
101
|
+
onfocus(e);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (onclick) {
|
|
105
|
+
onclick(e);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
{#if variant === 'button'}
|
|
111
|
+
<button
|
|
112
|
+
{id}
|
|
113
|
+
class={[
|
|
114
|
+
'dodo-ui-DynamicInput',
|
|
115
|
+
`size--${size}`,
|
|
116
|
+
`variant--${variant}`,
|
|
117
|
+
`${!value ? 'placeholder' : ''}`,
|
|
118
|
+
className,
|
|
119
|
+
].join(' ')}
|
|
120
|
+
bind:this={ref}
|
|
121
|
+
onclick={onclickMod}
|
|
122
|
+
{onblur}
|
|
123
|
+
{disabled}
|
|
124
|
+
>
|
|
125
|
+
{#if customInputContentTyped}
|
|
126
|
+
{@render customInputContentTyped(value)}
|
|
127
|
+
{:else}
|
|
128
|
+
{`${value}` || placeholder}
|
|
129
|
+
{/if}
|
|
130
|
+
</button>
|
|
131
|
+
{:else}
|
|
132
|
+
<input
|
|
133
|
+
class={['dodo-ui-DynamicInput', `size--${size}`, `variant--${variant}`, className].join(' ')}
|
|
134
|
+
{type}
|
|
135
|
+
{name}
|
|
136
|
+
{id}
|
|
137
|
+
{disabled}
|
|
138
|
+
{oninput}
|
|
139
|
+
{onchange}
|
|
140
|
+
{onfocus}
|
|
141
|
+
{onblur}
|
|
142
|
+
{onpaste}
|
|
143
|
+
{oncopy}
|
|
144
|
+
{oncut}
|
|
145
|
+
{placeholder}
|
|
146
|
+
bind:value
|
|
147
|
+
bind:this={ref}
|
|
148
|
+
{readonly}
|
|
149
|
+
/>
|
|
150
|
+
{/if}
|
|
151
|
+
|
|
152
|
+
<style lang="scss">
|
|
153
|
+
.dodo-ui-DynamicInput {
|
|
154
|
+
flex: 1;
|
|
155
|
+
border: 0;
|
|
156
|
+
outline: 0;
|
|
157
|
+
height: 100%;
|
|
158
|
+
background-color: transparent;
|
|
159
|
+
font-family: inherit;
|
|
160
|
+
color: inherit;
|
|
161
|
+
letter-spacing: 0.3px;
|
|
162
|
+
|
|
163
|
+
margin: 0;
|
|
164
|
+
|
|
165
|
+
&.variant {
|
|
166
|
+
&--button {
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: flex-start;
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
|
|
172
|
+
&.placeholder {
|
|
173
|
+
opacity: 0.6;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&.size {
|
|
179
|
+
&--normal {
|
|
180
|
+
font-size: 1rem;
|
|
181
|
+
padding: 0 calc(var(--dodo-ui-space-small) * 2);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&--small {
|
|
185
|
+
padding: 0 var(--dodo-ui-space);
|
|
186
|
+
font-size: 0.9rem;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
&--large {
|
|
190
|
+
font-size: 1.1rem;
|
|
191
|
+
padding: 0 calc(var(--dodo-ui-space) * 2);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" module>
|
|
2
2
|
import type { ComponentRoundness } from '$lib/types/roundness.js';
|
|
3
3
|
import type { ComponentSize } from '$lib/types/size.js';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
|
|
6
|
-
interface InputEnclosureProps {
|
|
6
|
+
export interface InputEnclosureProps {
|
|
7
7
|
/** InputEnclosure contents goes here */
|
|
8
8
|
children?: Snippet;
|
|
9
9
|
/** InputEnclosure ref */
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
/** Custom css class*/
|
|
28
28
|
class?: string;
|
|
29
29
|
}
|
|
30
|
+
</script>
|
|
30
31
|
|
|
32
|
+
<script lang="ts">
|
|
31
33
|
let {
|
|
32
34
|
size = 'normal',
|
|
33
35
|
roundness = 1,
|
|
@@ -62,6 +64,7 @@
|
|
|
62
64
|
{#if children}
|
|
63
65
|
{@render children()}
|
|
64
66
|
{/if}
|
|
67
|
+
|
|
65
68
|
{#if after}
|
|
66
69
|
<span class="content--after">
|
|
67
70
|
{@render after()}
|