@vllnt/ui-core 0.1.0-canary.100.shabd406b0b1cdb
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 +108 -0
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/component-contracts.json +208 -0
- package/component-contracts.schema.json +136 -0
- package/dist/chunk-25M4DIJU.js +570 -0
- package/dist/index.d.ts +1857 -0
- package/dist/index.js +1973 -0
- package/dist/theme-ChrZM15o.d.ts +612 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +10 -0
- package/llms.txt +14 -0
- package/package.json +79 -0
- package/tokens.json +834 -0
- package/tokens.schema.json +435 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@vllnt/ui-core` are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
### Breaking
|
|
8
|
+
|
|
9
|
+
- `component-contracts.json` and `componentContracts` use the new contract
|
|
10
|
+
format (version 0.2.0): each component has a `name`, `description`,
|
|
11
|
+
`platforms` and `props`, plus optional `states`, `accessibility` and
|
|
12
|
+
`parts`. Variants, sizes, levels, tones and weights moved to enum props, so
|
|
13
|
+
`components.button.variants` is now `components.button.props.variant.values`,
|
|
14
|
+
and Card `parts` is an object keyed by part name. The derived types
|
|
15
|
+
(`ButtonVariant`, `ButtonSize`, `BadgeVariant`, `CardPart`, `HeadingLevel`,
|
|
16
|
+
`TextSize`, `TextTone`, `TextWeight`) keep their names and values.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- `@vllnt/ui-core/theme` subpath (issue #993). It exports `createNativeTheme`,
|
|
21
|
+
`lightTheme`, `darkTheme` and their types, and loads only the native
|
|
22
|
+
tokens, which now live in their own generated module. The root entry is
|
|
23
|
+
unchanged and keeps every export with the same values.
|
|
24
|
+
|
|
25
|
+
- Spatial tokens (issue #846). `designTokens` has a `border` and a `surface`
|
|
26
|
+
on each depth step `z-0` to `z-4` (roles base, raised, overlay, floating,
|
|
27
|
+
modal), the colour `color.border-strong`, the target sizes
|
|
28
|
+
`size.target.pointer`, `touch` and `spatial` (24, 44, 60), and
|
|
29
|
+
`motion.press` and `motion.raise`, and a `deprecated` map of token path to
|
|
30
|
+
deprecation note. `size.target.min` keeps its value (2.75rem, 44) and equals
|
|
31
|
+
`size.target.touch`. Existing keys keep their shape. `nativeTokens` gains
|
|
32
|
+
`depth.light` / `depth.dark` (border and surface colours, offset in points,
|
|
33
|
+
the shadow as React Native shadow props with an Android `elevation`, glass
|
|
34
|
+
tint), `target` in points (`min`, `pointer`, `touch`, `spatial`) and
|
|
35
|
+
`motion.press` / `motion.raise` (`duration` in ms and `easing`).
|
|
36
|
+
|
|
37
|
+
- The Badge contract lists every Badge prop: `border`, `dot`, `size` and
|
|
38
|
+
`tone` join `variant`, with the values both renderers already take, and
|
|
39
|
+
web lists the span attributes it forwards. `BadgeVariant` is unchanged.
|
|
40
|
+
|
|
41
|
+
- The component contract format: `ComponentContract`, `ComponentContracts`
|
|
42
|
+
and its parts (`ContractProperty`, `ContractPlatform`, `ContractAccessibility`,
|
|
43
|
+
and so on), documented in the README and described by
|
|
44
|
+
`component-contracts.schema.json`.
|
|
45
|
+
- `validateComponentContracts(value)`: checks a parsed contracts file and
|
|
46
|
+
returns every problem as a sentence, with no dependency. Beyond the JSON
|
|
47
|
+
Schema, it rejects an enum default outside its values, and a platform prop
|
|
48
|
+
that restates a shared prop but changes its type, drops a shared value or
|
|
49
|
+
changes its default.
|
|
50
|
+
- `ContractDrift`, `ContractPropsFor`, `ContractPlatformValue` and
|
|
51
|
+
`ContractPropertyValue`: types a renderer uses in a type test to prove its
|
|
52
|
+
component props match a contract. A platform's enum values are its own plus
|
|
53
|
+
the shared ones.
|
|
54
|
+
- The full Button contract: purpose, shared props, web-only (`asChild`,
|
|
55
|
+
`icon-lg`, `unstyled`) and native-only (`textStyle`, text `children`)
|
|
56
|
+
props, states, and the required accessible name.
|
|
57
|
+
|
|
58
|
+
- `llms.txt` in the tarball: an index of the README, tokens, contracts and
|
|
59
|
+
changelog for agents reading `node_modules/@vllnt/ui-core/`. Written at pack time.
|
|
60
|
+
|
|
61
|
+
- `nativeTokens.glass`: the glass material per color scheme, generated from
|
|
62
|
+
`packages/design/tokens.json`. It holds the tint steps, hairline,
|
|
63
|
+
`mutedForeground`, `input` and `foreground` text roles, blur radii and the
|
|
64
|
+
`glass` and `glassFloating` shadows as React Native shadow props with an
|
|
65
|
+
Android `elevation`. `glass.solid` is the same surface with glass off
|
|
66
|
+
(opaque Card color, no blur). `NativeTheme` carries it as `theme.glass`, and
|
|
67
|
+
`NativeGlassTokens` and `NativeShadow` are exported.
|
|
68
|
+
|
|
69
|
+
### Deprecated
|
|
70
|
+
|
|
71
|
+
- `designTokens.elevation` (issue #846): the steps keep their string values;
|
|
72
|
+
`designTokens.deprecated["elevation.<step>"]` says each is deprecated. Read
|
|
73
|
+
`shadow.raised` in place of `elevation.sm`, and `shadow.overlay` in place of
|
|
74
|
+
`elevation.md` and `elevation.lg`. It stays for every 0.x release and leaves
|
|
75
|
+
no earlier than the next major.
|
|
76
|
+
|
|
77
|
+
## [0.1.0] - 2026-11-20
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- Initial platform-neutral token, theme, platform metadata, and portable component contracts.
|
|
82
|
+
|
|
83
|
+
- `productThemes`: the Maia and PaaS themes (colors per mode, fonts, type
|
|
84
|
+
scale, radius, default mode), generated from `packages/design/tokens.json`.
|
|
85
|
+
- `tamaguiTokens` and `tamaguiThemes`: plain objects in the shape Tamagui takes
|
|
86
|
+
for `createTokens` and `createTamagui({ themes })`, with themes keyed
|
|
87
|
+
`<theme>_<mode>`. No Tamagui dependency.
|
|
88
|
+
- Core tokens `success`, `warning`, `info` (with foregrounds), `diffAdded`,
|
|
89
|
+
`diffRemoved`, spacing `5` and `10`, radius `xl`, and a `label` type step.
|
|
90
|
+
|
|
91
|
+
### Changed
|
|
92
|
+
|
|
93
|
+
- README documents the install command.
|
|
94
|
+
|
|
95
|
+
- Core type weights follow the Penpot library: `fontWeight.caption` is 400
|
|
96
|
+
(was 500) and `fontWeight.label` is 500 (was 600), in `designTokens`,
|
|
97
|
+
`nativeTokens`, `tamaguiTokens` and the PaaS product theme, which uses the
|
|
98
|
+
core weights. The Maia theme keeps its own 500 and 600.
|
|
99
|
+
|
|
100
|
+
- The PaaS product theme's dark `card`, `popover` and `muted` are now
|
|
101
|
+
`#000000` (`productThemes.paas` and `tamaguiThemes.paas_dark`), following
|
|
102
|
+
the web's pure-black dark surfaces. `nativeTokens` and `tamaguiTokens` keep
|
|
103
|
+
their dark values (`#050505` page, `#0a0a0a` card and popover, `#262626`
|
|
104
|
+
muted).
|
|
105
|
+
|
|
106
|
+
### Fixed
|
|
107
|
+
|
|
108
|
+
- `createNativeTheme` keeps the default token when an override value is `undefined` instead of erasing it, and reports `colorScheme: "light"` for any scheme other than `"dark"` instead of echoing an invalid value.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 vllnt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @vllnt/ui-core
|
|
2
|
+
|
|
3
|
+
Platform-neutral design tokens and portable component contracts shared by the VLLNT UI web and React Native renderers.
|
|
4
|
+
|
|
5
|
+
## For AI agents
|
|
6
|
+
|
|
7
|
+
The installed package carries the docs for its own version. Start at `node_modules/@vllnt/ui-core/llms.txt`: it links the README, `tokens.json` and `component-contracts.json`.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @vllnt/ui-core@canary
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
- `canary` is published with `@vllnt/ui-native` from every core or native change on `main`, as `<next>-canary.<run>.sha<commit>`. It is the supported install today.
|
|
16
|
+
- Stable releases are published from `ui-core-vX.Y.Z` tags by `native-release.yml`, with npm provenance, and move `latest`. Until the first one, `latest` points at an old name-reservation build: do not install it.
|
|
17
|
+
|
|
18
|
+
React Native apps install it with `@vllnt/ui-native`, which pins the exact core version it was built with. See [releasing](../../docs/RELEASING.md).
|
|
19
|
+
|
|
20
|
+
## Use
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import {
|
|
24
|
+
createNativeTheme,
|
|
25
|
+
designTokens,
|
|
26
|
+
type ButtonVariant,
|
|
27
|
+
} from "@vllnt/ui-core";
|
|
28
|
+
|
|
29
|
+
const theme = createNativeTheme("dark", {
|
|
30
|
+
colors: { primary: "#f5f5f5" },
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Exports include the authored token object, generated React Native-compatible themes, the component contracts with their types and validator, and renderer-neutral option unions (`ButtonVariant`, `ButtonSize`, and so on) derived from the contracts. The JSON contracts are also available from `@vllnt/ui-core/tokens.json` and `@vllnt/ui-core/contracts.json`.
|
|
35
|
+
|
|
36
|
+
A renderer that only needs the native themes can import `createNativeTheme`, `lightTheme`, `darkTheme` and their types from `@vllnt/ui-core/theme`. That entry loads the native tokens only, not the web tokens, contracts or Tamagui tables, which keeps bundles small in bundlers that do not tree-shake, such as Metro.
|
|
37
|
+
|
|
38
|
+
`packages/design/tokens.json` and `packages/design/component-contracts.json` are the authored sources. Run `pnpm -F @vllnt/design-source tokens:generate` after changing either file. Generated artifacts are committed and checked for drift in CI.
|
|
39
|
+
|
|
40
|
+
## Component contracts
|
|
41
|
+
|
|
42
|
+
`component-contracts.json` (also `componentContracts`) describes each component once, for every renderer. An agent can read it to learn what a component is for, which props it takes on each platform, and what it needs to be accessible. Its JSON Schema is `component-contracts.schema.json`; `validateComponentContracts(value)` checks the same rules with no dependency and returns a list of problems (empty when valid).
|
|
43
|
+
|
|
44
|
+
Contracts are keyed by kebab-case id. Each one has:
|
|
45
|
+
|
|
46
|
+
| Field | Required | What |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `name` | yes | The exported component name, such as `Button`. |
|
|
49
|
+
| `description` | yes | What the component is for and when to choose it. |
|
|
50
|
+
| `platforms` | yes | The supported renderers (`web`, `native`). Each may name the host props it forwards (`inherits`, in words) and its own `props`. |
|
|
51
|
+
| `props` | yes | Props every platform takes with the same name, type and values. |
|
|
52
|
+
| `states` | no | States the component draws differently, such as `disabled` or `pressed`, each with a `description`. |
|
|
53
|
+
| `accessibility` | no | The WAI-ARIA `role`, and `labels` it needs, each with `required` and a `description`. |
|
|
54
|
+
| `parts` | no | The pieces of a compound component, such as `CardHeader`, each with a `description`. |
|
|
55
|
+
|
|
56
|
+
A prop has a `type` (`boolean`, `enum`, `node`, `number`, `string`, `style` or `text`), a `description`, and optionally `required` (default `false`), a `default`, and, for `enum` only, its `values`. Variants and sizes are enum props named `variant` and `size`. A platform prop with a shared prop's name widens it: same type and default, every shared value plus its own (web Button adds the `icon-lg` size and the `unstyled` variant). The validator rejects a restated prop that drops a shared value or changes the type or default; the JSON Schema cannot express that rule, or the rule that an enum default is one of its values.
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
"button": {
|
|
60
|
+
"name": "Button",
|
|
61
|
+
"description": "Triggers an action when pressed.",
|
|
62
|
+
"platforms": {
|
|
63
|
+
"web": { "props": { "asChild": { "type": "boolean", "default": false, "description": "Render the child element with the Button styles." } } },
|
|
64
|
+
"native": { "props": { "children": { "type": "text", "required": true, "description": "The label text." } } }
|
|
65
|
+
},
|
|
66
|
+
"props": {
|
|
67
|
+
"size": { "type": "enum", "values": ["default", "icon", "lg", "sm"], "default": "default", "description": "Height and padding." }
|
|
68
|
+
},
|
|
69
|
+
"accessibility": { "role": "button", "labels": { "name": { "required": true, "description": "The accessible name." } } }
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Renderers prove they match with the `ContractDrift` type. It lists every mismatch as a readable string (`"size: type or values differ from the contract"`, `"loading: not in the contract"`) and is `never` when the props match. Web and native Button run it in a type test (`button.contract.test-d.ts` and `button.contract.test.ts`):
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
type Drift = ContractDrift<
|
|
77
|
+
typeof componentContracts.components.button,
|
|
78
|
+
"web",
|
|
79
|
+
ButtonProps,
|
|
80
|
+
ButtonHTMLAttributes<HTMLButtonElement> // forwarded host props
|
|
81
|
+
>;
|
|
82
|
+
const noDrift: [Drift] extends [never] ? true : Drift = true;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
What the drift check does not cover:
|
|
86
|
+
|
|
87
|
+
- **Defaults.** Types cannot see a prop's default value, so `default` in a contract is documentation that review keeps true, not a checked fact.
|
|
88
|
+
- **Redeclared host attributes.** Props the renderer forwards (`TInherited`, such as `<button>` attributes on web) need no contract entry, so web may redeclare one, for example to narrow `type`, without the check noticing.
|
|
89
|
+
|
|
90
|
+
Button and Badge are full contracts. Both have a web drift check, and Button also has a native one. Card, Heading and Text list their portable options only, and have no drift check yet.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./component-contracts.schema.json",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"components": {
|
|
5
|
+
"badge": {
|
|
6
|
+
"name": "Badge",
|
|
7
|
+
"description": "A short, non-interactive label that tags or counts something, such as a status or a category.",
|
|
8
|
+
"platforms": {
|
|
9
|
+
"web": {
|
|
10
|
+
"inherits": "span element attributes (title, aria-*, and the rest), forwarded to the root span"
|
|
11
|
+
},
|
|
12
|
+
"native": {}
|
|
13
|
+
},
|
|
14
|
+
"props": {
|
|
15
|
+
"border": {
|
|
16
|
+
"type": "enum",
|
|
17
|
+
"values": ["none", "strong"],
|
|
18
|
+
"description": "Border weight. Leave it out to keep the border the variant draws. \"none\" removes the border; \"strong\" draws a full-contrast 1px border."
|
|
19
|
+
},
|
|
20
|
+
"dot": {
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"default": false,
|
|
23
|
+
"description": "Show a leading status dot. The dot is decorative and hidden from assistive technology, so the label says the status in words. It takes its colour from tone, and follows the label colour without a tone."
|
|
24
|
+
},
|
|
25
|
+
"size": {
|
|
26
|
+
"type": "enum",
|
|
27
|
+
"values": ["default", "header", "inline", "sm"],
|
|
28
|
+
"default": "default",
|
|
29
|
+
"description": "Chip size: \"header\" for page headers, \"sm\" for dense lists and tables, \"inline\" to sit in running text."
|
|
30
|
+
},
|
|
31
|
+
"tone": {
|
|
32
|
+
"type": "enum",
|
|
33
|
+
"values": [
|
|
34
|
+
"neutral",
|
|
35
|
+
"primary",
|
|
36
|
+
"info",
|
|
37
|
+
"success",
|
|
38
|
+
"warning",
|
|
39
|
+
"danger",
|
|
40
|
+
"solid",
|
|
41
|
+
"danger-tint",
|
|
42
|
+
"danger-solid"
|
|
43
|
+
],
|
|
44
|
+
"description": "Meaning of the chip. A status tone (neutral to danger) colours the dot and keeps the label and surface neutral; without a variant it uses the \"secondary\" surface. \"solid\", \"danger-tint\" and \"danger-solid\" set their own surface and replace the variant. Leave it out for the plain variant look."
|
|
45
|
+
},
|
|
46
|
+
"variant": {
|
|
47
|
+
"type": "enum",
|
|
48
|
+
"values": ["default", "destructive", "outline", "secondary", "soft"],
|
|
49
|
+
"description": "Surface of the chip. \"destructive\" still works, but new code uses tone \"danger-solid\", or tone \"danger\" with a dot for a calmer chip."
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"button": {
|
|
54
|
+
"name": "Button",
|
|
55
|
+
"description": "Triggers an action when pressed. Use it for actions, not for navigation between pages (on web, render a link through asChild instead).",
|
|
56
|
+
"platforms": {
|
|
57
|
+
"web": {
|
|
58
|
+
"inherits": "button element attributes (type, onClick, aria-*, and the rest), forwarded to the <button>",
|
|
59
|
+
"props": {
|
|
60
|
+
"asChild": {
|
|
61
|
+
"type": "boolean",
|
|
62
|
+
"default": false,
|
|
63
|
+
"description": "Render the single child element (for example a router link) with the Button styles instead of a <button>."
|
|
64
|
+
},
|
|
65
|
+
"children": {
|
|
66
|
+
"type": "node",
|
|
67
|
+
"description": "The label: text, an icon, or both."
|
|
68
|
+
},
|
|
69
|
+
"size": {
|
|
70
|
+
"type": "enum",
|
|
71
|
+
"values": ["default", "icon", "icon-lg", "lg", "sm"],
|
|
72
|
+
"default": "default",
|
|
73
|
+
"description": "Height and padding. \"icon\" and \"icon-lg\" are square icon-only buttons; \"icon-lg\" is the 44 px touch target."
|
|
74
|
+
},
|
|
75
|
+
"variant": {
|
|
76
|
+
"type": "enum",
|
|
77
|
+
"values": [
|
|
78
|
+
"default",
|
|
79
|
+
"destructive",
|
|
80
|
+
"ghost",
|
|
81
|
+
"link",
|
|
82
|
+
"outline",
|
|
83
|
+
"secondary",
|
|
84
|
+
"unstyled"
|
|
85
|
+
],
|
|
86
|
+
"default": "default",
|
|
87
|
+
"description": "Visual emphasis. \"unstyled\" adds no classes: the button draws only its className, and size has no effect."
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"native": {
|
|
92
|
+
"inherits": "Pressable props except children (onPress, accessibilityLabel, style, and the rest)",
|
|
93
|
+
"props": {
|
|
94
|
+
"children": {
|
|
95
|
+
"type": "text",
|
|
96
|
+
"required": true,
|
|
97
|
+
"description": "The label text, drawn in the variant's text style."
|
|
98
|
+
},
|
|
99
|
+
"textStyle": {
|
|
100
|
+
"type": "style",
|
|
101
|
+
"description": "Style for the label text, applied after the variant's text style."
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"props": {
|
|
107
|
+
"disabled": {
|
|
108
|
+
"type": "boolean",
|
|
109
|
+
"default": false,
|
|
110
|
+
"description": "Blocks presses and draws the disabled state."
|
|
111
|
+
},
|
|
112
|
+
"size": {
|
|
113
|
+
"type": "enum",
|
|
114
|
+
"values": ["default", "icon", "lg", "sm"],
|
|
115
|
+
"default": "default",
|
|
116
|
+
"description": "Height and padding. \"icon\" is a square icon-only button."
|
|
117
|
+
},
|
|
118
|
+
"variant": {
|
|
119
|
+
"type": "enum",
|
|
120
|
+
"values": [
|
|
121
|
+
"default",
|
|
122
|
+
"destructive",
|
|
123
|
+
"ghost",
|
|
124
|
+
"link",
|
|
125
|
+
"outline",
|
|
126
|
+
"secondary"
|
|
127
|
+
],
|
|
128
|
+
"default": "default",
|
|
129
|
+
"description": "Visual emphasis. Use \"default\" for the main action, \"destructive\" only for irreversible actions, and \"link\" only inside text."
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"states": {
|
|
133
|
+
"disabled": {
|
|
134
|
+
"description": "Not pressable; drawn in the disabled style."
|
|
135
|
+
},
|
|
136
|
+
"focus": {
|
|
137
|
+
"description": "Keyboard focus; draws the focus ring."
|
|
138
|
+
},
|
|
139
|
+
"hover": {
|
|
140
|
+
"description": "Pointer over the button; the background or text shifts."
|
|
141
|
+
},
|
|
142
|
+
"pressed": {
|
|
143
|
+
"description": "Being pressed. Native draws it; web keeps the hover style."
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"accessibility": {
|
|
147
|
+
"role": "button",
|
|
148
|
+
"labels": {
|
|
149
|
+
"name": {
|
|
150
|
+
"required": true,
|
|
151
|
+
"description": "The accessible name. Visible label text provides it; an icon-only button needs aria-label on web or accessibilityLabel on native."
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"card": {
|
|
157
|
+
"name": "Card",
|
|
158
|
+
"description": "A surface that groups related content and actions.",
|
|
159
|
+
"platforms": { "web": {}, "native": {} },
|
|
160
|
+
"props": {},
|
|
161
|
+
"parts": {
|
|
162
|
+
"Card": { "description": "The surface that holds the other parts." },
|
|
163
|
+
"CardHeader": { "description": "The top area, holding the title and description." },
|
|
164
|
+
"CardTitle": { "description": "The card's heading." },
|
|
165
|
+
"CardDescription": { "description": "Supporting text under the title." },
|
|
166
|
+
"CardContent": { "description": "The main body." },
|
|
167
|
+
"CardFooter": { "description": "The bottom area, usually for actions." }
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"heading": {
|
|
171
|
+
"name": "Heading",
|
|
172
|
+
"description": "A section title, ranked h1 to h6.",
|
|
173
|
+
"platforms": { "web": {}, "native": {} },
|
|
174
|
+
"props": {
|
|
175
|
+
"level": {
|
|
176
|
+
"type": "enum",
|
|
177
|
+
"values": [1, 2, 3, 4, 5, 6],
|
|
178
|
+
"description": "The heading rank, 1 (page title) to 6."
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"accessibility": {
|
|
182
|
+
"role": "heading"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"text": {
|
|
186
|
+
"name": "Text",
|
|
187
|
+
"description": "Body text whose scale, tone and weight come from the theme tokens.",
|
|
188
|
+
"platforms": { "web": {}, "native": {} },
|
|
189
|
+
"props": {
|
|
190
|
+
"size": {
|
|
191
|
+
"type": "enum",
|
|
192
|
+
"values": ["base", "caption", "lead", "small"],
|
|
193
|
+
"description": "The type scale step."
|
|
194
|
+
},
|
|
195
|
+
"tone": {
|
|
196
|
+
"type": "enum",
|
|
197
|
+
"values": ["default", "muted"],
|
|
198
|
+
"description": "The text color role. \"muted\" is for secondary text."
|
|
199
|
+
},
|
|
200
|
+
"weight": {
|
|
201
|
+
"type": "enum",
|
|
202
|
+
"values": ["medium", "normal", "semibold"],
|
|
203
|
+
"description": "The font weight."
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "VLLNT UI component contracts",
|
|
4
|
+
"description": "One renderer-neutral contract per component: purpose, props (type, default, required), states, accessibility, parts and supported platforms. Variants and sizes are enum props. validateComponentContracts in @vllnt/ui-core enforces the same rules plus two this schema cannot express: an enum default must be one of its values, and a platform prop that restates a shared prop keeps its type, every shared value and its default.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["version", "components"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": { "type": "string" },
|
|
9
|
+
"version": {
|
|
10
|
+
"description": "The contract format version.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
|
|
13
|
+
},
|
|
14
|
+
"components": {
|
|
15
|
+
"description": "Contracts by kebab-case component id.",
|
|
16
|
+
"type": "object",
|
|
17
|
+
"propertyNames": { "pattern": "^[a-z][a-z0-9-]*$" },
|
|
18
|
+
"additionalProperties": { "$ref": "#/$defs/component" }
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"additionalProperties": false,
|
|
22
|
+
"$defs": {
|
|
23
|
+
"text": { "type": "string", "pattern": "\\S" },
|
|
24
|
+
"component": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"required": ["name", "description", "platforms", "props"],
|
|
27
|
+
"properties": {
|
|
28
|
+
"name": { "description": "The exported component name.", "$ref": "#/$defs/text" },
|
|
29
|
+
"description": { "description": "What the component is for and when to choose it.", "$ref": "#/$defs/text" },
|
|
30
|
+
"platforms": {
|
|
31
|
+
"description": "The supported renderers, each with its own props.",
|
|
32
|
+
"type": "object",
|
|
33
|
+
"minProperties": 1,
|
|
34
|
+
"propertyNames": { "enum": ["web", "native"] },
|
|
35
|
+
"additionalProperties": { "$ref": "#/$defs/platform" }
|
|
36
|
+
},
|
|
37
|
+
"props": {
|
|
38
|
+
"description": "Props every listed platform takes with the same name, type and values.",
|
|
39
|
+
"$ref": "#/$defs/props"
|
|
40
|
+
},
|
|
41
|
+
"states": {
|
|
42
|
+
"description": "States the component draws differently, such as disabled or pressed.",
|
|
43
|
+
"$ref": "#/$defs/described"
|
|
44
|
+
},
|
|
45
|
+
"accessibility": { "$ref": "#/$defs/accessibility" },
|
|
46
|
+
"parts": {
|
|
47
|
+
"description": "Named pieces of a compound component.",
|
|
48
|
+
"$ref": "#/$defs/described"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"additionalProperties": false
|
|
52
|
+
},
|
|
53
|
+
"platform": {
|
|
54
|
+
"type": "object",
|
|
55
|
+
"properties": {
|
|
56
|
+
"inherits": {
|
|
57
|
+
"description": "Host props the renderer forwards unchanged, in words.",
|
|
58
|
+
"$ref": "#/$defs/text"
|
|
59
|
+
},
|
|
60
|
+
"props": {
|
|
61
|
+
"description": "Props this renderer adds, or shared props it widens (same type and default, every shared value plus more).",
|
|
62
|
+
"$ref": "#/$defs/props"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"additionalProperties": false
|
|
66
|
+
},
|
|
67
|
+
"props": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"additionalProperties": { "$ref": "#/$defs/prop" }
|
|
70
|
+
},
|
|
71
|
+
"prop": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"required": ["type", "description"],
|
|
74
|
+
"properties": {
|
|
75
|
+
"type": {
|
|
76
|
+
"description": "boolean, number, string: the plain value. enum: one of values. text: a string or number. node: renderable content. style: a renderer style object.",
|
|
77
|
+
"enum": ["boolean", "enum", "node", "number", "string", "style", "text"]
|
|
78
|
+
},
|
|
79
|
+
"description": { "$ref": "#/$defs/text" },
|
|
80
|
+
"required": { "type": "boolean" },
|
|
81
|
+
"default": { "type": ["boolean", "number", "string"] },
|
|
82
|
+
"values": {
|
|
83
|
+
"type": "array",
|
|
84
|
+
"minItems": 1,
|
|
85
|
+
"uniqueItems": true,
|
|
86
|
+
"items": { "anyOf": [{ "type": "number" }, { "$ref": "#/$defs/text" }] }
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"allOf": [
|
|
90
|
+
{
|
|
91
|
+
"if": { "properties": { "type": { "const": "enum" } } },
|
|
92
|
+
"then": { "required": ["values"] },
|
|
93
|
+
"else": { "not": { "required": ["values"] } }
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"if": { "properties": { "required": { "const": true } }, "required": ["required"] },
|
|
97
|
+
"then": { "not": { "required": ["default"] } }
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"additionalProperties": false
|
|
101
|
+
},
|
|
102
|
+
"described": {
|
|
103
|
+
"type": "object",
|
|
104
|
+
"additionalProperties": {
|
|
105
|
+
"type": "object",
|
|
106
|
+
"required": ["description"],
|
|
107
|
+
"properties": { "description": { "$ref": "#/$defs/text" } },
|
|
108
|
+
"additionalProperties": false
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"accessibility": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"required": ["role"],
|
|
114
|
+
"properties": {
|
|
115
|
+
"role": {
|
|
116
|
+
"description": "The WAI-ARIA role the component exposes.",
|
|
117
|
+
"$ref": "#/$defs/text"
|
|
118
|
+
},
|
|
119
|
+
"labels": {
|
|
120
|
+
"description": "Text alternatives the component needs, by name.",
|
|
121
|
+
"type": "object",
|
|
122
|
+
"additionalProperties": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"required": ["required", "description"],
|
|
125
|
+
"properties": {
|
|
126
|
+
"required": { "type": "boolean" },
|
|
127
|
+
"description": { "$ref": "#/$defs/text" }
|
|
128
|
+
},
|
|
129
|
+
"additionalProperties": false
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"additionalProperties": false
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|