'use strict';Object.defineProperty(exports,'__esModule',{value:true});var VGrid=require('@revolist/vue-datagrid'),Vue=require('vue'),VGridDate=require('@revolist/revogrid-column-date'),NumberColumnType=require('@revolist/revogrid-column-numeral');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var VGrid__default=/*#__PURE__*/_interopDefaultLegacy(VGrid);var Vue__default=/*#__PURE__*/_interopDefaultLegacy(Vue);var VGridDate__default=/*#__PURE__*/_interopDefaultLegacy(VGridDate);var NumberColumnType__default=/*#__PURE__*/_interopDefaultLegacy(NumberColumnType);//
// import NumberColumnType from "@revolist/revogrid-column-numeral"; // columnType: 'number'
/**
 * @group Table
 */
var script$2 = {
  name: "DataGrid",
  components: {
    VGrid: VGrid__default["default"],
  },
  props: {
    columns: {
      type: Array,
      default: function default$1() {
        return [];
      },
    },
    rows: {
      type: Array,
      default: function default$2() {
        return [];
      },
    },
  },
  data: function data() {
    return {
      columnTypes: {
        // number: new NumberColumnType("0,0"),
      },
    };
  },
};function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
    if (typeof shadowMode !== 'boolean') {
        createInjectorSSR = createInjector;
        createInjector = shadowMode;
        shadowMode = false;
    }
    // Vue.extend constructor export interop.
    var options = typeof script === 'function' ? script.options : script;
    // render functions
    if (template && template.render) {
        options.render = template.render;
        options.staticRenderFns = template.staticRenderFns;
        options._compiled = true;
        // functional template
        if (isFunctionalTemplate) {
            options.functional = true;
        }
    }
    // scopedId
    if (scopeId) {
        options._scopeId = scopeId;
    }
    var hook;
    if (moduleIdentifier) {
        // server build
        hook = function (context) {
            // 2.3 injection
            context =
                context || // cached call
                    (this.$vnode && this.$vnode.ssrContext) || // stateful
                    (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
            // 2.2 with runInNewContext: true
            if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
                context = __VUE_SSR_CONTEXT__;
            }
            // inject component styles
            if (style) {
                style.call(this, createInjectorSSR(context));
            }
            // register component module identifier for async chunk inference
            if (context && context._registeredComponents) {
                context._registeredComponents.add(moduleIdentifier);
            }
        };
        // used by ssr in case component is cached and beforeCreate
        // never gets called
        options._ssrRegister = hook;
    }
    else if (style) {
        hook = shadowMode
            ? function (context) {
                style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
            }
            : function (context) {
                style.call(this, createInjector(context));
            };
    }
    if (hook) {
        if (options.functional) {
            // register for functional component in vue file
            var originalRender = options.render;
            options.render = function renderWithStyleInjection(h, context) {
                hook.call(context);
                return originalRender(h, context);
            };
        }
        else {
            // inject component registration as beforeCreate hook
            var existing = options.beforeCreate;
            options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
        }
    }
    return script;
}/* script */
var __vue_script__$2 = script$2;

/* template */
var __vue_render__$2 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"w-full border"},[_c('v-grid',_vm._b({attrs:{"theme":"compact","columnTypes":_vm.columnTypes,"source":_vm.rows,"columns":_vm.columns}},'v-grid',_vm.$attrs,false))],1)};
var __vue_staticRenderFns__$2 = [];

  /* style */
  var __vue_inject_styles__$2 = undefined;
  /* scoped */
  var __vue_scope_id__$2 = undefined;
  /* module identifier */
  var __vue_module_identifier__$2 = "data-v-dfd97a2e";
  /* functional template */
  var __vue_is_functional_template__$2 = false;
  /* style inject */
  
  /* style inject SSR */
  
  /* style inject shadow dom */
  

  
  var __vue_component__$2 = /*#__PURE__*/normalizeComponent(
    { render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 },
    __vue_inject_styles__$2,
    __vue_script__$2,
    __vue_scope_id__$2,
    __vue_is_functional_template__$2,
    __vue_module_identifier__$2,
    false,
    undefined,
    undefined,
    undefined
  );//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//

var script$1 = {
  props: ["rowIndex", "prop", "column", "model", "close", "save"],
  data: function data() {
    return {
      valid: true,
    };
  },
  mounted: function mounted() {
    var this$1$1 = this;

    this.$nextTick(function () { return this$1$1.focusInput(); });
  },
  computed: {
    vinValue: function vinValue() {
      return this.model[this.prop];
    },
    isValid: function isValid() {
      if (this.valid) {
        return true;
      }
      return false;
    },
  },
  methods: {
    focusInput: function focusInput() {
      this.$refs.vin.focus();
    },

    validateVin: function validateVin(event) {
      var re = new RegExp(
        "^[A-HJ-NPR-Z\\d]{8}[\\dX][A-HJ-NPR-Z\\d]{2}\\d{6}$"
      );
      console.log(event.target.value.match(re));
      this.valid = event.target.value.match(re);
      console.log(this.isValid);
      return event.target.value.match(re);
    },
    updateVIN: function updateVIN(event) {
      if (this.isValid) {
        this.model[this.prop] = event.target.value;
        this.save(event.target.value);
      }
      // else {
      //   event.stopPropagation();
      //   this.closeEditor(event);
      // }
    },
    closeEditor: function closeEditor(event) {
      console.log("close object :>> ", event);
      // event.target.value = this.model[this.prop];
      // this.close();
    },
  },
};/* script */
var __vue_script__$1 = script$1;
/* template */
var __vue_render__$1 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"absolute w-full shadow-lg rounded-b ring-inset h-auto ring p-1 ring-blue-400"},[_vm._ssrNode("<input"+(_vm._ssrAttr("value",(_vm.model[_vm.prop])))+(_vm._ssrClass("w-full outline-none px-3 py-1",{ isValid : _vm.isValid }))+"> <div class=\"bg-red-100 mt-1 text-xs px-3 py-2 text-red-700\""+(_vm._ssrStyle(null,null, { display: (!_vm.isValid) ? '' : 'none' }))+">The value is not valid VIN</div>")])};
var __vue_staticRenderFns__$1 = [];

  /* style */
  var __vue_inject_styles__$1 = undefined;
  /* scoped */
  var __vue_scope_id__$1 = undefined;
  /* module identifier */
  var __vue_module_identifier__$1 = "data-v-a64accf4";
  /* functional template */
  var __vue_is_functional_template__$1 = false;
  /* style inject */
  
  /* style inject SSR */
  
  /* style inject shadow dom */
  

  
  var __vue_component__$1 = /*#__PURE__*/normalizeComponent(
    { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
    __vue_inject_styles__$1,
    __vue_script__$1,
    __vue_scope_id__$1,
    __vue_is_functional_template__$1,
    __vue_module_identifier__$1,
    false,
    undefined,
    undefined,
    undefined
  );//
// import Toggle2 from "@/components/hash/elements/Toggle2";
// const singleSelectEditor = VGridVueEditor(
//   Vue.component("vueEditor", singleSelectComp)
// );
// const multiSelectEditor = VGridVueEditor(
//   Vue.component("vueEditor", multiSelectComp)
// );
// const longTextEditor = VGridVueEditor(Vue.component("vueEditor", longTextComp));
var vinEditor = VGrid.VGridVueEditor(Vue__default["default"].component("vueEditor", __vue_component__$1));
// const numberEditor = VGridVueEditor(Vue.component("vueEditor", numberComp));
// const currencyEditor = VGridVueEditor(Vue.component("vueEditor", currencyComp));
// const phoneEditor = VGridVueEditor(Vue.component("vueEditor", PhoneComp));
/**
 * @group Table
 */

/**
 * A simple checkbox component
 *
 * ```html
 * <TableGrid
        :columns="getColumns"
        :rows="rows"
        resize
        filter
        range
        :readonly="false"
        :canFocus="true"
        :rowHeaders="false"
        :autoSizeColumn="{mode: 'autoSizeAll'}"
        class="border"
        style="height: 500px"
      ></TableGrid>
 * ```
 *
 */

var script = {
  name: "TableGrid",
  components: {
    "v-grid": VGrid__default["default"],
  },
  props: {
    title: {
      type: String,
      default: null,
    },
    theme: {
      type: String,
      default: "compact", //material,compact
    },
    readonly: {
      type: Boolean,
      default: true,
    },
    columns: {
      type: Array,
      required: true,
    },
    rows: {
      type: Array,
      required: true,
    },
    range: {
      type: Boolean,
      default: true,
    },
    filter: {
      type: Boolean,
      default: true,
    },
    dataTypes: {
      type: Object,
      //   default: {},
    },
    cssStyle: {
      type: String,
    },
    rowHeaders: {
      type: Boolean,
      default: true,
    },
    resize: {
      type: Boolean,
      default: true,
    },
    rowClass: {
      type: String,
      default: "rowClass",
    },
    css: {
      type: Object,
    },
  },
  data: function data() {
    return {
      gridEditors: {
        // number: numberEditor,
        // currency: currencyEditor,
        // singleSelect: singleSelectEditor,
        // longText: longTextEditor,
        // multiSelect: multiSelectEditor,
        vin: vinEditor,
        // phoneNumber: phoneEditor,
      },
      columnTypes: {
        number: new NumberColumnType__default["default"]("0,0"),
        // percentage: new NumberColumnType("0.000%"),
        currency: new NumberColumnType__default["default"]("$0,0.00"), // '$0,0[.]00'
        date: new VGridDate__default["default"](),
        // time: new NumberColumnType("00:00:00"),
        // select: new SelectTypePlugin(),
        // singleSelect: new SelectTypePlugin(),
        // multiSelect: new SelectTypePlugin(),
      },
    };
  },
  mounted: function mounted() {
    // console.log(this.$refs.tgrid.getColumns());
  },
  computed: {
    computedColumns: function computedColumns() {
      var result = this.columns.map(function (a) {
        if (a.columnType === "singleSelect") {
          a.source = ["Honda", "Volkswagen", "Mini", "Tesla", "Kia"];
          a.editor = "singleSelect";
        }
        if (a.columnType === "multiSelect") {
          a.source = ["Games", "Capacitor", "Sports", "Generic", "Landing"];
          a.editor = "multiSelect";
        }
        if (a.columnType === "checkbox") ;
        if (a.columnType === "vin") {
          a.editor = "vin";
        }
        if (a.columnType === "longText") {
          a.editor = "longText";
        }

        if (a.columnType === "currency") {
          a.editor = "currency";
          a.filter = "number";
        }
        if (a.columnType === "number") {
          a.filter = "number";
        }

        if (a.columnType === "phone") {
          a.editor = "phoneNumber";
        }

        return a;
      });
      return result;
    },
  },
  methods: {
    aftercolumnresize: function aftercolumnresize(e) {
      console.log('v-on:aftercolumnresize="aftercolumnresize"', e);
    },
    headerclick: function headerclick() {
      console.log('v-on:headerclick="headerclick"');
    },
    eventHandler: function eventHandler(e) {
      console.log("eventHandler", e.type, e);

      switch (e.type) {
        case "aftercolumnresize":
          this.$emit("col-resize", {
            type: "aftercolumnresize",
            id: e.detail[Object.getOwnPropertyNames(e.detail)[0]].id,
            field: e.detail,
            width: e.detail[Object.getOwnPropertyNames(e.detail)[0]].size,
          });
          break;

        case "afteredit":
          if (e.detail.data && e.detail.models) {
            // Multiple Edit
            console.log("Multiple Edit");
            this.$emit("row-updated", {
              type: 2,
              data: e.detail.data,
              rowData: e.detail.models,
            });
          } else {
            // Single Edit
            console.log("Single Edit");
            this.$emit("row-updated", {
              type: 1,
              data: e.detail,
              rowData: e.detail.model,
            });
          }
          break;
      }
    },
    getColumnIcon: function getColumnIcon(column) {
      switch (column.type) {
              }
      return ("" + (column.name));
    },
  },
};/* script */
var __vue_script__ = script;
/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('v-grid',_vm._g(_vm._b({ref:"tgrid",style:(_vm.cssStyle),attrs:{"theme":_vm.theme,"source":_vm.rows,"columns":_vm.computedColumns,"columnTypes":_vm.columnTypes,"resize":_vm.resize,"filter":_vm.filter,"rowClass":_vm.rowClass,"rowHeaders":_vm.rowHeaders,"exporting":true,"export":true,"range":_vm.range,"readonly":_vm.readonly,"editors":_vm.gridEditors,"useClipboard":true},on:{"aftercolumnresize":_vm.eventHandler,"headerclick":_vm.headerclick,"afteredit":_vm.eventHandler,"aftercolumnsset":_vm.eventHandler}},'v-grid',_vm.$attrs,false),_vm.$listeners))};
var __vue_staticRenderFns__ = [];

  /* style */
  var __vue_inject_styles__ = undefined;
  /* scoped */
  var __vue_scope_id__ = "data-v-473a7960";
  /* module identifier */
  var __vue_module_identifier__ = "data-v-473a7960";
  /* functional template */
  var __vue_is_functional_template__ = false;
  /* style inject */
  
  /* style inject SSR */
  
  /* style inject shadow dom */
  

  
  var __vue_component__ = /*#__PURE__*/normalizeComponent(
    { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
    __vue_inject_styles__,
    __vue_script__,
    __vue_scope_id__,
    __vue_is_functional_template__,
    __vue_module_identifier__,
    false,
    undefined,
    undefined,
    undefined
  );// The components are exported, then imported / exported in the`src/index.js` file

/**
 Example
    // src/components
    import List from './List.vue'
    import ListItem from './ListItem.vue'

    export default { List, ListItem }

    or

    // src/index.js
    export { List, ListItem } from './ListComponents'
 */var components=/*#__PURE__*/Object.freeze({__proto__:null,DataGrid:__vue_component__$2,TableGrid:__vue_component__});// Import vue components

var ComponentLibrary = {
  /**
   * A Vue.js plugin should expose an install method…The method will be called with the Vue constructor as the first argument, along with possible options
   * Merge user-defined options into the plugin registration with options = {}
   */
  // install(Vue, options = {}) { //for components option customization
  install: function install(Vue) {
    // components
    for (var componentName in components) {
      var component = components[componentName];
      if (component.name) {
        Vue.component(component.name, component);
      } else {
        console.error('H8 component name error');
      }

    }
  }
};


// Auto-install when vue is found (eg. in browser via <script> tag)
var GlobalVue = null;
if (typeof window !== 'undefined') {
  GlobalVue = window.Vue;
} else if (typeof global !== 'undefined') {
  GlobalVue = global.Vue;
}
if (GlobalVue) {
  GlobalVue.use(ComponentLibrary);
}exports.DataGrid=__vue_component__$2;exports.TableGrid=__vue_component__;exports["default"]=ComponentLibrary;//# sourceMappingURL=h8-ui-table.ssr.js.map
