sveltacular 0.0.35 → 0.0.36
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/dist/forms/money-box/money-box.svelte +1 -1
- package/dist/forms/number-box/number-box.svelte +2 -2
- package/dist/forms/number-box/number-box.svelte.d.ts +1 -1
- package/dist/generic/header/header.svelte +1 -1
- package/dist/generic/notice/notice.svelte +159 -0
- package/dist/generic/notice/notice.svelte.d.ts +25 -0
- package/dist/helpers/round-to-decimals.d.ts +4 -0
- package/dist/helpers/round-to-decimals.js +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { roundToDecimals } from "../../helpers/round-to-decimals.js";
|
|
1
|
+
<script>import { formatNumber, roundToDecimals } from "../../helpers/round-to-decimals.js";
|
|
2
2
|
import { uniqueId } from "../../helpers/unique-id.js";
|
|
3
3
|
import FormField from "../form-field.svelte";
|
|
4
4
|
import FormLabel from "../form-label.svelte";
|
|
@@ -7,12 +7,12 @@ export let value = 0;
|
|
|
7
7
|
export let placeholder = "";
|
|
8
8
|
export let size = "full";
|
|
9
9
|
export let type = "number";
|
|
10
|
-
export let step = 1;
|
|
11
10
|
export let min = 0;
|
|
12
11
|
export let max = 1e6;
|
|
13
12
|
export let decimals = 0;
|
|
14
13
|
export let prefix = null;
|
|
15
14
|
export let suffix = null;
|
|
15
|
+
export let step = 1;
|
|
16
16
|
const valueChanged = () => {
|
|
17
17
|
value = roundToDecimals(value, decimals);
|
|
18
18
|
};
|
|
@@ -6,12 +6,12 @@ declare const __propDef: {
|
|
|
6
6
|
placeholder?: string | undefined;
|
|
7
7
|
size?: FormFieldSizeOptions | undefined;
|
|
8
8
|
type?: ("number" | "currency") | undefined;
|
|
9
|
-
step?: number | undefined;
|
|
10
9
|
min?: number | undefined;
|
|
11
10
|
max?: number | undefined;
|
|
12
11
|
decimals?: number | undefined;
|
|
13
12
|
prefix?: string | null | undefined;
|
|
14
13
|
suffix?: string | null | undefined;
|
|
14
|
+
step?: number | undefined;
|
|
15
15
|
};
|
|
16
16
|
events: {
|
|
17
17
|
[evt: string]: CustomEvent<any>;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
2
|
+
const dispatch = createEventDispatcher();
|
|
3
|
+
export let title = void 0;
|
|
4
|
+
export let style = "info";
|
|
5
|
+
export let size = "full";
|
|
6
|
+
export let dismissable = false;
|
|
7
|
+
let visible = true;
|
|
8
|
+
let fading = false;
|
|
9
|
+
const goodbye = () => {
|
|
10
|
+
dispatch("dismiss");
|
|
11
|
+
fading = true;
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
visible = false;
|
|
14
|
+
dispatch("hidden");
|
|
15
|
+
}, 500);
|
|
16
|
+
};
|
|
17
|
+
const onClick = (e) => {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
goodbye();
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div class="notice {style} {size} {visible ? 'visible' : 'hidden'} {fading ? 'fading' : ''}">
|
|
25
|
+
{#if $$slots.icon}
|
|
26
|
+
<div class="icon">
|
|
27
|
+
<slot name="icon" />
|
|
28
|
+
</div>
|
|
29
|
+
{/if}
|
|
30
|
+
<div class="content">
|
|
31
|
+
{#if title}
|
|
32
|
+
<strong>{title}</strong>
|
|
33
|
+
{/if}
|
|
34
|
+
<div class="message">
|
|
35
|
+
<slot />
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{#if dismissable}
|
|
40
|
+
<div class="dismiss">
|
|
41
|
+
<button type="button" on:click={onClick}>X</button>
|
|
42
|
+
</div>
|
|
43
|
+
{/if}
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<style>.notice {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-direction: row;
|
|
49
|
+
gap: 1rem;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: flex-start;
|
|
52
|
+
position: relative;
|
|
53
|
+
width: 100%;
|
|
54
|
+
max-width: 100%;
|
|
55
|
+
padding: 1rem;
|
|
56
|
+
border-radius: 0.2rem;
|
|
57
|
+
border: 2px solid var(--base-fg, black);
|
|
58
|
+
background: var(--base-bg, white);
|
|
59
|
+
color: var(--base-fg, black);
|
|
60
|
+
position: relative;
|
|
61
|
+
opacity: 1;
|
|
62
|
+
transition: opacity 0.3s ease-in-out, transform 0.5s ease-in-out;
|
|
63
|
+
}
|
|
64
|
+
.notice.hidden {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
67
|
+
.notice.fading {
|
|
68
|
+
transform: translateY(-100%);
|
|
69
|
+
opacity: 0;
|
|
70
|
+
}
|
|
71
|
+
.notice .icon {
|
|
72
|
+
position: relative;
|
|
73
|
+
width: 3rem;
|
|
74
|
+
min-width: 3rem;
|
|
75
|
+
height: 100%;
|
|
76
|
+
}
|
|
77
|
+
.notice .content {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
gap: 0.5rem;
|
|
81
|
+
align-items: flex-start;
|
|
82
|
+
justify-content: flex-start;
|
|
83
|
+
}
|
|
84
|
+
.notice.info {
|
|
85
|
+
background-color: rgb(225, 225, 225);
|
|
86
|
+
color: rgb(78, 78, 78);
|
|
87
|
+
border-color: rgb(144, 144, 144);
|
|
88
|
+
}
|
|
89
|
+
.notice.attention {
|
|
90
|
+
background-color: rgb(255, 248, 219);
|
|
91
|
+
color: rgb(117, 82, 0);
|
|
92
|
+
border-color: rgb(181, 129, 5);
|
|
93
|
+
}
|
|
94
|
+
.notice.success {
|
|
95
|
+
background-color: rgb(229, 248, 230);
|
|
96
|
+
color: rgb(0, 100, 0);
|
|
97
|
+
border-color: rgb(30, 188, 47);
|
|
98
|
+
}
|
|
99
|
+
.notice.error {
|
|
100
|
+
background-color: rgb(255, 232, 230);
|
|
101
|
+
color: rgb(100, 0, 0);
|
|
102
|
+
border-color: rgb(218, 40, 40);
|
|
103
|
+
}
|
|
104
|
+
.notice.xl {
|
|
105
|
+
width: 60rem;
|
|
106
|
+
}
|
|
107
|
+
.notice.lg {
|
|
108
|
+
width: 40rem;
|
|
109
|
+
}
|
|
110
|
+
.notice.lg .icon {
|
|
111
|
+
width: 2.5rem;
|
|
112
|
+
min-width: 2.5rem;
|
|
113
|
+
}
|
|
114
|
+
.notice.lg .content {
|
|
115
|
+
font-size: 0.95rem;
|
|
116
|
+
}
|
|
117
|
+
.notice.md {
|
|
118
|
+
width: 25rem;
|
|
119
|
+
border-width: 1px;
|
|
120
|
+
border-radius: 3px;
|
|
121
|
+
}
|
|
122
|
+
.notice.md .icon {
|
|
123
|
+
width: 2rem;
|
|
124
|
+
min-width: 2rem;
|
|
125
|
+
}
|
|
126
|
+
.notice.md .content {
|
|
127
|
+
font-size: 0.85rem;
|
|
128
|
+
}
|
|
129
|
+
.notice.sm {
|
|
130
|
+
width: 15rem;
|
|
131
|
+
border-width: 1px;
|
|
132
|
+
border-radius: 2px;
|
|
133
|
+
}
|
|
134
|
+
.notice.sm .icon {
|
|
135
|
+
width: 1.5rem;
|
|
136
|
+
min-width: 1.5rem;
|
|
137
|
+
}
|
|
138
|
+
.notice.sm .content {
|
|
139
|
+
font-size: 0.75rem;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
button {
|
|
143
|
+
appearance: none;
|
|
144
|
+
border: none;
|
|
145
|
+
background-color: transparent;
|
|
146
|
+
font-size: 1rem;
|
|
147
|
+
cursor: pointer;
|
|
148
|
+
position: absolute;
|
|
149
|
+
top: 0.4rem;
|
|
150
|
+
right: 0.4rem;
|
|
151
|
+
width: 1rem;
|
|
152
|
+
height: 1rem;
|
|
153
|
+
line-height: 1rem;
|
|
154
|
+
text-align: center;
|
|
155
|
+
border-radius: 0.5rem;
|
|
156
|
+
}
|
|
157
|
+
button:hover {
|
|
158
|
+
font-weight: bold;
|
|
159
|
+
}</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
title?: string | undefined;
|
|
5
|
+
style?: ("outline" | "attention" | "success" | "error" | "info") | undefined;
|
|
6
|
+
size?: ("sm" | "md" | "lg" | "xl" | "full") | undefined;
|
|
7
|
+
dismissable?: boolean | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
dismiss: CustomEvent<void>;
|
|
11
|
+
hidden: CustomEvent<void>;
|
|
12
|
+
} & {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {
|
|
16
|
+
icon: {};
|
|
17
|
+
default: {};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type NoticeProps = typeof __propDef.props;
|
|
21
|
+
export type NoticeEvents = typeof __propDef.events;
|
|
22
|
+
export type NoticeSlots = typeof __propDef.slots;
|
|
23
|
+
export default class Notice extends SvelteComponent<NoticeProps, NoticeEvents, NoticeSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -10,3 +10,9 @@ export const roundToDecimals = (value, decimals) => {
|
|
|
10
10
|
return Math.round(value);
|
|
11
11
|
return Number(Math.round(Number(`${value}e${decimals}`)) + `e-${decimals}`);
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Format a number to a string with a specific number of decimals
|
|
15
|
+
*/
|
|
16
|
+
export const formatNumber = (value, decimals) => {
|
|
17
|
+
return roundToDecimals(value, decimals).toLocaleString();
|
|
18
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export { default as Panel } from './generic/panel/panel.svelte';
|
|
|
34
34
|
export { default as Section } from './generic/section/section.svelte';
|
|
35
35
|
export { default as Header } from './generic/header/header.svelte';
|
|
36
36
|
export { default as Dot } from './generic/dot/dot.svelte';
|
|
37
|
+
export { default as Notice } from './generic/notice/notice.svelte';
|
|
37
38
|
export { default as FlexCol } from './layout/flex-col.svelte';
|
|
38
39
|
export { default as FlexRow } from './layout/flex-row.svelte';
|
|
39
40
|
export { default as FlexItem } from './layout/flex-item.svelte';
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ export { default as Panel } from './generic/panel/panel.svelte';
|
|
|
36
36
|
export { default as Section } from './generic/section/section.svelte';
|
|
37
37
|
export { default as Header } from './generic/header/header.svelte';
|
|
38
38
|
export { default as Dot } from './generic/dot/dot.svelte';
|
|
39
|
+
export { default as Notice } from './generic/notice/notice.svelte';
|
|
39
40
|
// Layout
|
|
40
41
|
export { default as FlexCol } from './layout/flex-col.svelte';
|
|
41
42
|
export { default as FlexRow } from './layout/flex-row.svelte';
|