@unofficialbox/box-open-elements 0.5.0 → 0.7.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.
Files changed (227) hide show
  1. package/README.md +27 -73
  2. package/dist/components/collections/table.d.ts +113 -3
  3. package/dist/components/collections/table.js +540 -37
  4. package/dist/components/feedback/due-badge.d.ts +38 -0
  5. package/dist/components/feedback/due-badge.js +168 -0
  6. package/dist/components/feedback/due-types.d.ts +32 -0
  7. package/dist/components/feedback/due-types.js +91 -0
  8. package/dist/components/feedback/progress-steps.d.ts +51 -5
  9. package/dist/components/feedback/progress-steps.js +200 -22
  10. package/dist/components/feedback/stage-path.d.ts +44 -0
  11. package/dist/components/feedback/stage-path.js +235 -0
  12. package/dist/components/forms/select.d.ts +21 -0
  13. package/dist/components/forms/select.js +100 -3
  14. package/dist/components/forms/text-field.d.ts +21 -0
  15. package/dist/components/forms/text-field.js +100 -1
  16. package/dist/components/layout/nav-sidebar.d.ts +14 -0
  17. package/dist/components/layout/nav-sidebar.js +49 -0
  18. package/dist/components/layout/split-view.d.ts +14 -0
  19. package/dist/components/layout/split-view.js +80 -1
  20. package/dist/components/overlays/command-palette.d.ts +62 -0
  21. package/dist/components/overlays/command-palette.js +537 -0
  22. package/dist/components/overlays/command-types.d.ts +90 -0
  23. package/dist/components/overlays/command-types.js +259 -0
  24. package/dist/components/overlays/drawer.d.ts +18 -0
  25. package/dist/components/overlays/drawer.js +135 -9
  26. package/dist/components/overlays/shortcuts-overlay.d.ts +48 -0
  27. package/dist/components/overlays/shortcuts-overlay.js +385 -0
  28. package/dist/components/overlays/tooltip.js +1 -1
  29. package/dist/core/index.d.ts +4 -0
  30. package/dist/core/index.js +2 -0
  31. package/dist/core/offset-window.d.ts +70 -0
  32. package/dist/core/offset-window.js +134 -0
  33. package/dist/core/virtualize.d.ts +71 -0
  34. package/dist/core/virtualize.js +67 -0
  35. package/dist/element-maps.d.ts +292 -0
  36. package/dist/element-maps.js +1 -0
  37. package/dist/entries/activity-density.d.ts +1 -0
  38. package/dist/entries/activity-density.js +1 -0
  39. package/dist/entries/agent-chat.d.ts +1 -0
  40. package/dist/entries/agent-chat.js +1 -0
  41. package/dist/entries/audit-log.d.ts +1 -0
  42. package/dist/entries/audit-log.js +1 -0
  43. package/dist/entries/command-palette.d.ts +1 -0
  44. package/dist/entries/command-palette.js +1 -0
  45. package/dist/entries/compare-view.d.ts +1 -0
  46. package/dist/entries/compare-view.js +1 -0
  47. package/dist/entries/diff-viewer.d.ts +1 -0
  48. package/dist/entries/diff-viewer.js +1 -0
  49. package/dist/entries/due-badge.d.ts +1 -0
  50. package/dist/entries/due-badge.js +1 -0
  51. package/dist/entries/form-wizard.d.ts +1 -0
  52. package/dist/entries/form-wizard.js +1 -0
  53. package/dist/entries/lineage-graph.d.ts +1 -0
  54. package/dist/entries/lineage-graph.js +1 -0
  55. package/dist/entries/notification-bell.d.ts +1 -0
  56. package/dist/entries/notification-bell.js +1 -0
  57. package/dist/entries/notification-inbox.d.ts +1 -0
  58. package/dist/entries/notification-inbox.js +1 -0
  59. package/dist/entries/provenance-strip.d.ts +1 -0
  60. package/dist/entries/provenance-strip.js +1 -0
  61. package/dist/entries/run-trace.d.ts +1 -0
  62. package/dist/entries/run-trace.js +1 -0
  63. package/dist/entries/shortcuts-overlay.d.ts +1 -0
  64. package/dist/entries/shortcuts-overlay.js +1 -0
  65. package/dist/entries/signature-ceremony.d.ts +1 -0
  66. package/dist/entries/signature-ceremony.js +1 -0
  67. package/dist/entries/stage-path.d.ts +1 -0
  68. package/dist/entries/stage-path.js +1 -0
  69. package/dist/entries/timeline.d.ts +1 -0
  70. package/dist/entries/timeline.js +1 -0
  71. package/dist/entries/version-graph.d.ts +1 -0
  72. package/dist/entries/version-graph.js +1 -0
  73. package/dist/entries/version-list.d.ts +1 -0
  74. package/dist/entries/version-list.js +1 -0
  75. package/dist/entries/wizard-summary.d.ts +1 -0
  76. package/dist/entries/wizard-summary.js +1 -0
  77. package/dist/entries/work-queue.d.ts +1 -0
  78. package/dist/entries/work-queue.js +1 -0
  79. package/dist/entries/workload-board.d.ts +1 -0
  80. package/dist/entries/workload-board.js +1 -0
  81. package/dist/index.d.ts +21 -0
  82. package/dist/index.js +21 -0
  83. package/dist/patterns/agent-chat/agent-chat.d.ts +75 -0
  84. package/dist/patterns/agent-chat/agent-chat.js +820 -0
  85. package/dist/patterns/agent-chat/controller.d.ts +27 -0
  86. package/dist/patterns/agent-chat/controller.js +182 -0
  87. package/dist/patterns/agent-chat/index.d.ts +3 -0
  88. package/dist/patterns/agent-chat/index.js +6 -0
  89. package/dist/patterns/agent-chat/types.d.ts +109 -0
  90. package/dist/patterns/agent-chat/types.js +1 -0
  91. package/dist/patterns/audit/activity-density.d.ts +68 -0
  92. package/dist/patterns/audit/activity-density.js +428 -0
  93. package/dist/patterns/audit/audit-log.d.ts +182 -0
  94. package/dist/patterns/audit/audit-log.js +1082 -0
  95. package/dist/patterns/audit/index.d.ts +3 -0
  96. package/dist/patterns/audit/index.js +7 -0
  97. package/dist/patterns/audit/shared.d.ts +10 -0
  98. package/dist/patterns/audit/shared.js +50 -0
  99. package/dist/patterns/audit/types.d.ts +143 -0
  100. package/dist/patterns/audit/types.js +327 -0
  101. package/dist/patterns/audit/window.d.ts +116 -0
  102. package/dist/patterns/audit/window.js +132 -0
  103. package/dist/patterns/content-explorer/actions/controller.js +12 -2
  104. package/dist/patterns/content-explorer/box-transport.js +117 -25
  105. package/dist/patterns/content-explorer/content-explorer.d.ts +13 -1
  106. package/dist/patterns/content-explorer/content-explorer.js +36 -3
  107. package/dist/patterns/content-explorer/contracts.d.ts +24 -1
  108. package/dist/patterns/content-explorer/contracts.js +68 -11
  109. package/dist/patterns/content-explorer/controller.d.ts +16 -1
  110. package/dist/patterns/content-explorer/controller.js +130 -4
  111. package/dist/patterns/content-explorer/navigation/controller.js +11 -9
  112. package/dist/patterns/content-explorer/types.d.ts +58 -1
  113. package/dist/patterns/content-picker/content-picker.d.ts +71 -0
  114. package/dist/patterns/content-picker/content-picker.js +747 -0
  115. package/dist/patterns/content-picker/controller.d.ts +38 -0
  116. package/dist/patterns/content-picker/controller.js +141 -0
  117. package/dist/patterns/content-picker/index.d.ts +3 -0
  118. package/dist/patterns/content-picker/index.js +6 -0
  119. package/dist/patterns/content-picker/types.d.ts +52 -0
  120. package/dist/patterns/content-picker/types.js +26 -0
  121. package/dist/patterns/content-sidebar/content-sidebar.d.ts +43 -0
  122. package/dist/patterns/content-sidebar/content-sidebar.js +293 -0
  123. package/dist/patterns/content-sidebar/index.d.ts +2 -0
  124. package/dist/patterns/content-sidebar/index.js +4 -0
  125. package/dist/patterns/content-sidebar/types.d.ts +18 -0
  126. package/dist/patterns/content-sidebar/types.js +20 -0
  127. package/dist/patterns/content-uploader/box-transport.d.ts +14 -0
  128. package/dist/patterns/content-uploader/box-transport.js +54 -0
  129. package/dist/patterns/content-uploader/content-uploader.d.ts +62 -0
  130. package/dist/patterns/content-uploader/content-uploader.js +559 -0
  131. package/dist/patterns/content-uploader/controller.d.ts +39 -0
  132. package/dist/patterns/content-uploader/controller.js +227 -0
  133. package/dist/patterns/content-uploader/index.d.ts +4 -0
  134. package/dist/patterns/content-uploader/index.js +8 -0
  135. package/dist/patterns/content-uploader/types.d.ts +120 -0
  136. package/dist/patterns/content-uploader/types.js +38 -0
  137. package/dist/patterns/diff/compare-view.d.ts +47 -0
  138. package/dist/patterns/diff/compare-view.js +276 -0
  139. package/dist/patterns/diff/diff-viewer.d.ts +42 -0
  140. package/dist/patterns/diff/diff-viewer.js +434 -0
  141. package/dist/patterns/diff/engine.d.ts +22 -0
  142. package/dist/patterns/diff/engine.js +276 -0
  143. package/dist/patterns/diff/index.d.ts +4 -0
  144. package/dist/patterns/diff/index.js +8 -0
  145. package/dist/patterns/diff/types.d.ts +69 -0
  146. package/dist/patterns/diff/types.js +24 -0
  147. package/dist/patterns/form-wizard/controller.d.ts +39 -0
  148. package/dist/patterns/form-wizard/controller.js +157 -0
  149. package/dist/patterns/form-wizard/form-wizard.d.ts +63 -0
  150. package/dist/patterns/form-wizard/form-wizard.js +468 -0
  151. package/dist/patterns/form-wizard/index.d.ts +4 -0
  152. package/dist/patterns/form-wizard/index.js +8 -0
  153. package/dist/patterns/form-wizard/types.d.ts +109 -0
  154. package/dist/patterns/form-wizard/types.js +83 -0
  155. package/dist/patterns/form-wizard/wizard-summary.d.ts +62 -0
  156. package/dist/patterns/form-wizard/wizard-summary.js +324 -0
  157. package/dist/patterns/internal/safe-href.d.ts +17 -0
  158. package/dist/patterns/internal/safe-href.js +17 -0
  159. package/dist/patterns/lineage/index.d.ts +3 -0
  160. package/dist/patterns/lineage/index.js +6 -0
  161. package/dist/patterns/lineage/lineage-graph.d.ts +30 -0
  162. package/dist/patterns/lineage/lineage-graph.js +434 -0
  163. package/dist/patterns/lineage/provenance-strip.d.ts +22 -0
  164. package/dist/patterns/lineage/provenance-strip.js +194 -0
  165. package/dist/patterns/lineage/types.d.ts +53 -0
  166. package/dist/patterns/lineage/types.js +49 -0
  167. package/dist/patterns/notifications/index.d.ts +3 -0
  168. package/dist/patterns/notifications/index.js +6 -0
  169. package/dist/patterns/notifications/notification-bell.d.ts +38 -0
  170. package/dist/patterns/notifications/notification-bell.js +198 -0
  171. package/dist/patterns/notifications/notification-inbox.d.ts +46 -0
  172. package/dist/patterns/notifications/notification-inbox.js +537 -0
  173. package/dist/patterns/notifications/types.d.ts +61 -0
  174. package/dist/patterns/notifications/types.js +108 -0
  175. package/dist/patterns/preview/annotation-inspector.d.ts +25 -6
  176. package/dist/patterns/preview/annotation-inspector.js +239 -94
  177. package/dist/patterns/preview/annotation-thread.d.ts +25 -5
  178. package/dist/patterns/preview/annotation-thread.js +233 -82
  179. package/dist/patterns/preview/annotation-toolbar.d.ts +20 -6
  180. package/dist/patterns/preview/annotation-toolbar.js +162 -96
  181. package/dist/patterns/preview/content-preview-adapter.d.ts +10 -1
  182. package/dist/patterns/preview/content-preview-adapter.js +26 -1
  183. package/dist/patterns/preview/preview-element.d.ts +15 -2
  184. package/dist/patterns/preview/preview-element.js +223 -52
  185. package/dist/patterns/preview/provider-adapter.d.ts +47 -0
  186. package/dist/patterns/preview/provider-adapter.js +17 -0
  187. package/dist/patterns/run/index.d.ts +2 -0
  188. package/dist/patterns/run/index.js +4 -0
  189. package/dist/patterns/run/run-trace.d.ts +40 -0
  190. package/dist/patterns/run/run-trace.js +441 -0
  191. package/dist/patterns/run/types.d.ts +66 -0
  192. package/dist/patterns/run/types.js +152 -0
  193. package/dist/patterns/signature/index.d.ts +2 -0
  194. package/dist/patterns/signature/index.js +4 -0
  195. package/dist/patterns/signature/signature-ceremony.d.ts +33 -0
  196. package/dist/patterns/signature/signature-ceremony.js +317 -0
  197. package/dist/patterns/signature/types.d.ts +68 -0
  198. package/dist/patterns/signature/types.js +89 -0
  199. package/dist/patterns/timeline/index.d.ts +2 -0
  200. package/dist/patterns/timeline/index.js +4 -0
  201. package/dist/patterns/timeline/timeline.d.ts +27 -0
  202. package/dist/patterns/timeline/timeline.js +430 -0
  203. package/dist/patterns/timeline/types.d.ts +36 -0
  204. package/dist/patterns/timeline/types.js +27 -0
  205. package/dist/patterns/versions/graph-layout.d.ts +43 -0
  206. package/dist/patterns/versions/graph-layout.js +159 -0
  207. package/dist/patterns/versions/index.d.ts +4 -0
  208. package/dist/patterns/versions/index.js +8 -0
  209. package/dist/patterns/versions/shared.d.ts +4 -0
  210. package/dist/patterns/versions/shared.js +13 -0
  211. package/dist/patterns/versions/types.d.ts +37 -0
  212. package/dist/patterns/versions/types.js +39 -0
  213. package/dist/patterns/versions/version-graph.d.ts +36 -0
  214. package/dist/patterns/versions/version-graph.js +438 -0
  215. package/dist/patterns/versions/version-list.d.ts +39 -0
  216. package/dist/patterns/versions/version-list.js +407 -0
  217. package/dist/patterns/work-queue/controller.d.ts +26 -0
  218. package/dist/patterns/work-queue/controller.js +150 -0
  219. package/dist/patterns/work-queue/index.d.ts +4 -0
  220. package/dist/patterns/work-queue/index.js +7 -0
  221. package/dist/patterns/work-queue/types.d.ts +128 -0
  222. package/dist/patterns/work-queue/types.js +45 -0
  223. package/dist/patterns/work-queue/work-queue.d.ts +48 -0
  224. package/dist/patterns/work-queue/work-queue.js +534 -0
  225. package/dist/patterns/work-queue/workload-board.d.ts +53 -0
  226. package/dist/patterns/work-queue/workload-board.js +608 -0
  227. package/package.json +89 -5
@@ -0,0 +1,276 @@
1
+ import { mapScrollPosition } from "./types.js";
2
+ import { BaseElement } from "../../core/index.js";
3
+ import { boePanel, boeRadius } from "../../foundations/geometry/index.js";
4
+ const DEFAULT_TAG_NAME = "box-compare-view";
5
+ const escapeHtml = (value) => value
6
+ .replaceAll("&", "&")
7
+ .replaceAll("<", "&lt;")
8
+ .replaceAll(">", "&gt;")
9
+ .replaceAll('"', "&quot;")
10
+ .replaceAll("'", "&#39;");
11
+ const metricsOf = (element) => ({
12
+ scrollTop: element.scrollTop,
13
+ scrollHeight: element.scrollHeight,
14
+ clientHeight: element.clientHeight,
15
+ });
16
+ const elementStyles = `
17
+ :host {
18
+ display: block;
19
+ }
20
+
21
+ /*
22
+ * The height a host sets on the element has to reach the scrollers, or
23
+ * the panes size to their content, never overflow, and the scroll lock
24
+ * has nothing to do. Every link in the chain needs a definite height:
25
+ * one auto-height ancestor and the frame's 100% resolves to content
26
+ * height instead.
27
+ */
28
+ [part="host"] {
29
+ block-size: 100%;
30
+ min-block-size: 0;
31
+ }
32
+
33
+ [part="frame"] {
34
+ border: ${boePanel.border};
35
+ border-radius: ${boePanel.radius};
36
+ background: ${boePanel.background};
37
+ overflow: hidden;
38
+ display: grid;
39
+ grid-template-rows: auto 1fr;
40
+ block-size: 100%;
41
+ min-block-size: 0;
42
+ }
43
+
44
+ [part="toolbar"] {
45
+ display: flex;
46
+ align-items: center;
47
+ gap: 0.6rem;
48
+ padding: 0.6rem 0.85rem;
49
+ border-block-end: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 70%, transparent);
50
+ }
51
+
52
+ [part="heading"] {
53
+ margin: 0;
54
+ font: inherit;
55
+ font-size: 0.92rem;
56
+ font-weight: 700;
57
+ color: var(--boe-token-text-text, #1f1e1b);
58
+ }
59
+
60
+ [part="sync-toggle"] {
61
+ margin-inline-start: auto;
62
+ appearance: none;
63
+ font: inherit;
64
+ font-size: 0.78rem;
65
+ padding: 0.2rem 0.6rem;
66
+ border: 1px solid var(--boe-token-stroke-stroke, #e8e8e8);
67
+ border-radius: ${boeRadius.control};
68
+ background: var(--boe-token-surface-surface, #ffffff);
69
+ color: var(--boe-token-text-text, #222222);
70
+ cursor: pointer;
71
+ }
72
+
73
+ [part="sync-toggle"][aria-pressed="true"] {
74
+ background: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 12%, transparent);
75
+ border-color: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 38%, transparent);
76
+ color: color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 80%, black 20%);
77
+ }
78
+
79
+ [part="sync-toggle"]:focus-visible {
80
+ outline: none;
81
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--boe-token-surface-surface-brand, #0061d5) 18%, transparent);
82
+ }
83
+
84
+ [part="panes"] {
85
+ display: grid;
86
+ grid-template-columns: 1fr 1px 1fr;
87
+ min-block-size: 0;
88
+ }
89
+
90
+ [part="divider"] {
91
+ background: color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 80%, transparent);
92
+ }
93
+
94
+ [part="pane"] {
95
+ display: grid;
96
+ grid-template-rows: auto 1fr;
97
+ min-block-size: 0;
98
+ }
99
+
100
+ [part="pane-label"] {
101
+ padding: 0.45rem 0.85rem;
102
+ font-size: 0.72rem;
103
+ font-weight: 700;
104
+ letter-spacing: 0.06em;
105
+ text-transform: uppercase;
106
+ color: var(--boe-token-text-text-secondary, #6f6f6f);
107
+ border-block-end: 1px solid color-mix(in srgb, var(--boe-token-stroke-stroke, #e8e8e8) 45%, transparent);
108
+ }
109
+
110
+ [part="scroller"] {
111
+ overflow: auto;
112
+ padding: 0.75rem 0.85rem;
113
+ min-block-size: 0;
114
+ }
115
+
116
+ @media (prefers-reduced-motion: no-preference) {
117
+ [part="scroller"] {
118
+ scroll-behavior: auto;
119
+ }
120
+ }
121
+ `;
122
+ /**
123
+ * Side-by-side comparison shell with scroll-locked panes — doc-vs-doc review
124
+ * for the cases the diff table cannot serve, where the two things being
125
+ * compared are rendered documents rather than lines of text.
126
+ *
127
+ * The scroll maths lives in `mapScrollPosition`, which is pure, so the
128
+ * interesting behaviour is testable without a layout engine and a host can
129
+ * reuse it to drive its own panes.
130
+ *
131
+ * The subtle part is the **feedback loop**. Scrolling the left pane sets the
132
+ * right pane's `scrollTop`, which fires the right pane's own scroll event,
133
+ * which would scroll the left pane back — the two panes fight, and a slow
134
+ * drag turns into a stutter. Each programmatic scroll therefore marks the
135
+ * pane it is about to move, and that pane's next scroll event is swallowed.
136
+ *
137
+ * The mark is cleared immediately when the assignment does not actually move
138
+ * the pane (already there, or clamped at an end): no scroll event will fire
139
+ * in that case, so a mark left set would swallow the user's *next* real
140
+ * scroll instead.
141
+ */
142
+ export class CompareView extends BaseElement {
143
+ static tagName = DEFAULT_TAG_NAME;
144
+ static get observedAttributes() {
145
+ return ["heading", "left-label", "right-label", "sync", "sync-mode"];
146
+ }
147
+ hostEl;
148
+ leftEl;
149
+ rightEl;
150
+ toggleEl;
151
+ /** The pane whose next scroll event came from us, not from the user. */
152
+ echoPane = null;
153
+ get heading() {
154
+ return this.getAttribute("heading") ?? "Compare";
155
+ }
156
+ set heading(value) {
157
+ this.setAttribute("heading", value);
158
+ }
159
+ get leftLabel() {
160
+ return this.getAttribute("left-label") ?? "Before";
161
+ }
162
+ set leftLabel(value) {
163
+ this.setAttribute("left-label", value);
164
+ }
165
+ get rightLabel() {
166
+ return this.getAttribute("right-label") ?? "After";
167
+ }
168
+ set rightLabel(value) {
169
+ this.setAttribute("right-label", value);
170
+ }
171
+ /** Scroll lock. On by default — comparing is the point of the component. */
172
+ get sync() {
173
+ return this.getAttribute("sync") !== "off";
174
+ }
175
+ set sync(value) {
176
+ this.setAttribute("sync", value ? "on" : "off");
177
+ }
178
+ get syncMode() {
179
+ return this.getAttribute("sync-mode") === "absolute" ? "absolute" : "proportional";
180
+ }
181
+ set syncMode(value) {
182
+ this.setAttribute("sync-mode", value);
183
+ }
184
+ syncFrom(source, target) {
185
+ if (this.echoPane === source) {
186
+ // Our own doing — consume the mark and stop, or the panes fight.
187
+ this.echoPane = null;
188
+ return;
189
+ }
190
+ if (!this.sync) {
191
+ return;
192
+ }
193
+ const next = mapScrollPosition(metricsOf(source), metricsOf(target), this.syncMode);
194
+ const before = target.scrollTop;
195
+ this.echoPane = target;
196
+ target.scrollTop = next;
197
+ if (target.scrollTop === before) {
198
+ // Nothing moved, so no scroll event is coming; drop the mark rather
199
+ // than let it swallow the next real scroll on that pane.
200
+ this.echoPane = null;
201
+ }
202
+ }
203
+ renderTemplate() {
204
+ if (!this.shadowRoot) {
205
+ return;
206
+ }
207
+ this.shadowRoot.innerHTML = `
208
+ <style>${elementStyles}</style>
209
+ <div part="host">
210
+ <section part="frame">
211
+ <div part="toolbar">
212
+ <h3 part="heading"></h3>
213
+ <button type="button" part="sync-toggle" aria-pressed="true"></button>
214
+ </div>
215
+ <div part="panes">
216
+ <div part="pane" data-side="left">
217
+ <div part="pane-label" id="compare-left-label"></div>
218
+ <div part="scroller" data-side="left" tabindex="0" role="region" aria-labelledby="compare-left-label">
219
+ <slot name="left"></slot>
220
+ </div>
221
+ </div>
222
+ <div part="divider" role="presentation"></div>
223
+ <div part="pane" data-side="right">
224
+ <div part="pane-label" id="compare-right-label"></div>
225
+ <div part="scroller" data-side="right" tabindex="0" role="region" aria-labelledby="compare-right-label">
226
+ <slot name="right"></slot>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ </section>
231
+ </div>
232
+ `;
233
+ this.hostEl = this.shadowRoot.querySelector('[part="host"]');
234
+ this.leftEl = this.shadowRoot.querySelector('[part="scroller"][data-side="left"]');
235
+ this.rightEl = this.shadowRoot.querySelector('[part="scroller"][data-side="right"]');
236
+ this.toggleEl = this.shadowRoot.querySelector('[part="sync-toggle"]');
237
+ }
238
+ setupListeners() {
239
+ this.leftEl.addEventListener("scroll", () => {
240
+ this.syncFrom(this.leftEl, this.rightEl);
241
+ });
242
+ this.rightEl.addEventListener("scroll", () => {
243
+ this.syncFrom(this.rightEl, this.leftEl);
244
+ });
245
+ this.toggleEl.addEventListener("click", () => {
246
+ const next = !this.sync;
247
+ this.sync = next;
248
+ this.dispatchEvent(new CustomEvent("sync-toggled", {
249
+ detail: { sync: next },
250
+ bubbles: true,
251
+ composed: true,
252
+ }));
253
+ if (next) {
254
+ // Re-engaging should align immediately rather than waiting for the
255
+ // next scroll, or the panes sit visibly out of step while claiming
256
+ // to be locked.
257
+ this.syncFrom(this.leftEl, this.rightEl);
258
+ }
259
+ });
260
+ }
261
+ update() {
262
+ if (!this.hostEl) {
263
+ return;
264
+ }
265
+ const synced = this.sync;
266
+ this.hostEl.querySelector('[part="heading"]').textContent = this.heading;
267
+ this.hostEl.querySelector('[part="pane-label"][id="compare-left-label"]').textContent =
268
+ this.leftLabel;
269
+ this.hostEl.querySelector('[part="pane-label"][id="compare-right-label"]').textContent =
270
+ this.rightLabel;
271
+ this.toggleEl.textContent = synced ? "Scroll locked" : "Scroll unlocked";
272
+ this.toggleEl.setAttribute("aria-pressed", String(synced));
273
+ this.toggleEl.setAttribute("aria-label", escapeHtml(synced ? "Scroll lock on, disable" : "Scroll lock off, enable"));
274
+ }
275
+ }
276
+ CompareView.register();
@@ -0,0 +1,42 @@
1
+ import type { DiffResult } from "./types.js";
2
+ import { BaseElement } from "../../core/index.js";
3
+ export declare class DiffViewer extends BaseElement {
4
+ static readonly tagName: string;
5
+ static get observedAttributes(): string[];
6
+ private titleEl;
7
+ private statsEl;
8
+ private navEl;
9
+ private navPositionEl;
10
+ private navPreviousEl;
11
+ private navNextEl;
12
+ private scrollerEl;
13
+ private emptyEl;
14
+ private result;
15
+ private resultSignature;
16
+ private activeChangeIndex;
17
+ get heading(): string;
18
+ set heading(value: string);
19
+ /** The original document text. (`before`/`after` collide with ChildNode methods.) */
20
+ get beforeText(): string;
21
+ set beforeText(value: string);
22
+ /** The revised document text. */
23
+ get afterText(): string;
24
+ set afterText(value: string);
25
+ get beforeLabel(): string;
26
+ set beforeLabel(value: string);
27
+ get afterLabel(): string;
28
+ set afterLabel(value: string);
29
+ /** `split` (side-by-side, default) or `inline` (unified). */
30
+ get mode(): "split" | "inline";
31
+ set mode(value: "split" | "inline");
32
+ /** The computed diff for the current inputs. */
33
+ get diff(): DiffResult | null;
34
+ /** Step change navigation programmatically; used by the header buttons. */
35
+ goToChange(index: number): void;
36
+ private lineHtml;
37
+ private rowHtml;
38
+ private rebuildTable;
39
+ protected renderTemplate(): void;
40
+ protected setupListeners(): void;
41
+ protected update(): void;
42
+ }