@brucesantos/design-space 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +69 -1
- package/dist/contrast-B8xa1UIu.js +389 -0
- package/dist/contrast-B8xa1UIu.js.map +1 -0
- package/dist/design-space.css +1 -1
- package/dist/handoff/index.d.ts +20 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1268 -1116
- package/dist/index.js.map +1 -1
- package/dist/registry/index.d.ts +6 -2
- package/dist/shell/Home.d.ts +3 -2
- package/dist/shell/Topbar.d.ts +4 -3
- package/dist/shell/labels.d.ts +15 -0
- package/dist/testing.js +12 -12
- package/dist/types/index.d.ts +17 -0
- package/package.json +1 -1
- package/dist/contrast-BseNi5QD.js +0 -293
- package/dist/contrast-BseNi5QD.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,47 @@ Versionamento semântico. **Patch** para correção sem mudança de contrato,
|
|
|
6
6
|
Mudança estrutural — pasta obrigatória nova, schema de cenário alterado — exige
|
|
7
7
|
comando explícito e revisável, nunca merge silencioso.
|
|
8
8
|
|
|
9
|
+
## 0.6.0 (2026-08-13)
|
|
10
|
+
|
|
11
|
+
### Adicionado
|
|
12
|
+
|
|
13
|
+
- **Escopo explícito de handoff por URL.** `HandoffScope` traz allowlists neutras
|
|
14
|
+
de cenários, padrões de rota e componentes. O formato legível usa `handoff=1`
|
|
15
|
+
com parâmetros repetíveis `allowScenario`, `allowRoute` e `allowComponent`.
|
|
16
|
+
- Home, árvore, busca, flows, referências portadas e catálogo de componentes
|
|
17
|
+
respeitam o recorte. Navegação interna e links de Home/revisão limpa o
|
|
18
|
+
preservam; tentativas fora do escopo recebem mensagem clara sem montar a tela
|
|
19
|
+
solicitada.
|
|
20
|
+
- Helpers públicos `applyHandoffScope`, `parseHandoffScope`,
|
|
21
|
+
`normalizeHandoffScope`, `handoffAllowsScenario`, `handoffAllowsPath` e
|
|
22
|
+
`handoffAllowsComponent` permitem construir e verificar o mesmo contrato fora
|
|
23
|
+
do shell. `scenarioUrl()` e `componentUrl()` aceitam o recorte em
|
|
24
|
+
`overrides.handoff`.
|
|
25
|
+
|
|
26
|
+
### Alterado
|
|
27
|
+
|
|
28
|
+
- O Inspector agrupa visual e semanticamente dados da tarefa e contexto herdado
|
|
29
|
+
do produto/persona. A aba Acessibilidade distingue contrato da tarefa,
|
|
30
|
+
inspeção ao vivo da tela e verificações gerais do produto; Diagnóstico declara
|
|
31
|
+
que continua avaliando o catálogo inteiro.
|
|
32
|
+
- Cenário `approved` sem `approvedAt` aparece como **Aprovado — registro
|
|
33
|
+
pendente**, com alerta no painel e warning equivalente no validador. O status
|
|
34
|
+
e o marcador só recebem tratamento completo de aprovação quando existe uma URL
|
|
35
|
+
de commit registrada.
|
|
36
|
+
|
|
37
|
+
O handoff é bloqueio de foco/UX, não controle de acesso. Preview que exige
|
|
38
|
+
isolamento real precisa de build separado ou autenticação/autorização no produto.
|
|
39
|
+
Não há mudança obrigatória no schema de `Scenario` nem nos catálogos existentes.
|
|
40
|
+
|
|
41
|
+
## 0.5.1 (2026-08-12)
|
|
42
|
+
|
|
43
|
+
### Adicionado
|
|
44
|
+
|
|
45
|
+
- A home agora traz uma legenda dos sete status com o mesmo marcador colorido da
|
|
46
|
+
navegação, o rótulo e o significado completo. A informação permanece textual
|
|
47
|
+
e compreensível sem depender apenas de cor, responde em duas ou uma coluna e
|
|
48
|
+
continua sobrescrevível por `theme.labels`.
|
|
49
|
+
|
|
9
50
|
## 0.5.0 (2026-08-12)
|
|
10
51
|
|
|
11
52
|
### Adicionado
|
package/README.md
CHANGED
|
@@ -46,6 +46,11 @@ export const approveBlocked: Scenario = {
|
|
|
46
46
|
announces: ["request.status", "approval.result"],
|
|
47
47
|
},
|
|
48
48
|
status: "approved",
|
|
49
|
+
approvedAt: {
|
|
50
|
+
url: "https://review.example.test/commit/0123456/requests/REQ-2043",
|
|
51
|
+
commit: "0123456789abcdef",
|
|
52
|
+
date: "2026-08-13",
|
|
53
|
+
},
|
|
49
54
|
};
|
|
50
55
|
```
|
|
51
56
|
|
|
@@ -71,6 +76,12 @@ proposta nem compromisso de implementação.
|
|
|
71
76
|
| `implemented` | Implementado | Disponível no produto real e validado. |
|
|
72
77
|
| `superseded` | Superado | Mantido para histórico ou substituído por outra decisão. |
|
|
73
78
|
|
|
79
|
+
`approved` só representa uma aprovação completamente registrada quando
|
|
80
|
+
`approvedAt` contém a URL imutável do commit, o SHA e a data. Sem esse registro, o
|
|
81
|
+
Inspector mostra **Aprovado — registro pendente** e o validador emite o warning
|
|
82
|
+
“Aprovação incompleta”; a referência não é apresentada como plenamente
|
|
83
|
+
autorizada.
|
|
84
|
+
|
|
74
85
|
`scenariosUnderTest()` inclui por padrão apenas `approved`, `in-implementation` e
|
|
75
86
|
`implemented`. Cenários `ported` ficam fora até serem promovidos, mas podem ser
|
|
76
87
|
selecionados explicitamente pelo segundo argumento.
|
|
@@ -82,6 +93,8 @@ Busca, home, módulos e contagens seguem a visão atual, sem renderizar módulos
|
|
|
82
93
|
vazios. Um deep link direto para um portado infere a visão de referências mesmo
|
|
83
94
|
sem o parâmetro. Links 0.4.0 com `showPorted=1` continuam sendo lidos e são
|
|
84
95
|
normalizados para a nova visão. O diagnóstico sempre avalia o catálogo completo.
|
|
96
|
+
A home também apresenta uma legenda estável com a cor, o rótulo e o significado
|
|
97
|
+
de cada status; os chips de contagem continuam mostrando apenas a visão atual.
|
|
85
98
|
|
|
86
99
|
## A URL é o estado
|
|
87
100
|
|
|
@@ -107,6 +120,60 @@ rede declarados no cenário.
|
|
|
107
120
|
| `motion=1` | Movimento reduzido no palco. |
|
|
108
121
|
| `scale` | Ampliação de texto: `1`, `1.25`, `1.5`, `2`. |
|
|
109
122
|
| `panel=0` | Oculta o painel de contexto. |
|
|
123
|
+
| `handoff=1` | Ativa um recorte explícito de revisão/handoff. |
|
|
124
|
+
| `allowScenario` | Cenário permitido; pode ser repetido e autoriza também a rota do cenário. |
|
|
125
|
+
| `allowRoute` | Padrão de rota permitido, como `/requests/:id`; pode ser repetido. |
|
|
126
|
+
| `allowComponent` | Componente permitido; pode ser repetido. |
|
|
127
|
+
|
|
128
|
+
## Handoff focado por URL
|
|
129
|
+
|
|
130
|
+
O handoff é uma allowlist transportada junto dos demais controles. Ela filtra
|
|
131
|
+
Home, navegação, busca, flows, referências portadas e componentes. A raiz abre a
|
|
132
|
+
Home já filtrada; uma tentativa de abrir cenário, rota ou componente fora da
|
|
133
|
+
lista mostra um bloqueio claro sem montar a tela solicitada.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import {
|
|
137
|
+
scenarioUrl,
|
|
138
|
+
type HandoffScope,
|
|
139
|
+
} from "@brucesantos/design-space";
|
|
140
|
+
|
|
141
|
+
const handoff = {
|
|
142
|
+
scenarios: ["requests.approve-blocked", "requests.approve-allowed"],
|
|
143
|
+
routes: ["/help/:topic"],
|
|
144
|
+
components: ["actions.primary-button"],
|
|
145
|
+
} satisfies HandoffScope;
|
|
146
|
+
|
|
147
|
+
const url = scenarioUrl(approveBlocked, {
|
|
148
|
+
origin: "https://review.example.test",
|
|
149
|
+
overrides: { handoff },
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
O endereço resultante usa parâmetros repetíveis e legíveis:
|
|
154
|
+
|
|
155
|
+
```text
|
|
156
|
+
?scenario=requests.approve-blocked&persona=approver&fixture=request-without-document&handoff=1&allowScenario=requests.approve-allowed&allowScenario=requests.approve-blocked&allowRoute=%2Fhelp%2F%3Atopic&allowComponent=actions.primary-button
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
As listas são uma união: cenários tornam suas próprias rotas acessíveis, rotas
|
|
160
|
+
explícitas cobrem páginas sem cenário e componentes precisam ser listados
|
|
161
|
+
separadamente. `applyHandoffScope()` e `parseHandoffScope()` constroem ou leem o
|
|
162
|
+
mesmo contrato em URLs próprias.
|
|
163
|
+
|
|
164
|
+
Este recorte é um bloqueio de foco/UX, **não segurança**. O bundle e o catálogo
|
|
165
|
+
continuam no navegador. Preview público que precisa ocultar de fato o restante do
|
|
166
|
+
produto exige build separado para o recorte ou autenticação/autorização no
|
|
167
|
+
produto que publica o preview.
|
|
168
|
+
|
|
169
|
+
### Escopo no Inspector
|
|
170
|
+
|
|
171
|
+
Na aba Cenário, **Dados desta tarefa** reúne situação, reprodução, regras,
|
|
172
|
+
critérios e aprovação; **Contexto herdado do produto e da persona** reúne objetivo
|
|
173
|
+
e permissões efetivas. Em Acessibilidade, o contrato da tarefa, a inspeção da tela
|
|
174
|
+
atual e os pares globais do produto têm agrupamentos próprios. Diagnóstico
|
|
175
|
+
continua deliberadamente geral e identifica que avalia o catálogo inteiro,
|
|
176
|
+
inclusive fora do handoff.
|
|
110
177
|
|
|
111
178
|
## API
|
|
112
179
|
|
|
@@ -169,7 +236,8 @@ e a revisão limpa preservam a aparência escolhida.
|
|
|
169
236
|
consultam trabalho ativo por padrão e aceitam `{ view: "ported" }` para a
|
|
170
237
|
biblioteca de referências. `{ includePorted: true }` permanece disponível para
|
|
171
238
|
diagnóstico e consultas do catálogo completo. `tree` e `issues` continuam
|
|
172
|
-
completos.
|
|
239
|
+
completos. Todas aceitam também `{ handoff }`; `componentsFor(handoff)` aplica
|
|
240
|
+
o mesmo recorte ao catálogo visual.
|
|
173
241
|
- `validateProduct(product)` / `validateScenario(scenario)` — validação em runtime
|
|
174
242
|
do contrato. Pega fixture, persona, regra ou rota inexistente, que o TypeScript
|
|
175
243
|
não alcança.
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
const P = [
|
|
2
|
+
"ported",
|
|
3
|
+
"proposed",
|
|
4
|
+
"in-review",
|
|
5
|
+
"approved",
|
|
6
|
+
"in-implementation",
|
|
7
|
+
"implemented",
|
|
8
|
+
"superseded"
|
|
9
|
+
], k = [
|
|
10
|
+
"success",
|
|
11
|
+
"loading",
|
|
12
|
+
"empty",
|
|
13
|
+
"error",
|
|
14
|
+
"slow"
|
|
15
|
+
], S = /^[a-z0-9]+([.\-][a-z0-9]+)*$/;
|
|
16
|
+
function m(e) {
|
|
17
|
+
return typeof e == "string" && e.trim().length > 0;
|
|
18
|
+
}
|
|
19
|
+
function j(e, r) {
|
|
20
|
+
const t = [], o = m(e?.id) ? `scenario:${e.id}` : `scenario[${r ?? "?"}]`, n = (c) => t.push({ level: "error", where: o, message: c }), s = (c) => t.push({ level: "warning", where: o, message: c });
|
|
21
|
+
m(e?.id) ? S.test(e.id) ? e.id.includes(".") || s("`id` sem prefixo de módulo dificulta a navegação e a busca do agente.") : n(
|
|
22
|
+
"`id` deve ser minúsculo em kebab-case, com o módulo como prefixo: `requests.approve-blocked`."
|
|
23
|
+
) : n("`id` é obrigatório."), m(e?.title) || n("`title` é obrigatório e deve usar o vocabulário do negócio."), m(e?.route) ? e.route.startsWith("/") || n("`route` deve começar com `/`.") : n("`route` é obrigatório."), m(e?.persona) || n("`persona` é obrigatório."), m(e?.fixture) || n("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), P.includes(e?.status) || n(`\`status\` deve ser um de: ${P.join(", ")}.`), e?.network && !k.includes(e.network) && n(`\`network\` deve ser um de: ${k.join(", ")}.`);
|
|
24
|
+
const a = e?.a11y;
|
|
25
|
+
return !a || typeof a != "object" ? n(
|
|
26
|
+
"`a11y` é obrigatório. Acessibilidade é campo do contrato, não auditoria de fim de projeto (D-15)."
|
|
27
|
+
) : (["full", "partial", "not-applicable"].includes(a.keyboard) || n("`a11y.keyboard` deve ser `full`, `partial` ou `not-applicable`."), ["AA", "AAA"].includes(a.contrast) || n("`a11y.contrast` deve ser `AA` ou `AAA`. O padrão interno é WCAG 2.2 AA."), a.announces !== void 0 && !Array.isArray(a.announces) && n("`a11y.announces` deve ser uma lista de chaves de evento de domínio.")), e?.status === "approved" && a?.keyboard === "partial" && s(
|
|
28
|
+
'Cenário aprovado com `a11y.keyboard: "partial"`. Confirme que esta jornada não é crítica.'
|
|
29
|
+
), e?.status === "approved" && !e.approvedAt && s(
|
|
30
|
+
"Aprovação incompleta: cenário `approved` sem `approvedAt`. Registre a URL imutável do commit aprovado (§10.2); sem ela, a versão autorizada não é rastreável."
|
|
31
|
+
), e?.expected?.length || s(
|
|
32
|
+
"Sem `expected`, o cenário não vira caso verificável no handoff — é tela bonita sem critério (risco: prototype theater)."
|
|
33
|
+
), t;
|
|
34
|
+
}
|
|
35
|
+
function q(e) {
|
|
36
|
+
const r = [], t = (u, i, d) => r.push({ level: u, where: i, message: d }), o = new Set(e.personas?.map((u) => u.id) ?? []), n = new Set(e.fixtures?.map((u) => u.id) ?? []), s = new Set(e.rules?.map((u) => u.id) ?? []), a = new Set(e.modules?.map((u) => u.id) ?? []), c = /* @__PURE__ */ new Set();
|
|
37
|
+
m(e.id) || t("error", "product", "`id` é obrigatório."), m(e.name) || t("error", "product", "`name` é obrigatório."), e.routes?.length || t("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar.");
|
|
38
|
+
const p = /* @__PURE__ */ new Set();
|
|
39
|
+
for (const [u, i] of (e.components ?? []).entries()) {
|
|
40
|
+
const d = `component:${i?.id ?? u}`;
|
|
41
|
+
m(i?.id) ? S.test(i.id) ? p.has(i.id) ? t("error", d, `\`id\` duplicado: ${i.id}.`) : p.add(i.id) : t("error", d, "`id` deve ser minúsculo em kebab-case ou usar pontos para agrupamento.") : t("error", d, "`id` é obrigatório."), m(i?.name) || t("error", d, "`name` é obrigatório."), typeof i?.preview != "function" && t("error", d, "`preview` é obrigatório.");
|
|
42
|
+
const l = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const [x, f] of (i?.fixtures ?? []).entries()) {
|
|
44
|
+
const b = `${d}/fixture:${f?.id ?? x}`;
|
|
45
|
+
m(f?.id) ? S.test(f.id) ? l.has(f.id) ? t("error", b, `Id de fixture do componente duplicado: \`${f.id}\`.`) : l.add(f.id) : t(
|
|
46
|
+
"error",
|
|
47
|
+
b,
|
|
48
|
+
`Id de fixture do componente inválido: \`${f.id}\`. Use minúsculas em kebab-case.`
|
|
49
|
+
) : t("error", b, "`id` da fixture do componente é obrigatório."), m(f?.label) || t("error", b, "`label` da fixture do componente é obrigatório."), (!f || !("data" in f)) && t("error", b, "`data` da fixture do componente é obrigatório.");
|
|
50
|
+
}
|
|
51
|
+
i?.defaultFixture && !l.has(i.defaultFixture) && t(
|
|
52
|
+
"error",
|
|
53
|
+
d,
|
|
54
|
+
`\`defaultFixture\` aponta para fixture inexistente: \`${i.defaultFixture}\`.`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
for (const [u, i] of (e.scenarios ?? []).entries()) {
|
|
58
|
+
r.push(...j(i, u));
|
|
59
|
+
const d = `scenario:${i?.id ?? u}`;
|
|
60
|
+
if (i?.id) {
|
|
61
|
+
c.has(i.id) && t("error", d, `\`id\` duplicado: ${i.id}.`), c.add(i.id);
|
|
62
|
+
const l = i.id.split(".")[0];
|
|
63
|
+
l && a.size > 0 && !a.has(l) && t(
|
|
64
|
+
"warning",
|
|
65
|
+
d,
|
|
66
|
+
`Prefixo \`${l}\` não corresponde a nenhum módulo registrado. O cenário não vai aparecer na navegação.`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
i?.persona && !o.has(i.persona) && t("error", d, `Persona não registrada: \`${i.persona}\`.`), i?.fixture && !n.has(i.fixture) && t("error", d, `Fixture não registrada: \`${i.fixture}\`.`);
|
|
70
|
+
for (const l of i?.rules ?? [])
|
|
71
|
+
s.has(l) || t("error", d, `Regra não registrada: \`${l}\`.`);
|
|
72
|
+
i?.route && !T(i.route, e) && t(
|
|
73
|
+
"error",
|
|
74
|
+
d,
|
|
75
|
+
`Rota \`${i.route}\` não casa com nenhuma rota declarada. O deep link abriria a tela de rota inexistente.`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
for (const u of e.modules ?? [])
|
|
79
|
+
for (const i of u.flows ?? []) {
|
|
80
|
+
const d = `flow:${u.id}/${i.id}`;
|
|
81
|
+
i.steps?.length || t("warning", d, "Jornada sem passos.");
|
|
82
|
+
for (const l of i.steps ?? []) {
|
|
83
|
+
c.has(l.scenario) || t("error", d, `Passo aponta para cenário inexistente: \`${l.scenario}\`.`);
|
|
84
|
+
for (const [x, f] of Object.entries(l.branches ?? {}))
|
|
85
|
+
c.has(f) || t(
|
|
86
|
+
"error",
|
|
87
|
+
d,
|
|
88
|
+
`Ramificação "${x}" aponta para cenário inexistente: \`${f}\`.`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const h = e.dataSources?.default;
|
|
93
|
+
return h && h !== "fixtures" && (new Set(e.dataSources?.adapters?.map((i) => i.id) ?? []).has(h) || t("error", "product", `\`dataSources.default\` aponta para adapter inexistente: \`${h}\`.`), t(
|
|
94
|
+
"warning",
|
|
95
|
+
"product",
|
|
96
|
+
"A fonte padrão não é `fixtures`. O padrão do ambiente é dado sintético e determinístico (D-05); API real entra como adapter opcional, com justificativa."
|
|
97
|
+
)), r;
|
|
98
|
+
}
|
|
99
|
+
function T(e, r) {
|
|
100
|
+
const t = e.split("?")[0] ?? e;
|
|
101
|
+
return (r.routes ?? []).some((o) => U(o.path, t));
|
|
102
|
+
}
|
|
103
|
+
function U(e, r) {
|
|
104
|
+
const t = e.split("/").filter(Boolean), o = r.split("/").filter(Boolean);
|
|
105
|
+
for (const [n, s] of t.entries()) {
|
|
106
|
+
if (s === "*") return !0;
|
|
107
|
+
const a = o[n];
|
|
108
|
+
if (a === void 0) return !1;
|
|
109
|
+
if (!s.startsWith(":") && s !== a)
|
|
110
|
+
return !1;
|
|
111
|
+
}
|
|
112
|
+
return t.length === o.length;
|
|
113
|
+
}
|
|
114
|
+
function V(e) {
|
|
115
|
+
return e.some((r) => r.level === "error");
|
|
116
|
+
}
|
|
117
|
+
function G(e) {
|
|
118
|
+
return e.length === 0 ? "Nenhum problema encontrado." : e.map((r) => `${r.level === "error" ? "✖" : "▲"} ${r.where}
|
|
119
|
+
${r.message}`).join(`
|
|
120
|
+
`);
|
|
121
|
+
}
|
|
122
|
+
function C(e, r) {
|
|
123
|
+
const t = e.split("/").filter(Boolean), o = z(r).split("/").filter(Boolean), n = {};
|
|
124
|
+
for (const [s, a] of t.entries()) {
|
|
125
|
+
if (a === "*")
|
|
126
|
+
return n["*"] = o.slice(s).join("/"), n;
|
|
127
|
+
const c = o[s];
|
|
128
|
+
if (c === void 0) return null;
|
|
129
|
+
if (a.startsWith(":")) {
|
|
130
|
+
n[a.slice(1)] = c;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (a !== c) return null;
|
|
134
|
+
}
|
|
135
|
+
return t.length !== o.length ? null : n;
|
|
136
|
+
}
|
|
137
|
+
function J(e, r) {
|
|
138
|
+
const t = [...e].sort((o, n) => N(n.path) - N(o.path));
|
|
139
|
+
for (const o of t) {
|
|
140
|
+
const n = C(o.path, r);
|
|
141
|
+
if (n) return { definition: o, params: n };
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function N(e) {
|
|
145
|
+
const r = e.split("/").filter(Boolean);
|
|
146
|
+
let t = r.length;
|
|
147
|
+
for (const o of r)
|
|
148
|
+
o === "*" ? t -= 2 : o.startsWith(":") ? t += 1 : t += 4;
|
|
149
|
+
return t;
|
|
150
|
+
}
|
|
151
|
+
function z(e) {
|
|
152
|
+
const r = e.split("?")[0] ?? e;
|
|
153
|
+
try {
|
|
154
|
+
return decodeURI(r);
|
|
155
|
+
} catch {
|
|
156
|
+
return r;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const g = {
|
|
160
|
+
enabled: "handoff",
|
|
161
|
+
scenario: "allowScenario",
|
|
162
|
+
route: "allowRoute",
|
|
163
|
+
component: "allowComponent"
|
|
164
|
+
};
|
|
165
|
+
function K(e) {
|
|
166
|
+
if (e.get(g.enabled) === "1")
|
|
167
|
+
return I({
|
|
168
|
+
scenarios: e.getAll(g.scenario),
|
|
169
|
+
routes: e.getAll(g.route),
|
|
170
|
+
components: e.getAll(g.component)
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function E(e, r) {
|
|
174
|
+
for (const o of Object.values(g)) e.delete(o);
|
|
175
|
+
if (!r) return;
|
|
176
|
+
e.set(g.enabled, "1");
|
|
177
|
+
const t = I(r);
|
|
178
|
+
for (const o of t.scenarios ?? []) e.append(g.scenario, o);
|
|
179
|
+
for (const o of t.routes ?? []) e.append(g.route, o);
|
|
180
|
+
for (const o of t.components ?? []) e.append(g.component, o);
|
|
181
|
+
}
|
|
182
|
+
function I(e) {
|
|
183
|
+
const r = A(e.scenarios), t = A(e.routes), o = A(e.components);
|
|
184
|
+
return {
|
|
185
|
+
...r.length ? { scenarios: r } : {},
|
|
186
|
+
...t.length ? { routes: t } : {},
|
|
187
|
+
...o.length ? { components: o } : {}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function F(e, r) {
|
|
191
|
+
return !e || !!(r && e.scenarios?.includes(r));
|
|
192
|
+
}
|
|
193
|
+
function Q(e, r) {
|
|
194
|
+
return !e || !!(r && e.components?.includes(r));
|
|
195
|
+
}
|
|
196
|
+
function X(e, r, t = []) {
|
|
197
|
+
return !e || r === "/" ? !0 : [
|
|
198
|
+
...e.routes ?? [],
|
|
199
|
+
...t.filter((n) => F(e, n.id)).map((n) => n.route)
|
|
200
|
+
].some((n) => C(n, r) !== null);
|
|
201
|
+
}
|
|
202
|
+
function A(e) {
|
|
203
|
+
return [...new Set((e ?? []).map((r) => r.trim()).filter(Boolean))].sort();
|
|
204
|
+
}
|
|
205
|
+
const v = {
|
|
206
|
+
scenario: "scenario",
|
|
207
|
+
view: "view",
|
|
208
|
+
showPorted: "showPorted",
|
|
209
|
+
component: "component",
|
|
210
|
+
persona: "persona",
|
|
211
|
+
fixture: "fixture",
|
|
212
|
+
network: "network",
|
|
213
|
+
viewport: "viewport",
|
|
214
|
+
customWidth: "w",
|
|
215
|
+
themeMode: "theme",
|
|
216
|
+
locale: "locale",
|
|
217
|
+
dataSource: "source",
|
|
218
|
+
chromeTheme: "appearance",
|
|
219
|
+
chrome: "chrome",
|
|
220
|
+
keyboardMode: "kb",
|
|
221
|
+
reducedMotion: "motion",
|
|
222
|
+
textScale: "scale",
|
|
223
|
+
inspector: "panel"
|
|
224
|
+
};
|
|
225
|
+
function B(e) {
|
|
226
|
+
return typeof e == "boolean" ? e ? "1" : "0" : String(e);
|
|
227
|
+
}
|
|
228
|
+
function O(e, r = {}) {
|
|
229
|
+
for (const [t, o] of Object.entries(r)) {
|
|
230
|
+
if (o == null) continue;
|
|
231
|
+
if (t === "handoff") {
|
|
232
|
+
E(e, o);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (t === "showPorted") {
|
|
236
|
+
o === !0 && r.view === void 0 && e.set(v.view, "ported");
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
const n = v[t];
|
|
240
|
+
n && e.set(n, B(o));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function y(e = {}) {
|
|
244
|
+
const r = e.branchUrl || void 0, t = e.deploymentUrl || void 0, o = e.commit || void 0, n = e.env || "development", s = r && `https://${r}` || t && `https://${t}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
|
|
245
|
+
return {
|
|
246
|
+
env: n,
|
|
247
|
+
origin: s.replace(/\/$/, ""),
|
|
248
|
+
branchUrl: r,
|
|
249
|
+
deploymentUrl: t,
|
|
250
|
+
branch: e.branch || void 0,
|
|
251
|
+
commit: o,
|
|
252
|
+
shortCommit: o?.slice(0, 7),
|
|
253
|
+
isDeployed: n === "preview" || n === "production"
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function D(e, r = {}) {
|
|
257
|
+
const t = r.origin ?? y().origin, o = new URL(e.route, t);
|
|
258
|
+
return o.searchParams.set(v.scenario, e.id), o.searchParams.set(v.persona, e.persona), o.searchParams.set(v.fixture, e.fixture), e.status === "ported" && o.searchParams.set(v.view, "ported"), e.network && e.network !== "success" && o.searchParams.set(v.network, e.network), O(o.searchParams, r.overrides), o.toString();
|
|
259
|
+
}
|
|
260
|
+
function Y(e, r = {}) {
|
|
261
|
+
const t = r.origin ?? y().origin, o = new URL("/", t), n = r.fixture ?? e.fixtures?.find((s) => s.id === e.defaultFixture)?.id ?? e.fixtures?.[0]?.id;
|
|
262
|
+
return o.searchParams.set(v.component, e.id), n && o.searchParams.set(v.fixture, n), O(o.searchParams, r.overrides), o.toString();
|
|
263
|
+
}
|
|
264
|
+
function Z(e, r) {
|
|
265
|
+
const t = r.commit ?? y().commit;
|
|
266
|
+
if (!t) return;
|
|
267
|
+
const o = r.template.replaceAll("{shortCommit}", t.slice(0, 7)).replaceAll("{commit}", t);
|
|
268
|
+
return D(e, { origin: o });
|
|
269
|
+
}
|
|
270
|
+
const R = {
|
|
271
|
+
AA: { normal: 4.5, large: 3 },
|
|
272
|
+
AAA: { normal: 7, large: 4.5 }
|
|
273
|
+
}, W = {
|
|
274
|
+
white: "#ffffff",
|
|
275
|
+
black: "#000000",
|
|
276
|
+
transparent: "#00000000"
|
|
277
|
+
};
|
|
278
|
+
function $(e) {
|
|
279
|
+
const r = e.trim().toLowerCase(), t = W[r];
|
|
280
|
+
if (t) return $(t);
|
|
281
|
+
if (r.startsWith("#")) {
|
|
282
|
+
const n = r.slice(1), s = (a) => Number.parseInt(a.repeat(2), 16);
|
|
283
|
+
if (n.length === 3 || n.length === 4) {
|
|
284
|
+
const [a, c, p, h] = [...n];
|
|
285
|
+
return !a || !c || !p ? void 0 : { r: s(a), g: s(c), b: s(p), a: h ? s(h) / 255 : 1 };
|
|
286
|
+
}
|
|
287
|
+
if (n.length === 6 || n.length === 8) {
|
|
288
|
+
const a = (p) => Number.parseInt(n.slice(p, p + 2), 16), c = [a(0), a(2), a(4)];
|
|
289
|
+
return c.some(Number.isNaN) ? void 0 : {
|
|
290
|
+
r: c[0],
|
|
291
|
+
g: c[1],
|
|
292
|
+
b: c[2],
|
|
293
|
+
a: n.length === 8 ? a(6) / 255 : 1
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
const o = r.match(/^rgba?\(([^)]+)\)$/);
|
|
299
|
+
if (o?.[1]) {
|
|
300
|
+
const n = o[1].split(/[\s,/]+/).filter(Boolean), [s, a, c, p] = n.map(Number);
|
|
301
|
+
return [s, a, c].some((h) => h === void 0 || Number.isNaN(h)) ? void 0 : { r: s, g: a, b: c, a: p === void 0 || Number.isNaN(p) ? 1 : p };
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function L(e, r) {
|
|
305
|
+
if (e.a >= 1) return e;
|
|
306
|
+
const t = (o, n) => o * e.a + n * (1 - e.a);
|
|
307
|
+
return {
|
|
308
|
+
r: t(e.r, r.r),
|
|
309
|
+
g: t(e.g, r.g),
|
|
310
|
+
b: t(e.b, r.b),
|
|
311
|
+
a: 1
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function w({ r: e, g: r, b: t }) {
|
|
315
|
+
const o = (n) => {
|
|
316
|
+
const s = n / 255;
|
|
317
|
+
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
318
|
+
};
|
|
319
|
+
return 0.2126 * o(e) + 0.7152 * o(r) + 0.0722 * o(t);
|
|
320
|
+
}
|
|
321
|
+
function M(e, r) {
|
|
322
|
+
const t = $(r), o = $(e);
|
|
323
|
+
if (!t || !o) return;
|
|
324
|
+
const n = L(o, t), s = Math.max(w(n), w(t)), a = Math.min(w(n), w(t));
|
|
325
|
+
return (s + 0.05) / (a + 0.05);
|
|
326
|
+
}
|
|
327
|
+
function H(e) {
|
|
328
|
+
const r = e.target ?? "AA", t = e.largeText ? R[r].large : R[r].normal, o = M(e.foreground, e.background);
|
|
329
|
+
return {
|
|
330
|
+
pair: e,
|
|
331
|
+
target: r,
|
|
332
|
+
ratio: o,
|
|
333
|
+
required: t,
|
|
334
|
+
passes: o === void 0 ? void 0 : o >= t,
|
|
335
|
+
label: o === void 0 ? "não medido" : `${o.toFixed(2)}:1`
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function _(e = []) {
|
|
339
|
+
return e.map(H);
|
|
340
|
+
}
|
|
341
|
+
function ee(e) {
|
|
342
|
+
const r = _(e).filter((o) => o.passes !== !0);
|
|
343
|
+
if (r.length === 0) return;
|
|
344
|
+
const t = r.map(
|
|
345
|
+
(o) => ` ✖ ${o.pair.name}: ${o.label} (mínimo ${o.required}:1 para ${o.target}${o.pair.largeText ? ", texto grande" : ""})`
|
|
346
|
+
).join(`
|
|
347
|
+
`);
|
|
348
|
+
throw new Error(`Pares de contraste fora do alvo:
|
|
349
|
+
${t}`);
|
|
350
|
+
}
|
|
351
|
+
function te(e, r) {
|
|
352
|
+
if (typeof window > "u") return;
|
|
353
|
+
const t = r ?? document.documentElement;
|
|
354
|
+
return window.getComputedStyle(t).getPropertyValue(e).trim() || void 0;
|
|
355
|
+
}
|
|
356
|
+
export {
|
|
357
|
+
R as C,
|
|
358
|
+
g as H,
|
|
359
|
+
k as N,
|
|
360
|
+
v as P,
|
|
361
|
+
P as S,
|
|
362
|
+
F as a,
|
|
363
|
+
E as b,
|
|
364
|
+
_ as c,
|
|
365
|
+
X as d,
|
|
366
|
+
O as e,
|
|
367
|
+
ee as f,
|
|
368
|
+
y as g,
|
|
369
|
+
Q as h,
|
|
370
|
+
H as i,
|
|
371
|
+
Z as j,
|
|
372
|
+
Y as k,
|
|
373
|
+
M as l,
|
|
374
|
+
L as m,
|
|
375
|
+
G as n,
|
|
376
|
+
V as o,
|
|
377
|
+
K as p,
|
|
378
|
+
C as q,
|
|
379
|
+
J as r,
|
|
380
|
+
D as s,
|
|
381
|
+
I as t,
|
|
382
|
+
$ as u,
|
|
383
|
+
q as v,
|
|
384
|
+
te as w,
|
|
385
|
+
w as x,
|
|
386
|
+
B as y,
|
|
387
|
+
j as z
|
|
388
|
+
};
|
|
389
|
+
//# sourceMappingURL=contrast-B8xa1UIu.js.map
|