@sentropic/design-system-tokens 0.9.0 → 0.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,154 @@
1
+ /**
2
+ * ComponentAnatomy — typed, versioned contract for theme-portable component
3
+ * anatomy (Phase 1 pilot, cf. spec §3.3).
4
+ *
5
+ * This is the *schema* (livrable n°1). It is deliberately a strict TypeScript
6
+ * type — NOT a free `TokenTree` — so that a theme cannot silently drift away
7
+ * from the shape a component reads. Every leaf is a CSS-ready string (a value
8
+ * or a `var(--st-*)` reference). When `createComponent` builds the anatomy from
9
+ * a theme's `semantic` + `foundation`, the result is checked against these
10
+ * types at compile time.
11
+ *
12
+ * Versioning: bump ANATOMY_VERSION (semver-ish) when the *shape* changes so the
13
+ * matrix / consumers can detect a schema move. Phase 2 rollout MUST NOT begin
14
+ * while this number is still moving (cf. spec §5).
15
+ */
16
+ import type { TokenTree } from "./foundation.js";
17
+ export declare const ANATOMY_VERSION = "1.2.0";
18
+ /** A CSS-ready value: a literal or a `var(--st-*)` reference. */
19
+ export type CssValue = string;
20
+ /**
21
+ * Focus strategy = first-class primitive. `strategy` selects which CSS
22
+ * technique a shared mixin renders; the rest parametrise it.
23
+ * - `outline`: native `outline` + `outline-offset` (DSFR-like, offset ring)
24
+ * - `ring`: `box-shadow` ring around the box (base default)
25
+ * - `inset`: `box-shadow inset` drawn *inside* the box (Carbon)
26
+ * - `double`: two-tone outline (outer + inner), DSFR accessibility ring
27
+ */
28
+ export type FocusStrategy = "outline" | "ring" | "inset" | "double";
29
+ export interface FocusAnatomy {
30
+ [key: string]: CssValue;
31
+ strategy: FocusStrategy;
32
+ width: CssValue;
33
+ offset: CssValue;
34
+ color: CssValue;
35
+ /** Inset distance used by the `inset` / `double` strategies. */
36
+ inset: CssValue;
37
+ }
38
+ /** Shape = corners + stroke. */
39
+ export interface ShapeAnatomy {
40
+ [key: string]: CssValue;
41
+ radius: CssValue;
42
+ borderWidth: CssValue;
43
+ borderStyle: CssValue;
44
+ }
45
+ /**
46
+ * Field style = first-class primitive (v1.2.0). Distinguishes a *boxed* input
47
+ * (uniform stroke on all four sides, base Sent Tech) from a *filled-underline*
48
+ * input (filled background + a single bottom rule, no top/right/left stroke) —
49
+ * the real signature of DSFR « Champ de saisie » and Carbon « Text input ».
50
+ * Before this primitive, the input anatomy only carried a uniform border, so a
51
+ * filled-underline theme could not be rendered faithfully (it looked boxed).
52
+ *
53
+ * - `outline`: 4 equal borders (`border.subtle`), `fillBg = surface.default`.
54
+ * - `filled-underline`: filled `fillBg`, top/right/left = none, only `borderBottom`.
55
+ *
56
+ * The per-side borders are RESOLVED here (already combining width + style +
57
+ * color into a CSS-ready shorthand) so a component applies them verbatim with
58
+ * no per-theme branching.
59
+ */
60
+ export type FieldStyle = "outline" | "filled-underline";
61
+ export interface FieldAnatomy {
62
+ [key: string]: CssValue;
63
+ style: FieldStyle;
64
+ /** Field background fill (`surface.default` for outline; the fill tone otherwise). */
65
+ fillBg: CssValue;
66
+ /** Resolved per-side border shorthands (`<width> <style> <color>` or `none`). */
67
+ borderTop: CssValue;
68
+ borderRight: CssValue;
69
+ borderBottom: CssValue;
70
+ borderLeft: CssValue;
71
+ }
72
+ /** Density = the geometric envelope of a control for one size. */
73
+ export interface DensityAnatomy {
74
+ [key: string]: CssValue | undefined;
75
+ controlHeight: CssValue;
76
+ paddingBlock: CssValue;
77
+ paddingInline: CssValue;
78
+ gap: CssValue;
79
+ minWidth: CssValue;
80
+ /**
81
+ * Font size for this size token (v1.1.0). Density is already per-size
82
+ * (sm/md/lg), so the label scale rides with the control geometry instead of
83
+ * a single typography size + per-size CSS escapes. `md` mirrors the role
84
+ * typography size; sm/lg carry the theme's smaller/larger label sizes.
85
+ */
86
+ fontSize?: CssValue;
87
+ }
88
+ /** Typography by role (self-contained, theme-portable). */
89
+ export interface TypographyAnatomy {
90
+ [key: string]: CssValue | undefined;
91
+ family: CssValue;
92
+ size: CssValue;
93
+ weight: CssValue;
94
+ lineHeight: CssValue;
95
+ letterSpacing: CssValue;
96
+ textTransform: CssValue;
97
+ textDecoration: CssValue;
98
+ decorationThickness: CssValue;
99
+ decorationOffset: CssValue;
100
+ /**
101
+ * Decoration line in the hover state (v1.1.0). Source for
102
+ * `states.hover.decoration` on the link anatomy: DSFR/base stay `underline`
103
+ * (no-op), Carbon goes from `none` at rest to `underline` on hover.
104
+ */
105
+ textDecorationHover?: CssValue;
106
+ }
107
+ export interface IconAnatomy {
108
+ [key: string]: CssValue;
109
+ size: CssValue;
110
+ gap: CssValue;
111
+ }
112
+ /**
113
+ * Per-state delta. Every field is optional: a state only overrides what it
114
+ * actually changes. `transform` covers micro-interaction lifts; `opacity`
115
+ * covers disabled dimming; `decoration` covers underline toggles (links).
116
+ */
117
+ export interface StateDelta {
118
+ [key: string]: CssValue | undefined;
119
+ bg?: CssValue;
120
+ border?: CssValue;
121
+ text?: CssValue;
122
+ decoration?: CssValue;
123
+ transform?: CssValue;
124
+ opacity?: CssValue;
125
+ }
126
+ export interface StatesAnatomy {
127
+ [key: string]: StateDelta | undefined;
128
+ hover?: StateDelta;
129
+ active?: StateDelta;
130
+ focus?: StateDelta;
131
+ disabled?: StateDelta;
132
+ }
133
+ /**
134
+ * The anatomy of one component. `shape`, `density`, `typography`, `focus`,
135
+ * `icon` and `states` describe the theme-portable form; the remaining keys are
136
+ * the color *roles* the component paints with. Color roles stay loosely keyed
137
+ * (each component owns its own role names) but the anatomy block is strict.
138
+ */
139
+ export interface ComponentAnatomy {
140
+ [key: string]: TokenTree | undefined;
141
+ shape: ShapeAnatomy;
142
+ density?: {
143
+ sm?: Partial<DensityAnatomy>;
144
+ md?: Partial<DensityAnatomy>;
145
+ lg?: Partial<DensityAnatomy>;
146
+ };
147
+ typography: TypographyAnatomy;
148
+ focus: FocusAnatomy;
149
+ icon?: IconAnatomy;
150
+ states?: StatesAnatomy;
151
+ /** Field style (v1.2.0) — only meaningful on the input/control anatomy. */
152
+ field?: FieldA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pB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACtC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE;QACR,EAAE,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;QAC7B,EAAE,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;QAC7B,EAAE,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;KAC9B,CAAC;IACF,UAAU,EAAE,iBAAiB,CAAC;IAC9B,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ComponentAnatomy — typed, versioned contract for theme-portable component
3
+ * anatomy (Phase 1 pilot, cf. spec §3.3).
4
+ *
5
+ * This is the *schema* (livrable n°1). It is deliberately a strict TypeScript
6
+ * type — NOT a free `TokenTree` — so that a theme cannot silently drift away
7
+ * from the shape a component reads. Every leaf is a CSS-ready string (a value
8
+ * or a `var(--st-*)` reference). When `createComponent` builds the anatomy from
9
+ * a theme's `semantic` + `foundation`, the result is checked against these
10
+ * types at compile time.
11
+ *
12
+ * Versioning: bump ANATOMY_VERSION (semver-ish) when the *shape* changes so the
13
+ * matrix / consumers can detect a schema move. Phase 2 rollout MUST NOT begin
14
+ * while this number is still moving (cf. spec §5).
15
+ */
16
+ export const ANATOMY_VERSION = "1.2.0";
17
+ //# sourceMappingURL=anatomy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anatomy.js","sourceRoot":"","sources":["../src/anatomy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC"}