reactive-bulma 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var crypto = require('crypto');
4
-
5
3
  function styleInject(css, ref) {
6
4
  if ( ref === void 0 ) ref = {};
7
5
  var insertAt = ref.insertAt;
@@ -2867,7 +2865,7 @@ const parseKey = (max = 5000, min = 1) => {
2867
2865
  max = Math.floor(max);
2868
2866
  min = Math.ceil(min);
2869
2867
  const secureRandomNumbers = new Uint32Array(1);
2870
- crypto.getRandomValues(secureRandomNumbers);
2868
+ window.crypto.getRandomValues(secureRandomNumbers);
2871
2869
  return Math.floor(secureRandomNumbers[0] * (max - min) + min).toString();
2872
2870
  };
2873
2871
 
@@ -2944,7 +2942,7 @@ const Tag = ({ testId = null, containerTestId = null, cssClasses = null, contain
2944
2942
  const tagDeleteTestId = `${tagTestId}-delete`;
2945
2943
  return withAddon ? (React.createElement("section", { "data-testid": tagContainerTestId, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined, className: tagContainerClasses },
2946
2944
  React.createElement("span", { "data-testid": tagTestId, className: tagClasses }, text),
2947
- withDelete ? (React.createElement("a", { "data-testid": tagDeleteTestId, className: 'tag is-delete', "aria-hidden": 'true', onClick: onDeleteClick !== null && onDeleteClick !== void 0 ? onDeleteClick : undefined })) : (React.createElement("span", { className: tagAddonClasses }, addonText)))) : (React.createElement("span", { "data-testid": tagTestId, style: style !== null && style !== void 0 ? style : undefined, className: tagClasses },
2945
+ withDelete ? (React.createElement("a", { "data-testid": tagDeleteTestId, className: 'tag is-delete', title: 'delete', "aria-hidden": 'true', onClick: onDeleteClick !== null && onDeleteClick !== void 0 ? onDeleteClick : undefined })) : (React.createElement("span", { className: tagAddonClasses }, addonText)))) : (React.createElement("span", { "data-testid": tagTestId, style: style !== null && style !== void 0 ? style : undefined, className: tagClasses },
2948
2946
  text,
2949
2947
  withDelete ? (React.createElement("button", { "data-testid": tagDeleteTestId, className: 'delete', onClick: onDeleteClick !== null && onDeleteClick !== void 0 ? onDeleteClick : undefined })) : null));
2950
2948
  };
@@ -2953,8 +2951,6 @@ const Box = ({ testId = 'test-box', cssClasses = 'box', style = null, children =
2953
2951
 
2954
2952
  const renderTitleSection = (section) => {
2955
2953
  var _a, _b;
2956
- if (!section)
2957
- return null;
2958
2954
  const { type, size, isSpaced, cssClasses } = section;
2959
2955
  const sectionClasses = parseClasses([
2960
2956
  type,
@@ -2966,8 +2962,8 @@ const renderTitleSection = (section) => {
2966
2962
  return (React.createElement("p", { "data-testid": sectionTestId, className: sectionClasses, style: (_b = section === null || section === void 0 ? void 0 : section.style) !== null && _b !== void 0 ? _b : undefined }, section === null || section === void 0 ? void 0 : section.text));
2967
2963
  };
2968
2964
  const Title = ({ main, secondary }) => (React.createElement(React.Fragment, null,
2969
- renderTitleSection(main),
2970
- renderTitleSection(secondary)));
2965
+ main ? renderTitleSection(main) : null,
2966
+ secondary ? renderTitleSection(secondary) : null));
2971
2967
 
2972
2968
  var IconSizeEnum;
2973
2969
  (function (IconSizeEnum) {
@@ -3255,6 +3251,20 @@ const MenuItem = ({ testId = null, cssClasses = null, style = null, text, isActi
3255
3251
  return (React.createElement("a", { "data-testid": menuItemTestId, className: menuItemClasses, style: style !== null && style !== void 0 ? style : undefined, "aria-hidden": 'true', onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, text));
3256
3252
  };
3257
3253
 
3254
+ const PaginationItem = ({ testId = null, cssClasses = null, style = null, text, labelText = 'Page', currentLabelText = 'Go to page', isSelected = null, onClick = null }) => {
3255
+ const paginationItemClasses = parseClasses([
3256
+ 'pagination-link',
3257
+ isSelected ? 'is-current' : null,
3258
+ cssClasses
3259
+ ]);
3260
+ const paginationItemTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
3261
+ tag: 'pagination-link',
3262
+ parsedClasses: paginationItemClasses
3263
+ });
3264
+ const parsedLabelText = isSelected ? currentLabelText : labelText;
3265
+ return (React.createElement("a", { "data-testid": paginationItemTestId, className: paginationItemClasses, style: style !== null && style !== void 0 ? style : undefined, "aria-label": `${parsedLabelText} ${text}`, "aria-current": isSelected ? 'page' : undefined, "aria-hidden": 'true', onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, text));
3266
+ };
3267
+
3258
3268
  const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonList, isAttached = false, position = 'left' }) => {
3259
3269
  const buttonGroupClasses = parseClasses([
3260
3270
  'buttons',
@@ -3408,6 +3418,66 @@ const Menu = ({ testId = null, cssClasses = null, style = null, menuSections })
3408
3418
  React.createElement(MenuList, { key: `section-menu-list-${parseKey()}`, itemList: section.itemList }))))));
3409
3419
  };
3410
3420
 
3421
+ const renderEllipsis = (hasEllipsis) => hasEllipsis ? (React.createElement("li", null,
3422
+ React.createElement("span", { "aria-hidden": 'true', className: 'pagination-ellipsis' }, "\u2026"))) : null;
3423
+ const renderNavigationButton = (navigationButton) => {
3424
+ var _a;
3425
+ if (!navigationButton)
3426
+ return null;
3427
+ const navigationButtonClasses = parseClasses([
3428
+ navigationButton.cssClasses,
3429
+ navigationButton.isDisabled ? 'is-disabled' : null
3430
+ ]);
3431
+ return (React.createElement("a", { className: navigationButtonClasses, onClick: (_a = navigationButton.onClick) !== null && _a !== void 0 ? _a : undefined, "aria-hidden": 'true' }, navigationButton.text));
3432
+ };
3433
+ const renderPages = (pages, hasEllipsis, ellipsisItems) => {
3434
+ return pages.map((pageItem, pageIndex, { length }) => {
3435
+ const lastEllipsisItemIndex = length - ellipsisItems - 1;
3436
+ if (pageIndex === 0) {
3437
+ return (React.createElement(React.Fragment, { key: `first-pagination-item` },
3438
+ React.createElement(PaginationItem, Object.assign({}, pageItem)),
3439
+ renderEllipsis(hasEllipsis)));
3440
+ }
3441
+ if (!hasEllipsis ||
3442
+ (pageIndex > ellipsisItems && pageIndex < lastEllipsisItemIndex)) {
3443
+ return (React.createElement(PaginationItem, Object.assign({ key: `pagination-item-${parseKey()}` }, pageItem)));
3444
+ }
3445
+ if (pageIndex === --length) {
3446
+ return (React.createElement(React.Fragment, { key: `last-pagination-item` },
3447
+ renderEllipsis(hasEllipsis),
3448
+ React.createElement(PaginationItem, Object.assign({}, pageItem))));
3449
+ }
3450
+ });
3451
+ };
3452
+ const Pagination = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, pages, ellipsisItems = 0, showPreviousPageButton = {
3453
+ text: 'Previous',
3454
+ cssClasses: 'pagination-previous'
3455
+ }, showNextPageButton = {
3456
+ text: 'Next page',
3457
+ cssClasses: 'pagination-next'
3458
+ }, hasEllipsis = false, isRounded = false, alignment = null, size = null }) => {
3459
+ const paginationContainerClasses = parseClasses([
3460
+ 'pagination',
3461
+ isRounded ? 'is-rounded' : null,
3462
+ size,
3463
+ alignment,
3464
+ cssClasses
3465
+ ]);
3466
+ const paginationContainerTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
3467
+ tag: 'pagination',
3468
+ parsedClasses: paginationContainerClasses
3469
+ });
3470
+ const paginationClasses = parseClasses([
3471
+ 'pagination-list',
3472
+ containerCssClasses
3473
+ ]);
3474
+ const paginationTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({ tag: 'pagination-list', parsedClasses: paginationClasses });
3475
+ return (React.createElement("nav", { "data-testid": paginationContainerTestId, className: paginationContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined, role: 'navigation', "aria-label": 'pagination' },
3476
+ renderNavigationButton(showPreviousPageButton),
3477
+ renderNavigationButton(showNextPageButton),
3478
+ React.createElement("ul", { "data-testid": paginationTestId, className: paginationClasses, style: style !== null && style !== void 0 ? style : undefined }, renderPages(pages, hasEllipsis, ellipsisItems))));
3479
+ };
3480
+
3411
3481
  exports.Block = Block;
3412
3482
  exports.Box = Box;
3413
3483
  exports.BreadcrumbItem = BreadcrumbItem;
@@ -3429,6 +3499,8 @@ exports.MenuItem = MenuItem;
3429
3499
  exports.MenuList = MenuList;
3430
3500
  exports.Message = Message;
3431
3501
  exports.Notification = Notification;
3502
+ exports.Pagination = Pagination;
3503
+ exports.PaginationItem = PaginationItem;
3432
3504
  exports.ProgressBar = ProgressBar;
3433
3505
  exports.RadioButton = RadioButton;
3434
3506
  exports.Select = Select;