@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
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,360 @@
1
- # Temporary Holding Version
1
+ # @xynolog/react-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![Tests](https://github.com/xynolog/sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/xynolog/sdk/actions/workflows/ci.yml?query=branch%3Amain+is%3Asuccess+job%3A%22Test+react-ui%22)
4
+ [![codecov](https://codecov.io/gh/xynolog/sdk/graph/badge.svg?component=typescript-react-ui)](https://app.codecov.io/gh/xynolog/sdk/components)
5
+ [![npm version](https://img.shields.io/npm/v/@xynolog/react-ui.svg)](https://www.npmjs.com/package/@xynolog/react-ui)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@xynolog/react-ui.svg)](https://www.npmjs.com/package/@xynolog/react-ui)
7
+ [![License](https://img.shields.io/npm/l/@xynolog/react-ui.svg)](https://github.com/xynolog/sdk/blob/v0.8.1/LICENSE)
8
+ [![WCAG 2.1 AA](https://img.shields.io/badge/WCAG-2.1%20AA-blue.svg)](https://www.w3.org/WAI/WCAG2AA-Conformance)
9
+
10
+ Framework-agnostic React component library for building Xynolog knowledge management applications.
11
+
12
+ ## Overview
13
+
14
+ `@xynolog/react-ui` provides reusable React components, hooks, and utilities for creating Xynolog applications. The library is designed to be **completely framework-agnostic**, working seamlessly with Next.js, Create React App, Vite, Remix, or any other React framework.
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install @xynolog/react-ui @xynolog/sdk @xynolog/core
20
+ ```
21
+
22
+ Below 1.0 the minor number is the break, and the caret range npm writes into `package.json`
23
+ takes the releases up to the next minor and no further.
24
+
25
+ `@xynolog/sdk` is the primary dependency — it provides the `XynologBrowser`,
26
+ `XynologClient`, the read-through cache, and the state machinery that
27
+ `@xynolog/react-ui` renders. `@xynolog/core` provides the shared API types.
28
+
29
+ ### Peer Dependencies
30
+
31
+ ```json
32
+ {
33
+ "react": "^19.0.0",
34
+ "react-dom": "^19.0.0"
35
+ }
36
+ ```
37
+
38
+ ### CSS Setup
39
+
40
+ Import the styles in your app's main CSS file:
41
+
42
+ ```css
43
+ /* Your app's main CSS file (e.g., globals.css, app.css) */
44
+ @import '@xynolog/react-ui/styles';
45
+ ```
46
+
47
+ **Requirements:**
48
+ - Your build system must support PostCSS with `postcss-import` plugin
49
+ - This is standard in Next.js, Vite, and most modern build tools
50
+ - The package exports source CSS files, which your build system will process
51
+
52
+ **What this does:**
53
+ - Imports all component styles, design tokens, and CSS variables
54
+ - Your build tool processes the `@import` statements and bundles the CSS
55
+ - No additional configuration needed in most frameworks
56
+
57
+ ## Quick Start
58
+
59
+ ### 1. Set Up Providers
60
+
61
+ ```tsx
62
+ import {
63
+ XynologProvider,
64
+ TranslationProvider,
65
+ ProtectedErrorBoundary,
66
+ SessionEndedModal,
67
+ PermissionDeniedModal,
68
+ type TranslationManager,
69
+ } from '@xynolog/react-ui';
70
+
71
+ function App({ translationManager, children }: { translationManager: TranslationManager; children: React.ReactNode }) {
72
+ // `translationManager` is your implementation (see "Use Translations" below)
73
+ return (
74
+ <TranslationProvider translationManager={translationManager}>
75
+ {/* XynologProvider puts the XynologBrowser singleton into context.
76
+ useXynolog() hands it back; the active XynologSession (and its
77
+ XynologClient) flow from there. */}
78
+ <XynologProvider>
79
+ <ProtectedErrorBoundary>
80
+ <SessionEndedModal />
81
+ <PermissionDeniedModal />
82
+ {children}
83
+ </ProtectedErrorBoundary>
84
+ </XynologProvider>
85
+ </TranslationProvider>
86
+ );
87
+ }
88
+ ```
89
+
90
+ ### 2. Use Components
91
+
92
+ ```tsx
93
+ import { ResourceViewer, useResourceLoader, useXynolog, useObservable } from '@xynolog/react-ui';
94
+
95
+ function Resource({ rId }: { rId: ResourceId }) {
96
+ // The active session (null until one is signed in) and its client
97
+ const session = useObservable(useXynolog().activeSession$) ?? null;
98
+ // browse.resource() and browse.annotations() are SDK live queries backed by
99
+ // the read-through cache; useResourceLoader subscribes to both.
100
+ const { resource, annotations } = useResourceLoader(session?.client ?? null, rId);
101
+
102
+ if (!resource) return <div>Loading...</div>;
103
+
104
+ // `content` is the decoded text the host fetched (see useResourceContent)
105
+ return <ResourceViewer locale="en" session={session} resource={{ ...resource, content }} annotations={annotations} />;
106
+ }
107
+ ```
108
+
109
+ ### 3. Use Translations
110
+
111
+ ```tsx
112
+ import { TranslationProvider, useTranslations, type TranslationManager } from '@xynolog/react-ui';
113
+
114
+ // Reads the nearest TranslationProvider, and throws when there is none
115
+ function SettingsButton() {
116
+ const t = useTranslations('Toolbar');
117
+ return <button>{t('settings')}</button>;
118
+ }
119
+
120
+ // Option 1: Built-in locales
121
+ function SpanishApp() {
122
+ return (
123
+ <TranslationProvider locale="es">
124
+ <SettingsButton />
125
+ </TranslationProvider>
126
+ );
127
+ }
128
+
129
+ // Option 2: Custom translation system
130
+ const messages: Record<string, Record<string, string>> = {
131
+ Toolbar: { settings: 'Ajustes' },
132
+ };
133
+
134
+ const myTranslationManager: TranslationManager = {
135
+ t: (namespace, key) => messages[namespace]?.[key] ?? `${namespace}.${key}`,
136
+ };
137
+
138
+ function CustomApp() {
139
+ return (
140
+ <TranslationProvider translationManager={myTranslationManager}>
141
+ <SettingsButton />
142
+ </TranslationProvider>
143
+ );
144
+ }
145
+ ```
146
+
147
+ ### 4. Embed the Viewer With a Bare Session
148
+
149
+ `ResourceViewer`, `BrowseView` and `AnnotateView` need no provider. Each takes a session and its
150
+ language as props, and mounts its own `TranslationProvider` from the language. The language is
151
+ required: a `locale` of react-ui's own, or the host's `translationManager`. react-ui assumes
152
+ none, so a host that leaves it out does not compile.
153
+
154
+ ```tsx
155
+ import { ResourceViewer, useResourceLoader } from '@xynolog/react-ui';
156
+ import type { ResourceId } from '@xynolog/core';
157
+ import type { XynologSession } from '@xynolog/sdk';
158
+
159
+ function EmbeddedResource({ session, rId, content }: { session: XynologSession; rId: ResourceId; content: string }) {
160
+ const { resource, annotations } = useResourceLoader(session.client, rId);
161
+ if (!resource) return null;
162
+ return <ResourceViewer locale="en" session={session} resource={{ ...resource, content }} annotations={annotations} />;
163
+ }
164
+ ```
165
+
166
+ A locale's strings load the first time a view of that locale mounts; every view after that renders
167
+ at once. Colours, the JSON-LD view's among them, follow the page's `data-theme` attribute through
168
+ react-ui's stylesheet, so dark mode needs nothing more.
169
+
170
+ ## Key Features
171
+
172
+ - **Framework Independence** - Zero dependencies on Next.js, next-auth, or next-intl
173
+ - **Component Composition** - Components accept framework-specific implementations (Link, routing) as props
174
+ - **Provider Pattern** - Consistent approach for session, translations, and routing
175
+ - **SDK Live Queries** - Read data with `useObservable()` over the SDK's read-through cache; no bespoke fetching layer
176
+ - **Authentication Components** - Error display; signing in happens at the knowledge base's issuer
177
+ - **Navigation Components** - Collapsible sidebar with drag & drop resource tabs
178
+ - **Modal Components** - Global search and resource selection modals
179
+ - **Accessibility First** - WCAG compliant with keyboard navigation, screen reader support
180
+ - **Comprehensive Testing** - 1250+ tests with extensive coverage
181
+ - **Annotation System** - Rich annotation and tagging capabilities
182
+ - **Built-in Translations** - one per supported language (`LOCALE_CODES` from `@xynolog/core`), each loaded on demand
183
+ - **Flexible i18n** - Two modes: built-in locales or a custom translation system. There is no default language
184
+
185
+ ## Architecture
186
+
187
+ The library follows strict architectural principles:
188
+
189
+ - **No Aliasing or Wrappers** - Direct API access, no compatibility layers
190
+ - **Provider Pattern** - Consistent dependency injection via React Context
191
+ - **Framework Agnostic** - Apps provide framework-specific implementations
192
+ - **TypeScript First** - Full type safety throughout
193
+
194
+ ## CSS Architecture
195
+
196
+ **This package ships plain CSS and no utility framework.** No Tailwind, no
197
+ `@apply`, no utility classes — only `xynolog-`-prefixed BEM classes, data
198
+ attributes, and CSS custom properties. The rule exists so the stylesheet drops
199
+ into any stack a host happens to use, and it is enforced, not merely intended:
200
+ `npm run lint:no-utility-classes` plus the `xynolog/invariants` stylelint rule
201
+ fail on a utility class or a non-`xynolog-` selector.
202
+
203
+ The rule binds the library, not its hosts. An app is free to use whatever it
204
+ likes — `images/browser` uses Tailwind — and consumes this package by whichever
205
+ route fits:
206
+
207
+ | Host stack | Consume via |
208
+ |---|---|
209
+ | Anything with PostCSS | `@import '@xynolog/react-ui/styles'` |
210
+ | Own design system | `@xynolog/react-ui/styles/variables.css` for the tokens alone |
211
+
212
+ The styles are organized into a modular, maintainable structure:
213
+
214
+ - **Design Tokens** - Centralized variables for consistent theming
215
+ - **Core UI Elements** - Fundamental, reusable components (buttons, toggles, sliders, etc.)
216
+ - **W3C Motivations** - Dedicated styles for Web Annotation standard motivations
217
+ - **Component/Panel Separation** - Complex components vs. layout containers
218
+ - **Dark Theme Support** - Comprehensive dark mode using `[data-theme="dark"]`
219
+
220
+ Key directories:
221
+ - `styles/core/` - Fundamental UI elements (buttons, toggles, progress bars, sliders, badges, tags, indicators)
222
+ - `styles/motivations/` - W3C Web Annotation motivation styles (reference, highlight, assessment, comment, tag)
223
+ - `styles/components/` - Complex, composed components
224
+ - `styles/panels/` - Panel layouts and containers
225
+ - `styles/features/` - Feature-specific styling
226
+
227
+ See [STYLES.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/STYLES.md) for detailed CSS documentation.
228
+
229
+ ## Core Concepts
230
+
231
+ ### Providers
232
+
233
+ Cross-cutting concerns use the Provider Pattern:
234
+
235
+ - **XynologProvider** - The single React provider for session state. Puts the module-scoped `XynologBrowser` singleton into context; `useXynolog()` returns it. The browser owns the KB list, active KB, and validated session lifecycle — it's the single source of truth for "which KB and what's the session against it." The active `XynologSession` (and its `XynologClient`) flow from `browser.activeSession$`.
236
+ - **TranslationProvider** - Internationalization
237
+ - **Routing** - Not a provider: components that link take the host's `Link` and `routes` as props (`LinkComponentProps`, `RouteBuilder`)
238
+
239
+ See [SESSION.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/SESSION.md) for details.
240
+
241
+ ### Page state machines
242
+
243
+ `@xynolog/react-ui` houses the framework-neutral state machinery for the Xynolog Browser's specific pages and shell. These are RxJS-based factories (no React inside; pure observables and async functions) but they're shaped around the Browser's page taxonomy, so they belong with the components that render them rather than in `@xynolog/sdk`:
244
+
245
+ - **Shell** — `createShellStateUnit` (toolbar panel state with `'knowledge-base' | 'common' | 'resource'` taxonomy)
246
+ - **Pages** — `createComposePageStateUnit`, `createResourceViewerPageStateUnit`, `createResourceLoaderStateUnit`
247
+ - **Discovery + moderation** — `createDiscoverStateUnit`, `createEntityTagsStateUnit`
248
+
249
+ Adjacent to the state units: `useKBDiscovery` binds the sdk's
250
+ launcher-KB discovery subscription (`subscribeDiscovery`) to React state —
251
+ see [SESSION.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/SESSION.md#usekbdiscovery--launcher-published-kbs).
252
+
253
+ Each lives in `src/features/<feature>/state/` (or `src/state/` for cross-feature ones) next to the components that consume it. The `useStateUnit` hook wires them into React lifecycles.
254
+
255
+ Use them via `import { createComposePageStateUnit } from '@xynolog/react-ui'`. UI-shape-neutral state machines (flow VMs, worker adapters, search pipeline) live in `@xynolog/sdk` and are re-exported from here for convenience.
256
+
257
+ ### API Integration
258
+
259
+ Data fetching and caching are an SDK concern. The SDK exposes an RxJS
260
+ read-through cache (stale-while-revalidate); react-ui consumes it as live
261
+ queries via `useObservable()`. Reads come from `client.browse.*(...)`
262
+ observables; writes go through the typed namespaces (`client.mark.*`,
263
+ `client.bind.*`, etc.).
264
+
265
+ ```tsx
266
+ import { useXynolog, useObservable } from '@xynolog/react-ui';
267
+ import { readyValue } from '@xynolog/sdk';
268
+
269
+ function Example() {
270
+ const client = useObservable(useXynolog().activeSession$)?.client;
271
+
272
+ // Read: live query over the read-through cache. Emissions are
273
+ // CacheState<ResourceList>; readyValue projects out the ready envelope.
274
+ const state = useObservable(client?.browse.resources({ limit: 10 }));
275
+ const resources = state && readyValue(state)?.resources; // undefined until ready
276
+
277
+ // Write: typed namespace call (cache invalidation is handled by the SDK)
278
+ const archive = (rUri: ResourceId) => client?.mark.archive(rUri);
279
+ }
280
+ ```
281
+
282
+ See [API-INTEGRATION.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/API-INTEGRATION.md) for details.
283
+
284
+ ### Testing
285
+
286
+ Comprehensive test utilities included:
287
+
288
+ ```tsx
289
+ import { renderWithProviders, screen } from '@xynolog/react-ui/test-utils';
290
+
291
+ it('should render component', () => {
292
+ renderWithProviders(<Toolbar context="simple" activePanel={null} />);
293
+ expect(screen.getByLabelText('Toolbar.settings')).toBeInTheDocument();
294
+ });
295
+ ```
296
+
297
+ See [TESTING.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/TESTING.md) for details.
298
+
299
+ ## Documentation
300
+
301
+ - [SESSION.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/SESSION.md) - Provider Pattern and manager interfaces
302
+ - [INTERNATIONALIZATION.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/INTERNATIONALIZATION.md) - Translation approach
303
+ - [TESTING.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/TESTING.md) - Testing utilities and patterns
304
+ - [API-INTEGRATION.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/API-INTEGRATION.md) - Working with the Xynolog API
305
+ - [EVENTS.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/EVENTS.md) - Subscribing and emitting from React, and reading the wire log
306
+ - [COMPONENTS.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/COMPONENTS.md) - Component library reference
307
+ - [navigation-components.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/navigation-components.md) - Navigation components (CollapsibleResourceNavigation, SimpleNavigation, NavigationMenu, ObservableLink)
308
+ - [modal-components.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/modal-components.md) - Modal components (SearchModal)
309
+ - [ROUTING.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/ROUTING.md) - Framework-agnostic routing
310
+ - [ARCHITECTURE.md](https://github.com/xynolog/sdk/blob/v0.8.1/typescript/react-ui/docs/ARCHITECTURE.md) - Design principles and decisions
311
+ - [STYLES.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/STYLES.md) - Using the styles, design tokens and classes
312
+ - [ANNOTATIONS.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/ANNOTATIONS.md) - Annotation system
313
+ - [ACCESSIBILITY.md](https://github.com/xynolog/docs/blob/main/builder/react-ui/ACCESSIBILITY.md) - Accessibility architecture and WCAG compliance
314
+
315
+ ## Examples
316
+
317
+ ### Vite Integration
318
+
319
+ ```tsx
320
+ // src/App.tsx
321
+ import { TranslationProvider, XynologProvider, type TranslationManager } from '@xynolog/react-ui';
322
+
323
+ function useTranslationManager(): TranslationManager {
324
+ return {
325
+ t: (namespace, key) => `${namespace}.${key}` // Your i18n library
326
+ };
327
+ }
328
+
329
+ function App({ children }: { children: React.ReactNode }) {
330
+ const translationManager = useTranslationManager();
331
+
332
+ // XynologProvider defaults to the canonical web setup (WebBrowserStorage +
333
+ // an HTTP session factory). It reads the module-scoped XynologBrowser
334
+ // singleton via getBrowser() — no client construction here. Sign-in flows
335
+ // adopt the OAuth session onto the browser; browser.activeSession$ then
336
+ // carries the live XynologClient.
337
+ return (
338
+ <TranslationProvider translationManager={translationManager}>
339
+ <XynologProvider>{children}</XynologProvider>
340
+ </TranslationProvider>
341
+ );
342
+ }
343
+ ```
344
+
345
+ The Xynolog Browser (`images/browser`, Vite + React Router) is the full reference: its
346
+ `images/browser/src/app/providers.tsx` mounts the whole provider stack, with a translation
347
+ manager built over react-i18next.
348
+
349
+ ## License
350
+
351
+ [License information to be added]
352
+
353
+ ## Related Packages
354
+
355
+ - [@xynolog/sdk](https://github.com/xynolog/sdk/tree/v0.8.1/typescript/sdk) - `XynologBrowser`, `XynologClient`, the read-through cache, and the state machinery. Its [**Developer Guide**](https://github.com/xynolog/docs/blob/main/builder/DEVELOPER-GUIDE.md) covers end-to-end use, including embedding this package's `ResourceViewer`.
356
+ - [@xynolog/core](https://github.com/xynolog/sdk/tree/v0.8.1/typescript/core) - Shared API types (`components`) generated from the OpenAPI spec
357
+ - [@xynolog/http-transport](https://github.com/xynolog/sdk/tree/v0.8.1/typescript/http-transport) - HTTP transport (`HttpTransport`, `HttpContentTransport`, `APIError`)
358
+ - [xynolog-browser](https://github.com/xynolog/images/tree/main/browser) - Reference implementation (Vite + React Router)
359
+
360
+ Working on the SDK itself? See [CONTRIBUTING.md](https://github.com/xynolog/sdk/blob/main/CONTRIBUTING.md).