@webjsdev/cli 0.10.46 → 0.10.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/webjs.js
CHANGED
|
@@ -497,28 +497,31 @@ async function main() {
|
|
|
497
497
|
break;
|
|
498
498
|
}
|
|
499
499
|
case 'ui': {
|
|
500
|
-
// Delegate to @webjsdev/ui.
|
|
501
|
-
// @webjsdev/cli, so `npm install -g webjsdev` pulls it in
|
|
502
|
-
//
|
|
503
|
-
//
|
|
504
|
-
|
|
505
|
-
|
|
500
|
+
// Delegate to @webjsdev/ui's bin. It is a hard dependency of
|
|
501
|
+
// @webjsdev/cli, so `npm install -g webjsdev` pulls it in automatically
|
|
502
|
+
// and `webjs ui add button` works without an extra install.
|
|
503
|
+
//
|
|
504
|
+
// Resolve via resolveBin, NOT req.resolve('@webjsdev/ui/bin/webjsui.js'):
|
|
505
|
+
// the ui package's `exports` map does not list the bin subpath, so a
|
|
506
|
+
// direct subpath resolve throws ERR_PACKAGE_PATH_NOT_EXPORTED even though
|
|
507
|
+
// the file exists, which surfaced as a misleading "could not be resolved"
|
|
508
|
+
// (#1073). resolveBin resolves the `.` export, walks to the package root,
|
|
509
|
+
// and reads the `bin` map, exactly as `db` / `test --browser` do.
|
|
506
510
|
let entry;
|
|
507
511
|
try {
|
|
508
|
-
|
|
512
|
+
// Hard-dep path: @webjsdev/ui in the CLI's own node_modules.
|
|
513
|
+
entry = resolveBin(join(__dirname, '..'), '@webjsdev/ui', 'webjsui');
|
|
509
514
|
} catch {
|
|
510
|
-
// Fallback:
|
|
511
|
-
// workspace setups.
|
|
515
|
+
// Fallback: the user installed @webjsdev/ui directly in their project.
|
|
512
516
|
try {
|
|
513
|
-
|
|
514
|
-
entry = userReq.resolve('@webjsdev/ui/bin/webjsui.js');
|
|
517
|
+
entry = resolveBin(process.cwd(), '@webjsdev/ui', 'webjsui');
|
|
515
518
|
} catch {
|
|
516
519
|
console.error('@webjsdev/ui could not be resolved.');
|
|
517
520
|
console.error('Reinstall the CLI: npm install -g webjsdev');
|
|
518
521
|
process.exit(1);
|
|
519
522
|
}
|
|
520
523
|
}
|
|
521
|
-
const child = spawn(
|
|
524
|
+
const child = spawn(process.execPath, [entry, ...rest], { stdio: 'inherit', cwd: process.cwd() });
|
|
522
525
|
child.on('exit', (code) => process.exit(code ?? 0));
|
|
523
526
|
break;
|
|
524
527
|
}
|
package/package.json
CHANGED
|
@@ -91,11 +91,11 @@ html`<button class=${buttonClass({ variant: 'secondary', size: 'sm' })} @click=$
|
|
|
91
91
|
|
|
92
92
|
Why a class helper (not a `<ui-button>` wrapper): it adds NO indirection, so the element stays native (`@click`, `?disabled`, form submission, focus, a11y all just work) and the markup stays readable, while every button shares one source of truth (so no button can forget `cursor-pointer` or drift). Put the affordance every variant needs (like `cursor-pointer`) on the shared BASE.
|
|
93
93
|
|
|
94
|
-
**
|
|
94
|
+
**Default: `webjs ui add`, then modify. Do not hand-write a primitive from scratch.** For a repeated primitive with variants, run `webjs ui add <name>` then trim and theme the copied source. The scaffold already ships the `cn` prerequisite at `lib/utils/cn.ts`, so `add` works out of the box (a non-scaffold app runs `webjs ui init` once first to write `components.json`, the `cn` util, and the design tokens). The kit is shadcn-style, so `add` COPIES the helper's source INTO your `components/ui/` and you own and edit it exactly as freely as code you typed yourself. That is the key point: `add`-then-modify and hand-writing end at the SAME place (owned, editable class-helper source), so the difference is only the STARTING POINT. `add` starts you from vetted, variant-complete source you then adapt (and the copied header spells out the primitive's accessibility obligations), where hand-writing starts from a blank file and re-derives all of it for no benefit. Theme it to YOUR app (change the class values so the helper produces YOUR look, rather than bending your app to the kit's defaults) and keep only the parts you use (the gallery's `cardClass` is surface-only, since its panels vary their own padding and layout). Hand-author a primitive yourself ONLY for a one-off the kit does not cover, or a deliberate opt-out of the kit. Reserve `lib/utils/ui.ts` `html`-fragment helpers for repeated markup chunks; reserve `components/ui/*` class helpers for themed primitives with variants.
|
|
95
95
|
|
|
96
96
|
## Accessible native controls
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
Even with the kit, an app hand-authors SOME markup (a one-off primitive the kit does not cover, or the native element you wrap a class helper around), and there accessibility is your job (the `@webjsdev/ui` primitives carry their own, but a raw `<button>` / `<input>` does not). Three habits keep hand-authored interactive markup accessible on BOTH the JS and no-JS paths:
|
|
99
99
|
|
|
100
100
|
- **Associate a label with its control.** `<label for="email">` paired with `<input id="email">` (or wrap the control in the `<label>`), so a click on the label focuses the field and a screen reader announces it.
|
|
101
101
|
- **State a toggle's pressed state.** A button that toggles carries `aria-pressed=${on}` so assistive tech announces on/off, not just "button".
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
# The `@webjsdev/ui` component kit
|
|
2
2
|
|
|
3
|
-
Load this when the app
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Load this when the app uses `@webjsdev/ui` (a `components.json` is present), OR
|
|
4
|
+
when you are about to add a UI primitive (button, card, input, badge) to a fresh
|
|
5
|
+
app that has not initialised the kit yet: running `webjs ui init` then
|
|
6
|
+
`webjs ui add <name>` is HOW the kit comes to exist, and it is the default for a
|
|
7
|
+
repeated primitive over hand-writing one from scratch. `@webjsdev/ui` is the shadcn-style
|
|
8
|
+
kit for WebJs. The source is copied into your repo (`components/ui/`), so you own
|
|
9
|
+
and edit it exactly as freely as code you wrote yourself (the copied file is
|
|
10
|
+
yours to trim and theme). Two tiers:
|
|
6
11
|
|
|
7
12
|
- **Tier 1, class helpers (23 components).** Pure functions returning Tailwind
|
|
8
13
|
class strings (`buttonClass({ variant })`, `cardClass()`), composed with
|
package/templates/AGENTS.md
CHANGED
|
@@ -43,7 +43,8 @@ The order matters:
|
|
|
43
43
|
under `components/`, features under `modules/<feature>/`, server-only code
|
|
44
44
|
behind `.server.ts`. Build the app's OWN design system from the blank slate:
|
|
45
45
|
define design tokens in `app/layout.ts` and pull primitives with
|
|
46
|
-
`npx webjsdev ui add <name
|
|
46
|
+
`npx webjsdev ui add <name>` then theme the copied source (you own it, so
|
|
47
|
+
modify it rather than hand-writing a primitive from scratch), following
|
|
47
48
|
`.agents/skills/webjs/references/styling.md`.
|
|
48
49
|
|
|
49
50
|
If you are only exploring, keep the gallery and browse it.
|