1 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
2 |
|
3 | import { h } from 'preact';
|
4 | import cn from 'classnames';
|
5 | import { Icon } from './icon';
|
6 | import omit from './utils/omit';
|
7 | import { Portal } from './portal';
|
8 | import { Shield } from './shield';
|
9 |
|
10 | export const Dialog = incomingProps => {
|
11 | const {
|
12 | className,
|
13 | title,
|
14 | doClose,
|
15 | forceChoice,
|
16 | style,
|
17 | bottom,
|
18 | children
|
19 | } = incomingProps;
|
20 | const props = omit(incomingProps, ['className', 'title', 'doClose', 'forceChoice', 'style', 'children', 'bottom']);
|
21 | return h(
|
22 | Portal,
|
23 | { into: 'body' },
|
24 | h(
|
25 | 'div',
|
26 | { className: 'fixed z-999 vh-100 w-100 top-0 left-0 flex items-center justify-center' },
|
27 | h(Shield, { onClick: forceChoice ? null : doClose }),
|
28 | h(
|
29 | 'dialog',
|
30 | _extends({
|
31 | open: true,
|
32 | style: Object.assign({
|
33 | minHeight: '150px',
|
34 | minWidth: '300px',
|
35 | width: '600px',
|
36 |
|
37 | maxHeight: 'calc(100vh - 120px)'
|
38 | }, style),
|
39 | className: cn('ph2 pt2 pb1 bg-white bn br3 shadow-2 z-999 relative flex flex-column', className)
|
40 | }, props),
|
41 | h(
|
42 | 'div',
|
43 | { className: 'w-100 pt1 ph1' },
|
44 | !forceChoice &&
|
45 |
|
46 | h(
|
47 | 'div',
|
48 | { className: 'fr', style: { width: '44px', height: '10px' } },
|
49 | h(
|
50 | 'button',
|
51 | {
|
52 | onClick: doClose,
|
53 | style: { top: '-16px', right: '-4px' },
|
54 | className: 'button-reset bn bg-transparent relative pa3'
|
55 | },
|
56 | h(Icon, { icon: 'close' })
|
57 | )
|
58 | ),
|
59 | title && h(
|
60 | 'h3',
|
61 | { className: 'mt0 mb2' },
|
62 | title
|
63 | )
|
64 | ),
|
65 | h(
|
66 | 'div',
|
67 | { className: 'pa1 prevent-overscroll overflow-y-scroll w-100 overflow-x-hidden' },
|
68 | children
|
69 | ),
|
70 | h(
|
71 | 'div',
|
72 | { className: 'ph1 pv2' },
|
73 | bottom
|
74 | )
|
75 | )
|
76 | )
|
77 | );
|
78 | }; |
\ | No newline at end of file |