@gohanfromgoku/ui-kit 1.1.0 → 1.1.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.
|
@@ -7,7 +7,10 @@ export const createQueryParamsSearchString = (queryParams) => {
|
|
|
7
7
|
let search = "?";
|
|
8
8
|
for (let index = 0; index < keys.length; index++) {
|
|
9
9
|
const key = keys[index];
|
|
10
|
-
|
|
10
|
+
const encodedKey = encodeURIComponent(key);
|
|
11
|
+
const value = queryParams[key];
|
|
12
|
+
const encodedValue = encodeURIComponent(value == null ? "" : String(value));
|
|
13
|
+
search = `${search}${encodedKey}=${encodedValue}`;
|
|
11
14
|
if (index !== keys.length - 1) {
|
|
12
15
|
search = search + "&";
|
|
13
16
|
}
|
|
@@ -20,20 +23,18 @@ export const extractQueryParamsFromURL = (url) => {
|
|
|
20
23
|
const queryObj = {};
|
|
21
24
|
const parts = url.split("?");
|
|
22
25
|
if (parts.length > 2) {
|
|
23
|
-
throw "Invalid URL";
|
|
26
|
+
throw new Error("Invalid URL");
|
|
24
27
|
}
|
|
25
|
-
;
|
|
26
28
|
if (parts.length === 1) {
|
|
27
29
|
return queryObj;
|
|
28
30
|
}
|
|
29
|
-
;
|
|
30
31
|
const search = parts[1];
|
|
31
32
|
if (search && search.length > 0) {
|
|
32
33
|
const queries = search.split("&");
|
|
33
34
|
for (const query of queries) {
|
|
34
35
|
const queryParts = query.split("=");
|
|
35
36
|
if (queryParts.length > 2) {
|
|
36
|
-
throw "Invalid URL";
|
|
37
|
+
throw new Error("Invalid URL");
|
|
37
38
|
}
|
|
38
39
|
const [key, value] = queryParts;
|
|
39
40
|
queryObj[decodeURIComponent(key)] = decodeURIComponent(value ?? "");
|
package/dist/storage/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "../prototypes";
|
|
2
2
|
import { useSyncExternalStore } from "react";
|
|
3
3
|
export default function createStore(name, initialState) {
|
|
4
|
-
|
|
4
|
+
const originalState = JSON.parse(JSON.stringify(initialState));
|
|
5
|
+
let state = JSON.parse(JSON.stringify(originalState));
|
|
5
6
|
const listeners = new Set();
|
|
6
7
|
const subscribe = (listener) => {
|
|
7
8
|
listeners.add(listener);
|
|
@@ -13,11 +14,11 @@ export default function createStore(name, initialState) {
|
|
|
13
14
|
listeners.forEach(l => l());
|
|
14
15
|
};
|
|
15
16
|
const resetState = () => {
|
|
16
|
-
state =
|
|
17
|
+
state = JSON.parse(JSON.stringify(originalState));
|
|
17
18
|
listeners.forEach(l => l());
|
|
18
19
|
};
|
|
19
20
|
const useStore = () => useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
20
|
-
const capName = name.
|
|
21
|
+
const capName = (name.charAt(0).toUpperCase() + name.slice(1));
|
|
21
22
|
const exposedState = {};
|
|
22
23
|
Object.keys(initialState).forEach(key => {
|
|
23
24
|
Object.defineProperty(exposedState, key, {
|
package/package.json
CHANGED