impact-nova 1.7.31 → 1.7.32

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,156 +1,160 @@
1
- import { jsxs as c, jsx as t, Fragment as O } from "react/jsx-runtime";
2
- import * as a from "react";
3
- import { ChevronRight as T } from "lucide-react";
4
- import { useVirtualizer as $ } from "@tanstack/react-virtual";
1
+ import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
+ import * as o from "react";
3
+ import { ChevronRight as j } from "lucide-react";
4
+ import { useVirtualizer as I } from "@tanstack/react-virtual";
5
5
  import { cn as h } from "../../../lib/utils.js";
6
- import { Button as A } from "../button.js";
7
- import { useImpactNovaI18n as D } from "../../../i18n/ImpactNovaI18nContext.js";
8
- const F = a.forwardRef(
6
+ import { Button as O } from "../button.js";
7
+ import { useImpactNovaI18n as T } from "../../../i18n/ImpactNovaI18nContext.js";
8
+ const $ = o.forwardRef(
9
9
  ({
10
10
  className: N,
11
- items: u,
12
- renderItem: R,
13
- scrollStep: g = 200,
14
- hideScrollbar: p = !0,
15
- controlsPosition: s = "right",
16
- renderPrevious: v,
17
- renderNext: b,
18
- maxWidth: L = "100%",
11
+ items: d,
12
+ renderItem: C,
13
+ scrollStep: p = 200,
14
+ hideScrollbar: u = !0,
15
+ controlsPosition: v = "right",
16
+ renderPrevious: x,
17
+ renderNext: g,
18
+ maxWidth: R = "100%",
19
19
  estimateSize: m = 200,
20
- overscan: k = 5,
21
- ...C
22
- }, B) => {
23
- const { t: x } = D(), l = a.useRef(null), [n, E] = a.useState(!1), [o, H] = a.useState(!1);
24
- a.useImperativeHandle(B, () => l.current);
25
- const i = $({
26
- count: u.length,
27
- getScrollElement: () => l.current,
20
+ overscan: L = 5,
21
+ ...B
22
+ }, E) => {
23
+ const { t: b } = T(), r = o.useRef(null), [n, H] = o.useState(!1), [s, V] = o.useState(!1);
24
+ o.useImperativeHandle(E, () => r.current);
25
+ const c = I({
26
+ count: d.length,
27
+ getScrollElement: () => r.current,
28
28
  estimateSize: typeof m == "function" ? m : () => m,
29
29
  horizontal: !0,
30
- overscan: k
31
- }), V = i.getTotalSize(), d = a.useCallback(() => {
32
- const e = l.current;
33
- e && (E(e.scrollLeft > 0), H(Math.ceil(e.scrollLeft + e.clientWidth) < e.scrollWidth));
30
+ overscan: L
31
+ }), W = c.getTotalSize(), f = o.useCallback(() => {
32
+ const e = r.current;
33
+ e && (H(e.scrollLeft > 0), V(Math.ceil(e.scrollLeft + e.clientWidth) < e.scrollWidth));
34
34
  }, []);
35
- a.useEffect(() => {
36
- const e = l.current;
35
+ o.useEffect(() => {
36
+ const e = r.current;
37
37
  if (!e) return;
38
- d();
39
- const r = () => d();
40
- e.addEventListener("scroll", r);
41
- const f = new ResizeObserver(() => {
42
- d();
38
+ f();
39
+ const l = () => f();
40
+ e.addEventListener("scroll", l);
41
+ const i = new ResizeObserver(() => {
42
+ f();
43
43
  });
44
- return f.observe(e), () => {
45
- e.removeEventListener("scroll", r), f.disconnect();
44
+ return i.observe(e), () => {
45
+ e.removeEventListener("scroll", l), i.disconnect();
46
46
  };
47
- }, [d, u, V]);
48
- const z = () => {
49
- l.current?.scrollBy({ left: -g, behavior: "smooth" });
50
- }, y = () => {
51
- l.current?.scrollBy({ left: g, behavior: "smooth" });
52
- }, w = ({
47
+ }, [f, d, W]);
48
+ const w = () => {
49
+ r.current?.scrollBy({ left: -p, behavior: "smooth" });
50
+ }, z = () => {
51
+ r.current?.scrollBy({ left: p, behavior: "smooth" });
52
+ }, y = ({
53
53
  direction: e,
54
- onClick: r,
55
- disabled: f
54
+ onClick: l,
55
+ disabled: i
56
56
  }) => {
57
- if (f) return null;
58
- const S = x(e === "left" ? "horizontalScroller.scrollLeft" : "horizontalScroller.scrollRight");
59
- return /* @__PURE__ */ c(
60
- A,
57
+ if (i) return null;
58
+ const k = b(e === "left" ? "horizontalScroller.scrollLeft" : "horizontalScroller.scrollRight");
59
+ return /* @__PURE__ */ a(
60
+ O,
61
61
  {
62
62
  variant: "ghost",
63
63
  size: "icon",
64
64
  className: h(
65
65
  "h-8 w-8 rounded-md bg-canvas-muted text-content-tertiary hover:bg-brand-tint hover:text-brand"
66
66
  ),
67
- onClick: r,
68
- disabled: f,
69
- "aria-label": S,
67
+ onClick: l,
68
+ disabled: i,
69
+ "aria-label": k,
70
70
  "data-component": e === "left" ? "horizontal-scroller-prev" : "horizontal-scroller-next",
71
71
  children: [
72
72
  /* @__PURE__ */ t(
73
- T,
73
+ j,
74
74
  {
75
75
  className: h("h-4 w-4", e === "left" && "rotate-180")
76
76
  }
77
77
  ),
78
- /* @__PURE__ */ t("span", { className: "sr-only", children: S })
78
+ /* @__PURE__ */ t("span", { className: "sr-only", children: k })
79
79
  ]
80
80
  }
81
81
  );
82
- }, W = () => {
83
- const e = v ? v({ onClick: z, disabled: !n }) : /* @__PURE__ */ t(
84
- w,
82
+ }, S = (() => {
83
+ const e = x ? x({ onClick: w, disabled: !n }) : /* @__PURE__ */ t(
84
+ y,
85
85
  {
86
86
  direction: "left",
87
- onClick: z,
87
+ onClick: w,
88
88
  disabled: !n
89
89
  }
90
- ), r = b ? b({ onClick: y, disabled: !o }) : /* @__PURE__ */ t(
91
- w,
90
+ ), l = g ? g({ onClick: z, disabled: !s }) : /* @__PURE__ */ t(
91
+ y,
92
92
  {
93
93
  direction: "right",
94
- onClick: y,
95
- disabled: !o
94
+ onClick: z,
95
+ disabled: !s
96
96
  }
97
97
  );
98
- return s === "split" ? /* @__PURE__ */ c(O, { children: [
99
- /* @__PURE__ */ t("div", { className: "absolute left-0 top-1/2 z-20 -translate-y-1/2", children: e }),
100
- /* @__PURE__ */ t("div", { className: "absolute right-0 top-1/2 z-20 -translate-y-1/2", children: r })
101
- ] }) : s === "left" ? /* @__PURE__ */ c("div", { className: "absolute left-0 top-1/2 z-20 flex -translate-y-1/2 items-center gap-1", children: [
102
- e,
103
- r
104
- ] }) : /* @__PURE__ */ c("div", { className: "absolute right-0 top-1/2 z-20 flex -translate-y-1/2 items-center gap-1", children: [
105
- e,
106
- r
107
- ] });
108
- }, j = () => s === "left" ? n && o ? "pl-20" : n || o ? "pl-12" : "" : s === "split" && n ? "pl-12" : "", I = () => s === "right" ? n && o ? "pr-20" : n || o ? "pr-12" : "" : s === "split" && o ? "pr-12" : "";
109
- return /* @__PURE__ */ c(
98
+ return v === "split" ? {
99
+ left: n ? /* @__PURE__ */ t("div", { className: "flex-shrink-0", children: e }) : null,
100
+ right: s ? /* @__PURE__ */ t("div", { className: "flex-shrink-0", children: l }) : null
101
+ } : v === "left" ? {
102
+ left: n || s ? /* @__PURE__ */ a("div", { className: "flex-shrink-0 flex items-center gap-1", children: [
103
+ e,
104
+ l
105
+ ] }) : null,
106
+ right: null
107
+ } : {
108
+ left: null,
109
+ right: n || s ? /* @__PURE__ */ a("div", { className: "flex-shrink-0 flex items-center gap-1", children: [
110
+ e,
111
+ l
112
+ ] }) : null
113
+ };
114
+ })();
115
+ return /* @__PURE__ */ a(
110
116
  "div",
111
117
  {
112
118
  className: h(
113
- "relative group min-w-0 w-full bg-transparent",
114
- j(),
115
- I(),
119
+ "flex items-center gap-2 min-w-0 w-full bg-transparent",
116
120
  N
117
121
  ),
118
- style: { maxWidth: L },
122
+ style: { maxWidth: R },
119
123
  "data-component": "horizontal-scroller",
120
- ...C,
124
+ ...B,
121
125
  children: [
122
- W(),
126
+ S.left,
123
127
  /* @__PURE__ */ t(
124
128
  "div",
125
129
  {
126
- ref: l,
130
+ ref: r,
127
131
  className: h(
128
- "flex w-full overflow-x-auto overflow-y-hidden whitespace-nowrap",
129
- p && "scrollbar-hide",
132
+ "flex flex-1 min-w-0 overflow-x-auto overflow-y-hidden whitespace-nowrap",
133
+ u && "scrollbar-hide",
130
134
  "scroll-smooth"
131
135
  ),
132
136
  style: {
133
- scrollbarWidth: p ? "none" : "auto",
134
- msOverflowStyle: p ? "none" : "auto"
137
+ scrollbarWidth: u ? "none" : "auto",
138
+ msOverflowStyle: u ? "none" : "auto"
135
139
  },
136
140
  "data-component": "horizontal-scroller-viewport",
137
- children: /* @__PURE__ */ c(
141
+ children: /* @__PURE__ */ a(
138
142
  "div",
139
143
  {
140
144
  style: {
141
- width: `${i.getTotalSize()}px`,
145
+ width: `${c.getTotalSize()}px`,
142
146
  display: "flex",
143
147
  position: "relative"
144
148
  },
145
149
  children: [
146
- /* @__PURE__ */ t("div", { style: { width: `${i.getVirtualItems()[0]?.start ?? 0}px`, flexShrink: 0 } }),
147
- i.getVirtualItems().map((e) => /* @__PURE__ */ t(
150
+ /* @__PURE__ */ t("div", { style: { width: `${c.getVirtualItems()[0]?.start ?? 0}px`, flexShrink: 0 } }),
151
+ c.getVirtualItems().map((e) => /* @__PURE__ */ t(
148
152
  "div",
149
153
  {
150
- ref: i.measureElement,
154
+ ref: c.measureElement,
151
155
  "data-index": e.index,
152
156
  className: "flex-shrink-0",
153
- children: R(u[e.index], e.index)
157
+ children: C(d[e.index], e.index)
154
158
  },
155
159
  e.key
156
160
  ))
@@ -158,13 +162,14 @@ const F = a.forwardRef(
158
162
  }
159
163
  )
160
164
  }
161
- )
165
+ ),
166
+ S.right
162
167
  ]
163
168
  }
164
169
  );
165
170
  }
166
171
  );
167
- F.displayName = "HorizontalScroller";
172
+ $.displayName = "HorizontalScroller";
168
173
  export {
169
- F as default
174
+ $ as default
170
175
  };
@@ -46,4 +46,8 @@ export interface HorizontalScrollerProps<T = any> extends Omit<React.HTMLAttribu
46
46
  * Number of items to render outside visible area. Default 5.
47
47
  */
48
48
  overscan?: number;
49
+ /**
50
+ * Disable virtualization and render all items. Useful for small lists where keyboard navigation is important. Default false.
51
+ */
52
+ disableVirtualization?: boolean;
49
53
  }