@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.
Files changed (146) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +359 -2
  3. package/dist/PdfAnnotationCanvas.client-S64VRLUN.css +193 -0
  4. package/dist/PdfAnnotationCanvas.client-V7R4NXFO.js +799 -0
  5. package/dist/ar-AIV7P4FL.js +594 -0
  6. package/dist/bn-J2OR57PB.js +594 -0
  7. package/dist/chunk-4L3TYOIV.js +172 -0
  8. package/dist/chunk-BM76QBIO.js +594 -0
  9. package/dist/chunk-D2O46PZQ.js +240 -0
  10. package/dist/chunk-O23TLLXW.js +42 -0
  11. package/dist/chunk-WGTUIB6C.js +304 -0
  12. package/dist/cs-JNEAMHFB.js +594 -0
  13. package/dist/da-UY5ZRVTZ.js +594 -0
  14. package/dist/de-EETVXC42.js +594 -0
  15. package/dist/el-S5YKDMTL.js +594 -0
  16. package/dist/en-3YQWF45H.js +61 -0
  17. package/dist/es-GHA7S27R.js +594 -0
  18. package/dist/fa-JTR3GF6I.js +594 -0
  19. package/dist/fi-CQZ7BW57.js +594 -0
  20. package/dist/fr-OJH2WIY7.js +594 -0
  21. package/dist/he-2DBXWA2V.js +594 -0
  22. package/dist/hi-NZP7B55I.js +594 -0
  23. package/dist/id-4KXFKWOI.js +594 -0
  24. package/dist/index.css +4134 -0
  25. package/dist/index.d.ts +4040 -0
  26. package/dist/index.js +29638 -0
  27. package/dist/it-XBMYGKKY.js +594 -0
  28. package/dist/ja-OVHZS3EH.js +594 -0
  29. package/dist/ko-NW2MVM5L.js +594 -0
  30. package/dist/ms-RXLPBZLK.js +594 -0
  31. package/dist/nl-77CTBEDA.js +594 -0
  32. package/dist/no-RAPO56SE.js +594 -0
  33. package/dist/pl-XCFXZCTT.js +594 -0
  34. package/dist/pt-EMBE27IS.js +594 -0
  35. package/dist/ro-M7QLJBYN.js +594 -0
  36. package/dist/sv-ST6CITQY.js +594 -0
  37. package/dist/test-utils.css +112 -0
  38. package/dist/test-utils.d.ts +126 -0
  39. package/dist/test-utils.js +13119 -0
  40. package/dist/th-EEQGL3G7.js +594 -0
  41. package/dist/tr-5FYHZQKD.js +594 -0
  42. package/dist/uk-VTWDC467.js +594 -0
  43. package/dist/vi-ISBKJ66X.js +594 -0
  44. package/dist/zh-2AW2N66Z.js +594 -0
  45. package/package.json +132 -4
  46. package/src/components/ProtectedErrorBoundary.css +121 -0
  47. package/src/components/SessionExpiryBanner.css +67 -0
  48. package/src/components/StatusDisplay.css +439 -0
  49. package/src/components/Toast.css +136 -0
  50. package/src/components/annotation/annotation-entries.css +138 -0
  51. package/src/components/annotation/annotations.css +93 -0
  52. package/src/components/annotation/references.css +300 -0
  53. package/src/components/branding/Branding.css +129 -0
  54. package/src/components/error-states/errors.css +34 -0
  55. package/src/components/layout/Header.css +99 -0
  56. package/src/components/layout/LeftSidebar.css +115 -0
  57. package/src/components/layout/ResizeHandle.css +110 -0
  58. package/src/components/layout/SkipLinks.css +84 -0
  59. package/src/components/loading-states/loading.css +42 -0
  60. package/src/components/modals/SearchModal.css +1019 -0
  61. package/src/components/modals/modals.css +655 -0
  62. package/src/components/navigation/CollapsibleResourceNavigation.css +10 -0
  63. package/src/components/navigation/NavigationMenu.css +59 -0
  64. package/src/components/navigation/NavigationTabs.css +466 -0
  65. package/src/components/navigation/SimpleNavigation.css +9 -0
  66. package/src/components/pdf-annotation/PdfAnnotationCanvas.css +288 -0
  67. package/src/components/resource/panels/CollaborationPanel.css +184 -0
  68. package/src/components/resource/panels/DelegateSection.css +330 -0
  69. package/src/components/resource/panels/JsonLdPanel.css +37 -0
  70. package/src/components/resource/panels/ReferencesPanel.css +108 -0
  71. package/src/components/resource/panels/ResourceInfoPanel.css +183 -0
  72. package/src/components/resource/panels/StatisticsPanel.css +127 -0
  73. package/src/components/resource/panels/UnifiedAnnotationsPanel.css +129 -0
  74. package/src/components/settings/SettingsPanel.css +92 -0
  75. package/src/components/toolbar/Toolbar.css +245 -0
  76. package/src/features/auth/auth.css +120 -0
  77. package/src/styles/base/reset.css +105 -0
  78. package/src/styles/base/utilities.css +35 -0
  79. package/src/styles/core/badges.css +17 -0
  80. package/src/styles/core/buttons.css +772 -0
  81. package/src/styles/core/checkboxes.css +85 -0
  82. package/src/styles/core/forms.css +237 -0
  83. package/src/styles/core/index.css +43 -0
  84. package/src/styles/core/indicators.css +24 -0
  85. package/src/styles/core/inputs.css +164 -0
  86. package/src/styles/core/progress.css +85 -0
  87. package/src/styles/core/selects.css +119 -0
  88. package/src/styles/core/sliders.css +180 -0
  89. package/src/styles/core/tags.css +86 -0
  90. package/src/styles/core/textareas.css +104 -0
  91. package/src/styles/core/toggles.css +82 -0
  92. package/src/styles/features/compose.css +341 -0
  93. package/src/styles/features/entity-tags.css +140 -0
  94. package/src/styles/features/recent-docs.css +97 -0
  95. package/src/styles/features/resource-discovery.css +349 -0
  96. package/src/styles/features/resource-viewer.css +609 -0
  97. package/src/styles/features/resource.css +483 -0
  98. package/src/styles/features/schemas.css +222 -0
  99. package/src/styles/index.css +84 -0
  100. package/src/styles/layout/layout.css +28 -0
  101. package/src/styles/motivations/motivation-assessment.css +179 -0
  102. package/src/styles/motivations/motivation-comment.css +164 -0
  103. package/src/styles/motivations/motivation-highlight.css +132 -0
  104. package/src/styles/motivations/motivation-reference.css +167 -0
  105. package/src/styles/motivations/motivation-tag.css +182 -0
  106. package/src/styles/panels/history-panel.css +212 -0
  107. package/src/styles/panels/user-panel.css +21 -0
  108. package/src/styles/patterns/cards.css +26 -0
  109. package/src/styles/patterns/panel-helpers.css +32 -0
  110. package/src/styles/patterns/panels-base.css +272 -0
  111. package/src/styles/utilities/contrast.css +280 -0
  112. package/src/styles/utilities/focus-extended.css +276 -0
  113. package/src/styles/utilities/focus.css +41 -0
  114. package/src/styles/utilities/motion-overrides.css +286 -0
  115. package/src/styles/utilities/motion.css +184 -0
  116. package/src/styles/utilities/semantic-indicators.css +254 -0
  117. package/src/styles/variables.css +410 -0
  118. package/translations/ar.json +534 -0
  119. package/translations/bn.json +534 -0
  120. package/translations/cs.json +534 -0
  121. package/translations/da.json +534 -0
  122. package/translations/de.json +534 -0
  123. package/translations/el.json +534 -0
  124. package/translations/en.json +534 -0
  125. package/translations/es.json +534 -0
  126. package/translations/fa.json +534 -0
  127. package/translations/fi.json +534 -0
  128. package/translations/fr.json +534 -0
  129. package/translations/he.json +534 -0
  130. package/translations/hi.json +534 -0
  131. package/translations/id.json +534 -0
  132. package/translations/it.json +534 -0
  133. package/translations/ja.json +534 -0
  134. package/translations/ko.json +534 -0
  135. package/translations/ms.json +534 -0
  136. package/translations/nl.json +534 -0
  137. package/translations/no.json +534 -0
  138. package/translations/pl.json +534 -0
  139. package/translations/pt.json +534 -0
  140. package/translations/ro.json +534 -0
  141. package/translations/sv.json +534 -0
  142. package/translations/th.json +534 -0
  143. package/translations/tr.json +534 -0
  144. package/translations/uk.json +534 -0
  145. package/translations/vi.json +534 -0
  146. 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