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.
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { RadioButtonProps } from '../../../interfaces/atomProps';
3
+ declare const RadioButton: React.FC<RadioButtonProps>;
4
+ export default RadioButton;
@@ -11,3 +11,5 @@ export { default as TextArea } from './TextArea';
11
11
  export { default as Delete } from './Delete';
12
12
  export { default as Select } from './Select';
13
13
  export { default as File } from './File';
14
+ export { default as Checkbox } from './Checkbox';
15
+ export { default as RadioButton } from './RadioButton';
@@ -1,14 +1,14 @@
1
1
  import { ParseTestIdProps } from '../interfaces/functionProps';
2
2
  /**
3
- * @param { Array<string | null> } _classes Required. Array of classNames on `string` (or `null`) values
3
+ * @param { Array<string | null> } _classes `Required`. Array of classNames on `string` (or `null`) values
4
4
  * @returns { string } A single string product of merge all classNames, separated by spaces
5
5
  */
6
6
  export declare const parseClasses: (_classes: Array<string | null | undefined>) => string;
7
7
  /**
8
8
  * @param { ParseTestIdProps } config Configuration object
9
- * @param { string } config.tag Required. Component tag used between to build the final testId string.
10
- * @param { string } config.parsedClasses Required. A single string of previously parsed classes what will be joined with `tag` property.
11
- * @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.
9
+ * @param { string } config.tag `Required`. Component tag used between to build the final testId string.
10
+ * @param { string } config.parsedClasses `Required`. A single string of previously parsed classes what will be joined with `tag` property.
11
+ * @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.
12
12
  * @returns A single string product of merge all classNames, separated by `separator` value
13
13
  */
14
14
  export declare const parseTestId: (config: ParseTestIdProps) => string;
@@ -220,14 +220,24 @@ export interface CheckBoxProps extends BasicProps {
220
220
  /** `Function` Click function, alone does not nothing, but can be reused for other components */
221
221
  onChange?: () => void;
222
222
  }
223
- interface RadioButtonItemProps {
223
+ export interface RadioButtonItemProps extends Pick<BasicProps, 'testId' | 'style'> {
224
+ /** `Attribute` `Required` Sets checkbox's text*/
224
225
  label: string;
225
- name: string;
226
+ /** `Attribute` Sets the name that will relate this checkbox with the others */
227
+ name?: string;
228
+ /** `Attribute` Shows the checkbox as checked or unchecked */
226
229
  isChecked?: boolean;
230
+ /** `Attribute` Will disable the checkbox */
227
231
  isDisabled?: boolean;
232
+ /** `Function` Click function, alone does not nothing, but can be reused for other components */
233
+ onChange?: () => void;
228
234
  }
229
235
  export interface RadioButtonProps extends BasicProps {
236
+ /** `Attribute` `Required` Indicates the options contained to be selected */
230
237
  options: RadioButtonItemProps[];
238
+ /** `Attribute` `Required` Sets the name that will relate this checkbox with the others */
239
+ name: string;
240
+ /** `Function` Click function, alone does not nothing, but can be reused for other components */
231
241
  onChange?: () => void;
232
242
  }
233
243
  export {};
@@ -1,6 +1,6 @@
1
1
  interface RegExpRule {
2
- usedRegExp?: RegExp;
3
- regExpReplacer?: string;
2
+ regExp?: RegExp;
3
+ replacer?: string;
4
4
  }
5
5
  export interface ParseTestIdProps {
6
6
  tag: string;
package/dist/esm/index.js CHANGED
@@ -2833,15 +2833,15 @@ var reactExports = react.exports;
2833
2833
  var React = /*@__PURE__*/getDefaultExportFromCjs(reactExports);
2834
2834
 
2835
2835
  /**
2836
- * @param { Array<string | null> } _classes Required. Array of classNames on `string` (or `null`) values
2836
+ * @param { Array<string | null> } _classes `Required`. Array of classNames on `string` (or `null`) values
2837
2837
  * @returns { string } A single string product of merge all classNames, separated by spaces
2838
2838
  */
2839
2839
  const parseClasses = (_classes) => _classes.filter(_class => _class).join(' ');
2840
2840
  /**
2841
2841
  * @param { ParseTestIdProps } config Configuration object
2842
- * @param { string } config.tag Required. Component tag used between to build the final testId string.
2843
- * @param { string } config.parsedClasses Required. A single string of previously parsed classes what will be joined with `tag` property.
2844
- * @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.
2842
+ * @param { string } config.tag `Required`. Component tag used between to build the final testId string.
2843
+ * @param { string } config.parsedClasses `Required`. A single string of previously parsed classes what will be joined with `tag` property.
2844
+ * @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.
2845
2845
  * @returns A single string product of merge all classNames, separated by `separator` value
2846
2846
  */
2847
2847
  const parseTestId = (config) => {
@@ -2849,7 +2849,7 @@ const parseTestId = (config) => {
2849
2849
  let fixedClassString = config.parsedClasses;
2850
2850
  if (config.rules) {
2851
2851
  for (const rule of config.rules) {
2852
- fixedClassString = fixedClassString.replace(rule.usedRegExp, rule.regExpReplacer);
2852
+ fixedClassString = fixedClassString.replace(rule.regExp, rule.replacer);
2853
2853
  }
2854
2854
  }
2855
2855
  else {
@@ -2972,8 +2972,8 @@ const generateIconContainer = (icon, color) => {
2972
2972
  parsedClasses: (_a = color === null || color === void 0 ? void 0 : color.toString()) !== null && _a !== void 0 ? _a : '',
2973
2973
  rules: [
2974
2974
  {
2975
- usedRegExp: /has-text/gm,
2976
- regExpReplacer: ''
2975
+ regExp: /has-text/gm,
2976
+ replacer: ''
2977
2977
  }
2978
2978
  ]
2979
2979
  });
@@ -2999,12 +2999,12 @@ const Icon = ({ testId = null, containerTestId = null, cssClasses = null, contai
2999
2999
  parsedClasses: iconClasses,
3000
3000
  rules: [
3001
3001
  {
3002
- usedRegExp: /mdi-|mdi--/gm,
3003
- regExpReplacer: ''
3002
+ regExp: /mdi-|mdi--/gm,
3003
+ replacer: ''
3004
3004
  },
3005
3005
  {
3006
- usedRegExp: /mdi /gm,
3007
- regExpReplacer: '-'
3006
+ regExp: /mdi /gm,
3007
+ replacer: '-'
3008
3008
  }
3009
3009
  ],
3010
3010
  separator: '-'
@@ -3048,12 +3048,12 @@ const TextArea = ({ testId = null, cssClasses = null, style = null, text = null,
3048
3048
  parsedClasses: textAreaClasses,
3049
3049
  rules: [
3050
3050
  {
3051
- usedRegExp: /textarea/gm,
3052
- regExpReplacer: ''
3051
+ regExp: /textarea/gm,
3052
+ replacer: ''
3053
3053
  },
3054
3054
  {
3055
- usedRegExp: /is-|has-/gm,
3056
- regExpReplacer: '-'
3055
+ regExp: /is-|has-/gm,
3056
+ replacer: '-'
3057
3057
  }
3058
3058
  ]
3059
3059
  });
@@ -3086,7 +3086,7 @@ const Select = ({ testId = null, containerTestId = null, cssClasses = null, cont
3086
3086
  });
3087
3087
  const containerSelectTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : `${selectTestId}-container`;
3088
3088
  return (React.createElement("section", { "data-testid": containerSelectTestId, className: containerSelectClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
3089
- 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))))));
3089
+ 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))))));
3090
3090
  };
3091
3091
 
3092
3092
  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 }) => {
@@ -3105,12 +3105,12 @@ const File = ({ testId = null, containerTestId = null, cssClasses = null, contai
3105
3105
  parsedClasses: fileContainerClasses,
3106
3106
  rules: [
3107
3107
  {
3108
- usedRegExp: /has/gm,
3109
- regExpReplacer: '-has'
3108
+ regExp: /has/gm,
3109
+ replacer: '-has'
3110
3110
  },
3111
3111
  {
3112
- usedRegExp: /is|file/gm,
3113
- regExpReplacer: ''
3112
+ regExp: /is|file/gm,
3113
+ replacer: ''
3114
3114
  }
3115
3115
  ]
3116
3116
  });
@@ -3125,5 +3125,50 @@ const File = ({ testId = null, containerTestId = null, cssClasses = null, contai
3125
3125
  fileName ? React.createElement("span", { className: 'file-name' }, fileName) : null)));
3126
3126
  };
3127
3127
 
3128
- export { Block, Box, Button, Column, Delete, File, Icon, Input, ProgressBar, Select, Tag, TextArea, Title };
3128
+ const parseContentTestId = (content) => {
3129
+ if (typeof content === 'string')
3130
+ return `-${content === null || content === void 0 ? void 0 : content.toString()}`;
3131
+ if (content !== null)
3132
+ return '-with-component';
3133
+ return '';
3134
+ };
3135
+ const CheckBox = ({ testId = null, containerTestId = null, cssClasses = null, containerCssClasses = null, style = null, containerStyle = null, content = null, isDisabled = null, onChange = null }) => {
3136
+ const checkboxContainerClasses = parseClasses([
3137
+ 'checkbox',
3138
+ containerCssClasses
3139
+ ]);
3140
+ const checkboxContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
3141
+ tag: 'checkbox-container',
3142
+ parsedClasses: parseContentTestId(content)
3143
+ });
3144
+ const checkboxTestId = testId !== null && testId !== void 0 ? testId : parseTestId({
3145
+ tag: 'checkbox',
3146
+ parsedClasses: parseContentTestId(content)
3147
+ });
3148
+ return (React.createElement("label", { "data-testid": checkboxContainerTestId, className: checkboxContainerClasses, style: containerStyle !== null && containerStyle !== void 0 ? containerStyle : undefined },
3149
+ 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 }),
3150
+ content));
3151
+ };
3152
+
3153
+ // PARSERS
3154
+ const renderRadioButton = (config, index) => {
3155
+ const { testId = null, label, name, isChecked = false, isDisabled = false, style = null, onChange } = config;
3156
+ const radioButtonTestId = testId !== null && testId !== void 0 ? testId : `test-radio-button-item-${index}`;
3157
+ return (React.createElement("label", { key: index, className: 'radio' },
3158
+ React.createElement("input", { "data-testid": radioButtonTestId, type: 'radio', style: style !== null && style !== void 0 ? style : undefined, name: name, defaultChecked: isChecked, disabled: isDisabled, onChange: onChange }),
3159
+ label));
3160
+ };
3161
+ const RadioButton = ({ containerTestId = null, containerCssClasses = null, containerStyle = null, options, name, onChange = null }) => {
3162
+ const radioButtonContainerClasses = parseClasses([
3163
+ 'control',
3164
+ containerCssClasses
3165
+ ]);
3166
+ const radioButtonContainerTestId = containerTestId !== null && containerTestId !== void 0 ? containerTestId : parseTestId({
3167
+ tag: 'container-',
3168
+ parsedClasses: radioButtonContainerClasses
3169
+ });
3170
+ 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))));
3171
+ };
3172
+
3173
+ export { Block, Box, Button, CheckBox as Checkbox, Column, Delete, File, Icon, Input, ProgressBar, RadioButton, Select, Tag, TextArea, Title };
3129
3174
  //# sourceMappingURL=index.js.map