@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.
Files changed (151) hide show
  1. package/__tests__/dropdown.test.tsx +133 -12
  2. package/__tests__/effect.test.tsx +70 -0
  3. package/dist/components/Button/index.d.ts +3 -2
  4. package/dist/components/Button/index.d.ts.map +1 -1
  5. package/dist/components/Button/index.js +15 -14
  6. package/dist/components/Button/index.js.map +1 -1
  7. package/dist/components/Collection/item.d.ts +2 -2
  8. package/dist/components/Collection/item.d.ts.map +1 -1
  9. package/dist/components/Collection/item.js +6 -3
  10. package/dist/components/Collection/item.js.map +1 -1
  11. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  12. package/dist/components/ControlGroup/index.js +4 -1
  13. package/dist/components/ControlGroup/index.js.map +1 -1
  14. package/dist/components/Dropdown/index.d.ts +8 -7
  15. package/dist/components/Dropdown/index.d.ts.map +1 -1
  16. package/dist/components/Dropdown/index.js +12 -5
  17. package/dist/components/Dropdown/index.js.map +1 -1
  18. package/dist/components/Dropdown/item.d.ts +2 -2
  19. package/dist/components/Dropdown/item.d.ts.map +1 -1
  20. package/dist/components/Dropdown/item.js.map +1 -1
  21. package/dist/components/Dropdown/list.d.ts +9 -2
  22. package/dist/components/Dropdown/list.d.ts.map +1 -1
  23. package/dist/components/Dropdown/list.js +13 -5
  24. package/dist/components/Dropdown/list.js.map +1 -1
  25. package/dist/components/Effect/index.d.ts +29 -0
  26. package/dist/components/Effect/index.d.ts.map +1 -0
  27. package/dist/components/Effect/index.js +117 -0
  28. package/dist/components/Effect/index.js.map +1 -0
  29. package/dist/components/Header/index.d.ts +14 -8
  30. package/dist/components/Header/index.d.ts.map +1 -1
  31. package/dist/components/Header/index.js +52 -33
  32. package/dist/components/Header/index.js.map +1 -1
  33. package/dist/components/Input/index.d.ts +3 -2
  34. package/dist/components/Input/index.d.ts.map +1 -1
  35. package/dist/components/Input/index.js +8 -7
  36. package/dist/components/Input/index.js.map +1 -1
  37. package/dist/components/InternalPopover/index.d.ts.map +1 -1
  38. package/dist/components/InternalPopover/index.js +0 -1
  39. package/dist/components/InternalPopover/index.js.map +1 -1
  40. package/dist/components/Menu/index.js +1 -1
  41. package/dist/components/Menu/index.js.map +1 -1
  42. package/dist/components/Menu/item.d.ts +5 -11
  43. package/dist/components/Menu/item.d.ts.map +1 -1
  44. package/dist/components/Menu/item.js +4 -4
  45. package/dist/components/Menu/item.js.map +1 -1
  46. package/dist/components/Message/index.d.ts +3 -6
  47. package/dist/components/Message/index.d.ts.map +1 -1
  48. package/dist/components/Message/index.js +2 -1
  49. package/dist/components/Message/index.js.map +1 -1
  50. package/dist/components/Notifications/notification.d.ts +3 -2
  51. package/dist/components/Notifications/notification.d.ts.map +1 -1
  52. package/dist/components/Notifications/notification.js +3 -2
  53. package/dist/components/Notifications/notification.js.map +1 -1
  54. package/dist/components/Panel/index.d.ts +5 -3
  55. package/dist/components/Panel/index.d.ts.map +1 -1
  56. package/dist/components/Panel/index.js +17 -27
  57. package/dist/components/Panel/index.js.map +1 -1
  58. package/dist/components/Popover/index.d.ts +1 -1
  59. package/dist/components/Popover/index.d.ts.map +1 -1
  60. package/dist/components/Popover/index.js +2 -2
  61. package/dist/components/Popover/index.js.map +1 -1
  62. package/dist/components/Tabs/item.d.ts +1 -1
  63. package/dist/components/Tabs/item.d.ts.map +1 -1
  64. package/dist/components/Tabs/item.js +6 -5
  65. package/dist/components/Tabs/item.js.map +1 -1
  66. package/dist/components/Tag/index.d.ts +2 -2
  67. package/dist/components/Tag/index.d.ts.map +1 -1
  68. package/dist/components/Tag/index.js +6 -4
  69. package/dist/components/Tag/index.js.map +1 -1
  70. package/dist/components/Textarea/index.d.ts +2 -2
  71. package/dist/components/Textarea/index.d.ts.map +1 -1
  72. package/dist/components/Textarea/index.js +8 -7
  73. package/dist/components/Textarea/index.js.map +1 -1
  74. package/dist/constants/sizes.d.ts +7 -0
  75. package/dist/constants/sizes.d.ts.map +1 -1
  76. package/dist/constants/sizes.js +8 -1
  77. package/dist/constants/sizes.js.map +1 -1
  78. package/dist/constants/theme.d.ts +1 -0
  79. package/dist/constants/theme.d.ts.map +1 -1
  80. package/dist/constants/theme.js.map +1 -1
  81. package/dist/containers/ReqoreProvider.d.ts +2 -2
  82. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  83. package/dist/containers/ReqoreProvider.js +7 -5
  84. package/dist/containers/ReqoreProvider.js.map +1 -1
  85. package/dist/containers/UIProvider.d.ts +9 -3
  86. package/dist/containers/UIProvider.d.ts.map +1 -1
  87. package/dist/containers/UIProvider.js +3 -2
  88. package/dist/containers/UIProvider.js.map +1 -1
  89. package/dist/context/ReqoreContext.d.ts +2 -0
  90. package/dist/context/ReqoreContext.d.ts.map +1 -1
  91. package/dist/context/ReqoreContext.js +4 -1
  92. package/dist/context/ReqoreContext.js.map +1 -1
  93. package/dist/helpers/colors.js +1 -1
  94. package/dist/helpers/colors.js.map +1 -1
  95. package/dist/hooks/usePopover.d.ts.map +1 -1
  96. package/dist/hooks/usePopover.js +23 -9
  97. package/dist/hooks/usePopover.js.map +1 -1
  98. package/dist/hooks/useWhyDidYouUpdate.d.ts +2 -0
  99. package/dist/hooks/useWhyDidYouUpdate.d.ts.map +1 -0
  100. package/dist/hooks/useWhyDidYouUpdate.js +47 -0
  101. package/dist/hooks/useWhyDidYouUpdate.js.map +1 -0
  102. package/dist/index.d.ts +2 -1
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +6 -2
  105. package/dist/index.js.map +1 -1
  106. package/dist/types/global.d.ts +13 -0
  107. package/dist/types/global.d.ts.map +1 -1
  108. package/package.json +2 -1
  109. package/src/components/Button/index.tsx +34 -23
  110. package/src/components/Collection/item.tsx +6 -3
  111. package/src/components/ControlGroup/index.tsx +1 -0
  112. package/src/components/Dropdown/index.tsx +62 -36
  113. package/src/components/Dropdown/item.tsx +3 -6
  114. package/src/components/Dropdown/list.tsx +82 -56
  115. package/src/components/Effect/index.tsx +134 -0
  116. package/src/components/Header/index.tsx +33 -28
  117. package/src/components/Input/index.tsx +15 -7
  118. package/src/components/InternalPopover/index.tsx +0 -2
  119. package/src/components/Menu/index.tsx +1 -1
  120. package/src/components/Menu/item.tsx +8 -17
  121. package/src/components/Message/index.tsx +13 -5
  122. package/src/components/Notifications/notification.tsx +6 -3
  123. package/src/components/Panel/index.tsx +83 -79
  124. package/src/components/Popover/index.tsx +40 -38
  125. package/src/components/Tabs/item.tsx +92 -79
  126. package/src/components/Tag/index.tsx +16 -7
  127. package/src/components/Textarea/index.tsx +14 -7
  128. package/src/constants/sizes.ts +8 -0
  129. package/src/constants/theme.ts +1 -0
  130. package/src/containers/ReqoreProvider.tsx +16 -8
  131. package/src/containers/UIProvider.tsx +15 -13
  132. package/src/context/ReqoreContext.tsx +5 -0
  133. package/src/helpers/colors.ts +1 -1
  134. package/src/hooks/usePopover.tsx +34 -20
  135. package/src/hooks/useWhyDidYouUpdate.ts +32 -0
  136. package/src/index.tsx +10 -1
  137. package/src/mock/collectionData.tsx +55 -2
  138. package/src/stories/Button/Button.stories.tsx +15 -2
  139. package/src/stories/Collection/Collection.stories.tsx +1 -1
  140. package/src/stories/Dropdown/Dropdown.stories.tsx +62 -34
  141. package/src/stories/Header/Header.stories.tsx +71 -0
  142. package/src/stories/Input/Input.stories.tsx +12 -0
  143. package/src/stories/Menu/Menu.stories.tsx +14 -0
  144. package/src/stories/Message/Message.stories.tsx +13 -0
  145. package/src/stories/Notifications/Notification.stories.tsx +7 -2
  146. package/src/stories/Panel/Panel.stories.tsx +41 -5
  147. package/src/stories/Tabs/Tabs.stories.tsx +23 -23
  148. package/src/stories/Tag/Tag.stories.tsx +16 -0
  149. package/src/stories/TextArea/TextArea.stories.tsx +18 -0
  150. package/src/types/global.ts +14 -0
  151. 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 { IReqoreDropdownItemProps } from './item';
8
- import ReqoreDropdownList from './list';
7
+ import ReqoreDropdownList, { IReqoreDropdownItem, TDropdownItemOnClick } from './list';
9
8
 
10
- export interface IReqoreDropdownProps<T> extends IPopoverOptions {
11
- items?: IReqoreDropdownItemProps[];
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
- width?: string;
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
- const ReqoreDropdown = <T extends unknown = IReqoreButtonProps>({
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<T>) => {
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
- {...rest}
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 { IReqoreMenuItemProps } from '../Menu/item';
3
+ import { IReqoreDropdownItem } from './list';
4
4
 
5
- export interface IReqoreDropdownItemProps extends IReqoreMenuItemProps {}
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?: IReqoreMenuItemProps[];
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
- items,
19
- multiSelect,
20
- listStyle,
21
- _popoverId,
22
- filterable,
23
- width,
24
- height,
25
- }: IReqoreDropdownListProps) => {
26
- const [_items, setItems] = useState<IReqoreMenuItemProps[]>(items);
27
- const [query, setQuery] = useState<string>('');
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
- useEffect(() => {
30
- setItems(items);
31
- }, [items]);
39
+ useEffect(() => {
40
+ setItems(items);
41
+ }, [items]);
32
42
 
33
- const filteredItems: IReqoreMenuItemProps[] = useMemo(() => {
34
- if (!filterable || query === '') {
35
- return _items;
36
- }
43
+ const filteredItems: IReqoreDropdownItem[] = useMemo(() => {
44
+ if (!filterable || query === '') {
45
+ return _items;
46
+ }
37
47
 
38
- return _items.filter((item) => {
39
- const text = item.label || item.children;
48
+ return _items.filter((item) => {
49
+ const text = item.label || item.value || item.children;
40
50
 
41
- if (!text) {
42
- return false;
43
- }
51
+ if (!text) {
52
+ return false;
53
+ }
44
54
 
45
- return text.toString().toLowerCase().indexOf(query.toLowerCase()) !== -1;
46
- });
47
- }, [items, query, _items]);
55
+ return text.toString().toLowerCase().indexOf(query.toLowerCase()) !== -1;
56
+ });
57
+ }, [items, query, _items]);
48
58
 
49
- const handleQueryChange = (event: React.ChangeEvent<HTMLInputElement>) => {
50
- setQuery(event.target.value);
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
- return (
54
- <ReqoreMenu
55
- _insidePopover={!multiSelect}
56
- _popoverId={_popoverId}
57
- style={listStyle}
58
- width={width}
59
- maxHeight={height || '300px'}
60
- >
61
- {filterable && (
62
- <>
63
- <ReqoreInput
64
- value={query}
65
- onChange={handleQueryChange}
66
- placeholder='Filter'
67
- autoFocus
68
- onClearClick={() => setQuery('')}
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
- <ReqoreSpacer height={10} />
71
- </>
72
- )}
73
- {filteredItems.map((item: IReqoreMenuItemProps, index: number) => (
74
- <ReqoreMenuItem key={index} {...item} rightIcon={item.selected ? 'CheckLine' : undefined} />
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 styled, { css } from 'styled-components';
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 IReqoreHeaderStyle extends React.HTMLAttributes<HTMLHeadingElement> {
6
- theme: IReqoreTheme;
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 style = ({ theme, intent }: IReqoreHeaderStyle) => css`
19
+ export const StyledHeader = styled(StyledTextEffect)`
11
20
  margin: 0;
12
21
  padding: 0;
13
- color: ${intent ? theme.intents[intent] : getReadableColor(theme, undefined, undefined, true)};
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 ReqoreH3: React.FC<Omit<IReqoreHeaderStyle, 'theme'>> = styled.h3<IReqoreHeaderStyle>`
25
- ${(props) => style(props)};
26
- `;
27
-
28
- export const ReqoreH4: React.FC<Omit<IReqoreHeaderStyle, 'theme'>> = styled.h4<IReqoreHeaderStyle>`
29
- ${(props) => style(props)};
30
- `;
31
-
32
- export const ReqoreH5: React.FC<Omit<IReqoreHeaderStyle, 'theme'>> = styled.h5<IReqoreHeaderStyle>`
33
- ${(props) => style(props)};
34
- `;
35
-
36
- export const ReqoreH6: React.FC<Omit<IReqoreHeaderStyle, 'theme'>> = styled.h6<IReqoreHeaderStyle>`
37
- ${(props) => style(props)};
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.input<IReqoreInputStyle>`
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.3)};
100
- color: ${({ theme }: IReqoreInputStyle) => getReadableColor(theme)};
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.5)};
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 }) => rgba(getReadableColor(theme), 0.3)};
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 }) => rgba(getReadableColor(theme), 0.5)};
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}
@@ -133,8 +133,6 @@ const InternalPopover: React.FC<IReqoreInternalPopoverProps> = ({
133
133
  ],
134
134
  });
135
135
 
136
- console.log(opaque);
137
-
138
136
  useEffect(() => {
139
137
  if (popperRef.current) {
140
138
  updatePopover?.(id, { popperRef });
@@ -63,7 +63,7 @@ const ReqoreMenu: React.FC<IReqoreMenuProps> = forwardRef(
63
63
  _insidePopover,
64
64
  _popoverId,
65
65
  customTheme: theme,
66
- wrapText,
66
+ wrap: wrapText,
67
67
  })
68
68
  : null
69
69
  )}