@startinblox/core 0.17.28 → 0.17.29
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.
|
@@ -19,36 +19,14 @@ const FormFileMixin = {
|
|
|
19
19
|
},
|
|
20
20
|
|
|
21
21
|
attached() {
|
|
22
|
-
document.addEventListener('
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const formValue = await solidForm.component.getFormValue(); //to get modificated values
|
|
26
|
-
//if reset button clicked
|
|
27
|
-
|
|
28
|
-
if (e.target.getAttribute('type') === 'reset' && solidForm.contains(e.target)) {
|
|
29
|
-
//if edition form and value or if creation form
|
|
30
|
-
if (!solidForm.component.isCreationForm(formValue) && this.initialValue !== '' || solidForm.component.isCreationForm(formValue)) this.value = this.initialValue; //if edition form and no value
|
|
31
|
-
else if (!solidForm.component.isCreationForm(formValue) && this.initialValue === '') this.value = this.initialValue = '';
|
|
32
|
-
this.listAttributes['resetButtonHidden'] = true;
|
|
33
|
-
this.planRender();
|
|
34
|
-
} // if submit button clicked
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (e.target.getAttribute('type') === 'submit' && solidForm.contains(e.target)) {
|
|
38
|
-
if (solidForm.getAttribute('next') || solidForm.component.isCreationForm(formValue)) {
|
|
39
|
-
this.value = this.initialValue;
|
|
40
|
-
this.initialValue = '';
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (!solidForm.component.isCreationForm(formValue)) {
|
|
44
|
-
this.initialValue = this.value;
|
|
45
|
-
}
|
|
22
|
+
document.addEventListener('reset', e => {
|
|
23
|
+
console.log("reset", e.target, this.element);
|
|
46
24
|
|
|
25
|
+
if (e.target && e.target.contains(this.element)) {
|
|
26
|
+
this.value = this.initialValue;
|
|
47
27
|
this.listAttributes['resetButtonHidden'] = true;
|
|
48
28
|
this.planRender();
|
|
49
29
|
}
|
|
50
|
-
|
|
51
|
-
;
|
|
52
30
|
});
|
|
53
31
|
},
|
|
54
32
|
|
|
@@ -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","
|
|
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,SAAKF,cAAL,CAAoB,WAApB,IAAmC,KAAKG,SAAL,CAAeD,IAAf,CAAoB,IAApB,CAAnC;AACD,GAhBmB;;AAiBpBE,EAAAA,QAAQ,GAAG;AACTC,IAAAA,QAAQ,CAACC,gBAAT,CAA0B,OAA1B,EAAoCC,CAAD,IAAO;AACxCC,MAAAA,OAAO,CAACC,GAAR,CAAY,OAAZ,EAAqBF,CAAC,CAACG,MAAvB,EAA+B,KAAKC,OAApC;;AACA,UAAIJ,CAAC,CAACG,MAAF,IAAaH,CAAC,CAACG,MAAH,CAA0BE,QAA1B,C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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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startinblox/core",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.29",
|
|
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",
|