dn-react-router-toolkit 0.9.7 → 0.9.9

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 (39) hide show
  1. package/dist/api/default_api_handler.d.mts +1 -1
  2. package/dist/api/default_api_handler.d.ts +1 -1
  3. package/dist/api/index.js +1 -1
  4. package/dist/api/index.mjs +1 -1
  5. package/dist/api/patch_resource_handler.js +1 -1
  6. package/dist/api/patch_resource_handler.mjs +1 -1
  7. package/dist/api/put_resource_handler.js +1 -1
  8. package/dist/api/put_resource_handler.mjs +1 -1
  9. package/dist/api/resource_handler.js +1 -1
  10. package/dist/api/resource_handler.mjs +1 -1
  11. package/dist/client/editor.d.mts +1 -1
  12. package/dist/client/editor.d.ts +1 -1
  13. package/dist/client/index.d.mts +1 -1
  14. package/dist/client/index.d.ts +1 -1
  15. package/dist/client/index.js +2 -2
  16. package/dist/client/index.mjs +1 -1
  17. package/dist/client/store_text_editor.d.mts +1 -1
  18. package/dist/client/store_text_editor.d.ts +1 -1
  19. package/dist/client/store_text_editor.js +2 -2
  20. package/dist/client/store_text_editor.mjs +1 -1
  21. package/dist/crud/crud_form.js +2 -2
  22. package/dist/crud/crud_form.mjs +1 -1
  23. package/dist/crud/index.js +1 -1
  24. package/dist/crud/index.mjs +1 -1
  25. package/dist/post/index.d.mts +1 -4
  26. package/dist/post/index.d.ts +1 -4
  27. package/dist/post/index.js +2 -475
  28. package/dist/post/index.mjs +1 -484
  29. package/dist/post/thumbnail_picker.d.mts +1 -1
  30. package/dist/post/thumbnail_picker.d.ts +1 -1
  31. package/package.json +3 -3
  32. package/dist/post/editor_toolbar.d.mts +0 -10
  33. package/dist/post/editor_toolbar.d.ts +0 -10
  34. package/dist/post/editor_toolbar.js +0 -203
  35. package/dist/post/editor_toolbar.mjs +0 -177
  36. package/dist/post/post_form_page.d.mts +0 -33
  37. package/dist/post/post_form_page.d.ts +0 -33
  38. package/dist/post/post_form_page.js +0 -583
  39. package/dist/post/post_form_page.mjs +0 -560
@@ -10,11 +10,6 @@ function cn(...classes) {
10
10
  // src/utils/date.ts
11
11
  import moment from "moment-timezone";
12
12
 
13
- // src/utils/slug.ts
14
- var toSlug = (str) => {
15
- return str.toLowerCase().replace(/[^a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣ]+/g, "-").replace(/^-|-$/g, "");
16
- };
17
-
18
13
  // src/post/thumbnail_picker.tsx
19
14
  import { jsx } from "react/jsx-runtime";
20
15
  function PostThumbnailPicker({
@@ -79,484 +74,6 @@ function PostThumbnailPicker({
79
74
  index
80
75
  )) });
81
76
  }
82
-
83
- // src/post/editor_toolbar.tsx
84
- import {
85
- GoFileMedia,
86
- GoLink,
87
- GoListOrdered,
88
- GoListUnordered
89
- } from "react-icons/go";
90
-
91
- // src/client/env_loader.tsx
92
- import { useRouteLoaderData } from "react-router";
93
- import { jsx as jsx2 } from "react/jsx-runtime";
94
-
95
- // src/client/file_input.tsx
96
- import {
97
- useRef
98
- } from "react";
99
- import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
100
- function FileInput({
101
- buttonRef,
102
- className,
103
- ref,
104
- children,
105
- onClick,
106
- onChange,
107
- ...props
108
- }) {
109
- const inputRef = useRef(null);
110
- return /* @__PURE__ */ jsxs(Fragment, { children: [
111
- /* @__PURE__ */ jsx3(
112
- "button",
113
- {
114
- ref: buttonRef,
115
- className,
116
- type: "button",
117
- onClick: () => {
118
- inputRef.current?.click();
119
- },
120
- children
121
- }
122
- ),
123
- /* @__PURE__ */ jsx3(
124
- "input",
125
- {
126
- ...props,
127
- type: "file",
128
- ref: inputRef,
129
- style: {
130
- display: "none"
131
- },
132
- onChange: async (e) => {
133
- await onChange?.(e);
134
- if (inputRef.current) {
135
- inputRef.current.value = "";
136
- }
137
- }
138
- }
139
- )
140
- ] });
141
- }
142
-
143
- // src/client/use_user_agent.tsx
144
- import { useRouteLoaderData as useRouteLoaderData2 } from "react-router";
145
-
146
- // src/client/store_text_editor.tsx
147
- import {
148
- TextEditor
149
- } from "dn-react-text-editor";
150
- import { useStoreController } from "react-store-input";
151
- import { useImperativeHandle, useRef as useRef2 } from "react";
152
- import { jsx as jsx4 } from "react/jsx-runtime";
153
- function StoreTextEditor({
154
- store,
155
- name,
156
- getter,
157
- setter,
158
- defaultValue,
159
- ref,
160
- ...props
161
- }) {
162
- const controllerRef = useRef2(null);
163
- useImperativeHandle(
164
- ref,
165
- () => controllerRef.current,
166
- []
167
- );
168
- const { dispatch } = useStoreController(store, {
169
- onSubscribe: (state) => {
170
- const controller = controllerRef.current;
171
- if (!controller) {
172
- return;
173
- }
174
- const getResult = () => {
175
- if (getter) {
176
- return getter(state) || "";
177
- }
178
- if (name) {
179
- return state[name] || "";
180
- }
181
- return "";
182
- };
183
- const result = getResult();
184
- if (controller.value !== result) {
185
- controller.value = result;
186
- }
187
- },
188
- onDispatch: (state) => {
189
- const controller = controllerRef.current;
190
- if (!controller) {
191
- return;
192
- }
193
- if (setter) {
194
- setter(state, controller.value);
195
- return;
196
- }
197
- if (name) {
198
- state[name] = controller.value;
199
- }
200
- }
201
- });
202
- const getDefaultValue = () => {
203
- if (getter) {
204
- return getter(store.state);
205
- }
206
- if (name) {
207
- return store.state[name];
208
- }
209
- return void 0;
210
- };
211
- return /* @__PURE__ */ jsx4(
212
- TextEditor,
213
- {
214
- ...props,
215
- ref: controllerRef,
216
- defaultValue: defaultValue ?? getDefaultValue(),
217
- onChange: (e) => {
218
- dispatch();
219
- props.onChange?.(e);
220
- }
221
- }
222
- );
223
- }
224
-
225
- // src/client/editor.tsx
226
- import { generateMetadata } from "gw-file/client";
227
-
228
- // src/post/editor_toolbar.tsx
229
- import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
230
- function EditorToolbar({
231
- textEditorRef,
232
- className
233
- }) {
234
- return /* @__PURE__ */ jsxs2(
235
- "div",
236
- {
237
- className: cn("w-full h-12 flex items-center gap-0.5 px-1", className),
238
- children: [
239
- /* @__PURE__ */ jsx5(
240
- FileInput,
241
- {
242
- className: "button-icon-base text-[18px]",
243
- onChange: async (e) => {
244
- const files = e.target.files;
245
- if (!files || files.length === 0) {
246
- return;
247
- }
248
- textEditorRef.current?.commands.attachFile(Array.from(files));
249
- },
250
- children: /* @__PURE__ */ jsx5(GoFileMedia, {})
251
- }
252
- ),
253
- /* @__PURE__ */ jsx5(
254
- "button",
255
- {
256
- type: "button",
257
- onClick: () => {
258
- const href = prompt("\uB9C1\uD06C URL\uC744 \uC785\uB825\uD558\uC138\uC694");
259
- if (!href) {
260
- return;
261
- }
262
- textEditorRef.current?.commands.toggleMark("link", { href });
263
- },
264
- className: "button-icon-base text-[20px]",
265
- children: /* @__PURE__ */ jsx5(GoLink, {})
266
- }
267
- ),
268
- /* @__PURE__ */ jsx5(
269
- "button",
270
- {
271
- type: "button",
272
- onClick: () => {
273
- textEditorRef.current?.commands.toggleBlockType("heading", {
274
- level: 2
275
- });
276
- },
277
- className: "button-icon-base text-[18px]",
278
- children: /* @__PURE__ */ jsx5("span", { children: "H2" })
279
- }
280
- ),
281
- /* @__PURE__ */ jsx5(
282
- "button",
283
- {
284
- type: "button",
285
- onClick: () => {
286
- textEditorRef.current?.commands.toggleBlockType("heading", {
287
- level: 3
288
- });
289
- },
290
- className: "button-icon-base text-[18px]",
291
- children: /* @__PURE__ */ jsx5("span", { children: "H3" })
292
- }
293
- ),
294
- /* @__PURE__ */ jsx5(
295
- "button",
296
- {
297
- type: "button",
298
- onClick: () => {
299
- textEditorRef.current?.commands.wrapInList("ordered_list");
300
- },
301
- className: "button-icon-base text-[20px]",
302
- children: /* @__PURE__ */ jsx5(GoListOrdered, {})
303
- }
304
- ),
305
- /* @__PURE__ */ jsx5(
306
- "button",
307
- {
308
- type: "button",
309
- onClick: () => {
310
- textEditorRef.current?.commands.wrapInList("bullet_list");
311
- },
312
- className: "button-icon-base text-[20px]",
313
- children: /* @__PURE__ */ jsx5(GoListUnordered, {})
314
- }
315
- )
316
- ]
317
- }
318
- );
319
- }
320
-
321
- // src/post/post_form_page.tsx
322
- import { useLoaderData } from "react-router";
323
- import { useStoreComponent as useStoreComponent2 } from "react-store-input";
324
- import { useRef as useRef3 } from "react";
325
- import "dn-react-text-editor";
326
-
327
- // src/crud/crud_form_provider.tsx
328
- import { useNavigate } from "react-router";
329
- import { useStore } from "react-store-input";
330
- import {
331
- createContext,
332
- useContext
333
- } from "react";
334
- import { jsx as jsx6 } from "react/jsx-runtime";
335
- var FormContext = createContext({});
336
-
337
- // src/form/create_form_component.tsx
338
- import "react";
339
- import { jsx as jsx7 } from "react/jsx-runtime";
340
- function createComponent(tag, options) {
341
- return function FormComponent({ className, ...props }) {
342
- const Tag = tag;
343
- return /* @__PURE__ */ jsx7(Tag, { ...props, className: cn(options.className, className) });
344
- };
345
- }
346
-
347
- // src/form/form_components.tsx
348
- var FormEntry = createComponent("div", {
349
- className: "flex-1"
350
- });
351
- var FormRow = createComponent("div", {
352
- className: "flex-1 flex gap-4 mb-6"
353
- });
354
- var FormLabel = createComponent("label", {
355
- className: "flex-1 font-semibold mb-2.5 block"
356
- });
357
-
358
- // src/crud/crud_form.tsx
359
- import { useStoreComponent } from "react-store-input";
360
- import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
361
-
362
- // src/post/post_form_page.tsx
363
- import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
364
- var createPostFormPage = ({
365
- header: AdminPageHeader,
366
- textEditorClassName,
367
- attachFile
368
- }) => {
369
- return function PostFormPage({ form }) {
370
- const { boards } = useLoaderData();
371
- const component = useStoreComponent2(form.store);
372
- const textEditorRef = useRef3(null);
373
- return /* @__PURE__ */ jsxs4(Fragment3, { children: [
374
- /* @__PURE__ */ jsx9(
375
- AdminPageHeader,
376
- {
377
- title: `${form.name} \uCD94\uAC00`,
378
- actions: /* @__PURE__ */ jsxs4(Fragment3, { children: [
379
- /* @__PURE__ */ jsx9(
380
- "button",
381
- {
382
- type: "button",
383
- className: "button-outline",
384
- onClick: () => {
385
- form.delete();
386
- },
387
- children: "\uC0AD\uC81C\uD558\uAE30"
388
- }
389
- ),
390
- /* @__PURE__ */ jsx9(
391
- "button",
392
- {
393
- type: "button",
394
- className: "button-primary",
395
- onClick: () => {
396
- form.submit();
397
- },
398
- children: "\uC800\uC7A5\uD558\uAE30"
399
- }
400
- )
401
- ] })
402
- }
403
- ),
404
- /* @__PURE__ */ jsx9("div", { className: "px-4", children: /* @__PURE__ */ jsxs4("div", { className: "max-w-7xl mx-auto w-full", children: [
405
- /* @__PURE__ */ jsxs4(FormRow, { children: [
406
- /* @__PURE__ */ jsxs4(FormEntry, { children: [
407
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uACF5\uAC1C\uC5EC\uBD80" }),
408
- /* @__PURE__ */ jsxs4(
409
- component.select,
410
- {
411
- name: "isPublic",
412
- className: "select-form",
413
- toInputValue: (value) => value ? "true" : "false",
414
- toStateValue: (value) => Boolean(value === "true"),
415
- children: [
416
- /* @__PURE__ */ jsx9("option", { value: "true", children: "\uACF5\uAC1C" }),
417
- /* @__PURE__ */ jsx9("option", { value: "false", children: "\uBE44\uACF5\uAC1C" })
418
- ]
419
- }
420
- )
421
- ] }),
422
- /* @__PURE__ */ jsxs4(FormEntry, { children: [
423
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uC791\uC131\uC77C\uC2DC" }),
424
- /* @__PURE__ */ jsx9(
425
- component.input,
426
- {
427
- name: "createdAt",
428
- className: "input-form",
429
- type: "datetime-local"
430
- }
431
- )
432
- ] })
433
- ] }),
434
- /* @__PURE__ */ jsxs4(FormRow, { children: [
435
- /* @__PURE__ */ jsxs4(FormEntry, { children: [
436
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uAC8C\uC2DC\uD310" }),
437
- /* @__PURE__ */ jsxs4(component.select, { name: "boardId", className: "select-form", children: [
438
- /* @__PURE__ */ jsx9("option", { value: "", children: "\uC120\uD0DD\uD558\uC138\uC694" }),
439
- boards.map((board) => /* @__PURE__ */ jsx9("option", { value: board.id, children: board.title }, board.id))
440
- ] })
441
- ] }),
442
- /* @__PURE__ */ jsxs4(FormEntry, { children: [
443
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uCE74\uD14C\uACE0\uB9AC" }),
444
- /* @__PURE__ */ jsx9(
445
- component.input,
446
- {
447
- name: "category",
448
- className: "input-form",
449
- placeholder: "\uCE74\uD14C\uACE0\uB9AC"
450
- }
451
- )
452
- ] })
453
- ] }),
454
- /* @__PURE__ */ jsxs4(FormRow, { children: [
455
- /* @__PURE__ */ jsxs4(FormEntry, { children: [
456
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uC81C\uBAA9" }),
457
- /* @__PURE__ */ jsx9(
458
- component.input,
459
- {
460
- name: "title",
461
- className: "input-form",
462
- placeholder: "\uC81C\uBAA9\uC744 \uC785\uB825\uD558\uC138\uC694",
463
- onChange: (e) => {
464
- const title = e.target.value;
465
- form.store.dispatch((state) => {
466
- state.slug = toSlug(title);
467
- });
468
- }
469
- }
470
- )
471
- ] }),
472
- /* @__PURE__ */ jsxs4(FormEntry, { children: [
473
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uBD80\uC81C\uBAA9" }),
474
- /* @__PURE__ */ jsx9(
475
- component.input,
476
- {
477
- name: "subtitle",
478
- className: "input-form",
479
- placeholder: "\uBD80\uC81C\uBAA9\uC744 \uC785\uB825\uD558\uC138\uC694"
480
- }
481
- )
482
- ] })
483
- ] }),
484
- /* @__PURE__ */ jsxs4(FormRow, { children: [
485
- /* @__PURE__ */ jsxs4(FormEntry, { children: [
486
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uC2AC\uB7EC\uADF8" }),
487
- /* @__PURE__ */ jsx9(
488
- component.input,
489
- {
490
- name: "slug",
491
- className: "input-form",
492
- placeholder: "\uC81C\uBAA9"
493
- }
494
- )
495
- ] }),
496
- /* @__PURE__ */ jsxs4(FormEntry, { children: [
497
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uD0DC\uADF8" }),
498
- /* @__PURE__ */ jsx9(
499
- component.input,
500
- {
501
- name: "tags",
502
- className: "input-form",
503
- placeholder: "\uD0DC\uADF8 1, \uD0DC\uADF8 2, \uD0DC\uADF8 3"
504
- }
505
- )
506
- ] })
507
- ] }),
508
- /* @__PURE__ */ jsx9(FormRow, { children: /* @__PURE__ */ jsxs4(FormEntry, { children: [
509
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uC124\uBA85" }),
510
- /* @__PURE__ */ jsx9(
511
- StoreTextEditor,
512
- {
513
- store: form.store,
514
- mode: "text",
515
- name: "description",
516
- className: "text-editor min-h-[80px]",
517
- placeholder: "\uC124\uBA85"
518
- }
519
- )
520
- ] }) }),
521
- /* @__PURE__ */ jsx9(FormRow, { children: /* @__PURE__ */ jsxs4(FormEntry, { children: [
522
- /* @__PURE__ */ jsx9(FormLabel, { children: "\uC378\uB124\uC77C" }),
523
- /* @__PURE__ */ jsx9(
524
- PostThumbnailPicker,
525
- {
526
- store: form.store,
527
- textEditorRef
528
- }
529
- )
530
- ] }) })
531
- ] }) }),
532
- /* @__PURE__ */ jsx9("div", { className: "sticky top-[160px] z-998 bg-white px-4", children: /* @__PURE__ */ jsx9(
533
- EditorToolbar,
534
- {
535
- textEditorRef,
536
- className: "max-w-7xl mx-auto"
537
- }
538
- ) }),
539
- /* @__PURE__ */ jsx9("div", { className: "px-4", children: /* @__PURE__ */ jsx9(
540
- StoreTextEditor,
541
- {
542
- ref: textEditorRef,
543
- store: form.store,
544
- name: "html",
545
- placeholder: "\uC5EC\uAE30\uC5D0 \uBCF8\uBB38\uC744 \uC791\uC131\uD558\uC138\uC694...",
546
- updateDelay: 500,
547
- editor: {
548
- attributes: {
549
- class: cn(textEditorClassName, "pb-[50vh]")
550
- }
551
- },
552
- attachFile
553
- }
554
- ) })
555
- ] });
556
- };
557
- };
558
77
  export {
559
- EditorToolbar,
560
- PostThumbnailPicker,
561
- createPostFormPage
78
+ PostThumbnailPicker
562
79
  };
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Store } from 'react-store-input';
3
3
  import { RefObject } from 'react';
4
- import { TextEditorController } from 'dn-react-text-editor';
4
+ import { TextEditorController } from 'gw-react-text-editor';
5
5
 
6
6
  declare function PostThumbnailPicker<T extends {
7
7
  thumbnail: string | null;
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Store } from 'react-store-input';
3
3
  import { RefObject } from 'react';
4
- import { TextEditorController } from 'dn-react-text-editor';
4
+ import { TextEditorController } from 'gw-react-text-editor';
5
5
 
6
6
  declare function PostThumbnailPicker<T extends {
7
7
  thumbnail: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-router-toolkit",
3
- "version": "0.9.7",
3
+ "version": "0.9.9",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",
@@ -87,9 +87,9 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "cookie": "^1.1.1",
90
- "dn-react-text-editor": "^0.3.11",
90
+ "gw-react-text-editor": "^0.1.0",
91
91
  "gw-auth": "^0.1.2",
92
- "gw-file": "^0.1.2",
92
+ "gw-file": "^0.1.3",
93
93
  "gw-response": "^0.1.8",
94
94
  "gw-result": "^0.1.8",
95
95
  "moment-timezone": "^0.6.1",
@@ -1,10 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { TextEditorController } from 'dn-react-text-editor';
3
- import { RefObject } from 'react';
4
-
5
- declare function EditorToolbar({ textEditorRef, className, }: {
6
- textEditorRef: RefObject<TextEditorController | null>;
7
- className?: string;
8
- }): react_jsx_runtime.JSX.Element;
9
-
10
- export { EditorToolbar };
@@ -1,10 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { TextEditorController } from 'dn-react-text-editor';
3
- import { RefObject } from 'react';
4
-
5
- declare function EditorToolbar({ textEditorRef, className, }: {
6
- textEditorRef: RefObject<TextEditorController | null>;
7
- className?: string;
8
- }): react_jsx_runtime.JSX.Element;
9
-
10
- export { EditorToolbar };