drab 4.1.6 → 5.0.0-beta.0
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/animate/define.d.ts +2 -0
- package/animate/define.iife.js +1 -0
- package/animate/define.js +1 -0
- package/animate.d.ts +54 -0
- package/animate.iife.js +1 -0
- package/animate.js +1 -0
- package/base/define.d.ts +2 -0
- package/base/define.iife.js +1 -0
- package/base/define.js +1 -0
- package/base.d.ts +69 -0
- package/base.iife.js +1 -0
- package/base.js +1 -0
- package/breakpoint/define.d.ts +2 -0
- package/breakpoint/define.iife.js +1 -0
- package/breakpoint/define.js +1 -0
- package/breakpoint.d.ts +24 -0
- package/breakpoint.iife.js +1 -0
- package/breakpoint.js +1 -0
- package/chunk-2ZZQECRY.js +1 -0
- package/chunk-57VEEUFG.js +1 -0
- package/chunk-5JV4T7GM.js +1 -0
- package/chunk-6HYPZWQ4.js +1 -0
- package/chunk-7F7CQUEG.js +1 -0
- package/chunk-7KU2PRW5.js +1 -0
- package/chunk-7S6DTKGH.js +1 -0
- package/chunk-FNJ7AESC.js +9 -0
- package/chunk-IQJQPZUL.js +1 -0
- package/chunk-JMJUWKN2.js +1 -0
- package/chunk-MXKU7AKV.js +1 -0
- package/chunk-T7RZI3ZL.js +1 -0
- package/chunk-TSTTUEAF.js +1 -0
- package/chunk-VEVFQB5N.js +1 -0
- package/contextmenu/define.d.ts +2 -0
- package/contextmenu/define.iife.js +1 -0
- package/contextmenu/define.js +1 -0
- package/contextmenu.d.ts +15 -0
- package/contextmenu.iife.js +1 -0
- package/contextmenu.js +1 -0
- package/copy/define.d.ts +2 -0
- package/copy/define.iife.js +1 -0
- package/copy/define.js +1 -0
- package/copy.d.ts +13 -0
- package/copy.iife.js +1 -0
- package/copy.js +1 -0
- package/define.d.ts +2 -0
- package/define.iife.js +9 -0
- package/define.js +1 -0
- package/details/define.d.ts +2 -0
- package/details/define.iife.js +1 -0
- package/details/define.js +1 -0
- package/details.d.ts +23 -0
- package/details.iife.js +1 -0
- package/details.js +1 -0
- package/dialog/define.d.ts +2 -0
- package/dialog/define.iife.js +1 -0
- package/dialog/define.js +1 -0
- package/dialog.d.ts +20 -0
- package/dialog.iife.js +1 -0
- package/dialog.js +1 -0
- package/editor/define.d.ts +2 -0
- package/editor/define.iife.js +9 -0
- package/editor/define.js +1 -0
- package/editor.d.ts +58 -0
- package/editor.iife.js +9 -0
- package/editor.js +1 -0
- package/fullscreen/define.d.ts +2 -0
- package/fullscreen/define.iife.js +1 -0
- package/fullscreen/define.js +1 -0
- package/fullscreen.d.ts +23 -0
- package/fullscreen.iife.js +1 -0
- package/fullscreen.js +1 -0
- package/index-22PHGcPf.d.ts +17 -0
- package/index.d.ts +14 -0
- package/index.iife.js +9 -0
- package/index.js +1 -0
- package/package.json +131 -59
- package/popover/define.d.ts +2 -0
- package/popover/define.iife.js +1 -0
- package/popover/define.js +1 -0
- package/popover.d.ts +29 -0
- package/popover.iife.js +1 -0
- package/popover.js +1 -0
- package/share/define.d.ts +2 -0
- package/share/define.iife.js +1 -0
- package/share/define.js +1 -0
- package/share.d.ts +19 -0
- package/share.iife.js +1 -0
- package/share.js +1 -0
- package/tablesort/define.d.ts +2 -0
- package/tablesort/define.iife.js +1 -0
- package/tablesort/define.js +1 -0
- package/tablesort.d.ts +21 -0
- package/tablesort.iife.js +1 -0
- package/tablesort.js +1 -0
- package/youtube/define.d.ts +2 -0
- package/youtube/define.iife.js +1 -0
- package/youtube/define.js +1 -0
- package/youtube.d.ts +29 -0
- package/youtube.iife.js +1 -0
- package/youtube.js +1 -0
- package/LICENSE.md +0 -21
- package/README.md +0 -131
- package/dist/components/Breakpoint.svelte +0 -55
- package/dist/components/Breakpoint.svelte.d.ts +0 -46
- package/dist/components/ContextMenu.svelte +0 -150
- package/dist/components/ContextMenu.svelte.d.ts +0 -76
- package/dist/components/CopyButton.svelte +0 -97
- package/dist/components/CopyButton.svelte.d.ts +0 -60
- package/dist/components/DataTable.svelte +0 -208
- package/dist/components/DataTable.svelte.d.ts +0 -155
- package/dist/components/Details.svelte +0 -101
- package/dist/components/Details.svelte.d.ts +0 -67
- package/dist/components/Editor.svelte +0 -404
- package/dist/components/Editor.svelte.d.ts +0 -111
- package/dist/components/FrettedChord.svelte +0 -213
- package/dist/components/FrettedChord.svelte.d.ts +0 -79
- package/dist/components/FullscreenButton.svelte +0 -95
- package/dist/components/FullscreenButton.svelte.d.ts +0 -62
- package/dist/components/Popover.svelte +0 -153
- package/dist/components/Popover.svelte.d.ts +0 -80
- package/dist/components/ShareButton.svelte +0 -133
- package/dist/components/ShareButton.svelte.d.ts +0 -93
- package/dist/components/Sheet.svelte +0 -180
- package/dist/components/Sheet.svelte.d.ts +0 -99
- package/dist/components/Tablature.svelte +0 -173
- package/dist/components/Tablature.svelte.d.ts +0 -93
- package/dist/components/YouTube.svelte +0 -51
- package/dist/components/YouTube.svelte.d.ts +0 -49
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -14
- package/dist/util/accessibility.d.ts +0 -6
- package/dist/util/accessibility.js +0 -11
- package/dist/util/delay.d.ts +0 -1
- package/dist/util/delay.js +0 -1
- package/dist/util/transition.d.ts +0 -2
- package/dist/util/transition.js +0 -2
@@ -1,213 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### FrettedChord
|
5
|
-
|
6
|
-
Generates a fretted chord `svg` for instruments like guitar and ukulele.
|
7
|
-
|
8
|
-
Try it out and generate code: [FrettedChord Creator](https://svelte.dev/repl/5771d5c3f3c34137a174c8c402ca0b2d?version=4.2.0)
|
9
|
-
|
10
|
-
@props
|
11
|
-
|
12
|
-
- `class`
|
13
|
-
- `id`
|
14
|
-
- `name` - name of chord
|
15
|
-
- `notes` - list of the positioning of the notes required for the chord
|
16
|
-
- `size` - total size of chord square in pixels, defaults to `150`
|
17
|
-
- `strings` - total number of strings for the instrument
|
18
|
-
|
19
|
-
@example
|
20
|
-
|
21
|
-
```svelte
|
22
|
-
<script lang="ts">
|
23
|
-
import { FrettedChord } from "drab";
|
24
|
-
</script>
|
25
|
-
|
26
|
-
<FrettedChord
|
27
|
-
class="font-mono"
|
28
|
-
name="D"
|
29
|
-
notes={[
|
30
|
-
{
|
31
|
-
finger: 0,
|
32
|
-
string: 4,
|
33
|
-
fret: 0,
|
34
|
-
},
|
35
|
-
{
|
36
|
-
finger: 1,
|
37
|
-
string: 3,
|
38
|
-
fret: 2,
|
39
|
-
},
|
40
|
-
{
|
41
|
-
finger: 2,
|
42
|
-
string: 1,
|
43
|
-
fret: 2,
|
44
|
-
},
|
45
|
-
{
|
46
|
-
finger: 3,
|
47
|
-
string: 2,
|
48
|
-
fret: 3,
|
49
|
-
},
|
50
|
-
]}
|
51
|
-
/>
|
52
|
-
```
|
53
|
-
-->
|
54
|
-
|
55
|
-
<script>let className = "";
|
56
|
-
export { className as class };
|
57
|
-
export let id = "";
|
58
|
-
export let strings = 6;
|
59
|
-
export let name = "";
|
60
|
-
export let size = 150;
|
61
|
-
const boxSize = size * 0.61;
|
62
|
-
const offset = (size - boxSize) / 2;
|
63
|
-
const strokeWidth = size / 60;
|
64
|
-
const stringList = Array.from(Array(strings).keys());
|
65
|
-
export let notes = [];
|
66
|
-
let notesList = structuredClone(notes);
|
67
|
-
const usedStrings = notesList.map((note) => note.string);
|
68
|
-
for (let i = 1; i < strings + 1; i++) {
|
69
|
-
if (!usedStrings.includes(i)) {
|
70
|
-
notesList.push({
|
71
|
-
finger: "X",
|
72
|
-
string: i,
|
73
|
-
fret: 0
|
74
|
-
});
|
75
|
-
}
|
76
|
-
}
|
77
|
-
const frets = notesList.map((note) => note.fret).filter((fret) => fret !== 0);
|
78
|
-
if (!frets.length)
|
79
|
-
frets.push(0);
|
80
|
-
const highFret = Math.max(...frets);
|
81
|
-
const lowFret = Math.min(...frets);
|
82
|
-
let fretRange = highFret - lowFret + 1;
|
83
|
-
if (fretRange < 5)
|
84
|
-
fretRange = 5;
|
85
|
-
let firstFret = lowFret;
|
86
|
-
if (firstFret < 4 && highFret < 5) {
|
87
|
-
firstFret = 1;
|
88
|
-
if (lowFret !== 0)
|
89
|
-
fretRange += lowFret - 1;
|
90
|
-
if (lowFret === 2 && highFret < 5)
|
91
|
-
fretRange -= 1;
|
92
|
-
if (lowFret === 3 && highFret < 5)
|
93
|
-
fretRange -= 2;
|
94
|
-
} else {
|
95
|
-
notesList.forEach((note) => {
|
96
|
-
if (note.fret !== 0) {
|
97
|
-
note.fret = note.fret - firstFret + 1;
|
98
|
-
}
|
99
|
-
});
|
100
|
-
}
|
101
|
-
const circleRadius = boxSize / fretRange / 2.3;
|
102
|
-
const stringX = (string) => {
|
103
|
-
return boxSize / (strings - 1) * string + offset;
|
104
|
-
};
|
105
|
-
const fretY = (fret) => {
|
106
|
-
return boxSize / fretRange * fret + offset;
|
107
|
-
};
|
108
|
-
const noteX = (string) => {
|
109
|
-
return boxSize + offset - boxSize / (strings - 1) * (string - 1);
|
110
|
-
};
|
111
|
-
const noteY = (fret) => {
|
112
|
-
return boxSize / fretRange * fret + offset / 2 - boxSize / fretRange / 2;
|
113
|
-
};
|
114
|
-
</script>
|
115
|
-
|
116
|
-
{#if notes.length}
|
117
|
-
<svg
|
118
|
-
width={size}
|
119
|
-
height={size}
|
120
|
-
stroke="currentColor"
|
121
|
-
fill="currentColor"
|
122
|
-
class={className}
|
123
|
-
{id}
|
124
|
-
>
|
125
|
-
<title>{name}</title>
|
126
|
-
|
127
|
-
<!-- BACKGROUND -->
|
128
|
-
<rect
|
129
|
-
width={boxSize}
|
130
|
-
height={boxSize}
|
131
|
-
fill="transparent"
|
132
|
-
x={offset}
|
133
|
-
y={offset / 2}
|
134
|
-
stroke-width={strokeWidth}
|
135
|
-
/>
|
136
|
-
<line
|
137
|
-
x1={offset - strokeWidth / 2}
|
138
|
-
y1={offset / 2 - strokeWidth / 2}
|
139
|
-
x2={boxSize + offset + strokeWidth / 2}
|
140
|
-
y2={offset / 2 - strokeWidth / 2}
|
141
|
-
stroke-width={strokeWidth * 2}
|
142
|
-
/>
|
143
|
-
|
144
|
-
<!-- FRETS -->
|
145
|
-
{#each Array.from(Array(fretRange).keys()) as fret}
|
146
|
-
<line
|
147
|
-
x1={offset}
|
148
|
-
y1={fretY(fret) - offset / 2}
|
149
|
-
x2={boxSize + offset}
|
150
|
-
y2={fretY(fret) - offset / 2}
|
151
|
-
stroke-width={strokeWidth}
|
152
|
-
opacity="0.2"
|
153
|
-
/>
|
154
|
-
{/each}
|
155
|
-
|
156
|
-
<!-- STRINGS -->
|
157
|
-
{#each stringList as string}
|
158
|
-
<line
|
159
|
-
x1={stringX(string)}
|
160
|
-
y1={offset / 2}
|
161
|
-
x2={stringX(string)}
|
162
|
-
y2={boxSize + offset / 2}
|
163
|
-
stroke-width={strokeWidth}
|
164
|
-
/>
|
165
|
-
{/each}
|
166
|
-
|
167
|
-
<!-- NOTES -->
|
168
|
-
{#each notesList as note}
|
169
|
-
{#if note.fret !== 0}
|
170
|
-
<circle
|
171
|
-
cx={noteX(note.string)}
|
172
|
-
cy={noteY(note.fret)}
|
173
|
-
r={circleRadius}
|
174
|
-
/>
|
175
|
-
{/if}
|
176
|
-
{#if note.finger !== 0}
|
177
|
-
<!-- RECOMMENDED FINGER -->
|
178
|
-
<text
|
179
|
-
x={noteX(note.string) - size / 50}
|
180
|
-
y={note.fret === 0
|
181
|
-
? offset / 2 - strokeWidth * 2.4
|
182
|
-
: size - offset * 1.1}
|
183
|
-
color="currentColor"
|
184
|
-
fill="currentColor"
|
185
|
-
font-size={size / 13}
|
186
|
-
>
|
187
|
-
{note.finger}
|
188
|
-
</text>
|
189
|
-
{/if}
|
190
|
-
{/each}
|
191
|
-
|
192
|
-
<!-- CHORD NAME -->
|
193
|
-
<text
|
194
|
-
x={offset}
|
195
|
-
y={size - offset / 2.5}
|
196
|
-
font-size={boxSize / 6}
|
197
|
-
font-weight="600"
|
198
|
-
>
|
199
|
-
{name}
|
200
|
-
</text>
|
201
|
-
|
202
|
-
<!-- STARTING FRET -->
|
203
|
-
{#if firstFret > 1}
|
204
|
-
<text
|
205
|
-
x={size - offset / 1.8}
|
206
|
-
y={offset / 2 + boxSize / 7}
|
207
|
-
font-size={size / 13}
|
208
|
-
>
|
209
|
-
{firstFret}f
|
210
|
-
</text>
|
211
|
-
{/if}
|
212
|
-
</svg>
|
213
|
-
{/if}
|
@@ -1,79 +0,0 @@
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
2
|
-
declare const __propDef: {
|
3
|
-
props: {
|
4
|
-
class?: string | undefined;
|
5
|
-
id?: string | undefined;
|
6
|
-
/** total number of strings for the instrument */ strings?: number | undefined;
|
7
|
-
/** name of chord */ name?: string | undefined;
|
8
|
-
/** total size of chord square in pixels, defaults to `150` */ size?: number | undefined;
|
9
|
-
/** list of the positioning of the notes required for the chord */ notes?: {
|
10
|
-
/** recommended finger to use */
|
11
|
-
finger: number | string;
|
12
|
-
/** string number */
|
13
|
-
string: number;
|
14
|
-
/** fret number */
|
15
|
-
fret: number;
|
16
|
-
}[] | undefined;
|
17
|
-
};
|
18
|
-
events: {
|
19
|
-
[evt: string]: CustomEvent<any>;
|
20
|
-
};
|
21
|
-
slots: {};
|
22
|
-
};
|
23
|
-
export type FrettedChordProps = typeof __propDef.props;
|
24
|
-
export type FrettedChordEvents = typeof __propDef.events;
|
25
|
-
export type FrettedChordSlots = typeof __propDef.slots;
|
26
|
-
/**
|
27
|
-
* ### FrettedChord
|
28
|
-
*
|
29
|
-
* Generates a fretted chord `svg` for instruments like guitar and ukulele.
|
30
|
-
*
|
31
|
-
* Try it out and generate code: [FrettedChord Creator](https://svelte.dev/repl/5771d5c3f3c34137a174c8c402ca0b2d?version=4.2.0)
|
32
|
-
*
|
33
|
-
* @props
|
34
|
-
*
|
35
|
-
* - `class`
|
36
|
-
* - `id`
|
37
|
-
* - `name` - name of chord
|
38
|
-
* - `notes` - list of the positioning of the notes required for the chord
|
39
|
-
* - `size` - total size of chord square in pixels, defaults to `150`
|
40
|
-
* - `strings` - total number of strings for the instrument
|
41
|
-
*
|
42
|
-
* @example
|
43
|
-
*
|
44
|
-
* ```svelte
|
45
|
-
* <script lang="ts">
|
46
|
-
* import { FrettedChord } from "drab";
|
47
|
-
* </script>
|
48
|
-
*
|
49
|
-
* <FrettedChord
|
50
|
-
* class="font-mono"
|
51
|
-
* name="D"
|
52
|
-
* notes={[
|
53
|
-
* {
|
54
|
-
* finger: 0,
|
55
|
-
* string: 4,
|
56
|
-
* fret: 0,
|
57
|
-
* },
|
58
|
-
* {
|
59
|
-
* finger: 1,
|
60
|
-
* string: 3,
|
61
|
-
* fret: 2,
|
62
|
-
* },
|
63
|
-
* {
|
64
|
-
* finger: 2,
|
65
|
-
* string: 1,
|
66
|
-
* fret: 2,
|
67
|
-
* },
|
68
|
-
* {
|
69
|
-
* finger: 3,
|
70
|
-
* string: 2,
|
71
|
-
* fret: 3,
|
72
|
-
* },
|
73
|
-
* ]}
|
74
|
-
* />
|
75
|
-
* ```
|
76
|
-
*/
|
77
|
-
export default class FrettedChord extends SvelteComponent<FrettedChordProps, FrettedChordEvents, FrettedChordSlots> {
|
78
|
-
}
|
79
|
-
export {};
|
@@ -1,95 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### FullscreenButton
|
5
|
-
|
6
|
-
Make the document or a `target` element fullscreen.
|
7
|
-
|
8
|
-
@props
|
9
|
-
|
10
|
-
- `class`
|
11
|
-
- `confirmMessage` - message to display in the `confirm` popup, defaults to empty string `""` - disabled
|
12
|
-
- `id`
|
13
|
-
- `target` - element to make fullscreen (defaults to `document.documentElement` upon mount)
|
14
|
-
- `title`
|
15
|
-
|
16
|
-
@slots
|
17
|
-
|
18
|
-
| name | purpose | default value |
|
19
|
-
| ---------- | ---------------------------------------------- | -------------------- |
|
20
|
-
| `default` | content to display when fullscreen is disabled | `Enabled Fullscreen` |
|
21
|
-
| `enabled` | content to display when fullscreen is enabled | `Exit Fullscreen` |
|
22
|
-
|
23
|
-
@example
|
24
|
-
|
25
|
-
```svelte
|
26
|
-
<script lang="ts">
|
27
|
-
import { FullscreenButton } from "drab";
|
28
|
-
|
29
|
-
let target: HTMLDivElement;
|
30
|
-
</script>
|
31
|
-
|
32
|
-
<FullscreenButton class="button button-primary" />
|
33
|
-
|
34
|
-
<div bind:this={target} class="card mt-8 bg-muted">
|
35
|
-
<div class="mb-2">Target element</div>
|
36
|
-
<FullscreenButton {target} class="button button-primary">
|
37
|
-
Enable Element Fullscreen
|
38
|
-
</FullscreenButton>
|
39
|
-
</div>
|
40
|
-
```
|
41
|
-
-->
|
42
|
-
|
43
|
-
<script>import { onMount } from "svelte";
|
44
|
-
let className = "";
|
45
|
-
export { className as class };
|
46
|
-
export let id = "";
|
47
|
-
export let title = "";
|
48
|
-
export let target = null;
|
49
|
-
export let confirmMessage = "";
|
50
|
-
let disabled = true;
|
51
|
-
let fullscreen = false;
|
52
|
-
const onClick = () => {
|
53
|
-
if (fullscreen) {
|
54
|
-
document.exitFullscreen();
|
55
|
-
} else {
|
56
|
-
if (target && target.requestFullscreen) {
|
57
|
-
if (confirmMessage) {
|
58
|
-
const permission = confirm(confirmMessage);
|
59
|
-
if (permission)
|
60
|
-
target.requestFullscreen();
|
61
|
-
} else {
|
62
|
-
target.requestFullscreen();
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
};
|
67
|
-
const syncFullscreen = () => {
|
68
|
-
fullscreen = document.fullscreenElement !== null;
|
69
|
-
};
|
70
|
-
onMount(() => {
|
71
|
-
if (document.documentElement.requestFullscreen) {
|
72
|
-
syncFullscreen();
|
73
|
-
disabled = false;
|
74
|
-
}
|
75
|
-
if (!target)
|
76
|
-
target = document.documentElement;
|
77
|
-
});
|
78
|
-
</script>
|
79
|
-
|
80
|
-
<svelte:window on:fullscreenchange={syncFullscreen} />
|
81
|
-
|
82
|
-
<button
|
83
|
-
type="button"
|
84
|
-
{disabled}
|
85
|
-
on:click={onClick}
|
86
|
-
class={className}
|
87
|
-
{id}
|
88
|
-
{title}
|
89
|
-
>
|
90
|
-
{#if fullscreen}
|
91
|
-
<slot name="enabled">Exit Fullscreen</slot>
|
92
|
-
{:else}
|
93
|
-
<slot>Enable Fullscreen</slot>
|
94
|
-
{/if}
|
95
|
-
</button>
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
2
|
-
declare const __propDef: {
|
3
|
-
props: {
|
4
|
-
class?: string | undefined;
|
5
|
-
id?: string | undefined;
|
6
|
-
title?: string | undefined;
|
7
|
-
/** element to make fullscreen (defaults to `document.documentElement` upon mount) */ target?: HTMLElement | null | undefined;
|
8
|
-
/** message to display in the `confirm` popup, defaults to empty string `""` - disabled */ confirmMessage?: string | undefined;
|
9
|
-
};
|
10
|
-
events: {
|
11
|
-
[evt: string]: CustomEvent<any>;
|
12
|
-
};
|
13
|
-
slots: {
|
14
|
-
enabled: {};
|
15
|
-
default: {};
|
16
|
-
};
|
17
|
-
};
|
18
|
-
export type FullscreenButtonProps = typeof __propDef.props;
|
19
|
-
export type FullscreenButtonEvents = typeof __propDef.events;
|
20
|
-
export type FullscreenButtonSlots = typeof __propDef.slots;
|
21
|
-
/**
|
22
|
-
* ### FullscreenButton
|
23
|
-
*
|
24
|
-
* Make the document or a `target` element fullscreen.
|
25
|
-
*
|
26
|
-
* @props
|
27
|
-
*
|
28
|
-
* - `class`
|
29
|
-
* - `confirmMessage` - message to display in the `confirm` popup, defaults to empty string `""` - disabled
|
30
|
-
* - `id`
|
31
|
-
* - `target` - element to make fullscreen (defaults to `document.documentElement` upon mount)
|
32
|
-
* - `title`
|
33
|
-
*
|
34
|
-
* @slots
|
35
|
-
*
|
36
|
-
* | name | purpose | default value |
|
37
|
-
* | ---------- | ---------------------------------------------- | -------------------- |
|
38
|
-
* | `default` | content to display when fullscreen is disabled | `Enabled Fullscreen` |
|
39
|
-
* | `enabled` | content to display when fullscreen is enabled | `Exit Fullscreen` |
|
40
|
-
*
|
41
|
-
* @example
|
42
|
-
*
|
43
|
-
* ```svelte
|
44
|
-
* <script lang="ts">
|
45
|
-
* import { FullscreenButton } from "drab";
|
46
|
-
*
|
47
|
-
* let target: HTMLDivElement;
|
48
|
-
* </script>
|
49
|
-
*
|
50
|
-
* <FullscreenButton class="button button-primary" />
|
51
|
-
*
|
52
|
-
* <div bind:this={target} class="card mt-8 bg-muted">
|
53
|
-
* <div class="mb-2">Target element</div>
|
54
|
-
* <FullscreenButton {target} class="button button-primary">
|
55
|
-
* Enable Element Fullscreen
|
56
|
-
* </FullscreenButton>
|
57
|
-
* </div>
|
58
|
-
* ```
|
59
|
-
*/
|
60
|
-
export default class FullscreenButton extends SvelteComponent<FullscreenButtonProps, FullscreenButtonEvents, FullscreenButtonSlots> {
|
61
|
-
}
|
62
|
-
export {};
|
@@ -1,153 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### Popover
|
5
|
-
|
6
|
-
Displays a popover in relation to the `target`.
|
7
|
-
|
8
|
-
- Does not require the target to be `position: relative;`
|
9
|
-
- Adjusts position in case the popover renders outside of the viewport
|
10
|
-
|
11
|
-
@props
|
12
|
-
|
13
|
-
- `class`
|
14
|
-
- `display` - shows / hides the popover
|
15
|
-
- `id`
|
16
|
-
- `position` - where the popover is displayed in relation to the `target`, ex: `br` is bottom, right aligned
|
17
|
-
- `target` - target element to position the popover in relation to
|
18
|
-
- `transition` - scales the popover, set to `false` to disable
|
19
|
-
|
20
|
-
@slots
|
21
|
-
|
22
|
-
| name | purpose | default value |
|
23
|
-
| ---------- | ------------------------------- | ------------- |
|
24
|
-
| `default` | default | Popover |
|
25
|
-
|
26
|
-
@example
|
27
|
-
|
28
|
-
```svelte
|
29
|
-
<script lang="ts">
|
30
|
-
import { Popover } from "drab";
|
31
|
-
|
32
|
-
let target: HTMLButtonElement;
|
33
|
-
|
34
|
-
let display = false;
|
35
|
-
|
36
|
-
const open = () => (display = true);
|
37
|
-
const close = () => (display = false);
|
38
|
-
</script>
|
39
|
-
|
40
|
-
<button
|
41
|
-
class="button button-primary"
|
42
|
-
type="button"
|
43
|
-
bind:this={target}
|
44
|
-
on:click={open}
|
45
|
-
>
|
46
|
-
Open
|
47
|
-
</button>
|
48
|
-
|
49
|
-
<Popover {target} bind:display class="p-2">
|
50
|
-
<div class="card flex w-48 flex-col gap-2 p-2 shadow-md">
|
51
|
-
<div class="font-bold">Bottom</div>
|
52
|
-
<button class="button button-secondary" on:click={close}>Close</button>
|
53
|
-
<button class="button button-secondary" on:click={close}>Close</button>
|
54
|
-
<button class="button button-secondary" on:click={close}>Close</button>
|
55
|
-
</div>
|
56
|
-
</Popover>
|
57
|
-
```
|
58
|
-
-->
|
59
|
-
|
60
|
-
<script>import { prefersReducedMotion } from "../util/accessibility";
|
61
|
-
import { duration, start } from "../util/transition";
|
62
|
-
import { onMount, tick } from "svelte";
|
63
|
-
import { scale } from "svelte/transition";
|
64
|
-
let className = "";
|
65
|
-
export { className as class };
|
66
|
-
export let id = "";
|
67
|
-
export let display = true;
|
68
|
-
export let position = "b";
|
69
|
-
export let target;
|
70
|
-
export let transition = { duration, start };
|
71
|
-
let popover;
|
72
|
-
let coordinates = { x: 0, y: 0 };
|
73
|
-
const setPosition = async () => {
|
74
|
-
if (position.startsWith("t") || position.startsWith("b")) {
|
75
|
-
if (position.startsWith("t")) {
|
76
|
-
coordinates.y = -popover.offsetHeight;
|
77
|
-
} else {
|
78
|
-
coordinates.y = target.offsetHeight;
|
79
|
-
}
|
80
|
-
if (position.endsWith("l")) {
|
81
|
-
coordinates.x = 0;
|
82
|
-
} else if (position.endsWith("r")) {
|
83
|
-
coordinates.x = target.offsetWidth - popover.offsetWidth;
|
84
|
-
} else {
|
85
|
-
coordinates.x = target.offsetWidth / 2 - popover.offsetWidth / 2;
|
86
|
-
}
|
87
|
-
} else {
|
88
|
-
if (position.startsWith("l")) {
|
89
|
-
coordinates.x = -popover.offsetWidth;
|
90
|
-
} else {
|
91
|
-
coordinates.x = target.offsetWidth;
|
92
|
-
}
|
93
|
-
if (position.endsWith("t")) {
|
94
|
-
coordinates.y = 0;
|
95
|
-
} else if (position.endsWith("b")) {
|
96
|
-
coordinates.y = target.offsetHeight - popover.offsetHeight;
|
97
|
-
} else {
|
98
|
-
coordinates.y = target.offsetHeight / 2 - popover.offsetHeight / 2;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
const targetRect = target.getBoundingClientRect();
|
102
|
-
coordinates.x += targetRect.x + window.scrollX;
|
103
|
-
coordinates.y += targetRect.y + window.scrollY;
|
104
|
-
await tick();
|
105
|
-
const popoverRect = popover.getBoundingClientRect();
|
106
|
-
const extraMargin = 10;
|
107
|
-
if (popoverRect.x < extraMargin) {
|
108
|
-
coordinates.x += Math.abs(popoverRect.x) + extraMargin;
|
109
|
-
} else if (popoverRect.x + popover.offsetWidth > window.innerWidth) {
|
110
|
-
coordinates.x -= popoverRect.x + popover.offsetWidth - window.innerWidth + extraMargin;
|
111
|
-
}
|
112
|
-
if (popoverRect.y < 0) {
|
113
|
-
coordinates.y += Math.abs(popoverRect.y) + extraMargin;
|
114
|
-
} else if (popoverRect.y + popover.offsetHeight > window.innerHeight) {
|
115
|
-
coordinates.y -= popoverRect.y + popover.offsetHeight - window.innerHeight;
|
116
|
-
}
|
117
|
-
};
|
118
|
-
const onKeyDown = (e) => {
|
119
|
-
if (e.key === "Escape") {
|
120
|
-
display = false;
|
121
|
-
}
|
122
|
-
};
|
123
|
-
$:
|
124
|
-
if (target && popover)
|
125
|
-
setPosition();
|
126
|
-
onMount(() => {
|
127
|
-
if (prefersReducedMotion())
|
128
|
-
transition = false;
|
129
|
-
});
|
130
|
-
</script>
|
131
|
-
|
132
|
-
<svelte:body on:keydown={onKeyDown} />
|
133
|
-
|
134
|
-
{#if display}
|
135
|
-
<div
|
136
|
-
role="dialog"
|
137
|
-
bind:this={popover}
|
138
|
-
class={className}
|
139
|
-
{id}
|
140
|
-
style:top="{coordinates.y}px"
|
141
|
-
style:left="{coordinates.x}px"
|
142
|
-
transition:scale={transition ? transition : { duration: 0 }}
|
143
|
-
>
|
144
|
-
<slot>Popover</slot>
|
145
|
-
</div>
|
146
|
-
{/if}
|
147
|
-
|
148
|
-
<style>
|
149
|
-
div {
|
150
|
-
position: absolute;
|
151
|
-
margin: 0;
|
152
|
-
}
|
153
|
-
</style>
|
@@ -1,80 +0,0 @@
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
2
|
-
import { type ScaleParams } from "svelte/transition";
|
3
|
-
declare const __propDef: {
|
4
|
-
props: {
|
5
|
-
class?: string | undefined;
|
6
|
-
id?: string | undefined;
|
7
|
-
/** shows / hides the popover */ display?: boolean | undefined;
|
8
|
-
/** where the popover is displayed in relation to the `target`, ex: `br` is bottom, right aligned */ position?: ("tr" | "tl" | "t" | "rt" | "r" | "rb" | "br" | "b" | "bl" | "lb" | "l" | "lt") | undefined;
|
9
|
-
/** target element to position the popover in relation to */ target: HTMLElement;
|
10
|
-
/** scales the popover, set to `false` to disable */ transition?: false | ScaleParams | undefined;
|
11
|
-
};
|
12
|
-
events: {
|
13
|
-
[evt: string]: CustomEvent<any>;
|
14
|
-
};
|
15
|
-
slots: {
|
16
|
-
default: {};
|
17
|
-
};
|
18
|
-
};
|
19
|
-
export type PopoverProps = typeof __propDef.props;
|
20
|
-
export type PopoverEvents = typeof __propDef.events;
|
21
|
-
export type PopoverSlots = typeof __propDef.slots;
|
22
|
-
/**
|
23
|
-
* ### Popover
|
24
|
-
*
|
25
|
-
* Displays a popover in relation to the `target`.
|
26
|
-
*
|
27
|
-
* - Does not require the target to be `position: relative;`
|
28
|
-
* - Adjusts position in case the popover renders outside of the viewport
|
29
|
-
*
|
30
|
-
* @props
|
31
|
-
*
|
32
|
-
* - `class`
|
33
|
-
* - `display` - shows / hides the popover
|
34
|
-
* - `id`
|
35
|
-
* - `position` - where the popover is displayed in relation to the `target`, ex: `br` is bottom, right aligned
|
36
|
-
* - `target` - target element to position the popover in relation to
|
37
|
-
* - `transition` - scales the popover, set to `false` to disable
|
38
|
-
*
|
39
|
-
* @slots
|
40
|
-
*
|
41
|
-
* | name | purpose | default value |
|
42
|
-
* | ---------- | ------------------------------- | ------------- |
|
43
|
-
* | `default` | default | Popover |
|
44
|
-
*
|
45
|
-
* @example
|
46
|
-
*
|
47
|
-
* ```svelte
|
48
|
-
* <script lang="ts">
|
49
|
-
* import { Popover } from "drab";
|
50
|
-
*
|
51
|
-
* let target: HTMLButtonElement;
|
52
|
-
*
|
53
|
-
* let display = false;
|
54
|
-
*
|
55
|
-
* const open = () => (display = true);
|
56
|
-
* const close = () => (display = false);
|
57
|
-
* </script>
|
58
|
-
*
|
59
|
-
* <button
|
60
|
-
* class="button button-primary"
|
61
|
-
* type="button"
|
62
|
-
* bind:this={target}
|
63
|
-
* on:click={open}
|
64
|
-
* >
|
65
|
-
* Open
|
66
|
-
* </button>
|
67
|
-
*
|
68
|
-
* <Popover {target} bind:display class="p-2">
|
69
|
-
* <div class="card flex w-48 flex-col gap-2 p-2 shadow-md">
|
70
|
-
* <div class="font-bold">Bottom</div>
|
71
|
-
* <button class="button button-secondary" on:click={close}>Close</button>
|
72
|
-
* <button class="button button-secondary" on:click={close}>Close</button>
|
73
|
-
* <button class="button button-secondary" on:click={close}>Close</button>
|
74
|
-
* </div>
|
75
|
-
* </Popover>
|
76
|
-
* ```
|
77
|
-
*/
|
78
|
-
export default class Popover extends SvelteComponent<PopoverProps, PopoverEvents, PopoverSlots> {
|
79
|
-
}
|
80
|
-
export {};
|