@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.
- package/README.md +27 -73
- package/dist/components/collections/table.d.ts +113 -3
- package/dist/components/collections/table.js +540 -37
- package/dist/components/feedback/due-badge.d.ts +38 -0
- package/dist/components/feedback/due-badge.js +168 -0
- package/dist/components/feedback/due-types.d.ts +32 -0
- package/dist/components/feedback/due-types.js +91 -0
- package/dist/components/feedback/progress-steps.d.ts +51 -5
- package/dist/components/feedback/progress-steps.js +200 -22
- package/dist/components/feedback/stage-path.d.ts +44 -0
- package/dist/components/feedback/stage-path.js +235 -0
- package/dist/components/forms/select.d.ts +21 -0
- package/dist/components/forms/select.js +100 -3
- package/dist/components/forms/text-field.d.ts +21 -0
- package/dist/components/forms/text-field.js +100 -1
- package/dist/components/layout/nav-sidebar.d.ts +14 -0
- package/dist/components/layout/nav-sidebar.js +49 -0
- package/dist/components/layout/split-view.d.ts +14 -0
- package/dist/components/layout/split-view.js +80 -1
- package/dist/components/overlays/command-palette.d.ts +62 -0
- package/dist/components/overlays/command-palette.js +537 -0
- package/dist/components/overlays/command-types.d.ts +90 -0
- package/dist/components/overlays/command-types.js +259 -0
- package/dist/components/overlays/drawer.d.ts +18 -0
- package/dist/components/overlays/drawer.js +135 -9
- package/dist/components/overlays/shortcuts-overlay.d.ts +48 -0
- package/dist/components/overlays/shortcuts-overlay.js +385 -0
- package/dist/components/overlays/tooltip.js +1 -1
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +2 -0
- package/dist/core/offset-window.d.ts +70 -0
- package/dist/core/offset-window.js +134 -0
- package/dist/core/virtualize.d.ts +71 -0
- package/dist/core/virtualize.js +67 -0
- package/dist/element-maps.d.ts +292 -0
- package/dist/element-maps.js +1 -0
- package/dist/entries/activity-density.d.ts +1 -0
- package/dist/entries/activity-density.js +1 -0
- package/dist/entries/agent-chat.d.ts +1 -0
- package/dist/entries/agent-chat.js +1 -0
- package/dist/entries/audit-log.d.ts +1 -0
- package/dist/entries/audit-log.js +1 -0
- package/dist/entries/command-palette.d.ts +1 -0
- package/dist/entries/command-palette.js +1 -0
- package/dist/entries/compare-view.d.ts +1 -0
- package/dist/entries/compare-view.js +1 -0
- package/dist/entries/diff-viewer.d.ts +1 -0
- package/dist/entries/diff-viewer.js +1 -0
- package/dist/entries/due-badge.d.ts +1 -0
- package/dist/entries/due-badge.js +1 -0
- package/dist/entries/form-wizard.d.ts +1 -0
- package/dist/entries/form-wizard.js +1 -0
- package/dist/entries/lineage-graph.d.ts +1 -0
- package/dist/entries/lineage-graph.js +1 -0
- package/dist/entries/notification-bell.d.ts +1 -0
- package/dist/entries/notification-bell.js +1 -0
- package/dist/entries/notification-inbox.d.ts +1 -0
- package/dist/entries/notification-inbox.js +1 -0
- package/dist/entries/provenance-strip.d.ts +1 -0
- package/dist/entries/provenance-strip.js +1 -0
- package/dist/entries/run-trace.d.ts +1 -0
- package/dist/entries/run-trace.js +1 -0
- package/dist/entries/shortcuts-overlay.d.ts +1 -0
- package/dist/entries/shortcuts-overlay.js +1 -0
- package/dist/entries/signature-ceremony.d.ts +1 -0
- package/dist/entries/signature-ceremony.js +1 -0
- package/dist/entries/stage-path.d.ts +1 -0
- package/dist/entries/stage-path.js +1 -0
- package/dist/entries/timeline.d.ts +1 -0
- package/dist/entries/timeline.js +1 -0
- package/dist/entries/version-graph.d.ts +1 -0
- package/dist/entries/version-graph.js +1 -0
- package/dist/entries/version-list.d.ts +1 -0
- package/dist/entries/version-list.js +1 -0
- package/dist/entries/wizard-summary.d.ts +1 -0
- package/dist/entries/wizard-summary.js +1 -0
- package/dist/entries/work-queue.d.ts +1 -0
- package/dist/entries/work-queue.js +1 -0
- package/dist/entries/workload-board.d.ts +1 -0
- package/dist/entries/workload-board.js +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +21 -0
- package/dist/patterns/agent-chat/agent-chat.d.ts +75 -0
- package/dist/patterns/agent-chat/agent-chat.js +820 -0
- package/dist/patterns/agent-chat/controller.d.ts +27 -0
- package/dist/patterns/agent-chat/controller.js +182 -0
- package/dist/patterns/agent-chat/index.d.ts +3 -0
- package/dist/patterns/agent-chat/index.js +6 -0
- package/dist/patterns/agent-chat/types.d.ts +109 -0
- package/dist/patterns/agent-chat/types.js +1 -0
- package/dist/patterns/audit/activity-density.d.ts +68 -0
- package/dist/patterns/audit/activity-density.js +428 -0
- package/dist/patterns/audit/audit-log.d.ts +182 -0
- package/dist/patterns/audit/audit-log.js +1082 -0
- package/dist/patterns/audit/index.d.ts +3 -0
- package/dist/patterns/audit/index.js +7 -0
- package/dist/patterns/audit/shared.d.ts +10 -0
- package/dist/patterns/audit/shared.js +50 -0
- package/dist/patterns/audit/types.d.ts +143 -0
- package/dist/patterns/audit/types.js +327 -0
- package/dist/patterns/audit/window.d.ts +116 -0
- package/dist/patterns/audit/window.js +132 -0
- package/dist/patterns/content-explorer/actions/controller.js +12 -2
- package/dist/patterns/content-explorer/box-transport.js +117 -25
- package/dist/patterns/content-explorer/content-explorer.d.ts +13 -1
- package/dist/patterns/content-explorer/content-explorer.js +36 -3
- package/dist/patterns/content-explorer/contracts.d.ts +24 -1
- package/dist/patterns/content-explorer/contracts.js +68 -11
- package/dist/patterns/content-explorer/controller.d.ts +16 -1
- package/dist/patterns/content-explorer/controller.js +130 -4
- package/dist/patterns/content-explorer/navigation/controller.js +11 -9
- package/dist/patterns/content-explorer/types.d.ts +58 -1
- package/dist/patterns/content-picker/content-picker.d.ts +71 -0
- package/dist/patterns/content-picker/content-picker.js +747 -0
- package/dist/patterns/content-picker/controller.d.ts +38 -0
- package/dist/patterns/content-picker/controller.js +141 -0
- package/dist/patterns/content-picker/index.d.ts +3 -0
- package/dist/patterns/content-picker/index.js +6 -0
- package/dist/patterns/content-picker/types.d.ts +52 -0
- package/dist/patterns/content-picker/types.js +26 -0
- package/dist/patterns/content-sidebar/content-sidebar.d.ts +43 -0
- package/dist/patterns/content-sidebar/content-sidebar.js +293 -0
- package/dist/patterns/content-sidebar/index.d.ts +2 -0
- package/dist/patterns/content-sidebar/index.js +4 -0
- package/dist/patterns/content-sidebar/types.d.ts +18 -0
- package/dist/patterns/content-sidebar/types.js +20 -0
- package/dist/patterns/content-uploader/box-transport.d.ts +14 -0
- package/dist/patterns/content-uploader/box-transport.js +54 -0
- package/dist/patterns/content-uploader/content-uploader.d.ts +62 -0
- package/dist/patterns/content-uploader/content-uploader.js +559 -0
- package/dist/patterns/content-uploader/controller.d.ts +39 -0
- package/dist/patterns/content-uploader/controller.js +227 -0
- package/dist/patterns/content-uploader/index.d.ts +4 -0
- package/dist/patterns/content-uploader/index.js +8 -0
- package/dist/patterns/content-uploader/types.d.ts +120 -0
- package/dist/patterns/content-uploader/types.js +38 -0
- package/dist/patterns/diff/compare-view.d.ts +47 -0
- package/dist/patterns/diff/compare-view.js +276 -0
- package/dist/patterns/diff/diff-viewer.d.ts +42 -0
- package/dist/patterns/diff/diff-viewer.js +434 -0
- package/dist/patterns/diff/engine.d.ts +22 -0
- package/dist/patterns/diff/engine.js +276 -0
- package/dist/patterns/diff/index.d.ts +4 -0
- package/dist/patterns/diff/index.js +8 -0
- package/dist/patterns/diff/types.d.ts +69 -0
- package/dist/patterns/diff/types.js +24 -0
- package/dist/patterns/form-wizard/controller.d.ts +39 -0
- package/dist/patterns/form-wizard/controller.js +157 -0
- package/dist/patterns/form-wizard/form-wizard.d.ts +63 -0
- package/dist/patterns/form-wizard/form-wizard.js +468 -0
- package/dist/patterns/form-wizard/index.d.ts +4 -0
- package/dist/patterns/form-wizard/index.js +8 -0
- package/dist/patterns/form-wizard/types.d.ts +109 -0
- package/dist/patterns/form-wizard/types.js +83 -0
- package/dist/patterns/form-wizard/wizard-summary.d.ts +62 -0
- package/dist/patterns/form-wizard/wizard-summary.js +324 -0
- package/dist/patterns/internal/safe-href.d.ts +17 -0
- package/dist/patterns/internal/safe-href.js +17 -0
- package/dist/patterns/lineage/index.d.ts +3 -0
- package/dist/patterns/lineage/index.js +6 -0
- package/dist/patterns/lineage/lineage-graph.d.ts +30 -0
- package/dist/patterns/lineage/lineage-graph.js +434 -0
- package/dist/patterns/lineage/provenance-strip.d.ts +22 -0
- package/dist/patterns/lineage/provenance-strip.js +194 -0
- package/dist/patterns/lineage/types.d.ts +53 -0
- package/dist/patterns/lineage/types.js +49 -0
- package/dist/patterns/notifications/index.d.ts +3 -0
- package/dist/patterns/notifications/index.js +6 -0
- package/dist/patterns/notifications/notification-bell.d.ts +38 -0
- package/dist/patterns/notifications/notification-bell.js +198 -0
- package/dist/patterns/notifications/notification-inbox.d.ts +46 -0
- package/dist/patterns/notifications/notification-inbox.js +537 -0
- package/dist/patterns/notifications/types.d.ts +61 -0
- package/dist/patterns/notifications/types.js +108 -0
- package/dist/patterns/preview/annotation-inspector.d.ts +25 -6
- package/dist/patterns/preview/annotation-inspector.js +239 -94
- package/dist/patterns/preview/annotation-thread.d.ts +25 -5
- package/dist/patterns/preview/annotation-thread.js +233 -82
- package/dist/patterns/preview/annotation-toolbar.d.ts +20 -6
- package/dist/patterns/preview/annotation-toolbar.js +162 -96
- package/dist/patterns/preview/content-preview-adapter.d.ts +10 -1
- package/dist/patterns/preview/content-preview-adapter.js +26 -1
- package/dist/patterns/preview/preview-element.d.ts +15 -2
- package/dist/patterns/preview/preview-element.js +223 -52
- package/dist/patterns/preview/provider-adapter.d.ts +47 -0
- package/dist/patterns/preview/provider-adapter.js +17 -0
- package/dist/patterns/run/index.d.ts +2 -0
- package/dist/patterns/run/index.js +4 -0
- package/dist/patterns/run/run-trace.d.ts +40 -0
- package/dist/patterns/run/run-trace.js +441 -0
- package/dist/patterns/run/types.d.ts +66 -0
- package/dist/patterns/run/types.js +152 -0
- package/dist/patterns/signature/index.d.ts +2 -0
- package/dist/patterns/signature/index.js +4 -0
- package/dist/patterns/signature/signature-ceremony.d.ts +33 -0
- package/dist/patterns/signature/signature-ceremony.js +317 -0
- package/dist/patterns/signature/types.d.ts +68 -0
- package/dist/patterns/signature/types.js +89 -0
- package/dist/patterns/timeline/index.d.ts +2 -0
- package/dist/patterns/timeline/index.js +4 -0
- package/dist/patterns/timeline/timeline.d.ts +27 -0
- package/dist/patterns/timeline/timeline.js +430 -0
- package/dist/patterns/timeline/types.d.ts +36 -0
- package/dist/patterns/timeline/types.js +27 -0
- package/dist/patterns/versions/graph-layout.d.ts +43 -0
- package/dist/patterns/versions/graph-layout.js +159 -0
- package/dist/patterns/versions/index.d.ts +4 -0
- package/dist/patterns/versions/index.js +8 -0
- package/dist/patterns/versions/shared.d.ts +4 -0
- package/dist/patterns/versions/shared.js +13 -0
- package/dist/patterns/versions/types.d.ts +37 -0
- package/dist/patterns/versions/types.js +39 -0
- package/dist/patterns/versions/version-graph.d.ts +36 -0
- package/dist/patterns/versions/version-graph.js +438 -0
- package/dist/patterns/versions/version-list.d.ts +39 -0
- package/dist/patterns/versions/version-list.js +407 -0
- package/dist/patterns/work-queue/controller.d.ts +26 -0
- package/dist/patterns/work-queue/controller.js +150 -0
- package/dist/patterns/work-queue/index.d.ts +4 -0
- package/dist/patterns/work-queue/index.js +7 -0
- package/dist/patterns/work-queue/types.d.ts +128 -0
- package/dist/patterns/work-queue/types.js +45 -0
- package/dist/patterns/work-queue/work-queue.d.ts +48 -0
- package/dist/patterns/work-queue/work-queue.js +534 -0
- package/dist/patterns/work-queue/workload-board.d.ts +53 -0
- package/dist/patterns/work-queue/workload-board.js +608 -0
- 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("<", "<")
|
|
8
|
+
.replaceAll(">", ">")
|
|
9
|
+
.replaceAll('"', """)
|
|
10
|
+
.replaceAll("'", "'");
|
|
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
|
+
}
|