microtags 0.0.13 → 0.0.14
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/README.md +13 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -262,11 +262,11 @@ export const myCounter = define('my-counter')
|
|
|
262
262
|
There are two separate things people call "validation":
|
|
263
263
|
|
|
264
264
|
1. **Prop validation** checks the attributes passed into a component.
|
|
265
|
-
Pass a [Standard Schema](https://standardschema.dev)
|
|
266
|
-
ArkType) to [`p.schema`](#withprops)
|
|
267
|
-
and falls back to `undefined` when the value doesn't coerce.
|
|
268
|
-
2. **Form input validation** -- client-side validation -- checks live user
|
|
269
|
-
in a form, for example a value that changes on every keystroke.
|
|
265
|
+
Pass a [Standard Schema](https://standardschema.dev)
|
|
266
|
+
(Zod, Valibot, ArkType) to [`p.schema`](#withprops), and it coerces the
|
|
267
|
+
attribute value and falls back to `undefined` when the value doesn't coerce.
|
|
268
|
+
2. **Form input validation** -- aka client-side validation -- checks live user
|
|
269
|
+
input in a form, for example a value that changes on every keystroke.
|
|
270
270
|
There is no dedicated API for this. Validate the schema directly
|
|
271
271
|
inside `.setup()` and hold the result as a signal.
|
|
272
272
|
|
|
@@ -413,19 +413,13 @@ and the submit button is disabled until valid. See `example/subscribe-form.ts`.
|
|
|
413
413
|
|
|
414
414
|
## Serverside Example
|
|
415
415
|
|
|
416
|
-
See [./example/ssr.ts](./example/ssr.ts)
|
|
416
|
+
See [./example/ssr.ts](./example/ssr.ts) for an example of rendering an HTML
|
|
417
|
+
string and then "hydrating" the page on the client.
|
|
417
418
|
|
|
418
419
|
### `.TAG`
|
|
419
420
|
|
|
420
|
-
Each tag name
|
|
421
|
-
|
|
422
|
-
even though Node does not have browser APIs.
|
|
423
|
-
|
|
424
|
-
The `data-ref` attribute is a fallback. It's used when you don't pass a
|
|
425
|
-
selector to `r.one()`. If you pass explicit CSS selectors to `withRefs`,
|
|
426
|
-
e.g. `{ copy: r.one('button') }`, then the HTML does not require a `data-ref`
|
|
427
|
-
attribute.
|
|
428
|
-
|
|
421
|
+
Each tag name is exposed as a property `.TAG`. You can import the web
|
|
422
|
+
components in Node, even though Node does not have browser APIs.
|
|
429
423
|
|
|
430
424
|
```ts
|
|
431
425
|
import { MyCounter, CountBtn, CopyBtn } from './index.js'
|
|
@@ -469,9 +463,8 @@ export function render ():string {
|
|
|
469
463
|
|
|
470
464
|
### `.refs`
|
|
471
465
|
|
|
472
|
-
Web components created with `microtags` have a property `.refs
|
|
473
|
-
object of
|
|
474
|
-
`data-ref` attributes.
|
|
466
|
+
Web components created with `microtags` have a property `.refs`. It is an
|
|
467
|
+
object of ref names you passed in. Use it to create `data-ref` attributes.
|
|
475
468
|
|
|
476
469
|
```ts
|
|
477
470
|
import { MyCounter } from '../example.js'
|
|
@@ -494,12 +487,12 @@ export function render () {
|
|
|
494
487
|
|
|
495
488
|
### `define`
|
|
496
489
|
|
|
490
|
+
Function `define(tagName)` returns a [`ComponentBuilder`](#componentbuilder).
|
|
491
|
+
|
|
497
492
|
```js
|
|
498
493
|
function define (tagName:string):ComponentBuilder
|
|
499
494
|
```
|
|
500
495
|
|
|
501
|
-
Function `define(tagName)` returns a [`ComponentBuilder`](#componentbuilder).
|
|
502
|
-
|
|
503
496
|
|
|
504
497
|
#### `ComponentBuilder`
|
|
505
498
|
|