@ramme-io/ui 4.2.0 → 4.2.2

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.
@@ -1,38 +1,39 @@
1
1
  import { jsxs as e, jsx as t } from "react/jsx-runtime";
2
- import { useState as c, useEffect as g } from "react";
3
- import { Card as N, CardHeader as b, CardTitle as y, CardContent as v } from "../../layout/Card.js";
4
- import { Icon as s } from "../../ui/Icon.js";
5
- const d = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, U = ({ params: f }) => {
6
- const { ticker: i } = f, [r, x] = c(null), [l, m] = c(!0), [o, p] = c(null);
7
- g(() => {
2
+ import { apiBaseUrl as g } from "../../../utils/apiBaseUrl.js";
3
+ import { useState as c, useEffect as h } from "react";
4
+ import { Card as N, CardHeader as b, CardTitle as v, CardContent as y } from "../../layout/Card.js";
5
+ import { Icon as i } from "../../ui/Icon.js";
6
+ const E = ({ params: u }) => {
7
+ const { ticker: s } = u, [r, x] = c(null), [d, m] = c(!0), [o, l] = c(null);
8
+ h(() => {
8
9
  (async () => {
9
10
  try {
10
- m(!0), p(null);
11
- const a = (d == null ? void 0 : d.VITE_API_URL) ?? "http://localhost:8000", u = await fetch(`${a}/companies/${i.toUpperCase()}/hydrate-quote`);
12
- if (!u.ok)
13
- throw new Error(`No quote data available for ${i.toUpperCase()}`);
14
- const h = await u.json();
15
- x(h);
16
- } catch (a) {
17
- p(a instanceof Error ? a.message : "Failed to fetch quote");
11
+ m(!0), l(null);
12
+ const n = g(), p = await fetch(`${n}/companies/${s.toUpperCase()}/hydrate-quote`);
13
+ if (!p.ok)
14
+ throw new Error(`No quote data available for ${s.toUpperCase()}`);
15
+ const f = await p.json();
16
+ x(f);
17
+ } catch (n) {
18
+ l(n instanceof Error ? n.message : "Failed to fetch quote");
18
19
  } finally {
19
20
  m(!1);
20
21
  }
21
22
  })();
22
- }, [i]);
23
- const n = r && r.change_percent >= 0;
23
+ }, [s]);
24
+ const a = r && r.change_percent >= 0;
24
25
  return /* @__PURE__ */ e(N, { className: "w-full min-w-[280px] max-w-md shadow-lg border-primary/20", children: [
25
- /* @__PURE__ */ t(b, { className: "pb-3", children: /* @__PURE__ */ e(y, { className: "text-sm font-medium text-muted-foreground flex items-center gap-2", children: [
26
- /* @__PURE__ */ t(s, { name: "trending-up", size: 14 }),
26
+ /* @__PURE__ */ t(b, { className: "pb-3", children: /* @__PURE__ */ e(v, { className: "text-sm font-medium text-muted-foreground flex items-center gap-2", children: [
27
+ /* @__PURE__ */ t(i, { name: "trending-up", size: 14 }),
27
28
  "Live Quote"
28
29
  ] }) }),
29
- /* @__PURE__ */ e(v, { className: "pt-0", children: [
30
- l && /* @__PURE__ */ t("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ t(s, { name: "loader", size: 24, className: "animate-spin text-muted-foreground" }) }),
30
+ /* @__PURE__ */ e(y, { className: "pt-0", children: [
31
+ d && /* @__PURE__ */ t("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ t(i, { name: "loader", size: 24, className: "animate-spin text-muted-foreground" }) }),
31
32
  o && /* @__PURE__ */ e("div", { className: "flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: [
32
- /* @__PURE__ */ t(s, { name: "alert-circle", size: 14, className: "mt-px shrink-0" }),
33
+ /* @__PURE__ */ t(i, { name: "alert-circle", size: 14, className: "mt-px shrink-0" }),
33
34
  /* @__PURE__ */ t("span", { children: o })
34
35
  ] }),
35
- r && !l && !o && /* @__PURE__ */ e("div", { className: "space-y-3", children: [
36
+ r && !d && !o && /* @__PURE__ */ e("div", { className: "space-y-3", children: [
36
37
  /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ t("span", { className: "px-2.5 py-1 rounded-md bg-primary/10 border border-primary/20 font-mono text-sm font-semibold text-primary", children: r.ticker }) }),
37
38
  /* @__PURE__ */ e("div", { className: "space-y-1", children: [
38
39
  /* @__PURE__ */ e("div", { className: "flex items-baseline gap-2", children: [
@@ -43,8 +44,8 @@ const d = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, U =
43
44
  maximumFractionDigits: 2
44
45
  })
45
46
  ] }),
46
- /* @__PURE__ */ e("span", { className: `text-lg font-semibold ${n ? "text-green-500" : "text-red-500"}`, children: [
47
- n ? "+" : "",
47
+ /* @__PURE__ */ e("span", { className: `text-lg font-semibold ${a ? "text-green-500" : "text-red-500"}`, children: [
48
+ a ? "+" : "",
48
49
  r.change_percent.toFixed(2),
49
50
  "%"
50
51
  ] })
@@ -59,14 +60,14 @@ const d = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, U =
59
60
  })
60
61
  ] })
61
62
  ] }),
62
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2 pt-2 border-t border-border/40", children: /* @__PURE__ */ e("div", { className: `flex items-center gap-1.5 text-xs font-medium ${n ? "text-green-500" : "text-red-500"}`, children: [
63
- /* @__PURE__ */ t(s, { name: n ? "trending-up" : "trending-down", size: 14 }),
64
- /* @__PURE__ */ t("span", { children: n ? "Gaining" : "Declining" })
63
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-2 pt-2 border-t border-border/40", children: /* @__PURE__ */ e("div", { className: `flex items-center gap-1.5 text-xs font-medium ${a ? "text-green-500" : "text-red-500"}`, children: [
64
+ /* @__PURE__ */ t(i, { name: a ? "trending-up" : "trending-down", size: 14 }),
65
+ /* @__PURE__ */ t("span", { children: a ? "Gaining" : "Declining" })
65
66
  ] }) })
66
67
  ] })
67
68
  ] })
68
69
  ] });
69
70
  };
70
71
  export {
71
- U as LiveQuoteCard
72
+ E as LiveQuoteCard
72
73
  };
@@ -1,41 +1,42 @@
1
1
  import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { useState as i, useEffect as g } from "react";
2
+ import { apiBaseUrl as h } from "../../../utils/apiBaseUrl.js";
3
+ import { useState as l, useEffect as g } from "react";
3
4
  import { Card as N, CardHeader as b, CardTitle as w, CardContent as y } from "../../layout/Card.js";
4
- import { Icon as s } from "../../ui/Icon.js";
5
- const d = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, k = ({ params: u }) => {
6
- const { ticker: a } = u, [c, x] = i([]), [l, m] = i(!0), [n, p] = i(null);
5
+ import { Icon as a } from "../../ui/Icon.js";
6
+ const _ = ({ params: f }) => {
7
+ const { ticker: s } = f, [c, x] = l([]), [i, d] = l(!0), [n, m] = l(null);
7
8
  return g(() => {
8
9
  (async () => {
9
10
  try {
10
- m(!0), p(null);
11
- const o = (d == null ? void 0 : d.VITE_API_URL) ?? "http://localhost:8000", f = await fetch(`${o}/companies/${a.toUpperCase()}/news?limit=5`);
12
- if (!f.ok)
13
- throw new Error(`No news available for ${a.toUpperCase()}`);
14
- const h = await f.json();
15
- x(h);
11
+ d(!0), m(null);
12
+ const o = h(), p = await fetch(`${o}/companies/${s.toUpperCase()}/news?limit=5`);
13
+ if (!p.ok)
14
+ throw new Error(`No news available for ${s.toUpperCase()}`);
15
+ const u = await p.json();
16
+ x(u);
16
17
  } catch (o) {
17
- p(o instanceof Error ? o.message : "Failed to fetch news");
18
+ m(o instanceof Error ? o.message : "Failed to fetch news");
18
19
  } finally {
19
- m(!1);
20
+ d(!1);
20
21
  }
21
22
  })();
22
- }, [a]), /* @__PURE__ */ t(N, { className: "w-full min-w-[320px] max-w-2xl shadow-lg border-primary/20", children: [
23
+ }, [s]), /* @__PURE__ */ t(N, { className: "w-full min-w-[320px] max-w-2xl shadow-lg border-primary/20", children: [
23
24
  /* @__PURE__ */ e(b, { className: "pb-3", children: /* @__PURE__ */ t(w, { className: "text-sm font-medium text-muted-foreground flex items-center gap-2", children: [
24
- /* @__PURE__ */ e(s, { name: "newspaper", size: 14 }),
25
+ /* @__PURE__ */ e(a, { name: "newspaper", size: 14 }),
25
26
  "Recent News · ",
26
- a.toUpperCase()
27
+ s.toUpperCase()
27
28
  ] }) }),
28
29
  /* @__PURE__ */ t(y, { className: "pt-0", children: [
29
- l && /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ e(s, { name: "loader", size: 24, className: "animate-spin text-muted-foreground" }) }),
30
+ i && /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ e(a, { name: "loader", size: 24, className: "animate-spin text-muted-foreground" }) }),
30
31
  n && /* @__PURE__ */ t("div", { className: "flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive", children: [
31
- /* @__PURE__ */ e(s, { name: "alert-circle", size: 14, className: "mt-px shrink-0" }),
32
+ /* @__PURE__ */ e(a, { name: "alert-circle", size: 14, className: "mt-px shrink-0" }),
32
33
  /* @__PURE__ */ e("span", { children: n })
33
34
  ] }),
34
- c.length === 0 && !l && !n && /* @__PURE__ */ t("div", { className: "flex flex-col items-center justify-center py-8 gap-2 text-muted-foreground", children: [
35
- /* @__PURE__ */ e(s, { name: "inbox", size: 24, opacity: 0.5 }),
35
+ c.length === 0 && !i && !n && /* @__PURE__ */ t("div", { className: "flex flex-col items-center justify-center py-8 gap-2 text-muted-foreground", children: [
36
+ /* @__PURE__ */ e(a, { name: "inbox", size: 24, opacity: 0.5 }),
36
37
  /* @__PURE__ */ e("p", { className: "text-sm", children: "No recent news available" })
37
38
  ] }),
38
- c.length > 0 && !l && !n && /* @__PURE__ */ e("div", { className: "space-y-3", children: c.map((r) => /* @__PURE__ */ e(
39
+ c.length > 0 && !i && !n && /* @__PURE__ */ e("div", { className: "space-y-3", children: c.map((r) => /* @__PURE__ */ e(
39
40
  "div",
40
41
  {
41
42
  className: "border-b border-border/50 pb-3 last:border-0 last:pb-0",
@@ -64,7 +65,7 @@ const d = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, k =
64
65
  ] })
65
66
  ] })
66
67
  ] }),
67
- r.url && /* @__PURE__ */ e(s, { name: "external-link", size: 12, className: "text-muted-foreground/50 flex-shrink-0 mt-0.5" })
68
+ r.url && /* @__PURE__ */ e(a, { name: "external-link", size: 12, className: "text-muted-foreground/50 flex-shrink-0 mt-0.5" })
68
69
  ] })
69
70
  },
70
71
  r.id
@@ -73,5 +74,5 @@ const d = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, k =
73
74
  ] });
74
75
  };
75
76
  export {
76
- k as NewsSummaryCard
77
+ _ as NewsSummaryCard
77
78
  };
@@ -0,0 +1 @@
1
+ export {};