reactive-bulma 1.20.0 → 1.21.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +25 -20
- package/dist/cjs/index.js +161 -86
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/atoms/Checkbox/index.d.ts +3 -3
- 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 +5 -5
- package/dist/cjs/types/interfaces/atomProps.d.ts +123 -9
- package/dist/cjs/types/interfaces/functionProps.d.ts +2 -2
- package/dist/esm/index.js +160 -87
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/atoms/Checkbox/index.d.ts +3 -3
- 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 +5 -5
- package/dist/esm/types/interfaces/atomProps.d.ts +123 -9
- package/dist/esm/types/interfaces/functionProps.d.ts +2 -2
- package/dist/index.d.ts +129 -9
- package/package.json +25 -25
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 [
|
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
|
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 {
|
@@ -2862,7 +2862,7 @@ const parseTestId = (config) => {
|
|
2862
2862
|
return `test-${config.tag}${fixedClassString.replace(/ /gm, (_a = config.separator) !== null && _a !== void 0 ? _a : '')}`;
|
2863
2863
|
};
|
2864
2864
|
|
2865
|
-
const Button = ({
|
2865
|
+
const Button = ({ testId = null, cssClasses = null, style = null, type = 'button', text = null, isDisabled = false, color = 'is-primary', isLightColor = false, isInvertedColor = false, isOutlined = false, isRounded = false, isLoading = false, isStatic = false, size = null, onClick = null }) => {
|
2866
2866
|
const buttonClasses = parseClasses([
|
2867
2867
|
'button',
|
2868
2868
|
color,
|
@@ -2872,72 +2872,88 @@ const Button = ({ text = null, type = 'button', testId = null, style = null, col
|
|
2872
2872
|
isRounded ? 'is-rounded' : null,
|
2873
2873
|
isLoading ? 'is-loading' : null,
|
2874
2874
|
isStatic ? 'is-static' : null,
|
2875
|
-
size
|
2875
|
+
size,
|
2876
|
+
cssClasses
|
2876
2877
|
]);
|
2877
|
-
const
|
2878
|
-
return (React.createElement("button", { "data-testid":
|
2878
|
+
const buttonTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'button', parsedClasses: buttonClasses });
|
2879
|
+
return (React.createElement("button", { "data-testid": buttonTestId, type: type, className: buttonClasses, style: style !== null && style !== void 0 ? style : undefined, disabled: isDisabled !== null && isDisabled !== void 0 ? isDisabled : false, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, text));
|
2879
2880
|
};
|
2880
2881
|
|
2881
|
-
const Column = ({ testId = null,
|
2882
|
+
const Column = ({ testId = null, cssClasses = null, style = null, children = null, size = null, offset = null, isNarrow = false }) => {
|
2882
2883
|
const columnClasses = parseClasses([
|
2883
2884
|
'column',
|
2884
2885
|
size,
|
2885
2886
|
offset,
|
2886
|
-
isNarrow ? 'is-narrow' : null
|
2887
|
+
isNarrow ? 'is-narrow' : null,
|
2888
|
+
cssClasses
|
2887
2889
|
]);
|
2888
|
-
const
|
2889
|
-
return (React.createElement("section", { "data-testid":
|
2890
|
+
const columnTestId = testId !== null && testId !== void 0 ? testId : parseTestId({ tag: 'column', parsedClasses: columnClasses });
|
2891
|
+
return (React.createElement("section", { "data-testid": columnTestId, className: columnClasses, style: style !== null && style !== void 0 ? style : undefined }, children));
|
2890
2892
|
};
|
2891
2893
|
|
2892
|
-
const ProgressBar = ({
|
2894
|
+
const ProgressBar = ({ testId = null, cssClasses = null, style = null, value = 0, max = 100, color = 'is-primary', size = null, isLoading = false }) => {
|
2893
2895
|
const fixedValue = value > max || value < 0 ? 0 : value;
|
2894
|
-
const progressClasses = parseClasses([
|
2895
|
-
|
2896
|
+
const progressClasses = parseClasses([
|
2897
|
+
'progress',
|
2898
|
+
color,
|
2899
|
+
size,
|
2900
|
+
cssClasses
|
2901
|
+
]);
|
2902
|
+
const progressTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
|
2896
2903
|
tag: 'progress',
|
2897
2904
|
parsedClasses: progressClasses
|
2898
2905
|
});
|
2899
|
-
return (React.createElement("progress", { "data-testid":
|
2906
|
+
return (React.createElement("progress", { "data-testid": progressTestId, className: progressClasses, style: style !== null && style !== void 0 ? style : undefined, value: isLoading ? undefined : value, max: max }, `${isLoading ? 0 : fixedValue}%`));
|
2900
2907
|
};
|
2901
2908
|
|
2902
|
-
const Block = ({ testId = 'test-block', style = null, children = null }) => children ? (React.createElement("section", { "data-testid": testId, className:
|
2909
|
+
const Block = ({ testId = 'test-block', cssClasses = 'block', style = null, children = null }) => children ? (React.createElement("section", { "data-testid": testId, className: cssClasses, style: style !== null && style !== void 0 ? style : undefined }, children)) : null;
|
2903
2910
|
|
2904
|
-
const Tag = ({
|
2905
|
-
const
|
2911
|
+
const Tag = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, text, withDelete = false, withAddon = false, addonText = null, color = null, isLight = null, isRounded = null, size = null, addonColor = null, onDeleteClick = null }) => {
|
2912
|
+
const tagContainerClasses = parseClasses([
|
2913
|
+
'tags',
|
2914
|
+
'has-addons',
|
2915
|
+
size ? size.replace('is-', 'are-') : null,
|
2916
|
+
containerCssClasses
|
2917
|
+
]);
|
2906
2918
|
const tagClasses = parseClasses([
|
2907
2919
|
'tag',
|
2908
2920
|
color,
|
2909
2921
|
isLight && !withAddon ? 'is-light' : null,
|
2910
2922
|
isRounded && !withAddon ? 'is-rounded' : null,
|
2911
|
-
size
|
2912
|
-
|
2913
|
-
const tagsWrapperClasses = parseClasses([
|
2914
|
-
'tags',
|
2915
|
-
'has-addons',
|
2916
|
-
size ? size.replace('is-', 'are-') : null
|
2923
|
+
size,
|
2924
|
+
cssClasses
|
2917
2925
|
]);
|
2918
|
-
const
|
2919
|
-
const
|
2926
|
+
const tagAddonClasses = parseClasses(['tag', addonColor]);
|
2927
|
+
const tagLabel = withAddon ? 'tags' : 'tag';
|
2928
|
+
const tagTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
|
2920
2929
|
tag: tagLabel,
|
2921
|
-
parsedClasses: withAddon ?
|
2930
|
+
parsedClasses: withAddon ? tagContainerClasses : tagClasses,
|
2922
2931
|
separator: withAddon ? '-' : ''
|
2923
2932
|
});
|
2924
|
-
|
2925
|
-
|
2926
|
-
|
2933
|
+
const tagContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : `${tagTestId}-container`;
|
2934
|
+
const tagDeleteTestId = `${tagTestId}-delete`;
|
2935
|
+
return withAddon ? (React.createElement("section", { "data-testid": tagContainerTestId, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined, className: tagContainerClasses },
|
2936
|
+
React.createElement("span", { "data-testid": tagTestId, className: tagClasses }, text),
|
2937
|
+
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 },
|
2927
2938
|
text,
|
2928
|
-
withDelete ? (React.createElement("button", { "data-testid":
|
2939
|
+
withDelete ? (React.createElement("button", { "data-testid": tagDeleteTestId, className: 'delete', onClick: onDeleteClick !== null && onDeleteClick !== void 0 ? onDeleteClick : undefined })) : null));
|
2929
2940
|
};
|
2930
2941
|
|
2931
|
-
const Box = ({ testId = 'test-box', style = null, children = null }) => children ? (React.createElement("section", { "data-testid": testId, className:
|
2942
|
+
const Box = ({ testId = 'test-box', cssClasses = 'box', style = null, children = null }) => children ? (React.createElement("section", { "data-testid": testId, className: cssClasses, style: style !== null && style !== void 0 ? style : undefined }, children)) : null;
|
2932
2943
|
|
2933
2944
|
const renderTitleSection = (section) => {
|
2934
|
-
var _a, _b
|
2945
|
+
var _a, _b;
|
2946
|
+
if (!section)
|
2947
|
+
return null;
|
2948
|
+
const { type, size, isSpaced, cssClasses } = section;
|
2935
2949
|
const sectionClasses = parseClasses([
|
2936
|
-
|
2937
|
-
|
2938
|
-
|
2950
|
+
type,
|
2951
|
+
size !== null && size !== void 0 ? size : null,
|
2952
|
+
type === 'title' && isSpaced ? 'is-spaced' : null,
|
2953
|
+
cssClasses
|
2939
2954
|
]);
|
2940
|
-
|
2955
|
+
const sectionTestId = (_a = section === null || section === void 0 ? void 0 : section.testId) !== null && _a !== void 0 ? _a : `${section === null || section === void 0 ? void 0 : section.type}-test`;
|
2956
|
+
return (React.createElement("p", { "data-testid": sectionTestId, className: sectionClasses, style: (_b = section === null || section === void 0 ? void 0 : section.style) !== null && _b !== void 0 ? _b : undefined }, section === null || section === void 0 ? void 0 : section.text));
|
2941
2957
|
};
|
2942
2958
|
const Title = ({ main, secondary }) => (React.createElement(React.Fragment, null,
|
2943
2959
|
renderTitleSection(main),
|
@@ -2958,156 +2974,215 @@ const generateIconContainer = (icon, color) => {
|
|
2958
2974
|
parsedClasses: (_a = color === null || color === void 0 ? void 0 : color.toString()) !== null && _a !== void 0 ? _a : '',
|
2959
2975
|
rules: [
|
2960
2976
|
{
|
2961
|
-
|
2962
|
-
|
2977
|
+
regExp: /has-text/gm,
|
2978
|
+
replacer: ''
|
2963
2979
|
}
|
2964
2980
|
]
|
2965
2981
|
});
|
2966
2982
|
return (React.createElement("span", { "data-testid": containerTestId, className: containerClasses }, icon));
|
2967
2983
|
};
|
2968
|
-
const Icon = ({
|
2969
|
-
const
|
2984
|
+
const Icon = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, iconLabel, text = null, color = null, size = null, colorMode = null, isSpinning = false }) => {
|
2985
|
+
const iconContainerClasses = parseClasses([
|
2986
|
+
'icon',
|
2987
|
+
color,
|
2988
|
+
size,
|
2989
|
+
containerCssClasses
|
2990
|
+
]);
|
2970
2991
|
const iconClasses = parseClasses([
|
2971
2992
|
'mdi',
|
2972
2993
|
`mdi-${iconLabel}`,
|
2973
2994
|
colorMode ? `mdi-${colorMode}` : null,
|
2974
2995
|
isSpinning ? 'mdi-spin' : null,
|
2975
|
-
size ? `mdi-${IconSizeEnum[size]}px` : 'mdi-24px'
|
2996
|
+
size ? `mdi-${IconSizeEnum[size]}px` : 'mdi-24px',
|
2997
|
+
cssClasses
|
2976
2998
|
]);
|
2977
|
-
const
|
2999
|
+
const iconContainertestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
|
2978
3000
|
tag: 'icon',
|
2979
3001
|
parsedClasses: iconClasses,
|
2980
3002
|
rules: [
|
2981
3003
|
{
|
2982
|
-
|
2983
|
-
|
3004
|
+
regExp: /mdi-|mdi--/gm,
|
3005
|
+
replacer: ''
|
2984
3006
|
},
|
2985
3007
|
{
|
2986
|
-
|
2987
|
-
|
3008
|
+
regExp: /mdi /gm,
|
3009
|
+
replacer: '-'
|
2988
3010
|
}
|
2989
3011
|
],
|
2990
3012
|
separator: '-'
|
2991
3013
|
});
|
2992
|
-
const
|
2993
|
-
const iconComponent = (React.createElement("span", { "data-testid":
|
2994
|
-
React.createElement("i", { "data-testid":
|
3014
|
+
const iconTestId = testId !== null && testId !== void 0 ? testId : `${iconContainertestId}-i`;
|
3015
|
+
const iconComponent = (React.createElement("span", { "data-testid": iconContainertestId, className: iconContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
3016
|
+
React.createElement("i", { "data-testid": iconTestId, className: iconClasses, style: style !== null && style !== void 0 ? style : undefined }),
|
2995
3017
|
text ? React.createElement("span", null, text) : null));
|
2996
3018
|
return text ? generateIconContainer(iconComponent, color) : iconComponent;
|
2997
3019
|
};
|
2998
3020
|
|
2999
|
-
const Input = ({ testId = null, type, text = null, isDisabled = false, isReadonly = false,
|
3021
|
+
const Input = ({ testId = null, cssClasses = null, style = null, type, text = null, isDisabled = false, isReadonly = false, color = null, size = null, isRounded = null, isHovered = null, isFocused = null, onClick = null, onChange = null }) => {
|
3000
3022
|
const inputClasses = parseClasses([
|
3001
3023
|
'input',
|
3002
3024
|
color,
|
3003
3025
|
size,
|
3004
3026
|
isRounded ? 'is-rounded' : null,
|
3005
3027
|
isHovered ? 'is-hovered' : null,
|
3006
|
-
isFocused ? 'is-focused' : null
|
3028
|
+
isFocused ? 'is-focused' : null,
|
3029
|
+
cssClasses
|
3007
3030
|
]);
|
3008
|
-
const
|
3031
|
+
const inputTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
|
3009
3032
|
tag: 'input',
|
3010
3033
|
parsedClasses: inputClasses
|
3011
3034
|
});
|
3012
|
-
return (React.createElement("input", { "data-testid":
|
3035
|
+
return (React.createElement("input", { "data-testid": inputTestId, type: type, defaultValue: text !== null && text !== void 0 ? text : undefined, disabled: isDisabled, readOnly: isReadonly, className: inputClasses, style: style !== null && style !== void 0 ? style : undefined, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined, onChange: onChange !== null && onChange !== void 0 ? onChange : undefined }));
|
3013
3036
|
};
|
3014
3037
|
|
3015
|
-
const TextArea = ({ testId = null, text = null, cols = null, rows = null, isDisabled = false, isReadonly = false, isFixedSize = false,
|
3038
|
+
const TextArea = ({ testId = null, cssClasses = null, style = null, text = null, cols = null, rows = null, isDisabled = false, isReadonly = false, isFixedSize = false, color = null, size = null, isHovered = null, isFocused = null, onClick = null, onChange = null }) => {
|
3016
3039
|
const textAreaClasses = parseClasses([
|
3017
3040
|
'textarea',
|
3018
3041
|
color,
|
3019
3042
|
size,
|
3020
3043
|
isHovered ? 'is-hovered' : null,
|
3021
3044
|
isFocused ? 'is-focused' : null,
|
3022
|
-
isFixedSize ? 'has-fixed-size' : null
|
3045
|
+
isFixedSize ? 'has-fixed-size' : null,
|
3046
|
+
cssClasses
|
3023
3047
|
]);
|
3024
|
-
const
|
3048
|
+
const textAreaTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
|
3025
3049
|
tag: 'textarea',
|
3026
3050
|
parsedClasses: textAreaClasses,
|
3027
3051
|
rules: [
|
3028
3052
|
{
|
3029
|
-
|
3030
|
-
|
3053
|
+
regExp: /textarea/gm,
|
3054
|
+
replacer: ''
|
3031
3055
|
},
|
3032
3056
|
{
|
3033
|
-
|
3034
|
-
|
3057
|
+
regExp: /is-|has-/gm,
|
3058
|
+
replacer: '-'
|
3035
3059
|
}
|
3036
3060
|
]
|
3037
3061
|
});
|
3038
|
-
return (React.createElement("textarea", { "data-testid":
|
3062
|
+
return (React.createElement("textarea", { "data-testid": textAreaTestId, defaultValue: text !== null && text !== void 0 ? text : undefined, cols: cols !== null && cols !== void 0 ? cols : undefined, rows: rows !== null && rows !== void 0 ? rows : undefined, disabled: isDisabled, readOnly: isReadonly, className: textAreaClasses, style: style !== null && style !== void 0 ? style : undefined, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined, onChange: onChange !== null && onChange !== void 0 ? onChange : undefined }));
|
3039
3063
|
};
|
3040
3064
|
|
3041
|
-
const Delete = ({ testId = null, style = null, size = null, onClick = null }) => {
|
3042
|
-
const deleteClasses = parseClasses(['delete', size]);
|
3043
|
-
const
|
3065
|
+
const Delete = ({ testId = null, cssClasses = null, style = null, size = null, onClick = null }) => {
|
3066
|
+
const deleteClasses = parseClasses(['delete', size, cssClasses]);
|
3067
|
+
const deleteTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
|
3044
3068
|
tag: 'delete',
|
3045
3069
|
parsedClasses: deleteClasses
|
3046
3070
|
});
|
3047
|
-
return (React.createElement("button", { "data-testid":
|
3071
|
+
return (React.createElement("button", { "data-testid": deleteTestId, className: deleteClasses, style: style !== null && style !== void 0 ? style : undefined, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }));
|
3048
3072
|
};
|
3049
3073
|
|
3050
|
-
const Select = ({ testId = null,
|
3051
|
-
const
|
3074
|
+
const Select = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, options = [], showOptions = 1, isMultiple = false, color = null, size = null, isRounded = null, isHovered = null, isFocused = null, onClick = null }) => {
|
3075
|
+
const containerSelectClasses = parseClasses([
|
3052
3076
|
'select',
|
3053
3077
|
color,
|
3054
3078
|
size,
|
3055
3079
|
isMultiple ? 'is-multiple' : null,
|
3056
3080
|
isRounded ? 'is-rounded' : null,
|
3057
3081
|
isHovered ? 'is-hovered' : null,
|
3058
|
-
isFocused ? 'is-focused' : null
|
3082
|
+
isFocused ? 'is-focused' : null,
|
3083
|
+
containerCssClasses
|
3059
3084
|
]);
|
3060
3085
|
const selectTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
|
3061
3086
|
tag: 'select',
|
3062
|
-
parsedClasses:
|
3087
|
+
parsedClasses: containerSelectClasses
|
3063
3088
|
});
|
3064
|
-
|
3065
|
-
|
3089
|
+
const containerSelectTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : `${selectTestId}-container`;
|
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(), defaultChecked: selected !== null && selected !== void 0 ? selected : false, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }, name))))));
|
3066
3092
|
};
|
3067
3093
|
|
3068
|
-
const File = ({ testId = null, fileName = null, uploadIcon = { iconLabel: 'upload' }, uploadText = 'Choose a file…',
|
3069
|
-
const
|
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 }) => {
|
3095
|
+
const fileContainerClasses = parseClasses([
|
3070
3096
|
'file',
|
3071
3097
|
fileName ? 'has-name' : null,
|
3072
3098
|
buttonOnRight ? 'is-right' : null,
|
3073
3099
|
isFullWidth ? 'is-fullwidth' : null,
|
3074
3100
|
isBoxed ? 'is-boxed' : null,
|
3075
3101
|
color,
|
3076
|
-
size
|
3102
|
+
size,
|
3103
|
+
containerCssClasses
|
3077
3104
|
]);
|
3078
|
-
const
|
3105
|
+
const fileContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
|
3079
3106
|
tag: 'file',
|
3080
|
-
parsedClasses:
|
3107
|
+
parsedClasses: fileContainerClasses,
|
3081
3108
|
rules: [
|
3082
3109
|
{
|
3083
|
-
|
3084
|
-
|
3110
|
+
regExp: /has/gm,
|
3111
|
+
replacer: '-has'
|
3085
3112
|
},
|
3086
3113
|
{
|
3087
|
-
|
3088
|
-
|
3114
|
+
regExp: /is|file/gm,
|
3115
|
+
replacer: ''
|
3089
3116
|
}
|
3090
3117
|
]
|
3091
3118
|
});
|
3092
|
-
const
|
3093
|
-
|
3119
|
+
const fileInputClasses = cssClasses !== null && cssClasses !== void 0 ? cssClasses : 'file-input';
|
3120
|
+
const fileInputTestId = testId !== null && testId !== void 0 ? testId : `${fileContainerTestId}-input`;
|
3121
|
+
return (React.createElement("section", { "data-testid": fileContainerTestId, className: fileContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
|
3094
3122
|
React.createElement("label", { className: 'file-label' },
|
3095
|
-
React.createElement("input", { "data-testid": fileInputTestId,
|
3123
|
+
React.createElement("input", { "data-testid": fileInputTestId, type: 'file', name: 'resume', className: fileInputClasses, style: style !== null && style !== void 0 ? style : undefined, onClick: onClick !== null && onClick !== void 0 ? onClick : undefined }),
|
3096
3124
|
React.createElement("span", { className: 'file-cta' },
|
3097
3125
|
uploadIcon ? React.createElement(Icon, Object.assign({}, uploadIcon)) : null,
|
3098
3126
|
React.createElement("span", { className: 'file-label' }, uploadText)),
|
3099
3127
|
fileName ? React.createElement("span", { className: 'file-name' }, fileName) : null)));
|
3100
3128
|
};
|
3101
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
|
+
|
3102
3175
|
exports.Block = Block;
|
3103
3176
|
exports.Box = Box;
|
3104
3177
|
exports.Button = Button;
|
3178
|
+
exports.Checkbox = CheckBox;
|
3105
3179
|
exports.Column = Column;
|
3106
3180
|
exports.Delete = Delete;
|
3107
3181
|
exports.File = File;
|
3108
3182
|
exports.Icon = Icon;
|
3109
3183
|
exports.Input = Input;
|
3110
3184
|
exports.ProgressBar = ProgressBar;
|
3185
|
+
exports.RadioButton = RadioButton;
|
3111
3186
|
exports.Select = Select;
|
3112
3187
|
exports.Tag = Tag;
|
3113
3188
|
exports.TextArea = TextArea;
|