@elliemae/ds-dialog 2.3.0-rc.1 → 3.0.0-alpha.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/dist/cjs/DSDialog.js +130 -0
- package/dist/cjs/DSDialog.js.map +7 -0
- package/dist/cjs/DSDialogDatatestid.js +38 -0
- package/dist/cjs/DSDialogDatatestid.js.map +7 -0
- package/dist/cjs/defaultProps.js +46 -0
- package/dist/cjs/defaultProps.js.map +7 -0
- package/dist/cjs/index.js +94 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/propTypes.js +64 -0
- package/dist/cjs/propTypes.js.map +7 -0
- package/dist/cjs/sharedTypes.js +27 -0
- package/dist/cjs/sharedTypes.js.map +7 -0
- package/dist/cjs/styles.js +153 -0
- package/dist/cjs/styles.js.map +7 -0
- package/dist/cjs/utils.js +55 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/DSDialog.js +108 -0
- package/dist/esm/DSDialog.js.map +7 -0
- package/dist/esm/DSDialogDatatestid.js +9 -0
- package/dist/esm/DSDialogDatatestid.js.map +7 -0
- package/{esm → dist/esm}/defaultProps.js +8 -6
- package/dist/esm/defaultProps.js.map +7 -0
- package/{esm → dist/esm}/index.js +48 -19
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/propTypes.js +37 -0
- package/dist/esm/propTypes.js.map +7 -0
- package/dist/esm/sharedTypes.js +2 -0
- package/dist/esm/sharedTypes.js.map +7 -0
- package/dist/esm/styles.js +124 -0
- package/dist/esm/styles.js.map +7 -0
- package/dist/esm/utils.js +26 -0
- package/dist/esm/utils.js.map +7 -0
- package/package.json +48 -36
- package/cjs/DSDialog.js +0 -131
- package/cjs/DSDialogDatatestid.js +0 -10
- package/cjs/defaultProps.js +0 -19
- package/cjs/index.js +0 -70
- package/cjs/propTypes.js +0 -31
- package/cjs/sharedTypes.js +0 -7
- package/cjs/styles.js +0 -145
- package/cjs/utils.js +0 -35
- package/esm/DSDialog.js +0 -119
- package/esm/DSDialogDatatestid.js +0 -6
- package/esm/propTypes.js +0 -23
- package/esm/sharedTypes.js +0 -5
- package/esm/styles.js +0 -125
- package/esm/utils.js +0 -28
- package/types/DSDialog.d.ts +0 -376
- package/types/DSDialogDatatestid.d.ts +0 -4
- package/types/defaultProps.d.ts +0 -2
- package/types/index.d.ts +0 -52
- package/types/propTypes.d.ts +0 -388
- package/types/sharedTypes.d.ts +0 -6
- package/types/styles.d.ts +0 -23
- package/types/tests/DSDialog.test.d.ts +0 -1
- package/types/utils.d.ts +0 -20
package/esm/DSDialog.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
9
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
10
|
-
import ReactDOM from 'react-dom';
|
|
11
|
-
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
12
|
-
import { describe, useMemoMergePropsWithDefault, useValidateTypescriptPropTypes, useGetGlobalAttributes } from '@elliemae/ds-props-helpers';
|
|
13
|
-
import { StyledDialogBackground, FixedBody, StyledDialogContainer } from './styles.js';
|
|
14
|
-
import { propTypes } from './propTypes.js';
|
|
15
|
-
import { defaultProps } from './defaultProps.js';
|
|
16
|
-
import { getSpaceProps } from './utils.js';
|
|
17
|
-
import { DSDialogDatatestid } from './DSDialogDatatestid.js';
|
|
18
|
-
import { jsx } from 'react/jsx-runtime';
|
|
19
|
-
|
|
20
|
-
const _excluded = ["children", "isOpen", "onClickOutside", "onClose", "centered", "size", "removeAutoFocus", "zIndex"],
|
|
21
|
-
_excluded2 = ["className"];
|
|
22
|
-
|
|
23
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
-
|
|
25
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
|
-
|
|
27
|
-
const DSDialog = props => {
|
|
28
|
-
var _FixedBody;
|
|
29
|
-
|
|
30
|
-
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
31
|
-
const [bodyInfo, setBodyInfo] = useState({
|
|
32
|
-
overflow: false,
|
|
33
|
-
padding: '0px'
|
|
34
|
-
});
|
|
35
|
-
useValidateTypescriptPropTypes(propsWithDefault, propTypes);
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
children,
|
|
39
|
-
isOpen,
|
|
40
|
-
onClickOutside,
|
|
41
|
-
onClose,
|
|
42
|
-
centered,
|
|
43
|
-
size,
|
|
44
|
-
removeAutoFocus,
|
|
45
|
-
zIndex
|
|
46
|
-
} = propsWithDefault,
|
|
47
|
-
rest = _objectWithoutProperties(propsWithDefault, _excluded);
|
|
48
|
-
|
|
49
|
-
const containerRef = useRef(null);
|
|
50
|
-
const handleOutsideClick = useCallback(e => {
|
|
51
|
-
if (e.target.dataset.portalbg) onClickOutside();
|
|
52
|
-
}, [onClickOutside]);
|
|
53
|
-
const handleOnKeyDown = useCallback(e => {
|
|
54
|
-
if (e.key === 'Escape') onClose();
|
|
55
|
-
}, [onClose]);
|
|
56
|
-
|
|
57
|
-
const _useGetGlobalAttribut = useGetGlobalAttributes(propsWithDefault, {
|
|
58
|
-
onClick: handleOutsideClick,
|
|
59
|
-
onKeyDown: handleOnKeyDown
|
|
60
|
-
}),
|
|
61
|
-
{
|
|
62
|
-
className
|
|
63
|
-
} = _useGetGlobalAttribut,
|
|
64
|
-
restOfGlobalAttributes = _objectWithoutProperties(_useGetGlobalAttribut, _excluded2);
|
|
65
|
-
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
var _window$getComputedSt;
|
|
68
|
-
|
|
69
|
-
const body = document.getElementsByTagName('body')[0];
|
|
70
|
-
const {
|
|
71
|
-
clientHeight,
|
|
72
|
-
scrollHeight
|
|
73
|
-
} = body;
|
|
74
|
-
const padding = (_window$getComputedSt = window.getComputedStyle(body, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
|
|
75
|
-
if (!isOpen) return setBodyInfo({
|
|
76
|
-
overflow: false,
|
|
77
|
-
padding: '0px'
|
|
78
|
-
});
|
|
79
|
-
return setBodyInfo({
|
|
80
|
-
overflow: scrollHeight > clientHeight,
|
|
81
|
-
padding
|
|
82
|
-
});
|
|
83
|
-
}, [isOpen]);
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
var _containerRef$current;
|
|
86
|
-
|
|
87
|
-
if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.focus();
|
|
88
|
-
}, [isOpen, removeAutoFocus]);
|
|
89
|
-
|
|
90
|
-
if (isOpen) {
|
|
91
|
-
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/_jsx(StyledDialogBackground, {
|
|
92
|
-
className: className,
|
|
93
|
-
onClick: handleOutsideClick,
|
|
94
|
-
"data-portalbg": true,
|
|
95
|
-
"data-testid": DSDialogDatatestid.BACKGROUND,
|
|
96
|
-
zIndex: zIndex
|
|
97
|
-
}, void 0, _FixedBody || (_FixedBody = /*#__PURE__*/_jsx(FixedBody, {
|
|
98
|
-
bodyInfo: bodyInfo
|
|
99
|
-
})), /*#__PURE__*/jsx(StyledDialogContainer, _objectSpread(_objectSpread(_objectSpread({
|
|
100
|
-
role: "dialog",
|
|
101
|
-
"aria-modal": true,
|
|
102
|
-
ref: containerRef,
|
|
103
|
-
tabIndex: !removeAutoFocus ? 0 : undefined
|
|
104
|
-
}, getSpaceProps(rest)), {}, {
|
|
105
|
-
size: size,
|
|
106
|
-
centered: centered,
|
|
107
|
-
"data-testid": DSDialogDatatestid.CONTAINER
|
|
108
|
-
}, restOfGlobalAttributes), {}, {
|
|
109
|
-
children: children
|
|
110
|
-
}))), document.getElementsByTagName('body')[0]);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return null;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const DSDialogWithSchema = describe(DSDialog);
|
|
117
|
-
DSDialogWithSchema.propTypes = propTypes;
|
|
118
|
-
|
|
119
|
-
export { DSDialog, DSDialogWithSchema };
|
package/esm/propTypes.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import { PropTypes, globalAttributesPropTypes } from '@elliemae/ds-props-helpers';
|
|
8
|
-
import { DSDialogSizesArrayValues, DSDialogSizes } from './utils.js';
|
|
9
|
-
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
-
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
-
const propTypes = _objectSpread(_objectSpread({}, globalAttributesPropTypes), {}, {
|
|
14
|
-
isOpen: PropTypes.bool.description('Whether the Dialog is open or not.').defaultValue(false),
|
|
15
|
-
children: PropTypes.node.description('Nested components.').isRequired,
|
|
16
|
-
centered: PropTypes.bool.description('Centers the Dialog.').defaultValue(false),
|
|
17
|
-
removeAutoFocus: PropTypes.bool.description('Removes focus in the Dialog container when is open. If you want to focus an specific element in the Dialog, it should be set to true.').defaultValue(false),
|
|
18
|
-
onClickOutside: PropTypes.func.description('Callback that should be used to close the modal when the user clicks outside.').defaultValue(() => {}),
|
|
19
|
-
onClose: PropTypes.func.description('Callback triggered with ESC key.').defaultValue(() => {}),
|
|
20
|
-
size: PropTypes.oneOf(DSDialogSizesArrayValues).description("Dialog's width size.").defaultValue(DSDialogSizes.DEFAULT)
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export { propTypes };
|
package/esm/sharedTypes.js
DELETED
package/esm/styles.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { createGlobalStyle } from '@elliemae/ds-system';
|
|
4
|
-
import { space, sizing, layout, flexboxes } from '@xstyled/styled-components';
|
|
5
|
-
import { allSizes } from './utils.js';
|
|
6
|
-
|
|
7
|
-
var _templateObject;
|
|
8
|
-
const FixedBody = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n body {\n overflow: hidden;\n \n ", "\n }\n"])), _ref => {
|
|
9
|
-
let {
|
|
10
|
-
bodyInfo
|
|
11
|
-
} = _ref;
|
|
12
|
-
return bodyInfo.overflow ? "padding-right: calc( ".concat(bodyInfo.padding, " + 15px ) !important;") : "";
|
|
13
|
-
});
|
|
14
|
-
const StyledDialogBackground = /*#__PURE__*/styled.div.withConfig({
|
|
15
|
-
componentId: "sc-106vqwv-0"
|
|
16
|
-
})(["position:fixed;top:0;bottom:0;width:100%;height:100%;background:rgba(37,41,47,50%);overflow-y:auto;z-index:", ";"], _ref2 => {
|
|
17
|
-
let {
|
|
18
|
-
zIndex
|
|
19
|
-
} = _ref2;
|
|
20
|
-
return zIndex;
|
|
21
|
-
});
|
|
22
|
-
const StyledDialogContainer = /*#__PURE__*/styled.div.withConfig({
|
|
23
|
-
componentId: "sc-106vqwv-1"
|
|
24
|
-
})(["height:fit-content;position:absolute;top:0;bottom:0;left:0;right:0;margin:", ";width:", ";min-width:300px;box-shadow:0 10px 20px 0 ", ";background:", ";overflow-y:auto;", " &:focus{outline:none;}"], _ref3 => {
|
|
25
|
-
let {
|
|
26
|
-
centered
|
|
27
|
-
} = _ref3;
|
|
28
|
-
return centered ? 'auto' : '20vh auto auto auto';
|
|
29
|
-
}, _ref4 => {
|
|
30
|
-
let {
|
|
31
|
-
size
|
|
32
|
-
} = _ref4;
|
|
33
|
-
return allSizes[size];
|
|
34
|
-
}, _ref5 => {
|
|
35
|
-
let {
|
|
36
|
-
theme
|
|
37
|
-
} = _ref5;
|
|
38
|
-
return theme.colors.neutral[500];
|
|
39
|
-
}, _ref6 => {
|
|
40
|
-
let {
|
|
41
|
-
theme
|
|
42
|
-
} = _ref6;
|
|
43
|
-
return theme.colors.neutral['000'];
|
|
44
|
-
}, space);
|
|
45
|
-
const DSDialogTitle = /*#__PURE__*/styled.h3.withConfig({
|
|
46
|
-
componentId: "sc-106vqwv-2"
|
|
47
|
-
})(["font-size:", ";display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:28px;margin:0;"], _ref7 => {
|
|
48
|
-
let {
|
|
49
|
-
theme
|
|
50
|
-
} = _ref7;
|
|
51
|
-
return theme.fontSizes.title[700];
|
|
52
|
-
});
|
|
53
|
-
const DSDialogAddon = /*#__PURE__*/styled.div.withConfig({
|
|
54
|
-
componentId: "sc-106vqwv-3"
|
|
55
|
-
})([""]);
|
|
56
|
-
const DSDialogHeader = /*#__PURE__*/styled.div.withConfig({
|
|
57
|
-
componentId: "sc-106vqwv-4"
|
|
58
|
-
})(["display:grid;align-items:center;grid-auto-flow:column;min-height:", ";padding:10px ", ";& ", " + ", "{align-self:flex-start;justify-self:flex-end;}& ", ":only-child{justify-self:flex-end;}", " ", ""], _ref8 => {
|
|
59
|
-
let {
|
|
60
|
-
theme
|
|
61
|
-
} = _ref8;
|
|
62
|
-
return theme.space.m;
|
|
63
|
-
}, _ref9 => {
|
|
64
|
-
let {
|
|
65
|
-
theme
|
|
66
|
-
} = _ref9;
|
|
67
|
-
return theme.space.xs;
|
|
68
|
-
}, DSDialogTitle, DSDialogAddon, DSDialogAddon, space, sizing);
|
|
69
|
-
const DSDialogSeparator = /*#__PURE__*/styled.hr.attrs(() => ({
|
|
70
|
-
'aria-hidden': true
|
|
71
|
-
})).withConfig({
|
|
72
|
-
componentId: "sc-106vqwv-5"
|
|
73
|
-
})(["margin:0;border-top:1px solid ", ";"], _ref10 => {
|
|
74
|
-
let {
|
|
75
|
-
theme
|
|
76
|
-
} = _ref10;
|
|
77
|
-
return theme.colors.neutral['080'];
|
|
78
|
-
});
|
|
79
|
-
const DSDialogBody = /*#__PURE__*/styled.div.withConfig({
|
|
80
|
-
componentId: "sc-106vqwv-6"
|
|
81
|
-
})(["padding:", ";overflow-y:auto;", " ", " ", " ", ""], _ref11 => {
|
|
82
|
-
let {
|
|
83
|
-
theme
|
|
84
|
-
} = _ref11;
|
|
85
|
-
return theme.space.xs;
|
|
86
|
-
}, layout, space, flexboxes, sizing);
|
|
87
|
-
const DSDialogPrimaryMessage = /*#__PURE__*/styled.h3.withConfig({
|
|
88
|
-
componentId: "sc-106vqwv-7"
|
|
89
|
-
})(["margin:0;"]);
|
|
90
|
-
const DSDialogSecondaryMessage = /*#__PURE__*/styled.p.withConfig({
|
|
91
|
-
componentId: "sc-106vqwv-8"
|
|
92
|
-
})(["margin:0;color:", ";"], _ref12 => {
|
|
93
|
-
let {
|
|
94
|
-
theme
|
|
95
|
-
} = _ref12;
|
|
96
|
-
return theme.colors.neutral[500];
|
|
97
|
-
});
|
|
98
|
-
const DSDialogDefaultLayout = /*#__PURE__*/styled.div.withConfig({
|
|
99
|
-
componentId: "sc-106vqwv-9"
|
|
100
|
-
})(["display:grid;grid-auto-flow:row;justify-items:center;align-items:center;grid-gap:", ";", "{text-align:center;}"], _ref13 => {
|
|
101
|
-
let {
|
|
102
|
-
theme
|
|
103
|
-
} = _ref13;
|
|
104
|
-
return theme.space.xxs;
|
|
105
|
-
}, DSDialogSecondaryMessage);
|
|
106
|
-
const DSDialogFooter = /*#__PURE__*/styled.div.withConfig({
|
|
107
|
-
componentId: "sc-106vqwv-10"
|
|
108
|
-
})(["display:grid;grid-auto-flow:column;align-items:center;justify-content:flex-end;grid-gap:", ";min-height:", ";padding:0 ", ";", " ", " ", ""], _ref14 => {
|
|
109
|
-
let {
|
|
110
|
-
theme
|
|
111
|
-
} = _ref14;
|
|
112
|
-
return theme.space.xxs;
|
|
113
|
-
}, _ref15 => {
|
|
114
|
-
let {
|
|
115
|
-
theme
|
|
116
|
-
} = _ref15;
|
|
117
|
-
return theme.space.m;
|
|
118
|
-
}, _ref16 => {
|
|
119
|
-
let {
|
|
120
|
-
theme
|
|
121
|
-
} = _ref16;
|
|
122
|
-
return theme.space.xs;
|
|
123
|
-
}, space, flexboxes, sizing);
|
|
124
|
-
|
|
125
|
-
export { DSDialogAddon, DSDialogBody, DSDialogDefaultLayout, DSDialogFooter, DSDialogHeader, DSDialogPrimaryMessage, DSDialogSecondaryMessage, DSDialogSeparator, DSDialogTitle, FixedBody, StyledDialogBackground, StyledDialogContainer };
|
package/esm/utils.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
-
|
|
6
|
-
const getSpaceProps = props => Object.fromEntries(Object.entries(props).filter(_ref => {
|
|
7
|
-
let [key] = _ref;
|
|
8
|
-
return /^[pm][xytblr]?$/.exec(key);
|
|
9
|
-
}));
|
|
10
|
-
const DSDialogSizes = {
|
|
11
|
-
DEFAULT: 'default',
|
|
12
|
-
SMALL: 'small',
|
|
13
|
-
MEDIUM: 'medium',
|
|
14
|
-
LARGE: 'large',
|
|
15
|
-
XLARGE: 'x-large',
|
|
16
|
-
XXLARGE: 'xx-large'
|
|
17
|
-
};
|
|
18
|
-
const DSDialogSizesArrayValues = Object.values(DSDialogSizes);
|
|
19
|
-
const allSizes = {
|
|
20
|
-
default: '576px',
|
|
21
|
-
small: '320px',
|
|
22
|
-
medium: '656px',
|
|
23
|
-
large: '848px',
|
|
24
|
-
'x-large': '1042px',
|
|
25
|
-
'xx-large': '1440px'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { DSDialogSizes, DSDialogSizesArrayValues, allSizes, getSpaceProps };
|