Skip to content

Commit 4bf12f9

Browse files
Feat/v3/drag resize (#104)
* feat: drag & resize * fix: check listener exist el * fix(test): 1. Bump @vue/test-utils 2. add unit test for drag & resize
1 parent fbe5201 commit 4bf12f9

File tree

101 files changed

+3468
-1925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+3468
-1925
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
## 🎉 [Documentation](https://vue-final-modal.org)
3030

3131

32-
## 🙌 [Examples](https://vue-final-modal.org/examples/manual)
32+
## 🙌 [Examples](https://vue-final-modal.org/examples/liveDemo)
3333

3434
## Introduction
3535

@@ -43,7 +43,7 @@ You can create a [higher-order component](https://vue-final-modal.org/examples/r
4343
- [Tailwind CSS](https://vue-final-modal.org/examples/tailwind) friendly
4444
- Renderless component
4545
- [Tiny bundle size](https://bundlephobia.com/result?p=vue-final-modal)
46-
- Support `stackable`, `detachable`, `scrollable`, `transition`, `accessibility`, `focusTrap`, `dynamic modal`
46+
- Support `stackable`, `detachable`, `scrollable`, `draggable`, `resizable`, `transition`, `accessibility`, `focusTrap`, `dynamic modal`
4747

4848
## **Development**
4949

@@ -64,7 +64,7 @@ yarn build
6464
# Run examples
6565
cd examples
6666
yarn
67-
yarn serve
67+
yarn dev
6868

6969
# Run docs
7070
cd docs
@@ -96,6 +96,8 @@ To develop `vue-final-modal`, I learn a lot from these awesome libraries:
9696
- focusTrap for A11y
9797
- [Bootstrap Vue](https://bootstrap-vue.org/)
9898
- lockScroll
99+
- [vue-resizable](https://github.com/nikitasnv/vue-resizable)
100+
- drag & resize
99101

100102
> There is no perfect library even the `final` of vue modal.
101103

dist/VueFinalModal.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/components/examples/basic/BasicOptions.vue

Lines changed: 91 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,31 @@
1616
:attach="attach ? '#attach' : false"
1717
:focus-retain="focusRetain"
1818
:focus-trap="focusTrap"
19+
:drag="drag"
20+
:fit-parent="fitParent"
21+
:keep-changed-style="keepChangedStyle"
22+
:resize="resize"
23+
:resize-directions="resizeDirections"
24+
:drag-selector="allowDragSelector ? dragSelector : ''"
25+
:min-width="minWidth"
26+
:max-width="maxWidth"
27+
:min-height="minHeight"
28+
:max-height="maxHeight"
1929
@confirm="showModal = false"
2030
@cancel="showModal = false"
2131
>
2232
<template #title># Hello, world!</template>
23-
<p>
24-
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
25-
</p>
33+
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
2634
</v-modal>
2735

28-
<button class="vfm-btn" @click="showModal = true">Open Modal</button>
36+
<div class="flex space-x-2">
37+
<v-button highlight @click="showModal = true">Open Modal</v-button>
38+
<v-button @click="reset">reset</v-button>
39+
</div>
2940

30-
<h3>Prop Options:</h3>
41+
<h3 class="py-2">Basic:</h3>
3142

32-
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 p-4 border rounded">
43+
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-y-4 p-4 border rounded select-none">
3344
<label class="flex items-center space-x-2">
3445
<span>value:</span>
3546
<input v-model="showModal" type="checkbox" />
@@ -38,7 +49,6 @@
3849
<span>ssr:</span>
3950
<input v-model="ssr" type="checkbox" />
4051
</label>
41-
4252
<label class="flex items-center space-x-2">
4353
<span>lockScroll:</span>
4454
<input v-model="lockScroll" type="checkbox" />
@@ -101,13 +111,69 @@
101111
<span>focusTrap:</span>
102112
<input v-model="focusTrap" type="checkbox" />
103113
</label>
104-
<button class="vfm-btn" @click="reset">reset</button>
105114
</div>
106-
<h4>Attach area:</h4>
107-
<div id="attach" class="relative w-full h-64 mt-8 p-4 border rounded dark:bg-gray-700">
108-
<button class="vfm-btn" @click="openAttach">
109-
Attach to here and open modal
110-
</button>
115+
<h3 class="py-2">Drag & Resize:</h3>
116+
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 p-4 border rounded select-none">
117+
<label class="flex items-center space-x-2">
118+
<span>drag:</span>
119+
<input v-model="drag" type="checkbox" />
120+
</label>
121+
<div class="flex flex-col">
122+
<label class="flex items-center space-x-2">
123+
<input v-model="allowDragSelector" type="checkbox" />
124+
<span>dragSelector:</span>
125+
</label>
126+
<label>
127+
<input
128+
v-model="dragSelector"
129+
:disabled="!allowDragSelector"
130+
class="pl-2 dark:text-black rounded focus:outline-none"
131+
/>
132+
</label>
133+
</div>
134+
<label class="flex items-center space-x-2">
135+
<span>fitParent:</span>
136+
<input v-model="fitParent" type="checkbox" />
137+
</label>
138+
<label class="flex items-center space-x-2">
139+
<span>keepChangedStyle:</span>
140+
<input v-model="keepChangedStyle" type="checkbox" />
141+
</label>
142+
<label class="flex items-center space-x-2">
143+
<span>resize:</span>
144+
<input v-model="resize" type="checkbox" />
145+
</label>
146+
<div class="flex flex-col">
147+
<span>resizeDirections:</span>
148+
<div class="flex space-x-1">
149+
<div v-for="direction in ['t', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl']" :key="direction">
150+
<label>
151+
{{ direction }}:
152+
<input type="checkbox" v-model="resizeDirections" :value="direction" />
153+
</label>
154+
</div>
155+
</div>
156+
</div>
157+
<label class="flex items-center space-x-2">
158+
<span>minWidth:</span>
159+
<input v-model.number="minWidth" type="number" class="w-20 pl-2 dark:text-black rounded focus:outline-none" />
160+
</label>
161+
<label class="flex items-center space-x-2">
162+
<span>maxWidth:</span>
163+
<input v-model.number="maxWidth" type="number" class="w-20 pl-2 dark:text-black rounded focus:outline-none" />
164+
</label>
165+
<label class="flex items-center space-x-2">
166+
<span>minHeight:</span>
167+
<input v-model.number="minHeight" type="number" class="w-20 pl-2 dark:text-black rounded focus:outline-none" />
168+
</label>
169+
<label class="flex items-center space-x-2">
170+
<span>maxHeight:</span>
171+
<input v-model.number="maxHeight" type="number" class="w-20 pl-2 dark:text-black rounded focus:outline-none" />
172+
</label>
173+
</div>
174+
<h3 class="py-2">Attach:</h3>
175+
<div id="attach" class="relative w-full h-64 p-4 border rounded dark:bg-gray-900 overflow-hidden">
176+
<v-button highlight @click="openAttach">Attach to here and open modal</v-button>
111177
<p>click will:</p>
112178
<ul>
113179
<li>set "attach" to "true"</li>
@@ -134,7 +200,18 @@ const initData = () => ({
134200
zIndex: 0,
135201
attach: false,
136202
focusRetain: true,
137-
focusTrap: false
203+
focusTrap: false,
204+
drag: false,
205+
fitParent: true,
206+
keepChangedStyle: false,
207+
resize: false,
208+
resizeDirections: ['t', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl'],
209+
allowDragSelector: false,
210+
dragSelector: '.modal__title',
211+
minWidth: 0,
212+
maxWidth: 2000,
213+
minHeight: 0,
214+
maxHeight: 2000
138215
})
139216
140217
export default {

docs/components/examples/basic/BasicPlainStyleCodepen.vue

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs/components/examples/basic/VAccessibility.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<p>Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.</p>
66
</v-modal>
77

8-
<button class="vfm-btn" @click="show = true">Open modal</button>
8+
<v-button highlight @click="show = true">Open modal</v-button>
99
</div>
1010
</template>
1111

docs/components/examples/basic/VActionButtons.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
</p>
1212
</div>
1313
<div class="modal__action">
14-
<button class="vfm-btn" @click="showModal = false">confirm</button>
15-
<button class="vfm-btn" @click="showModal = false">cancel</button>
14+
<v-button @click="showModal = false">confirm</v-button>
15+
<v-button @click="showModal = false">cancel</v-button>
1616
</div>
1717
</vue-final-modal>
18-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
18+
<v-button highlight @click="showModal = true">Open modal</v-button>
1919
</div>
2020
</template>
2121

docs/components/examples/basic/VApiShow.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<div>
33
<v-modal v-model="showModal" name="VApiShow" @confirm="showModal = false" @cancel="showModal = false">
4-
<template #default="{ params }"> Hi {{ params.userName }} </template>
4+
<template #default="{ params }">Hi {{ params.userName }}</template>
55
<template #title>$vfm.show</template>
66
</v-modal>
7-
<button class="vfm-btn" @click="$vfm.show('VApiShow', { userName: 'vue-final-modal' })">Open modal</button>
7+
<v-button highlight @click="$vfm.show('VApiShow', { userName: 'vue-final-modal' })">Open modal</v-button>
88
</div>
99
</template>
1010

docs/components/examples/basic/VBackground.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<vue-final-modal v-model="showModal" content-class="modal-content">
44
<span class="modal__title">Hello, vue-final-modal</span>
55
</vue-final-modal>
6-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
6+
<v-button highlight @click="showModal = true">Open modal</v-button>
77
</div>
88
</template>
99

docs/components/examples/basic/VBasic.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<vue-final-modal v-model="showModal">
44
<span class="modal__title">Hello, vue-final-modal</span>
55
</vue-final-modal>
6-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
6+
<v-button highlight @click="showModal = true">Open modal</v-button>
77
</div>
88
</template>
99

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<button class="v-btn" v-on="$listeners"><span v-if="highlight">👉 </span><slot></slot></button>
3+
</template>
4+
5+
<script>
6+
export default {
7+
props: {
8+
highlight: {
9+
type: Boolean,
10+
default: false
11+
}
12+
}
13+
}
14+
</script>
15+
<style scoped>
16+
button.v-btn {
17+
@apply px-2 py-1 border rounded;
18+
}
19+
button.v-btn + button.v-btn {
20+
margin: 0 0 0 1rem;
21+
}
22+
</style>

docs/components/examples/basic/VCentered.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<vue-final-modal v-model="showModal" classes="modal-container" content-class="modal-content">
44
<span class="modal__title">Hello, vue-final-modal</span>
55
</vue-final-modal>
6-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
6+
<v-button highlight @click="showModal = true">Open modal</v-button>
77
</div>
88
</template>
99

docs/components/examples/basic/VCloseButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<p>Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.</p>
1010
</div>
1111
</vue-final-modal>
12-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
12+
<v-button highlight @click="showModal = true">Open modal</v-button>
1313
</div>
1414
</template>
1515

docs/components/examples/basic/VContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<p>Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.</p>
77
</div>
88
</vue-final-modal>
9-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
9+
<v-button highlight @click="showModal = true">Open modal</v-button>
1010
</div>
1111
</template>
1212

docs/components/examples/basic/VDynamic.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<button class="vfm-btn mb-4" @click="dynamic">Open Dynamic Modal</button>
2+
<v-button class="mb-4" highlight @click="dynamic">Open Dynamic Modal</v-button>
33
</template>
44

55
<script>

docs/components/examples/basic/VDynamicAdvanced.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<button class="vfm-btn mb-4" @click="dynamic">Open Dynamic Modal</button>
2+
<v-button class="mb-4" highlight @click="dynamic">Open Dynamic Modal</v-button>
33
</template>
44

55
<script>

docs/components/examples/basic/VEvents.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
>
1212
<template #title>Events Example!</template>
1313
</v-modal>
14-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
14+
<v-button highlight @click="showModal = true">Open modal</v-button>
1515
</div>
1616
</template>
1717

docs/components/examples/basic/VParams.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
</p>
2020
</div>
2121
<div class="modal__action">
22-
<button class="vfm-btn" @click="$vfm.hide('stackable')">confirm</button>
23-
<button class="vfm-btn" @click="$vfm.hide('stackable')">cancel</button>
22+
<v-button @click="$vfm.hide('stackable')">confirm</v-button>
23+
<v-button @click="$vfm.hide('stackable')">cancel</v-button>
2424
</div>
2525
</template>
2626
</vue-final-modal>
27-
<button class="vfm-btn" @click="$vfm.show('stackable', { test: 123 })">Show modal with params</button>
28-
<button class="vfm-btn" @click="$vfm.toggle('stackable', null, { test: 321 })">Toggle modal with params</button>
29-
<button class="vfm-btn" @click="$vfm.show('stackable')">Show modal</button>
30-
<button class="vfm-btn" @click="$vfm.hide('stackable')">Hide modal</button>
27+
<v-button @click="$vfm.show('stackable', { test: 123 })">Show modal with params</v-button>
28+
<v-button @click="$vfm.toggle('stackable', null, { test: 321 })">Toggle modal with params</v-button>
29+
<v-button @click="$vfm.show('stackable')">Show modal</v-button>
30+
<v-button @click="$vfm.hide('stackable')">Hide modal</v-button>
3131
</div>
3232
</template>
3333

docs/components/examples/basic/VScrollable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</p>
1212
</div>
1313
</vue-final-modal>
14-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
14+
<v-button highlight @click="showModal = true">Open modal</v-button>
1515
</div>
1616
</template>
1717

docs/components/examples/basic/VStackable.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
</p>
1313
</div>
1414
<div class="modal__action">
15-
<span>Try click →&nbsp;&nbsp;&nbsp;&nbsp;</span>
16-
<button class="vfm-btn" @click="showConfirmModal = true">confirm</button>
17-
<button class="vfm-btn" @click="showModal = false">cancel</button>
15+
<v-button highlight @click="showConfirmModal = true">confirm</v-button>
16+
<v-button @click="showModal = false">cancel</v-button>
1817
</div>
1918
</vue-final-modal>
2019

@@ -26,12 +25,12 @@
2625
<span class="modal__title">Confirm</span>
2726
<div class="modal__content">Confirm to submit.</div>
2827
<div class="modal__action">
29-
<button class="vfm-btn" @click="confirm">confirm</button>
30-
<button class="vfm-btn" @click="showConfirmModal = false">cancel</button>
28+
<v-button @click="confirm">confirm</v-button>
29+
<v-button @click="showConfirmModal = false">cancel</v-button>
3130
</div>
3231
</vue-final-modal>
3332

34-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
33+
<v-button highlight @click="showModal = true">Open modal</v-button>
3534
</div>
3635
</template>
3736

0 commit comments

Comments
 (0)