@pro6pp/infer-react 0.0.2-beta.1 → 0.0.2-beta.10

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/package.json CHANGED
@@ -1,15 +1,34 @@
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
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
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.10",
24
+ "main": "./dist/index.cjs",
25
+ "module": "./dist/index.js",
7
26
  "types": "./dist/index.d.ts",
8
27
  "exports": {
9
28
  ".": {
10
29
  "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
30
+ "import": "./dist/index.js",
31
+ "require": "./dist/index.cjs"
13
32
  }
14
33
  },
15
34
  "files": [
@@ -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.8"
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.d.mts DELETED
@@ -1,24 +0,0 @@
1
- import { InferConfig, InferState, InferCore, InferResult } from '@pro6pp/infer-core';
2
-
3
- /**
4
- * Hook for the Pro6PP Infer API.
5
- * @param config - The API configuration.
6
- * @returns An object containing the current state, input helpers, and selection handler.
7
- * @example
8
- * const { state, inputProps, selectItem } = useInfer({
9
- * authKey: 'YOUR_KEY',
10
- * country: 'NL'
11
- * });
12
- */
13
- declare function useInfer(config: InferConfig): {
14
- state: InferState;
15
- core: InferCore;
16
- inputProps: {
17
- value: string;
18
- onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
19
- onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
20
- };
21
- selectItem: (item: InferResult | string) => void;
22
- };
23
-
24
- export { useInfer };
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
- };