reactive-bulma 2.11.0 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/index.js +77 -34
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/components/molecules/PanelBlock/index.d.ts +4 -0
  5. package/dist/cjs/types/components/molecules/PanelTabs/index.d.ts +4 -0
  6. package/dist/cjs/types/components/molecules/index.d.ts +2 -1
  7. package/dist/cjs/types/components/{molecules → organisms}/FormField/index.d.ts +1 -1
  8. package/dist/cjs/types/components/organisms/Panel/index.d.ts +4 -0
  9. package/dist/cjs/types/components/organisms/index.d.ts +2 -0
  10. package/dist/cjs/types/functions/generators.d.ts +4 -0
  11. package/dist/cjs/types/functions/parsers.d.ts +1 -4
  12. package/dist/cjs/types/functions/tests/generators.test.d.ts +1 -0
  13. package/dist/cjs/types/index.d.ts +1 -0
  14. package/dist/cjs/types/interfaces/atomProps.d.ts +2 -2
  15. package/dist/cjs/types/interfaces/moleculeProps.d.ts +23 -14
  16. package/dist/cjs/types/interfaces/organismProps.d.ts +29 -0
  17. package/dist/cjs/types/types/domTypes.d.ts +3 -2
  18. package/dist/esm/index.js +75 -35
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/types/components/molecules/PanelBlock/index.d.ts +4 -0
  21. package/dist/esm/types/components/molecules/PanelTabs/index.d.ts +4 -0
  22. package/dist/esm/types/components/molecules/index.d.ts +2 -1
  23. package/dist/esm/types/components/{molecules → organisms}/FormField/index.d.ts +1 -1
  24. package/dist/esm/types/components/organisms/Panel/index.d.ts +4 -0
  25. package/dist/esm/types/components/organisms/index.d.ts +2 -0
  26. package/dist/esm/types/functions/generators.d.ts +4 -0
  27. package/dist/esm/types/functions/parsers.d.ts +1 -4
  28. package/dist/esm/types/functions/tests/generators.test.d.ts +1 -0
  29. package/dist/esm/types/index.d.ts +1 -0
  30. package/dist/esm/types/interfaces/atomProps.d.ts +2 -2
  31. package/dist/esm/types/interfaces/moleculeProps.d.ts +23 -14
  32. package/dist/esm/types/interfaces/organismProps.d.ts +29 -0
  33. package/dist/esm/types/types/domTypes.d.ts +3 -2
  34. package/dist/index.d.ts +59 -17
  35. package/package.json +11 -11
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Nicolás Omar González Passerino
3
+ Copyright (c) 2024 Nicolás Omar González Passerino
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/cjs/index.js CHANGED
@@ -2861,13 +2861,6 @@ 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
- };
2871
2864
 
2872
2865
  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 }) => {
2873
2866
  const buttonClasses = parseClasses([
@@ -3159,7 +3152,7 @@ const CheckBox = ({ testId = null, containerTestId = null, cssClasses = null, co
3159
3152
  content));
3160
3153
  };
3161
3154
 
3162
- // PARSERS
3155
+ // FUNCTIONS
3163
3156
  const renderRadioButton = (config, index) => {
3164
3157
  const { testId = null, label, name, isChecked = false, isDisabled = false, style = null, onChange } = config;
3165
3158
  const radioButtonTestId = testId !== null && testId !== void 0 ? testId : `test-radio-button-item-${index}`;
@@ -3283,20 +3276,22 @@ const PaginationItem = ({ testId = null, cssClasses = null, style = null, text,
3283
3276
  };
3284
3277
 
3285
3278
  const TabItem = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, icon = null, text, onClick = null }) => {
3286
- const tabItemContainerClasses = parseClasses([
3287
- 'tabItem-container',
3288
- null,
3289
- containerCssClasses
3290
- ]);
3291
- const tabItemClasses = parseClasses(['tabItem', cssClasses]);
3292
3279
  const tabItemContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
3293
- tag: 'tabItem-container',
3294
- parsedClasses: tabItemContainerClasses
3280
+ tag: 'tab-item-container',
3281
+ parsedClasses: containerCssClasses !== null && containerCssClasses !== void 0 ? containerCssClasses : ''
3295
3282
  });
3296
- const tabItemTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'tabItem', parsedClasses: tabItemClasses });
3297
- return (React.createElement("a", { "data-testid": tabItemContainerTestId, className: tabItemContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined, "aria-hidden": 'true', onClick: onClick !== null && onClick !== void 0 ? onClick : undefined },
3283
+ const tabItemTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'tab-item', parsedClasses: cssClasses !== null && cssClasses !== void 0 ? cssClasses : '' });
3284
+ return (React.createElement("a", { "data-testid": tabItemContainerTestId, className: containerCssClasses !== null && containerCssClasses !== void 0 ? containerCssClasses : undefined, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined, "aria-hidden": 'true', onClick: onClick !== null && onClick !== void 0 ? onClick : undefined },
3298
3285
  icon ? React.createElement(Icon, Object.assign({}, icon)) : null,
3299
- React.createElement("span", { "data-testid": tabItemTestId, className: tabItemClasses, style: style !== null && style !== void 0 ? style : undefined }, text)));
3286
+ React.createElement("span", { "data-testid": tabItemTestId, className: cssClasses !== null && cssClasses !== void 0 ? cssClasses : undefined, style: style !== null && style !== void 0 ? style : undefined }, text)));
3287
+ };
3288
+
3289
+ const generateKey = (max = 5000, min = 1) => {
3290
+ max = Math.floor(max);
3291
+ min = Math.ceil(min);
3292
+ const secureRandomNumbers = new Uint32Array(1);
3293
+ window.crypto.getRandomValues(secureRandomNumbers);
3294
+ return Math.floor(secureRandomNumbers[0] * (max - min) + min).toString();
3300
3295
  };
3301
3296
 
3302
3297
  const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonList, isAttached = false, position = 'left' }) => {
@@ -3325,7 +3320,7 @@ const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonLis
3325
3320
  const shouldApplyColor = (hasSelectedButton && currentButtonItem.isSelected) ||
3326
3321
  !hasSelectedButton;
3327
3322
  const buttonConfig = Object.assign(Object.assign({}, currentButtonItem), { color: shouldApplyColor ? currentButtonItem.color : undefined });
3328
- return (React.createElement(Button, Object.assign({ key: `button-group-item-${parseKey()}` }, buttonConfig)));
3323
+ return (React.createElement(Button, Object.assign({ key: `button-group-item-${generateKey()}` }, buttonConfig)));
3329
3324
  })));
3330
3325
  };
3331
3326
 
@@ -3353,7 +3348,7 @@ const ColumnGroup = ({ testId = null, cssClasses = null, style = null, listOfCol
3353
3348
  tag: 'columns',
3354
3349
  parsedClasses: columnGroupClasses
3355
3350
  });
3356
- 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))))));
3351
+ 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-${generateKey()}` }, columnItemConfig))))));
3357
3352
  };
3358
3353
 
3359
3354
  const Notification = ({ testId = null, cssClasses = null, style = null, children = null, deleteButton = null, color = null, isLightColor = null }) => {
@@ -3395,14 +3390,14 @@ const Breadcrumbs = ({ testId = 'breadcrumbs', containerTestId = null, cssClasse
3395
3390
  ]
3396
3391
  });
3397
3392
  return (React.createElement("nav", { "data-testid": breadcrumbsContainerTestId, className: breadcrumbsContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
3398
- 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)))))));
3393
+ 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-${generateKey()}` }, itemConfig)))))));
3399
3394
  };
3400
3395
 
3401
3396
  const renderDropdownMenu = (items) => (React.createElement("section", { className: 'dropdown-content' }, items.map((dropdownItemConfig, i) => {
3402
3397
  const isFirstItemInMenu = items.length > 1 && i === 0;
3403
- return isFirstItemInMenu ? (React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${parseKey()}` }, dropdownItemConfig))) : (React.createElement("section", { key: `dropdown-item-${parseKey()}-section` },
3404
- React.createElement(DropdownItem, { key: `dropdown-item-${parseKey()}-divider`, type: 'divider', itemText: 'divider' }),
3405
- React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${parseKey()}` }, dropdownItemConfig))));
3398
+ return isFirstItemInMenu ? (React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${generateKey()}` }, dropdownItemConfig))) : (React.createElement("section", { key: `dropdown-item-${generateKey()}-section` },
3399
+ React.createElement(DropdownItem, { key: `dropdown-item-${generateKey()}-divider`, type: 'divider', itemText: 'divider' }),
3400
+ React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${generateKey()}` }, dropdownItemConfig))));
3406
3401
  })));
3407
3402
  const Dropdown = ({ testId = null, cssClasses = null, style = null, inputText, dropdownPointer = 'dropdown-menu', listOfItems }) => {
3408
3403
  const [isMenuActive, setIsMenuActive] = reactExports.useState(false);
@@ -3434,12 +3429,12 @@ const MenuList = ({ testId = null, cssClasses = null, style = null, itemList })
3434
3429
  const menuListTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'menu-list', parsedClasses: menuListClasses });
3435
3430
  return (React.createElement("ul", { "data-testid": menuListTestId, className: menuListClasses, style: style !== null && style !== void 0 ? style : undefined }, itemList.map(item => {
3436
3431
  if ('subListTitle' in item) {
3437
- return (React.createElement("li", { key: `sub-list-menu-item-${parseKey()}` },
3432
+ return (React.createElement("li", { key: `sub-list-menu-item-${generateKey()}` },
3438
3433
  React.createElement(MenuItem, Object.assign({}, item.subListTitle)),
3439
- React.createElement("ul", null, item.subItems.map(subItem => (React.createElement(MenuItem, Object.assign({ key: `sub-list-menu-sub-item-${parseKey()}` }, subItem)))))));
3434
+ React.createElement("ul", null, item.subItems.map(subItem => (React.createElement(MenuItem, Object.assign({ key: `sub-list-menu-sub-item-${generateKey()}` }, subItem)))))));
3440
3435
  }
3441
3436
  else {
3442
- return (React.createElement(MenuItem, Object.assign({ key: `sub-list-item-${parseKey()}` }, item)));
3437
+ return (React.createElement(MenuItem, Object.assign({ key: `sub-list-item-${generateKey()}` }, item)));
3443
3438
  }
3444
3439
  })));
3445
3440
  };
@@ -3447,9 +3442,9 @@ const MenuList = ({ testId = null, cssClasses = null, style = null, itemList })
3447
3442
  const Menu = ({ testId = null, cssClasses = null, style = null, menuSections }) => {
3448
3443
  const menuClasses = parseClasses(['menu', cssClasses]);
3449
3444
  const menuTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'menu', parsedClasses: menuClasses });
3450
- 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()}` },
3451
- React.createElement("p", { key: `section-label-${parseKey()}`, className: 'menu-label' }, section.label),
3452
- React.createElement(MenuList, { key: `section-menu-list-${parseKey()}`, itemList: section.itemList }))))));
3445
+ 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-${generateKey()}` },
3446
+ React.createElement("p", { key: `section-label-${generateKey()}`, className: 'menu-label' }, section.label),
3447
+ React.createElement(MenuList, { key: `section-menu-list-${generateKey()}`, itemList: section.itemList }))))));
3453
3448
  };
3454
3449
 
3455
3450
  const renderEllipsis = (hasEllipsis) => hasEllipsis ? (React.createElement("li", null,
@@ -3474,7 +3469,7 @@ const renderPages = (pages, hasEllipsis, ellipsisItems) => {
3474
3469
  }
3475
3470
  if (!hasEllipsis ||
3476
3471
  (pageIndex > ellipsisItems && pageIndex < lastEllipsisItemIndex)) {
3477
- return (React.createElement(PaginationItem, Object.assign({ key: `pagination-item-${parseKey()}` }, pageItem)));
3472
+ return (React.createElement(PaginationItem, Object.assign({ key: `pagination-item-${generateKey()}` }, pageItem)));
3478
3473
  }
3479
3474
  if (pageIndex === --length) {
3480
3475
  return (React.createElement(React.Fragment, { key: `last-pagination-item` },
@@ -3546,7 +3541,7 @@ const Tabs = ({ testId = null, cssClasses = null, style = null, tabs, alignment
3546
3541
  ]);
3547
3542
  const tabsTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'tabs', parsedClasses: tabsClasses });
3548
3543
  return (React.createElement("section", { "data-testid": tabsTestId, className: tabsClasses, style: style !== null && style !== void 0 ? style : undefined },
3549
- React.createElement("ul", null, tabs.map(tabConfig => (React.createElement("li", { key: `tab-item-${parseKey()}`, className: tabConfig.isActive ? 'is-active' : undefined }, React.createElement(TabItem, Object.assign({}, tabConfig))))))));
3544
+ React.createElement("ul", null, tabs.map(tabConfig => (React.createElement("li", { key: `tab-item-${generateKey()}`, className: tabConfig.isActive ? 'is-active' : undefined }, React.createElement(TabItem, Object.assign({}, tabConfig))))))));
3550
3545
  };
3551
3546
 
3552
3547
  const renderIcon = (iconConfig) => iconConfig ? React.createElement(Icon, Object.assign({}, iconConfig)) : null;
@@ -3581,10 +3576,45 @@ const InputControl = ({ testId = null, cssClasses = null, style = null, inputCon
3581
3576
  renderIcon(rightIcon ? Object.assign(Object.assign({}, rightIcon), { position: 'is-right' }) : undefined)));
3582
3577
  };
3583
3578
 
3579
+ const convertConfigToComponent = ({ type, props }, testId, cssClasses, style, blockText) => {
3580
+ switch (type) {
3581
+ case 'icon': {
3582
+ const panelBlockIconClasses = parseClasses(['panel-icon', cssClasses]);
3583
+ const panelBlockIconTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'panel-icon', parsedClasses: panelBlockIconClasses });
3584
+ return (React.createElement(React.Fragment, null,
3585
+ React.createElement("span", { "data-testid": panelBlockIconTestId, className: panelBlockIconClasses, style: style !== null && style !== void 0 ? style : undefined },
3586
+ React.createElement(Icon, Object.assign({}, props))),
3587
+ blockText));
3588
+ }
3589
+ case 'control':
3590
+ return React.createElement(InputControl, Object.assign({}, props));
3591
+ case 'button':
3592
+ return React.createElement(Button, Object.assign({}, props));
3593
+ }
3594
+ };
3595
+ const PanelBlock = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, config, blockText = null, isActive = false, onClick }) => {
3596
+ const panelBlockLinkClasses = parseClasses([
3597
+ 'panel-block',
3598
+ isActive ? 'is-active' : null,
3599
+ containerCssClasses
3600
+ ]);
3601
+ const panelBlockLinkTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({ tag: 'panel-block', parsedClasses: panelBlockLinkClasses });
3602
+ return (React.createElement("a", { "data-testid": panelBlockLinkTestId, className: panelBlockLinkClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined, "aria-hidden": 'true', onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, convertConfigToComponent(config, testId, cssClasses, style, blockText)));
3603
+ };
3604
+
3605
+ const PanelTabs = ({ testId = null, cssClasses = null, style = null, tabList }) => {
3606
+ const panelTabsClasses = parseClasses(['panel-tabs', cssClasses]);
3607
+ const panelTabsTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'panel-tabs', parsedClasses: panelTabsClasses });
3608
+ return (React.createElement("section", { "data-testid": panelTabsTestId, className: panelTabsClasses, style: style !== null && style !== void 0 ? style : undefined }, tabList.map(tabItem => {
3609
+ var _a;
3610
+ return (React.createElement("a", { key: `tab-item-${generateKey()}`, className: tabItem.isActive ? 'is-active' : undefined, "aria-hidden": 'true', onClick: (_a = tabItem.onClick) !== null && _a !== void 0 ? _a : undefined }, tabItem.text));
3611
+ })));
3612
+ };
3613
+
3584
3614
  const renderFieldLabel = (labelText) => labelText ? (React.createElement("label", { "data-testid": 'test-form-field-label', className: 'label' }, labelText)) : null;
3585
3615
  const renderFieldBody = (inputControlConfig, isGrouped) => {
3586
3616
  if (isGrouped) {
3587
- return Array.isArray(inputControlConfig) ? (inputControlConfig.map((_singleConfig, i) => (React.createElement(InputControl, Object.assign({ key: `grouped-input-control-${parseKey()}`, testId: `test-grouped-input-control-${i}` }, _singleConfig))))) : (React.createElement(InputControl, Object.assign({}, inputControlConfig)));
3617
+ return Array.isArray(inputControlConfig) ? (inputControlConfig.map((_singleConfig, i) => (React.createElement(InputControl, Object.assign({ key: `grouped-input-control-${generateKey()}`, testId: `test-grouped-input-control-${i}` }, _singleConfig))))) : (React.createElement(InputControl, Object.assign({}, inputControlConfig)));
3588
3618
  }
3589
3619
  else {
3590
3620
  return Array.isArray(inputControlConfig) ? (React.createElement(InputControl, Object.assign({}, inputControlConfig[0]))) : (React.createElement(InputControl, Object.assign({}, inputControlConfig)));
@@ -3624,6 +3654,16 @@ const FormField = ({ testId = null, cssClasses = null, style = null, labelText =
3624
3654
  renderFieldHelper(helperConfig)))));
3625
3655
  };
3626
3656
 
3657
+ const generateHeader = (headerText) => (React.createElement("p", { className: 'panel-heading' }, headerText));
3658
+ const Panel = ({ testId = null, cssClasses = null, style = null, headerText, panelTabs = null, blockList, color = null }) => {
3659
+ const panelClasses = parseClasses(['panel', color, cssClasses]);
3660
+ const panelTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'panel', parsedClasses: panelClasses });
3661
+ return (React.createElement("article", { "data-testid": panelTestId, className: panelClasses, style: style !== null && style !== void 0 ? style : undefined },
3662
+ generateHeader(headerText),
3663
+ panelTabs ? React.createElement(PanelTabs, Object.assign({}, panelTabs)) : null,
3664
+ blockList.map(blockConfig => (React.createElement(PanelBlock, Object.assign({ key: `panel-block-item-${generateKey()}` }, blockConfig))))));
3665
+ };
3666
+
3627
3667
  exports.Block = Block;
3628
3668
  exports.Box = Box;
3629
3669
  exports.BreadcrumbItem = BreadcrumbItem;
@@ -3651,6 +3691,9 @@ exports.Modal = Modal;
3651
3691
  exports.Notification = Notification;
3652
3692
  exports.Pagination = Pagination;
3653
3693
  exports.PaginationItem = PaginationItem;
3694
+ exports.Panel = Panel;
3695
+ exports.PanelBlock = PanelBlock;
3696
+ exports.PanelTabs = PanelTabs;
3654
3697
  exports.ProgressBar = ProgressBar;
3655
3698
  exports.RadioButton = RadioButton;
3656
3699
  exports.Select = Select;