@public-ui/react-hook-form-adapter 3.0.6-rc.2
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/LICENSE +287 -0
- package/README.md +35 -0
- package/dist/index.cjs +104 -0
- package/dist/index.d.cts +8806 -0
- package/dist/index.d.mts +8806 -0
- package/dist/index.d.ts +8806 -0
- package/dist/index.mjs +84 -0
- package/package.json +89 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Controller } from 'react-hook-form';
|
|
3
|
+
import { KolInputText, KolInputPassword, KolInputEmail, KolInputNumber, KolInputRange, KolInputDate, KolInputColor, KolInputFile, KolTextarea, KolCombobox, KolSelect, KolSingleSelect, KolInputRadio, KolInputCheckbox } from '@public-ui/react-v19';
|
|
4
|
+
|
|
5
|
+
function withController(Component, valueProp) {
|
|
6
|
+
return React.forwardRef((props, ref) => {
|
|
7
|
+
const { name, control, rules, defaultValue, ...rest } = props;
|
|
8
|
+
const userEventHandlers = props._on || {};
|
|
9
|
+
return /* @__PURE__ */ React.createElement(
|
|
10
|
+
Controller,
|
|
11
|
+
{
|
|
12
|
+
name,
|
|
13
|
+
control,
|
|
14
|
+
rules,
|
|
15
|
+
defaultValue,
|
|
16
|
+
render: ({ field, fieldState }) => {
|
|
17
|
+
const componentProps = {
|
|
18
|
+
...rest,
|
|
19
|
+
_name: name,
|
|
20
|
+
_touched: fieldState.isTouched,
|
|
21
|
+
_disabled: props._disabled || field.disabled,
|
|
22
|
+
_msg: fieldState.error ? {
|
|
23
|
+
_type: "error",
|
|
24
|
+
_description: typeof fieldState.error === "string" ? fieldState.error : fieldState.error?.message ?? ""
|
|
25
|
+
} : void 0,
|
|
26
|
+
_on: {
|
|
27
|
+
...userEventHandlers,
|
|
28
|
+
onInput: (e, value) => {
|
|
29
|
+
field.onChange(value);
|
|
30
|
+
if (userEventHandlers.onInput) {
|
|
31
|
+
userEventHandlers.onInput(e, value);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
onChange: (e, value) => {
|
|
35
|
+
field.onChange(value);
|
|
36
|
+
if (userEventHandlers.onChange) {
|
|
37
|
+
userEventHandlers.onChange(e, value);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
onBlur: (e) => {
|
|
41
|
+
field.onBlur();
|
|
42
|
+
if (userEventHandlers.onBlur) {
|
|
43
|
+
userEventHandlers.onBlur(e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
if (valueProp) {
|
|
49
|
+
componentProps[valueProp] = field.value;
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ React.createElement(
|
|
52
|
+
Component,
|
|
53
|
+
{
|
|
54
|
+
ref: (e) => {
|
|
55
|
+
if (ref) {
|
|
56
|
+
if (typeof ref === "function") ref(e);
|
|
57
|
+
else ref.current = e;
|
|
58
|
+
}
|
|
59
|
+
if (e && field.ref) field.ref(e);
|
|
60
|
+
},
|
|
61
|
+
...componentProps
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const KolInputTextController = withController(KolInputText, "_value");
|
|
70
|
+
const KolInputPasswordController = withController(KolInputPassword, "_value");
|
|
71
|
+
const KolInputEmailController = withController(KolInputEmail, "_value");
|
|
72
|
+
const KolInputNumberController = withController(KolInputNumber, "_value");
|
|
73
|
+
const KolInputRangeController = withController(KolInputRange, "_value");
|
|
74
|
+
const KolInputDateController = withController(KolInputDate, "_value");
|
|
75
|
+
const KolInputColorController = withController(KolInputColor, "_value");
|
|
76
|
+
const KolInputFileController = withController(KolInputFile, void 0);
|
|
77
|
+
const KolTextareaController = withController(KolTextarea, "_value");
|
|
78
|
+
const KolComboboxController = withController(KolCombobox, "_value");
|
|
79
|
+
const KolSelectController = withController(KolSelect, "_value");
|
|
80
|
+
const KolSingleSelectController = withController(KolSingleSelect, "_value");
|
|
81
|
+
const KolInputRadioController = withController(KolInputRadio, "_value");
|
|
82
|
+
const KolInputCheckboxController = withController(KolInputCheckbox, "_checked");
|
|
83
|
+
|
|
84
|
+
export { KolComboboxController, KolInputCheckboxController, KolInputColorController, KolInputDateController, KolInputEmailController, KolInputFileController, KolInputNumberController, KolInputPasswordController, KolInputRadioController, KolInputRangeController, KolInputTextController, KolSelectController, KolSingleSelectController, KolTextareaController, withController };
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@public-ui/react-hook-form-adapter",
|
|
3
|
+
"version": "3.0.6-rc.2",
|
|
4
|
+
"license": "EUPL-1.2",
|
|
5
|
+
"homepage": "https://public-ui.github.io",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/public-ui/kolibri"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/public-ui/kolibri/issues",
|
|
12
|
+
"email": "kolibri@itzbund.de"
|
|
13
|
+
},
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Informationstechnikzentrum Bund",
|
|
16
|
+
"email": "kolibri@itzbund.de"
|
|
17
|
+
},
|
|
18
|
+
"description": "React Hook Form adapter for KoliBri - The accessible HTML-Standard.",
|
|
19
|
+
"keywords": [
|
|
20
|
+
"accessibility",
|
|
21
|
+
"accessible",
|
|
22
|
+
"bitv",
|
|
23
|
+
"framework",
|
|
24
|
+
"library",
|
|
25
|
+
"designsystem",
|
|
26
|
+
"design",
|
|
27
|
+
"system",
|
|
28
|
+
"web components",
|
|
29
|
+
"webcomponents",
|
|
30
|
+
"aria",
|
|
31
|
+
"wai",
|
|
32
|
+
"axe",
|
|
33
|
+
"custom elements",
|
|
34
|
+
"styleguide",
|
|
35
|
+
"style",
|
|
36
|
+
"guide",
|
|
37
|
+
"ui",
|
|
38
|
+
"html",
|
|
39
|
+
"css",
|
|
40
|
+
"web",
|
|
41
|
+
"a11y",
|
|
42
|
+
"w3c",
|
|
43
|
+
"webstandard",
|
|
44
|
+
"wcag",
|
|
45
|
+
"react",
|
|
46
|
+
"react-hook-form"
|
|
47
|
+
],
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/react": "18.3.24",
|
|
50
|
+
"@types/react-dom": "18.3.7",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "7.18.0",
|
|
52
|
+
"@typescript-eslint/parser": "7.18.0",
|
|
53
|
+
"eslint": "8.57.1",
|
|
54
|
+
"prettier": "3.6.2",
|
|
55
|
+
"react": "19.1.1",
|
|
56
|
+
"react-dom": "19.1.1",
|
|
57
|
+
"typescript": "5.9.2",
|
|
58
|
+
"unbuild": "3.6.1",
|
|
59
|
+
"@public-ui/components": "3.0.6-rc.2",
|
|
60
|
+
"@public-ui/react-v19": "3.0.6-rc.2"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"react": "^19",
|
|
64
|
+
"react-hook-form": "^7",
|
|
65
|
+
"@public-ui/react-v19": "3.0.6-rc.2"
|
|
66
|
+
},
|
|
67
|
+
"sideEffects": false,
|
|
68
|
+
"type": "module",
|
|
69
|
+
"exports": {
|
|
70
|
+
".": {
|
|
71
|
+
"types": "./dist/index.d.ts",
|
|
72
|
+
"import": "./dist/index.mjs",
|
|
73
|
+
"require": "./dist/index.cjs"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"main": "./dist/index.cjs",
|
|
77
|
+
"module": "./dist/index.mjs",
|
|
78
|
+
"types": "./dist/index.d.ts",
|
|
79
|
+
"files": [
|
|
80
|
+
"dist"
|
|
81
|
+
],
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "unbuild",
|
|
84
|
+
"format": "prettier --check src",
|
|
85
|
+
"-lint": "pnpm lint:eslint && pnpm lint:tsc",
|
|
86
|
+
"-lint:eslint": "eslint src",
|
|
87
|
+
"-lint:tsc": "tsc --noemit"
|
|
88
|
+
}
|
|
89
|
+
}
|