react-store-input 0.2.4 → 0.2.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.
- package/dist/create_render.d.mts +1 -1
- package/dist/create_render.d.ts +1 -1
- package/dist/create_render.js +3 -27
- package/dist/create_render.mjs +1 -23
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +119 -107
- package/dist/index.mjs +113 -99
- package/dist/text_editor.d.mts +13 -0
- package/dist/text_editor.d.ts +13 -0
- package/dist/text_editor.js +135 -0
- package/dist/text_editor.mjs +112 -0
- package/dist/use_form_store.d.mts +3 -1
- package/dist/use_form_store.d.ts +3 -1
- package/dist/use_form_store.js +111 -102
- package/dist/use_form_store.mjs +108 -97
- package/dist/use_store_component.d.mts +4 -1
- package/dist/use_store_component.d.ts +4 -1
- package/dist/use_store_component.js +97 -25
- package/dist/use_store_component.mjs +104 -30
- package/dist/use_store_controller.d.mts +1 -1
- package/dist/use_store_controller.d.ts +1 -1
- package/dist/use_store_controller.js +9 -17
- package/dist/use_store_controller.mjs +10 -18
- package/dist/use_store_input.d.mts +1 -1
- package/dist/use_store_input.d.ts +1 -1
- package/dist/use_store_input.js +9 -17
- package/dist/use_store_input.mjs +10 -18
- package/dist/use_store_input_with_name.d.mts +1 -1
- package/dist/use_store_input_with_name.d.ts +1 -1
- package/dist/use_store_input_with_name.js +9 -17
- package/dist/use_store_input_with_name.mjs +10 -18
- package/package.json +6 -4
- package/dist/use_selector.d.mts +0 -5
- package/dist/use_selector.d.ts +0 -5
- package/dist/use_selector.js +0 -50
- package/dist/use_selector.mjs +0 -25
- package/dist/use_store.d.mts +0 -12
- package/dist/use_store.d.ts +0 -12
- package/dist/use_store.js +0 -71
- package/dist/use_store.mjs +0 -46
- package/dist/use_subscribe.d.mts +0 -5
- package/dist/use_subscribe.d.ts +0 -5
- package/dist/use_subscribe.js +0 -38
- package/dist/use_subscribe.mjs +0 -13
package/dist/create_render.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Store } from 'gw-store';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
|
-
import { Store } from './use_store.mjs';
|
|
4
4
|
|
|
5
5
|
type CreateRender<TState> = (selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean) => ReactNode;
|
|
6
6
|
declare function createRender<TState>(store: Store<TState>, selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean): react_jsx_runtime.JSX.Element;
|
package/dist/create_render.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Store } from 'gw-store';
|
|
2
3
|
import { ReactNode } from 'react';
|
|
3
|
-
import { Store } from './use_store.js';
|
|
4
4
|
|
|
5
5
|
type CreateRender<TState> = (selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean) => ReactNode;
|
|
6
6
|
declare function createRender<TState>(store: Store<TState>, selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean): react_jsx_runtime.JSX.Element;
|
package/dist/create_render.js
CHANGED
|
@@ -24,35 +24,11 @@ __export(create_render_exports, {
|
|
|
24
24
|
createRenderWithStore: () => createRenderWithStore
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(create_render_exports);
|
|
27
|
-
|
|
28
|
-
// src/use_selector.tsx
|
|
29
|
-
var import_react = require("react");
|
|
30
|
-
function useSelector(store, selector, compare = (a, b) => a === b) {
|
|
31
|
-
const [state, setState] = (0, import_react.useState)(selector(store.state));
|
|
32
|
-
const stateRef = (0, import_react.useRef)(state);
|
|
33
|
-
(0, import_react.useEffect)(() => {
|
|
34
|
-
stateRef.current = state;
|
|
35
|
-
}, [state]);
|
|
36
|
-
(0, import_react.useEffect)(() => {
|
|
37
|
-
const unsubscribe = store.subscribe((newState) => {
|
|
38
|
-
const result = selector(newState);
|
|
39
|
-
if (compare(stateRef.current, result)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
setState(result);
|
|
43
|
-
});
|
|
44
|
-
return () => {
|
|
45
|
-
unsubscribe();
|
|
46
|
-
};
|
|
47
|
-
}, []);
|
|
48
|
-
return state;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// src/create_render.tsx
|
|
27
|
+
var import_gw_store = require("gw-store");
|
|
52
28
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
53
29
|
function createRender(store, selector, compare) {
|
|
54
30
|
function Component() {
|
|
55
|
-
const result = useSelector(store, (state) => state, compare);
|
|
31
|
+
const result = (0, import_gw_store.useSelector)(store, (state) => state, compare);
|
|
56
32
|
const content = selector(result);
|
|
57
33
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content });
|
|
58
34
|
}
|
|
@@ -61,7 +37,7 @@ function createRender(store, selector, compare) {
|
|
|
61
37
|
function createRenderWithStore(store) {
|
|
62
38
|
return function createRender2(selector, compare) {
|
|
63
39
|
function Component() {
|
|
64
|
-
const result = useSelector(store, (state) => state, compare);
|
|
40
|
+
const result = (0, import_gw_store.useSelector)(store, (state) => state, compare);
|
|
65
41
|
const content = selector(result);
|
|
66
42
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content });
|
|
67
43
|
}
|
package/dist/create_render.mjs
CHANGED
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
// src/use_selector.tsx
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
function useSelector(store, selector, compare = (a, b) => a === b) {
|
|
4
|
-
const [state, setState] = useState(selector(store.state));
|
|
5
|
-
const stateRef = useRef(state);
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
stateRef.current = state;
|
|
8
|
-
}, [state]);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const unsubscribe = store.subscribe((newState) => {
|
|
11
|
-
const result = selector(newState);
|
|
12
|
-
if (compare(stateRef.current, result)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
setState(result);
|
|
16
|
-
});
|
|
17
|
-
return () => {
|
|
18
|
-
unsubscribe();
|
|
19
|
-
};
|
|
20
|
-
}, []);
|
|
21
|
-
return state;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
1
|
// src/create_render.tsx
|
|
2
|
+
import { useSelector } from "gw-store";
|
|
25
3
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
26
4
|
function createRender(store, selector, compare) {
|
|
27
5
|
function Component() {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { Store, StoreSubscriber, useStore } from './use_store.mjs';
|
|
2
|
-
export { useSelector } from './use_selector.mjs';
|
|
3
|
-
export { useSubscribe } from './use_subscribe.mjs';
|
|
4
1
|
export { StoreControllerProps, useStoreController } from './use_store_controller.mjs';
|
|
5
2
|
export { InferNameFromProps, StoreInputWithNameProps, useStoreInputWithName } from './use_store_input_with_name.mjs';
|
|
6
3
|
export { StoreInputProps, useStoreInput } from './use_store_input.mjs';
|
|
7
4
|
export { Input, Select, StoreComponentPropsWithStore, StoreInputWithNameComponentProps, Textarea, useStoreComponent } from './use_store_component.mjs';
|
|
8
5
|
export { FormStore, useFormStore } from './use_form_store.mjs';
|
|
6
|
+
export { TextEditor, TextEditorProps } from './text_editor.mjs';
|
|
7
|
+
export * from 'gw-store';
|
|
9
8
|
import 'react';
|
|
10
9
|
import 'react/jsx-runtime';
|
|
11
10
|
import './create_render.mjs';
|
|
11
|
+
import 'gw-react-text-editor';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { Store, StoreSubscriber, useStore } from './use_store.js';
|
|
2
|
-
export { useSelector } from './use_selector.js';
|
|
3
|
-
export { useSubscribe } from './use_subscribe.js';
|
|
4
1
|
export { StoreControllerProps, useStoreController } from './use_store_controller.js';
|
|
5
2
|
export { InferNameFromProps, StoreInputWithNameProps, useStoreInputWithName } from './use_store_input_with_name.js';
|
|
6
3
|
export { StoreInputProps, useStoreInput } from './use_store_input.js';
|
|
7
4
|
export { Input, Select, StoreComponentPropsWithStore, StoreInputWithNameComponentProps, Textarea, useStoreComponent } from './use_store_component.js';
|
|
8
5
|
export { FormStore, useFormStore } from './use_form_store.js';
|
|
6
|
+
export { TextEditor, TextEditorProps } from './text_editor.js';
|
|
7
|
+
export * from 'gw-store';
|
|
9
8
|
import 'react';
|
|
10
9
|
import 'react/jsx-runtime';
|
|
11
10
|
import './create_render.js';
|
|
11
|
+
import 'gw-react-text-editor';
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
20
|
|
|
20
21
|
// src/index.tsx
|
|
@@ -22,106 +23,31 @@ var index_exports = {};
|
|
|
22
23
|
__export(index_exports, {
|
|
23
24
|
Input: () => Input,
|
|
24
25
|
Select: () => Select,
|
|
26
|
+
TextEditor: () => TextEditor,
|
|
25
27
|
Textarea: () => Textarea,
|
|
26
28
|
useFormStore: () => useFormStore,
|
|
27
|
-
useSelector: () => useSelector,
|
|
28
|
-
useStore: () => useStore,
|
|
29
29
|
useStoreComponent: () => useStoreComponent,
|
|
30
30
|
useStoreController: () => useStoreController,
|
|
31
31
|
useStoreInput: () => useStoreInput,
|
|
32
|
-
useStoreInputWithName: () => useStoreInputWithName
|
|
33
|
-
useSubscribe: () => useSubscribe
|
|
32
|
+
useStoreInputWithName: () => useStoreInputWithName
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(index_exports);
|
|
36
35
|
|
|
37
|
-
// src/
|
|
36
|
+
// src/use_store_controller.tsx
|
|
38
37
|
var import_react = require("react");
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (typeof recipe === "function") {
|
|
45
|
-
stateRef.current = (0, import_immer.produce)(stateRef.current, recipe);
|
|
46
|
-
} else {
|
|
47
|
-
stateRef.current = (0, import_immer.produce)(
|
|
48
|
-
stateRef.current,
|
|
49
|
-
(draft) => {
|
|
50
|
-
for (const key in recipe) {
|
|
51
|
-
draft[key] = recipe[key];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
notify(options.key);
|
|
57
|
-
};
|
|
58
|
-
const subscribe = (subscriber) => {
|
|
59
|
-
subscribers.current.push(subscriber);
|
|
60
|
-
return () => {
|
|
61
|
-
const index = subscribers.current.indexOf(subscriber);
|
|
62
|
-
if (index !== -1) {
|
|
63
|
-
subscribers.current.splice(index, 1);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
const notify = (key) => {
|
|
68
|
-
for (const listener of subscribers.current) {
|
|
69
|
-
listener(stateRef.current, key);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
return {
|
|
73
|
-
get state() {
|
|
74
|
-
return stateRef.current;
|
|
75
|
-
},
|
|
76
|
-
dispatch,
|
|
77
|
-
subscribe
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// src/use_selector.tsx
|
|
82
|
-
var import_react2 = require("react");
|
|
83
|
-
function useSelector(store, selector, compare = (a, b) => a === b) {
|
|
84
|
-
const [state, setState] = (0, import_react2.useState)(selector(store.state));
|
|
85
|
-
const stateRef = (0, import_react2.useRef)(state);
|
|
86
|
-
(0, import_react2.useEffect)(() => {
|
|
87
|
-
stateRef.current = state;
|
|
88
|
-
}, [state]);
|
|
89
|
-
(0, import_react2.useEffect)(() => {
|
|
90
|
-
const unsubscribe = store.subscribe((newState) => {
|
|
91
|
-
const result = selector(newState);
|
|
92
|
-
if (compare(stateRef.current, result)) {
|
|
38
|
+
function useStoreController(store, props) {
|
|
39
|
+
const dispatchKey = (0, import_react.useId)();
|
|
40
|
+
(0, import_react.useEffect)(() => {
|
|
41
|
+
const unsub = store.subscribe((state, key) => {
|
|
42
|
+
if (key === dispatchKey) {
|
|
93
43
|
return;
|
|
94
44
|
}
|
|
95
|
-
|
|
45
|
+
props.onSubscribe(state);
|
|
96
46
|
});
|
|
97
47
|
return () => {
|
|
98
|
-
|
|
48
|
+
unsub();
|
|
99
49
|
};
|
|
100
50
|
}, []);
|
|
101
|
-
return state;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// src/use_subscribe.tsx
|
|
105
|
-
var import_react3 = require("react");
|
|
106
|
-
function useSubscribe(store, subscriber) {
|
|
107
|
-
(0, import_react3.useEffect)(() => {
|
|
108
|
-
const unsubscribe = store.subscribe(subscriber);
|
|
109
|
-
return () => {
|
|
110
|
-
unsubscribe();
|
|
111
|
-
};
|
|
112
|
-
}, []);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// src/use_store_controller.tsx
|
|
116
|
-
var import_react4 = require("react");
|
|
117
|
-
function useStoreController(store, props) {
|
|
118
|
-
const dispatchKey = (0, import_react4.useId)();
|
|
119
|
-
useSubscribe(store, (state, key) => {
|
|
120
|
-
if (key === dispatchKey) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
props.onSubscribe(state);
|
|
124
|
-
});
|
|
125
51
|
const dispatch = () => {
|
|
126
52
|
store.dispatch(
|
|
127
53
|
(state) => {
|
|
@@ -254,22 +180,104 @@ function useStoreInputWithName(ref, store, props) {
|
|
|
254
180
|
}
|
|
255
181
|
|
|
256
182
|
// src/use_store_component.tsx
|
|
257
|
-
var
|
|
183
|
+
var import_react3 = require("react");
|
|
184
|
+
|
|
185
|
+
// src/text_editor.tsx
|
|
186
|
+
var import_gw_react_text_editor = require("gw-react-text-editor");
|
|
187
|
+
var import_react2 = require("react");
|
|
258
188
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
189
|
+
function TextEditor({
|
|
190
|
+
store,
|
|
191
|
+
name,
|
|
192
|
+
getter,
|
|
193
|
+
setter,
|
|
194
|
+
defaultValue,
|
|
195
|
+
ref,
|
|
196
|
+
...props
|
|
197
|
+
}) {
|
|
198
|
+
const controllerRef = (0, import_react2.useRef)(null);
|
|
199
|
+
(0, import_react2.useImperativeHandle)(
|
|
200
|
+
ref,
|
|
201
|
+
() => controllerRef.current,
|
|
202
|
+
[]
|
|
203
|
+
);
|
|
204
|
+
const { dispatch } = useStoreController(store, {
|
|
205
|
+
onSubscribe: (state) => {
|
|
206
|
+
const controller = controllerRef.current;
|
|
207
|
+
if (!controller) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const getResult = () => {
|
|
211
|
+
if (getter) {
|
|
212
|
+
return getter(state) || "";
|
|
213
|
+
}
|
|
214
|
+
if (name) {
|
|
215
|
+
return state[name] || "";
|
|
216
|
+
}
|
|
217
|
+
return "";
|
|
218
|
+
};
|
|
219
|
+
const result = getResult();
|
|
220
|
+
if (controller.value !== result) {
|
|
221
|
+
controller.value = result;
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
onDispatch: (state) => {
|
|
225
|
+
const controller = controllerRef.current;
|
|
226
|
+
if (!controller) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (setter) {
|
|
230
|
+
setter(state, controller.value);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (name) {
|
|
234
|
+
state[name] = controller.value;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
const getDefaultValue = () => {
|
|
239
|
+
if (getter) {
|
|
240
|
+
return getter(store.state);
|
|
241
|
+
}
|
|
242
|
+
if (name) {
|
|
243
|
+
return store.state[name];
|
|
244
|
+
}
|
|
245
|
+
return void 0;
|
|
246
|
+
};
|
|
247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
248
|
+
import_gw_react_text_editor.TextEditor,
|
|
249
|
+
{
|
|
250
|
+
...props,
|
|
251
|
+
ref: controllerRef,
|
|
252
|
+
defaultValue: defaultValue ?? getDefaultValue(),
|
|
253
|
+
onChange: (e) => {
|
|
254
|
+
dispatch();
|
|
255
|
+
props.onChange?.(e);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/use_store_component.tsx
|
|
262
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
259
263
|
function useStoreComponent(store) {
|
|
260
|
-
const input = (0,
|
|
261
|
-
return /* @__PURE__ */ (0,
|
|
264
|
+
const input = (0, import_react3.useCallback)(function Component(props) {
|
|
265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Input, { store, ...props });
|
|
262
266
|
}, []);
|
|
263
|
-
const select = (0,
|
|
264
|
-
return /* @__PURE__ */ (0,
|
|
267
|
+
const select = (0, import_react3.useCallback)(function Component(props) {
|
|
268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Select, { store, ...props });
|
|
265
269
|
}, []);
|
|
266
|
-
const textarea = (0,
|
|
267
|
-
return /* @__PURE__ */ (0,
|
|
270
|
+
const textarea = (0, import_react3.useCallback)(function Component(props) {
|
|
271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Textarea, { store, ...props });
|
|
272
|
+
}, []);
|
|
273
|
+
const textEditor = (0, import_react3.useCallback)(function Component(props) {
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(TextEditor, { store, ...props });
|
|
268
275
|
}, []);
|
|
269
276
|
return {
|
|
270
277
|
input,
|
|
271
278
|
select,
|
|
272
|
-
textarea
|
|
279
|
+
textarea,
|
|
280
|
+
textEditor
|
|
273
281
|
};
|
|
274
282
|
}
|
|
275
283
|
function Input({
|
|
@@ -280,7 +288,7 @@ function Input({
|
|
|
280
288
|
toStateValue,
|
|
281
289
|
...props
|
|
282
290
|
}) {
|
|
283
|
-
const ref = (0,
|
|
291
|
+
const ref = (0, import_react3.useRef)(null);
|
|
284
292
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
285
293
|
...props,
|
|
286
294
|
getter,
|
|
@@ -288,7 +296,7 @@ function Input({
|
|
|
288
296
|
toInputValue,
|
|
289
297
|
toStateValue
|
|
290
298
|
});
|
|
291
|
-
return /* @__PURE__ */ (0,
|
|
299
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { ref, ...props, ...storeProps });
|
|
292
300
|
}
|
|
293
301
|
function Select({
|
|
294
302
|
store,
|
|
@@ -298,7 +306,7 @@ function Select({
|
|
|
298
306
|
toStateValue,
|
|
299
307
|
...props
|
|
300
308
|
}) {
|
|
301
|
-
const ref = (0,
|
|
309
|
+
const ref = (0, import_react3.useRef)(null);
|
|
302
310
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
303
311
|
...props,
|
|
304
312
|
getter,
|
|
@@ -306,7 +314,7 @@ function Select({
|
|
|
306
314
|
toInputValue,
|
|
307
315
|
toStateValue
|
|
308
316
|
});
|
|
309
|
-
return /* @__PURE__ */ (0,
|
|
317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("select", { ref, ...props, ...storeProps });
|
|
310
318
|
}
|
|
311
319
|
function Textarea({
|
|
312
320
|
store,
|
|
@@ -316,7 +324,7 @@ function Textarea({
|
|
|
316
324
|
toStateValue,
|
|
317
325
|
...props
|
|
318
326
|
}) {
|
|
319
|
-
const ref = (0,
|
|
327
|
+
const ref = (0, import_react3.useRef)(null);
|
|
320
328
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
321
329
|
...props,
|
|
322
330
|
getter,
|
|
@@ -324,25 +332,27 @@ function Textarea({
|
|
|
324
332
|
toInputValue,
|
|
325
333
|
toStateValue
|
|
326
334
|
});
|
|
327
|
-
return /* @__PURE__ */ (0,
|
|
335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { ref, ...props, ...storeProps });
|
|
328
336
|
}
|
|
329
337
|
|
|
330
338
|
// src/create_render.tsx
|
|
331
|
-
var
|
|
339
|
+
var import_gw_store = require("gw-store");
|
|
340
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
332
341
|
function createRenderWithStore(store) {
|
|
333
342
|
return function createRender(selector, compare) {
|
|
334
343
|
function Component() {
|
|
335
|
-
const result = useSelector(store, (state) => state, compare);
|
|
344
|
+
const result = (0, import_gw_store.useSelector)(store, (state) => state, compare);
|
|
336
345
|
const content = selector(result);
|
|
337
|
-
return /* @__PURE__ */ (0,
|
|
346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: content });
|
|
338
347
|
}
|
|
339
|
-
return /* @__PURE__ */ (0,
|
|
348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, {});
|
|
340
349
|
};
|
|
341
350
|
}
|
|
342
351
|
|
|
343
352
|
// src/use_form_store.tsx
|
|
353
|
+
var import_gw_store2 = require("gw-store");
|
|
344
354
|
function useFormStore(initialState) {
|
|
345
|
-
const store = useStore(initialState);
|
|
355
|
+
const store = (0, import_gw_store2.useStore)(initialState);
|
|
346
356
|
const storeComponent = useStoreComponent(store);
|
|
347
357
|
return {
|
|
348
358
|
get state() {
|
|
@@ -354,17 +364,19 @@ function useFormStore(initialState) {
|
|
|
354
364
|
...storeComponent
|
|
355
365
|
};
|
|
356
366
|
}
|
|
367
|
+
|
|
368
|
+
// src/index.tsx
|
|
369
|
+
__reExport(index_exports, require("gw-store"), module.exports);
|
|
357
370
|
// Annotate the CommonJS export names for ESM import in node:
|
|
358
371
|
0 && (module.exports = {
|
|
359
372
|
Input,
|
|
360
373
|
Select,
|
|
374
|
+
TextEditor,
|
|
361
375
|
Textarea,
|
|
362
376
|
useFormStore,
|
|
363
|
-
useSelector,
|
|
364
|
-
useStore,
|
|
365
377
|
useStoreComponent,
|
|
366
378
|
useStoreController,
|
|
367
379
|
useStoreInput,
|
|
368
380
|
useStoreInputWithName,
|
|
369
|
-
|
|
381
|
+
...require("gw-store")
|
|
370
382
|
});
|