@medialane/ui 0.130.1 → 0.132.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/drop-item-list.cjs +118 -0
- package/dist/components/drop-item-list.cjs.map +1 -0
- package/dist/components/drop-item-list.d.cts +19 -0
- package/dist/components/drop-item-list.d.ts +19 -0
- package/dist/components/drop-item-list.js +84 -0
- package/dist/components/drop-item-list.js.map +1 -0
- package/dist/components/sheet.d.cts +1 -1
- package/dist/components/sheet.d.ts +1 -1
- package/dist/data/drop-create-schema.cjs +85 -0
- package/dist/data/drop-create-schema.cjs.map +1 -0
- package/dist/data/drop-create-schema.d.cts +111 -0
- package/dist/data/drop-create-schema.d.ts +111 -0
- package/dist/data/drop-create-schema.js +51 -0
- package/dist/data/drop-create-schema.js.map +1 -0
- package/dist/index.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/launchpad-defaults.cjs +85 -0
- package/dist/utils/launchpad-defaults.cjs.map +1 -0
- package/dist/utils/launchpad-defaults.d.cts +13 -0
- package/dist/utils/launchpad-defaults.d.ts +13 -0
- package/dist/utils/launchpad-defaults.js +59 -0
- package/dist/utils/launchpad-defaults.js.map +1 -0
- package/dist/utils/use-usd-prices.cjs +65 -0
- package/dist/utils/use-usd-prices.cjs.map +1 -0
- package/dist/utils/use-usd-prices.d.cts +11 -0
- package/dist/utils/use-usd-prices.d.ts +11 -0
- package/dist/utils/use-usd-prices.js +30 -0
- package/dist/utils/use-usd-prices.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,85 @@
|
|
|
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 launchpad_defaults_exports = {};
|
|
21
|
+
__export(launchpad_defaults_exports, {
|
|
22
|
+
getDefaultClaimWindow: () => getDefaultClaimWindow,
|
|
23
|
+
getDefaultDropSchedule: () => getDefaultDropSchedule,
|
|
24
|
+
suggestLaunchpadSymbol: () => suggestLaunchpadSymbol
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(launchpad_defaults_exports);
|
|
27
|
+
function formatDateForInput(date) {
|
|
28
|
+
const year = date.getFullYear();
|
|
29
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
30
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
31
|
+
return `${year}-${month}-${day}`;
|
|
32
|
+
}
|
|
33
|
+
function formatTimeForInput(date) {
|
|
34
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
35
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
36
|
+
return `${hours}:${minutes}`;
|
|
37
|
+
}
|
|
38
|
+
function roundUpToQuarterHour(date) {
|
|
39
|
+
const rounded = new Date(date);
|
|
40
|
+
rounded.setSeconds(0, 0);
|
|
41
|
+
const minutes = rounded.getMinutes();
|
|
42
|
+
const delta = (15 - minutes % 15) % 15 || 15;
|
|
43
|
+
rounded.setMinutes(minutes + delta);
|
|
44
|
+
return rounded;
|
|
45
|
+
}
|
|
46
|
+
function getDefaultDropSchedule(now = /* @__PURE__ */ new Date()) {
|
|
47
|
+
const start = roundUpToQuarterHour(now);
|
|
48
|
+
const end = new Date(start);
|
|
49
|
+
end.setDate(end.getDate() + 7);
|
|
50
|
+
end.setHours(23, 59, 0, 0);
|
|
51
|
+
return {
|
|
52
|
+
startDate: formatDateForInput(start),
|
|
53
|
+
startTime: formatTimeForInput(start),
|
|
54
|
+
endDate: formatDateForInput(end),
|
|
55
|
+
endTime: formatTimeForInput(end)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function getDefaultClaimWindow(daysFromNow = 30, now = /* @__PURE__ */ new Date()) {
|
|
59
|
+
const end = new Date(now);
|
|
60
|
+
end.setDate(end.getDate() + daysFromNow);
|
|
61
|
+
end.setHours(23, 59, 0, 0);
|
|
62
|
+
return {
|
|
63
|
+
claimEndDate: formatDateForInput(end),
|
|
64
|
+
claimEndTime: formatTimeForInput(end)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function suggestLaunchpadSymbol(name, maxLength = 10) {
|
|
68
|
+
const cleaned = name.toUpperCase().replace(/[^A-Z0-9 ]+/g, " ").trim();
|
|
69
|
+
if (!cleaned) return "";
|
|
70
|
+
const words = cleaned.split(/\s+/).filter(Boolean);
|
|
71
|
+
const initials = words.filter((word) => /[A-Z0-9]/.test(word)).map((word) => word[0]).join("");
|
|
72
|
+
const digits = words.join("").replace(/[^0-9]/g, "");
|
|
73
|
+
let candidate = `${initials}${digits}`.slice(0, maxLength);
|
|
74
|
+
if (candidate.length < 3) {
|
|
75
|
+
candidate = words.join("").replace(/\s+/g, "").slice(0, maxLength);
|
|
76
|
+
}
|
|
77
|
+
return candidate.slice(0, maxLength);
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
getDefaultClaimWindow,
|
|
82
|
+
getDefaultDropSchedule,
|
|
83
|
+
suggestLaunchpadSymbol
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=launchpad-defaults.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/launchpad-defaults.ts"],"sourcesContent":["\"use client\";\n\nfunction formatDateForInput(date: Date): string {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, \"0\");\n const day = String(date.getDate()).padStart(2, \"0\");\n return `${year}-${month}-${day}`;\n}\n\nfunction formatTimeForInput(date: Date): string {\n const hours = String(date.getHours()).padStart(2, \"0\");\n const minutes = String(date.getMinutes()).padStart(2, \"0\");\n return `${hours}:${minutes}`;\n}\n\nfunction roundUpToQuarterHour(date: Date): Date {\n const rounded = new Date(date);\n rounded.setSeconds(0, 0);\n const minutes = rounded.getMinutes();\n const delta = (15 - (minutes % 15)) % 15 || 15;\n rounded.setMinutes(minutes + delta);\n return rounded;\n}\n\nexport function getDefaultDropSchedule(now = new Date()) {\n const start = roundUpToQuarterHour(now);\n const end = new Date(start);\n end.setDate(end.getDate() + 7);\n end.setHours(23, 59, 0, 0);\n\n return {\n startDate: formatDateForInput(start),\n startTime: formatTimeForInput(start),\n endDate: formatDateForInput(end),\n endTime: formatTimeForInput(end),\n };\n}\n\nexport function getDefaultClaimWindow(daysFromNow = 30, now = new Date()) {\n const end = new Date(now);\n end.setDate(end.getDate() + daysFromNow);\n end.setHours(23, 59, 0, 0);\n\n return {\n claimEndDate: formatDateForInput(end),\n claimEndTime: formatTimeForInput(end),\n };\n}\n\nexport function suggestLaunchpadSymbol(name: string, maxLength = 10): string {\n const cleaned = name.toUpperCase().replace(/[^A-Z0-9 ]+/g, \" \").trim();\n if (!cleaned) return \"\";\n\n const words = cleaned.split(/\\s+/).filter(Boolean);\n const initials = words\n .filter((word) => /[A-Z0-9]/.test(word))\n .map((word) => word[0])\n .join(\"\");\n const digits = words.join(\"\").replace(/[^0-9]/g, \"\");\n\n let candidate = `${initials}${digits}`.slice(0, maxLength);\n if (candidate.length < 3) {\n candidate = words.join(\"\").replace(/\\s+/g, \"\").slice(0, maxLength);\n }\n\n return candidate.slice(0, maxLength);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,SAAS,mBAAmB,MAAoB;AAC9C,QAAM,OAAO,KAAK,YAAY;AAC9B,QAAM,QAAQ,OAAO,KAAK,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACzD,QAAM,MAAM,OAAO,KAAK,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAClD,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG;AAChC;AAEA,SAAS,mBAAmB,MAAoB;AAC9C,QAAM,QAAQ,OAAO,KAAK,SAAS,CAAC,EAAE,SAAS,GAAG,GAAG;AACrD,QAAM,UAAU,OAAO,KAAK,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG;AACzD,SAAO,GAAG,KAAK,IAAI,OAAO;AAC5B;AAEA,SAAS,qBAAqB,MAAkB;AAC9C,QAAM,UAAU,IAAI,KAAK,IAAI;AAC7B,UAAQ,WAAW,GAAG,CAAC;AACvB,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,SAAS,KAAM,UAAU,MAAO,MAAM;AAC5C,UAAQ,WAAW,UAAU,KAAK;AAClC,SAAO;AACT;AAEO,SAAS,uBAAuB,MAAM,oBAAI,KAAK,GAAG;AACvD,QAAM,QAAQ,qBAAqB,GAAG;AACtC,QAAM,MAAM,IAAI,KAAK,KAAK;AAC1B,MAAI,QAAQ,IAAI,QAAQ,IAAI,CAAC;AAC7B,MAAI,SAAS,IAAI,IAAI,GAAG,CAAC;AAEzB,SAAO;AAAA,IACL,WAAW,mBAAmB,KAAK;AAAA,IACnC,WAAW,mBAAmB,KAAK;AAAA,IACnC,SAAS,mBAAmB,GAAG;AAAA,IAC/B,SAAS,mBAAmB,GAAG;AAAA,EACjC;AACF;AAEO,SAAS,sBAAsB,cAAc,IAAI,MAAM,oBAAI,KAAK,GAAG;AACxE,QAAM,MAAM,IAAI,KAAK,GAAG;AACxB,MAAI,QAAQ,IAAI,QAAQ,IAAI,WAAW;AACvC,MAAI,SAAS,IAAI,IAAI,GAAG,CAAC;AAEzB,SAAO;AAAA,IACL,cAAc,mBAAmB,GAAG;AAAA,IACpC,cAAc,mBAAmB,GAAG;AAAA,EACtC;AACF;AAEO,SAAS,uBAAuB,MAAc,YAAY,IAAY;AAC3E,QAAM,UAAU,KAAK,YAAY,EAAE,QAAQ,gBAAgB,GAAG,EAAE,KAAK;AACrE,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,QAAQ,QAAQ,MAAM,KAAK,EAAE,OAAO,OAAO;AACjD,QAAM,WAAW,MACd,OAAO,CAAC,SAAS,WAAW,KAAK,IAAI,CAAC,EACtC,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,EACrB,KAAK,EAAE;AACV,QAAM,SAAS,MAAM,KAAK,EAAE,EAAE,QAAQ,WAAW,EAAE;AAEnD,MAAI,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS;AACzD,MAAI,UAAU,SAAS,GAAG;AACxB,gBAAY,MAAM,KAAK,EAAE,EAAE,QAAQ,QAAQ,EAAE,EAAE,MAAM,GAAG,SAAS;AAAA,EACnE;AAEA,SAAO,UAAU,MAAM,GAAG,SAAS;AACrC;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare function getDefaultDropSchedule(now?: Date): {
|
|
2
|
+
startDate: string;
|
|
3
|
+
startTime: string;
|
|
4
|
+
endDate: string;
|
|
5
|
+
endTime: string;
|
|
6
|
+
};
|
|
7
|
+
declare function getDefaultClaimWindow(daysFromNow?: number, now?: Date): {
|
|
8
|
+
claimEndDate: string;
|
|
9
|
+
claimEndTime: string;
|
|
10
|
+
};
|
|
11
|
+
declare function suggestLaunchpadSymbol(name: string, maxLength?: number): string;
|
|
12
|
+
|
|
13
|
+
export { getDefaultClaimWindow, getDefaultDropSchedule, suggestLaunchpadSymbol };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare function getDefaultDropSchedule(now?: Date): {
|
|
2
|
+
startDate: string;
|
|
3
|
+
startTime: string;
|
|
4
|
+
endDate: string;
|
|
5
|
+
endTime: string;
|
|
6
|
+
};
|
|
7
|
+
declare function getDefaultClaimWindow(daysFromNow?: number, now?: Date): {
|
|
8
|
+
claimEndDate: string;
|
|
9
|
+
claimEndTime: string;
|
|
10
|
+
};
|
|
11
|
+
declare function suggestLaunchpadSymbol(name: string, maxLength?: number): string;
|
|
12
|
+
|
|
13
|
+
export { getDefaultClaimWindow, getDefaultDropSchedule, suggestLaunchpadSymbol };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
function formatDateForInput(date) {
|
|
3
|
+
const year = date.getFullYear();
|
|
4
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
5
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
6
|
+
return `${year}-${month}-${day}`;
|
|
7
|
+
}
|
|
8
|
+
function formatTimeForInput(date) {
|
|
9
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
10
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
11
|
+
return `${hours}:${minutes}`;
|
|
12
|
+
}
|
|
13
|
+
function roundUpToQuarterHour(date) {
|
|
14
|
+
const rounded = new Date(date);
|
|
15
|
+
rounded.setSeconds(0, 0);
|
|
16
|
+
const minutes = rounded.getMinutes();
|
|
17
|
+
const delta = (15 - minutes % 15) % 15 || 15;
|
|
18
|
+
rounded.setMinutes(minutes + delta);
|
|
19
|
+
return rounded;
|
|
20
|
+
}
|
|
21
|
+
function getDefaultDropSchedule(now = /* @__PURE__ */ new Date()) {
|
|
22
|
+
const start = roundUpToQuarterHour(now);
|
|
23
|
+
const end = new Date(start);
|
|
24
|
+
end.setDate(end.getDate() + 7);
|
|
25
|
+
end.setHours(23, 59, 0, 0);
|
|
26
|
+
return {
|
|
27
|
+
startDate: formatDateForInput(start),
|
|
28
|
+
startTime: formatTimeForInput(start),
|
|
29
|
+
endDate: formatDateForInput(end),
|
|
30
|
+
endTime: formatTimeForInput(end)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function getDefaultClaimWindow(daysFromNow = 30, now = /* @__PURE__ */ new Date()) {
|
|
34
|
+
const end = new Date(now);
|
|
35
|
+
end.setDate(end.getDate() + daysFromNow);
|
|
36
|
+
end.setHours(23, 59, 0, 0);
|
|
37
|
+
return {
|
|
38
|
+
claimEndDate: formatDateForInput(end),
|
|
39
|
+
claimEndTime: formatTimeForInput(end)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function suggestLaunchpadSymbol(name, maxLength = 10) {
|
|
43
|
+
const cleaned = name.toUpperCase().replace(/[^A-Z0-9 ]+/g, " ").trim();
|
|
44
|
+
if (!cleaned) return "";
|
|
45
|
+
const words = cleaned.split(/\s+/).filter(Boolean);
|
|
46
|
+
const initials = words.filter((word) => /[A-Z0-9]/.test(word)).map((word) => word[0]).join("");
|
|
47
|
+
const digits = words.join("").replace(/[^0-9]/g, "");
|
|
48
|
+
let candidate = `${initials}${digits}`.slice(0, maxLength);
|
|
49
|
+
if (candidate.length < 3) {
|
|
50
|
+
candidate = words.join("").replace(/\s+/g, "").slice(0, maxLength);
|
|
51
|
+
}
|
|
52
|
+
return candidate.slice(0, maxLength);
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
getDefaultClaimWindow,
|
|
56
|
+
getDefaultDropSchedule,
|
|
57
|
+
suggestLaunchpadSymbol
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=launchpad-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/launchpad-defaults.ts"],"sourcesContent":["\"use client\";\n\nfunction formatDateForInput(date: Date): string {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, \"0\");\n const day = String(date.getDate()).padStart(2, \"0\");\n return `${year}-${month}-${day}`;\n}\n\nfunction formatTimeForInput(date: Date): string {\n const hours = String(date.getHours()).padStart(2, \"0\");\n const minutes = String(date.getMinutes()).padStart(2, \"0\");\n return `${hours}:${minutes}`;\n}\n\nfunction roundUpToQuarterHour(date: Date): Date {\n const rounded = new Date(date);\n rounded.setSeconds(0, 0);\n const minutes = rounded.getMinutes();\n const delta = (15 - (minutes % 15)) % 15 || 15;\n rounded.setMinutes(minutes + delta);\n return rounded;\n}\n\nexport function getDefaultDropSchedule(now = new Date()) {\n const start = roundUpToQuarterHour(now);\n const end = new Date(start);\n end.setDate(end.getDate() + 7);\n end.setHours(23, 59, 0, 0);\n\n return {\n startDate: formatDateForInput(start),\n startTime: formatTimeForInput(start),\n endDate: formatDateForInput(end),\n endTime: formatTimeForInput(end),\n };\n}\n\nexport function getDefaultClaimWindow(daysFromNow = 30, now = new Date()) {\n const end = new Date(now);\n end.setDate(end.getDate() + daysFromNow);\n end.setHours(23, 59, 0, 0);\n\n return {\n claimEndDate: formatDateForInput(end),\n claimEndTime: formatTimeForInput(end),\n };\n}\n\nexport function suggestLaunchpadSymbol(name: string, maxLength = 10): string {\n const cleaned = name.toUpperCase().replace(/[^A-Z0-9 ]+/g, \" \").trim();\n if (!cleaned) return \"\";\n\n const words = cleaned.split(/\\s+/).filter(Boolean);\n const initials = words\n .filter((word) => /[A-Z0-9]/.test(word))\n .map((word) => word[0])\n .join(\"\");\n const digits = words.join(\"\").replace(/[^0-9]/g, \"\");\n\n let candidate = `${initials}${digits}`.slice(0, maxLength);\n if (candidate.length < 3) {\n candidate = words.join(\"\").replace(/\\s+/g, \"\").slice(0, maxLength);\n }\n\n return candidate.slice(0, maxLength);\n}\n"],"mappings":";AAEA,SAAS,mBAAmB,MAAoB;AAC9C,QAAM,OAAO,KAAK,YAAY;AAC9B,QAAM,QAAQ,OAAO,KAAK,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG;AACzD,QAAM,MAAM,OAAO,KAAK,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG;AAClD,SAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG;AAChC;AAEA,SAAS,mBAAmB,MAAoB;AAC9C,QAAM,QAAQ,OAAO,KAAK,SAAS,CAAC,EAAE,SAAS,GAAG,GAAG;AACrD,QAAM,UAAU,OAAO,KAAK,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG;AACzD,SAAO,GAAG,KAAK,IAAI,OAAO;AAC5B;AAEA,SAAS,qBAAqB,MAAkB;AAC9C,QAAM,UAAU,IAAI,KAAK,IAAI;AAC7B,UAAQ,WAAW,GAAG,CAAC;AACvB,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,SAAS,KAAM,UAAU,MAAO,MAAM;AAC5C,UAAQ,WAAW,UAAU,KAAK;AAClC,SAAO;AACT;AAEO,SAAS,uBAAuB,MAAM,oBAAI,KAAK,GAAG;AACvD,QAAM,QAAQ,qBAAqB,GAAG;AACtC,QAAM,MAAM,IAAI,KAAK,KAAK;AAC1B,MAAI,QAAQ,IAAI,QAAQ,IAAI,CAAC;AAC7B,MAAI,SAAS,IAAI,IAAI,GAAG,CAAC;AAEzB,SAAO;AAAA,IACL,WAAW,mBAAmB,KAAK;AAAA,IACnC,WAAW,mBAAmB,KAAK;AAAA,IACnC,SAAS,mBAAmB,GAAG;AAAA,IAC/B,SAAS,mBAAmB,GAAG;AAAA,EACjC;AACF;AAEO,SAAS,sBAAsB,cAAc,IAAI,MAAM,oBAAI,KAAK,GAAG;AACxE,QAAM,MAAM,IAAI,KAAK,GAAG;AACxB,MAAI,QAAQ,IAAI,QAAQ,IAAI,WAAW;AACvC,MAAI,SAAS,IAAI,IAAI,GAAG,CAAC;AAEzB,SAAO;AAAA,IACL,cAAc,mBAAmB,GAAG;AAAA,IACpC,cAAc,mBAAmB,GAAG;AAAA,EACtC;AACF;AAEO,SAAS,uBAAuB,MAAc,YAAY,IAAY;AAC3E,QAAM,UAAU,KAAK,YAAY,EAAE,QAAQ,gBAAgB,GAAG,EAAE,KAAK;AACrE,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,QAAQ,QAAQ,MAAM,KAAK,EAAE,OAAO,OAAO;AACjD,QAAM,WAAW,MACd,OAAO,CAAC,SAAS,WAAW,KAAK,IAAI,CAAC,EACtC,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,EACrB,KAAK,EAAE;AACV,QAAM,SAAS,MAAM,KAAK,EAAE,EAAE,QAAQ,WAAW,EAAE;AAEnD,MAAI,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS;AACzD,MAAI,UAAU,SAAS,GAAG;AACxB,gBAAY,MAAM,KAAK,EAAE,EAAE,QAAQ,QAAQ,EAAE,EAAE,MAAM,GAAG,SAAS;AAAA,EACnE;AAEA,SAAO,UAAU,MAAM,GAAG,SAAS;AACrC;","names":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 use_usd_prices_exports = {};
|
|
31
|
+
__export(use_usd_prices_exports, {
|
|
32
|
+
usdPriceFor: () => usdPriceFor,
|
|
33
|
+
useUsdPrices: () => useUsdPrices
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(use_usd_prices_exports);
|
|
36
|
+
var import_swr = __toESM(require("swr"), 1);
|
|
37
|
+
function usdPriceFor(prices, symbol) {
|
|
38
|
+
return prices?.[symbol];
|
|
39
|
+
}
|
|
40
|
+
const REFRESH_MS = 6e4;
|
|
41
|
+
const PRICES_KEY = "usd-prices";
|
|
42
|
+
const PRICES_URL = "/api/proxy/v1/prices";
|
|
43
|
+
async function fetchUsdPrices() {
|
|
44
|
+
const res = await fetch(PRICES_URL);
|
|
45
|
+
const body = await res.json();
|
|
46
|
+
return body.data?.usd ?? null;
|
|
47
|
+
}
|
|
48
|
+
function useUsdPrices() {
|
|
49
|
+
const { data } = (0, import_swr.default)(PRICES_KEY, fetchUsdPrices, {
|
|
50
|
+
refreshInterval: REFRESH_MS,
|
|
51
|
+
dedupingInterval: REFRESH_MS,
|
|
52
|
+
revalidateOnFocus: false,
|
|
53
|
+
revalidateOnReconnect: true,
|
|
54
|
+
keepPreviousData: true,
|
|
55
|
+
onError: () => {
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return data ?? null;
|
|
59
|
+
}
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
usdPriceFor,
|
|
63
|
+
useUsdPrices
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=use-usd-prices.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-usd-prices.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\n\nexport type UsdPrices = Partial<Record<\"STRK\" | \"ETH\" | \"USDC\" | \"USDT\" | \"WBTC\", number>>;\n\n/** Looks up a USD price by an arbitrary token symbol (not just the pinned\n * set UsdPrices is keyed on) — a coin/memecoin symbol simply has no entry. */\nexport function usdPriceFor(prices: UsdPrices | null, symbol: string): number | undefined {\n return (prices as Record<string, number | undefined> | null)?.[symbol];\n}\n\nconst REFRESH_MS = 60_000;\nconst PRICES_KEY = \"usd-prices\";\nconst PRICES_URL = \"/api/proxy/v1/prices\";\n\nasync function fetchUsdPrices(): Promise<UsdPrices | null> {\n const res = await fetch(PRICES_URL);\n const body = (await res.json()) as { data?: { usd?: UsdPrices } };\n return body.data?.usd ?? null;\n}\n\n/**\n * Shared across every component that calls it: SWR keys the request, so a page\n * mounting twenty price-aware components issues one request, not twenty.\n */\nexport function useUsdPrices(): UsdPrices | null {\n const { data } = useSWR(PRICES_KEY, fetchUsdPrices, {\n refreshInterval: REFRESH_MS,\n dedupingInterval: REFRESH_MS,\n revalidateOnFocus: false,\n revalidateOnReconnect: true,\n keepPreviousData: true,\n onError: () => {},\n });\n return data ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAMZ,SAAS,YAAY,QAA0B,QAAoC;AACxF,SAAQ,SAAuD,MAAM;AACvE;AAEA,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,eAAe,iBAA4C;AACzD,QAAM,MAAM,MAAM,MAAM,UAAU;AAClC,QAAM,OAAQ,MAAM,IAAI,KAAK;AAC7B,SAAO,KAAK,MAAM,OAAO;AAC3B;AAMO,SAAS,eAAiC;AAC/C,QAAM,EAAE,KAAK,QAAI,WAAAA,SAAO,YAAY,gBAAgB;AAAA,IAClD,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,SAAS,MAAM;AAAA,IAAC;AAAA,EAClB,CAAC;AACD,SAAO,QAAQ;AACjB;","names":["useSWR"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type UsdPrices = Partial<Record<"STRK" | "ETH" | "USDC" | "USDT" | "WBTC", number>>;
|
|
2
|
+
/** Looks up a USD price by an arbitrary token symbol (not just the pinned
|
|
3
|
+
* set UsdPrices is keyed on) — a coin/memecoin symbol simply has no entry. */
|
|
4
|
+
declare function usdPriceFor(prices: UsdPrices | null, symbol: string): number | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Shared across every component that calls it: SWR keys the request, so a page
|
|
7
|
+
* mounting twenty price-aware components issues one request, not twenty.
|
|
8
|
+
*/
|
|
9
|
+
declare function useUsdPrices(): UsdPrices | null;
|
|
10
|
+
|
|
11
|
+
export { type UsdPrices, usdPriceFor, useUsdPrices };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type UsdPrices = Partial<Record<"STRK" | "ETH" | "USDC" | "USDT" | "WBTC", number>>;
|
|
2
|
+
/** Looks up a USD price by an arbitrary token symbol (not just the pinned
|
|
3
|
+
* set UsdPrices is keyed on) — a coin/memecoin symbol simply has no entry. */
|
|
4
|
+
declare function usdPriceFor(prices: UsdPrices | null, symbol: string): number | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Shared across every component that calls it: SWR keys the request, so a page
|
|
7
|
+
* mounting twenty price-aware components issues one request, not twenty.
|
|
8
|
+
*/
|
|
9
|
+
declare function useUsdPrices(): UsdPrices | null;
|
|
10
|
+
|
|
11
|
+
export { type UsdPrices, usdPriceFor, useUsdPrices };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
function usdPriceFor(prices, symbol) {
|
|
4
|
+
return prices?.[symbol];
|
|
5
|
+
}
|
|
6
|
+
const REFRESH_MS = 6e4;
|
|
7
|
+
const PRICES_KEY = "usd-prices";
|
|
8
|
+
const PRICES_URL = "/api/proxy/v1/prices";
|
|
9
|
+
async function fetchUsdPrices() {
|
|
10
|
+
const res = await fetch(PRICES_URL);
|
|
11
|
+
const body = await res.json();
|
|
12
|
+
return body.data?.usd ?? null;
|
|
13
|
+
}
|
|
14
|
+
function useUsdPrices() {
|
|
15
|
+
const { data } = useSWR(PRICES_KEY, fetchUsdPrices, {
|
|
16
|
+
refreshInterval: REFRESH_MS,
|
|
17
|
+
dedupingInterval: REFRESH_MS,
|
|
18
|
+
revalidateOnFocus: false,
|
|
19
|
+
revalidateOnReconnect: true,
|
|
20
|
+
keepPreviousData: true,
|
|
21
|
+
onError: () => {
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return data ?? null;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
usdPriceFor,
|
|
28
|
+
useUsdPrices
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=use-usd-prices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-usd-prices.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\n\nexport type UsdPrices = Partial<Record<\"STRK\" | \"ETH\" | \"USDC\" | \"USDT\" | \"WBTC\", number>>;\n\n/** Looks up a USD price by an arbitrary token symbol (not just the pinned\n * set UsdPrices is keyed on) — a coin/memecoin symbol simply has no entry. */\nexport function usdPriceFor(prices: UsdPrices | null, symbol: string): number | undefined {\n return (prices as Record<string, number | undefined> | null)?.[symbol];\n}\n\nconst REFRESH_MS = 60_000;\nconst PRICES_KEY = \"usd-prices\";\nconst PRICES_URL = \"/api/proxy/v1/prices\";\n\nasync function fetchUsdPrices(): Promise<UsdPrices | null> {\n const res = await fetch(PRICES_URL);\n const body = (await res.json()) as { data?: { usd?: UsdPrices } };\n return body.data?.usd ?? null;\n}\n\n/**\n * Shared across every component that calls it: SWR keys the request, so a page\n * mounting twenty price-aware components issues one request, not twenty.\n */\nexport function useUsdPrices(): UsdPrices | null {\n const { data } = useSWR(PRICES_KEY, fetchUsdPrices, {\n refreshInterval: REFRESH_MS,\n dedupingInterval: REFRESH_MS,\n revalidateOnFocus: false,\n revalidateOnReconnect: true,\n keepPreviousData: true,\n onError: () => {},\n });\n return data ?? null;\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAMZ,SAAS,YAAY,QAA0B,QAAoC;AACxF,SAAQ,SAAuD,MAAM;AACvE;AAEA,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,eAAe,iBAA4C;AACzD,QAAM,MAAM,MAAM,MAAM,UAAU;AAClC,QAAM,OAAQ,MAAM,IAAI,KAAK;AAC7B,SAAO,KAAK,MAAM,OAAO;AAC3B;AAMO,SAAS,eAAiC;AAC/C,QAAM,EAAE,KAAK,IAAI,OAAO,YAAY,gBAAgB;AAAA,IAClD,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,SAAS,MAAM;AAAA,IAAC;AAAA,EAClB,CAAC;AACD,SAAO,QAAQ;AACjB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medialane/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.132.0",
|
|
4
4
|
"description": "Shared UI components for Medialane apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -75,7 +75,8 @@
|
|
|
75
75
|
"recharts": ">=2.0.0",
|
|
76
76
|
"sonner": ">=1.0.0",
|
|
77
77
|
"swr": ">=2.0.0",
|
|
78
|
-
"tailwind-merge": ">=2.0.0"
|
|
78
|
+
"tailwind-merge": ">=2.0.0",
|
|
79
|
+
"zod": "^3.25.0"
|
|
79
80
|
},
|
|
80
81
|
"devDependencies": {
|
|
81
82
|
"@medialane/sdk": "0.85.5",
|
|
@@ -111,6 +112,7 @@
|
|
|
111
112
|
"tailwindcss": "^3.0.0",
|
|
112
113
|
"tsup": "^8.0.0",
|
|
113
114
|
"typescript": "^5.6.0",
|
|
114
|
-
"vite": "^8.2.1"
|
|
115
|
+
"vite": "^8.2.1",
|
|
116
|
+
"zod": "^3.25.76"
|
|
115
117
|
}
|
|
116
118
|
}
|