tg-controls_cli 0.0.8 → 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.
@@ -22248,6 +22248,17 @@ module.exports = JSON.parse("{\"code\":\"sk\",\"messages\":{\"alpha\":\"{_field_
22248
22248
 
22249
22249
  // extracted by mini-css-extract-plugin
22250
22250
 
22251
+ /***/ }),
22252
+
22253
+ /***/ "719a":
22254
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
22255
+
22256
+ "use strict";
22257
+ /* 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");
22258
+ /* 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__);
22259
+ /* unused harmony reexport * */
22260
+
22261
+
22251
22262
  /***/ }),
22252
22263
 
22253
22264
  /***/ "7234":
@@ -22326,6 +22337,13 @@ module.exports = function (argument) {
22326
22337
  };
22327
22338
 
22328
22339
 
22340
+ /***/ }),
22341
+
22342
+ /***/ "836d":
22343
+ /***/ (function(module, exports, __webpack_require__) {
22344
+
22345
+ // extracted by mini-css-extract-plugin
22346
+
22329
22347
  /***/ }),
22330
22348
 
22331
22349
  /***/ "83ab":
@@ -28982,78 +29000,55 @@ var ColorField_component = normalizeComponent(
28982
29000
  )
28983
29001
 
28984
29002
  /* harmony default export */ var ColorField = (ColorField_component.exports);
28985
- // 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=9506f218&
28986
- var FileFieldvue_type_template_id_9506f218_render = function render() {
29003
+ // 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&
29004
+ var FileFieldvue_type_template_id_6aec890d_scoped_true_render = function render() {
28987
29005
  var _vm = this,
28988
29006
  _c = _vm._self._c;
28989
- return _c('Field', {
28990
- staticClass: "w-100",
29007
+ return _c('div', {
29008
+ staticClass: "file-upload"
29009
+ }, [_c('div', {
29010
+ staticClass: "file-upload__area"
29011
+ }, [_c('div', [_c('input', {
28991
29012
  attrs: {
28992
- "name": _vm.fieldInfo.name,
28993
- "rules": _vm.fieldInfo.validationRules,
28994
- "label": _vm.fieldInfo.label
29013
+ "type": "file",
29014
+ "id": "customFile",
29015
+ "disabled": _vm.fieldInfo.disabled,
29016
+ "multiple": _vm.canUploadMultipleFile()
28995
29017
  },
28996
- scopedSlots: _vm._u([{
28997
- key: "default",
28998
- fn: function ({
28999
- errors
29000
- }) {
29001
- return [_c('div', {
29002
- class: {
29003
- 'custom-file from-control': true,
29004
- 'is-invalid': errors[0]
29005
- }
29006
- }, [_c('input', {
29007
- staticClass: "custom-file-input w-100",
29008
- attrs: {
29009
- "type": "file",
29010
- "disabled": _vm.fieldInfo.disabled,
29011
- "id": "customFile",
29012
- "multiple": _vm.canUploadMultipleFile()
29013
- },
29014
- on: {
29015
- "change": function ($event) {
29016
- return _vm.onChange($event);
29017
- },
29018
- "input": function ($event) {
29019
- return _vm.onInput($event);
29020
- }
29021
- }
29022
- }), _c('label', {
29023
- staticClass: "custom-file-label",
29024
- attrs: {
29025
- "for": "customFile"
29026
- }
29027
- }, [_vm._v(_vm._s(_vm.fileName))])]), _vm.showAddIcon() ? _c('div', {
29028
- staticClass: "ml-2 mt-1"
29029
- }, [_c('a', {
29030
- class: _vm.addButtonClass()
29031
- }, [_c('i', {
29032
- class: _vm.addIconClass(),
29033
- attrs: {
29034
- "alt": "+"
29035
- },
29036
- on: {
29037
- "click": function ($event) {
29038
- return _vm.onAddButtonClick($event);
29039
- }
29040
- }
29041
- })])]) : _vm._e(), errors[0] ? _c('span', {
29042
- staticClass: "invalid-feedback",
29043
- attrs: {
29044
- "name": _vm.fieldInfo.name
29045
- }
29046
- }, [_vm._v(_vm._s(errors[0]))]) : _vm._e()];
29047
- }
29048
- }])
29049
- });
29018
+ on: {
29019
+ "change": function ($event) {
29020
+ return _vm.onChange($event);
29021
+ }
29022
+ }
29023
+ }), _vm.errors.length > 0 ? _c('div', _vm._l(_vm.errors, function (error, index) {
29024
+ return _c('div', {
29025
+ key: index,
29026
+ staticClass: "file-upload__error"
29027
+ }, [_c('span', [_vm._v(_vm._s(error))])]);
29028
+ }), 0) : _vm._e()]), _vm._l(_vm.previewFiles, function (file, index) {
29029
+ return _c('div', {
29030
+ key: index,
29031
+ staticClass: "upload-preview"
29032
+ }, [file.isImage ? _c('img', {
29033
+ staticClass: "file-image",
29034
+ attrs: {
29035
+ "src": file.url,
29036
+ "alt": ""
29037
+ }
29038
+ }) : _vm._e(), !file.isImage ? _c('div', {
29039
+ staticClass: "file-extention"
29040
+ }, [_vm._v(" " + _vm._s(file.fileExtention) + " ")]) : _vm._e(), _c('span', {
29041
+ staticClass: "file-name"
29042
+ }, [_vm._v(" " + _vm._s(file.name) + _vm._s(file.isImage ? `.${file.fileExtention}` : "") + " ")])]);
29043
+ })], 2)]);
29050
29044
  };
29051
- var FileFieldvue_type_template_id_9506f218_staticRenderFns = [];
29045
+ var FileFieldvue_type_template_id_6aec890d_scoped_true_staticRenderFns = [];
29052
29046
 
29053
- // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=template&id=9506f218&
29047
+ // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=template&id=6aec890d&scoped=true&
29054
29048
 
29055
29049
  // 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&
29056
29050
 
29051
+
29057
29052
  /* harmony default export */ var FileFieldvue_type_script_lang_js_ = ({
29058
29053
  components: {
29059
29054
  Field: ValidationProvider
@@ -29070,7 +29065,19 @@ var FileFieldvue_type_template_id_9506f218_staticRenderFns = [];
29070
29065
  },
29071
29066
  data: function () {
29072
29067
  return {
29073
- fileName: "Choose File"
29068
+ maxSize: 0,
29069
+ accept: '',
29070
+ errors: [],
29071
+ file: {
29072
+ name: "",
29073
+ size: 0,
29074
+ type: "",
29075
+ fileExtention: "",
29076
+ url: "",
29077
+ isImage: false,
29078
+ isUploaded: false
29079
+ },
29080
+ previewFiles: []
29074
29081
  };
29075
29082
  },
29076
29083
  mounted: function () {
@@ -29078,40 +29085,83 @@ var FileFieldvue_type_template_id_9506f218_staticRenderFns = [];
29078
29085
  if (this.fieldInfo.placeholder) {
29079
29086
  this.fileName = this.fieldInfo.placeholder;
29080
29087
  }
29088
+ if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.hasOwnProperty('maxSize')) {
29089
+ this.maxSize = this.fieldInfo.config.maxSize;
29090
+ }
29091
+ if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.hasOwnProperty('accept')) {
29092
+ this.accept = this.fieldInfo.config.accept;
29093
+ }
29081
29094
  },
29082
29095
  methods: {
29083
- onChange: function (e) {
29084
- if (e.target.files.length > 0) {
29085
- this.fileName = e.target.files[0].name;
29086
- }
29087
- this.fieldInfo.value = e.target.files;
29088
- if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.onChange) {
29089
- this.fieldInfo.config.onChange(e, this.fieldInfo);
29090
- }
29091
- },
29092
- onInput: function (e) {},
29093
- showAddIcon: function () {
29094
- if (this.fieldInfo.config && this.fieldInfo.config.showAddIcon) {
29095
- return this.fieldInfo.config.showAddIcon;
29096
+ onChange(e) {
29097
+ this.errors = [];
29098
+ // Check if file is selected
29099
+ if (e.target.files && e.target.files[0]) {
29100
+ // Check if file is valid
29101
+ for (let index = 0; index < e.target.files.length; index++) {
29102
+ const file = e.target.files[index];
29103
+ if (this.isFileValid(file)) {
29104
+ // Get uploaded file
29105
+ // Get file size
29106
+ var fileSize = Math.round(file.size / 1024 / 1024 * 100) / 100;
29107
+ // Get file extention
29108
+ var fileExtention = file.name.split(".").pop();
29109
+ // Get file name
29110
+ var fileName = file.name.split(".").shift();
29111
+ // Check if file is an image
29112
+ var isImage = ["jpg", "jpeg", "png", "gif"].includes(fileExtention);
29113
+ // Print to console
29114
+ console.log(fileSize, fileExtention, fileName, isImage);
29115
+ // Load the FileReader API
29116
+ let reader = new FileReader();
29117
+ reader.addEventListener("load", () => {
29118
+ // Set file data
29119
+ this.file = {
29120
+ name: fileName,
29121
+ size: fileSize,
29122
+ type: file.type,
29123
+ fileExtention: fileExtention,
29124
+ isImage: isImage,
29125
+ url: reader.result,
29126
+ isUploaded: true
29127
+ };
29128
+ this.previewFiles.push(this.file);
29129
+ }, false);
29130
+ // Read uploaded file
29131
+ reader.readAsDataURL(file);
29132
+ } else {
29133
+ console.log("Invalid file");
29134
+ }
29135
+ }
29136
+ if (this.errors.length == 0) {
29137
+ this.fieldInfo.value = e.target.files;
29138
+ if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.onChange) {
29139
+ this.fieldInfo.config.onChange(e, this.fieldInfo);
29140
+ }
29141
+ }
29096
29142
  }
29097
29143
  },
29098
- onAddButtonClick: function (e) {
29099
- if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.onAddButtonClick) {
29100
- this.fieldInfo.config.onAddButtonClick(e, this.fieldInfo);
29144
+ isFileSizeValid(fileSize) {
29145
+ if (fileSize <= this.maxSize) {
29146
+ console.log("File size is valid");
29147
+ } else {
29148
+ this.errors.push(`File size should be less than ${this.maxSize} MB`);
29101
29149
  }
29102
29150
  },
29103
- addButtonClass: function () {
29104
- if (this.fieldInfo.config && this.fieldInfo.config.addIconBackground) {
29105
- return "round-icon-small theme-primary " + this.fieldInfo.config.addIconBackground;
29151
+ isFileTypeValid(fileExtention) {
29152
+ if (this.accept.split(",").includes(fileExtention)) {
29153
+ console.log("File type is valid");
29106
29154
  } else {
29107
- return "round-icon-small btn-dark theme-primary";
29155
+ this.errors.push(`File type should be ${this.accept}`);
29108
29156
  }
29109
29157
  },
29110
- addIconClass: function () {
29111
- if (this.fieldInfo.config && this.fieldInfo.config.addIcon) {
29112
- return "fa text-white pt-7 font-18 " + this.fieldInfo.config.addIcon;
29158
+ isFileValid(file) {
29159
+ this.isFileSizeValid(Math.round(file.size / 1024 / 1024 * 100) / 100);
29160
+ this.isFileTypeValid(file.name.split(".").pop());
29161
+ if (this.errors.length === 0) {
29162
+ return true;
29113
29163
  } else {
29114
- return "fa fa-plus text-white pt-7 font-18";
29164
+ return false;
29115
29165
  }
29116
29166
  },
29117
29167
  canUploadMultipleFile() {
@@ -29124,21 +29174,25 @@ var FileFieldvue_type_template_id_9506f218_staticRenderFns = [];
29124
29174
  });
29125
29175
  // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=script&lang=js&
29126
29176
  /* harmony default export */ var components_FileFieldvue_type_script_lang_js_ = (FileFieldvue_type_script_lang_js_);
29177
+ // EXTERNAL MODULE: ./src/components/FileField.vue?vue&type=style&index=0&id=6aec890d&prod&scoped=true&lang=css&
29178
+ var FileFieldvue_type_style_index_0_id_6aec890d_prod_scoped_true_lang_css_ = __webpack_require__("719a");
29179
+
29127
29180
  // CONCATENATED MODULE: ./src/components/FileField.vue
29128
29181
 
29129
29182
 
29130
29183
 
29131
29184
 
29132
29185
 
29186
+
29133
29187
  /* normalize component */
29134
29188
 
29135
29189
  var FileField_component = normalizeComponent(
29136
29190
  components_FileFieldvue_type_script_lang_js_,
29137
- FileFieldvue_type_template_id_9506f218_render,
29138
- FileFieldvue_type_template_id_9506f218_staticRenderFns,
29191
+ FileFieldvue_type_template_id_6aec890d_scoped_true_render,
29192
+ FileFieldvue_type_template_id_6aec890d_scoped_true_staticRenderFns,
29139
29193
  false,
29140
29194
  null,
29141
- null,
29195
+ "6aec890d",
29142
29196
  null
29143
29197
 
29144
29198
  )