@semcore/fullscreen-modal 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/lib/cjs/FullscreenModal.js +85 -122
- package/lib/cjs/FullscreenModal.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/fullscreen-modal.shadow.css +18 -18
- package/lib/es6/FullscreenModal.js +95 -122
- package/lib/es6/FullscreenModal.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/fullscreen-modal.shadow.css +18 -18
- package/lib/types/index.d.ts +41 -2
- package/package.json +5 -4
- package/src/FullscreenModal.js +152 -0
- package/src/index.d.ts +41 -0
- package/src/{index.tsx → index.js} +0 -0
- package/src/style/fullscreen-modal.shadow.css +18 -18
- package/lib/types/FullscreenModal.d.ts +0 -29
- package/src/FullscreenModal.tsx +0 -183
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
import { ReturnEl, CProps, PropGetterFn } from '@semcore/core';
|
|
3
|
+
import { IModalProps } from '@semcore/modal';
|
|
4
|
+
import { Box, IBoxProps } from '@semcore/flex-box';
|
|
5
|
+
import { IIconProps } from '@semcore/icon';
|
|
6
|
+
import { Text } from '@semcore/typography';
|
|
7
|
+
|
|
8
|
+
export interface IFullscreenModalProps extends IModalProps {
|
|
9
|
+
/** This property is responsible for the visibility of the modal window */
|
|
10
|
+
hidden?: boolean;
|
|
11
|
+
/** Function that is invoked when hiding a component */
|
|
12
|
+
onClose?: (
|
|
13
|
+
trigger: 'onBackClick' | 'onCloseClick' | 'onEscape' | 'onOutsideClick',
|
|
14
|
+
e?: React.MouseEvent | React.KeyboardEvent,
|
|
15
|
+
) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface IFullscreenModalHeaderProps extends IBoxProps {
|
|
19
|
+
title?: React.ReactNode;
|
|
20
|
+
description?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IFullscreenModalContext {
|
|
24
|
+
getBackProps: PropGetterFn;
|
|
25
|
+
getCloseProps: PropGetterFn;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const FullscreenModal: (<T>(
|
|
29
|
+
props: CProps<IFullscreenModalProps & T, IFullscreenModalContext>,
|
|
30
|
+
) => ReturnEl) & {
|
|
31
|
+
Header: <T>(props: IFullscreenModalHeaderProps & T) => ReturnEl;
|
|
32
|
+
Footer: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
|
|
33
|
+
Close: <T>(props: IIconProps & T) => ReturnEl;
|
|
34
|
+
Back: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
|
|
35
|
+
Body: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
|
|
36
|
+
Section: <T>(props: ComponentProps<typeof Box> & T) => ReturnEl;
|
|
37
|
+
Title: <T>(props: ComponentProps<typeof Text> & T) => ReturnEl;
|
|
38
|
+
Description: <T>(props: ComponentProps<typeof Text> & T) => ReturnEl;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default FullscreenModal;
|
|
File without changes
|
|
@@ -22,9 +22,9 @@ SBack {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
SClose {
|
|
25
|
-
top:
|
|
26
|
-
right:
|
|
27
|
-
padding:
|
|
25
|
+
top: 12px;
|
|
26
|
+
right: 20px;
|
|
27
|
+
padding: 12px;
|
|
28
28
|
color: var(--stone);
|
|
29
29
|
|
|
30
30
|
&:hover {
|
|
@@ -33,11 +33,11 @@ SClose {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
SBack {
|
|
36
|
-
top:
|
|
37
|
-
left:
|
|
36
|
+
top: 10px;
|
|
37
|
+
left: 32px;
|
|
38
38
|
display: flex;
|
|
39
39
|
align-items: center;
|
|
40
|
-
padding:
|
|
40
|
+
padding: 2px;
|
|
41
41
|
color: var(--gray60);
|
|
42
42
|
font-size: var(--fs100);
|
|
43
43
|
line-height: var(--lh100);
|
|
@@ -52,7 +52,7 @@ SBack {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
SBackText {
|
|
55
|
-
margin-left:
|
|
55
|
+
margin-left: 4px;
|
|
56
56
|
border-bottom-width: 1px;
|
|
57
57
|
border-bottom-style: solid;
|
|
58
58
|
border-bottom-color: transparent;
|
|
@@ -81,10 +81,10 @@ SDescription {
|
|
|
81
81
|
SHeader {
|
|
82
82
|
display: flex;
|
|
83
83
|
align-items: baseline;
|
|
84
|
-
padding-left:
|
|
85
|
-
padding-bottom:
|
|
86
|
-
padding-right:
|
|
87
|
-
padding-top:
|
|
84
|
+
padding-left: 32px;
|
|
85
|
+
padding-bottom: 12px;
|
|
86
|
+
padding-right: 77px;
|
|
87
|
+
padding-top: 30px;
|
|
88
88
|
min-height: 72px;
|
|
89
89
|
box-shadow: inset 0 -1px 1px 0 var(--gray80);
|
|
90
90
|
box-sizing: border-box;
|
|
@@ -103,17 +103,17 @@ SBody {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
SSection {
|
|
106
|
-
padding-top:
|
|
107
|
-
padding-bottom:
|
|
108
|
-
padding-left:
|
|
109
|
-
padding-right:
|
|
106
|
+
padding-top: 24px;
|
|
107
|
+
padding-bottom: 24px;
|
|
108
|
+
padding-left: 32px;
|
|
109
|
+
padding-right: 32px;
|
|
110
110
|
flex: 1 1 auto;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
SHeaderDivider {
|
|
114
|
-
margin-left:
|
|
115
|
-
margin-right:
|
|
116
|
-
height:
|
|
114
|
+
margin-left: 12px;
|
|
115
|
+
margin-right: 12px;
|
|
116
|
+
height: 16px;
|
|
117
117
|
width: 1px;
|
|
118
118
|
background-color: var(--gray80);
|
|
119
119
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
2
|
-
import { Merge } from '@semcore/core';
|
|
3
|
-
import { IModalProps, IModalContext } from '@semcore/modal';
|
|
4
|
-
import { IBoxProps } from '@semcore/flex-box';
|
|
5
|
-
import { IIconProps } from '@semcore/icon';
|
|
6
|
-
import { ITextProps } from '@semcore/typography';
|
|
7
|
-
export interface IFullscreenModalProps extends IModalProps {
|
|
8
|
-
/** This property is responsible for the visibility of the modal window */
|
|
9
|
-
hidden?: boolean;
|
|
10
|
-
/** Function that is invoked when hiding a component */
|
|
11
|
-
onClose?: (trigger: 'onBackClick' | 'onCloseClick' | 'onEscape' | 'onOutsideClick', e?: React.MouseEvent | React.KeyboardEvent) => void;
|
|
12
|
-
}
|
|
13
|
-
export interface IFullscreenModalHeaderProps extends IBoxProps {
|
|
14
|
-
title?: React.ReactNode;
|
|
15
|
-
description?: React.ReactNode;
|
|
16
|
-
}
|
|
17
|
-
declare const FullscreenModal: import("@semcore/core").ComponentType<Merge<IFullscreenModalProps, React.HTMLAttributes<HTMLDivElement>>, {
|
|
18
|
-
Header: Merge<IFullscreenModalHeaderProps, HTMLAttributes<HTMLDivElement>>;
|
|
19
|
-
Footer: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
|
|
20
|
-
Close: Merge<IIconProps, React.SVGAttributes<SVGElement>>;
|
|
21
|
-
Back: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
|
|
22
|
-
Body: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
|
|
23
|
-
Section: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
|
|
24
|
-
Title: Merge<ITextProps, HTMLAttributes<HTMLHeadingElement>>;
|
|
25
|
-
Description: Merge<ITextProps, HTMLAttributes<HTMLSpanElement>>;
|
|
26
|
-
}, IModalContext, {
|
|
27
|
-
[key: string]: (arg: unknown) => void;
|
|
28
|
-
}, null>;
|
|
29
|
-
export default FullscreenModal;
|
package/src/FullscreenModal.tsx
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
2
|
-
import createComponent, { Component, IFunctionProps, Merge, styled } from '@semcore/core';
|
|
3
|
-
import Modal, { IModalProps, IModalContext } from '@semcore/modal';
|
|
4
|
-
import { Box, IBoxProps } from '@semcore/flex-box';
|
|
5
|
-
import { IIconProps } from '@semcore/icon';
|
|
6
|
-
import CloseM from '@semcore/icon/lib/Close/m';
|
|
7
|
-
import ArrowLeftS from '@semcore/icon/lib/ArrowLeft/s';
|
|
8
|
-
import { ITextProps, Text } from '@semcore/typography';
|
|
9
|
-
import fire from '@semcore/utils/lib/fire';
|
|
10
|
-
import logger from '@semcore/utils/lib/logger';
|
|
11
|
-
|
|
12
|
-
import style from './style/fullscreen-modal.shadow.css';
|
|
13
|
-
|
|
14
|
-
export interface IFullscreenModalProps extends IModalProps {
|
|
15
|
-
/** This property is responsible for the visibility of the modal window */
|
|
16
|
-
hidden?: boolean;
|
|
17
|
-
/** Function that is invoked when hiding a component */
|
|
18
|
-
onClose?: (
|
|
19
|
-
trigger: 'onBackClick' | 'onCloseClick' | 'onEscape' | 'onOutsideClick',
|
|
20
|
-
e?: React.MouseEvent | React.KeyboardEvent,
|
|
21
|
-
) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
class FullscreenModalRoot extends Component<IFullscreenModalProps> {
|
|
25
|
-
static displayName = 'FullscreenModal';
|
|
26
|
-
static style = style;
|
|
27
|
-
|
|
28
|
-
bindHandlerClose = (trigger?: 'onBackClick' | 'onCloseClick') => (
|
|
29
|
-
e?: React.MouseEvent | React.KeyboardEvent,
|
|
30
|
-
) => {
|
|
31
|
-
fire(this, 'onClose', trigger, e);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
getCloseProps() {
|
|
35
|
-
return {
|
|
36
|
-
onClick: this.bindHandlerClose('onCloseClick'),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getBackProps() {
|
|
41
|
-
return {
|
|
42
|
-
onClick: this.bindHandlerClose('onBackClick'),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
render() {
|
|
47
|
-
const { Root: SFullscreenModal } = this;
|
|
48
|
-
const {
|
|
49
|
-
styles,
|
|
50
|
-
hidden,
|
|
51
|
-
Children,
|
|
52
|
-
onClose,
|
|
53
|
-
visible: visibleProps,
|
|
54
|
-
closable,
|
|
55
|
-
duration,
|
|
56
|
-
disablePortal,
|
|
57
|
-
} = this.asProps;
|
|
58
|
-
const SFullscreenOverlay = Modal.Overlay;
|
|
59
|
-
|
|
60
|
-
logger.warn(
|
|
61
|
-
hidden !== undefined,
|
|
62
|
-
"Свойство 'hidden' является устаревшим, используйте 'visible'",
|
|
63
|
-
this.asProps['data-ui-name'] || FullscreenModalRoot.displayName,
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const visible = visibleProps === undefined ? !hidden : visibleProps;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<Modal
|
|
70
|
-
closable={false}
|
|
71
|
-
visible={visible}
|
|
72
|
-
onClose={onClose}
|
|
73
|
-
duration={duration}
|
|
74
|
-
disablePortal={disablePortal}
|
|
75
|
-
>
|
|
76
|
-
{styled(styles)(
|
|
77
|
-
<SFullscreenOverlay>
|
|
78
|
-
<SFullscreenModal render={Modal.Window}>
|
|
79
|
-
{closable && <FullscreenModal.Close />}
|
|
80
|
-
<Children />
|
|
81
|
-
</SFullscreenModal>
|
|
82
|
-
</SFullscreenOverlay>,
|
|
83
|
-
)}
|
|
84
|
-
</Modal>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export interface IFullscreenModalHeaderProps extends IBoxProps {
|
|
90
|
-
title?: React.ReactNode;
|
|
91
|
-
description?: React.ReactNode;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function Header(props: IFunctionProps<IFullscreenModalHeaderProps>) {
|
|
95
|
-
const SHeaderDivider = 'div';
|
|
96
|
-
const { Root: SHeader, Children, styles, title, description } = props;
|
|
97
|
-
return styled(styles)(
|
|
98
|
-
<SHeader render={Box}>
|
|
99
|
-
{title && <FullscreenModal.Title children={title} />}
|
|
100
|
-
{description && (
|
|
101
|
-
<>
|
|
102
|
-
<SHeaderDivider />
|
|
103
|
-
<FullscreenModal.Description children={description} />
|
|
104
|
-
</>
|
|
105
|
-
)}
|
|
106
|
-
<Children />
|
|
107
|
-
</SHeader>,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function Body(props: IFunctionProps<IBoxProps>) {
|
|
112
|
-
const { Root: SBody, styles } = props;
|
|
113
|
-
return styled(styles)(<SBody render={Box} />);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function Section(props: IFunctionProps<IBoxProps>) {
|
|
117
|
-
const { Root: SSection, styles } = props;
|
|
118
|
-
return styled(styles)(<SSection render={Box} />);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function Footer(props: IFunctionProps<IBoxProps>) {
|
|
122
|
-
const { Root: SFooter, styles } = props;
|
|
123
|
-
return styled(styles)(<SFooter render={Box} />);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function Close(props: IFunctionProps<IIconProps>) {
|
|
127
|
-
const { Root: SClose, styles } = props;
|
|
128
|
-
return styled(styles)(<SClose render={CloseM} />);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function Title(props: IFunctionProps<ITextProps>) {
|
|
132
|
-
const { Root: STitle, styles } = props;
|
|
133
|
-
return styled(styles)(<STitle render={Text} tag="h4" />);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function Description(props: IFunctionProps<ITextProps>) {
|
|
137
|
-
const { Root: SDescription, styles } = props;
|
|
138
|
-
return styled(styles)(<SDescription render={Text} />);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function Back(props: IFunctionProps<IBoxProps>) {
|
|
142
|
-
const SBackText = Text;
|
|
143
|
-
const { Root: SBack, Children, styles } = props;
|
|
144
|
-
|
|
145
|
-
return styled(styles)(
|
|
146
|
-
<SBack render={Box}>
|
|
147
|
-
<ArrowLeftS />
|
|
148
|
-
<SBackText>
|
|
149
|
-
<Children />
|
|
150
|
-
</SBackText>
|
|
151
|
-
</SBack>,
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const FullscreenModal = createComponent<
|
|
156
|
-
Merge<IFullscreenModalProps, HTMLAttributes<HTMLDivElement>>,
|
|
157
|
-
{
|
|
158
|
-
Header: Merge<IFullscreenModalHeaderProps, HTMLAttributes<HTMLDivElement>>;
|
|
159
|
-
Footer: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
|
|
160
|
-
Close: Merge<IIconProps, React.SVGAttributes<SVGElement>>;
|
|
161
|
-
Back: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
|
|
162
|
-
Body: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
|
|
163
|
-
Section: Merge<IBoxProps, HTMLAttributes<HTMLDivElement>>;
|
|
164
|
-
Title: Merge<ITextProps, HTMLAttributes<HTMLHeadingElement>>;
|
|
165
|
-
Description: Merge<ITextProps, HTMLAttributes<HTMLSpanElement>>;
|
|
166
|
-
},
|
|
167
|
-
IModalContext
|
|
168
|
-
>(
|
|
169
|
-
FullscreenModalRoot,
|
|
170
|
-
{
|
|
171
|
-
Header,
|
|
172
|
-
Footer,
|
|
173
|
-
Close,
|
|
174
|
-
Back,
|
|
175
|
-
Body,
|
|
176
|
-
Section,
|
|
177
|
-
Title,
|
|
178
|
-
Description,
|
|
179
|
-
},
|
|
180
|
-
{ parent: Modal },
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
export default FullscreenModal;
|