@xynolog/react-ui 0.0.0-stage → 0.8.1
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/LICENSE +201 -0
- package/README.md +359 -2
- package/dist/PdfAnnotationCanvas.client-S64VRLUN.css +193 -0
- package/dist/PdfAnnotationCanvas.client-V7R4NXFO.js +799 -0
- package/dist/ar-AIV7P4FL.js +594 -0
- package/dist/bn-J2OR57PB.js +594 -0
- package/dist/chunk-4L3TYOIV.js +172 -0
- package/dist/chunk-BM76QBIO.js +594 -0
- package/dist/chunk-D2O46PZQ.js +240 -0
- package/dist/chunk-O23TLLXW.js +42 -0
- package/dist/chunk-WGTUIB6C.js +304 -0
- package/dist/cs-JNEAMHFB.js +594 -0
- package/dist/da-UY5ZRVTZ.js +594 -0
- package/dist/de-EETVXC42.js +594 -0
- package/dist/el-S5YKDMTL.js +594 -0
- package/dist/en-3YQWF45H.js +61 -0
- package/dist/es-GHA7S27R.js +594 -0
- package/dist/fa-JTR3GF6I.js +594 -0
- package/dist/fi-CQZ7BW57.js +594 -0
- package/dist/fr-OJH2WIY7.js +594 -0
- package/dist/he-2DBXWA2V.js +594 -0
- package/dist/hi-NZP7B55I.js +594 -0
- package/dist/id-4KXFKWOI.js +594 -0
- package/dist/index.css +4134 -0
- package/dist/index.d.ts +4040 -0
- package/dist/index.js +29638 -0
- package/dist/it-XBMYGKKY.js +594 -0
- package/dist/ja-OVHZS3EH.js +594 -0
- package/dist/ko-NW2MVM5L.js +594 -0
- package/dist/ms-RXLPBZLK.js +594 -0
- package/dist/nl-77CTBEDA.js +594 -0
- package/dist/no-RAPO56SE.js +594 -0
- package/dist/pl-XCFXZCTT.js +594 -0
- package/dist/pt-EMBE27IS.js +594 -0
- package/dist/ro-M7QLJBYN.js +594 -0
- package/dist/sv-ST6CITQY.js +594 -0
- package/dist/test-utils.css +112 -0
- package/dist/test-utils.d.ts +126 -0
- package/dist/test-utils.js +13119 -0
- package/dist/th-EEQGL3G7.js +594 -0
- package/dist/tr-5FYHZQKD.js +594 -0
- package/dist/uk-VTWDC467.js +594 -0
- package/dist/vi-ISBKJ66X.js +594 -0
- package/dist/zh-2AW2N66Z.js +594 -0
- package/package.json +132 -4
- package/src/components/ProtectedErrorBoundary.css +121 -0
- package/src/components/SessionExpiryBanner.css +67 -0
- package/src/components/StatusDisplay.css +439 -0
- package/src/components/Toast.css +136 -0
- package/src/components/annotation/annotation-entries.css +138 -0
- package/src/components/annotation/annotations.css +93 -0
- package/src/components/annotation/references.css +300 -0
- package/src/components/branding/Branding.css +129 -0
- package/src/components/error-states/errors.css +34 -0
- package/src/components/layout/Header.css +99 -0
- package/src/components/layout/LeftSidebar.css +115 -0
- package/src/components/layout/ResizeHandle.css +110 -0
- package/src/components/layout/SkipLinks.css +84 -0
- package/src/components/loading-states/loading.css +42 -0
- package/src/components/modals/SearchModal.css +1019 -0
- package/src/components/modals/modals.css +655 -0
- package/src/components/navigation/CollapsibleResourceNavigation.css +10 -0
- package/src/components/navigation/NavigationMenu.css +59 -0
- package/src/components/navigation/NavigationTabs.css +466 -0
- package/src/components/navigation/SimpleNavigation.css +9 -0
- package/src/components/pdf-annotation/PdfAnnotationCanvas.css +288 -0
- package/src/components/resource/panels/CollaborationPanel.css +184 -0
- package/src/components/resource/panels/DelegateSection.css +330 -0
- package/src/components/resource/panels/JsonLdPanel.css +37 -0
- package/src/components/resource/panels/ReferencesPanel.css +108 -0
- package/src/components/resource/panels/ResourceInfoPanel.css +183 -0
- package/src/components/resource/panels/StatisticsPanel.css +127 -0
- package/src/components/resource/panels/UnifiedAnnotationsPanel.css +129 -0
- package/src/components/settings/SettingsPanel.css +92 -0
- package/src/components/toolbar/Toolbar.css +245 -0
- package/src/features/auth/auth.css +120 -0
- package/src/styles/base/reset.css +105 -0
- package/src/styles/base/utilities.css +35 -0
- package/src/styles/core/badges.css +17 -0
- package/src/styles/core/buttons.css +772 -0
- package/src/styles/core/checkboxes.css +85 -0
- package/src/styles/core/forms.css +237 -0
- package/src/styles/core/index.css +43 -0
- package/src/styles/core/indicators.css +24 -0
- package/src/styles/core/inputs.css +164 -0
- package/src/styles/core/progress.css +85 -0
- package/src/styles/core/selects.css +119 -0
- package/src/styles/core/sliders.css +180 -0
- package/src/styles/core/tags.css +86 -0
- package/src/styles/core/textareas.css +104 -0
- package/src/styles/core/toggles.css +82 -0
- package/src/styles/features/compose.css +341 -0
- package/src/styles/features/entity-tags.css +140 -0
- package/src/styles/features/recent-docs.css +97 -0
- package/src/styles/features/resource-discovery.css +349 -0
- package/src/styles/features/resource-viewer.css +609 -0
- package/src/styles/features/resource.css +483 -0
- package/src/styles/features/schemas.css +222 -0
- package/src/styles/index.css +84 -0
- package/src/styles/layout/layout.css +28 -0
- package/src/styles/motivations/motivation-assessment.css +179 -0
- package/src/styles/motivations/motivation-comment.css +164 -0
- package/src/styles/motivations/motivation-highlight.css +132 -0
- package/src/styles/motivations/motivation-reference.css +167 -0
- package/src/styles/motivations/motivation-tag.css +182 -0
- package/src/styles/panels/history-panel.css +212 -0
- package/src/styles/panels/user-panel.css +21 -0
- package/src/styles/patterns/cards.css +26 -0
- package/src/styles/patterns/panel-helpers.css +32 -0
- package/src/styles/patterns/panels-base.css +272 -0
- package/src/styles/utilities/contrast.css +280 -0
- package/src/styles/utilities/focus-extended.css +276 -0
- package/src/styles/utilities/focus.css +41 -0
- package/src/styles/utilities/motion-overrides.css +286 -0
- package/src/styles/utilities/motion.css +184 -0
- package/src/styles/utilities/semantic-indicators.css +254 -0
- package/src/styles/variables.css +410 -0
- package/translations/ar.json +534 -0
- package/translations/bn.json +534 -0
- package/translations/cs.json +534 -0
- package/translations/da.json +534 -0
- package/translations/de.json +534 -0
- package/translations/el.json +534 -0
- package/translations/en.json +534 -0
- package/translations/es.json +534 -0
- package/translations/fa.json +534 -0
- package/translations/fi.json +534 -0
- package/translations/fr.json +534 -0
- package/translations/he.json +534 -0
- package/translations/hi.json +534 -0
- package/translations/id.json +534 -0
- package/translations/it.json +534 -0
- package/translations/ja.json +534 -0
- package/translations/ko.json +534 -0
- package/translations/ms.json +534 -0
- package/translations/nl.json +534 -0
- package/translations/no.json +534 -0
- package/translations/pl.json +534 -0
- package/translations/pt.json +534 -0
- package/translations/ro.json +534 -0
- package/translations/sv.json +534 -0
- package/translations/th.json +534 -0
- package/translations/tr.json +534 -0
- package/translations/uk.json +534 -0
- package/translations/vi.json +534 -0
- package/translations/zh.json +534 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
useTranslations
|
|
4
|
+
} from "./chunk-D2O46PZQ.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/browser-pdfjs.ts
|
|
7
|
+
var workerSrc;
|
|
8
|
+
var wasmUrl;
|
|
9
|
+
function setPdfWorkerSrc(src) {
|
|
10
|
+
workerSrc = src;
|
|
11
|
+
}
|
|
12
|
+
function setPdfWasmUrl(url) {
|
|
13
|
+
wasmUrl = url;
|
|
14
|
+
}
|
|
15
|
+
var pdfjsPromise;
|
|
16
|
+
async function getPdfjs() {
|
|
17
|
+
if (!pdfjsPromise) {
|
|
18
|
+
pdfjsPromise = import("pdfjs-dist").then((pdfjsLib) => {
|
|
19
|
+
if (workerSrc) {
|
|
20
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc;
|
|
21
|
+
}
|
|
22
|
+
return pdfjsLib;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return pdfjsPromise;
|
|
26
|
+
}
|
|
27
|
+
async function loadPdfDocument(url) {
|
|
28
|
+
const pdfjsLib = await getPdfjs();
|
|
29
|
+
return pdfjsLib.getDocument({ url, ...wasmUrl ? { wasmUrl } : {} }).promise;
|
|
30
|
+
}
|
|
31
|
+
async function renderPdfPageToDataUrl(page, scale = 1) {
|
|
32
|
+
const viewport = page.getViewport({ scale });
|
|
33
|
+
const canvas = document.createElement("canvas");
|
|
34
|
+
canvas.width = viewport.width;
|
|
35
|
+
canvas.height = viewport.height;
|
|
36
|
+
await page.render({ canvas, viewport }).promise;
|
|
37
|
+
return {
|
|
38
|
+
dataUrl: canvas.toDataURL("image/png"),
|
|
39
|
+
width: viewport.width,
|
|
40
|
+
height: viewport.height
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// src/hooks/useHoverDwell.ts
|
|
45
|
+
import { useEffect, useState } from "react";
|
|
46
|
+
import {
|
|
47
|
+
createHoverDwell
|
|
48
|
+
} from "@xynolog/sdk";
|
|
49
|
+
function useHoverDwell(session, delayMs) {
|
|
50
|
+
const [dwell, setDwell] = useState(void 0);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!session) {
|
|
53
|
+
setDwell(void 0);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const made = createHoverDwell(
|
|
57
|
+
(id) => session.client.beckon.hover(id),
|
|
58
|
+
delayMs
|
|
59
|
+
);
|
|
60
|
+
setDwell(made);
|
|
61
|
+
return () => {
|
|
62
|
+
made.dispose();
|
|
63
|
+
setDwell(void 0);
|
|
64
|
+
};
|
|
65
|
+
}, [session, delayMs]);
|
|
66
|
+
return dwell;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/lib/anchor-rect.ts
|
|
70
|
+
function toViewportAnchorRect(origin, x, y, width, height) {
|
|
71
|
+
const left = origin.left + x;
|
|
72
|
+
const top = origin.top + y;
|
|
73
|
+
return {
|
|
74
|
+
x: left,
|
|
75
|
+
y: top,
|
|
76
|
+
width,
|
|
77
|
+
height,
|
|
78
|
+
top,
|
|
79
|
+
right: left + width,
|
|
80
|
+
bottom: top + height,
|
|
81
|
+
left
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/components/annotation/AnchoredTextNotice.tsx
|
|
86
|
+
import { jsx } from "react/jsx-runtime";
|
|
87
|
+
function AnchoredTextNotice({
|
|
88
|
+
status
|
|
89
|
+
}) {
|
|
90
|
+
if (status === "held" || status === "unasked") return null;
|
|
91
|
+
return /* @__PURE__ */ jsx(AnchoredTextLine, { status });
|
|
92
|
+
}
|
|
93
|
+
function AnchoredTextLine({ status }) {
|
|
94
|
+
const t = useTranslations("PdfViewer");
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
className: "xynolog-anchored-text-notice",
|
|
99
|
+
"data-anchored-text": status,
|
|
100
|
+
role: "status",
|
|
101
|
+
children: t(status === "waiting" ? "preparingTextLayer" : "textLayerUnreadable")
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/hooks/useAnchoredText.ts
|
|
107
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
108
|
+
import { ANCHORED_TEXT_REASK_MS } from "@xynolog/core";
|
|
109
|
+
var WAITING = { status: "waiting" };
|
|
110
|
+
var NEVER = { status: "never" };
|
|
111
|
+
var UNASKED = { status: "unasked" };
|
|
112
|
+
var NO_TEXT = {
|
|
113
|
+
status: "held",
|
|
114
|
+
text: { text: "", items: [] }
|
|
115
|
+
};
|
|
116
|
+
function useAnchoredText(session, resourceUri) {
|
|
117
|
+
const [settled, setSettled] = useState2(null);
|
|
118
|
+
useEffect2(() => {
|
|
119
|
+
if (!session) return;
|
|
120
|
+
let cancelled = false;
|
|
121
|
+
let reask;
|
|
122
|
+
const settle = (state) => setSettled({ session, resourceUri, state });
|
|
123
|
+
const ask = () => {
|
|
124
|
+
void session.client.browse.resourceAnchoredText(resourceUri).then(
|
|
125
|
+
(answer) => {
|
|
126
|
+
if (cancelled) return;
|
|
127
|
+
switch (answer.kind) {
|
|
128
|
+
case "extracted":
|
|
129
|
+
settle({ status: "held", text: answer });
|
|
130
|
+
return;
|
|
131
|
+
case "no-map":
|
|
132
|
+
settle(NO_TEXT);
|
|
133
|
+
return;
|
|
134
|
+
case "declined":
|
|
135
|
+
case "unknown":
|
|
136
|
+
settle(NEVER);
|
|
137
|
+
return;
|
|
138
|
+
case "not-yet":
|
|
139
|
+
reask = setTimeout(ask, ANCHORED_TEXT_REASK_MS);
|
|
140
|
+
return;
|
|
141
|
+
default: {
|
|
142
|
+
const unreachable = answer;
|
|
143
|
+
return unreachable;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
() => {
|
|
148
|
+
if (!cancelled) reask = setTimeout(ask, ANCHORED_TEXT_REASK_MS);
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
ask();
|
|
153
|
+
return () => {
|
|
154
|
+
cancelled = true;
|
|
155
|
+
clearTimeout(reask);
|
|
156
|
+
};
|
|
157
|
+
}, [session, resourceUri]);
|
|
158
|
+
if (!session) return UNASKED;
|
|
159
|
+
return settled && settled.session === session && settled.resourceUri === resourceUri ? settled.state : WAITING;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export {
|
|
163
|
+
setPdfWorkerSrc,
|
|
164
|
+
setPdfWasmUrl,
|
|
165
|
+
loadPdfDocument,
|
|
166
|
+
renderPdfPageToDataUrl,
|
|
167
|
+
useHoverDwell,
|
|
168
|
+
toViewportAnchorRect,
|
|
169
|
+
AnchoredTextNotice,
|
|
170
|
+
useAnchoredText
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=chunk-4L3TYOIV.js.map
|