Skip to content

Commit 63b0400

Browse files
authored
Merge pull request #8 from kit-data-manager/fix-production-mode
Fix production mode
2 parents 113a5cb + 17a8a6a commit 63b0400

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

package.json

+13-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "This component contains an option to select an input file form which metadata needs to be extracted, an option to search from available mapping schemas whose name will be self explainatory .",
44
"author": "Ajay",
55
"license": "Apache License 2.0",
6-
"version": "0.5.2",
6+
"version": "0.5.3",
77
"private": false,
88
"keywords": [
99
"metadata",
@@ -20,6 +20,16 @@
2020
},
2121
"type": "module",
2222
"main": "./dist/com_mapping-service-input.umd.js",
23+
"module": "./dist/com_mapping-service-input.es.js",
24+
"exports": {
25+
".": {
26+
"import": "./dist/com_mapping-service-input.es.js",
27+
"require": "./dist/com_mapping-service-input.umd.js"
28+
}
29+
},
30+
"files": [
31+
"dist"
32+
],
2333
"scripts": {
2434
"dev": "vite",
2535
"format": "prettier --write .",
@@ -28,7 +38,6 @@
2838
"preview": "vite preview"
2939
},
3040
"devDependencies": {
31-
"@types/typeahead": "^0.11.32",
3241
"@typescript-eslint/eslint-plugin": "^5.52.0",
3342
"eslint": "^8.34.0",
3443
"eslint-config-prettier": "^8.6.0",
@@ -37,8 +46,8 @@
3746
"eslint-plugin-n": "^15.6.1",
3847
"eslint-plugin-promise": "^6.1.1",
3948
"prettier": "2.8.4",
40-
"typescript": "^4.9.5",
41-
"vite": "^4.1.1"
49+
"typescript": "^5.0.2",
50+
"vite": "^4.3.5"
4251
},
4352
"dependencies": {
4453
"filepond": "^4.30.4",

src/main.ts

+14-17
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ import * as FilePondLib from "filepond";
33
import { FilePond, FilePondOptions } from "filepond";
44
import filepondCSS from "filepond/dist/filepond.min.css?inline";
55
import typeahead from "typeahead-standalone";
6-
import { Dictionary, typeaheadResult } from "typeahead-standalone/dist/types";
76
import typeaheadCSS from "typeahead-standalone/dist/basic.css?inline";
7+
import customCSS from './style.css?inline';
88

9-
const ATTRIBUTES: string[] = ["base-url"
10-
];
11-
export class MappingInputProvider extends HTMLElement {
9+
const ATTRIBUTES: string[] = ["base-url"];
10+
class MappingInputProvider extends HTMLElement {
1211
shadowRoot: ShadowRoot;
1312
private testingFileChooser: FilePond | null = null;
14-
private mappingchooser: typeaheadResult<Dictionary> | null = null;
1513
// --- Attribute accessible from the HTML tag:
1614
baseUrl: URL = new URL("http://localhost:8090/");
17-
1815
// ---
1916

17+
2018
// --- Helper methods
2119
addCssContent(css: string): void {
2220
let styleElem: HTMLStyleElement = document.createElement("style");
@@ -41,13 +39,12 @@ export class MappingInputProvider extends HTMLElement {
4139
this.shadowRoot = this.attachShadow({ mode: "open" });
4240
this.addCssContent(filepondCSS);
4341
this.addCssContent(typeaheadCSS);
42+
this.addCssContent(customCSS);
4443

45-
{
46-
// Apply HTML Template to shadow DOM
47-
const template = document.createElement("template");
48-
template.innerHTML = templateContent;
49-
this.shadowRoot.append(template.content.cloneNode(true));
50-
}
44+
// Apply HTML Template to shadow DOM
45+
const template = document.createElement("template");
46+
template.innerHTML = templateContent;
47+
this.shadowRoot.append(template.content.cloneNode(true));
5148
}
5249

5350
/**
@@ -93,7 +90,7 @@ export class MappingInputProvider extends HTMLElement {
9390
this.shadowRoot.getElementById("mappingchooser")
9491
);
9592
if (inputElement != null) {
96-
this.mappingchooser = typeahead({
93+
typeahead({
9794
input: inputElement,
9895
minLength: -1,
9996
highlight: true,
@@ -148,9 +145,8 @@ export class MappingInputProvider extends HTMLElement {
148145
this.baseUrl = newValue;
149146
this.connectedCallback();
150147
}
151-
this.testingFileChooser;
152-
this.mappingchooser;
153148
}
149+
154150
/**
155151
* Optional boolean parameter download used in executeMapping method, user can choose to download the result.
156152
* It will help user chose between true, false or no parameter
@@ -186,6 +182,7 @@ export class MappingInputProvider extends HTMLElement {
186182
}
187183
}
188184
}
185+
189186
/**
190187
* In case if download is required triggerDownload can be used
191188
*/
@@ -194,9 +191,9 @@ export class MappingInputProvider extends HTMLElement {
194191
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(response)));
195192
element.setAttribute('download', "result.json");
196193
element.style.display = 'none';
197-
this.shadowRoot.appendChild;
194+
this.shadowRoot.appendChild(element);
198195
element.click();
199-
this.shadowRoot.removeChild;
196+
this.shadowRoot.removeChild(element);
200197
}
201198
}
202199

src/template.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<link rel="stylesheet" href="src/style.css">
21
<div class="mapping-container">
32
<h2 class="mapping-title">Choose a Mapping</h2>
43
<div class="mapping-input-container">

0 commit comments

Comments
 (0)