@spothero/ui 14.4.0-beta.0 → 14.5.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,7 +1,30 @@
1
- # 14.4.0-beta.0 - 04/21/2022
1
+ # 14.5.0 - 05/03/2022
2
+
3
+ ## New Features
4
+ * [[173526f](https://github.com/spothero/fe-ui/commit/173526f)] - FED-354 feat: adds Input component ([#283](https://github.com/spothero/fe-ui/pull/283)) (annaliarosed)
5
+ * `feat:` Set up TextInput component
6
+ * `refactor:` Rename component and set up styles
7
+ * `feat:` Unlabeled, placeholder styles added
8
+ * `feat:` Unlabeled, value styles added
9
+ * `feat:` Unlabeled, focus styles added
10
+ * `feat:` Unlabeled, error and disabled styles added
11
+ * `feat:` Add label prop and styles
12
+ * `feat:` Add helperText prop and styles
13
+ * `feat:` Add errorMessage prop and styles
14
+ * `feat:` Add isReadOnly prop to stories
15
+ * `fix:` Clean up
16
+ * `fix:` Change value color when isInvalid
17
+ * `fix:` Add missing ref
18
+ * `refactor:` Extract FormControl
19
+ * `fix:` Remove imported interfaces
20
+ * `fix:` Pass only isInvalid prop to FormControl
21
+ * `fix:` Pass only isDisabled and isRequired prop to FormControl
22
+ * `fix:` Pass forgotten propsCo-authored-by: Annalia Destefano <annalia.destefano@spothero.com>
23
+
24
+ # 14.4.0 - 04/21/2022
2
25
 
3
26
  ## Dependency Updates
4
- * [[2d872f5](https://github.com/spothero/fe-ui/commit/2d872f5)] - Upgrade to React 17 (Gru Singh)
27
+ * [[d04c143](https://github.com/spothero/fe-ui/commit/d04c143)] - Upgrade to React 17 ([#282](https://github.com/spothero/fe-ui/pull/282)) (Gru Singh)
5
28
 
6
29
  # 14.3.5 - 04/11/2022
7
30
 
package/CHANGELOG.tmp CHANGED
@@ -1,5 +1,23 @@
1
- # 14.4.0-beta.0 - 04/21/2022
1
+ # 14.5.0 - 05/03/2022
2
2
 
3
- ## Dependency Updates
4
- * [[2d872f5](https://github.com/spothero/fe-ui/commit/2d872f5)] - Upgrade to React 17 (Gru Singh)
3
+ ## New Features
4
+ * [[173526f](https://github.com/spothero/fe-ui/commit/173526f)] - FED-354 feat: adds Input component ([#283](https://github.com/spothero/fe-ui/pull/283)) (annaliarosed)
5
+ * `feat:` Set up TextInput component
6
+ * `refactor:` Rename component and set up styles
7
+ * `feat:` Unlabeled, placeholder styles added
8
+ * `feat:` Unlabeled, value styles added
9
+ * `feat:` Unlabeled, focus styles added
10
+ * `feat:` Unlabeled, error and disabled styles added
11
+ * `feat:` Add label prop and styles
12
+ * `feat:` Add helperText prop and styles
13
+ * `feat:` Add errorMessage prop and styles
14
+ * `feat:` Add isReadOnly prop to stories
15
+ * `fix:` Clean up
16
+ * `fix:` Change value color when isInvalid
17
+ * `fix:` Add missing ref
18
+ * `refactor:` Extract FormControl
19
+ * `fix:` Remove imported interfaces
20
+ * `fix:` Pass only isInvalid prop to FormControl
21
+ * `fix:` Pass only isDisabled and isRequired prop to FormControl
22
+ * `fix:` Pass forgotten propsCo-authored-by: Annalia Destefano <annalia.destefano@spothero.com>
5
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spothero/ui",
3
- "version": "14.4.0-beta.0",
3
+ "version": "14.5.0",
4
4
  "description": "SpotHero's React component UI library.",
5
5
  "main": "v2/index-bundled.cjs.js",
6
6
  "module": "v2/index.js",
@@ -0,0 +1,43 @@
1
+ import React, {forwardRef} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {
4
+ FormControl as ChakraFormControl,
5
+ FormHelperText,
6
+ FormLabel,
7
+ FormErrorMessage,
8
+ } from '@chakra-ui/react';
9
+
10
+ const FormControl = forwardRef(
11
+ ({children, label, helperText, errorMessage, ...props}, ref) => (
12
+ <ChakraFormControl {...props} ref={ref}>
13
+ {label && (
14
+ <FormLabel
15
+ color="gray.600"
16
+ fontWeight="semibold"
17
+ mb={2}
18
+ fontSize="sm"
19
+ >
20
+ {label}
21
+ </FormLabel>
22
+ )}
23
+ {children}
24
+ {helperText && (
25
+ <FormHelperText color="gray.600" mt={1} fontSize="xs">
26
+ {helperText}
27
+ </FormHelperText>
28
+ )}
29
+ <FormErrorMessage color="error" mt={1} fontSize="xs">
30
+ {errorMessage}
31
+ </FormErrorMessage>
32
+ </ChakraFormControl>
33
+ )
34
+ );
35
+
36
+ FormControl.propTypes = {
37
+ label: PropTypes.string,
38
+ helperText: PropTypes.string,
39
+ errorMessage: PropTypes.string,
40
+ children: PropTypes.node,
41
+ };
42
+
43
+ export default FormControl;
@@ -0,0 +1,41 @@
1
+ import React, {forwardRef} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import {Input as ChakraInput} from '@chakra-ui/react';
4
+ import FormControl from '../FormControl/FormControl';
5
+
6
+ const Input = 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
+ >
27
+ <ChakraInput ref={ref} {...props} />
28
+ </FormControl>
29
+ )
30
+ );
31
+
32
+ Input.propTypes = {
33
+ label: PropTypes.string,
34
+ helperText: PropTypes.string,
35
+ errorMessage: PropTypes.string,
36
+ isInvalid: PropTypes.bool,
37
+ isDisabled: PropTypes.bool,
38
+ isRequired: PropTypes.bool,
39
+ };
40
+
41
+ export default Input;
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import Component from './Input';
5
+
6
+ export default {
7
+ title: 'v2/Input',
8
+ component: Component,
9
+ parameters: {
10
+ removeBaseHtmlClass: true,
11
+ },
12
+ };
13
+
14
+ const InputTemplate = props => (
15
+ <Component variant="outline" maxWidth="200px" {...props} />
16
+ );
17
+
18
+ InputTemplate.propTypes = {
19
+ placeholder: PropTypes.string,
20
+ label: PropTypes.string,
21
+ helperText: PropTypes.string,
22
+ errorMessage: PropTypes.string,
23
+ isInvalid: PropTypes.bool,
24
+ isDisabled: PropTypes.bool,
25
+ isReadOnly: PropTypes.bool,
26
+ };
27
+
28
+ export const Input = InputTemplate.bind({});
29
+
30
+ Input.argTypes = {
31
+ placeholder: {
32
+ control: {type: 'text'},
33
+ },
34
+ label: {
35
+ control: {type: 'text'},
36
+ },
37
+ helperText: {
38
+ control: {type: 'text'},
39
+ },
40
+ errorMessage: {
41
+ control: {type: 'text'},
42
+ },
43
+ };
44
+
45
+ Input.args = {
46
+ placeholder: 'Placeholder text',
47
+ label: 'Label',
48
+ helperText: 'Helper text',
49
+ errorMessage: 'Error message',
50
+ isInvalid: false,
51
+ isDisabled: false,
52
+ isReadOnly: false,
53
+ };
@@ -0,0 +1 @@
1
+ export {default} from './Input';
@@ -0,0 +1,35 @@
1
+ import merge from 'lodash/merge';
2
+ import chakraDefaultTheme from '@chakra-ui/theme';
3
+
4
+ const variants = {
5
+ outline: {
6
+ field: {
7
+ border: '1px solid',
8
+ borderColor: 'gray.200',
9
+ fontSize: 'base',
10
+ paddingLeft: 3,
11
+ paddingRight: 3,
12
+ bg: 'inherit',
13
+ fontWeight: 'semibold',
14
+ boxShadow: 'none !important',
15
+ _placeholder: {color: 'gray.600', fontWeight: 'normal'},
16
+ _focus: {
17
+ borderColor: 'brandBlue',
18
+ },
19
+ _hover: {borderColor: 'gray.300'},
20
+ _readOnly: {boxShadow: 'none !important', userSelect: 'all'},
21
+ _disabled: {
22
+ backgroundColor: 'gray.50',
23
+ opacity: 0.4,
24
+ cursor: 'not-allowed',
25
+ },
26
+ _invalid: {
27
+ borderColor: 'error',
28
+ },
29
+ },
30
+ },
31
+ };
32
+
33
+ export default merge(chakraDefaultTheme.components.Input, {
34
+ variants,
35
+ });
@@ -22,6 +22,7 @@ export {default as Icon} from './Icon/Icon';
22
22
  export {default as Image} from './Image/Image';
23
23
  export {default as Loader} from './Loader/Loader';
24
24
  export {default as Checkbox} from './Checkbox';
25
+ export {default as Input} from './Input';
25
26
  export {Popover, PopoverTrigger, PopoverContent} from './Popover';
26
27
 
27
28
  // generic chakra reexports
@@ -11,3 +11,4 @@ export {default as Tabs} from './Tabs/styles';
11
11
  export {default as Select} from './Select/styles';
12
12
  export {default as Checkbox} from './Checkbox/styles';
13
13
  export {default as Popover} from './Popover/styles';
14
+ export {default as Input} from './Input/styles';