@elliemae/ds-dialog 2.2.0-alpha.2 → 2.2.0-beta.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/cjs/DSDialog.js +106 -81
- package/cjs/DSDialogDatatestid.js +8 -36
- package/cjs/DSDialogInternalTypes.js +2 -0
- package/cjs/DSDialogTypes.js +2 -27
- package/cjs/defaultProps.js +11 -38
- package/cjs/index.js +24 -47
- package/cjs/propTypes.js +16 -43
- package/cjs/styles.js +143 -148
- package/cjs/utils.js +30 -50
- package/esm/DSDialog.js +86 -44
- package/esm/DSDialogDatatestid.js +4 -7
- package/esm/DSDialogInternalTypes.js +1 -0
- package/esm/DSDialogTypes.js +1 -2
- package/esm/defaultProps.js +6 -8
- package/esm/index.js +4 -28
- package/esm/propTypes.js +12 -14
- package/esm/styles.js +124 -120
- package/esm/utils.js +23 -21
- package/package.json +6 -6
- package/types/DSDialog.d.ts +1 -1
- package/types/DSDialogInternalTypes.d.ts +25 -0
- package/types/DSDialogTypes.d.ts +1 -0
- package/types/styles.d.ts +4 -3
- package/cjs/DSDialog.js.map +0 -7
- package/cjs/DSDialogDatatestid.js.map +0 -7
- package/cjs/DSDialogInternalTypes.d.js +0 -27
- package/cjs/DSDialogInternalTypes.d.js.map +0 -7
- package/cjs/DSDialogTypes.js.map +0 -7
- package/cjs/defaultProps.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/propTypes.js.map +0 -7
- package/cjs/styles.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/esm/DSDialog.js.map +0 -7
- package/esm/DSDialogDatatestid.js.map +0 -7
- package/esm/DSDialogInternalTypes.d.js +0 -2
- package/esm/DSDialogInternalTypes.d.js.map +0 -7
- package/esm/DSDialogTypes.js.map +0 -7
- package/esm/defaultProps.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/propTypes.js.map +0 -7
- package/esm/styles.js.map +0 -7
- package/esm/utils.js.map +0 -7
package/cjs/styles.js
CHANGED
|
@@ -1,150 +1,145 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
var dsSystem = require('@elliemae/ds-system');
|
|
8
|
+
var styledComponents = require('@xstyled/styled-components');
|
|
9
|
+
var utils = require('./utils.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
14
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
15
|
+
|
|
16
|
+
var _templateObject;
|
|
17
|
+
const FixedBody = dsSystem.createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n body {\n overflow: hidden;\n \n ", "\n }\n"])), _ref => {
|
|
18
|
+
let {
|
|
19
|
+
bodyInfo
|
|
20
|
+
} = _ref;
|
|
21
|
+
return bodyInfo.overflow ? "padding-right: calc( ".concat(bodyInfo.padding, " + 15px ) !important;") : "";
|
|
22
|
+
});
|
|
23
|
+
const StyledDialogBackground = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
24
|
+
componentId: "sc-106vqwv-0"
|
|
25
|
+
})(["position:fixed;top:0;bottom:0;width:100%;height:100%;background:rgba(37,41,47,50%);overflow-y:auto;z-index:", ";"], _ref2 => {
|
|
26
|
+
let {
|
|
27
|
+
zIndex
|
|
28
|
+
} = _ref2;
|
|
29
|
+
return zIndex;
|
|
30
|
+
});
|
|
31
|
+
const StyledDialogContainer = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
32
|
+
componentId: "sc-106vqwv-1"
|
|
33
|
+
})(["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 => {
|
|
34
|
+
let {
|
|
35
|
+
centered
|
|
36
|
+
} = _ref3;
|
|
37
|
+
return centered ? 'auto' : '20vh auto auto auto';
|
|
38
|
+
}, _ref4 => {
|
|
39
|
+
let {
|
|
40
|
+
size
|
|
41
|
+
} = _ref4;
|
|
42
|
+
return utils.allSizes[size];
|
|
43
|
+
}, _ref5 => {
|
|
44
|
+
let {
|
|
45
|
+
theme
|
|
46
|
+
} = _ref5;
|
|
47
|
+
return theme.colors.neutral[500];
|
|
48
|
+
}, _ref6 => {
|
|
49
|
+
let {
|
|
50
|
+
theme
|
|
51
|
+
} = _ref6;
|
|
52
|
+
return theme.colors.neutral['000'];
|
|
53
|
+
}, styledComponents.space);
|
|
54
|
+
const DSDialogTitle = /*#__PURE__*/styled__default["default"].h3.withConfig({
|
|
55
|
+
componentId: "sc-106vqwv-2"
|
|
56
|
+
})(["font-size:", ";display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin:0;"], _ref7 => {
|
|
57
|
+
let {
|
|
58
|
+
theme
|
|
59
|
+
} = _ref7;
|
|
60
|
+
return theme.fontSizes.title[700];
|
|
61
|
+
});
|
|
62
|
+
const DSDialogAddon = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
63
|
+
componentId: "sc-106vqwv-3"
|
|
64
|
+
})([""]);
|
|
65
|
+
const DSDialogHeader = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
66
|
+
componentId: "sc-106vqwv-4"
|
|
67
|
+
})(["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 => {
|
|
68
|
+
let {
|
|
69
|
+
theme
|
|
70
|
+
} = _ref8;
|
|
71
|
+
return theme.space.m;
|
|
72
|
+
}, _ref9 => {
|
|
73
|
+
let {
|
|
74
|
+
theme
|
|
75
|
+
} = _ref9;
|
|
76
|
+
return theme.space.xs;
|
|
77
|
+
}, DSDialogTitle, DSDialogAddon, DSDialogAddon, styledComponents.space);
|
|
78
|
+
const DSDialogSeparator = /*#__PURE__*/styled__default["default"].hr.attrs(() => ({
|
|
79
|
+
'aria-hidden': true
|
|
80
|
+
})).withConfig({
|
|
81
|
+
componentId: "sc-106vqwv-5"
|
|
82
|
+
})(["margin:0;border-top:1px solid ", ";"], _ref10 => {
|
|
83
|
+
let {
|
|
84
|
+
theme
|
|
85
|
+
} = _ref10;
|
|
86
|
+
return theme.colors.neutral['080'];
|
|
87
|
+
});
|
|
88
|
+
const DSDialogBody = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
89
|
+
componentId: "sc-106vqwv-6"
|
|
90
|
+
})(["padding:", ";overflow-y:auto;", " ", " ", " ", ""], _ref11 => {
|
|
91
|
+
let {
|
|
92
|
+
theme
|
|
93
|
+
} = _ref11;
|
|
94
|
+
return theme.space.xs;
|
|
95
|
+
}, styledComponents.layout, styledComponents.space, styledComponents.flexboxes, styledComponents.sizing);
|
|
96
|
+
const DSDialogPrimaryMessage = /*#__PURE__*/styled__default["default"].h3.withConfig({
|
|
97
|
+
componentId: "sc-106vqwv-7"
|
|
98
|
+
})(["margin:0;"]);
|
|
99
|
+
const DSDialogSecondaryMessage = /*#__PURE__*/styled__default["default"].p.withConfig({
|
|
100
|
+
componentId: "sc-106vqwv-8"
|
|
101
|
+
})(["margin:0;color:", ";"], _ref12 => {
|
|
102
|
+
let {
|
|
103
|
+
theme
|
|
104
|
+
} = _ref12;
|
|
105
|
+
return theme.colors.neutral[500];
|
|
42
106
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
bottom: 0;
|
|
70
|
-
left: 0;
|
|
71
|
-
right: 0;
|
|
72
|
-
margin: ${({ centered }) => centered ? "auto" : "20vh auto auto auto"};
|
|
73
|
-
width: ${({ size }) => import_utils.allSizes[size]};
|
|
74
|
-
min-width: 300px;
|
|
75
|
-
box-shadow: 0 10px 20px 0 ${({ theme }) => theme.colors.neutral[500]};
|
|
76
|
-
background: ${({ theme }) => theme.colors.neutral["000"]};
|
|
77
|
-
overflow-y: auto;
|
|
78
|
-
${import_styled_components2.space}
|
|
79
|
-
&:focus {
|
|
80
|
-
outline: none;
|
|
81
|
-
}
|
|
82
|
-
`;
|
|
83
|
-
const DSDialogTitle = import_styled_components.default.h3`
|
|
84
|
-
font-size: ${({ theme }) => theme.fontSizes.title[700]};
|
|
85
|
-
display: -webkit-box;
|
|
86
|
-
-webkit-line-clamp: 2;
|
|
87
|
-
-webkit-box-orient: vertical;
|
|
88
|
-
overflow: hidden;
|
|
89
|
-
margin: 0;
|
|
90
|
-
`;
|
|
91
|
-
const DSDialogAddon = import_styled_components.default.div``;
|
|
92
|
-
const DSDialogHeader = import_styled_components.default.div`
|
|
93
|
-
display: grid;
|
|
94
|
-
align-items: center;
|
|
95
|
-
grid-auto-flow: column;
|
|
96
|
-
min-height: ${({ theme }) => theme.space.m};
|
|
97
|
-
padding: 10px ${({ theme }) => theme.space.xs};
|
|
98
|
-
& ${DSDialogTitle} + ${DSDialogAddon} {
|
|
99
|
-
align-self: flex-start;
|
|
100
|
-
justify-self: flex-end;
|
|
101
|
-
}
|
|
102
|
-
& ${DSDialogAddon}:only-child {
|
|
103
|
-
justify-self: flex-end;
|
|
104
|
-
}
|
|
105
|
-
${import_styled_components2.space}
|
|
106
|
-
`;
|
|
107
|
-
const DSDialogSeparator = import_styled_components.default.hr.attrs(() => ({ "aria-hidden": true }))`
|
|
108
|
-
margin: 0;
|
|
109
|
-
border-top: 1px solid ${({ theme }) => theme.colors.neutral["080"]};
|
|
110
|
-
`;
|
|
111
|
-
const DSDialogBody = import_styled_components.default.div`
|
|
112
|
-
padding: ${({ theme }) => theme.space.xs};
|
|
113
|
-
overflow-y: auto;
|
|
114
|
-
${import_styled_components2.layout}
|
|
115
|
-
${import_styled_components2.space}
|
|
116
|
-
${import_styled_components2.flexboxes}
|
|
117
|
-
${import_styled_components2.sizing}
|
|
118
|
-
`;
|
|
119
|
-
const DSDialogPrimaryMessage = import_styled_components.default.h3`
|
|
120
|
-
margin: 0;
|
|
121
|
-
`;
|
|
122
|
-
const DSDialogSecondaryMessage = import_styled_components.default.p`
|
|
123
|
-
margin: 0;
|
|
124
|
-
color: ${({ theme }) => theme.colors.neutral[500]};
|
|
125
|
-
`;
|
|
126
|
-
const DSDialogDefaultLayout = import_styled_components.default.div`
|
|
127
|
-
display: grid;
|
|
128
|
-
grid-auto-flow: row;
|
|
129
|
-
justify-items: center;
|
|
130
|
-
align-items: center;
|
|
131
|
-
grid-gap: ${({ theme }) => theme.space.xxs};
|
|
107
|
+
const DSDialogDefaultLayout = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
108
|
+
componentId: "sc-106vqwv-9"
|
|
109
|
+
})(["display:grid;grid-auto-flow:row;justify-items:center;align-items:center;grid-gap:", ";", "{text-align:center;}"], _ref13 => {
|
|
110
|
+
let {
|
|
111
|
+
theme
|
|
112
|
+
} = _ref13;
|
|
113
|
+
return theme.space.xxs;
|
|
114
|
+
}, DSDialogSecondaryMessage);
|
|
115
|
+
const DSDialogFooter = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
116
|
+
componentId: "sc-106vqwv-10"
|
|
117
|
+
})(["display:grid;grid-auto-flow:column;align-items:center;justify-content:flex-end;grid-gap:", ";min-height:", ";padding:0 ", ";", " ", " ", ""], _ref14 => {
|
|
118
|
+
let {
|
|
119
|
+
theme
|
|
120
|
+
} = _ref14;
|
|
121
|
+
return theme.space.xxs;
|
|
122
|
+
}, _ref15 => {
|
|
123
|
+
let {
|
|
124
|
+
theme
|
|
125
|
+
} = _ref15;
|
|
126
|
+
return theme.space.m;
|
|
127
|
+
}, _ref16 => {
|
|
128
|
+
let {
|
|
129
|
+
theme
|
|
130
|
+
} = _ref16;
|
|
131
|
+
return theme.space.xs;
|
|
132
|
+
}, styledComponents.space, styledComponents.flexboxes, styledComponents.sizing);
|
|
132
133
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
${import_styled_components2.space}
|
|
146
|
-
${import_styled_components2.flexboxes}
|
|
147
|
-
${import_styled_components2.sizing}
|
|
148
|
-
`;
|
|
149
|
-
module.exports = __toCommonJS(styles_exports);
|
|
150
|
-
//# sourceMappingURL=styles.js.map
|
|
134
|
+
exports.DSDialogAddon = DSDialogAddon;
|
|
135
|
+
exports.DSDialogBody = DSDialogBody;
|
|
136
|
+
exports.DSDialogDefaultLayout = DSDialogDefaultLayout;
|
|
137
|
+
exports.DSDialogFooter = DSDialogFooter;
|
|
138
|
+
exports.DSDialogHeader = DSDialogHeader;
|
|
139
|
+
exports.DSDialogPrimaryMessage = DSDialogPrimaryMessage;
|
|
140
|
+
exports.DSDialogSecondaryMessage = DSDialogSecondaryMessage;
|
|
141
|
+
exports.DSDialogSeparator = DSDialogSeparator;
|
|
142
|
+
exports.DSDialogTitle = DSDialogTitle;
|
|
143
|
+
exports.FixedBody = FixedBody;
|
|
144
|
+
exports.StyledDialogBackground = StyledDialogBackground;
|
|
145
|
+
exports.StyledDialogContainer = StyledDialogContainer;
|
package/cjs/utils.js
CHANGED
|
@@ -1,55 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var utils_exports = {};
|
|
29
|
-
__export(utils_exports, {
|
|
30
|
-
DSDialogSizes: () => DSDialogSizes,
|
|
31
|
-
DSDialogSizesArrayValues: () => DSDialogSizesArrayValues,
|
|
32
|
-
allSizes: () => allSizes,
|
|
33
|
-
getSpaceProps: () => getSpaceProps
|
|
34
|
-
});
|
|
35
|
-
var React = __toESM(require("react"));
|
|
36
|
-
const getSpaceProps = (props) => Object.fromEntries(Object.entries(props).filter(([key]) => /^[pm][xytblr]?$/.exec(key)));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
+
|
|
10
|
+
const getSpaceProps = props => Object.fromEntries(Object.entries(props).filter(_ref => {
|
|
11
|
+
let [key] = _ref;
|
|
12
|
+
return /^[pm][xytblr]?$/.exec(key);
|
|
13
|
+
}));
|
|
37
14
|
const DSDialogSizes = {
|
|
38
|
-
DEFAULT:
|
|
39
|
-
SMALL:
|
|
40
|
-
MEDIUM:
|
|
41
|
-
LARGE:
|
|
42
|
-
XLARGE:
|
|
43
|
-
XXLARGE:
|
|
15
|
+
DEFAULT: 'default',
|
|
16
|
+
SMALL: 'small',
|
|
17
|
+
MEDIUM: 'medium',
|
|
18
|
+
LARGE: 'large',
|
|
19
|
+
XLARGE: 'x-large',
|
|
20
|
+
XXLARGE: 'xx-large'
|
|
44
21
|
};
|
|
45
22
|
const DSDialogSizesArrayValues = Object.values(DSDialogSizes);
|
|
46
23
|
const allSizes = {
|
|
47
|
-
default:
|
|
48
|
-
small:
|
|
49
|
-
medium:
|
|
50
|
-
large:
|
|
51
|
-
|
|
52
|
-
|
|
24
|
+
default: '576px',
|
|
25
|
+
small: '320px',
|
|
26
|
+
medium: '656px',
|
|
27
|
+
large: '848px',
|
|
28
|
+
'x-large': '1042px',
|
|
29
|
+
'xx-large': '1440px'
|
|
53
30
|
};
|
|
54
|
-
|
|
55
|
-
|
|
31
|
+
|
|
32
|
+
exports.DSDialogSizes = DSDialogSizes;
|
|
33
|
+
exports.DSDialogSizesArrayValues = DSDialogSizesArrayValues;
|
|
34
|
+
exports.allSizes = allSizes;
|
|
35
|
+
exports.getSpaceProps = getSpaceProps;
|
package/esm/DSDialog.js
CHANGED
|
@@ -1,65 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
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 } from 'react-desc';
|
|
13
|
+
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';
|
|
14
|
+
import { StyledDialogBackground, FixedBody, StyledDialogContainer } from './styles.js';
|
|
15
|
+
import { propTypes } from './propTypes.js';
|
|
16
|
+
import { defaultProps } from './defaultProps.js';
|
|
17
|
+
import { getSpaceProps } from './utils.js';
|
|
18
|
+
import { DSDialogDatatestid } from './DSDialogDatatestid.js';
|
|
19
|
+
import { jsx } from 'react/jsx-runtime';
|
|
20
|
+
|
|
21
|
+
const _excluded = ["children", "isOpen", "onClickOutside", "centered", "size", "removeAutoFocus", "zIndex"];
|
|
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
|
+
|
|
12
30
|
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultProps);
|
|
13
|
-
const [
|
|
31
|
+
const [bodyInfo, setBodyInfo] = useState({
|
|
32
|
+
overflow: false,
|
|
33
|
+
padding: '0px'
|
|
34
|
+
});
|
|
14
35
|
useValidateTypescriptPropTypes(propsWithDefault, propTypes);
|
|
15
|
-
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
children,
|
|
39
|
+
isOpen,
|
|
40
|
+
onClickOutside,
|
|
41
|
+
centered,
|
|
42
|
+
size,
|
|
43
|
+
removeAutoFocus,
|
|
44
|
+
zIndex
|
|
45
|
+
} = propsWithDefault,
|
|
46
|
+
rest = _objectWithoutProperties(propsWithDefault, _excluded);
|
|
47
|
+
|
|
16
48
|
const containerRef = useRef(null);
|
|
17
|
-
const handleOutsideClick = useCallback(
|
|
18
|
-
if (e.target.dataset.portalbg)
|
|
19
|
-
onClickOutside();
|
|
49
|
+
const handleOutsideClick = useCallback(e => {
|
|
50
|
+
if (e.target.dataset.portalbg) onClickOutside();
|
|
20
51
|
}, [onClickOutside]);
|
|
21
|
-
const handleOnKeyDown = useCallback(
|
|
22
|
-
if (e.key ===
|
|
23
|
-
onClickOutside();
|
|
52
|
+
const handleOnKeyDown = useCallback(e => {
|
|
53
|
+
if (e.key === 'Escape') onClickOutside();
|
|
24
54
|
}, [onClickOutside]);
|
|
25
55
|
useEffect(() => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
56
|
+
var _window$getComputedSt;
|
|
57
|
+
|
|
58
|
+
const body = document.getElementsByTagName('body')[0];
|
|
59
|
+
const {
|
|
60
|
+
offsetHeight,
|
|
61
|
+
scrollHeight
|
|
62
|
+
} = body;
|
|
63
|
+
const padding = (_window$getComputedSt = window.getComputedStyle(body, null)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.getPropertyValue('padding-right');
|
|
64
|
+
if (!isOpen) return setBodyInfo({
|
|
65
|
+
overflow: false,
|
|
66
|
+
padding: '0px'
|
|
67
|
+
});
|
|
68
|
+
return setBodyInfo({
|
|
69
|
+
overflow: offsetHeight < scrollHeight,
|
|
70
|
+
padding
|
|
71
|
+
});
|
|
31
72
|
}, [isOpen]);
|
|
32
73
|
useEffect(() => {
|
|
33
|
-
|
|
34
|
-
|
|
74
|
+
var _containerRef$current;
|
|
75
|
+
|
|
76
|
+
if (isOpen && !removeAutoFocus) containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.focus();
|
|
35
77
|
}, [isOpen, removeAutoFocus]);
|
|
78
|
+
|
|
36
79
|
if (isOpen) {
|
|
37
|
-
return ReactDOM.createPortal(
|
|
80
|
+
return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/_jsx(StyledDialogBackground, {
|
|
38
81
|
onClick: handleOutsideClick,
|
|
39
82
|
"data-portalbg": true,
|
|
40
83
|
"data-testid": DSDialogDatatestid.BACKGROUND,
|
|
41
|
-
zIndex
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
}),
|
|
84
|
+
zIndex: zIndex
|
|
85
|
+
}, void 0, _FixedBody || (_FixedBody = /*#__PURE__*/_jsx(FixedBody, {
|
|
86
|
+
bodyInfo: bodyInfo
|
|
87
|
+
})), /*#__PURE__*/jsx(StyledDialogContainer, _objectSpread(_objectSpread({
|
|
45
88
|
role: "dialog",
|
|
46
89
|
"aria-modal": true,
|
|
47
90
|
ref: containerRef,
|
|
48
|
-
tabIndex: !removeAutoFocus ? 0 :
|
|
49
|
-
onKeyDown: handleOnKeyDown
|
|
50
|
-
|
|
51
|
-
size,
|
|
52
|
-
centered,
|
|
53
|
-
"data-testid": DSDialogDatatestid.CONTAINER
|
|
54
|
-
|
|
91
|
+
tabIndex: !removeAutoFocus ? 0 : undefined,
|
|
92
|
+
onKeyDown: handleOnKeyDown
|
|
93
|
+
}, getSpaceProps(rest)), {}, {
|
|
94
|
+
size: size,
|
|
95
|
+
centered: centered,
|
|
96
|
+
"data-testid": DSDialogDatatestid.CONTAINER,
|
|
97
|
+
children: children
|
|
98
|
+
}))), document.getElementsByTagName('body')[0]);
|
|
55
99
|
}
|
|
100
|
+
|
|
56
101
|
return null;
|
|
57
102
|
};
|
|
58
|
-
|
|
103
|
+
|
|
59
104
|
const DSDialogWithSchema = describe(DSDialog);
|
|
60
105
|
DSDialogWithSchema.propTypes = propTypes;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
DSDialogWithSchema
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=DSDialog.js.map
|
|
106
|
+
|
|
107
|
+
export { DSDialog, DSDialogWithSchema };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
const DSDialogDatatestid = {
|
|
3
|
-
CONTAINER:
|
|
4
|
-
BACKGROUND:
|
|
2
|
+
CONTAINER: 'ds-dialog-container',
|
|
3
|
+
BACKGROUND: 'ds-dialog-background'
|
|
5
4
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=DSDialogDatatestid.js.map
|
|
5
|
+
|
|
6
|
+
export { DSDialogDatatestid };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/esm/DSDialogTypes.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=DSDialogTypes.js.map
|
|
1
|
+
|
package/esm/defaultProps.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const noop = () => {
|
|
4
|
-
|
|
1
|
+
import { DSDialogSizes } from './utils.js';
|
|
2
|
+
|
|
3
|
+
const noop = () => {};
|
|
4
|
+
|
|
5
5
|
const defaultProps = {
|
|
6
6
|
isOpen: false,
|
|
7
7
|
centered: false,
|
|
@@ -10,7 +10,5 @@ const defaultProps = {
|
|
|
10
10
|
onClickOutside: noop,
|
|
11
11
|
zIndex: 10
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=defaultProps.js.map
|
|
13
|
+
|
|
14
|
+
export { defaultProps };
|
package/esm/index.js
CHANGED
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
DSDialogBody,
|
|
7
|
-
DSDialogHeader,
|
|
8
|
-
DSDialogFooter,
|
|
9
|
-
DSDialogSeparator,
|
|
10
|
-
DSDialogTitle,
|
|
11
|
-
DSDialogAddon,
|
|
12
|
-
DSDialogDefaultLayout,
|
|
13
|
-
DSDialogPrimaryMessage,
|
|
14
|
-
DSDialogSecondaryMessage
|
|
15
|
-
} from "./styles";
|
|
16
|
-
export {
|
|
17
|
-
DSDialogAddon,
|
|
18
|
-
DSDialogBody,
|
|
19
|
-
DSDialogDefaultLayout,
|
|
20
|
-
DSDialogFooter,
|
|
21
|
-
DSDialogHeader,
|
|
22
|
-
DSDialogPrimaryMessage,
|
|
23
|
-
DSDialogSecondaryMessage,
|
|
24
|
-
DSDialogSeparator,
|
|
25
|
-
DSDialogSizes,
|
|
26
|
-
DSDialogTitle
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { DSDialog, DSDialogWithSchema } from './DSDialog.js';
|
|
2
|
+
export { DSDialogDatatestid } from './DSDialogDatatestid.js';
|
|
3
|
+
export { DSDialogSizes } from './utils.js';
|
|
4
|
+
export { DSDialogAddon, DSDialogBody, DSDialogDefaultLayout, DSDialogFooter, DSDialogHeader, DSDialogPrimaryMessage, DSDialogSecondaryMessage, DSDialogSeparator, DSDialogTitle } from './styles.js';
|
package/esm/propTypes.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
import { DSDialogSizesArrayValues, DSDialogSizes } from './utils.js';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable max-len */
|
|
4
5
|
const propTypes = {
|
|
5
|
-
isOpen: PropTypes.bool.description(
|
|
6
|
-
children: PropTypes.node.description(
|
|
7
|
-
centered: PropTypes.bool.description(
|
|
8
|
-
size: PropTypes.oneOf(DSDialogSizesArrayValues).description(
|
|
9
|
-
removeAutoFocus: PropTypes.bool.description(
|
|
10
|
-
onClickOutside: PropTypes.func.description(
|
|
11
|
-
})
|
|
6
|
+
isOpen: PropTypes.bool.description('Wether the Dialog is open or not.').defaultValue(false),
|
|
7
|
+
children: PropTypes.node.description('Nested components.').isRequired,
|
|
8
|
+
centered: PropTypes.bool.description('Centers the Dialog.').defaultValue(false),
|
|
9
|
+
size: PropTypes.oneOf(DSDialogSizesArrayValues).description("Dialog's width size.").defaultValue(DSDialogSizes.DEFAULT),
|
|
10
|
+
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),
|
|
11
|
+
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(() => {})
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=propTypes.js.map
|
|
13
|
+
|
|
14
|
+
export { propTypes };
|