@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.
Files changed (133) hide show
  1. package/LICENSE +21 -596
  2. package/README.md +151 -0
  3. package/dist/chunk-G3PMV62Z.js +36 -0
  4. package/dist/chunk-G3PMV62Z.js.map +1 -0
  5. package/dist/chunk-PG6WD6AT.js +8611 -0
  6. package/dist/chunk-PG6WD6AT.js.map +1 -0
  7. package/dist/chunk-SHAX2WJJ.js +18 -0
  8. package/dist/chunk-SHAX2WJJ.js.map +1 -0
  9. package/dist/compat.json +3 -0
  10. package/dist/dist-JSEJWZKX.js +546 -0
  11. package/dist/dist-JSEJWZKX.js.map +1 -0
  12. package/dist/gridUnits.d.ts +34 -0
  13. package/dist/gridUnits.js +14 -0
  14. package/dist/gridUnits.js.map +1 -0
  15. package/dist/guards.d.ts +110 -0
  16. package/dist/guards.js +171 -0
  17. package/dist/guards.js.map +1 -0
  18. package/dist/index.d.ts +9349 -25
  19. package/dist/index.js +8098 -28
  20. package/dist/index.js.map +1 -1
  21. package/dist/magic-string.es-J7BYFTTJ.js +1309 -0
  22. package/dist/magic-string.es-J7BYFTTJ.js.map +1 -0
  23. package/dist/testing.d.ts +471 -0
  24. package/dist/testing.js +16747 -0
  25. package/dist/testing.js.map +1 -0
  26. package/dist/tokens.css +1063 -29
  27. package/dist/units-Cl-8ZdJc.d.ts +270 -0
  28. package/package.json +57 -15
  29. package/dist/ActionButton.d.ts +0 -18
  30. package/dist/ActionButton.d.ts.map +0 -1
  31. package/dist/ActionButton.js +0 -56
  32. package/dist/ActionButton.js.map +0 -1
  33. package/dist/Badge.d.ts +0 -15
  34. package/dist/Badge.d.ts.map +0 -1
  35. package/dist/Badge.js +0 -60
  36. package/dist/Badge.js.map +0 -1
  37. package/dist/Box.d.ts +0 -19
  38. package/dist/Box.d.ts.map +0 -1
  39. package/dist/Box.js +0 -27
  40. package/dist/Box.js.map +0 -1
  41. package/dist/Card.d.ts +0 -11
  42. package/dist/Card.d.ts.map +0 -1
  43. package/dist/Card.js +0 -13
  44. package/dist/Card.js.map +0 -1
  45. package/dist/Cluster.d.ts +0 -18
  46. package/dist/Cluster.d.ts.map +0 -1
  47. package/dist/Cluster.js +0 -24
  48. package/dist/Cluster.js.map +0 -1
  49. package/dist/EmptyState.d.ts +0 -16
  50. package/dist/EmptyState.d.ts.map +0 -1
  51. package/dist/EmptyState.js +0 -37
  52. package/dist/EmptyState.js.map +0 -1
  53. package/dist/GonogoTokens.d.ts +0 -16
  54. package/dist/GonogoTokens.d.ts.map +0 -1
  55. package/dist/GonogoTokens.js +0 -108
  56. package/dist/GonogoTokens.js.map +0 -1
  57. package/dist/Grid.d.ts +0 -25
  58. package/dist/Grid.d.ts.map +0 -1
  59. package/dist/Grid.js +0 -23
  60. package/dist/Grid.js.map +0 -1
  61. package/dist/Inline.d.ts +0 -20
  62. package/dist/Inline.d.ts.map +0 -1
  63. package/dist/Inline.js +0 -17
  64. package/dist/Inline.js.map +0 -1
  65. package/dist/Panel.d.ts +0 -14
  66. package/dist/Panel.d.ts.map +0 -1
  67. package/dist/Panel.js +0 -145
  68. package/dist/Panel.js.map +0 -1
  69. package/dist/ProgressBar.d.ts +0 -15
  70. package/dist/ProgressBar.d.ts.map +0 -1
  71. package/dist/ProgressBar.js +0 -31
  72. package/dist/ProgressBar.js.map +0 -1
  73. package/dist/Readout.d.ts +0 -35
  74. package/dist/Readout.d.ts.map +0 -1
  75. package/dist/Readout.js +0 -114
  76. package/dist/Readout.js.map +0 -1
  77. package/dist/Row.d.ts +0 -22
  78. package/dist/Row.d.ts.map +0 -1
  79. package/dist/Row.js +0 -32
  80. package/dist/Row.js.map +0 -1
  81. package/dist/Section.d.ts +0 -15
  82. package/dist/Section.d.ts.map +0 -1
  83. package/dist/Section.js +0 -21
  84. package/dist/Section.js.map +0 -1
  85. package/dist/Spinner.d.ts +0 -18
  86. package/dist/Spinner.d.ts.map +0 -1
  87. package/dist/Spinner.js +0 -22
  88. package/dist/Spinner.js.map +0 -1
  89. package/dist/Stack.d.ts +0 -15
  90. package/dist/Stack.d.ts.map +0 -1
  91. package/dist/Stack.js +0 -17
  92. package/dist/Stack.js.map +0 -1
  93. package/dist/StatusIndicator.d.ts +0 -27
  94. package/dist/StatusIndicator.d.ts.map +0 -1
  95. package/dist/StatusIndicator.js +0 -78
  96. package/dist/StatusIndicator.js.map +0 -1
  97. package/dist/Truncate.d.ts +0 -7
  98. package/dist/Truncate.d.ts.map +0 -1
  99. package/dist/Truncate.js +0 -14
  100. package/dist/Truncate.js.map +0 -1
  101. package/dist/Value.d.ts +0 -24
  102. package/dist/Value.d.ts.map +0 -1
  103. package/dist/Value.js +0 -42
  104. package/dist/Value.js.map +0 -1
  105. package/dist/WidgetHeader.d.ts +0 -16
  106. package/dist/WidgetHeader.d.ts.map +0 -1
  107. package/dist/WidgetHeader.js +0 -40
  108. package/dist/WidgetHeader.js.map +0 -1
  109. package/dist/defaultDarkTheme.d.ts +0 -16
  110. package/dist/defaultDarkTheme.d.ts.map +0 -1
  111. package/dist/defaultDarkTheme.js +0 -96
  112. package/dist/defaultDarkTheme.js.map +0 -1
  113. package/dist/format.d.ts +0 -11
  114. package/dist/format.d.ts.map +0 -1
  115. package/dist/format.js +0 -12
  116. package/dist/format.js.map +0 -1
  117. package/dist/index.d.ts.map +0 -1
  118. package/dist/science/ScienceExperimentRow.d.ts +0 -43
  119. package/dist/science/ScienceExperimentRow.d.ts.map +0 -1
  120. package/dist/science/ScienceExperimentRow.js +0 -61
  121. package/dist/science/ScienceExperimentRow.js.map +0 -1
  122. package/dist/test/axe.d.ts +0 -3
  123. package/dist/test/axe.d.ts.map +0 -1
  124. package/dist/test/axe.js +0 -5
  125. package/dist/test/axe.js.map +0 -1
  126. package/dist/test/setup.d.ts +0 -2
  127. package/dist/test/setup.d.ts.map +0 -1
  128. package/dist/test/setup.js +0 -12
  129. package/dist/test/setup.js.map +0 -1
  130. package/dist/theme.d.ts +0 -116
  131. package/dist/theme.d.ts.map +0 -1
  132. package/dist/theme.js +0 -15
  133. 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":[]}