@olenbetong/synergi-react 1.0.5 → 1.0.6
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/esm/ob.react.js +33 -36
- package/dist/esm/ob.react.min.js +1 -1
- package/dist/esm/ob.react.min.js.map +3 -3
- package/dist/iife/ob.react.js +36 -39
- package/dist/iife/ob.react.min.js +1 -1
- package/dist/iife/ob.react.min.js.map +3 -3
- package/es/Checkbox/index.js +1 -0
- package/es/DateNavigator/index.js +1 -1
- package/es/PageBanner/index.js +2 -1
- package/es/Portal/index.js +5 -7
- package/es/Sidebar/index.js +1 -0
- package/es/Spinner/index.d.ts +1 -1
- package/es/SplitContainer/index.d.ts +1 -1
- package/es/SplitContainer/index.js +2 -1
- package/es/ValueToggle/index.js +1 -1
- package/es/useTranslation/index.js +2 -1
- package/package.json +3 -3
- package/src/Checkbox/index.tsx +2 -1
- package/src/DateNavigator/index.tsx +1 -1
- package/src/PageBanner/index.tsx +2 -1
- package/src/Portal/index.tsx +8 -7
- package/src/Sidebar/index.tsx +1 -0
- package/src/Spinner/index.tsx +1 -1
- package/src/SplitContainer/index.tsx +6 -4
- package/src/ValueToggle/index.tsx +1 -1
- package/src/useTranslation/index.ts +2 -1
package/es/Checkbox/index.js
CHANGED
|
@@ -8,6 +8,7 @@ function Mark(props) {
|
|
|
8
8
|
export const Checkbox = forwardRef(function Checkbox({ className, disabled = false, id, onChange = () => null, title, value, ...other }, ref) {
|
|
9
9
|
const inputId = useId() + (id ?? "");
|
|
10
10
|
const input = useRef(null);
|
|
11
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Ref object
|
|
11
12
|
useEffect(() => {
|
|
12
13
|
if (typeof ref === "function") {
|
|
13
14
|
ref(input.current);
|
|
@@ -26,7 +26,7 @@ export function DateNavigator({ date: dateProp, onChange }) {
|
|
|
26
26
|
const dateUtc = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
|
|
27
27
|
let dateValue = new Date(dateUtc);
|
|
28
28
|
let text = formatter.format(dateValue);
|
|
29
|
-
let altText;
|
|
29
|
+
let altText = "";
|
|
30
30
|
if (todayUtc === dateUtc) {
|
|
31
31
|
altText = getLocalizedString("Today");
|
|
32
32
|
}
|
package/es/PageBanner/index.js
CHANGED
|
@@ -8,7 +8,8 @@ export function PageBanner({ as, className, children, ...other }) {
|
|
|
8
8
|
}
|
|
9
9
|
export const BannerImage = React.forwardRef(function BannerImage(props, ref) {
|
|
10
10
|
const { className, ...other } = props;
|
|
11
|
-
|
|
11
|
+
// biome-ignore lint/a11y/useAltText: should be provided by the user
|
|
12
|
+
return _jsx("img", { ref: ref, className: clsx("ObPageBanner-bannerImage", className), alt: "", ...other });
|
|
12
13
|
});
|
|
13
14
|
export function TabList({ as, className, children, sticky, ...other }) {
|
|
14
15
|
const Component = as ? as : "nav";
|
package/es/Portal/index.js
CHANGED
|
@@ -9,24 +9,22 @@ export function Portal({ children, root, type = "div" }) {
|
|
|
9
9
|
const forceUpdate = useForceUpdate();
|
|
10
10
|
const mountNode = useRef(null);
|
|
11
11
|
const portalNode = useRef(null);
|
|
12
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: because reasons
|
|
12
13
|
useEffect(() => {
|
|
13
14
|
const ownerDocument = mountNode.current?.ownerDocument;
|
|
14
|
-
|
|
15
|
-
if (ownerDocument && portalElem) {
|
|
15
|
+
if (ownerDocument && !portalNode.current) {
|
|
16
16
|
let parent = root ? ownerDocument.querySelector(root) || ownerDocument.body : ownerDocument.body;
|
|
17
17
|
const node = ownerDocument.createElement(type);
|
|
18
|
-
|
|
18
|
+
portalNode.current = node;
|
|
19
19
|
parent.appendChild(node);
|
|
20
20
|
forceUpdate();
|
|
21
21
|
return () => {
|
|
22
22
|
parent.removeChild(node);
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
}, []);
|
|
25
|
+
}, [root, type]);
|
|
26
26
|
if (!portalNode.current) {
|
|
27
27
|
return _jsx("div", { ref: mountNode });
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
return createPortal(children, portalNode.current);
|
|
31
|
-
}
|
|
29
|
+
return createPortal(children, portalNode.current);
|
|
32
30
|
}
|
package/es/Sidebar/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export function Sidebar(props) {
|
|
|
23
23
|
element?.addEventListener("transitionend", toggleHiddenContent);
|
|
24
24
|
return () => element?.removeEventListener("transitionend", toggleHiddenContent);
|
|
25
25
|
}, [open]);
|
|
26
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: TODO
|
|
26
27
|
useEffect(() => {
|
|
27
28
|
function handleCloseSidebar(evt) {
|
|
28
29
|
if (evt.key === "Escape") {
|
package/es/Spinner/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ settingsStore.keys().then((keys) => Promise.allSettled(keys
|
|
|
36
36
|
}
|
|
37
37
|
}))));
|
|
38
38
|
const Divider = forwardRef(function Divider(props, ref) {
|
|
39
|
-
return (_jsx("div", {
|
|
39
|
+
return (_jsx("div", { className: clsx("ObSplitContainer-divider", props.className), ref: ref, children: _jsx("span", { children: "\u2022\u2022\u2022" }) }));
|
|
40
40
|
});
|
|
41
41
|
function SplitRoot({ className, direction, ...props }) {
|
|
42
42
|
return _jsx("div", { className: clsx(className, "ObSplitContainer-root", direction), ...props });
|
|
@@ -79,6 +79,7 @@ export function SplitContainer({ className, children, direction = "vertical", fi
|
|
|
79
79
|
}
|
|
80
80
|
}, [id, layoutVersion]);
|
|
81
81
|
let childrenArray = Children.toArray(children);
|
|
82
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
82
83
|
useEffect(() => {
|
|
83
84
|
let divider = dividerRef.current;
|
|
84
85
|
if (divider) {
|
package/es/ValueToggle/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
|
4
4
|
let valueToggleId = 0;
|
|
5
5
|
function ValueToggleInner({ className, onChange, defaultValue, options, value, ...other }, ref) {
|
|
6
6
|
const wrapperRef = useRef(null);
|
|
7
|
-
const [toggleName] = useState(
|
|
7
|
+
const [toggleName] = useState(`obet-value-toggle-${String(++valueToggleId)}`);
|
|
8
8
|
const isControlled = value !== undefined;
|
|
9
9
|
useImperativeHandle(ref, () => {
|
|
10
10
|
const e = wrapperRef.current?.querySelector("input");
|
|
@@ -12,7 +12,7 @@ async function translateText(text, target, apiKey) {
|
|
|
12
12
|
let result = await fetch(url, options);
|
|
13
13
|
let json = await result.json();
|
|
14
14
|
let { data } = json;
|
|
15
|
-
if (data
|
|
15
|
+
if (data?.translations) {
|
|
16
16
|
let [translation] = data.translations;
|
|
17
17
|
return {
|
|
18
18
|
from: translation.detectedSourceLanguage,
|
|
@@ -27,6 +27,7 @@ export function useTranslation(text, targetLanguage, apiKey) {
|
|
|
27
27
|
let [from, setSourceLang] = useState(null);
|
|
28
28
|
let [isTranslating, setIsTranslating] = useState(false);
|
|
29
29
|
let textRef = useRef(text);
|
|
30
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: this is a way of resetting the state so we don't show outdated translations when the text changes
|
|
30
31
|
useEffect(() => {
|
|
31
32
|
textRef.current = text;
|
|
32
33
|
return () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/synergi-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Standalone React component for SynergiWeb and Partner Portal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./es/index.d.ts",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"sideEffects": false,
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@olenbetong/appframe-core": "2.11.
|
|
71
|
+
"@olenbetong/appframe-core": "2.11.7",
|
|
72
72
|
"clsx": "^2.1.1",
|
|
73
73
|
"localforage": "^1.10.0",
|
|
74
74
|
"mitt": "^3.0.0"
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"replace-in-files": "^3.0.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "bc10814d960b65e6959fb8506259e4d369f094ab"
|
|
91
91
|
}
|
package/src/Checkbox/index.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./index.scss";
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
-
import { HTMLAttributes, forwardRef, useEffect, useId, useRef } from "react";
|
|
4
|
+
import { type HTMLAttributes, forwardRef, useEffect, useId, useRef } from "react";
|
|
5
5
|
|
|
6
6
|
function Mark(props: HTMLAttributes<SVGElement>) {
|
|
7
7
|
return (
|
|
@@ -26,6 +26,7 @@ export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Che
|
|
|
26
26
|
const inputId = useId() + (id ?? "");
|
|
27
27
|
const input = useRef<HTMLInputElement>(null);
|
|
28
28
|
|
|
29
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Ref object
|
|
29
30
|
useEffect(() => {
|
|
30
31
|
if (typeof ref === "function") {
|
|
31
32
|
ref(input.current);
|
|
@@ -60,7 +60,7 @@ export function DateNavigator({ date: dateProp, onChange }: { date?: Date; onCha
|
|
|
60
60
|
let dateValue = new Date(dateUtc);
|
|
61
61
|
|
|
62
62
|
let text = formatter.format(dateValue);
|
|
63
|
-
let altText;
|
|
63
|
+
let altText = "";
|
|
64
64
|
|
|
65
65
|
if (todayUtc === dateUtc) {
|
|
66
66
|
altText = getLocalizedString("Today");
|
package/src/PageBanner/index.tsx
CHANGED
|
@@ -26,7 +26,8 @@ export const BannerImage = React.forwardRef<HTMLImageElement, BannerImageProps>(
|
|
|
26
26
|
ref,
|
|
27
27
|
) {
|
|
28
28
|
const { className, ...other } = props;
|
|
29
|
-
|
|
29
|
+
// biome-ignore lint/a11y/useAltText: should be provided by the user
|
|
30
|
+
return <img ref={ref} className={clsx("ObPageBanner-bannerImage", className)} alt="" {...other} />;
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
export type TabListProps = Pick<React.HTMLProps<HTMLDivElement>, "id" | "className" | "children"> & {
|
package/src/Portal/index.tsx
CHANGED
|
@@ -10,15 +10,16 @@ function useForceUpdate() {
|
|
|
10
10
|
export function Portal({ children, root, type = "div" }) {
|
|
11
11
|
const forceUpdate = useForceUpdate();
|
|
12
12
|
const mountNode = useRef<HTMLDivElement>(null);
|
|
13
|
-
const portalNode = useRef<HTMLElement>(null);
|
|
13
|
+
const portalNode = useRef<HTMLElement | null>(null);
|
|
14
14
|
|
|
15
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: because reasons
|
|
15
16
|
useEffect(() => {
|
|
16
17
|
const ownerDocument = mountNode.current?.ownerDocument;
|
|
17
|
-
|
|
18
|
-
if (ownerDocument && portalElem) {
|
|
18
|
+
if (ownerDocument && !portalNode.current) {
|
|
19
19
|
let parent = root ? ownerDocument.querySelector(root) || ownerDocument.body : ownerDocument.body;
|
|
20
|
+
|
|
20
21
|
const node = ownerDocument.createElement(type);
|
|
21
|
-
|
|
22
|
+
portalNode.current = node;
|
|
22
23
|
parent.appendChild(node);
|
|
23
24
|
forceUpdate();
|
|
24
25
|
|
|
@@ -26,11 +27,11 @@ export function Portal({ children, root, type = "div" }) {
|
|
|
26
27
|
parent.removeChild(node);
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
}, []);
|
|
30
|
+
}, [root, type]);
|
|
30
31
|
|
|
31
32
|
if (!portalNode.current) {
|
|
32
33
|
return <div ref={mountNode} />;
|
|
33
|
-
} else {
|
|
34
|
-
return createPortal(children, portalNode.current);
|
|
35
34
|
}
|
|
35
|
+
|
|
36
|
+
return createPortal(children, portalNode.current);
|
|
36
37
|
}
|
package/src/Sidebar/index.tsx
CHANGED
|
@@ -49,6 +49,7 @@ export function Sidebar(props: SidebarProps) {
|
|
|
49
49
|
return () => element?.removeEventListener("transitionend", toggleHiddenContent);
|
|
50
50
|
}, [open]);
|
|
51
51
|
|
|
52
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: TODO
|
|
52
53
|
useEffect(() => {
|
|
53
54
|
function handleCloseSidebar(evt) {
|
|
54
55
|
if (evt.key === "Escape") {
|
package/src/Spinner/index.tsx
CHANGED
|
@@ -2,7 +2,8 @@ import "./index.scss";
|
|
|
2
2
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import localforage from "localforage";
|
|
5
|
-
import React
|
|
5
|
+
import type React from "react";
|
|
6
|
+
import { Children, forwardRef, useEffect, useRef, useState } from "react";
|
|
6
7
|
|
|
7
8
|
const article = globalThis.af?.article?.id ?? globalThis.window?.location.pathname.substring(1).split("/")[0];
|
|
8
9
|
const settingsStore = localforage.createInstance({
|
|
@@ -63,7 +64,7 @@ type DividerProps = {
|
|
|
63
64
|
|
|
64
65
|
const Divider = forwardRef<HTMLDivElement, DividerProps>(function Divider(props: DividerProps, ref) {
|
|
65
66
|
return (
|
|
66
|
-
<div
|
|
67
|
+
<div className={clsx("ObSplitContainer-divider", props.className)} ref={ref}>
|
|
67
68
|
<span>•••</span>
|
|
68
69
|
</div>
|
|
69
70
|
);
|
|
@@ -174,6 +175,7 @@ export function SplitContainer({
|
|
|
174
175
|
|
|
175
176
|
let childrenArray = Children.toArray(children);
|
|
176
177
|
|
|
178
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
177
179
|
useEffect(() => {
|
|
178
180
|
let divider = dividerRef.current;
|
|
179
181
|
if (divider) {
|
|
@@ -229,8 +231,8 @@ export function SplitContainer({
|
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
function handleKeyDown(event: KeyboardEvent) {
|
|
232
|
-
let reduce
|
|
233
|
-
let shouldHandle
|
|
234
|
+
let reduce = true;
|
|
235
|
+
let shouldHandle = false;
|
|
234
236
|
if (!event.altKey && !event.ctrlKey && !event.metaKey) {
|
|
235
237
|
if (direction === "horizontal" && ["ArrowLeft", "ArrowRight"].includes(event.key)) {
|
|
236
238
|
shouldHandle = true;
|
|
@@ -23,7 +23,7 @@ function ValueToggleInner(
|
|
|
23
23
|
}>,
|
|
24
24
|
) {
|
|
25
25
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
26
|
-
const [toggleName] = useState(
|
|
26
|
+
const [toggleName] = useState(`obet-value-toggle-${String(++valueToggleId)}`);
|
|
27
27
|
const isControlled = value !== undefined;
|
|
28
28
|
|
|
29
29
|
useImperativeHandle(ref, () => {
|
|
@@ -16,7 +16,7 @@ async function translateText(text: string, target: string, apiKey: string) {
|
|
|
16
16
|
let json = await result.json();
|
|
17
17
|
let { data } = json;
|
|
18
18
|
|
|
19
|
-
if (data
|
|
19
|
+
if (data?.translations) {
|
|
20
20
|
let [translation] = data.translations;
|
|
21
21
|
|
|
22
22
|
return {
|
|
@@ -35,6 +35,7 @@ export function useTranslation(text: string, targetLanguage: string, apiKey: str
|
|
|
35
35
|
let [isTranslating, setIsTranslating] = useState(false);
|
|
36
36
|
let textRef = useRef(text);
|
|
37
37
|
|
|
38
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: this is a way of resetting the state so we don't show outdated translations when the text changes
|
|
38
39
|
useEffect(() => {
|
|
39
40
|
textRef.current = text;
|
|
40
41
|
return () => {
|