@sentropic/design-system-tokens 0.9.0 → 0.10.1
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/dist/anatomy.d.ts +211 -0
- package/dist/anatomy.d.ts.map +1 -0
- package/dist/anatomy.js +17 -0
- package/dist/anatomy.js.map +1 -0
- package/dist/component.d.ts +512 -141
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +574 -195
- package/dist/component.js.map +1 -1
- package/dist/css.d.ts.map +1 -1
- package/dist/css.js +21 -4
- package/dist/css.js.map +1 -1
- package/dist/foundation.d.ts +107 -1
- package/dist/foundation.d.ts.map +1 -1
- package/dist/foundation.js +132 -0
- package/dist/foundation.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/semantic.d.ts +2 -0
- package/dist/semantic.d.ts.map +1 -1
- package/dist/semantic.js +4 -0
- package/dist/semantic.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,211 @@
|
|
|
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.5.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
|
+
* v1.3.0 (additive, F3/F4):
|
|
61
|
+
* - `radiusTop` — per-field TOP-corner radius, resolved CSS-ready. The base
|
|
62
|
+
* `shape.radius` is a single uniform value; a filled-underline field can
|
|
63
|
+
* round only its TOP corners (DSFR « Champ de saisie » = 4px top / 0 bottom)
|
|
64
|
+
* while the bottom corners keep `shape.radius`. Defaults to the theme's own
|
|
65
|
+
* `shape.radius` so a boxed field stays uniform → no Sent Tech regression.
|
|
66
|
+
* - `underline` — the bottom rule rendered as a `box-shadow inset` instead of a
|
|
67
|
+
* `border-bottom` (the real DSFR/Carbon technique). `none` for an outline
|
|
68
|
+
* field (its rule is a real 4-side border); `inset 0 -<w> 0 0 <color>` for a
|
|
69
|
+
* filled-underline field, whose `borderBottom` then becomes `none`.
|
|
70
|
+
*/
|
|
71
|
+
export type FieldStyle = "outline" | "filled-underline";
|
|
72
|
+
export interface FieldAnatomy {
|
|
73
|
+
[key: string]: CssValue;
|
|
74
|
+
style: FieldStyle;
|
|
75
|
+
/** Field background fill (`surface.default` for outline; the fill tone otherwise). */
|
|
76
|
+
fillBg: CssValue;
|
|
77
|
+
/** Resolved per-side border shorthands (`<width> <style> <color>` or `none`). */
|
|
78
|
+
borderTop: CssValue;
|
|
79
|
+
borderRight: CssValue;
|
|
80
|
+
borderBottom: CssValue;
|
|
81
|
+
borderLeft: CssValue;
|
|
82
|
+
/**
|
|
83
|
+
* TOP-corner radius (v1.3.0). Defaults to the theme's `shape.radius` so a
|
|
84
|
+
* boxed field is unchanged; a filled-underline field may round only its top
|
|
85
|
+
* (DSFR = 4px) while the bottom corners keep `shape.radius`.
|
|
86
|
+
*/
|
|
87
|
+
radiusTop: CssValue;
|
|
88
|
+
/**
|
|
89
|
+
* Bottom-rule box-shadow (v1.3.0). `none` for an outline field (it draws a
|
|
90
|
+
* real border); `inset 0 -<width> 0 0 <color>` for a filled-underline field,
|
|
91
|
+
* which renders its bottom rule via this shadow instead of `border-bottom`.
|
|
92
|
+
*/
|
|
93
|
+
underline: CssValue;
|
|
94
|
+
/**
|
|
95
|
+
* Focus box-shadow for the field (v1.3.0), composed so the resting underline
|
|
96
|
+
* is never lost incoherently. An `outline`-strategy theme (DSFR) keeps the
|
|
97
|
+
* underline as its box-shadow at focus (its ring is a separate native
|
|
98
|
+
* `outline`); an `inset`/`ring`-strategy theme composes its focus ring AND the
|
|
99
|
+
* underline into one valid box-shadow list. An outline field with no underline
|
|
100
|
+
* resolves to the theme's plain focus box-shadow.
|
|
101
|
+
*/
|
|
102
|
+
focusShadow: CssValue;
|
|
103
|
+
/**
|
|
104
|
+
* Native `<select>` rendering primitive (v1.4.0, F5/F9). A native `<select>`
|
|
105
|
+
* with `appearance: auto` has its `line-height` FORCED to `normal` by the
|
|
106
|
+
* browser UA (proven on Chrome); only `appearance: none` lets the author
|
|
107
|
+
* `line-height` take effect (the real DSFR/Carbon selects use `appearance:
|
|
108
|
+
* none` + a custom chevron, which is why they render 24px/18px). Defaults to
|
|
109
|
+
* `auto` so the base Sent Tech select keeps its NATIVE arrow + render
|
|
110
|
+
* (unchanged); a filled-underline theme sets `none` so the anatomy line-height
|
|
111
|
+
* applies and the chevron is drawn by `selectChevron`.
|
|
112
|
+
*/
|
|
113
|
+
selectAppearance: CssValue;
|
|
114
|
+
/**
|
|
115
|
+
* Custom chevron background for the `<select>` when `selectAppearance` is
|
|
116
|
+
* `none` (the native arrow is then suppressed). `none` for the base (native
|
|
117
|
+
* arrow kept); a `url(...) no-repeat ...` background for a filled-underline
|
|
118
|
+
* theme. Applied as the select `background-image`/position so the arrow
|
|
119
|
+
* survives `appearance: none`.
|
|
120
|
+
*/
|
|
121
|
+
selectChevron: CssValue;
|
|
122
|
+
/**
|
|
123
|
+
* Right padding of the `<select>` reserving room for the chevron (F9). Defaults
|
|
124
|
+
* to the prior `2rem` arrow gap (base unchanged); DSFR reserves 40px, Carbon
|
|
125
|
+
* 48px to match the real `.fr-select` / `.bx--select-input` chevron gutter.
|
|
126
|
+
*/
|
|
127
|
+
selectPaddingRight: CssValue;
|
|
128
|
+
}
|
|
129
|
+
/** Density = the geometric envelope of a control for one size. */
|
|
130
|
+
export interface DensityAnatomy {
|
|
131
|
+
[key: string]: CssValue | undefined;
|
|
132
|
+
controlHeight: CssValue;
|
|
133
|
+
paddingBlock: CssValue;
|
|
134
|
+
paddingInline: CssValue;
|
|
135
|
+
gap: CssValue;
|
|
136
|
+
minWidth: CssValue;
|
|
137
|
+
/**
|
|
138
|
+
* Font size for this size token (v1.1.0). Density is already per-size
|
|
139
|
+
* (sm/md/lg), so the label scale rides with the control geometry instead of
|
|
140
|
+
* a single typography size + per-size CSS escapes. `md` mirrors the role
|
|
141
|
+
* typography size; sm/lg carry the theme's smaller/larger label sizes.
|
|
142
|
+
*/
|
|
143
|
+
fontSize?: CssValue;
|
|
144
|
+
}
|
|
145
|
+
/** Typography by role (self-contained, theme-portable). */
|
|
146
|
+
export interface TypographyAnatomy {
|
|
147
|
+
[key: string]: CssValue | undefined;
|
|
148
|
+
family: CssValue;
|
|
149
|
+
size: CssValue;
|
|
150
|
+
weight: CssValue;
|
|
151
|
+
lineHeight: CssValue;
|
|
152
|
+
letterSpacing: CssValue;
|
|
153
|
+
textTransform: CssValue;
|
|
154
|
+
textDecoration: CssValue;
|
|
155
|
+
decorationThickness: CssValue;
|
|
156
|
+
decorationOffset: CssValue;
|
|
157
|
+
/**
|
|
158
|
+
* Decoration line in the hover state (v1.1.0). Source for
|
|
159
|
+
* `states.hover.decoration` on the link anatomy: DSFR/base stay `underline`
|
|
160
|
+
* (no-op), Carbon goes from `none` at rest to `underline` on hover.
|
|
161
|
+
*/
|
|
162
|
+
textDecorationHover?: CssValue;
|
|
163
|
+
}
|
|
164
|
+
export interface IconAnatomy {
|
|
165
|
+
[key: string]: CssValue;
|
|
166
|
+
size: CssValue;
|
|
167
|
+
gap: CssValue;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Per-state delta. Every field is optional: a state only overrides what it
|
|
171
|
+
* actually changes. `transform` covers micro-interaction lifts; `opacity`
|
|
172
|
+
* covers disabled dimming; `decoration` covers underline toggles (links).
|
|
173
|
+
*/
|
|
174
|
+
export interface StateDelta {
|
|
175
|
+
[key: string]: CssValue | undefined;
|
|
176
|
+
bg?: CssValue;
|
|
177
|
+
border?: CssValue;
|
|
178
|
+
text?: CssValue;
|
|
179
|
+
decoration?: CssValue;
|
|
180
|
+
transform?: CssValue;
|
|
181
|
+
opacity?: CssValue;
|
|
182
|
+
}
|
|
183
|
+
export interface StatesAnatomy {
|
|
184
|
+
[key: string]: StateDelta | undefined;
|
|
185
|
+
hover?: StateDelta;
|
|
186
|
+
active?: StateDelta;
|
|
187
|
+
focus?: StateDelta;
|
|
188
|
+
disabled?: StateDelta;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The anatomy of one component. `shape`, `density`, `typography`, `focus`,
|
|
192
|
+
* `icon` and `states` describe the theme-portable form; the remaining keys are
|
|
193
|
+
* the color *roles* the component paints with. Color roles stay loosely keyed
|
|
194
|
+
* (each component owns its own role names) but the anatomy block is strict.
|
|
195
|
+
*/
|
|
196
|
+
export interface ComponentAnatomy {
|
|
197
|
+
[key: string]: TokenTree | undefined;
|
|
198
|
+
shape: ShapeAnatomy;
|
|
199
|
+
density?: {
|
|
200
|
+
sm?: Partial<DensityAnatomy>;
|
|
201
|
+
md?: Partial<DensityAnatomy>;
|
|
202
|
+
lg?: Partial<DensityAnatomy>;
|
|
203
|
+
};
|
|
204
|
+
typography: TypographyAnatomy;
|
|
205
|
+
focus: FocusAnatomy;
|
|
206
|
+
icon?: IconAnatomy;
|
|
207
|
+
states?: StatesAnatomy;
|
|
208
|
+
/** Field style (v1.2.0) — only meaningful on the input/control anatomy. */
|
|
209
|
+
field?: FieldAnatomy;
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=anatomy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anatomy.d.ts","sourceRoot":"","sources":["../src/anatomy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEpE,MAAM,WAAW,YAAY;IAI3B,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,gEAAgE;IAChE,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,gCAAgC;AAChC,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,MAAM,EAAE,QAAQ,CAAC;IACjB,WAAW,EAAE,QAAQ,CAAC;IACtB,WAAW,EAAE,QAAQ,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,sFAAsF;IACtF,MAAM,EAAE,QAAQ,CAAC;IACjB,iFAAiF;I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
|
|
|
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.5.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"}
|