@qoretechnologies/reqore 0.37.1 → 0.37.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.
Files changed (39) hide show
  1. package/dist/components/Drawer/backdrop.d.ts.map +1 -1
  2. package/dist/components/Drawer/backdrop.js +6 -1
  3. package/dist/components/Drawer/backdrop.js.map +1 -1
  4. package/dist/components/ExportModal/index.d.ts.map +1 -1
  5. package/dist/components/ExportModal/index.js +1 -1
  6. package/dist/components/ExportModal/index.js.map +1 -1
  7. package/dist/components/Tabs/index.d.ts +1 -1
  8. package/dist/components/Tabs/index.d.ts.map +1 -1
  9. package/dist/components/Tabs/item.d.ts.map +1 -1
  10. package/dist/components/Tabs/item.js +2 -3
  11. package/dist/components/Tabs/item.js.map +1 -1
  12. package/dist/components/Tabs/list.d.ts.map +1 -1
  13. package/dist/components/Tabs/list.js +41 -13
  14. package/dist/components/Tabs/list.js.map +1 -1
  15. package/dist/components/Tree/index.d.ts +4 -0
  16. package/dist/components/Tree/index.d.ts.map +1 -1
  17. package/dist/components/Tree/index.js +16 -4
  18. package/dist/components/Tree/index.js.map +1 -1
  19. package/dist/containers/UIProvider.d.ts.map +1 -1
  20. package/dist/containers/UIProvider.js +2 -2
  21. package/dist/containers/UIProvider.js.map +1 -1
  22. package/dist/helpers/utils.js +1 -1
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +4 -2
  26. package/dist/index.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/components/Drawer/backdrop.tsx +6 -1
  29. package/src/components/ExportModal/index.tsx +1 -0
  30. package/src/components/Tabs/index.tsx +1 -1
  31. package/src/components/Tabs/item.tsx +2 -5
  32. package/src/components/Tabs/list.tsx +70 -21
  33. package/src/components/Tree/index.tsx +18 -3
  34. package/src/containers/UIProvider.tsx +3 -2
  35. package/src/helpers/utils.ts +1 -1
  36. package/src/index.tsx +1 -0
  37. package/src/stories/Modal/Manager.stories.tsx +1 -1
  38. package/src/stories/Tabs/Tabs.stories.tsx +2 -2
  39. package/tests.json +1 -1
@@ -2,7 +2,7 @@ import { omit } from 'lodash';
2
2
  import { forwardRef, memo } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
4
  import { IReqoreTabsListItem } from '.';
5
- import { TABS_PADDING_TO_PX, TSizes } from '../../constants/sizes';
5
+ import { TSizes } from '../../constants/sizes';
6
6
  import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
7
7
  import { useCombinedRefs } from '../../hooks/useCombinedRefs';
8
8
  import { useReqoreTheme } from '../../hooks/useTheme';
@@ -29,7 +29,7 @@ export interface IReqoreTabListItemStyle extends IReqoreTabListItemProps {
29
29
  }
30
30
 
31
31
  export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
32
- ${({ disabled, vertical, size, fill, padded }: IReqoreTabListItemStyle) => {
32
+ ${({ disabled, vertical, fill, padded }: IReqoreTabListItemStyle) => {
33
33
  return css`
34
34
  display: flex;
35
35
  flex-shrink: 0;
@@ -37,9 +37,6 @@ export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
37
37
  position: relative;
38
38
  align-items: center;
39
39
  width: ${vertical ? `100%` : undefined};
40
- padding: ${`${TABS_PADDING_TO_PX[size!]}px`};
41
- padding-bottom: ${!vertical && 0};
42
- padding-right: ${vertical && 0};
43
40
 
44
41
  ${vertical
45
42
  ? css`
@@ -1,13 +1,13 @@
1
- import { isArray } from 'lodash';
1
+ import { isArray, isObject } from 'lodash';
2
2
  import React from 'react';
3
3
  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
7
  import {
8
+ GAP_FROM_SIZE,
8
9
  ICON_FROM_SIZE,
9
10
  PADDING_FROM_SIZE,
10
- TABS_PADDING_TO_PX,
11
11
  TEXT_FROM_SIZE,
12
12
  TSizes,
13
13
  } from '../../constants/sizes';
@@ -18,12 +18,14 @@ import {
18
18
  getColorFromMaybeString,
19
19
  getNthGradientColor,
20
20
  } from '../../helpers/colors';
21
- import { calculateStringSizeInPixels } from '../../helpers/utils';
21
+ import { calculateStringSizeInPixels, getOneLessSize } from '../../helpers/utils';
22
22
  import { useReqoreTheme } from '../../hooks/useTheme';
23
+ import { IReqoreButtonProps } from '../Button';
23
24
  import { TReqoreHexColor } from '../Effect';
24
25
  import ReqoreMenu from '../Menu';
25
26
  import ReqoreMenuItem, { IReqoreMenuItemProps } from '../Menu/item';
26
27
  import { StyledPopover } from '../Popover';
28
+ import { IReqoreTagProps } from '../Tag';
27
29
  import ReqoreTabsListItem, { IReqoreTabListItemProps, StyledTabListItem } from './item';
28
30
 
29
31
  export interface IReqoreTabsListProps
@@ -39,20 +41,30 @@ export interface IReqoreTabsListStyle extends Omit<IReqoreTabsListProps, 'tabs'>
39
41
  }
40
42
 
41
43
  export const StyledReqoreTabsList = styled.div<IReqoreTabsListStyle>`
42
- ${({ fill, vertical, currentTabColor, width }) => css`
44
+ ${({ fill, vertical, size, padded, flat, currentTabColor, width }) => css`
43
45
  height: ${vertical ? '100%' : undefined};
44
46
  width: ${vertical ? width || '200px' : '100%'};
45
47
  flex-flow: ${vertical ? 'column' : 'row'};
46
48
  display: flex;
47
49
  align-items: center;
50
+
51
+ gap: ${GAP_FROM_SIZE[size]}px;
52
+
53
+ ${padded &&
54
+ css`
55
+ padding: 0 ${PADDING_FROM_SIZE[size]}px;
56
+ `}
57
+
58
+ ${!flat &&
59
+ css`
48
60
  border-${vertical ? 'right' : 'bottom'}: 1px solid ${changeLightness(currentTabColor, 0.175)};
61
+ `}
49
62
 
50
- ${
51
- fill &&
52
- css`
53
- justify-content: space-around;
54
- `
55
- }
63
+
64
+ ${fill &&
65
+ css`
66
+ justify-content: space-around;
67
+ `}
56
68
 
57
69
  ${StyledPopover} {
58
70
  > ${StyledTabListItem} {
@@ -73,8 +85,27 @@ const getMoreLabel = (items: IReqoreTabsListItem[], activeTab?: string | number)
73
85
  return 'More';
74
86
  };
75
87
 
76
- const getLabel = (
77
- item: IReqoreTabsListItem | IReqoreTabsListItem[],
88
+ const getBadgeLength = (badge: IReqoreButtonProps['badge'], tabsSize: TSizes = 'normal') => {
89
+ if (!badge) {
90
+ return 0;
91
+ }
92
+
93
+ if (isArray(badge)) {
94
+ return badge.reduce((len, b) => len + getBadgeLength(b), 0);
95
+ }
96
+
97
+ if (isObject(badge)) {
98
+ return getLabelLength(badge, undefined, getOneLessSize(tabsSize)) + PADDING_FROM_SIZE[tabsSize];
99
+ }
100
+
101
+ return (
102
+ calculateStringSizeInPixels(badge.toString(), TEXT_FROM_SIZE[getOneLessSize(tabsSize)]) +
103
+ PADDING_FROM_SIZE[tabsSize]
104
+ );
105
+ };
106
+
107
+ const getLabelLength = (
108
+ item: IReqoreTabsListItem | IReqoreTabsListItem[] | IReqoreTagProps,
78
109
  activeTab?: string | number,
79
110
  tabsSize: TSizes = 'normal'
80
111
  ) => {
@@ -82,11 +113,29 @@ const getLabel = (
82
113
  return 0;
83
114
  }
84
115
 
85
- const label: string = isArray(item) ? getMoreLabel(item, activeTab) : item.label;
86
- const icon: number = isArray(item) || item.icon ? ICON_FROM_SIZE[tabsSize] : 0;
87
- const closeIconSize = isArray(item) || !item.onCloseClick ? 0 : ICON_FROM_SIZE[tabsSize] * 2;
116
+ const label: string | number = isArray(item) ? getMoreLabel(item, activeTab) : item.label;
117
+ const icon: number =
118
+ isArray(item) || item.icon ? ICON_FROM_SIZE[tabsSize] + PADDING_FROM_SIZE[tabsSize] : 0;
119
+ const rightIcon = (item as IReqoreTagProps).rightIcon
120
+ ? ICON_FROM_SIZE[tabsSize] + PADDING_FROM_SIZE[tabsSize]
121
+ : 0;
122
+ const closeIconSize =
123
+ isArray(item) ||
124
+ !(item as IReqoreTabsListItem).onCloseClick ||
125
+ !(item as IReqoreTagProps).onRemoveClick
126
+ ? 0
127
+ : ICON_FROM_SIZE[tabsSize] * 2;
128
+ const badgeLength = isArray(item)
129
+ ? 0
130
+ : getBadgeLength((item as IReqoreTabsListItem).badge, tabsSize);
88
131
 
89
- return calculateStringSizeInPixels(label, TEXT_FROM_SIZE[tabsSize]) + icon + closeIconSize;
132
+ return (
133
+ calculateStringSizeInPixels(label?.toString(), TEXT_FROM_SIZE[tabsSize]) +
134
+ icon +
135
+ closeIconSize +
136
+ badgeLength +
137
+ rightIcon
138
+ );
90
139
  };
91
140
 
92
141
  /**
@@ -105,15 +154,15 @@ export const getTabsLength = (
105
154
  ): number =>
106
155
  items.reduce((len, item) => {
107
156
  if (type === 'height') {
108
- const rows = getLabel(item, activeTab, tabsSize) / 4 || 1;
157
+ const rows = getLabelLength(item, activeTab, tabsSize) / 4 || 1;
109
158
 
110
159
  return len + rows * 15 + 10;
111
160
  }
112
161
 
113
162
  const labelLength: number =
114
- PADDING_FROM_SIZE[tabsSize] * 3 +
115
- TABS_PADDING_TO_PX[tabsSize] * 2 +
116
- getLabel(item, activeTab, tabsSize);
163
+ PADDING_FROM_SIZE[tabsSize] * 2 +
164
+ GAP_FROM_SIZE[tabsSize] * 2 +
165
+ getLabelLength(item, activeTab, tabsSize);
117
166
 
118
167
  return len + labelLength;
119
168
  }, 0);
@@ -264,7 +313,7 @@ const ReqoreTabsList = ({
264
313
  } as IReqoreMenuItemProps)}
265
314
  tooltip={tooltip}
266
315
  {...rest}
267
- key={index + label}
316
+ key={index + label?.toString()}
268
317
  >
269
318
  {label}
270
319
  </ReqoreMenuItem>
@@ -2,6 +2,7 @@ import { cloneDeep, size as lodashSize } from 'lodash';
2
2
  import { useMemo, useState } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { ReqoreMessage, ReqorePanel, useReqoreProperty } from '../..';
5
+ import { GAP_FROM_SIZE, TSizes } from '../../constants/sizes';
5
6
  import { IReqoreTheme } from '../../constants/theme';
6
7
  import { getTypeFromValue } from '../../helpers/utils';
7
8
  import { IWithReqoreSize } from '../../types/global';
@@ -28,12 +29,21 @@ export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
28
29
  export interface ITreeStyle {
29
30
  interactive?: boolean;
30
31
  theme: IReqoreTheme;
32
+ level?: number;
33
+ size?: TSizes;
31
34
  }
32
35
 
33
36
  export const StyledTreeLabel = styled(ReqoreMessage)`
34
37
  flex-shrink: 1;
35
38
  `;
36
39
 
40
+ export const StyledTreeWrapper = styled.div<ITreeStyle>`
41
+ display: flex;
42
+ flex-flow: column;
43
+ gap: ${({ size }) => GAP_FROM_SIZE[size]}px;
44
+ margin-left: ${({ level, size }) => (level ? level * GAP_FROM_SIZE[size] : 0)}px;
45
+ `;
46
+
37
47
  export const ReqoreTree = ({
38
48
  data,
39
49
  size = 'normal',
@@ -98,7 +108,7 @@ export const ReqoreTree = ({
98
108
  }
99
109
 
100
110
  return (
101
- <div key={index} style={{ margin: level === 1 ? '15px 0' : `15px` }}>
111
+ <StyledTreeWrapper key={index} size={zoomToSize[zoom]} level={level}>
102
112
  {isObject ? (
103
113
  <ReqoreControlGroup size={zoomToSize[zoom]}>
104
114
  <ReqoreButton
@@ -113,7 +123,7 @@ export const ReqoreTree = ({
113
123
  {_showTypes ? <ReqoreTag label={dataType} className='reqore-tree-type' /> : null}
114
124
  </ReqoreControlGroup>
115
125
  ) : (
116
- <ReqoreControlGroup size={zoomToSize[zoom]}>
126
+ <ReqoreControlGroup size={zoomToSize[zoom]} verticalAlign='flex-start'>
117
127
  <ReqoreTag
118
128
  label={displayKey}
119
129
  actions={
@@ -148,7 +158,7 @@ export const ReqoreTree = ({
148
158
  {isExpandable && isObject
149
159
  ? renderTree(data[key], stateKey, level + 1, [...path, key])
150
160
  : null}
151
- </div>
161
+ </StyledTreeWrapper>
152
162
  );
153
163
  });
154
164
  };
@@ -226,6 +236,11 @@ export const ReqoreTree = ({
226
236
  flat
227
237
  transparent
228
238
  size={size}
239
+ contentStyle={{
240
+ display: 'flex',
241
+ flexFlow: 'column',
242
+ gap: `${GAP_FROM_SIZE[size]}px`,
243
+ }}
229
244
  {...rest}
230
245
  actions={actions}
231
246
  >
@@ -42,19 +42,20 @@ const GlobalStyle = createGlobalStyle`
42
42
  left: 0;
43
43
  right: 0;
44
44
  bottom: 0;
45
- z-index: 999998;
45
+ z-index: 8998;
46
46
  cursor: pointer;
47
47
  background-color: ${({ theme }) => rgba(getMainBackgroundColor(theme), 0.3)};
48
48
  backdrop-filter: blur(3px);
49
49
  }
50
50
 
51
51
  .reqore-blur-z-index {
52
- z-index: 999999;
52
+ z-index: 8999;
53
53
  }
54
54
  `;
55
55
 
56
56
  const StyledPortal = styled.div`
57
57
  z-index: 9999;
58
+ position: relative;
58
59
 
59
60
  * {
60
61
  box-sizing: border-box;
@@ -86,7 +86,7 @@ export const calculateStringSizeInPixels = (value: string = '', fontSize: number
86
86
  /* It's calculating the width of a string in pixels. */
87
87
  return (
88
88
  Array.from(value).reduce((acc, cur) => acc + (widths[cur.charCodeAt(0)] ?? avg), 0) *
89
- (fontSize * 1.15)
89
+ (fontSize * 1.35)
90
90
  );
91
91
  };
92
92
 
package/src/index.tsx CHANGED
@@ -10,6 +10,7 @@ export { ReqoreCommentFeed } from './components/CommentFeed';
10
10
  export { default as ReqoreContent } from './components/Content';
11
11
  export { default as ReqoreControlGroup } from './components/ControlGroup';
12
12
  export { ReqoreDrawer } from './components/Drawer';
13
+ export { ReqoreBackdrop } from './components/Drawer/backdrop';
13
14
  export { default as ReqoreDropdown } from './components/Dropdown';
14
15
  export { ReqoreDropdownDivider, ReqoreDropdownItem } from './components/Dropdown/item';
15
16
  export { ReqoreEffect, ReqoreTextEffect } from './components/Effect';
@@ -117,7 +117,7 @@ export const FromCustomElement: Story = {
117
117
  <ReqoreBackdrop />
118
118
  <div
119
119
  className='custom-modal reqore-modal'
120
- style={{ position: 'absolute', left: '50%', top: '50%' }}
120
+ style={{ position: 'fixed', left: '50%', top: '50%' }}
121
121
  >
122
122
  This is a custom modal
123
123
  </div>
@@ -264,11 +264,11 @@ export const NotFlat: Story = {
264
264
  },
265
265
  };
266
266
 
267
- export const NoTabsPadding: Story = {
267
+ export const WithPadding: Story = {
268
268
  render: Template,
269
269
 
270
270
  args: {
271
- padded: false,
271
+ padded: true,
272
272
  },
273
273
  };
274
274