reactive-bulma 1.20.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/README.md +37 -21
- package/dist/cjs/index.js +67 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/atoms/RadioButton/index.d.ts +4 -0
- package/dist/cjs/types/components/atoms/index.d.ts +2 -0
- package/dist/cjs/types/functions/parsers.d.ts +4 -4
- package/dist/cjs/types/interfaces/atomProps.d.ts +12 -2
- package/dist/cjs/types/interfaces/functionProps.d.ts +2 -2
- package/dist/esm/index.js +66 -21
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/atoms/RadioButton/index.d.ts +4 -0
- package/dist/esm/types/components/atoms/index.d.ts +2 -0
- package/dist/esm/types/functions/parsers.d.ts +4 -4
- package/dist/esm/types/interfaces/atomProps.d.ts +12 -2
- package/dist/esm/types/interfaces/functionProps.d.ts +2 -2
- package/dist/index.d.ts +33 -1
- package/package.json +34 -32
package/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2023 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/README.md
CHANGED
@@ -15,8 +15,8 @@ Component library based on React, Bulma, Typescript and Rollup
|
|
15
15
|
|
16
16
|
## Table of contents
|
17
17
|
|
18
|
-
- [Status](#status)
|
19
18
|
- [Purpose](#purpose)
|
19
|
+
- [Status](#status)
|
20
20
|
- [Dependencies](#dependencies)
|
21
21
|
- [Quick start](#quick-start)
|
22
22
|
- [Folder structure](#folder-structure)
|
@@ -25,16 +25,18 @@ Component library based on React, Bulma, Typescript and Rollup
|
|
25
25
|
- [Versioning](#versioning)
|
26
26
|
- [Roadmap](#roadmap)
|
27
27
|
- [Changelog](#changelog)
|
28
|
+
- [Contributing](#contributing)
|
28
29
|
- [Credit](#credit)
|
29
30
|
- [License](#license)
|
30
31
|
|
31
32
|
## Purpose
|
32
|
-
|
33
|
+
|
34
|
+
After studying [an Udemy course about Typescript](https://github.com/NicolasOmar/typescript-practice), I wanted to start a new project to practice my new knowledge in a meaningful tool. Therefore, I started this project to understand how to create a component library and investigate the best ways to maintain and nourish it as any professional-level alternatives.
|
33
35
|
|
34
36
|
## Status
|
35
37
|
|
36
|
-
![Npm Version][badge-npm-version]
|
37
|
-
![Npm Bundle Size][badge-npm-size]
|
38
|
+
[![Npm Version][badge-npm-version]][link-npm]
|
39
|
+
[![Npm Bundle Size][badge-npm-size]][link-npm]
|
38
40
|
[![Npm Downloads][badge-npm-downloads]][link-npm-downloads]
|
39
41
|
[![Netlify Status][badge-netlify-status]][link-netlify-status]
|
40
42
|
[![Code Coverage][badge-code-coverage]][link-code-coverage]
|
@@ -43,14 +45,16 @@ After studying [a Udemy course about Typescript](https://github.com/NicolasOmar/
|
|
43
45
|
[![Security Rating][badge-soundcloud-security]][link-soundcloud-status]
|
44
46
|
[![Technical Debt][badge-soundcloud-tech-debt]][link-soundcloud-status]
|
45
47
|
[![Known Vulnerabilities][badge-snyk-status]][link-snyk-status]
|
46
|
-
![GitHub Repo stars][badge-github-repo-stars]
|
47
|
-
![GitHub commit activity][badge-github-commits]
|
48
|
-
![GitHub last commit][badge-github-last-commit]
|
48
|
+
[![GitHub Repo stars][badge-github-repo-stars]][link-github-stars]
|
49
|
+
[![GitHub commit activity][badge-github-commits]][link-github-commit-activity]
|
50
|
+
[![GitHub last commit][badge-github-last-commit]][link-github-commit-history]
|
49
51
|
[![Semantic Commits][badge-semantic-commits]][link-semantic-commits]
|
52
|
+
[![Contributor Covenant][badge-code-of-conduct]][link-code-of-conduct]
|
50
53
|
|
51
54
|
[badge-npm-version]: https://img.shields.io/github/package-json/v/nicolasomar/reactive-bulma?label=npm%20version&logo=npm&labelColor=535353&color=success&style=flat
|
52
55
|
[badge-npm-size]: https://img.shields.io/bundlephobia/min/reactive-bulma?label=bundle%20size&labelColor=535353&logo=npm&style=flat
|
53
56
|
[badge-npm-downloads]: https://img.shields.io/npm/dm/reactive-bulma?label=downloads&labelColor=535353&style=flat&logo=npm
|
57
|
+
[link-npm]: https://www.npmjs.com/package/reactive-bulma
|
54
58
|
[link-npm-downloads]: https://www.npmjs.com/package/reactive-bulma?activeTab=versions
|
55
59
|
[badge-netlify-status]: https://api.netlify.com/api/v1/badges/3101f2b5-0e28-4734-b749-ebb0e3e413c6/deploy-status
|
56
60
|
[link-netlify-status]: https://app.netlify.com/sites/reactivebulma/deploys
|
@@ -61,29 +65,34 @@ After studying [a Udemy course about Typescript](https://github.com/NicolasOmar/
|
|
61
65
|
[badge-soundcloud-security]: https://sonarcloud.io/api/project_badges/measure?project=NicolasOmar_reactive-bulma&metric=security_rating
|
62
66
|
[badge-soundcloud-tech-debt]: https://sonarcloud.io/api/project_badges/measure?project=NicolasOmar_reactive-bulma&metric=sqale_index
|
63
67
|
[link-soundcloud-status]: https://sonarcloud.io/summary/new_code?id=NicolasOmar_reactive-bulma
|
64
|
-
[badge-snyk-status]: https://
|
68
|
+
[badge-snyk-status]: https://snyk.io/test/github/nicolasomar/reactive-bulma/badge.svg
|
65
69
|
[link-snyk-status]: https://snyk.io/test/github/nicolasomar/reactive-bulma
|
66
70
|
[badge-github-repo-stars]: https://img.shields.io/github/stars/nicolasomar/reactive-bulma?label=stars&logo=github&labelColor=535353&style=flat
|
67
71
|
[badge-github-commits]: https://img.shields.io/github/commit-activity/m/nicolasomar/reactive-bulma?logo=github
|
68
72
|
[badge-github-last-commit]: https://img.shields.io/github/last-commit/nicolasomar/reactive-bulma?logo=github
|
73
|
+
[link-github-stars]: https://github.com/NicolasOmar/reactive-bulma/activity
|
74
|
+
[link-github-commit-activity]: https://github.com/NicolasOmar/reactive-bulma/activity
|
75
|
+
[link-github-commit-history]: https://github.com/NicolasOmar/reactive-bulma/commits/main
|
69
76
|
[badge-semantic-commits]: https://img.shields.io/badge/using-conventional%20commits-e10079?logo=conventional-commits
|
70
77
|
[link-semantic-commits]: https://github.com/semantic-release/semantic-release
|
78
|
+
[badge-code-of-conduct]: https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg
|
79
|
+
[link-code-of-conduct]: code_of_conduct.md
|
71
80
|
|
72
81
|
## Dependencies
|
73
82
|
|
74
|
-
![react dependency][badge-dependency-react]
|
75
|
-
![bulma dependency][badge-dependency-bulma]
|
76
|
-
![material design dependency][badge-dependency-material-design]
|
77
|
-
![typescript dependency][badge-dependency-typescript]
|
78
|
-
![rollup dependency][badge-dependency-rollup]
|
79
|
-
![storybook dependency][badge-dependency-storybook]
|
80
|
-
![semantic release dependency][badge-dependency-semantic-release]
|
81
|
-
![babel dependency][badge-dependency-babel]
|
82
|
-
![jest dependency][badge-dependency-jest]
|
83
|
-
![react testing library dependency][badge-dependency-react-testing]
|
84
|
-
![prettier dependency][badge-dependency-prettier]
|
85
|
-
![eslint dependency][badge-dependency-eslint]
|
86
|
-
![husky dependency][badge-dependency-husky]
|
83
|
+
[![react dependency][badge-dependency-react]][link-package-dependencies]
|
84
|
+
[![bulma dependency][badge-dependency-bulma]][link-package-dependencies]
|
85
|
+
[![material design dependency][badge-dependency-material-design]][link-package-dependencies]
|
86
|
+
[![typescript dependency][badge-dependency-typescript]][link-package-dependencies]
|
87
|
+
[![rollup dependency][badge-dependency-rollup]][link-package-dependencies]
|
88
|
+
[![storybook dependency][badge-dependency-storybook]][link-package-dependencies]
|
89
|
+
[![semantic release dependency][badge-dependency-semantic-release]][link-package-dependencies]
|
90
|
+
[![babel dependency][badge-dependency-babel]][link-package-dependencies]
|
91
|
+
[![jest dependency][badge-dependency-jest]][link-package-dependencies]
|
92
|
+
[![react testing library dependency][badge-dependency-react-testing]][link-package-dependencies]
|
93
|
+
[![prettier dependency][badge-dependency-prettier]][link-package-dependencies]
|
94
|
+
[![eslint dependency][badge-dependency-eslint]][link-package-dependencies]
|
95
|
+
[![husky dependency][badge-dependency-husky]][link-package-dependencies]
|
87
96
|
|
88
97
|
[badge-dependency-react]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/react/main?logo=react
|
89
98
|
[badge-dependency-bulma]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/bulma/main?logo=bulma
|
@@ -98,6 +107,7 @@ After studying [a Udemy course about Typescript](https://github.com/NicolasOmar/
|
|
98
107
|
[badge-dependency-prettier]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/prettier/main?logo=prettier
|
99
108
|
[badge-dependency-eslint]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/eslint/main?logo=eslint
|
100
109
|
[badge-dependency-husky]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/husky/main?logo=husky
|
110
|
+
[link-package-dependencies]: https://github.com/NicolasOmar/reactive-bulma/blob/main/package.json
|
101
111
|
|
102
112
|
## Quick start
|
103
113
|
|
@@ -133,6 +143,7 @@ Reactive bulma's documentation, included in this repo in the root directory, is
|
|
133
143
|
Learn more about using `Storybook` by reading its [documentation](https://storybook.js.org/docs/react/get-started/install).
|
134
144
|
|
135
145
|
## Usage
|
146
|
+
|
136
147
|
```jsx
|
137
148
|
import React from 'react'
|
138
149
|
import { Button } from 'reactive-bulma'
|
@@ -188,6 +199,11 @@ In case you want the detailed list of current and future features, go to the [ro
|
|
188
199
|
|
189
200
|
The [changelog](https://github.com/NicolasOmar/reactive-bulma/blob/main/CHANGELOG.md) (powered by `semantic-release`) is regularly updated to reflect what's changed in each new release.
|
190
201
|
|
202
|
+
## Contributing
|
203
|
+
|
204
|
+
If you're interested in contributing to Reactive Bulma, please read [our contributing docs](./CONTRIBUTING.md) before submitting a pull request.
|
205
|
+
|
206
|
+
|
191
207
|
## Credit
|
192
208
|
|
193
209
|
Bulma was beautifully crafted by [@jgthms](https://github.com/jgthms)
|
package/dist/cjs/index.js
CHANGED
@@ -2835,15 +2835,15 @@ var reactExports = react.exports;
|
|
2835
2835
|
var React = /*@__PURE__*/getDefaultExportFromCjs(reactExports);
|
2836
2836
|
|
2837
2837
|
/**
|
2838
|
-
* @param { Array<string | null> } _classes Required
|
2838
|
+
* @param { Array<string | null> } _classes `Required`. Array of classNames on `string` (or `null`) values
|
2839
2839
|
* @returns { string } A single string product of merge all classNames, separated by spaces
|
2840
2840
|
*/
|
2841
2841
|
const parseClasses = (_classes) => _classes.filter(_class => _class).join(' ');
|
2842
2842
|
/**
|
2843
2843
|
* @param { ParseTestIdProps } config Configuration object
|
2844
|
-
* @param { string } config.tag Required
|
2845
|
-
* @param { string } config.parsedClasses Required
|
2846
|
-
* @param { {
|
2844
|
+
* @param { string } config.tag `Required`. Component tag used between to build the final testId string.
|
2845
|
+
* @param { string } config.parsedClasses `Required`. A single string of previously parsed classes what will be joined with `tag` property.
|
2846
|
+
* @param { { regExp?: RegExp, replacer?: string }[] } config.rules Optional. An array of objects used with a regular expression to check each case and a replacer for each one, giving oportunity to handle specific cases of component class names.
|
2847
2847
|
* @returns A single string product of merge all classNames, separated by `separator` value
|
2848
2848
|
*/
|
2849
2849
|
const parseTestId = (config) => {
|
@@ -2851,7 +2851,7 @@ const parseTestId = (config) => {
|
|
2851
2851
|
let fixedClassString = config.parsedClasses;
|
2852
2852
|
if (config.rules) {
|
2853
2853
|
for (const rule of config.rules) {
|
2854
|
-
fixedClassString = fixedClassString.replace(rule.
|
2854
|
+
fixedClassString = fixedClassString.replace(rule.regExp, rule.replacer);
|
2855
2855
|
}
|
2856
2856
|
}
|
2857
2857
|
else {
|
@@ -2974,8 +2974,8 @@ const generateIconContainer = (icon, color) => {
|
|
2974
2974
|
parsedClasses: (_a = color === null || color === void 0 ? void 0 : color.toString()) !== null && _a !== void 0 ? _a : '',
|
2975
2975
|
rules: [
|
2976
2976
|
{
|
2977
|
-
|
2978
|
-
|
2977
|
+
regExp: /has-text/gm,
|
2978
|
+
replacer: ''
|
2979
2979
|
}
|
2980
2980
|
]
|
2981
2981
|
});
|
@@ -3001,12 +3001,12 @@ const Icon = ({ testId = null, containerTestId = null, cssClasses = null, contai
|
|
3001
3001
|
parsedClasses: iconClasses,
|
3002
3002
|
rules: [
|
3003
3003
|
{
|
3004
|
-
|
3005
|
-
|
3004
|
+
regExp: /mdi-|mdi--/gm,
|
3005
|
+
replacer: ''
|
3006
3006
|
},
|
3007
3007
|
{
|
3008
|
-
|
3009
|
-
|
3008
|
+
regExp: /mdi /gm,
|
3009
|
+
replacer: '-'
|
3010
3010
|
}
|
3011
3011
|
],
|
3012
3012
|
separator: '-'
|
@@ -3050,12 +3050,12 @@ const TextArea = ({ testId = null, cssClasses = null, style = null, text = null,
|
|
3050
3050
|
parsedClasses: textAreaClasses,
|
3051
3051
|
rules: [
|
3052
3052
|
{
|
3053
|
-
|
3054
|
-
|
3053
|
+
regExp: /textarea/gm,
|
3054
|
+
replacer: ''
|
3055
3055
|
},
|
3056
3056
|
{
|
3057
|
-
|
3058
|
-
|
3057
|
+
regExp: /is-|has-/gm,
|
3058
|
+
replacer: '-'
|
3059
3059
|
}
|
3060
3060
|
]
|
3061
3061
|
});
|
@@ -3088,7 +3088,7 @@ const Select = ({ testId = null, containerTestId = null, cssClasses = null, cont
|
|
3088
3088
|
});
|
3089
3089
|
const containerSelectTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : `${selectTestId}-container`;
|
3090
3090
|
return (React.createElement("section", { "data-testid": containerSelectTestId, className: containerSelectClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
3091
|
-
React.createElement("select", { "data-testid": selectTestId, className: cssClasses !== null && cssClasses !== void 0 ? cssClasses : undefined, style: style !== null && style !== void 0 ? style : undefined, multiple: isMultiple, size: showOptions }, options.map(({ id, name, selected }, i) => (React.createElement("option", { "data-testid": `${selectTestId}-option-${i}`, key: id.toString(),
|
3091
|
+
React.createElement("select", { "data-testid": selectTestId, className: cssClasses !== null && cssClasses !== void 0 ? cssClasses : undefined, style: style !== null && style !== void 0 ? style : undefined, multiple: isMultiple, size: showOptions }, options.map(({ id, name, selected }, i) => (React.createElement("option", { "data-testid": `${selectTestId}-option-${i}`, key: id.toString(), defaultChecked: selected !== null && selected !== void 0 ? selected : false, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, name))))));
|
3092
3092
|
};
|
3093
3093
|
|
3094
3094
|
const File = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, fileName = null, uploadIcon = { iconLabel: 'upload' }, uploadText = 'Choose a file…', buttonOnRight = false, isFullWidth = false, isBoxed = false, color = null, size = null, onClick = null }) => {
|
@@ -3107,12 +3107,12 @@ const File = ({ testId = null, containerTestId = null, cssClasses = null, contai
|
|
3107
3107
|
parsedClasses: fileContainerClasses,
|
3108
3108
|
rules: [
|
3109
3109
|
{
|
3110
|
-
|
3111
|
-
|
3110
|
+
regExp: /has/gm,
|
3111
|
+
replacer: '-has'
|
3112
3112
|
},
|
3113
3113
|
{
|
3114
|
-
|
3115
|
-
|
3114
|
+
regExp: /is|file/gm,
|
3115
|
+
replacer: ''
|
3116
3116
|
}
|
3117
3117
|
]
|
3118
3118
|
});
|
@@ -3127,15 +3127,62 @@ const File = ({ testId = null, containerTestId = null, cssClasses = null, contai
|
|
3127
3127
|
fileName ? React.createElement("span", { className: 'file-name' }, fileName) : null)));
|
3128
3128
|
};
|
3129
3129
|
|
3130
|
+
const parseContentTestId = (content) => {
|
3131
|
+
if (typeof content === 'string')
|
3132
|
+
return `-${content === null || content === void 0 ? void 0 : content.toString()}`;
|
3133
|
+
if (content !== null)
|
3134
|
+
return '-with-component';
|
3135
|
+
return '';
|
3136
|
+
};
|
3137
|
+
const CheckBox = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, content = null, isDisabled = null, onChange = null }) => {
|
3138
|
+
const checkboxContainerClasses = parseClasses([
|
3139
|
+
'checkbox',
|
3140
|
+
containerCssClasses
|
3141
|
+
]);
|
3142
|
+
const checkboxContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
|
3143
|
+
tag: 'checkbox-container',
|
3144
|
+
parsedClasses: parseContentTestId(content)
|
3145
|
+
});
|
3146
|
+
const checkboxTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
|
3147
|
+
tag: 'checkbox',
|
3148
|
+
parsedClasses: parseContentTestId(content)
|
3149
|
+
});
|
3150
|
+
return (React.createElement("label", { "data-testid": checkboxContainerTestId, className: checkboxContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
3151
|
+
React.createElement("input", { "data-testid": checkboxTestId, type: 'checkbox', className: cssClasses !== null && cssClasses !== void 0 ? cssClasses : undefined, style: style !== null && style !== void 0 ? style : undefined, disabled: isDisabled !== null && isDisabled !== void 0 ? isDisabled : false, onChange: onChange !== null && onChange !== void 0 ? onChange : undefined }),
|
3152
|
+
content));
|
3153
|
+
};
|
3154
|
+
|
3155
|
+
// PARSERS
|
3156
|
+
const renderRadioButton = (config, index) => {
|
3157
|
+
const { testId = null, label, name, isChecked = false, isDisabled = false, style = null, onChange } = config;
|
3158
|
+
const radioButtonTestId = testId !== null && testId !== void 0 ? testId : `test-radio-button-item-${index}`;
|
3159
|
+
return (React.createElement("label", { key: index, className: 'radio' },
|
3160
|
+
React.createElement("input", { "data-testid": radioButtonTestId, type: 'radio', style: style !== null && style !== void 0 ? style : undefined, name: name, defaultChecked: isChecked, disabled: isDisabled, onChange: onChange }),
|
3161
|
+
label));
|
3162
|
+
};
|
3163
|
+
const RadioButton = ({ containerTestId = null, containerCssClasses = null, containerStyle = null, options, name, onChange = null }) => {
|
3164
|
+
const radioButtonContainerClasses = parseClasses([
|
3165
|
+
'control',
|
3166
|
+
containerCssClasses
|
3167
|
+
]);
|
3168
|
+
const radioButtonContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
|
3169
|
+
tag: 'container-',
|
3170
|
+
parsedClasses: radioButtonContainerClasses
|
3171
|
+
});
|
3172
|
+
return (React.createElement("section", { "data-testid": radioButtonContainerTestId, className: radioButtonContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined }, options.map((_option, i) => renderRadioButton(Object.assign(Object.assign({}, _option), { name, onChange: onChange !== null && onChange !== void 0 ? onChange : undefined }), i))));
|
3173
|
+
};
|
3174
|
+
|
3130
3175
|
exports.Block = Block;
|
3131
3176
|
exports.Box = Box;
|
3132
3177
|
exports.Button = Button;
|
3178
|
+
exports.Checkbox = CheckBox;
|
3133
3179
|
exports.Column = Column;
|
3134
3180
|
exports.Delete = Delete;
|
3135
3181
|
exports.File = File;
|
3136
3182
|
exports.Icon = Icon;
|
3137
3183
|
exports.Input = Input;
|
3138
3184
|
exports.ProgressBar = ProgressBar;
|
3185
|
+
exports.RadioButton = RadioButton;
|
3139
3186
|
exports.Select = Select;
|
3140
3187
|
exports.Tag = Tag;
|
3141
3188
|
exports.TextArea = TextArea;
|