@qoretechnologies/reqore 0.30.4 → 0.30.6
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 +105 -0
- package/CONTRIBUTING.MD +78 -0
- package/LICENSE +1 -1
- package/README.md +44 -2
- package/SECURITY.md +5 -0
- package/__tests__/collection.test.tsx +1 -1
- package/__tests__/{control_group.test.tsx → control_group.text.tsx} +2 -4
- package/__tests__/modal.test.tsx +2 -74
- package/__tests__/panel.test.tsx +24 -96
- package/__tests__/popover.test.tsx +2 -24
- package/__tests__/tabs.test.tsx +0 -75
- package/dist/components/Button/index.d.ts +1 -4
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +7 -10
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Collection/index.d.ts +2 -7
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +53 -57
- 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 +4 -15
- 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 +4 -20
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +55 -241
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts +3 -3
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +16 -27
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +0 -1
- 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/Dropdown/list.d.ts +3 -3
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Effect/index.d.ts +9 -9
- package/dist/components/Effect/index.d.ts.map +1 -1
- package/dist/components/Effect/index.js +1 -1
- package/dist/components/Effect/index.js.map +1 -1
- package/dist/components/Icon/index.d.ts +6 -5
- package/dist/components/Icon/index.d.ts.map +1 -1
- package/dist/components/Icon/index.js +7 -14
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +0 -2
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +6 -9
- 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 +10 -12
- 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 +0 -2
- 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 +2 -2
- 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/Notifications/index.d.ts +1 -1
- package/dist/components/Notifications/index.d.ts.map +1 -1
- package/dist/components/Notifications/notification.d.ts +1 -1
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Panel/index.d.ts +6 -13
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +44 -78
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Popover/index.d.ts +2 -1
- 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 +0 -2
- package/dist/components/Spacer/index.d.ts.map +1 -1
- package/dist/components/Spacer/index.js +7 -29
- package/dist/components/Spacer/index.js.map +1 -1
- package/dist/components/Table/helpers.d.ts +2 -3
- package/dist/components/Table/helpers.d.ts.map +1 -1
- package/dist/components/Table/helpers.js +3 -6
- package/dist/components/Table/helpers.js.map +1 -1
- package/dist/components/Table/index.d.ts +3 -4
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Tabs/content.d.ts +1 -3
- package/dist/components/Tabs/content.d.ts.map +1 -1
- package/dist/components/Tabs/content.js +3 -8
- package/dist/components/Tabs/content.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +1 -4
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/index.js +4 -12
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/item.d.ts +0 -1
- 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 +3 -4
- 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 +8 -7
- package/dist/components/Tag/group.js.map +1 -1
- package/dist/components/Tag/index.d.ts +2 -6
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +12 -20
- 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.d.ts +2 -2
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +10 -10
- package/dist/constants/sizes.js.map +1 -1
- package/dist/constants/theme.d.ts +1 -1
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.js +8 -10
- package/dist/containers/PopoverProvider.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +2 -4
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +0 -7
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/context/ReqoreContext.d.ts +0 -2
- package/dist/context/ReqoreContext.d.ts.map +1 -1
- package/dist/context/ReqoreContext.js.map +1 -1
- package/dist/helpers/utils.d.ts +0 -2
- package/dist/helpers/utils.d.ts.map +1 -1
- package/dist/helpers/utils.js +2 -4
- 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 +0 -1
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +6 -8
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/styles.d.ts +0 -1
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +5 -6
- package/dist/styles.js.map +1 -1
- package/dist/types/global.d.ts +1 -27
- package/dist/types/global.d.ts.map +1 -1
- package/dist/types/icons.d.ts +1 -1
- package/dist/types/icons.d.ts.map +1 -1
- package/package.json +1 -1
- package/public/logo-dark.png +0 -0
- package/public/logo.png +0 -0
- package/public/q-symbol.png +0 -0
- package/public/qoreLogo-dark.png +0 -0
- package/public/qoreLogo.png +0 -0
- package/src/components/Button/index.tsx +5 -17
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/Collection/index.tsx +60 -93
- package/src/components/Collection/item.tsx +9 -29
- package/src/components/Columns/column.tsx +0 -1
- package/src/components/ControlGroup/index.tsx +103 -426
- package/src/components/Drawer/index.tsx +27 -28
- package/src/components/Dropdown/index.tsx +1 -3
- package/src/components/Effect/index.tsx +0 -1
- package/src/components/Icon/index.tsx +62 -81
- package/src/components/Input/index.tsx +4 -8
- package/src/components/InternalPopover/index.tsx +126 -131
- package/src/components/Menu/index.tsx +1 -7
- package/src/components/Message/index.tsx +1 -9
- package/src/components/MultiSelect/index.tsx +188 -180
- package/src/components/Panel/index.tsx +100 -227
- package/src/components/Popover/index.tsx +3 -1
- package/src/components/Spacer/index.tsx +14 -63
- package/src/components/Table/helpers.ts +6 -12
- package/src/components/Table/index.tsx +0 -1
- package/src/components/Tabs/content.tsx +3 -11
- package/src/components/Tabs/index.tsx +3 -14
- package/src/components/Tabs/item.tsx +5 -28
- package/src/components/Tabs/list.tsx +0 -4
- package/src/components/Tag/group.tsx +12 -6
- package/src/components/Tag/index.tsx +35 -67
- 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 +8 -11
- package/src/containers/ReqoreProvider.tsx +35 -40
- package/src/containers/UIProvider.tsx +0 -7
- package/src/context/ReqoreContext.tsx +0 -2
- package/src/helpers/utils.ts +0 -3
- package/src/hooks/useLatestZIndex.ts +2 -2
- package/src/hooks/usePopover.tsx +6 -9
- package/src/mock/collectionData.tsx +2 -33
- package/src/stories/Button/Button.stories.tsx +6 -14
- package/src/stories/Checkbox/Checkbox.stories.tsx +3 -6
- package/src/stories/Collection/Collection.stories.tsx +2 -18
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +34 -220
- package/src/stories/Drawer/Drawer.stories.tsx +3 -70
- package/src/stories/Dropdown/Dropdown.stories.tsx +3 -13
- package/src/stories/Icon/Icon.stories.tsx +0 -1
- package/src/stories/Input/Input.stories.tsx +3 -5
- package/src/stories/Menu/Menu.stories.tsx +0 -2
- package/src/stories/Message/Message.stories.tsx +0 -7
- package/src/stories/Panel/Panel.stories.tsx +13 -147
- package/src/stories/Popover/Popover.stories.tsx +82 -88
- package/src/stories/Tabs/Tabs.stories.tsx +15 -32
- package/src/stories/Tag/Tag.stories.tsx +3 -23
- package/src/stories/TextArea/TextArea.stories.tsx +3 -3
- package/src/styles.ts +0 -6
- package/src/types/global.ts +0 -28
- package/tests.json +1 -1
|
@@ -1,52 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { useMount, useUnmount } from 'react-use';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
4
2
|
import styled, { css } from 'styled-components';
|
|
5
|
-
import { ReqoreButton, ReqoreDrawer } from '../..';
|
|
6
3
|
import { GAP_FROM_SIZE, RADIUS_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
7
4
|
import { IReqoreTheme } from '../../constants/theme';
|
|
8
|
-
import {
|
|
9
|
-
IReqoreIntent,
|
|
10
|
-
IWithReqoreCustomTheme,
|
|
11
|
-
IWithReqoreFlat,
|
|
12
|
-
IWithReqoreFluid,
|
|
13
|
-
IWithReqoreMinimal,
|
|
14
|
-
IWithReqoreSize,
|
|
15
|
-
} from '../../types/global';
|
|
5
|
+
import { IWithReqoreFlat, IWithReqoreMinimal, IWithReqoreSize } from '../../types/global';
|
|
16
6
|
|
|
17
7
|
export interface IReqoreControlGroupProps
|
|
18
8
|
extends React.HTMLAttributes<HTMLDivElement>,
|
|
19
9
|
IWithReqoreFlat,
|
|
20
10
|
IWithReqoreSize,
|
|
21
|
-
IWithReqoreMinimal
|
|
22
|
-
IReqoreIntent,
|
|
23
|
-
IWithReqoreFluid,
|
|
24
|
-
IWithReqoreCustomTheme {
|
|
11
|
+
IWithReqoreMinimal {
|
|
25
12
|
stack?: boolean;
|
|
26
13
|
children: any;
|
|
27
|
-
|
|
14
|
+
fluid?: boolean;
|
|
28
15
|
rounded?: boolean;
|
|
29
|
-
responsive?: boolean;
|
|
30
16
|
gapSize?: TSizes;
|
|
31
17
|
/*
|
|
32
18
|
* Whether the contents of the control group should be stacked vertically
|
|
33
19
|
*/
|
|
34
20
|
vertical?: boolean;
|
|
35
|
-
verticalAlign?: 'flex-start' | 'center' | 'flex-end';
|
|
36
|
-
horizontalAlign?: 'flex-start' | 'center' | 'flex-end';
|
|
37
|
-
wrap?: boolean;
|
|
38
|
-
isInsideStackGroup?: boolean;
|
|
39
|
-
isInsideVerticalGroup?: boolean;
|
|
40
|
-
isFirst?: boolean;
|
|
41
|
-
isLast?: boolean;
|
|
42
|
-
isLastInFirstGroup?: boolean;
|
|
43
|
-
isLastInLastGroup?: boolean;
|
|
44
|
-
isFirstInLastGroup?: boolean;
|
|
45
|
-
childrenCount?: number;
|
|
46
|
-
childId?: number;
|
|
47
|
-
isChild?: boolean;
|
|
48
|
-
isFirstGroup?: boolean;
|
|
49
|
-
isLastGroup?: boolean;
|
|
50
21
|
}
|
|
51
22
|
|
|
52
23
|
export interface IReqoreControlGroupStyle extends IReqoreControlGroupProps {
|
|
@@ -56,415 +27,121 @@ export interface IReqoreControlGroupStyle extends IReqoreControlGroupProps {
|
|
|
56
27
|
export const StyledReqoreControlGroup = styled.div<IReqoreControlGroupStyle>`
|
|
57
28
|
display: flex;
|
|
58
29
|
flex: 0 auto;
|
|
59
|
-
width: ${({ fluid
|
|
60
|
-
|
|
61
|
-
align-items: ${({ vertical, fluid, horizontalAlign }) =>
|
|
62
|
-
vertical ? (fluid ? 'stretch' : horizontalAlign) : undefined};
|
|
30
|
+
width: ${({ fluid }) => (fluid ? '100%' : undefined)};
|
|
31
|
+
align-items: ${({ fluid }) => (fluid ? 'stretch' : 'flex-start')};
|
|
63
32
|
flex-flow: ${({ vertical }) => (vertical ? 'column' : 'row')};
|
|
64
|
-
gap: ${({ gapSize, stack }) => (!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined)};
|
|
65
|
-
flex-wrap: ${({ wrap }) => (wrap ? 'wrap' : 'nowrap')};
|
|
66
33
|
|
|
67
|
-
>
|
|
68
|
-
margin-top: ${({ verticalAlign }) =>
|
|
69
|
-
verticalAlign === 'flex-end' || verticalAlign === 'center' ? 'auto' : undefined};
|
|
70
|
-
margin-bottom: ${({ verticalAlign }) =>
|
|
71
|
-
verticalAlign === 'flex-start' || verticalAlign === 'center' ? 'auto' : undefined};
|
|
72
|
-
margin-right: ${({ horizontalAlign }) => (horizontalAlign === 'center' ? 'auto' : undefined)};
|
|
73
|
-
|
|
74
|
-
${({ vertical }) =>
|
|
75
|
-
vertical &&
|
|
76
|
-
css`
|
|
77
|
-
margin-left: ${({ horizontalAlign }) =>
|
|
78
|
-
horizontalAlign === 'flex-end' || horizontalAlign === 'center' ? 'auto' : undefined};
|
|
79
|
-
`}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
${({ vertical }) =>
|
|
83
|
-
!vertical &&
|
|
84
|
-
css`
|
|
85
|
-
> *:first-child {
|
|
86
|
-
margin-left: ${({ horizontalAlign }) =>
|
|
87
|
-
horizontalAlign === 'flex-end' || horizontalAlign === 'center' ? 'auto' : undefined};
|
|
88
|
-
}
|
|
89
|
-
`}
|
|
90
|
-
|
|
91
|
-
> * {
|
|
34
|
+
> .reqore-control-wrapper .reqore-control {
|
|
92
35
|
border-radius: ${({ stack }) => (!stack ? undefined : 0)};
|
|
93
36
|
}
|
|
94
|
-
`;
|
|
95
|
-
|
|
96
|
-
const ReqoreControlGroup = memo(
|
|
97
|
-
({
|
|
98
|
-
children,
|
|
99
|
-
className,
|
|
100
|
-
minimal,
|
|
101
|
-
size = 'normal',
|
|
102
|
-
gapSize = 'normal',
|
|
103
|
-
fluid,
|
|
104
|
-
flat,
|
|
105
|
-
fixed,
|
|
106
|
-
rounded = true,
|
|
107
|
-
wrap,
|
|
108
|
-
stack,
|
|
109
|
-
isInsideStackGroup,
|
|
110
|
-
isInsideVerticalGroup,
|
|
111
|
-
isFirstInLastGroup,
|
|
112
|
-
isLastInFirstGroup,
|
|
113
|
-
isLastInLastGroup,
|
|
114
|
-
intent,
|
|
115
|
-
customTheme,
|
|
116
|
-
isFirst,
|
|
117
|
-
isLast,
|
|
118
|
-
vertical,
|
|
119
|
-
childrenCount,
|
|
120
|
-
childId,
|
|
121
|
-
isChild,
|
|
122
|
-
isFirstGroup,
|
|
123
|
-
isLastGroup,
|
|
124
|
-
verticalAlign = 'center',
|
|
125
|
-
horizontalAlign = 'flex-start',
|
|
126
|
-
responsive,
|
|
127
|
-
...rest
|
|
128
|
-
}: IReqoreControlGroupProps) => {
|
|
129
|
-
const isStack = stack || isInsideStackGroup;
|
|
130
|
-
const isVertical = vertical || isInsideVerticalGroup;
|
|
131
37
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (child && React.isValidElement(child)) {
|
|
144
|
-
if (child.type === React.Fragment) {
|
|
145
|
-
// just compare to `React.Fragment`
|
|
146
|
-
countChildren((child.props as any).children);
|
|
147
|
-
} else {
|
|
148
|
-
count++;
|
|
38
|
+
${({ vertical }) =>
|
|
39
|
+
vertical
|
|
40
|
+
? css`
|
|
41
|
+
> .reqore-control,
|
|
42
|
+
> .reqore-control-wrapper,
|
|
43
|
+
> .reqore-tag,
|
|
44
|
+
> * {
|
|
45
|
+
&:not(:last-child) {
|
|
46
|
+
margin-bottom: ${({ stack, gapSize }) =>
|
|
47
|
+
!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined};
|
|
48
|
+
border-bottom: ${({ stack }) => (!stack ? undefined : 0)};
|
|
149
49
|
}
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
countChildren(children);
|
|
154
|
-
|
|
155
|
-
return count < 0 ? 0 : count;
|
|
156
|
-
}, [children]);
|
|
157
|
-
|
|
158
|
-
const checkIfOverflowing = useCallback(() => {
|
|
159
|
-
return (
|
|
160
|
-
ref.current &&
|
|
161
|
-
ref.current.clientWidth > 40 &&
|
|
162
|
-
!vertical &&
|
|
163
|
-
responsive &&
|
|
164
|
-
ref.current.scrollWidth > ref.current.clientWidth
|
|
165
|
-
);
|
|
166
|
-
}, [vertical, responsive, ref, children]);
|
|
167
|
-
|
|
168
|
-
useMount(() => {
|
|
169
|
-
if (!vertical && responsive) {
|
|
170
|
-
if ('ResizeObserver' in window) {
|
|
171
|
-
observer.current = new ResizeObserver(
|
|
172
|
-
debounce(() => {
|
|
173
|
-
if (ref && ref.current) {
|
|
174
|
-
setOverflowingChildren(0);
|
|
175
|
-
setLastReSize(ref.current.clientWidth);
|
|
176
|
-
}
|
|
177
|
-
}, 200)
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
observer.current.observe(ref.current);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
useUnmount(() => {
|
|
186
|
-
if (observer.current) {
|
|
187
|
-
observer.current.disconnect();
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
useEffect(() => {
|
|
192
|
-
// Is the control group still overflowing?
|
|
193
|
-
if ((overflowingChildren || overflowingChildren === 0) && checkIfOverflowing()) {
|
|
194
|
-
setOverflowingChildren(overflowingChildren + 1);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Hide the dialog if the group was resized and the dialog was open
|
|
198
|
-
if (overflowingChildren === 0) {
|
|
199
|
-
setIsOverflownDialogOpen(false);
|
|
200
|
-
}
|
|
201
|
-
}, [overflowingChildren, lastReSize]);
|
|
202
|
-
|
|
203
|
-
const getIsFirst = (index: number): boolean => {
|
|
204
|
-
return !isInsideStackGroup || childrenCount === 1
|
|
205
|
-
? index === 0
|
|
206
|
-
: (isFirst || isFirst !== false) && index === 0;
|
|
207
|
-
};
|
|
208
|
-
const getIsLast = (index: number): boolean => {
|
|
209
|
-
return !isInsideStackGroup
|
|
210
|
-
? index === realChildCount - 1
|
|
211
|
-
: (isLast || isLast !== false) && index === realChildCount - 1;
|
|
212
|
-
};
|
|
213
|
-
const getIsLastInFirstGroup = (index: number): boolean => {
|
|
214
|
-
return !isInsideStackGroup
|
|
215
|
-
? index === 0
|
|
216
|
-
: isFirstGroup && (isLast || isLast !== false) && index === realChildCount - 1;
|
|
217
|
-
};
|
|
218
|
-
const getIsFirstInLastGroup = (index: number): boolean => {
|
|
219
|
-
return !isInsideStackGroup
|
|
220
|
-
? index === realChildCount - 1
|
|
221
|
-
: isLastGroup && (isFirst || isFirst !== false) && childId === 1 && index === 0;
|
|
222
|
-
};
|
|
223
|
-
const getIsLastInLastGroup = (index: number): boolean => {
|
|
224
|
-
return !isInsideStackGroup
|
|
225
|
-
? index === realChildCount - 1
|
|
226
|
-
: isLastGroup && (isLast || isLast !== false) && index === realChildCount - 1;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const getBorderTopLeftRadius = (index: number): number | undefined => {
|
|
230
|
-
const _isFirstGroup =
|
|
231
|
-
!isInsideStackGroup || childrenCount === 1 ? true : isChild ? isFirstGroup : index === 0;
|
|
232
|
-
|
|
233
|
-
// If this is the first item
|
|
234
|
-
if (_isFirstGroup && getIsFirst(index)) {
|
|
235
|
-
return RADIUS_FROM_SIZE[size];
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return undefined;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
const getBorderTopRightRadius = (index: number): number | undefined => {
|
|
242
|
-
// If this group is not vertical we need to style the very last item
|
|
243
|
-
if (!isVertical || !isStack) {
|
|
244
|
-
const _isLastGroup =
|
|
245
|
-
!isInsideStackGroup || childrenCount === 1
|
|
246
|
-
? true
|
|
247
|
-
: isChild
|
|
248
|
-
? isLastGroup
|
|
249
|
-
: index === realChildCount - 1;
|
|
250
|
-
|
|
251
|
-
if (_isLastGroup && getIsLast(index)) {
|
|
252
|
-
return RADIUS_FROM_SIZE[size];
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return undefined;
|
|
256
|
-
}
|
|
257
50
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return undefined;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// This border only needs to apply when this group is vertical
|
|
281
|
-
// AND this item is the first item of the last group
|
|
282
|
-
if (getIsFirstInLastGroup(index)) {
|
|
283
|
-
return RADIUS_FROM_SIZE[size];
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
return undefined;
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const getBorderBottomRightRadius = (index: number): number | undefined => {
|
|
290
|
-
const _isLastGroup =
|
|
291
|
-
!isInsideStackGroup || childrenCount === 1
|
|
292
|
-
? true
|
|
293
|
-
: isChild
|
|
294
|
-
? isLastGroup
|
|
295
|
-
: index === realChildCount - 1;
|
|
296
|
-
|
|
297
|
-
// If this is the last item
|
|
298
|
-
if (_isLastGroup && getIsLast(index)) {
|
|
299
|
-
return RADIUS_FROM_SIZE[size];
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return undefined;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
let index = 0;
|
|
51
|
+
border-radius: ${({ stack }) => (!stack ? undefined : 0)};
|
|
52
|
+
|
|
53
|
+
${({ rounded, size, stack }) =>
|
|
54
|
+
rounded && stack
|
|
55
|
+
? css`
|
|
56
|
+
&:first-child {
|
|
57
|
+
border-top-left-radius: ${RADIUS_FROM_SIZE[size]}px;
|
|
58
|
+
border-top-right-radius: ${RADIUS_FROM_SIZE[size]}px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:last-child {
|
|
62
|
+
border-bottom-left-radius: ${RADIUS_FROM_SIZE[size]}px;
|
|
63
|
+
border-bottom-right-radius: ${RADIUS_FROM_SIZE[size]}px;
|
|
64
|
+
}
|
|
65
|
+
`
|
|
66
|
+
: undefined}
|
|
67
|
+
}
|
|
306
68
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
69
|
+
> .reqore-control-wrapper:not(:last-child) .reqore-control {
|
|
70
|
+
margin-bottom: ${({ stack, gapSize }) =>
|
|
71
|
+
!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined};
|
|
72
|
+
border-bottom: ${({ stack }) => (!stack ? undefined : 0)};
|
|
73
|
+
}
|
|
74
|
+
`
|
|
75
|
+
: css`
|
|
76
|
+
> .reqore-control,
|
|
77
|
+
> .reqore-control-wrapper,
|
|
78
|
+
> .reqore-tag,
|
|
79
|
+
> * {
|
|
80
|
+
&:not(:last-child) {
|
|
81
|
+
margin-right: ${({ stack, gapSize }) =>
|
|
82
|
+
!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined};
|
|
83
|
+
border-right: ${({ stack }) => (!stack ? undefined : 0)};
|
|
314
84
|
}
|
|
315
85
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
86
|
+
border-radius: ${({ stack }) => (!stack ? undefined : 0)};
|
|
87
|
+
|
|
88
|
+
${({ rounded, size, stack }) =>
|
|
89
|
+
rounded && stack
|
|
90
|
+
? css`
|
|
91
|
+
&:first-child {
|
|
92
|
+
border-top-left-radius: ${RADIUS_FROM_SIZE[size]}px;
|
|
93
|
+
border-bottom-left-radius: ${RADIUS_FROM_SIZE[size]}px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&:last-child {
|
|
97
|
+
border-top-right-radius: ${RADIUS_FROM_SIZE[size]}px;
|
|
98
|
+
border-bottom-right-radius: ${RADIUS_FROM_SIZE[size]}px;
|
|
99
|
+
}
|
|
100
|
+
`
|
|
101
|
+
: undefined}
|
|
102
|
+
}
|
|
103
|
+
`}
|
|
104
|
+
`;
|
|
105
|
+
|
|
106
|
+
const ReqoreControlGroup = forwardRef<HTMLDivElement, IReqoreControlGroupProps>(
|
|
107
|
+
(
|
|
108
|
+
{
|
|
109
|
+
children,
|
|
110
|
+
className,
|
|
111
|
+
minimal,
|
|
112
|
+
size = 'normal',
|
|
113
|
+
gapSize = 'normal',
|
|
114
|
+
fluid,
|
|
115
|
+
flat,
|
|
116
|
+
rounded = true,
|
|
117
|
+
...rest
|
|
118
|
+
}: IReqoreControlGroupProps,
|
|
119
|
+
ref
|
|
120
|
+
) => (
|
|
121
|
+
<StyledReqoreControlGroup
|
|
122
|
+
{...rest}
|
|
123
|
+
size={size}
|
|
124
|
+
gapSize={gapSize}
|
|
125
|
+
ref={ref}
|
|
126
|
+
rounded={rounded}
|
|
127
|
+
fluid={fluid}
|
|
128
|
+
className={`${className || ''} reqore-control-group`}
|
|
129
|
+
>
|
|
130
|
+
{React.Children.map(children, (child) =>
|
|
131
|
+
child
|
|
132
|
+
? React.cloneElement(child, {
|
|
319
133
|
minimal:
|
|
320
134
|
child.props?.minimal || child.props?.minimal === false
|
|
321
135
|
? child.props.minimal
|
|
322
136
|
: minimal,
|
|
323
137
|
size: child.props?.size || size,
|
|
324
138
|
flat: child.props?.flat || child.props?.flat === false ? child.props.flat : flat,
|
|
325
|
-
fluid
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
if (isStack) {
|
|
334
|
-
newProps = {
|
|
335
|
-
...newProps,
|
|
336
|
-
style: {
|
|
337
|
-
borderTopLeftRadius: getBorderTopLeftRadius(index),
|
|
338
|
-
borderBottomLeftRadius: getBorderBottomLeftRadius(index),
|
|
339
|
-
borderTopRightRadius: getBorderTopRightRadius(index),
|
|
340
|
-
borderBottomRightRadius: getBorderBottomRightRadius(index),
|
|
341
|
-
...(child.props?.style || {}),
|
|
342
|
-
},
|
|
343
|
-
isChild: true,
|
|
344
|
-
rounded: !isStack,
|
|
345
|
-
isInsideStackGroup: isStack,
|
|
346
|
-
isInsideVerticalGroup: isVertical,
|
|
347
|
-
isFirst: isChild ? getIsFirst(index) : undefined,
|
|
348
|
-
isLast: isChild ? getIsLast(index) : undefined,
|
|
349
|
-
isLastInFirstGroup: getIsLastInFirstGroup(index),
|
|
350
|
-
isLastInLastGroup: getIsLastInLastGroup(index),
|
|
351
|
-
isFirstInLastGroup: getIsFirstInLastGroup(index),
|
|
352
|
-
childrenCount: realChildCount,
|
|
353
|
-
childId: index + 1,
|
|
354
|
-
|
|
355
|
-
isFirstGroup: isChild ? isFirstGroup : index === 0,
|
|
356
|
-
isLastGroup: isChild ? isLastGroup : index === realChildCount - 1,
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/*
|
|
361
|
-
* Because of the way React.Children.map works, we have to
|
|
362
|
-
* manually decrement the index for every child that is `null`
|
|
363
|
-
* because react maps through null children and returns them in `Count`
|
|
364
|
-
* We filter these children out in the `realChildCount` variable,
|
|
365
|
-
* but the index is still incremented
|
|
366
|
-
* */
|
|
367
|
-
index = index + 1;
|
|
368
|
-
|
|
369
|
-
return React.cloneElement(child, newProps);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return child;
|
|
373
|
-
});
|
|
374
|
-
},
|
|
375
|
-
[
|
|
376
|
-
children,
|
|
377
|
-
isStack,
|
|
378
|
-
isVertical,
|
|
379
|
-
isChild,
|
|
380
|
-
isLastGroup,
|
|
381
|
-
isFirstGroup,
|
|
382
|
-
realChildCount,
|
|
383
|
-
index,
|
|
384
|
-
fluid,
|
|
385
|
-
flat,
|
|
386
|
-
minimal,
|
|
387
|
-
size,
|
|
388
|
-
intent,
|
|
389
|
-
]
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
// Get the overflown children
|
|
393
|
-
const overflownChildren = useMemo(
|
|
394
|
-
() =>
|
|
395
|
-
overflowingChildren ? React.Children.toArray(children).slice(0, overflowingChildren) : [],
|
|
396
|
-
[children, overflowingChildren]
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
// Remove the overflowing children count from the start of the children array
|
|
400
|
-
const _children = useMemo(
|
|
401
|
-
() =>
|
|
402
|
-
overflowingChildren && responsive
|
|
403
|
-
? [
|
|
404
|
-
children.slice(overflowingChildren),
|
|
405
|
-
<ReqoreButton
|
|
406
|
-
icon='MenuLine'
|
|
407
|
-
customTheme={customTheme}
|
|
408
|
-
tooltip={{
|
|
409
|
-
content: `Show ${React.Children.count(overflownChildren)} hidden items`,
|
|
410
|
-
}}
|
|
411
|
-
fixed
|
|
412
|
-
active={isOverflownDialogOpen}
|
|
413
|
-
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
|
|
414
|
-
e.stopPropagation();
|
|
415
|
-
setIsOverflownDialogOpen(!isOverflownDialogOpen);
|
|
416
|
-
}}
|
|
417
|
-
flat
|
|
418
|
-
/>,
|
|
419
|
-
]
|
|
420
|
-
: children,
|
|
421
|
-
[children, overflowingChildren, responsive, overflownChildren]
|
|
422
|
-
);
|
|
423
|
-
|
|
424
|
-
return (
|
|
425
|
-
<>
|
|
426
|
-
{isOverflownDialogOpen ? (
|
|
427
|
-
<ReqoreDrawer
|
|
428
|
-
isOpen
|
|
429
|
-
onClose={() => setIsOverflownDialogOpen(false)}
|
|
430
|
-
flat
|
|
431
|
-
floating
|
|
432
|
-
minimal
|
|
433
|
-
position='bottom'
|
|
434
|
-
hasBackdrop={false}
|
|
435
|
-
label='Hidden items'
|
|
436
|
-
minSize='100px'
|
|
437
|
-
size='auto'
|
|
438
|
-
>
|
|
439
|
-
<ReqoreControlGroup fluid wrap>
|
|
440
|
-
{overflownChildren}
|
|
441
|
-
</ReqoreControlGroup>
|
|
442
|
-
</ReqoreDrawer>
|
|
443
|
-
) : null}
|
|
444
|
-
<StyledReqoreControlGroup
|
|
445
|
-
{...rest}
|
|
446
|
-
vertical={vertical}
|
|
447
|
-
style={{
|
|
448
|
-
overflowX: responsive ? 'auto' : undefined,
|
|
449
|
-
...rest.style,
|
|
450
|
-
}}
|
|
451
|
-
size={size}
|
|
452
|
-
gapSize={gapSize}
|
|
453
|
-
ref={ref}
|
|
454
|
-
rounded={rounded}
|
|
455
|
-
fluid={fluid}
|
|
456
|
-
fixed={fixed}
|
|
457
|
-
wrap={wrap}
|
|
458
|
-
stack={isStack}
|
|
459
|
-
verticalAlign={verticalAlign}
|
|
460
|
-
horizontalAlign={horizontalAlign}
|
|
461
|
-
className={`${className || ''} reqore-control-group`}
|
|
462
|
-
>
|
|
463
|
-
{cloneThroughFragments(_children)}
|
|
464
|
-
</StyledReqoreControlGroup>
|
|
465
|
-
</>
|
|
466
|
-
);
|
|
467
|
-
}
|
|
139
|
+
fluid,
|
|
140
|
+
})
|
|
141
|
+
: null
|
|
142
|
+
)}
|
|
143
|
+
</StyledReqoreControlGroup>
|
|
144
|
+
)
|
|
468
145
|
);
|
|
469
146
|
|
|
470
147
|
export default ReqoreControlGroup;
|