|
| 1 | +<template> |
| 2 | + <div class="pb-8"> |
| 3 | + <v-modal |
| 4 | + v-model="showModal" |
| 5 | + :ssr="ssr" |
| 6 | + :lock-scroll="lockScroll" |
| 7 | + :hide-overlay="hideOverlay" |
| 8 | + :click-to-close="clickToClose" |
| 9 | + :esc-to-close="escToClose" |
| 10 | + :prevent-click="preventClick" |
| 11 | + :transition="transition ? 'vfm' : ''" |
| 12 | + :overlay-transition="overlayTransition ? 'vfm' : ''" |
| 13 | + :z-index-auto="zIndexAuto" |
| 14 | + :z-index-base="zIndexBase" |
| 15 | + :z-index="allowZIndex ? zIndex : false" |
| 16 | + :attach="attach ? '#attach' : false" |
| 17 | + :focus-retain="focusRetain" |
| 18 | + :focus-trap="focusTrap" |
| 19 | + @confirm="showModal = false" |
| 20 | + @cancel="showModal = false" |
| 21 | + > |
| 22 | + <template v-slot:title># Hello, world!</template> |
| 23 | + <p> |
| 24 | + Lorem Ipsum is simply dummy text of the printing and typesetting industry. |
| 25 | + </p> |
| 26 | + </v-modal> |
| 27 | + |
| 28 | + <button class="vfm-btn" @click="showModal = true">Open Modal</button> |
| 29 | + |
| 30 | + <h3>Prop Options:</h3> |
| 31 | + |
| 32 | + <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 p-4 border rounded"> |
| 33 | + <label class="flex items-center space-x-2"> |
| 34 | + <span>value:</span> |
| 35 | + <input v-model="showModal" type="checkbox" /> |
| 36 | + </label> |
| 37 | + <label class="flex items-center space-x-2"> |
| 38 | + <span>ssr:</span> |
| 39 | + <input v-model="ssr" type="checkbox" /> |
| 40 | + </label> |
| 41 | + |
| 42 | + <label class="flex items-center space-x-2"> |
| 43 | + <span>lockScroll:</span> |
| 44 | + <input v-model="lockScroll" type="checkbox" /> |
| 45 | + </label> |
| 46 | + <label class="flex items-center space-x-2"> |
| 47 | + <span>hideOverlay:</span> |
| 48 | + <input v-model="hideOverlay" type="checkbox" /> |
| 49 | + </label> |
| 50 | + <label class="flex items-center space-x-2"> |
| 51 | + <span>clickToClose:</span> |
| 52 | + <input v-model="clickToClose" type="checkbox" /> |
| 53 | + </label> |
| 54 | + <label class="flex items-center space-x-2"> |
| 55 | + <span>escToClose:</span> |
| 56 | + <input v-model="escToClose" type="checkbox" /> |
| 57 | + </label> |
| 58 | + <label class="flex items-center space-x-2"> |
| 59 | + <span>preventClick:</span> |
| 60 | + <input v-model="preventClick" type="checkbox" /> |
| 61 | + </label> |
| 62 | + <label class="flex items-center space-x-2"> |
| 63 | + <span>transition:</span> |
| 64 | + <input v-model="transition" type="checkbox" /> |
| 65 | + </label> |
| 66 | + <label class="flex items-center space-x-2"> |
| 67 | + <span>overlayTransition:</span> |
| 68 | + <input v-model="overlayTransition" type="checkbox" /> |
| 69 | + </label> |
| 70 | + <label class="flex items-center space-x-2"> |
| 71 | + <span>zIndexAuto:</span> |
| 72 | + <input v-model="zIndexAuto" type="checkbox" /> |
| 73 | + </label> |
| 74 | + <label class="flex items-center space-x-2"> |
| 75 | + <span>zIndexBase:</span> |
| 76 | + <input v-model="zIndexBase" class="w-20 pl-2 dark:text-black rounded focus:outline-none" type="number" /> |
| 77 | + </label> |
| 78 | + <div class="flex items-center space-x-2"> |
| 79 | + <label class="flex items-center space-x-2"> |
| 80 | + <input v-model="allowZIndex" type="checkbox" /> |
| 81 | + <span>zIndex:</span> |
| 82 | + </label> |
| 83 | + <label> |
| 84 | + <input |
| 85 | + v-model="zIndex" |
| 86 | + type="number" |
| 87 | + class="w-20 pl-2 dark:text-black rounded focus:outline-none" |
| 88 | + :disabled="!allowZIndex" |
| 89 | + /> |
| 90 | + </label> |
| 91 | + </div> |
| 92 | + <label class="flex items-center space-x-2"> |
| 93 | + <span>attach:</span> |
| 94 | + <input v-model="attach" type="checkbox" /> |
| 95 | + </label> |
| 96 | + <label class="flex items-center space-x-2"> |
| 97 | + <span>focusRetain:</span> |
| 98 | + <input v-model="focusRetain" type="checkbox" /> |
| 99 | + </label> |
| 100 | + <label class="flex items-center space-x-2"> |
| 101 | + <span>focusTrap:</span> |
| 102 | + <input v-model="focusTrap" type="checkbox" /> |
| 103 | + </label> |
| 104 | + <button class="vfm-btn" @click="reset">reset</button> |
| 105 | + </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> |
| 111 | + <p>click will:</p> |
| 112 | + <ul> |
| 113 | + <li>set "attach" to "true"</li> |
| 114 | + <li>set "lockScroll" to "false"</li> |
| 115 | + </ul> |
| 116 | + </div> |
| 117 | + </div> |
| 118 | +</template> |
| 119 | + |
| 120 | +<script> |
| 121 | +const initData = () => ({ |
| 122 | + showModal: false, |
| 123 | + ssr: true, |
| 124 | + lockScroll: true, |
| 125 | + hideOverlay: false, |
| 126 | + clickToClose: true, |
| 127 | + escToClose: false, |
| 128 | + preventClick: false, |
| 129 | + transition: true, |
| 130 | + overlayTransition: true, |
| 131 | + zIndexAuto: true, |
| 132 | + zIndexBase: 1000, |
| 133 | + allowZIndex: false, |
| 134 | + zIndex: 0, |
| 135 | + attach: false, |
| 136 | + focusRetain: true, |
| 137 | + focusTrap: false |
| 138 | +}) |
| 139 | +
|
| 140 | +export default { |
| 141 | + data: initData, |
| 142 | + methods: { |
| 143 | + openAttach() { |
| 144 | + this.attach = '#attach' |
| 145 | + this.showModal = true |
| 146 | + this.lockScroll = false |
| 147 | + }, |
| 148 | + reset() { |
| 149 | + Object.assign(this, initData()) |
| 150 | + } |
| 151 | + } |
| 152 | +} |
| 153 | +</script> |
0 commit comments