reactive-bulma 2.5.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +16 -9
- package/dist/cjs/index.js +65 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/atoms/MenuItem/index.d.ts +4 -0
- package/dist/cjs/types/components/atoms/index.d.ts +1 -0
- package/dist/cjs/types/components/molecules/Menu/index.d.ts +4 -0
- package/dist/cjs/types/components/molecules/MenuList/index.d.ts +4 -0
- package/dist/cjs/types/components/molecules/Message/index.d.ts +4 -0
- package/dist/cjs/types/components/molecules/index.d.ts +3 -0
- package/dist/cjs/types/functions/parsers.d.ts +1 -0
- package/dist/cjs/types/interfaces/atomProps.d.ts +6 -0
- package/dist/cjs/types/interfaces/moleculeProps.d.ts +33 -1
- package/dist/esm/index.js +62 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/atoms/MenuItem/index.d.ts +4 -0
- package/dist/esm/types/components/atoms/index.d.ts +1 -0
- package/dist/esm/types/components/molecules/Menu/index.d.ts +4 -0
- package/dist/esm/types/components/molecules/MenuList/index.d.ts +4 -0
- package/dist/esm/types/components/molecules/Message/index.d.ts +4 -0
- package/dist/esm/types/components/molecules/index.d.ts +3 -0
- package/dist/esm/types/functions/parsers.d.ts +1 -0
- package/dist/esm/types/interfaces/atomProps.d.ts +6 -0
- package/dist/esm/types/interfaces/moleculeProps.d.ts +33 -1
- package/dist/index.d.ts +46 -1
- package/package.json +34 -29
package/README.md
CHANGED
@@ -153,15 +153,6 @@ Reactive bulma's documentation, included in this repo in the root directory, is
|
|
153
153
|
|
154
154
|
Learn more about `Storybook` by reading its [documentation](https://storybook.js.org/docs/react/get-started/install).
|
155
155
|
|
156
|
-
### How to create a template component
|
157
|
-
|
158
|
-
After some time, I understood that creating component files is a repetitive and time-consuming task, so I made issue [#180](https://github.com/NicolasOmar/reactive-bulma/issues/180) to implement a library called [Hygen](https://www.hygen.io), whose function is to provide a way to generate templates for generic files that can consume time at the long term. You can run the script by the following steps:
|
159
|
-
|
160
|
-
- Open a console and run `npm run create` in your console.
|
161
|
-
- An will assistant will appear asking about how your component will be named. You can answer with text separated with spaces (` `), underscores (`_`), or hyphens (`-`)
|
162
|
-
- Then, the assistant will ask in which folder you want to create it (based on its type following [Atomic Design hierarchy structure](https://atomicdesign.bradfrost.com/chapter-2/))
|
163
|
-
- At last, the script should create all base files to reduce time and focus on custom implementation.
|
164
|
-
|
165
156
|
Learn more about `Hygen` by reading its [documentation](https://www.hygen.io/docs/quick-start).
|
166
157
|
|
167
158
|
## Usage
|
@@ -178,6 +169,22 @@ To see all component's variants and its code snippets, go to [Documentation](#do
|
|
178
169
|
|
179
170
|
In case you want to create a custom component for your forked Reactive Bulma version, the easiest way is by running the creation script I made, which [instructions are here](#how-to-create-a-template-component).
|
180
171
|
|
172
|
+
### How to create a template component
|
173
|
+
|
174
|
+
After some time, I understood that creating component files is a repetitive and time-consuming task, so I made issue [#180](https://github.com/NicolasOmar/reactive-bulma/issues/180) to implement a library called [Hygen](https://www.hygen.io), whose function is to provide a way to generate templates for generic files that can consume time at the long term. You can run the script by the following steps:
|
175
|
+
|
176
|
+
- Open a console and run `npm run create` in your console.
|
177
|
+
- An will assistant will appear asking about how your component will be named. You can answer with text separated with spaces (` `), underscores (`_`), or hyphens (`-`)
|
178
|
+
- Then, the assistant will ask in which folder you want to create it (based on its type following [Atomic Design hierarchy structure](https://atomicdesign.bradfrost.com/chapter-2/))
|
179
|
+
- At last, the script should create all base files to reduce time and focus on custom implementation.
|
180
|
+
|
181
|
+
### How to update all dependencies
|
182
|
+
|
183
|
+
In case you wanted to make your own fork, I recommend you to updated at least weekly using a custom command `npm run update`, which will run the following commands in order:
|
184
|
+
- `update:deps`: Using a [npm-check-updates](https://www.npmjs.com/package/npm-check-updates) script, you will be able to choose which dependencies want to update to latest version
|
185
|
+
- `update:doctor`: Will run a set of build and test checks in order to assure your update will not break any current build.
|
186
|
+
- `update:storybook`: Will update storybook to lastest version (following its recommended command) followed for a build check (similar to update:doctor, but for storybook only)
|
187
|
+
|
181
188
|
## Versioning
|
182
189
|
|
183
190
|
After investigating [semantic-release documentation](https://semantic-release.gitbook.io/semantic-release/) (reffer to [#3](https://github.com/NicolasOmar/reactive-bulma/issues/3)) and having a problematic implementation, I decided to change version meaning for this project with the following:
|
package/dist/cjs/index.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
var crypto = require('crypto');
|
4
|
+
|
3
5
|
function styleInject(css, ref) {
|
4
6
|
if ( ref === void 0 ) ref = {};
|
5
7
|
var insertAt = ref.insertAt;
|
@@ -2861,6 +2863,13 @@ const parseTestId = (config) => {
|
|
2861
2863
|
}
|
2862
2864
|
return `test-${config.tag}${fixedClassString.replace(/ /gm, (_a = config.separator) !== null && _a !== void 0 ? _a : '')}`;
|
2863
2865
|
};
|
2866
|
+
const parseKey = (max = 5000, min = 1) => {
|
2867
|
+
max = Math.floor(max);
|
2868
|
+
min = Math.ceil(min);
|
2869
|
+
const secureRandomNumbers = new Uint32Array(1);
|
2870
|
+
crypto.getRandomValues(secureRandomNumbers);
|
2871
|
+
return Math.floor(secureRandomNumbers[0] * (max - min) + min).toString();
|
2872
|
+
};
|
2864
2873
|
|
2865
2874
|
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
2875
|
const buttonClasses = parseClasses([
|
@@ -2935,7 +2944,7 @@ const Tag = ({ testId = null, containerTestId = null, cssClasses = null, contain
|
|
2935
2944
|
const tagDeleteTestId = `${tagTestId}-delete`;
|
2936
2945
|
return withAddon ? (React.createElement("section", { "data-testid": tagContainerTestId, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined, className: tagContainerClasses },
|
2937
2946
|
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 },
|
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 },
|
2939
2948
|
text,
|
2940
2949
|
withDelete ? (React.createElement("button", { "data-testid": tagDeleteTestId, className: 'delete', onClick: onDeleteClick !== null && onDeleteClick !== void 0 ? onDeleteClick : undefined })) : null));
|
2941
2950
|
};
|
@@ -3186,7 +3195,7 @@ const BreadcrumbItem = ({ testId = null, containerTestId = null, cssClasses = nu
|
|
3186
3195
|
});
|
3187
3196
|
const breadcrumbItemTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'breadcrumbItem', parsedClasses: breadcrumbItemClasses });
|
3188
3197
|
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)));
|
3198
|
+
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
3199
|
};
|
3191
3200
|
|
3192
3201
|
const DropdownTrigger = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, menuText, dropdownPointer = 'dropdown-menu', onClick = null }) => {
|
@@ -3236,6 +3245,16 @@ const DropdownItem = ({ testId = null, cssClasses = null, style = null, itemText
|
|
3236
3245
|
}
|
3237
3246
|
};
|
3238
3247
|
|
3248
|
+
const MenuItem = ({ testId = null, cssClasses = null, style = null, text, isActive = null, onClick = null }) => {
|
3249
|
+
const menuItemClasses = parseClasses([
|
3250
|
+
'menuItem',
|
3251
|
+
isActive ? 'is-active' : null,
|
3252
|
+
cssClasses
|
3253
|
+
]);
|
3254
|
+
const menuItemTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'menuItem', parsedClasses: menuItemClasses });
|
3255
|
+
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
|
+
};
|
3257
|
+
|
3239
3258
|
const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonList, isAttached = false, position = 'left' }) => {
|
3240
3259
|
const buttonGroupClasses = parseClasses([
|
3241
3260
|
'buttons',
|
@@ -3257,12 +3276,12 @@ const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonLis
|
|
3257
3276
|
}
|
3258
3277
|
]
|
3259
3278
|
});
|
3260
|
-
return (React.createElement("section", { "data-testid": buttonGroupTestId, className: buttonGroupClasses, style: style !== null && style !== void 0 ? style : undefined }, buttonList.map((currentButtonItem,
|
3279
|
+
return (React.createElement("section", { "data-testid": buttonGroupTestId, className: buttonGroupClasses, style: style !== null && style !== void 0 ? style : undefined }, buttonList.map((currentButtonItem, _, originalButtonList) => {
|
3261
3280
|
const hasSelectedButton = originalButtonList.some(({ isSelected }) => isSelected);
|
3262
3281
|
const shouldApplyColor = (hasSelectedButton && currentButtonItem.isSelected) ||
|
3263
3282
|
!hasSelectedButton;
|
3264
3283
|
const buttonConfig = Object.assign(Object.assign({}, currentButtonItem), { color: shouldApplyColor ? currentButtonItem.color : undefined });
|
3265
|
-
return (React.createElement(Button, Object.assign({ key: `button-group-item-${
|
3284
|
+
return (React.createElement(Button, Object.assign({ key: `button-group-item-${parseKey()}` }, buttonConfig)));
|
3266
3285
|
})));
|
3267
3286
|
};
|
3268
3287
|
|
@@ -3290,7 +3309,7 @@ const ColumnGroup = ({ testId = null, cssClasses = null, style = null, listOfCol
|
|
3290
3309
|
tag: 'columns',
|
3291
3310
|
parsedClasses: columnGroupClasses
|
3292
3311
|
});
|
3293
|
-
return (React.createElement("section", { "data-testid": columnGroupTestId, className: columnGroupClasses, style: style !== null && style !== void 0 ? style : undefined }, listOfColumns.map(
|
3312
|
+
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
3313
|
};
|
3295
3314
|
|
3296
3315
|
const Notification = ({ testId = null, cssClasses = null, style = null, children = null, deleteButton = null, color = null, isLightColor = null }) => {
|
@@ -3332,14 +3351,14 @@ const Breadcrumbs = ({ testId = 'breadcrumbs', containerTestId = null, cssClasse
|
|
3332
3351
|
]
|
3333
3352
|
});
|
3334
3353
|
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(
|
3354
|
+
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
3355
|
};
|
3337
3356
|
|
3338
3357
|
const renderDropdownMenu = (items) => (React.createElement("section", { className: 'dropdown-content' }, items.map((dropdownItemConfig, i) => {
|
3339
3358
|
const isFirstItemInMenu = items.length > 1 && i === 0;
|
3340
|
-
return isFirstItemInMenu ? (React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${
|
3341
|
-
React.createElement(DropdownItem, { key: `dropdown-item-${
|
3342
|
-
React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${
|
3359
|
+
return isFirstItemInMenu ? (React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${parseKey()}` }, dropdownItemConfig))) : (React.createElement("section", { key: `dropdown-item-${parseKey()}-section` },
|
3360
|
+
React.createElement(DropdownItem, { key: `dropdown-item-${parseKey()}-divider`, type: 'divider', itemText: 'divider' }),
|
3361
|
+
React.createElement(DropdownItem, Object.assign({ key: `dropdown-item-${parseKey()}` }, dropdownItemConfig))));
|
3343
3362
|
})));
|
3344
3363
|
const Dropdown = ({ testId = null, cssClasses = null, style = null, inputText, dropdownPointer = 'dropdown-menu', listOfItems }) => {
|
3345
3364
|
const [isMenuActive, setIsMenuActive] = reactExports.useState(false);
|
@@ -3356,6 +3375,39 @@ const Dropdown = ({ testId = null, cssClasses = null, style = null, inputText, d
|
|
3356
3375
|
React.createElement("section", { className: 'dropdown-menu', id: dropdownPointer, role: 'menu' }, renderDropdownMenu(listOfItems))));
|
3357
3376
|
};
|
3358
3377
|
|
3378
|
+
const Message = ({ testId = null, cssClasses = null, style = null, headerText = null, bodyText, deleteButton = null, color = null, size = null }) => {
|
3379
|
+
const messageClasses = parseClasses(['message', color, size, cssClasses]);
|
3380
|
+
const messageTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'message', parsedClasses: messageClasses });
|
3381
|
+
return (React.createElement("article", { "data-testid": messageTestId, className: messageClasses, style: style !== null && style !== void 0 ? style : undefined },
|
3382
|
+
headerText && (React.createElement("section", { "data-testid": `${messageTestId}-header`, className: 'message-header' },
|
3383
|
+
React.createElement("p", null, headerText),
|
3384
|
+
deleteButton ? React.createElement(Delete, Object.assign({}, deleteButton)) : null)),
|
3385
|
+
React.createElement("section", { "data-testid": `${messageTestId}-body`, className: 'message-body' }, bodyText)));
|
3386
|
+
};
|
3387
|
+
|
3388
|
+
const MenuList = ({ testId = null, cssClasses = null, style = null, itemList }) => {
|
3389
|
+
const menuListClasses = parseClasses(['menu-list', cssClasses]);
|
3390
|
+
const menuListTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'menu-list', parsedClasses: menuListClasses });
|
3391
|
+
return (React.createElement("ul", { "data-testid": menuListTestId, className: menuListClasses, style: style !== null && style !== void 0 ? style : undefined }, itemList.map(item => {
|
3392
|
+
if ('subListTitle' in item) {
|
3393
|
+
return (React.createElement("li", { key: `sub-list-menu-item-${parseKey()}` },
|
3394
|
+
React.createElement(MenuItem, Object.assign({}, item.subListTitle)),
|
3395
|
+
React.createElement("ul", null, item.subItems.map(subItem => (React.createElement(MenuItem, Object.assign({ key: `sub-list-menu-sub-item-${parseKey()}` }, subItem)))))));
|
3396
|
+
}
|
3397
|
+
else {
|
3398
|
+
return (React.createElement(MenuItem, Object.assign({ key: `sub-list-item-${parseKey()}` }, item)));
|
3399
|
+
}
|
3400
|
+
})));
|
3401
|
+
};
|
3402
|
+
|
3403
|
+
const Menu = ({ testId = null, cssClasses = null, style = null, menuSections }) => {
|
3404
|
+
const menuClasses = parseClasses(['menu', cssClasses]);
|
3405
|
+
const menuTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'menu', parsedClasses: menuClasses });
|
3406
|
+
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()}` },
|
3407
|
+
React.createElement("p", { key: `section-label-${parseKey()}`, className: 'menu-label' }, section.label),
|
3408
|
+
React.createElement(MenuList, { key: `section-menu-list-${parseKey()}`, itemList: section.itemList }))))));
|
3409
|
+
};
|
3410
|
+
|
3359
3411
|
exports.Block = Block;
|
3360
3412
|
exports.Box = Box;
|
3361
3413
|
exports.BreadcrumbItem = BreadcrumbItem;
|
@@ -3372,6 +3424,10 @@ exports.DropdownTrigger = DropdownTrigger;
|
|
3372
3424
|
exports.File = File;
|
3373
3425
|
exports.Icon = Icon;
|
3374
3426
|
exports.Input = Input;
|
3427
|
+
exports.Menu = Menu;
|
3428
|
+
exports.MenuItem = MenuItem;
|
3429
|
+
exports.MenuList = MenuList;
|
3430
|
+
exports.Message = Message;
|
3375
3431
|
exports.Notification = Notification;
|
3376
3432
|
exports.ProgressBar = ProgressBar;
|
3377
3433
|
exports.RadioButton = RadioButton;
|