drab 2.8.1 → 2.8.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/dist/components/ContextMenu.svelte +8 -7
- package/dist/components/ContextMenu.svelte.d.ts +4 -4
- package/dist/components/DataTable.svelte +87 -87
- package/dist/components/FullscreenButton.svelte +2 -2
- package/dist/components/FullscreenButton.svelte.d.ts +2 -2
- package/dist/components/Popover.svelte +6 -6
- package/dist/components/Popover.svelte.d.ts +5 -5
- package/dist/util/transition.d.ts +1 -0
- package/dist/util/transition.js +1 -0
- package/package.json +3 -1
@@ -11,7 +11,7 @@ Displays when the `target` element is right clicked, or long pressed on mobile.
|
|
11
11
|
- `display` - shows / hides the menu
|
12
12
|
- `id`
|
13
13
|
- `target` - target element to right click, defaults to the parent element
|
14
|
-
- `transition` -
|
14
|
+
- `transition` - scales the menu, set to `false` to disable
|
15
15
|
|
16
16
|
@slots
|
17
17
|
|
@@ -40,7 +40,7 @@ Displays when the `target` element is right clicked, or long pressed on mobile.
|
|
40
40
|
</ContextMenu>
|
41
41
|
</div>
|
42
42
|
|
43
|
-
<button class="btn" bind:this={target}>Target Right Click</button>
|
43
|
+
<button type="button" class="btn" bind:this={target}>Target Right Click</button>
|
44
44
|
<ContextMenu {target}>
|
45
45
|
<div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
|
46
46
|
<div class="font-bold">Context Menu</div>
|
@@ -53,15 +53,15 @@ Displays when the `target` element is right clicked, or long pressed on mobile.
|
|
53
53
|
-->
|
54
54
|
|
55
55
|
<script>import { onMount, tick } from "svelte";
|
56
|
-
import {
|
57
|
-
import { duration } from "../util/transition";
|
56
|
+
import { scale } from "svelte/transition";
|
57
|
+
import { duration, start } from "../util/transition";
|
58
58
|
import { prefersReducedMotion } from "../util/accessibility";
|
59
59
|
import { delay } from "../util/delay";
|
60
60
|
let className = "";
|
61
61
|
export { className as class };
|
62
62
|
export let id = "";
|
63
63
|
export let display = false;
|
64
|
-
export let transition = { duration };
|
64
|
+
export let transition = { duration, start };
|
65
65
|
export let target = null;
|
66
66
|
let contextMenu;
|
67
67
|
let base;
|
@@ -102,11 +102,12 @@ const onTouchStart = (e) => {
|
|
102
102
|
const onTouchEnd = () => {
|
103
103
|
clearTimeout(timer);
|
104
104
|
};
|
105
|
-
onMount(() => {
|
105
|
+
onMount(async () => {
|
106
106
|
if (prefersReducedMotion()) {
|
107
107
|
if (transition)
|
108
108
|
transition.duration = 0;
|
109
109
|
}
|
110
|
+
await tick();
|
110
111
|
if (!target) {
|
111
112
|
target = base.parentElement;
|
112
113
|
}
|
@@ -131,7 +132,7 @@ onMount(() => {
|
|
131
132
|
bind:this={contextMenu}
|
132
133
|
style:top="{coordinates.y}px"
|
133
134
|
style:left="{coordinates.x}px"
|
134
|
-
transition:
|
135
|
+
transition:scale={transition ? transition : { duration: 0 }}
|
135
136
|
>
|
136
137
|
<slot>Context Menu</slot>
|
137
138
|
</div>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
2
|
-
import { type
|
2
|
+
import { type ScaleParams } from "svelte/transition";
|
3
3
|
declare const __propDef: {
|
4
4
|
props: {
|
5
5
|
class?: string | undefined;
|
6
6
|
id?: string | undefined;
|
7
7
|
/** shows / hides the menu */ display?: boolean | undefined;
|
8
|
-
/**
|
8
|
+
/** scales the menu, set to `false` to disable */ transition?: false | ScaleParams | undefined;
|
9
9
|
/** target element to right click, defaults to the parent element */ target?: HTMLElement | null | undefined;
|
10
10
|
};
|
11
11
|
events: {
|
@@ -29,7 +29,7 @@ export type ContextMenuSlots = typeof __propDef.slots;
|
|
29
29
|
* - `display` - shows / hides the menu
|
30
30
|
* - `id`
|
31
31
|
* - `target` - target element to right click, defaults to the parent element
|
32
|
-
* - `transition` -
|
32
|
+
* - `transition` - scales the menu, set to `false` to disable
|
33
33
|
*
|
34
34
|
* @slots
|
35
35
|
*
|
@@ -58,7 +58,7 @@ export type ContextMenuSlots = typeof __propDef.slots;
|
|
58
58
|
* </ContextMenu>
|
59
59
|
* </div>
|
60
60
|
*
|
61
|
-
* <button class="btn" bind:this={target}>Target Right Click</button>
|
61
|
+
* <button type="button" class="btn" bind:this={target}>Target Right Click</button>
|
62
62
|
* <ContextMenu {target}>
|
63
63
|
* <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
|
64
64
|
* <div class="font-bold">Context Menu</div>
|
@@ -1,11 +1,11 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### DataTable
|
5
|
-
|
6
|
-
Data table to display an array of JS objects. Provides sorting and pagination. Set the `maxRows` prop to enable pagination. Data can be styled conditionally with slot props.
|
7
|
-
|
8
|
-
@props
|
1
|
+
<!--
|
2
|
+
@component
|
3
|
+
|
4
|
+
### DataTable
|
5
|
+
|
6
|
+
Data table to display an array of JS objects. Provides sorting and pagination. Set the `maxRows` prop to enable pagination. Data can be styled conditionally with slot props.
|
7
|
+
|
8
|
+
@props
|
9
9
|
|
10
10
|
- `ascending` - current sort order
|
11
11
|
- `classButton` - `button` class
|
@@ -32,17 +32,17 @@ Data table to display an array of JS objects. Provides sorting and pagination. S
|
|
32
32
|
- `sortBy` - column to sort by, defaults to first column
|
33
33
|
- `transition` - fades the rows in, set to `false` to disable
|
34
34
|
|
35
|
-
@slots
|
36
|
-
|
37
|
-
| name | purpose | default value | slot props |
|
38
|
-
| ------------ | ------------------------ | -------------------------------- | ------------------------------ |
|
39
|
-
| `next` | next button contents | `Next` | `currentPage` |
|
40
|
-
| `pageNumber` | page numbers | `currentPage` / `numberOfPages` | `currentPage`, `numberOfPages` |
|
41
|
-
| `previous` | previous button contents | `Previous` | `currentPage` |
|
42
|
-
| `td` | td contents | `Previous` | `column`, `row` |
|
43
|
-
| `th` | th contents | `Previous` | `column` |
|
44
|
-
|
45
|
-
@example
|
35
|
+
@slots
|
36
|
+
|
37
|
+
| name | purpose | default value | slot props |
|
38
|
+
| ------------ | ------------------------ | -------------------------------- | ------------------------------ |
|
39
|
+
| `next` | next button contents | `Next` | `currentPage` |
|
40
|
+
| `pageNumber` | page numbers | `currentPage` / `numberOfPages` | `currentPage`, `numberOfPages` |
|
41
|
+
| `previous` | previous button contents | `Previous` | `currentPage` |
|
42
|
+
| `td` | td contents | `Previous` | `column`, `row` |
|
43
|
+
| `th` | th contents | `Previous` | `column` |
|
44
|
+
|
45
|
+
@example
|
46
46
|
|
47
47
|
```svelte
|
48
48
|
<script lang="ts">
|
@@ -106,10 +106,10 @@ Data table to display an array of JS objects. Provides sorting and pagination. S
|
|
106
106
|
</svelte:fragment>
|
107
107
|
</DataTable>
|
108
108
|
```
|
109
|
-
-->
|
110
|
-
|
111
|
-
<script context="module"></script>
|
112
|
-
|
109
|
+
-->
|
110
|
+
|
111
|
+
<script context="module"></script>
|
112
|
+
|
113
113
|
<script>import { onMount } from "svelte";
|
114
114
|
import { fade } from "svelte/transition";
|
115
115
|
import { duration } from "../util/transition";
|
@@ -195,67 +195,67 @@ onMount(() => {
|
|
195
195
|
}
|
196
196
|
clientJs = true;
|
197
197
|
});
|
198
|
-
</script>
|
199
|
-
|
200
|
-
<div class={className} {id}>
|
201
|
-
<table class={classTable} id={idTable}>
|
202
|
-
<thead class={classThead}>
|
203
|
-
<tr class={classTheadTr}>
|
204
|
-
{#each columns as column}
|
205
|
-
<th
|
206
|
-
class="{classTh} {sortBy === column ? classThSorted : ''}"
|
207
|
-
on:click={() => sort(column)}
|
208
|
-
>
|
209
|
-
<slot name="th" {column}>{column}</slot>
|
210
|
-
</th>
|
211
|
-
{/each}
|
212
|
-
</tr>
|
213
|
-
</thead>
|
214
|
-
<tbody class={classTbody}>
|
215
|
-
{#each data as row, i}
|
216
|
-
{#if showRow(i, currentPage)}
|
217
|
-
<tr
|
218
|
-
in:fade={transition ? transition : { duration: 0 }}
|
219
|
-
class={classTbodyTr}
|
220
|
-
>
|
221
|
-
{#each columns as column}
|
222
|
-
<td class="{classTd} {sortBy === column ? classTdSorted : ''}">
|
223
|
-
<slot name="td" {row} {column}>{row[column]}</slot>
|
224
|
-
</td>
|
225
|
-
{/each}
|
226
|
-
</tr>
|
227
|
-
{/if}
|
228
|
-
{/each}
|
229
|
-
</tbody>
|
230
|
-
</table>
|
231
|
-
|
232
|
-
{#if maxRows}
|
233
|
-
<div class={classFooter}>
|
234
|
-
<div class={classPageNumber}>
|
235
|
-
<slot name="pageNumber" {currentPage} {numberOfPages}>
|
236
|
-
{currentPage} / {numberOfPages}
|
237
|
-
</slot>
|
238
|
-
</div>
|
239
|
-
<div class={classPageControls}>
|
240
|
-
<button
|
241
|
-
type="button"
|
242
|
-
class={classButton}
|
243
|
-
disabled={!clientJs || currentPage < 2}
|
244
|
-
on:click={() => currentPage--}
|
245
|
-
>
|
246
|
-
<slot name="previous" {currentPage}>Previous</slot>
|
247
|
-
</button>
|
248
|
-
<button
|
249
|
-
type="button"
|
250
|
-
class={classButton}
|
251
|
-
disabled={!clientJs || currentPage >= numberOfPages}
|
252
|
-
on:click={() => currentPage++}
|
253
|
-
>
|
254
|
-
<slot name="next" {currentPage}>Next</slot>
|
255
|
-
</button>
|
256
|
-
</div>
|
257
|
-
</div>
|
258
|
-
|
259
|
-
<noscript><div class={classNoscript}>{messageNoScript}</div></noscript>
|
260
|
-
{/if}
|
261
|
-
</div>
|
198
|
+
</script>
|
199
|
+
|
200
|
+
<div class={className} {id}>
|
201
|
+
<table class={classTable} id={idTable}>
|
202
|
+
<thead class={classThead}>
|
203
|
+
<tr class={classTheadTr}>
|
204
|
+
{#each columns as column}
|
205
|
+
<th
|
206
|
+
class="{classTh} {sortBy === column ? classThSorted : ''}"
|
207
|
+
on:click={() => sort(column)}
|
208
|
+
>
|
209
|
+
<slot name="th" {column}>{column}</slot>
|
210
|
+
</th>
|
211
|
+
{/each}
|
212
|
+
</tr>
|
213
|
+
</thead>
|
214
|
+
<tbody class={classTbody}>
|
215
|
+
{#each data as row, i}
|
216
|
+
{#if showRow(i, currentPage)}
|
217
|
+
<tr
|
218
|
+
in:fade={transition ? transition : { duration: 0 }}
|
219
|
+
class={classTbodyTr}
|
220
|
+
>
|
221
|
+
{#each columns as column}
|
222
|
+
<td class="{classTd} {sortBy === column ? classTdSorted : ''}">
|
223
|
+
<slot name="td" {row} {column}>{row[column]}</slot>
|
224
|
+
</td>
|
225
|
+
{/each}
|
226
|
+
</tr>
|
227
|
+
{/if}
|
228
|
+
{/each}
|
229
|
+
</tbody>
|
230
|
+
</table>
|
231
|
+
|
232
|
+
{#if maxRows}
|
233
|
+
<div class={classFooter}>
|
234
|
+
<div class={classPageNumber}>
|
235
|
+
<slot name="pageNumber" {currentPage} {numberOfPages}>
|
236
|
+
{currentPage} / {numberOfPages}
|
237
|
+
</slot>
|
238
|
+
</div>
|
239
|
+
<div class={classPageControls}>
|
240
|
+
<button
|
241
|
+
type="button"
|
242
|
+
class={classButton}
|
243
|
+
disabled={!clientJs || currentPage < 2}
|
244
|
+
on:click={() => currentPage--}
|
245
|
+
>
|
246
|
+
<slot name="previous" {currentPage}>Previous</slot>
|
247
|
+
</button>
|
248
|
+
<button
|
249
|
+
type="button"
|
250
|
+
class={classButton}
|
251
|
+
disabled={!clientJs || currentPage >= numberOfPages}
|
252
|
+
on:click={() => currentPage++}
|
253
|
+
>
|
254
|
+
<slot name="next" {currentPage}>Next</slot>
|
255
|
+
</button>
|
256
|
+
</div>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
<noscript><div class={classNoscript}>{messageNoScript}</div></noscript>
|
260
|
+
{/if}
|
261
|
+
</div>
|
@@ -30,9 +30,9 @@ Make the document or a specific element fullscreen.
|
|
30
30
|
let target: HTMLDivElement;
|
31
31
|
</script>
|
32
32
|
|
33
|
-
<FullscreenButton class="btn
|
33
|
+
<FullscreenButton class="btn" />
|
34
34
|
|
35
|
-
<div bind:this={target} class="rounded bg-neutral-800 p-4 text-neutral-50">
|
35
|
+
<div bind:this={target} class="mt-8 rounded bg-neutral-800 p-4 text-neutral-50">
|
36
36
|
<div class="mb-2">Target element</div>
|
37
37
|
<FullscreenButton {target} class="btn btn-s bg-neutral-50">
|
38
38
|
Enable Element Fullscreen
|
@@ -49,9 +49,9 @@ export type FullscreenButtonSlots = typeof __propDef.slots;
|
|
49
49
|
* let target: HTMLDivElement;
|
50
50
|
* </script>
|
51
51
|
*
|
52
|
-
* <FullscreenButton class="btn
|
52
|
+
* <FullscreenButton class="btn" />
|
53
53
|
*
|
54
|
-
* <div bind:this={target} class="rounded bg-neutral-800 p-4 text-neutral-50">
|
54
|
+
* <div bind:this={target} class="mt-8 rounded bg-neutral-800 p-4 text-neutral-50">
|
55
55
|
* <div class="mb-2">Target element</div>
|
56
56
|
* <FullscreenButton {target} class="btn btn-s bg-neutral-50">
|
57
57
|
* Enable Element Fullscreen
|
@@ -10,9 +10,9 @@ Displays a popover relatively positioned to the target. Does not require the tar
|
|
10
10
|
- `class`
|
11
11
|
- `display` - shows / hides the popover
|
12
12
|
- `id`
|
13
|
-
- `position` - where the popover is displayed in relation to the target
|
13
|
+
- `position` - where the popover is displayed in relation to the `target`
|
14
14
|
- `target` - target element to position the popover in relation to
|
15
|
-
- `transition` -
|
15
|
+
- `transition` - scales the popover, set to `false` to disable
|
16
16
|
|
17
17
|
@slots
|
18
18
|
|
@@ -52,16 +52,16 @@ Displays a popover relatively positioned to the target. Does not require the tar
|
|
52
52
|
-->
|
53
53
|
|
54
54
|
<script>import { prefersReducedMotion } from "../util/accessibility";
|
55
|
-
import { duration } from "../util/transition";
|
55
|
+
import { duration, start } from "../util/transition";
|
56
56
|
import { onMount, tick } from "svelte";
|
57
|
-
import {
|
57
|
+
import { scale } from "svelte/transition";
|
58
58
|
let className = "";
|
59
59
|
export { className as class };
|
60
60
|
export let id = "";
|
61
61
|
export let display = true;
|
62
62
|
export let position = "bottom";
|
63
63
|
export let target;
|
64
|
-
export let transition = { duration };
|
64
|
+
export let transition = { duration, start };
|
65
65
|
let popover;
|
66
66
|
let coordinates = { x: 0, y: 0 };
|
67
67
|
const setPosition = async () => {
|
@@ -122,7 +122,7 @@ onMount(() => {
|
|
122
122
|
{id}
|
123
123
|
style:top="{coordinates.y}px"
|
124
124
|
style:left="{coordinates.x}px"
|
125
|
-
transition:
|
125
|
+
transition:scale={transition ? transition : { duration: 0 }}
|
126
126
|
>
|
127
127
|
<slot>Popover</slot>
|
128
128
|
</div>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
2
|
-
import { type
|
2
|
+
import { type ScaleParams } from "svelte/transition";
|
3
3
|
declare const __propDef: {
|
4
4
|
props: {
|
5
5
|
class?: string | undefined;
|
6
6
|
id?: string | undefined;
|
7
7
|
/** shows / hides the popover */ display?: boolean | undefined;
|
8
|
-
/** where the popover is displayed in relation to the target */ position?: "top" | "bottom" | "left" | "right" | undefined;
|
8
|
+
/** where the popover is displayed in relation to the `target` */ position?: "top" | "bottom" | "left" | "right" | undefined;
|
9
9
|
/** target element to position the popover in relation to */ target: HTMLElement;
|
10
|
-
/**
|
10
|
+
/** scales the popover, set to `false` to disable */ transition?: false | ScaleParams | undefined;
|
11
11
|
};
|
12
12
|
events: {
|
13
13
|
[evt: string]: CustomEvent<any>;
|
@@ -29,9 +29,9 @@ export type PopoverSlots = typeof __propDef.slots;
|
|
29
29
|
* - `class`
|
30
30
|
* - `display` - shows / hides the popover
|
31
31
|
* - `id`
|
32
|
-
* - `position` - where the popover is displayed in relation to the target
|
32
|
+
* - `position` - where the popover is displayed in relation to the `target`
|
33
33
|
* - `target` - target element to position the popover in relation to
|
34
|
-
* - `transition` -
|
34
|
+
* - `transition` - scales the popover, set to `false` to disable
|
35
35
|
*
|
36
36
|
* @slots
|
37
37
|
*
|
package/dist/util/transition.js
CHANGED
package/package.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "drab",
|
3
|
-
"version": "2.8.
|
3
|
+
"version": "2.8.2",
|
4
4
|
"description": "An unstyled Svelte component library",
|
5
5
|
"keywords": [
|
6
6
|
"components",
|
7
7
|
"Svelte",
|
8
8
|
"SvelteKit",
|
9
9
|
"Accordion",
|
10
|
+
"Breakpoint",
|
10
11
|
"Chord",
|
11
12
|
"ContextMenu",
|
12
13
|
"Copy",
|
@@ -15,6 +16,7 @@
|
|
15
16
|
"Fullscreen",
|
16
17
|
"Popover",
|
17
18
|
"Share",
|
19
|
+
"Sheet",
|
18
20
|
"Tabs",
|
19
21
|
"YouTube"
|
20
22
|
],
|