@stagewise/ui 0.15.1 → 0.17.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.1",
3
+ "version": "0.17.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}
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { Icon, type IconProps } from './Icon';
3
+
4
+ interface IconCloudOutline18Props extends IconProps {
5
+ strokeWidth?: number;
6
+ }
7
+ export const IconCloudOutline18: React.FC<IconCloudOutline18Props> = ({
8
+ strokeWidth = 1.5,
9
+ ...props
10
+ }) => {
11
+ return (
12
+ <Icon size="18px" {...props}>
13
+ <path
14
+ d="M13.464,6.891c-.186-2.314-2.102-4.141-4.464-4.141-2.485,0-4.5,2.015-4.5,4.5,0,.35,.049,.686,.124,1.013-1.597,.067-2.874,1.374-2.874,2.987,0,1.657,1.343,3,3,3h7.75c2.071,0,3.75-1.679,3.75-3.75,0-1.736-1.185-3.182-2.786-3.609Z"
15
+ stroke="currentColor"
16
+ strokeWidth={strokeWidth}
17
+ strokeLinecap="round"
18
+ strokeLinejoin="round"
19
+ fill="none"
20
+ />
21
+ <path
22
+ d="M9.705,8c.687-.767,1.684-1.25,2.795-1.25,.333,0,.657,.059,.964,.141"
23
+ stroke="currentColor"
24
+ strokeWidth={strokeWidth}
25
+ strokeLinecap="round"
26
+ strokeLinejoin="round"
27
+ fill="none"
28
+ />
29
+ </Icon>
30
+ );
31
+ };
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { Icon, type IconProps } from './Icon';
3
+
4
+ interface IconCloudSlashOutline18Props extends IconProps {
5
+ strokeWidth?: number;
6
+ }
7
+ export const IconCloudSlashOutline18: React.FC<
8
+ IconCloudSlashOutline18Props
9
+ > = ({ strokeWidth = 1.5, ...props }) => {
10
+ return (
11
+ <Icon size="18px" {...props}>
12
+ <path
13
+ d="M12.922 5.078C12.161 3.691 10.696 2.75 9 2.75C6.515 2.75 4.5 4.765 4.5 7.25C4.5 7.6 4.54899 7.936 4.62399 8.263C3.02699 8.33 1.75 9.637 1.75 11.25C1.75 12.604 2.647 13.748 3.879 14.121"
14
+ stroke="currentColor"
15
+ strokeWidth={strokeWidth}
16
+ strokeLinecap="round"
17
+ strokeLinejoin="round"
18
+ fill="none"
19
+ />
20
+ <path
21
+ d="M2 16L16 2"
22
+ stroke="currentColor"
23
+ strokeWidth={strokeWidth}
24
+ strokeLinecap="round"
25
+ strokeLinejoin="round"
26
+ fill="none"
27
+ />
28
+ <path
29
+ d="M7.99219 14.25H12.5C14.571 14.25 16.25 12.571 16.25 10.5C16.25 9.26881 15.6525 8.18681 14.7351 7.50711"
30
+ stroke="currentColor"
31
+ strokeWidth={strokeWidth}
32
+ strokeLinecap="round"
33
+ strokeLinejoin="round"
34
+ fill="none"
35
+ />
36
+ </Icon>
37
+ );
38
+ };
@@ -33,6 +33,8 @@ export { IconCircleQuestionOutline18 } from './IconCircleQuestionOutline18';
33
33
  export { IconClipboardContentOutline18 } from './IconClipboardContentOutline18';
34
34
  export { IconClipboardOutline18 } from './IconClipboardOutline18';
35
35
  export { IconClone2Outline18 } from './IconClone2Outline18';
36
+ export { IconCloudOutline18 } from './IconCloudOutline18';
37
+ export { IconCloudSlashOutline18 } from './IconCloudSlashOutline18';
36
38
  export { IconCloneDashed2Outline18 } from './IconCloneDashed2Outline18';
37
39
  export { IconCodeBranchOutline18 } from './IconCodeBranchOutline18';
38
40
  export { IconCodeCommitOutline18 } from './IconCodeCommitOutline18';
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';
@@ -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
+ }