@semiont/react-ui 0.5.23 → 0.5.24

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 (48) hide show
  1. package/dist/{chunk-RO5CRVIA.js → chunk-4QMTEPQ3.js} +62 -30
  2. package/dist/chunk-4QMTEPQ3.js.map +1 -0
  3. package/dist/index.d.ts +18 -30
  4. package/dist/index.js +371 -409
  5. package/dist/index.js.map +1 -1
  6. package/dist/test-utils.js +3 -2
  7. package/dist/test-utils.js.map +1 -1
  8. package/package.json +4 -4
  9. package/src/components/annotation-popups/JsonLdView.tsx +1 -1
  10. package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +8 -2
  11. package/src/components/modals/ReferenceWizardModal.tsx +2 -1
  12. package/src/components/resource/panels/JsonLdPanel.tsx +1 -1
  13. package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +8 -2
  14. package/src/components/settings/SettingsPanel.tsx +6 -2
  15. package/src/components/settings/__tests__/SettingsPanel.test.tsx +28 -3
  16. package/src/features/admin-devops/__tests__/AdminDevOpsPage.test.tsx +3 -11
  17. package/src/features/admin-devops/components/AdminDevOpsPage.tsx +0 -3
  18. package/src/features/admin-exchange/__tests__/AdminExchangePage.test.tsx +0 -1
  19. package/src/features/admin-exchange/components/AdminExchangePage.tsx +0 -3
  20. package/src/features/admin-exchange/state/__tests__/exchange-state-unit.test.ts +1 -1
  21. package/src/features/admin-security/__tests__/AdminSecurityPage.test.tsx +0 -8
  22. package/src/features/admin-security/components/AdminSecurityPage.tsx +0 -3
  23. package/src/features/admin-security/state/__tests__/admin-security-state-unit.test.ts +1 -1
  24. package/src/features/admin-users/__tests__/AdminUsersPage.test.tsx +0 -1
  25. package/src/features/admin-users/components/AdminUsersPage.tsx +0 -3
  26. package/src/features/admin-users/state/__tests__/admin-users-state-unit.test.ts +1 -1
  27. package/src/features/auth-welcome/state/__tests__/welcome-state-unit.test.ts +1 -1
  28. package/src/features/moderate-entity-tags/__tests__/EntityTagsPage.test.tsx +0 -2
  29. package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +0 -3
  30. package/src/features/moderate-entity-tags/state/__tests__/entity-tags-state-unit.test.ts +1 -1
  31. package/src/features/moderate-recent/__tests__/RecentDocumentsPage.test.tsx +3 -5
  32. package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +0 -3
  33. package/src/features/moderate-tag-schemas/__tests__/TagSchemasPage.test.tsx +3 -5
  34. package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +0 -3
  35. package/src/features/moderation-linked-data/__tests__/LinkedDataPage.test.tsx +0 -1
  36. package/src/features/moderation-linked-data/components/LinkedDataPage.tsx +0 -3
  37. package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +17 -7
  38. package/src/features/resource-compose/components/ResourceComposePage.tsx +5 -3
  39. package/src/features/resource-compose/state/__tests__/compose-page-state-unit.test.ts +1 -1
  40. package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +0 -1
  41. package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +0 -3
  42. package/src/features/resource-discovery/state/__tests__/discover-state-unit.test.ts +1 -1
  43. package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +8 -5
  44. package/src/features/resource-viewer/components/ResourceViewerPage.tsx +3 -10
  45. package/src/features/resource-viewer/state/__tests__/resource-loader-state-unit.test.ts +1 -1
  46. package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +1 -1
  47. package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +2 -2
  48. package/dist/chunk-RO5CRVIA.js.map +0 -1
@@ -9404,6 +9404,36 @@ var require_cjs = __commonJS({
9404
9404
  }
9405
9405
  });
9406
9406
 
9407
+ // src/contexts/LineNumbersContext.tsx
9408
+ import { createContext, useContext, useState, useCallback } from "react";
9409
+ import { jsx } from "react/jsx-runtime";
9410
+ var LineNumbersContext = createContext(null);
9411
+ function LineNumbersProvider({ children }) {
9412
+ const [showLineNumbers, setShowLineNumbers] = useState(() => {
9413
+ if (typeof window !== "undefined") {
9414
+ return localStorage.getItem("showLineNumbers") === "true";
9415
+ }
9416
+ return false;
9417
+ });
9418
+ const toggleLineNumbers = useCallback(() => {
9419
+ setShowLineNumbers((prev) => {
9420
+ const next = !prev;
9421
+ if (typeof window !== "undefined") {
9422
+ localStorage.setItem("showLineNumbers", next.toString());
9423
+ }
9424
+ return next;
9425
+ });
9426
+ }, []);
9427
+ return /* @__PURE__ */ jsx(LineNumbersContext.Provider, { value: { showLineNumbers, toggleLineNumbers }, children });
9428
+ }
9429
+ function useLineNumbers() {
9430
+ const ctx = useContext(LineNumbersContext);
9431
+ if (!ctx) {
9432
+ throw new Error("useLineNumbers must be used within a LineNumbersProvider");
9433
+ }
9434
+ return ctx;
9435
+ }
9436
+
9407
9437
  // src/session/web-browser-storage.ts
9408
9438
  var WebBrowserStorage = class {
9409
9439
  constructor() {
@@ -9435,13 +9465,13 @@ var WebBrowserStorage = class {
9435
9465
  };
9436
9466
 
9437
9467
  // src/session/SemiontProvider.tsx
9438
- import { createContext, useContext, useMemo } from "react";
9468
+ import { createContext as createContext2, useContext as useContext2, useMemo } from "react";
9439
9469
  import {
9440
9470
  createHttpSessionFactory,
9441
9471
  getBrowser
9442
9472
  } from "@semiont/sdk";
9443
- import { jsx } from "react/jsx-runtime";
9444
- var SemiontContext = createContext(null);
9473
+ import { jsx as jsx2 } from "react/jsx-runtime";
9474
+ var SemiontContext = createContext2(null);
9445
9475
  function SemiontProvider({ browser, storage, sessionFactory, children }) {
9446
9476
  const value = useMemo(
9447
9477
  () => browser ?? getBrowser({
@@ -9450,10 +9480,10 @@ function SemiontProvider({ browser, storage, sessionFactory, children }) {
9450
9480
  }),
9451
9481
  [browser, storage, sessionFactory]
9452
9482
  );
9453
- return /* @__PURE__ */ jsx(SemiontContext.Provider, { value, children });
9483
+ return /* @__PURE__ */ jsx2(SemiontContext.Provider, { value, children });
9454
9484
  }
9455
9485
  function useSemiont() {
9456
- const ctx = useContext(SemiontContext);
9486
+ const ctx = useContext2(SemiontContext);
9457
9487
  if (!ctx) {
9458
9488
  throw new Error("useSemiont must be used within a <SemiontProvider>");
9459
9489
  }
@@ -9461,8 +9491,8 @@ function useSemiont() {
9461
9491
  }
9462
9492
 
9463
9493
  // src/contexts/TranslationContext.tsx
9464
- import { createContext as createContext2, useContext as useContext2, useState, useEffect, useMemo as useMemo2 } from "react";
9465
- import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
9494
+ import { createContext as createContext3, useContext as useContext3, useState as useState2, useEffect, useMemo as useMemo2 } from "react";
9495
+ import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
9466
9496
 
9467
9497
  // import("../../translations/**/*.json") in src/contexts/TranslationContext.tsx
9468
9498
  var globImport_translations_json = __glob({
@@ -9498,7 +9528,7 @@ var globImport_translations_json = __glob({
9498
9528
  });
9499
9529
 
9500
9530
  // src/contexts/TranslationContext.tsx
9501
- var TranslationContext = createContext2(null);
9531
+ var TranslationContext = createContext3(null);
9502
9532
  var translationCache = /* @__PURE__ */ new Map();
9503
9533
  function processPluralFormat(text, params) {
9504
9534
  const pluralMatch = text.match(/\{(\w+),\s*plural,\s*/);
@@ -9647,8 +9677,8 @@ function TranslationProvider({
9647
9677
  loadingComponent = null,
9648
9678
  children
9649
9679
  }) {
9650
- const [loadedTranslations, setLoadedTranslations] = useState(null);
9651
- const [isLoading, setIsLoading] = useState(false);
9680
+ const [loadedTranslations, setLoadedTranslations] = useState2(null);
9681
+ const [isLoading, setIsLoading] = useState2(false);
9652
9682
  useEffect(() => {
9653
9683
  if (locale && !translationManager) {
9654
9684
  setIsLoading(true);
@@ -9684,18 +9714,18 @@ function TranslationProvider({
9684
9714
  };
9685
9715
  }, [loadedTranslations, locale]);
9686
9716
  if (translationManager) {
9687
- return /* @__PURE__ */ jsx2(TranslationContext.Provider, { value: translationManager, children });
9717
+ return /* @__PURE__ */ jsx3(TranslationContext.Provider, { value: translationManager, children });
9688
9718
  }
9689
9719
  if (locale && isLoading) {
9690
- return /* @__PURE__ */ jsx2(Fragment, { children: loadingComponent });
9720
+ return /* @__PURE__ */ jsx3(Fragment, { children: loadingComponent });
9691
9721
  }
9692
9722
  if (locale && localeManager) {
9693
- return /* @__PURE__ */ jsx2(TranslationContext.Provider, { value: localeManager, children });
9723
+ return /* @__PURE__ */ jsx3(TranslationContext.Provider, { value: localeManager, children });
9694
9724
  }
9695
- return /* @__PURE__ */ jsx2(TranslationContext.Provider, { value: defaultTranslationManager, children });
9725
+ return /* @__PURE__ */ jsx3(TranslationContext.Provider, { value: defaultTranslationManager, children });
9696
9726
  }
9697
9727
  function useTranslations(namespace) {
9698
- const context = useContext2(TranslationContext);
9728
+ const context = useContext3(TranslationContext);
9699
9729
  if (!context) {
9700
9730
  return (key, params) => {
9701
9731
  const translations = en_default;
@@ -9733,14 +9763,14 @@ function usePreloadTranslations() {
9733
9763
  }
9734
9764
 
9735
9765
  // src/components/Toast.tsx
9736
- import React, { useEffect as useEffect2, useState as useState2 } from "react";
9766
+ import React, { useEffect as useEffect2, useState as useState3 } from "react";
9737
9767
  import { createPortal } from "react-dom";
9738
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
9768
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
9739
9769
  var icons = {
9740
- success: /* @__PURE__ */ jsx3("svg", { className: "semiont-toast-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }),
9741
- error: /* @__PURE__ */ jsx3("svg", { className: "semiont-toast-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }),
9742
- warning: /* @__PURE__ */ jsx3("svg", { className: "semiont-toast-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
9743
- info: /* @__PURE__ */ jsx3("svg", { className: "semiont-toast-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) })
9770
+ success: /* @__PURE__ */ jsx4("svg", { className: "semiont-toast-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx4("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }),
9771
+ error: /* @__PURE__ */ jsx4("svg", { className: "semiont-toast-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx4("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }),
9772
+ warning: /* @__PURE__ */ jsx4("svg", { className: "semiont-toast-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx4("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
9773
+ info: /* @__PURE__ */ jsx4("svg", { className: "semiont-toast-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx4("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) })
9744
9774
  };
9745
9775
  function Toast({ toast, onClose }) {
9746
9776
  useEffect2(() => {
@@ -9756,15 +9786,15 @@ function Toast({ toast, onClose }) {
9756
9786
  "data-variant": toast.type,
9757
9787
  role: "alert",
9758
9788
  children: [
9759
- /* @__PURE__ */ jsx3("div", { className: "semiont-toast-icon-wrapper", children: icons[toast.type] }),
9760
- /* @__PURE__ */ jsx3("p", { className: "semiont-toast-message", children: toast.message }),
9761
- /* @__PURE__ */ jsx3(
9789
+ /* @__PURE__ */ jsx4("div", { className: "semiont-toast-icon-wrapper", children: icons[toast.type] }),
9790
+ /* @__PURE__ */ jsx4("p", { className: "semiont-toast-message", children: toast.message }),
9791
+ /* @__PURE__ */ jsx4(
9762
9792
  "button",
9763
9793
  {
9764
9794
  onClick: () => onClose(toast.id),
9765
9795
  className: "semiont-toast-close",
9766
9796
  "aria-label": "Close",
9767
- children: /* @__PURE__ */ jsx3("svg", { className: "semiont-toast-close-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
9797
+ children: /* @__PURE__ */ jsx4("svg", { className: "semiont-toast-close-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx4("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
9768
9798
  }
9769
9799
  )
9770
9800
  ]
@@ -9772,20 +9802,20 @@ function Toast({ toast, onClose }) {
9772
9802
  );
9773
9803
  }
9774
9804
  function ToastContainer({ toasts, onClose }) {
9775
- const [mounted, setMounted] = useState2(false);
9805
+ const [mounted, setMounted] = useState3(false);
9776
9806
  useEffect2(() => {
9777
9807
  setMounted(true);
9778
9808
  return () => setMounted(false);
9779
9809
  }, []);
9780
9810
  if (!mounted) return null;
9781
9811
  return createPortal(
9782
- /* @__PURE__ */ jsx3("div", { className: "semiont-toast-container", children: toasts.map((toast) => /* @__PURE__ */ jsx3(Toast, { toast, onClose }, toast.id)) }),
9812
+ /* @__PURE__ */ jsx4("div", { className: "semiont-toast-container", children: toasts.map((toast) => /* @__PURE__ */ jsx4(Toast, { toast, onClose }, toast.id)) }),
9783
9813
  document.body
9784
9814
  );
9785
9815
  }
9786
9816
  var ToastContext = React.createContext(void 0);
9787
9817
  function ToastProvider({ children }) {
9788
- const [toasts, setToasts] = useState2([]);
9818
+ const [toasts, setToasts] = useState3([]);
9789
9819
  const showToast = React.useCallback((message, type = "info", duration) => {
9790
9820
  const id = Date.now().toString();
9791
9821
  const newToast = duration !== void 0 ? { id, message, type, duration } : { id, message, type };
@@ -9804,7 +9834,7 @@ function ToastProvider({ children }) {
9804
9834
  );
9805
9835
  return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: contextValue, children: [
9806
9836
  children,
9807
- /* @__PURE__ */ jsx3(ToastContainer, { toasts, onClose: handleClose })
9837
+ /* @__PURE__ */ jsx4(ToastContainer, { toasts, onClose: handleClose })
9808
9838
  ] });
9809
9839
  }
9810
9840
  function useToast() {
@@ -9816,6 +9846,8 @@ function useToast() {
9816
9846
  }
9817
9847
 
9818
9848
  export {
9849
+ LineNumbersProvider,
9850
+ useLineNumbers,
9819
9851
  WebBrowserStorage,
9820
9852
  SemiontProvider,
9821
9853
  useSemiont,
@@ -9941,4 +9973,4 @@ export {
9941
9973
  require_zipWith,
9942
9974
  require_cjs
9943
9975
  };
9944
- //# sourceMappingURL=chunk-RO5CRVIA.js.map
9976
+ //# sourceMappingURL=chunk-4QMTEPQ3.js.map