@v-c/dialog 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 antdv-community
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,369 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ const require_rolldown_runtime = require("../../_virtual/rolldown_runtime.cjs");
3
+ const require_context = require("../../context.cjs");
4
+ let vue = require("vue");
5
+ let __v_c_util = require("@v-c/util");
6
+ let __v_c_util_dist_pickAttrs = require("@v-c/util/dist/pickAttrs");
7
+ __v_c_util_dist_pickAttrs = require_rolldown_runtime.__toESM(__v_c_util_dist_pickAttrs);
8
+ var sentinelStyle = {
9
+ width: 0,
10
+ height: 0,
11
+ overflow: "hidden",
12
+ outline: "none"
13
+ };
14
+ var entityStyle = { outline: "none" };
15
+ var Panel = /* @__PURE__ */ (0, vue.defineComponent)((props, { expose, slots }) => {
16
+ const { setPanel } = require_context.useGetRefContext();
17
+ const mergedRef = (0, vue.shallowRef)();
18
+ const mergeRefFun = (el) => {
19
+ mergedRef.value = el;
20
+ setPanel(el);
21
+ props?.holderRef?.(el);
22
+ };
23
+ const sentinelStartRef = (0, vue.shallowRef)();
24
+ const sentinelEndRef = (0, vue.shallowRef)();
25
+ expose({
26
+ focus: () => {
27
+ sentinelStartRef.value?.focus?.({ preventScroll: true });
28
+ },
29
+ changeActive: (next) => {
30
+ const { activeElement } = document;
31
+ if (next && activeElement === sentinelEndRef.value) sentinelStartRef.value?.focus?.({ preventScroll: true });
32
+ else if (!next && activeElement === sentinelStartRef.value) sentinelEndRef.value?.focus?.({ preventScroll: true });
33
+ }
34
+ });
35
+ return () => {
36
+ const { width, height, footer, prefixCls, classNames: modalClassNames, styles: modalStyles, title, closable, closeIcon, bodyProps, bodyStyle, ariaId, style, className, forceRender, onClose, onMouseDown, onMouseUp, modalRender, animationVisible } = props;
37
+ const contentStyle = {};
38
+ if (width !== void 0) contentStyle.width = width;
39
+ if (height !== void 0) contentStyle.height = height;
40
+ const footerNode = footer ? (0, vue.createVNode)("div", {
41
+ "class": (0, __v_c_util.classNames)(`${prefixCls}-footer`, modalClassNames?.footer),
42
+ "style": { ...modalStyles?.footer }
43
+ }, [footer]) : null;
44
+ const headerNode = title ? (0, vue.createVNode)("div", {
45
+ "class": (0, __v_c_util.classNames)(`${prefixCls}-header`, modalClassNames?.header),
46
+ "style": { ...modalStyles?.header }
47
+ }, [title]) : null;
48
+ const closableFun = () => {
49
+ if (typeof closable === "object" && closable !== null) return closable;
50
+ if (closable) return { closeIcon: closeIcon ?? (0, vue.createVNode)("span", { "class": `${prefixCls}-close-x` }, null) };
51
+ return {};
52
+ };
53
+ const closableObj = closableFun();
54
+ const ariaProps = (0, __v_c_util_dist_pickAttrs.default)(closableObj, true);
55
+ const closeBtnIsDisabled = typeof closable === "object" && closable?.disabled;
56
+ const closerNode = closable ? (0, vue.createVNode)("button", (0, vue.mergeProps)({
57
+ "type": "button",
58
+ "onClick": onClose,
59
+ "aria-label": "Close"
60
+ }, ariaProps, {
61
+ "class": `${prefixCls}-close`,
62
+ "disabled": closeBtnIsDisabled
63
+ }), [closableObj.closeIcon]) : null;
64
+ const content = (0, vue.createVNode)("div", {
65
+ "class": (0, __v_c_util.classNames)(`${prefixCls}-container`, modalClassNames?.container),
66
+ "style": modalStyles?.container
67
+ }, [
68
+ closerNode,
69
+ headerNode,
70
+ (0, vue.createVNode)("div", (0, vue.mergeProps)({
71
+ "class": (0, __v_c_util.classNames)(`${prefixCls}-body`, modalClassNames?.body),
72
+ "style": {
73
+ ...bodyStyle,
74
+ ...modalStyles?.body
75
+ }
76
+ }, bodyProps), [slots?.default?.()]),
77
+ footerNode
78
+ ]);
79
+ const renderContent = () => {
80
+ if (!animationVisible && forceRender) return null;
81
+ return modalRender ? modalRender(content) : content;
82
+ };
83
+ return (0, vue.createVNode)("div", (0, vue.mergeProps)({
84
+ "key": "dialog-element",
85
+ "role": "dialog"
86
+ }, { "aria-labelledby": title ? ariaId : null }, {
87
+ "aria-modal": "true",
88
+ "ref": mergeRefFun,
89
+ "style": {
90
+ ...style,
91
+ ...contentStyle
92
+ },
93
+ "class": [prefixCls, className],
94
+ "onMousedown": onMouseDown,
95
+ "onMouseup": onMouseUp
96
+ }), [(0, vue.createVNode)("div", {
97
+ "ref": sentinelStartRef,
98
+ "tabindex": 0,
99
+ "style": entityStyle
100
+ }, [renderContent()]), (0, vue.createVNode)("div", {
101
+ "tabindex": 0,
102
+ "ref": sentinelEndRef,
103
+ "style": sentinelStyle
104
+ }, null)]);
105
+ };
106
+ }, {
107
+ props: {
108
+ prefixCls: {
109
+ type: String,
110
+ required: true,
111
+ default: void 0
112
+ },
113
+ ariaId: {
114
+ type: String,
115
+ required: false,
116
+ default: void 0
117
+ },
118
+ onMouseDown: {
119
+ type: Function,
120
+ required: false,
121
+ default: void 0
122
+ },
123
+ onMouseUp: {
124
+ type: Function,
125
+ required: false,
126
+ default: void 0
127
+ },
128
+ holderRef: {
129
+ type: Function,
130
+ required: false,
131
+ default: void 0
132
+ },
133
+ className: {
134
+ type: String,
135
+ required: false,
136
+ default: void 0
137
+ },
138
+ keyboard: {
139
+ type: Boolean,
140
+ required: false,
141
+ default: void 0
142
+ },
143
+ style: {
144
+ type: Object,
145
+ required: false,
146
+ default: void 0
147
+ },
148
+ rootStyle: {
149
+ type: Object,
150
+ required: false,
151
+ default: void 0
152
+ },
153
+ mask: {
154
+ type: Boolean,
155
+ required: false,
156
+ default: void 0
157
+ },
158
+ children: {
159
+ type: [
160
+ Object,
161
+ Function,
162
+ String,
163
+ Number,
164
+ null,
165
+ Boolean,
166
+ Array
167
+ ],
168
+ required: false,
169
+ default: void 0
170
+ },
171
+ afterClose: {
172
+ type: Function,
173
+ required: false,
174
+ default: void 0
175
+ },
176
+ afterOpenChange: {
177
+ type: Function,
178
+ required: false,
179
+ default: void 0
180
+ },
181
+ onClose: {
182
+ type: Function,
183
+ required: false,
184
+ default: void 0
185
+ },
186
+ closable: {
187
+ type: [Boolean, Object],
188
+ required: false,
189
+ default: void 0
190
+ },
191
+ maskClosable: {
192
+ type: Boolean,
193
+ required: false,
194
+ default: void 0
195
+ },
196
+ visible: {
197
+ type: Boolean,
198
+ required: false,
199
+ default: void 0
200
+ },
201
+ destroyOnHidden: {
202
+ type: Boolean,
203
+ required: false,
204
+ default: void 0
205
+ },
206
+ mousePosition: {
207
+ type: [Object, null],
208
+ required: false,
209
+ default: void 0
210
+ },
211
+ title: {
212
+ type: [
213
+ Object,
214
+ Function,
215
+ String,
216
+ Number,
217
+ null,
218
+ Boolean,
219
+ Array
220
+ ],
221
+ required: false,
222
+ default: void 0
223
+ },
224
+ footer: {
225
+ type: [
226
+ Object,
227
+ Function,
228
+ String,
229
+ Number,
230
+ null,
231
+ Boolean,
232
+ Array
233
+ ],
234
+ required: false,
235
+ default: void 0
236
+ },
237
+ transitionName: {
238
+ type: String,
239
+ required: false,
240
+ default: void 0
241
+ },
242
+ maskTransitionName: {
243
+ type: String,
244
+ required: false,
245
+ default: void 0
246
+ },
247
+ animation: {
248
+ required: false,
249
+ default: void 0
250
+ },
251
+ maskAnimation: {
252
+ required: false,
253
+ default: void 0
254
+ },
255
+ wrapStyle: {
256
+ type: Object,
257
+ required: false,
258
+ default: void 0
259
+ },
260
+ bodyStyle: {
261
+ type: Object,
262
+ required: false,
263
+ default: void 0
264
+ },
265
+ maskStyle: {
266
+ type: Object,
267
+ required: false,
268
+ default: void 0
269
+ },
270
+ wrapClassName: {
271
+ type: String,
272
+ required: false,
273
+ default: void 0
274
+ },
275
+ width: {
276
+ type: [String, Number],
277
+ required: false,
278
+ default: void 0
279
+ },
280
+ height: {
281
+ type: [String, Number],
282
+ required: false,
283
+ default: void 0
284
+ },
285
+ zIndex: {
286
+ type: Number,
287
+ required: false,
288
+ default: void 0
289
+ },
290
+ bodyProps: {
291
+ required: false,
292
+ default: void 0
293
+ },
294
+ maskProps: {
295
+ required: false,
296
+ default: void 0
297
+ },
298
+ rootClassName: {
299
+ type: String,
300
+ required: false,
301
+ default: void 0
302
+ },
303
+ classNames: {
304
+ type: Object,
305
+ required: false,
306
+ default: void 0
307
+ },
308
+ styles: {
309
+ type: Object,
310
+ required: false,
311
+ default: void 0
312
+ },
313
+ wrapProps: {
314
+ required: false,
315
+ default: void 0
316
+ },
317
+ getContainer: {
318
+ type: [
319
+ String,
320
+ Function,
321
+ Boolean
322
+ ],
323
+ required: false,
324
+ skipCheck: true,
325
+ default: void 0
326
+ },
327
+ closeIcon: {
328
+ type: [
329
+ Object,
330
+ Function,
331
+ String,
332
+ Number,
333
+ null,
334
+ Boolean,
335
+ Array
336
+ ],
337
+ required: false,
338
+ default: void 0
339
+ },
340
+ modalRender: {
341
+ type: Function,
342
+ required: false,
343
+ default: void 0
344
+ },
345
+ forceRender: {
346
+ type: Boolean,
347
+ required: false,
348
+ default: void 0
349
+ },
350
+ focusTriggerAfterClose: {
351
+ type: Boolean,
352
+ required: false,
353
+ default: void 0
354
+ },
355
+ panelRef: {
356
+ required: false,
357
+ default: void 0
358
+ },
359
+ animationVisible: {
360
+ type: Boolean,
361
+ required: true,
362
+ default: void 0
363
+ }
364
+ },
365
+ name: "Panel",
366
+ inheritAttrs: false
367
+ });
368
+ var Panel_default = Panel;
369
+ exports.default = Panel_default;
@@ -0,0 +1,19 @@
1
+ import { MouseEventHandler } from '@v-c/util/dist/EventInterface';
2
+ import { IDialogPropTypes } from '../../IDialogPropTypes';
3
+ export interface PanelProps extends Omit<IDialogPropTypes, 'getOpenCount'> {
4
+ prefixCls: string;
5
+ ariaId?: string;
6
+ onMouseDown?: (e: MouseEvent) => void;
7
+ onMouseUp?: MouseEventHandler;
8
+ holderRef?: (el: HTMLDivElement) => void;
9
+ }
10
+ export interface ContentRef {
11
+ focus: () => void;
12
+ changeActive: (next: boolean) => void;
13
+ }
14
+ declare const Panel: import('vue').DefineSetupFnComponent<PanelProps & {
15
+ animationVisible: boolean;
16
+ }, {}, {}, PanelProps & {
17
+ animationVisible: boolean;
18
+ } & {}, import('vue').PublicProps>;
19
+ export default Panel;