@elliemae/ds-dialog 2.3.1 → 3.0.0-alpha.3

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.
Files changed (56) hide show
  1. package/dist/cjs/DSDialog.js +139 -0
  2. package/dist/cjs/DSDialog.js.map +7 -0
  3. package/dist/cjs/DSDialogDatatestid.js +38 -0
  4. package/dist/cjs/DSDialogDatatestid.js.map +7 -0
  5. package/dist/cjs/defaultProps.js +46 -0
  6. package/dist/cjs/defaultProps.js.map +7 -0
  7. package/dist/cjs/index.js +94 -0
  8. package/dist/cjs/index.js.map +7 -0
  9. package/dist/cjs/propTypes.js +64 -0
  10. package/dist/cjs/propTypes.js.map +7 -0
  11. package/dist/cjs/sharedTypes.js +27 -0
  12. package/dist/cjs/sharedTypes.js.map +7 -0
  13. package/dist/cjs/styles.js +153 -0
  14. package/dist/cjs/styles.js.map +7 -0
  15. package/dist/cjs/utils.js +55 -0
  16. package/dist/cjs/utils.js.map +7 -0
  17. package/dist/esm/DSDialog.js +117 -0
  18. package/dist/esm/DSDialog.js.map +7 -0
  19. package/dist/esm/DSDialogDatatestid.js +9 -0
  20. package/dist/esm/DSDialogDatatestid.js.map +7 -0
  21. package/{esm → dist/esm}/defaultProps.js +8 -6
  22. package/dist/esm/defaultProps.js.map +7 -0
  23. package/{esm → dist/esm}/index.js +48 -19
  24. package/dist/esm/index.js.map +7 -0
  25. package/dist/esm/propTypes.js +37 -0
  26. package/dist/esm/propTypes.js.map +7 -0
  27. package/dist/esm/sharedTypes.js +2 -0
  28. package/dist/esm/sharedTypes.js.map +7 -0
  29. package/dist/esm/styles.js +124 -0
  30. package/dist/esm/styles.js.map +7 -0
  31. package/dist/esm/utils.js +26 -0
  32. package/dist/esm/utils.js.map +7 -0
  33. package/package.json +49 -37
  34. package/cjs/DSDialog.js +0 -141
  35. package/cjs/DSDialogDatatestid.js +0 -10
  36. package/cjs/defaultProps.js +0 -19
  37. package/cjs/index.js +0 -70
  38. package/cjs/propTypes.js +0 -31
  39. package/cjs/sharedTypes.js +0 -7
  40. package/cjs/styles.js +0 -145
  41. package/cjs/utils.js +0 -35
  42. package/esm/DSDialog.js +0 -129
  43. package/esm/DSDialogDatatestid.js +0 -6
  44. package/esm/propTypes.js +0 -23
  45. package/esm/sharedTypes.js +0 -5
  46. package/esm/styles.js +0 -125
  47. package/esm/utils.js +0 -28
  48. package/types/DSDialog.d.ts +0 -376
  49. package/types/DSDialogDatatestid.d.ts +0 -4
  50. package/types/defaultProps.d.ts +0 -2
  51. package/types/index.d.ts +0 -52
  52. package/types/propTypes.d.ts +0 -388
  53. package/types/sharedTypes.d.ts +0 -6
  54. package/types/styles.d.ts +0 -23
  55. package/types/tests/DSDialog.test.d.ts +0 -1
  56. package/types/utils.d.ts +0 -20
package/esm/DSDialog.js DELETED
@@ -1,129 +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 focusContainer = useCallback(() => {
51
- var _containerRef$current, _containerRef$current2, _containerRef$current3;
52
-
53
- const isContainerOrChildFocused = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.contains(document.activeElement);
54
- if (!isContainerOrChildFocused) (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : (_containerRef$current3 = _containerRef$current2.focus) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.call(_containerRef$current2);
55
- }, []);
56
- useEffect(() => {
57
- document.addEventListener('focusin', focusContainer);
58
- return () => document.removeEventListener('focusin', focusContainer);
59
- }, [focusContainer]);
60
- const handleOutsideClick = useCallback(e => {
61
- if (e.target.dataset.portalbg) onClickOutside();
62
- }, [onClickOutside]);
63
- const handleOnKeyDown = useCallback(e => {
64
- if (e.key === 'Escape') onClose();
65
- }, [onClose]);
66
-
67
- const _useGetGlobalAttribut = useGetGlobalAttributes(propsWithDefault, {
68
- onClick: handleOutsideClick,
69
- onKeyDown: handleOnKeyDown
70
- }),
71
- {
72
- className
73
- } = _useGetGlobalAttribut,
74
- restOfGlobalAttributes = _objectWithoutProperties(_useGetGlobalAttribut, _excluded2);
75
-
76
- useEffect(() => {
77
- var _window$getComputedSt;
78
-
79
- const body = document.getElementsByTagName('body')[0];
80
- const {
81
- clientHeight,
82
- scrollHeight
83
- } = body;
84
- const padding = (_window$getComputedSt = window.getComputedStyle(body, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
85
- if (!isOpen) return setBodyInfo({
86
- overflow: false,
87
- padding: '0px'
88
- });
89
- return setBodyInfo({
90
- overflow: scrollHeight > clientHeight,
91
- padding
92
- });
93
- }, [isOpen]);
94
- useEffect(() => {
95
- var _containerRef$current4;
96
-
97
- if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.focus();
98
- }, [isOpen, removeAutoFocus]);
99
-
100
- if (isOpen) {
101
- return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/_jsx(StyledDialogBackground, {
102
- className: className,
103
- onClick: handleOutsideClick,
104
- "data-portalbg": true,
105
- "data-testid": DSDialogDatatestid.BACKGROUND,
106
- zIndex: zIndex
107
- }, void 0, _FixedBody || (_FixedBody = /*#__PURE__*/_jsx(FixedBody, {
108
- bodyInfo: bodyInfo
109
- })), /*#__PURE__*/jsx(StyledDialogContainer, _objectSpread(_objectSpread(_objectSpread({
110
- role: "dialog",
111
- "aria-modal": true,
112
- ref: containerRef,
113
- tabIndex: !removeAutoFocus ? 0 : undefined
114
- }, getSpaceProps(rest)), {}, {
115
- size: size,
116
- centered: centered,
117
- "data-testid": DSDialogDatatestid.CONTAINER
118
- }, restOfGlobalAttributes), {}, {
119
- children: children
120
- }))), document.getElementsByTagName('body')[0]);
121
- }
122
-
123
- return null;
124
- };
125
-
126
- const DSDialogWithSchema = describe(DSDialog);
127
- DSDialogWithSchema.propTypes = propTypes;
128
-
129
- export { DSDialog, DSDialogWithSchema };
@@ -1,6 +0,0 @@
1
- const DSDialogDatatestid = {
2
- CONTAINER: 'ds-dialog-container',
3
- BACKGROUND: 'ds-dialog-background'
4
- };
5
-
6
- export { DSDialogDatatestid };
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 };
@@ -1,5 +0,0 @@
1
- let DSDialogInternalsT;
2
-
3
- (function (_DSDialogInternalsT) {})(DSDialogInternalsT || (DSDialogInternalsT = {}));
4
-
5
- export { DSDialogInternalsT };
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 };