@stagewise/ui 0.15.0 → 0.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stagewise/ui",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Customized shadcn/ui components built on Base UI primitives, for use across stagewise projects.",
5
5
  "type": "module",
6
6
  "license": "MIT AND OFL-1.1",
@@ -55,7 +55,7 @@
55
55
  "@types/react": "19.2.18",
56
56
  "@types/react-dom": "19.2.4",
57
57
  "@stagewise/typescript-config": "workspace:*",
58
- "typescript": "5.9.3"
58
+ "typescript": "7.0.2"
59
59
  },
60
60
  "keywords": [
61
61
  "react",
@@ -0,0 +1,207 @@
1
+ import * as React from 'react';
2
+ import { mergeProps } from '@base-ui/react/merge-props';
3
+ import { useRender } from '@base-ui/react/use-render';
4
+ import { cva, type VariantProps } from 'class-variance-authority';
5
+ import { cn } from '../../lib/utils';
6
+
7
+ import { Button } from './button';
8
+
9
+ const attachmentVariants = cva(
10
+ 'group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive/30 data-[state=idle]:border-dashed',
11
+ {
12
+ variants: {
13
+ size: {
14
+ default:
15
+ 'gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2',
16
+ sm: 'gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5',
17
+ xs: 'gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1',
18
+ },
19
+ orientation: {
20
+ horizontal: 'min-w-40 items-center',
21
+ vertical: 'w-24 flex-col has-data-[slot=attachment-content]:w-30',
22
+ },
23
+ },
24
+ },
25
+ );
26
+
27
+ function Attachment({
28
+ className,
29
+ state = 'done',
30
+ size = 'default',
31
+ orientation = 'horizontal',
32
+ ...props
33
+ }: React.ComponentProps<'div'> &
34
+ VariantProps<typeof attachmentVariants> & {
35
+ state?: 'idle' | 'uploading' | 'processing' | 'error' | 'done';
36
+ }) {
37
+ return (
38
+ <div
39
+ data-slot="attachment"
40
+ data-state={state}
41
+ data-size={size}
42
+ data-orientation={orientation}
43
+ className={cn(attachmentVariants({ size, orientation }), className)}
44
+ {...props}
45
+ />
46
+ );
47
+ }
48
+
49
+ const attachmentMediaVariants = cva(
50
+ "relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive/10 group-data-[state=error]/attachment:text-destructive group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5",
51
+ {
52
+ variants: {
53
+ variant: {
54
+ icon: '',
55
+ image:
56
+ 'opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover',
57
+ },
58
+ },
59
+ defaultVariants: {
60
+ variant: 'icon',
61
+ },
62
+ },
63
+ );
64
+
65
+ function AttachmentMedia({
66
+ className,
67
+ variant = 'icon',
68
+ ...props
69
+ }: React.ComponentProps<'div'> & VariantProps<typeof attachmentMediaVariants>) {
70
+ return (
71
+ <div
72
+ data-slot="attachment-media"
73
+ data-variant={variant}
74
+ className={cn(attachmentMediaVariants({ variant }), className)}
75
+ {...props}
76
+ />
77
+ );
78
+ }
79
+
80
+ function AttachmentContent({
81
+ className,
82
+ ...props
83
+ }: React.ComponentProps<'div'>) {
84
+ return (
85
+ <div
86
+ data-slot="attachment-content"
87
+ className={cn(
88
+ 'max-w-full min-w-0 flex-1 leading-tight group-data-[orientation=vertical]/attachment:px-1',
89
+ className,
90
+ )}
91
+ {...props}
92
+ />
93
+ );
94
+ }
95
+
96
+ function AttachmentTitle({
97
+ className,
98
+ ...props
99
+ }: React.ComponentProps<'span'>) {
100
+ return (
101
+ <span
102
+ data-slot="attachment-title"
103
+ className={cn(
104
+ 'block max-w-full min-w-0 truncate font-medium group-data-[state=processing]/attachment:shimmer group-data-[state=uploading]/attachment:shimmer',
105
+ className,
106
+ )}
107
+ {...props}
108
+ />
109
+ );
110
+ }
111
+
112
+ function AttachmentDescription({
113
+ className,
114
+ ...props
115
+ }: React.ComponentProps<'span'>) {
116
+ return (
117
+ <span
118
+ data-slot="attachment-description"
119
+ className={cn(
120
+ 'mt-0.5 block min-w-0 truncate text-xs text-muted-foreground group-data-[state=error]/attachment:text-destructive/80',
121
+ 'max-w-full',
122
+ className,
123
+ )}
124
+ {...props}
125
+ />
126
+ );
127
+ }
128
+
129
+ function AttachmentActions({
130
+ className,
131
+ ...props
132
+ }: React.ComponentProps<'div'>) {
133
+ return (
134
+ <div
135
+ data-slot="attachment-actions"
136
+ className={cn(
137
+ 'relative z-20 flex shrink-0 items-center group-data-[orientation=vertical]/attachment:absolute group-data-[orientation=vertical]/attachment:top-3 group-data-[orientation=vertical]/attachment:right-3 group-data-[orientation=vertical]/attachment:gap-1',
138
+ className,
139
+ )}
140
+ {...props}
141
+ />
142
+ );
143
+ }
144
+
145
+ function AttachmentAction({
146
+ className,
147
+ variant,
148
+ size = 'icon-xs',
149
+ ...props
150
+ }: React.ComponentProps<typeof Button>) {
151
+ return (
152
+ <Button
153
+ data-slot="attachment-action"
154
+ variant={variant ?? 'ghost'}
155
+ size={size}
156
+ className={cn(className)}
157
+ {...props}
158
+ />
159
+ );
160
+ }
161
+
162
+ function AttachmentTrigger({
163
+ className,
164
+ render,
165
+ type,
166
+ ...props
167
+ }: useRender.ComponentProps<'button'>) {
168
+ return useRender({
169
+ defaultTagName: 'button',
170
+ props: mergeProps<'button'>(
171
+ {
172
+ type: render ? type : (type ?? 'button'),
173
+ className: cn('absolute inset-0 z-10 outline-none', className),
174
+ },
175
+ props,
176
+ ),
177
+ render,
178
+ state: {
179
+ slot: 'attachment-trigger',
180
+ },
181
+ });
182
+ }
183
+
184
+ function AttachmentGroup({ className, ...props }: React.ComponentProps<'div'>) {
185
+ return (
186
+ <div
187
+ data-slot="attachment-group"
188
+ className={cn(
189
+ 'flex min-w-0 scroll-fade-x snap-x snap-mandatory scroll-px-1 no-scrollbar gap-3 overflow-x-auto overscroll-x-contain py-1 *:data-[slot=attachment]:flex-none *:data-[slot=attachment]:snap-start',
190
+ className,
191
+ )}
192
+ {...props}
193
+ />
194
+ );
195
+ }
196
+
197
+ export {
198
+ Attachment,
199
+ AttachmentGroup,
200
+ AttachmentMedia,
201
+ AttachmentContent,
202
+ AttachmentTitle,
203
+ AttachmentDescription,
204
+ AttachmentActions,
205
+ AttachmentAction,
206
+ AttachmentTrigger,
207
+ };
@@ -64,6 +64,7 @@ function MessageScrollerViewport({
64
64
  function MessageScrollerContent({
65
65
  className,
66
66
  spacerClassName,
67
+ style,
67
68
  ...props
68
69
  }: React.ComponentProps<typeof MessageScrollerPrimitive.Content>) {
69
70
  return (
@@ -78,6 +79,7 @@ function MessageScrollerContent({
78
79
  />
79
80
  )}
80
81
  {...props}
82
+ style={{ ...style, minWidth: 0 }}
81
83
  />
82
84
  );
83
85
  }
@@ -14,6 +14,7 @@ function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
14
14
  function PopoverContent({
15
15
  className,
16
16
  positionerClassName,
17
+ anchor,
17
18
  align = 'center',
18
19
  alignOffset = 0,
19
20
  side = 'bottom',
@@ -23,11 +24,17 @@ function PopoverContent({
23
24
  }: PopoverPrimitive.Popup.Props &
24
25
  Pick<
25
26
  PopoverPrimitive.Positioner.Props,
26
- 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'collisionAvoidance'
27
+ | 'anchor'
28
+ | 'align'
29
+ | 'alignOffset'
30
+ | 'side'
31
+ | 'sideOffset'
32
+ | 'collisionAvoidance'
27
33
  > & { positionerClassName?: string }) {
28
34
  return (
29
35
  <PopoverPrimitive.Portal>
30
36
  <PopoverPrimitive.Positioner
37
+ anchor={anchor}
31
38
  align={align}
32
39
  alignOffset={alignOffset}
33
40
  side={side}
@@ -25,6 +25,7 @@ function ScrollArea({
25
25
  >
26
26
  <ScrollAreaPrimitive.Content
27
27
  data-slot="scroll-area-content"
28
+ style={{ minWidth: 0 }}
28
29
  className="flex min-h-full flex-col"
29
30
  >
30
31
  {children}
@@ -4,7 +4,10 @@ function Skeleton({ className, ...props }: React.ComponentProps<'div'>) {
4
4
  return (
5
5
  <div
6
6
  data-slot="skeleton"
7
- className={cn('animate-pulse rounded-md bg-muted', className)}
7
+ className={cn(
8
+ 'animate-pulse rounded-md bg-muted in-data-[slot=sidebar]:bg-sidebar-skeleton',
9
+ className,
10
+ )}
8
11
  {...props}
9
12
  />
10
13
  );
@@ -10,7 +10,10 @@ function Spinner({
10
10
  data-slot="spinner"
11
11
  role="status"
12
12
  aria-label="Loading"
13
- className={cn('size-4 animate-spin', className)}
13
+ // h-4 w-4, not size-4: containers size icons without a size-* class
14
+ // (a size sm button's are 14px), so the spinner takes the size of the
15
+ // icon it stands in for.
16
+ className={cn('h-4 w-4 animate-spin', className)}
14
17
  {...props}
15
18
  />
16
19
  );
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export * from './components/ui/accordion';
9
9
  export * from './components/ui/alert';
10
10
  export * from './components/ui/alert-dialog';
11
11
  export * from './components/ui/aspect-ratio';
12
+ export * from './components/ui/attachment';
12
13
  export * from './components/ui/avatar';
13
14
  export * from './components/ui/badge';
14
15
  export * from './components/ui/breadcrumb';
@@ -57,6 +57,8 @@
57
57
  --sidebar-primary: var(--color-primary-solid);
58
58
  --sidebar-primary-foreground: var(--color-solid-foreground);
59
59
  --sidebar-accent: var(--color-base-150);
60
+ /* Skeletons on the sidebar; muted equals its surface in light mode. */
61
+ --sidebar-skeleton: var(--color-base-150);
60
62
  --sidebar-accent-foreground: var(--color-base-900);
61
63
  --sidebar-border: var(--border);
62
64
  --sidebar-ring: var(--color-primary-solid);
@@ -113,6 +115,7 @@
113
115
  var(--color-base-700) 60%,
114
116
  var(--color-base-600)
115
117
  );
118
+ --sidebar-skeleton: var(--color-base-600);
116
119
  --sidebar-accent-foreground: var(--color-base-200);
117
120
  --sidebar-border: var(--border);
118
121
  --sidebar-ring: var(--color-primary-solid);
@@ -28,6 +28,7 @@
28
28
  @import "./derived-utilities.css";
29
29
  @import "./animations.css";
30
30
  @import "./scroll-fade.css";
31
+ @import "./shimmer.css";
31
32
  @import "./bridge.css";
32
33
  @import "./tailwind-tokens.css";
33
34
 
@@ -114,3 +114,86 @@
114
114
  --scroll-fade-b-size: calc(var(--spacing) * --value(integer));
115
115
  --scroll-fade-b-size: --value([length], [percentage]);
116
116
  }
117
+
118
+ /* Horizontal fade from shadcn/tailwind.css. */
119
+ @property --scroll-fade-s {
120
+ syntax: "<length-percentage>";
121
+ inherits: false;
122
+ initial-value: 0px;
123
+ }
124
+
125
+ @property --scroll-fade-e {
126
+ syntax: "<length-percentage>";
127
+ inherits: false;
128
+ initial-value: 0px;
129
+ }
130
+
131
+ @theme inline {
132
+ @keyframes scroll-fade-reveal-s {
133
+ from {
134
+ --scroll-fade-s: 0px;
135
+ }
136
+ to {
137
+ --scroll-fade-s: var(
138
+ --_scroll-fade-size-s,
139
+ var(--scroll-fade-size, min(12%, calc(var(--spacing) * 10)))
140
+ );
141
+ }
142
+ }
143
+
144
+ @keyframes scroll-fade-reveal-e {
145
+ from {
146
+ --scroll-fade-e: var(
147
+ --_scroll-fade-size-e,
148
+ var(--scroll-fade-size, min(12%, calc(var(--spacing) * 10)))
149
+ );
150
+ }
151
+ to {
152
+ --scroll-fade-e: 0px;
153
+ }
154
+ }
155
+ }
156
+
157
+ @utility scroll-fade-x {
158
+ --_scroll-fade-size-s: var(
159
+ --scroll-fade-s-size,
160
+ var(--scroll-fade-size, min(12%, calc(var(--spacing) * 10)))
161
+ );
162
+ --_scroll-fade-size-e: var(
163
+ --scroll-fade-e-size,
164
+ var(--scroll-fade-size, min(12%, calc(var(--spacing) * 10)))
165
+ );
166
+ --scroll-fade-inline: linear-gradient(
167
+ to right,
168
+ transparent 0,
169
+ #000 var(--scroll-fade-s, 0px),
170
+ #000 calc(100% - var(--scroll-fade-e, 0px)),
171
+ transparent 100%
172
+ );
173
+ &:where([dir="rtl"], [dir="rtl"] *) {
174
+ --scroll-fade-inline: linear-gradient(
175
+ to left,
176
+ transparent 0,
177
+ #000 var(--scroll-fade-s, 0px),
178
+ #000 calc(100% - var(--scroll-fade-e, 0px)),
179
+ transparent 100%
180
+ );
181
+ }
182
+ -webkit-mask-image: var(--scroll-fade-inline);
183
+ mask-image: var(--scroll-fade-inline);
184
+ -webkit-mask-composite: source-in;
185
+ mask-composite: intersect;
186
+ -webkit-mask-repeat: no-repeat;
187
+ mask-repeat: no-repeat;
188
+
189
+ @supports (animation-timeline: scroll()) {
190
+ animation:
191
+ scroll-fade-reveal-s 1ms ease-in-out,
192
+ scroll-fade-reveal-e 1ms ease-in-out;
193
+ animation-timeline: scroll(self inline), scroll(self inline);
194
+ animation-range:
195
+ 0 var(--scroll-fade-reveal, calc(var(--spacing) * 24)),
196
+ calc(100% - var(--scroll-fade-reveal, calc(var(--spacing) * 24))) 100%;
197
+ animation-fill-mode: both;
198
+ }
199
+ }
@@ -0,0 +1,85 @@
1
+ /* Text shimmer from shadcn/tailwind.css, used by Attachment upload states. */
2
+ @property --shimmer-angle {
3
+ syntax: "<angle>";
4
+ inherits: true;
5
+ initial-value: 20deg;
6
+ }
7
+ @property --shimmer-image {
8
+ syntax: "*";
9
+ inherits: false;
10
+ }
11
+ @property --shimmer-text-fill {
12
+ syntax: "*";
13
+ inherits: false;
14
+ }
15
+
16
+ @theme inline {
17
+ @keyframes tw-shimmer {
18
+ from {
19
+ background-position: 100% 0;
20
+ }
21
+ to {
22
+ background-position: 0 0;
23
+ }
24
+ }
25
+ }
26
+
27
+ @utility shimmer {
28
+ --_spread: var(--shimmer-spread, calc(3ch + 40px));
29
+ --_base: currentColor;
30
+ --_highlight: var(
31
+ --shimmer-color,
32
+ oklch(from currentColor l c h / calc(alpha * 0.2))
33
+ );
34
+
35
+ background-image: var(
36
+ --shimmer-image,
37
+ linear-gradient(
38
+ calc(90deg + var(--shimmer-angle)),
39
+ var(--_base) calc(50% - var(--_spread)),
40
+ color-mix(in oklch, var(--_highlight), var(--_base) 50%)
41
+ calc(50% - var(--_spread) * 0.5),
42
+ var(--_highlight) 50%,
43
+ color-mix(in oklch, var(--_highlight), var(--_base) 50%)
44
+ calc(50% + var(--_spread) * 0.5),
45
+ var(--_base) calc(50% + var(--_spread))
46
+ )
47
+ );
48
+ background-repeat: no-repeat;
49
+ background-size: calc(200% + var(--_spread) * 2) 100%;
50
+ background-position: 0 0;
51
+ background-clip: text;
52
+ -webkit-background-clip: text;
53
+ -webkit-text-fill-color: var(--shimmer-text-fill, transparent);
54
+ animation: tw-shimmer var(--shimmer-duration, 2s) linear infinite;
55
+
56
+ @variant dark {
57
+ --_highlight: var(
58
+ --shimmer-color,
59
+ oklch(from currentColor max(0.8, calc(l + 0.4)) c h / calc(alpha + 0.4))
60
+ );
61
+ }
62
+
63
+ &:where([dir="rtl"], [dir="rtl"] *) {
64
+ animation-direction: reverse;
65
+ }
66
+
67
+ @media (prefers-reduced-motion: reduce) {
68
+ animation: none;
69
+ background-image: none;
70
+ -webkit-text-fill-color: currentColor;
71
+ }
72
+ }
73
+
74
+ @utility shimmer-once {
75
+ animation-iteration-count: 1;
76
+ }
77
+
78
+ @utility shimmer-reverse {
79
+ animation-direction: reverse;
80
+ }
81
+
82
+ @utility shimmer-none {
83
+ --shimmer-image: none;
84
+ --shimmer-text-fill: currentColor;
85
+ }
@@ -42,6 +42,7 @@
42
42
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
43
43
  --color-sidebar-accent: var(--sidebar-accent);
44
44
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
45
+ --color-sidebar-skeleton: var(--sidebar-skeleton);
45
46
  --color-sidebar-border: var(--sidebar-border);
46
47
  --color-sidebar-ring: var(--sidebar-ring);
47
48