groundfloor-react-ui 1.0.4 → 1.0.7

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.
@@ -4,120 +4,126 @@ import styled, { css, useTheme } from 'styled-components';
4
4
  import defaultThemeColor from '../constants/defaultThemeColor';
5
5
 
6
6
  const TextBox = styled.div`
7
- border: 1px solid ${({ theme }) => theme ? defaultThemeColor.border : theme.variant['primary-1']};
8
- border-radius: 4px;
9
- padding: 6.5px 12px;
10
- display: flex;
11
- align-items: center;
12
- background-color: ${({ theme }) => theme.bgColor};
13
- .input-icon svg path {
14
- fill: ${({ theme }) => theme.variant['neutral-1']};
15
- }
16
-
17
- &:focus-within {
18
- border: 1px solid ${({ theme }) => theme.variant['primary-1']};
19
- outline: none;
20
-
21
- .input-icon svg path {
22
- fill: ${({ theme }) => theme.variant['primary-1']};
23
- }
7
+ border: 1px solid
8
+ ${({ theme }) =>
9
+ theme ? defaultThemeColor.border : theme.variant['primary-1']};
10
+ border-radius: 4px;
11
+ padding: 6.5px 12px;
12
+ display: flex;
13
+ align-items: center;
14
+ background-color: ${({ theme }) => theme.bgColor};
15
+ .input-icon svg path {
16
+ fill: ${({ theme }) => theme.variant['neutral-1']};
17
+ }
18
+
19
+ &:focus-within {
20
+ border: 1px solid ${({ theme }) => theme.variant['primary-1']};
21
+ outline: none;
22
+
23
+ .input-icon svg path {
24
+ fill: ${({ theme }) => theme.variant['primary-1']};
24
25
  }
26
+ }
25
27
  `;
26
28
 
27
29
  TextBox.defaultProps = {
28
30
  theme: defaultThemeColor,
29
- }
31
+ };
30
32
 
31
33
  const Input = styled.input`
32
- border: 0;
33
- outline: 0;
34
- color: ${({ theme }) => theme.variant['primary-2']};
35
- margin: 0px;
36
- padding: 0;
37
- font-size: 14px;
38
- flex-grow: 1;
39
- flex-shrink: 0;
40
-
41
- // custom styles
42
- ${({ inputStyle }) => inputStyle}
34
+ border: 0;
35
+ outline: 0;
36
+ color: ${({ theme }) => theme.variant['primary-2']};
37
+ margin: 0px;
38
+ padding: 0;
39
+ font-size: 14px;
40
+ flex-grow: 1;
41
+ flex-shrink: 0;
42
+
43
+ // custom styles
44
+ ${({ inputStyle }) => inputStyle}
43
45
  `;
44
46
 
45
47
  Input.defaultProps = {
46
48
  theme: defaultThemeColor,
47
- }
49
+ };
48
50
 
49
51
  const requiredAsterisk = css`
50
- &:after {
51
- content:" *";
52
- color: ${({ theme }) => theme.variant['error']};
53
- }
54
- `
52
+ &:after {
53
+ content: ' *';
54
+ color: ${({ theme }) => theme.variant['error']};
55
+ }
56
+ `;
55
57
 
56
58
  const Label = styled.label`
57
- display: flex;
58
- margin-right: 10px;
59
- align-content: center;
60
- align-items: center;
61
- justify-content: center;
62
- display: block;
63
- margin-bottom: ${({ labelInline, }) => (labelInline) ? '0' : '7px'};
64
- margin-right: ${({ labelInline }) => labelInline ? '7px' : ''};
65
- color: ${({ theme }) => theme.variant['neutral-2']};
59
+ display: flex;
60
+ margin-right: 10px;
61
+ align-content: center;
62
+ align-items: center;
63
+ justify-content: center;
64
+ display: block;
65
+ margin-bottom: ${({ labelInline }) => (labelInline ? '0' : '7px')};
66
+ margin-right: ${({ labelInline }) => (labelInline ? '7px' : '')};
67
+ padding-bottom: 0px;
68
+ color: ${({ theme }) => theme.variant['neutral-2']};
66
69
  `;
67
70
 
68
71
  Label.defaultProps = {
69
72
  theme: defaultThemeColor,
70
- }
73
+ };
71
74
 
72
75
  const inline = css`
73
- display: flex;
74
- align-items: center;
75
- `
76
+ display: flex;
77
+ align-items: center;
78
+ `;
76
79
 
77
80
  const Form = styled.div`
78
- ${({ labelInline }) => labelInline ? inline : null}
81
+ ${({ labelInline }) => (labelInline ? inline : null)}
79
82
 
80
- > div {
81
- flex: 1 0 auto;
82
- }
83
- `
83
+ > div {
84
+ flex: 1 0 auto;
85
+ }
86
+ `;
84
87
 
85
88
  Form.defaultProps = {
86
89
  theme: defaultThemeColor,
87
- }
88
- export const NumericInput = ({ label, inputValue, inputStyle, iconBefore, iconAfter, onChange, ...props }) => {
90
+ };
91
+ export const NumericInput = ({
92
+ label,
93
+ inputValue,
94
+ inputStyle,
95
+ iconBefore,
96
+ iconAfter,
97
+ onChange,
98
+ ...props
99
+ }) => {
89
100
  const handleChange = (e) => {
90
101
  const re = /^[0-9\b.-]+$/;
91
102
  const { value } = e.currentTarget;
92
103
  if (value === '' || re.test(value)) {
93
104
  onChange(value);
94
105
  }
95
- }
106
+ };
96
107
 
97
108
  return (
98
109
  <Form {...props}>
99
110
  {label.length > 0 && <Label {...props}>{label}</Label>}
100
111
  <div>
101
- <TextBox
102
- {...props}
103
- >
104
- <div className="input-icon">
105
- {iconBefore}
106
- </div>
107
- <Input {...props}
112
+ <TextBox {...props}>
113
+ <div className='input-icon'>{iconBefore}</div>
114
+ <Input
115
+ {...props}
108
116
  inputStyle={inputStyle}
109
117
  value={inputValue}
110
118
  onChange={handleChange}
111
119
  type='number'
112
120
  />
113
- <div className="input-icon">
114
- {iconAfter}
115
- </div>
121
+ <div className='input-icon'>{iconAfter}</div>
116
122
  </TextBox>
117
123
  </div>
118
124
  </Form>
119
- )
120
- }
125
+ );
126
+ };
121
127
 
122
128
  NumericInput.propTypes = {
123
129
  /**
@@ -138,8 +144,7 @@ NumericInput.propTypes = {
138
144
  inputValue: PropTypes.any,
139
145
 
140
146
  inputStyle: PropTypes.object,
141
-
142
- }
147
+ };
143
148
 
144
149
  NumericInput.defaultProps = {
145
150
  theme: defaultThemeColor,
@@ -147,4 +152,4 @@ NumericInput.defaultProps = {
147
152
  labelInline: false,
148
153
  inputStyle: {},
149
154
  inputValue: null,
150
- }
155
+ };
@@ -100,6 +100,7 @@ export const PasswordInput = ({
100
100
  style={{
101
101
  display: 'flex',
102
102
  marginBottom: `${!labelInline ? '7px' : ''}`,
103
+ paddingBottom: '0px',
103
104
  }}
104
105
  {...props}
105
106
  />
@@ -6,64 +6,87 @@ import defaultStyles from '../constants/defaultStyle';
6
6
  import getDefaultStyles from '../constants/utils';
7
7
  import { Label } from '../Label';
8
8
 
9
-
10
9
  const RadioOuterCircle = styled.div`
10
+ box-sizing: initial;
11
11
 
12
- //Set the styles from the default styles object
13
- ${({ theme, defaultRadioOuterCircleStyle }) => {
12
+ //Set the styles from the default styles object
13
+ ${({ theme, defaultRadioOuterCircleStyle }) => {
14
14
  return getDefaultStyles(theme, defaultRadioOuterCircleStyle);
15
15
  }}
16
-
17
- border: 2px solid ${({ value, selected, selectedCircleColor, defaultBorderColor }) => value !== selected ? defaultBorderColor : selectedCircleColor};
18
-
19
- // custom styles
20
- ${({ radioOuterCircleStyle }) => radioOuterCircleStyle}
21
- `;
22
16
 
17
+ border: 2px solid ${({
18
+ value,
19
+ selected,
20
+ selectedCircleColor,
21
+ defaultBorderColor,
22
+ }) => (value !== selected ? defaultBorderColor : selectedCircleColor)};
23
+
24
+ // custom styles
25
+ ${({ radioOuterCircleStyle }) => radioOuterCircleStyle}
26
+ `;
23
27
 
24
28
  const RadioInnerCircle = styled.div`
29
+ box-sizing: initial;
25
30
 
26
- //Set the styles from the default styles object
27
- ${({ theme, defaultRadioInnerCircleStyle }) => {
31
+ //Set the styles from the default styles object
32
+ ${({ theme, defaultRadioInnerCircleStyle }) => {
28
33
  return getDefaultStyles(theme, defaultRadioInnerCircleStyle);
29
34
  }}
30
-
31
- width: ${({ value, selected, width }) => value === selected ? width : 0};
32
- height: ${({ value, selected, height }) => value === selected ? height : 0};
33
- background-color: ${({ value, selected, selectedCircleColor }) => value === selected ? selectedCircleColor : 'transparent'};
34
-
35
- // custom styles
36
- ${({ radioInnerCircleStyle }) => radioInnerCircleStyle}
35
+
36
+ width: ${({ value, selected, width }) => (value === selected ? width : 0)};
37
+ height: ${({ value, selected, height }) => (value === selected ? height : 0)};
38
+ background-color: ${({ value, selected, selectedCircleColor }) =>
39
+ value === selected ? selectedCircleColor : 'transparent'};
40
+
41
+ // custom styles
42
+ ${({ radioInnerCircleStyle }) => radioInnerCircleStyle}
37
43
  `;
38
44
 
39
45
  const OptionText = styled.div`
40
- //Set the styles from the default styles object
41
- ${({ theme, defaultOptionStyle }) => {
46
+ //Set the styles from the default styles object
47
+ ${({ theme, defaultOptionStyle }) => {
42
48
  return getDefaultStyles(theme, defaultOptionStyle);
43
49
  }}
44
- margin-right: ${({ inline }) => !inline ? '30px' : ''};
45
- color: ${({ selected, selectedOptionTextColor, defaultOptionColor }) => selected ?
46
- selectedOptionTextColor : defaultOptionColor};
47
-
48
- // custom styles
49
- ${({ optionStyle }) => optionStyle}
50
+ margin-right: ${({ inline }) => (!inline ? '30px' : '')};
51
+ color: ${({ selected, selectedOptionTextColor, defaultOptionColor }) =>
52
+ selected ? selectedOptionTextColor : defaultOptionColor};
53
+
54
+ // custom styles
55
+ ${({ optionStyle }) => optionStyle}
50
56
  `;
51
57
 
52
58
  const WrapperDiv = styled.div`
53
- margin-bottom: ${({ inline }) => !inline ? '14px' : ''};
54
- cursor: pointer;
55
- align-items: center;
56
- display: flex;
57
- gap: 10px;
58
- `
59
+ margin-bottom: ${({ inline }) => (!inline ? '14px' : '')};
60
+ cursor: pointer;
61
+ align-items: center;
62
+ display: flex;
63
+ gap: 10px;
64
+ `;
59
65
 
60
66
  const ParentDiv = styled.div`
61
- display: ${({ inline }) => !inline ? "inline-block" : "flex"};
62
- width: max-content;
63
- margin: 0;
64
- `
67
+ display: ${({ inline }) => (!inline ? 'inline-block' : 'flex')};
68
+ width: max-content;
69
+ margin: 0;
70
+ `;
65
71
 
66
- export const RadioInput = ({ radioOuterCircleStyle, radioInnerCircleStyle, labelStyle, label, optionStyle, options, selectedCircleColor, selectedOptionTextColor, onChange, selected, width, height, inline, defaultBorderColor, defaultOptionColor, ...props }) => {
72
+ export const RadioInput = ({
73
+ radioOuterCircleStyle,
74
+ radioInnerCircleStyle,
75
+ labelStyle,
76
+ label,
77
+ optionStyle,
78
+ options,
79
+ selectedCircleColor,
80
+ selectedOptionTextColor,
81
+ onChange,
82
+ selected,
83
+ width,
84
+ height,
85
+ inline,
86
+ defaultBorderColor,
87
+ defaultOptionColor,
88
+ ...props
89
+ }) => {
67
90
  return (
68
91
  <div>
69
92
  <Label
@@ -72,52 +95,71 @@ export const RadioInput = ({ radioOuterCircleStyle, radioInnerCircleStyle, label
72
95
  type={'radio-label'}
73
96
  text={label}
74
97
  />
75
- <ParentDiv inline={inline} >
98
+ <ParentDiv inline={inline}>
76
99
  {options.map((item, i) => {
77
- return <WrapperDiv
78
- key={i + Math.random() * 101}
79
- inline={inline}
80
- onClick={() => { !item?.disabled && onChange(item.value) }}>
81
- <RadioOuterCircle
82
- theme={defaultStyles}
83
- themeColor={defaultThemeColor}
84
- defaultBorderColor={defaultBorderColor}
85
- selectedCircleColor={selectedCircleColor}
86
- radioOuterCircleStyle={{ ...radioOuterCircleStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', borderColor: item?.disabled && item?.disabledColor }}
87
- defaultRadioOuterCircleStyle={'radio-outer-circle'}
88
- value={item.value}
89
- selected={!item?.disabled && selected}
100
+ return (
101
+ <WrapperDiv
102
+ key={i + Math.random() * 101}
103
+ inline={inline}
104
+ onClick={() => {
105
+ !item?.disabled && onChange(item.value);
106
+ }}
90
107
  >
91
-
92
- <RadioInnerCircle
108
+ <RadioOuterCircle
93
109
  theme={defaultStyles}
94
- width={width}
95
- height={height}
110
+ themeColor={defaultThemeColor}
111
+ defaultBorderColor={defaultBorderColor}
96
112
  selectedCircleColor={selectedCircleColor}
97
- radioInnerCircleStyle={{ ...radioInnerCircleStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', backgroundColor: item?.disabled ? 'transparent' : item?.value === selected ?radioInnerCircleStyle?.backgroundColor : 'transparent' }}
98
- defaultRadioInnerCircleStyle={'radio-inner-circle'}
113
+ radioOuterCircleStyle={{
114
+ ...radioOuterCircleStyle,
115
+ cursor: item?.disabled ? 'not-allowed ' : ' pointer',
116
+ borderColor: item?.disabled && item?.disabledColor,
117
+ }}
118
+ defaultRadioOuterCircleStyle={'radio-outer-circle'}
99
119
  value={item.value}
100
- selected={selected}
101
- />
102
- </RadioOuterCircle>
103
- <OptionText
104
- defaultOptionColor={defaultOptionColor}
105
- optionStyle={{ ...optionStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', color: item?.disabled && item?.disabledColor }}
106
- theme={defaultStyles}
107
- defaultOptionStyle={'option-text'}
108
- selectedOptionTextColor={selectedOptionTextColor}
109
- // selected={item.value === selected}
110
- selected={!item?.disabled && item.value === selected}
111
-
112
- >
113
- {item.label}
114
- </OptionText>
115
- </WrapperDiv>
120
+ selected={!item?.disabled && selected}
121
+ >
122
+ <RadioInnerCircle
123
+ theme={defaultStyles}
124
+ width={width}
125
+ height={height}
126
+ selectedCircleColor={selectedCircleColor}
127
+ radioInnerCircleStyle={{
128
+ ...radioInnerCircleStyle,
129
+ cursor: item?.disabled ? 'not-allowed ' : ' pointer',
130
+ backgroundColor: item?.disabled
131
+ ? 'transparent'
132
+ : item?.value === selected
133
+ ? radioInnerCircleStyle?.backgroundColor
134
+ : 'transparent',
135
+ }}
136
+ defaultRadioInnerCircleStyle={'radio-inner-circle'}
137
+ value={item.value}
138
+ selected={selected}
139
+ />
140
+ </RadioOuterCircle>
141
+ <OptionText
142
+ defaultOptionColor={defaultOptionColor}
143
+ optionStyle={{
144
+ ...optionStyle,
145
+ cursor: item?.disabled ? 'not-allowed ' : ' pointer',
146
+ color: item?.disabled && item?.disabledColor,
147
+ }}
148
+ theme={defaultStyles}
149
+ defaultOptionStyle={'option-text'}
150
+ selectedOptionTextColor={selectedOptionTextColor}
151
+ // selected={item.value === selected}
152
+ selected={!item?.disabled && item.value === selected}
153
+ >
154
+ {item.label}
155
+ </OptionText>
156
+ </WrapperDiv>
157
+ );
116
158
  })}
117
159
  </ParentDiv>
118
160
  </div>
119
- )
120
- }
161
+ );
162
+ };
121
163
 
122
164
  RadioInput.propTypes = {
123
165
  /**
@@ -133,11 +175,11 @@ RadioInput.propTypes = {
133
175
  */
134
176
  inline: PropTypes.bool,
135
177
  /**
136
- * RadioButton Contents i.e:-
137
- [{ label: "First Radio Button", value: "first", disabled:true, disabledColor: '#ae3232' },
138
- { label: "Second Radio Button", value: "second" },
139
- { label: "Third Radio Button", value: "third" }]
140
- */
178
+ * RadioButton Contents i.e:-
179
+ [{ label: "First Radio Button", value: "first", disabled:true, disabledColor: '#ae3232' },
180
+ { label: "Second Radio Button", value: "second" },
181
+ { label: "Third Radio Button", value: "third" }]
182
+ */
141
183
  options: PropTypes.array,
142
184
  /**
143
185
  * RadioButton style object
@@ -183,7 +225,7 @@ RadioInput.propTypes = {
183
225
  * RadioButton selected option
184
226
  */
185
227
  selectedOptionTextColor: PropTypes.string,
186
- }
228
+ };
187
229
 
188
230
  RadioInput.defaultProps = {
189
231
  label: '',
@@ -201,5 +243,4 @@ RadioInput.defaultProps = {
201
243
  height: '14px',
202
244
  selectedCircleColor: `${defaultThemeColor.primary['primary-1']}`,
203
245
  selectedOptionTextColor: `${defaultThemeColor.neutral['neutral-1']}`,
204
- }
205
-
246
+ };