@openwarelabs/ui 0.11.1 → 0.12.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/dist/components/AppShell/AppShell.context.d.cts +21 -0
- package/dist/components/AppShell/AppShell.context.d.ts +21 -0
- package/dist/components/AppShell/AppShell.d.cts +17 -0
- package/dist/components/AppShell/AppShell.d.ts +17 -0
- package/dist/components/AppShell/AppShell.types.d.cts +46 -0
- package/dist/components/AppShell/AppShell.types.d.ts +46 -0
- package/dist/components/Chart/BarChart.d.cts +6 -0
- package/dist/components/Chart/BarChart.d.ts +6 -0
- package/dist/components/Chart/Cartesian.d.cts +8 -0
- package/dist/components/Chart/Cartesian.d.ts +8 -0
- package/dist/components/Chart/Chart.d.cts +5 -0
- package/dist/components/Chart/Chart.d.ts +5 -0
- package/dist/components/Chart/Chart.types.d.cts +83 -0
- package/dist/components/Chart/Chart.types.d.ts +83 -0
- package/dist/components/Chart/ChartParts.d.cts +16 -0
- package/dist/components/Chart/ChartParts.d.ts +16 -0
- package/dist/components/Chart/DonutChart.d.cts +6 -0
- package/dist/components/Chart/DonutChart.d.ts +6 -0
- package/dist/components/Chart/LineChart.d.cts +6 -0
- package/dist/components/Chart/LineChart.d.ts +6 -0
- package/dist/components/Chart/Sparkline.d.cts +6 -0
- package/dist/components/Chart/Sparkline.d.ts +6 -0
- package/dist/components/Chart/chartUtils.d.cts +13 -0
- package/dist/components/Chart/chartUtils.d.ts +13 -0
- package/dist/components/NavList/NavList.d.cts +6 -24
- package/dist/components/NavList/NavList.d.ts +6 -24
- package/dist/components/NavList/NavList.types.d.cts +23 -0
- package/dist/components/NavList/NavList.types.d.ts +23 -0
- package/dist/components.css +511 -0
- package/dist/icons.d.cts +3 -0
- package/dist/icons.d.ts +3 -0
- package/dist/index.cjs +1299 -729
- 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 +1281 -711
- package/dist/index.js.map +4 -4
- package/dist/openware-ui.iife.js +8 -8
- package/dist/styles.css +541 -0
- package/dist/tailwind.css +10 -0
- package/dist/tokens.css +30 -0
- package/dist/tokens.json +80 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -145,8 +145,8 @@ import { forwardRef as forwardRef2 } from "react";
|
|
|
145
145
|
|
|
146
146
|
// src/hooks/useControllableState.ts
|
|
147
147
|
import { useCallback, useRef, useState } from "react";
|
|
148
|
-
function useControllableState(value,
|
|
149
|
-
const [internal, setInternal] = useState(
|
|
148
|
+
function useControllableState(value, defaultValue2, onChange) {
|
|
149
|
+
const [internal, setInternal] = useState(defaultValue2);
|
|
150
150
|
const isControlled = value !== void 0;
|
|
151
151
|
const current = isControlled ? value : internal;
|
|
152
152
|
const currentRef = useRef(current);
|
|
@@ -330,6 +330,27 @@ var InboxIcon = /* @__PURE__ */ icon(
|
|
|
330
330
|
/* @__PURE__ */ jsx4("path", { d: "M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z" })
|
|
331
331
|
] })
|
|
332
332
|
);
|
|
333
|
+
var MenuIcon = /* @__PURE__ */ icon(
|
|
334
|
+
/* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
335
|
+
/* @__PURE__ */ jsx4("path", { d: "M4 5h16" }),
|
|
336
|
+
/* @__PURE__ */ jsx4("path", { d: "M4 12h16" }),
|
|
337
|
+
/* @__PURE__ */ jsx4("path", { d: "M4 19h16" })
|
|
338
|
+
] })
|
|
339
|
+
);
|
|
340
|
+
var PanelLeftOpenIcon = /* @__PURE__ */ icon(
|
|
341
|
+
/* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
342
|
+
/* @__PURE__ */ jsx4("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }),
|
|
343
|
+
/* @__PURE__ */ jsx4("path", { d: "M9 3v18" }),
|
|
344
|
+
/* @__PURE__ */ jsx4("path", { d: "m14 9 3 3-3 3" })
|
|
345
|
+
] })
|
|
346
|
+
);
|
|
347
|
+
var PanelLeftCloseIcon = /* @__PURE__ */ icon(
|
|
348
|
+
/* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
349
|
+
/* @__PURE__ */ jsx4("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }),
|
|
350
|
+
/* @__PURE__ */ jsx4("path", { d: "M9 3v18" }),
|
|
351
|
+
/* @__PURE__ */ jsx4("path", { d: "m16 15-3-3 3-3" })
|
|
352
|
+
] })
|
|
353
|
+
);
|
|
333
354
|
|
|
334
355
|
// src/components/Button/ButtonGroup.tsx
|
|
335
356
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
@@ -425,7 +446,7 @@ import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
|
425
446
|
function SegmentedControl({
|
|
426
447
|
options,
|
|
427
448
|
value,
|
|
428
|
-
defaultValue,
|
|
449
|
+
defaultValue: defaultValue2,
|
|
429
450
|
onChange,
|
|
430
451
|
size: size2 = "md",
|
|
431
452
|
fullWidth = false,
|
|
@@ -433,7 +454,7 @@ function SegmentedControl({
|
|
|
433
454
|
className,
|
|
434
455
|
...aria
|
|
435
456
|
}) {
|
|
436
|
-
const [current, setCurrent] = useControllableState(value,
|
|
457
|
+
const [current, setCurrent] = useControllableState(value, defaultValue2 ?? options[0]?.value ?? "", onChange);
|
|
437
458
|
const refs = useRef2([]);
|
|
438
459
|
const groupRef = useRef2(null);
|
|
439
460
|
useIndicator(groupRef, '[aria-checked="true"]', current);
|
|
@@ -957,7 +978,7 @@ function ToggleButtonGroup(props) {
|
|
|
957
978
|
options,
|
|
958
979
|
selectionMode = "single",
|
|
959
980
|
value,
|
|
960
|
-
defaultValue,
|
|
981
|
+
defaultValue: defaultValue2,
|
|
961
982
|
onChange,
|
|
962
983
|
disallowEmptySelection = false,
|
|
963
984
|
size: sizeProp,
|
|
@@ -975,7 +996,7 @@ function ToggleButtonGroup(props) {
|
|
|
975
996
|
const multiple = selectionMode === "multiple";
|
|
976
997
|
const [selected, setSelected] = useControllableState(
|
|
977
998
|
toList(value),
|
|
978
|
-
toList(
|
|
999
|
+
toList(defaultValue2) ?? [],
|
|
979
1000
|
(next) => onChange?.(multiple ? next : next[0] ?? "")
|
|
980
1001
|
);
|
|
981
1002
|
const [focusedValue, setFocusedValue] = useState6(null);
|
|
@@ -1138,7 +1159,7 @@ function CheckboxGroup({
|
|
|
1138
1159
|
label,
|
|
1139
1160
|
description,
|
|
1140
1161
|
value,
|
|
1141
|
-
defaultValue = [],
|
|
1162
|
+
defaultValue: defaultValue2 = [],
|
|
1142
1163
|
onChange,
|
|
1143
1164
|
orientation = "vertical",
|
|
1144
1165
|
error,
|
|
@@ -1147,7 +1168,7 @@ function CheckboxGroup({
|
|
|
1147
1168
|
children,
|
|
1148
1169
|
className
|
|
1149
1170
|
}) {
|
|
1150
|
-
const [current, setCurrent] = useControllableState(value,
|
|
1171
|
+
const [current, setCurrent] = useControllableState(value, defaultValue2, onChange);
|
|
1151
1172
|
const generatedName = useId();
|
|
1152
1173
|
const errorId = useId();
|
|
1153
1174
|
return /* @__PURE__ */ jsx12(
|
|
@@ -1615,7 +1636,7 @@ function assignRef2(ref, value) {
|
|
|
1615
1636
|
}
|
|
1616
1637
|
var SearchField = /* @__PURE__ */ forwardRef8(function SearchField2({
|
|
1617
1638
|
value,
|
|
1618
|
-
defaultValue = "",
|
|
1639
|
+
defaultValue: defaultValue2 = "",
|
|
1619
1640
|
onChange,
|
|
1620
1641
|
onSubmit,
|
|
1621
1642
|
loading = false,
|
|
@@ -1625,7 +1646,7 @@ var SearchField = /* @__PURE__ */ forwardRef8(function SearchField2({
|
|
|
1625
1646
|
onKeyDown,
|
|
1626
1647
|
...inputProps
|
|
1627
1648
|
}, ref) {
|
|
1628
|
-
const [text, setText] = useControllableState(value,
|
|
1649
|
+
const [text, setText] = useControllableState(value, defaultValue2, onChange);
|
|
1629
1650
|
const inputRef = useRef10(null);
|
|
1630
1651
|
function handleKeyDown(event) {
|
|
1631
1652
|
onKeyDown?.(event);
|
|
@@ -1675,7 +1696,7 @@ import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
|
1675
1696
|
var decimals = (step) => (String(step).split(".")[1] ?? "").length;
|
|
1676
1697
|
var NumberField = /* @__PURE__ */ forwardRef9(function NumberField2({
|
|
1677
1698
|
value,
|
|
1678
|
-
defaultValue = null,
|
|
1699
|
+
defaultValue: defaultValue2 = null,
|
|
1679
1700
|
onChange,
|
|
1680
1701
|
min,
|
|
1681
1702
|
max,
|
|
@@ -1692,7 +1713,7 @@ var NumberField = /* @__PURE__ */ forwardRef9(function NumberField2({
|
|
|
1692
1713
|
form,
|
|
1693
1714
|
...inputProps
|
|
1694
1715
|
}, ref) {
|
|
1695
|
-
const [
|
|
1716
|
+
const [number2, setNumber] = useControllableState(value, defaultValue2, onChange);
|
|
1696
1717
|
const [draft, setDraft] = useState9(null);
|
|
1697
1718
|
const format = (n) => n === null ? "" : formatOptions ? new Intl.NumberFormat(void 0, formatOptions).format(n) : String(n);
|
|
1698
1719
|
const clamp3 = (n) => {
|
|
@@ -1713,7 +1734,7 @@ var NumberField = /* @__PURE__ */ forwardRef9(function NumberField2({
|
|
|
1713
1734
|
if (keepEditing) setDraft(String(next));
|
|
1714
1735
|
}
|
|
1715
1736
|
function stepBy(multiple) {
|
|
1716
|
-
const base = draft !== null && draft !== "" && !Number.isNaN(Number(draft)) ? Number(draft) :
|
|
1737
|
+
const base = draft !== null && draft !== "" && !Number.isNaN(Number(draft)) ? Number(draft) : number2 ?? min ?? 0;
|
|
1717
1738
|
const next = clamp3(base + step * multiple);
|
|
1718
1739
|
setNumber(next);
|
|
1719
1740
|
if (draft !== null) setDraft(String(next));
|
|
@@ -1735,8 +1756,8 @@ var NumberField = /* @__PURE__ */ forwardRef9(function NumberField2({
|
|
|
1735
1756
|
event.preventDefault();
|
|
1736
1757
|
move();
|
|
1737
1758
|
}
|
|
1738
|
-
const atMin = min !== void 0 &&
|
|
1739
|
-
const atMax = max !== void 0 &&
|
|
1759
|
+
const atMin = min !== void 0 && number2 !== null && number2 <= min;
|
|
1760
|
+
const atMax = max !== void 0 && number2 !== null && number2 >= max;
|
|
1740
1761
|
return /* @__PURE__ */ jsxs12(
|
|
1741
1762
|
"div",
|
|
1742
1763
|
{
|
|
@@ -1769,16 +1790,16 @@ var NumberField = /* @__PURE__ */ forwardRef9(function NumberField2({
|
|
|
1769
1790
|
role: "spinbutton",
|
|
1770
1791
|
autoComplete: "off",
|
|
1771
1792
|
className: "ow-number-field__input",
|
|
1772
|
-
"aria-valuenow":
|
|
1793
|
+
"aria-valuenow": number2 ?? void 0,
|
|
1773
1794
|
"aria-valuemin": min,
|
|
1774
1795
|
"aria-valuemax": max,
|
|
1775
|
-
"aria-valuetext":
|
|
1796
|
+
"aria-valuetext": number2 === null ? void 0 : format(number2),
|
|
1776
1797
|
"aria-invalid": isInvalid || void 0,
|
|
1777
1798
|
disabled,
|
|
1778
|
-
value: draft ?? format(
|
|
1799
|
+
value: draft ?? format(number2),
|
|
1779
1800
|
onFocus: (event) => {
|
|
1780
1801
|
onFocus?.(event);
|
|
1781
|
-
setDraft(
|
|
1802
|
+
setDraft(number2 === null ? "" : String(number2));
|
|
1782
1803
|
},
|
|
1783
1804
|
onChange: (event) => setDraft(event.target.value),
|
|
1784
1805
|
onBlur: (event) => {
|
|
@@ -1789,7 +1810,7 @@ var NumberField = /* @__PURE__ */ forwardRef9(function NumberField2({
|
|
|
1789
1810
|
...inputProps
|
|
1790
1811
|
}
|
|
1791
1812
|
),
|
|
1792
|
-
name ? /* @__PURE__ */ jsx18("input", { type: "hidden", name, form, value:
|
|
1813
|
+
name ? /* @__PURE__ */ jsx18("input", { type: "hidden", name, form, value: number2 ?? "", disabled }) : null,
|
|
1793
1814
|
/* @__PURE__ */ jsx18(
|
|
1794
1815
|
"button",
|
|
1795
1816
|
{
|
|
@@ -1813,7 +1834,7 @@ import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
|
1813
1834
|
function InputOTP({
|
|
1814
1835
|
length = 6,
|
|
1815
1836
|
value,
|
|
1816
|
-
defaultValue = "",
|
|
1837
|
+
defaultValue: defaultValue2 = "",
|
|
1817
1838
|
onChange,
|
|
1818
1839
|
onComplete,
|
|
1819
1840
|
type = "numeric",
|
|
@@ -1828,7 +1849,7 @@ function InputOTP({
|
|
|
1828
1849
|
name,
|
|
1829
1850
|
className
|
|
1830
1851
|
}) {
|
|
1831
|
-
const [code, setCode] = useControllableState(value,
|
|
1852
|
+
const [code, setCode] = useControllableState(value, defaultValue2, onChange);
|
|
1832
1853
|
const refs = useRef11([]);
|
|
1833
1854
|
const latest = useRef11(code);
|
|
1834
1855
|
latest.current = code;
|
|
@@ -1925,35 +1946,35 @@ import { forwardRef as forwardRef10, useMemo as useMemo3, useRef as useRef13, us
|
|
|
1925
1946
|
|
|
1926
1947
|
// src/components/Calendar/dates.ts
|
|
1927
1948
|
var pad = (n) => String(n).padStart(2, "0");
|
|
1928
|
-
function toISO(year, month,
|
|
1949
|
+
function toISO(year, month, day2) {
|
|
1929
1950
|
const date = /* @__PURE__ */ new Date(0);
|
|
1930
|
-
date.setUTCFullYear(year, month,
|
|
1951
|
+
date.setUTCFullYear(year, month, day2);
|
|
1931
1952
|
return `${String(date.getUTCFullYear()).padStart(4, "0")}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}`;
|
|
1932
1953
|
}
|
|
1933
1954
|
function parseISO(iso) {
|
|
1934
|
-
const [year, month,
|
|
1935
|
-
return { year, month: month - 1, day };
|
|
1955
|
+
const [year, month, day2] = iso.split("-").map(Number);
|
|
1956
|
+
return { year, month: month - 1, day: day2 };
|
|
1936
1957
|
}
|
|
1937
1958
|
function todayISO() {
|
|
1938
1959
|
const now = /* @__PURE__ */ new Date();
|
|
1939
1960
|
return toISO(now.getFullYear(), now.getMonth(), now.getDate());
|
|
1940
1961
|
}
|
|
1941
1962
|
function addDays(iso, days) {
|
|
1942
|
-
const { year, month, day } = parseISO(iso);
|
|
1943
|
-
return toISO(year, month,
|
|
1963
|
+
const { year, month, day: day2 } = parseISO(iso);
|
|
1964
|
+
return toISO(year, month, day2 + days);
|
|
1944
1965
|
}
|
|
1945
1966
|
function addMonths(iso, months) {
|
|
1946
|
-
const { year, month, day } = parseISO(iso);
|
|
1967
|
+
const { year, month, day: day2 } = parseISO(iso);
|
|
1947
1968
|
const lastDay = new Date(Date.UTC(year, month + months + 1, 0)).getUTCDate();
|
|
1948
|
-
return toISO(year, month + months, Math.min(
|
|
1969
|
+
return toISO(year, month + months, Math.min(day2, lastDay));
|
|
1949
1970
|
}
|
|
1950
1971
|
function weekday(iso) {
|
|
1951
|
-
const { year, month, day } = parseISO(iso);
|
|
1952
|
-
return new Date(Date.UTC(year, month,
|
|
1972
|
+
const { year, month, day: day2 } = parseISO(iso);
|
|
1973
|
+
return new Date(Date.UTC(year, month, day2)).getUTCDay();
|
|
1953
1974
|
}
|
|
1954
1975
|
function toDate(iso) {
|
|
1955
|
-
const { year, month, day } = parseISO(iso);
|
|
1956
|
-
return new Date(Date.UTC(year, month,
|
|
1976
|
+
const { year, month, day: day2 } = parseISO(iso);
|
|
1977
|
+
return new Date(Date.UTC(year, month, day2));
|
|
1957
1978
|
}
|
|
1958
1979
|
function formatDate(iso, locale, options) {
|
|
1959
1980
|
return new Intl.DateTimeFormat(locale, { ...options, timeZone: "UTC" }).format(toDate(iso));
|
|
@@ -2194,9 +2215,9 @@ function SegmentedField({
|
|
|
2194
2215
|
segmentRefs.current.slice(0, segments.length).forEach((element, index) => {
|
|
2195
2216
|
if (!element) return;
|
|
2196
2217
|
const box = element.getBoundingClientRect();
|
|
2197
|
-
const
|
|
2198
|
-
if (
|
|
2199
|
-
distance =
|
|
2218
|
+
const gap2 = event.clientX < box.left ? box.left - event.clientX : Math.max(0, event.clientX - box.right);
|
|
2219
|
+
if (gap2 < distance) {
|
|
2220
|
+
distance = gap2;
|
|
2200
2221
|
nearest = index;
|
|
2201
2222
|
}
|
|
2202
2223
|
});
|
|
@@ -2364,12 +2385,12 @@ function daysIn(year, month) {
|
|
|
2364
2385
|
function fromISO(iso) {
|
|
2365
2386
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
|
|
2366
2387
|
if (!match) return {};
|
|
2367
|
-
const [year, month,
|
|
2368
|
-
if (year < 1 || month < 1 || month > 12 ||
|
|
2369
|
-
return { year, month, day };
|
|
2388
|
+
const [year, month, day2] = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
2389
|
+
if (year < 1 || month < 1 || month > 12 || day2 < 1 || day2 > daysIn(year, month)) return {};
|
|
2390
|
+
return { year, month, day: day2 };
|
|
2370
2391
|
}
|
|
2371
|
-
function toISOValue({ day, month, year }) {
|
|
2372
|
-
return
|
|
2392
|
+
function toISOValue({ day: day2, month, year }) {
|
|
2393
|
+
return day2 === void 0 || month === void 0 || year === void 0 ? "" : `${pad2(year, 4)}-${pad2(month)}-${pad2(day2)}`;
|
|
2373
2394
|
}
|
|
2374
2395
|
function constrain(parts) {
|
|
2375
2396
|
const last = daysIn(parts.year, parts.month);
|
|
@@ -2386,7 +2407,7 @@ function dateLayout(locale) {
|
|
|
2386
2407
|
}
|
|
2387
2408
|
var DateField = /* @__PURE__ */ forwardRef10(function DateField2({
|
|
2388
2409
|
value,
|
|
2389
|
-
defaultValue = "",
|
|
2410
|
+
defaultValue: defaultValue2 = "",
|
|
2390
2411
|
onChange,
|
|
2391
2412
|
min,
|
|
2392
2413
|
max,
|
|
@@ -2403,7 +2424,7 @@ var DateField = /* @__PURE__ */ forwardRef10(function DateField2({
|
|
|
2403
2424
|
"aria-describedby": ariaDescribedBy,
|
|
2404
2425
|
className
|
|
2405
2426
|
}, ref) {
|
|
2406
|
-
const [current, setCurrent] = useControllableState(value,
|
|
2427
|
+
const [current, setCurrent] = useControllableState(value, defaultValue2, onChange);
|
|
2407
2428
|
const [parts, setParts] = useState11(() => fromISO(current));
|
|
2408
2429
|
const partsRef = useRef13(parts);
|
|
2409
2430
|
partsRef.current = parts;
|
|
@@ -2549,7 +2570,7 @@ function timeLayout(locale, twelve, seconds) {
|
|
|
2549
2570
|
}
|
|
2550
2571
|
var TimeField = /* @__PURE__ */ forwardRef11(function TimeField2({
|
|
2551
2572
|
value,
|
|
2552
|
-
defaultValue = "",
|
|
2573
|
+
defaultValue: defaultValue2 = "",
|
|
2553
2574
|
onChange,
|
|
2554
2575
|
hourCycle,
|
|
2555
2576
|
granularity = "minute",
|
|
@@ -2569,7 +2590,7 @@ var TimeField = /* @__PURE__ */ forwardRef11(function TimeField2({
|
|
|
2569
2590
|
"aria-describedby": ariaDescribedBy,
|
|
2570
2591
|
className
|
|
2571
2592
|
}, ref) {
|
|
2572
|
-
const [current, setCurrent] = useControllableState(value,
|
|
2593
|
+
const [current, setCurrent] = useControllableState(value, defaultValue2, onChange);
|
|
2573
2594
|
const localeCycle = useMemo4(() => localeHourCycle(locale), [locale]);
|
|
2574
2595
|
const twelve = (hourCycle ?? localeCycle) === 12;
|
|
2575
2596
|
const seconds = granularity === "second";
|
|
@@ -3065,7 +3086,7 @@ function ListBoxWithRef({
|
|
|
3065
3086
|
options,
|
|
3066
3087
|
selectionMode,
|
|
3067
3088
|
value,
|
|
3068
|
-
defaultValue,
|
|
3089
|
+
defaultValue: defaultValue2,
|
|
3069
3090
|
onChange,
|
|
3070
3091
|
disallowEmptySelection = false,
|
|
3071
3092
|
emptyMessage = "No options",
|
|
@@ -3083,7 +3104,7 @@ function ListBoxWithRef({
|
|
|
3083
3104
|
const multiple = selectionMode === "multiple";
|
|
3084
3105
|
const [current, setCurrent] = useControllableState(
|
|
3085
3106
|
value,
|
|
3086
|
-
|
|
3107
|
+
defaultValue2 ?? (multiple ? [] : ""),
|
|
3087
3108
|
onChange
|
|
3088
3109
|
);
|
|
3089
3110
|
const listRef = useRef17(null);
|
|
@@ -3374,7 +3395,7 @@ function assignRef4(ref, value) {
|
|
|
3374
3395
|
var Combobox = /* @__PURE__ */ forwardRef14(function Combobox2({
|
|
3375
3396
|
options,
|
|
3376
3397
|
value,
|
|
3377
|
-
defaultValue = "",
|
|
3398
|
+
defaultValue: defaultValue2 = "",
|
|
3378
3399
|
onChange,
|
|
3379
3400
|
onInputChange,
|
|
3380
3401
|
placeholder = "Search\u2026",
|
|
@@ -3387,7 +3408,7 @@ var Combobox = /* @__PURE__ */ forwardRef14(function Combobox2({
|
|
|
3387
3408
|
className,
|
|
3388
3409
|
...aria
|
|
3389
3410
|
}, ref) {
|
|
3390
|
-
const [selected, setSelected] = useControllableState(value,
|
|
3411
|
+
const [selected, setSelected] = useControllableState(value, defaultValue2, onChange);
|
|
3391
3412
|
const labelOf = (v) => options.find((option) => option.value === v)?.label ?? (allowCustomValue ? v : "");
|
|
3392
3413
|
const [text, setText] = useState15(() => labelOf(selected));
|
|
3393
3414
|
const [isOpen, setOpen] = useState15(false);
|
|
@@ -3602,7 +3623,7 @@ function RadioGroup({
|
|
|
3602
3623
|
label,
|
|
3603
3624
|
description,
|
|
3604
3625
|
value,
|
|
3605
|
-
defaultValue = "",
|
|
3626
|
+
defaultValue: defaultValue2 = "",
|
|
3606
3627
|
onChange,
|
|
3607
3628
|
orientation = "vertical",
|
|
3608
3629
|
variant = "default",
|
|
@@ -3612,7 +3633,7 @@ function RadioGroup({
|
|
|
3612
3633
|
children,
|
|
3613
3634
|
className
|
|
3614
3635
|
}) {
|
|
3615
|
-
const [current, select] = useControllableState(value,
|
|
3636
|
+
const [current, select] = useControllableState(value, defaultValue2, onChange);
|
|
3616
3637
|
const generatedName = useId6();
|
|
3617
3638
|
return /* @__PURE__ */ jsx27(RadioGroupContext.Provider, { value: { name: name ?? generatedName, value: current, select, disabled }, children: /* @__PURE__ */ jsx27(
|
|
3618
3639
|
Fieldset,
|
|
@@ -3683,7 +3704,7 @@ import { useId as useId7 } from "react";
|
|
|
3683
3704
|
import { jsx as jsx29, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3684
3705
|
function Slider({
|
|
3685
3706
|
value,
|
|
3686
|
-
defaultValue,
|
|
3707
|
+
defaultValue: defaultValue2,
|
|
3687
3708
|
onChange,
|
|
3688
3709
|
onChangeEnd,
|
|
3689
3710
|
min = 0,
|
|
@@ -3699,7 +3720,7 @@ function Slider({
|
|
|
3699
3720
|
disabled,
|
|
3700
3721
|
className
|
|
3701
3722
|
}) {
|
|
3702
|
-
const [current, setCurrent] = useControllableState(value,
|
|
3723
|
+
const [current, setCurrent] = useControllableState(value, defaultValue2 ?? min, onChange);
|
|
3703
3724
|
const labelId = useId7();
|
|
3704
3725
|
const isRange = Array.isArray(current);
|
|
3705
3726
|
const [low, high] = isRange ? current : [min, current];
|
|
@@ -3880,8 +3901,8 @@ function FileDropZone({
|
|
|
3880
3901
|
// src/components/Calendar/Calendar.tsx
|
|
3881
3902
|
import { forwardRef as forwardRef16, useEffect as useEffect14, useImperativeHandle, useMemo as useMemo8, useRef as useRef20, useState as useState17 } from "react";
|
|
3882
3903
|
import { jsx as jsx31, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3883
|
-
var Calendar = /* @__PURE__ */ forwardRef16(function Calendar2({ value, defaultValue = "", onChange, min, max, isDateDisabled, locale, weekStartsOn = 1, autoFocus = false, className }, ref) {
|
|
3884
|
-
const [selected, setSelected] = useControllableState(value,
|
|
3904
|
+
var Calendar = /* @__PURE__ */ forwardRef16(function Calendar2({ value, defaultValue: defaultValue2 = "", onChange, min, max, isDateDisabled, locale, weekStartsOn = 1, autoFocus = false, className }, ref) {
|
|
3905
|
+
const [selected, setSelected] = useControllableState(value, defaultValue2, onChange);
|
|
3885
3906
|
const today = todayISO();
|
|
3886
3907
|
const [focused, setFocused] = useState17(() => selected || clampDate(today, min, max));
|
|
3887
3908
|
const [shouldFocus, setShouldFocus] = useState17(autoFocus);
|
|
@@ -3955,14 +3976,14 @@ function canShowAfter(last, max) {
|
|
|
3955
3976
|
return !max || addMonths(last, 1) <= max;
|
|
3956
3977
|
}
|
|
3957
3978
|
function dateForKey(event, date, weekStartsOn) {
|
|
3958
|
-
const
|
|
3979
|
+
const day2 = (weekday(date) - weekStartsOn + 7) % 7;
|
|
3959
3980
|
const moves = {
|
|
3960
3981
|
ArrowLeft: () => addDays(date, -1),
|
|
3961
3982
|
ArrowRight: () => addDays(date, 1),
|
|
3962
3983
|
ArrowUp: () => addDays(date, -7),
|
|
3963
3984
|
ArrowDown: () => addDays(date, 7),
|
|
3964
|
-
Home: () => addDays(date, -
|
|
3965
|
-
End: () => addDays(date, 6 -
|
|
3985
|
+
Home: () => addDays(date, -day2),
|
|
3986
|
+
End: () => addDays(date, 6 - day2),
|
|
3966
3987
|
PageUp: () => addMonths(date, event.shiftKey ? -12 : -1),
|
|
3967
3988
|
PageDown: () => addMonths(date, event.shiftKey ? 12 : 1)
|
|
3968
3989
|
};
|
|
@@ -4076,7 +4097,7 @@ function assignRef5(ref, value) {
|
|
|
4076
4097
|
}
|
|
4077
4098
|
var DatePicker = /* @__PURE__ */ forwardRef17(function DatePicker2({
|
|
4078
4099
|
value,
|
|
4079
|
-
defaultValue = "",
|
|
4100
|
+
defaultValue: defaultValue2 = "",
|
|
4080
4101
|
onChange,
|
|
4081
4102
|
placeholder = "Pick a date",
|
|
4082
4103
|
formatOptions = { dateStyle: "medium" },
|
|
@@ -4091,7 +4112,7 @@ var DatePicker = /* @__PURE__ */ forwardRef17(function DatePicker2({
|
|
|
4091
4112
|
"aria-describedby": ariaDescribedBy,
|
|
4092
4113
|
...calendarProps
|
|
4093
4114
|
}, ref) {
|
|
4094
|
-
const [date, setDate] = useControllableState(value,
|
|
4115
|
+
const [date, setDate] = useControllableState(value, defaultValue2, onChange);
|
|
4095
4116
|
const [isOpen, setOpen] = useState18(false);
|
|
4096
4117
|
const triggerRef = useRef21(null);
|
|
4097
4118
|
const panelRef = useRef21(null);
|
|
@@ -4174,9 +4195,9 @@ var DatePicker = /* @__PURE__ */ forwardRef17(function DatePicker2({
|
|
|
4174
4195
|
// src/components/Calendar/RangeCalendar.tsx
|
|
4175
4196
|
import { forwardRef as forwardRef18, useEffect as useEffect15, useId as useId10, useImperativeHandle as useImperativeHandle2, useRef as useRef22, useState as useState19 } from "react";
|
|
4176
4197
|
import { jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4177
|
-
var RangeCalendar = /* @__PURE__ */ forwardRef18(function RangeCalendar2({ value, defaultValue = null, onChange, min, max, isDateDisabled, locale, weekStartsOn = 1, visibleMonths = 1, autoFocus = false, className }, ref) {
|
|
4198
|
+
var RangeCalendar = /* @__PURE__ */ forwardRef18(function RangeCalendar2({ value, defaultValue: defaultValue2 = null, onChange, min, max, isDateDisabled, locale, weekStartsOn = 1, visibleMonths = 1, autoFocus = false, className }, ref) {
|
|
4178
4199
|
const months = visibleMonths;
|
|
4179
|
-
const [range, setRange] = useControllableState(value,
|
|
4200
|
+
const [range, setRange] = useControllableState(value, defaultValue2, onChange);
|
|
4180
4201
|
const today = todayISO();
|
|
4181
4202
|
const [focused, setFocused] = useState19(() => range ? ordered(range.start, range.end).start : clampDate(today, min, max));
|
|
4182
4203
|
const [firstMonth, setFirstMonth] = useState19(() => fitMonths(startOfMonth(focused), months, min, max));
|
|
@@ -4248,8 +4269,8 @@ var RangeCalendar = /* @__PURE__ */ forwardRef18(function RangeCalendar2({ value
|
|
|
4248
4269
|
}
|
|
4249
4270
|
function cellClassName(date, column) {
|
|
4250
4271
|
if (!shown || shown.start === shown.end || !inShown(date)) return void 0;
|
|
4251
|
-
const { day } = parseISO(date);
|
|
4252
|
-
const monthStart = months > 1 &&
|
|
4272
|
+
const { day: day2 } = parseISO(date);
|
|
4273
|
+
const monthStart = months > 1 && day2 === 1;
|
|
4253
4274
|
const monthEnd = months > 1 && parseISO(addDays(date, 1)).day === 1;
|
|
4254
4275
|
return cx("ow-range-calendar__cell--in-range", {
|
|
4255
4276
|
"ow-range-calendar__cell--start": date === shown.start,
|
|
@@ -4359,7 +4380,7 @@ function useMediaQuery(query) {
|
|
|
4359
4380
|
}
|
|
4360
4381
|
var DateRangePicker = /* @__PURE__ */ forwardRef19(function DateRangePicker2({
|
|
4361
4382
|
value,
|
|
4362
|
-
defaultValue = null,
|
|
4383
|
+
defaultValue: defaultValue2 = null,
|
|
4363
4384
|
onChange,
|
|
4364
4385
|
presets,
|
|
4365
4386
|
visibleMonths = 2,
|
|
@@ -4376,7 +4397,7 @@ var DateRangePicker = /* @__PURE__ */ forwardRef19(function DateRangePicker2({
|
|
|
4376
4397
|
"aria-describedby": ariaDescribedBy,
|
|
4377
4398
|
...calendarProps
|
|
4378
4399
|
}, ref) {
|
|
4379
|
-
const [range, setRange] = useControllableState(value,
|
|
4400
|
+
const [range, setRange] = useControllableState(value, defaultValue2, onChange);
|
|
4380
4401
|
const [isOpen, setOpen] = useState20(false);
|
|
4381
4402
|
const fieldRef = useRef23(null);
|
|
4382
4403
|
const triggerRef = useRef23(null);
|
|
@@ -4575,8 +4596,8 @@ function ProgressCircle({
|
|
|
4575
4596
|
className
|
|
4576
4597
|
}) {
|
|
4577
4598
|
const { box, stroke } = circleSizes[size2];
|
|
4578
|
-
const
|
|
4579
|
-
const circumference = 2 * Math.PI *
|
|
4599
|
+
const radius2 = (box - stroke) / 2;
|
|
4600
|
+
const circumference = 2 * Math.PI * radius2;
|
|
4580
4601
|
const indeterminate = value === void 0;
|
|
4581
4602
|
const pct = indeterminate ? 25 : Math.min(100, Math.max(0, value / max * 100));
|
|
4582
4603
|
return /* @__PURE__ */ jsxs26(
|
|
@@ -4596,14 +4617,14 @@ function ProgressCircle({
|
|
|
4596
4617
|
style: { width: box, height: box },
|
|
4597
4618
|
children: [
|
|
4598
4619
|
/* @__PURE__ */ jsxs26("svg", { width: box, height: box, viewBox: `0 0 ${box} ${box}`, "aria-hidden": "true", children: [
|
|
4599
|
-
/* @__PURE__ */ jsx36("circle", { className: "ow-progress-circle__track", cx: box / 2, cy: box / 2, r:
|
|
4620
|
+
/* @__PURE__ */ jsx36("circle", { className: "ow-progress-circle__track", cx: box / 2, cy: box / 2, r: radius2, strokeWidth: stroke, fill: "none" }),
|
|
4600
4621
|
/* @__PURE__ */ jsx36(
|
|
4601
4622
|
"circle",
|
|
4602
4623
|
{
|
|
4603
4624
|
className: "ow-progress-circle__fill",
|
|
4604
4625
|
cx: box / 2,
|
|
4605
4626
|
cy: box / 2,
|
|
4606
|
-
r:
|
|
4627
|
+
r: radius2,
|
|
4607
4628
|
strokeWidth: stroke,
|
|
4608
4629
|
fill: "none",
|
|
4609
4630
|
strokeLinecap: "round",
|
|
@@ -4742,7 +4763,7 @@ function Toaster({
|
|
|
4742
4763
|
duration = 6e3,
|
|
4743
4764
|
closeButton = true,
|
|
4744
4765
|
offset = 16,
|
|
4745
|
-
gap = 10,
|
|
4766
|
+
gap: gap2 = 10,
|
|
4746
4767
|
id,
|
|
4747
4768
|
className
|
|
4748
4769
|
}) {
|
|
@@ -4775,7 +4796,7 @@ function Toaster({
|
|
|
4775
4796
|
closeButton,
|
|
4776
4797
|
offset,
|
|
4777
4798
|
mobileOffset: offset,
|
|
4778
|
-
gap,
|
|
4799
|
+
gap: gap2,
|
|
4779
4800
|
icons: icons2,
|
|
4780
4801
|
className: cx("ow-toaster", className),
|
|
4781
4802
|
containerAriaLabel: "Notifications",
|
|
@@ -5414,8 +5435,8 @@ function useTabs(component) {
|
|
|
5414
5435
|
return context;
|
|
5415
5436
|
}
|
|
5416
5437
|
var idPart = (value) => value.replace(/[^\w-]/g, "_");
|
|
5417
|
-
function Tabs({ value, defaultValue = "", onValueChange, variant = "segmented", className, children, ...props }) {
|
|
5418
|
-
const [current, select] = useControllableState(value,
|
|
5438
|
+
function Tabs({ value, defaultValue: defaultValue2 = "", onValueChange, variant = "segmented", className, children, ...props }) {
|
|
5439
|
+
const [current, select] = useControllableState(value, defaultValue2, onValueChange);
|
|
5419
5440
|
const baseId = useId19();
|
|
5420
5441
|
return /* @__PURE__ */ jsx45(TabsContext.Provider, { value: { value: current, select, baseId, variant }, children: /* @__PURE__ */ jsx45("div", { className: cx("ow-tabs", `ow-tabs--${variant}`, className), ...props, children }) });
|
|
5421
5442
|
}
|
|
@@ -5582,7 +5603,7 @@ var AccordionContext = /* @__PURE__ */ createContext7(null);
|
|
|
5582
5603
|
function Accordion({
|
|
5583
5604
|
type = "single",
|
|
5584
5605
|
value,
|
|
5585
|
-
defaultValue = [],
|
|
5606
|
+
defaultValue: defaultValue2 = [],
|
|
5586
5607
|
onValueChange,
|
|
5587
5608
|
variant = "bordered",
|
|
5588
5609
|
headingLevel = 3,
|
|
@@ -5591,7 +5612,7 @@ function Accordion({
|
|
|
5591
5612
|
onKeyDown,
|
|
5592
5613
|
...props
|
|
5593
5614
|
}) {
|
|
5594
|
-
const [openValues, setOpenValues] = useControllableState(value,
|
|
5615
|
+
const [openValues, setOpenValues] = useControllableState(value, defaultValue2, onValueChange);
|
|
5595
5616
|
function toggle(item) {
|
|
5596
5617
|
const isOpen = openValues.includes(item);
|
|
5597
5618
|
if (type === "single") setOpenValues(isOpen ? [] : [item]);
|
|
@@ -5786,7 +5807,16 @@ function Steps({ items: items2, current = 0, orientation = "vertical", title, la
|
|
|
5786
5807
|
}
|
|
5787
5808
|
|
|
5788
5809
|
// src/components/NavList/NavList.tsx
|
|
5789
|
-
import { forwardRef as forwardRef22 } from "react";
|
|
5810
|
+
import { forwardRef as forwardRef22, useContext as useContext11 } from "react";
|
|
5811
|
+
|
|
5812
|
+
// src/components/AppShell/AppShell.context.ts
|
|
5813
|
+
import { createContext as createContext8, useContext as useContext10 } from "react";
|
|
5814
|
+
var AppShellContext = /* @__PURE__ */ createContext8(null);
|
|
5815
|
+
function useAppShell() {
|
|
5816
|
+
return useContext10(AppShellContext);
|
|
5817
|
+
}
|
|
5818
|
+
|
|
5819
|
+
// src/components/NavList/NavList.tsx
|
|
5790
5820
|
import { Fragment as Fragment9, jsx as jsx50, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
5791
5821
|
function NavList({ label, heading, orientation = "vertical", children, className }) {
|
|
5792
5822
|
return /* @__PURE__ */ jsxs39("nav", { "aria-label": label, className: cx("ow-nav", `ow-nav--${orientation}`, className), children: [
|
|
@@ -5795,6 +5825,7 @@ function NavList({ label, heading, orientation = "vertical", children, className
|
|
|
5795
5825
|
] });
|
|
5796
5826
|
}
|
|
5797
5827
|
var NavItem = /* @__PURE__ */ forwardRef22(function NavItem2({ icon: icon2, active = false, className, children, type = "button", href, end, ...buttonProps }, ref) {
|
|
5828
|
+
const collapsed = useContext11(AppShellContext)?.collapsed ?? false;
|
|
5798
5829
|
const content = /* @__PURE__ */ jsxs39(Fragment9, { children: [
|
|
5799
5830
|
icon2 ? /* @__PURE__ */ jsx50("span", { className: "ow-nav__icon", children: icon2 }) : null,
|
|
5800
5831
|
/* @__PURE__ */ jsx50("span", { className: "ow-nav__label", children }),
|
|
@@ -5804,24 +5835,215 @@ var NavItem = /* @__PURE__ */ forwardRef22(function NavItem2({ icon: icon2, acti
|
|
|
5804
5835
|
"aria-current": active ? "page" : void 0,
|
|
5805
5836
|
className: cx("ow-nav__item", active && "ow-nav__item--active", className)
|
|
5806
5837
|
};
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
"a",
|
|
5810
|
-
{
|
|
5811
|
-
ref,
|
|
5812
|
-
href,
|
|
5813
|
-
...shared,
|
|
5814
|
-
...buttonProps,
|
|
5815
|
-
children: content
|
|
5816
|
-
}
|
|
5817
|
-
);
|
|
5818
|
-
}
|
|
5819
|
-
return /* @__PURE__ */ jsx50("button", { ref, type, ...shared, ...buttonProps, children: content });
|
|
5838
|
+
const item = href !== void 0 ? /* @__PURE__ */ jsx50("a", { ref, href, ...shared, ...buttonProps, children: content }) : /* @__PURE__ */ jsx50("button", { ref, type, ...shared, ...buttonProps, children: content });
|
|
5839
|
+
return collapsed ? /* @__PURE__ */ jsx50(Tooltip, { label: children, placement: "right", children: item }) : item;
|
|
5820
5840
|
});
|
|
5821
5841
|
|
|
5842
|
+
// src/components/AppShell/AppShell.tsx
|
|
5843
|
+
import { useCallback as useCallback10, useId as useId22, useMemo as useMemo10, useState as useState27 } from "react";
|
|
5844
|
+
|
|
5845
|
+
// src/components/Layout/Layout.tsx
|
|
5846
|
+
import {
|
|
5847
|
+
useEffect as useEffect25,
|
|
5848
|
+
useRef as useRef31,
|
|
5849
|
+
useState as useState26
|
|
5850
|
+
} from "react";
|
|
5851
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
5852
|
+
var space = (token) => token === "none" ? "0" : `var(--ow-space-${token})`;
|
|
5853
|
+
var alignments = { start: "flex-start", center: "center", end: "flex-end", stretch: "stretch", baseline: "baseline", between: "space-between" };
|
|
5854
|
+
function Stack({
|
|
5855
|
+
direction = "column",
|
|
5856
|
+
gap: gap2 = "md",
|
|
5857
|
+
align,
|
|
5858
|
+
justify,
|
|
5859
|
+
wrap = false,
|
|
5860
|
+
as = "div",
|
|
5861
|
+
className,
|
|
5862
|
+
style,
|
|
5863
|
+
children,
|
|
5864
|
+
...props
|
|
5865
|
+
}) {
|
|
5866
|
+
const Element2 = as;
|
|
5867
|
+
return /* @__PURE__ */ jsx51(
|
|
5868
|
+
Element2,
|
|
5869
|
+
{
|
|
5870
|
+
className: cx("ow-stack", className),
|
|
5871
|
+
style: {
|
|
5872
|
+
flexDirection: direction,
|
|
5873
|
+
gap: space(gap2),
|
|
5874
|
+
alignItems: align ? alignments[align] : void 0,
|
|
5875
|
+
justifyContent: justify ? alignments[justify] : void 0,
|
|
5876
|
+
flexWrap: wrap ? "wrap" : void 0,
|
|
5877
|
+
...style
|
|
5878
|
+
},
|
|
5879
|
+
...props,
|
|
5880
|
+
children
|
|
5881
|
+
}
|
|
5882
|
+
);
|
|
5883
|
+
}
|
|
5884
|
+
function Separator({ orientation = "horizontal", label, spacing = "none", className }) {
|
|
5885
|
+
const margin2 = orientation === "horizontal" ? `${space(spacing)} 0` : `0 ${space(spacing)}`;
|
|
5886
|
+
if (label && orientation === "horizontal") {
|
|
5887
|
+
return /* @__PURE__ */ jsx51("div", { role: "separator", className: cx("ow-separator-label", className), style: { margin: margin2 }, children: /* @__PURE__ */ jsx51("span", { className: "ow-separator-label__text", children: label }) });
|
|
5888
|
+
}
|
|
5889
|
+
return /* @__PURE__ */ jsx51(
|
|
5890
|
+
"div",
|
|
5891
|
+
{
|
|
5892
|
+
role: "separator",
|
|
5893
|
+
"aria-orientation": orientation,
|
|
5894
|
+
className: cx("ow-separator", `ow-separator--${orientation}`, className),
|
|
5895
|
+
style: { margin: margin2 }
|
|
5896
|
+
}
|
|
5897
|
+
);
|
|
5898
|
+
}
|
|
5899
|
+
function ScrollShadow({
|
|
5900
|
+
orientation = "vertical",
|
|
5901
|
+
size: size2 = 32,
|
|
5902
|
+
maxSize,
|
|
5903
|
+
className,
|
|
5904
|
+
style,
|
|
5905
|
+
children,
|
|
5906
|
+
"aria-label": ariaLabel,
|
|
5907
|
+
...props
|
|
5908
|
+
}) {
|
|
5909
|
+
const ref = useRef31(null);
|
|
5910
|
+
const [edges, setEdges] = useState26({ start: false, end: false });
|
|
5911
|
+
useEffect25(() => {
|
|
5912
|
+
const element = ref.current;
|
|
5913
|
+
if (!element) return;
|
|
5914
|
+
const update = () => {
|
|
5915
|
+
const position = orientation === "vertical" ? element.scrollTop : element.scrollLeft;
|
|
5916
|
+
const extent = orientation === "vertical" ? element.scrollHeight - element.clientHeight : element.scrollWidth - element.clientWidth;
|
|
5917
|
+
setEdges({ start: position > 1, end: position < extent - 1 });
|
|
5918
|
+
};
|
|
5919
|
+
update();
|
|
5920
|
+
element.addEventListener("scroll", update, { passive: true });
|
|
5921
|
+
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(update);
|
|
5922
|
+
observer?.observe(element);
|
|
5923
|
+
if (element.firstElementChild) observer?.observe(element.firstElementChild);
|
|
5924
|
+
return () => {
|
|
5925
|
+
element.removeEventListener("scroll", update);
|
|
5926
|
+
observer?.disconnect();
|
|
5927
|
+
};
|
|
5928
|
+
}, [orientation]);
|
|
5929
|
+
return /* @__PURE__ */ jsx51(
|
|
5930
|
+
"div",
|
|
5931
|
+
{
|
|
5932
|
+
ref,
|
|
5933
|
+
className: cx("ow-scroll-shadow", `ow-scroll-shadow--${orientation}`, className),
|
|
5934
|
+
"data-start": edges.start || void 0,
|
|
5935
|
+
"data-end": edges.end || void 0,
|
|
5936
|
+
tabIndex: ariaLabel ? 0 : void 0,
|
|
5937
|
+
role: ariaLabel ? "region" : void 0,
|
|
5938
|
+
"aria-label": ariaLabel,
|
|
5939
|
+
style: {
|
|
5940
|
+
"--ow-scroll-shadow": `${size2}px`,
|
|
5941
|
+
[orientation === "vertical" ? "maxHeight" : "maxWidth"]: maxSize,
|
|
5942
|
+
...style
|
|
5943
|
+
},
|
|
5944
|
+
...props,
|
|
5945
|
+
children
|
|
5946
|
+
}
|
|
5947
|
+
);
|
|
5948
|
+
}
|
|
5949
|
+
function VisuallyHidden({ className, ...props }) {
|
|
5950
|
+
return /* @__PURE__ */ jsx51("span", { className: cx("ow-visually-hidden", className), ...props });
|
|
5951
|
+
}
|
|
5952
|
+
|
|
5953
|
+
// src/components/AppShell/AppShell.tsx
|
|
5954
|
+
import { jsx as jsx52, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
5955
|
+
function AppShell({
|
|
5956
|
+
sidebar,
|
|
5957
|
+
children,
|
|
5958
|
+
variant = "inset",
|
|
5959
|
+
collapsible = false,
|
|
5960
|
+
collapsed,
|
|
5961
|
+
defaultCollapsed = false,
|
|
5962
|
+
onCollapsedChange,
|
|
5963
|
+
breakpoint = "md",
|
|
5964
|
+
topbar,
|
|
5965
|
+
topbarActions,
|
|
5966
|
+
labels = {},
|
|
5967
|
+
className,
|
|
5968
|
+
...props
|
|
5969
|
+
}) {
|
|
5970
|
+
const sidebarId = useId22();
|
|
5971
|
+
const [ownCollapsed, setOwnCollapsed] = useControllableState(collapsed, defaultCollapsed, onCollapsedChange);
|
|
5972
|
+
const [drawerOpen, setDrawerOpen] = useState27(false);
|
|
5973
|
+
const folded = collapsible && ownCollapsed;
|
|
5974
|
+
const openNavigation = useCallback10(() => setDrawerOpen(true), []);
|
|
5975
|
+
const closeNavigation = useCallback10(() => setDrawerOpen(false), []);
|
|
5976
|
+
const shared = useMemo10(
|
|
5977
|
+
() => ({
|
|
5978
|
+
collapsible,
|
|
5979
|
+
setCollapsed: setOwnCollapsed,
|
|
5980
|
+
toggleCollapsed: () => setOwnCollapsed((previous) => !previous),
|
|
5981
|
+
openNavigation,
|
|
5982
|
+
closeNavigation,
|
|
5983
|
+
sidebarId
|
|
5984
|
+
}),
|
|
5985
|
+
[collapsible, setOwnCollapsed, openNavigation, closeNavigation, sidebarId]
|
|
5986
|
+
);
|
|
5987
|
+
const beside = useMemo10(() => ({ ...shared, collapsed: folded, inDrawer: false }), [shared, folded]);
|
|
5988
|
+
const inDrawer = useMemo10(() => ({ ...shared, collapsed: false, inDrawer: true }), [shared]);
|
|
5989
|
+
const closeOnChoice = (event) => {
|
|
5990
|
+
if (event.target.closest(".ow-nav__item, [data-closes-navigation]")) setDrawerOpen(false);
|
|
5991
|
+
};
|
|
5992
|
+
return /* @__PURE__ */ jsxs40(
|
|
5993
|
+
"div",
|
|
5994
|
+
{
|
|
5995
|
+
className: cx("ow-app-shell", `ow-app-shell--${variant}`, `ow-app-shell--${breakpoint}`, folded && "ow-app-shell--collapsed", className),
|
|
5996
|
+
...props,
|
|
5997
|
+
children: [
|
|
5998
|
+
/* @__PURE__ */ jsxs40("div", { className: "ow-app-shell__frame", children: [
|
|
5999
|
+
/* @__PURE__ */ jsx52(AppShellContext.Provider, { value: beside, children: /* @__PURE__ */ jsx52("aside", { id: sidebarId, className: "ow-app-shell__sidebar", "aria-label": labels.navigation ?? "Main navigation", children: /* @__PURE__ */ jsx52("div", { className: "ow-sidebar", children: sidebar }) }) }),
|
|
6000
|
+
/* @__PURE__ */ jsxs40("div", { className: "ow-app-shell__body", children: [
|
|
6001
|
+
/* @__PURE__ */ jsxs40("header", { className: "ow-app-shell__topbar", children: [
|
|
6002
|
+
/* @__PURE__ */ jsx52(Button, { variant: "ghost", iconOnly: true, "aria-label": labels.openNavigation ?? "Open navigation", onClick: openNavigation, children: /* @__PURE__ */ jsx52(MenuIcon, { size: 18 }) }),
|
|
6003
|
+
/* @__PURE__ */ jsx52("div", { className: "ow-app-shell__topbar-start", children: topbar }),
|
|
6004
|
+
topbarActions ? /* @__PURE__ */ jsx52("div", { className: "ow-app-shell__topbar-end", children: topbarActions }) : null
|
|
6005
|
+
] }),
|
|
6006
|
+
/* @__PURE__ */ jsx52("main", { className: "ow-app-shell__main", children })
|
|
6007
|
+
] })
|
|
6008
|
+
] }),
|
|
6009
|
+
/* @__PURE__ */ jsx52(Drawer, { open: drawerOpen, onClose: closeNavigation, side: "left", size: 300, title: labels.menu ?? "Menu", className: "ow-app-shell__drawer", children: /* @__PURE__ */ jsx52(AppShellContext.Provider, { value: inDrawer, children: /* @__PURE__ */ jsx52("div", { className: "ow-sidebar ow-sidebar--drawer", onClick: closeOnChoice, children: sidebar }) }) })
|
|
6010
|
+
]
|
|
6011
|
+
}
|
|
6012
|
+
);
|
|
6013
|
+
}
|
|
6014
|
+
function SidebarHeader({ className, ...props }) {
|
|
6015
|
+
return /* @__PURE__ */ jsx52("div", { className: cx("ow-sidebar__header", className), ...props });
|
|
6016
|
+
}
|
|
6017
|
+
function SidebarContent({ className, children, ...props }) {
|
|
6018
|
+
return /* @__PURE__ */ jsx52(ScrollShadow, { className: cx("ow-sidebar__content", className), ...props, children });
|
|
6019
|
+
}
|
|
6020
|
+
function SidebarFooter({ className, ...props }) {
|
|
6021
|
+
return /* @__PURE__ */ jsx52("div", { className: cx("ow-sidebar__footer", className), ...props });
|
|
6022
|
+
}
|
|
6023
|
+
function SidebarToggle({ labels = {}, className }) {
|
|
6024
|
+
const shell = useAppShell();
|
|
6025
|
+
if (!shell?.collapsible || shell.inDrawer) return null;
|
|
6026
|
+
const label = shell.collapsed ? labels.expand ?? "Expand sidebar" : labels.collapse ?? "Collapse sidebar";
|
|
6027
|
+
const Icon = shell.collapsed ? PanelLeftOpenIcon : PanelLeftCloseIcon;
|
|
6028
|
+
return /* @__PURE__ */ jsx52(Tooltip, { label, placement: "right", children: /* @__PURE__ */ jsx52(
|
|
6029
|
+
Button,
|
|
6030
|
+
{
|
|
6031
|
+
variant: "ghost",
|
|
6032
|
+
iconOnly: true,
|
|
6033
|
+
size: "sm",
|
|
6034
|
+
"aria-label": label,
|
|
6035
|
+
"aria-expanded": !shell.collapsed,
|
|
6036
|
+
"aria-controls": shell.sidebarId,
|
|
6037
|
+
className: cx("ow-sidebar__toggle", className),
|
|
6038
|
+
onClick: shell.toggleCollapsed,
|
|
6039
|
+
children: /* @__PURE__ */ jsx52(Icon, { size: 16 })
|
|
6040
|
+
}
|
|
6041
|
+
) });
|
|
6042
|
+
}
|
|
6043
|
+
|
|
5822
6044
|
// src/components/Table/Table.tsx
|
|
5823
|
-
import { useMemo as
|
|
5824
|
-
import { jsx as
|
|
6045
|
+
import { useMemo as useMemo11 } from "react";
|
|
6046
|
+
import { jsx as jsx53, jsxs as jsxs41 } from "react/jsx-runtime";
|
|
5825
6047
|
function compare(a, b) {
|
|
5826
6048
|
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
5827
6049
|
return String(a).localeCompare(String(b), void 0, { numeric: true, sensitivity: "base" });
|
|
@@ -5856,7 +6078,7 @@ function Table({
|
|
|
5856
6078
|
return typeof first === "string" || typeof first === "number" ? String(first) : `row ${index + 1}`;
|
|
5857
6079
|
};
|
|
5858
6080
|
const field = (row, key) => row[key];
|
|
5859
|
-
const sorted =
|
|
6081
|
+
const sorted = useMemo11(() => {
|
|
5860
6082
|
if (!currentSort || manualSort) return rows;
|
|
5861
6083
|
const column = columns.find((c) => c.key === currentSort.key);
|
|
5862
6084
|
if (!column) return rows;
|
|
@@ -5872,16 +6094,16 @@ function Table({
|
|
|
5872
6094
|
);
|
|
5873
6095
|
}
|
|
5874
6096
|
const selectable = selectionMode === "multiple";
|
|
5875
|
-
return /* @__PURE__ */
|
|
6097
|
+
return /* @__PURE__ */ jsx53(
|
|
5876
6098
|
"div",
|
|
5877
6099
|
{
|
|
5878
6100
|
className: cx("ow-table-wrap", stickyHeader && "ow-table-wrap--sticky", className),
|
|
5879
6101
|
style: maxHeight ? { maxHeight } : void 0,
|
|
5880
6102
|
tabIndex: maxHeight ? 0 : void 0,
|
|
5881
|
-
children: /* @__PURE__ */
|
|
5882
|
-
caption ? /* @__PURE__ */
|
|
5883
|
-
/* @__PURE__ */
|
|
5884
|
-
selectable ? /* @__PURE__ */
|
|
6103
|
+
children: /* @__PURE__ */ jsxs41("table", { className: cx("ow-table", `ow-table--${density}`), children: [
|
|
6104
|
+
caption ? /* @__PURE__ */ jsx53("caption", { className: cx("ow-table__caption", hideCaption && "ow-visually-hidden"), children: caption }) : null,
|
|
6105
|
+
/* @__PURE__ */ jsx53("thead", { children: /* @__PURE__ */ jsxs41("tr", { children: [
|
|
6106
|
+
selectable ? /* @__PURE__ */ jsx53("th", { className: "ow-table__select", scope: "col", children: /* @__PURE__ */ jsx53(
|
|
5885
6107
|
Checkbox,
|
|
5886
6108
|
{
|
|
5887
6109
|
size: "sm",
|
|
@@ -5895,27 +6117,27 @@ function Table({
|
|
|
5895
6117
|
) }) : null,
|
|
5896
6118
|
columns.map((column) => {
|
|
5897
6119
|
const direction = currentSort?.key === column.key ? currentSort.direction : void 0;
|
|
5898
|
-
return /* @__PURE__ */
|
|
6120
|
+
return /* @__PURE__ */ jsx53(
|
|
5899
6121
|
"th",
|
|
5900
6122
|
{
|
|
5901
6123
|
scope: "col",
|
|
5902
6124
|
"aria-sort": direction ?? (column.sortable ? "none" : void 0),
|
|
5903
6125
|
className: cx(`ow-table__cell--${column.align ?? "start"}`),
|
|
5904
6126
|
style: column.width !== void 0 ? { width: column.width } : void 0,
|
|
5905
|
-
children: column.sortable ? /* @__PURE__ */
|
|
6127
|
+
children: column.sortable ? /* @__PURE__ */ jsxs41("button", { type: "button", className: "ow-table__sort", onClick: () => toggleSort(column.key), children: [
|
|
5906
6128
|
column.header,
|
|
5907
|
-
/* @__PURE__ */
|
|
6129
|
+
/* @__PURE__ */ jsx53("span", { className: cx("ow-table__sort-icon", direction && "ow-table__sort-icon--active"), children: direction === "ascending" ? /* @__PURE__ */ jsx53(ArrowUpIcon, { size: 12 }) : direction === "descending" ? /* @__PURE__ */ jsx53(ArrowDownIcon, { size: 12 }) : /* @__PURE__ */ jsx53(ChevronsUpDownIcon, { size: 12 }) })
|
|
5908
6130
|
] }) : column.header
|
|
5909
6131
|
},
|
|
5910
6132
|
column.key
|
|
5911
6133
|
);
|
|
5912
6134
|
})
|
|
5913
6135
|
] }) }),
|
|
5914
|
-
/* @__PURE__ */
|
|
6136
|
+
/* @__PURE__ */ jsx53("tbody", { children: sorted.length === 0 ? /* @__PURE__ */ jsx53("tr", { children: /* @__PURE__ */ jsx53("td", { className: "ow-table__empty", colSpan: columns.length + (selectable ? 1 : 0), children: emptyContent }) }) : sorted.map((row, index) => {
|
|
5915
6137
|
const key = keyOf2(row);
|
|
5916
6138
|
const isSelected = selected.includes(key);
|
|
5917
|
-
return /* @__PURE__ */
|
|
5918
|
-
selectable ? /* @__PURE__ */
|
|
6139
|
+
return /* @__PURE__ */ jsxs41("tr", { className: cx(isSelected && "ow-table__row--selected"), children: [
|
|
6140
|
+
selectable ? /* @__PURE__ */ jsx53("td", { className: "ow-table__select", children: /* @__PURE__ */ jsx53(
|
|
5919
6141
|
Checkbox,
|
|
5920
6142
|
{
|
|
5921
6143
|
size: "sm",
|
|
@@ -5926,7 +6148,7 @@ function Table({
|
|
|
5926
6148
|
)
|
|
5927
6149
|
}
|
|
5928
6150
|
) }) : null,
|
|
5929
|
-
columns.map((column) => /* @__PURE__ */
|
|
6151
|
+
columns.map((column) => /* @__PURE__ */ jsx53("td", { className: cx(`ow-table__cell--${column.align ?? "start"}`), children: column.render ? column.render(row) : field(row, column.key) }, column.key))
|
|
5930
6152
|
] }, key);
|
|
5931
6153
|
}) })
|
|
5932
6154
|
] })
|
|
@@ -5935,7 +6157,7 @@ function Table({
|
|
|
5935
6157
|
}
|
|
5936
6158
|
|
|
5937
6159
|
// src/components/Stat/Stat.tsx
|
|
5938
|
-
import { jsx as
|
|
6160
|
+
import { jsx as jsx54, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
5939
6161
|
function Sparkline({ values }) {
|
|
5940
6162
|
const max = Math.max(...values);
|
|
5941
6163
|
const min = Math.min(...values);
|
|
@@ -5947,37 +6169,483 @@ function Sparkline({ values }) {
|
|
|
5947
6169
|
});
|
|
5948
6170
|
const line = points.map(([x, y], index) => `${index ? "L" : "M"}${x.toFixed(2)} ${y.toFixed(2)}`).join(" ");
|
|
5949
6171
|
const [lastX, lastY] = points[points.length - 1];
|
|
5950
|
-
return /* @__PURE__ */
|
|
5951
|
-
/* @__PURE__ */
|
|
5952
|
-
/* @__PURE__ */
|
|
5953
|
-
/* @__PURE__ */
|
|
6172
|
+
return /* @__PURE__ */ jsxs42("div", { className: "ow-stat__trend", "aria-hidden": "true", children: [
|
|
6173
|
+
/* @__PURE__ */ jsxs42("svg", { viewBox: "0 0 100 40", preserveAspectRatio: "none", children: [
|
|
6174
|
+
/* @__PURE__ */ jsx54("path", { d: `${line} L100 40 L0 40 Z`, className: "ow-stat__trend-area" }),
|
|
6175
|
+
/* @__PURE__ */ jsx54("path", { d: line, className: "ow-stat__trend-line", vectorEffect: "non-scaling-stroke" })
|
|
5954
6176
|
] }),
|
|
5955
|
-
/* @__PURE__ */
|
|
6177
|
+
/* @__PURE__ */ jsx54("span", { className: "ow-stat__trend-end", style: { left: `${lastX}%`, top: `${lastY / 40 * 100}%` } })
|
|
5956
6178
|
] });
|
|
5957
6179
|
}
|
|
5958
6180
|
function Stat({ label, value, icon: icon2, change, changeTone, description, trend, className }) {
|
|
5959
6181
|
const tone = changeTone ?? (change?.startsWith("+") ? "positive" : /^[-−]/.test(change ?? "") ? "negative" : "neutral");
|
|
5960
6182
|
const rising = change ? !/^[-−]/.test(change) : false;
|
|
5961
|
-
return /* @__PURE__ */
|
|
5962
|
-
/* @__PURE__ */
|
|
5963
|
-
icon2 ? /* @__PURE__ */
|
|
5964
|
-
/* @__PURE__ */
|
|
6183
|
+
return /* @__PURE__ */ jsxs42("div", { className: cx("ow-stat", className), children: [
|
|
6184
|
+
/* @__PURE__ */ jsxs42("div", { className: "ow-stat__label", children: [
|
|
6185
|
+
icon2 ? /* @__PURE__ */ jsx54("span", { className: "ow-stat__icon", children: icon2 }) : null,
|
|
6186
|
+
/* @__PURE__ */ jsx54("span", { children: label })
|
|
5965
6187
|
] }),
|
|
5966
|
-
/* @__PURE__ */
|
|
5967
|
-
/* @__PURE__ */
|
|
5968
|
-
change ? /* @__PURE__ */
|
|
5969
|
-
tone === "neutral" ? null : rising ? /* @__PURE__ */
|
|
6188
|
+
/* @__PURE__ */ jsxs42("div", { className: "ow-stat__row", children: [
|
|
6189
|
+
/* @__PURE__ */ jsx54("span", { className: "ow-stat__value", children: value }),
|
|
6190
|
+
change ? /* @__PURE__ */ jsxs42("span", { className: cx("ow-stat__change", `ow-stat__change--${tone}`), children: [
|
|
6191
|
+
tone === "neutral" ? null : rising ? /* @__PURE__ */ jsx54(ArrowUpIcon, { size: 12 }) : /* @__PURE__ */ jsx54(ArrowDownIcon, { size: 12 }),
|
|
5970
6192
|
change
|
|
5971
6193
|
] }) : null
|
|
5972
6194
|
] }),
|
|
5973
|
-
description ? /* @__PURE__ */
|
|
5974
|
-
trend && trend.length > 1 ? /* @__PURE__ */
|
|
6195
|
+
description ? /* @__PURE__ */ jsx54("div", { className: "ow-stat__description", children: description }) : null,
|
|
6196
|
+
trend && trend.length > 1 ? /* @__PURE__ */ jsx54(Sparkline, { values: trend }) : null
|
|
6197
|
+
] });
|
|
6198
|
+
}
|
|
6199
|
+
|
|
6200
|
+
// src/components/Chart/Cartesian.tsx
|
|
6201
|
+
import { useState as useState29 } from "react";
|
|
6202
|
+
|
|
6203
|
+
// src/components/Chart/chartUtils.ts
|
|
6204
|
+
import { useLayoutEffect as useLayoutEffect7, useRef as useRef32, useState as useState28 } from "react";
|
|
6205
|
+
var colorOf = (color, index) => color === void 0 ? `var(--ow-chart-${index % 8 + 1})` : typeof color === "number" ? `var(--ow-chart-${color})` : color;
|
|
6206
|
+
var seriesColors = (series) => series.map((entry, index) => colorOf(entry.color, index));
|
|
6207
|
+
var number = new Intl.NumberFormat();
|
|
6208
|
+
var compact = new Intl.NumberFormat(void 0, { notation: "compact", maximumFractionDigits: 1 });
|
|
6209
|
+
var day = new Intl.DateTimeFormat(void 0, { day: "numeric", month: "short" });
|
|
6210
|
+
var defaultValue = (value) => number.format(value);
|
|
6211
|
+
var defaultTick = (value) => compact.format(value);
|
|
6212
|
+
var defaultIndex = (value) => value instanceof Date ? day.format(value) : String(value ?? "");
|
|
6213
|
+
var valueOf = (row, key) => {
|
|
6214
|
+
const value = row?.[key];
|
|
6215
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
6216
|
+
};
|
|
6217
|
+
function niceTicks(min, max) {
|
|
6218
|
+
const low = Math.min(0, min);
|
|
6219
|
+
const high = Math.max(0, max);
|
|
6220
|
+
const rough = (high - low || 1) / 4;
|
|
6221
|
+
const power = 10 ** Math.floor(Math.log10(rough));
|
|
6222
|
+
const step = [1, 2, 2.5, 5, 10].map((factor) => factor * power).find((candidate) => candidate >= rough);
|
|
6223
|
+
const start = Math.floor(low / step) * step;
|
|
6224
|
+
const end = Math.ceil(high / step) * step || step;
|
|
6225
|
+
const ticks = [];
|
|
6226
|
+
for (let tick = start; tick <= end + step / 2; tick += step) ticks.push(Math.round(tick / step) * step);
|
|
6227
|
+
return ticks;
|
|
6228
|
+
}
|
|
6229
|
+
function useWidth() {
|
|
6230
|
+
const ref = useRef32(null);
|
|
6231
|
+
const [width, setWidth] = useState28(0);
|
|
6232
|
+
useLayoutEffect7(() => {
|
|
6233
|
+
const element = ref.current;
|
|
6234
|
+
if (!element) return;
|
|
6235
|
+
const measure = () => setWidth(element.clientWidth);
|
|
6236
|
+
measure();
|
|
6237
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
6238
|
+
const observer = new ResizeObserver(measure);
|
|
6239
|
+
observer.observe(element);
|
|
6240
|
+
return () => observer.disconnect();
|
|
6241
|
+
}, []);
|
|
6242
|
+
return [ref, width];
|
|
6243
|
+
}
|
|
6244
|
+
var textWidth = (text) => text.length * 6.6;
|
|
6245
|
+
|
|
6246
|
+
// src/components/Chart/ChartParts.tsx
|
|
6247
|
+
import { jsx as jsx55, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
6248
|
+
function ChartLegend({ items: items2, shape }) {
|
|
6249
|
+
return /* @__PURE__ */ jsx55("ul", { className: "ow-chart__legend", children: items2.map((item, i) => /* @__PURE__ */ jsxs43("li", { className: "ow-chart__legend-item", children: [
|
|
6250
|
+
/* @__PURE__ */ jsx55("span", { className: `ow-chart__key ow-chart__key--${shape}`, style: { background: item.color }, "aria-hidden": "true" }),
|
|
6251
|
+
/* @__PURE__ */ jsx55("span", { className: "ow-chart__legend-label", children: item.label }),
|
|
6252
|
+
item.value !== void 0 ? /* @__PURE__ */ jsx55("span", { className: "ow-chart__legend-value", children: item.value }) : null
|
|
6253
|
+
] }, i)) });
|
|
6254
|
+
}
|
|
6255
|
+
function ChartTable({ caption, head, rows }) {
|
|
6256
|
+
return /* @__PURE__ */ jsxs43("table", { className: "ow-visually-hidden", children: [
|
|
6257
|
+
/* @__PURE__ */ jsx55("caption", { children: caption }),
|
|
6258
|
+
/* @__PURE__ */ jsx55("thead", { children: /* @__PURE__ */ jsx55("tr", { children: head.map((cell, i) => /* @__PURE__ */ jsx55("th", { scope: "col", children: cell }, i)) }) }),
|
|
6259
|
+
/* @__PURE__ */ jsx55("tbody", { children: rows.map((row, r) => /* @__PURE__ */ jsx55("tr", { children: row.map(
|
|
6260
|
+
(cell, i) => i === 0 ? /* @__PURE__ */ jsx55("th", { scope: "row", children: cell }, i) : /* @__PURE__ */ jsx55("td", { children: cell }, i)
|
|
6261
|
+
) }, r)) })
|
|
6262
|
+
] });
|
|
6263
|
+
}
|
|
6264
|
+
|
|
6265
|
+
// src/components/Chart/Cartesian.tsx
|
|
6266
|
+
import { Fragment as Fragment10, jsx as jsx56, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
6267
|
+
var gap = 2;
|
|
6268
|
+
var maxBar = 24;
|
|
6269
|
+
var radius = 4;
|
|
6270
|
+
function barPath(x, top, width, bottom, round) {
|
|
6271
|
+
const height = bottom - top;
|
|
6272
|
+
if (height <= 0 || width <= 0) return "";
|
|
6273
|
+
const r = round ? Math.min(radius, width / 2, height) : 0;
|
|
6274
|
+
return `M${x} ${bottom}V${top + r}${r ? `Q${x} ${top} ${x + r} ${top}` : ""}H${x + width - r}${r ? `Q${x + width} ${top} ${x + width} ${top + r}` : ""}V${bottom}Z`;
|
|
6275
|
+
}
|
|
6276
|
+
function linePath(points, curved) {
|
|
6277
|
+
if (!points.length) return "";
|
|
6278
|
+
const fixed = (n2) => n2.toFixed(1);
|
|
6279
|
+
if (!curved || points.length < 3) return points.map(([x, y], i) => `${i ? "L" : "M"}${fixed(x)} ${fixed(y)}`).join("");
|
|
6280
|
+
const n = points.length;
|
|
6281
|
+
const slopes = points.slice(0, -1).map(([x, y], i) => (points[i + 1][1] - y) / (points[i + 1][0] - x || 1));
|
|
6282
|
+
const tangents = points.map((_, i) => {
|
|
6283
|
+
if (i === 0) return slopes[0];
|
|
6284
|
+
if (i === n - 1) return slopes[n - 2];
|
|
6285
|
+
const a = slopes[i - 1];
|
|
6286
|
+
const b = slopes[i];
|
|
6287
|
+
return a * b <= 0 ? 0 : 3 * a * b / (Math.max(a, b) * 2 + Math.min(a, b));
|
|
6288
|
+
});
|
|
6289
|
+
let d = `M${fixed(points[0][0])} ${fixed(points[0][1])}`;
|
|
6290
|
+
for (let i = 0; i < n - 1; i++) {
|
|
6291
|
+
const [x0, y0] = points[i];
|
|
6292
|
+
const [x1, y1] = points[i + 1];
|
|
6293
|
+
const h = (x1 - x0) / 3;
|
|
6294
|
+
d += `C${fixed(x0 + h)} ${fixed(y0 + tangents[i] * h)} ${fixed(x1 - h)} ${fixed(y1 - tangents[i + 1] * h)} ${fixed(x1)} ${fixed(y1)}`;
|
|
6295
|
+
}
|
|
6296
|
+
return d;
|
|
6297
|
+
}
|
|
6298
|
+
function CartesianChart(props) {
|
|
6299
|
+
const {
|
|
6300
|
+
kind,
|
|
6301
|
+
data,
|
|
6302
|
+
index,
|
|
6303
|
+
series,
|
|
6304
|
+
label,
|
|
6305
|
+
height = 240,
|
|
6306
|
+
formatValue = defaultValue,
|
|
6307
|
+
formatTick = defaultTick,
|
|
6308
|
+
formatIndex = defaultIndex,
|
|
6309
|
+
legend = series.length > 1,
|
|
6310
|
+
className
|
|
6311
|
+
} = props;
|
|
6312
|
+
const stacked = kind === "bar" && Boolean(props.stacked);
|
|
6313
|
+
const area = kind === "line" && Boolean(props.area);
|
|
6314
|
+
const curved = kind === "line" && Boolean(props.curved);
|
|
6315
|
+
const [plotRef, width] = useWidth();
|
|
6316
|
+
const [active, setActive] = useState29(null);
|
|
6317
|
+
const colors = seriesColors(series);
|
|
6318
|
+
const count = data.length;
|
|
6319
|
+
const totals = data.map((row) => series.reduce((sum, entry) => sum + Math.max(0, valueOf(row, entry.key)), 0));
|
|
6320
|
+
const values = data.flatMap((row) => series.map((entry) => valueOf(row, entry.key)));
|
|
6321
|
+
const ticks = niceTicks(Math.min(0, ...values), stacked ? Math.max(0, ...totals) : Math.max(0, ...values));
|
|
6322
|
+
const low = ticks[0];
|
|
6323
|
+
const high = ticks[ticks.length - 1];
|
|
6324
|
+
const tickLabels = ticks.map(formatTick);
|
|
6325
|
+
const margin2 = { top: 8, right: kind === "line" ? 10 : 4, bottom: 26, left: Math.ceil(Math.max(...tickLabels.map(textWidth))) + 12 };
|
|
6326
|
+
const plotWidth = Math.max(0, width - margin2.left - margin2.right);
|
|
6327
|
+
const plotHeight = Math.max(0, height - margin2.top - margin2.bottom);
|
|
6328
|
+
const y = (value) => margin2.top + plotHeight - (value - low) / (high - low || 1) * plotHeight;
|
|
6329
|
+
const band = count ? plotWidth / count : 0;
|
|
6330
|
+
const inset = 6;
|
|
6331
|
+
const step = count > 1 ? (plotWidth - inset * 2) / (count - 1) : 0;
|
|
6332
|
+
const x = (i) => kind === "bar" ? margin2.left + band * (i + 0.5) : count > 1 ? margin2.left + inset + i * step : margin2.left + plotWidth / 2;
|
|
6333
|
+
const indexLabels = data.map((row) => formatIndex(row[index]));
|
|
6334
|
+
const spacing = kind === "bar" ? band : step || plotWidth;
|
|
6335
|
+
const every = Math.max(1, Math.ceil((Math.max(0, ...indexLabels.map(textWidth)) + 14) / (spacing || 1)));
|
|
6336
|
+
const labelled = data.map((_, i) => i).filter((i) => kind === "line" ? (count - 1 - i) % every === 0 : i % every === 0);
|
|
6337
|
+
const pick = (event) => {
|
|
6338
|
+
const left = event.currentTarget.getBoundingClientRect().left - margin2.left;
|
|
6339
|
+
const position = event.clientX - left;
|
|
6340
|
+
const i = kind === "bar" ? Math.floor((position - margin2.left) / (band || 1)) : Math.round((position - margin2.left - inset) / (step || 1));
|
|
6341
|
+
setActive(Math.min(count - 1, Math.max(0, i)));
|
|
6342
|
+
};
|
|
6343
|
+
const onKeyDown = (event) => {
|
|
6344
|
+
if (!count) return;
|
|
6345
|
+
const current = active ?? count - 1;
|
|
6346
|
+
const moves = { ArrowLeft: current - 1, ArrowRight: current + 1, Home: 0, End: count - 1 };
|
|
6347
|
+
if (event.key === "Escape") return setActive(null);
|
|
6348
|
+
if (!(event.key in moves)) return;
|
|
6349
|
+
event.preventDefault();
|
|
6350
|
+
setActive(Math.min(count - 1, Math.max(0, moves[event.key])));
|
|
6351
|
+
};
|
|
6352
|
+
const shown = active === null ? null : Math.min(active, count - 1);
|
|
6353
|
+
const describe = (i) => `${indexLabels[i]}: ${series.map((entry) => `${entry.label} ${formatValue(valueOf(data[i], entry.key))}`).join(", ")}.`;
|
|
6354
|
+
const groupSeries = stacked ? 1 : series.length;
|
|
6355
|
+
const groupWidth = Math.min(band * 0.72, groupSeries * maxBar + (groupSeries - 1) * gap);
|
|
6356
|
+
const barWidth = Math.max(1, (groupWidth - (groupSeries - 1) * gap) / groupSeries);
|
|
6357
|
+
const bars = () => data.map((row, i) => {
|
|
6358
|
+
const start = x(i) - groupWidth / 2;
|
|
6359
|
+
if (stacked) {
|
|
6360
|
+
let base = 0;
|
|
6361
|
+
const parts = series.map((entry, s) => {
|
|
6362
|
+
const value = Math.max(0, valueOf(row, entry.key));
|
|
6363
|
+
const part = { s, from: base, to: base + value };
|
|
6364
|
+
base += value;
|
|
6365
|
+
return part;
|
|
6366
|
+
});
|
|
6367
|
+
const top = [...parts].reverse().find((part) => part.to > part.from)?.s;
|
|
6368
|
+
return parts.map(
|
|
6369
|
+
({ s, from, to }) => to > from ? /* @__PURE__ */ jsx56("path", { d: barPath(start, y(to), barWidth, y(from) - (from > 0 ? gap : 0), s === top), fill: colors[s] }, `${i}-${s}`) : null
|
|
6370
|
+
);
|
|
6371
|
+
}
|
|
6372
|
+
return series.map((entry, s) => {
|
|
6373
|
+
const value = valueOf(row, entry.key);
|
|
6374
|
+
const left = start + s * (barWidth + gap);
|
|
6375
|
+
const d = value >= 0 ? barPath(left, y(value), barWidth, y(0), true) : y(value) > y(0) ? flipped(left, y(0), barWidth, y(value)) : "";
|
|
6376
|
+
return d ? /* @__PURE__ */ jsx56("path", { d, fill: colors[s] }, `${i}-${s}`) : null;
|
|
6377
|
+
});
|
|
6378
|
+
});
|
|
6379
|
+
const lines = () => series.map((entry, s) => {
|
|
6380
|
+
const points = data.map((row, i) => [x(i), y(valueOf(row, entry.key))]);
|
|
6381
|
+
const line = linePath(points, curved);
|
|
6382
|
+
return /* @__PURE__ */ jsxs44("g", { children: [
|
|
6383
|
+
area && points.length ? /* @__PURE__ */ jsx56(
|
|
6384
|
+
"path",
|
|
6385
|
+
{
|
|
6386
|
+
className: "ow-chart__area",
|
|
6387
|
+
d: `${line}L${points[points.length - 1][0].toFixed(1)} ${y(Math.max(low, 0))}L${points[0][0].toFixed(1)} ${y(Math.max(low, 0))}Z`,
|
|
6388
|
+
fill: colors[s]
|
|
6389
|
+
}
|
|
6390
|
+
) : null,
|
|
6391
|
+
/* @__PURE__ */ jsx56("path", { className: "ow-chart__line", d: line, stroke: colors[s] }),
|
|
6392
|
+
count === 1 ? /* @__PURE__ */ jsx56("circle", { className: "ow-chart__point", cx: points[0][0], cy: points[0][1], r: 4, fill: colors[s] }) : null
|
|
6393
|
+
] }, entry.key);
|
|
6394
|
+
});
|
|
6395
|
+
const onRight = shown !== null && x(shown) > width / 2;
|
|
6396
|
+
return /* @__PURE__ */ jsxs44("figure", { className: cx("ow-chart", `ow-chart--${kind}`, className), children: [
|
|
6397
|
+
legend ? /* @__PURE__ */ jsx56(ChartLegend, { items: series.map((entry, s) => ({ label: entry.label, color: colors[s] })), shape: kind === "line" ? "line" : "square" }) : null,
|
|
6398
|
+
/* @__PURE__ */ jsxs44(
|
|
6399
|
+
"div",
|
|
6400
|
+
{
|
|
6401
|
+
ref: plotRef,
|
|
6402
|
+
className: "ow-chart__plot",
|
|
6403
|
+
style: { height },
|
|
6404
|
+
tabIndex: count ? 0 : void 0,
|
|
6405
|
+
role: "group",
|
|
6406
|
+
"aria-label": `${label}. Use the left and right arrow keys to read each point.`,
|
|
6407
|
+
onKeyDown,
|
|
6408
|
+
onFocus: (event) => {
|
|
6409
|
+
if (event.target === event.currentTarget) setActive((current) => current ?? count - 1);
|
|
6410
|
+
},
|
|
6411
|
+
onBlur: () => setActive(null),
|
|
6412
|
+
children: [
|
|
6413
|
+
width > 0 ? /* @__PURE__ */ jsxs44("svg", { width, height, "aria-hidden": "true", className: "ow-chart__svg", children: [
|
|
6414
|
+
ticks.map((tick, t) => /* @__PURE__ */ jsxs44("g", { children: [
|
|
6415
|
+
/* @__PURE__ */ jsx56(
|
|
6416
|
+
"line",
|
|
6417
|
+
{
|
|
6418
|
+
className: tick === 0 ? "ow-chart__baseline" : "ow-chart__grid",
|
|
6419
|
+
x1: margin2.left,
|
|
6420
|
+
x2: width - margin2.right,
|
|
6421
|
+
y1: Math.round(y(tick)) + 0.5,
|
|
6422
|
+
y2: Math.round(y(tick)) + 0.5
|
|
6423
|
+
}
|
|
6424
|
+
),
|
|
6425
|
+
/* @__PURE__ */ jsx56("text", { className: "ow-chart__tick", x: margin2.left - 10, y: y(tick), dy: "0.32em", textAnchor: "end", children: tickLabels[t] })
|
|
6426
|
+
] }, tick)),
|
|
6427
|
+
labelled.map((i) => /* @__PURE__ */ jsx56(
|
|
6428
|
+
"text",
|
|
6429
|
+
{
|
|
6430
|
+
className: "ow-chart__tick",
|
|
6431
|
+
x: x(i),
|
|
6432
|
+
y: height - 6,
|
|
6433
|
+
textAnchor: kind === "line" && count > 1 && i === 0 ? "start" : kind === "line" && count > 1 && i === count - 1 ? "end" : "middle",
|
|
6434
|
+
children: indexLabels[i]
|
|
6435
|
+
},
|
|
6436
|
+
i
|
|
6437
|
+
)),
|
|
6438
|
+
kind === "bar" && shown !== null ? /* @__PURE__ */ jsx56("rect", { className: "ow-chart__band", x: x(shown) - band / 2, y: margin2.top, width: band, height: plotHeight, rx: 6 }) : null,
|
|
6439
|
+
kind === "bar" ? bars() : lines(),
|
|
6440
|
+
kind === "line" && shown !== null ? /* @__PURE__ */ jsxs44(Fragment10, { children: [
|
|
6441
|
+
/* @__PURE__ */ jsx56("line", { className: "ow-chart__crosshair", x1: x(shown), x2: x(shown), y1: margin2.top, y2: margin2.top + plotHeight }),
|
|
6442
|
+
series.map((entry, s) => /* @__PURE__ */ jsx56(
|
|
6443
|
+
"circle",
|
|
6444
|
+
{
|
|
6445
|
+
className: "ow-chart__point",
|
|
6446
|
+
cx: x(shown),
|
|
6447
|
+
cy: y(valueOf(data[shown], entry.key)),
|
|
6448
|
+
r: 4,
|
|
6449
|
+
fill: colors[s]
|
|
6450
|
+
},
|
|
6451
|
+
entry.key
|
|
6452
|
+
))
|
|
6453
|
+
] }) : null,
|
|
6454
|
+
/* @__PURE__ */ jsx56(
|
|
6455
|
+
"rect",
|
|
6456
|
+
{
|
|
6457
|
+
className: "ow-chart__hit",
|
|
6458
|
+
x: margin2.left,
|
|
6459
|
+
y: margin2.top,
|
|
6460
|
+
width: plotWidth,
|
|
6461
|
+
height: plotHeight,
|
|
6462
|
+
onPointerMove: pick,
|
|
6463
|
+
onPointerDown: pick,
|
|
6464
|
+
onPointerLeave: () => setActive(null)
|
|
6465
|
+
}
|
|
6466
|
+
)
|
|
6467
|
+
] }) : null,
|
|
6468
|
+
shown !== null && width > 0 ? /* @__PURE__ */ jsxs44("div", { className: "ow-chart__readout", style: onRight ? { right: width - x(shown) + 12 } : { left: x(shown) + 12 }, "aria-hidden": "true", children: [
|
|
6469
|
+
/* @__PURE__ */ jsx56("span", { className: "ow-chart__readout-title", children: indexLabels[shown] }),
|
|
6470
|
+
series.map((entry, s) => /* @__PURE__ */ jsxs44("span", { className: "ow-chart__readout-row", children: [
|
|
6471
|
+
/* @__PURE__ */ jsx56("span", { className: `ow-chart__key ow-chart__key--${kind === "line" ? "line" : "square"}`, style: { background: colors[s] } }),
|
|
6472
|
+
/* @__PURE__ */ jsx56("span", { className: "ow-chart__readout-label", children: entry.label }),
|
|
6473
|
+
/* @__PURE__ */ jsx56("strong", { children: formatValue(valueOf(data[shown], entry.key)) })
|
|
6474
|
+
] }, entry.key))
|
|
6475
|
+
] }) : null,
|
|
6476
|
+
/* @__PURE__ */ jsx56("span", { className: "ow-visually-hidden", "aria-live": "polite", children: shown !== null ? describe(shown) : "" })
|
|
6477
|
+
]
|
|
6478
|
+
}
|
|
6479
|
+
),
|
|
6480
|
+
/* @__PURE__ */ jsx56(
|
|
6481
|
+
ChartTable,
|
|
6482
|
+
{
|
|
6483
|
+
caption: label,
|
|
6484
|
+
head: ["", ...series.map((entry) => entry.label)],
|
|
6485
|
+
rows: data.map((row, i) => [indexLabels[i], ...series.map((entry) => formatValue(valueOf(row, entry.key)))])
|
|
6486
|
+
}
|
|
6487
|
+
)
|
|
5975
6488
|
] });
|
|
5976
6489
|
}
|
|
6490
|
+
function flipped(x, top, width, bottom) {
|
|
6491
|
+
const height = bottom - top;
|
|
6492
|
+
const r = Math.min(radius, width / 2, height);
|
|
6493
|
+
return `M${x} ${top}V${bottom - r}Q${x} ${bottom} ${x + r} ${bottom}H${x + width - r}Q${x + width} ${bottom} ${x + width} ${bottom - r}V${top}Z`;
|
|
6494
|
+
}
|
|
6495
|
+
|
|
6496
|
+
// src/components/Chart/LineChart.tsx
|
|
6497
|
+
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
6498
|
+
function LineChart(props) {
|
|
6499
|
+
return /* @__PURE__ */ jsx57(CartesianChart, { kind: "line", ...props });
|
|
6500
|
+
}
|
|
6501
|
+
|
|
6502
|
+
// src/components/Chart/BarChart.tsx
|
|
6503
|
+
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
6504
|
+
function BarChart(props) {
|
|
6505
|
+
return /* @__PURE__ */ jsx58(CartesianChart, { kind: "bar", ...props });
|
|
6506
|
+
}
|
|
6507
|
+
|
|
6508
|
+
// src/components/Chart/DonutChart.tsx
|
|
6509
|
+
import { useState as useState30 } from "react";
|
|
6510
|
+
import { jsx as jsx59, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
6511
|
+
var percent = new Intl.NumberFormat(void 0, { style: "percent", maximumFractionDigits: 1 });
|
|
6512
|
+
function slicePath(cx2, cy, outer, inner, start, end) {
|
|
6513
|
+
const point = (r, a) => `${(cx2 + r * Math.sin(a)).toFixed(2)} ${(cy - r * Math.cos(a)).toFixed(2)}`;
|
|
6514
|
+
const large = end - start > Math.PI ? 1 : 0;
|
|
6515
|
+
return `M${point(outer, start)}A${outer} ${outer} 0 ${large} 1 ${point(outer, end)}L${point(inner, end)}A${inner} ${inner} 0 ${large} 0 ${point(inner, start)}Z`;
|
|
6516
|
+
}
|
|
6517
|
+
function DonutChart({ data, label, formatValue = defaultValue, center, centerLabel = "Total", size: size2 = 180, legend = true, className }) {
|
|
6518
|
+
const [active, setActive] = useState30(null);
|
|
6519
|
+
const slices = data.map((slice, i) => ({ ...slice, value: Math.max(0, slice.value), fill: colorOf(slice.color, i) }));
|
|
6520
|
+
const total = slices.reduce((sum, slice) => sum + slice.value, 0);
|
|
6521
|
+
const share = (value) => percent.format(total ? value / total : 0);
|
|
6522
|
+
const outer = size2 / 2;
|
|
6523
|
+
const inner = outer - Math.max(14, Math.round(size2 * 0.13));
|
|
6524
|
+
const pad4 = (radius2) => slices.filter((slice) => slice.value > 0).length > 1 ? 1 / radius2 : 0;
|
|
6525
|
+
let angle = 0;
|
|
6526
|
+
const arcs = slices.map((slice) => {
|
|
6527
|
+
const start = angle;
|
|
6528
|
+
angle += total ? slice.value / total * Math.PI * 2 : 0;
|
|
6529
|
+
return { start, end: angle };
|
|
6530
|
+
});
|
|
6531
|
+
const onKeyDown = (event) => {
|
|
6532
|
+
if (!slices.length) return;
|
|
6533
|
+
const current = active ?? 0;
|
|
6534
|
+
const moves = {
|
|
6535
|
+
ArrowRight: (current + 1) % slices.length,
|
|
6536
|
+
ArrowDown: (current + 1) % slices.length,
|
|
6537
|
+
ArrowLeft: (current - 1 + slices.length) % slices.length,
|
|
6538
|
+
ArrowUp: (current - 1 + slices.length) % slices.length,
|
|
6539
|
+
Home: 0,
|
|
6540
|
+
End: slices.length - 1
|
|
6541
|
+
};
|
|
6542
|
+
if (event.key === "Escape") return setActive(null);
|
|
6543
|
+
if (!(event.key in moves)) return;
|
|
6544
|
+
event.preventDefault();
|
|
6545
|
+
setActive(moves[event.key]);
|
|
6546
|
+
};
|
|
6547
|
+
const shown = active === null ? null : slices[active];
|
|
6548
|
+
return /* @__PURE__ */ jsxs45("figure", { className: cx("ow-chart", "ow-chart--donut", className), children: [
|
|
6549
|
+
/* @__PURE__ */ jsxs45(
|
|
6550
|
+
"div",
|
|
6551
|
+
{
|
|
6552
|
+
className: "ow-chart__donut",
|
|
6553
|
+
style: { width: size2, height: size2 },
|
|
6554
|
+
tabIndex: slices.length ? 0 : void 0,
|
|
6555
|
+
role: "group",
|
|
6556
|
+
"aria-label": `${label}. Use the arrow keys to read each part.`,
|
|
6557
|
+
onKeyDown,
|
|
6558
|
+
onFocus: () => setActive((current) => current ?? 0),
|
|
6559
|
+
onBlur: () => setActive(null),
|
|
6560
|
+
onPointerLeave: () => setActive(null),
|
|
6561
|
+
children: [
|
|
6562
|
+
/* @__PURE__ */ jsxs45("svg", { width: size2, height: size2, viewBox: `0 0 ${size2} ${size2}`, "aria-hidden": "true", children: [
|
|
6563
|
+
total === 0 ? /* @__PURE__ */ jsx59("circle", { className: "ow-chart__empty", cx: outer, cy: outer, r: (outer + inner) / 2, strokeWidth: outer - inner }) : null,
|
|
6564
|
+
slices.map((slice, i) => {
|
|
6565
|
+
const { start, end } = arcs[i];
|
|
6566
|
+
if (end - start <= 0) return null;
|
|
6567
|
+
const whole = end - start >= Math.PI * 2 - 1e-6;
|
|
6568
|
+
const d = whole ? `${slicePath(outer, outer, outer, inner, 0, Math.PI)}${slicePath(outer, outer, outer, inner, Math.PI, Math.PI * 2)}` : innerPadded(outer, inner, start, end, pad4(outer), pad4(inner));
|
|
6569
|
+
return /* @__PURE__ */ jsx59(
|
|
6570
|
+
"path",
|
|
6571
|
+
{
|
|
6572
|
+
d,
|
|
6573
|
+
fill: slice.fill,
|
|
6574
|
+
className: cx("ow-chart__slice", active !== null && active !== i && "ow-chart__slice--dim"),
|
|
6575
|
+
onPointerEnter: () => setActive(i)
|
|
6576
|
+
},
|
|
6577
|
+
i
|
|
6578
|
+
);
|
|
6579
|
+
})
|
|
6580
|
+
] }),
|
|
6581
|
+
/* @__PURE__ */ jsxs45("div", { className: "ow-chart__center", "aria-hidden": "true", children: [
|
|
6582
|
+
/* @__PURE__ */ jsx59("strong", { className: "ow-chart__center-value", children: shown ? formatValue(shown.value) : center ?? formatValue(total) }),
|
|
6583
|
+
/* @__PURE__ */ jsx59("span", { className: "ow-chart__center-label", children: shown ? `${shown.label} \xB7 ${share(shown.value)}` : centerLabel })
|
|
6584
|
+
] }),
|
|
6585
|
+
/* @__PURE__ */ jsx59("span", { className: "ow-visually-hidden", "aria-live": "polite", children: shown ? `${shown.label}: ${formatValue(shown.value)}, ${share(shown.value)}.` : "" })
|
|
6586
|
+
]
|
|
6587
|
+
}
|
|
6588
|
+
),
|
|
6589
|
+
legend ? /* @__PURE__ */ jsx59(
|
|
6590
|
+
ChartLegend,
|
|
6591
|
+
{
|
|
6592
|
+
shape: "square",
|
|
6593
|
+
items: slices.map((slice) => ({ label: slice.label, color: slice.fill, value: `${formatValue(slice.value)} \xB7 ${share(slice.value)}` }))
|
|
6594
|
+
}
|
|
6595
|
+
) : null,
|
|
6596
|
+
/* @__PURE__ */ jsx59(
|
|
6597
|
+
ChartTable,
|
|
6598
|
+
{
|
|
6599
|
+
caption: label,
|
|
6600
|
+
head: ["", "Value", "Share"],
|
|
6601
|
+
rows: slices.map((slice) => [slice.label, formatValue(slice.value), share(slice.value)])
|
|
6602
|
+
}
|
|
6603
|
+
)
|
|
6604
|
+
] });
|
|
6605
|
+
}
|
|
6606
|
+
function innerPadded(outer, inner, start, end, padOuter, padInner) {
|
|
6607
|
+
const c = outer;
|
|
6608
|
+
const point = (r, a) => `${(c + r * Math.sin(a)).toFixed(2)} ${(c - r * Math.cos(a)).toFixed(2)}`;
|
|
6609
|
+
const os = start + padOuter;
|
|
6610
|
+
const oe = Math.max(os, end - padOuter);
|
|
6611
|
+
const is = start + padInner;
|
|
6612
|
+
const ie = Math.max(is, end - padInner);
|
|
6613
|
+
const largeOuter = oe - os > Math.PI ? 1 : 0;
|
|
6614
|
+
const largeInner = ie - is > Math.PI ? 1 : 0;
|
|
6615
|
+
return `M${point(outer, os)}A${outer} ${outer} 0 ${largeOuter} 1 ${point(outer, oe)}L${point(inner, ie)}A${inner} ${inner} 0 ${largeInner} 0 ${point(inner, is)}Z`;
|
|
6616
|
+
}
|
|
6617
|
+
|
|
6618
|
+
// src/components/Chart/Sparkline.tsx
|
|
6619
|
+
import { Fragment as Fragment11, jsx as jsx60, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
6620
|
+
function Sparkline2({ data, "aria-label": ariaLabel, color = 1, area = true, width = 120, height = 32, className }) {
|
|
6621
|
+
const min = Math.min(...data);
|
|
6622
|
+
const max = Math.max(...data);
|
|
6623
|
+
const pad4 = 3;
|
|
6624
|
+
const y = (value) => pad4 + (1 - (value - min) / (max - min || 1)) * (height - pad4 * 2) - (max === min ? (height - pad4 * 2) / 2 : 0);
|
|
6625
|
+
const x = (i) => data.length > 1 ? i / (data.length - 1) * 100 : 50;
|
|
6626
|
+
const line = data.map((value, i) => `${i ? "L" : "M"}${x(i).toFixed(2)} ${y(value).toFixed(2)}`).join("");
|
|
6627
|
+
const last = data.length - 1;
|
|
6628
|
+
return /* @__PURE__ */ jsx60(
|
|
6629
|
+
"span",
|
|
6630
|
+
{
|
|
6631
|
+
role: "img",
|
|
6632
|
+
"aria-label": ariaLabel,
|
|
6633
|
+
className: cx("ow-sparkline", className),
|
|
6634
|
+
style: { width, height, "--ow-sparkline-color": colorOf(color, 0) },
|
|
6635
|
+
children: data.length ? /* @__PURE__ */ jsxs46(Fragment11, { children: [
|
|
6636
|
+
/* @__PURE__ */ jsxs46("svg", { viewBox: `0 0 100 ${height}`, preserveAspectRatio: "none", "aria-hidden": "true", children: [
|
|
6637
|
+
area ? /* @__PURE__ */ jsx60("path", { className: "ow-sparkline__area", d: `${line}L100 ${height}L0 ${height}Z` }) : null,
|
|
6638
|
+
/* @__PURE__ */ jsx60("path", { className: "ow-sparkline__line", d: line, vectorEffect: "non-scaling-stroke" })
|
|
6639
|
+
] }),
|
|
6640
|
+
/* @__PURE__ */ jsx60("span", { className: "ow-sparkline__end", style: { left: `${x(last)}%`, top: y(data[last]) }, "aria-hidden": "true" })
|
|
6641
|
+
] }) : null
|
|
6642
|
+
}
|
|
6643
|
+
);
|
|
6644
|
+
}
|
|
5977
6645
|
|
|
5978
6646
|
// src/components/FileTree/FileTree.tsx
|
|
5979
|
-
import { useMemo as
|
|
5980
|
-
import { jsx as
|
|
6647
|
+
import { useMemo as useMemo12, useRef as useRef33, useState as useState31 } from "react";
|
|
6648
|
+
import { jsx as jsx61, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
5981
6649
|
function flatten(nodes, expanded, parent, level = 1) {
|
|
5982
6650
|
return nodes.flatMap((node) => {
|
|
5983
6651
|
const path = parent ? `${parent}/${node.name}` : node.name;
|
|
@@ -6002,10 +6670,10 @@ function FileTree({
|
|
|
6002
6670
|
className
|
|
6003
6671
|
}) {
|
|
6004
6672
|
const [current, setCurrent] = useControllableState(selected, defaultSelected, onSelect);
|
|
6005
|
-
const [expanded, setExpanded] =
|
|
6006
|
-
const rows =
|
|
6007
|
-
const [focusPath, setFocusPath] =
|
|
6008
|
-
const refs =
|
|
6673
|
+
const [expanded, setExpanded] = useState31(() => new Set(defaultExpanded === "all" ? allFolders(items2) : defaultExpanded));
|
|
6674
|
+
const rows = useMemo12(() => flatten(items2, expanded), [items2, expanded]);
|
|
6675
|
+
const [focusPath, setFocusPath] = useState31();
|
|
6676
|
+
const refs = useRef33(/* @__PURE__ */ new Map());
|
|
6009
6677
|
const tabStop = rows.some((row) => row.path === focusPath) ? focusPath : (rows.find((row) => row.path === current) ?? rows[0])?.path;
|
|
6010
6678
|
function focus(path) {
|
|
6011
6679
|
if (!path) return;
|
|
@@ -6055,8 +6723,8 @@ function FileTree({
|
|
|
6055
6723
|
const row = rows.find((entry) => entry.path === path);
|
|
6056
6724
|
if (!row) return null;
|
|
6057
6725
|
const isOpen = row.isFolder && expanded.has(path);
|
|
6058
|
-
const icon2 = node.icon ?? (row.isFolder ? isOpen ? /* @__PURE__ */
|
|
6059
|
-
return /* @__PURE__ */
|
|
6726
|
+
const icon2 = node.icon ?? (row.isFolder ? isOpen ? /* @__PURE__ */ jsx61(FolderOpenIcon, { size: 16 }) : /* @__PURE__ */ jsx61(FolderIcon, { size: 16 }) : /* @__PURE__ */ jsx61(FileIcon, { size: 16 }));
|
|
6727
|
+
return /* @__PURE__ */ jsxs47(
|
|
6060
6728
|
"li",
|
|
6061
6729
|
{
|
|
6062
6730
|
ref: (element) => {
|
|
@@ -6074,7 +6742,7 @@ function FileTree({
|
|
|
6074
6742
|
if (event.target === event.currentTarget) setFocusPath(path);
|
|
6075
6743
|
},
|
|
6076
6744
|
children: [
|
|
6077
|
-
/* @__PURE__ */
|
|
6745
|
+
/* @__PURE__ */ jsxs47(
|
|
6078
6746
|
"div",
|
|
6079
6747
|
{
|
|
6080
6748
|
className: cx("ow-tree__row", !row.isFolder && current === path && "ow-tree__row--selected"),
|
|
@@ -6084,51 +6752,51 @@ function FileTree({
|
|
|
6084
6752
|
activate(row);
|
|
6085
6753
|
},
|
|
6086
6754
|
children: [
|
|
6087
|
-
row.isFolder ? /* @__PURE__ */
|
|
6088
|
-
/* @__PURE__ */
|
|
6089
|
-
/* @__PURE__ */
|
|
6090
|
-
node.meta ? /* @__PURE__ */
|
|
6755
|
+
row.isFolder ? /* @__PURE__ */ jsx61(ChevronRightIcon, { size: 14, className: cx("ow-tree__chevron", isOpen && "ow-tree__chevron--open") }) : /* @__PURE__ */ jsx61("span", { className: "ow-tree__spacer" }),
|
|
6756
|
+
/* @__PURE__ */ jsx61("span", { className: cx("ow-tree__icon", row.isFolder && "ow-tree__icon--folder"), children: icon2 }),
|
|
6757
|
+
/* @__PURE__ */ jsx61("span", { className: "ow-tree__name", children: node.name }),
|
|
6758
|
+
node.meta ? /* @__PURE__ */ jsx61("span", { className: "ow-tree__meta", children: node.meta }) : null
|
|
6091
6759
|
]
|
|
6092
6760
|
}
|
|
6093
6761
|
),
|
|
6094
|
-
isOpen && node.children.length > 0 ? /* @__PURE__ */
|
|
6762
|
+
isOpen && node.children.length > 0 ? /* @__PURE__ */ jsx61("ul", { role: "group", className: "ow-tree__group", children: render(node.children, path, level + 1) }) : null
|
|
6095
6763
|
]
|
|
6096
6764
|
},
|
|
6097
6765
|
path
|
|
6098
6766
|
);
|
|
6099
6767
|
});
|
|
6100
6768
|
}
|
|
6101
|
-
return /* @__PURE__ */
|
|
6769
|
+
return /* @__PURE__ */ jsx61("ul", { role: "tree", "aria-label": label, className: cx("ow-tree", className), children: render(items2) });
|
|
6102
6770
|
}
|
|
6103
6771
|
|
|
6104
6772
|
// src/components/EmptyState/EmptyState.tsx
|
|
6105
|
-
import { jsx as
|
|
6773
|
+
import { jsx as jsx62, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
6106
6774
|
function EmptyState({ title, description, icon: icon2, actions, bordered = false, className }) {
|
|
6107
|
-
return /* @__PURE__ */
|
|
6108
|
-
/* @__PURE__ */
|
|
6109
|
-
/* @__PURE__ */
|
|
6110
|
-
/* @__PURE__ */
|
|
6111
|
-
description ? /* @__PURE__ */
|
|
6775
|
+
return /* @__PURE__ */ jsxs48("div", { className: cx("ow-empty", bordered && "ow-empty--bordered", className), children: [
|
|
6776
|
+
/* @__PURE__ */ jsx62("span", { className: "ow-empty__icon", "aria-hidden": "true", children: icon2 ?? /* @__PURE__ */ jsx62(InboxIcon, { size: 20 }) }),
|
|
6777
|
+
/* @__PURE__ */ jsxs48("div", { className: "ow-empty__text", children: [
|
|
6778
|
+
/* @__PURE__ */ jsx62("p", { className: "ow-empty__title", children: title }),
|
|
6779
|
+
description ? /* @__PURE__ */ jsx62("p", { className: "ow-empty__description", children: description }) : null
|
|
6112
6780
|
] }),
|
|
6113
|
-
actions ? /* @__PURE__ */
|
|
6781
|
+
actions ? /* @__PURE__ */ jsx62("div", { className: "ow-empty__actions", children: actions }) : null
|
|
6114
6782
|
] });
|
|
6115
6783
|
}
|
|
6116
6784
|
|
|
6117
6785
|
// src/components/Tag/Tag.tsx
|
|
6118
|
-
import { jsx as
|
|
6786
|
+
import { jsx as jsx63, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
6119
6787
|
function Tag({ onRemove, variant = "neutral", size: size2 = "md", icon: icon2, removeLabel, className, children, ...props }) {
|
|
6120
6788
|
const name = removeLabel ?? (typeof children === "string" ? children : "tag");
|
|
6121
|
-
return /* @__PURE__ */
|
|
6122
|
-
icon2 ? /* @__PURE__ */
|
|
6123
|
-
/* @__PURE__ */
|
|
6124
|
-
onRemove ? /* @__PURE__ */
|
|
6789
|
+
return /* @__PURE__ */ jsxs49("span", { className: cx("ow-tag", `ow-tag--${variant}`, `ow-tag--${size2}`, onRemove && "ow-tag--removable", className), ...props, children: [
|
|
6790
|
+
icon2 ? /* @__PURE__ */ jsx63("span", { className: "ow-tag__icon", children: icon2 }) : null,
|
|
6791
|
+
/* @__PURE__ */ jsx63("span", { className: "ow-tag__label", children }),
|
|
6792
|
+
onRemove ? /* @__PURE__ */ jsx63("button", { type: "button", className: "ow-tag__remove", "aria-label": `Remove ${name}`, onClick: onRemove, children: /* @__PURE__ */ jsx63(XIcon, { size: 12 }) }) : null
|
|
6125
6793
|
] });
|
|
6126
6794
|
}
|
|
6127
6795
|
function TagGroup({ label, className, children, ...props }) {
|
|
6128
|
-
return /* @__PURE__ */
|
|
6796
|
+
return /* @__PURE__ */ jsx63("div", { role: "group", "aria-label": label, className: cx("ow-tag-group", className), ...props, children });
|
|
6129
6797
|
}
|
|
6130
6798
|
function ColorSwatch({ color, name, value, size: size2 = "md", shape = "square", className }) {
|
|
6131
|
-
const swatch = /* @__PURE__ */
|
|
6799
|
+
const swatch = /* @__PURE__ */ jsx63(
|
|
6132
6800
|
"span",
|
|
6133
6801
|
{
|
|
6134
6802
|
className: cx("ow-swatch", `ow-swatch--${size2}`, shape === "circle" && "ow-swatch--circle"),
|
|
@@ -6136,19 +6804,19 @@ function ColorSwatch({ color, name, value, size: size2 = "md", shape = "square",
|
|
|
6136
6804
|
...name && !value ? { role: "img", "aria-label": name } : { "aria-hidden": true }
|
|
6137
6805
|
}
|
|
6138
6806
|
);
|
|
6139
|
-
if (!name && !value) return /* @__PURE__ */
|
|
6140
|
-
return /* @__PURE__ */
|
|
6807
|
+
if (!name && !value) return /* @__PURE__ */ jsx63("span", { className, children: swatch });
|
|
6808
|
+
return /* @__PURE__ */ jsxs49("span", { className: cx("ow-swatch-label", className), children: [
|
|
6141
6809
|
swatch,
|
|
6142
|
-
/* @__PURE__ */
|
|
6143
|
-
name ? /* @__PURE__ */
|
|
6144
|
-
/* @__PURE__ */
|
|
6810
|
+
/* @__PURE__ */ jsxs49("span", { className: "ow-swatch-label__text", children: [
|
|
6811
|
+
name ? /* @__PURE__ */ jsx63("span", { className: "ow-swatch-label__name", children: name }) : null,
|
|
6812
|
+
/* @__PURE__ */ jsx63("span", { className: "ow-swatch-label__value", children: value })
|
|
6145
6813
|
] })
|
|
6146
6814
|
] });
|
|
6147
6815
|
}
|
|
6148
6816
|
|
|
6149
6817
|
// src/components/Avatar/Avatar.tsx
|
|
6150
|
-
import { useState as
|
|
6151
|
-
import { jsx as
|
|
6818
|
+
import { useState as useState32 } from "react";
|
|
6819
|
+
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
6152
6820
|
var namedSizes = { sm: 24, md: 28, lg: 36, xl: 48 };
|
|
6153
6821
|
function avatarSize(size2) {
|
|
6154
6822
|
if (typeof size2 === "number") {
|
|
@@ -6158,37 +6826,37 @@ function avatarSize(size2) {
|
|
|
6158
6826
|
}
|
|
6159
6827
|
function Avatar({ name, src, size: size2 = "md", label, className }) {
|
|
6160
6828
|
const initials = getInitials(name);
|
|
6161
|
-
const [failedImage, setFailedImage] =
|
|
6829
|
+
const [failedImage, setFailedImage] = useState32();
|
|
6162
6830
|
const showImage = src && src !== failedImage;
|
|
6163
6831
|
const sizing = avatarSize(size2);
|
|
6164
|
-
return /* @__PURE__ */
|
|
6832
|
+
return /* @__PURE__ */ jsx64(
|
|
6165
6833
|
"span",
|
|
6166
6834
|
{
|
|
6167
6835
|
className: cx("ow-avatar", sizing.className, !initials && !showImage && "ow-avatar--empty", className),
|
|
6168
6836
|
style: sizing.style,
|
|
6169
6837
|
...label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
|
|
6170
6838
|
"data-initials": !showImage && initials ? initials : void 0,
|
|
6171
|
-
children: showImage ? /* @__PURE__ */
|
|
6839
|
+
children: showImage ? /* @__PURE__ */ jsx64("img", { src, alt: "", className: "ow-avatar__image", onError: () => setFailedImage(src) }) : initials ? null : /* @__PURE__ */ jsx64(UserIcon, { size: Math.round(sizing.pixels * 0.52) })
|
|
6172
6840
|
}
|
|
6173
6841
|
);
|
|
6174
6842
|
}
|
|
6175
6843
|
|
|
6176
6844
|
// src/components/Avatar/AvatarGroup.tsx
|
|
6177
6845
|
import { Children, cloneElement as cloneElement4, isValidElement as isValidElement4 } from "react";
|
|
6178
|
-
import { jsx as
|
|
6846
|
+
import { jsx as jsx65, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
6179
6847
|
function AvatarGroup({ children, max = 4, size: size2 = "md", label, className }) {
|
|
6180
6848
|
const avatars = Children.toArray(children).filter(isValidElement4);
|
|
6181
6849
|
const sizing = avatarSize(size2);
|
|
6182
6850
|
const shown = avatars.slice(0, max);
|
|
6183
6851
|
const hidden = avatars.length - shown.length;
|
|
6184
|
-
return /* @__PURE__ */
|
|
6852
|
+
return /* @__PURE__ */ jsxs50("div", { role: "group", "aria-label": label, className: cx("ow-avatar-group", className), children: [
|
|
6185
6853
|
shown.map((avatar) => cloneElement4(avatar, { size: size2 })),
|
|
6186
|
-
hidden > 0 ? /* @__PURE__ */
|
|
6187
|
-
/* @__PURE__ */
|
|
6854
|
+
hidden > 0 ? /* @__PURE__ */ jsxs50("span", { className: cx("ow-avatar", sizing.className, "ow-avatar--count"), style: sizing.style, children: [
|
|
6855
|
+
/* @__PURE__ */ jsxs50("span", { "aria-hidden": "true", children: [
|
|
6188
6856
|
"+",
|
|
6189
6857
|
hidden
|
|
6190
6858
|
] }),
|
|
6191
|
-
/* @__PURE__ */
|
|
6859
|
+
/* @__PURE__ */ jsxs50("span", { className: "ow-visually-hidden", children: [
|
|
6192
6860
|
"and ",
|
|
6193
6861
|
hidden,
|
|
6194
6862
|
" more"
|
|
@@ -6201,164 +6869,56 @@ function userSize(size2) {
|
|
|
6201
6869
|
return size2 >= 48 ? "ow-user--xl" : size2 >= 36 ? "ow-user--lg" : size2 >= 28 ? "ow-user--md" : "ow-user--sm";
|
|
6202
6870
|
}
|
|
6203
6871
|
function User({ name, description, src, size: size2 = "md", className }) {
|
|
6204
|
-
return /* @__PURE__ */
|
|
6205
|
-
/* @__PURE__ */
|
|
6206
|
-
/* @__PURE__ */
|
|
6207
|
-
/* @__PURE__ */
|
|
6208
|
-
description ? /* @__PURE__ */
|
|
6872
|
+
return /* @__PURE__ */ jsxs50("div", { className: cx("ow-user", userSize(size2), className), children: [
|
|
6873
|
+
/* @__PURE__ */ jsx65(Avatar, { name, src, size: size2 }),
|
|
6874
|
+
/* @__PURE__ */ jsxs50("div", { className: "ow-user__text", children: [
|
|
6875
|
+
/* @__PURE__ */ jsx65("span", { className: "ow-user__name", children: name }),
|
|
6876
|
+
description ? /* @__PURE__ */ jsx65("span", { className: "ow-user__description", children: description }) : null
|
|
6209
6877
|
] })
|
|
6210
6878
|
] });
|
|
6211
6879
|
}
|
|
6212
6880
|
|
|
6213
6881
|
// src/components/Kbd/Kbd.tsx
|
|
6214
|
-
import { jsx as
|
|
6882
|
+
import { jsx as jsx66 } from "react/jsx-runtime";
|
|
6215
6883
|
function Kbd({ className, ...props }) {
|
|
6216
|
-
return /* @__PURE__ */
|
|
6884
|
+
return /* @__PURE__ */ jsx66("kbd", { className: cx("ow-kbd", className), ...props });
|
|
6217
6885
|
}
|
|
6218
6886
|
function Code({ className, ...props }) {
|
|
6219
|
-
return /* @__PURE__ */
|
|
6887
|
+
return /* @__PURE__ */ jsx66("code", { className: cx("ow-code", className), ...props });
|
|
6220
6888
|
}
|
|
6221
6889
|
|
|
6222
6890
|
// src/components/Card/Card.tsx
|
|
6223
|
-
import { jsx as
|
|
6891
|
+
import { jsx as jsx67, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
6224
6892
|
function Card({ className, padding = "md", ...props }) {
|
|
6225
|
-
return /* @__PURE__ */
|
|
6893
|
+
return /* @__PURE__ */ jsx67("div", { className: cx("ow-card", `ow-card--pad-${padding}`, className), ...props });
|
|
6226
6894
|
}
|
|
6227
6895
|
function SettingsRow({ children, description, label, className }) {
|
|
6228
|
-
return /* @__PURE__ */
|
|
6229
|
-
/* @__PURE__ */
|
|
6230
|
-
/* @__PURE__ */
|
|
6231
|
-
description ? /* @__PURE__ */
|
|
6896
|
+
return /* @__PURE__ */ jsxs51("div", { className: cx("ow-settings-row", className), children: [
|
|
6897
|
+
/* @__PURE__ */ jsxs51("div", { className: "ow-settings-row__text", children: [
|
|
6898
|
+
/* @__PURE__ */ jsx67("span", { className: "ow-settings-row__label", children: label }),
|
|
6899
|
+
description ? /* @__PURE__ */ jsx67("div", { className: "ow-settings-row__description", children: description }) : null
|
|
6232
6900
|
] }),
|
|
6233
|
-
/* @__PURE__ */
|
|
6901
|
+
/* @__PURE__ */ jsx67("div", { className: "ow-settings-row__control", children })
|
|
6234
6902
|
] });
|
|
6235
6903
|
}
|
|
6236
6904
|
|
|
6237
|
-
// src/components/Layout/Layout.tsx
|
|
6238
|
-
import {
|
|
6239
|
-
useEffect as useEffect25,
|
|
6240
|
-
useRef as useRef32,
|
|
6241
|
-
useState as useState28
|
|
6242
|
-
} from "react";
|
|
6243
|
-
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
6244
|
-
var space = (token) => token === "none" ? "0" : `var(--ow-space-${token})`;
|
|
6245
|
-
var alignments = { start: "flex-start", center: "center", end: "flex-end", stretch: "stretch", baseline: "baseline", between: "space-between" };
|
|
6246
|
-
function Stack({
|
|
6247
|
-
direction = "column",
|
|
6248
|
-
gap = "md",
|
|
6249
|
-
align,
|
|
6250
|
-
justify,
|
|
6251
|
-
wrap = false,
|
|
6252
|
-
as = "div",
|
|
6253
|
-
className,
|
|
6254
|
-
style,
|
|
6255
|
-
children,
|
|
6256
|
-
...props
|
|
6257
|
-
}) {
|
|
6258
|
-
const Element2 = as;
|
|
6259
|
-
return /* @__PURE__ */ jsx60(
|
|
6260
|
-
Element2,
|
|
6261
|
-
{
|
|
6262
|
-
className: cx("ow-stack", className),
|
|
6263
|
-
style: {
|
|
6264
|
-
flexDirection: direction,
|
|
6265
|
-
gap: space(gap),
|
|
6266
|
-
alignItems: align ? alignments[align] : void 0,
|
|
6267
|
-
justifyContent: justify ? alignments[justify] : void 0,
|
|
6268
|
-
flexWrap: wrap ? "wrap" : void 0,
|
|
6269
|
-
...style
|
|
6270
|
-
},
|
|
6271
|
-
...props,
|
|
6272
|
-
children
|
|
6273
|
-
}
|
|
6274
|
-
);
|
|
6275
|
-
}
|
|
6276
|
-
function Separator({ orientation = "horizontal", label, spacing = "none", className }) {
|
|
6277
|
-
const margin2 = orientation === "horizontal" ? `${space(spacing)} 0` : `0 ${space(spacing)}`;
|
|
6278
|
-
if (label && orientation === "horizontal") {
|
|
6279
|
-
return /* @__PURE__ */ jsx60("div", { role: "separator", className: cx("ow-separator-label", className), style: { margin: margin2 }, children: /* @__PURE__ */ jsx60("span", { className: "ow-separator-label__text", children: label }) });
|
|
6280
|
-
}
|
|
6281
|
-
return /* @__PURE__ */ jsx60(
|
|
6282
|
-
"div",
|
|
6283
|
-
{
|
|
6284
|
-
role: "separator",
|
|
6285
|
-
"aria-orientation": orientation,
|
|
6286
|
-
className: cx("ow-separator", `ow-separator--${orientation}`, className),
|
|
6287
|
-
style: { margin: margin2 }
|
|
6288
|
-
}
|
|
6289
|
-
);
|
|
6290
|
-
}
|
|
6291
|
-
function ScrollShadow({
|
|
6292
|
-
orientation = "vertical",
|
|
6293
|
-
size: size2 = 32,
|
|
6294
|
-
maxSize,
|
|
6295
|
-
className,
|
|
6296
|
-
style,
|
|
6297
|
-
children,
|
|
6298
|
-
"aria-label": ariaLabel,
|
|
6299
|
-
...props
|
|
6300
|
-
}) {
|
|
6301
|
-
const ref = useRef32(null);
|
|
6302
|
-
const [edges, setEdges] = useState28({ start: false, end: false });
|
|
6303
|
-
useEffect25(() => {
|
|
6304
|
-
const element = ref.current;
|
|
6305
|
-
if (!element) return;
|
|
6306
|
-
const update = () => {
|
|
6307
|
-
const position = orientation === "vertical" ? element.scrollTop : element.scrollLeft;
|
|
6308
|
-
const extent = orientation === "vertical" ? element.scrollHeight - element.clientHeight : element.scrollWidth - element.clientWidth;
|
|
6309
|
-
setEdges({ start: position > 1, end: position < extent - 1 });
|
|
6310
|
-
};
|
|
6311
|
-
update();
|
|
6312
|
-
element.addEventListener("scroll", update, { passive: true });
|
|
6313
|
-
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(update);
|
|
6314
|
-
observer?.observe(element);
|
|
6315
|
-
if (element.firstElementChild) observer?.observe(element.firstElementChild);
|
|
6316
|
-
return () => {
|
|
6317
|
-
element.removeEventListener("scroll", update);
|
|
6318
|
-
observer?.disconnect();
|
|
6319
|
-
};
|
|
6320
|
-
}, [orientation]);
|
|
6321
|
-
return /* @__PURE__ */ jsx60(
|
|
6322
|
-
"div",
|
|
6323
|
-
{
|
|
6324
|
-
ref,
|
|
6325
|
-
className: cx("ow-scroll-shadow", `ow-scroll-shadow--${orientation}`, className),
|
|
6326
|
-
"data-start": edges.start || void 0,
|
|
6327
|
-
"data-end": edges.end || void 0,
|
|
6328
|
-
tabIndex: ariaLabel ? 0 : void 0,
|
|
6329
|
-
role: ariaLabel ? "region" : void 0,
|
|
6330
|
-
"aria-label": ariaLabel,
|
|
6331
|
-
style: {
|
|
6332
|
-
"--ow-scroll-shadow": `${size2}px`,
|
|
6333
|
-
[orientation === "vertical" ? "maxHeight" : "maxWidth"]: maxSize,
|
|
6334
|
-
...style
|
|
6335
|
-
},
|
|
6336
|
-
...props,
|
|
6337
|
-
children
|
|
6338
|
-
}
|
|
6339
|
-
);
|
|
6340
|
-
}
|
|
6341
|
-
function VisuallyHidden({ className, ...props }) {
|
|
6342
|
-
return /* @__PURE__ */ jsx60("span", { className: cx("ow-visually-hidden", className), ...props });
|
|
6343
|
-
}
|
|
6344
|
-
|
|
6345
6905
|
// src/components/Container/Container.tsx
|
|
6346
|
-
import { jsx as
|
|
6906
|
+
import { jsx as jsx68 } from "react/jsx-runtime";
|
|
6347
6907
|
function Container({ size: size2 = "page", as: Element2 = "div", className, ...props }) {
|
|
6348
|
-
return /* @__PURE__ */
|
|
6908
|
+
return /* @__PURE__ */ jsx68(Element2, { className: cx("ow-container", `ow-container--${size2}`, className), ...props });
|
|
6349
6909
|
}
|
|
6350
6910
|
|
|
6351
6911
|
// src/components/Section/Section.tsx
|
|
6352
|
-
import { jsx as
|
|
6912
|
+
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
6353
6913
|
function Section({ tone = "paper", spacing = "md", size: size2 = "page", as: Element2 = "section", className, children, ...props }) {
|
|
6354
|
-
return /* @__PURE__ */
|
|
6914
|
+
return /* @__PURE__ */ jsx69(Element2, { className: cx("ow-section", `ow-section--${tone}`, `ow-section--space-${spacing}`, className), ...props, children: size2 === false ? children : /* @__PURE__ */ jsx69(Container, { size: size2, children }) });
|
|
6355
6915
|
}
|
|
6356
6916
|
|
|
6357
6917
|
// src/components/Marketing/Marketing.tsx
|
|
6358
|
-
import { useRef as
|
|
6359
|
-
import { jsx as
|
|
6918
|
+
import { useRef as useRef34 } from "react";
|
|
6919
|
+
import { jsx as jsx70, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
6360
6920
|
function Chip({ className, ...props }) {
|
|
6361
|
-
return /* @__PURE__ */
|
|
6921
|
+
return /* @__PURE__ */ jsx70("span", { className: cx("ow-chip", className), ...props });
|
|
6362
6922
|
}
|
|
6363
6923
|
function SectionHeading({
|
|
6364
6924
|
eyebrow,
|
|
@@ -6368,21 +6928,21 @@ function SectionHeading({
|
|
|
6368
6928
|
as: Heading = "h2",
|
|
6369
6929
|
className
|
|
6370
6930
|
}) {
|
|
6371
|
-
return /* @__PURE__ */
|
|
6372
|
-
eyebrow ? /* @__PURE__ */
|
|
6373
|
-
/* @__PURE__ */
|
|
6374
|
-
intro ? /* @__PURE__ */
|
|
6931
|
+
return /* @__PURE__ */ jsxs52("div", { className: cx("ow-section-heading", align === "center" && "ow-section-heading--center", className), children: [
|
|
6932
|
+
eyebrow ? /* @__PURE__ */ jsx70(Chip, { children: eyebrow }) : null,
|
|
6933
|
+
/* @__PURE__ */ jsx70(Heading, { className: "ow-section-heading__title", children: title }),
|
|
6934
|
+
intro ? /* @__PURE__ */ jsx70("p", { className: "ow-section-heading__intro", children: intro }) : null
|
|
6375
6935
|
] });
|
|
6376
6936
|
}
|
|
6377
6937
|
function SiteHeader({ brand, nav, actions, className }) {
|
|
6378
|
-
return /* @__PURE__ */
|
|
6379
|
-
/* @__PURE__ */
|
|
6380
|
-
nav ? /* @__PURE__ */
|
|
6381
|
-
actions ? /* @__PURE__ */
|
|
6938
|
+
return /* @__PURE__ */ jsxs52("header", { className: cx("ow-site-header", className), children: [
|
|
6939
|
+
/* @__PURE__ */ jsx70("div", { className: "ow-site-header__brand", children: brand }),
|
|
6940
|
+
nav ? /* @__PURE__ */ jsx70("nav", { className: "ow-site-header__nav", children: nav }) : null,
|
|
6941
|
+
actions ? /* @__PURE__ */ jsx70("div", { className: "ow-site-header__actions", children: actions }) : null
|
|
6382
6942
|
] });
|
|
6383
6943
|
}
|
|
6384
6944
|
function DotGrid({ fade = false, interactive = false, className, children, onPointerMove, ...props }) {
|
|
6385
|
-
const ref =
|
|
6945
|
+
const ref = useRef34(null);
|
|
6386
6946
|
function track(event) {
|
|
6387
6947
|
onPointerMove?.(event);
|
|
6388
6948
|
const element = ref.current;
|
|
@@ -6391,7 +6951,7 @@ function DotGrid({ fade = false, interactive = false, className, children, onPoi
|
|
|
6391
6951
|
element.style.setProperty("--ow-pointer-x", `${event.clientX - rect.left}px`);
|
|
6392
6952
|
element.style.setProperty("--ow-pointer-y", `${event.clientY - rect.top}px`);
|
|
6393
6953
|
}
|
|
6394
|
-
return /* @__PURE__ */
|
|
6954
|
+
return /* @__PURE__ */ jsxs52(
|
|
6395
6955
|
"div",
|
|
6396
6956
|
{
|
|
6397
6957
|
ref,
|
|
@@ -6399,20 +6959,20 @@ function DotGrid({ fade = false, interactive = false, className, children, onPoi
|
|
|
6399
6959
|
onPointerMove: track,
|
|
6400
6960
|
...props,
|
|
6401
6961
|
children: [
|
|
6402
|
-
/* @__PURE__ */
|
|
6403
|
-
interactive ? /* @__PURE__ */
|
|
6404
|
-
/* @__PURE__ */
|
|
6962
|
+
/* @__PURE__ */ jsx70("span", { className: "ow-dot-grid__dots", "aria-hidden": "true" }),
|
|
6963
|
+
interactive ? /* @__PURE__ */ jsx70("span", { className: "ow-dot-grid__brass", "aria-hidden": "true" }) : null,
|
|
6964
|
+
/* @__PURE__ */ jsx70("div", { className: "ow-dot-grid__content", children })
|
|
6405
6965
|
]
|
|
6406
6966
|
}
|
|
6407
6967
|
);
|
|
6408
6968
|
}
|
|
6409
6969
|
|
|
6410
6970
|
// src/components/Prose/Prose.tsx
|
|
6411
|
-
import { forwardRef as forwardRef23, useEffect as useEffect26, useRef as
|
|
6412
|
-
import { jsx as
|
|
6971
|
+
import { forwardRef as forwardRef23, useEffect as useEffect26, useRef as useRef35 } from "react";
|
|
6972
|
+
import { jsx as jsx71 } from "react/jsx-runtime";
|
|
6413
6973
|
var Prose = /* @__PURE__ */ forwardRef23(function Prose2({ size: size2 = "md", fullWidth = false, as = "div", className, children, ...props }, ref) {
|
|
6414
6974
|
const Element2 = as;
|
|
6415
|
-
const root =
|
|
6975
|
+
const root = useRef35(null);
|
|
6416
6976
|
useEffect26(() => {
|
|
6417
6977
|
const element = root.current;
|
|
6418
6978
|
if (!element) return;
|
|
@@ -6425,7 +6985,7 @@ var Prose = /* @__PURE__ */ forwardRef23(function Prose2({ size: size2 = "md", f
|
|
|
6425
6985
|
if (text) box.setAttribute("aria-label", text);
|
|
6426
6986
|
}
|
|
6427
6987
|
});
|
|
6428
|
-
return /* @__PURE__ */
|
|
6988
|
+
return /* @__PURE__ */ jsx71(
|
|
6429
6989
|
Element2,
|
|
6430
6990
|
{
|
|
6431
6991
|
ref: (node) => {
|
|
@@ -6441,10 +7001,10 @@ var Prose = /* @__PURE__ */ forwardRef23(function Prose2({ size: size2 = "md", f
|
|
|
6441
7001
|
});
|
|
6442
7002
|
|
|
6443
7003
|
// src/components/TextShimmer/TextShimmer.tsx
|
|
6444
|
-
import { jsx as
|
|
7004
|
+
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
6445
7005
|
function TextShimmer({ children, as = "span", duration = 2, active = true, className }) {
|
|
6446
7006
|
const Element2 = as;
|
|
6447
|
-
return /* @__PURE__ */
|
|
7007
|
+
return /* @__PURE__ */ jsx72(
|
|
6448
7008
|
Element2,
|
|
6449
7009
|
{
|
|
6450
7010
|
className: cx("ow-shimmer", active && "ow-shimmer--active", className),
|
|
@@ -6458,17 +7018,17 @@ function TextShimmer({ children, as = "span", duration = 2, active = true, class
|
|
|
6458
7018
|
import {
|
|
6459
7019
|
forwardRef as forwardRef24,
|
|
6460
7020
|
useEffect as useEffect27,
|
|
6461
|
-
useId as
|
|
6462
|
-
useLayoutEffect as
|
|
6463
|
-
useRef as
|
|
6464
|
-
useState as
|
|
7021
|
+
useId as useId23,
|
|
7022
|
+
useLayoutEffect as useLayoutEffect8,
|
|
7023
|
+
useRef as useRef36,
|
|
7024
|
+
useState as useState33
|
|
6465
7025
|
} from "react";
|
|
6466
|
-
import { jsx as
|
|
7026
|
+
import { jsx as jsx73, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
6467
7027
|
var noAttachments = [];
|
|
6468
7028
|
var counterFrom = 0.8;
|
|
6469
7029
|
var announceDelay = 1e3;
|
|
6470
7030
|
function Glyph({ children }) {
|
|
6471
|
-
return /* @__PURE__ */
|
|
7031
|
+
return /* @__PURE__ */ jsx73(
|
|
6472
7032
|
"svg",
|
|
6473
7033
|
{
|
|
6474
7034
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6488,29 +7048,29 @@ function Glyph({ children }) {
|
|
|
6488
7048
|
}
|
|
6489
7049
|
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";
|
|
6490
7050
|
var fold = "M14 2v5a1 1 0 0 0 1 1h5";
|
|
6491
|
-
var PaperclipIcon = () => /* @__PURE__ */
|
|
6492
|
-
var StopIcon = () => /* @__PURE__ */
|
|
7051
|
+
var PaperclipIcon = () => /* @__PURE__ */ jsx73(Glyph, { children: /* @__PURE__ */ jsx73("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" }) });
|
|
7052
|
+
var StopIcon = () => /* @__PURE__ */ jsx73(Glyph, { children: /* @__PURE__ */ jsx73("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2", fill: "currentColor", stroke: "none" }) });
|
|
6493
7053
|
var fileIcons = {
|
|
6494
|
-
image: /* @__PURE__ */
|
|
6495
|
-
/* @__PURE__ */
|
|
6496
|
-
/* @__PURE__ */
|
|
6497
|
-
/* @__PURE__ */
|
|
6498
|
-
/* @__PURE__ */
|
|
7054
|
+
image: /* @__PURE__ */ jsxs53(Glyph, { children: [
|
|
7055
|
+
/* @__PURE__ */ jsx73("path", { d: sheet }),
|
|
7056
|
+
/* @__PURE__ */ jsx73("path", { d: fold }),
|
|
7057
|
+
/* @__PURE__ */ jsx73("circle", { cx: "10", cy: "12", r: "2" }),
|
|
7058
|
+
/* @__PURE__ */ jsx73("path", { d: "m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22" })
|
|
6499
7059
|
] }),
|
|
6500
|
-
code: /* @__PURE__ */
|
|
6501
|
-
/* @__PURE__ */
|
|
6502
|
-
/* @__PURE__ */
|
|
6503
|
-
/* @__PURE__ */
|
|
6504
|
-
/* @__PURE__ */
|
|
7060
|
+
code: /* @__PURE__ */ jsxs53(Glyph, { children: [
|
|
7061
|
+
/* @__PURE__ */ jsx73("path", { d: sheet }),
|
|
7062
|
+
/* @__PURE__ */ jsx73("path", { d: fold }),
|
|
7063
|
+
/* @__PURE__ */ jsx73("path", { d: "M10 12.5 8 15l2 2.5" }),
|
|
7064
|
+
/* @__PURE__ */ jsx73("path", { d: "m14 12.5 2 2.5-2 2.5" })
|
|
6505
7065
|
] }),
|
|
6506
|
-
text: /* @__PURE__ */
|
|
6507
|
-
/* @__PURE__ */
|
|
6508
|
-
/* @__PURE__ */
|
|
6509
|
-
/* @__PURE__ */
|
|
6510
|
-
/* @__PURE__ */
|
|
6511
|
-
/* @__PURE__ */
|
|
7066
|
+
text: /* @__PURE__ */ jsxs53(Glyph, { children: [
|
|
7067
|
+
/* @__PURE__ */ jsx73("path", { d: sheet }),
|
|
7068
|
+
/* @__PURE__ */ jsx73("path", { d: fold }),
|
|
7069
|
+
/* @__PURE__ */ jsx73("path", { d: "M10 9H8" }),
|
|
7070
|
+
/* @__PURE__ */ jsx73("path", { d: "M16 13H8" }),
|
|
7071
|
+
/* @__PURE__ */ jsx73("path", { d: "M16 17H8" })
|
|
6512
7072
|
] }),
|
|
6513
|
-
file: /* @__PURE__ */
|
|
7073
|
+
file: /* @__PURE__ */ jsx73(FileIcon, { size: 16 })
|
|
6514
7074
|
};
|
|
6515
7075
|
function kindOf({ name, type = "" }) {
|
|
6516
7076
|
const lower = name.toLowerCase();
|
|
@@ -6552,7 +7112,7 @@ function accepts(file, accept) {
|
|
|
6552
7112
|
var hasFiles = (event) => Array.from(event.dataTransfer.types).includes("Files");
|
|
6553
7113
|
var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
6554
7114
|
value,
|
|
6555
|
-
defaultValue = "",
|
|
7115
|
+
defaultValue: defaultValue2 = "",
|
|
6556
7116
|
onChange,
|
|
6557
7117
|
onSubmit,
|
|
6558
7118
|
isStreaming = false,
|
|
@@ -6581,18 +7141,18 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6581
7141
|
onKeyDown,
|
|
6582
7142
|
className
|
|
6583
7143
|
}, ref) {
|
|
6584
|
-
const [text, setText] = useControllableState(value,
|
|
6585
|
-
const textAreaRef =
|
|
6586
|
-
const actionRef =
|
|
6587
|
-
const pickerRef =
|
|
6588
|
-
const listRef =
|
|
6589
|
-
const composing =
|
|
6590
|
-
const dragDepth =
|
|
6591
|
-
const pendingFocus =
|
|
6592
|
-
const [isDragging, setIsDragging] =
|
|
6593
|
-
const [notice, setNotice] =
|
|
6594
|
-
const [announcement, setAnnouncement] =
|
|
6595
|
-
const hintId =
|
|
7144
|
+
const [text, setText] = useControllableState(value, defaultValue2, onChange);
|
|
7145
|
+
const textAreaRef = useRef36(null);
|
|
7146
|
+
const actionRef = useRef36(null);
|
|
7147
|
+
const pickerRef = useRef36(null);
|
|
7148
|
+
const listRef = useRef36(null);
|
|
7149
|
+
const composing = useRef36(false);
|
|
7150
|
+
const dragDepth = useRef36(0);
|
|
7151
|
+
const pendingFocus = useRef36(null);
|
|
7152
|
+
const [isDragging, setIsDragging] = useState33(false);
|
|
7153
|
+
const [notice, setNotice] = useState33();
|
|
7154
|
+
const [announcement, setAnnouncement] = useState33("");
|
|
7155
|
+
const hintId = useId23();
|
|
6596
7156
|
const rows = Math.max(1, Math.round(minRows));
|
|
6597
7157
|
const maxRowCount = Math.max(rows, Math.round(maxRows));
|
|
6598
7158
|
const canAttach = Boolean(onAttach) && !disabled;
|
|
@@ -6602,7 +7162,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6602
7162
|
const inline = !toolbarStart && !endActions;
|
|
6603
7163
|
const showCounter = maxLength !== void 0 && maxLength > 0 && text.length >= maxLength * counterFrom;
|
|
6604
7164
|
const remaining = maxLength === void 0 ? 0 : Math.max(0, maxLength - text.length);
|
|
6605
|
-
const
|
|
7165
|
+
const number2 = (count) => new Intl.NumberFormat(locale).format(count);
|
|
6606
7166
|
const shownHint = notice ?? hint;
|
|
6607
7167
|
const describedBy = [ariaDescribedBy, hint && !notice ? hintId : void 0].filter(Boolean).join(" ") || void 0;
|
|
6608
7168
|
const name = ariaLabel ?? (ariaLabelledBy || id ? void 0 : "Message");
|
|
@@ -6623,20 +7183,20 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6623
7183
|
observer.observe(textArea);
|
|
6624
7184
|
return () => observer.disconnect();
|
|
6625
7185
|
}, []);
|
|
6626
|
-
|
|
7186
|
+
useLayoutEffect8(() => {
|
|
6627
7187
|
if (textAreaRef.current) resizeTextArea(textAreaRef.current);
|
|
6628
7188
|
}, [size2, rows]);
|
|
6629
|
-
const wasStreaming =
|
|
6630
|
-
const actionHadFocus =
|
|
7189
|
+
const wasStreaming = useRef36(isStreaming);
|
|
7190
|
+
const actionHadFocus = useRef36(false);
|
|
6631
7191
|
if (wasStreaming.current !== isStreaming) {
|
|
6632
7192
|
actionHadFocus.current = typeof document !== "undefined" && document.activeElement === actionRef.current;
|
|
6633
7193
|
}
|
|
6634
|
-
|
|
7194
|
+
useLayoutEffect8(() => {
|
|
6635
7195
|
if (wasStreaming.current && !isStreaming && actionHadFocus.current && !hasContent) textAreaRef.current?.focus();
|
|
6636
7196
|
wasStreaming.current = isStreaming;
|
|
6637
7197
|
actionHadFocus.current = false;
|
|
6638
7198
|
}, [isStreaming, hasContent]);
|
|
6639
|
-
|
|
7199
|
+
useLayoutEffect8(() => {
|
|
6640
7200
|
const pending = pendingFocus.current;
|
|
6641
7201
|
if (!pending) return;
|
|
6642
7202
|
pendingFocus.current = null;
|
|
@@ -6648,7 +7208,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6648
7208
|
useEffect27(() => {
|
|
6649
7209
|
if (!showCounter || document.activeElement !== textAreaRef.current) return;
|
|
6650
7210
|
const timer = window.setTimeout(() => {
|
|
6651
|
-
setAnnouncement(`${
|
|
7211
|
+
setAnnouncement(`${number2(remaining)} ${remaining === 1 ? "character" : "characters"} left`);
|
|
6652
7212
|
}, announceDelay);
|
|
6653
7213
|
return () => window.clearTimeout(timer);
|
|
6654
7214
|
}, [showCounter, remaining, locale]);
|
|
@@ -6703,7 +7263,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6703
7263
|
event.preventDefault();
|
|
6704
7264
|
textAreaRef.current?.focus();
|
|
6705
7265
|
}
|
|
6706
|
-
const attachButton = onAttach ? /* @__PURE__ */
|
|
7266
|
+
const attachButton = onAttach ? /* @__PURE__ */ jsx73(Tooltip, { label: "Attach files", children: /* @__PURE__ */ jsx73(
|
|
6707
7267
|
Button,
|
|
6708
7268
|
{
|
|
6709
7269
|
className: "ow-prompt-input__attach",
|
|
@@ -6713,11 +7273,11 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6713
7273
|
"aria-label": multiple ? "Attach files" : "Attach a file",
|
|
6714
7274
|
disabled,
|
|
6715
7275
|
onClick: () => pickerRef.current?.click(),
|
|
6716
|
-
children: /* @__PURE__ */
|
|
7276
|
+
children: /* @__PURE__ */ jsx73(PaperclipIcon, {})
|
|
6717
7277
|
}
|
|
6718
7278
|
) }) : null;
|
|
6719
7279
|
const actionLabel = isStreaming ? "Stop" : "Send";
|
|
6720
|
-
const actionButton = /* @__PURE__ */
|
|
7280
|
+
const actionButton = /* @__PURE__ */ jsx73(Tooltip, { label: actionLabel, children: /* @__PURE__ */ jsx73(
|
|
6721
7281
|
Button,
|
|
6722
7282
|
{
|
|
6723
7283
|
ref: actionRef,
|
|
@@ -6732,10 +7292,10 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6732
7292
|
else submit();
|
|
6733
7293
|
textAreaRef.current?.focus();
|
|
6734
7294
|
},
|
|
6735
|
-
children: isStreaming ? /* @__PURE__ */
|
|
7295
|
+
children: isStreaming ? /* @__PURE__ */ jsx73(StopIcon, {}) : /* @__PURE__ */ jsx73(ArrowUpIcon, { size: 16 })
|
|
6736
7296
|
}
|
|
6737
7297
|
) });
|
|
6738
|
-
return /* @__PURE__ */
|
|
7298
|
+
return /* @__PURE__ */ jsxs53(
|
|
6739
7299
|
"div",
|
|
6740
7300
|
{
|
|
6741
7301
|
className: cx(
|
|
@@ -6749,7 +7309,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6749
7309
|
),
|
|
6750
7310
|
style: { "--ow-prompt-min-rows": rows, "--ow-prompt-max-rows": maxRowCount },
|
|
6751
7311
|
children: [
|
|
6752
|
-
/* @__PURE__ */
|
|
7312
|
+
/* @__PURE__ */ jsxs53(
|
|
6753
7313
|
"fieldset",
|
|
6754
7314
|
{
|
|
6755
7315
|
role: "presentation",
|
|
@@ -6779,12 +7339,12 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6779
7339
|
take(Array.from(event.dataTransfer.files));
|
|
6780
7340
|
},
|
|
6781
7341
|
children: [
|
|
6782
|
-
attachments.length ? /* @__PURE__ */
|
|
7342
|
+
attachments.length ? /* @__PURE__ */ jsx73("ul", { ref: listRef, className: "ow-prompt-input__attachments", "aria-label": "Attachments", children: attachments.map((attachment, index) => {
|
|
6783
7343
|
const [base, extension] = splitName(attachment.name);
|
|
6784
|
-
return /* @__PURE__ */
|
|
6785
|
-
/* @__PURE__ */
|
|
7344
|
+
return /* @__PURE__ */ jsxs53("li", { className: "ow-prompt-input__attachment", children: [
|
|
7345
|
+
/* @__PURE__ */ jsxs53("span", { className: "ow-prompt-input__thumb", "aria-hidden": "true", children: [
|
|
6786
7346
|
fileIcons[kindOf(attachment)],
|
|
6787
|
-
attachment.previewUrl ? /* @__PURE__ */
|
|
7347
|
+
attachment.previewUrl ? /* @__PURE__ */ jsx73(
|
|
6788
7348
|
"img",
|
|
6789
7349
|
{
|
|
6790
7350
|
src: attachment.previewUrl,
|
|
@@ -6795,26 +7355,26 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6795
7355
|
}
|
|
6796
7356
|
) : null
|
|
6797
7357
|
] }),
|
|
6798
|
-
/* @__PURE__ */
|
|
6799
|
-
/* @__PURE__ */
|
|
6800
|
-
/* @__PURE__ */
|
|
7358
|
+
/* @__PURE__ */ jsxs53("span", { className: "ow-prompt-input__file", children: [
|
|
7359
|
+
/* @__PURE__ */ jsxs53("span", { className: "ow-prompt-input__file-name", title: attachment.name, children: [
|
|
7360
|
+
/* @__PURE__ */ jsx73("span", { className: "ow-prompt-input__file-base", children: base }),
|
|
6801
7361
|
extension
|
|
6802
7362
|
] }),
|
|
6803
|
-
attachment.size !== void 0 ? /* @__PURE__ */
|
|
7363
|
+
attachment.size !== void 0 ? /* @__PURE__ */ jsx73("span", { className: "ow-prompt-input__file-size", children: formatBytes(attachment.size, locale) }) : null
|
|
6804
7364
|
] }),
|
|
6805
|
-
onRemoveAttachment ? /* @__PURE__ */
|
|
7365
|
+
onRemoveAttachment ? /* @__PURE__ */ jsx73(
|
|
6806
7366
|
"button",
|
|
6807
7367
|
{
|
|
6808
7368
|
type: "button",
|
|
6809
7369
|
className: "ow-prompt-input__remove",
|
|
6810
7370
|
"aria-label": `Remove ${attachment.name}`,
|
|
6811
7371
|
onClick: () => remove(attachment, index),
|
|
6812
|
-
children: /* @__PURE__ */
|
|
7372
|
+
children: /* @__PURE__ */ jsx73(XIcon, { size: 14 })
|
|
6813
7373
|
}
|
|
6814
7374
|
) : null
|
|
6815
7375
|
] }, attachment.id);
|
|
6816
7376
|
}) }) : null,
|
|
6817
|
-
/* @__PURE__ */
|
|
7377
|
+
/* @__PURE__ */ jsx73(
|
|
6818
7378
|
Textarea,
|
|
6819
7379
|
{
|
|
6820
7380
|
ref: setTextAreaRef,
|
|
@@ -6845,22 +7405,22 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6845
7405
|
}
|
|
6846
7406
|
}
|
|
6847
7407
|
),
|
|
6848
|
-
/* @__PURE__ */
|
|
6849
|
-
toolbarStart ? /* @__PURE__ */
|
|
7408
|
+
/* @__PURE__ */ jsxs53("div", { className: "ow-prompt-input__toolbar", "data-prompt-blank": "", children: [
|
|
7409
|
+
toolbarStart ? /* @__PURE__ */ jsxs53("div", { className: "ow-prompt-input__start", "data-prompt-blank": "", children: [
|
|
6850
7410
|
attachButton,
|
|
6851
7411
|
startActions
|
|
6852
7412
|
] }) : null,
|
|
6853
|
-
/* @__PURE__ */
|
|
6854
|
-
showCounter ? /* @__PURE__ */
|
|
6855
|
-
|
|
7413
|
+
/* @__PURE__ */ jsxs53("div", { className: "ow-prompt-input__end", "data-prompt-blank": "", children: [
|
|
7414
|
+
showCounter ? /* @__PURE__ */ jsxs53("span", { className: cx("ow-prompt-input__counter", remaining === 0 && "ow-prompt-input__counter--full"), "aria-hidden": "true", children: [
|
|
7415
|
+
number2(text.length),
|
|
6856
7416
|
" / ",
|
|
6857
|
-
|
|
7417
|
+
number2(maxLength)
|
|
6858
7418
|
] }) : null,
|
|
6859
7419
|
endActions,
|
|
6860
7420
|
actionButton
|
|
6861
7421
|
] })
|
|
6862
7422
|
] }),
|
|
6863
|
-
onAttach ? /* @__PURE__ */
|
|
7423
|
+
onAttach ? /* @__PURE__ */ jsx73(
|
|
6864
7424
|
"input",
|
|
6865
7425
|
{
|
|
6866
7426
|
ref: pickerRef,
|
|
@@ -6876,14 +7436,14 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6876
7436
|
}
|
|
6877
7437
|
}
|
|
6878
7438
|
) : null,
|
|
6879
|
-
isDragging ? /* @__PURE__ */
|
|
6880
|
-
/* @__PURE__ */
|
|
7439
|
+
isDragging ? /* @__PURE__ */ jsxs53("div", { className: "ow-prompt-input__drop", "aria-hidden": "true", children: [
|
|
7440
|
+
/* @__PURE__ */ jsx73(UploadIcon, { size: 16 }),
|
|
6881
7441
|
"Drop to attach"
|
|
6882
7442
|
] }) : null
|
|
6883
7443
|
]
|
|
6884
7444
|
}
|
|
6885
7445
|
),
|
|
6886
|
-
shownHint ? /* @__PURE__ */
|
|
7446
|
+
shownHint ? /* @__PURE__ */ jsx73(
|
|
6887
7447
|
"div",
|
|
6888
7448
|
{
|
|
6889
7449
|
className: cx("ow-prompt-input__hint", notice && "ow-prompt-input__hint--notice"),
|
|
@@ -6892,7 +7452,7 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6892
7452
|
children: shownHint
|
|
6893
7453
|
}
|
|
6894
7454
|
) : null,
|
|
6895
|
-
/* @__PURE__ */
|
|
7455
|
+
/* @__PURE__ */ jsx73("span", { className: "ow-visually-hidden", role: "status", children: announcement })
|
|
6896
7456
|
]
|
|
6897
7457
|
}
|
|
6898
7458
|
);
|
|
@@ -6900,18 +7460,18 @@ var PromptInput = /* @__PURE__ */ forwardRef24(function PromptInput2({
|
|
|
6900
7460
|
|
|
6901
7461
|
// src/components/PromptInput/PromptSuggestion.tsx
|
|
6902
7462
|
import { forwardRef as forwardRef25 } from "react";
|
|
6903
|
-
import { jsx as
|
|
7463
|
+
import { jsx as jsx74, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
6904
7464
|
var PromptSuggestion = /* @__PURE__ */ forwardRef25(function PromptSuggestion2({ children, icon: icon2, description, variant = description ? "card" : "pill", type = "button", className, ...buttonProps }, ref) {
|
|
6905
7465
|
if (variant === "card") {
|
|
6906
|
-
return /* @__PURE__ */
|
|
6907
|
-
icon2 ? /* @__PURE__ */
|
|
6908
|
-
/* @__PURE__ */
|
|
6909
|
-
/* @__PURE__ */
|
|
6910
|
-
description ? /* @__PURE__ */
|
|
7466
|
+
return /* @__PURE__ */ jsxs54("button", { ref, type, className: cx("ow-prompt-suggestion", "ow-prompt-suggestion--card", className), ...buttonProps, children: [
|
|
7467
|
+
icon2 ? /* @__PURE__ */ jsx74("span", { className: "ow-prompt-suggestion__icon", children: icon2 }) : null,
|
|
7468
|
+
/* @__PURE__ */ jsxs54("span", { className: "ow-prompt-suggestion__text", children: [
|
|
7469
|
+
/* @__PURE__ */ jsx74("span", { className: "ow-prompt-suggestion__title", children }),
|
|
7470
|
+
description ? /* @__PURE__ */ jsx74("span", { className: "ow-prompt-suggestion__description", children: description }) : null
|
|
6911
7471
|
] })
|
|
6912
7472
|
] });
|
|
6913
7473
|
}
|
|
6914
|
-
return /* @__PURE__ */
|
|
7474
|
+
return /* @__PURE__ */ jsxs54(
|
|
6915
7475
|
"button",
|
|
6916
7476
|
{
|
|
6917
7477
|
ref,
|
|
@@ -6924,8 +7484,8 @@ var PromptSuggestion = /* @__PURE__ */ forwardRef25(function PromptSuggestion2({
|
|
|
6924
7484
|
),
|
|
6925
7485
|
...buttonProps,
|
|
6926
7486
|
children: [
|
|
6927
|
-
icon2 ? /* @__PURE__ */
|
|
6928
|
-
/* @__PURE__ */
|
|
7487
|
+
icon2 ? /* @__PURE__ */ jsx74("span", { className: "ow-prompt-suggestion__icon", children: icon2 }) : null,
|
|
7488
|
+
/* @__PURE__ */ jsx74("span", { className: "ow-prompt-suggestion__label", children })
|
|
6929
7489
|
]
|
|
6930
7490
|
}
|
|
6931
7491
|
);
|
|
@@ -6940,7 +7500,7 @@ function PromptSuggestions({
|
|
|
6940
7500
|
style,
|
|
6941
7501
|
...props
|
|
6942
7502
|
}) {
|
|
6943
|
-
return /* @__PURE__ */
|
|
7503
|
+
return /* @__PURE__ */ jsx74(
|
|
6944
7504
|
"div",
|
|
6945
7505
|
{
|
|
6946
7506
|
role: "group",
|
|
@@ -6956,18 +7516,18 @@ function PromptSuggestions({
|
|
|
6956
7516
|
// src/components/Chat/ChatConversation.tsx
|
|
6957
7517
|
import {
|
|
6958
7518
|
Children as Children2,
|
|
6959
|
-
createContext as
|
|
7519
|
+
createContext as createContext9,
|
|
6960
7520
|
forwardRef as forwardRef26,
|
|
6961
|
-
useCallback as
|
|
7521
|
+
useCallback as useCallback11,
|
|
6962
7522
|
useEffect as useEffect28,
|
|
6963
7523
|
useImperativeHandle as useImperativeHandle3,
|
|
6964
|
-
useLayoutEffect as
|
|
6965
|
-
useMemo as
|
|
6966
|
-
useRef as
|
|
6967
|
-
useState as
|
|
7524
|
+
useLayoutEffect as useLayoutEffect9,
|
|
7525
|
+
useMemo as useMemo13,
|
|
7526
|
+
useRef as useRef37,
|
|
7527
|
+
useState as useState34
|
|
6968
7528
|
} from "react";
|
|
6969
|
-
import { jsx as
|
|
6970
|
-
var ChatConversationContext = /* @__PURE__ */
|
|
7529
|
+
import { jsx as jsx75, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
7530
|
+
var ChatConversationContext = /* @__PURE__ */ createContext9(null);
|
|
6971
7531
|
var stickyDistance = 32;
|
|
6972
7532
|
var defaultCount = (count) => `${count} new`;
|
|
6973
7533
|
var prefersReducedMotion = () => typeof window !== "undefined" && Boolean(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches);
|
|
@@ -6983,17 +7543,17 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
6983
7543
|
className,
|
|
6984
7544
|
...props
|
|
6985
7545
|
}, ref) {
|
|
6986
|
-
const scrollerRef =
|
|
6987
|
-
const contentRef =
|
|
6988
|
-
const jumpRef =
|
|
6989
|
-
const following =
|
|
6990
|
-
const lastTop =
|
|
6991
|
-
const ready =
|
|
6992
|
-
const unseen =
|
|
6993
|
-
const [isFollowing, setIsFollowing] =
|
|
6994
|
-
const [newCount, setNewCount] =
|
|
7546
|
+
const scrollerRef = useRef37(null);
|
|
7547
|
+
const contentRef = useRef37(null);
|
|
7548
|
+
const jumpRef = useRef37(null);
|
|
7549
|
+
const following = useRef37(true);
|
|
7550
|
+
const lastTop = useRef37(0);
|
|
7551
|
+
const ready = useRef37(false);
|
|
7552
|
+
const unseen = useRef37(/* @__PURE__ */ new Set());
|
|
7553
|
+
const [isFollowing, setIsFollowing] = useState34(true);
|
|
7554
|
+
const [newCount, setNewCount] = useState34(0);
|
|
6995
7555
|
const isEmpty = Children2.toArray(children).length === 0;
|
|
6996
|
-
const follow =
|
|
7556
|
+
const follow = useCallback11((next) => {
|
|
6997
7557
|
following.current = next;
|
|
6998
7558
|
setIsFollowing(next);
|
|
6999
7559
|
if (next && unseen.current.size > 0) {
|
|
@@ -7001,13 +7561,13 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7001
7561
|
setNewCount(0);
|
|
7002
7562
|
}
|
|
7003
7563
|
}, []);
|
|
7004
|
-
const stick =
|
|
7564
|
+
const stick = useCallback11(() => {
|
|
7005
7565
|
const scroller = scrollerRef.current;
|
|
7006
7566
|
if (!scroller) return;
|
|
7007
7567
|
scroller.scrollTop = scroller.scrollHeight;
|
|
7008
7568
|
lastTop.current = scroller.scrollTop;
|
|
7009
7569
|
}, []);
|
|
7010
|
-
const scrollToBottom =
|
|
7570
|
+
const scrollToBottom = useCallback11(
|
|
7011
7571
|
(options) => {
|
|
7012
7572
|
const scroller = scrollerRef.current;
|
|
7013
7573
|
if (!scroller) return;
|
|
@@ -7017,7 +7577,7 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7017
7577
|
[follow]
|
|
7018
7578
|
);
|
|
7019
7579
|
useImperativeHandle3(ref, () => ({ scrollToBottom }), [scrollToBottom]);
|
|
7020
|
-
|
|
7580
|
+
useLayoutEffect9(stick, [stick]);
|
|
7021
7581
|
useEffect28(() => {
|
|
7022
7582
|
ready.current = true;
|
|
7023
7583
|
}, []);
|
|
@@ -7044,7 +7604,7 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7044
7604
|
}
|
|
7045
7605
|
lastTop.current = top;
|
|
7046
7606
|
}
|
|
7047
|
-
const context =
|
|
7607
|
+
const context = useMemo13(
|
|
7048
7608
|
() => ({
|
|
7049
7609
|
ready,
|
|
7050
7610
|
register(id) {
|
|
@@ -7061,9 +7621,9 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7061
7621
|
);
|
|
7062
7622
|
const showJump = !isFollowing && !isEmpty;
|
|
7063
7623
|
const jump = usePresence(showJump);
|
|
7064
|
-
return /* @__PURE__ */
|
|
7065
|
-
/* @__PURE__ */
|
|
7066
|
-
/* @__PURE__ */
|
|
7624
|
+
return /* @__PURE__ */ jsxs55("div", { className: cx("ow-chat-conversation", width === "full" && "ow-chat-conversation--full", className), ...props, children: [
|
|
7625
|
+
/* @__PURE__ */ jsxs55("div", { className: "ow-chat-conversation__viewport", children: [
|
|
7626
|
+
/* @__PURE__ */ jsx75(
|
|
7067
7627
|
"div",
|
|
7068
7628
|
{
|
|
7069
7629
|
ref: scrollerRef,
|
|
@@ -7075,17 +7635,17 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7075
7635
|
"aria-labelledby": ariaLabelledBy,
|
|
7076
7636
|
tabIndex: isEmpty ? void 0 : 0,
|
|
7077
7637
|
onScroll,
|
|
7078
|
-
children: /* @__PURE__ */
|
|
7638
|
+
children: /* @__PURE__ */ jsx75("div", { ref: contentRef, className: "ow-chat-conversation__content", children: /* @__PURE__ */ jsx75(ChatConversationContext.Provider, { value: context, children }) })
|
|
7079
7639
|
}
|
|
7080
7640
|
),
|
|
7081
|
-
isEmpty && empty ? /* @__PURE__ */
|
|
7082
|
-
jump.mounted ? /* @__PURE__ */
|
|
7641
|
+
isEmpty && empty ? /* @__PURE__ */ jsx75("div", { className: "ow-chat-conversation__empty", children: /* @__PURE__ */ jsx75("div", { className: "ow-chat-conversation__empty-inner", children: empty }) }) : null,
|
|
7642
|
+
jump.mounted ? /* @__PURE__ */ jsx75("div", { className: "ow-chat-conversation__jump", "data-state": jump.state, children: /* @__PURE__ */ jsxs55(
|
|
7083
7643
|
Button,
|
|
7084
7644
|
{
|
|
7085
7645
|
ref: jumpRef,
|
|
7086
7646
|
size: "sm",
|
|
7087
7647
|
shape: "pill",
|
|
7088
|
-
startIcon: /* @__PURE__ */
|
|
7648
|
+
startIcon: /* @__PURE__ */ jsx75(ArrowDownIcon, { size: 16 }),
|
|
7089
7649
|
"aria-label": newCount > 0 ? `${jumpLabel}, ${formatNewCount(newCount)}` : jumpLabel,
|
|
7090
7650
|
tabIndex: showJump ? void 0 : -1,
|
|
7091
7651
|
onClick: () => {
|
|
@@ -7094,29 +7654,29 @@ var ChatConversation = /* @__PURE__ */ forwardRef26(function ChatConversation2({
|
|
|
7094
7654
|
},
|
|
7095
7655
|
children: [
|
|
7096
7656
|
jumpLabel,
|
|
7097
|
-
newCount > 0 ? /* @__PURE__ */
|
|
7657
|
+
newCount > 0 ? /* @__PURE__ */ jsx75("span", { className: "ow-chat-conversation__count", children: formatNewCount(newCount) }) : null
|
|
7098
7658
|
]
|
|
7099
7659
|
}
|
|
7100
7660
|
) }) : null
|
|
7101
7661
|
] }),
|
|
7102
|
-
footer != null && footer !== false ? /* @__PURE__ */
|
|
7662
|
+
footer != null && footer !== false ? /* @__PURE__ */ jsx75("div", { className: "ow-chat-conversation__footer", children: /* @__PURE__ */ jsx75("div", { className: "ow-chat-conversation__footer-inner", children: footer }) }) : null
|
|
7103
7663
|
] });
|
|
7104
7664
|
});
|
|
7105
7665
|
|
|
7106
7666
|
// src/components/Chat/ChatMessage.tsx
|
|
7107
7667
|
import {
|
|
7108
7668
|
forwardRef as forwardRef27,
|
|
7109
|
-
useContext as
|
|
7669
|
+
useContext as useContext12,
|
|
7110
7670
|
useEffect as useEffect29,
|
|
7111
|
-
useId as
|
|
7112
|
-
useLayoutEffect as
|
|
7113
|
-
useRef as
|
|
7114
|
-
useState as
|
|
7671
|
+
useId as useId24,
|
|
7672
|
+
useLayoutEffect as useLayoutEffect10,
|
|
7673
|
+
useRef as useRef38,
|
|
7674
|
+
useState as useState35
|
|
7115
7675
|
} from "react";
|
|
7116
|
-
import { Fragment as
|
|
7676
|
+
import { Fragment as Fragment12, jsx as jsx76, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
7117
7677
|
function lucide(paths) {
|
|
7118
7678
|
return function Icon({ size: size2 = 16, strokeWidth = 2, ...props }) {
|
|
7119
|
-
return /* @__PURE__ */
|
|
7679
|
+
return /* @__PURE__ */ jsx76(
|
|
7120
7680
|
"svg",
|
|
7121
7681
|
{
|
|
7122
7682
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -7137,55 +7697,55 @@ function lucide(paths) {
|
|
|
7137
7697
|
};
|
|
7138
7698
|
}
|
|
7139
7699
|
var BotIcon = /* @__PURE__ */ lucide(
|
|
7140
|
-
/* @__PURE__ */
|
|
7141
|
-
/* @__PURE__ */
|
|
7142
|
-
/* @__PURE__ */
|
|
7143
|
-
/* @__PURE__ */
|
|
7144
|
-
/* @__PURE__ */
|
|
7145
|
-
/* @__PURE__ */
|
|
7146
|
-
/* @__PURE__ */
|
|
7700
|
+
/* @__PURE__ */ jsxs56(Fragment12, { children: [
|
|
7701
|
+
/* @__PURE__ */ jsx76("path", { d: "M12 8V4H8" }),
|
|
7702
|
+
/* @__PURE__ */ jsx76("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }),
|
|
7703
|
+
/* @__PURE__ */ jsx76("path", { d: "M2 14h2" }),
|
|
7704
|
+
/* @__PURE__ */ jsx76("path", { d: "M20 14h2" }),
|
|
7705
|
+
/* @__PURE__ */ jsx76("path", { d: "M15 13v2" }),
|
|
7706
|
+
/* @__PURE__ */ jsx76("path", { d: "M9 13v2" })
|
|
7147
7707
|
] })
|
|
7148
7708
|
);
|
|
7149
7709
|
var RotateCcwIcon = /* @__PURE__ */ lucide(
|
|
7150
|
-
/* @__PURE__ */
|
|
7151
|
-
/* @__PURE__ */
|
|
7152
|
-
/* @__PURE__ */
|
|
7710
|
+
/* @__PURE__ */ jsxs56(Fragment12, { children: [
|
|
7711
|
+
/* @__PURE__ */ jsx76("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
|
|
7712
|
+
/* @__PURE__ */ jsx76("path", { d: "M3 3v5h5" })
|
|
7153
7713
|
] })
|
|
7154
7714
|
);
|
|
7155
7715
|
var ThumbsUpIcon = /* @__PURE__ */ lucide(
|
|
7156
|
-
/* @__PURE__ */
|
|
7157
|
-
/* @__PURE__ */
|
|
7158
|
-
/* @__PURE__ */
|
|
7716
|
+
/* @__PURE__ */ jsxs56(Fragment12, { children: [
|
|
7717
|
+
/* @__PURE__ */ jsx76("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" }),
|
|
7718
|
+
/* @__PURE__ */ jsx76("path", { d: "M7 10v12" })
|
|
7159
7719
|
] })
|
|
7160
7720
|
);
|
|
7161
7721
|
var ThumbsDownIcon = /* @__PURE__ */ lucide(
|
|
7162
|
-
/* @__PURE__ */
|
|
7163
|
-
/* @__PURE__ */
|
|
7164
|
-
/* @__PURE__ */
|
|
7722
|
+
/* @__PURE__ */ jsxs56(Fragment12, { children: [
|
|
7723
|
+
/* @__PURE__ */ jsx76("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" }),
|
|
7724
|
+
/* @__PURE__ */ jsx76("path", { d: "M17 14V2" })
|
|
7165
7725
|
] })
|
|
7166
7726
|
);
|
|
7167
7727
|
var PencilIcon = /* @__PURE__ */ lucide(
|
|
7168
|
-
/* @__PURE__ */
|
|
7169
|
-
/* @__PURE__ */
|
|
7170
|
-
/* @__PURE__ */
|
|
7728
|
+
/* @__PURE__ */ jsxs56(Fragment12, { children: [
|
|
7729
|
+
/* @__PURE__ */ jsx76("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" }),
|
|
7730
|
+
/* @__PURE__ */ jsx76("path", { d: "m15 5 4 4" })
|
|
7171
7731
|
] })
|
|
7172
7732
|
);
|
|
7173
7733
|
var botSizes = { sm: 14, md: 16, lg: 18 };
|
|
7174
7734
|
function ChatAgentAvatar({ size: size2 = "md", label, className }) {
|
|
7175
|
-
return /* @__PURE__ */
|
|
7735
|
+
return /* @__PURE__ */ jsx76(
|
|
7176
7736
|
"span",
|
|
7177
7737
|
{
|
|
7178
7738
|
className: cx("ow-chat-avatar", size2 !== "md" && `ow-chat-avatar--${size2}`, className),
|
|
7179
7739
|
role: label ? "img" : void 0,
|
|
7180
7740
|
"aria-label": label,
|
|
7181
7741
|
"aria-hidden": label ? void 0 : true,
|
|
7182
|
-
children: /* @__PURE__ */
|
|
7742
|
+
children: /* @__PURE__ */ jsx76(BotIcon, { size: botSizes[size2] })
|
|
7183
7743
|
}
|
|
7184
7744
|
);
|
|
7185
7745
|
}
|
|
7186
7746
|
function useChatEntrance() {
|
|
7187
|
-
const conversation =
|
|
7188
|
-
const [entering] =
|
|
7747
|
+
const conversation = useContext12(ChatConversationContext);
|
|
7748
|
+
const [entering] = useState35(() => conversation?.ready.current ?? false);
|
|
7189
7749
|
return entering;
|
|
7190
7750
|
}
|
|
7191
7751
|
var formatters = /* @__PURE__ */ new Map();
|
|
@@ -7204,14 +7764,14 @@ function formattersFor(locale) {
|
|
|
7204
7764
|
function MessageTime({ time, locale }) {
|
|
7205
7765
|
const date = typeof time === "string" ? new Date(time) : time;
|
|
7206
7766
|
if (Number.isNaN(date.getTime())) {
|
|
7207
|
-
return /* @__PURE__ */
|
|
7767
|
+
return /* @__PURE__ */ jsx76("time", { className: "ow-chat-message__time", children: String(time) });
|
|
7208
7768
|
}
|
|
7209
7769
|
const { short, full } = formattersFor(locale);
|
|
7210
|
-
return /* @__PURE__ */
|
|
7770
|
+
return /* @__PURE__ */ jsx76("time", { className: "ow-chat-message__time", dateTime: date.toISOString(), title: full.format(date), children: short.format(date) });
|
|
7211
7771
|
}
|
|
7212
7772
|
var skipCaret = '[aria-hidden="true"], .ow-visually-hidden';
|
|
7213
7773
|
function useStreamingCaret(bodyRef, contentRef, caretRef, active) {
|
|
7214
|
-
|
|
7774
|
+
useLayoutEffect10(() => {
|
|
7215
7775
|
const body = bodyRef.current;
|
|
7216
7776
|
const content = contentRef.current;
|
|
7217
7777
|
const caret = caretRef.current;
|
|
@@ -7257,37 +7817,37 @@ function useStreamingCaret(bodyRef, contentRef, caretRef, active) {
|
|
|
7257
7817
|
}, [active, bodyRef, contentRef, caretRef]);
|
|
7258
7818
|
}
|
|
7259
7819
|
var ChatMessage = /* @__PURE__ */ forwardRef27(function ChatMessage2({ from, children, name, avatar, time, locale, status = "done", error, onRetry, retryLabel = "Retry", actions, showActions = "hover", className, ...props }, ref) {
|
|
7260
|
-
const conversation =
|
|
7820
|
+
const conversation = useContext12(ChatConversationContext);
|
|
7261
7821
|
const entering = useChatEntrance();
|
|
7262
|
-
const id =
|
|
7263
|
-
const bodyRef =
|
|
7264
|
-
const contentRef =
|
|
7265
|
-
const caretRef =
|
|
7822
|
+
const id = useId24();
|
|
7823
|
+
const bodyRef = useRef38(null);
|
|
7824
|
+
const contentRef = useRef38(null);
|
|
7825
|
+
const caretRef = useRef38(null);
|
|
7266
7826
|
const streaming = status === "streaming";
|
|
7267
7827
|
useEffect29(() => conversation?.register(id), [conversation, id]);
|
|
7268
7828
|
useStreamingCaret(bodyRef, contentRef, caretRef, streaming && from !== "system");
|
|
7269
7829
|
if (from === "system") {
|
|
7270
|
-
return /* @__PURE__ */
|
|
7830
|
+
return /* @__PURE__ */ jsx76(
|
|
7271
7831
|
"div",
|
|
7272
7832
|
{
|
|
7273
7833
|
ref,
|
|
7274
7834
|
className: cx("ow-chat-message", "ow-chat-message--system", entering && "ow-chat-message--enter", className),
|
|
7275
7835
|
...props,
|
|
7276
|
-
children: /* @__PURE__ */
|
|
7836
|
+
children: /* @__PURE__ */ jsxs56("span", { className: "ow-chat-message__system-text", children: [
|
|
7277
7837
|
children,
|
|
7278
|
-
time !== void 0 ? /* @__PURE__ */
|
|
7279
|
-
/* @__PURE__ */
|
|
7280
|
-
/* @__PURE__ */
|
|
7838
|
+
time !== void 0 ? /* @__PURE__ */ jsxs56(Fragment12, { children: [
|
|
7839
|
+
/* @__PURE__ */ jsx76("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
7840
|
+
/* @__PURE__ */ jsx76(MessageTime, { time, locale })
|
|
7281
7841
|
] }) : null
|
|
7282
7842
|
] })
|
|
7283
7843
|
}
|
|
7284
7844
|
);
|
|
7285
7845
|
}
|
|
7286
7846
|
const isUser = from === "user";
|
|
7287
|
-
const avatarNode = avatar !== void 0 ? avatar : isUser ? null : /* @__PURE__ */
|
|
7847
|
+
const avatarNode = avatar !== void 0 ? avatar : isUser ? null : /* @__PURE__ */ jsx76(ChatAgentAvatar, {});
|
|
7288
7848
|
const hasHeader = name != null || time !== void 0;
|
|
7289
7849
|
const errorText = error ?? (isUser ? "Couldn't send this message." : "The answer didn't finish.");
|
|
7290
|
-
return /* @__PURE__ */
|
|
7850
|
+
return /* @__PURE__ */ jsxs56(
|
|
7291
7851
|
"article",
|
|
7292
7852
|
{
|
|
7293
7853
|
ref,
|
|
@@ -7303,22 +7863,22 @@ var ChatMessage = /* @__PURE__ */ forwardRef27(function ChatMessage2({ from, chi
|
|
|
7303
7863
|
"aria-busy": streaming || void 0,
|
|
7304
7864
|
...props,
|
|
7305
7865
|
children: [
|
|
7306
|
-
avatarNode != null && avatarNode !== false ? /* @__PURE__ */
|
|
7307
|
-
/* @__PURE__ */
|
|
7308
|
-
hasHeader ? /* @__PURE__ */
|
|
7309
|
-
name != null ? /* @__PURE__ */
|
|
7310
|
-
time !== void 0 ? /* @__PURE__ */
|
|
7311
|
-
] }) : /* @__PURE__ */
|
|
7312
|
-
/* @__PURE__ */
|
|
7313
|
-
/* @__PURE__ */
|
|
7314
|
-
streaming ? /* @__PURE__ */
|
|
7866
|
+
avatarNode != null && avatarNode !== false ? /* @__PURE__ */ jsx76("div", { className: "ow-chat-message__avatar", children: avatarNode }) : null,
|
|
7867
|
+
/* @__PURE__ */ jsxs56("div", { className: "ow-chat-message__main", children: [
|
|
7868
|
+
hasHeader ? /* @__PURE__ */ jsxs56("div", { className: "ow-chat-message__header", children: [
|
|
7869
|
+
name != null ? /* @__PURE__ */ jsx76("span", { className: "ow-chat-message__name", children: name }) : /* @__PURE__ */ jsx76("span", { className: "ow-visually-hidden", children: isUser ? "You" : "Agent" }),
|
|
7870
|
+
time !== void 0 ? /* @__PURE__ */ jsx76(MessageTime, { time, locale }) : null
|
|
7871
|
+
] }) : /* @__PURE__ */ jsx76("span", { className: "ow-visually-hidden", children: isUser ? "You" : "Agent" }),
|
|
7872
|
+
/* @__PURE__ */ jsxs56("div", { ref: bodyRef, className: "ow-chat-message__body", children: [
|
|
7873
|
+
/* @__PURE__ */ jsx76("div", { ref: contentRef, className: "ow-chat-message__content", children }),
|
|
7874
|
+
streaming ? /* @__PURE__ */ jsx76("span", { ref: caretRef, className: "ow-chat-message__caret", "aria-hidden": "true" }) : null
|
|
7315
7875
|
] }),
|
|
7316
|
-
status === "error" ? /* @__PURE__ */
|
|
7317
|
-
/* @__PURE__ */
|
|
7318
|
-
/* @__PURE__ */
|
|
7319
|
-
onRetry ? /* @__PURE__ */
|
|
7876
|
+
status === "error" ? /* @__PURE__ */ jsxs56("div", { className: cx("ow-chat-message__error", onRetry && "ow-chat-message__error--retry"), children: [
|
|
7877
|
+
/* @__PURE__ */ jsx76(CircleAlertIcon, { size: 16, className: "ow-chat-message__error-icon" }),
|
|
7878
|
+
/* @__PURE__ */ jsx76("span", { className: "ow-chat-message__error-text", children: errorText }),
|
|
7879
|
+
onRetry ? /* @__PURE__ */ jsx76(Button, { size: "sm", startIcon: /* @__PURE__ */ jsx76(RotateCcwIcon, { size: 16 }), onClick: onRetry, children: retryLabel }) : null
|
|
7320
7880
|
] }) : null,
|
|
7321
|
-
actions && !streaming ? /* @__PURE__ */
|
|
7881
|
+
actions && !streaming ? /* @__PURE__ */ jsx76("div", { className: "ow-chat-message__actions", children: actions }) : null
|
|
7322
7882
|
] })
|
|
7323
7883
|
]
|
|
7324
7884
|
}
|
|
@@ -7326,12 +7886,12 @@ var ChatMessage = /* @__PURE__ */ forwardRef27(function ChatMessage2({ from, chi
|
|
|
7326
7886
|
});
|
|
7327
7887
|
var defaultLabels = { copy: "Copy", copied: "Copied", edit: "Edit", retry: "Retry", good: "Good response", bad: "Bad response" };
|
|
7328
7888
|
function CopyAction({ text, label, copiedLabel }) {
|
|
7329
|
-
const [copied, setCopied] =
|
|
7330
|
-
const timer =
|
|
7889
|
+
const [copied, setCopied] = useState35(false);
|
|
7890
|
+
const timer = useRef38(0);
|
|
7331
7891
|
useEffect29(() => () => window.clearTimeout(timer.current), []);
|
|
7332
7892
|
const current = copied ? copiedLabel : label;
|
|
7333
|
-
return /* @__PURE__ */
|
|
7334
|
-
/* @__PURE__ */
|
|
7893
|
+
return /* @__PURE__ */ jsxs56(Fragment12, { children: [
|
|
7894
|
+
/* @__PURE__ */ jsx76(Tooltip, { label: current, children: /* @__PURE__ */ jsx76(
|
|
7335
7895
|
Button,
|
|
7336
7896
|
{
|
|
7337
7897
|
variant: "ghost",
|
|
@@ -7346,13 +7906,13 @@ function CopyAction({ text, label, copiedLabel }) {
|
|
|
7346
7906
|
timer.current = window.setTimeout(() => setCopied(false), 2e3);
|
|
7347
7907
|
}
|
|
7348
7908
|
},
|
|
7349
|
-
children: /* @__PURE__ */
|
|
7350
|
-
/* @__PURE__ */
|
|
7351
|
-
/* @__PURE__ */
|
|
7909
|
+
children: /* @__PURE__ */ jsxs56("span", { className: "ow-chat-actions__copy-icon", children: [
|
|
7910
|
+
/* @__PURE__ */ jsx76(CopyIcon, { size: 16 }),
|
|
7911
|
+
/* @__PURE__ */ jsx76(CheckIcon, { size: 16 })
|
|
7352
7912
|
] })
|
|
7353
7913
|
}
|
|
7354
7914
|
) }),
|
|
7355
|
-
/* @__PURE__ */
|
|
7915
|
+
/* @__PURE__ */ jsx76("span", { className: "ow-visually-hidden", "aria-live": "polite", children: copied ? copiedLabel : "" })
|
|
7356
7916
|
] });
|
|
7357
7917
|
}
|
|
7358
7918
|
function ChatMessageActions({
|
|
@@ -7371,7 +7931,7 @@ function ChatMessageActions({
|
|
|
7371
7931
|
const [current, setCurrent] = useControllableState(rating, defaultRating, onRate);
|
|
7372
7932
|
const rate = (value, label, Icon) => {
|
|
7373
7933
|
const pressed = current === value;
|
|
7374
|
-
return /* @__PURE__ */
|
|
7934
|
+
return /* @__PURE__ */ jsx76(Tooltip, { label, children: /* @__PURE__ */ jsx76(
|
|
7375
7935
|
ToggleButton,
|
|
7376
7936
|
{
|
|
7377
7937
|
variant: "ghost",
|
|
@@ -7381,15 +7941,15 @@ function ChatMessageActions({
|
|
|
7381
7941
|
pressed,
|
|
7382
7942
|
className: "ow-chat-actions__rate",
|
|
7383
7943
|
onPressedChange: () => setCurrent(pressed ? null : value),
|
|
7384
|
-
children: /* @__PURE__ */
|
|
7944
|
+
children: /* @__PURE__ */ jsx76(Icon, { size: 16 })
|
|
7385
7945
|
}
|
|
7386
7946
|
) });
|
|
7387
7947
|
};
|
|
7388
|
-
return /* @__PURE__ */
|
|
7389
|
-
text !== void 0 ? /* @__PURE__ */
|
|
7390
|
-
onEdit ? /* @__PURE__ */
|
|
7391
|
-
onRetry ? /* @__PURE__ */
|
|
7392
|
-
onRate ? /* @__PURE__ */
|
|
7948
|
+
return /* @__PURE__ */ jsxs56(Toolbar, { variant: "plain", size: "sm", "aria-label": ariaLabel, className: cx("ow-chat-actions", className), children: [
|
|
7949
|
+
text !== void 0 ? /* @__PURE__ */ jsx76(CopyAction, { text, label: words.copy, copiedLabel: words.copied }) : null,
|
|
7950
|
+
onEdit ? /* @__PURE__ */ jsx76(Tooltip, { label: words.edit, children: /* @__PURE__ */ jsx76(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": words.edit, onClick: onEdit, children: /* @__PURE__ */ jsx76(PencilIcon, { size: 16 }) }) }) : null,
|
|
7951
|
+
onRetry ? /* @__PURE__ */ jsx76(Tooltip, { label: words.retry, children: /* @__PURE__ */ jsx76(Button, { variant: "ghost", size: "sm", iconOnly: true, "aria-label": words.retry, onClick: onRetry, children: /* @__PURE__ */ jsx76(RotateCcwIcon, { size: 16 }) }) }) : null,
|
|
7952
|
+
onRate ? /* @__PURE__ */ jsxs56(Fragment12, { children: [
|
|
7393
7953
|
rate("up", words.good, ThumbsUpIcon),
|
|
7394
7954
|
rate("down", words.bad, ThumbsDownIcon)
|
|
7395
7955
|
] }) : null,
|
|
@@ -7398,31 +7958,31 @@ function ChatMessageActions({
|
|
|
7398
7958
|
}
|
|
7399
7959
|
|
|
7400
7960
|
// src/components/Chat/ChatLoader.tsx
|
|
7401
|
-
import { jsx as
|
|
7961
|
+
import { jsx as jsx77, jsxs as jsxs57 } from "react/jsx-runtime";
|
|
7402
7962
|
function ChatLoader({ label, inline = false, name, avatar, srLabel = "Working\u2026", className }) {
|
|
7403
7963
|
const entering = useChatEntrance();
|
|
7404
|
-
const indicator = label != null ? /* @__PURE__ */
|
|
7405
|
-
/* @__PURE__ */
|
|
7406
|
-
/* @__PURE__ */
|
|
7407
|
-
/* @__PURE__ */
|
|
7408
|
-
/* @__PURE__ */
|
|
7964
|
+
const indicator = label != null ? /* @__PURE__ */ jsx77(TextShimmer, { className: "ow-chat-loader__label", children: label }) : /* @__PURE__ */ jsxs57("span", { className: "ow-chat-loader__dots", children: [
|
|
7965
|
+
/* @__PURE__ */ jsx77("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7966
|
+
/* @__PURE__ */ jsx77("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7967
|
+
/* @__PURE__ */ jsx77("span", { className: "ow-chat-loader__dot", "aria-hidden": "true" }),
|
|
7968
|
+
/* @__PURE__ */ jsx77("span", { className: "ow-visually-hidden", children: srLabel })
|
|
7409
7969
|
] });
|
|
7410
7970
|
if (inline) {
|
|
7411
|
-
return /* @__PURE__ */
|
|
7971
|
+
return /* @__PURE__ */ jsx77("span", { role: "status", className: cx("ow-chat-loader", "ow-chat-loader--inline", className), children: indicator });
|
|
7412
7972
|
}
|
|
7413
|
-
const avatarNode = avatar === void 0 ? /* @__PURE__ */
|
|
7414
|
-
return /* @__PURE__ */
|
|
7415
|
-
avatarNode != null && avatarNode !== false ? /* @__PURE__ */
|
|
7416
|
-
/* @__PURE__ */
|
|
7417
|
-
name != null ? /* @__PURE__ */
|
|
7418
|
-
/* @__PURE__ */
|
|
7973
|
+
const avatarNode = avatar === void 0 ? /* @__PURE__ */ jsx77(ChatAgentAvatar, {}) : avatar;
|
|
7974
|
+
return /* @__PURE__ */ jsxs57("div", { role: "status", className: cx("ow-chat-message", "ow-chat-message--assistant", "ow-chat-loader", entering && "ow-chat-loader--enter", className), children: [
|
|
7975
|
+
avatarNode != null && avatarNode !== false ? /* @__PURE__ */ jsx77("div", { className: "ow-chat-message__avatar", children: avatarNode }) : null,
|
|
7976
|
+
/* @__PURE__ */ jsxs57("div", { className: "ow-chat-message__main", children: [
|
|
7977
|
+
name != null ? /* @__PURE__ */ jsx77("div", { className: "ow-chat-message__header", children: /* @__PURE__ */ jsx77("span", { className: "ow-chat-message__name", children: name }) }) : null,
|
|
7978
|
+
/* @__PURE__ */ jsx77("div", { className: "ow-chat-loader__line", children: indicator })
|
|
7419
7979
|
] })
|
|
7420
7980
|
] });
|
|
7421
7981
|
}
|
|
7422
7982
|
|
|
7423
7983
|
// src/components/ChatTool/ChatTool.tsx
|
|
7424
|
-
import { forwardRef as forwardRef28, useEffect as useEffect30, useId as
|
|
7425
|
-
import { Fragment as
|
|
7984
|
+
import { forwardRef as forwardRef28, useEffect as useEffect30, useId as useId25, useRef as useRef39, useState as useState36 } from "react";
|
|
7985
|
+
import { Fragment as Fragment13, jsx as jsx78, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
7426
7986
|
var statusWords = {
|
|
7427
7987
|
pending: "Not started",
|
|
7428
7988
|
running: "Running",
|
|
@@ -7432,7 +7992,7 @@ var statusWords = {
|
|
|
7432
7992
|
cancelled: "Cancelled"
|
|
7433
7993
|
};
|
|
7434
7994
|
function SlashIcon() {
|
|
7435
|
-
return /* @__PURE__ */
|
|
7995
|
+
return /* @__PURE__ */ jsx78(
|
|
7436
7996
|
"svg",
|
|
7437
7997
|
{
|
|
7438
7998
|
width: 12,
|
|
@@ -7444,12 +8004,12 @@ function SlashIcon() {
|
|
|
7444
8004
|
strokeLinecap: "round",
|
|
7445
8005
|
"aria-hidden": "true",
|
|
7446
8006
|
focusable: "false",
|
|
7447
|
-
children: /* @__PURE__ */
|
|
8007
|
+
children: /* @__PURE__ */ jsx78("path", { d: "M7 17 17 7" })
|
|
7448
8008
|
}
|
|
7449
8009
|
);
|
|
7450
8010
|
}
|
|
7451
8011
|
function ExclamationIcon() {
|
|
7452
|
-
return /* @__PURE__ */
|
|
8012
|
+
return /* @__PURE__ */ jsxs58(
|
|
7453
8013
|
"svg",
|
|
7454
8014
|
{
|
|
7455
8015
|
width: 12,
|
|
@@ -7462,41 +8022,41 @@ function ExclamationIcon() {
|
|
|
7462
8022
|
"aria-hidden": "true",
|
|
7463
8023
|
focusable: "false",
|
|
7464
8024
|
children: [
|
|
7465
|
-
/* @__PURE__ */
|
|
7466
|
-
/* @__PURE__ */
|
|
8025
|
+
/* @__PURE__ */ jsx78("path", { d: "M12 5v9" }),
|
|
8026
|
+
/* @__PURE__ */ jsx78("path", { d: "M12 19h.01" })
|
|
7467
8027
|
]
|
|
7468
8028
|
}
|
|
7469
8029
|
);
|
|
7470
8030
|
}
|
|
7471
8031
|
function ChatStatusMarker({ status, icon: icon2 }) {
|
|
7472
8032
|
const showsIcon = Boolean(icon2) && (status === "success" || status === "pending");
|
|
7473
|
-
const glyph = status === "running" ? /* @__PURE__ */
|
|
7474
|
-
return /* @__PURE__ */
|
|
7475
|
-
/* @__PURE__ */
|
|
7476
|
-
/* @__PURE__ */
|
|
8033
|
+
const glyph = status === "running" ? /* @__PURE__ */ jsx78(Spinner, { size: "sm", label: "" }) : status === "error" ? /* @__PURE__ */ jsx78(XIcon, { size: 12, strokeWidth: 3 }) : status === "approval" ? /* @__PURE__ */ jsx78(ExclamationIcon, {}) : status === "cancelled" ? /* @__PURE__ */ jsx78(SlashIcon, {}) : showsIcon ? icon2 : status === "success" ? /* @__PURE__ */ jsx78(CheckIcon, { size: 12, strokeWidth: 3 }) : null;
|
|
8034
|
+
return /* @__PURE__ */ jsxs58("span", { className: cx("ow-chat-status", `ow-chat-status--${status}`, showsIcon && "ow-chat-status--icon"), children: [
|
|
8035
|
+
/* @__PURE__ */ jsx78("span", { className: "ow-chat-status__glyph", "aria-hidden": "true", children: glyph }),
|
|
8036
|
+
/* @__PURE__ */ jsxs58("span", { className: "ow-visually-hidden", children: [
|
|
7477
8037
|
statusWords[status],
|
|
7478
8038
|
": "
|
|
7479
8039
|
] })
|
|
7480
8040
|
] });
|
|
7481
8041
|
}
|
|
7482
8042
|
function formatDuration(ms, locale) {
|
|
7483
|
-
const
|
|
8043
|
+
const number2 = (value, digits = 0) => new Intl.NumberFormat(locale, { maximumFractionDigits: digits }).format(value);
|
|
7484
8044
|
const safe = Math.max(0, ms);
|
|
7485
|
-
if (safe < 1e3) return `${
|
|
8045
|
+
if (safe < 1e3) return `${number2(Math.round(safe))} ms`;
|
|
7486
8046
|
const seconds = safe / 1e3;
|
|
7487
|
-
if (seconds < 10) return `${
|
|
7488
|
-
if (seconds < 60) return `${
|
|
8047
|
+
if (seconds < 10) return `${number2(Math.floor(seconds * 10) / 10, 1)} s`;
|
|
8048
|
+
if (seconds < 60) return `${number2(Math.floor(seconds))} s`;
|
|
7489
8049
|
const minutes = Math.floor(seconds / 60);
|
|
7490
8050
|
if (minutes < 60) {
|
|
7491
8051
|
const rest2 = Math.floor(seconds % 60);
|
|
7492
|
-
return rest2 ? `${
|
|
8052
|
+
return rest2 ? `${number2(minutes)} min ${number2(rest2)} s` : `${number2(minutes)} min`;
|
|
7493
8053
|
}
|
|
7494
8054
|
const hours = Math.floor(minutes / 60);
|
|
7495
8055
|
const rest = minutes % 60;
|
|
7496
|
-
return rest ? `${
|
|
8056
|
+
return rest ? `${number2(hours)} h ${number2(rest)} min` : `${number2(hours)} h`;
|
|
7497
8057
|
}
|
|
7498
8058
|
function ChatDuration({ ms, locale, className }) {
|
|
7499
|
-
return /* @__PURE__ */
|
|
8059
|
+
return /* @__PURE__ */ jsx78("time", { dateTime: `PT${Math.max(0, Math.round(ms)) / 1e3}S`, className, children: formatDuration(ms, locale) });
|
|
7500
8060
|
}
|
|
7501
8061
|
function useStatusExpansion({
|
|
7502
8062
|
expanded,
|
|
@@ -7507,8 +8067,8 @@ function useStatusExpansion({
|
|
|
7507
8067
|
initial = wantsOpen
|
|
7508
8068
|
}) {
|
|
7509
8069
|
const [isOpen, setOpen] = useControllableState(expanded, defaultExpanded ?? initial, onExpandedChange);
|
|
7510
|
-
const touched =
|
|
7511
|
-
const previous =
|
|
8070
|
+
const touched = useRef39(false);
|
|
8071
|
+
const previous = useRef39(wantsOpen);
|
|
7512
8072
|
useEffect30(() => {
|
|
7513
8073
|
if (previous.current === wantsOpen) return;
|
|
7514
8074
|
previous.current = wantsOpen;
|
|
@@ -7535,11 +8095,11 @@ function ChatCollapse({
|
|
|
7535
8095
|
className,
|
|
7536
8096
|
children
|
|
7537
8097
|
}) {
|
|
7538
|
-
const ref =
|
|
8098
|
+
const ref = useRef39(null);
|
|
7539
8099
|
useEffect30(() => {
|
|
7540
8100
|
if (ref.current) ref.current.inert = !open;
|
|
7541
8101
|
}, [open]);
|
|
7542
|
-
return /* @__PURE__ */
|
|
8102
|
+
return /* @__PURE__ */ jsx78("div", { ref, id, className: cx("ow-chat-collapse", bleed && "ow-chat-collapse--bleed"), "data-open": open, children: /* @__PURE__ */ jsx78("div", { className: "ow-chat-collapse__clip", children: /* @__PURE__ */ jsx78("div", { className, children }) }) });
|
|
7543
8103
|
}
|
|
7544
8104
|
var codeMaxHeight = 280;
|
|
7545
8105
|
function formatInput(input) {
|
|
@@ -7572,12 +8132,12 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7572
8132
|
className,
|
|
7573
8133
|
...props
|
|
7574
8134
|
}, ref) {
|
|
7575
|
-
const id =
|
|
7576
|
-
const rootRef =
|
|
7577
|
-
const triggerRef =
|
|
7578
|
-
const messageRef =
|
|
7579
|
-
const decided =
|
|
7580
|
-
const [announcement, setAnnouncement] =
|
|
8135
|
+
const id = useId25();
|
|
8136
|
+
const rootRef = useRef39(null);
|
|
8137
|
+
const triggerRef = useRef39(null);
|
|
8138
|
+
const messageRef = useRef39(null);
|
|
8139
|
+
const decided = useRef39(false);
|
|
8140
|
+
const [announcement, setAnnouncement] = useState36("");
|
|
7581
8141
|
const needsApproval = status === "approval";
|
|
7582
8142
|
const [isOpen, toggle] = useStatusExpansion({
|
|
7583
8143
|
expanded,
|
|
@@ -7608,23 +8168,23 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7608
8168
|
if (!active || active === document.body) (triggerRef.current ?? rootRef.current)?.focus();
|
|
7609
8169
|
}, [needsApproval]);
|
|
7610
8170
|
const running = status === "running";
|
|
7611
|
-
const header = /* @__PURE__ */
|
|
7612
|
-
/* @__PURE__ */
|
|
7613
|
-
icon2 ? /* @__PURE__ */
|
|
7614
|
-
/* @__PURE__ */
|
|
7615
|
-
/* @__PURE__ */
|
|
7616
|
-
/* @__PURE__ */
|
|
7617
|
-
name ? /* @__PURE__ */
|
|
8171
|
+
const header = /* @__PURE__ */ jsxs58(Fragment13, { children: [
|
|
8172
|
+
/* @__PURE__ */ jsx78(ChatStatusMarker, { status }),
|
|
8173
|
+
icon2 ? /* @__PURE__ */ jsx78("span", { className: "ow-chat-tool__icon", "aria-hidden": "true", children: icon2 }) : null,
|
|
8174
|
+
/* @__PURE__ */ jsxs58("span", { className: "ow-chat-tool__main", children: [
|
|
8175
|
+
/* @__PURE__ */ jsxs58("span", { className: "ow-chat-tool__heading", children: [
|
|
8176
|
+
/* @__PURE__ */ jsx78("span", { className: "ow-chat-tool__title", children: running ? /* @__PURE__ */ jsx78(TextShimmer, { children: title }) : title }),
|
|
8177
|
+
name ? /* @__PURE__ */ jsx78(Code, { className: "ow-chat-tool__name", children: name }) : null
|
|
7618
8178
|
] }),
|
|
7619
|
-
hasMeta ? /* @__PURE__ */
|
|
7620
|
-
summary ? /* @__PURE__ */
|
|
7621
|
-
summary && duration !== void 0 ? /* @__PURE__ */
|
|
7622
|
-
duration !== void 0 ? /* @__PURE__ */
|
|
8179
|
+
hasMeta ? /* @__PURE__ */ jsxs58("span", { className: "ow-chat-tool__meta", children: [
|
|
8180
|
+
summary ? /* @__PURE__ */ jsx78("span", { className: "ow-chat-tool__summary", children: summary }) : null,
|
|
8181
|
+
summary && duration !== void 0 ? /* @__PURE__ */ jsx78("span", { className: "ow-chat-tool__dot", "aria-hidden": "true", children: "\xB7" }) : null,
|
|
8182
|
+
duration !== void 0 ? /* @__PURE__ */ jsx78(ChatDuration, { ms: duration, locale, className: "ow-chat-tool__duration" }) : null
|
|
7623
8183
|
] }) : null
|
|
7624
8184
|
] }),
|
|
7625
|
-
hasDetails ? /* @__PURE__ */
|
|
8185
|
+
hasDetails ? /* @__PURE__ */ jsx78("span", { className: "ow-chat-tool__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsx78(ChevronRightIcon, { size: 14 }) }) : null
|
|
7626
8186
|
] });
|
|
7627
|
-
return /* @__PURE__ */
|
|
8187
|
+
return /* @__PURE__ */ jsxs58(
|
|
7628
8188
|
"div",
|
|
7629
8189
|
{
|
|
7630
8190
|
ref: (element) => {
|
|
@@ -7639,7 +8199,7 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7639
8199
|
tabIndex: hasDetails ? void 0 : -1,
|
|
7640
8200
|
...props,
|
|
7641
8201
|
children: [
|
|
7642
|
-
hasDetails ? /* @__PURE__ */
|
|
8202
|
+
hasDetails ? /* @__PURE__ */ jsx78(
|
|
7643
8203
|
"button",
|
|
7644
8204
|
{
|
|
7645
8205
|
ref: triggerRef,
|
|
@@ -7651,28 +8211,28 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7651
8211
|
onClick: toggle,
|
|
7652
8212
|
children: header
|
|
7653
8213
|
}
|
|
7654
|
-
) : /* @__PURE__ */
|
|
7655
|
-
hasDetails ? /* @__PURE__ */
|
|
7656
|
-
hasInput ? /* @__PURE__ */
|
|
7657
|
-
/* @__PURE__ */
|
|
7658
|
-
typeof input === "string" && !input.includes("\n") ? /* @__PURE__ */
|
|
8214
|
+
) : /* @__PURE__ */ jsx78("div", { className: "ow-chat-tool__header", children: header }),
|
|
8215
|
+
hasDetails ? /* @__PURE__ */ jsxs58(ChatCollapse, { id: `${id}-details`, open: isOpen, className: "ow-chat-tool__details", children: [
|
|
8216
|
+
hasInput ? /* @__PURE__ */ jsxs58("div", { className: "ow-chat-tool__section", children: [
|
|
8217
|
+
/* @__PURE__ */ jsx78("span", { className: "ow-chat-tool__label", children: "Input" }),
|
|
8218
|
+
typeof input === "string" && !input.includes("\n") ? /* @__PURE__ */ jsx78(Snippet, { value: input, prompt: null }) : /* @__PURE__ */ jsx78(CodeBlock, { code: formatInput(input), language: typeof input === "string" ? void 0 : "json", maxHeight: codeMaxHeight })
|
|
7659
8219
|
] }) : null,
|
|
7660
|
-
hasOutput ? /* @__PURE__ */
|
|
7661
|
-
/* @__PURE__ */
|
|
7662
|
-
typeof output === "string" ? /* @__PURE__ */
|
|
8220
|
+
hasOutput ? /* @__PURE__ */ jsxs58("div", { className: "ow-chat-tool__section", children: [
|
|
8221
|
+
/* @__PURE__ */ jsx78("span", { className: "ow-chat-tool__label", children: "Output" }),
|
|
8222
|
+
typeof output === "string" ? /* @__PURE__ */ jsx78(CodeBlock, { code: output, maxHeight: codeMaxHeight }) : /* @__PURE__ */ jsx78("div", { className: "ow-chat-tool__output", children: output })
|
|
7663
8223
|
] }) : null,
|
|
7664
|
-
hasError ? /* @__PURE__ */
|
|
7665
|
-
/* @__PURE__ */
|
|
7666
|
-
/* @__PURE__ */
|
|
8224
|
+
hasError ? /* @__PURE__ */ jsxs58("div", { className: "ow-chat-tool__section", children: [
|
|
8225
|
+
/* @__PURE__ */ jsx78("span", { className: "ow-chat-tool__label", children: "Error" }),
|
|
8226
|
+
/* @__PURE__ */ jsx78("div", { className: "ow-chat-tool__error", children: error })
|
|
7667
8227
|
] }) : null
|
|
7668
8228
|
] }) : null,
|
|
7669
|
-
needsApproval ? /* @__PURE__ */
|
|
7670
|
-
/* @__PURE__ */
|
|
8229
|
+
needsApproval ? /* @__PURE__ */ jsxs58("div", { className: "ow-chat-tool__approval", role: "group", "aria-labelledby": `${id}-request`, children: [
|
|
8230
|
+
/* @__PURE__ */ jsx78("p", { ref: messageRef, id: `${id}-request`, className: "ow-chat-tool__request", children: approvalMessage ?? (name ? /* @__PURE__ */ jsxs58(Fragment13, { children: [
|
|
7671
8231
|
"Wants to run ",
|
|
7672
|
-
/* @__PURE__ */
|
|
8232
|
+
/* @__PURE__ */ jsx78(Code, { children: name })
|
|
7673
8233
|
] }) : "Wants to go ahead") }),
|
|
7674
|
-
/* @__PURE__ */
|
|
7675
|
-
/* @__PURE__ */
|
|
8234
|
+
/* @__PURE__ */ jsxs58("div", { className: "ow-chat-tool__actions", children: [
|
|
8235
|
+
/* @__PURE__ */ jsx78(
|
|
7676
8236
|
Button,
|
|
7677
8237
|
{
|
|
7678
8238
|
variant: "primary",
|
|
@@ -7684,7 +8244,7 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7684
8244
|
children: approveLabel
|
|
7685
8245
|
}
|
|
7686
8246
|
),
|
|
7687
|
-
/* @__PURE__ */
|
|
8247
|
+
/* @__PURE__ */ jsx78(
|
|
7688
8248
|
Button,
|
|
7689
8249
|
{
|
|
7690
8250
|
size: "sm",
|
|
@@ -7697,15 +8257,15 @@ var ChatTool = /* @__PURE__ */ forwardRef28(function ChatTool2({
|
|
|
7697
8257
|
)
|
|
7698
8258
|
] })
|
|
7699
8259
|
] }) : null,
|
|
7700
|
-
/* @__PURE__ */
|
|
8260
|
+
/* @__PURE__ */ jsx78("span", { className: "ow-visually-hidden", "aria-live": "polite", children: announcement })
|
|
7701
8261
|
]
|
|
7702
8262
|
}
|
|
7703
8263
|
);
|
|
7704
8264
|
});
|
|
7705
8265
|
|
|
7706
8266
|
// src/components/ChainOfThought/ChainOfThought.tsx
|
|
7707
|
-
import { forwardRef as forwardRef29, useId as
|
|
7708
|
-
import { jsx as
|
|
8267
|
+
import { forwardRef as forwardRef29, useId as useId26 } from "react";
|
|
8268
|
+
import { jsx as jsx79, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
7709
8269
|
var plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
7710
8270
|
var ChainOfThought = /* @__PURE__ */ forwardRef29(function ChainOfThought2({
|
|
7711
8271
|
steps = [],
|
|
@@ -7721,7 +8281,7 @@ var ChainOfThought = /* @__PURE__ */ forwardRef29(function ChainOfThought2({
|
|
|
7721
8281
|
className,
|
|
7722
8282
|
...props
|
|
7723
8283
|
}, ref) {
|
|
7724
|
-
const id =
|
|
8284
|
+
const id = useId26();
|
|
7725
8285
|
const running = status === "running";
|
|
7726
8286
|
const [isOpen, toggle] = useStatusExpansion({
|
|
7727
8287
|
expanded,
|
|
@@ -7737,30 +8297,30 @@ var ChainOfThought = /* @__PURE__ */ forwardRef29(function ChainOfThought2({
|
|
|
7737
8297
|
const failed = steps.filter((step) => step.status === "error").length;
|
|
7738
8298
|
const heading = label ?? (running ? "Thinking\u2026" : duration !== void 0 ? `Thought for ${formatDuration(duration, locale)}` : "Reasoning");
|
|
7739
8299
|
const count = steps.length > 0 ? running ? `${finished} of ${plural(steps.length, "step")}` : plural(steps.length, "step") : null;
|
|
7740
|
-
const headerText = /* @__PURE__ */
|
|
7741
|
-
/* @__PURE__ */
|
|
7742
|
-
count ? /* @__PURE__ */
|
|
7743
|
-
/* @__PURE__ */
|
|
8300
|
+
const headerText = /* @__PURE__ */ jsxs59("span", { className: "ow-chat-toggle__text", children: [
|
|
8301
|
+
/* @__PURE__ */ jsx79("span", { className: "ow-chain-of-thought__label", children: running ? /* @__PURE__ */ jsx79(TextShimmer, { children: heading }) : heading }),
|
|
8302
|
+
count ? /* @__PURE__ */ jsxs59("span", { className: "ow-chat-toggle__meta", children: [
|
|
8303
|
+
/* @__PURE__ */ jsx79("span", { "aria-hidden": "true", children: "\xB7 " }),
|
|
7744
8304
|
count,
|
|
7745
|
-
failed > 0 ? /* @__PURE__ */
|
|
8305
|
+
failed > 0 ? /* @__PURE__ */ jsxs59("span", { className: "ow-chain-of-thought__failed", children: [
|
|
7746
8306
|
", ",
|
|
7747
8307
|
failed,
|
|
7748
8308
|
" failed"
|
|
7749
8309
|
] }) : null
|
|
7750
8310
|
] }) : null
|
|
7751
8311
|
] });
|
|
7752
|
-
return /* @__PURE__ */
|
|
7753
|
-
hasBody ? /* @__PURE__ */
|
|
7754
|
-
/* @__PURE__ */
|
|
8312
|
+
return /* @__PURE__ */ jsxs59("div", { ref, className: cx("ow-chain-of-thought", className), "data-status": status, "aria-busy": running || void 0, ...props, children: [
|
|
8313
|
+
hasBody ? /* @__PURE__ */ jsxs59("button", { type: "button", className: "ow-chat-toggle", "aria-expanded": isOpen, "aria-controls": `${id}-body`, onClick: toggle, children: [
|
|
8314
|
+
/* @__PURE__ */ jsx79("span", { className: "ow-chat-toggle__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsx79(ChevronRightIcon, { size: 14 }) }),
|
|
7755
8315
|
headerText
|
|
7756
|
-
] }) : /* @__PURE__ */
|
|
7757
|
-
hasBody ? /* @__PURE__ */
|
|
7758
|
-
hasReasoning ? /* @__PURE__ */
|
|
7759
|
-
steps.length > 0 ? /* @__PURE__ */
|
|
7760
|
-
/* @__PURE__ */
|
|
7761
|
-
/* @__PURE__ */
|
|
7762
|
-
/* @__PURE__ */
|
|
7763
|
-
step.detail !== void 0 && step.detail !== null ? /* @__PURE__ */
|
|
8316
|
+
] }) : /* @__PURE__ */ jsx79("div", { className: "ow-chat-toggle ow-chain-of-thought__static", children: headerText }),
|
|
8317
|
+
hasBody ? /* @__PURE__ */ jsxs59(ChatCollapse, { id: `${id}-body`, open: isOpen, bleed: true, className: "ow-chain-of-thought__body", children: [
|
|
8318
|
+
hasReasoning ? /* @__PURE__ */ jsx79("div", { className: "ow-chain-of-thought__reasoning", children }) : null,
|
|
8319
|
+
steps.length > 0 ? /* @__PURE__ */ jsx79("ol", { className: "ow-chain-of-thought__steps", children: steps.map((step) => /* @__PURE__ */ jsxs59("li", { className: "ow-chain-of-thought__step", "data-status": step.status, children: [
|
|
8320
|
+
/* @__PURE__ */ jsx79(ChatStatusMarker, { status: step.status, icon: step.icon }),
|
|
8321
|
+
/* @__PURE__ */ jsxs59("div", { className: "ow-chain-of-thought__step-body", children: [
|
|
8322
|
+
/* @__PURE__ */ jsx79("span", { className: "ow-chain-of-thought__step-title", children: step.status === "running" ? /* @__PURE__ */ jsx79(TextShimmer, { children: step.title }) : step.title }),
|
|
8323
|
+
step.detail !== void 0 && step.detail !== null ? /* @__PURE__ */ jsx79("div", { className: "ow-chain-of-thought__detail", children: step.detail }) : null
|
|
7764
8324
|
] })
|
|
7765
8325
|
] }, step.id)) }) : null
|
|
7766
8326
|
] }) : null
|
|
@@ -7768,8 +8328,8 @@ var ChainOfThought = /* @__PURE__ */ forwardRef29(function ChainOfThought2({
|
|
|
7768
8328
|
});
|
|
7769
8329
|
|
|
7770
8330
|
// src/components/ChatSource/ChatSource.tsx
|
|
7771
|
-
import { forwardRef as forwardRef30, useCallback as
|
|
7772
|
-
import { Fragment as
|
|
8331
|
+
import { forwardRef as forwardRef30, useCallback as useCallback12, useEffect as useEffect31, useId as useId27, useRef as useRef40, useState as useState37 } from "react";
|
|
8332
|
+
import { Fragment as Fragment14, jsx as jsx80, jsxs as jsxs60 } from "react/jsx-runtime";
|
|
7773
8333
|
var openDelay = 250;
|
|
7774
8334
|
var closeDelay = 150;
|
|
7775
8335
|
var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
@@ -7787,13 +8347,13 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7787
8347
|
"aria-label": ariaLabel,
|
|
7788
8348
|
className
|
|
7789
8349
|
}, ref) {
|
|
7790
|
-
const id =
|
|
7791
|
-
const wrapperRef =
|
|
7792
|
-
const chipRef =
|
|
7793
|
-
const cardRef =
|
|
7794
|
-
const timer =
|
|
7795
|
-
const pointer =
|
|
7796
|
-
const [open, setOpen] =
|
|
8350
|
+
const id = useId27();
|
|
8351
|
+
const wrapperRef = useRef40(null);
|
|
8352
|
+
const chipRef = useRef40(null);
|
|
8353
|
+
const cardRef = useRef40(null);
|
|
8354
|
+
const timer = useRef40(0);
|
|
8355
|
+
const pointer = useRef40("mouse");
|
|
8356
|
+
const [open, setOpen] = useState37(false);
|
|
7797
8357
|
const { mounted, state } = usePresence(open);
|
|
7798
8358
|
const style = useFloating({ open: mounted, anchorRef: chipRef, floatingRef: cardRef, placement: "bottom-start", offset: 6, maxHeight: 360 });
|
|
7799
8359
|
const schedule = (next, delay) => {
|
|
@@ -7801,7 +8361,7 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7801
8361
|
if (delay === 0) setOpen(next);
|
|
7802
8362
|
else timer.current = window.setTimeout(() => setOpen(next), delay);
|
|
7803
8363
|
};
|
|
7804
|
-
const close =
|
|
8364
|
+
const close = useCallback12(() => {
|
|
7805
8365
|
window.clearTimeout(timer.current);
|
|
7806
8366
|
setOpen(false);
|
|
7807
8367
|
}, []);
|
|
@@ -7838,8 +8398,8 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7838
8398
|
onClick?.(event);
|
|
7839
8399
|
}
|
|
7840
8400
|
};
|
|
7841
|
-
const chipText = /* @__PURE__ */
|
|
7842
|
-
return /* @__PURE__ */
|
|
8401
|
+
const chipText = /* @__PURE__ */ jsx80("span", { className: "ow-chat-source__chip-text", children: index ?? label });
|
|
8402
|
+
return /* @__PURE__ */ jsxs60(
|
|
7843
8403
|
"span",
|
|
7844
8404
|
{
|
|
7845
8405
|
ref: wrapperRef,
|
|
@@ -7851,19 +8411,19 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7851
8411
|
if (event.pointerType === "mouse") schedule(false, closeDelay);
|
|
7852
8412
|
},
|
|
7853
8413
|
children: [
|
|
7854
|
-
href ? /* @__PURE__ */
|
|
7855
|
-
/* @__PURE__ */
|
|
7856
|
-
/* @__PURE__ */
|
|
7857
|
-
icon2 ? /* @__PURE__ */
|
|
7858
|
-
/* @__PURE__ */
|
|
8414
|
+
href ? /* @__PURE__ */ jsx80("a", { href, ...externalProps, ...chipProps, children: chipText }) : /* @__PURE__ */ jsx80("button", { type: "button", ...chipProps, children: chipText }),
|
|
8415
|
+
/* @__PURE__ */ jsxs60("span", { ref: cardRef, ...manualPopover, hidden: !mounted, "data-state": state, className: "ow-chat-source-card ow-floating", style, children: [
|
|
8416
|
+
/* @__PURE__ */ jsxs60("span", { className: "ow-chat-source-card__header", children: [
|
|
8417
|
+
icon2 ? /* @__PURE__ */ jsx80("span", { className: "ow-chat-source-card__icon", "aria-hidden": "true", children: icon2 }) : null,
|
|
8418
|
+
/* @__PURE__ */ jsx80("span", { id: `${id}-title`, className: "ow-chat-source-card__title", children: title })
|
|
7859
8419
|
] }),
|
|
7860
|
-
source ? /* @__PURE__ */
|
|
7861
|
-
snippet ? /* @__PURE__ */
|
|
8420
|
+
source ? /* @__PURE__ */ jsx80("span", { id: `${id}-source`, className: "ow-chat-source-card__source", children: source }) : null,
|
|
8421
|
+
snippet ? /* @__PURE__ */ jsx80("span", { id: `${id}-snippet`, className: cx("ow-chat-source-card__snippet", `ow-chat-source-card__snippet--${snippetFormat}`), children: snippet }) : null,
|
|
7862
8422
|
href ? (
|
|
7863
8423
|
// The chip is the same link, so this one stays out of the tab order.
|
|
7864
|
-
/* @__PURE__ */
|
|
8424
|
+
/* @__PURE__ */ jsxs60("a", { href, ...externalProps, tabIndex: -1, className: cx(linkClassName({ variant: "standalone" }), "ow-chat-source-card__open"), children: [
|
|
7865
8425
|
openLabel,
|
|
7866
|
-
/* @__PURE__ */
|
|
8426
|
+
/* @__PURE__ */ jsx80(ArrowUpRightIcon, { size: 13 })
|
|
7867
8427
|
] })
|
|
7868
8428
|
) : null
|
|
7869
8429
|
] })
|
|
@@ -7872,33 +8432,33 @@ var ChatSource = /* @__PURE__ */ forwardRef30(function ChatSource2({
|
|
|
7872
8432
|
);
|
|
7873
8433
|
});
|
|
7874
8434
|
var ChatSources = /* @__PURE__ */ forwardRef30(function ChatSources2({ sources, label, expanded, defaultExpanded = false, onExpandedChange, className, ...props }, ref) {
|
|
7875
|
-
const id =
|
|
8435
|
+
const id = useId27();
|
|
7876
8436
|
const [isOpen, setOpen] = useControllableState(expanded, defaultExpanded, onExpandedChange);
|
|
7877
8437
|
if (sources.length === 0) return null;
|
|
7878
|
-
return /* @__PURE__ */
|
|
7879
|
-
/* @__PURE__ */
|
|
7880
|
-
/* @__PURE__ */
|
|
7881
|
-
/* @__PURE__ */
|
|
8438
|
+
return /* @__PURE__ */ jsxs60("div", { ref, className: cx("ow-chat-sources", className), ...props, children: [
|
|
8439
|
+
/* @__PURE__ */ jsxs60("button", { type: "button", className: "ow-chat-toggle", "aria-expanded": isOpen, "aria-controls": `${id}-list`, onClick: () => setOpen(!isOpen), children: [
|
|
8440
|
+
/* @__PURE__ */ jsx80("span", { className: "ow-chat-toggle__chevron", "aria-hidden": "true", children: /* @__PURE__ */ jsx80(ChevronRightIcon, { size: 14 }) }),
|
|
8441
|
+
/* @__PURE__ */ jsx80("span", { className: "ow-chat-toggle__text", children: label ?? `${sources.length} ${sources.length === 1 ? "source" : "sources"}` })
|
|
7882
8442
|
] }),
|
|
7883
|
-
/* @__PURE__ */
|
|
7884
|
-
const content = /* @__PURE__ */
|
|
7885
|
-
/* @__PURE__ */
|
|
7886
|
-
item.index !== void 0 ? /* @__PURE__ */
|
|
7887
|
-
/* @__PURE__ */
|
|
8443
|
+
/* @__PURE__ */ jsx80(ChatCollapse, { id: `${id}-list`, open: isOpen, bleed: true, className: "ow-chat-sources__body", children: /* @__PURE__ */ jsx80("ul", { className: "ow-chat-sources__list", children: sources.map((item, position) => {
|
|
8444
|
+
const content = /* @__PURE__ */ jsxs60(Fragment14, { children: [
|
|
8445
|
+
/* @__PURE__ */ jsxs60("span", { className: "ow-chat-sources__lead", children: [
|
|
8446
|
+
item.index !== void 0 ? /* @__PURE__ */ jsxs60("span", { className: "ow-chat-sources__index", children: [
|
|
8447
|
+
/* @__PURE__ */ jsx80("span", { className: "ow-visually-hidden", children: "Source " }),
|
|
7888
8448
|
item.index
|
|
7889
8449
|
] }) : null,
|
|
7890
|
-
item.icon || item.index === void 0 ? /* @__PURE__ */
|
|
8450
|
+
item.icon || item.index === void 0 ? /* @__PURE__ */ jsx80("span", { className: "ow-chat-sources__icon", "aria-hidden": "true", children: item.icon ?? /* @__PURE__ */ jsx80(FileIcon, { size: 15 }) }) : null
|
|
7891
8451
|
] }),
|
|
7892
|
-
/* @__PURE__ */
|
|
7893
|
-
/* @__PURE__ */
|
|
7894
|
-
item.source ? /* @__PURE__ */
|
|
8452
|
+
/* @__PURE__ */ jsxs60("span", { className: "ow-chat-sources__text", children: [
|
|
8453
|
+
/* @__PURE__ */ jsx80("span", { className: "ow-chat-sources__title", children: item.title }),
|
|
8454
|
+
item.source ? /* @__PURE__ */ jsx80("span", { className: "ow-chat-sources__source", children: item.source }) : null
|
|
7895
8455
|
] }),
|
|
7896
|
-
item.href && item.external ? /* @__PURE__ */
|
|
7897
|
-
/* @__PURE__ */
|
|
7898
|
-
/* @__PURE__ */
|
|
8456
|
+
item.href && item.external ? /* @__PURE__ */ jsxs60(Fragment14, { children: [
|
|
8457
|
+
/* @__PURE__ */ jsx80("span", { className: "ow-chat-sources__external", "aria-hidden": "true", children: /* @__PURE__ */ jsx80(ArrowUpRightIcon, { size: 14 }) }),
|
|
8458
|
+
/* @__PURE__ */ jsx80("span", { className: "ow-visually-hidden", children: " (opens in a new tab)" })
|
|
7899
8459
|
] }) : null
|
|
7900
8460
|
] });
|
|
7901
|
-
return /* @__PURE__ */
|
|
8461
|
+
return /* @__PURE__ */ jsx80("li", { children: item.href ? /* @__PURE__ */ jsx80(
|
|
7902
8462
|
"a",
|
|
7903
8463
|
{
|
|
7904
8464
|
href: item.href,
|
|
@@ -7906,21 +8466,21 @@ var ChatSources = /* @__PURE__ */ forwardRef30(function ChatSources2({ sources,
|
|
|
7906
8466
|
...item.external ? { target: "_blank", rel: "noopener noreferrer" } : {},
|
|
7907
8467
|
children: content
|
|
7908
8468
|
}
|
|
7909
|
-
) : /* @__PURE__ */
|
|
8469
|
+
) : /* @__PURE__ */ jsx80("div", { className: "ow-chat-sources__card", children: content }) }, item.id ?? item.index ?? position);
|
|
7910
8470
|
}) }) })
|
|
7911
8471
|
] });
|
|
7912
8472
|
});
|
|
7913
8473
|
|
|
7914
8474
|
// src/components/ColorPicker/ColorPicker.tsx
|
|
7915
|
-
import { forwardRef as forwardRef31, useCallback as
|
|
8475
|
+
import { forwardRef as forwardRef31, useCallback as useCallback13, useEffect as useEffect32, useId as useId28, useRef as useRef41, useState as useState38 } from "react";
|
|
7916
8476
|
import { HexAlphaColorPicker, HexColorInput, HexColorPicker } from "react-colorful";
|
|
7917
|
-
import { Fragment as
|
|
8477
|
+
import { Fragment as Fragment15, jsx as jsx81, jsxs as jsxs61 } from "react/jsx-runtime";
|
|
7918
8478
|
var swatchColor = (swatch) => typeof swatch === "string" ? swatch : swatch.color;
|
|
7919
8479
|
var swatchName = (swatch) => typeof swatch === "string" ? swatch : swatch.name;
|
|
7920
8480
|
var same = (a, b) => a.toLowerCase().replace(/^#/, "") === b.toLowerCase().replace(/^#/, "");
|
|
7921
8481
|
function ColorPicker({
|
|
7922
8482
|
value,
|
|
7923
|
-
defaultValue = "#312c7e",
|
|
8483
|
+
defaultValue: defaultValue2 = "#312c7e",
|
|
7924
8484
|
onChange,
|
|
7925
8485
|
alpha = false,
|
|
7926
8486
|
swatches,
|
|
@@ -7929,9 +8489,9 @@ function ColorPicker({
|
|
|
7929
8489
|
"aria-label": ariaLabel = "Colour",
|
|
7930
8490
|
className
|
|
7931
8491
|
}) {
|
|
7932
|
-
const [color, setColor] = useControllableState(value,
|
|
7933
|
-
const [canPick, setCanPick] =
|
|
7934
|
-
const rootRef =
|
|
8492
|
+
const [color, setColor] = useControllableState(value, defaultValue2, onChange);
|
|
8493
|
+
const [canPick, setCanPick] = useState38(false);
|
|
8494
|
+
const rootRef = useRef41(null);
|
|
7935
8495
|
useEffect32(() => setCanPick(typeof window !== "undefined" && "EyeDropper" in window), []);
|
|
7936
8496
|
useEffect32(() => {
|
|
7937
8497
|
const names = { saturation: "Colour", hue: "Hue", alpha: "Opacity" };
|
|
@@ -7949,13 +8509,13 @@ function ColorPicker({
|
|
|
7949
8509
|
} catch {
|
|
7950
8510
|
}
|
|
7951
8511
|
}
|
|
7952
|
-
return /* @__PURE__ */
|
|
7953
|
-
/* @__PURE__ */
|
|
7954
|
-
showInput || eyeDropper && canPick ? /* @__PURE__ */
|
|
7955
|
-
eyeDropper && canPick ? /* @__PURE__ */
|
|
7956
|
-
showInput ? /* @__PURE__ */
|
|
7957
|
-
/* @__PURE__ */
|
|
7958
|
-
/* @__PURE__ */
|
|
8512
|
+
return /* @__PURE__ */ jsxs61("div", { ref: rootRef, role: "group", "aria-label": ariaLabel, className: cx("ow-color-picker", className), children: [
|
|
8513
|
+
/* @__PURE__ */ jsx81(Picker, { color, onChange: change }),
|
|
8514
|
+
showInput || eyeDropper && canPick ? /* @__PURE__ */ jsxs61("div", { className: "ow-color-picker__row", children: [
|
|
8515
|
+
eyeDropper && canPick ? /* @__PURE__ */ jsx81("button", { type: "button", className: "ow-color-picker__dropper", "aria-label": "Pick a colour from the screen", onClick: pickFromScreen, children: /* @__PURE__ */ jsx81(PipetteIcon, { size: 15 }) }) : null,
|
|
8516
|
+
showInput ? /* @__PURE__ */ jsxs61("span", { className: "ow-input-group ow-input-group--sm ow-color-picker__input", children: [
|
|
8517
|
+
/* @__PURE__ */ jsx81("span", { className: "ow-input-group__addon", "aria-hidden": "true", children: "#" }),
|
|
8518
|
+
/* @__PURE__ */ jsx81(
|
|
7959
8519
|
HexColorInput,
|
|
7960
8520
|
{
|
|
7961
8521
|
className: "ow-input-group__input",
|
|
@@ -7967,11 +8527,11 @@ function ColorPicker({
|
|
|
7967
8527
|
}
|
|
7968
8528
|
)
|
|
7969
8529
|
] }) : null,
|
|
7970
|
-
/* @__PURE__ */
|
|
8530
|
+
/* @__PURE__ */ jsx81("span", { className: "ow-color-picker__preview", style: { "--ow-color-picker-value": color }, "aria-hidden": "true" })
|
|
7971
8531
|
] }) : null,
|
|
7972
|
-
swatches?.length ? /* @__PURE__ */
|
|
8532
|
+
swatches?.length ? /* @__PURE__ */ jsx81("div", { className: "ow-color-picker__swatches", role: "group", "aria-label": "Swatches", children: swatches.map((swatch) => {
|
|
7973
8533
|
const swatchValue = swatchColor(swatch);
|
|
7974
|
-
return /* @__PURE__ */
|
|
8534
|
+
return /* @__PURE__ */ jsx81(
|
|
7975
8535
|
"button",
|
|
7976
8536
|
{
|
|
7977
8537
|
type: "button",
|
|
@@ -7993,7 +8553,7 @@ function assignRef7(ref, value) {
|
|
|
7993
8553
|
}
|
|
7994
8554
|
var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
7995
8555
|
value,
|
|
7996
|
-
defaultValue = "#312c7e",
|
|
8556
|
+
defaultValue: defaultValue2 = "#312c7e",
|
|
7997
8557
|
onChange,
|
|
7998
8558
|
size: size2 = "md",
|
|
7999
8559
|
isInvalid = false,
|
|
@@ -8006,14 +8566,14 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
8006
8566
|
"aria-describedby": ariaDescribedBy,
|
|
8007
8567
|
...pickerProps
|
|
8008
8568
|
}, ref) {
|
|
8009
|
-
const [color, setColor] = useControllableState(value,
|
|
8010
|
-
const [isOpen, setOpen] =
|
|
8011
|
-
const triggerRef =
|
|
8012
|
-
const panelRef =
|
|
8013
|
-
const panelId =
|
|
8569
|
+
const [color, setColor] = useControllableState(value, defaultValue2, onChange);
|
|
8570
|
+
const [isOpen, setOpen] = useState38(false);
|
|
8571
|
+
const triggerRef = useRef41(null);
|
|
8572
|
+
const panelRef = useRef41(null);
|
|
8573
|
+
const panelId = useId28();
|
|
8014
8574
|
const { mounted, state } = usePresence(isOpen);
|
|
8015
8575
|
const style = useFloating({ open: mounted, anchorRef: triggerRef, floatingRef: panelRef, placement, offset: 6, maxHeight: 640 });
|
|
8016
|
-
const close =
|
|
8576
|
+
const close = useCallback13((reason) => {
|
|
8017
8577
|
setOpen(false);
|
|
8018
8578
|
if (reason !== "outside") triggerRef.current?.focus();
|
|
8019
8579
|
}, []);
|
|
@@ -8023,8 +8583,8 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
8023
8583
|
const frame = requestAnimationFrame(() => panelRef.current?.querySelector(".react-colorful__interactive")?.focus());
|
|
8024
8584
|
return () => cancelAnimationFrame(frame);
|
|
8025
8585
|
}, [isOpen]);
|
|
8026
|
-
return /* @__PURE__ */
|
|
8027
|
-
/* @__PURE__ */
|
|
8586
|
+
return /* @__PURE__ */ jsxs61(Fragment15, { children: [
|
|
8587
|
+
/* @__PURE__ */ jsxs61(
|
|
8028
8588
|
"button",
|
|
8029
8589
|
{
|
|
8030
8590
|
ref: (element) => {
|
|
@@ -8056,13 +8616,13 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
8056
8616
|
}
|
|
8057
8617
|
},
|
|
8058
8618
|
children: [
|
|
8059
|
-
/* @__PURE__ */
|
|
8060
|
-
/* @__PURE__ */
|
|
8061
|
-
/* @__PURE__ */
|
|
8619
|
+
/* @__PURE__ */ jsx81("span", { className: "ow-color-field__swatch", style: { "--ow-color-picker-value": color }, "aria-hidden": "true" }),
|
|
8620
|
+
/* @__PURE__ */ jsx81("span", { id: `${panelId}-value`, className: "ow-select__value ow-color-field__value", children: color.toUpperCase() }),
|
|
8621
|
+
/* @__PURE__ */ jsx81(ChevronDownIcon, { size: size2 === "sm" ? 14 : 16, className: "ow-select__chevron" })
|
|
8062
8622
|
]
|
|
8063
8623
|
}
|
|
8064
8624
|
),
|
|
8065
|
-
mounted ? /* @__PURE__ */
|
|
8625
|
+
mounted ? /* @__PURE__ */ jsx81(
|
|
8066
8626
|
"div",
|
|
8067
8627
|
{
|
|
8068
8628
|
ref: panelRef,
|
|
@@ -8076,17 +8636,17 @@ var ColorField = /* @__PURE__ */ forwardRef31(function ColorField2({
|
|
|
8076
8636
|
onKeyDown: (event) => {
|
|
8077
8637
|
if (event.key === "Enter" && event.target.closest(".react-colorful")) close();
|
|
8078
8638
|
},
|
|
8079
|
-
children: /* @__PURE__ */
|
|
8639
|
+
children: /* @__PURE__ */ jsx81(ColorPicker, { ...pickerProps, value: color, onChange: setColor })
|
|
8080
8640
|
}
|
|
8081
8641
|
) : null
|
|
8082
8642
|
] });
|
|
8083
8643
|
});
|
|
8084
8644
|
|
|
8085
8645
|
// src/components/ColorPicker/ColorArea.tsx
|
|
8086
|
-
import { forwardRef as forwardRef32, useRef as
|
|
8646
|
+
import { forwardRef as forwardRef32, useRef as useRef43, useState as useState40 } from "react";
|
|
8087
8647
|
|
|
8088
8648
|
// src/components/ColorPicker/color.ts
|
|
8089
|
-
import { useCallback as
|
|
8649
|
+
import { useCallback as useCallback14, useReducer, useRef as useRef42, useState as useState39 } from "react";
|
|
8090
8650
|
var clamp2 = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
8091
8651
|
function parseHex(color) {
|
|
8092
8652
|
let hex = color.trim().replace(/^#/, "");
|
|
@@ -8161,9 +8721,9 @@ var hslModel = {
|
|
|
8161
8721
|
write: (model) => hsvToRgb(hslToHsv(model))
|
|
8162
8722
|
};
|
|
8163
8723
|
var fallback = { r: 0, g: 0, b: 0, a: 1 };
|
|
8164
|
-
function useColorModel(value,
|
|
8165
|
-
const [color, setColor] = useControllableState(value,
|
|
8166
|
-
const memory =
|
|
8724
|
+
function useColorModel(value, defaultValue2, onChange, model, { hue, alpha = false } = {}) {
|
|
8725
|
+
const [color, setColor] = useControllableState(value, defaultValue2, onChange);
|
|
8726
|
+
const memory = useRef42(null);
|
|
8167
8727
|
const [, rerender] = useReducer((n) => n + 1, 0);
|
|
8168
8728
|
const incoming = normalizeHex(color);
|
|
8169
8729
|
if (!memory.current || memory.current.hex !== incoming || memory.current.model !== model) {
|
|
@@ -8175,7 +8735,7 @@ function useColorModel(value, defaultValue, onChange, model, { hue, alpha = fals
|
|
|
8175
8735
|
const isGrey = rgba.r === rgba.g && rgba.g === rgba.b;
|
|
8176
8736
|
const current = isGrey && hue !== void 0 ? { ...memory.current.value, h: hue } : memory.current.value;
|
|
8177
8737
|
const withAlpha = alpha || hasAlpha(color);
|
|
8178
|
-
const set =
|
|
8738
|
+
const set = useCallback14(
|
|
8179
8739
|
(next) => {
|
|
8180
8740
|
const hex = toHex(model.write(next), withAlpha);
|
|
8181
8741
|
memory.current = { hex, model, value: next };
|
|
@@ -8185,7 +8745,7 @@ function useColorModel(value, defaultValue, onChange, model, { hue, alpha = fals
|
|
|
8185
8745
|
},
|
|
8186
8746
|
[model, withAlpha, setColor]
|
|
8187
8747
|
);
|
|
8188
|
-
const latest =
|
|
8748
|
+
const latest = useCallback14(() => memory.current?.hex ?? incoming, [incoming]);
|
|
8189
8749
|
return { value: current, rgba: model.write(current), hex: memory.current.hex, set, latest };
|
|
8190
8750
|
}
|
|
8191
8751
|
function useDrag({
|
|
@@ -8194,8 +8754,8 @@ function useDrag({
|
|
|
8194
8754
|
onStart,
|
|
8195
8755
|
disabled = false
|
|
8196
8756
|
}) {
|
|
8197
|
-
const [dragging, setDragging] =
|
|
8198
|
-
const [pointerFocus, setPointerFocus] =
|
|
8757
|
+
const [dragging, setDragging] = useState39(false);
|
|
8758
|
+
const [pointerFocus, setPointerFocus] = useState39(false);
|
|
8199
8759
|
const move = (event) => {
|
|
8200
8760
|
const rect = event.currentTarget.getBoundingClientRect();
|
|
8201
8761
|
onMove(clamp2((event.clientX - rect.left) / (rect.width || 1), 0, 1), clamp2((event.clientY - rect.top) / (rect.height || 1), 0, 1));
|
|
@@ -8267,7 +8827,7 @@ var hueHex = (h) => toHex(hsvToRgb({ h, s: 100, v: 100, a: 1 }));
|
|
|
8267
8827
|
var hueStops = "#ff0000 0%, #ffff00 16.67%, #00ff00 33.33%, #00ffff 50%, #0000ff 66.67%, #ff00ff 83.33%, #ff0000 100%";
|
|
8268
8828
|
|
|
8269
8829
|
// src/components/ColorPicker/ColorArea.tsx
|
|
8270
|
-
import { jsx as
|
|
8830
|
+
import { jsx as jsx82, jsxs as jsxs62 } from "react/jsx-runtime";
|
|
8271
8831
|
var size = (length) => typeof length === "number" ? `${length}px` : length;
|
|
8272
8832
|
function assignRef8(ref, value) {
|
|
8273
8833
|
if (typeof ref === "function") ref(value);
|
|
@@ -8275,7 +8835,7 @@ function assignRef8(ref, value) {
|
|
|
8275
8835
|
}
|
|
8276
8836
|
var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
8277
8837
|
value,
|
|
8278
|
-
defaultValue = "#312c7e",
|
|
8838
|
+
defaultValue: defaultValue2 = "#312c7e",
|
|
8279
8839
|
onChange,
|
|
8280
8840
|
onChangeEnd,
|
|
8281
8841
|
hue,
|
|
@@ -8290,10 +8850,10 @@ var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
|
8290
8850
|
id,
|
|
8291
8851
|
className
|
|
8292
8852
|
}, ref) {
|
|
8293
|
-
const { value: hsv, rgba, hex, set, latest } = useColorModel(value,
|
|
8294
|
-
const rootRef =
|
|
8295
|
-
const inputs =
|
|
8296
|
-
const [axis, setAxis] =
|
|
8853
|
+
const { value: hsv, rgba, hex, set, latest } = useColorModel(value, defaultValue2, onChange, hsvModel, { hue });
|
|
8854
|
+
const rootRef = useRef43(null);
|
|
8855
|
+
const inputs = useRef43({ x: null, y: null });
|
|
8856
|
+
const [axis, setAxis] = useState40("x");
|
|
8297
8857
|
const isRtl = () => rootRef.current ? getComputedStyle(rootRef.current).direction === "rtl" : false;
|
|
8298
8858
|
const end = () => onChangeEnd?.(latest());
|
|
8299
8859
|
const drag = useDrag({
|
|
@@ -8344,11 +8904,11 @@ var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
|
8344
8904
|
function onKeyUp(event) {
|
|
8345
8905
|
if (/^(Arrow|Page|Home|End)/.test(event.key)) end();
|
|
8346
8906
|
}
|
|
8347
|
-
const
|
|
8348
|
-
const saturation = `Saturation ${
|
|
8349
|
-
const brightness = `brightness ${
|
|
8907
|
+
const percent2 = new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 });
|
|
8908
|
+
const saturation = `Saturation ${percent2.format(hsv.s / 100)}`;
|
|
8909
|
+
const brightness = `brightness ${percent2.format(hsv.v / 100)}`;
|
|
8350
8910
|
const colorName = describeColor(rgba);
|
|
8351
|
-
const input = (which) => /* @__PURE__ */
|
|
8911
|
+
const input = (which) => /* @__PURE__ */ jsx82(
|
|
8352
8912
|
"input",
|
|
8353
8913
|
{
|
|
8354
8914
|
ref: (element) => {
|
|
@@ -8375,7 +8935,7 @@ var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
|
8375
8935
|
onKeyUp
|
|
8376
8936
|
}
|
|
8377
8937
|
);
|
|
8378
|
-
return /* @__PURE__ */
|
|
8938
|
+
return /* @__PURE__ */ jsxs62(
|
|
8379
8939
|
"div",
|
|
8380
8940
|
{
|
|
8381
8941
|
ref: rootRef,
|
|
@@ -8396,7 +8956,7 @@ var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
|
8396
8956
|
},
|
|
8397
8957
|
...drag.handlers,
|
|
8398
8958
|
children: [
|
|
8399
|
-
/* @__PURE__ */
|
|
8959
|
+
/* @__PURE__ */ jsxs62(
|
|
8400
8960
|
"div",
|
|
8401
8961
|
{
|
|
8402
8962
|
className: "ow-color-area__thumb",
|
|
@@ -8407,15 +8967,15 @@ var ColorArea = /* @__PURE__ */ forwardRef32(function ColorArea2({
|
|
|
8407
8967
|
]
|
|
8408
8968
|
}
|
|
8409
8969
|
),
|
|
8410
|
-
name ? /* @__PURE__ */
|
|
8970
|
+
name ? /* @__PURE__ */ jsx82("input", { type: "hidden", name, value: hex }) : null
|
|
8411
8971
|
]
|
|
8412
8972
|
}
|
|
8413
8973
|
);
|
|
8414
8974
|
});
|
|
8415
8975
|
|
|
8416
8976
|
// src/components/ColorPicker/ColorSlider.tsx
|
|
8417
|
-
import { forwardRef as forwardRef33, useId as
|
|
8418
|
-
import { jsx as
|
|
8977
|
+
import { forwardRef as forwardRef33, useId as useId29, useRef as useRef44 } from "react";
|
|
8978
|
+
import { jsx as jsx83, jsxs as jsxs63 } from "react/jsx-runtime";
|
|
8419
8979
|
var channels = {
|
|
8420
8980
|
hue: { name: "Hue", max: 360, unit: "degree" },
|
|
8421
8981
|
saturation: { name: "Saturation", max: 100, unit: "percent" },
|
|
@@ -8465,7 +9025,7 @@ function assignRef9(ref, value) {
|
|
|
8465
9025
|
var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
8466
9026
|
channel,
|
|
8467
9027
|
value,
|
|
8468
|
-
defaultValue = "#312c7e",
|
|
9028
|
+
defaultValue: defaultValue2 = "#312c7e",
|
|
8469
9029
|
onChange,
|
|
8470
9030
|
onChangeEnd,
|
|
8471
9031
|
hue,
|
|
@@ -8484,15 +9044,15 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8484
9044
|
}, ref) {
|
|
8485
9045
|
const spec = channels[channel];
|
|
8486
9046
|
const isHsl = channel === "saturation" || channel === "lightness";
|
|
8487
|
-
const color = useColorModel(value,
|
|
9047
|
+
const color = useColorModel(value, defaultValue2, onChange, isHsl ? hslModel : hsvModel, {
|
|
8488
9048
|
hue,
|
|
8489
9049
|
alpha: channel === "alpha"
|
|
8490
9050
|
});
|
|
8491
9051
|
const { rgba, latest } = color;
|
|
8492
9052
|
const current = read(channel, color.value, rgba);
|
|
8493
|
-
const labelId =
|
|
8494
|
-
const trackRef =
|
|
8495
|
-
const inputRef =
|
|
9053
|
+
const labelId = useId29();
|
|
9054
|
+
const trackRef = useRef44(null);
|
|
9055
|
+
const inputRef = useRef44(null);
|
|
8496
9056
|
const vertical = orientation === "vertical";
|
|
8497
9057
|
const isRtl = () => !vertical && trackRef.current !== null && getComputedStyle(trackRef.current).direction === "rtl";
|
|
8498
9058
|
const end = () => onChangeEnd?.(latest());
|
|
@@ -8530,7 +9090,7 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8530
9090
|
const shown = format.format(spec.unit === "percent" ? current / 100 : current);
|
|
8531
9091
|
const named = channel === "hue" ? describeColor(parseHex(hueHex(color.value.h))) : describeColor({ ...rgba, a: 1 });
|
|
8532
9092
|
const fill = channel === "hue" ? hueHex(color.value.h) : toHex(rgba, channel === "alpha");
|
|
8533
|
-
return /* @__PURE__ */
|
|
9093
|
+
return /* @__PURE__ */ jsxs63(
|
|
8534
9094
|
"div",
|
|
8535
9095
|
{
|
|
8536
9096
|
className: cx(
|
|
@@ -8545,11 +9105,11 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8545
9105
|
className
|
|
8546
9106
|
),
|
|
8547
9107
|
children: [
|
|
8548
|
-
label || showValue ? /* @__PURE__ */
|
|
8549
|
-
label ? /* @__PURE__ */
|
|
8550
|
-
showValue ? /* @__PURE__ */
|
|
9108
|
+
label || showValue ? /* @__PURE__ */ jsxs63("div", { className: "ow-color-slider__header", children: [
|
|
9109
|
+
label ? /* @__PURE__ */ jsx83("span", { id: labelId, className: "ow-color-slider__label", children: label }) : /* @__PURE__ */ jsx83("span", {}),
|
|
9110
|
+
showValue ? /* @__PURE__ */ jsx83("output", { className: "ow-color-slider__value", "aria-hidden": "true", children: shown }) : null
|
|
8551
9111
|
] }) : null,
|
|
8552
|
-
/* @__PURE__ */
|
|
9112
|
+
/* @__PURE__ */ jsx83(
|
|
8553
9113
|
"div",
|
|
8554
9114
|
{
|
|
8555
9115
|
ref: trackRef,
|
|
@@ -8558,12 +9118,12 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8558
9118
|
"--ow-color-slider-gradient": `linear-gradient(var(--ow-color-slider-direction), ${gradient(channel, color.value, rgba)})`
|
|
8559
9119
|
},
|
|
8560
9120
|
...drag.handlers,
|
|
8561
|
-
children: /* @__PURE__ */
|
|
9121
|
+
children: /* @__PURE__ */ jsx83(
|
|
8562
9122
|
"div",
|
|
8563
9123
|
{
|
|
8564
9124
|
className: "ow-color-slider__thumb",
|
|
8565
9125
|
style: { "--ow-color-slider-position": `${current / spec.max * 100}%`, "--ow-color-slider-thumb": fill },
|
|
8566
|
-
children: /* @__PURE__ */
|
|
9126
|
+
children: /* @__PURE__ */ jsx83(
|
|
8567
9127
|
"input",
|
|
8568
9128
|
{
|
|
8569
9129
|
ref: (element) => {
|
|
@@ -8595,18 +9155,18 @@ var ColorSlider = /* @__PURE__ */ forwardRef33(function ColorSlider2({
|
|
|
8595
9155
|
)
|
|
8596
9156
|
}
|
|
8597
9157
|
),
|
|
8598
|
-
name ? /* @__PURE__ */
|
|
9158
|
+
name ? /* @__PURE__ */ jsx83("input", { type: "hidden", name, value: color.hex }) : null
|
|
8599
9159
|
]
|
|
8600
9160
|
}
|
|
8601
9161
|
);
|
|
8602
9162
|
});
|
|
8603
9163
|
|
|
8604
9164
|
// src/components/ColorPicker/ColorSwatchPicker.tsx
|
|
8605
|
-
import { forwardRef as forwardRef34, useRef as
|
|
8606
|
-
import { jsx as
|
|
8607
|
-
var ColorSwatchPicker = /* @__PURE__ */ forwardRef34(function ColorSwatchPicker2({ options, value, defaultValue, onChange, size: size2 = "md", shape = "square", disabled = false, name, className, ...aria }, ref) {
|
|
8608
|
-
const [current, setCurrent] = useControllableState(value,
|
|
8609
|
-
const refs =
|
|
9165
|
+
import { forwardRef as forwardRef34, useRef as useRef45 } from "react";
|
|
9166
|
+
import { jsx as jsx84, jsxs as jsxs64 } from "react/jsx-runtime";
|
|
9167
|
+
var ColorSwatchPicker = /* @__PURE__ */ forwardRef34(function ColorSwatchPicker2({ options, value, defaultValue: defaultValue2, onChange, size: size2 = "md", shape = "square", disabled = false, name, className, ...aria }, ref) {
|
|
9168
|
+
const [current, setCurrent] = useControllableState(value, defaultValue2 ?? "", onChange);
|
|
9169
|
+
const refs = useRef45([]);
|
|
8610
9170
|
const items2 = options.map((option) => {
|
|
8611
9171
|
const item = typeof option === "string" ? { value: option } : option;
|
|
8612
9172
|
const rgba = parseHex(item.value);
|
|
@@ -8640,7 +9200,7 @@ var ColorSwatchPicker = /* @__PURE__ */ forwardRef34(function ColorSwatchPicker2
|
|
|
8640
9200
|
refs.current[target]?.focus();
|
|
8641
9201
|
choose(target);
|
|
8642
9202
|
}
|
|
8643
|
-
return /* @__PURE__ */
|
|
9203
|
+
return /* @__PURE__ */ jsxs64(
|
|
8644
9204
|
"div",
|
|
8645
9205
|
{
|
|
8646
9206
|
ref,
|
|
@@ -8657,7 +9217,7 @@ var ColorSwatchPicker = /* @__PURE__ */ forwardRef34(function ColorSwatchPicker2
|
|
|
8657
9217
|
items2.map((item, index) => {
|
|
8658
9218
|
const isSelected = index === selectedIndex;
|
|
8659
9219
|
const isDisabled = disabled || Boolean(item.disabled);
|
|
8660
|
-
return /* @__PURE__ */
|
|
9220
|
+
return /* @__PURE__ */ jsx84(
|
|
8661
9221
|
"div",
|
|
8662
9222
|
{
|
|
8663
9223
|
ref: (element) => {
|
|
@@ -8674,12 +9234,12 @@ var ColorSwatchPicker = /* @__PURE__ */ forwardRef34(function ColorSwatchPicker2
|
|
|
8674
9234
|
style: { "--ow-color-swatch-picker-value": item.value },
|
|
8675
9235
|
onClick: () => choose(index),
|
|
8676
9236
|
onKeyDown: (event) => onKeyDown(event, index),
|
|
8677
|
-
children: /* @__PURE__ */
|
|
9237
|
+
children: /* @__PURE__ */ jsx84(CheckIcon, { size: size2 === "sm" ? 14 : 16, strokeWidth: 2.5, className: "ow-color-swatch-picker__check", "aria-hidden": "true" })
|
|
8678
9238
|
},
|
|
8679
9239
|
`${item.value}-${index}`
|
|
8680
9240
|
);
|
|
8681
9241
|
}),
|
|
8682
|
-
name ? /* @__PURE__ */
|
|
9242
|
+
name ? /* @__PURE__ */ jsx84("input", { type: "hidden", name, value: selectedIndex >= 0 ? items2[selectedIndex].value : "" }) : null
|
|
8683
9243
|
]
|
|
8684
9244
|
}
|
|
8685
9245
|
);
|
|
@@ -8881,9 +9441,11 @@ export {
|
|
|
8881
9441
|
Accordion,
|
|
8882
9442
|
AccordionItem,
|
|
8883
9443
|
Alert,
|
|
9444
|
+
AppShell,
|
|
8884
9445
|
Avatar,
|
|
8885
9446
|
AvatarGroup,
|
|
8886
9447
|
Badge,
|
|
9448
|
+
BarChart,
|
|
8887
9449
|
Breadcrumbs,
|
|
8888
9450
|
Button,
|
|
8889
9451
|
ButtonGroup,
|
|
@@ -8921,6 +9483,7 @@ export {
|
|
|
8921
9483
|
DateRangePicker,
|
|
8922
9484
|
Dialog,
|
|
8923
9485
|
Disclosure,
|
|
9486
|
+
DonutChart,
|
|
8924
9487
|
DotGrid,
|
|
8925
9488
|
Drawer,
|
|
8926
9489
|
EmptyState,
|
|
@@ -8933,6 +9496,7 @@ export {
|
|
|
8933
9496
|
Input,
|
|
8934
9497
|
InputOTP,
|
|
8935
9498
|
Kbd,
|
|
9499
|
+
LineChart,
|
|
8936
9500
|
Link,
|
|
8937
9501
|
ListBox,
|
|
8938
9502
|
Menu,
|
|
@@ -8962,11 +9526,16 @@ export {
|
|
|
8962
9526
|
Select,
|
|
8963
9527
|
Separator,
|
|
8964
9528
|
SettingsRow,
|
|
9529
|
+
SidebarContent,
|
|
9530
|
+
SidebarFooter,
|
|
9531
|
+
SidebarHeader,
|
|
9532
|
+
SidebarToggle,
|
|
8965
9533
|
SiteHeader,
|
|
8966
9534
|
Skeleton,
|
|
8967
9535
|
SkeletonRows,
|
|
8968
9536
|
Slider,
|
|
8969
9537
|
Snippet,
|
|
9538
|
+
Sparkline2 as Sparkline,
|
|
8970
9539
|
Spinner,
|
|
8971
9540
|
Stack,
|
|
8972
9541
|
Stat,
|
|
@@ -9012,6 +9581,7 @@ export {
|
|
|
9012
9581
|
toISO,
|
|
9013
9582
|
toast,
|
|
9014
9583
|
todayISO,
|
|
9584
|
+
useAppShell,
|
|
9015
9585
|
useControllableState,
|
|
9016
9586
|
useDismiss,
|
|
9017
9587
|
useFloating,
|