@nulogy/components 13.0.0 → 13.1.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.
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,18 +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,
51385
- "&:not(:last-child)": {
51386
- marginRight: theme.space.x2
51387
- },
51396
+ minWidth: iconOnly ? theme.space.x4 : "auto",
51388
51397
  cursor: disabled ? "default" : "pointer",
51389
51398
  "&:hover": {
51390
51399
  background: getHoverBackground(currentPage, disabled, theme)
@@ -51410,67 +51419,135 @@
51410
51419
  _ref$onClick = _ref.onClick,
51411
51420
  onClick = _ref$onClick === void 0 ? null : _ref$onClick,
51412
51421
  label = _ref.label,
51413
- ariaLabel = _ref.ariaLabel;
51422
+ ariaLabel = _ref.ariaLabel,
51423
+ showIconOnly = _ref.showIconOnly;
51414
51424
 
51415
51425
  var _useTranslation = useTranslation(),
51416
51426
  t = _useTranslation.t;
51417
51427
 
51428
+ var theme = styled.useTheme();
51418
51429
  return /*#__PURE__*/React__default["default"].createElement(PaginationButton, {
51419
51430
  disabled: disabled,
51420
51431
  onClick: onClick,
51421
- "aria-label": ariaLabel || t("go to previous results")
51432
+ "aria-label": ariaLabel || t("go to previous results"),
51433
+ iconOnly: showIconOnly
51422
51434
  }, /*#__PURE__*/React__default["default"].createElement(Icon, {
51423
51435
  icon: "leftArrow",
51424
- ml: "-8px"
51425
- }), " ", label || t("previous"));
51436
+ ml: showIconOnly ? "0" : "-" + theme.space.x1
51437
+ }), !showIconOnly && (label || t("previous")));
51426
51438
  };
51427
51439
 
51428
51440
  var NextButton = function NextButton(_ref) {
51429
51441
  var disabled = _ref.disabled,
51430
51442
  onClick = _ref.onClick,
51431
51443
  label = _ref.label,
51432
- ariaLabel = _ref.ariaLabel;
51444
+ ariaLabel = _ref.ariaLabel,
51445
+ showIconOnly = _ref.showIconOnly;
51433
51446
 
51434
51447
  var _useTranslation = useTranslation(),
51435
51448
  t = _useTranslation.t;
51436
51449
 
51450
+ var theme = styled.useTheme();
51437
51451
  return /*#__PURE__*/React__default["default"].createElement(PaginationButton, {
51438
51452
  disabled: disabled,
51439
51453
  onClick: onClick,
51440
- "aria-label": ariaLabel || t("go to next results")
51441
- }, label || t("next"), " ", /*#__PURE__*/React__default["default"].createElement(Icon, {
51454
+ "aria-label": ariaLabel || t("go to next results"),
51455
+ iconOnly: showIconOnly
51456
+ }, !showIconOnly && (label || t("next")), /*#__PURE__*/React__default["default"].createElement(Icon, {
51442
51457
  icon: "rightArrow",
51443
- mr: "-8px"
51458
+ mr: showIconOnly ? "0" : "-" + theme.space.x1
51444
51459
  }));
51445
51460
  };
51446
51461
 
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;
51462
+ var PaginationCount = function PaginationCount(_ref) {
51463
+ var currentPage = _ref.currentPage,
51464
+ totalPages = _ref.totalPages;
51465
+
51466
+ var _useTranslation = useTranslation(),
51467
+ t = _useTranslation.t;
51468
+
51469
+ return /*#__PURE__*/React__default["default"].createElement(Text, {
51470
+ fontSize: "small",
51471
+ lineHeight: "smallTextBase",
51472
+ mx: "x2"
51473
+ }, t("current page of total", {
51474
+ currentPage: currentPage,
51475
+ totalPages: totalPages
51476
+ }));
51477
+ };
51456
51478
 
51457
- if (currentPage <= MAX_PAGES_TO_SHOW - 1) {
51458
- return [].concat(pages.slice(0, 5), [SEPARATOR, totalPages]);
51479
+ function validateAndSetMaxVisiblePages(maxVisiblePages) {
51480
+ if (maxVisiblePages < 3) {
51481
+ console.error("Pagination maxVisiblePages prop must larger than 2. Value changed to 3.");
51482
+ return 3;
51459
51483
  }
51460
51484
 
51461
- if (currentPage > totalPages - 5) {
51462
- return [1, SEPARATOR].concat(pages.slice(totalPages - 5));
51485
+ if (maxVisiblePages > 12) {
51486
+ console.error("Pagination maxVisiblePages prop must smaller than 13. Value changed to 12.");
51487
+ return 12;
51463
51488
  }
51464
51489
 
51465
- return [1, SEPARATOR].concat(pages.slice(currentPage - 2, currentPage + 2), [SEPARATOR, totalPages]);
51466
- };
51490
+ return maxVisiblePages;
51491
+ }
51492
+
51493
+ function getPageItemsToDisplay(_ref) {
51494
+ var totalPages = _ref.totalPages,
51495
+ currentPage = _ref.currentPage,
51496
+ _ref$maxVisiblePages = _ref.maxVisiblePages,
51497
+ maxVisiblePages = _ref$maxVisiblePages === void 0 ? 6 : _ref$maxVisiblePages;
51498
+ var pages = [];
51499
+ maxVisiblePages = validateAndSetMaxVisiblePages(maxVisiblePages);
51500
+
51501
+ if (totalPages <= maxVisiblePages) {
51502
+ return Array.from({
51503
+ length: totalPages
51504
+ }, function (_, i) {
51505
+ return i + 1;
51506
+ });
51507
+ }
51508
+
51509
+ var remainingPages = maxVisiblePages - 2;
51510
+ var half = Math.floor((remainingPages - 1) / 2);
51511
+ var left = currentPage - half;
51512
+ var right = currentPage + Math.ceil((remainingPages - 1) / 2);
51513
+
51514
+ if (left < 2) {
51515
+ left = 2;
51516
+ right = left + remainingPages - 1;
51517
+ }
51518
+
51519
+ if (right > totalPages - 1) {
51520
+ right = totalPages - 1;
51521
+ left = right - remainingPages + 1;
51522
+ }
51523
+
51524
+ pages.push(1); // always include the first page
51525
+
51526
+ if (left > 2) pages.push("...");
51527
+
51528
+ for (var i = left; i <= right; i++) {
51529
+ pages.push(i);
51530
+ }
51531
+
51532
+ if (right < totalPages - 1) pages.push("...");
51533
+ pages.push(totalPages); // always include the last page
51534
+
51535
+ return pages;
51536
+ }
51537
+
51538
+ var SEPARATOR = "...";
51467
51539
 
51468
51540
  function Pagination(_a) {
51469
- var onNext = _a.onNext,
51470
- onPrevious = _a.onPrevious,
51471
- onSelectPage = _a.onSelectPage,
51541
+ var _a$onNext = _a.onNext,
51542
+ onNext = _a$onNext === void 0 ? noop$2 : _a$onNext,
51543
+ _a$onPrevious = _a.onPrevious,
51544
+ onPrevious = _a$onPrevious === void 0 ? noop$2 : _a$onPrevious,
51545
+ _a$onSelectPage = _a.onSelectPage,
51546
+ onSelectPage = _a$onSelectPage === void 0 ? noop$2 : _a$onSelectPage,
51472
51547
  currentPage = _a.currentPage,
51473
51548
  totalPages = _a.totalPages,
51549
+ _a$maxVisiblePages = _a.maxVisiblePages,
51550
+ maxVisiblePages = _a$maxVisiblePages === void 0 ? 6 : _a$maxVisiblePages,
51474
51551
  nextAriaLabel = _a.nextAriaLabel,
51475
51552
  nextLabel = _a.nextLabel,
51476
51553
  previousAriaLabel = _a.previousAriaLabel,
@@ -51478,11 +51555,14 @@
51478
51555
  scrollToTopAfterPagination = _a.scrollToTopAfterPagination,
51479
51556
  scrollTargetRef = _a.scrollTargetRef,
51480
51557
  ariaLabel = _a["aria-label"],
51481
- restProps = __rest$3(_a, ["onNext", "onPrevious", "onSelectPage", "currentPage", "totalPages", "nextAriaLabel", "nextLabel", "previousAriaLabel", "previousLabel", "scrollToTopAfterPagination", "scrollTargetRef", "aria-label"]);
51558
+ restProps = __rest$3(_a, ["onNext", "onPrevious", "onSelectPage", "currentPage", "totalPages", "maxVisiblePages", "nextAriaLabel", "nextLabel", "previousAriaLabel", "previousLabel", "scrollToTopAfterPagination", "scrollTargetRef", "aria-label"]);
51482
51559
 
51483
51560
  var _useTranslation = useTranslation(),
51484
51561
  t = _useTranslation.t;
51485
51562
 
51563
+ var phone = !useMediaQuery("phoneLandscape");
51564
+ var largerThanPhone = useMediaQuery("tabletPortrait");
51565
+
51486
51566
  var scrollToTop = function scrollToTop() {
51487
51567
  var _a, _b;
51488
51568
 
@@ -51497,7 +51577,9 @@
51497
51577
 
51498
51578
  return /*#__PURE__*/React__default["default"].createElement(Flex, Object.assign({
51499
51579
  as: "nav",
51500
- "aria-label": ariaLabel || t("pagination navigation")
51580
+ gap: "x2",
51581
+ "aria-label": ariaLabel || t("pagination navigation"),
51582
+ alignItems: "center"
51501
51583
  }, restProps), /*#__PURE__*/React__default["default"].createElement(PreviousButton, {
51502
51584
  disabled: currentPage === 1,
51503
51585
  onClick: function onClick() {
@@ -51507,13 +51589,17 @@
51507
51589
  scrollToTop();
51508
51590
  },
51509
51591
  ariaLabel: previousAriaLabel,
51510
- label: previousLabel
51511
- }), getPageItemsToDisplay(totalPages, currentPage).map(function (page, index) {
51592
+ label: phone ? null : previousLabel,
51593
+ showIconOnly: phone
51594
+ }), largerThanPhone ? getPageItemsToDisplay({
51595
+ totalPages: totalPages,
51596
+ currentPage: currentPage,
51597
+ maxVisiblePages: maxVisiblePages
51598
+ }).map(function (page, index) {
51512
51599
  var isCurrentPage = currentPage === page;
51513
51600
  if (page === SEPARATOR) return /*#__PURE__*/React__default["default"].createElement(Text, {
51514
51601
  key: "sep" + index,
51515
51602
  py: "x1",
51516
- mr: "x2",
51517
51603
  fontSize: "small",
51518
51604
  lineHeight: "smallTextBase"
51519
51605
  }, SEPARATOR);else return /*#__PURE__*/React__default["default"].createElement(PageNumber, {
@@ -51531,6 +51617,9 @@
51531
51617
  scrollToTop();
51532
51618
  }
51533
51619
  }, page);
51620
+ }) : /*#__PURE__*/React__default["default"].createElement(PaginationCount, {
51621
+ currentPage: currentPage,
51622
+ totalPages: totalPages
51534
51623
  }), /*#__PURE__*/React__default["default"].createElement(NextButton, {
51535
51624
  disabled: currentPage === totalPages,
51536
51625
  onClick: function onClick() {
@@ -51540,7 +51629,8 @@
51540
51629
  scrollToTop();
51541
51630
  },
51542
51631
  ariaLabel: nextAriaLabel,
51543
- label: nextLabel
51632
+ label: phone ? null : nextLabel,
51633
+ showIconOnly: phone
51544
51634
  }));
51545
51635
  }
51546
51636
 
@@ -54534,7 +54624,7 @@
54534
54624
  return {
54535
54625
  display: "flex",
54536
54626
  whiteSpace: "nowrap",
54537
- overflowX: "scroll",
54627
+ overflowX: "auto",
54538
54628
  overflowY: "hidden",
54539
54629
  marginBottom: theme.space.x1,
54540
54630
  "::-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,18 +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,
51368
- "&:not(:last-child)": {
51369
- marginRight: theme.space.x2
51370
- },
51379
+ minWidth: iconOnly ? theme.space.x4 : "auto",
51371
51380
  cursor: disabled ? "default" : "pointer",
51372
51381
  "&:hover": {
51373
51382
  background: getHoverBackground(currentPage, disabled, theme)
@@ -51393,67 +51402,135 @@ var PreviousButton = function PreviousButton(_ref) {
51393
51402
  _ref$onClick = _ref.onClick,
51394
51403
  onClick = _ref$onClick === void 0 ? null : _ref$onClick,
51395
51404
  label = _ref.label,
51396
- ariaLabel = _ref.ariaLabel;
51405
+ ariaLabel = _ref.ariaLabel,
51406
+ showIconOnly = _ref.showIconOnly;
51397
51407
 
51398
51408
  var _useTranslation = useTranslation(),
51399
51409
  t = _useTranslation.t;
51400
51410
 
51411
+ var theme = useTheme();
51401
51412
  return /*#__PURE__*/React__default.createElement(PaginationButton, {
51402
51413
  disabled: disabled,
51403
51414
  onClick: onClick,
51404
- "aria-label": ariaLabel || t("go to previous results")
51415
+ "aria-label": ariaLabel || t("go to previous results"),
51416
+ iconOnly: showIconOnly
51405
51417
  }, /*#__PURE__*/React__default.createElement(Icon, {
51406
51418
  icon: "leftArrow",
51407
- ml: "-8px"
51408
- }), " ", label || t("previous"));
51419
+ ml: showIconOnly ? "0" : "-" + theme.space.x1
51420
+ }), !showIconOnly && (label || t("previous")));
51409
51421
  };
51410
51422
 
51411
51423
  var NextButton = function NextButton(_ref) {
51412
51424
  var disabled = _ref.disabled,
51413
51425
  onClick = _ref.onClick,
51414
51426
  label = _ref.label,
51415
- ariaLabel = _ref.ariaLabel;
51427
+ ariaLabel = _ref.ariaLabel,
51428
+ showIconOnly = _ref.showIconOnly;
51416
51429
 
51417
51430
  var _useTranslation = useTranslation(),
51418
51431
  t = _useTranslation.t;
51419
51432
 
51433
+ var theme = useTheme();
51420
51434
  return /*#__PURE__*/React__default.createElement(PaginationButton, {
51421
51435
  disabled: disabled,
51422
51436
  onClick: onClick,
51423
- "aria-label": ariaLabel || t("go to next results")
51424
- }, label || t("next"), " ", /*#__PURE__*/React__default.createElement(Icon, {
51437
+ "aria-label": ariaLabel || t("go to next results"),
51438
+ iconOnly: showIconOnly
51439
+ }, !showIconOnly && (label || t("next")), /*#__PURE__*/React__default.createElement(Icon, {
51425
51440
  icon: "rightArrow",
51426
- mr: "-8px"
51441
+ mr: showIconOnly ? "0" : "-" + theme.space.x1
51427
51442
  }));
51428
51443
  };
51429
51444
 
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;
51445
+ var PaginationCount = function PaginationCount(_ref) {
51446
+ var currentPage = _ref.currentPage,
51447
+ totalPages = _ref.totalPages;
51448
+
51449
+ var _useTranslation = useTranslation(),
51450
+ t = _useTranslation.t;
51451
+
51452
+ return /*#__PURE__*/React__default.createElement(Text, {
51453
+ fontSize: "small",
51454
+ lineHeight: "smallTextBase",
51455
+ mx: "x2"
51456
+ }, t("current page of total", {
51457
+ currentPage: currentPage,
51458
+ totalPages: totalPages
51459
+ }));
51460
+ };
51439
51461
 
51440
- if (currentPage <= MAX_PAGES_TO_SHOW - 1) {
51441
- return [].concat(pages.slice(0, 5), [SEPARATOR, totalPages]);
51462
+ function validateAndSetMaxVisiblePages(maxVisiblePages) {
51463
+ if (maxVisiblePages < 3) {
51464
+ console.error("Pagination maxVisiblePages prop must larger than 2. Value changed to 3.");
51465
+ return 3;
51442
51466
  }
51443
51467
 
51444
- if (currentPage > totalPages - 5) {
51445
- return [1, SEPARATOR].concat(pages.slice(totalPages - 5));
51468
+ if (maxVisiblePages > 12) {
51469
+ console.error("Pagination maxVisiblePages prop must smaller than 13. Value changed to 12.");
51470
+ return 12;
51446
51471
  }
51447
51472
 
51448
- return [1, SEPARATOR].concat(pages.slice(currentPage - 2, currentPage + 2), [SEPARATOR, totalPages]);
51449
- };
51473
+ return maxVisiblePages;
51474
+ }
51475
+
51476
+ function getPageItemsToDisplay(_ref) {
51477
+ var totalPages = _ref.totalPages,
51478
+ currentPage = _ref.currentPage,
51479
+ _ref$maxVisiblePages = _ref.maxVisiblePages,
51480
+ maxVisiblePages = _ref$maxVisiblePages === void 0 ? 6 : _ref$maxVisiblePages;
51481
+ var pages = [];
51482
+ maxVisiblePages = validateAndSetMaxVisiblePages(maxVisiblePages);
51483
+
51484
+ if (totalPages <= maxVisiblePages) {
51485
+ return Array.from({
51486
+ length: totalPages
51487
+ }, function (_, i) {
51488
+ return i + 1;
51489
+ });
51490
+ }
51491
+
51492
+ var remainingPages = maxVisiblePages - 2;
51493
+ var half = Math.floor((remainingPages - 1) / 2);
51494
+ var left = currentPage - half;
51495
+ var right = currentPage + Math.ceil((remainingPages - 1) / 2);
51496
+
51497
+ if (left < 2) {
51498
+ left = 2;
51499
+ right = left + remainingPages - 1;
51500
+ }
51501
+
51502
+ if (right > totalPages - 1) {
51503
+ right = totalPages - 1;
51504
+ left = right - remainingPages + 1;
51505
+ }
51506
+
51507
+ pages.push(1); // always include the first page
51508
+
51509
+ if (left > 2) pages.push("...");
51510
+
51511
+ for (var i = left; i <= right; i++) {
51512
+ pages.push(i);
51513
+ }
51514
+
51515
+ if (right < totalPages - 1) pages.push("...");
51516
+ pages.push(totalPages); // always include the last page
51517
+
51518
+ return pages;
51519
+ }
51520
+
51521
+ var SEPARATOR = "...";
51450
51522
 
51451
51523
  function Pagination(_a) {
51452
- var onNext = _a.onNext,
51453
- onPrevious = _a.onPrevious,
51454
- onSelectPage = _a.onSelectPage,
51524
+ var _a$onNext = _a.onNext,
51525
+ onNext = _a$onNext === void 0 ? noop$2 : _a$onNext,
51526
+ _a$onPrevious = _a.onPrevious,
51527
+ onPrevious = _a$onPrevious === void 0 ? noop$2 : _a$onPrevious,
51528
+ _a$onSelectPage = _a.onSelectPage,
51529
+ onSelectPage = _a$onSelectPage === void 0 ? noop$2 : _a$onSelectPage,
51455
51530
  currentPage = _a.currentPage,
51456
51531
  totalPages = _a.totalPages,
51532
+ _a$maxVisiblePages = _a.maxVisiblePages,
51533
+ maxVisiblePages = _a$maxVisiblePages === void 0 ? 6 : _a$maxVisiblePages,
51457
51534
  nextAriaLabel = _a.nextAriaLabel,
51458
51535
  nextLabel = _a.nextLabel,
51459
51536
  previousAriaLabel = _a.previousAriaLabel,
@@ -51461,11 +51538,14 @@ function Pagination(_a) {
51461
51538
  scrollToTopAfterPagination = _a.scrollToTopAfterPagination,
51462
51539
  scrollTargetRef = _a.scrollTargetRef,
51463
51540
  ariaLabel = _a["aria-label"],
51464
- restProps = __rest$3(_a, ["onNext", "onPrevious", "onSelectPage", "currentPage", "totalPages", "nextAriaLabel", "nextLabel", "previousAriaLabel", "previousLabel", "scrollToTopAfterPagination", "scrollTargetRef", "aria-label"]);
51541
+ restProps = __rest$3(_a, ["onNext", "onPrevious", "onSelectPage", "currentPage", "totalPages", "maxVisiblePages", "nextAriaLabel", "nextLabel", "previousAriaLabel", "previousLabel", "scrollToTopAfterPagination", "scrollTargetRef", "aria-label"]);
51465
51542
 
51466
51543
  var _useTranslation = useTranslation(),
51467
51544
  t = _useTranslation.t;
51468
51545
 
51546
+ var phone = !useMediaQuery("phoneLandscape");
51547
+ var largerThanPhone = useMediaQuery("tabletPortrait");
51548
+
51469
51549
  var scrollToTop = function scrollToTop() {
51470
51550
  var _a, _b;
51471
51551
 
@@ -51480,7 +51560,9 @@ function Pagination(_a) {
51480
51560
 
51481
51561
  return /*#__PURE__*/React__default.createElement(Flex, Object.assign({
51482
51562
  as: "nav",
51483
- "aria-label": ariaLabel || t("pagination navigation")
51563
+ gap: "x2",
51564
+ "aria-label": ariaLabel || t("pagination navigation"),
51565
+ alignItems: "center"
51484
51566
  }, restProps), /*#__PURE__*/React__default.createElement(PreviousButton, {
51485
51567
  disabled: currentPage === 1,
51486
51568
  onClick: function onClick() {
@@ -51490,13 +51572,17 @@ function Pagination(_a) {
51490
51572
  scrollToTop();
51491
51573
  },
51492
51574
  ariaLabel: previousAriaLabel,
51493
- label: previousLabel
51494
- }), getPageItemsToDisplay(totalPages, currentPage).map(function (page, index) {
51575
+ label: phone ? null : previousLabel,
51576
+ showIconOnly: phone
51577
+ }), largerThanPhone ? getPageItemsToDisplay({
51578
+ totalPages: totalPages,
51579
+ currentPage: currentPage,
51580
+ maxVisiblePages: maxVisiblePages
51581
+ }).map(function (page, index) {
51495
51582
  var isCurrentPage = currentPage === page;
51496
51583
  if (page === SEPARATOR) return /*#__PURE__*/React__default.createElement(Text, {
51497
51584
  key: "sep" + index,
51498
51585
  py: "x1",
51499
- mr: "x2",
51500
51586
  fontSize: "small",
51501
51587
  lineHeight: "smallTextBase"
51502
51588
  }, SEPARATOR);else return /*#__PURE__*/React__default.createElement(PageNumber, {
@@ -51514,6 +51600,9 @@ function Pagination(_a) {
51514
51600
  scrollToTop();
51515
51601
  }
51516
51602
  }, page);
51603
+ }) : /*#__PURE__*/React__default.createElement(PaginationCount, {
51604
+ currentPage: currentPage,
51605
+ totalPages: totalPages
51517
51606
  }), /*#__PURE__*/React__default.createElement(NextButton, {
51518
51607
  disabled: currentPage === totalPages,
51519
51608
  onClick: function onClick() {
@@ -51523,7 +51612,8 @@ function Pagination(_a) {
51523
51612
  scrollToTop();
51524
51613
  },
51525
51614
  ariaLabel: nextAriaLabel,
51526
- label: nextLabel
51615
+ label: phone ? null : nextLabel,
51616
+ showIconOnly: phone
51527
51617
  }));
51528
51618
  }
51529
51619
 
@@ -54517,7 +54607,7 @@ var TabContainer = styled(Box).withConfig({
54517
54607
  return {
54518
54608
  display: "flex",
54519
54609
  whiteSpace: "nowrap",
54520
- overflowX: "scroll",
54610
+ overflowX: "auto",
54521
54611
  overflowY: "hidden",
54522
54612
  marginBottom: theme.space.x1,
54523
54613
  "::-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.1",
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",