@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.
- package/build/ui/components/accordion.d.ts +7 -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/navigation-menu.d.ts +13 -0
- package/build/ui/components/page-header.d.ts +7 -1
- package/build/ui/index.d.ts +19 -0
- package/build/ui/reference/components/accordion.tsx +85 -0
- package/build/ui/reference/components/alert-dialog.tsx +1 -1
- 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/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 +141 -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 +2 -2
- package/build/ui/reference/components/direction.tsx +22 -0
- 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/nav.tsx +6 -0
- 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 +9 -1
- package/build/ui/reference/components/timeline.tsx +7 -0
- package/build/ui/reference/components/toggle.tsx +1 -1
- package/build/ui/reference/index.ts +19 -0
- package/build/ui/standalone.js +168 -28
- package/build/ui/styles.css +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
import { cn } from '@rise-x/ui/lib/utils';
|
|
7
|
+
import { Button } from '@rise-x/ui/components/button';
|
|
8
|
+
import { Input } from '@rise-x/ui/components/input';
|
|
9
|
+
import { Textarea } from '@rise-x/ui/components/textarea';
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* ONE bordered container that the control and its addons share — the group
|
|
13
|
+
* carries the field chrome (surface, border, focus ring) and the Input inside
|
|
14
|
+
* is stripped bare, so an addon never doubles a border the way two adjacent
|
|
15
|
+
* boxes would. Supersedes the old InputGroup/InputAffix border-merging pair.
|
|
16
|
+
*
|
|
17
|
+
* Focus and error live on the GROUP, driven by :has() from the control inside:
|
|
18
|
+
* the whole object is the field, so the whole object affirms. Brand ring for
|
|
19
|
+
* data entry, error tokens for invalid — same contract as Input itself.
|
|
20
|
+
*/
|
|
21
|
+
function InputGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
data-slot="input-group"
|
|
25
|
+
role="group"
|
|
26
|
+
className={cn(
|
|
27
|
+
'group/input-group relative flex w-full items-center rounded-lg border border-input bg-card transition-[border-color,box-shadow] duration-100 outline-none',
|
|
28
|
+
'h-control min-w-0 has-[>textarea]:h-auto',
|
|
29
|
+
|
|
30
|
+
// Variants based on alignment.
|
|
31
|
+
'has-[>[data-align=inline-start]]:[&>input]:pl-2',
|
|
32
|
+
'has-[>[data-align=inline-end]]:[&>input]:pr-2',
|
|
33
|
+
'has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-2.5',
|
|
34
|
+
'has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-2.5',
|
|
35
|
+
|
|
36
|
+
// Focus state — the brand ring Input uses, lifted onto the group.
|
|
37
|
+
'has-[[data-slot=input-group-control]:focus-visible]:border-brand has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-brand/12',
|
|
38
|
+
|
|
39
|
+
/* Error state. The ring needs its own width — a colour alone renders
|
|
40
|
+
* nothing — and it is scoped to focus like Input's, with both has()
|
|
41
|
+
* conditions stacked so it outranks the brand focus ring above rather
|
|
42
|
+
* than racing it on source order. */
|
|
43
|
+
'has-[[data-slot][aria-invalid=true]]:border-error',
|
|
44
|
+
'has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:border-error',
|
|
45
|
+
'has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-3',
|
|
46
|
+
'has-[[data-slot][aria-invalid=true]]:has-[[data-slot=input-group-control]:focus-visible]:ring-error/18',
|
|
47
|
+
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const inputGroupAddonVariants = cva(
|
|
56
|
+
// addon text matches the control text (13px), muted because it is not the value
|
|
57
|
+
'flex h-auto cursor-text items-center justify-center gap-2 py-1 text-ui font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>svg:not([class*="size-"])]:size-3.5',
|
|
58
|
+
{
|
|
59
|
+
variants: {
|
|
60
|
+
align: {
|
|
61
|
+
// buttons and kbds tuck into the addon padding so they sit flush
|
|
62
|
+
'inline-start': 'order-first pl-2.5 has-[>button]:ml-[-6px] has-[>kbd]:ml-[-5px]',
|
|
63
|
+
'inline-end': 'order-last pr-2.5 has-[>button]:mr-[-6px] has-[>kbd]:mr-[-5px]',
|
|
64
|
+
'block-start':
|
|
65
|
+
'order-first w-full justify-start px-2.5 pt-2.5 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2.5',
|
|
66
|
+
'block-end':
|
|
67
|
+
'order-last w-full justify-start px-2.5 pb-2.5 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2.5',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
defaultVariants: {
|
|
71
|
+
align: 'inline-start',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
function InputGroupAddon({
|
|
77
|
+
className,
|
|
78
|
+
align = 'inline-start',
|
|
79
|
+
onClick,
|
|
80
|
+
...props
|
|
81
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof inputGroupAddonVariants>) {
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
role="group"
|
|
85
|
+
data-slot="input-group-addon"
|
|
86
|
+
data-align={align}
|
|
87
|
+
className={cn(inputGroupAddonVariants({ align }), className)}
|
|
88
|
+
/* Click-to-focus runs ALONGSIDE a caller's onClick, never instead of it —
|
|
89
|
+
* the same rule message-scroller.tsx states for onScroll. And it targets
|
|
90
|
+
* the group's control by slot, not by tag: a textarea group is one field
|
|
91
|
+
* too, and querying for `input` left its addons dead. */
|
|
92
|
+
onClick={(e) => {
|
|
93
|
+
onClick?.(e);
|
|
94
|
+
if ((e.target as HTMLElement).closest('button')) return;
|
|
95
|
+
e.currentTarget.parentElement
|
|
96
|
+
?.querySelector<HTMLElement>('[data-slot=input-group-control]')
|
|
97
|
+
?.focus();
|
|
98
|
+
}}
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Thin passthrough — the kit Button already has the xs / icon-xs steps an
|
|
105
|
+
* in-field action needs, so there is no separate size scale to maintain. */
|
|
106
|
+
function InputGroupButton({
|
|
107
|
+
type = 'button',
|
|
108
|
+
variant = 'ghost',
|
|
109
|
+
size = 'xs',
|
|
110
|
+
...props
|
|
111
|
+
}: React.ComponentProps<typeof Button>) {
|
|
112
|
+
return <Button type={type} variant={variant} size={size} {...props} />;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function InputGroupText({ className, ...props }: React.ComponentProps<'span'>) {
|
|
116
|
+
return (
|
|
117
|
+
<span
|
|
118
|
+
className={cn(
|
|
119
|
+
'flex items-center gap-2 text-ui text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*="size-"])]:size-3.5',
|
|
120
|
+
className,
|
|
121
|
+
)}
|
|
122
|
+
{...props}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function InputGroupInput({ className, ...props }: React.ComponentProps<'input'>) {
|
|
128
|
+
return (
|
|
129
|
+
<Input
|
|
130
|
+
data-slot="input-group-control"
|
|
131
|
+
className={cn('flex-1 rounded-none border-0 bg-transparent focus-visible:ring-0', className)}
|
|
132
|
+
{...props}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function InputGroupTextarea({ className, ...props }: React.ComponentProps<'textarea'>) {
|
|
138
|
+
return (
|
|
139
|
+
<Textarea
|
|
140
|
+
data-slot="input-group-control"
|
|
141
|
+
className={cn(
|
|
142
|
+
'flex-1 resize-none rounded-none border-0 bg-transparent py-2.5 focus-visible:ring-0',
|
|
143
|
+
className,
|
|
144
|
+
)}
|
|
145
|
+
{...props}
|
|
146
|
+
/>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
InputGroup,
|
|
152
|
+
InputGroupAddon,
|
|
153
|
+
InputGroupButton,
|
|
154
|
+
InputGroupText,
|
|
155
|
+
InputGroupInput,
|
|
156
|
+
InputGroupTextarea,
|
|
157
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { OTPInput, OTPInputContext } from 'input-otp';
|
|
5
|
+
import { MinusIcon } from 'lucide-react';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@rise-x/ui/lib/utils';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* One-time-code entry. A row of slots that behaves like a single field: paste
|
|
11
|
+
* fills every slot, backspace walks back, and the caret is drawn rather than
|
|
12
|
+
* native because there is no real caret to show in an empty box.
|
|
13
|
+
*
|
|
14
|
+
* IT IS ONE FIELD, SO IT TAKES ONE FOCUS TREATMENT. The active slot gets the
|
|
15
|
+
* brand ring — data going in, same as Input — and only the active one, because a
|
|
16
|
+
* row of six rings is a row of six fields.
|
|
17
|
+
*
|
|
18
|
+
* SLOTS SHARE THEIR BORDERS. Same arithmetic as InputGroup and ButtonGroup: the
|
|
19
|
+
* inner edge is drawn once and only the outer corners keep the radius, so a group
|
|
20
|
+
* of six reads as one control rather than six boxes in a row.
|
|
21
|
+
*
|
|
22
|
+
* GROUP IN THREES, NOT SIXES. A six-digit code split 3–3 is read as two chunks
|
|
23
|
+
* and typed more accurately than an undifferentiated run; `InputOTPSeparator` is
|
|
24
|
+
* what marks the split, and it is the container's, not a slot's.
|
|
25
|
+
*/
|
|
26
|
+
const InputOTP = React.forwardRef<
|
|
27
|
+
React.ComponentRef<typeof OTPInput>,
|
|
28
|
+
React.ComponentProps<typeof OTPInput>
|
|
29
|
+
>(function InputOTP({ className, containerClassName, ...props }, ref) {
|
|
30
|
+
return (
|
|
31
|
+
<OTPInput
|
|
32
|
+
ref={ref}
|
|
33
|
+
data-slot="input-otp"
|
|
34
|
+
containerClassName={cn('flex items-center gap-2 has-disabled:opacity-45', containerClassName)}
|
|
35
|
+
className={cn('disabled:cursor-not-allowed', className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
data-slot="input-otp-group"
|
|
45
|
+
className={cn(
|
|
46
|
+
'flex items-center',
|
|
47
|
+
// shared edges, outer corners only
|
|
48
|
+
'[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0',
|
|
49
|
+
'[&>*:not(:last-child)]:rounded-r-none',
|
|
50
|
+
className,
|
|
51
|
+
)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const InputOTPSlot = React.forwardRef<
|
|
58
|
+
HTMLDivElement,
|
|
59
|
+
React.ComponentProps<'div'> & { index: number }
|
|
60
|
+
>(function InputOTPSlot({ index, className, ...props }, ref) {
|
|
61
|
+
const context = React.useContext(OTPInputContext);
|
|
62
|
+
const slot = context?.slots[index];
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<div
|
|
66
|
+
ref={ref}
|
|
67
|
+
data-slot="input-otp-slot"
|
|
68
|
+
data-active={slot?.isActive ? '' : undefined}
|
|
69
|
+
className={cn(
|
|
70
|
+
'relative grid h-control-lg w-9 place-items-center border border-input bg-card text-ui tabular-nums transition-[border-color,box-shadow] duration-100 first:rounded-l-lg last:rounded-r-lg',
|
|
71
|
+
// the active slot is the focused field, and it has to sit above its
|
|
72
|
+
// neighbours or the ring is clipped by the shared edge
|
|
73
|
+
'data-active:z-10 data-active:border-brand data-active:ring-3 data-active:ring-brand/12',
|
|
74
|
+
'aria-invalid:border-error',
|
|
75
|
+
className,
|
|
76
|
+
)}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
{slot?.char}
|
|
80
|
+
{/* a drawn caret: an empty slot has no native one to show */}
|
|
81
|
+
{slot?.hasFakeCaret ? (
|
|
82
|
+
<div className="pointer-events-none absolute inset-0 grid place-items-center">
|
|
83
|
+
{/* no duration utility: --animate-caret-blink already carries 1.25s,
|
|
84
|
+
and a duration-* would fight it rather than tune it */}
|
|
85
|
+
<div className="h-4 w-px animate-caret-blink bg-foreground" />
|
|
86
|
+
</div>
|
|
87
|
+
) : null}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
function InputOTPSeparator({ className, ...props }: React.ComponentProps<'div'>) {
|
|
93
|
+
return (
|
|
94
|
+
<div
|
|
95
|
+
data-slot="input-otp-separator"
|
|
96
|
+
role="separator"
|
|
97
|
+
aria-hidden
|
|
98
|
+
className={cn('grid place-items-center text-subtle [&>svg]:size-3', className)}
|
|
99
|
+
{...props}
|
|
100
|
+
>
|
|
101
|
+
<MinusIcon />
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
|
|
@@ -79,36 +79,8 @@ function InputAction({ className, ...props }: React.ComponentProps<'button'>) {
|
|
|
79
79
|
);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/*
|
|
83
|
-
*
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div
|
|
87
|
-
data-slot="input-group"
|
|
88
|
-
className={cn(
|
|
89
|
-
'flex [&>input]:rounded-none',
|
|
90
|
-
'[&>[data-slot=input-affix]:first-child]:rounded-l-lg [&>[data-slot=input-affix]:first-child]:border-r-0',
|
|
91
|
-
'[&>[data-slot=input-affix]:last-child]:rounded-r-lg [&>[data-slot=input-affix]:last-child]:border-l-0',
|
|
92
|
-
'[&>[data-slot=input-affix]:first-child+input]:rounded-r-lg',
|
|
93
|
-
'[&>input:has(+[data-slot=input-affix])]:rounded-l-lg',
|
|
94
|
-
className,
|
|
95
|
-
)}
|
|
96
|
-
{...props}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function InputAffix({ className, ...props }: React.ComponentProps<'span'>) {
|
|
102
|
-
return (
|
|
103
|
-
<span
|
|
104
|
-
data-slot="input-affix"
|
|
105
|
-
className={cn(
|
|
106
|
-
'inline-flex h-control shrink-0 items-center border border-input bg-muted px-2.5 text-xs text-muted-foreground',
|
|
107
|
-
className,
|
|
108
|
-
)}
|
|
109
|
-
{...props}
|
|
110
|
-
/>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
82
|
+
/* The old InputGroup/InputAffix border-merging pair lived here; superseded by
|
|
83
|
+
* components/input-group.tsx, where the GROUP owns the field chrome and addons
|
|
84
|
+
* sit inside one border instead of merging two. */
|
|
113
85
|
|
|
114
|
-
export { Input, InputNumeric, InputField, InputAction
|
|
86
|
+
export { Input, InputNumeric, InputField, InputAction };
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
import { Separator } from '@rise-x/ui/components/separator';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* A media + content + actions row for things that are OBJECTS rather than table
|
|
10
|
+
* records — an integration, a teammate, a file. Complements GroupedList (dense,
|
|
11
|
+
* divider-driven) rather than replacing it: Item rows are self-contained and
|
|
12
|
+
* can stand alone, be a link, or sit in a plain stack.
|
|
13
|
+
*
|
|
14
|
+
* NO SURFACE BY DEFAULT, same rule as Accordion: on a card it is already on a
|
|
15
|
+
* surface. `outline` is for the standalone case, `muted` for a soft well —
|
|
16
|
+
* fill, not border, per the grey budget.
|
|
17
|
+
*/
|
|
18
|
+
/* No role="list" here. The ARIA list pattern requires every child to be a
|
|
19
|
+
* listitem, and Item is `asChild`-friendly — it is routinely a Link or a button
|
|
20
|
+
* carrying its own role, which a listitem wrapper would either fight or hide.
|
|
21
|
+
* A group of interactive rows is not a list to a screen reader; leaving the
|
|
22
|
+
* container generic keeps each row's own semantics intact. */
|
|
23
|
+
function ItemGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
data-slot="item-group"
|
|
27
|
+
className={cn('group/item-group flex flex-col', className)}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function ItemSeparator({ className, ...props }: React.ComponentProps<typeof Separator>) {
|
|
34
|
+
return (
|
|
35
|
+
<Separator
|
|
36
|
+
data-slot="item-separator"
|
|
37
|
+
orientation="horizontal"
|
|
38
|
+
className={cn('my-0', className)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const itemVariants = cva(
|
|
45
|
+
// grey focus ring — an item you operate is chrome, not data entry
|
|
46
|
+
'group/item flex flex-wrap items-center rounded-lg border border-transparent text-ui transition-colors duration-100 outline-none focus-visible:ring-3 focus-visible:ring-ring-control/35 [a]:transition-colors [a]:hover:bg-fill-0',
|
|
47
|
+
{
|
|
48
|
+
variants: {
|
|
49
|
+
variant: {
|
|
50
|
+
default: 'bg-transparent',
|
|
51
|
+
outline: 'border-border',
|
|
52
|
+
muted: 'bg-fill-0',
|
|
53
|
+
},
|
|
54
|
+
size: {
|
|
55
|
+
default: 'gap-4 p-4',
|
|
56
|
+
sm: 'gap-2.5 px-4 py-3',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
defaultVariants: {
|
|
60
|
+
variant: 'default',
|
|
61
|
+
size: 'default',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
function Item({
|
|
67
|
+
className,
|
|
68
|
+
variant = 'default',
|
|
69
|
+
size = 'default',
|
|
70
|
+
asChild = false,
|
|
71
|
+
...props
|
|
72
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof itemVariants> & { asChild?: boolean }) {
|
|
73
|
+
const Comp = asChild ? Slot.Root : 'div';
|
|
74
|
+
return (
|
|
75
|
+
<Comp
|
|
76
|
+
data-slot="item"
|
|
77
|
+
data-variant={variant}
|
|
78
|
+
data-size={size}
|
|
79
|
+
className={cn(itemVariants({ variant, size, className }))}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const itemMediaVariants = cva(
|
|
86
|
+
'flex shrink-0 items-center justify-center gap-2 group-has-[[data-slot=item-description]]/item:translate-y-0.5 group-has-[[data-slot=item-description]]/item:self-start [&_svg]:pointer-events-none',
|
|
87
|
+
{
|
|
88
|
+
variants: {
|
|
89
|
+
variant: {
|
|
90
|
+
default: 'bg-transparent',
|
|
91
|
+
// fill carries the icon tile — no border on a 32px square
|
|
92
|
+
icon: 'size-8 rounded-md bg-muted [&_svg:not([class*="size-"])]:size-4',
|
|
93
|
+
image: 'size-10 overflow-hidden rounded-md [&_img]:size-full [&_img]:object-cover',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
defaultVariants: {
|
|
97
|
+
variant: 'default',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
function ItemMedia({
|
|
103
|
+
className,
|
|
104
|
+
variant = 'default',
|
|
105
|
+
...props
|
|
106
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof itemMediaVariants>) {
|
|
107
|
+
return (
|
|
108
|
+
<div
|
|
109
|
+
data-slot="item-media"
|
|
110
|
+
data-variant={variant}
|
|
111
|
+
className={cn(itemMediaVariants({ variant, className }))}
|
|
112
|
+
{...props}
|
|
113
|
+
/>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function ItemContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
118
|
+
return (
|
|
119
|
+
<div
|
|
120
|
+
data-slot="item-content"
|
|
121
|
+
className={cn('flex flex-1 flex-col gap-1 [&+[data-slot=item-content]]:flex-none', className)}
|
|
122
|
+
{...props}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function ItemTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
128
|
+
return (
|
|
129
|
+
<div
|
|
130
|
+
data-slot="item-title"
|
|
131
|
+
className={cn('flex w-fit items-center gap-2 text-ui leading-snug font-medium', className)}
|
|
132
|
+
{...props}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function ItemDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
138
|
+
return (
|
|
139
|
+
<p
|
|
140
|
+
data-slot="item-description"
|
|
141
|
+
className={cn(
|
|
142
|
+
'line-clamp-2 text-xs leading-normal font-normal text-balance text-muted-foreground',
|
|
143
|
+
'[&>a]:underline [&>a]:underline-offset-3 [&>a:hover]:text-foreground',
|
|
144
|
+
className,
|
|
145
|
+
)}
|
|
146
|
+
{...props}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function ItemActions({ className, ...props }: React.ComponentProps<'div'>) {
|
|
152
|
+
return (
|
|
153
|
+
<div data-slot="item-actions" className={cn('flex items-center gap-2', className)} {...props} />
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function ItemHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
158
|
+
return (
|
|
159
|
+
<div
|
|
160
|
+
data-slot="item-header"
|
|
161
|
+
className={cn('flex basis-full items-center justify-between gap-2', className)}
|
|
162
|
+
{...props}
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function ItemFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
168
|
+
return (
|
|
169
|
+
<div
|
|
170
|
+
data-slot="item-footer"
|
|
171
|
+
className={cn('flex basis-full items-center justify-between gap-2', className)}
|
|
172
|
+
{...props}
|
|
173
|
+
/>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
Item,
|
|
179
|
+
ItemMedia,
|
|
180
|
+
ItemContent,
|
|
181
|
+
ItemActions,
|
|
182
|
+
ItemGroup,
|
|
183
|
+
ItemSeparator,
|
|
184
|
+
ItemTitle,
|
|
185
|
+
ItemDescription,
|
|
186
|
+
ItemHeader,
|
|
187
|
+
ItemFooter,
|
|
188
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@rise-x/ui/lib/utils';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* A key cap. Tooltip already styles a `data-slot=kbd` descendant on its inverted
|
|
7
|
+
* surface, so this component finally supplies the thing that selector was written
|
|
8
|
+
* for — until now every call site hand-rolled it.
|
|
9
|
+
*
|
|
10
|
+
* INHERITS ITS COLOUR. The cap is a translucent fill plus `currentColor`, never a
|
|
11
|
+
* fixed grey on white: a shortcut hint appears in a menu row, in a tooltip on the
|
|
12
|
+
* inverted surface, and in body copy, and a hardcoded pair of colours is wrong in
|
|
13
|
+
* two of those three. `bg-fill-*` sits on whatever is behind it, which is exactly
|
|
14
|
+
* the property needed here.
|
|
15
|
+
*
|
|
16
|
+
* 6px radius — the badge step. A key cap is the same size class as a badge, and
|
|
17
|
+
* anything rounder reads as a pill.
|
|
18
|
+
*/
|
|
19
|
+
function Kbd({ className, ...props }: React.ComponentProps<'kbd'>) {
|
|
20
|
+
return (
|
|
21
|
+
<kbd
|
|
22
|
+
data-slot="kbd"
|
|
23
|
+
className={cn(
|
|
24
|
+
'inline-flex h-[18px] min-w-[18px] shrink-0 items-center justify-center gap-0.5 rounded-sm bg-fill-2 px-1 font-sans text-[10px] font-medium text-current select-none',
|
|
25
|
+
className,
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* A sequence — ⌘ then K. The separator is the container's, not the caps'. */
|
|
33
|
+
function KbdGroup({ className, ...props }: React.ComponentProps<'span'>) {
|
|
34
|
+
return (
|
|
35
|
+
<span
|
|
36
|
+
data-slot="kbd-group"
|
|
37
|
+
className={cn('inline-flex items-center gap-1 text-current', className)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Kbd, KbdGroup };
|
|
@@ -8,7 +8,7 @@ function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimiti
|
|
|
8
8
|
<LabelPrimitive.Root
|
|
9
9
|
data-slot="label"
|
|
10
10
|
className={cn(
|
|
11
|
-
'flex items-center gap-2 text-
|
|
11
|
+
'flex items-center gap-2 text-ui leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
|
|
12
12
|
className,
|
|
13
13
|
)}
|
|
14
14
|
{...props}
|