@medialane/ui 0.341.0 → 0.343.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/account/input-otp.d.cts +2 -2
- package/dist/components/account/input-otp.d.ts +2 -2
- package/dist/components/activities-feed.cjs +0 -47
- package/dist/components/activities-feed.cjs.map +1 -1
- package/dist/components/activities-feed.js +1 -38
- package/dist/components/activities-feed.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 +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/fast-mint/fast-mint.d.cts +2 -2
- package/dist/components/fast-mint/fast-mint.d.ts +2 -2
- package/dist/components/launchpad/edition-mint-schema.d.cts +4 -4
- package/dist/components/launchpad/edition-mint-schema.d.ts +4 -4
- package/dist/components/medialane-app.cjs.map +1 -1
- package/dist/components/medialane-app.d.cts +1 -0
- package/dist/components/medialane-app.d.ts +1 -0
- package/dist/components/medialane-app.js.map +1 -1
- package/dist/index.cjs +8 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +6 -20
- package/dist/index.js.map +1 -1
- package/dist/utils/format-activity.cjs +2 -50
- package/dist/utils/format-activity.cjs.map +1 -1
- package/dist/utils/format-activity.d.cts +2 -5
- package/dist/utils/format-activity.d.ts +2 -5
- package/dist/utils/format-activity.js +1 -46
- package/dist/utils/format-activity.js.map +1 -1
- package/dist/utils/media-wallet/use-erc20-balance.d.cts +1 -1
- package/dist/utils/media-wallet/use-erc20-balance.d.ts +1 -1
- package/dist/utils/use-activities.cjs +2 -2
- package/dist/utils/use-activities.cjs.map +1 -1
- package/dist/utils/use-activities.js +2 -2
- package/dist/utils/use-activities.js.map +1 -1
- package/dist/utils/use-coin-price.cjs +1 -2
- package/dist/utils/use-coin-price.cjs.map +1 -1
- package/dist/utils/use-coin-price.js +1 -2
- package/dist/utils/use-coin-price.js.map +1 -1
- package/dist/utils/use-collections.cjs +1 -1
- package/dist/utils/use-collections.cjs.map +1 -1
- package/dist/utils/use-collections.js +1 -1
- package/dist/utils/use-collections.js.map +1 -1
- package/dist/utils/use-comments.cjs +1 -1
- package/dist/utils/use-comments.cjs.map +1 -1
- package/dist/utils/use-comments.js +1 -1
- package/dist/utils/use-comments.js.map +1 -1
- package/dist/utils/use-my-remix-offers.cjs +60 -0
- package/dist/utils/use-my-remix-offers.cjs.map +1 -0
- package/dist/utils/use-my-remix-offers.d.cts +12 -0
- package/dist/utils/use-my-remix-offers.d.ts +12 -0
- package/dist/utils/use-my-remix-offers.js +26 -0
- package/dist/utils/use-my-remix-offers.js.map +1 -0
- package/dist/utils/use-orders.cjs +4 -4
- package/dist/utils/use-orders.cjs.map +1 -1
- package/dist/utils/use-orders.js +4 -4
- package/dist/utils/use-orders.js.map +1 -1
- package/dist/utils/use-remix-offers.cjs +1 -1
- package/dist/utils/use-remix-offers.cjs.map +1 -1
- package/dist/utils/use-remix-offers.js +1 -1
- package/dist/utils/use-remix-offers.js.map +1 -1
- package/dist/utils/use-swap-quote.cjs +73 -0
- package/dist/utils/use-swap-quote.cjs.map +1 -0
- package/dist/utils/use-swap-quote.d.cts +15 -0
- package/dist/utils/use-swap-quote.d.ts +15 -0
- package/dist/utils/use-swap-quote.js +38 -0
- package/dist/utils/use-swap-quote.js.map +1 -0
- package/dist/utils/use-tokens-by-ip-type.cjs +1 -1
- package/dist/utils/use-tokens-by-ip-type.cjs.map +1 -1
- package/dist/utils/use-tokens-by-ip-type.js +1 -1
- package/dist/utils/use-tokens-by-ip-type.js.map +1 -1
- package/dist/utils/use-tokens.cjs +2 -2
- package/dist/utils/use-tokens.cjs.map +1 -1
- package/dist/utils/use-tokens.d.cts +1 -1
- package/dist/utils/use-tokens.d.ts +1 -1
- package/dist/utils/use-tokens.js +2 -2
- package/dist/utils/use-tokens.js.map +1 -1
- package/dist/utils/use-usd-prices.cjs +0 -1
- package/dist/utils/use-usd-prices.cjs.map +1 -1
- package/dist/utils/use-usd-prices.js +0 -1
- package/dist/utils/use-usd-prices.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/notification-row.cjs +0 -117
- package/dist/components/notification-row.cjs.map +0 -1
- package/dist/components/notification-row.d.cts +0 -11
- package/dist/components/notification-row.d.ts +0 -11
- package/dist/components/notification-row.js +0 -83
- package/dist/components/notification-row.js.map +0 -1
- package/dist/data/notification-meta.cjs +0 -66
- package/dist/data/notification-meta.cjs.map +0 -1
- package/dist/data/notification-meta.d.cts +0 -7
- package/dist/data/notification-meta.d.ts +0 -7
- package/dist/data/notification-meta.js +0 -50
- package/dist/data/notification-meta.js.map +0 -1
- package/dist/data/notification.cjs +0 -17
- package/dist/data/notification.cjs.map +0 -1
- package/dist/data/notification.d.cts +0 -31
- package/dist/data/notification.d.ts +0 -31
- package/dist/data/notification.js +0 -1
- package/dist/data/notification.js.map +0 -1
- package/dist/utils/notification-readiness.cjs +0 -32
- package/dist/utils/notification-readiness.cjs.map +0 -1
- package/dist/utils/notification-readiness.d.cts +0 -9
- package/dist/utils/notification-readiness.d.ts +0 -9
- package/dist/utils/notification-readiness.js +0 -8
- package/dist/utils/notification-readiness.js.map +0 -1
- package/dist/utils/notification-storage.cjs +0 -52
- package/dist/utils/notification-storage.cjs.map +0 -1
- package/dist/utils/notification-storage.d.cts +0 -4
- package/dist/utils/notification-storage.d.ts +0 -4
- package/dist/utils/notification-storage.js +0 -27
- package/dist/utils/notification-storage.js.map +0 -1
- package/dist/utils/use-notifications.cjs +0 -182
- package/dist/utils/use-notifications.cjs.map +0 -1
- package/dist/utils/use-notifications.d.cts +0 -11
- package/dist/utils/use-notifications.d.ts +0 -11
- package/dist/utils/use-notifications.js +0 -153
- package/dist/utils/use-notifications.js.map +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
import { useMedialaneApp } from "../components/medialane-app.js";
|
|
4
|
+
import { useMedialaneClient } from "./use-medialane-client.js";
|
|
5
|
+
function tokenKey(token) {
|
|
6
|
+
return typeof token === "string" ? token : token.address;
|
|
7
|
+
}
|
|
8
|
+
function tokenBody(token, side) {
|
|
9
|
+
return typeof token === "string" ? { [`${side}Symbol`]: token } : { [`${side}TokenAddress`]: token.address };
|
|
10
|
+
}
|
|
11
|
+
function swapQuoteKey(signedIn, sell, buy, amountRaw, amountMode, takerAddress) {
|
|
12
|
+
return signedIn && sell && buy && amountRaw ? ["swap-quote", tokenKey(sell), tokenKey(buy), amountRaw, amountMode, takerAddress] : null;
|
|
13
|
+
}
|
|
14
|
+
function useSwapQuote(sell, buy, amountRaw, takerAddress, amountMode = "buy") {
|
|
15
|
+
const client = useMedialaneClient();
|
|
16
|
+
const { signedIn } = useMedialaneApp();
|
|
17
|
+
const { data, error, isLoading } = useSWR(
|
|
18
|
+
swapQuoteKey(signedIn, sell, buy, amountRaw, amountMode, takerAddress),
|
|
19
|
+
() => client.api.platform.swapQuote({
|
|
20
|
+
...tokenBody(sell, "sell"),
|
|
21
|
+
...tokenBody(buy, "buy"),
|
|
22
|
+
[`${amountMode}AmountRaw`]: amountRaw,
|
|
23
|
+
takerAddress: takerAddress ?? void 0
|
|
24
|
+
}),
|
|
25
|
+
{
|
|
26
|
+
refreshInterval: 2e4,
|
|
27
|
+
dedupingInterval: 15e3,
|
|
28
|
+
revalidateOnFocus: false,
|
|
29
|
+
shouldRetryOnError: false
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
return { quote: data ?? null, isLoading, error };
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
swapQuoteKey,
|
|
36
|
+
useSwapQuote
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=use-swap-quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-swap-quote.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiSwapQuote } from \"@medialane/sdk\";\nimport { useMedialaneApp } from \"../components/medialane-app.js\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport type SwapQuoteSummary = ApiSwapQuote;\n\nexport type SwapToken = string | { address: string };\n\nexport type SwapAmountMode = \"sell\" | \"buy\";\n\nfunction tokenKey(token: SwapToken): string {\n return typeof token === \"string\" ? token : token.address;\n}\n\nfunction tokenBody(token: SwapToken, side: \"sell\" | \"buy\") {\n return typeof token === \"string\"\n ? { [`${side}Symbol`]: token }\n : { [`${side}TokenAddress`]: token.address };\n}\n\nexport function swapQuoteKey(\n signedIn: boolean | undefined,\n sell: SwapToken | null,\n buy: SwapToken | null,\n amountRaw: string | null,\n amountMode: SwapAmountMode,\n takerAddress: string | null,\n) {\n return signedIn && sell && buy && amountRaw\n ? ([\"swap-quote\", tokenKey(sell), tokenKey(buy), amountRaw, amountMode, takerAddress] as const)\n : null;\n}\n\nexport function useSwapQuote(\n sell: SwapToken | null,\n buy: SwapToken | null,\n amountRaw: string | null,\n takerAddress: string | null,\n amountMode: SwapAmountMode = \"buy\",\n) {\n const client = useMedialaneClient();\n const { signedIn } = useMedialaneApp();\n const { data, error, isLoading } = useSWR(\n swapQuoteKey(signedIn, sell, buy, amountRaw, amountMode, takerAddress),\n () =>\n client.api.platform.swapQuote({\n ...tokenBody(sell!, \"sell\"),\n ...tokenBody(buy!, \"buy\"),\n [`${amountMode}AmountRaw`]: amountRaw!,\n takerAddress: takerAddress ?? undefined,\n }),\n {\n refreshInterval: 20_000,\n dedupingInterval: 15_000,\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n },\n );\n return { quote: data ?? null, isLoading, error: error as Error | undefined };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAEnB,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AAQnC,SAAS,SAAS,OAA0B;AAC1C,SAAO,OAAO,UAAU,WAAW,QAAQ,MAAM;AACnD;AAEA,SAAS,UAAU,OAAkB,MAAsB;AACzD,SAAO,OAAO,UAAU,WACpB,EAAE,CAAC,GAAG,IAAI,QAAQ,GAAG,MAAM,IAC3B,EAAE,CAAC,GAAG,IAAI,cAAc,GAAG,MAAM,QAAQ;AAC/C;AAEO,SAAS,aACd,UACA,MACA,KACA,WACA,YACA,cACA;AACA,SAAO,YAAY,QAAQ,OAAO,YAC7B,CAAC,cAAc,SAAS,IAAI,GAAG,SAAS,GAAG,GAAG,WAAW,YAAY,YAAY,IAClF;AACN;AAEO,SAAS,aACd,MACA,KACA,WACA,cACA,aAA6B,OAC7B;AACA,QAAM,SAAS,mBAAmB;AAClC,QAAM,EAAE,SAAS,IAAI,gBAAgB;AACrC,QAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC,aAAa,UAAU,MAAM,KAAK,WAAW,YAAY,YAAY;AAAA,IACrE,MACE,OAAO,IAAI,SAAS,UAAU;AAAA,MAC5B,GAAG,UAAU,MAAO,MAAM;AAAA,MAC1B,GAAG,UAAU,KAAM,KAAK;AAAA,MACxB,CAAC,GAAG,UAAU,WAAW,GAAG;AAAA,MAC5B,cAAc,gBAAgB;AAAA,IAChC,CAAC;AAAA,IACH;AAAA,MACE,iBAAiB;AAAA,MACjB,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,IACtB;AAAA,EACF;AACA,SAAO,EAAE,OAAO,QAAQ,MAAM,WAAW,MAAkC;AAC7E;","names":[]}
|
|
@@ -39,7 +39,7 @@ function useTokensByIpType(ipTypeSlug, page = 1, limit = 24) {
|
|
|
39
39
|
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
40
40
|
`tokens-by-type-${ipTypeSlug ?? "all"}-${page}-${limit}`,
|
|
41
41
|
() => client.api.tokens.list({ page, limit, sort: "recent", ipType: ipTypeSlug ?? void 0 }),
|
|
42
|
-
{ revalidateOnFocus: false
|
|
42
|
+
{ revalidateOnFocus: false }
|
|
43
43
|
);
|
|
44
44
|
return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-tokens-by-ip-type.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiResponse, ApiToken } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function useTokensByIpType( ipTypeSlug: string | null, page = 1, limit = 24) {\n const client = useMedialaneClient();\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiToken[]>>(\n `tokens-by-type-${ipTypeSlug ?? \"all\"}-${page}-${limit}`,\n () => client.api.tokens.list({ page, limit, sort: \"recent\", ipType: ipTypeSlug ?? undefined }),\n { revalidateOnFocus: false
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-tokens-by-ip-type.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiResponse, ApiToken } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function useTokensByIpType( ipTypeSlug: string | null, page = 1, limit = 24) {\n const client = useMedialaneClient();\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiToken[]>>(\n `tokens-by-type-${ipTypeSlug ?? \"all\"}-${page}-${limit}`,\n () => client.api.tokens.list({ page, limit, sort: \"recent\", ipType: ipTypeSlug ?? undefined }),\n { revalidateOnFocus: false }\n );\n return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAEnB,kCAAmC;AAE5B,SAAS,kBAAmB,YAA2B,OAAO,GAAG,QAAQ,IAAI;AAClF,QAAM,aAAS,gDAAmB;AAClC,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,kBAAkB,cAAc,KAAK,IAAI,IAAI,IAAI,KAAK;AAAA,IACtD,MAAM,OAAO,IAAI,OAAO,KAAK,EAAE,MAAM,OAAO,MAAM,UAAU,QAAQ,cAAc,OAAU,CAAC;AAAA,IAC7F,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,QAAQ,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AAChF;","names":["useSWR"]}
|
|
@@ -6,7 +6,7 @@ function useTokensByIpType(ipTypeSlug, page = 1, limit = 24) {
|
|
|
6
6
|
const { data, error, isLoading, mutate } = useSWR(
|
|
7
7
|
`tokens-by-type-${ipTypeSlug ?? "all"}-${page}-${limit}`,
|
|
8
8
|
() => client.api.tokens.list({ page, limit, sort: "recent", ipType: ipTypeSlug ?? void 0 }),
|
|
9
|
-
{ revalidateOnFocus: false
|
|
9
|
+
{ revalidateOnFocus: false }
|
|
10
10
|
);
|
|
11
11
|
return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-tokens-by-ip-type.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiResponse, ApiToken } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function useTokensByIpType( ipTypeSlug: string | null, page = 1, limit = 24) {\n const client = useMedialaneClient();\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiToken[]>>(\n `tokens-by-type-${ipTypeSlug ?? \"all\"}-${page}-${limit}`,\n () => client.api.tokens.list({ page, limit, sort: \"recent\", ipType: ipTypeSlug ?? undefined }),\n { revalidateOnFocus: false
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-tokens-by-ip-type.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiResponse, ApiToken } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function useTokensByIpType( ipTypeSlug: string | null, page = 1, limit = 24) {\n const client = useMedialaneClient();\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiToken[]>>(\n `tokens-by-type-${ipTypeSlug ?? \"all\"}-${page}-${limit}`,\n () => client.api.tokens.list({ page, limit, sort: \"recent\", ipType: ipTypeSlug ?? undefined }),\n { revalidateOnFocus: false }\n );\n return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAEnB,SAAS,0BAA0B;AAE5B,SAAS,kBAAmB,YAA2B,OAAO,GAAG,QAAQ,IAAI;AAClF,QAAM,SAAS,mBAAmB;AAClC,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,kBAAkB,cAAc,KAAK,IAAI,IAAI,IAAI,KAAK;AAAA,IACtD,MAAM,OAAO,IAAI,OAAO,KAAK,EAAE,MAAM,OAAO,MAAM,UAAU,QAAQ,cAAc,OAAU,CAAC;AAAA,IAC7F,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,QAAQ,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AAChF;","names":[]}
|
|
@@ -81,12 +81,12 @@ function useTokenBalance(contract, tokenId, owner) {
|
|
|
81
81
|
);
|
|
82
82
|
return { amount: data?.amount ?? null, mutate };
|
|
83
83
|
}
|
|
84
|
-
function useTokensByOwner(address, page = 1, limit = 20
|
|
84
|
+
function useTokensByOwner(address, page = 1, limit = 20) {
|
|
85
85
|
const client = (0, import_use_medialane_client.useMedialaneClient)();
|
|
86
86
|
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
87
87
|
address ? import_query_keys.queryKeys.tokensOwned(address, page, limit) : null,
|
|
88
88
|
() => client.api.tokens.ownedBy(address, { page, limit }),
|
|
89
|
-
{ revalidateOnFocus: false,
|
|
89
|
+
{ revalidateOnFocus: false, revalidateOnMount: true }
|
|
90
90
|
);
|
|
91
91
|
return {
|
|
92
92
|
tokens: data?.data ?? EMPTY_TOKENS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-tokens.ts"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport useSWR from \"swr\";\nimport useSWRInfinite from \"swr/infinite\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { QUERY_PREFIX, queryKeys } from \"./query-keys.js\";\n\nconst EMPTY_TOKENS: ApiToken[] = [];\n\nconst INDEXING_POLL_MS = 10_000;\nconst INDEXING_WINDOW_MS = 60_000;\n\nfunction isNotIndexedYet(error: unknown): boolean {\n return Boolean(\n error && typeof error === \"object\" && (error as { status?: unknown }).status === 404,\n );\n}\n\nexport function useToken( contract: string | null, tokenId: string | null, initial?: ApiToken | null) {\n const client = useMedialaneClient();\n const [startedAt] = useState(() => Date.now());\n\n const { data, error, isLoading, mutate } = useSWR(\n contract && tokenId ? queryKeys.token(contract, tokenId) : null,\n () => client.api.tokens.get(contract!, tokenId!),\n {\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n fallbackData: initial ?? undefined,\n refreshInterval: (latest) =>\n latest || initial || Date.now() - startedAt > INDEXING_WINDOW_MS ? 0 : INDEXING_POLL_MS,\n }\n );\n\n const token = data ?? null;\n const withinWindow = Date.now() - startedAt <= INDEXING_WINDOW_MS;\n\n return {\n token,\n isLoading: isLoading && !token,\n isIndexing: !token && isNotIndexedYet(error) && withinWindow,\n error: isNotIndexedYet(error) ? undefined : error,\n mutate,\n };\n}\n\nexport function useTokenBalance(\n contract: string | null,\n tokenId: string | null,\n owner: string | null | undefined,\n) {\n const client = useMedialaneClient();\n\n const { data, mutate } = useSWR(\n contract && tokenId && owner ? queryKeys.tokenBalance(contract, tokenId, owner) : null,\n () => client.api.tokens.balance(contract!, tokenId!, owner!),\n { revalidateOnFocus: false }\n );\n\n return { amount: data?.amount ?? null, mutate };\n}\n\nexport function useTokensByOwner(\n address: string | null,\n page = 1,\n limit = 20,\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-tokens.ts"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport useSWR from \"swr\";\nimport useSWRInfinite from \"swr/infinite\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { QUERY_PREFIX, queryKeys } from \"./query-keys.js\";\n\nconst EMPTY_TOKENS: ApiToken[] = [];\n\nconst INDEXING_POLL_MS = 10_000;\nconst INDEXING_WINDOW_MS = 60_000;\n\nfunction isNotIndexedYet(error: unknown): boolean {\n return Boolean(\n error && typeof error === \"object\" && (error as { status?: unknown }).status === 404,\n );\n}\n\nexport function useToken( contract: string | null, tokenId: string | null, initial?: ApiToken | null) {\n const client = useMedialaneClient();\n const [startedAt] = useState(() => Date.now());\n\n const { data, error, isLoading, mutate } = useSWR(\n contract && tokenId ? queryKeys.token(contract, tokenId) : null,\n () => client.api.tokens.get(contract!, tokenId!),\n {\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n fallbackData: initial ?? undefined,\n refreshInterval: (latest) =>\n latest || initial || Date.now() - startedAt > INDEXING_WINDOW_MS ? 0 : INDEXING_POLL_MS,\n }\n );\n\n const token = data ?? null;\n const withinWindow = Date.now() - startedAt <= INDEXING_WINDOW_MS;\n\n return {\n token,\n isLoading: isLoading && !token,\n isIndexing: !token && isNotIndexedYet(error) && withinWindow,\n error: isNotIndexedYet(error) ? undefined : error,\n mutate,\n };\n}\n\nexport function useTokenBalance(\n contract: string | null,\n tokenId: string | null,\n owner: string | null | undefined,\n) {\n const client = useMedialaneClient();\n\n const { data, mutate } = useSWR(\n contract && tokenId && owner ? queryKeys.tokenBalance(contract, tokenId, owner) : null,\n () => client.api.tokens.balance(contract!, tokenId!, owner!),\n { revalidateOnFocus: false }\n );\n\n return { amount: data?.amount ?? null, mutate };\n}\n\nexport function useTokensByOwner(\n address: string | null,\n page = 1,\n limit = 20,\n) {\n const client = useMedialaneClient();\n\n const { data, error, isLoading, mutate } = useSWR(\n address ? queryKeys.tokensOwned(address, page, limit) : null,\n () => client.api.tokens.ownedBy(address!, { page: page, limit: limit }),\n { revalidateOnFocus: false, revalidateOnMount: true }\n );\n\n return {\n tokens: data?.data ?? EMPTY_TOKENS,\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useOwnedTokens(address: string | null, limit = 20) {\n const client = useMedialaneClient();\n\n const { data, error, isLoading, isValidating, setSize, mutate } = useSWRInfinite(\n (index) => (address ? ([QUERY_PREFIX.tokensOwnedPages, address, limit, index + 1] as const) : null),\n ([, owner, pageSize, page]) => client.api.tokens.ownedBy(owner, { page, limit: pageSize }),\n { revalidateOnFocus: false, revalidateFirstPage: false },\n );\n\n const tokens = data ? data.flatMap((page) => page.data) : EMPTY_TOKENS;\n const total = data?.[0]?.meta?.total ?? null;\n\n return {\n tokens,\n total,\n isLoading,\n isLoadingMore: isValidating,\n hasMore: total !== null && tokens.length < total,\n loadMore: () => void setSize((size) => size + 1),\n error,\n mutate,\n };\n}\n\nexport function useTokenHistory( contract: string | null, tokenId: string | null) {\n const client = useMedialaneClient();\n\n const { data, error, isLoading } = useSWR(\n contract && tokenId ? queryKeys.tokenHistory(contract, tokenId) : null,\n () => client.api.tokens.history(contract!, tokenId!),\n { revalidateOnFocus: false }\n );\n\n return { history: data?.data ?? [], isLoading, error };\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAyB;AACzB,iBAAmB;AACnB,sBAA2B;AAE3B,kCAAmC;AACnC,wBAAwC;AAExC,MAAM,eAA2B,CAAC;AAElC,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;AAE3B,SAAS,gBAAgB,OAAyB;AAChD,SAAO;AAAA,IACL,SAAS,OAAO,UAAU,YAAa,MAA+B,WAAW;AAAA,EACnF;AACF;AAEO,SAAS,SAAU,UAAyB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AE,SAAS,MAAM,QAAQ,CAAC,GAAG,WAAW,MAAM;AACvD;","names":["useSWR","useSWRInfinite"]}
|
|
@@ -184,7 +184,7 @@ declare function useTokenBalance(contract: string | null, tokenId: string | null
|
|
|
184
184
|
amount: string | null;
|
|
185
185
|
mutate: swr.KeyedMutator<_medialane_sdk.ApiTokenBalance>;
|
|
186
186
|
};
|
|
187
|
-
declare function useTokensByOwner(address: string | null, page?: number, limit?: number
|
|
187
|
+
declare function useTokensByOwner(address: string | null, page?: number, limit?: number): {
|
|
188
188
|
tokens: {
|
|
189
189
|
id: string;
|
|
190
190
|
chain: string;
|
|
@@ -184,7 +184,7 @@ declare function useTokenBalance(contract: string | null, tokenId: string | null
|
|
|
184
184
|
amount: string | null;
|
|
185
185
|
mutate: swr.KeyedMutator<_medialane_sdk.ApiTokenBalance>;
|
|
186
186
|
};
|
|
187
|
-
declare function useTokensByOwner(address: string | null, page?: number, limit?: number
|
|
187
|
+
declare function useTokensByOwner(address: string | null, page?: number, limit?: number): {
|
|
188
188
|
tokens: {
|
|
189
189
|
id: string;
|
|
190
190
|
chain: string;
|
package/dist/utils/use-tokens.js
CHANGED
|
@@ -44,12 +44,12 @@ function useTokenBalance(contract, tokenId, owner) {
|
|
|
44
44
|
);
|
|
45
45
|
return { amount: data?.amount ?? null, mutate };
|
|
46
46
|
}
|
|
47
|
-
function useTokensByOwner(address, page = 1, limit = 20
|
|
47
|
+
function useTokensByOwner(address, page = 1, limit = 20) {
|
|
48
48
|
const client = useMedialaneClient();
|
|
49
49
|
const { data, error, isLoading, mutate } = useSWR(
|
|
50
50
|
address ? queryKeys.tokensOwned(address, page, limit) : null,
|
|
51
51
|
() => client.api.tokens.ownedBy(address, { page, limit }),
|
|
52
|
-
{ revalidateOnFocus: false,
|
|
52
|
+
{ revalidateOnFocus: false, revalidateOnMount: true }
|
|
53
53
|
);
|
|
54
54
|
return {
|
|
55
55
|
tokens: data?.data ?? EMPTY_TOKENS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-tokens.ts"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport useSWR from \"swr\";\nimport useSWRInfinite from \"swr/infinite\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { QUERY_PREFIX, queryKeys } from \"./query-keys.js\";\n\nconst EMPTY_TOKENS: ApiToken[] = [];\n\nconst INDEXING_POLL_MS = 10_000;\nconst INDEXING_WINDOW_MS = 60_000;\n\nfunction isNotIndexedYet(error: unknown): boolean {\n return Boolean(\n error && typeof error === \"object\" && (error as { status?: unknown }).status === 404,\n );\n}\n\nexport function useToken( contract: string | null, tokenId: string | null, initial?: ApiToken | null) {\n const client = useMedialaneClient();\n const [startedAt] = useState(() => Date.now());\n\n const { data, error, isLoading, mutate } = useSWR(\n contract && tokenId ? queryKeys.token(contract, tokenId) : null,\n () => client.api.tokens.get(contract!, tokenId!),\n {\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n fallbackData: initial ?? undefined,\n refreshInterval: (latest) =>\n latest || initial || Date.now() - startedAt > INDEXING_WINDOW_MS ? 0 : INDEXING_POLL_MS,\n }\n );\n\n const token = data ?? null;\n const withinWindow = Date.now() - startedAt <= INDEXING_WINDOW_MS;\n\n return {\n token,\n isLoading: isLoading && !token,\n isIndexing: !token && isNotIndexedYet(error) && withinWindow,\n error: isNotIndexedYet(error) ? undefined : error,\n mutate,\n };\n}\n\nexport function useTokenBalance(\n contract: string | null,\n tokenId: string | null,\n owner: string | null | undefined,\n) {\n const client = useMedialaneClient();\n\n const { data, mutate } = useSWR(\n contract && tokenId && owner ? queryKeys.tokenBalance(contract, tokenId, owner) : null,\n () => client.api.tokens.balance(contract!, tokenId!, owner!),\n { revalidateOnFocus: false }\n );\n\n return { amount: data?.amount ?? null, mutate };\n}\n\nexport function useTokensByOwner(\n address: string | null,\n page = 1,\n limit = 20,\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-tokens.ts"],"sourcesContent":["\"use client\";\n\nimport { useState } from \"react\";\nimport useSWR from \"swr\";\nimport useSWRInfinite from \"swr/infinite\";\nimport type { ApiToken } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { QUERY_PREFIX, queryKeys } from \"./query-keys.js\";\n\nconst EMPTY_TOKENS: ApiToken[] = [];\n\nconst INDEXING_POLL_MS = 10_000;\nconst INDEXING_WINDOW_MS = 60_000;\n\nfunction isNotIndexedYet(error: unknown): boolean {\n return Boolean(\n error && typeof error === \"object\" && (error as { status?: unknown }).status === 404,\n );\n}\n\nexport function useToken( contract: string | null, tokenId: string | null, initial?: ApiToken | null) {\n const client = useMedialaneClient();\n const [startedAt] = useState(() => Date.now());\n\n const { data, error, isLoading, mutate } = useSWR(\n contract && tokenId ? queryKeys.token(contract, tokenId) : null,\n () => client.api.tokens.get(contract!, tokenId!),\n {\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n fallbackData: initial ?? undefined,\n refreshInterval: (latest) =>\n latest || initial || Date.now() - startedAt > INDEXING_WINDOW_MS ? 0 : INDEXING_POLL_MS,\n }\n );\n\n const token = data ?? null;\n const withinWindow = Date.now() - startedAt <= INDEXING_WINDOW_MS;\n\n return {\n token,\n isLoading: isLoading && !token,\n isIndexing: !token && isNotIndexedYet(error) && withinWindow,\n error: isNotIndexedYet(error) ? undefined : error,\n mutate,\n };\n}\n\nexport function useTokenBalance(\n contract: string | null,\n tokenId: string | null,\n owner: string | null | undefined,\n) {\n const client = useMedialaneClient();\n\n const { data, mutate } = useSWR(\n contract && tokenId && owner ? queryKeys.tokenBalance(contract, tokenId, owner) : null,\n () => client.api.tokens.balance(contract!, tokenId!, owner!),\n { revalidateOnFocus: false }\n );\n\n return { amount: data?.amount ?? null, mutate };\n}\n\nexport function useTokensByOwner(\n address: string | null,\n page = 1,\n limit = 20,\n) {\n const client = useMedialaneClient();\n\n const { data, error, isLoading, mutate } = useSWR(\n address ? queryKeys.tokensOwned(address, page, limit) : null,\n () => client.api.tokens.ownedBy(address!, { page: page, limit: limit }),\n { revalidateOnFocus: false, revalidateOnMount: true }\n );\n\n return {\n tokens: data?.data ?? EMPTY_TOKENS,\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useOwnedTokens(address: string | null, limit = 20) {\n const client = useMedialaneClient();\n\n const { data, error, isLoading, isValidating, setSize, mutate } = useSWRInfinite(\n (index) => (address ? ([QUERY_PREFIX.tokensOwnedPages, address, limit, index + 1] as const) : null),\n ([, owner, pageSize, page]) => client.api.tokens.ownedBy(owner, { page, limit: pageSize }),\n { revalidateOnFocus: false, revalidateFirstPage: false },\n );\n\n const tokens = data ? data.flatMap((page) => page.data) : EMPTY_TOKENS;\n const total = data?.[0]?.meta?.total ?? null;\n\n return {\n tokens,\n total,\n isLoading,\n isLoadingMore: isValidating,\n hasMore: total !== null && tokens.length < total,\n loadMore: () => void setSize((size) => size + 1),\n error,\n mutate,\n };\n}\n\nexport function useTokenHistory( contract: string | null, tokenId: string | null) {\n const client = useMedialaneClient();\n\n const { data, error, isLoading } = useSWR(\n contract && tokenId ? queryKeys.tokenHistory(contract, tokenId) : null,\n () => client.api.tokens.history(contract!, tokenId!),\n { revalidateOnFocus: false }\n );\n\n return { history: data?.data ?? [], isLoading, error };\n}\n\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,OAAO,YAAY;AACnB,OAAO,oBAAoB;AAE3B,SAAS,0BAA0B;AACnC,SAAS,cAAc,iBAAiB;AAExC,MAAM,eAA2B,CAAC;AAElC,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;AAE3B,SAAS,gBAAgB,OAAyB;AAChD,SAAO;AAAA,IACL,SAAS,OAAO,UAAU,YAAa,MAA+B,WAAW;AAAA,EACnF;AACF;AAEO,SAAS,SAAU,UAAyB,SAAwB,SAA2B;AACpG,QAAM,SAAS,mBAAmB;AAClC,QAAM,CAAC,SAAS,IAAI,SAAS,MAAM,KAAK,IAAI,CAA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|
|
59
59
|
const { data } = (0, import_swr.default)(PRICES_KEY, fetchUsdPrices, {
|
|
60
|
-
refreshInterval: REFRESH_MS,
|
|
61
60
|
dedupingInterval: REFRESH_MS,
|
|
62
61
|
revalidateOnFocus: false,
|
|
63
62
|
revalidateOnReconnect: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-usd-prices.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { formatUsd } from \"./format.js\";\n\nexport type UsdPrices = Partial<Record<\"STRK\" | \"ETH\" | \"USDC\" | \"USDT\" | \"WBTC\", number>>;\n\nexport function usdPriceFor(prices: UsdPrices | null, symbol: string): number | undefined {\n return (prices as Record<string, number | undefined> | null)?.[symbol];\n}\n\nexport function usdValueFor(\n amountFormatted: string | null | undefined,\n currency: string | null | undefined,\n prices: UsdPrices | null,\n): string | null {\n if (!amountFormatted || !currency || !prices) return null;\n const rate = usdPriceFor(prices, currency.toUpperCase());\n if (rate == null) return null;\n const amount = parseFloat(amountFormatted);\n if (isNaN(amount)) return null;\n return formatUsd(amount * rate);\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\nexport function useUsdPrices(): UsdPrices | null {\n const { data } = useSWR(PRICES_KEY, fetchUsdPrices, {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-usd-prices.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { formatUsd } from \"./format.js\";\n\nexport type UsdPrices = Partial<Record<\"STRK\" | \"ETH\" | \"USDC\" | \"USDT\" | \"WBTC\", number>>;\n\nexport function usdPriceFor(prices: UsdPrices | null, symbol: string): number | undefined {\n return (prices as Record<string, number | undefined> | null)?.[symbol];\n}\n\nexport function usdValueFor(\n amountFormatted: string | null | undefined,\n currency: string | null | undefined,\n prices: UsdPrices | null,\n): string | null {\n if (!amountFormatted || !currency || !prices) return null;\n const rate = usdPriceFor(prices, currency.toUpperCase());\n if (rate == null) return null;\n const amount = parseFloat(amountFormatted);\n if (isNaN(amount)) return null;\n return formatUsd(amount * rate);\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\nexport function useUsdPrices(): UsdPrices | null {\n const { data } = useSWR(PRICES_KEY, fetchUsdPrices, {\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;AAAA;AAEA,iBAAmB;AACnB,oBAA0B;AAInB,SAAS,YAAY,QAA0B,QAAoC;AACxF,SAAQ,SAAuD,MAAM;AACvE;AAEO,SAAS,YACd,iBACA,UACA,QACe;AACf,MAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,OAAQ,QAAO;AACrD,QAAM,OAAO,YAAY,QAAQ,SAAS,YAAY,CAAC;AACvD,MAAI,QAAQ,KAAM,QAAO;AACzB,QAAM,SAAS,WAAW,eAAe;AACzC,MAAI,MAAM,MAAM,EAAG,QAAO;AAC1B,aAAO,yBAAU,SAAS,IAAI;AAChC;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;AAEO,SAAS,eAAiC;AAC/C,QAAM,EAAE,KAAK,QAAI,WAAAA,SAAO,YAAY,gBAAgB;AAAA,IAClD,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-usd-prices.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { formatUsd } from \"./format.js\";\n\nexport type UsdPrices = Partial<Record<\"STRK\" | \"ETH\" | \"USDC\" | \"USDT\" | \"WBTC\", number>>;\n\nexport function usdPriceFor(prices: UsdPrices | null, symbol: string): number | undefined {\n return (prices as Record<string, number | undefined> | null)?.[symbol];\n}\n\nexport function usdValueFor(\n amountFormatted: string | null | undefined,\n currency: string | null | undefined,\n prices: UsdPrices | null,\n): string | null {\n if (!amountFormatted || !currency || !prices) return null;\n const rate = usdPriceFor(prices, currency.toUpperCase());\n if (rate == null) return null;\n const amount = parseFloat(amountFormatted);\n if (isNaN(amount)) return null;\n return formatUsd(amount * rate);\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\nexport function useUsdPrices(): UsdPrices | null {\n const { data } = useSWR(PRICES_KEY, fetchUsdPrices, {\n
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-usd-prices.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { formatUsd } from \"./format.js\";\n\nexport type UsdPrices = Partial<Record<\"STRK\" | \"ETH\" | \"USDC\" | \"USDT\" | \"WBTC\", number>>;\n\nexport function usdPriceFor(prices: UsdPrices | null, symbol: string): number | undefined {\n return (prices as Record<string, number | undefined> | null)?.[symbol];\n}\n\nexport function usdValueFor(\n amountFormatted: string | null | undefined,\n currency: string | null | undefined,\n prices: UsdPrices | null,\n): string | null {\n if (!amountFormatted || !currency || !prices) return null;\n const rate = usdPriceFor(prices, currency.toUpperCase());\n if (rate == null) return null;\n const amount = parseFloat(amountFormatted);\n if (isNaN(amount)) return null;\n return formatUsd(amount * rate);\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\nexport function useUsdPrices(): UsdPrices | null {\n const { data } = useSWR(PRICES_KEY, fetchUsdPrices, {\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;AACnB,SAAS,iBAAiB;AAInB,SAAS,YAAY,QAA0B,QAAoC;AACxF,SAAQ,SAAuD,MAAM;AACvE;AAEO,SAAS,YACd,iBACA,UACA,QACe;AACf,MAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,OAAQ,QAAO;AACrD,QAAM,OAAO,YAAY,QAAQ,SAAS,YAAY,CAAC;AACvD,MAAI,QAAQ,KAAM,QAAO;AACzB,QAAM,SAAS,WAAW,eAAe;AACzC,MAAI,MAAM,MAAM,EAAG,QAAO;AAC1B,SAAO,UAAU,SAAS,IAAI;AAChC;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;AAEO,SAAS,eAAiC;AAC/C,QAAM,EAAE,KAAK,IAAI,OAAO,YAAY,gBAAgB;AAAA,IAClD,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,117 +0,0 @@
|
|
|
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 notification_row_exports = {};
|
|
31
|
-
__export(notification_row_exports, {
|
|
32
|
-
NotificationRow: () => NotificationRow
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(notification_row_exports);
|
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
var import_link = __toESM(require("./link.js"), 1);
|
|
37
|
-
var import_image = __toESM(require("./image.js"), 1);
|
|
38
|
-
var import_lucide_react = require("lucide-react");
|
|
39
|
-
var import_time = require("../utils/time.js");
|
|
40
|
-
var import_cn = require("../utils/cn.js");
|
|
41
|
-
var import_notification_meta = require("../data/notification-meta.js");
|
|
42
|
-
function NotificationRow({
|
|
43
|
-
notification,
|
|
44
|
-
onNavigate,
|
|
45
|
-
compact = false
|
|
46
|
-
}) {
|
|
47
|
-
const { type, title, description, image, href, timestamp, isUnread } = notification;
|
|
48
|
-
const Icon = import_notification_meta.NOTIFICATION_ICON[type] ?? import_lucide_react.Bell;
|
|
49
|
-
const colorClass = import_notification_meta.NOTIFICATION_COLOR[type] ?? "text-muted-foreground bg-muted/40";
|
|
50
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
51
|
-
import_link.default,
|
|
52
|
-
{
|
|
53
|
-
href,
|
|
54
|
-
onClick: onNavigate,
|
|
55
|
-
className: (0, import_cn.cn)(
|
|
56
|
-
"flex items-start gap-3 px-4 transition-colors group",
|
|
57
|
-
compact ? "py-3" : "py-4",
|
|
58
|
-
isUnread && "bg-primary/[0.03]",
|
|
59
|
-
"hover:bg-muted/40"
|
|
60
|
-
),
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "relative shrink-0 mt-0.5", children: image ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
63
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-10 w-10 rounded-xl overflow-hidden bg-muted ring-1 ring-border/40", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
-
import_image.default,
|
|
65
|
-
{
|
|
66
|
-
src: image,
|
|
67
|
-
alt: "",
|
|
68
|
-
width: 40,
|
|
69
|
-
height: 40,
|
|
70
|
-
className: "object-cover w-full h-full",
|
|
71
|
-
unoptimized: true
|
|
72
|
-
}
|
|
73
|
-
) }),
|
|
74
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
75
|
-
"div",
|
|
76
|
-
{
|
|
77
|
-
className: (0, import_cn.cn)(
|
|
78
|
-
"absolute -bottom-1 -right-1 h-5 w-5 rounded-full border-2 border-background flex items-center justify-center",
|
|
79
|
-
colorClass
|
|
80
|
-
),
|
|
81
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { className: "h-2.5 w-2.5" })
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
|
-
"div",
|
|
86
|
-
{
|
|
87
|
-
className: (0, import_cn.cn)(
|
|
88
|
-
"h-10 w-10 rounded-xl flex items-center justify-center ring-1 ring-border/20",
|
|
89
|
-
colorClass
|
|
90
|
-
),
|
|
91
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { className: "h-4 w-4" })
|
|
92
|
-
}
|
|
93
|
-
) }),
|
|
94
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-1 min-w-0 space-y-0.5", children: [
|
|
95
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
-
"p",
|
|
97
|
-
{
|
|
98
|
-
className: (0, import_cn.cn)(
|
|
99
|
-
"text-sm leading-snug truncate",
|
|
100
|
-
isUnread ? "font-semibold text-foreground" : "font-medium text-foreground/90"
|
|
101
|
-
),
|
|
102
|
-
children: title
|
|
103
|
-
}
|
|
104
|
-
),
|
|
105
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-muted-foreground truncate", children: description }),
|
|
106
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-2xs text-muted-foreground/50 pt-0.5", children: (0, import_time.timeAgo)(timestamp) })
|
|
107
|
-
] }),
|
|
108
|
-
isUnread && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-2 w-2 rounded-full bg-primary shrink-0 mt-2" })
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
114
|
-
0 && (module.exports = {
|
|
115
|
-
NotificationRow
|
|
116
|
-
});
|
|
117
|
-
//# sourceMappingURL=notification-row.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/notification-row.tsx"],"sourcesContent":["\"use client\";\n\nimport Link from \"./link.js\";\nimport Image from \"./image.js\";\nimport { Bell } from \"lucide-react\";\nimport { timeAgo } from \"../utils/time.js\";\nimport { cn } from \"../utils/cn.js\";\nimport { NOTIFICATION_ICON, NOTIFICATION_COLOR } from \"../data/notification-meta.js\";\nimport type { Notification } from \"../data/notification.js\";\n\nexport interface NotificationRowProps {\n notification: Notification;\n onNavigate?: () => void;\n compact?: boolean;\n}\n\nexport function NotificationRow({\n notification,\n onNavigate,\n compact = false,\n}: NotificationRowProps) {\n const { type, title, description, image, href, timestamp, isUnread } = notification;\n const Icon = NOTIFICATION_ICON[type] ?? Bell;\n const colorClass = NOTIFICATION_COLOR[type] ?? \"text-muted-foreground bg-muted/40\";\n\n return (\n <Link\n href={href}\n onClick={onNavigate}\n className={cn(\n \"flex items-start gap-3 px-4 transition-colors group\",\n compact ? \"py-3\" : \"py-4\",\n isUnread && \"bg-primary/[0.03]\",\n \"hover:bg-muted/40\"\n )}\n >\n\n <div className=\"relative shrink-0 mt-0.5\">\n {image ? (\n <>\n <div className=\"h-10 w-10 rounded-xl overflow-hidden bg-muted ring-1 ring-border/40\">\n <Image\n src={image}\n alt=\"\"\n width={40}\n height={40}\n className=\"object-cover w-full h-full\"\n unoptimized\n />\n </div>\n <div\n className={cn(\n \"absolute -bottom-1 -right-1 h-5 w-5 rounded-full border-2 border-background flex items-center justify-center\",\n colorClass\n )}\n >\n <Icon className=\"h-2.5 w-2.5\" />\n </div>\n </>\n ) : (\n <div\n className={cn(\n \"h-10 w-10 rounded-xl flex items-center justify-center ring-1 ring-border/20\",\n colorClass\n )}\n >\n <Icon className=\"h-4 w-4\" />\n </div>\n )}\n </div>\n\n <div className=\"flex-1 min-w-0 space-y-0.5\">\n <p\n className={cn(\n \"text-sm leading-snug truncate\",\n isUnread ? \"font-semibold text-foreground\" : \"font-medium text-foreground/90\"\n )}\n >\n {title}\n </p>\n <p className=\"text-xs text-muted-foreground truncate\">{description}</p>\n <p className=\"text-2xs text-muted-foreground/50 pt-0.5\">{timeAgo(timestamp)}</p>\n </div>\n\n {isUnread && (\n <div className=\"h-2 w-2 rounded-full bg-primary shrink-0 mt-2\" />\n )}\n </Link>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuCU;AArCV,kBAAiB;AACjB,mBAAkB;AAClB,0BAAqB;AACrB,kBAAwB;AACxB,gBAAmB;AACnB,+BAAsD;AAS/C,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAAyB;AACvB,QAAM,EAAE,MAAM,OAAO,aAAa,OAAO,MAAM,WAAW,SAAS,IAAI;AACvE,QAAM,OAAO,2CAAkB,IAAI,KAAK;AACxC,QAAM,aAAa,4CAAmB,IAAI,KAAK;AAE/C,SACE;AAAA,IAAC,YAAAA;AAAA,IAAA;AAAA,MACC;AAAA,MACA,SAAS;AAAA,MACT,eAAW;AAAA,QACT;AAAA,QACA,UAAU,SAAS;AAAA,QACnB,YAAY;AAAA,QACZ;AAAA,MACF;AAAA,MAGA;AAAA,oDAAC,SAAI,WAAU,4BACZ,kBACC,4EACE;AAAA,sDAAC,SAAI,WAAU,uEACb;AAAA,YAAC,aAAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,KAAI;AAAA,cACJ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,WAAU;AAAA,cACV,aAAW;AAAA;AAAA,UACb,GACF;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,gBACT;AAAA,gBACA;AAAA,cACF;AAAA,cAEA,sDAAC,QAAK,WAAU,eAAc;AAAA;AAAA,UAChC;AAAA,WACF,IAEA;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,cACT;AAAA,cACA;AAAA,YACF;AAAA,YAEA,sDAAC,QAAK,WAAU,WAAU;AAAA;AAAA,QAC5B,GAEJ;AAAA,QAEA,6CAAC,SAAI,WAAU,8BACb;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,eAAW;AAAA,gBACT;AAAA,gBACA,WAAW,kCAAkC;AAAA,cAC/C;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACA,4CAAC,OAAE,WAAU,0CAA0C,uBAAY;AAAA,UACnE,4CAAC,OAAE,WAAU,4CAA4C,mCAAQ,SAAS,GAAE;AAAA,WAC9E;AAAA,QAEC,YACC,4CAAC,SAAI,WAAU,iDAAgD;AAAA;AAAA;AAAA,EAEnE;AAEJ;","names":["Link","Image"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { Notification } from '../data/notification.cjs';
|
|
3
|
-
|
|
4
|
-
interface NotificationRowProps {
|
|
5
|
-
notification: Notification;
|
|
6
|
-
onNavigate?: () => void;
|
|
7
|
-
compact?: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare function NotificationRow({ notification, onNavigate, compact, }: NotificationRowProps): react_jsx_runtime.JSX.Element;
|
|
10
|
-
|
|
11
|
-
export { NotificationRow, type NotificationRowProps };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { Notification } from '../data/notification.js';
|
|
3
|
-
|
|
4
|
-
interface NotificationRowProps {
|
|
5
|
-
notification: Notification;
|
|
6
|
-
onNavigate?: () => void;
|
|
7
|
-
compact?: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare function NotificationRow({ notification, onNavigate, compact, }: NotificationRowProps): react_jsx_runtime.JSX.Element;
|
|
10
|
-
|
|
11
|
-
export { NotificationRow, type NotificationRowProps };
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import Link from "./link.js";
|
|
4
|
-
import Image from "./image.js";
|
|
5
|
-
import { Bell } from "lucide-react";
|
|
6
|
-
import { timeAgo } from "../utils/time.js";
|
|
7
|
-
import { cn } from "../utils/cn.js";
|
|
8
|
-
import { NOTIFICATION_ICON, NOTIFICATION_COLOR } from "../data/notification-meta.js";
|
|
9
|
-
function NotificationRow({
|
|
10
|
-
notification,
|
|
11
|
-
onNavigate,
|
|
12
|
-
compact = false
|
|
13
|
-
}) {
|
|
14
|
-
const { type, title, description, image, href, timestamp, isUnread } = notification;
|
|
15
|
-
const Icon = NOTIFICATION_ICON[type] ?? Bell;
|
|
16
|
-
const colorClass = NOTIFICATION_COLOR[type] ?? "text-muted-foreground bg-muted/40";
|
|
17
|
-
return /* @__PURE__ */ jsxs(
|
|
18
|
-
Link,
|
|
19
|
-
{
|
|
20
|
-
href,
|
|
21
|
-
onClick: onNavigate,
|
|
22
|
-
className: cn(
|
|
23
|
-
"flex items-start gap-3 px-4 transition-colors group",
|
|
24
|
-
compact ? "py-3" : "py-4",
|
|
25
|
-
isUnread && "bg-primary/[0.03]",
|
|
26
|
-
"hover:bg-muted/40"
|
|
27
|
-
),
|
|
28
|
-
children: [
|
|
29
|
-
/* @__PURE__ */ jsx("div", { className: "relative shrink-0 mt-0.5", children: image ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
30
|
-
/* @__PURE__ */ jsx("div", { className: "h-10 w-10 rounded-xl overflow-hidden bg-muted ring-1 ring-border/40", children: /* @__PURE__ */ jsx(
|
|
31
|
-
Image,
|
|
32
|
-
{
|
|
33
|
-
src: image,
|
|
34
|
-
alt: "",
|
|
35
|
-
width: 40,
|
|
36
|
-
height: 40,
|
|
37
|
-
className: "object-cover w-full h-full",
|
|
38
|
-
unoptimized: true
|
|
39
|
-
}
|
|
40
|
-
) }),
|
|
41
|
-
/* @__PURE__ */ jsx(
|
|
42
|
-
"div",
|
|
43
|
-
{
|
|
44
|
-
className: cn(
|
|
45
|
-
"absolute -bottom-1 -right-1 h-5 w-5 rounded-full border-2 border-background flex items-center justify-center",
|
|
46
|
-
colorClass
|
|
47
|
-
),
|
|
48
|
-
children: /* @__PURE__ */ jsx(Icon, { className: "h-2.5 w-2.5" })
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
] }) : /* @__PURE__ */ jsx(
|
|
52
|
-
"div",
|
|
53
|
-
{
|
|
54
|
-
className: cn(
|
|
55
|
-
"h-10 w-10 rounded-xl flex items-center justify-center ring-1 ring-border/20",
|
|
56
|
-
colorClass
|
|
57
|
-
),
|
|
58
|
-
children: /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" })
|
|
59
|
-
}
|
|
60
|
-
) }),
|
|
61
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 space-y-0.5", children: [
|
|
62
|
-
/* @__PURE__ */ jsx(
|
|
63
|
-
"p",
|
|
64
|
-
{
|
|
65
|
-
className: cn(
|
|
66
|
-
"text-sm leading-snug truncate",
|
|
67
|
-
isUnread ? "font-semibold text-foreground" : "font-medium text-foreground/90"
|
|
68
|
-
),
|
|
69
|
-
children: title
|
|
70
|
-
}
|
|
71
|
-
),
|
|
72
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground truncate", children: description }),
|
|
73
|
-
/* @__PURE__ */ jsx("p", { className: "text-2xs text-muted-foreground/50 pt-0.5", children: timeAgo(timestamp) })
|
|
74
|
-
] }),
|
|
75
|
-
isUnread && /* @__PURE__ */ jsx("div", { className: "h-2 w-2 rounded-full bg-primary shrink-0 mt-2" })
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
export {
|
|
81
|
-
NotificationRow
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=notification-row.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/notification-row.tsx"],"sourcesContent":["\"use client\";\n\nimport Link from \"./link.js\";\nimport Image from \"./image.js\";\nimport { Bell } from \"lucide-react\";\nimport { timeAgo } from \"../utils/time.js\";\nimport { cn } from \"../utils/cn.js\";\nimport { NOTIFICATION_ICON, NOTIFICATION_COLOR } from \"../data/notification-meta.js\";\nimport type { Notification } from \"../data/notification.js\";\n\nexport interface NotificationRowProps {\n notification: Notification;\n onNavigate?: () => void;\n compact?: boolean;\n}\n\nexport function NotificationRow({\n notification,\n onNavigate,\n compact = false,\n}: NotificationRowProps) {\n const { type, title, description, image, href, timestamp, isUnread } = notification;\n const Icon = NOTIFICATION_ICON[type] ?? Bell;\n const colorClass = NOTIFICATION_COLOR[type] ?? \"text-muted-foreground bg-muted/40\";\n\n return (\n <Link\n href={href}\n onClick={onNavigate}\n className={cn(\n \"flex items-start gap-3 px-4 transition-colors group\",\n compact ? \"py-3\" : \"py-4\",\n isUnread && \"bg-primary/[0.03]\",\n \"hover:bg-muted/40\"\n )}\n >\n\n <div className=\"relative shrink-0 mt-0.5\">\n {image ? (\n <>\n <div className=\"h-10 w-10 rounded-xl overflow-hidden bg-muted ring-1 ring-border/40\">\n <Image\n src={image}\n alt=\"\"\n width={40}\n height={40}\n className=\"object-cover w-full h-full\"\n unoptimized\n />\n </div>\n <div\n className={cn(\n \"absolute -bottom-1 -right-1 h-5 w-5 rounded-full border-2 border-background flex items-center justify-center\",\n colorClass\n )}\n >\n <Icon className=\"h-2.5 w-2.5\" />\n </div>\n </>\n ) : (\n <div\n className={cn(\n \"h-10 w-10 rounded-xl flex items-center justify-center ring-1 ring-border/20\",\n colorClass\n )}\n >\n <Icon className=\"h-4 w-4\" />\n </div>\n )}\n </div>\n\n <div className=\"flex-1 min-w-0 space-y-0.5\">\n <p\n className={cn(\n \"text-sm leading-snug truncate\",\n isUnread ? \"font-semibold text-foreground\" : \"font-medium text-foreground/90\"\n )}\n >\n {title}\n </p>\n <p className=\"text-xs text-muted-foreground truncate\">{description}</p>\n <p className=\"text-2xs text-muted-foreground/50 pt-0.5\">{timeAgo(timestamp)}</p>\n </div>\n\n {isUnread && (\n <div className=\"h-2 w-2 rounded-full bg-primary shrink-0 mt-2\" />\n )}\n </Link>\n );\n}\n"],"mappings":";AAuCU,mBAEI,KAFJ;AArCV,OAAO,UAAU;AACjB,OAAO,WAAW;AAClB,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,UAAU;AACnB,SAAS,mBAAmB,0BAA0B;AAS/C,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAAyB;AACvB,QAAM,EAAE,MAAM,OAAO,aAAa,OAAO,MAAM,WAAW,SAAS,IAAI;AACvE,QAAM,OAAO,kBAAkB,IAAI,KAAK;AACxC,QAAM,aAAa,mBAAmB,IAAI,KAAK;AAE/C,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,SAAS;AAAA,MACT,WAAW;AAAA,QACT;AAAA,QACA,UAAU,SAAS;AAAA,QACnB,YAAY;AAAA,QACZ;AAAA,MACF;AAAA,MAGA;AAAA,4BAAC,SAAI,WAAU,4BACZ,kBACC,iCACE;AAAA,8BAAC,SAAI,WAAU,uEACb;AAAA,YAAC;AAAA;AAAA,cACC,KAAK;AAAA,cACL,KAAI;AAAA,cACJ,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,WAAU;AAAA,cACV,aAAW;AAAA;AAAA,UACb,GACF;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA;AAAA,cACF;AAAA,cAEA,8BAAC,QAAK,WAAU,eAAc;AAAA;AAAA,UAChC;AAAA,WACF,IAEA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT;AAAA,cACA;AAAA,YACF;AAAA,YAEA,8BAAC,QAAK,WAAU,WAAU;AAAA;AAAA,QAC5B,GAEJ;AAAA,QAEA,qBAAC,SAAI,WAAU,8BACb;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,WAAW,kCAAkC;AAAA,cAC/C;AAAA,cAEC;AAAA;AAAA,UACH;AAAA,UACA,oBAAC,OAAE,WAAU,0CAA0C,uBAAY;AAAA,UACnE,oBAAC,OAAE,WAAU,4CAA4C,kBAAQ,SAAS,GAAE;AAAA,WAC9E;AAAA,QAEC,YACC,oBAAC,SAAI,WAAU,iDAAgD;AAAA;AAAA;AAAA,EAEnE;AAEJ;","names":[]}
|
|
@@ -1,66 +0,0 @@
|
|
|
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 notification_meta_exports = {};
|
|
20
|
-
__export(notification_meta_exports, {
|
|
21
|
-
NOTIFICATION_COLOR: () => NOTIFICATION_COLOR,
|
|
22
|
-
NOTIFICATION_ICON: () => NOTIFICATION_ICON,
|
|
23
|
-
NOTIFICATION_LABEL: () => NOTIFICATION_LABEL
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(notification_meta_exports);
|
|
26
|
-
var import_lucide_react = require("lucide-react");
|
|
27
|
-
const NOTIFICATION_ICON = {
|
|
28
|
-
offer_accepted: import_lucide_react.CheckCircle2,
|
|
29
|
-
asset_received: import_lucide_react.Gift,
|
|
30
|
-
offer: import_lucide_react.HandCoins,
|
|
31
|
-
sale: import_lucide_react.Zap,
|
|
32
|
-
listing: import_lucide_react.Tag,
|
|
33
|
-
mint: import_lucide_react.Sparkles,
|
|
34
|
-
transfer: import_lucide_react.ArrowRightLeft,
|
|
35
|
-
cancelled: import_lucide_react.X,
|
|
36
|
-
announcement: import_lucide_react.Megaphone
|
|
37
|
-
};
|
|
38
|
-
const NOTIFICATION_COLOR = {
|
|
39
|
-
offer_accepted: "text-emerald-400 bg-emerald-500/10",
|
|
40
|
-
asset_received: "text-teal-400 bg-teal-500/10",
|
|
41
|
-
offer: "text-amber-400 bg-amber-500/10",
|
|
42
|
-
sale: "text-violet-400 bg-violet-500/10",
|
|
43
|
-
listing: "text-sky-400 bg-sky-500/10",
|
|
44
|
-
mint: "text-emerald-400 bg-emerald-500/10",
|
|
45
|
-
transfer: "text-slate-400 bg-slate-500/10",
|
|
46
|
-
cancelled: "text-rose-400 bg-rose-500/10",
|
|
47
|
-
announcement: "text-purple-400 bg-purple-500/10"
|
|
48
|
-
};
|
|
49
|
-
const NOTIFICATION_LABEL = {
|
|
50
|
-
offer_accepted: "Offer accepted",
|
|
51
|
-
asset_received: "Asset received",
|
|
52
|
-
offer: "New offer",
|
|
53
|
-
sale: "Sale",
|
|
54
|
-
listing: "Listing",
|
|
55
|
-
mint: "Mint",
|
|
56
|
-
transfer: "Transfer",
|
|
57
|
-
cancelled: "Cancelled",
|
|
58
|
-
announcement: "Announcement"
|
|
59
|
-
};
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
NOTIFICATION_COLOR,
|
|
63
|
-
NOTIFICATION_ICON,
|
|
64
|
-
NOTIFICATION_LABEL
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=notification-meta.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data/notification-meta.ts"],"sourcesContent":["import {\n CheckCircle2, Gift, HandCoins, Megaphone, Zap, Tag, Sparkles, ArrowRightLeft, X,\n} from \"lucide-react\";\nimport type { NotificationType } from \"./notification.js\";\n\nexport const NOTIFICATION_ICON: Record<NotificationType, React.ElementType> = {\n offer_accepted: CheckCircle2,\n asset_received: Gift,\n offer: HandCoins,\n sale: Zap,\n listing: Tag,\n mint: Sparkles,\n transfer: ArrowRightLeft,\n cancelled: X,\n announcement: Megaphone,\n};\n\nexport const NOTIFICATION_COLOR: Record<NotificationType, string> = {\n offer_accepted: \"text-emerald-400 bg-emerald-500/10\",\n asset_received: \"text-teal-400 bg-teal-500/10\",\n offer: \"text-amber-400 bg-amber-500/10\",\n sale: \"text-violet-400 bg-violet-500/10\",\n listing: \"text-sky-400 bg-sky-500/10\",\n mint: \"text-emerald-400 bg-emerald-500/10\",\n transfer: \"text-slate-400 bg-slate-500/10\",\n cancelled: \"text-rose-400 bg-rose-500/10\",\n announcement: \"text-purple-400 bg-purple-500/10\",\n};\n\nexport const NOTIFICATION_LABEL: Record<NotificationType, string> = {\n offer_accepted: \"Offer accepted\",\n asset_received: \"Asset received\",\n offer: \"New offer\",\n sale: \"Sale\",\n listing: \"Listing\",\n mint: \"Mint\",\n transfer: \"Transfer\",\n cancelled: \"Cancelled\",\n announcement: \"Announcement\",\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAEO;AAGA,MAAM,oBAAiE;AAAA,EAC5E,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,OAAgB;AAAA,EAChB,MAAgB;AAAA,EAChB,SAAgB;AAAA,EAChB,MAAgB;AAAA,EAChB,UAAgB;AAAA,EAChB,WAAgB;AAAA,EAChB,cAAgB;AAClB;AAEO,MAAM,qBAAuD;AAAA,EAClE,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,OAAgB;AAAA,EAChB,MAAgB;AAAA,EAChB,SAAgB;AAAA,EAChB,MAAgB;AAAA,EAChB,UAAgB;AAAA,EAChB,WAAgB;AAAA,EAChB,cAAgB;AAClB;AAEO,MAAM,qBAAuD;AAAA,EAClE,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,OAAgB;AAAA,EAChB,MAAgB;AAAA,EAChB,SAAgB;AAAA,EAChB,MAAgB;AAAA,EAChB,UAAgB;AAAA,EAChB,WAAgB;AAAA,EAChB,cAAgB;AAClB;","names":[]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NotificationType } from './notification.cjs';
|
|
2
|
-
|
|
3
|
-
declare const NOTIFICATION_ICON: Record<NotificationType, React.ElementType>;
|
|
4
|
-
declare const NOTIFICATION_COLOR: Record<NotificationType, string>;
|
|
5
|
-
declare const NOTIFICATION_LABEL: Record<NotificationType, string>;
|
|
6
|
-
|
|
7
|
-
export { NOTIFICATION_COLOR, NOTIFICATION_ICON, NOTIFICATION_LABEL };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NotificationType } from './notification.js';
|
|
2
|
-
|
|
3
|
-
declare const NOTIFICATION_ICON: Record<NotificationType, React.ElementType>;
|
|
4
|
-
declare const NOTIFICATION_COLOR: Record<NotificationType, string>;
|
|
5
|
-
declare const NOTIFICATION_LABEL: Record<NotificationType, string>;
|
|
6
|
-
|
|
7
|
-
export { NOTIFICATION_COLOR, NOTIFICATION_ICON, NOTIFICATION_LABEL };
|