18 Commits
Author SHA1 Message Date
bitbaum-fleet 2674d02f59 release v0.3.3 2026-10-28 06:58:20 +00:00
Cato 1c8cebad06 fix(release): install Chromium before browser verification (#21) 2026-10-28 07:56:03 +01:00
dependabot[bot] d9cf48db67 chore(deps-dev): bump the dev group with 7 updates (#20)
Bumps the dev group with 7 updates:

| Package | From | To |
| --- | --- | --- |
| [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `26.6.4` | `26.6.5` |
| [eslint](https://github.com/eslint/eslint) | `10.12.0` | `10.13.0` |
| [playwright](https://github.com/microsoft/playwright) | `1.63.0` | `1.64.1` |
| [prettier](https://github.com/prettier/prettier) | `3.9.9` | `3.9.10` |
| [react](https://github.com/react/react/tree/HEAD/packages/react) | `19.3.0` | `19.3.1` |
| [react-dom](https://github.com/react/react/tree/HEAD/packages/react-dom) | `19.3.0` | `19.3.1` |
| [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint) | `8.71.1` | `8.72.0` |


Updates `@types/node` from 26.6.4 to 26.6.5
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Updates `eslint` from 10.12.0 to 10.13.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Commits](https://github.com/eslint/eslint/compare/v10.12.0...v10.13.0)

Updates `playwright` from 1.63.0 to 1.64.1
- [Release notes](https://github.com/microsoft/playwright/releases)
- [Commits](https://github.com/microsoft/playwright/compare/v1.63.0...v1.64.1)

Updates `prettier` from 3.9.9 to 3.9.10
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.9.9...3.9.10)

Updates `react` from 19.3.0 to 19.3.1
- [Release notes](https://github.com/react/react/releases)
- [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/react/react/commits/v19.3.1/packages/react)

Updates `react-dom` from 19.3.0 to 19.3.1
- [Release notes](https://github.com/react/react/releases)
- [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/react/react/commits/v19.3.1/packages/react-dom)

Updates `typescript-eslint` from 8.71.1 to 8.72.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.72.0/packages/typescript-eslint)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 26.6.5
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: dev
- dependency-name: eslint
  dependency-version: 10.13.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: dev
- dependency-name: playwright
  dependency-version: 1.64.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: dev
- dependency-name: prettier
  dependency-version: 3.9.10
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: dev
- dependency-name: react
  dependency-version: 19.3.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: dev
- dependency-name: react-dom
  dependency-version: 19.3.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: dev
- dependency-name: typescript-eslint
  dependency-version: 8.72.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: dev
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-28 04:18:02 +01:00
Cato 5d54a255fe chore(deps): dependabot leaves TypeScript 7 alone until typescript-eslint supports it (#19) 2026-10-28 03:30:03 +01:00
Catoandbitbaum-fleet 93d00d526f docs(agents): the org rules block, generated from bitbaum/fleet (#18)
Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
2026-10-28 03:11:22 +01:00
Cato 2cdc2c3c33 ci(publish): the fleet's one publish.yml, with a no-publish check of the npm trusted-publisher link (#17)
Problem: this repo's @bitbaum package was published to npm with a maintainer token, so nothing proves npm trusts this workflow, and the next release is the first test. Change: the fleet's current publish.yml (bitbaum/fleet#314): the same publish path as before, plus a diagnose_auth input on Run workflow that asks npm whether it trusts this workflow for this package (HTTP 200 linked, 404 not) and publishes nothing.
2026-10-28 02:44:33 +01:00
Cato 43127a8dd9 docs(readme): install from npm, the way the registry says (#16)
Problem: the README told a reader to install a Git tag or a raw commit (2 files changed, 15 insertions(+), 1 deletion(-)). The package is on npm and fleet's SHARED.md and registers/packages.json name npm as the install route; a Git pin hides the version and defeats semver updates. Change: the install line is the npm one. Nothing else in the README changed.
2026-10-28 02:41:02 +01:00
Cato 38567ad912 docs: record verified release history and its evidence limits (#15) 2026-10-28 00:21:30 +01:00
Catoandfleet-reconciler 884f2f7f3c chore(deps): raise shared package floors to published versions (#14)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-10-27 12:34:18 +01:00
Catoandbitbaum-fleet 75db86da92 chore: add the fleet package template files this repo is missing (release-notify.yml) (#13)
Files from bitbaum/fleet `templates/package` that this repository does not have yet:

- `.github/workflows/release-notify.yml`

Only missing files are added — no file this repository already has is changed. `release.yml` is what lets the package owner release a new version from Loki (the package page: "Release vX.Y.Z"), or from the Actions tab.

Opened by bitbaum/fleet `scripts/packages/sync-package-template.mjs` (`.github/workflows/package-repos.yml`). It merges itself when this repository's CI is green.

Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
2026-10-26 19:12:28 +01:00
Catoandbitbaum-fleet 3831a8da08 chore: add the fleet package template files this repo is missing (AGENTS.md, CLAUDE.md) (#12)
Files from bitbaum/fleet `templates/package` that this repository does not have yet:

- `AGENTS.md`
- `CLAUDE.md`

Only missing files are added — no file this repository already has is changed. `release.yml` is what lets the package owner release a new version from Loki (the package page: "Release vX.Y.Z"), or from the Actions tab.

Opened by bitbaum/fleet `scripts/packages/sync-package-template.mjs` (`.github/workflows/package-repos.yml`). It merges itself when this repository's CI is green.

Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
2026-10-26 17:47:33 +01:00
Catoandfleet-reconciler f629b49444 chore(deps): raise shared package floors to published versions (#11)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-10-25 19:06:05 +01:00
Catoandbitbaum-fleet 592a184755 chore: add the fleet package template files this repo is missing (dependabot.yml, git-release.yml, release.yml) (#9)
Files from bitbaum/fleet `templates/package` that this repository does not have yet:

- `.github/dependabot.yml`
- `.github/workflows/git-release.yml`
- `.github/workflows/release.yml`

Only missing files are added — no file this repository already has is changed. `release.yml` is what lets the package owner release a new version from Loki (the package page: "Release vX.Y.Z"), or from the Actions tab.

Opened by bitbaum/fleet `scripts/packages/sync-package-template.mjs` (`.github/workflows/package-repos.yml`). It merges itself when this repository's CI is green.

Co-authored-by: bitbaum-fleet <fleet@bitbaum.invalid>
2026-10-25 09:32:30 +01:00
CatoandClaude f204f35f0c ci(publish): publish to npm on merge, first version included (#8)
One publish.yml for every @bitbaum package:
- a merged version bump releases itself (also v* tags, and Run workflow);
- already on npm → tokenless Trusted Publishing (OIDC) with provenance;
- not on npm yet → the first version uses the org secret
  NPM_BOOTSTRAP_TOKEN, then links this workflow as trusted publisher;
- neither → skips green and says what is missing.


Claude-Session: https://claude.ai/code/session_018LMe5Uv6mfWJibAiCaNbbk

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-17 18:04:07 +02:00
CatoandClaude Sonnet 5.5 f5e0a24208 fix: the date box matches a native input exactly; structure survives an app's display:block (0.3.2) (#7)
- line-height: normal (the font's own, like a native input) instead of 1.3,
  and an icon that fits a normal line: the box is now exactly a native
  input's height (38 vs 38; it was 40 vs 38, a visible step in form rows).
- structure rules on span.wk-input so an app's own unlayered class with
  display:block on the same element cannot collapse the stacked layout.
- codemod: an object spread inside onChange is no longer flagged as a JSX
  prop spread.

Both browser checks were first run failing against the old CSS.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-08 06:47:10 -07:00
CatoandClaude Sonnet 5.5 0072fe68aa fix: icon scales with the field's text; codemod skips comments (0.3.1) (#6)
A fixed 20px calendar icon made a dense 12px input taller than its
neighbours (34px vs 30px). The icon is now 1.25em. The browser check has a
compact input and fails on the old icon (it first passed on it — the limit
was exactly the old height; tightened and re-proven).

The codemod no longer edits comments or files already on whenkit (it
rewrote its own shim, whose comment mentioned the tag).

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-08 05:58:32 -07:00
CatoandClaude Sonnet 5.5 9fd8b3b11d chore: codemod to migrate date inputs to DateInput (#5)
A JSX tag scanner (braces, strings, template literals — not a regex over
attributes) that changes <input type=date|datetime-local> to DateInput and
adds one import. Lists what it will not guess. Tested on tricky fixtures,
including the blank-line-after-imports bug its own test caught; a second run
changes nothing.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-08 05:42:11 -07:00
CatoandClaude Sonnet 5.5 0173ac305c feat: DateInput — a drop-in for input type=date / datetime-local (0.3.0) (#4)
Same props and onChange(event) as the native input, so a call site changes
its tag and nothing else. The value shows in words in the app's OWN styling
(className lands on the visible box); the real input stays on top,
transparent, so the picker, keyboard, autofill, validation and form
submission keep working. Controlled or uncontrolled; locale and empty-state
words follow <html lang>.

The look is in @layer base so an app's classes win: unlayered defaults would
have beaten Tailwind v4's layered utilities. A browser check proves both a
plain class and a layered utility win, and fails without the layer.
DateField is now a labelled wrapper on DateInput.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-08 05:13:34 -07:00
34 changed files with 1570 additions and 303 deletions

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 5
ignore:
# typescript-eslint does not support TypeScript 7 yet (CI: "typescript-eslint
# does not support TS 7.0"), so every dev-dependency PR that carries it is red.
# Take it when typescript-eslint does.
- dependency-name: typescript
update-types: ["version-update:semver-major"]
groups:
dev:
dependency-type: development
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 3
+45
View File
@@ -0,0 +1,45 @@
name: Verified Git release
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
permissions:
contents: write
concurrency:
group: verified-git-release
cancel-in-progress: false
jobs:
release:
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_repository.full_name == github.repository &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.event != 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Tag the verified immutable artifact, even before npm bootstrap
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERIFIED_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
set -euo pipefail
version=$(node -p "require('./package.json').version")
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Only stable package versions get a Git release" >&2
exit 1
fi
tag="v$version"
if git show-ref --verify --quiet "refs/tags/$tag"; then
echo "$tag already exists; immutable tags are never moved."
exit 0
fi
git tag "$tag" "$VERIFIED_SHA"
git push origin "refs/tags/$tag"
gh release create "$tag" --repo "$GITHUB_REPOSITORY" \
--verify-tag --title "$tag" --generate-notes
+131 -50
View File
@@ -1,30 +1,45 @@
# prettier-ignore
name: Publish
# Publishing is driven by a version tag, so the released artifact is always
# traceable to a commit. `npm version` creates the tag; pushing it ships.
# The same file in every @bitbaum package. A merged version bump releases
# itself; so does a pushed v* tag, and "Run workflow" re-tries by hand.
#
# Auth is npm Trusted Publishing (OIDC): npmjs.com trusts exactly THIS
# workflow in THIS repo. No token exists anywhere — nothing to store, leak, or
# rotate — and provenance is attested on the registry. `npm publish`
# (npm >= 11.5) exchanges the id-token itself. Copied from chatkit (which copied speechkit and ai-kit).
# Two ways to npm, picked per run:
#
# NOT YET BOOTSTRAPPED. npm cannot trust a publisher for a package that does
# not exist, and the account's second factor is a passkey only a human holds,
# so the FIRST publish is manual (see README → "npm"). Until then every tag
# would fail here — a red run that means nothing is wrong. So the job checks
# the repo variable NPM_PUBLISHING and skips GREEN, saying why, unless it is
# "on". Set it after the bootstrap: gh variable set NPM_PUBLISHING -b on
# - The package is already on npm → tokenless. npmjs.com trusts exactly THIS
# workflow in THIS repo (Trusted Publishing, OIDC): no token exists, nothing
# to leak or rotate, and every release carries a signed provenance statement.
#
# - The package is NOT on npm yet → npm will not trust a publisher for a
# package that does not exist, so the first version needs the account once.
# Put a short-lived npm token in the org secret NPM_BOOTSTRAP_TOKEN (made on
# npmjs.com from a phone; see docs in bitbaum/fleet) and this job publishes
# the first version with it. Without the token it skips GREEN and says so, so
# a new package never paints CI red.
# NOTE (npm docs, `npm trust`): trust commands do NOT accept a granular token,
# not even one with "bypass 2FA" — they need the account's interactive 2FA.
# So the auto-link step below is best-effort and is EXPECTED to fall through
# to the printed fallback. The human step is then ONE form per package on
# npmjs.com (repo + "publish.yml"), or one local `npm trust` loop
# (bootstrap-local.sh, step 2). After that, every release is tokenless.
#
# Publishing is idempotent: a version already on the registry is a green
# no-op, so re-runs and repeat merges are harmless.
on:
push:
tags: ["v*"]
branches: [main]
# The auto-merge sweep re-arms this after a GITHUB_TOKEN merge, which
# starts no push workflow on its own (rearm_workflows in auto-merge.yml).
workflow_dispatch:
inputs:
diagnose_auth:
description: Test the npm trusted-publisher link without publishing anything.
type: boolean
default: false
# Publishing is idempotent: the job first asks the registry whether
# package.json's version already exists and skips (green) if it does. A
# re-pushed tag, a re-run, or two runs for the same version cannot paint a
# spurious E403 red — a red run that means "nothing is wrong" trains everyone
# to ignore the workflow (bip-kit 0.2.6 and 0.2.7, 2026-09-11). Runs are also
# serialised so two cannot race past the check; never cancelled, because a
# cancelled publish is a half-shipped release.
# Never two at once, never cancelled: a cancelled publish is a half-shipped
# release.
concurrency:
group: publish
cancel-in-progress: false
@@ -32,11 +47,11 @@ concurrency:
jobs:
publish:
runs-on: ubuntu-latest
if: vars.NPM_PUBLISHING == 'on'
permissions:
contents: read
# Required for npm provenance — proves on the registry that this tarball
# was built by this workflow from this commit.
# write: tag the released commit v<version> when the release came from
# main rather than from a pushed tag.
contents: write
# Required for OIDC publishing and npm provenance.
id-token: write
steps:
- uses: actions/checkout@v7
@@ -44,33 +59,78 @@ jobs:
# pnpm version comes from "packageManager" in package.json (SSOT).
- uses: pnpm/action-setup@v6
# No registry-url: setup-node would write an _authToken line that makes
# npm skip the OIDC exchange whenever no token is set.
- uses: actions/setup-node@v7
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Is this version already on the registry?
# Trusted publishing and `npm trust` need npm >= 11.10; do not trust
# whatever the runner's Node happens to bundle.
- run: npm install -g npm@11
# "Run workflow" with diagnose_auth ticked asks npm whether it trusts
# THIS workflow for this package, and publishes nothing. HTTP 200 =
# linked; 404 = the one form on npmjs.com is still to be filled in. The
# response body holds a short-lived token, so it is never printed.
- name: Is the npm trusted publisher linked? (no publish)
if: inputs.diagnose_auth == true
run: |
node --input-type=module <<'NODE'
const url = new URL(process.env.ACTIONS_ID_TOKEN_REQUEST_URL);
url.searchParams.set('audience', 'npm:registry.npmjs.org');
const identity = await fetch(url, {
headers: { authorization: `Bearer ${process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN}` },
signal: AbortSignal.timeout(30000),
});
if (!identity.ok) throw new Error(`GitHub OIDC request failed: HTTP ${identity.status}`);
const { value: jwt } = await identity.json();
const claims = JSON.parse(Buffer.from(jwt.split('.')[1], 'base64url'));
console.log('Publisher identity:', JSON.stringify({ repository: claims.repository, workflow_ref: claims.workflow_ref, ref: claims.ref }));
const name = JSON.parse(await (await import('node:fs/promises')).readFile('package.json', 'utf8')).name;
const exchange = await fetch(`https://registry.npmjs.org/-/npm/v1/oidc/token/exchange/package/${encodeURIComponent(name)}`, {
method: 'POST', headers: { authorization: `Bearer ${jwt}` },
signal: AbortSignal.timeout(30000),
});
console.log(`npm trust exchange for ${name}: HTTP ${exchange.status}`);
await exchange.body?.cancel();
if (!exchange.ok) throw new Error('npm does not trust this workflow for this package yet');
NODE
- name: What does npm have?
id: check
if: inputs.diagnose_auth != true
env:
BOOTSTRAP: ${{ secrets.NPM_BOOTSTRAP_TOKEN != '' }}
run: |
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
echo "name=$name" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
if npm view "$name@$version" version >/dev/null 2>&1; then
echo "→ $name@$version is already published; nothing to do."
echo "publish=false" >> "$GITHUB_OUTPUT"
echo "✅ \`$name@$version\` is already published — nothing to do." >> "$GITHUB_STEP_SUMMARY"
else
echo "→ $name@$version is not on the registry; releasing it."
echo "✅ \`$name@$version\` is already on npm — nothing to do." >> "$GITHUB_STEP_SUMMARY"
elif npm view "$name" version >/dev/null 2>&1; then
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "mode=oidc" >> "$GITHUB_OUTPUT"
elif [ "$BOOTSTRAP" = "true" ]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
echo "mode=first" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
{
echo "⏸ \`$name\` is not on npm yet, and its first version needs the account once."
echo "Add the org secret NPM_BOOTSTRAP_TOKEN (a short-lived npm token) and run this workflow again."
echo "Meanwhile it installs from GitHub: \`pnpm add github:${GITHUB_REPOSITORY}\`"
} >> "$GITHUB_STEP_SUMMARY"
fi
- if: steps.check.outputs.publish == 'true'
run: pnpm install --frozen-lockfile --ignore-scripts
# verify includes the real-browser test (test/browser.mjs), as in ci.yml;
# without the browser the v0.2.1 publish failed before reaching npm.
- if: steps.check.outputs.publish == 'true'
# verify includes the real-browser test (test/browser.mjs) where a
# package has one; without the browser it fails before reaching npm.
- if: steps.check.outputs.publish == 'true' && hashFiles('test/browser.mjs') != ''
run: pnpm exec playwright install --with-deps chromium
# Never publish something that would not have passed CI.
@@ -80,7 +140,7 @@ jobs:
# Refuse to publish a tag whose version does not match package.json,
# rather than silently shipping the wrong number.
- name: Check tag matches package version
if: steps.check.outputs.publish == 'true'
if: steps.check.outputs.publish == 'true' && github.ref_type == 'tag'
run: |
tag="${GITHUB_REF_NAME#v}"
pkg=$(node -p "require('./package.json').version")
@@ -89,31 +149,52 @@ jobs:
exit 1
fi
# npm >= 11.5 exchanges the OIDC id-token itself — no secret involved.
- name: Publish to npm (OIDC, tokenless)
- name: Publish to npm
if: steps.check.outputs.publish == 'true'
env:
NAME: ${{ steps.check.outputs.name }}
VERSION: ${{ steps.check.outputs.version }}
MODE: ${{ steps.check.outputs.mode }}
FIRST_TOKEN: ${{ secrets.NPM_BOOTSTRAP_TOKEN }}
run: |
if npm publish; then
if [ "$MODE" = "first" ]; then
# The one token-based publish in a package's life.
echo "//registry.npmjs.org/:_authToken=${FIRST_TOKEN}" > "$RUNNER_TEMP/.npmrc"
export NPM_CONFIG_USERCONFIG="$RUNNER_TEMP/.npmrc"
fi
if npm publish --access public --provenance; then
echo "🚀 Published \`$NAME@$VERSION\`." >> "$GITHUB_STEP_SUMMARY"
elif npm view "$NAME@$VERSION" version >/dev/null 2>&1; then
# The check above and this publish are not atomic. If another run
# slipped between them, the version is on the registry — which is
# the goal state, not an error.
echo "→ $NAME@$VERSION was published by a concurrent run; nothing to do."
echo "✅ \`$NAME@$VERSION\` was published by a concurrent run — nothing to do." >> "$GITHUB_STEP_SUMMARY"
# Another run slipped in between the check and this publish: the
# version is on the registry, which is the goal state.
echo "✅ \`$NAME@$VERSION\` was published by a concurrent run." >> "$GITHUB_STEP_SUMMARY"
else
exit 1
fi
if [ "$MODE" = "first" ]; then
# From now on this workflow publishes without any token.
if npm trust github "$NAME" --file publish.yml --repo "$GITHUB_REPOSITORY" --allow-publish --yes; then
echo "🔗 Linked \`$NAME\` to this workflow — later releases need no token." >> "$GITHUB_STEP_SUMMARY"
else
{
echo "⚠️ Published. npm does not let a token link the workflow (expected)."
echo "Link it once on https://www.npmjs.com/package/$NAME/access → Trusted Publisher → GitHub Actions:"
echo "repository \`$GITHUB_REPOSITORY\`, workflow \`publish.yml\`, tick *Allow npm publish*."
} >> "$GITHUB_STEP_SUMMARY"
fi
fi
rm -f "$RUNNER_TEMP/.npmrc"
# Present only so a tag before the bootstrap reads as a decision, not a
# silent no-op: the run is green and its summary says what to do.
not-yet:
runs-on: ubuntu-latest
if: vars.NPM_PUBLISHING != 'on'
steps:
- run: |
echo "npm publishing is not bootstrapped for this repo yet — nothing published." >> "$GITHUB_STEP_SUMMARY"
echo "Consumers install from git meanwhile: pnpm add github:bitbaum/whenkit#${GITHUB_REF_NAME}" >> "$GITHUB_STEP_SUMMARY"
# A release from main gets its tag here, so every published version is
# still traceable to a commit by name.
- name: Tag the released commit
if: steps.check.outputs.publish == 'true' && github.ref_type != 'tag'
env:
VERSION: ${{ steps.check.outputs.version }}
run: |
if git ls-remote --exit-code --tags origin "refs/tags/v$VERSION" >/dev/null; then
echo "→ v$VERSION already tagged."
else
git tag "v$VERSION" "$GITHUB_SHA"
git push origin "v$VERSION"
fi
+55
View File
@@ -0,0 +1,55 @@
# A release is useful only when the registry and consumers learn about it.
# No checkout or execution of the completed workflow's code: metadata only.
name: Notify Fleet of verified release
on:
workflow_run:
workflows: [CI, Release, Publish]
types: [completed]
permissions:
contents: read
actions: read
concurrency:
group: release-notify
cancel-in-progress: false
jobs:
notify:
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event != 'pull_request' && github.event.workflow_run.head_repository.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Resolve a verified immutable release before requesting reconciliation
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
SHA: ${{ github.event.workflow_run.head_sha }}
FLEET_TOKEN: ${{ secrets.FLEET_PAT }}
shell: bash
run: |
set -euo pipefail
manifest="$(gh api "repos/$GH_REPO/contents/package.json?ref=$SHA" --jq .content | base64 --decode)"
version="$(jq -r .version <<< "$manifest")"
if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
echo 'No stable version; no reconciliation requested.'
exit 0
fi
# Source commits with no matching release tag are not releases.
if ! tagged="$(gh api "repos/$GH_REPO/commits/v$version" --jq .sha 2>/dev/null)" || [ "$tagged" != "$SHA" ]; then
echo 'This commit is not the versioned release; no reconciliation requested.'
exit 0
fi
ci="$(gh api "repos/$GH_REPO/actions/runs?head_sha=$SHA&per_page=100" --jq '[.workflow_runs[] | select(.path == ".github/workflows/ci.yml" and (.event == "push" or .event == "workflow_dispatch"))] | first | .conclusion')"
if [ "$ci" != success ]; then
echo 'Release CI is not successful yet; its completion will retry notification.'
exit 0
fi
if [ -z "$FLEET_TOKEN" ]; then
echo '::error::FLEET_PAT is required to notify Fleet; scheduled reconciliation remains the fallback.'
exit 1
fi
payload="$(jq -n --arg repository "$GH_REPO" --arg version "$version" --arg commit "$SHA" '{event_type:"shared-package-release",client_payload:{repository:$repository,version:$version,commit:$commit}}')"
GH_TOKEN="$FLEET_TOKEN" gh api --method POST repos/bitbaum/fleet/dispatches --input - <<< "$payload"
echo "Requested authoritative registry and consumer reconciliation for $GH_REPO v$version ($SHA)." >> "$GITHUB_STEP_SUMMARY"
+212
View File
@@ -0,0 +1,212 @@
# Release — a new version of this package, from one button.
#
# Rendered from bitbaum/fleet templates/package. Loki's package page starts it
# ("Release vX.Y.Z"), and so can anyone from the Actions tab. It:
#
# 1. refuses unless main's CI is green on the exact commit it starts from,
# 2. raises the version in package.json (the bump, or the exact version
# asked for) — `npm version --no-git-tag-version`, so npm makes no commit
# and no tag of its own,
# 3. runs the package's own `verify`, which rebuilds the committed dist/,
# 4. commits "release vX.Y.Z" with the rebuilt dist/, tags vX.Y.Z, and pushes
# both in one atomic push,
# 5. creates a GitHub release with generated notes.
#
# Consumers pick the tag up through Dependabot (`github:bitbaum/whenkit#vX.Y.Z`),
# and publish.yml ships it to npm once npm publishing is switched on.
#
# WHY THE PUSH USES FLEET_PAT. A push made with GITHUB_TOKEN starts no workflow.
# publish.yml listens for the tag push, and CI must run on the release commit
# (the auto-merge sweep merges nothing onto a main whose CI it cannot see). So
# the release commit and tag are pushed with FLEET_PAT, the org secret every
# bitbaum repo already has (auto-merge.yml passes it to the sweep), and both
# workflows fire exactly as they would for a person's push. Calling publish.yml
# from here instead was the other option and is not the honest one: package
# repos keep the publish.yml they were created with (the template sync adds
# missing files and never rewrites one), so the tag push is the only path every
# repo's publish.yml is guaranteed to answer. No FLEET_PAT → no release, said
# plainly, rather than a tag that silently publishes nothing.
#
# If main is ever protected against direct pushes, FLEET_PAT's identity must be
# allowed to bypass it, or this fails at the push — after verify, before any
# tag exists, so nothing half-ships.
name: Release
run-name: Release ${{ inputs.version != '' && format('v{0}', inputs.version) || inputs.bump }}
on:
workflow_dispatch:
inputs:
bump:
description: Which part of the version to raise (ignored when an exact version is given)
type: choice
options: [patch, minor, major]
default: patch
version:
description: Exact version to release, e.g. 0.3.0 (optional — wins over bump)
type: string
required: false
default: ""
# One release at a time, never cancelled: a cancelled release is a commit
# without its tag, or a tag without its notes.
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: write # the GitHub release (the push itself uses FLEET_PAT)
actions: read # main's CI runs
checks: read
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Only from main
run: |
if [ "$GITHUB_REF" != "refs/heads/main" ]; then
echo "::error::A release starts from main, not $GITHUB_REF."
exit 1
fi
- name: FLEET_PAT is available
env:
PAT: ${{ secrets.FLEET_PAT }}
run: |
if [ -z "$PAT" ]; then
echo "::error::FLEET_PAT is not available to this repo. A tag pushed without it starts no workflow, so publish.yml would never run — refusing instead."
exit 1
fi
# The commit this run would release is github.sha: main's head when the
# run was started. Its CI must have FINISHED green — running is not green,
# and no run at all is not green either.
- name: Main's CI is green on this commit
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
SHA: ${{ github.sha }}
run: |
set -euo pipefail
run="$(gh run list --workflow ci.yml --branch main --commit "$SHA" --limit 1 \
--json status,conclusion,url --jq '.[0] // empty')"
if [ -z "$run" ]; then
echo "::error::CI has not run on main at ${SHA:0:7}. Nothing proves this commit works, so it is not released."
exit 1
fi
status="$(jq -r .status <<<"$run")"
conclusion="$(jq -r .conclusion <<<"$run")"
url="$(jq -r .url <<<"$run")"
if [ "$status" != "completed" ]; then
echo "::error::CI is still running on ${SHA:0:7} ($url). Start the release again when it finishes."
exit 1
fi
if [ "$conclusion" != "success" ]; then
echo "::error::CI on ${SHA:0:7} ended '$conclusion' ($url). Fix main first; a red commit is not released."
exit 1
fi
echo "CI on ${SHA:0:7} is green: $url"
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
token: ${{ secrets.FLEET_PAT }}
fetch-depth: 0
fetch-tags: true
# pnpm version comes from "packageManager" in package.json (SSOT).
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version: "24"
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Install Chromium when the package uses Playwright
run: |
if node -e 'const p = require("./package.json"); const d = { ...p.dependencies, ...p.devDependencies }; process.exit(d.playwright || d["@playwright/test"] ? 0 : 1)'; then
pnpm exec playwright install --with-deps chromium
fi
# Inputs reach the shell as environment variables, never pasted into the
# script: a `version` is free text typed by whoever started the run.
- name: Decide the version
id: version
env:
BUMP: ${{ inputs.bump }}
EXACT: ${{ inputs.version }}
run: |
set -euo pipefail
next="$(node -e '
const cur = require("./package.json").version;
const bump = process.env.BUMP, exact = process.env.EXACT.trim().replace(/^v/, "");
const parse = (v) => /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.exec(v)?.slice(1).map(Number);
const c = parse(cur);
if (!c) { console.error(`package.json version "${cur}" is not x.y.z`); process.exit(1); }
let n;
if (exact) {
n = parse(exact);
if (!n) { console.error(`"${exact}" is not a version like 0.3.0`); process.exit(1); }
} else if (bump === "major") n = [c[0] + 1, 0, 0];
else if (bump === "minor") n = [c[0], c[1] + 1, 0];
else if (bump === "patch") n = [c[0], c[1], c[2] + 1];
else { console.error(`bump must be patch, minor or major, not "${bump}"`); process.exit(1); }
const cmp = n[0] - c[0] || n[1] - c[1] || n[2] - c[2];
if (cmp <= 0) { console.error(`${n.join(".")} is not newer than ${cur}`); process.exit(1); }
console.log(n.join("."));
')"
if git rev-parse -q --verify "refs/tags/v$next" >/dev/null \
|| [ -n "$(git ls-remote --tags origin "refs/tags/v$next")" ]; then
echo "::error::v$next is already tagged. Nothing to do — Loki shows it on the next read."
exit 1
fi
echo "next=$next" >> "$GITHUB_OUTPUT"
echo "Releasing v$next (package.json was $(node -p 'require("./package.json").version'))."
- name: Raise the version
env:
NEXT: ${{ steps.version.outputs.next }}
run: npm version "$NEXT" --no-git-tag-version
# The package's own gate. It rebuilds dist/, which is committed so a
# `github:` install needs no build step.
- run: pnpm run verify
- name: Commit, tag and push
env:
NEXT: ${{ steps.version.outputs.next }}
run: |
set -euo pipefail
# Only the version and the build it implies may change. Anything else
# means verify rewrote source, and that is a change to review, not to
# release.
stray="$(git status --porcelain --untracked-files=all | awk '{print $2}' | grep -v -E '^(package\.json|dist/)' || true)"
if [ -n "$stray" ]; then
echo "::error::verify changed files outside package.json and dist/: $stray"
exit 1
fi
git config user.name "bitbaum-fleet"
git config user.email "fleet@bitbaum.invalid"
git add package.json dist
git commit -q -m "release v$NEXT"
git tag -a "v$NEXT" -m "v$NEXT"
# Atomic: the commit and the tag land together or not at all. A main
# that moved since this run started refuses the push (not a fast
# forward), and the release is simply started again.
git push --atomic origin "HEAD:refs/heads/main" "refs/tags/v$NEXT"
- name: GitHub release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
NEXT: ${{ steps.version.outputs.next }}
run: |
set -euo pipefail
gh release create "v$NEXT" --verify-tag --title "v$NEXT" --generate-notes
{
echo "## Released v$NEXT"
echo
echo "Install: \`github:$GITHUB_REPOSITORY#v$NEXT\`. Dependabot proposes it to every project that uses this package."
} >> "$GITHUB_STEP_SUMMARY"
+46
View File
@@ -0,0 +1,46 @@
# Agents
<!-- fleet:rules:begin — generated from bitbaum/fleet templates/agent-rules.md; edit it there, not here -->
## Org rules
Read `bitbaum/fleet` `AGENTS.md`, `SHARED.md` and the registers it names before
inventing a host, a name, a page or a shared behaviour. Do not copy their facts
into this file.
- **Packages first.** If a `@bitbaum/*` package (or `bip-kit`, `limitkit`,
`threadkit`, `ai-forms`) already does it, use it and fix a defect in the
package, not in this app. Every chat is `@bitbaum/chatkit`, every search box
`@bitbaum/searchkit`, every chart `@bitbaum/chartkit`, accounts
`@bitbaum/accountkit`, model calls `@bitbaum/ai-kit`. Review this product's
`package-plan.json` before building anything.
- **One shape per kind.** Things of the same kind look the same and sit in the
same place (fleet `AGENTS.md`, "One shape per kind").
- **Finished work ships by itself.** Open a non-draft pull request; the fleet
auto-merge sweep is the only merge path. Never merge by hand, through the
merge API, with `--auto` or with an admin bypass, and never force-push a
shared branch.
- **Nothing made up.** A fact on a page or in a doc needs a source that was
opened; where there is none, the line is removed or softened.
- **Bitcoin orange is for Bitcoin and top-of-funnel actions only.**
- **No model identifier** in anything pushed to a repository.
- Before you finish, run `node <fleet>/scripts/ci/docs-truth-audit.mjs --dir .`:
the same check the sweep runs on every pull request.
<!-- fleet:rules:end -->
Read `bitbaum/fleet` `AGENTS.md` and `SHARED.md` for shared-package ownership,
release and merge policy. Repository-specific instructions belong below.
This repository owns a reusable package. Fix shared defects here, verify the
package's public exports and affected consumer behavior, release through its
verified release workflow, then update consumers. Preserve product-specific
roles, tenancy, provider configuration and domain behavior in app adapters.
Before adding another implementation, inspect Fleet's package registry for an
existing owner. Shared authentication belongs to `@bitbaum/accountkit`, chat
behavior to `@bitbaum/chatkit`, and model/provider transport to `@bitbaum/ai-kit`.
Read `package.json` for this package's verification command and run it before
publishing changes. Use Fleet's auto-merge sweep; do not bypass its required
checks or rollout holds with manual merging or built-in `--auto`.
+14
View File
@@ -0,0 +1,14 @@
# Changelog
This retrospective record was added on 2026-10-27 from the immutable sources
linked below. Git commit dates are source dates, not inferred npm publication
dates. A GitHub release does not itself establish npm publication.
Application adoption and deployment evidence are tracked separately.
## 0.3.2
- [Tagged source `v0.3.2`](https://github.com/bitbaum/whenkit/tree/f5e0a24208187091c2ca792008cdd7695a19910f)
- [Source commit](https://github.com/bitbaum/whenkit/commit/f5e0a24208187091c2ca792008cdd7695a19910f), dated 2026-10-08.
No authored release notes were found for this tag when this record was made.
The links identify the verified source; missing feature history is not invented.
+1
View File
@@ -0,0 +1 @@
Read and follow [AGENTS.md](AGENTS.md).
+38 -2
View File
@@ -5,7 +5,7 @@ length chips, a readable date field over the native picker, and a booking
request that resolves to `{ startsAt, endsAt }` in the provider's time zone.
```bash
pnpm add github:bitbaum/whenkit#v0.2.1
pnpm add @bitbaum/whenkit
```
```tsx
@@ -48,6 +48,42 @@ rented by the day. Three decisions replace that:
autofill, a11y) transparent on top of a display that reads "Sat, 11 Oct ·
14:00", and opens the picker on tap.
## Replacing the date inputs you already have
`DateInput` is a drop-in for `<input type="date">` / `type="datetime-local"`:
same props, same `onChange(event)`, so a call site changes its tag and nothing
else.
```tsx
import { DateInput } from "@bitbaum/whenkit/react";
import "@bitbaum/whenkit/styles.css";
// before: <input type="date" value={due} onChange={(e) => setDue(e.target.value)} className="input" />
<DateInput value={due} onChange={(e) => setDue(e.target.value)} className="input" />;
```
Your own `className` lands on the visible box, and it wins: whenkit's look sits
in `@layer base`, below Tailwind utilities and plain app CSS. The real input
stays on top, invisible, so the picker, keyboard entry, autofill, `required`
validation and form submission all keep working. Controlled (`value`) or
uncontrolled (`defaultValue` + `name`, e.g. a server-action form). The empty
state and weekday/month words follow `<html lang>` (or pass `locale` /
`placeholder`).
### Migrating a repo
```bash
# one re-export per app: components/ui/date-input.tsx
# "use client"; import "@bitbaum/whenkit/styles.css"; export { DateInput } from "@bitbaum/whenkit/react";
node node_modules/@bitbaum/whenkit/scripts/migrate-date-inputs.mjs src --import "@/components/ui/date-input" # dry run
node node_modules/@bitbaum/whenkit/scripts/migrate-date-inputs.mjs src --import "@/components/ui/date-input" --write # apply
```
It changes the tag and adds one import — nothing else — and lists what it will
not guess (spread props, a dynamic `type={…}`). `--from Input` converts an
app's own wrapper component instead of the raw `<input>`. Tested on tricky
fixtures (`test/codemod.test.js`); a second run changes nothing.
## Rules it enforces
- Dates are `YYYY-MM-DD`, times `HH:MM` — wall-clock strings. They become an
@@ -71,7 +107,7 @@ rented by the day. Three decisions replace that:
`type BookingChoice`.
**React** (`@bitbaum/whenkit/react`): `BookingRequestPicker`, `DayStrip`,
`ChipGroup`, `DateField`.
`ChipGroup`, `DateInput`, `DateField` (a `DateInput` with its own label).
**Look** (`@bitbaum/whenkit/styles.css`): `--wk-*` variables default to
`@bitbaum/design-tokens`; set them once to match any other app.
+17 -1
View File
@@ -1,7 +1,7 @@
// Visual + browser check page. Not shipped.
import { useState } from "react";
import { createRoot } from "react-dom/client";
import { BookingRequestPicker, DateField } from "../src/react/index.js";
import { BookingRequestPicker, DateField, DateInput } from "../src/react/index.js";
import { resolveRequest, todayIn, type BookingChoice } from "../src/index.js";
const ZONE = "Europe/Zurich";
@@ -43,3 +43,19 @@ createRoot(document.getElementById("dialog")!).render(
</button>
</>,
);
createRoot(document.getElementById("own-class")!).render(
<DateInput className="app-input" defaultValue="2026-10-11" id="own" />,
);
createRoot(document.getElementById("match-date")!).render(
<DateInput className="match-input" defaultValue="2026-10-11" id="match" />,
);
createRoot(document.getElementById("block-class")!).render(
<DateInput className="block-input" defaultValue="2026-10-11" id="blocked" />,
);
createRoot(document.getElementById("compact-class")!).render(
<DateInput className="compact-input" defaultValue="2026-10-11" id="compact" />,
);
createRoot(document.getElementById("util-class")!).render(
<DateInput className="util-input" defaultValue="2026-10-11" id="util" />,
);
+45
View File
@@ -47,6 +47,41 @@
background: hsl(var(--surface-base, 0 0% 100%));
box-sizing: border-box;
}
/* An app's OWN input class, unlayered plain CSS and a layered utility: both
must beat whenkit's defaults (they live in @layer base). */
.app-input {
padding: 2px 6px;
border: 3px solid rgb(255, 0, 0);
border-radius: 0;
}
/* A dense app input: 12px text, tight padding (e.g. Loki's ui-input-tight). */
.compact-input {
font-size: 12px;
padding: 6px 10px;
line-height: 1.3;
}
@layer utilities {
.util-input {
border-width: 5px;
border-style: dashed;
border-color: rgb(0, 0, 255);
}
}
/* An app's input, applied to a native input AND to DateInput: they must end up
the same height (a serif so its natural line height differs from 1.3). */
.match-input {
font-family: Georgia, serif;
font-size: 14px;
padding: 10px 14px;
border: 1.5px solid rgb(150, 150, 150);
border-radius: 10px;
width: 100%;
box-sizing: border-box;
}
/* A hostile app class: display:block on the same element (unlayered, later). */
.block-input {
display: block;
}
.resolved {
font-size: 11px;
opacity: 0.5;
@@ -71,6 +106,16 @@
<div id="field"></div>
</section>
</div>
<div class="grid" style="margin-top: 24px">
<section><div id="own-class"></div></section>
<section><div id="util-class"></div></section>
<section><div id="compact-class"></div></section>
<section>
<input id="match-native" class="match-input" value="Bello" />
<div id="match-date" style="margin-top: 8px"></div>
</section>
<section><div id="block-class"></div></section>
</div>
<div class="dialog-like" id="dialog"></div>
</main>
<script src="./dist/demo.js"></script>
+3 -1
View File
@@ -1,3 +1,4 @@
import { describeValue } from "./DateInput.js";
export interface DateFieldProps {
label: string;
/** `YYYY-MM-DD` (date) or `YYYY-MM-DDTHH:MM` (withTime), or "" when empty. */
@@ -13,6 +14,7 @@ export interface DateFieldProps {
hint?: string;
className?: string;
}
export declare function describeFieldValue(value: string, withTime: boolean, locale?: string): string;
/** Kept for callers of 0.1–0.2: the words for a value, or "" if invalid. */
export declare const describeFieldValue: typeof describeValue;
export declare function DateField({ label, value, onChange, withTime, min, max, required, name, placeholder, locale, hint, className, }: DateFieldProps): import("react").JSX.Element;
//# sourceMappingURL=DateField.d.ts.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../src/react/DateField.tsx"],"names":[],"mappings":"AAoBA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAO,GAAG,MAAM,CAa1F;AAED,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,GAAG,EACH,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,MAAa,EACb,IAAI,EACJ,SAAS,GACV,EAAE,cAAc,+BA0DhB"}
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../src/react/DateField.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAa,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,sBAAgB,CAAC;AAEhD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,GAAG,EACH,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,MAAM,EACN,IAAI,EACJ,SAAS,GACV,EAAE,cAAc,+BA2BhB"}
+8 -37
View File
@@ -1,48 +1,19 @@
"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* A date (or date + time) field that reads like a sentence and picks like the
* phone does.
*
* The native picker is the best one there is on a phone — what looked bad
* across the fleet was the raw field around it: the browser's locale
* placeholder ("tt.mm.jjjj, --:--"), unstyled, different in every browser.
* So the native input stays (keyboard entry, a11y, autofill all keep
* working) and sits transparently over a display that says "Sat, 11 Oct ·
* 14:00". A tap anywhere opens the platform picker via `showPicker()`.
* A labelled date (or date + time) field: `DateInput` with its own label and
* an optional hint, for places that do not already have a form-field wrapper.
* Apps that do (most) use `DateInput` directly.
*
* Values are `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM` wall-clock strings — exactly
* what the native input speaks — never instants.
*/
import { useId } from "react";
import { dayLabel, formatTime } from "../labels.js";
import { isISODate, isWallTime } from "../calendar.js";
export function describeFieldValue(value, withTime, locale = "en") {
const [date, time] = value.split("T");
if (!isISODate(date))
return "";
const day = dayLabel(date, { locale });
const dayText = new Intl.DateTimeFormat(locale, {
timeZone: "UTC",
weekday: "short",
day: "numeric",
month: "short",
year: "numeric",
}).format(new Date(`${date}T00:00:00Z`));
if (withTime && isWallTime(time))
return `${dayText} · ${formatTime(time, locale)}`;
return dayText || day.short;
}
export function DateField({ label, value, onChange, withTime = false, min, max, required, name, placeholder, locale = "en", hint, className, }) {
import { DateInput, describeValue } from "./DateInput.js";
/** Kept for callers of 0.1–0.2: the words for a value, or "" if invalid. */
export const describeFieldValue = describeValue;
export function DateField({ label, value, onChange, withTime = false, min, max, required, name, placeholder, locale, hint, className, }) {
const id = useId();
const shown = value ? describeFieldValue(value, withTime, locale) : "";
return (_jsxs("div", { className: ["wk-field", className].filter(Boolean).join(" "), children: [_jsx("label", { className: "wk-label", htmlFor: id, children: label }), _jsxs("div", { className: "wk-field-box", "data-empty": shown ? undefined : true, children: [_jsx("span", { className: "wk-field-text", "aria-hidden": "true", children: shown || placeholder || (withTime ? "Pick a day and time" : "Pick a day") }), _jsxs("svg", { className: "wk-field-icon", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [_jsx("rect", { x: "3.5", y: "5", width: "17", height: "15", rx: "2.5", fill: "none", stroke: "currentColor", strokeWidth: "1.6" }), _jsx("path", { d: "M3.5 9.5h17M8 3v4M16 3v4", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })] }), _jsx("input", { id: id, className: "wk-field-input", type: withTime ? "datetime-local" : "date", value: value, min: min, max: max, required: required, name: name, "aria-describedby": hint ? `${id}-hint` : undefined, onChange: (e) => onChange(e.target.value), onClick: (e) => {
try {
e.currentTarget.showPicker?.();
}
catch {
// Not allowed (e.g. cross-origin iframe): native focus still works.
}
} })] }), hint && (_jsx("p", { className: "wk-hint", id: `${id}-hint`, children: hint }))] }));
return (_jsxs("div", { className: ["wk-field", className].filter(Boolean).join(" "), children: [_jsx("label", { className: "wk-label", htmlFor: id, children: label }), _jsx(DateInput, { id: id, type: withTime ? "datetime-local" : "date", value: value, onChange: (e) => onChange(e.target.value), min: min, max: max, required: required, name: name, placeholder: placeholder, locale: locale, "aria-describedby": hint ? `${id}-hint` : undefined }), hint && (_jsx("p", { className: "wk-hint", id: `${id}-hint`, children: hint }))] }));
}
//# sourceMappingURL=DateField.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../src/react/DateField.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAkBvD,MAAM,UAAU,kBAAkB,CAAC,KAAa,EAAE,QAAiB,EAAE,MAAM,GAAG,IAAI;IAChF,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAChC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE;QAC9C,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,OAAO;QAChB,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC;IACzC,IAAI,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,GAAG,OAAO,MAAM,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC;IACpF,OAAO,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,GAAG,EACH,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,MAAM,GAAG,IAAI,EACb,IAAI,EACJ,SAAS,GACM;IACf,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,OAAO,CACL,eAAK,SAAS,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAC/D,gBAAO,SAAS,EAAC,UAAU,EAAC,OAAO,EAAE,EAAE,YACpC,KAAK,GACA,EACR,eAAK,SAAS,EAAC,cAAc,gBAAa,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,aAChE,eAAM,SAAS,EAAC,eAAe,iBAAa,MAAM,YAC/C,KAAK,IAAI,WAAW,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,YAAY,CAAC,GACrE,EACP,eAAK,SAAS,EAAC,eAAe,EAAC,OAAO,EAAC,WAAW,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,aACrF,eACE,CAAC,EAAC,KAAK,EACP,CAAC,EAAC,GAAG,EACL,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,EAAE,EAAC,KAAK,EACR,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,GACjB,EACF,eACE,CAAC,EAAC,0BAA0B,EAC5B,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EACjB,aAAa,EAAC,OAAO,GACrB,IACE,EACN,gBACE,EAAE,EAAE,EAAE,EACN,SAAS,EAAC,gBAAgB,EAC1B,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,EAC1C,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,sBACQ,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,EACjD,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACzC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;4BACb,IAAI,CAAC;gCACH,CAAC,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,CAAC;4BACjC,CAAC;4BAAC,MAAM,CAAC;gCACP,oEAAoE;4BACtE,CAAC;wBACH,CAAC,GACD,IACE,EACL,IAAI,IAAI,CACP,YAAG,SAAS,EAAC,SAAS,EAAC,EAAE,EAAE,GAAG,EAAE,OAAO,YACpC,IAAI,GACH,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
{"version":3,"file":"DateField.js","sourceRoot":"","sources":["../../src/react/DateField.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;GAOG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkB1D,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAEhD,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,GAAG,EACH,GAAG,EACH,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,MAAM,EACN,IAAI,EACJ,SAAS,GACM;IACf,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,OAAO,CACL,eAAK,SAAS,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,aAC/D,gBAAO,SAAS,EAAC,UAAU,EAAC,OAAO,EAAE,EAAE,YACpC,KAAK,GACA,EACR,KAAC,SAAS,IACR,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,EAC1C,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACzC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,MAAM,sBACI,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,GACjD,EACD,IAAI,IAAI,CACP,YAAG,SAAS,EAAC,SAAS,EAAC,EAAE,EAAE,GAAG,EAAE,OAAO,YACpC,IAAI,GACH,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
+34
View File
@@ -0,0 +1,34 @@
/**
* A drop-in for `<input type="date">` and `<input type="datetime-local">`.
*
* Same props, same `onChange(event)` — a call site changes its tag and
* nothing else. What changes is what a person sees: the browser's bare field
* ("tt.mm.jjjj, --:--", different in every browser) is replaced by the value
* in words ("Sat, 11 Oct 2026 · 14:00") in the app's OWN input styling (its
* `className` lands on the visible box), while the real input stays on top,
* transparent, so the platform picker, keyboard entry, autofill, validation
* bubbles and form submission all keep working.
*
* Controlled (`value`) or uncontrolled (`defaultValue`, e.g. a server-action
* form): the visible text follows whichever the app uses.
*/
import { type ChangeEvent, type InputHTMLAttributes } from "react";
export interface DateInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "onChange" | "value" | "defaultValue"> {
/** `date` (default) or `datetime-local`. */
type?: "date" | "datetime-local";
/** `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM`. */
value?: string;
defaultValue?: string;
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
/** Words shown while empty. Defaults to a short phrase in the page language. */
placeholder?: string;
/** BCP 47 tag. Defaults to the page's `<html lang>` (read after mount). */
locale?: string;
/** Applied to the visible box — give it the same classes as the app's inputs. */
className?: string;
}
export declare function emptyWords(locale: string, withTime: boolean): string;
/** "Sat, 11 Oct 2026" or "Sat, 11 Oct 2026 · 14:00"; "" when not a valid value. */
export declare function describeValue(value: string, withTime: boolean, locale?: string): string;
export declare const DateInput: import("react").ForwardRefExoticComponent<DateInputProps & import("react").RefAttributes<HTMLInputElement>>;
//# sourceMappingURL=DateInput.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../src/react/DateInput.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,mBAAmB,EAEzB,MAAM,OAAO,CAAC;AAIf,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,cAAc,CAC/C;IACC,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACjC,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC1D,gFAAgF;IAChF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAGpE;AAED,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAO,GAAG,MAAM,CAWrF;AAWD,eAAO,MAAM,SAAS,6GAiFpB,CAAC"}
+83
View File
@@ -0,0 +1,83 @@
"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* A drop-in for `<input type="date">` and `<input type="datetime-local">`.
*
* Same props, same `onChange(event)` — a call site changes its tag and
* nothing else. What changes is what a person sees: the browser's bare field
* ("tt.mm.jjjj, --:--", different in every browser) is replaced by the value
* in words ("Sat, 11 Oct 2026 · 14:00") in the app's OWN input styling (its
* `className` lands on the visible box), while the real input stays on top,
* transparent, so the platform picker, keyboard entry, autofill, validation
* bubbles and form submission all keep working.
*
* Controlled (`value`) or uncontrolled (`defaultValue`, e.g. a server-action
* form): the visible text follows whichever the app uses.
*/
import { forwardRef, useEffect, useState, } from "react";
import { isISODate, isWallTime } from "../calendar.js";
import { formatTime } from "../labels.js";
const EMPTY_WORDS = {
en: ["Pick a date", "Pick a date and time"],
de: ["Datum wählen", "Datum und Uhrzeit wählen"],
fr: ["Choisir une date", "Choisir la date et l'heure"],
it: ["Scegli una data", "Scegli data e ora"],
es: ["Elegir fecha", "Elegir fecha y hora"],
};
export function emptyWords(locale, withTime) {
const words = EMPTY_WORDS[locale.toLowerCase().split("-")[0]] ?? EMPTY_WORDS.en;
return words[withTime ? 1 : 0];
}
/** "Sat, 11 Oct 2026" or "Sat, 11 Oct 2026 · 14:00"; "" when not a valid value. */
export function describeValue(value, withTime, locale = "en") {
const [date, time] = value.split("T");
if (!isISODate(date))
return "";
const day = new Intl.DateTimeFormat(locale, {
timeZone: "UTC",
weekday: "short",
day: "numeric",
month: "short",
year: "numeric",
}).format(new Date(`${date}T00:00:00Z`));
return withTime && isWallTime(time) ? `${day} · ${formatTime(time, locale)}` : day;
}
/** An unknown tag from <html lang> must never throw during render. */
function safeDescribe(value, withTime, locale) {
try {
return describeValue(value, withTime, locale);
}
catch {
return describeValue(value, withTime, "en");
}
}
export const DateInput = forwardRef(function DateInput({ type = "date", value, defaultValue, onChange, placeholder, locale, className, style, onClick, ...rest }, ref) {
const withTime = type === "datetime-local";
const [inner, setInner] = useState(defaultValue ?? "");
const [lang, setLang] = useState(locale ?? "en");
useEffect(() => {
if (locale)
setLang(locale);
else
setLang(document.documentElement.lang || "en");
}, [locale]);
const current = value ?? inner;
const text = current ? safeDescribe(current, withTime, lang) : "";
const empty = !text;
const handleClick = (event) => {
onClick?.(event);
if (event.defaultPrevented)
return;
try {
event.currentTarget.showPicker?.();
}
catch {
// Not permitted here (e.g. a cross-origin frame): native focus still works.
}
};
return (_jsxs("span", { className: ["wk-input", className].filter(Boolean).join(" "), "data-empty": empty || undefined, "data-disabled": rest.disabled || undefined, "data-invalid": rest["aria-invalid"] === true || rest["aria-invalid"] === "true" || undefined, style: style, children: [_jsx("span", { className: "wk-input-text", "aria-hidden": "true", children: text || placeholder || emptyWords(lang, withTime) }), _jsxs("svg", { className: "wk-input-icon", viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: [_jsx("rect", { x: "3.5", y: "5", width: "17", height: "15", rx: "2.5", fill: "none", stroke: "currentColor", strokeWidth: "1.6" }), _jsx("path", { d: "M3.5 9.5h17M8 3v4M16 3v4", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })] }), _jsx("input", { ...rest, ref: ref, type: type, className: "wk-input-native", ...(value !== undefined ? { value } : { defaultValue }), onClick: handleClick, onChange: (event) => {
setInner(event.target.value);
onChange?.(event);
} })] }));
});
//# sourceMappingURL=DateInput.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../src/react/DateInput.tsx"],"names":[],"mappings":"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"}
+1
View File
@@ -1,5 +1,6 @@
export { ChipGroup, type ChipGroupProps, type ChipOption } from "./ChipGroup.js";
export { DateField, describeFieldValue, type DateFieldProps } from "./DateField.js";
export { DateInput, describeValue, emptyWords, type DateInputProps } from "./DateInput.js";
export { DayStrip, type DayStripProps } from "./DayStrip.js";
export { BookingRequestPicker, DEFAULT_PICKER_WORDS, type BookingPickerWords, type BookingRequestPickerProps, } from "./BookingRequestPicker.js";
//# sourceMappingURL=index.d.ts.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,2BAA2B,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,GAC/B,MAAM,2BAA2B,CAAC"}
+1
View File
@@ -1,5 +1,6 @@
export { ChipGroup } from "./ChipGroup.js";
export { DateField, describeFieldValue } from "./DateField.js";
export { DateInput, describeValue, emptyWords } from "./DateInput.js";
export { DayStrip } from "./DayStrip.js";
export { BookingRequestPicker, DEFAULT_PICKER_WORDS, } from "./BookingRequestPicker.js";
//# sourceMappingURL=index.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwC,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAuB,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAGrB,MAAM,2BAA2B,CAAC"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwC,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAuB,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAuB,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAsB,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAGrB,MAAM,2BAA2B,CAAC"}
+1 -1
View File
@@ -20,7 +20,7 @@ export default tseslint.config(
},
{
// Tests are plain Node running under `node --test`.
files: ["test/**/*.js", "test/**/*.mjs"],
files: ["test/**/*.js", "test/**/*.mjs", "scripts/**/*.mjs"],
// browser.mjs is Node driving a browser: page.evaluate bodies run there.
languageOptions: { globals: { ...globals.node, ...globals.nodeBuiltin, ...globals.browser } },
},
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@bitbaum/whenkit",
"version": "0.2.1",
"version": "0.3.3",
"description": "Dates and times people can pick without typing: day chips, time chips, length chips, a readable date field over the native picker, and a low-friction booking request that resolves to {startsAt, endsAt} in the provider's zone.",
"license": "MIT",
"author": "Cato",
@@ -61,7 +61,7 @@
"test:browser": "pnpm run demo && node test/browser.mjs"
},
"devDependencies": {
"@bitbaum/design-tokens": "^1.1.0",
"@bitbaum/design-tokens": "^1.2.0",
"@eslint/js": "^10.0.1",
"@types/node": "^26.4.0",
"@types/react": "^19.2.18",
@@ -69,7 +69,7 @@
"esbuild": "^0.28.2",
"eslint": "^10.9.1",
"globals": "^17.11.0",
"playwright": "1.63.0",
"playwright": "1.64.1",
"prettier": "^3.9.6",
"react": "^19.2.8",
"react-dom": "^19.2.8",
+111 -111
View File
@@ -9,14 +9,14 @@ importers:
.:
devDependencies:
'@bitbaum/design-tokens':
specifier: ^1.1.0
version: 1.1.0
specifier: ^1.2.0
version: 1.2.0
'@eslint/js':
specifier: ^10.0.1
version: 10.0.1(eslint@10.12.0)
version: 10.0.1(eslint@10.13.0)
'@types/node':
specifier: ^26.4.0
version: 26.6.4
version: 26.6.5
'@types/react':
specifier: ^19.2.18
version: 19.3.0
@@ -28,33 +28,33 @@ importers:
version: 0.28.2
eslint:
specifier: ^10.9.1
version: 10.12.0
version: 10.13.0
globals:
specifier: ^17.11.0
version: 17.13.0
playwright:
specifier: 1.63.0
version: 1.63.0
specifier: 1.64.1
version: 1.64.1
prettier:
specifier: ^3.9.6
version: 3.9.9
version: 3.9.10
react:
specifier: ^19.2.8
version: 19.3.0
version: 19.3.1
react-dom:
specifier: ^19.2.8
version: 19.3.0(react@19.3.0)
version: 19.3.1(react@19.3.1)
typescript:
specifier: ^6.0.3
version: 6.0.3
typescript-eslint:
specifier: ^8.68.0
version: 8.71.1(eslint@10.12.0)(typescript@6.0.3)
version: 8.72.0(eslint@10.13.0)(typescript@6.0.3)
packages:
'@bitbaum/design-tokens@1.1.0':
resolution: {integrity: sha512-sDVplKP4jKe0WHCOnW7xk75RC46JsAYqUngcVlctyAs9f1TQqZqbYTfbmyYipYCOaCIHMflnzAneQTbqrQbtBw==}
'@bitbaum/design-tokens@1.2.0':
resolution: {integrity: sha512-13TSrgYbEzSqt5FNfW3HSJIFcenUto8nKlk4J4IUsepL0gsTBoZ0YDMiJTaJKmR8sPPmcCS94Z/xgUBQW43itw==}
engines: {node: '>=20'}
'@cacheable/memory@2.2.0':
@@ -296,8 +296,8 @@ packages:
'@types/json-schema@7.0.15':
resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==}
'@types/node@26.6.4':
resolution: {integrity: sha512-ldVPDCzj7fsaGZrLB0NuHuTvJcsNasysBAqMolr/cgxrLd1xbqxIr3XJiPnHHJUCxj5sNF1vnRj9aWnrVh5Jcg==}
'@types/node@26.6.5':
resolution: {integrity: sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==}
'@types/react-dom@19.3.0':
resolution: {integrity: sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==}
@@ -307,63 +307,63 @@ packages:
'@types/react@19.3.0':
resolution: {integrity: sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==}
'@typescript-eslint/eslint-plugin@8.71.1':
resolution: {integrity: sha512-nNlBf6HuotqMgZvSkWD5hNdemiBIxQ2NmrlgfcUIeZRs+BbakjscCQRq/Hb74EFVnFiSWWdL12JruqwBy3ERDw==}
'@typescript-eslint/eslint-plugin@8.72.0':
resolution: {integrity: sha512-aysKgysPX9XOv/dk95UkvUDe++Q3n3dJPG9CEWT3RUccxfkPJ+Qn6nhKPDhZXU6Ofo9kgwGWwKyQCnZIXTgngg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
'@typescript-eslint/parser': ^8.71.1
'@typescript-eslint/parser': ^8.72.0
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/parser@8.71.1':
resolution: {integrity: sha512-oM/5sAqz/l1v/zYK1qTOPrn2+JIrBGC1V6uNYucRO5gh6eT9vWJ/RhPbGE59byvZEUQ4VP6XkLBaS5Jti5jpvw==}
'@typescript-eslint/parser@8.72.0':
resolution: {integrity: sha512-0O+x3ynciD6zuXb1CKSu165haQV6ey53DKhHHUnujP7U+XlltJG+/keT0Xhd1HXCze+IHf7Tvt39ovyepX/LNw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/project-service@8.71.1':
resolution: {integrity: sha512-Oijc9RUsohHjncg6iGi7gCtjnEjYt9FWv9u6ygK8uKcHK5eLjLAkqERQ9BaytbpceOFdk6kifPCS/zAZE+A99g==}
'@typescript-eslint/project-service@8.72.0':
resolution: {integrity: sha512-bzHngBbmIgzj6TsTjVUCntGx6FFLgE7mPjpO0PzHycOaZHXqS43XnrkFIHRS16LLr/xO6FHSXG3GJFo/F4bSBQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/scope-manager@8.71.1':
resolution: {integrity: sha512-1YUDZXdTnXLlob03SFHBipdyMBsDVm7zoSz0ytTJ39dk5J1TgsTK03VlR/dLXG/RLLUrPcYbD4rp23BmHxHP0w==}
'@typescript-eslint/scope-manager@8.72.0':
resolution: {integrity: sha512-JewPyJOYcXBSAS7PIgufscHOwZqhTGyBRiQJhhuDln66tMchxvvt7nJ90JKKIoOelmdHA3kAQbm9cEUHc4JSEA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/tsconfig-utils@8.71.1':
resolution: {integrity: sha512-oTvkml5SxXhgg+WWKhod5qWQICDXtOB+/Hi9VdPKFAANJ2b7YOgMffgvzXuqog7R6A/JtrzRf128dsxummyWhg==}
'@typescript-eslint/tsconfig-utils@8.72.0':
resolution: {integrity: sha512-0vbxCf7xLVPSjcOdm6eQbgViH8EDJ8xnl1laLT9yoqSz2YmcSfSg5Vdl0JUvZf6rcuJ0ZivJIuMD4edTg8obaA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/type-utils@8.71.1':
resolution: {integrity: sha512-kH3t3jZCYv2PZSBEWPKTariLrCaoF1CLoPitYFBJOhAGEwWnSRAtGEifrfrpBa4K9JlwWNZotgA5w3/wLSk/FQ==}
'@typescript-eslint/type-utils@8.72.0':
resolution: {integrity: sha512-gEXxmmbSTSOVTC37IYYvremOM31v+UN2W772bJxmVYPhAOPSUxtacyb7wkm1EhkYKU6KzFJsdU44DCV4to0LWw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/types@8.71.1':
resolution: {integrity: sha512-ybYnPTUwg3VQQOFEiBPLs8Jxl1ry2vXdn1kVKguomBbvxpetdu3MKTNDqFNUrlG8ylP9MpZosmXMFYlGQHk1oQ==}
'@typescript-eslint/types@8.72.0':
resolution: {integrity: sha512-Adfoy59kxNEjT5E5fnyrp7GpHYuWs8ONbdohu4ez6IU46qDq8LltG90tLmkucZB2uhYL8mqBjtXqGd8yhfjXqQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@typescript-eslint/typescript-estree@8.71.1':
resolution: {integrity: sha512-pSKSEK1JJpHs6KiKVtABCE4iJK5d7FLFzDXQNBQ2oRY7LEd3UwOt3TZemTgu9syTIf56dJWlTn/pdmrO9oKUXQ==}
'@typescript-eslint/typescript-estree@8.72.0':
resolution: {integrity: sha512-gwLfFgWcw15tN2KXDCJvxEOQjPn+P3j/n3eSqkZ5sX4VpW9Cosodr+tWwBZRvJT3TcKx6HnPRGZMCNAiP1Xhug==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/utils@8.71.1':
resolution: {integrity: sha512-CBjT6gfAz3DW2j9Q4moFnqt208Aq+506sVGXfpRcyAeqn0EpayL0mjdWoCO2t3RC7GewNrFxdeehuEaPg6DMzQ==}
'@typescript-eslint/utils@8.72.0':
resolution: {integrity: sha512-0up3oArJZBYnzOaEXKo8DmI43QvMZyPoFEt9LWzRJcyl/RcJjfKKPebknN1VbTgXBf3M/KggUh5uUMdURLnseg==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
typescript: '>=4.8.4 <6.1.0'
'@typescript-eslint/visitor-keys@8.71.1':
resolution: {integrity: sha512-0GxiUGqMU0qXJt58cBsiG3DP8lUmBaFo2vChtUX+CT7PnR3v/VGLLrzVP4K9r1lNiZXjHYefMBbPunplr09v6w==}
'@typescript-eslint/visitor-keys@8.72.0':
resolution: {integrity: sha512-E2mroviasaWecDzTGiGMtuEguuLVOeRggnrIn93CJuxYJzQBHbyymlT08aVQydbBal5538o+JkBKXh2sRuCyIA==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
acorn-jsx@5.3.2:
@@ -430,8 +430,8 @@ packages:
resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
eslint@10.12.0:
resolution: {integrity: sha512-npHjrHb2o4ehH3mE+YuxABR+0gyb0aVWCIolgJDArwCiHEIsonBm3ZKjel5b0U5+a+MbEvIyRCGCzD3eKKK2NA==}
eslint@10.13.0:
resolution: {integrity: sha512-UohDjD4zSzEwhf58M3O7vc/ycc8O1I7dNlhtD0WxE8Px8EHNJKtUwzBqrzeGhisRuv2ag4sAYswszCJRgKXYUg==}
engines: {node: ^20.19.0 || ^22.13.0 || >=24}
hasBin: true
peerDependencies:
@@ -583,13 +583,13 @@ packages:
resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==}
engines: {node: '>=12'}
playwright-core@1.63.0:
resolution: {integrity: sha512-rYCsBF/M5HjUch52bbtVONEFjv6Xu8sm8h72dNlR5bzIE1fvC/bxgspzkjSfU+MweEMmPM8KJebG6nnyxo5mCg==}
playwright-core@1.64.1:
resolution: {integrity: sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==}
engines: {node: '>=20'}
hasBin: true
playwright@1.63.0:
resolution: {integrity: sha512-+7ziBLidS4NaNCdt57SUDT+wYmmd5fmiQejUic/kb+YsYSCPyOOE9sebzMjNmQrsnNpDJqd4WHvV/8lfKfUDUg==}
playwright@1.64.1:
resolution: {integrity: sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==}
engines: {node: '>=20'}
hasBin: true
@@ -597,8 +597,8 @@ packages:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'}
prettier@3.9.9:
resolution: {integrity: sha512-Z/CJHIkdujO/OtN7nXUii0Rf3VT5SRuhjBA82Xvu2XhBUgX3nhP67T0LHceBdQLex7OOFGTox+Q5Yg8Jk2Qivg==}
prettier@3.9.10:
resolution: {integrity: sha512-skGHTH1Yb9QvaTC4hWnRTzEYtCpApF0UMBPz+t/0ZPzP8ihefo/btKd+QA7pUE0fEwA1SbS/NmhyEcstdXOIdA==}
engines: {node: '>=14'}
hasBin: true
@@ -610,13 +610,13 @@ packages:
resolution: {integrity: sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==}
engines: {node: '>=20'}
react-dom@19.3.0:
resolution: {integrity: sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==}
react-dom@19.3.1:
resolution: {integrity: sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==}
peerDependencies:
react: ^19.3.0
react: ^19.3.1
react@19.3.0:
resolution: {integrity: sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==}
react@19.3.1:
resolution: {integrity: sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==}
engines: {node: '>=0.10.0'}
scheduler@0.28.0:
@@ -649,8 +649,8 @@ packages:
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
engines: {node: '>= 0.8.0'}
typescript-eslint@8.71.1:
resolution: {integrity: sha512-oiNVPC3/NbV1FpaHU07l8O6ynqG9v4PAiW2WvTrAmZdR0f2HI/gE668ElMLCK7Xbsu5k2fK5C4fXNiq05j7/nQ==}
typescript-eslint@8.72.0:
resolution: {integrity: sha512-r26Fkc8As+mZvqp7SLsMmNFyYUup/6CjK7/eHBHmhOw6GH6n6YFxHVFrG0jN1c5CMpDzelLPxvgeCOzx7BjN+A==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
peerDependencies:
eslint: ^8.57.0 || ^9.0.0 || ^10.0.0
@@ -682,7 +682,7 @@ packages:
snapshots:
'@bitbaum/design-tokens@1.1.0': {}
'@bitbaum/design-tokens@1.2.0': {}
'@cacheable/memory@2.2.0':
dependencies:
@@ -774,9 +774,9 @@ snapshots:
'@esbuild/win32-x64@0.28.2':
optional: true
'@eslint-community/eslint-utils@4.10.1(eslint@10.12.0)':
'@eslint-community/eslint-utils@4.10.1(eslint@10.13.0)':
dependencies:
eslint: 10.12.0
eslint: 10.13.0
eslint-visitor-keys: 3.4.3
'@eslint-community/regexpp@4.12.2': {}
@@ -797,9 +797,9 @@ snapshots:
dependencies:
'@types/json-schema': 7.0.15
'@eslint/js@10.0.1(eslint@10.12.0)':
'@eslint/js@10.0.1(eslint@10.13.0)':
optionalDependencies:
eslint: 10.12.0
eslint: 10.13.0
'@eslint/object-schema@3.0.5': {}
@@ -838,7 +838,7 @@ snapshots:
'@types/json-schema@7.0.15': {}
'@types/node@26.6.4':
'@types/node@26.6.5':
dependencies:
undici-types: 8.9.0
@@ -850,15 +850,15 @@ snapshots:
dependencies:
csstype: 3.2.3
'@typescript-eslint/eslint-plugin@8.71.1(@typescript-eslint/parser@8.71.1(eslint@10.12.0)(typescript@6.0.3))(eslint@10.12.0)(typescript@6.0.3)':
'@typescript-eslint/eslint-plugin@8.72.0(@typescript-eslint/parser@8.72.0(eslint@10.13.0)(typescript@6.0.3))(eslint@10.13.0)(typescript@6.0.3)':
dependencies:
'@eslint-community/regexpp': 4.12.2
'@typescript-eslint/parser': 8.71.1(eslint@10.12.0)(typescript@6.0.3)
'@typescript-eslint/scope-manager': 8.71.1
'@typescript-eslint/type-utils': 8.71.1(eslint@10.12.0)(typescript@6.0.3)
'@typescript-eslint/utils': 8.71.1(eslint@10.12.0)(typescript@6.0.3)
'@typescript-eslint/visitor-keys': 8.71.1
eslint: 10.12.0
'@typescript-eslint/parser': 8.72.0(eslint@10.13.0)(typescript@6.0.3)
'@typescript-eslint/scope-manager': 8.72.0
'@typescript-eslint/type-utils': 8.72.0(eslint@10.13.0)(typescript@6.0.3)
'@typescript-eslint/utils': 8.72.0(eslint@10.13.0)(typescript@6.0.3)
'@typescript-eslint/visitor-keys': 8.72.0
eslint: 10.13.0
ignore: 7.0.12
natural-compare: 1.4.0
ts-api-utils: 2.5.0(typescript@6.0.3)
@@ -866,56 +866,56 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/parser@8.71.1(eslint@10.12.0)(typescript@6.0.3)':
'@typescript-eslint/parser@8.72.0(eslint@10.13.0)(typescript@6.0.3)':
dependencies:
'@typescript-eslint/scope-manager': 8.71.1
'@typescript-eslint/types': 8.71.1
'@typescript-eslint/typescript-estree': 8.71.1(typescript@6.0.3)
'@typescript-eslint/visitor-keys': 8.71.1
'@typescript-eslint/scope-manager': 8.72.0
'@typescript-eslint/types': 8.72.0
'@typescript-eslint/typescript-estree': 8.72.0(typescript@6.0.3)
'@typescript-eslint/visitor-keys': 8.72.0
debug: 4.4.3
eslint: 10.12.0
eslint: 10.13.0
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/project-service@8.71.1(typescript@6.0.3)':
'@typescript-eslint/project-service@8.72.0(typescript@6.0.3)':
dependencies:
'@typescript-eslint/tsconfig-utils': 8.71.1(typescript@6.0.3)
'@typescript-eslint/types': 8.71.1
'@typescript-eslint/tsconfig-utils': 8.72.0(typescript@6.0.3)
'@typescript-eslint/types': 8.72.0
debug: 4.4.3
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/scope-manager@8.71.1':
'@typescript-eslint/scope-manager@8.72.0':
dependencies:
'@typescript-eslint/types': 8.71.1
'@typescript-eslint/visitor-keys': 8.71.1
'@typescript-eslint/types': 8.72.0
'@typescript-eslint/visitor-keys': 8.72.0
'@typescript-eslint/tsconfig-utils@8.71.1(typescript@6.0.3)':
'@typescript-eslint/tsconfig-utils@8.72.0(typescript@6.0.3)':
dependencies:
typescript: 6.0.3
'@typescript-eslint/type-utils@8.71.1(eslint@10.12.0)(typescript@6.0.3)':
'@typescript-eslint/type-utils@8.72.0(eslint@10.13.0)(typescript@6.0.3)':
dependencies:
'@typescript-eslint/types': 8.71.1
'@typescript-eslint/typescript-estree': 8.71.1(typescript@6.0.3)
'@typescript-eslint/utils': 8.71.1(eslint@10.12.0)(typescript@6.0.3)
'@typescript-eslint/types': 8.72.0
'@typescript-eslint/typescript-estree': 8.72.0(typescript@6.0.3)
'@typescript-eslint/utils': 8.72.0(eslint@10.13.0)(typescript@6.0.3)
debug: 4.4.3
eslint: 10.12.0
eslint: 10.13.0
ts-api-utils: 2.5.0(typescript@6.0.3)
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/types@8.71.1': {}
'@typescript-eslint/types@8.72.0': {}
'@typescript-eslint/typescript-estree@8.71.1(typescript@6.0.3)':
'@typescript-eslint/typescript-estree@8.72.0(typescript@6.0.3)':
dependencies:
'@typescript-eslint/project-service': 8.71.1(typescript@6.0.3)
'@typescript-eslint/tsconfig-utils': 8.71.1(typescript@6.0.3)
'@typescript-eslint/types': 8.71.1
'@typescript-eslint/visitor-keys': 8.71.1
'@typescript-eslint/project-service': 8.72.0(typescript@6.0.3)
'@typescript-eslint/tsconfig-utils': 8.72.0(typescript@6.0.3)
'@typescript-eslint/types': 8.72.0
'@typescript-eslint/visitor-keys': 8.72.0
debug: 4.4.3
minimatch: 10.2.6
semver: 7.8.5
@@ -925,20 +925,20 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@typescript-eslint/utils@8.71.1(eslint@10.12.0)(typescript@6.0.3)':
'@typescript-eslint/utils@8.72.0(eslint@10.13.0)(typescript@6.0.3)':
dependencies:
'@eslint-community/eslint-utils': 4.10.1(eslint@10.12.0)
'@typescript-eslint/scope-manager': 8.71.1
'@typescript-eslint/types': 8.71.1
'@typescript-eslint/typescript-estree': 8.71.1(typescript@6.0.3)
eslint: 10.12.0
'@eslint-community/eslint-utils': 4.10.1(eslint@10.13.0)
'@typescript-eslint/scope-manager': 8.72.0
'@typescript-eslint/types': 8.72.0
'@typescript-eslint/typescript-estree': 8.72.0(typescript@6.0.3)
eslint: 10.13.0
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
'@typescript-eslint/visitor-keys@8.71.1':
'@typescript-eslint/visitor-keys@8.72.0':
dependencies:
'@typescript-eslint/types': 8.71.1
'@typescript-eslint/types': 8.72.0
eslint-visitor-keys: 5.0.1
acorn-jsx@5.3.2(acorn@8.19.0):
@@ -1024,9 +1024,9 @@ snapshots:
eslint-visitor-keys@5.0.1: {}
eslint@10.12.0:
eslint@10.13.0:
dependencies:
'@eslint-community/eslint-utils': 4.10.1(eslint@10.12.0)
'@eslint-community/eslint-utils': 4.10.1(eslint@10.13.0)
'@eslint-community/regexpp': 4.12.2
'@eslint/config-array': 0.23.5
'@eslint/config-helpers': 0.7.0
@@ -1180,15 +1180,15 @@ snapshots:
picomatch@4.0.7: {}
playwright-core@1.63.0: {}
playwright-core@1.64.1: {}
playwright@1.63.0:
playwright@1.64.1:
dependencies:
playwright-core: 1.63.0
playwright-core: 1.64.1
prelude-ls@1.2.1: {}
prettier@3.9.9: {}
prettier@3.9.10: {}
punycode@2.3.1: {}
@@ -1196,12 +1196,12 @@ snapshots:
dependencies:
hookified: 2.2.0
react-dom@19.3.0(react@19.3.0):
react-dom@19.3.1(react@19.3.1):
dependencies:
react: 19.3.0
react: 19.3.1
scheduler: 0.28.0
react@19.3.0: {}
react@19.3.1: {}
scheduler@0.28.0: {}
@@ -1226,13 +1226,13 @@ snapshots:
dependencies:
prelude-ls: 1.2.1
typescript-eslint@8.71.1(eslint@10.12.0)(typescript@6.0.3):
typescript-eslint@8.72.0(eslint@10.13.0)(typescript@6.0.3):
dependencies:
'@typescript-eslint/eslint-plugin': 8.71.1(@typescript-eslint/parser@8.71.1(eslint@10.12.0)(typescript@6.0.3))(eslint@10.12.0)(typescript@6.0.3)
'@typescript-eslint/parser': 8.71.1(eslint@10.12.0)(typescript@6.0.3)
'@typescript-eslint/typescript-estree': 8.71.1(typescript@6.0.3)
'@typescript-eslint/utils': 8.71.1(eslint@10.12.0)(typescript@6.0.3)
eslint: 10.12.0
'@typescript-eslint/eslint-plugin': 8.72.0(@typescript-eslint/parser@8.72.0(eslint@10.13.0)(typescript@6.0.3))(eslint@10.13.0)(typescript@6.0.3)
'@typescript-eslint/parser': 8.72.0(eslint@10.13.0)(typescript@6.0.3)
'@typescript-eslint/typescript-estree': 8.72.0(typescript@6.0.3)
'@typescript-eslint/utils': 8.72.0(eslint@10.13.0)(typescript@6.0.3)
eslint: 10.13.0
typescript: 6.0.3
transitivePeerDependencies:
- supports-color
+156
View File
@@ -0,0 +1,156 @@
#!/usr/bin/env node
// Replace `<input type="date">` / `<input type="datetime-local">` with whenkit's
// DateInput — a drop-in (same props, same onChange(event)), so only the TAG
// changes. Nothing else in the file is touched except one import line.
//
// node scripts/migrate-date-inputs.mjs <dir> --import "@/components/ui/date-input" [--from input] [--write]
//
// --import module that exports DateInput (a one-line re-export per app that
// also imports "@bitbaum/whenkit/styles.css" once)
// --from tag to replace: `input` (default) or a wrapper such as `Input`
// --write apply; without it, a dry run that only reports
//
// It is a tag scanner, not a regex over attributes: it walks the JSX opening
// tag honouring braces, strings and template literals, so `onChange={(e) => …}`
// and multi-line props cannot confuse it. Anything it will NOT convert safely
// is listed for a human: spread props (`{...register("x")}`) are kept (DateInput
// forwards them) but flagged, and a dynamic `type={…}` is flagged, never guessed.
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
import { join, relative } from "node:path";
const args = process.argv.slice(2);
const root = args.find((a) => !a.startsWith("--"));
const opt = (name, fallback) => {
const i = args.indexOf(`--${name}`);
return i >= 0 ? args[i + 1] : fallback;
};
const write = args.includes("--write");
const from = opt("from", "input");
const importFrom = opt("import");
if (!root || !importFrom) {
console.error(
'usage: migrate-date-inputs.mjs <dir> --import "<module>" [--from input|Input] [--write]',
);
process.exit(2);
}
const SKIP =
/(^|\/)(node_modules|\.next|\.claude|dist|build|coverage|__tests__|tests?|e2e|cypress|\.git)(\/|$)/;
const FILE = /\.(tsx|jsx)$/;
const TEST_FILE = /\.(test|spec|stories)\.(tsx|jsx)$/;
function* walk(dir) {
for (const name of readdirSync(dir)) {
const path = join(dir, name);
if (SKIP.test(relative(root, path))) continue;
const st = statSync(path);
if (st.isDirectory()) yield* walk(path);
else if (FILE.test(name) && !TEST_FILE.test(name)) yield path;
}
}
/** End index (exclusive) of the JSX opening tag starting at `start` (`<tag`), or -1. */
function tagEnd(src, start) {
let depth = 0; // braces
let i = start;
while (i < src.length) {
const c = src[i];
if (depth === 0) {
if (c === '"' || c === "'") {
const close = src.indexOf(c, i + 1);
if (close < 0) return -1;
i = close + 1;
continue;
}
if (c === "{") depth++;
else if (c === ">") return i + 1;
} else {
if (c === "{") depth++;
else if (c === "}") depth--;
else if (c === '"' || c === "'" || c === "`") {
// string inside an expression
let j = i + 1;
while (j < src.length && src[j] !== c) j += src[j] === "\\" ? 2 : 1;
i = j + 1;
continue;
}
}
i++;
}
return -1;
}
const TYPE_STATIC =
/\btype=(?:"(date|datetime-local)"|'(date|datetime-local)'|\{\s*["'](date|datetime-local)["']\s*\})/;
const TYPE_ANY = /\btype=\{/;
/** `src` with comments blanked (same length, so indexes still line up). */
function maskComments(src) {
const blank = (m) => m.replace(/[^\n]/g, " ");
return src
.replace(/\/\*[\s\S]*?\*\//g, blank)
.replace(/(^|[^:"'`\\])\/\/[^\n]*/g, (m, lead) => lead + blank(m.slice(lead.length)));
}
let changedFiles = 0;
let changedTags = 0;
const review = [];
for (const file of walk(root)) {
const src = readFileSync(file, "utf8");
// The app's own re-export (and anything already on whenkit) is not a call site.
if (src.includes("@bitbaum/whenkit")) continue;
const code = maskComments(src);
const opening = new RegExp(`<${from}(?=[\\s/>])`, "g");
let out = "";
let last = 0;
let count = 0;
const alias = /\bDateInput\b/.test(src) && !src.includes(`from "${importFrom}"`);
const tag = alias ? "WhenDateInput" : "DateInput";
for (const m of code.matchAll(opening)) {
const end = tagEnd(src, m.index);
if (end < 0) continue;
const attrs = src.slice(m.index, end);
if (TYPE_STATIC.test(attrs)) {
out += src.slice(last, m.index) + `<${tag}`;
last = m.index + m[0].length;
count++;
const line = src.slice(0, m.index).split("\n").length;
// A JSX prop spread is `{...x}` at attribute level; `({ ...form, a })` inside
// an onChange arrow is an object literal and is not worth a human's time.
if (/(^|[\s"'}/])\{\s*\.\.\.[A-Za-z_$]/.test(attrs.replace(/=\{[^}]*\}/g, "=")))
review.push(`${relative(root, file)}:${line} spreads props — check they are input props`);
} else if (TYPE_ANY.test(attrs) && /date/i.test(src.slice(m.index, m.index + 400))) {
const line = src.slice(0, m.index).split("\n").length;
review.push(
`${relative(root, file)}:${line} has a dynamic type={…} near "date" — decide by hand`,
);
}
}
if (count === 0) continue;
out += src.slice(last);
const importLine = alias
? `import { DateInput as WhenDateInput } from "${importFrom}";`
: `import { DateInput } from "${importFrom}";`;
if (!out.includes(`from "${importFrom}"`)) {
// after the last top-level import (or the directive, or the top)
// `[ \t]*$` ends the match at the line, so the blank line after the imports is kept.
const imports = [...out.matchAll(/^import[\s\S]*?;[ \t]*$/gm)];
const at = imports.length
? imports[imports.length - 1].index + imports[imports.length - 1][0].length
: (/^(?:["']use (?:client|server)["'];?\s*)/.exec(out)?.[0].length ?? 0);
out = out.slice(0, at) + (at ? "\n" : "") + importLine + (at ? "" : "\n") + out.slice(at);
}
changedFiles++;
changedTags += count;
console.log(
`${write ? "wrote " : "would change "}${relative(root, file)} (${count} tag${count > 1 ? "s" : ""})`,
);
if (write) writeFileSync(file, out);
}
console.log(
`\n${changedTags} tag(s) in ${changedFiles} file(s)${write ? " migrated" : " (dry run — add --write)"}`,
);
if (review.length) console.log(`\nREVIEW BY HAND:\n ${review.join("\n ")}`);
+20 -70
View File
@@ -1,22 +1,15 @@
"use client";
/**
* A date (or date + time) field that reads like a sentence and picks like the
* phone does.
*
* The native picker is the best one there is on a phone — what looked bad
* across the fleet was the raw field around it: the browser's locale
* placeholder ("tt.mm.jjjj, --:--"), unstyled, different in every browser.
* So the native input stays (keyboard entry, a11y, autofill all keep
* working) and sits transparently over a display that says "Sat, 11 Oct ·
* 14:00". A tap anywhere opens the platform picker via `showPicker()`.
* A labelled date (or date + time) field: `DateInput` with its own label and
* an optional hint, for places that do not already have a form-field wrapper.
* Apps that do (most) use `DateInput` directly.
*
* Values are `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM` wall-clock strings — exactly
* what the native input speaks — never instants.
*/
import { useId } from "react";
import { dayLabel, formatTime } from "../labels.js";
import { isISODate, isWallTime } from "../calendar.js";
import { DateInput, describeValue } from "./DateInput.js";
export interface DateFieldProps {
label: string;
@@ -34,20 +27,8 @@ export interface DateFieldProps {
className?: string;
}
export function describeFieldValue(value: string, withTime: boolean, locale = "en"): string {
const [date, time] = value.split("T");
if (!isISODate(date)) return "";
const day = dayLabel(date, { locale });
const dayText = new Intl.DateTimeFormat(locale, {
timeZone: "UTC",
weekday: "short",
day: "numeric",
month: "short",
year: "numeric",
}).format(new Date(`${date}T00:00:00Z`));
if (withTime && isWallTime(time)) return `${dayText} · ${formatTime(time, locale)}`;
return dayText || day.short;
}
/** Kept for callers of 0.1–0.2: the words for a value, or "" if invalid. */
export const describeFieldValue = describeValue;
export function DateField({
label,
@@ -59,60 +40,29 @@ export function DateField({
required,
name,
placeholder,
locale = "en",
locale,
hint,
className,
}: DateFieldProps) {
const id = useId();
const shown = value ? describeFieldValue(value, withTime, locale) : "";
return (
<div className={["wk-field", className].filter(Boolean).join(" ")}>
<label className="wk-label" htmlFor={id}>
{label}
</label>
<div className="wk-field-box" data-empty={shown ? undefined : true}>
<span className="wk-field-text" aria-hidden="true">
{shown || placeholder || (withTime ? "Pick a day and time" : "Pick a day")}
</span>
<svg className="wk-field-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<rect
x="3.5"
y="5"
width="17"
height="15"
rx="2.5"
fill="none"
stroke="currentColor"
strokeWidth="1.6"
/>
<path
d="M3.5 9.5h17M8 3v4M16 3v4"
fill="none"
stroke="currentColor"
strokeWidth="1.6"
strokeLinecap="round"
/>
</svg>
<input
id={id}
className="wk-field-input"
type={withTime ? "datetime-local" : "date"}
value={value}
min={min}
max={max}
required={required}
name={name}
aria-describedby={hint ? `${id}-hint` : undefined}
onChange={(e) => onChange(e.target.value)}
onClick={(e) => {
try {
e.currentTarget.showPicker?.();
} catch {
// Not allowed (e.g. cross-origin iframe): native focus still works.
}
}}
/>
</div>
<DateInput
id={id}
type={withTime ? "datetime-local" : "date"}
value={value}
onChange={(e) => onChange(e.target.value)}
min={min}
max={max}
required={required}
name={name}
placeholder={placeholder}
locale={locale}
aria-describedby={hint ? `${id}-hint` : undefined}
/>
{hint && (
<p className="wk-hint" id={`${id}-hint`}>
{hint}
+163
View File
@@ -0,0 +1,163 @@
"use client";
/**
* A drop-in for `<input type="date">` and `<input type="datetime-local">`.
*
* Same props, same `onChange(event)` — a call site changes its tag and
* nothing else. What changes is what a person sees: the browser's bare field
* ("tt.mm.jjjj, --:--", different in every browser) is replaced by the value
* in words ("Sat, 11 Oct 2026 · 14:00") in the app's OWN input styling (its
* `className` lands on the visible box), while the real input stays on top,
* transparent, so the platform picker, keyboard entry, autofill, validation
* bubbles and form submission all keep working.
*
* Controlled (`value`) or uncontrolled (`defaultValue`, e.g. a server-action
* form): the visible text follows whichever the app uses.
*/
import {
forwardRef,
useEffect,
useState,
type ChangeEvent,
type InputHTMLAttributes,
type MouseEvent,
} from "react";
import { isISODate, isWallTime } from "../calendar.js";
import { formatTime } from "../labels.js";
export interface DateInputProps extends Omit<
InputHTMLAttributes<HTMLInputElement>,
"type" | "onChange" | "value" | "defaultValue"
> {
/** `date` (default) or `datetime-local`. */
type?: "date" | "datetime-local";
/** `YYYY-MM-DD` or `YYYY-MM-DDTHH:MM`. */
value?: string;
defaultValue?: string;
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
/** Words shown while empty. Defaults to a short phrase in the page language. */
placeholder?: string;
/** BCP 47 tag. Defaults to the page's `<html lang>` (read after mount). */
locale?: string;
/** Applied to the visible box — give it the same classes as the app's inputs. */
className?: string;
}
const EMPTY_WORDS: Record<string, [string, string]> = {
en: ["Pick a date", "Pick a date and time"],
de: ["Datum wählen", "Datum und Uhrzeit wählen"],
fr: ["Choisir une date", "Choisir la date et l'heure"],
it: ["Scegli una data", "Scegli data e ora"],
es: ["Elegir fecha", "Elegir fecha y hora"],
};
export function emptyWords(locale: string, withTime: boolean): string {
const words = EMPTY_WORDS[locale.toLowerCase().split("-")[0]] ?? EMPTY_WORDS.en;
return words[withTime ? 1 : 0];
}
/** "Sat, 11 Oct 2026" or "Sat, 11 Oct 2026 · 14:00"; "" when not a valid value. */
export function describeValue(value: string, withTime: boolean, locale = "en"): string {
const [date, time] = value.split("T");
if (!isISODate(date)) return "";
const day = new Intl.DateTimeFormat(locale, {
timeZone: "UTC",
weekday: "short",
day: "numeric",
month: "short",
year: "numeric",
}).format(new Date(`${date}T00:00:00Z`));
return withTime && isWallTime(time) ? `${day} · ${formatTime(time, locale)}` : day;
}
/** An unknown tag from <html lang> must never throw during render. */
function safeDescribe(value: string, withTime: boolean, locale: string): string {
try {
return describeValue(value, withTime, locale);
} catch {
return describeValue(value, withTime, "en");
}
}
export const DateInput = forwardRef<HTMLInputElement, DateInputProps>(function DateInput(
{
type = "date",
value,
defaultValue,
onChange,
placeholder,
locale,
className,
style,
onClick,
...rest
},
ref,
) {
const withTime = type === "datetime-local";
const [inner, setInner] = useState(defaultValue ?? "");
const [lang, setLang] = useState(locale ?? "en");
useEffect(() => {
if (locale) setLang(locale);
else setLang(document.documentElement.lang || "en");
}, [locale]);
const current = value ?? inner;
const text = current ? safeDescribe(current, withTime, lang) : "";
const empty = !text;
const handleClick = (event: MouseEvent<HTMLInputElement>) => {
onClick?.(event);
if (event.defaultPrevented) return;
try {
event.currentTarget.showPicker?.();
} catch {
// Not permitted here (e.g. a cross-origin frame): native focus still works.
}
};
return (
<span
className={["wk-input", className].filter(Boolean).join(" ")}
data-empty={empty || undefined}
data-disabled={rest.disabled || undefined}
data-invalid={rest["aria-invalid"] === true || rest["aria-invalid"] === "true" || undefined}
style={style}
>
<span className="wk-input-text" aria-hidden="true">
{text || placeholder || emptyWords(lang, withTime)}
</span>
<svg className="wk-input-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<rect
x="3.5"
y="5"
width="17"
height="15"
rx="2.5"
fill="none"
stroke="currentColor"
strokeWidth="1.6"
/>
<path
d="M3.5 9.5h17M8 3v4M16 3v4"
fill="none"
stroke="currentColor"
strokeWidth="1.6"
strokeLinecap="round"
/>
</svg>
<input
{...rest}
ref={ref}
type={type}
className="wk-input-native"
{...(value !== undefined ? { value } : { defaultValue })}
onClick={handleClick}
onChange={(event) => {
setInner(event.target.value);
onChange?.(event);
}}
/>
</span>
);
});
+1
View File
@@ -1,5 +1,6 @@
export { ChipGroup, type ChipGroupProps, type ChipOption } from "./ChipGroup.js";
export { DateField, describeFieldValue, type DateFieldProps } from "./DateField.js";
export { DateInput, describeValue, emptyWords, type DateInputProps } from "./DateInput.js";
export { DayStrip, type DayStripProps } from "./DayStrip.js";
export {
BookingRequestPicker,
+66 -20
View File
@@ -26,6 +26,7 @@
--wk-accent-soft: color-mix(in srgb, var(--wk-accent) 14%, transparent);
--wk-radius: var(--radius-control, 0.625rem);
--wk-font: var(--font-sans, system-ui, -apple-system, "Segoe UI", sans-serif);
--wk-danger: hsl(var(--status-negative, 0 65% 50%));
--wk-text: 1rem;
--wk-small: 0.8125rem;
--wk-target: 2.75rem;
@@ -208,7 +209,7 @@
text-decoration: line-through;
}
/* ---- the readable date field over the native picker ---- */
/* ---- the readable date input over the native picker ---- */
.wk-field {
display: flex;
@@ -216,47 +217,87 @@
gap: 0.375rem;
}
.wk-field-box {
/* The visible box, in two parts.
STRUCTURE (unlayered): what the stacked native input needs to work.
LOOK (@layer base): border, padding, colour, size. A named low layer, so an
app's own classes always win — Tailwind v4 utilities and component classes
sit in higher layers, plain app CSS is unlayered — and the date input then
looks like the app's other inputs, not like ours. (Unlayered defaults would
have beaten Tailwind's layered utilities.) No min-height: a compact input
stays compact; the picker sets its own 44px where it needs it. */
/* span.wk-input, not .wk-input: structure must hold even when an app's own
unlayered input class sets display:block on this same element. */
span.wk-input {
position: relative;
display: flex;
align-items: center;
gap: 0.5rem;
min-height: var(--wk-target);
padding: 0 0.875rem;
border: 1px solid var(--wk-line-2);
border-radius: var(--wk-radius);
background: var(--wk-bg);
box-sizing: border-box;
min-width: 0;
}
.wk-field-box:focus-within {
@layer base {
.wk-input {
width: 100%;
padding: 0.7rem 0.875rem;
border: 1px solid var(--wk-line-2);
border-radius: var(--wk-radius);
background: var(--wk-bg);
color: inherit;
font: inherit;
font-size: var(--wk-text);
/* The font's own line height, exactly like a native input — a fixed 1.3
made the date box a different height from its neighbours. */
line-height: normal;
}
}
.wk-field .wk-input,
.wk-other .wk-input {
min-height: var(--wk-target);
}
.wk-input:focus-within {
outline: 2px solid var(--wk-accent);
outline-offset: 1px;
border-color: var(--wk-accent);
}
.wk-field-text {
.wk-input[data-invalid] {
border-color: var(--wk-danger, #dc2626);
}
.wk-input[data-disabled] {
opacity: 0.55;
cursor: not-allowed;
}
.wk-input-text {
flex: 1;
min-width: 0;
font-size: var(--wk-text);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;
}
.wk-field-box[data-empty] .wk-field-text {
color: var(--wk-muted);
.wk-input[data-empty] .wk-input-text {
opacity: 0.55;
}
.wk-field-icon {
width: 1.25rem;
height: 1.25rem;
.wk-input-icon {
/* em, not rem, and no taller than a normal line: the icon scales with the
field's own text, so neither a dense 12px input nor a serif-font one is made
taller than its neighbours by it. */
width: 1.1em;
height: 1.1em;
flex: 0 0 auto;
color: var(--wk-fg-2);
opacity: 0.7;
}
/* The real control: full-size, invisible, on top — taps open the native
picker, keyboard entry and autofill keep working. 16px so iOS does not zoom. */
.wk-field-input {
picker, keyboard entry, autofill and validation keep working. 16px so iOS
does not zoom the page on focus. */
.wk-input-native {
position: absolute;
inset: 0;
width: 100%;
@@ -270,6 +311,10 @@
color-scheme: light dark;
}
.wk-input-native:disabled {
cursor: not-allowed;
}
/* "Another date…" under the strip is a quiet secondary control. */
.wk-other .wk-label {
position: absolute;
@@ -279,8 +324,9 @@
clip: rect(0 0 0 0);
}
.wk-other .wk-field-box {
.wk-other .wk-input {
align-self: flex-start;
width: auto;
border-style: dashed;
}
+54 -2
View File
@@ -97,9 +97,61 @@ try {
`${name}: flexible request without a day`,
);
// The app's own classes win over whenkit's defaults — plain CSS and a
// layered (Tailwind-style) utility alike. Without @layer base for the
// defaults, whenkit's unlayered rules would beat the layered utility.
const own = await page.evaluate(() => {
const css = (sel) => getComputedStyle(document.querySelector(sel));
return {
plainBorder: css("#own-class .wk-input").borderTopColor,
plainWidth: css("#own-class .wk-input").borderTopWidth,
utilWidth: css("#util-class .wk-input").borderTopWidth,
utilStyle: css("#util-class .wk-input").borderTopStyle,
};
});
check(
own.plainBorder === "rgb(255, 0, 0)" && own.plainWidth === "3px",
`${name}: an app class beats whenkit's input look (${own.plainBorder} ${own.plainWidth})`,
);
check(
own.utilWidth === "5px" && own.utilStyle === "dashed",
`${name}: a layered utility beats it too (${own.utilWidth} ${own.utilStyle})`,
);
// A dense app input stays dense: the icon scales with the text instead of
// forcing a 20px line into a 12px field.
const compactHeight = await page.evaluate(
() => document.querySelector("#compact-class .wk-input").getBoundingClientRect().height,
);
check(
compactHeight <= 32,
`${name}: a 12px compact date input stays compact (${Math.round(compactHeight)}px)`,
);
// The date box is the same height as a native input given the same class —
// so a form row does not step when one field is a date.
const heights = await page.evaluate(() => ({
native: document.getElementById("match-native").getBoundingClientRect().height,
date: document.querySelector("#match-date .wk-input").getBoundingClientRect().height,
}));
check(
Math.abs(heights.native - heights.date) <= 1,
`${name}: date box matches a native input's height (${heights.date} vs ${heights.native})`,
);
// An app class with display:block on the same element must not break the layout.
const stacked = await page.evaluate(() => {
const box = document.querySelector("#block-class .wk-input");
return getComputedStyle(box).display;
});
check(stacked === "flex", `${name}: an app's display:block cannot break the box (${stacked})`);
const small = await page.evaluate(
() =>
[...document.querySelectorAll(".wk-chip, .wk-day, .wk-field-box")]
[
...document.querySelectorAll(
".wk-chip, .wk-day, .wk-field .wk-input, .wk-other .wk-input",
),
]
.filter((el) => el.getClientRects().length > 0)
.map((el) => el.getBoundingClientRect())
.filter((r) => r.height < 43.5 || r.width < 43.5).length,
@@ -107,7 +159,7 @@ try {
check(small === 0, `${name}: every chip, day and field is at least 44px (${small} too small)`);
const inputSize = await page.evaluate(() =>
parseFloat(getComputedStyle(document.querySelector(".wk-field-input")).fontSize),
parseFloat(getComputedStyle(document.querySelector(".wk-input-native")).fontSize),
);
check(inputSize >= 16, `${name}: date input is ${inputSize}px (iOS zooms below 16)`);
+172
View File
@@ -0,0 +1,172 @@
// The migration codemod must change the TAG and one import line — nothing else —
// and must never touch an input that is not a date.
import { test } from "node:test";
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
const script = fileURLToPath(new URL("../scripts/migrate-date-inputs.mjs", import.meta.url));
const IMPORT = "@/components/ui/date-input";
function project(files) {
const dir = mkdtempSync(join(tmpdir(), "whenkit-codemod-"));
for (const [name, body] of Object.entries(files)) {
const path = join(dir, name);
mkdirSync(join(path, ".."), { recursive: true });
writeFileSync(path, body);
}
return dir;
}
const run = (dir, extra = []) =>
execFileSync("node", [script, dir, "--import", IMPORT, ...extra], { encoding: "utf8" });
const read = (dir, name) => readFileSync(join(dir, name), "utf8");
test("a dry run reports and writes nothing", () => {
const dir = project({
"a.tsx": `import x from "x";\nexport const A = () => <input type="date" value={v} />;\n`,
});
const before = read(dir, "a.tsx");
const out = run(dir);
assert.match(out, /would change a\.tsx/);
assert.match(out, /dry run/);
assert.equal(read(dir, "a.tsx"), before);
});
test("only the tag changes; props, arrows, strings and templates are untouched", () => {
const body = `"use client";
import { useState } from "react";
export function F() {
const [d, setD] = useState("");
return (
<input
type="date"
value={d}
onChange={(e) => setD(e.target.value)}
className={\`ui-input \${d ? "set" : ""}\`}
title="a > b"
min={new Date().toISOString().slice(0, 10)}
/>
);
}
`;
const dir = project({ "f.tsx": body });
run(dir, ["--write"]);
const after = read(dir, "f.tsx");
assert.match(after, /<DateInput\n\s+type="date"/);
assert.match(after, /onChange=\{\(e\) => setD\(e\.target\.value\)\}/);
assert.match(after, /className=\{`ui-input \$\{d \? "set" : ""\}`\}/);
assert.match(after, /title="a > b"/);
// the import goes after the last import, below the directive
assert.match(
after,
/"use client";\nimport \{ useState \} from "react";\nimport \{ DateInput \} from "@\/components\/ui\/date-input";\n/,
);
// and the diff is exactly one tag and one import
assert.equal(
after
.replace('import { DateInput } from "@/components/ui/date-input";\n', "")
.replace("<DateInput", "<input"),
body,
);
});
test("datetime-local, single-quoted and braced types are all converted", () => {
const dir = project({
"a.tsx": `import x from "x";\nexport const A = () => (<><input type='datetime-local' /><input type={"date"} /><input type="date"/></>);\n`,
});
run(dir, ["--write"]);
assert.equal((read(dir, "a.tsx").match(/<DateInput/g) ?? []).length, 3);
});
test("inputs that are not dates are left exactly alone", () => {
const body = `import x from "x";\nexport const A = () => (<><input type="text" /><input type="time" /><input /><input type={kind} /></>);\n`;
const dir = project({ "a.tsx": body });
const out = run(dir, ["--write"]);
assert.equal(read(dir, "a.tsx"), body);
assert.match(out, /0 tag\(s\) in 0 file\(s\)/);
});
test("a name clash gets an alias instead of shadowing the local DateInput", () => {
const dir = project({
"a.tsx": `import x from "x";\nfunction DateInput() { return <input type="date" />; }\nexport { DateInput };\n`,
});
run(dir, ["--write"]);
const after = read(dir, "a.tsx");
assert.match(after, /import \{ DateInput as WhenDateInput \} from/);
assert.match(after, /<WhenDateInput type="date" \/>/);
assert.match(after, /function DateInput\(\)/);
});
test("--from converts a wrapper component and leaves the raw input alone", () => {
const dir = project({
"a.tsx": `import x from "x";\nexport const A = () => (<><Input type="date" /><input type="date" /></>);\n`,
});
run(dir, ["--write", "--from", "Input"]);
const after = read(dir, "a.tsx");
assert.match(after, /<DateInput type="date" \/>/);
assert.match(after, /<input type="date" \/>/);
});
test("a second run changes nothing, and tests, node_modules and non-JSX are skipped", () => {
const dir = project({
"a.tsx": `import x from "x";\nexport const A = () => <input type="date" />;\n`,
"a.test.tsx": `export const T = () => <input type="date" />;\n`,
"node_modules/p/i.tsx": `export const N = () => <input type="date" />;\n`,
"b.ts": `const s = '<input type="date" />';\n`,
});
run(dir, ["--write"]);
const out = run(dir, ["--write"]);
assert.match(out, /0 tag\(s\) in 0 file\(s\)/);
assert.match(read(dir, "a.test.tsx"), /<input type="date"/);
assert.match(read(dir, "node_modules/p/i.tsx"), /<input type="date"/);
assert.match(read(dir, "b.ts"), /<input type="date"/);
});
test("risky shapes are listed for a human, not guessed", () => {
const dir = project({
"a.tsx": `import x from "x";\nexport const A = () => (<><input type="date" {...register("when")} /><input type={isDate ? "date" : "text"} /></>);\n`,
});
const out = run(dir);
assert.match(out, /REVIEW BY HAND/);
assert.match(out, /spreads props/);
assert.match(out, /dynamic type=/);
});
test("comments that mention an input are not call sites, and the app's own whenkit re-export is skipped", () => {
const withComments = `import x from "x";
// <input type="date"> used to be a bare field
/* and <input type="datetime-local" /> here */
export const A = () => (<>{/* <input type="date" /> */}<input type="date" /></>);
`;
const shim = `"use client";\n// the real <input type="date"> stays on top\nimport "@bitbaum/whenkit/styles.css";\nexport { DateInput } from "@bitbaum/whenkit/react";\n`;
const dir = project({ "a.tsx": withComments, "shim.tsx": shim });
run(dir, ["--write"]);
const after = read(dir, "a.tsx");
assert.match(after, /\/\/ <input type="date"> used to be/);
assert.match(after, /\/\* and <input type="datetime-local" \/> here \*\//);
assert.match(after, /\{\/\* <input type="date" \/> \*\/\}<DateInput type="date" \/>/);
assert.equal((after.match(/<DateInput/g) ?? []).length, 1);
assert.equal(read(dir, "shim.tsx"), shim);
});
test("a URL in a string does not hide the rest of the line", () => {
const dir = project({
"a.tsx": `import x from "x";\nexport const A = () => <a href="http://x.y">go</a>;\nexport const B = () => <input type="date" />; // after\n`,
});
run(dir, ["--write"]);
assert.match(read(dir, "a.tsx"), /<DateInput type="date" \/>; \/\/ after/);
});
test("an object spread inside onChange is not flagged; a JSX prop spread still is", () => {
const dir = project({
"a.tsx": `import x from "x";\nexport const A = () => <input type="date" onChange={(e) => set({ ...form, date: e.target.value })} />;\n`,
"b.tsx": `import x from "x";\nexport const B = () => <input type="date" {...register("when")} />;\n`,
});
const out = run(dir);
assert.doesNotMatch(out, /a\.tsx:\d+ spreads props/);
assert.match(out, /b\.tsx:\d+ spreads props/);
});
+62 -1
View File
@@ -5,7 +5,7 @@ import { test } from "node:test";
import assert from "node:assert/strict";
import { createElement as h } from "react";
import { renderToString } from "react-dom/server";
import { BookingRequestPicker, DateField, ChipGroup } from "../dist/react/index.js";
import { BookingRequestPicker, DateField, ChipGroup, DateInput } from "../dist/react/index.js";
const NOW = new Date("2026-10-10T08:00:00Z"); // 10:00 in Zurich, a Saturday
const base = { zone: "Europe/Zurich", locale: "en-GB", now: NOW, onChange: () => {} };
@@ -108,3 +108,64 @@ test("a fixed duration shows no length choice and is used for the slot", () => {
// 17:00 + 90 min would end after 18:00 closing, so it is not offered.
assert.doesNotMatch(html, />17:00</);
});
test("DateInput is a drop-in: every input prop reaches the real input, className the visible box", () => {
const html = renderToString(
h(DateInput, {
id: "due",
name: "due",
required: true,
min: "2026-10-01",
disabled: true,
"aria-invalid": true,
className: "ui-input-compact",
value: "2026-10-11",
onChange: () => {},
locale: "en-GB",
}),
);
assert.match(html, /<span class="wk-input ui-input-compact"/);
assert.match(html, /<input[^>]*id="due"/);
assert.match(html, /<input[^>]*name="due"/);
assert.match(html, /<input[^>]*required/);
assert.match(html, /<input[^>]*min="2026-10-01"/);
assert.match(html, /<input[^>]*disabled/);
assert.match(html, /<input[^>]*aria-invalid="true"/);
assert.match(html, /<input[^>]*type="date"/);
assert.match(html, /Sun, 11 Oct 2026/);
assert.match(html, /data-invalid/);
});
test("DateInput works uncontrolled (a server-action form): defaultValue shows and submits", () => {
const html = renderToString(
h(DateInput, { name: "date", defaultValue: "2026-03-05", locale: "de" }),
);
assert.match(html, /Do\., 5\. März 2026|Do, 5\. März 2026/);
assert.match(html, /<input[^>]*value="2026-03-05"/);
assert.match(html, /<input[^>]*name="date"/);
});
test("DateInput datetime-local shows the time, and an empty one shows words in the page language", () => {
const withTime = renderToString(
h(DateInput, {
type: "datetime-local",
value: "2026-10-11T14:30",
onChange: () => {},
locale: "en-GB",
}),
);
assert.match(withTime, /Sun, 11 Oct 2026 · 14:30/);
const empty = renderToString(h(DateInput, { value: "", onChange: () => {}, locale: "de" }));
assert.match(empty, /Datum wählen/);
assert.match(empty, /data-empty/);
const unknown = renderToString(h(DateInput, { value: "", onChange: () => {}, locale: "xx" }));
assert.match(unknown, /Pick a date/);
});
test("DateInput never throws on a bad value or a bad locale", () => {
assert.doesNotThrow(() =>
renderToString(
h(DateInput, { value: "not-a-date", onChange: () => {}, locale: "zz-INVALID-tag-!!" }),
),
);
});