@qoretechnologies/reqore 0.25.9 → 0.26.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 +133 -12
- package/__tests__/effect.test.tsx +70 -0
- package/dist/components/Button/index.d.ts +3 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +15 -14
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Collection/item.d.ts +2 -2
- package/dist/components/Collection/item.d.ts.map +1 -1
- package/dist/components/Collection/item.js +6 -3
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +4 -1
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +8 -7
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +12 -5
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/Dropdown/item.d.ts +2 -2
- package/dist/components/Dropdown/item.d.ts.map +1 -1
- package/dist/components/Dropdown/item.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts +9 -2
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Dropdown/list.js +13 -5
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/Effect/index.d.ts +29 -0
- package/dist/components/Effect/index.d.ts.map +1 -0
- package/dist/components/Effect/index.js +117 -0
- package/dist/components/Effect/index.js.map +1 -0
- package/dist/components/Header/index.d.ts +14 -8
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +52 -33
- package/dist/components/Header/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +3 -2
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +8 -7
- 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 +0 -1
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/item.d.ts +5 -11
- package/dist/components/Menu/item.d.ts.map +1 -1
- package/dist/components/Menu/item.js +4 -4
- package/dist/components/Menu/item.js.map +1 -1
- package/dist/components/Message/index.d.ts +3 -6
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +2 -1
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Notifications/notification.d.ts +3 -2
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Notifications/notification.js +3 -2
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Panel/index.d.ts +5 -3
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +17 -27
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Popover/index.d.ts +1 -1
- 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/Tabs/item.d.ts +1 -1
- package/dist/components/Tabs/item.d.ts.map +1 -1
- package/dist/components/Tabs/item.js +6 -5
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tag/index.d.ts +2 -2
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +6 -4
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +2 -2
- package/dist/components/Textarea/index.d.ts.map +1 -1
- package/dist/components/Textarea/index.js +8 -7
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/constants/sizes.d.ts +7 -0
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +8 -1
- package/dist/constants/sizes.js.map +1 -1
- package/dist/constants/theme.d.ts +1 -0
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/constants/theme.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts +2 -2
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +7 -5
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +9 -3
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +3 -2
- 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 +4 -1
- package/dist/context/ReqoreContext.js.map +1 -1
- package/dist/helpers/colors.js +1 -1
- package/dist/helpers/colors.js.map +1 -1
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +23 -9
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/hooks/useWhyDidYouUpdate.d.ts +2 -0
- package/dist/hooks/useWhyDidYouUpdate.d.ts.map +1 -0
- package/dist/hooks/useWhyDidYouUpdate.js +47 -0
- package/dist/hooks/useWhyDidYouUpdate.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/types/global.d.ts +13 -0
- package/dist/types/global.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/Button/index.tsx +34 -23
- package/src/components/Collection/item.tsx +6 -3
- package/src/components/ControlGroup/index.tsx +1 -0
- package/src/components/Dropdown/index.tsx +62 -36
- package/src/components/Dropdown/item.tsx +3 -6
- package/src/components/Dropdown/list.tsx +82 -56
- package/src/components/Effect/index.tsx +134 -0
- package/src/components/Header/index.tsx +33 -28
- package/src/components/Input/index.tsx +15 -7
- package/src/components/InternalPopover/index.tsx +0 -2
- package/src/components/Menu/index.tsx +1 -1
- package/src/components/Menu/item.tsx +8 -17
- package/src/components/Message/index.tsx +13 -5
- package/src/components/Notifications/notification.tsx +6 -3
- package/src/components/Panel/index.tsx +83 -79
- package/src/components/Popover/index.tsx +40 -38
- package/src/components/Tabs/item.tsx +92 -79
- package/src/components/Tag/index.tsx +16 -7
- package/src/components/Textarea/index.tsx +14 -7
- package/src/constants/sizes.ts +8 -0
- package/src/constants/theme.ts +1 -0
- package/src/containers/ReqoreProvider.tsx +16 -8
- package/src/containers/UIProvider.tsx +15 -13
- package/src/context/ReqoreContext.tsx +5 -0
- package/src/helpers/colors.ts +1 -1
- package/src/hooks/usePopover.tsx +34 -20
- package/src/hooks/useWhyDidYouUpdate.ts +32 -0
- package/src/index.tsx +10 -1
- package/src/mock/collectionData.tsx +55 -2
- package/src/stories/Button/Button.stories.tsx +15 -2
- package/src/stories/Collection/Collection.stories.tsx +1 -1
- package/src/stories/Dropdown/Dropdown.stories.tsx +62 -34
- package/src/stories/Header/Header.stories.tsx +71 -0
- package/src/stories/Input/Input.stories.tsx +12 -0
- package/src/stories/Menu/Menu.stories.tsx +14 -0
- package/src/stories/Message/Message.stories.tsx +13 -0
- package/src/stories/Notifications/Notification.stories.tsx +7 -2
- package/src/stories/Panel/Panel.stories.tsx +41 -5
- package/src/stories/Tabs/Tabs.stories.tsx +23 -23
- package/src/stories/Tag/Tag.stories.tsx +16 -0
- package/src/stories/TextArea/TextArea.stories.tsx +18 -0
- package/src/types/global.ts +14 -0
- package/tests.json +1 -1
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { memo, useMemo } from 'react';
|
|
3
3
|
import { ReqorePopover } from '../..';
|
|
4
4
|
import { IPopoverOptions } from '../../hooks/usePopover';
|
|
5
5
|
import { IReqoreIconName } from '../../types/icons';
|
|
6
6
|
import ReqoreButton, { IReqoreButtonProps } from '../Button';
|
|
7
|
-
import {
|
|
8
|
-
import ReqoreDropdownList from './list';
|
|
7
|
+
import ReqoreDropdownList, { IReqoreDropdownItem, TDropdownItemOnClick } from './list';
|
|
9
8
|
|
|
10
|
-
export interface IReqoreDropdownProps
|
|
11
|
-
items?:
|
|
9
|
+
export interface IReqoreDropdownProps extends Partial<IPopoverOptions> {
|
|
10
|
+
items?: IReqoreDropdownItem[];
|
|
12
11
|
multiSelect?: boolean;
|
|
13
12
|
buttonStyle?: React.CSSProperties;
|
|
14
13
|
listStyle?: React.CSSProperties;
|
|
15
14
|
component?: any;
|
|
16
|
-
componentProps?: T;
|
|
17
15
|
filterable?: boolean;
|
|
18
16
|
label?: any;
|
|
19
17
|
children?: any;
|
|
20
|
-
|
|
18
|
+
listWidth?: string;
|
|
21
19
|
icon?: IReqoreIconName;
|
|
22
20
|
rightIcon?: IReqoreIconName;
|
|
23
21
|
caretPosition?: 'left' | 'right';
|
|
24
22
|
isDefaultOpen?: boolean;
|
|
23
|
+
onItemSelect?: TDropdownItemOnClick;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
function ReqoreDropdown<T extends unknown = IReqoreButtonProps>({
|
|
28
27
|
items,
|
|
29
28
|
component,
|
|
30
|
-
componentProps,
|
|
31
29
|
label,
|
|
32
30
|
children,
|
|
33
31
|
multiSelect,
|
|
@@ -40,43 +38,71 @@ const ReqoreDropdown = <T extends unknown = IReqoreButtonProps>({
|
|
|
40
38
|
rightIcon,
|
|
41
39
|
caretPosition = 'left',
|
|
42
40
|
isDefaultOpen = false,
|
|
41
|
+
onItemSelect,
|
|
42
|
+
closeOnOutsideClick,
|
|
43
|
+
blur,
|
|
44
|
+
closeOnAnyClick,
|
|
45
|
+
content,
|
|
46
|
+
delay,
|
|
47
|
+
maxHeight,
|
|
48
|
+
maxWidth,
|
|
49
|
+
noArrow = true,
|
|
50
|
+
opaque,
|
|
51
|
+
openOnMount,
|
|
52
|
+
show,
|
|
53
|
+
targetElement,
|
|
54
|
+
useTargetWidth,
|
|
55
|
+
listWidth,
|
|
43
56
|
...rest
|
|
44
|
-
}: IReqoreDropdownProps
|
|
57
|
+
}: IReqoreDropdownProps & T) {
|
|
58
|
+
const componentProps = useMemo(
|
|
59
|
+
() =>
|
|
60
|
+
({
|
|
61
|
+
...rest,
|
|
62
|
+
icon: caretPosition === 'left' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
63
|
+
rightIcon: caretPosition === 'right' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
64
|
+
style: buttonStyle,
|
|
65
|
+
disabled: !size(items),
|
|
66
|
+
className: `${(rest as any)?.className || ''} reqore-dropdown-control`,
|
|
67
|
+
} as T),
|
|
68
|
+
[items, icon, rightIcon, buttonStyle, caretPosition, rest]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const popoverContent = useMemo(() => {
|
|
72
|
+
return size(items) ? (
|
|
73
|
+
<ReqoreDropdownList
|
|
74
|
+
multiSelect={multiSelect}
|
|
75
|
+
listStyle={listStyle}
|
|
76
|
+
width={useTargetWidth ? '100%' : listWidth}
|
|
77
|
+
items={items}
|
|
78
|
+
filterable={filterable}
|
|
79
|
+
onItemSelect={onItemSelect}
|
|
80
|
+
/>
|
|
81
|
+
) : undefined;
|
|
82
|
+
}, [items]);
|
|
83
|
+
|
|
45
84
|
return (
|
|
46
85
|
<ReqorePopover
|
|
47
|
-
{
|
|
86
|
+
closeOnOutsideClick={closeOnOutsideClick}
|
|
87
|
+
blur={blur}
|
|
88
|
+
closeOnAnyClick={closeOnAnyClick}
|
|
89
|
+
delay={delay}
|
|
90
|
+
maxHeight={maxHeight}
|
|
91
|
+
maxWidth={maxWidth}
|
|
92
|
+
noArrow={noArrow}
|
|
93
|
+
opaque={opaque}
|
|
94
|
+
useTargetWidth={useTargetWidth}
|
|
48
95
|
component={component || ReqoreButton}
|
|
49
|
-
componentProps={
|
|
50
|
-
{
|
|
51
|
-
icon: caretPosition === 'left' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
52
|
-
rightIcon: caretPosition === 'right' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
53
|
-
style: buttonStyle,
|
|
54
|
-
disabled: !size(items),
|
|
55
|
-
...rest,
|
|
56
|
-
...((componentProps || {}) as Object),
|
|
57
|
-
className: `${(componentProps as any)?.className || ''} reqore-dropdown-control`,
|
|
58
|
-
} as T
|
|
59
|
-
}
|
|
96
|
+
componentProps={componentProps}
|
|
60
97
|
noWrapper
|
|
61
98
|
placement={placement || 'bottom-start'}
|
|
62
99
|
handler={handler || 'click'}
|
|
63
100
|
openOnMount={isDefaultOpen}
|
|
64
|
-
content={
|
|
65
|
-
size(items) ? (
|
|
66
|
-
<ReqoreDropdownList
|
|
67
|
-
multiSelect={multiSelect}
|
|
68
|
-
listStyle={listStyle}
|
|
69
|
-
width={rest.useTargetWidth ? '100%' : rest.width}
|
|
70
|
-
items={items}
|
|
71
|
-
filterable={filterable}
|
|
72
|
-
/>
|
|
73
|
-
) : undefined
|
|
74
|
-
}
|
|
75
|
-
noArrow
|
|
101
|
+
content={popoverContent}
|
|
76
102
|
>
|
|
77
103
|
{children || label}
|
|
78
104
|
</ReqorePopover>
|
|
79
105
|
);
|
|
80
|
-
}
|
|
106
|
+
}
|
|
81
107
|
|
|
82
|
-
export default ReqoreDropdown;
|
|
108
|
+
export default memo(ReqoreDropdown) as typeof ReqoreDropdown;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { ReqoreMenuDivider, ReqoreMenuItem } from '../..';
|
|
2
2
|
import { IReqoreMenuDividerProps } from '../Menu/divider';
|
|
3
|
-
import {
|
|
3
|
+
import { IReqoreDropdownItem } from './list';
|
|
4
4
|
|
|
5
|
-
export interface IReqoreDropdownItemProps extends
|
|
5
|
+
export interface IReqoreDropdownItemProps extends Omit<IReqoreDropdownItem, 'value' | 'onClick'> {}
|
|
6
6
|
|
|
7
|
-
export const ReqoreDropdownItem = ({
|
|
8
|
-
children,
|
|
9
|
-
...rest
|
|
10
|
-
}: IReqoreDropdownItemProps) => (
|
|
7
|
+
export const ReqoreDropdownItem = ({ children, ...rest }: IReqoreDropdownItemProps) => (
|
|
11
8
|
<ReqoreMenuItem {...rest} rightIcon={rest.selected ? 'CheckLine' : undefined}>
|
|
12
9
|
{children}
|
|
13
10
|
</ReqoreMenuItem>
|
|
@@ -1,80 +1,106 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { memo, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { IReqoreComponent } from '../../types/global';
|
|
3
3
|
import ReqoreInput from '../Input';
|
|
4
4
|
import ReqoreMenu from '../Menu';
|
|
5
5
|
import ReqoreMenuItem, { IReqoreMenuItemProps } from '../Menu/item';
|
|
6
6
|
import { ReqoreSpacer } from '../Spacer';
|
|
7
7
|
|
|
8
|
+
export type TDropdownItemOnClick = (item: IReqoreDropdownItem) => void;
|
|
9
|
+
export interface IReqoreDropdownItem extends Omit<IReqoreMenuItemProps, 'onClick'> {
|
|
10
|
+
value: any;
|
|
11
|
+
label?: string;
|
|
12
|
+
onClick?: TDropdownItemOnClick;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export interface IReqoreDropdownListProps extends IReqoreComponent {
|
|
9
|
-
items?:
|
|
16
|
+
items?: IReqoreDropdownItem[];
|
|
10
17
|
multiSelect?: boolean;
|
|
11
18
|
listStyle?: React.CSSProperties;
|
|
12
19
|
width?: string;
|
|
13
20
|
height?: string;
|
|
14
21
|
filterable?: boolean;
|
|
22
|
+
onItemSelect?: TDropdownItemOnClick;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
const ReqoreDropdownList = (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const ReqoreDropdownList = memo(
|
|
26
|
+
({
|
|
27
|
+
items,
|
|
28
|
+
multiSelect,
|
|
29
|
+
listStyle,
|
|
30
|
+
_popoverId,
|
|
31
|
+
filterable,
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
onItemSelect,
|
|
35
|
+
}: IReqoreDropdownListProps) => {
|
|
36
|
+
const [_items, setItems] = useState<IReqoreDropdownItem[]>(items);
|
|
37
|
+
const [query, setQuery] = useState<string>('');
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
setItems(items);
|
|
41
|
+
}, [items]);
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
const filteredItems: IReqoreDropdownItem[] = useMemo(() => {
|
|
44
|
+
if (!filterable || query === '') {
|
|
45
|
+
return _items;
|
|
46
|
+
}
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
return _items.filter((item) => {
|
|
49
|
+
const text = item.label || item.value || item.children;
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
if (!text) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
return text.toString().toLowerCase().indexOf(query.toLowerCase()) !== -1;
|
|
56
|
+
});
|
|
57
|
+
}, [items, query, _items]);
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
const handleQueryChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
60
|
+
setQuery(event.target.value);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleItemClick = (item: IReqoreDropdownItem): void => {
|
|
64
|
+
if (item.onClick) {
|
|
65
|
+
item.onClick(item);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (onItemSelect) {
|
|
69
|
+
onItemSelect(item);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
52
72
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
return (
|
|
74
|
+
<ReqoreMenu
|
|
75
|
+
_insidePopover={!multiSelect}
|
|
76
|
+
_popoverId={_popoverId}
|
|
77
|
+
style={listStyle}
|
|
78
|
+
width={width}
|
|
79
|
+
maxHeight={height || '300px'}
|
|
80
|
+
>
|
|
81
|
+
{filterable && (
|
|
82
|
+
<>
|
|
83
|
+
<ReqoreInput
|
|
84
|
+
value={query}
|
|
85
|
+
onChange={handleQueryChange}
|
|
86
|
+
placeholder='Filter'
|
|
87
|
+
onClearClick={() => setQuery('')}
|
|
88
|
+
/>
|
|
89
|
+
<ReqoreSpacer height={10} />
|
|
90
|
+
</>
|
|
91
|
+
)}
|
|
92
|
+
{filteredItems.map((item: IReqoreDropdownItem, index: number) => (
|
|
93
|
+
<ReqoreMenuItem
|
|
94
|
+
key={index}
|
|
95
|
+
{...item}
|
|
96
|
+
label={item.label || item.value}
|
|
97
|
+
onClick={() => handleItemClick(item)}
|
|
98
|
+
rightIcon={item.selected ? 'CheckLine' : undefined}
|
|
69
99
|
/>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
))}
|
|
76
|
-
</ReqoreMenu>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
100
|
+
))}
|
|
101
|
+
</ReqoreMenu>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
79
105
|
|
|
80
106
|
export default ReqoreDropdownList;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { reduce } from 'lodash';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { TEXT_FROM_SIZE, TSizes, WEIGHT_TO_NUMBER } from '../../constants/sizes';
|
|
4
|
+
|
|
5
|
+
export interface IReqoreEffect {
|
|
6
|
+
gradient?: {
|
|
7
|
+
type?: 'linear' | 'radial';
|
|
8
|
+
shape?: 'circle' | 'ellipse';
|
|
9
|
+
colors: { [key: number]: string };
|
|
10
|
+
direction?: string;
|
|
11
|
+
};
|
|
12
|
+
noWrap?: boolean;
|
|
13
|
+
color?: string;
|
|
14
|
+
spaced?: number;
|
|
15
|
+
weight?: number | 'thin' | 'light' | 'normal' | 'bold' | 'thick';
|
|
16
|
+
uppercase?: boolean;
|
|
17
|
+
textSize?: TSizes;
|
|
18
|
+
textAlign?: 'left' | 'center' | 'right';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IReqoreTextEffectProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
effect: IReqoreEffect;
|
|
24
|
+
as?: React.ElementType;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const StyledEffect = styled.span`
|
|
28
|
+
// If gradient was supplied
|
|
29
|
+
${({ effect }: IReqoreTextEffectProps) => {
|
|
30
|
+
if (!effect || !effect.gradient) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const gradientType: string = effect.gradient.type || 'linear';
|
|
35
|
+
const gradientColors = reduce(
|
|
36
|
+
effect.gradient.colors,
|
|
37
|
+
(colorsString, color, percentage) => `${colorsString}, ${color} ${percentage}%`,
|
|
38
|
+
''
|
|
39
|
+
);
|
|
40
|
+
const gradientDirectionOrShape =
|
|
41
|
+
gradientType === 'linear'
|
|
42
|
+
? effect.gradient.direction || 'to right'
|
|
43
|
+
: effect.gradient.shape || 'circle';
|
|
44
|
+
const gradient = `${gradientType}-gradient(${gradientDirectionOrShape}${gradientColors})`;
|
|
45
|
+
|
|
46
|
+
return css`
|
|
47
|
+
background-image: ${gradient};
|
|
48
|
+
`;
|
|
49
|
+
}}
|
|
50
|
+
|
|
51
|
+
${({ effect }: IReqoreTextEffectProps) =>
|
|
52
|
+
effect && effect.spaced
|
|
53
|
+
? css`
|
|
54
|
+
letter-spacing: ${effect.spaced}px;
|
|
55
|
+
`
|
|
56
|
+
: undefined}
|
|
57
|
+
|
|
58
|
+
${({ effect }: IReqoreTextEffectProps) =>
|
|
59
|
+
effect && effect.uppercase
|
|
60
|
+
? css`
|
|
61
|
+
text-transform: uppercase;
|
|
62
|
+
`
|
|
63
|
+
: undefined}
|
|
64
|
+
|
|
65
|
+
${({ effect }: IReqoreTextEffectProps) => {
|
|
66
|
+
if (!effect || !effect.weight) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const weight =
|
|
71
|
+
typeof effect.weight === 'number' ? effect.weight : WEIGHT_TO_NUMBER[effect.weight];
|
|
72
|
+
|
|
73
|
+
return css`
|
|
74
|
+
font-weight: ${weight} !important;
|
|
75
|
+
`;
|
|
76
|
+
}}
|
|
77
|
+
|
|
78
|
+
${({ effect }: IReqoreTextEffectProps) =>
|
|
79
|
+
effect && effect.noWrap
|
|
80
|
+
? css`
|
|
81
|
+
white-space: nowrap;
|
|
82
|
+
text-overflow: ellipsis;
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
`
|
|
85
|
+
: undefined}
|
|
86
|
+
|
|
87
|
+
${({ effect }: IReqoreTextEffectProps) =>
|
|
88
|
+
effect && effect.color
|
|
89
|
+
? css`
|
|
90
|
+
color: ${effect.color} !important;
|
|
91
|
+
`
|
|
92
|
+
: undefined}
|
|
93
|
+
|
|
94
|
+
${({ effect }: IReqoreTextEffectProps) =>
|
|
95
|
+
effect && effect.textSize
|
|
96
|
+
? css`
|
|
97
|
+
font-size: ${TEXT_FROM_SIZE[effect.textSize]}px !important;
|
|
98
|
+
`
|
|
99
|
+
: undefined}
|
|
100
|
+
|
|
101
|
+
${({ effect }: IReqoreTextEffectProps) =>
|
|
102
|
+
effect && effect.textAlign
|
|
103
|
+
? css`
|
|
104
|
+
text-align: ${effect.textAlign};
|
|
105
|
+
`
|
|
106
|
+
: undefined}
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
export const StyledTextEffect = styled(StyledEffect)`
|
|
110
|
+
${({ effect }: IReqoreTextEffectProps) =>
|
|
111
|
+
effect && effect.gradient
|
|
112
|
+
? css`
|
|
113
|
+
display: inline-block;
|
|
114
|
+
-webkit-background-clip: text;
|
|
115
|
+
-webkit-text-fill-color: transparent;
|
|
116
|
+
`
|
|
117
|
+
: undefined}
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
export const ReqoreEffect = ({ children, ...rest }: IReqoreTextEffectProps) => {
|
|
121
|
+
return (
|
|
122
|
+
<StyledEffect className='reqore-effect' {...rest}>
|
|
123
|
+
{children}
|
|
124
|
+
</StyledEffect>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const ReqoreTextEffect = ({ children, ...rest }: IReqoreTextEffectProps) => {
|
|
129
|
+
return (
|
|
130
|
+
<StyledTextEffect className='reqore-text-effect' {...rest}>
|
|
131
|
+
{children}
|
|
132
|
+
</StyledTextEffect>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
2
3
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
3
4
|
import { getReadableColor } from '../../helpers/colors';
|
|
5
|
+
import { IWithReqoreEffect } from '../../types/global';
|
|
6
|
+
import { StyledTextEffect } from '../Effect';
|
|
4
7
|
|
|
5
|
-
export interface
|
|
6
|
-
|
|
8
|
+
export interface IReqoreHeadingProps
|
|
9
|
+
extends IWithReqoreEffect,
|
|
10
|
+
React.HTMLAttributes<HTMLHeadingElement> {
|
|
7
11
|
intent?: TReqoreIntent;
|
|
12
|
+
size?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IReqoreHeadingStyle extends IReqoreHeadingProps {
|
|
16
|
+
theme: IReqoreTheme;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
|
-
const
|
|
19
|
+
export const StyledHeader = styled(StyledTextEffect)`
|
|
11
20
|
margin: 0;
|
|
12
21
|
padding: 0;
|
|
13
|
-
color: ${
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export const ReqoreH1: React.FC<Omit<IReqoreHeaderStyle, 'theme'>> = styled.h1<IReqoreHeaderStyle>`
|
|
17
|
-
${(props) => style(props)};
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
export const ReqoreH2: React.FC<Omit<IReqoreHeaderStyle, 'theme'>> = styled.h2<IReqoreHeaderStyle>`
|
|
21
|
-
${(props) => style(props)};
|
|
22
|
+
color: ${({ theme, intent }) =>
|
|
23
|
+
intent ? theme.intents[intent] : getReadableColor(theme, undefined, undefined, true)};
|
|
22
24
|
`;
|
|
23
25
|
|
|
24
|
-
export const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export const
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
export const ReqoreHeading = ({ size, children, ...props }: IReqoreHeadingProps) => {
|
|
27
|
+
const HTMLheaderElement = useMemo(() => {
|
|
28
|
+
return `h${size}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
29
|
+
}, [size]);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<StyledHeader as={HTMLheaderElement} {...props}>
|
|
33
|
+
{children}
|
|
34
|
+
</StyledHeader>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const ReqoreH1 = (props: IReqoreHeadingProps) => <ReqoreHeading size={1} {...props} />;
|
|
39
|
+
export const ReqoreH2 = (props: IReqoreHeadingProps) => <ReqoreHeading size={2} {...props} />;
|
|
40
|
+
export const ReqoreH3 = (props: IReqoreHeadingProps) => <ReqoreHeading size={3} {...props} />;
|
|
41
|
+
export const ReqoreH4 = (props: IReqoreHeadingProps) => <ReqoreHeading size={4} {...props} />;
|
|
42
|
+
export const ReqoreH5 = (props: IReqoreHeadingProps) => <ReqoreHeading size={5} {...props} />;
|
|
43
|
+
export const ReqoreH6 = (props: IReqoreHeadingProps) => <ReqoreHeading size={6} {...props} />;
|
|
@@ -13,8 +13,10 @@ import {
|
|
|
13
13
|
IReqoreIntent,
|
|
14
14
|
IReqoreReadOnly,
|
|
15
15
|
IWithReqoreCustomTheme,
|
|
16
|
+
IWithReqoreEffect,
|
|
16
17
|
} from '../../types/global';
|
|
17
18
|
import { IReqoreIconName } from '../../types/icons';
|
|
19
|
+
import { StyledEffect } from '../Effect';
|
|
18
20
|
import ReqoreIcon from '../Icon';
|
|
19
21
|
import ReqoreInputClearButton from '../InputClearButton';
|
|
20
22
|
|
|
@@ -23,7 +25,8 @@ export interface IReqoreInputProps
|
|
|
23
25
|
IReqoreDisabled,
|
|
24
26
|
IReqoreReadOnly,
|
|
25
27
|
IReqoreIntent,
|
|
26
|
-
IWithReqoreCustomTheme
|
|
28
|
+
IWithReqoreCustomTheme,
|
|
29
|
+
IWithReqoreEffect {
|
|
27
30
|
autoFocus?: boolean;
|
|
28
31
|
tooltip?: string;
|
|
29
32
|
width?: number;
|
|
@@ -37,6 +40,7 @@ export interface IReqoreInputProps
|
|
|
37
40
|
icon?: IReqoreIconName;
|
|
38
41
|
flat?: boolean;
|
|
39
42
|
rounded?: boolean;
|
|
43
|
+
type?: 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
export interface IReqoreInputStyle extends IReqoreInputProps {
|
|
@@ -66,7 +70,7 @@ const StyledIconWrapper = styled.div<IReqoreInputStyle>`
|
|
|
66
70
|
align-items: center;
|
|
67
71
|
`;
|
|
68
72
|
|
|
69
|
-
export const StyledInput = styled
|
|
73
|
+
export const StyledInput = styled(StyledEffect)<IReqoreInputStyle>`
|
|
70
74
|
height: 100%;
|
|
71
75
|
width: 100%;
|
|
72
76
|
flex: 1;
|
|
@@ -96,25 +100,28 @@ export const StyledInput = styled.input<IReqoreInputStyle>`
|
|
|
96
100
|
: undefined}
|
|
97
101
|
|
|
98
102
|
background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
|
|
99
|
-
minimal ? 'transparent' : rgba(theme.main, 0.
|
|
100
|
-
color: ${({ theme }: IReqoreInputStyle) =>
|
|
103
|
+
minimal ? 'transparent' : rgba(theme.main, 0.1)};
|
|
104
|
+
color: ${({ theme }: IReqoreInputStyle) =>
|
|
105
|
+
getReadableColor(theme, undefined, undefined, true, theme.originalMain)};
|
|
101
106
|
|
|
102
107
|
transition: all 0.2s ease-out;
|
|
103
108
|
|
|
104
109
|
&:active,
|
|
105
110
|
&:focus {
|
|
106
111
|
background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
|
|
107
|
-
minimal ? 'transparent' : rgba(theme.main, 0.
|
|
112
|
+
minimal ? 'transparent' : rgba(theme.main, 0.15)};
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
&::placeholder {
|
|
111
116
|
transition: all 0.2s ease-out;
|
|
112
|
-
color: ${({ theme }) =>
|
|
117
|
+
color: ${({ theme }) =>
|
|
118
|
+
rgba(getReadableColor(theme, undefined, undefined, true, theme.originalMain), 0.3)};
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
&:focus {
|
|
116
122
|
&::placeholder {
|
|
117
|
-
color: ${({ theme }) =>
|
|
123
|
+
color: ${({ theme }) =>
|
|
124
|
+
rgba(getReadableColor(theme, undefined, undefined, true, theme.originalMain), 0.5)};
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
127
|
|
|
@@ -174,6 +181,7 @@ const ReqoreInput = forwardRef(
|
|
|
174
181
|
)}
|
|
175
182
|
<StyledInput
|
|
176
183
|
{...rest}
|
|
184
|
+
as='input'
|
|
177
185
|
theme={theme}
|
|
178
186
|
_size={size}
|
|
179
187
|
minimal={minimal}
|