@bigpixelrocket/uiok 0.1.0 → 0.1.2

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 CHANGED
@@ -6,9 +6,22 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.1.2] - 2026-11-08
10
+
9
11
  ### Added
10
12
 
11
- - Terminal (`@bigpixelrocket/uiok/terminal`, `docs/components/terminal.md`): `Terminal`, Ghostty's VT engine as WebAssembly drawn on a canvas, read-only without `onInput`, with a Copy and Paste menu whose chords come from `menuChords`, a visual bell, line-editing actions bound by `actionForKey`, and `TerminalScrollbackContext`. The package root does not export it, so an app without a terminal never loads its assets. Its words are the new `terminal` label group; the package now ships a `NOTICE` with the engine's, adapter's, and font's licences.
13
+ - `legibleOn` and `firstLegible`, the WCAG contrast picks UIOK's own tokens are derived with, exported from `@bigpixelrocket/uiok` and `@bigpixelrocket/uiok/themes` so an app can derive legible tokens of its own for `themeStylesheet()`. See `docs/themes.md`.
14
+ - `seriesColour`, the `--chart-1` to `--chart-8` token a series index is drawn in, exported from `@bigpixelrocket/uiok/charts` so a series drawn outside the charts matches theirs.
15
+
16
+ ### Fixed
17
+
18
+ - `DateTimePicker` widens a fraction field of more than three digits to fit them, so six digits of microseconds show whole; a millisecond field keeps its width.
19
+
20
+ ## [0.1.1] - 2026-11-08
21
+
22
+ ### Changed
23
+
24
+ - The package's npm homepage now links to the documentation site at https://bigpixelrocket.github.io/uiok/.
12
25
 
13
26
  ## [0.1.0] - 2026-11-07
14
27
 
@@ -33,6 +46,9 @@ The first published version. The package is published to npm as `@bigpixelrocket
33
46
  - Charts (`@bigpixelrocket/uiok/charts`): `LineChart`, `PieChart`, `ScatterChart`, and `ResultChart` (bar, column, line, spline, area, pie, timeline, scatter; stackable), painted from the `--chart-*` tokens, and `tokenColour`, `svgMarkup`, and `svgPng` to save a chart as a picture. Their shared words are the `charts` label group (`ChartLabels`).
34
47
  - Each area is importable on its own as `@bigpixelrocket/uiok/<area>` (`@bigpixelrocket/uiok/button`, `@bigpixelrocket/uiok/keyboard`, …).
35
48
  - `lucide-react` 1.31 or later within 1.x is a peer dependency.
49
+ - Terminal (`@bigpixelrocket/uiok/terminal`, `docs/components/terminal.md`): `Terminal`, Ghostty's VT engine as WebAssembly drawn on a canvas, read-only without `onInput`, with a Copy and Paste menu whose chords come from `menuChords`, a visual bell, line-editing actions bound by `actionForKey`, and `TerminalScrollbackContext`. The package root does not export it, so an app without a terminal never loads its assets. Its words are the new `terminal` label group; the package now ships a `NOTICE` with the engine's, adapter's, and font's licences.
36
50
 
37
- [Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.1.0...HEAD
51
+ [Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.1.2...HEAD
52
+ [0.1.2]: https://github.com/Bigpixelrocket/uiok/compare/v0.1.1...v0.1.2
53
+ [0.1.1]: https://github.com/Bigpixelrocket/uiok/compare/v0.1.0...v0.1.1
38
54
  [0.1.0]: https://github.com/Bigpixelrocket/uiok/releases/tag/v0.1.0
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Charts drawn in SVG from the theme's chart tokens: `LineChart`,
3
3
  * `PieChart`, `ScatterChart`, and `ResultChart` for a table of rows, plus
4
- * the helpers that save a chart as a picture.
4
+ * the helpers that save a chart as a picture, and `seriesColour` for a
5
+ * series drawn outside them.
5
6
  */
6
7
  export { svgMarkup, svgPng, tokenColour } from './Drawing.js';
7
8
  export type { LinePoint } from './Line.logic.js';
@@ -12,3 +13,4 @@ export { ResultChart, type ResultChartProps } from './ResultChart.js';
12
13
  export { RESULT_CHART_TYPES, STACKABLE_CHART_TYPES, type ChartSeries, type ResultChartType } from './ResultChart.logic.js';
13
14
  export type { ScatterAxis, ScatterAxisKind } from './Scatter.logic.js';
14
15
  export { ScatterChart, type ScatterChartProps, type ScatterPoint } from './ScatterChart.js';
16
+ export { seriesColour } from './seriesColour.js';
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Charts drawn in SVG from the theme's chart tokens: `LineChart`,
3
3
  * `PieChart`, `ScatterChart`, and `ResultChart` for a table of rows, plus
4
- * the helpers that save a chart as a picture.
4
+ * the helpers that save a chart as a picture, and `seriesColour` for a
5
+ * series drawn outside them.
5
6
  */
6
7
  export { svgMarkup, svgPng, tokenColour } from './Drawing.js';
7
8
  export { LineChart } from './LineChart.js';
@@ -9,3 +10,4 @@ export { PieChart } from './PieChart.js';
9
10
  export { ResultChart } from './ResultChart.js';
10
11
  export { RESULT_CHART_TYPES, STACKABLE_CHART_TYPES } from './ResultChart.logic.js';
11
12
  export { ScatterChart } from './ScatterChart.js';
13
+ export { seriesColour } from './seriesColour.js';
@@ -1,2 +1,10 @@
1
- /** The chart token the series at `index` (from zero) is drawn in, as a `var()`. */
1
+ /**
2
+ * The chart token the series at `index` (from zero) is drawn in, as a
3
+ * `var()`: `--chart-1` for 0 through `--chart-8` for 7, starting over at 8.
4
+ * `index` is a non-negative integer, as an array index is; any other number
5
+ * names a token no theme defines (`-1` gives `--chart-0`).
6
+ * A series an app draws beside the charts (its own legend, a map layer)
7
+ * takes the same colour as the chart's: `seriesColour(2)` is
8
+ * `'var(--chart-3)'`.
9
+ */
2
10
  export declare const seriesColour: (index: number) => string;
@@ -4,5 +4,13 @@
4
4
  */
5
5
  /** How many series colours the theme defines (`--chart-1` to `--chart-8`). */
6
6
  const SERIES_COLOURS = 8;
7
- /** The chart token the series at `index` (from zero) is drawn in, as a `var()`. */
7
+ /**
8
+ * The chart token the series at `index` (from zero) is drawn in, as a
9
+ * `var()`: `--chart-1` for 0 through `--chart-8` for 7, starting over at 8.
10
+ * `index` is a non-negative integer, as an array index is; any other number
11
+ * names a token no theme defines (`-1` gives `--chart-0`).
12
+ * A series an app draws beside the charts (its own legend, a map layer)
13
+ * takes the same colour as the chart's: `seriesColour(2)` is
14
+ * `'var(--chart-3)'`.
15
+ */
8
16
  export const seriesColour = (index) => `var(--chart-${(index % SERIES_COLOURS) + 1})`;
@@ -12,6 +12,12 @@ const TIME_FIELDS = [
12
12
  { part: 'minute', max: 59 },
13
13
  { part: 'second', max: 59 }
14
14
  ];
15
+ /**
16
+ * The most fraction digits a time field's own width shows whole; a longer
17
+ * fraction field (microseconds) widens to its digit count (`.long`, with
18
+ * `--date-picker-digits`).
19
+ */
20
+ const SHORT_FRACTION = 3;
15
21
  /** A time field's label. */
16
22
  const timeFieldLabel = (labels, part) => labels[part];
17
23
  /**
@@ -87,10 +93,12 @@ export function DateTimePicker({ kind, fraction = 0, value, onChange, firstDay =
87
93
  const next = Math.min(field.max, Math.max(0, Number(event.currentTarget.value)));
88
94
  if (Number.isFinite(next))
89
95
  write({ ...base, [field.part]: next });
90
- }, type: "number", value: base[field.part] })] }, field.part))), fraction > 0 && (_jsxs("label", { className: "date-picker-field", children: [fraction > 3 ? labels.microsecond : labels.millisecond, _jsx("input", { className: "date-picker-input", inputMode: "numeric", onChange: (event) => write({
96
+ }, type: "number", value: base[field.part] })] }, field.part))), fraction > 0 && (_jsxs("label", { className: "date-picker-field", children: [fraction > 3 ? labels.microsecond : labels.millisecond, _jsx("input", { className: fraction > SHORT_FRACTION ? 'date-picker-input long' : 'date-picker-input', inputMode: "numeric", onChange: (event) => write({
91
97
  ...base,
92
98
  fraction: event.currentTarget.value.replace(/\D/gu, '').slice(0, fraction)
93
- }), value: base.fraction.padEnd(fraction, '0').slice(0, fraction) })] }))] })), _jsxs("div", { className: "date-picker-foot", children: [_jsx(Button, { onClick: () => {
99
+ }), style: fraction > SHORT_FRACTION
100
+ ? { '--date-picker-digits': fraction }
101
+ : undefined, value: base.fraction.padEnd(fraction, '0').slice(0, fraction) })] }))] })), _jsxs("div", { className: "date-picker-foot", children: [_jsx(Button, { onClick: () => {
94
102
  write(nowParts());
95
103
  if (kind === 'date')
96
104
  close();
@@ -102,6 +102,14 @@
102
102
  box-shadow 120ms;
103
103
  }
104
104
 
105
+ /* A fraction field of more digits than 7ch shows whole (microseconds) is
106
+ as wide as its --date-picker-digits, plus a ch for the caret, its padding,
107
+ and its border, so it fits whether the page sizes boxes by content or
108
+ border. */
109
+ .date-picker-input.long {
110
+ width: calc((var(--date-picker-digits) + 1) * 1ch + 18px);
111
+ }
112
+
105
113
  .date-picker-input:focus-visible {
106
114
  outline: none;
107
115
  border-color: var(--accent);
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * The colour arithmetic the theme tokens are derived with: sRGB hex colours,
3
- * mixes, translucent forms, and WCAG 2 contrast ratios. Pure, with no DOM, so
4
- * the token generator, tests, and a host process that paints a window's
5
- * ground before any stylesheet loads can share it.
3
+ * mixes, translucent forms, WCAG 2 contrast ratios, and the picks of a tone
4
+ * that keeps a ratio (`firstLegible`, `legibleOn`). Pure, with no DOM, so the
5
+ * token generator, an app deriving tokens of its own, tests, and a host
6
+ * process that paints a window's ground before any stylesheet loads can
7
+ * share it.
6
8
  */
7
9
  /** An opaque colour as six lowercase hex digits, the form every palette entry takes. */
8
10
  export type Hex = `#${string}`;
@@ -27,3 +29,20 @@ export declare function translucent(hex: Hex, opacity: number): string;
27
29
  export declare function luminance(hex: Hex): number;
28
30
  /** WCAG 2 contrast ratio between two opaque colours, 1 to 21. */
29
31
  export declare function contrast(a: Hex, b: Hex): number;
32
+ /**
33
+ * The first of `candidates` that keeps a WCAG contrast of at least `ratio`
34
+ * on every one of `grounds`, else the last candidate, which a caller orders
35
+ * as the strongest; white when `candidates` is empty. Picks the quietest
36
+ * tone of a ramp that still reads: `firstLegible([palette.overlay0,
37
+ * palette.overlay1, palette.subtext0], [palette.base], 4.5)`.
38
+ */
39
+ export declare function firstLegible(candidates: readonly Hex[], grounds: readonly Hex[], ratio: number): Hex;
40
+ /**
41
+ * `color` itself when it keeps a WCAG contrast of at least `ratio` on every
42
+ * one of `grounds`, else `color` mixed toward black (over a light first
43
+ * ground) or white (over a dark one) a percent at a time until it does, so
44
+ * the hue survives as far as legibility allows; pure black or white when no
45
+ * mix keeps `ratio`. 4.5 suits text, 3 a mark read by shape alone:
46
+ * `legibleOn(palette.red, [palette.base], 4.5)`.
47
+ */
48
+ export declare function legibleOn(color: Hex, grounds: readonly Hex[], ratio: number): Hex;
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * The colour arithmetic the theme tokens are derived with: sRGB hex colours,
3
- * mixes, translucent forms, and WCAG 2 contrast ratios. Pure, with no DOM, so
4
- * the token generator, tests, and a host process that paints a window's
5
- * ground before any stylesheet loads can share it.
3
+ * mixes, translucent forms, WCAG 2 contrast ratios, and the picks of a tone
4
+ * that keeps a ratio (`firstLegible`, `legibleOn`). Pure, with no DOM, so the
5
+ * token generator, an app deriving tokens of its own, tests, and a host
6
+ * process that paints a window's ground before any stylesheet loads can
7
+ * share it.
6
8
  */
7
9
  const HEX_COLOR = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/;
8
10
  /** The channels of a six-digit hex colour; throws on any other form, so a palette typo fails loudly. */
@@ -50,3 +52,36 @@ export function contrast(a, b) {
50
52
  const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x);
51
53
  return ((light ?? 0) + 0.05) / ((dark ?? 0) + 0.05);
52
54
  }
55
+ const WHITE = '#ffffff';
56
+ const BLACK = '#000000';
57
+ /** Whether `tone` keeps `ratio` on every one of `grounds`. */
58
+ function legibleOnAll(tone, grounds, ratio) {
59
+ return grounds.every((ground) => contrast(tone, ground) >= ratio);
60
+ }
61
+ /**
62
+ * The first of `candidates` that keeps a WCAG contrast of at least `ratio`
63
+ * on every one of `grounds`, else the last candidate, which a caller orders
64
+ * as the strongest; white when `candidates` is empty. Picks the quietest
65
+ * tone of a ramp that still reads: `firstLegible([palette.overlay0,
66
+ * palette.overlay1, palette.subtext0], [palette.base], 4.5)`.
67
+ */
68
+ export function firstLegible(candidates, grounds, ratio) {
69
+ return (candidates.find((tone) => legibleOnAll(tone, grounds, ratio)) ?? candidates.at(-1) ?? WHITE);
70
+ }
71
+ /**
72
+ * `color` itself when it keeps a WCAG contrast of at least `ratio` on every
73
+ * one of `grounds`, else `color` mixed toward black (over a light first
74
+ * ground) or white (over a dark one) a percent at a time until it does, so
75
+ * the hue survives as far as legibility allows; pure black or white when no
76
+ * mix keeps `ratio`. 4.5 suits text, 3 a mark read by shape alone:
77
+ * `legibleOn(palette.red, [palette.base], 4.5)`.
78
+ */
79
+ export function legibleOn(color, grounds, ratio) {
80
+ const away = luminance(grounds[0] ?? WHITE) > 0.18 ? BLACK : WHITE;
81
+ for (let share = 100; share > 0; share -= 1) {
82
+ const tone = mix(color, away, share);
83
+ if (legibleOnAll(tone, grounds, ratio))
84
+ return tone;
85
+ }
86
+ return away;
87
+ }
@@ -7,6 +7,6 @@
7
7
  */
8
8
  export { subscribeThemeChange, wearThemes } from './attributes.js';
9
9
  export { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, THEMES, themeById, type GroupHue, type TerminalPalette, type Theme, type ThemePalette } from './catalog.js';
10
- export { contrast, hexOf, luminance, mix, rgbOf, translucent, type Hex, type Rgb } from './color.js';
10
+ export { contrast, firstLegible, hexOf, legibleOn, luminance, mix, rgbOf, translucent, type Hex, type Rgb } from './color.js';
11
11
  export { DARK_THEME_IDS, DEFAULT_DARK_THEME_ID, DEFAULT_LIGHT_THEME_ID, isDarkThemeId, isLightThemeId, LIGHT_THEME_IDS, THEME_ATTRIBUTES, THEME_ENTRIES, THEME_PREVIEW_ATTRIBUTE, type AppearanceThemes, type DarkThemeId, type LightThemeId, type ThemeAppearance, type ThemeEntry, type ThemeId } from './ids.js';
12
12
  export { FIXED_TOKENS, PREVIEW_TOKENS, previewTokens, themeStylesheet, themeTokens, type ThemeOverrides, type ThemeStylesheetOptions, type ThemeTokenName, type ThemeTokens } from './tokens.js';
@@ -7,6 +7,6 @@
7
7
  */
8
8
  export { subscribeThemeChange, wearThemes } from './attributes.js';
9
9
  export { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, THEMES, themeById } from './catalog.js';
10
- export { contrast, hexOf, luminance, mix, rgbOf, translucent } from './color.js';
10
+ export { contrast, firstLegible, hexOf, legibleOn, luminance, mix, rgbOf, translucent } from './color.js';
11
11
  export { DARK_THEME_IDS, DEFAULT_DARK_THEME_ID, DEFAULT_LIGHT_THEME_ID, isDarkThemeId, isLightThemeId, LIGHT_THEME_IDS, THEME_ATTRIBUTES, THEME_ENTRIES, THEME_PREVIEW_ATTRIBUTE } from './ids.js';
12
12
  export { FIXED_TOKENS, PREVIEW_TOKENS, previewTokens, themeStylesheet, themeTokens } from './tokens.js';
@@ -18,7 +18,7 @@
18
18
  * both sets under the same selectors.
19
19
  */
20
20
  import { DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, THEMES } from './catalog.js';
21
- import { contrast, luminance, mix, translucent } from './color.js';
21
+ import { contrast, firstLegible, legibleOn, luminance, mix, translucent } from './color.js';
22
22
  import { THEME_ATTRIBUTES, THEME_PREVIEW_ATTRIBUTE } from './ids.js';
23
23
  const WHITE = '#ffffff';
24
24
  const BLACK = '#000000';
@@ -58,31 +58,6 @@ const BY_APPEARANCE = {
58
58
  terminalSelection: 28
59
59
  }
60
60
  };
61
- /** Whether `tone` keeps `ratio` on every one of `grounds`. */
62
- function legibleOnAll(tone, grounds, ratio) {
63
- return grounds.every((ground) => contrast(tone, ground) >= ratio);
64
- }
65
- /**
66
- * The first of `candidates` that keeps `ratio` on every one of `grounds`,
67
- * else the last, the strongest.
68
- */
69
- function firstLegible(candidates, grounds, ratio) {
70
- return (candidates.find((tone) => legibleOnAll(tone, grounds, ratio)) ?? candidates.at(-1) ?? WHITE);
71
- }
72
- /**
73
- * `color` moved away from `grounds` (toward black over light grounds, white
74
- * over dark ones, judged by the first) a percent at a time until it keeps
75
- * `ratio` on every one of them.
76
- */
77
- function legibleOn(color, grounds, ratio) {
78
- const away = luminance(grounds[0] ?? WHITE) > 0.18 ? BLACK : WHITE;
79
- for (let share = 100; share > 0; share -= 1) {
80
- const tone = mix(color, away, share);
81
- if (legibleOnAll(tone, grounds, ratio))
82
- return tone;
83
- }
84
- return away;
85
- }
86
61
  /**
87
62
  * The text colour for a fill: white or the palette's darkest neutral,
88
63
  * whichever stands out more on it.
@@ -351,7 +326,8 @@ function rule(selector, tokens, depth = 0) {
351
326
  * The custom properties `@bigpixelrocket/uiok/styles.css` declares or reads beside the theme
352
327
  * tokens: the base sheet's on `:root`, and the hooks a component stylesheet
353
328
  * declares or reads (the activity stripes' colour, a dialog's tone and
354
- * pinned top), which an app token on `:root` would otherwise reach.
329
+ * pinned top, a date picker fraction field's digit count), which an app
330
+ * token on `:root` would otherwise reach.
355
331
  */
356
332
  const BASE_TOKEN_NAMES = [
357
333
  '--frost',
@@ -370,6 +346,7 @@ const BASE_TOKEN_NAMES = [
370
346
  '--pane-column-gap',
371
347
  '--pane-row-inset',
372
348
  '--pane-grid',
349
+ '--date-picker-digits',
373
350
  '--warning-text'
374
351
  ];
375
352
  /** Every token name uiok defines: the fixed tokens, those a theme sets, and the stylesheet's own. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigpixelrocket/uiok",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A React UI library with a retro look: themeable design tokens and accessible components.",
5
5
  "keywords": [
6
6
  "react",
@@ -10,7 +10,7 @@
10
10
  "themes",
11
11
  "retro"
12
12
  ],
13
- "homepage": "https://github.com/Bigpixelrocket/uiok#readme",
13
+ "homepage": "https://bigpixelrocket.github.io/uiok/",
14
14
  "bugs": {
15
15
  "url": "https://github.com/Bigpixelrocket/uiok/issues"
16
16
  },