spaper 0.4.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.
- package/README.md +27 -0
- package/components/Button.svelte +2 -0
- package/components/Button.svelte.d.ts +1 -0
- package/components/Form/Form.svelte.d.ts +6 -8
- package/components/Form/Slider.svelte +5 -5
- package/components/Modal/Modal.svelte +18 -5
- package/components/Modal/Modal.svelte.d.ts +5 -0
- package/components/Modal/index.d.ts +12 -1
- package/components/Modal/index.js +8 -3
- package/components/Tabs/Tab.svelte +7 -1
- package/components/Tabs/Tabs.svelte +7 -1
- package/components/Tabs/index.d.ts +2 -15
- package/components/Tabs/index.js +2 -3
- package/components/Tabs/utils.d.ts +14 -0
- package/components/Tabs/utils.js +3 -0
- package/package.json +3 -2
- package/utils.d.ts +3 -0
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
|
package/components/Button.svelte
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
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,6 +25,7 @@ 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
30
|
export let href = null;
|
|
29
31
|
export let external = false;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
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 {};
|
|
@@ -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,9 +1,9 @@
|
|
|
1
1
|
<svelte:window on:keydown={handleKeydown} />
|
|
2
2
|
|
|
3
|
-
<div
|
|
4
|
-
class="{$$restProps.class ?? ''} modal"
|
|
3
|
+
<div class="modal"
|
|
5
4
|
class:active>
|
|
6
|
-
<div
|
|
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
|
-
|
|
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,16 @@
|
|
|
25
31
|
</div>
|
|
26
32
|
</div>
|
|
27
33
|
|
|
28
|
-
<script >import
|
|
34
|
+
<script >import { createEventDispatcher, SvelteComponent } from 'svelte';
|
|
35
|
+
import Button from '../Button.svelte';
|
|
29
36
|
import CloseButton from '../CloseButton.svelte';
|
|
30
37
|
export let active = false;
|
|
31
38
|
export let title = '';
|
|
32
39
|
export let subTitle = '';
|
|
40
|
+
export let content = '';
|
|
41
|
+
export let component = null;
|
|
33
42
|
export let closeBtnText = 'Close';
|
|
43
|
+
const dispatch = createEventDispatcher();
|
|
34
44
|
function close() {
|
|
35
45
|
active = false;
|
|
36
46
|
}
|
|
@@ -38,6 +48,9 @@ function handleKeydown({ key }) {
|
|
|
38
48
|
if (key === 'Escape')
|
|
39
49
|
close();
|
|
40
50
|
}
|
|
51
|
+
$: if (!active) {
|
|
52
|
+
dispatch('close');
|
|
53
|
+
}
|
|
41
54
|
</script>
|
|
42
55
|
|
|
43
56
|
<style >.modal.active {
|
|
@@ -1,13 +1,18 @@
|
|
|
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: {
|
|
14
|
+
close: CustomEvent<any>;
|
|
15
|
+
} & {
|
|
11
16
|
[evt: string]: CustomEvent<any>;
|
|
12
17
|
};
|
|
13
18
|
slots: {
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
import type { SvelteComponent } from 'svelte';
|
|
2
|
+
import type { ComponentProps } from '../../utils';
|
|
1
3
|
import Modal from './Modal.svelte';
|
|
2
|
-
|
|
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
|
|
6
|
-
intro: true
|
|
6
|
+
props,
|
|
7
7
|
});
|
|
8
|
-
|
|
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;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<div {...$$restProps}
|
|
2
2
|
class="{$$restProps.class ?? ''} content margin"
|
|
3
3
|
class:content--active={active}
|
|
4
|
-
|
|
4
|
+
id={controlLabel}
|
|
5
|
+
aria-hidden={!active}
|
|
6
|
+
aria-labelledby={controlLabel}
|
|
7
|
+
role="tabpanel"
|
|
8
|
+
tabindex={active ? 0 : -1}>
|
|
5
9
|
{#if $$slots.header}
|
|
6
10
|
<div bind:this={header}
|
|
7
11
|
style="display: none">
|
|
@@ -13,6 +17,7 @@
|
|
|
13
17
|
|
|
14
18
|
<script >import { onMount, getContext } from 'svelte';
|
|
15
19
|
;
|
|
20
|
+
import { genControlLabel } from './utils';
|
|
16
21
|
export let label;
|
|
17
22
|
const key = {};
|
|
18
23
|
let active = false;
|
|
@@ -33,6 +38,7 @@ onMount(() => {
|
|
|
33
38
|
}
|
|
34
39
|
]);
|
|
35
40
|
});
|
|
41
|
+
$: controlLabel = genControlLabel(label);
|
|
36
42
|
</script>
|
|
37
43
|
|
|
38
44
|
<style>
|
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
class={`row flex-${placement} tabs ${$$restProps.class ?? ''}`}
|
|
3
3
|
style={`text-align: ${contentAlign}`}>
|
|
4
4
|
{#each $tabs as { label, header }, index}
|
|
5
|
+
{@const selected = index == activeTab}
|
|
5
6
|
<div class="tabs-label-header"
|
|
6
|
-
class:tabs-label-header--active={
|
|
7
|
+
class:tabs-label-header--active={selected}
|
|
8
|
+
aria-selected={selected}
|
|
9
|
+
aria-controls={genControlLabel(label)}
|
|
10
|
+
role="tab"
|
|
11
|
+
tabindex={selected ? 0 : -1}
|
|
7
12
|
on:click={showContent.bind(null, index)}>
|
|
8
13
|
{#if header}
|
|
9
14
|
{@html header.innerHTML}
|
|
@@ -20,6 +25,7 @@
|
|
|
20
25
|
import { writable } from 'svelte/store';
|
|
21
26
|
;
|
|
22
27
|
;
|
|
28
|
+
import { genControlLabel } from './utils';
|
|
23
29
|
export let activeTab = 0;
|
|
24
30
|
export let placement = 'spaces';
|
|
25
31
|
export let contentAlign = 'left';
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { Tabs, Tab };
|
|
1
|
+
export { default as Tabs } from './Tabs.svelte';
|
|
2
|
+
export { default as Tab } from './Tab.svelte';
|
package/components/Tabs/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
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 {};
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"papercss",
|
|
9
9
|
"components"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.7.6",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "git+https://github.com/Oli8/spaper.git"
|
|
@@ -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",
|
|
@@ -63,4 +64,4 @@
|
|
|
63
64
|
"./utils": "./utils.js"
|
|
64
65
|
},
|
|
65
66
|
"svelte": "./index.js"
|
|
66
|
-
}
|
|
67
|
+
}
|
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 {};
|