react-store-input 0.1.3 → 0.1.4
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 +92 -29
- package/dist/index.js +9 -5
- package/dist/index.mjs +9 -5
- package/dist/use_form_store.js +9 -5
- package/dist/use_form_store.mjs +9 -5
- package/dist/use_store_component.d.mts +3 -3
- package/dist/use_store_component.d.ts +3 -3
- package/dist/use_store_component.js +9 -5
- package/dist/use_store_component.mjs +9 -5
- package/dist/use_store_controller.d.mts +0 -1
- package/dist/use_store_controller.d.ts +0 -1
- package/dist/use_store_controller.js +0 -1
- package/dist/use_store_controller.mjs +0 -1
- package/dist/use_store_input.d.mts +0 -1
- package/dist/use_store_input.d.ts +0 -1
- package/dist/use_store_input.js +0 -2
- package/dist/use_store_input.mjs +0 -2
- package/dist/use_store_input_with_name.d.mts +0 -1
- package/dist/use_store_input_with_name.d.ts +0 -1
- package/dist/use_store_input_with_name.js +0 -2
- package/dist/use_store_input_with_name.mjs +0 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,29 +14,29 @@ This is a simple example of how to use this package.
|
|
|
14
14
|
import { useFormStore } from "dn-react-input";
|
|
15
15
|
|
|
16
16
|
export default function App() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
const store = useFormStore({
|
|
18
|
+
email: "",
|
|
19
|
+
password: "",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const submit = async () => {
|
|
23
|
+
const { email, password } = store.state;
|
|
24
|
+
|
|
25
|
+
alert(`Email: ${email}\nPassword: ${password}`);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<form
|
|
30
|
+
onSubmit={(e) => {
|
|
31
|
+
e.preventDefault();
|
|
32
|
+
submit();
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<store.input name="email" type="email" />
|
|
36
|
+
<store.input name="password" type="password" />
|
|
37
|
+
<button type="submit">Submit</button>
|
|
38
|
+
</form>
|
|
39
|
+
);
|
|
40
40
|
}
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -96,20 +96,20 @@ function Component() {
|
|
|
96
96
|
}
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
If you want to avoid passing the store to each input component, use `
|
|
99
|
+
If you want to avoid passing the store to each input component, use `useStoreComponent`. This hook provides input components that are already connected to the store.
|
|
100
100
|
|
|
101
101
|
```tsx
|
|
102
|
-
import {
|
|
102
|
+
import { useStoreComponent } from "dn-react-input";
|
|
103
103
|
|
|
104
104
|
function Component() {
|
|
105
105
|
...
|
|
106
|
-
const
|
|
106
|
+
const component = useStoreComponent(store);
|
|
107
107
|
|
|
108
108
|
return (
|
|
109
109
|
<form>
|
|
110
|
-
<
|
|
111
|
-
<
|
|
112
|
-
<
|
|
110
|
+
<component.input name="email" type="email" />
|
|
111
|
+
<component.input name="password" type="password" />
|
|
112
|
+
<component.input name="rememberMe" type="checkbox" />
|
|
113
113
|
</form>
|
|
114
114
|
);
|
|
115
115
|
}
|
|
@@ -169,6 +169,28 @@ function Component() {
|
|
|
169
169
|
}
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
+
`Store.render` is a shortcut for `createRender` when you use `useFormStore`.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
function Component() {
|
|
176
|
+
const store = useFormStore({
|
|
177
|
+
email: "",
|
|
178
|
+
password: "",
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<div>
|
|
183
|
+
{store.render((state) => (
|
|
184
|
+
<p>{state.email}</p>
|
|
185
|
+
))}
|
|
186
|
+
{store.render((state) => (
|
|
187
|
+
<p>{state.password}</p>
|
|
188
|
+
))}
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
172
194
|
## How to subscribe to state changes?
|
|
173
195
|
|
|
174
196
|
You can subscribe to state changes using the `subscribe` method of the store.
|
|
@@ -220,3 +242,44 @@ function Component() {
|
|
|
220
242
|
return <button onClick={updateEmail}>Update Email</button>;
|
|
221
243
|
}
|
|
222
244
|
```
|
|
245
|
+
|
|
246
|
+
## How to create custom input components?
|
|
247
|
+
|
|
248
|
+
You can create custom input components using the `useStoreInput` hook. This hook provides the necessary props to connect your custom input component to the store: `name`, `value`, `defaultValue`, `defaultChecked`, `onChange`, and `ref` which already subscribed to the store.
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
import { useStoreInput } from "dn-react-input";
|
|
252
|
+
|
|
253
|
+
function CustomInput({ store }: { store: Store<{ email: string }> }) {
|
|
254
|
+
const inputProps = useStoreInput(store, {
|
|
255
|
+
name: "email",
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
return <input {...inputProps} />;
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## How to creatre custom controller components?
|
|
263
|
+
|
|
264
|
+
If your custom component is not an html input element, you can use the `useStoreController` hook. This hook provides the necessary props to connect your custom controller component to the store: `ref`, `onSubscribe`, and `onDispatch`.
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
import { useStoreController } from "dn-react-input";
|
|
268
|
+
|
|
269
|
+
type State = {
|
|
270
|
+
count: number;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
function CustomController({ store }: { store: Store<State> }) {
|
|
274
|
+
const controllerProps = useStoreController<HTMLDivElement, State>(store, {
|
|
275
|
+
onSubscribe: (state, element) => {
|
|
276
|
+
element.textContent = `Count: ${state.count}`;
|
|
277
|
+
},
|
|
278
|
+
onDispatch: (state, element) => {
|
|
279
|
+
state.count += Number(element.textContent.replace("Count: ", ""));
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
return <div {...controllerProps} />;
|
|
284
|
+
}
|
|
285
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -153,7 +153,6 @@ function useStoreController(store, props) {
|
|
|
153
153
|
);
|
|
154
154
|
};
|
|
155
155
|
return {
|
|
156
|
-
dispatchKey,
|
|
157
156
|
ref,
|
|
158
157
|
onChange
|
|
159
158
|
};
|
|
@@ -240,7 +239,6 @@ function useStoreInput(store, props) {
|
|
|
240
239
|
});
|
|
241
240
|
return {
|
|
242
241
|
ref: inputProps.ref,
|
|
243
|
-
dispatchKey: inputProps.dispatchKey,
|
|
244
242
|
defaultValue: getDefaultValue(),
|
|
245
243
|
defaultChecked: getDefaultChecked(),
|
|
246
244
|
onChange: (event) => {
|
|
@@ -295,23 +293,29 @@ function useStoreComponent(store) {
|
|
|
295
293
|
}
|
|
296
294
|
function Input({
|
|
297
295
|
store,
|
|
296
|
+
getter,
|
|
297
|
+
setter,
|
|
298
298
|
...props
|
|
299
299
|
}) {
|
|
300
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
300
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
301
301
|
return /* @__PURE__ */ import_react7.default.createElement("input", { ...props, ...storeProps });
|
|
302
302
|
}
|
|
303
303
|
function Select({
|
|
304
304
|
store,
|
|
305
|
+
getter,
|
|
306
|
+
setter,
|
|
305
307
|
...props
|
|
306
308
|
}) {
|
|
307
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
309
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
308
310
|
return /* @__PURE__ */ import_react7.default.createElement("select", { ...props, ...storeProps });
|
|
309
311
|
}
|
|
310
312
|
function Textarea({
|
|
311
313
|
store,
|
|
314
|
+
getter,
|
|
315
|
+
setter,
|
|
312
316
|
...props
|
|
313
317
|
}) {
|
|
314
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
318
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
315
319
|
return /* @__PURE__ */ import_react7.default.createElement("textarea", { ...props, ...storeProps });
|
|
316
320
|
}
|
|
317
321
|
|
package/dist/index.mjs
CHANGED
|
@@ -105,7 +105,6 @@ function useStoreController(store, props) {
|
|
|
105
105
|
);
|
|
106
106
|
};
|
|
107
107
|
return {
|
|
108
|
-
dispatchKey,
|
|
109
108
|
ref,
|
|
110
109
|
onChange
|
|
111
110
|
};
|
|
@@ -192,7 +191,6 @@ function useStoreInput(store, props) {
|
|
|
192
191
|
});
|
|
193
192
|
return {
|
|
194
193
|
ref: inputProps.ref,
|
|
195
|
-
dispatchKey: inputProps.dispatchKey,
|
|
196
194
|
defaultValue: getDefaultValue(),
|
|
197
195
|
defaultChecked: getDefaultChecked(),
|
|
198
196
|
onChange: (event) => {
|
|
@@ -249,23 +247,29 @@ function useStoreComponent(store) {
|
|
|
249
247
|
}
|
|
250
248
|
function Input({
|
|
251
249
|
store,
|
|
250
|
+
getter,
|
|
251
|
+
setter,
|
|
252
252
|
...props
|
|
253
253
|
}) {
|
|
254
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
254
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
255
255
|
return /* @__PURE__ */ React.createElement("input", { ...props, ...storeProps });
|
|
256
256
|
}
|
|
257
257
|
function Select({
|
|
258
258
|
store,
|
|
259
|
+
getter,
|
|
260
|
+
setter,
|
|
259
261
|
...props
|
|
260
262
|
}) {
|
|
261
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
263
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
262
264
|
return /* @__PURE__ */ React.createElement("select", { ...props, ...storeProps });
|
|
263
265
|
}
|
|
264
266
|
function Textarea({
|
|
265
267
|
store,
|
|
268
|
+
getter,
|
|
269
|
+
setter,
|
|
266
270
|
...props
|
|
267
271
|
}) {
|
|
268
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
272
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
269
273
|
return /* @__PURE__ */ React.createElement("textarea", { ...props, ...storeProps });
|
|
270
274
|
}
|
|
271
275
|
|
package/dist/use_form_store.js
CHANGED
|
@@ -162,7 +162,6 @@ function useStoreController(store, props) {
|
|
|
162
162
|
);
|
|
163
163
|
};
|
|
164
164
|
return {
|
|
165
|
-
dispatchKey,
|
|
166
165
|
ref,
|
|
167
166
|
onChange
|
|
168
167
|
};
|
|
@@ -247,7 +246,6 @@ function useStoreInput(store, props) {
|
|
|
247
246
|
});
|
|
248
247
|
return {
|
|
249
248
|
ref: inputProps.ref,
|
|
250
|
-
dispatchKey: inputProps.dispatchKey,
|
|
251
249
|
defaultValue: getDefaultValue(),
|
|
252
250
|
defaultChecked: getDefaultChecked(),
|
|
253
251
|
onChange: (event) => {
|
|
@@ -300,23 +298,29 @@ function useStoreComponent(store) {
|
|
|
300
298
|
}
|
|
301
299
|
function Input({
|
|
302
300
|
store,
|
|
301
|
+
getter,
|
|
302
|
+
setter,
|
|
303
303
|
...props
|
|
304
304
|
}) {
|
|
305
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
305
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
306
306
|
return /* @__PURE__ */ import_react8.default.createElement("input", { ...props, ...storeProps });
|
|
307
307
|
}
|
|
308
308
|
function Select({
|
|
309
309
|
store,
|
|
310
|
+
getter,
|
|
311
|
+
setter,
|
|
310
312
|
...props
|
|
311
313
|
}) {
|
|
312
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
314
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
313
315
|
return /* @__PURE__ */ import_react8.default.createElement("select", { ...props, ...storeProps });
|
|
314
316
|
}
|
|
315
317
|
function Textarea({
|
|
316
318
|
store,
|
|
319
|
+
getter,
|
|
320
|
+
setter,
|
|
317
321
|
...props
|
|
318
322
|
}) {
|
|
319
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
323
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
320
324
|
return /* @__PURE__ */ import_react8.default.createElement("textarea", { ...props, ...storeProps });
|
|
321
325
|
}
|
|
322
326
|
|
package/dist/use_form_store.mjs
CHANGED
|
@@ -128,7 +128,6 @@ function useStoreController(store, props) {
|
|
|
128
128
|
);
|
|
129
129
|
};
|
|
130
130
|
return {
|
|
131
|
-
dispatchKey,
|
|
132
131
|
ref,
|
|
133
132
|
onChange
|
|
134
133
|
};
|
|
@@ -213,7 +212,6 @@ function useStoreInput(store, props) {
|
|
|
213
212
|
});
|
|
214
213
|
return {
|
|
215
214
|
ref: inputProps.ref,
|
|
216
|
-
dispatchKey: inputProps.dispatchKey,
|
|
217
215
|
defaultValue: getDefaultValue(),
|
|
218
216
|
defaultChecked: getDefaultChecked(),
|
|
219
217
|
onChange: (event) => {
|
|
@@ -266,23 +264,29 @@ function useStoreComponent(store) {
|
|
|
266
264
|
}
|
|
267
265
|
function Input({
|
|
268
266
|
store,
|
|
267
|
+
getter,
|
|
268
|
+
setter,
|
|
269
269
|
...props
|
|
270
270
|
}) {
|
|
271
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
271
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
272
272
|
return /* @__PURE__ */ React2.createElement("input", { ...props, ...storeProps });
|
|
273
273
|
}
|
|
274
274
|
function Select({
|
|
275
275
|
store,
|
|
276
|
+
getter,
|
|
277
|
+
setter,
|
|
276
278
|
...props
|
|
277
279
|
}) {
|
|
278
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
280
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
279
281
|
return /* @__PURE__ */ React2.createElement("select", { ...props, ...storeProps });
|
|
280
282
|
}
|
|
281
283
|
function Textarea({
|
|
282
284
|
store,
|
|
285
|
+
getter,
|
|
286
|
+
setter,
|
|
283
287
|
...props
|
|
284
288
|
}) {
|
|
285
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
289
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
286
290
|
return /* @__PURE__ */ React2.createElement("textarea", { ...props, ...storeProps });
|
|
287
291
|
}
|
|
288
292
|
|
|
@@ -14,8 +14,8 @@ declare function useStoreComponent<TState>(store: Store<TState>): {
|
|
|
14
14
|
type StoreComponentPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState> = StoreComponentProps<TElement, TState> & {
|
|
15
15
|
store: Store<TState>;
|
|
16
16
|
};
|
|
17
|
-
declare function Input<TState>({ store, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState>): React__default.JSX.Element;
|
|
18
|
-
declare function Select<TState>({ store, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState>): React__default.JSX.Element;
|
|
19
|
-
declare function Textarea<TState>({ store, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState>): React__default.JSX.Element;
|
|
17
|
+
declare function Input<TState>({ store, getter, setter, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState>): React__default.JSX.Element;
|
|
18
|
+
declare function Select<TState>({ store, getter, setter, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState>): React__default.JSX.Element;
|
|
19
|
+
declare function Textarea<TState>({ store, getter, setter, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState>): React__default.JSX.Element;
|
|
20
20
|
|
|
21
21
|
export { Input, Select, type StoreComponentProps, type StoreComponentPropsWithStore, Textarea, useStoreComponent };
|
|
@@ -14,8 +14,8 @@ declare function useStoreComponent<TState>(store: Store<TState>): {
|
|
|
14
14
|
type StoreComponentPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState> = StoreComponentProps<TElement, TState> & {
|
|
15
15
|
store: Store<TState>;
|
|
16
16
|
};
|
|
17
|
-
declare function Input<TState>({ store, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState>): React__default.JSX.Element;
|
|
18
|
-
declare function Select<TState>({ store, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState>): React__default.JSX.Element;
|
|
19
|
-
declare function Textarea<TState>({ store, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState>): React__default.JSX.Element;
|
|
17
|
+
declare function Input<TState>({ store, getter, setter, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState>): React__default.JSX.Element;
|
|
18
|
+
declare function Select<TState>({ store, getter, setter, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState>): React__default.JSX.Element;
|
|
19
|
+
declare function Textarea<TState>({ store, getter, setter, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState>): React__default.JSX.Element;
|
|
20
20
|
|
|
21
21
|
export { Input, Select, type StoreComponentProps, type StoreComponentPropsWithStore, Textarea, useStoreComponent };
|
|
@@ -92,7 +92,6 @@ function useStoreController(store, props) {
|
|
|
92
92
|
);
|
|
93
93
|
};
|
|
94
94
|
return {
|
|
95
|
-
dispatchKey,
|
|
96
95
|
ref,
|
|
97
96
|
onChange
|
|
98
97
|
};
|
|
@@ -177,7 +176,6 @@ function useStoreInput(store, props) {
|
|
|
177
176
|
});
|
|
178
177
|
return {
|
|
179
178
|
ref: inputProps.ref,
|
|
180
|
-
dispatchKey: inputProps.dispatchKey,
|
|
181
179
|
defaultValue: getDefaultValue(),
|
|
182
180
|
defaultChecked: getDefaultChecked(),
|
|
183
181
|
onChange: (event) => {
|
|
@@ -230,23 +228,29 @@ function useStoreComponent(store) {
|
|
|
230
228
|
}
|
|
231
229
|
function Input({
|
|
232
230
|
store,
|
|
231
|
+
getter,
|
|
232
|
+
setter,
|
|
233
233
|
...props
|
|
234
234
|
}) {
|
|
235
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
235
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
236
236
|
return /* @__PURE__ */ import_react5.default.createElement("input", { ...props, ...storeProps });
|
|
237
237
|
}
|
|
238
238
|
function Select({
|
|
239
239
|
store,
|
|
240
|
+
getter,
|
|
241
|
+
setter,
|
|
240
242
|
...props
|
|
241
243
|
}) {
|
|
242
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
244
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
243
245
|
return /* @__PURE__ */ import_react5.default.createElement("select", { ...props, ...storeProps });
|
|
244
246
|
}
|
|
245
247
|
function Textarea({
|
|
246
248
|
store,
|
|
249
|
+
getter,
|
|
250
|
+
setter,
|
|
247
251
|
...props
|
|
248
252
|
}) {
|
|
249
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
253
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
250
254
|
return /* @__PURE__ */ import_react5.default.createElement("textarea", { ...props, ...storeProps });
|
|
251
255
|
}
|
|
252
256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -57,7 +57,6 @@ function useStoreController(store, props) {
|
|
|
57
57
|
);
|
|
58
58
|
};
|
|
59
59
|
return {
|
|
60
|
-
dispatchKey,
|
|
61
60
|
ref,
|
|
62
61
|
onChange
|
|
63
62
|
};
|
|
@@ -142,7 +141,6 @@ function useStoreInput(store, props) {
|
|
|
142
141
|
});
|
|
143
142
|
return {
|
|
144
143
|
ref: inputProps.ref,
|
|
145
|
-
dispatchKey: inputProps.dispatchKey,
|
|
146
144
|
defaultValue: getDefaultValue(),
|
|
147
145
|
defaultChecked: getDefaultChecked(),
|
|
148
146
|
onChange: (event) => {
|
|
@@ -195,23 +193,29 @@ function useStoreComponent(store) {
|
|
|
195
193
|
}
|
|
196
194
|
function Input({
|
|
197
195
|
store,
|
|
196
|
+
getter,
|
|
197
|
+
setter,
|
|
198
198
|
...props
|
|
199
199
|
}) {
|
|
200
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
200
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
201
201
|
return /* @__PURE__ */ React.createElement("input", { ...props, ...storeProps });
|
|
202
202
|
}
|
|
203
203
|
function Select({
|
|
204
204
|
store,
|
|
205
|
+
getter,
|
|
206
|
+
setter,
|
|
205
207
|
...props
|
|
206
208
|
}) {
|
|
207
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
209
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
208
210
|
return /* @__PURE__ */ React.createElement("select", { ...props, ...storeProps });
|
|
209
211
|
}
|
|
210
212
|
function Textarea({
|
|
211
213
|
store,
|
|
214
|
+
getter,
|
|
215
|
+
setter,
|
|
212
216
|
...props
|
|
213
217
|
}) {
|
|
214
|
-
const storeProps = useStoreInputWithName(store, props);
|
|
218
|
+
const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
|
|
215
219
|
return /* @__PURE__ */ React.createElement("textarea", { ...props, ...storeProps });
|
|
216
220
|
}
|
|
217
221
|
export {
|
|
@@ -8,7 +8,6 @@ type StoreControllerProps<TController, TState> = {
|
|
|
8
8
|
onDispatch: (state: TState, element: TController) => void;
|
|
9
9
|
};
|
|
10
10
|
declare function useStoreController<TController, TState>(store: Store<TState>, props: StoreControllerProps<TController, TState>): {
|
|
11
|
-
dispatchKey: string;
|
|
12
11
|
ref: React.RefObject<TController | null>;
|
|
13
12
|
onChange: () => void;
|
|
14
13
|
};
|
|
@@ -8,7 +8,6 @@ type StoreControllerProps<TController, TState> = {
|
|
|
8
8
|
onDispatch: (state: TState, element: TController) => void;
|
|
9
9
|
};
|
|
10
10
|
declare function useStoreController<TController, TState>(store: Store<TState>, props: StoreControllerProps<TController, TState>): {
|
|
11
|
-
dispatchKey: string;
|
|
12
11
|
ref: React.RefObject<TController | null>;
|
|
13
12
|
onChange: () => void;
|
|
14
13
|
};
|
|
@@ -15,7 +15,6 @@ type StoreInputProps<TInputElement, TState> = {
|
|
|
15
15
|
};
|
|
16
16
|
declare function useStoreInput<TInputElement extends HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, TState>(store: Store<TState>, props: StoreInputProps<TInputElement, TState>): {
|
|
17
17
|
ref: React$1.RefObject<TInputElement | null>;
|
|
18
|
-
dispatchKey: string;
|
|
19
18
|
defaultValue: string | number | readonly string[] | undefined;
|
|
20
19
|
defaultChecked: boolean | undefined;
|
|
21
20
|
onChange: (event: React.ChangeEvent<TInputElement>) => void;
|
|
@@ -15,7 +15,6 @@ type StoreInputProps<TInputElement, TState> = {
|
|
|
15
15
|
};
|
|
16
16
|
declare function useStoreInput<TInputElement extends HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, TState>(store: Store<TState>, props: StoreInputProps<TInputElement, TState>): {
|
|
17
17
|
ref: React$1.RefObject<TInputElement | null>;
|
|
18
|
-
dispatchKey: string;
|
|
19
18
|
defaultValue: string | number | readonly string[] | undefined;
|
|
20
19
|
defaultChecked: boolean | undefined;
|
|
21
20
|
onChange: (event: React.ChangeEvent<TInputElement>) => void;
|
package/dist/use_store_input.js
CHANGED
|
@@ -75,7 +75,6 @@ function useStoreController(store, props) {
|
|
|
75
75
|
);
|
|
76
76
|
};
|
|
77
77
|
return {
|
|
78
|
-
dispatchKey,
|
|
79
78
|
ref,
|
|
80
79
|
onChange
|
|
81
80
|
};
|
|
@@ -160,7 +159,6 @@ function useStoreInput(store, props) {
|
|
|
160
159
|
});
|
|
161
160
|
return {
|
|
162
161
|
ref: inputProps.ref,
|
|
163
|
-
dispatchKey: inputProps.dispatchKey,
|
|
164
162
|
defaultValue: getDefaultValue(),
|
|
165
163
|
defaultChecked: getDefaultChecked(),
|
|
166
164
|
onChange: (event) => {
|
package/dist/use_store_input.mjs
CHANGED
|
@@ -51,7 +51,6 @@ function useStoreController(store, props) {
|
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
53
|
return {
|
|
54
|
-
dispatchKey,
|
|
55
54
|
ref,
|
|
56
55
|
onChange
|
|
57
56
|
};
|
|
@@ -136,7 +135,6 @@ function useStoreInput(store, props) {
|
|
|
136
135
|
});
|
|
137
136
|
return {
|
|
138
137
|
ref: inputProps.ref,
|
|
139
|
-
dispatchKey: inputProps.dispatchKey,
|
|
140
138
|
defaultValue: getDefaultValue(),
|
|
141
139
|
defaultChecked: getDefaultChecked(),
|
|
142
140
|
onChange: (event) => {
|
|
@@ -8,7 +8,6 @@ type Props<TInputElement, TState> = Omit<StoreInputProps<TInputElement, TState>,
|
|
|
8
8
|
declare function useStoreInputWithName<TInputElement extends HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, TState>(store: Store<TState>, props: Props<TInputElement, TState>): {
|
|
9
9
|
name: string | undefined;
|
|
10
10
|
ref: React.RefObject<TInputElement | null>;
|
|
11
|
-
dispatchKey: string;
|
|
12
11
|
defaultValue: string | number | readonly string[] | undefined;
|
|
13
12
|
defaultChecked: boolean | undefined;
|
|
14
13
|
onChange: (event: React.ChangeEvent<TInputElement>) => void;
|
|
@@ -8,7 +8,6 @@ type Props<TInputElement, TState> = Omit<StoreInputProps<TInputElement, TState>,
|
|
|
8
8
|
declare function useStoreInputWithName<TInputElement extends HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, TState>(store: Store<TState>, props: Props<TInputElement, TState>): {
|
|
9
9
|
name: string | undefined;
|
|
10
10
|
ref: React.RefObject<TInputElement | null>;
|
|
11
|
-
dispatchKey: string;
|
|
12
11
|
defaultValue: string | number | readonly string[] | undefined;
|
|
13
12
|
defaultChecked: boolean | undefined;
|
|
14
13
|
onChange: (event: React.ChangeEvent<TInputElement>) => void;
|
|
@@ -77,7 +77,6 @@ function useStoreController(store, props) {
|
|
|
77
77
|
);
|
|
78
78
|
};
|
|
79
79
|
return {
|
|
80
|
-
dispatchKey,
|
|
81
80
|
ref,
|
|
82
81
|
onChange
|
|
83
82
|
};
|
|
@@ -162,7 +161,6 @@ function useStoreInput(store, props) {
|
|
|
162
161
|
});
|
|
163
162
|
return {
|
|
164
163
|
ref: inputProps.ref,
|
|
165
|
-
dispatchKey: inputProps.dispatchKey,
|
|
166
164
|
defaultValue: getDefaultValue(),
|
|
167
165
|
defaultChecked: getDefaultChecked(),
|
|
168
166
|
onChange: (event) => {
|
|
@@ -51,7 +51,6 @@ function useStoreController(store, props) {
|
|
|
51
51
|
);
|
|
52
52
|
};
|
|
53
53
|
return {
|
|
54
|
-
dispatchKey,
|
|
55
54
|
ref,
|
|
56
55
|
onChange
|
|
57
56
|
};
|
|
@@ -136,7 +135,6 @@ function useStoreInput(store, props) {
|
|
|
136
135
|
});
|
|
137
136
|
return {
|
|
138
137
|
ref: inputProps.ref,
|
|
139
|
-
dispatchKey: inputProps.dispatchKey,
|
|
140
138
|
defaultValue: getDefaultValue(),
|
|
141
139
|
defaultChecked: getDefaultChecked(),
|
|
142
140
|
onChange: (event) => {
|