react-store-input 0.1.4 → 0.1.6

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.
@@ -130,18 +130,8 @@ var import_date_fns = require("date-fns");
130
130
  var import_react5 = require("react");
131
131
  function useStoreController(store, props) {
132
132
  const ref = (0, import_react5.useRef)(null);
133
+ (0, import_react5.useImperativeHandle)(props.ref, () => ref.current, []);
133
134
  const dispatchKey = (0, import_react5.useId)();
134
- (0, import_react5.useEffect)(() => {
135
- const element = ref.current;
136
- if (!element) {
137
- return;
138
- }
139
- if (typeof props.ref === "function") {
140
- props.ref(element);
141
- } else if (props.ref) {
142
- props.ref.current = element;
143
- }
144
- }, []);
145
135
  useSubscribe(store, (state, key) => {
146
136
  if (key === dispatchKey) {
147
137
  return;
@@ -149,7 +139,7 @@ function useStoreController(store, props) {
149
139
  if (!ref.current) return;
150
140
  props.onSubscribe(state, ref.current);
151
141
  });
152
- const onChange = () => {
142
+ const dispatch = () => {
153
143
  store.dispatch(
154
144
  (state) => {
155
145
  const element = ref.current;
@@ -163,26 +153,24 @@ function useStoreController(store, props) {
163
153
  };
164
154
  return {
165
155
  ref,
166
- onChange
156
+ dispatch
167
157
  };
168
158
  }
169
159
 
170
160
  // src/use_store_input.tsx
171
161
  function useStoreInput(store, props) {
172
- const toInputValue = (value) => {
162
+ const toInputValue = props.toInputValue || ((value) => {
173
163
  if (value === void 0 || value === null) {
174
164
  return "";
175
165
  }
176
166
  if (props.type === "datetime-local") {
177
- if (value instanceof Date) {
178
- return (0, import_date_fns.format)(value, "yyyy-MM-dd'T'HH:mm:ss");
179
- }
180
- if (typeof value === "string") {
181
- return toInputValue(new Date(value));
167
+ const date = new Date(value);
168
+ if (!isNaN(date.getTime())) {
169
+ return (0, import_date_fns.format)(date, "yyyy-MM-dd'T'HH:mm:ss");
182
170
  }
183
171
  }
184
172
  return String(value);
185
- };
173
+ });
186
174
  const getDefaultValue = () => {
187
175
  if (props.defaultValue !== void 0) {
188
176
  return props.defaultValue;
@@ -207,16 +195,15 @@ function useStoreInput(store, props) {
207
195
  }
208
196
  return toInputChecked(props.getter(store.state));
209
197
  };
210
- function toStateValue(value) {
211
- const selected = props.getter(store.state);
212
- if (typeof selected === "number") {
198
+ const toStateValue = props.toStateValue || ((value) => {
199
+ if (props.type === "number" || props.type === "range") {
213
200
  return Number(value);
214
201
  }
215
- if (selected instanceof Date) {
202
+ if (props.type === "datetime-local") {
216
203
  return new Date(value);
217
204
  }
218
205
  return value;
219
- }
206
+ });
220
207
  const inputProps = useStoreController(store, {
221
208
  ref: props.ref,
222
209
  onSubscribe: (state, element) => {
@@ -249,7 +236,7 @@ function useStoreInput(store, props) {
249
236
  defaultValue: getDefaultValue(),
250
237
  defaultChecked: getDefaultChecked(),
251
238
  onChange: (event) => {
252
- inputProps.onChange();
239
+ inputProps.dispatch();
253
240
  props.onChange?.(event);
254
241
  }
255
242
  };
@@ -281,15 +268,24 @@ function useStoreInputWithName(store, props) {
281
268
 
282
269
  // src/use_store_component.tsx
283
270
  function useStoreComponent(store) {
284
- const input = (0, import_react7.useCallback)(function Component(props) {
285
- return /* @__PURE__ */ import_react8.default.createElement(Input, { store, ...props });
286
- }, []);
287
- const select = (0, import_react7.useCallback)(function Component(props) {
288
- return /* @__PURE__ */ import_react8.default.createElement(Select, { store, ...props });
289
- }, []);
290
- const textarea = (0, import_react7.useCallback)(function Component(props) {
291
- return /* @__PURE__ */ import_react8.default.createElement(Textarea, { store, ...props });
292
- }, []);
271
+ const input = (0, import_react7.useCallback)(
272
+ function Component(props) {
273
+ return /* @__PURE__ */ import_react8.default.createElement(Input, { store, ...props });
274
+ },
275
+ []
276
+ );
277
+ const select = (0, import_react7.useCallback)(
278
+ function Component(props) {
279
+ return /* @__PURE__ */ import_react8.default.createElement(Select, { store, ...props });
280
+ },
281
+ []
282
+ );
283
+ const textarea = (0, import_react7.useCallback)(
284
+ function Component(props) {
285
+ return /* @__PURE__ */ import_react8.default.createElement(Textarea, { store, ...props });
286
+ },
287
+ []
288
+ );
293
289
  return {
294
290
  input,
295
291
  select,
@@ -300,27 +296,51 @@ function Input({
300
296
  store,
301
297
  getter,
302
298
  setter,
299
+ toInputValue,
300
+ toStateValue,
303
301
  ...props
304
302
  }) {
305
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
303
+ const storeProps = useStoreInputWithName(store, {
304
+ ...props,
305
+ getter,
306
+ setter,
307
+ toInputValue,
308
+ toStateValue
309
+ });
306
310
  return /* @__PURE__ */ import_react8.default.createElement("input", { ...props, ...storeProps });
307
311
  }
308
312
  function Select({
309
313
  store,
310
314
  getter,
311
315
  setter,
316
+ toInputValue,
317
+ toStateValue,
312
318
  ...props
313
319
  }) {
314
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
320
+ const storeProps = useStoreInputWithName(store, {
321
+ ...props,
322
+ getter,
323
+ setter,
324
+ toInputValue,
325
+ toStateValue
326
+ });
315
327
  return /* @__PURE__ */ import_react8.default.createElement("select", { ...props, ...storeProps });
316
328
  }
317
329
  function Textarea({
318
330
  store,
319
331
  getter,
320
332
  setter,
333
+ toInputValue,
334
+ toStateValue,
321
335
  ...props
322
336
  }) {
323
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
337
+ const storeProps = useStoreInputWithName(store, {
338
+ ...props,
339
+ getter,
340
+ setter,
341
+ toInputValue,
342
+ toStateValue
343
+ });
324
344
  return /* @__PURE__ */ import_react8.default.createElement("textarea", { ...props, ...storeProps });
325
345
  }
326
346
 
@@ -83,9 +83,7 @@ function useStore(initialState) {
83
83
  }
84
84
 
85
85
  // src/use_store_component.tsx
86
- import {
87
- useCallback
88
- } from "react";
86
+ import { useCallback } from "react";
89
87
  import React2 from "react";
90
88
 
91
89
  // src/use_store_input.tsx
@@ -93,21 +91,11 @@ import "react";
93
91
  import { format } from "date-fns";
94
92
 
95
93
  // src/use_store_controller.tsx
96
- import { useEffect as useEffect2, useId, useRef as useRef2 } from "react";
94
+ import { useId, useImperativeHandle, useRef as useRef2 } from "react";
97
95
  function useStoreController(store, props) {
98
96
  const ref = useRef2(null);
97
+ useImperativeHandle(props.ref, () => ref.current, []);
99
98
  const dispatchKey = useId();
100
- useEffect2(() => {
101
- const element = ref.current;
102
- if (!element) {
103
- return;
104
- }
105
- if (typeof props.ref === "function") {
106
- props.ref(element);
107
- } else if (props.ref) {
108
- props.ref.current = element;
109
- }
110
- }, []);
111
99
  useSubscribe(store, (state, key) => {
112
100
  if (key === dispatchKey) {
113
101
  return;
@@ -115,7 +103,7 @@ function useStoreController(store, props) {
115
103
  if (!ref.current) return;
116
104
  props.onSubscribe(state, ref.current);
117
105
  });
118
- const onChange = () => {
106
+ const dispatch = () => {
119
107
  store.dispatch(
120
108
  (state) => {
121
109
  const element = ref.current;
@@ -129,26 +117,24 @@ function useStoreController(store, props) {
129
117
  };
130
118
  return {
131
119
  ref,
132
- onChange
120
+ dispatch
133
121
  };
134
122
  }
135
123
 
136
124
  // src/use_store_input.tsx
137
125
  function useStoreInput(store, props) {
138
- const toInputValue = (value) => {
126
+ const toInputValue = props.toInputValue || ((value) => {
139
127
  if (value === void 0 || value === null) {
140
128
  return "";
141
129
  }
142
130
  if (props.type === "datetime-local") {
143
- if (value instanceof Date) {
144
- return format(value, "yyyy-MM-dd'T'HH:mm:ss");
145
- }
146
- if (typeof value === "string") {
147
- return toInputValue(new Date(value));
131
+ const date = new Date(value);
132
+ if (!isNaN(date.getTime())) {
133
+ return format(date, "yyyy-MM-dd'T'HH:mm:ss");
148
134
  }
149
135
  }
150
136
  return String(value);
151
- };
137
+ });
152
138
  const getDefaultValue = () => {
153
139
  if (props.defaultValue !== void 0) {
154
140
  return props.defaultValue;
@@ -173,16 +159,15 @@ function useStoreInput(store, props) {
173
159
  }
174
160
  return toInputChecked(props.getter(store.state));
175
161
  };
176
- function toStateValue(value) {
177
- const selected = props.getter(store.state);
178
- if (typeof selected === "number") {
162
+ const toStateValue = props.toStateValue || ((value) => {
163
+ if (props.type === "number" || props.type === "range") {
179
164
  return Number(value);
180
165
  }
181
- if (selected instanceof Date) {
166
+ if (props.type === "datetime-local") {
182
167
  return new Date(value);
183
168
  }
184
169
  return value;
185
- }
170
+ });
186
171
  const inputProps = useStoreController(store, {
187
172
  ref: props.ref,
188
173
  onSubscribe: (state, element) => {
@@ -215,7 +200,7 @@ function useStoreInput(store, props) {
215
200
  defaultValue: getDefaultValue(),
216
201
  defaultChecked: getDefaultChecked(),
217
202
  onChange: (event) => {
218
- inputProps.onChange();
203
+ inputProps.dispatch();
219
204
  props.onChange?.(event);
220
205
  }
221
206
  };
@@ -247,15 +232,24 @@ function useStoreInputWithName(store, props) {
247
232
 
248
233
  // src/use_store_component.tsx
249
234
  function useStoreComponent(store) {
250
- const input = useCallback(function Component(props) {
251
- return /* @__PURE__ */ React2.createElement(Input, { store, ...props });
252
- }, []);
253
- const select = useCallback(function Component(props) {
254
- return /* @__PURE__ */ React2.createElement(Select, { store, ...props });
255
- }, []);
256
- const textarea = useCallback(function Component(props) {
257
- return /* @__PURE__ */ React2.createElement(Textarea, { store, ...props });
258
- }, []);
235
+ const input = useCallback(
236
+ function Component(props) {
237
+ return /* @__PURE__ */ React2.createElement(Input, { store, ...props });
238
+ },
239
+ []
240
+ );
241
+ const select = useCallback(
242
+ function Component(props) {
243
+ return /* @__PURE__ */ React2.createElement(Select, { store, ...props });
244
+ },
245
+ []
246
+ );
247
+ const textarea = useCallback(
248
+ function Component(props) {
249
+ return /* @__PURE__ */ React2.createElement(Textarea, { store, ...props });
250
+ },
251
+ []
252
+ );
259
253
  return {
260
254
  input,
261
255
  select,
@@ -266,27 +260,51 @@ function Input({
266
260
  store,
267
261
  getter,
268
262
  setter,
263
+ toInputValue,
264
+ toStateValue,
269
265
  ...props
270
266
  }) {
271
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
267
+ const storeProps = useStoreInputWithName(store, {
268
+ ...props,
269
+ getter,
270
+ setter,
271
+ toInputValue,
272
+ toStateValue
273
+ });
272
274
  return /* @__PURE__ */ React2.createElement("input", { ...props, ...storeProps });
273
275
  }
274
276
  function Select({
275
277
  store,
276
278
  getter,
277
279
  setter,
280
+ toInputValue,
281
+ toStateValue,
278
282
  ...props
279
283
  }) {
280
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
284
+ const storeProps = useStoreInputWithName(store, {
285
+ ...props,
286
+ getter,
287
+ setter,
288
+ toInputValue,
289
+ toStateValue
290
+ });
281
291
  return /* @__PURE__ */ React2.createElement("select", { ...props, ...storeProps });
282
292
  }
283
293
  function Textarea({
284
294
  store,
285
295
  getter,
286
296
  setter,
297
+ toInputValue,
298
+ toStateValue,
287
299
  ...props
288
300
  }) {
289
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
301
+ const storeProps = useStoreInputWithName(store, {
302
+ ...props,
303
+ getter,
304
+ setter,
305
+ toInputValue,
306
+ toStateValue
307
+ });
290
308
  return /* @__PURE__ */ React2.createElement("textarea", { ...props, ...storeProps });
291
309
  }
292
310
 
@@ -1,21 +1,18 @@
1
- import React__default, { DetailedHTMLProps, InputHTMLAttributes } from 'react';
2
1
  import { Store } from './use_store.mjs';
2
+ import React__default from 'react';
3
+ import { StoreInputWithNameProps } from './use_store_input_with_name.mjs';
4
+ import './use_store_input.mjs';
3
5
 
4
- type StoreComponentProps<TInputElement, TState> = Omit<DetailedHTMLProps<InputHTMLAttributes<TInputElement>, TInputElement>, "name"> & {
5
- name?: keyof TState;
6
- getter?: (state: TState) => unknown;
7
- setter?: (state: TState, value: unknown) => void;
8
- };
9
6
  declare function useStoreComponent<TState>(store: Store<TState>): {
10
- input: React__default.FC<StoreComponentProps<HTMLInputElement, TState>>;
11
- select: React__default.FC<StoreComponentProps<HTMLSelectElement, TState>>;
12
- textarea: React__default.FC<StoreComponentProps<HTMLTextAreaElement, TState>>;
7
+ input: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameProps<HTMLInputElement, TState, TName, TValue>) => React__default.JSX.Element;
8
+ select: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameProps<HTMLSelectElement, TState, TName, TValue>) => React__default.JSX.Element;
9
+ textarea: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameProps<HTMLTextAreaElement, TState, TName, TValue>) => React__default.JSX.Element;
13
10
  };
14
- type StoreComponentPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState> = StoreComponentProps<TElement, TState> & {
11
+ type StoreComponentPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState, TName extends keyof TState | undefined, TValue> = StoreInputWithNameProps<TElement, TState, TName, TValue> & {
15
12
  store: Store<TState>;
16
13
  };
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;
14
+ declare function Input<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState, TName, TValue>): React__default.JSX.Element;
15
+ declare function Select<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState, TName, TValue>): React__default.JSX.Element;
16
+ declare function Textarea<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState, TName, TValue>): React__default.JSX.Element;
20
17
 
21
- export { Input, Select, type StoreComponentProps, type StoreComponentPropsWithStore, Textarea, useStoreComponent };
18
+ export { Input, Select, type StoreComponentPropsWithStore, Textarea, useStoreComponent };
@@ -1,21 +1,18 @@
1
- import React__default, { DetailedHTMLProps, InputHTMLAttributes } from 'react';
2
1
  import { Store } from './use_store.js';
2
+ import React__default from 'react';
3
+ import { StoreInputWithNameProps } from './use_store_input_with_name.js';
4
+ import './use_store_input.js';
3
5
 
4
- type StoreComponentProps<TInputElement, TState> = Omit<DetailedHTMLProps<InputHTMLAttributes<TInputElement>, TInputElement>, "name"> & {
5
- name?: keyof TState;
6
- getter?: (state: TState) => unknown;
7
- setter?: (state: TState, value: unknown) => void;
8
- };
9
6
  declare function useStoreComponent<TState>(store: Store<TState>): {
10
- input: React__default.FC<StoreComponentProps<HTMLInputElement, TState>>;
11
- select: React__default.FC<StoreComponentProps<HTMLSelectElement, TState>>;
12
- textarea: React__default.FC<StoreComponentProps<HTMLTextAreaElement, TState>>;
7
+ input: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameProps<HTMLInputElement, TState, TName, TValue>) => React__default.JSX.Element;
8
+ select: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameProps<HTMLSelectElement, TState, TName, TValue>) => React__default.JSX.Element;
9
+ textarea: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameProps<HTMLTextAreaElement, TState, TName, TValue>) => React__default.JSX.Element;
13
10
  };
14
- type StoreComponentPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState> = StoreComponentProps<TElement, TState> & {
11
+ type StoreComponentPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState, TName extends keyof TState | undefined, TValue> = StoreInputWithNameProps<TElement, TState, TName, TValue> & {
15
12
  store: Store<TState>;
16
13
  };
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;
14
+ declare function Input<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState, TName, TValue>): React__default.JSX.Element;
15
+ declare function Select<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState, TName, TValue>): React__default.JSX.Element;
16
+ declare function Textarea<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState, TName, TValue>): React__default.JSX.Element;
20
17
 
21
- export { Input, Select, type StoreComponentProps, type StoreComponentPropsWithStore, Textarea, useStoreComponent };
18
+ export { Input, Select, type StoreComponentPropsWithStore, Textarea, useStoreComponent };
@@ -60,18 +60,8 @@ function useSubscribe(store, subscriber) {
60
60
  // src/use_store_controller.tsx
61
61
  function useStoreController(store, props) {
62
62
  const ref = (0, import_react2.useRef)(null);
63
+ (0, import_react2.useImperativeHandle)(props.ref, () => ref.current, []);
63
64
  const dispatchKey = (0, import_react2.useId)();
64
- (0, import_react2.useEffect)(() => {
65
- const element = ref.current;
66
- if (!element) {
67
- return;
68
- }
69
- if (typeof props.ref === "function") {
70
- props.ref(element);
71
- } else if (props.ref) {
72
- props.ref.current = element;
73
- }
74
- }, []);
75
65
  useSubscribe(store, (state, key) => {
76
66
  if (key === dispatchKey) {
77
67
  return;
@@ -79,7 +69,7 @@ function useStoreController(store, props) {
79
69
  if (!ref.current) return;
80
70
  props.onSubscribe(state, ref.current);
81
71
  });
82
- const onChange = () => {
72
+ const dispatch = () => {
83
73
  store.dispatch(
84
74
  (state) => {
85
75
  const element = ref.current;
@@ -93,26 +83,24 @@ function useStoreController(store, props) {
93
83
  };
94
84
  return {
95
85
  ref,
96
- onChange
86
+ dispatch
97
87
  };
98
88
  }
99
89
 
100
90
  // src/use_store_input.tsx
101
91
  function useStoreInput(store, props) {
102
- const toInputValue = (value) => {
92
+ const toInputValue = props.toInputValue || ((value) => {
103
93
  if (value === void 0 || value === null) {
104
94
  return "";
105
95
  }
106
96
  if (props.type === "datetime-local") {
107
- if (value instanceof Date) {
108
- return (0, import_date_fns.format)(value, "yyyy-MM-dd'T'HH:mm:ss");
109
- }
110
- if (typeof value === "string") {
111
- return toInputValue(new Date(value));
97
+ const date = new Date(value);
98
+ if (!isNaN(date.getTime())) {
99
+ return (0, import_date_fns.format)(date, "yyyy-MM-dd'T'HH:mm:ss");
112
100
  }
113
101
  }
114
102
  return String(value);
115
- };
103
+ });
116
104
  const getDefaultValue = () => {
117
105
  if (props.defaultValue !== void 0) {
118
106
  return props.defaultValue;
@@ -137,16 +125,15 @@ function useStoreInput(store, props) {
137
125
  }
138
126
  return toInputChecked(props.getter(store.state));
139
127
  };
140
- function toStateValue(value) {
141
- const selected = props.getter(store.state);
142
- if (typeof selected === "number") {
128
+ const toStateValue = props.toStateValue || ((value) => {
129
+ if (props.type === "number" || props.type === "range") {
143
130
  return Number(value);
144
131
  }
145
- if (selected instanceof Date) {
132
+ if (props.type === "datetime-local") {
146
133
  return new Date(value);
147
134
  }
148
135
  return value;
149
- }
136
+ });
150
137
  const inputProps = useStoreController(store, {
151
138
  ref: props.ref,
152
139
  onSubscribe: (state, element) => {
@@ -179,7 +166,7 @@ function useStoreInput(store, props) {
179
166
  defaultValue: getDefaultValue(),
180
167
  defaultChecked: getDefaultChecked(),
181
168
  onChange: (event) => {
182
- inputProps.onChange();
169
+ inputProps.dispatch();
183
170
  props.onChange?.(event);
184
171
  }
185
172
  };
@@ -211,15 +198,24 @@ function useStoreInputWithName(store, props) {
211
198
 
212
199
  // src/use_store_component.tsx
213
200
  function useStoreComponent(store) {
214
- const input = (0, import_react4.useCallback)(function Component(props) {
215
- return /* @__PURE__ */ import_react5.default.createElement(Input, { store, ...props });
216
- }, []);
217
- const select = (0, import_react4.useCallback)(function Component(props) {
218
- return /* @__PURE__ */ import_react5.default.createElement(Select, { store, ...props });
219
- }, []);
220
- const textarea = (0, import_react4.useCallback)(function Component(props) {
221
- return /* @__PURE__ */ import_react5.default.createElement(Textarea, { store, ...props });
222
- }, []);
201
+ const input = (0, import_react4.useCallback)(
202
+ function Component(props) {
203
+ return /* @__PURE__ */ import_react5.default.createElement(Input, { store, ...props });
204
+ },
205
+ []
206
+ );
207
+ const select = (0, import_react4.useCallback)(
208
+ function Component(props) {
209
+ return /* @__PURE__ */ import_react5.default.createElement(Select, { store, ...props });
210
+ },
211
+ []
212
+ );
213
+ const textarea = (0, import_react4.useCallback)(
214
+ function Component(props) {
215
+ return /* @__PURE__ */ import_react5.default.createElement(Textarea, { store, ...props });
216
+ },
217
+ []
218
+ );
223
219
  return {
224
220
  input,
225
221
  select,
@@ -230,27 +226,51 @@ function Input({
230
226
  store,
231
227
  getter,
232
228
  setter,
229
+ toInputValue,
230
+ toStateValue,
233
231
  ...props
234
232
  }) {
235
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
233
+ const storeProps = useStoreInputWithName(store, {
234
+ ...props,
235
+ getter,
236
+ setter,
237
+ toInputValue,
238
+ toStateValue
239
+ });
236
240
  return /* @__PURE__ */ import_react5.default.createElement("input", { ...props, ...storeProps });
237
241
  }
238
242
  function Select({
239
243
  store,
240
244
  getter,
241
245
  setter,
246
+ toInputValue,
247
+ toStateValue,
242
248
  ...props
243
249
  }) {
244
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
250
+ const storeProps = useStoreInputWithName(store, {
251
+ ...props,
252
+ getter,
253
+ setter,
254
+ toInputValue,
255
+ toStateValue
256
+ });
245
257
  return /* @__PURE__ */ import_react5.default.createElement("select", { ...props, ...storeProps });
246
258
  }
247
259
  function Textarea({
248
260
  store,
249
261
  getter,
250
262
  setter,
263
+ toInputValue,
264
+ toStateValue,
251
265
  ...props
252
266
  }) {
253
- const storeProps = useStoreInputWithName(store, { ...props, getter, setter });
267
+ const storeProps = useStoreInputWithName(store, {
268
+ ...props,
269
+ getter,
270
+ setter,
271
+ toInputValue,
272
+ toStateValue
273
+ });
254
274
  return /* @__PURE__ */ import_react5.default.createElement("textarea", { ...props, ...storeProps });
255
275
  }
256
276
  // Annotate the CommonJS export names for ESM import in node: