@danielcruzcode/ui-core 0.1.4 → 0.1.6

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.
@@ -0,0 +1,52 @@
1
+ const s = {
2
+ color: {
3
+ red: {
4
+ 100: "#FDECEA",
5
+ 500: "#E31837"
6
+ },
7
+ neutral: {
8
+ 0: "#FFFFFF",
9
+ 100: "#F5F5F5",
10
+ 300: "#D1D1D1",
11
+ 700: "#4A4A4A",
12
+ 900: "#1A1A1A"
13
+ },
14
+ green: {
15
+ 100: "#E8F5EA",
16
+ 500: "#0A8920",
17
+ 600: "#077319"
18
+ },
19
+ yellow: {
20
+ 100: "#FEF7E0",
21
+ 500: "#F9AB00"
22
+ }
23
+ },
24
+ space: {
25
+ 2: "8px",
26
+ 4: "16px",
27
+ 6: "24px",
28
+ 8: "32px"
29
+ },
30
+ radius: {
31
+ sm: "4px",
32
+ md: "8px",
33
+ full: "9999px"
34
+ },
35
+ font: {
36
+ family: {
37
+ body: "'DM Sans', sans-serif",
38
+ display: "'Bebas Neue', sans-serif"
39
+ }
40
+ },
41
+ shadow: {
42
+ sm: "0 1px 2px 0 rgba(0,0,0,0.08)",
43
+ md: "0 4px 8px 0 rgba(0,0,0,0.12)"
44
+ },
45
+ transition: {
46
+ fast: "100ms ease",
47
+ normal: "200ms ease"
48
+ }
49
+ };
50
+ export {
51
+ s as primitives
52
+ };
@@ -1,6 +1,6 @@
1
1
  import { jsx as n, jsxs as u, Fragment as h } from "react/jsx-runtime";
2
2
  import f from "@emotion/styled";
3
- import { tokens as o } from "@danielcruzcode/design-tokens";
3
+ import { tokens as o } from "./index.esm14.js";
4
4
  const g = {
5
5
  primary: `background-color:${o.color.brand};color:#fff;border:none;&:hover:not(:disabled){background-color:${o.color.brandHover};}&:active:not(:disabled){background-color:${o.color.brandHover};box-shadow:${o.shadow.sm};}`,
6
6
  secondary: `background-color:transparent;color:${o.color.brand};border:1.5px solid ${o.color.brand};&:hover:not(:disabled){background-color:${o.color.brandSubtle};}`,
@@ -1,6 +1,6 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
2
  import l from "@emotion/styled";
3
- import { tokens as o } from "@danielcruzcode/design-tokens";
3
+ import { tokens as o } from "./index.esm14.js";
4
4
  const t = {
5
5
  brand: `background-color: ${o.color.brandSubtle}; color: ${o.color.brand};`,
6
6
  success: `background-color: ${o.color.successSubtle}; color: ${o.color.success};`,
@@ -1,6 +1,6 @@
1
1
  import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
2
  import t from "@emotion/styled";
3
- import { tokens as o } from "@danielcruzcode/design-tokens";
3
+ import { tokens as o } from "./index.esm14.js";
4
4
  const d = {
5
5
  default: `background-color:${o.color.surface};color:${o.color.text};border:1px solid ${o.color.border};`,
6
6
  brand: `background-color:${o.color.brandSubtle};color:${o.color.brand};border:1px solid ${o.color.brand};`
@@ -1,6 +1,6 @@
1
1
  import { jsxs as a, jsx as n } from "react/jsx-runtime";
2
2
  import e from "@emotion/styled";
3
- import { tokens as o } from "@danielcruzcode/design-tokens";
3
+ import { tokens as o } from "./index.esm14.js";
4
4
  import { useId as I } from "react";
5
5
  const w = e.div`display:flex;flex-direction:column;gap:4px;font-family:${o.font.body};`, z = e.label`font-size:13px;font-weight:500;color:${o.color.text};`, M = e.span`color:${o.color.danger};margin-left:2px;`, S = e.div`
6
6
  display:flex;align-items:center;gap:${o.space.sm};
@@ -1,6 +1,6 @@
1
1
  import { jsxs as c, jsx as r } from "react/jsx-runtime";
2
2
  import n from "@emotion/styled";
3
- import { tokens as o } from "@danielcruzcode/design-tokens";
3
+ import { tokens as o } from "./index.esm14.js";
4
4
  import { useId as m } from "react";
5
5
  const g = n.div`display:flex;flex-direction:column;gap:4px;font-family:${o.font.body};`, $ = n.label`font-size:13px;font-weight:500;color:${o.color.text};`, v = n.div`position:relative;display:flex;align-items:center;`, y = n.select`
6
6
  width:100%;height:40px;padding-inline-start:${o.space.sm};padding-inline-end:36px;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as f, jsx as e } from "react/jsx-runtime";
2
2
  import i from "@emotion/styled";
3
- import { tokens as t } from "@danielcruzcode/design-tokens";
3
+ import { tokens as t } from "./index.esm14.js";
4
4
  import { useId as x, useRef as b, useEffect as k } from "react";
5
5
  const g = i.label`
6
6
  display: inline-flex; align-items: center; gap: ${t.space.sm};
@@ -1,6 +1,6 @@
1
1
  import { jsxs as h, jsx as a } from "react/jsx-runtime";
2
2
  import e from "@emotion/styled";
3
- import { tokens as o } from "@danielcruzcode/design-tokens";
3
+ import { tokens as o } from "./index.esm14.js";
4
4
  const v = { none: "0", sm: o.space.sm, md: o.space.md, lg: o.space.lg }, f = e.article`
5
5
  display:flex;flex-direction:column;background-color:${o.color.background};
6
6
  border-radius:${o.radius.md};border:1px solid ${o.color.border};
@@ -1,76 +1,92 @@
1
- import { jsxs as m, jsx as n, Fragment as C } from "react/jsx-runtime";
2
- import d from "@emotion/styled";
3
- import { tokens as o } from "@danielcruzcode/design-tokens";
4
- import F from "./index.esm14.js";
5
- import { useState as p, useEffect as a, useCallback as N } from "react";
6
- const D = { sm: 8, md: 16, lg: 24, xl: 32 };
7
- function w(r, s) {
8
- return typeof r == "number" ? r : s >= 1024 ? r.desktop : s >= 640 ? r.tablet : r.mobile;
1
+ import { jsxs as y, jsx as o, Fragment as _ } from "react/jsx-runtime";
2
+ import c from "@emotion/styled";
3
+ import { tokens as e } from "./index.esm14.js";
4
+ import G from "./index.esm15.js";
5
+ import { useState as a, useRef as S, useEffect as u, useCallback as P } from "react";
6
+ const X = { sm: 8, md: 16, lg: 24, xl: 32 };
7
+ function Y(r, i) {
8
+ return typeof r == "number" ? r : i >= 1024 ? r.desktop : i >= 640 ? r.tablet : r.mobile;
9
9
  }
10
- const $ = d.button`
10
+ const I = c.button`
11
11
  position:absolute;top:50%;transform:translateY(-50%);z-index:10;
12
12
  display:flex;align-items:center;justify-content:center;
13
- width:36px;height:36px;border-radius:${o.radius.full};
14
- border:1px solid ${o.color.border};background-color:${o.color.background};
15
- color:${o.color.text};cursor:pointer;box-shadow:${o.shadow.sm};
16
- transition:box-shadow ${o.transition.fast};
17
- &:hover{box-shadow:${o.shadow.md};}
18
- &:focus-visible{outline:2px solid ${o.color.borderFocus};outline-offset:2px;}
13
+ width:36px;height:36px;border-radius:${e.radius.full};
14
+ border:1px solid ${e.color.border};background-color:${e.color.background};
15
+ color:${e.color.text};cursor:pointer;box-shadow:${e.shadow.sm};
16
+ transition:box-shadow ${e.transition.fast};
17
+ &:hover{box-shadow:${e.shadow.md};}
18
+ &:focus-visible{outline:2px solid ${e.color.borderFocus};outline-offset:2px;}
19
19
  &:disabled{opacity:0.4;cursor:not-allowed;}
20
- `, T = d($)`left:${o.space.sm};`, _ = d($)`right:${o.space.sm};`, G = d.button`
20
+ `, q = c(I)`left:${e.space.sm};`, H = c(I)`right:${e.space.sm};`, J = c.button`
21
21
  width:${({ active: r }) => r ? "20px" : "8px"};height:8px;
22
- border-radius:${o.radius.full};
23
- background-color:${({ active: r }) => r ? o.color.brand : o.color.border};
22
+ border-radius:${e.radius.full};
23
+ background-color:${({ active: r }) => r ? e.color.brand : e.color.border};
24
24
  border:none;cursor:pointer;padding:0;
25
- transition:background-color ${o.transition.fast},width ${o.transition.fast};
26
- &:focus-visible{outline:2px solid ${o.color.borderFocus};outline-offset:2px;}
27
- `, M = d.div`display:flex;justify-content:center;gap:${o.space.sm};margin-top:${o.space.sm};`;
28
- function J({
25
+ transition:background-color ${e.transition.fast},width ${e.transition.fast};
26
+ &:focus-visible{outline:2px solid ${e.color.borderFocus};outline-offset:2px;}
27
+ `, K = c.div`display:flex;justify-content:center;gap:${e.space.sm};margin-top:${e.space.sm};`;
28
+ function V({
29
29
  children: r,
30
- autoplay: s = !1,
31
- autoplayMs: h = 4e3,
32
- showArrows: k = !0,
33
- showDots: g = !0,
34
- loop: y = !1,
35
- slidesPerView: u = 1,
36
- slidesPerGroup: S = 1,
37
- gap: x,
38
- onSlideChange: c
30
+ autoplay: i = !1,
31
+ autoplayMs: p = 4e3,
32
+ pauseOnHover: h = !0,
33
+ showArrows: L = !0,
34
+ showDots: j = !0,
35
+ loop: R = !1,
36
+ slidesPerView: x = 1,
37
+ slidesPerGroup: W = 1,
38
+ gap: b,
39
+ onSlideChange: d
39
40
  }) {
40
- var v;
41
- const b = x && (v = D[x]) != null ? v : 0, [I, t] = F({ loop: y, slidesToScroll: S, align: "start" }), [L, j] = p(0), [W, E] = p([]), [f, z] = p(() => typeof window != "undefined" ? w(u, window.innerWidth) : 1);
42
- a(() => {
43
- if (typeof window == "undefined") return;
44
- const e = () => z(w(u, window.innerWidth));
45
- return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
46
- }, [u]);
47
- const l = N(() => {
41
+ var w;
42
+ const v = b && (w = X[b]) != null ? w : 0, [B, t] = G({ loop: R, slidesToScroll: W, align: "start" }), [C, E] = a(0), [F, M] = a([]), [m, $] = a(!1), k = S(x);
43
+ k.current = x;
44
+ const g = S(null), [f, N] = a(1);
45
+ u(() => {
46
+ const n = g.current;
47
+ if (!n) return;
48
+ const s = new ResizeObserver(([D]) => {
49
+ const T = D.contentRect.width;
50
+ N(Y(k.current, T));
51
+ });
52
+ return s.observe(n), () => s.disconnect();
53
+ }, []);
54
+ const l = P(() => {
48
55
  if (!t) return;
49
- const e = t.selectedScrollSnap();
50
- j(e), c == null || c(e);
51
- }, [t, c]);
52
- a(() => {
56
+ const n = t.selectedScrollSnap();
57
+ E(n), d == null || d(n);
58
+ }, [t, d]);
59
+ u(() => {
53
60
  if (t)
54
- return E(t.scrollSnapList()), t.on("select", l), t.on("reInit", l), () => {
61
+ return M(t.scrollSnapList()), t.on("select", l), t.on("reInit", l), () => {
55
62
  t.off("select", l), t.off("reInit", l);
56
63
  };
57
- }, [t, l]), a(() => {
64
+ }, [t, l]), u(() => {
58
65
  t == null || t.reInit();
59
- }, [t, f]), a(() => {
60
- if (!s || !t) return;
61
- const e = setInterval(() => t.scrollNext(), h);
62
- return () => clearInterval(e);
63
- }, [s, h, t]);
64
- const B = `calc((100% - ${b * (f - 1)}px) / ${f})`;
65
- return /* @__PURE__ */ m("div", { style: { position: "relative", width: "100%" }, children: [
66
- /* @__PURE__ */ n("div", { ref: I, style: { overflow: "hidden" }, children: /* @__PURE__ */ n("div", { style: { display: "flex", gap: b }, children: r.map((e, i) => /* @__PURE__ */ n("div", { style: { flex: `0 0 ${B}`, minWidth: 0 }, children: e }, i)) }) }),
67
- k && /* @__PURE__ */ m(C, { children: [
68
- /* @__PURE__ */ n(T, { type: "button", "aria-label": "Slide anterior", onClick: () => t == null ? void 0 : t.scrollPrev(), children: /* @__PURE__ */ n("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M10 12L6 8l4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
69
- /* @__PURE__ */ n(_, { type: "button", "aria-label": "Slide siguiente", onClick: () => t == null ? void 0 : t.scrollNext(), children: /* @__PURE__ */ n("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M6 4l4 4-4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
70
- ] }),
71
- g && /* @__PURE__ */ n(M, { children: W.map((e, i) => /* @__PURE__ */ n(G, { active: i === L, type: "button", onClick: () => t == null ? void 0 : t.scrollTo(i), "aria-label": `Ir al slide ${i + 1}` }, i)) })
72
- ] });
66
+ }, [t, f]), u(() => {
67
+ if (!i || !t || h && m) return;
68
+ const n = setInterval(() => t.scrollNext(), p);
69
+ return () => clearInterval(n);
70
+ }, [i, p, t, h, m]);
71
+ const z = `calc((100% - ${v * (f - 1)}px) / ${f})`;
72
+ return /* @__PURE__ */ y(
73
+ "div",
74
+ {
75
+ ref: g,
76
+ style: { position: "relative", width: "100%" },
77
+ onMouseEnter: () => $(!0),
78
+ onMouseLeave: () => $(!1),
79
+ children: [
80
+ /* @__PURE__ */ o("div", { ref: B, style: { overflow: "hidden" }, children: /* @__PURE__ */ o("div", { style: { display: "flex", gap: v }, children: r.map((n, s) => /* @__PURE__ */ o("div", { style: { flex: `0 0 ${z}`, minWidth: 0 }, children: n }, s)) }) }),
81
+ L && /* @__PURE__ */ y(_, { children: [
82
+ /* @__PURE__ */ o(q, { type: "button", "aria-label": "Slide anterior", onClick: () => t == null ? void 0 : t.scrollPrev(), children: /* @__PURE__ */ o("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ o("path", { d: "M10 12L6 8l4-4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
83
+ /* @__PURE__ */ o(H, { type: "button", "aria-label": "Slide siguiente", onClick: () => t == null ? void 0 : t.scrollNext(), children: /* @__PURE__ */ o("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ o("path", { d: "M6 4l4 4-4 4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
84
+ ] }),
85
+ j && /* @__PURE__ */ o(K, { children: F.map((n, s) => /* @__PURE__ */ o(J, { active: s === C, type: "button", onClick: () => t == null ? void 0 : t.scrollTo(s), "aria-label": `Ir al slide ${s + 1}` }, s)) })
86
+ ]
87
+ }
88
+ );
73
89
  }
74
90
  export {
75
- J as Carousel
91
+ V as Carousel
76
92
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielcruzcode/ui-core",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },