spaper 0.3.6 → 0.6.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.
package/README.md CHANGED
@@ -51,6 +51,33 @@ npm i spaper
51
51
 
52
52
  <hr />
53
53
 
54
+ ### Sponsors
55
+
56
+ Thanks to these generous people! :heart:
57
+
58
+ <table>
59
+ <tr>
60
+ <td align="center">
61
+ <a href="https://github.com/mehdi-dalil">
62
+ <img src="https://avatars.githubusercontent.com/u/65339771?v=4" width="80px;" alt=""/><br />
63
+ <sub><b>mehdi-dalil</b></sub>
64
+ </a>
65
+ </td>
66
+ </tr>
67
+ </table>
68
+
69
+
70
+ ### Donate
71
+
72
+ Any donation is greatly appreciated :heart:
73
+
74
+ | Source | Link / Address |
75
+ | :-------------- | :------------------------------------------|
76
+ | Github Sponsor | https://github.com/sponsors/Oli8 |
77
+ | PayPal | https://paypal.me/OliCrt |
78
+ | Bitcoin | 1Ez3Ts2WShUcbeGCjhZapdxVDK77DbYjdU |
79
+ | Ethereum | 0x6cd3d316a6ee6d210894981e1fcc83a00a27ede2 |
80
+
54
81
  #### Components
55
82
 
56
83
  - Alert
@@ -59,7 +86,9 @@ npm i spaper
59
86
  - Breadcrumb
60
87
  - Button
61
88
  - Card
89
+ - CloseButton
62
90
  - Collapsible
91
+ - CopyButton
63
92
  - Form
64
93
  - Checkbox
65
94
  - Input
@@ -1,4 +1,5 @@
1
- <article class="article padding-small"
1
+ <article {...$$restProps}
2
+ class="{$$restProps.class ?? ''} article padding-small"
2
3
  class:border>
3
4
  <h1 class="article-title">
4
5
  {#if $$slots.title}
@@ -1,6 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ [x: string]: any;
4
5
  title?: string;
5
6
  meta?: string;
6
7
  textLead?: string;
@@ -1,4 +1,6 @@
1
- <span class={`badge ${type}`} class:rounded>
1
+ <span {...$$restProps}
2
+ class="{$$restProps.class ?? ''} badge {type}"
3
+ class:rounded>
2
4
  <slot />
3
5
  </span>
4
6
 
@@ -1,6 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ [x: string]: any;
4
5
  type?: any;
5
6
  rounded?: boolean;
6
7
  };
@@ -1,4 +1,6 @@
1
- <ul class="breadcrumb" class:border>
1
+ <ul {...$$restProps}
2
+ class="{$$restProps.class ?? ''} breadcrumb"
3
+ class:border>
2
4
  {#each items as { text, href }}
3
5
  <li>
4
6
  {#if href}
@@ -1,6 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ [x: string]: any;
4
5
  border?: boolean;
5
6
  items?: {
6
7
  text: string;
@@ -2,13 +2,14 @@
2
2
  <a {...attr}
3
3
  class:disabled
4
4
  role="button"
5
- {href}
5
+ href={href ?? 'javascript:void(0);'}
6
6
  target={external ? '_blank' : '_self'}
7
7
  on:click>
8
8
  <slot />
9
9
  </a>
10
10
  {:else}
11
11
  <button {...attr}
12
+ type={nativeType}
12
13
  class:disabled
13
14
  disabled={disabled}
14
15
  on:click>
@@ -24,8 +25,9 @@ export let size = 'default';
24
25
  export let block = false;
25
26
  export let disabled = false;
26
27
  export let outline = null;
28
+ export let nativeType = null;
27
29
  export let isLink = false;
28
- export let href = 'javascript:void(0);';
30
+ export let href = null;
29
31
  export let external = false;
30
32
  let attr;
31
33
  $: {
@@ -8,6 +8,7 @@ declare const __propDef: {
8
8
  block?: boolean;
9
9
  disabled?: boolean;
10
10
  outline?: PaperType;
11
+ nativeType?: 'submit' | 'reset' | 'button';
11
12
  isLink?: boolean;
12
13
  href?: string;
13
14
  external?: boolean;
@@ -1,4 +1,5 @@
1
- <div class="card"
1
+ <div {...$$restProps}
2
+ class="{$$restProps.class ?? ''} card"
2
3
  style={`width: ${width}`}>
3
4
  {#if header || $$slots.header}
4
5
  <header class="card-header">
@@ -2,6 +2,7 @@ import { SvelteComponentTyped } from "svelte";
2
2
  import type { PositionY } from "../types";
3
3
  declare const __propDef: {
4
4
  props: {
5
+ [x: string]: any;
5
6
  title?: string;
6
7
  subTitle?: string;
7
8
  image?: string;
@@ -0,0 +1,43 @@
1
+ <Button {...$$restProps}
2
+ aria-label={ariaLabel}
3
+ on:click
4
+ on:click={copy}>
5
+ <slot />
6
+ </Button>
7
+
8
+ <script >var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ import { createEventDispatcher } from 'svelte';
18
+ import Button from './Button.svelte';
19
+ import { success } from './Toast';
20
+ export let text;
21
+ export let successMessage = 'Copied!';
22
+ export let ariaLabel = 'Copy to clipboard';
23
+ const dispatch = createEventDispatcher();
24
+ function copy() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ if (!text)
27
+ return;
28
+ try {
29
+ yield navigator.clipboard.writeText(text);
30
+ dispatch('copy', text);
31
+ if (successMessage)
32
+ success({
33
+ message: successMessage,
34
+ position: 'top',
35
+ duration: 1000,
36
+ });
37
+ }
38
+ catch (e) {
39
+ console.error(e);
40
+ }
41
+ });
42
+ }
43
+ </script>
@@ -0,0 +1,24 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ [x: string]: any;
5
+ text: string;
6
+ successMessage?: string;
7
+ ariaLabel?: string;
8
+ };
9
+ events: {
10
+ click: MouseEvent;
11
+ copy: CustomEvent<any>;
12
+ } & {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {
16
+ default: {};
17
+ };
18
+ };
19
+ export declare type CopyButtonProps = typeof __propDef.props;
20
+ export declare type CopyButtonEvents = typeof __propDef.events;
21
+ export declare type CopyButtonSlots = typeof __propDef.slots;
22
+ export default class CopyButton extends SvelteComponentTyped<CopyButtonProps, CopyButtonEvents, CopyButtonSlots> {
23
+ }
24
+ export {};
@@ -1,4 +1,5 @@
1
- <label class="paper-check">
1
+ <label {...$$restProps}
2
+ class="{$$restProps.class ?? ''} paper-check">
2
3
  <input type="checkbox"
3
4
  {value} {name}
4
5
  {disabled}
@@ -1,6 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ [x: string]: any;
4
5
  label?: string;
5
6
  value?: string;
6
7
  name?: string;
@@ -10,8 +10,7 @@
10
10
  bind:this={rangeEl}
11
11
  bind:value
12
12
  class={classes}
13
- {min} {max} {step}
14
- on:input={updateOutput} />
13
+ {min} {max} {step} />
15
14
  {#if !hideValue}
16
15
  <output>
17
16
  {#if $$slots.output}
@@ -42,11 +41,12 @@ let outputValue;
42
41
  onMount(() => {
43
42
  outputValue = rangeEl.value;
44
43
  });
45
- function updateOutput({ target }) {
46
- outputValue = target.value;
47
- }
48
44
  let classes;
49
45
  $: classes = `range-${background} ${computeClasses('input', { block })}`;
46
+ // need to react to programmatic change to `value` as well as slider variations
47
+ $: if (value !== null) {
48
+ outputValue = String(value);
49
+ }
50
50
  $: if (percentage) {
51
51
  outputValue = String(Math.round(Number(outputValue) / Number(max) * 100));
52
52
  }
@@ -1,5 +1,6 @@
1
1
  {#if tile}
2
- <label class="paper-switch-tile"
2
+ <label {...$$restProps}
3
+ class="{$$restProps.class ?? ''} paper-switch-tile"
3
4
  class:disabled>
4
5
  <input bind:checked
5
6
  type="checkbox"
@@ -1,6 +1,8 @@
1
1
  <svelte:window on:keydown={handleKeydown} />
2
2
 
3
- <div class="modal" class:active>
3
+ <div {...$$restProps}
4
+ class="{$$restProps.class ?? ''} modal"
5
+ class:active>
4
6
  <div class="modal-body">
5
7
  <CloseButton on:click={close} />
6
8
  {#if title}
@@ -23,12 +25,14 @@
23
25
  </div>
24
26
  </div>
25
27
 
26
- <script >import Button from '../Button.svelte';
28
+ <script >import { createEventDispatcher } from 'svelte';
29
+ import Button from '../Button.svelte';
27
30
  import CloseButton from '../CloseButton.svelte';
28
31
  export let active = false;
29
32
  export let title = '';
30
33
  export let subTitle = '';
31
34
  export let closeBtnText = 'Close';
35
+ const dispatch = createEventDispatcher();
32
36
  function close() {
33
37
  active = false;
34
38
  }
@@ -36,6 +40,9 @@ function handleKeydown({ key }) {
36
40
  if (key === 'Escape')
37
41
  close();
38
42
  }
43
+ $: if (active === false) {
44
+ dispatch('close');
45
+ }
39
46
  </script>
40
47
 
41
48
  <style >.modal.active {
@@ -1,12 +1,15 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ [x: string]: any;
4
5
  active?: boolean;
5
6
  title?: string;
6
7
  subTitle?: string;
7
8
  closeBtnText?: string;
8
9
  };
9
10
  events: {
11
+ close: CustomEvent<any>;
12
+ } & {
10
13
  [evt: string]: CustomEvent<any>;
11
14
  };
12
15
  slots: {
@@ -1,4 +1,5 @@
1
- <nav class={`${$$restProps.class ?? ''} paper-navbar`}
1
+ <nav {...$$restProps}
2
+ class={`${$$restProps.class ?? ''} paper-navbar`}
2
3
  class:border class:fixed
3
4
  class:split-nav={split}>
4
5
  {#if $$slots.brand}
@@ -1,4 +1,5 @@
1
- <div { ...{[`popover-${position}`]: label} }
1
+ <div {...$$restProps}
2
+ { ...{[`popover-${position}`]: label} }
2
3
  class={`${$$restProps.class} ${bgClass(background)}`}
3
4
  class:inline
4
5
  class:active={always || active}>
@@ -1,4 +1,5 @@
1
- <div class={`progress ${$$restProps.class ?? ''}`}
1
+ <div {...$$restProps}
2
+ class={`progress ${$$restProps.class ?? ''}`}
2
3
  class:margin-bottom={marginBottom}>
3
4
  <div class={`bar ${type} w-${cappedValue}`}
4
5
  class:striped class:infinite>
@@ -1,6 +1,6 @@
1
- <table class:table-alternating={striped}
2
- class:table-hover={hoverable}
3
- {...$$restProps}>
1
+ <table {...$$restProps}
2
+ class:table-alternating={striped}
3
+ class:table-hover={hoverable}>
4
4
  {#if showHeader}
5
5
  <thead>
6
6
  <tr>
@@ -1,6 +1,11 @@
1
- <div class="content margin"
1
+ <div {...$$restProps}
2
+ class="{$$restProps.class ?? ''} content margin"
2
3
  class:content--active={active}
3
- aria-hidden={!active}>
4
+ id={controlLabel}
5
+ aria-hidden={!active}
6
+ aria-labelledby={controlLabel}
7
+ role="tabpanel"
8
+ tabindex={active ? 0 : -1}>
4
9
  {#if $$slots.header}
5
10
  <div bind:this={header}
6
11
  style="display: none">
@@ -12,6 +17,7 @@
12
17
 
13
18
  <script >import { onMount, getContext } from 'svelte';
14
19
  ;
20
+ import { genControlLabel } from './index';
15
21
  export let label;
16
22
  const key = {};
17
23
  let active = false;
@@ -32,6 +38,7 @@ onMount(() => {
32
38
  }
33
39
  ]);
34
40
  });
41
+ $: controlLabel = genControlLabel(label);
35
42
  </script>
36
43
 
37
44
  <style>
@@ -1,6 +1,7 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ [x: string]: any;
4
5
  label: string;
5
6
  };
6
7
  events: {
@@ -1,8 +1,14 @@
1
- <div class={`row flex-${placement} tabs ${$$restProps.class ?? ''}`}
1
+ <div {...$$restProps}
2
+ class={`row flex-${placement} tabs ${$$restProps.class ?? ''}`}
2
3
  style={`text-align: ${contentAlign}`}>
3
4
  {#each $tabs as { label, header }, index}
5
+ {@const selected = index == activeTab}
4
6
  <div class="tabs-label-header"
5
- class:tabs-label-header--active={index == activeTab}
7
+ class:tabs-label-header--active={selected}
8
+ aria-selected={selected}
9
+ aria-controls={genControlLabel(label)}
10
+ role="tab"
11
+ tabindex={selected ? 0 : -1}
6
12
  on:click={showContent.bind(null, index)}>
7
13
  {#if header}
8
14
  {@html header.innerHTML}
@@ -19,6 +25,7 @@
19
25
  import { writable } from 'svelte/store';
20
26
  ;
21
27
  ;
28
+ import { genControlLabel } from './index';
22
29
  export let activeTab = 0;
23
30
  export let placement = 'spaces';
24
31
  export let contentAlign = 'left';
@@ -12,4 +12,5 @@ export interface TabDataType {
12
12
  activeTab: number | string;
13
13
  tabs: Writable<iTab[]>;
14
14
  }
15
+ export declare function genControlLabel(label: string): string;
15
16
  export { Tabs, Tab };
@@ -1,3 +1,6 @@
1
1
  import Tabs from './Tabs.svelte';
2
2
  import Tab from './Tab.svelte';
3
+ export function genControlLabel(label) {
4
+ return `paper-tab-${label}`;
5
+ }
3
6
  export { Tabs, Tab };
@@ -17,11 +17,11 @@ export let position = 'top-right';
17
17
  }
18
18
 
19
19
  div {
20
+ height: 0;
20
21
  position: fixed;
21
22
  display: flex;
22
23
  width: 100%;
23
24
  padding: 2em;
24
- overflow: hidden;
25
25
  z-index: 9999;
26
26
  flex-direction: column;
27
27
  }
package/index.d.ts CHANGED
@@ -14,4 +14,6 @@ import Progress from './components/Progress.svelte';
14
14
  import Table from './components/Table.svelte';
15
15
  import Pagination from './components/Pagination';
16
16
  import Toast from './components/Toast';
17
- export { Button, Alert, Badge, Breadcrumb, Navbar, Modal, Tabs, Tab, Form, Input, Select, Radio, Checkbox, Switch, Slider, Article, Card, Collapsible, Popover, Progress, Table, Pagination, Toast, };
17
+ import CloseButton from './components/CloseButton.svelte';
18
+ import CopyButton from './components/CopyButton.svelte';
19
+ export { Button, Alert, Badge, Breadcrumb, Navbar, Modal, Tabs, Tab, Form, Input, Select, Radio, Checkbox, Switch, Slider, Article, Card, Collapsible, Popover, Progress, Table, Pagination, Toast, CloseButton, CopyButton, };
package/index.js CHANGED
@@ -14,4 +14,6 @@ import Progress from './components/Progress.svelte';
14
14
  import Table from './components/Table.svelte';
15
15
  import Pagination from './components/Pagination';
16
16
  import Toast from './components/Toast';
17
- export { Button, Alert, Badge, Breadcrumb, Navbar, Modal, Tabs, Tab, Form, Input, Select, Radio, Checkbox, Switch, Slider, Article, Card, Collapsible, Popover, Progress, Table, Pagination, Toast, };
17
+ import CloseButton from './components/CloseButton.svelte';
18
+ import CopyButton from './components/CopyButton.svelte';
19
+ export { Button, Alert, Badge, Breadcrumb, Navbar, Modal, Tabs, Tab, Form, Input, Select, Radio, Checkbox, Switch, Slider, Article, Card, Collapsible, Popover, Progress, Table, Pagination, Toast, CloseButton, CopyButton, };
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "papercss",
9
9
  "components"
10
10
  ],
11
- "version": "0.3.6",
11
+ "version": "0.6.6",
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "git+https://github.com/Oli8/spaper.git"
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "homepage": "https://github.com/Oli8/spaper#readme",
20
20
  "peerDependencies": {
21
- "papercss": "^1.8.3"
21
+ "papercss": "^1.8.2"
22
22
  },
23
23
  "type": "module",
24
24
  "exports": {
@@ -31,6 +31,7 @@
31
31
  "./components/Card.svelte": "./components/Card.svelte",
32
32
  "./components/CloseButton.svelte": "./components/CloseButton.svelte",
33
33
  "./components/Collapsible.svelte": "./components/Collapsible.svelte",
34
+ "./components/CopyButton.svelte": "./components/CopyButton.svelte",
34
35
  "./components/Form/Checkbox.svelte": "./components/Form/Checkbox.svelte",
35
36
  "./components/Form/Form.svelte": "./components/Form/Form.svelte",
36
37
  "./components/Form/Input.svelte": "./components/Form/Input.svelte",
@@ -62,4 +63,4 @@
62
63
  "./utils": "./utils.js"
63
64
  },
64
65
  "svelte": "./index.js"
65
- }
66
+ }