drab 3.0.0 → 3.0.2
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 +125 -69
- package/dist/components/Breakpoint.svelte +33 -33
- package/dist/components/ContextMenu.svelte +84 -84
- package/dist/components/CopyButton.svelte +64 -61
- package/dist/components/CopyButton.svelte.d.ts +6 -4
- package/dist/components/DataTable.svelte +143 -143
- package/dist/components/Details.svelte +85 -85
- package/dist/components/Editor.svelte +98 -98
- package/dist/components/FrettedChord.svelte +154 -154
- package/dist/components/FullscreenButton.svelte +60 -60
- package/dist/components/Popover.svelte +77 -77
- package/dist/components/ShareButton.svelte +85 -85
- package/dist/components/Sheet.svelte +128 -118
- package/dist/components/Sheet.svelte.d.ts +10 -0
- package/dist/components/YouTube.svelte +33 -33
- package/package.json +81 -81
@@ -1,18 +1,18 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### ShareButton
|
5
|
-
|
6
|
-
Uses the [Navigator API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) to share data. Progressively enhances according to browser support.
|
7
|
-
|
8
|
-
- If the browser cannot share the provided data:
|
9
|
-
- `url` - uses the the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy
|
10
|
-
- `files` - uses a hidden `anchor` element to download the first file in the `files` array
|
11
|
-
- If no JavaScript:
|
12
|
-
- `button` is disabled
|
13
|
-
- `url` - displayed after the `button`
|
14
|
-
|
15
|
-
@props
|
1
|
+
<!--
|
2
|
+
@component
|
3
|
+
|
4
|
+
### ShareButton
|
5
|
+
|
6
|
+
Uses the [Navigator API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) to share data. Progressively enhances according to browser support.
|
7
|
+
|
8
|
+
- If the browser cannot share the provided data:
|
9
|
+
- `url` - uses the the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy
|
10
|
+
- `files` - uses a hidden `anchor` element to download the first file in the `files` array
|
11
|
+
- If no JavaScript:
|
12
|
+
- `button` is disabled
|
13
|
+
- `url` - displayed after the `button`
|
14
|
+
|
15
|
+
@props
|
16
16
|
|
17
17
|
- `classNoscript` - `noscript` class
|
18
18
|
- `class`
|
@@ -20,57 +20,57 @@ Uses the [Navigator API](https://developer.mozilla.org/en-US/docs/Web/API/Naviga
|
|
20
20
|
- `shareData` - [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share)
|
21
21
|
- `title`
|
22
22
|
|
23
|
-
@slots
|
24
|
-
|
25
|
-
| name | purpose | default value |
|
26
|
-
| ---------- | ------------------------------- | ------------- |
|
27
|
-
| `default` | default | `Share` |
|
28
|
-
| `complete` | displays after copy is complete | `Copied` |
|
29
|
-
|
30
|
-
@example
|
23
|
+
@slots
|
24
|
+
|
25
|
+
| name | purpose | default value |
|
26
|
+
| ---------- | ------------------------------- | ------------- |
|
27
|
+
| `default` | default | `Share` |
|
28
|
+
| `complete` | displays after copy is complete | `Copied` |
|
29
|
+
|
30
|
+
@example
|
31
31
|
|
32
32
|
```svelte
|
33
|
-
<script lang="ts">
|
34
|
-
import { ShareButton } from "drab";
|
35
|
-
|
36
|
-
let fileInput: HTMLInputElement;
|
37
|
-
|
38
|
-
let fileShareData: ShareData;
|
39
|
-
|
40
|
-
const onInput = () => {
|
41
|
-
if (fileInput.files) {
|
42
|
-
fileShareData.files = [fileInput.files[0]];
|
43
|
-
}
|
44
|
-
};
|
45
|
-
</script>
|
46
|
-
|
47
|
-
<ShareButton
|
48
|
-
class="btn mb-8"
|
49
|
-
shareData={{
|
50
|
-
text: "Check out this page: ",
|
51
|
-
title: "drab",
|
52
|
-
url: "https://drab.robino.dev",
|
53
|
-
}}
|
54
|
-
>
|
55
|
-
Share URL
|
56
|
-
</ShareButton>
|
57
|
-
|
58
|
-
<div>
|
59
|
-
<label class="label" for="fileInput">Upload File</label>
|
60
|
-
<input
|
61
|
-
type="file"
|
62
|
-
id="fileInput"
|
63
|
-
class="input mb-4"
|
64
|
-
bind:this={fileInput}
|
65
|
-
on:input={onInput}
|
66
|
-
/>
|
67
|
-
<ShareButton class="btn" bind:shareData={fileShareData}>
|
68
|
-
Share File
|
69
|
-
</ShareButton>
|
70
|
-
</div>
|
33
|
+
<script lang="ts">
|
34
|
+
import { ShareButton } from "drab";
|
35
|
+
|
36
|
+
let fileInput: HTMLInputElement;
|
37
|
+
|
38
|
+
let fileShareData: ShareData;
|
39
|
+
|
40
|
+
const onInput = () => {
|
41
|
+
if (fileInput.files) {
|
42
|
+
fileShareData.files = [fileInput.files[0]];
|
43
|
+
}
|
44
|
+
};
|
45
|
+
</script>
|
46
|
+
|
47
|
+
<ShareButton
|
48
|
+
class="btn mb-8"
|
49
|
+
shareData={{
|
50
|
+
text: "Check out this page: ",
|
51
|
+
title: "drab",
|
52
|
+
url: "https://drab.robino.dev",
|
53
|
+
}}
|
54
|
+
>
|
55
|
+
Share URL
|
56
|
+
</ShareButton>
|
57
|
+
|
58
|
+
<div>
|
59
|
+
<label class="label" for="fileInput">Upload File</label>
|
60
|
+
<input
|
61
|
+
type="file"
|
62
|
+
id="fileInput"
|
63
|
+
class="input mb-4"
|
64
|
+
bind:this={fileInput}
|
65
|
+
on:input={onInput}
|
66
|
+
/>
|
67
|
+
<ShareButton class="btn" bind:shareData={fileShareData}>
|
68
|
+
Share File
|
69
|
+
</ShareButton>
|
70
|
+
</div>
|
71
71
|
```
|
72
|
-
-->
|
73
|
-
|
72
|
+
-->
|
73
|
+
|
74
74
|
<script>import { onMount } from "svelte";
|
75
75
|
import { delay } from "../util/delay";
|
76
76
|
let className = "";
|
@@ -107,25 +107,25 @@ const onClick = async () => {
|
|
107
107
|
}
|
108
108
|
};
|
109
109
|
onMount(() => clientJs = true);
|
110
|
-
</script>
|
111
|
-
|
112
|
-
<button
|
113
|
-
type="button"
|
114
|
-
disabled={!clientJs || (!shareData.url && !shareData.files)}
|
115
|
-
on:click={onClick}
|
116
|
-
class={className}
|
117
|
-
{id}
|
118
|
-
{title}
|
119
|
-
>
|
120
|
-
{#if complete}
|
121
|
-
<slot name="complete">Copied</slot>
|
122
|
-
{:else}
|
123
|
-
<slot>Share</slot>
|
124
|
-
{/if}
|
125
|
-
</button>
|
126
|
-
|
127
|
-
<a href="/" bind:this={downloadAnchor} style:display="none">Download</a>
|
128
|
-
|
129
|
-
{#if shareData.url}
|
130
|
-
<noscript><span class={classNoscript}>{shareData.url}</span></noscript>
|
131
|
-
{/if}
|
110
|
+
</script>
|
111
|
+
|
112
|
+
<button
|
113
|
+
type="button"
|
114
|
+
disabled={!clientJs || (!shareData.url && !shareData.files)}
|
115
|
+
on:click={onClick}
|
116
|
+
class={className}
|
117
|
+
{id}
|
118
|
+
{title}
|
119
|
+
>
|
120
|
+
{#if complete}
|
121
|
+
<slot name="complete">Copied</slot>
|
122
|
+
{:else}
|
123
|
+
<slot>Share</slot>
|
124
|
+
{/if}
|
125
|
+
</button>
|
126
|
+
|
127
|
+
<a href="/" bind:this={downloadAnchor} style:display="none">Download</a>
|
128
|
+
|
129
|
+
{#if shareData.url}
|
130
|
+
<noscript><span class={classNoscript}>{shareData.url}</span></noscript>
|
131
|
+
{/if}
|
@@ -1,64 +1,71 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### Sheet
|
5
|
-
|
6
|
-
Creates a sheet element based on the `position` provided. `maxSize` is set to width or height of the sheet depending on the `position` provided. The `transition` is calculated based on the `position` and `maxSize` of the sheet.
|
7
|
-
|
8
|
-
@props
|
9
|
-
|
10
|
-
- `classSheet` - sheet class - not the backdrop
|
11
|
-
- `class`
|
12
|
-
- `display` - controls whether the sheet is displayed
|
13
|
-
- `id`
|
14
|
-
- `maxSize` - max width/height of sheet based on the `side` - can also use css instead
|
15
|
-
- `position` - determines the position of sheet
|
16
|
-
- `transitionSheet` - flies the sheet, set to `false` to remove
|
17
|
-
- `transition` - blurs the entire component, set to `false` to remove
|
18
|
-
|
19
|
-
@slots
|
20
|
-
|
21
|
-
| name | purpose | default value |
|
22
|
-
| ---------- | ------------------------------- | ------------- |
|
23
|
-
| `default` | content | `Content` |
|
24
|
-
|
25
|
-
@
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
>
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
</div>
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
1
|
+
<!--
|
2
|
+
@component
|
3
|
+
|
4
|
+
### Sheet
|
5
|
+
|
6
|
+
Creates a sheet element based on the `position` provided. `maxSize` is set to width or height of the sheet depending on the `position` provided. The `transition` is calculated based on the `position` and `maxSize` of the sheet.
|
7
|
+
|
8
|
+
@props
|
9
|
+
|
10
|
+
- `classSheet` - sheet class - not the backdrop
|
11
|
+
- `class`
|
12
|
+
- `display` - controls whether the sheet is displayed
|
13
|
+
- `id`
|
14
|
+
- `maxSize` - max width/height of sheet based on the `side` - can also use css instead
|
15
|
+
- `position` - determines the position of sheet
|
16
|
+
- `transitionSheet` - flies the sheet, set to `false` to remove
|
17
|
+
- `transition` - blurs the entire component, set to `false` to remove
|
18
|
+
|
19
|
+
@slots
|
20
|
+
|
21
|
+
| name | purpose | default value |
|
22
|
+
| ---------- | ------------------------------- | ------------- |
|
23
|
+
| `default` | content | `Content` |
|
24
|
+
|
25
|
+
@events
|
26
|
+
|
27
|
+
| name | event |
|
28
|
+
| --------- | ------------------ |
|
29
|
+
| `mount` | sheet is mounted |
|
30
|
+
| `destroy` | sheet is destroyed |
|
31
|
+
|
32
|
+
@example
|
33
|
+
|
34
|
+
```svelte
|
35
|
+
<script lang="ts">
|
36
|
+
import { Sheet } from "drab";
|
37
|
+
|
38
|
+
let display = false;
|
39
|
+
</script>
|
40
|
+
|
41
|
+
<button type="button" class="btn" on:click={() => (display = true)}>
|
42
|
+
Open
|
43
|
+
</button>
|
44
|
+
|
45
|
+
<Sheet
|
46
|
+
bind:display
|
47
|
+
class="backdrop-blur"
|
48
|
+
classSheet="p-4 shadow bg-white"
|
49
|
+
position="r"
|
50
|
+
>
|
51
|
+
<div class="mb-4 flex items-center justify-between">
|
52
|
+
<h2 class="my-0">Sheet</h2>
|
53
|
+
<button type="button" class="btn btn-s" on:click={() => (display = false)}>
|
54
|
+
Close
|
55
|
+
</button>
|
56
|
+
</div>
|
57
|
+
<div>
|
58
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
59
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
60
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
61
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
62
|
+
cillum dolore eu fugiat nulla pariatur.
|
63
|
+
</div>
|
64
|
+
</Sheet>
|
65
|
+
```
|
66
|
+
-->
|
67
|
+
|
68
|
+
<script>import { createEventDispatcher, onMount } from "svelte";
|
62
69
|
import {
|
63
70
|
blur,
|
64
71
|
fly
|
@@ -75,14 +82,17 @@ export let position = "l";
|
|
75
82
|
export let maxSize = 488;
|
76
83
|
export let transitionSheet = { duration };
|
77
84
|
let sheet;
|
85
|
+
const dispatch = createEventDispatcher();
|
86
|
+
const close = () => display = false;
|
78
87
|
const onKeyDown = (e) => {
|
79
|
-
if (e.key === "Escape")
|
80
|
-
|
81
|
-
}
|
88
|
+
if (e.key === "Escape")
|
89
|
+
close();
|
82
90
|
};
|
83
|
-
const
|
91
|
+
const lifecycle = (node) => {
|
92
|
+
dispatch("mount");
|
84
93
|
if (node instanceof HTMLElement)
|
85
94
|
node.focus();
|
95
|
+
return { destroy: () => dispatch("destroy") };
|
86
96
|
};
|
87
97
|
if (transitionSheet && !transitionSheet.x && !transitionSheet.y) {
|
88
98
|
if (position === "b") {
|
@@ -101,56 +111,56 @@ onMount(() => {
|
|
101
111
|
transitionSheet = false;
|
102
112
|
}
|
103
113
|
});
|
104
|
-
</script>
|
105
|
-
|
106
|
-
<svelte:body on:keydown={onKeyDown} />
|
107
|
-
|
108
|
-
{#if display}
|
109
|
-
<div
|
110
|
-
transition:blur={transition ? transition : { duration: 0 }}
|
111
|
-
|
112
|
-
class
|
113
|
-
class:d-backdrop-
|
114
|
-
class:d-backdrop-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
style={position === "t" || position === "b"
|
124
|
-
? `max-height: ${maxSize}px;`
|
125
|
-
: `max-width: ${maxSize}px`}
|
126
|
-
class={classSheet}
|
127
|
-
>
|
128
|
-
<slot>Content</slot>
|
129
|
-
</div>
|
130
|
-
<button title="Close" on:click={
|
131
|
-
</div>
|
132
|
-
{/if}
|
133
|
-
|
134
|
-
<style>
|
135
|
-
button {
|
136
|
-
flex-grow: 1;
|
137
|
-
}
|
138
|
-
.d-backdrop {
|
139
|
-
position: fixed;
|
140
|
-
display: flex;
|
141
|
-
top: 0;
|
142
|
-
bottom: 0;
|
143
|
-
left: 0;
|
144
|
-
right: 0;
|
145
|
-
overflow: hidden;
|
146
|
-
}
|
147
|
-
.d-backdrop-bottom {
|
148
|
-
flex-direction: column-reverse;
|
149
|
-
}
|
150
|
-
.d-backdrop-top {
|
151
|
-
flex-direction: column;
|
152
|
-
}
|
153
|
-
.d-backdrop-right {
|
154
|
-
flex-direction: row-reverse;
|
155
|
-
}
|
156
|
-
</style>
|
114
|
+
</script>
|
115
|
+
|
116
|
+
<svelte:body on:keydown={onKeyDown} />
|
117
|
+
|
118
|
+
{#if display}
|
119
|
+
<div
|
120
|
+
transition:blur={transition ? transition : { duration: 0 }}
|
121
|
+
class="d-backdrop {className}"
|
122
|
+
class:d-backdrop-bottom={position === "b"}
|
123
|
+
class:d-backdrop-top={position === "t"}
|
124
|
+
class:d-backdrop-right={position === "r"}
|
125
|
+
{id}
|
126
|
+
>
|
127
|
+
<div
|
128
|
+
bind:this={sheet}
|
129
|
+
transition:fly={transitionSheet ? transitionSheet : { duration: 0 }}
|
130
|
+
use:lifecycle
|
131
|
+
role="dialog"
|
132
|
+
tabindex="-1"
|
133
|
+
style={position === "t" || position === "b"
|
134
|
+
? `max-height: ${maxSize}px;`
|
135
|
+
: `max-width: ${maxSize}px`}
|
136
|
+
class={classSheet}
|
137
|
+
>
|
138
|
+
<slot>Content</slot>
|
139
|
+
</div>
|
140
|
+
<button title="Close" on:click={close}></button>
|
141
|
+
</div>
|
142
|
+
{/if}
|
143
|
+
|
144
|
+
<style>
|
145
|
+
button {
|
146
|
+
flex-grow: 1;
|
147
|
+
}
|
148
|
+
.d-backdrop {
|
149
|
+
position: fixed;
|
150
|
+
display: flex;
|
151
|
+
top: 0;
|
152
|
+
bottom: 0;
|
153
|
+
left: 0;
|
154
|
+
right: 0;
|
155
|
+
overflow: hidden;
|
156
|
+
}
|
157
|
+
.d-backdrop-bottom {
|
158
|
+
flex-direction: column-reverse;
|
159
|
+
}
|
160
|
+
.d-backdrop-top {
|
161
|
+
flex-direction: column;
|
162
|
+
}
|
163
|
+
.d-backdrop-right {
|
164
|
+
flex-direction: row-reverse;
|
165
|
+
}
|
166
|
+
</style>
|
@@ -12,6 +12,9 @@ declare const __propDef: {
|
|
12
12
|
/** flies the sheet, set to `false` to remove */ transitionSheet?: false | FlyParams | undefined;
|
13
13
|
};
|
14
14
|
events: {
|
15
|
+
mount: CustomEvent<any>;
|
16
|
+
destroy: CustomEvent<any>;
|
17
|
+
} & {
|
15
18
|
[evt: string]: CustomEvent<any>;
|
16
19
|
};
|
17
20
|
slots: {
|
@@ -43,6 +46,13 @@ export type SheetSlots = typeof __propDef.slots;
|
|
43
46
|
* | ---------- | ------------------------------- | ------------- |
|
44
47
|
* | `default` | content | `Content` |
|
45
48
|
*
|
49
|
+
* @events
|
50
|
+
*
|
51
|
+
* | name | event |
|
52
|
+
* | --------- | ------------------ |
|
53
|
+
* | `mount` | sheet is mounted |
|
54
|
+
* | `destroy` | sheet is destroyed |
|
55
|
+
*
|
46
56
|
* @example
|
47
57
|
*
|
48
58
|
* ```svelte
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### YouTube
|
5
|
-
|
6
|
-
Embeds a YouTube video `iframe` into a website with the video `uid`, using [www.youtube-nocookie.com](https://support.google.com/youtube/answer/171780?hl=en#zippy=%2Cturn-on-privacy-enhanced-mode).
|
7
|
-
|
8
|
-
@props
|
1
|
+
<!--
|
2
|
+
@component
|
3
|
+
|
4
|
+
### YouTube
|
5
|
+
|
6
|
+
Embeds a YouTube video `iframe` into a website with the video `uid`, using [www.youtube-nocookie.com](https://support.google.com/youtube/answer/171780?hl=en#zippy=%2Cturn-on-privacy-enhanced-mode).
|
7
|
+
|
8
|
+
@props
|
9
9
|
|
10
10
|
- `autoplay` - auto-plays the video
|
11
11
|
- `class`
|
@@ -14,21 +14,21 @@ Embeds a YouTube video `iframe` into a website with the video `uid`, using [www.
|
|
14
14
|
- `title`
|
15
15
|
- `uid` - unique YouTube id
|
16
16
|
|
17
|
-
@example
|
17
|
+
@example
|
18
18
|
|
19
19
|
```svelte
|
20
|
-
<script lang="ts">
|
21
|
-
import { YouTube } from "drab";
|
22
|
-
</script>
|
23
|
-
|
24
|
-
<YouTube
|
25
|
-
class="aspect-video w-full rounded"
|
26
|
-
title="Renegade - Kevin Olusola"
|
27
|
-
uid="gouiY85kD2o"
|
28
|
-
/>
|
20
|
+
<script lang="ts">
|
21
|
+
import { YouTube } from "drab";
|
22
|
+
</script>
|
23
|
+
|
24
|
+
<YouTube
|
25
|
+
class="aspect-video w-full rounded"
|
26
|
+
title="Renegade - Kevin Olusola"
|
27
|
+
uid="gouiY85kD2o"
|
28
|
+
/>
|
29
29
|
```
|
30
|
-
-->
|
31
|
-
|
30
|
+
-->
|
31
|
+
|
32
32
|
<script>let className = "";
|
33
33
|
export { className as class };
|
34
34
|
export let id = "";
|
@@ -36,16 +36,16 @@ export let uid;
|
|
36
36
|
export let title = "";
|
37
37
|
export let autoplay = false;
|
38
38
|
export let start = 0;
|
39
|
-
</script>
|
40
|
-
|
41
|
-
<iframe
|
42
|
-
class={className}
|
43
|
-
{id}
|
44
|
-
src="https://www.youtube-nocookie.com/embed/{uid}?start={start}{autoplay
|
45
|
-
? '&autoplay=1'
|
46
|
-
: ''}"
|
47
|
-
{title}
|
48
|
-
frameborder="0"
|
49
|
-
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
50
|
-
allowfullscreen
|
51
|
-
/>
|
39
|
+
</script>
|
40
|
+
|
41
|
+
<iframe
|
42
|
+
class={className}
|
43
|
+
{id}
|
44
|
+
src="https://www.youtube-nocookie.com/embed/{uid}?start={start}{autoplay
|
45
|
+
? '&autoplay=1'
|
46
|
+
: ''}"
|
47
|
+
{title}
|
48
|
+
frameborder="0"
|
49
|
+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
50
|
+
allowfullscreen
|
51
|
+
/>
|