Skip to content

Commit fcd7139

Browse files
committed
feat(core): modernize reactivity and stabilize layout (v0.5.0)
- Implemented decomposed reactivity engine (bindReactive) in src/reactivity.ts - Added layout stabilization using 'display: contents' and microtask rendering - Refactored FazElement, FazFormElement, and FazPaginator to use property-based reactivity - Removed legacy signal accessors/setters and redundant boilerplate - Updated all unit tests and the POC showcase to the new API - Bumped version to 0.5.0 Fixes: #167 Refs: #115
1 parent 656360f commit fcd7139

14 files changed

Lines changed: 312 additions & 236 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ yarn-error.log
1313
# Less
1414
stylesheets/*.css
1515
stylesheets/*.css.map
16+
17+
# Project
18+
.gemini/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "faz",
3-
"version": "0.4.3",
3+
"version": "0.5.0",
44
"description": "JS HTML Web Components",
55
"main": "dist/index.js",
66
"module": "dist/js/index.js",

showcase/src/poc/fast-poc-element.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ import { FazElement } from "../../../src/element";
33

44
// Uma versão do FazElement que renderiza SINCRONAMENTE pra matar a expansão
55
export class FastPocElement extends FazElement {
6-
connectedCallback() {
7-
if (this.comment){
8-
this.before(this.comment);
9-
}
10-
// SEM Promise.resolve().then()!
11-
// Renderizamos IMEDIATAMENTE no momento da conexão.
12-
if (this.loading()) {
13-
this.render();
14-
}
15-
this.setConnected(true);
16-
this.setLoading(false);
17-
}
6+
// A classe base agora já é síncrona por padrão, mas mantemos aqui
7+
// para garantir o comportamento desejado na POC.
188
}

showcase/src/poc/poc-alert.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
import { FazElement } from "../../../src/element";
1+
import { FastPocElement } from "./fast-poc-element";
22

3-
export class PocAlert extends FazElement {
3+
export class PocAlert extends FastPocElement {
44
constructor() {
55
super();
66
}
77

88
connectedCallback() {
99
const contentAttr = this.getAttribute("content");
10-
if (contentAttr) this.setContent(contentAttr);
10+
if (contentAttr) this.content = contentAttr;
1111
super.connectedCallback();
1212
}
1313

1414
show() {
15+
// Restauramos o display pra que as classes do Bootstrap funcionem no host
16+
this.style.display = "block";
1517
this.classList.add("alert", "alert-primary");
1618
this.setAttribute("role", "alert");
17-
const content = this.content();
19+
20+
const content = this.content;
1821
if (content) {
19-
// Usando innerHTML na POC pra eliminar qualquer dúvida com SolidJS render
2022
this.innerHTML = `<span>${content}</span>`;
2123
}
2224
}

showcase/src/poc/poc-breadcrumb-item.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
import { FazElement } from "../../../src/element";
1+
import { FastPocElement } from "./fast-poc-element";
22

3-
export class PocBreadcrumbItem extends FazElement {
3+
export class PocBreadcrumbItem extends FastPocElement {
4+
constructor() {
5+
super();
6+
}
47

58
connectedCallback() {
69
const contentAttr = this.getAttribute("content");
7-
if (contentAttr) this.setContent(contentAttr);
10+
if (contentAttr) this.content = contentAttr;
811
const linkAttr = this.getAttribute("link");
9-
if (linkAttr) this.setLink(linkAttr);
12+
if (linkAttr) this.link = linkAttr;
1013
super.connectedCallback();
1114
}
1215

1316
show() {
17+
// Removemos o 'contents' pra ele virar um flex-item de verdade
18+
this.style.display = "list-item";
1419
this.classList.add("breadcrumb-item");
15-
const content = this.content();
16-
const link = this.link();
20+
21+
const content = this.content;
22+
const link = this.link;
1723
if (content) {
18-
if (link) {
19-
this.innerHTML = `<a href="${link}">${content}</a>`;
20-
} else {
21-
this.innerHTML = `<span>${content}</span>`;
22-
}
24+
this.innerHTML = link ? `<a href="${link}">${content}</a>` : `<span>${content}</span>`;
2325
}
2426
}
2527
}

showcase/src/poc/poc-breadcrumb.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import { FazElement } from "../../../src/element";
1+
import { FastPocElement } from "./fast-poc-element";
22

3-
export class PocBreadcrumb extends FazElement {
3+
export class PocBreadcrumb extends FastPocElement {
44
private itemOl: HTMLElement | null = null;
55

66
get contentChild() {
7-
return this.itemOl as ChildNode;
7+
return (this.itemOl as unknown as ChildNode) || this.firstChild;
88
}
99

1010
show() {
11-
this.innerHTML = `<nav aria-label="breadcrumb"><ol class="breadcrumb"></ol></nav>`;
11+
this.innerHTML = `
12+
<nav aria-label="breadcrumb">
13+
<ol class="breadcrumb"></ol>
14+
</nav>
15+
`;
1216
this.itemOl = this.querySelector("ol");
1317
}
1418
}

0 commit comments

Comments
 (0)