@40rty/ams-ui 0.5.15 → 0.5.16
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/dist/conversation.js
CHANGED
|
@@ -101,7 +101,7 @@ function useSteadyLine(line, generic) {
|
|
|
101
101
|
|
|
102
102
|
// src/conversation/turn-text.tsx
|
|
103
103
|
import * as React3 from "react";
|
|
104
|
-
import { useProductCard } from "@40rty/ams-sdk";
|
|
104
|
+
import { proseRuns, useProductCard } from "@40rty/ams-sdk";
|
|
105
105
|
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
|
106
106
|
var CRUMB_MAX_CHARS = 26;
|
|
107
107
|
function crumbLabel(visitorText) {
|
|
@@ -134,13 +134,20 @@ function ProductLink({ product, children }) {
|
|
|
134
134
|
}
|
|
135
135
|
);
|
|
136
136
|
}
|
|
137
|
+
var LINK_CLASS = "underline underline-offset-4 [color:inherit] hover:text-[var(--fourty-convo-accent)]";
|
|
138
|
+
function ProseLink({ href, children }) {
|
|
139
|
+
return /* @__PURE__ */ jsx2("a", { href, target: "_blank", rel: "noopener noreferrer", className: LINK_CLASS, children });
|
|
140
|
+
}
|
|
137
141
|
function Rich({ text, products }) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
return /* @__PURE__ */ jsx2(Fragment2, { children: proseRuns(text).map((run, r) => {
|
|
143
|
+
if (run.href !== void 0 && products !== void 0) return /* @__PURE__ */ jsx2(ProseLink, { href: run.href, children: run.text }, r);
|
|
144
|
+
return run.text.split("**").map((part, i) => {
|
|
145
|
+
const key = `${String(r)}:${String(i)}`;
|
|
146
|
+
if (i % 2 === 0) return /* @__PURE__ */ jsx2(React3.Fragment, { children: part }, key);
|
|
147
|
+
const product = products === void 0 ? void 0 : productNamed(part, products);
|
|
148
|
+
if (product !== void 0) return /* @__PURE__ */ jsx2(ProductLink, { product, children: part }, key);
|
|
149
|
+
return /* @__PURE__ */ jsx2("strong", { className: "text-[var(--fourty-convo-ink)]", children: part }, key);
|
|
150
|
+
});
|
|
144
151
|
}) });
|
|
145
152
|
}
|
|
146
153
|
var WORD_EASE = [0.2, 0.75, 0.2, 1];
|
|
@@ -167,15 +174,20 @@ function RisingWords({ text, products, delayS = 0 }) {
|
|
|
167
174
|
const reduce = useReducedMotion();
|
|
168
175
|
const words = [];
|
|
169
176
|
let gap = false;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
let bold = false;
|
|
178
|
+
let runs = 0;
|
|
179
|
+
for (const link of proseRuns(text)) {
|
|
180
|
+
link.text.split("**").forEach((part, i) => {
|
|
181
|
+
if (i > 0) bold = !bold;
|
|
182
|
+
runs += 1;
|
|
183
|
+
const product = bold && link.href === void 0 ? productNamed(part, products) : void 0;
|
|
184
|
+
for (const m of part.matchAll(/(\s*)(\S+)/g)) {
|
|
185
|
+
words.push({ w: m[2], bold, spaced: words.length > 0 && (gap || m[1].length > 0), run: runs, product, href: link.href });
|
|
186
|
+
gap = false;
|
|
187
|
+
}
|
|
188
|
+
if (/\s$/.test(part)) gap = true;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
179
191
|
const keyOf = (i) => `${String(i)}:${words[i].w}`;
|
|
180
192
|
const keys = words.map((_, i) => keyOf(i));
|
|
181
193
|
const animated = reduce !== true;
|
|
@@ -190,14 +202,14 @@ function RisingWords({ text, products, delayS = 0 }) {
|
|
|
190
202
|
shownRef.current = new Set(keys);
|
|
191
203
|
});
|
|
192
204
|
const word = (i) => {
|
|
193
|
-
const { w, bold, product } = words[i];
|
|
205
|
+
const { w, bold: bold2, product, href } = words[i];
|
|
194
206
|
const key = keyOf(i);
|
|
195
207
|
const order = rank.get(key);
|
|
196
208
|
const fresh = order !== void 0;
|
|
197
209
|
return /* @__PURE__ */ jsx2(
|
|
198
210
|
motion.span,
|
|
199
211
|
{
|
|
200
|
-
className: `inline-block ${
|
|
212
|
+
className: `inline-block ${bold2 ? "font-[var(--font-weight-strong,_700)] text-[var(--fourty-convo-ink)]" : ""} ${product !== void 0 || href !== void 0 ? "underline underline-offset-[0.12em] [color:inherit]" : ""}`,
|
|
201
213
|
initial: fresh ? { opacity: 0, y: "0.5em", filter: "blur(8px)" } : false,
|
|
202
214
|
animate: { opacity: 1, y: 0, filter: "blur(0px)" },
|
|
203
215
|
transition: { duration: WORD_RISE_S, ease: WORD_EASE, delay: delayS + (order !== void 0 ? plan.offsetS + order * plan.staggerS : 0) },
|
|
@@ -209,9 +221,9 @@ function RisingWords({ text, products, delayS = 0 }) {
|
|
|
209
221
|
};
|
|
210
222
|
const out = [];
|
|
211
223
|
for (let i = 0; i < words.length; ) {
|
|
212
|
-
const { product, run, spaced } = words[i];
|
|
224
|
+
const { product, href, run, spaced } = words[i];
|
|
213
225
|
if (spaced) out.push(" ");
|
|
214
|
-
if (product === void 0) {
|
|
226
|
+
if (product === void 0 && href === void 0) {
|
|
215
227
|
out.push(word(i));
|
|
216
228
|
i += 1;
|
|
217
229
|
continue;
|
|
@@ -222,7 +234,8 @@ function RisingWords({ text, products, delayS = 0 }) {
|
|
|
222
234
|
if (i > start && words[i].spaced) name.push(" ");
|
|
223
235
|
name.push(word(i));
|
|
224
236
|
}
|
|
225
|
-
out.push(/* @__PURE__ */ jsx2(ProductLink, { product, children: name }, `link-${start}`));
|
|
237
|
+
if (product !== void 0) out.push(/* @__PURE__ */ jsx2(ProductLink, { product, children: name }, `link-${String(start)}`));
|
|
238
|
+
else if (href !== void 0) out.push(/* @__PURE__ */ jsx2(ProseLink, { href, children: name }, `link-${String(start)}`));
|
|
226
239
|
}
|
|
227
240
|
return /* @__PURE__ */ jsx2(Fragment2, { children: out });
|
|
228
241
|
}
|
|
@@ -9,9 +9,10 @@ export declare function crumbLabel(visitorText: string): string;
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function productNamed(name: string, products: readonly Product[]): Product | undefined;
|
|
11
11
|
/**
|
|
12
|
-
* `**bold**` in the agent's prose, rendered; everything else
|
|
13
|
-
* A bold run that names one of `products` is a link to it.
|
|
14
|
-
* out where the text already sits inside a control (the
|
|
12
|
+
* `**bold**` and `[label](url)` in the agent's prose, rendered; everything else
|
|
13
|
+
* is plain text. A bold run that names one of `products` is a link to it.
|
|
14
|
+
* `products` is left out where the text already sits inside a control (the
|
|
15
|
+
* folded turn's toggle) — there a link's label is plain text.
|
|
15
16
|
*/
|
|
16
17
|
export declare function Rich({ text, products }: {
|
|
17
18
|
text: string;
|
package/package.json
CHANGED
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
"zod": "^3.23.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@40rty/ams-sdk": "0.5.
|
|
79
|
+
"@40rty/ams-sdk": "0.5.16",
|
|
80
80
|
"lucide-react": ">=0.400.0",
|
|
81
81
|
"react": ">=18.0.0",
|
|
82
82
|
"react-dom": ">=18.0.0"
|
|
83
83
|
},
|
|
84
|
-
"version": "0.5.
|
|
84
|
+
"version": "0.5.16",
|
|
85
85
|
"homepage": "https://docs.40rty.ai",
|
|
86
86
|
"license": "UNLICENSED",
|
|
87
87
|
"engines": {
|