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