react-store-input 0.1.0 → 0.1.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/README.md +183 -0
- package/dist/create_render.d.mts +4 -3
- package/dist/create_render.d.ts +4 -3
- package/dist/create_render.js +13 -3
- package/dist/create_render.mjs +11 -2
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +148 -102
- package/dist/index.mjs +140 -100
- package/dist/use_form_store.d.mts +2 -2
- package/dist/use_form_store.d.ts +2 -2
- package/dist/use_form_store.js +142 -96
- package/dist/use_form_store.mjs +137 -95
- package/dist/use_store_component.d.mts +21 -0
- package/dist/use_store_component.d.ts +21 -0
- package/dist/use_store_component.js +258 -0
- package/dist/use_store_component.mjs +222 -0
- package/dist/use_store_controller.d.mts +16 -0
- package/dist/use_store_controller.d.ts +16 -0
- package/dist/use_store_controller.js +82 -0
- package/dist/use_store_controller.mjs +57 -0
- package/dist/use_store_input.d.mts +19 -14
- package/dist/use_store_input.d.ts +19 -14
- package/dist/use_store_input.js +94 -118
- package/dist/use_store_input.mjs +96 -113
- package/dist/use_store_input_with_name.d.mts +17 -0
- package/dist/use_store_input_with_name.d.ts +17 -0
- package/dist/use_store_input_with_name.js +201 -0
- package/dist/use_store_input_with_name.mjs +174 -0
- package/package.json +43 -43
- package/dist/use_store_input_props.d.mts +0 -23
- package/dist/use_store_input_props.d.ts +0 -23
- package/dist/use_store_input_props.js +0 -143
- package/dist/use_store_input_props.mjs +0 -122
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
// src/use_store_component.tsx
|
|
2
|
+
import {
|
|
3
|
+
useCallback
|
|
4
|
+
} from "react";
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
// src/use_store_input.tsx
|
|
8
|
+
import "react";
|
|
9
|
+
import { format } from "date-fns";
|
|
10
|
+
|
|
11
|
+
// src/use_store_controller.tsx
|
|
12
|
+
import { useEffect as useEffect2, useId, useRef } from "react";
|
|
13
|
+
|
|
14
|
+
// src/use_subscribe.tsx
|
|
15
|
+
import { useEffect } from "react";
|
|
16
|
+
function useSubscribe(store, subscriber) {
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const unsubscribe = store.subscribe(subscriber);
|
|
19
|
+
return () => {
|
|
20
|
+
unsubscribe();
|
|
21
|
+
};
|
|
22
|
+
}, [store]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/use_store_controller.tsx
|
|
26
|
+
function useStoreController(store, props) {
|
|
27
|
+
const ref = useRef(null);
|
|
28
|
+
const dispatchKey = useId();
|
|
29
|
+
useEffect2(() => {
|
|
30
|
+
const element = ref.current;
|
|
31
|
+
if (!element) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (typeof props.ref === "function") {
|
|
35
|
+
props.ref(element);
|
|
36
|
+
} else if (props.ref) {
|
|
37
|
+
props.ref.current = element;
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
useSubscribe(store, (state, key) => {
|
|
41
|
+
if (key === dispatchKey) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!ref.current) return;
|
|
45
|
+
props.onSubscribe(state, ref.current);
|
|
46
|
+
});
|
|
47
|
+
const onChange = () => {
|
|
48
|
+
store.dispatch(
|
|
49
|
+
(state) => {
|
|
50
|
+
const element = ref.current;
|
|
51
|
+
if (!element) return;
|
|
52
|
+
props.onDispatch(state, element);
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: dispatchKey
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
dispatchKey,
|
|
61
|
+
ref,
|
|
62
|
+
onChange
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/use_store_input.tsx
|
|
67
|
+
function useStoreInput(store, props) {
|
|
68
|
+
const toInputValue = (value) => {
|
|
69
|
+
if (value === void 0 || value === null) {
|
|
70
|
+
return "";
|
|
71
|
+
}
|
|
72
|
+
if (props.type === "datetime-local") {
|
|
73
|
+
if (value instanceof Date) {
|
|
74
|
+
return format(value, "yyyy-MM-dd'T'HH:mm:ss");
|
|
75
|
+
}
|
|
76
|
+
if (typeof value === "string") {
|
|
77
|
+
return toInputValue(new Date(value));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return String(value);
|
|
81
|
+
};
|
|
82
|
+
const getDefaultValue = () => {
|
|
83
|
+
if (props.defaultValue !== void 0) {
|
|
84
|
+
return props.defaultValue;
|
|
85
|
+
}
|
|
86
|
+
if (props.type === "checkbox" || props.type === "radio") {
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
return toInputValue(props.getter(store.state));
|
|
90
|
+
};
|
|
91
|
+
const toInputChecked = (value) => {
|
|
92
|
+
if (props.type === "radio") {
|
|
93
|
+
return value !== void 0 && value === props.value;
|
|
94
|
+
}
|
|
95
|
+
return Boolean(value);
|
|
96
|
+
};
|
|
97
|
+
const getDefaultChecked = () => {
|
|
98
|
+
if (props.defaultChecked) {
|
|
99
|
+
return props.defaultChecked;
|
|
100
|
+
}
|
|
101
|
+
if (props.type !== "checkbox" && props.type !== "radio") {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
return toInputChecked(props.getter(store.state));
|
|
105
|
+
};
|
|
106
|
+
function toStateValue(value) {
|
|
107
|
+
const selected = props.getter(store.state);
|
|
108
|
+
if (typeof selected === "number") {
|
|
109
|
+
return Number(value);
|
|
110
|
+
}
|
|
111
|
+
if (selected instanceof Date) {
|
|
112
|
+
return new Date(value);
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
}
|
|
116
|
+
const inputProps = useStoreController(store, {
|
|
117
|
+
ref: props.ref,
|
|
118
|
+
onSubscribe: (state, element) => {
|
|
119
|
+
if ("checked" in element && (props.type === "checkbox" || props.type === "radio")) {
|
|
120
|
+
const checked = toInputChecked(props.getter(state));
|
|
121
|
+
if (element.checked === checked) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
element.checked = checked;
|
|
125
|
+
} else {
|
|
126
|
+
const value = toInputValue(props.getter(state));
|
|
127
|
+
if (element.value === value) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
element.value = value;
|
|
131
|
+
}
|
|
132
|
+
const event = new Event("input", { bubbles: true });
|
|
133
|
+
element.dispatchEvent(event);
|
|
134
|
+
},
|
|
135
|
+
onDispatch: (state, element) => {
|
|
136
|
+
if ("checked" in element && props.type === "checkbox") {
|
|
137
|
+
props.setter(state, element.checked);
|
|
138
|
+
} else {
|
|
139
|
+
props.setter(state, toStateValue(element.value));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
ref: inputProps.ref,
|
|
145
|
+
dispatchKey: inputProps.dispatchKey,
|
|
146
|
+
defaultValue: getDefaultValue(),
|
|
147
|
+
defaultChecked: getDefaultChecked(),
|
|
148
|
+
onChange: (event) => {
|
|
149
|
+
inputProps.onChange();
|
|
150
|
+
props.onChange?.(event);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/use_store_input_with_name.tsx
|
|
156
|
+
function useStoreInputWithName(store, props) {
|
|
157
|
+
const inputProps = useStoreInput(store, {
|
|
158
|
+
...props,
|
|
159
|
+
getter: (state) => {
|
|
160
|
+
if (props.getter) {
|
|
161
|
+
return props.getter(state);
|
|
162
|
+
}
|
|
163
|
+
return state[props.name];
|
|
164
|
+
},
|
|
165
|
+
setter: (state, value) => {
|
|
166
|
+
if (props.setter) {
|
|
167
|
+
props.setter(state, value);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
state[props.name] = value;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return {
|
|
174
|
+
...inputProps,
|
|
175
|
+
name: "name" in props ? String(props.name) : void 0
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/use_store_component.tsx
|
|
180
|
+
function useStoreComponent(store) {
|
|
181
|
+
const input = useCallback(function Component(props) {
|
|
182
|
+
return /* @__PURE__ */ React.createElement(Input, { store, ...props });
|
|
183
|
+
}, []);
|
|
184
|
+
const select = useCallback(function Component(props) {
|
|
185
|
+
return /* @__PURE__ */ React.createElement(Select, { store, ...props });
|
|
186
|
+
}, []);
|
|
187
|
+
const textarea = useCallback(function Component(props) {
|
|
188
|
+
return /* @__PURE__ */ React.createElement(Textarea, { store, ...props });
|
|
189
|
+
}, []);
|
|
190
|
+
return {
|
|
191
|
+
input,
|
|
192
|
+
select,
|
|
193
|
+
textarea
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function Input({
|
|
197
|
+
store,
|
|
198
|
+
...props
|
|
199
|
+
}) {
|
|
200
|
+
const storeProps = useStoreInputWithName(store, props);
|
|
201
|
+
return /* @__PURE__ */ React.createElement("input", { ...props, ...storeProps });
|
|
202
|
+
}
|
|
203
|
+
function Select({
|
|
204
|
+
store,
|
|
205
|
+
...props
|
|
206
|
+
}) {
|
|
207
|
+
const storeProps = useStoreInputWithName(store, props);
|
|
208
|
+
return /* @__PURE__ */ React.createElement("select", { ...props, ...storeProps });
|
|
209
|
+
}
|
|
210
|
+
function Textarea({
|
|
211
|
+
store,
|
|
212
|
+
...props
|
|
213
|
+
}) {
|
|
214
|
+
const storeProps = useStoreInputWithName(store, props);
|
|
215
|
+
return /* @__PURE__ */ React.createElement("textarea", { ...props, ...storeProps });
|
|
216
|
+
}
|
|
217
|
+
export {
|
|
218
|
+
Input,
|
|
219
|
+
Select,
|
|
220
|
+
Textarea,
|
|
221
|
+
useStoreComponent
|
|
222
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Ref } from 'react';
|
|
3
|
+
import { Store } from './use_store.mjs';
|
|
4
|
+
|
|
5
|
+
type StoreControllerProps<TController, TState> = {
|
|
6
|
+
ref?: Ref<TController>;
|
|
7
|
+
onSubscribe: (state: TState, element: TController) => void;
|
|
8
|
+
onDispatch: (state: TState, element: TController) => void;
|
|
9
|
+
};
|
|
10
|
+
declare function useStoreController<TController, TState>(store: Store<TState>, props: StoreControllerProps<TController, TState>): {
|
|
11
|
+
dispatchKey: string;
|
|
12
|
+
ref: React.RefObject<TController | null>;
|
|
13
|
+
onChange: () => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { type StoreControllerProps, useStoreController };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Ref } from 'react';
|
|
3
|
+
import { Store } from './use_store.js';
|
|
4
|
+
|
|
5
|
+
type StoreControllerProps<TController, TState> = {
|
|
6
|
+
ref?: Ref<TController>;
|
|
7
|
+
onSubscribe: (state: TState, element: TController) => void;
|
|
8
|
+
onDispatch: (state: TState, element: TController) => void;
|
|
9
|
+
};
|
|
10
|
+
declare function useStoreController<TController, TState>(store: Store<TState>, props: StoreControllerProps<TController, TState>): {
|
|
11
|
+
dispatchKey: string;
|
|
12
|
+
ref: React.RefObject<TController | null>;
|
|
13
|
+
onChange: () => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { type StoreControllerProps, useStoreController };
|
|
@@ -0,0 +1,82 @@
|
|
|
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/use_store_controller.tsx
|
|
21
|
+
var use_store_controller_exports = {};
|
|
22
|
+
__export(use_store_controller_exports, {
|
|
23
|
+
useStoreController: () => useStoreController
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(use_store_controller_exports);
|
|
26
|
+
var import_react2 = require("react");
|
|
27
|
+
|
|
28
|
+
// src/use_subscribe.tsx
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
function useSubscribe(store, subscriber) {
|
|
31
|
+
(0, import_react.useEffect)(() => {
|
|
32
|
+
const unsubscribe = store.subscribe(subscriber);
|
|
33
|
+
return () => {
|
|
34
|
+
unsubscribe();
|
|
35
|
+
};
|
|
36
|
+
}, [store]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/use_store_controller.tsx
|
|
40
|
+
function useStoreController(store, props) {
|
|
41
|
+
const ref = (0, import_react2.useRef)(null);
|
|
42
|
+
const dispatchKey = (0, import_react2.useId)();
|
|
43
|
+
(0, import_react2.useEffect)(() => {
|
|
44
|
+
const element = ref.current;
|
|
45
|
+
if (!element) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (typeof props.ref === "function") {
|
|
49
|
+
props.ref(element);
|
|
50
|
+
} else if (props.ref) {
|
|
51
|
+
props.ref.current = element;
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
useSubscribe(store, (state, key) => {
|
|
55
|
+
if (key === dispatchKey) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!ref.current) return;
|
|
59
|
+
props.onSubscribe(state, ref.current);
|
|
60
|
+
});
|
|
61
|
+
const onChange = () => {
|
|
62
|
+
store.dispatch(
|
|
63
|
+
(state) => {
|
|
64
|
+
const element = ref.current;
|
|
65
|
+
if (!element) return;
|
|
66
|
+
props.onDispatch(state, element);
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: dispatchKey
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
dispatchKey,
|
|
75
|
+
ref,
|
|
76
|
+
onChange
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
useStoreController
|
|
82
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/use_store_controller.tsx
|
|
2
|
+
import { useEffect as useEffect2, useId, useRef } from "react";
|
|
3
|
+
|
|
4
|
+
// src/use_subscribe.tsx
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
function useSubscribe(store, subscriber) {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const unsubscribe = store.subscribe(subscriber);
|
|
9
|
+
return () => {
|
|
10
|
+
unsubscribe();
|
|
11
|
+
};
|
|
12
|
+
}, [store]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/use_store_controller.tsx
|
|
16
|
+
function useStoreController(store, props) {
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
const dispatchKey = useId();
|
|
19
|
+
useEffect2(() => {
|
|
20
|
+
const element = ref.current;
|
|
21
|
+
if (!element) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (typeof props.ref === "function") {
|
|
25
|
+
props.ref(element);
|
|
26
|
+
} else if (props.ref) {
|
|
27
|
+
props.ref.current = element;
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
useSubscribe(store, (state, key) => {
|
|
31
|
+
if (key === dispatchKey) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!ref.current) return;
|
|
35
|
+
props.onSubscribe(state, ref.current);
|
|
36
|
+
});
|
|
37
|
+
const onChange = () => {
|
|
38
|
+
store.dispatch(
|
|
39
|
+
(state) => {
|
|
40
|
+
const element = ref.current;
|
|
41
|
+
if (!element) return;
|
|
42
|
+
props.onDispatch(state, element);
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: dispatchKey
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
dispatchKey,
|
|
51
|
+
ref,
|
|
52
|
+
onChange
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
useStoreController
|
|
57
|
+
};
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { Ref, HTMLInputTypeAttribute } from 'react';
|
|
2
3
|
import { Store } from './use_store.mjs';
|
|
3
4
|
|
|
4
|
-
type StoreInputProps<
|
|
5
|
-
|
|
5
|
+
type StoreInputProps<TInputElement, TState> = {
|
|
6
|
+
ref?: Ref<TInputElement>;
|
|
7
|
+
type?: HTMLInputTypeAttribute;
|
|
8
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
|
9
|
+
value?: string | number | readonly string[] | undefined;
|
|
10
|
+
defaultChecked?: boolean | undefined;
|
|
11
|
+
onChange?: (event: React.ChangeEvent<TInputElement>) => void;
|
|
12
|
+
} & {
|
|
13
|
+
getter: (state: TState) => unknown;
|
|
14
|
+
setter: (state: TState, value: unknown) => void;
|
|
6
15
|
};
|
|
7
|
-
declare function useStoreInput<TState>(store: Store<TState>): {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
declare function useStoreInput<TInputElement extends HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, TState>(store: Store<TState>, props: StoreInputProps<TInputElement, TState>): {
|
|
17
|
+
ref: React$1.RefObject<TInputElement | null>;
|
|
18
|
+
dispatchKey: string;
|
|
19
|
+
defaultValue: string | number | readonly string[] | undefined;
|
|
20
|
+
defaultChecked: boolean | undefined;
|
|
21
|
+
onChange: (event: React.ChangeEvent<TInputElement>) => void;
|
|
11
22
|
};
|
|
12
|
-
type StoreInputPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState> = StoreInputProps<TElement, TState> & {
|
|
13
|
-
store: Store<TState>;
|
|
14
|
-
};
|
|
15
|
-
declare function Input<TState>({ store, ...props }: StoreInputPropsWithStore<HTMLInputElement, TState>): React__default.JSX.Element;
|
|
16
|
-
declare function Select<TState>({ store, ...props }: StoreInputPropsWithStore<HTMLSelectElement, TState>): React__default.JSX.Element;
|
|
17
|
-
declare function Textarea<TState>({ store, ...props }: StoreInputPropsWithStore<HTMLTextAreaElement, TState>): React__default.JSX.Element;
|
|
18
23
|
|
|
19
|
-
export {
|
|
24
|
+
export { type StoreInputProps, useStoreInput };
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { Ref, HTMLInputTypeAttribute } from 'react';
|
|
2
3
|
import { Store } from './use_store.js';
|
|
3
4
|
|
|
4
|
-
type StoreInputProps<
|
|
5
|
-
|
|
5
|
+
type StoreInputProps<TInputElement, TState> = {
|
|
6
|
+
ref?: Ref<TInputElement>;
|
|
7
|
+
type?: HTMLInputTypeAttribute;
|
|
8
|
+
defaultValue?: string | number | readonly string[] | undefined;
|
|
9
|
+
value?: string | number | readonly string[] | undefined;
|
|
10
|
+
defaultChecked?: boolean | undefined;
|
|
11
|
+
onChange?: (event: React.ChangeEvent<TInputElement>) => void;
|
|
12
|
+
} & {
|
|
13
|
+
getter: (state: TState) => unknown;
|
|
14
|
+
setter: (state: TState, value: unknown) => void;
|
|
6
15
|
};
|
|
7
|
-
declare function useStoreInput<TState>(store: Store<TState>): {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
declare function useStoreInput<TInputElement extends HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, TState>(store: Store<TState>, props: StoreInputProps<TInputElement, TState>): {
|
|
17
|
+
ref: React$1.RefObject<TInputElement | null>;
|
|
18
|
+
dispatchKey: string;
|
|
19
|
+
defaultValue: string | number | readonly string[] | undefined;
|
|
20
|
+
defaultChecked: boolean | undefined;
|
|
21
|
+
onChange: (event: React.ChangeEvent<TInputElement>) => void;
|
|
11
22
|
};
|
|
12
|
-
type StoreInputPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState> = StoreInputProps<TElement, TState> & {
|
|
13
|
-
store: Store<TState>;
|
|
14
|
-
};
|
|
15
|
-
declare function Input<TState>({ store, ...props }: StoreInputPropsWithStore<HTMLInputElement, TState>): React__default.JSX.Element;
|
|
16
|
-
declare function Select<TState>({ store, ...props }: StoreInputPropsWithStore<HTMLSelectElement, TState>): React__default.JSX.Element;
|
|
17
|
-
declare function Textarea<TState>({ store, ...props }: StoreInputPropsWithStore<HTMLTextAreaElement, TState>): React__default.JSX.Element;
|
|
18
23
|
|
|
19
|
-
export {
|
|
24
|
+
export { type StoreInputProps, useStoreInput };
|