reburn-ui 0.1.8 → 0.2.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/dist/core/Notifications/NotificationContainer.svelte +56 -0
- package/dist/core/Notifications/NotificationContainer.svelte.d.ts +10 -0
- package/dist/core/Notifications/Notifications.svelte +156 -0
- package/dist/core/Notifications/Notifications.svelte.d.ts +28 -0
- package/dist/core/Notifications/NotificationsStore.svelte.d.ts +46 -0
- package/dist/core/Notifications/NotificationsStore.svelte.js +71 -0
- package/dist/core/Notifications/get-auto-close.d.ts +1 -0
- package/dist/core/Notifications/get-auto-close.js +9 -0
- package/dist/core/Notifications/notificationStackAnimation.d.ts +5 -0
- package/dist/core/Notifications/notificationStackAnimation.js +11 -0
- package/dist/core/components/CloseButton/CloseButton.svelte +6 -1
- package/dist/core/components/Floating/CreateFloating.svelte.d.ts +27 -0
- package/dist/core/components/Floating/CreateFloating.svelte.js +47 -0
- package/dist/core/components/Notification/Notification.svelte +216 -0
- package/dist/core/components/Notification/Notification.svelte.d.ts +33 -0
- package/dist/core/components/Popover/Popover.svelte +18 -24
- package/dist/core/components/Portal/Portal.svelte +8 -4
- package/dist/core/components/Progress/Progress.svelte +28 -0
- package/dist/core/components/Progress/Progress.svelte.d.ts +15 -0
- package/dist/core/components/Progress/ProgressContext.svelte.d.ts +8 -0
- package/dist/core/components/Progress/ProgressContext.svelte.js +12 -0
- package/dist/core/components/Progress/ProgressLabel.svelte +25 -0
- package/dist/core/components/Progress/ProgressLabel.svelte.d.ts +6 -0
- package/dist/core/components/Progress/ProgressRoot.svelte +72 -0
- package/dist/core/components/Progress/ProgressRoot.svelte.d.ts +17 -0
- package/dist/core/components/Progress/ProgressSection.svelte +83 -0
- package/dist/core/components/Progress/ProgressSection.svelte.d.ts +17 -0
- package/dist/core/components/Progress/index.d.ts +12 -0
- package/dist/core/components/Progress/index.js +9 -0
- package/dist/core/components/Tooltip/CreateTooltip.svelte.d.ts +20 -0
- package/dist/core/components/Tooltip/CreateTooltip.svelte.js +19 -0
- package/dist/core/components/Tooltip/Tooltip.svelte +235 -0
- package/dist/core/components/Tooltip/Tooltip.svelte.d.ts +46 -0
- package/dist/core/components/Tooltip/Tooltip.types.d.ts +47 -0
- package/dist/core/components/Tooltip/Tooltip.types.js +1 -0
- package/dist/core/components/Tooltip/getTooltipMiddleware.d.ts +15 -0
- package/dist/core/components/Tooltip/getTooltipMiddleware.js +32 -0
- package/dist/core/components/index.d.ts +3 -0
- package/dist/core/components/index.js +3 -0
- package/dist/tools/icon-vite-plugin/utils/generateIconComponent.js +1 -2
- package/package.json +9 -9
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { DivElement } from '../../element-types.js';
|
|
3
|
+
import { getThemeColor } from '../../MantineProvider/index.js';
|
|
4
|
+
import type { MantineColor, MantineRadius } from '../../MantineProvider/theme.types.js';
|
|
5
|
+
import { getRadius } from '../../utils/get-size.js';
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
import type { CloseButtonProps } from '../CloseButton/CloseButton.svelte';
|
|
8
|
+
import CloseButton from '../CloseButton/CloseButton.svelte';
|
|
9
|
+
import type { LoaderProps } from '../Loader/Loader.svelte';
|
|
10
|
+
import Loader from '../Loader/Loader.svelte';
|
|
11
|
+
|
|
12
|
+
export interface NotificationProps extends Omit<DivElement, 'title'> {
|
|
13
|
+
variant?: string;
|
|
14
|
+
|
|
15
|
+
/** Called when close button is clicked */
|
|
16
|
+
onclose?: () => void;
|
|
17
|
+
|
|
18
|
+
/** Controls notification line or icon color, key of `theme.colors` or any valid CSS color, `theme.primaryColor` by default */
|
|
19
|
+
color?: MantineColor;
|
|
20
|
+
|
|
21
|
+
/** Key of `theme.radius` or any valid CSS value to set `border-radius`, `theme.defaultRadius` by default */
|
|
22
|
+
radius?: MantineRadius;
|
|
23
|
+
|
|
24
|
+
/** Notification icon, replaces color line */
|
|
25
|
+
icon?: Snippet;
|
|
26
|
+
|
|
27
|
+
/** Notification title, displayed before body */
|
|
28
|
+
title?: string;
|
|
29
|
+
|
|
30
|
+
/** Notification body, place main text here */
|
|
31
|
+
children?: Snippet;
|
|
32
|
+
|
|
33
|
+
/** Replaces colored line or icon with Loader component */
|
|
34
|
+
loading?: boolean;
|
|
35
|
+
|
|
36
|
+
/** Determines whether notification should have a border, `false` by default */
|
|
37
|
+
withBorder?: boolean;
|
|
38
|
+
|
|
39
|
+
/** Determines whether close button should be visible, `true` by default */
|
|
40
|
+
withCloseButton?: boolean;
|
|
41
|
+
|
|
42
|
+
/** Props passed down to the close button */
|
|
43
|
+
closeButtonProps?: CloseButtonProps;
|
|
44
|
+
|
|
45
|
+
/** Props passed down to `Loader` component */
|
|
46
|
+
loaderProps?: LoaderProps;
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<script lang="ts">
|
|
51
|
+
let {
|
|
52
|
+
children,
|
|
53
|
+
title,
|
|
54
|
+
icon,
|
|
55
|
+
loading,
|
|
56
|
+
role = 'alert',
|
|
57
|
+
radius,
|
|
58
|
+
color,
|
|
59
|
+
withBorder,
|
|
60
|
+
loaderProps,
|
|
61
|
+
withCloseButton = true,
|
|
62
|
+
onclose,
|
|
63
|
+
closeButtonProps,
|
|
64
|
+
...props
|
|
65
|
+
}: NotificationProps = $props();
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<div
|
|
69
|
+
{...props}
|
|
70
|
+
class={['root', props.class]}
|
|
71
|
+
style:--notification-radius={radius ? getRadius(radius) : undefined}
|
|
72
|
+
style:--notification-color={color ? getThemeColor(color) : undefined}
|
|
73
|
+
data-with-icon={Boolean(icon) || undefined}
|
|
74
|
+
data-with-border={withBorder || undefined}
|
|
75
|
+
{role}
|
|
76
|
+
>
|
|
77
|
+
{#if icon && !loading}
|
|
78
|
+
<div class="icon">
|
|
79
|
+
{@render icon?.()}
|
|
80
|
+
</div>
|
|
81
|
+
{/if}
|
|
82
|
+
|
|
83
|
+
{#if loading}
|
|
84
|
+
<Loader size={28} {color} {...loaderProps} class="loader" />
|
|
85
|
+
{/if}
|
|
86
|
+
|
|
87
|
+
<div class="body">
|
|
88
|
+
{#if title}
|
|
89
|
+
<div class="title">{title}</div>
|
|
90
|
+
{/if}
|
|
91
|
+
|
|
92
|
+
<div class="description" data-with-title={Boolean(title) || undefined}>
|
|
93
|
+
{@render children?.()}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
{#if withCloseButton}
|
|
98
|
+
<CloseButton iconSize={16} color="gray" {...closeButtonProps} onclick={onclose} class={['close-button', closeButtonProps?.class]} />
|
|
99
|
+
{/if}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<style>.root {
|
|
103
|
+
--notification-radius: var(--mantine-radius-default);
|
|
104
|
+
--notification-color: var(--mantine-primary-color-filled);
|
|
105
|
+
overflow: hidden;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
position: relative;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
padding-inline-start: calc(1.375rem * var(--mantine-scale));
|
|
111
|
+
padding-inline-end: var(--mantine-spacing-xs);
|
|
112
|
+
padding-top: var(--mantine-spacing-xs);
|
|
113
|
+
padding-bottom: var(--mantine-spacing-xs);
|
|
114
|
+
border-radius: var(--notification-radius);
|
|
115
|
+
box-shadow: var(--mantine-shadow-lg);
|
|
116
|
+
}
|
|
117
|
+
.root::before {
|
|
118
|
+
content: "";
|
|
119
|
+
display: block;
|
|
120
|
+
position: absolute;
|
|
121
|
+
width: calc(0.375rem * var(--mantine-scale));
|
|
122
|
+
top: var(--notification-radius);
|
|
123
|
+
bottom: var(--notification-radius);
|
|
124
|
+
inset-inline-start: calc(0.25rem * var(--mantine-scale));
|
|
125
|
+
border-radius: var(--notification-radius);
|
|
126
|
+
background-color: var(--notification-color);
|
|
127
|
+
}
|
|
128
|
+
:global(:where([data-mantine-color-scheme="light"])) .root {
|
|
129
|
+
background-color: var(--mantine-color-white);
|
|
130
|
+
}
|
|
131
|
+
:global(:where([data-mantine-color-scheme="dark"])) .root {
|
|
132
|
+
background-color: var(--mantine-color-dark-6);
|
|
133
|
+
}
|
|
134
|
+
.root:where([data-with-icon])::before {
|
|
135
|
+
display: none;
|
|
136
|
+
}
|
|
137
|
+
:global(:where([data-mantine-color-scheme="light"])) .root:where([data-with-border]) {
|
|
138
|
+
border: 1px solid var(--mantine-color-gray-3);
|
|
139
|
+
}
|
|
140
|
+
:global(:where([data-mantine-color-scheme="dark"])) .root:where([data-with-border]) {
|
|
141
|
+
border: 1px solid var(--mantine-color-dark-4);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.icon {
|
|
145
|
+
box-sizing: border-box;
|
|
146
|
+
margin-inline-end: var(--mantine-spacing-md);
|
|
147
|
+
width: calc(1.75rem * var(--mantine-scale));
|
|
148
|
+
height: calc(1.75rem * var(--mantine-scale));
|
|
149
|
+
border-radius: calc(1.75rem * var(--mantine-scale));
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
background-color: var(--notification-color);
|
|
154
|
+
color: var(--mantine-color-white);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
* :global(.loader) {
|
|
158
|
+
margin-inline-end: var(--mantine-spacing-md);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.body {
|
|
162
|
+
flex: 1;
|
|
163
|
+
overflow: hidden;
|
|
164
|
+
margin-inline-end: var(--mantine-spacing-xs);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.title {
|
|
168
|
+
margin-bottom: calc(0.125rem * var(--mantine-scale));
|
|
169
|
+
overflow: hidden;
|
|
170
|
+
text-overflow: ellipsis;
|
|
171
|
+
font-size: var(--mantine-font-size-sm);
|
|
172
|
+
line-height: var(--mantine-line-height-sm);
|
|
173
|
+
font-weight: 500;
|
|
174
|
+
}
|
|
175
|
+
:global(:where([data-mantine-color-scheme="light"])) .title {
|
|
176
|
+
color: var(--mantine-color-gray-9);
|
|
177
|
+
}
|
|
178
|
+
:global(:where([data-mantine-color-scheme="dark"])) .title {
|
|
179
|
+
color: var(--mantine-color-white);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.description {
|
|
183
|
+
font-size: var(--mantine-font-size-sm);
|
|
184
|
+
line-height: var(--mantine-line-height-sm);
|
|
185
|
+
overflow: hidden;
|
|
186
|
+
text-overflow: ellipsis;
|
|
187
|
+
}
|
|
188
|
+
:global(:where([data-mantine-color-scheme="light"])) .description {
|
|
189
|
+
color: var(--mantine-color-black);
|
|
190
|
+
}
|
|
191
|
+
:global(:where([data-mantine-color-scheme="dark"])) .description {
|
|
192
|
+
color: var(--mantine-color-dark-0);
|
|
193
|
+
}
|
|
194
|
+
:global(:where([data-mantine-color-scheme="light"])) .description:where([data-with-title]) {
|
|
195
|
+
color: var(--mantine-color-gray-6);
|
|
196
|
+
}
|
|
197
|
+
:global(:where([data-mantine-color-scheme="dark"])) .description:where([data-with-title]) {
|
|
198
|
+
color: var(--mantine-color-dark-2);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@media (hover: hover) {
|
|
202
|
+
:global(:where([data-mantine-color-scheme="light"])) * :global(.close-button):hover {
|
|
203
|
+
background-color: var(--mantine-color-gray-0);
|
|
204
|
+
}
|
|
205
|
+
:global(:where([data-mantine-color-scheme="dark"])) * :global(.close-button):hover {
|
|
206
|
+
background-color: var(--mantine-color-dark-8);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
@media (hover: none) {
|
|
210
|
+
:global(:where([data-mantine-color-scheme="light"])) * :global(.close-button):active {
|
|
211
|
+
background-color: var(--mantine-color-gray-0);
|
|
212
|
+
}
|
|
213
|
+
:global(:where([data-mantine-color-scheme="dark"])) * :global(.close-button):active {
|
|
214
|
+
background-color: var(--mantine-color-dark-8);
|
|
215
|
+
}
|
|
216
|
+
}</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DivElement } from '../../element-types.js';
|
|
2
|
+
import type { MantineColor, MantineRadius } from '../../MantineProvider/theme.types.js';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { CloseButtonProps } from '../CloseButton/CloseButton.svelte';
|
|
5
|
+
import type { LoaderProps } from '../Loader/Loader.svelte';
|
|
6
|
+
export interface NotificationProps extends Omit<DivElement, 'title'> {
|
|
7
|
+
variant?: string;
|
|
8
|
+
/** Called when close button is clicked */
|
|
9
|
+
onclose?: () => void;
|
|
10
|
+
/** Controls notification line or icon color, key of `theme.colors` or any valid CSS color, `theme.primaryColor` by default */
|
|
11
|
+
color?: MantineColor;
|
|
12
|
+
/** Key of `theme.radius` or any valid CSS value to set `border-radius`, `theme.defaultRadius` by default */
|
|
13
|
+
radius?: MantineRadius;
|
|
14
|
+
/** Notification icon, replaces color line */
|
|
15
|
+
icon?: Snippet;
|
|
16
|
+
/** Notification title, displayed before body */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Notification body, place main text here */
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
/** Replaces colored line or icon with Loader component */
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
/** Determines whether notification should have a border, `false` by default */
|
|
23
|
+
withBorder?: boolean;
|
|
24
|
+
/** Determines whether close button should be visible, `true` by default */
|
|
25
|
+
withCloseButton?: boolean;
|
|
26
|
+
/** Props passed down to the close button */
|
|
27
|
+
closeButtonProps?: CloseButtonProps;
|
|
28
|
+
/** Props passed down to `Loader` component */
|
|
29
|
+
loaderProps?: LoaderProps;
|
|
30
|
+
}
|
|
31
|
+
declare const Notification: import("svelte").Component<NotificationProps, {}, "">;
|
|
32
|
+
type Notification = ReturnType<typeof Notification>;
|
|
33
|
+
export default Notification;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { MantineRadius, MantineShadow } from '../../MantineProvider/theme.types.js';
|
|
3
3
|
import { ClickOutside, type ClickOutsideEvents } from '../../hooks/use-click-outside.svelte.js';
|
|
4
4
|
import { getDefaultZIndex } from '../../utils/get-default-z-index.js';
|
|
5
|
-
import {
|
|
5
|
+
import { type Middleware } from '@floating-ui/dom';
|
|
6
6
|
import { setContext, type Snippet } from 'svelte';
|
|
7
7
|
import type { ArrowPosition, FloatingAxesOffsets, FloatingPosition, FloatingStrategy } from '../Floating/types.js';
|
|
8
8
|
import Overlay, { type OverlayProps } from '../Overlay/Overlay.svelte';
|
|
@@ -144,6 +144,7 @@
|
|
|
144
144
|
<!-- TODO: implement keepMounted -->
|
|
145
145
|
|
|
146
146
|
<script lang="ts">
|
|
147
|
+
import { CreateFloating, type UpdatePositionProps } from '../Floating/CreateFloating.svelte.js';
|
|
147
148
|
import { POPOVER_CONTEXT_KEY, PopoverContext } from './PopoverContext.svelte.js';
|
|
148
149
|
|
|
149
150
|
let _id = $props.id();
|
|
@@ -241,31 +242,24 @@
|
|
|
241
242
|
);
|
|
242
243
|
});
|
|
243
244
|
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// TODO: see why this is needed
|
|
248
|
-
placement: preventPositionChangeWhenVisible ? positionRef! : position,
|
|
249
|
-
middleware: popoverMiddlewares,
|
|
250
|
-
}).then(({ x, y, middlewareData, placement }) => {
|
|
251
|
-
context.x = x;
|
|
252
|
-
context.y = y;
|
|
253
|
-
|
|
254
|
-
if (middlewareData.arrow) {
|
|
255
|
-
context.arrowX = middlewareData.arrow.x ?? 0;
|
|
256
|
-
context.arrowY = middlewareData.arrow.y ?? 0;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
onpositionchange?.(placement);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
$effect(() => {
|
|
264
|
-
if (!context.referenceElement || !context.floatingElement) return;
|
|
245
|
+
function handleUpdate({ x, y, middlewareData }: UpdatePositionProps) {
|
|
246
|
+
context.x = x;
|
|
247
|
+
context.y = y;
|
|
265
248
|
|
|
266
|
-
|
|
249
|
+
if (middlewareData.arrow) {
|
|
250
|
+
context.arrowX = middlewareData.arrow.x ?? 0;
|
|
251
|
+
context.arrowY = middlewareData.arrow.y ?? 0;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
267
254
|
|
|
268
|
-
|
|
255
|
+
new CreateFloating({
|
|
256
|
+
strategy: () => floatingStrategy,
|
|
257
|
+
placement: () => (preventPositionChangeWhenVisible ? positionRef! : position),
|
|
258
|
+
middleware: () => popoverMiddlewares,
|
|
259
|
+
onpositionchange: () => onpositionchange,
|
|
260
|
+
referenceElement: () => context.referenceElement,
|
|
261
|
+
floatingElement: () => context.floatingElement,
|
|
262
|
+
onupdate: () => handleUpdate,
|
|
269
263
|
});
|
|
270
264
|
|
|
271
265
|
function toggle() {
|
|
@@ -35,18 +35,22 @@
|
|
|
35
35
|
```
|
|
36
36
|
-->
|
|
37
37
|
<script lang="ts">
|
|
38
|
-
import { mount } from 'svelte';
|
|
38
|
+
import { mount, onDestroy, onMount, unmount } from 'svelte';
|
|
39
39
|
|
|
40
40
|
let { children, target }: PortalProps = $props();
|
|
41
41
|
|
|
42
|
-
let element
|
|
42
|
+
let element: ReturnType<typeof mount> | null = null;
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
onMount(() => {
|
|
45
45
|
element = mount(children, {
|
|
46
46
|
target: target ?? document.body,
|
|
47
47
|
intro: true,
|
|
48
48
|
});
|
|
49
|
+
});
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
onDestroy(() => {
|
|
52
|
+
if (element) {
|
|
53
|
+
unmount(element);
|
|
54
|
+
}
|
|
51
55
|
});
|
|
52
56
|
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { MantineColor } from '../../MantineProvider/theme.types.js';
|
|
3
|
+
import type { __ProgressRootProps } from './ProgressRoot.svelte';
|
|
4
|
+
import ProgressRoot from './ProgressRoot.svelte';
|
|
5
|
+
import ProgressSection from './ProgressSection.svelte';
|
|
6
|
+
|
|
7
|
+
export interface ProgressProps extends __ProgressRootProps {
|
|
8
|
+
/** Value of the progress */
|
|
9
|
+
value: number;
|
|
10
|
+
|
|
11
|
+
/** Key of `theme.colors` or any valid CSS value, `theme.primaryColor` by default */
|
|
12
|
+
color?: MantineColor;
|
|
13
|
+
|
|
14
|
+
/** Determines whether the section should have stripes, `false` by default */
|
|
15
|
+
striped?: boolean;
|
|
16
|
+
|
|
17
|
+
/** Determines whether the sections stripes should be animated, if set, `striped` prop is ignored, `false` by default */
|
|
18
|
+
animated?: boolean;
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
let { value, color, striped, animated, 'aria-label': label, ref = $bindable(), ...props }: ProgressProps = $props();
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<ProgressRoot bind:ref {...props}>
|
|
27
|
+
<ProgressSection {value} {color} {striped} {animated} aria-label={label} />
|
|
28
|
+
</ProgressRoot>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MantineColor } from '../../MantineProvider/theme.types.js';
|
|
2
|
+
import type { __ProgressRootProps } from './ProgressRoot.svelte';
|
|
3
|
+
export interface ProgressProps extends __ProgressRootProps {
|
|
4
|
+
/** Value of the progress */
|
|
5
|
+
value: number;
|
|
6
|
+
/** Key of `theme.colors` or any valid CSS value, `theme.primaryColor` by default */
|
|
7
|
+
color?: MantineColor;
|
|
8
|
+
/** Determines whether the section should have stripes, `false` by default */
|
|
9
|
+
striped?: boolean;
|
|
10
|
+
/** Determines whether the sections stripes should be animated, if set, `striped` prop is ignored, `false` by default */
|
|
11
|
+
animated?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const Progress: import("svelte").Component<ProgressProps, {}, "ref">;
|
|
14
|
+
type Progress = ReturnType<typeof Progress>;
|
|
15
|
+
export default Progress;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Getter } from '../../context/extract.js';
|
|
2
|
+
import type { __ProgressRootProps } from './ProgressRoot.svelte';
|
|
3
|
+
export declare const PROGRESS_CONTEXT_KEY: unique symbol;
|
|
4
|
+
export declare class ProgressContext {
|
|
5
|
+
autoContrast: boolean | undefined;
|
|
6
|
+
constructor(autoContrast: Getter<__ProgressRootProps['autoContrast']>);
|
|
7
|
+
}
|
|
8
|
+
export declare function getProgressContext(): ProgressContext;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { extract } from '../../context/extract.js';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
export const PROGRESS_CONTEXT_KEY = Symbol();
|
|
4
|
+
export class ProgressContext {
|
|
5
|
+
autoContrast;
|
|
6
|
+
constructor(autoContrast) {
|
|
7
|
+
this.autoContrast = $derived(extract(autoContrast));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function getProgressContext() {
|
|
11
|
+
return getContext(PROGRESS_CONTEXT_KEY);
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { DivElement } from '../../element-types.js';
|
|
3
|
+
|
|
4
|
+
export interface ProgressLabelProps extends DivElement {}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
let { children, ...props }: ProgressLabelProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div {...props} class={['label', props.class]}>
|
|
12
|
+
{@render children?.()}
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<style>.label {
|
|
16
|
+
color: var(--progress-label-color, var(--mantine-color-white));
|
|
17
|
+
font-weight: bold;
|
|
18
|
+
user-select: none;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
text-overflow: ellipsis;
|
|
22
|
+
font-size: min(var(--progress-size) * 0.65, 1.125rem * var(--mantine-scale));
|
|
23
|
+
line-height: 1;
|
|
24
|
+
padding-inline: calc(0.25rem * var(--mantine-scale));
|
|
25
|
+
}</style>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DivElement } from '../../element-types.js';
|
|
2
|
+
export interface ProgressLabelProps extends DivElement {
|
|
3
|
+
}
|
|
4
|
+
declare const ProgressLabel: import("svelte").Component<ProgressLabelProps, {}, "">;
|
|
5
|
+
type ProgressLabel = ReturnType<typeof ProgressLabel>;
|
|
6
|
+
export default ProgressLabel;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { DivElement } from '../../element-types.js';
|
|
3
|
+
import type { MantineRadius, MantineSize } from '../../MantineProvider/theme.types.js';
|
|
4
|
+
import { getRadius, getSize } from '../../utils/get-size.js';
|
|
5
|
+
import { setContext } from 'svelte';
|
|
6
|
+
import { PROGRESS_CONTEXT_KEY, ProgressContext } from './ProgressContext.svelte.js';
|
|
7
|
+
|
|
8
|
+
export interface __ProgressRootProps extends DivElement {
|
|
9
|
+
/** Controls track height, `'md'` by default */
|
|
10
|
+
size?: MantineSize | (string & {}) | number;
|
|
11
|
+
|
|
12
|
+
/** Key of `theme.radius` or any valid CSS value to set `border-radius`, `theme.defaultRadius` by default */
|
|
13
|
+
radius?: MantineRadius;
|
|
14
|
+
|
|
15
|
+
/** Determines whether label text color should depend on `background-color`. If luminosity of the `color` prop is less than `theme.luminosityThreshold`, then `theme.white` will be used for text color, otherwise `theme.black`. Overrides `theme.autoContrast`. */
|
|
16
|
+
autoContrast?: boolean;
|
|
17
|
+
|
|
18
|
+
/** Controls sections width transition duration, value is specified in ms, `100` by default */
|
|
19
|
+
transitionDuration?: number;
|
|
20
|
+
|
|
21
|
+
/** Ref to the root element */
|
|
22
|
+
ref?: HTMLElement;
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
let {
|
|
28
|
+
transitionDuration = 100,
|
|
29
|
+
size = 'md',
|
|
30
|
+
radius = 'md',
|
|
31
|
+
ref = $bindable(),
|
|
32
|
+
autoContrast = false,
|
|
33
|
+
children,
|
|
34
|
+
...props
|
|
35
|
+
}: __ProgressRootProps = $props();
|
|
36
|
+
|
|
37
|
+
const context = new ProgressContext(() => autoContrast);
|
|
38
|
+
|
|
39
|
+
setContext(PROGRESS_CONTEXT_KEY, context);
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<div
|
|
43
|
+
{...props}
|
|
44
|
+
bind:this={ref}
|
|
45
|
+
class={['root', props.class]}
|
|
46
|
+
style:--progress-size={getSize(size, 'progress-size')}
|
|
47
|
+
style:--progress-radius={radius ? getRadius(radius) : undefined}
|
|
48
|
+
style:--progress-transition-duration={typeof transitionDuration === 'number' ? `${transitionDuration}ms` : undefined}
|
|
49
|
+
>
|
|
50
|
+
{@render children?.()}
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<style>.root {
|
|
54
|
+
--progress-radius: var(--mantine-radius-default);
|
|
55
|
+
--progress-size: var(--progress-size-md);
|
|
56
|
+
--progress-size-xs: calc(0.1875rem * var(--mantine-scale));
|
|
57
|
+
--progress-size-sm: calc(0.3125rem * var(--mantine-scale));
|
|
58
|
+
--progress-size-md: calc(0.5rem * var(--mantine-scale));
|
|
59
|
+
--progress-size-lg: calc(0.75rem * var(--mantine-scale));
|
|
60
|
+
--progress-size-xl: calc(1rem * var(--mantine-scale));
|
|
61
|
+
position: relative;
|
|
62
|
+
height: var(--progress-size);
|
|
63
|
+
border-radius: var(--progress-radius);
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
display: flex;
|
|
66
|
+
}
|
|
67
|
+
:global(:where([data-mantine-color-scheme="light"])) .root {
|
|
68
|
+
background-color: var(--mantine-color-gray-2);
|
|
69
|
+
}
|
|
70
|
+
:global(:where([data-mantine-color-scheme="dark"])) .root {
|
|
71
|
+
background-color: var(--mantine-color-dark-4);
|
|
72
|
+
}</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DivElement } from '../../element-types.js';
|
|
2
|
+
import type { MantineRadius, MantineSize } from '../../MantineProvider/theme.types.js';
|
|
3
|
+
export interface __ProgressRootProps extends DivElement {
|
|
4
|
+
/** Controls track height, `'md'` by default */
|
|
5
|
+
size?: MantineSize | (string & {}) | number;
|
|
6
|
+
/** Key of `theme.radius` or any valid CSS value to set `border-radius`, `theme.defaultRadius` by default */
|
|
7
|
+
radius?: MantineRadius;
|
|
8
|
+
/** Determines whether label text color should depend on `background-color`. If luminosity of the `color` prop is less than `theme.luminosityThreshold`, then `theme.white` will be used for text color, otherwise `theme.black`. Overrides `theme.autoContrast`. */
|
|
9
|
+
autoContrast?: boolean;
|
|
10
|
+
/** Controls sections width transition duration, value is specified in ms, `100` by default */
|
|
11
|
+
transitionDuration?: number;
|
|
12
|
+
/** Ref to the root element */
|
|
13
|
+
ref?: HTMLElement;
|
|
14
|
+
}
|
|
15
|
+
declare const ProgressRoot: import("svelte").Component<__ProgressRootProps, {}, "ref">;
|
|
16
|
+
type ProgressRoot = ReturnType<typeof ProgressRoot>;
|
|
17
|
+
export default ProgressRoot;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { DivElement } from '../../element-types.js';
|
|
3
|
+
import type { MantineColor } from '../../MantineProvider/theme.types.js';
|
|
4
|
+
|
|
5
|
+
export interface ProgressSectionProps extends DivElement {
|
|
6
|
+
/** Value of the section in 0–100 range */
|
|
7
|
+
value: number;
|
|
8
|
+
|
|
9
|
+
/** Determines whether `aria-*` props should be added to the root element, `true` by default */
|
|
10
|
+
withAria?: boolean;
|
|
11
|
+
|
|
12
|
+
/** Key of `theme.colors` or any valid CSS value, `theme.primaryColor` by default */
|
|
13
|
+
color?: MantineColor;
|
|
14
|
+
|
|
15
|
+
/** Determines whether the section should have stripes, `false` by default */
|
|
16
|
+
striped?: boolean;
|
|
17
|
+
|
|
18
|
+
/** Determines whether the sections stripes should be animated, if set, `striped` prop is ignored, `false` by default */
|
|
19
|
+
animated?: boolean;
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<script lang="ts">
|
|
24
|
+
import { getAutoContrastValue, getContrastColor, getThemeColor } from '../../MantineProvider/index.js';
|
|
25
|
+
import { getProgressContext } from './ProgressContext.svelte.js';
|
|
26
|
+
|
|
27
|
+
let { value, withAria = true, color, striped, animated, children, ...props }: ProgressSectionProps = $props();
|
|
28
|
+
|
|
29
|
+
const ariaAttributes = $derived(
|
|
30
|
+
withAria
|
|
31
|
+
? {
|
|
32
|
+
role: 'progress',
|
|
33
|
+
'aria-valuemax': 100,
|
|
34
|
+
'aria-valuemin': 0,
|
|
35
|
+
'aria-valuenow': value,
|
|
36
|
+
'aria-valuetext': `${value}%`,
|
|
37
|
+
}
|
|
38
|
+
: {}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const ctx = getProgressContext();
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<div
|
|
45
|
+
{...props}
|
|
46
|
+
{...ariaAttributes}
|
|
47
|
+
class={['section', props.class]}
|
|
48
|
+
data-striped={striped || animated || undefined}
|
|
49
|
+
data-animated={animated || undefined}
|
|
50
|
+
style:--progress-section-width="{value}%"
|
|
51
|
+
style:--progress-section-color={getThemeColor(color)}
|
|
52
|
+
style:--progress-label-color={getAutoContrastValue(ctx.autoContrast) ? getContrastColor({ color, autoContrast: ctx.autoContrast }) : undefined}
|
|
53
|
+
>
|
|
54
|
+
{@render children?.()}
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<style>.section {
|
|
58
|
+
background-color: var(--progress-section-color);
|
|
59
|
+
height: 100%;
|
|
60
|
+
width: var(--progress-section-width);
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
background-size: calc(1.25rem * var(--mantine-scale)) calc(1.25rem * var(--mantine-scale));
|
|
66
|
+
transition: width var(--progress-transition-duration, 100ms) ease;
|
|
67
|
+
}
|
|
68
|
+
.section:where([data-striped]) {
|
|
69
|
+
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
|
|
70
|
+
}
|
|
71
|
+
.section:where([data-animated]) {
|
|
72
|
+
animation: stripes-animation 1s linear infinite;
|
|
73
|
+
}
|
|
74
|
+
.section:where(:last-of-type) {
|
|
75
|
+
border-radius: 0;
|
|
76
|
+
border-start-end-radius: var(--progress-radius);
|
|
77
|
+
border-end-end-radius: var(--progress-radius);
|
|
78
|
+
}
|
|
79
|
+
.section:where(:first-of-type) {
|
|
80
|
+
border-radius: 0;
|
|
81
|
+
border-start-start-radius: var(--progress-radius);
|
|
82
|
+
border-end-start-radius: var(--progress-radius);
|
|
83
|
+
}</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DivElement } from '../../element-types.js';
|
|
2
|
+
import type { MantineColor } from '../../MantineProvider/theme.types.js';
|
|
3
|
+
export interface ProgressSectionProps extends DivElement {
|
|
4
|
+
/** Value of the section in 0–100 range */
|
|
5
|
+
value: number;
|
|
6
|
+
/** Determines whether `aria-*` props should be added to the root element, `true` by default */
|
|
7
|
+
withAria?: boolean;
|
|
8
|
+
/** Key of `theme.colors` or any valid CSS value, `theme.primaryColor` by default */
|
|
9
|
+
color?: MantineColor;
|
|
10
|
+
/** Determines whether the section should have stripes, `false` by default */
|
|
11
|
+
striped?: boolean;
|
|
12
|
+
/** Determines whether the sections stripes should be animated, if set, `striped` prop is ignored, `false` by default */
|
|
13
|
+
animated?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const ProgressSection: import("svelte").Component<ProgressSectionProps, {}, "">;
|
|
16
|
+
type ProgressSection = ReturnType<typeof ProgressSection>;
|
|
17
|
+
export default ProgressSection;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ProgressComponent from './Progress.svelte';
|
|
2
|
+
import ProgressLabel from './ProgressLabel.svelte';
|
|
3
|
+
import ProgressRoot from './ProgressRoot.svelte';
|
|
4
|
+
import ProgressSection from './ProgressSection.svelte';
|
|
5
|
+
type Progress = typeof ProgressComponent;
|
|
6
|
+
interface ExtendedProgress extends Progress {
|
|
7
|
+
Section: typeof ProgressSection;
|
|
8
|
+
Root: typeof ProgressRoot;
|
|
9
|
+
Label: typeof ProgressLabel;
|
|
10
|
+
}
|
|
11
|
+
declare const Progress: ExtendedProgress;
|
|
12
|
+
export default Progress;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ProgressComponent from './Progress.svelte';
|
|
2
|
+
import ProgressLabel from './ProgressLabel.svelte';
|
|
3
|
+
import ProgressRoot from './ProgressRoot.svelte';
|
|
4
|
+
import ProgressSection from './ProgressSection.svelte';
|
|
5
|
+
const Progress = ProgressComponent;
|
|
6
|
+
Progress.Section = ProgressSection;
|
|
7
|
+
Progress.Root = ProgressRoot;
|
|
8
|
+
Progress.Label = ProgressLabel;
|
|
9
|
+
export default Progress;
|