@awenovations/aura 0.0.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/README.md +13 -0
- package/dist/alert/alert.stories.svelte +27 -0
- package/dist/alert/alert.stories.svelte.d.ts +28 -0
- package/dist/alert/alert.svelte +65 -0
- package/dist/alert/alert.svelte.d.ts +23 -0
- package/dist/alert/props.d.ts +2 -0
- package/dist/alert/props.js +1 -0
- package/dist/button/button.stories.svelte +456 -0
- package/dist/button/button.stories.svelte.d.ts +39 -0
- package/dist/button/button.svelte +143 -0
- package/dist/button/button.svelte.d.ts +29 -0
- package/dist/button/props.d.ts +6 -0
- package/dist/button/props.js +3 -0
- package/dist/container/container.stories.svelte +52 -0
- package/dist/container/container.stories.svelte.d.ts +32 -0
- package/dist/container/container.svelte +35 -0
- package/dist/container/container.svelte.d.ts +23 -0
- package/dist/container/props.d.ts +4 -0
- package/dist/container/props.js +2 -0
- package/dist/directives/click-outside.d.ts +6 -0
- package/dist/directives/click-outside.js +24 -0
- package/dist/dropdown/dropdown.stories.svelte +56 -0
- package/dist/dropdown/dropdown.stories.svelte.d.ts +23 -0
- package/dist/dropdown/dropdown.svelte +171 -0
- package/dist/dropdown/dropdown.svelte.d.ts +28 -0
- package/dist/error-state/error-state.stories.svelte +18 -0
- package/dist/error-state/error-state.stories.svelte.d.ts +23 -0
- package/dist/error-state/error-state.svelte +33 -0
- package/dist/error-state/error-state.svelte.d.ts +18 -0
- package/dist/float/float.svelte +34 -0
- package/dist/float/float.svelte.d.ts +22 -0
- package/dist/form-item/form-item.svelte +42 -0
- package/dist/form-item/form-item.svelte.d.ts +24 -0
- package/dist/icon/icon.stories.d.ts +25 -0
- package/dist/icon/icon.stories.js +49 -0
- package/dist/icon/icon.svelte +67 -0
- package/dist/icon/icon.svelte.d.ts +22 -0
- package/dist/icon/props.d.ts +2 -0
- package/dist/icon/props.js +1 -0
- package/dist/icons/arrow-circle-left-large.svg +10 -0
- package/dist/icons/arrow-circle-left-medium.svg +3 -0
- package/dist/icons/arrow-circle-left-small.svg +10 -0
- package/dist/icons/bug-large.svg +3 -0
- package/dist/icons/bug-medium.svg +3 -0
- package/dist/icons/bug-small.svg +3 -0
- package/dist/icons/caret-down-large.svg +0 -0
- package/dist/icons/caret-down-medium.svg +3 -0
- package/dist/icons/caret-down-small.svg +3 -0
- package/dist/icons/microsoft-color-large.svg +6 -0
- package/dist/icons/microsoft-color-medium.svg +6 -0
- package/dist/icons/microsoft-color-small.svg +6 -0
- package/dist/icons/user-story-large.svg +8 -0
- package/dist/icons/user-story-medium.svg +8 -0
- package/dist/icons/user-story-small.svg +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/input/input.stories.svelte +28 -0
- package/dist/input/input.stories.svelte.d.ts +23 -0
- package/dist/input/input.svelte +112 -0
- package/dist/input/input.svelte.d.ts +108 -0
- package/dist/progress/progress-ring.stories.svelte +27 -0
- package/dist/progress/progress-ring.stories.svelte.d.ts +28 -0
- package/dist/progress/progress-ring.svelte +78 -0
- package/dist/progress/progress-ring.svelte.d.ts +19 -0
- package/dist/progress/props.d.ts +2 -0
- package/dist/progress/props.js +1 -0
- package/dist/skeleton/skeleton.stories.svelte +22 -0
- package/dist/skeleton/skeleton.stories.svelte.d.ts +30 -0
- package/dist/skeleton/skeleton.svelte +23 -0
- package/dist/skeleton/skeleton.svelte.d.ts +19 -0
- package/dist/svgs/error-state-dark.svg +26 -0
- package/dist/svgs/error-state-light.svg +26 -0
- package/dist/svgs/zero-state-dark.svg +9 -0
- package/dist/svgs/zero-state-light.svg +9 -0
- package/dist/tokens/_variables.css +422 -0
- package/dist/utilities/wait-for-elm.d.ts +1 -0
- package/dist/utilities/wait-for-elm.js +17 -0
- package/dist/zero-state/zero-state.stories.svelte +18 -0
- package/dist/zero-state/zero-state.stories.svelte.d.ts +23 -0
- package/dist/zero-state/zero-state.svelte +34 -0
- package/dist/zero-state/zero-state.svelte.d.ts +18 -0
- package/package.json +97 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
import ProgressRing from "../progress/progress-ring.svelte";
|
|
3
|
+
export let kind = "filled";
|
|
4
|
+
export let variant = "primary";
|
|
5
|
+
export let size = "default";
|
|
6
|
+
export let fullWidth = false;
|
|
7
|
+
export let loading = false;
|
|
8
|
+
const dispatch = createEventDispatcher();
|
|
9
|
+
function onClick(event) {
|
|
10
|
+
dispatch("click", event);
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<button
|
|
15
|
+
{...$$restProps}
|
|
16
|
+
class:loading
|
|
17
|
+
class:isFilled={kind === 'filled'}
|
|
18
|
+
class:isOutlined={kind === 'outlined'}
|
|
19
|
+
class:isPrimary={variant === 'primary'}
|
|
20
|
+
class:isSecondary={variant === 'secondary'}
|
|
21
|
+
class:isTertiary={variant === 'tertiary'}
|
|
22
|
+
class:isDefaultSize={size === 'default'}
|
|
23
|
+
class:isSmall={size === 'small'}
|
|
24
|
+
class:fullWidth
|
|
25
|
+
on:click={onClick}
|
|
26
|
+
class={`aura-button ${$$restProps.class}`}
|
|
27
|
+
>
|
|
28
|
+
<div class="content">
|
|
29
|
+
<slot name="icon-before" />
|
|
30
|
+
<slot>Aura Button</slot>
|
|
31
|
+
{#if loading}
|
|
32
|
+
<ProgressRing {variant} />
|
|
33
|
+
{/if}
|
|
34
|
+
</div>
|
|
35
|
+
</button>
|
|
36
|
+
|
|
37
|
+
<style>.aura-button {
|
|
38
|
+
--icon-color: var(--text-color);
|
|
39
|
+
flex-shrink: 0;
|
|
40
|
+
padding: var(--padding-vertical) var(--padding-horizontal);
|
|
41
|
+
font: var(--font-size);
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
border-radius: var(--aura-button-border-radius);
|
|
44
|
+
outline: var(--border);
|
|
45
|
+
outline-offset: calc(var(--border-size) * -1px);
|
|
46
|
+
border: 0;
|
|
47
|
+
outline-color: var(--border-color);
|
|
48
|
+
background-color: var(--bg);
|
|
49
|
+
color: var(--text-color);
|
|
50
|
+
}
|
|
51
|
+
.aura-button.loading {
|
|
52
|
+
padding-right: 22px;
|
|
53
|
+
}
|
|
54
|
+
.aura-button.loading :global(.aura-progress-ring) {
|
|
55
|
+
width: 24px;
|
|
56
|
+
height: 24px;
|
|
57
|
+
}
|
|
58
|
+
.aura-button.loading.isSmall {
|
|
59
|
+
padding-right: 12px;
|
|
60
|
+
}
|
|
61
|
+
.aura-button.loading.isSmall :global(.aura-progress-ring) {
|
|
62
|
+
width: 14px;
|
|
63
|
+
height: 14px;
|
|
64
|
+
}
|
|
65
|
+
.aura-button.isFilled.isPrimary {
|
|
66
|
+
--bg: var(--aura-primary-30);
|
|
67
|
+
--bg-hover: var(--aura-primary-40);
|
|
68
|
+
--bg-active: var(--aura-primary-20);
|
|
69
|
+
--text-color: var(--aura-font-color);
|
|
70
|
+
--text-hover-opacity: 0.5;
|
|
71
|
+
}
|
|
72
|
+
.aura-button.isFilled.isSecondary {
|
|
73
|
+
--bg: var(--aura-secondary-30);
|
|
74
|
+
--bg-hover: var(--aura-secondary-40);
|
|
75
|
+
--bg-active: var(--aura-secondary-20);
|
|
76
|
+
--text-color: var(--aura-white-smoke);
|
|
77
|
+
--text-hover-opacity: 1;
|
|
78
|
+
}
|
|
79
|
+
.aura-button.isFilled.isTertiary {
|
|
80
|
+
--bg: var(--aura-tertiary-60);
|
|
81
|
+
--bg-hover: var(--aura-tertiary-70);
|
|
82
|
+
--bg-active: var(--aura-tertiary-30);
|
|
83
|
+
--text-color: var(--aura-white-smoke);
|
|
84
|
+
--text-hover-opacity: 1;
|
|
85
|
+
}
|
|
86
|
+
.aura-button.isOutlined {
|
|
87
|
+
--bg: none;
|
|
88
|
+
--bg-hover: none;
|
|
89
|
+
--bg-active: none;
|
|
90
|
+
--text-hover-opacity: 0.4;
|
|
91
|
+
--border-size: 1px;
|
|
92
|
+
--border: var(--border-size) solid;
|
|
93
|
+
--text-color: var(--aura-font-color);
|
|
94
|
+
}
|
|
95
|
+
.aura-button.isOutlined.isPrimary {
|
|
96
|
+
--border-color: var(--aura-primary-40);
|
|
97
|
+
--border-hover-color: var(--aura-primary-50);
|
|
98
|
+
--border-active-color: var(--aura-primary-20);
|
|
99
|
+
}
|
|
100
|
+
.aura-button.isOutlined.isSecondary {
|
|
101
|
+
--border-color: var(--aura-secondary-20);
|
|
102
|
+
--border-hover-color: var(--aura-secondary-30);
|
|
103
|
+
--border-active-color: var(--aura-secondary-10);
|
|
104
|
+
}
|
|
105
|
+
.aura-button.isOutlined.isTertiary {
|
|
106
|
+
--border-color: var(--aura-tertiary-60);
|
|
107
|
+
--border-hover-color: var(--aura-tertiary-70);
|
|
108
|
+
--border-active-color: var(--aura-tertiary-30);
|
|
109
|
+
}
|
|
110
|
+
.aura-button.isDefaultSize {
|
|
111
|
+
--gap: var(--aura-button-default-padding-vertical);
|
|
112
|
+
--padding-horizontal: var(--aura-button-default-padding-horizontal);
|
|
113
|
+
--padding-vertical: var(--aura-button-default-padding-vertical);
|
|
114
|
+
--font-size: var(--aura-button-default);
|
|
115
|
+
}
|
|
116
|
+
.aura-button.isSmall {
|
|
117
|
+
--gap: var(--aura-button-small-padding-vertical);
|
|
118
|
+
--padding-horizontal: var(--aura-button-small-padding-horizontal);
|
|
119
|
+
--padding-vertical: var(--aura-button-small-padding-vertical);
|
|
120
|
+
--font-size: var(--aura-button-small);
|
|
121
|
+
}
|
|
122
|
+
.aura-button.fullWidth {
|
|
123
|
+
width: 100%;
|
|
124
|
+
}
|
|
125
|
+
.aura-button.fullWidth .content {
|
|
126
|
+
justify-content: center;
|
|
127
|
+
}
|
|
128
|
+
.aura-button .content {
|
|
129
|
+
display: flex;
|
|
130
|
+
gap: var(--gap);
|
|
131
|
+
align-items: center;
|
|
132
|
+
}
|
|
133
|
+
.aura-button:hover {
|
|
134
|
+
background-color: var(--bg-hover);
|
|
135
|
+
outline-color: var(--border-hover-color);
|
|
136
|
+
}
|
|
137
|
+
.aura-button:active {
|
|
138
|
+
background-color: var(--bg-active);
|
|
139
|
+
outline-color: var(--border-active-color);
|
|
140
|
+
}
|
|
141
|
+
.aura-button:active .content {
|
|
142
|
+
opacity: var(--text-hover-opacity);
|
|
143
|
+
}</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type * as Props from './props';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
kind?: Props.ButtonKind;
|
|
7
|
+
variant?: any;
|
|
8
|
+
size?: any;
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
click: CustomEvent<{}>;
|
|
14
|
+
} & {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {
|
|
18
|
+
'icon-before': {};
|
|
19
|
+
default: {};
|
|
20
|
+
};
|
|
21
|
+
exports?: undefined;
|
|
22
|
+
bindings?: undefined;
|
|
23
|
+
};
|
|
24
|
+
export type ButtonProps = typeof __propDef.props;
|
|
25
|
+
export type ButtonEvents = typeof __propDef.events;
|
|
26
|
+
export type ButtonSlots = typeof __propDef.slots;
|
|
27
|
+
export default class Button extends SvelteComponent<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const buttonKinds: readonly ["filled", "outlined"];
|
|
2
|
+
export type ButtonKind = (typeof buttonKinds)[number];
|
|
3
|
+
export declare const buttonVariants: readonly ["primary", "secondary", "tertiary"];
|
|
4
|
+
export type ButtonVariants = (typeof buttonVariants)[number];
|
|
5
|
+
export declare const buttonSizes: readonly ["default", "small"];
|
|
6
|
+
export type ButtonSizes = (typeof buttonSizes)[number];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script context="module">import "../../app.scss";
|
|
2
|
+
import Container from "./container.svelte";
|
|
3
|
+
import { containerKinds, containerVariants } from "./props.ts";
|
|
4
|
+
export const meta = {
|
|
5
|
+
title: "AURA/Container",
|
|
6
|
+
component: Container,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {
|
|
9
|
+
kind: { control: "select", options: containerKinds },
|
|
10
|
+
variant: { control: "select", options: containerVariants }
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<script>import { Story, Template } from "@storybook/addon-svelte-csf";
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Template let:args>
|
|
19
|
+
<Container {...args}>Aura Container</Container>
|
|
20
|
+
</Template>
|
|
21
|
+
|
|
22
|
+
<Story
|
|
23
|
+
name="Filled Flat"
|
|
24
|
+
args={{
|
|
25
|
+
kind: 'filled',
|
|
26
|
+
variant: 'flat'
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<Story
|
|
31
|
+
name="Filled Elevated"
|
|
32
|
+
args={{
|
|
33
|
+
kind: 'filled',
|
|
34
|
+
variant: 'elevated'
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
<Story
|
|
39
|
+
name="Outlined Flat"
|
|
40
|
+
args={{
|
|
41
|
+
kind: 'outlined',
|
|
42
|
+
variant: 'flat'
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
|
|
46
|
+
<Story
|
|
47
|
+
name="Outlined Elevated"
|
|
48
|
+
args={{
|
|
49
|
+
kind: 'outlined',
|
|
50
|
+
variant: 'elevated'
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import '../../app.scss';
|
|
3
|
+
export declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof Container;
|
|
6
|
+
tags: string[];
|
|
7
|
+
argTypes: {
|
|
8
|
+
kind: {
|
|
9
|
+
control: string;
|
|
10
|
+
options: readonly ["filled", "outlined"];
|
|
11
|
+
};
|
|
12
|
+
variant: {
|
|
13
|
+
control: string;
|
|
14
|
+
options: readonly ["flat", "elevated"];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
declare const __propDef: {
|
|
19
|
+
props: Record<string, never>;
|
|
20
|
+
events: {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
};
|
|
23
|
+
slots: {};
|
|
24
|
+
exports?: {} | undefined;
|
|
25
|
+
bindings?: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
export type ContainerProps = typeof __propDef.props;
|
|
28
|
+
export type ContainerEvents = typeof __propDef.events;
|
|
29
|
+
export type ContainerSlots = typeof __propDef.slots;
|
|
30
|
+
export default class Container extends SvelteComponent<ContainerProps, ContainerEvents, ContainerSlots> {
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script>export let kind = "filled";
|
|
2
|
+
export let variant = "flat";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div
|
|
6
|
+
{...$$restProps}
|
|
7
|
+
class:isFilled={kind === 'filled'}
|
|
8
|
+
class:isOutlined={kind === 'outlined'}
|
|
9
|
+
class:isFlat={variant === 'flat'}
|
|
10
|
+
class:isElevated={variant === 'elevated'}
|
|
11
|
+
class={`aura-container ${$$restProps.class}`}
|
|
12
|
+
>
|
|
13
|
+
<slot />
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<style>.aura-container {
|
|
17
|
+
text-align: center;
|
|
18
|
+
border: 1px solid var(--aura-container-border-color);
|
|
19
|
+
border-radius: var(--aura-container-border-radius);
|
|
20
|
+
background-color: var(--bg);
|
|
21
|
+
box-shadow: var(--box-shadow);
|
|
22
|
+
padding: var(--aura-container-padding);
|
|
23
|
+
}
|
|
24
|
+
.aura-container.isFilled {
|
|
25
|
+
--bg: var(--aura-container-background);
|
|
26
|
+
}
|
|
27
|
+
.aura-container.isOutlined {
|
|
28
|
+
--bg: var(--aura-background);
|
|
29
|
+
}
|
|
30
|
+
.aura-container.isFlat {
|
|
31
|
+
--box-shadow: none;
|
|
32
|
+
}
|
|
33
|
+
.aura-container.isElevated {
|
|
34
|
+
--box-shadow: var(--aura-container-drop-shadow);
|
|
35
|
+
}</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type * as Props from './props';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
kind?: Props.ContainerKind;
|
|
7
|
+
variant?: Props.ContainerVariants;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {
|
|
13
|
+
default: {};
|
|
14
|
+
};
|
|
15
|
+
exports?: undefined;
|
|
16
|
+
bindings?: undefined;
|
|
17
|
+
};
|
|
18
|
+
export type ContainerProps = typeof __propDef.props;
|
|
19
|
+
export type ContainerEvents = typeof __propDef.events;
|
|
20
|
+
export type ContainerSlots = typeof __propDef.slots;
|
|
21
|
+
export default class Container extends SvelteComponent<ContainerProps, ContainerEvents, ContainerSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const containerKinds: readonly ["filled", "outlined"];
|
|
2
|
+
export type ContainerKind = (typeof containerKinds)[number];
|
|
3
|
+
export declare const containerVariants: readonly ["flat", "elevated"];
|
|
4
|
+
export type ContainerVariants = (typeof containerVariants)[number];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default function clickOutside(node, handler) {
|
|
2
|
+
let lastHandler;
|
|
3
|
+
const attachHandler = (handler) => {
|
|
4
|
+
if (lastHandler)
|
|
5
|
+
document.removeEventListener('click', lastHandler);
|
|
6
|
+
lastHandler = (e) => {
|
|
7
|
+
const path = e.composedPath();
|
|
8
|
+
if (path.includes(node))
|
|
9
|
+
return;
|
|
10
|
+
if (handler)
|
|
11
|
+
handler(e);
|
|
12
|
+
};
|
|
13
|
+
document.addEventListener('click', lastHandler);
|
|
14
|
+
};
|
|
15
|
+
attachHandler(handler);
|
|
16
|
+
return {
|
|
17
|
+
destroy() {
|
|
18
|
+
document.removeEventListener('click', lastHandler);
|
|
19
|
+
},
|
|
20
|
+
update(handler) {
|
|
21
|
+
attachHandler(handler);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script context="module">import "../../app.scss";
|
|
2
|
+
import Dropdown from "./dropdown.svelte";
|
|
3
|
+
import Button from "../button/button.svelte";
|
|
4
|
+
export const meta = {
|
|
5
|
+
title: "AURA/Dropdown",
|
|
6
|
+
component: Dropdown,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {}
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script>import { Story, Template } from "@storybook/addon-svelte-csf";
|
|
13
|
+
let valueForControlsStory = "Option 1";
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Template let:args>
|
|
17
|
+
<div style="height: 160px; max-width: 400px; margin: 0 auto;">
|
|
18
|
+
<Dropdown {...args}>
|
|
19
|
+
<aura-option value="Option 1">Option 1</aura-option>
|
|
20
|
+
<aura-option value="Option 2">Option 2</aura-option>
|
|
21
|
+
<aura-option>Option 3</aura-option>
|
|
22
|
+
</Dropdown>
|
|
23
|
+
</div>
|
|
24
|
+
</Template>
|
|
25
|
+
|
|
26
|
+
<Story height="500px" name="Default dropdown" />
|
|
27
|
+
|
|
28
|
+
<Story name="Custom Placeholder">
|
|
29
|
+
<div style="height: 160px; max-width: 400px; margin: 0 auto;">
|
|
30
|
+
<Dropdown>
|
|
31
|
+
<span slot="placeholder">Custom placeholder...</span>
|
|
32
|
+
<aura-option value="Option 1">Option 1</aura-option>
|
|
33
|
+
<aura-option value="Option 2">Option 2</aura-option>
|
|
34
|
+
<aura-option>Option 3</aura-option>
|
|
35
|
+
</Dropdown>
|
|
36
|
+
</div>
|
|
37
|
+
</Story>
|
|
38
|
+
|
|
39
|
+
<Story name="External Value Controls">
|
|
40
|
+
<div style="height: 160px; max-width: 400px; margin: 0 auto;">
|
|
41
|
+
<div style="display: flex; gap: 10px;">
|
|
42
|
+
<Dropdown
|
|
43
|
+
style="flex: 1"
|
|
44
|
+
on:change={(evt) => {
|
|
45
|
+
valueForControlsStory = evt.detail.value;
|
|
46
|
+
}}
|
|
47
|
+
currentValue={valueForControlsStory}
|
|
48
|
+
>
|
|
49
|
+
<aura-option value="Option 1">Option 1</aura-option>
|
|
50
|
+
<aura-option value="Option 2">Option 2</aura-option>
|
|
51
|
+
<aura-option>Option 3</aura-option>
|
|
52
|
+
</Dropdown>
|
|
53
|
+
<Button size="small" on:click={() => (valueForControlsStory = undefined)}>Clear</Button>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</Story>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import '../../app.scss';
|
|
3
|
+
export declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof Dropdown;
|
|
6
|
+
tags: string[];
|
|
7
|
+
argTypes: {};
|
|
8
|
+
};
|
|
9
|
+
declare const __propDef: {
|
|
10
|
+
props: Record<string, never>;
|
|
11
|
+
events: {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
};
|
|
14
|
+
slots: {};
|
|
15
|
+
exports?: {} | undefined;
|
|
16
|
+
bindings?: string | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type DropdownProps = typeof __propDef.props;
|
|
19
|
+
export type DropdownEvents = typeof __propDef.events;
|
|
20
|
+
export type DropdownSlots = typeof __propDef.slots;
|
|
21
|
+
export default class Dropdown extends SvelteComponent<DropdownProps, DropdownEvents, DropdownSlots> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<script>import Icon from "../icon/icon.svelte";
|
|
2
|
+
import Float from "../float/float.svelte";
|
|
3
|
+
import { createEventDispatcher } from "svelte";
|
|
4
|
+
import FormItem from "../form-item/form-item.svelte";
|
|
5
|
+
import clickOutside from "../directives/click-outside";
|
|
6
|
+
import { waitForElm } from "../utilities/wait-for-elm";
|
|
7
|
+
const dispatch = createEventDispatcher();
|
|
8
|
+
export let isOpen = false;
|
|
9
|
+
export let isFocused = false;
|
|
10
|
+
export let currentValue;
|
|
11
|
+
let target;
|
|
12
|
+
let menu;
|
|
13
|
+
$: minWidth = isOpen !== void 0 && target?.getBoundingClientRect().width || 0;
|
|
14
|
+
const onClick = () => {
|
|
15
|
+
isOpen = !isOpen;
|
|
16
|
+
};
|
|
17
|
+
const handleBlur = () => {
|
|
18
|
+
isOpen = false;
|
|
19
|
+
isFocused = false;
|
|
20
|
+
};
|
|
21
|
+
const handleFocus = () => {
|
|
22
|
+
isFocused = true;
|
|
23
|
+
};
|
|
24
|
+
$: menuItems = Array.from(
|
|
25
|
+
menu?.querySelector(".aura-menu slot")?.assignedElements()?.filter((element) => ["AURA-OPTION"].includes(element.tagName)) ?? menu?.querySelectorAll(".aura-menu > :is(aura-option)") ?? []
|
|
26
|
+
);
|
|
27
|
+
$: {
|
|
28
|
+
for (const menuItem of menuItems) {
|
|
29
|
+
menuItem.setAttribute("tabindex", "0");
|
|
30
|
+
if (menuItem.tagName === "AURA-OPTION") {
|
|
31
|
+
menuItem.setAttribute("role", "option");
|
|
32
|
+
if (currentValue === getValue(menuItem)) {
|
|
33
|
+
menuItem.setAttribute("aria-selected", "");
|
|
34
|
+
} else menuItem.removeAttribute("aria-selected");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const getValue = (e) => {
|
|
39
|
+
return e.getAttribute("value") ?? e["value"] ?? e.textContent;
|
|
40
|
+
};
|
|
41
|
+
const selectMenuItem = (e) => {
|
|
42
|
+
const item = menuItems.find((item2) => e.composedPath().includes(item2));
|
|
43
|
+
if (item.tagName === "AURA-OPTION") {
|
|
44
|
+
const value = getValue(item);
|
|
45
|
+
if (!$$props.currentValue) {
|
|
46
|
+
currentValue = value;
|
|
47
|
+
}
|
|
48
|
+
dispatch("change", {
|
|
49
|
+
value
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const handleOpenOnArrowKeyPress = async (evt) => {
|
|
54
|
+
isOpen = true;
|
|
55
|
+
await waitForElm(".aura-menu");
|
|
56
|
+
handleSelectMenuKeyboardActions(evt);
|
|
57
|
+
};
|
|
58
|
+
const handleArrowDownKeyPress = (evt) => {
|
|
59
|
+
evt.preventDefault();
|
|
60
|
+
let nextOption = menu.querySelector("aura-option[aria-selected] + aura-option");
|
|
61
|
+
if (!nextOption) {
|
|
62
|
+
nextOption = menu.querySelector("aura-option:first-of-type");
|
|
63
|
+
}
|
|
64
|
+
nextOption.click();
|
|
65
|
+
};
|
|
66
|
+
const handleArrowUpKeyPress = (evt) => {
|
|
67
|
+
evt.preventDefault();
|
|
68
|
+
let nextOption = menu.querySelector("aura-option:has( + aura-option[aria-selected])");
|
|
69
|
+
if (!nextOption) {
|
|
70
|
+
nextOption = menu.querySelector("aura-option:last-of-type");
|
|
71
|
+
}
|
|
72
|
+
nextOption.click();
|
|
73
|
+
};
|
|
74
|
+
const handleSelectMenuKeyboardActions = async (evt) => {
|
|
75
|
+
if (evt.code === "Escape" || evt.code === "Tab") {
|
|
76
|
+
handleBlur();
|
|
77
|
+
} else if (!isOpen && (evt.code === "ArrowDown" || evt.code === "ArrowUp")) {
|
|
78
|
+
await handleOpenOnArrowKeyPress(evt);
|
|
79
|
+
} else if (evt.code === "ArrowDown") {
|
|
80
|
+
handleArrowDownKeyPress(evt);
|
|
81
|
+
} else if (evt.code === "ArrowUp") {
|
|
82
|
+
handleArrowUpKeyPress(evt);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const handleMenuOptionSelectEvent = (evt) => {
|
|
86
|
+
selectMenuItem(evt);
|
|
87
|
+
if (evt.pointerId !== -1) handleBlur();
|
|
88
|
+
};
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<div
|
|
92
|
+
{...$$restProps}
|
|
93
|
+
class={`aura-dropdown ${$$restProps.class}`}
|
|
94
|
+
bind:this={target}
|
|
95
|
+
tabindex="-1"
|
|
96
|
+
role="button"
|
|
97
|
+
use:clickOutside={(isOpen || isFocused) && handleBlur}
|
|
98
|
+
on:keydown|stopPropagation={handleSelectMenuKeyboardActions}
|
|
99
|
+
on:click|stopPropagation={onClick}
|
|
100
|
+
>
|
|
101
|
+
<FormItem showFocusOutline={isOpen || isFocused}>
|
|
102
|
+
<button class="trigger" on:focus={handleFocus}>
|
|
103
|
+
{#if currentValue}
|
|
104
|
+
{currentValue}
|
|
105
|
+
{:else}
|
|
106
|
+
<slot name="placeholder">select...</slot>
|
|
107
|
+
{/if}
|
|
108
|
+
<Icon name="caret-down" size="small" />
|
|
109
|
+
</button>
|
|
110
|
+
</FormItem>
|
|
111
|
+
{#if isOpen}
|
|
112
|
+
<Float {target}>
|
|
113
|
+
<div
|
|
114
|
+
bind:this={menu}
|
|
115
|
+
role="menu"
|
|
116
|
+
tabindex="-1"
|
|
117
|
+
class="aura-menu"
|
|
118
|
+
style:--aura-menu-control-width={`${minWidth}px`}
|
|
119
|
+
on:keypress={handleSelectMenuKeyboardActions}
|
|
120
|
+
on:click|stopPropagation={handleMenuOptionSelectEvent}
|
|
121
|
+
>
|
|
122
|
+
<slot />
|
|
123
|
+
</div>
|
|
124
|
+
</Float>
|
|
125
|
+
{/if}
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<style>.aura-dropdown button {
|
|
129
|
+
all: unset;
|
|
130
|
+
width: 100%;
|
|
131
|
+
display: flex;
|
|
132
|
+
justify-content: space-between;
|
|
133
|
+
align-items: center;
|
|
134
|
+
}
|
|
135
|
+
.aura-dropdown button :global(.icon) {
|
|
136
|
+
--icon-color: var(--aura-dropdown-open-icon-color);
|
|
137
|
+
margin-top: 2px;
|
|
138
|
+
margin-left: -5px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.aura-menu {
|
|
142
|
+
border-radius: var(--aura-menu-border-radius);
|
|
143
|
+
box-shadow: var(--aura-menu-drop-shadow);
|
|
144
|
+
border: 1px solid var(--aura-menu-border-color);
|
|
145
|
+
background-color: var(--aura-menu-background-color);
|
|
146
|
+
min-height: 25px;
|
|
147
|
+
margin-top: var(--aura-menu-margin-top);
|
|
148
|
+
width: var(--aura-menu-control-width);
|
|
149
|
+
display: flex;
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
padding: var(--aura-menu-padding);
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
gap: var(--aura-menu-padding);
|
|
155
|
+
}
|
|
156
|
+
.aura-menu :global(aura-option) {
|
|
157
|
+
width: 100%;
|
|
158
|
+
border-radius: var(--aura-dropdown-option-border-radius);
|
|
159
|
+
padding: var(--aura-dropdown-option-padding);
|
|
160
|
+
box-sizing: border-box;
|
|
161
|
+
user-select: none;
|
|
162
|
+
color: var(--aura-light-font-color);
|
|
163
|
+
}
|
|
164
|
+
.aura-menu :global(aura-option):hover {
|
|
165
|
+
background: var(--aura-dropdown-option-hover-background);
|
|
166
|
+
}
|
|
167
|
+
.aura-menu :global(aura-option:active),
|
|
168
|
+
.aura-menu :global(aura-option[aria-selected]) {
|
|
169
|
+
background: var(--aura-dropdown-option-active-background);
|
|
170
|
+
color: var(--aura-dropdown-option-active-color);
|
|
171
|
+
}</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
isFocused?: boolean;
|
|
7
|
+
currentValue: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
change: CustomEvent<{
|
|
11
|
+
value: string | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
} & {
|
|
14
|
+
[evt: string]: CustomEvent<any>;
|
|
15
|
+
};
|
|
16
|
+
slots: {
|
|
17
|
+
placeholder: {};
|
|
18
|
+
default: {};
|
|
19
|
+
};
|
|
20
|
+
exports?: undefined;
|
|
21
|
+
bindings?: undefined;
|
|
22
|
+
};
|
|
23
|
+
export type DropdownProps = typeof __propDef.props;
|
|
24
|
+
export type DropdownEvents = typeof __propDef.events;
|
|
25
|
+
export type DropdownSlots = typeof __propDef.slots;
|
|
26
|
+
export default class Dropdown extends SvelteComponent<DropdownProps, DropdownEvents, DropdownSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script context="module">import "../../app.scss";
|
|
2
|
+
import ErrorState from "./error-state.svelte";
|
|
3
|
+
export const meta = {
|
|
4
|
+
title: "AURA/Error State",
|
|
5
|
+
component: ErrorState,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
argTypes: {}
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script>import { Story, Template } from "@storybook/addon-svelte-csf";
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Template>
|
|
15
|
+
<ErrorState>An unexpected error occurred, <u>try again?</u></ErrorState>
|
|
16
|
+
</Template>
|
|
17
|
+
|
|
18
|
+
<Story name="Default Error State" />
|