@qoretechnologies/reqore 0.43.0 → 0.45.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/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +6 -2
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/DatePicker/index.d.ts +29 -0
- package/dist/components/DatePicker/index.d.ts.map +1 -0
- package/dist/components/DatePicker/index.js +147 -0
- package/dist/components/DatePicker/index.js.map +1 -0
- package/dist/components/Effect/index.d.ts +1 -1
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +3 -1
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +5 -1
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts +2 -0
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +5 -4
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
- package/tests.json +1 -1
- package/.eslintrc.js +0 -40
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
- package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
- package/.github/workflows/beta_release.yml +0 -100
- package/.github/workflows/tests.yml +0 -84
- package/.gitpod.yml +0 -11
- package/.jest-test-results.json +0 -1
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -0
- package/__tests__/breadcrumbs.test.tsx +0 -75
- package/__tests__/button.test.tsx +0 -218
- package/__tests__/checkbox.test.tsx +0 -45
- package/__tests__/collection.test.tsx +0 -243
- package/__tests__/containers/paging.test.tsx +0 -138
- package/__tests__/control_group.test.tsx +0 -32
- package/__tests__/drawer.test.tsx +0 -140
- package/__tests__/dropdown.test.tsx +0 -381
- package/__tests__/effect.test.tsx +0 -70
- package/__tests__/heading.test.tsx +0 -58
- package/__tests__/helpers/colors.test.tsx +0 -18
- package/__tests__/helpers/table.test.tsx +0 -67
- package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
- package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
- package/__tests__/hooks/useTheme.test.tsx +0 -31
- package/__tests__/icon.test.tsx +0 -53
- package/__tests__/input.test.tsx +0 -482
- package/__tests__/layout.test.tsx +0 -37
- package/__tests__/menu.test.tsx +0 -65
- package/__tests__/messages.test.tsx +0 -79
- package/__tests__/modal.test.tsx +0 -204
- package/__tests__/multiselect.test.tsx +0 -458
- package/__tests__/navbar.test.tsx +0 -31
- package/__tests__/notifications.test.tsx +0 -178
- package/__tests__/pagination.test.tsx +0 -437
- package/__tests__/panel.test.tsx +0 -243
- package/__tests__/popover.test.tsx +0 -282
- package/__tests__/radiogroup.test.tsx +0 -47
- package/__tests__/setup.js +0 -8
- package/__tests__/stories/Collection.stories.tsx +0 -0
- package/__tests__/table.test.tsx +0 -647
- package/__tests__/tabs.test.tsx +0 -321
- package/__tests__/tag.test.tsx +0 -160
- package/__tests__/textarea.test.tsx +0 -467
- package/__tests__/timeAgo.test.tsx +0 -27
- package/__tests__/tree.test.tsx +0 -58
- package/build-storybook.log +0 -491
- package/chromatic.config.json +0 -1
- package/icons.ts +0 -1
- package/migration-storybook.log +0 -56
- package/public/logo-dark.png +0 -0
- package/public/logo.png +0 -0
- package/public/q-symbol-small.png +0 -0
- package/public/q-symbol.png +0 -0
- package/public/qoreLogo-dark.png +0 -0
- package/public/qoreLogo.png +0 -0
- package/src/components/Breadcrumbs/index.tsx +0 -254
- package/src/components/Breadcrumbs/item.tsx +0 -44
- package/src/components/Button/index.tsx +0 -628
- package/src/components/Checkbox/index.tsx +0 -388
- package/src/components/Collection/index.tsx +0 -426
- package/src/components/Collection/item.tsx +0 -267
- package/src/components/Columns/column.tsx +0 -27
- package/src/components/Columns/index.tsx +0 -41
- package/src/components/Comment/index.tsx +0 -141
- package/src/components/CommentFeed/index.tsx +0 -34
- package/src/components/Content/index.tsx +0 -34
- package/src/components/Content/wrapper.tsx +0 -36
- package/src/components/ControlGroup/index.tsx +0 -523
- package/src/components/Drawer/backdrop.tsx +0 -54
- package/src/components/Drawer/index.tsx +0 -365
- package/src/components/Dropdown/index.tsx +0 -153
- package/src/components/Dropdown/item.tsx +0 -33
- package/src/components/Dropdown/list.tsx +0 -222
- package/src/components/Effect/index.tsx +0 -463
- package/src/components/ExportModal/index.tsx +0 -99
- package/src/components/Header/index.tsx +0 -81
- package/src/components/Icon/index.tsx +0 -184
- package/src/components/Input/index.tsx +0 -282
- package/src/components/InputClearButton/index.tsx +0 -59
- package/src/components/InternalPopover/index.tsx +0 -303
- package/src/components/KeyValueTable/index.tsx +0 -192
- package/src/components/Label/index.tsx +0 -10
- package/src/components/Layout/content.tsx +0 -31
- package/src/components/Layout/index.tsx +0 -55
- package/src/components/Menu/divider.tsx +0 -92
- package/src/components/Menu/index.tsx +0 -141
- package/src/components/Menu/item.tsx +0 -137
- package/src/components/Menu/section.tsx +0 -81
- package/src/components/Message/index.tsx +0 -220
- package/src/components/Modal/index.tsx +0 -26
- package/src/components/MultiSelect/index.tsx +0 -288
- package/src/components/Navbar/divider.tsx +0 -50
- package/src/components/Navbar/group.tsx +0 -53
- package/src/components/Navbar/index.tsx +0 -82
- package/src/components/Navbar/item.tsx +0 -92
- package/src/components/Notifications/index.tsx +0 -57
- package/src/components/Notifications/notification.tsx +0 -362
- package/src/components/Paging/index.tsx +0 -321
- package/src/components/Panel/LabelEditor.tsx +0 -67
- package/src/components/Panel/NonResponsiveActions.tsx +0 -79
- package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
- package/src/components/Panel/index.tsx +0 -912
- package/src/components/Panel/panel.screenshot.tsx +0 -29
- package/src/components/Paragraph/index.tsx +0 -43
- package/src/components/Popover/index.tsx +0 -68
- package/src/components/RadioGroup/index.tsx +0 -71
- package/src/components/Slider/index.tsx +0 -358
- package/src/components/Spacer/index.tsx +0 -142
- package/src/components/Spinner/index.tsx +0 -74
- package/src/components/Table/body.tsx +0 -109
- package/src/components/Table/cell.tsx +0 -136
- package/src/components/Table/header.tsx +0 -236
- package/src/components/Table/headerCell.tsx +0 -203
- package/src/components/Table/helpers.ts +0 -308
- package/src/components/Table/index.tsx +0 -797
- package/src/components/Table/row.tsx +0 -288
- package/src/components/Table/value.tsx +0 -28
- package/src/components/Tabs/content.tsx +0 -68
- package/src/components/Tabs/index.tsx +0 -124
- package/src/components/Tabs/item.tsx +0 -198
- package/src/components/Tabs/list.tsx +0 -381
- package/src/components/Tag/group.tsx +0 -73
- package/src/components/Tag/index.tsx +0 -463
- package/src/components/Textarea/index.tsx +0 -277
- package/src/components/TimeAgo/index.tsx +0 -15
- package/src/components/Tree/index.tsx +0 -271
- package/src/constants/animations.ts +0 -9
- package/src/constants/colors.ts +0 -13
- package/src/constants/paging.ts +0 -93
- package/src/constants/sizes.ts +0 -185
- package/src/constants/theme.ts +0 -122
- package/src/containers/Paging.tsx +0 -136
- package/src/containers/PopoverProvider.tsx +0 -124
- package/src/containers/ReqoreProvider.tsx +0 -289
- package/src/containers/ThemeProvider.tsx +0 -12
- package/src/containers/UIProvider.tsx +0 -101
- package/src/context/PopoverContext.tsx +0 -11
- package/src/context/ReqoreContext.tsx +0 -47
- package/src/context/ThemeContext.tsx +0 -4
- package/src/helpers/animations.ts +0 -13
- package/src/helpers/colors.ts +0 -335
- package/src/helpers/time.ts +0 -21
- package/src/helpers/utils.ts +0 -152
- package/src/hooks/useAutoFocus.ts +0 -106
- package/src/hooks/useCloneThroughFragments.ts +0 -39
- package/src/hooks/useCombinedRefs.ts +0 -26
- package/src/hooks/useLatestZIndex.ts +0 -13
- package/src/hooks/useOutsideClick.ts +0 -29
- package/src/hooks/usePaging.ts +0 -128
- package/src/hooks/usePopover.tsx +0 -220
- package/src/hooks/useQueryWithDelay.ts +0 -30
- package/src/hooks/useReqore.ts +0 -12
- package/src/hooks/useReqoreContext.ts +0 -16
- package/src/hooks/useReqoreEffect.ts +0 -49
- package/src/hooks/useTextareaAutoSize.ts +0 -22
- package/src/hooks/useTheme.ts +0 -48
- package/src/hooks/useTooltip.ts +0 -40
- package/src/hooks/useWhyDidYouUpdate.ts +0 -32
- package/src/icons.json +0 -2295
- package/src/index.tsx +0 -79
- package/src/mock/breadcrumbs.ts +0 -146
- package/src/mock/collectionData.tsx +0 -380
- package/src/mock/data.json +0 -11000
- package/src/mock/icons.ts +0 -32
- package/src/mock/menu.ts +0 -93
- package/src/mock/multiSelect.ts +0 -71
- package/src/mock/object.json +0 -317
- package/src/mock/styleMock.js +0 -1
- package/src/mock/tableData.ts +0 -64
- package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
- package/src/stories/Button/Button.stories.tsx +0 -405
- package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
- package/src/stories/Collection/Collection.stories.tsx +0 -317
- package/src/stories/Columns/Columns.stories.tsx +0 -158
- package/src/stories/Comment/Comment.stories.tsx +0 -136
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
- package/src/stories/Drawer/Drawer.stories.tsx +0 -294
- package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
- package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
- package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
- package/src/stories/Header/Header.stories.tsx +0 -108
- package/src/stories/Icon/Icon.stories.tsx +0 -162
- package/src/stories/Input/Input.stories.tsx +0 -220
- package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
- package/src/stories/Label/Label.stories.tsx +0 -33
- package/src/stories/Menu/Menu.stories.tsx +0 -367
- package/src/stories/Message/Message.stories.tsx +0 -167
- package/src/stories/Modal/Manager.stories.tsx +0 -192
- package/src/stories/Modal/Modal.stories.tsx +0 -252
- package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
- package/src/stories/Navbar/Navbar.stories.tsx +0 -119
- package/src/stories/Notifications/Interactive.stories.tsx +0 -117
- package/src/stories/Notifications/Notification.stories.tsx +0 -216
- package/src/stories/Notifications/Notifications.stories.tsx +0 -81
- package/src/stories/Paging/Paging.stories.tsx +0 -255
- package/src/stories/Panel/Panel.stories.tsx +0 -753
- package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
- package/src/stories/Popover/Popover.stories.tsx +0 -510
- package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
- package/src/stories/Slider/Slider.stories.tsx +0 -173
- package/src/stories/Spacer/Spacer.stories.tsx +0 -100
- package/src/stories/Spinner/Spinner.stories.tsx +0 -82
- package/src/stories/Table/Table.stories.tsx +0 -571
- package/src/stories/Tabs/Tabs.stories.tsx +0 -346
- package/src/stories/Tag/Tag.stories.tsx +0 -381
- package/src/stories/Tag/TagGroup.stories.tsx +0 -307
- package/src/stories/TextArea/TextArea.stories.tsx +0 -287
- package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
- package/src/stories/Tree/Tree.stories.tsx +0 -124
- package/src/stories/Wrapper.tsx +0 -13
- package/src/stories/utils/args.ts +0 -151
- package/src/stories/utils.ts +0 -39
- package/src/styles.ts +0 -124
- package/src/types/global.ts +0 -211
- package/src/types/icons.ts +0 -2272
- package/tsconfig.prod.json +0 -26
|
@@ -1,628 +0,0 @@
|
|
|
1
|
-
import { size } from 'lodash';
|
|
2
|
-
import { rgba } from 'polished';
|
|
3
|
-
import React, { forwardRef, memo, useCallback, useMemo, useState } from 'react';
|
|
4
|
-
import styled, { css } from 'styled-components';
|
|
5
|
-
import {
|
|
6
|
-
CONTROL_TEXT_FROM_SIZE,
|
|
7
|
-
ICON_FROM_SIZE,
|
|
8
|
-
PADDING_FROM_SIZE,
|
|
9
|
-
PILL_RADIUS_MODIFIER,
|
|
10
|
-
RADIUS_FROM_SIZE,
|
|
11
|
-
SIZE_TO_PX,
|
|
12
|
-
TSizes,
|
|
13
|
-
} from '../../constants/sizes';
|
|
14
|
-
import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
|
|
15
|
-
import { changeLightness, getReadableColor, getReadableColorFrom } from '../../helpers/colors';
|
|
16
|
-
import { alignToFlexAlign, getOneLessSize } from '../../helpers/utils';
|
|
17
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
18
|
-
import { useReqoreProperty } from '../../hooks/useReqoreContext';
|
|
19
|
-
import { useReqoreEffect } from '../../hooks/useReqoreEffect';
|
|
20
|
-
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
21
|
-
import { useTooltip } from '../../hooks/useTooltip';
|
|
22
|
-
import {
|
|
23
|
-
ActiveIconScale,
|
|
24
|
-
DisabledElement,
|
|
25
|
-
InactiveIconScale,
|
|
26
|
-
ReadOnlyElement,
|
|
27
|
-
ScaleIconOnHover,
|
|
28
|
-
StyledActiveContent,
|
|
29
|
-
StyledContent,
|
|
30
|
-
StyledInActiveContent,
|
|
31
|
-
StyledInvisibleContent,
|
|
32
|
-
} from '../../styles';
|
|
33
|
-
import {
|
|
34
|
-
IReqoreDisabled,
|
|
35
|
-
IReqoreIntent,
|
|
36
|
-
IReqoreReadOnly,
|
|
37
|
-
IWithReqoreEffect,
|
|
38
|
-
IWithReqoreSize,
|
|
39
|
-
TReqoreTooltipProp,
|
|
40
|
-
} from '../../types/global';
|
|
41
|
-
import { IReqoreIconName } from '../../types/icons';
|
|
42
|
-
import {
|
|
43
|
-
IReqoreEffect,
|
|
44
|
-
ReqoreTextEffect,
|
|
45
|
-
StyledEffect,
|
|
46
|
-
TReqoreEffectColor,
|
|
47
|
-
TReqoreHexColor,
|
|
48
|
-
} from '../Effect';
|
|
49
|
-
import ReqoreIcon, { IReqoreIconProps } from '../Icon';
|
|
50
|
-
import { ReqoreHorizontalSpacer, ReqoreSpacer } from '../Spacer';
|
|
51
|
-
import ReqoreTag, { IReqoreTagProps } from '../Tag';
|
|
52
|
-
import ReqoreTagGroup from '../Tag/group';
|
|
53
|
-
|
|
54
|
-
export type TReqoreBadge = string | number | IReqoreTagProps;
|
|
55
|
-
|
|
56
|
-
export interface IReqoreButtonProps
|
|
57
|
-
extends React.HTMLAttributes<HTMLButtonElement>,
|
|
58
|
-
IReqoreDisabled,
|
|
59
|
-
IReqoreIntent,
|
|
60
|
-
IReqoreReadOnly,
|
|
61
|
-
IWithReqoreEffect {
|
|
62
|
-
icon?: IReqoreIconName;
|
|
63
|
-
size?: TSizes;
|
|
64
|
-
minimal?: boolean;
|
|
65
|
-
tooltip?: TReqoreTooltipProp;
|
|
66
|
-
fluid?: boolean;
|
|
67
|
-
fixed?: boolean;
|
|
68
|
-
active?: boolean;
|
|
69
|
-
flat?: boolean;
|
|
70
|
-
animated?: boolean;
|
|
71
|
-
|
|
72
|
-
compact?: boolean;
|
|
73
|
-
verticalPadding?: TSizes;
|
|
74
|
-
|
|
75
|
-
rightIcon?: IReqoreIconName;
|
|
76
|
-
customTheme?: IReqoreCustomTheme;
|
|
77
|
-
wrap?: boolean;
|
|
78
|
-
badge?: TReqoreBadge | TReqoreBadge[];
|
|
79
|
-
|
|
80
|
-
description?: string | number;
|
|
81
|
-
maxWidth?: string;
|
|
82
|
-
textAlign?: 'left' | 'center' | 'right';
|
|
83
|
-
iconsAlign?: 'center' | 'sides';
|
|
84
|
-
iconColor?: TReqoreEffectColor;
|
|
85
|
-
leftIconColor?: TReqoreEffectColor;
|
|
86
|
-
rightIconColor?: TReqoreEffectColor;
|
|
87
|
-
leftIconProps?: IReqoreIconProps;
|
|
88
|
-
rightIconProps?: IReqoreIconProps;
|
|
89
|
-
labelEffect?: IReqoreEffect;
|
|
90
|
-
descriptionEffect?: IReqoreEffect;
|
|
91
|
-
label?: React.HTMLAttributes<HTMLButtonElement>['children'];
|
|
92
|
-
as?: string | React.ElementType;
|
|
93
|
-
grow?: 0 | 1 | 2 | 3 | 4;
|
|
94
|
-
shrink?: 0 | 1 | 2 | 3 | 4;
|
|
95
|
-
rounded?: boolean;
|
|
96
|
-
|
|
97
|
-
pill?: boolean;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export interface IReqoreButtonStyle extends Omit<IReqoreButtonProps, 'intent'> {
|
|
101
|
-
theme: IReqoreTheme;
|
|
102
|
-
animate?: boolean;
|
|
103
|
-
color?: TReqoreHexColor;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const getButtonMainColor = (theme: IReqoreTheme, color?: TReqoreHexColor) => {
|
|
107
|
-
if (color) {
|
|
108
|
-
return color;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return theme.main;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const StyledAnimatedTextWrapper = styled.span`
|
|
115
|
-
min-width: 5px;
|
|
116
|
-
overflow: hidden;
|
|
117
|
-
position: relative;
|
|
118
|
-
text-align: ${({ textAlign }) => textAlign};
|
|
119
|
-
display: flex;
|
|
120
|
-
flex-flow: column;
|
|
121
|
-
align-items: ${({ textAlign }) => alignToFlexAlign(textAlign)};
|
|
122
|
-
`;
|
|
123
|
-
|
|
124
|
-
export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
|
|
125
|
-
display: flex;
|
|
126
|
-
flex-flow: column;
|
|
127
|
-
justify-content: center;
|
|
128
|
-
margin: 0;
|
|
129
|
-
font-weight: 600;
|
|
130
|
-
position: relative;
|
|
131
|
-
overflow: hidden;
|
|
132
|
-
vertical-align: middle;
|
|
133
|
-
border: ${({ theme, color, flat }) =>
|
|
134
|
-
!flat ? `1px solid ${changeLightness(getButtonMainColor(theme, color), 0.2)}` : 0};
|
|
135
|
-
padding: ${({ size, compact, verticalPadding }) =>
|
|
136
|
-
`${verticalPadding ? PADDING_FROM_SIZE[verticalPadding] : 0}px ${
|
|
137
|
-
compact ? PADDING_FROM_SIZE[size] / 2 : PADDING_FROM_SIZE[size]
|
|
138
|
-
}px`};
|
|
139
|
-
font-size: ${({ size }) => CONTROL_TEXT_FROM_SIZE[size]}px;
|
|
140
|
-
|
|
141
|
-
min-height: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
142
|
-
min-width: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
143
|
-
max-width: ${({ maxWidth, fluid, fixed }) => maxWidth || (fluid && !fixed ? '100%' : undefined)};
|
|
144
|
-
|
|
145
|
-
${({ wrap, description }) =>
|
|
146
|
-
!wrap && !description
|
|
147
|
-
? css`
|
|
148
|
-
max-height: ${({ size, verticalPadding }) =>
|
|
149
|
-
SIZE_TO_PX[size] + (verticalPadding ? PADDING_FROM_SIZE[verticalPadding] * 2 : 0)}px;
|
|
150
|
-
`
|
|
151
|
-
: null}
|
|
152
|
-
|
|
153
|
-
flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto')};
|
|
154
|
-
flex-shrink: ${({ shrink }) => shrink};
|
|
155
|
-
flex-grow: ${({ grow }) => grow};
|
|
156
|
-
align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
|
|
157
|
-
|
|
158
|
-
border-radius: ${({ size, rounded, pill }) =>
|
|
159
|
-
rounded === false ? undefined : RADIUS_FROM_SIZE[size] * (pill ? PILL_RADIUS_MODIFIER : 1)}px;
|
|
160
|
-
|
|
161
|
-
background-color: ${({ minimal, color }) => {
|
|
162
|
-
if (minimal) {
|
|
163
|
-
return 'transparent';
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return color;
|
|
167
|
-
}};
|
|
168
|
-
|
|
169
|
-
color: ${({ theme, color, minimal }) =>
|
|
170
|
-
color
|
|
171
|
-
? minimal
|
|
172
|
-
? getReadableColor(theme, undefined, undefined, true, theme.originalMain)
|
|
173
|
-
: getReadableColorFrom(color, true)
|
|
174
|
-
: getReadableColor(theme, undefined, undefined, true)};
|
|
175
|
-
|
|
176
|
-
${InactiveIconScale}
|
|
177
|
-
|
|
178
|
-
${({ readOnly, animate, active }) =>
|
|
179
|
-
!readOnly && !active
|
|
180
|
-
? css`
|
|
181
|
-
&:not(:disabled) {
|
|
182
|
-
${ScaleIconOnHover}
|
|
183
|
-
|
|
184
|
-
cursor: pointer;
|
|
185
|
-
transition: all 0.2s ease-out;
|
|
186
|
-
|
|
187
|
-
&:active {
|
|
188
|
-
transform: scale(0.97);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
&:hover,
|
|
192
|
-
&:active,
|
|
193
|
-
&:focus {
|
|
194
|
-
background-color: ${({ theme, color, minimal }: IReqoreButtonStyle) =>
|
|
195
|
-
minimal
|
|
196
|
-
? rgba(changeLightness(getButtonMainColor(theme, color), 0.05), 0.2)
|
|
197
|
-
: changeLightness(getButtonMainColor(theme, color), 0.05)};
|
|
198
|
-
color: ${({ theme, color, minimal }) =>
|
|
199
|
-
getReadableColor(
|
|
200
|
-
{ main: minimal ? theme.originalMain : getButtonMainColor(theme, color) },
|
|
201
|
-
undefined,
|
|
202
|
-
undefined
|
|
203
|
-
)};
|
|
204
|
-
border-color: ${({ flat, theme, color }) =>
|
|
205
|
-
flat ? undefined : changeLightness(getButtonMainColor(theme, color), 0.35)};
|
|
206
|
-
|
|
207
|
-
${animate &&
|
|
208
|
-
css`
|
|
209
|
-
${StyledActiveContent} {
|
|
210
|
-
transform: translateY(0px);
|
|
211
|
-
filter: blur(0);
|
|
212
|
-
opacity: 1;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
${StyledInActiveContent} {
|
|
216
|
-
transform: translateY(150%);
|
|
217
|
-
filter: blur(10px);
|
|
218
|
-
opacity: 0;
|
|
219
|
-
}
|
|
220
|
-
`}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
`
|
|
224
|
-
: readOnly
|
|
225
|
-
? css`
|
|
226
|
-
${ReadOnlyElement};
|
|
227
|
-
`
|
|
228
|
-
: undefined}
|
|
229
|
-
|
|
230
|
-
${({ active, flat, theme, color }: IReqoreButtonStyle) => {
|
|
231
|
-
if (active) {
|
|
232
|
-
return css`
|
|
233
|
-
cursor: pointer;
|
|
234
|
-
background-color: ${changeLightness(getButtonMainColor(theme, color), 0.1)};
|
|
235
|
-
color: ${getReadableColor(
|
|
236
|
-
{ main: changeLightness(getButtonMainColor(theme, color), 0.1) },
|
|
237
|
-
undefined,
|
|
238
|
-
undefined
|
|
239
|
-
)};
|
|
240
|
-
border-color: ${flat
|
|
241
|
-
? undefined
|
|
242
|
-
: changeLightness(getButtonMainColor(theme, color), 0.175)};
|
|
243
|
-
|
|
244
|
-
&:hover,
|
|
245
|
-
&:active,
|
|
246
|
-
&:focus {
|
|
247
|
-
border-color: ${flat
|
|
248
|
-
? undefined
|
|
249
|
-
: changeLightness(getButtonMainColor(theme, color), 0.275)};
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
${ActiveIconScale}
|
|
253
|
-
`;
|
|
254
|
-
}
|
|
255
|
-
}}
|
|
256
|
-
|
|
257
|
-
&:disabled {
|
|
258
|
-
${DisabledElement};
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
&:focus,
|
|
262
|
-
&:active {
|
|
263
|
-
outline: none;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
&:focus {
|
|
267
|
-
border-color: ${({ minimal, theme, color }) =>
|
|
268
|
-
minimal ? undefined : changeLightness(getButtonMainColor(theme, color), 0.4)};
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
.reqore-button-description {
|
|
272
|
-
padding-bottom: ${({ size }) => PADDING_FROM_SIZE[size] / 2}px;
|
|
273
|
-
}
|
|
274
|
-
`;
|
|
275
|
-
|
|
276
|
-
export const StyledButtonContent = styled.div`
|
|
277
|
-
display: flex;
|
|
278
|
-
align-items: center;
|
|
279
|
-
width: 100%;
|
|
280
|
-
height: 100%;
|
|
281
|
-
min-width: ${({ size }) => ICON_FROM_SIZE[size]}px;
|
|
282
|
-
flex: 1;
|
|
283
|
-
flex-shrink: 0;
|
|
284
|
-
padding: ${({ size, flat }) => PADDING_FROM_SIZE[size] / 2 - (!flat ? 1 : 0)}px 0;
|
|
285
|
-
|
|
286
|
-
${({ wrap, description }) =>
|
|
287
|
-
!wrap && !description
|
|
288
|
-
? css`
|
|
289
|
-
max-height: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
290
|
-
`
|
|
291
|
-
: null}
|
|
292
|
-
`;
|
|
293
|
-
|
|
294
|
-
export interface IReqoreButtonBadgeProps extends IWithReqoreSize {
|
|
295
|
-
color?: TReqoreEffectColor;
|
|
296
|
-
theme?: IReqoreTheme;
|
|
297
|
-
content?: TReqoreBadge | TReqoreBadge[];
|
|
298
|
-
wrap?: boolean;
|
|
299
|
-
wrapGroup?: boolean;
|
|
300
|
-
compact?: boolean;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
export const ButtonBadge = memo(({ wrapGroup, compact, ...props }: IReqoreButtonBadgeProps) => {
|
|
304
|
-
const renderTag = useCallback(
|
|
305
|
-
({ size, color, theme, content, key }: IReqoreButtonBadgeProps & { key: number }) => (
|
|
306
|
-
<ReqoreTag
|
|
307
|
-
key={key}
|
|
308
|
-
size={getOneLessSize(size)}
|
|
309
|
-
asBadge
|
|
310
|
-
color={color}
|
|
311
|
-
customTheme={theme}
|
|
312
|
-
className='reqore-button-badge'
|
|
313
|
-
minimal={!(content as IReqoreTagProps)?.effect?.gradient}
|
|
314
|
-
{...(typeof content === 'string' || typeof content === 'number'
|
|
315
|
-
? { label: content }
|
|
316
|
-
: content)}
|
|
317
|
-
/>
|
|
318
|
-
),
|
|
319
|
-
[props]
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
const content = Array.isArray(props.content) ? props.content : [props.content];
|
|
323
|
-
|
|
324
|
-
const leftBadges = content.filter(
|
|
325
|
-
(badge) => typeof badge === 'string' || typeof badge === 'number' || !badge?.align
|
|
326
|
-
);
|
|
327
|
-
const rightBadges = content.filter(
|
|
328
|
-
(badge) => typeof badge !== 'string' && typeof badge !== 'number' && badge?.align === 'right'
|
|
329
|
-
);
|
|
330
|
-
const middleBadges = content.filter(
|
|
331
|
-
(badge) => typeof badge !== 'string' && typeof badge !== 'number' && badge?.align === 'center'
|
|
332
|
-
);
|
|
333
|
-
|
|
334
|
-
const buildContent = (badge: TReqoreBadge) => {
|
|
335
|
-
if (typeof badge === 'string' || typeof badge === 'number') {
|
|
336
|
-
return { label: badge, align: undefined };
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return { ...badge, align: undefined };
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
return (
|
|
343
|
-
<>
|
|
344
|
-
<ReqoreSpacer
|
|
345
|
-
width={props.wrap ? undefined : PADDING_FROM_SIZE[props.size] / (compact ? 2 : 1)}
|
|
346
|
-
height={!props.wrap ? undefined : PADDING_FROM_SIZE[props.size] / 2}
|
|
347
|
-
/>
|
|
348
|
-
{size(leftBadges) ? (
|
|
349
|
-
<ReqoreTagGroup wrap={wrapGroup} align='left'>
|
|
350
|
-
{leftBadges.map((badge, index) =>
|
|
351
|
-
renderTag({ ...props, content: buildContent(badge), key: index })
|
|
352
|
-
)}
|
|
353
|
-
</ReqoreTagGroup>
|
|
354
|
-
) : null}
|
|
355
|
-
{size(middleBadges) ? (
|
|
356
|
-
<ReqoreTagGroup wrap={wrapGroup} fluid align='center'>
|
|
357
|
-
{middleBadges.map((badge, index) =>
|
|
358
|
-
renderTag({ ...props, content: buildContent(badge), key: index })
|
|
359
|
-
)}
|
|
360
|
-
</ReqoreTagGroup>
|
|
361
|
-
) : null}
|
|
362
|
-
{size(rightBadges) ? (
|
|
363
|
-
<ReqoreTagGroup wrap={wrapGroup} align='right'>
|
|
364
|
-
{rightBadges.map((badge, index) =>
|
|
365
|
-
renderTag({ ...props, content: buildContent(badge), key: index })
|
|
366
|
-
)}
|
|
367
|
-
</ReqoreTagGroup>
|
|
368
|
-
) : null}
|
|
369
|
-
</>
|
|
370
|
-
);
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
const ReqoreButton = memo(
|
|
374
|
-
forwardRef<HTMLButtonElement, IReqoreButtonProps>(
|
|
375
|
-
(
|
|
376
|
-
{
|
|
377
|
-
icon,
|
|
378
|
-
size = 'normal',
|
|
379
|
-
minimal,
|
|
380
|
-
children,
|
|
381
|
-
tooltip,
|
|
382
|
-
className,
|
|
383
|
-
fluid,
|
|
384
|
-
fixed,
|
|
385
|
-
intent,
|
|
386
|
-
active,
|
|
387
|
-
flat,
|
|
388
|
-
rightIcon,
|
|
389
|
-
customTheme,
|
|
390
|
-
wrap,
|
|
391
|
-
readOnly,
|
|
392
|
-
badge,
|
|
393
|
-
description,
|
|
394
|
-
maxWidth,
|
|
395
|
-
textAlign = 'left',
|
|
396
|
-
effect,
|
|
397
|
-
labelEffect,
|
|
398
|
-
descriptionEffect,
|
|
399
|
-
leftIconColor,
|
|
400
|
-
rightIconColor,
|
|
401
|
-
iconColor,
|
|
402
|
-
iconsAlign,
|
|
403
|
-
leftIconProps,
|
|
404
|
-
rightIconProps,
|
|
405
|
-
label,
|
|
406
|
-
compact,
|
|
407
|
-
as,
|
|
408
|
-
animated,
|
|
409
|
-
...rest
|
|
410
|
-
}: IReqoreButtonProps,
|
|
411
|
-
ref
|
|
412
|
-
) => {
|
|
413
|
-
const { targetRef } = useCombinedRefs(ref);
|
|
414
|
-
const [buttonRef, setButtonRef] = useState<HTMLButtonElement>(undefined);
|
|
415
|
-
const animations = useReqoreProperty('animations');
|
|
416
|
-
const theme = useReqoreTheme('main', customTheme, intent);
|
|
417
|
-
const fixedEffect = useReqoreEffect('buttons', theme, effect);
|
|
418
|
-
|
|
419
|
-
/* A custom hook that is used to add a tooltip to the button. */
|
|
420
|
-
useTooltip(buttonRef, tooltip);
|
|
421
|
-
|
|
422
|
-
// If color or intent was specified, set the color
|
|
423
|
-
const customColor = intent ? theme.main : changeLightness(theme.main, 0.07);
|
|
424
|
-
const _flat = minimal ? flat : flat !== false;
|
|
425
|
-
const color: TReqoreHexColor = customColor
|
|
426
|
-
? minimal
|
|
427
|
-
? getReadableColor(theme, undefined, undefined, true, theme.originalMain)
|
|
428
|
-
: getReadableColorFrom(customColor, true)
|
|
429
|
-
: getReadableColor(theme, undefined, undefined, true);
|
|
430
|
-
|
|
431
|
-
const _children = useMemo(() => label || children, [label, children]);
|
|
432
|
-
const hasLeftIcon = icon || leftIconProps?.image;
|
|
433
|
-
const hasRightIcon = rightIcon || rightIconProps?.image;
|
|
434
|
-
|
|
435
|
-
const hasRightAlignedBadge = useMemo(() => {
|
|
436
|
-
if (Array.isArray(badge)) {
|
|
437
|
-
return badge.some(
|
|
438
|
-
(badge) =>
|
|
439
|
-
typeof badge !== 'string' && typeof badge !== 'number' && badge?.align === 'right'
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
return typeof badge !== 'string' && typeof badge !== 'number' && badge?.align === 'right';
|
|
444
|
-
}, [badge]);
|
|
445
|
-
|
|
446
|
-
const animate = animated === true || (animations.buttons && animated !== false);
|
|
447
|
-
|
|
448
|
-
return (
|
|
449
|
-
<StyledButton
|
|
450
|
-
{...rest}
|
|
451
|
-
effect={{
|
|
452
|
-
interactive: !readOnly && !rest.disabled,
|
|
453
|
-
...fixedEffect,
|
|
454
|
-
gradient: intent ? undefined : fixedEffect?.gradient,
|
|
455
|
-
}}
|
|
456
|
-
tabindex={rest.disabled ? -1 : 0}
|
|
457
|
-
as={as || 'button'}
|
|
458
|
-
theme={theme}
|
|
459
|
-
ref={(ref) => {
|
|
460
|
-
targetRef.current = ref;
|
|
461
|
-
setButtonRef(ref);
|
|
462
|
-
}}
|
|
463
|
-
fluid={fluid}
|
|
464
|
-
fixed={fixed}
|
|
465
|
-
maxWidth={maxWidth}
|
|
466
|
-
minimal={minimal}
|
|
467
|
-
size={size}
|
|
468
|
-
color={customColor}
|
|
469
|
-
animate={animate}
|
|
470
|
-
flat={_flat}
|
|
471
|
-
active={active}
|
|
472
|
-
readOnly={readOnly}
|
|
473
|
-
wrap={wrap}
|
|
474
|
-
description={description}
|
|
475
|
-
className={`${className || ''} reqore-control reqore-button`}
|
|
476
|
-
compact={compact}
|
|
477
|
-
>
|
|
478
|
-
<StyledButtonContent size={size} wrap={wrap} description={description} flat={_flat}>
|
|
479
|
-
{hasLeftIcon ? (
|
|
480
|
-
<>
|
|
481
|
-
<ReqoreIcon
|
|
482
|
-
icon={icon}
|
|
483
|
-
size={size}
|
|
484
|
-
color={leftIconColor || iconColor}
|
|
485
|
-
compact={compact}
|
|
486
|
-
{...leftIconProps}
|
|
487
|
-
style={
|
|
488
|
-
textAlign !== 'left' || iconsAlign === 'center'
|
|
489
|
-
? {
|
|
490
|
-
marginRight: iconsAlign !== 'center' || !children ? 'auto' : undefined,
|
|
491
|
-
marginLeft:
|
|
492
|
-
iconsAlign === 'center' || (textAlign === 'center' && !_children)
|
|
493
|
-
? 'auto'
|
|
494
|
-
: undefined,
|
|
495
|
-
}
|
|
496
|
-
: undefined
|
|
497
|
-
}
|
|
498
|
-
/>
|
|
499
|
-
{_children || hasRightIcon ? (
|
|
500
|
-
<ReqoreSpacer width={PADDING_FROM_SIZE[size] / (compact ? 2 : 1)} />
|
|
501
|
-
) : null}
|
|
502
|
-
</>
|
|
503
|
-
) : _children ? (
|
|
504
|
-
<ReqoreHorizontalSpacer
|
|
505
|
-
width={1}
|
|
506
|
-
style={textAlign !== 'left' ? { marginRight: 'auto' } : undefined}
|
|
507
|
-
/>
|
|
508
|
-
) : null}
|
|
509
|
-
{_children && (
|
|
510
|
-
<StyledAnimatedTextWrapper
|
|
511
|
-
textAlign={textAlign}
|
|
512
|
-
style={
|
|
513
|
-
textAlign === 'center' && iconsAlign !== 'center' ? { margin: 'auto' } : undefined
|
|
514
|
-
}
|
|
515
|
-
>
|
|
516
|
-
{!animate && (
|
|
517
|
-
<StyledContent
|
|
518
|
-
wrap={wrap}
|
|
519
|
-
effect={labelEffect}
|
|
520
|
-
className='reqore-button-text-content'
|
|
521
|
-
>
|
|
522
|
-
{_children}
|
|
523
|
-
</StyledContent>
|
|
524
|
-
)}
|
|
525
|
-
{animate && (
|
|
526
|
-
<StyledActiveContent
|
|
527
|
-
wrap={wrap}
|
|
528
|
-
effect={labelEffect}
|
|
529
|
-
className='reqore-button-text-content reqore-animated'
|
|
530
|
-
>
|
|
531
|
-
{_children}
|
|
532
|
-
</StyledActiveContent>
|
|
533
|
-
)}
|
|
534
|
-
{animate && (
|
|
535
|
-
<StyledInActiveContent
|
|
536
|
-
wrap={wrap}
|
|
537
|
-
effect={labelEffect}
|
|
538
|
-
className='reqore-button-text-content reqore-animated'
|
|
539
|
-
>
|
|
540
|
-
{_children}
|
|
541
|
-
</StyledInActiveContent>
|
|
542
|
-
)}
|
|
543
|
-
{animate && (
|
|
544
|
-
<StyledInvisibleContent
|
|
545
|
-
wrap={wrap}
|
|
546
|
-
effect={labelEffect}
|
|
547
|
-
className='reqore-button-text-content reqore-animated'
|
|
548
|
-
>
|
|
549
|
-
{_children}
|
|
550
|
-
</StyledInvisibleContent>
|
|
551
|
-
)}
|
|
552
|
-
{(badge || badge === 0) && wrap ? (
|
|
553
|
-
<ButtonBadge content={badge} size={size} theme={theme} wrap />
|
|
554
|
-
) : null}
|
|
555
|
-
</StyledAnimatedTextWrapper>
|
|
556
|
-
)}
|
|
557
|
-
{(badge || badge === 0) && !wrap ? (
|
|
558
|
-
<ButtonBadge
|
|
559
|
-
content={badge}
|
|
560
|
-
size={size}
|
|
561
|
-
theme={theme}
|
|
562
|
-
compact={compact}
|
|
563
|
-
wrapGroup={false}
|
|
564
|
-
wrap={false}
|
|
565
|
-
/>
|
|
566
|
-
) : null}
|
|
567
|
-
{!hasRightIcon ? (
|
|
568
|
-
_children ? (
|
|
569
|
-
<ReqoreHorizontalSpacer
|
|
570
|
-
width={1}
|
|
571
|
-
style={
|
|
572
|
-
textAlign !== 'right' && !hasRightAlignedBadge
|
|
573
|
-
? { marginLeft: 'auto' }
|
|
574
|
-
: undefined
|
|
575
|
-
}
|
|
576
|
-
/>
|
|
577
|
-
) : null
|
|
578
|
-
) : (
|
|
579
|
-
<>
|
|
580
|
-
{_children || badge ? (
|
|
581
|
-
<ReqoreSpacer width={PADDING_FROM_SIZE[size] / (compact ? 2 : 1)} />
|
|
582
|
-
) : null}
|
|
583
|
-
<ReqoreIcon
|
|
584
|
-
icon={rightIcon}
|
|
585
|
-
size={size}
|
|
586
|
-
color={rightIconColor || iconColor}
|
|
587
|
-
compact={compact}
|
|
588
|
-
{...rightIconProps}
|
|
589
|
-
style={
|
|
590
|
-
textAlign !== 'right' || iconsAlign === 'center'
|
|
591
|
-
? {
|
|
592
|
-
marginLeft:
|
|
593
|
-
!hasRightAlignedBadge && (iconsAlign !== 'center' || !_children)
|
|
594
|
-
? 'auto'
|
|
595
|
-
: undefined,
|
|
596
|
-
marginRight:
|
|
597
|
-
iconsAlign === 'center' || (textAlign === 'center' && !_children)
|
|
598
|
-
? 'auto'
|
|
599
|
-
: undefined,
|
|
600
|
-
}
|
|
601
|
-
: undefined
|
|
602
|
-
}
|
|
603
|
-
/>
|
|
604
|
-
</>
|
|
605
|
-
)}
|
|
606
|
-
</StyledButtonContent>
|
|
607
|
-
|
|
608
|
-
{description && (
|
|
609
|
-
<ReqoreTextEffect
|
|
610
|
-
className='reqore-button-description'
|
|
611
|
-
effect={{
|
|
612
|
-
textSize: getOneLessSize(size),
|
|
613
|
-
weight: 'light',
|
|
614
|
-
color: `${color}90`,
|
|
615
|
-
textAlign,
|
|
616
|
-
...descriptionEffect,
|
|
617
|
-
}}
|
|
618
|
-
>
|
|
619
|
-
{description}
|
|
620
|
-
</ReqoreTextEffect>
|
|
621
|
-
)}
|
|
622
|
-
</StyledButton>
|
|
623
|
-
);
|
|
624
|
-
}
|
|
625
|
-
)
|
|
626
|
-
);
|
|
627
|
-
|
|
628
|
-
export default ReqoreButton;
|