@rise-x/apps-sdk 0.8.0 → 0.11.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 +209 -21
- package/build/rsbuild/index.d.ts +36 -0
- package/build/rsbuild/index.js +225 -0
- package/build/ui/classes.json +209 -0
- package/build/ui/components/ai.d.ts +33 -1
- package/build/ui/components/app-frame.d.ts +19 -0
- package/build/ui/components/chat-input.d.ts +28 -0
- package/build/ui/components/message-scroller.d.ts +34 -10
- package/build/ui/components/nav.d.ts +2 -1
- package/build/ui/components/sheet.d.ts +10 -0
- package/build/ui/components/thinking-rings.d.ts +4 -0
- package/build/ui/demo.html +26794 -0
- package/build/ui/index.d.ts +3 -0
- package/build/ui/standalone.js +59 -58
- package/build/ui/styles.css +1 -1
- package/package.json +24 -3
- package/rsbuild/package.json +8 -0
- package/template/AGENTS.md +18 -10
- package/template/README.md +5 -5
- package/template/package.json +8 -9
- package/template/rsbuild.config.mts +17 -0
- package/template/src/App.tsx +21 -11
- package/template/tsconfig.json +3 -1
- package/build/ui/reference/README.md +0 -11
- package/build/ui/reference/components/accordion.tsx +0 -85
- package/build/ui/reference/components/ai.tsx +0 -291
- package/build/ui/reference/components/alert-dialog.tsx +0 -213
- package/build/ui/reference/components/alert.tsx +0 -112
- package/build/ui/reference/components/aspect-ratio.tsx +0 -28
- package/build/ui/reference/components/avatar.tsx +0 -158
- package/build/ui/reference/components/badge.tsx +0 -160
- package/build/ui/reference/components/button-group.tsx +0 -77
- package/build/ui/reference/components/button.tsx +0 -107
- package/build/ui/reference/components/calendar.tsx +0 -119
- package/build/ui/reference/components/card.tsx +0 -144
- package/build/ui/reference/components/carousel.tsx +0 -248
- package/build/ui/reference/components/chart.tsx +0 -704
- package/build/ui/reference/components/checkbox.tsx +0 -44
- package/build/ui/reference/components/collapsible.tsx +0 -43
- package/build/ui/reference/components/combobox.tsx +0 -141
- package/build/ui/reference/components/command.tsx +0 -181
- package/build/ui/reference/components/context-menu.tsx +0 -243
- package/build/ui/reference/components/data-table.tsx +0 -650
- package/build/ui/reference/components/date-picker.tsx +0 -218
- package/build/ui/reference/components/dialog.tsx +0 -172
- package/build/ui/reference/components/direction.tsx +0 -22
- package/build/ui/reference/components/dropdown-menu.tsx +0 -245
- package/build/ui/reference/components/empty-state.tsx +0 -63
- package/build/ui/reference/components/field.tsx +0 -252
- package/build/ui/reference/components/file-upload.tsx +0 -116
- package/build/ui/reference/components/hover-card.tsx +0 -64
- package/build/ui/reference/components/input-group.tsx +0 -157
- package/build/ui/reference/components/input-otp.tsx +0 -106
- package/build/ui/reference/components/input.tsx +0 -86
- package/build/ui/reference/components/item.tsx +0 -188
- package/build/ui/reference/components/kbd.tsx +0 -43
- package/build/ui/reference/components/label.tsx +0 -19
- package/build/ui/reference/components/list.tsx +0 -191
- package/build/ui/reference/components/map.css +0 -251
- package/build/ui/reference/components/map.tsx +0 -294
- package/build/ui/reference/components/menubar.tsx +0 -275
- package/build/ui/reference/components/message-scroller.tsx +0 -141
- package/build/ui/reference/components/message.tsx +0 -171
- package/build/ui/reference/components/nav.tsx +0 -122
- package/build/ui/reference/components/navigation-menu.tsx +0 -191
- package/build/ui/reference/components/page-header.tsx +0 -245
- package/build/ui/reference/components/popover.tsx +0 -76
- package/build/ui/reference/components/progress.tsx +0 -31
- package/build/ui/reference/components/radio.tsx +0 -65
- package/build/ui/reference/components/resizable.tsx +0 -40
- package/build/ui/reference/components/scroll-area.tsx +0 -55
- package/build/ui/reference/components/segmented.tsx +0 -45
- package/build/ui/reference/components/select.tsx +0 -188
- package/build/ui/reference/components/separator.tsx +0 -26
- package/build/ui/reference/components/sheet.tsx +0 -184
- package/build/ui/reference/components/skeleton.tsx +0 -15
- package/build/ui/reference/components/slider.tsx +0 -161
- package/build/ui/reference/components/snackbar.tsx +0 -27
- package/build/ui/reference/components/sonner.tsx +0 -43
- package/build/ui/reference/components/spinner.tsx +0 -27
- package/build/ui/reference/components/statistic.tsx +0 -122
- package/build/ui/reference/components/stepper.tsx +0 -138
- package/build/ui/reference/components/switch.tsx +0 -47
- package/build/ui/reference/components/table.tsx +0 -246
- package/build/ui/reference/components/textarea.tsx +0 -28
- package/build/ui/reference/components/timeline.tsx +0 -101
- package/build/ui/reference/components/toggle-group.tsx +0 -86
- package/build/ui/reference/components/toggle.tsx +0 -46
- package/build/ui/reference/components/tooltip.tsx +0 -53
- package/build/ui/reference/index.ts +0 -68
- package/build/ui/reference/lib/utils.ts +0 -34
- package/template/webpack.config.js +0 -112
- package/template/webpack.local.config.js +0 -68
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { Slider as SliderPrimitive } from 'radix-ui';
|
|
5
|
-
|
|
6
|
-
import { cn } from '@rise-x/ui/lib/utils';
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* 5px track, 20px floating thumb on a two-layer shadow, filled portion in
|
|
10
|
-
* brand. The filled range is an affirmative reading of the value, which is the
|
|
11
|
-
* one place a slider earns brand; the thumb stays white so it reads as a
|
|
12
|
-
* physical control on any track colour.
|
|
13
|
-
*/
|
|
14
|
-
function Slider({ className, ...props }: React.ComponentProps<typeof SliderPrimitive.Root>) {
|
|
15
|
-
return (
|
|
16
|
-
<SliderPrimitive.Root
|
|
17
|
-
data-slot="slider"
|
|
18
|
-
className={cn('relative flex w-full touch-none items-center select-none', className)}
|
|
19
|
-
{...props}
|
|
20
|
-
>
|
|
21
|
-
<SliderPrimitive.Track
|
|
22
|
-
data-slot="slider-track"
|
|
23
|
-
className="relative h-[5px] w-full grow overflow-hidden rounded-full bg-fill-2"
|
|
24
|
-
>
|
|
25
|
-
<SliderPrimitive.Range data-slot="slider-range" className="absolute h-full bg-brand" />
|
|
26
|
-
</SliderPrimitive.Track>
|
|
27
|
-
<SliderPrimitive.Thumb
|
|
28
|
-
data-slot="slider-thumb"
|
|
29
|
-
className="block size-5 rounded-full border-0 bg-white shadow-[0_1px_4px_rgb(0_0_0/0.2),0_3px_10px_rgb(0_0_0/0.12)] outline-none focus-visible:ring-3 focus-visible:ring-ring-control/35"
|
|
30
|
-
/>
|
|
31
|
-
</SliderPrimitive.Root>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/* Rating. Read-only by default: a star row that accepts clicks is rare in an
|
|
36
|
-
* enterprise tool and an interactive-looking control that does nothing is
|
|
37
|
-
* worse than a static one. */
|
|
38
|
-
function Rating({
|
|
39
|
-
value,
|
|
40
|
-
max = 5,
|
|
41
|
-
className,
|
|
42
|
-
onRate,
|
|
43
|
-
...props
|
|
44
|
-
}: Omit<React.ComponentProps<'span'>, 'children'> & {
|
|
45
|
-
value: number;
|
|
46
|
-
max?: number;
|
|
47
|
-
onRate?: (value: number) => void;
|
|
48
|
-
}) {
|
|
49
|
-
return (
|
|
50
|
-
<span
|
|
51
|
-
data-slot="rating"
|
|
52
|
-
role={onRate ? 'radiogroup' : 'img'}
|
|
53
|
-
aria-label={`${value} out of ${max}`}
|
|
54
|
-
className={cn('inline-flex gap-0.5', className)}
|
|
55
|
-
{...props}
|
|
56
|
-
>
|
|
57
|
-
{Array.from({ length: max }, (_, i) => {
|
|
58
|
-
const on = i < value;
|
|
59
|
-
const star = (
|
|
60
|
-
<svg viewBox="0 0 24 24" fill="currentColor" className="size-4">
|
|
61
|
-
<path d="M12 2.5l2.9 6.1 6.6.9-4.8 4.6 1.2 6.6-5.9-3.2-5.9 3.2 1.2-6.6L2.5 9.5l6.6-.9z" />
|
|
62
|
-
</svg>
|
|
63
|
-
);
|
|
64
|
-
return onRate ? (
|
|
65
|
-
// role=radio + aria-checked, because the wrapper claims radiogroup: a
|
|
66
|
-
// radiogroup whose children are plain buttons owns no radios, so the
|
|
67
|
-
// current rating was conveyed by colour alone
|
|
68
|
-
<button
|
|
69
|
-
key={i}
|
|
70
|
-
type="button"
|
|
71
|
-
role="radio"
|
|
72
|
-
aria-checked={i + 1 === value}
|
|
73
|
-
aria-label={`${i + 1}`}
|
|
74
|
-
onClick={() => onRate(i + 1)}
|
|
75
|
-
className={cn(
|
|
76
|
-
'outline-none focus-visible:ring-3 focus-visible:ring-ring-control/35',
|
|
77
|
-
on ? 'text-warning' : 'text-border-strong',
|
|
78
|
-
)}
|
|
79
|
-
>
|
|
80
|
-
{star}
|
|
81
|
-
</button>
|
|
82
|
-
) : (
|
|
83
|
-
<span key={i} className={on ? 'text-warning' : 'text-border-strong'}>
|
|
84
|
-
{star}
|
|
85
|
-
</span>
|
|
86
|
-
);
|
|
87
|
-
})}
|
|
88
|
-
</span>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* Numeric stepper. One filled track with hairline dividers and no outer
|
|
93
|
-
* border — the fill is the container, so the group reads as a single control
|
|
94
|
-
* instead of three adjacent buttons. */
|
|
95
|
-
function StepperInput({
|
|
96
|
-
className,
|
|
97
|
-
value,
|
|
98
|
-
onValueChange,
|
|
99
|
-
min,
|
|
100
|
-
max,
|
|
101
|
-
...props
|
|
102
|
-
}: Omit<React.ComponentProps<'span'>, 'children' | 'onChange'> & {
|
|
103
|
-
value: number;
|
|
104
|
-
onValueChange?: (value: number) => void;
|
|
105
|
-
min?: number;
|
|
106
|
-
max?: number;
|
|
107
|
-
}) {
|
|
108
|
-
const step = (delta: number) => {
|
|
109
|
-
const next = value + delta;
|
|
110
|
-
if (min !== undefined && next < min) return;
|
|
111
|
-
if (max !== undefined && next > max) return;
|
|
112
|
-
onValueChange?.(next);
|
|
113
|
-
};
|
|
114
|
-
return (
|
|
115
|
-
<span
|
|
116
|
-
data-slot="stepper-input"
|
|
117
|
-
className={cn('inline-flex items-center overflow-hidden rounded-lg bg-fill-1', className)}
|
|
118
|
-
{...props}
|
|
119
|
-
>
|
|
120
|
-
<button
|
|
121
|
-
type="button"
|
|
122
|
-
aria-label="Decrease"
|
|
123
|
-
onClick={() => step(-1)}
|
|
124
|
-
className="grid size-control place-items-center text-muted-foreground transition-colors hover:bg-fill-2 hover:text-foreground [&>svg]:size-3"
|
|
125
|
-
>
|
|
126
|
-
<svg
|
|
127
|
-
viewBox="0 0 24 24"
|
|
128
|
-
fill="none"
|
|
129
|
-
stroke="currentColor"
|
|
130
|
-
strokeWidth={2.5}
|
|
131
|
-
strokeLinecap="round"
|
|
132
|
-
>
|
|
133
|
-
<path d="M5 12h14" />
|
|
134
|
-
</svg>
|
|
135
|
-
</button>
|
|
136
|
-
<span aria-hidden className="h-4 w-px self-center bg-fill-3" />
|
|
137
|
-
<span className="grid h-control min-w-9 place-items-center px-1 text-ui tabular-nums">
|
|
138
|
-
{value}
|
|
139
|
-
</span>
|
|
140
|
-
<span aria-hidden className="h-4 w-px self-center bg-fill-3" />
|
|
141
|
-
<button
|
|
142
|
-
type="button"
|
|
143
|
-
aria-label="Increase"
|
|
144
|
-
onClick={() => step(1)}
|
|
145
|
-
className="grid size-control place-items-center text-muted-foreground transition-colors hover:bg-fill-2 hover:text-foreground [&>svg]:size-3"
|
|
146
|
-
>
|
|
147
|
-
<svg
|
|
148
|
-
viewBox="0 0 24 24"
|
|
149
|
-
fill="none"
|
|
150
|
-
stroke="currentColor"
|
|
151
|
-
strokeWidth={2.5}
|
|
152
|
-
strokeLinecap="round"
|
|
153
|
-
>
|
|
154
|
-
<path d="M12 5v14M5 12h14" />
|
|
155
|
-
</svg>
|
|
156
|
-
</button>
|
|
157
|
-
</span>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export { Slider, Rating, StepperInput };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { cn } from '@rise-x/ui/lib/utils';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Snackbar — inverted surface, one line, one action. Distinct from Toast on
|
|
7
|
-
* purpose: a toast reports something that happened and stacks; a snackbar is a
|
|
8
|
-
* single transient acknowledgement with an undo, so it is a bar rather than a
|
|
9
|
-
* card and only ever one is on screen.
|
|
10
|
-
*/
|
|
11
|
-
function Snackbar({ className, ...props }: React.ComponentProps<'div'>) {
|
|
12
|
-
return (
|
|
13
|
-
<div
|
|
14
|
-
data-slot="snackbar"
|
|
15
|
-
role="status"
|
|
16
|
-
className={cn(
|
|
17
|
-
'flex h-10 items-center gap-3 rounded-lg bg-foreground pr-2 pl-3.5 text-xs text-background',
|
|
18
|
-
// the action inherits the inverted surface rather than the page one
|
|
19
|
-
'[&_[data-slot=button]]:text-background [&_[data-slot=button]]:hover:bg-white/12',
|
|
20
|
-
className,
|
|
21
|
-
)}
|
|
22
|
-
{...props}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { Snackbar };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Toaster as Sonner, type ToasterProps } from 'sonner';
|
|
3
|
-
import {
|
|
4
|
-
CircleCheckIcon,
|
|
5
|
-
InfoIcon,
|
|
6
|
-
TriangleAlertIcon,
|
|
7
|
-
OctagonXIcon,
|
|
8
|
-
Loader2Icon,
|
|
9
|
-
} from 'lucide-react';
|
|
10
|
-
|
|
11
|
-
// Theme is injected by the host (the shell passes its resolved theme) so the
|
|
12
|
-
// package stays decoupled from any particular ThemeProvider implementation.
|
|
13
|
-
const Toaster = ({ theme = 'system', ...props }: ToasterProps) => {
|
|
14
|
-
return (
|
|
15
|
-
<Sonner
|
|
16
|
-
theme={theme}
|
|
17
|
-
className="toaster group"
|
|
18
|
-
icons={{
|
|
19
|
-
success: <CircleCheckIcon className="size-4" />,
|
|
20
|
-
info: <InfoIcon className="size-4" />,
|
|
21
|
-
warning: <TriangleAlertIcon className="size-4" />,
|
|
22
|
-
error: <OctagonXIcon className="size-4" />,
|
|
23
|
-
loading: <Loader2Icon className="size-4 animate-spin" />,
|
|
24
|
-
}}
|
|
25
|
-
style={
|
|
26
|
-
{
|
|
27
|
-
'--normal-bg': 'var(--popover)',
|
|
28
|
-
'--normal-text': 'var(--popover-foreground)',
|
|
29
|
-
'--normal-border': 'var(--border)',
|
|
30
|
-
'--border-radius': 'var(--radius)',
|
|
31
|
-
} as React.CSSProperties
|
|
32
|
-
}
|
|
33
|
-
toastOptions={{
|
|
34
|
-
classNames: {
|
|
35
|
-
toast: 'cn-toast',
|
|
36
|
-
},
|
|
37
|
-
}}
|
|
38
|
-
{...props}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { Toaster };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { cn } from '@rise-x/ui/lib/utils';
|
|
4
|
-
|
|
5
|
-
/* One ring, one weight. `prefers-reduced-motion` stops the rotation — a static
|
|
6
|
-
* ring still reads as "waiting". */
|
|
7
|
-
function Spinner({
|
|
8
|
-
className,
|
|
9
|
-
size = 16,
|
|
10
|
-
...props
|
|
11
|
-
}: Omit<React.ComponentProps<'span'>, 'children'> & { size?: number }) {
|
|
12
|
-
return (
|
|
13
|
-
<span
|
|
14
|
-
data-slot="spinner"
|
|
15
|
-
role="status"
|
|
16
|
-
aria-label="Loading"
|
|
17
|
-
style={{ width: size, height: size, borderWidth: size <= 14 ? 1.5 : 2 }}
|
|
18
|
-
className={cn(
|
|
19
|
-
'inline-block shrink-0 rounded-full border-border border-t-muted-foreground motion-safe:animate-spin',
|
|
20
|
-
className,
|
|
21
|
-
)}
|
|
22
|
-
{...props}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { Spinner };
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
-
|
|
4
|
-
import { cn } from '@rise-x/ui/lib/utils';
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* KPI / metric / trend. Numerals at 600 with negative tracking, label above in
|
|
8
|
-
* muted 12px, delta as a small coloured run of text.
|
|
9
|
-
*
|
|
10
|
-
* Trend colour is SEMANTIC (success / error), never brand — the same reasoning
|
|
11
|
-
* that keeps brand out of charts: if the company colour means "good", a
|
|
12
|
-
* downward number rendered in it becomes unreadable as a warning.
|
|
13
|
-
*/
|
|
14
|
-
function Statistic({ className, ...props }: React.ComponentProps<'div'>) {
|
|
15
|
-
return <div data-slot="statistic" className={cn('flex flex-col', className)} {...props} />;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function StatisticLabel({ className, ...props }: React.ComponentProps<'div'>) {
|
|
19
|
-
return (
|
|
20
|
-
<div
|
|
21
|
-
data-slot="statistic-label"
|
|
22
|
-
className={cn('text-xs text-muted-foreground', className)}
|
|
23
|
-
{...props}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function StatisticValue({
|
|
29
|
-
className,
|
|
30
|
-
size = 'default',
|
|
31
|
-
...props
|
|
32
|
-
}: React.ComponentProps<'div'> & { size?: 'sm' | 'default' | 'lg' }) {
|
|
33
|
-
return (
|
|
34
|
-
<div
|
|
35
|
-
data-slot="statistic-value"
|
|
36
|
-
data-size={size}
|
|
37
|
-
className={cn(
|
|
38
|
-
'mt-0.5 flex items-baseline gap-1.5 font-semibold tracking-[-0.02em] tabular-nums',
|
|
39
|
-
size === 'sm' && 'text-[19px] tracking-[-0.01em]',
|
|
40
|
-
size === 'default' && 'text-[26px]',
|
|
41
|
-
size === 'lg' && 'text-[32px]',
|
|
42
|
-
className,
|
|
43
|
-
)}
|
|
44
|
-
{...props}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function StatisticCaption({ className, ...props }: React.ComponentProps<'div'>) {
|
|
50
|
-
return (
|
|
51
|
-
<div
|
|
52
|
-
data-slot="statistic-caption"
|
|
53
|
-
className={cn('mt-1 text-micro text-subtle', className)}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const trendVariants = cva(
|
|
60
|
-
'inline-flex items-center gap-0.5 text-xs font-medium [&>svg]:size-3 [&>svg]:shrink-0',
|
|
61
|
-
{
|
|
62
|
-
variants: {
|
|
63
|
-
direction: {
|
|
64
|
-
up: 'text-success-text',
|
|
65
|
-
down: 'text-error-text',
|
|
66
|
-
flat: 'text-muted-foreground',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
defaultVariants: { direction: 'flat' },
|
|
70
|
-
},
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
function Trend({
|
|
74
|
-
className,
|
|
75
|
-
direction = 'flat',
|
|
76
|
-
...props
|
|
77
|
-
}: React.ComponentProps<'span'> & VariantProps<typeof trendVariants>) {
|
|
78
|
-
return (
|
|
79
|
-
<span data-slot="trend" className={cn(trendVariants({ direction }), className)} {...props} />
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/* Meter: a 4px track. Neutral by default — colour it only when the value
|
|
84
|
-
* genuinely encodes a status, not merely to decorate a number. */
|
|
85
|
-
const meterVariants = cva('h-1 overflow-hidden rounded-full bg-border', {
|
|
86
|
-
variants: {
|
|
87
|
-
tone: {
|
|
88
|
-
neutral: '[&>i]:bg-primary',
|
|
89
|
-
success: '[&>i]:bg-success',
|
|
90
|
-
warning: '[&>i]:bg-warning',
|
|
91
|
-
error: '[&>i]:bg-error',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
defaultVariants: { tone: 'neutral' },
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
function Meter({
|
|
98
|
-
className,
|
|
99
|
-
tone = 'neutral',
|
|
100
|
-
value,
|
|
101
|
-
...props
|
|
102
|
-
}: Omit<React.ComponentProps<'div'>, 'children'> &
|
|
103
|
-
VariantProps<typeof meterVariants> & { value: number }) {
|
|
104
|
-
return (
|
|
105
|
-
<div
|
|
106
|
-
data-slot="meter"
|
|
107
|
-
role="progressbar"
|
|
108
|
-
aria-valuenow={value}
|
|
109
|
-
aria-valuemin={0}
|
|
110
|
-
aria-valuemax={100}
|
|
111
|
-
className={cn(meterVariants({ tone }), className)}
|
|
112
|
-
{...props}
|
|
113
|
-
>
|
|
114
|
-
<i
|
|
115
|
-
className="block h-full rounded-full"
|
|
116
|
-
style={{ width: `${Math.max(0, Math.min(100, value))}%` }}
|
|
117
|
-
/>
|
|
118
|
-
</div>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export { Statistic, StatisticLabel, StatisticValue, StatisticCaption, Trend, Meter, trendVariants };
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { cn } from '@rise-x/ui/lib/utils';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Progress through a multi-step task. Three states, each carried by a different
|
|
7
|
-
* mechanism rather than three shades of one colour:
|
|
8
|
-
* done → filled brand dot with a tick, and the connector behind it is brand
|
|
9
|
-
* current → outlined in the text colour with a NEUTRAL halo
|
|
10
|
-
* ahead → hairline outline, muted label
|
|
11
|
-
* Brand marks completion because a finished step is affirmative — the same reason
|
|
12
|
-
* a checked switch is brand and a checked checkbox is not. The halo stays grey: a
|
|
13
|
-
* green ring around a black circle reads as two competing marks rather than one
|
|
14
|
-
* emphasised step.
|
|
15
|
-
*
|
|
16
|
-
* THE CONTAINER OWNS THE CONNECTORS, not the steps. When each step carried its
|
|
17
|
-
* own `flex-1` line, the line took whatever width was left after that step's
|
|
18
|
-
* label — so a long label got a 4px stub and a short one got 90px, and the line
|
|
19
|
-
* appeared to hang off the end of the previous label rather than bridging two
|
|
20
|
-
* dots. Interleaved by the container, every connector gets an equal share of the
|
|
21
|
-
* leftover space no matter how uneven the labels are.
|
|
22
|
-
*/
|
|
23
|
-
function Steps({ className, children, ...props }: React.ComponentProps<'ol'>) {
|
|
24
|
-
const steps = React.Children.toArray(children).filter(React.isValidElement);
|
|
25
|
-
return (
|
|
26
|
-
<ol data-slot="steps" className={cn('flex list-none items-start p-0', className)} {...props}>
|
|
27
|
-
{steps.map((step, i) => {
|
|
28
|
-
const prev = steps[i - 1] as React.ReactElement<{ state?: StepState }> | undefined;
|
|
29
|
-
return (
|
|
30
|
-
<React.Fragment key={step.key ?? i}>
|
|
31
|
-
{i > 0 ? (
|
|
32
|
-
<li
|
|
33
|
-
aria-hidden
|
|
34
|
-
className={cn(
|
|
35
|
-
'mx-2 mt-2.5 h-px flex-1',
|
|
36
|
-
// the line behind a completed step is part of the completed run
|
|
37
|
-
prev?.props?.state === 'done' ? 'bg-brand' : 'bg-border',
|
|
38
|
-
)}
|
|
39
|
-
/>
|
|
40
|
-
) : null}
|
|
41
|
-
{step}
|
|
42
|
-
</React.Fragment>
|
|
43
|
-
);
|
|
44
|
-
})}
|
|
45
|
-
</ol>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
type StepState = 'done' | 'current' | 'ahead';
|
|
50
|
-
|
|
51
|
-
function Step({
|
|
52
|
-
className,
|
|
53
|
-
state = 'ahead',
|
|
54
|
-
index,
|
|
55
|
-
children,
|
|
56
|
-
...props
|
|
57
|
-
}: React.ComponentProps<'li'> & {
|
|
58
|
-
state?: StepState;
|
|
59
|
-
/** 1-based number shown when the step is not complete. */
|
|
60
|
-
index?: number;
|
|
61
|
-
}) {
|
|
62
|
-
return (
|
|
63
|
-
<li
|
|
64
|
-
data-slot="step"
|
|
65
|
-
data-state={state}
|
|
66
|
-
// shrink-0: the step is as wide as its content, and the connectors take the
|
|
67
|
-
// slack — the reverse leaves the lines at the mercy of label length
|
|
68
|
-
className={cn('flex shrink-0 items-start gap-2', className)}
|
|
69
|
-
{...props}
|
|
70
|
-
>
|
|
71
|
-
<span
|
|
72
|
-
className={cn(
|
|
73
|
-
'grid size-5 shrink-0 place-items-center rounded-full border text-[10px] font-medium [&>svg]:size-[11px]',
|
|
74
|
-
state === 'done' && 'border-brand bg-brand text-[#0a0a0a]',
|
|
75
|
-
state === 'current' &&
|
|
76
|
-
'border-foreground text-foreground shadow-[0_0_0_3px_var(--fill-2)]',
|
|
77
|
-
state === 'ahead' && 'border-border-strong bg-card text-muted-foreground',
|
|
78
|
-
)}
|
|
79
|
-
>
|
|
80
|
-
{state === 'done' ? (
|
|
81
|
-
<svg
|
|
82
|
-
viewBox="0 0 24 24"
|
|
83
|
-
fill="none"
|
|
84
|
-
stroke="currentColor"
|
|
85
|
-
strokeWidth={3}
|
|
86
|
-
strokeLinecap="round"
|
|
87
|
-
>
|
|
88
|
-
<path d="M20 6L9 17l-5-5" />
|
|
89
|
-
</svg>
|
|
90
|
-
) : (
|
|
91
|
-
index
|
|
92
|
-
)}
|
|
93
|
-
</span>
|
|
94
|
-
{/* the dot is 20px and the label line ~16px, so 2px of offset puts the
|
|
95
|
-
label on the dot's optical centre rather than above it */}
|
|
96
|
-
<span
|
|
97
|
-
className={cn(
|
|
98
|
-
'mt-[2px] text-xs leading-[1.35] whitespace-nowrap',
|
|
99
|
-
state === 'current' ? 'font-medium text-foreground' : 'text-muted-foreground',
|
|
100
|
-
)}
|
|
101
|
-
>
|
|
102
|
-
{children}
|
|
103
|
-
</span>
|
|
104
|
-
</li>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/* The bar at the foot of a wizard: where you are on the left, movement on the
|
|
109
|
-
* right. Separate from Steps so a wizard can show progress at the top and
|
|
110
|
-
* navigation at the bottom without either knowing about the other. */
|
|
111
|
-
function WizardBar({ className, ...props }: React.ComponentProps<'div'>) {
|
|
112
|
-
return (
|
|
113
|
-
<div
|
|
114
|
-
data-slot="wizard-bar"
|
|
115
|
-
className={cn(
|
|
116
|
-
'flex items-center gap-2 border-t border-border-subtle px-5 py-3.5 [&>[data-slot=wizard-end]]:ml-auto',
|
|
117
|
-
className,
|
|
118
|
-
)}
|
|
119
|
-
{...props}
|
|
120
|
-
/>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function WizardMeta({ className, ...props }: React.ComponentProps<'span'>) {
|
|
125
|
-
return (
|
|
126
|
-
<span
|
|
127
|
-
data-slot="wizard-meta"
|
|
128
|
-
className={cn('text-xs text-muted-foreground', className)}
|
|
129
|
-
{...props}
|
|
130
|
-
/>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function WizardEnd({ className, ...props }: React.ComponentProps<'div'>) {
|
|
135
|
-
return <div data-slot="wizard-end" className={cn('flex gap-2', className)} {...props} />;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export { Steps, Step, WizardBar, WizardMeta, WizardEnd, type StepState };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Switch as SwitchPrimitive } from 'radix-ui';
|
|
3
|
-
|
|
4
|
-
import { cn } from '@rise-x/ui/lib/utils';
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* 30×18 track, 14px thumb, 2px inset — so the checked thumb travels exactly
|
|
8
|
-
* 12px. Checked is BRAND, not primary: a switch is an affirmative commitment
|
|
9
|
-
* ("this is on"), which is precisely the complementary role brand keeps in a
|
|
10
|
-
* neutral system. Contrast with Checkbox, where "selected" is a neutral fact
|
|
11
|
-
* about a row and the fill is near-black.
|
|
12
|
-
*/
|
|
13
|
-
function Switch({
|
|
14
|
-
className,
|
|
15
|
-
size = 'default',
|
|
16
|
-
...props
|
|
17
|
-
}: React.ComponentProps<typeof SwitchPrimitive.Root> & {
|
|
18
|
-
size?: 'sm' | 'default';
|
|
19
|
-
}) {
|
|
20
|
-
return (
|
|
21
|
-
<SwitchPrimitive.Root
|
|
22
|
-
data-slot="switch"
|
|
23
|
-
data-size={size}
|
|
24
|
-
className={cn(
|
|
25
|
-
'peer group/switch relative inline-flex shrink-0 items-center rounded-full border-0 transition-colors duration-150 ease-decelerate outline-none after:absolute after:-inset-x-3 after:-inset-y-2',
|
|
26
|
-
'focus-visible:ring-3 focus-visible:ring-ring-control/35',
|
|
27
|
-
'data-[size=default]:h-[18px] data-[size=default]:w-[30px] data-[size=sm]:h-3.5 data-[size=sm]:w-6',
|
|
28
|
-
'data-checked:bg-brand data-unchecked:bg-border-strong',
|
|
29
|
-
'aria-invalid:ring-3 aria-invalid:ring-error/20',
|
|
30
|
-
'data-disabled:cursor-not-allowed data-disabled:opacity-45',
|
|
31
|
-
className,
|
|
32
|
-
)}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
<SwitchPrimitive.Thumb
|
|
36
|
-
data-slot="switch-thumb"
|
|
37
|
-
className={cn(
|
|
38
|
-
'pointer-events-none block translate-x-0.5 rounded-full bg-white shadow-[0_1px_2px_rgb(0_0_0/0.15)] ring-0 transition-transform duration-150 ease-decelerate',
|
|
39
|
-
'group-data-[size=default]/switch:size-3.5 group-data-[size=sm]/switch:size-2.5',
|
|
40
|
-
'group-data-[size=default]/switch:data-checked:translate-x-[14px] group-data-[size=sm]/switch:data-checked:translate-x-[12px]',
|
|
41
|
-
)}
|
|
42
|
-
/>
|
|
43
|
-
</SwitchPrimitive.Root>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export { Switch };
|