asma-ui-core 3.138.1 → 3.138.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,48 +1,48 @@
1
- import { cn as s } from "../../../helpers/cn.js";
1
+ import { cn as n } from "../../../helpers/cn.js";
2
2
  import { resolveSx as K } from "../../../helpers/sx.js";
3
- import { ChevronRightIcon as M } from "../../icons/chevron-right-icon/ChevronRightIcon.js";
4
- import { ChevronLeftIcon as V } from "../../icons/chevron-left-icon/ChevronLeftIcon.js";
5
- import { consumerOverrides as q } from "../../../helpers/classOverride.js";
6
- import { TabsContext as z } from "./TabsContext.js";
7
- import { Children as F, cloneElement as G, isValidElement as J, useCallback as b, useLayoutEffect as Q, useMemo as U, useRef as E, useState as A } from "react";
8
- import { jsx as l, jsxs as B } from "react/jsx-runtime";
9
- var I = 120, le = ({ value: n, onChange: m, variant: g = "standard", scrollButtons: w = "auto", centered: j, size: f = "default", className: p, sx: N, children: x }) => {
10
- const i = E(null), a = E(/* @__PURE__ */ new Map()), [h, O] = A({
3
+ import { ChevronRightIcon as V } from "../../icons/chevron-right-icon/ChevronRightIcon.js";
4
+ import { ChevronLeftIcon as q } from "../../icons/chevron-left-icon/ChevronLeftIcon.js";
5
+ import { consumerOverrides as z } from "../../../helpers/classOverride.js";
6
+ import { TabsContext as F } from "./TabsContext.js";
7
+ import { Children as G, cloneElement as J, isValidElement as Q, useCallback as m, useLayoutEffect as U, useMemo as X, useRef as A, useState as B } from "react";
8
+ import { jsx as l, jsxs as I } from "react/jsx-runtime";
9
+ var j = 120, se = ({ value: i, onChange: b, variant: g = "standard", scrollButtons: w = "auto", centered: N, size: f = "default", className: x, sx: O, children: p }) => {
10
+ const a = A(null), s = A(/* @__PURE__ */ new Map()), [h, W] = B({
11
11
  left: 0,
12
12
  width: 0,
13
13
  disabled: !1
14
- }), [c, W] = A({
14
+ }), [c, _] = B({
15
15
  left: !1,
16
16
  right: !1
17
- }), y = g === "scrollable", v = b((e, t) => {
18
- t ? a.current.set(e, t) : a.current.delete(e);
19
- }, []), S = b((e, t) => m?.(e, t), [m]), d = b(() => {
20
- const e = a.current.get(n), t = i.current;
21
- if (e && O({
17
+ }), y = g === "scrollable", v = m((e, t) => {
18
+ t ? s.current.set(e, t) : s.current.delete(e);
19
+ }, []), S = m((e, t) => b?.(e, t), [b]), d = m(() => {
20
+ const e = s.current.get(i), t = a.current;
21
+ if (e && W({
22
22
  left: e.offsetLeft,
23
23
  width: e.offsetWidth,
24
24
  disabled: e.disabled || e.getAttribute("aria-disabled") === "true"
25
25
  }), t) {
26
- const { scrollLeft: o, scrollWidth: r, clientWidth: u } = t;
27
- W({
26
+ const { scrollLeft: o, clientWidth: r } = t, u = Math.max(0, ...Array.from(s.current.values(), (E) => E.offsetLeft + E.offsetWidth));
27
+ _({
28
28
  left: o > 1,
29
- right: o + u < r - 1
29
+ right: o + r < u - 1
30
30
  });
31
31
  }
32
- }, [n]);
33
- Q(() => {
32
+ }, [i]);
33
+ U(() => {
34
34
  d();
35
- const e = i.current;
35
+ const e = a.current;
36
36
  if (!e) return;
37
37
  const t = new ResizeObserver(d);
38
38
  return t.observe(e), () => t.disconnect();
39
- }, [d, x]);
39
+ }, [d, p]);
40
40
  const k = (e) => {
41
- i.current?.scrollBy({
41
+ a.current?.scrollBy({
42
42
  left: e,
43
43
  behavior: "smooth"
44
44
  });
45
- }, _ = (e) => {
45
+ }, D = (e) => {
46
46
  if (![
47
47
  "ArrowRight",
48
48
  "ArrowLeft",
@@ -50,49 +50,49 @@ var I = 120, le = ({ value: n, onChange: m, variant: g = "standard", scrollButto
50
50
  "End"
51
51
  ].includes(e.key)) return;
52
52
  e.preventDefault();
53
- const t = Array.from(a.current.values());
53
+ const t = Array.from(s.current.values());
54
54
  if (t.length === 0) return;
55
55
  const o = t.findIndex((u) => u === document.activeElement);
56
56
  let r = o;
57
57
  e.key === "ArrowRight" ? r = (o + 1) % t.length : e.key === "ArrowLeft" ? r = (o - 1 + t.length) % t.length : e.key === "Home" ? r = 0 : e.key === "End" && (r = t.length - 1), t[r]?.focus();
58
- }, L = y && w !== !1, R = w === !0, D = L && (R || c.left), P = L && (R || c.right), T = q(p, "padding-x"), H = U(() => ({
59
- value: n,
58
+ }, L = y && w !== !1, R = w === !0, M = L && (R || c.left), P = L && (R || c.right), T = z(x, "padding-x"), H = X(() => ({
59
+ value: i,
60
60
  size: f,
61
61
  onSelect: S,
62
62
  register: v
63
63
  }), [
64
- n,
64
+ i,
65
65
  f,
66
66
  S,
67
67
  v
68
68
  ]), C = "flex h-10 w-10 shrink-0 items-center justify-center self-center rounded-[10%] border border-solid border-delta-500 text-delta-700 transition-colors hover:bg-gama-50 disabled:invisible";
69
- return /* @__PURE__ */ l(z.Provider, {
69
+ return /* @__PURE__ */ l(F.Provider, {
70
70
  value: H,
71
- children: /* @__PURE__ */ B("div", {
72
- className: s("relative flex items-center rounded-t-lg bg-white", !T && "px-4", p),
73
- style: K(N),
71
+ children: /* @__PURE__ */ I("div", {
72
+ className: n("relative flex items-center rounded-t-lg bg-white", !T && "px-4", x),
73
+ style: K(O),
74
74
  children: [
75
- D && /* @__PURE__ */ l("button", {
75
+ M && /* @__PURE__ */ l("button", {
76
76
  type: "button",
77
77
  "aria-label": "scroll tabs left",
78
- className: s(C, "mr-2"),
78
+ className: n(C, "mr-2"),
79
79
  disabled: !c.left,
80
- onClick: () => k(-I),
81
- children: /* @__PURE__ */ l(V, {
80
+ onClick: () => k(-j),
81
+ children: /* @__PURE__ */ l(q, {
82
82
  width: 24,
83
83
  height: 24
84
84
  })
85
85
  }),
86
- /* @__PURE__ */ B("div", {
87
- ref: i,
86
+ /* @__PURE__ */ I("div", {
87
+ ref: a,
88
88
  role: "tablist",
89
89
  "aria-orientation": "horizontal",
90
- onKeyDown: _,
90
+ onKeyDown: D,
91
91
  onScroll: d,
92
- className: s("relative flex bg-[linear-gradient(to_top,var(--colors-delta-200)_1px,transparent_1px)] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", y ? "flex-1 overflow-x-auto" : "w-full", g === "fullWidth" && "[&>*]:flex-1", j && "justify-center", f === "small" && "min-h-9"),
93
- children: [F.map(x, (e, t) => J(e) ? G(e, { index: t }) : e), /* @__PURE__ */ l("span", {
92
+ className: n("relative flex bg-[linear-gradient(to_top,var(--colors-delta-200)_1px,transparent_1px)] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", y ? "flex-1 overflow-x-auto" : "w-full", g === "fullWidth" && "[&>*]:flex-1", N && "justify-center", f === "small" && "min-h-9"),
93
+ children: [G.map(p, (e, t) => Q(e) ? J(e, { index: t }) : e), /* @__PURE__ */ l("span", {
94
94
  "aria-hidden": !0,
95
- className: s("absolute bottom-0 h-[3px] transition-all duration-300", h.disabled ? "bg-delta-300" : "bg-gama-500"),
95
+ className: n("absolute bottom-0 h-[3px] transition-all duration-300", h.disabled ? "bg-delta-300" : "bg-gama-500"),
96
96
  style: {
97
97
  left: h.left,
98
98
  width: h.width
@@ -102,10 +102,10 @@ var I = 120, le = ({ value: n, onChange: m, variant: g = "standard", scrollButto
102
102
  P && /* @__PURE__ */ l("button", {
103
103
  type: "button",
104
104
  "aria-label": "scroll tabs right",
105
- className: s(C, "ml-2"),
105
+ className: n(C, "ml-2"),
106
106
  disabled: !c.right,
107
- onClick: () => k(I),
108
- children: /* @__PURE__ */ l(M, {
107
+ onClick: () => k(j),
108
+ children: /* @__PURE__ */ l(V, {
109
109
  width: 24,
110
110
  height: 24
111
111
  })
@@ -115,5 +115,5 @@ var I = 120, le = ({ value: n, onChange: m, variant: g = "standard", scrollButto
115
115
  });
116
116
  };
117
117
  export {
118
- le as StyledTabs
118
+ se as StyledTabs
119
119
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.138.1",
6
+ "version": "3.138.2",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",