@medialane/ui 0.396.0 → 0.397.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 (121) hide show
  1. package/dist/components/account/input-otp.d.cts +2 -2
  2. package/dist/components/account/input-otp.d.ts +2 -2
  3. package/dist/components/alert.d.cts +1 -1
  4. package/dist/components/alert.d.ts +1 -1
  5. package/dist/components/badge.d.cts +1 -1
  6. package/dist/components/badge.d.ts +1 -1
  7. package/dist/components/button.d.cts +2 -2
  8. package/dist/components/button.d.ts +2 -2
  9. package/dist/components/drop/create/asset-editor.cjs +14 -4
  10. package/dist/components/drop/create/asset-editor.cjs.map +1 -1
  11. package/dist/components/drop/create/asset-editor.js +14 -4
  12. package/dist/components/drop/create/asset-editor.js.map +1 -1
  13. package/dist/components/fast-mint/asset-form-parts.cjs +8 -43
  14. package/dist/components/fast-mint/asset-form-parts.cjs.map +1 -1
  15. package/dist/components/fast-mint/asset-form-parts.d.cts +5 -10
  16. package/dist/components/fast-mint/asset-form-parts.d.ts +5 -10
  17. package/dist/components/fast-mint/asset-form-parts.js +8 -42
  18. package/dist/components/fast-mint/asset-form-parts.js.map +1 -1
  19. package/dist/components/fast-mint/dropzone.cjs +1 -0
  20. package/dist/components/fast-mint/dropzone.cjs.map +1 -1
  21. package/dist/components/fast-mint/dropzone.js +1 -0
  22. package/dist/components/fast-mint/dropzone.js.map +1 -1
  23. package/dist/components/fast-mint/fast-mint.cjs +47 -45
  24. package/dist/components/fast-mint/fast-mint.cjs.map +1 -1
  25. package/dist/components/fast-mint/fast-mint.js +48 -46
  26. package/dist/components/fast-mint/fast-mint.js.map +1 -1
  27. package/dist/components/image-upload-field.cjs +140 -0
  28. package/dist/components/image-upload-field.cjs.map +1 -0
  29. package/dist/components/image-upload-field.d.cts +19 -0
  30. package/dist/components/image-upload-field.d.ts +19 -0
  31. package/dist/components/image-upload-field.js +106 -0
  32. package/dist/components/image-upload-field.js.map +1 -0
  33. package/dist/components/launchpad/coin-create.cjs +11 -54
  34. package/dist/components/launchpad/coin-create.cjs.map +1 -1
  35. package/dist/components/launchpad/coin-create.js +12 -55
  36. package/dist/components/launchpad/coin-create.js.map +1 -1
  37. package/dist/components/launchpad/collection-create-form.cjs +18 -76
  38. package/dist/components/launchpad/collection-create-form.cjs.map +1 -1
  39. package/dist/components/launchpad/collection-create-form.js +18 -76
  40. package/dist/components/launchpad/collection-create-form.js.map +1 -1
  41. package/dist/components/launchpad/edition-mint-fields.cjs +12 -87
  42. package/dist/components/launchpad/edition-mint-fields.cjs.map +1 -1
  43. package/dist/components/launchpad/edition-mint-fields.d.cts +4 -8
  44. package/dist/components/launchpad/edition-mint-fields.d.ts +4 -8
  45. package/dist/components/launchpad/edition-mint-fields.js +14 -79
  46. package/dist/components/launchpad/edition-mint-fields.js.map +1 -1
  47. package/dist/components/launchpad/edition-mint-schema.d.cts +6 -6
  48. package/dist/components/launchpad/edition-mint-schema.d.ts +6 -6
  49. package/dist/components/launchpad/edition-mint.cjs +21 -39
  50. package/dist/components/launchpad/edition-mint.cjs.map +1 -1
  51. package/dist/components/launchpad/edition-mint.js +21 -39
  52. package/dist/components/launchpad/edition-mint.js.map +1 -1
  53. package/dist/components/launchpad/pop-create-fields.cjs +14 -91
  54. package/dist/components/launchpad/pop-create-fields.cjs.map +1 -1
  55. package/dist/components/launchpad/pop-create-fields.d.cts +4 -8
  56. package/dist/components/launchpad/pop-create-fields.d.ts +4 -8
  57. package/dist/components/launchpad/pop-create-fields.js +14 -83
  58. package/dist/components/launchpad/pop-create-fields.js.map +1 -1
  59. package/dist/components/launchpad/pop-create.cjs +20 -32
  60. package/dist/components/launchpad/pop-create.cjs.map +1 -1
  61. package/dist/components/launchpad/pop-create.js +20 -32
  62. package/dist/components/launchpad/pop-create.js.map +1 -1
  63. package/dist/components/launchpad/remix-mint.cjs +15 -52
  64. package/dist/components/launchpad/remix-mint.cjs.map +1 -1
  65. package/dist/components/launchpad/remix-mint.js +16 -53
  66. package/dist/components/launchpad/remix-mint.js.map +1 -1
  67. package/dist/components/launchpad/single-edition-mint.cjs +11 -72
  68. package/dist/components/launchpad/single-edition-mint.cjs.map +1 -1
  69. package/dist/components/launchpad/single-edition-mint.js +12 -73
  70. package/dist/components/launchpad/single-edition-mint.js.map +1 -1
  71. package/dist/components/launchpad/tier-mint-form.cjs +14 -60
  72. package/dist/components/launchpad/tier-mint-form.cjs.map +1 -1
  73. package/dist/components/launchpad/tier-mint-form.js +15 -61
  74. package/dist/components/launchpad/tier-mint-form.js.map +1 -1
  75. package/dist/components/launchpad/tier-mint-presets.cjs +0 -4
  76. package/dist/components/launchpad/tier-mint-presets.cjs.map +1 -1
  77. package/dist/components/launchpad/tier-mint-presets.d.cts +0 -2
  78. package/dist/components/launchpad/tier-mint-presets.d.ts +0 -2
  79. package/dist/components/launchpad/tier-mint-presets.js +0 -4
  80. package/dist/components/launchpad/tier-mint-presets.js.map +1 -1
  81. package/dist/i18n/catalog/pt.cjs +3 -7
  82. package/dist/i18n/catalog/pt.cjs.map +1 -1
  83. package/dist/i18n/catalog/pt.js +3 -7
  84. package/dist/i18n/catalog/pt.js.map +1 -1
  85. package/dist/index.cjs +9 -3
  86. package/dist/index.cjs.map +1 -1
  87. package/dist/index.d.cts +3 -1
  88. package/dist/index.d.ts +3 -1
  89. package/dist/index.js +6 -2
  90. package/dist/index.js.map +1 -1
  91. package/dist/utils/ipfs-upload.cjs +3 -7
  92. package/dist/utils/ipfs-upload.cjs.map +1 -1
  93. package/dist/utils/ipfs-upload.d.cts +1 -3
  94. package/dist/utils/ipfs-upload.d.ts +1 -3
  95. package/dist/utils/ipfs-upload.js +3 -7
  96. package/dist/utils/ipfs-upload.js.map +1 -1
  97. package/dist/utils/use-file-upload.cjs +105 -0
  98. package/dist/utils/use-file-upload.cjs.map +1 -0
  99. package/dist/utils/use-file-upload.d.cts +26 -0
  100. package/dist/utils/use-file-upload.d.ts +26 -0
  101. package/dist/utils/use-file-upload.js +81 -0
  102. package/dist/utils/use-file-upload.js.map +1 -0
  103. package/dist/utils/use-image-upload.cjs +56 -0
  104. package/dist/utils/use-image-upload.cjs.map +1 -0
  105. package/dist/utils/use-image-upload.d.cts +19 -0
  106. package/dist/utils/use-image-upload.d.ts +19 -0
  107. package/dist/utils/use-image-upload.js +32 -0
  108. package/dist/utils/use-image-upload.js.map +1 -0
  109. package/package.json +1 -1
  110. package/dist/components/fast-mint/use-ipfs-upload.cjs +0 -64
  111. package/dist/components/fast-mint/use-ipfs-upload.cjs.map +0 -1
  112. package/dist/components/fast-mint/use-ipfs-upload.d.cts +0 -9
  113. package/dist/components/fast-mint/use-ipfs-upload.d.ts +0 -9
  114. package/dist/components/fast-mint/use-ipfs-upload.js +0 -40
  115. package/dist/components/fast-mint/use-ipfs-upload.js.map +0 -1
  116. package/dist/utils/use-launchpad-image-upload.cjs +0 -103
  117. package/dist/utils/use-launchpad-image-upload.cjs.map +0 -1
  118. package/dist/utils/use-launchpad-image-upload.d.cts +0 -21
  119. package/dist/utils/use-launchpad-image-upload.d.ts +0 -21
  120. package/dist/utils/use-launchpad-image-upload.js +0 -79
  121. package/dist/utils/use-launchpad-image-upload.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
3
4
  import Image from "next/image";
4
5
  import { FileText, ImagePlus, Loader2, Music, Video } from "lucide-react";
5
6
  import { IP_TEMPLATES } from "../../data/ip-templates.js";
6
- import { acceptFor } from "../../utils/upload-limits.js";
7
7
  import { cn } from "../../utils/cn.js";
8
8
  import { useT } from "../../i18n/provider.js";
9
9
  const MEDIA_KIND_ICON = {
@@ -18,11 +18,13 @@ function MediaRow({
18
18
  preview,
19
19
  uri,
20
20
  uploading,
21
+ error,
21
22
  ipType,
22
- inputRef,
23
- onSelect
23
+ onSelect,
24
+ onRetry
24
25
  }) {
25
26
  const t = useT();
27
+ const inputRef = useRef(null);
26
28
  const KindIcon = MEDIA_KIND_ICON[kind];
27
29
  const template = IP_TEMPLATES[ipType];
28
30
  const TemplateIcon = template.icon;
@@ -34,7 +36,7 @@ function MediaRow({
34
36
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
35
37
  /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold truncate", children: file.name }),
36
38
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
37
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: uploading ? t("Uploading\u2026") : uri ? t("Uploaded") : t("Upload failed") }),
39
+ error ? /* @__PURE__ */ jsx("p", { role: "alert", className: "text-xs text-destructive", children: error }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: uploading ? t("Uploading\u2026") : uri ? t("Uploaded") : t("Upload failed") }),
38
40
  uri && /* @__PURE__ */ jsxs(
39
41
  "span",
40
42
  {
@@ -52,6 +54,7 @@ function MediaRow({
52
54
  )
53
55
  ] })
54
56
  ] }),
57
+ error && /* @__PURE__ */ jsx("button", { type: "button", onClick: onRetry, className: "text-xs font-semibold text-brand-blue hover:underline shrink-0", children: t("Retry") }),
55
58
  /* @__PURE__ */ jsx(
56
59
  "button",
57
60
  {
@@ -63,47 +66,11 @@ function MediaRow({
63
66
  ),
64
67
  /* @__PURE__ */ jsx("input", { ref: inputRef, type: "file", className: "hidden", onChange: (e) => {
65
68
  const f = e.target.files?.[0];
69
+ e.target.value = "";
66
70
  if (f) onSelect(f);
67
71
  } })
68
72
  ] });
69
73
  }
70
- function CoverUpload({
71
- preview,
72
- uploading,
73
- inputRef,
74
- onSelect
75
- }) {
76
- const t = useT();
77
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
78
- /* @__PURE__ */ jsx("label", { className: "text-sm font-medium", children: t("Upload a cover image for your asset *") }),
79
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
80
- /* @__PURE__ */ jsxs(
81
- "div",
82
- {
83
- role: "button",
84
- tabIndex: 0,
85
- onClick: () => !uploading && inputRef.current?.click(),
86
- onKeyDown: (e) => {
87
- if ((e.key === "Enter" || e.key === " ") && !uploading) {
88
- e.preventDefault();
89
- inputRef.current?.click();
90
- }
91
- },
92
- className: "relative h-20 w-20 rounded-xl border-2 border-dashed border-border bg-muted flex items-center justify-center overflow-hidden shrink-0 cursor-pointer hover:border-primary/50 transition-colors",
93
- children: [
94
- preview ? /* @__PURE__ */ jsx(Image, { src: preview, alt: "", fill: true, className: "object-cover", unoptimized: true }) : /* @__PURE__ */ jsx(ImagePlus, { className: "h-6 w-6 text-muted-foreground" }),
95
- uploading && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-background/70", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) }),
96
- /* @__PURE__ */ jsx("input", { ref: inputRef, type: "file", accept: acceptFor("image"), className: "hidden", onChange: (e) => {
97
- const f = e.target.files?.[0];
98
- if (f) onSelect(f);
99
- } })
100
- ]
101
- }
102
- ),
103
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("Cover art for previews.") })
104
- ] })
105
- ] });
106
- }
107
74
  function FormatPicker({
108
75
  formats,
109
76
  value,
@@ -136,7 +103,6 @@ function FormatPicker({
136
103
  ] });
137
104
  }
138
105
  export {
139
- CoverUpload,
140
106
  FormatPicker,
141
107
  MediaRow
142
108
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/fast-mint/asset-form-parts.tsx"],"sourcesContent":["\"use client\";\n\nimport type { RefObject } from \"react\";\nimport Image from \"next/image\";\nimport { FileText, ImagePlus, Loader2, Music, Video } from \"lucide-react\";\nimport { IP_TEMPLATES } from \"../../data/ip-templates.js\";\nimport type { IPType } from \"../../data/ip.js\";\nimport { acceptFor } from \"../../utils/upload-limits.js\";\nimport { cn } from \"../../utils/cn.js\";\nimport type { FormatDefinition, MintFormat } from \"./formats/types.js\";\nimport type { MediaKind } from \"./types.js\";\nimport { useT } from \"../../i18n/provider.js\";\n\nconst MEDIA_KIND_ICON: Record<MediaKind, typeof ImagePlus> = {\n image: ImagePlus,\n audio: Music,\n video: Video,\n document: FileText,\n};\n\nexport function MediaRow({\n file, kind, preview, uri, uploading, ipType, inputRef, onSelect,\n}: {\n file: File;\n kind: MediaKind;\n preview: string | null;\n uri: string | null;\n uploading: boolean;\n ipType: IPType;\n inputRef: RefObject<HTMLInputElement | null>;\n onSelect: (file: File) => void;\n}) {\n const t = useT();\n const KindIcon = MEDIA_KIND_ICON[kind];\n const template = IP_TEMPLATES[ipType];\n const TemplateIcon = template.icon;\n return (\n <div className=\"panel flex items-center gap-4 p-3\">\n <div className=\"relative h-14 w-14 rounded-2xl bg-muted overflow-hidden shrink-0\">\n {kind === \"image\" && preview ? (\n <Image src={preview} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <KindIcon className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n )}\n {uploading && (\n <div className=\"absolute inset-0 flex items-center justify-center bg-background/70\">\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n </div>\n )}\n </div>\n <div className=\"min-w-0 flex-1 space-y-1\">\n <p className=\"text-sm font-semibold truncate\">{file.name}</p>\n <div className=\"flex items-center gap-2 flex-wrap\">\n <p className=\"text-xs text-muted-foreground\">\n {uploading ? t(\"Uploading…\") : uri ? t(\"Uploaded\") : t(\"Upload failed\")}\n </p>\n {uri && (\n <span\n className={cn(\n \"inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-2xs font-medium bg-background/40\",\n template.color.bg, template.color.text, template.color.border\n )}\n >\n <TemplateIcon className=\"h-3 w-3\" />\n {t(template.label)}\n </span>\n )}\n </div>\n </div>\n <button\n type=\"button\"\n onClick={() => inputRef.current?.click()}\n className=\"text-xs font-semibold text-brand-blue hover:underline shrink-0\"\n >\n {t(\"Change\")}\n </button>\n <input ref={inputRef} type=\"file\" className=\"hidden\" onChange={(e) => { const f = e.target.files?.[0]; if (f) onSelect(f); }} />\n </div>\n );\n}\n\nexport function CoverUpload({\n preview, uploading, inputRef, onSelect,\n}: {\n preview: string | null;\n uploading: boolean;\n inputRef: RefObject<HTMLInputElement | null>;\n onSelect: (file: File) => void;\n}) {\n const t = useT();\n return (\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t(\"Upload a cover image for your asset *\")}</label>\n <div className=\"flex items-center gap-4\">\n <div\n role=\"button\"\n tabIndex={0}\n onClick={() => !uploading && inputRef.current?.click()}\n onKeyDown={(e) => { if ((e.key === \"Enter\" || e.key === \" \") && !uploading) { e.preventDefault(); inputRef.current?.click(); } }}\n className=\"relative h-20 w-20 rounded-xl border-2 border-dashed border-border bg-muted flex items-center justify-center overflow-hidden shrink-0 cursor-pointer hover:border-primary/50 transition-colors\"\n >\n {preview ? (\n <Image src={preview} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <ImagePlus className=\"h-6 w-6 text-muted-foreground\" />\n )}\n {uploading && (\n <div className=\"absolute inset-0 flex items-center justify-center bg-background/70\">\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n </div>\n )}\n <input ref={inputRef} type=\"file\" accept={acceptFor(\"image\")} className=\"hidden\" onChange={(e) => { const f = e.target.files?.[0]; if (f) onSelect(f); }} />\n </div>\n <p className=\"text-xs text-muted-foreground\">{t(\"Cover art for previews.\")}</p>\n </div>\n </div>\n );\n}\n\nexport function FormatPicker({\n formats, value, onChange,\n}: {\n formats: ReadonlyArray<Pick<FormatDefinition, \"key\" | \"title\" | \"hint\" | \"icon\">>;\n value: MintFormat;\n onChange: (format: MintFormat) => void;\n}) {\n const t = useT();\n return (\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\" id=\"fast-mint-format\">{t(\"What do you want to make with it?\")}</label>\n <div role=\"radiogroup\" aria-labelledby=\"fast-mint-format\" className=\"grid grid-cols-1 sm:grid-cols-2 gap-3\">\n {formats.map(({ key, icon: Icon, title, hint }) => (\n <button\n key={key}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === key}\n onClick={() => onChange(key)}\n className={cn(\"flex items-start gap-3 rounded-xl p-4 text-left transition-colors\",\n value === key ? \"bg-brand-blue/15\" : \"hover:bg-muted/40 bg-background/40\")}\n >\n <Icon className={cn(\"h-5 w-5 shrink-0 mt-0.5\", value === key ? \"text-brand-blue\" : \"text-muted-foreground\")} />\n <span>\n <span className=\"block text-sm font-semibold\">{t(title)}</span>\n <span className=\"block text-xs mt-0.5 text-muted-foreground\">{t(hint)}</span>\n </span>\n </button>\n ))}\n </div>\n </div>\n );\n}\n"],"mappings":";AAsCM,SAEI,KAFJ;AAnCN,OAAO,WAAW;AAClB,SAAS,UAAU,WAAW,SAAS,OAAO,aAAa;AAC3D,SAAS,oBAAoB;AAE7B,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAGnB,SAAS,YAAY;AAErB,MAAM,kBAAuD;AAAA,EAC3D,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,UAAU;AACZ;AAEO,SAAS,SAAS;AAAA,EACvB;AAAA,EAAM;AAAA,EAAM;AAAA,EAAS;AAAA,EAAK;AAAA,EAAW;AAAA,EAAQ;AAAA,EAAU;AACzD,GASG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,WAAW,gBAAgB,IAAI;AACrC,QAAM,WAAW,aAAa,MAAM;AACpC,QAAM,eAAe,SAAS;AAC9B,SACE,qBAAC,SAAI,WAAU,qCACb;AAAA,yBAAC,SAAI,WAAU,oEACZ;AAAA,eAAS,WAAW,UACnB,oBAAC,SAAM,KAAK,SAAS,KAAI,IAAG,MAAI,MAAC,WAAU,gBAAe,aAAW,MAAC,IAEtE,oBAAC,SAAI,WAAU,qDACb,8BAAC,YAAS,WAAU,iCAAgC,GACtD;AAAA,MAED,aACC,oBAAC,SAAI,WAAU,sEACb,8BAAC,WAAQ,WAAU,wBAAuB,GAC5C;AAAA,OAEJ;AAAA,IACA,qBAAC,SAAI,WAAU,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AAAA,gCAAC,UAAK,WAAU,+BAA+B,YAAE,KAAK,GAAE;AAAA,YACxD,oBAAC,UAAK,WAAU,8CAA8C,YAAE,IAAI,GAAE;AAAA,aACxE;AAAA;AAAA;AAAA,MAZK;AAAA,IAaP,CACD,GACH;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/fast-mint/asset-form-parts.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport Image from \"next/image\";\nimport { FileText, ImagePlus, Loader2, Music, Video } from \"lucide-react\";\nimport { IP_TEMPLATES } from \"../../data/ip-templates.js\";\nimport type { IPType } from \"../../data/ip.js\";\nimport { cn } from \"../../utils/cn.js\";\nimport type { FormatDefinition, MintFormat } from \"./formats/types.js\";\nimport type { MediaKind } from \"./types.js\";\nimport { useT } from \"../../i18n/provider.js\";\n\nconst MEDIA_KIND_ICON: Record<MediaKind, typeof ImagePlus> = {\n image: ImagePlus,\n audio: Music,\n video: Video,\n document: FileText,\n};\n\nexport function MediaRow({\n file, kind, preview, uri, uploading, error, ipType, onSelect, onRetry,\n}: {\n file: File;\n kind: MediaKind;\n preview: string | null;\n uri: string | null;\n uploading: boolean;\n error: string | null;\n ipType: IPType;\n onSelect: (file: File) => void;\n onRetry: () => void;\n}) {\n const t = useT();\n const inputRef = useRef<HTMLInputElement>(null);\n const KindIcon = MEDIA_KIND_ICON[kind];\n const template = IP_TEMPLATES[ipType];\n const TemplateIcon = template.icon;\n return (\n <div className=\"panel flex items-center gap-4 p-3\">\n <div className=\"relative h-14 w-14 rounded-2xl bg-muted overflow-hidden shrink-0\">\n {kind === \"image\" && preview ? (\n <Image src={preview} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <KindIcon className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n )}\n {uploading && (\n <div className=\"absolute inset-0 flex items-center justify-center bg-background/70\">\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n </div>\n )}\n </div>\n <div className=\"min-w-0 flex-1 space-y-1\">\n <p className=\"text-sm font-semibold truncate\">{file.name}</p>\n <div className=\"flex items-center gap-2 flex-wrap\">\n {error ? (\n <p role=\"alert\" className=\"text-xs text-destructive\">{error}</p>\n ) : (\n <p className=\"text-xs text-muted-foreground\">\n {uploading ? t(\"Uploading…\") : uri ? t(\"Uploaded\") : t(\"Upload failed\")}\n </p>\n )}\n {uri && (\n <span\n className={cn(\n \"inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-2xs font-medium bg-background/40\",\n template.color.bg, template.color.text, template.color.border\n )}\n >\n <TemplateIcon className=\"h-3 w-3\" />\n {t(template.label)}\n </span>\n )}\n </div>\n </div>\n {error && (\n <button type=\"button\" onClick={onRetry} className=\"text-xs font-semibold text-brand-blue hover:underline shrink-0\">\n {t(\"Retry\")}\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => inputRef.current?.click()}\n className=\"text-xs font-semibold text-brand-blue hover:underline shrink-0\"\n >\n {t(\"Change\")}\n </button>\n <input ref={inputRef} type=\"file\" className=\"hidden\" onChange={(e) => { const f = e.target.files?.[0]; e.target.value = \"\"; if (f) onSelect(f); }} />\n </div>\n );\n}\n\nexport function FormatPicker({\n formats, value, onChange,\n}: {\n formats: ReadonlyArray<Pick<FormatDefinition, \"key\" | \"title\" | \"hint\" | \"icon\">>;\n value: MintFormat;\n onChange: (format: MintFormat) => void;\n}) {\n const t = useT();\n return (\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\" id=\"fast-mint-format\">{t(\"What do you want to make with it?\")}</label>\n <div role=\"radiogroup\" aria-labelledby=\"fast-mint-format\" className=\"grid grid-cols-1 sm:grid-cols-2 gap-3\">\n {formats.map(({ key, icon: Icon, title, hint }) => (\n <button\n key={key}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === key}\n onClick={() => onChange(key)}\n className={cn(\"flex items-start gap-3 rounded-xl p-4 text-left transition-colors\",\n value === key ? \"bg-brand-blue/15\" : \"hover:bg-muted/40 bg-background/40\")}\n >\n <Icon className={cn(\"h-5 w-5 shrink-0 mt-0.5\", value === key ? \"text-brand-blue\" : \"text-muted-foreground\")} />\n <span>\n <span className=\"block text-sm font-semibold\">{t(title)}</span>\n <span className=\"block text-xs mt-0.5 text-muted-foreground\">{t(hint)}</span>\n </span>\n </button>\n ))}\n </div>\n </div>\n );\n}\n"],"mappings":";AAuCM,SAEI,KAFJ;AArCN,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,SAAS,UAAU,WAAW,SAAS,OAAO,aAAa;AAC3D,SAAS,oBAAoB;AAE7B,SAAS,UAAU;AAGnB,SAAS,YAAY;AAErB,MAAM,kBAAuD;AAAA,EAC3D,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,UAAU;AACZ;AAEO,SAAS,SAAS;AAAA,EACvB;AAAA,EAAM;AAAA,EAAM;AAAA,EAAS;AAAA,EAAK;AAAA,EAAW;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAU;AAChE,GAUG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,WAAW,OAAyB,IAAI;AAC9C,QAAM,WAAW,gBAAgB,IAAI;AACrC,QAAM,WAAW,aAAa,MAAM;AACpC,QAAM,eAAe,SAAS;AAC9B,SACE,qBAAC,SAAI,WAAU,qCACb;AAAA,yBAAC,SAAI,WAAU,oEACZ;AAAA,eAAS,WAAW,UACnB,oBAAC,SAAM,KAAK,SAAS,KAAI,IAAG,MAAI,MAAC,WAAU,gBAAe,aAAW,MAAC,IAEtE,oBAAC,SAAI,WAAU,qDACb,8BAAC,YAAS,WAAU,iCAAgC,GACtD;AAAA,MAED,aACC,oBAAC,SAAI,WAAU,sEACb,8BAAC,WAAQ,WAAU,wBAAuB,GAC5C;AAAA,OAEJ;AAAA,IACA,qBAAC,SAAI,WAAU,4BACb;AAAA,0BAAC,OAAE,WAAU,kCAAkC,eAAK,MAAK;AAAA,MACzD,qBAAC,SAAI,WAAU,qCACZ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AAK;AAAA,QACL,MAAK;AAAA,QACL,gBAAc,UAAU;AAAA,QACxB,SAAS,MAAM,SAAS,GAAG;AAAA,QAC3B,WAAW;AAAA,UAAG;AAAA,UACZ,UAAU,MAAM,qBAAqB;AAAA,QAAoC;AAAA,QAE3E;AAAA,8BAAC,QAAK,WAAW,GAAG,2BAA2B,UAAU,MAAM,oBAAoB,uBAAuB,GAAG;AAAA,UAC7G,qBAAC,UACC;AAAA,gCAAC,UAAK,WAAU,+BAA+B,YAAE,KAAK,GAAE;AAAA,YACxD,oBAAC,UAAK,WAAU,8CAA8C,YAAE,IAAI,GAAE;AAAA,aACxE;AAAA;AAAA;AAAA,MAZK;AAAA,IAaP,CACD,GACH;AAAA,KACF;AAEJ;","names":[]}
@@ -108,6 +108,7 @@ function Dropzone({
108
108
  className: "hidden",
109
109
  onChange: (e) => {
110
110
  const f = e.target.files?.[0];
111
+ e.target.value = "";
111
112
  if (f) onFileSelected(f);
112
113
  }
113
114
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/fast-mint/dropzone.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport { ImagePlus, Upload, LogIn } from \"lucide-react\";\nimport { cn } from \"../../utils/cn.js\";\nimport { Button } from \"../button.js\";\nimport type { MediaKind } from \"./types.js\";\nimport { acceptFor } from \"../../utils/upload-limits.js\";\nimport { useT } from \"../../i18n/provider.js\";\n\nexport interface DropzoneProps {\n mediaKindLock?: MediaKind;\n presentation?: \"inline\" | \"dialog\";\n hasWallet: boolean;\n onRequireWallet: () => void;\n onFileSelected: (file: File) => void;\n connectLabel?: string;\n}\n\nexport function Dropzone({\n mediaKindLock,\n presentation = \"inline\",\n hasWallet,\n onRequireWallet,\n onFileSelected,\n connectLabel = \"Sign in\",\n}: DropzoneProps) {\n const t = useT();\n const mediaInputRef = useRef<HTMLInputElement>(null);\n\n const openMediaPicker = () => {\n if (!hasWallet) { onRequireWallet(); return; }\n mediaInputRef.current?.click();\n };\n\n return (\n <section\n role=\"button\"\n tabIndex={0}\n aria-label={hasWallet ? t(\"Upload media\") : t(\"{label} to upload media\", { label: t(connectLabel) })}\n onClick={openMediaPicker}\n onKeyDown={(e) => { if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); openMediaPicker(); } }}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => { e.preventDefault(); if (!hasWallet) { onRequireWallet(); return; } const f = e.dataTransfer.files?.[0]; if (f) onFileSelected(f); }}\n className={cn(\n \"relative flex flex-col items-center justify-center gap-4 cursor-pointer transition-colors text-center rounded-2xl border-[3px] border-dashed border-brand-blue/40 hover:border-brand-blue/70 hover:bg-brand-blue/[0.04] p-6\",\n presentation === \"dialog\" ? \"min-h-[16rem] sm:min-h-[18rem]\" : \"min-h-[20rem] sm:min-h-[24rem]\"\n )}\n >\n <div className=\"h-14 w-14 rounded-2xl bg-muted flex items-center justify-center\">\n <ImagePlus className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n <div className=\"space-y-1.5 px-6\">\n <h2 className=\"text-2xl sm:text-3xl font-bold tracking-tight\">\n {mediaKindLock ? `Drop or upload an ${mediaKindLock}` : t(\"Drop or upload your media\")}\n </h2>\n <p className=\"text-base text-muted-foreground max-w-sm mx-auto\">\n {mediaKindLock === \"image\" ? t(\"It becomes your avatar and app theme.\") : t(\"Protect your creation and monetize it worldwide.\")}\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"soft\"\n className=\"rounded-full mt-1 bg-card\"\n onClick={(e) => { e.stopPropagation(); openMediaPicker(); }}\n >\n {hasWallet ? (\n <>\n <Upload className=\"h-3.5 w-3.5 mr-1.5\" />\n {t(\"Browse files\")}\n </>\n ) : (\n <>\n <LogIn className=\"h-3.5 w-3.5 mr-1.5\" />\n {t(connectLabel)}\n </>\n )}\n </Button>\n <p className=\"text-2xs text-muted-foreground/70\">\n {mediaKindLock === \"image\" ? t(\"Image files\") : t(\"Any media file\")}\n </p>\n <input\n ref={mediaInputRef}\n type=\"file\"\n accept={mediaKindLock === \"image\" ? acceptFor(\"image\") : undefined}\n className=\"hidden\"\n onChange={(e) => { const f = e.target.files?.[0]; if (f) onFileSelected(f); }}\n />\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDQ;AAhDR,mBAAuB;AACvB,0BAAyC;AACzC,gBAAmB;AACnB,oBAAuB;AAEvB,2BAA0B;AAC1B,sBAAqB;AAWd,SAAS,SAAS;AAAA,EACvB;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AACjB,GAAkB;AAChB,QAAM,QAAI,sBAAK;AACf,QAAM,oBAAgB,qBAAyB,IAAI;AAEnD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,CAAC,WAAW;AAAE,sBAAgB;AAAG;AAAA,IAAQ;AAC7C,kBAAc,SAAS,MAAM;AAAA,EAC/B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV,cAAY,YAAY,EAAE,cAAc,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAAA,MACnG,SAAS;AAAA,MACT,WAAW,CAAC,MAAM;AAAE,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AAAE,YAAE,eAAe;AAAG,0BAAgB;AAAA,QAAG;AAAA,MAAE;AAAA,MACvG,YAAY,CAAC,MAAM,EAAE,eAAe;AAAA,MACpC,QAAQ,CAAC,MAAM;AAAE,UAAE,eAAe;AAAG,YAAI,CAAC,WAAW;AAAE,0BAAgB;AAAG;AAAA,QAAQ;AAAE,cAAM,IAAI,EAAE,aAAa,QAAQ,CAAC;AAAG,YAAI,EAAG,gBAAe,CAAC;AAAA,MAAG;AAAA,MACnJ,eAAW;AAAA,QACT;AAAA,QACA,iBAAiB,WAAW,mCAAmC;AAAA,MACjE;AAAA,MAEA;AAAA,oDAAC,SAAI,WAAU,mEACb,sDAAC,iCAAU,WAAU,iCAAgC,GACvD;AAAA,QACA,6CAAC,SAAI,WAAU,oBACb;AAAA,sDAAC,QAAG,WAAU,iDACX,0BAAgB,qBAAqB,aAAa,KAAK,EAAE,2BAA2B,GACvF;AAAA,UACA,4CAAC,OAAE,WAAU,oDACV,4BAAkB,UAAU,EAAE,uCAAuC,IAAI,EAAE,kDAAkD,GAChI;AAAA,WACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,SAAS,CAAC,MAAM;AAAE,gBAAE,gBAAgB;AAAG,8BAAgB;AAAA,YAAG;AAAA,YAEzD,sBACC,4EACE;AAAA,0DAAC,8BAAO,WAAU,sBAAqB;AAAA,cACtC,EAAE,cAAc;AAAA,eACnB,IAEA,4EACE;AAAA,0DAAC,6BAAM,WAAU,sBAAqB;AAAA,cACrC,EAAE,YAAY;AAAA,eACjB;AAAA;AAAA,QAEJ;AAAA,QACA,4CAAC,OAAE,WAAU,qCACV,4BAAkB,UAAU,EAAE,aAAa,IAAI,EAAE,gBAAgB,GACpE;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,KAAK;AAAA,YACL,MAAK;AAAA,YACL,QAAQ,kBAAkB,cAAU,gCAAU,OAAO,IAAI;AAAA,YACzD,WAAU;AAAA,YACV,UAAU,CAAC,MAAM;AAAE,oBAAM,IAAI,EAAE,OAAO,QAAQ,CAAC;AAAG,kBAAI,EAAG,gBAAe,CAAC;AAAA,YAAG;AAAA;AAAA,QAC9E;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/fast-mint/dropzone.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport { ImagePlus, Upload, LogIn } from \"lucide-react\";\nimport { cn } from \"../../utils/cn.js\";\nimport { Button } from \"../button.js\";\nimport type { MediaKind } from \"./types.js\";\nimport { acceptFor } from \"../../utils/upload-limits.js\";\nimport { useT } from \"../../i18n/provider.js\";\n\nexport interface DropzoneProps {\n mediaKindLock?: MediaKind;\n presentation?: \"inline\" | \"dialog\";\n hasWallet: boolean;\n onRequireWallet: () => void;\n onFileSelected: (file: File) => void;\n connectLabel?: string;\n}\n\nexport function Dropzone({\n mediaKindLock,\n presentation = \"inline\",\n hasWallet,\n onRequireWallet,\n onFileSelected,\n connectLabel = \"Sign in\",\n}: DropzoneProps) {\n const t = useT();\n const mediaInputRef = useRef<HTMLInputElement>(null);\n\n const openMediaPicker = () => {\n if (!hasWallet) { onRequireWallet(); return; }\n mediaInputRef.current?.click();\n };\n\n return (\n <section\n role=\"button\"\n tabIndex={0}\n aria-label={hasWallet ? t(\"Upload media\") : t(\"{label} to upload media\", { label: t(connectLabel) })}\n onClick={openMediaPicker}\n onKeyDown={(e) => { if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); openMediaPicker(); } }}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => { e.preventDefault(); if (!hasWallet) { onRequireWallet(); return; } const f = e.dataTransfer.files?.[0]; if (f) onFileSelected(f); }}\n className={cn(\n \"relative flex flex-col items-center justify-center gap-4 cursor-pointer transition-colors text-center rounded-2xl border-[3px] border-dashed border-brand-blue/40 hover:border-brand-blue/70 hover:bg-brand-blue/[0.04] p-6\",\n presentation === \"dialog\" ? \"min-h-[16rem] sm:min-h-[18rem]\" : \"min-h-[20rem] sm:min-h-[24rem]\"\n )}\n >\n <div className=\"h-14 w-14 rounded-2xl bg-muted flex items-center justify-center\">\n <ImagePlus className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n <div className=\"space-y-1.5 px-6\">\n <h2 className=\"text-2xl sm:text-3xl font-bold tracking-tight\">\n {mediaKindLock ? `Drop or upload an ${mediaKindLock}` : t(\"Drop or upload your media\")}\n </h2>\n <p className=\"text-base text-muted-foreground max-w-sm mx-auto\">\n {mediaKindLock === \"image\" ? t(\"It becomes your avatar and app theme.\") : t(\"Protect your creation and monetize it worldwide.\")}\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"soft\"\n className=\"rounded-full mt-1 bg-card\"\n onClick={(e) => { e.stopPropagation(); openMediaPicker(); }}\n >\n {hasWallet ? (\n <>\n <Upload className=\"h-3.5 w-3.5 mr-1.5\" />\n {t(\"Browse files\")}\n </>\n ) : (\n <>\n <LogIn className=\"h-3.5 w-3.5 mr-1.5\" />\n {t(connectLabel)}\n </>\n )}\n </Button>\n <p className=\"text-2xs text-muted-foreground/70\">\n {mediaKindLock === \"image\" ? t(\"Image files\") : t(\"Any media file\")}\n </p>\n <input\n ref={mediaInputRef}\n type=\"file\"\n accept={mediaKindLock === \"image\" ? acceptFor(\"image\") : undefined}\n className=\"hidden\"\n onChange={(e) => { const f = e.target.files?.[0]; e.target.value = \"\"; if (f) onFileSelected(f); }}\n />\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkDQ;AAhDR,mBAAuB;AACvB,0BAAyC;AACzC,gBAAmB;AACnB,oBAAuB;AAEvB,2BAA0B;AAC1B,sBAAqB;AAWd,SAAS,SAAS;AAAA,EACvB;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AACjB,GAAkB;AAChB,QAAM,QAAI,sBAAK;AACf,QAAM,oBAAgB,qBAAyB,IAAI;AAEnD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,CAAC,WAAW;AAAE,sBAAgB;AAAG;AAAA,IAAQ;AAC7C,kBAAc,SAAS,MAAM;AAAA,EAC/B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV,cAAY,YAAY,EAAE,cAAc,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAAA,MACnG,SAAS;AAAA,MACT,WAAW,CAAC,MAAM;AAAE,YAAI,EAAE,QAAQ,WAAW,EAA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O,IAAI;AAAA,YACzD,WAAU;AAAA,YACV,UAAU,CAAC,MAAM;AAAE,oBAAM,IAAI,EAAE,OAAO,QAAQ,CAAC;AAAG,gBAAE,OAAO,QAAQ;AAAI,kBAAI,EAAG,gBAAe,CAAC;AAAA,YAAG;AAAA;AAAA,QACnG;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -85,6 +85,7 @@ function Dropzone({
85
85
  className: "hidden",
86
86
  onChange: (e) => {
87
87
  const f = e.target.files?.[0];
88
+ e.target.value = "";
88
89
  if (f) onFileSelected(f);
89
90
  }
90
91
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/fast-mint/dropzone.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport { ImagePlus, Upload, LogIn } from \"lucide-react\";\nimport { cn } from \"../../utils/cn.js\";\nimport { Button } from \"../button.js\";\nimport type { MediaKind } from \"./types.js\";\nimport { acceptFor } from \"../../utils/upload-limits.js\";\nimport { useT } from \"../../i18n/provider.js\";\n\nexport interface DropzoneProps {\n mediaKindLock?: MediaKind;\n presentation?: \"inline\" | \"dialog\";\n hasWallet: boolean;\n onRequireWallet: () => void;\n onFileSelected: (file: File) => void;\n connectLabel?: string;\n}\n\nexport function Dropzone({\n mediaKindLock,\n presentation = \"inline\",\n hasWallet,\n onRequireWallet,\n onFileSelected,\n connectLabel = \"Sign in\",\n}: DropzoneProps) {\n const t = useT();\n const mediaInputRef = useRef<HTMLInputElement>(null);\n\n const openMediaPicker = () => {\n if (!hasWallet) { onRequireWallet(); return; }\n mediaInputRef.current?.click();\n };\n\n return (\n <section\n role=\"button\"\n tabIndex={0}\n aria-label={hasWallet ? t(\"Upload media\") : t(\"{label} to upload media\", { label: t(connectLabel) })}\n onClick={openMediaPicker}\n onKeyDown={(e) => { if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); openMediaPicker(); } }}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => { e.preventDefault(); if (!hasWallet) { onRequireWallet(); return; } const f = e.dataTransfer.files?.[0]; if (f) onFileSelected(f); }}\n className={cn(\n \"relative flex flex-col items-center justify-center gap-4 cursor-pointer transition-colors text-center rounded-2xl border-[3px] border-dashed border-brand-blue/40 hover:border-brand-blue/70 hover:bg-brand-blue/[0.04] p-6\",\n presentation === \"dialog\" ? \"min-h-[16rem] sm:min-h-[18rem]\" : \"min-h-[20rem] sm:min-h-[24rem]\"\n )}\n >\n <div className=\"h-14 w-14 rounded-2xl bg-muted flex items-center justify-center\">\n <ImagePlus className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n <div className=\"space-y-1.5 px-6\">\n <h2 className=\"text-2xl sm:text-3xl font-bold tracking-tight\">\n {mediaKindLock ? `Drop or upload an ${mediaKindLock}` : t(\"Drop or upload your media\")}\n </h2>\n <p className=\"text-base text-muted-foreground max-w-sm mx-auto\">\n {mediaKindLock === \"image\" ? t(\"It becomes your avatar and app theme.\") : t(\"Protect your creation and monetize it worldwide.\")}\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"soft\"\n className=\"rounded-full mt-1 bg-card\"\n onClick={(e) => { e.stopPropagation(); openMediaPicker(); }}\n >\n {hasWallet ? (\n <>\n <Upload className=\"h-3.5 w-3.5 mr-1.5\" />\n {t(\"Browse files\")}\n </>\n ) : (\n <>\n <LogIn className=\"h-3.5 w-3.5 mr-1.5\" />\n {t(connectLabel)}\n </>\n )}\n </Button>\n <p className=\"text-2xs text-muted-foreground/70\">\n {mediaKindLock === \"image\" ? t(\"Image files\") : t(\"Any media file\")}\n </p>\n <input\n ref={mediaInputRef}\n type=\"file\"\n accept={mediaKindLock === \"image\" ? acceptFor(\"image\") : undefined}\n className=\"hidden\"\n onChange={(e) => { const f = e.target.files?.[0]; if (f) onFileSelected(f); }}\n />\n </section>\n );\n}\n"],"mappings":";AAkDQ,SAiBE,UAjBF,KAEF,YAFE;AAhDR,SAAS,cAAc;AACvB,SAAS,WAAW,QAAQ,aAAa;AACzC,SAAS,UAA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IAAI,EAAE,kDAAkD,GAChI;AAAA,WACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,SAAS,CAAC,MAAM;AAAE,gBAAE,gBAAgB;AAAG,8BAAgB;AAAA,YAAG;AAAA,YAEzD,sBACC,iCACE;AAAA,kCAAC,UAAO,WAAU,sBAAqB;AAAA,cACtC,EAAE,cAAc;AAAA,eACnB,IAEA,iCACE;AAAA,kCAAC,SAAM,WAAU,sBAAqB;AAAA,cACrC,EAAE,YAAY;AAAA,eACjB;AAAA;AAAA,QAEJ;AAAA,QACA,oBAAC,OAAE,WAAU,qCACV,4BAAkB,UAAU,EAAE,aAAa,IAAI,EAAE,gBAAgB,GACpE;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,KAAK;AAAA,YACL,MAAK;AAAA,YACL,QAAQ,kBAAkB,UAAU,UAAU,OAAO,IAAI;AAAA,YACzD,WAAU;AAAA,YACV,UAAU,CAAC,MAAM;AAAE,oBAAM,IAAI,EAAE,OAAO,QAAQ,CAAC;AAAG,kBAAI,EAAG,gBAAe,CAAC;AAAA,YAAG;AAAA;AAAA,QAC9E;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/fast-mint/dropzone.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef } from \"react\";\nimport { ImagePlus, Upload, LogIn } from \"lucide-react\";\nimport { cn } from \"../../utils/cn.js\";\nimport { Button } from \"../button.js\";\nimport type { MediaKind } from \"./types.js\";\nimport { acceptFor } from \"../../utils/upload-limits.js\";\nimport { useT } from \"../../i18n/provider.js\";\n\nexport interface DropzoneProps {\n mediaKindLock?: MediaKind;\n presentation?: \"inline\" | \"dialog\";\n hasWallet: boolean;\n onRequireWallet: () => void;\n onFileSelected: (file: File) => void;\n connectLabel?: string;\n}\n\nexport function Dropzone({\n mediaKindLock,\n presentation = \"inline\",\n hasWallet,\n onRequireWallet,\n onFileSelected,\n connectLabel = \"Sign in\",\n}: DropzoneProps) {\n const t = useT();\n const mediaInputRef = useRef<HTMLInputElement>(null);\n\n const openMediaPicker = () => {\n if (!hasWallet) { onRequireWallet(); return; }\n mediaInputRef.current?.click();\n };\n\n return (\n <section\n role=\"button\"\n tabIndex={0}\n aria-label={hasWallet ? t(\"Upload media\") : t(\"{label} to upload media\", { label: t(connectLabel) })}\n onClick={openMediaPicker}\n onKeyDown={(e) => { if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); openMediaPicker(); } }}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => { e.preventDefault(); if (!hasWallet) { onRequireWallet(); return; } const f = e.dataTransfer.files?.[0]; if (f) onFileSelected(f); }}\n className={cn(\n \"relative flex flex-col items-center justify-center gap-4 cursor-pointer transition-colors text-center rounded-2xl border-[3px] border-dashed border-brand-blue/40 hover:border-brand-blue/70 hover:bg-brand-blue/[0.04] p-6\",\n presentation === \"dialog\" ? \"min-h-[16rem] sm:min-h-[18rem]\" : \"min-h-[20rem] sm:min-h-[24rem]\"\n )}\n >\n <div className=\"h-14 w-14 rounded-2xl bg-muted flex items-center justify-center\">\n <ImagePlus className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n <div className=\"space-y-1.5 px-6\">\n <h2 className=\"text-2xl sm:text-3xl font-bold tracking-tight\">\n {mediaKindLock ? `Drop or upload an ${mediaKindLock}` : t(\"Drop or upload your media\")}\n </h2>\n <p className=\"text-base text-muted-foreground max-w-sm mx-auto\">\n {mediaKindLock === \"image\" ? t(\"It becomes your avatar and app theme.\") : t(\"Protect your creation and monetize it worldwide.\")}\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"soft\"\n className=\"rounded-full mt-1 bg-card\"\n onClick={(e) => { e.stopPropagation(); openMediaPicker(); }}\n >\n {hasWallet ? (\n <>\n <Upload className=\"h-3.5 w-3.5 mr-1.5\" />\n {t(\"Browse files\")}\n </>\n ) : (\n <>\n <LogIn className=\"h-3.5 w-3.5 mr-1.5\" />\n {t(connectLabel)}\n </>\n )}\n </Button>\n <p className=\"text-2xs text-muted-foreground/70\">\n {mediaKindLock === \"image\" ? t(\"Image files\") : t(\"Any media file\")}\n </p>\n <input\n ref={mediaInputRef}\n type=\"file\"\n accept={mediaKindLock === \"image\" ? acceptFor(\"image\") : undefined}\n className=\"hidden\"\n onChange={(e) => { const f = e.target.files?.[0]; e.target.value = \"\"; if (f) onFileSelected(f); }}\n />\n </section>\n );\n}\n"],"mappings":";AAkDQ,SAiBE,UAjBF,KAEF,YAFE;AAhDR,SAAS,cAAc;AACvB,SAAS,WAAW,QAAQ,aAAa;AACzC,SAAS,UAAU;AACnB,SAAS,cAAc;AAEvB,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AAWd,SAAS,SAAS;AAAA,EACvB;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AACjB,GAAkB;AAChB,QAAM,IAAI,KAAK;AACf,QAAM,gBAAgB,OAAyB,IAAI;AAEnD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,CAAC,WAAW;AAAE,sBAAgB;AAAG;AAAA,IAAQ;AAC7C,kBAAc,SAAS,MAAM;AAAA,EAC/B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU;AAAA,MACV,cAAY,YAAY,EAAE,cAAc,IAAI,EAAE,2BAA2B,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;AAAA,MACnG,SAAS;AAAA,MACT,WAAW,CAAC,MAAM;AAAE,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AAAE,YAAE,eAAe;AAAG,0BAAgB;AAAA,QAAG;AAAA,MAAE;AAAA,MACvG,YAAY,CAAC,MAAM,EAAE,eAAe;AAAA,MACpC,QAAQ,CAAC,MAAM;AAAE,UAAE,eAAe;AAAG,YAAI,CAAC,WAAW;AAAE,0BAAgB;AAAG;AAAA,QAAQ;AA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@ -43,9 +43,11 @@ var import_registry = require("./formats/registry.js");
43
43
  var import_form = require("./form.js");
44
44
  var import_media_kind = require("./media-kind.js");
45
45
  var import_launchpad_rules = require("../../utils/launchpad-rules.js");
46
- var import_use_ipfs_upload = require("./use-ipfs-upload.js");
46
+ var import_use_file_upload = require("../../utils/use-file-upload.js");
47
+ var import_image_upload_field = require("../image-upload-field.js");
47
48
  var import_use_new_collection_draft = require("./use-new-collection-draft.js");
48
49
  var import_provider = require("../../i18n/provider.js");
50
+ var import_translate = require("../../i18n/translate.js");
49
51
  var import_action_button = require("../action-button.js");
50
52
  function FastMint(props) {
51
53
  const t = (0, import_provider.useT)();
@@ -68,12 +70,7 @@ function FastMint(props) {
68
70
  const [status, setStatus] = (0, import_react.useState)("idle");
69
71
  const [errorMsg, setErrorMsg] = (0, import_react.useState)(null);
70
72
  const [step, setStep] = (0, import_react.useState)(null);
71
- const media = (0, import_use_ipfs_upload.useIpfsUpload)();
72
- const feature = (0, import_use_ipfs_upload.useIpfsUpload)();
73
- const [mediaFile, setMediaFile] = (0, import_react.useState)(null);
74
73
  const [mediaKind, setMediaKind] = (0, import_react.useState)("image");
75
- const mediaInputRef = (0, import_react.useRef)(null);
76
- const featureInputRef = (0, import_react.useRef)(null);
77
74
  const [formatKey, setFormatKey] = (0, import_react.useState)("single");
78
75
  const [formatStates, setFormatStates] = (0, import_react.useState)(import_registry.initialFormatStates);
79
76
  const [resume, setResume] = (0, import_react.useState)(null);
@@ -97,31 +94,33 @@ function FastMint(props) {
97
94
  if (!token) throw new Error("Sign in first");
98
95
  return (await (0, import_ipfs_upload.uploadFileToIpfs)(client.api, file, kind)).uri;
99
96
  };
100
- const handleMediaSelect = async (file) => {
97
+ const routeFor = (file) => import_media_kind.MEDIA_ROUTE_MIME_TYPES.has(file.type) ? "media" : "document";
98
+ const mediaProblem = (file) => {
101
99
  const kind = (0, import_media_kind.detectMediaKind)(file.type);
102
- if (!kind) {
103
- setErrorMsg("Use a supported media file.");
104
- return;
105
- }
100
+ if (!kind) return (0, import_translate.msg)("Use a supported media file.");
106
101
  if (mediaKindLock && kind !== mediaKindLock) {
107
- setErrorMsg(`Please upload a${mediaKindLock === "image" ? "n" : ""} ${mediaKindLock}.`);
108
- return;
109
- }
110
- const route = import_media_kind.MEDIA_ROUTE_MIME_TYPES.has(file.type) ? "media" : "document";
111
- const fileError = (0, import_upload_limits.uploadError)(file, route);
112
- if (fileError) {
113
- setErrorMsg(fileError);
114
- return;
102
+ return mediaKindLock === "image" ? (0, import_translate.msg)("Please upload an image.") : `Please upload a ${mediaKindLock}.`;
115
103
  }
116
- setMediaFile(file);
117
- setMediaKind(kind);
118
- setIpType(import_media_kind.IP_TYPE_BY_KIND[kind]);
119
- await media.start(file, (f) => uploadFile(f, route), setErrorMsg);
104
+ return (0, import_upload_limits.uploadError)(file, routeFor(file));
120
105
  };
121
- const clearMedia = () => {
122
- setMediaFile(null);
123
- media.clear();
124
- if (mediaInputRef.current) mediaInputRef.current.value = "";
106
+ const media = (0, import_use_file_upload.useFileUpload)({
107
+ validate: mediaProblem,
108
+ upload: (file) => uploadFile(file, routeFor(file)),
109
+ failureMessage: (0, import_translate.msg)("Upload failed")
110
+ });
111
+ const feature = (0, import_use_file_upload.useFileUpload)({
112
+ validate: (file) => (0, import_upload_limits.uploadError)(file, "image"),
113
+ upload: (file) => uploadFile(file, "image"),
114
+ failureMessage: (0, import_translate.msg)("Upload failed")
115
+ });
116
+ const mediaFile = media.status !== "failed" || media.canRetry ? media.file : null;
117
+ const handleMediaSelect = (file) => {
118
+ const kind = (0, import_media_kind.detectMediaKind)(file.type);
119
+ if (kind && !mediaProblem(file)) {
120
+ setMediaKind(kind);
121
+ setIpType(import_media_kind.IP_TYPE_BY_KIND[kind]);
122
+ }
123
+ void media.select(file);
125
124
  };
126
125
  const image = mediaKind === "image" ? media.uri : feature.uri;
127
126
  const previewImage = mediaKind === "image" ? media.preview : feature.preview;
@@ -188,7 +187,7 @@ function FastMint(props) {
188
187
  setResult(null);
189
188
  setResume(null);
190
189
  form.reset();
191
- clearMedia();
190
+ media.clear();
192
191
  feature.clear();
193
192
  setFormatStates((0, import_registry.initialFormatStates)());
194
193
  draft.reset();
@@ -212,17 +211,20 @@ function FastMint(props) {
212
211
  }
213
212
  if (!mediaFile) {
214
213
  return wrap(
215
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
216
- import_dropzone.Dropzone,
217
- {
218
- mediaKindLock,
219
- presentation,
220
- hasWallet,
221
- onRequireWallet,
222
- connectLabel,
223
- onFileSelected: handleMediaSelect
224
- }
225
- )
214
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-3", children: [
215
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
216
+ import_dropzone.Dropzone,
217
+ {
218
+ mediaKindLock,
219
+ presentation,
220
+ hasWallet,
221
+ onRequireWallet,
222
+ connectLabel,
223
+ onFileSelected: handleMediaSelect
224
+ }
225
+ ),
226
+ media.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", className: "text-center text-sm text-destructive", children: media.error })
227
+ ] })
226
228
  );
227
229
  }
228
230
  const submitBlocked = !ready || busy || !hasWallet;
@@ -238,7 +240,8 @@ function FastMint(props) {
238
240
  uri: media.uri,
239
241
  uploading: media.uploading,
240
242
  ipType,
241
- inputRef: mediaInputRef,
243
+ error: media.error,
244
+ onRetry: () => void media.retry(),
242
245
  onSelect: handleMediaSelect
243
246
  }
244
247
  ),
@@ -284,12 +287,11 @@ function FastMint(props) {
284
287
  )
285
288
  ] }),
286
289
  mediaKind !== "image" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
287
- import_asset_form_parts.CoverUpload,
290
+ import_image_upload_field.ImageUploadField,
288
291
  {
289
- preview: feature.preview,
290
- uploading: feature.uploading,
291
- inputRef: featureInputRef,
292
- onSelect: (file) => void feature.start(file, (f) => uploadFile(f, "image"), setErrorMsg)
292
+ upload: feature,
293
+ label: t("Upload a cover image for your asset *"),
294
+ hint: t("Cover art for previews.")
293
295
  }
294
296
  ),
295
297
  shared && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(format.Fields, { shared, state: formatState, update: updateFormat }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/fast-mint/fast-mint.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport { Loader2 } from \"lucide-react\";\nimport { profileHref } from \"@medialane/sdk\";\nimport { describeError } from \"../../utils/describe-error.js\";\nimport { uploadError } from \"../../utils/upload-limits.js\";\nimport { uploadFileToIpfs, type SignedUploadKind } from \"../../utils/ipfs-upload.js\";\nimport { invalidatePortfolioCache } from \"../../utils/portfolio-cache.js\";\nimport type { IPType } from \"../../data/ip.js\";\nimport { Input } from \"../input.js\";\nimport { Textarea } from \"../textarea.js\";\nimport { MedialaneCollectionCard } from \"../medialane-collection-card.js\";\nimport { Dialog, DialogContent, DialogDescription, DialogTitle } from \"../dialog.js\";\nimport type { MetadataField } from \"../ip-type-fields.js\";\nimport { Dropzone } from \"./dropzone.js\";\nimport { SuccessView } from \"./success-view.js\";\nimport { CoverUpload, FormatPicker, MediaRow } from \"./asset-form-parts.js\";\nimport { PartialCreateError, type StepInfo } from \"./create-then-add.js\";\nimport { FORMATS, getFormat, initialFormatStates } from \"./formats/registry.js\";\nimport type { FormatResult, FormatShared, MintFormat } from \"./formats/types.js\";\nimport { DEFAULT_VALUES, type FormValues } from \"./form.js\";\nimport { IP_TYPE_BY_KIND, MEDIA_ROUTE_MIME_TYPES, detectMediaKind } from \"./media-kind.js\";\nimport { isWebLink } from \"../../utils/launchpad-rules.js\";\nimport { useIpfsUpload } from \"./use-ipfs-upload.js\";\nimport { useNewCollectionDraft } from \"./use-new-collection-draft.js\";\nimport type { FastMintProps, MediaKind } from \"./types.js\";\nimport { useT } from \"../../i18n/provider.js\";\nimport { ActionButton } from \"../action-button.js\";\n\nexport function FastMint(props: FastMintProps) {\n const t = useT();\n const {\n presentation = \"inline\", open = true, onClose, mediaKindLock, onMinted,\n collections, refetchCollections,\n hasWallet, walletAddress, onRequireWallet, connectLabel, getUploadToken, getSigner,\n client,\n } = props;\n\n const [status, setStatus] = useState<\"idle\" | \"minting\" | \"success\" | \"error\">(\"idle\");\n const [errorMsg, setErrorMsg] = useState<string | null>(null);\n const [step, setStep] = useState<StepInfo | null>(null);\n\n const media = useIpfsUpload();\n const feature = useIpfsUpload();\n const [mediaFile, setMediaFile] = useState<File | null>(null);\n const [mediaKind, setMediaKind] = useState<MediaKind>(\"image\");\n const mediaInputRef = useRef<HTMLInputElement>(null);\n const featureInputRef = useRef<HTMLInputElement>(null);\n\n const [formatKey, setFormatKey] = useState<MintFormat>(\"single\");\n const [formatStates, setFormatStates] = useState(initialFormatStates);\n const [resume, setResume] = useState<{ format: MintFormat; destination: unknown } | null>(null);\n const [result, setResult] = useState<FormatResult | null>(null);\n\n const [ipType, setIpType] = useState<IPType>(\"NFT\");\n const templateFieldsRef = useRef<MetadataField[]>([]);\n\n const form = useForm<FormValues>({ defaultValues: DEFAULT_VALUES });\n const name = form.watch(\"name\");\n const description = form.watch(\"description\");\n const draft = useNewCollectionDraft(name, description);\n\n useEffect(() => {\n if (walletAddress && !form.getValues(\"external_url\")) {\n form.setValue(\"external_url\", `https://medialane.io/account/${walletAddress}`);\n }\n }, [walletAddress, form]);\n\n const format = getFormat(formatKey);\n const formatState = formatStates[formatKey];\n const updateFormat = (patch: object) =>\n setFormatStates((states) => ({ ...states, [formatKey]: { ...(states[formatKey] as object), ...patch } }));\n\n const uploadFile = async (file: File, kind: SignedUploadKind) => {\n const token = await getUploadToken();\n if (!token) throw new Error(\"Sign in first\");\n return (await uploadFileToIpfs(client.api, file, kind)).uri;\n };\n\n const handleMediaSelect = async (file: File) => {\n const kind = detectMediaKind(file.type);\n if (!kind) {\n setErrorMsg(\"Use a supported media file.\");\n return;\n }\n if (mediaKindLock && kind !== mediaKindLock) {\n setErrorMsg(`Please upload a${mediaKindLock === \"image\" ? \"n\" : \"\"} ${mediaKindLock}.`);\n return;\n }\n const route = MEDIA_ROUTE_MIME_TYPES.has(file.type) ? \"media\" : \"document\";\n const fileError = uploadError(file, route);\n if (fileError) {\n setErrorMsg(fileError);\n return;\n }\n setMediaFile(file);\n setMediaKind(kind);\n setIpType(IP_TYPE_BY_KIND[kind]);\n await media.start(file, (f) => uploadFile(f, route), setErrorMsg);\n };\n\n const clearMedia = () => {\n setMediaFile(null);\n media.clear();\n if (mediaInputRef.current) mediaInputRef.current.value = \"\";\n };\n\n const image = mediaKind === \"image\" ? media.uri : feature.uri;\n const previewImage = mediaKind === \"image\" ? media.preview : feature.preview;\n\n const shared: FormatShared | null = media.uri && image && mediaFile\n ? {\n form, draft, collections,\n walletAddress: walletAddress ?? \"\",\n mediaKind, mediaUri: media.uri, mediaName: mediaFile.name, image, previewImage,\n ipType, onIpTypeChange: setIpType, templateFieldsRef,\n uploadDocument: (file) => uploadFile(file, \"document\"),\n }\n : null;\n\n const ready = !!shared && !media.uploading && !feature.uploading && name.trim().length > 0 && format.isReady(shared, formatState);\n\n const onSubmit = async () => {\n if (!hasWallet) { onRequireWallet(); return; }\n if (!shared || !walletAddress) return;\n const link = form.getValues(\"external_url\");\n if (!isWebLink(link)) {\n setErrorMsg(\"External link must start with http:// or https://\");\n setStatus(\"error\");\n return;\n }\n\n setStatus(\"minting\");\n setErrorMsg(null);\n setStep(null);\n\n try {\n const outcome = await format.submit(shared, formatState, {\n client,\n signer: await getSigner(),\n getUploadToken,\n resume: resume?.format === formatKey ? resume.destination : null,\n onStep: setStep,\n });\n setResult(outcome);\n setResume(null);\n setStatus(\"success\");\n invalidatePortfolioCache(walletAddress);\n if (outcome.asset) onMinted?.(outcome.asset);\n void refetchCollections().catch(() => {});\n } catch (err) {\n if (err instanceof PartialCreateError) {\n setResume({ format: formatKey, destination: err.destination });\n setErrorMsg(`${err.message} ${describeError(err.reason).message} Press the button again to finish.`);\n } else {\n setErrorMsg(describeError(err).message);\n }\n setStatus(\"error\");\n }\n };\n\n const resetAll = () => {\n setStatus(\"idle\");\n setErrorMsg(null);\n setStep(null);\n setResult(null);\n setResume(null);\n form.reset();\n clearMedia();\n feature.clear();\n setFormatStates(initialFormatStates());\n draft.reset();\n templateFieldsRef.current = [];\n };\n\n const busy = status === \"minting\";\n\n const wrap = (node: React.ReactNode) => {\n if (presentation !== \"dialog\") return node;\n return (\n <Dialog open={open} onOpenChange={(next) => { if (!next) onClose?.(); }}>\n <DialogContent className=\"gap-0 p-6 sm:max-w-2xl sm:p-8\">\n <DialogTitle className=\"sr-only\">{t(\"Create\")}</DialogTitle>\n <DialogDescription className=\"sr-only\">{t(\"Publish media as an asset.\")}</DialogDescription>\n {node}\n </DialogContent>\n </Dialog>\n );\n };\n\n if (status === \"success\" && result) {\n return wrap(\n <SuccessView presentation={presentation} previewImage={previewImage} result={result} onPublishAnother={resetAll} />\n );\n }\n\n if (!mediaFile) {\n return wrap(\n <Dropzone\n mediaKindLock={mediaKindLock}\n presentation={presentation}\n hasWallet={hasWallet}\n onRequireWallet={onRequireWallet}\n connectLabel={connectLabel}\n onFileSelected={handleMediaSelect}\n />\n );\n }\n\n const submitBlocked = !ready || busy || !hasWallet;\n const buttonLabel = busy\n ? `${step?.label ?? \"Working\"}…${step && step.total > 1 ? ` (${step.index} of ${step.total})` : \"\"}`\n : t(format.submitLabel(formatState));\n\n return wrap(\n <section className=\"space-y-6\">\n <MediaRow\n file={mediaFile}\n kind={mediaKind}\n preview={media.preview}\n uri={media.uri}\n uploading={media.uploading}\n ipType={ipType}\n inputRef={mediaInputRef}\n onSelect={handleMediaSelect}\n />\n\n {media.uri && (\n <div className=\"grid grid-cols-1 lg:grid-cols-[1fr_320px] gap-8 items-start\">\n <div className=\"space-y-5\">\n <FormatPicker formats={FORMATS} value={formatKey} onChange={setFormatKey} />\n\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t(\"Title *\")}</label>\n <Input\n value={name}\n onChange={(e) => form.setValue(\"name\", e.target.value)}\n placeholder={t(\"My Creative Work\")}\n />\n </div>\n\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t(\"Description\")}</label>\n <Textarea\n value={description}\n onChange={(e) => form.setValue(\"description\", e.target.value)}\n placeholder={t(\"The story behind the work…\")}\n rows={3}\n />\n </div>\n\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t(\"External link\")} <span className=\"text-muted-foreground font-normal\">{t(\"(optional)\")}</span></label>\n <Input\n value={form.watch(\"external_url\")}\n onChange={(e) => form.setValue(\"external_url\", e.target.value)}\n placeholder={t(\"https://yourwebsite.com\")}\n />\n </div>\n\n {mediaKind !== \"image\" && (\n <CoverUpload\n preview={feature.preview}\n uploading={feature.uploading}\n inputRef={featureInputRef}\n onSelect={(file) => void feature.start(file, (f) => uploadFile(f, \"image\"), setErrorMsg)}\n />\n )}\n\n {shared && <format.Fields shared={shared} state={formatState} update={updateFormat} />}\n\n {status === \"error\" && errorMsg && <p className=\"text-xs text-destructive\">{errorMsg}</p>}\n\n <ActionButton solid big type=\"button\" disabled={submitBlocked} onClick={() => void onSubmit()} className=\"w-full\">\n {busy && <Loader2 className=\"h-4 w-4 animate-spin\" />}\n {buttonLabel}\n </ActionButton>\n <p className=\"text-xs text-center text-muted-foreground\">\n {t(\"Zero platform fees to mint.\")}\n </p>\n </div>\n\n <div className=\"order-first lg:order-last lg:sticky lg:top-20 max-w-[260px] mx-auto w-full lg:max-w-none lg:mx-0\">\n <MedialaneCollectionCard\n image={previewImage}\n name={name}\n collection={shared ? format.previewLabel(shared, formatState) : undefined}\n creator={walletAddress ? `${walletAddress.slice(0, 6)}…${walletAddress.slice(-4)}` : undefined}\n creatorHref={walletAddress ? profileHref({ address: walletAddress }) : undefined}\n />\n </div>\n </div>\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuLQ;AArLR,mBAA4C;AAC5C,6BAAwB;AACxB,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SAAS,gBAAgB,GAAG,cAAc,MAAM,GAAG,CAAC,CAAC,SAAI,cAAc,MAAM,EAAE,CAAC,KAAK;AAAA,YACrF,aAAa,oBAAgB,wBAAY,EAAE,SAAS,cAAc,CAAC,IAAI;AAAA;AAAA,QACzE,GACF;AAAA,SACF;AAAA,OAEJ;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/fast-mint/fast-mint.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport { Loader2 } from \"lucide-react\";\nimport { profileHref } from \"@medialane/sdk\";\nimport { describeError } from \"../../utils/describe-error.js\";\nimport { uploadError } from \"../../utils/upload-limits.js\";\nimport { uploadFileToIpfs, type SignedUploadKind } from \"../../utils/ipfs-upload.js\";\nimport { invalidatePortfolioCache } from \"../../utils/portfolio-cache.js\";\nimport type { IPType } from \"../../data/ip.js\";\nimport { Input } from \"../input.js\";\nimport { Textarea } from \"../textarea.js\";\nimport { MedialaneCollectionCard } from \"../medialane-collection-card.js\";\nimport { Dialog, DialogContent, DialogDescription, DialogTitle } from \"../dialog.js\";\nimport type { MetadataField } from \"../ip-type-fields.js\";\nimport { Dropzone } from \"./dropzone.js\";\nimport { SuccessView } from \"./success-view.js\";\nimport { FormatPicker, MediaRow } from \"./asset-form-parts.js\";\nimport { PartialCreateError, type StepInfo } from \"./create-then-add.js\";\nimport { FORMATS, getFormat, initialFormatStates } from \"./formats/registry.js\";\nimport type { FormatResult, FormatShared, MintFormat } from \"./formats/types.js\";\nimport { DEFAULT_VALUES, type FormValues } from \"./form.js\";\nimport { IP_TYPE_BY_KIND, MEDIA_ROUTE_MIME_TYPES, detectMediaKind } from \"./media-kind.js\";\nimport { isWebLink } from \"../../utils/launchpad-rules.js\";\nimport { useFileUpload } from \"../../utils/use-file-upload.js\";\nimport { ImageUploadField } from \"../image-upload-field.js\";\nimport { useNewCollectionDraft } from \"./use-new-collection-draft.js\";\nimport type { FastMintProps, MediaKind } from \"./types.js\";\nimport { useT } from \"../../i18n/provider.js\";\nimport { msg } from \"../../i18n/translate.js\";\nimport { ActionButton } from \"../action-button.js\";\n\nexport function FastMint(props: FastMintProps) {\n const t = useT();\n const {\n presentation = \"inline\", open = true, onClose, mediaKindLock, onMinted,\n collections, refetchCollections,\n hasWallet, walletAddress, onRequireWallet, connectLabel, getUploadToken, getSigner,\n client,\n } = props;\n\n const [status, setStatus] = useState<\"idle\" | \"minting\" | \"success\" | \"error\">(\"idle\");\n const [errorMsg, setErrorMsg] = useState<string | null>(null);\n const [step, setStep] = useState<StepInfo | null>(null);\n\n const [mediaKind, setMediaKind] = useState<MediaKind>(\"image\");\n\n const [formatKey, setFormatKey] = useState<MintFormat>(\"single\");\n const [formatStates, setFormatStates] = useState(initialFormatStates);\n const [resume, setResume] = useState<{ format: MintFormat; destination: unknown } | null>(null);\n const [result, setResult] = useState<FormatResult | null>(null);\n\n const [ipType, setIpType] = useState<IPType>(\"NFT\");\n const templateFieldsRef = useRef<MetadataField[]>([]);\n\n const form = useForm<FormValues>({ defaultValues: DEFAULT_VALUES });\n const name = form.watch(\"name\");\n const description = form.watch(\"description\");\n const draft = useNewCollectionDraft(name, description);\n\n useEffect(() => {\n if (walletAddress && !form.getValues(\"external_url\")) {\n form.setValue(\"external_url\", `https://medialane.io/account/${walletAddress}`);\n }\n }, [walletAddress, form]);\n\n const format = getFormat(formatKey);\n const formatState = formatStates[formatKey];\n const updateFormat = (patch: object) =>\n setFormatStates((states) => ({ ...states, [formatKey]: { ...(states[formatKey] as object), ...patch } }));\n\n const uploadFile = async (file: File, kind: SignedUploadKind) => {\n const token = await getUploadToken();\n if (!token) throw new Error(\"Sign in first\");\n return (await uploadFileToIpfs(client.api, file, kind)).uri;\n };\n\n const routeFor = (file: File) => (MEDIA_ROUTE_MIME_TYPES.has(file.type) ? \"media\" : \"document\");\n\n const mediaProblem = (file: File) => {\n const kind = detectMediaKind(file.type);\n if (!kind) return msg(\"Use a supported media file.\");\n if (mediaKindLock && kind !== mediaKindLock) {\n return mediaKindLock === \"image\" ? msg(\"Please upload an image.\") : `Please upload a ${mediaKindLock}.`;\n }\n return uploadError(file, routeFor(file));\n };\n\n const media = useFileUpload({\n validate: mediaProblem,\n upload: (file) => uploadFile(file, routeFor(file)),\n failureMessage: msg(\"Upload failed\"),\n });\n const feature = useFileUpload({\n validate: (file) => uploadError(file, \"image\"),\n upload: (file) => uploadFile(file, \"image\"),\n failureMessage: msg(\"Upload failed\"),\n });\n const mediaFile = media.status !== \"failed\" || media.canRetry ? media.file : null;\n\n const handleMediaSelect = (file: File) => {\n const kind = detectMediaKind(file.type);\n if (kind && !mediaProblem(file)) {\n setMediaKind(kind);\n setIpType(IP_TYPE_BY_KIND[kind]);\n }\n void media.select(file);\n };\n\n const image = mediaKind === \"image\" ? media.uri : feature.uri;\n const previewImage = mediaKind === \"image\" ? media.preview : feature.preview;\n\n const shared: FormatShared | null = media.uri && image && mediaFile\n ? {\n form, draft, collections,\n walletAddress: walletAddress ?? \"\",\n mediaKind, mediaUri: media.uri, mediaName: mediaFile.name, image, previewImage,\n ipType, onIpTypeChange: setIpType, templateFieldsRef,\n uploadDocument: (file) => uploadFile(file, \"document\"),\n }\n : null;\n\n const ready = !!shared && !media.uploading && !feature.uploading && name.trim().length > 0 && format.isReady(shared, formatState);\n\n const onSubmit = async () => {\n if (!hasWallet) { onRequireWallet(); return; }\n if (!shared || !walletAddress) return;\n const link = form.getValues(\"external_url\");\n if (!isWebLink(link)) {\n setErrorMsg(\"External link must start with http:// or https://\");\n setStatus(\"error\");\n return;\n }\n\n setStatus(\"minting\");\n setErrorMsg(null);\n setStep(null);\n\n try {\n const outcome = await format.submit(shared, formatState, {\n client,\n signer: await getSigner(),\n getUploadToken,\n resume: resume?.format === formatKey ? resume.destination : null,\n onStep: setStep,\n });\n setResult(outcome);\n setResume(null);\n setStatus(\"success\");\n invalidatePortfolioCache(walletAddress);\n if (outcome.asset) onMinted?.(outcome.asset);\n void refetchCollections().catch(() => {});\n } catch (err) {\n if (err instanceof PartialCreateError) {\n setResume({ format: formatKey, destination: err.destination });\n setErrorMsg(`${err.message} ${describeError(err.reason).message} Press the button again to finish.`);\n } else {\n setErrorMsg(describeError(err).message);\n }\n setStatus(\"error\");\n }\n };\n\n const resetAll = () => {\n setStatus(\"idle\");\n setErrorMsg(null);\n setStep(null);\n setResult(null);\n setResume(null);\n form.reset();\n media.clear();\n feature.clear();\n setFormatStates(initialFormatStates());\n draft.reset();\n templateFieldsRef.current = [];\n };\n\n const busy = status === \"minting\";\n\n const wrap = (node: React.ReactNode) => {\n if (presentation !== \"dialog\") return node;\n return (\n <Dialog open={open} onOpenChange={(next) => { if (!next) onClose?.(); }}>\n <DialogContent className=\"gap-0 p-6 sm:max-w-2xl sm:p-8\">\n <DialogTitle className=\"sr-only\">{t(\"Create\")}</DialogTitle>\n <DialogDescription className=\"sr-only\">{t(\"Publish media as an asset.\")}</DialogDescription>\n {node}\n </DialogContent>\n </Dialog>\n );\n };\n\n if (status === \"success\" && result) {\n return wrap(\n <SuccessView presentation={presentation} previewImage={previewImage} result={result} onPublishAnother={resetAll} />\n );\n }\n\n if (!mediaFile) {\n return wrap(\n <div className=\"space-y-3\">\n <Dropzone\n mediaKindLock={mediaKindLock}\n presentation={presentation}\n hasWallet={hasWallet}\n onRequireWallet={onRequireWallet}\n connectLabel={connectLabel}\n onFileSelected={handleMediaSelect}\n />\n {media.error && <p role=\"alert\" className=\"text-center text-sm text-destructive\">{media.error}</p>}\n </div>\n );\n }\n\n const submitBlocked = !ready || busy || !hasWallet;\n const buttonLabel = busy\n ? `${step?.label ?? \"Working\"}…${step && step.total > 1 ? ` (${step.index} of ${step.total})` : \"\"}`\n : t(format.submitLabel(formatState));\n\n return wrap(\n <section className=\"space-y-6\">\n <MediaRow\n file={mediaFile}\n kind={mediaKind}\n preview={media.preview}\n uri={media.uri}\n uploading={media.uploading}\n ipType={ipType}\n error={media.error}\n onRetry={() => void media.retry()}\n onSelect={handleMediaSelect}\n />\n\n {media.uri && (\n <div className=\"grid grid-cols-1 lg:grid-cols-[1fr_320px] gap-8 items-start\">\n <div className=\"space-y-5\">\n <FormatPicker formats={FORMATS} value={formatKey} onChange={setFormatKey} />\n\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t(\"Title *\")}</label>\n <Input\n value={name}\n onChange={(e) => form.setValue(\"name\", e.target.value)}\n placeholder={t(\"My Creative Work\")}\n />\n </div>\n\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t(\"Description\")}</label>\n <Textarea\n value={description}\n onChange={(e) => form.setValue(\"description\", e.target.value)}\n placeholder={t(\"The story behind the work…\")}\n rows={3}\n />\n </div>\n\n <div className=\"space-y-2\">\n <label className=\"text-sm font-medium\">{t(\"External link\")} <span className=\"text-muted-foreground font-normal\">{t(\"(optional)\")}</span></label>\n <Input\n value={form.watch(\"external_url\")}\n onChange={(e) => form.setValue(\"external_url\", e.target.value)}\n placeholder={t(\"https://yourwebsite.com\")}\n />\n </div>\n\n {mediaKind !== \"image\" && (\n <ImageUploadField\n upload={feature}\n label={t(\"Upload a cover image for your asset *\")}\n hint={t(\"Cover art for previews.\")}\n />\n )}\n\n {shared && <format.Fields shared={shared} state={formatState} update={updateFormat} />}\n\n {status === \"error\" && errorMsg && <p className=\"text-xs text-destructive\">{errorMsg}</p>}\n\n <ActionButton solid big type=\"button\" disabled={submitBlocked} onClick={() => void onSubmit()} className=\"w-full\">\n {busy && <Loader2 className=\"h-4 w-4 animate-spin\" />}\n {buttonLabel}\n </ActionButton>\n <p className=\"text-xs text-center text-muted-foreground\">\n {t(\"Zero platform fees to mint.\")}\n </p>\n </div>\n\n <div className=\"order-first lg:order-last lg:sticky lg:top-20 max-w-[260px] mx-auto w-full lg:max-w-none lg:mx-0\">\n <MedialaneCollectionCard\n image={previewImage}\n name={name}\n collection={shared ? format.previewLabel(shared, formatState) : undefined}\n creator={walletAddress ? `${walletAddress.slice(0, 6)}…${walletAddress.slice(-4)}` : undefined}\n creatorHref={walletAddress ? profileHref({ address: walletAddress }) : undefined}\n />\n </div>\n </div>\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwLQ;AAtLR,mBAA4C;AAC5C,6BAAwB;AACxB,0BAAwB;AACxB,iBAA4B;AAC5B,4BAA8B;AAC9B,2BAA4B;AAC5B,yBAAwD;AACxD,6BAAyC;AAEzC,mBAAsB;AACtB,sBAAyB;AACzB,uCAAwC;AACxC,oBAAsE;AAEtE,sBAAyB;AACzB,0BAA4B;AAC5B,8BAAuC;AACvC,6BAAkD;AAClD,sBAAwD;AAExD,kBAAgD;AAChD,wBAAyE;AACzE,6BAA0B;AAC1B,6BAA8B;AAC9B,gCAAiC;AACjC,sCAAsC;AAEtC,sBAAqB;AACrB,uBAAoB;AACpB,2BAA6B;AAEtB,SAAS,SAAS,OAAsB;AAC7C,QAAM,QAAI,sBAAK;AACf,QAAM;AAAA,IACJ,eAAe;AAAA,IAAU,OAAO;AAAA,IAAM;AAAA,IAAS;AAAA,IAAe;AAAA,IAC9D;AAAA,IAAa;AAAA,IACb;AAAA,IAAW;AAAA,IAAe;AAAA,IAAiB;AAAA,IAAc;AAAA,IAAgB;AAAA,IACzE;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAmD,MAAM;AACrF,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAwB,IAAI;AAC5D,QAAM,CAAC,MAAM,OAAO,QAAI,uBAA0B,IAAI;AAEtD,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAoB,OAAO;AAE7D,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAqB,QAAQ;AAC/D,QAAM,CAAC,cAAc,eAAe,QAAI,uBAAS,mCAAmB;AACpE,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAA8D,IAAI;AAC9F,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAA8B,IAA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YAAY,4CAAC,OAAE,WAAU,4BAA4B,oBAAS;AAAA,UAErF,6CAAC,qCAAa,OAAK,MAAC,KAAG,MAAC,MAAK,UAAS,UAAU,eAAe,SAAS,MAAM,KAAK,SAAS,GAAG,WAAU,UACtG;AAAA,oBAAQ,4CAAC,+BAAQ,WAAU,wBAAuB;AAAA,YAClD;AAAA,aACH;AAAA,UACA,4CAAC,OAAE,WAAU,6CACV,YAAE,6BAA6B,GAClC;AAAA,WACF;AAAA,QAEA,4CAAC,SAAI,WAAU,oGACb;AAAA,UAAC;AAAA;AAAA,YACC,OAAO;AAAA,YACP;AAAA,YACA,YAAY,SAAS,OAAO,aAAa,QAAQ,WAAW,IAAI;AAAA,YAChE,SAAS,gBAAgB,GAAG,cAAc,MAAM,GAAG,CAAC,CAAC,SAAI,cAAc,MAAM,EAAE,CAAC,KAAK;AAAA,YACrF,aAAa,oBAAgB,wBAAY,EAAE,SAAS,cAAc,CAAC,IAAI;AAAA;AAAA,QACzE,GACF;AAAA,SACF;AAAA,OAEJ;AAAA,EACF;AACF;","names":[]}
@@ -14,15 +14,17 @@ import { MedialaneCollectionCard } from "../medialane-collection-card.js";
14
14
  import { Dialog, DialogContent, DialogDescription, DialogTitle } from "../dialog.js";
15
15
  import { Dropzone } from "./dropzone.js";
16
16
  import { SuccessView } from "./success-view.js";
17
- import { CoverUpload, FormatPicker, MediaRow } from "./asset-form-parts.js";
17
+ import { FormatPicker, MediaRow } from "./asset-form-parts.js";
18
18
  import { PartialCreateError } from "./create-then-add.js";
19
19
  import { FORMATS, getFormat, initialFormatStates } from "./formats/registry.js";
20
20
  import { DEFAULT_VALUES } from "./form.js";
21
21
  import { IP_TYPE_BY_KIND, MEDIA_ROUTE_MIME_TYPES, detectMediaKind } from "./media-kind.js";
22
22
  import { isWebLink } from "../../utils/launchpad-rules.js";
23
- import { useIpfsUpload } from "./use-ipfs-upload.js";
23
+ import { useFileUpload } from "../../utils/use-file-upload.js";
24
+ import { ImageUploadField } from "../image-upload-field.js";
24
25
  import { useNewCollectionDraft } from "./use-new-collection-draft.js";
25
26
  import { useT } from "../../i18n/provider.js";
27
+ import { msg } from "../../i18n/translate.js";
26
28
  import { ActionButton } from "../action-button.js";
27
29
  function FastMint(props) {
28
30
  const t = useT();
@@ -45,12 +47,7 @@ function FastMint(props) {
45
47
  const [status, setStatus] = useState("idle");
46
48
  const [errorMsg, setErrorMsg] = useState(null);
47
49
  const [step, setStep] = useState(null);
48
- const media = useIpfsUpload();
49
- const feature = useIpfsUpload();
50
- const [mediaFile, setMediaFile] = useState(null);
51
50
  const [mediaKind, setMediaKind] = useState("image");
52
- const mediaInputRef = useRef(null);
53
- const featureInputRef = useRef(null);
54
51
  const [formatKey, setFormatKey] = useState("single");
55
52
  const [formatStates, setFormatStates] = useState(initialFormatStates);
56
53
  const [resume, setResume] = useState(null);
@@ -74,31 +71,33 @@ function FastMint(props) {
74
71
  if (!token) throw new Error("Sign in first");
75
72
  return (await uploadFileToIpfs(client.api, file, kind)).uri;
76
73
  };
77
- const handleMediaSelect = async (file) => {
74
+ const routeFor = (file) => MEDIA_ROUTE_MIME_TYPES.has(file.type) ? "media" : "document";
75
+ const mediaProblem = (file) => {
78
76
  const kind = detectMediaKind(file.type);
79
- if (!kind) {
80
- setErrorMsg("Use a supported media file.");
81
- return;
82
- }
77
+ if (!kind) return msg("Use a supported media file.");
83
78
  if (mediaKindLock && kind !== mediaKindLock) {
84
- setErrorMsg(`Please upload a${mediaKindLock === "image" ? "n" : ""} ${mediaKindLock}.`);
85
- return;
86
- }
87
- const route = MEDIA_ROUTE_MIME_TYPES.has(file.type) ? "media" : "document";
88
- const fileError = uploadError(file, route);
89
- if (fileError) {
90
- setErrorMsg(fileError);
91
- return;
79
+ return mediaKindLock === "image" ? msg("Please upload an image.") : `Please upload a ${mediaKindLock}.`;
92
80
  }
93
- setMediaFile(file);
94
- setMediaKind(kind);
95
- setIpType(IP_TYPE_BY_KIND[kind]);
96
- await media.start(file, (f) => uploadFile(f, route), setErrorMsg);
81
+ return uploadError(file, routeFor(file));
97
82
  };
98
- const clearMedia = () => {
99
- setMediaFile(null);
100
- media.clear();
101
- if (mediaInputRef.current) mediaInputRef.current.value = "";
83
+ const media = useFileUpload({
84
+ validate: mediaProblem,
85
+ upload: (file) => uploadFile(file, routeFor(file)),
86
+ failureMessage: msg("Upload failed")
87
+ });
88
+ const feature = useFileUpload({
89
+ validate: (file) => uploadError(file, "image"),
90
+ upload: (file) => uploadFile(file, "image"),
91
+ failureMessage: msg("Upload failed")
92
+ });
93
+ const mediaFile = media.status !== "failed" || media.canRetry ? media.file : null;
94
+ const handleMediaSelect = (file) => {
95
+ const kind = detectMediaKind(file.type);
96
+ if (kind && !mediaProblem(file)) {
97
+ setMediaKind(kind);
98
+ setIpType(IP_TYPE_BY_KIND[kind]);
99
+ }
100
+ void media.select(file);
102
101
  };
103
102
  const image = mediaKind === "image" ? media.uri : feature.uri;
104
103
  const previewImage = mediaKind === "image" ? media.preview : feature.preview;
@@ -165,7 +164,7 @@ function FastMint(props) {
165
164
  setResult(null);
166
165
  setResume(null);
167
166
  form.reset();
168
- clearMedia();
167
+ media.clear();
169
168
  feature.clear();
170
169
  setFormatStates(initialFormatStates());
171
170
  draft.reset();
@@ -189,17 +188,20 @@ function FastMint(props) {
189
188
  }
190
189
  if (!mediaFile) {
191
190
  return wrap(
192
- /* @__PURE__ */ jsx(
193
- Dropzone,
194
- {
195
- mediaKindLock,
196
- presentation,
197
- hasWallet,
198
- onRequireWallet,
199
- connectLabel,
200
- onFileSelected: handleMediaSelect
201
- }
202
- )
191
+ /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
192
+ /* @__PURE__ */ jsx(
193
+ Dropzone,
194
+ {
195
+ mediaKindLock,
196
+ presentation,
197
+ hasWallet,
198
+ onRequireWallet,
199
+ connectLabel,
200
+ onFileSelected: handleMediaSelect
201
+ }
202
+ ),
203
+ media.error && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-center text-sm text-destructive", children: media.error })
204
+ ] })
203
205
  );
204
206
  }
205
207
  const submitBlocked = !ready || busy || !hasWallet;
@@ -215,7 +217,8 @@ function FastMint(props) {
215
217
  uri: media.uri,
216
218
  uploading: media.uploading,
217
219
  ipType,
218
- inputRef: mediaInputRef,
220
+ error: media.error,
221
+ onRetry: () => void media.retry(),
219
222
  onSelect: handleMediaSelect
220
223
  }
221
224
  ),
@@ -261,12 +264,11 @@ function FastMint(props) {
261
264
  )
262
265
  ] }),
263
266
  mediaKind !== "image" && /* @__PURE__ */ jsx(
264
- CoverUpload,
267
+ ImageUploadField,
265
268
  {
266
- preview: feature.preview,
267
- uploading: feature.uploading,
268
- inputRef: featureInputRef,
269
- onSelect: (file) => void feature.start(file, (f) => uploadFile(f, "image"), setErrorMsg)
269
+ upload: feature,
270
+ label: t("Upload a cover image for your asset *"),
271
+ hint: t("Cover art for previews.")
270
272
  }
271
273
  ),
272
274
  shared && /* @__PURE__ */ jsx(format.Fields, { shared, state: formatState, update: updateFormat }),