@qoretechnologies/reqore 0.30.6 → 0.30.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.
- package/LICENSE +1 -1
- package/README.md +2 -44
- package/__tests__/collection.test.tsx +1 -1
- package/__tests__/{control_group.text.tsx → control_group.test.tsx} +4 -2
- package/__tests__/modal.test.tsx +74 -2
- package/__tests__/panel.test.tsx +96 -24
- package/__tests__/popover.test.tsx +24 -2
- package/__tests__/tabs.test.tsx +75 -0
- package/dist/components/Button/index.d.ts +7 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +30 -20
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +6 -3
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Collection/index.d.ts +7 -2
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +57 -53
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Collection/item.d.ts +5 -5
- package/dist/components/Collection/item.d.ts.map +1 -1
- package/dist/components/Collection/item.js +15 -4
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/Columns/column.d.ts.map +1 -1
- package/dist/components/Columns/column.js +1 -1
- package/dist/components/Columns/column.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts +21 -4
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +250 -55
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts +3 -3
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +27 -16
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +1 -0
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +2 -2
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts +3 -3
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Effect/index.d.ts +10 -10
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js +7 -6
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts +5 -6
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +14 -7
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +10 -4
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +12 -10
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Message/index.d.ts +2 -0
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +2 -2
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +2 -2
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.js +10 -10
- package/dist/components/MultiSelect/index.js.map +1 -1
- package/dist/components/Notifications/index.d.ts +1 -1
- package/dist/components/Notifications/index.d.ts.map +1 -1
- package/dist/components/Notifications/notification.d.ts +1 -1
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Panel/index.d.ts +13 -6
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +78 -44
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Popover/index.d.ts +1 -2
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +2 -2
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Spacer/index.d.ts +2 -0
- package/dist/components/Spacer/index.d.ts.map +1 -1
- package/dist/components/Spacer/index.js +29 -7
- package/dist/components/Spacer/index.js.map +1 -1
- package/dist/components/Table/header.js +2 -2
- package/dist/components/Table/header.js.map +1 -1
- package/dist/components/Table/headerCell.js +2 -2
- package/dist/components/Table/headerCell.js.map +1 -1
- package/dist/components/Table/helpers.d.ts +3 -2
- package/dist/components/Table/helpers.d.ts.map +1 -1
- package/dist/components/Table/helpers.js +6 -3
- package/dist/components/Table/helpers.js.map +1 -1
- package/dist/components/Table/index.d.ts +4 -3
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/row.d.ts +0 -5
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Table/row.js +3 -7
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Tabs/content.d.ts +3 -1
- package/dist/components/Tabs/content.d.ts.map +1 -1
- package/dist/components/Tabs/content.js +8 -3
- package/dist/components/Tabs/content.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +4 -1
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js +12 -4
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/item.d.ts +1 -0
- package/dist/components/Tabs/item.d.ts.map +1 -1
- package/dist/components/Tabs/item.js +7 -7
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tabs/list.d.ts +1 -1
- package/dist/components/Tabs/list.d.ts.map +1 -1
- package/dist/components/Tabs/list.js +7 -6
- package/dist/components/Tabs/list.js.map +1 -1
- package/dist/components/Tag/group.d.ts +2 -2
- package/dist/components/Tag/group.d.ts.map +1 -1
- package/dist/components/Tag/group.js +7 -8
- package/dist/components/Tag/group.js.map +1 -1
- package/dist/components/Tag/index.d.ts +6 -2
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +24 -12
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Tree/index.js +1 -1
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/constants/animations.js +1 -1
- package/dist/constants/sizes.d.ts +2 -2
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +10 -10
- package/dist/constants/sizes.js.map +1 -1
- package/dist/constants/theme.d.ts +1 -1
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.js +10 -8
- package/dist/containers/PopoverProvider.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +4 -2
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +7 -0
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/context/ReqoreContext.d.ts +2 -0
- package/dist/context/ReqoreContext.d.ts.map +1 -1
- package/dist/context/ReqoreContext.js.map +1 -1
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +6 -2
- package/dist/helpers/colors.js.map +1 -1
- package/dist/helpers/utils.d.ts +3 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +17 -2
- package/dist/helpers/utils.js.map +1 -1
- package/dist/hooks/useLatestZIndex.js +2 -2
- package/dist/hooks/useLatestZIndex.js.map +1 -1
- package/dist/hooks/usePopover.d.ts +1 -0
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +8 -6
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/styles.d.ts +1 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +6 -5
- package/dist/styles.js.map +1 -1
- package/dist/types/global.d.ts +27 -1
- package/dist/types/global.d.ts.map +1 -1
- package/dist/types/icons.d.ts +1 -1
- package/dist/types/icons.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +79 -34
- package/src/components/Checkbox/index.tsx +3 -2
- package/src/components/Collection/index.tsx +93 -60
- package/src/components/Collection/item.tsx +29 -9
- package/src/components/Columns/column.tsx +1 -0
- package/src/components/ControlGroup/index.tsx +449 -104
- package/src/components/Drawer/index.tsx +28 -27
- package/src/components/Dropdown/index.tsx +3 -1
- package/src/components/Effect/index.tsx +22 -14
- package/src/components/Icon/index.tsx +81 -62
- package/src/components/Input/index.tsx +8 -3
- package/src/components/InternalPopover/index.tsx +131 -126
- package/src/components/Menu/index.tsx +7 -1
- package/src/components/Message/index.tsx +9 -1
- package/src/components/MultiSelect/index.tsx +180 -188
- package/src/components/Panel/index.tsx +227 -100
- package/src/components/Popover/index.tsx +1 -3
- package/src/components/Spacer/index.tsx +63 -14
- package/src/components/Table/header.tsx +2 -2
- package/src/components/Table/headerCell.tsx +2 -2
- package/src/components/Table/helpers.ts +12 -6
- package/src/components/Table/index.tsx +1 -0
- package/src/components/Table/row.tsx +2 -7
- package/src/components/Tabs/content.tsx +11 -3
- package/src/components/Tabs/index.tsx +14 -3
- package/src/components/Tabs/item.tsx +28 -5
- package/src/components/Tabs/list.tsx +7 -3
- package/src/components/Tag/group.tsx +6 -12
- package/src/components/Tag/index.tsx +69 -35
- package/src/components/Tree/index.tsx +1 -1
- package/src/constants/animations.ts +1 -1
- package/src/constants/sizes.ts +10 -10
- package/src/containers/PopoverProvider.tsx +11 -8
- package/src/containers/ReqoreProvider.tsx +40 -35
- package/src/containers/UIProvider.tsx +7 -0
- package/src/context/ReqoreContext.tsx +2 -0
- package/src/helpers/colors.ts +8 -2
- package/src/helpers/utils.ts +18 -0
- package/src/hooks/useLatestZIndex.ts +2 -2
- package/src/hooks/usePopover.tsx +9 -6
- package/src/mock/collectionData.tsx +33 -2
- package/src/stories/Button/Button.stories.tsx +72 -7
- package/src/stories/Checkbox/Checkbox.stories.tsx +6 -3
- package/src/stories/Collection/Collection.stories.tsx +18 -2
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +282 -33
- package/src/stories/Drawer/Drawer.stories.tsx +70 -3
- package/src/stories/Dropdown/Dropdown.stories.tsx +13 -3
- package/src/stories/Icon/Icon.stories.tsx +1 -0
- package/src/stories/Input/Input.stories.tsx +5 -3
- package/src/stories/Menu/Menu.stories.tsx +2 -0
- package/src/stories/Message/Message.stories.tsx +7 -0
- package/src/stories/Panel/Panel.stories.tsx +147 -13
- package/src/stories/Popover/Popover.stories.tsx +88 -82
- package/src/stories/Tabs/Tabs.stories.tsx +33 -15
- package/src/stories/Tag/Tag.stories.tsx +23 -3
- package/src/stories/TextArea/TextArea.stories.tsx +3 -3
- package/src/styles.ts +6 -0
- package/src/types/global.ts +28 -0
- package/tests.json +1 -1
- package/CODE_OF_CONDUCT.md +0 -105
- package/CONTRIBUTING.MD +0 -78
- package/SECURITY.md +0 -5
- package/public/logo-dark.png +0 -0
- package/public/logo.png +0 -0
- package/public/q-symbol.png +0 -0
- package/public/qoreLogo-dark.png +0 -0
- package/public/qoreLogo.png +0 -0
|
@@ -27,7 +27,7 @@ export interface IReqoreDrawerProps extends Omit<IReqorePanelProps, 'size'> {
|
|
|
27
27
|
onClose?: () => void;
|
|
28
28
|
onHideToggle?: (isHidden: boolean) => void;
|
|
29
29
|
hasBackdrop?: boolean;
|
|
30
|
-
size?: string;
|
|
30
|
+
size?: string | 'auto';
|
|
31
31
|
maxSize?: string;
|
|
32
32
|
minSize?: string;
|
|
33
33
|
opacity?: number;
|
|
@@ -170,6 +170,7 @@ export const ReqoreDrawer = ({
|
|
|
170
170
|
_isModal,
|
|
171
171
|
width,
|
|
172
172
|
height,
|
|
173
|
+
actions = [],
|
|
173
174
|
...rest
|
|
174
175
|
}: IReqoreDrawerProps) => {
|
|
175
176
|
const { animations } = useContext(ReqoreContext);
|
|
@@ -199,12 +200,13 @@ export const ReqoreDrawer = ({
|
|
|
199
200
|
|
|
200
201
|
const zIndex = useLatestZIndex();
|
|
201
202
|
const wrapperZIndex = useLatestZIndex();
|
|
202
|
-
const
|
|
203
|
-
const
|
|
203
|
+
const _actions: IReqorePanelAction[] = useMemo(() => {
|
|
204
|
+
const builtActions: IReqorePanelAction[] = [...actions];
|
|
204
205
|
|
|
205
206
|
/* Adding a hide/show button to the drawer. */
|
|
206
207
|
if (hidable) {
|
|
207
|
-
|
|
208
|
+
builtActions.push({
|
|
209
|
+
responsive: false,
|
|
208
210
|
icon: getHideShowIcon(position, _isHidden),
|
|
209
211
|
onClick: () => {
|
|
210
212
|
setIsHidden(!_isHidden);
|
|
@@ -218,14 +220,15 @@ export const ReqoreDrawer = ({
|
|
|
218
220
|
|
|
219
221
|
/* Adding a close button to the drawer. */
|
|
220
222
|
if (onClose) {
|
|
221
|
-
|
|
223
|
+
builtActions.push({
|
|
224
|
+
responsive: false,
|
|
222
225
|
icon: 'CloseLine',
|
|
223
226
|
onClick: onClose,
|
|
224
227
|
className: 'reqore-drawer-close-button',
|
|
225
228
|
});
|
|
226
229
|
}
|
|
227
230
|
|
|
228
|
-
return
|
|
231
|
+
return builtActions;
|
|
229
232
|
}, [hidable, position, onClose]);
|
|
230
233
|
|
|
231
234
|
const positions = useMemo(() => {
|
|
@@ -263,27 +266,27 @@ export const ReqoreDrawer = ({
|
|
|
263
266
|
/>
|
|
264
267
|
) : null}
|
|
265
268
|
<Resizable
|
|
266
|
-
className='reqore-drawer-resizable
|
|
269
|
+
className={`${className || ''} reqore-drawer-resizable`}
|
|
267
270
|
maxHeight={
|
|
268
271
|
layout === 'horizontal' || layout === 'center' ? maxSize || '90vh' : undefined
|
|
269
272
|
}
|
|
270
273
|
minHeight={
|
|
271
274
|
layout === 'center'
|
|
272
|
-
? '
|
|
275
|
+
? '40px'
|
|
273
276
|
: layout === 'horizontal'
|
|
274
277
|
? _isHidden
|
|
275
278
|
? 0
|
|
276
|
-
: minSize || '
|
|
279
|
+
: minSize || '40px'
|
|
277
280
|
: undefined
|
|
278
281
|
}
|
|
279
282
|
maxWidth={layout === 'vertical' || layout === 'center' ? maxSize || '90vw' : undefined}
|
|
280
283
|
minWidth={
|
|
281
284
|
layout === 'center'
|
|
282
|
-
? '
|
|
285
|
+
? '40px'
|
|
283
286
|
: layout === 'vertical'
|
|
284
287
|
? _isHidden
|
|
285
288
|
? 0
|
|
286
|
-
: minSize || '
|
|
289
|
+
: minSize || '40px'
|
|
287
290
|
: undefined
|
|
288
291
|
}
|
|
289
292
|
as={StyledDrawerResizable}
|
|
@@ -342,21 +345,19 @@ export const ReqoreDrawer = ({
|
|
|
342
345
|
<StyledCloseWrapper
|
|
343
346
|
className='reqore-drawer-controls'
|
|
344
347
|
position={position}
|
|
345
|
-
w={layout === 'vertical'
|
|
346
|
-
h={layout === 'horizontal'
|
|
348
|
+
w={layout === 'vertical' ? 0 : _size.width}
|
|
349
|
+
h={layout === 'horizontal' ? 0 : _size.height}
|
|
347
350
|
>
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
/>
|
|
359
|
-
)}
|
|
351
|
+
<ReqoreButton
|
|
352
|
+
flat
|
|
353
|
+
customTheme={theme}
|
|
354
|
+
className='reqore-drawer-control reqore-drawer-hide-button'
|
|
355
|
+
icon={getHideShowIcon(position, _isHidden)}
|
|
356
|
+
onClick={() => {
|
|
357
|
+
setIsHidden(!_isHidden);
|
|
358
|
+
onHideToggle && onHideToggle(!_isHidden);
|
|
359
|
+
}}
|
|
360
|
+
/>
|
|
360
361
|
</StyledCloseWrapper>
|
|
361
362
|
) : null}
|
|
362
363
|
{!_isHidden && (
|
|
@@ -364,12 +365,12 @@ export const ReqoreDrawer = ({
|
|
|
364
365
|
{...rest}
|
|
365
366
|
opacity={opacity}
|
|
366
367
|
blur={hasBackdrop ? 0 : blur}
|
|
367
|
-
actions={
|
|
368
|
+
actions={_actions}
|
|
368
369
|
customTheme={customTheme}
|
|
369
370
|
intent={intent}
|
|
370
371
|
rounded={floating || _isModal ? true : false}
|
|
371
372
|
flat={flat}
|
|
372
|
-
className={
|
|
373
|
+
className={`reqore-drawer`}
|
|
373
374
|
style={{
|
|
374
375
|
width: '100%',
|
|
375
376
|
maxHeight: '100%',
|
|
@@ -22,6 +22,7 @@ export interface IReqoreDropdownProps extends Partial<IPopoverOptions> {
|
|
|
22
22
|
caretPosition?: 'left' | 'right';
|
|
23
23
|
isDefaultOpen?: boolean;
|
|
24
24
|
onItemSelect?: TDropdownItemOnClick;
|
|
25
|
+
style?: React.CSSProperties;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
function ReqoreDropdown<T extends unknown = IReqoreButtonProps>({
|
|
@@ -64,7 +65,7 @@ function ReqoreDropdown<T extends unknown = IReqoreButtonProps>({
|
|
|
64
65
|
...rest,
|
|
65
66
|
icon: caretPosition === 'left' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
66
67
|
rightIcon: caretPosition === 'right' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
67
|
-
style: buttonStyle,
|
|
68
|
+
style: buttonStyle || rest.style,
|
|
68
69
|
disabled: !size(items),
|
|
69
70
|
className: `${(rest as any)?.className || ''} reqore-dropdown-control`,
|
|
70
71
|
} as T),
|
|
@@ -98,6 +99,7 @@ function ReqoreDropdown<T extends unknown = IReqoreButtonProps>({
|
|
|
98
99
|
useTargetWidth={useTargetWidth}
|
|
99
100
|
component={component || ReqoreButton}
|
|
100
101
|
componentProps={componentProps}
|
|
102
|
+
isReqoreComponent
|
|
101
103
|
noWrapper
|
|
102
104
|
placement={placement || 'bottom-start'}
|
|
103
105
|
handler={handler || 'click'}
|
|
@@ -114,10 +114,16 @@ export const StyledEffect = styled.span`
|
|
|
114
114
|
const gradientColors = createEffectGradient(
|
|
115
115
|
theme,
|
|
116
116
|
effect.gradient.colors,
|
|
117
|
-
0,
|
|
117
|
+
minimal ? 0.05 : 0,
|
|
118
118
|
!isText && minimal && !active
|
|
119
119
|
);
|
|
120
|
-
const gradientColorsActive = createEffectGradient(
|
|
120
|
+
const gradientColorsActive = createEffectGradient(
|
|
121
|
+
theme,
|
|
122
|
+
effect.gradient.colors,
|
|
123
|
+
0.05,
|
|
124
|
+
minimal,
|
|
125
|
+
true
|
|
126
|
+
);
|
|
121
127
|
|
|
122
128
|
const gradientDirectionOrShape =
|
|
123
129
|
gradientType === 'linear'
|
|
@@ -167,16 +173,17 @@ export const StyledEffect = styled.span`
|
|
|
167
173
|
background: ${active ? gradientActive : gradient};
|
|
168
174
|
border-color: ${borderColor} !important;
|
|
169
175
|
|
|
170
|
-
${color &&
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
${color && !minimal
|
|
177
|
+
? css`
|
|
178
|
+
color: ${getReadableColorFrom(getColorFromMaybeString(theme, color), false)} !important;
|
|
179
|
+
&::placeholder {
|
|
180
|
+
color: ${rgba(
|
|
181
|
+
getReadableColorFrom(getColorFromMaybeString(theme, color), false),
|
|
182
|
+
0.7
|
|
183
|
+
)} !important;
|
|
184
|
+
}
|
|
185
|
+
`
|
|
186
|
+
: undefined}
|
|
180
187
|
|
|
181
188
|
${effect.gradient.animate === 'always' || (effect.gradient.animate === 'active' && active)
|
|
182
189
|
? css`
|
|
@@ -269,6 +276,7 @@ export const StyledEffect = styled.span`
|
|
|
269
276
|
white-space: nowrap;
|
|
270
277
|
text-overflow: ellipsis;
|
|
271
278
|
overflow: hidden;
|
|
279
|
+
min-width: 30px;
|
|
272
280
|
`
|
|
273
281
|
: undefined}
|
|
274
282
|
|
|
@@ -364,9 +372,9 @@ export const ReqoreEffect = ({ children, ...rest }: IReqoreTextEffectProps) => {
|
|
|
364
372
|
);
|
|
365
373
|
};
|
|
366
374
|
|
|
367
|
-
export const ReqoreTextEffect = ({ children, ...rest }: IReqoreTextEffectProps) => {
|
|
375
|
+
export const ReqoreTextEffect = ({ children, className, ...rest }: IReqoreTextEffectProps) => {
|
|
368
376
|
return (
|
|
369
|
-
<StyledTextEffect className='reqore-text-effect
|
|
377
|
+
<StyledTextEffect className={`${className || ''} reqore-text-effect`} {...rest}>
|
|
370
378
|
{children}
|
|
371
379
|
</StyledTextEffect>
|
|
372
380
|
);
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import React, { memo, useContext } from 'react';
|
|
1
|
+
import React, { forwardRef, memo, useContext } from 'react';
|
|
2
2
|
import { IconContext } from 'react-icons';
|
|
3
3
|
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
7
|
import { ICON_FROM_SIZE, PADDING_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
8
|
-
import {
|
|
8
|
+
import { getColorFromMaybeString } from '../../helpers/colors';
|
|
9
9
|
import { isStringSize } from '../../helpers/utils';
|
|
10
|
-
import {
|
|
10
|
+
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
11
|
+
import { useTooltip } from '../../hooks/useTooltip';
|
|
12
|
+
import { IReqoreIntent, IWithReqoreEffect, IWithReqoreTooltip } from '../../types/global';
|
|
11
13
|
import { IReqoreIconName } from '../../types/icons';
|
|
12
|
-
import { StyledEffect } from '../Effect';
|
|
14
|
+
import { StyledEffect, TReqoreEffectColor } from '../Effect';
|
|
13
15
|
|
|
14
|
-
export interface IReqoreIconProps
|
|
16
|
+
export interface IReqoreIconProps
|
|
17
|
+
extends React.HTMLAttributes<HTMLSpanElement>,
|
|
18
|
+
IWithReqoreEffect,
|
|
19
|
+
IWithReqoreTooltip,
|
|
20
|
+
IReqoreIntent {
|
|
15
21
|
icon?: IReqoreIconName;
|
|
16
|
-
color?:
|
|
22
|
+
color?: TReqoreEffectColor;
|
|
17
23
|
size?: TSizes | string;
|
|
18
24
|
iconProps?: IconBaseProps;
|
|
19
|
-
intent?: TReqoreIntent;
|
|
20
25
|
margin?: 'right' | 'left' | 'both';
|
|
21
26
|
image?: string;
|
|
22
27
|
rounded?: boolean;
|
|
@@ -52,71 +57,85 @@ export const StyledIconWrapper = styled(StyledEffect)<{ margin: 'right' | 'left'
|
|
|
52
57
|
`;
|
|
53
58
|
|
|
54
59
|
const ReqoreIcon = memo(
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
forwardRef<HTMLSpanElement, IReqoreIconProps>(
|
|
61
|
+
(
|
|
62
|
+
{
|
|
63
|
+
icon,
|
|
64
|
+
size = 'normal',
|
|
65
|
+
className,
|
|
66
|
+
color,
|
|
67
|
+
margin,
|
|
68
|
+
style = {},
|
|
69
|
+
iconProps,
|
|
70
|
+
intent,
|
|
71
|
+
image,
|
|
72
|
+
tooltip,
|
|
73
|
+
...rest
|
|
74
|
+
}: IReqoreIconProps,
|
|
75
|
+
ref
|
|
76
|
+
) => {
|
|
77
|
+
const { targetRef } = useCombinedRefs(ref);
|
|
78
|
+
const theme = useContext(ReqoreThemeContext);
|
|
79
|
+
const Icon: IconType = RemixIcons[`Ri${icon}`];
|
|
80
|
+
const finalColor: string | undefined = intent
|
|
81
|
+
? theme.intents[intent]
|
|
82
|
+
: getColorFromMaybeString(theme, color);
|
|
83
|
+
const finalSize: string = isStringSize(size) ? ICON_FROM_SIZE[size] : size;
|
|
84
|
+
|
|
85
|
+
useTooltip(targetRef.current, tooltip);
|
|
86
|
+
|
|
87
|
+
if (image) {
|
|
88
|
+
return (
|
|
89
|
+
<StyledIconWrapper
|
|
90
|
+
{...rest}
|
|
91
|
+
ref={targetRef}
|
|
92
|
+
size={size}
|
|
93
|
+
margin={margin}
|
|
94
|
+
className={`${className || ''} reqore-icon`}
|
|
95
|
+
style={{ ...style, width: finalSize, height: finalSize }}
|
|
96
|
+
>
|
|
97
|
+
<img src={image} alt='' />
|
|
98
|
+
</StyledIconWrapper>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!Icon) {
|
|
103
|
+
return (
|
|
104
|
+
<StyledIconWrapper
|
|
105
|
+
{...rest}
|
|
106
|
+
ref={targetRef}
|
|
107
|
+
size={size}
|
|
108
|
+
margin={margin}
|
|
109
|
+
className={`${className || ''} reqore-icon`}
|
|
110
|
+
style={{ ...style, width: finalSize, height: finalSize }}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
71
114
|
|
|
72
|
-
if (image) {
|
|
73
115
|
return (
|
|
74
116
|
<StyledIconWrapper
|
|
75
117
|
{...rest}
|
|
76
|
-
|
|
118
|
+
ref={targetRef}
|
|
77
119
|
margin={margin}
|
|
78
|
-
|
|
120
|
+
size={size}
|
|
79
121
|
style={{ ...style, width: finalSize, height: finalSize }}
|
|
122
|
+
className={`${className || ''} reqore-icon`}
|
|
80
123
|
>
|
|
81
|
-
<
|
|
124
|
+
<IconContext.Provider
|
|
125
|
+
value={{
|
|
126
|
+
color: finalColor || 'inherit',
|
|
127
|
+
size: finalSize,
|
|
128
|
+
style: {
|
|
129
|
+
verticalAlign: 'super',
|
|
130
|
+
},
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
<Icon {...iconProps} />
|
|
134
|
+
</IconContext.Provider>
|
|
82
135
|
</StyledIconWrapper>
|
|
83
136
|
);
|
|
84
137
|
}
|
|
85
|
-
|
|
86
|
-
if (!Icon) {
|
|
87
|
-
return (
|
|
88
|
-
<StyledIconWrapper
|
|
89
|
-
{...rest}
|
|
90
|
-
size={size}
|
|
91
|
-
margin={margin}
|
|
92
|
-
className={`${className || ''} reqore-icon`}
|
|
93
|
-
style={{ ...style, width: finalSize, height: finalSize }}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<StyledIconWrapper
|
|
100
|
-
{...rest}
|
|
101
|
-
margin={margin}
|
|
102
|
-
size={size}
|
|
103
|
-
style={{ ...style, width: finalSize, height: finalSize }}
|
|
104
|
-
className={`${className || ''} reqore-icon`}
|
|
105
|
-
>
|
|
106
|
-
<IconContext.Provider
|
|
107
|
-
value={{
|
|
108
|
-
color: finalColor || 'inherit',
|
|
109
|
-
size: finalSize,
|
|
110
|
-
style: {
|
|
111
|
-
verticalAlign: 'super',
|
|
112
|
-
},
|
|
113
|
-
}}
|
|
114
|
-
>
|
|
115
|
-
<Icon {...iconProps} />
|
|
116
|
-
</IconContext.Provider>
|
|
117
|
-
</StyledIconWrapper>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
138
|
+
)
|
|
120
139
|
);
|
|
121
140
|
|
|
122
141
|
export default ReqoreIcon;
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
IWithReqoreEffect,
|
|
23
23
|
} from '../../types/global';
|
|
24
24
|
import { IReqoreIconName } from '../../types/icons';
|
|
25
|
-
import { StyledEffect } from '../Effect';
|
|
25
|
+
import { StyledEffect, TReqoreEffectColor } from '../Effect';
|
|
26
26
|
import ReqoreIcon from '../Icon';
|
|
27
27
|
import ReqoreInputClearButton from '../InputClearButton';
|
|
28
28
|
|
|
@@ -48,6 +48,7 @@ export interface IReqoreInputProps
|
|
|
48
48
|
rounded?: boolean;
|
|
49
49
|
type?: 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
|
|
50
50
|
wrapperStyle?: React.CSSProperties;
|
|
51
|
+
iconColor?: TReqoreEffectColor;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
export interface IReqoreInputStyle extends IReqoreInputProps {
|
|
@@ -60,7 +61,10 @@ export interface IReqoreInputStyle extends IReqoreInputProps {
|
|
|
60
61
|
export const StyledInputWrapper = styled.div<IReqoreInputStyle>`
|
|
61
62
|
height: ${({ _size }) => SIZE_TO_PX[_size]}px;
|
|
62
63
|
width: ${({ width }) => (width ? `${width}px` : 'auto')};
|
|
63
|
-
|
|
64
|
+
max-width: ${({ fluid, fixed }) => (fluid && !fixed ? '100%' : undefined)};
|
|
65
|
+
min-width: 60px;
|
|
66
|
+
flex: ${({ fluid, fixed }) => (fixed ? '0 auto' : fluid ? '1 auto' : '0 1 auto')};
|
|
67
|
+
align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
|
|
64
68
|
font-size: ${({ _size }) => TEXT_FROM_SIZE[_size]}px;
|
|
65
69
|
position: relative;
|
|
66
70
|
overflow: hidden;
|
|
@@ -150,6 +154,7 @@ const ReqoreInput = forwardRef<HTMLDivElement, IReqoreInputProps>(
|
|
|
150
154
|
className,
|
|
151
155
|
onClearClick,
|
|
152
156
|
icon,
|
|
157
|
+
iconColor,
|
|
153
158
|
flat,
|
|
154
159
|
rounded = true,
|
|
155
160
|
minimal,
|
|
@@ -185,7 +190,7 @@ const ReqoreInput = forwardRef<HTMLDivElement, IReqoreInputProps>(
|
|
|
185
190
|
>
|
|
186
191
|
{icon && (
|
|
187
192
|
<StyledIconWrapper _size={size}>
|
|
188
|
-
<ReqoreIcon size={size} icon={icon} />
|
|
193
|
+
<ReqoreIcon size={size} icon={icon} color={iconColor} />
|
|
189
194
|
</StyledIconWrapper>
|
|
190
195
|
)}
|
|
191
196
|
<StyledInput
|