@brucesantos/design-space 0.2.0 → 0.3.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 +50 -0
- package/README.md +74 -1
- package/dist/contrast-87-ijttm.js +268 -0
- package/dist/contrast-87-ijttm.js.map +1 -0
- package/dist/controls/params.d.ts +2 -0
- package/dist/controls/state.d.ts +2 -0
- package/dist/design-space.css +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1151 -802
- package/dist/index.js.map +1 -1
- package/dist/registry/index.d.ts +2 -1
- package/dist/shell/Controls.d.ts +2 -1
- package/dist/shell/Inspector.d.ts +3 -2
- package/dist/shell/Sidebar.d.ts +8 -2
- package/dist/shell/Topbar.d.ts +6 -5
- package/dist/shell/labels.d.ts +19 -0
- package/dist/testing/index.d.ts +4 -4
- package/dist/testing.js +2 -2
- package/dist/testing.js.map +1 -1
- package/dist/types/index.d.ts +26 -1
- package/package.json +2 -2
- package/dist/contrast-BXd_acxo.js +0 -260
- package/dist/contrast-BXd_acxo.js.map +0 -1
package/dist/registry/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fixture, Flow, Module, Persona, ProductDefinition, Rule, Scenario, ScenarioStatus } from '../types/index.js';
|
|
1
|
+
import { ComponentPreview, Fixture, Flow, Module, Persona, ProductDefinition, Rule, Scenario, ScenarioStatus } from '../types/index.js';
|
|
2
2
|
import { ValidationIssue } from './validate.js';
|
|
3
3
|
export type ModuleNode = {
|
|
4
4
|
module: Module;
|
|
@@ -12,6 +12,7 @@ export type Registry = {
|
|
|
12
12
|
orphans: Scenario[];
|
|
13
13
|
issues: ValidationIssue[];
|
|
14
14
|
scenario: (id: string | undefined) => Scenario | undefined;
|
|
15
|
+
component: (id: string | undefined) => ComponentPreview | undefined;
|
|
15
16
|
persona: (id: string | undefined) => Persona | undefined;
|
|
16
17
|
fixture: (id: string | undefined) => Fixture | undefined;
|
|
17
18
|
rule: (id: string | undefined) => Rule | undefined;
|
package/dist/shell/Controls.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ControlsState } from '../types/index.js';
|
|
|
3
3
|
export type ControlsProps = {
|
|
4
4
|
registry: Registry;
|
|
5
5
|
controls: ControlsState;
|
|
6
|
+
scenarioActive: boolean;
|
|
6
7
|
onChange: (patch: Partial<ControlsState>) => void;
|
|
7
8
|
};
|
|
8
|
-
export declare function Controls({ registry, controls, onChange }: ControlsProps): import("react").JSX.Element;
|
|
9
|
+
export declare function Controls({ registry, controls, scenarioActive, onChange }: ControlsProps): import("react").JSX.Element;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Registry } from '../registry/index.js';
|
|
2
2
|
import { AccessibleNode } from '../a11y/accessible-tree.js';
|
|
3
|
-
import { ControlsState, Scenario } from '../types/index.js';
|
|
3
|
+
import { ComponentPreview, ControlsState, Scenario } from '../types/index.js';
|
|
4
4
|
export type InspectorProps = {
|
|
5
5
|
registry: Registry;
|
|
6
6
|
scenario: Scenario | undefined;
|
|
7
|
+
component?: ComponentPreview;
|
|
7
8
|
controls: ControlsState;
|
|
8
9
|
focusedNode: AccessibleNode | undefined;
|
|
9
10
|
tabStopCount: number;
|
|
10
11
|
};
|
|
11
|
-
export declare function Inspector({ registry, scenario, controls, focusedNode, tabStopCount, }: InspectorProps): import("react").JSX.Element;
|
|
12
|
+
export declare function Inspector({ registry, scenario, component, controls, focusedNode, tabStopCount, }: InspectorProps): import("react").JSX.Element;
|
package/dist/shell/Sidebar.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Registry } from '../registry/index.js';
|
|
2
|
+
import { ControlsState, Scenario } from '../types/index.js';
|
|
2
3
|
export type SidebarProps = {
|
|
3
4
|
registry: Registry;
|
|
4
|
-
activeScenario:
|
|
5
|
+
activeScenario: Scenario | undefined;
|
|
6
|
+
activeComponent: string | undefined;
|
|
7
|
+
controls: ControlsState;
|
|
5
8
|
onOpenScenario: (scenarioId: string) => void;
|
|
9
|
+
onOpenComponent: (componentId: string) => void;
|
|
6
10
|
};
|
|
7
|
-
export declare function Sidebar({ registry, activeScenario, onOpenScenario }: SidebarProps): import("react").JSX.Element;
|
|
11
|
+
export declare function Sidebar({ registry, activeScenario, activeComponent, controls, onOpenScenario, onOpenComponent, }: SidebarProps): import("react").JSX.Element;
|
|
12
|
+
export declare function isSearchShortcut(event: Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "altKey" | "shiftKey">): boolean;
|
|
13
|
+
export declare function nextItemId(ids: string[], currentId: string | undefined, offset: number): string | undefined;
|
package/dist/shell/Topbar.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { DeployContext } from '../deploy/index.js';
|
|
2
|
-
import { ProductDefinition, Scenario } from '../types/index.js';
|
|
2
|
+
import { ChromeTheme, ProductDefinition, Scenario } from '../types/index.js';
|
|
3
3
|
export type TopbarProps = {
|
|
4
4
|
product: ProductDefinition;
|
|
5
5
|
scenario: Scenario | undefined;
|
|
6
6
|
deploy: DeployContext;
|
|
7
7
|
inspectorOpen: boolean;
|
|
8
|
-
|
|
8
|
+
chromeTheme: ChromeTheme;
|
|
9
9
|
onToggleInspector: () => void;
|
|
10
|
-
|
|
11
|
-
onHideChrome: () => void;
|
|
10
|
+
onToggleChromeTheme: () => void;
|
|
12
11
|
};
|
|
13
|
-
export declare function Topbar({ product, scenario, deploy, inspectorOpen,
|
|
12
|
+
export declare function Topbar({ product, scenario, deploy, inspectorOpen, chromeTheme, onToggleInspector, onToggleChromeTheme, }: TopbarProps): import("react").JSX.Element;
|
|
13
|
+
export declare function buildCleanReviewUrl(href: string): string;
|
|
14
|
+
export declare function buildHomeUrl(origin: string, chromeTheme: ChromeTheme): string;
|
package/dist/shell/labels.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type Labels = {
|
|
|
7
7
|
/** Rótulo de viewport por id: `fit`, `mobile`, `tablet`, `desktop`, `custom`. */
|
|
8
8
|
viewport: Record<string, string>;
|
|
9
9
|
topbar: {
|
|
10
|
+
homeTitle: (product: string) => string;
|
|
10
11
|
toggleNav: string;
|
|
11
12
|
copyLink: string;
|
|
12
13
|
copied: string;
|
|
@@ -14,18 +15,32 @@ export type Labels = {
|
|
|
14
15
|
cleanReview: string;
|
|
15
16
|
cleanReviewTitle: string;
|
|
16
17
|
panel: string;
|
|
18
|
+
lightMode: string;
|
|
19
|
+
darkMode: string;
|
|
17
20
|
branchTitle: (branch: string) => string;
|
|
18
21
|
commitTitle: (commit: string) => string;
|
|
19
22
|
envTitle: (env: string) => string;
|
|
20
23
|
};
|
|
21
24
|
sidebar: {
|
|
22
25
|
region: string;
|
|
26
|
+
flowsTab: string;
|
|
27
|
+
componentsTab: string;
|
|
23
28
|
searchPlaceholder: string;
|
|
24
29
|
searchLabel: string;
|
|
30
|
+
componentSearchPlaceholder: string;
|
|
31
|
+
componentSearchLabel: string;
|
|
32
|
+
searchShortcut: string;
|
|
25
33
|
noMatch: (query: string) => string;
|
|
26
34
|
matchCount: (total: number) => string;
|
|
35
|
+
noComponentMatch: (query: string) => string;
|
|
36
|
+
componentMatchCount: (total: number) => string;
|
|
27
37
|
emptyModule: string;
|
|
38
|
+
emptyComponents: string;
|
|
28
39
|
withoutModule: string;
|
|
40
|
+
scope: string;
|
|
41
|
+
scopeData: string;
|
|
42
|
+
scopePersona: string;
|
|
43
|
+
scopeNetwork: string;
|
|
29
44
|
};
|
|
30
45
|
controls: {
|
|
31
46
|
region: string;
|
|
@@ -53,6 +68,8 @@ export type Labels = {
|
|
|
53
68
|
tabDiagnostics: string;
|
|
54
69
|
diagnosticsWithErrors: (count: number) => string;
|
|
55
70
|
noScenario: string;
|
|
71
|
+
componentReference: string;
|
|
72
|
+
componentGroup: string;
|
|
56
73
|
situation: string;
|
|
57
74
|
reproduction: string;
|
|
58
75
|
id: string;
|
|
@@ -112,6 +129,8 @@ export type Labels = {
|
|
|
112
129
|
};
|
|
113
130
|
/** Português. É o padrão, não uma obrigação. */
|
|
114
131
|
export declare const DEFAULT_LABELS: Labels;
|
|
132
|
+
/** English (United States), selectable by the product through `theme.labels`. */
|
|
133
|
+
export declare const EN_US_LABELS: Labels;
|
|
115
134
|
/** Override por grupo. O que não vier declarado fica no padrão. */
|
|
116
135
|
export type LabelsOverride = {
|
|
117
136
|
[Group in keyof Labels]?: Partial<Labels[Group]>;
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -26,10 +26,10 @@ export declare function pathFor(scenario: Scenario, overrides?: Partial<Controls
|
|
|
26
26
|
/**
|
|
27
27
|
* Cenários que valem uma jornada automatizada.
|
|
28
28
|
*
|
|
29
|
-
* Deliberadamente não é "todos": rodar Playwright em cenário `
|
|
30
|
-
* transforma exploração em trabalho de manutenção de
|
|
31
|
-
* "governança proporcional" (Princípio 9). O piso é o
|
|
32
|
-
* aprovado ou já existe em produção.
|
|
29
|
+
* Deliberadamente não é "todos": rodar Playwright em cenário `ported` ou
|
|
30
|
+
* `proposed` transforma importação ou exploração em trabalho de manutenção de
|
|
31
|
+
* teste, que é o oposto de "governança proporcional" (Princípio 9). O piso é o
|
|
32
|
+
* cenário que já foi aprovado ou já existe em produção.
|
|
33
33
|
*/
|
|
34
34
|
export declare function scenariosUnderTest(product: ProductDefinition, statuses?: ScenarioStatus[]): Scenario[];
|
|
35
35
|
/** Cenários que declaram jornada completável só por teclado. */
|
package/dist/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { v as n, j as o, i, s as t } from "./contrast-
|
|
2
|
-
import { b as v, d as P, c as g, f as E } from "./contrast-
|
|
1
|
+
import { v as n, j as o, i, s as t } from "./contrast-87-ijttm.js";
|
|
2
|
+
import { b as v, d as P, c as g, f as E } from "./contrast-87-ijttm.js";
|
|
3
3
|
function a(e = "http://localhost:5173") {
|
|
4
4
|
const r = typeof process < "u" ? process.env : {};
|
|
5
5
|
return (r.PREVIEW_URL || r.BASE_URL || e).replace(/\/$/, "");
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sources":["../src/testing/index.ts"],"sourcesContent":["/**\n * `@brucesantos/design-space/testing`\n *\n * Utilitários para os testes do produto. Vive num entrypoint separado porque\n * nada aqui deve chegar ao bundle do preview.\n *\n * O que este módulo assume: o preview é público, sem proteção de acesso (D-11).\n * Como não há segredo de bypass nem header de automação a emitir, o Playwright\n * aponta direto para a URL do preview — e é por isso que estas funções só\n * precisam de uma origem.\n */\n\nimport { scenarioUrl } from \"../deploy/index.js\";\nimport { validateProduct, hasErrors, formatIssues } from \"../registry/validate.js\";\nimport {\n assertContrastPairs,\n checkContrastPair,\n checkContrastPairs,\n contrastRatio,\n} from \"../a11y/contrast.js\";\nimport type { ControlsState, ProductDefinition, Scenario, ScenarioStatus } from \"../types/index.js\";\n\n/**\n * Origem contra a qual os testes rodam.\n *\n * `PREVIEW_URL` é o que o gatilho `deployment_status` do GitHub Actions entrega\n * pronto (§10.6), o que dispensa qualquer lógica de descobrir onde o preview foi\n * publicado. Sem ela, cai no dev server local.\n */\nexport function testOrigin(fallback = \"http://localhost:5173\"): string {\n const env = typeof process !== \"undefined\" ? process.env : {};\n const url = env.PREVIEW_URL || env.BASE_URL || fallback;\n return url.replace(/\\/$/, \"\");\n}\n\n/** URL absoluta de um cenário para uso em `page.goto`. */\nexport function urlFor(\n scenario: Scenario,\n options: { origin?: string; overrides?: Partial<ControlsState> } = {},\n): string {\n return scenarioUrl(scenario, { origin: options.origin ?? testOrigin(), overrides: options.overrides });\n}\n\n/**\n * Caminho relativo de um cenário: `/rota?scenario=…`.\n *\n * É a forma preferida em Playwright, porque deixa o `baseURL` da configuração\n * decidir se o teste roda contra o preview ou contra o dev server. Um teste que\n * embute a origem passa a existir em duas versões, e a versão local é a que\n * ninguém roda.\n */\nexport function pathFor(\n scenario: Scenario,\n overrides: Partial<ControlsState> = {},\n): string {\n const url = new URL(scenarioUrl(scenario, { origin: \"http://design-space.invalid\", overrides }));\n return `${url.pathname}${url.search}`;\n}\n\n/**\n * Cenários que valem uma jornada automatizada.\n *\n * Deliberadamente não é \"todos\": rodar Playwright em cenário `
|
|
1
|
+
{"version":3,"file":"testing.js","sources":["../src/testing/index.ts"],"sourcesContent":["/**\n * `@brucesantos/design-space/testing`\n *\n * Utilitários para os testes do produto. Vive num entrypoint separado porque\n * nada aqui deve chegar ao bundle do preview.\n *\n * O que este módulo assume: o preview é público, sem proteção de acesso (D-11).\n * Como não há segredo de bypass nem header de automação a emitir, o Playwright\n * aponta direto para a URL do preview — e é por isso que estas funções só\n * precisam de uma origem.\n */\n\nimport { scenarioUrl } from \"../deploy/index.js\";\nimport { validateProduct, hasErrors, formatIssues } from \"../registry/validate.js\";\nimport {\n assertContrastPairs,\n checkContrastPair,\n checkContrastPairs,\n contrastRatio,\n} from \"../a11y/contrast.js\";\nimport type { ControlsState, ProductDefinition, Scenario, ScenarioStatus } from \"../types/index.js\";\n\n/**\n * Origem contra a qual os testes rodam.\n *\n * `PREVIEW_URL` é o que o gatilho `deployment_status` do GitHub Actions entrega\n * pronto (§10.6), o que dispensa qualquer lógica de descobrir onde o preview foi\n * publicado. Sem ela, cai no dev server local.\n */\nexport function testOrigin(fallback = \"http://localhost:5173\"): string {\n const env = typeof process !== \"undefined\" ? process.env : {};\n const url = env.PREVIEW_URL || env.BASE_URL || fallback;\n return url.replace(/\\/$/, \"\");\n}\n\n/** URL absoluta de um cenário para uso em `page.goto`. */\nexport function urlFor(\n scenario: Scenario,\n options: { origin?: string; overrides?: Partial<ControlsState> } = {},\n): string {\n return scenarioUrl(scenario, { origin: options.origin ?? testOrigin(), overrides: options.overrides });\n}\n\n/**\n * Caminho relativo de um cenário: `/rota?scenario=…`.\n *\n * É a forma preferida em Playwright, porque deixa o `baseURL` da configuração\n * decidir se o teste roda contra o preview ou contra o dev server. Um teste que\n * embute a origem passa a existir em duas versões, e a versão local é a que\n * ninguém roda.\n */\nexport function pathFor(\n scenario: Scenario,\n overrides: Partial<ControlsState> = {},\n): string {\n const url = new URL(scenarioUrl(scenario, { origin: \"http://design-space.invalid\", overrides }));\n return `${url.pathname}${url.search}`;\n}\n\n/**\n * Cenários que valem uma jornada automatizada.\n *\n * Deliberadamente não é \"todos\": rodar Playwright em cenário `ported` ou\n * `proposed` transforma importação ou exploração em trabalho de manutenção de\n * teste, que é o oposto de \"governança proporcional\" (Princípio 9). O piso é o\n * cenário que já foi aprovado ou já existe em produção.\n */\nexport function scenariosUnderTest(\n product: ProductDefinition,\n statuses: ScenarioStatus[] = [\"approved\", \"in-implementation\", \"implemented\"],\n): Scenario[] {\n return product.scenarios.filter((scenario) => statuses.includes(scenario.status));\n}\n\n/** Cenários que declaram jornada completável só por teclado. */\nexport function keyboardScenarios(product: ProductDefinition): Scenario[] {\n return product.scenarios.filter((scenario) => scenario.a11y.keyboard === \"full\");\n}\n\n/**\n * Falha o teste quando o contrato de cenário do produto tem erro.\n *\n * É o equivalente do typecheck para o que o TypeScript não alcança: fixture\n * inexistente, persona escrita errada, rota que não casa com nada.\n */\nexport function assertValidProduct(product: ProductDefinition): void {\n const issues = validateProduct(product);\n if (hasErrors(issues)) {\n throw new Error(`Contrato de cenário inválido:\\n${formatIssues(issues)}`);\n }\n}\n\n// Medição de contraste também é ferramenta de teste: o produto valida os\n// próprios tokens, e o motor só sabe medir.\nexport {\n assertContrastPairs,\n checkContrastPair,\n checkContrastPairs,\n contrastRatio,\n formatIssues,\n hasErrors,\n validateProduct,\n};\nexport { scenarioUrl } from \"../deploy/index.js\";\n"],"names":["testOrigin","fallback","env","urlFor","scenario","options","scenarioUrl","pathFor","overrides","url","scenariosUnderTest","product","statuses","keyboardScenarios","assertValidProduct","issues","validateProduct","hasErrors","formatIssues"],"mappings":";;AA6BO,SAASA,EAAWC,IAAW,yBAAiC;AACrE,QAAMC,IAAM,OAAO,UAAY,MAAc,QAAQ,MAAM,CAAA;AAE3D,UADYA,EAAI,eAAeA,EAAI,YAAYD,GACpC,QAAQ,OAAO,EAAE;AAC9B;AAGO,SAASE,EACdC,GACAC,IAAmE,IAC3D;AACR,SAAOC,EAAYF,GAAU,EAAE,QAAQC,EAAQ,UAAUL,KAAc,WAAWK,EAAQ,UAAA,CAAW;AACvG;AAUO,SAASE,EACdH,GACAI,IAAoC,IAC5B;AACR,QAAMC,IAAM,IAAI,IAAIH,EAAYF,GAAU,EAAE,QAAQ,+BAA+B,WAAAI,EAAA,CAAW,CAAC;AAC/F,SAAO,GAAGC,EAAI,QAAQ,GAAGA,EAAI,MAAM;AACrC;AAUO,SAASC,EACdC,GACAC,IAA6B,CAAC,YAAY,qBAAqB,aAAa,GAChE;AACZ,SAAOD,EAAQ,UAAU,OAAO,CAACP,MAAaQ,EAAS,SAASR,EAAS,MAAM,CAAC;AAClF;AAGO,SAASS,EAAkBF,GAAwC;AACxE,SAAOA,EAAQ,UAAU,OAAO,CAACP,MAAaA,EAAS,KAAK,aAAa,MAAM;AACjF;AAQO,SAASU,EAAmBH,GAAkC;AACnE,QAAMI,IAASC,EAAgBL,CAAO;AACtC,MAAIM,EAAUF,CAAM;AAClB,UAAM,IAAI,MAAM;AAAA,EAAkCG,EAAaH,CAAM,CAAC,EAAE;AAE5E;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { LabelsOverride } from '../shell/labels.js';
|
|
|
4
4
|
* Estado de ciclo de vida do cenário (§18.1). Existe para evitar que a
|
|
5
5
|
* referência envelheça em silêncio quando o produto real muda.
|
|
6
6
|
*/
|
|
7
|
-
export type ScenarioStatus = "proposed" | "in-review" | "approved" | "in-implementation" | "implemented" | "superseded";
|
|
7
|
+
export type ScenarioStatus = "ported" | "proposed" | "in-review" | "approved" | "in-implementation" | "implemented" | "superseded";
|
|
8
8
|
export declare const SCENARIO_STATUSES: readonly ScenarioStatus[];
|
|
9
9
|
/** Nível de conformidade alvo. O padrão interno é WCAG 2.2 AA. */
|
|
10
10
|
export type ContrastTarget = "AA" | "AAA";
|
|
@@ -167,6 +167,23 @@ export type ScreenProps = {
|
|
|
167
167
|
/** Contexto do cenário ativo, resolvido pelo motor. */
|
|
168
168
|
context: ScenarioContext;
|
|
169
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* Componente do produto exposto no catálogo do Design Space.
|
|
172
|
+
*
|
|
173
|
+
* O motor só organiza e renderiza a referência. Implementação, aparência e
|
|
174
|
+
* conteúdo continuam no repositório do produto.
|
|
175
|
+
*/
|
|
176
|
+
export type ComponentPreview = {
|
|
177
|
+
/** Identificador estável usado no deep link: `button.primary`. */
|
|
178
|
+
id: string;
|
|
179
|
+
/** Nome legível no vocabulário do produto. */
|
|
180
|
+
name: string;
|
|
181
|
+
/** Grupo de navegação: `Ações`, `Formulários`, `Feedback`. */
|
|
182
|
+
group?: string;
|
|
183
|
+
description?: string;
|
|
184
|
+
/** Composição visual fornecida e mantida pelo produto. */
|
|
185
|
+
preview: ComponentType;
|
|
186
|
+
};
|
|
170
187
|
/**
|
|
171
188
|
* A UI do produto nunca depende diretamente de um backend. A camada de
|
|
172
189
|
* adapters permite alimentar o mesmo cenário por fixture, REST, GraphQL ou
|
|
@@ -239,6 +256,8 @@ export type ProductDefinition = {
|
|
|
239
256
|
fixtures: Fixture[];
|
|
240
257
|
rules?: Rule[];
|
|
241
258
|
routes: RouteDefinition[];
|
|
259
|
+
/** Catálogo visual opcional, implementado integralmente pelo produto. */
|
|
260
|
+
components?: ComponentPreview[];
|
|
242
261
|
theme?: ProductTheme;
|
|
243
262
|
/**
|
|
244
263
|
* Adapters de dados disponíveis. `fixtures` é o padrão (D-05); qualquer
|
|
@@ -343,8 +362,12 @@ export type ViewportSetting = {
|
|
|
343
362
|
width?: number;
|
|
344
363
|
height?: number;
|
|
345
364
|
};
|
|
365
|
+
/** Aparência do chrome do Design Space. Não altera o tema da UI do produto. */
|
|
366
|
+
export type ChromeTheme = "dark" | "light";
|
|
346
367
|
export type ControlsState = {
|
|
347
368
|
scenario: string | undefined;
|
|
369
|
+
/** Referência visual ativa. Opcional para preservar objetos do contrato anterior. */
|
|
370
|
+
component?: string;
|
|
348
371
|
persona: string | undefined;
|
|
349
372
|
fixture: string | undefined;
|
|
350
373
|
network: NetworkState;
|
|
@@ -353,6 +376,8 @@ export type ControlsState = {
|
|
|
353
376
|
themeMode: string | undefined;
|
|
354
377
|
locale: string | undefined;
|
|
355
378
|
dataSource: string | undefined;
|
|
379
|
+
/** Tema visual do chrome; independente de `themeMode` do produto. */
|
|
380
|
+
chromeTheme?: ChromeTheme;
|
|
356
381
|
/** Chrome do Design Space oculto: revisão limpa e captura de tela. */
|
|
357
382
|
chrome: boolean;
|
|
358
383
|
keyboardMode: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brucesantos/design-space",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Motor neutro do Bananas Design Space: registry de cenários, shell, deep links, controles de persona/viewport/rede, inspetor de regras e ferramentas de acessibilidade. Não contém UI de cliente.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,4 +64,4 @@
|
|
|
64
64
|
"typecheck": "tsc --noEmit",
|
|
65
65
|
"test": "vitest run"
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
const b = [
|
|
2
|
-
"proposed",
|
|
3
|
-
"in-review",
|
|
4
|
-
"approved",
|
|
5
|
-
"in-implementation",
|
|
6
|
-
"implemented",
|
|
7
|
-
"superseded"
|
|
8
|
-
], w = [
|
|
9
|
-
"success",
|
|
10
|
-
"loading",
|
|
11
|
-
"empty",
|
|
12
|
-
"error",
|
|
13
|
-
"slow"
|
|
14
|
-
], $ = /^[a-z0-9]+([.\-][a-z0-9]+)*$/;
|
|
15
|
-
function m(e) {
|
|
16
|
-
return typeof e == "string" && e.trim().length > 0;
|
|
17
|
-
}
|
|
18
|
-
function y(e, o) {
|
|
19
|
-
const t = [], r = m(e?.id) ? `scenario:${e.id}` : `scenario[${o ?? "?"}]`, a = (d) => t.push({ level: "error", where: r, message: d }), i = (d) => t.push({ level: "warning", where: r, message: d });
|
|
20
|
-
m(e?.id) ? $.test(e.id) ? e.id.includes(".") || i("`id` sem prefixo de módulo dificulta a navegação e a busca do agente.") : a(
|
|
21
|
-
"`id` deve ser minúsculo em kebab-case, com o módulo como prefixo: `requests.approve-blocked`."
|
|
22
|
-
) : a("`id` é obrigatório."), m(e?.title) || a("`title` é obrigatório e deve usar o vocabulário do negócio."), m(e?.route) ? e.route.startsWith("/") || a("`route` deve começar com `/`.") : a("`route` é obrigatório."), m(e?.persona) || a("`persona` é obrigatório."), m(e?.fixture) || a("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), b.includes(e?.status) || a(`\`status\` deve ser um de: ${b.join(", ")}.`), e?.network && !w.includes(e.network) && a(`\`network\` deve ser um de: ${w.join(", ")}.`);
|
|
23
|
-
const n = e?.a11y;
|
|
24
|
-
return !n || typeof n != "object" ? a(
|
|
25
|
-
"`a11y` é obrigatório. Acessibilidade é campo do contrato, não auditoria de fim de projeto (D-15)."
|
|
26
|
-
) : (["full", "partial", "not-applicable"].includes(n.keyboard) || a("`a11y.keyboard` deve ser `full`, `partial` ou `not-applicable`."), ["AA", "AAA"].includes(n.contrast) || a("`a11y.contrast` deve ser `AA` ou `AAA`. O padrão interno é WCAG 2.2 AA."), n.announces !== void 0 && !Array.isArray(n.announces) && a("`a11y.announces` deve ser uma lista de chaves de evento de domínio.")), e?.status === "approved" && n?.keyboard === "partial" && i(
|
|
27
|
-
'Cenário aprovado com `a11y.keyboard: "partial"`. Confirme que esta jornada não é crítica.'
|
|
28
|
-
), e?.status === "approved" && !e.approvedAt && i(
|
|
29
|
-
"Cenário aprovado sem `approvedAt`. A aprovação deve ser registrada por URL de commit (§10.2), senão muda de conteúdo debaixo de quem aprovou."
|
|
30
|
-
), e?.expected?.length || i(
|
|
31
|
-
"Sem `expected`, o cenário não vira caso verificável no handoff — é tela bonita sem critério (risco: prototype theater)."
|
|
32
|
-
), t;
|
|
33
|
-
}
|
|
34
|
-
function U(e) {
|
|
35
|
-
const o = [], t = (c, s, u) => o.push({ level: c, where: s, message: u }), r = new Set(e.personas?.map((c) => c.id) ?? []), a = new Set(e.fixtures?.map((c) => c.id) ?? []), i = new Set(e.rules?.map((c) => c.id) ?? []), n = new Set(e.modules?.map((c) => c.id) ?? []), d = /* @__PURE__ */ new Set();
|
|
36
|
-
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.");
|
|
37
|
-
for (const [c, s] of (e.scenarios ?? []).entries()) {
|
|
38
|
-
o.push(...y(s, c));
|
|
39
|
-
const u = `scenario:${s?.id ?? c}`;
|
|
40
|
-
if (s?.id) {
|
|
41
|
-
d.has(s.id) && t("error", u, `\`id\` duplicado: ${s.id}.`), d.add(s.id);
|
|
42
|
-
const f = s.id.split(".")[0];
|
|
43
|
-
f && n.size > 0 && !n.has(f) && t(
|
|
44
|
-
"warning",
|
|
45
|
-
u,
|
|
46
|
-
`Prefixo \`${f}\` não corresponde a nenhum módulo registrado. O cenário não vai aparecer na navegação.`
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
s?.persona && !r.has(s.persona) && t("error", u, `Persona não registrada: \`${s.persona}\`.`), s?.fixture && !a.has(s.fixture) && t("error", u, `Fixture não registrada: \`${s.fixture}\`.`);
|
|
50
|
-
for (const f of s?.rules ?? [])
|
|
51
|
-
i.has(f) || t("error", u, `Regra não registrada: \`${f}\`.`);
|
|
52
|
-
s?.route && !k(s.route, e) && t(
|
|
53
|
-
"error",
|
|
54
|
-
u,
|
|
55
|
-
`Rota \`${s.route}\` não casa com nenhuma rota declarada. O deep link abriria a tela de rota inexistente.`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
for (const c of e.modules ?? [])
|
|
59
|
-
for (const s of c.flows ?? []) {
|
|
60
|
-
const u = `flow:${c.id}/${s.id}`;
|
|
61
|
-
s.steps?.length || t("warning", u, "Jornada sem passos.");
|
|
62
|
-
for (const f of s.steps ?? []) {
|
|
63
|
-
d.has(f.scenario) || t("error", u, `Passo aponta para cenário inexistente: \`${f.scenario}\`.`);
|
|
64
|
-
for (const [S, v] of Object.entries(f.branches ?? {}))
|
|
65
|
-
d.has(v) || t(
|
|
66
|
-
"error",
|
|
67
|
-
u,
|
|
68
|
-
`Ramificação "${S}" aponta para cenário inexistente: \`${v}\`.`
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const l = e.dataSources?.default;
|
|
73
|
-
return l && l !== "fixtures" && (new Set(e.dataSources?.adapters?.map((s) => s.id) ?? []).has(l) || t("error", "product", `\`dataSources.default\` aponta para adapter inexistente: \`${l}\`.`), t(
|
|
74
|
-
"warning",
|
|
75
|
-
"product",
|
|
76
|
-
"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."
|
|
77
|
-
)), o;
|
|
78
|
-
}
|
|
79
|
-
function k(e, o) {
|
|
80
|
-
const t = e.split("?")[0] ?? e;
|
|
81
|
-
return (o.routes ?? []).some((r) => N(r.path, t));
|
|
82
|
-
}
|
|
83
|
-
function N(e, o) {
|
|
84
|
-
const t = e.split("/").filter(Boolean), r = o.split("/").filter(Boolean);
|
|
85
|
-
for (const [a, i] of t.entries()) {
|
|
86
|
-
if (i === "*") return !0;
|
|
87
|
-
const n = r[a];
|
|
88
|
-
if (n === void 0) return !1;
|
|
89
|
-
if (!i.startsWith(":") && i !== n)
|
|
90
|
-
return !1;
|
|
91
|
-
}
|
|
92
|
-
return t.length === r.length;
|
|
93
|
-
}
|
|
94
|
-
function D(e) {
|
|
95
|
-
return e.some((o) => o.level === "error");
|
|
96
|
-
}
|
|
97
|
-
function M(e) {
|
|
98
|
-
return e.length === 0 ? "Nenhum problema encontrado." : e.map((o) => `${o.level === "error" ? "✖" : "▲"} ${o.where}
|
|
99
|
-
${o.message}`).join(`
|
|
100
|
-
`);
|
|
101
|
-
}
|
|
102
|
-
const p = {
|
|
103
|
-
scenario: "scenario",
|
|
104
|
-
persona: "persona",
|
|
105
|
-
fixture: "fixture",
|
|
106
|
-
network: "network",
|
|
107
|
-
viewport: "viewport",
|
|
108
|
-
customWidth: "w",
|
|
109
|
-
themeMode: "theme",
|
|
110
|
-
locale: "locale",
|
|
111
|
-
dataSource: "source",
|
|
112
|
-
chrome: "chrome",
|
|
113
|
-
keyboardMode: "kb",
|
|
114
|
-
reducedMotion: "motion",
|
|
115
|
-
textScale: "scale",
|
|
116
|
-
inspector: "panel"
|
|
117
|
-
};
|
|
118
|
-
function P(e) {
|
|
119
|
-
return typeof e == "boolean" ? e ? "1" : "0" : String(e);
|
|
120
|
-
}
|
|
121
|
-
function C(e, o = {}) {
|
|
122
|
-
for (const [t, r] of Object.entries(o)) {
|
|
123
|
-
if (r == null) continue;
|
|
124
|
-
const a = p[t];
|
|
125
|
-
a && e.set(a, P(r));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function x(e = {}) {
|
|
129
|
-
const o = e.branchUrl || void 0, t = e.deploymentUrl || void 0, r = e.commit || void 0, a = e.env || "development", i = o && `https://${o}` || t && `https://${t}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
|
|
130
|
-
return {
|
|
131
|
-
env: a,
|
|
132
|
-
origin: i.replace(/\/$/, ""),
|
|
133
|
-
branchUrl: o,
|
|
134
|
-
deploymentUrl: t,
|
|
135
|
-
branch: e.branch || void 0,
|
|
136
|
-
commit: r,
|
|
137
|
-
shortCommit: r?.slice(0, 7),
|
|
138
|
-
isDeployed: a === "preview" || a === "production"
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function R(e, o = {}) {
|
|
142
|
-
const t = o.origin ?? x().origin, r = new URL(e.route, t);
|
|
143
|
-
return r.searchParams.set(p.scenario, e.id), r.searchParams.set(p.persona, e.persona), r.searchParams.set(p.fixture, e.fixture), e.network && e.network !== "success" && r.searchParams.set(p.network, e.network), C(r.searchParams, o.overrides), r.toString();
|
|
144
|
-
}
|
|
145
|
-
function z(e, o) {
|
|
146
|
-
const t = o.commit ?? x().commit;
|
|
147
|
-
if (!t) return;
|
|
148
|
-
const r = o.template.replaceAll("{shortCommit}", t.slice(0, 7)).replaceAll("{commit}", t);
|
|
149
|
-
return R(e, { origin: r });
|
|
150
|
-
}
|
|
151
|
-
const A = {
|
|
152
|
-
AA: { normal: 4.5, large: 3 },
|
|
153
|
-
AAA: { normal: 7, large: 4.5 }
|
|
154
|
-
}, O = {
|
|
155
|
-
white: "#ffffff",
|
|
156
|
-
black: "#000000",
|
|
157
|
-
transparent: "#00000000"
|
|
158
|
-
};
|
|
159
|
-
function g(e) {
|
|
160
|
-
const o = e.trim().toLowerCase(), t = O[o];
|
|
161
|
-
if (t) return g(t);
|
|
162
|
-
if (o.startsWith("#")) {
|
|
163
|
-
const a = o.slice(1), i = (n) => Number.parseInt(n.repeat(2), 16);
|
|
164
|
-
if (a.length === 3 || a.length === 4) {
|
|
165
|
-
const [n, d, l, c] = [...a];
|
|
166
|
-
return !n || !d || !l ? void 0 : { r: i(n), g: i(d), b: i(l), a: c ? i(c) / 255 : 1 };
|
|
167
|
-
}
|
|
168
|
-
if (a.length === 6 || a.length === 8) {
|
|
169
|
-
const n = (l) => Number.parseInt(a.slice(l, l + 2), 16), d = [n(0), n(2), n(4)];
|
|
170
|
-
return d.some(Number.isNaN) ? void 0 : {
|
|
171
|
-
r: d[0],
|
|
172
|
-
g: d[1],
|
|
173
|
-
b: d[2],
|
|
174
|
-
a: a.length === 8 ? n(6) / 255 : 1
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const r = o.match(/^rgba?\(([^)]+)\)$/);
|
|
180
|
-
if (r?.[1]) {
|
|
181
|
-
const a = r[1].split(/[\s,/]+/).filter(Boolean), [i, n, d, l] = a.map(Number);
|
|
182
|
-
return [i, n, d].some((c) => c === void 0 || Number.isNaN(c)) ? void 0 : { r: i, g: n, b: d, a: l === void 0 || Number.isNaN(l) ? 1 : l };
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function I(e, o) {
|
|
186
|
-
if (e.a >= 1) return e;
|
|
187
|
-
const t = (r, a) => r * e.a + a * (1 - e.a);
|
|
188
|
-
return {
|
|
189
|
-
r: t(e.r, o.r),
|
|
190
|
-
g: t(e.g, o.g),
|
|
191
|
-
b: t(e.b, o.b),
|
|
192
|
-
a: 1
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function h({ r: e, g: o, b: t }) {
|
|
196
|
-
const r = (a) => {
|
|
197
|
-
const i = a / 255;
|
|
198
|
-
return i <= 0.03928 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4;
|
|
199
|
-
};
|
|
200
|
-
return 0.2126 * r(e) + 0.7152 * r(o) + 0.0722 * r(t);
|
|
201
|
-
}
|
|
202
|
-
function T(e, o) {
|
|
203
|
-
const t = g(o), r = g(e);
|
|
204
|
-
if (!t || !r) return;
|
|
205
|
-
const a = I(r, t), i = Math.max(h(a), h(t)), n = Math.min(h(a), h(t));
|
|
206
|
-
return (i + 0.05) / (n + 0.05);
|
|
207
|
-
}
|
|
208
|
-
function j(e) {
|
|
209
|
-
const o = e.target ?? "AA", t = e.largeText ? A[o].large : A[o].normal, r = T(e.foreground, e.background);
|
|
210
|
-
return {
|
|
211
|
-
pair: e,
|
|
212
|
-
target: o,
|
|
213
|
-
ratio: r,
|
|
214
|
-
required: t,
|
|
215
|
-
passes: r === void 0 ? void 0 : r >= t,
|
|
216
|
-
label: r === void 0 ? "não medido" : `${r.toFixed(2)}:1`
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
function E(e = []) {
|
|
220
|
-
return e.map(j);
|
|
221
|
-
}
|
|
222
|
-
function L(e) {
|
|
223
|
-
const o = E(e).filter((r) => r.passes !== !0);
|
|
224
|
-
if (o.length === 0) return;
|
|
225
|
-
const t = o.map(
|
|
226
|
-
(r) => ` ✖ ${r.pair.name}: ${r.label} (mínimo ${r.required}:1 para ${r.target}${r.pair.largeText ? ", texto grande" : ""})`
|
|
227
|
-
).join(`
|
|
228
|
-
`);
|
|
229
|
-
throw new Error(`Pares de contraste fora do alvo:
|
|
230
|
-
${t}`);
|
|
231
|
-
}
|
|
232
|
-
function W(e, o) {
|
|
233
|
-
if (typeof window > "u") return;
|
|
234
|
-
const t = o ?? document.documentElement;
|
|
235
|
-
return window.getComputedStyle(t).getPropertyValue(e).trim() || void 0;
|
|
236
|
-
}
|
|
237
|
-
export {
|
|
238
|
-
A as C,
|
|
239
|
-
w as N,
|
|
240
|
-
p as P,
|
|
241
|
-
b as S,
|
|
242
|
-
C as a,
|
|
243
|
-
L as b,
|
|
244
|
-
E as c,
|
|
245
|
-
j as d,
|
|
246
|
-
z as e,
|
|
247
|
-
T as f,
|
|
248
|
-
x as g,
|
|
249
|
-
I as h,
|
|
250
|
-
M as i,
|
|
251
|
-
D as j,
|
|
252
|
-
h as k,
|
|
253
|
-
P as l,
|
|
254
|
-
y as m,
|
|
255
|
-
g as p,
|
|
256
|
-
W as r,
|
|
257
|
-
R as s,
|
|
258
|
-
U as v
|
|
259
|
-
};
|
|
260
|
-
//# sourceMappingURL=contrast-BXd_acxo.js.map
|