@uni-design-system/uni-core 10.1.0 → 10.2.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/CHANGELOG.md +89 -0
- package/dist/cjs/index.cjs +63 -18
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +63 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/types/concepts/component/component.types.d.ts +18 -1
- package/dist/types/concepts/component/component.types.d.ts.map +1 -1
- package/dist/types/concepts/index.d.ts +1 -0
- package/dist/types/concepts/index.d.ts.map +1 -1
- package/dist/types/concepts/theme/theme.types.d.ts +3 -1
- package/dist/types/concepts/theme/theme.types.d.ts.map +1 -1
- package/dist/types/concepts/theme/theme.validation.d.ts.map +1 -1
- package/dist/types/concepts/theme/themes/base.theme.d.ts.map +1 -1
- package/dist/types/concepts/variant/index.d.ts +2 -0
- package/dist/types/concepts/variant/index.d.ts.map +1 -0
- package/dist/types/concepts/variant/variant.types.d.ts +50 -0
- package/dist/types/concepts/variant/variant.types.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
# @uni-design-system/uni-core
|
|
2
2
|
|
|
3
|
+
## 10.2.1
|
|
4
|
+
|
|
5
|
+
## 10.2.0
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- [`1cd0140`](https://github.com/uni-design-system/uni/commit/1cd0140d2e6a4c753f48fb46418ba08769979263) Thanks [@gaenglish](https://github.com/gaenglish)! - Checkbox, radio and toggle take their accent from the theme, not from the
|
|
10
|
+
variant's name.
|
|
11
|
+
|
|
12
|
+
**Twelve sites across the three controls resolved a variant name as a colour
|
|
13
|
+
token.** That held together only because every name in the closed union happened
|
|
14
|
+
to also be a colour. Under an open registry the coincidence ends by design:
|
|
15
|
+
`<uni-checkbox variant="destructive">` would look up `colors['destructive']`,
|
|
16
|
+
miss, and **silently render primary** — a wrong-coloured control with no error,
|
|
17
|
+
no warning, and nothing to grep for.
|
|
18
|
+
|
|
19
|
+
Checkbox was worse than it looked. Alongside five `getThemeColor` calls it had
|
|
20
|
+
two more through a second resolver that built `on-${variant}`, so an
|
|
21
|
+
unregistered intent also missed its paired content colour and fell back to
|
|
22
|
+
`on-primary` — the tick would have stayed light on a dark fill even after the
|
|
23
|
+
box was fixed.
|
|
24
|
+
|
|
25
|
+
The theme now says which colour draws each intent, through a new
|
|
26
|
+
`variantOptions` map on `ComponentTheme`:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
checkbox: {
|
|
30
|
+
variantOptions: {
|
|
31
|
+
primary: { accent: 'primary' },
|
|
32
|
+
warn: { accent: 'warn' },
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`variantOptions` is per-variant data a component **reads**, as against `variants`,
|
|
38
|
+
which is CSS that gets **applied**. The distinction earns its place here: a
|
|
39
|
+
checkbox's accent lands on the box outline, the checked and indeterminate fills,
|
|
40
|
+
the tick and the focus ring at once, and expressing that as CSS would have meant
|
|
41
|
+
the theme naming `.checkbox-check` and `.radio-inner` — promoting private DOM to
|
|
42
|
+
public theme contract.
|
|
43
|
+
|
|
44
|
+
All three controls gain a `checkedColor` input as the per-instance override,
|
|
45
|
+
matching the one `uni-toggle` already had; its resolution order is now input →
|
|
46
|
+
the variant's themed accent → theme option. The base theme defines the same
|
|
47
|
+
seven intents `button` and `iconButton` do, so the library is consistent about
|
|
48
|
+
which exist by default, and `getThemeColor` — triplicated byte-for-byte across
|
|
49
|
+
the three components, with a silent fallback to primary — is gone.
|
|
50
|
+
|
|
51
|
+
Rendering is unchanged for anything that does not set `variant`: the default
|
|
52
|
+
still resolves to the primary accent and its paired on-colour.
|
|
53
|
+
|
|
54
|
+
- [`1cd0140`](https://github.com/uni-design-system/uni/commit/1cd0140d2e6a4c753f48fb46418ba08769979263) Thanks [@gaenglish](https://github.com/gaenglish)! - `Variant` is an open registry: a design system can define its own intents.
|
|
55
|
+
|
|
56
|
+
A variant names _what an action means_, and it is the theme's job to describe
|
|
57
|
+
how that intent is drawn. So the set of names was never Uni's to fix — an app
|
|
58
|
+
whose actions are `destructive`, `subtle` and `info` had to translate them onto
|
|
59
|
+
twelve names chosen elsewhere. `Variant` is now `keyof UniVariantRegistry`,
|
|
60
|
+
extended by declaration merging:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
declare module '@uni-design-system/uni-core' {
|
|
64
|
+
interface UniVariantRegistry {
|
|
65
|
+
destructive: true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`variant="destructive"` then compiles wherever a variant is accepted, and
|
|
71
|
+
`variant="destructve"` still does not — which the library's other open-token
|
|
72
|
+
idiom, `Named | (string & {})`, cannot give you, and which would also have
|
|
73
|
+
collapsed the theme's `variants` map keys to `string`.
|
|
74
|
+
|
|
75
|
+
Only the type was ever closed: theme validation checks the _shape_ of a
|
|
76
|
+
`variants` block and never its key names, so a custom variant already reached
|
|
77
|
+
`componentStyle` untouched at runtime.
|
|
78
|
+
|
|
79
|
+
**The registry extends; it cannot replace.** Declaration merging has no way to
|
|
80
|
+
remove a member, so Uni's twelve names stay legal in a consuming app; enforcing
|
|
81
|
+
a house set is a lint concern rather than a type. Two names are reserved and
|
|
82
|
+
documented as always present: `primary`, which every component inherits as its
|
|
83
|
+
default, and `disabled`, which the disabled state resolves to.
|
|
84
|
+
|
|
85
|
+
**An unthemed variant now says so.** With a closed union this was nearly
|
|
86
|
+
impossible; with an open set it is the ordinary state of a work in progress —
|
|
87
|
+
a variant registered and used before its theme block exists. The theme service
|
|
88
|
+
warns once per component and variant in dev, naming what the theme does define,
|
|
89
|
+
mirroring what it already did for an unknown spacing token. Components that
|
|
90
|
+
theme no variants at all stay silent, since a missing key there is not a gap.
|
|
91
|
+
|
|
3
92
|
## 10.1.0
|
|
4
93
|
|
|
5
94
|
### Minor Changes
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1057,6 +1057,30 @@ var buildBorders = (c) => ({
|
|
|
1057
1057
|
* surface and draws the edge — so every role stays consistent and a theme can
|
|
1058
1058
|
* still override any single cell.
|
|
1059
1059
|
*/
|
|
1060
|
+
/**
|
|
1061
|
+
* Accent roles for the selection controls (checkbox, radio, toggle).
|
|
1062
|
+
*
|
|
1063
|
+
* A variant names the intent; this says which colour token draws it, and the
|
|
1064
|
+
* component decides where it lands — the box fill, the ring, the dot, the
|
|
1065
|
+
* track, the focus ring. Keeping it as a role rather than a `variants`
|
|
1066
|
+
* StyleExpression is what stops interior class names like `.checkbox-check`
|
|
1067
|
+
* becoming public theme contract.
|
|
1068
|
+
*
|
|
1069
|
+
* The same seven names `button` and `iconButton` theme, so the library is
|
|
1070
|
+
* consistent about which intents exist by default.
|
|
1071
|
+
*/
|
|
1072
|
+
var SELECTION_ACCENTS = {
|
|
1073
|
+
primary: { accent: "primary" },
|
|
1074
|
+
secondary: { accent: "secondary" },
|
|
1075
|
+
tertiary: { accent: "tertiary" },
|
|
1076
|
+
warn: { accent: "warn" },
|
|
1077
|
+
success: { accent: "success" },
|
|
1078
|
+
disabled: { accent: "disabled" },
|
|
1079
|
+
ghost: {
|
|
1080
|
+
accent: "ghost",
|
|
1081
|
+
onAccent: "on-primary"
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1060
1084
|
var tagVariant = (c, role) => ({ [role]: {
|
|
1061
1085
|
backgroundColor: c[`${role}-container`],
|
|
1062
1086
|
color: c[`on-${role}-container`],
|
|
@@ -1193,18 +1217,24 @@ var buildComponents = (c) => ({
|
|
|
1193
1217
|
activeColor: "primary-container",
|
|
1194
1218
|
maxSuggestions: 8
|
|
1195
1219
|
} },
|
|
1196
|
-
checkbox: {
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1220
|
+
checkbox: {
|
|
1221
|
+
options: {
|
|
1222
|
+
size: 20,
|
|
1223
|
+
boxColor: "surface",
|
|
1224
|
+
borderRadius: 2,
|
|
1225
|
+
focusRingGap: 2
|
|
1226
|
+
},
|
|
1227
|
+
variantOptions: SELECTION_ACCENTS
|
|
1228
|
+
},
|
|
1229
|
+
radio: {
|
|
1230
|
+
options: {
|
|
1231
|
+
size: 20,
|
|
1232
|
+
ringColor: "outline",
|
|
1233
|
+
fillColor: "surface",
|
|
1234
|
+
motion: "control"
|
|
1235
|
+
},
|
|
1236
|
+
variantOptions: SELECTION_ACCENTS
|
|
1237
|
+
},
|
|
1208
1238
|
dialog: { options: {
|
|
1209
1239
|
borderRadius: "lg",
|
|
1210
1240
|
color: "primary-surface",
|
|
@@ -1266,13 +1296,16 @@ var buildComponents = (c) => ({
|
|
|
1266
1296
|
activeSymbol: "check",
|
|
1267
1297
|
motion: "control"
|
|
1268
1298
|
},
|
|
1269
|
-
variants: {
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1299
|
+
variants: {
|
|
1300
|
+
primary: {},
|
|
1301
|
+
warn: {
|
|
1302
|
+
color: c.warn,
|
|
1303
|
+
[HOVER_OR_KEYBOARD_FOCUS]: {
|
|
1304
|
+
backgroundColor: c["warn-container"],
|
|
1305
|
+
color: c["on-warn-container"]
|
|
1306
|
+
}
|
|
1274
1307
|
}
|
|
1275
|
-
}
|
|
1308
|
+
}
|
|
1276
1309
|
},
|
|
1277
1310
|
popover: { options: {
|
|
1278
1311
|
color: "primary-surface",
|
|
@@ -1821,6 +1854,7 @@ var buildComponents = (c) => ({
|
|
|
1821
1854
|
knobColor: "surface",
|
|
1822
1855
|
motion: "control"
|
|
1823
1856
|
},
|
|
1857
|
+
variantOptions: SELECTION_ACCENTS,
|
|
1824
1858
|
sizes: {
|
|
1825
1859
|
sm: {
|
|
1826
1860
|
width: 28,
|
|
@@ -2643,6 +2677,17 @@ var checkComponents = (value, issues) => {
|
|
|
2643
2677
|
}
|
|
2644
2678
|
for (const [key, style] of Object.entries(styles)) if (style !== void 0) checkStyleExpression(style, `components.${name}.${section}.${key}`, issues);
|
|
2645
2679
|
}
|
|
2680
|
+
const variantOptions = entry["variantOptions"];
|
|
2681
|
+
if (variantOptions !== void 0) {
|
|
2682
|
+
if (!isRecord(variantOptions)) issues.push({
|
|
2683
|
+
path: `components.${name}.variantOptions`,
|
|
2684
|
+
message: "must be an object"
|
|
2685
|
+
});
|
|
2686
|
+
else for (const [key, roles] of Object.entries(variantOptions)) if (roles !== void 0 && !isRecord(roles)) issues.push({
|
|
2687
|
+
path: `components.${name}.variantOptions.${key}`,
|
|
2688
|
+
message: "must be an object"
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2646
2691
|
if (entry["options"] !== void 0 && !isRecord(entry["options"])) issues.push({
|
|
2647
2692
|
path: `components.${name}.options`,
|
|
2648
2693
|
message: "must be an object"
|