spaper 0.6.6 → 0.7.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.
@@ -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,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;
@@ -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/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "papercss",
9
9
  "components"
10
10
  ],
11
- "version": "0.6.6",
11
+ "version": "0.7.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": {
@@ -55,6 +55,7 @@
55
55
  "./components/Tabs/Tab.svelte": "./components/Tabs/Tab.svelte",
56
56
  "./components/Tabs/Tabs.svelte": "./components/Tabs/Tabs.svelte",
57
57
  "./components/Tabs": "./components/Tabs/index.js",
58
+ "./components/Tabs/utils": "./components/Tabs/utils.js",
58
59
  "./components/Toast/Toast.svelte": "./components/Toast/Toast.svelte",
59
60
  "./components/Toast/ToastContainer.svelte": "./components/Toast/ToastContainer.svelte",
60
61
  "./components/Toast": "./components/Toast/index.js",
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 {};