spaper 0.8.6 → 1.0.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 +10 -2
- 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 +7 -1
- package/components/Form/Radio.svelte +7 -1
- package/components/Form/Radio.svelte.d.ts +3 -1
- package/components/Pagination/Pagination.svelte +23 -8
- package/components/Pagination/Pagination.svelte.d.ts +2 -0
- package/components/Skeleton.svelte +55 -0
- package/components/Skeleton.svelte.d.ts +22 -0
- package/components/Table.svelte +2 -1
- package/components/Table.svelte.d.ts +24 -0
- package/components/Tabs/Tab.svelte +6 -1
- package/components/Tabs/Tabs.svelte +2 -2
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +7 -2
- package/types.d.ts +13 -0
- package/utils.d.ts +4 -0
- package/utils.js +8 -0
package/README.md
CHANGED
|
@@ -63,8 +63,14 @@ 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
|
-
</table>
|
|
73
|
+
</table>
|
|
68
74
|
|
|
69
75
|
|
|
70
76
|
### Donate
|
|
@@ -86,6 +92,7 @@ Any donation is greatly appreciated :heart:
|
|
|
86
92
|
- Breadcrumb
|
|
87
93
|
- Button
|
|
88
94
|
- Card
|
|
95
|
+
- Carousel
|
|
89
96
|
- CloseButton
|
|
90
97
|
- Collapsible
|
|
91
98
|
- CopyButton
|
|
@@ -101,6 +108,7 @@ Any donation is greatly appreciated :heart:
|
|
|
101
108
|
- Pagination
|
|
102
109
|
- Popover
|
|
103
110
|
- Progress
|
|
111
|
+
- Skeleton
|
|
104
112
|
- Table
|
|
105
113
|
- Tabs
|
|
106
|
-
- Toast
|
|
114
|
+
- 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 {};
|
|
@@ -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;
|
|
@@ -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 {};
|
package/components/Table.svelte
CHANGED
|
@@ -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 {};
|
|
@@ -15,7 +15,7 @@
|
|
|
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
20
|
import { genControlLabel } from './utils';
|
|
21
21
|
export let label;
|
|
@@ -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,6 +40,9 @@ onMount(() => {
|
|
|
38
40
|
}
|
|
39
41
|
]);
|
|
40
42
|
});
|
|
43
|
+
onDestroy(() => {
|
|
44
|
+
tabsData.tabs.update(tabs => (tabs.filter(t => t.key !== key)));
|
|
45
|
+
});
|
|
41
46
|
$: controlLabel = genControlLabel(label);
|
|
42
47
|
</script>
|
|
43
48
|
|
|
@@ -1,6 +1,6 @@
|
|
|
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"
|
package/index.d.ts
CHANGED
|
@@ -16,4 +16,6 @@ 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
|
-
|
|
19
|
+
import Skeleton from './components/Skeleton.svelte';
|
|
20
|
+
import { Carousel, CarouselItem } from './components/Carousel';
|
|
21
|
+
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, };
|
package/index.js
CHANGED
|
@@ -16,4 +16,6 @@ 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
|
-
|
|
19
|
+
import Skeleton from './components/Skeleton.svelte';
|
|
20
|
+
import { Carousel, CarouselItem } from './components/Carousel';
|
|
21
|
+
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, };
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"papercss",
|
|
9
9
|
"components"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "1.0.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",
|
|
@@ -51,6 +55,7 @@
|
|
|
51
55
|
"./components/Pagination": "./components/Pagination/index.js",
|
|
52
56
|
"./components/Popover.svelte": "./components/Popover.svelte",
|
|
53
57
|
"./components/Progress.svelte": "./components/Progress.svelte",
|
|
58
|
+
"./components/Skeleton.svelte": "./components/Skeleton.svelte",
|
|
54
59
|
"./components/Table.svelte": "./components/Table.svelte",
|
|
55
60
|
"./components/Tabs/Tab.svelte": "./components/Tabs/Tab.svelte",
|
|
56
61
|
"./components/Tabs/Tabs.svelte": "./components/Tabs/Tabs.svelte",
|
package/types.d.ts
CHANGED
|
@@ -11,3 +11,16 @@ 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;
|
|
23
|
+
|
|
24
|
+
export type Transition = 'blur'
|
|
25
|
+
| 'fade' | 'fly' | 'slide'
|
|
26
|
+
| 'scale' | 'draw' | 'crossfade';
|
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
|
+
}
|