@elliemae/ds-dialog 2.2.2-rc.1 → 2.3.0-alpha.10

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 (63) hide show
  1. package/dist/cjs/DSDialog.js +99 -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/DSDialogInternalTypes.js +27 -0
  6. package/dist/cjs/DSDialogInternalTypes.js.map +7 -0
  7. package/dist/cjs/DSDialogTypes.js +27 -0
  8. package/dist/cjs/DSDialogTypes.js.map +7 -0
  9. package/dist/cjs/defaultProps.js +45 -0
  10. package/dist/cjs/defaultProps.js.map +7 -0
  11. package/dist/cjs/index.js +94 -0
  12. package/dist/cjs/index.js.map +7 -0
  13. package/dist/cjs/propTypes.js +46 -0
  14. package/dist/cjs/propTypes.js.map +7 -0
  15. package/dist/cjs/styles.js +151 -0
  16. package/dist/cjs/styles.js.map +7 -0
  17. package/dist/cjs/utils.js +55 -0
  18. package/dist/cjs/utils.js.map +7 -0
  19. package/dist/esm/DSDialog.js +75 -0
  20. package/dist/esm/DSDialog.js.map +7 -0
  21. package/dist/esm/DSDialogDatatestid.js +9 -0
  22. package/dist/esm/DSDialogDatatestid.js.map +7 -0
  23. package/dist/esm/DSDialogInternalTypes.js +2 -0
  24. package/dist/esm/DSDialogInternalTypes.js.map +7 -0
  25. package/dist/esm/DSDialogTypes.js +2 -0
  26. package/dist/esm/DSDialogTypes.js.map +7 -0
  27. package/dist/esm/defaultProps.js +16 -0
  28. package/dist/esm/defaultProps.js.map +7 -0
  29. package/{esm → dist/esm}/index.js +48 -19
  30. package/dist/esm/index.js.map +7 -0
  31. package/dist/esm/propTypes.js +17 -0
  32. package/dist/esm/propTypes.js.map +7 -0
  33. package/dist/esm/styles.js +122 -0
  34. package/dist/esm/styles.js.map +7 -0
  35. package/dist/esm/utils.js +26 -0
  36. package/dist/esm/utils.js.map +7 -0
  37. package/{types → dist/types}/DSDialog.d.ts +1 -1
  38. package/{types → dist/types}/DSDialogDatatestid.d.ts +0 -0
  39. package/{types → dist/types}/DSDialogInternalTypes.d.ts +0 -0
  40. package/{types → dist/types}/DSDialogTypes.d.ts +0 -0
  41. package/{types → dist/types}/defaultProps.d.ts +0 -0
  42. package/{types → dist/types}/index.d.ts +0 -0
  43. package/{types → dist/types}/propTypes.d.ts +0 -0
  44. package/{types → dist/types}/styles.d.ts +0 -0
  45. package/{types → dist/types}/utils.d.ts +0 -0
  46. package/package.json +37 -35
  47. package/cjs/DSDialog.js +0 -123
  48. package/cjs/DSDialogDatatestid.js +0 -10
  49. package/cjs/DSDialogInternalTypes.js +0 -2
  50. package/cjs/DSDialogTypes.js +0 -2
  51. package/cjs/defaultProps.js +0 -18
  52. package/cjs/index.js +0 -70
  53. package/cjs/propTypes.js +0 -31
  54. package/cjs/styles.js +0 -145
  55. package/cjs/utils.js +0 -35
  56. package/esm/DSDialog.js +0 -111
  57. package/esm/DSDialogDatatestid.js +0 -6
  58. package/esm/DSDialogInternalTypes.js +0 -1
  59. package/esm/DSDialogTypes.js +0 -1
  60. package/esm/defaultProps.js +0 -14
  61. package/esm/propTypes.js +0 -23
  62. package/esm/styles.js +0 -125
  63. package/esm/utils.js +0 -28
package/esm/DSDialog.js DELETED
@@ -1,111 +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 { jsxs, jsx } from 'react/jsx-runtime';
19
-
20
- const _excluded = ["children", "isOpen", "onClickOutside", "centered", "size", "removeAutoFocus", "zIndex"];
21
-
22
- 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; }
23
-
24
- 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; }
25
-
26
- const DSDialog = props => {
27
- var _FixedBody;
28
-
29
- const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
30
- const [bodyInfo, setBodyInfo] = useState({
31
- overflow: false,
32
- padding: '0px'
33
- });
34
- useValidateTypescriptPropTypes(propsWithDefault, propTypes);
35
-
36
- const {
37
- children,
38
- isOpen,
39
- onClickOutside,
40
- centered,
41
- size,
42
- removeAutoFocus,
43
- zIndex
44
- } = propsWithDefault,
45
- rest = _objectWithoutProperties(propsWithDefault, _excluded);
46
-
47
- const containerRef = useRef(null);
48
- const handleOutsideClick = useCallback(e => {
49
- if (e.target.dataset.portalbg) onClickOutside();
50
- }, [onClickOutside]);
51
- const handleOnKeyDown = useCallback(e => {
52
- if (e.key === 'Escape') onClickOutside();
53
- }, [onClickOutside]);
54
- useEffect(() => {
55
- var _window$getComputedSt;
56
-
57
- const body = document.getElementsByTagName('body')[0];
58
- const {
59
- offsetHeight,
60
- scrollHeight
61
- } = body;
62
- const padding = (_window$getComputedSt = window.getComputedStyle(body, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
63
- if (!isOpen) return setBodyInfo({
64
- overflow: false,
65
- padding: '0px'
66
- });
67
- return setBodyInfo({
68
- overflow: offsetHeight < scrollHeight,
69
- padding
70
- });
71
- }, [isOpen]);
72
- useEffect(() => {
73
- var _containerRef$current;
74
-
75
- if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.focus();
76
- }, [isOpen, removeAutoFocus]);
77
- const globalAttributes = useGetGlobalAttributes(propsWithDefault, {
78
- onClick: handleOutsideClick
79
- });
80
-
81
- if (isOpen) {
82
- return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/jsxs(StyledDialogBackground, _objectSpread(_objectSpread({
83
- onClick: handleOutsideClick,
84
- "data-portalbg": true,
85
- "data-testid": DSDialogDatatestid.BACKGROUND,
86
- zIndex: zIndex
87
- }, globalAttributes), {}, {
88
- children: [_FixedBody || (_FixedBody = /*#__PURE__*/_jsx(FixedBody, {
89
- bodyInfo: bodyInfo
90
- })), /*#__PURE__*/jsx(StyledDialogContainer, _objectSpread(_objectSpread({
91
- role: "dialog",
92
- "aria-modal": true,
93
- ref: containerRef,
94
- tabIndex: !removeAutoFocus ? 0 : undefined,
95
- onKeyDown: handleOnKeyDown
96
- }, getSpaceProps(rest)), {}, {
97
- size: size,
98
- centered: centered,
99
- "data-testid": DSDialogDatatestid.CONTAINER,
100
- children: children
101
- }))]
102
- })), document.getElementsByTagName('body')[0]);
103
- }
104
-
105
- return null;
106
- };
107
-
108
- const DSDialogWithSchema = describe(DSDialog);
109
- DSDialogWithSchema.propTypes = propTypes;
110
-
111
- 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 };
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
-
@@ -1,14 +0,0 @@
1
- import { DSDialogSizes } from './utils.js';
2
-
3
- const noop = () => {};
4
-
5
- const defaultProps = {
6
- isOpen: false,
7
- centered: false,
8
- size: DSDialogSizes.DEFAULT,
9
- removeAutoFocus: false,
10
- onClickOutside: noop,
11
- zIndex: 10
12
- };
13
-
14
- export { defaultProps };
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({
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. Cb also triggers when the user press ESC key for accessibility purposes.').defaultValue(() => {})
19
- }, globalAttributesPropTypes), {}, {
20
- size: PropTypes.oneOf(DSDialogSizesArrayValues).description("Dialog's width size.").defaultValue(DSDialogSizes.DEFAULT)
21
- });
22
-
23
- export { propTypes };
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, layout, flexboxes, sizing } 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;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);
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 };