@crewlethq/ui 0.138.0 → 0.140.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -208,6 +208,13 @@ places:
208
208
  - A surface that pans or zooms dispatches `LAYER_REPOSITION_EVENT` on its host
209
209
  when the content beneath it moves, and every panel anchored inside follows.
210
210
 
211
+ ## Changes in 0.140.0
212
+
213
+ ### A change drawn as the document it changed
214
+
215
+ - **`DocumentDiff`** draws a save to a page as the page reads: each block rendered in `Document`'s type, a whole new block raised one surface step and marked `+`, a removed one sunk, struck and marked `−`, and a run of blocks left out folded to a count (`{ change: 'skipped', count, of }`: "3 unchanged paragraphs", "4 more paragraphs removed"). The host parses and renders the blocks, as with `Document`.
216
+ - **`DocumentDiffAdded` and `DocumentDiffRemoved`** mark the words a change added and removed inside a block: an underline on the raised step and a strike in the tertiary ink on the sunk one, each with "added:" or "removed:" read first (`DOCUMENT_DIFF_LABELS`). No hue: a removed word is not a failure and an added one is not a success.
217
+
211
218
  ## Changes in 0.137.0
212
219
 
213
220
  ### A passing tab and a reviewer's verdict
@@ -1,15 +1,15 @@
1
- export { ArtifactCard, ArtifactCardSkeleton, ArtifactPreviewGlyph } from '../chunk-4676PXF7.js';
1
+ export { ArtifactCard, ArtifactCardSkeleton, ArtifactPreviewGlyph } from '../chunk-XVRLNGEO.js';
2
2
  import '../chunk-WFAJYBLX.js';
3
3
  import '../chunk-265IX4YA.js';
4
4
  import '../chunk-GBKBME7Q.js';
5
5
  import '../chunk-WGLOH33S.js';
6
- import '../chunk-DOY3KC6I.js';
7
6
  import '../chunk-E7KRB77B.js';
8
7
  import '../chunk-AV2DXAEL.js';
9
8
  import '../chunk-475DOAWF.js';
10
9
  import '../chunk-WSIJDWUG.js';
11
10
  import '../chunk-W3A6NBUM.js';
12
11
  import '../chunk-XLND4DD6.js';
12
+ import '../chunk-DOY3KC6I.js';
13
13
  export { ARTIFACT_KINDS, ArtifactKindGlyph } from '../chunk-RSKW25Y5.js';
14
14
  import '../chunk-SPCNQUEU.js';
15
15
  import '../chunk-YMFFGPFE.js';
@@ -1,8 +1,8 @@
1
- export { AvatarPicker } from '../chunk-JFB742TW.js';
1
+ export { AvatarPicker } from '../chunk-44DZHJSQ.js';
2
2
  import '../chunk-X3LYR2BK.js';
3
3
  import '../chunk-KDRJZWE3.js';
4
- import '../chunk-AYKXMIOR.js';
5
4
  import '../chunk-CBUAKPF7.js';
5
+ import '../chunk-AYKXMIOR.js';
6
6
  import '../chunk-PNLCBC2N.js';
7
7
  import '../chunk-F2BE5X4J.js';
8
8
  import '../chunk-7F3OPUM5.js';
@@ -54,7 +54,7 @@
54
54
  * over the boards beside it (`boardRoom`).
55
55
  */
56
56
  import { type ReactNode, type Ref } from 'react';
57
- import { type CanvasHandle, type CanvasLabels, type CanvasPoint } from '../Canvas/index.js';
57
+ import { type CanvasHandle, type CanvasLabels, type CanvasSize, type CanvasPoint, type CanvasView } from '../Canvas/index.js';
58
58
  /** An artboard: an id, its frame in canvas pixels and its title. */
59
59
  export interface CanvasBoardItem {
60
60
  id: string;
@@ -213,6 +213,13 @@ export interface CanvasBoardProps {
213
213
  canvasLabels?: Partial<CanvasLabels> | undefined;
214
214
  /** The canvas underneath, for a caller that reveals or fits a board. */
215
215
  canvasRef?: Ref<CanvasHandle> | undefined;
216
+ /**
217
+ * Drawn over the canvas, above the boards, such as comment pins: place each
218
+ * item with the canvas handle's `screenRect` of its world point.
219
+ */
220
+ overlay?: ReactNode | undefined;
221
+ /** The view moved (a pan, a zoom or a resize): an overlay is placed again. */
222
+ onViewChange?: ((view: CanvasView, viewport: CanvasSize) => void) | undefined;
216
223
  className?: string | undefined;
217
224
  }
218
225
  /**
@@ -244,4 +251,4 @@ export declare function boardName(title: string, position: number, room: number)
244
251
  } | null;
245
252
  /** The fewest letters a shortened board name keeps before its ellipsis. */
246
253
  export declare const BOARD_NAME_MIN_CHARS = 3;
247
- export declare function CanvasBoard({ label, boards, notes, renderBoard, maxLive, minLiveWidth, editable, minSide, maxSide, onBoardChange, onNoteChange, onNoteRemove, onNoteCreate, onBoardCreate, onBoardRemove, onOpen, onActivate, selected: heldSelection, onSelectedChange, controlsExtra, toolbar, labels, canvasLabels, canvasRef, className, }: CanvasBoardProps): import("react").JSX.Element;
254
+ export declare function CanvasBoard({ label, boards, notes, renderBoard, maxLive, minLiveWidth, editable, minSide, maxSide, onBoardChange, onNoteChange, onNoteRemove, onNoteCreate, onBoardCreate, onBoardRemove, onOpen, onActivate, selected: heldSelection, onSelectedChange, controlsExtra, toolbar, labels, canvasLabels, canvasRef, overlay, onViewChange, className, }: CanvasBoardProps): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- export { BOARD_NAME_MIN_CHARS, CANVAS_BOARD_MAX_LIVE, CANVAS_BOARD_MIN_LIVE_WIDTH, CANVAS_BOARD_MIN_ZOOM, CANVAS_NOTE_COLORS, CanvasBoard, TITLE_GLYPH_EM, boardName, boardRoom, liveBoards, titleSize } from '../chunk-FZSQPNIY.js';
1
+ export { BOARD_NAME_MIN_CHARS, CANVAS_BOARD_MAX_LIVE, CANVAS_BOARD_MIN_LIVE_WIDTH, CANVAS_BOARD_MIN_ZOOM, CANVAS_NOTE_COLORS, CanvasBoard, TITLE_GLYPH_EM, boardName, boardRoom, liveBoards, titleSize } from '../chunk-KIZMSNL3.js';
2
2
  import '../chunk-YJPQJVRJ.js';
3
3
  import '../chunk-LRK7SHXN.js';
4
4
  import '../chunk-NPEI2QAN.js';
@@ -0,0 +1,19 @@
1
+ import { type ButtonHTMLAttributes } from 'react';
2
+ /** A thread still to be answered, one that was resolved, or one being written. */
3
+ export type CommentPinState = 'open' | 'resolved' | 'draft';
4
+ export interface CommentPinProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'aria-label'> {
5
+ /** The mark on the pin: the thread's number, or its author's initial. A resolved pin shows a check. */
6
+ mark: string;
7
+ /** The pin's accessible name: who said what, and where. */
8
+ label: string;
9
+ state?: CommentPinState | undefined;
10
+ /** The thread is the one open beside the content. */
11
+ selected?: boolean | undefined;
12
+ }
13
+ /**
14
+ * A comment thread's marker over the content it is about.
15
+ *
16
+ * Its tip, the bottom-start corner, is the anchored point: place the pin with
17
+ * `left`/`top` at the point and it stands up and to the end of it.
18
+ */
19
+ export declare const CommentPin: import("react").ForwardRefExoticComponent<CommentPinProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,3 @@
1
+ import './CommentPin.css';
2
+ export { CommentPin } from './CommentPin.js';
3
+ export type { CommentPinProps, CommentPinState } from './CommentPin.js';
@@ -0,0 +1,2 @@
1
+ export { CommentPin } from '../chunk-VG4WNM7W.js';
2
+ import '../chunk-ODEQTPFM.js';
@@ -0,0 +1,77 @@
1
+ /* A comment thread's marker (CommentPin.tsx): a bubble whose bottom-start corner is the point. */
2
+
3
+ .crewlet-comment-pin {
4
+ position: absolute;
5
+ z-index: var(--z-index-presence);
6
+ display: inline-flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ box-sizing: border-box;
10
+ width: var(--size-control-sm);
11
+ height: var(--size-control-sm);
12
+ margin: 0;
13
+ padding: 0;
14
+ border: 2px solid var(--color-surface-elevated);
15
+ border-radius: var(--radius-pill) var(--radius-pill) var(--radius-pill) 0;
16
+ background: var(--color-brand-accent);
17
+ box-shadow: var(--shadow-cursor);
18
+ color: var(--color-text-on-accent);
19
+ font-family: var(--font-family-sans);
20
+ font-size: var(--font-size-2xs);
21
+ font-weight: var(--font-weight-semibold);
22
+ line-height: 1;
23
+ cursor: pointer;
24
+ transform: translateY(-100%);
25
+ transform-origin: bottom left;
26
+ transition:
27
+ transform var(--motion-duration-fast) ease,
28
+ box-shadow var(--motion-duration-fast) ease;
29
+ }
30
+
31
+ [dir='rtl'] .crewlet-comment-pin {
32
+ border-radius: var(--radius-pill) var(--radius-pill) 0 var(--radius-pill);
33
+ transform: translate(-100%, -100%);
34
+ transform-origin: bottom right;
35
+ }
36
+
37
+ .crewlet-comment-pin:hover {
38
+ transform: translateY(-100%) scale(1.08);
39
+ }
40
+
41
+ /* The pin draws an edge, so its ring sits over that edge rather than off it. */
42
+ .crewlet-comment-pin:focus-visible {
43
+ outline: 2px solid var(--color-focus);
44
+ outline-offset: var(--size-focus-ring-inset-offset);
45
+ }
46
+
47
+ .crewlet-comment-pin--selected {
48
+ box-shadow:
49
+ 0 0 0 2px var(--color-surface-elevated),
50
+ 0 0 0 4px var(--color-brand-accent),
51
+ var(--shadow-cursor);
52
+ transform: translateY(-100%) scale(1.12);
53
+ }
54
+
55
+ .crewlet-comment-pin--resolved {
56
+ background: var(--color-surface-subtle);
57
+ color: var(--color-text-secondary);
58
+ border-color: var(--color-border-default);
59
+ }
60
+
61
+ .crewlet-comment-pin--draft {
62
+ background: var(--color-surface-elevated);
63
+ border: 2px dashed var(--color-brand-accent);
64
+ color: var(--color-brand-accent-ink);
65
+ }
66
+
67
+ .crewlet-comment-pin__mark {
68
+ max-width: 2.5ch;
69
+ overflow: hidden;
70
+ white-space: nowrap;
71
+ }
72
+
73
+ @media (prefers-reduced-motion: reduce) {
74
+ .crewlet-comment-pin {
75
+ transition: none;
76
+ }
77
+ }
@@ -1,7 +1,7 @@
1
- export { DEEP_WORK_CARD_LABELS, DEEP_WORK_STATES, DEEP_WORK_STATE_LABELS, DeepWorkCard } from '../chunk-VJVWCEGC.js';
1
+ export { DEEP_WORK_CARD_LABELS, DEEP_WORK_STATES, DEEP_WORK_STATE_LABELS, DeepWorkCard } from '../chunk-MQSJB47C.js';
2
2
  import '../chunk-EHD4CEHK.js';
3
- import '../chunk-MXOT2CWL.js';
4
3
  import '../chunk-XMXIPVOS.js';
4
+ import '../chunk-MXOT2CWL.js';
5
5
  import '../chunk-NWKH5FF7.js';
6
6
  import '../chunk-SJ3EUCFD.js';
7
7
  import '../chunk-QRE6JCHS.js';
@@ -0,0 +1,64 @@
1
+ import { type HTMLAttributes, type ReactNode } from 'react';
2
+ import { type DocumentSize } from '../Document/index.js';
3
+ export interface DocumentDiffLabels {
4
+ /** The group's accessible name when the caller gives none. */
5
+ region: string;
6
+ /** Said before a block that is new: "Added:". */
7
+ added: string;
8
+ /** Said before a block that is gone: "Removed:". */
9
+ removed: string;
10
+ /** Said before each added run of words, with its own punctuation: "added:". */
11
+ addedWords: string;
12
+ /** Said before each removed run of words: "removed:". */
13
+ removedWords: string;
14
+ /** The row a run of left-out blocks folds into: "3 unchanged paragraphs", "4 more paragraphs removed". */
15
+ skipped: (count: number, of: DocumentDiffChange) => string;
16
+ }
17
+ export declare const DOCUMENT_DIFF_LABELS: DocumentDiffLabels;
18
+ /** What happened to one block of the document. */
19
+ export type DocumentDiffChange = 'same' | 'changed' | 'added' | 'removed';
20
+ /**
21
+ * One block of the diff: a paragraph, a heading, a list item or a table the
22
+ * host rendered. A `changed` block marks its own words with
23
+ * [DocumentDiffAdded] and [DocumentDiffRemoved]; `skipped` stands for a run of
24
+ * blocks left out, unchanged ones unless `of` says otherwise.
25
+ */
26
+ export type DocumentDiffBlock = {
27
+ change: DocumentDiffChange;
28
+ content: ReactNode;
29
+ key?: string | number | undefined;
30
+ } | {
31
+ change: 'skipped';
32
+ count: number;
33
+ of?: DocumentDiffChange | undefined;
34
+ key?: string | number | undefined;
35
+ };
36
+ export interface DocumentDiffProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
37
+ blocks: readonly DocumentDiffBlock[];
38
+ /** The reading size of the document the blocks come from. `sm` by default, a preview's. */
39
+ size?: DocumentSize | undefined;
40
+ labels?: Partial<DocumentDiffLabels> | undefined;
41
+ }
42
+ /**
43
+ * A change to a document, drawn as the document: each block rendered as it
44
+ * reads, the words that changed marked where they stand, and the unchanged
45
+ * stretches folded to a count.
46
+ *
47
+ * NO HUE. A removed word is not a failure and an added one is not a success,
48
+ * so the marks are a strike and an underline, each on a surface step of the
49
+ * diff's own ground, with a word read in their place. A whole new block is
50
+ * raised one step and marked `+`; a whole removed one is sunk, struck and
51
+ * marked `−`.
52
+ *
53
+ * THE HOST RENDERS, as with [Document]: it parses the two versions, decides
54
+ * which blocks changed and wraps the changed words of a block in
55
+ * [DocumentDiffAdded] and [DocumentDiffRemoved].
56
+ */
57
+ export declare function DocumentDiff({ blocks, size, labels: overrides, className, 'aria-label': ariaLabel, ...rest }: DocumentDiffProps): import("react").JSX.Element;
58
+ export interface DocumentDiffWordsProps {
59
+ children?: ReactNode;
60
+ }
61
+ /** Words a change added inside a block: underlined on the raised step, "added:" read first. */
62
+ export declare function DocumentDiffAdded({ children }: DocumentDiffWordsProps): import("react").JSX.Element;
63
+ /** Words a change removed inside a block: struck through in the quiet ink, "removed:" read first. */
64
+ export declare function DocumentDiffRemoved({ children }: DocumentDiffWordsProps): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import './DocumentDiff.css';
2
+ export { DOCUMENT_DIFF_LABELS, DocumentDiff, DocumentDiffAdded, DocumentDiffRemoved } from './DocumentDiff.js';
3
+ export type { DocumentDiffBlock, DocumentDiffChange, DocumentDiffLabels, DocumentDiffProps, DocumentDiffWordsProps } from './DocumentDiff.js';
@@ -0,0 +1,5 @@
1
+ export { DOCUMENT_DIFF_LABELS, DocumentDiff, DocumentDiffAdded, DocumentDiffRemoved } from '../chunk-WBGRXZG2.js';
2
+ import '../chunk-I4PBFJGX.js';
3
+ import '../chunk-4ITETIGZ.js';
4
+ import '../chunk-RRRK2KB6.js';
5
+ import '../chunk-ODEQTPFM.js';
@@ -0,0 +1,114 @@
1
+ /* DocumentDiff: a change drawn as the document it changed (DocumentDiff.tsx).
2
+ No hue: a block's or a run's kind is its mark, a word read in its place, and
3
+ one surface step off the diff's own ground, raised for added and sunk for
4
+ removed. */
5
+ .crewlet-document-diff {
6
+ /* An excerpt's blocks sit closer than a page's. */
7
+ --crewlet-document-gap: var(--spacing-2);
8
+ padding: var(--spacing-2) var(--spacing-3) var(--spacing-2) var(--spacing-1);
9
+ border: 1px solid var(--color-border-default);
10
+ border-radius: var(--radius-sm);
11
+ background: var(--color-surface-subtle);
12
+ }
13
+
14
+ /* The mark's track and the block's own, so every block's words share one edge. */
15
+ .crewlet-document-diff__block,
16
+ .crewlet-document-diff__skip {
17
+ display: grid;
18
+ grid-template-columns: var(--spacing-4) minmax(0, 1fr);
19
+ column-gap: var(--spacing-1);
20
+ align-items: baseline;
21
+ border-radius: var(--radius-xs);
22
+ }
23
+
24
+ .crewlet-document-diff__mark {
25
+ color: var(--color-text-secondary);
26
+ font-family: var(--font-family-mono);
27
+ text-align: center;
28
+ user-select: none;
29
+ }
30
+
31
+ .crewlet-document-diff__content {
32
+ min-width: 0;
33
+ }
34
+
35
+ .crewlet-document-diff__content > * + * {
36
+ margin-block-start: var(--crewlet-document-gap);
37
+ }
38
+
39
+ .crewlet-document-diff__block--added,
40
+ .crewlet-document-diff__block--removed {
41
+ padding-block: var(--spacing-1);
42
+ }
43
+
44
+ .crewlet-document-diff__block--added {
45
+ background: var(--color-surface-elevated);
46
+ }
47
+
48
+ .crewlet-document-diff__block--removed {
49
+ background: var(--color-surface-background);
50
+ }
51
+
52
+ /* Neighbouring blocks of one kind read as one region: no gap, no inner corners. */
53
+ .crewlet-document-diff__block--added + .crewlet-document-diff__block--added,
54
+ .crewlet-document-diff__block--removed + .crewlet-document-diff__block--removed {
55
+ margin-block-start: 0;
56
+ border-start-start-radius: 0;
57
+ border-start-end-radius: 0;
58
+ }
59
+
60
+ .crewlet-document-diff__block--added:has(+ .crewlet-document-diff__block--added),
61
+ .crewlet-document-diff__block--removed:has(+ .crewlet-document-diff__block--removed) {
62
+ border-end-start-radius: 0;
63
+ border-end-end-radius: 0;
64
+ }
65
+
66
+ .crewlet-document-diff__block--removed .crewlet-document-diff__content {
67
+ color: var(--color-text-tertiary);
68
+ text-decoration-line: line-through;
69
+ text-decoration-thickness: from-font;
70
+ }
71
+
72
+ /* What was removed takes the quiet ink throughout: its headings, strong words and links too. */
73
+ .crewlet-document-diff__block--removed .crewlet-document-diff__content *,
74
+ .crewlet-document-diff__removed * {
75
+ color: inherit;
76
+ }
77
+
78
+ /* Changed words inside a block. A run that wraps keeps its ground on every line. */
79
+ .crewlet-document-diff__added,
80
+ .crewlet-document-diff__removed {
81
+ border-radius: var(--radius-xs);
82
+ -webkit-box-decoration-break: clone;
83
+ box-decoration-break: clone;
84
+ }
85
+
86
+ .crewlet-document-diff__added {
87
+ background: var(--color-surface-elevated);
88
+ color: var(--color-text-primary);
89
+ text-decoration-line: underline;
90
+ text-decoration-thickness: from-font;
91
+ text-underline-position: under;
92
+ }
93
+
94
+ .crewlet-document-diff__removed {
95
+ background: var(--color-surface-background);
96
+ color: var(--color-text-tertiary);
97
+ text-decoration-line: line-through;
98
+ text-decoration-thickness: from-font;
99
+ }
100
+
101
+ /* Two runs that touch stand a word space apart, so they never read as one word. */
102
+ .crewlet-document-diff__removed:has(+ :is(.crewlet-document-diff__added, .crewlet-document-diff__removed)) {
103
+ margin-inline-end: var(--spacing-1);
104
+ }
105
+
106
+ .crewlet-document-diff__added + .crewlet-document-diff__removed {
107
+ margin-inline-start: var(--spacing-1);
108
+ }
109
+
110
+ /* A folded run says how many blocks it stands for, and of what kind. */
111
+ .crewlet-document-diff__skip {
112
+ color: var(--color-text-tertiary);
113
+ font-size: var(--font-size-xs);
114
+ }
@@ -1,7 +1,7 @@
1
- export { OPEN_IN_APP_CARD_LABELS, OpenInAppCard } from '../chunk-MVRTOAOW.js';
1
+ export { OPEN_IN_APP_CARD_LABELS, OpenInAppCard } from '../chunk-NHUQRUCW.js';
2
2
  import '../chunk-KOJPDCGQ.js';
3
- import '../chunk-KBZO4B33.js';
4
3
  import '../chunk-VRVNLJUA.js';
4
+ import '../chunk-KBZO4B33.js';
5
5
  import '../chunk-XMXIPVOS.js';
6
6
  import '../chunk-NWKH5FF7.js';
7
7
  import '../chunk-SJ3EUCFD.js';
@@ -252,6 +252,8 @@ function CanvasBoard({
252
252
  labels,
253
253
  canvasLabels,
254
254
  canvasRef,
255
+ overlay,
256
+ onViewChange,
255
257
  className
256
258
  }) {
257
259
  const text = { ...LABELS, ...labels };
@@ -416,10 +418,14 @@ function CanvasBoard({
416
418
  controlsExtra,
417
419
  hint,
418
420
  labels: canvasLabels,
419
- overlay: toolbar ? /* @__PURE__ */ jsx("div", { className: "crewlet-canvas-board__tools", children: /* @__PURE__ */ jsx(CanvasToolbar, { label: text.tools, tools, value: tool, onChange: setTool }) }) : void 0,
421
+ overlay: toolbar || overlay ? /* @__PURE__ */ jsxs(Fragment, { children: [
422
+ overlay,
423
+ toolbar ? /* @__PURE__ */ jsx("div", { className: "crewlet-canvas-board__tools", children: /* @__PURE__ */ jsx(CanvasToolbar, { label: text.tools, tools, value: tool, onChange: setTool }) }) : null
424
+ ] }) : void 0,
420
425
  onViewChange: (nextView, size) => {
421
426
  setView(nextView);
422
427
  setViewport(size);
428
+ onViewChange?.(nextView, size);
423
429
  },
424
430
  ref: canvas,
425
431
  children: /* @__PURE__ */ jsxs("div", { className: "crewlet-canvas-board__layer", style: zoomVar, children: [
@@ -0,0 +1,22 @@
1
+ import { cx } from './chunk-ODEQTPFM.js';
2
+ import './CommentPin-YTJAKYUC.css';
3
+ import { forwardRef } from 'react';
4
+ import { CheckGlyph } from '@crewlethq/icons/glyphs';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ var CommentPin = forwardRef(function CommentPin2({ mark, label, state = "open", selected = false, className, type = "button", ...rest }, ref) {
8
+ return /* @__PURE__ */ jsx(
9
+ "button",
10
+ {
11
+ ...rest,
12
+ ref,
13
+ type,
14
+ "aria-label": label,
15
+ "aria-pressed": selected,
16
+ className: cx("crewlet-comment-pin", `crewlet-comment-pin--${state}`, selected && "crewlet-comment-pin--selected", className),
17
+ children: /* @__PURE__ */ jsx("span", { className: "crewlet-comment-pin__mark", "aria-hidden": "true", children: state === "resolved" ? /* @__PURE__ */ jsx(CheckGlyph, { size: "xs" }) : mark })
18
+ }
19
+ );
20
+ });
21
+
22
+ export { CommentPin };
@@ -0,0 +1,81 @@
1
+ import { Document } from './chunk-I4PBFJGX.js';
2
+ import { VisuallyHidden } from './chunk-RRRK2KB6.js';
3
+ import { cx } from './chunk-ODEQTPFM.js';
4
+ import './DocumentDiff-UXBGVIJK.css';
5
+ import { createContext, useContext } from 'react';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
+
8
+ var DOCUMENT_DIFF_LABELS = {
9
+ region: "Changes",
10
+ added: "Added:",
11
+ removed: "Removed:",
12
+ addedWords: "added:",
13
+ removedWords: "removed:",
14
+ skipped: (count, of) => {
15
+ const n = count.toLocaleString();
16
+ if (of === "same") return count === 1 ? "1 unchanged paragraph" : `${n} unchanged paragraphs`;
17
+ return `${count === 1 ? "1 more paragraph" : `${n} more paragraphs`} ${of}`;
18
+ }
19
+ };
20
+ var LabelsContext = createContext(DOCUMENT_DIFF_LABELS);
21
+ function DocumentDiff({ blocks, size = "sm", labels: overrides, className, "aria-label": ariaLabel, ...rest }) {
22
+ const labels = overrides ? { ...DOCUMENT_DIFF_LABELS, ...overrides } : DOCUMENT_DIFF_LABELS;
23
+ return /* @__PURE__ */ jsx(LabelsContext.Provider, { value: labels, children: /* @__PURE__ */ jsx(
24
+ Document,
25
+ {
26
+ ...rest,
27
+ role: "group",
28
+ "aria-label": ariaLabel ?? labels.region,
29
+ size,
30
+ measure: "none",
31
+ className: cx("crewlet-document-diff", className),
32
+ children: blocks.map((block, index) => {
33
+ const key = block.key ?? index;
34
+ if (block.change === "skipped") {
35
+ const of = block.of ?? "same";
36
+ return /* @__PURE__ */ jsxs("p", { className: "crewlet-document-diff__skip", children: [
37
+ /* @__PURE__ */ jsx("span", { className: "crewlet-document-diff__mark", "aria-hidden": "true", children: of === "added" ? "+" : of === "removed" ? "\u2212" : "" }),
38
+ /* @__PURE__ */ jsx("span", { children: labels.skipped(block.count, of) })
39
+ ] }, key);
40
+ }
41
+ return /* @__PURE__ */ jsxs(
42
+ "div",
43
+ {
44
+ className: cx(
45
+ "crewlet-document-diff__block",
46
+ block.change === "same" && "crewlet-document-diff__block--same",
47
+ block.change === "changed" && "crewlet-document-diff__block--changed",
48
+ block.change === "added" && "crewlet-document-diff__block--added",
49
+ block.change === "removed" && "crewlet-document-diff__block--removed"
50
+ ),
51
+ children: [
52
+ /* @__PURE__ */ jsx("span", { className: "crewlet-document-diff__mark", "aria-hidden": "true", children: block.change === "added" ? "+" : block.change === "removed" ? "\u2212" : "" }),
53
+ /* @__PURE__ */ jsxs("div", { className: "crewlet-document-diff__content", children: [
54
+ block.change === "added" && /* @__PURE__ */ jsx(VisuallyHidden, { children: labels.added }),
55
+ block.change === "removed" && /* @__PURE__ */ jsx(VisuallyHidden, { children: labels.removed }),
56
+ block.content
57
+ ] })
58
+ ]
59
+ },
60
+ key
61
+ );
62
+ })
63
+ }
64
+ ) });
65
+ }
66
+ function DocumentDiffAdded({ children }) {
67
+ const labels = useContext(LabelsContext);
68
+ return /* @__PURE__ */ jsxs("ins", { className: "crewlet-document-diff__added", children: [
69
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: `${labels.addedWords} ` }),
70
+ children
71
+ ] });
72
+ }
73
+ function DocumentDiffRemoved({ children }) {
74
+ const labels = useContext(LabelsContext);
75
+ return /* @__PURE__ */ jsxs("del", { className: "crewlet-document-diff__removed", children: [
76
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: `${labels.removedWords} ` }),
77
+ children
78
+ ] });
79
+ }
80
+
81
+ export { DOCUMENT_DIFF_LABELS, DocumentDiff, DocumentDiffAdded, DocumentDiffRemoved };
@@ -64,6 +64,7 @@ export * from '../ColorField/index.js';
64
64
  export * from '../ColorSwatch/index.js';
65
65
  export * from '../Combobox/index.js';
66
66
  export * from '../CommandPalette/index.js';
67
+ export * from '../CommentPin/index.js';
67
68
  export * from '../CommentThread/index.js';
68
69
  export * from '../CompactNav/index.js';
69
70
  export * from '../Composer/index.js';
@@ -91,6 +92,7 @@ export * from '../Divider/index.js';
91
92
  export * from '../DocTabsEditor/index.js';
92
93
  export * from '../DockColumn/index.js';
93
94
  export * from '../Document/index.js';
95
+ export * from '../DocumentDiff/index.js';
94
96
  export * from '../DownloadButton/index.js';
95
97
  export * from '../EditingStatus/index.js';
96
98
  export * from '../EmojiPicker/index.js';