@startinblox/core 0.17.29 → 0.17.30

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.
@@ -20,12 +20,13 @@ const FormFileMixin = {
20
20
 
21
21
  attached() {
22
22
  document.addEventListener('reset', e => {
23
- console.log("reset", e.target, this.element);
24
-
25
23
  if (e.target && e.target.contains(this.element)) {
26
24
  this.value = this.initialValue;
27
25
  this.listAttributes['resetButtonHidden'] = true;
28
26
  this.planRender();
27
+ const dataHolder = this.element.querySelector('input[data-holder]');
28
+ dataHolder.value = this.value;
29
+ dataHolder.dispatchEvent(new Event('change'));
29
30
  }
30
31
  });
31
32
  },
@@ -39,6 +40,7 @@ const FormFileMixin = {
39
40
 
40
41
  const filePicker = this.element.querySelector('input[type="file"]');
41
42
  if (filePicker.files.length < 1) return;
43
+ const dataHolder = this.element.querySelector('input[data-holder]');
42
44
  this.listAttributes['output'] = '⏳';
43
45
  this.planRender();
44
46
  const file = filePicker.files[0];
@@ -47,18 +49,7 @@ const FormFileMixin = {
47
49
  store.fetchAuthn(this.uploadUrl, {
48
50
  method: 'POST',
49
51
  body: formData
50
- }).then(response => {
51
- const location = response.headers.get('location');
52
-
53
- if (location == null) {
54
- this.listAttributes['output'] = 'header location not found!';
55
- } else {
56
- this.value = location;
57
- this.listAttributes['output'] = '';
58
- this.listAttributes['resetButtonHidden'] = false;
59
- this.planRender();
60
- }
61
- }).catch(error => {
52
+ }).then(response => this.updateFile(dataHolder, response)).catch(error => {
62
53
  this.listAttributes['fileValue'] = '';
63
54
  this.listAttributes['output'] = 'upload error';
64
55
  this.planRender();
@@ -66,15 +57,35 @@ const FormFileMixin = {
66
57
  });
67
58
  },
68
59
 
60
+ updateFile(dataHolder, response) {
61
+ const location = response.headers.get('location');
62
+
63
+ if (location == null) {
64
+ this.listAttributes['output'] = 'header location not found!';
65
+ } else {
66
+ this.value = location;
67
+ this.listAttributes['output'] = '';
68
+ this.listAttributes['resetButtonHidden'] = false;
69
+ dataHolder.value = location;
70
+ dataHolder.dispatchEvent(new Event('change'));
71
+ this.planRender();
72
+ }
73
+ },
74
+
69
75
  resetFile(event) {
70
76
  event.preventDefault();
71
77
  this.value = '';
72
78
  const filePicker = this.element.querySelector('input[type="file"]');
73
- if (filePicker) filePicker.value = '';
79
+ const dataHolder = this.element.querySelector('input[data-holder]');
80
+
81
+ if (filePicker && dataHolder) {
82
+ filePicker.value = dataHolder.value = '';
83
+ }
84
+
74
85
  this.listAttributes['fileValue'] = '';
75
86
  this.listAttributes['output'] = '';
76
- this.listAttributes['resetButtonHidden'] = true; // this.input.dispatchEvent(new Event('change'));
77
-
87
+ this.listAttributes['resetButtonHidden'] = true;
88
+ dataHolder.dispatchEvent(new Event('change'));
78
89
  this.planRender();
79
90
  }
80
91
 
@@ -1 +1 @@
1
- {"version":3,"sources":["formFileMixin.ts"],"names":["store","FormFileMixin","name","attributes","uploadUrl","type","String","default","initialState","initialValue","created","listAttributes","selectFile","bind","resetFile","attached","document","addEventListener","e","console","log","target","element","contains","value","planRender","filePicker","querySelector","files","length","file","formData","FormData","append","fetchAuthn","method","body","then","response","location","headers","get","catch","error","event","preventDefault"],"mappings":"AAAA,SAASA,KAAT,QAAsB,wBAAtB;AAEA,MAAMC,aAAa,GAAG;AACpBC,EAAAA,IAAI,EAAE,iBADc;AAEpBC,EAAAA,UAAU,EAAE;AACVC,IAAAA,SAAS,EAAE;AACTC,MAAAA,IAAI,EAAEC,MADG;AAETC,MAAAA,OAAO,EAAE;AAFA;AADD,GAFQ;AAQpBC,EAAAA,YAAY,EAAE;AACZC,IAAAA,YAAY,EAAE;AADF,GARM;;AAWpBC,EAAAA,OAAO,GAAG;AACR,SAAKC,cAAL,CAAoB,QAApB,IAAgC,EAAhC;AACA,SAAKA,cAAL,CAAoB,mBAApB,IAA2C,IAA3C;AACA,SAAKA,cAAL,CAAoB,YAApB,IAAoC,KAAKC,UAAL,CAAgBC,IAAhB,CAAqB,IAArB,CAApC;AACA,SAA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IAJH,CAIQC,QAAQ,IAAI;AAChB,YAAMC,QAAQ,GAAGD,QAAQ,CAACE,OAAT,CAAiBC,GAAjB,CAAqB,UAArB,CAAjB;;AACA,UAAIF,QAAQ,IAAI,IAAhB,EAAsB;AACpB,aAAK5B,cAAL,CAAoB,QAApB,IAAgC,4BAAhC;AACD,OAFD,MAEO;AACL,aAAKa,KAAL,GAAae,QAAb;AACA,aAAK5B,cAAL,CAAoB,QAApB,IAAgC,EAAhC;AACA,aAAKA,cAAL,CAAoB,mBAApB,IAA2C,KAA3C;AACA,aAAKc,UAAL;AACD;AACF,KAdH,EAeGiB,KAfH,CAeSC,KAAK,IAAI;AACd,WAAKhC,cAAL,CAAoB,WAApB,IAAmC,EAAnC;AACA,WAAKA,cAAL,CAAoB,QAApB,IAAgC,cAAhC;AACA,WAAKc,UAAL;AACAN,MAAAA,OAAO,CAACwB,KAAR,CAAcA,KAAd;AACD,KApBH;AAqBD,GAhEmB;;AAiEpB7B,EAAAA,SAAS,CAAC8B,KAAD,EAAQ;AACfA,IAAAA,KAAK,CAACC,cAAN;AACA,SAAKrB,KAAL,GAAa,EAAb;AACA,UAAME,UAAU,GAAG,KAAKJ,OAAL,CAAaK,aAAb,CAA2B,oBAA3B,CAAnB;AACA,QAAID,UAAJ,EAAgBA,UAAU,CAACF,KAAX,GAAmB,EAAnB;AAChB,SAAKb,cAAL,CAAoB,WAApB,IAAmC,EAAnC;AACA,SAAKA,cAAL,CAAoB,QAApB,IAAgC,EAAhC;AACA,SAAKA,cAAL,CAAoB,mBAApB,IAA2C,IAA3C,CAPe,CAQf;;AACA,SAAKc,UAAL;AACD;;AA3EmB,CAAtB;AA8EA,SACExB,aADF","sourcesContent":["import { store } from \"../../libs/store/store\";\n\nconst FormFileMixin = {\n name: 'form-file-mixin',\n attributes: {\n uploadUrl: {\n type: String,\n default: ''\n },\n },\n initialState: {\n initialValue: ''\n },\n created() {\n this.listAttributes['output'] = '';\n this.listAttributes['resetButtonHidden'] = true;\n this.listAttributes['selectFile'] = this.selectFile.bind(this);\n this.listAttributes['resetFile'] = this.resetFile.bind(this);\n },\n attached() {\n document.addEventListener('reset', (e) => {\n console.log(\"reset\", e.target, this.element);\n if (e.target && (e.target as HTMLElement).contains(this.element)) {\n this.value = this.initialValue;\n this.listAttributes['resetButtonHidden'] = true;\n this.planRender();\n }\n })\n },\n selectFile() {\n if (this.uploadUrl === null) return;\n\n if (this.initialValue === '') {\n this.initialValue = this.value;\n }\n\n const filePicker = this.element.querySelector('input[type=\"file\"]');\n if (filePicker.files!.length < 1) return;\n\n this.listAttributes['output'] = '⏳';\n this.planRender();\n\n const file = filePicker.files![0];\n const formData = new FormData();\n formData.append('file', file);\n store.fetchAuthn(this.uploadUrl, {\n method: 'POST',\n body: formData,\n })\n .then(response => {\n const location = response.headers.get('location');\n if (location == null) {\n this.listAttributes['output'] = 'header location not found!';\n } else {\n this.value = location;\n this.listAttributes['output'] = '';\n this.listAttributes['resetButtonHidden'] = false;\n this.planRender();\n }\n })\n .catch(error => {\n this.listAttributes['fileValue'] = '';\n this.listAttributes['output'] = 'upload error';\n this.planRender();\n console.error(error);\n });\n },\n resetFile(event) {\n event.preventDefault();\n this.value = '';\n const filePicker = this.element.querySelector('input[type=\"file\"]');\n if (filePicker) filePicker.value = '';\n this.listAttributes['fileValue'] = '';\n this.listAttributes['output'] = '';\n this.listAttributes['resetButtonHidden'] = true;\n // this.input.dispatchEvent(new Event('change'));\n this.planRender();\n }\n}\n\nexport {\n FormFileMixin\n}\n"]}
1
+ {"version":3,"sources":["formFileMixin.ts"],"names":["store","FormFileMixin","name","attributes","uploadUrl","type","String","default","initialState","initialValue","created","listAttributes","selectFile","bind","resetFile","attached","document","addEventListener","e","target","contains","element","value","planRender","dataHolder","querySelector","dispatchEvent","Event","filePicker","files","length","file","formData","FormData","append","fetchAuthn","method","body","then","response","updateFile","catch","error","console","location","headers","get","event","preventDefault"],"mappings":"AAAA,SAASA,KAAT,QAAsB,wBAAtB;AAEA,MAAMC,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B,IAAgC,EAAhC;AACA,WAAKA,cAAL,CAAoB,mBAApB,IAA2C,KAA3C;AAEAa,MAAAA,UAAU,CAACF,KAAX,GAAmBsB,QAAnB;AACApB,MAAAA,UAAU,CAACE,aAAX,CAAyB,IAAIC,KAAJ,CAAU,QAAV,CAAzB;AAEA,WAAKJ,UAAL;AACD;AACF,GAzEmB;;AA2EpBT,EAAAA,SAAS,CAACiC,KAAD,EAAQ;AACfA,IAAAA,KAAK,CAACC,cAAN;AACA,SAAK1B,KAAL,GAAa,EAAb;AACA,UAAMM,UAAU,GAAG,KAAKP,OAAL,CAAaI,aAAb,CAA2B,oBAA3B,CAAnB;AACA,UAAMD,UAAU,GAAG,KAAKH,OAAL,CAAaI,aAAb,CAA2B,oBAA3B,CAAnB;;AAEA,QAAIG,UAAU,IAAIJ,UAAlB,EAA+B;AAC7BI,MAAAA,UAAU,CAACN,KAAX,GAAmBE,UAAU,CAACF,KAAX,GAAmB,EAAtC;AACD;;AAED,SAAKX,cAAL,CAAoB,WAApB,IAAmC,EAAnC;AACA,SAAKA,cAAL,CAAoB,QAApB,IAAgC,EAAhC;AACA,SAAKA,cAAL,CAAoB,mBAApB,IAA2C,IAA3C;AACAa,IAAAA,UAAU,CAACE,aAAX,CAAyB,IAAIC,KAAJ,CAAU,QAAV,CAAzB;AACA,SAAKJ,UAAL;AACD;;AA1FmB,CAAtB;AA6FA,SACEtB,aADF","sourcesContent":["import { store } from \"../../libs/store/store\";\n\nconst FormFileMixin = {\n name: 'form-file-mixin',\n attributes: {\n uploadUrl: {\n type: String,\n default: ''\n },\n },\n initialState: {\n initialValue: ''\n },\n created() {\n this.listAttributes['output'] = '';\n this.listAttributes['resetButtonHidden'] = true;\n this.listAttributes['selectFile'] = this.selectFile.bind(this);\n this.listAttributes['resetFile'] = this.resetFile.bind(this);\n },\n attached() {\n document.addEventListener('reset', (e) => {\n if (e.target && (e.target as HTMLElement).contains(this.element)) {\n this.value = this.initialValue;\n this.listAttributes['resetButtonHidden'] = true;\n this.planRender();\n const dataHolder = this.element.querySelector('input[data-holder]');\n dataHolder.value = this.value;\n dataHolder.dispatchEvent(new Event('change'));\n }\n })\n },\n selectFile() {\n if (this.uploadUrl === null) return;\n\n if (this.initialValue === '') {\n this.initialValue = this.value;\n }\n\n const filePicker = this.element.querySelector('input[type=\"file\"]');\n if (filePicker.files!.length < 1) return;\n\n const dataHolder = this.element.querySelector('input[data-holder]');\n this.listAttributes['output'] = '⏳';\n this.planRender();\n\n const file = filePicker.files![0];\n const formData = new FormData();\n formData.append('file', file);\n store.fetchAuthn(this.uploadUrl, {\n method: 'POST',\n body: formData,\n })\n .then(response => this.updateFile(dataHolder, response) )\n .catch(error => {\n this.listAttributes['fileValue'] = '';\n this.listAttributes['output'] = 'upload error';\n this.planRender();\n console.error(error);\n });\n },\n\n updateFile(dataHolder: HTMLInputElement, response: Response) {\n const location = response.headers.get('location');\n if (location == null) {\n this.listAttributes['output'] = 'header location not found!';\n } else {\n this.value = location;\n this.listAttributes['output'] = '';\n this.listAttributes['resetButtonHidden'] = false;\n\n dataHolder.value = location;\n dataHolder.dispatchEvent(new Event('change'));\n\n this.planRender();\n }\n },\n\n resetFile(event) {\n event.preventDefault();\n this.value = '';\n const filePicker = this.element.querySelector('input[type=\"file\"]');\n const dataHolder = this.element.querySelector('input[data-holder]');\n\n if (filePicker && dataHolder ) {\n filePicker.value = dataHolder.value = '';\n }\n\n this.listAttributes['fileValue'] = '';\n this.listAttributes['output'] = '';\n this.listAttributes['resetButtonHidden'] = true;\n dataHolder.dispatchEvent(new Event('change'));\n this.planRender();\n }\n}\n\nexport {\n FormFileMixin\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startinblox/core",
3
- "version": "0.17.29",
3
+ "version": "0.17.30",
4
4
  "description": "This is a series of web component respecting both the web components standards and the Linked Data Platform convention.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",