@axel669/zephyr 0.1.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/LICENSE +21 -0
- package/package.json +32 -0
- package/readme.md +44 -0
- package/src/avatar.svelte +54 -0
- package/src/badge.svelte +40 -0
- package/src/button.svelte +80 -0
- package/src/chip.svelte +53 -0
- package/src/composed/data-table.svelte +150 -0
- package/src/composed/entry-button.svelte +66 -0
- package/src/composed/toast/message.svelte +44 -0
- package/src/composed/toast.svelte +108 -0
- package/src/dialog.svelte +53 -0
- package/src/drawer.svelte +121 -0
- package/src/flex.svelte +57 -0
- package/src/grid.svelte +66 -0
- package/src/handler$.mjs +68 -0
- package/src/icon.svelte +34 -0
- package/src/index.mjs +85 -0
- package/src/inline-dialog.svelte +23 -0
- package/src/input/area.svelte +97 -0
- package/src/input/elems.mjs +7 -0
- package/src/input/email.svelte +102 -0
- package/src/input/file.svelte +81 -0
- package/src/input/number.svelte +102 -0
- package/src/input/password.svelte +99 -0
- package/src/input/search.svelte +102 -0
- package/src/input/text.svelte +102 -0
- package/src/link.svelte +62 -0
- package/src/modal.svelte +68 -0
- package/src/notification.svelte +57 -0
- package/src/paper.svelte +114 -0
- package/src/popover.svelte +60 -0
- package/src/progress.svelte +60 -0
- package/src/radio.svelte +82 -0
- package/src/screen.svelte +69 -0
- package/src/select.svelte +121 -0
- package/src/table.svelte +69 -0
- package/src/tabs.svelte +77 -0
- package/src/text.svelte +49 -0
- package/src/titlebar.svelte +69 -0
- package/src/toaster.svelte +42 -0
- package/src/toggle.svelte +90 -0
- package/src/tooltip.svelte +45 -0
- package/src/vars.mjs +61 -0
- package/src/wsx.mjs +45 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Containers/Dialog
|
|
4
|
+
|
|
5
|
+
# Dialog
|
|
6
|
+
|
|
7
|
+
A modal container for creating dialogs. The Dialog component is a modal
|
|
8
|
+
element that uses a Paper element for the layout of content. All props and
|
|
9
|
+
slots for the Dialog are passed to the underlying Paper component.
|
|
10
|
+
|
|
11
|
+
The Dialog component is used as a wrapper for content and is used in
|
|
12
|
+
conjunction with the Modal component to be controlled on screen.
|
|
13
|
+
|
|
14
|
+
## Props
|
|
15
|
+
See the Paper component props.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
`cool-dialog.svelte`
|
|
19
|
+
```svelte
|
|
20
|
+
<Dialog>
|
|
21
|
+
<Titlebar slot="header">
|
|
22
|
+
<Text slot="title" title>
|
|
23
|
+
Some Title
|
|
24
|
+
</Text>
|
|
25
|
+
</Titlebar>
|
|
26
|
+
|
|
27
|
+
<span>Content</span>
|
|
28
|
+
</Dialog>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`app.svelte`
|
|
32
|
+
```svelte
|
|
33
|
+
<Modal component={CoolDialog} />
|
|
34
|
+
<EntryButton this={Modal} component={CoolDialog}>
|
|
35
|
+
Open Cool Dialog
|
|
36
|
+
</EntryButton>
|
|
37
|
+
```
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import { fade } from "svelte/transition"
|
|
41
|
+
|
|
42
|
+
import wsx from "./wsx.mjs"
|
|
43
|
+
|
|
44
|
+
import Paper from "./paper.svelte"
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<wind-wrapper transition:fade={{ duration: 200 }} ws-x="@dialog grid">
|
|
48
|
+
<Paper {...$$props}>
|
|
49
|
+
<slot name="header" slot="header" />
|
|
50
|
+
<slot />
|
|
51
|
+
<slot name="footer" slot="footer" />
|
|
52
|
+
</Paper>
|
|
53
|
+
</wind-wrapper>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script context="module">
|
|
2
|
+
const defs = {
|
|
3
|
+
select: {
|
|
4
|
+
"@select": true,
|
|
5
|
+
"w-min": "35vw",
|
|
6
|
+
grid: true,
|
|
7
|
+
over: "hidden"
|
|
8
|
+
},
|
|
9
|
+
menu: {
|
|
10
|
+
"@menu": true,
|
|
11
|
+
w: "15vw",
|
|
12
|
+
},
|
|
13
|
+
action: {
|
|
14
|
+
"@action": true,
|
|
15
|
+
w: "15vw",
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const css = {
|
|
19
|
+
select: (t, u) => `
|
|
20
|
+
transform: translateY(-${u * 100}%);
|
|
21
|
+
opacity: ${t};
|
|
22
|
+
`,
|
|
23
|
+
menu: (t, u) => `
|
|
24
|
+
transform: translateX(-${u * 100}%);
|
|
25
|
+
opacity: ${t};
|
|
26
|
+
`,
|
|
27
|
+
action: (t, u) => `
|
|
28
|
+
transform: translateX(${u * 100}%);
|
|
29
|
+
opacity: ${t};
|
|
30
|
+
`
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
/*md
|
|
36
|
+
[@] Components/Containers/Drawer
|
|
37
|
+
|
|
38
|
+
# Drawer
|
|
39
|
+
|
|
40
|
+
A modal container for creating dialogs. The Dialog component is a modal
|
|
41
|
+
element that uses a Paper element for the layout of content. All extra props
|
|
42
|
+
and slots for the Drawer are passed to the underlying Paper component.
|
|
43
|
+
|
|
44
|
+
The Drawer component is used as a wrapper for content and is used in
|
|
45
|
+
conjunction with the Modal component to be controlled on screen.
|
|
46
|
+
|
|
47
|
+
## Props
|
|
48
|
+
- ### close `function`
|
|
49
|
+
If passed, this function will be called when the user clicks in the
|
|
50
|
+
empty area outside of the drawer contents.
|
|
51
|
+
- ### height `string`
|
|
52
|
+
Sets the height of the select drawer, no effect for menu and action
|
|
53
|
+
drawers which default to full height of the window.
|
|
54
|
+
- ### type `string`
|
|
55
|
+
The type of drawer. Default is "menu"
|
|
56
|
+
- #### "menu"
|
|
57
|
+
Makes a drawer that slides in on the left side of the screen
|
|
58
|
+
- #### "action"
|
|
59
|
+
Makes a drawer that slides in on the right side of the screen
|
|
60
|
+
- #### "select"
|
|
61
|
+
Makes a drawer that is centered horizontally and slides in from
|
|
62
|
+
the top of the screen
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
`cool-drawer.svelte`
|
|
66
|
+
```svelte
|
|
67
|
+
<Drawer>
|
|
68
|
+
<Titlebar slot="header">
|
|
69
|
+
<Text slot="title" title>
|
|
70
|
+
Some Title
|
|
71
|
+
</Text>
|
|
72
|
+
</Titlebar>
|
|
73
|
+
|
|
74
|
+
<span>Content</span>
|
|
75
|
+
</Drawer>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`app.svelte`
|
|
79
|
+
```svelte
|
|
80
|
+
<Modal component={CoolDrawer} />
|
|
81
|
+
<EntryButton this={Modal} component={CoolDrawer}>
|
|
82
|
+
Open Cool Dialog
|
|
83
|
+
</EntryButton>
|
|
84
|
+
```
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
import { fly } from "svelte/transition"
|
|
88
|
+
|
|
89
|
+
import wsx from "./wsx.mjs"
|
|
90
|
+
|
|
91
|
+
import Paper from "./paper.svelte"
|
|
92
|
+
|
|
93
|
+
export let height
|
|
94
|
+
export let type = "menu"
|
|
95
|
+
|
|
96
|
+
const slide = (node, options) => ({
|
|
97
|
+
delay: 0,
|
|
98
|
+
duration: 200,
|
|
99
|
+
css: css[type],
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const animation = {
|
|
103
|
+
duration: 200
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
$: container = {
|
|
107
|
+
...defs[type],
|
|
108
|
+
h: (type === "select") ? height : "100%",
|
|
109
|
+
grid: true,
|
|
110
|
+
}
|
|
111
|
+
</script>
|
|
112
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
113
|
+
<wind-drawer-container use:wsx={container} on:click|stopPropagation>
|
|
114
|
+
<wind-transition transition:slide ws-x="grid">
|
|
115
|
+
<Paper {...$$restProps}>
|
|
116
|
+
<slot name="header" slot="header" />
|
|
117
|
+
<slot />
|
|
118
|
+
<slot name="footer" slot="footer" />
|
|
119
|
+
</Paper>
|
|
120
|
+
</wind-transition>
|
|
121
|
+
</wind-drawer-container>
|
package/src/flex.svelte
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Containers/Flex
|
|
4
|
+
|
|
5
|
+
# Flex
|
|
6
|
+
|
|
7
|
+
Container that uses flex layout by default with some nice default values.
|
|
8
|
+
|
|
9
|
+
## Base
|
|
10
|
+
[Windstorm Flex](https://axel669.github.io/lib.windstorm/#components-flex)
|
|
11
|
+
|
|
12
|
+
## Props
|
|
13
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
14
|
+
are supported.
|
|
15
|
+
|
|
16
|
+
- ### direction `string`
|
|
17
|
+
Sets `fl-dir`
|
|
18
|
+
- ### pad `string`
|
|
19
|
+
Sets `p`
|
|
20
|
+
- ### gap `string`
|
|
21
|
+
Sets `gap`
|
|
22
|
+
- ### cross `string`
|
|
23
|
+
Sets `fl-cr-a`
|
|
24
|
+
- ### main `string`
|
|
25
|
+
Sets `fl-m-a`
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
```svelte
|
|
29
|
+
<Flex cross="stretch">
|
|
30
|
+
<Text>Content</Text>
|
|
31
|
+
<Text>More content</Text>
|
|
32
|
+
<Text>Event more content</Text>
|
|
33
|
+
<Flex>
|
|
34
|
+
```
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
import wsx from "./wsx.mjs"
|
|
38
|
+
|
|
39
|
+
export let direction = false
|
|
40
|
+
export let pad = false
|
|
41
|
+
export let gap = false
|
|
42
|
+
export let cross = "start"
|
|
43
|
+
export let main = "start"
|
|
44
|
+
|
|
45
|
+
$: wind = {
|
|
46
|
+
"fl-dir": direction,
|
|
47
|
+
"fl-cr-a": cross,
|
|
48
|
+
"fl-m-a": main,
|
|
49
|
+
p: pad,
|
|
50
|
+
gap: gap,
|
|
51
|
+
...$$restProps
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<ws-flex use:wsx={wind}>
|
|
56
|
+
<slot />
|
|
57
|
+
</ws-flex>
|
package/src/grid.svelte
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Containers/Grid
|
|
4
|
+
|
|
5
|
+
# Grid
|
|
6
|
+
|
|
7
|
+
Container that uses grid layout by default with some nice default values.
|
|
8
|
+
|
|
9
|
+
## Base
|
|
10
|
+
[Windstorm Grid](https://axel669.github.io/lib.windstorm/#components-grid)
|
|
11
|
+
|
|
12
|
+
## Props
|
|
13
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
14
|
+
are supported.
|
|
15
|
+
|
|
16
|
+
- ### direction `string`
|
|
17
|
+
Sets `gr-dir`
|
|
18
|
+
- ### pad `string`
|
|
19
|
+
Sets `p`
|
|
20
|
+
- ### gap `string`
|
|
21
|
+
Sets `gap`
|
|
22
|
+
- ### cols `string|Array`
|
|
23
|
+
Sets `gr-col`. Accepts either an array of values that are joined by " "
|
|
24
|
+
or a regular string value.
|
|
25
|
+
- ### rows `string|Array`
|
|
26
|
+
Sets `gr-row`. Accepts either an array of values that are joined by " "
|
|
27
|
+
or a regular string value.
|
|
28
|
+
- ### autoCol `string`
|
|
29
|
+
Sets `gr-acol`
|
|
30
|
+
- ### autoRow `string`
|
|
31
|
+
Sets `gr-arow`
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
```svelte
|
|
35
|
+
<Grid cross="stretch">
|
|
36
|
+
<Text>Content</Text>
|
|
37
|
+
<Text>More content</Text>
|
|
38
|
+
<Text>Event more content</Text>
|
|
39
|
+
<Grid>
|
|
40
|
+
```
|
|
41
|
+
*/
|
|
42
|
+
import wsx from "./wsx.mjs"
|
|
43
|
+
|
|
44
|
+
export let direction = false
|
|
45
|
+
export let pad = false
|
|
46
|
+
export let gap = false
|
|
47
|
+
export let cols = null
|
|
48
|
+
export let rows = null
|
|
49
|
+
export let autoCol = false
|
|
50
|
+
export let autoRow = false
|
|
51
|
+
|
|
52
|
+
$: wind = {
|
|
53
|
+
"gr-dir": direction,
|
|
54
|
+
"gr-col": cols?.join?.(" ") ?? cols ?? false,
|
|
55
|
+
"gr-row": rows?.join?.(" ") ?? rows ?? false,
|
|
56
|
+
"gr-acol": autoCol,
|
|
57
|
+
"gr-arow": autoRow,
|
|
58
|
+
p: pad,
|
|
59
|
+
gap: gap,
|
|
60
|
+
...$$restProps
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<ws-grid use:wsx={wind}>
|
|
65
|
+
<slot />
|
|
66
|
+
</ws-grid>
|
package/src/handler$.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*md
|
|
2
|
+
[@] Event Handlers
|
|
3
|
+
|
|
4
|
+
# Event Handlers
|
|
5
|
+
|
|
6
|
+
Zephyr provides a couple of functions to help make event handlers look
|
|
7
|
+
nicer and bind arguments easier.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/*md
|
|
12
|
+
## handler$
|
|
13
|
+
|
|
14
|
+
Wraps a function for currying as an event handler. The curried function does
|
|
15
|
+
not pass the event into final function call.
|
|
16
|
+
|
|
17
|
+
### Usage
|
|
18
|
+
```js
|
|
19
|
+
const clicked = handler$(
|
|
20
|
+
(buttonName) => console.log(buttonName)
|
|
21
|
+
)
|
|
22
|
+
```
|
|
23
|
+
```svelte
|
|
24
|
+
<!-- logs "first" when clicked -->
|
|
25
|
+
<Button on:click={clicked("first")}>
|
|
26
|
+
First
|
|
27
|
+
</Button>
|
|
28
|
+
<!-- logs "second" when clicked -->
|
|
29
|
+
<Button on:click={clicked("second")}>
|
|
30
|
+
Second
|
|
31
|
+
</Button>
|
|
32
|
+
```
|
|
33
|
+
*/
|
|
34
|
+
const handler$ = (func) =>
|
|
35
|
+
(...args) =>
|
|
36
|
+
(_, ...extra) => func(...args, ...extra)
|
|
37
|
+
|
|
38
|
+
/*md
|
|
39
|
+
## eventHandler$
|
|
40
|
+
|
|
41
|
+
Wraps a function for currying as an event handler. Unlike the `handler$`
|
|
42
|
+
function, the event is passed to the curried function.
|
|
43
|
+
|
|
44
|
+
### Usage
|
|
45
|
+
In the following example, "first" is logged each time the first button is
|
|
46
|
+
clicked, and "second" is logged when the second button is clicked. In both
|
|
47
|
+
cases the click event is also logged.
|
|
48
|
+
```js
|
|
49
|
+
const clicked = eventHandler$(
|
|
50
|
+
(event, buttonName) => console.log(event, buttonName)
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
```svelte
|
|
54
|
+
<!-- logs the event and "first" when clicked -->
|
|
55
|
+
<Button on:click={clicked("first")}>
|
|
56
|
+
First
|
|
57
|
+
</Button>
|
|
58
|
+
<!-- logs the event and "second" when clicked -->
|
|
59
|
+
<Button on:click={clicked("second")}>
|
|
60
|
+
Second
|
|
61
|
+
</Button>
|
|
62
|
+
```
|
|
63
|
+
*/
|
|
64
|
+
const eventHandler$ = (func) =>
|
|
65
|
+
(...args) =>
|
|
66
|
+
(...extra) => func(...extra, ...args)
|
|
67
|
+
|
|
68
|
+
export { handler$, eventHandler$ }
|
package/src/icon.svelte
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Icon
|
|
4
|
+
|
|
5
|
+
# Icon
|
|
6
|
+
|
|
7
|
+
Displays a [Tabler Icon](https://tabler-icons.io/) and some optional text.
|
|
8
|
+
The icon will appear at the beginning of the text.
|
|
9
|
+
|
|
10
|
+
## Base
|
|
11
|
+
[Windstorm Icon](https://axel669.github.io/lib.windstorm/#components-icon)
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
15
|
+
are supported.
|
|
16
|
+
|
|
17
|
+
- ### name `string`
|
|
18
|
+
The name of the icon. Use the tabler icon class name without the "ti-".
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
```svelte
|
|
22
|
+
<Icon name="hexagon" />
|
|
23
|
+
<Icon name="hexagons">Are the bestagons</Icon>
|
|
24
|
+
```
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import wsx from "./wsx.mjs"
|
|
28
|
+
|
|
29
|
+
export let name
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<ws-icon class="ti-{name}" use:wsx={$$restProps}>
|
|
33
|
+
<slot />
|
|
34
|
+
</ws-icon>
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*md
|
|
2
|
+
[@] Home
|
|
3
|
+
|
|
4
|
+
# Zephyr
|
|
5
|
+
Zephyr is a svelte binding for the
|
|
6
|
+
[Windstorm](https://www.npmjs.com/package/@axel669/windstorm)
|
|
7
|
+
library.
|
|
8
|
+
|
|
9
|
+
[Docs Here](https://svelte-wind.axel669.net)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
Zephyr can be installed through npm (or the variants like yarn, pnpm, etc).
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @axel669/svelte-wind
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
Components can be imported individually from the library for tree-shaking, or
|
|
20
|
+
the entire lib can imported at once, but I dunno how big that bundle will be.
|
|
21
|
+
|
|
22
|
+
```svelte
|
|
23
|
+
<script>
|
|
24
|
+
// individual import for tree shaking
|
|
25
|
+
import { Button } from "@axel69/svelte-wind"
|
|
26
|
+
|
|
27
|
+
// bring the whole thing to keep it simple
|
|
28
|
+
import * as Wind from "@axel69/svelte-wind"
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<!-- the wsx action can be used to setup the ws-x needed for the body -->
|
|
32
|
+
<svelte:body use:wsx={{theme, "@app": true}} />
|
|
33
|
+
|
|
34
|
+
<Button on:click={stuff}>
|
|
35
|
+
I'm a button!
|
|
36
|
+
</Button>
|
|
37
|
+
|
|
38
|
+
<Wind.Button on:click={stuff}>
|
|
39
|
+
I'm also button!
|
|
40
|
+
</Wind.Button>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Svelte Config
|
|
44
|
+
No special configuration of svelte is required, nor is there a separate plugin
|
|
45
|
+
that needs to be added. Just have svelte and you're good to go.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
export { default as Avatar } from "./avatar.svelte"
|
|
49
|
+
export { default as Badge } from "./badge.svelte"
|
|
50
|
+
export { default as Button } from "./button.svelte"
|
|
51
|
+
export { default as Chip } from "./chip.svelte"
|
|
52
|
+
export { default as Dialog } from "./dialog.svelte"
|
|
53
|
+
export { default as Drawer } from "./drawer.svelte"
|
|
54
|
+
export { default as Flex } from "./flex.svelte"
|
|
55
|
+
export { default as Grid } from "./grid.svelte"
|
|
56
|
+
export { default as Icon } from "./icon.svelte"
|
|
57
|
+
export { default as InlineDialog } from "./inline-dialog.svelte"
|
|
58
|
+
export { default as Link } from "./link.svelte"
|
|
59
|
+
export { default as Modal } from "./modal.svelte"
|
|
60
|
+
export { default as Notification } from "./notification.svelte"
|
|
61
|
+
export { default as Paper } from "./paper.svelte"
|
|
62
|
+
export { default as Popover } from "./popover.svelte"
|
|
63
|
+
export { default as Progress } from "./progress.svelte"
|
|
64
|
+
export { default as Radio } from "./radio.svelte"
|
|
65
|
+
export { default as Screen } from "./screen.svelte"
|
|
66
|
+
export { default as Select } from "./select.svelte"
|
|
67
|
+
export { default as Table } from "./table.svelte"
|
|
68
|
+
export { default as Tabs } from "./tabs.svelte"
|
|
69
|
+
export { default as Text } from "./text.svelte"
|
|
70
|
+
export { default as Titlebar } from "./titlebar.svelte"
|
|
71
|
+
export { default as Toaster } from "./toaster.svelte"
|
|
72
|
+
export { default as Toggle } from "./toggle.svelte"
|
|
73
|
+
export { default as Tooltip } from "./tooltip.svelte"
|
|
74
|
+
|
|
75
|
+
export { default as DataTable } from "./composed/data-table.svelte"
|
|
76
|
+
export { default as EntryButton } from "./composed/entry-button.svelte"
|
|
77
|
+
export { default as Toast } from "./composed/toast.svelte"
|
|
78
|
+
|
|
79
|
+
export { default as wsx } from "./wsx.mjs"
|
|
80
|
+
|
|
81
|
+
export * as Input from "./input/elems.mjs"
|
|
82
|
+
|
|
83
|
+
export * from "./handler$.mjs"
|
|
84
|
+
|
|
85
|
+
export { default as TheLastAirbender } from "./avatar.svelte"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import wsx from "./wsx.mjs"
|
|
3
|
+
|
|
4
|
+
import Paper from "./paper.svelte"
|
|
5
|
+
|
|
6
|
+
const id = Math.random().toString(16)
|
|
7
|
+
|
|
8
|
+
$: paper = {
|
|
9
|
+
"@dialog": true,
|
|
10
|
+
"@outline": true,
|
|
11
|
+
...$$restProps
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<slot name="toggle" {id} />
|
|
16
|
+
<input type="checkbox" ws-x="hide" {id} />
|
|
17
|
+
<ws-modal>
|
|
18
|
+
<ws-paper use:wsx={paper}>
|
|
19
|
+
<slot name="header" {id} />
|
|
20
|
+
<slot name="content" {id} />
|
|
21
|
+
<slot name="footer" {id} />
|
|
22
|
+
</ws-paper>
|
|
23
|
+
</ws-modal>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/Input/Area
|
|
4
|
+
|
|
5
|
+
# Input.Area
|
|
6
|
+
|
|
7
|
+
A multiline text input component.
|
|
8
|
+
|
|
9
|
+
## Base
|
|
10
|
+
[Windstorm Labled Control](https://axel669.github.io/lib.windstorm/#components-labeled-control)
|
|
11
|
+
using a `<textarea>`
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
All [windstorm functions](https://axel669.github.io/lib.windstorm/#css-shorthands)
|
|
15
|
+
are supported.
|
|
16
|
+
|
|
17
|
+
- ### color `string`
|
|
18
|
+
Sets `$color`
|
|
19
|
+
- ### error `string`
|
|
20
|
+
Shows an error message under the input
|
|
21
|
+
- ### flat `bool`
|
|
22
|
+
Sets `@flat`
|
|
23
|
+
- ### hint `string`
|
|
24
|
+
Shows a hint under the label. If no label is provided, the hint will not
|
|
25
|
+
be shown either
|
|
26
|
+
- ### label `string`
|
|
27
|
+
The label for the input
|
|
28
|
+
- ### transform `function`
|
|
29
|
+
If given, it will transform the text value from the input and set the
|
|
30
|
+
`tvalue` to the result
|
|
31
|
+
- ### tvalue
|
|
32
|
+
Value that can be bound to as the output of the transform function.
|
|
33
|
+
Setting has no effect
|
|
34
|
+
- ### validate `function`
|
|
35
|
+
If given, will check the transformed output against a validation
|
|
36
|
+
criteria and store the result in `valid`
|
|
37
|
+
- ### valid `bool`
|
|
38
|
+
Value that can be bound to as the output of the validation function.
|
|
39
|
+
Setting has no effect
|
|
40
|
+
- ### value `string`
|
|
41
|
+
The value of the textarea, can be bound to
|
|
42
|
+
|
|
43
|
+
## Functions
|
|
44
|
+
- focus()\\
|
|
45
|
+
Focuses the textarea
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
```js
|
|
49
|
+
import { Input } from "@axel669/svelte-wind"
|
|
50
|
+
```
|
|
51
|
+
```svelte
|
|
52
|
+
<Input.Area bind:value />
|
|
53
|
+
<Input.Area bind:value color="primary" />
|
|
54
|
+
<Input.Area bind:value label="Wat" hint="Blep"/>
|
|
55
|
+
<Input.Area bind:value bind:tvalue transform={txt => txt.toLowerCase()} />
|
|
56
|
+
<Input.Area bind:value bind:valid validate={txt => txt.indexOf("a") > 0} />
|
|
57
|
+
```
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
import wsx from "../wsx.mjs"
|
|
61
|
+
|
|
62
|
+
export let flat = false
|
|
63
|
+
export let label
|
|
64
|
+
export let color = "default"
|
|
65
|
+
export let error = null
|
|
66
|
+
export let hint = null
|
|
67
|
+
|
|
68
|
+
export let value = ""
|
|
69
|
+
|
|
70
|
+
export let transform = i => i
|
|
71
|
+
export let tvalue
|
|
72
|
+
export let validate = () => true
|
|
73
|
+
export let valid
|
|
74
|
+
|
|
75
|
+
let area = null
|
|
76
|
+
export const focus = () => area.focus()
|
|
77
|
+
|
|
78
|
+
$: wind = {
|
|
79
|
+
"@flat": flat,
|
|
80
|
+
"@control": true,
|
|
81
|
+
$color: color,
|
|
82
|
+
...$$restProps,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
$: tvalue = transform(value ?? "")
|
|
86
|
+
$: valid = validate(tvalue)
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<label use:wsx={wind} ws-error={error}>
|
|
90
|
+
{#if label}
|
|
91
|
+
<span ws-x="$text" ws-hint={hint}>{label}</span>
|
|
92
|
+
{/if}
|
|
93
|
+
<textarea {...$$restProps} bind:value on:focus on:blur bind:this={area} />
|
|
94
|
+
|
|
95
|
+
<slot name="start" />
|
|
96
|
+
<slot name="end" />
|
|
97
|
+
</label>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Area } from "./area.svelte"
|
|
2
|
+
export { default as Email } from "./email.svelte"
|
|
3
|
+
export { default as File } from "./file.svelte"
|
|
4
|
+
export { default as Number } from "./number.svelte"
|
|
5
|
+
export { default as Password } from "./password.svelte"
|
|
6
|
+
export { default as Search } from "./search.svelte"
|
|
7
|
+
export { default as Text } from "./text.svelte"
|