@medialane/ui 0.286.0 → 0.287.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/components/button.d.cts +1 -1
  2. package/dist/components/button.d.ts +1 -1
  3. package/dist/components/collection-settings.cjs +350 -0
  4. package/dist/components/collection-settings.cjs.map +1 -0
  5. package/dist/components/collection-settings.d.cts +7 -0
  6. package/dist/components/collection-settings.d.ts +7 -0
  7. package/dist/components/collection-settings.js +335 -0
  8. package/dist/components/collection-settings.js.map +1 -0
  9. package/dist/components/collection-slug-claim.cjs +219 -0
  10. package/dist/components/collection-slug-claim.cjs.map +1 -0
  11. package/dist/components/collection-slug-claim.d.cts +10 -0
  12. package/dist/components/collection-slug-claim.d.ts +10 -0
  13. package/dist/components/collection-slug-claim.js +185 -0
  14. package/dist/components/collection-slug-claim.js.map +1 -0
  15. package/dist/components/fast-mint/fast-mint.d.cts +2 -2
  16. package/dist/components/fast-mint/fast-mint.d.ts +2 -2
  17. package/dist/components/medialane-app.cjs.map +1 -1
  18. package/dist/components/medialane-app.d.cts +1 -0
  19. package/dist/components/medialane-app.d.ts +1 -0
  20. package/dist/components/medialane-app.js.map +1 -1
  21. package/dist/components/settings-section.cjs +65 -0
  22. package/dist/components/settings-section.cjs.map +1 -0
  23. package/dist/components/settings-section.d.cts +24 -0
  24. package/dist/components/settings-section.d.ts +24 -0
  25. package/dist/components/settings-section.js +38 -0
  26. package/dist/components/settings-section.js.map +1 -0
  27. package/dist/components/sheet.d.cts +1 -1
  28. package/dist/components/sheet.d.ts +1 -1
  29. package/dist/index.cjs +3 -0
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1 -0
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +2 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/utils/collection-settings-form.cjs +77 -0
  36. package/dist/utils/collection-settings-form.cjs.map +1 -0
  37. package/dist/utils/collection-settings-form.d.cts +21 -0
  38. package/dist/utils/collection-settings-form.d.ts +21 -0
  39. package/dist/utils/collection-settings-form.js +51 -0
  40. package/dist/utils/collection-settings-form.js.map +1 -0
  41. package/dist/utils/use-collection-settings.cjs +83 -0
  42. package/dist/utils/use-collection-settings.cjs.map +1 -0
  43. package/dist/utils/use-collection-settings.d.cts +58 -0
  44. package/dist/utils/use-collection-settings.d.ts +58 -0
  45. package/dist/utils/use-collection-settings.js +59 -0
  46. package/dist/utils/use-collection-settings.js.map +1 -0
  47. package/package.json +1 -1
@@ -0,0 +1,77 @@
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 collection_settings_form_exports = {};
20
+ __export(collection_settings_form_exports, {
21
+ EMPTY_SETTINGS_FORM: () => EMPTY_SETTINGS_FORM,
22
+ applyProfile: () => applyProfile,
23
+ toProfileInput: () => toProfileInput
24
+ });
25
+ module.exports = __toCommonJS(collection_settings_form_exports);
26
+ const EMPTY_SETTINGS_FORM = {
27
+ displayName: "",
28
+ description: "",
29
+ image: "",
30
+ bannerImage: "",
31
+ websiteUrl: "",
32
+ twitterUrl: "",
33
+ discordUrl: "",
34
+ telegramUrl: "",
35
+ gatedEnabled: false,
36
+ gatedContentTitle: "",
37
+ gatedContentUrl: "",
38
+ gatedContentType: ""
39
+ };
40
+ function applyProfile(form, profile) {
41
+ return {
42
+ ...form,
43
+ displayName: profile.displayName ?? "",
44
+ description: profile.description ?? "",
45
+ image: profile.image ?? "",
46
+ bannerImage: profile.bannerImage ?? "",
47
+ websiteUrl: profile.websiteUrl ?? "",
48
+ twitterUrl: profile.twitterUrl ?? "",
49
+ discordUrl: profile.discordUrl ?? "",
50
+ telegramUrl: profile.telegramUrl ?? "",
51
+ gatedEnabled: profile.hasGatedContent,
52
+ gatedContentTitle: profile.gatedContentTitle ?? ""
53
+ };
54
+ }
55
+ function toProfileInput(form) {
56
+ const gated = form.gatedEnabled;
57
+ return {
58
+ displayName: form.displayName || null,
59
+ description: form.description || null,
60
+ image: form.image || null,
61
+ bannerImage: form.bannerImage || null,
62
+ websiteUrl: form.websiteUrl || null,
63
+ twitterUrl: form.twitterUrl || null,
64
+ discordUrl: form.discordUrl || null,
65
+ telegramUrl: form.telegramUrl || null,
66
+ gatedContentTitle: gated ? form.gatedContentTitle || null : null,
67
+ gatedContentUrl: gated ? form.gatedContentUrl || null : null,
68
+ gatedContentType: gated ? form.gatedContentType || null : null
69
+ };
70
+ }
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ EMPTY_SETTINGS_FORM,
74
+ applyProfile,
75
+ toProfileInput
76
+ });
77
+ //# sourceMappingURL=collection-settings-form.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/collection-settings-form.ts"],"sourcesContent":["import type { ApiCollectionProfile, UpdateCollectionProfileInput } from \"@medialane/sdk\";\n\nexport interface CollectionSettingsForm {\n displayName: string;\n description: string;\n image: string;\n bannerImage: string;\n websiteUrl: string;\n twitterUrl: string;\n discordUrl: string;\n telegramUrl: string;\n gatedEnabled: boolean;\n gatedContentTitle: string;\n gatedContentUrl: string;\n gatedContentType: string;\n}\n\nexport const EMPTY_SETTINGS_FORM: CollectionSettingsForm = {\n displayName: \"\",\n description: \"\",\n image: \"\",\n bannerImage: \"\",\n websiteUrl: \"\",\n twitterUrl: \"\",\n discordUrl: \"\",\n telegramUrl: \"\",\n gatedEnabled: false,\n gatedContentTitle: \"\",\n gatedContentUrl: \"\",\n gatedContentType: \"\",\n};\n\nexport function applyProfile(form: CollectionSettingsForm, profile: ApiCollectionProfile): CollectionSettingsForm {\n return {\n ...form,\n displayName: profile.displayName ?? \"\",\n description: profile.description ?? \"\",\n image: profile.image ?? \"\",\n bannerImage: profile.bannerImage ?? \"\",\n websiteUrl: profile.websiteUrl ?? \"\",\n twitterUrl: profile.twitterUrl ?? \"\",\n discordUrl: profile.discordUrl ?? \"\",\n telegramUrl: profile.telegramUrl ?? \"\",\n gatedEnabled: profile.hasGatedContent,\n gatedContentTitle: profile.gatedContentTitle ?? \"\",\n };\n}\n\nexport function toProfileInput(form: CollectionSettingsForm): UpdateCollectionProfileInput {\n const gated = form.gatedEnabled;\n return {\n displayName: form.displayName || null,\n description: form.description || null,\n image: form.image || null,\n bannerImage: form.bannerImage || null,\n websiteUrl: form.websiteUrl || null,\n twitterUrl: form.twitterUrl || null,\n discordUrl: form.discordUrl || null,\n telegramUrl: form.telegramUrl || null,\n gatedContentTitle: gated ? form.gatedContentTitle || null : null,\n gatedContentUrl: gated ? form.gatedContentUrl || null : null,\n gatedContentType: gated\n ? ((form.gatedContentType || null) as UpdateCollectionProfileInput[\"gatedContentType\"])\n : null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,MAAM,sBAA8C;AAAA,EACzD,aAAa;AAAA,EACb,aAAa;AAAA,EACb,OAAO;AAAA,EACP,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,kBAAkB;AACpB;AAEO,SAAS,aAAa,MAA8B,SAAuD;AAChH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,aAAa,QAAQ,eAAe;AAAA,IACpC,aAAa,QAAQ,eAAe;AAAA,IACpC,OAAO,QAAQ,SAAS;AAAA,IACxB,aAAa,QAAQ,eAAe;AAAA,IACpC,YAAY,QAAQ,cAAc;AAAA,IAClC,YAAY,QAAQ,cAAc;AAAA,IAClC,YAAY,QAAQ,cAAc;AAAA,IAClC,aAAa,QAAQ,eAAe;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,mBAAmB,QAAQ,qBAAqB;AAAA,EAClD;AACF;AAEO,SAAS,eAAe,MAA4D;AACzF,QAAM,QAAQ,KAAK;AACnB,SAAO;AAAA,IACL,aAAa,KAAK,eAAe;AAAA,IACjC,aAAa,KAAK,eAAe;AAAA,IACjC,OAAO,KAAK,SAAS;AAAA,IACrB,aAAa,KAAK,eAAe;AAAA,IACjC,YAAY,KAAK,cAAc;AAAA,IAC/B,YAAY,KAAK,cAAc;AAAA,IAC/B,YAAY,KAAK,cAAc;AAAA,IAC/B,aAAa,KAAK,eAAe;AAAA,IACjC,mBAAmB,QAAQ,KAAK,qBAAqB,OAAO;AAAA,IAC5D,iBAAiB,QAAQ,KAAK,mBAAmB,OAAO;AAAA,IACxD,kBAAkB,QACZ,KAAK,oBAAoB,OAC3B;AAAA,EACN;AACF;","names":[]}
@@ -0,0 +1,21 @@
1
+ import { ApiCollectionProfile, UpdateCollectionProfileInput } from '@medialane/sdk';
2
+
3
+ interface CollectionSettingsForm {
4
+ displayName: string;
5
+ description: string;
6
+ image: string;
7
+ bannerImage: string;
8
+ websiteUrl: string;
9
+ twitterUrl: string;
10
+ discordUrl: string;
11
+ telegramUrl: string;
12
+ gatedEnabled: boolean;
13
+ gatedContentTitle: string;
14
+ gatedContentUrl: string;
15
+ gatedContentType: string;
16
+ }
17
+ declare const EMPTY_SETTINGS_FORM: CollectionSettingsForm;
18
+ declare function applyProfile(form: CollectionSettingsForm, profile: ApiCollectionProfile): CollectionSettingsForm;
19
+ declare function toProfileInput(form: CollectionSettingsForm): UpdateCollectionProfileInput;
20
+
21
+ export { type CollectionSettingsForm, EMPTY_SETTINGS_FORM, applyProfile, toProfileInput };
@@ -0,0 +1,21 @@
1
+ import { ApiCollectionProfile, UpdateCollectionProfileInput } from '@medialane/sdk';
2
+
3
+ interface CollectionSettingsForm {
4
+ displayName: string;
5
+ description: string;
6
+ image: string;
7
+ bannerImage: string;
8
+ websiteUrl: string;
9
+ twitterUrl: string;
10
+ discordUrl: string;
11
+ telegramUrl: string;
12
+ gatedEnabled: boolean;
13
+ gatedContentTitle: string;
14
+ gatedContentUrl: string;
15
+ gatedContentType: string;
16
+ }
17
+ declare const EMPTY_SETTINGS_FORM: CollectionSettingsForm;
18
+ declare function applyProfile(form: CollectionSettingsForm, profile: ApiCollectionProfile): CollectionSettingsForm;
19
+ declare function toProfileInput(form: CollectionSettingsForm): UpdateCollectionProfileInput;
20
+
21
+ export { type CollectionSettingsForm, EMPTY_SETTINGS_FORM, applyProfile, toProfileInput };
@@ -0,0 +1,51 @@
1
+ const EMPTY_SETTINGS_FORM = {
2
+ displayName: "",
3
+ description: "",
4
+ image: "",
5
+ bannerImage: "",
6
+ websiteUrl: "",
7
+ twitterUrl: "",
8
+ discordUrl: "",
9
+ telegramUrl: "",
10
+ gatedEnabled: false,
11
+ gatedContentTitle: "",
12
+ gatedContentUrl: "",
13
+ gatedContentType: ""
14
+ };
15
+ function applyProfile(form, profile) {
16
+ return {
17
+ ...form,
18
+ displayName: profile.displayName ?? "",
19
+ description: profile.description ?? "",
20
+ image: profile.image ?? "",
21
+ bannerImage: profile.bannerImage ?? "",
22
+ websiteUrl: profile.websiteUrl ?? "",
23
+ twitterUrl: profile.twitterUrl ?? "",
24
+ discordUrl: profile.discordUrl ?? "",
25
+ telegramUrl: profile.telegramUrl ?? "",
26
+ gatedEnabled: profile.hasGatedContent,
27
+ gatedContentTitle: profile.gatedContentTitle ?? ""
28
+ };
29
+ }
30
+ function toProfileInput(form) {
31
+ const gated = form.gatedEnabled;
32
+ return {
33
+ displayName: form.displayName || null,
34
+ description: form.description || null,
35
+ image: form.image || null,
36
+ bannerImage: form.bannerImage || null,
37
+ websiteUrl: form.websiteUrl || null,
38
+ twitterUrl: form.twitterUrl || null,
39
+ discordUrl: form.discordUrl || null,
40
+ telegramUrl: form.telegramUrl || null,
41
+ gatedContentTitle: gated ? form.gatedContentTitle || null : null,
42
+ gatedContentUrl: gated ? form.gatedContentUrl || null : null,
43
+ gatedContentType: gated ? form.gatedContentType || null : null
44
+ };
45
+ }
46
+ export {
47
+ EMPTY_SETTINGS_FORM,
48
+ applyProfile,
49
+ toProfileInput
50
+ };
51
+ //# sourceMappingURL=collection-settings-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/collection-settings-form.ts"],"sourcesContent":["import type { ApiCollectionProfile, UpdateCollectionProfileInput } from \"@medialane/sdk\";\n\nexport interface CollectionSettingsForm {\n displayName: string;\n description: string;\n image: string;\n bannerImage: string;\n websiteUrl: string;\n twitterUrl: string;\n discordUrl: string;\n telegramUrl: string;\n gatedEnabled: boolean;\n gatedContentTitle: string;\n gatedContentUrl: string;\n gatedContentType: string;\n}\n\nexport const EMPTY_SETTINGS_FORM: CollectionSettingsForm = {\n displayName: \"\",\n description: \"\",\n image: \"\",\n bannerImage: \"\",\n websiteUrl: \"\",\n twitterUrl: \"\",\n discordUrl: \"\",\n telegramUrl: \"\",\n gatedEnabled: false,\n gatedContentTitle: \"\",\n gatedContentUrl: \"\",\n gatedContentType: \"\",\n};\n\nexport function applyProfile(form: CollectionSettingsForm, profile: ApiCollectionProfile): CollectionSettingsForm {\n return {\n ...form,\n displayName: profile.displayName ?? \"\",\n description: profile.description ?? \"\",\n image: profile.image ?? \"\",\n bannerImage: profile.bannerImage ?? \"\",\n websiteUrl: profile.websiteUrl ?? \"\",\n twitterUrl: profile.twitterUrl ?? \"\",\n discordUrl: profile.discordUrl ?? \"\",\n telegramUrl: profile.telegramUrl ?? \"\",\n gatedEnabled: profile.hasGatedContent,\n gatedContentTitle: profile.gatedContentTitle ?? \"\",\n };\n}\n\nexport function toProfileInput(form: CollectionSettingsForm): UpdateCollectionProfileInput {\n const gated = form.gatedEnabled;\n return {\n displayName: form.displayName || null,\n description: form.description || null,\n image: form.image || null,\n bannerImage: form.bannerImage || null,\n websiteUrl: form.websiteUrl || null,\n twitterUrl: form.twitterUrl || null,\n discordUrl: form.discordUrl || null,\n telegramUrl: form.telegramUrl || null,\n gatedContentTitle: gated ? form.gatedContentTitle || null : null,\n gatedContentUrl: gated ? form.gatedContentUrl || null : null,\n gatedContentType: gated\n ? ((form.gatedContentType || null) as UpdateCollectionProfileInput[\"gatedContentType\"])\n : null,\n };\n}\n"],"mappings":"AAiBO,MAAM,sBAA8C;AAAA,EACzD,aAAa;AAAA,EACb,aAAa;AAAA,EACb,OAAO;AAAA,EACP,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,kBAAkB;AACpB;AAEO,SAAS,aAAa,MAA8B,SAAuD;AAChH,SAAO;AAAA,IACL,GAAG;AAAA,IACH,aAAa,QAAQ,eAAe;AAAA,IACpC,aAAa,QAAQ,eAAe;AAAA,IACpC,OAAO,QAAQ,SAAS;AAAA,IACxB,aAAa,QAAQ,eAAe;AAAA,IACpC,YAAY,QAAQ,cAAc;AAAA,IAClC,YAAY,QAAQ,cAAc;AAAA,IAClC,YAAY,QAAQ,cAAc;AAAA,IAClC,aAAa,QAAQ,eAAe;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,mBAAmB,QAAQ,qBAAqB;AAAA,EAClD;AACF;AAEO,SAAS,eAAe,MAA4D;AACzF,QAAM,QAAQ,KAAK;AACnB,SAAO;AAAA,IACL,aAAa,KAAK,eAAe;AAAA,IACjC,aAAa,KAAK,eAAe;AAAA,IACjC,OAAO,KAAK,SAAS;AAAA,IACrB,aAAa,KAAK,eAAe;AAAA,IACjC,YAAY,KAAK,cAAc;AAAA,IAC/B,YAAY,KAAK,cAAc;AAAA,IAC/B,YAAY,KAAK,cAAc;AAAA,IAC/B,aAAa,KAAK,eAAe;AAAA,IACjC,mBAAmB,QAAQ,KAAK,qBAAqB,OAAO;AAAA,IAC5D,iBAAiB,QAAQ,KAAK,mBAAmB,OAAO;AAAA,IACxD,kBAAkB,QACZ,KAAK,oBAAoB,OAC3B;AAAA,EACN;AACF;","names":[]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var use_collection_settings_exports = {};
21
+ __export(use_collection_settings_exports, {
22
+ useCollectionSettings: () => useCollectionSettings
23
+ });
24
+ module.exports = __toCommonJS(use_collection_settings_exports);
25
+ var import_react = require("react");
26
+ var import_sdk = require("@medialane/sdk");
27
+ var import_medialane_app = require("../components/medialane-app.js");
28
+ var import_describe_error = require("./describe-error.js");
29
+ var import_use_collections = require("./use-collections.js");
30
+ var import_use_profiles = require("./use-profiles.js");
31
+ var import_collection_settings_form = require("./collection-settings-form.js");
32
+ function useCollectionSettings(contract) {
33
+ const { walletAddress, getClient, ensureSignedIn } = (0, import_medialane_app.useMedialaneApp)();
34
+ const { collection, isLoading: collectionLoading } = (0, import_use_collections.useCollection)(contract);
35
+ const { profile, isLoading: profileLoading, mutate } = (0, import_use_profiles.useCollectionProfile)(contract);
36
+ const [form, setForm] = (0, import_react.useState)(import_collection_settings_form.EMPTY_SETTINGS_FORM);
37
+ const [saving, setSaving] = (0, import_react.useState)(false);
38
+ const [saveStatus, setSaveStatus] = (0, import_react.useState)("idle");
39
+ const [saveError, setSaveError] = (0, import_react.useState)(null);
40
+ (0, import_react.useEffect)(() => {
41
+ if (profile) setForm((f) => (0, import_collection_settings_form.applyProfile)(f, profile));
42
+ }, [profile]);
43
+ const update = (0, import_react.useCallback)((patch) => setForm((f) => ({ ...f, ...patch })), []);
44
+ const set = (key) => (e) => update({ [key]: e.target.value });
45
+ const isOwner = Boolean(
46
+ walletAddress && collection?.owner && (0, import_sdk.normalizeAddress)("STARKNET", walletAddress) === (0, import_sdk.normalizeAddress)("STARKNET", collection.owner)
47
+ );
48
+ const save = async () => {
49
+ setSaving(true);
50
+ setSaveError(null);
51
+ try {
52
+ await ensureSignedIn?.();
53
+ await getClient().api.collections.updateProfile(contract, (0, import_collection_settings_form.toProfileInput)(form));
54
+ await mutate();
55
+ setSaveStatus("saved");
56
+ setTimeout(() => setSaveStatus("idle"), 3e3);
57
+ } catch (e) {
58
+ setSaveStatus("error");
59
+ setSaveError((0, import_describe_error.describeError)(e).message);
60
+ } finally {
61
+ setSaving(false);
62
+ }
63
+ };
64
+ return {
65
+ collection,
66
+ profile,
67
+ collectionLoading,
68
+ isLoading: collectionLoading || profileLoading,
69
+ isOwner,
70
+ form,
71
+ set,
72
+ update,
73
+ saving,
74
+ saveStatus,
75
+ saveError,
76
+ save
77
+ };
78
+ }
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ useCollectionSettings
82
+ });
83
+ //# sourceMappingURL=use-collection-settings.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/use-collection-settings.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useState, type ChangeEvent } from \"react\";\nimport { normalizeAddress } from \"@medialane/sdk\";\nimport { useMedialaneApp } from \"../components/medialane-app.js\";\nimport { describeError } from \"./describe-error.js\";\nimport { useCollection } from \"./use-collections.js\";\nimport { useCollectionProfile } from \"./use-profiles.js\";\nimport { EMPTY_SETTINGS_FORM, applyProfile, toProfileInput, type CollectionSettingsForm } from \"./collection-settings-form.js\";\n\ntype SaveStatus = \"idle\" | \"saved\" | \"error\";\n\nexport function useCollectionSettings(contract: string) {\n const { walletAddress, getClient, ensureSignedIn } = useMedialaneApp();\n const { collection, isLoading: collectionLoading } = useCollection(contract);\n const { profile, isLoading: profileLoading, mutate } = useCollectionProfile(contract);\n\n const [form, setForm] = useState<CollectionSettingsForm>(EMPTY_SETTINGS_FORM);\n const [saving, setSaving] = useState(false);\n const [saveStatus, setSaveStatus] = useState<SaveStatus>(\"idle\");\n const [saveError, setSaveError] = useState<string | null>(null);\n\n useEffect(() => {\n if (profile) setForm((f) => applyProfile(f, profile));\n }, [profile]);\n\n const update = useCallback((patch: Partial<CollectionSettingsForm>) => setForm((f) => ({ ...f, ...patch })), []);\n\n const set = (key: keyof CollectionSettingsForm) => (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>\n update({ [key]: e.target.value });\n\n const isOwner = Boolean(\n walletAddress &&\n collection?.owner &&\n normalizeAddress(\"STARKNET\", walletAddress) === normalizeAddress(\"STARKNET\", collection.owner),\n );\n\n const save = async () => {\n setSaving(true);\n setSaveError(null);\n try {\n await ensureSignedIn?.();\n await getClient().api.collections.updateProfile(contract, toProfileInput(form));\n await mutate();\n setSaveStatus(\"saved\");\n setTimeout(() => setSaveStatus(\"idle\"), 3000);\n } catch (e) {\n setSaveStatus(\"error\");\n setSaveError(describeError(e).message);\n } finally {\n setSaving(false);\n }\n };\n\n return {\n collection,\n profile,\n collectionLoading,\n isLoading: collectionLoading || profileLoading,\n isOwner,\n form,\n set,\n update,\n saving,\n saveStatus,\n saveError,\n save,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAmE;AACnE,iBAAiC;AACjC,2BAAgC;AAChC,4BAA8B;AAC9B,6BAA8B;AAC9B,0BAAqC;AACrC,sCAA+F;AAIxF,SAAS,sBAAsB,UAAkB;AACtD,QAAM,EAAE,eAAe,WAAW,eAAe,QAAI,sCAAgB;AACrE,QAAM,EAAE,YAAY,WAAW,kBAAkB,QAAI,sCAAc,QAAQ;AAC3E,QAAM,EAAE,SAAS,WAAW,gBAAgB,OAAO,QAAI,0CAAqB,QAAQ;AAEpF,QAAM,CAAC,MAAM,OAAO,QAAI,uBAAiC,mDAAmB;AAC5E,QAAM,CAAC,QAAQ,SAAS,QAAI,uBAAS,KAAK;AAC1C,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAqB,MAAM;AAC/D,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAwB,IAAI;AAE9D,8BAAU,MAAM;AACd,QAAI,QAAS,SAAQ,CAAC,UAAM,8CAAa,GAAG,OAAO,CAAC;AAAA,EACtD,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,aAAS,0BAAY,CAAC,UAA2C,QAAQ,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;AAE/G,QAAM,MAAM,CAAC,QAAsC,CAAC,MAClD,OAAO,EAAE,CAAC,GAAG,GAAG,EAAE,OAAO,MAAM,CAAC;AAElC,QAAM,UAAU;AAAA,IACd,iBACE,YAAY,aACZ,6BAAiB,YAAY,aAAa,UAAM,6BAAiB,YAAY,WAAW,KAAK;AAAA,EACjG;AAEA,QAAM,OAAO,YAAY;AACvB,cAAU,IAAI;AACd,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,iBAAiB;AACvB,YAAM,UAAU,EAAE,IAAI,YAAY,cAAc,cAAU,gDAAe,IAAI,CAAC;AAC9E,YAAM,OAAO;AACb,oBAAc,OAAO;AACrB,iBAAW,MAAM,cAAc,MAAM,GAAG,GAAI;AAAA,IAC9C,SAAS,GAAG;AACV,oBAAc,OAAO;AACrB,uBAAa,qCAAc,CAAC,EAAE,OAAO;AAAA,IACvC,UAAE;AACA,gBAAU,KAAK;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,qBAAqB;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,58 @@
1
+ import * as _medialane_sdk from '@medialane/sdk';
2
+ import * as zod from 'zod';
3
+ import { ChangeEvent } from 'react';
4
+ import { CollectionSettingsForm } from './collection-settings-form.cjs';
5
+
6
+ type SaveStatus = "idle" | "saved" | "error";
7
+ declare function useCollectionSettings(contract: string): {
8
+ collection: {
9
+ symbol: string | null;
10
+ chain: string;
11
+ owner: string | null;
12
+ collectionId: string | null;
13
+ name: string | null;
14
+ description: string | null;
15
+ image: string | null;
16
+ service: string | null;
17
+ contractAddress: string;
18
+ id: string;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
22
+ standard: "ERC721" | "ERC1155";
23
+ attributes: zod.objectOutputType<{
24
+ trait_type: zod.ZodString;
25
+ value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
26
+ display_type: zod.ZodOptional<zod.ZodString>;
27
+ }, zod.ZodTypeAny, "passthrough">[] | null;
28
+ holderCount: number;
29
+ startBlock: string;
30
+ isFeatured: boolean;
31
+ isHidden: boolean;
32
+ claimedBy: string | null;
33
+ floorPrice: string | null;
34
+ totalVolume: string | null;
35
+ totalSupply: number;
36
+ profile: {
37
+ description: string | null;
38
+ image: string | null;
39
+ displayName: string | null;
40
+ gatedContentTitle: string | null;
41
+ hasGatedContent: boolean;
42
+ slug: string | null;
43
+ } | null;
44
+ } | null;
45
+ profile: _medialane_sdk.ApiCollectionProfile | null;
46
+ collectionLoading: boolean;
47
+ isLoading: boolean;
48
+ isOwner: boolean;
49
+ form: CollectionSettingsForm;
50
+ set: (key: keyof CollectionSettingsForm) => (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
51
+ update: (patch: Partial<CollectionSettingsForm>) => void;
52
+ saving: boolean;
53
+ saveStatus: SaveStatus;
54
+ saveError: string | null;
55
+ save: () => Promise<void>;
56
+ };
57
+
58
+ export { useCollectionSettings };
@@ -0,0 +1,58 @@
1
+ import * as _medialane_sdk from '@medialane/sdk';
2
+ import * as zod from 'zod';
3
+ import { ChangeEvent } from 'react';
4
+ import { CollectionSettingsForm } from './collection-settings-form.js';
5
+
6
+ type SaveStatus = "idle" | "saved" | "error";
7
+ declare function useCollectionSettings(contract: string): {
8
+ collection: {
9
+ symbol: string | null;
10
+ chain: string;
11
+ owner: string | null;
12
+ collectionId: string | null;
13
+ name: string | null;
14
+ description: string | null;
15
+ image: string | null;
16
+ service: string | null;
17
+ contractAddress: string;
18
+ id: string;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
22
+ standard: "ERC721" | "ERC1155";
23
+ attributes: zod.objectOutputType<{
24
+ trait_type: zod.ZodString;
25
+ value: zod.ZodUnion<[zod.ZodString, zod.ZodNumber, zod.ZodBoolean]>;
26
+ display_type: zod.ZodOptional<zod.ZodString>;
27
+ }, zod.ZodTypeAny, "passthrough">[] | null;
28
+ holderCount: number;
29
+ startBlock: string;
30
+ isFeatured: boolean;
31
+ isHidden: boolean;
32
+ claimedBy: string | null;
33
+ floorPrice: string | null;
34
+ totalVolume: string | null;
35
+ totalSupply: number;
36
+ profile: {
37
+ description: string | null;
38
+ image: string | null;
39
+ displayName: string | null;
40
+ gatedContentTitle: string | null;
41
+ hasGatedContent: boolean;
42
+ slug: string | null;
43
+ } | null;
44
+ } | null;
45
+ profile: _medialane_sdk.ApiCollectionProfile | null;
46
+ collectionLoading: boolean;
47
+ isLoading: boolean;
48
+ isOwner: boolean;
49
+ form: CollectionSettingsForm;
50
+ set: (key: keyof CollectionSettingsForm) => (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
51
+ update: (patch: Partial<CollectionSettingsForm>) => void;
52
+ saving: boolean;
53
+ saveStatus: SaveStatus;
54
+ saveError: string | null;
55
+ save: () => Promise<void>;
56
+ };
57
+
58
+ export { useCollectionSettings };
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useState } from "react";
3
+ import { normalizeAddress } from "@medialane/sdk";
4
+ import { useMedialaneApp } from "../components/medialane-app.js";
5
+ import { describeError } from "./describe-error.js";
6
+ import { useCollection } from "./use-collections.js";
7
+ import { useCollectionProfile } from "./use-profiles.js";
8
+ import { EMPTY_SETTINGS_FORM, applyProfile, toProfileInput } from "./collection-settings-form.js";
9
+ function useCollectionSettings(contract) {
10
+ const { walletAddress, getClient, ensureSignedIn } = useMedialaneApp();
11
+ const { collection, isLoading: collectionLoading } = useCollection(contract);
12
+ const { profile, isLoading: profileLoading, mutate } = useCollectionProfile(contract);
13
+ const [form, setForm] = useState(EMPTY_SETTINGS_FORM);
14
+ const [saving, setSaving] = useState(false);
15
+ const [saveStatus, setSaveStatus] = useState("idle");
16
+ const [saveError, setSaveError] = useState(null);
17
+ useEffect(() => {
18
+ if (profile) setForm((f) => applyProfile(f, profile));
19
+ }, [profile]);
20
+ const update = useCallback((patch) => setForm((f) => ({ ...f, ...patch })), []);
21
+ const set = (key) => (e) => update({ [key]: e.target.value });
22
+ const isOwner = Boolean(
23
+ walletAddress && collection?.owner && normalizeAddress("STARKNET", walletAddress) === normalizeAddress("STARKNET", collection.owner)
24
+ );
25
+ const save = async () => {
26
+ setSaving(true);
27
+ setSaveError(null);
28
+ try {
29
+ await ensureSignedIn?.();
30
+ await getClient().api.collections.updateProfile(contract, toProfileInput(form));
31
+ await mutate();
32
+ setSaveStatus("saved");
33
+ setTimeout(() => setSaveStatus("idle"), 3e3);
34
+ } catch (e) {
35
+ setSaveStatus("error");
36
+ setSaveError(describeError(e).message);
37
+ } finally {
38
+ setSaving(false);
39
+ }
40
+ };
41
+ return {
42
+ collection,
43
+ profile,
44
+ collectionLoading,
45
+ isLoading: collectionLoading || profileLoading,
46
+ isOwner,
47
+ form,
48
+ set,
49
+ update,
50
+ saving,
51
+ saveStatus,
52
+ saveError,
53
+ save
54
+ };
55
+ }
56
+ export {
57
+ useCollectionSettings
58
+ };
59
+ //# sourceMappingURL=use-collection-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/use-collection-settings.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useEffect, useState, type ChangeEvent } from \"react\";\nimport { normalizeAddress } from \"@medialane/sdk\";\nimport { useMedialaneApp } from \"../components/medialane-app.js\";\nimport { describeError } from \"./describe-error.js\";\nimport { useCollection } from \"./use-collections.js\";\nimport { useCollectionProfile } from \"./use-profiles.js\";\nimport { EMPTY_SETTINGS_FORM, applyProfile, toProfileInput, type CollectionSettingsForm } from \"./collection-settings-form.js\";\n\ntype SaveStatus = \"idle\" | \"saved\" | \"error\";\n\nexport function useCollectionSettings(contract: string) {\n const { walletAddress, getClient, ensureSignedIn } = useMedialaneApp();\n const { collection, isLoading: collectionLoading } = useCollection(contract);\n const { profile, isLoading: profileLoading, mutate } = useCollectionProfile(contract);\n\n const [form, setForm] = useState<CollectionSettingsForm>(EMPTY_SETTINGS_FORM);\n const [saving, setSaving] = useState(false);\n const [saveStatus, setSaveStatus] = useState<SaveStatus>(\"idle\");\n const [saveError, setSaveError] = useState<string | null>(null);\n\n useEffect(() => {\n if (profile) setForm((f) => applyProfile(f, profile));\n }, [profile]);\n\n const update = useCallback((patch: Partial<CollectionSettingsForm>) => setForm((f) => ({ ...f, ...patch })), []);\n\n const set = (key: keyof CollectionSettingsForm) => (e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>\n update({ [key]: e.target.value });\n\n const isOwner = Boolean(\n walletAddress &&\n collection?.owner &&\n normalizeAddress(\"STARKNET\", walletAddress) === normalizeAddress(\"STARKNET\", collection.owner),\n );\n\n const save = async () => {\n setSaving(true);\n setSaveError(null);\n try {\n await ensureSignedIn?.();\n await getClient().api.collections.updateProfile(contract, toProfileInput(form));\n await mutate();\n setSaveStatus(\"saved\");\n setTimeout(() => setSaveStatus(\"idle\"), 3000);\n } catch (e) {\n setSaveStatus(\"error\");\n setSaveError(describeError(e).message);\n } finally {\n setSaving(false);\n }\n };\n\n return {\n collection,\n profile,\n collectionLoading,\n isLoading: collectionLoading || profileLoading,\n isOwner,\n form,\n set,\n update,\n saving,\n saveStatus,\n saveError,\n save,\n };\n}\n"],"mappings":";AAEA,SAAS,aAAa,WAAW,gBAAkC;AACnE,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,qBAAqB,cAAc,sBAAmD;AAIxF,SAAS,sBAAsB,UAAkB;AACtD,QAAM,EAAE,eAAe,WAAW,eAAe,IAAI,gBAAgB;AACrE,QAAM,EAAE,YAAY,WAAW,kBAAkB,IAAI,cAAc,QAAQ;AAC3E,QAAM,EAAE,SAAS,WAAW,gBAAgB,OAAO,IAAI,qBAAqB,QAAQ;AAEpF,QAAM,CAAC,MAAM,OAAO,IAAI,SAAiC,mBAAmB;AAC5E,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,KAAK;AAC1C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAqB,MAAM;AAC/D,QAAM,CAAC,WAAW,YAAY,IAAI,SAAwB,IAAI;AAE9D,YAAU,MAAM;AACd,QAAI,QAAS,SAAQ,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAAA,EACtD,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,SAAS,YAAY,CAAC,UAA2C,QAAQ,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;AAE/G,QAAM,MAAM,CAAC,QAAsC,CAAC,MAClD,OAAO,EAAE,CAAC,GAAG,GAAG,EAAE,OAAO,MAAM,CAAC;AAElC,QAAM,UAAU;AAAA,IACd,iBACE,YAAY,SACZ,iBAAiB,YAAY,aAAa,MAAM,iBAAiB,YAAY,WAAW,KAAK;AAAA,EACjG;AAEA,QAAM,OAAO,YAAY;AACvB,cAAU,IAAI;AACd,iBAAa,IAAI;AACjB,QAAI;AACF,YAAM,iBAAiB;AACvB,YAAM,UAAU,EAAE,IAAI,YAAY,cAAc,UAAU,eAAe,IAAI,CAAC;AAC9E,YAAM,OAAO;AACb,oBAAc,OAAO;AACrB,iBAAW,MAAM,cAAc,MAAM,GAAG,GAAI;AAAA,IAC9C,SAAS,GAAG;AACV,oBAAc,OAAO;AACrB,mBAAa,cAAc,CAAC,EAAE,OAAO;AAAA,IACvC,UAAE;AACA,gBAAU,KAAK;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,qBAAqB;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medialane/ui",
3
- "version": "0.286.0",
3
+ "version": "0.287.0",
4
4
  "description": "Shared UI components for Medialane apps",
5
5
  "type": "module",
6
6
  "sideEffects": false,