@axel669/zephyr 0.2.0-beta.3 → 0.3.6
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/package.json +33 -33
- package/readme.md +63 -63
- package/src/async/button.md +27 -0
- package/src/async/button.svelte +29 -31
- package/src/async/load-zone.md +42 -0
- package/src/async/load-zone.svelte +22 -20
- package/src/composed/data-table/th.md +21 -0
- package/src/composed/data-table/th.svelte +61 -61
- package/src/composed/data-table.md +86 -85
- package/src/composed/data-table.svelte +199 -149
- package/src/composed/entry-button.md +44 -34
- package/src/composed/entry-button.svelte +31 -31
- package/src/composed/table-functions.js +13 -13
- package/src/composed/toast/message.svelte +56 -56
- package/src/composed/toast.md +45 -36
- package/src/composed/toast.svelte +70 -70
- package/src/control/button.md +41 -41
- package/src/control/button.svelte +27 -27
- package/src/control/input.md +87 -0
- package/src/control/input.svelte +109 -109
- package/src/control/label.md +48 -49
- package/src/control/label.svelte +38 -38
- package/src/control/link.md +50 -50
- package/src/control/link.svelte +32 -30
- package/src/control/radio.md +58 -58
- package/src/control/radio.svelte +28 -28
- package/src/control/select.md +70 -70
- package/src/control/select.svelte +64 -64
- package/src/control/tabs.md +47 -47
- package/src/control/tabs.svelte +43 -41
- package/src/control/toggle.md +61 -61
- package/src/control/toggle.svelte +49 -49
- package/src/data-display/avatar.md +36 -36
- package/src/data-display/avatar.svelte +25 -25
- package/src/data-display/badge.md +30 -30
- package/src/data-display/badge.svelte +14 -14
- package/src/data-display/chip.md +36 -36
- package/src/data-display/chip.svelte +28 -28
- package/src/data-display/details.md +42 -3
- package/src/data-display/details.svelte +25 -25
- package/src/data-display/popover.md +32 -32
- package/src/data-display/popover.svelte +25 -25
- package/src/data-display/progress.md +46 -46
- package/src/data-display/progress.svelte +27 -27
- package/src/data-display/table.md +59 -7
- package/src/data-display/table.svelte +38 -38
- package/src/data-display/tooltip.md +29 -29
- package/src/data-display/tooltip.svelte +17 -17
- package/src/dialogs/alert.md +42 -3
- package/src/dialogs/alert.svelte +34 -34
- package/src/dialogs/confirm.md +56 -3
- package/src/dialogs/confirm.svelte +45 -45
- package/src/functions.md +108 -83
- package/src/handler$.mjs +20 -20
- package/src/hash.js +14 -0
- package/src/index.mjs +53 -52
- package/src/info/icon.md +21 -21
- package/src/info/icon.svelte +9 -9
- package/src/info/notification.md +36 -36
- package/src/info/notification.svelte +16 -16
- package/src/info/titlebar.md +75 -75
- package/src/info/titlebar.svelte +18 -18
- package/src/info/toaster.md +26 -26
- package/src/info/toaster.svelte +14 -14
- package/src/inline-dialog.svelte +23 -23
- package/src/layout/dialog.md +43 -43
- package/src/layout/dialog.svelte +26 -26
- package/src/layout/drawer.md +70 -70
- package/src/layout/drawer.svelte +49 -49
- package/src/layout/flex.md +43 -43
- package/src/layout/flex.svelte +26 -24
- package/src/layout/grid.md +61 -61
- package/src/layout/grid.svelte +30 -28
- package/src/layout/modal.md +50 -50
- package/src/layout/modal.svelte +60 -60
- package/src/layout/paper.md +94 -94
- package/src/layout/paper.svelte +47 -47
- package/src/layout/screen.md +33 -33
- package/src/layout/screen.svelte +34 -34
- package/src/spinner/circle-spinner.svelte +15 -15
- package/src/spinner/hexagon-spinner.svelte +15 -15
- package/src/spinner/spinners.md +22 -3
- package/src/text.md +34 -34
- package/src/text.svelte +22 -22
- package/src/variant.mjs +12 -12
- package/src/wsx.mjs +24 -24
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import { createEventDispatcher } from "svelte"
|
|
5
|
-
|
|
6
|
-
import Button from "../control/button.svelte"
|
|
7
|
-
import Modal from "../layout/modal.svelte"
|
|
8
|
-
import { handler$ } from "../handler$.mjs"
|
|
9
|
-
|
|
10
|
-
export let component
|
|
11
|
-
export let props
|
|
12
|
-
let wrapper = Modal
|
|
13
|
-
export { wrapper as this }
|
|
14
|
-
|
|
15
|
-
const send = createEventDispatcher()
|
|
16
|
-
|
|
17
|
-
let element = null
|
|
18
|
-
const open = handler$(
|
|
19
|
-
async (props) => {
|
|
20
|
-
const elemProps = (typeof props === "function") ? props() : props
|
|
21
|
-
const result = await element.show(elemProps)
|
|
22
|
-
send("entry", result)
|
|
23
|
-
}
|
|
24
|
-
)
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<Button {...$$restProps} on:click={open(props)}>
|
|
28
|
-
<slot />
|
|
29
|
-
</Button>
|
|
30
|
-
|
|
31
|
-
<svelte:component this={wrapper} {component} bind:this={element} />
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import { createEventDispatcher } from "svelte"
|
|
5
|
+
|
|
6
|
+
import Button from "../control/button.svelte"
|
|
7
|
+
import Modal from "../layout/modal.svelte"
|
|
8
|
+
import { handler$ } from "../handler$.mjs"
|
|
9
|
+
|
|
10
|
+
export let component
|
|
11
|
+
export let props
|
|
12
|
+
let wrapper = Modal
|
|
13
|
+
export { wrapper as this }
|
|
14
|
+
|
|
15
|
+
const send = createEventDispatcher()
|
|
16
|
+
|
|
17
|
+
let element = null
|
|
18
|
+
const open = handler$(
|
|
19
|
+
async (props) => {
|
|
20
|
+
const elemProps = (typeof props === "function") ? props() : props
|
|
21
|
+
const result = await element.show(elemProps)
|
|
22
|
+
send("entry", result)
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<Button {...$$restProps} on:click={open(props)}>
|
|
28
|
+
<slot />
|
|
29
|
+
</Button>
|
|
30
|
+
|
|
31
|
+
<svelte:component this={wrapper} {component} bind:this={element} />
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export const filters = {
|
|
2
|
-
text: (propName) =>
|
|
3
|
-
(row, text) =>
|
|
4
|
-
row[propName]
|
|
5
|
-
.toLowerCase()
|
|
6
|
-
.includes(text.toLowerCase())
|
|
7
|
-
}
|
|
8
|
-
export const sorts = {
|
|
9
|
-
natural: (propName) => {
|
|
10
|
-
const comparitor = new Intl.Collator(undefined, { numeric: true })
|
|
11
|
-
return (a, b) => comparitor.compare(a[propName], b[propName])
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
export const filters = {
|
|
2
|
+
text: (propName) =>
|
|
3
|
+
(row, text) =>
|
|
4
|
+
row[propName]
|
|
5
|
+
.toLowerCase()
|
|
6
|
+
.includes(text.toLowerCase())
|
|
7
|
+
}
|
|
8
|
+
export const sorts = {
|
|
9
|
+
natural: (propName) => {
|
|
10
|
+
const comparitor = new Intl.Collator(undefined, { numeric: true })
|
|
11
|
+
return (a, b) => comparitor.compare(a[propName], b[propName])
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/*md
|
|
3
|
-
[@] Components/ToastMessage
|
|
4
|
-
|
|
5
|
-
# ToastMessage
|
|
6
|
-
|
|
7
|
-
The default component for Toast to show messages with
|
|
8
|
-
|
|
9
|
-
## Props
|
|
10
|
-
|
|
11
|
-
### actionText
|
|
12
|
-
`string`
|
|
13
|
-
|
|
14
|
-
If given, the message will have a button that can be clicked and will
|
|
15
|
-
use this text for the button text
|
|
16
|
-
|
|
17
|
-
### color
|
|
18
|
-
`string`
|
|
19
|
-
|
|
20
|
-
Sets `$color`
|
|
21
|
-
|
|
22
|
-
### icon
|
|
23
|
-
`string`
|
|
24
|
-
|
|
25
|
-
An icon to show with the message
|
|
26
|
-
|
|
27
|
-
### message
|
|
28
|
-
`string`
|
|
29
|
-
|
|
30
|
-
The message to show
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
import { createEventDispatcher } from "svelte"
|
|
34
|
-
|
|
35
|
-
import Button from "../../control/button.svelte"
|
|
36
|
-
import Icon from "../../info/icon.svelte"
|
|
37
|
-
import Notification from "../../info/notification.svelte"
|
|
38
|
-
|
|
39
|
-
export let message = ""
|
|
40
|
-
export let icon = ""
|
|
41
|
-
export let color = false
|
|
42
|
-
export let actionText = null
|
|
43
|
-
|
|
44
|
-
const dispatch = createEventDispatcher()
|
|
45
|
-
const dismiss = () => dispatch("action", null)
|
|
46
|
-
const respond = () => dispatch("action", true)
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<Notification {color} on:click={dismiss}>
|
|
50
|
-
<Icon name={icon}>{message}</Icon>
|
|
51
|
-
{#if actionText}
|
|
52
|
-
<Button {color} variant="fill" on:click={respond}>
|
|
53
|
-
{actionText}
|
|
54
|
-
</Button>
|
|
55
|
-
{/if}
|
|
56
|
-
</Notification>
|
|
1
|
+
<script>
|
|
2
|
+
/*md
|
|
3
|
+
[@] Components/ToastMessage
|
|
4
|
+
|
|
5
|
+
# ToastMessage
|
|
6
|
+
|
|
7
|
+
The default component for Toast to show messages with
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
### actionText
|
|
12
|
+
`string`
|
|
13
|
+
|
|
14
|
+
If given, the message will have a button that can be clicked and will
|
|
15
|
+
use this text for the button text
|
|
16
|
+
|
|
17
|
+
### color
|
|
18
|
+
`string`
|
|
19
|
+
|
|
20
|
+
Sets `$color`
|
|
21
|
+
|
|
22
|
+
### icon
|
|
23
|
+
`string`
|
|
24
|
+
|
|
25
|
+
An icon to show with the message
|
|
26
|
+
|
|
27
|
+
### message
|
|
28
|
+
`string`
|
|
29
|
+
|
|
30
|
+
The message to show
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import { createEventDispatcher } from "svelte"
|
|
34
|
+
|
|
35
|
+
import Button from "../../control/button.svelte"
|
|
36
|
+
import Icon from "../../info/icon.svelte"
|
|
37
|
+
import Notification from "../../info/notification.svelte"
|
|
38
|
+
|
|
39
|
+
export let message = ""
|
|
40
|
+
export let icon = ""
|
|
41
|
+
export let color = false
|
|
42
|
+
export let actionText = null
|
|
43
|
+
|
|
44
|
+
const dispatch = createEventDispatcher()
|
|
45
|
+
const dismiss = () => dispatch("action", null)
|
|
46
|
+
const respond = () => dispatch("action", true)
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<Notification {color} on:click={dismiss}>
|
|
50
|
+
<Icon name={icon}>{message}</Icon>
|
|
51
|
+
{#if actionText}
|
|
52
|
+
<Button {color} variant="fill" on:click={respond}>
|
|
53
|
+
{actionText}
|
|
54
|
+
</Button>
|
|
55
|
+
{/if}
|
|
56
|
+
</Notification>
|
package/src/composed/toast.md
CHANGED
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
# Toast
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
# Toast
|
|
2
|
+
Displays toast notifications along the edge of the screen. Unlike the Toaster
|
|
3
|
+
component, this has functions for interacting with and generating toast
|
|
4
|
+
messages, where the Toaster component has the programmer manage the content.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
See the Toaster component. The Toast component is wrapper around it that
|
|
8
|
+
also controls the children being shown for convenience.
|
|
9
|
+
|
|
10
|
+
### component
|
|
11
|
+
The component to use as a wrapper for the messages. Defaults to the
|
|
12
|
+
ToastMessage component.
|
|
13
|
+
|
|
14
|
+
### position
|
|
15
|
+
The position to show modals in. Uses the same positions as the Windstorm
|
|
16
|
+
toaster.
|
|
17
|
+
|
|
18
|
+
## Functions
|
|
19
|
+
|
|
20
|
+
### show(duration, props)
|
|
21
|
+
Shows a toast notification that will disappear after the specified
|
|
22
|
+
duration (time in milliseconds). The props provided are passed to an
|
|
23
|
+
instance of the component specified in the props.
|
|
24
|
+
|
|
25
|
+
## Events
|
|
26
|
+
|
|
27
|
+
### action
|
|
28
|
+
Fired when a toast message is clicked. The info argument contains a
|
|
29
|
+
value property that is provided by the message component, and a copy
|
|
30
|
+
of the props passed to that instace.
|
|
31
|
+
|
|
32
|
+
For the default messages, the value will be `null` if no button was
|
|
33
|
+
clicked, and `true` if the action button was clicked. This allows
|
|
34
|
+
actions to be taken against interactions in the message without having
|
|
35
|
+
to bind all kinds of events or callbacks.
|
|
36
|
+
|
|
37
|
+
## Example
|
|
38
|
+
```svelte
|
|
39
|
+
<script>
|
|
40
|
+
let toast = null
|
|
41
|
+
const notify = () => toast.show(5000, { message: "hi" })
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<Toast bind:this={toast} position="bc" />
|
|
45
|
+
```
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script context="module">
|
|
4
|
-
const genID = () => `${Date.now()}:${Math.random().toString(16)}`
|
|
5
|
-
|
|
6
|
-
const delays = {}
|
|
7
|
-
const delay = ({time, action, id}) => {
|
|
8
|
-
const trigger = () => {
|
|
9
|
-
const info = delays[id]
|
|
10
|
-
clearTimeout(info.id)
|
|
11
|
-
action()
|
|
12
|
-
delete delays[id]
|
|
13
|
-
}
|
|
14
|
-
const timeoutID = setTimeout(trigger, time)
|
|
15
|
-
delays[id] = { trigger, id: timeoutID }
|
|
16
|
-
}
|
|
17
|
-
delay.trigger = (id) => delays[id].trigger()
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<script>
|
|
21
|
-
import { createEventDispatcher } from "svelte"
|
|
22
|
-
import { fade } from "svelte/transition"
|
|
23
|
-
|
|
24
|
-
import { eventHandler$ } from "../handler$.mjs"
|
|
25
|
-
|
|
26
|
-
import Toaster from "../info/toaster.svelte"
|
|
27
|
-
|
|
28
|
-
import ToastMessage from "./toast/message.svelte"
|
|
29
|
-
|
|
30
|
-
export let component = ToastMessage
|
|
31
|
-
export let position = "tc"
|
|
32
|
-
|
|
33
|
-
let items = []
|
|
34
|
-
|
|
35
|
-
const dispatch = createEventDispatcher()
|
|
36
|
-
const act = eventHandler$(
|
|
37
|
-
(evt, id, props) => {
|
|
38
|
-
delay.trigger(id)
|
|
39
|
-
dispatch(
|
|
40
|
-
"action",
|
|
41
|
-
{ value: evt.detail, props }
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
export const show = (duration, props) => {
|
|
47
|
-
const id = genID()
|
|
48
|
-
items = [...items, { id, props }]
|
|
49
|
-
delay({
|
|
50
|
-
action: () => items = items.filter(
|
|
51
|
-
item => item.id !== id
|
|
52
|
-
),
|
|
53
|
-
time: duration,
|
|
54
|
-
id,
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
export const clear = () => items = []
|
|
58
|
-
</script>
|
|
59
|
-
|
|
60
|
-
<Toaster {position} {...$$restProps}>
|
|
61
|
-
{#each items as {props, id} (id)}
|
|
62
|
-
<zephyr-toast-wrapper ws-x="grid" transition:fade={{duration: 200}}>
|
|
63
|
-
<svelte:component
|
|
64
|
-
this={component}
|
|
65
|
-
{...props}
|
|
66
|
-
on:action={act(id, props)}
|
|
67
|
-
/>
|
|
68
|
-
</zephyr-toast-wrapper>
|
|
69
|
-
{/each}
|
|
70
|
-
</Toaster>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script context="module">
|
|
4
|
+
const genID = () => `${Date.now()}:${Math.random().toString(16)}`
|
|
5
|
+
|
|
6
|
+
const delays = {}
|
|
7
|
+
const delay = ({time, action, id}) => {
|
|
8
|
+
const trigger = () => {
|
|
9
|
+
const info = delays[id]
|
|
10
|
+
clearTimeout(info.id)
|
|
11
|
+
action()
|
|
12
|
+
delete delays[id]
|
|
13
|
+
}
|
|
14
|
+
const timeoutID = setTimeout(trigger, time)
|
|
15
|
+
delays[id] = { trigger, id: timeoutID }
|
|
16
|
+
}
|
|
17
|
+
delay.trigger = (id) => delays[id].trigger()
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { createEventDispatcher } from "svelte"
|
|
22
|
+
import { fade } from "svelte/transition"
|
|
23
|
+
|
|
24
|
+
import { eventHandler$ } from "../handler$.mjs"
|
|
25
|
+
|
|
26
|
+
import Toaster from "../info/toaster.svelte"
|
|
27
|
+
|
|
28
|
+
import ToastMessage from "./toast/message.svelte"
|
|
29
|
+
|
|
30
|
+
export let component = ToastMessage
|
|
31
|
+
export let position = "tc"
|
|
32
|
+
|
|
33
|
+
let items = []
|
|
34
|
+
|
|
35
|
+
const dispatch = createEventDispatcher()
|
|
36
|
+
const act = eventHandler$(
|
|
37
|
+
(evt, id, props) => {
|
|
38
|
+
delay.trigger(id)
|
|
39
|
+
dispatch(
|
|
40
|
+
"action",
|
|
41
|
+
{ value: evt.detail, props }
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export const show = (duration, props) => {
|
|
47
|
+
const id = genID()
|
|
48
|
+
items = [...items, { id, props }]
|
|
49
|
+
delay({
|
|
50
|
+
action: () => items = items.filter(
|
|
51
|
+
item => item.id !== id
|
|
52
|
+
),
|
|
53
|
+
time: duration,
|
|
54
|
+
id,
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
export const clear = () => items = []
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<Toaster {position} {...$$restProps}>
|
|
61
|
+
{#each items as {props, id} (id)}
|
|
62
|
+
<zephyr-toast-wrapper ws-x="[grid]" transition:fade={{duration: 200}}>
|
|
63
|
+
<svelte:component
|
|
64
|
+
this={component}
|
|
65
|
+
{...props}
|
|
66
|
+
on:action={act(id, props)}
|
|
67
|
+
/>
|
|
68
|
+
</zephyr-toast-wrapper>
|
|
69
|
+
{/each}
|
|
70
|
+
</Toaster>
|
package/src/control/button.md
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
# Button
|
|
2
|
-
|
|
3
|
-
Basic clickable component for handling user interaction.
|
|
4
|
-
|
|
5
|
-
## Props
|
|
6
|
-
|
|
7
|
-
### color
|
|
8
|
-
`string`
|
|
9
|
-
|
|
10
|
-
Sets `$color`
|
|
11
|
-
|
|
12
|
-
### compact
|
|
13
|
-
`bool`
|
|
14
|
-
|
|
15
|
-
Sets `$compact`
|
|
16
|
-
|
|
17
|
-
### fill / outline
|
|
18
|
-
`bool`
|
|
19
|
-
|
|
20
|
-
Sets the button type to `$fill` if fill is true, `$outline` if outline
|
|
21
|
-
is true, or `$flat` if neither is true.
|
|
22
|
-
|
|
23
|
-
## Events
|
|
24
|
-
- click
|
|
25
|
-
|
|
26
|
-
## Example
|
|
27
|
-
```svelte
|
|
28
|
-
<script>
|
|
29
|
-
import { Button } from "@axel669/zephyr"
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<Button on:click={action}>
|
|
33
|
-
Flat Button
|
|
34
|
-
</Button>
|
|
35
|
-
<Button on:click={action} outline>
|
|
36
|
-
Outlined Button
|
|
37
|
-
</Button>
|
|
38
|
-
<Button on:click={action} fill color="danger">
|
|
39
|
-
Filled Button
|
|
40
|
-
</Button>
|
|
41
|
-
```
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
Basic clickable component for handling user interaction.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
### color
|
|
8
|
+
`string`
|
|
9
|
+
|
|
10
|
+
Sets `$color`
|
|
11
|
+
|
|
12
|
+
### compact
|
|
13
|
+
`bool`
|
|
14
|
+
|
|
15
|
+
Sets `$compact`
|
|
16
|
+
|
|
17
|
+
### fill / outline
|
|
18
|
+
`bool`
|
|
19
|
+
|
|
20
|
+
Sets the button type to `$fill` if fill is true, `$outline` if outline
|
|
21
|
+
is true, or `$flat` if neither is true.
|
|
22
|
+
|
|
23
|
+
## Events
|
|
24
|
+
- click
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
```svelte
|
|
28
|
+
<script>
|
|
29
|
+
import { Button } from "@axel669/zephyr"
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<Button on:click={action}>
|
|
33
|
+
Flat Button
|
|
34
|
+
</Button>
|
|
35
|
+
<Button on:click={action} outline>
|
|
36
|
+
Outlined Button
|
|
37
|
+
</Button>
|
|
38
|
+
<Button on:click={action} fill color="danger">
|
|
39
|
+
Filled Button
|
|
40
|
+
</Button>
|
|
41
|
+
```
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import wsx from "../wsx.mjs"
|
|
5
|
-
import variant from "../variant.mjs"
|
|
6
|
-
|
|
7
|
-
export let color = false
|
|
8
|
-
export let compact = false
|
|
9
|
-
export let disabled
|
|
10
|
-
|
|
11
|
-
export let fill = false
|
|
12
|
-
export let outline = false
|
|
13
|
-
export let flat = false
|
|
14
|
-
|
|
15
|
-
$: type = variant({ fill, outline, flat })
|
|
16
|
-
|
|
17
|
-
$: wind = {
|
|
18
|
-
[type]: true,
|
|
19
|
-
"$color": color,
|
|
20
|
-
$compact: compact,
|
|
21
|
-
...$$restProps
|
|
22
|
-
}
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<button use:wsx={wind} {disabled} on:click|stopPropagation>
|
|
26
|
-
<slot />
|
|
27
|
-
</button>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import wsx from "../wsx.mjs"
|
|
5
|
+
import variant from "../variant.mjs"
|
|
6
|
+
|
|
7
|
+
export let color = false
|
|
8
|
+
export let compact = false
|
|
9
|
+
export let disabled
|
|
10
|
+
|
|
11
|
+
export let fill = false
|
|
12
|
+
export let outline = false
|
|
13
|
+
export let flat = false
|
|
14
|
+
|
|
15
|
+
$: type = variant({ fill, outline, flat })
|
|
16
|
+
|
|
17
|
+
$: wind = {
|
|
18
|
+
[type]: true,
|
|
19
|
+
"$color": color,
|
|
20
|
+
$compact: compact,
|
|
21
|
+
...$$restProps
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<button use:wsx={wind} {disabled} on:click|stopPropagation>
|
|
26
|
+
<slot />
|
|
27
|
+
</button>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Input
|
|
2
|
+
A component that wraps the text-based input tags. Includes optional outline,
|
|
3
|
+
label, hint text, error showing, input validation, input transformation, and
|
|
4
|
+
browser level autocomplete.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
### autoCompleteOptions
|
|
9
|
+
An array of options to show for auto complete. Uses the browser `datalist`
|
|
10
|
+
element to create the auto complete.
|
|
11
|
+
|
|
12
|
+
### color
|
|
13
|
+
Sets the $color macro.
|
|
14
|
+
|
|
15
|
+
### disabled
|
|
16
|
+
Disables the input.
|
|
17
|
+
|
|
18
|
+
### error
|
|
19
|
+
If set, shows an error message under the input.
|
|
20
|
+
|
|
21
|
+
### flat
|
|
22
|
+
If true, the input will not have a border. Default is false (with a border).
|
|
23
|
+
|
|
24
|
+
### hint
|
|
25
|
+
Shows a hint under the label of the input.
|
|
26
|
+
|
|
27
|
+
### type
|
|
28
|
+
The type of input. Default to "text".
|
|
29
|
+
|
|
30
|
+
### value
|
|
31
|
+
The value of the input. Can be bound the same way a normal text input value is
|
|
32
|
+
bound in Svelte.
|
|
33
|
+
|
|
34
|
+
### transform
|
|
35
|
+
A function to transform the value of the input automatically. Results are put
|
|
36
|
+
into the tvalue prop.
|
|
37
|
+
|
|
38
|
+
### tvalue
|
|
39
|
+
The transformed value of the input. Binding should only be used to react to
|
|
40
|
+
the value as it will be overriden while a user is typing into the input.
|
|
41
|
+
|
|
42
|
+
### validate
|
|
43
|
+
A function to determine if the value of the input is valid. Results are put into
|
|
44
|
+
the `valid` prop. If a transform function is provided, the transformed value
|
|
45
|
+
is given to the validation function.
|
|
46
|
+
|
|
47
|
+
### valid
|
|
48
|
+
The result of the validation function. Binding should only be used to react to
|
|
49
|
+
the value.
|
|
50
|
+
|
|
51
|
+
## Instance Functions
|
|
52
|
+
|
|
53
|
+
### focus
|
|
54
|
+
Focuses the input.
|
|
55
|
+
|
|
56
|
+
## Slots
|
|
57
|
+
|
|
58
|
+
### end
|
|
59
|
+
Puts an element at the end of the input.
|
|
60
|
+
|
|
61
|
+
### start
|
|
62
|
+
Puts an element at the start of the input.
|
|
63
|
+
|
|
64
|
+
## Example
|
|
65
|
+
|
|
66
|
+
```svelte
|
|
67
|
+
<script>
|
|
68
|
+
import { Input } from "@axel669/zephyr"
|
|
69
|
+
|
|
70
|
+
let name = ""
|
|
71
|
+
let ageText = ""
|
|
72
|
+
let age = 0
|
|
73
|
+
let ageValid = false
|
|
74
|
+
|
|
75
|
+
$: ageError = ageValid ? "Invalid Age" : null
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<Input bind:value={name} label="Name" />
|
|
79
|
+
<Input
|
|
80
|
+
bind:value={ageText}
|
|
81
|
+
transform={v => parseInt(v)}
|
|
82
|
+
bind:tvalue={age}
|
|
83
|
+
validate={age => age > 0}
|
|
84
|
+
bind:valid={ageValid}
|
|
85
|
+
error={ageError}
|
|
86
|
+
/>
|
|
87
|
+
```
|