dn-react-router-toolkit 0.7.6 → 0.7.8

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 (95) hide show
  1. package/dist/api/create_api_handler.d.mts +5 -5
  2. package/dist/api/create_api_handler.d.ts +5 -5
  3. package/dist/api/index.d.mts +7 -0
  4. package/dist/api/index.d.ts +7 -0
  5. package/dist/api/index.js +163 -2
  6. package/dist/api/index.mjs +169 -1
  7. package/dist/client/env_loader.d.mts +2 -2
  8. package/dist/client/env_loader.d.ts +2 -2
  9. package/dist/client/env_loader.js +2 -12
  10. package/dist/client/env_loader.mjs +2 -2
  11. package/dist/client/file_input.d.mts +3 -2
  12. package/dist/client/file_input.d.ts +3 -2
  13. package/dist/client/file_input.js +30 -37
  14. package/dist/client/file_input.mjs +33 -28
  15. package/dist/client/index.d.mts +1 -0
  16. package/dist/client/index.d.ts +1 -0
  17. package/dist/client/index.js +38 -44
  18. package/dist/client/index.mjs +39 -33
  19. package/dist/client/store_text_editor.d.mts +2 -2
  20. package/dist/client/store_text_editor.d.ts +2 -2
  21. package/dist/client/store_text_editor.js +3 -12
  22. package/dist/client/store_text_editor.mjs +3 -2
  23. package/dist/crud/crud_form.d.mts +5 -4
  24. package/dist/crud/crud_form.d.ts +5 -4
  25. package/dist/crud/crud_form.js +74 -72
  26. package/dist/crud/crud_form.mjs +79 -62
  27. package/dist/crud/crud_form_provider.d.mts +9 -7
  28. package/dist/crud/crud_form_provider.d.ts +9 -7
  29. package/dist/crud/crud_form_provider.js +2 -12
  30. package/dist/crud/crud_form_provider.mjs +6 -3
  31. package/dist/crud/crud_page.d.mts +10 -6
  32. package/dist/crud/crud_page.d.ts +10 -6
  33. package/dist/crud/crud_page.js +272 -409
  34. package/dist/crud/crud_page.mjs +277 -399
  35. package/dist/crud/generate_pages.d.mts +10 -2
  36. package/dist/crud/generate_pages.d.ts +10 -2
  37. package/dist/crud/generate_pages.js +17 -14
  38. package/dist/crud/generate_pages.mjs +17 -4
  39. package/dist/crud/index.d.mts +2 -1
  40. package/dist/crud/index.d.ts +2 -1
  41. package/dist/crud/index.js +290 -404
  42. package/dist/crud/index.mjs +295 -404
  43. package/dist/form/create_form_component.d.mts +3 -2
  44. package/dist/form/create_form_component.d.ts +3 -2
  45. package/dist/form/create_form_component.js +3 -12
  46. package/dist/form/create_form_component.mjs +3 -2
  47. package/dist/form/form_components.d.mts +5 -4
  48. package/dist/form/form_components.d.ts +5 -4
  49. package/dist/form/form_components.js +3 -12
  50. package/dist/form/form_components.mjs +3 -2
  51. package/dist/form/index.d.mts +1 -0
  52. package/dist/form/index.d.ts +1 -0
  53. package/dist/form/index.js +3 -12
  54. package/dist/form/index.mjs +3 -2
  55. package/dist/post/editor_toolbar.d.mts +4 -3
  56. package/dist/post/editor_toolbar.d.ts +4 -3
  57. package/dist/post/editor_toolbar.js +116 -273
  58. package/dist/post/editor_toolbar.mjs +123 -263
  59. package/dist/post/index.d.mts +1 -0
  60. package/dist/post/index.d.ts +1 -0
  61. package/dist/post/index.js +329 -411
  62. package/dist/post/index.mjs +337 -409
  63. package/dist/post/post_form_page.d.mts +5 -4
  64. package/dist/post/post_form_page.d.ts +5 -4
  65. package/dist/post/post_form_page.js +331 -413
  66. package/dist/post/post_form_page.mjs +337 -409
  67. package/dist/post/thumbnail_picker.d.mts +3 -2
  68. package/dist/post/thumbnail_picker.d.ts +3 -2
  69. package/dist/post/thumbnail_picker.js +14 -23
  70. package/dist/post/thumbnail_picker.mjs +14 -13
  71. package/dist/seo/index.d.mts +1 -1
  72. package/dist/seo/index.d.ts +1 -1
  73. package/dist/seo/index.js +2 -2
  74. package/dist/seo/index.mjs +2 -2
  75. package/dist/seo/seo.d.mts +2 -2
  76. package/dist/seo/seo.d.ts +2 -2
  77. package/dist/seo/seo.js +2 -2
  78. package/dist/seo/seo.mjs +2 -2
  79. package/dist/table/buttons.d.mts +2 -2
  80. package/dist/table/buttons.d.ts +2 -2
  81. package/dist/table/buttons.js +42 -57
  82. package/dist/table/buttons.mjs +42 -47
  83. package/dist/table/index.d.mts +1 -0
  84. package/dist/table/index.d.ts +1 -0
  85. package/dist/table/index.js +185 -338
  86. package/dist/table/index.mjs +185 -328
  87. package/dist/table/page.d.mts +5 -4
  88. package/dist/table/page.d.ts +5 -4
  89. package/dist/table/page.js +185 -338
  90. package/dist/table/page.mjs +185 -328
  91. package/dist/table/table.d.mts +5 -4
  92. package/dist/table/table.d.ts +5 -4
  93. package/dist/table/table.js +77 -237
  94. package/dist/table/table.mjs +77 -227
  95. package/package.json +7 -5
@@ -1,4 +1,4 @@
1
- import { Table, InferInsertModel, SQLWrapper } from 'drizzle-orm';
1
+ import { Table, InferSelectModel, SQLWrapper } from 'drizzle-orm';
2
2
  import { ActionFunctionArgs, LoaderFunctionArgs } from 'react-router';
3
3
  import { TableRepository } from '../table/repository.mjs';
4
4
  import { WithAuthHandler } from '../auth/with_auth.mjs';
@@ -10,13 +10,13 @@ type APIHandlerOptions<T extends Table, TSelect> = {
10
10
  withAuthAction: WithAuthHandler<ActionFunctionArgs>;
11
11
  repository: TableRepository<T, TSelect>;
12
12
  validators?: {
13
- [K in keyof InferInsertModel<T>]?: {
14
- validate?: (value?: InferInsertModel<T>[K]) => boolean;
15
- message?: (value?: InferInsertModel<T>[K]) => string;
13
+ [K in keyof InferSelectModel<T>]?: {
14
+ validate?: (value?: InferSelectModel<T>[K]) => boolean;
15
+ message?: (value?: InferSelectModel<T>[K]) => string;
16
16
  };
17
17
  };
18
18
  existingConditions?: {
19
- [K in keyof InferInsertModel<T>]?: (value: InferInsertModel<T>[K]) => SQLWrapper;
19
+ [K in keyof InferSelectModel<T>]?: (value: InferSelectModel<T>[K]) => SQLWrapper;
20
20
  };
21
21
  injectUserId?: boolean;
22
22
  roles?: string[];
@@ -1,4 +1,4 @@
1
- import { Table, InferInsertModel, SQLWrapper } from 'drizzle-orm';
1
+ import { Table, InferSelectModel, SQLWrapper } from 'drizzle-orm';
2
2
  import { ActionFunctionArgs, LoaderFunctionArgs } from 'react-router';
3
3
  import { TableRepository } from '../table/repository.js';
4
4
  import { WithAuthHandler } from '../auth/with_auth.js';
@@ -10,13 +10,13 @@ type APIHandlerOptions<T extends Table, TSelect> = {
10
10
  withAuthAction: WithAuthHandler<ActionFunctionArgs>;
11
11
  repository: TableRepository<T, TSelect>;
12
12
  validators?: {
13
- [K in keyof InferInsertModel<T>]?: {
14
- validate?: (value?: InferInsertModel<T>[K]) => boolean;
15
- message?: (value?: InferInsertModel<T>[K]) => string;
13
+ [K in keyof InferSelectModel<T>]?: {
14
+ validate?: (value?: InferSelectModel<T>[K]) => boolean;
15
+ message?: (value?: InferSelectModel<T>[K]) => string;
16
16
  };
17
17
  };
18
18
  existingConditions?: {
19
- [K in keyof InferInsertModel<T>]?: (value: InferInsertModel<T>[K]) => SQLWrapper;
19
+ [K in keyof InferSelectModel<T>]?: (value: InferSelectModel<T>[K]) => SQLWrapper;
20
20
  };
21
21
  injectUserId?: boolean;
22
22
  roles?: string[];
@@ -1,4 +1,11 @@
1
1
  export { createAPIHandler } from './create_handler.mjs';
2
+ export { APIHandlerOptions, apiHandler } from './create_api_handler.mjs';
3
+ export { ItemAPIHandlerOptions, itemApiHandler } from './item_api_handler.mjs';
2
4
  import 'react-router';
3
5
  import 'dn-react-toolkit/auth/server';
4
6
  import 'dn-react-toolkit/file/server';
7
+ import 'drizzle-orm';
8
+ import '../table/repository.mjs';
9
+ import 'drizzle-orm/pg-core';
10
+ import '../auth/with_auth.mjs';
11
+ import 'dn-react-toolkit/auth';
@@ -1,4 +1,11 @@
1
1
  export { createAPIHandler } from './create_handler.js';
2
+ export { APIHandlerOptions, apiHandler } from './create_api_handler.js';
3
+ export { ItemAPIHandlerOptions, itemApiHandler } from './item_api_handler.js';
2
4
  import 'react-router';
3
5
  import 'dn-react-toolkit/auth/server';
4
6
  import 'dn-react-toolkit/file/server';
7
+ import 'drizzle-orm';
8
+ import '../table/repository.js';
9
+ import 'drizzle-orm/pg-core';
10
+ import '../auth/with_auth.js';
11
+ import 'dn-react-toolkit/auth';
package/dist/api/index.js CHANGED
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/api/index.ts
21
21
  var api_exports = {};
22
22
  __export(api_exports, {
23
- createAPIHandler: () => createAPIHandler
23
+ apiHandler: () => apiHandler,
24
+ createAPIHandler: () => createAPIHandler,
25
+ itemApiHandler: () => itemApiHandler
24
26
  });
25
27
  module.exports = __toCommonJS(api_exports);
26
28
 
@@ -237,7 +239,166 @@ var createAPIHandler = ({
237
239
  };
238
240
  return handler;
239
241
  };
242
+
243
+ // src/api/create_api_handler.ts
244
+ var import_http2 = require("dn-react-toolkit/http");
245
+ var import_drizzle_orm = require("drizzle-orm");
246
+ var import_react_router2 = require("react-router");
247
+ var import_uuid2 = require("uuid");
248
+
249
+ // src/crud/serialize.ts
250
+ function deserialize(data) {
251
+ if (data === void 0) {
252
+ return void 0;
253
+ }
254
+ if (typeof data === "object" && data !== null && "type" in data && "value" in data) {
255
+ const { type, value } = data;
256
+ switch (type) {
257
+ case "null":
258
+ return null;
259
+ case "string":
260
+ return value;
261
+ case "number":
262
+ return value;
263
+ case "boolean":
264
+ return value;
265
+ case "date":
266
+ return new Date(value);
267
+ case "array":
268
+ return value.map((item) => deserialize(item));
269
+ case "object":
270
+ return Object.entries(value).reduce(
271
+ (acc, [key, value2]) => {
272
+ return {
273
+ ...acc,
274
+ [key]: deserialize(value2)
275
+ };
276
+ },
277
+ {}
278
+ );
279
+ default:
280
+ return void 0;
281
+ }
282
+ }
283
+ return void 0;
284
+ }
285
+
286
+ // src/api/create_api_handler.ts
287
+ function apiHandler({
288
+ withAuthAction,
289
+ repository,
290
+ validators,
291
+ existingConditions,
292
+ injectUserId,
293
+ roles
294
+ }) {
295
+ const loader = async ({ request }) => {
296
+ return {};
297
+ };
298
+ const action = withAuthAction((auth) => async ({ request }) => {
299
+ if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
300
+ throw (0, import_http2.UNAUTHORIZED)();
301
+ }
302
+ switch (request.method) {
303
+ case "POST":
304
+ case "PUT": {
305
+ try {
306
+ const serilaizedParams = await request.json();
307
+ const params = deserialize(serilaizedParams);
308
+ if (validators) {
309
+ const paramsForValidation = Object.keys(validators).filter(
310
+ (key) => Object.prototype.hasOwnProperty.call(validators, key)
311
+ );
312
+ for (const paramKey of paramsForValidation) {
313
+ const value = params[paramKey];
314
+ const validator = validators[paramKey];
315
+ if (validator?.validate && !validator.validate(value)) {
316
+ throw (0, import_http2.BAD_REQUEST)(
317
+ validator.message ? validator.message(value) : void 0
318
+ );
319
+ }
320
+ }
321
+ }
322
+ const itemId = params.id || (0, import_uuid2.v4)();
323
+ if (!params.id && existingConditions) {
324
+ const paramsForExistenceCheck = Object.keys(
325
+ existingConditions
326
+ ).filter(
327
+ (key) => Object.prototype.hasOwnProperty.call(params, key)
328
+ );
329
+ if (paramsForExistenceCheck.length > 0) {
330
+ const where = (0, import_drizzle_orm.and)(
331
+ ...paramsForExistenceCheck.reduce((acc, key) => {
332
+ const condition = existingConditions[key];
333
+ if (condition) {
334
+ acc.push(condition(params[key]));
335
+ }
336
+ return acc;
337
+ }, [])
338
+ );
339
+ const existing = await repository.findAll({
340
+ limit: 1,
341
+ where
342
+ });
343
+ if (existing.length > 0) {
344
+ throw (0, import_http2.CONFLICT)("\uC790\uB8CC\uAC00 \uC774\uBBF8 \uC874\uC7AC\uD569\uB2C8\uB2E4.");
345
+ }
346
+ }
347
+ }
348
+ const values = {
349
+ id: itemId,
350
+ userId: injectUserId ? auth?.userId : void 0,
351
+ ...params
352
+ };
353
+ const item = await repository.save(values);
354
+ return (0, import_http2.CREATED)(item);
355
+ } catch (error) {
356
+ if (error instanceof Error) {
357
+ throw (0, import_http2.INTERNAL_SERVER_ERROR)(error.message);
358
+ }
359
+ throw error;
360
+ }
361
+ }
362
+ default:
363
+ throw (0, import_http2.METHOD_NOT_ALLOWED)();
364
+ }
365
+ });
366
+ return {
367
+ loader,
368
+ action
369
+ };
370
+ }
371
+
372
+ // src/api/item_api_handler.ts
373
+ var import_http3 = require("dn-react-toolkit/http");
374
+ var import_react_router3 = require("react-router");
375
+ function itemApiHandler({
376
+ withAuthAction,
377
+ repository
378
+ }) {
379
+ const loader = async ({ request }) => {
380
+ return {};
381
+ };
382
+ const action = withAuthAction((auth) => async ({ params, request }) => {
383
+ if (!auth || auth.role !== "admin") {
384
+ return (0, import_http3.UNAUTHORIZED)();
385
+ }
386
+ switch (request.method) {
387
+ case "DELETE": {
388
+ const itemId = params.itemId;
389
+ await repository.delete(itemId);
390
+ return {};
391
+ }
392
+ }
393
+ });
394
+ return {
395
+ loader,
396
+ action
397
+ };
398
+ }
240
399
  // Annotate the CommonJS export names for ESM import in node:
241
400
  0 && (module.exports = {
242
- createAPIHandler
401
+ apiHandler,
402
+ createAPIHandler,
403
+ itemApiHandler
243
404
  });
@@ -225,6 +225,174 @@ var createAPIHandler = ({
225
225
  };
226
226
  return handler;
227
227
  };
228
+
229
+ // src/api/create_api_handler.ts
230
+ import {
231
+ BAD_REQUEST,
232
+ CONFLICT,
233
+ CREATED,
234
+ INTERNAL_SERVER_ERROR,
235
+ METHOD_NOT_ALLOWED,
236
+ UNAUTHORIZED
237
+ } from "dn-react-toolkit/http";
238
+ import {
239
+ and
240
+ } from "drizzle-orm";
241
+ import "react-router";
242
+ import { v4 as v42 } from "uuid";
243
+
244
+ // src/crud/serialize.ts
245
+ function deserialize(data) {
246
+ if (data === void 0) {
247
+ return void 0;
248
+ }
249
+ if (typeof data === "object" && data !== null && "type" in data && "value" in data) {
250
+ const { type, value } = data;
251
+ switch (type) {
252
+ case "null":
253
+ return null;
254
+ case "string":
255
+ return value;
256
+ case "number":
257
+ return value;
258
+ case "boolean":
259
+ return value;
260
+ case "date":
261
+ return new Date(value);
262
+ case "array":
263
+ return value.map((item) => deserialize(item));
264
+ case "object":
265
+ return Object.entries(value).reduce(
266
+ (acc, [key, value2]) => {
267
+ return {
268
+ ...acc,
269
+ [key]: deserialize(value2)
270
+ };
271
+ },
272
+ {}
273
+ );
274
+ default:
275
+ return void 0;
276
+ }
277
+ }
278
+ return void 0;
279
+ }
280
+
281
+ // src/api/create_api_handler.ts
282
+ function apiHandler({
283
+ withAuthAction,
284
+ repository,
285
+ validators,
286
+ existingConditions,
287
+ injectUserId,
288
+ roles
289
+ }) {
290
+ const loader = async ({ request }) => {
291
+ return {};
292
+ };
293
+ const action = withAuthAction((auth) => async ({ request }) => {
294
+ if (roles && roles.length > 0 && (!auth || !roles.includes(auth.role))) {
295
+ throw UNAUTHORIZED();
296
+ }
297
+ switch (request.method) {
298
+ case "POST":
299
+ case "PUT": {
300
+ try {
301
+ const serilaizedParams = await request.json();
302
+ const params = deserialize(serilaizedParams);
303
+ if (validators) {
304
+ const paramsForValidation = Object.keys(validators).filter(
305
+ (key) => Object.prototype.hasOwnProperty.call(validators, key)
306
+ );
307
+ for (const paramKey of paramsForValidation) {
308
+ const value = params[paramKey];
309
+ const validator = validators[paramKey];
310
+ if (validator?.validate && !validator.validate(value)) {
311
+ throw BAD_REQUEST(
312
+ validator.message ? validator.message(value) : void 0
313
+ );
314
+ }
315
+ }
316
+ }
317
+ const itemId = params.id || v42();
318
+ if (!params.id && existingConditions) {
319
+ const paramsForExistenceCheck = Object.keys(
320
+ existingConditions
321
+ ).filter(
322
+ (key) => Object.prototype.hasOwnProperty.call(params, key)
323
+ );
324
+ if (paramsForExistenceCheck.length > 0) {
325
+ const where = and(
326
+ ...paramsForExistenceCheck.reduce((acc, key) => {
327
+ const condition = existingConditions[key];
328
+ if (condition) {
329
+ acc.push(condition(params[key]));
330
+ }
331
+ return acc;
332
+ }, [])
333
+ );
334
+ const existing = await repository.findAll({
335
+ limit: 1,
336
+ where
337
+ });
338
+ if (existing.length > 0) {
339
+ throw CONFLICT("\uC790\uB8CC\uAC00 \uC774\uBBF8 \uC874\uC7AC\uD569\uB2C8\uB2E4.");
340
+ }
341
+ }
342
+ }
343
+ const values = {
344
+ id: itemId,
345
+ userId: injectUserId ? auth?.userId : void 0,
346
+ ...params
347
+ };
348
+ const item = await repository.save(values);
349
+ return CREATED(item);
350
+ } catch (error) {
351
+ if (error instanceof Error) {
352
+ throw INTERNAL_SERVER_ERROR(error.message);
353
+ }
354
+ throw error;
355
+ }
356
+ }
357
+ default:
358
+ throw METHOD_NOT_ALLOWED();
359
+ }
360
+ });
361
+ return {
362
+ loader,
363
+ action
364
+ };
365
+ }
366
+
367
+ // src/api/item_api_handler.ts
368
+ import { UNAUTHORIZED as UNAUTHORIZED2 } from "dn-react-toolkit/http";
369
+ import "react-router";
370
+ function itemApiHandler({
371
+ withAuthAction,
372
+ repository
373
+ }) {
374
+ const loader = async ({ request }) => {
375
+ return {};
376
+ };
377
+ const action = withAuthAction((auth) => async ({ params, request }) => {
378
+ if (!auth || auth.role !== "admin") {
379
+ return UNAUTHORIZED2();
380
+ }
381
+ switch (request.method) {
382
+ case "DELETE": {
383
+ const itemId = params.itemId;
384
+ await repository.delete(itemId);
385
+ return {};
386
+ }
387
+ }
388
+ });
389
+ return {
390
+ loader,
391
+ action
392
+ };
393
+ }
228
394
  export {
229
- createAPIHandler
395
+ apiHandler,
396
+ createAPIHandler,
397
+ itemApiHandler
230
398
  };
@@ -1,7 +1,7 @@
1
- import React__default from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
3
  declare function EnvLoader({ dataKey }: {
4
4
  dataKey?: string;
5
- }): React__default.JSX.Element | undefined;
5
+ }): react_jsx_runtime.JSX.Element | undefined;
6
6
 
7
7
  export { EnvLoader };
@@ -1,7 +1,7 @@
1
- import React__default from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
 
3
3
  declare function EnvLoader({ dataKey }: {
4
4
  dataKey?: string;
5
- }): React__default.JSX.Element | undefined;
5
+ }): react_jsx_runtime.JSX.Element | undefined;
6
6
 
7
7
  export { EnvLoader };
@@ -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/client/env_loader.tsx
@@ -33,14 +23,14 @@ __export(env_loader_exports, {
33
23
  EnvLoader: () => EnvLoader
34
24
  });
35
25
  module.exports = __toCommonJS(env_loader_exports);
36
- var import_react = __toESM(require("react"));
37
26
  var import_react_router = require("react-router");
27
+ var import_jsx_runtime = require("react/jsx-runtime");
38
28
  function EnvLoader({ dataKey = "ENV" }) {
39
29
  const data = (0, import_react_router.useRouteLoaderData)("root");
40
30
  if (!data) {
41
31
  return;
42
32
  }
43
- return /* @__PURE__ */ import_react.default.createElement(
33
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
44
34
  "script",
45
35
  {
46
36
  dangerouslySetInnerHTML: {
@@ -1,12 +1,12 @@
1
1
  // src/client/env_loader.tsx
2
- import React from "react";
3
2
  import { useRouteLoaderData } from "react-router";
3
+ import { jsx } from "react/jsx-runtime";
4
4
  function EnvLoader({ dataKey = "ENV" }) {
5
5
  const data = useRouteLoaderData("root");
6
6
  if (!data) {
7
7
  return;
8
8
  }
9
- return /* @__PURE__ */ React.createElement(
9
+ return /* @__PURE__ */ jsx(
10
10
  "script",
11
11
  {
12
12
  dangerouslySetInnerHTML: {
@@ -1,10 +1,11 @@
1
- import React__default, { DetailedHTMLProps, InputHTMLAttributes, Ref, ChangeEvent } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { DetailedHTMLProps, InputHTMLAttributes, Ref, ChangeEvent } from 'react';
2
3
 
3
4
  type Props = Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "onChange"> & {
4
5
  buttonRef?: Ref<HTMLButtonElement>;
5
6
  } & {
6
7
  onChange?: (event: ChangeEvent<HTMLInputElement>) => void | Promise<void>;
7
8
  };
8
- declare function FileInput({ buttonRef, className, ref, children, onClick, onChange, ...props }: Props): React__default.JSX.Element;
9
+ declare function FileInput({ buttonRef, className, ref, children, onClick, onChange, ...props }: Props): react_jsx_runtime.JSX.Element;
9
10
 
10
11
  export { FileInput };
@@ -1,10 +1,11 @@
1
- import React__default, { DetailedHTMLProps, InputHTMLAttributes, Ref, ChangeEvent } from 'react';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { DetailedHTMLProps, InputHTMLAttributes, Ref, ChangeEvent } from 'react';
2
3
 
3
4
  type Props = Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "onChange"> & {
4
5
  buttonRef?: Ref<HTMLButtonElement>;
5
6
  } & {
6
7
  onChange?: (event: ChangeEvent<HTMLInputElement>) => void | Promise<void>;
7
8
  };
8
- declare function FileInput({ buttonRef, className, ref, children, onClick, onChange, ...props }: Props): React__default.JSX.Element;
9
+ declare function FileInput({ buttonRef, className, ref, children, onClick, onChange, ...props }: Props): react_jsx_runtime.JSX.Element;
9
10
 
10
11
  export { FileInput };
@@ -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/client/file_input.tsx
@@ -34,7 +24,7 @@ __export(file_input_exports, {
34
24
  });
35
25
  module.exports = __toCommonJS(file_input_exports);
36
26
  var import_react = require("react");
37
- var import_react2 = __toESM(require("react"));
27
+ var import_jsx_runtime = require("react/jsx-runtime");
38
28
  function FileInput({
39
29
  buttonRef,
40
30
  className,
@@ -44,35 +34,38 @@ function FileInput({
44
34
  onChange,
45
35
  ...props
46
36
  }) {
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();
37
+ const inputRef = (0, import_react.useRef)(null);
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
39
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
40
+ "button",
41
+ {
42
+ ref: buttonRef,
43
+ className,
44
+ type: "button",
45
+ onClick: () => {
46
+ inputRef.current?.click();
47
+ },
48
+ children
56
49
  }
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 = "";
50
+ ),
51
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
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
+ }
72
65
  }
73
66
  }
74
- }
75
- ));
67
+ )
68
+ ] });
76
69
  }
77
70
  // Annotate the CommonJS export names for ESM import in node:
78
71
  0 && (module.exports = {