@qoretechnologies/reqore 0.20.7 → 0.21.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/__tests__/dropdown.test.tsx +1 -1
- package/dist/components/Breadcrumbs/index.d.ts +2 -2
- package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/item.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/item.js +3 -4
- package/dist/components/Breadcrumbs/item.js.map +1 -1
- package/dist/components/Button/index.d.ts +3 -7
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +28 -19
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts +3 -4
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +35 -12
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Comment/index.d.ts +2 -2
- package/dist/components/ControlGroup/index.d.ts +1 -0
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +3 -2
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Header/index.d.ts +2 -2
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Icon/index.d.ts +2 -2
- package/dist/components/Input/index.d.ts +2 -4
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +57 -28
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Menu/index.d.ts +3 -2
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +7 -4
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/item.d.ts +7 -6
- package/dist/components/Menu/item.d.ts.map +1 -1
- package/dist/components/Menu/item.js +9 -67
- package/dist/components/Menu/item.js.map +1 -1
- package/dist/components/Message/index.d.ts +2 -2
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Navbar/item.d.ts.map +1 -1
- package/dist/components/Navbar/item.js +12 -5
- package/dist/components/Navbar/item.js.map +1 -1
- package/dist/components/Notifications/notification.d.ts +4 -4
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Panel/index.d.ts +3 -3
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Paragraph/index.d.ts +2 -2
- package/dist/components/Paragraph/index.d.ts.map +1 -1
- package/dist/components/Sidebar/index.d.ts.map +1 -1
- package/dist/components/Sidebar/index.js +7 -6
- package/dist/components/Sidebar/index.js.map +1 -1
- package/dist/components/Table/index.d.ts +6 -6
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/row.d.ts +6 -6
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Tabs/index.d.ts +5 -5
- package/dist/components/Tabs/item.d.ts.map +1 -1
- package/dist/components/Tabs/item.js +2 -3
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tag/index.d.ts +5 -10
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +10 -7
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +4 -2
- package/dist/components/Textarea/index.d.ts.map +1 -1
- package/dist/components/Textarea/index.js +55 -15
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/constants/theme.d.ts +1 -1
- package/dist/containers/ReqoreProvider.d.ts +4 -4
- package/dist/helpers/colors.d.ts +2 -2
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/hooks/useCombinedRefs.d.ts +10 -1
- package/dist/hooks/useCombinedRefs.d.ts.map +1 -1
- package/dist/hooks/useCombinedRefs.js +18 -2
- package/dist/hooks/useCombinedRefs.js.map +1 -1
- package/dist/hooks/useTheme.d.ts +2 -2
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +5 -3
- package/dist/styles.js.map +1 -1
- package/dist/types/global.d.ts +69 -0
- package/dist/types/global.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Breadcrumbs/index.tsx +2 -2
- package/src/components/Breadcrumbs/item.tsx +4 -5
- package/src/components/Button/index.tsx +77 -49
- package/src/components/Checkbox/index.tsx +27 -17
- package/src/components/Comment/index.tsx +2 -2
- package/src/components/ControlGroup/index.tsx +3 -3
- package/src/components/Header/index.tsx +2 -2
- package/src/components/Icon/index.tsx +2 -2
- package/src/components/Input/index.tsx +58 -44
- package/src/components/Menu/index.tsx +14 -3
- package/src/components/Menu/item.tsx +42 -132
- package/src/components/Message/index.tsx +2 -2
- package/src/components/Navbar/item.tsx +20 -3
- package/src/components/Notifications/notification.tsx +4 -4
- package/src/components/Panel/index.tsx +3 -3
- package/src/components/Paragraph/index.tsx +2 -2
- package/src/components/Sidebar/index.tsx +11 -0
- package/src/components/Table/index.tsx +8 -8
- package/src/components/Table/row.tsx +11 -11
- package/src/components/Tabs/index.tsx +5 -5
- package/src/components/Tabs/item.tsx +3 -4
- package/src/components/Tag/index.tsx +18 -21
- package/src/components/Textarea/index.tsx +76 -28
- package/src/constants/theme.ts +1 -1
- package/src/containers/ReqoreProvider.tsx +4 -4
- package/src/helpers/colors.ts +2 -2
- package/src/hooks/useCombinedRefs.ts +9 -2
- package/src/hooks/useTheme.ts +2 -2
- package/src/stories/Button/Button.stories.tsx +4 -1
- package/src/stories/Checkbox/Checkbox.stories.tsx +5 -4
- package/src/stories/Input/Input.stories.tsx +39 -6
- package/src/stories/Menu/Menu.stories.tsx +14 -2
- package/src/stories/RadioGroup/RadioGroup.stories.tsx +10 -0
- package/src/stories/Tag/Tag.stories.tsx +7 -1
- package/src/stories/TextArea/TextArea.stories.tsx +83 -13
- package/src/styles.ts +11 -2
- package/src/types/global.ts +74 -0
- package/tests.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Placement } from '@popperjs/core';
|
|
2
1
|
import { rgba } from 'polished';
|
|
3
|
-
import React, { forwardRef
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
4
3
|
import styled, { css } from 'styled-components';
|
|
5
4
|
import {
|
|
6
5
|
PADDING_FROM_SIZE,
|
|
@@ -9,26 +8,38 @@ import {
|
|
|
9
8
|
TEXT_FROM_SIZE,
|
|
10
9
|
TSizes,
|
|
11
10
|
} from '../../constants/sizes';
|
|
12
|
-
import { IReqoreCustomTheme,
|
|
11
|
+
import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
|
|
13
12
|
import { changeLightness, getReadableColor, getReadableColorFrom } from '../../helpers/colors';
|
|
14
13
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
15
14
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
16
15
|
import { useTooltip } from '../../hooks/useTooltip';
|
|
17
|
-
import {
|
|
18
|
-
|
|
16
|
+
import {
|
|
17
|
+
ActiveIconScale,
|
|
18
|
+
DisabledElement,
|
|
19
|
+
InactiveIconScale,
|
|
20
|
+
ReadOnlyElement,
|
|
21
|
+
ScaleIconOnHover,
|
|
22
|
+
} from '../../styles';
|
|
23
|
+
import {
|
|
24
|
+
IReqoreDisabled,
|
|
25
|
+
IReqoreIntent,
|
|
26
|
+
IReqoreReadOnly,
|
|
27
|
+
TReqoreTooltipProp,
|
|
28
|
+
} from '../../types/global';
|
|
19
29
|
import { IReqoreIconName } from '../../types/icons';
|
|
20
30
|
import ReqoreIcon from '../Icon';
|
|
21
31
|
|
|
22
|
-
export interface IReqoreButtonProps
|
|
32
|
+
export interface IReqoreButtonProps
|
|
33
|
+
extends React.HTMLAttributes<HTMLButtonElement>,
|
|
34
|
+
IReqoreDisabled,
|
|
35
|
+
IReqoreIntent,
|
|
36
|
+
IReqoreReadOnly {
|
|
23
37
|
icon?: IReqoreIconName;
|
|
24
38
|
size?: TSizes;
|
|
25
39
|
minimal?: boolean;
|
|
26
|
-
disabled?: boolean;
|
|
27
40
|
tooltip?: TReqoreTooltipProp;
|
|
28
|
-
tooltipPlacement?: Placement;
|
|
29
41
|
fluid?: boolean;
|
|
30
42
|
fixed?: boolean;
|
|
31
|
-
intent?: IReqoreIntent;
|
|
32
43
|
active?: boolean;
|
|
33
44
|
flat?: boolean;
|
|
34
45
|
rightIcon?: IReqoreIconName;
|
|
@@ -51,6 +62,7 @@ const getButtonMainColor = (theme: IReqoreTheme, color?: string) => {
|
|
|
51
62
|
export const StyledAnimatedTextWrapper = styled.span`
|
|
52
63
|
overflow: hidden;
|
|
53
64
|
position: relative;
|
|
65
|
+
padding: 4px 0;
|
|
54
66
|
`;
|
|
55
67
|
|
|
56
68
|
export const StyledActiveContent = styled.span`
|
|
@@ -99,6 +111,7 @@ export const StyledInvisibleContent = styled.span`
|
|
|
99
111
|
|
|
100
112
|
export const StyledButton = styled.button<IReqoreButtonStyle>`
|
|
101
113
|
display: flex;
|
|
114
|
+
text-align: left;
|
|
102
115
|
align-items: center;
|
|
103
116
|
margin: 0;
|
|
104
117
|
font-weight: 600;
|
|
@@ -109,7 +122,14 @@ export const StyledButton = styled.button<IReqoreButtonStyle>`
|
|
|
109
122
|
padding: 0 ${({ size }) => PADDING_FROM_SIZE[size]}px;
|
|
110
123
|
font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
|
|
111
124
|
|
|
112
|
-
height: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
125
|
+
min-height: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
126
|
+
|
|
127
|
+
${({ wrap }) =>
|
|
128
|
+
wrap &&
|
|
129
|
+
css`
|
|
130
|
+
max-height: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
131
|
+
`}
|
|
132
|
+
|
|
113
133
|
min-width: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
114
134
|
|
|
115
135
|
flex: ${({ fluid, fixed }) => (fixed ? '0 auto' : fluid ? '1 auto' : '0 0 auto')};
|
|
@@ -134,38 +154,47 @@ export const StyledButton = styled.button<IReqoreButtonStyle>`
|
|
|
134
154
|
: getReadableColorFrom(color, true)
|
|
135
155
|
: getReadableColor(theme, undefined, undefined, true)};
|
|
136
156
|
|
|
137
|
-
${
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
157
|
+
${InactiveIconScale}
|
|
158
|
+
|
|
159
|
+
${({ readOnly }) =>
|
|
160
|
+
!readOnly
|
|
161
|
+
? css`
|
|
162
|
+
&:not(:disabled) {
|
|
163
|
+
${ScaleIconOnHover}
|
|
164
|
+
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
transition: all 0.2s ease-out;
|
|
167
|
+
|
|
168
|
+
&:active {
|
|
169
|
+
transform: scale(0.95);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&:hover,
|
|
173
|
+
&:focus {
|
|
174
|
+
background-color: ${({ theme, color }: IReqoreButtonStyle) =>
|
|
175
|
+
changeLightness(getButtonMainColor(theme, color), 0.05)};
|
|
176
|
+
color: ${({ theme, color }) =>
|
|
177
|
+
getReadableColor({ main: getButtonMainColor(theme, color) }, undefined, undefined)};
|
|
178
|
+
border-color: ${({ minimal, theme, color }) =>
|
|
179
|
+
minimal ? undefined : changeLightness(getButtonMainColor(theme, color), 0.1)};
|
|
180
|
+
|
|
181
|
+
${StyledActiveContent} {
|
|
182
|
+
transform: translateY(0px);
|
|
183
|
+
filter: blur(0);
|
|
184
|
+
opacity: 1;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
${StyledInActiveContent} {
|
|
188
|
+
transform: translateY(150%);
|
|
189
|
+
filter: blur(10px);
|
|
190
|
+
opacity: 0;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`
|
|
195
|
+
: css`
|
|
196
|
+
${ReadOnlyElement};
|
|
197
|
+
`}
|
|
169
198
|
|
|
170
199
|
${({ active, minimal, theme, color }: IReqoreButtonStyle) =>
|
|
171
200
|
active &&
|
|
@@ -180,9 +209,7 @@ export const StyledButton = styled.button<IReqoreButtonStyle>`
|
|
|
180
209
|
`}
|
|
181
210
|
|
|
182
211
|
&:disabled {
|
|
183
|
-
|
|
184
|
-
pointer-events: none;
|
|
185
|
-
cursor: not-allowed;
|
|
212
|
+
${DisabledElement};
|
|
186
213
|
}
|
|
187
214
|
|
|
188
215
|
&:focus,
|
|
@@ -213,16 +240,16 @@ const ReqoreButton = forwardRef(
|
|
|
213
240
|
rightIcon,
|
|
214
241
|
customTheme,
|
|
215
242
|
wrap = true,
|
|
243
|
+
readOnly,
|
|
216
244
|
...rest
|
|
217
245
|
}: IReqoreButtonProps,
|
|
218
246
|
ref
|
|
219
247
|
) => {
|
|
220
|
-
const
|
|
221
|
-
const combinedRef = useCombinedRefs(innerRef, ref);
|
|
248
|
+
const { targetRef } = useCombinedRefs(ref);
|
|
222
249
|
const theme: IReqoreTheme = useReqoreTheme('main', customTheme, intent);
|
|
223
250
|
|
|
224
251
|
/* A custom hook that is used to add a tooltip to the button. */
|
|
225
|
-
useTooltip(
|
|
252
|
+
useTooltip(targetRef.current, tooltip);
|
|
226
253
|
|
|
227
254
|
// If color or intent was specified, set the color
|
|
228
255
|
const customColor = theme.main;
|
|
@@ -231,7 +258,7 @@ const ReqoreButton = forwardRef(
|
|
|
231
258
|
<StyledButton
|
|
232
259
|
{...rest}
|
|
233
260
|
theme={theme}
|
|
234
|
-
ref={
|
|
261
|
+
ref={targetRef}
|
|
235
262
|
fluid={fluid}
|
|
236
263
|
fixed={fixed}
|
|
237
264
|
minimal={minimal}
|
|
@@ -239,6 +266,7 @@ const ReqoreButton = forwardRef(
|
|
|
239
266
|
color={customColor}
|
|
240
267
|
flat={flat}
|
|
241
268
|
active={active}
|
|
269
|
+
readOnly={readOnly}
|
|
242
270
|
className={`${className || ''} reqore-control reqore-button`}
|
|
243
271
|
>
|
|
244
272
|
{icon && (
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { rgba } from 'polished';
|
|
2
|
-
import React, { forwardRef
|
|
3
|
-
import styled from 'styled-components';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
4
4
|
import { SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
5
5
|
import { IReqoreTheme } from '../../constants/theme';
|
|
6
6
|
import { getReadableColor } from '../../helpers/colors';
|
|
7
7
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
8
|
+
import { useTooltip } from '../../hooks/useTooltip';
|
|
9
|
+
import { DisabledElement, ReadOnlyElement } from '../../styles';
|
|
10
|
+
import { IReqoreDisabled, IReqoreReadOnly, TReqoreTooltipProp } from '../../types/global';
|
|
10
11
|
import { IReqoreIconName } from '../../types/icons';
|
|
11
12
|
import ReqoreIcon from '../Icon';
|
|
12
13
|
|
|
13
|
-
export interface IReqoreCheckboxProps
|
|
14
|
+
export interface IReqoreCheckboxProps
|
|
15
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
16
|
+
IReqoreDisabled,
|
|
17
|
+
IReqoreReadOnly {
|
|
14
18
|
label?: string;
|
|
15
19
|
labelDetail?: any;
|
|
16
20
|
labelDetailPosition?: 'left' | 'right';
|
|
17
21
|
size?: TSizes;
|
|
18
22
|
checked?: boolean;
|
|
19
|
-
disabled?: boolean;
|
|
20
23
|
labelPosition?: 'right' | 'left';
|
|
21
24
|
fluid?: boolean;
|
|
22
25
|
fixed?: boolean;
|
|
23
|
-
tooltip?:
|
|
26
|
+
tooltip?: TReqoreTooltipProp;
|
|
24
27
|
asSwitch?: boolean;
|
|
25
28
|
uncheckedIcon?: IReqoreIconName;
|
|
26
29
|
checkedIcon?: IReqoreIconName;
|
|
@@ -68,7 +71,7 @@ const StyledSwitch = styled.div<IReqoreCheckboxStyle>`
|
|
|
68
71
|
`;
|
|
69
72
|
|
|
70
73
|
const StyledCheckbox = styled.div<IReqoreCheckboxStyle>`
|
|
71
|
-
display: flex;
|
|
74
|
+
display: inline-flex;
|
|
72
75
|
align-items: center;
|
|
73
76
|
cursor: pointer;
|
|
74
77
|
padding: 0px;
|
|
@@ -79,8 +82,17 @@ const StyledCheckbox = styled.div<IReqoreCheckboxStyle>`
|
|
|
79
82
|
|
|
80
83
|
flex: ${({ fluid, fixed }) => (fixed ? '0 auto' : fluid ? '1' : '0 0 auto')};
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
${({ disabled }) =>
|
|
86
|
+
disabled &&
|
|
87
|
+
css`
|
|
88
|
+
${DisabledElement};
|
|
89
|
+
`}
|
|
90
|
+
|
|
91
|
+
${({ readOnly }) =>
|
|
92
|
+
readOnly &&
|
|
93
|
+
css`
|
|
94
|
+
${ReadOnlyElement};
|
|
95
|
+
`}
|
|
84
96
|
|
|
85
97
|
color: ${({ theme, checked }) => getReadableColor(theme, undefined, undefined, !checked)};
|
|
86
98
|
|
|
@@ -109,25 +121,23 @@ const Checkbox = forwardRef(
|
|
|
109
121
|
asSwitch,
|
|
110
122
|
uncheckedIcon = 'CheckboxBlankCircleLine',
|
|
111
123
|
checkedIcon = 'CheckboxCircleFill',
|
|
124
|
+
readOnly,
|
|
112
125
|
...rest
|
|
113
126
|
}: IReqoreCheckboxProps,
|
|
114
127
|
ref
|
|
115
128
|
) => {
|
|
116
|
-
const
|
|
117
|
-
const combinedRef = useCombinedRefs(innerRef, ref);
|
|
129
|
+
const { targetRef } = useCombinedRefs(ref);
|
|
118
130
|
|
|
119
|
-
|
|
120
|
-
targetElement: combinedRef.current,
|
|
121
|
-
...tooltip,
|
|
122
|
-
});
|
|
131
|
+
useTooltip(targetRef.current, tooltip);
|
|
123
132
|
|
|
124
133
|
return (
|
|
125
134
|
<StyledCheckbox
|
|
126
135
|
{...rest}
|
|
127
|
-
ref={
|
|
136
|
+
ref={targetRef}
|
|
128
137
|
size={size}
|
|
129
138
|
disabled={disabled}
|
|
130
139
|
checked={checked}
|
|
140
|
+
readOnly={readOnly}
|
|
131
141
|
className={`${className || ''} reqore-checkbox reqore-control`}
|
|
132
142
|
>
|
|
133
143
|
{label && labelPosition === 'left' ? (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { ReqoreButton, ReqoreColumn, ReqoreControlGroup, ReqoreDropdown } from '../..';
|
|
4
|
-
import {
|
|
4
|
+
import { TReqoreIntent } from '../../constants/theme';
|
|
5
5
|
import { IReqoreIconName } from '../../types/icons';
|
|
6
6
|
import { ReqoreColumns } from '../Columns';
|
|
7
7
|
import { ReqoreH3 } from '../Header';
|
|
@@ -14,7 +14,7 @@ export interface IReqoreCommentProps {
|
|
|
14
14
|
image?: string;
|
|
15
15
|
title?: string;
|
|
16
16
|
children: any;
|
|
17
|
-
intent?:
|
|
17
|
+
intent?: TReqoreIntent;
|
|
18
18
|
rounded?: boolean;
|
|
19
19
|
flat?: boolean;
|
|
20
20
|
detail?: string;
|
|
@@ -16,7 +16,7 @@ export interface IReqoreControlGroupStyle extends IReqoreControlGroupProps {
|
|
|
16
16
|
theme: IReqoreTheme;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
|
|
20
20
|
display: flex;
|
|
21
21
|
flex: 0 auto;
|
|
22
22
|
width: ${({ fluid }) => (fluid ? '100%' : undefined)};
|
|
@@ -59,7 +59,7 @@ const ReqoreControlGroup = ({
|
|
|
59
59
|
rounded = true,
|
|
60
60
|
...rest
|
|
61
61
|
}: IReqoreControlGroupProps) => (
|
|
62
|
-
<
|
|
62
|
+
<StyledReqoreControlGroup
|
|
63
63
|
{...rest}
|
|
64
64
|
size={size}
|
|
65
65
|
rounded={rounded}
|
|
@@ -75,7 +75,7 @@ const ReqoreControlGroup = ({
|
|
|
75
75
|
})
|
|
76
76
|
: null
|
|
77
77
|
)}
|
|
78
|
-
</
|
|
78
|
+
</StyledReqoreControlGroup>
|
|
79
79
|
);
|
|
80
80
|
|
|
81
81
|
export default ReqoreControlGroup;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
import {
|
|
2
|
+
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
3
3
|
import { getReadableColor } from '../../helpers/colors';
|
|
4
4
|
|
|
5
5
|
export interface IReqoreHeaderStyle extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
6
6
|
theme: IReqoreTheme;
|
|
7
|
-
intent?:
|
|
7
|
+
intent?: TReqoreIntent;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const style = ({ theme, intent }: IReqoreHeaderStyle) => css`
|
|
@@ -4,7 +4,7 @@ import { IconBaseProps, IconType } from 'react-icons/lib';
|
|
|
4
4
|
import * as RemixIcons from 'react-icons/ri';
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
6
|
import { ReqoreThemeContext } from '../..';
|
|
7
|
-
import {
|
|
7
|
+
import { TReqoreIntent } from '../../constants/theme';
|
|
8
8
|
import { IReqoreIconName } from '../../types/icons';
|
|
9
9
|
|
|
10
10
|
export interface IReqoreIconProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
@@ -12,7 +12,7 @@ export interface IReqoreIconProps extends React.HTMLAttributes<HTMLSpanElement>
|
|
|
12
12
|
color?: string;
|
|
13
13
|
size?: string;
|
|
14
14
|
iconProps?: IconBaseProps;
|
|
15
|
-
intent?:
|
|
15
|
+
intent?: TReqoreIntent;
|
|
16
16
|
margin?: 'right' | 'left' | 'both';
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import styled from 'styled-components';
|
|
1
|
+
import { rgba } from 'polished';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import styled, { css } from 'styled-components';
|
|
5
4
|
import { RADIUS_FROM_SIZE, SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
6
5
|
import { IReqoreTheme } from '../../constants/theme';
|
|
7
6
|
import { changeLightness, getReadableColor } from '../../helpers/colors';
|
|
8
7
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
9
|
-
import
|
|
8
|
+
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
9
|
+
import { useTooltip } from '../../hooks/useTooltip';
|
|
10
|
+
import { DisabledElement, ReadOnlyElement } from '../../styles';
|
|
11
|
+
import {
|
|
12
|
+
IReqoreDisabled,
|
|
13
|
+
IReqoreIntent,
|
|
14
|
+
IReqoreReadOnly,
|
|
15
|
+
IWithReqoreCustomTheme,
|
|
16
|
+
} from '../../types/global';
|
|
10
17
|
import { IReqoreIconName } from '../../types/icons';
|
|
11
18
|
import ReqoreIcon from '../Icon';
|
|
12
19
|
import ReqoreInputClearButton from '../InputClearButton';
|
|
13
20
|
|
|
14
|
-
export interface IReqoreInputProps
|
|
21
|
+
export interface IReqoreInputProps
|
|
22
|
+
extends React.HTMLAttributes<HTMLInputElement>,
|
|
23
|
+
IReqoreDisabled,
|
|
24
|
+
IReqoreReadOnly,
|
|
25
|
+
IReqoreIntent,
|
|
26
|
+
IWithReqoreCustomTheme {
|
|
15
27
|
autoFocus?: boolean;
|
|
16
|
-
disabled?: boolean;
|
|
17
28
|
tooltip?: string;
|
|
18
|
-
tooltipPlacement?: Placement;
|
|
19
29
|
width?: number;
|
|
20
30
|
size?: TSizes;
|
|
21
31
|
minimal?: boolean;
|
|
@@ -45,19 +55,6 @@ export const StyledInputWrapper = styled.div<IReqoreInputStyle>`
|
|
|
45
55
|
overflow: hidden;
|
|
46
56
|
border-radius: ${({ minimal, rounded, _size }) =>
|
|
47
57
|
minimal || !rounded ? 0 : RADIUS_FROM_SIZE[_size]}px;
|
|
48
|
-
border: ${({ minimal, theme, flat }) =>
|
|
49
|
-
!minimal && !flat ? `1px solid ${rgba(getReadableColor(theme), 0.2)}` : 0};
|
|
50
|
-
border-bottom: ${({ minimal, theme, flat }) =>
|
|
51
|
-
minimal && !flat ? `0.5px solid ${rgba(getReadableColor(theme), 0.2)}` : undefined};
|
|
52
|
-
|
|
53
|
-
transition: all 0.2s ease-out;
|
|
54
|
-
|
|
55
|
-
&:active,
|
|
56
|
-
&:focus,
|
|
57
|
-
&:hover {
|
|
58
|
-
outline: none;
|
|
59
|
-
border-color: ${({ theme }) => rgba(getReadableColor(theme), 0.3)};
|
|
60
|
-
}
|
|
61
58
|
`;
|
|
62
59
|
|
|
63
60
|
const StyledIconWrapper = styled.div<IReqoreInputStyle>`
|
|
@@ -78,24 +75,37 @@ export const StyledInput = styled.input<IReqoreInputStyle>`
|
|
|
78
75
|
padding-right: ${({ clearable, _size }) => (clearable ? SIZE_TO_PX[_size] : 7)}px;
|
|
79
76
|
padding-left: ${({ hasIcon, _size }) => (hasIcon ? SIZE_TO_PX[_size] : 7)}px;
|
|
80
77
|
font-size: ${({ _size }) => TEXT_FROM_SIZE[_size]}px;
|
|
81
|
-
border:
|
|
78
|
+
border-radius: ${({ minimal, rounded, _size }) =>
|
|
79
|
+
minimal || !rounded ? 0 : RADIUS_FROM_SIZE[_size]}px;
|
|
80
|
+
border: ${({ minimal, theme, flat }) =>
|
|
81
|
+
!minimal && !flat ? `1px solid ${changeLightness(theme.main, 0.05)}` : 0};
|
|
82
|
+
border-bottom: ${({ minimal, theme, flat }) =>
|
|
83
|
+
minimal && !flat ? `0.5px solid ${changeLightness(theme.main, 0.05)}` : undefined};
|
|
84
|
+
|
|
85
|
+
transition: all 0.2s ease-out;
|
|
86
|
+
|
|
87
|
+
${({ disabled, readOnly }) =>
|
|
88
|
+
!disabled && !readOnly
|
|
89
|
+
? css`
|
|
90
|
+
&:active,
|
|
91
|
+
&:focus,
|
|
92
|
+
&:hover {
|
|
93
|
+
outline: none;
|
|
94
|
+
border-color: ${({ theme }) => changeLightness(theme.main, 0.1)};
|
|
95
|
+
}
|
|
96
|
+
`
|
|
97
|
+
: undefined}
|
|
82
98
|
|
|
83
99
|
background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
|
|
84
|
-
minimal ? 'transparent' :
|
|
100
|
+
minimal ? 'transparent' : rgba(theme.main, 0.3)};
|
|
85
101
|
color: ${({ theme }: IReqoreInputStyle) => getReadableColor(theme)};
|
|
86
102
|
|
|
87
103
|
transition: all 0.2s ease-out;
|
|
88
104
|
|
|
89
|
-
&:active,
|
|
90
|
-
&:focus,
|
|
91
|
-
&:hover {
|
|
92
|
-
outline: none;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
105
|
&:active,
|
|
96
106
|
&:focus {
|
|
97
107
|
background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
|
|
98
|
-
minimal ? 'transparent' :
|
|
108
|
+
minimal ? 'transparent' : rgba(theme.main, 0.5)};
|
|
99
109
|
}
|
|
100
110
|
|
|
101
111
|
&::placeholder {
|
|
@@ -109,9 +119,10 @@ export const StyledInput = styled.input<IReqoreInputStyle>`
|
|
|
109
119
|
}
|
|
110
120
|
}
|
|
111
121
|
|
|
122
|
+
${({ readOnly }) => readOnly && ReadOnlyElement};
|
|
123
|
+
|
|
112
124
|
&:disabled {
|
|
113
|
-
|
|
114
|
-
opacity: 0.3;
|
|
125
|
+
${DisabledElement};
|
|
115
126
|
}
|
|
116
127
|
`;
|
|
117
128
|
|
|
@@ -119,7 +130,6 @@ const ReqoreInput = forwardRef(
|
|
|
119
130
|
(
|
|
120
131
|
{
|
|
121
132
|
tooltip,
|
|
122
|
-
tooltipPlacement,
|
|
123
133
|
width,
|
|
124
134
|
size = 'normal',
|
|
125
135
|
fluid,
|
|
@@ -131,20 +141,17 @@ const ReqoreInput = forwardRef(
|
|
|
131
141
|
rounded = true,
|
|
132
142
|
minimal,
|
|
133
143
|
children,
|
|
144
|
+
readOnly,
|
|
145
|
+
customTheme,
|
|
146
|
+
intent,
|
|
134
147
|
...rest
|
|
135
148
|
}: IReqoreInputProps,
|
|
136
149
|
ref
|
|
137
150
|
) => {
|
|
138
|
-
const
|
|
139
|
-
const
|
|
151
|
+
const { targetRef } = useCombinedRefs(ref);
|
|
152
|
+
const theme = useReqoreTheme('main', customTheme, intent);
|
|
140
153
|
|
|
141
|
-
|
|
142
|
-
targetElement: combinedRef.current,
|
|
143
|
-
content: tooltip,
|
|
144
|
-
handler: 'hover',
|
|
145
|
-
placement: tooltipPlacement,
|
|
146
|
-
show: !!tooltip,
|
|
147
|
-
});
|
|
154
|
+
useTooltip(targetRef.current, tooltip);
|
|
148
155
|
|
|
149
156
|
return (
|
|
150
157
|
<StyledInputWrapper
|
|
@@ -153,10 +160,13 @@ const ReqoreInput = forwardRef(
|
|
|
153
160
|
fixed={fixed}
|
|
154
161
|
width={width}
|
|
155
162
|
flat={flat}
|
|
163
|
+
theme={theme}
|
|
156
164
|
rounded={rounded}
|
|
157
165
|
minimal={minimal}
|
|
158
166
|
_size={size}
|
|
159
|
-
ref={
|
|
167
|
+
ref={targetRef}
|
|
168
|
+
readOnly={readOnly}
|
|
169
|
+
disabled={rest.disabled}
|
|
160
170
|
>
|
|
161
171
|
{icon && (
|
|
162
172
|
<StyledIconWrapper _size={size}>
|
|
@@ -165,14 +175,18 @@ const ReqoreInput = forwardRef(
|
|
|
165
175
|
)}
|
|
166
176
|
<StyledInput
|
|
167
177
|
{...rest}
|
|
178
|
+
theme={theme}
|
|
168
179
|
_size={size}
|
|
169
180
|
minimal={minimal}
|
|
181
|
+
flat={flat}
|
|
182
|
+
rounded={rounded}
|
|
170
183
|
hasIcon={!!icon}
|
|
171
184
|
clearable={!rest?.disabled && !!(onClearClick && rest?.onChange)}
|
|
172
185
|
className={`${className || ''} reqore-control reqore-input`}
|
|
186
|
+
readOnly={readOnly}
|
|
173
187
|
/>
|
|
174
188
|
<ReqoreInputClearButton
|
|
175
|
-
enabled={!rest?.disabled && !!(onClearClick && rest?.onChange)}
|
|
189
|
+
enabled={!readOnly && !rest?.disabled && !!(onClearClick && rest?.onChange)}
|
|
176
190
|
onClick={onClearClick}
|
|
177
191
|
size={size}
|
|
178
192
|
show={rest?.value && rest.value !== '' ? true : false}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
|
-
import { IReqoreCustomTheme,
|
|
3
|
+
import { IReqoreCustomTheme, IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
4
4
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
5
5
|
import { changeLightness } from '../../helpers/colors';
|
|
6
6
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
7
7
|
import { IReqoreComponent } from '../../types/global';
|
|
8
|
+
import { StyledReqoreControlGroup } from '../ControlGroup';
|
|
8
9
|
|
|
9
10
|
export interface IReqoreMenuProps extends IReqoreComponent, React.HTMLAttributes<HTMLDivElement> {
|
|
10
11
|
children: any;
|
|
@@ -12,7 +13,8 @@ export interface IReqoreMenuProps extends IReqoreComponent, React.HTMLAttributes
|
|
|
12
13
|
width?: string;
|
|
13
14
|
maxHeight?: string;
|
|
14
15
|
customTheme?: IReqoreCustomTheme;
|
|
15
|
-
intent?:
|
|
16
|
+
intent?: TReqoreIntent;
|
|
17
|
+
wrapText?: boolean;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export interface IReqoreMenuStyle extends IReqoreMenuProps {
|
|
@@ -37,10 +39,17 @@ const StyledReqoreMenu = styled.div<IReqoreMenuStyle>`
|
|
|
37
39
|
)};
|
|
38
40
|
padding-${position === 'left' ? 'right' : 'left'}: 10px;
|
|
39
41
|
`}
|
|
42
|
+
|
|
43
|
+
${StyledReqoreControlGroup}:not(:last-child) {
|
|
44
|
+
margin-bottom: 5px;
|
|
45
|
+
}
|
|
40
46
|
`;
|
|
41
47
|
|
|
42
48
|
const ReqoreMenu: React.FC<IReqoreMenuProps> = forwardRef(
|
|
43
|
-
(
|
|
49
|
+
(
|
|
50
|
+
{ children, position, _insidePopover, _popoverId, customTheme, intent, wrapText, ...rest },
|
|
51
|
+
ref: any
|
|
52
|
+
) => {
|
|
44
53
|
const theme = useReqoreTheme('main', customTheme, intent);
|
|
45
54
|
|
|
46
55
|
return (
|
|
@@ -52,6 +61,8 @@ const ReqoreMenu: React.FC<IReqoreMenuProps> = forwardRef(
|
|
|
52
61
|
React.cloneElement(child, {
|
|
53
62
|
_insidePopover,
|
|
54
63
|
_popoverId,
|
|
64
|
+
customTheme: theme,
|
|
65
|
+
wrapText,
|
|
55
66
|
})
|
|
56
67
|
: null
|
|
57
68
|
)}
|