reactive-bulma 2.4.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +23 -9
- package/dist/cjs/index.js +82 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/atoms/DropdownItem/index.d.ts +4 -0
- package/dist/cjs/types/components/atoms/DropdownTrigger/index.d.ts +4 -0
- package/dist/cjs/types/components/atoms/index.d.ts +2 -0
- package/dist/cjs/types/components/molecules/Dropdown/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 +2 -0
- package/dist/cjs/types/interfaces/atomProps.d.ts +21 -17
- package/dist/cjs/types/interfaces/commonProps.d.ts +4 -0
- package/dist/cjs/types/interfaces/moleculeProps.d.ts +21 -1
- package/dist/cjs/types/types/domTypes.d.ts +1 -0
- package/dist/esm/index.js +79 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/atoms/DropdownItem/index.d.ts +4 -0
- package/dist/esm/types/components/atoms/DropdownTrigger/index.d.ts +4 -0
- package/dist/esm/types/components/atoms/index.d.ts +2 -0
- package/dist/esm/types/components/molecules/Dropdown/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 +2 -0
- package/dist/esm/types/interfaces/atomProps.d.ts +21 -17
- package/dist/esm/types/interfaces/commonProps.d.ts +4 -0
- package/dist/esm/types/interfaces/moleculeProps.d.ts +21 -1
- package/dist/esm/types/types/domTypes.d.ts +1 -0
- package/dist/index.d.ts +53 -16
- package/package.json +29 -23
package/README.md
CHANGED
@@ -85,28 +85,34 @@ After studying [an Udemy course about Typescript](https://github.com/NicolasOmar
|
|
85
85
|
[![material design dependency][badge-dependency-material-design]][link-package-dependencies]
|
86
86
|
[![typescript dependency][badge-dependency-typescript]][link-package-dependencies]
|
87
87
|
[![rollup dependency][badge-dependency-rollup]][link-package-dependencies]
|
88
|
+
[![postcss dependency][badge-dependency-postcss]][link-package-dependencies]
|
88
89
|
[![storybook dependency][badge-dependency-storybook]][link-package-dependencies]
|
89
90
|
[![semantic release dependency][badge-dependency-semantic-release]][link-package-dependencies]
|
90
91
|
[![babel dependency][badge-dependency-babel]][link-package-dependencies]
|
91
92
|
[![jest dependency][badge-dependency-jest]][link-package-dependencies]
|
92
93
|
[![react testing library dependency][badge-dependency-react-testing]][link-package-dependencies]
|
94
|
+
[![lint-staged dependency][badge-dependency-lint-staged]][link-package-dependencies]
|
93
95
|
[![prettier dependency][badge-dependency-prettier]][link-package-dependencies]
|
94
96
|
[![eslint dependency][badge-dependency-eslint]][link-package-dependencies]
|
95
97
|
[![husky dependency][badge-dependency-husky]][link-package-dependencies]
|
98
|
+
[![hygen dependency][badge-dependency-hygen]][link-package-dependencies]
|
96
99
|
|
97
100
|
[badge-dependency-react]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/react/main?logo=react
|
98
101
|
[badge-dependency-bulma]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/bulma/main?logo=bulma
|
99
102
|
[badge-dependency-material-design]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/@mdi/font/main?logo=materialdesignicons
|
100
103
|
[badge-dependency-typescript]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/typescript/main?logo=typescript
|
104
|
+
[badge-dependency-postcss]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/postcss/main?logo=postcss
|
101
105
|
[badge-dependency-rollup]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/rollup/main?logo=rollup.js
|
102
106
|
[badge-dependency-storybook]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/storybook/main?logo=storybook
|
103
107
|
[badge-dependency-semantic-release]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/semantic-release/main?logo=semantic-release
|
104
108
|
[badge-dependency-babel]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/@babel/core/main?logo=babel
|
105
109
|
[badge-dependency-jest]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/jest/main?logo=jest
|
106
110
|
[badge-dependency-react-testing]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/@testing-library/react/main?logo=testing-library
|
111
|
+
[badge-dependency-lint-staged]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/lint-staged/main?logo=lint-staged
|
107
112
|
[badge-dependency-prettier]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/prettier/main?logo=prettier
|
108
113
|
[badge-dependency-eslint]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/eslint/main?logo=eslint
|
109
114
|
[badge-dependency-husky]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/husky/main?logo=husky
|
115
|
+
[badge-dependency-hygen]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/hygen/main?logo=hygen
|
110
116
|
[link-package-dependencies]: https://github.com/NicolasOmar/reactive-bulma/blob/main/package.json
|
111
117
|
|
112
118
|
## Quick start
|
@@ -120,6 +126,7 @@ Several quick start options are available:
|
|
120
126
|
## Folder structure
|
121
127
|
|
122
128
|
In case you have cloned the repo, it will show you the following folders:
|
129
|
+
- `_templates:` Dedicated to [Hygen](https://www.hygen.io/) configuration and implementation files. Dedicated to create new components from customizable templates
|
123
130
|
- `.github:` [Github Actions](https://github.com/features/actions/) files used to run post-merge.commits like unit test coverage collection.
|
124
131
|
- `.husky:` Dedicated to [Husky](https://typicode.github.io/husky/) configuration files.
|
125
132
|
- `.storybook:` Dedicated to [Storybook](https://storybook.js.org/) configuration files.
|
@@ -146,15 +153,6 @@ Reactive bulma's documentation, included in this repo in the root directory, is
|
|
146
153
|
|
147
154
|
Learn more about `Storybook` by reading its [documentation](https://storybook.js.org/docs/react/get-started/install).
|
148
155
|
|
149
|
-
### How to create a template component
|
150
|
-
|
151
|
-
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:
|
152
|
-
|
153
|
-
- Open a console and run `npm run create` in your console.
|
154
|
-
- An will assistant will appear asking about how your component will be named. You can answer with text separated with spaces (` `), underscores (`_`), or hyphens (`-`)
|
155
|
-
- 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/))
|
156
|
-
- At last, the script should create all base files to reduce time and focus on custom implementation.
|
157
|
-
|
158
156
|
Learn more about `Hygen` by reading its [documentation](https://www.hygen.io/docs/quick-start).
|
159
157
|
|
160
158
|
## Usage
|
@@ -171,6 +169,22 @@ To see all component's variants and its code snippets, go to [Documentation](#do
|
|
171
169
|
|
172
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).
|
173
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
|
+
|
174
188
|
## Versioning
|
175
189
|
|
176
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
@@ -3189,6 +3189,53 @@ const BreadcrumbItem = ({ testId = null, containerTestId = null, cssClasses = nu
|
|
3189
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)));
|
3190
3190
|
};
|
3191
3191
|
|
3192
|
+
const DropdownTrigger = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, menuText, dropdownPointer = 'dropdown-menu', onClick = null }) => {
|
3193
|
+
const dropdownTriggerContainerClasses = parseClasses([
|
3194
|
+
'dropdown-trigger',
|
3195
|
+
containerCssClasses
|
3196
|
+
]);
|
3197
|
+
const dropdownTriggerContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
|
3198
|
+
tag: 'dropdown-trigger',
|
3199
|
+
parsedClasses: dropdownTriggerContainerClasses
|
3200
|
+
});
|
3201
|
+
const dropdownTriggerClasses = parseClasses(['button', cssClasses]);
|
3202
|
+
const dropdownTriggerTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'button', parsedClasses: dropdownTriggerClasses });
|
3203
|
+
return (React.createElement("section", { "data-testid": dropdownTriggerContainerTestId, className: dropdownTriggerContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
3204
|
+
React.createElement("button", { "data-testid": dropdownTriggerTestId, className: dropdownTriggerClasses, style: style !== null && style !== void 0 ? style : undefined, "aria-haspopup": 'true', "aria-controls": dropdownPointer, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined },
|
3205
|
+
React.createElement("span", null, menuText),
|
3206
|
+
React.createElement("span", { className: 'icon is-small' },
|
3207
|
+
React.createElement("i", { className: 'mdi mdi-chevron-down', "aria-hidden": 'true' })))));
|
3208
|
+
};
|
3209
|
+
|
3210
|
+
const DropdownItem = ({ testId = null, cssClasses = null, style = null, itemText, type = 'item', isActiveItem = false, onClick = null }) => {
|
3211
|
+
const isDivider = type === 'divider';
|
3212
|
+
const itemTypeClass = isDivider ? 'dropdown-divider' : 'dropdown-item';
|
3213
|
+
const dropdownItemClasses = parseClasses([
|
3214
|
+
itemTypeClass,
|
3215
|
+
isActiveItem && !isDivider ? 'is-active' : null,
|
3216
|
+
cssClasses
|
3217
|
+
]);
|
3218
|
+
const dropdownItemConfig = {
|
3219
|
+
'data-testid': testId !== null && testId !== void 0 ? testId : parseTestId({
|
3220
|
+
tag: itemTypeClass,
|
3221
|
+
parsedClasses: `${dropdownItemClasses}-${type}`
|
3222
|
+
}),
|
3223
|
+
'className': dropdownItemClasses,
|
3224
|
+
'style': style !== null && style !== void 0 ? style : undefined,
|
3225
|
+
'onClick': onClick !== null && onClick !== void 0 ? onClick : undefined
|
3226
|
+
};
|
3227
|
+
switch (type) {
|
3228
|
+
case 'item':
|
3229
|
+
return (React.createElement("div", Object.assign({}, dropdownItemConfig),
|
3230
|
+
React.createElement("p", null, itemText)));
|
3231
|
+
case 'divider':
|
3232
|
+
return React.createElement("hr", Object.assign({}, dropdownItemConfig));
|
3233
|
+
case 'link':
|
3234
|
+
default:
|
3235
|
+
return React.createElement("a", Object.assign({}, dropdownItemConfig), itemText);
|
3236
|
+
}
|
3237
|
+
};
|
3238
|
+
|
3192
3239
|
const ButtonGroup = ({ testId = null, cssClasses = null, style = null, buttonList, isAttached = false, position = 'left' }) => {
|
3193
3240
|
const buttonGroupClasses = parseClasses([
|
3194
3241
|
'buttons',
|
@@ -3288,6 +3335,37 @@ const Breadcrumbs = ({ testId = 'breadcrumbs', containerTestId = null, cssClasse
|
|
3288
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)))))));
|
3289
3336
|
};
|
3290
3337
|
|
3338
|
+
const renderDropdownMenu = (items) => (React.createElement("section", { className: 'dropdown-content' }, items.map((dropdownItemConfig, i) => {
|
3339
|
+
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))));
|
3343
|
+
})));
|
3344
|
+
const Dropdown = ({ testId = null, cssClasses = null, style = null, inputText, dropdownPointer = 'dropdown-menu', listOfItems }) => {
|
3345
|
+
const [isMenuActive, setIsMenuActive] = reactExports.useState(false);
|
3346
|
+
const dropdownClasses = parseClasses([
|
3347
|
+
'dropdown',
|
3348
|
+
isMenuActive ? 'is-active' : null,
|
3349
|
+
cssClasses
|
3350
|
+
]);
|
3351
|
+
const dropdownTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'dropdown', parsedClasses: dropdownClasses });
|
3352
|
+
return (React.createElement("section", { "data-testid": dropdownTestId, className: dropdownClasses, style: style !== null && style !== void 0 ? style : undefined },
|
3353
|
+
React.createElement(DropdownTrigger, { menuText: inputText,
|
3354
|
+
dropdownPointer,
|
3355
|
+
onClick: () => setIsMenuActive(!isMenuActive) }),
|
3356
|
+
React.createElement("section", { className: 'dropdown-menu', id: dropdownPointer, role: 'menu' }, renderDropdownMenu(listOfItems))));
|
3357
|
+
};
|
3358
|
+
|
3359
|
+
const Message = ({ testId = null, cssClasses = null, style = null, headerText = null, bodyText, deleteButton = null, color = null, size = null }) => {
|
3360
|
+
const messageClasses = parseClasses(['message', color, size, cssClasses]);
|
3361
|
+
const messageTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'message', parsedClasses: messageClasses });
|
3362
|
+
return (React.createElement("article", { "data-testid": messageTestId, className: messageClasses, style: style !== null && style !== void 0 ? style : undefined },
|
3363
|
+
headerText && (React.createElement("section", { "data-testid": `${messageTestId}-header`, className: 'message-header' },
|
3364
|
+
React.createElement("p", null, headerText),
|
3365
|
+
deleteButton ? React.createElement(Delete, Object.assign({}, deleteButton)) : null)),
|
3366
|
+
React.createElement("section", { "data-testid": `${messageTestId}-body`, className: 'message-body' }, bodyText)));
|
3367
|
+
};
|
3368
|
+
|
3291
3369
|
exports.Block = Block;
|
3292
3370
|
exports.Box = Box;
|
3293
3371
|
exports.BreadcrumbItem = BreadcrumbItem;
|
@@ -3298,9 +3376,13 @@ exports.Checkbox = CheckBox;
|
|
3298
3376
|
exports.Column = Column;
|
3299
3377
|
exports.ColumnGroup = ColumnGroup;
|
3300
3378
|
exports.Delete = Delete;
|
3379
|
+
exports.Dropdown = Dropdown;
|
3380
|
+
exports.DropdownItem = DropdownItem;
|
3381
|
+
exports.DropdownTrigger = DropdownTrigger;
|
3301
3382
|
exports.File = File;
|
3302
3383
|
exports.Icon = Icon;
|
3303
3384
|
exports.Input = Input;
|
3385
|
+
exports.Message = Message;
|
3304
3386
|
exports.Notification = Notification;
|
3305
3387
|
exports.ProgressBar = ProgressBar;
|
3306
3388
|
exports.RadioButton = RadioButton;
|