@qoretechnologies/reqore 0.27.6 → 0.28.1

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 (120) hide show
  1. package/__tests__/tabs.test.tsx +1 -1
  2. package/dist/components/Breadcrumbs/index.d.ts.map +1 -1
  3. package/dist/components/Breadcrumbs/index.js +4 -5
  4. package/dist/components/Breadcrumbs/index.js.map +1 -1
  5. package/dist/components/Breadcrumbs/item.d.ts.map +1 -1
  6. package/dist/components/Breadcrumbs/item.js +1 -1
  7. package/dist/components/Breadcrumbs/item.js.map +1 -1
  8. package/dist/components/Button/index.d.ts +8 -2
  9. package/dist/components/Button/index.d.ts.map +1 -1
  10. package/dist/components/Button/index.js +49 -29
  11. package/dist/components/Button/index.js.map +1 -1
  12. package/dist/components/Checkbox/index.js +1 -1
  13. package/dist/components/Checkbox/index.js.map +1 -1
  14. package/dist/components/Collection/item.js +1 -1
  15. package/dist/components/Collection/item.js.map +1 -1
  16. package/dist/components/Effect/index.d.ts.map +1 -1
  17. package/dist/components/Effect/index.js +2 -1
  18. package/dist/components/Effect/index.js.map +1 -1
  19. package/dist/components/Header/index.d.ts +2 -1
  20. package/dist/components/Header/index.d.ts.map +1 -1
  21. package/dist/components/Header/index.js +5 -2
  22. package/dist/components/Header/index.js.map +1 -1
  23. package/dist/components/Icon/index.d.ts +2 -1
  24. package/dist/components/Icon/index.d.ts.map +1 -1
  25. package/dist/components/Icon/index.js +17 -6
  26. package/dist/components/Icon/index.js.map +1 -1
  27. package/dist/components/Input/index.js +1 -1
  28. package/dist/components/Input/index.js.map +1 -1
  29. package/dist/components/Menu/index.js +2 -2
  30. package/dist/components/Menu/index.js.map +1 -1
  31. package/dist/components/Message/index.d.ts +2 -3
  32. package/dist/components/Message/index.d.ts.map +1 -1
  33. package/dist/components/Message/index.js +8 -7
  34. package/dist/components/Message/index.js.map +1 -1
  35. package/dist/components/Notifications/notification.d.ts +3 -4
  36. package/dist/components/Notifications/notification.d.ts.map +1 -1
  37. package/dist/components/Notifications/notification.js +23 -20
  38. package/dist/components/Notifications/notification.js.map +1 -1
  39. package/dist/components/Panel/index.d.ts +3 -2
  40. package/dist/components/Panel/index.d.ts.map +1 -1
  41. package/dist/components/Panel/index.js +19 -11
  42. package/dist/components/Panel/index.js.map +1 -1
  43. package/dist/components/Table/row.js +1 -1
  44. package/dist/components/Table/row.js.map +1 -1
  45. package/dist/components/Tabs/index.d.ts +2 -6
  46. package/dist/components/Tabs/index.d.ts.map +1 -1
  47. package/dist/components/Tabs/index.js.map +1 -1
  48. package/dist/components/Tabs/item.d.ts.map +1 -1
  49. package/dist/components/Tabs/item.js +19 -10
  50. package/dist/components/Tabs/item.js.map +1 -1
  51. package/dist/components/Tabs/list.d.ts +8 -0
  52. package/dist/components/Tabs/list.d.ts.map +1 -1
  53. package/dist/components/Tabs/list.js +32 -12
  54. package/dist/components/Tabs/list.js.map +1 -1
  55. package/dist/components/Tag/group.d.ts +2 -1
  56. package/dist/components/Tag/group.d.ts.map +1 -1
  57. package/dist/components/Tag/group.js +8 -4
  58. package/dist/components/Tag/group.js.map +1 -1
  59. package/dist/components/Tag/index.d.ts +3 -2
  60. package/dist/components/Tag/index.d.ts.map +1 -1
  61. package/dist/components/Tag/index.js +50 -25
  62. package/dist/components/Tag/index.js.map +1 -1
  63. package/dist/constants/sizes.d.ts +22 -0
  64. package/dist/constants/sizes.d.ts.map +1 -1
  65. package/dist/constants/sizes.js +36 -14
  66. package/dist/constants/sizes.js.map +1 -1
  67. package/dist/containers/ReqoreProvider.d.ts +1 -1
  68. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  69. package/dist/containers/UIProvider.d.ts.map +1 -1
  70. package/dist/containers/UIProvider.js +1 -1
  71. package/dist/containers/UIProvider.js.map +1 -1
  72. package/dist/helpers/colors.d.ts.map +1 -1
  73. package/dist/helpers/colors.js +8 -4
  74. package/dist/helpers/colors.js.map +1 -1
  75. package/dist/helpers/utils.d.ts +1 -0
  76. package/dist/helpers/utils.d.ts.map +1 -1
  77. package/dist/helpers/utils.js +7 -2
  78. package/dist/helpers/utils.js.map +1 -1
  79. package/dist/styles.d.ts +2 -0
  80. package/dist/styles.d.ts.map +1 -1
  81. package/dist/styles.js +5 -3
  82. package/dist/styles.js.map +1 -1
  83. package/dist/types/global.d.ts +13 -0
  84. package/dist/types/global.d.ts.map +1 -1
  85. package/package.json +1 -1
  86. package/src/components/Breadcrumbs/index.tsx +6 -21
  87. package/src/components/Breadcrumbs/item.tsx +1 -7
  88. package/src/components/Button/index.tsx +112 -58
  89. package/src/components/Checkbox/index.tsx +1 -1
  90. package/src/components/Collection/item.tsx +1 -1
  91. package/src/components/Effect/index.tsx +4 -0
  92. package/src/components/Header/index.tsx +6 -3
  93. package/src/components/Icon/index.tsx +21 -8
  94. package/src/components/Input/index.tsx +1 -1
  95. package/src/components/Menu/index.tsx +6 -6
  96. package/src/components/Message/index.tsx +20 -13
  97. package/src/components/Notifications/notification.tsx +46 -39
  98. package/src/components/Panel/index.tsx +40 -8
  99. package/src/components/Table/row.tsx +1 -1
  100. package/src/components/Tabs/index.tsx +2 -6
  101. package/src/components/Tabs/item.tsx +33 -24
  102. package/src/components/Tabs/list.tsx +47 -15
  103. package/src/components/Tag/group.tsx +22 -5
  104. package/src/components/Tag/index.tsx +120 -45
  105. package/src/constants/sizes.ts +39 -13
  106. package/src/containers/ReqoreProvider.tsx +1 -1
  107. package/src/containers/UIProvider.tsx +3 -0
  108. package/src/helpers/colors.ts +8 -4
  109. package/src/helpers/utils.ts +7 -2
  110. package/src/mock/collectionData.tsx +4 -0
  111. package/src/stories/Button/Button.stories.tsx +43 -17
  112. package/src/stories/ControlGroup/ControlGroup.stories.tsx +2 -2
  113. package/src/stories/Message/Message.stories.tsx +6 -6
  114. package/src/stories/Notifications/Notification.stories.tsx +4 -3
  115. package/src/stories/Panel/Panel.stories.tsx +18 -1
  116. package/src/stories/Tabs/Tabs.stories.tsx +20 -13
  117. package/src/stories/Tag/Tag.stories.tsx +43 -0
  118. package/src/styles.ts +5 -2
  119. package/src/types/global.ts +14 -0
  120. package/tests.json +1 -1
@@ -4,7 +4,13 @@ import { useMeasure } from 'react-use';
4
4
  import styled, { css } from 'styled-components';
5
5
  import { IReqoreTabsListItem, IReqoreTabsProps } from '.';
6
6
  import { ReqorePopover } from '../..';
7
- import { TABS_SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
7
+ import {
8
+ ICON_FROM_SIZE,
9
+ PADDING_FROM_SIZE,
10
+ TABS_PADDING_TO_PX,
11
+ TEXT_FROM_SIZE,
12
+ TSizes,
13
+ } from '../../constants/sizes';
8
14
  import { IReqoreBreadcrumbsTheme, IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
9
15
  import ReqoreThemeProvider from '../../containers/ThemeProvider';
10
16
  import { changeLightness } from '../../helpers/colors';
@@ -28,13 +34,13 @@ export interface IReqoreTabsListStyle extends Omit<IReqoreTabsListProps, 'tabs'>
28
34
  }
29
35
 
30
36
  export const StyledReqoreTabsList = styled.div<IReqoreTabsListStyle>`
31
- ${({ theme, fill, vertical, size, width }) => css`
32
- height: ${vertical ? '100%' : `${TABS_SIZE_TO_PX[size]}px`};
37
+ ${({ fill, vertical, currentTabColor, width }) => css`
38
+ height: ${vertical ? '100%' : undefined};
33
39
  width: ${vertical ? width || '200px' : '100%'};
34
40
  flex-flow: ${vertical ? 'column' : 'row'};
35
41
  display: flex;
36
42
  align-items: center;
37
- border-${vertical ? 'right' : 'bottom'}: 1px solid ${changeLightness(theme.main, 0.05)};
43
+ border-${vertical ? 'right' : 'bottom'}: 1px solid ${changeLightness(currentTabColor, 0.175)};
38
44
 
39
45
  ${
40
46
  fill &&
@@ -72,12 +78,20 @@ const getLabel = (
72
78
  }
73
79
 
74
80
  const label: string = isArray(item) ? getMoreLabel(item, activeTab) : item.label;
75
- const icon: number = isArray(item) || item.icon ? TEXT_FROM_SIZE[tabsSize] : 0;
76
- const closeIconSize = isArray(item) || !item.onCloseClick ? 0 : 30;
81
+ const icon: number = isArray(item) || item.icon ? ICON_FROM_SIZE[tabsSize] : 0;
82
+ const closeIconSize = isArray(item) || !item.onCloseClick ? 0 : ICON_FROM_SIZE[tabsSize] * 2;
77
83
 
78
84
  return calculateStringSizeInPixels(label, TEXT_FROM_SIZE[tabsSize]) + icon + closeIconSize;
79
85
  };
80
86
 
87
+ /**
88
+ * This function returns the total width or height of the tabs.
89
+ * @param items the items that will be rendered in the tabs
90
+ * @param type the type of calculation, either width or height
91
+ * @param activeTab the currently active tab
92
+ * @param tabsSize the size of the tabs
93
+ * @returns the total width or height of the tabs
94
+ */
81
95
  export const getTabsLength = (
82
96
  items: (IReqoreTabsListItem | IReqoreTabsListItem[])[],
83
97
  type: 'width' | 'height' = 'width',
@@ -91,7 +105,12 @@ export const getTabsLength = (
91
105
  return len + rows * 15 + 10;
92
106
  }
93
107
 
94
- return len + 36 + getLabel(item, activeTab, tabsSize);
108
+ const labelLength: number =
109
+ PADDING_FROM_SIZE[tabsSize] * 3 +
110
+ TABS_PADDING_TO_PX[tabsSize] * 2 +
111
+ getLabel(item, activeTab, tabsSize);
112
+
113
+ return len + labelLength;
95
114
  }, 0);
96
115
 
97
116
  const getTransformedItems = (
@@ -142,6 +161,11 @@ const ReqoreTabsList = ({
142
161
  }: IReqoreTabsListProps) => {
143
162
  const [ref, { width, height }] = useMeasure();
144
163
  const theme = useReqoreTheme('main', customTheme, intent);
164
+ const activeTabData = tabs.find((tab) => tab.id === activeTab);
165
+ const currentTabColor =
166
+ activeTabIntent || activeTabData?.intent
167
+ ? theme.intents[activeTabIntent || activeTabData.intent]
168
+ : activeTabData?.customTheme?.main || theme.main;
145
169
 
146
170
  const transformedItems = vertical
147
171
  ? tabs
@@ -164,6 +188,7 @@ const ReqoreTabsList = ({
164
188
  ref={ref}
165
189
  flat={flat}
166
190
  theme={theme}
191
+ currentTabColor={currentTabColor}
167
192
  >
168
193
  {transformedItems.map((item: IReqoreTabsListItem | IReqoreTabsListItem[], index: number) =>
169
194
  isArray(item) ? (
@@ -178,7 +203,11 @@ const ReqoreTabsList = ({
178
203
  label: getMoreLabel(item, activeTab),
179
204
  active: !!isTabHidden(item, activeTab),
180
205
  activeIntent: activeTabIntent,
181
- customTheme: theme,
206
+ customTheme: !!isTabHidden(item, activeTab)
207
+ ? {
208
+ main: currentTabColor,
209
+ }
210
+ : theme,
182
211
  vertical,
183
212
  flat,
184
213
  size,
@@ -203,6 +232,7 @@ const ReqoreTabsList = ({
203
232
  intent,
204
233
  activeIntent,
205
234
  closeIcon,
235
+ ...rest
206
236
  }) => (
207
237
  <ReqoreMenuItem
208
238
  {...({
@@ -212,11 +242,12 @@ const ReqoreTabsList = ({
212
242
  intent: activeTab === id ? activeIntent || intent : intent,
213
243
  disabled,
214
244
  rightIcon: onCloseClick ? closeIcon || 'CloseLine' : undefined,
215
- onRightIconClick: onCloseClick
216
- ? () => {
217
- onCloseClick(id);
218
- }
219
- : undefined,
245
+ onRightIconClick:
246
+ onCloseClick && !disabled
247
+ ? () => {
248
+ onCloseClick(id);
249
+ }
250
+ : undefined,
220
251
  selected: activeTab === id,
221
252
  onClick: (_id, event: React.MouseEvent<any>) => {
222
253
  if (!disabled) {
@@ -229,6 +260,7 @@ const ReqoreTabsList = ({
229
260
  },
230
261
  } as IReqoreMenuItemProps)}
231
262
  tooltip={tooltip}
263
+ {...rest}
232
264
  key={index + label}
233
265
  >
234
266
  {label}
@@ -242,13 +274,13 @@ const ReqoreTabsList = ({
242
274
  ) : (
243
275
  <React.Fragment key={index}>
244
276
  <ReqoreTabsListItem
245
- {...item}
277
+ customTheme={theme}
246
278
  fill={fill}
247
279
  size={size}
248
280
  flat={flat}
249
281
  activeIntent={activeTabIntent}
250
- customTheme={theme}
251
282
  wrapTabNames={wrapTabNames}
283
+ {...item}
252
284
  key={index}
253
285
  vertical={vertical}
254
286
  active={activeTab === item.id}
@@ -7,21 +7,38 @@ export interface IReqoreTagGroup extends React.HTMLAttributes<HTMLDivElement> {
7
7
  children: any;
8
8
  size?: TSizes;
9
9
  columns?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
10
+ hasBottomMargin?: boolean;
10
11
  }
11
12
 
12
13
  const StyledTagGroup = styled.div`
14
+ flex-shrink: 0;
15
+
13
16
  ${StyledTag} {
14
- margin-right: 5px;
15
- margin-bottom: 5px;
17
+ &:not(:last-child) {
18
+ margin-right: 5px;
19
+ }
20
+
21
+ margin-bottom: ${({ hasBottomMargin }) => (hasBottomMargin ? '5px' : '0px')};
16
22
  }
17
23
  `;
18
24
 
19
- const ReqoreTagGroup = ({ children, size, className, columns, ...rest }: IReqoreTagGroup) => (
20
- <StyledTagGroup {...rest} className={`${className || ''} reqore-tag-group`}>
25
+ const ReqoreTagGroup = ({
26
+ children,
27
+ size,
28
+ className,
29
+ columns,
30
+ hasBottomMargin = true,
31
+ ...rest
32
+ }: IReqoreTagGroup) => (
33
+ <StyledTagGroup
34
+ {...rest}
35
+ hasBottomMargin={hasBottomMargin}
36
+ className={`${className || ''} reqore-tag-group`}
37
+ >
21
38
  {React.Children.map(children, (child) =>
22
39
  child
23
40
  ? React.cloneElement(child, {
24
- size,
41
+ size: child.props?.size || size,
25
42
  width: columns ? `calc(${100 / columns}% - 5px)` : child.props.width,
26
43
  })
27
44
  : null
@@ -20,6 +20,7 @@ import {
20
20
  IReqoreDisabled,
21
21
  IReqoreIntent,
22
22
  IWithReqoreEffect,
23
+ IWithReqoreMinimal,
23
24
  IWithReqoreTooltip,
24
25
  } from '../../types/global';
25
26
  import { IReqoreIconName } from '../../types/icons';
@@ -35,7 +36,8 @@ export interface IReqoreTagProps
35
36
  extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'>,
36
37
  IWithReqoreTooltip,
37
38
  IReqoreDisabled,
38
- IWithReqoreEffect {
39
+ IWithReqoreEffect,
40
+ IWithReqoreMinimal {
39
41
  size?: TSizes;
40
42
  label?: string | number;
41
43
  labelKey?: string | number;
@@ -48,6 +50,7 @@ export interface IReqoreTagProps
48
50
  width?: string;
49
51
  badge?: boolean;
50
52
  intent?: TReqoreIntent;
53
+ wrap?: boolean;
51
54
  }
52
55
 
53
56
  export interface IReqoreTagStyle extends IReqoreTagProps {
@@ -60,39 +63,55 @@ export const StyledTag = styled(StyledEffect)<IReqoreTagStyle>`
60
63
  display: inline-flex;
61
64
  justify-content: center;
62
65
  flex-shrink: 0;
63
- align-items: center;
66
+ align-items: stretch;
64
67
  font-family: system-ui;
65
68
  font-weight: 600;
66
69
  overflow: hidden;
67
70
  vertical-align: middle;
68
71
  font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
69
- height: ${({ size, badge }) => (badge ? BADGE_SIZE_TO_PX[size] : SIZE_TO_PX[size])}px;
72
+
70
73
  min-width: ${({ size }) => SIZE_TO_PX[size]}px;
71
74
  border-radius: ${({ badge, size }) => (badge ? 18 : RADIUS_FROM_SIZE[size])}px;
72
75
  width: ${({ width }) => width || undefined};
73
76
  transition: all 0.2s ease-out;
74
77
 
75
- ${({ theme, color, labelKey }) =>
78
+ ${({ wrap, hasWidth }) =>
79
+ wrap || hasWidth
80
+ ? css`
81
+ min-height: ${({ size, badge }) => (badge ? BADGE_SIZE_TO_PX[size] : SIZE_TO_PX[size])}px;
82
+ `
83
+ : css`
84
+ height: ${({ size, badge }) => (badge ? BADGE_SIZE_TO_PX[size] : SIZE_TO_PX[size])}px;
85
+ `}
86
+
87
+ ${({ theme, color, labelKey, minimal }: IReqoreTagStyle) =>
76
88
  css`
77
89
  background-color: ${color || changeLightness(theme.main, 0.1)};
78
- color: ${color ? getReadableColorFrom(color) : getReadableColor(theme, undefined, undefined)};
90
+ color: ${minimal
91
+ ? getReadableColor(theme, undefined, undefined, true, theme.originalMain)
92
+ : color
93
+ ? getReadableColorFrom(color)
94
+ : getReadableColor(theme, undefined, undefined)};
79
95
 
80
- ${StyledTagContentWrapper} {
96
+ ${StyledTagKeyWrapper} {
81
97
  background-color: ${labelKey ? rgba('#000000', 0.2) : undefined};
82
98
  }
83
99
  `}
84
100
 
85
- ${({ theme, color, interactive }) =>
86
- interactive &&
87
- css`
88
- cursor: pointer;
89
- &:hover {
90
- background-color: ${changeLightness(color || theme.main, color ? 0.05 : 0.15)};
91
- color: ${color
92
- ? getReadableColorFrom(color)
93
- : getReadableColor(theme, undefined, undefined)};
94
- }
95
- `}
101
+ ${({ theme, color, interactive, minimal, effect }) =>
102
+ interactive && !effect?.gradient
103
+ ? css`
104
+ cursor: pointer;
105
+ &:hover {
106
+ background-color: ${changeLightness(color || theme.main, color ? 0.05 : 0.15)};
107
+ color: ${minimal
108
+ ? getReadableColor(theme, undefined, undefined, false, theme.originalMain)
109
+ : color
110
+ ? getReadableColorFrom(color)
111
+ : getReadableColor(theme, undefined, undefined)};
112
+ }
113
+ `
114
+ : undefined}
96
115
 
97
116
 
98
117
  ${({ disabled }) =>
@@ -106,34 +125,58 @@ export const StyledTag = styled(StyledEffect)<IReqoreTagStyle>`
106
125
 
107
126
  const StyledTagRightIcon = styled(ReqoreIcon)``;
108
127
 
109
- const StyledTagContentWrapper = styled.div<{ size: TSizes }>`
128
+ const StyledTagKeyWrapper = styled.span<{ size: TSizes }>`
110
129
  display: flex;
111
130
  align-items: center;
112
131
  justify-content: center;
132
+ flex: ${({ hasKey }) => (hasKey ? 1 : undefined)};
113
133
  flex-shrink: 0;
134
+ min-height: 100%;
135
+ `;
136
+
137
+ const StyledTagContentWrapper = styled.span<{ size: TSizes }>`
138
+ display: flex;
139
+ align-items: center;
140
+ justify-content: center;
114
141
  flex: 1;
115
- overflow: hidden;
116
- height: 100%;
142
+ flex-shrink: 0;
143
+ min-height: 100%;
117
144
  `;
118
145
 
119
146
  const StyledTagContent = styled.span<{ size: TSizes }>`
120
- padding: 0 ${({ size }) => PADDING_FROM_SIZE[size]}px;
121
- height: 100%;
147
+ padding: 4px ${({ size }) => PADDING_FROM_SIZE[size]}px;
148
+ min-height: 100%;
122
149
  display: flex;
123
150
  align-items: center;
124
- overflow: hidden;
125
- text-overflow: ellipsis;
126
- white-space: nowrap;
151
+ flex: 1;
152
+
153
+ ${({ wrap, hasWidth }) =>
154
+ !wrap && !hasWidth
155
+ ? css`
156
+ overflow: hidden;
157
+ text-overflow: ellipsis;
158
+ white-space: nowrap;
159
+ `
160
+ : css`
161
+ word-break: break-word;
162
+ `}
127
163
  `;
128
164
 
129
165
  const StyledTagContentKey = styled(StyledTagContent)`
130
166
  font-weight: 800;
167
+ flex: 1;
168
+
169
+ ${({ wrap, hasWidth }) =>
170
+ !wrap && !hasWidth
171
+ ? undefined
172
+ : css`
173
+ word-break: break-word;
174
+ `}
131
175
  `;
132
176
 
133
- const StyledButtonWrapper = styled.div<IReqoreTagStyle>`
177
+ const StyledButtonWrapper = styled.span<IReqoreTagStyle>`
134
178
  flex-shrink: 0;
135
179
  font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
136
- height: ${({ size }) => SIZE_TO_PX[size]}px;
137
180
  width: ${({ size }) => SIZE_TO_PX[size]}px;
138
181
  display: flex;
139
182
  justify-content: center;
@@ -172,6 +215,9 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
172
215
  badge,
173
216
  intent,
174
217
  color,
218
+ minimal,
219
+ wrap = false,
220
+ width,
175
221
  ...rest
176
222
  }: IReqoreTagProps,
177
223
  ref
@@ -182,40 +228,69 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
182
228
  useTooltip(targetRef.current, tooltip);
183
229
 
184
230
  // If color or intent was specified, set the color
185
- const customColor = intent ? theme.intents[intent] : color;
231
+ let customColor = intent ? theme.intents[intent] : color;
232
+ customColor = minimal ? `${customColor || '#000000'}40` : customColor;
186
233
 
187
234
  return (
188
235
  <StyledTag
189
236
  {...rest}
237
+ effect={{
238
+ ...rest.effect,
239
+ interactive: !!onClick && !rest.disabled,
240
+ }}
241
+ width={width}
190
242
  labelKey={labelKey}
191
243
  color={customColor}
192
244
  className={`${className || ''} reqore-tag`}
193
245
  size={size}
194
246
  ref={targetRef}
195
247
  badge={badge}
248
+ minimal={minimal}
196
249
  removable={!!onRemoveClick}
197
250
  interactive={!!onClick && !rest.disabled}
251
+ wrap={wrap}
252
+ hasWidth={!!width}
198
253
  >
199
254
  {icon || labelKey ? (
200
- <StyledTagContentWrapper size={size} className='reqore-tag-content' onClick={onClick}>
201
- {icon && (
202
- <ReqoreIcon
203
- icon={icon}
204
- size={`${TEXT_FROM_SIZE[size]}px`}
205
- margin={label ? 'left' : 'both'}
255
+ <StyledTagKeyWrapper
256
+ size={size}
257
+ className='reqore-tag-key-content'
258
+ onClick={onClick}
259
+ wrap={wrap}
260
+ hasWidth={!!width}
261
+ hasKey={!!labelKey}
262
+ >
263
+ {icon && <ReqoreIcon icon={icon} size={size} margin={label ? 'left' : 'both'} />}
264
+ {labelKey && (
265
+ <StyledTagContentKey wrap={wrap} hasWidth={!!width} size={size}>
266
+ {labelKey}
267
+ </StyledTagContentKey>
268
+ )}
269
+ </StyledTagKeyWrapper>
270
+ ) : null}
271
+ {label || label === 0 || rightIcon ? (
272
+ <StyledTagContentWrapper
273
+ size={size}
274
+ className='reqore-tag-content'
275
+ onClick={onClick}
276
+ wrap={wrap}
277
+ hasWidth={!!width}
278
+ hasKey={!!labelKey}
279
+ >
280
+ {label || label === 0 ? (
281
+ <StyledTagContent size={size} onClick={onClick} wrap={wrap} hasWidth={!!width}>
282
+ {label}
283
+ </StyledTagContent>
284
+ ) : null}
285
+ {rightIcon && (
286
+ <StyledTagRightIcon
287
+ icon={rightIcon}
288
+ size={size}
289
+ margin={label || icon ? 'right' : 'both'}
206
290
  />
207
291
  )}
208
- {labelKey && <StyledTagContentKey size={size}>{labelKey}</StyledTagContentKey>}
209
292
  </StyledTagContentWrapper>
210
293
  ) : null}
211
- {label && <StyledTagContent size={size}>{label}</StyledTagContent>}
212
- {rightIcon && (
213
- <StyledTagRightIcon
214
- icon={rightIcon}
215
- size={`${TEXT_FROM_SIZE[size]}px`}
216
- margin={label || icon ? 'right' : 'both'}
217
- />
218
- )}
219
294
  {_size(actions)
220
295
  ? actions.map((action) => (
221
296
  <>
@@ -234,7 +309,7 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
234
309
  : {})}
235
310
  noWrapper
236
311
  >
237
- <ReqoreIcon icon={action.icon} size={`${TEXT_FROM_SIZE[size]}px`} />
312
+ <ReqoreIcon icon={action.icon} size={size} />
238
313
  </ReqorePopover>
239
314
  </>
240
315
  ))
@@ -251,7 +326,7 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
251
326
  noWrapper
252
327
  content='Remove'
253
328
  >
254
- <ReqoreIcon icon='CloseLine' size={`${TEXT_FROM_SIZE[size]}px`} />
329
+ <ReqoreIcon icon='CloseLine' size={size} />
255
330
  </ReqorePopover>
256
331
  ) : null}
257
332
  </StyledTag>
@@ -1,6 +1,8 @@
1
1
  export type TSizes = 'tiny' | 'small' | 'normal' | 'big' | 'huge';
2
2
  export type TWeights = 'soft' | 'normal' | 'heavy';
3
3
 
4
+ export const SIZES = ['tiny', 'small', 'normal', 'big', 'huge'] as const;
5
+
4
6
  export const SIZE_TO_NUMBER = {
5
7
  tiny: 1,
6
8
  small: 2,
@@ -17,6 +19,14 @@ export const NUMBER_TO_SIZE = {
17
19
  5: 'huge',
18
20
  };
19
21
 
22
+ export const HEADER_SIZE_TO_NUMBER = {
23
+ tiny: 5,
24
+ small: 4,
25
+ normal: 3,
26
+ big: 2,
27
+ huge: 1,
28
+ };
29
+
20
30
  export const SIZE_TO_PX = {
21
31
  tiny: 10,
22
32
  small: 20,
@@ -27,8 +37,8 @@ export const SIZE_TO_PX = {
27
37
 
28
38
  export const BADGE_SIZE_TO_PX = {
29
39
  tiny: 10,
30
- small: 17,
31
- normal: 23,
40
+ small: 18,
41
+ normal: 24,
32
42
  big: 30,
33
43
  huge: 36,
34
44
  };
@@ -73,12 +83,20 @@ export const TEXT_FROM_SIZE = {
73
83
  huge: 21,
74
84
  };
75
85
 
86
+ export const ICON_FROM_SIZE = {
87
+ tiny: 11,
88
+ small: 14,
89
+ normal: 17,
90
+ big: 20,
91
+ huge: 23,
92
+ };
93
+
76
94
  export const PADDING_FROM_SIZE = {
77
- tiny: 2,
78
- small: 5,
79
- normal: 8,
80
- big: 11,
81
- huge: 14,
95
+ tiny: 5,
96
+ small: 8,
97
+ normal: 11,
98
+ big: 14,
99
+ huge: 17,
82
100
  };
83
101
 
84
102
  export const RADIUS_FROM_SIZE = {
@@ -90,12 +108,20 @@ export const RADIUS_FROM_SIZE = {
90
108
  };
91
109
 
92
110
  export const ICON_FROM_HEADER_SIZE = {
93
- 1: 21,
94
- 2: 18,
95
- 3: 15,
96
- 4: 12,
97
- 5: 9,
98
- 6: 6,
111
+ 1: 23,
112
+ 2: 20,
113
+ 3: 17,
114
+ 4: 14,
115
+ 5: 11,
116
+ 6: 8,
117
+ };
118
+
119
+ export const ICON_WRAPPER_FROM_HEADER_SIZE = {
120
+ huge: 34,
121
+ big: 26,
122
+ normal: 19,
123
+ small: 17,
124
+ tiny: 15,
99
125
  };
100
126
 
101
127
  export const WEIGHT_TO_NUMBER = {
@@ -25,7 +25,7 @@ export interface IReqoreNotificationData {
25
25
  type?: IReqoreNotificationType;
26
26
  intent?: TReqoreIntent;
27
27
  flat?: boolean;
28
- inverted?: boolean;
28
+ minimal?: boolean;
29
29
  size?: TSizes;
30
30
  }
31
31
 
@@ -27,6 +27,9 @@ export interface IReqoreUIProviderProps {
27
27
 
28
28
  const StyledPortal = styled.div`
29
29
  z-index: 9999;
30
+ * {
31
+ box-sizing: border-box;
32
+ }
30
33
  `;
31
34
 
32
35
  const ReqoreUIProvider: React.FC<IReqoreUIProviderProps> = ({ children, theme, options }) => {
@@ -108,7 +108,7 @@ export const buildTheme = (theme: IReqoreTheme): IReqoreTheme => {
108
108
  }
109
109
 
110
110
  if (!newTheme.notifications?.muted) {
111
- newTheme.notifications.muted = newTheme.intents.muted || DEFAULT_INTENTS.muted;
111
+ newTheme.notifications.muted = `${newTheme.intents.muted || DEFAULT_INTENTS.muted}30`;
112
112
  }
113
113
 
114
114
  return newTheme;
@@ -122,9 +122,13 @@ export const mergeThemes = (element: string, theme: IReqoreTheme, customTheme: a
122
122
  }
123
123
 
124
124
  if (element === 'main' && customTheme) {
125
- merge(clonedTheme, { main: customTheme.main, originalMain: clonedTheme.main });
125
+ merge(clonedTheme, {
126
+ main: customTheme.main,
127
+ originalMain: clonedTheme.main,
128
+ text: customTheme.text,
129
+ });
126
130
  } else {
127
- merge(clonedTheme, { [element]: customTheme || {} });
131
+ merge(clonedTheme, { [element]: customTheme || {}, text: customTheme.text });
128
132
  }
129
133
 
130
134
  return clonedTheme;
@@ -135,7 +139,7 @@ export const getNotificationIntent = (theme: IReqoreTheme, intent?: TReqoreInten
135
139
  return theme.notifications[intent];
136
140
  }
137
141
 
138
- return theme.main;
142
+ return changeLightness(theme.main, 0.1);
139
143
  };
140
144
 
141
145
  export const getMainBackgroundColor = (theme: IReqoreTheme): string =>
@@ -8,7 +8,7 @@ import {
8
8
  isString,
9
9
  isUndefined,
10
10
  } from 'lodash';
11
- import { NUMBER_TO_SIZE, SIZE_TO_NUMBER, TSizes } from '../constants/sizes';
11
+ import { NUMBER_TO_SIZE, SIZES, SIZE_TO_NUMBER, TSizes } from '../constants/sizes';
12
12
 
13
13
  export const sleep = async (ms: number) => await new Promise((r) => setTimeout(r, ms));
14
14
 
@@ -71,10 +71,15 @@ export const calculateStringSizeInPixels = (value: string = '', fontSize: number
71
71
 
72
72
  /* It's calculating the width of a string in pixels. */
73
73
  return (
74
- Array.from(value).reduce((acc, cur) => acc + (widths[cur.charCodeAt(0)] ?? avg), 0) * fontSize
74
+ Array.from(value).reduce((acc, cur) => acc + (widths[cur.charCodeAt(0)] ?? avg), 0) *
75
+ (fontSize * 1.15)
75
76
  );
76
77
  };
77
78
 
79
+ export const isStringSize = (value: TSizes | string | number) => {
80
+ return SIZES.includes(value as TSizes);
81
+ };
82
+
78
83
  export const getOneLessSize = (size: TSizes): TSizes => {
79
84
  // Get the initial sizes number
80
85
  const initialSizeNumber: number = SIZE_TO_NUMBER[size];
@@ -50,18 +50,22 @@ export default [
50
50
  ],
51
51
  },
52
52
  {
53
+ icon: 'TextWrap',
53
54
  label: 'Item that is not minimal',
54
55
  tooltip: 'This is a test item',
55
56
  content:
56
57
  'Hello I am a test item content and I am very long so I will wrap to the next line and I will be very long',
57
58
  minimal: false,
59
+ badge: 0,
58
60
  },
59
61
  {
62
+ icon: 'FolderWarningFill',
60
63
  label: 'Expandable item',
61
64
  tooltip: 'This is a test item',
62
65
  content:
63
66
  'Hello I am a test item content and I am very long so I will wrap to the next line and I will be very long',
64
67
  expandable: true,
68
+ badge: 10,
65
69
  tags: [
66
70
  {
67
71
  label: 23,