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,129 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
import type { PaperType, PaperColor } from '../../types'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
label?: string
|
|
7
|
+
min?: number | string
|
|
8
|
+
max?: number | string
|
|
9
|
+
step?: number | string
|
|
10
|
+
/** @deprecated Use `class="w-full"` instead. */
|
|
11
|
+
block?: boolean
|
|
12
|
+
hideValue?: boolean
|
|
13
|
+
value?: number | string | null
|
|
14
|
+
type?: PaperColor | null
|
|
15
|
+
/** @deprecated Use `type` — maps to `slider-paper-{color}`. */
|
|
16
|
+
background?: PaperType | null
|
|
17
|
+
percentage?: boolean
|
|
18
|
+
disabled?: boolean
|
|
19
|
+
children?: import('svelte').Snippet
|
|
20
|
+
output?: import('svelte').Snippet<[number | string | null]>
|
|
21
|
+
[key: string]: any
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let {
|
|
25
|
+
label = '',
|
|
26
|
+
min = 0,
|
|
27
|
+
max = 100,
|
|
28
|
+
step = 1,
|
|
29
|
+
block = false,
|
|
30
|
+
hideValue = false,
|
|
31
|
+
value = $bindable(null),
|
|
32
|
+
type = null,
|
|
33
|
+
background = null,
|
|
34
|
+
percentage = false,
|
|
35
|
+
disabled = false,
|
|
36
|
+
children,
|
|
37
|
+
output,
|
|
38
|
+
...rest
|
|
39
|
+
}: Props = $props()
|
|
40
|
+
|
|
41
|
+
const typeClass: Record<PaperColor, string> = {
|
|
42
|
+
primary: 'slider-paper-primary',
|
|
43
|
+
secondary: 'slider-paper-secondary',
|
|
44
|
+
success: 'slider-paper-success',
|
|
45
|
+
warning: 'slider-paper-warning',
|
|
46
|
+
danger: 'slider-paper-danger',
|
|
47
|
+
muted: 'slider-paper-muted',
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let rangeEl: HTMLInputElement | undefined = $state()
|
|
51
|
+
let outputValue: string = $state('')
|
|
52
|
+
|
|
53
|
+
function syncFill(el = rangeEl) {
|
|
54
|
+
if (!el) return
|
|
55
|
+
const lo = Number(min)
|
|
56
|
+
const hi = Number(max)
|
|
57
|
+
const span = hi - lo
|
|
58
|
+
const pct =
|
|
59
|
+
!Number.isFinite(span) || span === 0
|
|
60
|
+
? 0
|
|
61
|
+
: Math.min(100, Math.max(0, ((el.valueAsNumber - lo) / span) * 100))
|
|
62
|
+
el.style.setProperty('--value', `${pct}%`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function formatOutput(raw: string | number) {
|
|
66
|
+
return percentage
|
|
67
|
+
? String(Math.round((Number(raw) / Number(max)) * 100))
|
|
68
|
+
: String(raw)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function syncOutput() {
|
|
72
|
+
if (value !== null && value !== '') {
|
|
73
|
+
outputValue = formatOutput(value)
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
outputValue = rangeEl ? formatOutput(rangeEl.value) : ''
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function onInput() {
|
|
80
|
+
syncFill()
|
|
81
|
+
outputValue = formatOutput(rangeEl!.value)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
onMount(() => {
|
|
85
|
+
syncFill()
|
|
86
|
+
syncOutput()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
let color = $derived(type ?? background)
|
|
90
|
+
|
|
91
|
+
$effect(() => {
|
|
92
|
+
syncFill()
|
|
93
|
+
syncOutput()
|
|
94
|
+
})
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<label {...rest} class={[{ block, disabled }, rest.class]}>
|
|
98
|
+
{#if children}
|
|
99
|
+
{@render children?.()}
|
|
100
|
+
{:else}
|
|
101
|
+
{label}
|
|
102
|
+
{/if}
|
|
103
|
+
<input
|
|
104
|
+
type="range"
|
|
105
|
+
bind:this={rangeEl}
|
|
106
|
+
bind:value
|
|
107
|
+
class={[
|
|
108
|
+
'slider-paper',
|
|
109
|
+
color ? typeClass[color] : '',
|
|
110
|
+
{ 'w-full': block },
|
|
111
|
+
rest.class,
|
|
112
|
+
]}
|
|
113
|
+
{min}
|
|
114
|
+
{max}
|
|
115
|
+
{step}
|
|
116
|
+
{disabled}
|
|
117
|
+
oninput={onInput}
|
|
118
|
+
/>
|
|
119
|
+
{#if !hideValue}
|
|
120
|
+
<output>
|
|
121
|
+
{#if output}
|
|
122
|
+
{@render output(value)}
|
|
123
|
+
{:else}
|
|
124
|
+
{outputValue}
|
|
125
|
+
{#if percentage}%{/if}
|
|
126
|
+
{/if}
|
|
127
|
+
</output>
|
|
128
|
+
{/if}
|
|
129
|
+
</label>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PaperType, PaperColor } from '../../types';
|
|
2
|
+
interface Props {
|
|
3
|
+
label?: string;
|
|
4
|
+
min?: number | string;
|
|
5
|
+
max?: number | string;
|
|
6
|
+
step?: number | string;
|
|
7
|
+
/** @deprecated Use `class="w-full"` instead. */
|
|
8
|
+
block?: boolean;
|
|
9
|
+
hideValue?: boolean;
|
|
10
|
+
value?: number | string | null;
|
|
11
|
+
type?: PaperColor | null;
|
|
12
|
+
/** @deprecated Use `type` — maps to `slider-paper-{color}`. */
|
|
13
|
+
background?: PaperType | null;
|
|
14
|
+
percentage?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
children?: import('svelte').Snippet;
|
|
17
|
+
output?: import('svelte').Snippet<[number | string | null]>;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
declare const Slider: import("svelte").Component<Props, {}, "value">;
|
|
21
|
+
type Slider = ReturnType<typeof Slider>;
|
|
22
|
+
export default Slider;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PaperType } from '../../types'
|
|
3
|
+
|
|
4
|
+
interface TileSide {
|
|
5
|
+
label: string
|
|
6
|
+
background?: PaperType
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface TileOptions {
|
|
10
|
+
on: TileSide
|
|
11
|
+
off: TileSide
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
checked?: boolean
|
|
16
|
+
disabled?: boolean
|
|
17
|
+
round?: boolean
|
|
18
|
+
inline?: boolean
|
|
19
|
+
tile?: TileOptions | null
|
|
20
|
+
onchange?: (checked: boolean) => void
|
|
21
|
+
children?: import('svelte').Snippet
|
|
22
|
+
[key: string]: any
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
checked = $bindable(false),
|
|
27
|
+
disabled = false,
|
|
28
|
+
round = false,
|
|
29
|
+
inline = false,
|
|
30
|
+
tile = null,
|
|
31
|
+
onchange,
|
|
32
|
+
children,
|
|
33
|
+
...rest
|
|
34
|
+
}: Props = $props()
|
|
35
|
+
|
|
36
|
+
const domId = $props.id()
|
|
37
|
+
|
|
38
|
+
let switchClass = $derived(inline ? 'paper-switch-2' : 'paper-switch')
|
|
39
|
+
let labelClass = $derived(
|
|
40
|
+
inline ? 'paper-switch-2-label' : 'paper-switch-label',
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
function handleChange() {
|
|
44
|
+
onchange?.(checked)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const backgrounds: Record<PaperType, string> = {
|
|
48
|
+
primary: 'bg-primary',
|
|
49
|
+
secondary: 'bg-secondary',
|
|
50
|
+
success: 'bg-success',
|
|
51
|
+
warning: 'bg-warning',
|
|
52
|
+
danger: 'bg-danger',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function bgClass(color?: PaperType) {
|
|
56
|
+
if (!color) return ''
|
|
57
|
+
return backgrounds[color]
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
{#if tile}
|
|
62
|
+
<label {...rest} class={['paper-switch-tile', { disabled }, rest.class]}>
|
|
63
|
+
<input bind:checked type="checkbox" {disabled} onchange={handleChange} />
|
|
64
|
+
<div class="paper-switch-tile-card border-paper">
|
|
65
|
+
<div
|
|
66
|
+
class={[
|
|
67
|
+
'paper-switch-tile-card-front',
|
|
68
|
+
'border-paper',
|
|
69
|
+
bgClass(tile.off.background),
|
|
70
|
+
]}
|
|
71
|
+
>
|
|
72
|
+
{tile.off.label}
|
|
73
|
+
</div>
|
|
74
|
+
<div
|
|
75
|
+
class={[
|
|
76
|
+
'paper-switch-tile-card-back',
|
|
77
|
+
'border-paper',
|
|
78
|
+
bgClass(tile.on.background),
|
|
79
|
+
]}
|
|
80
|
+
>
|
|
81
|
+
{tile.on.label}
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</label>
|
|
85
|
+
{:else}
|
|
86
|
+
<label class={switchClass}>
|
|
87
|
+
<input
|
|
88
|
+
id={domId}
|
|
89
|
+
bind:checked
|
|
90
|
+
type="checkbox"
|
|
91
|
+
{disabled}
|
|
92
|
+
onchange={handleChange}
|
|
93
|
+
/>
|
|
94
|
+
<span class={['paper-switch-slider', { round }]}></span>
|
|
95
|
+
</label>
|
|
96
|
+
{#if children}
|
|
97
|
+
<label class={labelClass} for={domId}>
|
|
98
|
+
{@render children?.()}
|
|
99
|
+
</label>
|
|
100
|
+
{/if}
|
|
101
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PaperType } from '../../types';
|
|
2
|
+
interface TileSide {
|
|
3
|
+
label: string;
|
|
4
|
+
background?: PaperType;
|
|
5
|
+
}
|
|
6
|
+
interface TileOptions {
|
|
7
|
+
on: TileSide;
|
|
8
|
+
off: TileSide;
|
|
9
|
+
}
|
|
10
|
+
interface Props {
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
round?: boolean;
|
|
14
|
+
inline?: boolean;
|
|
15
|
+
tile?: TileOptions | null;
|
|
16
|
+
onchange?: (checked: boolean) => void;
|
|
17
|
+
children?: import('svelte').Snippet;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
declare const Switch: import("svelte").Component<Props, {}, "checked">;
|
|
21
|
+
type Switch = ReturnType<typeof Switch>;
|
|
22
|
+
export default Switch;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Input from './Input.svelte';
|
|
2
|
+
import Select from './Select.svelte';
|
|
3
|
+
import Radio from './Radio.svelte';
|
|
4
|
+
import Checkbox from './Checkbox.svelte';
|
|
5
|
+
import Switch from './Switch.svelte';
|
|
6
|
+
import Slider from './Slider.svelte';
|
|
7
|
+
import { NumberInput } from './NumberInput';
|
|
8
|
+
export type InputType = 'text' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'url' | 'time' | 'date' | 'month' | 'week' | 'datetime-local' | 'color' | 'textarea';
|
|
9
|
+
export { Input, Select, Radio, Checkbox, Switch, Slider, NumberInput };
|
|
@@ -4,5 +4,5 @@ import Radio from './Radio.svelte';
|
|
|
4
4
|
import Checkbox from './Checkbox.svelte';
|
|
5
5
|
import Switch from './Switch.svelte';
|
|
6
6
|
import Slider from './Slider.svelte';
|
|
7
|
-
import
|
|
8
|
-
export { Input, Select, Radio, Checkbox, Switch, Slider,
|
|
7
|
+
import { NumberInput } from './NumberInput';
|
|
8
|
+
export { Input, Select, Radio, Checkbox, Switch, Slider, NumberInput };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { PaperSize, PaperType, StringOrSnippet } from '../types'
|
|
4
|
+
import { isSnippet } from '../utils'
|
|
5
|
+
|
|
6
|
+
type HeroSize = PaperSize | 'fullheight'
|
|
7
|
+
type HeroType = PaperType | 'muted'
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
type?: HeroType
|
|
11
|
+
size?: HeroSize
|
|
12
|
+
border?: boolean
|
|
13
|
+
title?: StringOrSnippet
|
|
14
|
+
textLead?: StringOrSnippet
|
|
15
|
+
children?: Snippet
|
|
16
|
+
class?: string
|
|
17
|
+
[key: string]: unknown
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
type = 'primary',
|
|
22
|
+
size = 'default',
|
|
23
|
+
border = true,
|
|
24
|
+
title = '',
|
|
25
|
+
textLead = '',
|
|
26
|
+
children,
|
|
27
|
+
class: className = '',
|
|
28
|
+
...rest
|
|
29
|
+
}: Props = $props()
|
|
30
|
+
|
|
31
|
+
const typeClass: Record<HeroType, string> = {
|
|
32
|
+
primary: 'hero-paper-primary',
|
|
33
|
+
secondary: 'hero-paper-secondary',
|
|
34
|
+
success: 'hero-paper-success',
|
|
35
|
+
warning: 'hero-paper-warning',
|
|
36
|
+
danger: 'hero-paper-danger',
|
|
37
|
+
muted: 'hero-paper-muted',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const sizeClass: Record<Exclude<HeroSize, 'default'>, string> = {
|
|
41
|
+
small: 'hero-paper-sm',
|
|
42
|
+
large: 'hero-paper-lg',
|
|
43
|
+
fullheight: 'hero-paper-fullheight',
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<section
|
|
48
|
+
{...rest}
|
|
49
|
+
class={[
|
|
50
|
+
'hero-paper',
|
|
51
|
+
typeClass[type],
|
|
52
|
+
size !== 'default' ? sizeClass[size] : '',
|
|
53
|
+
{ 'border-0': !border },
|
|
54
|
+
className,
|
|
55
|
+
]}
|
|
56
|
+
>
|
|
57
|
+
<div class="hero-paper-body">
|
|
58
|
+
{#if isSnippet(title)}
|
|
59
|
+
{@render title()}
|
|
60
|
+
{:else if title}
|
|
61
|
+
<h2 class="hero-paper-title">{title}</h2>
|
|
62
|
+
{/if}
|
|
63
|
+
|
|
64
|
+
{#if isSnippet(textLead) || textLead}
|
|
65
|
+
<p class="hero-paper-lead">
|
|
66
|
+
{#if isSnippet(textLead)}
|
|
67
|
+
{@render textLead()}
|
|
68
|
+
{:else}
|
|
69
|
+
{textLead}
|
|
70
|
+
{/if}
|
|
71
|
+
</p>
|
|
72
|
+
{/if}
|
|
73
|
+
|
|
74
|
+
{#if children}
|
|
75
|
+
<div>{@render children()}</div>
|
|
76
|
+
{/if}
|
|
77
|
+
</div>
|
|
78
|
+
</section>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { PaperSize, PaperType, StringOrSnippet } from '../types';
|
|
3
|
+
type HeroSize = PaperSize | 'fullheight';
|
|
4
|
+
type HeroType = PaperType | 'muted';
|
|
5
|
+
interface Props {
|
|
6
|
+
type?: HeroType;
|
|
7
|
+
size?: HeroSize;
|
|
8
|
+
border?: boolean;
|
|
9
|
+
title?: StringOrSnippet;
|
|
10
|
+
textLead?: StringOrSnippet;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
class?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
declare const Hero: import("svelte").Component<Props, {}, "">;
|
|
16
|
+
type Hero = ReturnType<typeof Hero>;
|
|
17
|
+
export default Hero;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { SketchyIcon } from '@sketchyicons/svelte'
|
|
3
|
+
import type { IconNode } from '@sketchyicons/svelte'
|
|
4
|
+
import type { PaperColor } from '../types'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/** Icon geometry (`IconNode` from `spaper/icons` or `@sketchyicons/svelte`). */
|
|
8
|
+
name?: IconNode | null
|
|
9
|
+
/** Sketchyicons prop name — same as `name`. */
|
|
10
|
+
img?: IconNode | null
|
|
11
|
+
/** Paper color token. Overridden by `color` when both are set. */
|
|
12
|
+
type?: PaperColor | null
|
|
13
|
+
/**
|
|
14
|
+
* Stroke color: a paper token (`primary`, `muted`, …) or any CSS color.
|
|
15
|
+
* Wins over `type` when both are set.
|
|
16
|
+
*/
|
|
17
|
+
color?: PaperColor | (string & {}) | null
|
|
18
|
+
size?: number | string
|
|
19
|
+
strokeWidth?: number | string
|
|
20
|
+
absoluteStrokeWidth?: boolean
|
|
21
|
+
/**
|
|
22
|
+
* Path fill: a paper token (`primary`, `danger`, …) or any CSS color
|
|
23
|
+
* (e.g. `currentColor`). SketchyIcon has no fill — drawn locally when set.
|
|
24
|
+
*/
|
|
25
|
+
fill?: PaperColor | (string & {}) | null
|
|
26
|
+
[key: string]: any
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
name = null,
|
|
31
|
+
img = null,
|
|
32
|
+
type = null,
|
|
33
|
+
color = null,
|
|
34
|
+
size = 24,
|
|
35
|
+
strokeWidth = 2,
|
|
36
|
+
absoluteStrokeWidth = false,
|
|
37
|
+
fill = null,
|
|
38
|
+
...rest
|
|
39
|
+
}: Props = $props()
|
|
40
|
+
|
|
41
|
+
const TOKEN_COLORS = new Set<string>([
|
|
42
|
+
'primary',
|
|
43
|
+
'secondary',
|
|
44
|
+
'success',
|
|
45
|
+
'warning',
|
|
46
|
+
'danger',
|
|
47
|
+
'muted',
|
|
48
|
+
])
|
|
49
|
+
|
|
50
|
+
function resolveColor(raw: string | null | undefined): string {
|
|
51
|
+
if (!raw) return 'currentColor'
|
|
52
|
+
if (TOKEN_COLORS.has(raw)) return `var(--paper-${raw})`
|
|
53
|
+
return raw
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let node = $derived(name ?? img)
|
|
57
|
+
let resolvedColor = $derived(
|
|
58
|
+
resolveColor((color ?? type) as string | null | undefined),
|
|
59
|
+
)
|
|
60
|
+
let resolvedFill = $derived(!fill ? null : resolveColor(fill as string))
|
|
61
|
+
let width = $derived(
|
|
62
|
+
absoluteStrokeWidth ? (Number(strokeWidth) * 24) / Number(size) : strokeWidth,
|
|
63
|
+
)
|
|
64
|
+
let ariaHidden = $derived(
|
|
65
|
+
rest['aria-label'] || rest['aria-labelledby'] ? undefined : ('true' as const),
|
|
66
|
+
)
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
{#if node}
|
|
70
|
+
{#if resolvedFill}
|
|
71
|
+
<!-- SketchyIcon has no `fill` prop — draw locally when a fill is requested. -->
|
|
72
|
+
<svg
|
|
73
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
74
|
+
viewBox="0 0 24 24"
|
|
75
|
+
fill="none"
|
|
76
|
+
stroke-linecap="round"
|
|
77
|
+
stroke-linejoin="round"
|
|
78
|
+
width={size}
|
|
79
|
+
height={size}
|
|
80
|
+
stroke={resolvedColor}
|
|
81
|
+
stroke-width={width}
|
|
82
|
+
aria-hidden={ariaHidden}
|
|
83
|
+
{...rest}
|
|
84
|
+
class={['inline-block', rest.class]}
|
|
85
|
+
>
|
|
86
|
+
{#each node as [, attributes], i (i)}
|
|
87
|
+
<path d={String(attributes.d)} fill={resolvedFill} />
|
|
88
|
+
{/each}
|
|
89
|
+
</svg>
|
|
90
|
+
{:else}
|
|
91
|
+
<SketchyIcon
|
|
92
|
+
img={node}
|
|
93
|
+
{size}
|
|
94
|
+
color={resolvedColor}
|
|
95
|
+
{strokeWidth}
|
|
96
|
+
{absoluteStrokeWidth}
|
|
97
|
+
aria-hidden={ariaHidden}
|
|
98
|
+
{...rest}
|
|
99
|
+
class={['inline-block', rest.class]}
|
|
100
|
+
/>
|
|
101
|
+
{/if}
|
|
102
|
+
{/if}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { IconNode } from '@sketchyicons/svelte';
|
|
2
|
+
import type { PaperColor } from '../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
/** Icon geometry (`IconNode` from `spaper/icons` or `@sketchyicons/svelte`). */
|
|
5
|
+
name?: IconNode | null;
|
|
6
|
+
/** Sketchyicons prop name — same as `name`. */
|
|
7
|
+
img?: IconNode | null;
|
|
8
|
+
/** Paper color token. Overridden by `color` when both are set. */
|
|
9
|
+
type?: PaperColor | null;
|
|
10
|
+
/**
|
|
11
|
+
* Stroke color: a paper token (`primary`, `muted`, …) or any CSS color.
|
|
12
|
+
* Wins over `type` when both are set.
|
|
13
|
+
*/
|
|
14
|
+
color?: PaperColor | (string & {}) | null;
|
|
15
|
+
size?: number | string;
|
|
16
|
+
strokeWidth?: number | string;
|
|
17
|
+
absoluteStrokeWidth?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Path fill: a paper token (`primary`, `danger`, …) or any CSS color
|
|
20
|
+
* (e.g. `currentColor`). SketchyIcon has no fill — drawn locally when set.
|
|
21
|
+
*/
|
|
22
|
+
fill?: PaperColor | (string & {}) | null;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
25
|
+
declare const Icon: import("svelte").Component<Props, {}, "">;
|
|
26
|
+
type Icon = ReturnType<typeof Icon>;
|
|
27
|
+
export default Icon;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte'
|
|
3
|
+
import type { StringOrSnippet } from '../../types'
|
|
4
|
+
import { isSnippet } from '../../utils'
|
|
5
|
+
import Button from '../Button.svelte'
|
|
6
|
+
import Icon from '../Icon.svelte'
|
|
7
|
+
import { X } from '../../icons'
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
active?: boolean
|
|
11
|
+
title?: StringOrSnippet
|
|
12
|
+
subTitle?: StringOrSnippet
|
|
13
|
+
content?: string
|
|
14
|
+
component?: Component | null
|
|
15
|
+
closeBtnText?: string
|
|
16
|
+
onclose?: () => void
|
|
17
|
+
children?: import('svelte').Snippet
|
|
18
|
+
footer?: import('svelte').Snippet
|
|
19
|
+
[key: string]: any
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
active = $bindable(false),
|
|
24
|
+
title = '',
|
|
25
|
+
subTitle = '',
|
|
26
|
+
content = '',
|
|
27
|
+
component = null,
|
|
28
|
+
closeBtnText = 'Close',
|
|
29
|
+
onclose,
|
|
30
|
+
children,
|
|
31
|
+
footer,
|
|
32
|
+
...rest
|
|
33
|
+
}: Props = $props()
|
|
34
|
+
|
|
35
|
+
let dialogEl: HTMLDialogElement | undefined = $state()
|
|
36
|
+
const uid = $props.id()
|
|
37
|
+
|
|
38
|
+
export function close() {
|
|
39
|
+
active = false
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function onNativeClose() {
|
|
43
|
+
active = false
|
|
44
|
+
onclose?.()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function onBackdropClick(e: MouseEvent) {
|
|
48
|
+
if (e.target === dialogEl) close()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
$effect(() => {
|
|
52
|
+
if (dialogEl) {
|
|
53
|
+
if (active && !dialogEl.open) dialogEl.showModal()
|
|
54
|
+
else if (!active && dialogEl.open) dialogEl.close()
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
60
|
+
<dialog
|
|
61
|
+
bind:this={dialogEl}
|
|
62
|
+
{...rest}
|
|
63
|
+
class={[
|
|
64
|
+
'modal-paper',
|
|
65
|
+
'border-paper',
|
|
66
|
+
'rounded-paper',
|
|
67
|
+
'shadow-paper',
|
|
68
|
+
rest.class,
|
|
69
|
+
]}
|
|
70
|
+
onclick={onBackdropClick}
|
|
71
|
+
onclose={onNativeClose}
|
|
72
|
+
{...title ? { 'aria-labelledby': uid } : {}}
|
|
73
|
+
>
|
|
74
|
+
<form method="dialog">
|
|
75
|
+
<button
|
|
76
|
+
type="submit"
|
|
77
|
+
class="modal-paper-close inline-flex items-center justify-center"
|
|
78
|
+
aria-label="Close"
|
|
79
|
+
>
|
|
80
|
+
<Icon name={X} size={20} />
|
|
81
|
+
</button>
|
|
82
|
+
</form>
|
|
83
|
+
|
|
84
|
+
{#if title}
|
|
85
|
+
<h4 id={uid} class="modal-paper-title">
|
|
86
|
+
{#if isSnippet(title)}
|
|
87
|
+
{@render title()}
|
|
88
|
+
{:else}
|
|
89
|
+
{title}
|
|
90
|
+
{/if}
|
|
91
|
+
</h4>
|
|
92
|
+
{/if}
|
|
93
|
+
{#if subTitle}
|
|
94
|
+
<h5 class="modal-paper-subtitle">
|
|
95
|
+
{#if isSnippet(subTitle)}
|
|
96
|
+
{@render subTitle()}
|
|
97
|
+
{:else}
|
|
98
|
+
{subTitle}
|
|
99
|
+
{/if}
|
|
100
|
+
</h5>
|
|
101
|
+
{/if}
|
|
102
|
+
|
|
103
|
+
{#if content}
|
|
104
|
+
{content}
|
|
105
|
+
{:else if component}
|
|
106
|
+
{@const Dynamic = component}
|
|
107
|
+
<Dynamic />
|
|
108
|
+
{:else}
|
|
109
|
+
{@render children?.()}
|
|
110
|
+
{/if}
|
|
111
|
+
|
|
112
|
+
<footer class="flex flex-wrap items-center justify-end gap-2 mt-4">
|
|
113
|
+
{#if footer}
|
|
114
|
+
{@render footer?.()}
|
|
115
|
+
{/if}
|
|
116
|
+
<Button onclick={close} type="primary">
|
|
117
|
+
{closeBtnText}
|
|
118
|
+
</Button>
|
|
119
|
+
</footer>
|
|
120
|
+
</dialog>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
import type { StringOrSnippet } from '../../types';
|
|
3
|
+
interface Props {
|
|
4
|
+
active?: boolean;
|
|
5
|
+
title?: StringOrSnippet;
|
|
6
|
+
subTitle?: StringOrSnippet;
|
|
7
|
+
content?: string;
|
|
8
|
+
component?: Component | null;
|
|
9
|
+
closeBtnText?: string;
|
|
10
|
+
onclose?: () => void;
|
|
11
|
+
children?: import('svelte').Snippet;
|
|
12
|
+
footer?: import('svelte').Snippet;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
declare const Modal: Component<Props, {
|
|
16
|
+
close: () => void;
|
|
17
|
+
}, "active">;
|
|
18
|
+
type Modal = ReturnType<typeof Modal>;
|
|
19
|
+
export default Modal;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import Modal from './Modal.svelte';
|
|
3
|
+
type ModalProps = ComponentProps<typeof Modal>;
|
|
4
|
+
type ProgrammaticModalProps = Omit<ModalProps, 'active'>;
|
|
5
|
+
interface ProgrammaticModalInstance {
|
|
6
|
+
close: () => void;
|
|
7
|
+
}
|
|
8
|
+
type ProgrammaticModalComponent = typeof Modal & {
|
|
9
|
+
open: (props: ProgrammaticModalProps) => ProgrammaticModalInstance;
|
|
10
|
+
};
|
|
11
|
+
declare const _default: ProgrammaticModalComponent;
|
|
12
|
+
export default _default;
|