reactive-bulma 2.6.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. package/dist/cjs/index.js +130 -13
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/atoms/MenuItem/index.d.ts +4 -0
  4. package/dist/cjs/types/components/atoms/PaginationItem/index.d.ts +4 -0
  5. package/dist/cjs/types/components/atoms/index.d.ts +2 -0
  6. package/dist/cjs/types/components/molecules/Menu/index.d.ts +4 -0
  7. package/dist/cjs/types/components/molecules/MenuList/index.d.ts +4 -0
  8. package/dist/cjs/types/components/molecules/Pagination/index.d.ts +4 -0
  9. package/dist/cjs/types/components/molecules/index.d.ts +3 -0
  10. package/dist/cjs/types/functions/parsers.d.ts +1 -0
  11. package/dist/cjs/types/interfaces/atomProps.d.ts +20 -4
  12. package/dist/cjs/types/interfaces/moleculeProps.d.ts +52 -6
  13. package/dist/cjs/types/types/styleTypes.d.ts +2 -1
  14. package/dist/esm/index.js +126 -14
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/types/components/atoms/MenuItem/index.d.ts +4 -0
  17. package/dist/esm/types/components/atoms/PaginationItem/index.d.ts +4 -0
  18. package/dist/esm/types/components/atoms/index.d.ts +2 -0
  19. package/dist/esm/types/components/molecules/Menu/index.d.ts +4 -0
  20. package/dist/esm/types/components/molecules/MenuList/index.d.ts +4 -0
  21. package/dist/esm/types/components/molecules/Pagination/index.d.ts +4 -0
  22. package/dist/esm/types/components/molecules/index.d.ts +3 -0
  23. package/dist/esm/types/functions/parsers.d.ts +1 -0
  24. package/dist/esm/types/interfaces/atomProps.d.ts +20 -4
  25. package/dist/esm/types/interfaces/moleculeProps.d.ts +52 -6
  26. package/dist/esm/types/types/styleTypes.d.ts +2 -1
  27. package/dist/index.d.ts +80 -8
  28. package/package.json +18 -18
package/dist/cjs/index.js CHANGED
@@ -2861,6 +2861,13 @@ const parseTestId = (config) => {
2861
2861
  }
2862
2862
  return `test-${config.tag}${fixedClassString.replace(/ /gm, (_a = config.separator) !== null && _a !== void 0 ? _a : '')}`;
2863
2863
  };
2864
+ const parseKey = (max = 5000, min = 1) => {
2865
+ max = Math.floor(max);
2866
+ min = Math.ceil(min);
2867
+ const secureRandomNumbers = new Uint32Array(1);
2868
+ window.crypto.getRandomValues(secureRandomNumbers);
2869
+ return Math.floor(secureRandomNumbers[0] * (max - min) + min).toString();
2870
+ };
2864
2871
 
2865
2872
  const Button = ({ testId = null, cssClasses = null, style = null, type = 'button', text = null, isDisabled = false, color = null, isLightColor = false, isInvertedColor = false, isOutlined = false, isRounded = false, isLoading = false, isStatic = false, isSelected = false, size = null, onClick = null }) => {
2866
2873
  const buttonClasses = parseClasses([
@@ -2935,7 +2942,7 @@ const Tag = ({ testId = null, containerTestId = null, cssClasses = null, contain
2935
2942
  const tagDeleteTestId = `${tagTestId}-delete`;
2936
2943
  return withAddon ? (React.createElement("section", { "data-testid": tagContainerTestId, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined, className: tagContainerClasses },
2937
2944
  React.createElement("span", { "data-testid": tagTestId, className: tagClasses }, text),
2938
- withDelete ? (React.createElement("a", { "data-testid": tagDeleteTestId, className: 'tag is-delete', 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 },
2939
2946
  text,
2940
2947
  withDelete ? (React.createElement("button", { "data-testid": tagDeleteTestId, className: 'delete', onClick: onDeleteClick !== null && onDeleteClick !== void 0 ? onDeleteClick : undefined })) : null));
2941
2948
  };
@@ -2944,8 +2951,6 @@ const Box = ({ testId = 'test-box', cssClasses = 'box', style = null, children =
2944
2951
 
2945
2952
  const renderTitleSection = (section) => {
2946
2953
  var _a, _b;
2947
- if (!section)
2948
- return null;
2949
2954
  const { type, size, isSpaced, cssClasses } = section;
2950
2955
  const sectionClasses = parseClasses([
2951
2956
  type,
@@ -2957,8 +2962,8 @@ const renderTitleSection = (section) => {
2957
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));
2958
2963
  };
2959
2964
  const Title = ({ main, secondary }) => (React.createElement(React.Fragment, null,
2960
- renderTitleSection(main),
2961
- renderTitleSection(secondary)));
2965
+ main ? renderTitleSection(main) : null,
2966
+ secondary ? renderTitleSection(secondary) : null));
2962
2967
 
2963
2968
  var IconSizeEnum;
2964
2969
  (function (IconSizeEnum) {
@@ -3186,7 +3191,7 @@ const BreadcrumbItem = ({ testId = null, containerTestId = null, cssClasses = nu
3186
3191
  });
3187
3192
  const breadcrumbItemTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'breadcrumbItem', parsedClasses: breadcrumbItemClasses });
3188
3193
  return (React.createElement("li", { "data-testid": breadcrumbItemContainerTestId, className: breadcrumbItemContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
3189
- React.createElement("a", { "data-testid": breadcrumbItemTestId, className: breadcrumbItemClasses, style: style !== null && style !== void 0 ? style : undefined, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, text)));
3194
+ React.createElement("a", { "data-testid": breadcrumbItemTestId, className: breadcrumbItemClasses, style: style !== null && style !== void 0 ? style : undefined, "aria-hidden": 'true', onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, text)));
3190
3195
  };
3191
3196
 
3192
3197
  const DropdownTrigger = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, menuText, dropdownPointer = 'dropdown-menu', onClick = null }) => {
@@ -3236,6 +3241,30 @@ const DropdownItem = ({ testId = null, cssClasses = null, style = null, itemText
3236
3241
  }
3237
3242
  };
3238
3243
 
3244
+ const MenuItem = ({ testId = null, cssClasses = null, style = null, text, isActive = null, onClick = null }) => {
3245
+ const menuItemClasses = parseClasses([
3246
+ 'menuItem',
3247
+ isActive ? 'is-active' : null,
3248
+ cssClasses
3249
+ ]);
3250
+ const menuItemTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'menuItem', parsedClasses: menuItemClasses });
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));
3252
+ };
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
+
3239
3268
  const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonList, isAttached = false, position = 'left' }) => {
3240
3269
  const buttonGroupClasses = parseClasses([
3241
3270
  'buttons',
@@ -3257,12 +3286,12 @@ const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonLis
3257
3286
  }
3258
3287
  ]
3259
3288
  });
3260
- return (React.createElement("section", { "data-testid": buttonGroupTestId, className: buttonGroupClasses, style: style !== null && style !== void 0 ? style : undefined }, buttonList.map((currentButtonItem, i, originalButtonList) => {
3289
+ return (React.createElement("section", { "data-testid": buttonGroupTestId, className: buttonGroupClasses, style: style !== null && style !== void 0 ? style : undefined }, buttonList.map((currentButtonItem, _, originalButtonList) => {
3261
3290
  const hasSelectedButton = originalButtonList.some(({ isSelected }) => isSelected);
3262
3291
  const shouldApplyColor = (hasSelectedButton && currentButtonItem.isSelected) ||
3263
3292
  !hasSelectedButton;
3264
3293
  const buttonConfig = Object.assign(Object.assign({}, currentButtonItem), { color: shouldApplyColor ? currentButtonItem.color : undefined });
3265
- return (React.createElement(Button, Object.assign({ key: `button-group-item-${i}` }, buttonConfig)));
3294
+ return (React.createElement(Button, Object.assign({ key: `button-group-item-${parseKey()}` }, buttonConfig)));
3266
3295
  })));
3267
3296
  };
3268
3297
 
@@ -3290,7 +3319,7 @@ const ColumnGroup = ({ testId = null, cssClasses = null, style = null, listOfCol
3290
3319
  tag: 'columns',
3291
3320
  parsedClasses: columnGroupClasses
3292
3321
  });
3293
- return (React.createElement("section", { "data-testid": columnGroupTestId, className: columnGroupClasses, style: style !== null && style !== void 0 ? style : undefined }, listOfColumns.map((_columnItem, i) => (React.createElement(Column, Object.assign({ key: `column-group-item-${i}` }, _columnItem))))));
3322
+ return (React.createElement("section", { "data-testid": columnGroupTestId, className: columnGroupClasses, style: style !== null && style !== void 0 ? style : undefined }, listOfColumns.map(columnItemConfig => (React.createElement(Column, Object.assign({ key: `column-group-item-${parseKey()}` }, columnItemConfig))))));
3294
3323
  };
3295
3324
 
3296
3325
  const Notification = ({ testId = null, cssClasses = null, style = null, children = null, deleteButton = null, color = null, isLightColor = null }) => {
@@ -3332,14 +3361,14 @@ const Breadcrumbs = ({ testId = 'breadcrumbs', containerTestId = null, cssClasse
3332
3361
  ]
3333
3362
  });
3334
3363
  return (React.createElement("nav", { "data-testid": breadcrumbsContainerTestId, className: breadcrumbsContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
3335
- React.createElement("ul", { "data-testid": testId, className: cssClasses !== null && cssClasses !== void 0 ? cssClasses : undefined, style: style !== null && style !== void 0 ? style : undefined }, items.map((itemConfig, i) => (React.createElement(BreadcrumbItem, Object.assign({ key: `breadcrumb-item-${i}` }, itemConfig)))))));
3364
+ React.createElement("ul", { "data-testid": testId, className: cssClasses !== null && cssClasses !== void 0 ? cssClasses : undefined, style: style !== null && style !== void 0 ? style : undefined }, items.map(itemConfig => (React.createElement(BreadcrumbItem, Object.assign({ key: `breadcrumb-item-${parseKey()}` }, itemConfig)))))));
3336
3365
  };
3337
3366
 
3338
3367
  const renderDropdownMenu = (items) => (React.createElement("section", { className: 'dropdown-content' }, items.map((dropdownItemConfig, i) => {
3339
3368
  const isFirstItemInMenu = items.length > 1 && i === 0;
3340
- return isFirstItemInMenu ? (React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${i}` }, dropdownItemConfig))) : (React.createElement("section", { key: `dropdown-item-${i}-section` },
3341
- React.createElement(DropdownItem, { key: `dropdown-item-${i}-divider`, type: 'divider', itemText: 'divider' }),
3342
- React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${i}` }, dropdownItemConfig))));
3369
+ return isFirstItemInMenu ? (React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${parseKey()}` }, dropdownItemConfig))) : (React.createElement("section", { key: `dropdown-item-${parseKey()}-section` },
3370
+ React.createElement(DropdownItem, { key: `dropdown-item-${parseKey()}-divider`, type: 'divider', itemText: 'divider' }),
3371
+ React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${parseKey()}` }, dropdownItemConfig))));
3343
3372
  })));
3344
3373
  const Dropdown = ({ testId = null, cssClasses = null, style = null, inputText, dropdownPointer = 'dropdown-menu', listOfItems }) => {
3345
3374
  const [isMenuActive, setIsMenuActive] = reactExports.useState(false);
@@ -3366,6 +3395,89 @@ const Message = ({ testId = null, cssClasses = null, style = null, headerText =
3366
3395
  React.createElement("section", { "data-testid": `${messageTestId}-body`, className: 'message-body' }, bodyText)));
3367
3396
  };
3368
3397
 
3398
+ const MenuList = ({ testId = null, cssClasses = null, style = null, itemList }) => {
3399
+ const menuListClasses = parseClasses(['menu-list', cssClasses]);
3400
+ const menuListTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'menu-list', parsedClasses: menuListClasses });
3401
+ return (React.createElement("ul", { "data-testid": menuListTestId, className: menuListClasses, style: style !== null && style !== void 0 ? style : undefined }, itemList.map(item => {
3402
+ if ('subListTitle' in item) {
3403
+ return (React.createElement("li", { key: `sub-list-menu-item-${parseKey()}` },
3404
+ React.createElement(MenuItem, Object.assign({}, item.subListTitle)),
3405
+ React.createElement("ul", null, item.subItems.map(subItem => (React.createElement(MenuItem, Object.assign({ key: `sub-list-menu-sub-item-${parseKey()}` }, subItem)))))));
3406
+ }
3407
+ else {
3408
+ return (React.createElement(MenuItem, Object.assign({ key: `sub-list-item-${parseKey()}` }, item)));
3409
+ }
3410
+ })));
3411
+ };
3412
+
3413
+ const Menu = ({ testId = null, cssClasses = null, style = null, menuSections }) => {
3414
+ const menuClasses = parseClasses(['menu', cssClasses]);
3415
+ const menuTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'menu', parsedClasses: menuClasses });
3416
+ return (React.createElement("aside", { "data-testid": menuTestId, className: menuClasses, style: style !== null && style !== void 0 ? style : undefined }, menuSections.map(section => (React.createElement(React.Fragment, { key: `section-${parseKey()}` },
3417
+ React.createElement("p", { key: `section-label-${parseKey()}`, className: 'menu-label' }, section.label),
3418
+ React.createElement(MenuList, { key: `section-menu-list-${parseKey()}`, itemList: section.itemList }))))));
3419
+ };
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
+
3369
3481
  exports.Block = Block;
3370
3482
  exports.Box = Box;
3371
3483
  exports.BreadcrumbItem = BreadcrumbItem;
@@ -3382,8 +3494,13 @@ exports.DropdownTrigger = DropdownTrigger;
3382
3494
  exports.File = File;
3383
3495
  exports.Icon = Icon;
3384
3496
  exports.Input = Input;
3497
+ exports.Menu = Menu;
3498
+ exports.MenuItem = MenuItem;
3499
+ exports.MenuList = MenuList;
3385
3500
  exports.Message = Message;
3386
3501
  exports.Notification = Notification;
3502
+ exports.Pagination = Pagination;
3503
+ exports.PaginationItem = PaginationItem;
3387
3504
  exports.ProgressBar = ProgressBar;
3388
3505
  exports.RadioButton = RadioButton;
3389
3506
  exports.Select = Select;