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