compote-ui 0.64.1 → 0.65.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/components/progress/progress-circular.svelte +58 -0
- package/dist/components/progress/progress-circular.svelte.d.ts +4 -0
- package/dist/components/progress/progress-linear.svelte +51 -0
- package/dist/components/progress/progress-linear.svelte.d.ts +4 -0
- package/dist/components/progress/types.d.ts +23 -0
- package/dist/components/progress/types.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/theme.css +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Progress } from '@ark-ui/svelte/progress';
|
|
3
|
+
import type { ProgressCircularProps, ProgressSize, ProgressVariant } from './types';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
value = $bindable(),
|
|
7
|
+
label,
|
|
8
|
+
showValueText = false,
|
|
9
|
+
size = 'md',
|
|
10
|
+
thickness,
|
|
11
|
+
variant = 'primary',
|
|
12
|
+
class: className,
|
|
13
|
+
...rootProps
|
|
14
|
+
}: ProgressCircularProps = $props();
|
|
15
|
+
|
|
16
|
+
const sizeMap: Record<ProgressSize, number> = {
|
|
17
|
+
sm: 40,
|
|
18
|
+
md: 64,
|
|
19
|
+
lg: 96
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const px = $derived(typeof size === 'number' ? size : sizeMap[size]);
|
|
23
|
+
const stroke = $derived(thickness ?? Math.max(3, Math.round(px / 10)));
|
|
24
|
+
|
|
25
|
+
const strokeColor: Record<ProgressVariant, string> = {
|
|
26
|
+
primary: 'stroke-primary',
|
|
27
|
+
success: 'stroke-success',
|
|
28
|
+
danger: 'stroke-danger',
|
|
29
|
+
warning: 'stroke-warning',
|
|
30
|
+
info: 'stroke-info'
|
|
31
|
+
};
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<Progress.Root bind:value {...rootProps} class={className}>
|
|
35
|
+
<div class="inline-flex flex-col items-center gap-2">
|
|
36
|
+
<div class="relative inline-flex items-center justify-center">
|
|
37
|
+
<Progress.Circle
|
|
38
|
+
class="data-[state=indeterminate]:animate-spin"
|
|
39
|
+
style="--size: {px}px; --thickness: {stroke}px"
|
|
40
|
+
>
|
|
41
|
+
<Progress.CircleTrack class="stroke-surface-3" />
|
|
42
|
+
<Progress.CircleRange
|
|
43
|
+
class={[
|
|
44
|
+
'transition-[stroke-dashoffset] duration-300 ease-out',
|
|
45
|
+
'data-[state=indeterminate]:[stroke-dasharray:calc(var(--circumference)*0.25)_var(--circumference)]! data-[state=indeterminate]:[stroke-dashoffset:0]!',
|
|
46
|
+
strokeColor[variant]
|
|
47
|
+
]}
|
|
48
|
+
/>
|
|
49
|
+
</Progress.Circle>
|
|
50
|
+
{#if showValueText}
|
|
51
|
+
<Progress.ValueText class="absolute text-sm font-medium tabular-nums text-ink" />
|
|
52
|
+
{/if}
|
|
53
|
+
</div>
|
|
54
|
+
{#if label}
|
|
55
|
+
<Progress.Label class="text-sm font-medium text-ink">{label}</Progress.Label>
|
|
56
|
+
{/if}
|
|
57
|
+
</div>
|
|
58
|
+
</Progress.Root>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Progress } from '@ark-ui/svelte/progress';
|
|
3
|
+
import { cn } from 'tailwind-variants';
|
|
4
|
+
import type { ProgressLinearProps, ProgressSize, ProgressVariant } from './types';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
value = $bindable(),
|
|
8
|
+
label,
|
|
9
|
+
showValueText = false,
|
|
10
|
+
size = 'md',
|
|
11
|
+
variant = 'primary',
|
|
12
|
+
class: className,
|
|
13
|
+
...rootProps
|
|
14
|
+
}: ProgressLinearProps = $props();
|
|
15
|
+
|
|
16
|
+
const trackHeight: Record<ProgressSize, string> = {
|
|
17
|
+
sm: 'h-1',
|
|
18
|
+
md: 'h-2',
|
|
19
|
+
lg: 'h-3'
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const rangeColor: Record<ProgressVariant, string> = {
|
|
23
|
+
primary: 'bg-primary',
|
|
24
|
+
success: 'bg-success',
|
|
25
|
+
danger: 'bg-danger',
|
|
26
|
+
warning: 'bg-warning',
|
|
27
|
+
info: 'bg-info'
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<Progress.Root bind:value {...rootProps} class={cn('flex w-full flex-col gap-1.5', className)}>
|
|
32
|
+
{#if label || showValueText}
|
|
33
|
+
<div class="flex items-center justify-between gap-2">
|
|
34
|
+
{#if label}
|
|
35
|
+
<Progress.Label class="text-sm font-medium text-ink">{label}</Progress.Label>
|
|
36
|
+
{/if}
|
|
37
|
+
{#if showValueText}
|
|
38
|
+
<Progress.ValueText class="text-sm tabular-nums text-ink-dim" />
|
|
39
|
+
{/if}
|
|
40
|
+
</div>
|
|
41
|
+
{/if}
|
|
42
|
+
<Progress.Track class={cn('w-full overflow-hidden rounded-full bg-surface-3', trackHeight[size])}>
|
|
43
|
+
<Progress.Range
|
|
44
|
+
class={cn(
|
|
45
|
+
'h-full rounded-full transition-[width] duration-300 ease-out',
|
|
46
|
+
'data-[state=indeterminate]:w-2/5 data-[state=indeterminate]:animate-[compote-progress-indeterminate_1.2s_ease-in-out_infinite]',
|
|
47
|
+
rangeColor[variant]
|
|
48
|
+
)}
|
|
49
|
+
/>
|
|
50
|
+
</Progress.Track>
|
|
51
|
+
</Progress.Root>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ProgressRootBaseProps } from '@ark-ui/svelte/progress';
|
|
2
|
+
export type ProgressSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
export type ProgressVariant = 'primary' | 'success' | 'danger' | 'warning' | 'info';
|
|
4
|
+
interface ProgressSharedProps extends ProgressRootBaseProps {
|
|
5
|
+
/** Optional label rendered above the progress indicator. */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Render the formatted value text (e.g. `50%`). */
|
|
8
|
+
showValueText?: boolean;
|
|
9
|
+
/** Color of the filled range. */
|
|
10
|
+
variant?: ProgressVariant;
|
|
11
|
+
class?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ProgressLinearProps extends ProgressSharedProps {
|
|
14
|
+
/** Thickness of the track. */
|
|
15
|
+
size?: ProgressSize;
|
|
16
|
+
}
|
|
17
|
+
export interface ProgressCircularProps extends ProgressSharedProps {
|
|
18
|
+
/** Diameter of the ring in pixels. */
|
|
19
|
+
size?: ProgressSize | number;
|
|
20
|
+
/** Stroke width of the ring in pixels. */
|
|
21
|
+
thickness?: number;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,9 @@ export type { PasswordInputProps } from './components/password-input/types';
|
|
|
45
45
|
export { default as PhoneInput } from './components/phone-input/phone-input.svelte';
|
|
46
46
|
export type { PhoneInputProps } from './components/phone-input/types';
|
|
47
47
|
export * as Popover from './components/popover';
|
|
48
|
+
export { default as ProgressLinear } from './components/progress/progress-linear.svelte';
|
|
49
|
+
export { default as ProgressCircular } from './components/progress/progress-circular.svelte';
|
|
50
|
+
export type { ProgressLinearProps, ProgressCircularProps, ProgressSize, ProgressVariant } from './components/progress/types';
|
|
48
51
|
export { default as QrCode } from './components/qr-code/qr-code.svelte';
|
|
49
52
|
export { default as Select } from './components/select/select.svelte';
|
|
50
53
|
export { default as Splitter } from './components/splitter/splitter.svelte';
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,8 @@ export { default as NumberInput } from './components/number-input/number-input.s
|
|
|
32
32
|
export { default as PasswordInput } from './components/password-input/password-input.svelte';
|
|
33
33
|
export { default as PhoneInput } from './components/phone-input/phone-input.svelte';
|
|
34
34
|
export * as Popover from './components/popover';
|
|
35
|
+
export { default as ProgressLinear } from './components/progress/progress-linear.svelte';
|
|
36
|
+
export { default as ProgressCircular } from './components/progress/progress-circular.svelte';
|
|
35
37
|
export { default as QrCode } from './components/qr-code/qr-code.svelte';
|
|
36
38
|
export { default as Select } from './components/select/select.svelte';
|
|
37
39
|
export { default as Splitter } from './components/splitter/splitter.svelte';
|
package/dist/theme.css
CHANGED