@medialane/ui 0.366.0 → 0.368.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.
- package/dist/components/alert.d.cts +1 -1
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/approve-mint-dialog.d.cts +0 -1
- package/dist/components/approve-mint-dialog.d.ts +0 -1
- package/dist/components/asset-card.cjs +3 -3
- package/dist/components/asset-card.cjs.map +1 -1
- package/dist/components/asset-card.js +3 -3
- package/dist/components/asset-card.js.map +1 -1
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/button.d.cts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/collection-card.cjs +3 -3
- package/dist/components/collection-card.cjs.map +1 -1
- package/dist/components/collection-card.js +3 -3
- package/dist/components/collection-card.js.map +1 -1
- package/dist/components/collection-page.cjs +1 -1
- package/dist/components/collection-page.cjs.map +1 -1
- package/dist/components/collection-page.js +1 -1
- package/dist/components/collection-page.js.map +1 -1
- package/dist/components/fast-mint/asset-form-parts.cjs +25 -51
- package/dist/components/fast-mint/asset-form-parts.cjs.map +1 -1
- package/dist/components/fast-mint/asset-form-parts.d.cts +11 -14
- package/dist/components/fast-mint/asset-form-parts.d.ts +11 -14
- package/dist/components/fast-mint/asset-form-parts.js +27 -52
- package/dist/components/fast-mint/asset-form-parts.js.map +1 -1
- package/dist/components/fast-mint/collection-section.cjs +11 -21
- package/dist/components/fast-mint/collection-section.cjs.map +1 -1
- package/dist/components/fast-mint/collection-section.d.cts +5 -7
- package/dist/components/fast-mint/collection-section.d.ts +5 -7
- package/dist/components/fast-mint/collection-section.js +11 -21
- package/dist/components/fast-mint/collection-section.js.map +1 -1
- package/dist/components/fast-mint/create-then-add.cjs +55 -0
- package/dist/components/fast-mint/create-then-add.cjs.map +1 -0
- package/dist/components/fast-mint/create-then-add.d.cts +24 -0
- package/dist/components/fast-mint/create-then-add.d.ts +24 -0
- package/dist/components/fast-mint/create-then-add.js +30 -0
- package/dist/components/fast-mint/create-then-add.js.map +1 -0
- package/dist/components/fast-mint/dropzone.d.cts +0 -1
- package/dist/components/fast-mint/dropzone.d.ts +0 -1
- package/dist/components/fast-mint/fast-mint.cjs +96 -167
- package/dist/components/fast-mint/fast-mint.cjs.map +1 -1
- package/dist/components/fast-mint/fast-mint.js +98 -169
- package/dist/components/fast-mint/fast-mint.js.map +1 -1
- package/dist/components/fast-mint/formats/nft.cjs +236 -0
- package/dist/components/fast-mint/formats/nft.cjs.map +1 -0
- package/dist/components/fast-mint/formats/nft.d.cts +19 -0
- package/dist/components/fast-mint/formats/nft.d.ts +19 -0
- package/dist/components/fast-mint/formats/nft.js +217 -0
- package/dist/components/fast-mint/formats/nft.js.map +1 -0
- package/dist/components/fast-mint/formats/pop.cjs +161 -0
- package/dist/components/fast-mint/formats/pop.cjs.map +1 -0
- package/dist/components/fast-mint/formats/pop.d.cts +18 -0
- package/dist/components/fast-mint/formats/pop.d.ts +18 -0
- package/dist/components/fast-mint/formats/pop.js +137 -0
- package/dist/components/fast-mint/formats/pop.js.map +1 -0
- package/dist/components/fast-mint/formats/registry.cjs +42 -0
- package/dist/components/fast-mint/formats/registry.cjs.map +1 -0
- package/dist/components/fast-mint/formats/registry.d.cts +20 -0
- package/dist/components/fast-mint/formats/registry.d.ts +20 -0
- package/dist/components/fast-mint/formats/registry.js +16 -0
- package/dist/components/fast-mint/formats/registry.js.map +1 -0
- package/dist/components/fast-mint/formats/tiers.cjs +206 -0
- package/dist/components/fast-mint/formats/tiers.cjs.map +1 -0
- package/dist/components/fast-mint/formats/tiers.d.cts +19 -0
- package/dist/components/fast-mint/formats/tiers.d.ts +19 -0
- package/dist/components/fast-mint/formats/tiers.js +181 -0
- package/dist/components/fast-mint/formats/tiers.js.map +1 -0
- package/dist/components/fast-mint/formats/types.cjs +31 -0
- package/dist/components/fast-mint/formats/types.cjs.map +1 -0
- package/dist/components/fast-mint/formats/types.d.cts +71 -0
- package/dist/components/fast-mint/formats/types.d.ts +71 -0
- package/dist/components/fast-mint/formats/types.js +7 -0
- package/dist/components/fast-mint/formats/types.js.map +1 -0
- package/dist/components/fast-mint/media-kind.d.cts +0 -1
- package/dist/components/fast-mint/media-kind.d.ts +0 -1
- package/dist/components/fast-mint/success-view.cjs +18 -59
- package/dist/components/fast-mint/success-view.cjs.map +1 -1
- package/dist/components/fast-mint/success-view.d.cts +13 -8
- package/dist/components/fast-mint/success-view.d.ts +13 -8
- package/dist/components/fast-mint/success-view.js +19 -60
- package/dist/components/fast-mint/success-view.js.map +1 -1
- package/dist/components/fast-mint/types.cjs.map +1 -1
- package/dist/components/fast-mint/types.d.cts +0 -3
- package/dist/components/fast-mint/types.d.ts +0 -3
- package/dist/components/launchpad/collection-create-form.cjs +9 -18
- package/dist/components/launchpad/collection-create-form.cjs.map +1 -1
- package/dist/components/launchpad/collection-create-form.js +9 -18
- package/dist/components/launchpad/collection-create-form.js.map +1 -1
- package/dist/components/launchpad/edition-mint-schema.cjs +3 -4
- package/dist/components/launchpad/edition-mint-schema.cjs.map +1 -1
- package/dist/components/launchpad/edition-mint-schema.d.cts +1 -1
- package/dist/components/launchpad/edition-mint-schema.d.ts +1 -1
- package/dist/components/launchpad/edition-mint-schema.js +3 -4
- package/dist/components/launchpad/edition-mint-schema.js.map +1 -1
- package/dist/components/launchpad/pop-create-fields.cjs +8 -6
- package/dist/components/launchpad/pop-create-fields.cjs.map +1 -1
- package/dist/components/launchpad/pop-create-fields.d.cts +8 -2
- package/dist/components/launchpad/pop-create-fields.d.ts +8 -2
- package/dist/components/launchpad/pop-create-fields.js +7 -6
- package/dist/components/launchpad/pop-create-fields.js.map +1 -1
- package/dist/components/launchpad/pop-create-schema.cjs +3 -4
- package/dist/components/launchpad/pop-create-schema.cjs.map +1 -1
- package/dist/components/launchpad/pop-create-schema.js +3 -4
- package/dist/components/launchpad/pop-create-schema.js.map +1 -1
- package/dist/components/launchpad/pop-create.cjs +12 -25
- package/dist/components/launchpad/pop-create.cjs.map +1 -1
- package/dist/components/launchpad/pop-create.js +12 -25
- package/dist/components/launchpad/pop-create.js.map +1 -1
- package/dist/components/launchpad/single-edition-mint.cjs +2 -1
- package/dist/components/launchpad/single-edition-mint.cjs.map +1 -1
- package/dist/components/launchpad/single-edition-mint.js +2 -1
- package/dist/components/launchpad/single-edition-mint.js.map +1 -1
- package/dist/components/launchpad/tier-mint-form.cjs +11 -27
- package/dist/components/launchpad/tier-mint-form.cjs.map +1 -1
- package/dist/components/launchpad/tier-mint-form.js +9 -25
- package/dist/components/launchpad/tier-mint-form.js.map +1 -1
- package/dist/components/launchpad-page.cjs +1 -2
- package/dist/components/launchpad-page.cjs.map +1 -1
- package/dist/components/launchpad-page.js +1 -2
- package/dist/components/launchpad-page.js.map +1 -1
- package/dist/components/page-skeletons.cjs +79 -47
- package/dist/components/page-skeletons.cjs.map +1 -1
- package/dist/components/page-skeletons.d.cts +3 -1
- package/dist/components/page-skeletons.d.ts +3 -1
- package/dist/components/page-skeletons.js +77 -47
- package/dist/components/page-skeletons.js.map +1 -1
- package/dist/components/pop-burn-button.cjs +1 -1
- package/dist/components/pop-burn-button.cjs.map +1 -1
- package/dist/components/pop-burn-button.js +1 -1
- package/dist/components/pop-burn-button.js.map +1 -1
- package/dist/components/pop-claim-button.cjs +3 -3
- package/dist/components/pop-claim-button.cjs.map +1 -1
- package/dist/components/pop-claim-button.js +3 -3
- package/dist/components/pop-claim-button.js.map +1 -1
- package/dist/components/pop-manage-page.cjs +3 -3
- package/dist/components/pop-manage-page.cjs.map +1 -1
- package/dist/components/pop-manage-page.js +3 -3
- package/dist/components/pop-manage-page.js.map +1 -1
- package/dist/components/service-collections-page.cjs +3 -2
- package/dist/components/service-collections-page.cjs.map +1 -1
- package/dist/components/service-collections-page.d.cts +2 -2
- package/dist/components/service-collections-page.d.ts +2 -2
- package/dist/components/service-collections-page.js +3 -2
- package/dist/components/service-collections-page.js.map +1 -1
- package/dist/components/token-card.cjs +7 -4
- package/dist/components/token-card.cjs.map +1 -1
- package/dist/components/token-card.js +7 -4
- package/dist/components/token-card.js.map +1 -1
- package/dist/components/transfer-dialog.d.cts +0 -1
- package/dist/components/transfer-dialog.d.ts +0 -1
- package/dist/data/launchpad-services.cjs +48 -27
- package/dist/data/launchpad-services.cjs.map +1 -1
- package/dist/data/launchpad-services.d.cts +11 -1
- package/dist/data/launchpad-services.d.ts +11 -1
- package/dist/data/launchpad-services.js +44 -26
- package/dist/data/launchpad-services.js.map +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/drop/actions.d.cts +0 -1
- package/dist/utils/drop/actions.d.ts +0 -1
- package/dist/utils/drop/draft.cjs +3 -2
- package/dist/utils/drop/draft.cjs.map +1 -1
- package/dist/utils/drop/draft.js +3 -2
- package/dist/utils/drop/draft.js.map +1 -1
- package/dist/utils/drop/sale.cjs +2 -1
- package/dist/utils/drop/sale.cjs.map +1 -1
- package/dist/utils/drop/sale.js +2 -1
- package/dist/utils/drop/sale.js.map +1 -1
- package/dist/utils/drop/types.d.cts +0 -1
- package/dist/utils/drop/types.d.ts +0 -1
- package/dist/utils/launchpad-actions.cjs +90 -0
- package/dist/utils/launchpad-actions.cjs.map +1 -0
- package/dist/utils/launchpad-actions.d.cts +39 -0
- package/dist/utils/launchpad-actions.d.ts +39 -0
- package/dist/utils/launchpad-actions.js +60 -0
- package/dist/utils/launchpad-actions.js.map +1 -0
- package/dist/utils/launchpad-rules.cjs +77 -0
- package/dist/utils/launchpad-rules.cjs.map +1 -0
- package/dist/utils/launchpad-rules.d.cts +13 -0
- package/dist/utils/launchpad-rules.d.ts +13 -0
- package/dist/utils/launchpad-rules.js +35 -0
- package/dist/utils/launchpad-rules.js.map +1 -0
- package/dist/utils/success-messages.cjs +5 -5
- package/dist/utils/success-messages.cjs.map +1 -1
- package/dist/utils/success-messages.d.cts +1 -1
- package/dist/utils/success-messages.d.ts +1 -1
- package/dist/utils/success-messages.js +5 -5
- package/dist/utils/success-messages.js.map +1 -1
- package/dist/utils/use-transaction.d.cts +0 -1
- package/dist/utils/use-transaction.d.ts +0 -1
- package/package.json +1 -1
- package/dist/components/fast-mint/mint-asset.cjs +0 -124
- package/dist/components/fast-mint/mint-asset.cjs.map +0 -1
- package/dist/components/fast-mint/mint-asset.d.cts +0 -41
- package/dist/components/fast-mint/mint-asset.d.ts +0 -41
- package/dist/components/fast-mint/mint-asset.js +0 -100
- package/dist/components/fast-mint/mint-asset.js.map +0 -1
- package/dist/utils/launchpad-handoff.cjs +0 -62
- package/dist/utils/launchpad-handoff.cjs.map +0 -1
- package/dist/utils/launchpad-handoff.d.cts +0 -11
- package/dist/utils/launchpad-handoff.d.ts +0 -11
- package/dist/utils/launchpad-handoff.js +0 -35
- package/dist/utils/launchpad-handoff.js.map +0 -1
|
@@ -42,7 +42,6 @@ var import_textarea = require("../textarea.js");
|
|
|
42
42
|
var import_popover = require("../popover.js");
|
|
43
43
|
var import_cn = require("../../utils/cn.js");
|
|
44
44
|
var import_use_image_url = require("../../utils/use-image-url.js");
|
|
45
|
-
var import_mintable_collections = require("./mintable-collections.js");
|
|
46
45
|
function collectionDisplayLabel(col) {
|
|
47
46
|
return col.name || col.symbol || `Collection #${col.collectionId}`;
|
|
48
47
|
}
|
|
@@ -109,23 +108,22 @@ function CollectionPicker({
|
|
|
109
108
|
] });
|
|
110
109
|
}
|
|
111
110
|
function CollectionSection({
|
|
112
|
-
assetType,
|
|
113
111
|
mode,
|
|
114
112
|
onModeChange,
|
|
115
113
|
collections,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
onExistingContract,
|
|
114
|
+
value,
|
|
115
|
+
onValue,
|
|
116
|
+
valueOf,
|
|
120
117
|
draft,
|
|
121
|
-
previewImage
|
|
118
|
+
previewImage,
|
|
119
|
+
noun = "collection"
|
|
122
120
|
}) {
|
|
123
|
-
const single = assetType === "single";
|
|
124
121
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
|
|
125
122
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between", children: [
|
|
126
123
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "text-sm font-medium flex items-center gap-1.5", children: [
|
|
127
124
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Boxes, { className: "h-4 w-4" }),
|
|
128
|
-
|
|
125
|
+
noun.charAt(0).toUpperCase() + noun.slice(1),
|
|
126
|
+
" *"
|
|
129
127
|
] }),
|
|
130
128
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex rounded-lg border border-border overflow-hidden", children: [
|
|
131
129
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -157,15 +155,7 @@ function CollectionSection({
|
|
|
157
155
|
)
|
|
158
156
|
] })
|
|
159
157
|
] }),
|
|
160
|
-
mode === "existing" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
161
|
-
CollectionPicker,
|
|
162
|
-
{
|
|
163
|
-
collections,
|
|
164
|
-
value: single ? existingId : existingContract,
|
|
165
|
-
onChange: single ? onExistingId : onExistingContract,
|
|
166
|
-
valueOf: (0, import_mintable_collections.collectionKey)(assetType)
|
|
167
|
-
}
|
|
168
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-3 rounded-xl border border-border p-3", children: [
|
|
158
|
+
mode === "existing" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollectionPicker, { collections, value, onChange: onValue, valueOf }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-3 rounded-xl border border-border p-3", children: [
|
|
169
159
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative h-16 w-16 rounded-lg overflow-hidden bg-muted shrink-0", children: previewImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image.default, { src: previewImage, alt: "", fill: true, className: "object-cover", unoptimized: true }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Boxes, { className: "h-5 w-5 text-muted-foreground/40" }) }) }),
|
|
170
160
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 flex-1 space-y-2", children: [
|
|
171
161
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid grid-cols-[1fr_100px] gap-2", children: [
|
|
@@ -174,7 +164,7 @@ function CollectionSection({
|
|
|
174
164
|
{
|
|
175
165
|
value: draft.name,
|
|
176
166
|
onChange: (e) => draft.setName(e.target.value),
|
|
177
|
-
placeholder:
|
|
167
|
+
placeholder: `${noun.charAt(0).toUpperCase() + noun.slice(1)} name`,
|
|
178
168
|
className: "h-9 text-sm"
|
|
179
169
|
}
|
|
180
170
|
),
|
|
@@ -193,12 +183,12 @@ function CollectionSection({
|
|
|
193
183
|
{
|
|
194
184
|
value: draft.description,
|
|
195
185
|
onChange: (e) => draft.setDescription(e.target.value),
|
|
196
|
-
placeholder:
|
|
186
|
+
placeholder: `Describe this ${noun}\u2026`,
|
|
197
187
|
rows: 2,
|
|
198
188
|
className: "text-sm resize-none"
|
|
199
189
|
}
|
|
200
190
|
),
|
|
201
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-2xs text-muted-foreground", children: "Prefilled from
|
|
191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-2xs text-muted-foreground", children: "Prefilled from the title and description \u2014 edit anything above." })
|
|
202
192
|
] })
|
|
203
193
|
] })
|
|
204
194
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/fast-mint/collection-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport Image from \"next/image\";\nimport type { ApiCollection } from \"@medialane/sdk\";\nimport { Boxes, Check, ChevronDown, Plus } from \"lucide-react\";\nimport { Input } from \"../input.js\";\nimport { Textarea } from \"../textarea.js\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover.js\";\nimport { cn } from \"../../utils/cn.js\";\nimport { useImageUrl } from \"../../utils/use-image-url.js\";\nimport { collectionKey, type MintAssetType } from \"./mintable-collections.js\";\nimport type { useNewCollectionDraft } from \"./use-new-collection-draft.js\";\n\nfunction collectionDisplayLabel(col: ApiCollection) {\n return col.name || col.symbol || `Collection #${col.collectionId}`;\n}\n\nfunction CollectionThumb({ image }: { image: string | null | undefined }) {\n const resolveImage = useImageUrl();\n const imageUrl = resolveImage(image);\n return (\n <div className=\"relative h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0\">\n {imageUrl ? (\n <Image src={imageUrl} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Boxes className=\"h-4 w-4 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n );\n}\n\nexport function CollectionPicker({\n collections, value, onChange, valueOf,\n}: {\n collections: ApiCollection[];\n value: string;\n onChange: (id: string) => void;\n valueOf: (c: ApiCollection) => string | null | undefined;\n}) {\n const [open, setOpen] = useState(false);\n const selected = value\n ? collections.find((c) => valueOf(c) === value) ?? null\n : null;\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n aria-expanded={open}\n className=\"flex w-full items-center gap-3 rounded-xl border border-border p-3 text-left transition-colors hover:bg-muted/40\"\n >\n <CollectionThumb image={selected?.image} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-semibold truncate\">\n {selected ? collectionDisplayLabel(selected) : collections.length ? \"Choose a collection\" : \"No collections yet\"}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {selected ? `${selected.totalSupply ?? 0} work${selected.totalSupply === 1 ? \"\" : \"s\"}` : \"Where this work will live\"}\n </p>\n </div>\n <ChevronDown className=\"h-3.5 w-3.5 text-muted-foreground shrink-0\" />\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-[var(--radix-popover-trigger-width)] p-0\" align=\"start\">\n <div className=\"max-h-64 overflow-y-auto p-1\">\n {collections.length === 0 ? (\n <p className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No collections yet — create one instead.</p>\n ) : (\n collections.map((col) => {\n const id = valueOf(col);\n const isSelected = !!id && value === id;\n return (\n <button\n key={id ?? col.contractAddress ?? col.name}\n type=\"button\"\n disabled={!id}\n onClick={() => { if (!id) return; onChange(id); setOpen(false); }}\n className=\"flex w-full items-center gap-2.5 rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted/60\"\n >\n <CollectionThumb image={col.image} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-medium truncate\">{collectionDisplayLabel(col)}</p>\n <p className=\"text-xs text-muted-foreground\">{col.totalSupply ?? 0} work{col.totalSupply === 1 ? \"\" : \"s\"}</p>\n </div>\n {isSelected && <Check className=\"h-4 w-4 text-brand-blue shrink-0\" />}\n </button>\n );\n })\n )}\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n\n\nexport type CollectionMode = \"existing\" | \"new\";\n\nexport function CollectionSection({\n assetType, mode, onModeChange, collections, existingId, existingContract, onExistingId, onExistingContract, draft, previewImage,\n}: {\n assetType: MintAssetType;\n mode: CollectionMode;\n onModeChange: (mode: CollectionMode) => void;\n collections: ApiCollection[];\n existingId: string;\n existingContract: string;\n onExistingId: (id: string) => void;\n onExistingContract: (contract: string) => void;\n draft: ReturnType<typeof useNewCollectionDraft>;\n previewImage: string | null;\n}) {\n const single = assetType === \"single\";\n return (\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between\">\n <label className=\"text-sm font-medium flex items-center gap-1.5\">\n <Boxes className=\"h-4 w-4\" />\n Collection *\n </label>\n <div className=\"flex rounded-lg border border-border overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => onModeChange(\"existing\")}\n className={cn(\"px-3 h-7 text-xs font-medium transition-colors\",\n mode === \"existing\" ? \"bg-primary text-primary-foreground\" : \"bg-background hover:bg-muted text-muted-foreground\")}\n >\n Existing\n </button>\n <button\n type=\"button\"\n onClick={() => onModeChange(\"new\")}\n className={cn(\"px-3 h-7 text-xs font-medium border-l border-border transition-colors flex items-center gap-1\",\n mode === \"new\" ? \"bg-primary text-primary-foreground\" : \"bg-background hover:bg-muted text-muted-foreground\")}\n >\n <Plus className=\"h-3 w-3\" />New\n </button>\n </div>\n </div>\n\n {mode === \"existing\" ? (\n <CollectionPicker\n collections={collections}\n value={single ? existingId : existingContract}\n onChange={single ? onExistingId : onExistingContract}\n valueOf={collectionKey(assetType)}\n />\n ) : (\n <div className=\"flex gap-3 rounded-xl border border-border p-3\">\n <div className=\"relative h-16 w-16 rounded-lg overflow-hidden bg-muted shrink-0\">\n {previewImage ? (\n <Image src={previewImage} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Boxes className=\"h-5 w-5 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n <div className=\"min-w-0 flex-1 space-y-2\">\n <div className=\"grid grid-cols-[1fr_100px] gap-2\">\n <Input\n value={draft.name}\n onChange={(e) => draft.setName(e.target.value)}\n placeholder=\"Collection name\"\n className=\"h-9 text-sm\"\n />\n <Input\n value={draft.symbol}\n onChange={(e) => draft.setSymbol(e.target.value.toUpperCase())}\n placeholder=\"SYMBOL\"\n className=\"h-9 text-sm\"\n />\n </div>\n <Textarea\n value={draft.description}\n onChange={(e) => draft.setDescription(e.target.value)}\n placeholder=\"Describe this collection…\"\n rows={2}\n className=\"text-sm resize-none\"\n />\n <p className=\"text-2xs text-muted-foreground\">Prefilled from your asset — edit anything above.</p>\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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AAM,MAAM,UAAU,EAAE,OAAO,MAAM,YAAY,CAAC;AAAA,cAC7D,aAAY;AAAA,cACZ,WAAU;AAAA;AAAA,UACZ;AAAA,WACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,MAAM;AAAA,YACb,UAAU,CAAC,MAAM,MAAM,eAAe,EAAE,OAAO,KAAK;AAAA,YACpD,aAAY;AAAA,YACZ,MAAM;AAAA,YACN,WAAU;AAAA;AAAA,QACZ;AAAA,QACA,4CAAC,OAAE,WAAU,kCAAiC,mEAAgD;AAAA,SAChG;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":["Image"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/fast-mint/collection-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport Image from \"next/image\";\nimport type { ApiCollection } from \"@medialane/sdk\";\nimport { Boxes, Check, ChevronDown, Plus } from \"lucide-react\";\nimport { Input } from \"../input.js\";\nimport { Textarea } from \"../textarea.js\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover.js\";\nimport { cn } from \"../../utils/cn.js\";\nimport { useImageUrl } from \"../../utils/use-image-url.js\";\nimport type { useNewCollectionDraft } from \"./use-new-collection-draft.js\";\n\nfunction collectionDisplayLabel(col: ApiCollection) {\n return col.name || col.symbol || `Collection #${col.collectionId}`;\n}\n\nfunction CollectionThumb({ image }: { image: string | null | undefined }) {\n const resolveImage = useImageUrl();\n const imageUrl = resolveImage(image);\n return (\n <div className=\"relative h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0\">\n {imageUrl ? (\n <Image src={imageUrl} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Boxes className=\"h-4 w-4 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n );\n}\n\nexport function CollectionPicker({\n collections, value, onChange, valueOf,\n}: {\n collections: ApiCollection[];\n value: string;\n onChange: (id: string) => void;\n valueOf: (c: ApiCollection) => string | null | undefined;\n}) {\n const [open, setOpen] = useState(false);\n const selected = value\n ? collections.find((c) => valueOf(c) === value) ?? null\n : null;\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n aria-expanded={open}\n className=\"flex w-full items-center gap-3 rounded-xl border border-border p-3 text-left transition-colors hover:bg-muted/40\"\n >\n <CollectionThumb image={selected?.image} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-semibold truncate\">\n {selected ? collectionDisplayLabel(selected) : collections.length ? \"Choose a collection\" : \"No collections yet\"}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {selected ? `${selected.totalSupply ?? 0} work${selected.totalSupply === 1 ? \"\" : \"s\"}` : \"Where this work will live\"}\n </p>\n </div>\n <ChevronDown className=\"h-3.5 w-3.5 text-muted-foreground shrink-0\" />\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-[var(--radix-popover-trigger-width)] p-0\" align=\"start\">\n <div className=\"max-h-64 overflow-y-auto p-1\">\n {collections.length === 0 ? (\n <p className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No collections yet — create one instead.</p>\n ) : (\n collections.map((col) => {\n const id = valueOf(col);\n const isSelected = !!id && value === id;\n return (\n <button\n key={id ?? col.contractAddress ?? col.name}\n type=\"button\"\n disabled={!id}\n onClick={() => { if (!id) return; onChange(id); setOpen(false); }}\n className=\"flex w-full items-center gap-2.5 rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted/60\"\n >\n <CollectionThumb image={col.image} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-medium truncate\">{collectionDisplayLabel(col)}</p>\n <p className=\"text-xs text-muted-foreground\">{col.totalSupply ?? 0} work{col.totalSupply === 1 ? \"\" : \"s\"}</p>\n </div>\n {isSelected && <Check className=\"h-4 w-4 text-brand-blue shrink-0\" />}\n </button>\n );\n })\n )}\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n\n\nexport type CollectionMode = \"existing\" | \"new\";\n\nexport function CollectionSection({\n mode, onModeChange, collections, value, onValue, valueOf, draft, previewImage, noun = \"collection\",\n}: {\n mode: CollectionMode;\n onModeChange: (mode: CollectionMode) => void;\n collections: ApiCollection[];\n value: string;\n onValue: (value: string) => void;\n valueOf: (c: ApiCollection) => string | null | undefined;\n draft: ReturnType<typeof useNewCollectionDraft>;\n previewImage: string | null;\n noun?: string;\n}) {\n return (\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between\">\n <label className=\"text-sm font-medium flex items-center gap-1.5\">\n <Boxes className=\"h-4 w-4\" />\n {noun.charAt(0).toUpperCase() + noun.slice(1)} *\n </label>\n <div className=\"flex rounded-lg border border-border overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => onModeChange(\"existing\")}\n className={cn(\"px-3 h-7 text-xs font-medium transition-colors\",\n mode === \"existing\" ? \"bg-primary text-primary-foreground\" : \"bg-background hover:bg-muted text-muted-foreground\")}\n >\n Existing\n </button>\n <button\n type=\"button\"\n onClick={() => onModeChange(\"new\")}\n className={cn(\"px-3 h-7 text-xs font-medium border-l border-border transition-colors flex items-center gap-1\",\n mode === \"new\" ? \"bg-primary text-primary-foreground\" : \"bg-background hover:bg-muted text-muted-foreground\")}\n >\n <Plus className=\"h-3 w-3\" />New\n </button>\n </div>\n </div>\n\n {mode === \"existing\" ? (\n <CollectionPicker collections={collections} value={value} onChange={onValue} valueOf={valueOf} />\n ) : (\n <div className=\"flex gap-3 rounded-xl border border-border p-3\">\n <div className=\"relative h-16 w-16 rounded-lg overflow-hidden bg-muted shrink-0\">\n {previewImage ? (\n <Image src={previewImage} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Boxes className=\"h-5 w-5 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n <div className=\"min-w-0 flex-1 space-y-2\">\n <div className=\"grid grid-cols-[1fr_100px] gap-2\">\n <Input\n value={draft.name}\n onChange={(e) => draft.setName(e.target.value)}\n placeholder={`${noun.charAt(0).toUpperCase() + noun.slice(1)} name`}\n className=\"h-9 text-sm\"\n />\n <Input\n value={draft.symbol}\n onChange={(e) => draft.setSymbol(e.target.value.toUpperCase())}\n placeholder=\"SYMBOL\"\n className=\"h-9 text-sm\"\n />\n </div>\n <Textarea\n value={draft.description}\n onChange={(e) => draft.setDescription(e.target.value)}\n placeholder={`Describe this ${noun}…`}\n rows={2}\n className=\"text-sm resize-none\"\n />\n <p className=\"text-2xs text-muted-foreground\">Prefilled from the title and description — edit anything above.</p>\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBQ;AArBR,mBAAyB;AACzB,mBAAkB;AAElB,0BAAgD;AAChD,mBAAsB;AACtB,sBAAyB;AACzB,qBAAwD;AACxD,gBAAmB;AACnB,2BAA4B;AAG5B,SAAS,uBAAuB,KAAoB;AAClD,SAAO,IAAI,QAAQ,IAAI,UAAU,eAAe,IAAI,YAAY;AAClE;AAEA,SAAS,gBAAgB,EAAE,MAAM,GAAyC;AACxE,QAAM,mBAAe,kCAAY;AACjC,QAAM,WAAW,aAAa,KAAK;AACnC,SACE,4CAAC,SAAI,WAAU,mEACZ,qBACC,4CAAC,aAAAA,SAAA,EAAM,KAAK,UAAU,KAAI,IAAG,MAAI,MAAC,WAAU,gBAAe,aAAW,MAAC,IAEvE,4CAAC,SAAI,WAAU,qDACb,sDAAC,6BAAM,WAAU,oCAAmC,GACtD,GAEJ;AAEJ;AAEO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EAAa;AAAA,EAAO;AAAA,EAAU;AAChC,GAKG;AACD,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,QAAM,WAAW,QACb,YAAY,KAAK,CAAC,MAAM,QAAQ,CAAC,MAAM,KAAK,KAAK,OACjD;AAEJ,SACE,6CAAC,0BAAQ,MAAY,cAAc,SAC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DAAC,6BAAM,WAAU,oCAAmC,GACtD,GAEJ;AAAA,MACA,6CAAC,SAAI,WAAU,4BACb;AAAA,qDAAC,SAAI,WAAU,oCACb;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,MAAM;AAAA,cACb,UAAU,CAAC,MAAM,MAAM,QAAQ,EAAE,OAAO,KAAK;AAAA,cAC7C,aAAa,GAAG,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC,CAAC;AAAA,cAC5D,WAAU;AAAA;AAAA,UACZ;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,MAAM;AAAA,cACb,UAAU,CAAC,MAAM,MAAM,UAAU,EAAE,OAAO,MAAM,YAAY,CAAC;AAAA,cAC7D,aAAY;AAAA,cACZ,WAAU;AAAA;AAAA,UACZ;AAAA,WACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,MAAM;AAAA,YACb,UAAU,CAAC,MAAM,MAAM,eAAe,EAAE,OAAO,KAAK;AAAA,YACpD,aAAa,iBAAiB,IAAI;AAAA,YAClC,MAAM;AAAA,YACN,WAAU;AAAA;AAAA,QACZ;AAAA,QACA,4CAAC,OAAE,WAAU,kCAAiC,kFAA+D;AAAA,SAC/G;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":["Image"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ApiCollection } from '@medialane/sdk';
|
|
3
|
-
import { MintAssetType } from './mintable-collections.cjs';
|
|
4
3
|
import { useNewCollectionDraft } from './use-new-collection-draft.cjs';
|
|
5
4
|
import 'react';
|
|
6
5
|
|
|
@@ -11,17 +10,16 @@ declare function CollectionPicker({ collections, value, onChange, valueOf, }: {
|
|
|
11
10
|
valueOf: (c: ApiCollection) => string | null | undefined;
|
|
12
11
|
}): react_jsx_runtime.JSX.Element;
|
|
13
12
|
type CollectionMode = "existing" | "new";
|
|
14
|
-
declare function CollectionSection({
|
|
15
|
-
assetType: MintAssetType;
|
|
13
|
+
declare function CollectionSection({ mode, onModeChange, collections, value, onValue, valueOf, draft, previewImage, noun, }: {
|
|
16
14
|
mode: CollectionMode;
|
|
17
15
|
onModeChange: (mode: CollectionMode) => void;
|
|
18
16
|
collections: ApiCollection[];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
onExistingContract: (contract: string) => void;
|
|
17
|
+
value: string;
|
|
18
|
+
onValue: (value: string) => void;
|
|
19
|
+
valueOf: (c: ApiCollection) => string | null | undefined;
|
|
23
20
|
draft: ReturnType<typeof useNewCollectionDraft>;
|
|
24
21
|
previewImage: string | null;
|
|
22
|
+
noun?: string;
|
|
25
23
|
}): react_jsx_runtime.JSX.Element;
|
|
26
24
|
|
|
27
25
|
export { type CollectionMode, CollectionPicker, CollectionSection };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ApiCollection } from '@medialane/sdk';
|
|
3
|
-
import { MintAssetType } from './mintable-collections.js';
|
|
4
3
|
import { useNewCollectionDraft } from './use-new-collection-draft.js';
|
|
5
4
|
import 'react';
|
|
6
5
|
|
|
@@ -11,17 +10,16 @@ declare function CollectionPicker({ collections, value, onChange, valueOf, }: {
|
|
|
11
10
|
valueOf: (c: ApiCollection) => string | null | undefined;
|
|
12
11
|
}): react_jsx_runtime.JSX.Element;
|
|
13
12
|
type CollectionMode = "existing" | "new";
|
|
14
|
-
declare function CollectionSection({
|
|
15
|
-
assetType: MintAssetType;
|
|
13
|
+
declare function CollectionSection({ mode, onModeChange, collections, value, onValue, valueOf, draft, previewImage, noun, }: {
|
|
16
14
|
mode: CollectionMode;
|
|
17
15
|
onModeChange: (mode: CollectionMode) => void;
|
|
18
16
|
collections: ApiCollection[];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
onExistingContract: (contract: string) => void;
|
|
17
|
+
value: string;
|
|
18
|
+
onValue: (value: string) => void;
|
|
19
|
+
valueOf: (c: ApiCollection) => string | null | undefined;
|
|
23
20
|
draft: ReturnType<typeof useNewCollectionDraft>;
|
|
24
21
|
previewImage: string | null;
|
|
22
|
+
noun?: string;
|
|
25
23
|
}): react_jsx_runtime.JSX.Element;
|
|
26
24
|
|
|
27
25
|
export { type CollectionMode, CollectionPicker, CollectionSection };
|
|
@@ -8,7 +8,6 @@ import { Textarea } from "../textarea.js";
|
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger } from "../popover.js";
|
|
9
9
|
import { cn } from "../../utils/cn.js";
|
|
10
10
|
import { useImageUrl } from "../../utils/use-image-url.js";
|
|
11
|
-
import { collectionKey } from "./mintable-collections.js";
|
|
12
11
|
function collectionDisplayLabel(col) {
|
|
13
12
|
return col.name || col.symbol || `Collection #${col.collectionId}`;
|
|
14
13
|
}
|
|
@@ -75,23 +74,22 @@ function CollectionPicker({
|
|
|
75
74
|
] });
|
|
76
75
|
}
|
|
77
76
|
function CollectionSection({
|
|
78
|
-
assetType,
|
|
79
77
|
mode,
|
|
80
78
|
onModeChange,
|
|
81
79
|
collections,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
onExistingContract,
|
|
80
|
+
value,
|
|
81
|
+
onValue,
|
|
82
|
+
valueOf,
|
|
86
83
|
draft,
|
|
87
|
-
previewImage
|
|
84
|
+
previewImage,
|
|
85
|
+
noun = "collection"
|
|
88
86
|
}) {
|
|
89
|
-
const single = assetType === "single";
|
|
90
87
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
91
88
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
92
89
|
/* @__PURE__ */ jsxs("label", { className: "text-sm font-medium flex items-center gap-1.5", children: [
|
|
93
90
|
/* @__PURE__ */ jsx(Boxes, { className: "h-4 w-4" }),
|
|
94
|
-
|
|
91
|
+
noun.charAt(0).toUpperCase() + noun.slice(1),
|
|
92
|
+
" *"
|
|
95
93
|
] }),
|
|
96
94
|
/* @__PURE__ */ jsxs("div", { className: "flex rounded-lg border border-border overflow-hidden", children: [
|
|
97
95
|
/* @__PURE__ */ jsx(
|
|
@@ -123,15 +121,7 @@ function CollectionSection({
|
|
|
123
121
|
)
|
|
124
122
|
] })
|
|
125
123
|
] }),
|
|
126
|
-
mode === "existing" ? /* @__PURE__ */ jsx(
|
|
127
|
-
CollectionPicker,
|
|
128
|
-
{
|
|
129
|
-
collections,
|
|
130
|
-
value: single ? existingId : existingContract,
|
|
131
|
-
onChange: single ? onExistingId : onExistingContract,
|
|
132
|
-
valueOf: collectionKey(assetType)
|
|
133
|
-
}
|
|
134
|
-
) : /* @__PURE__ */ jsxs("div", { className: "flex gap-3 rounded-xl border border-border p-3", children: [
|
|
124
|
+
mode === "existing" ? /* @__PURE__ */ jsx(CollectionPicker, { collections, value, onChange: onValue, valueOf }) : /* @__PURE__ */ jsxs("div", { className: "flex gap-3 rounded-xl border border-border p-3", children: [
|
|
135
125
|
/* @__PURE__ */ jsx("div", { className: "relative h-16 w-16 rounded-lg overflow-hidden bg-muted shrink-0", children: previewImage ? /* @__PURE__ */ jsx(Image, { src: previewImage, alt: "", fill: true, className: "object-cover", unoptimized: true }) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx(Boxes, { className: "h-5 w-5 text-muted-foreground/40" }) }) }),
|
|
136
126
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-2", children: [
|
|
137
127
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[1fr_100px] gap-2", children: [
|
|
@@ -140,7 +130,7 @@ function CollectionSection({
|
|
|
140
130
|
{
|
|
141
131
|
value: draft.name,
|
|
142
132
|
onChange: (e) => draft.setName(e.target.value),
|
|
143
|
-
placeholder:
|
|
133
|
+
placeholder: `${noun.charAt(0).toUpperCase() + noun.slice(1)} name`,
|
|
144
134
|
className: "h-9 text-sm"
|
|
145
135
|
}
|
|
146
136
|
),
|
|
@@ -159,12 +149,12 @@ function CollectionSection({
|
|
|
159
149
|
{
|
|
160
150
|
value: draft.description,
|
|
161
151
|
onChange: (e) => draft.setDescription(e.target.value),
|
|
162
|
-
placeholder:
|
|
152
|
+
placeholder: `Describe this ${noun}\u2026`,
|
|
163
153
|
rows: 2,
|
|
164
154
|
className: "text-sm resize-none"
|
|
165
155
|
}
|
|
166
156
|
),
|
|
167
|
-
/* @__PURE__ */ jsx("p", { className: "text-2xs text-muted-foreground", children: "Prefilled from
|
|
157
|
+
/* @__PURE__ */ jsx("p", { className: "text-2xs text-muted-foreground", children: "Prefilled from the title and description \u2014 edit anything above." })
|
|
168
158
|
] })
|
|
169
159
|
] })
|
|
170
160
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/fast-mint/collection-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport Image from \"next/image\";\nimport type { ApiCollection } from \"@medialane/sdk\";\nimport { Boxes, Check, ChevronDown, Plus } from \"lucide-react\";\nimport { Input } from \"../input.js\";\nimport { Textarea } from \"../textarea.js\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover.js\";\nimport { cn } from \"../../utils/cn.js\";\nimport { useImageUrl } from \"../../utils/use-image-url.js\";\nimport { collectionKey, type MintAssetType } from \"./mintable-collections.js\";\nimport type { useNewCollectionDraft } from \"./use-new-collection-draft.js\";\n\nfunction collectionDisplayLabel(col: ApiCollection) {\n return col.name || col.symbol || `Collection #${col.collectionId}`;\n}\n\nfunction CollectionThumb({ image }: { image: string | null | undefined }) {\n const resolveImage = useImageUrl();\n const imageUrl = resolveImage(image);\n return (\n <div className=\"relative h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0\">\n {imageUrl ? (\n <Image src={imageUrl} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Boxes className=\"h-4 w-4 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n );\n}\n\nexport function CollectionPicker({\n collections, value, onChange, valueOf,\n}: {\n collections: ApiCollection[];\n value: string;\n onChange: (id: string) => void;\n valueOf: (c: ApiCollection) => string | null | undefined;\n}) {\n const [open, setOpen] = useState(false);\n const selected = value\n ? collections.find((c) => valueOf(c) === value) ?? null\n : null;\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n aria-expanded={open}\n className=\"flex w-full items-center gap-3 rounded-xl border border-border p-3 text-left transition-colors hover:bg-muted/40\"\n >\n <CollectionThumb image={selected?.image} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-semibold truncate\">\n {selected ? collectionDisplayLabel(selected) : collections.length ? \"Choose a collection\" : \"No collections yet\"}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {selected ? `${selected.totalSupply ?? 0} work${selected.totalSupply === 1 ? \"\" : \"s\"}` : \"Where this work will live\"}\n </p>\n </div>\n <ChevronDown className=\"h-3.5 w-3.5 text-muted-foreground shrink-0\" />\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-[var(--radix-popover-trigger-width)] p-0\" align=\"start\">\n <div className=\"max-h-64 overflow-y-auto p-1\">\n {collections.length === 0 ? (\n <p className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No collections yet — create one instead.</p>\n ) : (\n collections.map((col) => {\n const id = valueOf(col);\n const isSelected = !!id && value === id;\n return (\n <button\n key={id ?? col.contractAddress ?? col.name}\n type=\"button\"\n disabled={!id}\n onClick={() => { if (!id) return; onChange(id); setOpen(false); }}\n className=\"flex w-full items-center gap-2.5 rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted/60\"\n >\n <CollectionThumb image={col.image} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-medium truncate\">{collectionDisplayLabel(col)}</p>\n <p className=\"text-xs text-muted-foreground\">{col.totalSupply ?? 0} work{col.totalSupply === 1 ? \"\" : \"s\"}</p>\n </div>\n {isSelected && <Check className=\"h-4 w-4 text-brand-blue shrink-0\" />}\n </button>\n );\n })\n )}\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n\n\nexport type CollectionMode = \"existing\" | \"new\";\n\nexport function CollectionSection({\n assetType, mode, onModeChange, collections, existingId, existingContract, onExistingId, onExistingContract, draft, previewImage,\n}: {\n assetType: MintAssetType;\n mode: CollectionMode;\n onModeChange: (mode: CollectionMode) => void;\n collections: ApiCollection[];\n existingId: string;\n existingContract: string;\n onExistingId: (id: string) => void;\n onExistingContract: (contract: string) => void;\n draft: ReturnType<typeof useNewCollectionDraft>;\n previewImage: string | null;\n}) {\n const single = assetType === \"single\";\n return (\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between\">\n <label className=\"text-sm font-medium flex items-center gap-1.5\">\n <Boxes className=\"h-4 w-4\" />\n Collection *\n </label>\n <div className=\"flex rounded-lg border border-border overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => onModeChange(\"existing\")}\n className={cn(\"px-3 h-7 text-xs font-medium transition-colors\",\n mode === \"existing\" ? \"bg-primary text-primary-foreground\" : \"bg-background hover:bg-muted text-muted-foreground\")}\n >\n Existing\n </button>\n <button\n type=\"button\"\n onClick={() => onModeChange(\"new\")}\n className={cn(\"px-3 h-7 text-xs font-medium border-l border-border transition-colors flex items-center gap-1\",\n mode === \"new\" ? \"bg-primary text-primary-foreground\" : \"bg-background hover:bg-muted text-muted-foreground\")}\n >\n <Plus className=\"h-3 w-3\" />New\n </button>\n </div>\n </div>\n\n {mode === \"existing\" ? (\n <CollectionPicker\n collections={collections}\n value={single ? existingId : existingContract}\n onChange={single ? onExistingId : onExistingContract}\n valueOf={collectionKey(assetType)}\n />\n ) : (\n <div className=\"flex gap-3 rounded-xl border border-border p-3\">\n <div className=\"relative h-16 w-16 rounded-lg overflow-hidden bg-muted shrink-0\">\n {previewImage ? (\n <Image src={previewImage} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Boxes className=\"h-5 w-5 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n <div className=\"min-w-0 flex-1 space-y-2\">\n <div className=\"grid grid-cols-[1fr_100px] gap-2\">\n <Input\n value={draft.name}\n onChange={(e) => draft.setName(e.target.value)}\n placeholder=\"Collection name\"\n className=\"h-9 text-sm\"\n />\n <Input\n value={draft.symbol}\n onChange={(e) => draft.setSymbol(e.target.value.toUpperCase())}\n placeholder=\"SYMBOL\"\n className=\"h-9 text-sm\"\n />\n </div>\n <Textarea\n value={draft.description}\n onChange={(e) => draft.setDescription(e.target.value)}\n placeholder=\"Describe this collection…\"\n rows={2}\n className=\"text-sm resize-none\"\n />\n <p className=\"text-2xs text-muted-foreground\">Prefilled from your asset — edit anything above.</p>\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAwBQ,cAgCE,YAhCF;AAtBR,SAAS,gBAAgB;AACzB,OAAO,WAAW;AAElB,SAAS,OAAO,OAAO,aAAa,YAAY;AAChD,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,qBAAyC;AAGlD,SAAS,uBAAuB,KAAoB;AAClD,SAAO,IAAI,QAAQ,IAAI,UAAU,eAAe,IAAI,YAAY;AAClE;AAEA,SAAS,gBAAgB,EAAE,MAAM,GAAyC;AACxE,QAAM,eAAe,YAAY;AACjC,QAAM,WAAW,aAAa,KAAK;AACnC,SACE,oBAAC,SAAI,WAAU,mEACZ,qBACC,oBAAC,SAAM,KAAK,UAAU,KAAI,IAAG,MAAI,MAAC,WAAU,gBAAe,aAAW,MAAC,IAEvE,oBAAC,SAAI,WAAU,qDACb,8BAAC,SAAM,WAAU,oCAAmC,GACtD,GAEJ;AAEJ;AAEO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EAAa;AAAA,EAAO;AAAA,EAAU;AAChC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C,SAAS,cAAc,SAAS;AAAA;AAAA,IAClC,IAEA,qBAAC,SAAI,WAAU,kDACb;AAAA,0BAAC,SAAI,WAAU,mEACZ,yBACC,oBAAC,SAAM,KAAK,cAAc,KAAI,IAAG,MAAI,MAAC,WAAU,gBAAe,aAAW,MAAC,IAE3E,oBAAC,SAAI,WAAU,qDACb,8BAAC,SAAM,WAAU,oCAAmC,GACtD,GAEJ;AAAA,MACA,qBAAC,SAAI,WAAU,4BACb;AAAA,6BAAC,SAAI,WAAU,oCACb;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,MAAM;AAAA,cACb,UAAU,CAAC,MAAM,MAAM,QAAQ,EAAE,OAAO,KAAK;AAAA,cAC7C,aAAY;AAAA,cACZ,WAAU;AAAA;AAAA,UACZ;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,MAAM;AAAA,cACb,UAAU,CAAC,MAAM,MAAM,UAAU,EAAE,OAAO,MAAM,YAAY,CAAC;AAAA,cAC7D,aAAY;AAAA,cACZ,WAAU;AAAA;AAAA,UACZ;AAAA,WACF;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,MAAM;AAAA,YACb,UAAU,CAAC,MAAM,MAAM,eAAe,EAAE,OAAO,KAAK;AAAA,YACpD,aAAY;AAAA,YACZ,MAAM;AAAA,YACN,WAAU;AAAA;AAAA,QACZ;AAAA,QACA,oBAAC,OAAE,WAAU,kCAAiC,mEAAgD;AAAA,SAChG;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/fast-mint/collection-section.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport Image from \"next/image\";\nimport type { ApiCollection } from \"@medialane/sdk\";\nimport { Boxes, Check, ChevronDown, Plus } from \"lucide-react\";\nimport { Input } from \"../input.js\";\nimport { Textarea } from \"../textarea.js\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover.js\";\nimport { cn } from \"../../utils/cn.js\";\nimport { useImageUrl } from \"../../utils/use-image-url.js\";\nimport type { useNewCollectionDraft } from \"./use-new-collection-draft.js\";\n\nfunction collectionDisplayLabel(col: ApiCollection) {\n return col.name || col.symbol || `Collection #${col.collectionId}`;\n}\n\nfunction CollectionThumb({ image }: { image: string | null | undefined }) {\n const resolveImage = useImageUrl();\n const imageUrl = resolveImage(image);\n return (\n <div className=\"relative h-10 w-10 rounded-lg overflow-hidden bg-muted shrink-0\">\n {imageUrl ? (\n <Image src={imageUrl} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Boxes className=\"h-4 w-4 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n );\n}\n\nexport function CollectionPicker({\n collections, value, onChange, valueOf,\n}: {\n collections: ApiCollection[];\n value: string;\n onChange: (id: string) => void;\n valueOf: (c: ApiCollection) => string | null | undefined;\n}) {\n const [open, setOpen] = useState(false);\n const selected = value\n ? collections.find((c) => valueOf(c) === value) ?? null\n : null;\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n aria-expanded={open}\n className=\"flex w-full items-center gap-3 rounded-xl border border-border p-3 text-left transition-colors hover:bg-muted/40\"\n >\n <CollectionThumb image={selected?.image} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-semibold truncate\">\n {selected ? collectionDisplayLabel(selected) : collections.length ? \"Choose a collection\" : \"No collections yet\"}\n </p>\n <p className=\"text-xs text-muted-foreground\">\n {selected ? `${selected.totalSupply ?? 0} work${selected.totalSupply === 1 ? \"\" : \"s\"}` : \"Where this work will live\"}\n </p>\n </div>\n <ChevronDown className=\"h-3.5 w-3.5 text-muted-foreground shrink-0\" />\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-[var(--radix-popover-trigger-width)] p-0\" align=\"start\">\n <div className=\"max-h-64 overflow-y-auto p-1\">\n {collections.length === 0 ? (\n <p className=\"px-3 py-4 text-center text-sm text-muted-foreground\">No collections yet — create one instead.</p>\n ) : (\n collections.map((col) => {\n const id = valueOf(col);\n const isSelected = !!id && value === id;\n return (\n <button\n key={id ?? col.contractAddress ?? col.name}\n type=\"button\"\n disabled={!id}\n onClick={() => { if (!id) return; onChange(id); setOpen(false); }}\n className=\"flex w-full items-center gap-2.5 rounded-lg px-2 py-2 text-left transition-colors hover:bg-muted/60\"\n >\n <CollectionThumb image={col.image} />\n <div className=\"min-w-0 flex-1\">\n <p className=\"text-sm font-medium truncate\">{collectionDisplayLabel(col)}</p>\n <p className=\"text-xs text-muted-foreground\">{col.totalSupply ?? 0} work{col.totalSupply === 1 ? \"\" : \"s\"}</p>\n </div>\n {isSelected && <Check className=\"h-4 w-4 text-brand-blue shrink-0\" />}\n </button>\n );\n })\n )}\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n\n\nexport type CollectionMode = \"existing\" | \"new\";\n\nexport function CollectionSection({\n mode, onModeChange, collections, value, onValue, valueOf, draft, previewImage, noun = \"collection\",\n}: {\n mode: CollectionMode;\n onModeChange: (mode: CollectionMode) => void;\n collections: ApiCollection[];\n value: string;\n onValue: (value: string) => void;\n valueOf: (c: ApiCollection) => string | null | undefined;\n draft: ReturnType<typeof useNewCollectionDraft>;\n previewImage: string | null;\n noun?: string;\n}) {\n return (\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between\">\n <label className=\"text-sm font-medium flex items-center gap-1.5\">\n <Boxes className=\"h-4 w-4\" />\n {noun.charAt(0).toUpperCase() + noun.slice(1)} *\n </label>\n <div className=\"flex rounded-lg border border-border overflow-hidden\">\n <button\n type=\"button\"\n onClick={() => onModeChange(\"existing\")}\n className={cn(\"px-3 h-7 text-xs font-medium transition-colors\",\n mode === \"existing\" ? \"bg-primary text-primary-foreground\" : \"bg-background hover:bg-muted text-muted-foreground\")}\n >\n Existing\n </button>\n <button\n type=\"button\"\n onClick={() => onModeChange(\"new\")}\n className={cn(\"px-3 h-7 text-xs font-medium border-l border-border transition-colors flex items-center gap-1\",\n mode === \"new\" ? \"bg-primary text-primary-foreground\" : \"bg-background hover:bg-muted text-muted-foreground\")}\n >\n <Plus className=\"h-3 w-3\" />New\n </button>\n </div>\n </div>\n\n {mode === \"existing\" ? (\n <CollectionPicker collections={collections} value={value} onChange={onValue} valueOf={valueOf} />\n ) : (\n <div className=\"flex gap-3 rounded-xl border border-border p-3\">\n <div className=\"relative h-16 w-16 rounded-lg overflow-hidden bg-muted shrink-0\">\n {previewImage ? (\n <Image src={previewImage} alt=\"\" fill className=\"object-cover\" unoptimized />\n ) : (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n <Boxes className=\"h-5 w-5 text-muted-foreground/40\" />\n </div>\n )}\n </div>\n <div className=\"min-w-0 flex-1 space-y-2\">\n <div className=\"grid grid-cols-[1fr_100px] gap-2\">\n <Input\n value={draft.name}\n onChange={(e) => draft.setName(e.target.value)}\n placeholder={`${noun.charAt(0).toUpperCase() + noun.slice(1)} name`}\n className=\"h-9 text-sm\"\n />\n <Input\n value={draft.symbol}\n onChange={(e) => draft.setSymbol(e.target.value.toUpperCase())}\n placeholder=\"SYMBOL\"\n className=\"h-9 text-sm\"\n />\n </div>\n <Textarea\n value={draft.description}\n onChange={(e) => draft.setDescription(e.target.value)}\n placeholder={`Describe this ${noun}…`}\n rows={2}\n className=\"text-sm resize-none\"\n />\n <p className=\"text-2xs text-muted-foreground\">Prefilled from the title and description — edit anything above.</p>\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAuBQ,cAgCE,YAhCF;AArBR,SAAS,gBAAgB;AACzB,OAAO,WAAW;AAElB,SAAS,OAAO,OAAO,aAAa,YAAY;AAChD,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAG5B,SAAS,uBAAuB,KAAoB;AAClD,SAAO,IAAI,QAAQ,IAAI,UAAU,eAAe,IAAI,YAA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N,WAAU;AAAA;AAAA,QACZ;AAAA,QACA,oBAAC,OAAE,WAAU,kCAAiC,kFAA+D;AAAA,SAC/G;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var create_then_add_exports = {};
|
|
20
|
+
__export(create_then_add_exports, {
|
|
21
|
+
PartialCreateError: () => PartialCreateError,
|
|
22
|
+
createThenAdd: () => createThenAdd
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(create_then_add_exports);
|
|
25
|
+
class PartialCreateError extends Error {
|
|
26
|
+
constructor(destination, noun, reason) {
|
|
27
|
+
super(`Your ${noun} was created, but the last step did not finish.`);
|
|
28
|
+
this.name = "PartialCreateError";
|
|
29
|
+
this.destination = destination;
|
|
30
|
+
this.noun = noun;
|
|
31
|
+
this.reason = reason;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function createThenAdd(opts) {
|
|
35
|
+
const { existing, create, add, labels, noun, onStep } = opts;
|
|
36
|
+
const total = existing === null ? 2 : 1;
|
|
37
|
+
if (existing !== null) {
|
|
38
|
+
onStep({ label: labels.add, index: 1, total });
|
|
39
|
+
return add(existing);
|
|
40
|
+
}
|
|
41
|
+
onStep({ label: labels.create, index: 1, total });
|
|
42
|
+
const created = await create();
|
|
43
|
+
onStep({ label: labels.add, index: 2, total });
|
|
44
|
+
try {
|
|
45
|
+
return await add(created);
|
|
46
|
+
} catch (reason) {
|
|
47
|
+
throw new PartialCreateError(created, noun, reason);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
PartialCreateError,
|
|
53
|
+
createThenAdd
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=create-then-add.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/fast-mint/create-then-add.ts"],"sourcesContent":["export interface StepInfo {\n label: string;\n index: number;\n total: number;\n}\n\nexport class PartialCreateError extends Error {\n readonly destination: unknown;\n readonly noun: string;\n readonly reason: unknown;\n\n constructor(destination: unknown, noun: string, reason: unknown) {\n super(`Your ${noun} was created, but the last step did not finish.`);\n this.name = \"PartialCreateError\";\n this.destination = destination;\n this.noun = noun;\n this.reason = reason;\n }\n}\n\nexport async function createThenAdd<D, R>(opts: {\n existing: D | null;\n create: () => Promise<D>;\n add: (destination: D) => Promise<R>;\n labels: { create: string; add: string };\n noun: string;\n onStep: (step: StepInfo) => void;\n}): Promise<R> {\n const { existing, create, add, labels, noun, onStep } = opts;\n const total = existing === null ? 2 : 1;\n\n if (existing !== null) {\n onStep({ label: labels.add, index: 1, total });\n return add(existing);\n }\n\n onStep({ label: labels.create, index: 1, total });\n const created = await create();\n onStep({ label: labels.add, index: 2, total });\n try {\n return await add(created);\n } catch (reason) {\n throw new PartialCreateError(created, noun, reason);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,2BAA2B,MAAM;AAAA,EAK5C,YAAY,aAAsB,MAAc,QAAiB;AAC/D,UAAM,QAAQ,IAAI,iDAAiD;AACnE,SAAK,OAAO;AACZ,SAAK,cAAc;AACnB,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEA,eAAsB,cAAoB,MAO3B;AACb,QAAM,EAAE,UAAU,QAAQ,KAAK,QAAQ,MAAM,OAAO,IAAI;AACxD,QAAM,QAAQ,aAAa,OAAO,IAAI;AAEtC,MAAI,aAAa,MAAM;AACrB,WAAO,EAAE,OAAO,OAAO,KAAK,OAAO,GAAG,MAAM,CAAC;AAC7C,WAAO,IAAI,QAAQ;AAAA,EACrB;AAEA,SAAO,EAAE,OAAO,OAAO,QAAQ,OAAO,GAAG,MAAM,CAAC;AAChD,QAAM,UAAU,MAAM,OAAO;AAC7B,SAAO,EAAE,OAAO,OAAO,KAAK,OAAO,GAAG,MAAM,CAAC;AAC7C,MAAI;AACF,WAAO,MAAM,IAAI,OAAO;AAAA,EAC1B,SAAS,QAAQ;AACf,UAAM,IAAI,mBAAmB,SAAS,MAAM,MAAM;AAAA,EACpD;AACF;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface StepInfo {
|
|
2
|
+
label: string;
|
|
3
|
+
index: number;
|
|
4
|
+
total: number;
|
|
5
|
+
}
|
|
6
|
+
declare class PartialCreateError extends Error {
|
|
7
|
+
readonly destination: unknown;
|
|
8
|
+
readonly noun: string;
|
|
9
|
+
readonly reason: unknown;
|
|
10
|
+
constructor(destination: unknown, noun: string, reason: unknown);
|
|
11
|
+
}
|
|
12
|
+
declare function createThenAdd<D, R>(opts: {
|
|
13
|
+
existing: D | null;
|
|
14
|
+
create: () => Promise<D>;
|
|
15
|
+
add: (destination: D) => Promise<R>;
|
|
16
|
+
labels: {
|
|
17
|
+
create: string;
|
|
18
|
+
add: string;
|
|
19
|
+
};
|
|
20
|
+
noun: string;
|
|
21
|
+
onStep: (step: StepInfo) => void;
|
|
22
|
+
}): Promise<R>;
|
|
23
|
+
|
|
24
|
+
export { PartialCreateError, type StepInfo, createThenAdd };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface StepInfo {
|
|
2
|
+
label: string;
|
|
3
|
+
index: number;
|
|
4
|
+
total: number;
|
|
5
|
+
}
|
|
6
|
+
declare class PartialCreateError extends Error {
|
|
7
|
+
readonly destination: unknown;
|
|
8
|
+
readonly noun: string;
|
|
9
|
+
readonly reason: unknown;
|
|
10
|
+
constructor(destination: unknown, noun: string, reason: unknown);
|
|
11
|
+
}
|
|
12
|
+
declare function createThenAdd<D, R>(opts: {
|
|
13
|
+
existing: D | null;
|
|
14
|
+
create: () => Promise<D>;
|
|
15
|
+
add: (destination: D) => Promise<R>;
|
|
16
|
+
labels: {
|
|
17
|
+
create: string;
|
|
18
|
+
add: string;
|
|
19
|
+
};
|
|
20
|
+
noun: string;
|
|
21
|
+
onStep: (step: StepInfo) => void;
|
|
22
|
+
}): Promise<R>;
|
|
23
|
+
|
|
24
|
+
export { PartialCreateError, type StepInfo, createThenAdd };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class PartialCreateError extends Error {
|
|
2
|
+
constructor(destination, noun, reason) {
|
|
3
|
+
super(`Your ${noun} was created, but the last step did not finish.`);
|
|
4
|
+
this.name = "PartialCreateError";
|
|
5
|
+
this.destination = destination;
|
|
6
|
+
this.noun = noun;
|
|
7
|
+
this.reason = reason;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
async function createThenAdd(opts) {
|
|
11
|
+
const { existing, create, add, labels, noun, onStep } = opts;
|
|
12
|
+
const total = existing === null ? 2 : 1;
|
|
13
|
+
if (existing !== null) {
|
|
14
|
+
onStep({ label: labels.add, index: 1, total });
|
|
15
|
+
return add(existing);
|
|
16
|
+
}
|
|
17
|
+
onStep({ label: labels.create, index: 1, total });
|
|
18
|
+
const created = await create();
|
|
19
|
+
onStep({ label: labels.add, index: 2, total });
|
|
20
|
+
try {
|
|
21
|
+
return await add(created);
|
|
22
|
+
} catch (reason) {
|
|
23
|
+
throw new PartialCreateError(created, noun, reason);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
PartialCreateError,
|
|
28
|
+
createThenAdd
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=create-then-add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/fast-mint/create-then-add.ts"],"sourcesContent":["export interface StepInfo {\n label: string;\n index: number;\n total: number;\n}\n\nexport class PartialCreateError extends Error {\n readonly destination: unknown;\n readonly noun: string;\n readonly reason: unknown;\n\n constructor(destination: unknown, noun: string, reason: unknown) {\n super(`Your ${noun} was created, but the last step did not finish.`);\n this.name = \"PartialCreateError\";\n this.destination = destination;\n this.noun = noun;\n this.reason = reason;\n }\n}\n\nexport async function createThenAdd<D, R>(opts: {\n existing: D | null;\n create: () => Promise<D>;\n add: (destination: D) => Promise<R>;\n labels: { create: string; add: string };\n noun: string;\n onStep: (step: StepInfo) => void;\n}): Promise<R> {\n const { existing, create, add, labels, noun, onStep } = opts;\n const total = existing === null ? 2 : 1;\n\n if (existing !== null) {\n onStep({ label: labels.add, index: 1, total });\n return add(existing);\n }\n\n onStep({ label: labels.create, index: 1, total });\n const created = await create();\n onStep({ label: labels.add, index: 2, total });\n try {\n return await add(created);\n } catch (reason) {\n throw new PartialCreateError(created, noun, reason);\n }\n}\n"],"mappings":"AAMO,MAAM,2BAA2B,MAAM;AAAA,EAK5C,YAAY,aAAsB,MAAc,QAAiB;AAC/D,UAAM,QAAQ,IAAI,iDAAiD;AACnE,SAAK,OAAO;AACZ,SAAK,cAAc;AACnB,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;AAEA,eAAsB,cAAoB,MAO3B;AACb,QAAM,EAAE,UAAU,QAAQ,KAAK,QAAQ,MAAM,OAAO,IAAI;AACxD,QAAM,QAAQ,aAAa,OAAO,IAAI;AAEtC,MAAI,aAAa,MAAM;AACrB,WAAO,EAAE,OAAO,OAAO,KAAK,OAAO,GAAG,MAAM,CAAC;AAC7C,WAAO,IAAI,QAAQ;AAAA,EACrB;AAEA,SAAO,EAAE,OAAO,OAAO,QAAQ,OAAO,GAAG,MAAM,CAAC;AAChD,QAAM,UAAU,MAAM,OAAO;AAC7B,SAAO,EAAE,OAAO,OAAO,KAAK,OAAO,GAAG,MAAM,CAAC;AAC7C,MAAI;AACF,WAAO,MAAM,IAAI,OAAO;AAAA,EAC1B,SAAS,QAAQ;AACf,UAAM,IAAI,mBAAmB,SAAS,MAAM,MAAM;AAAA,EACpD;AACF;","names":[]}
|