vue-modaller 1.0.7 → 1.0.8
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/README.md +378 -37
- package/dist/composables/useDeviceDetection.d.ts +6 -0
- package/dist/modal.vue.d.ts +8 -2
- package/dist/style.css +1 -1
- package/dist/types/global.d.ts +2 -1
- package/dist/useModal.d.ts +6 -4
- package/dist/variants/dragable.d.ts +3 -1
- package/dist/vue-modaller.js +259 -216
- package/dist/vue-modaller.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,45 +1,61 @@
|
|
|
1
|
-
# VueModaller
|
|
1
|
+
# VueModaller 🎭
|
|
2
2
|
|
|
3
|
-
A flexible and powerful modal system for Vue 3 applications with TypeScript support
|
|
3
|
+
A flexible and powerful modal system for Vue 3 applications with TypeScript support. Create beautiful modals with draggable functionality, side panels, and smooth animations.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
6
9
|
|
|
7
|
-
✨
|
|
8
|
-
- Standard modals
|
|
9
|
-
- Side panels
|
|
10
|
-
- Panel modals
|
|
11
|
-
- Draggable modals (Instagram-style)
|
|
10
|
+
## ✨ Features
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
12
|
+
🎯 **Multiple Modal Types**
|
|
13
|
+
- **Standard Modal** - Classic centered modals
|
|
14
|
+
- **Side Panel** - Slide-in panels from the side
|
|
15
|
+
- **Panel Modal** - Bottom-aligned panels with rounded top corners
|
|
16
|
+
- **Draggable Modal** - Instagram-style draggable bottom sheets
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
18
|
+
📱 **Responsive Design**
|
|
19
|
+
- **Device Detection** - Automatic mobile/desktop detection
|
|
20
|
+
- **Adaptive Types** - Different modal types for mobile vs desktop
|
|
21
|
+
- **Touch Gestures** - Smooth drag and swipe interactions
|
|
22
|
+
- **Velocity-based** - Smart animations based on gesture speed
|
|
23
|
+
|
|
24
|
+
🎨 **Highly Customizable**
|
|
25
|
+
- **CSS Variables** - Easy theming with CSS custom properties
|
|
26
|
+
- **BEM Methodology** - Clean, maintainable CSS architecture
|
|
27
|
+
- **Custom Animations** - Smooth CSS and JavaScript animations
|
|
28
|
+
- **Handle Styling** - Fully customizable drag handles
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
30
|
+
🚀 **Developer Experience**
|
|
31
|
+
- **TypeScript** - Full TypeScript support with detailed types
|
|
32
|
+
- **Vue 3** - Built for Vue 3 Composition API
|
|
33
|
+
- **Easy Integration** - Simple composable-based API
|
|
34
|
+
- **Global Components** - Auto-registered components
|
|
35
|
+
- **Slot Support** - Dynamic slot content with props
|
|
29
36
|
|
|
30
|
-
## Installation
|
|
37
|
+
## 📦 Installation
|
|
31
38
|
|
|
32
39
|
```bash
|
|
33
40
|
npm install vue-modaller
|
|
34
41
|
```
|
|
35
42
|
|
|
36
|
-
|
|
43
|
+
```bash
|
|
44
|
+
yarn add vue-modaller
|
|
45
|
+
```
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
```bash
|
|
48
|
+
pnpm add vue-modaller
|
|
49
|
+
```
|
|
39
50
|
|
|
40
|
-
|
|
51
|
+
## 🚀 Quick Start
|
|
52
|
+
|
|
53
|
+
### 1. Install the Plugin
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
41
56
|
import { createApp } from 'vue'
|
|
42
57
|
import VueModaller from 'vue-modaller'
|
|
58
|
+
import 'vue-modaller/dist/style.css' // Import styles
|
|
43
59
|
import App from './App.vue'
|
|
44
60
|
|
|
45
61
|
const app = createApp(App)
|
|
@@ -47,7 +63,7 @@ app.use(VueModaller)
|
|
|
47
63
|
app.mount('#app')
|
|
48
64
|
```
|
|
49
65
|
|
|
50
|
-
### 2. Add ModalRoot to
|
|
66
|
+
### 2. Add ModalRoot to Your App
|
|
51
67
|
|
|
52
68
|
```vue
|
|
53
69
|
<template>
|
|
@@ -58,23 +74,24 @@ app.mount('#app')
|
|
|
58
74
|
</template>
|
|
59
75
|
```
|
|
60
76
|
|
|
61
|
-
### 3.
|
|
77
|
+
### 3. Create Your First Modal
|
|
62
78
|
|
|
63
79
|
```vue
|
|
64
|
-
<script setup>
|
|
80
|
+
<script setup lang="ts">
|
|
65
81
|
import { useModal } from 'vue-modaller'
|
|
66
82
|
import MyModalContent from './MyModalContent.vue'
|
|
67
83
|
|
|
68
|
-
const
|
|
84
|
+
const openStandardModal = async () => {
|
|
69
85
|
const result = await useModal(MyModalContent, {
|
|
70
|
-
title: '
|
|
86
|
+
title: 'Welcome!',
|
|
71
87
|
config: {
|
|
72
|
-
type: 'modal',
|
|
88
|
+
type: 'modal',
|
|
89
|
+
width: 500,
|
|
73
90
|
blur: true,
|
|
74
91
|
closeable: true
|
|
75
92
|
},
|
|
76
93
|
props: {
|
|
77
|
-
message: 'Hello from
|
|
94
|
+
message: 'Hello from VueModaller!'
|
|
78
95
|
}
|
|
79
96
|
})
|
|
80
97
|
console.log('Modal result:', result)
|
|
@@ -82,24 +99,348 @@ const openModal = async () => {
|
|
|
82
99
|
</script>
|
|
83
100
|
|
|
84
101
|
<template>
|
|
85
|
-
<button @click="
|
|
102
|
+
<button @click="openStandardModal">
|
|
103
|
+
Open Modal
|
|
104
|
+
</button>
|
|
86
105
|
</template>
|
|
87
106
|
```
|
|
88
107
|
|
|
89
|
-
## Modal Types
|
|
108
|
+
## 🎭 Modal Types
|
|
90
109
|
|
|
91
110
|
### Standard Modal
|
|
92
|
-
|
|
111
|
+
Perfect for confirmations, forms, and general content display.
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
93
114
|
const result = await useModal(Component, {
|
|
94
115
|
config: {
|
|
95
116
|
type: 'modal',
|
|
96
117
|
width: 500,
|
|
118
|
+
height: 400,
|
|
97
119
|
blur: true,
|
|
98
|
-
|
|
120
|
+
corner: '12px'
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Side Panel
|
|
126
|
+
Great for navigation menus, filters, and side content.
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
const result = await useModal(Component, {
|
|
130
|
+
config: {
|
|
131
|
+
type: 'side',
|
|
132
|
+
blur: true,
|
|
133
|
+
margin: 20 // Top margin
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Panel Modal
|
|
139
|
+
Bottom-aligned panels with rounded corners, perfect for mobile interfaces.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const result = await useModal(Component, {
|
|
143
|
+
config: {
|
|
144
|
+
type: 'panel',
|
|
145
|
+
height: '60vh',
|
|
146
|
+
corner: '16px'
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Draggable Modal (Instagram-style)
|
|
152
|
+
Interactive bottom sheets with smooth drag gestures.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
const result = await useModal(Component, {
|
|
156
|
+
config: {
|
|
157
|
+
type: 'draggable',
|
|
158
|
+
draggableConfig: {
|
|
159
|
+
initialPosition: 'half', // 'full' | 'half'
|
|
160
|
+
hideHandle: false,
|
|
161
|
+
shadow: '0 -8px 24px rgba(0,0,0,0.15)',
|
|
162
|
+
handle: {
|
|
163
|
+
color: '#e0e0e0',
|
|
164
|
+
hoverColor: '#bdbdbd',
|
|
165
|
+
activeColor: '#9e9e9e',
|
|
166
|
+
width: '48px',
|
|
167
|
+
height: '4px',
|
|
168
|
+
radius: '2px'
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## 📱 Responsive Modals
|
|
176
|
+
|
|
177
|
+
Automatically adapt modal types based on device:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
const result = await useModal(Component, {
|
|
181
|
+
config: {
|
|
182
|
+
type: 'modal', // Desktop type
|
|
183
|
+
mobileType: 'draggable', // Mobile type
|
|
184
|
+
width: 600,
|
|
185
|
+
draggableConfig: {
|
|
186
|
+
initialPosition: 'half'
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
When viewed on mobile, this will show a draggable modal instead of a standard modal!
|
|
193
|
+
|
|
194
|
+
## ⚙️ Configuration API
|
|
195
|
+
|
|
196
|
+
### ModalConfig Interface
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
interface ModalConfig {
|
|
200
|
+
// Modal type
|
|
201
|
+
type?: 'modal' | 'side' | 'panel' | 'draggable'
|
|
202
|
+
mobileType?: 'modal' | 'side' | 'panel' | 'draggable'
|
|
203
|
+
|
|
204
|
+
// Dimensions
|
|
205
|
+
width?: number
|
|
206
|
+
height?: number | string
|
|
207
|
+
|
|
208
|
+
// Appearance
|
|
209
|
+
blur?: boolean // Backdrop blur effect
|
|
210
|
+
closeable?: boolean // Allow closing by clicking outside
|
|
211
|
+
corner?: string // Border radius
|
|
212
|
+
margin?: number // Top margin (side panels)
|
|
213
|
+
padding?: string // Internal padding
|
|
214
|
+
background?: string // Background color class
|
|
215
|
+
|
|
216
|
+
// Animation
|
|
217
|
+
anim?: boolean // Enable/disable animations
|
|
218
|
+
|
|
219
|
+
// Draggable specific
|
|
220
|
+
draggableConfig?: DraggableConfig
|
|
221
|
+
|
|
222
|
+
// Lifecycle
|
|
223
|
+
onClosed?: () => void // Callback when modal closes
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### DraggableConfig Interface
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
interface DraggableConfig {
|
|
231
|
+
initialPosition?: 'full' | 'half'
|
|
232
|
+
hideHandle?: boolean
|
|
233
|
+
shadow?: string
|
|
234
|
+
handle?: {
|
|
235
|
+
color?: string
|
|
236
|
+
hoverColor?: string
|
|
237
|
+
activeColor?: string
|
|
238
|
+
height?: string
|
|
239
|
+
width?: string
|
|
240
|
+
radius?: string | number
|
|
241
|
+
marginTop?: string | number
|
|
242
|
+
marginBottom?: string | number
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## 🎨 Styling & Theming
|
|
248
|
+
|
|
249
|
+
VueModaller uses CSS custom properties for easy theming:
|
|
250
|
+
|
|
251
|
+
```css
|
|
252
|
+
:root {
|
|
253
|
+
/* Backdrop */
|
|
254
|
+
--modal-backdrop: rgba(0, 0, 0, 0.2);
|
|
255
|
+
|
|
256
|
+
/* Modal */
|
|
257
|
+
--white: #ffffff;
|
|
258
|
+
--modal-border-radius: 0.75rem;
|
|
259
|
+
--modal-padding: 1rem;
|
|
260
|
+
--modal-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
|
261
|
+
--modal-z-index: 9999;
|
|
262
|
+
|
|
263
|
+
/* Draggable Handle */
|
|
264
|
+
--modal-draggable-handle-color: #ccc;
|
|
265
|
+
--modal-draggable-handle-hover-color: #999;
|
|
266
|
+
--modal-draggable-handle-active-color: #666;
|
|
267
|
+
--modal-draggable-handle-height: 5px;
|
|
268
|
+
--modal-draggable-handle-width: 45px;
|
|
269
|
+
--modal-draggable-handle-radius: 4px;
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Custom Themes
|
|
274
|
+
|
|
275
|
+
```css
|
|
276
|
+
/* Dark theme example */
|
|
277
|
+
:root {
|
|
278
|
+
--white: #1a1a1a;
|
|
279
|
+
--modal-backdrop: rgba(0, 0, 0, 0.8);
|
|
280
|
+
--modal-draggable-handle-color: #444;
|
|
281
|
+
--modal-draggable-handle-hover-color: #666;
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## 🔧 Advanced Usage
|
|
286
|
+
|
|
287
|
+
### Dynamic Slot Content
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
const result = await useModal(Component, {
|
|
291
|
+
config: { type: 'modal' },
|
|
292
|
+
slots: {
|
|
293
|
+
header: {
|
|
294
|
+
component: MyHeaderComponent,
|
|
295
|
+
props: { title: 'Custom Header' }
|
|
296
|
+
},
|
|
297
|
+
footer: {
|
|
298
|
+
component: MyFooterComponent,
|
|
299
|
+
props: { showActions: true }
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Multiple Modals
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
// Stack multiple modals
|
|
309
|
+
const modal1 = useModal(Component1, { config: { type: 'modal' } })
|
|
310
|
+
const modal2 = useModal(Component2, { config: { type: 'side' } })
|
|
311
|
+
|
|
312
|
+
// Close all modals
|
|
313
|
+
import { closeAllModal } from 'vue-modaller'
|
|
314
|
+
closeAllModal()
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Modal Results
|
|
318
|
+
|
|
319
|
+
```typescript
|
|
320
|
+
// In your modal component
|
|
321
|
+
<script setup>
|
|
322
|
+
const emit = defineEmits(['close'])
|
|
323
|
+
|
|
324
|
+
const handleSubmit = () => {
|
|
325
|
+
emit('close', { success: true, data: formData })
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const handleCancel = () => {
|
|
329
|
+
emit('close', { success: false })
|
|
330
|
+
}
|
|
331
|
+
</script>
|
|
332
|
+
|
|
333
|
+
// Usage
|
|
334
|
+
const result = await useModal(MyForm, { config: { type: 'modal' } })
|
|
335
|
+
if (result.success) {
|
|
336
|
+
console.log('Form data:', result.data)
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## 📱 Device Detection
|
|
341
|
+
|
|
342
|
+
VueModaller includes a powerful device detection composable:
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { useDeviceDetection } from 'vue-modaller'
|
|
346
|
+
|
|
347
|
+
export default {
|
|
348
|
+
setup() {
|
|
349
|
+
const { isMobile, isTablet, isDesktop, detectDevice } = useDeviceDetection()
|
|
350
|
+
|
|
351
|
+
return {
|
|
352
|
+
isMobile,
|
|
353
|
+
isTablet,
|
|
354
|
+
isDesktop
|
|
355
|
+
}
|
|
99
356
|
}
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## 🎯 Best Practices
|
|
361
|
+
|
|
362
|
+
### Mobile-First Design
|
|
363
|
+
```typescript
|
|
364
|
+
// Recommended pattern for responsive modals
|
|
365
|
+
const openModal = async () => {
|
|
366
|
+
await useModal(Component, {
|
|
367
|
+
config: {
|
|
368
|
+
type: 'modal',
|
|
369
|
+
mobileType: 'draggable', // Better UX on mobile
|
|
370
|
+
width: 600,
|
|
371
|
+
draggableConfig: {
|
|
372
|
+
initialPosition: 'half'
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
})
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Performance Optimization
|
|
380
|
+
```typescript
|
|
381
|
+
// Use markRaw for large components
|
|
382
|
+
import { markRaw } from 'vue'
|
|
383
|
+
const HeavyComponent = markRaw(MyHeavyComponent)
|
|
384
|
+
|
|
385
|
+
await useModal(HeavyComponent, {
|
|
386
|
+
config: { type: 'modal' }
|
|
100
387
|
})
|
|
101
388
|
```
|
|
102
389
|
|
|
390
|
+
## 🔍 Examples
|
|
391
|
+
|
|
392
|
+
Check out our [live examples](https://classyrazy.github.io/vue-modaller/) to see VueModaller in action!
|
|
393
|
+
|
|
394
|
+
## 📄 API Reference
|
|
395
|
+
|
|
396
|
+
### Functions
|
|
397
|
+
|
|
398
|
+
#### `useModal(component, options)`
|
|
399
|
+
Opens a modal and returns a promise.
|
|
400
|
+
|
|
401
|
+
**Parameters:**
|
|
402
|
+
- `component` - Vue component to render
|
|
403
|
+
- `options` - Configuration object
|
|
404
|
+
|
|
405
|
+
**Returns:** `Promise<any>` - Resolves with modal result
|
|
406
|
+
|
|
407
|
+
#### `closeModal(data, index)`
|
|
408
|
+
Programmatically close a specific modal.
|
|
409
|
+
|
|
410
|
+
#### `closeAllModal(data)`
|
|
411
|
+
Close all open modals.
|
|
412
|
+
|
|
413
|
+
### Components
|
|
414
|
+
|
|
415
|
+
#### `<ModalRoot />`
|
|
416
|
+
Global modal container. Must be included in your app.
|
|
417
|
+
|
|
418
|
+
## 🤝 Contributing
|
|
419
|
+
|
|
420
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
421
|
+
|
|
422
|
+
## 📝 License
|
|
423
|
+
|
|
424
|
+
MIT © [Classydev](https://github.com/classyrazy)
|
|
425
|
+
|
|
426
|
+
## 🙋♂️ Support
|
|
427
|
+
|
|
428
|
+
- 📚 [Documentation](https://classyrazy.github.io/vue-modaller/)
|
|
429
|
+
- 🐛 [Report Issues](https://github.com/classyrazy/vue-modaller/issues)
|
|
430
|
+
- 💬 [Discussions](https://github.com/classyrazy/vue-modaller/discussions)
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
<div align="center">
|
|
435
|
+
<p>Made with ❤️ by <a href="https://github.com/classyrazy">Classydev</a></p>
|
|
436
|
+
|
|
437
|
+
<p>
|
|
438
|
+
<a href="https://github.com/classyrazy/vue-modaller/stargazers">⭐ Star on GitHub</a> •
|
|
439
|
+
<a href="https://www.npmjs.com/package/vue-modaller">📦 NPM Package</a>
|
|
440
|
+
</p>
|
|
441
|
+
</div>
|
|
442
|
+
```
|
|
443
|
+
|
|
103
444
|
### Side Panel
|
|
104
445
|
```javascript
|
|
105
446
|
const result = await useModal(Component, {
|
package/dist/modal.vue.d.ts
CHANGED
|
@@ -9,14 +9,20 @@ type __VLS_Slots = {} & {
|
|
|
9
9
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
10
|
config: PropType<modalOptionsType>;
|
|
11
11
|
modalKeyIndex: NumberConstructor;
|
|
12
|
-
|
|
12
|
+
mobileView: BooleanConstructor;
|
|
13
|
+
}>, {
|
|
14
|
+
closeDialog: () => void;
|
|
15
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
16
|
close: (...args: any[]) => void;
|
|
14
17
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
15
18
|
config: PropType<modalOptionsType>;
|
|
16
19
|
modalKeyIndex: NumberConstructor;
|
|
20
|
+
mobileView: BooleanConstructor;
|
|
17
21
|
}>> & Readonly<{
|
|
18
22
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
19
|
-
}>, {
|
|
23
|
+
}>, {
|
|
24
|
+
mobileView: boolean;
|
|
25
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
20
26
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
21
27
|
declare const _default: typeof __VLS_export;
|
|
22
28
|
export default _default;
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--
|
|
1
|
+
:root{--draggable-slidein-y: 0px}@-webkit-keyframes zoomIn{0%{opacity:0;-webkit-transform:translateY(16px) scale(.95);transform:translateY(16px) scale(.95)}to{opacity:1;-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1)}}@keyframes zoomIn{0%{opacity:0;-webkit-transform:translateY(16px) scale(.95);transform:translateY(16px) scale(.95)}to{opacity:1;-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1)}}.zoomIn{-webkit-animation-name:zoomIn;animation-name:zoomIn;animation-duration:.3s;animation-timing-function:ease-out;animation-fill-mode:both}@-webkit-keyframes zoomOut{0%{opacity:1;-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1)}to{opacity:0;-webkit-transform:translateY(16px) scale(.95);transform:translateY(16px) scale(.95)}}@keyframes zoomOut{0%{opacity:1;-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1)}to{opacity:0;-webkit-transform:translateY(16px) scale(.95);transform:translateY(16px) scale(.95)}}.zoomOut{-webkit-animation-name:zoomOut;animation-name:zoomOut;animation-duration:.2s;animation-timing-function:ease-in;animation-fill-mode:both}@-webkit-keyframes slideOutRight{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}to{visibility:hidden;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}}@keyframes slideOutRight{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}to{visibility:hidden;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}}.slideOutRight{-webkit-animation-name:slideOutRight;animation-name:slideOutRight;animation-duration:.2s;animation-timing-function:ease-in;animation-fill-mode:both}@-webkit-keyframes slideInRight{0%{-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0);visibility:visible}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}@keyframes slideInRight{0%{-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0);visibility:visible}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}.slideInRight{-webkit-animation-name:slideInRight;animation-name:slideInRight;animation-duration:.3s;animation-timing-function:ease-out;animation-fill-mode:both}@-webkit-keyframes slideInBottom{0%{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);visibility:visible}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}@keyframes slideInBottom{0%{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);visibility:visible}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}.slideInBottom{-webkit-animation-name:slideInBottom;animation-name:slideInBottom;animation-duration:.3s;animation-timing-function:ease-out;animation-fill-mode:backwards}@-webkit-keyframes slideOutBottom{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}to{visibility:hidden;-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}}@keyframes slideOutBottom{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}to{visibility:hidden;-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}}.slideOutBottom{-webkit-animation-name:slideOutBottom;animation-name:slideOutBottom;animation-duration:.2s;animation-timing-function:ease-in;animation-fill-mode:backwards}@-webkit-keyframes slideInUp{0%{-webkit-transform:translate3d(0,50%,0);transform:translate3d(0,50%,0);visibility:visible}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}@keyframes slideInUp{0%{-webkit-transform:translateY(50%);transform:translateY(50%);visibility:visible}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0)}}@keyframes slideInUp{0%{-webkit-transform:translateY(100%);transform:translateY(100%);visibility:visible}to{-webkit-transform:translateY(50%);transform:translateY(50%)}}.slideInUp{-webkit-animation-name:slideInUp;animation-name:slideInUp;animation-duration:.3s;animation-timing-function:ease-out;animation-fill-mode:both}@-webkit-keyframes slideOutDown{0%{-webkit-transform:translateY(0);transform:translateY(0)}to{visibility:hidden;-webkit-transform:translateY(50%);transform:translateY(50%)}}@keyframes slideOutDown{0%{-webkit-transform:translateY(50%);transform:translateY(50%)}to{visibility:hidden;-webkit-transform:translateY(0%);transform:translateY(0)}}.slideOutDown{-webkit-animation-name:slideOutDown;animation-name:slideOutDown;animation-duration:.2s;animation-timing-function:ease-in;animation-fill-mode:forwards}@-webkit-keyframes slideInBottom{0%{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);opacity:0}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0);opacity:1}}@keyframes slideInBottom{0%{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);opacity:0}to{-webkit-transform:translate3d(0,0,0);transform:translateZ(0);opacity:1}}.slideInBottom{-webkit-animation-name:slideInBottom;animation-name:slideInBottom;animation-duration:.35s;animation-timing-function:cubic-bezier(.25,.46,.45,.94);animation-fill-mode:both}@-webkit-keyframes slideOutBottom{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0);opacity:1}to{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);opacity:0}}@keyframes slideOutBottom{0%{-webkit-transform:translate3d(0,0,0);transform:translateZ(0);opacity:1}to{-webkit-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0);opacity:0}}.slideOutBottom{-webkit-animation-name:slideOutBottom;animation-name:slideOutBottom;animation-duration:.25s;animation-timing-function:cubic-bezier(.55,.055,.675,.19);animation-fill-mode:both}:root{--white: #fff;--blue-500: #3b82f6;--blue-600: #2563eb;--gray-500: #6b7280;--gray-600: #4b5563;--dark: #1f2937;--border-gray: #e0e0e0;--modal-backdrop: rgba(0, 0, 0, .2);--modal-border-radius: .75rem;--modal-padding: 1rem;--modal-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -1px rgba(0, 0, 0, .06);--modal-z-index: 9999;--modal-content-z-index: 99;--modal-draggable-handle-color: #ccc;--modal-draggable-handle-hover-color: #999;--modal-draggable-handle-active-color: #666;--modal-draggable-handle-height: 5px;--modal-draggable-handle-width: 45px;--modal-draggable-handle-radius: 4px;--modal-draggable-handle-margin-top: 10px;--modal-draggable-handle-margin-bottom: 10px}.__modal-wrapper{display:flex;position:fixed;width:100%;height:100%;z-index:var(--modal-z-index);top:0;left:0}.__modal-wrapper--centered{display:flex;justify-content:center;align-items:center}.__modal-wrapper--side{display:grid;justify-content:flex-end}.__modal-backdrop{position:absolute;width:100%;height:100%;background-color:var(--modal-backdrop);cursor:pointer;top:0;right:0;bottom:0;left:0}.__modal-backdrop--blur,.blur-bg{-webkit-backdrop-filter:blur(2.5px);backdrop-filter:blur(2.5px)}.__modal-content{z-index:var(--modal-content-z-index);width:100%;pointer-events:auto;overflow-y:auto;background-color:var(--white)}.__modal-content--standard{max-width:100%;margin-top:5rem;margin-bottom:5rem}.__modal-content--side{height:100%}@media (min-width: 1024px){.__modal-content--side{max-width:30rem}}.__modal-wrapper--panel{display:flex;justify-content:center;align-items:flex-end;top:0;left:0}.__modal-content--panel{width:100%;height:100vh;max-height:100vh;transition:transform .25s cubic-bezier(.25,.1,.25,1);position:absolute;bottom:0}.__modal-wrapper--draggable{display:flex;justify-content:center}.__modal-content--dragable.dragging{transition:none}.__modal-content--draggable{width:100%;height:100vh;max-height:100vh;transition:transform .25s cubic-bezier(.25,.1,.25,1);position:absolute;bottom:0;touch-action:none;overflow:hidden}.__modal-content--draggable.__modal-content--dragging{transition:none}.__modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:.75rem}.__modal-header__title{color:var(--dark);font-weight:600}.__modal-header__title--standard{font-size:1.25rem;line-height:1.75rem}.__modal-header__title--side{font-size:1.5rem;line-height:2rem}.__modal-header__close-btn{cursor:pointer;width:2.5rem;height:2.5rem;display:flex;justify-content:center;align-items:center;border:1px solid var(--border-gray);border-radius:9999px;background-color:transparent;font-size:1.25rem;color:var(--dark)}.__modal-header__close-btn:hover{background-color:#f3f4f6}.__modal-body{padding:var(--modal-padding)}@media (min-width: 768px){.__modal-body{padding:var(--modal-padding)}}.__modal-drag-handle{cursor:grab;background:var(--modal-draggable-handle-color);height:var(--modal-draggable-handle-height);width:var(--modal-draggable-handle-width);border-radius:var(--modal-draggable-handle-radius);margin-top:var(--modal-draggable-handle-margin-top);margin-bottom:var(--modal-draggable-handle-margin-bottom);margin-left:auto;margin-right:auto;transition:background-color .2s}.__modal-drag-handle:hover{background:var(--modal-draggable-handle-hover-color)}.__modal-drag-handle:active{cursor:grabbing;background:var(--modal-draggable-handle-active-color)}.__hidden{display:none}
|
package/dist/types/global.d.ts
CHANGED
package/dist/useModal.d.ts
CHANGED
|
@@ -26,7 +26,8 @@ export declare const modalOptions: Ref<{
|
|
|
26
26
|
draggableConfig?: {
|
|
27
27
|
initialPosition?: "full" | "half" | undefined;
|
|
28
28
|
hideHandle?: boolean | undefined;
|
|
29
|
-
|
|
29
|
+
shadow?: string | undefined;
|
|
30
|
+
handle?: {
|
|
30
31
|
color?: string | undefined;
|
|
31
32
|
height?: string | undefined;
|
|
32
33
|
width?: string | undefined;
|
|
@@ -35,7 +36,7 @@ export declare const modalOptions: Ref<{
|
|
|
35
36
|
marginBottom?: string | number | undefined;
|
|
36
37
|
hoverColor?: string | undefined;
|
|
37
38
|
activeColor?: string | undefined;
|
|
38
|
-
};
|
|
39
|
+
} | undefined;
|
|
39
40
|
} | undefined;
|
|
40
41
|
}[], modalOptionsType[] | {
|
|
41
42
|
open: boolean;
|
|
@@ -55,7 +56,8 @@ export declare const modalOptions: Ref<{
|
|
|
55
56
|
draggableConfig?: {
|
|
56
57
|
initialPosition?: "full" | "half" | undefined;
|
|
57
58
|
hideHandle?: boolean | undefined;
|
|
58
|
-
|
|
59
|
+
shadow?: string | undefined;
|
|
60
|
+
handle?: {
|
|
59
61
|
color?: string | undefined;
|
|
60
62
|
height?: string | undefined;
|
|
61
63
|
width?: string | undefined;
|
|
@@ -64,7 +66,7 @@ export declare const modalOptions: Ref<{
|
|
|
64
66
|
marginBottom?: string | number | undefined;
|
|
65
67
|
hoverColor?: string | undefined;
|
|
66
68
|
activeColor?: string | undefined;
|
|
67
|
-
};
|
|
69
|
+
} | undefined;
|
|
68
70
|
} | undefined;
|
|
69
71
|
}[]>;
|
|
70
72
|
export declare const modalProps: Ref<{
|
|
@@ -9,7 +9,9 @@ export interface DragableState {
|
|
|
9
9
|
closed: number;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
export declare const useDraggable: (config: DraggableConfig | undefined, closeCallback: () => void
|
|
12
|
+
export declare const useDraggable: (config: DraggableConfig | undefined, closeCallback: () => void, modalRef?: {
|
|
13
|
+
value: boolean;
|
|
14
|
+
}) => {
|
|
13
15
|
open: import("vue").Ref<boolean, boolean>;
|
|
14
16
|
translateY: import("vue").Ref<number, number>;
|
|
15
17
|
isDragging: import("vue").Ref<boolean, boolean>;
|
package/dist/vue-modaller.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
1
|
+
import { ref as m, onMounted as I, onUnmounted as pe, defineComponent as Oe, computed as F, openBlock as x, createElementBlock as K, normalizeClass as j, createElementVNode as z, normalizeStyle as Pe, unref as T, createCommentVNode as Q, renderSlot as De, markRaw as Ye, toRaw as ze, createBlock as J, Teleport as Ve, Fragment as He, renderList as $e, createSlots as xe, withCtx as X, resolveDynamicComponent as Le, mergeProps as Be, toDisplayString as Fe } from "vue";
|
|
2
|
+
const We = {
|
|
3
3
|
initialPosition: "half",
|
|
4
4
|
hideHandle: !1,
|
|
5
5
|
handle: {
|
|
@@ -9,288 +9,331 @@ const xe = {
|
|
|
9
9
|
hoverColor: "#999",
|
|
10
10
|
activeColor: "#666"
|
|
11
11
|
}
|
|
12
|
-
},
|
|
13
|
-
const
|
|
14
|
-
let
|
|
15
|
-
const
|
|
16
|
-
|
|
12
|
+
}, qe = (n = We, e, s) => {
|
|
13
|
+
const C = m(!1), a = m(0), t = m(!1), u = m(!1);
|
|
14
|
+
let f = 0, v = 0, o = !1, c = 0, r = { full: 0, half: 0, closed: 0 }, P = 0, D = 0, L = 0, B = 0;
|
|
15
|
+
const V = m(null), A = () => {
|
|
16
|
+
c = window.innerHeight, r = {
|
|
17
17
|
full: 0,
|
|
18
|
-
half:
|
|
19
|
-
closed:
|
|
20
|
-
}, a.value = r.closed,
|
|
21
|
-
},
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
a.value =
|
|
18
|
+
half: c * 0.4,
|
|
19
|
+
closed: c
|
|
20
|
+
}, a.value = r.closed, P = r.closed;
|
|
21
|
+
}, k = (M, h = 300) => new Promise((_) => {
|
|
22
|
+
if (u.value) return _();
|
|
23
|
+
u.value = !0;
|
|
24
|
+
const l = a.value, d = M - l, i = performance.now(), b = (E) => {
|
|
25
|
+
const Y = E - i, U = Math.min(Y / h, 1), G = 1 - Math.pow(1 - U, 3);
|
|
26
|
+
a.value = l + d * G, U < 1 ? requestAnimationFrame(b) : (u.value = !1, P = a.value, _());
|
|
27
27
|
};
|
|
28
|
-
requestAnimationFrame(
|
|
29
|
-
}),
|
|
30
|
-
await
|
|
31
|
-
},
|
|
32
|
-
await
|
|
33
|
-
},
|
|
34
|
-
var
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
var
|
|
41
|
-
if (!
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
requestAnimationFrame(b);
|
|
29
|
+
}), $ = async () => {
|
|
30
|
+
await k(r[n.initialPosition], 400);
|
|
31
|
+
}, p = async () => {
|
|
32
|
+
(s == null ? void 0 : s.value) !== void 0 && (s.value = !1), await k(r.closed, 100), e(), console.log("Panel closed already");
|
|
33
|
+
}, H = (M) => {
|
|
34
|
+
var _, l;
|
|
35
|
+
if (u.value) return;
|
|
36
|
+
t.value = !0, o = !0;
|
|
37
|
+
const h = M;
|
|
38
|
+
f = h instanceof PointerEvent ? h.clientY : ((l = (_ = h.touches) == null ? void 0 : _[0]) == null ? void 0 : l.clientY) || 0, B = f, L = Date.now(), document.addEventListener("pointermove", w), document.addEventListener("pointerup", y), document.addEventListener("touchmove", w, { passive: !1 }), document.addEventListener("touchend", y);
|
|
39
|
+
}, w = (M) => {
|
|
40
|
+
var E, Y;
|
|
41
|
+
if (!o || u.value) return;
|
|
42
|
+
const h = M;
|
|
43
|
+
v = h instanceof PointerEvent ? h.clientY : ((Y = (E = h.touches) == null ? void 0 : E[0]) == null ? void 0 : Y.clientY) || 0;
|
|
44
|
+
const _ = v - f, l = P + _, d = Date.now(), i = v - B, b = d - L;
|
|
45
|
+
D = i / b, B = v, L = d, l < r.full ? a.value = r.full : l > r.closed ? a.value = r.closed : a.value = l;
|
|
46
|
+
}, y = async () => {
|
|
47
|
+
t.value = !1, o = !1, document.removeEventListener("pointermove", w), document.removeEventListener("pointerup", y), document.removeEventListener("touchmove", w), document.removeEventListener("touchend", y);
|
|
48
|
+
const M = a.value, h = Math.abs(M - r.full), _ = Math.abs(M - r.half), l = Math.abs(M - r.closed), d = Math.min(h, _, l);
|
|
49
|
+
let i = r.half;
|
|
50
|
+
if (D > 0.5 ? P === r.full ? i = r.half : i = r.closed : D < -0.5 || d === h ? i = r.full : d === _ ? i = r.half : i = r.closed, i === r.closed) {
|
|
51
|
+
(s == null ? void 0 : s.value) !== void 0 && (s.value = !1);
|
|
52
|
+
const b = Math.abs(D) > 0.5 ? 100 : 150;
|
|
53
|
+
await k(i, b), e();
|
|
54
|
+
} else
|
|
55
|
+
await k(i, 250);
|
|
56
|
+
}, S = () => {
|
|
57
|
+
p();
|
|
53
58
|
};
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
}),
|
|
57
|
-
document.removeEventListener("pointermove",
|
|
59
|
+
return I(() => {
|
|
60
|
+
A();
|
|
61
|
+
}), pe(() => {
|
|
62
|
+
document.removeEventListener("pointermove", w), document.removeEventListener("pointerup", y), document.removeEventListener("touchmove", w), document.removeEventListener("touchend", y);
|
|
58
63
|
}), {
|
|
59
|
-
open:
|
|
64
|
+
open: C,
|
|
60
65
|
translateY: a,
|
|
61
|
-
isDragging:
|
|
62
|
-
isAnimating:
|
|
63
|
-
panel:
|
|
64
|
-
openPanel:
|
|
65
|
-
closePanel:
|
|
66
|
-
startDrag:
|
|
67
|
-
handleBackdropClick:
|
|
68
|
-
initPositions:
|
|
69
|
-
animateToPosition:
|
|
66
|
+
isDragging: t,
|
|
67
|
+
isAnimating: u,
|
|
68
|
+
panel: V,
|
|
69
|
+
openPanel: $,
|
|
70
|
+
closePanel: p,
|
|
71
|
+
startDrag: H,
|
|
72
|
+
handleBackdropClick: S,
|
|
73
|
+
initPositions: A,
|
|
74
|
+
animateToPosition: k
|
|
70
75
|
};
|
|
71
|
-
},
|
|
76
|
+
}, Re = { class: "__modal-body" }, Ue = { class: "__modal-header" }, je = /* @__PURE__ */ Oe({
|
|
72
77
|
__name: "modal",
|
|
73
78
|
props: {
|
|
74
79
|
config: Object,
|
|
75
|
-
modalKeyIndex: Number
|
|
80
|
+
modalKeyIndex: Number,
|
|
81
|
+
mobileView: Boolean
|
|
76
82
|
},
|
|
77
83
|
emits: ["close"],
|
|
78
|
-
setup(
|
|
79
|
-
var
|
|
80
|
-
const s =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}), T = () => {
|
|
86
|
-
var n, t;
|
|
87
|
-
(n = a.config) != null && n.closeable && (console.log("Modal closed from outside", (t = a.config) == null ? void 0 : t.closeable), y());
|
|
88
|
-
}, L = K(() => {
|
|
89
|
-
var n, t, c;
|
|
90
|
-
return ((n = a.config) == null ? void 0 : n.type) == "side" ? "100%" : (t = a.config) != null && t.width ? `${(c = a.config) == null ? void 0 : c.width}px` : "480px";
|
|
91
|
-
}), B = K(() => {
|
|
92
|
-
var n, t, c, v;
|
|
93
|
-
return (n = a.config) != null && n.height && a.config.type !== "draggable" ? typeof ((t = a.config) == null ? void 0 : t.height) == "number" ? `${(c = a.config) == null ? void 0 : c.height}px` : (v = a.config) == null ? void 0 : v.height : "100%";
|
|
84
|
+
setup(n, { expose: e, emit: s }) {
|
|
85
|
+
var y, S, M, h, _;
|
|
86
|
+
const C = s, a = n, t = F(() => a.config ? a.mobileView && a.config.mobileType ? a.config.mobileType : a.config.type : "modal"), u = m(!1), f = () => {
|
|
87
|
+
t.value === "draggable" ? P() : C("close");
|
|
88
|
+
};
|
|
89
|
+
e({
|
|
90
|
+
closeDialog: f
|
|
94
91
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
const { isDragging: v, translateY: o, startDrag: c, openPanel: r, closePanel: P, isAnimating: D } = qe((y = a.config) == null ? void 0 : y.draggableConfig, () => {
|
|
93
|
+
C("close");
|
|
94
|
+
}, u), L = (l) => {
|
|
95
|
+
t.value === "draggable" && c(l);
|
|
96
|
+
}, B = () => {
|
|
97
|
+
var l;
|
|
98
|
+
(l = a.config) != null && l.closeable && f();
|
|
99
|
+
}, V = F(() => {
|
|
100
|
+
var l, d, i;
|
|
101
|
+
return t.value === "side" ? (l = a.config) != null && l.width ? `${a.config.width}px` : "100%" : (d = a.config) != null && d.width && !a.mobileView ? `${(i = a.config) == null ? void 0 : i.width}px` : a.mobileView ? "100%" : "480px";
|
|
102
|
+
}), A = F(() => {
|
|
103
|
+
var l, d, i, b;
|
|
104
|
+
return (l = a.config) != null && l.height && t.value !== "draggable" ? typeof ((d = a.config) == null ? void 0 : d.height) == "number" ? `${(i = a.config) == null ? void 0 : i.height}px` : (b = a.config) == null ? void 0 : b.height : "100%";
|
|
105
|
+
}), k = F(() => {
|
|
106
|
+
var l, d, i, b, E;
|
|
107
|
+
return t.value === "side" ? `${((l = a.config) == null ? void 0 : l.corner) || "10px"} 0 0 ${((d = a.config) == null ? void 0 : d.corner) || "10px"}` : t.value === "panel" || t.value === "draggable" ? `${((i = a.config) == null ? void 0 : i.corner) || "10px"} ${((b = a.config) == null ? void 0 : b.corner) || "10px"} 0 0` : `${((E = a.config) == null ? void 0 : E.corner) || "10px"}`;
|
|
108
|
+
}), $ = (l) => typeof l == "number" ? `${l}px` : typeof l == "string" ? l : "100%";
|
|
109
|
+
let p = m({
|
|
110
|
+
modal: { cls: "is-modal", anim_in: "zoomIn", anim_out: "zoomOut", style: `padding: ${$((S = a.config) == null ? void 0 : S.padding)};` },
|
|
111
|
+
panel: { cls: "is-panel", anim_in: "slideInBottom", anim_out: "slideOutBottom", style: `padding: ${$((M = a.config) == null ? void 0 : M.padding)};` },
|
|
112
|
+
draggable: { cls: "is-draggable", anim_in: "", anim_out: "", style: `padding: ${$((h = a.config) == null ? void 0 : h.padding)};` },
|
|
113
|
+
side: { cls: "is-side", anim_in: "slideInRight", anim_out: "slideOutRight", style: `padding: ${$((_ = a.config) == null ? void 0 : _.padding)};` }
|
|
100
114
|
});
|
|
101
|
-
const
|
|
102
|
-
var
|
|
103
|
-
return (
|
|
104
|
-
}),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
mainModalClass: t
|
|
115
|
+
const H = F(() => {
|
|
116
|
+
var l;
|
|
117
|
+
return (l = a.config) != null && l.anim ? p.value[t.value || "modal"].anim_in : p.value[t.value || "modal"].anim_out;
|
|
118
|
+
}), w = F(() => {
|
|
119
|
+
let l = "__modal-wrapper--centered", d = "__modal-content __modal-content--standard";
|
|
120
|
+
return t.value == "modal" ? (l = "__modal-wrapper--centered", d = "__modal-content __modal-content--standard") : t.value == "side" ? (l = "__modal-wrapper--side", d = "__modal-content __modal-content--side") : t.value == "panel" ? (l = "__modal-wrapper--panel", d = "__modal-content __modal-content--panel") : t.value == "draggable" && (l = "__modal-wrapper--draggable", d = `__modal-content __modal-content--draggable ${v.value ? "__modal-content--dragging" : ""} ${D.value ? "__modal-content--animating" : ""}`), {
|
|
121
|
+
mainModalWrapperClass: l,
|
|
122
|
+
mainModalClass: d
|
|
110
123
|
};
|
|
111
|
-
})
|
|
112
|
-
return
|
|
124
|
+
});
|
|
125
|
+
return I(() => {
|
|
113
126
|
setTimeout(() => {
|
|
114
|
-
|
|
115
|
-
w.value = !0, ((n = a.config) == null ? void 0 : n.type) === "draggable" && (P(), console.log("opened draggable with animation"));
|
|
127
|
+
u.value = !0, t.value === "draggable" && r();
|
|
116
128
|
}, 100);
|
|
117
|
-
}), (
|
|
118
|
-
var
|
|
119
|
-
return (
|
|
129
|
+
}), (l, d) => {
|
|
130
|
+
var i, b, E, Y, U, G, N, ee, ae, le, ne, te, re, ie, oe, ce, de, ge, se, ue, fe, me, ve, he, be, _e, Ce, we, ye, Me, Te, ke, Ee;
|
|
131
|
+
return (i = n.config) != null && i.open ? (x(), K("div", {
|
|
120
132
|
key: 0,
|
|
121
|
-
class:
|
|
133
|
+
class: j(["__modal-wrapper", w.value.mainModalWrapperClass])
|
|
122
134
|
}, [
|
|
123
|
-
|
|
124
|
-
class:
|
|
125
|
-
onClick:
|
|
135
|
+
z("div", {
|
|
136
|
+
class: j(["__modal-backdrop", (b = n.config) != null && b.blur ? "__modal-backdrop--blur" : ""]),
|
|
137
|
+
onClick: B
|
|
126
138
|
}, null, 2),
|
|
127
|
-
|
|
139
|
+
u.value ? (x(), K("div", {
|
|
128
140
|
key: 0,
|
|
129
141
|
ref: "modalElement",
|
|
130
|
-
class:
|
|
131
|
-
onPointerdown:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
class: j([w.value.mainModalClass, (E = n.config) != null && E.background ? `bg-${(Y = n.config) == null ? void 0 : Y.background}` : "__modal-content", H.value]),
|
|
143
|
+
onPointerdown: L,
|
|
144
|
+
style: Pe({
|
|
145
|
+
width: V.value,
|
|
146
|
+
maxHeight: A.value,
|
|
147
|
+
borderRadius: k.value,
|
|
148
|
+
marginTop: `${(U = n.config) != null && U.margin && t.value === "side" ? `${n.config.margin}px` : "0"}`,
|
|
149
|
+
transform: t.value === "draggable" ? `translateY(${T(o)}px)` : "",
|
|
150
|
+
boxShadow: t.value === "draggable" ? (N = (G = n.config) == null ? void 0 : G.draggableConfig) == null ? void 0 : N.shadow : ""
|
|
139
151
|
})
|
|
140
152
|
}, [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"--modal-draggable-handle-
|
|
147
|
-
"--modal-draggable-handle-
|
|
148
|
-
"--modal-draggable-handle-
|
|
149
|
-
"--modal-draggable-handle-
|
|
150
|
-
"--modal-draggable-handle-
|
|
151
|
-
"--modal-draggable-handle-
|
|
152
|
-
"--modal-draggable-handle-margin-
|
|
153
|
+
z("div", Re, [
|
|
154
|
+
t.value === "draggable" ? (x(), K("div", {
|
|
155
|
+
key: 0,
|
|
156
|
+
class: j(["__modal-drag-handle", { __hidden: (ae = (ee = n.config) == null ? void 0 : ee.draggableConfig) == null ? void 0 : ae.hideHandle }]),
|
|
157
|
+
style: Pe({
|
|
158
|
+
"--modal-draggable-handle-color": (te = (ne = (le = n.config) == null ? void 0 : le.draggableConfig) == null ? void 0 : ne.handle) == null ? void 0 : te.color,
|
|
159
|
+
"--modal-draggable-handle-hover-color": (oe = (ie = (re = n.config) == null ? void 0 : re.draggableConfig) == null ? void 0 : ie.handle) == null ? void 0 : oe.hoverColor,
|
|
160
|
+
"--modal-draggable-handle-active-color": (ge = (de = (ce = n.config) == null ? void 0 : ce.draggableConfig) == null ? void 0 : de.handle) == null ? void 0 : ge.activeColor,
|
|
161
|
+
"--modal-draggable-handle-height": ((fe = (ue = (se = n.config) == null ? void 0 : se.draggableConfig) == null ? void 0 : ue.handle) == null ? void 0 : fe.height) || "5px",
|
|
162
|
+
"--modal-draggable-handle-width": ((he = (ve = (me = n.config) == null ? void 0 : me.draggableConfig) == null ? void 0 : ve.handle) == null ? void 0 : he.width) || "45px",
|
|
163
|
+
"--modal-draggable-handle-radius": ((Ce = (_e = (be = n.config) == null ? void 0 : be.draggableConfig) == null ? void 0 : _e.handle) == null ? void 0 : Ce.radius) || "4px",
|
|
164
|
+
"--modal-draggable-handle-margin-top": ((Me = (ye = (we = n.config) == null ? void 0 : we.draggableConfig) == null ? void 0 : ye.handle) == null ? void 0 : Me.marginTop) || "10px",
|
|
165
|
+
"--modal-draggable-handle-margin-bottom": ((Ee = (ke = (Te = n.config) == null ? void 0 : Te.draggableConfig) == null ? void 0 : ke.handle) == null ? void 0 : Ee.marginBottom) || "10px"
|
|
153
166
|
})
|
|
154
|
-
}, null, 6),
|
|
155
|
-
|
|
156
|
-
|
|
167
|
+
}, null, 6)) : Q("", !0),
|
|
168
|
+
z("div", Ue, [
|
|
169
|
+
De(l.$slots, "header")
|
|
157
170
|
]),
|
|
158
|
-
|
|
159
|
-
|
|
171
|
+
z("div", null, [
|
|
172
|
+
De(l.$slots, "default")
|
|
160
173
|
])
|
|
161
174
|
])
|
|
162
|
-
], 38)) :
|
|
163
|
-
], 2)) :
|
|
175
|
+
], 38)) : Q("", !0)
|
|
176
|
+
], 2)) : Q("", !0);
|
|
164
177
|
};
|
|
165
178
|
}
|
|
166
|
-
}),
|
|
179
|
+
}), Ae = m(!1), O = m([]), W = m([]), Se = m(""), g = m([]), q = m([]), R = m([]), Ie = (n, e) => new Promise(
|
|
167
180
|
(s) => {
|
|
168
|
-
var
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
const
|
|
181
|
+
var t, u, f, v, o, c, r, P, D, L, B, V, A, k, $, p, H, w, y;
|
|
182
|
+
Ae.value = !0;
|
|
183
|
+
const C = Ye(ze(n));
|
|
184
|
+
O.value.length > 0 ? O.value.push(C) : O.value = [C], Se.value = (e == null ? void 0 : e.title) || "";
|
|
185
|
+
const a = {
|
|
173
186
|
width: (e == null ? void 0 : e.config.width) || 450,
|
|
174
187
|
background: (e == null ? void 0 : e.config.background) || "white",
|
|
175
188
|
padding: (e == null ? void 0 : e.config.padding) || "20px",
|
|
176
189
|
closeable: (e == null ? void 0 : e.config.closeable) ?? !0,
|
|
177
|
-
blur: (e == null ? void 0 : e.config.blur)
|
|
178
|
-
corner: (e == null ? void 0 : e.config.corner)
|
|
190
|
+
blur: (e == null ? void 0 : e.config.blur) || !0,
|
|
191
|
+
corner: (e == null ? void 0 : e.config.corner) || "10px",
|
|
179
192
|
type: (e == null ? void 0 : e.config.type) || "modal",
|
|
180
193
|
open: !0,
|
|
181
194
|
anim: !0,
|
|
182
195
|
title: (e == null ? void 0 : e.config.title) || "",
|
|
183
196
|
margin: (e == null ? void 0 : e.config.margin) || 0,
|
|
184
197
|
height: (e == null ? void 0 : e.config.height) || 0,
|
|
185
|
-
mobileType:
|
|
198
|
+
mobileType: e == null ? void 0 : e.config.mobileType,
|
|
186
199
|
draggableConfig: {
|
|
187
|
-
|
|
188
|
-
|
|
200
|
+
shadow: ((t = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : t.shadow) || "0 -4px 12px rgba(0, 0, 0, 0.25)",
|
|
201
|
+
initialPosition: ((u = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : u.initialPosition) || "half",
|
|
202
|
+
hideHandle: ((f = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : f.hideHandle) || !1,
|
|
189
203
|
handle: {
|
|
190
|
-
color: ((
|
|
191
|
-
height: ((r = (
|
|
192
|
-
width: ((
|
|
193
|
-
radius: ((
|
|
194
|
-
marginTop: ((
|
|
195
|
-
marginBottom: ((
|
|
196
|
-
hoverColor: ((
|
|
197
|
-
activeColor: ((
|
|
204
|
+
color: ((o = (v = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : v.handle) == null ? void 0 : o.color) || "#ccc",
|
|
205
|
+
height: ((r = (c = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : c.handle) == null ? void 0 : r.height) || "5px",
|
|
206
|
+
width: ((D = (P = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : P.handle) == null ? void 0 : D.width) || "45px",
|
|
207
|
+
radius: ((B = (L = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : L.handle) == null ? void 0 : B.radius) || "4px",
|
|
208
|
+
marginTop: ((A = (V = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : V.handle) == null ? void 0 : A.marginTop) || "10px",
|
|
209
|
+
marginBottom: (($ = (k = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : k.handle) == null ? void 0 : $.marginBottom) || "10px",
|
|
210
|
+
hoverColor: ((H = (p = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : p.handle) == null ? void 0 : H.hoverColor) || "#999",
|
|
211
|
+
activeColor: ((y = (w = e == null ? void 0 : e.config.draggableConfig) == null ? void 0 : w.handle) == null ? void 0 : y.activeColor) || "#666"
|
|
198
212
|
}
|
|
199
213
|
}
|
|
200
214
|
};
|
|
201
|
-
|
|
215
|
+
g.value.push(a), q.value.push({
|
|
202
216
|
...e == null ? void 0 : e.props,
|
|
203
|
-
onClose: (
|
|
204
|
-
s(
|
|
205
|
-
|
|
206
|
-
|
|
217
|
+
onClose: (S) => {
|
|
218
|
+
s(S), Z(
|
|
219
|
+
S,
|
|
220
|
+
g.value.length - 1
|
|
207
221
|
);
|
|
208
222
|
}
|
|
209
|
-
}),
|
|
223
|
+
}), R.value.push((e == null ? void 0 : e.slots) || {}), e != null && e.config.onClosed ? W.value.push(e.config.onClosed) : W.value.push(() => {
|
|
210
224
|
});
|
|
211
225
|
}
|
|
212
|
-
),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
},
|
|
226
|
+
), Z = (n, e) => {
|
|
227
|
+
const { type: s, mobileType: C } = g.value[e];
|
|
228
|
+
return g.value[e] ? g.value[e].anim = !1 : g.value[g.value.length - 1].anim = !1, setTimeout(() => {
|
|
229
|
+
if (e === g.value.length - 1) {
|
|
230
|
+
const a = g.value[g.value.length - 1];
|
|
231
|
+
a ? (a.open = !1, O.value.pop(), g.value.pop(), q.value.pop(), R.value.pop()) : (g.value = [], O.value = [], q.value = [], R.value = []);
|
|
232
|
+
} else
|
|
233
|
+
g.value[e] && (g.value[e].open = !1, O.value.splice(e, 1), g.value.splice(e, 1), q.value.splice(e, 1), R.value.splice(e, 1));
|
|
234
|
+
try {
|
|
235
|
+
W.value[e] && typeof W.value[e] == "function" && (W.value[e](n), W.value.splice(e, 1));
|
|
236
|
+
} catch (a) {
|
|
237
|
+
throw console.log(a), new Error("Error in your onClosed function");
|
|
238
|
+
}
|
|
239
|
+
}, s !== "draggable" && C !== "draggable" ? 500 : 0), n;
|
|
240
|
+
}, Ke = (n) => {
|
|
241
|
+
setTimeout(() => (Ae.value = !1, O.value = [], Se.value = "", g.value = [], q.value = [], R.value = [], n), 300);
|
|
242
|
+
}, Ge = () => {
|
|
243
|
+
const n = m(!1), e = m(!1), s = m(!1);
|
|
244
|
+
return {
|
|
245
|
+
isMobile: n,
|
|
246
|
+
isTablet: e,
|
|
247
|
+
isDesktop: s,
|
|
248
|
+
detectDevice: () => {
|
|
249
|
+
const a = window.innerWidth, t = navigator.userAgent, u = a <= 768, f = a > 768 && a <= 1024, v = a > 1024, c = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(t), r = "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
250
|
+
n.value = u || c && r, e.value = f && !n.value, s.value = v && !r && !c, !s.value && !e.value && (n.value = !0);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}, Je = ["onClick"], Qe = /* @__PURE__ */ Oe({
|
|
226
254
|
__name: "modalRoot",
|
|
227
|
-
setup(
|
|
228
|
-
const e = (
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
255
|
+
setup(n) {
|
|
256
|
+
const e = (u, f) => {
|
|
257
|
+
Z(u, f);
|
|
258
|
+
}, s = m([]), C = (u, f) => {
|
|
259
|
+
const { type: v, mobileType: o } = g.value[f];
|
|
260
|
+
if (v == "draggable" || o && o == "draggable") {
|
|
261
|
+
const c = s.value[f];
|
|
262
|
+
c && c.closeDialog && c.closeDialog();
|
|
263
|
+
} else
|
|
264
|
+
Z(u, f);
|
|
265
|
+
}, { isMobile: a, detectDevice: t } = Ge();
|
|
266
|
+
return I(() => {
|
|
267
|
+
t(), window.addEventListener("resize", t);
|
|
268
|
+
}), pe(() => {
|
|
269
|
+
window.removeEventListener("resize", t);
|
|
270
|
+
}), (u, f) => (x(), K("div", null, [
|
|
271
|
+
(x(), J(Ve, { to: "body" }, [
|
|
272
|
+
(x(!0), K(He, null, $e(T(O), (v, o) => (x(), J(je, {
|
|
273
|
+
onClose: (c) => e(c, o),
|
|
235
274
|
key: o,
|
|
236
|
-
config:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
275
|
+
config: T(g)[o],
|
|
276
|
+
ref_for: !0,
|
|
277
|
+
ref_key: "modalRefs",
|
|
278
|
+
ref: s,
|
|
279
|
+
"modal-key-index": o,
|
|
280
|
+
"mobile-view": T(a)
|
|
281
|
+
}, xe({
|
|
282
|
+
default: X(() => [
|
|
283
|
+
(x(), J(Le(v), Be({
|
|
284
|
+
data: T(g),
|
|
285
|
+
onClose: (c) => C(c, o)
|
|
286
|
+
}, { ref_for: !0 }, T(q)[o], { onCloseAll: T(Ke) }), xe({ _: 2 }, [
|
|
287
|
+
$e(T(R)[o], (c, r) => ({
|
|
288
|
+
name: r,
|
|
289
|
+
fn: X(() => [
|
|
290
|
+
(x(), J(Le(c.component), Be({ ref_for: !0 }, c.props), null, 16))
|
|
248
291
|
])
|
|
249
292
|
}))
|
|
250
293
|
]), 1040, ["data", "onClose", "onCloseAll"]))
|
|
251
294
|
]),
|
|
252
295
|
_: 2
|
|
253
296
|
}, [
|
|
254
|
-
|
|
297
|
+
T(g)[o].title ? {
|
|
255
298
|
name: "header",
|
|
256
|
-
fn:
|
|
257
|
-
|
|
258
|
-
class:
|
|
259
|
-
}, Fe(
|
|
260
|
-
|
|
299
|
+
fn: X(() => [
|
|
300
|
+
z("h3", {
|
|
301
|
+
class: j(["__modal-header__title", T(g)[o].type == "modal" ? "__modal-header__title--standard" : "__modal-header__title--side"])
|
|
302
|
+
}, Fe(T(g)[o].title), 3),
|
|
303
|
+
z("button", {
|
|
261
304
|
type: "button",
|
|
262
305
|
class: "__modal-header__close-btn",
|
|
263
|
-
onClick: (
|
|
264
|
-
}, [...
|
|
265
|
-
|
|
266
|
-
])], 8,
|
|
306
|
+
onClick: (c) => e(c, o)
|
|
307
|
+
}, [...f[0] || (f[0] = [
|
|
308
|
+
z("span", null, "×", -1)
|
|
309
|
+
])], 8, Je)
|
|
267
310
|
]),
|
|
268
311
|
key: "0"
|
|
269
312
|
} : void 0
|
|
270
|
-
]), 1032, ["onClose", "config", "modal-key-index"]))), 128))
|
|
313
|
+
]), 1032, ["onClose", "config", "modal-key-index", "mobile-view"]))), 128))
|
|
271
314
|
]))
|
|
272
315
|
]));
|
|
273
316
|
}
|
|
274
|
-
}),
|
|
275
|
-
install(
|
|
276
|
-
console.log("Installing VueModaller plugin with options:", e),
|
|
317
|
+
}), Xe = {
|
|
318
|
+
install(n, e) {
|
|
319
|
+
console.log("Installing VueModaller plugin with options:", e), n.component("ModalRoot", Qe);
|
|
277
320
|
}
|
|
278
|
-
},
|
|
279
|
-
|
|
321
|
+
}, Ne = (n) => (e) => {
|
|
322
|
+
Xe.install(e, n);
|
|
280
323
|
};
|
|
281
324
|
export {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
325
|
+
Qe as ModalRoot,
|
|
326
|
+
Xe as VueModaller,
|
|
327
|
+
Ke as closeAllModal,
|
|
328
|
+
Z as closeModal,
|
|
329
|
+
O as compRef,
|
|
330
|
+
Ne as createPlugin,
|
|
331
|
+
Xe as default,
|
|
332
|
+
Ae as modalOpen,
|
|
333
|
+
g as modalOptions,
|
|
334
|
+
q as modalProps,
|
|
335
|
+
R as modalSlots,
|
|
336
|
+
Se as modalTitle,
|
|
337
|
+
W as onClosedFunctions,
|
|
338
|
+
Ie as useModal
|
|
296
339
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(g,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],l):(g=typeof globalThis<"u"?globalThis:g||self,l(g.VueModaller={},g.Vue))})(this,function(g,l){"use strict";const Ce={initialPosition:"half",hideHandle:!1,handle:{color:"#ccc",height:"5px",width:"45px",hoverColor:"#999",activeColor:"#666"}},_e=(n=Ce,e)=>{const h=l.ref(!1),a=l.ref(0),w=l.ref(!1),d=l.ref(!1);let s=0,y=0,P=!1,V=0,r={full:0,half:0,closed:0},E=0,L=0,$=0,T=0;const F=l.ref(null),D=()=>{V=window.innerHeight,r={full:0,half:V*.4,closed:V},a.value=r.closed,E=r.closed},v=(m,f=300)=>new Promise(_=>{if(d.value)return _();d.value=!0;const b=a.value,k=m-b,u=performance.now(),z=A=>{const H=A-u,p=Math.min(H/f,1),j=1-Math.pow(1-p,3);a.value=b+k*j,p<1?requestAnimationFrame(z):(d.value=!1,E=a.value,_())};requestAnimationFrame(z)}),Y=async()=>{await v(r[n.initialPosition],400)},B=async()=>{await v(r.closed,300),e&&setTimeout(()=>e(),50)},t=m=>{var _,b;if(d.value)return;w.value=!0,P=!0;const f=m;s=f instanceof PointerEvent?f.clientY:((b=(_=f.touches)==null?void 0:_[0])==null?void 0:b.clientY)||0,T=s,$=Date.now(),document.addEventListener("pointermove",o),document.addEventListener("pointerup",c),document.addEventListener("touchmove",o,{passive:!1}),document.addEventListener("touchend",c)},o=m=>{var A,H;if(!P||d.value)return;const f=m;y=f instanceof PointerEvent?f.clientY:((H=(A=f.touches)==null?void 0:A[0])==null?void 0:H.clientY)||0;const _=y-s,b=E+_,k=Date.now(),u=y-T,z=k-$;L=u/z,T=y,$=k,b<r.full?a.value=r.full:b>r.closed?a.value=r.closed:a.value=b},c=async()=>{w.value=!1,P=!1,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",c),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",c);const m=a.value,f=Math.abs(m-r.full),_=Math.abs(m-r.half),b=Math.abs(m-r.closed),k=Math.min(f,_,b);let u=r.half;L>.5?E===r.full?u=r.half:u=r.closed:L<-.5||k===f?u=r.full:k===_?u=r.half:u=r.closed,u===r.closed?await B():await v(u,250)},C=()=>{B()};return l.onMounted(()=>{D()}),l.onUnmounted(()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",c),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",c)}),{open:h,translateY:a,isDragging:w,isAnimating:d,panel:F,openPanel:Y,closePanel:B,startDrag:t,handleBackdropClick:C,initPositions:D,animateToPosition:v}},ye={class:"__modal-body"},we={class:"__modal-header"},ve=l.defineComponent({__name:"modal",props:{config:Object,modalKeyIndex:Number},emits:["close"],setup(n,{emit:e}){var Y,B;const h=e,a=n,w=()=>{var t;((t=a.config)==null?void 0:t.type)==="draggable"?V():h("close")},{isDragging:d,translateY:s,startDrag:y,openPanel:P,closePanel:V,isAnimating:r}=_e((Y=a.config)==null?void 0:Y.draggableConfig,()=>{h("close")}),E=()=>{var t,o;(t=a.config)!=null&&t.closeable&&(console.log("Modal closed from outside",(o=a.config)==null?void 0:o.closeable),w())},L=l.computed(()=>{var t,o,c;return((t=a.config)==null?void 0:t.type)=="side"?"100%":(o=a.config)!=null&&o.width?`${(c=a.config)==null?void 0:c.width}px`:"480px"}),$=l.computed(()=>{var t,o,c,C;return(t=a.config)!=null&&t.height&&a.config.type!=="draggable"?typeof((o=a.config)==null?void 0:o.height)=="number"?`${(c=a.config)==null?void 0:c.height}px`:(C=a.config)==null?void 0:C.height:"100%"});let T=l.ref({modal:{cls:"is-modal",anim_in:"zoomIn",anim_out:"zoomOut",style:`padding: ${(B=a.config)==null?void 0:B.padding}px;`},panel:{cls:"is-panel",anim_in:"slideInBottom",anim_out:"slideOutBottom",style:"padding: 0"},draggable:{cls:"is-draggable",anim_in:"",anim_out:"",style:"padding: 0"},side:{cls:"is-side",anim_in:"slideInRight",anim_out:"slideOutRight",style:"padding: 0"}});const F=l.computed(()=>{var t,o,c;return(t=a.config)!=null&&t.anim?T.value[((o=a.config)==null?void 0:o.type)||"modal"].anim_in:T.value[((c=a.config)==null?void 0:c.type)||"modal"].anim_out}),D=l.computed(()=>{var c,C,m,f;let t="__modal-wrapper--centered",o="__modal-content __modal-content--standard";return((c=a.config)==null?void 0:c.type)=="modal"?(t="__modal-wrapper--centered",o="__modal-content __modal-content--standard"):((C=a.config)==null?void 0:C.type)=="side"?(t="__modal-wrapper--side",o="__modal-content __modal-content--side"):((m=a.config)==null?void 0:m.type)=="panel"?(t="__modal-wrapper--panel",o="__modal-content __modal-content--panel"):((f=a.config)==null?void 0:f.type)=="draggable"&&(t="__modal-wrapper--draggable",o=`__modal-content __modal-content--draggable ${d.value?"__modal-content--dragging":""} ${r.value?"__modal-content--animating":""}`),{mainModalWrapperClass:t,mainModalClass:o}}),v=l.ref(!1);return l.onMounted(()=>{setTimeout(()=>{var t;v.value=!0,((t=a.config)==null?void 0:t.type)==="draggable"&&(P(),console.log("opened draggable with animation"))},100)}),(t,o)=>{var c,C,m,f,_,b,k,u,z,A,H,p,j,Q,X,Z,N,x,I,ee,le,ae,ne,te,oe,re,ce,de,ie,ge,fe,se,me,ue,he,be;return(c=n.config)!=null&&c.open?(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["__modal-wrapper",D.value.mainModalWrapperClass])},[l.createElementVNode("div",{class:l.normalizeClass(["__modal-backdrop",(C=n.config)!=null&&C.blur?"__modal-backdrop--blur":""]),onClick:E},null,2),v.value?(l.openBlock(),l.createElementBlock("div",{key:0,ref:"modalElement",class:l.normalizeClass([D.value.mainModalClass,(m=n.config)!=null&&m.background?`bg-${(f=n.config)==null?void 0:f.background}`:"__modal-content",F.value]),onPointerdown:o[0]||(o[0]=(...Te)=>l.unref(y)&&l.unref(y)(...Te)),style:l.normalizeStyle({width:L.value,maxHeight:$.value,borderRadius:`${((_=n.config)==null?void 0:_.type)!=="side"&&((b=n.config)==null?void 0:b.type)!=="panel"&&((k=n.config)==null?void 0:k.type)!=="draggable"?((u=n.config)==null?void 0:u.corner)??"0.75rem":"0"}`,marginTop:`${(z=n.config)!=null&&z.margin&&n.config.type=="side"?`${n.config.margin}px`:"0"}`,transform:`translateY(${l.unref(s)}px)`})},[l.createElementVNode("div",ye,[l.createElementVNode("div",{class:l.normalizeClass(["__modal-drag-handle",{__hidden:((H=(A=n.config)==null?void 0:A.draggableConfig)==null?void 0:H.hideHandle)||((p=n.config)==null?void 0:p.type)!=="draggable"}]),style:l.normalizeStyle({"--modal-draggable-handle-color":(X=(Q=(j=n.config)==null?void 0:j.draggableConfig)==null?void 0:Q.handle)==null?void 0:X.color,"--modal-draggable-handle-hover-color":(x=(N=(Z=n.config)==null?void 0:Z.draggableConfig)==null?void 0:N.handle)==null?void 0:x.hoverColor,"--modal-draggable-handle-active-color":(le=(ee=(I=n.config)==null?void 0:I.draggableConfig)==null?void 0:ee.handle)==null?void 0:le.activeColor,"--modal-draggable-handle-height":((te=(ne=(ae=n.config)==null?void 0:ae.draggableConfig)==null?void 0:ne.handle)==null?void 0:te.height)||"5px","--modal-draggable-handle-width":((ce=(re=(oe=n.config)==null?void 0:oe.draggableConfig)==null?void 0:re.handle)==null?void 0:ce.width)||"45px","--modal-draggable-handle-radius":((ge=(ie=(de=n.config)==null?void 0:de.draggableConfig)==null?void 0:ie.handle)==null?void 0:ge.radius)||"4px","--modal-draggable-handle-margin-top":((me=(se=(fe=n.config)==null?void 0:fe.draggableConfig)==null?void 0:se.handle)==null?void 0:me.marginTop)||"10px","--modal-draggable-handle-margin-bottom":((be=(he=(ue=n.config)==null?void 0:ue.draggableConfig)==null?void 0:he.handle)==null?void 0:be.marginBottom)||"10px"})},null,6),l.createElementVNode("div",we,[l.renderSlot(t.$slots,"header")]),l.createElementVNode("div",null,[l.renderSlot(t.$slots,"default")])])],38)):l.createCommentVNode("",!0)],2)):l.createCommentVNode("",!0)}}}),q=l.ref(!1),M=l.ref([]),O=l.ref([]),U=l.ref(""),i=l.ref([]),R=l.ref([]),S=l.ref([]),ke=(n,e)=>new Promise(h=>{var d,s,y,P,V,r,E,L,$,T,F,D,v,Y,B,t,o,c;q.value=!0;const a=l.markRaw(l.toRaw(n));M.value.length>0?M.value.push(a):M.value=[a],U.value=(e==null?void 0:e.title)||"";const w={width:(e==null?void 0:e.config.width)||450,background:(e==null?void 0:e.config.background)||"white",padding:(e==null?void 0:e.config.padding)||"20px",closeable:(e==null?void 0:e.config.closeable)??!0,blur:(e==null?void 0:e.config.blur)??!0,corner:(e==null?void 0:e.config.corner)??"10px",type:(e==null?void 0:e.config.type)||"modal",open:!0,anim:!0,title:(e==null?void 0:e.config.title)||"",margin:(e==null?void 0:e.config.margin)||0,height:(e==null?void 0:e.config.height)||0,mobileType:(e==null?void 0:e.config.mobileType)||"modal",draggableConfig:{initialPosition:((d=e==null?void 0:e.config.draggableConfig)==null?void 0:d.initialPosition)||"half",hideHandle:((s=e==null?void 0:e.config.draggableConfig)==null?void 0:s.hideHandle)||!1,handle:{color:((P=(y=e==null?void 0:e.config.draggableConfig)==null?void 0:y.handle)==null?void 0:P.color)||"#ccc",height:((r=(V=e==null?void 0:e.config.draggableConfig)==null?void 0:V.handle)==null?void 0:r.height)||"5px",width:((L=(E=e==null?void 0:e.config.draggableConfig)==null?void 0:E.handle)==null?void 0:L.width)||"45px",radius:((T=($=e==null?void 0:e.config.draggableConfig)==null?void 0:$.handle)==null?void 0:T.radius)||"4px",marginTop:((D=(F=e==null?void 0:e.config.draggableConfig)==null?void 0:F.handle)==null?void 0:D.marginTop)||"10px",marginBottom:((Y=(v=e==null?void 0:e.config.draggableConfig)==null?void 0:v.handle)==null?void 0:Y.marginBottom)||"10px",hoverColor:((t=(B=e==null?void 0:e.config.draggableConfig)==null?void 0:B.handle)==null?void 0:t.hoverColor)||"#999",activeColor:((c=(o=e==null?void 0:e.config.draggableConfig)==null?void 0:o.handle)==null?void 0:c.activeColor)||"#666"}}};console.log("configToBeUsed in useModal:",w),i.value.push(w),R.value.push({...e==null?void 0:e.props,onClose:C=>{h(C),W(C,i.value.length-1)}}),S.value.push((e==null?void 0:e.slots)||{}),e!=null&&e.config.onClosed?O.value.push(e.config.onClosed):O.value.push(()=>{})}),W=(n,e)=>(i.value[e]?i.value[e].anim=!1:i.value[i.value.length-1].anim=!1,setTimeout(()=>{if(e===i.value.length-1){const h=i.value[i.value.length-1];h?(h.open=!1,M.value.pop(),i.value.pop(),R.value.pop(),S.value.pop()):(i.value=[],M.value=[],R.value=[],S.value=[])}else i.value[e]&&(i.value[e].open=!1,M.value.splice(e,1),i.value.splice(e,1),R.value.splice(e,1),S.value.splice(e,1));try{O.value[e]&&typeof O.value[e]=="function"&&(O.value[e](n),O.value.splice(e,1))}catch(h){throw console.log(h),new Error("Error in your onClosed function")}},500),n),G=n=>{setTimeout(()=>(q.value=!1,M.value=[],U.value="",i.value=[],R.value=[],S.value=[],n),300)},Me=["onClick"],J=l.defineComponent({__name:"modalRoot",setup(n){const e=(h,a)=>{W(h,a)};return(h,a)=>(l.openBlock(),l.createElementBlock("div",null,[(l.openBlock(),l.createBlock(l.Teleport,{to:"body"},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(M),(w,d)=>(l.openBlock(),l.createBlock(ve,{onClose:s=>e(s,d),key:d,config:l.unref(i)[d],"modal-key-index":d},l.createSlots({default:l.withCtx(()=>[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(w),l.mergeProps({data:l.unref(i),onClose:s=>l.unref(W)(s,d)},{ref_for:!0},l.unref(R)[d],{onCloseAll:l.unref(G)}),l.createSlots({_:2},[l.renderList(l.unref(S)[d],(s,y)=>({name:y,fn:l.withCtx(()=>[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(l.markRaw(l.toRaw(s.component))),l.mergeProps({ref_for:!0},s.props),null,16))])}))]),1040,["data","onClose","onCloseAll"]))]),_:2},[l.unref(i)[d].title?{name:"header",fn:l.withCtx(()=>[l.createElementVNode("h3",{class:l.normalizeClass(["__modal-header__title",l.unref(i)[d].type=="modal"?"__modal-header__title--standard":"__modal-header__title--side"])},l.toDisplayString(l.unref(i)[d].title),3),l.createElementVNode("button",{type:"button",class:"__modal-header__close-btn",onClick:s=>e(s,d)},[...a[0]||(a[0]=[l.createElementVNode("span",null,"×",-1)])],8,Me)]),key:"0"}:void 0]),1032,["onClose","config","modal-key-index"]))),128))]))]))}}),K={install(n,e){console.log("Installing VueModaller plugin with options:",e),n.component("ModalRoot",J)}},Ee=n=>e=>{K.install(e,n)};g.ModalRoot=J,g.VueModaller=K,g.closeAllModal=G,g.closeModal=W,g.compRef=M,g.createPlugin=Ee,g.default=K,g.modalOpen=q,g.modalOptions=i,g.modalProps=R,g.modalSlots=S,g.modalTitle=U,g.onClosedFunctions=O,g.useModal=ke,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(m,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],l):(m=typeof globalThis<"u"?globalThis:m||self,l(m.VueModaller={},m.Vue))})(this,function(m,l){"use strict";const ke={initialPosition:"half",hideHandle:!1,handle:{color:"#ccc",height:"5px",width:"45px",hoverColor:"#999",activeColor:"#666"}},Me=(t=ke,e,f)=>{const w=l.ref(!1),a=l.ref(0),o=l.ref(!1),u=l.ref(!1);let h=0,b=0,i=!1,d=0,r={full:0,half:0,closed:0},P=0,D=0,$=0,V=0;const F=l.ref(null),A=()=>{d=window.innerHeight,r={full:0,half:d*.4,closed:d},a.value=r.closed,P=r.closed},E=(M,v=300)=>new Promise(_=>{if(u.value)return _();u.value=!0;const n=a.value,s=M-n,c=performance.now(),C=T=>{const H=T-c,W=Math.min(H/v,1),q=1-Math.pow(1-W,3);a.value=n+s*q,W<1?requestAnimationFrame(C):(u.value=!1,P=a.value,_())};requestAnimationFrame(C)}),p=async()=>{await E(r[t.initialPosition],400)},S=async()=>{(f==null?void 0:f.value)!==void 0&&(f.value=!1),await E(r.closed,100),e(),console.log("Panel closed already")},x=M=>{var _,n;if(u.value)return;o.value=!0,i=!0;const v=M;h=v instanceof PointerEvent?v.clientY:((n=(_=v.touches)==null?void 0:_[0])==null?void 0:n.clientY)||0,V=h,$=Date.now(),document.addEventListener("pointermove",y),document.addEventListener("pointerup",k),document.addEventListener("touchmove",y,{passive:!1}),document.addEventListener("touchend",k)},y=M=>{var T,H;if(!i||u.value)return;const v=M;b=v instanceof PointerEvent?v.clientY:((H=(T=v.touches)==null?void 0:T[0])==null?void 0:H.clientY)||0;const _=b-h,n=P+_,s=Date.now(),c=b-V,C=s-$;D=c/C,V=b,$=s,n<r.full?a.value=r.full:n>r.closed?a.value=r.closed:a.value=n},k=async()=>{o.value=!1,i=!1,document.removeEventListener("pointermove",y),document.removeEventListener("pointerup",k),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",k);const M=a.value,v=Math.abs(M-r.full),_=Math.abs(M-r.half),n=Math.abs(M-r.closed),s=Math.min(v,_,n);let c=r.half;if(D>.5?P===r.full?c=r.half:c=r.closed:D<-.5||s===v?c=r.full:s===_?c=r.half:c=r.closed,c===r.closed){(f==null?void 0:f.value)!==void 0&&(f.value=!1);const C=Math.abs(D)>.5?100:150;await E(c,C),e()}else await E(c,250)},Y=()=>{S()};return l.onMounted(()=>{A()}),l.onUnmounted(()=>{document.removeEventListener("pointermove",y),document.removeEventListener("pointerup",k),document.removeEventListener("touchmove",y),document.removeEventListener("touchend",k)}),{open:w,translateY:a,isDragging:o,isAnimating:u,panel:F,openPanel:p,closePanel:S,startDrag:x,handleBackdropClick:Y,initPositions:A,animateToPosition:E}},Ee={class:"__modal-body"},Te={class:"__modal-header"},Be=l.defineComponent({__name:"modal",props:{config:Object,modalKeyIndex:Number,mobileView:Boolean},emits:["close"],setup(t,{expose:e,emit:f}){var k,Y,M,v,_;const w=f,a=t,o=l.computed(()=>a.config?a.mobileView&&a.config.mobileType?a.config.mobileType:a.config.type:"modal"),u=l.ref(!1),h=()=>{o.value==="draggable"?P():w("close")};e({closeDialog:h});const{isDragging:b,translateY:i,startDrag:d,openPanel:r,closePanel:P,isAnimating:D}=Me((k=a.config)==null?void 0:k.draggableConfig,()=>{w("close")},u),$=n=>{o.value==="draggable"&&d(n)},V=()=>{var n;(n=a.config)!=null&&n.closeable&&h()},F=l.computed(()=>{var n,s,c;return o.value==="side"?(n=a.config)!=null&&n.width?`${a.config.width}px`:"100%":(s=a.config)!=null&&s.width&&!a.mobileView?`${(c=a.config)==null?void 0:c.width}px`:a.mobileView?"100%":"480px"}),A=l.computed(()=>{var n,s,c,C;return(n=a.config)!=null&&n.height&&o.value!=="draggable"?typeof((s=a.config)==null?void 0:s.height)=="number"?`${(c=a.config)==null?void 0:c.height}px`:(C=a.config)==null?void 0:C.height:"100%"}),E=l.computed(()=>{var n,s,c,C,T;return o.value==="side"?`${((n=a.config)==null?void 0:n.corner)||"10px"} 0 0 ${((s=a.config)==null?void 0:s.corner)||"10px"}`:o.value==="panel"||o.value==="draggable"?`${((c=a.config)==null?void 0:c.corner)||"10px"} ${((C=a.config)==null?void 0:C.corner)||"10px"} 0 0`:`${((T=a.config)==null?void 0:T.corner)||"10px"}`}),p=n=>typeof n=="number"?`${n}px`:typeof n=="string"?n:"100%";let S=l.ref({modal:{cls:"is-modal",anim_in:"zoomIn",anim_out:"zoomOut",style:`padding: ${p((Y=a.config)==null?void 0:Y.padding)};`},panel:{cls:"is-panel",anim_in:"slideInBottom",anim_out:"slideOutBottom",style:`padding: ${p((M=a.config)==null?void 0:M.padding)};`},draggable:{cls:"is-draggable",anim_in:"",anim_out:"",style:`padding: ${p((v=a.config)==null?void 0:v.padding)};`},side:{cls:"is-side",anim_in:"slideInRight",anim_out:"slideOutRight",style:`padding: ${p((_=a.config)==null?void 0:_.padding)};`}});const x=l.computed(()=>{var n;return(n=a.config)!=null&&n.anim?S.value[o.value||"modal"].anim_in:S.value[o.value||"modal"].anim_out}),y=l.computed(()=>{let n="__modal-wrapper--centered",s="__modal-content __modal-content--standard";return o.value=="modal"?(n="__modal-wrapper--centered",s="__modal-content __modal-content--standard"):o.value=="side"?(n="__modal-wrapper--side",s="__modal-content __modal-content--side"):o.value=="panel"?(n="__modal-wrapper--panel",s="__modal-content __modal-content--panel"):o.value=="draggable"&&(n="__modal-wrapper--draggable",s=`__modal-content __modal-content--draggable ${b.value?"__modal-content--dragging":""} ${D.value?"__modal-content--animating":""}`),{mainModalWrapperClass:n,mainModalClass:s}});return l.onMounted(()=>{setTimeout(()=>{u.value=!0,o.value==="draggable"&&r()},100)}),(n,s)=>{var c,C,T,H,W,q,Q,X,Z,N,I,ee,le,ae,ne,te,oe,re,ce,ie,de,ge,se,fe,me,ue,he,be,ve,Ce,_e,we,ye;return(c=t.config)!=null&&c.open?(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["__modal-wrapper",y.value.mainModalWrapperClass])},[l.createElementVNode("div",{class:l.normalizeClass(["__modal-backdrop",(C=t.config)!=null&&C.blur?"__modal-backdrop--blur":""]),onClick:V},null,2),u.value?(l.openBlock(),l.createElementBlock("div",{key:0,ref:"modalElement",class:l.normalizeClass([y.value.mainModalClass,(T=t.config)!=null&&T.background?`bg-${(H=t.config)==null?void 0:H.background}`:"__modal-content",x.value]),onPointerdown:$,style:l.normalizeStyle({width:F.value,maxHeight:A.value,borderRadius:E.value,marginTop:`${(W=t.config)!=null&&W.margin&&o.value==="side"?`${t.config.margin}px`:"0"}`,transform:o.value==="draggable"?`translateY(${l.unref(i)}px)`:"",boxShadow:o.value==="draggable"?(Q=(q=t.config)==null?void 0:q.draggableConfig)==null?void 0:Q.shadow:""})},[l.createElementVNode("div",Ee,[o.value==="draggable"?(l.openBlock(),l.createElementBlock("div",{key:0,class:l.normalizeClass(["__modal-drag-handle",{__hidden:(Z=(X=t.config)==null?void 0:X.draggableConfig)==null?void 0:Z.hideHandle}]),style:l.normalizeStyle({"--modal-draggable-handle-color":(ee=(I=(N=t.config)==null?void 0:N.draggableConfig)==null?void 0:I.handle)==null?void 0:ee.color,"--modal-draggable-handle-hover-color":(ne=(ae=(le=t.config)==null?void 0:le.draggableConfig)==null?void 0:ae.handle)==null?void 0:ne.hoverColor,"--modal-draggable-handle-active-color":(re=(oe=(te=t.config)==null?void 0:te.draggableConfig)==null?void 0:oe.handle)==null?void 0:re.activeColor,"--modal-draggable-handle-height":((de=(ie=(ce=t.config)==null?void 0:ce.draggableConfig)==null?void 0:ie.handle)==null?void 0:de.height)||"5px","--modal-draggable-handle-width":((fe=(se=(ge=t.config)==null?void 0:ge.draggableConfig)==null?void 0:se.handle)==null?void 0:fe.width)||"45px","--modal-draggable-handle-radius":((he=(ue=(me=t.config)==null?void 0:me.draggableConfig)==null?void 0:ue.handle)==null?void 0:he.radius)||"4px","--modal-draggable-handle-margin-top":((Ce=(ve=(be=t.config)==null?void 0:be.draggableConfig)==null?void 0:ve.handle)==null?void 0:Ce.marginTop)||"10px","--modal-draggable-handle-margin-bottom":((ye=(we=(_e=t.config)==null?void 0:_e.draggableConfig)==null?void 0:we.handle)==null?void 0:ye.marginBottom)||"10px"})},null,6)):l.createCommentVNode("",!0),l.createElementVNode("div",Te,[l.renderSlot(n.$slots,"header")]),l.createElementVNode("div",null,[l.renderSlot(n.$slots,"default")])])],38)):l.createCommentVNode("",!0)],2)):l.createCommentVNode("",!0)}}}),R=l.ref(!1),B=l.ref([]),L=l.ref([]),U=l.ref(""),g=l.ref([]),O=l.ref([]),z=l.ref([]),Pe=(t,e)=>new Promise(f=>{var o,u,h,b,i,d,r,P,D,$,V,F,A,E,p,S,x,y,k;R.value=!0;const w=l.markRaw(l.toRaw(t));B.value.length>0?B.value.push(w):B.value=[w],U.value=(e==null?void 0:e.title)||"";const a={width:(e==null?void 0:e.config.width)||450,background:(e==null?void 0:e.config.background)||"white",padding:(e==null?void 0:e.config.padding)||"20px",closeable:(e==null?void 0:e.config.closeable)??!0,blur:(e==null?void 0:e.config.blur)||!0,corner:(e==null?void 0:e.config.corner)||"10px",type:(e==null?void 0:e.config.type)||"modal",open:!0,anim:!0,title:(e==null?void 0:e.config.title)||"",margin:(e==null?void 0:e.config.margin)||0,height:(e==null?void 0:e.config.height)||0,mobileType:e==null?void 0:e.config.mobileType,draggableConfig:{shadow:((o=e==null?void 0:e.config.draggableConfig)==null?void 0:o.shadow)||"0 -4px 12px rgba(0, 0, 0, 0.25)",initialPosition:((u=e==null?void 0:e.config.draggableConfig)==null?void 0:u.initialPosition)||"half",hideHandle:((h=e==null?void 0:e.config.draggableConfig)==null?void 0:h.hideHandle)||!1,handle:{color:((i=(b=e==null?void 0:e.config.draggableConfig)==null?void 0:b.handle)==null?void 0:i.color)||"#ccc",height:((r=(d=e==null?void 0:e.config.draggableConfig)==null?void 0:d.handle)==null?void 0:r.height)||"5px",width:((D=(P=e==null?void 0:e.config.draggableConfig)==null?void 0:P.handle)==null?void 0:D.width)||"45px",radius:((V=($=e==null?void 0:e.config.draggableConfig)==null?void 0:$.handle)==null?void 0:V.radius)||"4px",marginTop:((A=(F=e==null?void 0:e.config.draggableConfig)==null?void 0:F.handle)==null?void 0:A.marginTop)||"10px",marginBottom:((p=(E=e==null?void 0:e.config.draggableConfig)==null?void 0:E.handle)==null?void 0:p.marginBottom)||"10px",hoverColor:((x=(S=e==null?void 0:e.config.draggableConfig)==null?void 0:S.handle)==null?void 0:x.hoverColor)||"#999",activeColor:((k=(y=e==null?void 0:e.config.draggableConfig)==null?void 0:y.handle)==null?void 0:k.activeColor)||"#666"}}};g.value.push(a),O.value.push({...e==null?void 0:e.props,onClose:Y=>{f(Y),j(Y,g.value.length-1)}}),z.value.push((e==null?void 0:e.slots)||{}),e!=null&&e.config.onClosed?L.value.push(e.config.onClosed):L.value.push(()=>{})}),j=(t,e)=>{const{type:f,mobileType:w}=g.value[e];return g.value[e]?g.value[e].anim=!1:g.value[g.value.length-1].anim=!1,setTimeout(()=>{if(e===g.value.length-1){const a=g.value[g.value.length-1];a?(a.open=!1,B.value.pop(),g.value.pop(),O.value.pop(),z.value.pop()):(g.value=[],B.value=[],O.value=[],z.value=[])}else g.value[e]&&(g.value[e].open=!1,B.value.splice(e,1),g.value.splice(e,1),O.value.splice(e,1),z.value.splice(e,1));try{L.value[e]&&typeof L.value[e]=="function"&&(L.value[e](t),L.value.splice(e,1))}catch(a){throw console.log(a),new Error("Error in your onClosed function")}},f!=="draggable"&&w!=="draggable"?500:0),t},G=t=>{setTimeout(()=>(R.value=!1,B.value=[],U.value="",g.value=[],O.value=[],z.value=[],t),300)},De=()=>{const t=l.ref(!1),e=l.ref(!1),f=l.ref(!1);return{isMobile:t,isTablet:e,isDesktop:f,detectDevice:()=>{const a=window.innerWidth,o=navigator.userAgent,u=a<=768,h=a>768&&a<=1024,b=a>1024,d=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(o),r="ontouchstart"in window||navigator.maxTouchPoints>0;t.value=u||d&&r,e.value=h&&!t.value,f.value=b&&!r&&!d,!f.value&&!e.value&&(t.value=!0)}}},pe=["onClick"],J=l.defineComponent({__name:"modalRoot",setup(t){const e=(u,h)=>{j(u,h)},f=l.ref([]),w=(u,h)=>{const{type:b,mobileType:i}=g.value[h];if(b=="draggable"||i&&i=="draggable"){const d=f.value[h];d&&d.closeDialog&&d.closeDialog()}else j(u,h)},{isMobile:a,detectDevice:o}=De();return l.onMounted(()=>{o(),window.addEventListener("resize",o)}),l.onUnmounted(()=>{window.removeEventListener("resize",o)}),(u,h)=>(l.openBlock(),l.createElementBlock("div",null,[(l.openBlock(),l.createBlock(l.Teleport,{to:"body"},[(l.openBlock(!0),l.createElementBlock(l.Fragment,null,l.renderList(l.unref(B),(b,i)=>(l.openBlock(),l.createBlock(Be,{onClose:d=>e(d,i),key:i,config:l.unref(g)[i],ref_for:!0,ref_key:"modalRefs",ref:f,"modal-key-index":i,"mobile-view":l.unref(a)},l.createSlots({default:l.withCtx(()=>[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(b),l.mergeProps({data:l.unref(g),onClose:d=>w(d,i)},{ref_for:!0},l.unref(O)[i],{onCloseAll:l.unref(G)}),l.createSlots({_:2},[l.renderList(l.unref(z)[i],(d,r)=>({name:r,fn:l.withCtx(()=>[(l.openBlock(),l.createBlock(l.resolveDynamicComponent(d.component),l.mergeProps({ref_for:!0},d.props),null,16))])}))]),1040,["data","onClose","onCloseAll"]))]),_:2},[l.unref(g)[i].title?{name:"header",fn:l.withCtx(()=>[l.createElementVNode("h3",{class:l.normalizeClass(["__modal-header__title",l.unref(g)[i].type=="modal"?"__modal-header__title--standard":"__modal-header__title--side"])},l.toDisplayString(l.unref(g)[i].title),3),l.createElementVNode("button",{type:"button",class:"__modal-header__close-btn",onClick:d=>e(d,i)},[...h[0]||(h[0]=[l.createElementVNode("span",null,"×",-1)])],8,pe)]),key:"0"}:void 0]),1032,["onClose","config","modal-key-index","mobile-view"]))),128))]))]))}}),K={install(t,e){console.log("Installing VueModaller plugin with options:",e),t.component("ModalRoot",J)}},$e=t=>e=>{K.install(e,t)};m.ModalRoot=J,m.VueModaller=K,m.closeAllModal=G,m.closeModal=j,m.compRef=B,m.createPlugin=$e,m.default=K,m.modalOpen=R,m.modalOptions=g,m.modalProps=O,m.modalSlots=z,m.modalTitle=U,m.onClosedFunctions=L,m.useModal=Pe,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-modaller",
|
|
3
3
|
"author": "Classydev (https://github.com/classyrazy)",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A flexible and powerful modal system for Vue 3 applications with TypeScript support, featuring draggable modals, side panels, and smooth animations",
|
|
7
7
|
"private": false,
|