@40rty/ams-ui 0.5.4 → 0.5.6

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.
@@ -1,34 +1,7 @@
1
1
  'use client';
2
-
3
- // src/utils/cn.ts
4
- import { clsx } from "clsx";
5
- import { twMerge } from "tailwind-merge";
6
- function cn(...inputs) {
7
- return twMerge(clsx(inputs));
8
- }
9
-
10
- // src/shell/Spinner.tsx
11
- import { motion } from "framer-motion";
12
- import { jsx } from "react/jsx-runtime";
13
- function Spinner({ size = 14 }) {
14
- return /* @__PURE__ */ jsx(
15
- motion.span,
16
- {
17
- "aria-hidden": "true",
18
- animate: { rotate: 360 },
19
- transition: { duration: 0.6, repeat: Infinity, ease: "linear" },
20
- style: {
21
- display: "inline-block",
22
- width: size,
23
- height: size,
24
- border: "2px solid currentColor",
25
- borderRightColor: "transparent",
26
- borderRadius: "50%",
27
- verticalAlign: "middle"
28
- }
29
- }
30
- );
31
- }
2
+ import {
3
+ cn
4
+ } from "./chunk-WDL5PHO2.js";
32
5
 
33
6
  // src/hooks/use-media-query.ts
34
7
  import { useState, useEffect } from "react";
@@ -74,8 +47,8 @@ function useScrollLock(locked, anchorRef) {
74
47
 
75
48
  // src/shell/DragSheet.tsx
76
49
  import * as React from "react";
77
- import { motion as motion2, AnimatePresence, useDragControls, useReducedMotion } from "framer-motion";
78
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
50
+ import { motion, AnimatePresence, useDragControls, useReducedMotion } from "framer-motion";
51
+ import { jsx, jsxs } from "react/jsx-runtime";
79
52
  var ROOT_CLASS = "fourty-drag-sheet";
80
53
  var SCRIM_CLASS = "fourty-drag-sheet__scrim";
81
54
  var PANEL_CLASS = "fourty-drag-sheet__panel";
@@ -122,7 +95,7 @@ function DragSheet({
122
95
  const detentMax = `calc(${heightFraction} * 100dvh)`;
123
96
  const panelHeight = isFull ? FULL_HEIGHT : fit ? "auto" : detentMax;
124
97
  const panelMaxHeight = isFull ? FULL_HEIGHT : detentMax;
125
- return /* @__PURE__ */ jsx2(AnimatePresence, { children: open && // Fixed, viewport-sized containing block for the scrim + panel below.
98
+ return /* @__PURE__ */ jsx(AnimatePresence, { children: open && // Fixed, viewport-sized containing block for the scrim + panel below.
126
99
  // Both are `position: absolute`, so without a positioned root they'd
127
100
  // resolve to whatever ancestor happens to be positioned — on the mobile
128
101
  // shell that's the tall, `position: relative` document-scroll root, which
@@ -131,8 +104,8 @@ function DragSheet({
131
104
  // the same viewport-pin the MorphIsland uses; `z-index` matches the
132
105
  // desktop modal (above the island at 60 and the chrome at 50).
133
106
  /* @__PURE__ */ jsxs("div", { className: ROOT_CLASS, style: { position: "fixed", inset: 0, zIndex: 80 }, children: [
134
- /* @__PURE__ */ jsx2(
135
- motion2.div,
107
+ /* @__PURE__ */ jsx(
108
+ motion.div,
136
109
  {
137
110
  "aria-hidden": "true",
138
111
  className: SCRIM_CLASS,
@@ -145,7 +118,7 @@ function DragSheet({
145
118
  }
146
119
  ),
147
120
  /* @__PURE__ */ jsxs(
148
- motion2.div,
121
+ motion.div,
149
122
  {
150
123
  role: "dialog",
151
124
  "aria-label": label,
@@ -182,7 +155,7 @@ function DragSheet({
182
155
  background: "var(--fourty-sheet-bg, var(--color-surface))"
183
156
  },
184
157
  children: [
185
- /* @__PURE__ */ jsx2(
158
+ /* @__PURE__ */ jsx(
186
159
  "div",
187
160
  {
188
161
  className: HANDLE_CLASS,
@@ -195,7 +168,7 @@ function DragSheet({
195
168
  cursor: "grab",
196
169
  touchAction: "none"
197
170
  },
198
- children: /* @__PURE__ */ jsx2(
171
+ children: /* @__PURE__ */ jsx(
199
172
  "div",
200
173
  {
201
174
  className: GRIP_CLASS,
@@ -210,7 +183,7 @@ function DragSheet({
210
183
  )
211
184
  }
212
185
  ),
213
- /* @__PURE__ */ jsx2("div", { className: BODY_CLASS, style: { position: "relative", flex: 1, minHeight: 0, display: "flex", flexDirection: "column" }, children })
186
+ /* @__PURE__ */ jsx("div", { className: BODY_CLASS, style: { position: "relative", flex: 1, minHeight: 0, display: "flex", flexDirection: "column" }, children })
214
187
  ]
215
188
  }
216
189
  )
@@ -218,8 +191,6 @@ function DragSheet({
218
191
  }
219
192
 
220
193
  export {
221
- cn,
222
- Spinner,
223
194
  useMediaQuery,
224
195
  useScrollLock,
225
196
  DragSheet
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+
3
+ // src/utils/cn.ts
4
+ import { clsx } from "clsx";
5
+ import { twMerge } from "tailwind-merge";
6
+ function cn(...inputs) {
7
+ return twMerge(clsx(inputs));
8
+ }
9
+
10
+ // src/shell/Spinner.tsx
11
+ import { motion } from "framer-motion";
12
+ import { jsx } from "react/jsx-runtime";
13
+ function Spinner({ size = 14 }) {
14
+ return /* @__PURE__ */ jsx(
15
+ motion.span,
16
+ {
17
+ "aria-hidden": "true",
18
+ animate: { rotate: 360 },
19
+ transition: { duration: 0.6, repeat: Infinity, ease: "linear" },
20
+ style: {
21
+ display: "inline-block",
22
+ width: size,
23
+ height: size,
24
+ border: "2px solid currentColor",
25
+ borderRightColor: "transparent",
26
+ borderRadius: "50%",
27
+ verticalAlign: "middle"
28
+ }
29
+ }
30
+ );
31
+ }
32
+
33
+ export {
34
+ cn,
35
+ Spinner
36
+ };
@@ -0,0 +1,318 @@
1
+ 'use client';
2
+ import {
3
+ Spinner,
4
+ cn
5
+ } from "./chunk-WDL5PHO2.js";
6
+ import {
7
+ AnimatePresence,
8
+ motion,
9
+ pressPresets
10
+ } from "./chunk-432XYPDT.js";
11
+
12
+ // src/shell/ListeningWaveform.tsx
13
+ import { jsx } from "react/jsx-runtime";
14
+ var LISTENING_BARS = [
15
+ { id: "a", from: 0.45, to: 1, duration: 0.5, delay: 0 },
16
+ { id: "b", from: 0.9, to: 0.35, duration: 0.62, delay: 0.09 },
17
+ { id: "c", from: 0.55, to: 0.95, duration: 0.46, delay: 0.04 },
18
+ { id: "d", from: 1, to: 0.4, duration: 0.55, delay: 0.13 }
19
+ ];
20
+ function ListeningWaveform({
21
+ color,
22
+ barWidth = 2.5,
23
+ gap = 2.5,
24
+ height = 16
25
+ }) {
26
+ return /* @__PURE__ */ jsx(
27
+ "span",
28
+ {
29
+ "aria-hidden": "true",
30
+ style: { display: "inline-flex", alignItems: "center", justifyContent: "center", gap, height },
31
+ children: LISTENING_BARS.map((bar) => /* @__PURE__ */ jsx(
32
+ motion.span,
33
+ {
34
+ initial: { scaleY: bar.from },
35
+ animate: { scaleY: bar.to },
36
+ transition: {
37
+ duration: bar.duration,
38
+ delay: bar.delay,
39
+ repeat: Infinity,
40
+ repeatType: "mirror",
41
+ ease: "easeInOut"
42
+ },
43
+ style: {
44
+ width: barWidth,
45
+ height: "100%",
46
+ borderRadius: 1,
47
+ background: color,
48
+ transformOrigin: "center"
49
+ }
50
+ },
51
+ bar.id
52
+ ))
53
+ }
54
+ );
55
+ }
56
+
57
+ // src/shell/DictationButton.tsx
58
+ import { AudioLines } from "lucide-react";
59
+ import { jsx as jsx2 } from "react/jsx-runtime";
60
+ var MIC_CLASS = "fourty-composer-mic";
61
+ var MIC_IDLE_COLOR = "var(--fourty-mic-idle, var(--color-text-muted))";
62
+ var MIC_ACTIVE_COLOR = "var(--fourty-mic-active, var(--color-primary))";
63
+ function DictationButton({
64
+ listening,
65
+ supported,
66
+ onToggle,
67
+ className,
68
+ style
69
+ }) {
70
+ if (!supported) return null;
71
+ return /* @__PURE__ */ jsx2(
72
+ motion.button,
73
+ {
74
+ type: "button",
75
+ onClick: onToggle,
76
+ "aria-label": listening ? "Stop dictation" : "Dictate",
77
+ "aria-pressed": listening,
78
+ title: listening ? "Stop dictation" : "Dictate",
79
+ className: cn(MIC_CLASS, className),
80
+ whileHover: pressPresets.icon.whileHover,
81
+ whileTap: pressPresets.icon.whileTap,
82
+ animate: { color: listening ? MIC_ACTIVE_COLOR : MIC_IDLE_COLOR },
83
+ transition: pressPresets.icon.transition,
84
+ style: {
85
+ // Mirror the send button's footprint so the two read as a paired
86
+ // control set: a full-height 32px cell, transparent (vs. the send's
87
+ // fill) to keep the send the primary action. Sharp, no radius — fits
88
+ // the SM stencilled composer.
89
+ background: "transparent",
90
+ border: 0,
91
+ padding: 0,
92
+ cursor: "pointer",
93
+ display: "inline-flex",
94
+ alignItems: "center",
95
+ justifyContent: "center",
96
+ flex: "0 0 32px",
97
+ width: 32,
98
+ alignSelf: "stretch",
99
+ ...style
100
+ },
101
+ children: listening ? (
102
+ // The listening waveform replaces the glyph while a session is live.
103
+ /* @__PURE__ */ jsx2(ListeningWaveform, { color: MIC_ACTIVE_COLOR })
104
+ ) : /* @__PURE__ */ jsx2(AudioLines, { size: 16, strokeWidth: 1.6 })
105
+ }
106
+ );
107
+ }
108
+
109
+ // src/shell/composer/AttachmentStrip.tsx
110
+ import * as React from "react";
111
+ import { X, FileText, AlertCircle, ImageOff } from "lucide-react";
112
+ import { isImageAttachment } from "@40rty/ams-sdk";
113
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
114
+ var STRIP_CLASS = "fourty-composer-attachments";
115
+ var THUMB = 52;
116
+ function Thumb({ a }) {
117
+ const [imgFailed, setImgFailed] = React.useState(false);
118
+ if (a.previewUrl !== null && !imgFailed) {
119
+ return /* @__PURE__ */ jsx3(
120
+ "img",
121
+ {
122
+ src: a.previewUrl,
123
+ alt: a.name,
124
+ onError: () => setImgFailed(true),
125
+ style: { width: "100%", height: "100%", objectFit: "cover", display: "block" }
126
+ }
127
+ );
128
+ }
129
+ const Icon = isImageAttachment(a.mimeType) ? ImageOff : FileText;
130
+ return /* @__PURE__ */ jsxs(
131
+ "div",
132
+ {
133
+ style: {
134
+ width: "100%",
135
+ height: "100%",
136
+ display: "flex",
137
+ flexDirection: "column",
138
+ alignItems: "center",
139
+ justifyContent: "center",
140
+ gap: 2,
141
+ padding: 4,
142
+ color: "var(--color-text-muted)"
143
+ },
144
+ children: [
145
+ /* @__PURE__ */ jsx3(Icon, { size: 18, strokeWidth: 1.5 }),
146
+ /* @__PURE__ */ jsx3(
147
+ "span",
148
+ {
149
+ style: {
150
+ fontSize: 8,
151
+ lineHeight: 1.1,
152
+ maxWidth: "100%",
153
+ overflow: "hidden",
154
+ textOverflow: "ellipsis",
155
+ whiteSpace: "nowrap"
156
+ },
157
+ children: a.name
158
+ }
159
+ )
160
+ ]
161
+ }
162
+ );
163
+ }
164
+ function AttachmentStrip({
165
+ attachments,
166
+ onRemove
167
+ }) {
168
+ if (attachments.length === 0) return null;
169
+ return /* @__PURE__ */ jsx3(
170
+ "div",
171
+ {
172
+ className: STRIP_CLASS,
173
+ style: { display: "flex", flexWrap: "wrap", gap: 8 },
174
+ children: /* @__PURE__ */ jsx3(AnimatePresence, { initial: false, children: attachments.map((a) => /* @__PURE__ */ jsxs(
175
+ motion.div,
176
+ {
177
+ layout: true,
178
+ initial: { opacity: 0, scale: 0.9 },
179
+ animate: { opacity: 1, scale: 1 },
180
+ exit: { opacity: 0, scale: 0.9 },
181
+ transition: { duration: 0.18, ease: [0.22, 1, 0.36, 1] },
182
+ title: a.error !== null ? a.error : a.name,
183
+ style: {
184
+ position: "relative",
185
+ width: THUMB,
186
+ height: THUMB,
187
+ flex: `0 0 ${THUMB}px`,
188
+ overflow: "hidden",
189
+ background: "var(--color-surface-alt)",
190
+ border: `1px solid ${a.status === "error" ? "var(--color-danger, #d4503e)" : "var(--color-border)"}`
191
+ },
192
+ children: [
193
+ /* @__PURE__ */ jsx3(Thumb, { a }),
194
+ a.status === "uploading" && /* @__PURE__ */ jsx3(
195
+ "div",
196
+ {
197
+ style: {
198
+ position: "absolute",
199
+ inset: 0,
200
+ display: "flex",
201
+ alignItems: "center",
202
+ justifyContent: "center",
203
+ background: "rgba(0,0,0,0.35)",
204
+ color: "#fff"
205
+ },
206
+ children: /* @__PURE__ */ jsx3(Spinner, {})
207
+ }
208
+ ),
209
+ a.status === "error" && /* @__PURE__ */ jsx3(
210
+ "div",
211
+ {
212
+ style: {
213
+ position: "absolute",
214
+ inset: 0,
215
+ display: "flex",
216
+ alignItems: "center",
217
+ justifyContent: "center",
218
+ background: "color-mix(in srgb, var(--color-danger, #d4503e) 18%, transparent)",
219
+ color: "var(--color-danger, #d4503e)"
220
+ },
221
+ children: /* @__PURE__ */ jsx3(AlertCircle, { size: 18, strokeWidth: 1.5 })
222
+ }
223
+ ),
224
+ /* @__PURE__ */ jsx3(
225
+ "button",
226
+ {
227
+ type: "button",
228
+ onClick: () => onRemove(a.localId),
229
+ "aria-label": `Remove ${a.name}`,
230
+ style: {
231
+ position: "absolute",
232
+ top: 2,
233
+ right: 2,
234
+ width: 16,
235
+ height: 16,
236
+ display: "inline-flex",
237
+ alignItems: "center",
238
+ justifyContent: "center",
239
+ background: "var(--color-text)",
240
+ color: "var(--color-surface)",
241
+ border: 0,
242
+ borderRadius: 8,
243
+ cursor: "pointer",
244
+ padding: 0
245
+ },
246
+ children: /* @__PURE__ */ jsx3(X, { size: 10, strokeWidth: 2 })
247
+ }
248
+ )
249
+ ]
250
+ },
251
+ a.localId
252
+ )) })
253
+ }
254
+ );
255
+ }
256
+
257
+ // src/shell/composer/AttachButton.tsx
258
+ import * as React2 from "react";
259
+ import { Image as ImageIcon } from "lucide-react";
260
+ import { ATTACHMENT_ACCEPT } from "@40rty/ams-sdk";
261
+ import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
262
+ var ATTACH_CLASS = "fourty-composer-attach";
263
+ var ATTACH_COLOR = "var(--fourty-attach-color, var(--color-text-muted))";
264
+ function AttachButton({ onFiles, className, style }) {
265
+ const inputRef = React2.useRef(null);
266
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
267
+ /* @__PURE__ */ jsx4(
268
+ "input",
269
+ {
270
+ ref: inputRef,
271
+ type: "file",
272
+ multiple: true,
273
+ accept: ATTACHMENT_ACCEPT,
274
+ style: { display: "none" },
275
+ onChange: (e) => {
276
+ const files = e.target.files;
277
+ if (files !== null && files.length > 0) onFiles(files);
278
+ e.target.value = "";
279
+ }
280
+ }
281
+ ),
282
+ /* @__PURE__ */ jsx4(
283
+ motion.button,
284
+ {
285
+ type: "button",
286
+ onClick: () => inputRef.current?.click(),
287
+ "aria-label": "Attach a file",
288
+ title: "Attach a file",
289
+ className: cn(ATTACH_CLASS, className),
290
+ whileHover: pressPresets.icon.whileHover,
291
+ whileTap: pressPresets.icon.whileTap,
292
+ transition: pressPresets.icon.transition,
293
+ style: {
294
+ background: "transparent",
295
+ border: 0,
296
+ padding: 0,
297
+ cursor: "pointer",
298
+ display: "inline-flex",
299
+ alignItems: "center",
300
+ justifyContent: "center",
301
+ flex: "0 0 32px",
302
+ width: 32,
303
+ alignSelf: "stretch",
304
+ color: ATTACH_COLOR,
305
+ ...style
306
+ },
307
+ children: /* @__PURE__ */ jsx4(ImageIcon, { size: 18, strokeWidth: 1.6 })
308
+ }
309
+ )
310
+ ] });
311
+ }
312
+
313
+ export {
314
+ ListeningWaveform,
315
+ DictationButton,
316
+ AttachmentStrip,
317
+ AttachButton
318
+ };
@@ -1,24 +1,27 @@
1
1
  'use client';
2
2
  import {
3
- AttachButton,
4
- AttachmentStrip,
5
3
  ComposerChipStrip,
6
- DictationButton,
7
4
  usePromptComposer
8
- } from "./chunk-2QRYXSCB.js";
5
+ } from "./chunk-CKNELL6G.js";
9
6
  import "./chunk-H6MSAD5M.js";
10
- import "./chunk-JQNZ5UUK.js";
7
+ import "./chunk-I5QE47QY.js";
11
8
  import {
12
9
  useLabels
13
10
  } from "./chunk-2HM6EVDV.js";
14
11
  import "./chunk-RMJDSHLA.js";
12
+ import "./chunk-PHXP2SKS.js";
13
+ import "./chunk-GQURT3IR.js";
14
+ import {
15
+ AttachButton,
16
+ AttachmentStrip,
17
+ DictationButton
18
+ } from "./chunk-WVD2Y2N2.js";
19
+ import "./chunk-WDL5PHO2.js";
15
20
  import {
16
21
  AnimatePresence,
17
22
  motion,
18
23
  useReducedMotion
19
24
  } from "./chunk-432XYPDT.js";
20
- import "./chunk-PHXP2SKS.js";
21
- import "./chunk-GQURT3IR.js";
22
25
 
23
26
  // src/conversation/ConversationCanvas.tsx
24
27
  import { CanvasArrangementProvider, CanvasMotionStyleProvider, SpacefrontCanvas } from "@40rty/ams-sdk";