tg-controls_cli 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/myLib.umd.js CHANGED
@@ -22257,6 +22257,17 @@ module.exports = JSON.parse("{\"code\":\"sk\",\"messages\":{\"alpha\":\"{_field_
22257
22257
 
22258
22258
  // extracted by mini-css-extract-plugin
22259
22259
 
22260
+ /***/ }),
22261
+
22262
+ /***/ "719a":
22263
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
22264
+
22265
+ "use strict";
22266
+ /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_FileField_vue_vue_type_style_index_0_id_6aec890d_prod_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("836d");
22267
+ /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_FileField_vue_vue_type_style_index_0_id_6aec890d_prod_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_7_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_7_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_7_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_lib_index_js_vue_loader_options_FileField_vue_vue_type_style_index_0_id_6aec890d_prod_scoped_true_lang_css___WEBPACK_IMPORTED_MODULE_0__);
22268
+ /* unused harmony reexport * */
22269
+
22270
+
22260
22271
  /***/ }),
22261
22272
 
22262
22273
  /***/ "7234":
@@ -22335,6 +22346,13 @@ module.exports = function (argument) {
22335
22346
  };
22336
22347
 
22337
22348
 
22349
+ /***/ }),
22350
+
22351
+ /***/ "836d":
22352
+ /***/ (function(module, exports, __webpack_require__) {
22353
+
22354
+ // extracted by mini-css-extract-plugin
22355
+
22338
22356
  /***/ }),
22339
22357
 
22340
22358
  /***/ "83ab":
@@ -27378,14 +27396,12 @@ var component = normalizeComponent(
27378
27396
  )
27379
27397
 
27380
27398
  /* harmony default export */ var NumericField = (component.exports);
27381
- // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"c1dfe90e-vue-loader-template"}!./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/SelectField.vue?vue&type=template&id=6a915f0b&
27382
- var SelectFieldvue_type_template_id_6a915f0b_render = function render() {
27399
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"c1dfe90e-vue-loader-template"}!./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/SelectField.vue?vue&type=template&id=5f764756&
27400
+ var SelectFieldvue_type_template_id_5f764756_render = function render() {
27383
27401
  var _vm = this,
27384
27402
  _c = _vm._self._c;
27385
- return _c('div', {
27386
- staticClass: "w-100 d-flex"
27387
- }, [_c('Field', {
27388
- staticClass: "w-100",
27403
+ return _c('Field', {
27404
+ staticClass: "d-flex w-100",
27389
27405
  attrs: {
27390
27406
  "name": _vm.fieldInfo.name,
27391
27407
  "rules": _vm.fieldInfo.validationRules,
@@ -27454,11 +27470,11 @@ var SelectFieldvue_type_template_id_6a915f0b_render = function render() {
27454
27470
  }, [_vm._v(_vm._s(errors[0]))]) : _vm._e()];
27455
27471
  }
27456
27472
  }])
27457
- })], 1);
27473
+ });
27458
27474
  };
27459
- var SelectFieldvue_type_template_id_6a915f0b_staticRenderFns = [];
27475
+ var SelectFieldvue_type_template_id_5f764756_staticRenderFns = [];
27460
27476
 
27461
- // CONCATENATED MODULE: ./src/components/SelectField.vue?vue&type=template&id=6a915f0b&
27477
+ // CONCATENATED MODULE: ./src/components/SelectField.vue?vue&type=template&id=5f764756&
27462
27478
 
27463
27479
  // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/SelectField.vue?vue&type=script&lang=js&
27464
27480
 
@@ -27533,8 +27549,8 @@ var SelectFieldvue_type_template_id_6a915f0b_staticRenderFns = [];
27533
27549
 
27534
27550
  var SelectField_component = normalizeComponent(
27535
27551
  components_SelectFieldvue_type_script_lang_js_,
27536
- SelectFieldvue_type_template_id_6a915f0b_render,
27537
- SelectFieldvue_type_template_id_6a915f0b_staticRenderFns,
27552
+ SelectFieldvue_type_template_id_5f764756_render,
27553
+ SelectFieldvue_type_template_id_5f764756_staticRenderFns,
27538
27554
  false,
27539
27555
  null,
27540
27556
  null,
@@ -28993,77 +29009,55 @@ var ColorField_component = normalizeComponent(
28993
29009
  )
28994
29010
 
28995
29011
  /* harmony default export */ var ColorField = (ColorField_component.exports);
28996
- // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"c1dfe90e-vue-loader-template"}!./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/FileField.vue?vue&type=template&id=3677443c&
28997
- var FileFieldvue_type_template_id_3677443c_render = function render() {
29012
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"c1dfe90e-vue-loader-template"}!./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--6!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/FileField.vue?vue&type=template&id=6aec890d&scoped=true&
29013
+ var FileFieldvue_type_template_id_6aec890d_scoped_true_render = function render() {
28998
29014
  var _vm = this,
28999
29015
  _c = _vm._self._c;
29000
- return _c('Field', {
29001
- staticClass: "w-100",
29016
+ return _c('div', {
29017
+ staticClass: "file-upload"
29018
+ }, [_c('div', {
29019
+ staticClass: "file-upload__area"
29020
+ }, [_c('div', [_c('input', {
29002
29021
  attrs: {
29003
- "name": _vm.fieldInfo.name,
29004
- "rules": _vm.fieldInfo.validationRules,
29005
- "label": _vm.fieldInfo.label
29022
+ "type": "file",
29023
+ "id": "customFile",
29024
+ "disabled": _vm.fieldInfo.disabled,
29025
+ "multiple": _vm.canUploadMultipleFile()
29006
29026
  },
29007
- scopedSlots: _vm._u([{
29008
- key: "default",
29009
- fn: function ({
29010
- errors
29011
- }) {
29012
- return [_c('div', {
29013
- class: {
29014
- 'custom-file from-control': true,
29015
- 'is-invalid': errors[0]
29016
- }
29017
- }, [_c('input', {
29018
- staticClass: "custom-file-input w-100",
29019
- attrs: {
29020
- "type": "file",
29021
- "disabled": _vm.fieldInfo.disabled,
29022
- "id": "customFile"
29023
- },
29024
- on: {
29025
- "change": function ($event) {
29026
- return _vm.onChange($event);
29027
- },
29028
- "input": function ($event) {
29029
- return _vm.onInput($event);
29030
- }
29031
- }
29032
- }), _c('label', {
29033
- staticClass: "custom-file-label",
29034
- attrs: {
29035
- "for": "customFile"
29036
- }
29037
- }, [_vm._v(_vm._s(_vm.fileName))])]), _vm.showAddIcon() ? _c('div', {
29038
- staticClass: "ml-2 mt-1"
29039
- }, [_c('a', {
29040
- class: _vm.addButtonClass()
29041
- }, [_c('i', {
29042
- class: _vm.addIconClass(),
29043
- attrs: {
29044
- "alt": "+"
29045
- },
29046
- on: {
29047
- "click": function ($event) {
29048
- return _vm.onAddButtonClick($event);
29049
- }
29050
- }
29051
- })])]) : _vm._e(), errors[0] ? _c('span', {
29052
- staticClass: "invalid-feedback",
29053
- attrs: {
29054
- "name": _vm.fieldInfo.name
29055
- }
29056
- }, [_vm._v(_vm._s(errors[0]))]) : _vm._e()];
29057
- }
29058
- }])
29059
- });
29027
+ on: {
29028
+ "change": function ($event) {
29029
+ return _vm.onChange($event);
29030
+ }
29031
+ }
29032
+ }), _vm.errors.length > 0 ? _c('div', _vm._l(_vm.errors, function (error, index) {
29033
+ return _c('div', {
29034
+ key: index,
29035
+ staticClass: "file-upload__error"
29036
+ }, [_c('span', [_vm._v(_vm._s(error))])]);
29037
+ }), 0) : _vm._e()]), _vm._l(_vm.previewFiles, function (file, index) {
29038
+ return _c('div', {
29039
+ key: index,
29040
+ staticClass: "upload-preview"
29041
+ }, [file.isImage ? _c('img', {
29042
+ staticClass: "file-image",
29043
+ attrs: {
29044
+ "src": file.url,
29045
+ "alt": ""
29046
+ }
29047
+ }) : _vm._e(), !file.isImage ? _c('div', {
29048
+ staticClass: "file-extention"
29049
+ }, [_vm._v(" " + _vm._s(file.fileExtention) + " ")]) : _vm._e(), _c('span', {
29050
+ staticClass: "file-name"
29051
+ }, [_vm._v(" " + _vm._s(file.name) + _vm._s(file.isImage ? `.${file.fileExtention}` : "") + " ")])]);
29052
+ })], 2)]);
29060
29053
  };
29061
- var FileFieldvue_type_template_id_3677443c_staticRenderFns = [];
29054
+ var FileFieldvue_type_template_id_6aec890d_scoped_true_staticRenderFns = [];
29062
29055
 
29063
- // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=template&id=3677443c&
29056
+ // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=template&id=6aec890d&scoped=true&
29064
29057
 
29065
29058
  // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/FileField.vue?vue&type=script&lang=js&
29066
29059
 
29060
+
29067
29061
  /* harmony default export */ var FileFieldvue_type_script_lang_js_ = ({
29068
29062
  components: {
29069
29063
  Field: ValidationProvider
@@ -29080,7 +29074,19 @@ var FileFieldvue_type_template_id_3677443c_staticRenderFns = [];
29080
29074
  },
29081
29075
  data: function () {
29082
29076
  return {
29083
- fileName: "Choose File"
29077
+ maxSize: 0,
29078
+ accept: '',
29079
+ errors: [],
29080
+ file: {
29081
+ name: "",
29082
+ size: 0,
29083
+ type: "",
29084
+ fileExtention: "",
29085
+ url: "",
29086
+ isImage: false,
29087
+ isUploaded: false
29088
+ },
29089
+ previewFiles: []
29084
29090
  };
29085
29091
  },
29086
29092
  mounted: function () {
@@ -29088,61 +29094,114 @@ var FileFieldvue_type_template_id_3677443c_staticRenderFns = [];
29088
29094
  if (this.fieldInfo.placeholder) {
29089
29095
  this.fileName = this.fieldInfo.placeholder;
29090
29096
  }
29097
+ if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.hasOwnProperty('maxSize')) {
29098
+ this.maxSize = this.fieldInfo.config.maxSize;
29099
+ }
29100
+ if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.hasOwnProperty('accept')) {
29101
+ this.accept = this.fieldInfo.config.accept;
29102
+ }
29091
29103
  },
29092
29104
  methods: {
29093
- onChange: function (e) {
29094
- if (e.target.files.length > 0) {
29095
- this.fileName = e.target.files[0].name;
29096
- }
29097
- this.fieldInfo.value = e.target.files;
29098
- if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.onChange) {
29099
- this.fieldInfo.config.onChange(e, this.fieldInfo);
29105
+ onChange(e) {
29106
+ this.errors = [];
29107
+ // Check if file is selected
29108
+ if (e.target.files && e.target.files[0]) {
29109
+ // Check if file is valid
29110
+ for (let index = 0; index < e.target.files.length; index++) {
29111
+ const file = e.target.files[index];
29112
+ if (this.isFileValid(file)) {
29113
+ // Get uploaded file
29114
+ // Get file size
29115
+ var fileSize = Math.round(file.size / 1024 / 1024 * 100) / 100;
29116
+ // Get file extention
29117
+ var fileExtention = file.name.split(".").pop();
29118
+ // Get file name
29119
+ var fileName = file.name.split(".").shift();
29120
+ // Check if file is an image
29121
+ var isImage = ["jpg", "jpeg", "png", "gif"].includes(fileExtention);
29122
+ // Print to console
29123
+ console.log(fileSize, fileExtention, fileName, isImage);
29124
+ // Load the FileReader API
29125
+ let reader = new FileReader();
29126
+ reader.addEventListener("load", () => {
29127
+ // Set file data
29128
+ this.file = {
29129
+ name: fileName,
29130
+ size: fileSize,
29131
+ type: file.type,
29132
+ fileExtention: fileExtention,
29133
+ isImage: isImage,
29134
+ url: reader.result,
29135
+ isUploaded: true
29136
+ };
29137
+ this.previewFiles.push(this.file);
29138
+ }, false);
29139
+ // Read uploaded file
29140
+ reader.readAsDataURL(file);
29141
+ } else {
29142
+ console.log("Invalid file");
29143
+ }
29144
+ }
29145
+ if (this.errors.length == 0) {
29146
+ this.fieldInfo.value = e.target.files;
29147
+ if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.onChange) {
29148
+ this.fieldInfo.config.onChange(e, this.fieldInfo);
29149
+ }
29150
+ }
29100
29151
  }
29101
29152
  },
29102
- onInput: function (e) {},
29103
- showAddIcon: function () {
29104
- if (this.fieldInfo.config && this.fieldInfo.config.showAddIcon) {
29105
- return this.fieldInfo.config.showAddIcon;
29153
+ isFileSizeValid(fileSize) {
29154
+ if (fileSize <= this.maxSize) {
29155
+ console.log("File size is valid");
29156
+ } else {
29157
+ this.errors.push(`File size should be less than ${this.maxSize} MB`);
29106
29158
  }
29107
29159
  },
29108
- onAddButtonClick: function (e) {
29109
- if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.onAddButtonClick) {
29110
- this.fieldInfo.config.onAddButtonClick(e, this.fieldInfo);
29160
+ isFileTypeValid(fileExtention) {
29161
+ if (this.accept.split(",").includes(fileExtention)) {
29162
+ console.log("File type is valid");
29163
+ } else {
29164
+ this.errors.push(`File type should be ${this.accept}`);
29111
29165
  }
29112
29166
  },
29113
- addButtonClass: function () {
29114
- if (this.fieldInfo.config && this.fieldInfo.config.addIconBackground) {
29115
- return "round-icon-small theme-primary " + this.fieldInfo.config.addIconBackground;
29167
+ isFileValid(file) {
29168
+ this.isFileSizeValid(Math.round(file.size / 1024 / 1024 * 100) / 100);
29169
+ this.isFileTypeValid(file.name.split(".").pop());
29170
+ if (this.errors.length === 0) {
29171
+ return true;
29116
29172
  } else {
29117
- return "round-icon-small btn-dark theme-primary";
29173
+ return false;
29118
29174
  }
29119
29175
  },
29120
- addIconClass: function () {
29121
- if (this.fieldInfo.config && this.fieldInfo.config.addIcon) {
29122
- return "fa text-white pt-7 font-18 " + this.fieldInfo.config.addIcon;
29123
- } else {
29124
- return "fa fa-plus text-white pt-7 font-18";
29176
+ canUploadMultipleFile() {
29177
+ if (this.fieldInfo.config && this.fieldInfo.config.hasOwnProperty('multiple')) {
29178
+ return this.fieldInfo.config.multiple;
29125
29179
  }
29180
+ return false;
29126
29181
  }
29127
29182
  }
29128
29183
  });
29129
29184
  // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=script&lang=js&
29130
29185
  /* harmony default export */ var components_FileFieldvue_type_script_lang_js_ = (FileFieldvue_type_script_lang_js_);
29186
+ // EXTERNAL MODULE: ./src/components/FileField.vue?vue&type=style&index=0&id=6aec890d&prod&scoped=true&lang=css&
29187
+ var FileFieldvue_type_style_index_0_id_6aec890d_prod_scoped_true_lang_css_ = __webpack_require__("719a");
29188
+
29131
29189
  // CONCATENATED MODULE: ./src/components/FileField.vue
29132
29190
 
29133
29191
 
29134
29192
 
29135
29193
 
29136
29194
 
29195
+
29137
29196
  /* normalize component */
29138
29197
 
29139
29198
  var FileField_component = normalizeComponent(
29140
29199
  components_FileFieldvue_type_script_lang_js_,
29141
- FileFieldvue_type_template_id_3677443c_render,
29142
- FileFieldvue_type_template_id_3677443c_staticRenderFns,
29200
+ FileFieldvue_type_template_id_6aec890d_scoped_true_render,
29201
+ FileFieldvue_type_template_id_6aec890d_scoped_true_staticRenderFns,
29143
29202
  false,
29144
29203
  null,
29145
- null,
29204
+ "6aec890d",
29146
29205
  null
29147
29206
 
29148
29207
  )