@spothero/ui 14.5.2 → 14.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ # 14.7.0 - 05/12/2022
2
+
3
+ ## New Features
4
+ * [[bf20c4f](https://github.com/spothero/fe-ui/commit/bf20c4f)] - Add classname to input and select so it doesn't break in prod ([#287](https://github.com/spothero/fe-ui/pull/287)) (annaliarosed)
5
+ * `Co-authored-by:` Annalia Destefano <annalia.destefano@spothero.com>
6
+
7
+ # 14.6.0 - 05/10/2022
8
+
9
+ ## New Features
10
+ * [[119cc85](https://github.com/spothero/fe-ui/commit/119cc85)] - Wrap Select component in FormControl component ([#285](https://github.com/spothero/fe-ui/pull/285)) (annaliarosed)
11
+ * `feat:` Wrap Select in FormControl and update stories for Select
12
+ * `feat:` Update styles to match design
13
+ * `chore:` Remove FormControl stories for now
14
+ * `fix:` Connect label and input
15
+ * `fix:` Connect label and inputCo-authored-by: Annalia Destefano <annalia.destefano@spothero.com>
16
+
1
17
  # 14.5.2 - 05/10/2022
2
18
 
3
19
  ## Miscellaneous Updates
package/CHANGELOG.tmp CHANGED
@@ -1,5 +1,6 @@
1
- # 14.5.2 - 05/10/2022
1
+ # 14.7.0 - 05/12/2022
2
2
 
3
- ## Miscellaneous Updates
4
- * [[d59e284](https://github.com/spothero/fe-ui/commit/d59e284)] - `fix:` Link new Input and Label using htmlFor ([#286](https://github.com/spothero/fe-ui/pull/286)) (Mick Johnson)
3
+ ## New Features
4
+ * [[bf20c4f](https://github.com/spothero/fe-ui/commit/bf20c4f)] - Add classname to input and select so it doesn't break in prod ([#287](https://github.com/spothero/fe-ui/pull/287)) (annaliarosed)
5
+ * `Co-authored-by:` Annalia Destefano <annalia.destefano@spothero.com>
5
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spothero/ui",
3
- "version": "14.5.2",
3
+ "version": "14.7.0",
4
4
  "description": "SpotHero's React component UI library.",
5
5
  "main": "v2/index-bundled.cjs.js",
6
6
  "module": "v2/index.js",
@@ -39,7 +39,7 @@ FormControl.propTypes = {
39
39
  label: PropTypes.string,
40
40
  helperText: PropTypes.string,
41
41
  errorMessage: PropTypes.string,
42
- children: PropTypes.node,
42
+ children: PropTypes.element,
43
43
  };
44
44
 
45
45
  export default FormControl;
@@ -1,4 +1,5 @@
1
1
  import React, {forwardRef} from 'react';
2
+ import cn from 'classnames';
2
3
  import PropTypes from 'prop-types';
3
4
  import {Input as ChakraInput} from '@chakra-ui/react';
4
5
  import FormControl from '../FormControl/FormControl';
@@ -15,19 +16,23 @@ const Input = forwardRef(
15
16
  ...props
16
17
  },
17
18
  ref
18
- ) => (
19
- <FormControl
20
- isInvalid={isInvalid}
21
- isDisabled={isDisabled}
22
- isRequired={isRequired}
23
- errorMessage={errorMessage}
24
- helperText={helperText}
25
- label={label}
26
- inputId={props.id}
27
- >
28
- <ChakraInput ref={ref} {...props} />
29
- </FormControl>
30
- )
19
+ ) => {
20
+ const classes = cn({'FormElement-contains-error': isInvalid});
21
+
22
+ return (
23
+ <FormControl
24
+ isInvalid={isInvalid}
25
+ isDisabled={isDisabled}
26
+ isRequired={isRequired}
27
+ errorMessage={errorMessage}
28
+ helperText={helperText}
29
+ label={label}
30
+ inputId={props.id}
31
+ >
32
+ <ChakraInput ref={ref} className={classes} {...props} />
33
+ </FormControl>
34
+ );
35
+ }
31
36
  );
32
37
 
33
38
  Input.propTypes = {
@@ -50,4 +50,5 @@ Input.args = {
50
50
  isInvalid: false,
51
51
  isDisabled: false,
52
52
  isReadOnly: false,
53
+ isRequired: false,
53
54
  };
@@ -1 +1,54 @@
1
- export {Select as default} from '@chakra-ui/react';
1
+ import React, {forwardRef} from 'react';
2
+ import cn from 'classnames';
3
+ import PropTypes from 'prop-types';
4
+ import {Select as ChakraSelect} from '@chakra-ui/react';
5
+ import FormControl from '../FormControl/FormControl';
6
+
7
+ const Select = forwardRef(
8
+ (
9
+ {
10
+ label,
11
+ helperText,
12
+ errorMessage,
13
+ isInvalid,
14
+ isDisabled,
15
+ isRequired,
16
+ ...props
17
+ },
18
+ ref
19
+ ) => {
20
+ const classes = cn({'FormElement-contains-error': isInvalid});
21
+
22
+ return (
23
+ <FormControl
24
+ isInvalid={isInvalid}
25
+ isDisabled={isDisabled}
26
+ isRequired={isRequired}
27
+ errorMessage={errorMessage}
28
+ helperText={helperText}
29
+ label={label}
30
+ inputId={props.id}
31
+ >
32
+ <ChakraSelect
33
+ fontWeight="regular"
34
+ fontSize="sm"
35
+ ref={ref}
36
+ className={classes}
37
+ {...props}
38
+ />
39
+ </FormControl>
40
+ );
41
+ }
42
+ );
43
+
44
+ Select.propTypes = {
45
+ id: PropTypes.string.isRequired,
46
+ label: PropTypes.string,
47
+ helperText: PropTypes.string,
48
+ errorMessage: PropTypes.string,
49
+ isInvalid: PropTypes.bool,
50
+ isDisabled: PropTypes.bool,
51
+ isRequired: PropTypes.bool,
52
+ };
53
+
54
+ export default Select;
@@ -1,33 +1,59 @@
1
1
  import React from 'react';
2
+ import PropTypes from 'prop-types';
2
3
 
3
4
  import Component from './Select';
4
5
 
5
6
  export default {
6
7
  title: 'v2/Select',
8
+ component: Component,
7
9
  parameters: {
8
10
  removeBaseHtmlClass: true,
9
11
  },
10
12
  };
11
13
 
12
- const SelectTemplate = () => {
13
- return (
14
- <Component
15
- variant="outline"
16
- value="three"
17
- onChange={e => {
18
- // eslint-disable-next-line no-console
19
- console.log('Selected value', e.target.value);
20
- }}
21
- maxWidth="300px"
22
- >
23
- <option value="one">One</option>
24
- <option value="two">Two</option>
25
- <option value="three">Three</option>
26
- <option value="four">Four</option>
27
- </Component>
28
- );
29
- };
14
+ const SelectTemplate = props => (
15
+ <Component variant="outline" maxWidth="200px" {...props}>
16
+ <option value="one">One</option>
17
+ <option value="two">Two</option>
18
+ <option value="three">Three</option>
19
+ <option value="four">Four</option>
20
+ </Component>
21
+ );
30
22
 
31
- SelectTemplate.propTypes = {};
23
+ SelectTemplate.propTypes = {
24
+ placeholder: PropTypes.string,
25
+ label: PropTypes.string,
26
+ helperText: PropTypes.string,
27
+ errorMessage: PropTypes.string,
28
+ isInvalid: PropTypes.bool,
29
+ isDisabled: PropTypes.bool,
30
+ isReadOnly: PropTypes.bool,
31
+ };
32
32
 
33
33
  export const Select = SelectTemplate.bind({});
34
+
35
+ Select.argTypes = {
36
+ placeholder: {
37
+ control: {type: 'text'},
38
+ },
39
+ label: {
40
+ control: {type: 'text'},
41
+ },
42
+ helperText: {
43
+ control: {type: 'text'},
44
+ },
45
+ errorMessage: {
46
+ control: {type: 'text'},
47
+ },
48
+ };
49
+
50
+ Select.args = {
51
+ placeholder: 'Placeholder text',
52
+ label: 'Label',
53
+ helperText: 'Helper text',
54
+ errorMessage: 'Error message',
55
+ isInvalid: false,
56
+ isDisabled: false,
57
+ isReadOnly: false,
58
+ isRequired: false,
59
+ };