@rise-x/apps-sdk 0.9.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 +116 -31
- package/build/rsbuild/index.d.ts +6 -1
- package/build/rsbuild/index.js +23 -2
- package/build/ui/classes.json +209 -0
- package/build/ui/components/ai.d.ts +33 -1
- package/build/ui/components/app-frame.d.ts +16 -10
- package/build/ui/components/chat-input.d.ts +28 -0
- package/build/ui/components/message-scroller.d.ts +34 -10
- 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 +2 -0
- package/build/ui/standalone.js +59 -58
- package/build/ui/styles.css +1 -1
- package/package.json +4 -3
- package/template/AGENTS.md +3 -3
- package/template/README.md +5 -5
- package/template/package.json +8 -9
- package/template/rsbuild.config.mts +17 -0
- package/template/src/App.tsx +4 -1
- 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 -293
- package/build/ui/reference/components/alert-dialog.tsx +0 -207
- package/build/ui/reference/components/alert.tsx +0 -112
- package/build/ui/reference/components/app-frame.tsx +0 -71
- 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 -109
- 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 -146
- 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 -177
- package/build/ui/reference/components/nav.tsx +0 -127
- 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 -69
- 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,248 +0,0 @@
|
|
|
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
|
-
};
|