@etsoo/react 1.8.37 → 1.8.39

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.
@@ -4,3 +4,8 @@ import { DataTypes } from "@etsoo/shared";
4
4
  * Provide exact type data
5
5
  */
6
6
  export declare function useSearchParamsEx<T extends DataTypes.BasicTemplate>(template: T): DataTypes.BasicTemplateType<T>;
7
+ /**
8
+ * Extended useSearchParams of react-router-dom
9
+ * Provide exact type data and setSearchParams function
10
+ */
11
+ export declare function useSearchParamsEx1<T extends DataTypes.BasicTemplate>(template: T): readonly [DataTypes.BasicTemplateType<T>, import("react-router").SetURLSearchParams];
@@ -1,8 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useSearchParamsEx = useSearchParamsEx;
4
+ exports.useSearchParamsEx1 = useSearchParamsEx1;
4
5
  const shared_1 = require("@etsoo/shared");
5
6
  const react_router_1 = require("react-router");
7
+ function parseData(template, sp) {
8
+ const paras = Object.fromEntries(Object.keys(template).map((key) => {
9
+ const type = template[key];
10
+ return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
11
+ }));
12
+ // Return
13
+ return shared_1.DomUtils.dataAs(paras, template, false);
14
+ }
6
15
  /**
7
16
  * Extended useSearchParams of react-router-dom
8
17
  * Provide exact type data
@@ -10,10 +19,15 @@ const react_router_1 = require("react-router");
10
19
  function useSearchParamsEx(template) {
11
20
  // Get parameters
12
21
  const [sp] = (0, react_router_1.useSearchParams)();
13
- const paras = Object.fromEntries(Object.keys(template).map((key) => {
14
- const type = template[key];
15
- return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
16
- }));
22
+ return parseData(template, sp);
23
+ }
24
+ /**
25
+ * Extended useSearchParams of react-router-dom
26
+ * Provide exact type data and setSearchParams function
27
+ */
28
+ function useSearchParamsEx1(template) {
29
+ // Get parameters
30
+ const [sp, setSearchParams] = (0, react_router_1.useSearchParams)();
17
31
  // Return
18
- return shared_1.DomUtils.dataAs(paras, template, false);
32
+ return [parseData(template, sp), setSearchParams];
19
33
  }
@@ -4,3 +4,8 @@ import { DataTypes } from "@etsoo/shared";
4
4
  * Provide exact type data
5
5
  */
6
6
  export declare function useSearchParamsEx<T extends DataTypes.BasicTemplate>(template: T): DataTypes.BasicTemplateType<T>;
7
+ /**
8
+ * Extended useSearchParams of react-router-dom
9
+ * Provide exact type data and setSearchParams function
10
+ */
11
+ export declare function useSearchParamsEx1<T extends DataTypes.BasicTemplate>(template: T): readonly [DataTypes.BasicTemplateType<T>, import("react-router").SetURLSearchParams];
@@ -1,5 +1,13 @@
1
1
  import { DomUtils } from "@etsoo/shared";
2
2
  import { useSearchParams } from "react-router";
3
+ function parseData(template, sp) {
4
+ const paras = Object.fromEntries(Object.keys(template).map((key) => {
5
+ const type = template[key];
6
+ return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
7
+ }));
8
+ // Return
9
+ return DomUtils.dataAs(paras, template, false);
10
+ }
3
11
  /**
4
12
  * Extended useSearchParams of react-router-dom
5
13
  * Provide exact type data
@@ -7,10 +15,15 @@ import { useSearchParams } from "react-router";
7
15
  export function useSearchParamsEx(template) {
8
16
  // Get parameters
9
17
  const [sp] = useSearchParams();
10
- const paras = Object.fromEntries(Object.keys(template).map((key) => {
11
- const type = template[key];
12
- return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
13
- }));
18
+ return parseData(template, sp);
19
+ }
20
+ /**
21
+ * Extended useSearchParams of react-router-dom
22
+ * Provide exact type data and setSearchParams function
23
+ */
24
+ export function useSearchParamsEx1(template) {
25
+ // Get parameters
26
+ const [sp, setSearchParams] = useSearchParams();
14
27
  // Return
15
- return DomUtils.dataAs(paras, template, false);
28
+ return [parseData(template, sp), setSearchParams];
16
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.8.37",
3
+ "version": "1.8.39",
4
4
  "description": "TypeScript ReactJs UI Independent Framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,12 +40,12 @@
40
40
  "@emotion/css": "^11.13.5",
41
41
  "@emotion/react": "^11.13.5",
42
42
  "@emotion/styled": "^11.13.5",
43
- "@etsoo/appscript": "^1.6.21",
43
+ "@etsoo/appscript": "^1.6.22",
44
44
  "@etsoo/notificationbase": "^1.1.60",
45
- "@etsoo/shared": "^1.2.66",
45
+ "@etsoo/shared": "^1.2.68",
46
46
  "react": "^18.3.1",
47
47
  "react-dom": "^18.3.1",
48
- "react-router-dom": "^7.4.1",
48
+ "react-router-dom": "^7.5.0",
49
49
  "react-window": "^1.8.11"
50
50
  },
51
51
  "overrides": {
@@ -65,8 +65,8 @@
65
65
  "@types/react-dom": "^18.3.6",
66
66
  "@types/react-window": "^1.8.8",
67
67
  "@vitejs/plugin-react": "^4.3.4",
68
- "jsdom": "^26.0.0",
69
- "typescript": "^5.8.2",
68
+ "jsdom": "^26.1.0",
69
+ "typescript": "^5.8.3",
70
70
  "vitest": "^3.1.1"
71
71
  }
72
72
  }
@@ -1,6 +1,21 @@
1
1
  import { DataTypes, DomUtils } from "@etsoo/shared";
2
2
  import { useSearchParams } from "react-router";
3
3
 
4
+ function parseData<T extends DataTypes.BasicTemplate>(
5
+ template: T,
6
+ sp: URLSearchParams
7
+ ) {
8
+ const paras = Object.fromEntries(
9
+ Object.keys(template).map((key) => {
10
+ const type = template[key];
11
+ return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
12
+ })
13
+ );
14
+
15
+ // Return
16
+ return DomUtils.dataAs(paras, template, false);
17
+ }
18
+
4
19
  /**
5
20
  * Extended useSearchParams of react-router-dom
6
21
  * Provide exact type data
@@ -10,13 +25,19 @@ export function useSearchParamsEx<T extends DataTypes.BasicTemplate>(
10
25
  ) {
11
26
  // Get parameters
12
27
  const [sp] = useSearchParams();
13
- const paras = Object.fromEntries(
14
- Object.keys(template).map((key) => {
15
- const type = template[key];
16
- return [key, type.endsWith("[]") ? sp.getAll(key) : sp.get(key)];
17
- })
18
- );
28
+ return parseData(template, sp);
29
+ }
30
+
31
+ /**
32
+ * Extended useSearchParams of react-router-dom
33
+ * Provide exact type data and setSearchParams function
34
+ */
35
+ export function useSearchParamsEx1<T extends DataTypes.BasicTemplate>(
36
+ template: T
37
+ ) {
38
+ // Get parameters
39
+ const [sp, setSearchParams] = useSearchParams();
19
40
 
20
41
  // Return
21
- return DomUtils.dataAs(paras, template, false);
42
+ return [parseData(template, sp), setSearchParams] as const;
22
43
  }