@jsenv/navi 0.29.443 → 0.29.445

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.
@@ -114,8 +114,8 @@ start when unsure which export solves a problem.
114
114
  Before any handler whose body only assigns state.
115
115
  - `control_value.md` — who holds a control's value; `--navi-update` for a button
116
116
  proposing one; a `defaultValue` follows the record it was read from; empty
117
- keeps the shape of the question. Before wiring a value with `value` +
118
- `uiAction`.
117
+ keeps the shape of the question; what a checkbox is worth (`boolean` for a
118
+ yes/no). Before wiring a value with `value` + `uiAction`.
119
119
  - `control_object.md` — one value made of several controls: `ControlGroup` versus
120
120
  `Form`, naming, `<Picker type="object">`, a settings sheet, controls that are
121
121
  not there (lazy slides, popups, deferred boxes, items outside the render
@@ -226,8 +226,10 @@ start when unsure which export solves a problem.
226
226
  `<Input type="checkbox">`/`<Input type="radio">`; there is no `Checkbox`),
227
227
  `Select`, `Picker` and the others work with nothing wired: inside a `Form`, the
228
228
  form reads them when it sends. When the app needs the value, bind it with
229
- `signal`. `action` reacts to a change that can fail or take time; it is not how
230
- a control is wired. Never `onChange` + manual state.
229
+ `signal`. A checkbox is HTML's (`"on"` or its `value`, `undefined` unchecked);
230
+ a yes/no is `<Input type="checkbox" boolean>`, `true` or `false`. `action`
231
+ reacts to a change that can fail or take time; it is not how a control is
232
+ wired. Never `onChange` + manual state.
231
233
  - **A gesture is named, not read by hand**: `interactions={{ swipe_right: … }}`
232
234
  on any `Box`, so on any component — never a `pointerdown` listener of your own.
233
235
  - **Texts**: a user-visible sentence containing a value is one template with
package/docs/actions.md CHANGED
@@ -313,13 +313,17 @@ the control's value, so the callback receives what the control now holds.
313
313
  ```jsx
314
314
  // ✓ the box shows it is saving, says so if the save fails, and goes back to
315
315
  // where it was — nothing to write for any of it
316
- <Input type="checkbox" action={(visibility) => saveMe({ visibility })} />
316
+ <Input type="checkbox" boolean action={(visibility) => saveMe({ visibility })} />
317
317
 
318
318
  // ✗ same save, and the user learns nothing: no pending state, and a failure
319
319
  // leaves the box showing something the server never accepted
320
- <Input type="checkbox" uiAction={(visibility) => saveMe({ visibility })} />
320
+ <Input type="checkbox" boolean uiAction={(visibility) => saveMe({ visibility })} />
321
321
  ```
322
322
 
323
+ `boolean` makes the box a yes/no, `true` or `false`; without it, unchecked is
324
+ `undefined` and the save sends nothing (see
325
+ [control_value.md](./control_value.md#what-a-checkbox-is-worth)).
326
+
323
327
  The give-away is an `async` `uiAction`, or one that calls something that writes:
324
328
  `uiAction` never waits for what it starts, so nobody is left holding the result.
325
329
  To merely REMEMBER the value rather than send it, neither is the answer: bind a
@@ -14,6 +14,7 @@ somewhere else in the app.
14
14
  - [Drawing what a control holds](#drawing-what-a-control-holds)
15
15
  - [What a signal holds, control by control](#what-a-signal-holds-control-by-control)
16
16
  - [Empty keeps the shape of the question](#empty-keeps-the-shape-of-the-question)
17
+ - [What a checkbox is worth](#what-a-checkbox-is-worth)
17
18
  - [Which controls take a `signal`](#which-controls-take-a-signal)
18
19
  - [The PROP is what controls, not its value](#the-prop-is-what-controls-not-its-value)
19
20
  - [A yes/no shown as two rows](#a-yesno-shown-as-two-rows)
@@ -281,18 +282,37 @@ it holds something. A list of days nobody picked is `[]`, not `""`:
281
282
  | `Picker type="array"`, `List selectable multiple` | `[]` |
282
283
  | `Picker type="object"` | `{}` |
283
284
  | text/number/date `Input`, `Select` | `""` |
284
- | `Input type="checkbox" value={true}` | `false` |
285
- | radio, checkbox holding a value of its own | absent |
285
+ | `Input type="checkbox" boolean` | `false` |
286
+ | radio, any other checkbox | absent |
286
287
 
287
288
  This is what a clear (`--navi-clear`, a row's cross) leaves behind and what the
288
289
  object around it carries, so `value.days || []` is not needed.
289
290
 
290
- A checkbox is a member of a set, the way HTML has it: checked it carries its
291
- `value` (`"on"` when it was given none), unchecked it carries nothing at all —
292
- which is what lets several checkboxes sharing a name aggregate into an array. A
293
- checkbox that is a yes/no says so with `value={true}`, and is then `true` or
294
- `false`. Its bound `signal` holds the boolean either way: what a signal on a
295
- checkbox is about is whether it is checked.
291
+ ## What a checkbox is worth
292
+
293
+ A checkbox answers the way HTML's does: checked it carries its `value`,
294
+ unchecked it carries nothing. `boolean` makes it a yes/no instead:
295
+
296
+ | checkbox | checked | unchecked |
297
+ | -------------- | -------- | ----------- |
298
+ | no `value` | `"on"` | `undefined` |
299
+ | `value="toto"` | `"toto"` | `undefined` |
300
+ | `value={true}` | `true` | `undefined` |
301
+ | `boolean` | `true` | `false` |
302
+
303
+ That is what it hands everywhere: to its own `action` and `uiAction`, and to
304
+ the form or group around it. Only a bound `signal` differs: it holds whether the
305
+ box is checked, a boolean in every row above.
306
+
307
+ Choose by what the box asks:
308
+
309
+ - **A yes/no** (a setting, a consent, a favourite) is `boolean`. Unchecked has
310
+ to say "no", and `undefined` says nothing: `{ favourite: undefined }` is sent
311
+ as `{}`, the server changes nothing, and the box shows a "no" nobody
312
+ accepted.
313
+ - **A member of a set** (several checkboxes sharing a `name`, each adding its
314
+ value) takes its own `value`, or none for `"on"`. Unchecked carries nothing,
315
+ so the group gathers only the checked ones into an array.
296
316
 
297
317
  ## Which controls take a `signal`
298
318
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/navi",
3
- "version": "0.29.443",
3
+ "version": "0.29.445",
4
4
  "type": "module",
5
5
  "description": "Library of components including navigation to create frontend applications",
6
6
  "repository": {