spaper 1.3.0 → 2.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 +20 -58
- package/dist/components/Alert.svelte +83 -0
- package/dist/components/Alert.svelte.d.ts +15 -0
- package/dist/components/Article.svelte +63 -0
- package/dist/components/Article.svelte.d.ts +17 -0
- package/dist/components/Avatar/Avatar.svelte +102 -0
- package/dist/components/Avatar/Avatar.svelte.d.ts +16 -0
- package/dist/components/Avatar/AvatarGroup.svelte +21 -0
- package/dist/components/Avatar/AvatarGroup.svelte.d.ts +9 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/Breadcrumb.svelte +33 -0
- package/dist/components/Breadcrumb.svelte.d.ts +12 -0
- package/dist/components/Button.svelte +174 -0
- package/dist/components/Button.svelte.d.ts +33 -0
- package/dist/components/Card.svelte +101 -0
- package/dist/components/Card.svelte.d.ts +22 -0
- package/dist/components/Carousel/Carousel.svelte +204 -0
- package/dist/components/Carousel/Carousel.svelte.d.ts +27 -0
- package/dist/components/Carousel/CarouselItem.svelte +48 -0
- package/dist/components/Carousel/CarouselItem.svelte.d.ts +7 -0
- package/{components → dist/components}/Carousel/index.d.ts +1 -0
- package/dist/components/Carousel/types.d.ts +22 -0
- package/dist/components/CloseButton.svelte +34 -0
- package/dist/components/CloseButton.svelte.d.ts +8 -0
- package/dist/components/Collapsible.svelte +64 -0
- package/dist/components/Collapsible.svelte.d.ts +16 -0
- package/dist/components/CopyButton.svelte +54 -0
- package/dist/components/CopyButton.svelte.d.ts +13 -0
- package/dist/components/Divider.svelte +9 -0
- package/dist/components/Divider.svelte.d.ts +6 -0
- package/dist/components/Form/Checkbox.svelte +54 -0
- package/dist/components/Form/Checkbox.svelte.d.ts +15 -0
- package/dist/components/Form/Input.svelte +105 -0
- package/dist/components/Form/Input.svelte.d.ts +21 -0
- package/dist/components/Form/NumberInput/DecrementButton.svelte +14 -0
- package/dist/components/Form/NumberInput/DecrementButton.svelte.d.ts +9 -0
- package/dist/components/Form/NumberInput/IncrementButton.svelte +14 -0
- package/dist/components/Form/NumberInput/IncrementButton.svelte.d.ts +9 -0
- package/dist/components/Form/NumberInput/NumberInput.svelte +227 -0
- package/dist/components/Form/NumberInput/NumberInput.svelte.d.ts +34 -0
- package/dist/components/Form/NumberInput/index.d.ts +3 -0
- package/dist/components/Form/NumberInput/index.js +3 -0
- package/dist/components/Form/Radio.svelte +42 -0
- package/dist/components/Form/Radio.svelte.d.ts +13 -0
- package/dist/components/Form/Select.svelte +61 -0
- package/dist/components/Form/Select.svelte.d.ts +12 -0
- package/dist/components/Form/Slider.svelte +129 -0
- package/dist/components/Form/Slider.svelte.d.ts +22 -0
- package/dist/components/Form/Switch.svelte +101 -0
- package/dist/components/Form/Switch.svelte.d.ts +22 -0
- package/dist/components/Form/index.d.ts +9 -0
- package/{components → dist/components}/Form/index.js +2 -2
- package/dist/components/Hero.svelte +78 -0
- package/dist/components/Hero.svelte.d.ts +17 -0
- package/dist/components/Icon.svelte +102 -0
- package/dist/components/Icon.svelte.d.ts +27 -0
- package/dist/components/Modal/Modal.svelte +120 -0
- package/dist/components/Modal/Modal.svelte.d.ts +19 -0
- package/dist/components/Modal/index.d.ts +12 -0
- package/dist/components/Modal/index.js +30 -0
- package/dist/components/Navbar.svelte +98 -0
- package/dist/components/Navbar.svelte.d.ts +11 -0
- package/dist/components/Pagination/Arrow.svelte +29 -0
- package/dist/components/Pagination/Arrow.svelte.d.ts +8 -0
- package/dist/components/Pagination/NavigationButton.svelte +33 -0
- package/dist/components/Pagination/NavigationButton.svelte.d.ts +13 -0
- package/dist/components/Pagination/Pagination.svelte +209 -0
- package/dist/components/Pagination/Pagination.svelte.d.ts +32 -0
- package/{components → dist/components}/Pagination/arrow-dimension.js +3 -3
- package/{components → dist/components}/Pagination/index.d.ts +1 -1
- package/dist/components/Popover.svelte +64 -0
- package/dist/components/Popover.svelte.d.ts +17 -0
- package/dist/components/Progress.svelte +87 -0
- package/dist/components/Progress.svelte.d.ts +19 -0
- package/dist/components/ScrollTop.svelte +79 -0
- package/dist/components/ScrollTop.svelte.d.ts +17 -0
- package/dist/components/Skeleton.svelte +104 -0
- package/dist/components/Skeleton.svelte.d.ts +21 -0
- package/dist/components/Spinner.svelte +59 -0
- package/dist/components/Spinner.svelte.d.ts +16 -0
- package/dist/components/Table/Table.svelte +292 -0
- package/dist/components/Table/Table.svelte.d.ts +25 -0
- package/dist/components/Table/TableColumn.svelte +62 -0
- package/dist/components/Table/TableColumn.svelte.d.ts +15 -0
- package/dist/components/Table/context.d.ts +13 -0
- package/dist/components/Table/context.js +1 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Table/index.js +2 -0
- package/dist/components/Tabs/Tab.svelte +90 -0
- package/dist/components/Tabs/Tab.svelte.d.ts +14 -0
- package/dist/components/Tabs/Tabs.svelte +138 -0
- package/dist/components/Tabs/Tabs.svelte.d.ts +13 -0
- package/{components → dist/components}/Tabs/utils.d.ts +4 -3
- package/dist/components/Tag.svelte +38 -0
- package/dist/components/Tag.svelte.d.ts +10 -0
- package/dist/components/Toast/Toast.svelte +105 -0
- package/dist/components/Toast/Toast.svelte.d.ts +6 -0
- package/dist/components/Toast/ToastContainer.svelte +101 -0
- package/dist/components/Toast/ToastContainer.svelte.d.ts +8 -0
- package/{components → dist/components}/Toast/index.d.ts +19 -5
- package/dist/components/Toast/index.js +100 -0
- package/dist/icons.d.ts +3 -0
- package/dist/icons.js +2 -0
- package/dist/index.d.ts +31 -0
- package/{index.js → dist/index.js} +10 -5
- package/dist/type-icons.d.ts +4 -0
- package/dist/type-icons.js +9 -0
- package/dist/types.d.ts +29 -0
- package/dist/utils.d.ts +16 -0
- package/dist/utils.js +44 -0
- package/package.json +70 -64
- package/components/Alert.svelte +0 -34
- package/components/Alert.svelte.d.ts +0 -21
- package/components/Article.svelte +0 -39
- package/components/Article.svelte.d.ts +0 -26
- package/components/Badge.svelte +0 -16
- package/components/Badge.svelte.d.ts +0 -20
- package/components/Breadcrumb.svelte +0 -17
- package/components/Breadcrumb.svelte.d.ts +0 -21
- package/components/Button.svelte +0 -41
- package/components/Button.svelte.d.ts +0 -30
- package/components/Card.svelte +0 -70
- package/components/Card.svelte.d.ts +0 -32
- package/components/Carousel/Carousel.svelte +0 -128
- package/components/Carousel/Carousel.svelte.d.ts +0 -35
- package/components/Carousel/CarouselItem.svelte +0 -32
- package/components/Carousel/CarouselItem.svelte.d.ts +0 -18
- package/components/Carousel/types.d.ts +0 -14
- package/components/CloseButton.svelte +0 -23
- package/components/CloseButton.svelte.d.ts +0 -19
- package/components/Collapsible.svelte +0 -49
- package/components/Collapsible.svelte.d.ts +0 -21
- package/components/CopyButton.svelte +0 -43
- package/components/CopyButton.svelte.d.ts +0 -24
- package/components/Form/Checkbox.svelte +0 -37
- package/components/Form/Checkbox.svelte.d.ts +0 -26
- package/components/Form/Form.svelte +0 -11
- package/components/Form/Form.svelte.d.ts +0 -26
- package/components/Form/Input.svelte +0 -74
- package/components/Form/Input.svelte.d.ts +0 -28
- package/components/Form/Radio.svelte +0 -26
- package/components/Form/Radio.svelte.d.ts +0 -25
- package/components/Form/Select.svelte +0 -40
- package/components/Form/Select.svelte.d.ts +0 -24
- package/components/Form/Slider.svelte +0 -124
- package/components/Form/Slider.svelte.d.ts +0 -30
- package/components/Form/Switch.svelte +0 -71
- package/components/Form/index.d.ts +0 -9
- package/components/Form/style.scss +0 -4
- package/components/Hero.svelte +0 -78
- package/components/Hero.svelte.d.ts +0 -26
- package/components/Layout/Col.svelte +0 -25
- package/components/Layout/Col.svelte.d.ts +0 -27
- package/components/Layout/Row.svelte +0 -24
- package/components/Layout/Row.svelte.d.ts +0 -26
- package/components/Layout/index.d.ts +0 -2
- package/components/Layout/index.js +0 -2
- package/components/Modal/Modal.svelte +0 -62
- package/components/Modal/Modal.svelte.d.ts +0 -28
- package/components/Modal/index.d.ts +0 -13
- package/components/Modal/index.js +0 -17
- package/components/Navbar.svelte +0 -40
- package/components/Navbar.svelte.d.ts +0 -22
- package/components/Pagination/Arrow.svelte +0 -17
- package/components/Pagination/Arrow.svelte.d.ts +0 -19
- package/components/Pagination/NavigationButton.svelte +0 -23
- package/components/Pagination/NavigationButton.svelte.d.ts +0 -23
- package/components/Pagination/Pagination.svelte +0 -137
- package/components/Pagination/Pagination.svelte.d.ts +0 -36
- package/components/Popover.svelte +0 -57
- package/components/Popover.svelte.d.ts +0 -25
- package/components/Progress.svelte +0 -39
- package/components/Progress.svelte.d.ts +0 -25
- package/components/Skeleton.svelte +0 -55
- package/components/Skeleton.svelte.d.ts +0 -22
- package/components/Table.svelte +0 -73
- package/components/Table.svelte.d.ts +0 -24
- package/components/Tabs/Tab.svelte +0 -52
- package/components/Tabs/Tab.svelte.d.ts +0 -20
- package/components/Tabs/Tabs.svelte +0 -90
- package/components/Tabs/Tabs.svelte.d.ts +0 -25
- package/components/Toast/Toast.svelte +0 -91
- package/components/Toast/Toast.svelte.d.ts +0 -26
- package/components/Toast/ToastContainer.svelte +0 -37
- package/components/Toast/ToastContainer.svelte.d.ts +0 -18
- package/components/Toast/index.js +0 -37
- package/index.d.ts +0 -23
- package/types.d.ts +0 -16
- package/utils.d.ts +0 -16
- package/utils.js +0 -34
- /package/{components → dist/components}/Carousel/index.js +0 -0
- /package/{components → dist/components}/Carousel/types.js +0 -0
- /package/{components → dist/components}/Pagination/arrow-dimension.d.ts +0 -0
- /package/{components → dist/components}/Pagination/index.js +0 -0
- /package/{components → dist/components}/Tabs/index.d.ts +0 -0
- /package/{components → dist/components}/Tabs/index.js +0 -0
- /package/{components → dist/components}/Tabs/utils.js +0 -0
- /package/{components → dist/components}/style.scss +0 -0
- /package/{types.js → dist/types.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mount, unmount } from 'svelte';
|
|
2
|
+
import Modal from './Modal.svelte';
|
|
3
|
+
const TRANSITION_TIME = 300;
|
|
4
|
+
function open(props) {
|
|
5
|
+
let closing = false;
|
|
6
|
+
const modal = mount(Modal, {
|
|
7
|
+
target: document.body,
|
|
8
|
+
props: {
|
|
9
|
+
...props,
|
|
10
|
+
active: true,
|
|
11
|
+
onclose: () => {
|
|
12
|
+
props.onclose?.();
|
|
13
|
+
if (closing)
|
|
14
|
+
return;
|
|
15
|
+
closing = true;
|
|
16
|
+
setTimeout(() => unmount(modal), TRANSITION_TIME);
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
close: () => {
|
|
22
|
+
if (closing)
|
|
23
|
+
return;
|
|
24
|
+
modal.close();
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
;
|
|
29
|
+
Modal.open = open;
|
|
30
|
+
export default Modal;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
border?: boolean
|
|
4
|
+
fixed?: boolean
|
|
5
|
+
split?: boolean
|
|
6
|
+
brand?: import('svelte').Snippet
|
|
7
|
+
children?: import('svelte').Snippet
|
|
8
|
+
[key: string]: any
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
border = true,
|
|
13
|
+
fixed = false,
|
|
14
|
+
split = true,
|
|
15
|
+
brand,
|
|
16
|
+
children,
|
|
17
|
+
...rest
|
|
18
|
+
}: Props = $props()
|
|
19
|
+
|
|
20
|
+
const uid = $props.id()
|
|
21
|
+
|
|
22
|
+
let open: boolean = $state(false)
|
|
23
|
+
let mobile = $state(false)
|
|
24
|
+
|
|
25
|
+
$effect(() => {
|
|
26
|
+
const raw = getComputedStyle(document.documentElement)
|
|
27
|
+
.getPropertyValue('--breakpoint-paper-nav')
|
|
28
|
+
.trim()
|
|
29
|
+
const query = window.matchMedia(`(width < ${raw || '48rem'})`)
|
|
30
|
+
const update = () => {
|
|
31
|
+
mobile = query.matches
|
|
32
|
+
}
|
|
33
|
+
update()
|
|
34
|
+
query.addEventListener('change', update)
|
|
35
|
+
return () => query.removeEventListener('change', update)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
function close() {
|
|
39
|
+
open = false
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function toggle() {
|
|
43
|
+
open = !open
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Close after a link/button click without making the wrapper a click target. */
|
|
47
|
+
function closeOnNavigate(node: HTMLElement) {
|
|
48
|
+
const onClick = (e: MouseEvent) => {
|
|
49
|
+
const target = e.target as HTMLElement | null
|
|
50
|
+
if (target?.closest('a, button')) close()
|
|
51
|
+
}
|
|
52
|
+
node.addEventListener('click', onClick)
|
|
53
|
+
return {
|
|
54
|
+
destroy() {
|
|
55
|
+
node.removeEventListener('click', onClick)
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<nav
|
|
62
|
+
{...rest}
|
|
63
|
+
class={[
|
|
64
|
+
'nav-paper',
|
|
65
|
+
{
|
|
66
|
+
'border-paper': border,
|
|
67
|
+
'nav-paper-fixed': fixed,
|
|
68
|
+
'nav-paper-split': split,
|
|
69
|
+
},
|
|
70
|
+
rest.class,
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
{#if brand}
|
|
74
|
+
{@render brand?.()}
|
|
75
|
+
{/if}
|
|
76
|
+
<div class="nav-paper-collapsible">
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
class={['nav-paper-burger', { open }]}
|
|
80
|
+
aria-label={open ? 'Close navigation' : 'Open navigation'}
|
|
81
|
+
aria-expanded={open}
|
|
82
|
+
aria-controls="{uid}-menu"
|
|
83
|
+
onclick={toggle}
|
|
84
|
+
>
|
|
85
|
+
<div class="bar1"></div>
|
|
86
|
+
<div class="bar2"></div>
|
|
87
|
+
<div class="bar3"></div>
|
|
88
|
+
</button>
|
|
89
|
+
<div
|
|
90
|
+
id="{uid}-menu"
|
|
91
|
+
class={['nav-paper-collapsible-body', { open }]}
|
|
92
|
+
inert={mobile && !open}
|
|
93
|
+
use:closeOnNavigate
|
|
94
|
+
>
|
|
95
|
+
{@render children?.()}
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</nav>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
border?: boolean;
|
|
3
|
+
fixed?: boolean;
|
|
4
|
+
split?: boolean;
|
|
5
|
+
brand?: import('svelte').Snippet;
|
|
6
|
+
children?: import('svelte').Snippet;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
declare const Navbar: import("svelte").Component<Props, {}, "">;
|
|
10
|
+
type Navbar = ReturnType<typeof Navbar>;
|
|
11
|
+
export default Navbar;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '../Icon.svelte'
|
|
3
|
+
import {
|
|
4
|
+
ChevronLeft,
|
|
5
|
+
ChevronRight,
|
|
6
|
+
ChevronsLeft,
|
|
7
|
+
ChevronsRight,
|
|
8
|
+
} from '../../icons'
|
|
9
|
+
import type { PaperSize } from '../../types'
|
|
10
|
+
import arrowDimension from './arrow-dimension'
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
size: PaperSize
|
|
14
|
+
action: 'first' | 'previous' | 'next' | 'last'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let { size, action }: Props = $props()
|
|
18
|
+
|
|
19
|
+
const icons = {
|
|
20
|
+
first: ChevronsLeft,
|
|
21
|
+
previous: ChevronLeft,
|
|
22
|
+
next: ChevronRight,
|
|
23
|
+
last: ChevronsRight,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let dimension = $derived(arrowDimension[size])
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<Icon name={icons[action]} size={dimension} />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PaperSize } from '../../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
size: PaperSize;
|
|
4
|
+
action: 'first' | 'previous' | 'next' | 'last';
|
|
5
|
+
}
|
|
6
|
+
declare const Arrow: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type Arrow = ReturnType<typeof Arrow>;
|
|
8
|
+
export default Arrow;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Button from '../Button.svelte'
|
|
3
|
+
import Arrow from './Arrow.svelte'
|
|
4
|
+
import type { PaperSize, PaperType } from '../../types'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
size: PaperSize
|
|
8
|
+
label: string | null
|
|
9
|
+
action: 'first' | 'previous' | 'next' | 'last'
|
|
10
|
+
type: PaperType
|
|
11
|
+
disabled: boolean
|
|
12
|
+
clickHandler: (e: MouseEvent) => any
|
|
13
|
+
ariaLabel: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { size, label, action, type, disabled, clickHandler, ariaLabel }: Props =
|
|
17
|
+
$props()
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<Button
|
|
21
|
+
{size}
|
|
22
|
+
{type}
|
|
23
|
+
isLink
|
|
24
|
+
{disabled}
|
|
25
|
+
aria-label={ariaLabel}
|
|
26
|
+
onclick={clickHandler}
|
|
27
|
+
>
|
|
28
|
+
{#if label}
|
|
29
|
+
{label}
|
|
30
|
+
{:else}
|
|
31
|
+
<Arrow {size} {action} />
|
|
32
|
+
{/if}
|
|
33
|
+
</Button>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PaperSize, PaperType } from '../../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
size: PaperSize;
|
|
4
|
+
label: string | null;
|
|
5
|
+
action: 'first' | 'previous' | 'next' | 'last';
|
|
6
|
+
type: PaperType;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
clickHandler: (e: MouseEvent) => any;
|
|
9
|
+
ariaLabel: string;
|
|
10
|
+
}
|
|
11
|
+
declare const NavigationButton: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type NavigationButton = ReturnType<typeof NavigationButton>;
|
|
13
|
+
export default NavigationButton;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import Button from '../Button.svelte'
|
|
4
|
+
import Input from '../Form/Input.svelte'
|
|
5
|
+
import type { PaperSize, PaperType } from '../../types'
|
|
6
|
+
import NavigationButton from './NavigationButton.svelte'
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
total: number
|
|
10
|
+
pageSize?: number
|
|
11
|
+
current?: number
|
|
12
|
+
size?: PaperSize
|
|
13
|
+
navigation?: boolean
|
|
14
|
+
/** When true, the pagination is displayed as $page / $pageCount. */
|
|
15
|
+
simple?: boolean
|
|
16
|
+
bullets?: boolean
|
|
17
|
+
previousLabel?: string | null
|
|
18
|
+
nextLabel?: string | null
|
|
19
|
+
highlightedStyle?: PaperType
|
|
20
|
+
defaultStyle?: PaperType | null
|
|
21
|
+
/** The number of pages to show before and after the current page. */
|
|
22
|
+
rangeBetween?: number | null
|
|
23
|
+
/** When true, an input is displayed to jump to a specific page. */
|
|
24
|
+
jumper?: boolean
|
|
25
|
+
pageLabel?: Snippet<[number]> | null
|
|
26
|
+
ariaLabel?: string
|
|
27
|
+
ariaFirstLabel?: string
|
|
28
|
+
ariaPreviousLabel?: string
|
|
29
|
+
ariaNextLabel?: string
|
|
30
|
+
ariaLastLabel?: string
|
|
31
|
+
ariaPageLabel?: ((idx: number) => string) | null
|
|
32
|
+
onchange?: (current: number) => void
|
|
33
|
+
[key: string]: any
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let {
|
|
37
|
+
total,
|
|
38
|
+
pageSize = 10,
|
|
39
|
+
current = $bindable(1),
|
|
40
|
+
size = 'small',
|
|
41
|
+
navigation = true,
|
|
42
|
+
simple = false,
|
|
43
|
+
bullets = false,
|
|
44
|
+
previousLabel = null,
|
|
45
|
+
nextLabel = null,
|
|
46
|
+
highlightedStyle = 'secondary',
|
|
47
|
+
defaultStyle = null,
|
|
48
|
+
rangeBetween = null,
|
|
49
|
+
jumper = false,
|
|
50
|
+
pageLabel = null,
|
|
51
|
+
ariaLabel = 'Pagination',
|
|
52
|
+
ariaFirstLabel = 'first page',
|
|
53
|
+
ariaPreviousLabel = 'previous page',
|
|
54
|
+
ariaNextLabel = 'next page',
|
|
55
|
+
ariaLastLabel = 'last page',
|
|
56
|
+
ariaPageLabel = null,
|
|
57
|
+
onchange,
|
|
58
|
+
...rest
|
|
59
|
+
}: Props = $props()
|
|
60
|
+
|
|
61
|
+
let jumperValue = $state('')
|
|
62
|
+
|
|
63
|
+
const pageCount = $derived(Math.ceil(total / pageSize))
|
|
64
|
+
|
|
65
|
+
const pages = $derived(
|
|
66
|
+
current
|
|
67
|
+
? Array.from({ length: pageCount }, (_, i) => ({
|
|
68
|
+
idx: ++i,
|
|
69
|
+
show: shouldDisplayButton(i),
|
|
70
|
+
}))
|
|
71
|
+
: [],
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
let showNavigation: boolean = $derived(navigation && !bullets)
|
|
75
|
+
|
|
76
|
+
function submitJumper({ code }: KeyboardEvent) {
|
|
77
|
+
const toPage = Number(jumperValue)
|
|
78
|
+
if (code !== 'Enter' || pageInvalid(toPage)) return
|
|
79
|
+
|
|
80
|
+
changePage(toPage)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function pageInvalid(idx: number): boolean {
|
|
84
|
+
return idx < 1 || idx > pageCount || !Number.isInteger(idx)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function shouldDisplayButton(idx: number): boolean {
|
|
88
|
+
if (!rangeBetween || [1, pageCount].includes(idx)) return true
|
|
89
|
+
|
|
90
|
+
return idx >= current - rangeBetween && idx <= current + rangeBetween
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function shouldDisplayEllipsis(idx: number): boolean {
|
|
94
|
+
return pages[idx - 2].show
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function changePage(val: number) {
|
|
98
|
+
if (pageInvalid(val)) return
|
|
99
|
+
|
|
100
|
+
current = val
|
|
101
|
+
onchange?.(current)
|
|
102
|
+
}
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
{#snippet pageNumber(idx: number)}
|
|
106
|
+
{idx}
|
|
107
|
+
{/snippet}
|
|
108
|
+
|
|
109
|
+
{#snippet navigationButton(action: 'first' | 'previous' | 'next' | 'last')}
|
|
110
|
+
{@const atStart = action === 'first' || action === 'previous'}
|
|
111
|
+
{@const label = {
|
|
112
|
+
first: null,
|
|
113
|
+
previous: previousLabel,
|
|
114
|
+
next: nextLabel,
|
|
115
|
+
last: null,
|
|
116
|
+
}[action]}
|
|
117
|
+
{@const page = {
|
|
118
|
+
first: 1,
|
|
119
|
+
previous: current - 1,
|
|
120
|
+
next: current + 1,
|
|
121
|
+
last: pageCount,
|
|
122
|
+
}[action]}
|
|
123
|
+
{@const name = {
|
|
124
|
+
first: ariaFirstLabel,
|
|
125
|
+
previous: ariaPreviousLabel,
|
|
126
|
+
next: ariaNextLabel,
|
|
127
|
+
last: ariaLastLabel,
|
|
128
|
+
}[action]}
|
|
129
|
+
<NavigationButton
|
|
130
|
+
type={highlightedStyle}
|
|
131
|
+
{size}
|
|
132
|
+
{action}
|
|
133
|
+
{label}
|
|
134
|
+
disabled={atStart ? current <= 1 : current >= pageCount}
|
|
135
|
+
clickHandler={changePage.bind(null, page)}
|
|
136
|
+
ariaLabel={name}
|
|
137
|
+
/>
|
|
138
|
+
{/snippet}
|
|
139
|
+
|
|
140
|
+
{#snippet navButtons(
|
|
141
|
+
actions: Array<'first' | 'previous' | 'next' | 'last'>,
|
|
142
|
+
inList: boolean,
|
|
143
|
+
)}
|
|
144
|
+
{#if showNavigation}
|
|
145
|
+
{#each actions as action (action)}
|
|
146
|
+
{#if inList}
|
|
147
|
+
<li class="m-0">{@render navigationButton(action)}</li>
|
|
148
|
+
{:else}
|
|
149
|
+
{@render navigationButton(action)}
|
|
150
|
+
{/if}
|
|
151
|
+
{/each}
|
|
152
|
+
{/if}
|
|
153
|
+
{/snippet}
|
|
154
|
+
|
|
155
|
+
<nav
|
|
156
|
+
{...rest}
|
|
157
|
+
class={[
|
|
158
|
+
'inline-flex flex-wrap items-center justify-center gap-1',
|
|
159
|
+
rest.class,
|
|
160
|
+
]}
|
|
161
|
+
aria-label={ariaLabel}
|
|
162
|
+
>
|
|
163
|
+
{#if simple}
|
|
164
|
+
{@render navButtons(['first', 'previous'], false)}
|
|
165
|
+
{current} / {pageCount}
|
|
166
|
+
{@render navButtons(['next', 'last'], false)}
|
|
167
|
+
{:else}
|
|
168
|
+
<ul
|
|
169
|
+
class="m-0 flex list-none items-center gap-1 p-0 [&_li]:before:content-none"
|
|
170
|
+
>
|
|
171
|
+
{@render navButtons(['first', 'previous'], true)}
|
|
172
|
+
{#each pages as { idx, show }}
|
|
173
|
+
{#if show}
|
|
174
|
+
<li class="m-0">
|
|
175
|
+
<Button
|
|
176
|
+
{size}
|
|
177
|
+
isLink
|
|
178
|
+
class={bullets ? 'rounded-full!' : ''}
|
|
179
|
+
onclick={() => changePage(idx)}
|
|
180
|
+
type={idx === current ? highlightedStyle : defaultStyle}
|
|
181
|
+
aria-label={ariaPageLabel?.(idx) ?? `Page ${idx}`}
|
|
182
|
+
aria-current={idx === current ? 'page' : undefined}
|
|
183
|
+
>
|
|
184
|
+
{#if !bullets}
|
|
185
|
+
{@render (pageLabel ?? pageNumber)(idx)}
|
|
186
|
+
{/if}
|
|
187
|
+
</Button>
|
|
188
|
+
</li>
|
|
189
|
+
{:else if shouldDisplayEllipsis(idx)}
|
|
190
|
+
<li class="m-0">…</li>
|
|
191
|
+
{/if}
|
|
192
|
+
{/each}
|
|
193
|
+
{@render navButtons(['next', 'last'], true)}
|
|
194
|
+
</ul>
|
|
195
|
+
{/if}
|
|
196
|
+
|
|
197
|
+
{#if jumper}
|
|
198
|
+
<Input
|
|
199
|
+
class="inline w-16"
|
|
200
|
+
bind:value={jumperValue}
|
|
201
|
+
type="number"
|
|
202
|
+
placeholder="Go to"
|
|
203
|
+
min="1"
|
|
204
|
+
max={pageCount}
|
|
205
|
+
step="1"
|
|
206
|
+
onkeydown={submitJumper}
|
|
207
|
+
/>
|
|
208
|
+
{/if}
|
|
209
|
+
</nav>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { PaperSize, PaperType } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
total: number;
|
|
5
|
+
pageSize?: number;
|
|
6
|
+
current?: number;
|
|
7
|
+
size?: PaperSize;
|
|
8
|
+
navigation?: boolean;
|
|
9
|
+
/** When true, the pagination is displayed as $page / $pageCount. */
|
|
10
|
+
simple?: boolean;
|
|
11
|
+
bullets?: boolean;
|
|
12
|
+
previousLabel?: string | null;
|
|
13
|
+
nextLabel?: string | null;
|
|
14
|
+
highlightedStyle?: PaperType;
|
|
15
|
+
defaultStyle?: PaperType | null;
|
|
16
|
+
/** The number of pages to show before and after the current page. */
|
|
17
|
+
rangeBetween?: number | null;
|
|
18
|
+
/** When true, an input is displayed to jump to a specific page. */
|
|
19
|
+
jumper?: boolean;
|
|
20
|
+
pageLabel?: Snippet<[number]> | null;
|
|
21
|
+
ariaLabel?: string;
|
|
22
|
+
ariaFirstLabel?: string;
|
|
23
|
+
ariaPreviousLabel?: string;
|
|
24
|
+
ariaNextLabel?: string;
|
|
25
|
+
ariaLastLabel?: string;
|
|
26
|
+
ariaPageLabel?: ((idx: number) => string) | null;
|
|
27
|
+
onchange?: (current: number) => void;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}
|
|
30
|
+
declare const Pagination: import("svelte").Component<Props, {}, "current">;
|
|
31
|
+
type Pagination = ReturnType<typeof Pagination>;
|
|
32
|
+
export default Pagination;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PaperColor, Position } from '../types'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
label?: string
|
|
6
|
+
position?: Position
|
|
7
|
+
inline?: boolean
|
|
8
|
+
type?: PaperColor | null
|
|
9
|
+
/** @deprecated Use `type`. */
|
|
10
|
+
background?: PaperColor | null
|
|
11
|
+
active?: boolean
|
|
12
|
+
/** When true, the popover is always shown. */
|
|
13
|
+
always?: boolean
|
|
14
|
+
children?: import('svelte').Snippet
|
|
15
|
+
[key: string]: any
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
label = '',
|
|
20
|
+
position = 'top',
|
|
21
|
+
inline = true,
|
|
22
|
+
type = null,
|
|
23
|
+
background = 'primary',
|
|
24
|
+
active = false,
|
|
25
|
+
always = false,
|
|
26
|
+
children,
|
|
27
|
+
...rest
|
|
28
|
+
}: Props = $props()
|
|
29
|
+
|
|
30
|
+
const positionClass: Record<Position, string> = {
|
|
31
|
+
top: 'popover-paper-top',
|
|
32
|
+
bottom: 'popover-paper-bottom',
|
|
33
|
+
left: 'popover-paper-left',
|
|
34
|
+
right: 'popover-paper-right',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const color = $derived(type ?? background)
|
|
38
|
+
|
|
39
|
+
const backgroundClass: Record<PaperColor, string> = {
|
|
40
|
+
primary: 'popover-paper-primary',
|
|
41
|
+
secondary: 'popover-paper-secondary',
|
|
42
|
+
success: 'popover-paper-success',
|
|
43
|
+
warning: 'popover-paper-warning',
|
|
44
|
+
danger: 'popover-paper-danger',
|
|
45
|
+
muted: 'popover-paper-muted',
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<div
|
|
50
|
+
{...rest}
|
|
51
|
+
data-popover={label}
|
|
52
|
+
class={[
|
|
53
|
+
'popover-paper',
|
|
54
|
+
positionClass[position],
|
|
55
|
+
color && backgroundClass[color],
|
|
56
|
+
{
|
|
57
|
+
inline,
|
|
58
|
+
active: always || active,
|
|
59
|
+
},
|
|
60
|
+
rest.class,
|
|
61
|
+
]}
|
|
62
|
+
>
|
|
63
|
+
{@render children?.()}
|
|
64
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PaperColor, Position } from '../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
label?: string;
|
|
4
|
+
position?: Position;
|
|
5
|
+
inline?: boolean;
|
|
6
|
+
type?: PaperColor | null;
|
|
7
|
+
/** @deprecated Use `type`. */
|
|
8
|
+
background?: PaperColor | null;
|
|
9
|
+
active?: boolean;
|
|
10
|
+
/** When true, the popover is always shown. */
|
|
11
|
+
always?: boolean;
|
|
12
|
+
children?: import('svelte').Snippet;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
declare const Popover: import("svelte").Component<Props, {}, "">;
|
|
16
|
+
type Popover = ReturnType<typeof Popover>;
|
|
17
|
+
export default Popover;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PaperColor } from '../types'
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
value?: number | string
|
|
6
|
+
type?: PaperColor
|
|
7
|
+
showValue?: boolean
|
|
8
|
+
striped?: boolean
|
|
9
|
+
/** Loops the bar. Ignores `value`. */
|
|
10
|
+
indeterminate?: boolean
|
|
11
|
+
/** @deprecated Use `indeterminate`. */
|
|
12
|
+
infinite?: boolean
|
|
13
|
+
/** @deprecated Use `class="mb-4"` instead. */
|
|
14
|
+
marginBottom?: boolean
|
|
15
|
+
barClass?: string
|
|
16
|
+
children?: import('svelte').Snippet
|
|
17
|
+
[key: string]: any
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
value = 50,
|
|
22
|
+
type = 'primary',
|
|
23
|
+
showValue = false,
|
|
24
|
+
striped = false,
|
|
25
|
+
indeterminate = false,
|
|
26
|
+
infinite = false,
|
|
27
|
+
marginBottom = true,
|
|
28
|
+
barClass = '',
|
|
29
|
+
children,
|
|
30
|
+
...rest
|
|
31
|
+
}: Props = $props()
|
|
32
|
+
|
|
33
|
+
const barTypeClass: Record<Exclude<PaperColor, 'primary'>, string> = {
|
|
34
|
+
secondary: 'progress-paper-bar-secondary',
|
|
35
|
+
success: 'progress-paper-bar-success',
|
|
36
|
+
warning: 'progress-paper-bar-warning',
|
|
37
|
+
danger: 'progress-paper-bar-danger',
|
|
38
|
+
muted: 'progress-paper-bar-muted',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const stripedClass: Record<PaperColor, string> = {
|
|
42
|
+
primary: 'progress-paper-striped',
|
|
43
|
+
secondary: 'progress-paper-striped-secondary',
|
|
44
|
+
success: 'progress-paper-striped-success',
|
|
45
|
+
warning: 'progress-paper-striped-warning',
|
|
46
|
+
danger: 'progress-paper-striped-danger',
|
|
47
|
+
muted: 'progress-paper-striped-muted',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let cappedValue: number = $derived(Math.max(Math.min(+value, 100), 0))
|
|
51
|
+
const isIndeterminate = $derived(indeterminate || infinite)
|
|
52
|
+
|
|
53
|
+
let variantClass = $derived(
|
|
54
|
+
striped
|
|
55
|
+
? (stripedClass[type] ?? '')
|
|
56
|
+
: type === 'primary'
|
|
57
|
+
? ''
|
|
58
|
+
: (barTypeClass[type] ?? ''),
|
|
59
|
+
)
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
{...rest}
|
|
64
|
+
class={[
|
|
65
|
+
'progress-paper',
|
|
66
|
+
{
|
|
67
|
+
'progress-paper-indeterminate': isIndeterminate,
|
|
68
|
+
'mb-4': marginBottom,
|
|
69
|
+
},
|
|
70
|
+
rest.class,
|
|
71
|
+
]}
|
|
72
|
+
role="progressbar"
|
|
73
|
+
aria-valuenow={isIndeterminate ? undefined : cappedValue}
|
|
74
|
+
>
|
|
75
|
+
{#if isIndeterminate || cappedValue > 0}
|
|
76
|
+
<div
|
|
77
|
+
class={['progress-paper-bar', variantClass, barClass]}
|
|
78
|
+
style={isIndeterminate ? undefined : `width: ${cappedValue}%`}
|
|
79
|
+
>
|
|
80
|
+
{#if children}
|
|
81
|
+
{@render children?.()}
|
|
82
|
+
{:else if showValue}
|
|
83
|
+
{cappedValue}%
|
|
84
|
+
{/if}
|
|
85
|
+
</div>
|
|
86
|
+
{/if}
|
|
87
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PaperColor } from '../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
value?: number | string;
|
|
4
|
+
type?: PaperColor;
|
|
5
|
+
showValue?: boolean;
|
|
6
|
+
striped?: boolean;
|
|
7
|
+
/** Loops the bar. Ignores `value`. */
|
|
8
|
+
indeterminate?: boolean;
|
|
9
|
+
/** @deprecated Use `indeterminate`. */
|
|
10
|
+
infinite?: boolean;
|
|
11
|
+
/** @deprecated Use `class="mb-4"` instead. */
|
|
12
|
+
marginBottom?: boolean;
|
|
13
|
+
barClass?: string;
|
|
14
|
+
children?: import('svelte').Snippet;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
declare const Progress: import("svelte").Component<Props, {}, "">;
|
|
18
|
+
type Progress = ReturnType<typeof Progress>;
|
|
19
|
+
export default Progress;
|