Cibles
Angular
dsfc generates the src/ of an Angular library with standalone components, CSS custom properties for tokens, and Vitest specs of its models and of its rendered components in Chromium.
dsfc build fixtures/scenarios/01-button-calculated --target angular --output generated/angular
What is generated
The output is the src/ folder of an Angular 22 library: copy it into a library project
created with ng generate library.
generated/angular/
├── src/
│ ├── public-api.ts
│ └── lib/
│ ├── tokens.css # CSS custom properties per context
│ ├── tokens.ts
│ ├── context.ts # DsContext, provideDsContext(), the dsProvide directive
│ ├── button.ts # standalone component <ds-button>
│ ├── button.model.ts # pure model: resolveButton(), handleButton()
│ ├── action-bar.ts, action-bar.model.ts
│ ├── icons.ts, support.ts
│ ├── examples.spec.ts # the examples as tests of the models
│ └── examples.dom.spec.ts # the examples as tests of the rendered components
└── dsf-build.json
Components are standalone, use signals and OnPush change detection. Properties become
input(), events become output().
Tokens as CSS custom properties
:root {
--ds-unit-base: 16px;
--ds-color-surface: color(srgb 1 1 1);
/* … */
}
[data-ds-theme="dark"] {
--ds-color-surface: color(srgb 0.050980392156862744 0.050980392156862744 0.050980392156862744);
/* … */
}
Context follows the DOM: [dsProvide]="{ theme: 'dark' }" on an element sets
data-ds-theme for its subtree, so slot content resolves where it is rendered.
Using the components
<ds-button label="Continue" [appearance]="'primary'" (activate)="submit()" />
<section [dsProvide]="{ theme: 'dark' }">
<ds-button label="Cancel" (activate)="cancel()" />
</section>
Include tokens.css in the application styles, and set an application-wide context with
provideDsContext({ theme: 'dark' }) if needed.
Native mapping
A button role with an activation handler renders a native <button>, with no custom
keyboard handling. Another component that handles activation (it has an interactive role,
or it is a focus stop with a role) is activated by a click and, when it is a focus stop, by
Space and Enter (D-058). The context follows the browser live: reduced motion, reduced
transparency, increased contrast, a coarse pointer, the document’s dir and lang, and the
browser’s default font size, which sets the text scale text is drawn at (D-058). The tri-state checkbox renders a native <input type="checkbox"> with
indeterminate; a click only requests the change (change event), the host applies it.
Icons, including library icons and icons chosen at run time, are CSS masks, mirrored in
right-to-left layouts when direction = "mirror".
Same rendering as SwiftUI
Box effects follow one model on both targets:
- a
borderis drawn inside the bounds (a::beforelayer, not the CSSborder) and does not change the layout; shadowsfollow the CSSbox-shadowmodel, includingspreadandinset;- a
font_familylist is a fallback stack.
Not supported yet
Every scenario of the corpus (01–14), both example ports and the target fixtures generate
with no DSF-X001. What the generator cannot realize faithfully is reported as DSF-X001
with its location, and nothing is written; what it realizes only in part (accessibility
actions, which ARIA cannot name) is a DSF-X004 warning: nothing is approximated silently. The
known deviations
list where the generated code still differs from the reference semantics.
Examples as tests in a real browser
Each example becomes a test of the generated models and, where the browser can run it, a
test of the rendered components (D-059): TestBed renders the example’s component in
headless Chromium (Vitest browser mode with Playwright), with its properties, variants,
context and slot content, in a box of the example’s available space. Steps use the browser’s
own input: focus moves, Tab and Shift+Tab, keys, presses and drags, typing into the text
input, a press on a dialog’s scrim or outside a popover; host updates go through the
component’s inputs. Expectations read what the browser shows: presence, the focused element,
roles, names, states and relations as assistive technology sees them, and boxes and lines
measured by the browser’s layout for geometry. Every element of a node carries its name
(data-ds-node="surface"), which end-to-end tests of an application can use too.
Examples on the virtual clock run there too (D-062): the test gives the generated motion code
a clock of its own and turns Angular’s animations on; every animation the components start is
paused when it starts, and an advance step moves time through the ends of the running
animations in order, so advance = ms(160) moves exactly 160 ms, a transition or
presence expectation reads the phase and the eased progress, and transition_end arrives
when the motion it completes has finished.
Of the 407 examples of the 35 validated packages, 390 run in the browser, 117 of them
examples a model test cannot run (focus, dialogs, keys, geometry, motion). The 9 left to
dsfc test need Tab around a modal dialog, which the browser takes to its own controls
before it wraps (3), a press on a focus stop, which the browser focuses and the reference
semantics do not (4), the absence of a repetition of a virtualized list, which a target may
keep, and a live text, announced through a region of its own. Each example’s realization is
listed in dsf-build.json (example.model, example.dom, or example.<reason>). The
browser tests found eleven defects of the generated components, now fixed, among them double
events from an instance event with two handlers, an option press that took focus from its
combobox field, slot content losing its state when an adaptive layout moved it, and nodes
that entered at their component’s first render.
Motion
Presence transitions (enter, exit) are Web Animations run from Angular’s
animate.enter and animate.leave. A shared transition between two components is a view
transition (document.startViewTransition): one end’s snapshot morphs into the other’s
bounds and crossfades into it in the declared duration and easing, the page’s snapshot
crossfading with it; reversed mid-way, it starts from what it shows; transition_end is
delivered when it has finished. With reduced motion the declared crossfade plays. Without a
source, or in a browser without view transitions, the declared fallback plays, and the
capability report lists both (motion.shared_element, motion.shared_element.runtime).
The motion code runs on an injectable clock (DS_CLOCK), the platform’s by default.
Options
| Option | Default | Meaning |
|---|---|---|
prefix |
ds |
Selector and class prefix (ds-button, DsButton). Lowercase letters and digits. |
Validation
tools/validate-angular.sh creates a fresh workspace with Angular CLI 22.3 (run with bun),
builds the generated library with ng build and runs ng test in headless Chromium, which
Playwright installs. All 14 scenarios, both example ports and the 19 target
fixtures build and pass.