sa-spell-checker 1.0.0
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.
- package/dist/sa-spell-checker.mjs +105 -0
- package/dist/sa-spell-checker.umd.js +49 -0
- package/package.json +16 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const s = `
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.wrapper {
|
|
9
|
+
position: relative;
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
textarea {
|
|
14
|
+
width: 100%;
|
|
15
|
+
min-height: 80px;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
font-family: inherit;
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
line-height: 1.5;
|
|
20
|
+
color: #111827;
|
|
21
|
+
background: #fff;
|
|
22
|
+
border: 1px solid #d1d5db;
|
|
23
|
+
border-radius: 6px;
|
|
24
|
+
padding: 8px 12px;
|
|
25
|
+
resize: vertical;
|
|
26
|
+
outline: none;
|
|
27
|
+
transition: border-color 0.15s, box-shadow 0.15s;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
textarea:focus {
|
|
31
|
+
border-color: #6366f1;
|
|
32
|
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
textarea:disabled {
|
|
36
|
+
background: #f9fafb;
|
|
37
|
+
color: #9ca3af;
|
|
38
|
+
cursor: not-allowed;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
textarea::placeholder {
|
|
42
|
+
color: #9ca3af;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
class r extends HTMLElement {
|
|
46
|
+
static get observedAttributes() {
|
|
47
|
+
return ["spellcheck", "lang", "placeholder", "value", "disabled", "rows"];
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
const e = this.attachShadow({ mode: "open" });
|
|
51
|
+
e.innerHTML = `
|
|
52
|
+
<style>${s}</style>
|
|
53
|
+
<div class="wrapper">
|
|
54
|
+
<textarea></textarea>
|
|
55
|
+
</div>
|
|
56
|
+
`, this._textarea = e.querySelector("textarea"), this._applyAllAttrs(), this._textarea.addEventListener("input", () => {
|
|
57
|
+
this.dispatchEvent(
|
|
58
|
+
new CustomEvent("sa-change", {
|
|
59
|
+
detail: { value: this._textarea.value },
|
|
60
|
+
bubbles: !0,
|
|
61
|
+
composed: !0
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
attributeChangedCallback(e, t, a) {
|
|
67
|
+
this._textarea && this._applyAttr(e, a);
|
|
68
|
+
}
|
|
69
|
+
_applyAllAttrs() {
|
|
70
|
+
for (const e of r.observedAttributes)
|
|
71
|
+
this._applyAttr(e, this.getAttribute(e));
|
|
72
|
+
}
|
|
73
|
+
_applyAttr(e, t) {
|
|
74
|
+
const a = this._textarea;
|
|
75
|
+
switch (e) {
|
|
76
|
+
case "spellcheck":
|
|
77
|
+
a.spellcheck = t !== "false";
|
|
78
|
+
break;
|
|
79
|
+
case "lang":
|
|
80
|
+
a.lang = t || "en-US";
|
|
81
|
+
break;
|
|
82
|
+
case "placeholder":
|
|
83
|
+
a.placeholder = t || "";
|
|
84
|
+
break;
|
|
85
|
+
case "value":
|
|
86
|
+
a.value !== (t || "") && (a.value = t || "");
|
|
87
|
+
break;
|
|
88
|
+
case "disabled":
|
|
89
|
+
a.disabled = t !== null && t !== "false";
|
|
90
|
+
break;
|
|
91
|
+
case "rows":
|
|
92
|
+
t && (a.rows = parseInt(t, 10));
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// JS property accessors
|
|
97
|
+
get value() {
|
|
98
|
+
var e;
|
|
99
|
+
return ((e = this._textarea) == null ? void 0 : e.value) ?? "";
|
|
100
|
+
}
|
|
101
|
+
set value(e) {
|
|
102
|
+
this._textarea && (this._textarea.value = e ?? "");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
customElements.define("sa-spell-checker", r);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
(function(s){typeof define=="function"&&define.amd?define(s):s()})(function(){"use strict";const s=`
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.wrapper {
|
|
9
|
+
position: relative;
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
textarea {
|
|
14
|
+
width: 100%;
|
|
15
|
+
min-height: 80px;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
font-family: inherit;
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
line-height: 1.5;
|
|
20
|
+
color: #111827;
|
|
21
|
+
background: #fff;
|
|
22
|
+
border: 1px solid #d1d5db;
|
|
23
|
+
border-radius: 6px;
|
|
24
|
+
padding: 8px 12px;
|
|
25
|
+
resize: vertical;
|
|
26
|
+
outline: none;
|
|
27
|
+
transition: border-color 0.15s, box-shadow 0.15s;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
textarea:focus {
|
|
31
|
+
border-color: #6366f1;
|
|
32
|
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
textarea:disabled {
|
|
36
|
+
background: #f9fafb;
|
|
37
|
+
color: #9ca3af;
|
|
38
|
+
cursor: not-allowed;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
textarea::placeholder {
|
|
42
|
+
color: #9ca3af;
|
|
43
|
+
}
|
|
44
|
+
`;class r extends HTMLElement{static get observedAttributes(){return["spellcheck","lang","placeholder","value","disabled","rows"]}connectedCallback(){const e=this.attachShadow({mode:"open"});e.innerHTML=`
|
|
45
|
+
<style>${s}</style>
|
|
46
|
+
<div class="wrapper">
|
|
47
|
+
<textarea></textarea>
|
|
48
|
+
</div>
|
|
49
|
+
`,this._textarea=e.querySelector("textarea"),this._applyAllAttrs(),this._textarea.addEventListener("input",()=>{this.dispatchEvent(new CustomEvent("sa-change",{detail:{value:this._textarea.value},bubbles:!0,composed:!0}))})}attributeChangedCallback(e,t,a){this._textarea&&this._applyAttr(e,a)}_applyAllAttrs(){for(const e of r.observedAttributes)this._applyAttr(e,this.getAttribute(e))}_applyAttr(e,t){const a=this._textarea;switch(e){case"spellcheck":a.spellcheck=t!=="false";break;case"lang":a.lang=t||"en-US";break;case"placeholder":a.placeholder=t||"";break;case"value":a.value!==(t||"")&&(a.value=t||"");break;case"disabled":a.disabled=t!==null&&t!=="false";break;case"rows":t&&(a.rows=parseInt(t,10));break}}get value(){var e;return((e=this._textarea)==null?void 0:e.value)??""}set value(e){this._textarea&&(this._textarea.value=e??"")}}customElements.define("sa-spell-checker",r)});
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sa-spell-checker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SuperAnnotate custom spell checker web component",
|
|
5
|
+
"main": "dist/sa-spell-checker.umd.cjs",
|
|
6
|
+
"module": "dist/sa-spell-checker.js",
|
|
7
|
+
"files": ["dist"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"build": "vite build",
|
|
11
|
+
"preview": "vite preview"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"vite": "^5.4.0"
|
|
15
|
+
}
|
|
16
|
+
}
|