@growth-angels/ds-core 1.14.2 → 1.15.1

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.
@@ -8,8 +8,10 @@ export const Carousel = (props) => {
8
8
  const trackRef = useRef(null);
9
9
  const isNavigatingRef = useRef(false);
10
10
  const slides = Children.toArray(children);
11
- const calculatePages = (totalSlides = 0, slidesPerView = 0, step = 1) => {
12
- return Math.max(1, Math.ceil((totalSlides - slidesPerView) / step) + 1);
11
+ const calculatePages = (totalSlides = 0, slidesPerView = 0) => {
12
+ if (slidesPerView <= 0)
13
+ return 1;
14
+ return Math.ceil(totalSlides / slidesPerView);
13
15
  };
14
16
  const [activeSlideIndex, setActiveSlideIndex] = useState(0);
15
17
  const [activeDOMIndex, setActiveDOMIndex] = useState(0);
@@ -33,8 +35,8 @@ export const Carousel = (props) => {
33
35
  useEffect(() => {
34
36
  const currentSlidesPerView = slidesPerView[breakpoint] ??
35
37
  (typeof slidesPerView === "number" ? slidesPerView : slidesPerView.xl ?? 1);
36
- setTotalPages(calculatePages(slides.length, currentSlidesPerView, 1));
37
- }, [breakpoint, slidesPerView]);
38
+ setTotalPages(calculatePages(slides.length, currentSlidesPerView));
39
+ }, [breakpoint, slidesPerView, slides.length]);
38
40
  useEffect(() => {
39
41
  const track = trackRef.current;
40
42
  if (!track)
@@ -8,7 +8,7 @@ export const Tabs = ({ tabs, children, extraClassNames, edit }) => {
8
8
  if (extraClassNames) {
9
9
  classes.push(...extraClassNames);
10
10
  }
11
- return (_jsxs("div", { className: classes.join(" "), children: [_jsx("div", { className: "ga-ds-tabs__list", role: "tablist", children: tabs.map((tab, index) => (_jsx("button", { ref: (el) => (tabsRef.current[index] = el), role: "tab", "aria-selected": activeTab === tab.id, "aria-controls": `ga-ds-tabpanel-${tab.id}`, id: `ga-ds-tab-${tab.id}`, tabIndex: activeTab === tab.id ? 0 : -1, className: `ga-ds-tabs__tab ${activeTab === tab.id ? "ga-ds-tabs__tab--active" : ""}`, onClick: () => setActiveTab(tab.id), children: tab.label }, tab.id))) }), _jsx("div", { className: "ga-ds-tabs__panels", children: !edit
11
+ return (_jsxs("div", { className: classes.join(" "), children: [_jsx("div", { className: "ga-ds-tabs__list", role: "tablist", children: _jsx("div", { className: "ga-ds-tabs__list-container", children: tabs.map((tab, index) => (_jsx("button", { ref: (el) => (tabsRef.current[index] = el), role: "tab", "aria-selected": activeTab === tab.id, "aria-controls": `ga-ds-tabpanel-${tab.id}`, id: `ga-ds-tab-${tab.id}`, tabIndex: activeTab === tab.id ? 0 : -1, className: `ga-ds-tabs__tab ${activeTab === tab.id ? "ga-ds-tabs__tab--active" : ""}`, onClick: () => setActiveTab(tab.id), children: tab.label }, tab.id))) }) }), _jsx("div", { className: "ga-ds-tabs__panels", children: !edit
12
12
  ? Children.toArray(children).map((child) => (_jsx("div", { className: ["ga-ds-tabs__panel", activeTab === child.props.id ? "ga-ds-tabs__panel--active" : ""].join(" "), children: _jsx("div", { role: "tabpanel", id: `ga-ds-tabpanel-${child.props.id}`, "aria-labelledby": `ga-ds-tab-${child.props.id}`, children: child }) }, child.props.id)))
13
13
  : children })] }));
14
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-angels/ds-core",
3
- "version": "1.14.2",
3
+ "version": "1.15.1",
4
4
  "description": "Design system by Growth Angels",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -20,8 +20,9 @@ export const Carousel = (props: CarouselProps) => {
20
20
  const isNavigatingRef = useRef(false)
21
21
  const slides = Children.toArray(children)
22
22
 
23
- const calculatePages = (totalSlides = 0, slidesPerView = 0, step = 1) => {
24
- return Math.max(1, Math.ceil((totalSlides - slidesPerView) / step) + 1)
23
+ const calculatePages = (totalSlides = 0, slidesPerView = 0) => {
24
+ if (slidesPerView <= 0) return 1
25
+ return Math.ceil(totalSlides / slidesPerView)
25
26
  }
26
27
 
27
28
  const [activeSlideIndex, setActiveSlideIndex] = useState(0)
@@ -51,8 +52,8 @@ export const Carousel = (props: CarouselProps) => {
51
52
  (slidesPerView as Record<string, number>)[breakpoint] ??
52
53
  (typeof slidesPerView === "number" ? slidesPerView : (slidesPerView as any).xl ?? 1)
53
54
 
54
- setTotalPages(calculatePages(slides.length, currentSlidesPerView, 1))
55
- }, [breakpoint, slidesPerView])
55
+ setTotalPages(calculatePages(slides.length, currentSlidesPerView))
56
+ }, [breakpoint, slidesPerView, slides.length])
56
57
 
57
58
  useEffect(() => {
58
59
  const track = trackRef.current
@@ -1,7 +1,23 @@
1
1
  .ga-ds-tabs {
2
2
  $this: &;
3
+ &__list-wrapper {
4
+ max-width: 100%;
5
+ overflow: hidden;
6
+ }
3
7
  &__list {
8
+ overflow-x: auto;
9
+ overflow-y: hidden;
10
+ white-space: nowrap;
11
+ -webkit-overflow-scrolling: touch;
12
+ max-width: 100%;
13
+ &::-webkit-scrollbar {
14
+ display: none; // Safari and Chrome
15
+ }
16
+ }
17
+ &__list-container {
4
18
  display: flex;
19
+ flex-wrap: nowrap;
20
+ width: fit-content;
5
21
 
6
22
  #{$this}__tab {
7
23
  background: none;
@@ -9,6 +25,7 @@
9
25
  font-size: inherit;
10
26
  padding: inherit;
11
27
  cursor: pointer;
28
+ width: max-content;
12
29
  }
13
30
  }
14
31
 
@@ -13,21 +13,23 @@ export const Tabs = ({ tabs, children, extraClassNames, edit }: TabsProps) => {
13
13
  return (
14
14
  <div className={classes.join(" ")}>
15
15
  <div className="ga-ds-tabs__list" role="tablist">
16
- {tabs.map((tab, index) => (
17
- <button
18
- key={tab.id}
19
- ref={(el) => (tabsRef.current[index] = el)}
20
- role="tab"
21
- aria-selected={activeTab === tab.id}
22
- aria-controls={`ga-ds-tabpanel-${tab.id}`}
23
- id={`ga-ds-tab-${tab.id}`}
24
- tabIndex={activeTab === tab.id ? 0 : -1}
25
- className={`ga-ds-tabs__tab ${activeTab === tab.id ? "ga-ds-tabs__tab--active" : ""}`}
26
- onClick={() => setActiveTab(tab.id)}
27
- >
28
- {tab.label}
29
- </button>
30
- ))}
16
+ <div className="ga-ds-tabs__list-container">
17
+ {tabs.map((tab, index) => (
18
+ <button
19
+ key={tab.id}
20
+ ref={(el) => (tabsRef.current[index] = el)}
21
+ role="tab"
22
+ aria-selected={activeTab === tab.id}
23
+ aria-controls={`ga-ds-tabpanel-${tab.id}`}
24
+ id={`ga-ds-tab-${tab.id}`}
25
+ tabIndex={activeTab === tab.id ? 0 : -1}
26
+ className={`ga-ds-tabs__tab ${activeTab === tab.id ? "ga-ds-tabs__tab--active" : ""}`}
27
+ onClick={() => setActiveTab(tab.id)}
28
+ >
29
+ {tab.label}
30
+ </button>
31
+ ))}
32
+ </div>
31
33
  </div>
32
34
  <div className="ga-ds-tabs__panels">
33
35
  {!edit