@pro6pp/infer-react 0.0.2-beta.1 → 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 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
- 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");
2
+ import { useState, useMemo } from "react";
3
+ import { InferCore, INITIAL_STATE } from "@pro6pp/infer-core";
28
4
  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({
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
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
23
+ export {
49
24
  useInfer
50
- });
25
+ };
package/package.json CHANGED
@@ -1,7 +1,26 @@
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
- "version": "0.0.2-beta.1",
5
+ "homepage": "https://github.com/pro6pp/infer-sdk/tree/main/packages/react",
6
+ "keywords": [
7
+ "react",
8
+ "hook",
9
+ "address",
10
+ "autocomplete",
11
+ "pro6pp",
12
+ "netherlands",
13
+ "germany",
14
+ "postal-code",
15
+ "validation",
16
+ "infer-api",
17
+ "sdk"
18
+ ],
19
+ "bugs": {
20
+ "url": "https://github.com/pro6pp/infer-sdk/issues"
21
+ },
22
+ "sideEffects": false,
23
+ "version": "0.0.2-beta.3",
5
24
  "main": "./dist/index.js",
6
25
  "module": "./dist/index.mjs",
7
26
  "types": "./dist/index.d.ts",
@@ -19,15 +38,19 @@
19
38
  "scripts": {
20
39
  "build": "tsup",
21
40
  "dev": "tsup --watch",
22
- "type-check": "tsc --noEmit"
41
+ "type-check": "tsc --noEmit",
42
+ "test": "vitest",
43
+ "test:coverage": "vitest run --coverage"
23
44
  },
24
45
  "peerDependencies": {
25
46
  "react": ">=16"
26
47
  },
27
48
  "dependencies": {
28
- "@pro6pp/infer-core": "0.0.2-beta.1"
49
+ "@pro6pp/infer-core": "0.0.2-beta.3"
29
50
  },
30
51
  "devDependencies": {
52
+ "@testing-library/dom": "^10.4.1",
53
+ "@testing-library/react": "^16.3.1",
31
54
  "@types/react": "^19.2.7"
32
55
  },
33
56
  "publishConfig": {
@@ -36,7 +59,7 @@
36
59
  "license": "MIT",
37
60
  "repository": {
38
61
  "type": "git",
39
- "url": "https://github.com/pro6pp/infer-sdk",
62
+ "url": "git+https://github.com/pro6pp/infer-sdk.git",
40
63
  "directory": "packages/react"
41
64
  }
42
65
  }
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