Package library as @moduletrace/twui npm package

- Move components/ to src/ and compile to dist/ with tsc
- Add root barrel export plus deep-import subpath exports and base.css export
- Post-compile step: copy base.css, add .js import extensions, mark client modules
- Add publish.sh and .npmrc for the Gitea npm registry
- Fix type errors, guard TinyMCE env access, drop ace-builds type dependency
- Rename clashing props type names, remove Next.js scaffolding and unused deps

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-18 10:17:54 +01:00
co-authored by Claude Opus 5.5
parent d19d412066
commit 11da9b89e7
148 changed files with 937 additions and 500 deletions
+85
View File
@@ -0,0 +1,85 @@
import { describe, expect, test } from "bun:test";
import twuiNumberfy from "./numberfy";
describe("twuiNumberfy", () => {
test("converts a number to number", () => {
expect(twuiNumberfy(42)).toBe(42);
});
test("converts a numeric string to number", () => {
expect(twuiNumberfy("42")).toBe(42);
});
test("strips non-numeric characters", () => {
expect(twuiNumberfy("$1,234.56")).toBe(1234.56);
});
test("returns 0 for non-numeric string", () => {
expect(twuiNumberfy("hello")).toBe(0);
});
test("returns 0 for undefined input", () => {
expect(twuiNumberfy(undefined)).toBe(0);
});
test("returns 0 for null input", () => {
expect(twuiNumberfy(null)).toBe(0);
});
test("rounds with decimals=0", () => {
expect(twuiNumberfy(3.7, 0)).toBe(4);
});
test("rounds with decimals=0 (floor case)", () => {
expect(twuiNumberfy(3.2, 0)).toBe(3);
});
test("limits decimal places", () => {
expect(twuiNumberfy(3.14159, 2)).toBe(3.14);
});
test("preserves existing decimals when no decimals param", () => {
expect(twuiNumberfy("3.14")).toBe(3.14);
});
test("rounds integers when no decimals param and no existing decimals", () => {
expect(twuiNumberfy("42")).toBe(42);
});
test("strips minus sign (does not support negatives)", () => {
expect(twuiNumberfy("-5")).toBe(5);
});
test("handles string with currency symbol", () => {
expect(twuiNumberfy("₦50,000")).toBe(50000);
});
test("handles empty string", () => {
expect(twuiNumberfy("")).toBe(0);
});
test("handles boolean true", () => {
expect(twuiNumberfy(true)).toBe(0);
});
test("handles boolean false", () => {
expect(twuiNumberfy(false)).toBe(0);
});
test("handles string with percentage", () => {
expect(twuiNumberfy("75%")).toBe(75);
});
test("handles multiple decimal points (results in NaN -> 0)", () => {
const result = twuiNumberfy("1.2.3");
expect(result).toBe(0);
});
test("handles zero", () => {
expect(twuiNumberfy(0)).toBe(0);
});
test("handles very large numbers", () => {
expect(twuiNumberfy("9999999999")).toBe(9999999999);
});
});