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.
@@ -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":
@@ -27369,14 +27387,12 @@ var component = normalizeComponent(
27369
27387
  )
27370
27388
 
27371
27389
  /* harmony default export */ var NumericField = (component.exports);
27372
- // 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&
27373
- var SelectFieldvue_type_template_id_6a915f0b_render = function render() {
27390
+ // 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&
27391
+ var SelectFieldvue_type_template_id_5f764756_render = function render() {
27374
27392
  var _vm = this,
27375
27393
  _c = _vm._self._c;
27376
- return _c('div', {
27377
- staticClass: "w-100 d-flex"
27378
- }, [_c('Field', {
27379
- staticClass: "w-100",
27394
+ return _c('Field', {
27395
+ staticClass: "d-flex w-100",
27380
27396
  attrs: {
27381
27397
  "name": _vm.fieldInfo.name,
27382
27398
  "rules": _vm.fieldInfo.validationRules,
@@ -27445,11 +27461,11 @@ var SelectFieldvue_type_template_id_6a915f0b_render = function render() {
27445
27461
  }, [_vm._v(_vm._s(errors[0]))]) : _vm._e()];
27446
27462
  }
27447
27463
  }])
27448
- })], 1);
27464
+ });
27449
27465
  };
27450
- var SelectFieldvue_type_template_id_6a915f0b_staticRenderFns = [];
27466
+ var SelectFieldvue_type_template_id_5f764756_staticRenderFns = [];
27451
27467
 
27452
- // CONCATENATED MODULE: ./src/components/SelectField.vue?vue&type=template&id=6a915f0b&
27468
+ // CONCATENATED MODULE: ./src/components/SelectField.vue?vue&type=template&id=5f764756&
27453
27469
 
27454
27470
  // 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&
27455
27471
 
@@ -27524,8 +27540,8 @@ var SelectFieldvue_type_template_id_6a915f0b_staticRenderFns = [];
27524
27540
 
27525
27541
  var SelectField_component = normalizeComponent(
27526
27542
  components_SelectFieldvue_type_script_lang_js_,
27527
- SelectFieldvue_type_template_id_6a915f0b_render,
27528
- SelectFieldvue_type_template_id_6a915f0b_staticRenderFns,
27543
+ SelectFieldvue_type_template_id_5f764756_render,
27544
+ SelectFieldvue_type_template_id_5f764756_staticRenderFns,
27529
27545
  false,
27530
27546
  null,
27531
27547
  null,
@@ -28984,77 +29000,55 @@ var ColorField_component = normalizeComponent(
28984
29000
  )
28985
29001
 
28986
29002
  /* harmony default export */ var ColorField = (ColorField_component.exports);
28987
- // 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&
28988
- var FileFieldvue_type_template_id_3677443c_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() {
28989
29005
  var _vm = this,
28990
29006
  _c = _vm._self._c;
28991
- return _c('Field', {
28992
- staticClass: "w-100",
29007
+ return _c('div', {
29008
+ staticClass: "file-upload"
29009
+ }, [_c('div', {
29010
+ staticClass: "file-upload__area"
29011
+ }, [_c('div', [_c('input', {
28993
29012
  attrs: {
28994
- "name": _vm.fieldInfo.name,
28995
- "rules": _vm.fieldInfo.validationRules,
28996
- "label": _vm.fieldInfo.label
29013
+ "type": "file",
29014
+ "id": "customFile",
29015
+ "disabled": _vm.fieldInfo.disabled,
29016
+ "multiple": _vm.canUploadMultipleFile()
28997
29017
  },
28998
- scopedSlots: _vm._u([{
28999
- key: "default",
29000
- fn: function ({
29001
- errors
29002
- }) {
29003
- return [_c('div', {
29004
- class: {
29005
- 'custom-file from-control': true,
29006
- 'is-invalid': errors[0]
29007
- }
29008
- }, [_c('input', {
29009
- staticClass: "custom-file-input w-100",
29010
- attrs: {
29011
- "type": "file",
29012
- "disabled": _vm.fieldInfo.disabled,
29013
- "id": "customFile"
29014
- },
29015
- on: {
29016
- "change": function ($event) {
29017
- return _vm.onChange($event);
29018
- },
29019
- "input": function ($event) {
29020
- return _vm.onInput($event);
29021
- }
29022
- }
29023
- }), _c('label', {
29024
- staticClass: "custom-file-label",
29025
- attrs: {
29026
- "for": "customFile"
29027
- }
29028
- }, [_vm._v(_vm._s(_vm.fileName))])]), _vm.showAddIcon() ? _c('div', {
29029
- staticClass: "ml-2 mt-1"
29030
- }, [_c('a', {
29031
- class: _vm.addButtonClass()
29032
- }, [_c('i', {
29033
- class: _vm.addIconClass(),
29034
- attrs: {
29035
- "alt": "+"
29036
- },
29037
- on: {
29038
- "click": function ($event) {
29039
- return _vm.onAddButtonClick($event);
29040
- }
29041
- }
29042
- })])]) : _vm._e(), errors[0] ? _c('span', {
29043
- staticClass: "invalid-feedback",
29044
- attrs: {
29045
- "name": _vm.fieldInfo.name
29046
- }
29047
- }, [_vm._v(_vm._s(errors[0]))]) : _vm._e()];
29048
- }
29049
- }])
29050
- });
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)]);
29051
29044
  };
29052
- var FileFieldvue_type_template_id_3677443c_staticRenderFns = [];
29045
+ var FileFieldvue_type_template_id_6aec890d_scoped_true_staticRenderFns = [];
29053
29046
 
29054
- // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=template&id=3677443c&
29047
+ // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=template&id=6aec890d&scoped=true&
29055
29048
 
29056
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&
29057
29050
 
29051
+
29058
29052
  /* harmony default export */ var FileFieldvue_type_script_lang_js_ = ({
29059
29053
  components: {
29060
29054
  Field: ValidationProvider
@@ -29071,7 +29065,19 @@ var FileFieldvue_type_template_id_3677443c_staticRenderFns = [];
29071
29065
  },
29072
29066
  data: function () {
29073
29067
  return {
29074
- 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: []
29075
29081
  };
29076
29082
  },
29077
29083
  mounted: function () {
@@ -29079,61 +29085,114 @@ var FileFieldvue_type_template_id_3677443c_staticRenderFns = [];
29079
29085
  if (this.fieldInfo.placeholder) {
29080
29086
  this.fileName = this.fieldInfo.placeholder;
29081
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
+ }
29082
29094
  },
29083
29095
  methods: {
29084
- onChange: function (e) {
29085
- if (e.target.files.length > 0) {
29086
- this.fileName = e.target.files[0].name;
29087
- }
29088
- this.fieldInfo.value = e.target.files;
29089
- if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.onChange) {
29090
- this.fieldInfo.config.onChange(e, this.fieldInfo);
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
+ }
29091
29142
  }
29092
29143
  },
29093
- onInput: function (e) {},
29094
- showAddIcon: function () {
29095
- if (this.fieldInfo.config && this.fieldInfo.config.showAddIcon) {
29096
- return this.fieldInfo.config.showAddIcon;
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`);
29097
29149
  }
29098
29150
  },
29099
- onAddButtonClick: function (e) {
29100
- if (this.fieldInfo && this.fieldInfo.config && this.fieldInfo.config.onAddButtonClick) {
29101
- this.fieldInfo.config.onAddButtonClick(e, this.fieldInfo);
29151
+ isFileTypeValid(fileExtention) {
29152
+ if (this.accept.split(",").includes(fileExtention)) {
29153
+ console.log("File type is valid");
29154
+ } else {
29155
+ this.errors.push(`File type should be ${this.accept}`);
29102
29156
  }
29103
29157
  },
29104
- addButtonClass: function () {
29105
- if (this.fieldInfo.config && this.fieldInfo.config.addIconBackground) {
29106
- return "round-icon-small theme-primary " + this.fieldInfo.config.addIconBackground;
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;
29107
29163
  } else {
29108
- return "round-icon-small btn-dark theme-primary";
29164
+ return false;
29109
29165
  }
29110
29166
  },
29111
- addIconClass: function () {
29112
- if (this.fieldInfo.config && this.fieldInfo.config.addIcon) {
29113
- return "fa text-white pt-7 font-18 " + this.fieldInfo.config.addIcon;
29114
- } else {
29115
- return "fa fa-plus text-white pt-7 font-18";
29167
+ canUploadMultipleFile() {
29168
+ if (this.fieldInfo.config && this.fieldInfo.config.hasOwnProperty('multiple')) {
29169
+ return this.fieldInfo.config.multiple;
29116
29170
  }
29171
+ return false;
29117
29172
  }
29118
29173
  }
29119
29174
  });
29120
29175
  // CONCATENATED MODULE: ./src/components/FileField.vue?vue&type=script&lang=js&
29121
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
+
29122
29180
  // CONCATENATED MODULE: ./src/components/FileField.vue
29123
29181
 
29124
29182
 
29125
29183
 
29126
29184
 
29127
29185
 
29186
+
29128
29187
  /* normalize component */
29129
29188
 
29130
29189
  var FileField_component = normalizeComponent(
29131
29190
  components_FileFieldvue_type_script_lang_js_,
29132
- FileFieldvue_type_template_id_3677443c_render,
29133
- FileFieldvue_type_template_id_3677443c_staticRenderFns,
29191
+ FileFieldvue_type_template_id_6aec890d_scoped_true_render,
29192
+ FileFieldvue_type_template_id_6aec890d_scoped_true_staticRenderFns,
29134
29193
  false,
29135
29194
  null,
29136
- null,
29195
+ "6aec890d",
29137
29196
  null
29138
29197
 
29139
29198
  )