@axel669/zephyr 0.3.4-beta.0 → 0.3.8
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 +2 -2
- package/readme.md +63 -63
- package/src/async/button.md +27 -27
- package/src/async/button.svelte +29 -29
- package/src/async/load-zone.md +42 -42
- package/src/async/load-zone.svelte +22 -22
- package/src/composed/data-table/th.md +21 -21
- package/src/composed/data-table/th.svelte +61 -61
- package/src/composed/data-table.md +86 -86
- package/src/composed/data-table.svelte +199 -199
- package/src/composed/entry-button.md +44 -44
- 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 -45
- 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 -87
- package/src/control/input.svelte +109 -109
- package/src/control/label.md +48 -48
- package/src/control/label.svelte +38 -38
- package/src/control/link.md +50 -50
- package/src/control/link.svelte +32 -32
- 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 -43
- 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 -42
- 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 -59
- 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 -42
- package/src/dialogs/alert.svelte +34 -34
- package/src/dialogs/confirm.md +56 -56
- package/src/dialogs/confirm.svelte +45 -45
- package/src/functions.md +108 -108
- package/src/handler$.mjs +20 -20
- package/src/hash.js +14 -14
- package/src/index.mjs +53 -53
- 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 -26
- package/src/layout/grid.md +61 -61
- package/src/layout/grid.svelte +30 -30
- 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 -22
- package/src/text.md +34 -34
- package/src/text.svelte +22 -22
- package/src/variant.mjs +12 -12
- package/src/wsx.mjs +24 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axel669/zephyr",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"author": "",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@axel669/windstorm": "0.3.
|
|
15
|
+
"@axel669/windstorm": "0.3.8"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@axel669/ipsen": "0.4.0-beta.7",
|
package/readme.md
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
# Zephyr
|
|
2
|
-
Zephyr is a svelte binding for the [Windstorm](https://windstorm.axel669.net)
|
|
3
|
-
library, with some additional parts to make it look nice in the markup.
|
|
4
|
-
|
|
5
|
-
[Docs Here](https://zephyr.axel669.net)
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
Zephyr can be installed through npm (or the variants like yarn, pnpm, etc).
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm install @axel669/zephyr
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Components
|
|
15
|
-
Components can be imported individually from the library for tree-shaking, or
|
|
16
|
-
the entire lib can imported at once, but I dunno how big that bundle will be.
|
|
17
|
-
Components can also take any windstorm macro as a prop, including custom macros,
|
|
18
|
-
using the same rules as the `wsx` covered in [Functions](./src/functions.md).
|
|
19
|
-
|
|
20
|
-
### Theming
|
|
21
|
-
Windstorm expects a theme to be defined on an ancestor of the html elements
|
|
22
|
-
that use it, and Zephyr does not automatically set the theme because it can
|
|
23
|
-
used anywhere in the page. This means the wsx action (or setting the ws-x
|
|
24
|
-
attribute directly) will be needed for components to look right. Any valid
|
|
25
|
-
Windstorm theme is usable, including custom ones.
|
|
26
|
-
|
|
27
|
-
### Example
|
|
28
|
-
```svelte
|
|
29
|
-
<script>
|
|
30
|
-
// individual import for tree shaking
|
|
31
|
-
import {
|
|
32
|
-
Button,
|
|
33
|
-
wsx
|
|
34
|
-
} from "@axel669/zephyr"
|
|
35
|
-
|
|
36
|
-
// bring the whole thing to keep it simple
|
|
37
|
-
import * as Wind from "@axel669/zephyr"
|
|
38
|
-
|
|
39
|
-
const theme = "dark"
|
|
40
|
-
const handler = () => {
|
|
41
|
-
console.log("button clicked!")
|
|
42
|
-
}
|
|
43
|
-
</script>
|
|
44
|
-
|
|
45
|
-
<!-- the wsx action can be used to setup the ws-x needed for the body -->
|
|
46
|
-
<svelte:body use:wsx={{"@theme": theme, "@app": true}} />
|
|
47
|
-
|
|
48
|
-
<Button on:click={handler}>
|
|
49
|
-
I'm a button!
|
|
50
|
-
</Button>
|
|
51
|
-
|
|
52
|
-
<Wind.Button on:click={handler}>
|
|
53
|
-
I'm also button!
|
|
54
|
-
</Wind.Button>
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Svelte Config
|
|
58
|
-
Zephyr does not output any css of its own, so no configuration is required to
|
|
59
|
-
make it styled as expected. For people using Svelte 4+ you will need to make
|
|
60
|
-
sure your bundler has the browser conditions set as some components do use
|
|
61
|
-
lifecycle functions that will not be bundled without the setting.
|
|
62
|
-
[Svelte Docs](https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers)
|
|
63
|
-
about the setting.
|
|
1
|
+
# Zephyr
|
|
2
|
+
Zephyr is a svelte binding for the [Windstorm](https://windstorm.axel669.net)
|
|
3
|
+
library, with some additional parts to make it look nice in the markup.
|
|
4
|
+
|
|
5
|
+
[Docs Here](https://zephyr.axel669.net)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
Zephyr can be installed through npm (or the variants like yarn, pnpm, etc).
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @axel669/zephyr
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Components
|
|
15
|
+
Components can be imported individually from the library for tree-shaking, or
|
|
16
|
+
the entire lib can imported at once, but I dunno how big that bundle will be.
|
|
17
|
+
Components can also take any windstorm macro as a prop, including custom macros,
|
|
18
|
+
using the same rules as the `wsx` covered in [Functions](./src/functions.md).
|
|
19
|
+
|
|
20
|
+
### Theming
|
|
21
|
+
Windstorm expects a theme to be defined on an ancestor of the html elements
|
|
22
|
+
that use it, and Zephyr does not automatically set the theme because it can
|
|
23
|
+
used anywhere in the page. This means the wsx action (or setting the ws-x
|
|
24
|
+
attribute directly) will be needed for components to look right. Any valid
|
|
25
|
+
Windstorm theme is usable, including custom ones.
|
|
26
|
+
|
|
27
|
+
### Example
|
|
28
|
+
```svelte
|
|
29
|
+
<script>
|
|
30
|
+
// individual import for tree shaking
|
|
31
|
+
import {
|
|
32
|
+
Button,
|
|
33
|
+
wsx
|
|
34
|
+
} from "@axel669/zephyr"
|
|
35
|
+
|
|
36
|
+
// bring the whole thing to keep it simple
|
|
37
|
+
import * as Wind from "@axel669/zephyr"
|
|
38
|
+
|
|
39
|
+
const theme = "dark"
|
|
40
|
+
const handler = () => {
|
|
41
|
+
console.log("button clicked!")
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<!-- the wsx action can be used to setup the ws-x needed for the body -->
|
|
46
|
+
<svelte:body use:wsx={{"@theme": theme, "@app": true}} />
|
|
47
|
+
|
|
48
|
+
<Button on:click={handler}>
|
|
49
|
+
I'm a button!
|
|
50
|
+
</Button>
|
|
51
|
+
|
|
52
|
+
<Wind.Button on:click={handler}>
|
|
53
|
+
I'm also button!
|
|
54
|
+
</Wind.Button>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Svelte Config
|
|
58
|
+
Zephyr does not output any css of its own, so no configuration is required to
|
|
59
|
+
make it styled as expected. For people using Svelte 4+ you will need to make
|
|
60
|
+
sure your bundler has the browser conditions set as some components do use
|
|
61
|
+
lifecycle functions that will not be bundled without the setting.
|
|
62
|
+
[Svelte Docs](https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers)
|
|
63
|
+
about the setting.
|
package/src/async/button.md
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# AsyncButton
|
|
2
|
-
A button that makes it simpler to fire off async functions in response to button
|
|
3
|
-
clicks. In addition to calling the function, the button will disable itself
|
|
4
|
-
during the function duration and show a load spinner inside the button.
|
|
5
|
-
|
|
6
|
-
## Props
|
|
7
|
-
The AsyncButton supports all of the [Button](../control/button.md) props.
|
|
8
|
-
|
|
9
|
-
### handler
|
|
10
|
-
The async function to call when the button is clicked.
|
|
11
|
-
|
|
12
|
-
## Example
|
|
13
|
-
|
|
14
|
-
```svelte
|
|
15
|
-
<script>
|
|
16
|
-
import { AsyncButton } from "@axel669/zephyr"
|
|
17
|
-
|
|
18
|
-
const load = async () => {
|
|
19
|
-
const res = await fetch(someURL)
|
|
20
|
-
console.log(await res.text())
|
|
21
|
-
}
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<AsyncButton handler={load} color="@primary">
|
|
25
|
-
Load Things
|
|
26
|
-
</AsyncButton>
|
|
27
|
-
```
|
|
1
|
+
# AsyncButton
|
|
2
|
+
A button that makes it simpler to fire off async functions in response to button
|
|
3
|
+
clicks. In addition to calling the function, the button will disable itself
|
|
4
|
+
during the function duration and show a load spinner inside the button.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
The AsyncButton supports all of the [Button](../control/button.md) props.
|
|
8
|
+
|
|
9
|
+
### handler
|
|
10
|
+
The async function to call when the button is clicked.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
```svelte
|
|
15
|
+
<script>
|
|
16
|
+
import { AsyncButton } from "@axel669/zephyr"
|
|
17
|
+
|
|
18
|
+
const load = async () => {
|
|
19
|
+
const res = await fetch(someURL)
|
|
20
|
+
console.log(await res.text())
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<AsyncButton handler={load} color="@primary">
|
|
25
|
+
Load Things
|
|
26
|
+
</AsyncButton>
|
|
27
|
+
```
|
package/src/async/button.svelte
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Button from "../control/button.svelte"
|
|
3
|
-
import Spinner from "../spinner/circle-spinner.svelte"
|
|
4
|
-
|
|
5
|
-
export let handler = null
|
|
6
|
-
export let disabled
|
|
7
|
-
|
|
8
|
-
let running = false
|
|
9
|
-
const asyncHandler = async (evt) => {
|
|
10
|
-
running = true
|
|
11
|
-
await handler(evt)
|
|
12
|
-
running = false
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
$: inactive = disabled || running
|
|
16
|
-
$: props = {
|
|
17
|
-
...$$restProps,
|
|
18
|
-
disabled: inactive,
|
|
19
|
-
}
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<Button {...props} on:click={asyncHandler}>
|
|
23
|
-
<div ws-x="[h 20px] [m.r:not(:empty) 4px]">
|
|
24
|
-
{#if running === true}
|
|
25
|
-
<Spinner size="20px" />
|
|
26
|
-
{/if}
|
|
27
|
-
</div>
|
|
28
|
-
<slot />
|
|
29
|
-
</Button>
|
|
1
|
+
<script>
|
|
2
|
+
import Button from "../control/button.svelte"
|
|
3
|
+
import Spinner from "../spinner/circle-spinner.svelte"
|
|
4
|
+
|
|
5
|
+
export let handler = null
|
|
6
|
+
export let disabled
|
|
7
|
+
|
|
8
|
+
let running = false
|
|
9
|
+
const asyncHandler = async (evt) => {
|
|
10
|
+
running = true
|
|
11
|
+
await handler(evt)
|
|
12
|
+
running = false
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
$: inactive = disabled || running
|
|
16
|
+
$: props = {
|
|
17
|
+
...$$restProps,
|
|
18
|
+
disabled: inactive,
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<Button {...props} on:click={asyncHandler}>
|
|
23
|
+
<div ws-x="[h 20px] [m.r:not(:empty) 4px]">
|
|
24
|
+
{#if running === true}
|
|
25
|
+
<Spinner size="20px" />
|
|
26
|
+
{/if}
|
|
27
|
+
</div>
|
|
28
|
+
<slot />
|
|
29
|
+
</Button>
|
package/src/async/load-zone.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# LoadZone
|
|
2
|
-
A component for putting content that is behind an async function.
|
|
3
|
-
|
|
4
|
-
## Props
|
|
5
|
-
|
|
6
|
-
### message
|
|
7
|
-
The text to show while the promise is pending.
|
|
8
|
-
|
|
9
|
-
### source
|
|
10
|
-
`Promise`
|
|
11
|
-
|
|
12
|
-
The promise that will resolve into some kind of content-related information.
|
|
13
|
-
|
|
14
|
-
## Slots
|
|
15
|
-
|
|
16
|
-
### default
|
|
17
|
-
The default slot will be shown when the promise resolves.
|
|
18
|
-
|
|
19
|
-
### loading
|
|
20
|
-
The content to show while the promise is pending. Overrides the default of a
|
|
21
|
-
load spinner with some text.
|
|
22
|
-
|
|
23
|
-
### error
|
|
24
|
-
The content to show when the promise rejects. Use `let:error` to get the error
|
|
25
|
-
that was thrown.
|
|
26
|
-
|
|
27
|
-
## Example
|
|
28
|
-
|
|
29
|
-
```svelte
|
|
30
|
-
<LoadZone source={asyncThing} let:result>
|
|
31
|
-
<div>
|
|
32
|
-
content
|
|
33
|
-
</div>
|
|
34
|
-
<div>
|
|
35
|
-
{JSON.stringify(result)}
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<div slot="error">
|
|
39
|
-
:(
|
|
40
|
-
</div>
|
|
41
|
-
</LoadZone>
|
|
42
|
-
```
|
|
1
|
+
# LoadZone
|
|
2
|
+
A component for putting content that is behind an async function.
|
|
3
|
+
|
|
4
|
+
## Props
|
|
5
|
+
|
|
6
|
+
### message
|
|
7
|
+
The text to show while the promise is pending.
|
|
8
|
+
|
|
9
|
+
### source
|
|
10
|
+
`Promise`
|
|
11
|
+
|
|
12
|
+
The promise that will resolve into some kind of content-related information.
|
|
13
|
+
|
|
14
|
+
## Slots
|
|
15
|
+
|
|
16
|
+
### default
|
|
17
|
+
The default slot will be shown when the promise resolves.
|
|
18
|
+
|
|
19
|
+
### loading
|
|
20
|
+
The content to show while the promise is pending. Overrides the default of a
|
|
21
|
+
load spinner with some text.
|
|
22
|
+
|
|
23
|
+
### error
|
|
24
|
+
The content to show when the promise rejects. Use `let:error` to get the error
|
|
25
|
+
that was thrown.
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
```svelte
|
|
30
|
+
<LoadZone source={asyncThing} let:result>
|
|
31
|
+
<div>
|
|
32
|
+
content
|
|
33
|
+
</div>
|
|
34
|
+
<div>
|
|
35
|
+
{JSON.stringify(result)}
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<div slot="error">
|
|
39
|
+
:(
|
|
40
|
+
</div>
|
|
41
|
+
</LoadZone>
|
|
42
|
+
```
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script>
|
|
4
|
-
import Spinner from "../spinner/hexagon-spinner.svelte"
|
|
5
|
-
export let source = null
|
|
6
|
-
export let message = "Loading"
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
{#if source !== null}
|
|
10
|
-
{#await source}
|
|
11
|
-
<slot name="loading">
|
|
12
|
-
<ws-flex ws-x="[fl-center]">
|
|
13
|
-
<span>{message}</span>
|
|
14
|
-
<Spinner size="100px" />
|
|
15
|
-
</ws-flex>
|
|
16
|
-
</slot>
|
|
17
|
-
{:then result}
|
|
18
|
-
<slot {result} />
|
|
19
|
-
{:catch error}
|
|
20
|
-
<slot name="error" {error} />
|
|
21
|
-
{/await}
|
|
22
|
-
{/if}
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script>
|
|
4
|
+
import Spinner from "../spinner/hexagon-spinner.svelte"
|
|
5
|
+
export let source = null
|
|
6
|
+
export let message = "Loading"
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#if source !== null}
|
|
10
|
+
{#await source}
|
|
11
|
+
<slot name="loading">
|
|
12
|
+
<ws-flex ws-x="[fl-center]">
|
|
13
|
+
<span>{message}</span>
|
|
14
|
+
<Spinner size="100px" />
|
|
15
|
+
</ws-flex>
|
|
16
|
+
</slot>
|
|
17
|
+
{:then result}
|
|
18
|
+
<slot {result} />
|
|
19
|
+
{:catch error}
|
|
20
|
+
<slot name="error" {error} />
|
|
21
|
+
{/await}
|
|
22
|
+
{/if}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# TH
|
|
2
|
-
|
|
3
|
-
The TH component has no use outside fo the DataTable, but is used to support
|
|
4
|
-
the filter and sorting functionality for that component.
|
|
5
|
-
|
|
6
|
-
## Props
|
|
7
|
-
|
|
8
|
-
### sort
|
|
9
|
-
`Function`
|
|
10
|
-
|
|
11
|
-
The sorting function to use for the column defined. Should return values that
|
|
12
|
-
match the expected values for `Array.sort`.
|
|
13
|
-
|
|
14
|
-
### filter
|
|
15
|
-
`Function`
|
|
16
|
-
|
|
17
|
-
The function to use for filtering based on the column. The function is given
|
|
18
|
-
2 arguments: a row of data and the text from the filter input field. The
|
|
19
|
-
function should return `true` if the item should be shown. A filter function on
|
|
20
|
-
a specific column does not need to only look at the specified column, but not
|
|
21
|
-
doing could cause confusion for users without proper context.
|
|
1
|
+
# TH
|
|
2
|
+
|
|
3
|
+
The TH component has no use outside fo the DataTable, but is used to support
|
|
4
|
+
the filter and sorting functionality for that component.
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
### sort
|
|
9
|
+
`Function`
|
|
10
|
+
|
|
11
|
+
The sorting function to use for the column defined. Should return values that
|
|
12
|
+
match the expected values for `Array.sort`.
|
|
13
|
+
|
|
14
|
+
### filter
|
|
15
|
+
`Function`
|
|
16
|
+
|
|
17
|
+
The function to use for filtering based on the column. The function is given
|
|
18
|
+
2 arguments: a row of data and the text from the filter input field. The
|
|
19
|
+
function should return `true` if the item should be shown. A filter function on
|
|
20
|
+
a specific column does not need to only look at the specified column, but not
|
|
21
|
+
doing could cause confusion for users without proper context.
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
<svelte:options immutable />
|
|
2
|
-
|
|
3
|
-
<script context="module">
|
|
4
|
-
const sortIcons = {
|
|
5
|
-
"asc": "arrow-
|
|
6
|
-
"desc": "arrow-
|
|
7
|
-
}
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<script>
|
|
11
|
-
import { getContext } from "svelte"
|
|
12
|
-
|
|
13
|
-
import Button from "../../control/button.svelte"
|
|
14
|
-
import Grid from "../../layout/grid.svelte"
|
|
15
|
-
import Icon from "../../info/icon.svelte"
|
|
16
|
-
|
|
17
|
-
import wsx from "../../wsx.mjs"
|
|
18
|
-
import { dtContext } from "../data-table.svelte"
|
|
19
|
-
|
|
20
|
-
export let sort = null
|
|
21
|
-
export let filter = null
|
|
22
|
-
|
|
23
|
-
const context = getContext(dtContext)
|
|
24
|
-
|
|
25
|
-
const setSort = () => $context.updateSort(sort)
|
|
26
|
-
|
|
27
|
-
let value = ""
|
|
28
|
-
$: $context.updateFilter(filter, value)
|
|
29
|
-
|
|
30
|
-
$: wind = {
|
|
31
|
-
...$$restProps,
|
|
32
|
-
p: "0px",
|
|
33
|
-
sel: "none"
|
|
34
|
-
}
|
|
35
|
-
$: sortIcon =
|
|
36
|
-
($context.sorting.base === sort)
|
|
37
|
-
? sortIcons[$context.sorting.direction]
|
|
38
|
-
: "
|
|
39
|
-
</script>
|
|
40
|
-
|
|
41
|
-
<th use:wsx={wind} style="vertical-align: top;">
|
|
42
|
-
<Grid rows="40px min-content" p="0px" gap="0px">
|
|
43
|
-
{#if sort === null}
|
|
44
|
-
<div ws-x="[flex] [fl.cross center] [fl.main center]">
|
|
45
|
-
<slot />
|
|
46
|
-
</div>
|
|
47
|
-
{:else}
|
|
48
|
-
<Button compact r="0px" color="primary" fill={$context.fillHeader}
|
|
49
|
-
t.wt="inherit" on:click={setSort}>
|
|
50
|
-
<slot />
|
|
51
|
-
<Icon name={sortIcon} m.l="4px" t.sz="16px" />
|
|
52
|
-
</Button>
|
|
53
|
-
{/if}
|
|
54
|
-
{#if filter !== null}
|
|
55
|
-
<Grid gap="0px" p="0px" cols="min-content 1fr">
|
|
56
|
-
<Icon name="filter" />
|
|
57
|
-
<input type="text" ws-x="[w.min 20px] [
|
|
58
|
-
</Grid>
|
|
59
|
-
{/if}
|
|
60
|
-
</Grid>
|
|
61
|
-
</th>
|
|
1
|
+
<svelte:options immutable />
|
|
2
|
+
|
|
3
|
+
<script context="module">
|
|
4
|
+
const sortIcons = {
|
|
5
|
+
"asc": "arrow-up",
|
|
6
|
+
"desc": "arrow-down",
|
|
7
|
+
}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import { getContext } from "svelte"
|
|
12
|
+
|
|
13
|
+
import Button from "../../control/button.svelte"
|
|
14
|
+
import Grid from "../../layout/grid.svelte"
|
|
15
|
+
import Icon from "../../info/icon.svelte"
|
|
16
|
+
|
|
17
|
+
import wsx from "../../wsx.mjs"
|
|
18
|
+
import { dtContext } from "../data-table.svelte"
|
|
19
|
+
|
|
20
|
+
export let sort = null
|
|
21
|
+
export let filter = null
|
|
22
|
+
|
|
23
|
+
const context = getContext(dtContext)
|
|
24
|
+
|
|
25
|
+
const setSort = () => $context.updateSort(sort)
|
|
26
|
+
|
|
27
|
+
let value = ""
|
|
28
|
+
$: $context.updateFilter(filter, value)
|
|
29
|
+
|
|
30
|
+
$: wind = {
|
|
31
|
+
...$$restProps,
|
|
32
|
+
p: "0px",
|
|
33
|
+
sel: "none"
|
|
34
|
+
}
|
|
35
|
+
$: sortIcon =
|
|
36
|
+
($context.sorting.base === sort)
|
|
37
|
+
? sortIcons[$context.sorting.direction]
|
|
38
|
+
: "arrow-down-up"
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<th use:wsx={wind} style="vertical-align: top;">
|
|
42
|
+
<Grid rows="40px min-content" p="0px" gap="0px">
|
|
43
|
+
{#if sort === null}
|
|
44
|
+
<div ws-x="[flex] [fl.cross center] [fl.main center]">
|
|
45
|
+
<slot />
|
|
46
|
+
</div>
|
|
47
|
+
{:else}
|
|
48
|
+
<Button compact r="0px" color="primary" fill={$context.fillHeader}
|
|
49
|
+
t.wt="inherit" on:click={setSort}>
|
|
50
|
+
<slot />
|
|
51
|
+
<Icon name={sortIcon} m.l="4px" t.sz="16px" />
|
|
52
|
+
</Button>
|
|
53
|
+
{/if}
|
|
54
|
+
{#if filter !== null}
|
|
55
|
+
<Grid gap="0px" p="0px" cols="min-content 1fr">
|
|
56
|
+
<Icon name="filter" />
|
|
57
|
+
<input type="text" ws-x="[w.min 20px] [outln:focus none]" bind:value />
|
|
58
|
+
</Grid>
|
|
59
|
+
{/if}
|
|
60
|
+
</Grid>
|
|
61
|
+
</th>
|