drab 2.8.4 → 2.8.6

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.
@@ -11,7 +11,6 @@
11
11
 
12
12
  - `classButton` - `class` of all the `button` elements
13
13
  - `classControls` - `class` of the `div` that wraps the controls
14
- - `classNoscript` - `noscript` class
15
14
  - `classTextarea` - `class` of the `textarea` element
16
15
  - `contentElements` - an array of `EditorContentElement`s for the controls
17
16
  - `idControls` - `id` of the `div` that wraps the controls
@@ -25,46 +24,43 @@
25
24
  @example
26
25
 
27
26
  ```svelte
28
- <script lang="ts">
29
- import { Editor } from "drab";
30
- </script>
31
-
32
- <Editor
33
- classButton="btn"
34
- classControls="flex gap-2"
35
- classTextarea="border w-full h-36 p-2 rounded"
36
- placeholderTextarea="asterisk: ctrl+i, anchor: ctrl+["
37
- contentElements={[
38
- {
39
- name: "Bullet",
40
- text: "- ",
41
- display: "block",
42
- icon: "Bullet",
43
- },
44
- {
45
- name: "Asterisk",
46
- text: "*",
47
- display: "wrap",
48
- icon: "Asterisk",
49
- key: "i",
50
- class: "italic",
51
- },
52
- {
53
- name: "Anchor",
54
- text: "[text](href)",
55
- display: "inline",
56
- icon: "Anchor",
57
- key: "[",
58
- },
59
- ]}
60
- />
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
+ name: "Bullet",
39
+ text: "- ",
40
+ display: "block",
41
+ icon: "Bullet",
42
+ },
43
+ {
44
+ name: "Italic",
45
+ text: "*",
46
+ display: "wrap",
47
+ icon: "Italic",
48
+ key: "i",
49
+ class: "italic",
50
+ },
51
+ {
52
+ name: "Anchor",
53
+ text: "[text](href)",
54
+ display: "inline",
55
+ icon: "Anchor",
56
+ key: "[",
57
+ },
58
+ ]}
59
+ />
61
60
  ```
62
61
  -->
63
62
 
64
- <script context="module"></script>
65
-
66
63
  <script>import { onMount } from "svelte";
67
- import { messageNoScript } from "../util/messages";
68
64
  export let contentElements = [];
69
65
  export let valueTextarea = "";
70
66
  export let placeholderTextarea = "";
@@ -83,7 +79,6 @@ export let keyPairs = {
83
79
  '"': '"',
84
80
  "`": "`"
85
81
  };
86
- export let classNoscript = "";
87
82
  let clientJs = false;
88
83
  let textArea;
89
84
  contentElements.forEach((el) => {
@@ -379,9 +374,3 @@ onMount(() => clientJs = true);
379
374
  </button>
380
375
  {/each}
381
376
  </div>
382
-
383
- <noscript>
384
- <div class={classNoscript}>
385
- {messageNoScript}
386
- </div>
387
- </noscript>
@@ -1,27 +1,21 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import type { ComponentType } from "svelte";
3
- /**
4
- * - `EditorContentElement` to pass into the `contentElements` array prop
5
- * - `contentElements` prop creates a list of button controls to insert
6
- * text into the `TextAreaElement`
7
- */
8
- export interface EditorContentElement {
9
- /** name of element */
10
- name: string;
11
- /** text to add */
12
- text: string;
13
- /** controls how the text is added */
14
- display: "inline" | "block" | "wrap";
15
- /** contents of the `button` */
16
- icon: string | ComponentType;
17
- /** keyboard shortcut */
18
- key?: string;
19
- /** class to apply to the specific `button` */
20
- class?: string;
21
- }
2
+ import { type ComponentType } from "svelte";
22
3
  declare const __propDef: {
23
4
  props: {
24
- /** an array of `EditorContentElement`s for the controls */ contentElements?: EditorContentElement[] | undefined;
5
+ /** an array of `EditorContentElement`s for the controls */ contentElements?: {
6
+ /** name of element */
7
+ name: string;
8
+ /** text to add */
9
+ text: string;
10
+ /** controls how the text is added */
11
+ display: "inline" | "block" | "wrap";
12
+ /** contents of the `button` */
13
+ icon: string | ComponentType;
14
+ /** keyboard shortcut */
15
+ key?: string | undefined;
16
+ /** class to apply to the specific `button` */
17
+ class?: string | undefined;
18
+ }[] | undefined;
25
19
  /** `value` of the `textarea` element */ valueTextarea?: string | undefined;
26
20
  /** `placeholder` of the `textarea` element */ placeholderTextarea?: string | undefined;
27
21
  /** `class` of the `textarea` element */ classTextarea?: string | undefined;
@@ -34,7 +28,6 @@ declare const __propDef: {
34
28
  /** keys that will auto-close if typed, value is their closing character */ keyPairs?: {
35
29
  [key: string]: string;
36
30
  } | undefined;
37
- /** `noscript` class */ classNoscript?: string | undefined;
38
31
  };
39
32
  events: {
40
33
  input: Event;
@@ -57,7 +50,6 @@ export type EditorSlots = typeof __propDef.slots;
57
50
  *
58
51
  * - `classButton` - `class` of all the `button` elements
59
52
  * - `classControls` - `class` of the `div` that wraps the controls
60
- * - `classNoscript` - `noscript` class
61
53
  * - `classTextarea` - `class` of the `textarea` element
62
54
  * - `contentElements` - an array of `EditorContentElement`s for the controls
63
55
  * - `idControls` - `id` of the `div` that wraps the controls
@@ -78,7 +70,7 @@ export type EditorSlots = typeof __propDef.slots;
78
70
  * <Editor
79
71
  * classButton="btn"
80
72
  * classControls="flex gap-2"
81
- * classTextarea="border w-full h-36 p-2 rounded"
73
+ * classTextarea="border w-full h-36 p-2 rounded mb-2"
82
74
  * placeholderTextarea="asterisk: ctrl+i, anchor: ctrl+["
83
75
  * contentElements={[
84
76
  * {
@@ -88,10 +80,10 @@ export type EditorSlots = typeof __propDef.slots;
88
80
  * icon: "Bullet",
89
81
  * },
90
82
  * {
91
- * name: "Asterisk",
83
+ * name: "Italic",
92
84
  * text: "*",
93
85
  * display: "wrap",
94
- * icon: "Asterisk",
86
+ * icon: "Italic",
95
87
  * key: "i",
96
88
  * class: "italic",
97
89
  * },
@@ -7,7 +7,6 @@ Make the document or a specific element fullscreen.
7
7
 
8
8
  @props
9
9
 
10
- - `classNoscript` - `noscript` class
11
10
  - `class`
12
11
  - `confirmMessage` - message to display in the `confirm` popup, defaults to empty string `""` -- disabled
13
12
  - `id`
@@ -24,32 +23,30 @@ Make the document or a specific element fullscreen.
24
23
  @example
25
24
 
26
25
  ```svelte
27
- <script lang="ts">
28
- import { FullscreenButton } from "drab";
29
-
30
- let target: HTMLDivElement;
31
- </script>
32
-
33
- <FullscreenButton class="btn" />
34
-
35
- <div bind:this={target} class="mt-8 rounded bg-neutral-800 p-4 text-neutral-50">
36
- <div class="mb-2">Target element</div>
37
- <FullscreenButton {target} class="btn btn-s bg-neutral-50">
38
- Enable Element Fullscreen
39
- </FullscreenButton>
40
- </div>
26
+ <script lang="ts">
27
+ import { FullscreenButton } from "drab";
28
+
29
+ let target: HTMLDivElement;
30
+ </script>
31
+
32
+ <FullscreenButton class="btn" />
33
+
34
+ <div bind:this={target} class="mt-8 rounded bg-neutral-800 p-4 text-neutral-50">
35
+ <div class="mb-2">Target element</div>
36
+ <FullscreenButton {target} class="btn btn-s bg-neutral-50">
37
+ Enable Element Fullscreen
38
+ </FullscreenButton>
39
+ </div>
41
40
  ```
42
41
  -->
43
42
 
44
43
  <script>import { onMount } from "svelte";
45
- import { messageNoScript } from "../util/messages";
46
44
  let className = "";
47
45
  export { className as class };
48
46
  export let id = "";
49
47
  export let title = "";
50
48
  export let target = null;
51
49
  export let confirmMessage = "";
52
- export let classNoscript = "";
53
50
  let disabled = true;
54
51
  let fullscreen = false;
55
52
  const onClick = () => {
@@ -91,5 +88,3 @@ onMount(() => {
91
88
  <slot>Enable Fullscreen</slot>
92
89
  {/if}
93
90
  </button>
94
-
95
- <noscript><div class={classNoscript}>{messageNoScript}</div></noscript>
@@ -6,7 +6,6 @@ declare const __propDef: {
6
6
  title?: string | undefined;
7
7
  /** element to make fullscreen (defaults to `document.documentElement` upon mount) */ target?: HTMLElement | null | undefined;
8
8
  /** message to display in the `confirm` popup, defaults to empty string `""` -- disabled */ confirmMessage?: string | undefined;
9
- /** `noscript` class */ classNoscript?: string | undefined;
10
9
  };
11
10
  events: {
12
11
  [evt: string]: CustomEvent<any>;
@@ -26,7 +25,6 @@ export type FullscreenButtonSlots = typeof __propDef.slots;
26
25
  *
27
26
  * @props
28
27
  *
29
- * - `classNoscript` - `noscript` class
30
28
  * - `class`
31
29
  * - `confirmMessage` - message to display in the `confirm` popup, defaults to empty string `""` -- disabled
32
30
  * - `id`
@@ -1,11 +1,11 @@
1
- <!--
2
- @component
3
-
4
- ### Popover
5
-
6
- Displays a popover relatively positioned to the target. Does not require the target to be `position: relative;`.
7
-
8
- @props
1
+ <!--
2
+ @component
3
+
4
+ ### Popover
5
+
6
+ Displays a popover relatively positioned to the target. Does not require the target to be `position: relative;`.
7
+
8
+ @props
9
9
 
10
10
  - `class`
11
11
  - `display` - shows / hides the popover
@@ -14,41 +14,41 @@ Displays a popover relatively positioned to the target. Does not require the tar
14
14
  - `target` - target element to position the popover in relation to
15
15
  - `transition` - scales the popover, set to `false` to disable
16
16
 
17
- @slots
18
-
19
- | name | purpose | default value |
20
- | ---------- | ------------------------------- | ------------- |
21
- | `default` | default | Popover |
22
-
23
- @example
17
+ @slots
18
+
19
+ | name | purpose | default value |
20
+ | ---------- | ------------------------------- | ------------- |
21
+ | `default` | default | Popover |
22
+
23
+ @example
24
24
 
25
25
  ```svelte
26
- <script lang="ts">
27
- import { Popover } from "drab";
28
-
29
- let target: HTMLButtonElement;
30
-
31
- let display = false;
32
-
33
- const open = () => (display = true);
34
- const close = () => (display = false);
35
- </script>
36
-
37
- <button class="btn" type="button" bind:this={target} on:click={open}>
38
- Open
39
- </button>
40
-
41
- <Popover {target} bind:display class="p-2">
42
- <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
43
- <div class="font-bold">Bottom</div>
44
- <button class="btn" on:click={close}>Close</button>
45
- <button class="btn" on:click={close}>Close</button>
46
- <button class="btn" on:click={close}>Close</button>
47
- </div>
48
- </Popover>
26
+ <script lang="ts">
27
+ import { Popover } from "drab";
28
+
29
+ let target: HTMLButtonElement;
30
+
31
+ let display = false;
32
+
33
+ const open = () => (display = true);
34
+ const close = () => (display = false);
35
+ </script>
36
+
37
+ <button class="btn" type="button" bind:this={target} on:click={open}>
38
+ Open
39
+ </button>
40
+
41
+ <Popover {target} bind:display class="p-2">
42
+ <div class="flex w-48 flex-col gap-2 rounded border bg-white p-2 shadow">
43
+ <div class="font-bold">Bottom</div>
44
+ <button class="btn" on:click={close}>Close</button>
45
+ <button class="btn" on:click={close}>Close</button>
46
+ <button class="btn" on:click={close}>Close</button>
47
+ </div>
48
+ </Popover>
49
49
  ```
50
- -->
51
-
50
+ -->
51
+
52
52
  <script>import { prefersReducedMotion } from "../util/accessibility";
53
53
  import { duration, start } from "../util/transition";
54
54
  import { onMount, tick } from "svelte";
@@ -106,26 +106,26 @@ onMount(() => {
106
106
  if (prefersReducedMotion())
107
107
  transition = false;
108
108
  });
109
- </script>
110
-
111
- <svelte:body on:keydown={onKeyDown} />
112
-
113
- {#if display}
114
- <div
115
- role="dialog"
116
- bind:this={popover}
117
- class={className}
118
- {id}
119
- style:top="{coordinates.y}px"
120
- style:left="{coordinates.x}px"
121
- transition:scale={transition ? transition : { duration: 0 }}
122
- >
123
- <slot>Popover</slot>
124
- </div>
125
- {/if}
126
-
127
- <style>
128
- div {
129
- position: absolute;
130
- }
131
- </style>
109
+ </script>
110
+
111
+ <svelte:body on:keydown={onKeyDown} />
112
+
113
+ {#if display}
114
+ <div
115
+ role="dialog"
116
+ bind:this={popover}
117
+ class={className}
118
+ {id}
119
+ style:top="{coordinates.y}px"
120
+ style:left="{coordinates.x}px"
121
+ transition:scale={transition ? transition : { duration: 0 }}
122
+ >
123
+ <slot>Popover</slot>
124
+ </div>
125
+ {/if}
126
+
127
+ <style>
128
+ div {
129
+ position: absolute;
130
+ }
131
+ </style>
@@ -30,50 +30,49 @@ Uses the [Navigator API](https://developer.mozilla.org/en-US/docs/Web/API/Naviga
30
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
72
  -->
73
73
 
74
74
  <script>import { onMount } from "svelte";
75
75
  import { delay } from "../util/delay";
76
- import { messageNoScript } from "../util/messages";
77
76
  let className = "";
78
77
  export { className as class };
79
78
  export let id = "";
@@ -127,8 +126,6 @@ onMount(() => clientJs = true);
127
126
 
128
127
  <a href="/" bind:this={downloadAnchor} style:display="none">Download</a>
129
128
 
130
- <noscript>
131
- <span class={classNoscript}>
132
- {shareData.url ? shareData.url : messageNoScript}
133
- </span>
134
- </noscript>
129
+ {#if shareData.url}
130
+ <noscript><span class={classNoscript}>{shareData.url}</span></noscript>
131
+ {/if}