dn-react-router-toolkit 0.5.8 → 0.6.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/dist/auth/cookie_store.d.mts +1 -1
- package/dist/auth/cookie_store.d.ts +1 -1
- package/dist/auth/cookie_store.js +4 -4
- package/dist/auth/cookie_store.mjs +4 -4
- package/dist/auth/index.js +4 -4
- package/dist/auth/index.mjs +4 -4
- package/dist/client/env_loader.d.mts +2 -2
- package/dist/client/env_loader.d.ts +2 -2
- package/dist/client/file_input.d.mts +10 -0
- package/dist/client/file_input.d.ts +10 -0
- package/dist/client/file_input.js +80 -0
- package/dist/client/file_input.mjs +45 -0
- package/dist/client/index.d.mts +4 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +104 -0
- package/dist/client/index.mjs +102 -0
- package/dist/client/store_text_editor.d.mts +13 -0
- package/dist/client/store_text_editor.d.ts +13 -0
- package/dist/client/store_text_editor.js +94 -0
- package/dist/client/store_text_editor.mjs +59 -0
- package/dist/crud/crud_form.d.mts +4 -6
- package/dist/crud/crud_form.d.ts +4 -6
- package/dist/crud/crud_form.js +147 -100
- package/dist/crud/crud_form.mjs +148 -106
- package/dist/crud/crud_form_provider.d.mts +10 -10
- package/dist/crud/crud_form_provider.d.ts +10 -10
- package/dist/crud/crud_form_provider.js +5 -6
- package/dist/crud/crud_form_provider.mjs +4 -5
- package/dist/crud/crud_page.d.mts +8 -8
- package/dist/crud/crud_page.d.ts +8 -8
- package/dist/crud/crud_page.js +203 -160
- package/dist/crud/crud_page.mjs +200 -162
- package/dist/crud/generate_pages.d.mts +3 -3
- package/dist/crud/generate_pages.d.ts +3 -3
- package/dist/crud/index.d.mts +1 -1
- package/dist/crud/index.d.ts +1 -1
- package/dist/crud/index.js +256 -213
- package/dist/crud/index.mjs +240 -202
- package/dist/form/create_form_component.d.mts +28 -0
- package/dist/form/create_form_component.d.ts +28 -0
- package/dist/form/create_form_component.js +47 -0
- package/dist/form/create_form_component.mjs +12 -0
- package/dist/form/form_components.d.mts +7 -0
- package/dist/form/form_components.d.ts +7 -0
- package/dist/form/form_components.js +64 -0
- package/dist/form/form_components.mjs +25 -0
- package/dist/form/index.d.mts +3 -0
- package/dist/form/index.d.ts +3 -0
- package/dist/form/index.js +66 -0
- package/dist/form/index.mjs +26 -0
- package/dist/post/index.d.mts +2 -0
- package/dist/post/index.d.ts +2 -0
- package/dist/post/index.js +33 -0
- package/dist/post/index.mjs +4 -0
- package/dist/post/thumbnail_picker.d.mts +18 -0
- package/dist/post/thumbnail_picker.d.ts +18 -0
- package/dist/post/thumbnail_picker.js +101 -0
- package/dist/post/thumbnail_picker.mjs +70 -0
- package/dist/seo/seo.d.mts +2 -2
- package/dist/seo/seo.d.ts +2 -2
- package/dist/table/buttons.d.mts +2 -2
- package/dist/table/buttons.d.ts +2 -2
- package/dist/table/index.js +44 -47
- package/dist/table/index.mjs +44 -47
- package/dist/table/page.d.mts +5 -7
- package/dist/table/page.d.ts +5 -7
- package/dist/table/page.js +44 -47
- package/dist/table/page.mjs +44 -47
- package/dist/table/table.d.mts +4 -4
- package/dist/table/table.d.ts +4 -4
- package/package.json +14 -2
|
@@ -4,7 +4,7 @@ import { SerializeOptions, ParseOptions } from 'cookie';
|
|
|
4
4
|
declare class ReactRouterCookieManager implements CookieManager {
|
|
5
5
|
name: string;
|
|
6
6
|
options: SerializeOptions;
|
|
7
|
-
private
|
|
7
|
+
private cookie;
|
|
8
8
|
constructor(name: string);
|
|
9
9
|
parse(request: Request, parseOptions?: ParseOptions | undefined): Promise<string | null>;
|
|
10
10
|
serialize(value: string | null, serializeOptions?: SerializeOptions | undefined): Promise<string>;
|
|
@@ -4,7 +4,7 @@ import { SerializeOptions, ParseOptions } from 'cookie';
|
|
|
4
4
|
declare class ReactRouterCookieManager implements CookieManager {
|
|
5
5
|
name: string;
|
|
6
6
|
options: SerializeOptions;
|
|
7
|
-
private
|
|
7
|
+
private cookie;
|
|
8
8
|
constructor(name: string);
|
|
9
9
|
parse(request: Request, parseOptions?: ParseOptions | undefined): Promise<string | null>;
|
|
10
10
|
serialize(value: string | null, serializeOptions?: SerializeOptions | undefined): Promise<string>;
|
|
@@ -27,7 +27,7 @@ var import_react_router = require("react-router");
|
|
|
27
27
|
var ReactRouterCookieManager = class {
|
|
28
28
|
name;
|
|
29
29
|
options;
|
|
30
|
-
|
|
30
|
+
cookie;
|
|
31
31
|
constructor(name) {
|
|
32
32
|
this.name = name;
|
|
33
33
|
this.options = {
|
|
@@ -36,14 +36,14 @@ var ReactRouterCookieManager = class {
|
|
|
36
36
|
secure: process.env.NODE_ENV === "production",
|
|
37
37
|
sameSite: "strict"
|
|
38
38
|
};
|
|
39
|
-
this.
|
|
39
|
+
this.cookie = (0, import_react_router.createCookie)(this.name, this.options);
|
|
40
40
|
}
|
|
41
41
|
async parse(request, parseOptions) {
|
|
42
42
|
const cookieStore = request.headers.get("cookie") || "";
|
|
43
|
-
return this.
|
|
43
|
+
return this.cookie.parse(cookieStore, parseOptions);
|
|
44
44
|
}
|
|
45
45
|
async serialize(value, serializeOptions) {
|
|
46
|
-
return this.
|
|
46
|
+
return this.cookie.serialize(value, {
|
|
47
47
|
...this.options,
|
|
48
48
|
maxAge: !value ? 0 : void 0,
|
|
49
49
|
...serializeOptions
|
|
@@ -3,7 +3,7 @@ import { createCookie } from "react-router";
|
|
|
3
3
|
var ReactRouterCookieManager = class {
|
|
4
4
|
name;
|
|
5
5
|
options;
|
|
6
|
-
|
|
6
|
+
cookie;
|
|
7
7
|
constructor(name) {
|
|
8
8
|
this.name = name;
|
|
9
9
|
this.options = {
|
|
@@ -12,14 +12,14 @@ var ReactRouterCookieManager = class {
|
|
|
12
12
|
secure: process.env.NODE_ENV === "production",
|
|
13
13
|
sameSite: "strict"
|
|
14
14
|
};
|
|
15
|
-
this.
|
|
15
|
+
this.cookie = createCookie(this.name, this.options);
|
|
16
16
|
}
|
|
17
17
|
async parse(request, parseOptions) {
|
|
18
18
|
const cookieStore = request.headers.get("cookie") || "";
|
|
19
|
-
return this.
|
|
19
|
+
return this.cookie.parse(cookieStore, parseOptions);
|
|
20
20
|
}
|
|
21
21
|
async serialize(value, serializeOptions) {
|
|
22
|
-
return this.
|
|
22
|
+
return this.cookie.serialize(value, {
|
|
23
23
|
...this.options,
|
|
24
24
|
maxAge: !value ? 0 : void 0,
|
|
25
25
|
...serializeOptions
|
package/dist/auth/index.js
CHANGED
|
@@ -126,7 +126,7 @@ var import_react_router = require("react-router");
|
|
|
126
126
|
var ReactRouterCookieManager = class {
|
|
127
127
|
name;
|
|
128
128
|
options;
|
|
129
|
-
|
|
129
|
+
cookie;
|
|
130
130
|
constructor(name) {
|
|
131
131
|
this.name = name;
|
|
132
132
|
this.options = {
|
|
@@ -135,14 +135,14 @@ var ReactRouterCookieManager = class {
|
|
|
135
135
|
secure: process.env.NODE_ENV === "production",
|
|
136
136
|
sameSite: "strict"
|
|
137
137
|
};
|
|
138
|
-
this.
|
|
138
|
+
this.cookie = (0, import_react_router.createCookie)(this.name, this.options);
|
|
139
139
|
}
|
|
140
140
|
async parse(request, parseOptions) {
|
|
141
141
|
const cookieStore = request.headers.get("cookie") || "";
|
|
142
|
-
return this.
|
|
142
|
+
return this.cookie.parse(cookieStore, parseOptions);
|
|
143
143
|
}
|
|
144
144
|
async serialize(value, serializeOptions) {
|
|
145
|
-
return this.
|
|
145
|
+
return this.cookie.serialize(value, {
|
|
146
146
|
...this.options,
|
|
147
147
|
maxAge: !value ? 0 : void 0,
|
|
148
148
|
...serializeOptions
|
package/dist/auth/index.mjs
CHANGED
|
@@ -98,7 +98,7 @@ import { createCookie } from "react-router";
|
|
|
98
98
|
var ReactRouterCookieManager = class {
|
|
99
99
|
name;
|
|
100
100
|
options;
|
|
101
|
-
|
|
101
|
+
cookie;
|
|
102
102
|
constructor(name) {
|
|
103
103
|
this.name = name;
|
|
104
104
|
this.options = {
|
|
@@ -107,14 +107,14 @@ var ReactRouterCookieManager = class {
|
|
|
107
107
|
secure: process.env.NODE_ENV === "production",
|
|
108
108
|
sameSite: "strict"
|
|
109
109
|
};
|
|
110
|
-
this.
|
|
110
|
+
this.cookie = createCookie(this.name, this.options);
|
|
111
111
|
}
|
|
112
112
|
async parse(request, parseOptions) {
|
|
113
113
|
const cookieStore = request.headers.get("cookie") || "";
|
|
114
|
-
return this.
|
|
114
|
+
return this.cookie.parse(cookieStore, parseOptions);
|
|
115
115
|
}
|
|
116
116
|
async serialize(value, serializeOptions) {
|
|
117
|
-
return this.
|
|
117
|
+
return this.cookie.serialize(value, {
|
|
118
118
|
...this.options,
|
|
119
119
|
maxAge: !value ? 0 : void 0,
|
|
120
120
|
...serializeOptions
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React__default, { DetailedHTMLProps, InputHTMLAttributes, Ref, ChangeEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
type Props = Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "onChange"> & {
|
|
4
|
+
buttonRef?: Ref<HTMLButtonElement>;
|
|
5
|
+
} & {
|
|
6
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void | Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
declare function FileInput({ buttonRef, className, ref, children, onClick, onChange, ...props }: Props): React__default.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { FileInput };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React__default, { DetailedHTMLProps, InputHTMLAttributes, Ref, ChangeEvent } from 'react';
|
|
2
|
+
|
|
3
|
+
type Props = Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "onChange"> & {
|
|
4
|
+
buttonRef?: Ref<HTMLButtonElement>;
|
|
5
|
+
} & {
|
|
6
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void | Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
declare function FileInput({ buttonRef, className, ref, children, onClick, onChange, ...props }: Props): React__default.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { FileInput };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/client/file_input.tsx
|
|
31
|
+
var file_input_exports = {};
|
|
32
|
+
__export(file_input_exports, {
|
|
33
|
+
FileInput: () => FileInput
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(file_input_exports);
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_react2 = __toESM(require("react"));
|
|
38
|
+
function FileInput({
|
|
39
|
+
buttonRef,
|
|
40
|
+
className,
|
|
41
|
+
ref,
|
|
42
|
+
children,
|
|
43
|
+
onClick,
|
|
44
|
+
onChange,
|
|
45
|
+
...props
|
|
46
|
+
}) {
|
|
47
|
+
const inputRef = import_react2.default.useRef(null);
|
|
48
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(
|
|
49
|
+
"button",
|
|
50
|
+
{
|
|
51
|
+
ref: buttonRef,
|
|
52
|
+
className,
|
|
53
|
+
type: "button",
|
|
54
|
+
onClick: () => {
|
|
55
|
+
inputRef.current?.click();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
children
|
|
59
|
+
), /* @__PURE__ */ import_react2.default.createElement(
|
|
60
|
+
"input",
|
|
61
|
+
{
|
|
62
|
+
...props,
|
|
63
|
+
type: "file",
|
|
64
|
+
ref: inputRef,
|
|
65
|
+
style: {
|
|
66
|
+
display: "none"
|
|
67
|
+
},
|
|
68
|
+
onChange: async (e) => {
|
|
69
|
+
await onChange?.(e);
|
|
70
|
+
if (inputRef.current) {
|
|
71
|
+
inputRef.current.value = "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
));
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
FileInput
|
|
80
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/client/file_input.tsx
|
|
2
|
+
import "react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
function FileInput({
|
|
5
|
+
buttonRef,
|
|
6
|
+
className,
|
|
7
|
+
ref,
|
|
8
|
+
children,
|
|
9
|
+
onClick,
|
|
10
|
+
onChange,
|
|
11
|
+
...props
|
|
12
|
+
}) {
|
|
13
|
+
const inputRef = React.useRef(null);
|
|
14
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
15
|
+
"button",
|
|
16
|
+
{
|
|
17
|
+
ref: buttonRef,
|
|
18
|
+
className,
|
|
19
|
+
type: "button",
|
|
20
|
+
onClick: () => {
|
|
21
|
+
inputRef.current?.click();
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
children
|
|
25
|
+
), /* @__PURE__ */ React.createElement(
|
|
26
|
+
"input",
|
|
27
|
+
{
|
|
28
|
+
...props,
|
|
29
|
+
type: "file",
|
|
30
|
+
ref: inputRef,
|
|
31
|
+
style: {
|
|
32
|
+
display: "none"
|
|
33
|
+
},
|
|
34
|
+
onChange: async (e) => {
|
|
35
|
+
await onChange?.(e);
|
|
36
|
+
if (inputRef.current) {
|
|
37
|
+
inputRef.current.value = "";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
));
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
FileInput
|
|
45
|
+
};
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { env } from './env.mjs';
|
|
2
2
|
export { EnvLoader } from './env_loader.mjs';
|
|
3
|
+
export { FileInput } from './file_input.mjs';
|
|
3
4
|
export { useUserAgent } from './use_user_agent.mjs';
|
|
5
|
+
export { createStoreTextEditor } from './store_text_editor.mjs';
|
|
4
6
|
import 'react';
|
|
7
|
+
import 'dn-react-text-editor';
|
|
8
|
+
import 'react-store-input';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { env } from './env.js';
|
|
2
2
|
export { EnvLoader } from './env_loader.js';
|
|
3
|
+
export { FileInput } from './file_input.js';
|
|
3
4
|
export { useUserAgent } from './use_user_agent.js';
|
|
5
|
+
export { createStoreTextEditor } from './store_text_editor.js';
|
|
4
6
|
import 'react';
|
|
7
|
+
import 'dn-react-text-editor';
|
|
8
|
+
import 'react-store-input';
|
package/dist/client/index.js
CHANGED
|
@@ -31,6 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var client_exports = {};
|
|
32
32
|
__export(client_exports, {
|
|
33
33
|
EnvLoader: () => EnvLoader,
|
|
34
|
+
FileInput: () => FileInput,
|
|
35
|
+
createStoreTextEditor: () => createStoreTextEditor,
|
|
34
36
|
env: () => env,
|
|
35
37
|
useUserAgent: () => useUserAgent
|
|
36
38
|
});
|
|
@@ -62,6 +64,49 @@ function EnvLoader({ dataKey = "ENV" }) {
|
|
|
62
64
|
);
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
// src/client/file_input.tsx
|
|
68
|
+
var import_react2 = require("react");
|
|
69
|
+
var import_react3 = __toESM(require("react"));
|
|
70
|
+
function FileInput({
|
|
71
|
+
buttonRef,
|
|
72
|
+
className,
|
|
73
|
+
ref,
|
|
74
|
+
children,
|
|
75
|
+
onClick,
|
|
76
|
+
onChange,
|
|
77
|
+
...props
|
|
78
|
+
}) {
|
|
79
|
+
const inputRef = import_react3.default.useRef(null);
|
|
80
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(
|
|
81
|
+
"button",
|
|
82
|
+
{
|
|
83
|
+
ref: buttonRef,
|
|
84
|
+
className,
|
|
85
|
+
type: "button",
|
|
86
|
+
onClick: () => {
|
|
87
|
+
inputRef.current?.click();
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
children
|
|
91
|
+
), /* @__PURE__ */ import_react3.default.createElement(
|
|
92
|
+
"input",
|
|
93
|
+
{
|
|
94
|
+
...props,
|
|
95
|
+
type: "file",
|
|
96
|
+
ref: inputRef,
|
|
97
|
+
style: {
|
|
98
|
+
display: "none"
|
|
99
|
+
},
|
|
100
|
+
onChange: async (e) => {
|
|
101
|
+
await onChange?.(e);
|
|
102
|
+
if (inputRef.current) {
|
|
103
|
+
inputRef.current.value = "";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
));
|
|
108
|
+
}
|
|
109
|
+
|
|
65
110
|
// src/client/use_user_agent.tsx
|
|
66
111
|
var import_react_router2 = require("react-router");
|
|
67
112
|
function useUserAgent() {
|
|
@@ -72,9 +117,68 @@ function useUserAgent() {
|
|
|
72
117
|
const isDesktop = !isMobile && !isTablet;
|
|
73
118
|
return { userAgent, isMobile, isTablet, isDesktop };
|
|
74
119
|
}
|
|
120
|
+
|
|
121
|
+
// src/client/store_text_editor.tsx
|
|
122
|
+
var import_dn_react_text_editor = require("dn-react-text-editor");
|
|
123
|
+
var import_react_store_input = require("react-store-input");
|
|
124
|
+
var import_react4 = __toESM(require("react"));
|
|
125
|
+
function createStoreTextEditor(TextEditor) {
|
|
126
|
+
function StoreComponent({
|
|
127
|
+
store,
|
|
128
|
+
name,
|
|
129
|
+
defaultValue,
|
|
130
|
+
...props
|
|
131
|
+
}) {
|
|
132
|
+
const { ref, onChange } = (0, import_react_store_input.useStoreController)(
|
|
133
|
+
store,
|
|
134
|
+
{
|
|
135
|
+
ref: props.ref,
|
|
136
|
+
onSubscribe: (state, element) => {
|
|
137
|
+
const result = (props.getter ? props.getter(state) : name ? state[name] : "") || "";
|
|
138
|
+
if (element.value !== result) {
|
|
139
|
+
element.value = result;
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
onDispatch: (state, element) => {
|
|
143
|
+
if (props.setter) {
|
|
144
|
+
props.setter(state, element.value);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (name) {
|
|
148
|
+
state[name] = element.value;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
const getDefaultValue = () => {
|
|
154
|
+
if (props.getter) {
|
|
155
|
+
return props.getter(store.state);
|
|
156
|
+
}
|
|
157
|
+
if (name) {
|
|
158
|
+
return store.state[name];
|
|
159
|
+
}
|
|
160
|
+
return void 0;
|
|
161
|
+
};
|
|
162
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
163
|
+
TextEditor,
|
|
164
|
+
{
|
|
165
|
+
...props,
|
|
166
|
+
ref,
|
|
167
|
+
defaultValue: defaultValue ?? getDefaultValue(),
|
|
168
|
+
onChange: (e) => {
|
|
169
|
+
onChange();
|
|
170
|
+
props.onChange?.(e);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
return StoreComponent;
|
|
176
|
+
}
|
|
75
177
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
178
|
0 && (module.exports = {
|
|
77
179
|
EnvLoader,
|
|
180
|
+
FileInput,
|
|
181
|
+
createStoreTextEditor,
|
|
78
182
|
env,
|
|
79
183
|
useUserAgent
|
|
80
184
|
});
|
package/dist/client/index.mjs
CHANGED
|
@@ -24,6 +24,49 @@ function EnvLoader({ dataKey = "ENV" }) {
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// src/client/file_input.tsx
|
|
28
|
+
import "react";
|
|
29
|
+
import React2 from "react";
|
|
30
|
+
function FileInput({
|
|
31
|
+
buttonRef,
|
|
32
|
+
className,
|
|
33
|
+
ref,
|
|
34
|
+
children,
|
|
35
|
+
onClick,
|
|
36
|
+
onChange,
|
|
37
|
+
...props
|
|
38
|
+
}) {
|
|
39
|
+
const inputRef = React2.useRef(null);
|
|
40
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
ref: buttonRef,
|
|
44
|
+
className,
|
|
45
|
+
type: "button",
|
|
46
|
+
onClick: () => {
|
|
47
|
+
inputRef.current?.click();
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
children
|
|
51
|
+
), /* @__PURE__ */ React2.createElement(
|
|
52
|
+
"input",
|
|
53
|
+
{
|
|
54
|
+
...props,
|
|
55
|
+
type: "file",
|
|
56
|
+
ref: inputRef,
|
|
57
|
+
style: {
|
|
58
|
+
display: "none"
|
|
59
|
+
},
|
|
60
|
+
onChange: async (e) => {
|
|
61
|
+
await onChange?.(e);
|
|
62
|
+
if (inputRef.current) {
|
|
63
|
+
inputRef.current.value = "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
));
|
|
68
|
+
}
|
|
69
|
+
|
|
27
70
|
// src/client/use_user_agent.tsx
|
|
28
71
|
import { useRouteLoaderData as useRouteLoaderData2 } from "react-router";
|
|
29
72
|
function useUserAgent() {
|
|
@@ -34,8 +77,67 @@ function useUserAgent() {
|
|
|
34
77
|
const isDesktop = !isMobile && !isTablet;
|
|
35
78
|
return { userAgent, isMobile, isTablet, isDesktop };
|
|
36
79
|
}
|
|
80
|
+
|
|
81
|
+
// src/client/store_text_editor.tsx
|
|
82
|
+
import "dn-react-text-editor";
|
|
83
|
+
import { useStoreController } from "react-store-input";
|
|
84
|
+
import React3 from "react";
|
|
85
|
+
function createStoreTextEditor(TextEditor) {
|
|
86
|
+
function StoreComponent({
|
|
87
|
+
store,
|
|
88
|
+
name,
|
|
89
|
+
defaultValue,
|
|
90
|
+
...props
|
|
91
|
+
}) {
|
|
92
|
+
const { ref, onChange } = useStoreController(
|
|
93
|
+
store,
|
|
94
|
+
{
|
|
95
|
+
ref: props.ref,
|
|
96
|
+
onSubscribe: (state, element) => {
|
|
97
|
+
const result = (props.getter ? props.getter(state) : name ? state[name] : "") || "";
|
|
98
|
+
if (element.value !== result) {
|
|
99
|
+
element.value = result;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
onDispatch: (state, element) => {
|
|
103
|
+
if (props.setter) {
|
|
104
|
+
props.setter(state, element.value);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (name) {
|
|
108
|
+
state[name] = element.value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
const getDefaultValue = () => {
|
|
114
|
+
if (props.getter) {
|
|
115
|
+
return props.getter(store.state);
|
|
116
|
+
}
|
|
117
|
+
if (name) {
|
|
118
|
+
return store.state[name];
|
|
119
|
+
}
|
|
120
|
+
return void 0;
|
|
121
|
+
};
|
|
122
|
+
return /* @__PURE__ */ React3.createElement(
|
|
123
|
+
TextEditor,
|
|
124
|
+
{
|
|
125
|
+
...props,
|
|
126
|
+
ref,
|
|
127
|
+
defaultValue: defaultValue ?? getDefaultValue(),
|
|
128
|
+
onChange: (e) => {
|
|
129
|
+
onChange();
|
|
130
|
+
props.onChange?.(e);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return StoreComponent;
|
|
136
|
+
}
|
|
37
137
|
export {
|
|
38
138
|
EnvLoader,
|
|
139
|
+
FileInput,
|
|
140
|
+
createStoreTextEditor,
|
|
39
141
|
env,
|
|
40
142
|
useUserAgent
|
|
41
143
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TextEditorProps } from 'dn-react-text-editor';
|
|
2
|
+
import { Store } from 'react-store-input';
|
|
3
|
+
import React__default, { FC } from 'react';
|
|
4
|
+
|
|
5
|
+
type Props<TState> = {
|
|
6
|
+
store: Store<TState>;
|
|
7
|
+
name?: keyof TState;
|
|
8
|
+
getter?: (state: TState) => string;
|
|
9
|
+
setter?: (state: TState, value: string) => void;
|
|
10
|
+
} & TextEditorProps;
|
|
11
|
+
declare function createStoreTextEditor(TextEditor: FC<TextEditorProps>): <TState>({ store, name, defaultValue, ...props }: Props<TState>) => React__default.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { createStoreTextEditor };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TextEditorProps } from 'dn-react-text-editor';
|
|
2
|
+
import { Store } from 'react-store-input';
|
|
3
|
+
import React__default, { FC } from 'react';
|
|
4
|
+
|
|
5
|
+
type Props<TState> = {
|
|
6
|
+
store: Store<TState>;
|
|
7
|
+
name?: keyof TState;
|
|
8
|
+
getter?: (state: TState) => string;
|
|
9
|
+
setter?: (state: TState, value: string) => void;
|
|
10
|
+
} & TextEditorProps;
|
|
11
|
+
declare function createStoreTextEditor(TextEditor: FC<TextEditorProps>): <TState>({ store, name, defaultValue, ...props }: Props<TState>) => React__default.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { createStoreTextEditor };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/client/store_text_editor.tsx
|
|
31
|
+
var store_text_editor_exports = {};
|
|
32
|
+
__export(store_text_editor_exports, {
|
|
33
|
+
createStoreTextEditor: () => createStoreTextEditor
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(store_text_editor_exports);
|
|
36
|
+
var import_dn_react_text_editor = require("dn-react-text-editor");
|
|
37
|
+
var import_react_store_input = require("react-store-input");
|
|
38
|
+
var import_react = __toESM(require("react"));
|
|
39
|
+
function createStoreTextEditor(TextEditor) {
|
|
40
|
+
function StoreComponent({
|
|
41
|
+
store,
|
|
42
|
+
name,
|
|
43
|
+
defaultValue,
|
|
44
|
+
...props
|
|
45
|
+
}) {
|
|
46
|
+
const { ref, onChange } = (0, import_react_store_input.useStoreController)(
|
|
47
|
+
store,
|
|
48
|
+
{
|
|
49
|
+
ref: props.ref,
|
|
50
|
+
onSubscribe: (state, element) => {
|
|
51
|
+
const result = (props.getter ? props.getter(state) : name ? state[name] : "") || "";
|
|
52
|
+
if (element.value !== result) {
|
|
53
|
+
element.value = result;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
onDispatch: (state, element) => {
|
|
57
|
+
if (props.setter) {
|
|
58
|
+
props.setter(state, element.value);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (name) {
|
|
62
|
+
state[name] = element.value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
const getDefaultValue = () => {
|
|
68
|
+
if (props.getter) {
|
|
69
|
+
return props.getter(store.state);
|
|
70
|
+
}
|
|
71
|
+
if (name) {
|
|
72
|
+
return store.state[name];
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
77
|
+
TextEditor,
|
|
78
|
+
{
|
|
79
|
+
...props,
|
|
80
|
+
ref,
|
|
81
|
+
defaultValue: defaultValue ?? getDefaultValue(),
|
|
82
|
+
onChange: (e) => {
|
|
83
|
+
onChange();
|
|
84
|
+
props.onChange?.(e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return StoreComponent;
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
createStoreTextEditor
|
|
94
|
+
});
|