@pro6pp/infer-react 0.0.2-beta.2 → 0.0.2-beta.3
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/index.cjs +50 -0
- package/dist/index.js +7 -32
- package/package.json +8 -3
- package/dist/index.mjs +0 -25
- /package/dist/{index.d.mts → index.d.cts} +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
useInfer: () => useInfer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_infer_core = require("@pro6pp/infer-core");
|
|
28
|
+
function useInfer(config) {
|
|
29
|
+
const [state, setState] = (0, import_react.useState)(import_infer_core.INITIAL_STATE);
|
|
30
|
+
const core = (0, import_react.useMemo)(() => {
|
|
31
|
+
return new import_infer_core.InferCore({
|
|
32
|
+
...config,
|
|
33
|
+
onStateChange: (newState) => setState({ ...newState })
|
|
34
|
+
});
|
|
35
|
+
}, [config.country, config.authKey, config.limit]);
|
|
36
|
+
return {
|
|
37
|
+
state,
|
|
38
|
+
core,
|
|
39
|
+
inputProps: {
|
|
40
|
+
value: state.query,
|
|
41
|
+
onChange: (e) => core.handleInput(e.target.value),
|
|
42
|
+
onKeyDown: (e) => core.handleKeyDown(e)
|
|
43
|
+
},
|
|
44
|
+
selectItem: (item) => core.selectItem(item)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
useInfer
|
|
50
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
1
|
// src/index.ts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
useInfer: () => useInfer
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
var import_react = require("react");
|
|
27
|
-
var import_infer_core = require("@pro6pp/infer-core");
|
|
2
|
+
import { useState, useMemo } from "react";
|
|
3
|
+
import { InferCore, INITIAL_STATE } from "@pro6pp/infer-core";
|
|
28
4
|
function useInfer(config) {
|
|
29
|
-
const [state, setState] =
|
|
30
|
-
const core =
|
|
31
|
-
return new
|
|
5
|
+
const [state, setState] = useState(INITIAL_STATE);
|
|
6
|
+
const core = useMemo(() => {
|
|
7
|
+
return new InferCore({
|
|
32
8
|
...config,
|
|
33
9
|
onStateChange: (newState) => setState({ ...newState })
|
|
34
10
|
});
|
|
@@ -44,7 +20,6 @@ function useInfer(config) {
|
|
|
44
20
|
selectItem: (item) => core.selectItem(item)
|
|
45
21
|
};
|
|
46
22
|
}
|
|
47
|
-
|
|
48
|
-
0 && (module.exports = {
|
|
23
|
+
export {
|
|
49
24
|
useInfer
|
|
50
|
-
}
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pro6pp/infer-react",
|
|
3
|
+
"type": "module",
|
|
3
4
|
"description": "Headless React one-field input for the Pro6PP Infer API.",
|
|
4
5
|
"homepage": "https://github.com/pro6pp/infer-sdk/tree/main/packages/react",
|
|
5
6
|
"keywords": [
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
"url": "https://github.com/pro6pp/infer-sdk/issues"
|
|
20
21
|
},
|
|
21
22
|
"sideEffects": false,
|
|
22
|
-
"version": "0.0.2-beta.
|
|
23
|
+
"version": "0.0.2-beta.3",
|
|
23
24
|
"main": "./dist/index.js",
|
|
24
25
|
"module": "./dist/index.mjs",
|
|
25
26
|
"types": "./dist/index.d.ts",
|
|
@@ -37,15 +38,19 @@
|
|
|
37
38
|
"scripts": {
|
|
38
39
|
"build": "tsup",
|
|
39
40
|
"dev": "tsup --watch",
|
|
40
|
-
"type-check": "tsc --noEmit"
|
|
41
|
+
"type-check": "tsc --noEmit",
|
|
42
|
+
"test": "vitest",
|
|
43
|
+
"test:coverage": "vitest run --coverage"
|
|
41
44
|
},
|
|
42
45
|
"peerDependencies": {
|
|
43
46
|
"react": ">=16"
|
|
44
47
|
},
|
|
45
48
|
"dependencies": {
|
|
46
|
-
"@pro6pp/infer-core": "0.0.2-beta.
|
|
49
|
+
"@pro6pp/infer-core": "0.0.2-beta.3"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
52
|
+
"@testing-library/dom": "^10.4.1",
|
|
53
|
+
"@testing-library/react": "^16.3.1",
|
|
49
54
|
"@types/react": "^19.2.7"
|
|
50
55
|
},
|
|
51
56
|
"publishConfig": {
|
package/dist/index.mjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import { useState, useMemo } from "react";
|
|
3
|
-
import { InferCore, INITIAL_STATE } from "@pro6pp/infer-core";
|
|
4
|
-
function useInfer(config) {
|
|
5
|
-
const [state, setState] = useState(INITIAL_STATE);
|
|
6
|
-
const core = useMemo(() => {
|
|
7
|
-
return new InferCore({
|
|
8
|
-
...config,
|
|
9
|
-
onStateChange: (newState) => setState({ ...newState })
|
|
10
|
-
});
|
|
11
|
-
}, [config.country, config.authKey, config.limit]);
|
|
12
|
-
return {
|
|
13
|
-
state,
|
|
14
|
-
core,
|
|
15
|
-
inputProps: {
|
|
16
|
-
value: state.query,
|
|
17
|
-
onChange: (e) => core.handleInput(e.target.value),
|
|
18
|
-
onKeyDown: (e) => core.handleKeyDown(e)
|
|
19
|
-
},
|
|
20
|
-
selectItem: (item) => core.selectItem(item)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
useInfer
|
|
25
|
-
};
|
|
File without changes
|