@charcoal-ui/react-sandbox 3.2.0 → 3.3.0
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.
- package/dist/components/Carousel/index.story.d.ts +1 -1
- package/dist/components/CarouselButton/index.story.d.ts +1 -1
- package/dist/components/Pager/index.d.ts +2 -1
- package/dist/components/Pager/index.d.ts.map +1 -1
- package/dist/components/Pager/index.story.d.ts +8 -0
- package/dist/components/Pager/index.story.d.ts.map +1 -1
- package/dist/foundation/{contants.d.ts → constants.d.ts} +1 -1
- package/dist/foundation/constants.d.ts.map +1 -0
- package/dist/index.cjs.js +33 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +33 -18
- package/dist/index.esm.js.map +1 -1
- package/package.json +16 -15
- package/src/components/Carousel/index.tsx +7 -7
- package/src/components/Filter/index.story.tsx +1 -1
- package/src/components/Layout/index.tsx +1 -1
- package/src/components/MenuListItem/index.story.tsx +1 -1
- package/src/components/Pager/index.story.tsx +54 -6
- package/src/components/Pager/index.tsx +31 -11
- package/src/index.ts +1 -1
- package/dist/foundation/contants.d.ts.map +0 -1
- /package/src/foundation/{contants.ts → constants.ts} +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -303,7 +303,7 @@ import { useContext } from "react";
|
|
|
303
303
|
import * as React2 from "react";
|
|
304
304
|
import styled6, { createGlobalStyle, css as css3 } from "styled-components";
|
|
305
305
|
|
|
306
|
-
// src/foundation/
|
|
306
|
+
// src/foundation/constants.ts
|
|
307
307
|
import { columnSystem, COLUMN_UNIT, GUTTER_UNIT } from "@charcoal-ui/foundation";
|
|
308
308
|
var MAIN_COLUMN_HORIZONTAL_MIN_MARGIN = 72;
|
|
309
309
|
var RESPONSIVE_LEFT_WIDTH = columnSystem(2, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT;
|
|
@@ -1374,12 +1374,12 @@ function Carousel({
|
|
|
1374
1374
|
animation.current = true;
|
|
1375
1375
|
}, [animation, scrollLeft, set, scrollAmountCoef, setScrollLeft]);
|
|
1376
1376
|
useEffect2(() => {
|
|
1377
|
-
const
|
|
1378
|
-
const
|
|
1379
|
-
if (
|
|
1380
|
-
setLeftShow(
|
|
1381
|
-
setRightShow(
|
|
1382
|
-
onScrollStateChange?.(
|
|
1377
|
+
const newLeftShow = scrollLeft > 0;
|
|
1378
|
+
const newRightShow = scrollLeft < maxScrollLeft && maxScrollLeft > 0;
|
|
1379
|
+
if (newLeftShow !== leftShow || newRightShow !== rightShow) {
|
|
1380
|
+
setLeftShow(newLeftShow);
|
|
1381
|
+
setRightShow(newRightShow);
|
|
1382
|
+
onScrollStateChange?.(newLeftShow || newRightShow);
|
|
1383
1383
|
}
|
|
1384
1384
|
}, [leftShow, maxScrollLeft, onScrollStateChange, rightShow, scrollLeft]);
|
|
1385
1385
|
const handleScroll = useCallback2(() => {
|
|
@@ -1680,27 +1680,32 @@ var StyledPolyline = styled15.polyline`
|
|
|
1680
1680
|
// src/components/Pager/index.tsx
|
|
1681
1681
|
import { useComponentAbstraction as useComponentAbstraction4 } from "@charcoal-ui/react";
|
|
1682
1682
|
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1683
|
-
function usePagerWindow(page, pageCount,
|
|
1683
|
+
function usePagerWindow(page, pageCount, pageRangeDisplayed = 7) {
|
|
1684
1684
|
if (process.env.NODE_ENV !== "production") {
|
|
1685
|
-
warning((page | 0) === page, `\`page\` must be
|
|
1685
|
+
warning((page | 0) === page, `\`page\` must be integer (${page})`);
|
|
1686
1686
|
warning(
|
|
1687
1687
|
(pageCount | 0) === pageCount,
|
|
1688
|
-
`\`pageCount\` must be
|
|
1688
|
+
`\`pageCount\` must be integer (${pageCount})`
|
|
1689
1689
|
);
|
|
1690
|
+
warning(
|
|
1691
|
+
(pageRangeDisplayed | 0) === pageRangeDisplayed,
|
|
1692
|
+
`\`pageRangeDisplayed\` must be integer (${pageRangeDisplayed})`
|
|
1693
|
+
);
|
|
1694
|
+
warning(pageRangeDisplayed > 2, `\`windowSize\` must be greater than 2`);
|
|
1690
1695
|
}
|
|
1691
1696
|
const window2 = useMemo2(() => {
|
|
1692
1697
|
const visibleFirstPage = 1;
|
|
1693
1698
|
const visibleLastPage = Math.min(
|
|
1694
1699
|
pageCount,
|
|
1695
|
-
Math.max(page + Math.floor(
|
|
1700
|
+
Math.max(page + Math.floor(pageRangeDisplayed / 2), pageRangeDisplayed)
|
|
1696
1701
|
);
|
|
1697
|
-
if (visibleLastPage <=
|
|
1702
|
+
if (visibleLastPage <= pageRangeDisplayed) {
|
|
1698
1703
|
return Array.from(
|
|
1699
1704
|
{ length: 1 + visibleLastPage - visibleFirstPage },
|
|
1700
1705
|
(_, i) => visibleFirstPage + i
|
|
1701
1706
|
);
|
|
1702
1707
|
} else {
|
|
1703
|
-
const start = visibleLastPage - (
|
|
1708
|
+
const start = visibleLastPage - (pageRangeDisplayed - 1) + 2;
|
|
1704
1709
|
return [
|
|
1705
1710
|
visibleFirstPage,
|
|
1706
1711
|
"...",
|
|
@@ -1710,12 +1715,17 @@ function usePagerWindow(page, pageCount, windowSize = 7) {
|
|
|
1710
1715
|
)
|
|
1711
1716
|
];
|
|
1712
1717
|
}
|
|
1713
|
-
}, [page, pageCount,
|
|
1718
|
+
}, [page, pageCount, pageRangeDisplayed]);
|
|
1714
1719
|
useDebugValue2(window2);
|
|
1715
1720
|
return window2;
|
|
1716
1721
|
}
|
|
1717
|
-
var Pager_default = memo2(function Pager({
|
|
1718
|
-
|
|
1722
|
+
var Pager_default = memo2(function Pager({
|
|
1723
|
+
page,
|
|
1724
|
+
pageCount,
|
|
1725
|
+
pageRangeDisplayed,
|
|
1726
|
+
onChange
|
|
1727
|
+
}) {
|
|
1728
|
+
const window2 = usePagerWindow(page, pageCount, pageRangeDisplayed);
|
|
1719
1729
|
const makeClickHandler = useCallback3(
|
|
1720
1730
|
(value) => () => {
|
|
1721
1731
|
onChange(value);
|
|
@@ -1752,9 +1762,14 @@ var Pager_default = memo2(function Pager({ page, pageCount, onChange }) {
|
|
|
1752
1762
|
)
|
|
1753
1763
|
] });
|
|
1754
1764
|
});
|
|
1755
|
-
function LinkPager({
|
|
1765
|
+
function LinkPager({
|
|
1766
|
+
page,
|
|
1767
|
+
pageCount,
|
|
1768
|
+
pageRangeDisplayed,
|
|
1769
|
+
makeUrl
|
|
1770
|
+
}) {
|
|
1756
1771
|
const { Link } = useComponentAbstraction4();
|
|
1757
|
-
const window2 = usePagerWindow(page, pageCount);
|
|
1772
|
+
const window2 = usePagerWindow(page, pageCount, pageRangeDisplayed);
|
|
1758
1773
|
const hasNext = page < pageCount;
|
|
1759
1774
|
const hasPrev = page > 1;
|
|
1760
1775
|
return /* @__PURE__ */ jsxs8(PagerContainer, { children: [
|