@qoretechnologies/reqore 0.44.0 → 0.46.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 (226) hide show
  1. package/dist/constants/theme.d.ts +8 -1
  2. package/dist/constants/theme.d.ts.map +1 -1
  3. package/dist/constants/theme.js +16 -2
  4. package/dist/constants/theme.js.map +1 -1
  5. package/package.json +1 -1
  6. package/tests.json +1 -1
  7. package/.eslintrc.js +0 -40
  8. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  9. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  10. package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
  11. package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
  12. package/.github/workflows/beta_release.yml +0 -100
  13. package/.github/workflows/tests.yml +0 -84
  14. package/.gitpod.yml +0 -11
  15. package/.jest-test-results.json +0 -1
  16. package/.prettierrc +0 -7
  17. package/.vscode/settings.json +0 -0
  18. package/__tests__/breadcrumbs.test.tsx +0 -75
  19. package/__tests__/button.test.tsx +0 -218
  20. package/__tests__/checkbox.test.tsx +0 -45
  21. package/__tests__/collection.test.tsx +0 -243
  22. package/__tests__/containers/paging.test.tsx +0 -138
  23. package/__tests__/control_group.test.tsx +0 -32
  24. package/__tests__/drawer.test.tsx +0 -140
  25. package/__tests__/dropdown.test.tsx +0 -381
  26. package/__tests__/effect.test.tsx +0 -70
  27. package/__tests__/heading.test.tsx +0 -58
  28. package/__tests__/helpers/colors.test.tsx +0 -18
  29. package/__tests__/helpers/table.test.tsx +0 -67
  30. package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
  31. package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
  32. package/__tests__/hooks/useTheme.test.tsx +0 -31
  33. package/__tests__/icon.test.tsx +0 -53
  34. package/__tests__/input.test.tsx +0 -482
  35. package/__tests__/layout.test.tsx +0 -37
  36. package/__tests__/menu.test.tsx +0 -65
  37. package/__tests__/messages.test.tsx +0 -79
  38. package/__tests__/modal.test.tsx +0 -204
  39. package/__tests__/multiselect.test.tsx +0 -458
  40. package/__tests__/navbar.test.tsx +0 -31
  41. package/__tests__/notifications.test.tsx +0 -178
  42. package/__tests__/pagination.test.tsx +0 -437
  43. package/__tests__/panel.test.tsx +0 -243
  44. package/__tests__/popover.test.tsx +0 -282
  45. package/__tests__/radiogroup.test.tsx +0 -47
  46. package/__tests__/setup.js +0 -8
  47. package/__tests__/stories/Collection.stories.tsx +0 -0
  48. package/__tests__/table.test.tsx +0 -647
  49. package/__tests__/tabs.test.tsx +0 -321
  50. package/__tests__/tag.test.tsx +0 -160
  51. package/__tests__/textarea.test.tsx +0 -467
  52. package/__tests__/timeAgo.test.tsx +0 -27
  53. package/__tests__/tree.test.tsx +0 -58
  54. package/build-storybook.log +0 -491
  55. package/chromatic.config.json +0 -1
  56. package/icons.ts +0 -1
  57. package/migration-storybook.log +0 -56
  58. package/public/logo-dark.png +0 -0
  59. package/public/logo.png +0 -0
  60. package/public/q-symbol-small.png +0 -0
  61. package/public/q-symbol.png +0 -0
  62. package/public/qoreLogo-dark.png +0 -0
  63. package/public/qoreLogo.png +0 -0
  64. package/src/components/Breadcrumbs/index.tsx +0 -254
  65. package/src/components/Breadcrumbs/item.tsx +0 -44
  66. package/src/components/Button/index.tsx +0 -633
  67. package/src/components/Checkbox/index.tsx +0 -388
  68. package/src/components/Collection/index.tsx +0 -426
  69. package/src/components/Collection/item.tsx +0 -267
  70. package/src/components/Columns/column.tsx +0 -27
  71. package/src/components/Columns/index.tsx +0 -41
  72. package/src/components/Comment/index.tsx +0 -141
  73. package/src/components/CommentFeed/index.tsx +0 -34
  74. package/src/components/Content/index.tsx +0 -34
  75. package/src/components/Content/wrapper.tsx +0 -36
  76. package/src/components/ControlGroup/index.tsx +0 -523
  77. package/src/components/DatePicker/index.tsx +0 -347
  78. package/src/components/Drawer/backdrop.tsx +0 -54
  79. package/src/components/Drawer/index.tsx +0 -365
  80. package/src/components/Dropdown/index.tsx +0 -153
  81. package/src/components/Dropdown/item.tsx +0 -33
  82. package/src/components/Dropdown/list.tsx +0 -222
  83. package/src/components/Effect/index.tsx +0 -464
  84. package/src/components/ExportModal/index.tsx +0 -99
  85. package/src/components/Header/index.tsx +0 -81
  86. package/src/components/Icon/index.tsx +0 -184
  87. package/src/components/Input/index.tsx +0 -295
  88. package/src/components/InputClearButton/index.tsx +0 -59
  89. package/src/components/InternalPopover/index.tsx +0 -303
  90. package/src/components/KeyValueTable/index.tsx +0 -192
  91. package/src/components/Label/index.tsx +0 -10
  92. package/src/components/Layout/content.tsx +0 -31
  93. package/src/components/Layout/index.tsx +0 -55
  94. package/src/components/Menu/divider.tsx +0 -92
  95. package/src/components/Menu/index.tsx +0 -141
  96. package/src/components/Menu/item.tsx +0 -137
  97. package/src/components/Menu/section.tsx +0 -81
  98. package/src/components/Message/index.tsx +0 -220
  99. package/src/components/Modal/index.tsx +0 -26
  100. package/src/components/MultiSelect/index.tsx +0 -288
  101. package/src/components/Navbar/divider.tsx +0 -50
  102. package/src/components/Navbar/group.tsx +0 -53
  103. package/src/components/Navbar/index.tsx +0 -82
  104. package/src/components/Navbar/item.tsx +0 -92
  105. package/src/components/Notifications/index.tsx +0 -57
  106. package/src/components/Notifications/notification.tsx +0 -362
  107. package/src/components/Paging/index.tsx +0 -321
  108. package/src/components/Panel/LabelEditor.tsx +0 -67
  109. package/src/components/Panel/NonResponsiveActions.tsx +0 -79
  110. package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
  111. package/src/components/Panel/index.tsx +0 -912
  112. package/src/components/Panel/panel.screenshot.tsx +0 -29
  113. package/src/components/Paragraph/index.tsx +0 -43
  114. package/src/components/Popover/index.tsx +0 -68
  115. package/src/components/RadioGroup/index.tsx +0 -71
  116. package/src/components/Slider/index.tsx +0 -358
  117. package/src/components/Spacer/index.tsx +0 -142
  118. package/src/components/Spinner/index.tsx +0 -74
  119. package/src/components/Table/body.tsx +0 -109
  120. package/src/components/Table/cell.tsx +0 -136
  121. package/src/components/Table/header.tsx +0 -236
  122. package/src/components/Table/headerCell.tsx +0 -203
  123. package/src/components/Table/helpers.ts +0 -308
  124. package/src/components/Table/index.tsx +0 -797
  125. package/src/components/Table/row.tsx +0 -288
  126. package/src/components/Table/value.tsx +0 -28
  127. package/src/components/Tabs/content.tsx +0 -68
  128. package/src/components/Tabs/index.tsx +0 -124
  129. package/src/components/Tabs/item.tsx +0 -198
  130. package/src/components/Tabs/list.tsx +0 -381
  131. package/src/components/Tag/group.tsx +0 -73
  132. package/src/components/Tag/index.tsx +0 -463
  133. package/src/components/Textarea/index.tsx +0 -277
  134. package/src/components/TimeAgo/index.tsx +0 -15
  135. package/src/components/Tree/index.tsx +0 -271
  136. package/src/constants/animations.ts +0 -9
  137. package/src/constants/colors.ts +0 -13
  138. package/src/constants/paging.ts +0 -93
  139. package/src/constants/sizes.ts +0 -185
  140. package/src/constants/theme.ts +0 -122
  141. package/src/containers/Paging.tsx +0 -136
  142. package/src/containers/PopoverProvider.tsx +0 -124
  143. package/src/containers/ReqoreProvider.tsx +0 -289
  144. package/src/containers/ThemeProvider.tsx +0 -12
  145. package/src/containers/UIProvider.tsx +0 -101
  146. package/src/context/PopoverContext.tsx +0 -11
  147. package/src/context/ReqoreContext.tsx +0 -47
  148. package/src/context/ThemeContext.tsx +0 -4
  149. package/src/helpers/animations.ts +0 -13
  150. package/src/helpers/colors.ts +0 -335
  151. package/src/helpers/time.ts +0 -21
  152. package/src/helpers/utils.ts +0 -152
  153. package/src/hooks/useAutoFocus.ts +0 -106
  154. package/src/hooks/useCloneThroughFragments.ts +0 -39
  155. package/src/hooks/useCombinedRefs.ts +0 -26
  156. package/src/hooks/useLatestZIndex.ts +0 -13
  157. package/src/hooks/useOutsideClick.ts +0 -29
  158. package/src/hooks/usePaging.ts +0 -128
  159. package/src/hooks/usePopover.tsx +0 -220
  160. package/src/hooks/useQueryWithDelay.ts +0 -30
  161. package/src/hooks/useReqore.ts +0 -12
  162. package/src/hooks/useReqoreContext.ts +0 -16
  163. package/src/hooks/useReqoreEffect.ts +0 -49
  164. package/src/hooks/useTextareaAutoSize.ts +0 -22
  165. package/src/hooks/useTheme.ts +0 -48
  166. package/src/hooks/useTooltip.ts +0 -40
  167. package/src/hooks/useWhyDidYouUpdate.ts +0 -32
  168. package/src/icons.json +0 -2295
  169. package/src/index.tsx +0 -80
  170. package/src/mock/breadcrumbs.ts +0 -146
  171. package/src/mock/collectionData.tsx +0 -380
  172. package/src/mock/data.json +0 -11000
  173. package/src/mock/icons.ts +0 -32
  174. package/src/mock/menu.ts +0 -93
  175. package/src/mock/multiSelect.ts +0 -71
  176. package/src/mock/object.json +0 -317
  177. package/src/mock/styleMock.js +0 -1
  178. package/src/mock/tableData.ts +0 -64
  179. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
  180. package/src/stories/Button/Button.stories.tsx +0 -405
  181. package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
  182. package/src/stories/Collection/Collection.stories.tsx +0 -317
  183. package/src/stories/Columns/Columns.stories.tsx +0 -158
  184. package/src/stories/Comment/Comment.stories.tsx +0 -136
  185. package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
  186. package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
  187. package/src/stories/Drawer/Drawer.stories.tsx +0 -294
  188. package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
  189. package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
  190. package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
  191. package/src/stories/Header/Header.stories.tsx +0 -108
  192. package/src/stories/Icon/Icon.stories.tsx +0 -162
  193. package/src/stories/Input/Input.stories.tsx +0 -220
  194. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
  195. package/src/stories/Label/Label.stories.tsx +0 -33
  196. package/src/stories/Menu/Menu.stories.tsx +0 -367
  197. package/src/stories/Message/Message.stories.tsx +0 -167
  198. package/src/stories/Modal/Manager.stories.tsx +0 -192
  199. package/src/stories/Modal/Modal.stories.tsx +0 -252
  200. package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
  201. package/src/stories/Navbar/Navbar.stories.tsx +0 -119
  202. package/src/stories/Notifications/Interactive.stories.tsx +0 -117
  203. package/src/stories/Notifications/Notification.stories.tsx +0 -216
  204. package/src/stories/Notifications/Notifications.stories.tsx +0 -81
  205. package/src/stories/Paging/Paging.stories.tsx +0 -255
  206. package/src/stories/Panel/Panel.stories.tsx +0 -753
  207. package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
  208. package/src/stories/Popover/Popover.stories.tsx +0 -510
  209. package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
  210. package/src/stories/Slider/Slider.stories.tsx +0 -173
  211. package/src/stories/Spacer/Spacer.stories.tsx +0 -100
  212. package/src/stories/Spinner/Spinner.stories.tsx +0 -82
  213. package/src/stories/Table/Table.stories.tsx +0 -571
  214. package/src/stories/Tabs/Tabs.stories.tsx +0 -346
  215. package/src/stories/Tag/Tag.stories.tsx +0 -381
  216. package/src/stories/Tag/TagGroup.stories.tsx +0 -307
  217. package/src/stories/TextArea/TextArea.stories.tsx +0 -287
  218. package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
  219. package/src/stories/Tree/Tree.stories.tsx +0 -124
  220. package/src/stories/Wrapper.tsx +0 -13
  221. package/src/stories/utils/args.ts +0 -151
  222. package/src/stories/utils.ts +0 -39
  223. package/src/styles.ts +0 -124
  224. package/src/types/global.ts +0 -211
  225. package/src/types/icons.ts +0 -2272
  226. package/tsconfig.prod.json +0 -26
@@ -1,912 +0,0 @@
1
- import classNames from 'classnames';
2
- import { isArray, omit, size } from 'lodash';
3
- import { darken, rgba } from 'polished';
4
- import { Resizable, ResizableProps } from 're-resizable';
5
- import { ReactElement, forwardRef, useCallback, useMemo, useState } from 'react';
6
- import { useMeasure, useUpdateEffect } from 'react-use';
7
- import styled, { css } from 'styled-components';
8
- import {
9
- GAP_FROM_SIZE,
10
- HEADER_SIZE_TO_NUMBER,
11
- ICON_FROM_HEADER_SIZE,
12
- PADDING_FROM_SIZE,
13
- RADIUS_FROM_SIZE,
14
- SIZE_TO_PX,
15
- TEXT_FROM_SIZE,
16
- TSizes,
17
- } from '../../constants/sizes';
18
- import { IReqoreTheme } from '../../constants/theme';
19
- import {
20
- changeDarkness,
21
- changeLightness,
22
- getMainBackgroundColor,
23
- getReadableColor,
24
- } from '../../helpers/colors';
25
- import { getOneHigherSize, isActionShown } from '../../helpers/utils';
26
- import { useCombinedRefs } from '../../hooks/useCombinedRefs';
27
- import { useReqoreProperty } from '../../hooks/useReqoreContext';
28
- import { useReqoreTheme } from '../../hooks/useTheme';
29
- import { useTooltip } from '../../hooks/useTooltip';
30
- import { ACTIVE_ICON_SCALE, DisabledElement, INACTIVE_ICON_SCALE } from '../../styles';
31
- import {
32
- IReqoreIntent,
33
- IWithReqoreCustomTheme,
34
- IWithReqoreFlat,
35
- IWithReqoreFluid,
36
- IWithReqoreIconImage,
37
- IWithReqoreSize,
38
- IWithReqoreTooltip,
39
- } from '../../types/global';
40
- import { IReqoreIconName } from '../../types/icons';
41
- import ReqoreBreadcrumbs, { IReqoreBreadcrumbsProps } from '../Breadcrumbs';
42
- import ReqoreButton, { ButtonBadge, IReqoreButtonProps, TReqoreBadge } from '../Button';
43
- import { StyledCollectionItemContent } from '../Collection/item';
44
- import ReqoreControlGroup from '../ControlGroup';
45
- import ReqoreDropdown from '../Dropdown';
46
- import { IReqoreDropdownItem } from '../Dropdown/list';
47
- import { IReqoreEffect, StyledEffect, TReqoreEffectColor } from '../Effect';
48
- import { StyledHeader } from '../Header';
49
- import ReqoreIcon, { IReqoreIconProps, StyledIconWrapper } from '../Icon';
50
- import { LabelEditor } from './LabelEditor';
51
- import { ReqorePanelNonResponsiveActions } from './NonResponsiveActions';
52
-
53
- export interface IReqorePanelSubAction extends Omit<IReqoreDropdownItem, 'value'> {}
54
- export interface IReqorePanelAction extends IReqoreButtonProps, IWithReqoreTooltip, IReqoreIntent {
55
- label?: string | number;
56
- onClick?: () => void;
57
- group?: IReqorePanelAction[];
58
- actions?: IReqorePanelSubAction[];
59
- multiSelect?: boolean;
60
- // Custom react element
61
- as?: React.ElementType;
62
- props?: { [key: string | number]: any } | undefined;
63
- // Hide the action if the condition is false
64
- show?: boolean | 'hover';
65
- // Hide the action if the group is too small
66
- responsive?: boolean;
67
- }
68
-
69
- export interface IReqorePanelBottomAction extends IReqorePanelAction {
70
- position?: 'left' | 'right';
71
- }
72
-
73
- export interface IReqorePanelContent {}
74
- export type TReqorePanelActions = IReqorePanelAction[];
75
- export type TReqorePanelBottomActions = IReqorePanelBottomAction[];
76
-
77
- export interface IReqorePanelProps
78
- extends IWithReqoreSize,
79
- IWithReqoreCustomTheme,
80
- IWithReqoreFlat,
81
- IReqoreIntent,
82
- IWithReqoreTooltip,
83
- IWithReqoreFluid,
84
- IWithReqoreIconImage,
85
- React.HTMLAttributes<HTMLDivElement> {
86
- as?: any;
87
- children?: any;
88
- icon?: IReqoreIconName;
89
- iconProps?: IReqoreIconProps;
90
- label?: string | ReactElement<any>;
91
- badge?: TReqoreBadge | TReqoreBadge[];
92
- collapsible?: boolean;
93
- isCollapsed?: boolean;
94
- collapseButtonProps?: IReqoreButtonProps;
95
- disabled?: boolean;
96
-
97
- onLabelEdit?: (label: string | number) => void;
98
- resizable?: ResizableProps;
99
-
100
- breadcrumbs?: IReqoreBreadcrumbsProps;
101
-
102
- onClose?: () => void;
103
- closeButtonProps?: IReqoreButtonProps;
104
-
105
- rounded?: boolean;
106
-
107
- actions?: TReqorePanelActions;
108
- bottomActions?: TReqorePanelBottomActions;
109
- showActionsWhenCollapsed?: boolean;
110
-
111
- unMountContentOnCollapse?: boolean;
112
- onCollapseChange?: (isCollapsed?: boolean) => void;
113
- fill?: boolean;
114
- padded?: boolean;
115
- contentStyle?: React.CSSProperties;
116
- opacity?: number;
117
- blur?: number;
118
- minimal?: boolean;
119
- headerSize?: 1 | 2 | 3 | 4 | 5 | 6;
120
- contentSize?: TSizes;
121
- contentEffect?: IReqoreEffect;
122
- headerEffect?: IReqoreEffect;
123
- transparent?: boolean;
124
- iconColor?: TReqoreEffectColor;
125
- responsiveActions?: boolean;
126
- responsiveTitle?: boolean;
127
- getContentRef?: (ref: HTMLDivElement) => any;
128
-
129
- headerProps?: React.HTMLAttributes<unknown>;
130
- showHeaderTooltip?: boolean;
131
- }
132
-
133
- export interface IStyledPanel extends IReqorePanelProps {
134
- theme: IReqoreTheme;
135
- noHorizontalPadding?: boolean;
136
- }
137
-
138
- export const StyledPanelTitleHeader = styled.div`
139
- display: flex;
140
- justify-content: flex-start;
141
- align-items: center;
142
- flex: 1 1 auto;
143
- width: 100%;
144
- overflow: hidden;
145
- `;
146
-
147
- export const StyledPanelTitleHeaderContent = styled.div`
148
- display: flex;
149
- justify-content: flex-start;
150
- align-items: center;
151
- flex: 0 1 auto;
152
- overflow: hidden;
153
- min-width: ${({ iconSize, hasLabel, hasIcon }) => {
154
- let width = 0;
155
-
156
- if (hasIcon) {
157
- width += iconSize;
158
- }
159
-
160
- if (hasLabel) {
161
- width += 50;
162
- }
163
-
164
- return width;
165
- }}px;
166
-
167
- ${StyledHeader} {
168
- min-width: 50px;
169
- }
170
- `;
171
-
172
- export type TPanelStyle = React.FC<
173
- Omit<IReqorePanelProps, 'onResize' | 'size'> &
174
- ResizableProps & {
175
- ref?: any;
176
- theme: IReqoreTheme;
177
- effect: IReqoreEffect;
178
- interactive?: boolean;
179
- }
180
- >;
181
-
182
- export const StyledPanel: TPanelStyle = styled(StyledEffect)<IStyledPanel>`
183
- background-color: ${({ theme, opacity = 1 }: IStyledPanel) =>
184
- rgba(changeDarkness(getMainBackgroundColor(theme), 0.03), opacity)};
185
- border-radius: ${({ rounded }) => (rounded ? RADIUS_FROM_SIZE.normal : 0)}px;
186
- border: ${({ theme, flat, intent }) =>
187
- flat && !intent
188
- ? undefined
189
- : `1px solid ${changeLightness(
190
- intent ? theme.intents[intent] : getMainBackgroundColor(theme),
191
- 0.2
192
- )}`};
193
- color: ${({ theme }) => getReadableColor(theme, undefined, undefined, true)};
194
- overflow: hidden;
195
- display: flex;
196
- flex-flow: column;
197
- position: relative;
198
- backdrop-filter: ${({ blur, opacity }) => (blur && opacity < 1 ? `blur(${blur}px)` : undefined)};
199
- width: ${({ fluid }) => (fluid ? '100%' : undefined)};
200
- max-width: 100%;
201
- flex: ${({ fluid }) => (fluid ? '1 auto' : '0 0 auto')};
202
-
203
- &:not(:hover) {
204
- .reqore-panel-action-hidden {
205
- display: none;
206
- }
207
- }
208
-
209
- ${({ interactive, theme, opacity = 1, flat, intent }) =>
210
- interactive
211
- ? css`
212
- cursor: pointer;
213
-
214
- &:hover {
215
- ${StyledPanelTitle} ${StyledPanelTitleHeaderContent} > ${StyledIconWrapper} {
216
- transform: scale(${ACTIVE_ICON_SCALE});
217
- }
218
-
219
- background-color: ${opacity === 0 && flat
220
- ? undefined
221
- : rgba(
222
- darken(0.025, rgba(changeDarkness(getMainBackgroundColor(theme), 0.03), opacity)),
223
- opacity
224
- )};
225
-
226
- border-color: ${flat && !intent
227
- ? undefined
228
- : `${changeLightness(
229
- intent ? theme.intents[intent] : getMainBackgroundColor(theme),
230
- 0.25
231
- )}`};
232
-
233
- ${opacity !== 0 &&
234
- css`
235
- ${StyledCollectionItemContent}:after {
236
- background: linear-gradient(
237
- to top,
238
- ${rgba(
239
- darken(
240
- 0.025,
241
- rgba(changeDarkness(getMainBackgroundColor(theme), 0.03), opacity)
242
- ),
243
- opacity
244
- )}
245
- 0%,
246
- transparent 100%
247
- );
248
- }
249
- `}
250
- }
251
- `
252
- : undefined}
253
-
254
- ${({ fill, isCollapsed }) =>
255
- !isCollapsed && fill
256
- ? css`
257
- height: 100%;
258
- flex: 1;
259
- `
260
- : undefined}
261
-
262
- ${({ disabled }) => disabled && DisabledElement}
263
- `;
264
-
265
- export const StyledPanelTitle = styled.div<IStyledPanel>`
266
- display: flex;
267
- flex-flow: ${({ responsive, isMobile }) => (responsive ? (isMobile ? 'column' : 'row') : 'row')};
268
- background-color: ${({ theme, opacity = 1 }: IStyledPanel) =>
269
- rgba(changeLightness(getMainBackgroundColor(theme), 0.03), opacity)};
270
- justify-content: space-between;
271
- // 2 is border that has to be added to the size + the button size + padding
272
- min-height: ${({ size, transparent, flat, minimal }) =>
273
- 2 +
274
- (SIZE_TO_PX[size] + ((transparent && flat) || minimal ? 0 : PADDING_FROM_SIZE[size]) * 2)}px;
275
- align-items: center;
276
- padding: ${({ noHorizontalPadding, size, transparent, flat, intent }: IStyledPanel) =>
277
- `${transparent && flat && !intent ? 0 : PADDING_FROM_SIZE[size]}px ${
278
- noHorizontalPadding ? 0 : `${PADDING_FROM_SIZE[size]}px`
279
- }`};
280
- border-bottom: ${({ theme, isCollapsed, flat, opacity = 1 }) =>
281
- !isCollapsed && !flat
282
- ? `1px solid ${rgba(changeLightness(getMainBackgroundColor(theme), 0.2), opacity)}`
283
- : null};
284
- transition: background-color 0.2s ease-out;
285
- overflow: hidden;
286
- flex: 0 0 auto;
287
- gap: ${GAP_FROM_SIZE.normal}px;
288
-
289
- ${StyledPanelTitleHeaderContent} > ${StyledIconWrapper} {
290
- transform: scale(${INACTIVE_ICON_SCALE});
291
- }
292
-
293
- ${({ collapsible }) =>
294
- collapsible &&
295
- css`
296
- cursor: pointer;
297
- &:hover {
298
- ${StyledPanelTitleHeaderContent} > ${StyledIconWrapper} {
299
- transform: scale(${ACTIVE_ICON_SCALE});
300
- }
301
-
302
- background-color: ${({ theme, opacity = 1 }: IStyledPanel) =>
303
- rgba(changeLightness(getMainBackgroundColor(theme), 0.05), opacity)};
304
- }
305
- `}
306
- `;
307
-
308
- export const StyledPanelTopBar = styled(StyledPanelTitle)`
309
- padding-bottom: ${({ minimal, padded, size, transparent, isCollapsed }: IStyledPanel) =>
310
- !padded || isCollapsed
311
- ? `${PADDING_FROM_SIZE[size]}px`
312
- : minimal || transparent
313
- ? 0
314
- : undefined};
315
- padding-top: ${({ minimal, size }: IStyledPanel) =>
316
- minimal ? `${PADDING_FROM_SIZE[size]}px` : undefined};
317
- `;
318
-
319
- export const StyledPanelBottomActions = styled(StyledPanelTitle)`
320
- padding-top: ${({ minimal, padded, size, transparent }: IStyledPanel) =>
321
- !padded ? `${PADDING_FROM_SIZE[size]}px` : minimal || transparent ? 0 : undefined};
322
- padding-bottom: ${({ minimal, size }: IStyledPanel) =>
323
- minimal ? `${PADDING_FROM_SIZE[size]}px` : undefined};
324
- border-bottom: 0;
325
- border-top: ${({ theme, flat, opacity = 1 }) =>
326
- !flat
327
- ? `1px solid ${rgba(changeLightness(getMainBackgroundColor(theme), 0.2), opacity)}`
328
- : null};
329
- `;
330
-
331
- export const StyledPanelContent = styled.div<IStyledPanel>`
332
- display: ${({ isCollapsed }) => (isCollapsed ? 'none !important' : undefined)};
333
- padding: ${({ padded, size, noHorizontalPadding, minimal }) =>
334
- !padded
335
- ? undefined
336
- : noHorizontalPadding
337
- ? `${PADDING_FROM_SIZE[size]}px 0`
338
- : `${PADDING_FROM_SIZE[size] / (minimal ? 2 : 1)}px ${PADDING_FROM_SIZE[size]}px`};
339
- // The padding is not needed when the panel is minimal and has title, since
340
- // the title already has padding and is transparent
341
- padding-top: ${({ minimal, hasLabel, padded, size }) =>
342
- minimal && hasLabel && padded
343
- ? `${PADDING_FROM_SIZE[size] / 2}px`
344
- : padded
345
- ? `${PADDING_FROM_SIZE[size]}px`
346
- : undefined};
347
- padding-bottom: ${({ minimal, padded, size, hasBottomActions }) =>
348
- minimal && hasBottomActions && padded
349
- ? `${PADDING_FROM_SIZE[size] / 2}px`
350
- : padded
351
- ? `${PADDING_FROM_SIZE[size]}px`
352
- : undefined};
353
- flex: 1;
354
- overflow: auto;
355
- overflow-wrap: anywhere;
356
- font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
357
- `;
358
-
359
- export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
360
- (
361
- {
362
- children,
363
- label,
364
- collapseButtonProps = {},
365
- collapsible,
366
- onClose,
367
- closeButtonProps = {},
368
- rounded = true,
369
- actions = [],
370
- bottomActions = [],
371
- isCollapsed,
372
- customTheme,
373
- icon,
374
- iconImage,
375
- intent,
376
- className,
377
- flat,
378
- unMountContentOnCollapse = true,
379
- onCollapseChange,
380
- padded = true,
381
- contentStyle,
382
- contentEffect,
383
- headerEffect = {},
384
- headerSize,
385
- contentSize,
386
- minimal,
387
- tooltip,
388
- badge,
389
- iconColor,
390
- iconProps = {},
391
- fluid,
392
- responsiveActions = true,
393
- responsiveTitle = true,
394
- size: panelSize = 'normal',
395
- getContentRef,
396
- headerProps = {},
397
- disabled,
398
- breadcrumbs,
399
- showActionsWhenCollapsed = true,
400
- showHeaderTooltip,
401
- resizable,
402
- onLabelEdit,
403
- ...rest
404
- }: IReqorePanelProps,
405
- ref
406
- ) => {
407
- const [_isCollapsed, setIsCollapsed] = useState(isCollapsed || false);
408
- const theme = useReqoreTheme(
409
- 'main',
410
- customTheme ||
411
- (contentEffect?.gradient && minimal
412
- ? { main: Object.values(contentEffect.gradient.colors)[0] as TReqoreEffectColor }
413
- : undefined)
414
- );
415
-
416
- const isMobile = useReqoreProperty('isMobile');
417
- const { targetRef } = useCombinedRefs(ref);
418
- const [itemRef, setItemRef] = useState<HTMLDivElement>(undefined);
419
- const [measureRef, { width }] = useMeasure();
420
-
421
- useTooltip(itemRef, tooltip);
422
-
423
- useUpdateEffect(() => {
424
- setIsCollapsed(!!isCollapsed);
425
- }, [isCollapsed]);
426
-
427
- const _resizable: ResizableProps = useMemo(() => {
428
- const disabledProps: ResizableProps = {
429
- enable: {
430
- top: false,
431
- right: false,
432
- bottom: false,
433
- left: false,
434
- topRight: false,
435
- bottomRight: false,
436
- bottomLeft: false,
437
- topLeft: false,
438
- },
439
- };
440
-
441
- if (isCollapsed || disabled) {
442
- return disabledProps;
443
- }
444
-
445
- return resizable || disabledProps;
446
- }, [resizable, isCollapsed, disabled]);
447
-
448
- // Return true if the card has a title bar, otherwise return false.
449
- const hasTitleBar: boolean = useMemo(
450
- () =>
451
- !!label ||
452
- !!breadcrumbs ||
453
- collapsible ||
454
- !!onClose ||
455
- !!size(actions.filter(isActionShown)) ||
456
- !!(isArray(badge) ? size(badge) : badge) ||
457
- !!icon,
458
- [label, collapsible, onClose, actions, badge, icon]
459
- );
460
-
461
- // Return true if the card has a title bar, otherwise return false.
462
- const hasTitleHeader: boolean = useMemo(
463
- () => !!label || !!badge || !!icon || !!breadcrumbs,
464
- [label, icon, badge, breadcrumbs]
465
- );
466
-
467
- const isSmall = useMemo(
468
- () => responsiveTitle && width < 480 && process.env.NODE_ENV !== 'test',
469
- [width, responsiveTitle]
470
- );
471
-
472
- // If collapsible is true, toggle the isCollapsed state
473
- // If the isCollapsed state is true, the component is expanded
474
- // If the isCollapsed state is false, the component is collapsed
475
- const handleCollapseClick = useCallback(() => {
476
- // If collapsible is true, toggle the isCollapsed state
477
- if (collapsible) {
478
- setIsCollapsed(!_isCollapsed);
479
- onCollapseChange?.(!_isCollapsed);
480
- }
481
- }, [collapsible, _isCollapsed, onCollapseChange]);
482
-
483
- const leftBottomActions: IReqorePanelBottomAction[] = useMemo(
484
- () => bottomActions.filter(({ position }) => position === 'left' || !position),
485
- [bottomActions]
486
- );
487
-
488
- const rightBottomActions: IReqorePanelBottomAction[] = useMemo(
489
- () => bottomActions.filter(({ position }) => position === 'right'),
490
- [bottomActions]
491
- );
492
-
493
- // Calculates whether or not the bottom actions should be displayed.
494
- const hasBottomActions: boolean = useMemo(
495
- () =>
496
- !!(
497
- size(leftBottomActions.filter(isActionShown)) ||
498
- size(rightBottomActions.filter(isActionShown))
499
- ),
500
- [leftBottomActions, rightBottomActions]
501
- );
502
-
503
- const renderResponsiveActions = useCallback(
504
- (align: 'flex-start' | 'center' | 'flex-end' = 'flex-end') =>
505
- (action: IReqorePanelAction, index: number) => {
506
- return renderActions(action, index, true, align);
507
- },
508
- [actions, showActionsWhenCollapsed, _isCollapsed]
509
- );
510
-
511
- const hasNonResponsiveActions = useCallback(
512
- (data: TReqorePanelActions) =>
513
- (!responsiveActions && size(data)) ||
514
- data.some((action) => action.responsive === false && action.show !== false),
515
- [actions, bottomActions, responsiveActions, showActionsWhenCollapsed, _isCollapsed]
516
- );
517
-
518
- const hasResponsiveActions = useCallback(
519
- (data: TReqorePanelActions) =>
520
- responsiveActions &&
521
- data.some((action) => action.responsive !== false && action.show !== false),
522
- [actions, bottomActions, responsiveActions, showActionsWhenCollapsed, _isCollapsed]
523
- );
524
-
525
- const renderNonResponsiveActions = useCallback(
526
- (align: 'flex-start' | 'center' | 'flex-end' = 'flex-end') =>
527
- (action: IReqorePanelAction, index: number) => {
528
- return renderActions(action, index, false, align);
529
- },
530
- [actions, bottomActions, responsiveActions, showActionsWhenCollapsed, _isCollapsed]
531
- );
532
-
533
- const renderActions = useCallback(
534
- (
535
- action: IReqorePanelAction,
536
- index: number,
537
- includeResponsive,
538
- align: 'flex-start' | 'center' | 'flex-end' = 'flex-end'
539
- ) => {
540
- if (
541
- action.show === false ||
542
- (showActionsWhenCollapsed === false && _isCollapsed === true) ||
543
- (includeResponsive && action.responsive === false) ||
544
- (!includeResponsive &&
545
- responsiveActions &&
546
- (action.responsive === true || !('responsive' in action)))
547
- ) {
548
- return null;
549
- }
550
-
551
- const {
552
- id,
553
- actions,
554
- label,
555
- intent,
556
- as: CustomElement,
557
- props = {},
558
- group,
559
- show,
560
- ...rest
561
- }: IReqorePanelAction = action;
562
-
563
- let { className }: IReqorePanelAction = action;
564
-
565
- // If the show prop is 'hover', add the hidden class to the action
566
- className = classNames(className, show === 'hover' ? 'reqore-panel-action-hidden' : '');
567
-
568
- if (size(group)) {
569
- return (
570
- <ReqoreControlGroup
571
- intent={intent}
572
- stack
573
- customTheme={rest.customTheme || theme}
574
- size={rest.size}
575
- fixed={rest.fixed}
576
- fluid={rest.fluid}
577
- key={index}
578
- className={className}
579
- horizontalAlign={align}
580
- >
581
- {group.map((action, index) => renderActions(action, index, true))}
582
- </ReqoreControlGroup>
583
- );
584
- }
585
-
586
- if (size(actions)) {
587
- return (
588
- <ReqoreDropdown<IReqoreButtonProps>
589
- fixed
590
- {...rest}
591
- key={index}
592
- label={label}
593
- items={actions}
594
- intent={intent}
595
- className={className}
596
- customTheme={rest.customTheme || theme}
597
- onClick={(e: React.MouseEvent<HTMLButtonElement>) => e.stopPropagation()}
598
- id={id}
599
- />
600
- );
601
- }
602
-
603
- if (CustomElement) {
604
- return (
605
- <CustomElement
606
- fixed
607
- className={className}
608
- {...props}
609
- // key={props.key || index}
610
- // reactKey={props.key || index}
611
- customTheme={props.customTheme || theme}
612
- onClick={(e: React.MouseEvent<any>) => {
613
- e.stopPropagation();
614
- props?.onClick?.(e);
615
- }}
616
- />
617
- );
618
- }
619
-
620
- return (
621
- <ReqoreButton
622
- fixed
623
- {...rest}
624
- id={id}
625
- key={index}
626
- className={className}
627
- customTheme={rest.customTheme || theme}
628
- intent={intent}
629
- onClick={
630
- rest.onClick
631
- ? (e: React.MouseEvent<HTMLButtonElement>) => {
632
- e.stopPropagation();
633
- rest.onClick?.();
634
- }
635
- : undefined
636
- }
637
- >
638
- {label}
639
- </ReqoreButton>
640
- );
641
- },
642
- [actions, theme, showActionsWhenCollapsed, _isCollapsed]
643
- );
644
-
645
- const interactive: boolean = !!(
646
- rest.onClick ||
647
- rest.onMouseOver ||
648
- rest.onMouseEnter ||
649
- rest.onDoubleClick ||
650
- rest.onContextMenu
651
- );
652
-
653
- const transformedContentEffect: IReqoreEffect = useMemo(() => {
654
- const newContentEffect: IReqoreEffect = { ...contentEffect };
655
-
656
- if (newContentEffect.gradient) {
657
- newContentEffect.gradient.borderColor = intent
658
- ? theme.intents[intent]
659
- : newContentEffect.gradient.borderColor;
660
- }
661
-
662
- newContentEffect.interactive = interactive;
663
-
664
- return newContentEffect;
665
- }, [intent, theme, contentEffect, interactive]);
666
-
667
- const opacity = rest.transparent ? 0 : rest.opacity;
668
- const noHorizontalPadding = opacity === 0 && flat && !intent;
669
-
670
- const showNonResponsiveGroup = useCallback((): boolean => {
671
- let show: boolean = false;
672
-
673
- // SHOULD THIS GROUP SHOW CONTROL BUTTONS?
674
- // This group should only show control buttons
675
- // if the panel is not small
676
- if (!isSmall && (onClose || collapsible)) {
677
- show = true;
678
- }
679
-
680
- // OTHERWISE, ARE THERE ANY NON RESPONSIVE ACTIONS TO BE SHOWN?
681
- // This either means actions where user specified responsive: false
682
- // or user passed responsiveActions: false
683
- if (hasNonResponsiveActions(actions)) {
684
- show = true;
685
- }
686
-
687
- return show;
688
- }, [isSmall, collapsible, actions, hasNonResponsiveActions]);
689
-
690
- return (
691
- <StyledPanel
692
- {...omit(rest, ['onResize'])}
693
- {..._resizable}
694
- as={rest.as || !!resizable ? Resizable : 'div'}
695
- ref={(ref) => {
696
- let _ref = ref;
697
-
698
- if (ref?.resizable) {
699
- _ref = ref.resizable;
700
- }
701
-
702
- targetRef.current = _ref;
703
- setItemRef(_ref);
704
- }}
705
- isCollapsed={_isCollapsed}
706
- rounded={rounded}
707
- flat={flat}
708
- intent={intent}
709
- className={`${className || ''} reqore-panel`}
710
- interactive={interactive}
711
- theme={theme}
712
- effect={transformedContentEffect}
713
- opacity={opacity}
714
- fluid={fluid}
715
- disabled={disabled}
716
- >
717
- {hasTitleBar && (
718
- <StyledPanelTopBar
719
- flat={flat}
720
- isCollapsed={_isCollapsed}
721
- collapsible={collapsible}
722
- className='reqore-panel-title'
723
- onClick={handleCollapseClick}
724
- theme={theme}
725
- minimal={minimal}
726
- size={contentSize || panelSize}
727
- opacity={opacity ?? (minimal ? 0 : 1)}
728
- noHorizontalPadding={noHorizontalPadding}
729
- responsive={responsiveTitle}
730
- isMobile={isMobile || isSmall}
731
- ref={measureRef}
732
- padded={padded}
733
- transparent={rest.transparent || opacity === 0}
734
- intent={intent}
735
- >
736
- {hasTitleHeader && (
737
- <StyledPanelTitleHeader>
738
- {breadcrumbs ? (
739
- <ReqoreBreadcrumbs
740
- {...breadcrumbs}
741
- padded={false}
742
- margin='none'
743
- flat
744
- responsive
745
- />
746
- ) : icon || iconImage || label ? (
747
- <StyledPanelTitleHeaderContent
748
- size={panelSize}
749
- {...headerProps}
750
- hasLabel={!!label}
751
- hasIcon={!!icon || !!iconImage}
752
- iconSize={ICON_FROM_HEADER_SIZE[headerSize || HEADER_SIZE_TO_NUMBER[panelSize]]}
753
- >
754
- {icon || iconImage ? (
755
- <ReqoreIcon
756
- size={`${
757
- ICON_FROM_HEADER_SIZE[headerSize || HEADER_SIZE_TO_NUMBER[panelSize]]
758
- }px`}
759
- icon={icon}
760
- image={iconImage}
761
- margin='right'
762
- color={iconColor}
763
- tooltip={{
764
- content: label,
765
- }}
766
- {...iconProps}
767
- />
768
- ) : null}
769
- {typeof label === 'string' ? (
770
- <LabelEditor
771
- size={headerSize || panelSize}
772
- customTheme={theme}
773
- effect={{
774
- noWrap: true,
775
- ...headerEffect,
776
- }}
777
- label={label}
778
- onSubmit={onLabelEdit}
779
- tooltip={showHeaderTooltip ? label : undefined}
780
- />
781
- ) : (
782
- label
783
- )}
784
- </StyledPanelTitleHeaderContent>
785
- ) : null}
786
- {badge || badge === 0 ? (
787
- <ButtonBadge
788
- color={changeLightness(theme.main, 0.18)}
789
- size={getOneHigherSize(panelSize)}
790
- content={badge}
791
- wrapGroup={isSmall}
792
- />
793
- ) : null}
794
- <ReqorePanelNonResponsiveActions
795
- show={isSmall && (!!onClose || collapsible)}
796
- isSmall={isSmall}
797
- showControlButtons
798
- size={panelSize}
799
- hasResponsiveActions={hasResponsiveActions(actions)}
800
- customTheme={theme}
801
- isCollapsed={_isCollapsed}
802
- onCollapseClick={collapsible ? handleCollapseClick : undefined}
803
- onCloseClick={onClose}
804
- closeButtonProps={closeButtonProps}
805
- collapseButtonProps={collapseButtonProps}
806
- fluid={false}
807
- style={{ marginLeft: 'auto' }}
808
- />
809
- </StyledPanelTitleHeader>
810
- )}
811
- {hasResponsiveActions(actions) && (
812
- <ReqoreControlGroup
813
- responsive={responsiveActions}
814
- fluid={responsiveActions || isSmall}
815
- horizontalAlign='flex-end'
816
- customTheme={theme}
817
- size={panelSize}
818
- >
819
- {actions.map(renderResponsiveActions())}
820
- </ReqoreControlGroup>
821
- )}
822
- <ReqorePanelNonResponsiveActions
823
- show={showNonResponsiveGroup()}
824
- isSmall={isSmall}
825
- showControlButtons={!isSmall}
826
- size={panelSize}
827
- hasResponsiveActions={hasResponsiveActions(actions)}
828
- customTheme={theme}
829
- isCollapsed={_isCollapsed}
830
- onCollapseClick={collapsible ? handleCollapseClick : undefined}
831
- onCloseClick={onClose}
832
- closeButtonProps={closeButtonProps}
833
- collapseButtonProps={collapseButtonProps}
834
- fluid={!hasTitleHeader || isSmall}
835
- >
836
- {actions.map(renderNonResponsiveActions())}
837
- </ReqorePanelNonResponsiveActions>
838
- </StyledPanelTopBar>
839
- )}
840
- {!_isCollapsed || (_isCollapsed && !unMountContentOnCollapse) ? (
841
- <StyledPanelContent
842
- as={'div'}
843
- className='reqore-panel-content'
844
- hasLabel={!!hasTitleBar}
845
- hasBottomActions={hasBottomActions}
846
- isCollapsed={_isCollapsed}
847
- style={contentStyle}
848
- padded={padded}
849
- minimal={minimal}
850
- size={contentSize || panelSize}
851
- ref={getContentRef}
852
- noHorizontalPadding={noHorizontalPadding}
853
- >
854
- {children}
855
- </StyledPanelContent>
856
- ) : null}
857
- {hasBottomActions && !_isCollapsed ? (
858
- <StyledPanelBottomActions
859
- flat={flat}
860
- className='reqore-panel-bottom-actions'
861
- theme={theme}
862
- padded={padded}
863
- intent={intent}
864
- minimal={minimal}
865
- transparent={rest.transparent || opacity === 0}
866
- opacity={opacity ?? (minimal ? 0 : 1)}
867
- size={contentSize || panelSize}
868
- noHorizontalPadding={noHorizontalPadding}
869
- >
870
- {hasNonResponsiveActions(leftBottomActions) ? (
871
- <ReqoreControlGroup size={panelSize} style={{ marginRight: 'auto' }}>
872
- {leftBottomActions.map(renderNonResponsiveActions('flex-start'))}
873
- </ReqoreControlGroup>
874
- ) : null}
875
- {hasResponsiveActions(leftBottomActions) && (
876
- <ReqoreControlGroup
877
- fluid={responsiveActions}
878
- responsive={responsiveActions}
879
- customTheme={theme}
880
- size={panelSize}
881
- style={{ marginRight: 'auto' }}
882
- >
883
- {leftBottomActions.map(renderResponsiveActions('flex-start'))}
884
- </ReqoreControlGroup>
885
- )}
886
- {hasResponsiveActions(rightBottomActions) && (
887
- <ReqoreControlGroup
888
- fluid={responsiveActions}
889
- horizontalAlign='flex-end'
890
- responsive={responsiveActions}
891
- customTheme={theme}
892
- style={{ marginLeft: 'auto' }}
893
- size={panelSize}
894
- >
895
- {rightBottomActions.map(renderResponsiveActions())}
896
- </ReqoreControlGroup>
897
- )}
898
- {hasNonResponsiveActions(rightBottomActions) ? (
899
- <ReqoreControlGroup
900
- horizontalAlign='flex-end'
901
- size={panelSize}
902
- style={{ marginLeft: 'auto' }}
903
- >
904
- {rightBottomActions.map(renderNonResponsiveActions())}
905
- </ReqoreControlGroup>
906
- ) : null}
907
- </StyledPanelBottomActions>
908
- ) : null}
909
- </StyledPanel>
910
- );
911
- }
912
- );