1
- import Vue from 'vue' ;
2
- import vClickOutside from 'v-click-outside' ;
1
+ import { resolveDirective , openBlock , createElementBlock , withDirectives , Fragment , renderList , withModifiers , normalizeClass , createElementVNode } from 'vue' ;
3
2
4
- //
5
- Vue . use ( vClickOutside ) ;
3
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : { } ;
4
+
5
+ function createCommonjsModule ( fn , module ) {
6
+ return module = { exports : { } } , fn ( module , module . exports ) , module . exports ;
7
+ }
8
+
9
+ var vClickOutside_umd = createCommonjsModule ( function ( module , exports ) {
10
+ ! function ( e , n ) { module . exports = n ( ) ; } ( commonjsGlobal , function ( ) { var e = "__v-click-outside" , n = "undefined" != typeof window , t = "undefined" != typeof navigator , r = n && ( "ontouchstart" in window || t && navigator . msMaxTouchPoints > 0 ) ?[ "touchstart" ] :[ "click" ] , i = function ( e ) { var n = e . event , t = e . handler ; ( 0 , e . middleware ) ( n ) && t ( n ) ; } , a = function ( n , t ) { var a = function ( e ) { var n = "function" == typeof e ; if ( ! n && "object" != typeof e ) { throw new Error ( "v-click-outside: Binding value must be a function or an object" ) ; } return { handler :n ?e :e . handler , middleware :e . middleware || function ( e ) { return e } , events :e . events || r , isActive :! ( ! 1 === e . isActive ) , detectIframe :! ( ! 1 === e . detectIframe ) , capture :Boolean ( e . capture ) } } ( t . value ) , o = a . handler , d = a . middleware , c = a . detectIframe , u = a . capture ; if ( a . isActive ) { if ( n [ e ] = a . events . map ( function ( e ) { return { event :e , srcTarget :document . documentElement , handler :function ( e ) { return function ( e ) { var n = e . el , t = e . event , r = e . handler , a = e . middleware , o = t . path || t . composedPath && t . composedPath ( ) ; ( o ?o . indexOf ( n ) < 0 :! n . contains ( t . target ) ) && i ( { event :t , handler :r , middleware :a } ) ; } ( { el :n , event :e , handler :o , middleware :d } ) } , capture :u } } ) , c ) { var l = { event :"blur" , srcTarget :window , handler :function ( e ) { return function ( e ) { var n = e . el , t = e . event , r = e . handler , a = e . middleware ; setTimeout ( function ( ) { var e = document . activeElement ; e && "IFRAME" === e . tagName && ! n . contains ( e ) && i ( { event :t , handler :r , middleware :a } ) ; } , 0 ) ; } ( { el :n , event :e , handler :o , middleware :d } ) } , capture :u } ; n [ e ] = [ ] . concat ( n [ e ] , [ l ] ) ; } n [ e ] . forEach ( function ( t ) { var r = t . event , i = t . srcTarget , a = t . handler ; return setTimeout ( function ( ) { n [ e ] && i . addEventListener ( r , a , u ) ; } , 0 ) } ) ; } } , o = function ( n ) { ( n [ e ] || [ ] ) . forEach ( function ( e ) { return e . srcTarget . removeEventListener ( e . event , e . handler , e . capture ) } ) , delete n [ e ] ; } , d = n ?{ beforeMount :a , updated :function ( e , n ) { var t = n . value , r = n . oldValue ; JSON . stringify ( t ) !== JSON . stringify ( r ) && ( o ( e ) , a ( e , { value :t } ) ) ; } , unmounted :o } :{ } ; return { install :function ( e ) { e . directive ( "click-outside" , d ) ; } , directive :d } } ) ;
11
+
12
+ } ) ;
6
13
7
14
var script = {
8
15
name : "VueSimpleContextMenu" ,
@@ -16,6 +23,13 @@ var script = {
16
23
required : true
17
24
}
18
25
} ,
26
+ emits : [
27
+ 'menu-closed' ,
28
+ 'option-clicked'
29
+ ] ,
30
+ directives : {
31
+ 'click-outside' : vClickOutside_umd . directive
32
+ } ,
19
33
data : function data ( ) {
20
34
return {
21
35
item : null ,
@@ -80,173 +94,53 @@ var script = {
80
94
mounted : function mounted ( ) {
81
95
document . body . addEventListener ( "keyup" , this . onEscKeyRelease ) ;
82
96
} ,
83
- beforeDestroy : function beforeDestroy ( ) {
97
+ beforeUnmount : function beforeUnmount ( ) {
84
98
document . removeEventListener ( "keyup" , this . onEscKeyRelease ) ;
85
99
}
86
100
} ;
87
101
88
- function normalizeComponent ( template , style , script , scopeId , isFunctionalTemplate , moduleIdentifier /* server only */ , shadowMode , createInjector , createInjectorSSR , createInjectorShadow ) {
89
- if ( typeof shadowMode !== 'boolean' ) {
90
- createInjectorSSR = createInjector ;
91
- createInjector = shadowMode ;
92
- shadowMode = false ;
93
- }
94
- // Vue.extend constructor export interop.
95
- var options = typeof script === 'function' ? script . options : script ;
96
- // render functions
97
- if ( template && template . render ) {
98
- options . render = template . render ;
99
- options . staticRenderFns = template . staticRenderFns ;
100
- options . _compiled = true ;
101
- // functional template
102
- if ( isFunctionalTemplate ) {
103
- options . functional = true ;
104
- }
105
- }
106
- // scopedId
107
- if ( scopeId ) {
108
- options . _scopeId = scopeId ;
109
- }
110
- var hook ;
111
- if ( moduleIdentifier ) {
112
- // server build
113
- hook = function ( context ) {
114
- // 2.3 injection
115
- context =
116
- context || // cached call
117
- ( this . $vnode && this . $vnode . ssrContext ) || // stateful
118
- ( this . parent && this . parent . $vnode && this . parent . $vnode . ssrContext ) ; // functional
119
- // 2.2 with runInNewContext: true
120
- if ( ! context && typeof __VUE_SSR_CONTEXT__ !== 'undefined' ) {
121
- context = __VUE_SSR_CONTEXT__ ;
122
- }
123
- // inject component styles
124
- if ( style ) {
125
- style . call ( this , createInjectorSSR ( context ) ) ;
126
- }
127
- // register component module identifier for async chunk inference
128
- if ( context && context . _registeredComponents ) {
129
- context . _registeredComponents . add ( moduleIdentifier ) ;
130
- }
131
- } ;
132
- // used by ssr in case component is cached and beforeCreate
133
- // never gets called
134
- options . _ssrRegister = hook ;
135
- }
136
- else if ( style ) {
137
- hook = shadowMode
138
- ? function ( context ) {
139
- style . call ( this , createInjectorShadow ( context , this . $root . $options . shadowRoot ) ) ;
140
- }
141
- : function ( context ) {
142
- style . call ( this , createInjector ( context ) ) ;
143
- } ;
144
- }
145
- if ( hook ) {
146
- if ( options . functional ) {
147
- // register for functional component in vue file
148
- var originalRender = options . render ;
149
- options . render = function renderWithStyleInjection ( h , context ) {
150
- hook . call ( context ) ;
151
- return originalRender ( h , context ) ;
152
- } ;
153
- }
154
- else {
155
- // inject component registration as beforeCreate hook
156
- var existing = options . beforeCreate ;
157
- options . beforeCreate = existing ? [ ] . concat ( existing , hook ) : [ hook ] ;
158
- }
159
- }
160
- return script ;
102
+ var _hoisted_1 = [ "id" ] ;
103
+ var _hoisted_2 = [ "onClick" ] ;
104
+ var _hoisted_3 = [ "innerHTML" ] ;
105
+
106
+ function render ( _ctx , _cache , $props , $setup , $data , $options ) {
107
+ var _directive_click_outside = resolveDirective ( "click-outside" ) ;
108
+
109
+ return ( openBlock ( ) , createElementBlock ( "div" , null , [
110
+ withDirectives ( ( openBlock ( ) , createElementBlock ( "ul" , {
111
+ id : $props . elementId ,
112
+ class : "vue-simple-context-menu"
113
+ } , [
114
+ ( openBlock ( true ) , createElementBlock ( Fragment , null , renderList ( $props . options , function ( option , index ) {
115
+ return ( openBlock ( ) , createElementBlock ( "li" , {
116
+ key : index ,
117
+ onClick : withModifiers ( function ( $event ) { return ( $options . optionClicked ( option ) ) ; } , [ "stop" ] ) ,
118
+ class : normalizeClass ( [ "vue-simple-context-menu__item" , [
119
+ option . class ,
120
+ option . type === 'divider' ? 'vue-simple-context-menu__divider' : ''
121
+ ] ] )
122
+ } , [
123
+ createElementVNode ( "span" , {
124
+ innerHTML : option . name
125
+ } , null , 8 /* PROPS */ , _hoisted_3 )
126
+ ] , 10 /* CLASS, PROPS */ , _hoisted_2 ) )
127
+ } ) , 128 /* KEYED_FRAGMENT */ ) )
128
+ ] , 8 /* PROPS */ , _hoisted_1 ) ) , [
129
+ [ _directive_click_outside , $options . onClickOutside ]
130
+ ] )
131
+ ] ) )
161
132
}
162
133
163
- /* script */
164
- var __vue_script__ = script ;
165
- /* template */
166
- var __vue_render__ = function ( ) {
167
- var _vm = this ;
168
- var _h = _vm . $createElement ;
169
- var _c = _vm . _self . _c || _h ;
170
- return _c ( "div" , [
171
- _c (
172
- "ul" ,
173
- {
174
- directives : [
175
- {
176
- name : "click-outside" ,
177
- rawName : "v-click-outside" ,
178
- value : _vm . onClickOutside ,
179
- expression : "onClickOutside"
180
- }
181
- ] ,
182
- staticClass : "vue-simple-context-menu" ,
183
- attrs : { id : _vm . elementId }
184
- } ,
185
- _vm . _l ( _vm . options , function ( option , index ) {
186
- return _c (
187
- "li" ,
188
- {
189
- key : index ,
190
- staticClass : "vue-simple-context-menu__item" ,
191
- class : [
192
- option . class ,
193
- option . type === "divider"
194
- ? "vue-simple-context-menu__divider"
195
- : ""
196
- ] ,
197
- on : {
198
- click : function ( $event ) {
199
- $event . stopPropagation ( ) ;
200
- return _vm . optionClicked ( option )
201
- }
202
- }
203
- } ,
204
- [ _c ( "span" , { domProps : { innerHTML : _vm . _s ( option . name ) } } ) ]
205
- )
206
- } ) ,
207
- 0
208
- )
209
- ] )
210
- } ;
211
- var __vue_staticRenderFns__ = [ ] ;
212
- __vue_render__ . _withStripped = true ;
213
-
214
- /* style */
215
- var __vue_inject_styles__ = undefined ;
216
- /* scoped */
217
- var __vue_scope_id__ = undefined ;
218
- /* module identifier */
219
- var __vue_module_identifier__ = undefined ;
220
- /* functional template */
221
- var __vue_is_functional_template__ = false ;
222
- /* style inject */
223
-
224
- /* style inject SSR */
225
-
226
- /* style inject shadow dom */
227
-
228
-
229
-
230
- var __vue_component__ = /*#__PURE__*/ normalizeComponent (
231
- { render : __vue_render__ , staticRenderFns : __vue_staticRenderFns__ } ,
232
- __vue_inject_styles__ ,
233
- __vue_script__ ,
234
- __vue_scope_id__ ,
235
- __vue_is_functional_template__ ,
236
- __vue_module_identifier__ ,
237
- false ,
238
- undefined ,
239
- undefined ,
240
- undefined
241
- ) ;
134
+ script . render = render ;
135
+ script . __file = "src/vue-simple-context-menu.vue" ;
242
136
243
137
// Import vue component
244
138
245
- // install function executed by Vue .use()
246
- function install ( Vue ) {
139
+ // install function executed by app .use()
140
+ function install ( app ) {
247
141
if ( install . installed ) { return ; }
248
142
install . installed = true ;
249
- Vue . component ( 'VueSimpleContextMenu' , __vue_component__ ) ;
143
+ app . component ( 'VueSimpleContextMenu' , script ) ;
250
144
}
251
145
252
146
// Create module definition for Vue.use()
@@ -269,5 +163,5 @@ if (GlobalVue) {
269
163
// also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo';
270
164
// export const RollupDemoDirective = component;
271
165
272
- export default __vue_component__ ;
166
+ export default script ;
273
167
export { install } ;
0 commit comments