|
| 1 | +/*! |
| 2 | + * vue-gridjs v0.1.0 |
| 3 | + * (c) |
| 4 | + */ |
| 5 | +import 'core-js/modules/es.object.to-string'; |
| 6 | +import 'core-js/modules/es.promise'; |
| 7 | +import 'core-js/modules/es.regexp.exec'; |
| 8 | +import 'core-js/modules/es.string.search'; |
| 9 | +import { Grid } from 'gridjs'; |
| 10 | +import uuid from 'uuid-random'; |
| 11 | +import elementReady from 'element-ready'; |
| 12 | +import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.mjs'; |
| 13 | +import __vue_create_injector__ from 'vue-runtime-helpers/dist/inject-style/browser.mjs'; |
| 14 | + |
| 15 | +function _await(value, then, direct) { |
| 16 | + if (direct) { |
| 17 | + return then ? then(value) : value; |
| 18 | + } |
| 19 | + |
| 20 | + if (!value || !value.then) { |
| 21 | + value = Promise.resolve(value); |
| 22 | + } |
| 23 | + |
| 24 | + return then ? value.then(then) : value; |
| 25 | +} |
| 26 | + |
| 27 | +var script = { |
| 28 | + name: 'Grid', |
| 29 | + props: { |
| 30 | + autoWidth: { |
| 31 | + type: Boolean, |
| 32 | + default: true |
| 33 | + }, |
| 34 | + from: { |
| 35 | + type: String, |
| 36 | + default: undefined |
| 37 | + }, |
| 38 | + data: { |
| 39 | + type: Object, |
| 40 | + default: function _default() { |
| 41 | + return { |
| 42 | + cols: ['Table is null'], |
| 43 | + rows: ['Please add some data'] |
| 44 | + }; |
| 45 | + } |
| 46 | + }, |
| 47 | + language: { |
| 48 | + type: Object, |
| 49 | + default: undefined |
| 50 | + }, |
| 51 | + pagination: { |
| 52 | + type: [Object, Boolean], |
| 53 | + default: false |
| 54 | + }, |
| 55 | + search: { |
| 56 | + type: [Object, Boolean], |
| 57 | + default: false |
| 58 | + }, |
| 59 | + server: { |
| 60 | + type: Object, |
| 61 | + default: undefined |
| 62 | + }, |
| 63 | + sort: { |
| 64 | + type: [Object, Boolean], |
| 65 | + default: false |
| 66 | + }, |
| 67 | + theme: { |
| 68 | + type: String, |
| 69 | + default: 'mermaid' |
| 70 | + }, |
| 71 | + width: { |
| 72 | + type: String, |
| 73 | + default: '100%' |
| 74 | + } |
| 75 | + }, |
| 76 | + data: function data() { |
| 77 | + return { |
| 78 | + uuid: null, |
| 79 | + wrapper: null |
| 80 | + }; |
| 81 | + }, |
| 82 | + mounted: function mounted() { |
| 83 | + try { |
| 84 | + var _this2 = this; |
| 85 | + |
| 86 | + // give table a unique id |
| 87 | + _this2.uuid = uuid(); // select the unique wrapper element |
| 88 | + |
| 89 | + return _await(elementReady("[data-uuid=\"".concat(_this2.uuid, "\"]")), function (_elementReady) { |
| 90 | + _this2.wrapper = _elementReady; |
| 91 | + |
| 92 | + if (_this2.data && _this2.data.rows || _this2.server || _this2.from) { |
| 93 | + _this2.grid = new Grid({ |
| 94 | + autoWidth: false, |
| 95 | + columns: _this2.data.cols, |
| 96 | + data: _this2.data.rows, |
| 97 | + from: _this2.from, |
| 98 | + pagination: _this2.pagination, |
| 99 | + search: _this2.search, |
| 100 | + server: _this2.server, |
| 101 | + sort: _this2.sort, |
| 102 | + width: _this2.width |
| 103 | + }).render(_this2.wrapper); |
| 104 | + } |
| 105 | + }); // instantiate grid.js |
| 106 | + } catch (e) { |
| 107 | + return Promise.reject(e); |
| 108 | + } |
| 109 | + }, |
| 110 | + destroyed: function destroyed() { |
| 111 | + // unload from memory |
| 112 | + this.grid = undefined; |
| 113 | + this.wrapper = undefined; |
| 114 | + } |
| 115 | +}; |
| 116 | + |
| 117 | +/* script */ |
| 118 | +var __vue_script__ = script; |
| 119 | +/* template */ |
| 120 | + |
| 121 | +var __vue_render__ = function __vue_render__() { |
| 122 | + var _vm = this; |
| 123 | + |
| 124 | + var _h = _vm.$createElement; |
| 125 | + |
| 126 | + var _c = _vm._self._c || _h; |
| 127 | + |
| 128 | + return _c('article', { |
| 129 | + class: "gridjs__wrapper " + _vm.theme, |
| 130 | + attrs: { |
| 131 | + "data-uuid": _vm.uuid |
| 132 | + } |
| 133 | + }); |
| 134 | +}; |
| 135 | + |
| 136 | +var __vue_staticRenderFns__ = []; |
| 137 | +/* style */ |
| 138 | + |
| 139 | +var __vue_inject_styles__ = function __vue_inject_styles__(inject) { |
| 140 | + if (!inject) return; |
| 141 | + inject("data-v-68133c66_0", { |
| 142 | + source: ".mermaid[data-v-68133c66]{@import '~gridjs/dist/theme/mermaid.css';}", |
| 143 | + map: undefined, |
| 144 | + media: undefined |
| 145 | + }); |
| 146 | +}; |
| 147 | +/* scoped */ |
| 148 | + |
| 149 | + |
| 150 | +var __vue_scope_id__ = "data-v-68133c66"; |
| 151 | +/* module identifier */ |
| 152 | + |
| 153 | +var __vue_module_identifier__ = undefined; |
| 154 | +/* functional template */ |
| 155 | + |
| 156 | +var __vue_is_functional_template__ = false; |
| 157 | +/* style inject SSR */ |
| 158 | + |
| 159 | +/* style inject shadow dom */ |
| 160 | + |
| 161 | +var __vue_component__ = /*#__PURE__*/__vue_normalize__({ |
| 162 | + render: __vue_render__, |
| 163 | + staticRenderFns: __vue_staticRenderFns__ |
| 164 | +}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, __vue_create_injector__, undefined, undefined); |
| 165 | + |
| 166 | +function install(Vue) { |
| 167 | + if (install.installed) return; |
| 168 | + install.installed = true; |
| 169 | + Vue.component('Grid', __vue_component__); |
| 170 | +} |
| 171 | +var plugin = { |
| 172 | + install: install |
| 173 | +}; |
| 174 | +var GlobalVue = null; |
| 175 | + |
| 176 | +if (typeof window !== 'undefined') { |
| 177 | + GlobalVue = window.Vue; |
| 178 | +} else if (typeof global !== 'undefined') { |
| 179 | + GlobalVue = global.Vue; |
| 180 | +} |
| 181 | + |
| 182 | +if (GlobalVue) { |
| 183 | + GlobalVue.use(plugin); |
| 184 | +} |
| 185 | + |
| 186 | +export default __vue_component__; |
| 187 | +export { install }; |
0 commit comments