dn-react-router-toolkit 0.9.12 → 0.10.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.
Files changed (64) hide show
  1. package/dist/api/default_api_handler.d.mts +2 -1
  2. package/dist/api/default_api_handler.d.ts +2 -1
  3. package/dist/api/index.js +2 -23
  4. package/dist/api/index.mjs +3 -31
  5. package/dist/api/patch_resource_handler.js +2 -23
  6. package/dist/api/patch_resource_handler.mjs +3 -31
  7. package/dist/api/put_resource_handler.js +2 -23
  8. package/dist/api/put_resource_handler.mjs +3 -31
  9. package/dist/api/resource_handler.d.mts +3 -2
  10. package/dist/api/resource_handler.d.ts +3 -2
  11. package/dist/api/resource_handler.js +2 -23
  12. package/dist/api/resource_handler.mjs +3 -31
  13. package/dist/client/env_loader.d.mts +2 -2
  14. package/dist/client/env_loader.d.ts +2 -2
  15. package/dist/client/file_input.d.mts +2 -2
  16. package/dist/client/file_input.d.ts +2 -2
  17. package/dist/client/index.d.mts +0 -7
  18. package/dist/client/index.d.ts +0 -7
  19. package/dist/client/index.js +0 -117
  20. package/dist/client/index.mjs +0 -117
  21. package/dist/crud/crud_form.d.mts +2 -2
  22. package/dist/crud/crud_form.d.ts +2 -2
  23. package/dist/crud/crud_form.js +40 -151
  24. package/dist/crud/crud_form.mjs +40 -158
  25. package/dist/crud/crud_form_provider.d.mts +6 -7
  26. package/dist/crud/crud_form_provider.d.ts +6 -7
  27. package/dist/crud/crud_form_provider.mjs +1 -4
  28. package/dist/crud/index.d.mts +0 -1
  29. package/dist/crud/index.d.ts +0 -1
  30. package/dist/crud/index.js +2 -23
  31. package/dist/crud/index.mjs +3 -31
  32. package/dist/form/create_form_component.d.mts +2 -2
  33. package/dist/form/create_form_component.d.ts +2 -2
  34. package/dist/form/form_components.d.mts +3 -4
  35. package/dist/form/form_components.d.ts +3 -4
  36. package/dist/form/index.d.mts +0 -1
  37. package/dist/form/index.d.ts +0 -1
  38. package/dist/index.d.mts +2 -3
  39. package/dist/index.d.ts +2 -3
  40. package/dist/post/index.d.mts +2 -3
  41. package/dist/post/index.d.ts +2 -3
  42. package/dist/post/thumbnail_picker.d.mts +4 -4
  43. package/dist/post/thumbnail_picker.d.ts +4 -4
  44. package/dist/seo/index.d.mts +1 -1
  45. package/dist/seo/index.d.ts +1 -1
  46. package/dist/seo/seo.d.mts +2 -2
  47. package/dist/seo/seo.d.ts +2 -2
  48. package/dist/table/buttons.d.mts +2 -2
  49. package/dist/table/buttons.d.ts +2 -2
  50. package/dist/table/index.d.mts +1 -2
  51. package/dist/table/index.d.ts +1 -2
  52. package/dist/table/table.d.mts +2 -2
  53. package/dist/table/table.d.ts +2 -2
  54. package/dist/table/table_form.d.mts +2 -3
  55. package/dist/table/table_form.d.ts +2 -3
  56. package/package.json +13 -13
  57. package/dist/client/editor.d.mts +0 -12
  58. package/dist/client/editor.d.ts +0 -12
  59. package/dist/client/editor.js +0 -63
  60. package/dist/client/editor.mjs +0 -38
  61. package/dist/client/store_text_editor.d.mts +0 -13
  62. package/dist/client/store_text_editor.d.ts +0 -13
  63. package/dist/client/store_text_editor.js +0 -104
  64. package/dist/client/store_text_editor.mjs +0 -81
@@ -82,126 +82,9 @@ function useUserAgent() {
82
82
  const isDesktop = !isMobile && !isTablet;
83
83
  return { userAgent, isMobile, isTablet, isDesktop };
84
84
  }
85
-
86
- // src/client/store_text_editor.tsx
87
- import {
88
- TextEditor
89
- } from "gw-react-text-editor";
90
- import { useStoreController } from "react-store-input";
91
- import { useImperativeHandle, useRef as useRef2 } from "react";
92
- import { jsx as jsx3 } from "react/jsx-runtime";
93
- function StoreTextEditor({
94
- store,
95
- name,
96
- getter,
97
- setter,
98
- defaultValue,
99
- ref,
100
- ...props
101
- }) {
102
- const controllerRef = useRef2(null);
103
- useImperativeHandle(
104
- ref,
105
- () => controllerRef.current,
106
- []
107
- );
108
- const { dispatch } = useStoreController(store, {
109
- onSubscribe: (state) => {
110
- const controller = controllerRef.current;
111
- if (!controller) {
112
- return;
113
- }
114
- const getResult = () => {
115
- if (getter) {
116
- return getter(state) || "";
117
- }
118
- if (name) {
119
- return state[name] || "";
120
- }
121
- return "";
122
- };
123
- const result = getResult();
124
- if (controller.value !== result) {
125
- controller.value = result;
126
- }
127
- },
128
- onDispatch: (state) => {
129
- const controller = controllerRef.current;
130
- if (!controller) {
131
- return;
132
- }
133
- if (setter) {
134
- setter(state, controller.value);
135
- return;
136
- }
137
- if (name) {
138
- state[name] = controller.value;
139
- }
140
- }
141
- });
142
- const getDefaultValue = () => {
143
- if (getter) {
144
- return getter(store.state);
145
- }
146
- if (name) {
147
- return store.state[name];
148
- }
149
- return void 0;
150
- };
151
- return /* @__PURE__ */ jsx3(
152
- TextEditor,
153
- {
154
- ...props,
155
- ref: controllerRef,
156
- defaultValue: defaultValue ?? getDefaultValue(),
157
- onChange: (e) => {
158
- dispatch();
159
- props.onChange?.(e);
160
- }
161
- }
162
- );
163
- }
164
-
165
- // src/client/editor.tsx
166
- import { generateMetadata } from "gw-file/client";
167
- function createAttachFileOptions({
168
- cdn,
169
- fileUploader
170
- }) {
171
- return {
172
- uploadFile: async (file) => {
173
- const result = await fileUploader.uploadFile(file, {
174
- convertToWebp: true
175
- });
176
- if (result.isErr) {
177
- throw new Error(result.error.message);
178
- }
179
- return {
180
- alt: file.name,
181
- src: cdn(result.value.key)
182
- };
183
- },
184
- generateMetadata: (file) => generateMetadata(file, {
185
- uploadBlob: async (blob) => {
186
- const result = await fileUploader.uploadBlob(blob, "file", {
187
- convertToWebp: true
188
- });
189
- if (result.isErr) {
190
- throw new Error(result.error.message);
191
- }
192
- return {
193
- alt: file.name,
194
- src: cdn(result.value.key)
195
- };
196
- }
197
- })
198
- };
199
- }
200
85
  export {
201
86
  EnvLoader,
202
87
  FileInput,
203
- StoreTextEditor,
204
- createAttachFileOptions,
205
88
  env,
206
89
  useUserAgent
207
90
  };
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { FC, ReactNode } from 'react';
3
3
 
4
4
  type Props = {
@@ -7,6 +7,6 @@ type Props = {
7
7
  actions?: ReactNode;
8
8
  }>;
9
9
  };
10
- declare function CrudForm<TModel extends Record<string, unknown>>({ AdminHeader, }: Props): react_jsx_runtime.JSX.Element;
10
+ declare function CrudForm<TModel extends Record<string, unknown>>({ AdminHeader }: Props): react.JSX.Element;
11
11
 
12
12
  export { CrudForm as default };
@@ -1,4 +1,4 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
1
+ import * as react from 'react';
2
2
  import { FC, ReactNode } from 'react';
3
3
 
4
4
  type Props = {
@@ -7,6 +7,6 @@ type Props = {
7
7
  actions?: ReactNode;
8
8
  }>;
9
9
  };
10
- declare function CrudForm<TModel extends Record<string, unknown>>({ AdminHeader, }: Props): react_jsx_runtime.JSX.Element;
10
+ declare function CrudForm<TModel extends Record<string, unknown>>({ AdminHeader }: Props): react.JSX.Element;
11
11
 
12
12
  export { CrudForm as default };
@@ -76,113 +76,19 @@ var FormLabel = createComponent("label", {
76
76
  });
77
77
 
78
78
  // src/crud/crud_form.tsx
79
- var import_react_store_input3 = require("react-store-input");
80
-
81
- // src/client/env_loader.tsx
82
- var import_react_router2 = require("react-router");
83
- var import_jsx_runtime3 = require("react/jsx-runtime");
84
-
85
- // src/client/file_input.tsx
86
- var import_react3 = require("react");
87
- var import_jsx_runtime4 = require("react/jsx-runtime");
88
-
89
- // src/client/use_user_agent.tsx
90
- var import_react_router3 = require("react-router");
91
-
92
- // src/client/store_text_editor.tsx
93
- var import_gw_react_text_editor = require("gw-react-text-editor");
94
79
  var import_react_store_input2 = require("react-store-input");
95
- var import_react4 = require("react");
96
- var import_jsx_runtime5 = require("react/jsx-runtime");
97
- function StoreTextEditor({
98
- store,
99
- name,
100
- getter,
101
- setter,
102
- defaultValue,
103
- ref,
104
- ...props
105
- }) {
106
- const controllerRef = (0, import_react4.useRef)(null);
107
- (0, import_react4.useImperativeHandle)(
108
- ref,
109
- () => controllerRef.current,
110
- []
111
- );
112
- const { dispatch } = (0, import_react_store_input2.useStoreController)(store, {
113
- onSubscribe: (state) => {
114
- const controller = controllerRef.current;
115
- if (!controller) {
116
- return;
117
- }
118
- const getResult = () => {
119
- if (getter) {
120
- return getter(state) || "";
121
- }
122
- if (name) {
123
- return state[name] || "";
124
- }
125
- return "";
126
- };
127
- const result = getResult();
128
- if (controller.value !== result) {
129
- controller.value = result;
130
- }
131
- },
132
- onDispatch: (state) => {
133
- const controller = controllerRef.current;
134
- if (!controller) {
135
- return;
136
- }
137
- if (setter) {
138
- setter(state, controller.value);
139
- return;
140
- }
141
- if (name) {
142
- state[name] = controller.value;
143
- }
144
- }
145
- });
146
- const getDefaultValue = () => {
147
- if (getter) {
148
- return getter(store.state);
149
- }
150
- if (name) {
151
- return store.state[name];
152
- }
153
- return void 0;
154
- };
155
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
156
- import_gw_react_text_editor.TextEditor,
157
- {
158
- ...props,
159
- ref: controllerRef,
160
- defaultValue: defaultValue ?? getDefaultValue(),
161
- onChange: (e) => {
162
- dispatch();
163
- props.onChange?.(e);
164
- }
165
- }
166
- );
167
- }
168
-
169
- // src/client/editor.tsx
170
- var import_client = require("gw-file/client");
171
-
172
- // src/crud/crud_form.tsx
173
- var import_jsx_runtime6 = require("react/jsx-runtime");
174
- function CrudForm({
175
- AdminHeader
176
- }) {
80
+ var import_text_editor = require("react-store-input/text-editor");
81
+ var import_jsx_runtime3 = require("react/jsx-runtime");
82
+ function CrudForm({ AdminHeader }) {
177
83
  const form = useFormContext();
178
- const component = (0, import_react_store_input3.useStoreComponent)(form.store);
179
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
180
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
84
+ const component = (0, import_react_store_input2.useStoreComponent)(form.store);
85
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
86
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
181
87
  AdminHeader,
182
88
  {
183
89
  title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
184
- actions: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
185
- form.item && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
90
+ actions: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
91
+ form.item && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
186
92
  "button",
187
93
  {
188
94
  type: "button",
@@ -193,64 +99,47 @@ function CrudForm({
193
99
  children: "\uC0AD\uC81C\uD558\uAE30"
194
100
  }
195
101
  ),
196
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
197
- "button",
198
- {
199
- type: "button",
200
- className: "button-primary",
201
- onClick: form.submit,
202
- children: "\uC800\uC7A5\uD558\uAE30"
203
- }
204
- )
102
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "button-primary", onClick: form.submit, children: "\uC800\uC7A5\uD558\uAE30" })
205
103
  ] })
206
104
  }
207
105
  ),
208
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: Object.entries(form.columns).map(
209
- ([name, value]) => {
210
- function InputComponent() {
211
- if (value.component) {
212
- const Component = value.component;
213
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component, { store: form.store, name });
214
- }
215
- if (value.type === "textarea") {
216
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
217
- StoreTextEditor,
218
- {
219
- store: form.store,
220
- name,
221
- editor: {
222
- attributes: {
223
- class: "text-editor-form"
224
- }
225
- }
226
- }
227
- );
228
- }
229
- if (value.options) {
230
- const Component = value.options;
231
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(component.select, { name, className: "select-form", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component, {}) });
232
- }
233
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
234
- component.input,
106
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: Object.entries(form.columns).map(([name, value]) => {
107
+ function InputComponent() {
108
+ if (value.component) {
109
+ const Component = value.component;
110
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { store: form.store, name });
111
+ }
112
+ if (value.type === "textarea") {
113
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
114
+ import_text_editor.TextEditor,
235
115
  {
116
+ store: form.store,
236
117
  name,
237
- type: value.type,
238
- className: "input-form"
118
+ editor: {
119
+ attributes: {
120
+ class: "text-editor-form"
121
+ }
122
+ }
239
123
  }
240
124
  );
241
125
  }
242
- const v = form.store.state[name];
243
- if (typeof v === "boolean") {
244
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex", children: [
245
- value.label,
246
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ml-auto", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InputComponent, {}) })
247
- ] });
126
+ if (value.options) {
127
+ const Component = value.options;
128
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(component.select, { name, className: "select-form", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, {}) });
248
129
  }
249
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormRow, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(FormEntry, { children: [
250
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FormLabel, { children: value.label }, name),
251
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InputComponent, {})
252
- ] }) }, name);
130
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(component.input, { name, type: value.type, className: "input-form" });
131
+ }
132
+ const v = form.store.state[name];
133
+ if (typeof v === "boolean") {
134
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex", children: [
135
+ value.label,
136
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ml-auto", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InputComponent, {}) })
137
+ ] });
253
138
  }
254
- ) }) })
139
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FormRow, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(FormEntry, { children: [
140
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FormLabel, { children: value.label }, name),
141
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InputComponent, {})
142
+ ] }) }, name);
143
+ }) }) })
255
144
  ] });
256
145
  }
@@ -1,10 +1,7 @@
1
1
  // src/crud/crud_form_provider.tsx
2
2
  import { useNavigate } from "react-router";
3
3
  import { useStore } from "react-store-input";
4
- import {
5
- createContext,
6
- useContext
7
- } from "react";
4
+ import { createContext, useContext } from "react";
8
5
  import { jsx } from "react/jsx-runtime";
9
6
  var FormContext = createContext({});
10
7
  function useFormContext() {
@@ -44,116 +41,18 @@ var FormLabel = createComponent("label", {
44
41
 
45
42
  // src/crud/crud_form.tsx
46
43
  import { useStoreComponent } from "react-store-input";
47
-
48
- // src/client/env_loader.tsx
49
- import { useRouteLoaderData } from "react-router";
50
- import { jsx as jsx3 } from "react/jsx-runtime";
51
-
52
- // src/client/file_input.tsx
53
- import {
54
- useRef
55
- } from "react";
56
- import { Fragment, jsx as jsx4, jsxs } from "react/jsx-runtime";
57
-
58
- // src/client/use_user_agent.tsx
59
- import { useRouteLoaderData as useRouteLoaderData2 } from "react-router";
60
-
61
- // src/client/store_text_editor.tsx
62
- import {
63
- TextEditor
64
- } from "gw-react-text-editor";
65
- import { useStoreController } from "react-store-input";
66
- import { useImperativeHandle, useRef as useRef2 } from "react";
67
- import { jsx as jsx5 } from "react/jsx-runtime";
68
- function StoreTextEditor({
69
- store,
70
- name,
71
- getter,
72
- setter,
73
- defaultValue,
74
- ref,
75
- ...props
76
- }) {
77
- const controllerRef = useRef2(null);
78
- useImperativeHandle(
79
- ref,
80
- () => controllerRef.current,
81
- []
82
- );
83
- const { dispatch } = useStoreController(store, {
84
- onSubscribe: (state) => {
85
- const controller = controllerRef.current;
86
- if (!controller) {
87
- return;
88
- }
89
- const getResult = () => {
90
- if (getter) {
91
- return getter(state) || "";
92
- }
93
- if (name) {
94
- return state[name] || "";
95
- }
96
- return "";
97
- };
98
- const result = getResult();
99
- if (controller.value !== result) {
100
- controller.value = result;
101
- }
102
- },
103
- onDispatch: (state) => {
104
- const controller = controllerRef.current;
105
- if (!controller) {
106
- return;
107
- }
108
- if (setter) {
109
- setter(state, controller.value);
110
- return;
111
- }
112
- if (name) {
113
- state[name] = controller.value;
114
- }
115
- }
116
- });
117
- const getDefaultValue = () => {
118
- if (getter) {
119
- return getter(store.state);
120
- }
121
- if (name) {
122
- return store.state[name];
123
- }
124
- return void 0;
125
- };
126
- return /* @__PURE__ */ jsx5(
127
- TextEditor,
128
- {
129
- ...props,
130
- ref: controllerRef,
131
- defaultValue: defaultValue ?? getDefaultValue(),
132
- onChange: (e) => {
133
- dispatch();
134
- props.onChange?.(e);
135
- }
136
- }
137
- );
138
- }
139
-
140
- // src/client/editor.tsx
141
- import { generateMetadata } from "gw-file/client";
142
-
143
- // src/crud/crud_form.tsx
144
- import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
145
- function CrudForm({
146
- AdminHeader
147
- }) {
44
+ import { TextEditor } from "react-store-input/text-editor";
45
+ import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
46
+ function CrudForm({ AdminHeader }) {
148
47
  const form = useFormContext();
149
48
  const component = useStoreComponent(form.store);
150
- return /* @__PURE__ */ jsxs2(Fragment2, { children: [
151
- /* @__PURE__ */ jsx6(
49
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
50
+ /* @__PURE__ */ jsx3(
152
51
  AdminHeader,
153
52
  {
154
53
  title: `${form.name} ${form.item ? "\uC218\uC815" : "\uCD94\uAC00"}`,
155
- actions: /* @__PURE__ */ jsxs2(Fragment2, { children: [
156
- form.item && /* @__PURE__ */ jsx6(
54
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
55
+ form.item && /* @__PURE__ */ jsx3(
157
56
  "button",
158
57
  {
159
58
  type: "button",
@@ -164,65 +63,48 @@ function CrudForm({
164
63
  children: "\uC0AD\uC81C\uD558\uAE30"
165
64
  }
166
65
  ),
167
- /* @__PURE__ */ jsx6(
168
- "button",
169
- {
170
- type: "button",
171
- className: "button-primary",
172
- onClick: form.submit,
173
- children: "\uC800\uC7A5\uD558\uAE30"
174
- }
175
- )
66
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "button-primary", onClick: form.submit, children: "\uC800\uC7A5\uD558\uAE30" })
176
67
  ] })
177
68
  }
178
69
  ),
179
- /* @__PURE__ */ jsx6("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ jsx6(Fragment2, { children: Object.entries(form.columns).map(
180
- ([name, value]) => {
181
- function InputComponent() {
182
- if (value.component) {
183
- const Component = value.component;
184
- return /* @__PURE__ */ jsx6(Component, { store: form.store, name });
185
- }
186
- if (value.type === "textarea") {
187
- return /* @__PURE__ */ jsx6(
188
- StoreTextEditor,
189
- {
190
- store: form.store,
191
- name,
192
- editor: {
193
- attributes: {
194
- class: "text-editor-form"
195
- }
196
- }
197
- }
198
- );
199
- }
200
- if (value.options) {
201
- const Component = value.options;
202
- return /* @__PURE__ */ jsx6(component.select, { name, className: "select-form", children: /* @__PURE__ */ jsx6(Component, {}) });
203
- }
204
- return /* @__PURE__ */ jsx6(
205
- component.input,
70
+ /* @__PURE__ */ jsx3("div", { className: "max-w-2xl mx-auto", children: Object.keys(form.columns).length > 0 && /* @__PURE__ */ jsx3(Fragment, { children: Object.entries(form.columns).map(([name, value]) => {
71
+ function InputComponent() {
72
+ if (value.component) {
73
+ const Component = value.component;
74
+ return /* @__PURE__ */ jsx3(Component, { store: form.store, name });
75
+ }
76
+ if (value.type === "textarea") {
77
+ return /* @__PURE__ */ jsx3(
78
+ TextEditor,
206
79
  {
80
+ store: form.store,
207
81
  name,
208
- type: value.type,
209
- className: "input-form"
82
+ editor: {
83
+ attributes: {
84
+ class: "text-editor-form"
85
+ }
86
+ }
210
87
  }
211
88
  );
212
89
  }
213
- const v = form.store.state[name];
214
- if (typeof v === "boolean") {
215
- return /* @__PURE__ */ jsxs2("div", { className: "flex", children: [
216
- value.label,
217
- /* @__PURE__ */ jsx6("div", { className: "ml-auto", children: /* @__PURE__ */ jsx6(InputComponent, {}) })
218
- ] });
90
+ if (value.options) {
91
+ const Component = value.options;
92
+ return /* @__PURE__ */ jsx3(component.select, { name, className: "select-form", children: /* @__PURE__ */ jsx3(Component, {}) });
219
93
  }
220
- return /* @__PURE__ */ jsx6(FormRow, { children: /* @__PURE__ */ jsxs2(FormEntry, { children: [
221
- /* @__PURE__ */ jsx6(FormLabel, { children: value.label }, name),
222
- /* @__PURE__ */ jsx6(InputComponent, {})
223
- ] }) }, name);
94
+ return /* @__PURE__ */ jsx3(component.input, { name, type: value.type, className: "input-form" });
95
+ }
96
+ const v = form.store.state[name];
97
+ if (typeof v === "boolean") {
98
+ return /* @__PURE__ */ jsxs("div", { className: "flex", children: [
99
+ value.label,
100
+ /* @__PURE__ */ jsx3("div", { className: "ml-auto", children: /* @__PURE__ */ jsx3(InputComponent, {}) })
101
+ ] });
224
102
  }
225
- ) }) })
103
+ return /* @__PURE__ */ jsx3(FormRow, { children: /* @__PURE__ */ jsxs(FormEntry, { children: [
104
+ /* @__PURE__ */ jsx3(FormLabel, { children: value.label }, name),
105
+ /* @__PURE__ */ jsx3(InputComponent, {})
106
+ ] }) }, name);
107
+ }) }) })
226
108
  ] });
227
109
  }
228
110
  export {
@@ -1,9 +1,8 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import * as react from 'react';
3
2
  import { HTMLInputTypeAttribute, FC, ReactNode } from 'react';
4
3
  import { Store } from 'react-store-input';
5
4
 
6
- type FormColumnValue<TModel> = {
5
+ type FormColumnValue<TModel extends {}> = {
7
6
  label?: string;
8
7
  type?: HTMLInputTypeAttribute | "textarea";
9
8
  defaultValue?: TModel[keyof TModel];
@@ -13,10 +12,10 @@ type FormColumnValue<TModel> = {
13
12
  }>;
14
13
  options?: FC;
15
14
  };
16
- type FormColumns<TModel> = Partial<{
15
+ type FormColumns<TModel extends {}> = Partial<{
17
16
  [K in keyof TModel]: FormColumnValue<TModel>;
18
17
  }>;
19
- type FormContextProps<TModel> = {
18
+ type FormContextProps<TModel extends {}> = {
20
19
  name: string;
21
20
  item?: TModel;
22
21
  store: Store<TModel>;
@@ -25,8 +24,8 @@ type FormContextProps<TModel> = {
25
24
  columns: FormColumns<TModel>;
26
25
  };
27
26
  declare const FormContext: react.Context<{}>;
28
- declare function useFormContext<TModel>(): FormContextProps<TModel>;
29
- type CrudFormProps<TModel> = {
27
+ declare function useFormContext<TModel extends {}>(): FormContextProps<TModel>;
28
+ type CrudFormProps<TModel extends {}> = {
30
29
  primaryKey?: keyof TModel;
31
30
  name: string;
32
31
  prefix: string;
@@ -34,6 +33,6 @@ type CrudFormProps<TModel> = {
34
33
  columns?: FormColumns<TModel>;
35
34
  children?: ReactNode;
36
35
  };
37
- declare function CrudFormProvider<TModel>({ primaryKey, name, prefix, item, columns, children, }: CrudFormProps<TModel>): react_jsx_runtime.JSX.Element;
36
+ declare function CrudFormProvider<TModel extends {}>({ primaryKey, name, prefix, item, columns, children, }: CrudFormProps<TModel>): react.JSX.Element;
38
37
 
39
38
  export { type CrudFormProps, type FormColumnValue, type FormColumns, FormContext, type FormContextProps, CrudFormProvider as default, useFormContext };