react-store-input 0.1.9 → 0.2.1
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 +3 -2
- package/dist/create_render.d.ts +3 -2
- package/dist/create_render.js +5 -15
- package/dist/create_render.mjs +5 -5
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -40
- package/dist/index.mjs +16 -26
- package/dist/use_form_store.d.mts +1 -0
- package/dist/use_form_store.d.ts +1 -0
- package/dist/use_form_store.js +25 -45
- package/dist/use_form_store.mjs +16 -26
- package/dist/use_store_component.d.mts +9 -8
- package/dist/use_store_component.d.ts +9 -8
- package/dist/use_store_component.js +17 -37
- package/dist/use_store_component.mjs +13 -23
- package/dist/use_store_input.js +0 -1
- package/dist/use_store_input.mjs +0 -1
- package/dist/use_store_input_with_name.d.mts +2 -2
- package/dist/use_store_input_with_name.d.ts +2 -2
- package/dist/use_store_input_with_name.js +0 -1
- package/dist/use_store_input_with_name.mjs +0 -1
- package/package.json +1 -1
package/dist/create_render.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { Store } from './use_store.mjs';
|
|
3
4
|
|
|
4
5
|
type CreateRender<TState> = (selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean) => ReactNode;
|
|
5
|
-
declare function createRender<TState>(store: Store<TState>, selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean):
|
|
6
|
+
declare function createRender<TState>(store: Store<TState>, selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean): react_jsx_runtime.JSX.Element;
|
|
6
7
|
declare function createRenderWithStore<TState>(store: Store<TState>): CreateRender<TState>;
|
|
7
8
|
|
|
8
9
|
export { type CreateRender, createRender, createRenderWithStore };
|
package/dist/create_render.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
import { Store } from './use_store.js';
|
|
3
4
|
|
|
4
5
|
type CreateRender<TState> = (selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean) => ReactNode;
|
|
5
|
-
declare function createRender<TState>(store: Store<TState>, selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean):
|
|
6
|
+
declare function createRender<TState>(store: Store<TState>, selector: (state: TState) => ReactNode, compare?: (a: TState, b: TState) => boolean): react_jsx_runtime.JSX.Element;
|
|
6
7
|
declare function createRenderWithStore<TState>(store: Store<TState>): CreateRender<TState>;
|
|
7
8
|
|
|
8
9
|
export { type CreateRender, createRender, createRenderWithStore };
|
package/dist/create_render.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/create_render.tsx
|
|
@@ -63,23 +53,23 @@ function useSelector(store, selector, compare = (a, b) => a === b) {
|
|
|
63
53
|
}
|
|
64
54
|
|
|
65
55
|
// src/create_render.tsx
|
|
66
|
-
var
|
|
56
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
67
57
|
function createRender(store, selector, compare) {
|
|
68
58
|
function Component() {
|
|
69
59
|
const result = useSelector(store, (state) => state, compare);
|
|
70
60
|
const content = selector(result);
|
|
71
|
-
return /* @__PURE__ */
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content });
|
|
72
62
|
}
|
|
73
|
-
return /* @__PURE__ */
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
|
74
64
|
}
|
|
75
65
|
function createRenderWithStore(store) {
|
|
76
66
|
return function createRender2(selector, compare) {
|
|
77
67
|
function Component() {
|
|
78
68
|
const result = useSelector(store, (state) => state, compare);
|
|
79
69
|
const content = selector(result);
|
|
80
|
-
return /* @__PURE__ */
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content });
|
|
81
71
|
}
|
|
82
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
|
83
73
|
};
|
|
84
74
|
}
|
|
85
75
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/create_render.mjs
CHANGED
|
@@ -26,23 +26,23 @@ function useSelector(store, selector, compare = (a, b) => a === b) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// src/create_render.tsx
|
|
29
|
-
import
|
|
29
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
30
30
|
function createRender(store, selector, compare) {
|
|
31
31
|
function Component() {
|
|
32
32
|
const result = useSelector(store, (state) => state, compare);
|
|
33
33
|
const content = selector(result);
|
|
34
|
-
return /* @__PURE__ */
|
|
34
|
+
return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
35
35
|
}
|
|
36
|
-
return /* @__PURE__ */
|
|
36
|
+
return /* @__PURE__ */ jsx(Component, {});
|
|
37
37
|
}
|
|
38
38
|
function createRenderWithStore(store) {
|
|
39
39
|
return function createRender2(selector, compare) {
|
|
40
40
|
function Component() {
|
|
41
41
|
const result = useSelector(store, (state) => state, compare);
|
|
42
42
|
const content = selector(result);
|
|
43
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
44
44
|
}
|
|
45
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ jsx(Component, {});
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
export {
|
package/dist/index.d.mts
CHANGED
|
@@ -7,4 +7,5 @@ export { StoreInputProps, useStoreInput } from './use_store_input.mjs';
|
|
|
7
7
|
export { Input, Select, StoreComponentPropsWithStore, StoreInputWithNameComponentProps, Textarea, useStoreComponent } from './use_store_component.mjs';
|
|
8
8
|
export { FormStore, useFormStore } from './use_form_store.mjs';
|
|
9
9
|
import 'react';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
10
11
|
import './create_render.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export { StoreInputProps, useStoreInput } from './use_store_input.js';
|
|
|
7
7
|
export { Input, Select, StoreComponentPropsWithStore, StoreInputWithNameComponentProps, Textarea, useStoreComponent } from './use_store_component.js';
|
|
8
8
|
export { FormStore, useFormStore } from './use_form_store.js';
|
|
9
9
|
import 'react';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
10
11
|
import './create_render.js';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.tsx
|
|
@@ -141,7 +131,6 @@ function useStoreController(store, props) {
|
|
|
141
131
|
}
|
|
142
132
|
|
|
143
133
|
// src/use_store_input.tsx
|
|
144
|
-
var import_react5 = require("react");
|
|
145
134
|
var import_date_fns = require("date-fns");
|
|
146
135
|
function useStoreInput(ref, store, props) {
|
|
147
136
|
const toInputValue = props.toInputValue || ((value) => {
|
|
@@ -258,27 +247,18 @@ function useStoreInputWithName(ref, store, props) {
|
|
|
258
247
|
}
|
|
259
248
|
|
|
260
249
|
// src/use_store_component.tsx
|
|
261
|
-
var
|
|
262
|
-
var
|
|
250
|
+
var import_react5 = require("react");
|
|
251
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
263
252
|
function useStoreComponent(store) {
|
|
264
|
-
const input = (0,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
);
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
},
|
|
274
|
-
[]
|
|
275
|
-
);
|
|
276
|
-
const textarea = (0, import_react6.useCallback)(
|
|
277
|
-
function Component(props) {
|
|
278
|
-
return /* @__PURE__ */ import_react7.default.createElement(Textarea, { store, ...props });
|
|
279
|
-
},
|
|
280
|
-
[]
|
|
281
|
-
);
|
|
253
|
+
const input = (0, import_react5.useCallback)(function Component(props) {
|
|
254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { store, ...props });
|
|
255
|
+
}, []);
|
|
256
|
+
const select = (0, import_react5.useCallback)(function Component(props) {
|
|
257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, { store, ...props });
|
|
258
|
+
}, []);
|
|
259
|
+
const textarea = (0, import_react5.useCallback)(function Component(props) {
|
|
260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Textarea, { store, ...props });
|
|
261
|
+
}, []);
|
|
282
262
|
return {
|
|
283
263
|
input,
|
|
284
264
|
select,
|
|
@@ -293,7 +273,7 @@ function Input({
|
|
|
293
273
|
toStateValue,
|
|
294
274
|
...props
|
|
295
275
|
}) {
|
|
296
|
-
const ref = (0,
|
|
276
|
+
const ref = (0, import_react5.useRef)(null);
|
|
297
277
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
298
278
|
...props,
|
|
299
279
|
getter,
|
|
@@ -301,7 +281,7 @@ function Input({
|
|
|
301
281
|
toInputValue,
|
|
302
282
|
toStateValue
|
|
303
283
|
});
|
|
304
|
-
return /* @__PURE__ */
|
|
284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { ref, ...props, ...storeProps });
|
|
305
285
|
}
|
|
306
286
|
function Select({
|
|
307
287
|
store,
|
|
@@ -311,7 +291,7 @@ function Select({
|
|
|
311
291
|
toStateValue,
|
|
312
292
|
...props
|
|
313
293
|
}) {
|
|
314
|
-
const ref = (0,
|
|
294
|
+
const ref = (0, import_react5.useRef)(null);
|
|
315
295
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
316
296
|
...props,
|
|
317
297
|
getter,
|
|
@@ -319,7 +299,7 @@ function Select({
|
|
|
319
299
|
toInputValue,
|
|
320
300
|
toStateValue
|
|
321
301
|
});
|
|
322
|
-
return /* @__PURE__ */
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { ref, ...props, ...storeProps });
|
|
323
303
|
}
|
|
324
304
|
function Textarea({
|
|
325
305
|
store,
|
|
@@ -329,7 +309,7 @@ function Textarea({
|
|
|
329
309
|
toStateValue,
|
|
330
310
|
...props
|
|
331
311
|
}) {
|
|
332
|
-
const ref = (0,
|
|
312
|
+
const ref = (0, import_react5.useRef)(null);
|
|
333
313
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
334
314
|
...props,
|
|
335
315
|
getter,
|
|
@@ -337,19 +317,19 @@ function Textarea({
|
|
|
337
317
|
toInputValue,
|
|
338
318
|
toStateValue
|
|
339
319
|
});
|
|
340
|
-
return /* @__PURE__ */
|
|
320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { ref, ...props, ...storeProps });
|
|
341
321
|
}
|
|
342
322
|
|
|
343
323
|
// src/create_render.tsx
|
|
344
|
-
var
|
|
324
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
345
325
|
function createRenderWithStore(store) {
|
|
346
326
|
return function createRender(selector, compare) {
|
|
347
327
|
function Component() {
|
|
348
328
|
const result = useSelector(store, (state) => state, compare);
|
|
349
329
|
const content = selector(result);
|
|
350
|
-
return /* @__PURE__ */
|
|
330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content });
|
|
351
331
|
}
|
|
352
|
-
return /* @__PURE__ */
|
|
332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component, {});
|
|
353
333
|
};
|
|
354
334
|
}
|
|
355
335
|
|
package/dist/index.mjs
CHANGED
|
@@ -95,7 +95,6 @@ function useStoreController(store, props) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// src/use_store_input.tsx
|
|
98
|
-
import "react";
|
|
99
98
|
import { format } from "date-fns";
|
|
100
99
|
function useStoreInput(ref, store, props) {
|
|
101
100
|
const toInputValue = props.toInputValue || ((value) => {
|
|
@@ -213,26 +212,17 @@ function useStoreInputWithName(ref, store, props) {
|
|
|
213
212
|
|
|
214
213
|
// src/use_store_component.tsx
|
|
215
214
|
import { useCallback, useRef as useRef2 } from "react";
|
|
216
|
-
import
|
|
215
|
+
import { jsx } from "react/jsx-runtime";
|
|
217
216
|
function useStoreComponent(store) {
|
|
218
|
-
const input = useCallback(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
);
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
},
|
|
228
|
-
[]
|
|
229
|
-
);
|
|
230
|
-
const textarea = useCallback(
|
|
231
|
-
function Component(props) {
|
|
232
|
-
return /* @__PURE__ */ React.createElement(Textarea, { store, ...props });
|
|
233
|
-
},
|
|
234
|
-
[]
|
|
235
|
-
);
|
|
217
|
+
const input = useCallback(function Component(props) {
|
|
218
|
+
return /* @__PURE__ */ jsx(Input, { store, ...props });
|
|
219
|
+
}, []);
|
|
220
|
+
const select = useCallback(function Component(props) {
|
|
221
|
+
return /* @__PURE__ */ jsx(Select, { store, ...props });
|
|
222
|
+
}, []);
|
|
223
|
+
const textarea = useCallback(function Component(props) {
|
|
224
|
+
return /* @__PURE__ */ jsx(Textarea, { store, ...props });
|
|
225
|
+
}, []);
|
|
236
226
|
return {
|
|
237
227
|
input,
|
|
238
228
|
select,
|
|
@@ -255,7 +245,7 @@ function Input({
|
|
|
255
245
|
toInputValue,
|
|
256
246
|
toStateValue
|
|
257
247
|
});
|
|
258
|
-
return /* @__PURE__ */
|
|
248
|
+
return /* @__PURE__ */ jsx("input", { ref, ...props, ...storeProps });
|
|
259
249
|
}
|
|
260
250
|
function Select({
|
|
261
251
|
store,
|
|
@@ -273,7 +263,7 @@ function Select({
|
|
|
273
263
|
toInputValue,
|
|
274
264
|
toStateValue
|
|
275
265
|
});
|
|
276
|
-
return /* @__PURE__ */
|
|
266
|
+
return /* @__PURE__ */ jsx("select", { ref, ...props, ...storeProps });
|
|
277
267
|
}
|
|
278
268
|
function Textarea({
|
|
279
269
|
store,
|
|
@@ -291,19 +281,19 @@ function Textarea({
|
|
|
291
281
|
toInputValue,
|
|
292
282
|
toStateValue
|
|
293
283
|
});
|
|
294
|
-
return /* @__PURE__ */
|
|
284
|
+
return /* @__PURE__ */ jsx("textarea", { ref, ...props, ...storeProps });
|
|
295
285
|
}
|
|
296
286
|
|
|
297
287
|
// src/create_render.tsx
|
|
298
|
-
import
|
|
288
|
+
import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
|
|
299
289
|
function createRenderWithStore(store) {
|
|
300
290
|
return function createRender(selector, compare) {
|
|
301
291
|
function Component() {
|
|
302
292
|
const result = useSelector(store, (state) => state, compare);
|
|
303
293
|
const content = selector(result);
|
|
304
|
-
return /* @__PURE__ */
|
|
294
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: content });
|
|
305
295
|
}
|
|
306
|
-
return /* @__PURE__ */
|
|
296
|
+
return /* @__PURE__ */ jsx2(Component, {});
|
|
307
297
|
};
|
|
308
298
|
}
|
|
309
299
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CreateRender } from './create_render.mjs';
|
|
2
2
|
import { Store } from './use_store.mjs';
|
|
3
3
|
import { useStoreComponent } from './use_store_component.mjs';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
4
5
|
import 'react';
|
|
5
6
|
import './use_store_input_with_name.mjs';
|
|
6
7
|
import './use_store_input.mjs';
|
package/dist/use_form_store.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CreateRender } from './create_render.js';
|
|
2
2
|
import { Store } from './use_store.js';
|
|
3
3
|
import { useStoreComponent } from './use_store_component.js';
|
|
4
|
+
import 'react/jsx-runtime';
|
|
4
5
|
import 'react';
|
|
5
6
|
import './use_store_input_with_name.js';
|
|
6
7
|
import './use_store_input.js';
|
package/dist/use_form_store.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/use_form_store.tsx
|
|
@@ -62,24 +52,24 @@ function useSelector(store, selector, compare = (a, b) => a === b) {
|
|
|
62
52
|
}
|
|
63
53
|
|
|
64
54
|
// src/create_render.tsx
|
|
65
|
-
var
|
|
55
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
66
56
|
function createRenderWithStore(store) {
|
|
67
57
|
return function createRender(selector, compare) {
|
|
68
58
|
function Component() {
|
|
69
59
|
const result = useSelector(store, (state) => state, compare);
|
|
70
60
|
const content = selector(result);
|
|
71
|
-
return /* @__PURE__ */
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content });
|
|
72
62
|
}
|
|
73
|
-
return /* @__PURE__ */
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
|
74
64
|
};
|
|
75
65
|
}
|
|
76
66
|
|
|
77
67
|
// src/use_store.tsx
|
|
78
|
-
var
|
|
68
|
+
var import_react3 = require("react");
|
|
79
69
|
var import_immer = require("immer");
|
|
80
70
|
function useStore(initialState) {
|
|
81
|
-
const stateRef = (0,
|
|
82
|
-
const subscribers = (0,
|
|
71
|
+
const stateRef = (0, import_react3.useRef)(initialState);
|
|
72
|
+
const subscribers = (0, import_react3.useRef)([]);
|
|
83
73
|
const dispatch = (recipe, options = {}) => {
|
|
84
74
|
if (typeof recipe === "function") {
|
|
85
75
|
stateRef.current = (0, import_immer.produce)(stateRef.current, recipe);
|
|
@@ -119,17 +109,15 @@ function useStore(initialState) {
|
|
|
119
109
|
}
|
|
120
110
|
|
|
121
111
|
// src/use_store_component.tsx
|
|
122
|
-
var
|
|
123
|
-
var import_react8 = __toESM(require("react"));
|
|
112
|
+
var import_react5 = require("react");
|
|
124
113
|
|
|
125
114
|
// src/use_store_input.tsx
|
|
126
|
-
var import_react6 = require("react");
|
|
127
115
|
var import_date_fns = require("date-fns");
|
|
128
116
|
|
|
129
117
|
// src/use_store_controller.tsx
|
|
130
|
-
var
|
|
118
|
+
var import_react4 = require("react");
|
|
131
119
|
function useStoreController(store, props) {
|
|
132
|
-
const dispatchKey = (0,
|
|
120
|
+
const dispatchKey = (0, import_react4.useId)();
|
|
133
121
|
useSubscribe(store, (state, key) => {
|
|
134
122
|
if (key === dispatchKey) {
|
|
135
123
|
return;
|
|
@@ -267,25 +255,17 @@ function useStoreInputWithName(ref, store, props) {
|
|
|
267
255
|
}
|
|
268
256
|
|
|
269
257
|
// src/use_store_component.tsx
|
|
258
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
270
259
|
function useStoreComponent(store) {
|
|
271
|
-
const input = (0,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
);
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
);
|
|
260
|
+
const input = (0, import_react5.useCallback)(function Component(props) {
|
|
261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Input, { store, ...props });
|
|
262
|
+
}, []);
|
|
263
|
+
const select = (0, import_react5.useCallback)(function Component(props) {
|
|
264
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Select, { store, ...props });
|
|
265
|
+
}, []);
|
|
266
|
+
const textarea = (0, import_react5.useCallback)(function Component(props) {
|
|
267
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Textarea, { store, ...props });
|
|
268
|
+
}, []);
|
|
289
269
|
return {
|
|
290
270
|
input,
|
|
291
271
|
select,
|
|
@@ -300,7 +280,7 @@ function Input({
|
|
|
300
280
|
toStateValue,
|
|
301
281
|
...props
|
|
302
282
|
}) {
|
|
303
|
-
const ref = (0,
|
|
283
|
+
const ref = (0, import_react5.useRef)(null);
|
|
304
284
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
305
285
|
...props,
|
|
306
286
|
getter,
|
|
@@ -308,7 +288,7 @@ function Input({
|
|
|
308
288
|
toInputValue,
|
|
309
289
|
toStateValue
|
|
310
290
|
});
|
|
311
|
-
return /* @__PURE__ */
|
|
291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { ref, ...props, ...storeProps });
|
|
312
292
|
}
|
|
313
293
|
function Select({
|
|
314
294
|
store,
|
|
@@ -318,7 +298,7 @@ function Select({
|
|
|
318
298
|
toStateValue,
|
|
319
299
|
...props
|
|
320
300
|
}) {
|
|
321
|
-
const ref = (0,
|
|
301
|
+
const ref = (0, import_react5.useRef)(null);
|
|
322
302
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
323
303
|
...props,
|
|
324
304
|
getter,
|
|
@@ -326,7 +306,7 @@ function Select({
|
|
|
326
306
|
toInputValue,
|
|
327
307
|
toStateValue
|
|
328
308
|
});
|
|
329
|
-
return /* @__PURE__ */
|
|
309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("select", { ref, ...props, ...storeProps });
|
|
330
310
|
}
|
|
331
311
|
function Textarea({
|
|
332
312
|
store,
|
|
@@ -336,7 +316,7 @@ function Textarea({
|
|
|
336
316
|
toStateValue,
|
|
337
317
|
...props
|
|
338
318
|
}) {
|
|
339
|
-
const ref = (0,
|
|
319
|
+
const ref = (0, import_react5.useRef)(null);
|
|
340
320
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
341
321
|
...props,
|
|
342
322
|
getter,
|
|
@@ -344,7 +324,7 @@ function Textarea({
|
|
|
344
324
|
toInputValue,
|
|
345
325
|
toStateValue
|
|
346
326
|
});
|
|
347
|
-
return /* @__PURE__ */
|
|
327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { ref, ...props, ...storeProps });
|
|
348
328
|
}
|
|
349
329
|
|
|
350
330
|
// src/use_form_store.tsx
|
package/dist/use_form_store.mjs
CHANGED
|
@@ -26,15 +26,15 @@ function useSelector(store, selector, compare = (a, b) => a === b) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// src/create_render.tsx
|
|
29
|
-
import
|
|
29
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
30
30
|
function createRenderWithStore(store) {
|
|
31
31
|
return function createRender(selector, compare) {
|
|
32
32
|
function Component() {
|
|
33
33
|
const result = useSelector(store, (state) => state, compare);
|
|
34
34
|
const content = selector(result);
|
|
35
|
-
return /* @__PURE__ */
|
|
35
|
+
return /* @__PURE__ */ jsx(Fragment, { children: content });
|
|
36
36
|
}
|
|
37
|
-
return /* @__PURE__ */
|
|
37
|
+
return /* @__PURE__ */ jsx(Component, {});
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -84,10 +84,8 @@ function useStore(initialState) {
|
|
|
84
84
|
|
|
85
85
|
// src/use_store_component.tsx
|
|
86
86
|
import { useCallback, useRef as useRef2 } from "react";
|
|
87
|
-
import React2 from "react";
|
|
88
87
|
|
|
89
88
|
// src/use_store_input.tsx
|
|
90
|
-
import "react";
|
|
91
89
|
import { format } from "date-fns";
|
|
92
90
|
|
|
93
91
|
// src/use_store_controller.tsx
|
|
@@ -231,25 +229,17 @@ function useStoreInputWithName(ref, store, props) {
|
|
|
231
229
|
}
|
|
232
230
|
|
|
233
231
|
// src/use_store_component.tsx
|
|
232
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
234
233
|
function useStoreComponent(store) {
|
|
235
|
-
const input = useCallback(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
);
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
},
|
|
245
|
-
[]
|
|
246
|
-
);
|
|
247
|
-
const textarea = useCallback(
|
|
248
|
-
function Component(props) {
|
|
249
|
-
return /* @__PURE__ */ React2.createElement(Textarea, { store, ...props });
|
|
250
|
-
},
|
|
251
|
-
[]
|
|
252
|
-
);
|
|
234
|
+
const input = useCallback(function Component(props) {
|
|
235
|
+
return /* @__PURE__ */ jsx2(Input, { store, ...props });
|
|
236
|
+
}, []);
|
|
237
|
+
const select = useCallback(function Component(props) {
|
|
238
|
+
return /* @__PURE__ */ jsx2(Select, { store, ...props });
|
|
239
|
+
}, []);
|
|
240
|
+
const textarea = useCallback(function Component(props) {
|
|
241
|
+
return /* @__PURE__ */ jsx2(Textarea, { store, ...props });
|
|
242
|
+
}, []);
|
|
253
243
|
return {
|
|
254
244
|
input,
|
|
255
245
|
select,
|
|
@@ -272,7 +262,7 @@ function Input({
|
|
|
272
262
|
toInputValue,
|
|
273
263
|
toStateValue
|
|
274
264
|
});
|
|
275
|
-
return /* @__PURE__ */
|
|
265
|
+
return /* @__PURE__ */ jsx2("input", { ref, ...props, ...storeProps });
|
|
276
266
|
}
|
|
277
267
|
function Select({
|
|
278
268
|
store,
|
|
@@ -290,7 +280,7 @@ function Select({
|
|
|
290
280
|
toInputValue,
|
|
291
281
|
toStateValue
|
|
292
282
|
});
|
|
293
|
-
return /* @__PURE__ */
|
|
283
|
+
return /* @__PURE__ */ jsx2("select", { ref, ...props, ...storeProps });
|
|
294
284
|
}
|
|
295
285
|
function Textarea({
|
|
296
286
|
store,
|
|
@@ -308,7 +298,7 @@ function Textarea({
|
|
|
308
298
|
toInputValue,
|
|
309
299
|
toStateValue
|
|
310
300
|
});
|
|
311
|
-
return /* @__PURE__ */
|
|
301
|
+
return /* @__PURE__ */ jsx2("textarea", { ref, ...props, ...storeProps });
|
|
312
302
|
}
|
|
313
303
|
|
|
314
304
|
// src/use_form_store.tsx
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DetailedHTMLProps } from 'react';
|
|
2
3
|
import { Store } from './use_store.mjs';
|
|
3
4
|
import { StoreInputWithNameProps } from './use_store_input_with_name.mjs';
|
|
4
5
|
import './use_store_input.mjs';
|
|
5
6
|
|
|
6
|
-
type StoreInputWithNameComponentProps<TElement, TState, TName extends keyof TState | undefined, TValue> = StoreInputWithNameProps<TElement, TState, TName, TValue> & Omit<DetailedHTMLProps<
|
|
7
|
+
type StoreInputWithNameComponentProps<TElement, TState, TName extends keyof TState | undefined, TValue> = StoreInputWithNameProps<TElement, TState, TName, TValue> & Omit<DetailedHTMLProps<React.InputHTMLAttributes<TElement>, TElement>, keyof StoreInputWithNameProps<TElement, TState, TName, TValue>>;
|
|
7
8
|
declare function useStoreComponent<TState>(store: Store<TState>): {
|
|
8
|
-
input: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLInputElement, TState, TName, TValue>) =>
|
|
9
|
-
select: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLSelectElement, TState, TName, TValue>) =>
|
|
10
|
-
textarea: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLTextAreaElement, TState, TName, TValue>) =>
|
|
9
|
+
input: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLInputElement, TState, TName, TValue>) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
select: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLSelectElement, TState, TName, TValue>) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
textarea: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLTextAreaElement, TState, TName, TValue>) => react_jsx_runtime.JSX.Element;
|
|
11
12
|
};
|
|
12
13
|
type StoreComponentPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState, TName extends keyof TState | undefined, TValue> = StoreInputWithNameComponentProps<TElement, TState, TName, TValue> & {
|
|
13
14
|
store: Store<TState>;
|
|
14
15
|
};
|
|
15
|
-
declare function Input<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState, TName, TValue>):
|
|
16
|
-
declare function Select<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState, TName, TValue>):
|
|
17
|
-
declare function Textarea<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState, TName, TValue>):
|
|
16
|
+
declare function Input<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState, TName, TValue>): react_jsx_runtime.JSX.Element;
|
|
17
|
+
declare function Select<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState, TName, TValue>): react_jsx_runtime.JSX.Element;
|
|
18
|
+
declare function Textarea<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState, TName, TValue>): react_jsx_runtime.JSX.Element;
|
|
18
19
|
|
|
19
20
|
export { Input, Select, type StoreComponentPropsWithStore, type StoreInputWithNameComponentProps, Textarea, useStoreComponent };
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DetailedHTMLProps } from 'react';
|
|
2
3
|
import { Store } from './use_store.js';
|
|
3
4
|
import { StoreInputWithNameProps } from './use_store_input_with_name.js';
|
|
4
5
|
import './use_store_input.js';
|
|
5
6
|
|
|
6
|
-
type StoreInputWithNameComponentProps<TElement, TState, TName extends keyof TState | undefined, TValue> = StoreInputWithNameProps<TElement, TState, TName, TValue> & Omit<DetailedHTMLProps<
|
|
7
|
+
type StoreInputWithNameComponentProps<TElement, TState, TName extends keyof TState | undefined, TValue> = StoreInputWithNameProps<TElement, TState, TName, TValue> & Omit<DetailedHTMLProps<React.InputHTMLAttributes<TElement>, TElement>, keyof StoreInputWithNameProps<TElement, TState, TName, TValue>>;
|
|
7
8
|
declare function useStoreComponent<TState>(store: Store<TState>): {
|
|
8
|
-
input: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLInputElement, TState, TName, TValue>) =>
|
|
9
|
-
select: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLSelectElement, TState, TName, TValue>) =>
|
|
10
|
-
textarea: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLTextAreaElement, TState, TName, TValue>) =>
|
|
9
|
+
input: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLInputElement, TState, TName, TValue>) => react_jsx_runtime.JSX.Element;
|
|
10
|
+
select: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLSelectElement, TState, TName, TValue>) => react_jsx_runtime.JSX.Element;
|
|
11
|
+
textarea: <TName extends keyof TState | undefined, TValue>(props: StoreInputWithNameComponentProps<HTMLTextAreaElement, TState, TName, TValue>) => react_jsx_runtime.JSX.Element;
|
|
11
12
|
};
|
|
12
13
|
type StoreComponentPropsWithStore<TElement extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, TState, TName extends keyof TState | undefined, TValue> = StoreInputWithNameComponentProps<TElement, TState, TName, TValue> & {
|
|
13
14
|
store: Store<TState>;
|
|
14
15
|
};
|
|
15
|
-
declare function Input<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState, TName, TValue>):
|
|
16
|
-
declare function Select<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState, TName, TValue>):
|
|
17
|
-
declare function Textarea<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState, TName, TValue>):
|
|
16
|
+
declare function Input<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLInputElement, TState, TName, TValue>): react_jsx_runtime.JSX.Element;
|
|
17
|
+
declare function Select<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLSelectElement, TState, TName, TValue>): react_jsx_runtime.JSX.Element;
|
|
18
|
+
declare function Textarea<TState, TName extends keyof TState | undefined, TValue>({ store, getter, setter, toInputValue, toStateValue, ...props }: StoreComponentPropsWithStore<HTMLTextAreaElement, TState, TName, TValue>): react_jsx_runtime.JSX.Element;
|
|
18
19
|
|
|
19
20
|
export { Input, Select, type StoreComponentPropsWithStore, type StoreInputWithNameComponentProps, Textarea, useStoreComponent };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/use_store_component.tsx
|
|
@@ -36,11 +26,9 @@ __export(use_store_component_exports, {
|
|
|
36
26
|
useStoreComponent: () => useStoreComponent
|
|
37
27
|
});
|
|
38
28
|
module.exports = __toCommonJS(use_store_component_exports);
|
|
39
|
-
var
|
|
40
|
-
var import_react5 = __toESM(require("react"));
|
|
29
|
+
var import_react3 = require("react");
|
|
41
30
|
|
|
42
31
|
// src/use_store_input.tsx
|
|
43
|
-
var import_react3 = require("react");
|
|
44
32
|
var import_date_fns = require("date-fns");
|
|
45
33
|
|
|
46
34
|
// src/use_store_controller.tsx
|
|
@@ -197,25 +185,17 @@ function useStoreInputWithName(ref, store, props) {
|
|
|
197
185
|
}
|
|
198
186
|
|
|
199
187
|
// src/use_store_component.tsx
|
|
188
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
200
189
|
function useStoreComponent(store) {
|
|
201
|
-
const input = (0,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
);
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
);
|
|
190
|
+
const input = (0, import_react3.useCallback)(function Component(props) {
|
|
191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { store, ...props });
|
|
192
|
+
}, []);
|
|
193
|
+
const select = (0, import_react3.useCallback)(function Component(props) {
|
|
194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Select, { store, ...props });
|
|
195
|
+
}, []);
|
|
196
|
+
const textarea = (0, import_react3.useCallback)(function Component(props) {
|
|
197
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Textarea, { store, ...props });
|
|
198
|
+
}, []);
|
|
219
199
|
return {
|
|
220
200
|
input,
|
|
221
201
|
select,
|
|
@@ -230,7 +210,7 @@ function Input({
|
|
|
230
210
|
toStateValue,
|
|
231
211
|
...props
|
|
232
212
|
}) {
|
|
233
|
-
const ref = (0,
|
|
213
|
+
const ref = (0, import_react3.useRef)(null);
|
|
234
214
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
235
215
|
...props,
|
|
236
216
|
getter,
|
|
@@ -238,7 +218,7 @@ function Input({
|
|
|
238
218
|
toInputValue,
|
|
239
219
|
toStateValue
|
|
240
220
|
});
|
|
241
|
-
return /* @__PURE__ */
|
|
221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { ref, ...props, ...storeProps });
|
|
242
222
|
}
|
|
243
223
|
function Select({
|
|
244
224
|
store,
|
|
@@ -248,7 +228,7 @@ function Select({
|
|
|
248
228
|
toStateValue,
|
|
249
229
|
...props
|
|
250
230
|
}) {
|
|
251
|
-
const ref = (0,
|
|
231
|
+
const ref = (0, import_react3.useRef)(null);
|
|
252
232
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
253
233
|
...props,
|
|
254
234
|
getter,
|
|
@@ -256,7 +236,7 @@ function Select({
|
|
|
256
236
|
toInputValue,
|
|
257
237
|
toStateValue
|
|
258
238
|
});
|
|
259
|
-
return /* @__PURE__ */
|
|
239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { ref, ...props, ...storeProps });
|
|
260
240
|
}
|
|
261
241
|
function Textarea({
|
|
262
242
|
store,
|
|
@@ -266,7 +246,7 @@ function Textarea({
|
|
|
266
246
|
toStateValue,
|
|
267
247
|
...props
|
|
268
248
|
}) {
|
|
269
|
-
const ref = (0,
|
|
249
|
+
const ref = (0, import_react3.useRef)(null);
|
|
270
250
|
const storeProps = useStoreInputWithName(ref, store, {
|
|
271
251
|
...props,
|
|
272
252
|
getter,
|
|
@@ -274,7 +254,7 @@ function Textarea({
|
|
|
274
254
|
toInputValue,
|
|
275
255
|
toStateValue
|
|
276
256
|
});
|
|
277
|
-
return /* @__PURE__ */
|
|
257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { ref, ...props, ...storeProps });
|
|
278
258
|
}
|
|
279
259
|
// Annotate the CommonJS export names for ESM import in node:
|
|
280
260
|
0 && (module.exports = {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// src/use_store_component.tsx
|
|
2
2
|
import { useCallback, useRef } from "react";
|
|
3
|
-
import React from "react";
|
|
4
3
|
|
|
5
4
|
// src/use_store_input.tsx
|
|
6
|
-
import "react";
|
|
7
5
|
import { format } from "date-fns";
|
|
8
6
|
|
|
9
7
|
// src/use_store_controller.tsx
|
|
@@ -160,25 +158,17 @@ function useStoreInputWithName(ref, store, props) {
|
|
|
160
158
|
}
|
|
161
159
|
|
|
162
160
|
// src/use_store_component.tsx
|
|
161
|
+
import { jsx } from "react/jsx-runtime";
|
|
163
162
|
function useStoreComponent(store) {
|
|
164
|
-
const input = useCallback(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
);
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
[]
|
|
175
|
-
);
|
|
176
|
-
const textarea = useCallback(
|
|
177
|
-
function Component(props) {
|
|
178
|
-
return /* @__PURE__ */ React.createElement(Textarea, { store, ...props });
|
|
179
|
-
},
|
|
180
|
-
[]
|
|
181
|
-
);
|
|
163
|
+
const input = useCallback(function Component(props) {
|
|
164
|
+
return /* @__PURE__ */ jsx(Input, { store, ...props });
|
|
165
|
+
}, []);
|
|
166
|
+
const select = useCallback(function Component(props) {
|
|
167
|
+
return /* @__PURE__ */ jsx(Select, { store, ...props });
|
|
168
|
+
}, []);
|
|
169
|
+
const textarea = useCallback(function Component(props) {
|
|
170
|
+
return /* @__PURE__ */ jsx(Textarea, { store, ...props });
|
|
171
|
+
}, []);
|
|
182
172
|
return {
|
|
183
173
|
input,
|
|
184
174
|
select,
|
|
@@ -201,7 +191,7 @@ function Input({
|
|
|
201
191
|
toInputValue,
|
|
202
192
|
toStateValue
|
|
203
193
|
});
|
|
204
|
-
return /* @__PURE__ */
|
|
194
|
+
return /* @__PURE__ */ jsx("input", { ref, ...props, ...storeProps });
|
|
205
195
|
}
|
|
206
196
|
function Select({
|
|
207
197
|
store,
|
|
@@ -219,7 +209,7 @@ function Select({
|
|
|
219
209
|
toInputValue,
|
|
220
210
|
toStateValue
|
|
221
211
|
});
|
|
222
|
-
return /* @__PURE__ */
|
|
212
|
+
return /* @__PURE__ */ jsx("select", { ref, ...props, ...storeProps });
|
|
223
213
|
}
|
|
224
214
|
function Textarea({
|
|
225
215
|
store,
|
|
@@ -237,7 +227,7 @@ function Textarea({
|
|
|
237
227
|
toInputValue,
|
|
238
228
|
toStateValue
|
|
239
229
|
});
|
|
240
|
-
return /* @__PURE__ */
|
|
230
|
+
return /* @__PURE__ */ jsx("textarea", { ref, ...props, ...storeProps });
|
|
241
231
|
}
|
|
242
232
|
export {
|
|
243
233
|
Input,
|
package/dist/use_store_input.js
CHANGED
|
@@ -23,7 +23,6 @@ __export(use_store_input_exports, {
|
|
|
23
23
|
useStoreInput: () => useStoreInput
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(use_store_input_exports);
|
|
26
|
-
var import_react3 = require("react");
|
|
27
26
|
var import_date_fns = require("date-fns");
|
|
28
27
|
|
|
29
28
|
// src/use_store_controller.tsx
|
package/dist/use_store_input.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { Store } from './use_store.mjs';
|
|
4
4
|
import { StoreInputProps } from './use_store_input.mjs';
|
|
@@ -11,7 +11,7 @@ declare function useStoreInputWithName<TInputElement extends HTMLInputElement |
|
|
|
11
11
|
name: string | undefined;
|
|
12
12
|
defaultValue: string | number | readonly string[] | undefined;
|
|
13
13
|
defaultChecked: boolean | undefined;
|
|
14
|
-
onChange: (event:
|
|
14
|
+
onChange: (event: react.ChangeEvent<TInputElement>) => void;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export { type InferNameFromProps, type StoreInputWithNameProps, useStoreInputWithName };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react from 'react';
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { Store } from './use_store.js';
|
|
4
4
|
import { StoreInputProps } from './use_store_input.js';
|
|
@@ -11,7 +11,7 @@ declare function useStoreInputWithName<TInputElement extends HTMLInputElement |
|
|
|
11
11
|
name: string | undefined;
|
|
12
12
|
defaultValue: string | number | readonly string[] | undefined;
|
|
13
13
|
defaultChecked: boolean | undefined;
|
|
14
|
-
onChange: (event:
|
|
14
|
+
onChange: (event: react.ChangeEvent<TInputElement>) => void;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export { type InferNameFromProps, type StoreInputWithNameProps, useStoreInputWithName };
|
|
@@ -25,7 +25,6 @@ __export(use_store_input_with_name_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(use_store_input_with_name_exports);
|
|
26
26
|
|
|
27
27
|
// src/use_store_input.tsx
|
|
28
|
-
var import_react3 = require("react");
|
|
29
28
|
var import_date_fns = require("date-fns");
|
|
30
29
|
|
|
31
30
|
// src/use_store_controller.tsx
|