@qoretechnologies/reqore 0.30.14 → 0.30.16

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 (48) hide show
  1. package/__tests__/multiselect.test.tsx +69 -0
  2. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  3. package/dist/components/ControlGroup/index.js +55 -17
  4. package/dist/components/ControlGroup/index.js.map +1 -1
  5. package/dist/components/Dropdown/list.d.ts.map +1 -1
  6. package/dist/components/Dropdown/list.js +0 -1
  7. package/dist/components/Dropdown/list.js.map +1 -1
  8. package/dist/components/Message/index.d.ts +2 -2
  9. package/dist/components/Message/index.d.ts.map +1 -1
  10. package/dist/components/Message/index.js +2 -2
  11. package/dist/components/Message/index.js.map +1 -1
  12. package/dist/components/MultiSelect/index.d.ts +3 -1
  13. package/dist/components/MultiSelect/index.d.ts.map +1 -1
  14. package/dist/components/MultiSelect/index.js +3 -1
  15. package/dist/components/MultiSelect/index.js.map +1 -1
  16. package/dist/components/Notifications/notification.d.ts +2 -2
  17. package/dist/components/Notifications/notification.d.ts.map +1 -1
  18. package/dist/components/Notifications/notification.js +15 -6
  19. package/dist/components/Notifications/notification.js.map +1 -1
  20. package/dist/components/Tag/index.d.ts +4 -2
  21. package/dist/components/Tag/index.d.ts.map +1 -1
  22. package/dist/components/Tag/index.js +4 -4
  23. package/dist/components/Tag/index.js.map +1 -1
  24. package/dist/components/Textarea/index.d.ts +1 -0
  25. package/dist/components/Textarea/index.d.ts.map +1 -1
  26. package/dist/components/Textarea/index.js +15 -6
  27. package/dist/components/Textarea/index.js.map +1 -1
  28. package/dist/components/Tree/index.d.ts +3 -2
  29. package/dist/components/Tree/index.d.ts.map +1 -1
  30. package/dist/components/Tree/index.js +45 -6
  31. package/dist/components/Tree/index.js.map +1 -1
  32. package/dist/hooks/useTheme.d.ts +1 -1
  33. package/dist/hooks/useTheme.d.ts.map +1 -1
  34. package/dist/hooks/useTheme.js +3 -2
  35. package/dist/hooks/useTheme.js.map +1 -1
  36. package/package.json +11 -3
  37. package/src/components/ControlGroup/index.tsx +85 -25
  38. package/src/components/Dropdown/list.tsx +0 -2
  39. package/src/components/Message/index.tsx +8 -1
  40. package/src/components/MultiSelect/index.tsx +6 -0
  41. package/src/components/Notifications/notification.tsx +22 -8
  42. package/src/components/Tag/index.tsx +33 -7
  43. package/src/components/Textarea/index.tsx +11 -2
  44. package/src/components/Tree/index.tsx +51 -66
  45. package/src/hooks/useTheme.ts +3 -2
  46. package/src/stories/Notifications/Notification.stories.tsx +2 -0
  47. package/src/stories/Tag/Tag.stories.tsx +29 -1
  48. package/tests.json +1 -1
@@ -1,5 +1,12 @@
1
1
  import { debounce } from 'lodash';
2
- import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import React, {
3
+ memo,
4
+ useCallback,
5
+ useEffect,
6
+ useMemo,
7
+ useRef,
8
+ useState,
9
+ } from 'react';
3
10
  import { useMount, useUnmount } from 'react-use';
4
11
  import styled, { css } from 'styled-components';
5
12
  import { ReqoreButton, ReqoreDrawer } from '../..';
@@ -56,13 +63,16 @@ export interface IReqoreControlGroupStyle extends IReqoreControlGroupProps {
56
63
 
57
64
  export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
58
65
  display: flex;
59
- flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? undefined : '0 0 auto')};
66
+ flex: ${({ fluid, fixed }) =>
67
+ fixed ? '0 0 auto' : fluid ? undefined : '0 0 auto'};
60
68
  width: ${({ fluid, fixed }) => (fluid && !fixed ? '100%' : undefined)};
61
- justify-content: ${({ fluid, vertical }) => (vertical && fluid ? 'stretch' : undefined)};
69
+ justify-content: ${({ fluid, vertical }) =>
70
+ vertical && fluid ? 'stretch' : undefined};
62
71
  align-items: ${({ vertical, fluid, horizontalAlign }) =>
63
72
  vertical ? (fluid ? 'stretch' : horizontalAlign) : undefined};
64
73
  flex-flow: ${({ vertical }) => (vertical ? 'column' : 'row')};
65
- gap: ${({ gapSize, stack }) => (!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined)};
74
+ gap: ${({ gapSize, stack }) =>
75
+ !stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined};
66
76
  flex-wrap: ${({ wrap }) => (wrap ? 'wrap' : 'nowrap')};
67
77
 
68
78
  // If the group has the fill prop,
@@ -85,16 +95,23 @@ export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
85
95
 
86
96
  > * {
87
97
  margin-top: ${({ fill, verticalAlign }) =>
88
- !fill && (verticalAlign === 'flex-end' || verticalAlign === 'center') ? 'auto' : undefined};
98
+ !fill && (verticalAlign === 'flex-end' || verticalAlign === 'center')
99
+ ? 'auto'
100
+ : undefined};
89
101
  margin-bottom: ${({ fill, verticalAlign }) =>
90
- !fill && (verticalAlign === 'flex-start' || verticalAlign === 'center') ? 'auto' : undefined};
91
- margin-right: ${({ horizontalAlign }) => (horizontalAlign === 'center' ? 'auto' : undefined)};
102
+ !fill && (verticalAlign === 'flex-start' || verticalAlign === 'center')
103
+ ? 'auto'
104
+ : undefined};
105
+ margin-right: ${({ horizontalAlign }) =>
106
+ horizontalAlign === 'center' ? 'auto' : undefined};
92
107
 
93
108
  ${({ vertical }) =>
94
109
  vertical &&
95
110
  css`
96
111
  margin-left: ${({ horizontalAlign }) =>
97
- horizontalAlign === 'flex-end' || horizontalAlign === 'center' ? 'auto' : undefined};
112
+ horizontalAlign === 'flex-end' || horizontalAlign === 'center'
113
+ ? 'auto'
114
+ : undefined};
98
115
  `}
99
116
  }
100
117
 
@@ -103,7 +120,9 @@ export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
103
120
  css`
104
121
  > *:first-child {
105
122
  margin-left: ${({ horizontalAlign }) =>
106
- horizontalAlign === 'flex-end' || horizontalAlign === 'center' ? 'auto' : undefined};
123
+ horizontalAlign === 'flex-end' || horizontalAlign === 'center'
124
+ ? 'auto'
125
+ : undefined};
107
126
  }
108
127
  `}
109
128
 
@@ -149,9 +168,12 @@ const ReqoreControlGroup = memo(
149
168
  const isStack = stack || isInsideStackGroup;
150
169
  const isVertical = vertical || isInsideVerticalGroup;
151
170
 
152
- const [overflowingChildren, setOverflowingChildren] = useState<number | undefined>(0);
171
+ const [overflowingChildren, setOverflowingChildren] = useState<
172
+ number | undefined
173
+ >(0);
153
174
  const [lastReSize, setLastReSize] = useState<number>(0);
154
- const [isOverflownDialogOpen, setIsOverflownDialogOpen] = useState<boolean>(false);
175
+ const [isOverflownDialogOpen, setIsOverflownDialogOpen] =
176
+ useState<boolean>(false);
155
177
  const observer = useRef<ResizeObserver | null>(null);
156
178
  const ref = useRef<HTMLDivElement>(null);
157
179
 
@@ -210,7 +232,10 @@ const ReqoreControlGroup = memo(
210
232
 
211
233
  useEffect(() => {
212
234
  // Is the control group still overflowing?
213
- if ((overflowingChildren || overflowingChildren === 0) && checkIfOverflowing()) {
235
+ if (
236
+ (overflowingChildren || overflowingChildren === 0) &&
237
+ checkIfOverflowing()
238
+ ) {
214
239
  setOverflowingChildren(overflowingChildren + 1);
215
240
  }
216
241
 
@@ -233,22 +258,33 @@ const ReqoreControlGroup = memo(
233
258
  const getIsLastInFirstGroup = (index: number): boolean => {
234
259
  return !isInsideStackGroup
235
260
  ? index === 0
236
- : isFirstGroup && (isLast || isLast !== false) && index === realChildCount - 1;
261
+ : isFirstGroup &&
262
+ (isLast || isLast !== false) &&
263
+ index === realChildCount - 1;
237
264
  };
238
265
  const getIsFirstInLastGroup = (index: number): boolean => {
239
266
  return !isInsideStackGroup
240
267
  ? index === realChildCount - 1
241
- : isLastGroup && (isFirst || isFirst !== false) && childId === 1 && index === 0;
268
+ : isLastGroup &&
269
+ (isFirst || isFirst !== false) &&
270
+ childId === 1 &&
271
+ index === 0;
242
272
  };
243
273
  const getIsLastInLastGroup = (index: number): boolean => {
244
274
  return !isInsideStackGroup
245
275
  ? index === realChildCount - 1
246
- : isLastGroup && (isLast || isLast !== false) && index === realChildCount - 1;
276
+ : isLastGroup &&
277
+ (isLast || isLast !== false) &&
278
+ index === realChildCount - 1;
247
279
  };
248
280
 
249
281
  const getBorderTopLeftRadius = (index: number): number | undefined => {
250
282
  const _isFirstGroup =
251
- !isInsideStackGroup || childrenCount === 1 ? true : isChild ? isFirstGroup : index === 0;
283
+ !isInsideStackGroup || childrenCount === 1
284
+ ? true
285
+ : isChild
286
+ ? isFirstGroup
287
+ : index === 0;
252
288
 
253
289
  // If this is the first item
254
290
  if (_isFirstGroup && getIsFirst(index)) {
@@ -288,7 +324,11 @@ const ReqoreControlGroup = memo(
288
324
  // If this group is not vertical we need to style the very first item
289
325
  if (!isVertical || !isStack) {
290
326
  const _isFirstGroup =
291
- !isInsideStackGroup || childrenCount === 1 ? true : isChild ? isFirstGroup : index === 0;
327
+ !isInsideStackGroup || childrenCount === 1
328
+ ? true
329
+ : isChild
330
+ ? isFirstGroup
331
+ : index === 0;
292
332
 
293
333
  if (_isFirstGroup && getIsFirst(index)) {
294
334
  return RADIUS_FROM_SIZE[size];
@@ -341,12 +381,26 @@ const ReqoreControlGroup = memo(
341
381
  ? child.props.minimal
342
382
  : minimal,
343
383
  size: child.props?.size || size,
344
- flat: child.props?.flat || child.props?.flat === false ? child.props.flat : flat,
345
- fluid: child.props?.fluid || child.props?.fluid === false ? child.props.fluid : fluid,
346
- fixed: child.props?.fixed || child.props?.fixed === false ? child.props.fixed : fixed,
347
- fill: child.props?.fill || child.props?.fill === false ? child.props.fixed : fill,
384
+ flat:
385
+ child.props?.flat || child.props?.flat === false
386
+ ? child.props.flat
387
+ : flat,
388
+ fluid:
389
+ child.props?.fluid || child.props?.fluid === false
390
+ ? child.props.fluid
391
+ : fluid,
392
+ fixed:
393
+ child.props?.fixed || child.props?.fixed === false
394
+ ? child.props.fixed
395
+ : fixed,
396
+ fill:
397
+ child.props?.fill || child.props?.fill === false
398
+ ? child.props.fill
399
+ : fill,
348
400
  stack:
349
- child.props?.stack || child.props?.stack === false ? child.props.stack : isStack,
401
+ child.props?.stack || child.props?.stack === false
402
+ ? child.props.stack
403
+ : isStack,
350
404
  intent: child.props?.intent || intent,
351
405
  customTheme: child.props?.customTheme || customTheme,
352
406
  };
@@ -374,7 +428,9 @@ const ReqoreControlGroup = memo(
374
428
  childId: index + 1,
375
429
 
376
430
  isFirstGroup: isChild ? isFirstGroup : index === 0,
377
- isLastGroup: isChild ? isLastGroup : index === realChildCount - 1,
431
+ isLastGroup: isChild
432
+ ? isLastGroup
433
+ : index === realChildCount - 1,
378
434
  };
379
435
  }
380
436
 
@@ -413,7 +469,9 @@ const ReqoreControlGroup = memo(
413
469
  // Get the overflown children
414
470
  const overflownChildren = useMemo(
415
471
  () =>
416
- overflowingChildren ? React.Children.toArray(children).slice(0, overflowingChildren) : [],
472
+ overflowingChildren
473
+ ? React.Children.toArray(children).slice(0, overflowingChildren)
474
+ : [],
417
475
  [children, overflowingChildren]
418
476
  );
419
477
 
@@ -427,7 +485,9 @@ const ReqoreControlGroup = memo(
427
485
  icon='MenuLine'
428
486
  customTheme={customTheme}
429
487
  tooltip={{
430
- content: `Show ${React.Children.count(overflownChildren)} hidden items`,
488
+ content: `Show ${React.Children.count(
489
+ overflownChildren
490
+ )} hidden items`,
431
491
  }}
432
492
  fixed
433
493
  active={isOverflownDialogOpen}
@@ -79,8 +79,6 @@ const ReqoreDropdownList = memo(
79
79
  }
80
80
  };
81
81
 
82
- console.log('Filtered Items', filteredItems);
83
-
84
82
  return (
85
83
  <ReqoreMenu
86
84
  _insidePopover={!multiSelect}
@@ -11,6 +11,8 @@ import {
11
11
  IReqoreIntent,
12
12
  IWithReqoreCustomTheme,
13
13
  IWithReqoreEffect,
14
+ IWithReqoreFixed,
15
+ IWithReqoreFluid,
14
16
  IWithReqoreMinimal,
15
17
  IWithReqoreOpaque,
16
18
  IWithReqoreSize,
@@ -36,6 +38,8 @@ export interface IReqoreMessageProps
36
38
  IWithReqoreMinimal,
37
39
  IWithReqoreOpaque,
38
40
  IWithReqoreTooltip,
41
+ IWithReqoreFixed,
42
+ IWithReqoreFluid,
39
43
  React.HTMLAttributes<HTMLDivElement> {
40
44
  title?: string;
41
45
  children: any;
@@ -73,6 +77,8 @@ const ReqoreMessage = memo(
73
77
  customTheme,
74
78
  iconColor,
75
79
  tooltip,
80
+ fixed,
81
+ fluid,
76
82
  ...rest
77
83
  },
78
84
  ref
@@ -132,7 +138,8 @@ const ReqoreMessage = memo(
132
138
  flat={flat}
133
139
  minimal={minimal}
134
140
  asMessage
135
- fluid
141
+ fluid={fluid}
142
+ fixed={fixed}
136
143
  className={`${rest?.className || ''} reqore-message`}
137
144
  ref={targetRef}
138
145
  size={size}
@@ -21,6 +21,8 @@ export interface IReqoreMultiSelectProps
21
21
  items?: TReqoreMultiSelectItem[];
22
22
  onItemClick?: (item: IReqoreDropdownItem) => void;
23
23
  onItemClickIcon?: IReqoreTagProps['rightIcon'];
24
+ onItemAdded?: (item: TReqoreMultiSelectItem) => void;
25
+ onItemRemoved?: (item: TReqoreMultiSelectItem) => void;
24
26
  canRemoveItems?: boolean;
25
27
  canCreateItems?: boolean;
26
28
  selectedItemEffect?: IReqoreEffect;
@@ -87,6 +89,8 @@ export const ReqoreMultiSelect = ({
87
89
  openOnMount,
88
90
  enterKeySelects,
89
91
  onItemClickIcon,
92
+ onItemAdded,
93
+ onItemRemoved,
90
94
  ...rest
91
95
  }: IReqoreMultiSelectProps) => {
92
96
  const [createdItems, setCreatedItems] = useState<TReqoreMultiSelectItem[]>([]);
@@ -114,8 +118,10 @@ export const ReqoreMultiSelect = ({
114
118
  (item: TReqoreMultiSelectItem): void => {
115
119
  if (value.includes(item.value)) {
116
120
  onValueChange(value.filter((v) => v !== item.value));
121
+ onItemRemoved?.(item.value);
117
122
  } else {
118
123
  onValueChange([...value, item.value]);
124
+ onItemAdded?.(item.value);
119
125
  }
120
126
  },
121
127
  [value]
@@ -15,7 +15,13 @@ import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
15
15
  import ReqoreThemeProvider from '../../containers/ThemeProvider';
16
16
  import { fadeIn } from '../../helpers/animations';
17
17
  import { changeLightness, getNotificationIntent, getReadableColor } from '../../helpers/colors';
18
- import { IWithReqoreEffect, IWithReqoreMinimal, IWithReqoreOpaque } from '../../types/global';
18
+ import { useReqoreTheme } from '../../hooks/useTheme';
19
+ import {
20
+ IWithReqoreCustomTheme,
21
+ IWithReqoreEffect,
22
+ IWithReqoreMinimal,
23
+ IWithReqoreOpaque,
24
+ } from '../../types/global';
19
25
  import { IReqoreIconName } from '../../types/icons';
20
26
  import { StyledEffect } from '../Effect';
21
27
  import { ReqoreHeading } from '../Header';
@@ -26,7 +32,8 @@ export type IReqoreNotificationType = TReqoreIntent;
26
32
  export interface IReqoreNotificationProps
27
33
  extends IWithReqoreEffect,
28
34
  IWithReqoreMinimal,
29
- IWithReqoreOpaque {
35
+ IWithReqoreOpaque,
36
+ IWithReqoreCustomTheme {
30
37
  type?: IReqoreNotificationType;
31
38
  intent?: TReqoreIntent;
32
39
  title?: string;
@@ -65,13 +72,14 @@ const timeoutAnimation = keyframes`
65
72
  `;
66
73
 
67
74
  export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotificationStyle>`
68
- min-width: ${({ fluid }) => (!fluid ? '200px' : undefined)};
69
- max-width: ${({ fluid }) => (!fluid ? '450px' : undefined)};
75
+ min-width: ${({ fluid }) => (!fluid ? '30px' : undefined)};
76
+ max-width: ${({ maxWidth, fluid, fixed }) => maxWidth || (fluid && !fixed ? '100%' : undefined)};
70
77
  border-radius: 5px;
71
78
  min-height: ${({ size = 'normal' }: IReqoreNotificationStyle) => TABS_SIZE_TO_PX[size]}px;
72
79
  display: flex;
73
- flex: 0 0 auto;
74
- overflow: auto;
80
+ flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto')};
81
+ align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
82
+ overflow: hidden;
75
83
  position: relative;
76
84
  transition: all 0.2s ease-out;
77
85
 
@@ -229,10 +237,14 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
229
237
  minimal,
230
238
  opaque,
231
239
  size = 'normal',
240
+ customTheme,
232
241
  },
233
242
  ref: any
234
243
  ) => {
235
244
  const [internalTimeout, setInternalTimeout] = useState(null);
245
+ const theme = useReqoreTheme('main', customTheme, type || intent, 'notifications');
246
+
247
+ console.log(theme, customTheme, intent);
236
248
 
237
249
  const transitions = useTransition(true, {
238
250
  from: { opacity: 0, transform: 'scale(0.9)' },
@@ -284,15 +296,17 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
284
296
  style={styles}
285
297
  size={size}
286
298
  opaque={opaque}
299
+ theme={theme}
300
+ maxWidth='450px'
287
301
  >
288
302
  {type || intent || icon ? (
289
303
  <StyledIconWrapper type={type || intent} size={size}>
290
304
  <ReqoreIcon icon={icon || typeToIcon[type || intent]} margin={'both'} size={size} />
291
305
  </StyledIconWrapper>
292
306
  ) : null}
293
- <StyledNotificationContentWrapper size={size}>
307
+ <StyledNotificationContentWrapper size={size} theme={theme}>
294
308
  {title && <ReqoreHeading size={size}>{title}</ReqoreHeading>}
295
- <StyledNotificationContent hasTitle={!!title} size={size}>
309
+ <StyledNotificationContent theme={theme} hasTitle={!!title} size={size}>
296
310
  {content}
297
311
  </StyledNotificationContent>
298
312
  </StyledNotificationContentWrapper>
@@ -32,7 +32,13 @@ import {
32
32
  IWithReqoreTooltip,
33
33
  } from '../../types/global';
34
34
  import { IReqoreIconName } from '../../types/icons';
35
- import { StyledEffect, TReqoreEffectColor, TReqoreHexColor } from '../Effect';
35
+ import {
36
+ IReqoreEffect,
37
+ StyledEffect,
38
+ StyledTextEffect,
39
+ TReqoreEffectColor,
40
+ TReqoreHexColor,
41
+ } from '../Effect';
36
42
  import ReqoreIcon from '../Icon';
37
43
 
38
44
  export interface IReqoreTagAction extends IWithReqoreTooltip, IReqoreDisabled, IReqoreIntent {
@@ -45,10 +51,10 @@ export interface IReqoreTagProps
45
51
  extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'>,
46
52
  IWithReqoreTooltip,
47
53
  IReqoreDisabled,
48
- IWithReqoreEffect,
49
54
  IWithReqoreMinimal,
50
55
  IWithReqoreFluid,
51
- IWithReqoreFixed {
56
+ IWithReqoreFixed,
57
+ IWithReqoreEffect {
52
58
  size?: TSizes;
53
59
  label?: string | number;
54
60
  labelKey?: string | number;
@@ -65,6 +71,8 @@ export interface IReqoreTagProps
65
71
  asBadge?: boolean;
66
72
  intent?: TReqoreIntent;
67
73
  wrap?: boolean;
74
+ labelEffect?: IReqoreEffect;
75
+ labelKeyEffect?: IReqoreEffect;
68
76
  }
69
77
 
70
78
  export interface IReqoreTagStyle extends IReqoreTagProps {
@@ -170,7 +178,7 @@ const StyledTagContentWrapper = styled.span<{ size: TSizes }>`
170
178
  min-height: 100%;
171
179
  `;
172
180
 
173
- const StyledTagContent = styled.span<{ size: TSizes }>`
181
+ const StyledTagContent = styled(StyledTextEffect)<{ size: TSizes }>`
174
182
  padding: 4px ${({ size }) => PADDING_FROM_SIZE[size]}px;
175
183
  min-height: 100%;
176
184
  display: flex;
@@ -190,7 +198,6 @@ const StyledTagContent = styled.span<{ size: TSizes }>`
190
198
  `;
191
199
 
192
200
  const StyledTagContentKey = styled(StyledTagContent)`
193
- font-weight: 800;
194
201
  flex: 1;
195
202
 
196
203
  ${({ wrap, hasWidth }) =>
@@ -250,6 +257,8 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
250
257
  leftIconColor,
251
258
  rightIconColor,
252
259
  iconColor,
260
+ labelEffect,
261
+ labelKeyEffect,
253
262
  ...rest
254
263
  }: IReqoreTagProps,
255
264
  ref
@@ -309,7 +318,17 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
309
318
  />
310
319
  )}
311
320
  {labelKey && (
312
- <StyledTagContentKey wrap={wrap} hasWidth={!!width} size={size}>
321
+ <StyledTagContentKey
322
+ wrap={wrap}
323
+ hasWidth={!!width}
324
+ size={size}
325
+ effect={
326
+ {
327
+ weight: 'thick',
328
+ ...labelKeyEffect,
329
+ } as IReqoreEffect
330
+ }
331
+ >
313
332
  {labelKey}
314
333
  </StyledTagContentKey>
315
334
  )}
@@ -325,7 +344,14 @@ const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
325
344
  hasKey={!!labelKey}
326
345
  >
327
346
  {label || label === 0 ? (
328
- <StyledTagContent size={size} wrap={wrap} hasWidth={!!width}>
347
+ <StyledTagContent
348
+ size={size}
349
+ wrap={wrap}
350
+ hasWidth={!!width}
351
+ effect={{
352
+ ...labelEffect,
353
+ }}
354
+ >
329
355
  {label}
330
356
  </StyledTagContent>
331
357
  ) : null}
@@ -1,7 +1,7 @@
1
1
  import { rgba } from 'polished';
2
2
  import React, { forwardRef, useEffect, useState } from 'react';
3
3
  import styled, { css } from 'styled-components';
4
- import { RADIUS_FROM_SIZE, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
4
+ import { RADIUS_FROM_SIZE, SIZE_TO_PX, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
5
5
  import { IReqoreTheme } from '../../constants/theme';
6
6
  import { changeLightness, getReadableColor } from '../../helpers/colors';
7
7
  import { useCombinedRefs } from '../../hooks/useCombinedRefs';
@@ -41,6 +41,7 @@ export interface IReqoreTextareaProps
41
41
  cols?: number;
42
42
  rounded?: boolean;
43
43
  flat?: boolean;
44
+ fixed?: boolean;
44
45
  onClearClick?: () => any;
45
46
  wrapperStyle?: React.CSSProperties;
46
47
  }
@@ -52,17 +53,23 @@ export interface IReqoreTextareaStyle extends IReqoreTextareaProps {
52
53
 
53
54
  export const StyledTextareaWrapper = styled.div<IReqoreTextareaStyle>`
54
55
  height: ${({ height }) => (height ? `${height}px` : undefined)};
56
+ min-height: ${({ _size }) => SIZE_TO_PX[_size]}px;
57
+ max-height: 100%;
55
58
  width: ${({ width, fluid }) => (fluid ? '100%' : width ? `${width}px` : 'auto')};
56
- flex: ${({ fluid }) => (fluid ? '1' : undefined)};
59
+ flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto')};
60
+ align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
57
61
  position: relative;
58
62
  overflow: hidden;
59
63
  `;
60
64
 
61
65
  export const StyledTextarea = styled(StyledEffect)<IReqoreTextareaStyle>`
62
66
  width: 100%;
67
+ max-width: 100%;
68
+ max-height: 100%;
63
69
  font-size: ${({ _size }) => TEXT_FROM_SIZE[_size]}px;
64
70
  margin: 0;
65
71
  padding: 5px 7px;
72
+ min-height: ${({ _size }) => SIZE_TO_PX[_size]}px;
66
73
 
67
74
  background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
68
75
  minimal ? 'transparent' : rgba(theme.main, 0.1)};
@@ -130,6 +137,7 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
130
137
  wrapperStyle,
131
138
  value,
132
139
  onChange,
140
+ fixed,
133
141
  ...rest
134
142
  }: IReqoreTextareaProps,
135
143
  ref
@@ -151,6 +159,7 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
151
159
  width={width}
152
160
  height={height}
153
161
  fluid={fluid}
162
+ fixed={fixed}
154
163
  _size={size}
155
164
  theme={theme}
156
165
  style={wrapperStyle}
@@ -1,16 +1,17 @@
1
1
  import { cloneDeep, size as lodashSize } from 'lodash';
2
2
  import { useContext, useState } from 'react';
3
3
  import styled from 'styled-components';
4
- import { ReqoreMessage, ReqoreTextarea } from '../..';
4
+ import { ReqoreMessage, ReqorePanel, ReqoreTextarea } from '../..';
5
5
  import { IReqoreTheme } from '../../constants/theme';
6
6
  import ReqoreContext from '../../context/ReqoreContext';
7
7
  import { getLineCount, getTypeFromValue } from '../../helpers/utils';
8
8
  import { IWithReqoreSize } from '../../types/global';
9
9
  import ReqoreButton from '../Button';
10
10
  import ReqoreControlGroup from '../ControlGroup';
11
+ import { IReqorePanelProps } from '../Panel';
11
12
  import ReqoreTag from '../Tag';
12
13
 
13
- export interface IReqoreTreeProps extends IWithReqoreSize {
14
+ export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
14
15
  data: Object | Array<any>;
15
16
  mode?: 'tree' | 'copy';
16
17
  expanded?: boolean;
@@ -20,11 +21,6 @@ export interface IReqoreTreeProps extends IWithReqoreSize {
20
21
  showControls?: boolean;
21
22
  }
22
23
 
23
- const StyledTreeWrapper = styled.div`
24
- display: flex;
25
- flex-flow: column;
26
- `;
27
-
28
24
  export interface ITreeStyle {
29
25
  interactive?: boolean;
30
26
  theme: IReqoreTheme;
@@ -43,6 +39,7 @@ export const ReqoreTree = ({
43
39
  onItemClick,
44
40
  withLabelCopy,
45
41
  showControls = true,
42
+ ...rest
46
43
  }: IReqoreTreeProps) => {
47
44
  const [_mode, setMode] = useState<'tree' | 'copy'>(mode);
48
45
  const [items, setItems] = useState({});
@@ -179,74 +176,62 @@ export const ReqoreTree = ({
179
176
  const lineCount: number = getLineCount(textData);
180
177
 
181
178
  return (
182
- <StyledTreeWrapper className='reqore-tree'>
183
- {showControls && (
184
- <ReqoreControlGroup stack size={size} responsive>
185
- {isDeep() && !allExpanded ? (
186
- <ReqoreButton
187
- flat
188
- className='reqore-tree-expand-all'
189
- icon='ArrowDownFill'
190
- onClick={handleExpandClick}
191
- key='expand-button'
192
- >
193
- Expand all
194
- </ReqoreButton>
195
- ) : null}
196
- {isDeep() &&
197
- (allExpanded || lodashSize(items) > 0 ? (
198
- <ReqoreButton
199
- flat
200
- className='reqore-tree-collapse-all'
201
- icon='ArrowUpFill'
202
- onClick={handleCollapseClick}
203
- key='collapse-button'
204
- >
205
- {' '}
206
- Collapse all{' '}
207
- </ReqoreButton>
208
- ) : null)}
209
- <ReqoreButton
210
- flat
211
- className='reqore-tree-show-types'
212
- icon='CodeBoxFill'
213
- active={_showTypes}
214
- onClick={handleTypesClick}
215
- >
216
- Show types
217
- </ReqoreButton>
218
- <ReqoreButton
219
- flat
220
- className='reqore-tree-as-tree'
221
- active={_mode === 'tree'}
222
- onClick={handleTreeClick}
223
- icon='Menu2Fill'
224
- >
225
- Tree View
226
- </ReqoreButton>
227
- <ReqoreButton
228
- flat
229
- className='reqore-tree-as-text'
230
- onClick={handleCopyClick}
231
- active={_mode === 'copy'}
232
- icon='ClipboardFill'
233
- >
234
- Text View
235
- </ReqoreButton>
236
- </ReqoreControlGroup>
237
- )}
238
-
239
- {_mode === 'tree' && <div>{renderTree(data, true)}</div>}
179
+ <ReqorePanel
180
+ className='reqore-tree'
181
+ minimal
182
+ flat
183
+ transparent
184
+ size={size}
185
+ {...rest}
186
+ actions={
187
+ showControls
188
+ ? [
189
+ {
190
+ className: 'reqore-tree-expand-all',
191
+ icon: 'ArrowDownFill',
192
+ onClick: handleExpandClick,
193
+ show: !!(isDeep() && !allExpanded),
194
+ label: 'Expand all',
195
+ },
196
+ {
197
+ show: !!(isDeep() && (allExpanded || lodashSize(items) > 0)),
198
+ className: 'reqore-tree-collapse-all',
199
+ icon: 'ArrowUpFill',
200
+ onClick: handleCollapseClick,
201
+
202
+ label: 'Collapse all',
203
+ },
204
+ {
205
+ className: 'reqore-tree-show-types',
206
+ icon: 'CodeBoxFill',
207
+ active: _showTypes,
208
+ onClick: handleTypesClick,
209
+ label: 'Show types',
210
+ },
211
+ {
212
+ className: _mode === 'tree' ? 'reqore-tree-as-text' : 'reqore-tree-as-tree',
213
+ onClick: _mode === 'tree' ? handleCopyClick : handleTreeClick,
214
+ icon: _mode === 'tree' ? 'Menu2Fill' : 'ClipboardFill',
215
+ label: _mode === 'tree' ? 'Text View' : 'Tree View',
216
+ },
217
+ ]
218
+ : undefined
219
+ }
220
+ >
221
+ {_mode === 'tree' && renderTree(data, true)}
240
222
 
241
223
  {_mode === 'copy' && (
242
224
  <ReqoreTextarea
243
225
  className='reqore-tree-textarea'
244
226
  id='tree-content'
245
227
  defaultValue={textData}
228
+ scaleWithContent
246
229
  size={size}
230
+ fluid
231
+ readOnly
247
232
  rows={lineCount > 20 ? 20 : lineCount}
248
233
  />
249
234
  )}
250
- </StyledTreeWrapper>
235
+ </ReqorePanel>
251
236
  );
252
237
  };