@lumx/react 2.2.20 → 2.2.22-alpha-icons-tree-shake.1
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/esm/_internal/AutocompleteMultiple.js.map +1 -1
- package/esm/_internal/Avatar2.js.map +1 -1
- package/esm/_internal/ButtonRoot.js.map +1 -1
- package/esm/_internal/Checkbox2.js.map +1 -1
- package/esm/_internal/Chip2.js.map +1 -1
- package/esm/_internal/ClickAwayProvider.js +45 -26
- package/esm/_internal/ClickAwayProvider.js.map +1 -1
- package/esm/_internal/CommentBlock.js.map +1 -1
- package/esm/_internal/Dialog2.js +6 -3
- package/esm/_internal/Dialog2.js.map +1 -1
- package/esm/_internal/Divider2.js.map +1 -1
- package/esm/_internal/DragHandle.js.map +1 -1
- package/esm/_internal/Dropdown2.js.map +1 -1
- package/esm/_internal/ExpansionPanel.js.map +1 -1
- package/esm/_internal/Flag2.js.map +1 -1
- package/esm/_internal/GenericBlock.js +79 -22
- package/esm/_internal/GenericBlock.js.map +1 -1
- package/esm/_internal/Icon2.js.map +1 -1
- package/esm/_internal/ImageBlock.js.map +1 -1
- package/esm/_internal/InputHelper.js.map +1 -1
- package/esm/_internal/InputLabel.js.map +1 -1
- package/esm/_internal/Lightbox2.js +1 -1
- package/esm/_internal/Lightbox2.js.map +1 -1
- package/esm/_internal/LinkPreview.js.map +1 -1
- package/esm/_internal/Mosaic2.js.map +1 -1
- package/esm/_internal/Notification2.js.map +1 -1
- package/esm/_internal/Popover2.js +1 -1
- package/esm/_internal/Popover2.js.map +1 -1
- package/esm/_internal/PostBlock.js.map +1 -1
- package/esm/_internal/Progress2.js.map +1 -1
- package/esm/_internal/RadioGroup.js.map +1 -1
- package/esm/_internal/SelectMultiple.js.map +1 -1
- package/esm/_internal/SideNavigationItem.js.map +1 -1
- package/esm/_internal/SkeletonTypography.js.map +1 -1
- package/esm/_internal/Slider2.js.map +1 -1
- package/esm/_internal/Slides.js.map +1 -1
- package/esm/_internal/Switch2.js.map +1 -1
- package/esm/_internal/TabPanel.js.map +1 -1
- package/esm/_internal/TableRow.js.map +1 -1
- package/esm/_internal/TextField.js.map +1 -1
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/Uploader2.js.map +1 -1
- package/esm/_internal/UserBlock.js.map +1 -1
- package/esm/_internal/_rollupPluginBabelHelpers.js +5 -1
- package/esm/_internal/_rollupPluginBabelHelpers.js.map +1 -1
- package/esm/_internal/generic-block.js +8 -0
- package/esm/_internal/generic-block.js.map +1 -1
- package/esm/_internal/type.js +11 -1
- package/esm/_internal/type.js.map +1 -1
- package/package.json +5 -5
- package/src/components/autocomplete/Autocomplete.tsx +6 -8
- package/src/components/avatar/Avatar.tsx +2 -4
- package/src/components/button/Button.test.tsx +1 -1
- package/src/components/button/ButtonRoot.tsx +3 -4
- package/src/components/button/IconButton.test.tsx +1 -1
- package/src/components/checkbox/Checkbox.tsx +2 -4
- package/src/components/chip/Chip.tsx +2 -4
- package/src/components/comment-block/CommentBlock.tsx +2 -4
- package/src/components/dialog/Dialog.stories.tsx +7 -3
- package/src/components/dialog/Dialog.tsx +11 -4
- package/src/components/dialog/__snapshots__/Dialog.test.tsx.snap +7 -0
- package/src/components/divider/Divider.tsx +2 -5
- package/src/components/drag-handle/DragHandle.tsx +2 -5
- package/src/components/dropdown/Dropdown.tsx +4 -3
- package/src/components/expansion-panel/ExpansionPanel.tsx +2 -3
- package/src/components/flag/Flag.tsx +2 -4
- package/src/components/generic-block/GenericBlock.stories.tsx +92 -123
- package/src/components/generic-block/GenericBlock.test.tsx +128 -4
- package/src/components/generic-block/GenericBlock.tsx +127 -33
- package/src/components/icon/Icon.tsx +2 -4
- package/src/components/image-block/ImageBlock.tsx +2 -4
- package/src/components/input-helper/InputHelper.tsx +2 -4
- package/src/components/input-label/InputLabel.tsx +2 -4
- package/src/components/lightbox/Lightbox.tsx +4 -6
- package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +1 -1
- package/src/components/link-preview/LinkPreview.tsx +2 -4
- package/src/components/mosaic/Mosaic.tsx +2 -4
- package/src/components/notification/Notification.tsx +2 -4
- package/src/components/popover/Popover.tsx +1 -1
- package/src/components/popover/__snapshots__/Popover.test.tsx.snap +10 -10
- package/src/components/post-block/PostBlock.tsx +2 -4
- package/src/components/progress/Progress.tsx +2 -4
- package/src/components/radio-button/RadioButton.tsx +2 -4
- package/src/components/select/constants.ts +2 -5
- package/src/components/side-navigation/SideNavigation.tsx +2 -4
- package/src/components/skeleton/SkeletonCircle.tsx +2 -4
- package/src/components/skeleton/SkeletonRectangle.tsx +2 -4
- package/src/components/skeleton/SkeletonTypography.tsx +2 -4
- package/src/components/slider/Slider.tsx +2 -4
- package/src/components/slideshow/Slides.tsx +2 -7
- package/src/components/slideshow/SlideshowControls.tsx +2 -4
- package/src/components/switch/Switch.tsx +2 -4
- package/src/components/table/Table.tsx +2 -4
- package/src/components/tabs/TabList.tsx +2 -4
- package/src/components/text-field/TextField.tsx +6 -8
- package/src/components/thumbnail/Thumbnail.tsx +3 -5
- package/src/components/uploader/Uploader.tsx +2 -4
- package/src/components/user-block/UserBlock.tsx +2 -4
- package/src/hooks/useClickAway.tsx +5 -5
- package/src/testing/utils/commonTestsSuite.ts +2 -2
- package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +58 -0
- package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +51 -19
- package/src/utils/focus/getFirstAndLastFocusable.test.ts +6 -0
- package/src/utils/focus/getFirstAndLastFocusable.ts +2 -2
- package/src/utils/type.ts +19 -2
- package/types.d.ts +112 -139
- package/src/components/generic-block/__snapshots__/GenericBlock.test.tsx.snap +0 -92
- package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.tsx +0 -75
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { createRef } from 'react';
|
|
2
2
|
import { mount, shallow } from 'enzyme';
|
|
3
3
|
import 'jest-enzyme';
|
|
4
|
-
import { commonTestsSuite
|
|
4
|
+
import { commonTestsSuite } from '@lumx/react/testing/utils';
|
|
5
5
|
|
|
6
6
|
import { GenericBlock, GenericBlockProps } from './GenericBlock';
|
|
7
|
-
import * as stories from '../../stories/generated/GenericBlock/Demos.stories';
|
|
8
7
|
|
|
9
8
|
const CLASSNAME = GenericBlock.className as string;
|
|
10
9
|
|
|
@@ -20,7 +19,132 @@ const setup = (props: Partial<GenericBlockProps> = {}, shallowRendering = true)
|
|
|
20
19
|
describe(`<${GenericBlock.displayName}>`, () => {
|
|
21
20
|
// 1. Test render via snapshot.
|
|
22
21
|
describe('Snapshots and structure', () => {
|
|
23
|
-
|
|
22
|
+
it('should render default', () => {
|
|
23
|
+
const wrapper = shallow(
|
|
24
|
+
<GenericBlock figure="figure" actions="actions">
|
|
25
|
+
Content
|
|
26
|
+
</GenericBlock>,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(wrapper.prop('gap')).toBe('big');
|
|
30
|
+
expect(wrapper.prop('hAlign')).toBe('top');
|
|
31
|
+
expect(wrapper.prop('orientation')).toBe('horizontal');
|
|
32
|
+
expect(wrapper.prop('vAlign')).toBe('center');
|
|
33
|
+
|
|
34
|
+
const figure = wrapper.find('.lumx-generic-block__figure');
|
|
35
|
+
expect(figure).toBeDefined();
|
|
36
|
+
|
|
37
|
+
const content = wrapper.find('.lumx-generic-block__content');
|
|
38
|
+
expect(content.prop('fillSpace')).toBe(true);
|
|
39
|
+
expect(content.prop('vAlign')).toBe('left');
|
|
40
|
+
expect(content.prop('orientation')).toBe('vertical');
|
|
41
|
+
|
|
42
|
+
const actions = wrapper.find('.lumx-generic-block__actions');
|
|
43
|
+
expect(actions.prop('vAlign')).toBe('right');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should render vertical', () => {
|
|
47
|
+
const wrapper = shallow(
|
|
48
|
+
<GenericBlock figure="figure" actions="actions" orientation="vertical">
|
|
49
|
+
Content
|
|
50
|
+
</GenericBlock>,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(wrapper.prop('gap')).toBe('big');
|
|
54
|
+
expect(wrapper.prop('hAlign')).toBe('top');
|
|
55
|
+
expect(wrapper.prop('orientation')).toBe('vertical');
|
|
56
|
+
expect(wrapper.prop('vAlign')).toBe('center');
|
|
57
|
+
|
|
58
|
+
const figure = wrapper.find('.lumx-generic-block__figure');
|
|
59
|
+
expect(figure).toBeDefined();
|
|
60
|
+
|
|
61
|
+
const content = wrapper.find('.lumx-generic-block__content');
|
|
62
|
+
expect(content.prop('fillSpace')).toBe(true);
|
|
63
|
+
expect(content.prop('vAlign')).toBe('center');
|
|
64
|
+
expect(content.prop('orientation')).toBe('vertical');
|
|
65
|
+
|
|
66
|
+
const actions = wrapper.find('.lumx-generic-block__actions');
|
|
67
|
+
expect(actions.prop('vAlign')).toBe('center');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should combine figure props', () => {
|
|
71
|
+
const wrapper = shallow(
|
|
72
|
+
<GenericBlock figure="Figure 1" figureProps={{ className: 'figure1', vAlign: 'left' }}>
|
|
73
|
+
<GenericBlock.Figure className="figure2" fillSpace>
|
|
74
|
+
Figure 2
|
|
75
|
+
</GenericBlock.Figure>
|
|
76
|
+
</GenericBlock>,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const figure = wrapper.find('.lumx-generic-block__figure');
|
|
80
|
+
expect(figure).toHaveClassName('figure1');
|
|
81
|
+
expect(figure).toHaveClassName('figure2');
|
|
82
|
+
expect(figure.prop('fillSpace')).toBe(true);
|
|
83
|
+
expect(figure.prop('vAlign')).toBe('left');
|
|
84
|
+
expect(figure).toHaveText('Figure 1Figure 2');
|
|
85
|
+
|
|
86
|
+
expect(wrapper.find('.lumx-generic-block__content')).toHaveLength(0);
|
|
87
|
+
expect(wrapper.find('.lumx-generic-block__actions')).toHaveLength(0);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should combine content props', () => {
|
|
91
|
+
const wrapper = shallow(
|
|
92
|
+
<GenericBlock contentProps={{ className: 'content1', vAlign: 'left' }}>
|
|
93
|
+
Content 1
|
|
94
|
+
<GenericBlock.Content className="content2" fillSpace>
|
|
95
|
+
Content 2
|
|
96
|
+
</GenericBlock.Content>
|
|
97
|
+
</GenericBlock>,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const content = wrapper.find('.lumx-generic-block__content');
|
|
101
|
+
expect(content).toHaveClassName('content1');
|
|
102
|
+
expect(content).toHaveClassName('content2');
|
|
103
|
+
expect(content.prop('fillSpace')).toBe(true);
|
|
104
|
+
expect(content.prop('vAlign')).toBe('left');
|
|
105
|
+
expect(content).toHaveText('Content 2Content 1');
|
|
106
|
+
|
|
107
|
+
expect(wrapper.find('.lumx-generic-block__figure')).toHaveLength(0);
|
|
108
|
+
expect(wrapper.find('.lumx-generic-block__actions')).toHaveLength(0);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should combine actions props', () => {
|
|
112
|
+
const wrapper = shallow(
|
|
113
|
+
<GenericBlock actions="Actions 1" actionsProps={{ className: 'actions1', vAlign: 'left' }}>
|
|
114
|
+
<GenericBlock.Actions className="actions2" fillSpace>
|
|
115
|
+
Actions 2
|
|
116
|
+
</GenericBlock.Actions>
|
|
117
|
+
</GenericBlock>,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const actions = wrapper.find('.lumx-generic-block__actions');
|
|
121
|
+
expect(actions).toHaveClassName('actions1');
|
|
122
|
+
expect(actions).toHaveClassName('actions2');
|
|
123
|
+
expect(actions.prop('fillSpace')).toBe(true);
|
|
124
|
+
expect(actions.prop('vAlign')).toBe('left');
|
|
125
|
+
expect(actions).toHaveText('Actions 1Actions 2');
|
|
126
|
+
|
|
127
|
+
expect(wrapper.find('.lumx-generic-block__figure')).toHaveLength(0);
|
|
128
|
+
expect(wrapper.find('.lumx-generic-block__content')).toHaveLength(0);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should forward refs', () => {
|
|
132
|
+
const rootRef = createRef<HTMLDivElement>();
|
|
133
|
+
const figureRef = createRef<HTMLDivElement>();
|
|
134
|
+
const contentRef = createRef<HTMLDivElement>();
|
|
135
|
+
const actionsRef = createRef<HTMLDivElement>();
|
|
136
|
+
shallow(
|
|
137
|
+
<GenericBlock ref={rootRef}>
|
|
138
|
+
<GenericBlock.Figure ref={figureRef} />
|
|
139
|
+
<GenericBlock.Content ref={contentRef} />
|
|
140
|
+
<GenericBlock.Actions ref={actionsRef} />
|
|
141
|
+
</GenericBlock>,
|
|
142
|
+
);
|
|
143
|
+
expect(rootRef.current).toBeDefined();
|
|
144
|
+
expect(figureRef.current).toBeDefined();
|
|
145
|
+
expect(contentRef.current).toBeDefined();
|
|
146
|
+
expect(actionsRef.current).toBeDefined();
|
|
147
|
+
});
|
|
24
148
|
});
|
|
25
149
|
|
|
26
150
|
// Common tests suite.
|
|
@@ -1,29 +1,47 @@
|
|
|
1
|
-
import React, { forwardRef, ReactNode } from 'react';
|
|
1
|
+
import React, { Children, forwardRef, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import
|
|
3
|
+
import isEmpty from 'lodash/isEmpty';
|
|
4
|
+
import { Comp, getRootClassName, isComponentType, partitionMulti } from '@lumx/react/utils';
|
|
4
5
|
import { Orientation, Size, FlexBox, FlexBoxProps, Alignment, HorizontalAlignment } from '@lumx/react';
|
|
5
6
|
|
|
6
7
|
export interface GenericBlockProps extends FlexBoxProps {
|
|
7
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Component to use as visual element.
|
|
10
|
+
*/
|
|
8
11
|
figure?: ReactNode;
|
|
9
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Actions to set after the main content.
|
|
14
|
+
*/
|
|
10
15
|
actions?: ReactNode;
|
|
11
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Main content to display or sections components
|
|
18
|
+
* ({@see GenericBlock.Figure}, {@see GenericBlock.Content} & {@see GenericBlock.Actions})
|
|
19
|
+
*/
|
|
12
20
|
children: ReactNode;
|
|
13
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Orientation of the 3 sections
|
|
23
|
+
*/
|
|
14
24
|
orientation?: FlexBoxProps['orientation'];
|
|
15
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Horizontal alignment.
|
|
27
|
+
*/
|
|
16
28
|
hAlign?: FlexBoxProps['hAlign'];
|
|
17
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Vertical alignment.
|
|
31
|
+
*/
|
|
18
32
|
vAlign?: FlexBoxProps['vAlign'];
|
|
19
33
|
/**
|
|
20
34
|
* The props to forward to the content.
|
|
21
35
|
* By default, the content will have the same alignment as wrapper.
|
|
22
36
|
*/
|
|
23
37
|
contentProps?: Omit<FlexBoxProps, 'children'>;
|
|
24
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* props to forward to the actions element.
|
|
40
|
+
*/
|
|
25
41
|
actionsProps?: Omit<FlexBoxProps, 'children'>;
|
|
26
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* props to forward to the figure element.
|
|
44
|
+
*/
|
|
27
45
|
figureProps?: Omit<FlexBoxProps, 'children'>;
|
|
28
46
|
}
|
|
29
47
|
|
|
@@ -41,24 +59,53 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
41
59
|
* Component default props.
|
|
42
60
|
*/
|
|
43
61
|
const DEFAULT_PROPS: Partial<GenericBlockProps> = {
|
|
44
|
-
gap: Size.
|
|
45
|
-
orientation: Orientation.
|
|
46
|
-
hAlign: Alignment.
|
|
62
|
+
gap: Size.big,
|
|
63
|
+
orientation: Orientation.horizontal,
|
|
64
|
+
hAlign: Alignment.top,
|
|
47
65
|
vAlign: Alignment.center,
|
|
48
66
|
};
|
|
49
67
|
|
|
68
|
+
type BaseGenericBlock = Comp<GenericBlockProps, HTMLDivElement>;
|
|
69
|
+
|
|
70
|
+
interface GenericBlock extends BaseGenericBlock {
|
|
71
|
+
/**
|
|
72
|
+
* Use `GenericBlock.Figure` component as children of the `GenericBlock` component as an alternative way to inject
|
|
73
|
+
* the "figure" section of the block (instead of using `figure` and `figureProps` props).
|
|
74
|
+
*/
|
|
75
|
+
Figure: Comp<FlexBoxProps>;
|
|
76
|
+
/**
|
|
77
|
+
* Use `GenericBlock.Content` component as children of the `GenericBlock` component as an alternative way to inject
|
|
78
|
+
* the "content" section of the block (instead of using `content` and `contentProps` props).
|
|
79
|
+
*/
|
|
80
|
+
Content: Comp<FlexBoxProps>;
|
|
81
|
+
/**
|
|
82
|
+
* Use `GenericBlock.Actions` component as children of the `GenericBlock` component as an alternative way to inject
|
|
83
|
+
* the "actions" section of the block (instead of using `actions` and `actionsProps` props).
|
|
84
|
+
*/
|
|
85
|
+
Actions: Comp<FlexBoxProps>;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const Figure = (() => null) as any;
|
|
89
|
+
const isFigure = isComponentType(Figure);
|
|
90
|
+
|
|
91
|
+
const Content = (() => null) as any;
|
|
92
|
+
const isContent = isComponentType(Content);
|
|
93
|
+
|
|
94
|
+
const Actions = (() => null) as any;
|
|
95
|
+
const isActions = isComponentType(Actions);
|
|
96
|
+
|
|
50
97
|
/**
|
|
51
98
|
* The GenericBlock is a layout component made of 3 sections that can be
|
|
52
99
|
* displayed either horizontally of vertically with the same gap between each section.
|
|
53
100
|
*
|
|
54
101
|
* The sections are:
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
102
|
+
* - `Figure` => A visual element to display before the main content.
|
|
103
|
+
* - `Content` => The main content displayed
|
|
104
|
+
* - `Actions` => One or more actions to set after the element.
|
|
58
105
|
*
|
|
59
106
|
* @see https://www.figma.com/file/lzzrQmsfaXRaOyRfoEogPZ/DS%3A-playground?node-id=1%3A4076
|
|
60
107
|
*/
|
|
61
|
-
|
|
108
|
+
const BaseGenericBlock: BaseGenericBlock = forwardRef((props, ref) => {
|
|
62
109
|
const {
|
|
63
110
|
className,
|
|
64
111
|
figure,
|
|
@@ -72,6 +119,23 @@ export const GenericBlock: Comp<GenericBlockProps, HTMLDivElement> = forwardRef(
|
|
|
72
119
|
...forwardedProps
|
|
73
120
|
} = props;
|
|
74
121
|
|
|
122
|
+
const sections = React.useMemo(() => {
|
|
123
|
+
// Split children by section type
|
|
124
|
+
const [[figureChild], [contentChild], [actionsChild], ...otherChildren] = partitionMulti(
|
|
125
|
+
Children.toArray(children),
|
|
126
|
+
[isFigure, isContent, isActions],
|
|
127
|
+
);
|
|
128
|
+
return {
|
|
129
|
+
figureChild,
|
|
130
|
+
figureChildProps: (figureChild as ReactElement)?.props,
|
|
131
|
+
contentChild,
|
|
132
|
+
contentChildProps: (contentChild as ReactElement)?.props,
|
|
133
|
+
actionsChild,
|
|
134
|
+
actionsChildProps: (actionsChild as ReactElement)?.props,
|
|
135
|
+
otherChildren: otherChildren.filter((child) => !isEmpty(child)),
|
|
136
|
+
};
|
|
137
|
+
}, [children]);
|
|
138
|
+
|
|
75
139
|
let actionsVAlign: HorizontalAlignment = Alignment.center;
|
|
76
140
|
if (orientation === Orientation.horizontal) {
|
|
77
141
|
actionsVAlign = Alignment.right;
|
|
@@ -89,32 +153,62 @@ export const GenericBlock: Comp<GenericBlockProps, HTMLDivElement> = forwardRef(
|
|
|
89
153
|
orientation={orientation}
|
|
90
154
|
{...forwardedProps}
|
|
91
155
|
>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
156
|
+
{(figure || sections.figureChildProps?.children) && (
|
|
157
|
+
<FlexBox
|
|
158
|
+
ref={(sections.figureChild as any)?.ref}
|
|
159
|
+
{...figureProps}
|
|
160
|
+
{...sections.figureChildProps}
|
|
161
|
+
className={classNames(
|
|
162
|
+
figureProps?.className,
|
|
163
|
+
sections.figureChildProps?.className,
|
|
164
|
+
`${CLASSNAME}__figure`,
|
|
165
|
+
)}
|
|
166
|
+
>
|
|
167
|
+
{figure}
|
|
168
|
+
{sections.figureChildProps?.children}
|
|
169
|
+
</FlexBox>
|
|
170
|
+
)}
|
|
95
171
|
|
|
96
|
-
{children && (
|
|
172
|
+
{(sections.contentChildProps?.children || sections.otherChildren.length > 0) && (
|
|
97
173
|
<FlexBox
|
|
174
|
+
ref={(sections.contentChild as any)?.ref}
|
|
98
175
|
orientation={Orientation.vertical}
|
|
99
176
|
fillSpace
|
|
100
177
|
vAlign={contentVAlign}
|
|
101
178
|
{...contentProps}
|
|
102
|
-
|
|
179
|
+
{...sections.contentChildProps}
|
|
180
|
+
className={classNames(
|
|
181
|
+
contentProps?.className,
|
|
182
|
+
sections.contentChildProps?.className,
|
|
183
|
+
`${CLASSNAME}__content`,
|
|
184
|
+
)}
|
|
103
185
|
>
|
|
104
|
-
{children}
|
|
186
|
+
{sections.contentChildProps?.children}
|
|
187
|
+
{sections.otherChildren}
|
|
105
188
|
</FlexBox>
|
|
106
189
|
)}
|
|
107
190
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
191
|
+
{(actions || sections.actionsChildProps?.children) && (
|
|
192
|
+
<FlexBox
|
|
193
|
+
ref={(sections.actionsChild as any)?.ref}
|
|
194
|
+
vAlign={actionsVAlign}
|
|
195
|
+
{...actionsProps}
|
|
196
|
+
{...sections.actionsChildProps}
|
|
197
|
+
className={classNames(
|
|
198
|
+
actionsProps?.className,
|
|
199
|
+
sections.actionsChildProps?.className,
|
|
200
|
+
`${CLASSNAME}__actions`,
|
|
201
|
+
)}
|
|
202
|
+
>
|
|
203
|
+
{actions}
|
|
204
|
+
{sections.actionsChildProps?.children}
|
|
205
|
+
</FlexBox>
|
|
206
|
+
)}
|
|
115
207
|
</FlexBox>
|
|
116
208
|
);
|
|
117
209
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
210
|
+
BaseGenericBlock.displayName = COMPONENT_NAME;
|
|
211
|
+
BaseGenericBlock.className = CLASSNAME;
|
|
212
|
+
BaseGenericBlock.defaultProps = DEFAULT_PROPS;
|
|
213
|
+
|
|
214
|
+
export const GenericBlock: GenericBlock = Object.assign(BaseGenericBlock, { Figure, Content, Actions });
|
|
@@ -3,7 +3,7 @@ import React, { forwardRef } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Color, ColorPalette, ColorVariant, Size, Theme } from '@lumx/react';
|
|
6
|
-
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
6
|
+
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
|
|
7
7
|
import { mdiAlertCircle } from '@lumx/icons';
|
|
8
8
|
|
|
9
9
|
export type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
|
|
@@ -11,7 +11,7 @@ export type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'x
|
|
|
11
11
|
/**
|
|
12
12
|
* Defines the props of the component.
|
|
13
13
|
*/
|
|
14
|
-
export interface IconProps extends GenericProps {
|
|
14
|
+
export interface IconProps extends GenericProps, HasTheme {
|
|
15
15
|
/** Color variant. */
|
|
16
16
|
color?: Color;
|
|
17
17
|
/** Lightened or darkened variant of the selected icon color. */
|
|
@@ -25,8 +25,6 @@ export interface IconProps extends GenericProps {
|
|
|
25
25
|
icon: string;
|
|
26
26
|
/** Size variant. */
|
|
27
27
|
size?: IconSizes;
|
|
28
|
-
/** Theme adapting the component to light or dark background. */
|
|
29
|
-
theme?: Theme;
|
|
30
28
|
/** Sets an alternative text on the svg. Will set an `img` role to the svg. */
|
|
31
29
|
alt?: string;
|
|
32
30
|
}
|
|
@@ -6,7 +6,7 @@ import isObject from 'lodash/isObject';
|
|
|
6
6
|
|
|
7
7
|
import { Alignment, HorizontalAlignment, Size, Theme, Thumbnail } from '@lumx/react';
|
|
8
8
|
|
|
9
|
-
import { Comp, GenericProps, getRootClassName, handleBasicClasses, ValueOf } from '@lumx/react/utils';
|
|
9
|
+
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme, ValueOf } from '@lumx/react/utils';
|
|
10
10
|
import { ThumbnailProps } from '../thumbnail/Thumbnail';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -26,7 +26,7 @@ export type ImageBlockSize = Extract<Size, 'xl' | 'xxl'>;
|
|
|
26
26
|
/**
|
|
27
27
|
* Defines the props of the component.
|
|
28
28
|
*/
|
|
29
|
-
export interface ImageBlockProps extends GenericProps {
|
|
29
|
+
export interface ImageBlockProps extends GenericProps, HasTheme {
|
|
30
30
|
/** Action toolbar content. */
|
|
31
31
|
actions?: ReactNode;
|
|
32
32
|
/** Alignment. */
|
|
@@ -47,8 +47,6 @@ export interface ImageBlockProps extends GenericProps {
|
|
|
47
47
|
size?: ImageBlockSize;
|
|
48
48
|
/** Tag content. */
|
|
49
49
|
tags?: ReactNode;
|
|
50
|
-
/** Theme adapting the component to light or dark background. */
|
|
51
|
-
theme?: Theme;
|
|
52
50
|
/** Props to pass to the thumbnail (minus those already set by the ImageBlock props). */
|
|
53
51
|
thumbnailProps?: Omit<ThumbnailProps, 'image' | 'size' | 'theme' | 'align' | 'fillHeight'>;
|
|
54
52
|
/** Image title to display in the caption. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Kind, Theme } from '@lumx/react';
|
|
2
|
-
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
2
|
+
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import React, { forwardRef, ReactNode } from 'react';
|
|
5
5
|
|
|
@@ -8,13 +8,11 @@ import { INPUT_HELPER_CONFIGURATION } from './constants';
|
|
|
8
8
|
/**
|
|
9
9
|
* Defines the props of the component.
|
|
10
10
|
*/
|
|
11
|
-
export interface InputHelperProps extends GenericProps {
|
|
11
|
+
export interface InputHelperProps extends GenericProps, HasTheme {
|
|
12
12
|
/** Helper content. */
|
|
13
13
|
children: string | ReactNode;
|
|
14
14
|
/** Helper variant. */
|
|
15
15
|
kind?: Kind;
|
|
16
|
-
/** Theme adapting the component to light or dark background. */
|
|
17
|
-
theme?: Theme;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { Theme } from '@lumx/react';
|
|
2
|
-
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
2
|
+
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import React, { forwardRef, ReactNode } from 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Defines the props of the component.
|
|
8
8
|
*/
|
|
9
|
-
export interface InputLabelProps extends GenericProps {
|
|
9
|
+
export interface InputLabelProps extends GenericProps, HasTheme {
|
|
10
10
|
/** Label content. */
|
|
11
11
|
children: string | ReactNode;
|
|
12
12
|
/** Native htmlFor property. */
|
|
13
13
|
htmlFor: string;
|
|
14
14
|
/** Whether the component is required or not. */
|
|
15
15
|
isRequired?: boolean;
|
|
16
|
-
/** Theme adapting the component to light or dark background. */
|
|
17
|
-
theme?: Theme;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -4,9 +4,9 @@ import classNames from 'classnames';
|
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
|
|
6
6
|
import { mdiClose } from '@lumx/icons';
|
|
7
|
-
import { ColorPalette, Emphasis, IconButton, IconButtonProps
|
|
7
|
+
import { ColorPalette, Emphasis, IconButton, IconButtonProps } from '@lumx/react';
|
|
8
8
|
import { DOCUMENT } from '@lumx/react/constants';
|
|
9
|
-
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
9
|
+
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
|
|
10
10
|
|
|
11
11
|
import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
|
|
12
12
|
import { useDelayedVisibility } from '@lumx/react/hooks/useDelayedVisibility';
|
|
@@ -20,7 +20,7 @@ const LIGHTBOX_TRANSITION_DURATION = 400;
|
|
|
20
20
|
/**
|
|
21
21
|
* Defines the props of the component.
|
|
22
22
|
*/
|
|
23
|
-
export interface LightboxProps extends GenericProps {
|
|
23
|
+
export interface LightboxProps extends GenericProps, HasTheme {
|
|
24
24
|
/** Props to pass to the close button (minus those already set by the Lightbox props). */
|
|
25
25
|
closeButtonProps?: Pick<IconButtonProps, 'label'> &
|
|
26
26
|
Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;
|
|
@@ -30,8 +30,6 @@ export interface LightboxProps extends GenericProps {
|
|
|
30
30
|
parentElement: RefObject<any>;
|
|
31
31
|
/** Whether to keep the dialog open on clickaway or escape press. */
|
|
32
32
|
preventAutoClose?: boolean;
|
|
33
|
-
/** Theme adapting the component to light or dark background. */
|
|
34
|
-
theme?: Theme;
|
|
35
33
|
/** Z-axis position. */
|
|
36
34
|
zIndex?: number;
|
|
37
35
|
/** On close callback. */
|
|
@@ -143,7 +141,7 @@ export const Lightbox: Comp<LightboxProps, HTMLDivElement> = forwardRef((props,
|
|
|
143
141
|
onClick={onClose}
|
|
144
142
|
/>
|
|
145
143
|
)}
|
|
146
|
-
<ClickAwayProvider callback={!preventAutoClose && onClose}
|
|
144
|
+
<ClickAwayProvider callback={!preventAutoClose && onClose} childrenRefs={clickAwayRefs}>
|
|
147
145
|
<div ref={childrenRef} className={`${CLASSNAME}__wrapper`} role="presentation">
|
|
148
146
|
{children}
|
|
149
147
|
</div>
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
ThumbnailProps,
|
|
15
15
|
} from '@lumx/react';
|
|
16
16
|
|
|
17
|
-
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HeadingElement } from '@lumx/react/utils';
|
|
17
|
+
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HeadingElement, HasTheme } from '@lumx/react/utils';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Defines the props of the component.
|
|
21
21
|
*/
|
|
22
|
-
export interface LinkPreviewProps extends GenericProps {
|
|
22
|
+
export interface LinkPreviewProps extends GenericProps, HasTheme {
|
|
23
23
|
/** Description. */
|
|
24
24
|
description?: string;
|
|
25
25
|
/** Link URL. */
|
|
@@ -30,8 +30,6 @@ export interface LinkPreviewProps extends GenericProps {
|
|
|
30
30
|
linkProps?: Omit<LinkProps, 'color' | 'colorVariant' | 'href' | 'target'>;
|
|
31
31
|
/** Size variant. */
|
|
32
32
|
size?: Extract<Size, 'regular' | 'big'>;
|
|
33
|
-
/** Theme adapting the component to light or dark background. */
|
|
34
|
-
theme?: Theme;
|
|
35
33
|
/** Thumbnail for the link preview. */
|
|
36
34
|
thumbnailProps?: ThumbnailProps;
|
|
37
35
|
/** Title. */
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import React, { forwardRef, MouseEventHandler, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { Alignment, AspectRatio, Theme, Thumbnail, ThumbnailProps } from '@lumx/react';
|
|
4
|
-
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
4
|
+
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import take from 'lodash/take';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Defines the props of the component.
|
|
10
10
|
*/
|
|
11
|
-
export interface MosaicProps extends GenericProps {
|
|
12
|
-
/** Theme adapting the component to light or dark background. */
|
|
13
|
-
theme?: Theme;
|
|
11
|
+
export interface MosaicProps extends GenericProps, HasTheme {
|
|
14
12
|
/** Thumbnails. */
|
|
15
13
|
thumbnails: ThumbnailProps[];
|
|
16
14
|
/** On image click callback. */
|
|
@@ -9,22 +9,20 @@ import { Button, Emphasis, Icon, Kind, Size, Theme } from '@lumx/react';
|
|
|
9
9
|
|
|
10
10
|
import { DOCUMENT, NOTIFICATION_TRANSITION_DURATION } from '@lumx/react/constants';
|
|
11
11
|
import { NOTIFICATION_CONFIGURATION } from '@lumx/react/components/notification/constants';
|
|
12
|
-
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
12
|
+
import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
|
|
13
13
|
|
|
14
14
|
import { useDelayedVisibility } from '@lumx/react/hooks/useDelayedVisibility';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Defines the props of the component.
|
|
18
18
|
*/
|
|
19
|
-
export interface NotificationProps extends GenericProps {
|
|
19
|
+
export interface NotificationProps extends GenericProps, HasTheme {
|
|
20
20
|
/** Action button label. */
|
|
21
21
|
actionLabel?: string;
|
|
22
22
|
/** Content. */
|
|
23
23
|
content?: React.ReactNode;
|
|
24
24
|
/** Whether the component is open or not. */
|
|
25
25
|
isOpen?: boolean;
|
|
26
|
-
/** Theme adapting the component to light or dark background. */
|
|
27
|
-
theme?: Theme;
|
|
28
26
|
/** Notification type. */
|
|
29
27
|
type?: Kind;
|
|
30
28
|
/** Z-axis position. */
|
|
@@ -342,7 +342,7 @@ export const Popover: Comp<PopoverProps, HTMLDivElement> = forwardRef((props, re
|
|
|
342
342
|
style={popoverStyle}
|
|
343
343
|
{...attributes.popper}
|
|
344
344
|
>
|
|
345
|
-
<ClickAwayProvider callback={closeOnClickAway && handleClose}
|
|
345
|
+
<ClickAwayProvider callback={closeOnClickAway && handleClose} childrenRefs={clickAwayRefs}>
|
|
346
346
|
{hasArrow && <div ref={setArrowElement} className={`${CLASSNAME}__arrow`} style={styles.arrow} />}
|
|
347
347
|
{children}
|
|
348
348
|
</ClickAwayProvider>
|