@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.
@@ -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
  }
@@ -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
- return _jsx("img", { ref: ref, className: clsx("ObPageBanner-bannerImage", className), ...other });
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";
@@ -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
- let portalElem = portalNode.current;
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
- portalElem = node;
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
- else {
30
- return createPortal(children, portalNode.current);
31
- }
29
+ return createPortal(children, portalNode.current);
32
30
  }
@@ -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") {
@@ -1,5 +1,5 @@
1
1
  import "./index.css";
2
- import React from "react";
2
+ import type React from "react";
3
3
  export type SpinnerProps = React.HTMLProps<HTMLDivElement> & {
4
4
  fullPage?: boolean;
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import "./index.css";
2
- import React from "react";
2
+ import type React from "react";
3
3
  export type SplitContainerProps = {
4
4
  className?: string;
5
5
  panelClassName?: string;
@@ -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", { tabIndex: 0, className: clsx("ObSplitContainer-divider", props.className), ref: ref, children: _jsx("span", { children: "\u2022\u2022\u2022" }) }));
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) {
@@ -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("obet-value-toggle-" + String(++valueToggleId));
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 && data.translations) {
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.5",
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.6",
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": "48ecf3f030bc4cab59c3a7eb06506b9a6c208ba7"
90
+ "gitHead": "bc10814d960b65e6959fb8506259e4d369f094ab"
91
91
  }
@@ -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");
@@ -26,7 +26,8 @@ export const BannerImage = React.forwardRef<HTMLImageElement, BannerImageProps>(
26
26
  ref,
27
27
  ) {
28
28
  const { className, ...other } = props;
29
- return <img ref={ref} className={clsx("ObPageBanner-bannerImage", className)} {...other} />;
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"> & {
@@ -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
- let portalElem = portalNode.current;
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
- portalElem = node;
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
  }
@@ -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") {
@@ -1,7 +1,7 @@
1
1
  import "./index.scss";
2
2
 
3
3
  import clsx from "clsx";
4
- import React from "react";
4
+ import type React from "react";
5
5
 
6
6
  export type SpinnerProps = React.HTMLProps<HTMLDivElement> & {
7
7
  fullPage?: boolean;
@@ -2,7 +2,8 @@ import "./index.scss";
2
2
 
3
3
  import clsx from "clsx";
4
4
  import localforage from "localforage";
5
- import React, { Children, forwardRef, useEffect, useRef, useState } from "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 tabIndex={0} className={clsx("ObSplitContainer-divider", props.className)} ref={ref}>
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: boolean = true;
233
- let shouldHandle: boolean = false;
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("obet-value-toggle-" + String(++valueToggleId));
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 && data.translations) {
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 () => {