gd-bs 5.8.7 → 5.8.8

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.
@@ -43,6 +43,7 @@ var _InputGroup = /** @class */ (function (_super) {
43
43
  function _InputGroup(props, template) {
44
44
  if (template === void 0) { template = templates_1.HTML; }
45
45
  var _this = _super.call(this, template, props) || this;
46
+ _this._fileValue = null;
46
47
  _this._initFl = false;
47
48
  // Configure the collapse
48
49
  _this.configure();
@@ -67,30 +68,13 @@ var _InputGroup = /** @class */ (function (_super) {
67
68
  var label = this.el.querySelector("label");
68
69
  if (label) {
69
70
  this.props.id ? label.setAttribute("for", this.props.id) : null;
70
- // See if this is a file
71
- if (this.props.type == InputGroupTypes.File) {
72
- // Set the class
73
- label.classList.add("form-file-label");
74
- // Set the text
75
- var spanText = document.createElement("span");
76
- spanText.classList.add("form-file-text");
77
- spanText.innerHTML = this.props.label || "Choose a file...";
78
- label.appendChild(spanText);
79
- // Set the button
80
- var spanButton = document.createElement("span");
81
- spanButton.classList.add("form-file-button");
82
- spanButton.innerHTML = "Browse";
83
- label.appendChild(spanButton);
71
+ // Set the label if it exists
72
+ if (this.props.label) {
73
+ label.innerHTML = this.props.label;
84
74
  }
75
+ // Else, remove it
85
76
  else {
86
- // Set the label if it exists
87
- if (this.props.label) {
88
- label.innerHTML = this.props.label;
89
- }
90
- // Else, remove it
91
- else {
92
- this.el.removeChild(label);
93
- }
77
+ this.el.removeChild(label);
94
78
  }
95
79
  }
96
80
  // See if the label exists
@@ -188,6 +172,31 @@ var _InputGroup = /** @class */ (function (_super) {
188
172
  }, 1);
189
173
  });
190
174
  }
175
+ // See if this is a file
176
+ if (this.props.type == InputGroupTypes.File) {
177
+ // Set the change event
178
+ elInput.addEventListener("onchange", function (ev) {
179
+ // Get the source file
180
+ var srcFile = ev.target["files"][0];
181
+ if (srcFile) {
182
+ var reader = new FileReader();
183
+ // Set the file loaded event
184
+ reader.onloadend = function (ev) {
185
+ _this._fileValue = {
186
+ data: ev.target.result,
187
+ name: srcFile.name
188
+ };
189
+ };
190
+ // Set the error
191
+ reader.onerror = function (ev) {
192
+ // Log
193
+ console.log("Error reading the file", srcFile, ev.target.error);
194
+ };
195
+ // Read the file
196
+ reader.readAsArrayBuffer(srcFile);
197
+ }
198
+ });
199
+ }
191
200
  }
192
201
  };
193
202
  // Configures the text box
@@ -265,6 +274,7 @@ var _InputGroup = /** @class */ (function (_super) {
265
274
  /**
266
275
  * Public Interface
267
276
  */
277
+ _InputGroup.prototype.getFileInfo = function () { return this._fileValue; };
268
278
  _InputGroup.prototype.getValue = function () { return this.elTextbox.value; };
269
279
  // Sets the textbox value
270
280
  _InputGroup.prototype.setValue = function (value) {