@rise-x/apps-sdk 0.7.0 → 0.8.1

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.
Files changed (59) hide show
  1. package/build/ui/components/accordion.d.ts +7 -0
  2. package/build/ui/components/aspect-ratio.d.ts +4 -0
  3. package/build/ui/components/button-group.d.ts +7 -0
  4. package/build/ui/components/carousel.d.ts +18 -0
  5. package/build/ui/components/chart.d.ts +45 -94
  6. package/build/ui/components/collapsible.d.ts +6 -0
  7. package/build/ui/components/combobox.d.ts +19 -0
  8. package/build/ui/components/command.d.ts +18 -0
  9. package/build/ui/components/context-menu.d.ts +29 -0
  10. package/build/ui/components/date-picker.d.ts +16 -0
  11. package/build/ui/components/direction.d.ts +6 -0
  12. package/build/ui/components/field.d.ts +25 -0
  13. package/build/ui/components/hover-card.d.ts +6 -0
  14. package/build/ui/components/input-group.d.ts +13 -0
  15. package/build/ui/components/input-otp.d.ts +34 -0
  16. package/build/ui/components/input.d.ts +1 -3
  17. package/build/ui/components/item.d.ts +23 -0
  18. package/build/ui/components/kbd.d.ts +4 -0
  19. package/build/ui/components/menubar.d.ts +26 -0
  20. package/build/ui/components/message-scroller.d.ts +15 -0
  21. package/build/ui/components/navigation-menu.d.ts +13 -0
  22. package/build/ui/components/page-header.d.ts +7 -1
  23. package/build/ui/index.d.ts +19 -0
  24. package/build/ui/reference/components/accordion.tsx +85 -0
  25. package/build/ui/reference/components/alert-dialog.tsx +1 -1
  26. package/build/ui/reference/components/aspect-ratio.tsx +28 -0
  27. package/build/ui/reference/components/button-group.tsx +77 -0
  28. package/build/ui/reference/components/carousel.tsx +248 -0
  29. package/build/ui/reference/components/chart.tsx +441 -1131
  30. package/build/ui/reference/components/collapsible.tsx +43 -0
  31. package/build/ui/reference/components/combobox.tsx +141 -0
  32. package/build/ui/reference/components/command.tsx +181 -0
  33. package/build/ui/reference/components/context-menu.tsx +243 -0
  34. package/build/ui/reference/components/data-table.tsx +3 -3
  35. package/build/ui/reference/components/date-picker.tsx +218 -0
  36. package/build/ui/reference/components/dialog.tsx +2 -2
  37. package/build/ui/reference/components/direction.tsx +22 -0
  38. package/build/ui/reference/components/field.tsx +252 -0
  39. package/build/ui/reference/components/hover-card.tsx +64 -0
  40. package/build/ui/reference/components/input-group.tsx +157 -0
  41. package/build/ui/reference/components/input-otp.tsx +106 -0
  42. package/build/ui/reference/components/input.tsx +4 -32
  43. package/build/ui/reference/components/item.tsx +188 -0
  44. package/build/ui/reference/components/kbd.tsx +43 -0
  45. package/build/ui/reference/components/label.tsx +1 -1
  46. package/build/ui/reference/components/menubar.tsx +275 -0
  47. package/build/ui/reference/components/message-scroller.tsx +141 -0
  48. package/build/ui/reference/components/nav.tsx +6 -0
  49. package/build/ui/reference/components/navigation-menu.tsx +191 -0
  50. package/build/ui/reference/components/page-header.tsx +32 -0
  51. package/build/ui/reference/components/popover.tsx +2 -2
  52. package/build/ui/reference/components/select.tsx +11 -8
  53. package/build/ui/reference/components/sheet.tsx +9 -1
  54. package/build/ui/reference/components/timeline.tsx +7 -0
  55. package/build/ui/reference/components/toggle.tsx +1 -1
  56. package/build/ui/reference/index.ts +19 -0
  57. package/build/ui/standalone.js +168 -28
  58. package/build/ui/styles.css +1 -1
  59. package/package.json +6 -1
@@ -0,0 +1,85 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { Accordion as AccordionPrimitive } from 'radix-ui';
5
+ import { ChevronDownIcon } from 'lucide-react';
6
+
7
+ import { cn } from '@rise-x/ui/lib/utils';
8
+
9
+ /*
10
+ * Progressive disclosure for a list of sections. The trigger is the whole row —
11
+ * a chevron you have to hit is a target the size of a full stop.
12
+ *
13
+ * THE CONTAINER OWNS THE DIVIDERS, drawn between items rather than as a border
14
+ * on every row: a top-and-bottom border doubles up at every seam. Same rule as
15
+ * List, and the same reason.
16
+ *
17
+ * NO SURFACE OF ITS OWN by default. An accordion inside a card is already on a
18
+ * surface, and wrapping each item in another one produces a box in a box. Pass
19
+ * `bordered` for the standalone case where the group needs to read as one object.
20
+ */
21
+ function Accordion({ className, ...props }: React.ComponentProps<typeof AccordionPrimitive.Root>) {
22
+ return <AccordionPrimitive.Root data-slot="accordion" className={cn(className)} {...props} />;
23
+ }
24
+
25
+ function AccordionItem({
26
+ className,
27
+ ...props
28
+ }: React.ComponentProps<typeof AccordionPrimitive.Item>) {
29
+ return (
30
+ <AccordionPrimitive.Item
31
+ data-slot="accordion-item"
32
+ className={cn('border-t border-border-subtle first:border-t-0', className)}
33
+ {...props}
34
+ />
35
+ );
36
+ }
37
+
38
+ function AccordionTrigger({
39
+ className,
40
+ children,
41
+ ...props
42
+ }: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
43
+ return (
44
+ <AccordionPrimitive.Header className="flex">
45
+ <AccordionPrimitive.Trigger
46
+ data-slot="accordion-trigger"
47
+ className={cn(
48
+ 'flex flex-1 cursor-pointer items-center gap-2.5 border-0 bg-transparent py-3 text-left text-ui font-medium outline-none transition-colors duration-150 ease-decelerate',
49
+ 'hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring-control/35',
50
+ // the chevron turns rather than swapping glyph: one mark, one meaning
51
+ '[&>svg]:size-3.5 [&>svg]:shrink-0 [&>svg]:text-muted-foreground [&>svg]:transition-transform [&>svg]:duration-200 [&>svg]:ease-decelerate',
52
+ 'data-open:[&>svg]:rotate-180',
53
+ className,
54
+ )}
55
+ {...props}
56
+ >
57
+ <span className="min-w-0 flex-1">{children}</span>
58
+ <ChevronDownIcon aria-hidden />
59
+ </AccordionPrimitive.Trigger>
60
+ </AccordionPrimitive.Header>
61
+ );
62
+ }
63
+
64
+ function AccordionContent({
65
+ className,
66
+ children,
67
+ ...props
68
+ }: React.ComponentProps<typeof AccordionPrimitive.Content>) {
69
+ return (
70
+ <AccordionPrimitive.Content
71
+ data-slot="accordion-content"
72
+ className={cn(
73
+ 'overflow-hidden text-xs text-muted-foreground',
74
+ 'data-open:animate-accordion-down data-closed:animate-accordion-up',
75
+ )}
76
+ {...props}
77
+ >
78
+ {/* padding on an inner element, not the animated one — animating a box
79
+ whose own padding is part of the measured height stutters at both ends */}
80
+ <div className={cn('pb-3', className)}>{children}</div>
81
+ </AccordionPrimitive.Content>
82
+ );
83
+ }
84
+
85
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
@@ -155,7 +155,7 @@ const AlertDialogDescription = React.forwardRef<
155
155
  ref={ref}
156
156
  data-slot="alert-dialog-description"
157
157
  className={cn(
158
- 'text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground',
158
+ 'text-ui text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground',
159
159
  className,
160
160
  )}
161
161
  {...props}
@@ -0,0 +1,28 @@
1
+ import * as React from 'react';
2
+ import { AspectRatio as AspectRatioPrimitive } from 'radix-ui';
3
+
4
+ import { cn } from '@rise-x/ui/lib/utils';
5
+
6
+ /*
7
+ * Holds a box at a fixed ratio so media cannot shift the layout while it loads.
8
+ * Deliberately carries no surface, radius or border of its own — the caller
9
+ * decides whether the thing inside is a thumbnail (10px) or a card (14px), and a
10
+ * radius here would clip at the wrong step.
11
+ *
12
+ * Use `MediaThumb` instead for a fixed-size square in a gallery; this is for the
13
+ * responsive case where the width is unknown and only the ratio is fixed.
14
+ */
15
+ function AspectRatio({
16
+ className,
17
+ ...props
18
+ }: React.ComponentProps<typeof AspectRatioPrimitive.Root>) {
19
+ return (
20
+ <AspectRatioPrimitive.Root
21
+ data-slot="aspect-ratio"
22
+ className={cn('[&>img]:size-full [&>img]:object-cover [&>video]:size-full', className)}
23
+ {...props}
24
+ />
25
+ );
26
+ }
27
+
28
+ export { AspectRatio };
@@ -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 };
@@ -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
+ };