@nulogy/components 13.0.0 → 13.1.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/main.js CHANGED
@@ -50056,6 +50056,7 @@
50056
50056
  "expand row": "Zeile erweitern",
50057
50057
  "go to next results": "Zu den n\xE4chsten Ergebnissen wechseln",
50058
50058
  "go to page": "Zu Seite {{count}} wechseln",
50059
+ "current page of total": "Seite {{currentPage}} von {{totalPages}}",
50059
50060
  "go to previous results": "Zu den vorherigen Ergebnissen wechseln",
50060
50061
  "go to": "Wechseln zu",
50061
50062
  "hide actions": "Aktionen verbergen",
@@ -50098,6 +50099,7 @@
50098
50099
  "expand row": "Expand row",
50099
50100
  "go to next results": "Go to next results",
50100
50101
  "go to page": "Go to page {{count}}",
50102
+ "current page of total": "Page {{currentPage}} of {{totalPages}}",
50101
50103
  "go to previous results": "Go to previous results",
50102
50104
  "go to": "Go to",
50103
50105
  "hide actions": "Hide actions",
@@ -50182,6 +50184,7 @@
50182
50184
  "expand row": "D\xE9velopper la ligne",
50183
50185
  "go to next results": "Aller aux r\xE9sultats suivants",
50184
50186
  "go to page": "Aller \xE0 la page {{count}}",
50187
+ "current page of total": "Page {{currentPage}} sur {{totalPages}}",
50185
50188
  "go to previous results": "Aller aux r\xE9sultats pr\xE9c\xE9dents",
50186
50189
  "go to": "Aller \xE0",
50187
50190
  "hide actions": "Masquer les actions",
@@ -50224,6 +50227,7 @@
50224
50227
  "expand row": "Rij uitvouwen",
50225
50228
  "go to next results": "Ga naar volgende resultaten",
50226
50229
  "go to page": "Ga naar pagina {{count}}",
50230
+ "current page of total": "Pagina {{currentPage}} van {{totalPages}}",
50227
50231
  "go to previous results": "Ga naar vorige resultaten",
50228
50232
  "go to": "Ga naar",
50229
50233
  "hide actions": "Acties verbergen",
@@ -50266,6 +50270,7 @@
50266
50270
  "expand row": "Rozwi\u0144 wiersz",
50267
50271
  "go to next results": "Przejd\u017A do nast\u0119pnych wynik\xF3w",
50268
50272
  "go to page": "Przejd\u017A do strony {{count}}",
50273
+ "current page of total": "Strona {{currentPage}} z {{totalPages}}",
50269
50274
  "go to previous results": "Przejd\u017A do poprzednich wynik\xF3w",
50270
50275
  "go to": "Przejd\u017A do",
50271
50276
  "hide actions": "Hide actions",
@@ -50308,6 +50313,7 @@
50308
50313
  "expand row": "Expandir fila",
50309
50314
  "go to next results": "Ir para resultados seguintes",
50310
50315
  "go to page": "Ir para p\xE1gina {{count}}",
50316
+ "current page of total": "P\xE1gina {{currentPage}} de {{totalPages}}",
50311
50317
  "go to previous results": "Ir para resultados anteriores",
50312
50318
  "go to": "Ir para",
50313
50319
  "hide actions": "Ocultar a\xE7\xF5es",
@@ -50350,6 +50356,7 @@
50350
50356
  "expand row": "Extindere r\xE2nd",
50351
50357
  "go to next results": "Merge\u021Bi la urm\u0103toarele rezultate",
50352
50358
  "go to page": "Merge\u021Bi la pagina {{count}}",
50359
+ "current page of total": "Pagina {{currentPage}} din {{totalPages}}",
50353
50360
  "go to previous results": "Merge\u021Bi la rezultatele anterioare",
50354
50361
  "go to": "Merge\u021Bi la",
50355
50362
  "hide actions": "Ascundere ac\u021Biuni",
@@ -50392,6 +50399,7 @@
50392
50399
  "expand row": "\u5C55\u5F00\u884C",
50393
50400
  "go to next results": "\u8BBF\u95EE\u4E4B\u540E\u7684\u7ED3\u679C",
50394
50401
  "go to page": "\u8BBF\u95EE\u7B2C {{count}} \u9875 ",
50402
+ "current page of total": "\u7B2C {{currentPage}} \u9875\uFF0C\u5171 {{totalPages}} \u9875",
50395
50403
  "go to previous results": "\u8BBF\u95EE\u4E4B\u524D\u7684\u7ED3\u679C",
50396
50404
  "go to": "\u8BBF\u95EE ",
50397
50405
  "hide actions": "\u9690\u85CF\u64CD\u4F5C",
@@ -51373,15 +51381,19 @@
51373
51381
  })(function (_ref) {
51374
51382
  var theme = _ref.theme,
51375
51383
  disabled = _ref.disabled,
51376
- currentPage = _ref.currentPage;
51384
+ currentPage = _ref.currentPage,
51385
+ iconOnly = _ref.iconOnly;
51377
51386
  return {
51378
51387
  fontSize: theme.fontSizes.small,
51379
- padding: theme.space.x1 + " " + theme.space.x2,
51388
+ padding: iconOnly ? theme.space.x1 : theme.space.x1 + " " + theme.space.x2,
51380
51389
  lineHeight: theme.lineHeights.smallTextBase,
51381
51390
  display: "flex",
51391
+ alignItems: "center",
51392
+ justifyContent: "center",
51382
51393
  borderRadius: theme.radii.medium,
51383
51394
  border: "1px solid " + (currentPage ? theme.colors.darkBlue : theme.colors.lightGrey),
51384
51395
  color: disabled ? theme.colors.grey : theme.colors.black,
51396
+ minWidth: iconOnly ? theme.space.x4 : "auto",
51385
51397
  "&:not(:last-child)": {
51386
51398
  marginRight: theme.space.x2
51387
51399
  },
@@ -51410,67 +51422,135 @@
51410
51422
  _ref$onClick = _ref.onClick,
51411
51423
  onClick = _ref$onClick === void 0 ? null : _ref$onClick,
51412
51424
  label = _ref.label,
51413
- ariaLabel = _ref.ariaLabel;
51425
+ ariaLabel = _ref.ariaLabel,
51426
+ showIconOnly = _ref.showIconOnly;
51414
51427
 
51415
51428
  var _useTranslation = useTranslation(),
51416
51429
  t = _useTranslation.t;
51417
51430
 
51431
+ var theme = styled.useTheme();
51418
51432
  return /*#__PURE__*/React__default["default"].createElement(PaginationButton, {
51419
51433
  disabled: disabled,
51420
51434
  onClick: onClick,
51421
- "aria-label": ariaLabel || t("go to previous results")
51435
+ "aria-label": ariaLabel || t("go to previous results"),
51436
+ iconOnly: showIconOnly
51422
51437
  }, /*#__PURE__*/React__default["default"].createElement(Icon, {
51423
51438
  icon: "leftArrow",
51424
- ml: "-8px"
51425
- }), " ", label || t("previous"));
51439
+ ml: showIconOnly ? "0" : "-" + theme.space.x1
51440
+ }), !showIconOnly && (label || t("previous")));
51426
51441
  };
51427
51442
 
51428
51443
  var NextButton = function NextButton(_ref) {
51429
51444
  var disabled = _ref.disabled,
51430
51445
  onClick = _ref.onClick,
51431
51446
  label = _ref.label,
51432
- ariaLabel = _ref.ariaLabel;
51447
+ ariaLabel = _ref.ariaLabel,
51448
+ showIconOnly = _ref.showIconOnly;
51433
51449
 
51434
51450
  var _useTranslation = useTranslation(),
51435
51451
  t = _useTranslation.t;
51436
51452
 
51453
+ var theme = styled.useTheme();
51437
51454
  return /*#__PURE__*/React__default["default"].createElement(PaginationButton, {
51438
51455
  disabled: disabled,
51439
51456
  onClick: onClick,
51440
- "aria-label": ariaLabel || t("go to next results")
51441
- }, label || t("next"), " ", /*#__PURE__*/React__default["default"].createElement(Icon, {
51457
+ "aria-label": ariaLabel || t("go to next results"),
51458
+ iconOnly: showIconOnly
51459
+ }, !showIconOnly && (label || t("next")), /*#__PURE__*/React__default["default"].createElement(Icon, {
51442
51460
  icon: "rightArrow",
51443
- mr: "-8px"
51461
+ mr: showIconOnly ? "0" : "-" + theme.space.x1
51444
51462
  }));
51445
51463
  };
51446
51464
 
51447
- var SEPARATOR = "...";
51448
- var getPageItemsToDisplay = function getPageItemsToDisplay(totalPages, currentPage) {
51449
- var MAX_PAGES_TO_SHOW = 6;
51450
- var pages = Array.from({
51451
- length: totalPages
51452
- }, function (v, i) {
51453
- return i + 1;
51454
- });
51455
- if (totalPages <= MAX_PAGES_TO_SHOW) return pages;
51465
+ var PaginationCount = function PaginationCount(_ref) {
51466
+ var currentPage = _ref.currentPage,
51467
+ totalPages = _ref.totalPages;
51456
51468
 
51457
- if (currentPage <= MAX_PAGES_TO_SHOW - 1) {
51458
- return [].concat(pages.slice(0, 5), [SEPARATOR, totalPages]);
51469
+ var _useTranslation = useTranslation(),
51470
+ t = _useTranslation.t;
51471
+
51472
+ return /*#__PURE__*/React__default["default"].createElement(Text, {
51473
+ fontSize: "small",
51474
+ lineHeight: "smallTextBase",
51475
+ mx: "x2"
51476
+ }, t("current page of total", {
51477
+ currentPage: currentPage,
51478
+ totalPages: totalPages
51479
+ }));
51480
+ };
51481
+
51482
+ function validateAndSetMaxVisiblePages(maxVisiblePages) {
51483
+ if (maxVisiblePages < 3) {
51484
+ console.error("Pagination maxVisiblePages prop must larger than 2. Value changed to 3.");
51485
+ return 3;
51459
51486
  }
51460
51487
 
51461
- if (currentPage > totalPages - 5) {
51462
- return [1, SEPARATOR].concat(pages.slice(totalPages - 5));
51488
+ if (maxVisiblePages > 12) {
51489
+ console.error("Pagination maxVisiblePages prop must smaller than 13. Value changed to 12.");
51490
+ return 12;
51463
51491
  }
51464
51492
 
51465
- return [1, SEPARATOR].concat(pages.slice(currentPage - 2, currentPage + 2), [SEPARATOR, totalPages]);
51466
- };
51493
+ return maxVisiblePages;
51494
+ }
51495
+
51496
+ function getPageItemsToDisplay(_ref) {
51497
+ var totalPages = _ref.totalPages,
51498
+ currentPage = _ref.currentPage,
51499
+ _ref$maxVisiblePages = _ref.maxVisiblePages,
51500
+ maxVisiblePages = _ref$maxVisiblePages === void 0 ? 6 : _ref$maxVisiblePages;
51501
+ var pages = [];
51502
+ maxVisiblePages = validateAndSetMaxVisiblePages(maxVisiblePages);
51503
+
51504
+ if (totalPages <= maxVisiblePages) {
51505
+ return Array.from({
51506
+ length: totalPages
51507
+ }, function (_, i) {
51508
+ return i + 1;
51509
+ });
51510
+ }
51511
+
51512
+ var remainingPages = maxVisiblePages - 2;
51513
+ var half = Math.floor((remainingPages - 1) / 2);
51514
+ var left = currentPage - half;
51515
+ var right = currentPage + Math.ceil((remainingPages - 1) / 2);
51516
+
51517
+ if (left < 2) {
51518
+ left = 2;
51519
+ right = left + remainingPages - 1;
51520
+ }
51521
+
51522
+ if (right > totalPages - 1) {
51523
+ right = totalPages - 1;
51524
+ left = right - remainingPages + 1;
51525
+ }
51526
+
51527
+ pages.push(1); // always include the first page
51528
+
51529
+ if (left > 2) pages.push("...");
51530
+
51531
+ for (var i = left; i <= right; i++) {
51532
+ pages.push(i);
51533
+ }
51534
+
51535
+ if (right < totalPages - 1) pages.push("...");
51536
+ pages.push(totalPages); // always include the last page
51537
+
51538
+ return pages;
51539
+ }
51540
+
51541
+ var SEPARATOR = "...";
51467
51542
 
51468
51543
  function Pagination(_a) {
51469
- var onNext = _a.onNext,
51470
- onPrevious = _a.onPrevious,
51471
- onSelectPage = _a.onSelectPage,
51544
+ var _a$onNext = _a.onNext,
51545
+ onNext = _a$onNext === void 0 ? noop$2 : _a$onNext,
51546
+ _a$onPrevious = _a.onPrevious,
51547
+ onPrevious = _a$onPrevious === void 0 ? noop$2 : _a$onPrevious,
51548
+ _a$onSelectPage = _a.onSelectPage,
51549
+ onSelectPage = _a$onSelectPage === void 0 ? noop$2 : _a$onSelectPage,
51472
51550
  currentPage = _a.currentPage,
51473
51551
  totalPages = _a.totalPages,
51552
+ _a$maxVisiblePages = _a.maxVisiblePages,
51553
+ maxVisiblePages = _a$maxVisiblePages === void 0 ? 6 : _a$maxVisiblePages,
51474
51554
  nextAriaLabel = _a.nextAriaLabel,
51475
51555
  nextLabel = _a.nextLabel,
51476
51556
  previousAriaLabel = _a.previousAriaLabel,
@@ -51478,11 +51558,14 @@
51478
51558
  scrollToTopAfterPagination = _a.scrollToTopAfterPagination,
51479
51559
  scrollTargetRef = _a.scrollTargetRef,
51480
51560
  ariaLabel = _a["aria-label"],
51481
- restProps = __rest$3(_a, ["onNext", "onPrevious", "onSelectPage", "currentPage", "totalPages", "nextAriaLabel", "nextLabel", "previousAriaLabel", "previousLabel", "scrollToTopAfterPagination", "scrollTargetRef", "aria-label"]);
51561
+ restProps = __rest$3(_a, ["onNext", "onPrevious", "onSelectPage", "currentPage", "totalPages", "maxVisiblePages", "nextAriaLabel", "nextLabel", "previousAriaLabel", "previousLabel", "scrollToTopAfterPagination", "scrollTargetRef", "aria-label"]);
51482
51562
 
51483
51563
  var _useTranslation = useTranslation(),
51484
51564
  t = _useTranslation.t;
51485
51565
 
51566
+ var phone = !useMediaQuery("phoneLandscape");
51567
+ var largerThanPhone = useMediaQuery("tabletPortrait");
51568
+
51486
51569
  var scrollToTop = function scrollToTop() {
51487
51570
  var _a, _b;
51488
51571
 
@@ -51497,7 +51580,8 @@
51497
51580
 
51498
51581
  return /*#__PURE__*/React__default["default"].createElement(Flex, Object.assign({
51499
51582
  as: "nav",
51500
- "aria-label": ariaLabel || t("pagination navigation")
51583
+ "aria-label": ariaLabel || t("pagination navigation"),
51584
+ alignItems: "center"
51501
51585
  }, restProps), /*#__PURE__*/React__default["default"].createElement(PreviousButton, {
51502
51586
  disabled: currentPage === 1,
51503
51587
  onClick: function onClick() {
@@ -51507,8 +51591,13 @@
51507
51591
  scrollToTop();
51508
51592
  },
51509
51593
  ariaLabel: previousAriaLabel,
51510
- label: previousLabel
51511
- }), getPageItemsToDisplay(totalPages, currentPage).map(function (page, index) {
51594
+ label: phone ? null : previousLabel,
51595
+ showIconOnly: phone
51596
+ }), largerThanPhone ? getPageItemsToDisplay({
51597
+ totalPages: totalPages,
51598
+ currentPage: currentPage,
51599
+ maxVisiblePages: maxVisiblePages
51600
+ }).map(function (page, index) {
51512
51601
  var isCurrentPage = currentPage === page;
51513
51602
  if (page === SEPARATOR) return /*#__PURE__*/React__default["default"].createElement(Text, {
51514
51603
  key: "sep" + index,
@@ -51531,6 +51620,9 @@
51531
51620
  scrollToTop();
51532
51621
  }
51533
51622
  }, page);
51623
+ }) : /*#__PURE__*/React__default["default"].createElement(PaginationCount, {
51624
+ currentPage: currentPage,
51625
+ totalPages: totalPages
51534
51626
  }), /*#__PURE__*/React__default["default"].createElement(NextButton, {
51535
51627
  disabled: currentPage === totalPages,
51536
51628
  onClick: function onClick() {
@@ -51540,7 +51632,8 @@
51540
51632
  scrollToTop();
51541
51633
  },
51542
51634
  ariaLabel: nextAriaLabel,
51543
- label: nextLabel
51635
+ label: phone ? null : nextLabel,
51636
+ showIconOnly: phone
51544
51637
  }));
51545
51638
  }
51546
51639
 
@@ -54534,7 +54627,7 @@
54534
54627
  return {
54535
54628
  display: "flex",
54536
54629
  whiteSpace: "nowrap",
54537
- overflowX: "scroll",
54630
+ overflowX: "auto",
54538
54631
  overflowY: "hidden",
54539
54632
  marginBottom: theme.space.x1,
54540
54633
  "::-webkit-scrollbar": {
@@ -50039,6 +50039,7 @@ var de_DE = {
50039
50039
  "expand row": "Zeile erweitern",
50040
50040
  "go to next results": "Zu den n\xE4chsten Ergebnissen wechseln",
50041
50041
  "go to page": "Zu Seite {{count}} wechseln",
50042
+ "current page of total": "Seite {{currentPage}} von {{totalPages}}",
50042
50043
  "go to previous results": "Zu den vorherigen Ergebnissen wechseln",
50043
50044
  "go to": "Wechseln zu",
50044
50045
  "hide actions": "Aktionen verbergen",
@@ -50081,6 +50082,7 @@ var en_US = {
50081
50082
  "expand row": "Expand row",
50082
50083
  "go to next results": "Go to next results",
50083
50084
  "go to page": "Go to page {{count}}",
50085
+ "current page of total": "Page {{currentPage}} of {{totalPages}}",
50084
50086
  "go to previous results": "Go to previous results",
50085
50087
  "go to": "Go to",
50086
50088
  "hide actions": "Hide actions",
@@ -50165,6 +50167,7 @@ var fr_FR = {
50165
50167
  "expand row": "D\xE9velopper la ligne",
50166
50168
  "go to next results": "Aller aux r\xE9sultats suivants",
50167
50169
  "go to page": "Aller \xE0 la page {{count}}",
50170
+ "current page of total": "Page {{currentPage}} sur {{totalPages}}",
50168
50171
  "go to previous results": "Aller aux r\xE9sultats pr\xE9c\xE9dents",
50169
50172
  "go to": "Aller \xE0",
50170
50173
  "hide actions": "Masquer les actions",
@@ -50207,6 +50210,7 @@ var nl_NL = {
50207
50210
  "expand row": "Rij uitvouwen",
50208
50211
  "go to next results": "Ga naar volgende resultaten",
50209
50212
  "go to page": "Ga naar pagina {{count}}",
50213
+ "current page of total": "Pagina {{currentPage}} van {{totalPages}}",
50210
50214
  "go to previous results": "Ga naar vorige resultaten",
50211
50215
  "go to": "Ga naar",
50212
50216
  "hide actions": "Acties verbergen",
@@ -50249,6 +50253,7 @@ var pl_PL = {
50249
50253
  "expand row": "Rozwi\u0144 wiersz",
50250
50254
  "go to next results": "Przejd\u017A do nast\u0119pnych wynik\xF3w",
50251
50255
  "go to page": "Przejd\u017A do strony {{count}}",
50256
+ "current page of total": "Strona {{currentPage}} z {{totalPages}}",
50252
50257
  "go to previous results": "Przejd\u017A do poprzednich wynik\xF3w",
50253
50258
  "go to": "Przejd\u017A do",
50254
50259
  "hide actions": "Hide actions",
@@ -50291,6 +50296,7 @@ var pt_BR = {
50291
50296
  "expand row": "Expandir fila",
50292
50297
  "go to next results": "Ir para resultados seguintes",
50293
50298
  "go to page": "Ir para p\xE1gina {{count}}",
50299
+ "current page of total": "P\xE1gina {{currentPage}} de {{totalPages}}",
50294
50300
  "go to previous results": "Ir para resultados anteriores",
50295
50301
  "go to": "Ir para",
50296
50302
  "hide actions": "Ocultar a\xE7\xF5es",
@@ -50333,6 +50339,7 @@ var ro_RO = {
50333
50339
  "expand row": "Extindere r\xE2nd",
50334
50340
  "go to next results": "Merge\u021Bi la urm\u0103toarele rezultate",
50335
50341
  "go to page": "Merge\u021Bi la pagina {{count}}",
50342
+ "current page of total": "Pagina {{currentPage}} din {{totalPages}}",
50336
50343
  "go to previous results": "Merge\u021Bi la rezultatele anterioare",
50337
50344
  "go to": "Merge\u021Bi la",
50338
50345
  "hide actions": "Ascundere ac\u021Biuni",
@@ -50375,6 +50382,7 @@ var zh_CN = {
50375
50382
  "expand row": "\u5C55\u5F00\u884C",
50376
50383
  "go to next results": "\u8BBF\u95EE\u4E4B\u540E\u7684\u7ED3\u679C",
50377
50384
  "go to page": "\u8BBF\u95EE\u7B2C {{count}} \u9875 ",
50385
+ "current page of total": "\u7B2C {{currentPage}} \u9875\uFF0C\u5171 {{totalPages}} \u9875",
50378
50386
  "go to previous results": "\u8BBF\u95EE\u4E4B\u524D\u7684\u7ED3\u679C",
50379
50387
  "go to": "\u8BBF\u95EE ",
50380
50388
  "hide actions": "\u9690\u85CF\u64CD\u4F5C",
@@ -51356,15 +51364,19 @@ var PaginationButton = styled.button.withConfig({
51356
51364
  })(function (_ref) {
51357
51365
  var theme = _ref.theme,
51358
51366
  disabled = _ref.disabled,
51359
- currentPage = _ref.currentPage;
51367
+ currentPage = _ref.currentPage,
51368
+ iconOnly = _ref.iconOnly;
51360
51369
  return {
51361
51370
  fontSize: theme.fontSizes.small,
51362
- padding: theme.space.x1 + " " + theme.space.x2,
51371
+ padding: iconOnly ? theme.space.x1 : theme.space.x1 + " " + theme.space.x2,
51363
51372
  lineHeight: theme.lineHeights.smallTextBase,
51364
51373
  display: "flex",
51374
+ alignItems: "center",
51375
+ justifyContent: "center",
51365
51376
  borderRadius: theme.radii.medium,
51366
51377
  border: "1px solid " + (currentPage ? theme.colors.darkBlue : theme.colors.lightGrey),
51367
51378
  color: disabled ? theme.colors.grey : theme.colors.black,
51379
+ minWidth: iconOnly ? theme.space.x4 : "auto",
51368
51380
  "&:not(:last-child)": {
51369
51381
  marginRight: theme.space.x2
51370
51382
  },
@@ -51393,67 +51405,135 @@ var PreviousButton = function PreviousButton(_ref) {
51393
51405
  _ref$onClick = _ref.onClick,
51394
51406
  onClick = _ref$onClick === void 0 ? null : _ref$onClick,
51395
51407
  label = _ref.label,
51396
- ariaLabel = _ref.ariaLabel;
51408
+ ariaLabel = _ref.ariaLabel,
51409
+ showIconOnly = _ref.showIconOnly;
51397
51410
 
51398
51411
  var _useTranslation = useTranslation(),
51399
51412
  t = _useTranslation.t;
51400
51413
 
51414
+ var theme = useTheme();
51401
51415
  return /*#__PURE__*/React__default.createElement(PaginationButton, {
51402
51416
  disabled: disabled,
51403
51417
  onClick: onClick,
51404
- "aria-label": ariaLabel || t("go to previous results")
51418
+ "aria-label": ariaLabel || t("go to previous results"),
51419
+ iconOnly: showIconOnly
51405
51420
  }, /*#__PURE__*/React__default.createElement(Icon, {
51406
51421
  icon: "leftArrow",
51407
- ml: "-8px"
51408
- }), " ", label || t("previous"));
51422
+ ml: showIconOnly ? "0" : "-" + theme.space.x1
51423
+ }), !showIconOnly && (label || t("previous")));
51409
51424
  };
51410
51425
 
51411
51426
  var NextButton = function NextButton(_ref) {
51412
51427
  var disabled = _ref.disabled,
51413
51428
  onClick = _ref.onClick,
51414
51429
  label = _ref.label,
51415
- ariaLabel = _ref.ariaLabel;
51430
+ ariaLabel = _ref.ariaLabel,
51431
+ showIconOnly = _ref.showIconOnly;
51416
51432
 
51417
51433
  var _useTranslation = useTranslation(),
51418
51434
  t = _useTranslation.t;
51419
51435
 
51436
+ var theme = useTheme();
51420
51437
  return /*#__PURE__*/React__default.createElement(PaginationButton, {
51421
51438
  disabled: disabled,
51422
51439
  onClick: onClick,
51423
- "aria-label": ariaLabel || t("go to next results")
51424
- }, label || t("next"), " ", /*#__PURE__*/React__default.createElement(Icon, {
51440
+ "aria-label": ariaLabel || t("go to next results"),
51441
+ iconOnly: showIconOnly
51442
+ }, !showIconOnly && (label || t("next")), /*#__PURE__*/React__default.createElement(Icon, {
51425
51443
  icon: "rightArrow",
51426
- mr: "-8px"
51444
+ mr: showIconOnly ? "0" : "-" + theme.space.x1
51427
51445
  }));
51428
51446
  };
51429
51447
 
51430
- var SEPARATOR = "...";
51431
- var getPageItemsToDisplay = function getPageItemsToDisplay(totalPages, currentPage) {
51432
- var MAX_PAGES_TO_SHOW = 6;
51433
- var pages = Array.from({
51434
- length: totalPages
51435
- }, function (v, i) {
51436
- return i + 1;
51437
- });
51438
- if (totalPages <= MAX_PAGES_TO_SHOW) return pages;
51448
+ var PaginationCount = function PaginationCount(_ref) {
51449
+ var currentPage = _ref.currentPage,
51450
+ totalPages = _ref.totalPages;
51439
51451
 
51440
- if (currentPage <= MAX_PAGES_TO_SHOW - 1) {
51441
- return [].concat(pages.slice(0, 5), [SEPARATOR, totalPages]);
51452
+ var _useTranslation = useTranslation(),
51453
+ t = _useTranslation.t;
51454
+
51455
+ return /*#__PURE__*/React__default.createElement(Text, {
51456
+ fontSize: "small",
51457
+ lineHeight: "smallTextBase",
51458
+ mx: "x2"
51459
+ }, t("current page of total", {
51460
+ currentPage: currentPage,
51461
+ totalPages: totalPages
51462
+ }));
51463
+ };
51464
+
51465
+ function validateAndSetMaxVisiblePages(maxVisiblePages) {
51466
+ if (maxVisiblePages < 3) {
51467
+ console.error("Pagination maxVisiblePages prop must larger than 2. Value changed to 3.");
51468
+ return 3;
51442
51469
  }
51443
51470
 
51444
- if (currentPage > totalPages - 5) {
51445
- return [1, SEPARATOR].concat(pages.slice(totalPages - 5));
51471
+ if (maxVisiblePages > 12) {
51472
+ console.error("Pagination maxVisiblePages prop must smaller than 13. Value changed to 12.");
51473
+ return 12;
51446
51474
  }
51447
51475
 
51448
- return [1, SEPARATOR].concat(pages.slice(currentPage - 2, currentPage + 2), [SEPARATOR, totalPages]);
51449
- };
51476
+ return maxVisiblePages;
51477
+ }
51478
+
51479
+ function getPageItemsToDisplay(_ref) {
51480
+ var totalPages = _ref.totalPages,
51481
+ currentPage = _ref.currentPage,
51482
+ _ref$maxVisiblePages = _ref.maxVisiblePages,
51483
+ maxVisiblePages = _ref$maxVisiblePages === void 0 ? 6 : _ref$maxVisiblePages;
51484
+ var pages = [];
51485
+ maxVisiblePages = validateAndSetMaxVisiblePages(maxVisiblePages);
51486
+
51487
+ if (totalPages <= maxVisiblePages) {
51488
+ return Array.from({
51489
+ length: totalPages
51490
+ }, function (_, i) {
51491
+ return i + 1;
51492
+ });
51493
+ }
51494
+
51495
+ var remainingPages = maxVisiblePages - 2;
51496
+ var half = Math.floor((remainingPages - 1) / 2);
51497
+ var left = currentPage - half;
51498
+ var right = currentPage + Math.ceil((remainingPages - 1) / 2);
51499
+
51500
+ if (left < 2) {
51501
+ left = 2;
51502
+ right = left + remainingPages - 1;
51503
+ }
51504
+
51505
+ if (right > totalPages - 1) {
51506
+ right = totalPages - 1;
51507
+ left = right - remainingPages + 1;
51508
+ }
51509
+
51510
+ pages.push(1); // always include the first page
51511
+
51512
+ if (left > 2) pages.push("...");
51513
+
51514
+ for (var i = left; i <= right; i++) {
51515
+ pages.push(i);
51516
+ }
51517
+
51518
+ if (right < totalPages - 1) pages.push("...");
51519
+ pages.push(totalPages); // always include the last page
51520
+
51521
+ return pages;
51522
+ }
51523
+
51524
+ var SEPARATOR = "...";
51450
51525
 
51451
51526
  function Pagination(_a) {
51452
- var onNext = _a.onNext,
51453
- onPrevious = _a.onPrevious,
51454
- onSelectPage = _a.onSelectPage,
51527
+ var _a$onNext = _a.onNext,
51528
+ onNext = _a$onNext === void 0 ? noop$2 : _a$onNext,
51529
+ _a$onPrevious = _a.onPrevious,
51530
+ onPrevious = _a$onPrevious === void 0 ? noop$2 : _a$onPrevious,
51531
+ _a$onSelectPage = _a.onSelectPage,
51532
+ onSelectPage = _a$onSelectPage === void 0 ? noop$2 : _a$onSelectPage,
51455
51533
  currentPage = _a.currentPage,
51456
51534
  totalPages = _a.totalPages,
51535
+ _a$maxVisiblePages = _a.maxVisiblePages,
51536
+ maxVisiblePages = _a$maxVisiblePages === void 0 ? 6 : _a$maxVisiblePages,
51457
51537
  nextAriaLabel = _a.nextAriaLabel,
51458
51538
  nextLabel = _a.nextLabel,
51459
51539
  previousAriaLabel = _a.previousAriaLabel,
@@ -51461,11 +51541,14 @@ function Pagination(_a) {
51461
51541
  scrollToTopAfterPagination = _a.scrollToTopAfterPagination,
51462
51542
  scrollTargetRef = _a.scrollTargetRef,
51463
51543
  ariaLabel = _a["aria-label"],
51464
- restProps = __rest$3(_a, ["onNext", "onPrevious", "onSelectPage", "currentPage", "totalPages", "nextAriaLabel", "nextLabel", "previousAriaLabel", "previousLabel", "scrollToTopAfterPagination", "scrollTargetRef", "aria-label"]);
51544
+ restProps = __rest$3(_a, ["onNext", "onPrevious", "onSelectPage", "currentPage", "totalPages", "maxVisiblePages", "nextAriaLabel", "nextLabel", "previousAriaLabel", "previousLabel", "scrollToTopAfterPagination", "scrollTargetRef", "aria-label"]);
51465
51545
 
51466
51546
  var _useTranslation = useTranslation(),
51467
51547
  t = _useTranslation.t;
51468
51548
 
51549
+ var phone = !useMediaQuery("phoneLandscape");
51550
+ var largerThanPhone = useMediaQuery("tabletPortrait");
51551
+
51469
51552
  var scrollToTop = function scrollToTop() {
51470
51553
  var _a, _b;
51471
51554
 
@@ -51480,7 +51563,8 @@ function Pagination(_a) {
51480
51563
 
51481
51564
  return /*#__PURE__*/React__default.createElement(Flex, Object.assign({
51482
51565
  as: "nav",
51483
- "aria-label": ariaLabel || t("pagination navigation")
51566
+ "aria-label": ariaLabel || t("pagination navigation"),
51567
+ alignItems: "center"
51484
51568
  }, restProps), /*#__PURE__*/React__default.createElement(PreviousButton, {
51485
51569
  disabled: currentPage === 1,
51486
51570
  onClick: function onClick() {
@@ -51490,8 +51574,13 @@ function Pagination(_a) {
51490
51574
  scrollToTop();
51491
51575
  },
51492
51576
  ariaLabel: previousAriaLabel,
51493
- label: previousLabel
51494
- }), getPageItemsToDisplay(totalPages, currentPage).map(function (page, index) {
51577
+ label: phone ? null : previousLabel,
51578
+ showIconOnly: phone
51579
+ }), largerThanPhone ? getPageItemsToDisplay({
51580
+ totalPages: totalPages,
51581
+ currentPage: currentPage,
51582
+ maxVisiblePages: maxVisiblePages
51583
+ }).map(function (page, index) {
51495
51584
  var isCurrentPage = currentPage === page;
51496
51585
  if (page === SEPARATOR) return /*#__PURE__*/React__default.createElement(Text, {
51497
51586
  key: "sep" + index,
@@ -51514,6 +51603,9 @@ function Pagination(_a) {
51514
51603
  scrollToTop();
51515
51604
  }
51516
51605
  }, page);
51606
+ }) : /*#__PURE__*/React__default.createElement(PaginationCount, {
51607
+ currentPage: currentPage,
51608
+ totalPages: totalPages
51517
51609
  }), /*#__PURE__*/React__default.createElement(NextButton, {
51518
51610
  disabled: currentPage === totalPages,
51519
51611
  onClick: function onClick() {
@@ -51523,7 +51615,8 @@ function Pagination(_a) {
51523
51615
  scrollToTop();
51524
51616
  },
51525
51617
  ariaLabel: nextAriaLabel,
51526
- label: nextLabel
51618
+ label: phone ? null : nextLabel,
51619
+ showIconOnly: phone
51527
51620
  }));
51528
51621
  }
51529
51622
 
@@ -54517,7 +54610,7 @@ var TabContainer = styled(Box).withConfig({
54517
54610
  return {
54518
54611
  display: "flex",
54519
54612
  whiteSpace: "nowrap",
54520
- overflowX: "scroll",
54613
+ overflowX: "auto",
54521
54614
  overflowY: "hidden",
54522
54615
  marginBottom: theme.space.x1,
54523
54616
  "::-webkit-scrollbar": {
@@ -2,8 +2,9 @@ import React, { ReactNode } from "react";
2
2
  type NextButtonProps = {
3
3
  disabled: boolean;
4
4
  onClick: React.MouseEventHandler<HTMLButtonElement>;
5
- label: ReactNode;
6
- ariaLabel: string;
5
+ label?: ReactNode;
6
+ ariaLabel?: string;
7
+ showIconOnly?: boolean;
7
8
  };
8
- declare const NextButton: ({ disabled, onClick, label, ariaLabel }: NextButtonProps) => React.JSX.Element;
9
+ declare const NextButton: ({ disabled, onClick, label, ariaLabel, showIconOnly }: NextButtonProps) => React.JSX.Element;
9
10
  export default NextButton;
@@ -2,9 +2,10 @@
2
2
  type PageNumberProps = {
3
3
  currentPage: boolean;
4
4
  };
5
- declare const PageNumber: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "disabled" | "currentPage"> & {
5
+ declare const PageNumber: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "disabled" | "currentPage" | "iconOnly"> & {
6
6
  disabled?: boolean;
7
7
  currentPage?: boolean;
8
+ iconOnly?: boolean;
8
9
  }, "ref"> & {
9
10
  ref?: import("react").Ref<HTMLButtonElement>;
10
11
  }, PageNumberProps>> & string;
@@ -1,13 +1,13 @@
1
1
  import React, { ReactNode, RefObject } from "react";
2
2
  import { FlexProps } from "../Flex/Flex";
3
- declare const SEPARATOR: "...";
4
- export declare const getPageItemsToDisplay: (totalPages: number, currentPage: number) => Array<typeof SEPARATOR | number>;
3
+ export declare const SEPARATOR: "...";
5
4
  interface PaginationProps extends FlexProps {
6
- currentPage: number;
7
- totalPages: number;
8
5
  onNext?: () => void;
9
6
  onPrevious?: () => void;
10
7
  onSelectPage?: (page: number) => void;
8
+ currentPage: number;
9
+ totalPages: number;
10
+ maxVisiblePages?: number;
11
11
  nextLabel?: ReactNode;
12
12
  nextAriaLabel?: string;
13
13
  previousLabel?: ReactNode;
@@ -15,5 +15,5 @@ interface PaginationProps extends FlexProps {
15
15
  scrollToTopAfterPagination?: boolean;
16
16
  scrollTargetRef?: RefObject<HTMLElement>;
17
17
  }
18
- declare function Pagination({ onNext, onPrevious, onSelectPage, currentPage, totalPages, nextAriaLabel, nextLabel, previousAriaLabel, previousLabel, scrollToTopAfterPagination, scrollTargetRef, "aria-label": ariaLabel, ...restProps }: PaginationProps): React.JSX.Element;
18
+ declare function Pagination({ onNext, onPrevious, onSelectPage, currentPage, totalPages, maxVisiblePages, nextAriaLabel, nextLabel, previousAriaLabel, previousLabel, scrollToTopAfterPagination, scrollTargetRef, "aria-label": ariaLabel, ...restProps }: PaginationProps): React.JSX.Element;
19
19
  export default Pagination;
@@ -22,4 +22,5 @@ export declare const WithLessThan5Pages: {
22
22
  name: string;
23
23
  };
24
24
  };
25
+ export declare const CustomMaxVisiblePages: () => React.JSX.Element;
25
26
  export declare function ScrollAfterPagination(): React.JSX.Element;
@@ -2,5 +2,6 @@
2
2
  declare const PaginationButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
3
3
  disabled?: boolean;
4
4
  currentPage?: boolean;
5
+ iconOnly?: boolean;
5
6
  }>> & string;
6
7
  export default PaginationButton;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ type PaginationCountProps = {
3
+ currentPage: number;
4
+ totalPages: number;
5
+ };
6
+ declare const PaginationCount: ({ currentPage, totalPages }: PaginationCountProps) => React.JSX.Element;
7
+ export default PaginationCount;
@@ -2,8 +2,9 @@ import React, { ReactNode } from "react";
2
2
  type PreviousButtonProps = {
3
3
  disabled: boolean;
4
4
  onClick: React.MouseEventHandler<HTMLButtonElement>;
5
- label: ReactNode;
6
- ariaLabel: string;
5
+ label?: ReactNode;
6
+ ariaLabel?: string;
7
+ showIconOnly?: boolean;
7
8
  };
8
- declare const PreviousButton: ({ disabled, onClick, label, ariaLabel }: PreviousButtonProps) => React.JSX.Element;
9
+ declare const PreviousButton: ({ disabled, onClick, label, ariaLabel, showIconOnly }: PreviousButtonProps) => React.JSX.Element;
9
10
  export default PreviousButton;
@@ -0,0 +1,9 @@
1
+ import { SEPARATOR } from "./Pagination";
2
+ interface PaginationItemsToDisplay {
3
+ totalPages: number;
4
+ currentPage: number;
5
+ maxVisiblePages?: number;
6
+ }
7
+ type PagesToDisplay = (number | typeof SEPARATOR)[];
8
+ export declare function getPageItemsToDisplay({ totalPages, currentPage, maxVisiblePages, }: PaginationItemsToDisplay): PagesToDisplay;
9
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Creates a mock implementation of the `window.matchMedia` function.
3
+ * This is useful for changing the width of the viewport in tests without
4
+ * needing to manipulate the actual browser environment.
5
+ *
6
+ */
7
+ export declare const createMatchMedia: (width: number) => (query: string) => MediaQueryList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nulogy/components",
3
- "version": "13.0.0",
3
+ "version": "13.1.0",
4
4
  "description": "Component library for the Nulogy Design System - http://nulogy.design",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -90,6 +90,7 @@
90
90
  "@storybook/theming": "^6.1.9",
91
91
  "@testing-library/jest-dom": "5.11.5",
92
92
  "@testing-library/react": "^12.1.5",
93
+ "@types/css-mediaquery": "^0.1.4",
93
94
  "@types/jest": "^29.5.1",
94
95
  "@types/node": "^14.0.14",
95
96
  "@types/react": "^17.0.39",
@@ -108,6 +109,7 @@
108
109
  "babel-preset-react": "6.24.1",
109
110
  "chromatic": "^6.0.6",
110
111
  "concurrently": "^5.2.0",
112
+ "css-mediaquery": "^0.1.2",
111
113
  "cypress": "^13.2.0",
112
114
  "cypress-enter-plugin": "^1.0.1",
113
115
  "cypress-plugin-tab": "^1.0.1",