@shoplflow/base 0.26.4 → 0.26.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.
package/dist/index.cjs CHANGED
@@ -3436,6 +3436,122 @@ var Tooltip = (_a) => {
3436
3436
  };
3437
3437
  Tooltip.Content = TooltipContent;
3438
3438
  exports.Tooltip = Tooltip;
3439
+ var PaginationWrapper = styled6__default.default.div`
3440
+ display: flex;
3441
+ align-items: center;
3442
+ width: 100%;
3443
+ justify-content: space-between;
3444
+ `;
3445
+ var StyledPagination = styled6__default.default.nav`
3446
+ display: flex;
3447
+ align-items: center;
3448
+ `;
3449
+ var PageItem = styled6__default.default.button`
3450
+ display: flex;
3451
+ justify-content: center;
3452
+ align-items: center;
3453
+ width: 32px;
3454
+ height: 32px;
3455
+ border-radius: ${exports.borderRadiusTokens.borderRadius08};
3456
+ background-color: ${({ isActive }) => isActive ? exports.colorTokens.neutral300 : exports.colorTokens.neutral0};
3457
+ font-size: 13px;
3458
+ font-weight: ${({ isActive }) => isActive && "600"};
3459
+ line-height: 2;
3460
+ cursor: pointer;
3461
+
3462
+ &:hover {
3463
+ background-color: ${({ isActive }) => isActive ? exports.colorTokens.neutral300 : exports.colorTokens.neutral100};
3464
+ }
3465
+ `;
3466
+ var Ellipsis = styled6__default.default.div`
3467
+ display: flex;
3468
+ justify-content: center;
3469
+ align-items: center;
3470
+ width: 32px;
3471
+ height: 32px;
3472
+ `;
3473
+ var PaginationSizeSelector = ({ data, pageSize, setPageSize }) => {
3474
+ const { selectedItem, handleToggleSelect } = utils.useSelect("SINGLE", data, {
3475
+ key: "value"
3476
+ });
3477
+ const handleClickMenu = (value) => {
3478
+ handleToggleSelect(value);
3479
+ setPageSize(value);
3480
+ };
3481
+ return /* @__PURE__ */ jsxRuntime.jsx(
3482
+ exports.Dropdown,
3483
+ {
3484
+ option: "CLICK",
3485
+ width: "66px",
3486
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(
3487
+ exports.Dropdown.Button,
3488
+ {
3489
+ placeholder: String(pageSize),
3490
+ sizeVar: "S",
3491
+ value: selectedItem && /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { typography: "body1_400", color: "neutral400", children: selectedItem.label })
3492
+ }
3493
+ ),
3494
+ popper: /* @__PURE__ */ jsxRuntime.jsx(exports.Dropdown.Content, { type: "FILL", children: data.map((item) => {
3495
+ const isSelected = item.value === pageSize;
3496
+ return /* @__PURE__ */ jsxRuntime.jsx(exports.Menu, { isSelected, onClick: () => handleClickMenu(item.value), children: item.label }, item.value);
3497
+ }) })
3498
+ }
3499
+ );
3500
+ };
3501
+ var PaginationSizeSelector_default = PaginationSizeSelector;
3502
+ var Pagination = (_a) => {
3503
+ var _b = _a, {
3504
+ currentPage,
3505
+ pageCount = 5,
3506
+ itemsTotalCount,
3507
+ pageSize,
3508
+ previousPage,
3509
+ nextPage,
3510
+ gotoPage,
3511
+ leftSource,
3512
+ rightSource
3513
+ } = _b, rest = __objRest(_b, [
3514
+ "currentPage",
3515
+ "pageCount",
3516
+ "itemsTotalCount",
3517
+ "pageSize",
3518
+ "previousPage",
3519
+ "nextPage",
3520
+ "gotoPage",
3521
+ "leftSource",
3522
+ "rightSource"
3523
+ ]);
3524
+ const pageTotalCount = Math.ceil(itemsTotalCount / Number(pageSize));
3525
+ const showLeftEllipsis = currentPage > pageCount - 1;
3526
+ const showRightEllipsis = currentPage < pageTotalCount && Math.ceil((currentPage + 1) / pageCount) < Math.ceil(pageTotalCount / pageCount);
3527
+ const canPreviousPage = currentPage > 0;
3528
+ const canNextPage = currentPage < pageTotalCount - 1;
3529
+ return /* @__PURE__ */ jsxRuntime.jsxs(PaginationWrapper, __spreadProps(__spreadValues({}, rest), { children: [
3530
+ leftSource ? leftSource : /* @__PURE__ */ jsxRuntime.jsx("div", {}),
3531
+ /* @__PURE__ */ jsxRuntime.jsxs(StyledPagination, { "data-shoplflow": "Pagination", children: [
3532
+ /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", styleVar: "GHOST", disabled: !canPreviousPage, onClick: () => gotoPage(0), children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.FirstPageIcon, color: "neutral400", sizeVar: "S" }) }),
3533
+ /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", styleVar: "GHOST", onClick: previousPage, disabled: !canPreviousPage, children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.LeftArrowIcon, color: "neutral400", sizeVar: "S" }) }),
3534
+ showLeftEllipsis && /* @__PURE__ */ jsxRuntime.jsx(Ellipsis, { children: /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { children: "..." }) }),
3535
+ [...Array(pageTotalCount)].splice(0, pageCount).map(
3536
+ (_, idx) => idx + Math.floor(currentPage / pageCount) * pageCount < pageTotalCount && /* @__PURE__ */ jsxRuntime.jsx(
3537
+ PageItem,
3538
+ {
3539
+ isActive: currentPage === idx + Math.floor(currentPage / pageCount) * pageCount,
3540
+ onClick: () => gotoPage(idx + Math.floor(currentPage / pageCount) * pageCount),
3541
+ children: idx + 1 + Math.floor(currentPage / pageCount) * pageCount
3542
+ },
3543
+ idx
3544
+ )
3545
+ ),
3546
+ showRightEllipsis && /* @__PURE__ */ jsxRuntime.jsx(Ellipsis, { children: /* @__PURE__ */ jsxRuntime.jsx(exports.Text, { children: "..." }) }),
3547
+ /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", styleVar: "GHOST", onClick: nextPage, disabled: !canNextPage, children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.RightArrowIcon, color: "neutral400", sizeVar: "S" }) }),
3548
+ /* @__PURE__ */ jsxRuntime.jsx(exports.IconButton, { sizeVar: "S", styleVar: "GHOST", disabled: !canNextPage, onClick: () => gotoPage(pageTotalCount - 1), children: /* @__PURE__ */ jsxRuntime.jsx(exports.Icon, { iconSource: ShoplAssets.EndPageIcon, color: "neutral400", sizeVar: "S" }) })
3549
+ ] }),
3550
+ rightSource ? rightSource : /* @__PURE__ */ jsxRuntime.jsx("div", {})
3551
+ ] }));
3552
+ };
3553
+ Pagination.SizeSelector = PaginationSizeSelector_default;
3554
+ exports.Pagination = Pagination;
3439
3555
  var SpaceMarginWrapper = styled6__default.default(framerMotion.motion.div)`
3440
3556
  position: relative;
3441
3557
  display: flex;