@tooark/code 1.9.4 → 1.10.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.
@@ -0,0 +1,442 @@
1
+ import { ARK_SIZE_CSS, observeColorScheme } from '@tooark/tokens';
2
+ import { createCodeEditor } from '../engine/index.js';
3
+ import { HTMLElementBase } from './html-element-base.js';
4
+ import { upgradeProperties } from './upgrade-properties.js';
5
+
6
+ // Mesma regra do coerceBooleanAttr de @tooark/core (este pacote só depende de tokens): frameworks passam o valor do
7
+ // atributo como propriedade, então "" é presente e "false" é ausente.
8
+ function truthy(value) {
9
+ if (value === "" || value === true)
10
+ return true;
11
+ if (value === false || value === null || value === undefined || value === "false")
12
+ return false;
13
+ return Boolean(value);
14
+ }
15
+ /** Sem extensões do app; uma referência só, para `null` repetido não reconfigurar o editor. */
16
+ const NO_EXTENSIONS = [];
17
+ /**
18
+ * Custom Element que renderiza um editor de código CodeMirror 6.
19
+ *
20
+ * O texto vai pela propriedade `value` (ou pelo atributo `value` como valor
21
+ * inicial) e volta em `change` com `detail: { value }` a cada edição do
22
+ * usuário. Atributos: `language` (json | javascript | yaml | text),
23
+ * `readonly`, `placeholder`, `min-height` e `max-height` (comprimentos CSS;
24
+ * acima da máxima o conteúdo rola por dentro), `line-numbers`,
25
+ * `fold`, `tab-indent` e `autocomplete` (ligados por padrão; "false"
26
+ * desliga), `wrap`, `indent-style` (space | tab), `indent-size`,
27
+ * `line-ending` (lf | crlf | auto), `theme` (auto | light | dark),
28
+ * `aria-label` (vai para o conteúdo editável, o `role="textbox"`) e
29
+ * `testid`. Propriedades JS: `variableKeys` (completions depois de `{{`),
30
+ * `completions` (palavras oferecidas em qualquer linguagem),
31
+ * `completionSource` (fonte própria), `formatter` (formatador do app;
32
+ * sem ele só JSON formata) e `format()`, também por Shift+Alt+F. Tab recua e
33
+ * Esc+Tab sai do editor. Em `auto` o tema segue o color-scheme da página e
34
+ * acompanha a troca em tempo de execução (`observeColorScheme` de
35
+ * @tooark/tokens). O nó do CodeMirror leva `data-ark="code-editor"` e o
36
+ * `testid` como `data-testid`.
37
+ *
38
+ * Opcionais, desligados até o app pedir: a propriedade `variables` pinta
39
+ * cada `{{chave}}` pelo intent da variável, com tooltip do escopo e do valor;
40
+ * `mark-unknown-variables` pinta em `danger` a chave desconhecida;
41
+ * `single-line` vira um campo de uma linha na altura dos controles (`size`),
42
+ * com Enter emitindo `ark-submit` (`detail: { value }`); a propriedade
43
+ * `extensions` soma extensões do CodeMirror do app (gramáticas que a lib não
44
+ * traz, calhas, decorações) às da lib, sem recriar o editor.
45
+ */
46
+ class ArkCodeEditor extends HTMLElementBase {
47
+ constructor() {
48
+ super(...arguments);
49
+ this.instance = null;
50
+ /** Texto antes de montar, ou o último conhecido depois de desmontar. */
51
+ this.pendingValue = "";
52
+ this.keys = [];
53
+ this.vars = [];
54
+ this.items = [];
55
+ /** Extensões do app como vieram: a mesma referência atribuída de novo não reconfigura o editor. */
56
+ this.exts = NO_EXTENSIONS;
57
+ /** Para de observar o tema da página; só existe com `theme="auto"`. */
58
+ this.disposeTheme = null;
59
+ }
60
+ static get observedAttributes() {
61
+ return [
62
+ "language",
63
+ "readonly",
64
+ "placeholder",
65
+ "min-height",
66
+ "max-height",
67
+ "line-numbers",
68
+ "fold",
69
+ "wrap",
70
+ "indent-style",
71
+ "indent-size",
72
+ "line-ending",
73
+ "tab-indent",
74
+ "autocomplete",
75
+ "mark-unknown-variables",
76
+ "single-line",
77
+ "size",
78
+ "theme",
79
+ "aria-label",
80
+ "testid"
81
+ ];
82
+ }
83
+ /** Texto do editor. Atribuir substitui tudo sem disparar `change`. */
84
+ get value() {
85
+ return this.instance ? this.instance.getValue() : this.pendingValue;
86
+ }
87
+ set value(next) {
88
+ const text = next ?? "";
89
+ this.pendingValue = text;
90
+ this.instance?.setValue(text);
91
+ }
92
+ /** Chaves oferecidas como completions depois de `{{` (propriedade JS). */
93
+ get variableKeys() {
94
+ return [...this.keys];
95
+ }
96
+ set variableKeys(next) {
97
+ this.keys = Array.isArray(next) ? next.filter((key) => typeof key === "string" && key.length > 0) : [];
98
+ this.instance?.setVariableKeys(this.keys);
99
+ }
100
+ /** Variáveis com escopo e cor (propriedade JS): completam depois de `{{` e pintam o `{{chave}}` no texto. */
101
+ get variables() {
102
+ return this.vars.map((variable) => ({ ...variable }));
103
+ }
104
+ set variables(next) {
105
+ this.vars = Array.isArray(next)
106
+ ? next.filter((variable) => variable && typeof variable.key === "string" && variable.key.length > 0)
107
+ : [];
108
+ this.instance?.setVariables(this.vars);
109
+ }
110
+ /** Pinta em `danger` o `{{chave}}` fora de `variables` e `variableKeys` (atributo `mark-unknown-variables`). */
111
+ get markUnknownVariables() {
112
+ return this.hasAttribute("mark-unknown-variables");
113
+ }
114
+ set markUnknownVariables(value) {
115
+ this.toggleAttribute("mark-unknown-variables", truthy(value));
116
+ }
117
+ /** Campo de uma linha na altura dos controles (atributo `single-line`); Enter emite `ark-submit`. */
118
+ get singleLine() {
119
+ return this.hasAttribute("single-line");
120
+ }
121
+ set singleLine(value) {
122
+ this.toggleAttribute("single-line", truthy(value));
123
+ }
124
+ /** Escala da fonte e do recuo; em `single-line`, também a altura (atributo `size`). Padrão: "md". */
125
+ get size() {
126
+ const value = (this.getAttribute("size") || "md").toLowerCase();
127
+ return Object.keys(ARK_SIZE_CSS).includes(value) ? value : "md";
128
+ }
129
+ set size(value) {
130
+ this.setAttribute("size", value);
131
+ }
132
+ /** Palavras oferecidas como completion em qualquer linguagem (propriedade JS, formato do CodeMirror). */
133
+ get completions() {
134
+ return [...this.items];
135
+ }
136
+ set completions(next) {
137
+ this.items = Array.isArray(next) ? next.filter((item) => item && typeof item.label === "string") : [];
138
+ this.instance?.setCompletions(this.items);
139
+ }
140
+ /** Fonte de completion própria (propriedade JS), somada às da linguagem. */
141
+ get completionSource() {
142
+ return this.source;
143
+ }
144
+ set completionSource(next) {
145
+ this.source = typeof next === "function" ? next : undefined;
146
+ this.instance?.setCompletionSource(this.source);
147
+ }
148
+ /** Formatador do app (propriedade JS); sem ele só `language="json"` formata. */
149
+ get formatter() {
150
+ return this.formatFn;
151
+ }
152
+ set formatter(next) {
153
+ this.formatFn = typeof next === "function" ? next : undefined;
154
+ this.instance?.setFormatter(this.formatFn);
155
+ }
156
+ /**
157
+ * Extensões do CodeMirror do app (propriedade JS), depois das da lib: gramáticas que ela não traz (com `language`
158
+ * em "text"), calhas, decorações. Trocar reconfigura sem recriar o editor; `null` remove.
159
+ */
160
+ get extensions() {
161
+ return this.exts;
162
+ }
163
+ set extensions(next) {
164
+ const value = next !== null && typeof next === "object" ? next : NO_EXTENSIONS;
165
+ if (value === this.exts)
166
+ return;
167
+ this.exts = value;
168
+ this.instance?.setExtensions(value);
169
+ }
170
+ /** Recuo com espaços ou tabulação (atributo `indent-style`). Padrão: "space". */
171
+ get indentStyle() {
172
+ return this.getAttribute("indent-style") === "tab" ? "tab" : "space";
173
+ }
174
+ set indentStyle(value) {
175
+ this.setAttribute("indent-style", value);
176
+ }
177
+ /** Espaços por nível, ou largura da tabulação (atributo `indent-size`). Padrão: 2. */
178
+ get indentSize() {
179
+ const raw = Number(this.getAttribute("indent-size"));
180
+ return this.hasAttribute("indent-size") && Number.isInteger(raw) && raw >= 1 && raw <= 16 ? raw : 2;
181
+ }
182
+ set indentSize(value) {
183
+ this.setAttribute("indent-size", String(value));
184
+ }
185
+ /** Fim de linha do valor (atributo `line-ending`): lf, crlf ou auto. Padrão: "auto". */
186
+ get lineEnding() {
187
+ const value = (this.getAttribute("line-ending") || "auto").toLowerCase();
188
+ return value === "lf" || value === "crlf" ? value : "auto";
189
+ }
190
+ set lineEnding(value) {
191
+ this.setAttribute("line-ending", value);
192
+ }
193
+ /** Fim de linha em vigor depois de resolver `auto` (o do último valor atribuído). */
194
+ get resolvedLineEnding() {
195
+ return this.instance ? this.instance.resolvedLineEnding() : this.pendingValue.includes("\r\n") ? "crlf" : "lf";
196
+ }
197
+ /** Tab recua e Esc+Tab sai; ligado salvo `tab-indent="false"`. */
198
+ get tabIndent() {
199
+ return this.getAttribute("tab-indent") !== "false";
200
+ }
201
+ set tabIndent(value) {
202
+ this.setAttribute("tab-indent", truthy(value) ? "true" : "false");
203
+ }
204
+ /** Completions ligadas salvo `autocomplete="false"`. */
205
+ get autocomplete() {
206
+ return this.getAttribute("autocomplete") !== "false";
207
+ }
208
+ set autocomplete(value) {
209
+ this.setAttribute("autocomplete", truthy(value) ? "true" : "false");
210
+ }
211
+ /** Linguagem do realce (atributo `language`). Padrão: "text". */
212
+ get language() {
213
+ const value = (this.getAttribute("language") || "text").toLowerCase();
214
+ return value === "json" || value === "javascript" || value === "yaml" ? value : "text";
215
+ }
216
+ set language(next) {
217
+ this.setAttribute("language", next);
218
+ }
219
+ get readonly() {
220
+ return this.hasAttribute("readonly");
221
+ }
222
+ set readonly(value) {
223
+ this.toggleAttribute("readonly", truthy(value));
224
+ }
225
+ /** Quebra de linha visual (atributo `wrap`). */
226
+ get wrap() {
227
+ return this.hasAttribute("wrap");
228
+ }
229
+ set wrap(value) {
230
+ this.toggleAttribute("wrap", truthy(value));
231
+ }
232
+ /** Numeração das linhas; ligada salvo `line-numbers="false"`. */
233
+ get lineNumbers() {
234
+ return this.getAttribute("line-numbers") !== "false";
235
+ }
236
+ set lineNumbers(value) {
237
+ this.setAttribute("line-numbers", truthy(value) ? "true" : "false");
238
+ }
239
+ /** Calha de dobra; ligada salvo `fold="false"`. */
240
+ get fold() {
241
+ return this.getAttribute("fold") !== "false";
242
+ }
243
+ set fold(value) {
244
+ this.setAttribute("fold", truthy(value) ? "true" : "false");
245
+ }
246
+ get placeholder() {
247
+ return this.getAttribute("placeholder") || "";
248
+ }
249
+ set placeholder(value) {
250
+ if (value) {
251
+ this.setAttribute("placeholder", value);
252
+ }
253
+ else {
254
+ this.removeAttribute("placeholder");
255
+ }
256
+ }
257
+ /** Altura mínima do editor (atributo `min-height`, comprimento CSS). Padrão: "8rem". */
258
+ get minHeight() {
259
+ return this.getAttribute("min-height")?.trim() || "8rem";
260
+ }
261
+ set minHeight(value) {
262
+ if (value) {
263
+ this.setAttribute("min-height", value);
264
+ }
265
+ else {
266
+ this.removeAttribute("min-height");
267
+ }
268
+ }
269
+ /**
270
+ * Altura máxima do editor (atributo `max-height`, comprimento CSS): acima dela o conteúdo rola dentro do editor.
271
+ * Ignorada em `single-line`. Padrão: "" (sem limite, cresce com o conteúdo).
272
+ */
273
+ get maxHeight() {
274
+ return this.getAttribute("max-height")?.trim() || "";
275
+ }
276
+ set maxHeight(value) {
277
+ if (value) {
278
+ this.setAttribute("max-height", value);
279
+ }
280
+ else {
281
+ this.removeAttribute("max-height");
282
+ }
283
+ }
284
+ get theme() {
285
+ const value = (this.getAttribute("theme") || "auto").toLowerCase();
286
+ return value === "light" || value === "dark" ? value : "auto";
287
+ }
288
+ set theme(value) {
289
+ this.setAttribute("theme", value);
290
+ }
291
+ /** Tema efetivamente aplicado (depois de resolver `auto`); `null` antes de renderizar. */
292
+ get resolvedTheme() {
293
+ return this.instance?.resolvedTheme() ?? null;
294
+ }
295
+ /** Instância nativa do CodeMirror (uso avançado); `null` antes de renderizar. */
296
+ get view() {
297
+ return this.instance?.view ?? null;
298
+ }
299
+ connectedCallback() {
300
+ upgradeProperties(this);
301
+ // O atributo `value` só dá o texto inicial; depois a propriedade manda.
302
+ if (!this.instance && !this.pendingValue && this.hasAttribute("value")) {
303
+ this.pendingValue = this.getAttribute("value") ?? "";
304
+ }
305
+ this.render();
306
+ }
307
+ disconnectedCallback() {
308
+ this.teardown();
309
+ }
310
+ attributeChangedCallback(name, oldValue, newValue) {
311
+ if (oldValue === newValue || !this.instance)
312
+ return;
313
+ if (name === "language")
314
+ this.instance.setLanguage(this.language);
315
+ if (name === "readonly")
316
+ this.instance.setReadonly(this.readonly);
317
+ if (name === "placeholder")
318
+ this.instance.setPlaceholder(this.placeholder);
319
+ if (name === "aria-label")
320
+ this.instance.setLabel(newValue || undefined);
321
+ if (name === "min-height")
322
+ this.instance.setMinHeight(this.minHeight);
323
+ if (name === "max-height")
324
+ this.instance.setMaxHeight(this.maxHeight);
325
+ if (name === "line-numbers")
326
+ this.instance.setLineNumbers(this.lineNumbers);
327
+ if (name === "fold")
328
+ this.instance.setFold(this.fold);
329
+ if (name === "wrap")
330
+ this.instance.setWrap(this.wrap);
331
+ if (name === "indent-style" || name === "indent-size")
332
+ this.instance.setIndent(this.indentStyle, this.indentSize);
333
+ if (name === "line-ending")
334
+ this.instance.setLineEnding(this.lineEnding);
335
+ if (name === "tab-indent")
336
+ this.instance.setTabIndent(this.tabIndent);
337
+ if (name === "autocomplete")
338
+ this.instance.setAutocomplete(this.autocomplete);
339
+ if (name === "mark-unknown-variables")
340
+ this.instance.setMarkUnknownVariables(this.markUnknownVariables);
341
+ if (name === "single-line")
342
+ this.instance.setSingleLine(this.singleLine);
343
+ if (name === "size")
344
+ this.instance.setSize(this.size);
345
+ if (name === "theme") {
346
+ this.instance.setTheme(this.theme);
347
+ this.syncThemeObserver();
348
+ }
349
+ if (name === "testid")
350
+ this.applyHooks();
351
+ }
352
+ /** Foca o editor. */
353
+ focus() {
354
+ this.instance?.focus();
355
+ }
356
+ /** Formata o documento com `formatter` (ou JSON nativo); `false` sem formatador ou quando falha (`ark-format-error`). */
357
+ format() {
358
+ return this.instance ? this.instance.format() : Promise.resolve(false);
359
+ }
360
+ /** Indica se a linguagem atual tem como ser formatada. */
361
+ get canFormat() {
362
+ return this.instance ? this.instance.canFormat() : this.formatFn !== undefined || this.language === "json";
363
+ }
364
+ render() {
365
+ this.teardown();
366
+ this.style.display = this.style.display || "block";
367
+ this.instance = createCodeEditor(this, {
368
+ value: this.pendingValue,
369
+ language: this.language,
370
+ theme: this.theme,
371
+ readonly: this.readonly,
372
+ placeholder: this.placeholder || undefined,
373
+ label: this.getAttribute("aria-label") || undefined,
374
+ lineNumbers: this.lineNumbers,
375
+ fold: this.fold,
376
+ wrap: this.wrap,
377
+ minHeight: this.minHeight,
378
+ maxHeight: this.maxHeight || undefined,
379
+ indentStyle: this.indentStyle,
380
+ indentSize: this.indentSize,
381
+ lineEnding: this.lineEnding,
382
+ tabIndent: this.tabIndent,
383
+ autocomplete: this.autocomplete,
384
+ variableKeys: this.keys,
385
+ variables: this.vars,
386
+ markUnknownVariables: this.markUnknownVariables,
387
+ singleLine: this.singleLine,
388
+ size: this.size,
389
+ completions: this.items,
390
+ completionSource: this.source,
391
+ formatter: this.formatFn,
392
+ extensions: this.exts,
393
+ onChange: (value) => {
394
+ this.pendingValue = value;
395
+ this.dispatchEvent(new CustomEvent("change", { detail: { value }, bubbles: true, composed: true }));
396
+ },
397
+ onSubmit: (value) => {
398
+ this.dispatchEvent(new CustomEvent("ark-submit", { detail: { value }, bubbles: true, composed: true }));
399
+ },
400
+ onFormatError: (error) => {
401
+ this.dispatchEvent(new CustomEvent("ark-format-error", { detail: { error }, bubbles: true, composed: true }));
402
+ }
403
+ });
404
+ this.applyHooks();
405
+ this.syncThemeObserver();
406
+ }
407
+ // O nó raiz do CodeMirror leva o hook de E2E, como os componentes de @tooark/web-components.
408
+ applyHooks() {
409
+ const dom = this.instance?.view.dom;
410
+ if (!dom)
411
+ return;
412
+ dom.setAttribute("data-ark", "code-editor");
413
+ const testid = this.getAttribute("testid");
414
+ if (testid) {
415
+ dom.setAttribute("data-testid", testid);
416
+ }
417
+ else {
418
+ dom.removeAttribute("data-testid");
419
+ }
420
+ }
421
+ // Em `auto`, a troca de tema da página re-resolve o tema do editor; com tema fixo não há o que observar.
422
+ syncThemeObserver() {
423
+ this.disposeTheme?.();
424
+ this.disposeTheme = null;
425
+ if (this.theme !== "auto")
426
+ return;
427
+ this.disposeTheme = observeColorScheme(this, () => this.instance?.setTheme("auto"));
428
+ }
429
+ teardown() {
430
+ this.disposeTheme?.();
431
+ this.disposeTheme = null;
432
+ if (this.instance) {
433
+ this.pendingValue = this.instance.getValue();
434
+ this.instance.destroy();
435
+ this.instance = null;
436
+ }
437
+ }
438
+ }
439
+ ArkCodeEditor.tagName = "ark-code-editor";
440
+
441
+ export { ArkCodeEditor };
442
+ //# sourceMappingURL=ark-code-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ark-code-editor.js","sources":["../../src/components/ark-code-editor.ts"],"sourcesContent":["import type { EditorView } from \"@codemirror/view\";\nimport { ARK_SIZE_CSS, type ArkSize, type ArkThemeSelected, observeColorScheme } from \"@tooark/tokens\";\nimport { type ArkCodeEditorInstance, createCodeEditor } from \"../engine\";\nimport type {\n ArkCodeCompletion,\n ArkCodeCompletionSource,\n ArkCodeExtension,\n ArkCodeFormatter,\n ArkCodeIndentStyle,\n ArkCodeLanguage,\n ArkCodeLineEnding,\n ArkCodeTheme,\n ArkCodeVariable\n} from \"../types\";\nimport { HTMLElementBase } from \"./html-element-base\";\nimport { upgradeProperties } from \"./upgrade-properties\";\n\n// Mesma regra do coerceBooleanAttr de @tooark/core (este pacote só depende de tokens): frameworks passam o valor do\n// atributo como propriedade, então \"\" é presente e \"false\" é ausente.\nfunction truthy(value: unknown): boolean {\n if (value === \"\" || value === true) return true;\n if (value === false || value === null || value === undefined || value === \"false\") return false;\n return Boolean(value);\n}\n\n/** Sem extensões do app; uma referência só, para `null` repetido não reconfigurar o editor. */\nconst NO_EXTENSIONS: ArkCodeExtension = [];\n\n/**\n * Custom Element que renderiza um editor de código CodeMirror 6.\n *\n * O texto vai pela propriedade `value` (ou pelo atributo `value` como valor\n * inicial) e volta em `change` com `detail: { value }` a cada edição do\n * usuário. Atributos: `language` (json | javascript | yaml | text),\n * `readonly`, `placeholder`, `min-height` e `max-height` (comprimentos CSS;\n * acima da máxima o conteúdo rola por dentro), `line-numbers`,\n * `fold`, `tab-indent` e `autocomplete` (ligados por padrão; \"false\"\n * desliga), `wrap`, `indent-style` (space | tab), `indent-size`,\n * `line-ending` (lf | crlf | auto), `theme` (auto | light | dark),\n * `aria-label` (vai para o conteúdo editável, o `role=\"textbox\"`) e\n * `testid`. Propriedades JS: `variableKeys` (completions depois de `{{`),\n * `completions` (palavras oferecidas em qualquer linguagem),\n * `completionSource` (fonte própria), `formatter` (formatador do app;\n * sem ele só JSON formata) e `format()`, também por Shift+Alt+F. Tab recua e\n * Esc+Tab sai do editor. Em `auto` o tema segue o color-scheme da página e\n * acompanha a troca em tempo de execução (`observeColorScheme` de\n * @tooark/tokens). O nó do CodeMirror leva `data-ark=\"code-editor\"` e o\n * `testid` como `data-testid`.\n *\n * Opcionais, desligados até o app pedir: a propriedade `variables` pinta\n * cada `{{chave}}` pelo intent da variável, com tooltip do escopo e do valor;\n * `mark-unknown-variables` pinta em `danger` a chave desconhecida;\n * `single-line` vira um campo de uma linha na altura dos controles (`size`),\n * com Enter emitindo `ark-submit` (`detail: { value }`); a propriedade\n * `extensions` soma extensões do CodeMirror do app (gramáticas que a lib não\n * traz, calhas, decorações) às da lib, sem recriar o editor.\n */\nexport class ArkCodeEditor extends HTMLElementBase {\n static readonly tagName = \"ark-code-editor\";\n\n private instance: ArkCodeEditorInstance | null = null;\n /** Texto antes de montar, ou o último conhecido depois de desmontar. */\n private pendingValue = \"\";\n private keys: string[] = [];\n private vars: ArkCodeVariable[] = [];\n private items: ArkCodeCompletion[] = [];\n private source: ArkCodeCompletionSource | undefined;\n private formatFn: ArkCodeFormatter | undefined;\n /** Extensões do app como vieram: a mesma referência atribuída de novo não reconfigura o editor. */\n private exts: ArkCodeExtension = NO_EXTENSIONS;\n /** Para de observar o tema da página; só existe com `theme=\"auto\"`. */\n private disposeTheme: (() => void) | null = null;\n\n static get observedAttributes(): string[] {\n return [\n \"language\",\n \"readonly\",\n \"placeholder\",\n \"min-height\",\n \"max-height\",\n \"line-numbers\",\n \"fold\",\n \"wrap\",\n \"indent-style\",\n \"indent-size\",\n \"line-ending\",\n \"tab-indent\",\n \"autocomplete\",\n \"mark-unknown-variables\",\n \"single-line\",\n \"size\",\n \"theme\",\n \"aria-label\",\n \"testid\"\n ];\n }\n\n /** Texto do editor. Atribuir substitui tudo sem disparar `change`. */\n get value(): string {\n return this.instance ? this.instance.getValue() : this.pendingValue;\n }\n\n set value(next: string | null | undefined) {\n const text = next ?? \"\";\n this.pendingValue = text;\n this.instance?.setValue(text);\n }\n\n /** Chaves oferecidas como completions depois de `{{` (propriedade JS). */\n get variableKeys(): string[] {\n return [...this.keys];\n }\n\n set variableKeys(next: string[] | null | undefined) {\n this.keys = Array.isArray(next) ? next.filter((key) => typeof key === \"string\" && key.length > 0) : [];\n this.instance?.setVariableKeys(this.keys);\n }\n\n /** Variáveis com escopo e cor (propriedade JS): completam depois de `{{` e pintam o `{{chave}}` no texto. */\n get variables(): ArkCodeVariable[] {\n return this.vars.map((variable) => ({ ...variable }));\n }\n\n set variables(next: ArkCodeVariable[] | null | undefined) {\n this.vars = Array.isArray(next)\n ? next.filter((variable) => variable && typeof variable.key === \"string\" && variable.key.length > 0)\n : [];\n this.instance?.setVariables(this.vars);\n }\n\n /** Pinta em `danger` o `{{chave}}` fora de `variables` e `variableKeys` (atributo `mark-unknown-variables`). */\n get markUnknownVariables(): boolean {\n return this.hasAttribute(\"mark-unknown-variables\");\n }\n\n set markUnknownVariables(value: boolean | string | null | undefined) {\n this.toggleAttribute(\"mark-unknown-variables\", truthy(value));\n }\n\n /** Campo de uma linha na altura dos controles (atributo `single-line`); Enter emite `ark-submit`. */\n get singleLine(): boolean {\n return this.hasAttribute(\"single-line\");\n }\n\n set singleLine(value: boolean | string | null | undefined) {\n this.toggleAttribute(\"single-line\", truthy(value));\n }\n\n /** Escala da fonte e do recuo; em `single-line`, também a altura (atributo `size`). Padrão: \"md\". */\n get size(): ArkSize {\n const value = (this.getAttribute(\"size\") || \"md\").toLowerCase();\n return Object.keys(ARK_SIZE_CSS).includes(value) ? (value as ArkSize) : \"md\";\n }\n\n set size(value: ArkSize) {\n this.setAttribute(\"size\", value);\n }\n\n /** Palavras oferecidas como completion em qualquer linguagem (propriedade JS, formato do CodeMirror). */\n get completions(): ArkCodeCompletion[] {\n return [...this.items];\n }\n\n set completions(next: ArkCodeCompletion[] | null | undefined) {\n this.items = Array.isArray(next) ? next.filter((item) => item && typeof item.label === \"string\") : [];\n this.instance?.setCompletions(this.items);\n }\n\n /** Fonte de completion própria (propriedade JS), somada às da linguagem. */\n get completionSource(): ArkCodeCompletionSource | undefined {\n return this.source;\n }\n\n set completionSource(next: ArkCodeCompletionSource | null | undefined) {\n this.source = typeof next === \"function\" ? next : undefined;\n this.instance?.setCompletionSource(this.source);\n }\n\n /** Formatador do app (propriedade JS); sem ele só `language=\"json\"` formata. */\n get formatter(): ArkCodeFormatter | undefined {\n return this.formatFn;\n }\n\n set formatter(next: ArkCodeFormatter | null | undefined) {\n this.formatFn = typeof next === \"function\" ? next : undefined;\n this.instance?.setFormatter(this.formatFn);\n }\n\n /**\n * Extensões do CodeMirror do app (propriedade JS), depois das da lib: gramáticas que ela não traz (com `language`\n * em \"text\"), calhas, decorações. Trocar reconfigura sem recriar o editor; `null` remove.\n */\n get extensions(): ArkCodeExtension {\n return this.exts;\n }\n\n set extensions(next: ArkCodeExtension | null | undefined) {\n const value = next !== null && typeof next === \"object\" ? next : NO_EXTENSIONS;\n if (value === this.exts) return;\n this.exts = value;\n this.instance?.setExtensions(value);\n }\n\n /** Recuo com espaços ou tabulação (atributo `indent-style`). Padrão: \"space\". */\n get indentStyle(): ArkCodeIndentStyle {\n return this.getAttribute(\"indent-style\") === \"tab\" ? \"tab\" : \"space\";\n }\n\n set indentStyle(value: ArkCodeIndentStyle) {\n this.setAttribute(\"indent-style\", value);\n }\n\n /** Espaços por nível, ou largura da tabulação (atributo `indent-size`). Padrão: 2. */\n get indentSize(): number {\n const raw = Number(this.getAttribute(\"indent-size\"));\n return this.hasAttribute(\"indent-size\") && Number.isInteger(raw) && raw >= 1 && raw <= 16 ? raw : 2;\n }\n\n set indentSize(value: number) {\n this.setAttribute(\"indent-size\", String(value));\n }\n\n /** Fim de linha do valor (atributo `line-ending`): lf, crlf ou auto. Padrão: \"auto\". */\n get lineEnding(): ArkCodeLineEnding {\n const value = (this.getAttribute(\"line-ending\") || \"auto\").toLowerCase();\n return value === \"lf\" || value === \"crlf\" ? value : \"auto\";\n }\n\n set lineEnding(value: ArkCodeLineEnding) {\n this.setAttribute(\"line-ending\", value);\n }\n\n /** Fim de linha em vigor depois de resolver `auto` (o do último valor atribuído). */\n get resolvedLineEnding(): \"lf\" | \"crlf\" {\n return this.instance ? this.instance.resolvedLineEnding() : this.pendingValue.includes(\"\\r\\n\") ? \"crlf\" : \"lf\";\n }\n\n /** Tab recua e Esc+Tab sai; ligado salvo `tab-indent=\"false\"`. */\n get tabIndent(): boolean {\n return this.getAttribute(\"tab-indent\") !== \"false\";\n }\n\n set tabIndent(value: boolean | string | null | undefined) {\n this.setAttribute(\"tab-indent\", truthy(value) ? \"true\" : \"false\");\n }\n\n /** Completions ligadas salvo `autocomplete=\"false\"`. */\n get autocomplete(): boolean {\n return this.getAttribute(\"autocomplete\") !== \"false\";\n }\n\n set autocomplete(value: boolean | string | null | undefined) {\n this.setAttribute(\"autocomplete\", truthy(value) ? \"true\" : \"false\");\n }\n\n /** Linguagem do realce (atributo `language`). Padrão: \"text\". */\n get language(): ArkCodeLanguage {\n const value = (this.getAttribute(\"language\") || \"text\").toLowerCase();\n return value === \"json\" || value === \"javascript\" || value === \"yaml\" ? value : \"text\";\n }\n\n set language(next: ArkCodeLanguage) {\n this.setAttribute(\"language\", next);\n }\n\n get readonly(): boolean {\n return this.hasAttribute(\"readonly\");\n }\n\n set readonly(value: boolean | string | null | undefined) {\n this.toggleAttribute(\"readonly\", truthy(value));\n }\n\n /** Quebra de linha visual (atributo `wrap`). */\n get wrap(): boolean {\n return this.hasAttribute(\"wrap\");\n }\n\n set wrap(value: boolean | string | null | undefined) {\n this.toggleAttribute(\"wrap\", truthy(value));\n }\n\n /** Numeração das linhas; ligada salvo `line-numbers=\"false\"`. */\n get lineNumbers(): boolean {\n return this.getAttribute(\"line-numbers\") !== \"false\";\n }\n\n set lineNumbers(value: boolean | string | null | undefined) {\n this.setAttribute(\"line-numbers\", truthy(value) ? \"true\" : \"false\");\n }\n\n /** Calha de dobra; ligada salvo `fold=\"false\"`. */\n get fold(): boolean {\n return this.getAttribute(\"fold\") !== \"false\";\n }\n\n set fold(value: boolean | string | null | undefined) {\n this.setAttribute(\"fold\", truthy(value) ? \"true\" : \"false\");\n }\n\n get placeholder(): string {\n return this.getAttribute(\"placeholder\") || \"\";\n }\n\n set placeholder(value: string | null | undefined) {\n if (value) {\n this.setAttribute(\"placeholder\", value);\n } else {\n this.removeAttribute(\"placeholder\");\n }\n }\n\n /** Altura mínima do editor (atributo `min-height`, comprimento CSS). Padrão: \"8rem\". */\n get minHeight(): string {\n return this.getAttribute(\"min-height\")?.trim() || \"8rem\";\n }\n\n set minHeight(value: string | null | undefined) {\n if (value) {\n this.setAttribute(\"min-height\", value);\n } else {\n this.removeAttribute(\"min-height\");\n }\n }\n\n /**\n * Altura máxima do editor (atributo `max-height`, comprimento CSS): acima dela o conteúdo rola dentro do editor.\n * Ignorada em `single-line`. Padrão: \"\" (sem limite, cresce com o conteúdo).\n */\n get maxHeight(): string {\n return this.getAttribute(\"max-height\")?.trim() || \"\";\n }\n\n set maxHeight(value: string | null | undefined) {\n if (value) {\n this.setAttribute(\"max-height\", value);\n } else {\n this.removeAttribute(\"max-height\");\n }\n }\n\n get theme(): ArkCodeTheme {\n const value = (this.getAttribute(\"theme\") || \"auto\").toLowerCase();\n return value === \"light\" || value === \"dark\" ? value : \"auto\";\n }\n\n set theme(value: ArkCodeTheme) {\n this.setAttribute(\"theme\", value);\n }\n\n /** Tema efetivamente aplicado (depois de resolver `auto`); `null` antes de renderizar. */\n get resolvedTheme(): ArkThemeSelected | null {\n return this.instance?.resolvedTheme() ?? null;\n }\n\n /** Instância nativa do CodeMirror (uso avançado); `null` antes de renderizar. */\n get view(): EditorView | null {\n return this.instance?.view ?? null;\n }\n\n connectedCallback(): void {\n upgradeProperties(this);\n // O atributo `value` só dá o texto inicial; depois a propriedade manda.\n if (!this.instance && !this.pendingValue && this.hasAttribute(\"value\")) {\n this.pendingValue = this.getAttribute(\"value\") ?? \"\";\n }\n this.render();\n }\n\n disconnectedCallback(): void {\n this.teardown();\n }\n\n attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this.instance) return;\n\n if (name === \"language\") this.instance.setLanguage(this.language);\n if (name === \"readonly\") this.instance.setReadonly(this.readonly);\n if (name === \"placeholder\") this.instance.setPlaceholder(this.placeholder);\n if (name === \"aria-label\") this.instance.setLabel(newValue || undefined);\n if (name === \"min-height\") this.instance.setMinHeight(this.minHeight);\n if (name === \"max-height\") this.instance.setMaxHeight(this.maxHeight);\n if (name === \"line-numbers\") this.instance.setLineNumbers(this.lineNumbers);\n if (name === \"fold\") this.instance.setFold(this.fold);\n if (name === \"wrap\") this.instance.setWrap(this.wrap);\n if (name === \"indent-style\" || name === \"indent-size\") this.instance.setIndent(this.indentStyle, this.indentSize);\n if (name === \"line-ending\") this.instance.setLineEnding(this.lineEnding);\n if (name === \"tab-indent\") this.instance.setTabIndent(this.tabIndent);\n if (name === \"autocomplete\") this.instance.setAutocomplete(this.autocomplete);\n if (name === \"mark-unknown-variables\") this.instance.setMarkUnknownVariables(this.markUnknownVariables);\n if (name === \"single-line\") this.instance.setSingleLine(this.singleLine);\n if (name === \"size\") this.instance.setSize(this.size);\n if (name === \"theme\") {\n this.instance.setTheme(this.theme);\n this.syncThemeObserver();\n }\n if (name === \"testid\") this.applyHooks();\n }\n\n /** Foca o editor. */\n focus(): void {\n this.instance?.focus();\n }\n\n /** Formata o documento com `formatter` (ou JSON nativo); `false` sem formatador ou quando falha (`ark-format-error`). */\n format(): Promise<boolean> {\n return this.instance ? this.instance.format() : Promise.resolve(false);\n }\n\n /** Indica se a linguagem atual tem como ser formatada. */\n get canFormat(): boolean {\n return this.instance ? this.instance.canFormat() : this.formatFn !== undefined || this.language === \"json\";\n }\n\n private render(): void {\n this.teardown();\n this.style.display = this.style.display || \"block\";\n\n this.instance = createCodeEditor(this, {\n value: this.pendingValue,\n language: this.language,\n theme: this.theme,\n readonly: this.readonly,\n placeholder: this.placeholder || undefined,\n label: this.getAttribute(\"aria-label\") || undefined,\n lineNumbers: this.lineNumbers,\n fold: this.fold,\n wrap: this.wrap,\n minHeight: this.minHeight,\n maxHeight: this.maxHeight || undefined,\n indentStyle: this.indentStyle,\n indentSize: this.indentSize,\n lineEnding: this.lineEnding,\n tabIndent: this.tabIndent,\n autocomplete: this.autocomplete,\n variableKeys: this.keys,\n variables: this.vars,\n markUnknownVariables: this.markUnknownVariables,\n singleLine: this.singleLine,\n size: this.size,\n completions: this.items,\n completionSource: this.source,\n formatter: this.formatFn,\n extensions: this.exts,\n onChange: (value) => {\n this.pendingValue = value;\n this.dispatchEvent(new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }));\n },\n onSubmit: (value) => {\n this.dispatchEvent(new CustomEvent(\"ark-submit\", { detail: { value }, bubbles: true, composed: true }));\n },\n onFormatError: (error) => {\n this.dispatchEvent(new CustomEvent(\"ark-format-error\", { detail: { error }, bubbles: true, composed: true }));\n }\n });\n\n this.applyHooks();\n this.syncThemeObserver();\n }\n\n // O nó raiz do CodeMirror leva o hook de E2E, como os componentes de @tooark/web-components.\n private applyHooks(): void {\n const dom = this.instance?.view.dom;\n if (!dom) return;\n dom.setAttribute(\"data-ark\", \"code-editor\");\n const testid = this.getAttribute(\"testid\");\n if (testid) {\n dom.setAttribute(\"data-testid\", testid);\n } else {\n dom.removeAttribute(\"data-testid\");\n }\n }\n\n // Em `auto`, a troca de tema da página re-resolve o tema do editor; com tema fixo não há o que observar.\n private syncThemeObserver(): void {\n this.disposeTheme?.();\n this.disposeTheme = null;\n if (this.theme !== \"auto\") return;\n this.disposeTheme = observeColorScheme(this, () => this.instance?.setTheme(\"auto\"));\n }\n\n private teardown(): void {\n this.disposeTheme?.();\n this.disposeTheme = null;\n if (this.instance) {\n this.pendingValue = this.instance.getValue();\n this.instance.destroy();\n this.instance = null;\n }\n }\n}\n\nexport default ArkCodeE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CAAC,UAAU,EAAE,aAAa,CAAC;QAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;QAC1C,IAAI,MAAM,EAAE;AACV,YAAA,GAAG,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;QACzC;aAAO;AACL,YAAA,GAAG,CAAC,eAAe,CAAC,aAAa,CAAC;QACpC;IACF;;IAGQ,iBAAiB,GAAA;AACvB,QAAA,IAAI,CAAC,YAAY,IAAI;AACrB,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI;AACxB,QAAA,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM;YAAE;AAC3B,QAAA,IAAI,CAAC,YAAY,GAAG,kBAAkB,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrF;IAEQ,QAAQ,GAAA;AACd,QAAA,IAAI,CAAC,YAAY,IAAI;AACrB,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI;AACxB,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;AAC5C,YAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACvB,YAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;QACtB;IACF;;AA/agB,aAAA,CAAA,OAAO,GAAG,iBAAH;;"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ // Base dos Custom Elements que também carrega fora do navegador. No SSR (Node, Angular SSR, Next, Nuxt) não existe
4
+ // HTMLElement, e um `extends HTMLElement` no topo do módulo derrubaria o import de quem só renderiza o HTML; lá a
5
+ // base é uma classe vazia, e os elementos só passam a existir no cliente, quando registerTooark*() os define.
6
+ /** `HTMLElement` no navegador; fora dele, uma classe vazia para o módulo poder ser importado no servidor. */
7
+ const HTMLElementBase = typeof HTMLElement === "undefined" ? class {
8
+ } : HTMLElement;
9
+
10
+ exports.HTMLElementBase = HTMLElementBase;
11
+ //# sourceMappingURL=html-element-base.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-element-base.cjs","sources":["../../src/components/html-element-base.ts"],"sourcesContent":["// Base dos Custom Elements que também carrega fora do navegador. No SSR (Node, Angular SSR, Next, Nuxt) não existe\n// HTMLElement, e um `extends HTMLElement` no topo do módulo derrubaria o import de quem só renderiza o HTML; lá a\n// base é uma classe vazia, e os elementos só passam a existir no cliente, quando registerTooark*() os define.\n\n/** `HTMLElement` no navegador; fora dele, uma classe vazia para o módulo poder ser importado no servidor. */\nexport const HTMLElementBase: typeof HTMLElement =\n typeof HTMLElement === \"undefined\" ? (class {} as unknown as typeof HTMLElement) : HTMLElement;\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AAEA;AACO,MAAM,eAAe,GAC1B,OAAO,WAAW,KAAK,WAAW,GAAI,MAAA;CAA0C,GAAG;;"}
@@ -0,0 +1,9 @@
1
+ // Base dos Custom Elements que também carrega fora do navegador. No SSR (Node, Angular SSR, Next, Nuxt) não existe
2
+ // HTMLElement, e um `extends HTMLElement` no topo do módulo derrubaria o import de quem só renderiza o HTML; lá a
3
+ // base é uma classe vazia, e os elementos só passam a existir no cliente, quando registerTooark*() os define.
4
+ /** `HTMLElement` no navegador; fora dele, uma classe vazia para o módulo poder ser importado no servidor. */
5
+ const HTMLElementBase = typeof HTMLElement === "undefined" ? class {
6
+ } : HTMLElement;
7
+
8
+ export { HTMLElementBase };
9
+ //# sourceMappingURL=html-element-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-element-base.js","sources":["../../src/components/html-element-base.ts"],"sourcesContent":["// Base dos Custom Elements que também carrega fora do navegador. No SSR (Node, Angular SSR, Next, Nuxt) não existe\n// HTMLElement, e um `extends HTMLElement` no topo do módulo derrubaria o import de quem só renderiza o HTML; lá a\n// base é uma classe vazia, e os elementos só passam a existir no cliente, quando registerTooark*() os define.\n\n/** `HTMLElement` no navegador; fora dele, uma classe vazia para o módulo poder ser importado no servidor. */\nexport const HTMLElementBase: typeof HTMLElement =\n typeof HTMLElement === \"undefined\" ? (class {} as unknown as typeof HTMLElement) : HTMLElement;\n"],"names":[],"mappings":"AAAA;AACA;AACA;AAEA;AACO,MAAM,eAAe,GAC1B,OAAO,WAAW,KAAK,WAAW,GAAI,MAAA;CAA0C,GAAG;;"}
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ // Um framework (ou o app) pode gravar uma propriedade no elemento antes de registerTooark*() defini-lo: sem a classe,
4
+ // `el.rows = x` vira uma propriedade própria do nó, que depois do upgrade esconde o setter da classe e o valor nunca
5
+ // chega ao componente. Ao conectar, toda propriedade própria que tem setter na classe é retirada e regravada por ele,
6
+ // na ordem em que foi gravada. Os campos da própria classe e o que os frameworks penduram no nó (chaves internas do
7
+ // React e do Vue) não têm setter e ficam como estão.
8
+ /** Reaplica pelo setter da classe as propriedades gravadas no nó antes de o elemento ser registrado. */
9
+ function upgradeProperties(element) {
10
+ const target = element;
11
+ for (const name of Object.keys(element)) {
12
+ if (!hasSetter(Object.getPrototypeOf(element), name))
13
+ continue;
14
+ const value = target[name];
15
+ delete target[name];
16
+ target[name] = value;
17
+ }
18
+ }
19
+ // Procura o acessor na cadeia de protótipos até o HTMLElement: as propriedades nativas nunca viram propriedade própria,
20
+ // porque o nó já é um HTMLElement antes do registro.
21
+ function hasSetter(prototype, name) {
22
+ for (let proto = prototype; proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {
23
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
24
+ if (descriptor)
25
+ return typeof descriptor.set === "function";
26
+ }
27
+ return false;
28
+ }
29
+
30
+ exports.upgradeProperties = upgradeProperties;
31
+ //# sourceMappingURL=upgrade-properties.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-properties.cjs","sources":["../../src/components/upgrade-properties.ts"],"sourcesContent":["// Um framework (ou o app) pode gravar uma propriedade no elemento antes de registerTooark*() defini-lo: sem a classe,\n// `el.rows = x` vira uma propriedade própria do nó, que depois do upgrade esconde o setter da classe e o valor nunca\n// chega ao componente. Ao conectar, toda propriedade própria que tem setter na classe é retirada e regravada por ele,\n// na ordem em que foi gravada. Os campos da própria classe e o que os frameworks penduram no nó (chaves internas do\n// React e do Vue) não têm setter e ficam como estão.\n\n/** Reaplica pelo setter da classe as propriedades gravadas no nó antes de o elemento ser registrado. */\nexport function upgradeProperties(element: HTMLElement): void {\n const target = element as unknown as Record<string, unknown>;\n for (const name of Object.keys(element)) {\n if (!hasSetter(Object.getPrototypeOf(element), name)) continue;\n const value = target[name];\n delete target[name];\n target[name] = value;\n }\n}\n\n// Procura o acessor na cadeia de protótipos até o HTMLElement: as propriedades nativas nunca viram propriedade própria,\n// porque o nó já é um HTMLElement antes do registro.\nfunction hasSetter(prototype: object | null, name: string): boolean {\n for (let proto = prototype; proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor) return typeof descriptor.set === \"function\";\n }\n return false;\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA;AACM,SAAU,iBAAiB,CAAC,OAAoB,EAAA;IACpD,MAAM,MAAM,GAAG,OAA6C;IAC5D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QACvC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;YAAE;AACtD,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;AAC1B,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC;AACnB,QAAA,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK;IACtB;AACF;AAEA;AACA;AACA,SAAS,SAAS,CAAC,SAAwB,EAAE,IAAY,EAAA;IACvD,KAAK,IAAI,KAAK,GAAG,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,WAAW,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;QAC1G,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC;AAC/D,QAAA,IAAI,UAAU;AAAE,YAAA,OAAO,OAAO,UAAU,CAAC,GAAG,KAAK,UAAU;IAC7D;AACA,IAAA,OAAO,KAAK;AACd;;"}
@@ -0,0 +1,29 @@
1
+ // Um framework (ou o app) pode gravar uma propriedade no elemento antes de registerTooark*() defini-lo: sem a classe,
2
+ // `el.rows = x` vira uma propriedade própria do nó, que depois do upgrade esconde o setter da classe e o valor nunca
3
+ // chega ao componente. Ao conectar, toda propriedade própria que tem setter na classe é retirada e regravada por ele,
4
+ // na ordem em que foi gravada. Os campos da própria classe e o que os frameworks penduram no nó (chaves internas do
5
+ // React e do Vue) não têm setter e ficam como estão.
6
+ /** Reaplica pelo setter da classe as propriedades gravadas no nó antes de o elemento ser registrado. */
7
+ function upgradeProperties(element) {
8
+ const target = element;
9
+ for (const name of Object.keys(element)) {
10
+ if (!hasSetter(Object.getPrototypeOf(element), name))
11
+ continue;
12
+ const value = target[name];
13
+ delete target[name];
14
+ target[name] = value;
15
+ }
16
+ }
17
+ // Procura o acessor na cadeia de protótipos até o HTMLElement: as propriedades nativas nunca viram propriedade própria,
18
+ // porque o nó já é um HTMLElement antes do registro.
19
+ function hasSetter(prototype, name) {
20
+ for (let proto = prototype; proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {
21
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
22
+ if (descriptor)
23
+ return typeof descriptor.set === "function";
24
+ }
25
+ return false;
26
+ }
27
+
28
+ export { upgradeProperties };
29
+ //# sourceMappingURL=upgrade-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade-properties.js","sources":["../../src/components/upgrade-properties.ts"],"sourcesContent":["// Um framework (ou o app) pode gravar uma propriedade no elemento antes de registerTooark*() defini-lo: sem a classe,\n// `el.rows = x` vira uma propriedade própria do nó, que depois do upgrade esconde o setter da classe e o valor nunca\n// chega ao componente. Ao conectar, toda propriedade própria que tem setter na classe é retirada e regravada por ele,\n// na ordem em que foi gravada. Os campos da própria classe e o que os frameworks penduram no nó (chaves internas do\n// React e do Vue) não têm setter e ficam como estão.\n\n/** Reaplica pelo setter da classe as propriedades gravadas no nó antes de o elemento ser registrado. */\nexport function upgradeProperties(element: HTMLElement): void {\n const target = element as unknown as Record<string, unknown>;\n for (const name of Object.keys(element)) {\n if (!hasSetter(Object.getPrototypeOf(element), name)) continue;\n const value = target[name];\n delete target[name];\n target[name] = value;\n }\n}\n\n// Procura o acessor na cadeia de protótipos até o HTMLElement: as propriedades nativas nunca viram propriedade própria,\n// porque o nó já é um HTMLElement antes do registro.\nfunction hasSetter(prototype: object | null, name: string): boolean {\n for (let proto = prototype; proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, name);\n if (descriptor) return typeof descriptor.set === \"function\";\n }\n return false;\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACM,SAAU,iBAAiB,CAAC,OAAoB,EAAA;IACpD,MAAM,MAAM,GAAG,OAA6C;IAC5D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;QACvC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;YAAE;AACtD,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;AAC1B,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC;AACnB,QAAA,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK;IACtB;AACF;AAEA;AACA;AACA,SAAS,SAAS,CAAC,SAAwB,EAAE,IAAY,EAAA;IACvD,KAAK,IAAI,KAAK,GAAG,SAAS,EAAE,KAAK,IAAI,KAAK,KAAK,WAAW,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;QAC1G,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC;AAC/D,QAAA,IAAI,UAAU;AAAE,YAAA,OAAO,OAAO,UAAU,CAAC,GAAG,KAAK,UAAU;IAC7D;AACA,IAAA,OAAO,KAAK;AACd;;"}