drab 2.8.6 → 3.0.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/README.md +69 -67
- package/dist/components/Breakpoint.svelte +7 -7
- package/dist/components/Breakpoint.svelte.d.ts +1 -1
- package/dist/components/ContextMenu.svelte +74 -75
- package/dist/components/ContextMenu.svelte.d.ts +1 -1
- package/dist/components/CopyButton.svelte +35 -13
- package/dist/components/CopyButton.svelte.d.ts +8 -4
- package/dist/components/DataTable.svelte +124 -118
- package/dist/components/DataTable.svelte.d.ts +15 -9
- package/dist/components/Details.svelte +76 -76
- package/dist/components/Details.svelte.d.ts +3 -3
- package/dist/components/Editor.svelte +39 -39
- package/dist/components/Editor.svelte.d.ts +6 -6
- package/dist/components/{Chord.svelte → FrettedChord.svelte} +36 -34
- package/dist/components/{Chord.svelte.d.ts → FrettedChord.svelte.d.ts} +13 -11
- package/dist/components/FullscreenButton.svelte +22 -17
- package/dist/components/FullscreenButton.svelte.d.ts +1 -1
- package/dist/components/Popover.svelte +70 -67
- package/dist/components/Popover.svelte.d.ts +5 -2
- package/dist/components/ShareButton.svelte +38 -38
- package/dist/components/Sheet.svelte +104 -104
- package/dist/components/Sheet.svelte.d.ts +2 -2
- package/dist/components/YouTube.svelte +9 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +81 -81
@@ -1,11 +1,17 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### DataTable
|
5
|
-
|
6
|
-
Data table to display an array of
|
7
|
-
|
8
|
-
|
1
|
+
<!--
|
2
|
+
@component
|
3
|
+
|
4
|
+
### DataTable
|
5
|
+
|
6
|
+
Data table to display an array of objects. Works with zero configuration, just pass an array of objects into the `data` prop.
|
7
|
+
|
8
|
+
- Set the `maxRows` prop to enable pagination, bind to `currentPage` to navigate (see second example below)
|
9
|
+
- Provides sorting for `number`, `string`, `boolean`, and `Date`
|
10
|
+
- Strings are sorted using `Intl.Collator`
|
11
|
+
- Style or modify the rendering of data with slot props
|
12
|
+
- `numberOfPages` is calculated and sent back through the `controls` slot
|
13
|
+
|
14
|
+
@props
|
9
15
|
|
10
16
|
- `ascending` - current sort order
|
11
17
|
- `classTbodyTr` - `tbody tr` class
|
@@ -23,88 +29,88 @@ Data table to display an array of JS objects. Provides pagination and sorting fo
|
|
23
29
|
- `maxRows` - maximum number of rows to show on each page, defaults to `0` - no pagination
|
24
30
|
- `sortBy` - key (column) to sort by, defaults to first key
|
25
31
|
|
26
|
-
@slots
|
27
|
-
|
28
|
-
| name | purpose
|
29
|
-
| ---------- |
|
30
|
-
| `controls` | helper that passes back `maxRows` and `numberOfPages` |
|
31
|
-
| `td` | td contents
|
32
|
-
| `th` | th contents
|
33
|
-
|
34
|
-
@example
|
32
|
+
@slots
|
33
|
+
|
34
|
+
| name | purpose | default value | slot props |
|
35
|
+
| ---------- | ---------------------------------------------------------------- | ------------- | ------------------------------- |
|
36
|
+
| `controls` | helper that passes back `maxRows` and calculated `numberOfPages` | empty | `maxRows`, `numberOfPages` |
|
37
|
+
| `td` | td contents | `value` | `item`, `key`, `sortBy` `value` |
|
38
|
+
| `th` | th contents | `key` | `key`, `sortBy` |
|
39
|
+
|
40
|
+
@example
|
35
41
|
|
36
42
|
```svelte
|
37
|
-
<script lang="ts">
|
38
|
-
import type { ComponentProps } from "svelte";
|
39
|
-
import { DataTable } from "drab";
|
40
|
-
|
41
|
-
let currentPage = 0;
|
42
|
-
|
43
|
-
const data: ComponentProps<DataTable>["data"] = [
|
44
|
-
{ make: "Honda", model: "CR-V", year: 2011, awd: true },
|
45
|
-
{ make: "Volvo", model: "XC-40", year: 2024, awd: true },
|
46
|
-
{ make: "Ferrari", model: "458 Italia", year: 2015, awd: false },
|
47
|
-
{ make: "Chevrolet", model: "Silverado", year: 2022, awd: true },
|
48
|
-
{ make: "Ford", model: "Model A", year: 1931, awd: false },
|
49
|
-
{ make: "Subaru", model: "Outback", year: 2021, awd: true },
|
50
|
-
{ make: "Ford", model: "Bronco", year: 1970, awd: true },
|
51
|
-
{ make: "GMC", model: "Acadia", year: 2008, awd: true },
|
52
|
-
{ make: "BMW", model: "X3", year: 2023, awd: true },
|
53
|
-
];
|
54
|
-
</script>
|
55
|
-
|
56
|
-
<DataTable {data} class="mb-12" />
|
57
|
-
|
58
|
-
<DataTable
|
59
|
-
{data}
|
60
|
-
bind:currentPage
|
61
|
-
sortBy="year"
|
62
|
-
maxRows={4}
|
63
|
-
class="tabular-nums"
|
64
|
-
classTh="cursor-pointer capitalize"
|
65
|
-
classTbodyTr="transition hover:bg-neutral-50"
|
66
|
-
>
|
67
|
-
<svelte:fragment slot="th" let:key let:sortBy>
|
68
|
-
<span class:uppercase={key === "awd"} class:underline={key === sortBy}>
|
69
|
-
{key}
|
70
|
-
</span>
|
71
|
-
</svelte:fragment>
|
72
|
-
<svelte:fragment slot="td" let:value>
|
73
|
-
{#if typeof value === "boolean"}
|
74
|
-
{value ? "Yes" : "No"}
|
75
|
-
{:else}
|
76
|
-
{value}
|
77
|
-
{/if}
|
78
|
-
</svelte:fragment>
|
79
|
-
<svelte:fragment slot="controls" let:maxRows let:numberOfPages>
|
80
|
-
{#if maxRows}
|
81
|
-
<div class="flex items-center justify-between">
|
82
|
-
<div>{currentPage + 1} / {numberOfPages}</div>
|
83
|
-
<div>
|
84
|
-
<button
|
85
|
-
type="button"
|
86
|
-
class="btn"
|
87
|
-
disabled={currentPage < 1}
|
88
|
-
on:click={() => currentPage--}
|
89
|
-
>
|
90
|
-
Previous
|
91
|
-
</button>
|
92
|
-
<button
|
93
|
-
type="button"
|
94
|
-
class="btn"
|
95
|
-
disabled={currentPage >= numberOfPages - 1}
|
96
|
-
on:click={() => currentPage++}
|
97
|
-
>
|
98
|
-
Next
|
99
|
-
</button>
|
100
|
-
</div>
|
101
|
-
</div>
|
102
|
-
{/if}
|
103
|
-
</svelte:fragment>
|
104
|
-
</DataTable>
|
43
|
+
<script lang="ts">
|
44
|
+
import type { ComponentProps } from "svelte";
|
45
|
+
import { DataTable } from "drab";
|
46
|
+
|
47
|
+
let currentPage = 0;
|
48
|
+
|
49
|
+
const data: ComponentProps<DataTable>["data"] = [
|
50
|
+
{ make: "Honda", model: "CR-V", year: 2011, awd: true },
|
51
|
+
{ make: "Volvo", model: "XC-40", year: 2024, awd: true },
|
52
|
+
{ make: "Ferrari", model: "458 Italia", year: 2015, awd: false },
|
53
|
+
{ make: "Chevrolet", model: "Silverado", year: 2022, awd: true },
|
54
|
+
{ make: "Ford", model: "Model A", year: 1931, awd: false },
|
55
|
+
{ make: "Subaru", model: "Outback", year: 2021, awd: true },
|
56
|
+
{ make: "Ford", model: "Bronco", year: 1970, awd: true },
|
57
|
+
{ make: "GMC", model: "Acadia", year: 2008, awd: true },
|
58
|
+
{ make: "BMW", model: "X3", year: 2023, awd: true },
|
59
|
+
];
|
60
|
+
</script>
|
61
|
+
|
62
|
+
<DataTable {data} class="mb-12" />
|
63
|
+
|
64
|
+
<DataTable
|
65
|
+
{data}
|
66
|
+
bind:currentPage
|
67
|
+
sortBy="year"
|
68
|
+
maxRows={4}
|
69
|
+
class="tabular-nums"
|
70
|
+
classTh="cursor-pointer capitalize"
|
71
|
+
classTbodyTr="transition hover:bg-neutral-50"
|
72
|
+
>
|
73
|
+
<svelte:fragment slot="th" let:key let:sortBy>
|
74
|
+
<span class:uppercase={key === "awd"} class:underline={key === sortBy}>
|
75
|
+
{key}
|
76
|
+
</span>
|
77
|
+
</svelte:fragment>
|
78
|
+
<svelte:fragment slot="td" let:value>
|
79
|
+
{#if typeof value === "boolean"}
|
80
|
+
{value ? "Yes" : "No"}
|
81
|
+
{:else}
|
82
|
+
{value}
|
83
|
+
{/if}
|
84
|
+
</svelte:fragment>
|
85
|
+
<svelte:fragment slot="controls" let:maxRows let:numberOfPages>
|
86
|
+
{#if maxRows}
|
87
|
+
<div class="flex items-center justify-between gap-4">
|
88
|
+
<div class="min-w-fit">{currentPage + 1} / {numberOfPages}</div>
|
89
|
+
<div class="flex gap-2">
|
90
|
+
<button
|
91
|
+
type="button"
|
92
|
+
class="btn"
|
93
|
+
disabled={currentPage < 1}
|
94
|
+
on:click={() => currentPage--}
|
95
|
+
>
|
96
|
+
Previous
|
97
|
+
</button>
|
98
|
+
<button
|
99
|
+
type="button"
|
100
|
+
class="btn"
|
101
|
+
disabled={currentPage >= numberOfPages - 1}
|
102
|
+
on:click={() => currentPage++}
|
103
|
+
>
|
104
|
+
Next
|
105
|
+
</button>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
{/if}
|
109
|
+
</svelte:fragment>
|
110
|
+
</DataTable>
|
105
111
|
```
|
106
|
-
-->
|
107
|
-
|
112
|
+
-->
|
113
|
+
|
108
114
|
<script>let className = "";
|
109
115
|
export { className as class };
|
110
116
|
export let id = "";
|
@@ -129,6 +135,7 @@ const sort = (key, toggleAscending = true) => {
|
|
129
135
|
} else {
|
130
136
|
ascending = true;
|
131
137
|
}
|
138
|
+
const collator = new Intl.Collator();
|
132
139
|
data.sort((a, b) => {
|
133
140
|
const aVal = a[key];
|
134
141
|
const bVal = b[key];
|
@@ -139,7 +146,6 @@ const sort = (key, toggleAscending = true) => {
|
|
139
146
|
return bVal - aVal;
|
140
147
|
}
|
141
148
|
} else if (typeof aVal === "string" && typeof bVal === "string") {
|
142
|
-
const collator = new Intl.Collator();
|
143
149
|
if (ascending) {
|
144
150
|
return collator.compare(aVal, bVal);
|
145
151
|
} else {
|
@@ -170,33 +176,33 @@ const showRow = (i, currentPage2) => {
|
|
170
176
|
return overMin && underMax;
|
171
177
|
};
|
172
178
|
sort(sortBy, false);
|
173
|
-
</script>
|
174
|
-
|
175
|
-
<table class={className} {id}>
|
176
|
-
<thead class={classThead}>
|
177
|
-
<tr class="{classTr} {classTheadTr}">
|
178
|
-
{#each keys as key}
|
179
|
-
<th class={classTh} on:click={() => sort(key)}>
|
180
|
-
<slot name="th" {key} {sortBy}>{key}</slot>
|
181
|
-
</th>
|
182
|
-
{/each}
|
183
|
-
</tr>
|
184
|
-
</thead>
|
185
|
-
<tbody class={classTbody}>
|
186
|
-
{#each data as item, i}
|
187
|
-
{#if showRow(i, currentPage)}
|
188
|
-
<tr class="{classTr} {classTbodyTr}">
|
189
|
-
{#each keys as key}
|
190
|
-
<td class={classTd}>
|
191
|
-
<slot name="td" {item} {key} {sortBy} value={item[key]}>
|
192
|
-
{item[key]}
|
193
|
-
</slot>
|
194
|
-
</td>
|
195
|
-
{/each}
|
196
|
-
</tr>
|
197
|
-
{/if}
|
198
|
-
{/each}
|
199
|
-
</tbody>
|
200
|
-
</table>
|
201
|
-
|
202
|
-
<slot name="controls" {maxRows} {numberOfPages} />
|
179
|
+
</script>
|
180
|
+
|
181
|
+
<table class={className} {id}>
|
182
|
+
<thead class={classThead}>
|
183
|
+
<tr class="{classTr} {classTheadTr}">
|
184
|
+
{#each keys as key}
|
185
|
+
<th class={classTh} on:click={() => sort(key)}>
|
186
|
+
<slot name="th" {key} {sortBy}>{key}</slot>
|
187
|
+
</th>
|
188
|
+
{/each}
|
189
|
+
</tr>
|
190
|
+
</thead>
|
191
|
+
<tbody class={classTbody}>
|
192
|
+
{#each data as item, i}
|
193
|
+
{#if showRow(i, currentPage)}
|
194
|
+
<tr class="{classTr} {classTbodyTr}">
|
195
|
+
{#each keys as key}
|
196
|
+
<td class={classTd}>
|
197
|
+
<slot name="td" {item} {key} {sortBy} value={item[key]}>
|
198
|
+
{item[key]}
|
199
|
+
</slot>
|
200
|
+
</td>
|
201
|
+
{/each}
|
202
|
+
</tr>
|
203
|
+
{/if}
|
204
|
+
{/each}
|
205
|
+
</tbody>
|
206
|
+
</table>
|
207
|
+
|
208
|
+
<slot name="controls" {maxRows} {numberOfPages} />
|
@@ -43,7 +43,13 @@ export type DataTableSlots = typeof __propDef.slots;
|
|
43
43
|
/**
|
44
44
|
* ### DataTable
|
45
45
|
*
|
46
|
-
* Data table to display an array of
|
46
|
+
* Data table to display an array of objects. Works with zero configuration, just pass an array of objects into the `data` prop.
|
47
|
+
*
|
48
|
+
* - Set the `maxRows` prop to enable pagination, bind to `currentPage` to navigate (see second example below)
|
49
|
+
* - Provides sorting for `number`, `string`, `boolean`, and `Date`
|
50
|
+
* - Strings are sorted using `Intl.Collator`
|
51
|
+
* - Style or modify the rendering of data with slot props
|
52
|
+
* - `numberOfPages` is calculated and sent back through the `controls` slot
|
47
53
|
*
|
48
54
|
* @props
|
49
55
|
*
|
@@ -65,11 +71,11 @@ export type DataTableSlots = typeof __propDef.slots;
|
|
65
71
|
*
|
66
72
|
* @slots
|
67
73
|
*
|
68
|
-
* | name | purpose
|
69
|
-
* | ---------- |
|
70
|
-
* | `controls` | helper that passes back `maxRows` and `numberOfPages` |
|
71
|
-
* | `td` | td contents
|
72
|
-
* | `th` | th contents
|
74
|
+
* | name | purpose | default value | slot props |
|
75
|
+
* | ---------- | ---------------------------------------------------------------- | ------------- | ------------------------------- |
|
76
|
+
* | `controls` | helper that passes back `maxRows` and calculated `numberOfPages` | empty | `maxRows`, `numberOfPages` |
|
77
|
+
* | `td` | td contents | `value` | `item`, `key`, `sortBy` `value` |
|
78
|
+
* | `th` | th contents | `key` | `key`, `sortBy` |
|
73
79
|
*
|
74
80
|
* @example
|
75
81
|
*
|
@@ -118,9 +124,9 @@ export type DataTableSlots = typeof __propDef.slots;
|
|
118
124
|
* </svelte:fragment>
|
119
125
|
* <svelte:fragment slot="controls" let:maxRows let:numberOfPages>
|
120
126
|
* {#if maxRows}
|
121
|
-
* <div class="flex items-center justify-between">
|
122
|
-
* <div>{currentPage + 1} / {numberOfPages}</div>
|
123
|
-
* <div>
|
127
|
+
* <div class="flex items-center justify-between gap-4">
|
128
|
+
* <div class="min-w-fit">{currentPage + 1} / {numberOfPages}</div>
|
129
|
+
* <div class="flex gap-2">
|
124
130
|
* <button
|
125
131
|
* type="button"
|
126
132
|
* class="btn"
|
@@ -1,50 +1,50 @@
|
|
1
|
-
<!--
|
2
|
-
@component
|
3
|
-
|
4
|
-
### Details
|
5
|
-
|
6
|
-
Displays a `details` element with helpful defaults and transitions. Can be used to make an accordion, or a collapse.
|
7
|
-
|
8
|
-
@props
|
1
|
+
<!--
|
2
|
+
@component
|
3
|
+
|
4
|
+
### Details
|
5
|
+
|
6
|
+
Displays a `details` element with helpful defaults and transitions. Can be used to make an accordion, or a collapse.
|
7
|
+
|
8
|
+
@props
|
9
9
|
|
10
10
|
- `class`
|
11
11
|
- `id`
|
12
12
|
- `open`
|
13
13
|
- `transition` - slides the content, set to `false` to remove
|
14
14
|
|
15
|
-
@slots
|
16
|
-
|
17
|
-
| name | purpose | default value | slot props |
|
18
|
-
| --------- | ------------------------------- | -------------- | ---------- |
|
19
|
-
| `summary` | `summary` element contents |
|
20
|
-
| `content` | contents when details is `open` |
|
21
|
-
|
22
|
-
@example
|
15
|
+
@slots
|
16
|
+
|
17
|
+
| name | purpose | default value | slot props |
|
18
|
+
| --------- | ------------------------------- | -------------- | ---------- |
|
19
|
+
| `summary` | `summary` element contents | empty | `open` |
|
20
|
+
| `content` | contents when details is `open` | empty | none |
|
21
|
+
|
22
|
+
@example
|
23
23
|
|
24
24
|
```svelte
|
25
|
-
<script lang="ts">
|
26
|
-
import { Details } from "drab";
|
27
|
-
import Chevron from "../../site/svg/Chevron.svelte";
|
28
|
-
</script>
|
29
|
-
|
30
|
-
<Details class="border-b">
|
31
|
-
<svelte:fragment slot="summary" let:open>
|
32
|
-
<div
|
33
|
-
class="flex cursor-pointer items-center justify-between gap-8 p-4
|
34
|
-
>
|
35
|
-
<div>Does it work without JavaScript?</div>
|
36
|
-
<div class="transition" class:rotate-180={open}>
|
37
|
-
<Chevron />
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
</svelte:fragment>
|
41
|
-
<svelte:fragment slot="content">
|
42
|
-
<div class="px-4 pb-4">Yes.</div>
|
43
|
-
</svelte:fragment>
|
44
|
-
</Details>
|
25
|
+
<script lang="ts">
|
26
|
+
import { Details } from "drab";
|
27
|
+
import Chevron from "../../site/svg/Chevron.svelte";
|
28
|
+
</script>
|
29
|
+
|
30
|
+
<Details class="border-b">
|
31
|
+
<svelte:fragment slot="summary" let:open>
|
32
|
+
<div
|
33
|
+
class="flex cursor-pointer items-center justify-between gap-8 p-4 underline hover:decoration-dotted"
|
34
|
+
>
|
35
|
+
<div>Does it work without JavaScript?</div>
|
36
|
+
<div class="transition" class:rotate-180={open}>
|
37
|
+
<Chevron />
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
</svelte:fragment>
|
41
|
+
<svelte:fragment slot="content">
|
42
|
+
<div class="px-4 pb-4">Yes.</div>
|
43
|
+
</svelte:fragment>
|
44
|
+
</Details>
|
45
45
|
```
|
46
|
-
-->
|
47
|
-
|
46
|
+
-->
|
47
|
+
|
48
48
|
<script>import { onMount } from "svelte";
|
49
49
|
import { slide } from "svelte/transition";
|
50
50
|
import { prefersReducedMotion } from "../util/accessibility";
|
@@ -63,41 +63,41 @@ onMount(() => {
|
|
63
63
|
if (prefersReducedMotion())
|
64
64
|
transition = false;
|
65
65
|
});
|
66
|
-
</script>
|
67
|
-
|
68
|
-
<div class={className} {id}>
|
69
|
-
<details bind:open>
|
70
|
-
<!-- svelte-ignore a11y-no-redundant-roles -->
|
71
|
-
<summary
|
72
|
-
role="button"
|
73
|
-
tabindex="0"
|
74
|
-
on:click|preventDefault={toggleOpen}
|
75
|
-
on:keydown={(e) => {
|
76
|
-
if (e.key === "Enter") {
|
77
|
-
e.preventDefault();
|
78
|
-
toggleOpen();
|
79
|
-
}
|
80
|
-
}}
|
81
|
-
>
|
82
|
-
<slot name="summary" {open} />
|
83
|
-
</summary>
|
84
|
-
{#if !clientJs || !transition}
|
85
|
-
<slot name="content" />
|
86
|
-
{/if}
|
87
|
-
</details>
|
88
|
-
{#if clientJs && open && transition}
|
89
|
-
<!-- outside the details for the transition -->
|
90
|
-
<div transition:slide={transition}>
|
91
|
-
<slot name="content" />
|
92
|
-
</div>
|
93
|
-
{/if}
|
94
|
-
</div>
|
95
|
-
|
96
|
-
<style>
|
97
|
-
summary {
|
98
|
-
list-style: none;
|
99
|
-
}
|
100
|
-
summary::-webkit-details-marker {
|
101
|
-
display: none;
|
102
|
-
}
|
103
|
-
</style>
|
66
|
+
</script>
|
67
|
+
|
68
|
+
<div class={className} {id}>
|
69
|
+
<details bind:open>
|
70
|
+
<!-- svelte-ignore a11y-no-redundant-roles -->
|
71
|
+
<summary
|
72
|
+
role="button"
|
73
|
+
tabindex="0"
|
74
|
+
on:click|preventDefault={toggleOpen}
|
75
|
+
on:keydown={(e) => {
|
76
|
+
if (e.key === "Enter") {
|
77
|
+
e.preventDefault();
|
78
|
+
toggleOpen();
|
79
|
+
}
|
80
|
+
}}
|
81
|
+
>
|
82
|
+
<slot name="summary" {open} />
|
83
|
+
</summary>
|
84
|
+
{#if !clientJs || !transition}
|
85
|
+
<slot name="content" />
|
86
|
+
{/if}
|
87
|
+
</details>
|
88
|
+
{#if clientJs && open && transition}
|
89
|
+
<!-- outside the details for the transition -->
|
90
|
+
<div transition:slide={transition}>
|
91
|
+
<slot name="content" />
|
92
|
+
</div>
|
93
|
+
{/if}
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<style>
|
97
|
+
summary {
|
98
|
+
list-style: none;
|
99
|
+
}
|
100
|
+
summary::-webkit-details-marker {
|
101
|
+
display: none;
|
102
|
+
}
|
103
|
+
</style>
|
@@ -36,8 +36,8 @@ export type DetailsSlots = typeof __propDef.slots;
|
|
36
36
|
*
|
37
37
|
* | name | purpose | default value | slot props |
|
38
38
|
* | --------- | ------------------------------- | -------------- | ---------- |
|
39
|
-
* | `summary` | `summary` element contents |
|
40
|
-
* | `content` | contents when details is `open` |
|
39
|
+
* | `summary` | `summary` element contents | empty | `open` |
|
40
|
+
* | `content` | contents when details is `open` | empty | none |
|
41
41
|
*
|
42
42
|
* @example
|
43
43
|
*
|
@@ -50,7 +50,7 @@ export type DetailsSlots = typeof __propDef.slots;
|
|
50
50
|
* <Details class="border-b">
|
51
51
|
* <svelte:fragment slot="summary" let:open>
|
52
52
|
* <div
|
53
|
-
* class="flex cursor-pointer items-center justify-between gap-8 p-4
|
53
|
+
* class="flex cursor-pointer items-center justify-between gap-8 p-4 underline hover:decoration-dotted"
|
54
54
|
* >
|
55
55
|
* <div>Does it work without JavaScript?</div>
|
56
56
|
* <div class="transition" class:rotate-180={open}>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
### Editor
|
5
5
|
|
6
|
-
`textarea` element with controls to add content and keyboard shortcuts. Compared to other WYSIWYG editors,
|
6
|
+
`textarea` element with controls to add content and keyboard shortcuts. Compared to other WYSIWYG editors, the `valueTextarea` is just a `string`, so you can easily store it in a database or manipulate it without learning a separate API.
|
7
7
|
|
8
8
|
- This component is used to create [Typo](https://typo.robino.dev)
|
9
9
|
|
@@ -24,39 +24,39 @@
|
|
24
24
|
@example
|
25
25
|
|
26
26
|
```svelte
|
27
|
-
<script lang="ts">
|
28
|
-
import { Editor } from "drab";
|
29
|
-
</script>
|
30
|
-
|
31
|
-
<Editor
|
32
|
-
classButton="btn"
|
33
|
-
classControls="flex gap-2"
|
34
|
-
classTextarea="border w-full h-36 p-2 rounded mb-2"
|
35
|
-
placeholderTextarea="asterisk: ctrl+i, anchor: ctrl+["
|
36
|
-
contentElements={[
|
37
|
-
{
|
38
|
-
|
39
|
-
text: "- ",
|
40
|
-
display: "block",
|
41
|
-
icon: "Bullet",
|
42
|
-
},
|
43
|
-
{
|
44
|
-
|
45
|
-
text: "*",
|
46
|
-
display: "wrap",
|
47
|
-
icon: "Italic",
|
48
|
-
key: "i",
|
49
|
-
class: "italic",
|
50
|
-
},
|
51
|
-
{
|
52
|
-
|
53
|
-
text: "[text](href)",
|
54
|
-
display: "inline",
|
55
|
-
icon: "Anchor",
|
56
|
-
key: "[",
|
57
|
-
},
|
58
|
-
]}
|
59
|
-
/>
|
27
|
+
<script lang="ts">
|
28
|
+
import { Editor } from "drab";
|
29
|
+
</script>
|
30
|
+
|
31
|
+
<Editor
|
32
|
+
classButton="btn"
|
33
|
+
classControls="flex gap-2"
|
34
|
+
classTextarea="border w-full h-36 p-2 rounded mb-2"
|
35
|
+
placeholderTextarea="asterisk: ctrl+i, anchor: ctrl+["
|
36
|
+
contentElements={[
|
37
|
+
{
|
38
|
+
title: "Bullet",
|
39
|
+
text: "- ",
|
40
|
+
display: "block",
|
41
|
+
icon: "Bullet",
|
42
|
+
},
|
43
|
+
{
|
44
|
+
title: "Italic",
|
45
|
+
text: "*",
|
46
|
+
display: "wrap",
|
47
|
+
icon: "Italic",
|
48
|
+
key: "i",
|
49
|
+
class: "italic",
|
50
|
+
},
|
51
|
+
{
|
52
|
+
title: "Anchor",
|
53
|
+
text: "[text](href)",
|
54
|
+
display: "inline",
|
55
|
+
icon: "Anchor",
|
56
|
+
key: "[",
|
57
|
+
},
|
58
|
+
]}
|
59
|
+
/>
|
60
60
|
```
|
61
61
|
-->
|
62
62
|
|
@@ -177,7 +177,7 @@ const onKeyDown = async (e) => {
|
|
177
177
|
display: "inline",
|
178
178
|
text: " ",
|
179
179
|
icon: "tab",
|
180
|
-
|
180
|
+
title: "tab"
|
181
181
|
});
|
182
182
|
}
|
183
183
|
} else if (e.key === "Enter") {
|
@@ -197,7 +197,7 @@ const onKeyDown = async (e) => {
|
|
197
197
|
text: `
|
198
198
|
${repeat}`,
|
199
199
|
icon: "",
|
200
|
-
|
200
|
+
title: ""
|
201
201
|
});
|
202
202
|
} else if (repeat && original.length === columnNumber) {
|
203
203
|
e.preventDefault();
|
@@ -217,7 +217,7 @@ ${repeat}`,
|
|
217
217
|
text: `
|
218
218
|
`,
|
219
219
|
icon: "",
|
220
|
-
|
220
|
+
title: ""
|
221
221
|
});
|
222
222
|
}, 0);
|
223
223
|
}
|
@@ -241,7 +241,7 @@ ${repeat}`,
|
|
241
241
|
display: "wrap",
|
242
242
|
text: e.key,
|
243
243
|
icon: "",
|
244
|
-
|
244
|
+
title: ""
|
245
245
|
});
|
246
246
|
openChars.push(e.key);
|
247
247
|
}
|
@@ -363,7 +363,7 @@ onMount(() => clientJs = true);
|
|
363
363
|
type="button"
|
364
364
|
class={el.class ? `${classButton} ${el.class}` : classButton}
|
365
365
|
on:click={() => addContent(el)}
|
366
|
-
title={el.
|
366
|
+
title={el.title}
|
367
367
|
disabled={!clientJs}
|
368
368
|
>
|
369
369
|
{#if typeof el.icon !== "string"}
|
@@ -3,8 +3,8 @@ import { type ComponentType } from "svelte";
|
|
3
3
|
declare const __propDef: {
|
4
4
|
props: {
|
5
5
|
/** an array of `EditorContentElement`s for the controls */ contentElements?: {
|
6
|
-
/**
|
7
|
-
|
6
|
+
/** title of element and it's corresponding button */
|
7
|
+
title: string;
|
8
8
|
/** text to add */
|
9
9
|
text: string;
|
10
10
|
/** controls how the text is added */
|
@@ -42,7 +42,7 @@ export type EditorSlots = typeof __propDef.slots;
|
|
42
42
|
/**
|
43
43
|
* ### Editor
|
44
44
|
*
|
45
|
-
* `textarea` element with controls to add content and keyboard shortcuts. Compared to other WYSIWYG editors,
|
45
|
+
* `textarea` element with controls to add content and keyboard shortcuts. Compared to other WYSIWYG editors, the `valueTextarea` is just a `string`, so you can easily store it in a database or manipulate it without learning a separate API.
|
46
46
|
*
|
47
47
|
* - This component is used to create [Typo](https://typo.robino.dev)
|
48
48
|
*
|
@@ -74,13 +74,13 @@ export type EditorSlots = typeof __propDef.slots;
|
|
74
74
|
* placeholderTextarea="asterisk: ctrl+i, anchor: ctrl+["
|
75
75
|
* contentElements={[
|
76
76
|
* {
|
77
|
-
*
|
77
|
+
* title: "Bullet",
|
78
78
|
* text: "- ",
|
79
79
|
* display: "block",
|
80
80
|
* icon: "Bullet",
|
81
81
|
* },
|
82
82
|
* {
|
83
|
-
*
|
83
|
+
* title: "Italic",
|
84
84
|
* text: "*",
|
85
85
|
* display: "wrap",
|
86
86
|
* icon: "Italic",
|
@@ -88,7 +88,7 @@ export type EditorSlots = typeof __propDef.slots;
|
|
88
88
|
* class: "italic",
|
89
89
|
* },
|
90
90
|
* {
|
91
|
-
*
|
91
|
+
* title: "Anchor",
|
92
92
|
* text: "[text](href)",
|
93
93
|
* display: "inline",
|
94
94
|
* icon: "Anchor",
|