spaper 0.9.6 → 1.1.0
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 +6 -3
- package/components/Card.svelte.d.ts +1 -1
- package/components/Carousel/Carousel.svelte +128 -0
- package/components/Carousel/Carousel.svelte.d.ts +35 -0
- package/components/Carousel/CarouselItem.svelte +32 -0
- package/components/Carousel/CarouselItem.svelte.d.ts +18 -0
- package/components/Carousel/index.d.ts +2 -0
- package/components/Carousel/index.js +2 -0
- package/components/Carousel/types.d.ts +14 -0
- package/components/Carousel/types.js +1 -0
- package/components/Form/Form.svelte.d.ts +7 -0
- package/components/Hero.svelte +59 -0
- package/components/Hero.svelte.d.ts +26 -0
- package/components/Pagination/Pagination.svelte +23 -8
- package/components/Pagination/Pagination.svelte.d.ts +2 -0
- package/components/Tabs/Tab.svelte +9 -5
- package/components/Tabs/Tabs.svelte +5 -4
- package/components/Tabs/utils.d.ts +1 -1
- package/components/Tabs/utils.js +2 -2
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +7 -2
- package/types.d.ts +4 -0
- package/utils.d.ts +4 -0
- package/utils.js +8 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Browse [documentation and demo here](https://oli8.github.io/spaper/).
|
|
|
14
14
|
Add a link to the CDN into your HTML file:
|
|
15
15
|
|
|
16
16
|
```html
|
|
17
|
-
<link rel="stylesheet" href="https://unpkg.com/papercss@1.
|
|
17
|
+
<link rel="stylesheet" href="https://unpkg.com/papercss@1.9.1/dist/paper.min.css">
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
Or use NPM:
|
|
@@ -70,7 +70,7 @@ Thanks to these generous people! :heart:
|
|
|
70
70
|
</a>
|
|
71
71
|
</td>
|
|
72
72
|
</tr>
|
|
73
|
-
</table>
|
|
73
|
+
</table>
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
### Donate
|
|
@@ -82,7 +82,7 @@ Any donation is greatly appreciated :heart:
|
|
|
82
82
|
| Github Sponsor | https://github.com/sponsors/Oli8 |
|
|
83
83
|
| PayPal | https://paypal.me/OliCrt |
|
|
84
84
|
| Bitcoin | 1Ez3Ts2WShUcbeGCjhZapdxVDK77DbYjdU |
|
|
85
|
-
| Ethereum |
|
|
85
|
+
| Ethereum | 0xc4364cafac87fd8085dc26af4a4a8c3bbad1bd3e |
|
|
86
86
|
|
|
87
87
|
#### Components
|
|
88
88
|
|
|
@@ -92,6 +92,7 @@ Any donation is greatly appreciated :heart:
|
|
|
92
92
|
- Breadcrumb
|
|
93
93
|
- Button
|
|
94
94
|
- Card
|
|
95
|
+
- Carousel
|
|
95
96
|
- CloseButton
|
|
96
97
|
- Collapsible
|
|
97
98
|
- CopyButton
|
|
@@ -102,11 +103,13 @@ Any donation is greatly appreciated :heart:
|
|
|
102
103
|
- Select
|
|
103
104
|
- Slider
|
|
104
105
|
- Switch
|
|
106
|
+
- Hero
|
|
105
107
|
- Modal
|
|
106
108
|
- Navbar
|
|
107
109
|
- Pagination
|
|
108
110
|
- Popover
|
|
109
111
|
- Progress
|
|
112
|
+
- Skeleton
|
|
110
113
|
- Table
|
|
111
114
|
- Tabs
|
|
112
115
|
- Toast
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<section {...$$restProps} tabindex="0"
|
|
2
|
+
class="{$$restProps.class ?? ''} carousel"
|
|
3
|
+
on:click
|
|
4
|
+
on:keydown
|
|
5
|
+
on:keydown={handleKeydown}
|
|
6
|
+
on:mouseover
|
|
7
|
+
on:focus
|
|
8
|
+
on:mouseenter
|
|
9
|
+
on:mouseenter={pause}
|
|
10
|
+
on:mouseleave
|
|
11
|
+
on:mouseleave={resume}>
|
|
12
|
+
<div class="carousel-panel">
|
|
13
|
+
<slot />
|
|
14
|
+
{#if bullets}
|
|
15
|
+
<Pagination class="carousel-bullets margin-top-small"
|
|
16
|
+
total={length}
|
|
17
|
+
pageSize={1}
|
|
18
|
+
current={index + 1}
|
|
19
|
+
bullets
|
|
20
|
+
on:change={navigationHandler} />
|
|
21
|
+
{/if}
|
|
22
|
+
</div>
|
|
23
|
+
</section>
|
|
24
|
+
|
|
25
|
+
<script >import { onMount, setContext, createEventDispatcher } from 'svelte';
|
|
26
|
+
import { writable } from 'svelte/store';
|
|
27
|
+
;
|
|
28
|
+
;
|
|
29
|
+
import Pagination from '../Pagination/Pagination.svelte';
|
|
30
|
+
export let index = 0;
|
|
31
|
+
export let interval = 2500;
|
|
32
|
+
export let autoplay = true;
|
|
33
|
+
export let repeat = true;
|
|
34
|
+
export let pauseOnHover = true;
|
|
35
|
+
export let bullets = true;
|
|
36
|
+
export let keyNavigation = true;
|
|
37
|
+
export let transition = 'fade';
|
|
38
|
+
const dispatch = createEventDispatcher();
|
|
39
|
+
let intervalId;
|
|
40
|
+
const items = writable([]);
|
|
41
|
+
const transitionStore = writable(transition);
|
|
42
|
+
const itemsData = {
|
|
43
|
+
activeItem: index,
|
|
44
|
+
items,
|
|
45
|
+
transition: transitionStore,
|
|
46
|
+
};
|
|
47
|
+
setContext('carouselItems', itemsData);
|
|
48
|
+
onMount(() => {
|
|
49
|
+
$items[index].show();
|
|
50
|
+
if (autoplay) {
|
|
51
|
+
setUpAutoplay();
|
|
52
|
+
return () => clearInterval(intervalId);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
function setUpAutoplay() {
|
|
56
|
+
if (intervalId)
|
|
57
|
+
clearInterval(intervalId);
|
|
58
|
+
intervalId = window.setInterval(() => {
|
|
59
|
+
index = (index + 1) % length;
|
|
60
|
+
if (!repeat && index === length - 1) {
|
|
61
|
+
clearInterval(intervalId);
|
|
62
|
+
}
|
|
63
|
+
}, interval);
|
|
64
|
+
}
|
|
65
|
+
function navigationHandler({ detail: value }) {
|
|
66
|
+
goToItem(value - 1);
|
|
67
|
+
}
|
|
68
|
+
function goToItem(idx) {
|
|
69
|
+
if (autoplay) {
|
|
70
|
+
setUpAutoplay();
|
|
71
|
+
}
|
|
72
|
+
index = idx;
|
|
73
|
+
}
|
|
74
|
+
function pause() {
|
|
75
|
+
if (!pauseOnHover || !autoplay)
|
|
76
|
+
return;
|
|
77
|
+
clearInterval(intervalId);
|
|
78
|
+
}
|
|
79
|
+
function resume() {
|
|
80
|
+
if (!pauseOnHover || !autoplay)
|
|
81
|
+
return;
|
|
82
|
+
setUpAutoplay();
|
|
83
|
+
}
|
|
84
|
+
function handleKeydown({ key }) {
|
|
85
|
+
if (!keyNavigation)
|
|
86
|
+
return;
|
|
87
|
+
switch (key) {
|
|
88
|
+
case 'ArrowRight':
|
|
89
|
+
goToItem((index + 1) % length);
|
|
90
|
+
break;
|
|
91
|
+
case 'ArrowLeft':
|
|
92
|
+
goToItem((length + index - 1) % length);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function updateTabsVisility() {
|
|
97
|
+
$items.forEach((item, idx) => {
|
|
98
|
+
if (idx === index)
|
|
99
|
+
item.show();
|
|
100
|
+
else
|
|
101
|
+
item.hide();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
$: if (index > -1) {
|
|
105
|
+
updateTabsVisility();
|
|
106
|
+
dispatch('change', index);
|
|
107
|
+
}
|
|
108
|
+
$: $transitionStore = transition;
|
|
109
|
+
$: ({ length } = $items);
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<style >.carousel {
|
|
113
|
+
outline: none;
|
|
114
|
+
}
|
|
115
|
+
.carousel-panel {
|
|
116
|
+
position: relative;
|
|
117
|
+
display: inline-block;
|
|
118
|
+
min-height: var(--min-height, 120px);
|
|
119
|
+
height: var(--height, auto);
|
|
120
|
+
max-height: var(--max-height, none);
|
|
121
|
+
min-width: var(--min-width, 0);
|
|
122
|
+
width: var(--width, auto);
|
|
123
|
+
max-width: var(--min-width, none);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
:global(.carousel-bullets) {
|
|
127
|
+
text-align: center;
|
|
128
|
+
}</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { Transition } from '../../types';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
index?: number;
|
|
7
|
+
interval?: number;
|
|
8
|
+
autoplay?: boolean;
|
|
9
|
+
repeat?: boolean;
|
|
10
|
+
pauseOnHover?: boolean;
|
|
11
|
+
bullets?: boolean;
|
|
12
|
+
keyNavigation?: boolean;
|
|
13
|
+
transition?: Transition | null;
|
|
14
|
+
};
|
|
15
|
+
events: {
|
|
16
|
+
click: MouseEvent;
|
|
17
|
+
keydown: KeyboardEvent;
|
|
18
|
+
mouseover: MouseEvent;
|
|
19
|
+
focus: FocusEvent;
|
|
20
|
+
mouseenter: MouseEvent;
|
|
21
|
+
mouseleave: MouseEvent;
|
|
22
|
+
change: CustomEvent<any>;
|
|
23
|
+
} & {
|
|
24
|
+
[evt: string]: CustomEvent<any>;
|
|
25
|
+
};
|
|
26
|
+
slots: {
|
|
27
|
+
default: {};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare type CarouselProps = typeof __propDef.props;
|
|
31
|
+
export declare type CarouselEvents = typeof __propDef.events;
|
|
32
|
+
export declare type CarouselSlots = typeof __propDef.slots;
|
|
33
|
+
export default class Carousel extends SvelteComponentTyped<CarouselProps, CarouselEvents, CarouselSlots> {
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{#if active}
|
|
2
|
+
<div {...$$restProps}
|
|
3
|
+
class="{$$restProps.class ?? ''} carousel-item"
|
|
4
|
+
in:configureTransition={{
|
|
5
|
+
name: $transition,
|
|
6
|
+
disabled: !$transition,
|
|
7
|
+
}}>
|
|
8
|
+
<slot />
|
|
9
|
+
</div>
|
|
10
|
+
{/if}
|
|
11
|
+
|
|
12
|
+
<script >import { onMount, onDestroy, getContext } from 'svelte';
|
|
13
|
+
;
|
|
14
|
+
import { configureTransition } from '../../utils';
|
|
15
|
+
const key = Symbol();
|
|
16
|
+
let active = false;
|
|
17
|
+
const itemsData = getContext('carouselItems');
|
|
18
|
+
if (!itemsData)
|
|
19
|
+
throw new Error('CarouselItem should be nested inside a Carousel');
|
|
20
|
+
onMount(() => {
|
|
21
|
+
itemsData.items.update(items => [...items, {
|
|
22
|
+
key,
|
|
23
|
+
show: () => active = true,
|
|
24
|
+
hide: () => active = false,
|
|
25
|
+
}
|
|
26
|
+
]);
|
|
27
|
+
});
|
|
28
|
+
onDestroy(() => {
|
|
29
|
+
itemsData.items.update(items => (items.filter(item => item.key !== key)));
|
|
30
|
+
});
|
|
31
|
+
$: ({ transition } = itemsData);
|
|
32
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare type CarouselItemProps = typeof __propDef.props;
|
|
14
|
+
export declare type CarouselItemEvents = typeof __propDef.events;
|
|
15
|
+
export declare type CarouselItemSlots = typeof __propDef.slots;
|
|
16
|
+
export default class CarouselItem extends SvelteComponentTyped<CarouselItemProps, CarouselItemEvents, CarouselItemSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Transition } from '../../types';
|
|
2
|
+
import type { Writable } from 'svelte/store';
|
|
3
|
+
export interface iCarouselItem {
|
|
4
|
+
key: Symbol;
|
|
5
|
+
show: () => void;
|
|
6
|
+
hide: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare type CarouselItemsStore = Writable<iCarouselItem[]>;
|
|
9
|
+
export declare type TransitionStore = Writable<Transition>;
|
|
10
|
+
export interface CarouselItemsData {
|
|
11
|
+
activeItem: number;
|
|
12
|
+
items: CarouselItemsStore;
|
|
13
|
+
transition: TransitionStore;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,13 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
};
|
|
6
6
|
events: {
|
|
7
|
+
submit: Event;
|
|
8
|
+
click: MouseEvent;
|
|
9
|
+
keydown: KeyboardEvent;
|
|
10
|
+
mouseover: MouseEvent;
|
|
11
|
+
mouseenter: MouseEvent;
|
|
12
|
+
mouseleave: MouseEvent;
|
|
13
|
+
} & {
|
|
7
14
|
[evt: string]: CustomEvent<any>;
|
|
8
15
|
};
|
|
9
16
|
slots: {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<section {...$$restProps}
|
|
2
|
+
class={classes}
|
|
3
|
+
class:border>
|
|
4
|
+
<div class="hero-body">
|
|
5
|
+
{#if $$slots.title}
|
|
6
|
+
<slot name="title" />
|
|
7
|
+
{:else}
|
|
8
|
+
<h2 class="hero-title">{title}</h2>
|
|
9
|
+
{/if}
|
|
10
|
+
|
|
11
|
+
{#if $$slots.textLead || textLead}
|
|
12
|
+
<p class="hero-text-lead">
|
|
13
|
+
{#if $$slots.textLead}
|
|
14
|
+
<slot name="textLead" />
|
|
15
|
+
{:else}
|
|
16
|
+
{textLead}
|
|
17
|
+
{/if}
|
|
18
|
+
</p>
|
|
19
|
+
{/if}
|
|
20
|
+
|
|
21
|
+
<div><slot /></div>
|
|
22
|
+
</div>
|
|
23
|
+
</section>
|
|
24
|
+
|
|
25
|
+
<script >var _a;
|
|
26
|
+
;
|
|
27
|
+
import { computeClasses } from '../utils';
|
|
28
|
+
export let type = 'primary';
|
|
29
|
+
export let size = 'default';
|
|
30
|
+
export let border = true;
|
|
31
|
+
export let title = '';
|
|
32
|
+
export let textLead = '';
|
|
33
|
+
$: classes = `hero background-${type}
|
|
34
|
+
${(_a = $$restProps.class) !== null && _a !== void 0 ? _a : ''}
|
|
35
|
+
${computeClasses('hero', { size })}`;
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style >.hero {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
padding: 1.5rem 3rem;
|
|
43
|
+
margin-bottom: 20px;
|
|
44
|
+
}
|
|
45
|
+
.hero-title {
|
|
46
|
+
margin-block: 1rem 0.5rem;
|
|
47
|
+
}
|
|
48
|
+
.hero-text-lead {
|
|
49
|
+
font-size: 1.25rem;
|
|
50
|
+
}
|
|
51
|
+
.hero-small {
|
|
52
|
+
padding: 0 1.5rem;
|
|
53
|
+
}
|
|
54
|
+
.hero-large {
|
|
55
|
+
padding: 5rem 5rem;
|
|
56
|
+
}
|
|
57
|
+
.hero-fullheight {
|
|
58
|
+
min-height: 100vh;
|
|
59
|
+
}</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { PaperSize, PaperType } from '../types';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
type?: PaperType;
|
|
7
|
+
size?: PaperSize | "fullheight";
|
|
8
|
+
border?: boolean;
|
|
9
|
+
title?: string;
|
|
10
|
+
textLead?: string;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {
|
|
16
|
+
title: {};
|
|
17
|
+
textLead: {};
|
|
18
|
+
default: {};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare type HeroProps = typeof __propDef.props;
|
|
22
|
+
export declare type HeroEvents = typeof __propDef.events;
|
|
23
|
+
export declare type HeroSlots = typeof __propDef.slots;
|
|
24
|
+
export default class Hero extends SvelteComponentTyped<HeroProps, HeroEvents, HeroSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<section {...$$restProps}>
|
|
2
|
-
{#if
|
|
2
|
+
{#if showNavigation}
|
|
3
3
|
<NavigationButton
|
|
4
4
|
type={highlightedStyle}
|
|
5
5
|
{size} action="previous"
|
|
@@ -12,26 +12,27 @@
|
|
|
12
12
|
{#if simple}
|
|
13
13
|
{current} / {pageCount}
|
|
14
14
|
{:else}
|
|
15
|
-
<
|
|
15
|
+
<ol class="padding-none">
|
|
16
16
|
{#each pages as {idx, show}}
|
|
17
17
|
<li>
|
|
18
18
|
{#if show}
|
|
19
19
|
<Button {size} isLink
|
|
20
|
+
class={bullets ? 'paper-pagination-btn--rounded' : ''}
|
|
20
21
|
on:click={changePage.bind(null, idx)}
|
|
21
22
|
type={idx === current ? highlightedStyle : defaultStyle}
|
|
22
23
|
aria-label={ariaPageLabel?.(idx) ?? `Page ${idx}`}
|
|
23
24
|
aria-current={idx === current}>
|
|
24
|
-
{idx}
|
|
25
|
+
{displayedPageLabel(idx)}
|
|
25
26
|
</Button>
|
|
26
27
|
{:else if shouldDisplayEllipsis(idx)}
|
|
27
28
|
…
|
|
28
29
|
{/if}
|
|
29
30
|
</li>
|
|
30
31
|
{/each}
|
|
31
|
-
</
|
|
32
|
+
</ol>
|
|
32
33
|
{/if}
|
|
33
34
|
|
|
34
|
-
{#if
|
|
35
|
+
{#if showNavigation}
|
|
35
36
|
<NavigationButton
|
|
36
37
|
type={highlightedStyle}
|
|
37
38
|
{size} action="next"
|
|
@@ -62,12 +63,14 @@ export let current = 1;
|
|
|
62
63
|
export let size = 'small';
|
|
63
64
|
export let navigation = true;
|
|
64
65
|
export let simple = false;
|
|
66
|
+
export let bullets = false;
|
|
65
67
|
export let previousLabel = null;
|
|
66
68
|
export let nextLabel = null;
|
|
67
69
|
export let highlightedStyle = 'secondary';
|
|
68
70
|
export let defaultStyle = null;
|
|
69
71
|
export let rangeBetween = null;
|
|
70
72
|
export let jumper = false;
|
|
73
|
+
export let pageLabel = null;
|
|
71
74
|
export let ariaPreviousLabel = 'previous page';
|
|
72
75
|
export let ariaNextLabel = 'next page';
|
|
73
76
|
export let ariaPageLabel = null;
|
|
@@ -79,6 +82,8 @@ let pages;
|
|
|
79
82
|
$: if (current) {
|
|
80
83
|
pages = Array.from({ length: pageCount }, (_, i) => ({ idx: ++i, show: shouldDisplayButton(i) }));
|
|
81
84
|
}
|
|
85
|
+
let showNavigation;
|
|
86
|
+
$: showNavigation = navigation && !bullets;
|
|
82
87
|
function submitJumper({ code }) {
|
|
83
88
|
const toPage = Number(jumperValue);
|
|
84
89
|
if (code !== 'Enter' || pageInvalid(toPage))
|
|
@@ -103,20 +108,30 @@ function changePage(val) {
|
|
|
103
108
|
current = val;
|
|
104
109
|
dispatch('change', current);
|
|
105
110
|
}
|
|
111
|
+
function displayedPageLabel(idx) {
|
|
112
|
+
var _a;
|
|
113
|
+
if (bullets)
|
|
114
|
+
return '';
|
|
115
|
+
return (_a = pageLabel === null || pageLabel === void 0 ? void 0 : pageLabel(idx)) !== null && _a !== void 0 ? _a : idx;
|
|
116
|
+
}
|
|
106
117
|
</script>
|
|
107
118
|
|
|
108
|
-
<style >
|
|
119
|
+
<style >ol, li {
|
|
109
120
|
display: inline;
|
|
110
121
|
}
|
|
111
122
|
|
|
112
|
-
|
|
123
|
+
ol li {
|
|
113
124
|
text-indent: 0;
|
|
114
125
|
}
|
|
115
|
-
|
|
126
|
+
ol li::before {
|
|
116
127
|
content: "";
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
:global(.paper-pagination-input) {
|
|
120
131
|
display: inline;
|
|
121
132
|
width: 4rem;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
:global(.paper-pagination-btn--rounded) {
|
|
136
|
+
border-radius: 50%;
|
|
122
137
|
}</style>
|
|
@@ -9,12 +9,14 @@ declare const __propDef: {
|
|
|
9
9
|
size?: PaperSize;
|
|
10
10
|
navigation?: boolean;
|
|
11
11
|
simple?: boolean;
|
|
12
|
+
bullets?: boolean;
|
|
12
13
|
previousLabel?: string;
|
|
13
14
|
nextLabel?: string;
|
|
14
15
|
highlightedStyle?: PaperType;
|
|
15
16
|
defaultStyle?: PaperType;
|
|
16
17
|
rangeBetween?: number;
|
|
17
18
|
jumper?: boolean;
|
|
19
|
+
pageLabel?: (idx: number) => string | number;
|
|
18
20
|
ariaPreviousLabel?: string;
|
|
19
21
|
ariaNextLabel?: string;
|
|
20
22
|
ariaPageLabel?: (idx: number) => string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<div {...$$restProps}
|
|
2
2
|
class="{$$restProps.class ?? ''} content margin"
|
|
3
3
|
class:content--active={active}
|
|
4
|
-
id={
|
|
4
|
+
id={getId(label, 'content')}
|
|
5
5
|
aria-hidden={!active}
|
|
6
|
-
aria-labelledby={
|
|
6
|
+
aria-labelledby={getId(label, 'label')}
|
|
7
7
|
role="tabpanel"
|
|
8
8
|
tabindex={active ? 0 : -1}>
|
|
9
9
|
{#if $$slots.header}
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
<slot />
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
<script >import { onMount, getContext } from 'svelte';
|
|
18
|
+
<script >import { onMount, onDestroy, getContext } from 'svelte';
|
|
19
19
|
;
|
|
20
|
-
import {
|
|
20
|
+
import { getId } from './utils';
|
|
21
21
|
export let label;
|
|
22
22
|
const key = {};
|
|
23
23
|
let active = false;
|
|
@@ -27,6 +27,8 @@ $: if (header) {
|
|
|
27
27
|
.removeAttribute('slot');
|
|
28
28
|
}
|
|
29
29
|
const tabsData = getContext('tabs');
|
|
30
|
+
if (!tabsData)
|
|
31
|
+
throw new Error('Tab should be nested inside a Tabs');
|
|
30
32
|
$: tabsData.tabs.update(tabs => (tabs.map(t => t.key === key ? Object.assign(Object.assign({}, t), { label, header }) : t)));
|
|
31
33
|
onMount(() => {
|
|
32
34
|
tabsData.tabs.update(tabs => [...tabs, {
|
|
@@ -38,7 +40,9 @@ onMount(() => {
|
|
|
38
40
|
}
|
|
39
41
|
]);
|
|
40
42
|
});
|
|
41
|
-
|
|
43
|
+
onDestroy(() => {
|
|
44
|
+
tabsData.tabs.update(tabs => (tabs.filter(t => t.key !== key)));
|
|
45
|
+
});
|
|
42
46
|
</script>
|
|
43
47
|
|
|
44
48
|
<style>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<div {...$$restProps}
|
|
2
|
-
class=
|
|
3
|
-
style=
|
|
2
|
+
class="row flex-{placement} tabs {$$restProps.class ?? ''}"
|
|
3
|
+
style="text-align: {contentAlign}">
|
|
4
4
|
{#each $tabs as { label, header }, index}
|
|
5
5
|
{@const selected = index == activeTab}
|
|
6
6
|
<div class="tabs-label-header"
|
|
7
7
|
class:tabs-label-header--active={selected}
|
|
8
|
+
id={getId(label, 'label')}
|
|
8
9
|
aria-selected={selected}
|
|
9
|
-
aria-controls={
|
|
10
|
+
aria-controls={getId(label, 'content')}
|
|
10
11
|
role="tab"
|
|
11
12
|
tabindex={selected ? 0 : -1}
|
|
12
13
|
on:click={showContent.bind(null, index)}>
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
import { writable } from 'svelte/store';
|
|
26
27
|
;
|
|
27
28
|
;
|
|
28
|
-
import {
|
|
29
|
+
import { getId } from './utils';
|
|
29
30
|
export let activeTab = 0;
|
|
30
31
|
export let placement = 'spaces';
|
|
31
32
|
export let contentAlign = 'left';
|
package/components/Tabs/utils.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function
|
|
2
|
-
return `paper-tab-${label}`;
|
|
1
|
+
export function getId(label, part) {
|
|
2
|
+
return `paper-tab-${label}-${part}`;
|
|
3
3
|
}
|
package/index.d.ts
CHANGED
|
@@ -17,4 +17,6 @@ import Toast from './components/Toast';
|
|
|
17
17
|
import CloseButton from './components/CloseButton.svelte';
|
|
18
18
|
import CopyButton from './components/CopyButton.svelte';
|
|
19
19
|
import Skeleton from './components/Skeleton.svelte';
|
|
20
|
-
|
|
20
|
+
import { Carousel, CarouselItem } from './components/Carousel';
|
|
21
|
+
import Hero from './components/Hero.svelte';
|
|
22
|
+
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, Carousel, CarouselItem, Hero, };
|
package/index.js
CHANGED
|
@@ -17,4 +17,6 @@ import Toast from './components/Toast';
|
|
|
17
17
|
import CloseButton from './components/CloseButton.svelte';
|
|
18
18
|
import CopyButton from './components/CopyButton.svelte';
|
|
19
19
|
import Skeleton from './components/Skeleton.svelte';
|
|
20
|
-
|
|
20
|
+
import { Carousel, CarouselItem } from './components/Carousel';
|
|
21
|
+
import Hero from './components/Hero.svelte';
|
|
22
|
+
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, Carousel, CarouselItem, Hero, };
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"papercss",
|
|
9
9
|
"components"
|
|
10
10
|
],
|
|
11
|
-
"version": "
|
|
11
|
+
"version": "1.1.0",
|
|
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.
|
|
21
|
+
"papercss": "^1.8.2"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"exports": {
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"./components/Breadcrumb.svelte": "./components/Breadcrumb.svelte",
|
|
30
30
|
"./components/Button.svelte": "./components/Button.svelte",
|
|
31
31
|
"./components/Card.svelte": "./components/Card.svelte",
|
|
32
|
+
"./components/Carousel/Carousel.svelte": "./components/Carousel/Carousel.svelte",
|
|
33
|
+
"./components/Carousel/CarouselItem.svelte": "./components/Carousel/CarouselItem.svelte",
|
|
34
|
+
"./components/Carousel": "./components/Carousel/index.js",
|
|
35
|
+
"./components/Carousel/types": "./components/Carousel/types.js",
|
|
32
36
|
"./components/CloseButton.svelte": "./components/CloseButton.svelte",
|
|
33
37
|
"./components/Collapsible.svelte": "./components/Collapsible.svelte",
|
|
34
38
|
"./components/CopyButton.svelte": "./components/CopyButton.svelte",
|
|
@@ -41,6 +45,7 @@
|
|
|
41
45
|
"./components/Form/Switch.svelte": "./components/Form/Switch.svelte",
|
|
42
46
|
"./components/Form": "./components/Form/index.js",
|
|
43
47
|
"./components/Form/style.scss": "./components/Form/style.scss",
|
|
48
|
+
"./components/Hero.svelte": "./components/Hero.svelte",
|
|
44
49
|
"./components/Modal/Modal.svelte": "./components/Modal/Modal.svelte",
|
|
45
50
|
"./components/Modal": "./components/Modal/index.js",
|
|
46
51
|
"./components/Navbar.svelte": "./components/Navbar.svelte",
|
package/types.d.ts
CHANGED
package/utils.d.ts
CHANGED
|
@@ -9,4 +9,8 @@ export declare function getDomAttributes({ props, classes, toOmit }: getDomAttri
|
|
|
9
9
|
export declare type ComponentProps<T extends {
|
|
10
10
|
$set: (...args: any) => any;
|
|
11
11
|
}> = NonNullable<Parameters<T['$set']>[0]>;
|
|
12
|
+
export declare function configureTransition(node: any, { name, disabled }: {
|
|
13
|
+
name: any;
|
|
14
|
+
disabled: any;
|
|
15
|
+
}): any;
|
|
12
16
|
export {};
|
package/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as transition from 'svelte/transition';
|
|
1
2
|
const propToClass = {
|
|
2
3
|
size: (pf, val) => `${pf}-${val}`,
|
|
3
4
|
block: (pf, _val) => `${pf}-block`,
|
|
@@ -20,3 +21,10 @@ export function getDomAttributes({ props, classes, toOmit = [] }) {
|
|
|
20
21
|
...omit(props, toOmit), class: classes
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
export function configureTransition(node, { name, disabled }) {
|
|
25
|
+
if (disabled
|
|
26
|
+
|| window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return transition[name](node);
|
|
30
|
+
}
|