@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.
- package/dist/{chunk-RO5CRVIA.js → chunk-4QMTEPQ3.js} +62 -30
- package/dist/chunk-4QMTEPQ3.js.map +1 -0
- package/dist/index.d.ts +18 -30
- package/dist/index.js +371 -409
- package/dist/index.js.map +1 -1
- package/dist/test-utils.js +3 -2
- package/dist/test-utils.js.map +1 -1
- package/package.json +4 -4
- package/src/components/annotation-popups/JsonLdView.tsx +1 -1
- package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +8 -2
- package/src/components/modals/ReferenceWizardModal.tsx +2 -1
- package/src/components/resource/panels/JsonLdPanel.tsx +1 -1
- package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +8 -2
- package/src/components/settings/SettingsPanel.tsx +6 -2
- package/src/components/settings/__tests__/SettingsPanel.test.tsx +28 -3
- package/src/features/admin-devops/__tests__/AdminDevOpsPage.test.tsx +3 -11
- package/src/features/admin-devops/components/AdminDevOpsPage.tsx +0 -3
- package/src/features/admin-exchange/__tests__/AdminExchangePage.test.tsx +0 -1
- package/src/features/admin-exchange/components/AdminExchangePage.tsx +0 -3
- package/src/features/admin-exchange/state/__tests__/exchange-state-unit.test.ts +1 -1
- package/src/features/admin-security/__tests__/AdminSecurityPage.test.tsx +0 -8
- package/src/features/admin-security/components/AdminSecurityPage.tsx +0 -3
- package/src/features/admin-security/state/__tests__/admin-security-state-unit.test.ts +1 -1
- package/src/features/admin-users/__tests__/AdminUsersPage.test.tsx +0 -1
- package/src/features/admin-users/components/AdminUsersPage.tsx +0 -3
- package/src/features/admin-users/state/__tests__/admin-users-state-unit.test.ts +1 -1
- package/src/features/auth-welcome/state/__tests__/welcome-state-unit.test.ts +1 -1
- package/src/features/moderate-entity-tags/__tests__/EntityTagsPage.test.tsx +0 -2
- package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +0 -3
- package/src/features/moderate-entity-tags/state/__tests__/entity-tags-state-unit.test.ts +1 -1
- package/src/features/moderate-recent/__tests__/RecentDocumentsPage.test.tsx +3 -5
- package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +0 -3
- package/src/features/moderate-tag-schemas/__tests__/TagSchemasPage.test.tsx +3 -5
- package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +0 -3
- package/src/features/moderation-linked-data/__tests__/LinkedDataPage.test.tsx +0 -1
- package/src/features/moderation-linked-data/components/LinkedDataPage.tsx +0 -3
- package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +17 -7
- package/src/features/resource-compose/components/ResourceComposePage.tsx +5 -3
- package/src/features/resource-compose/state/__tests__/compose-page-state-unit.test.ts +1 -1
- package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +0 -1
- package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +0 -3
- package/src/features/resource-discovery/state/__tests__/discover-state-unit.test.ts +1 -1
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +8 -5
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +3 -10
- package/src/features/resource-viewer/state/__tests__/resource-loader-state-unit.test.ts +1 -1
- package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +1 -1
- package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +2 -2
- 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 =
|
|
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__ */
|
|
9483
|
+
return /* @__PURE__ */ jsx2(SemiontContext.Provider, { value, children });
|
|
9454
9484
|
}
|
|
9455
9485
|
function useSemiont() {
|
|
9456
|
-
const ctx =
|
|
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
|
|
9465
|
-
import { Fragment, jsx as
|
|
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 =
|
|
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] =
|
|
9651
|
-
const [isLoading, setIsLoading] =
|
|
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__ */
|
|
9717
|
+
return /* @__PURE__ */ jsx3(TranslationContext.Provider, { value: translationManager, children });
|
|
9688
9718
|
}
|
|
9689
9719
|
if (locale && isLoading) {
|
|
9690
|
-
return /* @__PURE__ */
|
|
9720
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: loadingComponent });
|
|
9691
9721
|
}
|
|
9692
9722
|
if (locale && localeManager) {
|
|
9693
|
-
return /* @__PURE__ */
|
|
9723
|
+
return /* @__PURE__ */ jsx3(TranslationContext.Provider, { value: localeManager, children });
|
|
9694
9724
|
}
|
|
9695
|
-
return /* @__PURE__ */
|
|
9725
|
+
return /* @__PURE__ */ jsx3(TranslationContext.Provider, { value: defaultTranslationManager, children });
|
|
9696
9726
|
}
|
|
9697
9727
|
function useTranslations(namespace) {
|
|
9698
|
-
const context =
|
|
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
|
|
9766
|
+
import React, { useEffect as useEffect2, useState as useState3 } from "react";
|
|
9737
9767
|
import { createPortal } from "react-dom";
|
|
9738
|
-
import { jsx as
|
|
9768
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
9739
9769
|
var icons = {
|
|
9740
|
-
success: /* @__PURE__ */
|
|
9741
|
-
error: /* @__PURE__ */
|
|
9742
|
-
warning: /* @__PURE__ */
|
|
9743
|
-
info: /* @__PURE__ */
|
|
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__ */
|
|
9760
|
-
/* @__PURE__ */
|
|
9761
|
-
/* @__PURE__ */
|
|
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__ */
|
|
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] =
|
|
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__ */
|
|
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] =
|
|
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__ */
|
|
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-
|
|
9976
|
+
//# sourceMappingURL=chunk-4QMTEPQ3.js.map
|