@qoretechnologies/reqore 0.34.11 → 0.34.13

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.
@@ -15,8 +15,7 @@ import { IReqoreBreadcrumbsTheme, IReqoreTheme, TReqoreIntent } from '../../cons
15
15
  import { changeLightness, getReadableColor, getReadableColorFrom } from '../../helpers/colors';
16
16
  import { calculateStringSizeInPixels } from '../../helpers/utils';
17
17
  import { useReqoreTheme } from '../../hooks/useTheme';
18
- import { TReqoreTooltipProp } from '../../types/global';
19
- import { IReqoreIconName } from '../../types/icons';
18
+ import { IReqoreButtonProps } from '../Button';
20
19
  import ReqoreIcon from '../Icon';
21
20
  import ReqoreMenu from '../Menu';
22
21
  import ReqoreMenuItem from '../Menu/item';
@@ -32,15 +31,11 @@ export interface IReqoreBreadcrumbItemTabs {
32
31
  activeTabIntent?: TReqoreIntent;
33
32
  }
34
33
 
35
- export interface IReqoreBreadcrumbItem {
36
- tooltip?: TReqoreTooltipProp;
34
+ export interface IReqoreBreadcrumbItem extends IReqoreButtonProps {
37
35
  label?: string;
38
- icon?: IReqoreIconName;
39
- active?: boolean;
40
36
  as?: any;
41
37
  props?: React.HTMLAttributes<any>;
42
38
  withTabs?: IReqoreBreadcrumbItemTabs;
43
- customTheme?: IReqoreBreadcrumbsTheme;
44
39
  }
45
40
 
46
41
  export interface IReqoreBreadcrumbsProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -58,14 +53,14 @@ interface IStyledBreadcrumbs extends Omit<IReqoreBreadcrumbsProps, 'items'> {
58
53
  }
59
54
 
60
55
  const StyledReqoreBreadcrumbs = styled.div<IStyledBreadcrumbs>`
61
- ${({ theme, size }: IStyledBreadcrumbs) => css`
56
+ ${({ theme, size, flat }: IStyledBreadcrumbs) => css`
62
57
  width: 100%;
63
- height: ${TABS_SIZE_TO_PX[size!]}px;
58
+ min-height: ${TABS_SIZE_TO_PX[size!]}px;
64
59
  margin: ${MARGIN_FROM_SIZE[size!]}px 0;
65
60
  display: flex;
66
61
  padding: 0 ${PADDING_FROM_SIZE[size!]}px;
67
62
  justify-content: space-between;
68
- border-bottom: 1px solid ${changeLightness(theme.main, 0.05)};
63
+ border-bottom: ${flat ? undefined : `1px solid ${changeLightness(theme.main, 0.05)}`};
69
64
  background-color: ${({ theme }: { theme: IReqoreTheme }) =>
70
65
  theme.breadcrumbs?.main || 'transparent'};
71
66
 
@@ -104,7 +99,6 @@ const StyledBreadcrumbsTabsWrapper = styled.div`
104
99
  width: 100%;
105
100
  `;
106
101
 
107
- const itemPadding = 27;
108
102
  const arrowSize = 50;
109
103
 
110
104
  const getBreadcrumbsLength = (
@@ -119,7 +113,7 @@ const getBreadcrumbsLength = (
119
113
  if (item.withTabs) {
120
114
  return (
121
115
  len +
122
- itemPadding +
116
+ PADDING_FROM_SIZE[size] +
123
117
  arrowSize +
124
118
  getTabsLength(item.withTabs.tabs, 'width', item.withTabs.activeTab, size)
125
119
  );
@@ -127,7 +121,7 @@ const getBreadcrumbsLength = (
127
121
 
128
122
  return (
129
123
  len +
130
- itemPadding +
124
+ PADDING_FROM_SIZE[size] +
131
125
  ICON_FROM_SIZE[size] +
132
126
  arrowSize +
133
127
  calculateStringSizeInPixels(item.label || '', TEXT_FROM_SIZE[size])
@@ -1,20 +1,9 @@
1
- import { forwardRef, useState } from 'react';
2
- import styled, { css } from 'styled-components';
1
+ import { forwardRef } from 'react';
3
2
  import { IReqoreBreadcrumbItem } from '.';
4
- import { PADDING_FROM_SIZE, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
3
+ import { TSizes } from '../../constants/sizes';
5
4
  import { IReqoreTheme } from '../../constants/theme';
6
- import { changeLightness, getReadableColor, getReadableColorFrom } from '../../helpers/colors';
7
- import { useCombinedRefs } from '../../hooks/useCombinedRefs';
8
5
  import { useReqoreTheme } from '../../hooks/useTheme';
9
- import { useTooltip } from '../../hooks/useTooltip';
10
- import { ActiveIconScale, InactiveIconScale } from '../../styles';
11
- import {
12
- StyledActiveContent,
13
- StyledAnimatedTextWrapper,
14
- StyledInActiveContent,
15
- StyledInvisibleContent,
16
- } from '../Button';
17
- import ReqoreIcon from '../Icon';
6
+ import ReqoreButton from '../Button';
18
7
 
19
8
  export interface IReqoreBreadcrumbItemProps extends IReqoreBreadcrumbItem {
20
9
  interactive?: boolean;
@@ -25,131 +14,24 @@ export interface IReqoreBreadcrumbItemStyle extends IReqoreBreadcrumbItemProps {
25
14
  theme: IReqoreTheme;
26
15
  }
27
16
 
28
- const StyledBreadcrumbItem = styled.div<IReqoreBreadcrumbItemStyle>`
29
- ${({ theme, active, interactive, size }: IReqoreBreadcrumbItemStyle) => {
30
- const textColor =
31
- theme.breadcrumbs?.item?.color ||
32
- (theme.breadcrumbs?.main
33
- ? getReadableColorFrom(theme.breadcrumbs.main, true)
34
- : getReadableColor(theme, undefined, undefined, true));
35
-
36
- return css`
37
- display: flex;
38
- flex-shrink: 0;
39
- height: 100%;
40
- justify-content: space-evenly;
41
- align-items: center;
42
- padding: 0 ${PADDING_FROM_SIZE[size!]}px;
43
- transition: background-color 0.15s ease-out;
44
- font-size: ${TEXT_FROM_SIZE[size!]}px;
45
- font-weight: 450;
46
- position: relative;
47
- overflow: hidden;
48
-
49
- * {
50
- color: ${textColor};
51
- }
52
-
53
- ${InactiveIconScale}
54
-
55
- ${active &&
56
- css`
57
- * {
58
- font-weight: 600;
59
- color: ${theme.breadcrumbs?.item?.activeColor ||
60
- (theme.breadcrumbs?.main
61
- ? getReadableColorFrom(theme.breadcrumbs.main, true)
62
- : getReadableColor(theme, undefined, undefined))};
63
- }
64
-
65
- ${ActiveIconScale}
66
- `}
67
-
68
- ${interactive &&
69
- css`
70
- cursor: pointer;
71
- &:hover {
72
- color: ${theme.breadcrumbs?.item?.hoverColor ||
73
- (theme.breadcrumbs?.main
74
- ? getReadableColorFrom(theme.breadcrumbs.main)
75
- : getReadableColor(theme, undefined, undefined))};
76
- background-color: ${changeLightness(theme.breadcrumbs?.main || theme.main, 0.05)};
77
- ${ActiveIconScale}
78
-
79
- ${StyledActiveContent} {
80
- transform: translateY(0px);
81
- filter: blur(0);
82
- opacity: 1;
83
- }
84
-
85
- ${StyledInActiveContent} {
86
- transform: translateY(150%);
87
- filter: blur(10px);
88
- opacity: 0;
89
- }
90
- }
91
- `}
92
-
93
- a:hover {
94
- color: ${theme.breadcrumbs?.item?.hoverColor ||
95
- (theme.breadcrumbs?.main
96
- ? getReadableColorFrom(theme.breadcrumbs?.main)
97
- : getReadableColor(theme, undefined, undefined))};
98
- }
99
- `;
100
- }}
101
-
102
- a {
103
- text-decoration: none;
104
-
105
- &:hover {
106
- text-decoration: underline;
107
- }
108
- }
109
- `;
110
-
111
- const ReqoreBreadcrumbsItem = forwardRef<HTMLDivElement, IReqoreBreadcrumbItemProps>(
112
- (
113
- {
114
- tooltip,
115
- label,
116
- props,
117
- icon,
118
- active,
119
- as,
120
- interactive,
121
- customTheme,
122
- size = 'normal',
123
- }: IReqoreBreadcrumbItemProps,
124
- ref
125
- ) => {
126
- const { targetRef } = useCombinedRefs(ref);
127
- const [itemRef, setItemRef] = useState(undefined);
17
+ const ReqoreBreadcrumbsItem = forwardRef<HTMLButtonElement, IReqoreBreadcrumbItemProps>(
18
+ ({ label, props, as, customTheme, ...rest }: IReqoreBreadcrumbItemProps, ref) => {
128
19
  const theme = useReqoreTheme('breadcrumbs', customTheme);
129
20
 
130
- useTooltip(itemRef, tooltip);
131
-
132
21
  return (
133
- <StyledBreadcrumbItem
134
- ref={(ref) => {
135
- targetRef.current = ref;
136
- setItemRef(ref);
137
- }}
138
- active={active}
139
- interactive={interactive || !!props?.onClick}
22
+ <ReqoreButton
23
+ // @ts-ignore
24
+ as={as}
25
+ ref={ref}
140
26
  className='reqore-breadcrumbs-item'
141
- theme={theme}
142
- size={size}
27
+ customTheme={theme}
28
+ minimal
29
+ flat
30
+ {...rest}
31
+ {...props}
143
32
  >
144
- {icon && <ReqoreIcon icon={icon} size={size} margin={label ? 'right' : undefined} />}
145
- {label && (
146
- <StyledAnimatedTextWrapper as={as || 'span'} {...props}>
147
- <StyledActiveContent>{label}</StyledActiveContent>
148
- <StyledInActiveContent>{label}</StyledInActiveContent>
149
- <StyledInvisibleContent>{label}</StyledInvisibleContent>
150
- </StyledAnimatedTextWrapper>
151
- )}
152
- </StyledBreadcrumbItem>
33
+ {label}
34
+ </ReqoreButton>
153
35
  );
154
36
  }
155
37
  );
@@ -76,6 +76,7 @@ export interface IReqoreButtonProps
76
76
  labelEffect?: IReqoreEffect;
77
77
  descriptionEffect?: IReqoreEffect;
78
78
  label?: React.HTMLAttributes<HTMLButtonElement>['children'];
79
+ as?: string | React.ElementType;
79
80
  }
80
81
 
81
82
  export interface IReqoreButtonStyle extends Omit<IReqoreButtonProps, 'intent'> {
@@ -398,6 +399,7 @@ const ReqoreButton = memo(
398
399
  iconColor,
399
400
  iconsAlign,
400
401
  label,
402
+ as,
401
403
  ...rest
402
404
  }: IReqoreButtonProps,
403
405
  ref
@@ -434,7 +436,7 @@ const ReqoreButton = memo(
434
436
  }
435
437
  }
436
438
  tabindex={rest.disabled ? -1 : 0}
437
- as='button'
439
+ as={as || 'button'}
438
440
  theme={theme}
439
441
  ref={(ref) => {
440
442
  targetRef.current = ref;
@@ -16,14 +16,17 @@ export interface IReqorePaginationComponentProps
16
16
  listPageButtonProps?: IReqoreDropdownProps;
17
17
  controlPageButtonProps?: IReqoreButtonProps;
18
18
  loadMoreButtonProps?: IReqoreButtonProps;
19
+ loadAllButtonProps?: IReqoreButtonProps;
19
20
  firstPageLabel?: string;
20
21
  lastPageLabel?: string;
21
22
  nextPageLabel?: string;
22
23
  previousPageLabel?: string;
23
24
  pageLabel?: string;
24
25
  loadMoreLabel?: string;
26
+ loadAllLabel?: string;
25
27
  showPages?: boolean;
26
28
  showControls?: boolean;
29
+ showLoadAllButton?: boolean;
27
30
  showPagesAs?: 'buttons' | 'list';
28
31
  showLabels?: boolean;
29
32
  scrollOnLoadMore?: boolean;
@@ -66,15 +69,18 @@ function Pagination<T>({
66
69
  listPageButtonProps = {},
67
70
  controlPageButtonProps = {},
68
71
  loadMoreButtonProps = {},
72
+ loadAllButtonProps = {},
69
73
  firstPageLabel = 'First',
70
74
  lastPageLabel = 'Last',
71
75
  nextPageLabel = 'Next',
72
76
  previousPageLabel = 'Back',
73
77
  pageLabel = 'Page',
74
78
  loadMoreLabel = 'Load more',
79
+ loadAllLabel = 'Load all',
75
80
  showLabels,
76
81
  showPages = true,
77
82
  showControls = true,
83
+ showLoadAllButton = true,
78
84
  scrollOnLoadMore,
79
85
  autoLoadMore,
80
86
  itemsPerPage,
@@ -191,19 +197,35 @@ function Pagination<T>({
191
197
  {infinite && !isLastPage ? (
192
198
  <ReqoreControlGroup vertical>
193
199
  <div className='reqore-auto-scroll-target' ref={setScrollTargetRef} />
194
- <ReqoreButton
195
- icon='ArrowDropDownLine'
196
- badge={itemsLeft}
197
- iconsAlign='center'
198
- {...loadMoreButtonProps}
199
- onClick={next}
200
- ref={setLoadMoreRef}
201
- style={{
202
- scrollMarginTop: '200px',
203
- }}
204
- >
205
- {showLabels && loadMoreLabel}
206
- </ReqoreButton>
200
+ <ReqoreControlGroup stack>
201
+ <ReqoreButton
202
+ icon='ArrowDropDownLine'
203
+ badge={itemsPerPage}
204
+ iconsAlign='center'
205
+ {...loadMoreButtonProps}
206
+ onClick={next}
207
+ ref={setLoadMoreRef}
208
+ style={{
209
+ scrollMarginTop: '200px',
210
+ }}
211
+ >
212
+ {showLabels && loadMoreLabel}
213
+ </ReqoreButton>
214
+ {showLoadAllButton && (
215
+ <ReqoreButton
216
+ icon='ArrowDropDownLine'
217
+ badge={itemsLeft}
218
+ iconsAlign='center'
219
+ {...loadAllButtonProps}
220
+ onClick={last}
221
+ style={{
222
+ scrollMarginTop: '200px',
223
+ }}
224
+ >
225
+ {showLabels && loadAllLabel}
226
+ </ReqoreButton>
227
+ )}
228
+ </ReqoreControlGroup>
207
229
  </ReqoreControlGroup>
208
230
  ) : null}
209
231
  {!infinite ? (
@@ -1,5 +1,6 @@
1
1
  import { noop } from 'lodash';
2
2
  import { IReqoreBreadcrumbItem, IReqoreBreadcrumbItemTabs } from '../components/Breadcrumbs';
3
+ import { ReqoreH3 } from '../components/Header';
3
4
  import { Icons } from './icons';
4
5
 
5
6
  export default [
@@ -10,18 +11,21 @@ export default [
10
11
  active: true,
11
12
  },
12
13
  {
13
- label: 'Workflows',
14
- icon: Icons.Workflow,
14
+ label: 'Workflows as Link',
15
15
  tooltip: 'Opens in a new window',
16
16
  as: 'a',
17
17
  props: {
18
18
  href: 'https://google.com',
19
19
  },
20
+ icon: Icons.Workflows,
21
+ flat: false,
22
+ intent: 'info',
20
23
  },
21
24
  {
22
- label: 'Services',
23
25
  icon: Icons.Services,
24
- tooltip: 'Services',
26
+ tooltip: 'Services as H3',
27
+ as: ReqoreH3,
28
+ label: 'Services as H3',
25
29
  props: {
26
30
  onClick: noop,
27
31
  },
@@ -30,6 +34,10 @@ export default [
30
34
  label: 'Jobs',
31
35
  icon: Icons.Jobs,
32
36
  customTheme: '#a9a9a9',
37
+ badge: 10,
38
+ description: 'Some item description',
39
+ intent: 'warning',
40
+ minimal: false,
33
41
  },
34
42
  {
35
43
  tooltip: 'Connections',
@@ -3,6 +3,7 @@ import { IReqoreBreadcrumbItem, IReqoreBreadcrumbsProps } from '../../components
3
3
  import { ReqoreBreadcrumbs } from '../../index';
4
4
  import breadcrumbs, { breadcrumbsTabs } from '../../mock/breadcrumbs';
5
5
  import { buildTemplate } from '../utils';
6
+ import { SizeArg } from '../utils/args';
6
7
 
7
8
  export default {
8
9
  title: 'Components/Breadcrumbs',
@@ -13,6 +14,7 @@ export default {
13
14
  description: 'Whether tabs should be shown alongside the breadcrumbs',
14
15
  control: 'boolean',
15
16
  },
17
+ ...SizeArg,
16
18
  },
17
19
  parameters: {
18
20
  jest: ['breadcrumbs.test.tsx'],
@@ -36,3 +38,4 @@ const Template: ComponentStory<typeof ReqoreBreadcrumbs & { withTabs?: boolean }
36
38
 
37
39
  export const Default = buildTemplate(Template);
38
40
  export const WithTabs = buildTemplate(Template, { withTabs: true });
41
+ export const Flat = buildTemplate(Template, { flat: true });
@@ -174,7 +174,7 @@ export const Infinite: Story<
174
174
  > = Template.bind({});
175
175
  Infinite.args = {
176
176
  showLabels: true,
177
- fluid: true,
177
+ fluid: false,
178
178
  loadMoreButtonProps: {
179
179
  textAlign: 'center',
180
180
  },
@@ -195,6 +195,10 @@ InfiniteWithAutoScroll.args = {
195
195
  textAlign: 'center',
196
196
  size: 'big',
197
197
  },
198
+ loadAllButtonProps: {
199
+ textAlign: 'center',
200
+ size: 'big',
201
+ },
198
202
  loadMoreLabel: 'Load 100 more',
199
203
  pagingOptions: {
200
204
  infinite: true,