@discuss-ds/ui 0.31.0 → 0.33.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/CHANGELOG.md +42 -0
- package/dist/index.cjs +208 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -5
- package/dist/index.d.ts +19 -5
- package/dist/index.js +220 -86
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/styles/globals.css +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @discuss-ds/ui
|
|
2
2
|
|
|
3
|
+
## 0.33.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#121](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/121) [`45858be`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/45858beb03a60f335a8a110ebc099bee02053e62) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `InlineEdit` marks (and the marks in `QuestionOptionEditor` and the question header) take two new optional properties. `tone: 'warning'` underlines the words in the warning colour instead of the destructive one, for a recommendation rather than a mistake. `message` adds a short rationale to the mark's card, above the suggestions. Without them nothing changes: a mark is still a destructive underline with a card that has the marked text, its corrections and Dismiss.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#129](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/129) [`db76aa7`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/db76aa7b7887312494fa3f8239a3a5d344dddb28) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - While a field with marks is edited, a `warning` mark keeps its highlight behind the words (as well as its underline), and the browser's text selection shows over it. The highlight layer now sits behind the field, which is transparent for the time it is edited.
|
|
12
|
+
|
|
13
|
+
- [#131](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/131) [`f5a6599`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/f5a6599e02acf524f01ddda4ccaf739b456e7879) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - While a field with marks is edited, the highlight and underline of a mark now have the same geometry as when it is not edited: the first line reaches the top of the field and the last line's underline lands on the field's own bottom border (covering it). The highlight is drawn behind the field (the text selection still shows over it) and the underline in a layer over the field. Before, while editing they stopped about 4px short of the field's top and bottom edges.
|
|
14
|
+
|
|
15
|
+
- [#127](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/127) [`a168e3f`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/a168e3f07c3dbe78561b056dbc06135938e43f97) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - In the card of a `warning` mark in `InlineEdit` (and the other text fields that mark words), the struck-through words use the destructive foreground color, as in the card of any other mark, and the `message` comes after the correction and before the buttons.
|
|
16
|
+
|
|
17
|
+
- [#125](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/125) [`31992d1`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/31992d1bb4cfd93817c9d2f1cf3423e27e6f9da2) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - A `warning` mark in `InlineEdit` (and the other text fields that mark words) is highlighted in dandelion 100 behind the words, and its card is the regular card (the same background and border as any mark's card) with Dismiss and Apply together at the right. A default (destructive) mark is unchanged.
|
|
18
|
+
|
|
19
|
+
- [#123](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/123) [`73f0a37`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/73f0a37a8794839e070ffc8ac456e42a7e003a25) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - The card of a `warning` mark in `InlineEdit` (and the other text fields that mark words) has the background and border of the warning inline message, and its Dismiss and Apply buttons sit together at the right. The card of a default (destructive) mark is unchanged.
|
|
20
|
+
|
|
21
|
+
- [#124](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/124) [`b2b0c71`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/b2b0c7101a279cb5477546125aa8338c2f5e3345) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - A `warning` mark in `InlineEdit` (and the other text fields that mark words) has the warning soft background behind the words as well as the warning underline. A default (destructive) mark is unchanged.
|
|
22
|
+
|
|
23
|
+
- [#130](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/130) [`5ea9e71`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/5ea9e71957b5106e7cafb168a45215b0818a68e2) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - The highlight and underline of a mark are now drawn per line of the marked words instead of with one padding for the whole word. On a title that wraps, the first line reaches the top of the field and the last line's underline lands exactly on the field's own bottom border (covering it), as a single-line word already did; before, the last line stopped a few pixels short. Visually unchanged for a word on one line. The marked word keeps its place in the text and its click; `data-tone` on it tells the tone of the mark.
|
|
24
|
+
|
|
25
|
+
- [#128](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/128) [`755b6d4`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/755b6d4462b14068480ad3ebf11e914c0f05b41f) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - The underlines of `marks` (in `InlineEdit`, the question header and `QuestionOptionEditor`) now stay while the field is being edited, as plain lines that take no click. They move with the text typed before them and go away when the words they mark are changed. Before, they disappeared as soon as the field was opened.
|
|
26
|
+
|
|
27
|
+
- [#126](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/126) [`6127b20`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/6127b2066d9f15fb311bbb90d0e65c2f26cfb977) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - New color token `--sys-color-warning-background-highlight` (Tailwind: `bg-warning-background-highlight`): the highlight behind words that carry a warning. It is dandelion 100 in light mode and dandelion 800 in dark mode. A `warning` mark in `InlineEdit` (and the other text fields that mark words) uses it instead of a fixed dandelion shade, so the highlight follows the theme.
|
|
28
|
+
- Updated dependencies [[`6127b20`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/6127b2066d9f15fb311bbb90d0e65c2f26cfb977)]:
|
|
29
|
+
- @discuss-ds/tokens@0.3.0
|
|
30
|
+
|
|
31
|
+
## 0.32.0
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- [#119](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/119) [`15ebfed`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/15ebfed6c3ae07ffc4dd35477b21db154178b082) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `StatCard` takes an optional `caption`: small muted text under the value that says what it refers to or breaks it down, such as "11 open-ended · 5 closed-ended". Without it the card is unchanged.
|
|
36
|
+
|
|
37
|
+
- [#120](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/120) [`019b943`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/019b94332ddcb818d0116aa87ce6d060991a2fdc) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - `ToastInline` takes an optional `actionsPlacement`: `"end"` (default, unchanged) keeps the actions after the message on the same line, `"bottom"` puts them under the message, for messages long enough to wrap.
|
|
38
|
+
|
|
39
|
+
- [#116](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/116) [`d197db4`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/d197db4524765401c77d60f54d20da020dcc8678) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - Question types now include `upload-video`, `upload-photo` and `upload-document`, each with its own icon (a video, an image, a document file) in `QuestionTypeIcon`, `QuestionNavItem` and `QuestionEditorCard`/`QuestionHeader` (the `questionType` prop). The generic `upload` type and its icon are unchanged, so nothing existing needs to change.
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- [#118](https://github.com/TamyresLucas/Discuss-UI-Storybook/pull/118) [`9aacac2`](https://github.com/TamyresLucas/Discuss-UI-Storybook/commit/9aacac2c16147e393c89cc7c4ea696dc092b2c40) Thanks [@TamyresLucas](https://github.com/TamyresLucas)! - The `upload-video` question type now uses the video camera icon (Phosphor `VideoCamera`, the same glyph as `screen-recording`) and `upload-document` the file-with-text icon (Phosphor `FileText`), in `QuestionTypeIcon`, `QuestionNavItem` and `QuestionEditorCard`/`QuestionHeader`. `upload-photo` keeps the image icon.
|
|
44
|
+
|
|
3
45
|
## 0.31.0
|
|
4
46
|
|
|
5
47
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1615,37 +1615,96 @@ function splitMarks(text, marks) {
|
|
|
1615
1615
|
if (at < text.length) out.push({ text: text.slice(at) });
|
|
1616
1616
|
return out;
|
|
1617
1617
|
}
|
|
1618
|
-
var
|
|
1619
|
-
function
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1618
|
+
var lineClasses = (tone, hovered) => cn("pointer-events-none absolute -z-10 rounded-xxs border-b-2", tone === "warning" ? "border-warning-foreground bg-warning-background-highlight" : cn("border-destructive-foreground", hovered && "bg-destructive-soft"));
|
|
1619
|
+
function markLines(rects, origin, field) {
|
|
1620
|
+
const count = field ? Math.max(1, Math.round((field.contentBottom - field.contentTop) / field.lineHeight)) : 1;
|
|
1621
|
+
const boxes = rects.filter((r) => r.width > 0).map((r) => {
|
|
1622
|
+
if (!field) return { left: r.left - origin.left, top: r.top - origin.top, width: r.width, height: r.height };
|
|
1623
|
+
const index = Math.min(count - 1, Math.max(0, Math.floor((r.top + r.height / 2 - field.contentTop) / field.lineHeight)));
|
|
1624
|
+
const top = index === 0 ? field.top : field.contentTop + index * field.lineHeight;
|
|
1625
|
+
const bottom = index === count - 1 ? field.bottom : field.contentTop + (index + 1) * field.lineHeight;
|
|
1626
|
+
return { left: r.left - origin.left, top: top - origin.top, width: r.width, height: bottom - top };
|
|
1627
|
+
});
|
|
1628
|
+
return boxes.reduce((out, box) => {
|
|
1629
|
+
const same = field ? out.find((o) => Math.abs(o.top - box.top) < 0.5 && Math.abs(o.height - box.height) < 0.5) : void 0;
|
|
1630
|
+
if (!same) return [...out, box];
|
|
1631
|
+
const left = Math.min(same.left, box.left);
|
|
1632
|
+
const right = Math.max(same.left + same.width, box.left + box.width);
|
|
1633
|
+
return out.map((o) => o === same ? { ...o, left, width: right - left } : o);
|
|
1634
|
+
}, []);
|
|
1635
|
+
}
|
|
1636
|
+
var sameLines = (a, b) => a.length === b.length && a.every((l, i) => Object.keys(l).every((k) => Math.abs(l[k] - b[i][k]) < 0.5));
|
|
1637
|
+
function useMarkLines(anchorRef, markRef) {
|
|
1638
|
+
const [lines, setLines] = React24.useState([]);
|
|
1639
|
+
const measure = React24.useCallback(() => {
|
|
1640
|
+
const anchor = anchorRef.current;
|
|
1641
|
+
const mark = markRef.current;
|
|
1642
|
+
if (!anchor || !mark) return;
|
|
1643
|
+
const button = mark.closest("button");
|
|
1644
|
+
const a = anchor.getBoundingClientRect();
|
|
1645
|
+
let field;
|
|
1646
|
+
if (button) {
|
|
1627
1647
|
const b = button.getBoundingClientRect();
|
|
1628
|
-
const
|
|
1629
|
-
const
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
setPadding((p) => Math.abs(p.top - next.top) < 0.5 && Math.abs(p.bottom - next.bottom) < 0.5 ? p : next);
|
|
1642
|
-
};
|
|
1643
|
-
align();
|
|
1644
|
-
const observer = new ResizeObserver(align);
|
|
1648
|
+
const style = getComputedStyle(button);
|
|
1649
|
+
const contentTop = b.top + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.paddingTop) || 0);
|
|
1650
|
+
const contentBottom = b.bottom - (parseFloat(style.borderBottomWidth) || 0) - (parseFloat(style.paddingBottom) || 0);
|
|
1651
|
+
field = { top: b.top, bottom: b.bottom, contentTop, contentBottom, lineHeight: parseFloat(style.lineHeight) || contentBottom - contentTop };
|
|
1652
|
+
}
|
|
1653
|
+
const next = markLines([...mark.getClientRects()], a, field);
|
|
1654
|
+
setLines((prev) => sameLines(prev, next) ? prev : next);
|
|
1655
|
+
}, [anchorRef, markRef]);
|
|
1656
|
+
React24.useLayoutEffect(measure);
|
|
1657
|
+
React24.useLayoutEffect(() => {
|
|
1658
|
+
const button = markRef.current?.closest("button");
|
|
1659
|
+
if (!button) return;
|
|
1660
|
+
const observer = new ResizeObserver(measure);
|
|
1645
1661
|
observer.observe(button);
|
|
1646
1662
|
return () => observer.disconnect();
|
|
1647
|
-
}, [
|
|
1648
|
-
return
|
|
1663
|
+
}, [markRef, measure]);
|
|
1664
|
+
return lines;
|
|
1665
|
+
}
|
|
1666
|
+
function remapMarks(saved, draft, marks) {
|
|
1667
|
+
if (!marks?.length) return [];
|
|
1668
|
+
if (saved === draft) return marks;
|
|
1669
|
+
const max = Math.min(saved.length, draft.length);
|
|
1670
|
+
let before = 0;
|
|
1671
|
+
while (before < max && saved[before] === draft[before]) before += 1;
|
|
1672
|
+
let after = 0;
|
|
1673
|
+
while (after < max - before && saved[saved.length - 1 - after] === draft[draft.length - 1 - after]) after += 1;
|
|
1674
|
+
const editEnd = saved.length - after;
|
|
1675
|
+
const delta = draft.length - saved.length;
|
|
1676
|
+
return marks.flatMap((m) => m.end <= before ? [m] : m.start >= editEnd ? [{ ...m, start: m.start + delta, end: m.end + delta }] : []);
|
|
1677
|
+
}
|
|
1678
|
+
function DraftMarks({ text, marks, layer, className, scrollLeft = 0, singleLine }) {
|
|
1679
|
+
const rootRef = React24.useRef(null);
|
|
1680
|
+
const textRef = React24.useRef(null);
|
|
1681
|
+
const [boxes, setBoxes] = React24.useState([]);
|
|
1682
|
+
React24.useLayoutEffect(() => {
|
|
1683
|
+
if (textRef.current) textRef.current.scrollLeft = scrollLeft;
|
|
1684
|
+
}, [scrollLeft, text]);
|
|
1685
|
+
React24.useLayoutEffect(() => {
|
|
1686
|
+
const root = rootRef.current;
|
|
1687
|
+
const mirror = textRef.current;
|
|
1688
|
+
if (!root || !mirror) return;
|
|
1689
|
+
const r = root.getBoundingClientRect();
|
|
1690
|
+
const style = getComputedStyle(mirror);
|
|
1691
|
+
const contentTop = r.top + (parseFloat(style.borderTopWidth) || 0) + (parseFloat(style.paddingTop) || 0);
|
|
1692
|
+
const contentBottom = r.bottom - (parseFloat(style.borderBottomWidth) || 0) - (parseFloat(style.paddingBottom) || 0);
|
|
1693
|
+
const lineHeight = singleLine ? contentBottom - contentTop : parseFloat(style.lineHeight) || contentBottom - contentTop;
|
|
1694
|
+
const field = { top: r.top, bottom: r.bottom, contentTop, contentBottom, lineHeight };
|
|
1695
|
+
const next = [...mirror.querySelectorAll("[data-draft-mark]")].flatMap(
|
|
1696
|
+
(el) => markLines([...el.getClientRects()], { left: r.left, top: r.top }, field).map((box) => ({ tone: el.dataset.tone ?? "destructive", box }))
|
|
1697
|
+
);
|
|
1698
|
+
setBoxes((prev) => prev.length === next.length && prev.every((p, i) => p.tone === next[i].tone && sameLines([p.box], [next[i].box])) ? prev : next);
|
|
1699
|
+
});
|
|
1700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { ref: rootRef, "aria-hidden": true, "data-draft-marks": true, "data-layer": layer, className: "pointer-events-none absolute inset-0", children: [
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: textRef, className: cn(className, "absolute inset-0 overflow-hidden text-transparent"), children: splitMarks(text, marks).map(
|
|
1702
|
+
(piece, i) => piece.mark ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-draft-mark": true, "data-tone": piece.mark.tone ?? "destructive", children: piece.text }, i) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: piece.text }, i)
|
|
1703
|
+
) }),
|
|
1704
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "absolute inset-0", style: { clipPath: "inset(-4px 0)" }, children: boxes.map(
|
|
1705
|
+
({ tone, box }, i) => layer === "behind" ? tone === "warning" && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-draft-box": true, className: "absolute rounded-xxs bg-warning-background-highlight", style: box }, i) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-draft-box": true, className: cn("absolute rounded-xxs border-b-2", tone === "warning" ? "border-warning-foreground" : "border-destructive-foreground"), style: box }, i)
|
|
1706
|
+
) })
|
|
1707
|
+
] });
|
|
1649
1708
|
}
|
|
1650
1709
|
var closeOpenMarkCard = null;
|
|
1651
1710
|
function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
@@ -1658,12 +1717,19 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1658
1717
|
},
|
|
1659
1718
|
[close]
|
|
1660
1719
|
);
|
|
1661
|
-
const
|
|
1662
|
-
const
|
|
1720
|
+
const anchorRef = React24.useRef(null);
|
|
1721
|
+
const [hovered, setHovered] = React24.useState(false);
|
|
1722
|
+
const lines = useMarkLines(anchorRef, ref);
|
|
1723
|
+
const layers = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { ref: anchorRef, "aria-hidden": true, className: "relative isolate", children: lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-mark-line": true, className: lineClasses(mark.tone, hovered), style: line }, i)) });
|
|
1663
1724
|
if (!onApply && !onDismiss) {
|
|
1664
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.
|
|
1725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
1726
|
+
layers,
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { ref, "data-mark": true, "data-tone": mark.tone ?? "destructive", className: "relative", children: text })
|
|
1728
|
+
] });
|
|
1665
1729
|
}
|
|
1666
1730
|
const suggestions = (mark.suggestions ?? []).slice(0, 3);
|
|
1731
|
+
const warning = mark.tone === "warning";
|
|
1732
|
+
const struck = "text-destructive-foreground";
|
|
1667
1733
|
const handleOpenChange = (next) => {
|
|
1668
1734
|
if (next) {
|
|
1669
1735
|
if (closeOpenMarkCard && closeOpenMarkCard !== close) closeOpenMarkCard();
|
|
@@ -1675,7 +1741,22 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1675
1741
|
};
|
|
1676
1742
|
const stop = (event) => event.stopPropagation();
|
|
1677
1743
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_radix_ui14.Popover.Root, { open, onOpenChange: handleOpenChange, children: [
|
|
1678
|
-
|
|
1744
|
+
layers,
|
|
1745
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_radix_ui14.Popover.Trigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1746
|
+
"span",
|
|
1747
|
+
{
|
|
1748
|
+
ref,
|
|
1749
|
+
"data-mark": true,
|
|
1750
|
+
"data-tone": mark.tone ?? "destructive",
|
|
1751
|
+
role: "button",
|
|
1752
|
+
tabIndex: -1,
|
|
1753
|
+
onClick: stop,
|
|
1754
|
+
onMouseEnter: () => setHovered(true),
|
|
1755
|
+
onMouseLeave: () => setHovered(false),
|
|
1756
|
+
className: "relative cursor-pointer",
|
|
1757
|
+
children: text
|
|
1758
|
+
}
|
|
1759
|
+
) }),
|
|
1679
1760
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_radix_ui14.Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
1680
1761
|
import_radix_ui14.Popover.Content,
|
|
1681
1762
|
{
|
|
@@ -1690,18 +1771,19 @@ function MarkedText({ mark, text, onApply, onDismiss }) {
|
|
|
1690
1771
|
suggestions.length > 1 && onApply ? (
|
|
1691
1772
|
// Several possible fixes: each one is a choice, applied with a click, so there is no Apply button.
|
|
1692
1773
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex flex-col gap-1", role: "group", "aria-label": "Choose a correction", children: suggestions.map((suggestion) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Button, { type: "button", size: "sm", variant: "ghost", className: "h-auto justify-start px-2 py-1 whitespace-normal", onClick: () => onApply(mark, suggestion), children: [
|
|
1693
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("s", { className:
|
|
1774
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("s", { className: struck, children: text }),
|
|
1694
1775
|
" ",
|
|
1695
1776
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-accent-foreground", children: suggestion === "" ? "Remove" : suggestion })
|
|
1696
1777
|
] }, suggestion)) })
|
|
1697
1778
|
) : suggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { className: "min-w-0 break-words", children: [
|
|
1698
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("s", { className:
|
|
1779
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("s", { className: struck, children: text }),
|
|
1699
1780
|
suggestions[0] !== "" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
1700
1781
|
" ",
|
|
1701
1782
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "font-semibold text-accent-foreground", children: suggestions[0] })
|
|
1702
1783
|
] })
|
|
1703
1784
|
] }),
|
|
1704
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.
|
|
1785
|
+
mark.message && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "min-w-0 break-words text-body-small text-surface-foreground", children: mark.message }),
|
|
1786
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: cn("flex items-center gap-3", warning ? "justify-end" : "justify-between"), children: [
|
|
1705
1787
|
onDismiss ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => onDismiss(mark), children: [
|
|
1706
1788
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react11.Trash, { size: 16, "aria-hidden": true }),
|
|
1707
1789
|
" Dismiss"
|
|
@@ -1754,6 +1836,8 @@ var InlineEdit = React25.forwardRef(
|
|
|
1754
1836
|
const [error, setError] = React25.useState(null);
|
|
1755
1837
|
const errorId = React25.useId();
|
|
1756
1838
|
const fieldRef = React25.useRef(null);
|
|
1839
|
+
const [scroll, setScroll] = React25.useState(0);
|
|
1840
|
+
const [draftMarks, setDraftMarks] = React25.useState([]);
|
|
1757
1841
|
const readRef = React25.useRef(null);
|
|
1758
1842
|
const cancelled = React25.useRef(false);
|
|
1759
1843
|
const restoreFocus = React25.useRef(false);
|
|
@@ -1775,6 +1859,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1775
1859
|
const start = () => {
|
|
1776
1860
|
if (disabled) return;
|
|
1777
1861
|
setDraft(value);
|
|
1862
|
+
setDraftMarks(marks ?? []);
|
|
1778
1863
|
setError(null);
|
|
1779
1864
|
cancelled.current = false;
|
|
1780
1865
|
setEditing(true);
|
|
@@ -1800,6 +1885,7 @@ var InlineEdit = React25.forwardRef(
|
|
|
1800
1885
|
};
|
|
1801
1886
|
const textClasses = cn("text-ui-input-value text-surface-foreground", textClassName);
|
|
1802
1887
|
const question = variant === "question";
|
|
1888
|
+
const draftMarksClass = cn("px-3 py-1", question ? "border-0 border-b-2 border-transparent" : "border border-transparent", multiline ? "whitespace-pre-wrap break-words" : "whitespace-pre", textClasses);
|
|
1803
1889
|
const fill = multiline || question;
|
|
1804
1890
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1805
1891
|
"div",
|
|
@@ -1808,39 +1894,68 @@ var InlineEdit = React25.forwardRef(
|
|
|
1808
1894
|
className: cn(fill ? "flex w-full min-w-0" : "inline-flex min-w-0 max-w-full", editing && (error || showLimits) && "flex-col gap-1.5", className),
|
|
1809
1895
|
...props,
|
|
1810
1896
|
children: editing ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
question ? cn("rounded-none border-0 border-b-2 bg-transparent", error ? "border-destructive" : "border-accent-muted") : cn("rounded-md", !error && "focus-visible:border-input-accent", fieldSurfaceClasses(error ? "error" : "default")),
|
|
1823
|
-
textClasses
|
|
1897
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: cn("relative flex w-full min-w-0", draftMarks.length > 0 && !question && "rounded-md bg-surface"), children: [
|
|
1898
|
+
draftMarks.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1899
|
+
DraftMarks,
|
|
1900
|
+
{
|
|
1901
|
+
layer: "behind",
|
|
1902
|
+
singleLine: !multiline,
|
|
1903
|
+
text: draft,
|
|
1904
|
+
marks: draftMarks,
|
|
1905
|
+
scrollLeft: multiline ? 0 : scroll,
|
|
1906
|
+
className: draftMarksClass
|
|
1907
|
+
}
|
|
1824
1908
|
),
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1909
|
+
React25.createElement(multiline ? "textarea" : "input", {
|
|
1910
|
+
ref: fieldRef,
|
|
1911
|
+
value: draft,
|
|
1912
|
+
maxLength,
|
|
1913
|
+
"aria-label": ariaLabel,
|
|
1914
|
+
"aria-invalid": error ? true : void 0,
|
|
1915
|
+
"aria-describedby": error || showLimits ? errorId : void 0,
|
|
1916
|
+
...multiline ? { rows: 1 } : { type: "text" },
|
|
1917
|
+
className: cn(
|
|
1918
|
+
"relative w-full px-3 py-1 outline-none",
|
|
1919
|
+
multiline && "field-sizing-content resize-none",
|
|
1920
|
+
question ? cn("rounded-none border-0 border-b-2 bg-transparent", error ? "border-destructive" : "border-accent-muted") : cn("rounded-md", !error && "focus-visible:border-input-accent", fieldSurfaceClasses(error ? "error" : "default")),
|
|
1921
|
+
textClasses,
|
|
1922
|
+
// Transparent over the highlight layer, so the highlight and the browser's text selection show together.
|
|
1923
|
+
draftMarks.length > 0 && "bg-transparent"
|
|
1924
|
+
),
|
|
1925
|
+
onChange: (event) => {
|
|
1926
|
+
setDraft(event.target.value);
|
|
1927
|
+
setDraftMarks(remapMarks(draft, event.target.value, draftMarks));
|
|
1928
|
+
requestAnimationFrame(() => setScroll(fieldRef.current?.scrollLeft ?? 0));
|
|
1929
|
+
if (error) setError(problemWith(event.target.value));
|
|
1930
|
+
onDraftChange?.(event.target.value);
|
|
1931
|
+
},
|
|
1932
|
+
onKeyDown: (event) => {
|
|
1933
|
+
if (event.key === "Escape") {
|
|
1934
|
+
cancelled.current = true;
|
|
1935
|
+
setError(null);
|
|
1936
|
+
finish(false, true);
|
|
1937
|
+
} else if (event.key === "Enter" && (!multiline || event.metaKey || event.ctrlKey || (question || submitOnEnter) && !event.shiftKey)) {
|
|
1938
|
+
event.preventDefault();
|
|
1939
|
+
finish(true, true);
|
|
1940
|
+
}
|
|
1941
|
+
},
|
|
1942
|
+
onScroll: (event) => setScroll(event.currentTarget.scrollLeft),
|
|
1943
|
+
onBlur: () => {
|
|
1944
|
+
if (!cancelled.current) finish(true, false);
|
|
1838
1945
|
}
|
|
1839
|
-
},
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1946
|
+
}),
|
|
1947
|
+
draftMarks.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1948
|
+
DraftMarks,
|
|
1949
|
+
{
|
|
1950
|
+
layer: "over",
|
|
1951
|
+
singleLine: !multiline,
|
|
1952
|
+
text: draft,
|
|
1953
|
+
marks: draftMarks,
|
|
1954
|
+
scrollLeft: multiline ? 0 : scroll,
|
|
1955
|
+
className: draftMarksClass
|
|
1956
|
+
}
|
|
1957
|
+
)
|
|
1958
|
+
] }),
|
|
1844
1959
|
(error || showLimits) && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
1845
1960
|
"p",
|
|
1846
1961
|
{
|
|
@@ -2462,19 +2577,25 @@ var Toast = React34.forwardRef(
|
|
|
2462
2577
|
Toast.displayName = "Toast";
|
|
2463
2578
|
var ToastAction = import_radix_ui18.Toast.Action;
|
|
2464
2579
|
var ToastInline = React34.forwardRef(
|
|
2465
|
-
({ className, variant = "info", actions, onClose, closeLabel = "Close", children, ...props }, ref) => {
|
|
2580
|
+
({ className, variant = "info", actions, actionsPlacement = "end", onClose, closeLabel = "Close", children, ...props }, ref) => {
|
|
2466
2581
|
const v = variant ?? "info";
|
|
2582
|
+
const below = actionsPlacement === "bottom" && !!actions;
|
|
2467
2583
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
2468
2584
|
"div",
|
|
2469
2585
|
{
|
|
2470
2586
|
ref,
|
|
2471
2587
|
role: v === "destructive" ? "alert" : "status",
|
|
2472
|
-
className: cn("flex
|
|
2588
|
+
className: cn("flex gap-2 rounded-sm px-2 py-1.5", below ? "items-start" : "items-center", inlineVariants({ variant: v }), className),
|
|
2473
2589
|
...props,
|
|
2474
2590
|
children: [
|
|
2475
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(VariantIcon, { variant: v === "neutral" ? "info" : v, size: 16 }),
|
|
2476
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.
|
|
2477
|
-
|
|
2591
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: cn("inline-flex shrink-0", below && "mt-0.5"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(VariantIcon, { variant: v === "neutral" ? "info" : v, size: 16 }) }),
|
|
2592
|
+
below ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [
|
|
2593
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-body-small text-secondary-muted-foreground", children }),
|
|
2594
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "flex items-center gap-2", children: actions })
|
|
2595
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
2596
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "min-w-0 flex-1 text-body-small text-secondary-muted-foreground", children }),
|
|
2597
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "flex shrink-0 items-center gap-2", children: actions })
|
|
2598
|
+
] }),
|
|
2478
2599
|
onClose && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": closeLabel, onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react17.X, { size: 16, "aria-hidden": true }) })
|
|
2479
2600
|
]
|
|
2480
2601
|
}
|
|
@@ -2950,6 +3071,9 @@ var icons = {
|
|
|
2950
3071
|
"select-multiple": import_react20.CheckSquare,
|
|
2951
3072
|
ranking: import_react20.ListNumbers,
|
|
2952
3073
|
upload: import_react20.FileArrowUp,
|
|
3074
|
+
"upload-video": import_react20.VideoCamera,
|
|
3075
|
+
"upload-photo": import_react20.Image,
|
|
3076
|
+
"upload-document": import_react20.FileText,
|
|
2953
3077
|
rating: import_react20.StarHalf,
|
|
2954
3078
|
"open-end": import_react20.ChatsCircle,
|
|
2955
3079
|
"screen-recording": import_react20.VideoCamera
|
|
@@ -3355,6 +3479,9 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3355
3479
|
const [focused, setFocused] = React45.useState(false);
|
|
3356
3480
|
const showMarks = !!marks?.length && !focused && draft === null;
|
|
3357
3481
|
const fieldRef = React45.useRef(null);
|
|
3482
|
+
const [editMarks, setEditMarks] = React45.useState([]);
|
|
3483
|
+
const [scroll, setScroll] = React45.useState(0);
|
|
3484
|
+
const typed = guarded ? draft ?? label : label;
|
|
3358
3485
|
const skipBlur = React45.useRef(false);
|
|
3359
3486
|
const problemWith = (text) => minLength !== void 0 && text.trim().length < minLength ? `Enter at least ${minLength} ${minLength === 1 ? "character" : "characters"}.` : null;
|
|
3360
3487
|
const save = () => {
|
|
@@ -3425,6 +3552,7 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3425
3552
|
] }) : locked ? null : grip }),
|
|
3426
3553
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3427
3554
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "relative min-w-0", children: [
|
|
3555
|
+
focused && editMarks.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DraftMarks, { layer: "behind", singleLine: true, text: typed, marks: editMarks, scrollLeft: scroll, className: "flex items-center whitespace-pre text-body-base" }),
|
|
3428
3556
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
3429
3557
|
"input",
|
|
3430
3558
|
{
|
|
@@ -3437,13 +3565,17 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3437
3565
|
value: guarded ? draft ?? label : label,
|
|
3438
3566
|
onFocus: () => {
|
|
3439
3567
|
setFocused(true);
|
|
3568
|
+
setEditMarks(marks ?? []);
|
|
3440
3569
|
if (guarded && draft === null) setDraft(label);
|
|
3441
3570
|
},
|
|
3442
3571
|
onChange: (event) => {
|
|
3572
|
+
requestAnimationFrame(() => setScroll(fieldRef.current?.scrollLeft ?? 0));
|
|
3573
|
+
setEditMarks(remapMarks(typed, event.target.value, editMarks));
|
|
3443
3574
|
if (!guarded) return onLabelChange?.(event.target.value);
|
|
3444
3575
|
setDraft(event.target.value);
|
|
3445
3576
|
if (error) setError(problemWith(event.target.value));
|
|
3446
3577
|
},
|
|
3578
|
+
onScroll: (event) => setScroll(event.currentTarget.scrollLeft),
|
|
3447
3579
|
onKeyDown: (event) => {
|
|
3448
3580
|
if (!guarded) return;
|
|
3449
3581
|
if (event.key === "Escape") {
|
|
@@ -3469,13 +3601,14 @@ function QuestionOptionEditor({ label, onLabelChange, placeholder, placeholderTo
|
|
|
3469
3601
|
save();
|
|
3470
3602
|
},
|
|
3471
3603
|
className: cn(
|
|
3472
|
-
"w-full min-w-0 bg-transparent text-body-base text-surface-foreground outline-none",
|
|
3604
|
+
"relative w-full min-w-0 bg-transparent text-body-base text-surface-foreground outline-none",
|
|
3473
3605
|
placeholderTone === "regular" ? "placeholder:text-surface-foreground" : "placeholder:text-muted-foreground",
|
|
3474
3606
|
// The marked text is drawn over the field, so the field's own letters step aside until it is edited.
|
|
3475
3607
|
showMarks && "text-transparent"
|
|
3476
3608
|
)
|
|
3477
3609
|
}
|
|
3478
3610
|
),
|
|
3611
|
+
focused && editMarks.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DraftMarks, { layer: "over", singleLine: true, text: typed, marks: editMarks, scrollLeft: scroll, className: "flex items-center whitespace-pre text-body-base" }),
|
|
3479
3612
|
showMarks && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 flex items-center overflow-hidden whitespace-pre text-body-base text-surface-foreground [&_[data-mark]]:pointer-events-auto", children: splitMarks(label, marks).map(
|
|
3480
3613
|
(piece, i) => piece.mark ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(MarkedText, { mark: piece.mark, text: piece.text, onApply: onMarkApply, onDismiss: onMarkDismiss }, `${piece.mark.start}:${piece.text}`) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { children: piece.text }, i)
|
|
3481
3614
|
) })
|
|
@@ -3915,12 +4048,13 @@ var statCardVariants = (0, import_class_variance_authority6.cva)("flex min-w-0 f
|
|
|
3915
4048
|
defaultVariants: { variant: "default" }
|
|
3916
4049
|
});
|
|
3917
4050
|
var StatCard = React51.forwardRef(
|
|
3918
|
-
({ className, variant, label, value, icon, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { ref, className: cn(statCardVariants({ variant }), className), ...props, children: [
|
|
4051
|
+
({ className, variant, label, value, icon, caption, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { ref, className: cn(statCardVariants({ variant }), className), ...props, children: [
|
|
3919
4052
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "truncate text-ui-caption text-secondary-muted-foreground", children: label }),
|
|
3920
4053
|
/* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("p", { className: "flex items-center gap-2 text-body-base text-surface-foreground", children: [
|
|
3921
4054
|
icon && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { "aria-hidden": "true", className: "inline-flex size-6 shrink-0 items-center justify-center", children: icon }),
|
|
3922
4055
|
value
|
|
3923
|
-
] })
|
|
4056
|
+
] }),
|
|
4057
|
+
caption && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "text-ui-caption text-secondary-muted-foreground", children: caption })
|
|
3924
4058
|
] })
|
|
3925
4059
|
);
|
|
3926
4060
|
StatCard.displayName = "StatCard";
|