@ksp-gonogo/ui-kit 0.1.0 → 0.2.0-rc.12
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/LICENSE +21 -596
- package/README.md +151 -0
- package/dist/chunk-G3PMV62Z.js +36 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/chunk-PG6WD6AT.js +8611 -0
- package/dist/chunk-PG6WD6AT.js.map +1 -0
- package/dist/chunk-SHAX2WJJ.js +18 -0
- package/dist/chunk-SHAX2WJJ.js.map +1 -0
- package/dist/compat.json +3 -0
- package/dist/dist-JSEJWZKX.js +546 -0
- package/dist/dist-JSEJWZKX.js.map +1 -0
- package/dist/gridUnits.d.ts +34 -0
- package/dist/gridUnits.js +14 -0
- package/dist/gridUnits.js.map +1 -0
- package/dist/guards.d.ts +110 -0
- package/dist/guards.js +171 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.d.ts +9349 -25
- package/dist/index.js +8098 -28
- package/dist/index.js.map +1 -1
- package/dist/magic-string.es-J7BYFTTJ.js +1309 -0
- package/dist/magic-string.es-J7BYFTTJ.js.map +1 -0
- package/dist/testing.d.ts +471 -0
- package/dist/testing.js +16747 -0
- package/dist/testing.js.map +1 -0
- package/dist/tokens.css +1063 -29
- package/dist/units-Cl-8ZdJc.d.ts +270 -0
- package/package.json +57 -15
- package/dist/ActionButton.d.ts +0 -18
- package/dist/ActionButton.d.ts.map +0 -1
- package/dist/ActionButton.js +0 -56
- package/dist/ActionButton.js.map +0 -1
- package/dist/Badge.d.ts +0 -15
- package/dist/Badge.d.ts.map +0 -1
- package/dist/Badge.js +0 -60
- package/dist/Badge.js.map +0 -1
- package/dist/Box.d.ts +0 -19
- package/dist/Box.d.ts.map +0 -1
- package/dist/Box.js +0 -27
- package/dist/Box.js.map +0 -1
- package/dist/Card.d.ts +0 -11
- package/dist/Card.d.ts.map +0 -1
- package/dist/Card.js +0 -13
- package/dist/Card.js.map +0 -1
- package/dist/Cluster.d.ts +0 -18
- package/dist/Cluster.d.ts.map +0 -1
- package/dist/Cluster.js +0 -24
- package/dist/Cluster.js.map +0 -1
- package/dist/EmptyState.d.ts +0 -16
- package/dist/EmptyState.d.ts.map +0 -1
- package/dist/EmptyState.js +0 -37
- package/dist/EmptyState.js.map +0 -1
- package/dist/GonogoTokens.d.ts +0 -16
- package/dist/GonogoTokens.d.ts.map +0 -1
- package/dist/GonogoTokens.js +0 -108
- package/dist/GonogoTokens.js.map +0 -1
- package/dist/Grid.d.ts +0 -25
- package/dist/Grid.d.ts.map +0 -1
- package/dist/Grid.js +0 -23
- package/dist/Grid.js.map +0 -1
- package/dist/Inline.d.ts +0 -20
- package/dist/Inline.d.ts.map +0 -1
- package/dist/Inline.js +0 -17
- package/dist/Inline.js.map +0 -1
- package/dist/Panel.d.ts +0 -14
- package/dist/Panel.d.ts.map +0 -1
- package/dist/Panel.js +0 -145
- package/dist/Panel.js.map +0 -1
- package/dist/ProgressBar.d.ts +0 -15
- package/dist/ProgressBar.d.ts.map +0 -1
- package/dist/ProgressBar.js +0 -31
- package/dist/ProgressBar.js.map +0 -1
- package/dist/Readout.d.ts +0 -35
- package/dist/Readout.d.ts.map +0 -1
- package/dist/Readout.js +0 -114
- package/dist/Readout.js.map +0 -1
- package/dist/Row.d.ts +0 -22
- package/dist/Row.d.ts.map +0 -1
- package/dist/Row.js +0 -32
- package/dist/Row.js.map +0 -1
- package/dist/Section.d.ts +0 -15
- package/dist/Section.d.ts.map +0 -1
- package/dist/Section.js +0 -21
- package/dist/Section.js.map +0 -1
- package/dist/Spinner.d.ts +0 -18
- package/dist/Spinner.d.ts.map +0 -1
- package/dist/Spinner.js +0 -22
- package/dist/Spinner.js.map +0 -1
- package/dist/Stack.d.ts +0 -15
- package/dist/Stack.d.ts.map +0 -1
- package/dist/Stack.js +0 -17
- package/dist/Stack.js.map +0 -1
- package/dist/StatusIndicator.d.ts +0 -27
- package/dist/StatusIndicator.d.ts.map +0 -1
- package/dist/StatusIndicator.js +0 -78
- package/dist/StatusIndicator.js.map +0 -1
- package/dist/Truncate.d.ts +0 -7
- package/dist/Truncate.d.ts.map +0 -1
- package/dist/Truncate.js +0 -14
- package/dist/Truncate.js.map +0 -1
- package/dist/Value.d.ts +0 -24
- package/dist/Value.d.ts.map +0 -1
- package/dist/Value.js +0 -42
- package/dist/Value.js.map +0 -1
- package/dist/WidgetHeader.d.ts +0 -16
- package/dist/WidgetHeader.d.ts.map +0 -1
- package/dist/WidgetHeader.js +0 -40
- package/dist/WidgetHeader.js.map +0 -1
- package/dist/defaultDarkTheme.d.ts +0 -16
- package/dist/defaultDarkTheme.d.ts.map +0 -1
- package/dist/defaultDarkTheme.js +0 -96
- package/dist/defaultDarkTheme.js.map +0 -1
- package/dist/format.d.ts +0 -11
- package/dist/format.d.ts.map +0 -1
- package/dist/format.js +0 -12
- package/dist/format.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/science/ScienceExperimentRow.d.ts +0 -43
- package/dist/science/ScienceExperimentRow.d.ts.map +0 -1
- package/dist/science/ScienceExperimentRow.js +0 -61
- package/dist/science/ScienceExperimentRow.js.map +0 -1
- package/dist/test/axe.d.ts +0 -3
- package/dist/test/axe.d.ts.map +0 -1
- package/dist/test/axe.js +0 -5
- package/dist/test/axe.js.map +0 -1
- package/dist/test/setup.d.ts +0 -2
- package/dist/test/setup.d.ts.map +0 -1
- package/dist/test/setup.js +0 -12
- package/dist/test/setup.js.map +0 -1
- package/dist/theme.d.ts +0 -116
- package/dist/theme.d.ts.map +0 -1
- package/dist/theme.js +0 -15
- package/dist/theme.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# @ksp-gonogo/ui-kit
|
|
2
|
+
|
|
3
|
+
The design system behind [Gonogo](https://github.com/ksp-gonogo/gonogo), a mission-control
|
|
4
|
+
dashboard for Kerbal Space Program. It's the same set of primitives the built-in widgets are
|
|
5
|
+
made of, published so that widgets and Uplinks written outside this repo look like they belong
|
|
6
|
+
on the same screen. Compose them and your widget picks up the host's theme, spacing and type
|
|
7
|
+
scale without you writing CSS for any of it.
|
|
8
|
+
|
|
9
|
+
A widget ships inside an **Uplink**, the extension unit that pairs a KSP mod with a client
|
|
10
|
+
bundle. This package is one of its two halves; the other is `@ksp-gonogo/sitrep-sdk`, which
|
|
11
|
+
carries the registration and the telemetry hooks.
|
|
12
|
+
|
|
13
|
+
## The documentation lives elsewhere
|
|
14
|
+
|
|
15
|
+
**[Gonogo Uplink developer documentation](https://ksp-gonogo.github.io/uplink-dev-docs/)** is the
|
|
16
|
+
reference for this package, and for everything around it:
|
|
17
|
+
|
|
18
|
+
- [the guide](https://ksp-gonogo.github.io/uplink-dev-docs/guide/), start to finish, if you have
|
|
19
|
+
not written an Uplink before
|
|
20
|
+
- [the ui-kit reference](https://ksp-gonogo.github.io/uplink-dev-docs/reference/ui-kit/), a page
|
|
21
|
+
per primitive
|
|
22
|
+
|
|
23
|
+
Every snippet on that site is transcluded from a source file that is compiled in CI, so a
|
|
24
|
+
signature that drifts fails the build instead of reading correctly and being wrong. This file
|
|
25
|
+
deliberately carries no component reference of its own: a second, unchecked copy would drift,
|
|
26
|
+
and it did.
|
|
27
|
+
|
|
28
|
+
What follows is only what you need before the docs are any use to you: how to install the
|
|
29
|
+
package, and the three environment constraints that will otherwise stop you at the first import.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install @ksp-gonogo/ui-kit
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
React 18 and styled-components 6 are peer dependencies; install them if you don't have them:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npm install react@^18 styled-components@^6
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
They're peers rather than dependencies because there has to be exactly one copy of each in the
|
|
44
|
+
final app. styled-components keeps its `ThemeContext` in module state, so a second copy would
|
|
45
|
+
give your components a different context than the host's `ThemeProvider` populates, and your
|
|
46
|
+
`theme` would come back empty. React has the same problem one layer down. As peers, they
|
|
47
|
+
resolve to whatever the host already installed.
|
|
48
|
+
|
|
49
|
+
Primitives read `theme.space` and `theme.colors`, so they need a `ThemeProvider` in scope and
|
|
50
|
+
will throw without one. Inside a Gonogo dashboard the host has already mounted it. Standing the
|
|
51
|
+
kit up yourself, for a test or a preview outside the app:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import "@ksp-gonogo/ui-kit/tokens.css";
|
|
55
|
+
import { DefaultThemeProvider } from "@ksp-gonogo/ui-kit";
|
|
56
|
+
|
|
57
|
+
<DefaultThemeProvider>
|
|
58
|
+
<YourWidget />
|
|
59
|
+
</DefaultThemeProvider>;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Testing with vitest: the kit must be inlined
|
|
63
|
+
|
|
64
|
+
Add this to your `vitest.config.ts`, or every test file that touches the kit dies on import
|
|
65
|
+
before a single assertion runs:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
export default defineConfig({
|
|
69
|
+
test: {
|
|
70
|
+
server: { deps: { inline: [/@ksp-gonogo/] } },
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Vitest hands `node_modules` dependencies to Node's ESM loader rather than transforming them, and
|
|
76
|
+
`styled-components@6` publishes no `exports` map, only `main` (CommonJS) and `module` (ESM).
|
|
77
|
+
Node therefore loads the CommonJS half, and its interop makes the default export the module
|
|
78
|
+
namespace object rather than the `styled` factory. The kit evaluates `styled.span` at module
|
|
79
|
+
scope, so you get:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
TypeError: styled.span is not a function
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
before any of your code runs. Inlining makes Vite process the kit itself, which honours `module`
|
|
86
|
+
and resolves the factory. This is not specific to this kit, it is what any styled-components
|
|
87
|
+
library needs from vitest, and it is why you will not see the problem in a monorepo where the kit
|
|
88
|
+
is a workspace symlink: Vite never pre-bundles a linked dependency.
|
|
89
|
+
|
|
90
|
+
The same setting is what the kit's `/testing`, `/render-probe` and `/page-check` entry points
|
|
91
|
+
need, and it is the reason `expectNoA11yViolations` will otherwise appear not to exist.
|
|
92
|
+
|
|
93
|
+
**Do not read a green vitest run as proof a `@ksp-gonogo` package is loadable.** Inlining also
|
|
94
|
+
performs the module-extension search Node refuses to, so it hides an unloadable emit rather than
|
|
95
|
+
reporting it. That is a real bug this project shipped for six weeks.
|
|
96
|
+
|
|
97
|
+
## Build against `moduleResolution: "bundler"`
|
|
98
|
+
|
|
99
|
+
`deps.inline` is a bundler setting. `tsc` is not a bundler, so under
|
|
100
|
+
`moduleResolution: "nodenext"` the missing `exports` map bites again at the type level:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
error TS2339: Property 'div' does not exist on type
|
|
104
|
+
'typeof import(".../styled-components/dist/index")'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
That is two lines of code with no `@ksp-gonogo` package involved:
|
|
108
|
+
`import styled from "styled-components"` followed by `styled.div`. Nothing in this kit can fix it
|
|
109
|
+
for you, and no shim in your own source fixes it cleanly either (unwrapping `.default` satisfies
|
|
110
|
+
`nodenext` and then breaks `bundler`, which resolves the ESM half where the default IS the factory).
|
|
111
|
+
|
|
112
|
+
So: build against `"bundler"`, which is what `@ksp-gonogo/sitrep-sdk/tsconfig.base.json` sets and
|
|
113
|
+
why it sets it. An Uplink whose widgets use `styled` cannot pass a `nodenext` typecheck until
|
|
114
|
+
styled-components ships an `exports` map, and that is a statement about styled-components rather
|
|
115
|
+
than about your code.
|
|
116
|
+
|
|
117
|
+
The kit's own declarations are unaffected in practice because the shipped baseline sets
|
|
118
|
+
`skipLibCheck: true`, which suppresses errors inside `.d.ts` files. Turning it off surfaces roughly
|
|
119
|
+
sixty of them, none actionable from a consumer's side.
|
|
120
|
+
|
|
121
|
+
## The theme is typed for you, everywhere
|
|
122
|
+
|
|
123
|
+
Importing the package binds the theme contract onto styled-components' `DefaultTheme`. You get
|
|
124
|
+
autocomplete and type errors in theme callbacks without writing your own `declare module`, so
|
|
125
|
+
`theme.space.bogus` is a compile error rather than `any`.
|
|
126
|
+
|
|
127
|
+
This is a global augmentation, it's how module augmentation works, and there's no scoped version.
|
|
128
|
+
Importing the kit anywhere in a project types `DefaultTheme` everywhere in it. If you already
|
|
129
|
+
augment `DefaultTheme` yourself, expect a conflict.
|
|
130
|
+
|
|
131
|
+
## One convention worth knowing
|
|
132
|
+
|
|
133
|
+
Widgets here carry close to no CSS of their own. Spacing, surfaces, borders and type all come
|
|
134
|
+
from the kit, which is what keeps twenty-odd widgets from twenty-odd authors reading as one
|
|
135
|
+
instrument panel. If you find yourself reaching for a bespoke `styled.div` to do something the
|
|
136
|
+
kit almost does, that's usually a gap in the kit worth
|
|
137
|
+
[raising](https://github.com/ksp-gonogo/gonogo/issues).
|
|
138
|
+
|
|
139
|
+
## Versioning
|
|
140
|
+
|
|
141
|
+
The kit carries the Gonogo release version, the same one as `@ksp-gonogo/sitrep-sdk`,
|
|
142
|
+
`@ksp-gonogo/uplink-tools` and the app it shipped with, and names the sdk of that release as an
|
|
143
|
+
exact peer. Install them together at one version, and move them together.
|
|
144
|
+
|
|
145
|
+
What the kit's surface promises is held by the extension API version, which the app checks
|
|
146
|
+
before it loads an Uplink, not by the package version. Token names are part of that surface,
|
|
147
|
+
not an implementation detail: renaming one is a break.
|
|
148
|
+
|
|
149
|
+
## Licence
|
|
150
|
+
|
|
151
|
+
MIT
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
__commonJS,
|
|
33
|
+
__export,
|
|
34
|
+
__toESM
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=chunk-G3PMV62Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|