@qoretechnologies/reqore 0.30.6 → 0.30.8
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/CODE_OF_CONDUCT.md +104 -104
- package/CONTRIBUTING.MD +78 -78
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/SECURITY.md +5 -5
- package/__tests__/collection.test.tsx +1 -1
- package/__tests__/{control_group.text.tsx → control_group.test.tsx} +4 -2
- package/__tests__/modal.test.tsx +74 -2
- package/__tests__/panel.test.tsx +96 -24
- package/__tests__/popover.test.tsx +24 -2
- package/__tests__/tabs.test.tsx +75 -0
- package/dist/components/Button/index.d.ts +6 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +30 -20
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +6 -3
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Collection/index.d.ts +7 -2
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +57 -53
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Collection/item.d.ts +5 -5
- package/dist/components/Collection/item.d.ts.map +1 -1
- package/dist/components/Collection/item.js +15 -4
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/Columns/column.d.ts.map +1 -1
- package/dist/components/Columns/column.js +1 -1
- package/dist/components/Columns/column.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts +21 -4
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +250 -55
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts +2 -2
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +27 -16
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +1 -0
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +2 -2
- package/dist/components/Dropdown/index.js.map +1 -1
- 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 +7 -6
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts +5 -6
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +14 -7
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +10 -4
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +12 -10
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Message/index.d.ts +2 -0
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +2 -2
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.js +10 -10
- package/dist/components/MultiSelect/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts +13 -6
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +78 -44
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Popover/index.d.ts +1 -2
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +2 -2
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Spacer/index.d.ts +2 -0
- package/dist/components/Spacer/index.d.ts.map +1 -1
- package/dist/components/Spacer/index.js +29 -7
- package/dist/components/Spacer/index.js.map +1 -1
- package/dist/components/Table/header.js +2 -2
- package/dist/components/Table/header.js.map +1 -1
- package/dist/components/Table/headerCell.js +2 -2
- package/dist/components/Table/headerCell.js.map +1 -1
- package/dist/components/Table/helpers.d.ts +3 -2
- package/dist/components/Table/helpers.d.ts.map +1 -1
- package/dist/components/Table/helpers.js +6 -3
- package/dist/components/Table/helpers.js.map +1 -1
- package/dist/components/Table/index.d.ts +1 -0
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/row.d.ts +0 -5
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Table/row.js +3 -7
- package/dist/components/Table/row.js.map +1 -1
- package/dist/components/Tabs/content.d.ts +3 -1
- package/dist/components/Tabs/content.d.ts.map +1 -1
- package/dist/components/Tabs/content.js +8 -3
- package/dist/components/Tabs/content.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +4 -1
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js +12 -4
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/item.d.ts +1 -0
- package/dist/components/Tabs/item.d.ts.map +1 -1
- package/dist/components/Tabs/item.js +7 -7
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tabs/list.d.ts +1 -1
- package/dist/components/Tabs/list.d.ts.map +1 -1
- package/dist/components/Tabs/list.js +7 -6
- package/dist/components/Tabs/list.js.map +1 -1
- package/dist/components/Tag/group.d.ts +2 -2
- package/dist/components/Tag/group.d.ts.map +1 -1
- package/dist/components/Tag/group.js +7 -8
- package/dist/components/Tag/group.js.map +1 -1
- package/dist/components/Tag/index.d.ts +6 -2
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +24 -12
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Tree/index.js +1 -1
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/constants/animations.js +1 -1
- package/dist/constants/sizes.js +10 -10
- package/dist/constants/sizes.js.map +1 -1
- package/dist/containers/PopoverProvider.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.js +10 -8
- package/dist/containers/PopoverProvider.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +4 -2
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +7 -0
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/context/ReqoreContext.d.ts +2 -0
- package/dist/context/ReqoreContext.d.ts.map +1 -1
- package/dist/context/ReqoreContext.js.map +1 -1
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/colors.d.ts.map +1 -1
- package/dist/helpers/colors.js +6 -2
- package/dist/helpers/colors.js.map +1 -1
- package/dist/helpers/utils.d.ts +3 -0
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +16 -1
- package/dist/helpers/utils.js.map +1 -1
- package/dist/hooks/useLatestZIndex.js +2 -2
- package/dist/hooks/useLatestZIndex.js.map +1 -1
- package/dist/hooks/usePopover.d.ts +1 -0
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +8 -6
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/styles.d.ts +1 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +6 -5
- package/dist/styles.js.map +1 -1
- package/dist/types/global.d.ts +26 -0
- package/dist/types/global.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +79 -34
- package/src/components/Checkbox/index.tsx +3 -2
- package/src/components/Collection/index.tsx +93 -60
- package/src/components/Collection/item.tsx +29 -9
- package/src/components/Columns/column.tsx +1 -0
- package/src/components/ControlGroup/index.tsx +449 -104
- package/src/components/Drawer/index.tsx +28 -27
- package/src/components/Dropdown/index.tsx +3 -1
- package/src/components/Effect/index.tsx +22 -14
- package/src/components/Icon/index.tsx +81 -62
- package/src/components/Input/index.tsx +8 -3
- package/src/components/InternalPopover/index.tsx +131 -126
- package/src/components/Menu/index.tsx +7 -1
- package/src/components/Message/index.tsx +9 -1
- package/src/components/MultiSelect/index.tsx +180 -188
- package/src/components/Panel/index.tsx +227 -100
- package/src/components/Popover/index.tsx +1 -3
- package/src/components/Spacer/index.tsx +63 -14
- package/src/components/Table/header.tsx +2 -2
- package/src/components/Table/headerCell.tsx +2 -2
- package/src/components/Table/helpers.ts +12 -6
- package/src/components/Table/index.tsx +1 -0
- package/src/components/Table/row.tsx +2 -7
- package/src/components/Tabs/content.tsx +11 -3
- package/src/components/Tabs/index.tsx +14 -3
- package/src/components/Tabs/item.tsx +28 -5
- package/src/components/Tabs/list.tsx +7 -3
- package/src/components/Tag/group.tsx +6 -12
- package/src/components/Tag/index.tsx +69 -35
- package/src/components/Tree/index.tsx +1 -1
- package/src/constants/animations.ts +1 -1
- package/src/constants/sizes.ts +10 -10
- package/src/containers/PopoverProvider.tsx +11 -8
- package/src/containers/ReqoreProvider.tsx +40 -35
- package/src/containers/UIProvider.tsx +7 -0
- package/src/context/ReqoreContext.tsx +2 -0
- package/src/helpers/colors.ts +8 -2
- package/src/helpers/utils.ts +18 -0
- package/src/hooks/useLatestZIndex.ts +2 -2
- package/src/hooks/usePopover.tsx +9 -6
- package/src/mock/collectionData.tsx +33 -2
- package/src/stories/Button/Button.stories.tsx +72 -7
- package/src/stories/Checkbox/Checkbox.stories.tsx +6 -3
- package/src/stories/Collection/Collection.stories.tsx +18 -2
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +282 -33
- package/src/stories/Drawer/Drawer.stories.tsx +70 -3
- package/src/stories/Dropdown/Dropdown.stories.tsx +13 -3
- package/src/stories/Icon/Icon.stories.tsx +1 -0
- package/src/stories/Input/Input.stories.tsx +5 -3
- package/src/stories/Menu/Menu.stories.tsx +2 -0
- package/src/stories/Message/Message.stories.tsx +7 -0
- package/src/stories/Panel/Panel.stories.tsx +147 -13
- package/src/stories/Popover/Popover.stories.tsx +88 -82
- package/src/stories/Tabs/Tabs.stories.tsx +33 -15
- package/src/stories/Tag/Tag.stories.tsx +23 -3
- package/src/stories/TextArea/TextArea.stories.tsx +3 -3
- package/src/styles.ts +6 -0
- package/src/types/global.ts +28 -0
- package/tests.json +1 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
|
|
12
12
|
import ReqoreContext from '../../context/ReqoreContext';
|
|
13
13
|
import { changeLightness, getReadableColor, getReadableColorFrom } from '../../helpers/colors';
|
|
14
|
-
import { getOneLessSize } from '../../helpers/utils';
|
|
14
|
+
import { alignToFlexAlign, getOneLessSize } from '../../helpers/utils';
|
|
15
15
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
16
16
|
import { useReqoreEffect } from '../../hooks/useReqoreEffect';
|
|
17
17
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
} from '../../types/global';
|
|
34
34
|
import { IReqoreIconName } from '../../types/icons';
|
|
35
35
|
import {
|
|
36
|
+
IReqoreEffect,
|
|
36
37
|
ReqoreTextEffect,
|
|
37
38
|
StyledEffect,
|
|
38
39
|
StyledTextEffect,
|
|
@@ -67,6 +68,11 @@ export interface IReqoreButtonProps
|
|
|
67
68
|
description?: string | number;
|
|
68
69
|
maxWidth?: string;
|
|
69
70
|
textAlign?: 'left' | 'center' | 'right';
|
|
71
|
+
iconColor?: TReqoreEffectColor;
|
|
72
|
+
leftIconColor?: TReqoreEffectColor;
|
|
73
|
+
rightIconColor?: TReqoreEffectColor;
|
|
74
|
+
labelEffect?: IReqoreEffect;
|
|
75
|
+
descriptionEffect?: IReqoreEffect;
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
export interface IReqoreButtonStyle extends Omit<IReqoreButtonProps, 'intent'> {
|
|
@@ -86,10 +92,13 @@ const getButtonMainColor = (theme: IReqoreTheme, color?: TReqoreHexColor) => {
|
|
|
86
92
|
export const StyledAnimatedTextWrapper = styled.span`
|
|
87
93
|
overflow: hidden;
|
|
88
94
|
position: relative;
|
|
89
|
-
text-align:
|
|
95
|
+
text-align: ${({ textAlign }) => textAlign};
|
|
96
|
+
display: flex;
|
|
97
|
+
flex-flow: column;
|
|
98
|
+
align-items: ${({ textAlign }) => alignToFlexAlign(textAlign)};
|
|
90
99
|
`;
|
|
91
100
|
|
|
92
|
-
export const StyledActiveContent = styled
|
|
101
|
+
export const StyledActiveContent = styled(StyledTextEffect)`
|
|
93
102
|
position: absolute;
|
|
94
103
|
transform: translateY(-150%);
|
|
95
104
|
opacity: 0;
|
|
@@ -109,7 +118,7 @@ export const StyledActiveContent = styled.span`
|
|
|
109
118
|
`}
|
|
110
119
|
`;
|
|
111
120
|
|
|
112
|
-
export const StyledInActiveContent = styled
|
|
121
|
+
export const StyledInActiveContent = styled(StyledTextEffect)`
|
|
113
122
|
position: absolute;
|
|
114
123
|
transform: translateY(0);
|
|
115
124
|
transition: all 0.2s ease-out;
|
|
@@ -127,7 +136,7 @@ export const StyledInActiveContent = styled.span`
|
|
|
127
136
|
`}
|
|
128
137
|
`;
|
|
129
138
|
|
|
130
|
-
export const StyledInvisibleContent = styled
|
|
139
|
+
export const StyledInvisibleContent = styled(StyledTextEffect)`
|
|
131
140
|
visibility: hidden;
|
|
132
141
|
position: relative;
|
|
133
142
|
overflow: hidden;
|
|
@@ -158,7 +167,7 @@ export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
|
|
|
158
167
|
|
|
159
168
|
min-height: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
160
169
|
min-width: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
161
|
-
max-width: ${({ maxWidth }) => maxWidth || undefined};
|
|
170
|
+
max-width: ${({ maxWidth, fluid, fixed }) => maxWidth || (fluid && !fixed ? '100%' : undefined)};
|
|
162
171
|
${({ wrap, description }) =>
|
|
163
172
|
!wrap && !description
|
|
164
173
|
? css`
|
|
@@ -167,6 +176,7 @@ export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
|
|
|
167
176
|
: null}
|
|
168
177
|
|
|
169
178
|
flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto')};
|
|
179
|
+
align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
|
|
170
180
|
|
|
171
181
|
border-radius: ${({ size }) => RADIUS_FROM_SIZE[size]}px;
|
|
172
182
|
|
|
@@ -197,7 +207,7 @@ export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
|
|
|
197
207
|
transition: all 0.2s ease-out;
|
|
198
208
|
|
|
199
209
|
&:active {
|
|
200
|
-
transform:
|
|
210
|
+
transform: scale(0.97);
|
|
201
211
|
}
|
|
202
212
|
|
|
203
213
|
&:hover,
|
|
@@ -237,24 +247,32 @@ export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
|
|
|
237
247
|
`
|
|
238
248
|
: undefined}
|
|
239
249
|
|
|
240
|
-
${({ active, flat, theme, color }: IReqoreButtonStyle) =>
|
|
241
|
-
active
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
&:focus {
|
|
250
|
+
${({ active, flat, theme, color }: IReqoreButtonStyle) => {
|
|
251
|
+
if (active) {
|
|
252
|
+
return css`
|
|
253
|
+
cursor: pointer;
|
|
254
|
+
background-color: ${changeLightness(getButtonMainColor(theme, color), 0.1)};
|
|
255
|
+
color: ${getReadableColor(
|
|
256
|
+
{ main: changeLightness(getButtonMainColor(theme, color), 0.1) },
|
|
257
|
+
undefined,
|
|
258
|
+
undefined
|
|
259
|
+
)};
|
|
251
260
|
border-color: ${flat
|
|
252
261
|
? undefined
|
|
253
|
-
: changeLightness(getButtonMainColor(theme, color), 0.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
262
|
+
: changeLightness(getButtonMainColor(theme, color), 0.175)};
|
|
263
|
+
|
|
264
|
+
&:hover,
|
|
265
|
+
&:active,
|
|
266
|
+
&:focus {
|
|
267
|
+
border-color: ${flat
|
|
268
|
+
? undefined
|
|
269
|
+
: changeLightness(getButtonMainColor(theme, color), 0.275)};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
${ActiveIconScale}
|
|
273
|
+
`;
|
|
274
|
+
}
|
|
275
|
+
}}
|
|
258
276
|
|
|
259
277
|
&:disabled {
|
|
260
278
|
${DisabledElement};
|
|
@@ -270,7 +288,7 @@ export const StyledButton = styled(StyledEffect)<IReqoreButtonStyle>`
|
|
|
270
288
|
minimal ? undefined : changeLightness(getButtonMainColor(theme, color), 0.4)};
|
|
271
289
|
}
|
|
272
290
|
|
|
273
|
-
|
|
291
|
+
.reqore-button-description {
|
|
274
292
|
padding-bottom: ${({ size }) => PADDING_FROM_SIZE[getOneLessSize(size)]}px;
|
|
275
293
|
}
|
|
276
294
|
`;
|
|
@@ -325,7 +343,7 @@ export const ButtonBadge = memo((props: IReqoreButtonBadgeProps) => {
|
|
|
325
343
|
width={props.wrap ? undefined : PADDING_FROM_SIZE[props.size]}
|
|
326
344
|
height={!props.wrap ? undefined : PADDING_FROM_SIZE[props.size] / 2}
|
|
327
345
|
/>
|
|
328
|
-
<ReqoreTagGroup
|
|
346
|
+
<ReqoreTagGroup>
|
|
329
347
|
{props.content.map((badge, index) => renderTag({ ...props, content: badge, key: index }))}
|
|
330
348
|
</ReqoreTagGroup>
|
|
331
349
|
</>
|
|
@@ -367,6 +385,11 @@ const ReqoreButton = memo(
|
|
|
367
385
|
maxWidth,
|
|
368
386
|
textAlign = 'left',
|
|
369
387
|
effect,
|
|
388
|
+
labelEffect,
|
|
389
|
+
descriptionEffect,
|
|
390
|
+
leftIconColor,
|
|
391
|
+
rightIconColor,
|
|
392
|
+
iconColor,
|
|
370
393
|
...rest
|
|
371
394
|
}: IReqoreButtonProps,
|
|
372
395
|
ref
|
|
@@ -391,10 +414,14 @@ const ReqoreButton = memo(
|
|
|
391
414
|
return (
|
|
392
415
|
<StyledButton
|
|
393
416
|
{...rest}
|
|
394
|
-
effect={
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
417
|
+
effect={
|
|
418
|
+
intent
|
|
419
|
+
? undefined
|
|
420
|
+
: {
|
|
421
|
+
interactive: !readOnly && !rest.disabled,
|
|
422
|
+
...fixedEffect,
|
|
423
|
+
}
|
|
424
|
+
}
|
|
398
425
|
as='button'
|
|
399
426
|
theme={theme}
|
|
400
427
|
ref={targetRef}
|
|
@@ -415,7 +442,12 @@ const ReqoreButton = memo(
|
|
|
415
442
|
<StyledButtonContent size={size} wrap={wrap} description={description} flat={_flat}>
|
|
416
443
|
{icon && (
|
|
417
444
|
<>
|
|
418
|
-
<ReqoreIcon
|
|
445
|
+
<ReqoreIcon
|
|
446
|
+
icon={icon}
|
|
447
|
+
size={size}
|
|
448
|
+
color={leftIconColor || iconColor}
|
|
449
|
+
style={textAlign !== 'left' ? { marginRight: 'auto' } : undefined}
|
|
450
|
+
/>
|
|
419
451
|
{children || badge || rightIcon ? (
|
|
420
452
|
<ReqoreSpacer width={PADDING_FROM_SIZE[size]} />
|
|
421
453
|
) : null}
|
|
@@ -423,9 +455,15 @@ const ReqoreButton = memo(
|
|
|
423
455
|
)}
|
|
424
456
|
{children && (
|
|
425
457
|
<StyledAnimatedTextWrapper textAlign={textAlign}>
|
|
426
|
-
<StyledActiveContent wrap={wrap}
|
|
427
|
-
|
|
428
|
-
|
|
458
|
+
<StyledActiveContent wrap={wrap} effect={labelEffect}>
|
|
459
|
+
{children}
|
|
460
|
+
</StyledActiveContent>
|
|
461
|
+
<StyledInActiveContent wrap={wrap} effect={labelEffect}>
|
|
462
|
+
{children}
|
|
463
|
+
</StyledInActiveContent>
|
|
464
|
+
<StyledInvisibleContent wrap={wrap} effect={labelEffect}>
|
|
465
|
+
{children}
|
|
466
|
+
</StyledInvisibleContent>
|
|
429
467
|
{(badge || badge === 0) && wrap ? (
|
|
430
468
|
<ButtonBadge content={badge} size={size} color={color} wrap />
|
|
431
469
|
) : null}
|
|
@@ -437,18 +475,25 @@ const ReqoreButton = memo(
|
|
|
437
475
|
{rightIcon && (
|
|
438
476
|
<>
|
|
439
477
|
{children || badge ? <ReqoreSpacer width={PADDING_FROM_SIZE[size]} /> : null}
|
|
440
|
-
<ReqoreIcon
|
|
478
|
+
<ReqoreIcon
|
|
479
|
+
icon={rightIcon}
|
|
480
|
+
size={size}
|
|
481
|
+
style={textAlign !== 'right' ? { marginLeft: 'auto' } : undefined}
|
|
482
|
+
color={rightIconColor || iconColor}
|
|
483
|
+
/>
|
|
441
484
|
</>
|
|
442
485
|
)}
|
|
443
486
|
</StyledButtonContent>
|
|
444
487
|
|
|
445
488
|
{description && (
|
|
446
489
|
<ReqoreTextEffect
|
|
490
|
+
className='reqore-button-description'
|
|
447
491
|
effect={{
|
|
448
492
|
textSize: getOneLessSize(size),
|
|
449
493
|
weight: 'light',
|
|
450
494
|
color: `${color}90`,
|
|
451
495
|
textAlign,
|
|
496
|
+
...descriptionEffect,
|
|
452
497
|
}}
|
|
453
498
|
>
|
|
454
499
|
{description}
|
|
@@ -137,7 +137,8 @@ const StyledCheckbox = styled.div<IReqoreCheckboxStyle>`
|
|
|
137
137
|
height: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
138
138
|
font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
max-width: ${({ fluid, fixed }) => (fluid && !fixed ? '100%' : undefined)};
|
|
141
|
+
flex: ${({ fluid, fixed }) => (fixed ? '0 auto' : fluid ? '1 auto' : '0 0 auto')};
|
|
141
142
|
|
|
142
143
|
${({ disabled }) =>
|
|
143
144
|
disabled &&
|
|
@@ -272,7 +273,7 @@ const Checkbox = forwardRef<HTMLDivElement, IReqoreCheckboxProps>(
|
|
|
272
273
|
textSize: getOneLessSize(size),
|
|
273
274
|
weight: 'bold',
|
|
274
275
|
...switchTextEffect,
|
|
275
|
-
opacity: checked ? 0.
|
|
276
|
+
opacity: checked ? 0.3 : 1,
|
|
276
277
|
} as IReqoreEffect
|
|
277
278
|
}
|
|
278
279
|
>
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
|
+
import { useUpdateEffect } from 'react-use';
|
|
3
4
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import {
|
|
5
|
+
import { IReqoreIconName } from '../../types/icons';
|
|
5
6
|
import { IReqoreColumnsProps, StyledColumns } from '../Columns';
|
|
6
7
|
import ReqoreInput from '../Input';
|
|
7
8
|
import ReqoreMessage from '../Message';
|
|
8
|
-
import { IReqorePanelAction, IReqorePanelProps, ReqorePanel } from '../Panel';
|
|
9
|
+
import { IReqorePanelAction, IReqorePanelProps, ReqorePanel, TReqorePanelActions } from '../Panel';
|
|
9
10
|
import { sortTableData } from '../Table/helpers';
|
|
10
11
|
import { IReqoreCollectionItemProps, ReqoreCollectionItem } from './item';
|
|
11
12
|
|
|
12
13
|
export interface IReqoreCollectionProps
|
|
13
14
|
extends Pick<
|
|
14
15
|
IReqorePanelProps,
|
|
15
|
-
|
|
16
|
+
| 'size'
|
|
17
|
+
| 'intent'
|
|
18
|
+
| 'customTheme'
|
|
19
|
+
| 'actions'
|
|
20
|
+
| 'bottomActions'
|
|
21
|
+
| 'label'
|
|
22
|
+
| 'headerSize'
|
|
23
|
+
| 'badge'
|
|
24
|
+
| 'icon'
|
|
25
|
+
| 'flat'
|
|
26
|
+
| 'minimal'
|
|
27
|
+
| 'transparent'
|
|
28
|
+
| 'fluid'
|
|
16
29
|
>,
|
|
17
30
|
IReqoreColumnsProps {
|
|
18
31
|
items?: IReqoreCollectionItemProps[];
|
|
@@ -23,6 +36,10 @@ export interface IReqoreCollectionProps
|
|
|
23
36
|
maxItemHeight?: number;
|
|
24
37
|
filterable?: boolean;
|
|
25
38
|
sortable?: boolean;
|
|
39
|
+
showAs?: 'list' | 'grid';
|
|
40
|
+
showSelectedFirst?: boolean;
|
|
41
|
+
selectedIcon?: IReqoreIconName;
|
|
42
|
+
emptyMessage?: string;
|
|
26
43
|
}
|
|
27
44
|
|
|
28
45
|
export const StyledCollectionWrapper = styled(StyledColumns)`
|
|
@@ -48,17 +65,53 @@ export const ReqoreCollection = ({
|
|
|
48
65
|
maxItemHeight,
|
|
49
66
|
filterable,
|
|
50
67
|
sortable,
|
|
68
|
+
showSelectedFirst,
|
|
51
69
|
headerSize = 2,
|
|
70
|
+
showAs = 'grid',
|
|
71
|
+
selectedIcon,
|
|
72
|
+
flat = true,
|
|
73
|
+
minimal,
|
|
74
|
+
transparent = true,
|
|
75
|
+
emptyMessage = 'No data in this collection, try changing your search query or filters',
|
|
52
76
|
...rest
|
|
53
77
|
}: IReqoreCollectionProps) => {
|
|
54
|
-
const [
|
|
78
|
+
const [_showAs, setShowAs] = useState<'list' | 'grid'>(showAs);
|
|
55
79
|
const [sort, setSort] = useState<'asc' | 'desc'>('asc');
|
|
56
80
|
const [query, setQuery] = useState<string>('');
|
|
57
81
|
|
|
58
|
-
|
|
59
|
-
()
|
|
60
|
-
|
|
61
|
-
|
|
82
|
+
useUpdateEffect(() => {
|
|
83
|
+
setShowAs(showAs);
|
|
84
|
+
}, [showAs]);
|
|
85
|
+
|
|
86
|
+
const sortedItems: IReqoreCollectionItemProps[] = useMemo(() => {
|
|
87
|
+
if (!sortable) {
|
|
88
|
+
return items;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (showSelectedFirst) {
|
|
92
|
+
// Filter out the selected items
|
|
93
|
+
const selectedItems = items.filter((item) => item.selected);
|
|
94
|
+
// Filter out the unselected items
|
|
95
|
+
const unselectedItems = items.filter((item) => !item.selected);
|
|
96
|
+
// Sort the selected items
|
|
97
|
+
const sortedSelectedItems = sortTableData(selectedItems, {
|
|
98
|
+
by: 'label',
|
|
99
|
+
direction: sort,
|
|
100
|
+
});
|
|
101
|
+
// Sort the unselected items
|
|
102
|
+
const sortedUnselectedItems = sortTableData(unselectedItems, {
|
|
103
|
+
by: 'label',
|
|
104
|
+
direction: sort,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return [...sortedSelectedItems, ...sortedUnselectedItems];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return sortTableData(items, {
|
|
111
|
+
by: 'label',
|
|
112
|
+
direction: sort,
|
|
113
|
+
});
|
|
114
|
+
}, [items, sort]);
|
|
62
115
|
|
|
63
116
|
const filteredItems: IReqoreCollectionItemProps[] = useMemo(() => {
|
|
64
117
|
if (!filterable || query === '') {
|
|
@@ -81,8 +134,29 @@ export const ReqoreCollection = ({
|
|
|
81
134
|
};
|
|
82
135
|
|
|
83
136
|
const finalItems = filteredItems;
|
|
84
|
-
const finalActions:
|
|
85
|
-
let actions:
|
|
137
|
+
const finalActions: TReqorePanelActions = useMemo(() => {
|
|
138
|
+
let actions: TReqorePanelActions = rest.actions ? [...rest.actions] : [];
|
|
139
|
+
|
|
140
|
+
const toolbarGroup: IReqorePanelAction = {
|
|
141
|
+
responsive: false,
|
|
142
|
+
group: [
|
|
143
|
+
{
|
|
144
|
+
icon: _showAs === 'grid' ? 'ListOrdered' : 'GridLine',
|
|
145
|
+
onClick: () => setShowAs(_showAs === 'grid' ? 'list' : 'grid'),
|
|
146
|
+
tooltip: _showAs === 'grid' ? 'Show as list' : 'Show as grid',
|
|
147
|
+
disabled: !size(finalItems),
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
if (sortable) {
|
|
153
|
+
toolbarGroup.group.push({
|
|
154
|
+
icon: sort === 'desc' ? 'SortDesc' : 'SortAsc',
|
|
155
|
+
onClick: () => setSort(sort === 'desc' ? 'asc' : 'desc'),
|
|
156
|
+
tooltip: sort === 'desc' ? 'Sort ascending' : 'Sort descending',
|
|
157
|
+
disabled: !size(finalItems),
|
|
158
|
+
});
|
|
159
|
+
}
|
|
86
160
|
|
|
87
161
|
if (filterable) {
|
|
88
162
|
actions = [
|
|
@@ -101,74 +175,32 @@ export const ReqoreCollection = ({
|
|
|
101
175
|
];
|
|
102
176
|
}
|
|
103
177
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
...actions,
|
|
107
|
-
[
|
|
108
|
-
{
|
|
109
|
-
icon: 'SortAsc',
|
|
110
|
-
intent: sort === 'asc' ? ReqoreIntents.INFO : undefined,
|
|
111
|
-
onClick: () => setSort('asc'),
|
|
112
|
-
active: sort === 'asc',
|
|
113
|
-
tooltip: 'Sort ascending',
|
|
114
|
-
disabled: !size(finalItems),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
icon: 'SortDesc',
|
|
118
|
-
intent: sort === 'desc' ? ReqoreIntents.INFO : undefined,
|
|
119
|
-
onClick: () => setSort('desc'),
|
|
120
|
-
active: sort === 'desc',
|
|
121
|
-
tooltip: 'Sort descending',
|
|
122
|
-
disabled: !size(finalItems),
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return [
|
|
129
|
-
...actions,
|
|
130
|
-
[
|
|
131
|
-
{
|
|
132
|
-
icon: 'GridLine',
|
|
133
|
-
onClick: () => setShowAs('grid'),
|
|
134
|
-
intent: showAs === 'grid' ? ReqoreIntents.INFO : undefined,
|
|
135
|
-
active: showAs === 'grid',
|
|
136
|
-
tooltip: 'Show as grid',
|
|
137
|
-
disabled: !size(finalItems),
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
icon: 'ListOrdered',
|
|
141
|
-
onClick: () => setShowAs('list'),
|
|
142
|
-
intent: showAs === 'list' ? ReqoreIntents.INFO : undefined,
|
|
143
|
-
active: showAs === 'list',
|
|
144
|
-
tooltip: 'Show as list',
|
|
145
|
-
disabled: !size(finalItems),
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
...(rest.actions || []),
|
|
149
|
-
];
|
|
150
|
-
}, [filterable, handleQueryChange, query, rest.actions, showAs, sort, sortable, finalItems]);
|
|
178
|
+
return [...actions, toolbarGroup];
|
|
179
|
+
}, [filterable, handleQueryChange, query, rest.actions, _showAs, sort, sortable, finalItems]);
|
|
151
180
|
|
|
152
181
|
return (
|
|
153
182
|
<ReqorePanel
|
|
154
183
|
{...rest}
|
|
155
184
|
headerSize={headerSize}
|
|
156
185
|
style={{
|
|
186
|
+
...rest.style,
|
|
157
187
|
height: height ?? undefined,
|
|
158
188
|
}}
|
|
159
189
|
fill={fill}
|
|
160
190
|
padded
|
|
161
|
-
|
|
191
|
+
transparent={transparent}
|
|
192
|
+
minimal={minimal}
|
|
193
|
+
flat={flat}
|
|
162
194
|
actions={finalActions}
|
|
163
195
|
className={`reqore-collection ${rest.className || ''}`}
|
|
164
196
|
>
|
|
165
197
|
{!size(finalItems) ? (
|
|
166
198
|
<ReqoreMessage intent='muted' flat title='No items found'>
|
|
167
|
-
|
|
199
|
+
{emptyMessage}
|
|
168
200
|
</ReqoreMessage>
|
|
169
201
|
) : (
|
|
170
202
|
<StyledCollectionWrapper
|
|
171
|
-
columns={
|
|
203
|
+
columns={_showAs === 'grid' ? 'auto-fit' : 1}
|
|
172
204
|
columnsGap={stacked ? '0px' : columnsGap}
|
|
173
205
|
rounded={rounded}
|
|
174
206
|
stacked={stacked}
|
|
@@ -177,6 +209,7 @@ export const ReqoreCollection = ({
|
|
|
177
209
|
{finalItems?.map((item) => (
|
|
178
210
|
<ReqoreCollectionItem
|
|
179
211
|
{...item}
|
|
212
|
+
icon={item.icon || (item.selected ? selectedIcon : undefined)}
|
|
180
213
|
key={item.id || item.label.toString()}
|
|
181
214
|
rounded={!stacked}
|
|
182
215
|
maxContentHeight={maxItemHeight}
|
|
@@ -7,13 +7,13 @@ import ReqoreContext from '../../context/ReqoreContext';
|
|
|
7
7
|
import { changeDarkness, getMainBackgroundColor } from '../../helpers/colors';
|
|
8
8
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
9
9
|
import { StyledBackdrop } from '../Drawer';
|
|
10
|
-
import { IReqoreDropdownItem } from '../Dropdown/list';
|
|
11
10
|
import {
|
|
12
11
|
IReqorePanelAction,
|
|
13
12
|
IReqorePanelBottomAction,
|
|
14
13
|
IReqorePanelProps,
|
|
15
14
|
ReqorePanel,
|
|
16
15
|
} from '../Panel';
|
|
16
|
+
import { ReqoreP } from '../Paragraph';
|
|
17
17
|
import { ReqoreSpacer } from '../Spacer';
|
|
18
18
|
import ReqoreTag, { IReqoreTagProps } from '../Tag';
|
|
19
19
|
import ReqoreTagGroup from '../Tag/group';
|
|
@@ -29,22 +29,24 @@ export interface IReqoreCollectionItemProps
|
|
|
29
29
|
| 'unMountContentOnCollapse'
|
|
30
30
|
| 'bottomActions'
|
|
31
31
|
> {
|
|
32
|
-
|
|
32
|
+
selected?: boolean;
|
|
33
33
|
content?: string | React.ReactNode;
|
|
34
34
|
expandable?: boolean;
|
|
35
35
|
expandedContent?: string | React.ReactNode;
|
|
36
36
|
expandedActions?: IReqorePanelBottomAction[];
|
|
37
37
|
image?: string;
|
|
38
|
-
actions?:
|
|
38
|
+
actions?: IReqorePanelAction[];
|
|
39
39
|
tags?: IReqoreTagProps[];
|
|
40
40
|
maxContentHeight?: number;
|
|
41
|
+
showContentFade?: boolean;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export const StyledCollectionItemContent = styled.div`
|
|
44
45
|
max-height: ${({ providedHeight }) => (providedHeight ? `${providedHeight}px` : 'auto')};
|
|
45
|
-
overflow: hidden;
|
|
46
|
+
overflow: ${({ isSelected }) => (isSelected ? 'auto' : 'hidden')};
|
|
46
47
|
position: relative;
|
|
47
48
|
transition: 0.3s ease-in-out;
|
|
49
|
+
flex: 1;
|
|
48
50
|
|
|
49
51
|
${({ contentOverflows, theme, opacity = 1 }) =>
|
|
50
52
|
contentOverflows &&
|
|
@@ -69,7 +71,6 @@ export const StyledCollectionItemContent = styled.div`
|
|
|
69
71
|
export const ReqoreCollectionItem = ({
|
|
70
72
|
flat = true,
|
|
71
73
|
minimal = true,
|
|
72
|
-
headerSize = 3,
|
|
73
74
|
style,
|
|
74
75
|
content,
|
|
75
76
|
actions,
|
|
@@ -78,6 +79,7 @@ export const ReqoreCollectionItem = ({
|
|
|
78
79
|
expandedContent,
|
|
79
80
|
expandedActions,
|
|
80
81
|
maxContentHeight,
|
|
82
|
+
showContentFade = true,
|
|
81
83
|
...rest
|
|
82
84
|
}: IReqoreCollectionItemProps) => {
|
|
83
85
|
const [isSelected, setIsSelected] = useState(false);
|
|
@@ -182,7 +184,7 @@ export const ReqoreCollectionItem = ({
|
|
|
182
184
|
{ icon: 'CloseLine', onClick: handleItemClick },
|
|
183
185
|
] as IReqorePanelAction[])
|
|
184
186
|
: size(actions)
|
|
185
|
-
?
|
|
187
|
+
? actions
|
|
186
188
|
: undefined;
|
|
187
189
|
|
|
188
190
|
return (
|
|
@@ -200,7 +202,6 @@ export const ReqoreCollectionItem = ({
|
|
|
200
202
|
)}
|
|
201
203
|
<ReqorePanel
|
|
202
204
|
flat={flat}
|
|
203
|
-
headerSize={headerSize}
|
|
204
205
|
ref={ref}
|
|
205
206
|
minimal={minimal}
|
|
206
207
|
{...rest}
|
|
@@ -212,18 +213,37 @@ export const ReqoreCollectionItem = ({
|
|
|
212
213
|
...dimensions,
|
|
213
214
|
transformOrigin: 'center',
|
|
214
215
|
}}
|
|
216
|
+
contentStyle={{
|
|
217
|
+
...rest.contentStyle,
|
|
218
|
+
display: 'flex',
|
|
219
|
+
flexFlow: 'column',
|
|
220
|
+
justifyContent: 'space-between',
|
|
221
|
+
}}
|
|
215
222
|
onClick={(expandable && !isSelected) || rest.onClick ? handleItemClick : undefined}
|
|
216
223
|
actions={actualActions}
|
|
217
224
|
className={`reqore-collection-item ${rest.className || ''}`}
|
|
218
225
|
>
|
|
219
226
|
<StyledCollectionItemContent
|
|
220
227
|
theme={theme}
|
|
221
|
-
opacity={rest.opacity}
|
|
228
|
+
opacity={rest.transparent ? 0 : rest.opacity}
|
|
222
229
|
providedHeight={isSelected ? undefined : maxContentHeight}
|
|
223
|
-
|
|
230
|
+
isSelected={isSelected}
|
|
231
|
+
contentOverflows={
|
|
232
|
+
!rest.transparent &&
|
|
233
|
+
!rest.contentEffect &&
|
|
234
|
+
!isSelected &&
|
|
235
|
+
sizes?.height > maxContentHeight &&
|
|
236
|
+
showContentFade
|
|
237
|
+
}
|
|
224
238
|
>
|
|
225
239
|
<div ref={contentRef}>{actualContent}</div>
|
|
226
240
|
</StyledCollectionItemContent>
|
|
241
|
+
{showContentFade &&
|
|
242
|
+
(rest.contentEffect || rest.transparent) &&
|
|
243
|
+
!isSelected &&
|
|
244
|
+
sizes?.height > maxContentHeight ? (
|
|
245
|
+
<ReqoreP>...</ReqoreP>
|
|
246
|
+
) : null}
|
|
227
247
|
{size(tags) ? (
|
|
228
248
|
<>
|
|
229
249
|
<ReqoreSpacer height={10} />
|