react-store-input 0.2.6 → 0.4.0
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/CHANGELOG.md +114 -0
- package/README.md +179 -201
- package/dist/index.d.mts +127 -10
- package/dist/index.d.ts +127 -10
- package/dist/index.js +554 -249
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +549 -247
- package/dist/index.mjs.map +1 -0
- package/dist/text-editor.d.mts +11 -0
- package/dist/text-editor.d.ts +11 -0
- package/dist/{text_editor.js → text-editor.js} +31 -51
- package/dist/text-editor.js.map +1 -0
- package/dist/text-editor.mjs +90 -0
- package/dist/text-editor.mjs.map +1 -0
- package/package.json +78 -18
- package/dist/create_render.d.mts +0 -9
- package/dist/create_render.d.ts +0 -9
- package/dist/create_render.js +0 -51
- package/dist/create_render.mjs +0 -25
- package/dist/text_editor.d.mts +0 -13
- package/dist/text_editor.d.ts +0 -13
- package/dist/text_editor.mjs +0 -112
- package/dist/use_form_store.d.mts +0 -16
- package/dist/use_form_store.d.ts +0 -16
- package/dist/use_form_store.js +0 -365
- package/dist/use_form_store.mjs +0 -340
- package/dist/use_store_component.d.mts +0 -23
- package/dist/use_store_component.d.ts +0 -23
- package/dist/use_store_component.js +0 -337
- package/dist/use_store_component.mjs +0 -311
- package/dist/use_store_controller.d.mts +0 -11
- package/dist/use_store_controller.d.ts +0 -11
- package/dist/use_store_controller.js +0 -57
- package/dist/use_store_controller.mjs +0 -32
- package/dist/use_store_input.d.mts +0 -22
- package/dist/use_store_input.d.ts +0 -22
- package/dist/use_store_input.js +0 -151
- package/dist/use_store_input.mjs +0 -126
- package/dist/use_store_input_with_name.d.mts +0 -17
- package/dist/use_store_input_with_name.d.ts +0 -17
- package/dist/use_store_input_with_name.js +0 -177
- package/dist/use_store_input_with_name.mjs +0 -150
- package/tsup.config.ts +0 -9
package/dist/text_editor.mjs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// src/text_editor.tsx
|
|
2
|
-
import {
|
|
3
|
-
TextEditor as GwTextEditor
|
|
4
|
-
} from "gw-react-text-editor";
|
|
5
|
-
import { useImperativeHandle, useRef } from "react";
|
|
6
|
-
|
|
7
|
-
// src/use_store_controller.tsx
|
|
8
|
-
import { useEffect, useId } from "react";
|
|
9
|
-
function useStoreController(store, props) {
|
|
10
|
-
const dispatchKey = useId();
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const unsub = store.subscribe((state, key) => {
|
|
13
|
-
if (key === dispatchKey) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
props.onSubscribe(state);
|
|
17
|
-
});
|
|
18
|
-
return () => {
|
|
19
|
-
unsub();
|
|
20
|
-
};
|
|
21
|
-
}, []);
|
|
22
|
-
const dispatch = () => {
|
|
23
|
-
store.dispatch(
|
|
24
|
-
(state) => {
|
|
25
|
-
props.onDispatch(state);
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
key: dispatchKey
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
return {
|
|
33
|
-
dispatch
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// src/text_editor.tsx
|
|
38
|
-
import { jsx } from "react/jsx-runtime";
|
|
39
|
-
function TextEditor({
|
|
40
|
-
store,
|
|
41
|
-
name,
|
|
42
|
-
getter,
|
|
43
|
-
setter,
|
|
44
|
-
defaultValue,
|
|
45
|
-
ref,
|
|
46
|
-
...props
|
|
47
|
-
}) {
|
|
48
|
-
const controllerRef = useRef(null);
|
|
49
|
-
useImperativeHandle(
|
|
50
|
-
ref,
|
|
51
|
-
() => controllerRef.current,
|
|
52
|
-
[]
|
|
53
|
-
);
|
|
54
|
-
const { dispatch } = useStoreController(store, {
|
|
55
|
-
onSubscribe: (state) => {
|
|
56
|
-
const controller = controllerRef.current;
|
|
57
|
-
if (!controller) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const getResult = () => {
|
|
61
|
-
if (getter) {
|
|
62
|
-
return getter(state) || "";
|
|
63
|
-
}
|
|
64
|
-
if (name) {
|
|
65
|
-
return state[name] || "";
|
|
66
|
-
}
|
|
67
|
-
return "";
|
|
68
|
-
};
|
|
69
|
-
const result = getResult();
|
|
70
|
-
if (controller.value !== result) {
|
|
71
|
-
controller.value = result;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
onDispatch: (state) => {
|
|
75
|
-
const controller = controllerRef.current;
|
|
76
|
-
if (!controller) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (setter) {
|
|
80
|
-
setter(state, controller.value);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (name) {
|
|
84
|
-
state[name] = controller.value;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
const getDefaultValue = () => {
|
|
89
|
-
if (getter) {
|
|
90
|
-
return getter(store.state);
|
|
91
|
-
}
|
|
92
|
-
if (name) {
|
|
93
|
-
return store.state[name];
|
|
94
|
-
}
|
|
95
|
-
return void 0;
|
|
96
|
-
};
|
|
97
|
-
return /* @__PURE__ */ jsx(
|
|
98
|
-
GwTextEditor,
|
|
99
|
-
{
|
|
100
|
-
...props,
|
|
101
|
-
ref: controllerRef,
|
|
102
|
-
defaultValue: defaultValue ?? getDefaultValue(),
|
|
103
|
-
onChange: (e) => {
|
|
104
|
-
dispatch();
|
|
105
|
-
props.onChange?.(e);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
export {
|
|
111
|
-
TextEditor
|
|
112
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CreateRender } from './create_render.mjs';
|
|
2
|
-
import { Store } from 'gw-store';
|
|
3
|
-
import { useStoreComponent } from './use_store_component.mjs';
|
|
4
|
-
import 'react/jsx-runtime';
|
|
5
|
-
import 'react';
|
|
6
|
-
import './use_store_input_with_name.mjs';
|
|
7
|
-
import './use_store_input.mjs';
|
|
8
|
-
import './text_editor.mjs';
|
|
9
|
-
import 'gw-react-text-editor';
|
|
10
|
-
|
|
11
|
-
type FormStore<TState> = Store<TState> & ReturnType<typeof useStoreComponent<TState>> & {
|
|
12
|
-
render: CreateRender<TState>;
|
|
13
|
-
};
|
|
14
|
-
declare function useFormStore<TState>(initialState: TState): FormStore<TState>;
|
|
15
|
-
|
|
16
|
-
export { type FormStore, useFormStore };
|
package/dist/use_form_store.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CreateRender } from './create_render.js';
|
|
2
|
-
import { Store } from 'gw-store';
|
|
3
|
-
import { useStoreComponent } from './use_store_component.js';
|
|
4
|
-
import 'react/jsx-runtime';
|
|
5
|
-
import 'react';
|
|
6
|
-
import './use_store_input_with_name.js';
|
|
7
|
-
import './use_store_input.js';
|
|
8
|
-
import './text_editor.js';
|
|
9
|
-
import 'gw-react-text-editor';
|
|
10
|
-
|
|
11
|
-
type FormStore<TState> = Store<TState> & ReturnType<typeof useStoreComponent<TState>> & {
|
|
12
|
-
render: CreateRender<TState>;
|
|
13
|
-
};
|
|
14
|
-
declare function useFormStore<TState>(initialState: TState): FormStore<TState>;
|
|
15
|
-
|
|
16
|
-
export { type FormStore, useFormStore };
|
package/dist/use_form_store.js
DELETED
|
@@ -1,365 +0,0 @@
|
|
|
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_form_store.tsx
|
|
21
|
-
var use_form_store_exports = {};
|
|
22
|
-
__export(use_form_store_exports, {
|
|
23
|
-
useFormStore: () => useFormStore
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(use_form_store_exports);
|
|
26
|
-
|
|
27
|
-
// src/create_render.tsx
|
|
28
|
-
var import_gw_store = require("gw-store");
|
|
29
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
|
-
function createRenderWithStore(store) {
|
|
31
|
-
return function createRender(selector, compare) {
|
|
32
|
-
function Component() {
|
|
33
|
-
const result = (0, import_gw_store.useSelector)(store, (state) => state, compare);
|
|
34
|
-
const content = selector(result);
|
|
35
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content });
|
|
36
|
-
}
|
|
37
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/use_form_store.tsx
|
|
42
|
-
var import_gw_store2 = require("gw-store");
|
|
43
|
-
|
|
44
|
-
// src/use_store_component.tsx
|
|
45
|
-
var import_react3 = require("react");
|
|
46
|
-
|
|
47
|
-
// src/use_store_input.tsx
|
|
48
|
-
var import_date_fns = require("date-fns");
|
|
49
|
-
|
|
50
|
-
// src/use_store_controller.tsx
|
|
51
|
-
var import_react = require("react");
|
|
52
|
-
function useStoreController(store, props) {
|
|
53
|
-
const dispatchKey = (0, import_react.useId)();
|
|
54
|
-
(0, import_react.useEffect)(() => {
|
|
55
|
-
const unsub = store.subscribe((state, key) => {
|
|
56
|
-
if (key === dispatchKey) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
props.onSubscribe(state);
|
|
60
|
-
});
|
|
61
|
-
return () => {
|
|
62
|
-
unsub();
|
|
63
|
-
};
|
|
64
|
-
}, []);
|
|
65
|
-
const dispatch = () => {
|
|
66
|
-
store.dispatch(
|
|
67
|
-
(state) => {
|
|
68
|
-
props.onDispatch(state);
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
key: dispatchKey
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
return {
|
|
76
|
-
dispatch
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// src/use_store_input.tsx
|
|
81
|
-
function useStoreInput(ref, store, props) {
|
|
82
|
-
const toInputValue = props.toInputValue || ((value) => {
|
|
83
|
-
if (value === void 0 || value === null) {
|
|
84
|
-
return "";
|
|
85
|
-
}
|
|
86
|
-
if (props.type === "datetime-local") {
|
|
87
|
-
const date = new Date(value);
|
|
88
|
-
if (!isNaN(date.getTime())) {
|
|
89
|
-
return (0, import_date_fns.format)(date, "yyyy-MM-dd'T'HH:mm:ss");
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return String(value);
|
|
93
|
-
});
|
|
94
|
-
const getDefaultValue = () => {
|
|
95
|
-
if (props.defaultValue !== void 0) {
|
|
96
|
-
return props.defaultValue;
|
|
97
|
-
}
|
|
98
|
-
if (props.type === "checkbox" || props.type === "radio") {
|
|
99
|
-
return void 0;
|
|
100
|
-
}
|
|
101
|
-
return toInputValue(props.getter(store.state));
|
|
102
|
-
};
|
|
103
|
-
const toInputChecked = (value) => {
|
|
104
|
-
if (props.type === "radio") {
|
|
105
|
-
return value !== void 0 && value === props.value;
|
|
106
|
-
}
|
|
107
|
-
return Boolean(value);
|
|
108
|
-
};
|
|
109
|
-
const getDefaultChecked = () => {
|
|
110
|
-
if (props.defaultChecked) {
|
|
111
|
-
return props.defaultChecked;
|
|
112
|
-
}
|
|
113
|
-
if (props.type !== "checkbox" && props.type !== "radio") {
|
|
114
|
-
return void 0;
|
|
115
|
-
}
|
|
116
|
-
return toInputChecked(props.getter(store.state));
|
|
117
|
-
};
|
|
118
|
-
const toStateValue = props.toStateValue || ((value) => {
|
|
119
|
-
if (props.type === "number" || props.type === "range") {
|
|
120
|
-
return Number(value);
|
|
121
|
-
}
|
|
122
|
-
if (props.type === "datetime-local") {
|
|
123
|
-
return new Date(value);
|
|
124
|
-
}
|
|
125
|
-
return value;
|
|
126
|
-
});
|
|
127
|
-
const inputProps = useStoreController(store, {
|
|
128
|
-
onSubscribe: (state) => {
|
|
129
|
-
const element = ref.current;
|
|
130
|
-
if (!element) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if ("checked" in element && (props.type === "checkbox" || props.type === "radio")) {
|
|
134
|
-
const checked = toInputChecked(props.getter(state));
|
|
135
|
-
if (element.checked === checked) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
element.checked = checked;
|
|
139
|
-
} else {
|
|
140
|
-
const value = toInputValue(props.getter(state));
|
|
141
|
-
if (element.value === value) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
element.value = value;
|
|
145
|
-
}
|
|
146
|
-
const event = new Event("input", { bubbles: true });
|
|
147
|
-
element.dispatchEvent(event);
|
|
148
|
-
},
|
|
149
|
-
onDispatch: (state) => {
|
|
150
|
-
const element = ref.current;
|
|
151
|
-
if (!element) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if ("checked" in element && props.type === "checkbox") {
|
|
155
|
-
props.setter(state, element.checked);
|
|
156
|
-
} else {
|
|
157
|
-
props.setter(state, toStateValue(element.value));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
return {
|
|
162
|
-
defaultValue: getDefaultValue(),
|
|
163
|
-
defaultChecked: getDefaultChecked(),
|
|
164
|
-
onChange: (event) => {
|
|
165
|
-
inputProps.dispatch();
|
|
166
|
-
props.onChange?.(event);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// src/use_store_input_with_name.tsx
|
|
172
|
-
function useStoreInputWithName(ref, store, props) {
|
|
173
|
-
const inputProps = useStoreInput(ref, store, {
|
|
174
|
-
...props,
|
|
175
|
-
getter: (state) => {
|
|
176
|
-
if (props.getter) {
|
|
177
|
-
return props.getter(state);
|
|
178
|
-
}
|
|
179
|
-
return state[props.name];
|
|
180
|
-
},
|
|
181
|
-
setter: (state, value) => {
|
|
182
|
-
if (props.setter) {
|
|
183
|
-
props.setter(state, value);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
state[props.name] = value;
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
return {
|
|
190
|
-
...inputProps,
|
|
191
|
-
name: "name" in props ? String(props.name) : void 0
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// src/text_editor.tsx
|
|
196
|
-
var import_gw_react_text_editor = require("gw-react-text-editor");
|
|
197
|
-
var import_react2 = require("react");
|
|
198
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
199
|
-
function TextEditor({
|
|
200
|
-
store,
|
|
201
|
-
name,
|
|
202
|
-
getter,
|
|
203
|
-
setter,
|
|
204
|
-
defaultValue,
|
|
205
|
-
ref,
|
|
206
|
-
...props
|
|
207
|
-
}) {
|
|
208
|
-
const controllerRef = (0, import_react2.useRef)(null);
|
|
209
|
-
(0, import_react2.useImperativeHandle)(
|
|
210
|
-
ref,
|
|
211
|
-
() => controllerRef.current,
|
|
212
|
-
[]
|
|
213
|
-
);
|
|
214
|
-
const { dispatch } = useStoreController(store, {
|
|
215
|
-
onSubscribe: (state) => {
|
|
216
|
-
const controller = controllerRef.current;
|
|
217
|
-
if (!controller) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
const getResult = () => {
|
|
221
|
-
if (getter) {
|
|
222
|
-
return getter(state) || "";
|
|
223
|
-
}
|
|
224
|
-
if (name) {
|
|
225
|
-
return state[name] || "";
|
|
226
|
-
}
|
|
227
|
-
return "";
|
|
228
|
-
};
|
|
229
|
-
const result = getResult();
|
|
230
|
-
if (controller.value !== result) {
|
|
231
|
-
controller.value = result;
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
onDispatch: (state) => {
|
|
235
|
-
const controller = controllerRef.current;
|
|
236
|
-
if (!controller) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
if (setter) {
|
|
240
|
-
setter(state, controller.value);
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
if (name) {
|
|
244
|
-
state[name] = controller.value;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
const getDefaultValue = () => {
|
|
249
|
-
if (getter) {
|
|
250
|
-
return getter(store.state);
|
|
251
|
-
}
|
|
252
|
-
if (name) {
|
|
253
|
-
return store.state[name];
|
|
254
|
-
}
|
|
255
|
-
return void 0;
|
|
256
|
-
};
|
|
257
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
258
|
-
import_gw_react_text_editor.TextEditor,
|
|
259
|
-
{
|
|
260
|
-
...props,
|
|
261
|
-
ref: controllerRef,
|
|
262
|
-
defaultValue: defaultValue ?? getDefaultValue(),
|
|
263
|
-
onChange: (e) => {
|
|
264
|
-
dispatch();
|
|
265
|
-
props.onChange?.(e);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// src/use_store_component.tsx
|
|
272
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
273
|
-
function useStoreComponent(store) {
|
|
274
|
-
const input = (0, import_react3.useCallback)(function Component(props) {
|
|
275
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Input, { store, ...props });
|
|
276
|
-
}, []);
|
|
277
|
-
const select = (0, import_react3.useCallback)(function Component(props) {
|
|
278
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Select, { store, ...props });
|
|
279
|
-
}, []);
|
|
280
|
-
const textarea = (0, import_react3.useCallback)(function Component(props) {
|
|
281
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Textarea, { store, ...props });
|
|
282
|
-
}, []);
|
|
283
|
-
const textEditor = (0, import_react3.useCallback)(function Component(props) {
|
|
284
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TextEditor, { store, ...props });
|
|
285
|
-
}, []);
|
|
286
|
-
return {
|
|
287
|
-
input,
|
|
288
|
-
select,
|
|
289
|
-
textarea,
|
|
290
|
-
textEditor
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
function Input({
|
|
294
|
-
store,
|
|
295
|
-
getter,
|
|
296
|
-
setter,
|
|
297
|
-
toInputValue,
|
|
298
|
-
toStateValue,
|
|
299
|
-
...props
|
|
300
|
-
}) {
|
|
301
|
-
const ref = (0, import_react3.useRef)(null);
|
|
302
|
-
const storeProps = useStoreInputWithName(ref, store, {
|
|
303
|
-
...props,
|
|
304
|
-
getter,
|
|
305
|
-
setter,
|
|
306
|
-
toInputValue,
|
|
307
|
-
toStateValue
|
|
308
|
-
});
|
|
309
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { ref, ...props, ...storeProps });
|
|
310
|
-
}
|
|
311
|
-
function Select({
|
|
312
|
-
store,
|
|
313
|
-
getter,
|
|
314
|
-
setter,
|
|
315
|
-
toInputValue,
|
|
316
|
-
toStateValue,
|
|
317
|
-
...props
|
|
318
|
-
}) {
|
|
319
|
-
const ref = (0, import_react3.useRef)(null);
|
|
320
|
-
const storeProps = useStoreInputWithName(ref, store, {
|
|
321
|
-
...props,
|
|
322
|
-
getter,
|
|
323
|
-
setter,
|
|
324
|
-
toInputValue,
|
|
325
|
-
toStateValue
|
|
326
|
-
});
|
|
327
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("select", { ref, ...props, ...storeProps });
|
|
328
|
-
}
|
|
329
|
-
function Textarea({
|
|
330
|
-
store,
|
|
331
|
-
getter,
|
|
332
|
-
setter,
|
|
333
|
-
toInputValue,
|
|
334
|
-
toStateValue,
|
|
335
|
-
...props
|
|
336
|
-
}) {
|
|
337
|
-
const ref = (0, import_react3.useRef)(null);
|
|
338
|
-
const storeProps = useStoreInputWithName(ref, store, {
|
|
339
|
-
...props,
|
|
340
|
-
getter,
|
|
341
|
-
setter,
|
|
342
|
-
toInputValue,
|
|
343
|
-
toStateValue
|
|
344
|
-
});
|
|
345
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("textarea", { ref, ...props, ...storeProps });
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// src/use_form_store.tsx
|
|
349
|
-
function useFormStore(initialState) {
|
|
350
|
-
const store = (0, import_gw_store2.useStore)(initialState);
|
|
351
|
-
const storeComponent = useStoreComponent(store);
|
|
352
|
-
return {
|
|
353
|
-
get state() {
|
|
354
|
-
return store.state;
|
|
355
|
-
},
|
|
356
|
-
dispatch: store.dispatch,
|
|
357
|
-
subscribe: store.subscribe,
|
|
358
|
-
render: createRenderWithStore(store),
|
|
359
|
-
...storeComponent
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
363
|
-
0 && (module.exports = {
|
|
364
|
-
useFormStore
|
|
365
|
-
});
|