reactive-bulma 1.20.1 → 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
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)
@@ -29,12 +29,12 @@ Component library based on React, Bulma, Typescript and Rollup
29
29
  - [License](#license)
30
30
 
31
31
  ## Purpose
32
- After studying [a 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.
32
+ 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
33
 
34
34
  ## Status
35
35
 
36
- ![Npm Version][badge-npm-version]
37
- ![Npm Bundle Size][badge-npm-size]
36
+ [![Npm Version][badge-npm-version]][link-npm]
37
+ [![Npm Bundle Size][badge-npm-size]][link-npm]
38
38
  [![Npm Downloads][badge-npm-downloads]][link-npm-downloads]
39
39
  [![Netlify Status][badge-netlify-status]][link-netlify-status]
40
40
  [![Code Coverage][badge-code-coverage]][link-code-coverage]
@@ -43,14 +43,15 @@ After studying [a Udemy course about Typescript](https://github.com/NicolasOmar/
43
43
  [![Security Rating][badge-soundcloud-security]][link-soundcloud-status]
44
44
  [![Technical Debt][badge-soundcloud-tech-debt]][link-soundcloud-status]
45
45
  [![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]
46
+ [![GitHub Repo stars][badge-github-repo-stars]][link-github-stars]
47
+ [![GitHub commit activity][badge-github-commits]][link-github-commit-activity]
48
+ [![GitHub last commit][badge-github-last-commit]][link-github-commit-history]
49
49
  [![Semantic Commits][badge-semantic-commits]][link-semantic-commits]
50
50
 
51
51
  [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
52
  [badge-npm-size]: https://img.shields.io/bundlephobia/min/reactive-bulma?label=bundle%20size&labelColor=535353&logo=npm&style=flat
53
53
  [badge-npm-downloads]: https://img.shields.io/npm/dm/reactive-bulma?label=downloads&labelColor=535353&style=flat&logo=npm
54
+ [link-npm]: https://www.npmjs.com/package/reactive-bulma
54
55
  [link-npm-downloads]: https://www.npmjs.com/package/reactive-bulma?activeTab=versions
55
56
  [badge-netlify-status]: https://api.netlify.com/api/v1/badges/3101f2b5-0e28-4734-b749-ebb0e3e413c6/deploy-status
56
57
  [link-netlify-status]: https://app.netlify.com/sites/reactivebulma/deploys
@@ -66,24 +67,27 @@ After studying [a Udemy course about Typescript](https://github.com/NicolasOmar/
66
67
  [badge-github-repo-stars]: https://img.shields.io/github/stars/nicolasomar/reactive-bulma?label=stars&logo=github&labelColor=535353&style=flat
67
68
  [badge-github-commits]: https://img.shields.io/github/commit-activity/m/nicolasomar/reactive-bulma?logo=github
68
69
  [badge-github-last-commit]: https://img.shields.io/github/last-commit/nicolasomar/reactive-bulma?logo=github
70
+ [link-github-stars]: https://github.com/NicolasOmar/reactive-bulma/activity
71
+ [link-github-commit-activity]: https://github.com/NicolasOmar/reactive-bulma/activity
72
+ [link-github-commit-history]: https://github.com/NicolasOmar/reactive-bulma/commits/main
69
73
  [badge-semantic-commits]: https://img.shields.io/badge/using-conventional%20commits-e10079?logo=conventional-commits
70
74
  [link-semantic-commits]: https://github.com/semantic-release/semantic-release
71
75
 
72
76
  ## Dependencies
73
77
 
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]
78
+ [![react dependency][badge-dependency-react]][link-package-dependencies]
79
+ [![bulma dependency][badge-dependency-bulma]][link-package-dependencies]
80
+ [![material design dependency][badge-dependency-material-design]][link-package-dependencies]
81
+ [![typescript dependency][badge-dependency-typescript]][link-package-dependencies]
82
+ [![rollup dependency][badge-dependency-rollup]][link-package-dependencies]
83
+ [![storybook dependency][badge-dependency-storybook]][link-package-dependencies]
84
+ [![semantic release dependency][badge-dependency-semantic-release]][link-package-dependencies]
85
+ [![babel dependency][badge-dependency-babel]][link-package-dependencies]
86
+ [![jest dependency][badge-dependency-jest]][link-package-dependencies]
87
+ [![react testing library dependency][badge-dependency-react-testing]][link-package-dependencies]
88
+ [![prettier dependency][badge-dependency-prettier]][link-package-dependencies]
89
+ [![eslint dependency][badge-dependency-eslint]][link-package-dependencies]
90
+ [![husky dependency][badge-dependency-husky]][link-package-dependencies]
87
91
 
88
92
  [badge-dependency-react]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/react/main?logo=react
89
93
  [badge-dependency-bulma]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/bulma/main?logo=bulma
@@ -98,6 +102,7 @@ After studying [a Udemy course about Typescript](https://github.com/NicolasOmar/
98
102
  [badge-dependency-prettier]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/prettier/main?logo=prettier
99
103
  [badge-dependency-eslint]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/eslint/main?logo=eslint
100
104
  [badge-dependency-husky]: https://img.shields.io/github/package-json/dependency-version/nicolasomar/reactive-bulma/dev/husky/main?logo=husky
105
+ [link-package-dependencies]: https://github.com/NicolasOmar/reactive-bulma/blob/main/package.json
101
106
 
102
107
  ## Quick start
103
108
 
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. Array of classNames on `string` (or `null`) values
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. 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 { { usedRegExp?: RegExp, regExpReplacer?: 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.
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.usedRegExp, rule.regExpReplacer);
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
- usedRegExp: /has-text/gm,
2978
- regExpReplacer: ''
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
- usedRegExp: /mdi-|mdi--/gm,
3005
- regExpReplacer: ''
3004
+ regExp: /mdi-|mdi--/gm,
3005
+ replacer: ''
3006
3006
  },
3007
3007
  {
3008
- usedRegExp: /mdi /gm,
3009
- regExpReplacer: '-'
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
- usedRegExp: /textarea/gm,
3054
- regExpReplacer: ''
3053
+ regExp: /textarea/gm,
3054
+ replacer: ''
3055
3055
  },
3056
3056
  {
3057
- usedRegExp: /is-|has-/gm,
3058
- regExpReplacer: '-'
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(), selected: selected !== null && selected !== void 0 ? selected : false, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, name))))));
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
- usedRegExp: /has/gm,
3111
- regExpReplacer: '-has'
3110
+ regExp: /has/gm,
3111
+ replacer: '-has'
3112
3112
  },
3113
3113
  {
3114
- usedRegExp: /is|file/gm,
3115
- regExpReplacer: ''
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;