@rise-x/apps-sdk 0.7.0 → 0.9.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 +104 -1
- package/build/rsbuild/index.d.ts +31 -0
- package/build/rsbuild/index.js +204 -0
- package/build/ui/components/accordion.d.ts +7 -0
- package/build/ui/components/app-frame.d.ts +13 -0
- package/build/ui/components/aspect-ratio.d.ts +4 -0
- package/build/ui/components/button-group.d.ts +7 -0
- package/build/ui/components/carousel.d.ts +18 -0
- package/build/ui/components/chart.d.ts +45 -94
- package/build/ui/components/collapsible.d.ts +6 -0
- package/build/ui/components/combobox.d.ts +19 -0
- package/build/ui/components/command.d.ts +18 -0
- package/build/ui/components/context-menu.d.ts +29 -0
- package/build/ui/components/date-picker.d.ts +16 -0
- package/build/ui/components/direction.d.ts +6 -0
- package/build/ui/components/field.d.ts +25 -0
- package/build/ui/components/hover-card.d.ts +6 -0
- package/build/ui/components/input-group.d.ts +13 -0
- package/build/ui/components/input-otp.d.ts +34 -0
- package/build/ui/components/input.d.ts +1 -3
- package/build/ui/components/item.d.ts +23 -0
- package/build/ui/components/kbd.d.ts +4 -0
- package/build/ui/components/menubar.d.ts +26 -0
- package/build/ui/components/message-scroller.d.ts +15 -0
- package/build/ui/components/nav.d.ts +2 -1
- package/build/ui/components/navigation-menu.d.ts +13 -0
- package/build/ui/components/page-header.d.ts +7 -1
- package/build/ui/index.d.ts +20 -0
- package/build/ui/reference/components/accordion.tsx +85 -0
- package/build/ui/reference/components/ai.tsx +3 -1
- package/build/ui/reference/components/alert-dialog.tsx +10 -16
- package/build/ui/reference/components/app-frame.tsx +71 -0
- package/build/ui/reference/components/aspect-ratio.tsx +28 -0
- package/build/ui/reference/components/button-group.tsx +77 -0
- package/build/ui/reference/components/button.tsx +4 -2
- package/build/ui/reference/components/carousel.tsx +248 -0
- package/build/ui/reference/components/chart.tsx +441 -1131
- package/build/ui/reference/components/collapsible.tsx +43 -0
- package/build/ui/reference/components/combobox.tsx +146 -0
- package/build/ui/reference/components/command.tsx +181 -0
- package/build/ui/reference/components/context-menu.tsx +243 -0
- package/build/ui/reference/components/data-table.tsx +3 -3
- package/build/ui/reference/components/date-picker.tsx +218 -0
- package/build/ui/reference/components/dialog.tsx +3 -3
- package/build/ui/reference/components/direction.tsx +22 -0
- package/build/ui/reference/components/dropdown-menu.tsx +1 -1
- package/build/ui/reference/components/field.tsx +252 -0
- package/build/ui/reference/components/hover-card.tsx +64 -0
- package/build/ui/reference/components/input-group.tsx +157 -0
- package/build/ui/reference/components/input-otp.tsx +106 -0
- package/build/ui/reference/components/input.tsx +4 -32
- package/build/ui/reference/components/item.tsx +188 -0
- package/build/ui/reference/components/kbd.tsx +43 -0
- package/build/ui/reference/components/label.tsx +1 -1
- package/build/ui/reference/components/menubar.tsx +275 -0
- package/build/ui/reference/components/message-scroller.tsx +141 -0
- package/build/ui/reference/components/message.tsx +12 -6
- package/build/ui/reference/components/nav.tsx +14 -3
- package/build/ui/reference/components/navigation-menu.tsx +191 -0
- package/build/ui/reference/components/page-header.tsx +32 -0
- package/build/ui/reference/components/popover.tsx +2 -2
- package/build/ui/reference/components/select.tsx +11 -8
- package/build/ui/reference/components/sheet.tsx +10 -2
- package/build/ui/reference/components/timeline.tsx +7 -0
- package/build/ui/reference/components/toggle.tsx +1 -1
- package/build/ui/reference/index.ts +20 -0
- package/build/ui/standalone.js +167 -28
- package/build/ui/styles.css +1 -1
- package/package.json +27 -2
- package/rsbuild/package.json +8 -0
- package/template/AGENTS.md +15 -7
- package/template/src/App.tsx +18 -11
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@rise-x/ui/lib/utils';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Buttons that act as ONE control — a split action, or a segmented set of
|
|
7
|
+
* commands. Distinct from ToggleGroup, which records a selection: a button group
|
|
8
|
+
* fires actions and remembers nothing.
|
|
9
|
+
*
|
|
10
|
+
* BORDERS ARE SHARED, NOT DOUBLED. The group collapses the edge where two
|
|
11
|
+
* children meet and keeps the radius only on the outer corners, so a row of three
|
|
12
|
+
* reads as one object rather than three adjacent buttons — the same arithmetic
|
|
13
|
+
* InputGroup uses for its affixes, and the same reason.
|
|
14
|
+
*
|
|
15
|
+
* The children keep their own variant. A group of `outline` buttons and a group
|
|
16
|
+
* of `secondary` ones both work; mixing variants inside one group does not, and
|
|
17
|
+
* that is a call site problem rather than something to guard here.
|
|
18
|
+
*/
|
|
19
|
+
function ButtonGroup({
|
|
20
|
+
className,
|
|
21
|
+
orientation = 'horizontal',
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<'div'> & { orientation?: 'horizontal' | 'vertical' }) {
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
data-slot="button-group"
|
|
27
|
+
data-orientation={orientation}
|
|
28
|
+
role="group"
|
|
29
|
+
className={cn(
|
|
30
|
+
'inline-flex w-fit',
|
|
31
|
+
'data-horizontal:flex-row data-vertical:flex-col data-vertical:items-stretch',
|
|
32
|
+
// inner radii collapse; only the outer corners survive
|
|
33
|
+
'data-horizontal:[&>*:not(:first-child)]:rounded-l-none data-horizontal:[&>*:not(:last-child)]:rounded-r-none',
|
|
34
|
+
'data-vertical:[&>*:not(:first-child)]:rounded-t-none data-vertical:[&>*:not(:last-child)]:rounded-b-none',
|
|
35
|
+
// and the shared edge is drawn once
|
|
36
|
+
'data-horizontal:[&>*:not(:first-child)]:border-l-0 data-vertical:[&>*:not(:first-child)]:border-t-0',
|
|
37
|
+
// a focused member has to sit above its neighbour or the ring is clipped
|
|
38
|
+
'[&>*]:relative [&>*:focus-visible]:z-10',
|
|
39
|
+
className,
|
|
40
|
+
)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/*
|
|
47
|
+
* A non-interactive label inside the group — a unit, a count, a static prefix.
|
|
48
|
+
* Matches the control height so the group keeps one baseline, and takes the muted
|
|
49
|
+
* tone because it is not pressable and must not look it.
|
|
50
|
+
*/
|
|
51
|
+
function ButtonGroupText({ className, ...props }: React.ComponentProps<'span'>) {
|
|
52
|
+
return (
|
|
53
|
+
<span
|
|
54
|
+
data-slot="button-group-text"
|
|
55
|
+
className={cn(
|
|
56
|
+
'inline-flex h-control shrink-0 items-center border border-border-strong bg-muted px-2.5 text-ui text-muted-foreground',
|
|
57
|
+
className,
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Hairline between two members of a FILLED group, where there are no borders to
|
|
65
|
+
* share. Owned by the group, like every other separator in the system. */
|
|
66
|
+
function ButtonGroupSeparator({ className, ...props }: React.ComponentProps<'span'>) {
|
|
67
|
+
return (
|
|
68
|
+
<span
|
|
69
|
+
data-slot="button-group-separator"
|
|
70
|
+
aria-hidden
|
|
71
|
+
className={cn('w-px shrink-0 self-stretch bg-fill-3', className)}
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { ButtonGroup, ButtonGroupText, ButtonGroupSeparator };
|
|
@@ -52,8 +52,10 @@ const buttonVariants = cva(
|
|
|
52
52
|
* upload glyph still describes the control after a file is chosen. */
|
|
53
53
|
dashed:
|
|
54
54
|
'border-dashed border-border-strong text-muted-foreground hover:bg-fill-1 hover:text-foreground aria-pressed:border-solid aria-pressed:border-transparent aria-pressed:bg-fill-2 aria-pressed:text-foreground aria-pressed:hover:bg-fill-3 aria-pressed:[&>svg:first-child]:hidden data-filled:border-solid data-filled:border-transparent data-filled:bg-fill-2 data-filled:text-foreground data-filled:hover:bg-fill-3',
|
|
55
|
-
/* Rise-X wireframe pill —
|
|
56
|
-
|
|
55
|
+
/* Rise-X wireframe pill — frosted-glass surface, soft shadow, fully
|
|
56
|
+
* rounded. Translucent + backdrop blur so scrolled content shows
|
|
57
|
+
* through without hurting label contrast. */
|
|
58
|
+
pill: 'rounded-full border-border/60 bg-card/70 text-card-foreground shadow-pill backdrop-blur-xl backdrop-saturate-150 hover:shadow-card aria-expanded:shadow-card',
|
|
57
59
|
},
|
|
58
60
|
size: {
|
|
59
61
|
default:
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react';
|
|
5
|
+
import { ArrowLeftIcon, ArrowRightIcon } from 'lucide-react';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@rise-x/ui/lib/utils';
|
|
8
|
+
import { Button } from '@rise-x/ui/components/button';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* A horizontal (or vertical) slider for media and cards.
|
|
12
|
+
*
|
|
13
|
+
* READ THIS BEFORE USING IT IN AN ENTERPRISE VIEW. A carousel hides content
|
|
14
|
+
* behind an interaction, which is the opposite of data-first: anything the reader
|
|
15
|
+
* needs to compare must not be in one. It earns its place for media — product
|
|
16
|
+
* photos, scanned pages, a document preview — and for a genuinely browsable strip
|
|
17
|
+
* where seeing everything at once is not the point. For a set of records, a
|
|
18
|
+
* wrapping grid or a table is the right answer and this is the wrong one.
|
|
19
|
+
*
|
|
20
|
+
* NO AUTOPLAY, DELIBERATELY. Content that moves on its own competes for attention
|
|
21
|
+
* with the work, and it is a documented accessibility failure for anyone who reads
|
|
22
|
+
* slowly. If a caller wants it they can pass the Embla plugin themselves and own
|
|
23
|
+
* that decision.
|
|
24
|
+
*
|
|
25
|
+
* THE ARROWS ARE ALWAYS RENDERED AND DISABLE AT THE ENDS rather than disappearing.
|
|
26
|
+
* A control that vanishes tells the reader nothing about why; a disabled one says
|
|
27
|
+
* "this is the end". Same reason the filter trigger keeps its shape when empty.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
type CarouselApi = UseEmblaCarouselType[1];
|
|
31
|
+
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
|
|
32
|
+
type CarouselOptions = UseCarouselParameters[0];
|
|
33
|
+
type CarouselPlugin = UseCarouselParameters[1];
|
|
34
|
+
|
|
35
|
+
type CarouselContextValue = {
|
|
36
|
+
carouselRef: UseEmblaCarouselType[0];
|
|
37
|
+
api: CarouselApi;
|
|
38
|
+
orientation: 'horizontal' | 'vertical';
|
|
39
|
+
scrollPrev: () => void;
|
|
40
|
+
scrollNext: () => void;
|
|
41
|
+
canScrollPrev: boolean;
|
|
42
|
+
canScrollNext: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const CarouselContext = React.createContext<CarouselContextValue | null>(null);
|
|
46
|
+
|
|
47
|
+
function useCarousel() {
|
|
48
|
+
const context = React.useContext(CarouselContext);
|
|
49
|
+
if (!context) {
|
|
50
|
+
throw new Error('useCarousel must be used within a <Carousel />');
|
|
51
|
+
}
|
|
52
|
+
return context;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const Carousel = React.forwardRef<
|
|
56
|
+
HTMLDivElement,
|
|
57
|
+
React.ComponentProps<'div'> & {
|
|
58
|
+
opts?: CarouselOptions;
|
|
59
|
+
plugins?: CarouselPlugin;
|
|
60
|
+
orientation?: 'horizontal' | 'vertical';
|
|
61
|
+
setApi?: (api: CarouselApi) => void;
|
|
62
|
+
}
|
|
63
|
+
>(function Carousel(
|
|
64
|
+
{ orientation = 'horizontal', opts, setApi, plugins, className, children, ...props },
|
|
65
|
+
ref,
|
|
66
|
+
) {
|
|
67
|
+
const [carouselRef, api] = useEmblaCarousel(
|
|
68
|
+
{ ...opts, axis: orientation === 'horizontal' ? 'x' : 'y' },
|
|
69
|
+
plugins,
|
|
70
|
+
);
|
|
71
|
+
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
72
|
+
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
73
|
+
|
|
74
|
+
const onSelect = React.useCallback((emblaApi: CarouselApi) => {
|
|
75
|
+
if (!emblaApi) return;
|
|
76
|
+
setCanScrollPrev(emblaApi.canScrollPrev());
|
|
77
|
+
setCanScrollNext(emblaApi.canScrollNext());
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
const scrollPrev = React.useCallback(() => api?.scrollPrev(), [api]);
|
|
81
|
+
const scrollNext = React.useCallback(() => api?.scrollNext(), [api]);
|
|
82
|
+
|
|
83
|
+
/* The arrow keys match the AXIS — left/right for a horizontal strip, up/down
|
|
84
|
+
* for a vertical one — and a control inside a slide keeps its own arrows: on
|
|
85
|
+
* the capture phase an unconditional preventDefault would take the caret keys
|
|
86
|
+
* away from a text field and the option keys away from a select. */
|
|
87
|
+
const handleKeyDown = React.useCallback(
|
|
88
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
89
|
+
const target = event.target as HTMLElement | null;
|
|
90
|
+
if (target?.closest('input, textarea, select, [contenteditable=""], [contenteditable=true]'))
|
|
91
|
+
return;
|
|
92
|
+
const [prevKey, nextKey] =
|
|
93
|
+
orientation === 'horizontal' ? ['ArrowLeft', 'ArrowRight'] : ['ArrowUp', 'ArrowDown'];
|
|
94
|
+
if (event.key === prevKey) {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
scrollPrev();
|
|
97
|
+
} else if (event.key === nextKey) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
scrollNext();
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
[orientation, scrollPrev, scrollNext],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
React.useEffect(() => {
|
|
106
|
+
if (api && setApi) setApi(api);
|
|
107
|
+
}, [api, setApi]);
|
|
108
|
+
|
|
109
|
+
React.useEffect(() => {
|
|
110
|
+
if (!api) return;
|
|
111
|
+
onSelect(api);
|
|
112
|
+
api.on('reInit', onSelect);
|
|
113
|
+
api.on('select', onSelect);
|
|
114
|
+
return () => {
|
|
115
|
+
api.off('reInit', onSelect);
|
|
116
|
+
api.off('select', onSelect);
|
|
117
|
+
};
|
|
118
|
+
}, [api, onSelect]);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<CarouselContext.Provider
|
|
122
|
+
value={{
|
|
123
|
+
carouselRef,
|
|
124
|
+
api,
|
|
125
|
+
orientation,
|
|
126
|
+
scrollPrev,
|
|
127
|
+
scrollNext,
|
|
128
|
+
canScrollPrev,
|
|
129
|
+
canScrollNext,
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<div
|
|
133
|
+
ref={ref}
|
|
134
|
+
data-slot="carousel"
|
|
135
|
+
onKeyDownCapture={handleKeyDown}
|
|
136
|
+
className={cn('relative', className)}
|
|
137
|
+
role="region"
|
|
138
|
+
aria-roledescription="carousel"
|
|
139
|
+
{...props}
|
|
140
|
+
>
|
|
141
|
+
{children}
|
|
142
|
+
</div>
|
|
143
|
+
</CarouselContext.Provider>
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
148
|
+
const { carouselRef, orientation } = useCarousel();
|
|
149
|
+
return (
|
|
150
|
+
<div ref={carouselRef} data-slot="carousel-viewport" className="overflow-hidden">
|
|
151
|
+
<div
|
|
152
|
+
data-slot="carousel-content"
|
|
153
|
+
className={cn(
|
|
154
|
+
'flex',
|
|
155
|
+
// negative margin plus per-item padding is how Embla spaces slides —
|
|
156
|
+
// a gap would be measured into the scroll distance and drift
|
|
157
|
+
orientation === 'horizontal' ? '-ml-2.5' : '-mt-2.5 flex-col',
|
|
158
|
+
className,
|
|
159
|
+
)}
|
|
160
|
+
{...props}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
|
|
167
|
+
const { orientation } = useCarousel();
|
|
168
|
+
return (
|
|
169
|
+
<div
|
|
170
|
+
data-slot="carousel-item"
|
|
171
|
+
role="group"
|
|
172
|
+
aria-roledescription="slide"
|
|
173
|
+
className={cn(
|
|
174
|
+
'min-w-0 shrink-0 grow-0 basis-full',
|
|
175
|
+
orientation === 'horizontal' ? 'pl-2.5' : 'pt-2.5',
|
|
176
|
+
className,
|
|
177
|
+
)}
|
|
178
|
+
{...props}
|
|
179
|
+
/>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function CarouselPrevious({
|
|
184
|
+
className,
|
|
185
|
+
variant = 'outline',
|
|
186
|
+
size = 'icon-sm',
|
|
187
|
+
...props
|
|
188
|
+
}: React.ComponentProps<typeof Button>) {
|
|
189
|
+
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
190
|
+
return (
|
|
191
|
+
<Button
|
|
192
|
+
data-slot="carousel-previous"
|
|
193
|
+
variant={variant}
|
|
194
|
+
size={size}
|
|
195
|
+
className={cn(
|
|
196
|
+
'absolute rounded-full',
|
|
197
|
+
orientation === 'horizontal'
|
|
198
|
+
? 'top-1/2 -left-3.5 -translate-y-1/2'
|
|
199
|
+
: '-top-3.5 left-1/2 -translate-x-1/2 rotate-90',
|
|
200
|
+
className,
|
|
201
|
+
)}
|
|
202
|
+
disabled={!canScrollPrev}
|
|
203
|
+
onClick={scrollPrev}
|
|
204
|
+
{...props}
|
|
205
|
+
>
|
|
206
|
+
<ArrowLeftIcon />
|
|
207
|
+
<span className="sr-only">Previous slide</span>
|
|
208
|
+
</Button>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function CarouselNext({
|
|
213
|
+
className,
|
|
214
|
+
variant = 'outline',
|
|
215
|
+
size = 'icon-sm',
|
|
216
|
+
...props
|
|
217
|
+
}: React.ComponentProps<typeof Button>) {
|
|
218
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
219
|
+
return (
|
|
220
|
+
<Button
|
|
221
|
+
data-slot="carousel-next"
|
|
222
|
+
variant={variant}
|
|
223
|
+
size={size}
|
|
224
|
+
className={cn(
|
|
225
|
+
'absolute rounded-full',
|
|
226
|
+
orientation === 'horizontal'
|
|
227
|
+
? 'top-1/2 -right-3.5 -translate-y-1/2'
|
|
228
|
+
: '-bottom-3.5 left-1/2 -translate-x-1/2 rotate-90',
|
|
229
|
+
className,
|
|
230
|
+
)}
|
|
231
|
+
disabled={!canScrollNext}
|
|
232
|
+
onClick={scrollNext}
|
|
233
|
+
{...props}
|
|
234
|
+
>
|
|
235
|
+
<ArrowRightIcon />
|
|
236
|
+
<span className="sr-only">Next slide</span>
|
|
237
|
+
</Button>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
type CarouselApi,
|
|
243
|
+
Carousel,
|
|
244
|
+
CarouselContent,
|
|
245
|
+
CarouselItem,
|
|
246
|
+
CarouselPrevious,
|
|
247
|
+
CarouselNext,
|
|
248
|
+
};
|