@qoretechnologies/reqore 0.32.0 → 0.32.2
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/.github/workflows/tests.yml +3 -1
- package/__tests__/breadcrumbs.test.tsx +46 -28
- package/__tests__/button.test.tsx +18 -0
- package/__tests__/checkbox.test.tsx +19 -1
- package/__tests__/collection.test.tsx +9 -0
- package/__tests__/icon.test.tsx +19 -1
- package/__tests__/input.test.tsx +18 -0
- package/__tests__/messages.test.tsx +16 -0
- package/__tests__/modal.test.tsx +4 -4
- package/__tests__/notifications.test.tsx +6 -6
- package/__tests__/panel.test.tsx +19 -1
- package/__tests__/textarea.test.tsx +18 -0
- package/__tests__/tree.test.tsx +3 -1
- package/dist/components/Breadcrumbs/item.d.ts.map +1 -1
- package/dist/components/Breadcrumbs/item.js +6 -2
- package/dist/components/Breadcrumbs/item.js.map +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +18 -4
- 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 +8 -4
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Collection/index.d.ts +2 -1
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +15 -12
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Collection/item.js +2 -2
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/Comment/index.d.ts +0 -1
- package/dist/components/Comment/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +1 -1
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropdown/item.d.ts +0 -1
- package/dist/components/Dropdown/item.d.ts.map +1 -1
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +8 -4
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +4 -4
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InputClearButton/index.d.ts +0 -1
- package/dist/components/InputClearButton/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +2 -1
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Menu/item.d.ts +1 -1
- package/dist/components/Menu/item.d.ts.map +1 -1
- package/dist/components/Menu/item.js +3 -6
- package/dist/components/Menu/item.js.map +1 -1
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +6 -2
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Modal/index.d.ts +0 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +13 -9
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Panel/panel.screenshot.d.ts +0 -1
- package/dist/components/Panel/panel.screenshot.d.ts.map +1 -1
- package/dist/components/Sidebar/item.d.ts +0 -1
- package/dist/components/Sidebar/item.d.ts.map +1 -1
- package/dist/components/Sidebar/item.js +1 -3
- package/dist/components/Sidebar/item.js.map +1 -1
- package/dist/components/Spinner/index.d.ts +0 -1
- package/dist/components/Spinner/index.d.ts.map +1 -1
- package/dist/components/Table/header.d.ts +0 -1
- package/dist/components/Table/header.d.ts.map +1 -1
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +7 -4
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts.map +1 -1
- package/dist/components/Textarea/index.js +7 -6
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/components/Tree/index.d.ts +0 -1
- package/dist/components/Tree/index.d.ts.map +1 -1
- package/dist/components/Tree/index.js +2 -4
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/containers/PopoverProvider.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.js +2 -2
- package/dist/containers/PopoverProvider.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +4 -0
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/ThemeProvider.d.ts +1 -2
- package/dist/containers/ThemeProvider.d.ts.map +1 -1
- package/dist/containers/ThemeProvider.js +3 -3
- package/dist/containers/ThemeProvider.js.map +1 -1
- package/dist/context/PopoverContext.d.ts +1 -2
- package/dist/context/PopoverContext.d.ts.map +1 -1
- package/dist/context/PopoverContext.js +2 -2
- package/dist/context/PopoverContext.js.map +1 -1
- package/dist/context/ReqoreContext.d.ts +3 -2
- package/dist/context/ReqoreContext.d.ts.map +1 -1
- package/dist/context/ReqoreContext.js +5 -3
- package/dist/context/ReqoreContext.js.map +1 -1
- package/dist/context/ThemeContext.d.ts +1 -2
- package/dist/context/ThemeContext.d.ts.map +1 -1
- package/dist/context/ThemeContext.js +2 -2
- package/dist/context/ThemeContext.js.map +1 -1
- package/dist/hooks/useLatestZIndex.d.ts.map +1 -1
- package/dist/hooks/useLatestZIndex.js +3 -2
- package/dist/hooks/useLatestZIndex.js.map +1 -1
- package/dist/hooks/usePopover.d.ts +0 -1
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +4 -3
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/hooks/useReqore.js +2 -2
- package/dist/hooks/useReqore.js.map +1 -1
- package/dist/hooks/useReqoreContext.d.ts +3 -0
- package/dist/hooks/useReqoreContext.d.ts.map +1 -0
- package/dist/hooks/useReqoreContext.js +19 -0
- package/dist/hooks/useReqoreContext.js.map +1 -0
- package/dist/hooks/useReqoreEffect.js +2 -5
- package/dist/hooks/useReqoreEffect.js.map +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useTheme.js +20 -20
- package/dist/hooks/useTheme.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +18 -16
- package/src/components/Breadcrumbs/item.tsx +7 -3
- package/src/components/Button/index.tsx +25 -7
- package/src/components/Checkbox/index.tsx +9 -5
- package/src/components/Collection/index.tsx +21 -9
- package/src/components/Collection/item.tsx +3 -3
- package/src/components/ControlGroup/index.tsx +1 -1
- package/src/components/Drawer/index.tsx +4 -4
- package/src/components/Icon/index.tsx +9 -5
- package/src/components/Input/index.tsx +5 -9
- package/src/components/InternalPopover/index.tsx +2 -1
- package/src/components/Menu/item.tsx +6 -9
- package/src/components/Message/index.tsx +6 -2
- package/src/components/Panel/index.tsx +14 -7
- package/src/components/Sidebar/item.tsx +2 -4
- package/src/components/Tag/index.tsx +9 -6
- package/src/components/Textarea/index.tsx +6 -8
- package/src/components/Tree/index.tsx +5 -8
- package/src/containers/PopoverProvider.tsx +2 -2
- package/src/containers/ReqoreProvider.tsx +5 -1
- package/src/containers/ThemeProvider.tsx +3 -13
- package/src/context/PopoverContext.tsx +1 -1
- package/src/context/ReqoreContext.tsx +4 -1
- package/src/context/ThemeContext.tsx +1 -1
- package/src/hooks/useLatestZIndex.ts +5 -3
- package/src/hooks/usePopover.tsx +4 -3
- package/src/hooks/useReqore.ts +1 -1
- package/src/hooks/useReqoreContext.ts +16 -0
- package/src/hooks/useReqoreEffect.ts +3 -3
- package/src/hooks/useTheme.ts +21 -17
- package/src/index.tsx +1 -0
- package/src/stories/Button/Button.stories.tsx +7 -0
- package/src/stories/Collection/Collection.stories.tsx +6 -3
- package/src/stories/Drawer/Drawer.stories.tsx +4 -3
- package/src/stories/Modal/Modal.stories.tsx +3 -4
- package/src/stories/Notifications/Interactive.stories.tsx +3 -4
- package/src/stories/Panel/Panel.stories.tsx +1 -0
- package/tests.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { forwardRef, memo
|
|
1
|
+
import React, { forwardRef, memo } 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, keyframes } from 'styled-components';
|
|
6
|
-
import {
|
|
6
|
+
import { useReqoreTheme } from '../..';
|
|
7
7
|
import { ICON_FROM_SIZE, PADDING_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
8
8
|
import { getColorFromMaybeString } from '../../helpers/colors';
|
|
9
9
|
import { isStringSize } from '../../helpers/utils';
|
|
@@ -97,7 +97,8 @@ const ReqoreIcon = memo(
|
|
|
97
97
|
ref
|
|
98
98
|
) => {
|
|
99
99
|
const { targetRef } = useCombinedRefs(ref);
|
|
100
|
-
const
|
|
100
|
+
const [iconRef, setIconRef] = React.useState<HTMLSpanElement>(undefined);
|
|
101
|
+
const theme = useReqoreTheme();
|
|
101
102
|
const Icon: IconType = RemixIcons[`Ri${icon}`];
|
|
102
103
|
const finalColor: string | undefined = intent
|
|
103
104
|
? theme.intents[intent]
|
|
@@ -109,7 +110,7 @@ const ReqoreIcon = memo(
|
|
|
109
110
|
: wrapperSize
|
|
110
111
|
: finalSize;
|
|
111
112
|
|
|
112
|
-
useTooltip(
|
|
113
|
+
useTooltip(iconRef, tooltip);
|
|
113
114
|
|
|
114
115
|
if (image) {
|
|
115
116
|
return (
|
|
@@ -145,7 +146,10 @@ const ReqoreIcon = memo(
|
|
|
145
146
|
<StyledIconWrapper
|
|
146
147
|
{...rest}
|
|
147
148
|
as={wrapperElement}
|
|
148
|
-
ref={
|
|
149
|
+
ref={(ref) => {
|
|
150
|
+
targetRef.current = ref;
|
|
151
|
+
setIconRef(ref);
|
|
152
|
+
}}
|
|
149
153
|
margin={margin}
|
|
150
154
|
size={size}
|
|
151
155
|
style={{ width: finalWrapperSize, height: finalWrapperSize, ...style }}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { rgba } from 'polished';
|
|
2
|
-
import React, { forwardRef,
|
|
2
|
+
import React, { forwardRef, useState } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import {
|
|
5
5
|
PADDING_FROM_SIZE,
|
|
@@ -188,15 +188,11 @@ const ReqoreInput = forwardRef<HTMLDivElement, IReqoreInputProps>(
|
|
|
188
188
|
ref
|
|
189
189
|
) => {
|
|
190
190
|
const { targetRef } = useCombinedRefs(ref);
|
|
191
|
-
const inputRef =
|
|
191
|
+
const [inputRef, setInputRef] = useState<HTMLInputElement>(null);
|
|
192
192
|
const theme = useReqoreTheme('main', customTheme, intent);
|
|
193
193
|
|
|
194
|
-
useTooltip(
|
|
195
|
-
useAutoFocus(
|
|
196
|
-
inputRef.current,
|
|
197
|
-
readOnly || rest.disabled ? undefined : focusRules,
|
|
198
|
-
rest.onChange
|
|
199
|
-
);
|
|
194
|
+
useTooltip(inputRef, tooltip);
|
|
195
|
+
useAutoFocus(inputRef, readOnly || rest.disabled ? undefined : focusRules, rest.onChange);
|
|
200
196
|
|
|
201
197
|
return (
|
|
202
198
|
<StyledInputWrapper
|
|
@@ -227,7 +223,7 @@ const ReqoreInput = forwardRef<HTMLDivElement, IReqoreInputProps>(
|
|
|
227
223
|
}}
|
|
228
224
|
onChange={!readOnly && !rest?.disabled ? rest?.onChange : undefined}
|
|
229
225
|
as='input'
|
|
230
|
-
ref={
|
|
226
|
+
ref={(ref) => setInputRef(ref)}
|
|
231
227
|
theme={theme}
|
|
232
228
|
_size={size}
|
|
233
229
|
minimal={minimal}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { cloneDeep, isString } from 'lodash';
|
|
2
2
|
import { rgba } from 'polished';
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { MutableRefObject, memo, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { usePopper } from 'react-popper';
|
|
6
6
|
import styled, { css } from 'styled-components';
|
|
7
|
+
import { useContext } from 'use-context-selector';
|
|
7
8
|
import { RADIUS_FROM_SIZE } from '../../constants/sizes';
|
|
8
9
|
import { IReqoreTheme } from '../../constants/theme';
|
|
9
10
|
import { IPopoverData } from '../../containers/PopoverProvider';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React, { forwardRef
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useContext } from 'use-context-selector';
|
|
2
3
|
import { ReqoreButton, ReqoreControlGroup } from '../..';
|
|
3
4
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
4
5
|
import PopoverContext from '../../context/PopoverContext';
|
|
5
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
6
|
-
import { useTooltip } from '../../hooks/useTooltip';
|
|
7
6
|
import { IReqoreComponent } from '../../types/global';
|
|
8
7
|
import { IReqoreButtonProps } from '../Button';
|
|
9
8
|
|
|
@@ -33,7 +32,7 @@ export interface IReqoreMenuItemRightIconStyle {
|
|
|
33
32
|
intent?: TReqoreIntent;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
const ReqoreMenuItem = forwardRef<
|
|
35
|
+
const ReqoreMenuItem = forwardRef<HTMLButtonElement, IReqoreMenuItemProps>(
|
|
37
36
|
(
|
|
38
37
|
{
|
|
39
38
|
children,
|
|
@@ -53,10 +52,9 @@ const ReqoreMenuItem = forwardRef<HTMLDivElement, IReqoreMenuItemProps>(
|
|
|
53
52
|
flat = true,
|
|
54
53
|
...rest
|
|
55
54
|
}: IReqoreMenuItemProps,
|
|
56
|
-
ref
|
|
55
|
+
ref
|
|
57
56
|
) => {
|
|
58
57
|
const { removePopover } = useContext(PopoverContext);
|
|
59
|
-
const { targetRef } = useCombinedRefs(ref);
|
|
60
58
|
|
|
61
59
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
62
60
|
event.persist();
|
|
@@ -81,8 +79,6 @@ const ReqoreMenuItem = forwardRef<HTMLDivElement, IReqoreMenuItemProps>(
|
|
|
81
79
|
}
|
|
82
80
|
};
|
|
83
81
|
|
|
84
|
-
useTooltip(targetRef.current, tooltip);
|
|
85
|
-
|
|
86
82
|
return (
|
|
87
83
|
<ReqoreControlGroup stack={!!onRightIconClick} fluid>
|
|
88
84
|
<ReqoreButton
|
|
@@ -94,11 +90,12 @@ const ReqoreMenuItem = forwardRef<HTMLDivElement, IReqoreMenuItemProps>(
|
|
|
94
90
|
fluid
|
|
95
91
|
onClick={handleClick}
|
|
96
92
|
active={selected}
|
|
97
|
-
ref={
|
|
93
|
+
ref={ref}
|
|
98
94
|
disabled={disabled}
|
|
99
95
|
intent={intent}
|
|
100
96
|
icon={icon}
|
|
101
97
|
rightIcon={onRightIconClick ? undefined : rightIcon}
|
|
98
|
+
tooltip={tooltip}
|
|
102
99
|
>
|
|
103
100
|
{label || children}
|
|
104
101
|
</ReqoreButton>
|
|
@@ -87,8 +87,9 @@ const ReqoreMessage = memo(
|
|
|
87
87
|
const [internalTimeout, setInternalTimeout] = useState<NodeJS.Timeout | null>(null);
|
|
88
88
|
const theme = useReqoreTheme('main', customTheme, intent);
|
|
89
89
|
const { targetRef } = useCombinedRefs(ref);
|
|
90
|
+
const [itemRef, setItemRef] = useState<HTMLDivElement>(undefined);
|
|
90
91
|
|
|
91
|
-
useTooltip(
|
|
92
|
+
useTooltip(itemRef, tooltip);
|
|
92
93
|
|
|
93
94
|
useMount(() => {
|
|
94
95
|
if (duration) {
|
|
@@ -142,7 +143,10 @@ const ReqoreMessage = memo(
|
|
|
142
143
|
fluid={fluid}
|
|
143
144
|
fixed={fixed}
|
|
144
145
|
className={`${rest?.className || ''} reqore-message`}
|
|
145
|
-
ref={
|
|
146
|
+
ref={(ref) => {
|
|
147
|
+
targetRef.current = ref;
|
|
148
|
+
setItemRef(ref);
|
|
149
|
+
}}
|
|
146
150
|
size={size}
|
|
147
151
|
theme={theme}
|
|
148
152
|
>
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from '../../helpers/colors';
|
|
22
22
|
import { getOneHigherSize, isActionShown } from '../../helpers/utils';
|
|
23
23
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
24
|
-
import {
|
|
24
|
+
import { useReqoreProperty } from '../../hooks/useReqoreContext';
|
|
25
25
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
26
26
|
import { useTooltip } from '../../hooks/useTooltip';
|
|
27
27
|
import { ACTIVE_ICON_SCALE, INACTIVE_ICON_SCALE } from '../../styles';
|
|
@@ -102,6 +102,7 @@ export interface IReqorePanelProps
|
|
|
102
102
|
transparent?: boolean;
|
|
103
103
|
iconColor?: TReqoreEffectColor;
|
|
104
104
|
responsiveActions?: boolean;
|
|
105
|
+
responsiveTitle?: boolean;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
export interface IStyledPanel extends IReqorePanelProps {
|
|
@@ -187,7 +188,7 @@ export const StyledPanel = styled(StyledEffect)<IStyledPanel>`
|
|
|
187
188
|
|
|
188
189
|
export const StyledPanelTitle = styled.div<IStyledPanel>`
|
|
189
190
|
display: flex;
|
|
190
|
-
flex-flow: ${({ isMobile }) => (isMobile ? 'column' : 'row')};
|
|
191
|
+
flex-flow: ${({ responsive, isMobile }) => (responsive ? (isMobile ? 'column' : 'row') : 'row')};
|
|
191
192
|
background-color: ${({ theme, opacity = 1 }: IStyledPanel) =>
|
|
192
193
|
rgba(changeLightness(getMainBackgroundColor(theme), 0.03), opacity)};
|
|
193
194
|
justify-content: space-between;
|
|
@@ -295,6 +296,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
295
296
|
iconProps = {},
|
|
296
297
|
fluid,
|
|
297
298
|
responsiveActions = true,
|
|
299
|
+
responsiveTitle = true,
|
|
298
300
|
size: panelSize = 'normal',
|
|
299
301
|
...rest
|
|
300
302
|
}: IReqorePanelProps,
|
|
@@ -308,10 +310,11 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
308
310
|
? { main: Object.values(contentEffect.gradient.colors)[0] as TReqoreEffectColor }
|
|
309
311
|
: undefined)
|
|
310
312
|
);
|
|
311
|
-
const
|
|
313
|
+
const isMobile = useReqoreProperty('isMobile');
|
|
312
314
|
const { targetRef } = useCombinedRefs(ref);
|
|
315
|
+
const [itemRef, setItemRef] = useState<HTMLDivElement>(undefined);
|
|
313
316
|
|
|
314
|
-
useTooltip(
|
|
317
|
+
useTooltip(itemRef, tooltip);
|
|
315
318
|
|
|
316
319
|
useUpdateEffect(() => {
|
|
317
320
|
setIsCollapsed(!!isCollapsed);
|
|
@@ -421,8 +424,8 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
421
424
|
stack
|
|
422
425
|
customTheme={rest.customTheme || theme}
|
|
423
426
|
size={rest.size}
|
|
424
|
-
fixed={rest.fixed
|
|
425
|
-
fluid={rest.fluid
|
|
427
|
+
fixed={rest.fixed}
|
|
428
|
+
fluid={rest.fluid}
|
|
426
429
|
key={index}
|
|
427
430
|
>
|
|
428
431
|
{group.map((action, index) => renderActions(action, index, true))}
|
|
@@ -517,7 +520,10 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
517
520
|
<StyledPanel
|
|
518
521
|
{...rest}
|
|
519
522
|
as={rest.as || 'div'}
|
|
520
|
-
ref={
|
|
523
|
+
ref={(ref) => {
|
|
524
|
+
targetRef.current = ref;
|
|
525
|
+
setItemRef(ref);
|
|
526
|
+
}}
|
|
521
527
|
isCollapsed={_isCollapsed}
|
|
522
528
|
rounded={rounded}
|
|
523
529
|
flat={flat}
|
|
@@ -540,6 +546,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
540
546
|
size={contentSize || panelSize}
|
|
541
547
|
opacity={opacity ?? (minimal ? 0 : 1)}
|
|
542
548
|
noHorizontalPadding={noHorizontalPadding}
|
|
549
|
+
responsive={responsiveTitle}
|
|
543
550
|
isMobile={isMobile}
|
|
544
551
|
>
|
|
545
552
|
{hasTitleHeader && (
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import classnames from 'classnames';
|
|
2
2
|
import map from 'lodash/map';
|
|
3
|
-
import { useContext } from 'react';
|
|
4
3
|
import { useMount } from 'react-use';
|
|
5
4
|
import { IQorusSidebarItem } from '.';
|
|
6
|
-
import { ReqorePopover } from '../..';
|
|
5
|
+
import { ReqorePopover, useReqoreTheme } from '../..';
|
|
7
6
|
import { IReqoreTheme } from '../../constants/theme';
|
|
8
|
-
import ThemeContext from '../../context/ThemeContext';
|
|
9
7
|
import { getMainColor, getReadableColor } from '../../helpers/colors';
|
|
10
8
|
import { isActiveMulti } from '../../helpers/sidebar';
|
|
11
9
|
import ReqoreIcon from '../Icon';
|
|
@@ -202,7 +200,7 @@ const SidebarItemWrapper = ({
|
|
|
202
200
|
useNativeTitle,
|
|
203
201
|
onClick,
|
|
204
202
|
}: SidebarItemProps) => {
|
|
205
|
-
const theme: IReqoreTheme =
|
|
203
|
+
const theme: IReqoreTheme = useReqoreTheme();
|
|
206
204
|
|
|
207
205
|
useMount(() => {
|
|
208
206
|
if (
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _size from 'lodash/size';
|
|
2
2
|
import { rgba } from 'polished';
|
|
3
|
-
import React, { forwardRef,
|
|
3
|
+
import React, { forwardRef, useState } from 'react';
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
|
-
import { ReqorePopover } from '../..';
|
|
5
|
+
import { ReqorePopover, useReqoreTheme } from '../..';
|
|
6
6
|
import {
|
|
7
7
|
BADGE_SIZE_TO_PX,
|
|
8
8
|
PADDING_FROM_SIZE,
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
TSizes,
|
|
13
13
|
} from '../../constants/sizes';
|
|
14
14
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
15
|
-
import ThemeContext from '../../context/ThemeContext';
|
|
16
15
|
import {
|
|
17
16
|
changeLightness,
|
|
18
17
|
getColorFromMaybeString,
|
|
@@ -264,9 +263,10 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
|
|
|
264
263
|
ref
|
|
265
264
|
) => {
|
|
266
265
|
const { targetRef } = useCombinedRefs(ref);
|
|
267
|
-
const theme: IReqoreTheme =
|
|
266
|
+
const theme: IReqoreTheme = useReqoreTheme();
|
|
267
|
+
const [itemRef, setItemRef] = useState<HTMLDivElement>(undefined);
|
|
268
268
|
|
|
269
|
-
useTooltip(
|
|
269
|
+
useTooltip(itemRef, tooltip);
|
|
270
270
|
|
|
271
271
|
// If color or intent was specified, set the color
|
|
272
272
|
const getCustomColor = (itemIntent?: TReqoreIntent): TReqoreHexColor => {
|
|
@@ -292,7 +292,10 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
|
|
|
292
292
|
color={getCustomColor(intent)}
|
|
293
293
|
className={`${className || ''} reqore-tag`}
|
|
294
294
|
size={size}
|
|
295
|
-
ref={
|
|
295
|
+
ref={(ref) => {
|
|
296
|
+
targetRef.current = ref;
|
|
297
|
+
setItemRef(ref);
|
|
298
|
+
}}
|
|
296
299
|
asBadge={asBadge}
|
|
297
300
|
minimal={minimal}
|
|
298
301
|
removable={!!onRemoveClick}
|
|
@@ -146,6 +146,7 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
|
|
|
146
146
|
ref
|
|
147
147
|
) => {
|
|
148
148
|
const { targetRef }: any = useCombinedRefs(ref);
|
|
149
|
+
const [inputRef, setInputRef] = useState<HTMLTextAreaElement>(null);
|
|
149
150
|
const theme = useReqoreTheme('main', customTheme, intent);
|
|
150
151
|
const [_value, setValue] = useState(value || '');
|
|
151
152
|
|
|
@@ -153,13 +154,9 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
|
|
|
153
154
|
setValue(value || '');
|
|
154
155
|
}, [value]);
|
|
155
156
|
|
|
156
|
-
useTooltip(
|
|
157
|
-
useAutosizeTextArea(
|
|
158
|
-
useAutoFocus(
|
|
159
|
-
targetRef.current,
|
|
160
|
-
rest.readOnly || rest.disabled ? undefined : focusRules,
|
|
161
|
-
onChange
|
|
162
|
-
);
|
|
157
|
+
useTooltip(inputRef, tooltip);
|
|
158
|
+
useAutosizeTextArea(inputRef, _value, scaleWithContent);
|
|
159
|
+
useAutoFocus(inputRef, rest.readOnly || rest.disabled ? undefined : focusRules, onChange);
|
|
163
160
|
|
|
164
161
|
return (
|
|
165
162
|
<StyledTextareaWrapper
|
|
@@ -171,6 +168,7 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
|
|
|
171
168
|
_size={size}
|
|
172
169
|
theme={theme}
|
|
173
170
|
style={wrapperStyle}
|
|
171
|
+
ref={targetRef}
|
|
174
172
|
>
|
|
175
173
|
<StyledTextarea
|
|
176
174
|
{...rest}
|
|
@@ -185,7 +183,7 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
|
|
|
185
183
|
as='textarea'
|
|
186
184
|
className={`${className || ''} reqore-control reqore-textarea`}
|
|
187
185
|
_size={size}
|
|
188
|
-
ref={
|
|
186
|
+
ref={(ref) => setInputRef(ref)}
|
|
189
187
|
theme={theme}
|
|
190
188
|
rounded={rounded}
|
|
191
189
|
rows={1}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { cloneDeep, size as lodashSize } from 'lodash';
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import { ReqoreMessage, ReqorePanel, ReqoreTextarea } from '../..';
|
|
4
|
+
import { ReqoreMessage, ReqorePanel, ReqoreTextarea, useReqoreProperty } from '../..';
|
|
5
5
|
import { IReqoreTheme } from '../../constants/theme';
|
|
6
|
-
import
|
|
7
|
-
import { getLineCount, getTypeFromValue } from '../../helpers/utils';
|
|
6
|
+
import { getTypeFromValue } from '../../helpers/utils';
|
|
8
7
|
import { IWithReqoreSize } from '../../types/global';
|
|
9
8
|
import ReqoreButton from '../Button';
|
|
10
9
|
import ReqoreControlGroup from '../ControlGroup';
|
|
@@ -45,7 +44,7 @@ export const ReqoreTree = ({
|
|
|
45
44
|
const [items, setItems] = useState({});
|
|
46
45
|
const [allExpanded, setAllExpanded] = useState(expanded || !showControls);
|
|
47
46
|
const [_showTypes, setShowTypes] = useState(showTypes);
|
|
48
|
-
const
|
|
47
|
+
const addNotification = useReqoreProperty('addNotification');
|
|
49
48
|
|
|
50
49
|
const handleCopyClick = () => {
|
|
51
50
|
setMode('copy');
|
|
@@ -173,7 +172,6 @@ export const ReqoreTree = ({
|
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
const textData: string = renderText(data);
|
|
176
|
-
const lineCount: number = getLineCount(textData);
|
|
177
175
|
|
|
178
176
|
return (
|
|
179
177
|
<ReqorePanel
|
|
@@ -224,12 +222,11 @@ export const ReqoreTree = ({
|
|
|
224
222
|
<ReqoreTextarea
|
|
225
223
|
className='reqore-tree-textarea'
|
|
226
224
|
id='tree-content'
|
|
227
|
-
|
|
225
|
+
value={textData}
|
|
228
226
|
scaleWithContent
|
|
229
227
|
size={size}
|
|
230
228
|
fluid
|
|
231
229
|
readOnly
|
|
232
|
-
rows={lineCount > 20 ? 20 : lineCount}
|
|
233
230
|
/>
|
|
234
231
|
)}
|
|
235
232
|
</ReqorePanel>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
2
|
import React, { MutableRefObject, useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { useReqoreProperty } from '..';
|
|
3
4
|
import Popover from '../components/InternalPopover';
|
|
4
5
|
import PopoverContext from '../context/PopoverContext';
|
|
5
6
|
import { IPopoverOptions } from '../hooks/usePopover';
|
|
6
|
-
import { useReqore } from '../hooks/useReqore';
|
|
7
7
|
|
|
8
8
|
export interface IReqorePopoverProviderProps {
|
|
9
9
|
children: any;
|
|
@@ -17,7 +17,7 @@ export interface IPopoverData extends IPopoverOptions {
|
|
|
17
17
|
|
|
18
18
|
const PopoverProvider: React.FC<IReqorePopoverProviderProps> = ({ children, uiScale }) => {
|
|
19
19
|
const [popovers, setPopovers] = useState<IPopoverData[]>([]);
|
|
20
|
-
const
|
|
20
|
+
const closePopoversOnEscPress = useReqoreProperty('closePopoversOnEscPress');
|
|
21
21
|
|
|
22
22
|
const handleClick = useCallback(
|
|
23
23
|
(event: MouseEvent) => {
|
|
@@ -2,14 +2,16 @@ import { size } from 'lodash';
|
|
|
2
2
|
import React, { useRef, useState } from 'react';
|
|
3
3
|
import { useMedia } from 'react-use';
|
|
4
4
|
import shortid from 'shortid';
|
|
5
|
+
import { useContext } from 'use-context-selector';
|
|
5
6
|
import { ReqoreModal, ReqoreTextEffect } from '..';
|
|
6
7
|
import ReqoreNotificationsWrapper from '../components/Notifications';
|
|
7
8
|
import ReqoreNotification, {
|
|
8
9
|
IReqoreNotificationType,
|
|
9
10
|
} from '../components/Notifications/notification';
|
|
10
11
|
import { TSizes } from '../constants/sizes';
|
|
11
|
-
import { TReqoreIntent } from '../constants/theme';
|
|
12
|
+
import { IReqoreTheme, TReqoreIntent } from '../constants/theme';
|
|
12
13
|
import ReqoreContext from '../context/ReqoreContext';
|
|
14
|
+
import ThemeContext from '../context/ThemeContext';
|
|
13
15
|
import { IReqoreIconName } from '../types/icons';
|
|
14
16
|
import { IReqoreOptions } from './UIProvider';
|
|
15
17
|
|
|
@@ -50,6 +52,7 @@ export interface IReqoreConfirmationModal {
|
|
|
50
52
|
const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, options = {} }) => {
|
|
51
53
|
const [notifications, setNotifications] = useState<IReqoreNotificationData[] | null>([]);
|
|
52
54
|
const [confirmationModal, setConfirmationModal] = useState<IReqoreConfirmationModal>({});
|
|
55
|
+
const theme: IReqoreTheme = useContext<IReqoreTheme>(ThemeContext);
|
|
53
56
|
const latestZIndex = useRef<number>(9000);
|
|
54
57
|
|
|
55
58
|
const isMobile = process.env.NODE_ENV === 'test' ? false : useMedia('(max-width: 480px)');
|
|
@@ -114,6 +117,7 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, options = {}
|
|
|
114
117
|
<ReqoreContext.Provider
|
|
115
118
|
value={{
|
|
116
119
|
notifications,
|
|
120
|
+
theme,
|
|
117
121
|
addNotification,
|
|
118
122
|
removeNotification,
|
|
119
123
|
confirmAction,
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
1
|
import { ThemeProvider } from 'styled-components';
|
|
2
|
+
import { useContext } from 'use-context-selector';
|
|
3
3
|
import { IReqoreTheme } from '../constants/theme';
|
|
4
4
|
import ThemeContext from '../context/ThemeContext';
|
|
5
5
|
|
|
6
|
-
const ReqoreThemeProvider = ({
|
|
7
|
-
children,
|
|
8
|
-
theme,
|
|
9
|
-
}: {
|
|
10
|
-
children: any;
|
|
11
|
-
theme?: IReqoreTheme;
|
|
12
|
-
}) => {
|
|
6
|
+
const ReqoreThemeProvider = ({ children, theme }: { children: any; theme?: IReqoreTheme }) => {
|
|
13
7
|
const _theme: IReqoreTheme = useContext(ThemeContext);
|
|
14
8
|
|
|
15
|
-
return
|
|
16
|
-
<ThemeProvider theme={theme || _theme}>
|
|
17
|
-
<>{children}</>
|
|
18
|
-
</ThemeProvider>
|
|
19
|
-
);
|
|
9
|
+
return <ThemeProvider theme={theme || _theme}>{children}</ThemeProvider>;
|
|
20
10
|
};
|
|
21
11
|
|
|
22
12
|
export default ReqoreThemeProvider;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createContext } from '
|
|
1
|
+
import { createContext } from 'use-context-selector';
|
|
2
|
+
import { DEFAULT_THEME, IReqoreTheme } from '../constants/theme';
|
|
2
3
|
import { IReqoreConfirmationModal, IReqoreNotificationData } from '../containers/ReqoreProvider';
|
|
3
4
|
import { IReqoreOptions } from '../containers/UIProvider';
|
|
4
5
|
|
|
@@ -15,6 +16,7 @@ export interface IReqoreContext {
|
|
|
15
16
|
readonly tooltips?: IReqoreOptions['tooltips'];
|
|
16
17
|
readonly closePopoversOnEscPress?: boolean;
|
|
17
18
|
readonly latestZIndex?: number;
|
|
19
|
+
theme: IReqoreTheme;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export default createContext<IReqoreContext>({
|
|
@@ -27,4 +29,5 @@ export default createContext<IReqoreContext>({
|
|
|
27
29
|
dialogs: true,
|
|
28
30
|
},
|
|
29
31
|
closePopoversOnEscPress: true,
|
|
32
|
+
theme: DEFAULT_THEME,
|
|
30
33
|
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useReqoreProperty } from './useReqoreContext';
|
|
3
3
|
|
|
4
4
|
const useLatestZIndex = (): number => {
|
|
5
|
-
const
|
|
5
|
+
const getAndIncreaseZIndex = useReqoreProperty('getAndIncreaseZIndex');
|
|
6
|
+
const latestZIndex = useReqoreProperty('latestZIndex');
|
|
7
|
+
|
|
6
8
|
const zIndex = useMemo(() => getAndIncreaseZIndex(), [latestZIndex]);
|
|
7
9
|
|
|
8
10
|
return zIndex;
|
package/src/hooks/usePopover.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Placement } from '@popperjs/core';
|
|
2
|
-
import { MutableRefObject,
|
|
2
|
+
import { MutableRefObject, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import { useUnmount, useUpdateEffect } from 'react-use';
|
|
4
4
|
import shortid from 'shortid';
|
|
5
|
+
import { useContext } from 'use-context-selector';
|
|
6
|
+
import { useReqoreProperty } from '..';
|
|
5
7
|
import { IPopoverData } from '../containers/PopoverProvider';
|
|
6
8
|
import PopoverContext from '../context/PopoverContext';
|
|
7
9
|
import {
|
|
@@ -11,7 +13,6 @@ import {
|
|
|
11
13
|
IWithReqoreMinimal,
|
|
12
14
|
} from '../types/global';
|
|
13
15
|
import { IReqoreIconName } from '../types/icons';
|
|
14
|
-
import { useReqore } from './useReqore';
|
|
15
16
|
|
|
16
17
|
const startEvents = {
|
|
17
18
|
hover: 'mouseenter',
|
|
@@ -78,7 +79,7 @@ const usePopover = ({
|
|
|
78
79
|
}: IPopoverOptions): IPopoverControls => {
|
|
79
80
|
const { addPopover, removePopover, updatePopover, popovers, isPopoverOpen } =
|
|
80
81
|
useContext(PopoverContext);
|
|
81
|
-
const
|
|
82
|
+
const tooltips = useReqoreProperty('tooltips');
|
|
82
83
|
const { current }: MutableRefObject<string> = useRef(shortid.generate());
|
|
83
84
|
let { current: timeout }: MutableRefObject<any> = useRef(0);
|
|
84
85
|
|
package/src/hooks/useReqore.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useContextSelector } from 'use-context-selector';
|
|
2
|
+
import ReqoreContext, { IReqoreContext } from '../context/ReqoreContext';
|
|
3
|
+
|
|
4
|
+
export const useReqoreProperty = <T extends keyof IReqoreContext>(
|
|
5
|
+
property: T
|
|
6
|
+
): IReqoreContext[T] => {
|
|
7
|
+
const contextProperty = useContextSelector(ReqoreContext, (value) => {
|
|
8
|
+
if (!(property in value)) {
|
|
9
|
+
throw new Error(`Reqore context property ${property} not found`);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return value[property];
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return contextProperty;
|
|
16
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
IReqoreEffect,
|
|
4
4
|
TReqoreEffectGradientAnimationTrigger,
|
|
5
5
|
TReqoreHexColor,
|
|
6
6
|
} from '../components/Effect';
|
|
7
7
|
import { IReqoreTheme } from '../constants/theme';
|
|
8
|
-
import
|
|
8
|
+
import { useReqoreTheme } from './useTheme';
|
|
9
9
|
|
|
10
10
|
export const useReqoreEffect = (
|
|
11
11
|
component: 'buttons',
|
|
12
12
|
theme: IReqoreTheme,
|
|
13
13
|
effect?: IReqoreEffect
|
|
14
14
|
): IReqoreEffect => {
|
|
15
|
-
let _theme: IReqoreTheme =
|
|
15
|
+
let _theme: IReqoreTheme = useReqoreTheme();
|
|
16
16
|
|
|
17
17
|
// Return the effect if the component is not defined in the theme
|
|
18
18
|
if (!theme[component]) {
|