sa-spell-checker 1.0.0 → 1.0.2

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.
@@ -1,105 +1,690 @@
1
- const s = `
2
- :host {
3
- display: block;
4
- width: 100%;
5
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ const R = globalThis, W = R.ShadowRoot && (R.ShadyCSS === void 0 || R.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, nt = Symbol(), F = /* @__PURE__ */ new WeakMap();
7
+ let dt = class {
8
+ constructor(t, e, s) {
9
+ if (this._$cssResult$ = !0, s !== nt) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
10
+ this.cssText = t, this.t = e;
6
11
  }
7
-
8
- .wrapper {
9
- position: relative;
10
- width: 100%;
12
+ get styleSheet() {
13
+ let t = this.o;
14
+ const e = this.t;
15
+ if (W && t === void 0) {
16
+ const s = e !== void 0 && e.length === 1;
17
+ s && (t = F.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && F.set(e, t));
18
+ }
19
+ return t;
11
20
  }
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;
21
+ toString() {
22
+ return this.cssText;
28
23
  }
29
-
30
- textarea:focus {
31
- border-color: #6366f1;
32
- box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
24
+ };
25
+ const ht = (r) => new dt(typeof r == "string" ? r : r + "", void 0, nt), ut = (r, t) => {
26
+ if (W) r.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
27
+ else for (const e of t) {
28
+ const s = document.createElement("style"), i = R.litNonce;
29
+ i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, r.appendChild(s);
33
30
  }
34
-
35
- textarea:disabled {
36
- background: #f9fafb;
37
- color: #9ca3af;
38
- cursor: not-allowed;
31
+ }, K = W ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => {
32
+ let e = "";
33
+ for (const s of t.cssRules) e += s.cssText;
34
+ return ht(e);
35
+ })(r) : r;
36
+ /**
37
+ * @license
38
+ * Copyright 2017 Google LLC
39
+ * SPDX-License-Identifier: BSD-3-Clause
40
+ */
41
+ const { is: $t, defineProperty: ft, getOwnPropertyDescriptor: _t, getOwnPropertyNames: gt, getOwnPropertySymbols: At, getPrototypeOf: mt } = Object, g = globalThis, Z = g.trustedTypes, yt = Z ? Z.emptyScript : "", j = g.reactiveElementPolyfillSupport, P = (r, t) => r, z = { toAttribute(r, t) {
42
+ switch (t) {
43
+ case Boolean:
44
+ r = r ? yt : null;
45
+ break;
46
+ case Object:
47
+ case Array:
48
+ r = r == null ? r : JSON.stringify(r);
39
49
  }
40
-
41
- textarea::placeholder {
42
- color: #9ca3af;
50
+ return r;
51
+ }, fromAttribute(r, t) {
52
+ let e = r;
53
+ switch (t) {
54
+ case Boolean:
55
+ e = r !== null;
56
+ break;
57
+ case Number:
58
+ e = r === null ? null : Number(r);
59
+ break;
60
+ case Object:
61
+ case Array:
62
+ try {
63
+ e = JSON.parse(r);
64
+ } catch {
65
+ e = null;
66
+ }
67
+ }
68
+ return e;
69
+ } }, V = (r, t) => !$t(r, t), J = { attribute: !0, type: String, converter: z, reflect: !1, useDefault: !1, hasChanged: V };
70
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), g.litPropertyMetadata ?? (g.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
71
+ let E = class extends HTMLElement {
72
+ static addInitializer(t) {
73
+ this._$Ei(), (this.l ?? (this.l = [])).push(t);
43
74
  }
44
- `;
45
- class r extends HTMLElement {
46
75
  static get observedAttributes() {
47
- return ["spellcheck", "lang", "placeholder", "value", "disabled", "rows"];
76
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
77
+ }
78
+ static createProperty(t, e = J) {
79
+ if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
80
+ const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
81
+ i !== void 0 && ft(this.prototype, t, i);
82
+ }
83
+ }
84
+ static getPropertyDescriptor(t, e, s) {
85
+ const { get: i, set: o } = _t(this.prototype, t) ?? { get() {
86
+ return this[e];
87
+ }, set(n) {
88
+ this[e] = n;
89
+ } };
90
+ return { get: i, set(n) {
91
+ const l = i == null ? void 0 : i.call(this);
92
+ o == null || o.call(this, n), this.requestUpdate(t, l, s);
93
+ }, configurable: !0, enumerable: !0 };
94
+ }
95
+ static getPropertyOptions(t) {
96
+ return this.elementProperties.get(t) ?? J;
97
+ }
98
+ static _$Ei() {
99
+ if (this.hasOwnProperty(P("elementProperties"))) return;
100
+ const t = mt(this);
101
+ t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
102
+ }
103
+ static finalize() {
104
+ if (this.hasOwnProperty(P("finalized"))) return;
105
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(P("properties"))) {
106
+ const e = this.properties, s = [...gt(e), ...At(e)];
107
+ for (const i of s) this.createProperty(i, e[i]);
108
+ }
109
+ const t = this[Symbol.metadata];
110
+ if (t !== null) {
111
+ const e = litPropertyMetadata.get(t);
112
+ if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i);
113
+ }
114
+ this._$Eh = /* @__PURE__ */ new Map();
115
+ for (const [e, s] of this.elementProperties) {
116
+ const i = this._$Eu(e, s);
117
+ i !== void 0 && this._$Eh.set(i, e);
118
+ }
119
+ this.elementStyles = this.finalizeStyles(this.styles);
120
+ }
121
+ static finalizeStyles(t) {
122
+ const e = [];
123
+ if (Array.isArray(t)) {
124
+ const s = new Set(t.flat(1 / 0).reverse());
125
+ for (const i of s) e.unshift(K(i));
126
+ } else t !== void 0 && e.push(K(t));
127
+ return e;
128
+ }
129
+ static _$Eu(t, e) {
130
+ const s = e.attribute;
131
+ return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
132
+ }
133
+ constructor() {
134
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
135
+ }
136
+ _$Ev() {
137
+ var t;
138
+ this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
139
+ }
140
+ addController(t) {
141
+ var e;
142
+ (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
143
+ }
144
+ removeController(t) {
145
+ var e;
146
+ (e = this._$EO) == null || e.delete(t);
147
+ }
148
+ _$E_() {
149
+ const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
150
+ for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
151
+ t.size > 0 && (this._$Ep = t);
152
+ }
153
+ createRenderRoot() {
154
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
155
+ return ut(t, this.constructor.elementStyles), t;
48
156
  }
49
157
  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
- );
158
+ var t;
159
+ this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
160
+ var s;
161
+ return (s = e.hostConnected) == null ? void 0 : s.call(e);
162
+ });
163
+ }
164
+ enableUpdating(t) {
165
+ }
166
+ disconnectedCallback() {
167
+ var t;
168
+ (t = this._$EO) == null || t.forEach((e) => {
169
+ var s;
170
+ return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
64
171
  });
65
172
  }
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() {
173
+ attributeChangedCallback(t, e, s) {
174
+ this._$AK(t, s);
175
+ }
176
+ _$ET(t, e) {
177
+ var o;
178
+ const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
179
+ if (i !== void 0 && s.reflect === !0) {
180
+ const n = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : z).toAttribute(e, s.type);
181
+ this._$Em = t, n == null ? this.removeAttribute(i) : this.setAttribute(i, n), this._$Em = null;
182
+ }
183
+ }
184
+ _$AK(t, e) {
185
+ var o, n;
186
+ const s = this.constructor, i = s._$Eh.get(t);
187
+ if (i !== void 0 && this._$Em !== i) {
188
+ const l = s.getPropertyOptions(i), h = typeof l.converter == "function" ? { fromAttribute: l.converter } : ((o = l.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? l.converter : z;
189
+ this._$Em = i;
190
+ const c = h.fromAttribute(e, l.type);
191
+ this[i] = c ?? ((n = this._$Ej) == null ? void 0 : n.get(i)) ?? c, this._$Em = null;
192
+ }
193
+ }
194
+ requestUpdate(t, e, s, i = !1, o) {
195
+ var n;
196
+ if (t !== void 0) {
197
+ const l = this.constructor;
198
+ if (i === !1 && (o = this[t]), s ?? (s = l.getPropertyOptions(t)), !((s.hasChanged ?? V)(o, e) || s.useDefault && s.reflect && o === ((n = this._$Ej) == null ? void 0 : n.get(t)) && !this.hasAttribute(l._$Eu(t, s)))) return;
199
+ this.C(t, e, s);
200
+ }
201
+ this.isUpdatePending === !1 && (this._$ES = this._$EP());
202
+ }
203
+ C(t, e, { useDefault: s, reflect: i, wrapped: o }, n) {
204
+ s && !(this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Map())).has(t) && (this._$Ej.set(t, n ?? e ?? this[t]), o !== !0 || n !== void 0) || (this._$AL.has(t) || (this.hasUpdated || s || (e = void 0), this._$AL.set(t, e)), i === !0 && this._$Em !== t && (this._$Eq ?? (this._$Eq = /* @__PURE__ */ new Set())).add(t));
205
+ }
206
+ async _$EP() {
207
+ this.isUpdatePending = !0;
208
+ try {
209
+ await this._$ES;
210
+ } catch (e) {
211
+ Promise.reject(e);
212
+ }
213
+ const t = this.scheduleUpdate();
214
+ return t != null && await t, !this.isUpdatePending;
215
+ }
216
+ scheduleUpdate() {
217
+ return this.performUpdate();
218
+ }
219
+ performUpdate() {
220
+ var s;
221
+ if (!this.isUpdatePending) return;
222
+ if (!this.hasUpdated) {
223
+ if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
224
+ for (const [o, n] of this._$Ep) this[o] = n;
225
+ this._$Ep = void 0;
226
+ }
227
+ const i = this.constructor.elementProperties;
228
+ if (i.size > 0) for (const [o, n] of i) {
229
+ const { wrapped: l } = n, h = this[o];
230
+ l !== !0 || this._$AL.has(o) || h === void 0 || this.C(o, void 0, n, h);
231
+ }
232
+ }
233
+ let t = !1;
234
+ const e = this._$AL;
235
+ try {
236
+ t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((i) => {
237
+ var o;
238
+ return (o = i.hostUpdate) == null ? void 0 : o.call(i);
239
+ }), this.update(e)) : this._$EM();
240
+ } catch (i) {
241
+ throw t = !1, this._$EM(), i;
242
+ }
243
+ t && this._$AE(e);
244
+ }
245
+ willUpdate(t) {
246
+ }
247
+ _$AE(t) {
98
248
  var e;
99
- return ((e = this._textarea) == null ? void 0 : e.value) ?? "";
249
+ (e = this._$EO) == null || e.forEach((s) => {
250
+ var i;
251
+ return (i = s.hostUpdated) == null ? void 0 : i.call(s);
252
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
253
+ }
254
+ _$EM() {
255
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
256
+ }
257
+ get updateComplete() {
258
+ return this.getUpdateComplete();
259
+ }
260
+ getUpdateComplete() {
261
+ return this._$ES;
262
+ }
263
+ shouldUpdate(t) {
264
+ return !0;
265
+ }
266
+ update(t) {
267
+ this._$Eq && (this._$Eq = this._$Eq.forEach((e) => this._$ET(e, this[e]))), this._$EM();
268
+ }
269
+ updated(t) {
270
+ }
271
+ firstUpdated(t) {
272
+ }
273
+ };
274
+ E.elementStyles = [], E.shadowRootOptions = { mode: "open" }, E[P("elementProperties")] = /* @__PURE__ */ new Map(), E[P("finalized")] = /* @__PURE__ */ new Map(), j == null || j({ ReactiveElement: E }), (g.reactiveElementVersions ?? (g.reactiveElementVersions = [])).push("2.1.2");
275
+ /**
276
+ * @license
277
+ * Copyright 2017 Google LLC
278
+ * SPDX-License-Identifier: BSD-3-Clause
279
+ */
280
+ const O = globalThis, Q = (r) => r, L = O.trustedTypes, X = L ? L.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, lt = "$lit$", _ = `lit$${Math.random().toFixed(9).slice(2)}$`, at = "?" + _, vt = `<${at}>`, v = document, k = () => v.createComment(""), M = (r) => r === null || typeof r != "object" && typeof r != "function", G = Array.isArray, bt = (r) => G(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", I = `[
281
+ \f\r]`, C = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Y = /-->/g, tt = />/g, A = RegExp(`>|${I}(?:([^\\s"'>=/]+)(${I}*=${I}*(?:[^
282
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), et = /'/g, st = /"/g, ct = /^(?:script|style|textarea|title)$/i, Et = (r) => (t, ...e) => ({ _$litType$: r, strings: t, values: e }), it = Et(1), S = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), rt = /* @__PURE__ */ new WeakMap(), m = v.createTreeWalker(v, 129);
283
+ function pt(r, t) {
284
+ if (!G(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array");
285
+ return X !== void 0 ? X.createHTML(t) : t;
286
+ }
287
+ const St = (r, t) => {
288
+ const e = r.length - 1, s = [];
289
+ let i, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", n = C;
290
+ for (let l = 0; l < e; l++) {
291
+ const h = r[l];
292
+ let c, d, a = -1, u = 0;
293
+ for (; u < h.length && (n.lastIndex = u, d = n.exec(h), d !== null); ) u = n.lastIndex, n === C ? d[1] === "!--" ? n = Y : d[1] !== void 0 ? n = tt : d[2] !== void 0 ? (ct.test(d[2]) && (i = RegExp("</" + d[2], "g")), n = A) : d[3] !== void 0 && (n = A) : n === A ? d[0] === ">" ? (n = i ?? C, a = -1) : d[1] === void 0 ? a = -2 : (a = n.lastIndex - d[2].length, c = d[1], n = d[3] === void 0 ? A : d[3] === '"' ? st : et) : n === st || n === et ? n = A : n === Y || n === tt ? n = C : (n = A, i = void 0);
294
+ const f = n === A && r[l + 1].startsWith("/>") ? " " : "";
295
+ o += n === C ? h + vt : a >= 0 ? (s.push(c), h.slice(0, a) + lt + h.slice(a) + _ + f) : h + _ + (a === -2 ? l : f);
296
+ }
297
+ return [pt(r, o + (r[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
298
+ };
299
+ class N {
300
+ constructor({ strings: t, _$litType$: e }, s) {
301
+ let i;
302
+ this.parts = [];
303
+ let o = 0, n = 0;
304
+ const l = t.length - 1, h = this.parts, [c, d] = St(t, e);
305
+ if (this.el = N.createElement(c, s), m.currentNode = this.el.content, e === 2 || e === 3) {
306
+ const a = this.el.content.firstChild;
307
+ a.replaceWith(...a.childNodes);
308
+ }
309
+ for (; (i = m.nextNode()) !== null && h.length < l; ) {
310
+ if (i.nodeType === 1) {
311
+ if (i.hasAttributes()) for (const a of i.getAttributeNames()) if (a.endsWith(lt)) {
312
+ const u = d[n++], f = i.getAttribute(a).split(_), H = /([.?@])?(.*)/.exec(u);
313
+ h.push({ type: 1, index: o, name: H[2], strings: f, ctor: H[1] === "." ? xt : H[1] === "?" ? Ct : H[1] === "@" ? Pt : D }), i.removeAttribute(a);
314
+ } else a.startsWith(_) && (h.push({ type: 6, index: o }), i.removeAttribute(a));
315
+ if (ct.test(i.tagName)) {
316
+ const a = i.textContent.split(_), u = a.length - 1;
317
+ if (u > 0) {
318
+ i.textContent = L ? L.emptyScript : "";
319
+ for (let f = 0; f < u; f++) i.append(a[f], k()), m.nextNode(), h.push({ type: 2, index: ++o });
320
+ i.append(a[u], k());
321
+ }
322
+ }
323
+ } else if (i.nodeType === 8) if (i.data === at) h.push({ type: 2, index: o });
324
+ else {
325
+ let a = -1;
326
+ for (; (a = i.data.indexOf(_, a + 1)) !== -1; ) h.push({ type: 7, index: o }), a += _.length - 1;
327
+ }
328
+ o++;
329
+ }
330
+ }
331
+ static createElement(t, e) {
332
+ const s = v.createElement("template");
333
+ return s.innerHTML = t, s;
334
+ }
335
+ }
336
+ function w(r, t, e = r, s) {
337
+ var n, l;
338
+ if (t === S) return t;
339
+ let i = s !== void 0 ? (n = e._$Co) == null ? void 0 : n[s] : e._$Cl;
340
+ const o = M(t) ? void 0 : t._$litDirective$;
341
+ return (i == null ? void 0 : i.constructor) !== o && ((l = i == null ? void 0 : i._$AO) == null || l.call(i, !1), o === void 0 ? i = void 0 : (i = new o(r), i._$AT(r, e, s)), s !== void 0 ? (e._$Co ?? (e._$Co = []))[s] = i : e._$Cl = i), i !== void 0 && (t = w(r, i._$AS(r, t.values), i, s)), t;
342
+ }
343
+ class wt {
344
+ constructor(t, e) {
345
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
346
+ }
347
+ get parentNode() {
348
+ return this._$AM.parentNode;
349
+ }
350
+ get _$AU() {
351
+ return this._$AM._$AU;
352
+ }
353
+ u(t) {
354
+ const { el: { content: e }, parts: s } = this._$AD, i = ((t == null ? void 0 : t.creationScope) ?? v).importNode(e, !0);
355
+ m.currentNode = i;
356
+ let o = m.nextNode(), n = 0, l = 0, h = s[0];
357
+ for (; h !== void 0; ) {
358
+ if (n === h.index) {
359
+ let c;
360
+ h.type === 2 ? c = new T(o, o.nextSibling, this, t) : h.type === 1 ? c = new h.ctor(o, h.name, h.strings, this, t) : h.type === 6 && (c = new Ot(o, this, t)), this._$AV.push(c), h = s[++l];
361
+ }
362
+ n !== (h == null ? void 0 : h.index) && (o = m.nextNode(), n++);
363
+ }
364
+ return m.currentNode = v, i;
100
365
  }
101
- set value(e) {
102
- this._textarea && (this._textarea.value = e ?? "");
366
+ p(t) {
367
+ let e = 0;
368
+ for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
103
369
  }
104
370
  }
105
- customElements.define("sa-spell-checker", r);
371
+ class T {
372
+ get _$AU() {
373
+ var t;
374
+ return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
375
+ }
376
+ constructor(t, e, s, i) {
377
+ this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = i, this._$Cv = (i == null ? void 0 : i.isConnected) ?? !0;
378
+ }
379
+ get parentNode() {
380
+ let t = this._$AA.parentNode;
381
+ const e = this._$AM;
382
+ return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
383
+ }
384
+ get startNode() {
385
+ return this._$AA;
386
+ }
387
+ get endNode() {
388
+ return this._$AB;
389
+ }
390
+ _$AI(t, e = this) {
391
+ t = w(this, t, e), M(t) ? t === p || t == null || t === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : t !== this._$AH && t !== S && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : bt(t) ? this.k(t) : this._(t);
392
+ }
393
+ O(t) {
394
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
395
+ }
396
+ T(t) {
397
+ this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
398
+ }
399
+ _(t) {
400
+ this._$AH !== p && M(this._$AH) ? this._$AA.nextSibling.data = t : this.T(v.createTextNode(t)), this._$AH = t;
401
+ }
402
+ $(t) {
403
+ var o;
404
+ const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = N.createElement(pt(s.h, s.h[0]), this.options)), s);
405
+ if (((o = this._$AH) == null ? void 0 : o._$AD) === i) this._$AH.p(e);
406
+ else {
407
+ const n = new wt(i, this), l = n.u(this.options);
408
+ n.p(e), this.T(l), this._$AH = n;
409
+ }
410
+ }
411
+ _$AC(t) {
412
+ let e = rt.get(t.strings);
413
+ return e === void 0 && rt.set(t.strings, e = new N(t)), e;
414
+ }
415
+ k(t) {
416
+ G(this._$AH) || (this._$AH = [], this._$AR());
417
+ const e = this._$AH;
418
+ let s, i = 0;
419
+ for (const o of t) i === e.length ? e.push(s = new T(this.O(k()), this.O(k()), this, this.options)) : s = e[i], s._$AI(o), i++;
420
+ i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i);
421
+ }
422
+ _$AR(t = this._$AA.nextSibling, e) {
423
+ var s;
424
+ for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, e); t !== this._$AB; ) {
425
+ const i = Q(t).nextSibling;
426
+ Q(t).remove(), t = i;
427
+ }
428
+ }
429
+ setConnected(t) {
430
+ var e;
431
+ this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
432
+ }
433
+ }
434
+ class D {
435
+ get tagName() {
436
+ return this.element.tagName;
437
+ }
438
+ get _$AU() {
439
+ return this._$AM._$AU;
440
+ }
441
+ constructor(t, e, s, i, o) {
442
+ this.type = 1, this._$AH = p, this._$AN = void 0, this.element = t, this.name = e, this._$AM = i, this.options = o, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = p;
443
+ }
444
+ _$AI(t, e = this, s, i) {
445
+ const o = this.strings;
446
+ let n = !1;
447
+ if (o === void 0) t = w(this, t, e, 0), n = !M(t) || t !== this._$AH && t !== S, n && (this._$AH = t);
448
+ else {
449
+ const l = t;
450
+ let h, c;
451
+ for (t = o[0], h = 0; h < o.length - 1; h++) c = w(this, l[s + h], e, h), c === S && (c = this._$AH[h]), n || (n = !M(c) || c !== this._$AH[h]), c === p ? t = p : t !== p && (t += (c ?? "") + o[h + 1]), this._$AH[h] = c;
452
+ }
453
+ n && !i && this.j(t);
454
+ }
455
+ j(t) {
456
+ t === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
457
+ }
458
+ }
459
+ class xt extends D {
460
+ constructor() {
461
+ super(...arguments), this.type = 3;
462
+ }
463
+ j(t) {
464
+ this.element[this.name] = t === p ? void 0 : t;
465
+ }
466
+ }
467
+ class Ct extends D {
468
+ constructor() {
469
+ super(...arguments), this.type = 4;
470
+ }
471
+ j(t) {
472
+ this.element.toggleAttribute(this.name, !!t && t !== p);
473
+ }
474
+ }
475
+ class Pt extends D {
476
+ constructor(t, e, s, i, o) {
477
+ super(t, e, s, i, o), this.type = 5;
478
+ }
479
+ _$AI(t, e = this) {
480
+ if ((t = w(this, t, e, 0) ?? p) === S) return;
481
+ const s = this._$AH, i = t === p && s !== p || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, o = t !== p && (s === p || i);
482
+ i && this.element.removeEventListener(this.name, this, s), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
483
+ }
484
+ handleEvent(t) {
485
+ var e;
486
+ typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
487
+ }
488
+ }
489
+ class Ot {
490
+ constructor(t, e, s) {
491
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
492
+ }
493
+ get _$AU() {
494
+ return this._$AM._$AU;
495
+ }
496
+ _$AI(t) {
497
+ w(this, t);
498
+ }
499
+ }
500
+ const B = O.litHtmlPolyfillSupport;
501
+ B == null || B(N, T), (O.litHtmlVersions ?? (O.litHtmlVersions = [])).push("3.3.2");
502
+ const Ut = (r, t, e) => {
503
+ const s = (e == null ? void 0 : e.renderBefore) ?? t;
504
+ let i = s._$litPart$;
505
+ if (i === void 0) {
506
+ const o = (e == null ? void 0 : e.renderBefore) ?? null;
507
+ s._$litPart$ = i = new T(t.insertBefore(k(), o), o, void 0, e ?? {});
508
+ }
509
+ return i._$AI(r), i;
510
+ };
511
+ /**
512
+ * @license
513
+ * Copyright 2017 Google LLC
514
+ * SPDX-License-Identifier: BSD-3-Clause
515
+ */
516
+ const y = globalThis;
517
+ class U extends E {
518
+ constructor() {
519
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
520
+ }
521
+ createRenderRoot() {
522
+ var e;
523
+ const t = super.createRenderRoot();
524
+ return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t;
525
+ }
526
+ update(t) {
527
+ const e = this.render();
528
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Ut(e, this.renderRoot, this.renderOptions);
529
+ }
530
+ connectedCallback() {
531
+ var t;
532
+ super.connectedCallback(), (t = this._$Do) == null || t.setConnected(!0);
533
+ }
534
+ disconnectedCallback() {
535
+ var t;
536
+ super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1);
537
+ }
538
+ render() {
539
+ return S;
540
+ }
541
+ }
542
+ var ot;
543
+ U._$litElement$ = !0, U.finalized = !0, (ot = y.litElementHydrateSupport) == null || ot.call(y, { LitElement: U });
544
+ const q = y.litElementPolyfillSupport;
545
+ q == null || q({ LitElement: U });
546
+ (y.litElementVersions ?? (y.litElementVersions = [])).push("4.2.2");
547
+ /**
548
+ * @license
549
+ * Copyright 2017 Google LLC
550
+ * SPDX-License-Identifier: BSD-3-Clause
551
+ */
552
+ const kt = (r) => (t, e) => {
553
+ e !== void 0 ? e.addInitializer(() => {
554
+ customElements.define(r, t);
555
+ }) : customElements.define(r, t);
556
+ };
557
+ /**
558
+ * @license
559
+ * Copyright 2017 Google LLC
560
+ * SPDX-License-Identifier: BSD-3-Clause
561
+ */
562
+ const Mt = { attribute: !0, type: String, converter: z, reflect: !1, hasChanged: V }, Nt = (r = Mt, t, e) => {
563
+ const { kind: s, metadata: i } = e;
564
+ let o = globalThis.litPropertyMetadata.get(i);
565
+ if (o === void 0 && globalThis.litPropertyMetadata.set(i, o = /* @__PURE__ */ new Map()), s === "setter" && ((r = Object.create(r)).wrapped = !0), o.set(e.name, r), s === "accessor") {
566
+ const { name: n } = e;
567
+ return { set(l) {
568
+ const h = t.get.call(this);
569
+ t.set.call(this, l), this.requestUpdate(n, h, r, !0, l);
570
+ }, init(l) {
571
+ return l !== void 0 && this.C(n, void 0, r, l), l;
572
+ } };
573
+ }
574
+ if (s === "setter") {
575
+ const { name: n } = e;
576
+ return function(l) {
577
+ const h = this[n];
578
+ t.call(this, l), this.requestUpdate(n, h, r, !0, l);
579
+ };
580
+ }
581
+ throw Error("Unsupported decorator location: " + s);
582
+ };
583
+ function x(r) {
584
+ return (t, e) => typeof e == "object" ? Nt(r, t, e) : ((s, i, o) => {
585
+ const n = i.hasOwnProperty(o);
586
+ return i.constructor.createProperty(o, s), n ? Object.getOwnPropertyDescriptor(i, o) : void 0;
587
+ })(r, t, e);
588
+ }
589
+ /**
590
+ * @license
591
+ * Copyright 2017 Google LLC
592
+ * SPDX-License-Identifier: BSD-3-Clause
593
+ */
594
+ function Tt(r) {
595
+ return x({ ...r, state: !0, attribute: !1 });
596
+ }
597
+ const Ht = ":host{display:block;width:100%;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.controls{display:flex;gap:12px;align-items:center;margin-bottom:8px;flex-wrap:wrap}.controls label{font-size:12px;font-weight:600;color:#374151}button{font-size:12px;padding:3px 10px;border-radius:4px;cursor:pointer;border:1px solid #76b900;background:#76b900;color:#fff;font-weight:600}button.off{background:#fff;color:#6b7280;border-color:#d1d5db}select{font-size:12px;padding:3px 8px;border:1px solid #d1d5db;border-radius:4px;cursor:pointer;color:#374151}textarea{width:100%;min-height:80px;box-sizing:border-box;font-family:inherit;font-size:14px;line-height:1.5;color:#111827;background:#fff;border:1px solid #d1d5db;border-radius:6px;padding:8px 12px;resize:vertical;outline:none;transition:border-color .15s,box-shadow .15s}textarea:focus{border-color:#6366f1;box-shadow:0 0 0 3px #6366f11f}textarea::placeholder{color:#9ca3af}";
598
+ var Rt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, b = (r, t, e, s) => {
599
+ for (var i = s > 1 ? void 0 : s ? zt(t, e) : t, o = r.length - 1, n; o >= 0; o--)
600
+ (n = r[o]) && (i = (s ? n(t, e, i) : n(i)) || i);
601
+ return s && i && Rt(t, e, i), i;
602
+ };
603
+ let $ = class extends U {
604
+ constructor() {
605
+ super(...arguments), this.spellcheck = !0, this.lang = "en-US", this.placeholder = "Type here...", this.value = "", this.rows = 4, this._spellcheckOn = !0, this.LANGUAGES = [
606
+ { value: "en-US", label: "English (US)" },
607
+ { value: "en-GB", label: "English (UK)" },
608
+ { value: "fr", label: "French" },
609
+ { value: "de", label: "German" },
610
+ { value: "es", label: "Spanish" },
611
+ { value: "ko", label: "Korean" }
612
+ ];
613
+ }
614
+ connectedCallback() {
615
+ super.connectedCallback(), this._spellcheckOn = this.spellcheck;
616
+ }
617
+ _onToggle() {
618
+ this._spellcheckOn = !this._spellcheckOn;
619
+ }
620
+ _onLangChange(r) {
621
+ this.lang = r.target.value;
622
+ }
623
+ _onInput(r) {
624
+ this.value = r.target.value, this.dispatchEvent(
625
+ new CustomEvent("sa-change", {
626
+ detail: { value: this.value },
627
+ bubbles: !0,
628
+ composed: !0
629
+ })
630
+ );
631
+ }
632
+ render() {
633
+ return it`
634
+ <div class="controls">
635
+ <label>Spellcheck:</label>
636
+ <button
637
+ class=${this._spellcheckOn ? "" : "off"}
638
+ @click=${this._onToggle}
639
+ >
640
+ ${this._spellcheckOn ? "ON" : "OFF"}
641
+ </button>
642
+
643
+ <label>Language:</label>
644
+ <select @change=${this._onLangChange}>
645
+ ${this.LANGUAGES.map(
646
+ ({ value: r, label: t }) => it`
647
+ <option value=${r} ?selected=${r === this.lang}>
648
+ ${t}
649
+ </option>
650
+ `
651
+ )}
652
+ </select>
653
+ </div>
654
+
655
+ <textarea
656
+ .value=${this.value}
657
+ placeholder=${this.placeholder}
658
+ rows=${this.rows}
659
+ lang=${this.lang}
660
+ ?spellcheck=${this._spellcheckOn}
661
+ @input=${this._onInput}
662
+ ></textarea>
663
+ `;
664
+ }
665
+ };
666
+ $.styles = ht(Ht);
667
+ b([
668
+ x({ type: Boolean })
669
+ ], $.prototype, "spellcheck", 2);
670
+ b([
671
+ x()
672
+ ], $.prototype, "lang", 2);
673
+ b([
674
+ x()
675
+ ], $.prototype, "placeholder", 2);
676
+ b([
677
+ x()
678
+ ], $.prototype, "value", 2);
679
+ b([
680
+ x({ type: Number })
681
+ ], $.prototype, "rows", 2);
682
+ b([
683
+ Tt()
684
+ ], $.prototype, "_spellcheckOn", 2);
685
+ $ = b([
686
+ kt("sa-spell-checker")
687
+ ], $);
688
+ export {
689
+ $ as SaSpellChecker
690
+ };
@@ -1,49 +1,59 @@
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
- }
1
+ (function(u,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(u=typeof globalThis<"u"?globalThis:u||self,f(u.SaSpellChecker={}))})(this,function(u){"use strict";/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */var pe;const f=globalThis,D=f.ShadowRoot&&(f.ShadyCSS===void 0||f.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,F=Symbol(),K=new WeakMap;let de=class{constructor(e,t,s){if(this._$cssResult$=!0,s!==F)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(D&&e===void 0){const s=t!==void 0&&t.length===1;s&&(e=K.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),s&&K.set(t,e))}return e}toString(){return this.cssText}};const Z=r=>new de(typeof r=="string"?r:r+"",void 0,F),ue=(r,e)=>{if(D)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const s=document.createElement("style"),i=f.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=t.cssText,r.appendChild(s)}},J=D?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(const s of e.cssRules)t+=s.cssText;return Z(t)})(r):r;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */const{is:$e,defineProperty:fe,getOwnPropertyDescriptor:_e,getOwnPropertyNames:ge,getOwnPropertySymbols:ye,getPrototypeOf:me}=Object,_=globalThis,Q=_.trustedTypes,Ae=Q?Q.emptyScript:"",I=_.reactiveElementPolyfillSupport,P=(r,e)=>r,R={toAttribute(r,e){switch(e){case Boolean:r=r?Ae:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},B=(r,e)=>!$e(r,e),X={attribute:!0,type:String,converter:R,reflect:!1,useDefault:!1,hasChanged:B};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),_.litPropertyMetadata??(_.litPropertyMetadata=new WeakMap);let E=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=X){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(e,s,t);i!==void 0&&fe(this.prototype,e,i)}}static getPropertyDescriptor(e,t,s){const{get:i,set:n}=_e(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get:i,set(o){const h=i==null?void 0:i.call(this);n==null||n.call(this,o),this.requestUpdate(e,h,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??X}static _$Ei(){if(this.hasOwnProperty(P("elementProperties")))return;const e=me(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(P("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(P("properties"))){const t=this.properties,s=[...ge(t),...ye(t)];for(const i of s)this.createProperty(i,t[i])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[s,i]of t)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);i!==void 0&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const s=new Set(e.flat(1/0).reverse());for(const i of s)t.unshift(J(i))}else e!==void 0&&t.push(J(e));return t}static _$Eu(e,t){const s=t.attribute;return s===!1?void 0:typeof s=="string"?s:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const s of t.keys())this.hasOwnProperty(s)&&(e.set(s,this[s]),delete this[s]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ue(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var s;return(s=t.hostConnected)==null?void 0:s.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var s;return(s=t.hostDisconnected)==null?void 0:s.call(t)})}attributeChangedCallback(e,t,s){this._$AK(e,s)}_$ET(e,t){var n;const s=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,s);if(i!==void 0&&s.reflect===!0){const o=(((n=s.converter)==null?void 0:n.toAttribute)!==void 0?s.converter:R).toAttribute(t,s.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,t){var n,o;const s=this.constructor,i=s._$Eh.get(e);if(i!==void 0&&this._$Em!==i){const h=s.getPropertyOptions(i),l=typeof h.converter=="function"?{fromAttribute:h.converter}:((n=h.converter)==null?void 0:n.fromAttribute)!==void 0?h.converter:R;this._$Em=i;const c=l.fromAttribute(t,h.type);this[i]=c??((o=this._$Ej)==null?void 0:o.get(i))??c,this._$Em=null}}requestUpdate(e,t,s,i=!1,n){var o;if(e!==void 0){const h=this.constructor;if(i===!1&&(n=this[e]),s??(s=h.getPropertyOptions(e)),!((s.hasChanged??B)(n,t)||s.useDefault&&s.reflect&&n===((o=this._$Ej)==null?void 0:o.get(e))&&!this.hasAttribute(h._$Eu(e,s))))return;this.C(e,t,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,o??t??this[e]),n!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||s||(t=void 0),this._$AL.set(e,t)),i===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[n,o]of i){const{wrapped:h}=o,l=this[n];h!==!0||this._$AL.has(n)||l===void 0||this.C(n,void 0,o,l)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(s=this._$EO)==null||s.forEach(i=>{var n;return(n=i.hostUpdate)==null?void 0:n.call(i)}),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};E.elementStyles=[],E.shadowRootOptions={mode:"open"},E[P("elementProperties")]=new Map,E[P("finalized")]=new Map,I==null||I({ReactiveElement:E}),(_.reactiveElementVersions??(_.reactiveElementVersions=[])).push("2.1.2");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */const O=globalThis,Y=r=>r,z=O.trustedTypes,ee=z?z.createPolicy("lit-html",{createHTML:r=>r}):void 0,te="$lit$",g=`lit$${Math.random().toFixed(9).slice(2)}$`,se="?"+g,ve=`<${se}>`,m=document,U=()=>m.createComment(""),k=r=>r===null||typeof r!="object"&&typeof r!="function",q=Array.isArray,be=r=>q(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",W=`[
14
+ \f\r]`,T=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ie=/-->/g,re=/>/g,A=RegExp(`>|${W}(?:([^\\s"'>=/]+)(${W}*=${W}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),ne=/'/g,oe=/"/g,le=/^(?:script|style|textarea|title)$/i,Se=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),he=Se(1),w=Symbol.for("lit-noChange"),p=Symbol.for("lit-nothing"),ae=new WeakMap,v=m.createTreeWalker(m,129);function ce(r,e){if(!q(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return ee!==void 0?ee.createHTML(e):e}const Ee=(r,e)=>{const t=r.length-1,s=[];let i,n=e===2?"<svg>":e===3?"<math>":"",o=T;for(let h=0;h<t;h++){const l=r[h];let c,d,a=-1,$=0;for(;$<l.length&&(o.lastIndex=$,d=o.exec(l),d!==null);)$=o.lastIndex,o===T?d[1]==="!--"?o=ie:d[1]!==void 0?o=re:d[2]!==void 0?(le.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=A):d[3]!==void 0&&(o=A):o===A?d[0]===">"?(o=i??T,a=-1):d[1]===void 0?a=-2:(a=o.lastIndex-d[2].length,c=d[1],o=d[3]===void 0?A:d[3]==='"'?oe:ne):o===oe||o===ne?o=A:o===ie||o===re?o=T:(o=A,i=void 0);const y=o===A&&r[h+1].startsWith("/>")?" ":"";n+=o===T?l+ve:a>=0?(s.push(c),l.slice(0,a)+te+l.slice(a)+g+y):l+g+(a===-2?h:y)}return[ce(r,n+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),s]};class M{constructor({strings:e,_$litType$:t},s){let i;this.parts=[];let n=0,o=0;const h=e.length-1,l=this.parts,[c,d]=Ee(e,t);if(this.el=M.createElement(c,s),v.currentNode=this.el.content,t===2||t===3){const a=this.el.content.firstChild;a.replaceWith(...a.childNodes)}for(;(i=v.nextNode())!==null&&l.length<h;){if(i.nodeType===1){if(i.hasAttributes())for(const a of i.getAttributeNames())if(a.endsWith(te)){const $=d[o++],y=i.getAttribute(a).split(g),L=/([.?@])?(.*)/.exec($);l.push({type:1,index:n,name:L[2],strings:y,ctor:L[1]==="."?Ce:L[1]==="?"?xe:L[1]==="@"?Pe:j}),i.removeAttribute(a)}else a.startsWith(g)&&(l.push({type:6,index:n}),i.removeAttribute(a));if(le.test(i.tagName)){const a=i.textContent.split(g),$=a.length-1;if($>0){i.textContent=z?z.emptyScript:"";for(let y=0;y<$;y++)i.append(a[y],U()),v.nextNode(),l.push({type:2,index:++n});i.append(a[$],U())}}}else if(i.nodeType===8)if(i.data===se)l.push({type:2,index:n});else{let a=-1;for(;(a=i.data.indexOf(g,a+1))!==-1;)l.push({type:7,index:n}),a+=g.length-1}n++}}static createElement(e,t){const s=m.createElement("template");return s.innerHTML=e,s}}function C(r,e,t=r,s){var o,h;if(e===w)return e;let i=s!==void 0?(o=t._$Co)==null?void 0:o[s]:t._$Cl;const n=k(e)?void 0:e._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((h=i==null?void 0:i._$AO)==null||h.call(i,!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,t,s)),s!==void 0?(t._$Co??(t._$Co=[]))[s]=i:t._$Cl=i),i!==void 0&&(e=C(r,i._$AS(r,e.values),i,s)),e}class we{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:s}=this._$AD,i=((e==null?void 0:e.creationScope)??m).importNode(t,!0);v.currentNode=i;let n=v.nextNode(),o=0,h=0,l=s[0];for(;l!==void 0;){if(o===l.index){let c;l.type===2?c=new N(n,n.nextSibling,this,e):l.type===1?c=new l.ctor(n,l.name,l.strings,this,e):l.type===6&&(c=new Oe(n,this,e)),this._$AV.push(c),l=s[++h]}o!==(l==null?void 0:l.index)&&(n=v.nextNode(),o++)}return v.currentNode=m,i}p(e){let t=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(e,s,t),t+=s.strings.length-2):s._$AI(e[t])),t++}}class N{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,s,i){this.type=2,this._$AH=p,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=C(this,e,t),k(e)?e===p||e==null||e===""?(this._$AH!==p&&this._$AR(),this._$AH=p):e!==this._$AH&&e!==w&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):be(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==p&&k(this._$AH)?this._$AA.nextSibling.data=e:this.T(m.createTextNode(e)),this._$AH=e}$(e){var n;const{values:t,_$litType$:s}=e,i=typeof s=="number"?this._$AC(e):(s.el===void 0&&(s.el=M.createElement(ce(s.h,s.h[0]),this.options)),s);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(t);else{const o=new we(i,this),h=o.u(this.options);o.p(t),this.T(h),this._$AH=o}}_$AC(e){let t=ae.get(e.strings);return t===void 0&&ae.set(e.strings,t=new M(e)),t}k(e){q(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let s,i=0;for(const n of e)i===t.length?t.push(s=new N(this.O(U()),this.O(U()),this,this.options)):s=t[i],s._$AI(n),i++;i<t.length&&(this._$AR(s&&s._$AB.nextSibling,i),t.length=i)}_$AR(e=this._$AA.nextSibling,t){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,t);e!==this._$AB;){const i=Y(e).nextSibling;Y(e).remove(),e=i}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class j{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,s,i,n){this.type=1,this._$AH=p,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=p}_$AI(e,t=this,s,i){const n=this.strings;let o=!1;if(n===void 0)e=C(this,e,t,0),o=!k(e)||e!==this._$AH&&e!==w,o&&(this._$AH=e);else{const h=e;let l,c;for(e=n[0],l=0;l<n.length-1;l++)c=C(this,h[s+l],t,l),c===w&&(c=this._$AH[l]),o||(o=!k(c)||c!==this._$AH[l]),c===p?e=p:e!==p&&(e+=(c??"")+n[l+1]),this._$AH[l]=c}o&&!i&&this.j(e)}j(e){e===p?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Ce extends j{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===p?void 0:e}}class xe extends j{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==p)}}class Pe extends j{constructor(e,t,s,i,n){super(e,t,s,i,n),this.type=5}_$AI(e,t=this){if((e=C(this,e,t,0)??p)===w)return;const s=this._$AH,i=e===p&&s!==p||e.capture!==s.capture||e.once!==s.once||e.passive!==s.passive,n=e!==p&&(s===p||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class Oe{constructor(e,t,s){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(e){C(this,e)}}const V=O.litHtmlPolyfillSupport;V==null||V(M,N),(O.litHtmlVersions??(O.litHtmlVersions=[])).push("3.3.2");const Ue=(r,e,t)=>{const s=(t==null?void 0:t.renderBefore)??e;let i=s._$litPart$;if(i===void 0){const n=(t==null?void 0:t.renderBefore)??null;s._$litPart$=i=new N(e.insertBefore(U(),n),n,void 0,t??{})}return i._$AI(r),i};/**
16
+ * @license
17
+ * Copyright 2017 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */const b=globalThis;class H extends E{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Ue(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return w}}H._$litElement$=!0,H.finalized=!0,(pe=b.litElementHydrateSupport)==null||pe.call(b,{LitElement:H});const G=b.litElementPolyfillSupport;G==null||G({LitElement:H}),(b.litElementVersions??(b.litElementVersions=[])).push("4.2.2");/**
20
+ * @license
21
+ * Copyright 2017 Google LLC
22
+ * SPDX-License-Identifier: BSD-3-Clause
23
+ */const ke=r=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(r,e)}):customElements.define(r,e)};/**
24
+ * @license
25
+ * Copyright 2017 Google LLC
26
+ * SPDX-License-Identifier: BSD-3-Clause
27
+ */const Te={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:B},Me=(r=Te,e,t)=>{const{kind:s,metadata:i}=t;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),s==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(t.name,r),s==="accessor"){const{name:o}=t;return{set(h){const l=e.get.call(this);e.set.call(this,h),this.requestUpdate(o,l,r,!0,h)},init(h){return h!==void 0&&this.C(o,void 0,r,h),h}}}if(s==="setter"){const{name:o}=t;return function(h){const l=this[o];e.call(this,h),this.requestUpdate(o,l,r,!0,h)}}throw Error("Unsupported decorator location: "+s)};function x(r){return(e,t)=>typeof t=="object"?Me(r,e,t):((s,i,n)=>{const o=i.hasOwnProperty(n);return i.constructor.createProperty(n,s),o?Object.getOwnPropertyDescriptor(i,n):void 0})(r,e,t)}/**
28
+ * @license
29
+ * Copyright 2017 Google LLC
30
+ * SPDX-License-Identifier: BSD-3-Clause
31
+ */function Ne(r){return x({...r,state:!0,attribute:!1})}const He=":host{display:block;width:100%;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.controls{display:flex;gap:12px;align-items:center;margin-bottom:8px;flex-wrap:wrap}.controls label{font-size:12px;font-weight:600;color:#374151}button{font-size:12px;padding:3px 10px;border-radius:4px;cursor:pointer;border:1px solid #76b900;background:#76b900;color:#fff;font-weight:600}button.off{background:#fff;color:#6b7280;border-color:#d1d5db}select{font-size:12px;padding:3px 8px;border:1px solid #d1d5db;border-radius:4px;cursor:pointer;color:#374151}textarea{width:100%;min-height:80px;box-sizing:border-box;font-family:inherit;font-size:14px;line-height:1.5;color:#111827;background:#fff;border:1px solid #d1d5db;border-radius:6px;padding:8px 12px;resize:vertical;outline:none;transition:border-color .15s,box-shadow .15s}textarea:focus{border-color:#6366f1;box-shadow:0 0 0 3px #6366f11f}textarea::placeholder{color:#9ca3af}";var Re=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,S=(r,e,t,s)=>{for(var i=s>1?void 0:s?ze(e,t):e,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(e,t,i):o(i))||i);return s&&i&&Re(e,t,i),i};u.SaSpellChecker=class extends H{constructor(){super(...arguments),this.spellcheck=!0,this.lang="en-US",this.placeholder="Type here...",this.value="",this.rows=4,this._spellcheckOn=!0,this.LANGUAGES=[{value:"en-US",label:"English (US)"},{value:"en-GB",label:"English (UK)"},{value:"fr",label:"French"},{value:"de",label:"German"},{value:"es",label:"Spanish"},{value:"ko",label:"Korean"}]}connectedCallback(){super.connectedCallback(),this._spellcheckOn=this.spellcheck}_onToggle(){this._spellcheckOn=!this._spellcheckOn}_onLangChange(e){this.lang=e.target.value}_onInput(e){this.value=e.target.value,this.dispatchEvent(new CustomEvent("sa-change",{detail:{value:this.value},bubbles:!0,composed:!0}))}render(){return he`
32
+ <div class="controls">
33
+ <label>Spellcheck:</label>
34
+ <button
35
+ class=${this._spellcheckOn?"":"off"}
36
+ @click=${this._onToggle}
37
+ >
38
+ ${this._spellcheckOn?"ON":"OFF"}
39
+ </button>
7
40
 
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>
41
+ <label>Language:</label>
42
+ <select @change=${this._onLangChange}>
43
+ ${this.LANGUAGES.map(({value:e,label:t})=>he`
44
+ <option value=${e} ?selected=${e===this.lang}>
45
+ ${t}
46
+ </option>
47
+ `)}
48
+ </select>
48
49
  </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)});
50
+
51
+ <textarea
52
+ .value=${this.value}
53
+ placeholder=${this.placeholder}
54
+ rows=${this.rows}
55
+ lang=${this.lang}
56
+ ?spellcheck=${this._spellcheckOn}
57
+ @input=${this._onInput}
58
+ ></textarea>
59
+ `}},u.SaSpellChecker.styles=Z(He),S([x({type:Boolean})],u.SaSpellChecker.prototype,"spellcheck",2),S([x()],u.SaSpellChecker.prototype,"lang",2),S([x()],u.SaSpellChecker.prototype,"placeholder",2),S([x()],u.SaSpellChecker.prototype,"value",2),S([x({type:Number})],u.SaSpellChecker.prototype,"rows",2),S([Ne()],u.SaSpellChecker.prototype,"_spellcheckOn",2),u.SaSpellChecker=S([ke("sa-spell-checker")],u.SaSpellChecker),Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,16 +1,22 @@
1
1
  {
2
2
  "name": "sa-spell-checker",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "SuperAnnotate custom spell checker web component",
5
5
  "main": "dist/sa-spell-checker.umd.cjs",
6
6
  "module": "dist/sa-spell-checker.js",
7
- "files": ["dist"],
7
+ "files": [
8
+ "dist"
9
+ ],
8
10
  "scripts": {
9
11
  "dev": "vite",
10
12
  "build": "vite build",
11
13
  "preview": "vite preview"
12
14
  },
13
15
  "devDependencies": {
16
+ "typescript": "^5.9.3",
14
17
  "vite": "^5.4.0"
18
+ },
19
+ "dependencies": {
20
+ "lit": "^3.3.2"
15
21
  }
16
22
  }