@spothero/ui 14.5.2 → 14.6.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,13 @@
1
+ # 14.6.0 - 05/10/2022
2
+
3
+ ## New Features
4
+ * [[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)
5
+ * `feat:` Wrap Select in FormControl and update stories for Select
6
+ * `feat:` Update styles to match design
7
+ * `chore:` Remove FormControl stories for now
8
+ * `fix:` Connect label and input
9
+ * `fix:` Connect label and inputCo-authored-by: Annalia Destefano <annalia.destefano@spothero.com>
10
+
1
11
  # 14.5.2 - 05/10/2022
2
12
 
3
13
  ## Miscellaneous Updates
package/CHANGELOG.tmp CHANGED
@@ -1,5 +1,10 @@
1
- # 14.5.2 - 05/10/2022
1
+ # 14.6.0 - 05/10/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
+ * [[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)
5
+ * `feat:` Wrap Select in FormControl and update stories for Select
6
+ * `feat:` Update styles to match design
7
+ * `chore:` Remove FormControl stories for now
8
+ * `fix:` Connect label and input
9
+ * `fix:` Connect label and inputCo-authored-by: Annalia Destefano <annalia.destefano@spothero.com>
5
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spothero/ui",
3
- "version": "14.5.2",
3
+ "version": "14.6.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;
@@ -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,48 @@
1
- export {Select as default} from '@chakra-ui/react';
1
+ import React, {forwardRef} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {Select as ChakraSelect} from '@chakra-ui/react';
4
+ import FormControl from '../FormControl/FormControl';
5
+
6
+ const Select = forwardRef(
7
+ (
8
+ {
9
+ label,
10
+ helperText,
11
+ errorMessage,
12
+ isInvalid,
13
+ isDisabled,
14
+ isRequired,
15
+ ...props
16
+ },
17
+ 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
+ <ChakraSelect
29
+ fontWeight="regular"
30
+ fontSize="sm"
31
+ ref={ref}
32
+ {...props}
33
+ />
34
+ </FormControl>
35
+ )
36
+ );
37
+
38
+ Select.propTypes = {
39
+ id: PropTypes.string.isRequired,
40
+ label: PropTypes.string,
41
+ helperText: PropTypes.string,
42
+ errorMessage: PropTypes.string,
43
+ isInvalid: PropTypes.bool,
44
+ isDisabled: PropTypes.bool,
45
+ isRequired: PropTypes.bool,
46
+ };
47
+
48
+ 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
+ };