@medialane/ui 0.395.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.
- package/README.md +4 -2
- package/dist/components/alert.d.cts +1 -1
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/back-button.cjs +23 -7
- package/dist/components/back-button.cjs.map +1 -1
- package/dist/components/back-button.d.cts +6 -3
- package/dist/components/back-button.d.ts +6 -3
- package/dist/components/back-button.js +14 -8
- package/dist/components/back-button.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/comments-section.cjs +1 -1
- package/dist/components/comments-section.cjs.map +1 -1
- package/dist/components/comments-section.js +1 -1
- package/dist/components/comments-section.js.map +1 -1
- package/dist/components/create-form-primitives.cjs +3 -2
- package/dist/components/create-form-primitives.cjs.map +1 -1
- package/dist/components/create-form-primitives.d.cts +2 -1
- package/dist/components/create-form-primitives.d.ts +2 -1
- package/dist/components/create-form-primitives.js +3 -2
- package/dist/components/create-form-primitives.js.map +1 -1
- package/dist/components/creator-page.cjs +15 -11
- package/dist/components/creator-page.cjs.map +1 -1
- package/dist/components/creator-page.js +16 -12
- package/dist/components/creator-page.js.map +1 -1
- package/dist/components/drop/create/asset-editor.cjs +14 -4
- package/dist/components/drop/create/asset-editor.cjs.map +1 -1
- package/dist/components/drop/create/asset-editor.js +14 -4
- package/dist/components/drop/create/asset-editor.js.map +1 -1
- package/dist/components/fast-mint/asset-form-parts.cjs +8 -43
- package/dist/components/fast-mint/asset-form-parts.cjs.map +1 -1
- package/dist/components/fast-mint/asset-form-parts.d.cts +5 -10
- package/dist/components/fast-mint/asset-form-parts.d.ts +5 -10
- package/dist/components/fast-mint/asset-form-parts.js +8 -42
- package/dist/components/fast-mint/asset-form-parts.js.map +1 -1
- package/dist/components/fast-mint/dropzone.cjs +1 -0
- package/dist/components/fast-mint/dropzone.cjs.map +1 -1
- package/dist/components/fast-mint/dropzone.js +1 -0
- package/dist/components/fast-mint/dropzone.js.map +1 -1
- package/dist/components/fast-mint/fast-mint.cjs +47 -45
- package/dist/components/fast-mint/fast-mint.cjs.map +1 -1
- package/dist/components/fast-mint/fast-mint.js +48 -46
- package/dist/components/fast-mint/fast-mint.js.map +1 -1
- package/dist/components/image-upload-field.cjs +140 -0
- package/dist/components/image-upload-field.cjs.map +1 -0
- package/dist/components/image-upload-field.d.cts +19 -0
- package/dist/components/image-upload-field.d.ts +19 -0
- package/dist/components/image-upload-field.js +106 -0
- package/dist/components/image-upload-field.js.map +1 -0
- package/dist/components/launchpad/coin-create.cjs +12 -55
- package/dist/components/launchpad/coin-create.cjs.map +1 -1
- package/dist/components/launchpad/coin-create.js +13 -56
- package/dist/components/launchpad/coin-create.js.map +1 -1
- package/dist/components/launchpad/collection-create-form.cjs +18 -76
- package/dist/components/launchpad/collection-create-form.cjs.map +1 -1
- package/dist/components/launchpad/collection-create-form.js +18 -76
- package/dist/components/launchpad/collection-create-form.js.map +1 -1
- package/dist/components/launchpad/edition-mint-fields.cjs +12 -87
- package/dist/components/launchpad/edition-mint-fields.cjs.map +1 -1
- package/dist/components/launchpad/edition-mint-fields.d.cts +4 -8
- package/dist/components/launchpad/edition-mint-fields.d.ts +4 -8
- package/dist/components/launchpad/edition-mint-fields.js +14 -79
- package/dist/components/launchpad/edition-mint-fields.js.map +1 -1
- package/dist/components/launchpad/edition-mint-schema.d.cts +8 -8
- package/dist/components/launchpad/edition-mint-schema.d.ts +8 -8
- package/dist/components/launchpad/edition-mint.cjs +24 -46
- package/dist/components/launchpad/edition-mint.cjs.map +1 -1
- package/dist/components/launchpad/edition-mint.js +24 -46
- package/dist/components/launchpad/edition-mint.js.map +1 -1
- package/dist/components/launchpad/pop-create-fields.cjs +14 -91
- package/dist/components/launchpad/pop-create-fields.cjs.map +1 -1
- package/dist/components/launchpad/pop-create-fields.d.cts +4 -8
- package/dist/components/launchpad/pop-create-fields.d.ts +4 -8
- package/dist/components/launchpad/pop-create-fields.js +14 -83
- package/dist/components/launchpad/pop-create-fields.js.map +1 -1
- package/dist/components/launchpad/pop-create.cjs +21 -33
- package/dist/components/launchpad/pop-create.cjs.map +1 -1
- package/dist/components/launchpad/pop-create.js +21 -33
- package/dist/components/launchpad/pop-create.js.map +1 -1
- package/dist/components/launchpad/remix-mint.cjs +20 -61
- package/dist/components/launchpad/remix-mint.cjs.map +1 -1
- package/dist/components/launchpad/remix-mint.js +21 -62
- package/dist/components/launchpad/remix-mint.js.map +1 -1
- package/dist/components/launchpad/single-edition-mint.cjs +12 -73
- package/dist/components/launchpad/single-edition-mint.cjs.map +1 -1
- package/dist/components/launchpad/single-edition-mint.js +13 -74
- package/dist/components/launchpad/single-edition-mint.js.map +1 -1
- package/dist/components/launchpad/sponsorship-create.cjs +2 -2
- package/dist/components/launchpad/sponsorship-create.cjs.map +1 -1
- package/dist/components/launchpad/sponsorship-create.js +2 -2
- package/dist/components/launchpad/sponsorship-create.js.map +1 -1
- package/dist/components/launchpad/tier-mint-form.cjs +17 -70
- package/dist/components/launchpad/tier-mint-form.cjs.map +1 -1
- package/dist/components/launchpad/tier-mint-form.js +18 -71
- package/dist/components/launchpad/tier-mint-form.js.map +1 -1
- package/dist/components/launchpad/tier-mint-presets.cjs +0 -4
- package/dist/components/launchpad/tier-mint-presets.cjs.map +1 -1
- package/dist/components/launchpad/tier-mint-presets.d.cts +0 -2
- package/dist/components/launchpad/tier-mint-presets.d.ts +0 -2
- package/dist/components/launchpad/tier-mint-presets.js +0 -4
- package/dist/components/launchpad/tier-mint-presets.js.map +1 -1
- package/dist/components/license-request-page.cjs +14 -18
- package/dist/components/license-request-page.cjs.map +1 -1
- package/dist/components/license-request-page.js +16 -20
- package/dist/components/license-request-page.js.map +1 -1
- package/dist/components/page-container.cjs +2 -1
- package/dist/components/page-container.cjs.map +1 -1
- package/dist/components/page-container.d.cts +1 -1
- package/dist/components/page-container.d.ts +1 -1
- package/dist/components/page-container.js +2 -1
- package/dist/components/page-container.js.map +1 -1
- package/dist/components/page-state.cjs +50 -0
- package/dist/components/page-state.cjs.map +1 -0
- package/dist/components/page-state.d.cts +18 -0
- package/dist/components/page-state.d.ts +18 -0
- package/dist/components/page-state.js +25 -0
- package/dist/components/page-state.js.map +1 -0
- package/dist/components/pop-claim-button.cjs +1 -1
- package/dist/components/pop-claim-button.cjs.map +1 -1
- package/dist/components/pop-claim-button.js +1 -1
- package/dist/components/pop-claim-button.js.map +1 -1
- package/dist/components/pop-manage-page.cjs +53 -72
- package/dist/components/pop-manage-page.cjs.map +1 -1
- package/dist/components/pop-manage-page.js +54 -73
- package/dist/components/pop-manage-page.js.map +1 -1
- package/dist/components/pop-my-events-page.cjs +5 -4
- package/dist/components/pop-my-events-page.cjs.map +1 -1
- package/dist/components/pop-my-events-page.js +5 -4
- package/dist/components/pop-my-events-page.js.map +1 -1
- package/dist/components/portfolio-shell.cjs +3 -12
- package/dist/components/portfolio-shell.cjs.map +1 -1
- package/dist/components/portfolio-shell.js +3 -12
- package/dist/components/portfolio-shell.js.map +1 -1
- package/dist/components/service-collections-page.cjs +2 -4
- package/dist/components/service-collections-page.cjs.map +1 -1
- package/dist/components/service-collections-page.d.cts +0 -2
- package/dist/components/service-collections-page.d.ts +0 -2
- package/dist/components/service-collections-page.js +2 -4
- package/dist/components/service-collections-page.js.map +1 -1
- package/dist/components/sponsorship-offer-page.cjs +4 -3
- package/dist/components/sponsorship-offer-page.cjs.map +1 -1
- package/dist/components/sponsorship-offer-page.js +4 -3
- package/dist/components/sponsorship-offer-page.js.map +1 -1
- package/dist/components/transaction-dialog.cjs +2 -2
- package/dist/components/transaction-dialog.cjs.map +1 -1
- package/dist/components/transaction-dialog.js +2 -2
- package/dist/components/transaction-dialog.js.map +1 -1
- package/dist/components/transfer-collection-ownership.cjs +1 -1
- package/dist/components/transfer-collection-ownership.cjs.map +1 -1
- package/dist/components/transfer-collection-ownership.js +1 -1
- package/dist/components/transfer-collection-ownership.js.map +1 -1
- package/dist/components/wallet-required.cjs +4 -14
- package/dist/components/wallet-required.cjs.map +1 -1
- package/dist/components/wallet-required.js +5 -15
- package/dist/components/wallet-required.js.map +1 -1
- package/dist/i18n/catalog/pt.cjs +25 -9
- package/dist/i18n/catalog/pt.cjs.map +1 -1
- package/dist/i18n/catalog/pt.js +25 -9
- package/dist/i18n/catalog/pt.js.map +1 -1
- package/dist/index.cjs +14 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/ipfs-upload.cjs +3 -7
- package/dist/utils/ipfs-upload.cjs.map +1 -1
- package/dist/utils/ipfs-upload.d.cts +1 -3
- package/dist/utils/ipfs-upload.d.ts +1 -3
- package/dist/utils/ipfs-upload.js +3 -7
- package/dist/utils/ipfs-upload.js.map +1 -1
- package/dist/utils/use-file-upload.cjs +105 -0
- package/dist/utils/use-file-upload.cjs.map +1 -0
- package/dist/utils/use-file-upload.d.cts +26 -0
- package/dist/utils/use-file-upload.d.ts +26 -0
- package/dist/utils/use-file-upload.js +81 -0
- package/dist/utils/use-file-upload.js.map +1 -0
- package/dist/utils/use-image-upload.cjs +56 -0
- package/dist/utils/use-image-upload.cjs.map +1 -0
- package/dist/utils/use-image-upload.d.cts +19 -0
- package/dist/utils/use-image-upload.d.ts +19 -0
- package/dist/utils/use-image-upload.js +32 -0
- package/dist/utils/use-image-upload.js.map +1 -0
- package/package.json +1 -1
- package/dist/components/fast-mint/use-ipfs-upload.cjs +0 -64
- package/dist/components/fast-mint/use-ipfs-upload.cjs.map +0 -1
- package/dist/components/fast-mint/use-ipfs-upload.d.cts +0 -9
- package/dist/components/fast-mint/use-ipfs-upload.d.ts +0 -9
- package/dist/components/fast-mint/use-ipfs-upload.js +0 -40
- package/dist/components/fast-mint/use-ipfs-upload.js.map +0 -1
- package/dist/utils/use-launchpad-image-upload.cjs +0 -103
- package/dist/utils/use-launchpad-image-upload.cjs.map +0 -1
- package/dist/utils/use-launchpad-image-upload.d.cts +0 -21
- package/dist/utils/use-launchpad-image-upload.d.ts +0 -21
- package/dist/utils/use-launchpad-image-upload.js +0 -79
- package/dist/utils/use-launchpad-image-upload.js.map +0 -1
|
@@ -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":";;;;;;;;;;;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,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":[]}
|
|
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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D,UAAU,4CAAC,OAAO,QAAP,EAAc,QAAgB,OAAO,aAAa,QAAQ,cAAc;AAAA,UAEnF,WAAW,WAAW,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 {
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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__ */
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
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
|
-
|
|
267
|
+
ImageUploadField,
|
|
265
268
|
{
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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 }),
|
|
@@ -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"],"m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YAClD;AAAA,aACH;AAAA,UACA,oBAAC,OAAE,WAAU,6CACV,YAAE,6BAA6B,GAClC;AAAA,WACF;AAAA,QAEA,oBAAC,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,gBAAgB,YAAY,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":";AAwLQ,SACE,KADF;AAtLR,SAAS,WAAW,QAAQ,gBAAgB;AAC5C,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,wBAA+C;AACxD,SAAS,gCAAgC;AAEzC,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,+BAA+B;AACxC,SAAS,QAAQ,eAAe,mBAAmB,mBAAmB;AAEtE,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,cAAc,gBAAgB;AACvC,SAAS,0BAAyC;AAClD,SAAS,SAAS,WAAW,2BAA2B;AAExD,SAAS,sBAAuC;AAChD,SAAS,iBAAiB,wBAAwB,uBAAuB;AACzE,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AAEtC,SAAS,YAAY;AACrB,SAAS,WAAW;AACpB,SAAS,oBAAoB;AAEtB,SAAS,SAAS,OAAsB;AAC7C,QAAM,IAAI,KAAK;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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AAA,gBAChC,UAAU,CAAC,MAAM,KAAK,SAAS,gBAAgB,EAAE,OAAO,KAAK;AAAA,gBAC7D,aAAa,EAAE,yBAAyB;AAAA;AAAA,YAC1C;AAAA,aACF;AAAA,UAEC,cAAc,WACb;AAAA,YAAC;AAAA;AAAA,cACC,QAAQ;AAAA,cACR,OAAO,EAAE,uCAAuC;AAAA,cAChD,MAAM,EAAE,yBAAyB;AAAA;AAAA,UACnC;AAAA,UAGD,UAAU,oBAAC,OAAO,QAAP,EAAc,QAAgB,OAAO,aAAa,QAAQ,cAAc;AAAA,UAEnF,WAAW,WAAW,YAAY,oBAAC,OAAE,WAAU,4BAA4B,oBAAS;AAAA,UAErF,qBAAC,gBAAa,OAAK,MAAC,KAAG,MAAC,MAAK,UAAS,UAAU,eAAe,SAAS,MAAM,KAAK,SAAS,GAAG,WAAU,UACtG;AAAA,oBAAQ,oBAAC,WAAQ,WAAU,wBAAuB;AAAA,YAClD;AAAA,aACH;AAAA,UACA,oBAAC,OAAE,WAAU,6CACV,YAAE,6BAA6B,GAClC;AAAA,WACF;AAAA,QAEA,oBAAC,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,gBAAgB,YAAY,EAAE,SAAS,cAAc,CAAC,IAAI;AAAA;AAAA,QACzE,GACF;AAAA,SACF;AAAA,OAEJ;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var image_upload_field_exports = {};
|
|
31
|
+
__export(image_upload_field_exports, {
|
|
32
|
+
ImageUploadField: () => ImageUploadField
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(image_upload_field_exports);
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_lucide_react = require("lucide-react");
|
|
38
|
+
var import_image = __toESM(require("./image.js"), 1);
|
|
39
|
+
var import_button = require("./button.js");
|
|
40
|
+
var import_upload_limits = require("../utils/upload-limits.js");
|
|
41
|
+
var import_cn = require("../utils/cn.js");
|
|
42
|
+
var import_provider = require("../i18n/provider.js");
|
|
43
|
+
function ImageUploadField({ upload, label, ariaLabel, alt = "", required, optional, hint, buttonLabel, round, currentImage }) {
|
|
44
|
+
const t = (0, import_provider.useT)();
|
|
45
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
46
|
+
const { status, error, uploading } = upload;
|
|
47
|
+
const failed = status === "failed" || !!error;
|
|
48
|
+
const shown = upload.file ? upload.preview : currentImage;
|
|
49
|
+
const hasImage = !!upload.file || !!currentImage;
|
|
50
|
+
const name = typeof label === "string" ? label : ariaLabel ?? t("Upload image");
|
|
51
|
+
const open = () => inputRef.current?.click();
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
ref: upload.fieldRef,
|
|
56
|
+
role: "group",
|
|
57
|
+
"aria-label": name,
|
|
58
|
+
tabIndex: -1,
|
|
59
|
+
"data-status": status,
|
|
60
|
+
className: "space-y-2 outline-none",
|
|
61
|
+
children: [
|
|
62
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-sm font-medium", children: [
|
|
63
|
+
label,
|
|
64
|
+
required ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-destructive", children: " *" }) : null,
|
|
65
|
+
optional ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "text-muted-foreground font-normal", children: [
|
|
66
|
+
" ",
|
|
67
|
+
t("(optional)")
|
|
68
|
+
] }) : null
|
|
69
|
+
] }) : null,
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-4", children: [
|
|
71
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
72
|
+
"button",
|
|
73
|
+
{
|
|
74
|
+
type: "button",
|
|
75
|
+
onClick: open,
|
|
76
|
+
disabled: uploading,
|
|
77
|
+
"aria-label": name,
|
|
78
|
+
className: (0, import_cn.cn)(
|
|
79
|
+
"relative flex h-24 w-24 shrink-0 items-center justify-center overflow-hidden border-2 border-dashed bg-muted transition-colors",
|
|
80
|
+
round ? "rounded-full" : "rounded-2xl",
|
|
81
|
+
failed ? "border-destructive" : "border-border hover:border-primary/50"
|
|
82
|
+
),
|
|
83
|
+
children: [
|
|
84
|
+
shown ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_image.default, { src: shown, alt, fill: true, unoptimized: true, className: (0, import_cn.cn)("object-cover", failed && "opacity-30") }) : failed ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ImagePlus, { className: "h-6 w-6 text-muted-foreground" }),
|
|
85
|
+
uploading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "absolute inset-0 flex items-center justify-center bg-background/70", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "h-4 w-4 animate-spin" }) }) : null,
|
|
86
|
+
failed ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AlertCircle, { className: "relative h-7 w-7 text-destructive" }) : null
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-w-0 space-y-1.5", children: [
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
+
"input",
|
|
93
|
+
{
|
|
94
|
+
ref: inputRef,
|
|
95
|
+
type: "file",
|
|
96
|
+
accept: (0, import_upload_limits.acceptFor)("image"),
|
|
97
|
+
className: "hidden",
|
|
98
|
+
onChange: (event) => {
|
|
99
|
+
const file = event.target.files?.[0];
|
|
100
|
+
event.target.value = "";
|
|
101
|
+
if (file) void upload.select(file);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
106
|
+
upload.canRetry ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { type: "button", size: "sm", onClick: () => void upload.retry(), children: [
|
|
107
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.RotateCw, { className: "mr-1.5 h-3.5 w-3.5" }),
|
|
108
|
+
t("Retry")
|
|
109
|
+
] }) : null,
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { type: "button", variant: "soft", size: "sm", disabled: uploading, onClick: open, children: uploading ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "mr-1.5 h-3.5 w-3.5 animate-spin" }),
|
|
112
|
+
t("Uploading\u2026")
|
|
113
|
+
] }) : hasImage ? t("Change") : buttonLabel ?? t("Upload image") })
|
|
114
|
+
] }),
|
|
115
|
+
hasImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
116
|
+
"button",
|
|
117
|
+
{
|
|
118
|
+
type: "button",
|
|
119
|
+
onClick: upload.clear,
|
|
120
|
+
className: "flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-destructive",
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.X, { className: "h-3 w-3" }),
|
|
123
|
+
" ",
|
|
124
|
+
t("Remove")
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
) : null,
|
|
128
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", className: "text-sm text-destructive", children: error }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: status === "uploaded" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-primary", children: t("\u2713 Uploaded") }) : t("Image files") }),
|
|
129
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground", children: hint }) : null
|
|
130
|
+
] })
|
|
131
|
+
] })
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
137
|
+
0 && (module.exports = {
|
|
138
|
+
ImageUploadField
|
|
139
|
+
});
|
|
140
|
+
//# sourceMappingURL=image-upload-field.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/image-upload-field.tsx"],"sourcesContent":["\"use client\";\n\nimport { useRef, type ReactNode } from \"react\";\nimport { AlertCircle, ImagePlus, Loader2, RotateCw, X } from \"lucide-react\";\nimport Image from \"./image.js\";\nimport { Button } from \"./button.js\";\nimport { acceptFor } from \"../utils/upload-limits.js\";\nimport { cn } from \"../utils/cn.js\";\nimport type { FileUpload } from \"../utils/use-file-upload.js\";\nimport { useT } from \"../i18n/provider.js\";\n\nexport interface ImageUploadFieldProps {\n upload: FileUpload;\n label?: ReactNode;\n ariaLabel?: string;\n alt?: string;\n required?: boolean;\n optional?: boolean;\n hint?: ReactNode;\n buttonLabel?: string;\n round?: boolean;\n currentImage?: string | null;\n}\n\nexport function ImageUploadField({ upload, label, ariaLabel, alt = \"\", required, optional, hint, buttonLabel, round, currentImage }: ImageUploadFieldProps) {\n const t = useT();\n const inputRef = useRef<HTMLInputElement>(null);\n const { status, error, uploading } = upload;\n const failed = status === \"failed\" || !!error;\n const shown = upload.file ? upload.preview : currentImage;\n const hasImage = !!upload.file || !!currentImage;\n const name = typeof label === \"string\" ? label : ariaLabel ?? t(\"Upload image\");\n const open = () => inputRef.current?.click();\n\n return (\n <div\n ref={upload.fieldRef}\n role=\"group\"\n aria-label={name}\n tabIndex={-1}\n data-status={status}\n className=\"space-y-2 outline-none\"\n >\n {label ? (\n <p className=\"text-sm font-medium\">\n {label}\n {required ? <span className=\"text-destructive\"> *</span> : null}\n {optional ? <span className=\"text-muted-foreground font-normal\"> {t(\"(optional)\")}</span> : null}\n </p>\n ) : null}\n\n <div className=\"flex items-center gap-4\">\n <button\n type=\"button\"\n onClick={open}\n disabled={uploading}\n aria-label={name}\n className={cn(\n \"relative flex h-24 w-24 shrink-0 items-center justify-center overflow-hidden border-2 border-dashed bg-muted transition-colors\",\n round ? \"rounded-full\" : \"rounded-2xl\",\n failed ? \"border-destructive\" : \"border-border hover:border-primary/50\",\n )}\n >\n {shown ? (\n <Image src={shown} alt={alt} fill unoptimized className={cn(\"object-cover\", failed && \"opacity-30\")} />\n ) : failed ? null : (\n <ImagePlus className=\"h-6 w-6 text-muted-foreground\" />\n )}\n {uploading ? (\n <span className=\"absolute inset-0 flex items-center justify-center bg-background/70\">\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n </span>\n ) : null}\n {failed ? <AlertCircle className=\"relative h-7 w-7 text-destructive\" /> : null}\n </button>\n\n <div className=\"min-w-0 space-y-1.5\">\n <input\n ref={inputRef}\n type=\"file\"\n accept={acceptFor(\"image\")}\n className=\"hidden\"\n onChange={(event) => {\n const file = event.target.files?.[0];\n event.target.value = \"\";\n if (file) void upload.select(file);\n }}\n />\n <div className=\"flex flex-wrap items-center gap-2\">\n {upload.canRetry ? (\n <Button type=\"button\" size=\"sm\" onClick={() => void upload.retry()}>\n <RotateCw className=\"mr-1.5 h-3.5 w-3.5\" />\n {t(\"Retry\")}\n </Button>\n ) : null}\n <Button type=\"button\" variant=\"soft\" size=\"sm\" disabled={uploading} onClick={open}>\n {uploading ? (\n <>\n <Loader2 className=\"mr-1.5 h-3.5 w-3.5 animate-spin\" />\n {t(\"Uploading…\")}\n </>\n ) : hasImage ? t(\"Change\") : buttonLabel ?? t(\"Upload image\")}\n </Button>\n </div>\n {hasImage ? (\n <button\n type=\"button\"\n onClick={upload.clear}\n className=\"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-destructive\"\n >\n <X className=\"h-3 w-3\" /> {t(\"Remove\")}\n </button>\n ) : null}\n {error ? (\n <p role=\"alert\" className=\"text-sm text-destructive\">{error}</p>\n ) : (\n <p className=\"text-xs text-muted-foreground\">\n {status === \"uploaded\" ? <span className=\"text-primary\">{t(\"✓ Uploaded\")}</span> : t(\"Image files\")}\n </p>\n )}\n {hint ? <p className=\"text-xs text-muted-foreground\">{hint}</p> : null}\n </div>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CsB;AA5CtB,mBAAuC;AACvC,0BAA6D;AAC7D,mBAAkB;AAClB,oBAAuB;AACvB,2BAA0B;AAC1B,gBAAmB;AAEnB,sBAAqB;AAed,SAAS,iBAAiB,EAAE,QAAQ,OAAO,WAAW,MAAM,IAAI,UAAU,UAAU,MAAM,aAAa,OAAO,aAAa,GAA0B;AAC1J,QAAM,QAAI,sBAAK;AACf,QAAM,eAAW,qBAAyB,IAAI;AAC9C,QAAM,EAAE,QAAQ,OAAO,UAAU,IAAI;AACrC,QAAM,SAAS,WAAW,YAAY,CAAC,CAAC;AACxC,QAAM,QAAQ,OAAO,OAAO,OAAO,UAAU;AAC7C,QAAM,WAAW,CAAC,CAAC,OAAO,QAAQ,CAAC,CAAC;AACpC,QAAM,OAAO,OAAO,UAAU,WAAW,QAAQ,aAAa,EAAE,cAAc;AAC9E,QAAM,OAAO,MAAM,SAAS,SAAS,MAAM;AAE3C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK,OAAO;AAAA,MACZ,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,UAAU;AAAA,MACV,eAAa;AAAA,MACb,WAAU;AAAA,MAET;AAAA,gBACC,6CAAC,OAAE,WAAU,uBACV;AAAA;AAAA,UACA,WAAW,4CAAC,UAAK,WAAU,oBAAmB,gBAAE,IAAU;AAAA,UAC1D,WAAW,6CAAC,UAAK,WAAU,qCAAoC;AAAA;AAAA,YAAE,EAAE,YAAY;AAAA,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;AAAA,4DAAC,+BAAQ,WAAU,mCAAkC;AAAA,gBACpD,EAAE,iBAAY;AAAA,iBACjB,IACE,WAAW,EAAE,QAAQ,IAAI,eAAe,EAAE,cAAc,GAC9D;AAAA,eACF;AAAA,YACC,WACC;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,SAAS,OAAO;AAAA,gBAChB,WAAU;AAAA,gBAEV;AAAA,8DAAC,yBAAE,WAAU,WAAU;AAAA,kBAAE;AAAA,kBAAE,EAAE,QAAQ;AAAA;AAAA;AAAA,YACvC,IACE;AAAA,YACH,QACC,4CAAC,OAAE,MAAK,SAAQ,WAAU,4BAA4B,iBAAM,IAE5D,4CAAC,OAAE,WAAU,iCACV,qBAAW,aAAa,4CAAC,UAAK,WAAU,gBAAgB,YAAE,iBAAY,GAAE,IAAU,EAAE,aAAa,GACpG;AAAA,YAED,OAAO,4CAAC,OAAE,WAAU,iCAAiC,gBAAK,IAAO;AAAA,aACpE;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["Image"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { FileUpload } from '../utils/use-file-upload.cjs';
|
|
4
|
+
|
|
5
|
+
interface ImageUploadFieldProps {
|
|
6
|
+
upload: FileUpload;
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
ariaLabel?: string;
|
|
9
|
+
alt?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
optional?: boolean;
|
|
12
|
+
hint?: ReactNode;
|
|
13
|
+
buttonLabel?: string;
|
|
14
|
+
round?: boolean;
|
|
15
|
+
currentImage?: string | null;
|
|
16
|
+
}
|
|
17
|
+
declare function ImageUploadField({ upload, label, ariaLabel, alt, required, optional, hint, buttonLabel, round, currentImage }: ImageUploadFieldProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { ImageUploadField, type ImageUploadFieldProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { FileUpload } from '../utils/use-file-upload.js';
|
|
4
|
+
|
|
5
|
+
interface ImageUploadFieldProps {
|
|
6
|
+
upload: FileUpload;
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
ariaLabel?: string;
|
|
9
|
+
alt?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
optional?: boolean;
|
|
12
|
+
hint?: ReactNode;
|
|
13
|
+
buttonLabel?: string;
|
|
14
|
+
round?: boolean;
|
|
15
|
+
currentImage?: string | null;
|
|
16
|
+
}
|
|
17
|
+
declare function ImageUploadField({ upload, label, ariaLabel, alt, required, optional, hint, buttonLabel, round, currentImage }: ImageUploadFieldProps): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { ImageUploadField, type ImageUploadFieldProps };
|