@openwarelabs/ui 0.10.0 → 0.11.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/README.md +5 -1
- package/dist/components/Avatar/Avatar.d.cts +2 -13
- package/dist/components/Avatar/Avatar.d.ts +2 -13
- package/dist/components/Avatar/Avatar.types.d.cts +13 -0
- package/dist/components/Avatar/Avatar.types.d.ts +13 -0
- package/dist/components/Calendar/DatePicker.d.cts +2 -19
- package/dist/components/Calendar/DatePicker.d.ts +2 -19
- package/dist/components/Calendar/DatePicker.types.d.cts +19 -0
- package/dist/components/Calendar/DatePicker.types.d.ts +19 -0
- package/dist/components/Calendar/DateRangePicker.d.cts +2 -34
- package/dist/components/Calendar/DateRangePicker.d.ts +2 -34
- package/dist/components/Calendar/DateRangePicker.types.d.cts +34 -0
- package/dist/components/Calendar/DateRangePicker.types.d.ts +34 -0
- package/dist/components/ColorPicker/ColorPicker.d.cts +2 -55
- package/dist/components/ColorPicker/ColorPicker.d.ts +2 -55
- package/dist/components/ColorPicker/ColorPicker.types.d.cts +54 -0
- package/dist/components/ColorPicker/ColorPicker.types.d.ts +54 -0
- package/dist/components/Container/Container.d.cts +7 -0
- package/dist/components/Container/Container.d.ts +7 -0
- package/dist/components/Container/Container.types.d.cts +12 -0
- package/dist/components/Container/Container.types.d.ts +12 -0
- package/dist/components/ListBox/ListBox.d.cts +3 -61
- package/dist/components/ListBox/ListBox.d.ts +3 -61
- package/dist/components/ListBox/ListBox.types.d.cts +61 -0
- package/dist/components/ListBox/ListBox.types.d.ts +61 -0
- package/dist/components/Prose/Prose.d.cts +2 -16
- package/dist/components/Prose/Prose.d.ts +2 -16
- package/dist/components/Prose/Prose.types.d.cts +16 -0
- package/dist/components/Prose/Prose.types.d.ts +16 -0
- package/dist/components/Section/Section.d.cts +7 -0
- package/dist/components/Section/Section.d.ts +7 -0
- package/dist/components/Section/Section.types.d.cts +16 -0
- package/dist/components/Section/Section.types.d.ts +16 -0
- package/dist/components.css +83 -0
- package/dist/index.cjs +333 -298
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +320 -285
- package/dist/index.js.map +4 -4
- package/dist/openware-ui.iife.js +7 -7
- package/dist/styles.css +86 -0
- package/dist/tokens.css +3 -0
- package/dist/tokens.json +15 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -3303,7 +3303,7 @@ function ListBoxWithRef({
|
|
|
3303
3303
|
);
|
|
3304
3304
|
};
|
|
3305
3305
|
const isEmpty = flat.length === 0;
|
|
3306
|
-
const describedBy =
|
|
3306
|
+
const describedBy = ariaDescribedBy;
|
|
3307
3307
|
return /* @__PURE__ */ jsxs16(
|
|
3308
3308
|
"div",
|
|
3309
3309
|
{
|
|
@@ -3346,7 +3346,10 @@ function ListBoxWithRef({
|
|
|
3346
3346
|
item.options.map(renderOption)
|
|
3347
3347
|
] }, `group-${item.label}-${groupIndex}`) : renderOption(item)
|
|
3348
3348
|
),
|
|
3349
|
-
isEmpty ?
|
|
3349
|
+
isEmpty ? (
|
|
3350
|
+
// A listbox holds options, so an empty one says so with one that can't be chosen.
|
|
3351
|
+
/* @__PURE__ */ jsx25("div", { id: emptyId, className: "ow-listbox__empty", role: "option", "aria-disabled": "true", "aria-selected": "false", children: emptyMessage })
|
|
3352
|
+
) : null
|
|
3350
3353
|
]
|
|
3351
3354
|
}
|
|
3352
3355
|
);
|
|
@@ -4114,9 +4117,9 @@ var DatePicker = /* @__PURE__ */ forwardRef17(function DatePicker2({
|
|
|
4114
4117
|
"aria-haspopup": "dialog",
|
|
4115
4118
|
"aria-expanded": isOpen,
|
|
4116
4119
|
"aria-controls": isOpen ? panelId : void 0,
|
|
4117
|
-
"aria-label": ariaLabel,
|
|
4118
|
-
"aria-labelledby": ariaLabelledBy,
|
|
4119
|
-
"aria-describedby":
|
|
4120
|
+
"aria-label": ariaLabel && !ariaLabelledBy ? `${ariaLabel}, ${label}` : void 0,
|
|
4121
|
+
"aria-labelledby": ariaLabelledBy ? `${ariaLabelledBy} ${panelId}-value` : void 0,
|
|
4122
|
+
"aria-describedby": ariaDescribedBy,
|
|
4120
4123
|
"aria-invalid": isInvalid || void 0,
|
|
4121
4124
|
disabled,
|
|
4122
4125
|
className: cx(
|
|
@@ -4419,9 +4422,9 @@ var DateRangePicker = /* @__PURE__ */ forwardRef19(function DateRangePicker2({
|
|
|
4419
4422
|
"aria-haspopup": "dialog",
|
|
4420
4423
|
"aria-expanded": isOpen,
|
|
4421
4424
|
"aria-controls": isOpen ? panelId : void 0,
|
|
4422
|
-
"aria-label": ariaLabel,
|
|
4423
|
-
"aria-labelledby": ariaLabelledBy,
|
|
4424
|
-
"aria-describedby":
|
|
4425
|
+
"aria-label": ariaLabel && !ariaLabelledBy ? `${ariaLabel}, ${label}` : void 0,
|
|
4426
|
+
"aria-labelledby": ariaLabelledBy ? `${ariaLabelledBy} ${panelId}-value` : void 0,
|
|
4427
|
+
"aria-describedby": ariaDescribedBy,
|
|
4425
4428
|
"aria-invalid": isInvalid || void 0,
|
|
4426
4429
|
disabled,
|
|
4427
4430
|
className: cx("ow-select", "ow-date-range-picker__trigger", `ow-select--${size2}`, {
|
|
@@ -6164,7 +6167,8 @@ function Avatar({ name, src, size: size2 = "md", label, className }) {
|
|
|
6164
6167
|
className: cx("ow-avatar", sizing.className, !initials && !showImage && "ow-avatar--empty", className),
|
|
6165
6168
|
style: sizing.style,
|
|
6166
6169
|
...label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
|
|
6167
|
-
|
|
6170
|
+
"data-initials": !showImage && initials ? initials : void 0,
|
|
6171
|
+
children: showImage ? /* @__PURE__ */ jsx56("img", { src, alt: "", className: "ow-avatar__image", onError: () => setFailedImage(src) }) : initials ? null : /* @__PURE__ */ jsx56(UserIcon, { size: Math.round(sizing.pixels * 0.52) })
|
|
6168
6172
|
}
|
|
6169
6173
|
);
|
|
6170
6174
|
}
|
|
@@ -6338,11 +6342,23 @@ function VisuallyHidden({ className, ...props }) {
|
|
|
6338
6342
|
return /* @__PURE__ */ jsx60("span", { className: cx("ow-visually-hidden", className), ...props });
|
|
6339
6343
|
}
|
|
6340
6344
|
|
|
6345
|
+
// src/components/Container/Container.tsx
|
|
6346
|
+
import { jsx as jsx61 } from "react/jsx-runtime";
|
|
6347
|
+
function Container({ size: size2 = "page", as: Element2 = "div", className, ...props }) {
|
|
6348
|
+
return /* @__PURE__ */ jsx61(Element2, { className: cx("ow-container", `ow-container--${size2}`, className), ...props });
|
|
6349
|
+
}
|
|
6350
|
+
|
|
6351
|
+
// src/components/Section/Section.tsx
|
|
6352
|
+
import { jsx as jsx62 } from "react/jsx-runtime";
|
|
6353
|
+
function Section({ tone = "paper", spacing = "md", size: size2 = "page", as: Element2 = "section", className, children, ...props }) {
|
|
6354
|
+
return /* @__PURE__ */ jsx62(Element2, { className: cx("ow-section", `ow-section--${tone}`, `ow-section--space-${spacing}`, className), ...props, children: size2 === false ? children : /* @__PURE__ */ jsx62(Container, { size: size2, children }) });
|
|
6355
|
+
}
|
|
6356
|
+
|
|
6341
6357
|
// src/components/Marketing/Marketing.tsx
|
|
6342
6358
|
import { useRef as useRef33 } from "react";
|
|
6343
|
-
import { jsx as
|
|
6359
|
+
import { jsx as jsx63, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
6344
6360
|
function Chip({ className, ...props }) {
|
|
6345
|
-
return /* @__PURE__ */
|
|
6361
|
+
return /* @__PURE__ */ jsx63("span", { className: cx("ow-chip", className), ...props });
|
|
6346
6362
|
}
|
|
6347
6363
|
function SectionHeading({
|
|
6348
6364
|
eyebrow,
|
|
@@ -6353,16 +6369,16 @@ function SectionHeading({
|
|
|
6353
6369
|
className
|
|
6354
6370
|
}) {
|
|
6355
6371
|
return /* @__PURE__ */ jsxs47("div", { className: cx("ow-section-heading", align === "center" && "ow-section-heading--center", className), children: [
|
|
6356
|
-
eyebrow ? /* @__PURE__ */
|
|
6357
|
-
/* @__PURE__ */
|
|
6358
|
-
intro ? /* @__PURE__ */
|
|
6372
|
+
eyebrow ? /* @__PURE__ */ jsx63(Chip, { children: eyebrow }) : null,
|
|
6373
|
+
/* @__PURE__ */ jsx63(Heading, { className: "ow-section-heading__title", children: title }),
|
|
6374
|
+
intro ? /* @__PURE__ */ jsx63("p", { className: "ow-section-heading__intro", children: intro }) : null
|
|
6359
6375
|
] });
|
|
6360
6376
|
}
|
|
6361
6377
|
function SiteHeader({ brand, nav, actions, className }) {
|
|
6362
6378
|
return /* @__PURE__ */ jsxs47("header", { className: cx("ow-site-header", className), children: [
|
|
6363
|
-
/* @__PURE__ */
|
|
6364
|
-
nav ? /* @__PURE__ */
|
|
6365
|
-
actions ? /* @__PURE__ */
|
|
6379
|
+
/* @__PURE__ */ jsx63("div", { className: "ow-site-header__brand", children: brand }),
|
|
6380
|
+
nav ? /* @__PURE__ */ jsx63("nav", { className: "ow-site-header__nav", children: nav }) : null,
|
|
6381
|
+
actions ? /* @__PURE__ */ jsx63("div", { className: "ow-site-header__actions", children: actions }) : null
|
|
6366
6382
|
] });
|
|
6367
6383
|
}
|
|
6368
6384
|
function DotGrid({ fade = false, interactive = false, className, children, onPointerMove, ...props }) {
|
|
@@ -6383,23 +6399,40 @@ function DotGrid({ fade = false, interactive = false, className, children, onPoi
|
|
|
6383
6399
|
onPointerMove: track,
|
|
6384
6400
|
...props,
|
|
6385
6401
|
children: [
|
|
6386
|
-
/* @__PURE__ */
|
|
6387
|
-
interactive ? /* @__PURE__ */
|
|
6388
|
-
/* @__PURE__ */
|
|
6402
|
+
/* @__PURE__ */ jsx63("span", { className: "ow-dot-grid__dots", "aria-hidden": "true" }),
|
|
6403
|
+
interactive ? /* @__PURE__ */ jsx63("span", { className: "ow-dot-grid__brass", "aria-hidden": "true" }) : null,
|
|
6404
|
+
/* @__PURE__ */ jsx63("div", { className: "ow-dot-grid__content", children })
|
|
6389
6405
|
]
|
|
6390
6406
|
}
|
|
6391
6407
|
);
|
|
6392
6408
|
}
|
|
6393
6409
|
|
|
6394
6410
|
// src/components/Prose/Prose.tsx
|
|
6395
|
-
import { forwardRef as forwardRef23 } from "react";
|
|
6396
|
-
import { jsx as
|
|
6411
|
+
import { forwardRef as forwardRef23, useEffect as useEffect26, useRef as useRef34 } from "react";
|
|
6412
|
+
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
6397
6413
|
var Prose = /* @__PURE__ */ forwardRef23(function Prose2({ size: size2 = "md", fullWidth = false, as = "div", className, children, ...props }, ref) {
|
|
6398
6414
|
const Element2 = as;
|
|
6399
|
-
|
|
6415
|
+
const root = useRef34(null);
|
|
6416
|
+
useEffect26(() => {
|
|
6417
|
+
const element = root.current;
|
|
6418
|
+
if (!element) return;
|
|
6419
|
+
for (const scroller of element.querySelectorAll("pre, .ow-table-wrap")) {
|
|
6420
|
+
if (scroller.scrollWidth > scroller.clientWidth && !scroller.hasAttribute("tabindex")) scroller.tabIndex = 0;
|
|
6421
|
+
}
|
|
6422
|
+
for (const box of element.querySelectorAll('li > input[type="checkbox"], li > p > input[type="checkbox"]')) {
|
|
6423
|
+
if (box.labels?.length || box.hasAttribute("aria-label") || box.hasAttribute("aria-labelledby")) continue;
|
|
6424
|
+
const text = box.closest("li")?.textContent?.trim();
|
|
6425
|
+
if (text) box.setAttribute("aria-label", text);
|
|
6426
|
+
}
|
|
6427
|
+
});
|
|
6428
|
+
return /* @__PURE__ */ jsx64(
|
|
6400
6429
|
Element2,
|
|
6401
6430
|
{
|
|
6402
|
-
ref
|
|
6431
|
+
ref: (node) => {
|
|
6432
|
+
root.current = node;
|
|
6433
|
+
if (typeof ref === "function") ref(node);
|
|
6434
|
+
else if (ref) ref.current = node;
|
|
6435
|
+
},
|
|
6403
6436
|
className: cx("ow-prose", `ow-prose--${size2}`, size2 === "md" ? "ow-type-prose" : "ow-type-copy", fullWidth && "ow-prose--full", className),
|
|
6404
6437
|
...props,
|
|
6405
6438
|
children
|
|
@@ -6408,10 +6441,10 @@ var Prose = /* @__PURE__ */ forwardRef23(function Prose2({ size: size2 = "md", f
|
|
|
6408
6441
|
});
|
|
6409
6442
|
|
|
6410
6443
|
// src/components/TextShimmer/TextShimmer.tsx
|
|
6411
|
-
import { jsx as
|
|
6444
|
+
import { jsx as jsx65 } from "react/jsx-runtime";
|
|
6412
6445
|
function TextShimmer({ children, as = "span", duration = 2, active = true, className }) {
|
|
6413
6446
|
const Element2 = as;
|
|
6414
|
-
return /* @__PURE__ */
|
|
6447
|
+
return /* @__PURE__ */ jsx65(
|
|
6415
6448
|
Element2,
|
|
6416
6449
|
{
|
|
6417
6450
|
className: cx("ow-shimmer", active && "ow-shimmer--active", className),
|
|
@@ -6424,18 +6457,18 @@ function TextShimmer({ children, as = "span", duration = 2, active = true, class
|
|
|
6424
6457
|
// src/components/PromptInput/PromptInput.tsx
|
|
6425
6458
|
import {
|
|
6426
6459
|
forwardRef as forwardRef24,
|
|
6427
|
-
useEffect as
|
|
6460
|
+
useEffect as useEffect27,
|
|
6428
6461
|
useId as useId22,
|
|
6429
6462
|
useLayoutEffect as useLayoutEffect7,
|
|
6430
|
-
useRef as
|
|
6463
|
+
useRef as useRef35,
|
|
6431
6464
|
useState as useState29
|
|
6432
6465
|
} from "react";
|
|
6433
|
-
import { jsx as
|
|
6466
|
+
import { jsx as jsx66, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
6434
6467
|
var noAttachments = [];
|
|
6435
6468
|
var counterFrom = 0.8;
|
|
6436
6469
|
var announceDelay = 1e3;
|
|
6437
6470
|
function Glyph({ children }) {
|
|
6438
|
-
return /* @__PURE__ */
|
|
6471
|
+
return /* @__PURE__ */ jsx66(
|
|
6439
6472
|
"svg",
|
|
6440
6473
|
{
|
|
6441
6474
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6455,29 +6488,29 @@ function Glyph({ children }) {
|
|
|
6455
6488
|
}
|
|
6456
6489
|
var sheet = "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z";
|
|
6457
6490
|
var fold = "M14 2v5a1 1 0 0 0 1 1h5";
|
|
6458
|
-
var PaperclipIcon = () => /* @__PURE__ */
|
|
6459
|
-
var StopIcon = () => /* @__PURE__ */
|
|
6491
|
+
var PaperclipIcon = () => /* @__PURE__ */ jsx66(Glyph, { children: /* @__PURE__ */ jsx66("path", { d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551" }) });
|
|
6492
|
+
var StopIcon = () => /* @__PURE__ */ jsx66(Glyph, { children: /* @__PURE__ */ jsx66("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2", fill: "currentColor", stroke: "none" }) });
|
|
6460
6493
|
var fileIcons = {
|
|
6461
6494
|
image: /* @__PURE__ */ jsxs48(Glyph, { children: [
|
|
6462
|
-
/* @__PURE__ */
|
|
6463
|
-
/* @__PURE__ */
|
|
6464
|
-
/* @__PURE__ */
|
|
6465
|
-
/* @__PURE__ */
|
|
6495
|
+
/* @__PURE__ */ jsx66("path", { d: sheet }),
|
|
6496
|
+
/* @__PURE__ */ jsx66("path", { d: fold }),
|
|
6497
|
+
/* @__PURE__ */ jsx66("circle", { cx: "10", cy: "12", r: "2" }),
|
|
6498
|
+
/* @__PURE__ */ jsx66("path", { d: "m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22" })
|
|
6466
6499
|
] }),
|
|
6467
6500
|
code: /* @__PURE__ */ jsxs48(Glyph, { children: [
|
|
6468
|
-
/* @__PURE__ */
|
|
6469
|
-
/* @__PURE__ */
|
|
6470
|
-
/* @__PURE__ */
|
|
6471
|
-
/* @__PURE__ */
|
|
6501
|
+
/* @__PURE__ */ jsx66("path", { d: sheet }),
|
|
6502
|
+
/* @__PURE__ */ jsx66("path", { d: fold }),
|
|
6503
|
+
/* @__PURE__ */ jsx66("path", { d: "M10 12.5 8 15l2 2.5" }),
|
|
6504
|
+
/* @__PURE__ */ jsx66("path", { d: "m14 12.5 2 2.5-2 2.5" })
|
|
6472
6505
|
] }),
|
|
6473
6506
|
text: /* @__PURE__ */ jsxs48(Glyph, { children: [
|
|
6474
|
-
/* @__PURE__ */
|
|
6475
|
-
/* @__PURE__ */
|
|
6476
|
-
/* @__PURE__ */
|
|
6477
|
-
/* @__PURE__ */
|
|
6478
|
-
/* @__PURE__ */
|
|
6507
|
+
/* @__PURE__ */ jsx66("path", { d: sheet }),
|
|
6508
|
+
/* @__PURE__ */ jsx66("path", { d: fold }),
|
|
6509
|
+
/* @__PURE__ */ jsx66("path", { d: "M10 9H8" }),
|
|
6510
|
+
/* @__PURE__ */ jsx66("path", { d: "M16 13H8" }),
|
|
6511
|
+
/* @__PURE__ */ jsx66("path", { d: "M16 17H8" })
|
|
6479
6512
|
] }),
|
|
6480
|
-
file: /* @__PURE__ */
|
|
6513
|
+
file: /* @__PURE__ */ jsx66(FileIcon, { size: 16 })
|
|
6481
6514
|
};
|
|
6482
6515
|
function kindOf({ name, type = "" }) {
|
|
6483
6516
|
const lower = name.toLowerCase();
|
|
@@ -6549,13 +6582,13 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6549
6582
|
className
|
|
6550
6583
|
}, ref) {
|
|
6551
6584
|
const [text, setText] = useControllableState(value, defaultValue, onChange);
|
|
6552
|
-
const textAreaRef =
|
|
6553
|
-
const actionRef =
|
|
6554
|
-
const pickerRef =
|
|
6555
|
-
const listRef =
|
|
6556
|
-
const composing =
|
|
6557
|
-
const dragDepth =
|
|
6558
|
-
const pendingFocus =
|
|
6585
|
+
const textAreaRef = useRef35(null);
|
|
6586
|
+
const actionRef = useRef35(null);
|
|
6587
|
+
const pickerRef = useRef35(null);
|
|
6588
|
+
const listRef = useRef35(null);
|
|
6589
|
+
const composing = useRef35(false);
|
|
6590
|
+
const dragDepth = useRef35(0);
|
|
6591
|
+
const pendingFocus = useRef35(null);
|
|
6559
6592
|
const [isDragging, setIsDragging] = useState29(false);
|
|
6560
6593
|
const [notice, setNotice] = useState29();
|
|
6561
6594
|
const [announcement, setAnnouncement] = useState29("");
|
|
@@ -6578,7 +6611,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6578
6611
|
if (typeof ref === "function") ref(element);
|
|
6579
6612
|
else if (ref) ref.current = element;
|
|
6580
6613
|
}
|
|
6581
|
-
|
|
6614
|
+
useEffect27(() => {
|
|
6582
6615
|
const textArea = textAreaRef.current;
|
|
6583
6616
|
if (!textArea || typeof ResizeObserver === "undefined") return;
|
|
6584
6617
|
let width = textArea.clientWidth;
|
|
@@ -6593,8 +6626,8 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6593
6626
|
useLayoutEffect7(() => {
|
|
6594
6627
|
if (textAreaRef.current) resizeTextArea(textAreaRef.current);
|
|
6595
6628
|
}, [size2, rows]);
|
|
6596
|
-
const wasStreaming =
|
|
6597
|
-
const actionHadFocus =
|
|
6629
|
+
const wasStreaming = useRef35(isStreaming);
|
|
6630
|
+
const actionHadFocus = useRef35(false);
|
|
6598
6631
|
if (wasStreaming.current !== isStreaming) {
|
|
6599
6632
|
actionHadFocus.current = typeof document !== "undefined" && document.activeElement === actionRef.current;
|
|
6600
6633
|
}
|
|
@@ -6612,7 +6645,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6612
6645
|
const next = buttons?.length ? buttons[Math.min(pending.index, buttons.length - 1)] : void 0;
|
|
6613
6646
|
(next ?? textAreaRef.current)?.focus();
|
|
6614
6647
|
}, [attachments]);
|
|
6615
|
-
|
|
6648
|
+
useEffect27(() => {
|
|
6616
6649
|
if (!showCounter || document.activeElement !== textAreaRef.current) return;
|
|
6617
6650
|
const timer = window.setTimeout(() => {
|
|
6618
6651
|
setAnnouncement(`${number(remaining)} ${remaining === 1 ? "character" : "characters"} left`);
|
|
@@ -6670,7 +6703,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6670
6703
|
event.preventDefault();
|
|
6671
6704
|
textAreaRef.current?.focus();
|
|
6672
6705
|
}
|
|
6673
|
-
const attachButton = onAttach ? /* @__PURE__ */
|
|
6706
|
+
const attachButton = onAttach ? /* @__PURE__ */ jsx66(Tooltip, { label: "Attach files", children: /* @__PURE__ */ jsx66(
|
|
6674
6707
|
Button,
|
|
6675
6708
|
{
|
|
6676
6709
|
className: "ow-prompt-input__attach",
|
|
@@ -6680,11 +6713,11 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6680
6713
|
"aria-label": multiple ? "Attach files" : "Attach a file",
|
|
6681
6714
|
disabled,
|
|
6682
6715
|
onClick: () => pickerRef.current?.click(),
|
|
6683
|
-
children: /* @__PURE__ */
|
|
6716
|
+
children: /* @__PURE__ */ jsx66(PaperclipIcon, {})
|
|
6684
6717
|
}
|
|
6685
6718
|
) }) : null;
|
|
6686
6719
|
const actionLabel = isStreaming ? "Stop" : "Send";
|
|
6687
|
-
const actionButton = /* @__PURE__ */
|
|
6720
|
+
const actionButton = /* @__PURE__ */ jsx66(Tooltip, { label: actionLabel, children: /* @__PURE__ */ jsx66(
|
|
6688
6721
|
Button,
|
|
6689
6722
|
{
|
|
6690
6723
|
ref: actionRef,
|
|
@@ -6699,7 +6732,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6699
6732
|
else submit();
|
|
6700
6733
|
textAreaRef.current?.focus();
|
|
6701
6734
|
},
|
|
6702
|
-
children: isStreaming ? /* @__PURE__ */
|
|
6735
|
+
children: isStreaming ? /* @__PURE__ */ jsx66(StopIcon, {}) : /* @__PURE__ */ jsx66(ArrowUpIcon, { size: 16 })
|
|
6703
6736
|
}
|
|
6704
6737
|
) });
|
|
6705
6738
|
return /* @__PURE__ */ jsxs48(
|
|
@@ -6746,12 +6779,12 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6746
6779
|
take(Array.from(event.dataTransfer.files));
|
|
6747
6780
|
},
|
|
6748
6781
|
children: [
|
|
6749
|
-
attachments.length ? /* @__PURE__ */
|
|
6782
|
+
attachments.length ? /* @__PURE__ */ jsx66("ul", { ref: listRef, className: "ow-prompt-input__attachments", "aria-label": "Attachments", children: attachments.map((attachment, index) => {
|
|
6750
6783
|
const [base, extension] = splitName(attachment.name);
|
|
6751
6784
|
return /* @__PURE__ */ jsxs48("li", { className: "ow-prompt-input__attachment", children: [
|
|
6752
6785
|
/* @__PURE__ */ jsxs48("span", { className: "ow-prompt-input__thumb", "aria-hidden": "true", children: [
|
|
6753
6786
|
fileIcons[kindOf(attachment)],
|
|
6754
|
-
attachment.previewUrl ? /* @__PURE__ */
|
|
6787
|
+
attachment.previewUrl ? /* @__PURE__ */ jsx66(
|
|
6755
6788
|
"img",
|
|
6756
6789
|
{
|
|
6757
6790
|
src: attachment.previewUrl,
|
|
@@ -6764,24 +6797,24 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6764
6797
|
] }),
|
|
6765
6798
|
/* @__PURE__ */ jsxs48("span", { className: "ow-prompt-input__file", children: [
|
|
6766
6799
|
/* @__PURE__ */ jsxs48("span", { className: "ow-prompt-input__file-name", title: attachment.name, children: [
|
|
6767
|
-
/* @__PURE__ */
|
|
6800
|
+
/* @__PURE__ */ jsx66("span", { className: "ow-prompt-input__file-base", children: base }),
|
|
6768
6801
|
extension
|
|
6769
6802
|
] }),
|
|
6770
|
-
attachment.size !== void 0 ? /* @__PURE__ */
|
|
6803
|
+
attachment.size !== void 0 ? /* @__PURE__ */ jsx66("span", { className: "ow-prompt-input__file-size", children: formatBytes(attachment.size, locale) }) : null
|
|
6771
6804
|
] }),
|
|
6772
|
-
onRemoveAttachment ? /* @__PURE__ */
|
|
6805
|
+
onRemoveAttachment ? /* @__PURE__ */ jsx66(
|
|
6773
6806
|
"button",
|
|
6774
6807
|
{
|
|
6775
6808
|
type: "button",
|
|
6776
6809
|
className: "ow-prompt-input__remove",
|
|
6777
6810
|
"aria-label": `Remove ${attachment.name}`,
|
|
6778
6811
|
onClick: () => remove(attachment, index),
|
|
6779
|
-
children: /* @__PURE__ */
|
|
6812
|
+
children: /* @__PURE__ */ jsx66(XIcon, { size: 14 })
|
|
6780
6813
|
}
|
|
6781
6814
|
) : null
|
|
6782
6815
|
] }, attachment.id);
|
|
6783
6816
|
}) }) : null,
|
|
6784
|
-
/* @__PURE__ */
|
|
6817
|
+
/* @__PURE__ */ jsx66(
|
|
6785
6818
|
Textarea,
|
|
6786
6819
|
{
|
|
6787
6820
|
ref: setTextAreaRef,
|
|
@@ -6827,7 +6860,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6827
6860
|
actionButton
|
|
6828
6861
|
] })
|
|
6829
6862
|
] }),
|
|
6830
|
-
onAttach ? /* @__PURE__ */
|
|
6863
|
+
onAttach ? /* @__PURE__ */ jsx66(
|
|
6831
6864
|
"input",
|
|
6832
6865
|
{
|
|
6833
6866
|
ref: pickerRef,
|
|
@@ -6844,13 +6877,13 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6844
6877
|
}
|
|
6845
6878
|
) : null,
|
|
6846
6879
|
isDragging ? /* @__PURE__ */ jsxs48("div", { className: "ow-prompt-input__drop", "aria-hidden": "true", children: [
|
|
6847
|
-
/* @__PURE__ */
|
|
6880
|
+
/* @__PURE__ */ jsx66(UploadIcon, { size: 16 }),
|
|
6848
6881
|
"Drop to attach"
|
|
6849
6882
|
] }) : null
|
|
6850
6883
|
]
|
|
6851
6884
|
}
|
|
6852
6885
|
),
|
|
6853
|
-
shownHint ? /* @__PURE__ */
|
|
6886
|
+
shownHint ? /* @__PURE__ */ jsx66(
|
|
6854
6887
|
"div",
|
|
6855
6888
|
{
|
|
6856
6889
|
className: cx("ow-prompt-input__hint", notice && "ow-prompt-input__hint--notice"),
|
|
@@ -6859,7 +6892,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6859
6892
|
children: shownHint
|
|
6860
6893
|
}
|
|
6861
6894
|
) : null,
|
|
6862
|
-
/* @__PURE__ */
|
|
6895
|
+
/* @__PURE__ */ jsx66("span", { className: "ow-visually-hidden", role: "status", children: announcement })
|
|
6863
6896
|
]
|
|
6864
6897
|
}
|
|
6865
6898
|
);
|
|
@@ -6867,14 +6900,14 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6867
6900
|
|
|
6868
6901
|
// src/components/PromptInput/PromptSuggestion.tsx
|
|
6869
6902
|
import { forwardRef as forwardRef25 } from "react";
|
|
6870
|
-
import { jsx as
|
|
6903
|
+
import { jsx as jsx67, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
6871
6904
|
var PromptSuggestion = /* @__PURE__ */ forwardRef25(function PromptSuggestion2({ children, icon: icon2, description, variant = description ? "card" : "pill", type = "button", className, ...buttonProps }, ref) {
|
|
6872
6905
|
if (variant === "card") {
|
|
6873
6906
|
return /* @__PURE__ */ jsxs49("button", { ref, type, className: cx("ow-prompt-suggestion", "ow-prompt-suggestion--card", className), ...buttonProps, children: [
|
|
6874
|
-
icon2 ? /* @__PURE__ */
|
|
6907
|
+
icon2 ? /* @__PURE__ */ jsx67("span", { className: "ow-prompt-suggestion__icon", children: icon2 }) : null,
|
|
6875
6908
|
/* @__PURE__ */ jsxs49("span", { className: "ow-prompt-suggestion__text", children: [
|
|
6876
|
-
/* @__PURE__ */
|
|
6877
|
-
description ? /* @__PURE__ */
|
|
6909
|
+
/* @__PURE__ */ jsx67("span", { className: "ow-prompt-suggestion__title", children }),
|
|
6910
|
+
description ? /* @__PURE__ */ jsx67("span", { className: "ow-prompt-suggestion__description", children: description }) : null
|
|
6878
6911
|
] })
|
|
6879
6912
|
] });
|
|
6880
6913
|
}
|
|
@@ -6891,8 +6924,8 @@ var PromptSuggestion = /* @__PURE__ */ forwardRef25(function PromptSuggestion2({
|
|
|
6891
6924
|
),
|
|
6892
6925
|
...buttonProps,
|
|
6893
6926
|
children: [
|
|
6894
|
-
icon2 ? /* @__PURE__ */
|
|
6895
|
-
/* @__PURE__ */
|
|
6927
|
+
icon2 ? /* @__PURE__ */ jsx67("span", { className: "ow-prompt-suggestion__icon", children: icon2 }) : null,
|
|
6928
|
+
/* @__PURE__ */ jsx67("span", { className: "ow-prompt-suggestion__label", children })
|
|
6896
6929
|
]
|
|
6897
6930
|
}
|
|
6898
6931
|
);
|
|
@@ -6907,7 +6940,7 @@ function PromptSuggestions({
|
|
|
6907
6940
|
style,
|
|
6908
6941
|
...props
|
|
6909
6942
|
}) {
|
|
6910
|
-
return /* @__PURE__ */
|
|
6943
|
+
return /* @__PURE__ */ jsx67(
|
|
6911
6944
|
"div",
|
|
6912
6945
|
{
|
|
6913
6946
|
role: "group",
|
|
@@ -6926,14 +6959,14 @@ import {
|
|
|
6926
6959
|
createContext as createContext8,
|
|
6927
6960
|
forwardRef as forwardRef26,
|
|
6928
6961
|
useCallback as useCallback10,
|
|
6929
|
-
useEffect as
|
|
6962
|
+
useEffect as useEffect28,
|
|
6930
6963
|
useImperativeHandle as useImperativeHandle3,
|
|
6931
6964
|
useLayoutEffect as useLayoutEffect8,
|
|
6932
6965
|
useMemo as useMemo12,
|
|
6933
|
-
useRef as
|
|
6966
|
+
useRef as useRef36,
|
|
6934
6967
|
useState as useState30
|
|
6935
6968
|
} from "react";
|
|
6936
|
-
import { jsx as
|
|
6969
|
+
import { jsx as jsx68, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
6937
6970
|
var ChatConversationContext = /* @__PURE__ */ createContext8(null);
|
|
6938
6971
|
var stickyDistance = 32;
|
|
6939
6972
|
var defaultCount = (count) => `${count} new`;
|
|
@@ -6950,13 +6983,13 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
6950
6983
|
className,
|
|
6951
6984
|
...props
|
|
6952
6985
|
}, ref) {
|
|
6953
|
-
const scrollerRef =
|
|
6954
|
-
const contentRef =
|
|
6955
|
-
const jumpRef =
|
|
6956
|
-
const following =
|
|
6957
|
-
const lastTop =
|
|
6958
|
-
const ready =
|
|
6959
|
-
const unseen =
|
|
6986
|
+
const scrollerRef = useRef36(null);
|
|
6987
|
+
const contentRef = useRef36(null);
|
|
6988
|
+
const jumpRef = useRef36(null);
|
|
6989
|
+
const following = useRef36(true);
|
|
6990
|
+
const lastTop = useRef36(0);
|
|
6991
|
+
const ready = useRef36(false);
|
|
6992
|
+
const unseen = useRef36(/* @__PURE__ */ new Set());
|
|
6960
6993
|
const [isFollowing, setIsFollowing] = useState30(true);
|
|
6961
6994
|
const [newCount, setNewCount] = useState30(0);
|
|
6962
6995
|
const isEmpty = Children2.toArray(children).length === 0;
|
|
@@ -6985,10 +7018,10 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
6985
7018
|
);
|
|
6986
7019
|
useImperativeHandle3(ref, () => ({ scrollToBottom }), [scrollToBottom]);
|
|
6987
7020
|
useLayoutEffect8(stick, [stick]);
|
|
6988
|
-
|
|
7021
|
+
useEffect28(() => {
|
|
6989
7022
|
ready.current = true;
|
|
6990
7023
|
}, []);
|
|
6991
|
-
|
|
7024
|
+
useEffect28(() => {
|
|
6992
7025
|
const scroller = scrollerRef.current;
|
|
6993
7026
|
const content = contentRef.current;
|
|
6994
7027
|
if (!scroller || !content || typeof ResizeObserver === "undefined") return void 0;
|
|
@@ -7030,7 +7063,7 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7030
7063
|
const jump = usePresence(showJump);
|
|
7031
7064
|
return /* @__PURE__ */ jsxs50("div", { className: cx("ow-chat-conversation", width === "full" && "ow-chat-conversation--full", className), ...props, children: [
|
|
7032
7065
|
/* @__PURE__ */ jsxs50("div", { className: "ow-chat-conversation__viewport", children: [
|
|
7033
|
-
/* @__PURE__ */
|
|
7066
|
+
/* @__PURE__ */ jsx68(
|
|
7034
7067
|
"div",
|
|
7035
7068
|
{
|
|
7036
7069
|
ref: scrollerRef,
|
|
@@ -7042,17 +7075,17 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7042
7075
|
"aria-labelledby": ariaLabelledBy,
|
|
7043
7076
|
tabIndex: isEmpty ? void 0 : 0,
|
|
7044
7077
|
onScroll,
|
|
7045
|
-
children: /* @__PURE__ */
|
|
7078
|
+
children: /* @__PURE__ */ jsx68("div", { ref: contentRef, className: "ow-chat-conversation__content", children: /* @__PURE__ */ jsx68(ChatConversationContext.Provider, { value: context, children }) })
|
|
7046
7079
|
}
|
|
7047
7080
|
),
|
|
7048
|
-
isEmpty && empty ? /* @__PURE__ */
|
|
7049
|
-
jump.mounted ? /* @__PURE__ */
|
|
7081
|
+
isEmpty && empty ? /* @__PURE__ */ jsx68("div", { className: "ow-chat-conversation__empty", children: /* @__PURE__ */ jsx68("div", { className: "ow-chat-conversation__empty-inner", children: empty }) }) : null,
|
|
7082
|
+
jump.mounted ? /* @__PURE__ */ jsx68("div", { className: "ow-chat-conversation__jump", "data-state": jump.state, children: /* @__PURE__ */ jsxs50(
|
|
7050
7083
|
Button,
|
|
7051
7084
|
{
|
|
7052
7085
|
ref: jumpRef,
|
|
7053
7086
|
size: "sm",
|
|
7054
7087
|
shape: "pill",
|
|
7055
|
-
startIcon: /* @__PURE__ */
|
|
7088
|
+
startIcon: /* @__PURE__ */ jsx68(ArrowDownIcon, { size: 16 }),
|
|
7056
7089
|
"aria-label": newCount > 0 ? `${jumpLabel}, ${formatNewCount(newCount)}` : jumpLabel,
|
|
7057
7090
|
tabIndex: showJump ? void 0 : -1,
|
|
7058
7091
|
onClick: () => {
|
|
@@ -7061,12 +7094,12 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7061
7094
|
},
|
|
7062
7095
|
children: [
|
|
7063
7096
|
jumpLabel,
|
|
7064
|
-
newCount > 0 ? /* @__PURE__ */
|
|
7097
|
+
newCount > 0 ? /* @__PURE__ */ jsx68("span", { className: "ow-chat-conversation__count", children: formatNewCount(newCount) }) : null
|
|
7065
7098
|
]
|
|
7066
7099
|
}
|
|
7067
7100
|
) }) : null
|
|
7068
7101
|
] }),
|
|
7069
|
-
footer != null && footer !== false ? /* @__PURE__ */
|
|
7102
|
+
footer != null && footer !== false ? /* @__PURE__ */ jsx68("div", { className: "ow-chat-conversation__footer", children: /* @__PURE__ */ jsx68("div", { className: "ow-chat-conversation__footer-inner", children: footer }) }) : null
|
|
7070
7103
|
] });
|
|
7071
7104
|
});
|
|
7072
7105
|
|
|
@@ -7074,16 +7107,16 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7074
7107
|
import {
|
|
7075
7108
|
forwardRef as forwardRef27,
|
|
7076
7109
|
useContext as useContext10,
|
|
7077
|
-
useEffect as
|
|
7110
|
+
useEffect as useEffect29,
|
|
7078
7111
|
useId as useId23,
|
|
7079
7112
|
useLayoutEffect as useLayoutEffect9,
|
|
7080
|
-
useRef as
|
|
7113
|
+
useRef as useRef37,
|
|
7081
7114
|
useState as useState31
|
|
7082
7115
|
} from "react";
|
|
7083
|
-
import { Fragment as Fragment10, jsx as
|
|
7116
|
+
import { Fragment as Fragment10, jsx as jsx69, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
7084
7117
|
function lucide(paths) {
|
|
7085
7118
|
return function Icon({ size: size2 = 16, strokeWidth = 2, ...props }) {
|
|
7086
|
-
return /* @__PURE__ */
|
|
7119
|
+
return /* @__PURE__ */ jsx69(
|
|
7087
7120
|
"svg",
|
|
7088
7121
|
{
|
|
7089
7122
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -7105,48 +7138,48 @@ function lucide(paths) {
|
|
|
7105
7138
|
}
|
|
7106
7139
|
var BotIcon = /* @__PURE__ */ lucide(
|
|
7107
7140
|
/* @__PURE__ */ jsxs51(Fragment10, { children: [
|
|
7108
|
-
/* @__PURE__ */
|
|
7109
|
-
/* @__PURE__ */
|
|
7110
|
-
/* @__PURE__ */
|
|
7111
|
-
/* @__PURE__ */
|
|
7112
|
-
/* @__PURE__ */
|
|
7113
|
-
/* @__PURE__ */
|
|
7141
|
+
/* @__PURE__ */ jsx69("path", { d: "M12 8V4H8" }),
|
|
7142
|
+
/* @__PURE__ */ jsx69("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }),
|
|
7143
|
+
/* @__PURE__ */ jsx69("path", { d: "M2 14h2" }),
|
|
7144
|
+
/* @__PURE__ */ jsx69("path", { d: "M20 14h2" }),
|
|
7145
|
+
/* @__PURE__ */ jsx69("path", { d: "M15 13v2" }),
|
|
7146
|
+
/* @__PURE__ */ jsx69("path", { d: "M9 13v2" })
|
|
7114
7147
|
] })
|
|
7115
7148
|
);
|
|
7116
7149
|
var RotateCcwIcon = /* @__PURE__ */ lucide(
|
|
7117
7150
|
/* @__PURE__ */ jsxs51(Fragment10, { children: [
|
|
7118
|
-
/* @__PURE__ */
|
|
7119
|
-
/* @__PURE__ */
|
|
7151
|
+
/* @__PURE__ */ jsx69("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
|
|
7152
|
+
/* @__PURE__ */ jsx69("path", { d: "M3 3v5h5" })
|
|
7120
7153
|
] })
|
|
7121
7154
|
);
|
|
7122
7155
|
var ThumbsUpIcon = /* @__PURE__ */ lucide(
|
|
7123
7156
|
/* @__PURE__ */ jsxs51(Fragment10, { children: [
|
|
7124
|
-
/* @__PURE__ */
|
|
7125
|
-
/* @__PURE__ */
|
|
7157
|
+
/* @__PURE__ */ jsx69("path", { d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" }),
|
|
7158
|
+
/* @__PURE__ */ jsx69("path", { d: "M7 10v12" })
|
|
7126
7159
|
] })
|
|
7127
7160
|
);
|
|
7128
7161
|
var ThumbsDownIcon = /* @__PURE__ */ lucide(
|
|
7129
7162
|
/* @__PURE__ */ jsxs51(Fragment10, { children: [
|
|
7130
|
-
/* @__PURE__ */
|
|
7131
|
-
/* @__PURE__ */
|
|
7163
|
+
/* @__PURE__ */ jsx69("path", { d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z" }),
|
|
7164
|
+
/* @__PURE__ */ jsx69("path", { d: "M17 14V2" })
|
|
7132
7165
|
] })
|
|
7133
7166
|
);
|
|
7134
7167
|
var PencilIcon = /* @__PURE__ */ lucide(
|
|
7135
7168
|
/* @__PURE__ */ jsxs51(Fragment10, { children: [
|
|
7136
|
-
/* @__PURE__ */
|
|
7137
|
-
/* @__PURE__ */
|
|
7169
|
+
/* @__PURE__ */ jsx69("path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }),
|
|
7170
|
+
/* @__PURE__ */ jsx69("path", { d: "m15 5 4 4" })
|
|
7138
7171
|
] })
|
|
7139
7172
|
);
|
|
7140
7173
|
var botSizes = { sm: 14, md: 16, lg: 18 };
|
|
7141
7174
|
function ChatAgentAvatar({ size: size2 = "md", label, className }) {
|
|
7142
|
-
return /* @__PURE__ */
|
|
7175
|
+
return /* @__PURE__ */ jsx69(
|
|
7143
7176
|
"span",
|
|
7144
7177
|
{
|
|
7145
7178
|
className: cx("ow-chat-avatar", size2 !== "md" && `ow-chat-avatar--${size2}`, className),
|
|
7146
7179
|
role: label ? "img" : void 0,
|
|
7147
7180
|
"aria-label": label,
|
|
7148
7181
|
"aria-hidden": label ? void 0 : true,
|
|
7149
|
-
children: /* @__PURE__ */
|
|
7182
|
+
children: /* @__PURE__ */ jsx69(BotIcon, { size: botSizes[size2] })
|
|
7150
7183
|
}
|
|
7151
7184
|
);
|
|
7152
7185
|
}
|
|
@@ -7171,10 +7204,10 @@ function formattersFor(locale) {
|
|
|
7171
7204
|
function MessageTime({ time, locale }) {
|
|
7172
7205
|
const date = typeof time === "string" ? new Date(time) : time;
|
|
7173
7206
|
if (Number.isNaN(date.getTime())) {
|
|
7174
|
-
return /* @__PURE__ */
|
|
7207
|
+
return /* @__PURE__ */ jsx69("time", { className: "ow-chat-message__time", children: String(time) });
|
|
7175
7208
|
}
|
|
7176
7209
|
const { short, full } = formattersFor(locale);
|
|
7177
|
-
return /* @__PURE__ */
|
|
7210
|
+
return /* @__PURE__ */ jsx69("time", { className: "ow-chat-message__time", dateTime: date.toISOString(), title: full.format(date), children: short.format(date) });
|
|
7178
7211
|
}
|
|
7179
7212
|
var skipCaret = '[aria-hidden="true"], .ow-visually-hidden';
|
|
7180
7213
|
function useStreamingCaret(bodyRef, contentRef, caretRef, active) {
|
|
@@ -7227,14 +7260,14 @@ var ChatMessage = /* @__PURE__ */ forwardRef27(function ChatMessage2({ from, chi
|
|
|
7227
7260
|
const conversation = useContext10(ChatConversationContext);
|
|
7228
7261
|
const entering = useChatEntrance();
|
|
7229
7262
|
const id = useId23();
|
|
7230
|
-
const bodyRef =
|
|
7231
|
-
const contentRef =
|
|
7232
|
-
const caretRef =
|
|
7263
|
+
const bodyRef = useRef37(null);
|
|
7264
|
+
const contentRef = useRef37(null);
|
|
7265
|
+
const caretRef = useRef37(null);
|
|
7233
7266
|
const streaming = status === "streaming";
|
|
7234
|
-
|
|
7267
|
+
useEffect29(() => conversation?.register(id), [conversation, id]);
|
|
7235
7268
|
useStreamingCaret(bodyRef, contentRef, caretRef, streaming && from !== "system");
|
|
7236
7269
|
if (from === "system") {
|
|
7237
|
-
return /* @__PURE__ */
|
|
7270
|
+
return /* @__PURE__ */ jsx69(
|
|
7238
7271
|
"div",
|
|
7239
7272
|
{
|
|
7240
7273
|
ref,
|
|
@@ -7243,15 +7276,15 @@ var ChatMessage = /* @__PURE__ */ forwardRef27(function ChatMessage2({ from, chi
|
|
|
7243
7276
|
children: /* @__PURE__ */ jsxs51("span", { className: "ow-chat-message__system-text", children: [
|
|
7244
7277
|
children,
|
|
7245
7278
|
time !== void 0 ? /* @__PURE__ */ jsxs51(Fragment10, { children: [
|
|
7246
|
-
/* @__PURE__ */
|
|
7247
|
-
/* @__PURE__ */
|
|
7279
|
+
/* @__PURE__ */ jsx69("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
7280
|
+
/* @__PURE__ */ jsx69(MessageTime, { time, locale })
|
|
7248
7281
|
] }) : null
|
|
7249
7282
|
] })
|
|
7250
7283
|
}
|
|
7251
7284
|
);
|
|
7252
7285
|
}
|
|
7253
7286
|
const isUser = from === "user";
|
|
7254
|
-
const avatarNode = avatar !== void 0 ? avatar : isUser ? null : /* @__PURE__ */
|
|
7287
|
+
const avatarNode = avatar !== void 0 ? avatar : isUser ? null : /* @__PURE__ */ jsx69(ChatAgentAvatar, {});
|
|
7255
7288
|
const hasHeader = name != null || time !== void 0;
|
|
7256
7289
|
const errorText = error ?? (isUser ? "Couldn't send this message." : "The answer didn't finish.");
|
|
7257
7290
|
return /* @__PURE__ */ jsxs51(
|
|
@@ -7270,22 +7303,22 @@ var ChatMessage = /* @__PURE__ */ forwardRef27(function ChatMessage2({ from, chi
|
|
|
7270
7303
|
"aria-busy": streaming || void 0,
|
|
7271
7304
|
...props,
|
|
7272
7305
|
children: [
|
|
7273
|
-
avatarNode != null && avatarNode !== false ? /* @__PURE__ */
|
|
7306
|
+
avatarNode != null && avatarNode !== false ? /* @__PURE__ */ jsx69("div", { className: "ow-chat-message__avatar", children: avatarNode }) : null,
|
|
7274
7307
|
/* @__PURE__ */ jsxs51("div", { className: "ow-chat-message__main", children: [
|
|
7275
7308
|
hasHeader ? /* @__PURE__ */ jsxs51("div", { className: "ow-chat-message__header", children: [
|
|
7276
|
-
name != null ? /* @__PURE__ */
|
|
7277
|
-
time !== void 0 ? /* @__PURE__ */
|
|
7278
|
-
] }) : /* @__PURE__ */
|
|
7309
|
+
name != null ? /* @__PURE__ */ jsx69("span", { className: "ow-chat-message__name", children: name }) : /* @__PURE__ */ jsx69("span", { className: "ow-visually-hidden", children: isUser ? "You" : "Agent" }),
|
|
7310
|
+
time !== void 0 ? /* @__PURE__ */ jsx69(MessageTime, { time, locale }) : null
|
|
7311
|
+
] }) : /* @__PURE__ */ jsx69("span", { className: "ow-visually-hidden", children: isUser ? "You" : "Agent" }),
|
|
7279
7312
|
/* @__PURE__ */ jsxs51("div", { ref: bodyRef, className: "ow-chat-message__body", children: [
|
|
7280
|
-
/* @__PURE__ */
|
|
7281
|
-
streaming ? /* @__PURE__ */
|
|
7313
|
+
/* @__PURE__ */ jsx69("div", { ref: contentRef, className: "ow-chat-message__content", children }),
|
|
7314
|
+
streaming ? /* @__PURE__ */ jsx69("span", { ref: caretRef, className: "ow-chat-message__caret", "aria-hidden": "true" }) : null
|
|
7282
7315
|
] }),
|
|
7283
7316
|
status === "error" ? /* @__PURE__ */ jsxs51("div", { className: cx("ow-chat-message__error", onRetry && "ow-chat-message__error--retry"), children: [
|
|
7284
|
-
/* @__PURE__ */
|
|
7285
|
-
/* @__PURE__ */
|
|
7286
|
-
onRetry ? /* @__PURE__ */
|
|
7317
|
+
/* @__PURE__ */ jsx69(CircleAlertIcon, { size: 16, className: "ow-chat-message__error-icon" }),
|
|
7318
|
+
/* @__PURE__ */ jsx69("span", { className: "ow-chat-message__error-text", children: errorText }),
|
|
7319
|
+
onRetry ? /* @__PURE__ */ jsx69(Button, { size: "sm", startIcon: /* @__PURE__ */ jsx69(RotateCcwIcon, { size: 16 }), onClick: onRetry, children: retryLabel }) : null
|
|
7287
7320
|
] }) : null,
|
|
7288
|
-
actions && !streaming ? /* @__PURE__ */
|
|
7321
|
+
actions && !streaming ? /* @__PURE__ */ jsx69("div", { className: "ow-chat-message__actions", children: actions }) : null
|
|
7289
7322
|
] })
|
|
7290
7323
|
]
|
|
7291
7324
|
}
|
|
@@ -7294,11 +7327,11 @@ var ChatMessage = /* @__PURE__ */ forwardRef27(function ChatMessage2({ from, chi
|
|
|
7294
7327
|
var defaultLabels = { copy: "Copy", copied: "Copied", edit: "Edit", retry: "Retry", good: "Good response", bad: "Bad response" };
|
|
7295
7328
|
function CopyAction({ text, label, copiedLabel }) {
|
|
7296
7329
|
const [copied, setCopied] = useState31(false);
|
|
7297
|
-
const timer =
|
|
7298
|
-
|
|
7330
|
+
const timer = useRef37(0);
|
|
7331
|
+
useEffect29(() => () => window.clearTimeout(timer.current), []);
|
|
7299
7332
|
const current = copied ? copiedLabel : label;
|
|
7300
7333
|
return /* @__PURE__ */ jsxs51(Fragment10, { children: [
|
|
7301
|
-
/* @__PURE__ */
|
|
7334
|
+
/* @__PURE__ */ jsx69(Tooltip, { label: current, children: /* @__PURE__ */ jsx69(
|
|
7302
7335
|
Button,
|
|
7303
7336
|
{
|
|
7304
7337
|
variant: "ghost",
|
|
@@ -7314,12 +7347,12 @@ function CopyAction({ text, label, copiedLabel }) {
|
|
|
7314
7347
|
}
|
|
7315
7348
|
},
|
|
7316
7349
|
children: /* @__PURE__ */ jsxs51("span", { className: "ow-chat-actions__copy-icon", children: [
|
|
7317
|
-
/* @__PURE__ */
|
|
7318
|
-
/* @__PURE__ */
|
|
7350
|
+
/* @__PURE__ */ jsx69(CopyIcon, { size: 16 }),
|
|
7351
|
+
/* @__PURE__ */ jsx69(CheckIcon, { size: 16 })
|
|
7319
7352
|
] })
|
|
7320
7353
|
}
|
|
7321
7354
|
) }),
|
|
7322
|
-
/* @__PURE__ */
|
|
7355
|
+
/* @__PURE__ */ jsx69("span", { className: "ow-visually-hidden", "aria-live": "polite", children: copied ? copiedLabel : "" })
|
|
7323
7356
|
] });
|
|
7324
7357
|
}
|
|
7325
7358
|
function ChatMessageActions({
|
|
@@ -7338,7 +7371,7 @@ function ChatMessageActions({
|
|
|
7338
7371
|
const [current, setCurrent] = useControllableState(rating, defaultRating, onRate);
|
|
7339
7372
|
const rate = (value, label, Icon) => {
|
|
7340
7373
|
const pressed = current === value;
|
|
7341
|
-
return /* @__PURE__ */
|
|
7374
|
+
return /* @__PURE__ */ jsx69(Tooltip, { label, children: /* @__PURE__ */ jsx69(
|
|
7342
7375
|
ToggleButton,
|
|
7343
7376
|
{
|
|
7344
7377
|
variant: "ghost",
|
|
@@ -7348,14 +7381,14 @@ function ChatMessageActions({
|
|
|
7348
7381
|
pressed,
|
|
7349
7382
|
className: "ow-chat-actions__rate",
|
|
7350
7383
|
onPressedChange: () => setCurrent(pressed ? null : value),
|
|
7351
|
-
children: /* @__PURE__ */
|
|
7384
|
+
children: /* @__PURE__ */ jsx69(Icon, { size: 16 })
|
|
7352
7385
|
}
|
|
7353
7386
|
) });
|
|
7354
7387
|
};
|
|
7355
7388
|
return /* @__PURE__ */ jsxs51(Toolbar, { variant: "plain", size: "sm", "aria-label": ariaLabel, className: cx("ow-chat-actions", className), children: [
|
|
7356
|
-
text !== void 0 ? /* @__PURE__ */
|
|
7357
|
-
onEdit ? /* @__PURE__ */
|
|
7358
|
-
onRetry ? /* @__PURE__ */
|
|
7389
|
+
text !== void 0 ? /* @__PURE__ */ jsx69(CopyAction, { text, label: words.copy, copiedLabel: words.copied }) : null,
|
|
7390
|
+
onEdit ? /* @__PURE__ */ jsx69(Tooltip, { label: words.edit, children: /* @__PURE__ */ jsx69(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": words.edit, onClick: onEdit, children: /* @__PURE__ */ jsx69(PencilIcon, { size: 16 }) }) }) : null,
|
|
7391
|
+
onRetry ? /* @__PURE__ */ jsx69(Tooltip, { label: words.retry, children: /* @__PURE__ */ jsx69(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": words.retry, onClick: onRetry, children: /* @__PURE__ */ jsx69(RotateCcwIcon, { size: 16 }) }) }) : null,
|
|
7359
7392
|
onRate ? /* @__PURE__ */ jsxs51(Fragment10, { children: [
|
|
7360
7393
|
rate("up", words.good, ThumbsUpIcon),
|
|
7361
7394
|
rate("down", words.bad, ThumbsDownIcon)
|
|
@@ -7365,31 +7398,31 @@ function ChatMessageActions({
|
|
|
7365
7398
|
}
|
|
7366
7399
|
|
|
7367
7400
|
// src/components/Chat/ChatLoader.tsx
|
|
7368
|
-
import { jsx as
|
|
7401
|
+
import { jsx as jsx70, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
7369
7402
|
function ChatLoader({ label, inline = false, name, avatar, srLabel = "Working\u2026", className }) {
|
|
7370
7403
|
const entering = useChatEntrance();
|
|
7371
|
-
const indicator = label != null ? /* @__PURE__ */
|
|
7372
|
-
/* @__PURE__ */
|
|
7373
|
-
/* @__PURE__ */
|
|
7374
|
-
/* @__PURE__ */
|
|
7375
|
-
/* @__PURE__ */
|
|
7404
|
+
const indicator = label != null ? /* @__PURE__ */ jsx70(TextShimmer, { className: "ow-chat-loader__label", children: label }) : /* @__PURE__ */ jsxs52("span", { className: "ow-chat-loader__dots", children: [
|
|
7405
|
+
/* @__PURE__ */ jsx70("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7406
|
+
/* @__PURE__ */ jsx70("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7407
|
+
/* @__PURE__ */ jsx70("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7408
|
+
/* @__PURE__ */ jsx70("span", { className: "ow-visually-hidden", children: srLabel })
|
|
7376
7409
|
] });
|
|
7377
7410
|
if (inline) {
|
|
7378
|
-
return /* @__PURE__ */
|
|
7411
|
+
return /* @__PURE__ */ jsx70("span", { role: "status", className: cx("ow-chat-loader", "ow-chat-loader--inline", className), children: indicator });
|
|
7379
7412
|
}
|
|
7380
|
-
const avatarNode = avatar === void 0 ? /* @__PURE__ */
|
|
7413
|
+
const avatarNode = avatar === void 0 ? /* @__PURE__ */ jsx70(ChatAgentAvatar, {}) : avatar;
|
|
7381
7414
|
return /* @__PURE__ */ jsxs52("div", { role: "status", className: cx("ow-chat-message", "ow-chat-message--assistant", "ow-chat-loader", entering && "ow-chat-loader--enter", className), children: [
|
|
7382
|
-
avatarNode != null && avatarNode !== false ? /* @__PURE__ */
|
|
7415
|
+
avatarNode != null && avatarNode !== false ? /* @__PURE__ */ jsx70("div", { className: "ow-chat-message__avatar", children: avatarNode }) : null,
|
|
7383
7416
|
/* @__PURE__ */ jsxs52("div", { className: "ow-chat-message__main", children: [
|
|
7384
|
-
name != null ? /* @__PURE__ */
|
|
7385
|
-
/* @__PURE__ */
|
|
7417
|
+
name != null ? /* @__PURE__ */ jsx70("div", { className: "ow-chat-message__header", children: /* @__PURE__ */ jsx70("span", { className: "ow-chat-message__name", children: name }) }) : null,
|
|
7418
|
+
/* @__PURE__ */ jsx70("div", { className: "ow-chat-loader__line", children: indicator })
|
|
7386
7419
|
] })
|
|
7387
7420
|
] });
|
|
7388
7421
|
}
|
|
7389
7422
|
|
|
7390
7423
|
// src/components/ChatTool/ChatTool.tsx
|
|
7391
|
-
import { forwardRef as forwardRef28, useEffect as
|
|
7392
|
-
import { Fragment as Fragment11, jsx as
|
|
7424
|
+
import { forwardRef as forwardRef28, useEffect as useEffect30, useId as useId24, useRef as useRef38, useState as useState32 } from "react";
|
|
7425
|
+
import { Fragment as Fragment11, jsx as jsx71, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
7393
7426
|
var statusWords = {
|
|
7394
7427
|
pending: "Not started",
|
|
7395
7428
|
running: "Running",
|
|
@@ -7399,7 +7432,7 @@ var statusWords = {
|
|
|
7399
7432
|
cancelled: "Cancelled"
|
|
7400
7433
|
};
|
|
7401
7434
|
function SlashIcon() {
|
|
7402
|
-
return /* @__PURE__ */
|
|
7435
|
+
return /* @__PURE__ */ jsx71(
|
|
7403
7436
|
"svg",
|
|
7404
7437
|
{
|
|
7405
7438
|
width: 12,
|
|
@@ -7411,7 +7444,7 @@ function SlashIcon() {
|
|
|
7411
7444
|
strokeLinecap: "round",
|
|
7412
7445
|
"aria-hidden": "true",
|
|
7413
7446
|
focusable: "false",
|
|
7414
|
-
children: /* @__PURE__ */
|
|
7447
|
+
children: /* @__PURE__ */ jsx71("path", { d: "M7 17 17 7" })
|
|
7415
7448
|
}
|
|
7416
7449
|
);
|
|
7417
7450
|
}
|
|
@@ -7429,17 +7462,17 @@ function ExclamationIcon() {
|
|
|
7429
7462
|
"aria-hidden": "true",
|
|
7430
7463
|
focusable: "false",
|
|
7431
7464
|
children: [
|
|
7432
|
-
/* @__PURE__ */
|
|
7433
|
-
/* @__PURE__ */
|
|
7465
|
+
/* @__PURE__ */ jsx71("path", { d: "M12 5v9" }),
|
|
7466
|
+
/* @__PURE__ */ jsx71("path", { d: "M12 19h.01" })
|
|
7434
7467
|
]
|
|
7435
7468
|
}
|
|
7436
7469
|
);
|
|
7437
7470
|
}
|
|
7438
7471
|
function ChatStatusMarker({ status, icon: icon2 }) {
|
|
7439
7472
|
const showsIcon = Boolean(icon2) && (status === "success" || status === "pending");
|
|
7440
|
-
const glyph = status === "running" ? /* @__PURE__ */
|
|
7473
|
+
const glyph = status === "running" ? /* @__PURE__ */ jsx71(Spinner, { size: "sm", label: "" }) : status === "error" ? /* @__PURE__ */ jsx71(XIcon, { size: 12, strokeWidth: 3 }) : status === "approval" ? /* @__PURE__ */ jsx71(ExclamationIcon, {}) : status === "cancelled" ? /* @__PURE__ */ jsx71(SlashIcon, {}) : showsIcon ? icon2 : status === "success" ? /* @__PURE__ */ jsx71(CheckIcon, { size: 12, strokeWidth: 3 }) : null;
|
|
7441
7474
|
return /* @__PURE__ */ jsxs53("span", { className: cx("ow-chat-status", `ow-chat-status--${status}`, showsIcon && "ow-chat-status--icon"), children: [
|
|
7442
|
-
/* @__PURE__ */
|
|
7475
|
+
/* @__PURE__ */ jsx71("span", { className: "ow-chat-status__glyph", "aria-hidden": "true", children: glyph }),
|
|
7443
7476
|
/* @__PURE__ */ jsxs53("span", { className: "ow-visually-hidden", children: [
|
|
7444
7477
|
statusWords[status],
|
|
7445
7478
|
": "
|
|
@@ -7463,7 +7496,7 @@ function formatDuration(ms, locale) {
|
|
|
7463
7496
|
return rest ? `${number(hours)} h ${number(rest)} min` : `${number(hours)} h`;
|
|
7464
7497
|
}
|
|
7465
7498
|
function ChatDuration({ ms, locale, className }) {
|
|
7466
|
-
return /* @__PURE__ */
|
|
7499
|
+
return /* @__PURE__ */ jsx71("time", { dateTime: `PT${Math.max(0, Math.round(ms)) / 1e3}S`, className, children: formatDuration(ms, locale) });
|
|
7467
7500
|
}
|
|
7468
7501
|
function useStatusExpansion({
|
|
7469
7502
|
expanded,
|
|
@@ -7474,9 +7507,9 @@ function useStatusExpansion({
|
|
|
7474
7507
|
initial = wantsOpen
|
|
7475
7508
|
}) {
|
|
7476
7509
|
const [isOpen, setOpen] = useControllableState(expanded, defaultExpanded ?? initial, onExpandedChange);
|
|
7477
|
-
const touched =
|
|
7478
|
-
const previous =
|
|
7479
|
-
|
|
7510
|
+
const touched = useRef38(false);
|
|
7511
|
+
const previous = useRef38(wantsOpen);
|
|
7512
|
+
useEffect30(() => {
|
|
7480
7513
|
if (previous.current === wantsOpen) return;
|
|
7481
7514
|
previous.current = wantsOpen;
|
|
7482
7515
|
if (expanded !== void 0) return;
|
|
@@ -7502,11 +7535,11 @@ function ChatCollapse({
|
|
|
7502
7535
|
className,
|
|
7503
7536
|
children
|
|
7504
7537
|
}) {
|
|
7505
|
-
const ref =
|
|
7506
|
-
|
|
7538
|
+
const ref = useRef38(null);
|
|
7539
|
+
useEffect30(() => {
|
|
7507
7540
|
if (ref.current) ref.current.inert = !open;
|
|
7508
7541
|
}, [open]);
|
|
7509
|
-
return /* @__PURE__ */
|
|
7542
|
+
return /* @__PURE__ */ jsx71("div", { ref, id, className: cx("ow-chat-collapse", bleed && "ow-chat-collapse--bleed"), "data-open": open, children: /* @__PURE__ */ jsx71("div", { className: "ow-chat-collapse__clip", children: /* @__PURE__ */ jsx71("div", { className, children }) }) });
|
|
7510
7543
|
}
|
|
7511
7544
|
var codeMaxHeight = 280;
|
|
7512
7545
|
function formatInput(input) {
|
|
@@ -7540,10 +7573,10 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7540
7573
|
...props
|
|
7541
7574
|
}, ref) {
|
|
7542
7575
|
const id = useId24();
|
|
7543
|
-
const rootRef =
|
|
7544
|
-
const triggerRef =
|
|
7545
|
-
const messageRef =
|
|
7546
|
-
const decided =
|
|
7576
|
+
const rootRef = useRef38(null);
|
|
7577
|
+
const triggerRef = useRef38(null);
|
|
7578
|
+
const messageRef = useRef38(null);
|
|
7579
|
+
const decided = useRef38(false);
|
|
7547
7580
|
const [announcement, setAnnouncement] = useState32("");
|
|
7548
7581
|
const needsApproval = status === "approval";
|
|
7549
7582
|
const [isOpen, toggle] = useStatusExpansion({
|
|
@@ -7557,7 +7590,7 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7557
7590
|
const hasError = error !== void 0 && error !== null && error !== false && error !== "";
|
|
7558
7591
|
const hasDetails = hasInput || hasOutput || hasError;
|
|
7559
7592
|
const hasMeta = Boolean(summary) || duration !== void 0;
|
|
7560
|
-
|
|
7593
|
+
useEffect30(() => {
|
|
7561
7594
|
if (!needsApproval) {
|
|
7562
7595
|
setAnnouncement("");
|
|
7563
7596
|
return;
|
|
@@ -7568,7 +7601,7 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7568
7601
|
}, 150);
|
|
7569
7602
|
return () => window.clearTimeout(timer);
|
|
7570
7603
|
}, [needsApproval]);
|
|
7571
|
-
|
|
7604
|
+
useEffect30(() => {
|
|
7572
7605
|
if (needsApproval || !decided.current) return;
|
|
7573
7606
|
decided.current = false;
|
|
7574
7607
|
const active = document.activeElement;
|
|
@@ -7576,20 +7609,20 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7576
7609
|
}, [needsApproval]);
|
|
7577
7610
|
const running = status === "running";
|
|
7578
7611
|
const header = /* @__PURE__ */ jsxs53(Fragment11, { children: [
|
|
7579
|
-
/* @__PURE__ */
|
|
7580
|
-
icon2 ? /* @__PURE__ */
|
|
7612
|
+
/* @__PURE__ */ jsx71(ChatStatusMarker, { status }),
|
|
7613
|
+
icon2 ? /* @__PURE__ */ jsx71("span", { className: "ow-chat-tool__icon", "aria-hidden": "true", children: icon2 }) : null,
|
|
7581
7614
|
/* @__PURE__ */ jsxs53("span", { className: "ow-chat-tool__main", children: [
|
|
7582
7615
|
/* @__PURE__ */ jsxs53("span", { className: "ow-chat-tool__heading", children: [
|
|
7583
|
-
/* @__PURE__ */
|
|
7584
|
-
name ? /* @__PURE__ */
|
|
7616
|
+
/* @__PURE__ */ jsx71("span", { className: "ow-chat-tool__title", children: running ? /* @__PURE__ */ jsx71(TextShimmer, { children: title }) : title }),
|
|
7617
|
+
name ? /* @__PURE__ */ jsx71(Code, { className: "ow-chat-tool__name", children: name }) : null
|
|
7585
7618
|
] }),
|
|
7586
7619
|
hasMeta ? /* @__PURE__ */ jsxs53("span", { className: "ow-chat-tool__meta", children: [
|
|
7587
|
-
summary ? /* @__PURE__ */
|
|
7588
|
-
summary && duration !== void 0 ? /* @__PURE__ */
|
|
7589
|
-
duration !== void 0 ? /* @__PURE__ */
|
|
7620
|
+
summary ? /* @__PURE__ */ jsx71("span", { className: "ow-chat-tool__summary", children: summary }) : null,
|
|
7621
|
+
summary && duration !== void 0 ? /* @__PURE__ */ jsx71("span", { className: "ow-chat-tool__dot", "aria-hidden": "true", children: "\xB7" }) : null,
|
|
7622
|
+
duration !== void 0 ? /* @__PURE__ */ jsx71(ChatDuration, { ms: duration, locale, className: "ow-chat-tool__duration" }) : null
|
|
7590
7623
|
] }) : null
|
|
7591
7624
|
] }),
|
|
7592
|
-
hasDetails ? /* @__PURE__ */
|
|
7625
|
+
hasDetails ? /* @__PURE__ */ jsx71("span", { className: "ow-chat-tool__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsx71(ChevronRightIcon, { size: 14 }) }) : null
|
|
7593
7626
|
] });
|
|
7594
7627
|
return /* @__PURE__ */ jsxs53(
|
|
7595
7628
|
"div",
|
|
@@ -7606,7 +7639,7 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7606
7639
|
tabIndex: hasDetails ? void 0 : -1,
|
|
7607
7640
|
...props,
|
|
7608
7641
|
children: [
|
|
7609
|
-
hasDetails ? /* @__PURE__ */
|
|
7642
|
+
hasDetails ? /* @__PURE__ */ jsx71(
|
|
7610
7643
|
"button",
|
|
7611
7644
|
{
|
|
7612
7645
|
ref: triggerRef,
|
|
@@ -7618,28 +7651,28 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7618
7651
|
onClick: toggle,
|
|
7619
7652
|
children: header
|
|
7620
7653
|
}
|
|
7621
|
-
) : /* @__PURE__ */
|
|
7654
|
+
) : /* @__PURE__ */ jsx71("div", { className: "ow-chat-tool__header", children: header }),
|
|
7622
7655
|
hasDetails ? /* @__PURE__ */ jsxs53(ChatCollapse, { id: `${id}-details`, open: isOpen, className: "ow-chat-tool__details", children: [
|
|
7623
7656
|
hasInput ? /* @__PURE__ */ jsxs53("div", { className: "ow-chat-tool__section", children: [
|
|
7624
|
-
/* @__PURE__ */
|
|
7625
|
-
typeof input === "string" && !input.includes("\n") ? /* @__PURE__ */
|
|
7657
|
+
/* @__PURE__ */ jsx71("span", { className: "ow-chat-tool__label", children: "Input" }),
|
|
7658
|
+
typeof input === "string" && !input.includes("\n") ? /* @__PURE__ */ jsx71(Snippet, { value: input, prompt: null }) : /* @__PURE__ */ jsx71(CodeBlock, { code: formatInput(input), language: typeof input === "string" ? void 0 : "json", maxHeight: codeMaxHeight })
|
|
7626
7659
|
] }) : null,
|
|
7627
7660
|
hasOutput ? /* @__PURE__ */ jsxs53("div", { className: "ow-chat-tool__section", children: [
|
|
7628
|
-
/* @__PURE__ */
|
|
7629
|
-
typeof output === "string" ? /* @__PURE__ */
|
|
7661
|
+
/* @__PURE__ */ jsx71("span", { className: "ow-chat-tool__label", children: "Output" }),
|
|
7662
|
+
typeof output === "string" ? /* @__PURE__ */ jsx71(CodeBlock, { code: output, maxHeight: codeMaxHeight }) : /* @__PURE__ */ jsx71("div", { className: "ow-chat-tool__output", children: output })
|
|
7630
7663
|
] }) : null,
|
|
7631
7664
|
hasError ? /* @__PURE__ */ jsxs53("div", { className: "ow-chat-tool__section", children: [
|
|
7632
|
-
/* @__PURE__ */
|
|
7633
|
-
/* @__PURE__ */
|
|
7665
|
+
/* @__PURE__ */ jsx71("span", { className: "ow-chat-tool__label", children: "Error" }),
|
|
7666
|
+
/* @__PURE__ */ jsx71("div", { className: "ow-chat-tool__error", children: error })
|
|
7634
7667
|
] }) : null
|
|
7635
7668
|
] }) : null,
|
|
7636
7669
|
needsApproval ? /* @__PURE__ */ jsxs53("div", { className: "ow-chat-tool__approval", role: "group", "aria-labelledby": `${id}-request`, children: [
|
|
7637
|
-
/* @__PURE__ */
|
|
7670
|
+
/* @__PURE__ */ jsx71("p", { ref: messageRef, id: `${id}-request`, className: "ow-chat-tool__request", children: approvalMessage ?? (name ? /* @__PURE__ */ jsxs53(Fragment11, { children: [
|
|
7638
7671
|
"Wants to run ",
|
|
7639
|
-
/* @__PURE__ */
|
|
7672
|
+
/* @__PURE__ */ jsx71(Code, { children: name })
|
|
7640
7673
|
] }) : "Wants to go ahead") }),
|
|
7641
7674
|
/* @__PURE__ */ jsxs53("div", { className: "ow-chat-tool__actions", children: [
|
|
7642
|
-
/* @__PURE__ */
|
|
7675
|
+
/* @__PURE__ */ jsx71(
|
|
7643
7676
|
Button,
|
|
7644
7677
|
{
|
|
7645
7678
|
variant: "primary",
|
|
@@ -7651,7 +7684,7 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7651
7684
|
children: approveLabel
|
|
7652
7685
|
}
|
|
7653
7686
|
),
|
|
7654
|
-
/* @__PURE__ */
|
|
7687
|
+
/* @__PURE__ */ jsx71(
|
|
7655
7688
|
Button,
|
|
7656
7689
|
{
|
|
7657
7690
|
size: "sm",
|
|
@@ -7664,7 +7697,7 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7664
7697
|
)
|
|
7665
7698
|
] })
|
|
7666
7699
|
] }) : null,
|
|
7667
|
-
/* @__PURE__ */
|
|
7700
|
+
/* @__PURE__ */ jsx71("span", { className: "ow-visually-hidden", "aria-live": "polite", children: announcement })
|
|
7668
7701
|
]
|
|
7669
7702
|
}
|
|
7670
7703
|
);
|
|
@@ -7672,7 +7705,7 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7672
7705
|
|
|
7673
7706
|
// src/components/ChainOfThought/ChainOfThought.tsx
|
|
7674
7707
|
import { forwardRef as forwardRef29, useId as useId25 } from "react";
|
|
7675
|
-
import { jsx as
|
|
7708
|
+
import { jsx as jsx72, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
7676
7709
|
var plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
7677
7710
|
var ChainOfThought = /* @__PURE__ */ forwardRef29(function ChainOfThought2({
|
|
7678
7711
|
steps = [],
|
|
@@ -7705,9 +7738,9 @@ var ChainOfThought = /* @__PURE__ */ forwardRef29(function ChainOfThought2({
|
|
|
7705
7738
|
const heading = label ?? (running ? "Thinking\u2026" : duration !== void 0 ? `Thought for ${formatDuration(duration, locale)}` : "Reasoning");
|
|
7706
7739
|
const count = steps.length > 0 ? running ? `${finished} of ${plural(steps.length, "step")}` : plural(steps.length, "step") : null;
|
|
7707
7740
|
const headerText = /* @__PURE__ */ jsxs54("span", { className: "ow-chat-toggle__text", children: [
|
|
7708
|
-
/* @__PURE__ */
|
|
7741
|
+
/* @__PURE__ */ jsx72("span", { className: "ow-chain-of-thought__label", children: running ? /* @__PURE__ */ jsx72(TextShimmer, { children: heading }) : heading }),
|
|
7709
7742
|
count ? /* @__PURE__ */ jsxs54("span", { className: "ow-chat-toggle__meta", children: [
|
|
7710
|
-
/* @__PURE__ */
|
|
7743
|
+
/* @__PURE__ */ jsx72("span", { "aria-hidden": "true", children: "\xB7 " }),
|
|
7711
7744
|
count,
|
|
7712
7745
|
failed > 0 ? /* @__PURE__ */ jsxs54("span", { className: "ow-chain-of-thought__failed", children: [
|
|
7713
7746
|
", ",
|
|
@@ -7718,16 +7751,16 @@ var ChainOfThought = /* @__PURE__ */ forwardRef29(function ChainOfThought2({
|
|
|
7718
7751
|
] });
|
|
7719
7752
|
return /* @__PURE__ */ jsxs54("div", { ref, className: cx("ow-chain-of-thought", className), "data-status": status, "aria-busy": running || void 0, ...props, children: [
|
|
7720
7753
|
hasBody ? /* @__PURE__ */ jsxs54("button", { type: "button", className: "ow-chat-toggle", "aria-expanded": isOpen, "aria-controls": `${id}-body`, onClick: toggle, children: [
|
|
7721
|
-
/* @__PURE__ */
|
|
7754
|
+
/* @__PURE__ */ jsx72("span", { className: "ow-chat-toggle__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsx72(ChevronRightIcon, { size: 14 }) }),
|
|
7722
7755
|
headerText
|
|
7723
|
-
] }) : /* @__PURE__ */
|
|
7756
|
+
] }) : /* @__PURE__ */ jsx72("div", { className: "ow-chat-toggle ow-chain-of-thought__static", children: headerText }),
|
|
7724
7757
|
hasBody ? /* @__PURE__ */ jsxs54(ChatCollapse, { id: `${id}-body`, open: isOpen, bleed: true, className: "ow-chain-of-thought__body", children: [
|
|
7725
|
-
hasReasoning ? /* @__PURE__ */
|
|
7726
|
-
steps.length > 0 ? /* @__PURE__ */
|
|
7727
|
-
/* @__PURE__ */
|
|
7758
|
+
hasReasoning ? /* @__PURE__ */ jsx72("div", { className: "ow-chain-of-thought__reasoning", children }) : null,
|
|
7759
|
+
steps.length > 0 ? /* @__PURE__ */ jsx72("ol", { className: "ow-chain-of-thought__steps", children: steps.map((step) => /* @__PURE__ */ jsxs54("li", { className: "ow-chain-of-thought__step", "data-status": step.status, children: [
|
|
7760
|
+
/* @__PURE__ */ jsx72(ChatStatusMarker, { status: step.status, icon: step.icon }),
|
|
7728
7761
|
/* @__PURE__ */ jsxs54("div", { className: "ow-chain-of-thought__step-body", children: [
|
|
7729
|
-
/* @__PURE__ */
|
|
7730
|
-
step.detail !== void 0 && step.detail !== null ? /* @__PURE__ */
|
|
7762
|
+
/* @__PURE__ */ jsx72("span", { className: "ow-chain-of-thought__step-title", children: step.status === "running" ? /* @__PURE__ */ jsx72(TextShimmer, { children: step.title }) : step.title }),
|
|
7763
|
+
step.detail !== void 0 && step.detail !== null ? /* @__PURE__ */ jsx72("div", { className: "ow-chain-of-thought__detail", children: step.detail }) : null
|
|
7731
7764
|
] })
|
|
7732
7765
|
] }, step.id)) }) : null
|
|
7733
7766
|
] }) : null
|
|
@@ -7735,8 +7768,8 @@ var ChainOfThought = /* @__PURE__ */ forwardRef29(function ChainOfThought2({
|
|
|
7735
7768
|
});
|
|
7736
7769
|
|
|
7737
7770
|
// src/components/ChatSource/ChatSource.tsx
|
|
7738
|
-
import { forwardRef as forwardRef30, useCallback as useCallback11, useEffect as
|
|
7739
|
-
import { Fragment as Fragment12, jsx as
|
|
7771
|
+
import { forwardRef as forwardRef30, useCallback as useCallback11, useEffect as useEffect31, useId as useId26, useRef as useRef39, useState as useState33 } from "react";
|
|
7772
|
+
import { Fragment as Fragment12, jsx as jsx73, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
7740
7773
|
var openDelay = 250;
|
|
7741
7774
|
var closeDelay = 150;
|
|
7742
7775
|
var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
@@ -7755,11 +7788,11 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7755
7788
|
className
|
|
7756
7789
|
}, ref) {
|
|
7757
7790
|
const id = useId26();
|
|
7758
|
-
const wrapperRef =
|
|
7759
|
-
const chipRef =
|
|
7760
|
-
const cardRef =
|
|
7761
|
-
const timer =
|
|
7762
|
-
const pointer =
|
|
7791
|
+
const wrapperRef = useRef39(null);
|
|
7792
|
+
const chipRef = useRef39(null);
|
|
7793
|
+
const cardRef = useRef39(null);
|
|
7794
|
+
const timer = useRef39(0);
|
|
7795
|
+
const pointer = useRef39("mouse");
|
|
7763
7796
|
const [open, setOpen] = useState33(false);
|
|
7764
7797
|
const { mounted, state } = usePresence(open);
|
|
7765
7798
|
const style = useFloating({ open: mounted, anchorRef: chipRef, floatingRef: cardRef, placement: "bottom-start", offset: 6, maxHeight: 360 });
|
|
@@ -7773,7 +7806,7 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7773
7806
|
setOpen(false);
|
|
7774
7807
|
}, []);
|
|
7775
7808
|
useDismiss(open, [wrapperRef], close);
|
|
7776
|
-
|
|
7809
|
+
useEffect31(() => () => window.clearTimeout(timer.current), []);
|
|
7777
7810
|
const name = ariaLabel ?? (index !== void 0 ? `Source ${index}` : label ?? "Source");
|
|
7778
7811
|
const describedBy = [`${id}-title`, source ? `${id}-source` : null, snippet ? `${id}-snippet` : null].filter(Boolean).join(" ");
|
|
7779
7812
|
const externalProps = external ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
@@ -7805,7 +7838,7 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7805
7838
|
onClick?.(event);
|
|
7806
7839
|
}
|
|
7807
7840
|
};
|
|
7808
|
-
const chipText = /* @__PURE__ */
|
|
7841
|
+
const chipText = /* @__PURE__ */ jsx73("span", { className: "ow-chat-source__chip-text", children: index ?? label });
|
|
7809
7842
|
return /* @__PURE__ */ jsxs55(
|
|
7810
7843
|
"span",
|
|
7811
7844
|
{
|
|
@@ -7818,19 +7851,19 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7818
7851
|
if (event.pointerType === "mouse") schedule(false, closeDelay);
|
|
7819
7852
|
},
|
|
7820
7853
|
children: [
|
|
7821
|
-
href ? /* @__PURE__ */
|
|
7854
|
+
href ? /* @__PURE__ */ jsx73("a", { href, ...externalProps, ...chipProps, children: chipText }) : /* @__PURE__ */ jsx73("button", { type: "button", ...chipProps, children: chipText }),
|
|
7822
7855
|
/* @__PURE__ */ jsxs55("span", { ref: cardRef, ...manualPopover, hidden: !mounted, "data-state": state, className: "ow-chat-source-card ow-floating", style, children: [
|
|
7823
7856
|
/* @__PURE__ */ jsxs55("span", { className: "ow-chat-source-card__header", children: [
|
|
7824
|
-
icon2 ? /* @__PURE__ */
|
|
7825
|
-
/* @__PURE__ */
|
|
7857
|
+
icon2 ? /* @__PURE__ */ jsx73("span", { className: "ow-chat-source-card__icon", "aria-hidden": "true", children: icon2 }) : null,
|
|
7858
|
+
/* @__PURE__ */ jsx73("span", { id: `${id}-title`, className: "ow-chat-source-card__title", children: title })
|
|
7826
7859
|
] }),
|
|
7827
|
-
source ? /* @__PURE__ */
|
|
7828
|
-
snippet ? /* @__PURE__ */
|
|
7860
|
+
source ? /* @__PURE__ */ jsx73("span", { id: `${id}-source`, className: "ow-chat-source-card__source", children: source }) : null,
|
|
7861
|
+
snippet ? /* @__PURE__ */ jsx73("span", { id: `${id}-snippet`, className: cx("ow-chat-source-card__snippet", `ow-chat-source-card__snippet--${snippetFormat}`), children: snippet }) : null,
|
|
7829
7862
|
href ? (
|
|
7830
7863
|
// The chip is the same link, so this one stays out of the tab order.
|
|
7831
7864
|
/* @__PURE__ */ jsxs55("a", { href, ...externalProps, tabIndex: -1, className: cx(linkClassName({ variant: "standalone" }), "ow-chat-source-card__open"), children: [
|
|
7832
7865
|
openLabel,
|
|
7833
|
-
/* @__PURE__ */
|
|
7866
|
+
/* @__PURE__ */ jsx73(ArrowUpRightIcon, { size: 13 })
|
|
7834
7867
|
] })
|
|
7835
7868
|
) : null
|
|
7836
7869
|
] })
|
|
@@ -7844,28 +7877,28 @@ var ChatSources = /* @__PURE__ */ forwardRef30(function ChatSources2({ sources,
|
|
|
7844
7877
|
if (sources.length === 0) return null;
|
|
7845
7878
|
return /* @__PURE__ */ jsxs55("div", { ref, className: cx("ow-chat-sources", className), ...props, children: [
|
|
7846
7879
|
/* @__PURE__ */ jsxs55("button", { type: "button", className: "ow-chat-toggle", "aria-expanded": isOpen, "aria-controls": `${id}-list`, onClick: () => setOpen(!isOpen), children: [
|
|
7847
|
-
/* @__PURE__ */
|
|
7848
|
-
/* @__PURE__ */
|
|
7880
|
+
/* @__PURE__ */ jsx73("span", { className: "ow-chat-toggle__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsx73(ChevronRightIcon, { size: 14 }) }),
|
|
7881
|
+
/* @__PURE__ */ jsx73("span", { className: "ow-chat-toggle__text", children: label ?? `${sources.length} ${sources.length === 1 ? "source" : "sources"}` })
|
|
7849
7882
|
] }),
|
|
7850
|
-
/* @__PURE__ */
|
|
7883
|
+
/* @__PURE__ */ jsx73(ChatCollapse, { id: `${id}-list`, open: isOpen, bleed: true, className: "ow-chat-sources__body", children: /* @__PURE__ */ jsx73("ul", { className: "ow-chat-sources__list", children: sources.map((item, position) => {
|
|
7851
7884
|
const content = /* @__PURE__ */ jsxs55(Fragment12, { children: [
|
|
7852
7885
|
/* @__PURE__ */ jsxs55("span", { className: "ow-chat-sources__lead", children: [
|
|
7853
7886
|
item.index !== void 0 ? /* @__PURE__ */ jsxs55("span", { className: "ow-chat-sources__index", children: [
|
|
7854
|
-
/* @__PURE__ */
|
|
7887
|
+
/* @__PURE__ */ jsx73("span", { className: "ow-visually-hidden", children: "Source " }),
|
|
7855
7888
|
item.index
|
|
7856
7889
|
] }) : null,
|
|
7857
|
-
item.icon || item.index === void 0 ? /* @__PURE__ */
|
|
7890
|
+
item.icon || item.index === void 0 ? /* @__PURE__ */ jsx73("span", { className: "ow-chat-sources__icon", "aria-hidden": "true", children: item.icon ?? /* @__PURE__ */ jsx73(FileIcon, { size: 15 }) }) : null
|
|
7858
7891
|
] }),
|
|
7859
7892
|
/* @__PURE__ */ jsxs55("span", { className: "ow-chat-sources__text", children: [
|
|
7860
|
-
/* @__PURE__ */
|
|
7861
|
-
item.source ? /* @__PURE__ */
|
|
7893
|
+
/* @__PURE__ */ jsx73("span", { className: "ow-chat-sources__title", children: item.title }),
|
|
7894
|
+
item.source ? /* @__PURE__ */ jsx73("span", { className: "ow-chat-sources__source", children: item.source }) : null
|
|
7862
7895
|
] }),
|
|
7863
7896
|
item.href && item.external ? /* @__PURE__ */ jsxs55(Fragment12, { children: [
|
|
7864
|
-
/* @__PURE__ */
|
|
7865
|
-
/* @__PURE__ */
|
|
7897
|
+
/* @__PURE__ */ jsx73("span", { className: "ow-chat-sources__external", "aria-hidden": "true", children: /* @__PURE__ */ jsx73(ArrowUpRightIcon, { size: 14 }) }),
|
|
7898
|
+
/* @__PURE__ */ jsx73("span", { className: "ow-visually-hidden", children: " (opens in a new tab)" })
|
|
7866
7899
|
] }) : null
|
|
7867
7900
|
] });
|
|
7868
|
-
return /* @__PURE__ */
|
|
7901
|
+
return /* @__PURE__ */ jsx73("li", { children: item.href ? /* @__PURE__ */ jsx73(
|
|
7869
7902
|
"a",
|
|
7870
7903
|
{
|
|
7871
7904
|
href: item.href,
|
|
@@ -7873,15 +7906,15 @@ var ChatSources = /* @__PURE__ */ forwardRef30(function ChatSources2({ sources,
|
|
|
7873
7906
|
...item.external ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
7874
7907
|
children: content
|
|
7875
7908
|
}
|
|
7876
|
-
) : /* @__PURE__ */
|
|
7909
|
+
) : /* @__PURE__ */ jsx73("div", { className: "ow-chat-sources__card", children: content }) }, item.id ?? item.index ?? position);
|
|
7877
7910
|
}) }) })
|
|
7878
7911
|
] });
|
|
7879
7912
|
});
|
|
7880
7913
|
|
|
7881
7914
|
// src/components/ColorPicker/ColorPicker.tsx
|
|
7882
|
-
import { forwardRef as forwardRef31, useCallback as useCallback12, useEffect as
|
|
7915
|
+
import { forwardRef as forwardRef31, useCallback as useCallback12, useEffect as useEffect32, useId as useId27, useRef as useRef40, useState as useState34 } from "react";
|
|
7883
7916
|
import { HexAlphaColorPicker, HexColorInput, HexColorPicker } from "react-colorful";
|
|
7884
|
-
import { Fragment as Fragment13, jsx as
|
|
7917
|
+
import { Fragment as Fragment13, jsx as jsx74, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
7885
7918
|
var swatchColor = (swatch) => typeof swatch === "string" ? swatch : swatch.color;
|
|
7886
7919
|
var swatchName = (swatch) => typeof swatch === "string" ? swatch : swatch.name;
|
|
7887
7920
|
var same = (a, b) => a.toLowerCase().replace(/^#/, "") === b.toLowerCase().replace(/^#/, "");
|
|
@@ -7898,9 +7931,9 @@ function ColorPicker({
|
|
|
7898
7931
|
}) {
|
|
7899
7932
|
const [color, setColor] = useControllableState(value, defaultValue, onChange);
|
|
7900
7933
|
const [canPick, setCanPick] = useState34(false);
|
|
7901
|
-
const rootRef =
|
|
7902
|
-
|
|
7903
|
-
|
|
7934
|
+
const rootRef = useRef40(null);
|
|
7935
|
+
useEffect32(() => setCanPick(typeof window !== "undefined" && "EyeDropper" in window), []);
|
|
7936
|
+
useEffect32(() => {
|
|
7904
7937
|
const names = { saturation: "Colour", hue: "Hue", alpha: "Opacity" };
|
|
7905
7938
|
for (const [part, label] of Object.entries(names)) {
|
|
7906
7939
|
rootRef.current?.querySelector(`.react-colorful__${part} .react-colorful__interactive`)?.setAttribute("aria-label", label);
|
|
@@ -7917,12 +7950,12 @@ function ColorPicker({
|
|
|
7917
7950
|
}
|
|
7918
7951
|
}
|
|
7919
7952
|
return /* @__PURE__ */ jsxs56("div", { ref: rootRef, role: "group", "aria-label": ariaLabel, className: cx("ow-color-picker", className), children: [
|
|
7920
|
-
/* @__PURE__ */
|
|
7953
|
+
/* @__PURE__ */ jsx74(Picker, { color, onChange: change }),
|
|
7921
7954
|
showInput || eyeDropper && canPick ? /* @__PURE__ */ jsxs56("div", { className: "ow-color-picker__row", children: [
|
|
7922
|
-
eyeDropper && canPick ? /* @__PURE__ */
|
|
7955
|
+
eyeDropper && canPick ? /* @__PURE__ */ jsx74("button", { type: "button", className: "ow-color-picker__dropper", "aria-label": "Pick a colour from the screen", onClick: pickFromScreen, children: /* @__PURE__ */ jsx74(PipetteIcon, { size: 15 }) }) : null,
|
|
7923
7956
|
showInput ? /* @__PURE__ */ jsxs56("span", { className: "ow-input-group ow-input-group--sm ow-color-picker__input", children: [
|
|
7924
|
-
/* @__PURE__ */
|
|
7925
|
-
/* @__PURE__ */
|
|
7957
|
+
/* @__PURE__ */ jsx74("span", { className: "ow-input-group__addon", "aria-hidden": "true", children: "#" }),
|
|
7958
|
+
/* @__PURE__ */ jsx74(
|
|
7926
7959
|
HexColorInput,
|
|
7927
7960
|
{
|
|
7928
7961
|
className: "ow-input-group__input",
|
|
@@ -7934,11 +7967,11 @@ function ColorPicker({
|
|
|
7934
7967
|
}
|
|
7935
7968
|
)
|
|
7936
7969
|
] }) : null,
|
|
7937
|
-
/* @__PURE__ */
|
|
7970
|
+
/* @__PURE__ */ jsx74("span", { className: "ow-color-picker__preview", style: { "--ow-color-picker-value": color }, "aria-hidden": "true" })
|
|
7938
7971
|
] }) : null,
|
|
7939
|
-
swatches?.length ? /* @__PURE__ */
|
|
7972
|
+
swatches?.length ? /* @__PURE__ */ jsx74("div", { className: "ow-color-picker__swatches", role: "group", "aria-label": "Swatches", children: swatches.map((swatch) => {
|
|
7940
7973
|
const swatchValue = swatchColor(swatch);
|
|
7941
|
-
return /* @__PURE__ */
|
|
7974
|
+
return /* @__PURE__ */ jsx74(
|
|
7942
7975
|
"button",
|
|
7943
7976
|
{
|
|
7944
7977
|
type: "button",
|
|
@@ -7975,8 +8008,8 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
7975
8008
|
}, ref) {
|
|
7976
8009
|
const [color, setColor] = useControllableState(value, defaultValue, onChange);
|
|
7977
8010
|
const [isOpen, setOpen] = useState34(false);
|
|
7978
|
-
const triggerRef =
|
|
7979
|
-
const panelRef =
|
|
8011
|
+
const triggerRef = useRef40(null);
|
|
8012
|
+
const panelRef = useRef40(null);
|
|
7980
8013
|
const panelId = useId27();
|
|
7981
8014
|
const { mounted, state } = usePresence(isOpen);
|
|
7982
8015
|
const style = useFloating({ open: mounted, anchorRef: triggerRef, floatingRef: panelRef, placement, offset: 6, maxHeight: 640 });
|
|
@@ -7985,7 +8018,7 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
7985
8018
|
if (reason !== "outside") triggerRef.current?.focus();
|
|
7986
8019
|
}, []);
|
|
7987
8020
|
useDismiss(isOpen, [panelRef, triggerRef], close);
|
|
7988
|
-
|
|
8021
|
+
useEffect32(() => {
|
|
7989
8022
|
if (!isOpen) return void 0;
|
|
7990
8023
|
const frame = requestAnimationFrame(() => panelRef.current?.querySelector(".react-colorful__interactive")?.focus());
|
|
7991
8024
|
return () => cancelAnimationFrame(frame);
|
|
@@ -8003,9 +8036,9 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
8003
8036
|
"aria-haspopup": "dialog",
|
|
8004
8037
|
"aria-expanded": isOpen,
|
|
8005
8038
|
"aria-controls": isOpen ? panelId : void 0,
|
|
8006
|
-
"aria-label": ariaLabel,
|
|
8007
|
-
"aria-labelledby": ariaLabelledBy,
|
|
8008
|
-
"aria-describedby":
|
|
8039
|
+
"aria-label": ariaLabel && !ariaLabelledBy ? `${ariaLabel}, ${color.toUpperCase()}` : void 0,
|
|
8040
|
+
"aria-labelledby": ariaLabelledBy ? `${ariaLabelledBy} ${panelId}-value` : void 0,
|
|
8041
|
+
"aria-describedby": ariaDescribedBy,
|
|
8009
8042
|
"aria-invalid": isInvalid || void 0,
|
|
8010
8043
|
disabled,
|
|
8011
8044
|
className: cx(
|
|
@@ -8023,13 +8056,13 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
8023
8056
|
}
|
|
8024
8057
|
},
|
|
8025
8058
|
children: [
|
|
8026
|
-
/* @__PURE__ */
|
|
8027
|
-
/* @__PURE__ */
|
|
8028
|
-
/* @__PURE__ */
|
|
8059
|
+
/* @__PURE__ */ jsx74("span", { className: "ow-color-field__swatch", style: { "--ow-color-picker-value": color }, "aria-hidden": "true" }),
|
|
8060
|
+
/* @__PURE__ */ jsx74("span", { id: `${panelId}-value`, className: "ow-select__value ow-color-field__value", children: color.toUpperCase() }),
|
|
8061
|
+
/* @__PURE__ */ jsx74(ChevronDownIcon, { size: size2 === "sm" ? 14 : 16, className: "ow-select__chevron" })
|
|
8029
8062
|
]
|
|
8030
8063
|
}
|
|
8031
8064
|
),
|
|
8032
|
-
mounted ? /* @__PURE__ */
|
|
8065
|
+
mounted ? /* @__PURE__ */ jsx74(
|
|
8033
8066
|
"div",
|
|
8034
8067
|
{
|
|
8035
8068
|
ref: panelRef,
|
|
@@ -8043,17 +8076,17 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
8043
8076
|
onKeyDown: (event) => {
|
|
8044
8077
|
if (event.key === "Enter" && event.target.closest(".react-colorful")) close();
|
|
8045
8078
|
},
|
|
8046
|
-
children: /* @__PURE__ */
|
|
8079
|
+
children: /* @__PURE__ */ jsx74(ColorPicker, { ...pickerProps, value: color, onChange: setColor })
|
|
8047
8080
|
}
|
|
8048
8081
|
) : null
|
|
8049
8082
|
] });
|
|
8050
8083
|
});
|
|
8051
8084
|
|
|
8052
8085
|
// src/components/ColorPicker/ColorArea.tsx
|
|
8053
|
-
import { forwardRef as forwardRef32, useRef as
|
|
8086
|
+
import { forwardRef as forwardRef32, useRef as useRef42, useState as useState36 } from "react";
|
|
8054
8087
|
|
|
8055
8088
|
// src/components/ColorPicker/color.ts
|
|
8056
|
-
import { useCallback as useCallback13, useReducer, useRef as
|
|
8089
|
+
import { useCallback as useCallback13, useReducer, useRef as useRef41, useState as useState35 } from "react";
|
|
8057
8090
|
var clamp2 = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
8058
8091
|
function parseHex(color) {
|
|
8059
8092
|
let hex = color.trim().replace(/^#/, "");
|
|
@@ -8130,7 +8163,7 @@ var hslModel = {
|
|
|
8130
8163
|
var fallback = { r: 0, g: 0, b: 0, a: 1 };
|
|
8131
8164
|
function useColorModel(value, defaultValue, onChange, model, { hue, alpha = false } = {}) {
|
|
8132
8165
|
const [color, setColor] = useControllableState(value, defaultValue, onChange);
|
|
8133
|
-
const memory =
|
|
8166
|
+
const memory = useRef41(null);
|
|
8134
8167
|
const [, rerender] = useReducer((n) => n + 1, 0);
|
|
8135
8168
|
const incoming = normalizeHex(color);
|
|
8136
8169
|
if (!memory.current || memory.current.hex !== incoming || memory.current.model !== model) {
|
|
@@ -8234,7 +8267,7 @@ var hueHex = (h) => toHex(hsvToRgb({ h, s: 100, v: 100, a: 1 }));
|
|
|
8234
8267
|
var hueStops = "#ff0000 0%, #ffff00 16.67%, #00ff00 33.33%, #00ffff 50%, #0000ff 66.67%, #ff00ff 83.33%, #ff0000 100%";
|
|
8235
8268
|
|
|
8236
8269
|
// src/components/ColorPicker/ColorArea.tsx
|
|
8237
|
-
import { jsx as
|
|
8270
|
+
import { jsx as jsx75, jsxs as jsxs57 } from "react/jsx-runtime";
|
|
8238
8271
|
var size = (length) => typeof length === "number" ? `${length}px` : length;
|
|
8239
8272
|
function assignRef8(ref, value) {
|
|
8240
8273
|
if (typeof ref === "function") ref(value);
|
|
@@ -8258,8 +8291,8 @@ var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
|
8258
8291
|
className
|
|
8259
8292
|
}, ref) {
|
|
8260
8293
|
const { value: hsv, rgba, hex, set, latest } = useColorModel(value, defaultValue, onChange, hsvModel, { hue });
|
|
8261
|
-
const rootRef =
|
|
8262
|
-
const inputs =
|
|
8294
|
+
const rootRef = useRef42(null);
|
|
8295
|
+
const inputs = useRef42({ x: null, y: null });
|
|
8263
8296
|
const [axis, setAxis] = useState36("x");
|
|
8264
8297
|
const isRtl = () => rootRef.current ? getComputedStyle(rootRef.current).direction === "rtl" : false;
|
|
8265
8298
|
const end = () => onChangeEnd?.(latest());
|
|
@@ -8315,7 +8348,7 @@ var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
|
8315
8348
|
const saturation = `Saturation ${percent.format(hsv.s / 100)}`;
|
|
8316
8349
|
const brightness = `brightness ${percent.format(hsv.v / 100)}`;
|
|
8317
8350
|
const colorName = describeColor(rgba);
|
|
8318
|
-
const input = (which) => /* @__PURE__ */
|
|
8351
|
+
const input = (which) => /* @__PURE__ */ jsx75(
|
|
8319
8352
|
"input",
|
|
8320
8353
|
{
|
|
8321
8354
|
ref: (element) => {
|
|
@@ -8374,15 +8407,15 @@ var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
|
8374
8407
|
]
|
|
8375
8408
|
}
|
|
8376
8409
|
),
|
|
8377
|
-
name ? /* @__PURE__ */
|
|
8410
|
+
name ? /* @__PURE__ */ jsx75("input", { type: "hidden", name, value: hex }) : null
|
|
8378
8411
|
]
|
|
8379
8412
|
}
|
|
8380
8413
|
);
|
|
8381
8414
|
});
|
|
8382
8415
|
|
|
8383
8416
|
// src/components/ColorPicker/ColorSlider.tsx
|
|
8384
|
-
import { forwardRef as forwardRef33, useId as useId28, useRef as
|
|
8385
|
-
import { jsx as
|
|
8417
|
+
import { forwardRef as forwardRef33, useId as useId28, useRef as useRef43 } from "react";
|
|
8418
|
+
import { jsx as jsx76, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
8386
8419
|
var channels = {
|
|
8387
8420
|
hue: { name: "Hue", max: 360, unit: "degree" },
|
|
8388
8421
|
saturation: { name: "Saturation", max: 100, unit: "percent" },
|
|
@@ -8458,8 +8491,8 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8458
8491
|
const { rgba, latest } = color;
|
|
8459
8492
|
const current = read(channel, color.value, rgba);
|
|
8460
8493
|
const labelId = useId28();
|
|
8461
|
-
const trackRef =
|
|
8462
|
-
const inputRef =
|
|
8494
|
+
const trackRef = useRef43(null);
|
|
8495
|
+
const inputRef = useRef43(null);
|
|
8463
8496
|
const vertical = orientation === "vertical";
|
|
8464
8497
|
const isRtl = () => !vertical && trackRef.current !== null && getComputedStyle(trackRef.current).direction === "rtl";
|
|
8465
8498
|
const end = () => onChangeEnd?.(latest());
|
|
@@ -8513,10 +8546,10 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8513
8546
|
),
|
|
8514
8547
|
children: [
|
|
8515
8548
|
label || showValue ? /* @__PURE__ */ jsxs58("div", { className: "ow-color-slider__header", children: [
|
|
8516
|
-
label ? /* @__PURE__ */
|
|
8517
|
-
showValue ? /* @__PURE__ */
|
|
8549
|
+
label ? /* @__PURE__ */ jsx76("span", { id: labelId, className: "ow-color-slider__label", children: label }) : /* @__PURE__ */ jsx76("span", {}),
|
|
8550
|
+
showValue ? /* @__PURE__ */ jsx76("output", { className: "ow-color-slider__value", "aria-hidden": "true", children: shown }) : null
|
|
8518
8551
|
] }) : null,
|
|
8519
|
-
/* @__PURE__ */
|
|
8552
|
+
/* @__PURE__ */ jsx76(
|
|
8520
8553
|
"div",
|
|
8521
8554
|
{
|
|
8522
8555
|
ref: trackRef,
|
|
@@ -8525,12 +8558,12 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8525
8558
|
"--ow-color-slider-gradient": `linear-gradient(var(--ow-color-slider-direction), ${gradient(channel, color.value, rgba)})`
|
|
8526
8559
|
},
|
|
8527
8560
|
...drag.handlers,
|
|
8528
|
-
children: /* @__PURE__ */
|
|
8561
|
+
children: /* @__PURE__ */ jsx76(
|
|
8529
8562
|
"div",
|
|
8530
8563
|
{
|
|
8531
8564
|
className: "ow-color-slider__thumb",
|
|
8532
8565
|
style: { "--ow-color-slider-position": `${current / spec.max * 100}%`, "--ow-color-slider-thumb": fill },
|
|
8533
|
-
children: /* @__PURE__ */
|
|
8566
|
+
children: /* @__PURE__ */ jsx76(
|
|
8534
8567
|
"input",
|
|
8535
8568
|
{
|
|
8536
8569
|
ref: (element) => {
|
|
@@ -8562,18 +8595,18 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8562
8595
|
)
|
|
8563
8596
|
}
|
|
8564
8597
|
),
|
|
8565
|
-
name ? /* @__PURE__ */
|
|
8598
|
+
name ? /* @__PURE__ */ jsx76("input", { type: "hidden", name, value: color.hex }) : null
|
|
8566
8599
|
]
|
|
8567
8600
|
}
|
|
8568
8601
|
);
|
|
8569
8602
|
});
|
|
8570
8603
|
|
|
8571
8604
|
// src/components/ColorPicker/ColorSwatchPicker.tsx
|
|
8572
|
-
import { forwardRef as forwardRef34, useRef as
|
|
8573
|
-
import { jsx as
|
|
8605
|
+
import { forwardRef as forwardRef34, useRef as useRef44 } from "react";
|
|
8606
|
+
import { jsx as jsx77, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
8574
8607
|
var ColorSwatchPicker = /* @__PURE__ */ forwardRef34(function ColorSwatchPicker2({ options, value, defaultValue, onChange, size: size2 = "md", shape = "square", disabled = false, name, className, ...aria }, ref) {
|
|
8575
8608
|
const [current, setCurrent] = useControllableState(value, defaultValue ?? "", onChange);
|
|
8576
|
-
const refs =
|
|
8609
|
+
const refs = useRef44([]);
|
|
8577
8610
|
const items2 = options.map((option) => {
|
|
8578
8611
|
const item = typeof option === "string" ? { value: option } : option;
|
|
8579
8612
|
const rgba = parseHex(item.value);
|
|
@@ -8624,7 +8657,7 @@ var ColorSwatchPicker = /* @__PURE__ */ forwardRef34(function ColorSwatchPicker2
|
|
|
8624
8657
|
items2.map((item, index) => {
|
|
8625
8658
|
const isSelected = index === selectedIndex;
|
|
8626
8659
|
const isDisabled = disabled || Boolean(item.disabled);
|
|
8627
|
-
return /* @__PURE__ */
|
|
8660
|
+
return /* @__PURE__ */ jsx77(
|
|
8628
8661
|
"div",
|
|
8629
8662
|
{
|
|
8630
8663
|
ref: (element) => {
|
|
@@ -8641,12 +8674,12 @@ var ColorSwatchPicker = /* @__PURE__ */ forwardRef34(function ColorSwatchPicker2
|
|
|
8641
8674
|
style: { "--ow-color-swatch-picker-value": item.value },
|
|
8642
8675
|
onClick: () => choose(index),
|
|
8643
8676
|
onKeyDown: (event) => onKeyDown(event, index),
|
|
8644
|
-
children: /* @__PURE__ */
|
|
8677
|
+
children: /* @__PURE__ */ jsx77(CheckIcon, { size: size2 === "sm" ? 14 : 16, strokeWidth: 2.5, className: "ow-color-swatch-picker__check", "aria-hidden": "true" })
|
|
8645
8678
|
},
|
|
8646
8679
|
`${item.value}-${index}`
|
|
8647
8680
|
);
|
|
8648
8681
|
}),
|
|
8649
|
-
name ? /* @__PURE__ */
|
|
8682
|
+
name ? /* @__PURE__ */ jsx77("input", { type: "hidden", name, value: selectedIndex >= 0 ? items2[selectedIndex].value : "" }) : null
|
|
8650
8683
|
]
|
|
8651
8684
|
}
|
|
8652
8685
|
);
|
|
@@ -8881,6 +8914,7 @@ export {
|
|
|
8881
8914
|
Combobox,
|
|
8882
8915
|
CommandPalette,
|
|
8883
8916
|
ConfirmDialog,
|
|
8917
|
+
Container,
|
|
8884
8918
|
CopyButton,
|
|
8885
8919
|
DateField,
|
|
8886
8920
|
DatePicker,
|
|
@@ -8922,6 +8956,7 @@ export {
|
|
|
8922
8956
|
RangeCalendar,
|
|
8923
8957
|
ScrollShadow,
|
|
8924
8958
|
SearchField,
|
|
8959
|
+
Section,
|
|
8925
8960
|
SectionHeading,
|
|
8926
8961
|
SegmentedControl,
|
|
8927
8962
|
Select,
|