@olenbetong/synergi-react 0.8.13 → 1.0.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.
- package/dist/esm/ob.react.js +5 -4
- 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 +5 -4
- package/dist/iife/ob.react.min.js +1 -1
- package/dist/iife/ob.react.min.js.map +3 -3
- package/es/SplitContainer/index.js +5 -4
- package/package.json +3 -3
- package/src/SplitContainer/index.tsx +5 -4
|
@@ -3,8 +3,9 @@ import "./index.css";
|
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import localforage from "localforage";
|
|
5
5
|
import { Children, forwardRef, useEffect, useRef, useState } from "react";
|
|
6
|
+
const article = globalThis.af?.article?.id ?? globalThis.window?.location.pathname.substring(1).split("/")[0];
|
|
6
7
|
const settingsStore = localforage.createInstance({
|
|
7
|
-
name: `AfSplitContainers.${af
|
|
8
|
+
name: `AfSplitContainers.${globalThis.af?.userSession.login ?? "anonymous"}`,
|
|
8
9
|
});
|
|
9
10
|
const settingsCache = {};
|
|
10
11
|
async function persistState(key, layoutVersion, fixedSize) {
|
|
@@ -28,7 +29,7 @@ async function getSettings(key, layoutVersion) {
|
|
|
28
29
|
// This ways the persisted state can be restored faster after the initial
|
|
29
30
|
// page load.
|
|
30
31
|
settingsStore.keys().then((keys) => Promise.allSettled(keys
|
|
31
|
-
.filter((key) => key.startsWith(
|
|
32
|
+
.filter((key) => key.startsWith(article))
|
|
32
33
|
.map((key) => settingsStore.getItem(key).then((settings) => {
|
|
33
34
|
if (settings && !settingsCache[key]) {
|
|
34
35
|
settingsCache[key] = settings;
|
|
@@ -58,7 +59,7 @@ export function SplitContainer({ className, children, direction = "vertical", fi
|
|
|
58
59
|
setFixedSize((current) => {
|
|
59
60
|
let newValue = typeof size === "function" ? size(current) : size;
|
|
60
61
|
if (id) {
|
|
61
|
-
let key = `${
|
|
62
|
+
let key = `${article}.${id}`;
|
|
62
63
|
persistState(key, layoutVersion, newValue);
|
|
63
64
|
}
|
|
64
65
|
return newValue;
|
|
@@ -66,7 +67,7 @@ export function SplitContainer({ className, children, direction = "vertical", fi
|
|
|
66
67
|
}
|
|
67
68
|
useEffect(() => {
|
|
68
69
|
if (id) {
|
|
69
|
-
let key = `${
|
|
70
|
+
let key = `${article}.${id}`;
|
|
70
71
|
getSettings(key, layoutVersion).then((data) => {
|
|
71
72
|
if (data) {
|
|
72
73
|
// Persisted state exists, and matches the current layout version,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/synergi-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
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.3",
|
|
72
72
|
"clsx": "^1.2.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": "d0fd3e40cf6cc63bd9c2f461afb746e267d4c7e7"
|
|
91
91
|
}
|
|
@@ -4,8 +4,9 @@ import clsx from "clsx";
|
|
|
4
4
|
import localforage from "localforage";
|
|
5
5
|
import React, { Children, forwardRef, useEffect, useRef, useState } from "react";
|
|
6
6
|
|
|
7
|
+
const article = globalThis.af?.article?.id ?? globalThis.window?.location.pathname.substring(1).split("/")[0];
|
|
7
8
|
const settingsStore = localforage.createInstance({
|
|
8
|
-
name: `AfSplitContainers.${af
|
|
9
|
+
name: `AfSplitContainers.${globalThis.af?.userSession.login ?? "anonymous"}`,
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
type SplitContainerSettings = {
|
|
@@ -43,7 +44,7 @@ async function getSettings(key: string, layoutVersion: string | number): Promise
|
|
|
43
44
|
settingsStore.keys().then((keys) =>
|
|
44
45
|
Promise.allSettled(
|
|
45
46
|
keys
|
|
46
|
-
.filter((key) => key.startsWith(
|
|
47
|
+
.filter((key) => key.startsWith(article))
|
|
47
48
|
.map((key) =>
|
|
48
49
|
settingsStore.getItem<SplitContainerSettings>(key).then((settings) => {
|
|
49
50
|
if (settings && !settingsCache[key]) {
|
|
@@ -147,7 +148,7 @@ export function SplitContainer({
|
|
|
147
148
|
let newValue: number = typeof size === "function" ? size(current) : size;
|
|
148
149
|
|
|
149
150
|
if (id) {
|
|
150
|
-
let key = `${
|
|
151
|
+
let key = `${article}.${id}`;
|
|
151
152
|
persistState(key, layoutVersion, newValue);
|
|
152
153
|
}
|
|
153
154
|
|
|
@@ -157,7 +158,7 @@ export function SplitContainer({
|
|
|
157
158
|
|
|
158
159
|
useEffect(() => {
|
|
159
160
|
if (id) {
|
|
160
|
-
let key = `${
|
|
161
|
+
let key = `${article}.${id}`;
|
|
161
162
|
|
|
162
163
|
getSettings(key, layoutVersion).then((data: number | null) => {
|
|
163
164
|
if (data) {
|