1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | var _typeof = require("@babel/runtime/helpers/typeof");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = void 0;
|
11 |
|
12 | var _vue = require("vue");
|
13 |
|
14 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
15 |
|
16 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
17 |
|
18 | var _transition = _interopRequireWildcard(require("../_util/transition"));
|
19 |
|
20 | var _IDialogPropTypes = _interopRequireDefault(require("./IDialogPropTypes"));
|
21 |
|
22 | var _util = require("./util");
|
23 |
|
24 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
25 |
|
26 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
27 |
|
28 | var sentinelStyle = {
|
29 | width: 0,
|
30 | height: 0,
|
31 | overflow: 'hidden',
|
32 | outline: 'none'
|
33 | };
|
34 |
|
35 | var _default2 = (0, _vue.defineComponent)({
|
36 | name: 'Content',
|
37 | inheritAttrs: false,
|
38 | props: (0, _extends2.default)((0, _extends2.default)({}, (0, _IDialogPropTypes.default)()), {
|
39 | motionName: String,
|
40 | ariaId: String,
|
41 | onVisibleChanged: Function,
|
42 | onMousedown: Function,
|
43 | onMouseup: Function
|
44 | }),
|
45 | setup: function setup(props, _ref) {
|
46 | var expose = _ref.expose,
|
47 | slots = _ref.slots,
|
48 | attrs = _ref.attrs;
|
49 | var sentinelStartRef = (0, _vue.ref)();
|
50 | var sentinelEndRef = (0, _vue.ref)();
|
51 | var dialogRef = (0, _vue.ref)();
|
52 | expose({
|
53 | focus: function focus() {
|
54 | var _a;
|
55 |
|
56 | (_a = sentinelStartRef.value) === null || _a === void 0 ? void 0 : _a.focus();
|
57 | },
|
58 | changeActive: function changeActive(next) {
|
59 | var _document = document,
|
60 | activeElement = _document.activeElement;
|
61 |
|
62 | if (next && activeElement === sentinelEndRef.value) {
|
63 | sentinelStartRef.value.focus();
|
64 | } else if (!next && activeElement === sentinelStartRef.value) {
|
65 | sentinelEndRef.value.focus();
|
66 | }
|
67 | }
|
68 | });
|
69 | var transformOrigin = (0, _vue.ref)();
|
70 | var contentStyleRef = (0, _vue.computed)(function () {
|
71 | var width = props.width,
|
72 | height = props.height;
|
73 | var contentStyle = {};
|
74 |
|
75 | if (width !== undefined) {
|
76 | contentStyle.width = typeof width === 'number' ? "".concat(width, "px") : width;
|
77 | }
|
78 |
|
79 | if (height !== undefined) {
|
80 | contentStyle.height = typeof height === 'number' ? "".concat(height, "px") : height;
|
81 | }
|
82 |
|
83 | if (transformOrigin.value) {
|
84 | contentStyle.transformOrigin = transformOrigin.value;
|
85 | }
|
86 |
|
87 | return contentStyle;
|
88 | });
|
89 |
|
90 | var onPrepare = function onPrepare() {
|
91 | (0, _vue.nextTick)(function () {
|
92 | if (dialogRef.value) {
|
93 | var elementOffset = (0, _util.offset)(dialogRef.value);
|
94 | transformOrigin.value = props.mousePosition ? "".concat(props.mousePosition.x - elementOffset.left, "px ").concat(props.mousePosition.y - elementOffset.top, "px") : '';
|
95 | }
|
96 | });
|
97 | };
|
98 |
|
99 | var onVisibleChanged = function onVisibleChanged(visible) {
|
100 | props.onVisibleChanged(visible);
|
101 | };
|
102 |
|
103 | return function () {
|
104 | var _a, _b, _c, _d;
|
105 |
|
106 | var prefixCls = props.prefixCls,
|
107 | _props$footer = props.footer,
|
108 | footer = _props$footer === void 0 ? (_a = slots.footer) === null || _a === void 0 ? void 0 : _a.call(slots) : _props$footer,
|
109 | _props$title = props.title,
|
110 | title = _props$title === void 0 ? (_b = slots.title) === null || _b === void 0 ? void 0 : _b.call(slots) : _props$title,
|
111 | ariaId = props.ariaId,
|
112 | closable = props.closable,
|
113 | _props$closeIcon = props.closeIcon,
|
114 | closeIcon = _props$closeIcon === void 0 ? (_c = slots.closeIcon) === null || _c === void 0 ? void 0 : _c.call(slots) : _props$closeIcon,
|
115 | onClose = props.onClose,
|
116 | bodyStyle = props.bodyStyle,
|
117 | bodyProps = props.bodyProps,
|
118 | onMousedown = props.onMousedown,
|
119 | onMouseup = props.onMouseup,
|
120 | visible = props.visible,
|
121 | _props$modalRender = props.modalRender,
|
122 | modalRender = _props$modalRender === void 0 ? slots.modalRender : _props$modalRender,
|
123 | destroyOnClose = props.destroyOnClose,
|
124 | motionName = props.motionName;
|
125 | var footerNode;
|
126 |
|
127 | if (footer) {
|
128 | footerNode = (0, _vue.createVNode)("div", {
|
129 | "class": "".concat(prefixCls, "-footer")
|
130 | }, [footer]);
|
131 | }
|
132 |
|
133 | var headerNode;
|
134 |
|
135 | if (title) {
|
136 | headerNode = (0, _vue.createVNode)("div", {
|
137 | "class": "".concat(prefixCls, "-header")
|
138 | }, [(0, _vue.createVNode)("div", {
|
139 | "class": "".concat(prefixCls, "-title"),
|
140 | "id": ariaId
|
141 | }, [title])]);
|
142 | }
|
143 |
|
144 | var closer;
|
145 |
|
146 | if (closable) {
|
147 | closer = (0, _vue.createVNode)("button", {
|
148 | "type": "button",
|
149 | "onClick": onClose,
|
150 | "aria-label": "Close",
|
151 | "class": "".concat(prefixCls, "-close")
|
152 | }, [closeIcon || (0, _vue.createVNode)("span", {
|
153 | "class": "".concat(prefixCls, "-close-x")
|
154 | }, null)]);
|
155 | }
|
156 |
|
157 | var content = (0, _vue.createVNode)("div", {
|
158 | "class": "".concat(prefixCls, "-content")
|
159 | }, [closer, headerNode, (0, _vue.createVNode)("div", (0, _objectSpread2.default)({
|
160 | "class": "".concat(prefixCls, "-body"),
|
161 | "style": bodyStyle
|
162 | }, bodyProps), [(_d = slots.default) === null || _d === void 0 ? void 0 : _d.call(slots)]), footerNode]);
|
163 | var transitionProps = (0, _transition.getTransitionProps)(motionName);
|
164 | return (0, _vue.createVNode)(_transition.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, transitionProps), {}, {
|
165 | "onBeforeEnter": onPrepare,
|
166 | "onAfterEnter": function onAfterEnter() {
|
167 | return onVisibleChanged(true);
|
168 | },
|
169 | "onAfterLeave": function onAfterLeave() {
|
170 | return onVisibleChanged(false);
|
171 | }
|
172 | }), {
|
173 | default: function _default() {
|
174 | return [visible || !destroyOnClose ? (0, _vue.withDirectives)((0, _vue.createVNode)("div", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, attrs), {}, {
|
175 | "ref": dialogRef,
|
176 | "key": "dialog-element",
|
177 | "role": "document",
|
178 | "style": (0, _extends2.default)((0, _extends2.default)({}, contentStyleRef.value), attrs.style),
|
179 | "class": [prefixCls, attrs.class],
|
180 | "onMousedown": onMousedown,
|
181 | "onMouseup": onMouseup
|
182 | }), [(0, _vue.createVNode)("div", {
|
183 | "tabindex": 0,
|
184 | "ref": sentinelStartRef,
|
185 | "style": sentinelStyle,
|
186 | "aria-hidden": "true"
|
187 | }, null), modalRender ? modalRender({
|
188 | originVNode: content
|
189 | }) : content, (0, _vue.createVNode)("div", {
|
190 | "tabindex": 0,
|
191 | "ref": sentinelEndRef,
|
192 | "style": sentinelStyle,
|
193 | "aria-hidden": "true"
|
194 | }, null)]), [[_vue.vShow, visible]]) : null];
|
195 | }
|
196 | });
|
197 | };
|
198 | }
|
199 | });
|
200 |
|
201 | exports.default = _default2; |
\ | No newline at end of file |