@jcsoftdev/ui 0.2.1 → 0.2.3

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
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.3 (2026-10-13)
4
+
5
+ ### Fixes
6
+
7
+ - **Checkbox looks like a checkbox.** The box is square (`rounded-xs`, the 4px small-radius token, 3px in the compact theme) instead of a circle, and the checked and indeterminate fill is the accent (as in Switch and the selected RadioGroup row) instead of the success green. Round plus green read as a radio button in multi-select lists. Sizes, 44px touch hit area, focus ring, disabled state and the `box`/`indicator`/`icon` parts are unchanged; The indeterminate state draws a dash instead of a check mark, and a disabled checkbox is dimmed (`opacity-50`, `cursor-not-allowed`) like the other form controls. RadioGroup stays round.
8
+
9
+ ## 0.2.2 (2026-10-13)
10
+
11
+ ### Fixes
12
+
13
+ - **`ui-theme build --no-kotlin` no longer builds Kotlin.** It used to generate `Theme.kt` and discard it, so `var(...)` and `oklch(...)` colors still threw "Unsupported color for Kotlin". Without the flag, the error now names the token and suggests `--no-kotlin`.
14
+
15
+ ### Added
16
+
17
+ - **`@jcsoftdev/ui/theme-builder`** exports `buildTheme`, `buildTokensCss`, `buildThemeCss`, `buildFontsCss` and `buildThemeKt`, typed. `buildTheme` takes `kotlin: false` to skip `Theme.kt`.
18
+
3
19
  ## 0.2.1 (2026-10-13)
4
20
 
5
21
  ### Fixes
package/bin/ui-theme.mjs CHANGED
@@ -7,7 +7,8 @@ import { buildTheme } from "../scripts/build-theme.mjs";
7
7
  const USAGE = `Usage: ui-theme build [tokens.json] --out <dir> [--kotlin-package <pkg>] [--no-kotlin]
8
8
 
9
9
  Generates tokens.css, theme.css, fonts.css and Theme.kt from a tokens file.
10
- Without a tokens file the bundled default theme is used.`;
10
+ Without a tokens file the bundled default theme is used.
11
+ --no-kotlin skips Theme.kt, so tokens with var() or oklch() colors build.`;
11
12
 
12
13
  const args = process.argv.slice(2);
13
14
  const flag = (name) => {
@@ -35,11 +36,13 @@ if (command !== "build" || !out) {
35
36
 
36
37
  const here = dirname(fileURLToPath(import.meta.url));
37
38
  const file = resolve(tokensFlag ?? positional ?? join(here, "../tokens/default.json"));
38
- const files = buildTheme(JSON.parse(readFileSync(file, "utf8")), { kotlinPackage });
39
+ const files = buildTheme(JSON.parse(readFileSync(file, "utf8")), {
40
+ kotlinPackage,
41
+ kotlin: !noKotlin,
42
+ });
39
43
 
40
44
  mkdirSync(resolve(out), { recursive: true });
41
45
  for (const [name, content] of Object.entries(files)) {
42
- if (noKotlin && name.endsWith(".kt")) continue;
43
46
  writeFileSync(join(resolve(out), name), content);
44
47
  console.log(`wrote ${join(out, name)}`);
45
48
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useRef } from "react";
4
- import { Check } from "../../icons/index.js";
4
+ import { Check, Minus } from "../../icons/index.js";
5
5
  import { cn } from "../../utils/cn.js";
6
6
  import { composeHandlers, useComposedRefs } from "../../utils/compose.js";
7
7
  import { BubbleInput, useFormBubble, useFormReset } from "../../utils/form-bubble.js";
@@ -51,7 +51,7 @@ function Checkbox({
51
51
  ...props,
52
52
  ref: composedRef,
53
53
  className: cn(
54
- "group inline-flex size-10 shrink-0 items-center justify-center in-data-[density=touch]:size-11",
54
+ "group inline-flex size-10 shrink-0 items-center justify-center in-data-[density=touch]:size-11 disabled:cursor-not-allowed disabled:opacity-50",
55
55
  classNames?.root,
56
56
  className
57
57
  ),
@@ -66,7 +66,7 @@ function Checkbox({
66
66
  "span",
67
67
  {
68
68
  className: cn(
69
- "grid size-4.5 place-items-center rounded-pill border-[1.5px] border-line-strong group-data-[state=checked]:border-success group-data-[state=checked]:bg-success group-data-[state=indeterminate]:border-success group-data-[state=indeterminate]:bg-success",
69
+ "grid size-4.5 place-items-center rounded-xs border-[1.5px] border-line-strong group-data-[state=checked]:border-accent group-data-[state=checked]:bg-accent group-data-[state=indeterminate]:border-accent group-data-[state=indeterminate]:bg-accent",
70
70
  classNames?.box
71
71
  ),
72
72
  children: checked === false ? null : /* @__PURE__ */ jsx(
@@ -76,7 +76,13 @@ function Checkbox({
76
76
  "data-disabled": disabledAttr,
77
77
  style: { pointerEvents: "none" },
78
78
  className: classNames?.indicator,
79
- children: /* @__PURE__ */ jsx(
79
+ children: checked === "indeterminate" ? /* @__PURE__ */ jsx(
80
+ Minus,
81
+ {
82
+ "aria-hidden": "true",
83
+ className: cn("size-2.75 stroke-[3] text-on-accent", classNames?.icon)
84
+ }
85
+ ) : /* @__PURE__ */ jsx(
80
86
  Check,
81
87
  {
82
88
  "aria-hidden": "true",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcsoftdev/ui",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Token-driven React component library: React 19, Tailwind v4.",
5
5
  "author": "jcsoftdev",
6
6
  "license": "MIT",
@@ -45,6 +45,7 @@
45
45
  "bin",
46
46
  "icons",
47
47
  "scripts/build-theme.mjs",
48
+ "scripts/build-theme.d.ts",
48
49
  "README.md",
49
50
  "CHANGELOG.md",
50
51
  "THIRD_PARTY_NOTICES.md",
@@ -54,6 +55,10 @@
54
55
  "./styles/*": "./styles/*",
55
56
  "./tokens/*": "./tokens/*",
56
57
  "./package.json": "./package.json",
58
+ "./theme-builder": {
59
+ "types": "./scripts/build-theme.d.ts",
60
+ "import": "./scripts/build-theme.mjs"
61
+ },
57
62
  "./rich-text": {
58
63
  "types": "./dist/rich-text/index.d.ts",
59
64
  "source": "./src/rich-text/index.ts",
@@ -0,0 +1,18 @@
1
+ export interface ThemeTokens {
2
+ name: string;
3
+ [group: string]: unknown;
4
+ }
5
+
6
+ export interface BuildThemeOptions {
7
+ kotlin?: boolean;
8
+ kotlinPackage?: string;
9
+ }
10
+
11
+ export function buildTokensCss(tokens: ThemeTokens): string;
12
+ export function buildThemeCss(tokens: ThemeTokens): string;
13
+ export function buildFontsCss(tokens: ThemeTokens): string;
14
+ export function buildThemeKt(tokens: ThemeTokens, pkg?: string): string;
15
+ export function buildTheme(
16
+ tokens: ThemeTokens,
17
+ options?: BuildThemeOptions,
18
+ ): Record<string, string>;
@@ -341,6 +341,17 @@ export function toKotlinColor(css) {
341
341
  throw new Error(`Unsupported color for Kotlin: ${css}`);
342
342
  }
343
343
 
344
+ const kotlinColorOf = (token, theme, base) => {
345
+ const value = valueFor(token, theme, base);
346
+ try {
347
+ return toKotlinColor(value);
348
+ } catch {
349
+ throw new Error(
350
+ `Token "${token.name}" (${theme}) has a color Kotlin cannot represent: ${value}. Use hex or rgb(a) values, or pass --no-kotlin.`,
351
+ );
352
+ }
353
+ };
354
+
344
355
  const px = (value) => `${Number.parseFloat(value)}.dp`;
345
356
 
346
357
  export function buildThemeKt(tokens, pkg = "com.jcsoftdev.ui.theme") {
@@ -368,7 +379,7 @@ export function buildThemeKt(tokens, pkg = "com.jcsoftdev.ui.theme") {
368
379
  for (const theme of themes) {
369
380
  out.push(` val ${pascal(theme)} = ThemeColors(`);
370
381
  for (const t of colors) {
371
- out.push(` ${camel(t.name)} = ${toKotlinColor(valueFor(t, theme, base))},`);
382
+ out.push(` ${camel(t.name)} = ${kotlinColorOf(t, theme, base)},`);
372
383
  }
373
384
  out.push(" )");
374
385
  }
@@ -387,7 +398,7 @@ export function buildThemeKt(tokens, pkg = "com.jcsoftdev.ui.theme") {
387
398
  const byName = new Map(tokens.color.tokens.map((t) => [t.name, t]));
388
399
  const args = Object.entries(PALETTE_ROLES).map(([role]) => {
389
400
  const tok = byName.get(roles[role]);
390
- return tok ? toKotlinColor(valueFor(tok, theme, base)) : "Color.Unspecified";
401
+ return tok ? kotlinColorOf(tok, theme, base) : "Color.Unspecified";
391
402
  });
392
403
  out.push(` "${id}" to AccentPalette(${args.join(", ")}),`);
393
404
  }
@@ -427,11 +438,12 @@ export function buildThemeKt(tokens, pkg = "com.jcsoftdev.ui.theme") {
427
438
  return out.join("\n");
428
439
  }
429
440
 
430
- export function buildTheme(tokens, { kotlinPackage } = {}) {
431
- return {
441
+ export function buildTheme(tokens, { kotlinPackage, kotlin = true } = {}) {
442
+ const css = {
432
443
  "tokens.css": buildTokensCss(tokens),
433
444
  "theme.css": buildThemeCss(tokens),
434
445
  "fonts.css": buildFontsCss(tokens),
435
- "Theme.kt": buildThemeKt(tokens, kotlinPackage),
436
446
  };
447
+ if (!kotlin) return css;
448
+ return { ...css, "Theme.kt": buildThemeKt(tokens, kotlinPackage) };
437
449
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { type ComponentProps, useRef } from "react";
4
- import { Check } from "../../icons/index.js";
4
+ import { Check, Minus } from "../../icons/index.js";
5
5
  import type { ClassNames } from "../../utils/class-names.js";
6
6
  import { cn } from "../../utils/cn.js";
7
7
  import { composeHandlers, useComposedRefs } from "../../utils/compose.js";
@@ -76,7 +76,7 @@ export function Checkbox({
76
76
  {...props}
77
77
  ref={composedRef}
78
78
  className={cn(
79
- "group inline-flex size-10 shrink-0 items-center justify-center in-data-[density=touch]:size-11",
79
+ "group inline-flex size-10 shrink-0 items-center justify-center in-data-[density=touch]:size-11 disabled:cursor-not-allowed disabled:opacity-50",
80
80
  classNames?.root,
81
81
  className,
82
82
  )}
@@ -91,7 +91,7 @@ export function Checkbox({
91
91
  >
92
92
  <span
93
93
  className={cn(
94
- "grid size-4.5 place-items-center rounded-pill border-[1.5px] border-line-strong group-data-[state=checked]:border-success group-data-[state=checked]:bg-success group-data-[state=indeterminate]:border-success group-data-[state=indeterminate]:bg-success",
94
+ "grid size-4.5 place-items-center rounded-xs border-[1.5px] border-line-strong group-data-[state=checked]:border-accent group-data-[state=checked]:bg-accent group-data-[state=indeterminate]:border-accent group-data-[state=indeterminate]:bg-accent",
95
95
  classNames?.box,
96
96
  )}
97
97
  >
@@ -102,10 +102,17 @@ export function Checkbox({
102
102
  style={{ pointerEvents: "none" }}
103
103
  className={classNames?.indicator}
104
104
  >
105
- <Check
106
- aria-hidden="true"
107
- className={cn("size-2.75 stroke-[3] text-on-accent", classNames?.icon)}
108
- />
105
+ {checked === "indeterminate" ? (
106
+ <Minus
107
+ aria-hidden="true"
108
+ className={cn("size-2.75 stroke-[3] text-on-accent", classNames?.icon)}
109
+ />
110
+ ) : (
111
+ <Check
112
+ aria-hidden="true"
113
+ className={cn("size-2.75 stroke-[3] text-on-accent", classNames?.icon)}
114
+ />
115
+ )}
109
116
  </span>
110
117
  )}
111
118
  </span>