@rise-x/apps-sdk 0.9.0 → 0.11.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 (92) hide show
  1. package/README.md +117 -32
  2. package/build/rsbuild/index.d.ts +6 -1
  3. package/build/rsbuild/index.js +24 -3
  4. package/build/ui/classes.json +209 -0
  5. package/build/ui/components/ai.d.ts +33 -1
  6. package/build/ui/components/app-frame.d.ts +16 -10
  7. package/build/ui/components/chat-input.d.ts +28 -0
  8. package/build/ui/components/message-scroller.d.ts +34 -10
  9. package/build/ui/components/sheet.d.ts +10 -0
  10. package/build/ui/components/thinking-rings.d.ts +4 -0
  11. package/build/ui/demo.html +26794 -0
  12. package/build/ui/index.d.ts +2 -0
  13. package/build/ui/standalone.js +60 -58
  14. package/build/ui/styles.css +1 -1
  15. package/package.json +4 -3
  16. package/template/AGENTS.md +3 -3
  17. package/template/README.md +5 -5
  18. package/template/package.json +8 -9
  19. package/template/rsbuild.config.mts +17 -0
  20. package/template/src/App.tsx +4 -1
  21. package/template/tsconfig.json +3 -1
  22. package/build/ui/reference/README.md +0 -11
  23. package/build/ui/reference/components/accordion.tsx +0 -85
  24. package/build/ui/reference/components/ai.tsx +0 -293
  25. package/build/ui/reference/components/alert-dialog.tsx +0 -207
  26. package/build/ui/reference/components/alert.tsx +0 -112
  27. package/build/ui/reference/components/app-frame.tsx +0 -71
  28. package/build/ui/reference/components/aspect-ratio.tsx +0 -28
  29. package/build/ui/reference/components/avatar.tsx +0 -158
  30. package/build/ui/reference/components/badge.tsx +0 -160
  31. package/build/ui/reference/components/button-group.tsx +0 -77
  32. package/build/ui/reference/components/button.tsx +0 -109
  33. package/build/ui/reference/components/calendar.tsx +0 -119
  34. package/build/ui/reference/components/card.tsx +0 -144
  35. package/build/ui/reference/components/carousel.tsx +0 -248
  36. package/build/ui/reference/components/chart.tsx +0 -704
  37. package/build/ui/reference/components/checkbox.tsx +0 -44
  38. package/build/ui/reference/components/collapsible.tsx +0 -43
  39. package/build/ui/reference/components/combobox.tsx +0 -146
  40. package/build/ui/reference/components/command.tsx +0 -181
  41. package/build/ui/reference/components/context-menu.tsx +0 -243
  42. package/build/ui/reference/components/data-table.tsx +0 -650
  43. package/build/ui/reference/components/date-picker.tsx +0 -218
  44. package/build/ui/reference/components/dialog.tsx +0 -172
  45. package/build/ui/reference/components/direction.tsx +0 -22
  46. package/build/ui/reference/components/dropdown-menu.tsx +0 -245
  47. package/build/ui/reference/components/empty-state.tsx +0 -63
  48. package/build/ui/reference/components/field.tsx +0 -252
  49. package/build/ui/reference/components/file-upload.tsx +0 -116
  50. package/build/ui/reference/components/hover-card.tsx +0 -64
  51. package/build/ui/reference/components/input-group.tsx +0 -157
  52. package/build/ui/reference/components/input-otp.tsx +0 -106
  53. package/build/ui/reference/components/input.tsx +0 -86
  54. package/build/ui/reference/components/item.tsx +0 -188
  55. package/build/ui/reference/components/kbd.tsx +0 -43
  56. package/build/ui/reference/components/label.tsx +0 -19
  57. package/build/ui/reference/components/list.tsx +0 -191
  58. package/build/ui/reference/components/map.css +0 -251
  59. package/build/ui/reference/components/map.tsx +0 -294
  60. package/build/ui/reference/components/menubar.tsx +0 -275
  61. package/build/ui/reference/components/message-scroller.tsx +0 -141
  62. package/build/ui/reference/components/message.tsx +0 -177
  63. package/build/ui/reference/components/nav.tsx +0 -127
  64. package/build/ui/reference/components/navigation-menu.tsx +0 -191
  65. package/build/ui/reference/components/page-header.tsx +0 -245
  66. package/build/ui/reference/components/popover.tsx +0 -76
  67. package/build/ui/reference/components/progress.tsx +0 -31
  68. package/build/ui/reference/components/radio.tsx +0 -65
  69. package/build/ui/reference/components/resizable.tsx +0 -40
  70. package/build/ui/reference/components/scroll-area.tsx +0 -55
  71. package/build/ui/reference/components/segmented.tsx +0 -45
  72. package/build/ui/reference/components/select.tsx +0 -188
  73. package/build/ui/reference/components/separator.tsx +0 -26
  74. package/build/ui/reference/components/sheet.tsx +0 -184
  75. package/build/ui/reference/components/skeleton.tsx +0 -15
  76. package/build/ui/reference/components/slider.tsx +0 -161
  77. package/build/ui/reference/components/snackbar.tsx +0 -27
  78. package/build/ui/reference/components/sonner.tsx +0 -43
  79. package/build/ui/reference/components/spinner.tsx +0 -27
  80. package/build/ui/reference/components/statistic.tsx +0 -122
  81. package/build/ui/reference/components/stepper.tsx +0 -138
  82. package/build/ui/reference/components/switch.tsx +0 -47
  83. package/build/ui/reference/components/table.tsx +0 -246
  84. package/build/ui/reference/components/textarea.tsx +0 -28
  85. package/build/ui/reference/components/timeline.tsx +0 -101
  86. package/build/ui/reference/components/toggle-group.tsx +0 -86
  87. package/build/ui/reference/components/toggle.tsx +0 -46
  88. package/build/ui/reference/components/tooltip.tsx +0 -53
  89. package/build/ui/reference/index.ts +0 -69
  90. package/build/ui/reference/lib/utils.ts +0 -34
  91. package/template/webpack.config.js +0 -112
  92. package/template/webpack.local.config.js +0 -68
@@ -1,160 +0,0 @@
1
- import * as React from 'react';
2
- import { cva, type VariantProps } from 'class-variance-authority';
3
- import { Slot } from 'radix-ui';
4
-
5
- import { cn } from '@rise-x/ui/lib/utils';
6
-
7
- /*
8
- * Badges are FILLED, never outlined — the tint alone carries the state, and a
9
- * border on a 20px chip is pure noise. Same treatment as Tag; only the radius
10
- * separates them (badge 6px, tag pill).
11
- *
12
- * The five status tones are one recipe — a translucent fill of the hue plus its
13
- * darkened `-text` variant. The text tones are darker than the raw hue on
14
- * purpose: measured over their own 12–15% fill, the undarkened values came in
15
- * at 3.7–4.5:1 and failed AA.
16
- */
17
- const badgeVariants = cva(
18
- 'group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1.5 overflow-hidden rounded-sm border-0 px-[7px] text-micro leading-none font-medium whitespace-nowrap transition-colors duration-150 ease-decelerate focus-visible:ring-3 focus-visible:ring-ring-control/35 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:pointer-events-none [&>svg]:size-3!',
19
- {
20
- variants: {
21
- variant: {
22
- /* neutral is the default: most badges are labels, not alarms */
23
- default: 'bg-fill-1 text-muted-foreground [a]:hover:bg-fill-2',
24
- neutral: 'bg-fill-1 text-muted-foreground [a]:hover:bg-fill-2',
25
- solid: 'bg-primary text-primary-foreground [a]:hover:bg-primary/85',
26
- success: 'bg-success/13 text-success-text',
27
- warning: 'bg-warning/15 text-warning-text',
28
- error: 'bg-error/12 text-error-text',
29
- info: 'bg-info/12 text-info-text',
30
- /* AI provenance — flat berry, and only for "Diana produced this".
31
- * Never on a finished answer; see the AI message component. */
32
- ai: 'bg-ai/12 text-ai-text',
33
- outline: 'border border-border text-foreground [a]:hover:bg-muted',
34
- ghost: 'text-muted-foreground hover:bg-muted hover:text-foreground',
35
- /* Kept for existing call sites. `secondary` was already a grey fill and
36
- * `destructive` a red tint, so both map onto the new recipe without
37
- * changing what they meant — destructive just gains AA-safe text. */
38
- secondary: 'bg-fill-1 text-muted-foreground [a]:hover:bg-fill-2',
39
- destructive: 'bg-error/12 text-error-text',
40
- link: 'text-foreground underline decoration-border-strong underline-offset-[3px]',
41
- /* count pill: square-ish minimum so "1" and "24" are the same shape */
42
- count: 'min-w-5 justify-center bg-fill-1 px-1.5 text-muted-foreground tabular-nums',
43
- },
44
- },
45
- defaultVariants: {
46
- variant: 'default',
47
- },
48
- },
49
- );
50
-
51
- function Badge({
52
- className,
53
- variant = 'default',
54
- asChild = false,
55
- ...props
56
- }: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
57
- const Comp = asChild ? Slot.Root : 'span';
58
-
59
- return (
60
- <Comp
61
- data-slot="badge"
62
- data-variant={variant}
63
- className={cn(badgeVariants({ variant }), className)}
64
- {...props}
65
- />
66
- );
67
- }
68
-
69
- /* Tag = categorical label (pill, grey). Chip = a removable token the user put
70
- * there (pill, grey fill, × button). Indicator = a bare dot plus text, for
71
- * inline use where even a filled badge is too much. */
72
- function Tag({ className, ...props }: React.ComponentProps<'span'>) {
73
- return (
74
- <span
75
- data-slot="tag"
76
- className={cn(
77
- 'inline-flex h-5 w-fit shrink-0 items-center gap-1.5 rounded-full bg-muted px-2 text-micro font-medium whitespace-nowrap text-muted-foreground',
78
- className,
79
- )}
80
- {...props}
81
- />
82
- );
83
- }
84
-
85
- function Chip({
86
- className,
87
- children,
88
- onRemove,
89
- removeLabel = 'Remove',
90
- ...props
91
- }: React.ComponentProps<'span'> & { onRemove?: () => void; removeLabel?: string }) {
92
- return (
93
- <span
94
- data-slot="chip"
95
- className={cn(
96
- // no outline: a chip lives inside an input, and an outline inside an
97
- // outline reads as a box in a box
98
- 'inline-flex h-6 w-fit shrink-0 items-center gap-1.5 rounded-full border-0 bg-fill-2 pr-1 pl-2.5 text-xs whitespace-nowrap',
99
- className,
100
- )}
101
- {...props}
102
- >
103
- {children}
104
- {onRemove ? (
105
- <button
106
- type="button"
107
- aria-label={removeLabel}
108
- onClick={onRemove}
109
- className="grid size-4 shrink-0 place-items-center rounded-full text-subtle transition-colors hover:bg-fill-3 hover:text-foreground"
110
- >
111
- <svg
112
- viewBox="0 0 24 24"
113
- fill="none"
114
- stroke="currentColor"
115
- strokeWidth={2.4}
116
- className="size-2.5"
117
- >
118
- <path d="M18 6L6 18M6 6l12 12" strokeLinecap="round" />
119
- </svg>
120
- </button>
121
- ) : null}
122
- </span>
123
- );
124
- }
125
-
126
- const dotVariants = cva('inline-block size-1.5 shrink-0 rounded-full', {
127
- variants: {
128
- tone: {
129
- neutral: 'bg-neutral',
130
- success: 'bg-success',
131
- warning: 'bg-warning',
132
- error: 'bg-error',
133
- info: 'bg-info',
134
- ai: 'bg-ai',
135
- },
136
- },
137
- defaultVariants: { tone: 'neutral' },
138
- });
139
-
140
- function StatusDot({
141
- className,
142
- tone = 'neutral',
143
- ...props
144
- }: React.ComponentProps<'span'> & VariantProps<typeof dotVariants>) {
145
- return (
146
- <span data-slot="status-dot" className={cn(dotVariants({ tone }), className)} {...props} />
147
- );
148
- }
149
-
150
- function StatusIndicator({ className, ...props }: React.ComponentProps<'span'>) {
151
- return (
152
- <span
153
- data-slot="status-indicator"
154
- className={cn('inline-flex items-center gap-1.5 text-xs', className)}
155
- {...props}
156
- />
157
- );
158
- }
159
-
160
- export { Badge, badgeVariants, Tag, Chip, StatusDot, StatusIndicator };
@@ -1,77 +0,0 @@
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 };
@@ -1,109 +0,0 @@
1
- import * as React from 'react';
2
- import { cva, type VariantProps } from 'class-variance-authority';
3
- import { Slot } from 'radix-ui';
4
-
5
- import { cn } from '@rise-x/ui/lib/utils';
6
-
7
- /*
8
- * 32px tall, 10px radius, 13px/500 label. Two things worth knowing:
9
- *
10
- * · `default` is NEUTRAL, not brand. Theme Neutral is the system preset
11
- * because every ecosystem carries its own brand colour, so the default call
12
- * to action is near-black and green is complementary. Use `brand` only where
13
- * the green genuinely IS the message.
14
- * · Focus is the neutral ring, not the brand ring. A control you OPERATE gets
15
- * a grey ring; only a field you ENTER DATA INTO gets brand affirmation
16
- * (see input.tsx). Mixing the two makes brand meaningless.
17
- */
18
- const buttonVariants = cva(
19
- "group/button inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-transparent bg-clip-padding text-ui leading-none font-medium whitespace-nowrap transition-[background-color,border-color,color,transform] duration-150 ease-decelerate outline-none select-none focus-visible:ring-3 focus-visible:ring-ring-control/35 active:scale-[0.975] disabled:pointer-events-none disabled:opacity-45 aria-disabled:pointer-events-none aria-disabled:opacity-45 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",
20
- {
21
- variants: {
22
- variant: {
23
- default: 'bg-primary text-primary-foreground hover:bg-primary/85',
24
- outline:
25
- 'border-border-strong bg-card hover:bg-muted aria-expanded:bg-muted dark:bg-transparent',
26
- secondary: 'bg-muted text-foreground hover:bg-fill-2 aria-expanded:bg-fill-2',
27
- ghost:
28
- 'text-muted-foreground hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground',
29
- /* Tinted secondary: fill plus coloured label. Reads as an action
30
- * without competing with the solid one next to it. */
31
- tint: 'bg-fill-1 text-foreground hover:bg-fill-2',
32
- 'tint-brand': 'bg-brand-tint text-brand-text hover:bg-brand/20',
33
- /* Destructive is a TEXT action by default — a red block is rarely what
34
- * you want next to a cancel button. `destructive-solid` is the
35
- * confirm-in-a-dialog case. */
36
- destructive: 'text-error-text hover:bg-error/10',
37
- 'destructive-solid': 'bg-error-solid text-white hover:bg-error-solid/90',
38
- brand: 'bg-brand text-[#0a0a0a] hover:bg-brand/90',
39
- /* A text link, so it has no box: the height and padding reset live in
40
- * compoundVariants below, not here — cva emits `size` AFTER `variant`,
41
- * so `h-auto p-0` written here loses to `h-control px-3` every time. */
42
- link: 'text-foreground underline decoration-border-strong underline-offset-[3px] hover:decoration-foreground active:scale-100',
43
- /* Filter trigger. Two states that must be told apart at a glance:
44
- * empty = dashed outline + muted label ("a slot you could fill"),
45
- * applied = solid fill, no dash, full-strength label. */
46
- /* The applied state has TWO hooks on purpose. `aria-pressed` fits a
47
- * filter trigger, which is genuinely a toggle. `data-filled` is for
48
- * slots that are filled rather than pressed — a file picker opens a
49
- * dialog, so claiming a pressed state there announces a control that
50
- * does not exist. One deliberate difference: `data-filled` keeps the
51
- * leading glyph. A filter's "+" stops making sense once applied; an
52
- * upload glyph still describes the control after a file is chosen. */
53
- dashed:
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 — 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',
59
- },
60
- size: {
61
- default:
62
- 'h-control px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5',
63
- xs: "h-control-xs gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
64
- sm: 'h-control-sm rounded-md px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
65
- lg: 'h-control-lg px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3',
66
- icon: 'size-control px-0',
67
- 'icon-xs': "size-control-xs rounded-md px-0 [&_svg:not([class*='size-'])]:size-3",
68
- 'icon-sm': 'size-control-sm rounded-md px-0',
69
- 'icon-lg': 'size-control-lg px-0',
70
- },
71
- },
72
- /* Applied last, so it wins the merge against whichever `size` is in play. */
73
- compoundVariants: [{ variant: 'link', class: 'h-auto p-0' }],
74
- defaultVariants: {
75
- variant: 'default',
76
- size: 'default',
77
- },
78
- },
79
- );
80
-
81
- // forwardRef (not React 19 ref-as-prop): the classic React 18 host also renders
82
- // these components, and it strips `ref` from plain function components — which
83
- // breaks Radix's own ref injection when Button is the child of an asChild Slot
84
- // (Dialog/Sheet close buttons).
85
- const Button = React.forwardRef<
86
- HTMLButtonElement,
87
- React.ComponentProps<'button'> &
88
- VariantProps<typeof buttonVariants> & {
89
- asChild?: boolean;
90
- }
91
- >(function Button(
92
- { className, variant = 'default', size = 'default', asChild = false, ...props },
93
- ref,
94
- ) {
95
- const Comp = asChild ? Slot.Root : 'button';
96
-
97
- return (
98
- <Comp
99
- ref={ref}
100
- data-slot="button"
101
- data-variant={variant}
102
- data-size={size}
103
- className={cn(buttonVariants({ variant, size, className }))}
104
- {...props}
105
- />
106
- );
107
- });
108
-
109
- export { Button, buttonVariants };
@@ -1,119 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import { cn } from '@rise-x/ui/lib/utils';
4
-
5
- /*
6
- * Date grid. Range selection is drawn as ONE continuous shape, not three
7
- * separate pills: the endpoints keep their radius on the outer edge only and the
8
- * days between lose it entirely, so a range reads as a span rather than as
9
- * "these days are individually selected".
10
- *
11
- * Brand is used here because a chosen date is an affirmative commitment — same
12
- * rule as a checked switch.
13
- */
14
- const DOW = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
15
-
16
- export interface CalendarDay {
17
- label: number;
18
- /** Outside the displayed month. */
19
- outside?: boolean;
20
- today?: boolean;
21
- /** Position within a selected range. */
22
- range?: 'start' | 'in' | 'end';
23
- }
24
-
25
- function Calendar({
26
- className,
27
- title,
28
- days,
29
- onPrev,
30
- onNext,
31
- onSelectDay,
32
- footer,
33
- ...props
34
- }: Omit<React.ComponentProps<'div'>, 'children'> & {
35
- title: React.ReactNode;
36
- days: CalendarDay[];
37
- onPrev?: () => void;
38
- onNext?: () => void;
39
- /** Picks a day. Without it the grid is a read-only display and the days stop
40
- * pretending to be pressable — an interactive-looking control that does
41
- * nothing is worse than a static one. */
42
- onSelectDay?: (day: CalendarDay, index: number) => void;
43
- footer?: React.ReactNode;
44
- }) {
45
- return (
46
- <div
47
- data-slot="calendar"
48
- className={cn('w-[294px] rounded-2xl bg-card p-3.5 shadow-pop', className)}
49
- {...props}
50
- >
51
- <div className="mb-2 flex items-center justify-between">
52
- <NavBtn label="Previous month" onClick={onPrev} d="M15 6l-6 6 6 6" />
53
- <span className="text-ui font-medium">{title}</span>
54
- <NavBtn label="Next month" onClick={onNext} d="M9 6l6 6-6 6" />
55
- </div>
56
- <div className="grid grid-cols-7 gap-x-0 gap-y-0.5">
57
- {DOW.map((d) => (
58
- <span key={d} className="grid h-6 place-items-center text-[10px] text-subtle">
59
- {d}
60
- </span>
61
- ))}
62
- {days.map((d, i) => {
63
- // Same rule as GroupedListRow: a day is a control only when there is
64
- // something to hook, otherwise it is a span and is not focusable.
65
- const Comp = onSelectDay ? 'button' : ('span' as React.ElementType);
66
- return (
67
- <Comp
68
- key={i}
69
- type={onSelectDay ? 'button' : undefined}
70
- aria-current={d.today ? 'date' : undefined}
71
- aria-pressed={onSelectDay && d.range ? true : undefined}
72
- onClick={onSelectDay ? () => onSelectDay(d, i) : undefined}
73
- className={cn(
74
- 'grid h-[30px] place-items-center rounded-md text-xs transition-colors',
75
- onSelectDay && 'cursor-pointer',
76
- !d.range && onSelectDay && 'hover:bg-muted',
77
- d.outside && 'text-subtle',
78
- d.today && !d.range && 'shadow-[inset_0_0_0_1px_var(--border-strong)]',
79
- // the middle of a range has no radius at all — that is what makes
80
- // the span continuous
81
- d.range === 'in' && 'rounded-none bg-brand-tint',
82
- d.range === 'start' && 'rounded-r-none bg-brand font-medium text-[#0a0a0a]',
83
- d.range === 'end' && 'rounded-l-none bg-brand font-medium text-[#0a0a0a]',
84
- )}
85
- >
86
- {d.label}
87
- </Comp>
88
- );
89
- })}
90
- </div>
91
- {footer ? (
92
- <div className="mt-3 flex gap-1 border-t border-border-subtle pt-2.5">{footer}</div>
93
- ) : null}
94
- </div>
95
- );
96
- }
97
-
98
- function NavBtn({ label, onClick, d }: { label: string; onClick?: () => void; d: string }) {
99
- return (
100
- <button
101
- type="button"
102
- aria-label={label}
103
- onClick={onClick}
104
- className="grid size-6 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground [&>svg]:size-3.5"
105
- >
106
- <svg
107
- viewBox="0 0 24 24"
108
- fill="none"
109
- stroke="currentColor"
110
- strokeWidth={2.5}
111
- strokeLinecap="round"
112
- >
113
- <path d={d} />
114
- </svg>
115
- </button>
116
- );
117
- }
118
-
119
- export { Calendar };
@@ -1,144 +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
- * One container, five intents — and NO outline on any of them. A card is
8
- * defined by its surface plus a whisper of depth; an outline around a white box
9
- * on a grey page is saying something the surface already said, and an outline
10
- * inside an outline is a box in a box.
11
- *
12
- * Status is carried by a TINTED LEADING GLYPH plus a badge, never by a coloured
13
- * edge. An edge stripe reads as something stuck to the card; a glyph reads as
14
- * part of it.
15
- */
16
- const cardVariants = cva('rounded-xl border-0 bg-card text-card-foreground shadow-card', {
17
- variants: {
18
- variant: {
19
- default: '',
20
- /* metric/summary carry numerals, so they get tighter padding via slots */
21
- metric: '',
22
- summary: '',
23
- /* interactive lifts 1px on hover — enough to read as pressable without
24
- * animating a shadow the size of the card */
25
- interactive:
26
- 'cursor-pointer transition-[box-shadow,transform] duration-200 ease-decelerate hover:-translate-y-px hover:shadow-[0_6px_18px_-5px_rgb(16_24_40/0.14),0_1px_3px_rgb(16_24_40/0.07)]',
27
- status: '',
28
- },
29
- },
30
- defaultVariants: { variant: 'default' },
31
- });
32
-
33
- function Card({
34
- className,
35
- variant = 'default',
36
- ...props
37
- }: React.ComponentProps<'div'> & VariantProps<typeof cardVariants>) {
38
- return (
39
- <div
40
- data-slot="card"
41
- data-variant={variant}
42
- className={cn(cardVariants({ variant }), className)}
43
- {...props}
44
- />
45
- );
46
- }
47
-
48
- function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
49
- return (
50
- <div
51
- data-slot="card-header"
52
- className={cn('flex items-start gap-3 px-4 pt-3.5 pb-3', className)}
53
- {...props}
54
- />
55
- );
56
- }
57
-
58
- /* The tinted glyph that carries status. Tone is on the glyph, not the card. */
59
- const cardGlyphVariants = cva(
60
- 'grid size-7 shrink-0 place-items-center rounded-md [&_svg]:size-3.5',
61
- {
62
- variants: {
63
- tone: {
64
- neutral: 'bg-fill-1 text-muted-foreground',
65
- success: 'bg-success/13 text-success-text',
66
- warning: 'bg-warning/15 text-warning-text',
67
- error: 'bg-error/12 text-error-text',
68
- info: 'bg-info/12 text-info-text',
69
- ai: 'bg-ai/12 text-ai-text',
70
- },
71
- },
72
- defaultVariants: { tone: 'neutral' },
73
- },
74
- );
75
-
76
- function CardGlyph({
77
- className,
78
- tone = 'neutral',
79
- ...props
80
- }: React.ComponentProps<'span'> & VariantProps<typeof cardGlyphVariants>) {
81
- return (
82
- <span
83
- data-slot="card-glyph"
84
- className={cn(cardGlyphVariants({ tone }), className)}
85
- {...props}
86
- />
87
- );
88
- }
89
-
90
- function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
91
- return (
92
- <div
93
- data-slot="card-title"
94
- className={cn('text-ui leading-tight font-medium', className)}
95
- {...props}
96
- />
97
- );
98
- }
99
-
100
- function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
101
- return (
102
- <div
103
- data-slot="card-description"
104
- className={cn('mt-0.5 text-xs text-muted-foreground', className)}
105
- {...props}
106
- />
107
- );
108
- }
109
-
110
- function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
111
- return (
112
- <div
113
- data-slot="card-content"
114
- className={cn('px-4 pb-4 [&:first-child]:pt-4', className)}
115
- {...props}
116
- />
117
- );
118
- }
119
-
120
- /* Inset separator: starts where the content starts, not at the container edge,
121
- * so the card reads as one surface rather than stacked bands. */
122
- function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
123
- return (
124
- <div
125
- data-slot="card-footer"
126
- className={cn(
127
- 'mx-4 flex items-center gap-2 border-t border-border-subtle py-3 text-xs text-muted-foreground',
128
- className,
129
- )}
130
- {...props}
131
- />
132
- );
133
- }
134
-
135
- export {
136
- Card,
137
- CardHeader,
138
- CardGlyph,
139
- CardTitle,
140
- CardDescription,
141
- CardContent,
142
- CardFooter,
143
- cardVariants,
144
- };