spaper 0.6.6 → 0.9.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
@@ -63,6 +63,12 @@ Thanks to these generous people! :heart:
63
63
  <sub><b>mehdi-dalil</b></sub>
64
64
  </a>
65
65
  </td>
66
+ <td align="center">
67
+ <a href="https://github.com/t0kido">
68
+ <img src="https://avatars.githubusercontent.com/u/12486500?v=4" width="80px;" alt=""/><br />
69
+ <sub><b>t0kido</b></sub>
70
+ </a>
71
+ </td>
66
72
  </tr>
67
73
  </table>
68
74
 
@@ -1,9 +1,9 @@
1
1
  {#if isLink || href}
2
- <a {...attr}
3
- class:disabled
2
+ <a class:disabled
4
3
  role="button"
5
4
  href={href ?? 'javascript:void(0);'}
6
- target={external ? '_blank' : '_self'}
5
+ target={external ? '_blank' : null}
6
+ {...attr}
7
7
  on:click>
8
8
  <slot />
9
9
  </a>
@@ -1,4 +1,10 @@
1
1
  <form {...$$restProps}
2
- class="{$$restProps.class ?? ''} form-group">
2
+ class="{$$restProps.class ?? ''} form-group"
3
+ on:submit|preventDefault
4
+ on:click
5
+ on:keydown
6
+ on:mouseover
7
+ on:mouseenter
8
+ on:mouseleave>
3
9
  <slot />
4
10
  </form>
@@ -1,11 +1,4 @@
1
- /** @typedef {typeof __propDef.props} FormProps */
2
- /** @typedef {typeof __propDef.events} FormEvents */
3
- /** @typedef {typeof __propDef.slots} FormSlots */
4
- export default class Form {
5
- }
6
- export type FormProps = typeof __propDef.props;
7
- export type FormEvents = typeof __propDef.events;
8
- export type FormSlots = typeof __propDef.slots;
1
+ import { SvelteComponentTyped } from "svelte";
9
2
  declare const __propDef: {
10
3
  props: {
11
4
  [x: string]: any;
@@ -17,4 +10,9 @@ declare const __propDef: {
17
10
  default: {};
18
11
  };
19
12
  };
13
+ export declare type FormProps = typeof __propDef.props & svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["form"]>;
14
+ export declare type FormEvents = typeof __propDef.events;
15
+ export declare type FormSlots = typeof __propDef.slots;
16
+ export default class Form extends SvelteComponentTyped<FormProps, FormEvents, FormSlots> {
17
+ }
20
18
  export {};
@@ -1,15 +1,4 @@
1
- {#if label}
2
- <label>
3
- {label}
4
- <input type="radio"
5
- {value}
6
- {...$$restProps}
7
- bind:group
8
- on:focus
9
- on:blur
10
- on:change />
11
- </label>
12
- {:else}
1
+ <label class="paper-radio">
13
2
  <input type="radio"
14
3
  {value}
15
4
  {...$$restProps}
@@ -17,9 +6,21 @@
17
6
  on:focus
18
7
  on:blur
19
8
  on:change />
20
- {/if}
9
+ <span>
10
+ {#if $$slots.default}
11
+ <slot />
12
+ {:else}
13
+ {label}
14
+ {/if}
15
+ </span>
16
+ </label>
21
17
 
22
18
  <script >export let label = '';
23
19
  export let value = '';
24
20
  export let group = '';
25
21
  </script>
22
+
23
+ <style >input[disabled] + span::before, input[disabled] ~ span {
24
+ opacity: 0.5;
25
+ cursor: not-allowed;
26
+ }</style>
@@ -13,7 +13,9 @@ declare const __propDef: {
13
13
  } & {
14
14
  [evt: string]: CustomEvent<any>;
15
15
  };
16
- slots: {};
16
+ slots: {
17
+ default: {};
18
+ };
17
19
  };
18
20
  export declare type RadioProps = typeof __propDef.props;
19
21
  export declare type RadioEvents = typeof __propDef.events;
@@ -1,9 +1,9 @@
1
1
  <svelte:window on:keydown={handleKeydown} />
2
2
 
3
- <div {...$$restProps}
4
- class="{$$restProps.class ?? ''} modal"
3
+ <div class="modal"
5
4
  class:active>
6
- <div class="modal-body">
5
+ <div {...$$restProps}
6
+ class="{$$restProps.class ?? ''} modal-body">
7
7
  <CloseButton on:click={close} />
8
8
  {#if title}
9
9
  <h4 class="modal-title">{title}</h4>
@@ -12,7 +12,13 @@
12
12
  <h5 class="modal-subtitle">{subTitle}</h5>
13
13
  {/if}
14
14
  <p class="modal-text">
15
- <slot />
15
+ {#if content}
16
+ {content}
17
+ {:else if component}
18
+ <svelte:component this={component} />
19
+ {:else}
20
+ <slot />
21
+ {/if}
16
22
  </p>
17
23
  <footer>
18
24
  {#if $$slots.footer}
@@ -25,12 +31,14 @@
25
31
  </div>
26
32
  </div>
27
33
 
28
- <script >import { createEventDispatcher } from 'svelte';
34
+ <script >import { createEventDispatcher, SvelteComponent } from 'svelte';
29
35
  import Button from '../Button.svelte';
30
36
  import CloseButton from '../CloseButton.svelte';
31
37
  export let active = false;
32
38
  export let title = '';
33
39
  export let subTitle = '';
40
+ export let content = '';
41
+ export let component = null;
34
42
  export let closeBtnText = 'Close';
35
43
  const dispatch = createEventDispatcher();
36
44
  function close() {
@@ -40,7 +48,7 @@ function handleKeydown({ key }) {
40
48
  if (key === 'Escape')
41
49
  close();
42
50
  }
43
- $: if (active === false) {
51
+ $: if (!active) {
44
52
  dispatch('close');
45
53
  }
46
54
  </script>
@@ -1,10 +1,13 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
+ import { SvelteComponent } from 'svelte';
2
3
  declare const __propDef: {
3
4
  props: {
4
5
  [x: string]: any;
5
6
  active?: boolean;
6
7
  title?: string;
7
8
  subTitle?: string;
9
+ content?: string;
10
+ component?: typeof SvelteComponent;
8
11
  closeBtnText?: string;
9
12
  };
10
13
  events: {
@@ -1,2 +1,13 @@
1
+ import type { SvelteComponent } from 'svelte';
2
+ import type { ComponentProps } from '../../utils';
1
3
  import Modal from './Modal.svelte';
2
- export default Modal;
4
+ declare type ModalProps = ComponentProps<Modal>;
5
+ declare type ProgrammaticModalProps = Omit<ModalProps, 'active'>;
6
+ interface ProgrammaticModal {
7
+ open?: (props: ProgrammaticModalProps) => ProgrammaticModalInstance;
8
+ close?: () => void;
9
+ }
10
+ declare type ProgrammaticModalComponent = ProgrammaticModal & typeof SvelteComponent;
11
+ declare type ProgrammaticModalInstance = ProgrammaticModal & SvelteComponent;
12
+ declare const _default: ProgrammaticModalComponent;
13
+ export default _default;
@@ -1,11 +1,16 @@
1
1
  import Modal from './Modal.svelte';
2
+ const TRANSITION_TIME = 235;
2
3
  function open(props) {
3
4
  const modal = new Modal({
4
5
  target: document.body,
5
- props: { active: true, ...props },
6
- intro: true
6
+ props,
7
7
  });
8
- modal.close = modal.$destroy;
8
+ // Preserve transition
9
+ setTimeout(modal.$set.bind(modal, { active: true }), 1);
10
+ modal.close = () => {
11
+ modal.$set({ active: false });
12
+ setTimeout(modal.$destroy, TRANSITION_TIME);
13
+ };
9
14
  return modal;
10
15
  }
11
16
  Modal.open = open;
@@ -0,0 +1,55 @@
1
+ {#if active}
2
+ {#each { length: count } as _}
3
+ {@const borderType = Math.floor(Math.random() * 6 + 1)}
4
+ <div {...$$restProps}
5
+ aria-hidden="true"
6
+ aria-valuetext={ariaValueText}
7
+ tabindex="-1"
8
+ role="progressbar"
9
+ class="border border-{borderType} margin-small"
10
+ class:animated
11
+ class:circle
12
+ class:inline>
13
+ </div>
14
+ {/each}
15
+ {/if}
16
+
17
+ <script >export let active = true;
18
+ export let count = 1;
19
+ export let animated = true;
20
+ export let circle = false;
21
+ export let inline = false;
22
+ export let ariaValueText = 'Loading...';
23
+ </script>
24
+
25
+ <style >:global(.dark) div {
26
+ --mid-gradient: var(--primary-dark);
27
+ }
28
+
29
+ div {
30
+ cursor: progress;
31
+ border-color: transparent;
32
+ width: var(--width, auto);
33
+ min-height: 1rem;
34
+ height: var(--height, 100%);
35
+ background: var(--muted-light-10);
36
+ background: linear-gradient(95deg, var(--muted-light-10) 5%, var(--mid-gradient, var(--muted-light)) 20%, var(--muted-light-10) 50%);
37
+ background-size: 200% 100%;
38
+ }
39
+ div.circle {
40
+ border-radius: 50%;
41
+ }
42
+ div.inline {
43
+ display: inline-block;
44
+ }
45
+
46
+ @media (prefers-reduced-motion: no-preference) {
47
+ .animated {
48
+ animation: loading 2s linear infinite alternate;
49
+ }
50
+ }
51
+ @keyframes loading {
52
+ to {
53
+ background-position-x: -200%;
54
+ }
55
+ }</style>
@@ -0,0 +1,22 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {
4
+ [x: string]: any;
5
+ active?: boolean;
6
+ count?: number;
7
+ animated?: boolean;
8
+ circle?: boolean;
9
+ inline?: boolean;
10
+ ariaValueText?: string;
11
+ };
12
+ events: {
13
+ [evt: string]: CustomEvent<any>;
14
+ };
15
+ slots: {};
16
+ };
17
+ export declare type SkeletonProps = typeof __propDef.props;
18
+ export declare type SkeletonEvents = typeof __propDef.events;
19
+ export declare type SkeletonSlots = typeof __propDef.slots;
20
+ export default class Skeleton extends SvelteComponentTyped<SkeletonProps, SkeletonEvents, SkeletonSlots> {
21
+ }
22
+ export {};
@@ -41,7 +41,8 @@
41
41
  </tbody>
42
42
  </table>
43
43
 
44
- <script >let tmpCol;
44
+ <script >;
45
+ let tmpCol;
45
46
  export let columns = [];
46
47
  export let data = [];
47
48
  export let striped = false;
@@ -0,0 +1,24 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { TableColumn as Column } from '../types';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ columns?: Column[];
7
+ data?: {}[];
8
+ striped?: boolean;
9
+ hoverable?: boolean;
10
+ showHeader?: boolean;
11
+ headerCLass?: string;
12
+ cellCLass?: string;
13
+ };
14
+ events: {
15
+ [evt: string]: CustomEvent<any>;
16
+ };
17
+ slots: {};
18
+ };
19
+ export declare type TableProps = typeof __propDef.props;
20
+ export declare type TableEvents = typeof __propDef.events;
21
+ export declare type TableSlots = typeof __propDef.slots;
22
+ export default class Table extends SvelteComponentTyped<TableProps, TableEvents, TableSlots> {
23
+ }
24
+ export {};
@@ -17,7 +17,7 @@
17
17
 
18
18
  <script >import { onMount, getContext } from 'svelte';
19
19
  ;
20
- import { genControlLabel } from './index';
20
+ import { genControlLabel } from './utils';
21
21
  export let label;
22
22
  const key = {};
23
23
  let active = false;
@@ -25,7 +25,7 @@
25
25
  import { writable } from 'svelte/store';
26
26
  ;
27
27
  ;
28
- import { genControlLabel } from './index';
28
+ import { genControlLabel } from './utils';
29
29
  export let activeTab = 0;
30
30
  export let placement = 'spaces';
31
31
  export let contentAlign = 'left';
@@ -1,16 +1,2 @@
1
- import type { Writable } from 'svelte/store';
2
- import Tabs from './Tabs.svelte';
3
- import Tab from './Tab.svelte';
4
- export interface iTab {
5
- key: Object;
6
- label: string;
7
- header?: HTMLElement;
8
- show: () => void;
9
- hide: () => void;
10
- }
11
- export interface TabDataType {
12
- activeTab: number | string;
13
- tabs: Writable<iTab[]>;
14
- }
15
- export declare function genControlLabel(label: string): string;
16
- export { Tabs, Tab };
1
+ export { default as Tabs } from './Tabs.svelte';
2
+ export { default as Tab } from './Tab.svelte';
@@ -1,6 +1,2 @@
1
- import Tabs from './Tabs.svelte';
2
- import Tab from './Tab.svelte';
3
- export function genControlLabel(label) {
4
- return `paper-tab-${label}`;
5
- }
6
- export { Tabs, Tab };
1
+ export { default as Tabs } from './Tabs.svelte';
2
+ export { default as Tab } from './Tab.svelte';
@@ -0,0 +1,14 @@
1
+ import type { Writable } from 'svelte/store';
2
+ interface iTab {
3
+ key: Object;
4
+ label: string;
5
+ header?: HTMLElement;
6
+ show: () => void;
7
+ hide: () => void;
8
+ }
9
+ export interface TabDataType {
10
+ activeTab: number | string;
11
+ tabs: Writable<iTab[]>;
12
+ }
13
+ export declare function genControlLabel(label: string): string;
14
+ export {};
@@ -0,0 +1,3 @@
1
+ export function genControlLabel(label) {
2
+ return `paper-tab-${label}`;
3
+ }
package/index.d.ts CHANGED
@@ -16,4 +16,5 @@ import Pagination from './components/Pagination';
16
16
  import Toast from './components/Toast';
17
17
  import CloseButton from './components/CloseButton.svelte';
18
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, };
19
+ import Skeleton from './components/Skeleton.svelte';
20
+ 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, Skeleton, };
package/index.js CHANGED
@@ -16,4 +16,5 @@ import Pagination from './components/Pagination';
16
16
  import Toast from './components/Toast';
17
17
  import CloseButton from './components/CloseButton.svelte';
18
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, };
19
+ import Skeleton from './components/Skeleton.svelte';
20
+ 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, Skeleton, };
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "papercss",
9
9
  "components"
10
10
  ],
11
- "version": "0.6.6",
11
+ "version": "0.9.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.2"
21
+ "papercss": "^1.8.3"
22
22
  },
23
23
  "type": "module",
24
24
  "exports": {
@@ -51,10 +51,12 @@
51
51
  "./components/Pagination": "./components/Pagination/index.js",
52
52
  "./components/Popover.svelte": "./components/Popover.svelte",
53
53
  "./components/Progress.svelte": "./components/Progress.svelte",
54
+ "./components/Skeleton.svelte": "./components/Skeleton.svelte",
54
55
  "./components/Table.svelte": "./components/Table.svelte",
55
56
  "./components/Tabs/Tab.svelte": "./components/Tabs/Tab.svelte",
56
57
  "./components/Tabs/Tabs.svelte": "./components/Tabs/Tabs.svelte",
57
58
  "./components/Tabs": "./components/Tabs/index.js",
59
+ "./components/Tabs/utils": "./components/Tabs/utils.js",
58
60
  "./components/Toast/Toast.svelte": "./components/Toast/Toast.svelte",
59
61
  "./components/Toast/ToastContainer.svelte": "./components/Toast/ToastContainer.svelte",
60
62
  "./components/Toast": "./components/Toast/index.js",
package/types.d.ts CHANGED
@@ -11,3 +11,12 @@ export type Attributes = Record<string, string|boolean>;
11
11
  export type PositionY = 'top' | 'bottom';
12
12
  export type PositionX = 'left' | 'right';
13
13
  export type Position = PositionX | PositionY;
14
+
15
+ export interface TableColumnObj {
16
+ field: string;
17
+ label?: string;
18
+ content?: (text?: string) => string;
19
+ html?: boolean;
20
+ }
21
+
22
+ export type TableColumn = TableColumnObj | string;
package/utils.d.ts CHANGED
@@ -6,4 +6,7 @@ interface getDomAttributesParams {
6
6
  }
7
7
  export declare function computeClasses(elPrefix: string, props: Record<string, any>): string;
8
8
  export declare function getDomAttributes({ props, classes, toOmit }: getDomAttributesParams): Attributes;
9
+ export declare type ComponentProps<T extends {
10
+ $set: (...args: any) => any;
11
+ }> = NonNullable<Parameters<T['$set']>[0]>;
9
12
  export {};