@gjermundgaraba-designs/pixel-paper 0.13.0 → 0.14.1

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.
Files changed (130) hide show
  1. package/DESIGN.md +29 -22
  2. package/dist/src/announcer/announcer.d.ts +34 -26
  3. package/dist/src/announcer/announcer.d.ts.map +1 -1
  4. package/dist/src/announcer/announcer.js +42 -32
  5. package/dist/src/announcer/index.d.ts +1 -1
  6. package/dist/src/announcer/index.d.ts.map +1 -1
  7. package/dist/src/announcer/index.js +1 -1
  8. package/dist/src/banner/banner.d.ts +1 -1
  9. package/dist/src/banner/banner.js +1 -1
  10. package/dist/src/barChart/barChart.js +1 -1
  11. package/dist/src/board/board.d.ts +1 -4
  12. package/dist/src/board/board.d.ts.map +1 -1
  13. package/dist/src/board/board.js +8 -71
  14. package/dist/src/button/button.d.ts +1 -1
  15. package/dist/src/button/button.js +1 -1
  16. package/dist/src/card/card.d.ts +36 -9
  17. package/dist/src/card/card.d.ts.map +1 -1
  18. package/dist/src/card/card.js +46 -8
  19. package/dist/src/card/index.d.ts +2 -2
  20. package/dist/src/card/index.d.ts.map +1 -1
  21. package/dist/src/card/index.js +1 -1
  22. package/dist/src/commandPalette/commandPalette.d.ts +4 -0
  23. package/dist/src/commandPalette/commandPalette.d.ts.map +1 -1
  24. package/dist/src/confirmDialog/confirmDialog.d.ts +20 -27
  25. package/dist/src/confirmDialog/confirmDialog.d.ts.map +1 -1
  26. package/dist/src/confirmDialog/confirmDialog.js +23 -20
  27. package/dist/src/confirmDialog/index.d.ts +1 -1
  28. package/dist/src/confirmDialog/index.d.ts.map +1 -1
  29. package/dist/src/confirmDialog/index.js +1 -1
  30. package/dist/src/contextMenu/contextMenu.d.ts +6 -6
  31. package/dist/src/dialog/dialog.d.ts +40 -9
  32. package/dist/src/dialog/dialog.d.ts.map +1 -1
  33. package/dist/src/dialog/dialog.js +37 -15
  34. package/dist/src/dialog/index.d.ts +1 -1
  35. package/dist/src/dialog/index.d.ts.map +1 -1
  36. package/dist/src/dialog/index.js +1 -1
  37. package/dist/src/drag/drag.d.ts +40 -0
  38. package/dist/src/drag/drag.d.ts.map +1 -0
  39. package/dist/src/drag/drag.js +134 -0
  40. package/dist/src/emptyState/emptyState.d.ts +6 -4
  41. package/dist/src/emptyState/emptyState.d.ts.map +1 -1
  42. package/dist/src/emptyState/emptyState.js +1 -1
  43. package/dist/src/errorSummary/errorSummary.d.ts +1 -1
  44. package/dist/src/errorSummary/errorSummary.js +1 -1
  45. package/dist/src/index.d.ts +3 -0
  46. package/dist/src/index.d.ts.map +1 -1
  47. package/dist/src/index.js +3 -0
  48. package/dist/src/keyHelp/keyHelp.d.ts +4 -0
  49. package/dist/src/keyHelp/keyHelp.d.ts.map +1 -1
  50. package/dist/src/lineChart/lineChart.js +1 -1
  51. package/dist/src/liveRegion/index.d.ts +3 -0
  52. package/dist/src/liveRegion/index.d.ts.map +1 -0
  53. package/dist/src/liveRegion/index.js +1 -0
  54. package/dist/src/liveRegion/liveRegion.d.ts +42 -0
  55. package/dist/src/liveRegion/liveRegion.d.ts.map +1 -0
  56. package/dist/src/liveRegion/liveRegion.js +35 -0
  57. package/dist/src/loading/loading.d.ts +8 -3
  58. package/dist/src/loading/loading.d.ts.map +1 -1
  59. package/dist/src/loading/loading.js +4 -3
  60. package/dist/src/menu/menu.d.ts +6 -6
  61. package/dist/src/meter/meter.d.ts +3 -0
  62. package/dist/src/meter/meter.d.ts.map +1 -1
  63. package/dist/src/meter/meter.js +6 -3
  64. package/dist/src/remote/index.d.ts +3 -0
  65. package/dist/src/remote/index.d.ts.map +1 -0
  66. package/dist/src/remote/index.js +1 -0
  67. package/dist/src/remote/remote.d.ts +29 -0
  68. package/dist/src/remote/remote.d.ts.map +1 -0
  69. package/dist/src/remote/remote.js +41 -0
  70. package/dist/src/skipLink/index.d.ts +1 -1
  71. package/dist/src/skipLink/index.d.ts.map +1 -1
  72. package/dist/src/skipLink/index.js +1 -1
  73. package/dist/src/skipLink/skipLink.d.ts +24 -8
  74. package/dist/src/skipLink/skipLink.d.ts.map +1 -1
  75. package/dist/src/skipLink/skipLink.js +27 -8
  76. package/dist/src/sortable/index.d.ts +3 -0
  77. package/dist/src/sortable/index.d.ts.map +1 -0
  78. package/dist/src/sortable/index.js +1 -0
  79. package/dist/src/sortable/sortable.d.ts +1144 -0
  80. package/dist/src/sortable/sortable.d.ts.map +1 -0
  81. package/dist/src/sortable/sortable.js +504 -0
  82. package/dist/src/toast/index.d.ts +1 -1
  83. package/dist/src/toast/index.d.ts.map +1 -1
  84. package/dist/src/toast/index.js +1 -1
  85. package/dist/src/toast/toast.d.ts +32 -20
  86. package/dist/src/toast/toast.d.ts.map +1 -1
  87. package/dist/src/toast/toast.js +8 -3
  88. package/dist/src/topBar/barHeight.d.ts +6 -0
  89. package/dist/src/topBar/barHeight.d.ts.map +1 -1
  90. package/dist/src/topBar/barHeight.js +4 -0
  91. package/dist/src/topBar/index.d.ts +1 -1
  92. package/dist/src/topBar/index.d.ts.map +1 -1
  93. package/dist/src/topBar/index.js +1 -1
  94. package/dist/src/topBar/topBar.d.ts +1 -2
  95. package/dist/src/topBar/topBar.d.ts.map +1 -1
  96. package/package.json +1 -1
  97. package/src/announcer/announcer.ts +48 -32
  98. package/src/announcer/index.ts +1 -1
  99. package/src/banner/banner.ts +1 -1
  100. package/src/barChart/barChart.ts +1 -1
  101. package/src/board/board.ts +18 -87
  102. package/src/button/button.ts +1 -1
  103. package/src/card/card.ts +121 -21
  104. package/src/card/index.ts +2 -2
  105. package/src/confirmDialog/confirmDialog.ts +27 -33
  106. package/src/confirmDialog/index.ts +2 -0
  107. package/src/dialog/dialog.ts +47 -18
  108. package/src/dialog/index.ts +3 -1
  109. package/src/drag/drag.ts +207 -0
  110. package/src/emptyState/emptyState.ts +7 -5
  111. package/src/errorSummary/errorSummary.ts +1 -1
  112. package/src/index.ts +3 -0
  113. package/src/lineChart/lineChart.ts +1 -1
  114. package/src/liveRegion/index.ts +2 -0
  115. package/src/liveRegion/liveRegion.ts +75 -0
  116. package/src/loading/loading.ts +11 -5
  117. package/src/meter/meter.ts +17 -3
  118. package/src/pixel-paper.css +182 -27
  119. package/src/remote/index.ts +2 -0
  120. package/src/remote/remote.ts +76 -0
  121. package/src/skipLink/index.ts +1 -1
  122. package/src/skipLink/skipLink.ts +38 -9
  123. package/src/sortable/index.ts +14 -0
  124. package/src/sortable/sortable.ts +857 -0
  125. package/src/toast/index.ts +1 -0
  126. package/src/toast/toast.ts +9 -3
  127. package/src/tokens.css +13 -11
  128. package/src/topBar/barHeight.ts +6 -0
  129. package/src/topBar/index.ts +1 -1
  130. package/src/topBar/topBar.ts +1 -2
@@ -2,7 +2,6 @@ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
2
  import { Button as UiButton, DragAndDrop as UiDragAndDrop } from "@foldkit/ui";
3
3
  import { Array, Effect, Equal, Match, Option, Schema, Stream, pipe } from "effect";
4
4
  import * as Command from "foldkit/command";
5
- import * as Dom from "foldkit/dom";
6
5
  import { childAttributes, } from "foldkit/html";
7
6
  import { defineMessageUnion } from "foldkit/message";
8
7
  import * as Mount from "foldkit/mount";
@@ -17,6 +16,7 @@ import * as IconButton from "../iconButton/iconButton.js";
17
16
  import { LOCALE } from "../locale/locale.js";
18
17
  import { slotView } from "../slot/slot.js";
19
18
  import { prefixKeys } from "../subscription/prefixKeys.js";
19
+ import { LEFT_BUTTON, activatedKeyboardDrag, cancelledDrag, escapeKeys, innerControls, isCarrying, measureLift, phaseOf, pressedDraggable, } from "../drag/drag.js";
20
20
  // MODEL
21
21
  /** Schema for one card as the board knows it: its id, unique across the board, and its name
22
22
  * in words, which the grip and screen readers use. */
@@ -134,28 +134,8 @@ const columnHook = (model, columnId) => __foldkitBrandViewResult((hookId(id(mode
134
134
  const CARD_ATTRIBUTE = "board-card";
135
135
  const TITLE_ATTRIBUTE = "board-title";
136
136
  const GRIP_ATTRIBUTE = "board-grip";
137
- // PHASE
138
- const Phase = Schema.Literals(["Idle", "Pressed", "PointerDragging", "KeyboardDragging"]);
139
- // NOTE: @foldkit/ui gap: DragAndDrop has no accessor for which input holds a card.
140
- // `ghostStyle` is Some only while a pointer drags, so it tells a pointer drag from a keyboard
141
- // one.
142
- const phaseOf = (dragAndDrop) => {
143
- if (Option.isNone(UiDragAndDrop.maybeDraggedItemId(dragAndDrop))) {
144
- return __foldkitBrandViewResult(("Idle"), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#phaseOf");
145
- }
146
- else if (!UiDragAndDrop.isDragging(dragAndDrop)) {
147
- return __foldkitBrandViewResult(("Pressed"), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#phaseOf");
148
- }
149
- else if (Option.isSome(UiDragAndDrop.ghostStyle(dragAndDrop))) {
150
- return __foldkitBrandViewResult(("PointerDragging"), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#phaseOf");
151
- }
152
- else {
153
- return __foldkitBrandViewResult(("KeyboardDragging"), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#phaseOf");
154
- }
155
- };
156
- const isCarrying = (phase) => __foldkitBrandViewResult((phase === "PointerDragging" || phase === "KeyboardDragging"), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#isCarrying");
157
137
  // COMMAND
158
- /** Says a step of a move through the page's live region (`Announcer.announce`), which is
138
+ /** Says a step of a move through the page's live region (as `Announcer.Announce` does), which is
159
139
  * inside the topmost open dialog when there is one. */
160
140
  export const AnnounceMove = Command.define("AnnounceMove", {
161
141
  args: { text: Schema.String },
@@ -238,18 +218,6 @@ const settle = (previous, putBack = COPY.putBack) => __foldkitBrandViewResult(((
238
218
  commands: [...(dragAndDropUpdate.commands ?? []), ...announceMove(maybeText)],
239
219
  }, dragAndDropUpdate.outMessage)), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#anonymous~20");
240
220
  }), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#settle");
241
- // NOTE: @foldkit/ui gap: DragAndDrop exposes no update capability for a press, a keyboard
242
- // pick-up or a cancel, and its `draggable` bundle (`role="option"`, `tabindex`) cannot sit on
243
- // the grip's button, so the board builds these three child Messages itself.
244
- const pressedDraggable = (fields) =>
245
- // oxlint-disable-next-line foldkit/no-child-message-construction-in-root
246
- __foldkitBrandViewResult((UiDragAndDrop.Message.PressedDraggable(fields)), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#pressedDraggable");
247
- const activatedKeyboardDrag = (fields) =>
248
- // oxlint-disable-next-line foldkit/no-child-message-construction-in-root
249
- __foldkitBrandViewResult((UiDragAndDrop.Message.ActivatedKeyboardDrag(fields)), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#activatedKeyboardDrag");
250
- const cancelledDrag = () =>
251
- // oxlint-disable-next-line foldkit/no-child-message-construction-in-root
252
- __foldkitBrandViewResult((UiDragAndDrop.Message.CancelledDrag()), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#cancelledDrag");
253
221
  const holding = (model, held) => __foldkitBrandViewResult((modifyFields(model, { maybeHeld: () => __foldkitBrandViewResult((Option.some(held)), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#maybeHeld~2") })), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#holding");
254
222
  const canLift = (model) => __foldkitBrandViewResult((model.isMovable && phaseOf(model.dragAndDrop) === "Idle"), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#canLift");
255
223
  const liftByKeyboard = (model, place, columns) => {
@@ -345,28 +313,10 @@ export const setMovable = (model, isMovable) => {
345
313
  return __foldkitBrandViewResult((isMovable ? { model: next } : cancel(next)), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#setMovable");
346
314
  };
347
315
  // SUBSCRIPTION
348
- // NOTE: @foldkit/ui gap: DragAndDrop's own Escape cancels the move and lets the key travel
349
- // on, to a dialog around the board. The board takes the key first and stops it.
350
- /** Escape while a card is pressed or held cancels it and goes no further: it is taken on the
351
- * window, before the page's own key bindings or a dialog see it. */
352
- export const escapeMessage = (event) => {
353
- if (event.key !== "Escape" || event.isComposing) {
354
- return __foldkitBrandViewResult((Option.none()), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#escapeMessage");
355
- }
356
- event.preventDefault();
357
- event.stopPropagation();
358
- return __foldkitBrandViewResult((Option.some(Message.PressedEscape())), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#escapeMessage");
359
- };
360
- const escapeKeys = Dom.streamFromEventFilterMap({
361
- target: () => __foldkitBrandViewResult((window), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#target"),
362
- type: "keydown",
363
- filterMapEvent: escapeMessage,
364
- options: { capture: true },
365
- });
366
316
  const holdingSubscriptions = Subscription.make()((entry) => (__foldkitBrandViewResult(({
367
317
  escape: entry({ isHolding: Schema.Boolean }, {
368
318
  modelToDependencies: (model) => (__foldkitBrandViewResult(({ isHolding: isHolding(model) }), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#modelToDependencies")),
369
- dependenciesToStream: ({ isHolding: isHoldingNow }) => __foldkitBrandViewResult((isHoldingNow ? escapeKeys : Stream.empty), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#dependenciesToStream"),
319
+ dependenciesToStream: ({ isHolding: isHoldingNow }) => __foldkitBrandViewResult((isHoldingNow ? escapeKeys(Message.PressedEscape()) : Stream.empty), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#dependenciesToStream"),
370
320
  }),
371
321
  }), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#anonymous~35")));
372
322
  // NOTE: @foldkit/ui gap: DragAndDrop's Subscription keys are fixed, so two of its users on a
@@ -396,26 +346,11 @@ export const SizeLiftedCard = Mount.define("SizeLiftedCard", {
396
346
  args: { cardHook: Schema.String, pressX: Schema.Number, pressY: Schema.Number },
397
347
  messages: [Message.CompletedSizeLiftedCard],
398
348
  execute: ({ element, cardHook: hook, pressX, pressY }) => __foldkitBrandViewResult((Effect.sync(() => {
399
- const maybeCard = Option.fromNullishOr(document.querySelector(`[data-sortable-id="${CSS.escape(hook)}"]`));
400
- if (Option.isSome(maybeCard) && element instanceof HTMLElement) {
401
- const rect = maybeCard.value.getBoundingClientRect();
402
- element.style.setProperty("--lift-width", `${rect.width}px`);
403
- element.style.setProperty("--lift-x", `${rect.left - pressX}px`);
404
- element.style.setProperty("--lift-y", `${rect.top - pressY}px`);
405
- }
349
+ measureLift(element, `[data-sortable-id="${CSS.escape(hook)}"]`, pressX, pressY);
406
350
  return __foldkitBrandViewResult((Message.CompletedSizeLiftedCard()), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#anonymous~37");
407
351
  })), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#execute~2"),
408
352
  });
409
- const LEFT_BUTTON = 0;
410
- const INNER_CONTROL = [
411
- "input",
412
- "textarea",
413
- "select",
414
- "a[href]",
415
- '[contenteditable]:not([contenteditable="false"])',
416
- `button:not([data-${TITLE_ATTRIBUTE}]):not([data-${GRIP_ATTRIBUTE}])`,
417
- "[data-no-lift]",
418
- ].join(", ");
353
+ const INNER_CONTROL = innerControls(`[data-${TITLE_ATTRIBUTE}], [data-${GRIP_ATTRIBUTE}]`);
419
354
  const isInside = (outer, inner) => __foldkitBrandViewResult((inner !== null && outer.contains(inner)), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#isInside");
420
355
  /** Where a press on a card landed: its body, its grip, or a control inside it (none). */
421
356
  const pressSpotOf = (target) => {
@@ -549,7 +484,9 @@ const columnView = (info, column, h) => {
549
484
  ]),
550
485
  ...Array.match(items, {
551
486
  onEmpty: () => __foldkitBrandViewResult((info.toEmptyView(column)), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#onEmpty"),
552
- onNonEmpty: (cards) => __foldkitBrandViewResult(([h.ul([h.Class("board-cards")], cards)]), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#onNonEmpty"),
487
+ // NOTE: Safari takes list semantics from a list printed without markers, so the
488
+ // list says it is one
489
+ onNonEmpty: (cards) => __foldkitBrandViewResult(([h.ul([h.Role("list"), h.Class("board-cards")], cards)]), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#onNonEmpty"),
553
490
  }),
554
491
  ]),
555
492
  ])), "@gjermundgaraba-designs/pixel-paper/src/board/board.js#columnView");
@@ -64,7 +64,7 @@ export type ViewConfig<Message> = Look & Readonly<{
64
64
  * While busy it is `aria-busy` too.
65
65
  *
66
66
  * Enter in a field can still submit a form that has no live submit button, so the form's
67
- * own update must ignore a submit while its work is saving (see `Card`'s `onSubmit`).
67
+ * own update must ignore a submit while its work is saving (see `Card.formView`).
68
68
  */
69
69
  export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
70
70
  //# sourceMappingURL=button.d.ts.map
@@ -33,7 +33,7 @@ const wordsView = (label, maybeDone, h) => __foldkitBrandViewResult((Option.matc
33
33
  * While busy it is `aria-busy` too.
34
34
  *
35
35
  * Enter in a field can still submit a form that has no live submit button, so the form's
36
- * own update must ignore a submit while its work is saving (see `Card`'s `onSubmit`).
36
+ * own update must ignore a submit while its work is saving (see `Card.formView`).
37
37
  */
38
38
  export const view = (config, h) => {
39
39
  const { label, onClick, isBusy = false, isDisabled = false, type = "button", attributes = [], glyph, } = config;
@@ -11,11 +11,6 @@ export type ViewConfig<Message> = Readonly<{
11
11
  /** Attributes for the close glyph, such as a Dialog's `closeButton` group, which closes it.
12
12
  * The glyph prints when they are given. */
13
13
  closeAttributes?: Attributes<Message>;
14
- /** The close glyph is held while work the reader may not walk away from runs: it prints
15
- * held (`aria-disabled`), stays in the keyboard and drops `closeAttributes`, so a press does
16
- * nothing. Escape and the veil still send a Dialog's close request, so the parent's update
17
- * leaves that Message out while it holds the glyph (see `Dialog.isCloseRequest`). */
18
- isCloseHeld?: boolean;
19
14
  /** 440px instead of 680px: confirms, settings, sign-in. */
20
15
  isNarrow?: boolean;
21
16
  /** The action bar: a 2px ink rule, then these pushed right. Give the default `isDefault`. */
@@ -25,11 +20,43 @@ export type ViewConfig<Message> = Readonly<{
25
20
  /** Attributes for the action bar, such as a Dialog's `actionBar` group, which moves focus
26
21
  * between the actions with h, l and the side arrows. */
27
22
  actionBarAttributes?: Attributes<Message>;
28
- /** Makes the card a form, named by its title, so it is a form landmark; Enter in a field
29
- * submits it, whether or not its submit button is held. While the form's work is saving,
30
- * the parent's update must ignore this Message. */
31
- onSubmit?: Message;
32
23
  }>;
33
24
  /** The raised surface: paper in a 2px ink box on the 8px print shadow, under a title bar. */
34
25
  export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
26
+ /** Configuration for rendering a form card with `formView`: a card's, but for its body, its
27
+ * close attributes and its actions, which the form fills. `lead` stays the card's: what
28
+ * goes before the push, such as a form's own delete. */
29
+ export type FormViewConfig<Message> = Omit<ViewConfig<Message>, "body" | "closeAttributes" | "actions"> & Readonly<{
30
+ /** Unique in the document: the submit button's id is `submitId(id)`. */
31
+ id: string;
32
+ /** The form's content, fields and all, in one Fields group that `isBusy` holds. A link in
33
+ * it (an ErrorSummary's) stays live. */
34
+ body: ReadonlyArray<Html | string>;
35
+ /** The submit button's words. It prints primary, the card's default. */
36
+ submit: string;
37
+ /** The cancel button's words, before the submit. It closes through `closeAttributes`. */
38
+ cancel?: string;
39
+ /** Attributes for the close glyph and the cancel button, such as a Dialog's `closeButton`
40
+ * group, which closes it. The glyph prints when they are given. */
41
+ closeAttributes?: Attributes<Message>;
42
+ /** The form's work is running (it sends): the submit button is busy, the close glyph and
43
+ * cancel are held without `closeAttributes`, and the body is natively disabled, so
44
+ * nothing changes under the send and nothing sends twice. In a Dialog, hold its ways out
45
+ * too (`Dialog.setCloseHeld`), and let go of both where the send fails. Enter in a field can submit before the fields are held,
46
+ * so the update still ignores `onSubmit` while busy. */
47
+ isBusy?: boolean;
48
+ /** The form cannot be sent yet (nothing to send): the submit button is held as a Button
49
+ * is, and the fields and cancel stay live. Enter in a field can still submit, so the
50
+ * update ignores `onSubmit` while it cannot be sent. */
51
+ isSubmitDisabled?: boolean;
52
+ /** Sent when the form submits, by its button or by Enter in a field. */
53
+ onSubmit: Message;
54
+ }>;
55
+ /** The id of a form card's submit button. A send disables the fields, so focus in one falls
56
+ * to the page: the form's update moves it here as it sends, with
57
+ * `Focus.Focus({ id: Card.submitId(id) })`. */
58
+ export declare const submitId: (id: string) => string;
59
+ /** A card that is a form, named by its title, so a form landmark: its body in one Fields
60
+ * group, then cancel and the primary submit button in the action bar. */
61
+ export declare const formView: <Message>(config: FormViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
35
62
  //# sourceMappingURL=card.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/card/card.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAM9D,sDAAsD;AACtD,MAAM,MAAM,UAAU,CAAC,OAAO,IAAI,QAAQ,CAAC;IACzC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,eAAe,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IACnC;gDAC4C;IAC5C,eAAe,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACtC;;;0FAGsF;IACtF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6FAA6F;IAC7F,OAAO,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IACvC,uEAAuE;IACvE,IAAI,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IACpC;6DACyD;IACzD,mBAAmB,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC1C;;wDAEoD;IACpD,QAAQ,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CAAC,OAAO,CAAC,EACnB,MAAM,GAAG,iBAAiB,GAAG,SAAS,CACvC,GACC,QAAQ,CAAC;IACP,wEAAwE;IACxE,EAAE,EAAE,MAAM,CAAC;IACX;6CACyC;IACzC,IAAI,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IACnC,wEAAwE;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;wEACoE;IACpE,eAAe,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACtC;;;;6DAIyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;6DAEyD;IACzD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEL;;gDAEgD;AAChD,eAAO,MAAM,QAAQ,OAAQ,MAAM,KAAG,MAAwB,CAAC;AAE/D;0EAC0E;AAC1E,eAAO,MAAM,QAAQ,GAAI,OAAO,UACtB,cAAc,CAAC,OAAO,CAAC,KAC5B,WAAW,CAAC,OAAO,CAAC,KACtB,IAwDF,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
2
  import { Array } from "effect";
3
+ import * as Button from "../button/button.js";
4
+ import * as Fields from "../fields/fields.js";
3
5
  import * as IconButton from "../iconButton/iconButton.js";
4
6
  import { slotView } from "../slot/slot.js";
5
- /** The raised surface: paper in a 2px ink box on the 8px print shadow, under a title bar. */
6
- export const view = (config, h) => {
7
- const { title, titleAttributes = [], meta, body, closeAttributes, isCloseHeld = false, isNarrow = false, actions = [], lead = [], actionBarAttributes = [], onSubmit, } = config;
7
+ const childrenView = (config, h) => {
8
+ const { title, titleAttributes = [], meta, body, closeAttributes, isCloseHeld = false, actions = [], lead = [], actionBarAttributes = [], } = config;
8
9
  const titleBar = h.header([h.Class("card-tb")], [
9
10
  h.h2(titleAttributes, [title]),
10
11
  ...(meta === undefined ? [] : [h.span([h.Class("meta")], [meta])]),
@@ -23,9 +24,46 @@ export const view = (config, h) => {
23
24
  onEmpty: () => __foldkitBrandViewResult(([]), "@gjermundgaraba-designs/pixel-paper/src/card/card.js#onEmpty"),
24
25
  onNonEmpty: (bar) => __foldkitBrandViewResult(([h.div([...actionBarAttributes, h.Class("card-actions")], bar)]), "@gjermundgaraba-designs/pixel-paper/src/card/card.js#onNonEmpty"),
25
26
  });
26
- const children = [titleBar, h.div([h.Class("card-body")], body), ...actionBar];
27
- const rootAttributes = [h.Class(isNarrow ? "card narrow" : "card")];
28
- return __foldkitBrandViewResult((onSubmit === undefined
29
- ? h.div(rootAttributes, children)
30
- : h.form([...rootAttributes, h.AriaLabel(title), h.Novalidate(true), h.OnSubmit(onSubmit)], children)), "@gjermundgaraba-designs/pixel-paper/src/card/card.js#view");
27
+ return __foldkitBrandViewResult(([titleBar, h.div([h.Class("card-body")], body), ...actionBar]), "@gjermundgaraba-designs/pixel-paper/src/card/card.js#childrenView");
28
+ };
29
+ const className = (isNarrow) => __foldkitBrandViewResult((isNarrow === true ? "card narrow" : "card"), "@gjermundgaraba-designs/pixel-paper/src/card/card.js#className");
30
+ /** The raised surface: paper in a 2px ink box on the 8px print shadow, under a title bar. */
31
+ export const view = (config, h) => __foldkitBrandViewResult((h.div([h.Class(className(config.isNarrow))], childrenView(config, h))), "@gjermundgaraba-designs/pixel-paper/src/card/card.js#view");
32
+ /** The id of a form card's submit button. A send disables the fields, so focus in one falls
33
+ * to the page: the form's update moves it here as it sends, with
34
+ * `Focus.Focus({ id: Card.submitId(id) })`. */
35
+ export const submitId = (id) => __foldkitBrandViewResult((`${id}-submit`), "@gjermundgaraba-designs/pixel-paper/src/card/card.js#submitId");
36
+ /** A card that is a form, named by its title, so a form landmark: its body in one Fields
37
+ * group, then cancel and the primary submit button in the action bar. */
38
+ export const formView = (config, h) => {
39
+ const { id, title, submit, cancel, closeAttributes, isBusy = false, isSubmitDisabled = false, onSubmit, } = config;
40
+ const cancelButton = cancel === undefined
41
+ ? []
42
+ : [
43
+ Button.view({
44
+ label: cancel,
45
+ isDisabled: isBusy,
46
+ attributes: isBusy ? [] : (closeAttributes ?? []),
47
+ }, h),
48
+ ];
49
+ const submitButton = Button.view({
50
+ label: submit,
51
+ variant: "Primary",
52
+ isDefault: true,
53
+ isBusy,
54
+ isDisabled: isSubmitDisabled,
55
+ type: "submit",
56
+ attributes: [h.Id(submitId(id))],
57
+ }, h);
58
+ return __foldkitBrandViewResult((h.form([
59
+ h.Class(className(config.isNarrow)),
60
+ h.AriaLabel(title),
61
+ h.Novalidate(true),
62
+ h.OnSubmit(onSubmit),
63
+ ], childrenView({
64
+ ...config,
65
+ body: [Fields.view({ body: config.body, isBusy }, h)],
66
+ isCloseHeld: isBusy,
67
+ actions: [...cancelButton, submitButton],
68
+ }, h))), "@gjermundgaraba-designs/pixel-paper/src/card/card.js#formView");
31
69
  };
@@ -1,3 +1,3 @@
1
- export { view } from "./card.ts";
2
- export type { ViewConfig } from "./card.ts";
1
+ export { formView, submitId, view } from "./card.ts";
2
+ export type { FormViewConfig, ViewConfig } from "./card.ts";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/card/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
@@ -1 +1 @@
1
- export { view } from "./card.js";
1
+ export { formView, submitId, view } from "./card.js";
@@ -31,6 +31,7 @@ export declare const Model: Schema.Struct<{
31
31
  }>;
32
32
  readonly maybeFocusSelector: Schema.Option<Schema.String>;
33
33
  }>;
34
+ readonly isCloseHeld: Schema.Boolean;
34
35
  }>;
35
36
  readonly query: Schema.String;
36
37
  readonly maybeCursor: Schema.Option<Schema.String>;
@@ -126,6 +127,7 @@ export declare const update: (model: Model, message: Message) => Readonly<{
126
127
  };
127
128
  readonly maybeFocusSelector: Option.Option<string>;
128
129
  };
130
+ readonly isCloseHeld: boolean;
129
131
  };
130
132
  readonly query: string;
131
133
  readonly maybeCursor: Option.Option<string>;
@@ -289,6 +291,7 @@ export declare const subscriptions: <Prefix extends string>(keyPrefix: Prefix) =
289
291
  };
290
292
  readonly maybeFocusSelector: Option.Option<string>;
291
293
  };
294
+ readonly isCloseHeld: boolean;
292
295
  };
293
296
  readonly query: string;
294
297
  readonly maybeCursor: Option.Option<string>;
@@ -457,6 +460,7 @@ export declare const view: import("foldkit/submodel").View<{
457
460
  };
458
461
  readonly maybeFocusSelector: Option.Option<string>;
459
462
  };
463
+ readonly isCloseHeld: boolean;
460
464
  };
461
465
  readonly query: string;
462
466
  readonly maybeCursor: Option.Option<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"commandPalette.d.ts","sourceRoot":"","sources":["../../../src/commandPalette/commandPalette.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,MAAM,EAAS,MAAM,EAAE,MAAM,EAAwB,MAAM,QAAQ,CAAC;AACpF,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAa,IAAI,EAAkC,MAAM,cAAc,CAAC;AAKpF,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAoBzC,OAAO,KAAK,EAAU,OAAO,EAAQ,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAavC;;;;;;;;;;;kDAWkD;AAClD,eAAO,MA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;;;;;;;;;;;;;GAaG;AAOH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAnZf;oFACgF;cACtE,aAAa,CAAC,OAAO,CAAC;IAChC;wBACoB;YACZ,MAAM;IACd,mFAAmF;WAC5E,MAAM;IACb;;kCAE8B;mBACf,MAAM,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC;IACjD;0CACsC;uBACnB,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS;GAkZ5C,CAAC"}
@@ -16,11 +16,11 @@ export declare const Model: Schema.Struct<{
16
16
  }>;
17
17
  readonly maybeFocusSelector: Schema.Option<Schema.String>;
18
18
  }>;
19
+ readonly isCloseHeld: Schema.Boolean;
19
20
  }>;
20
21
  }>;
21
22
  export type Model = typeof Model.Type;
22
- /** Union of all Messages a confirm dialog can produce. `RequestedCloseWhileHeld`: Escape or a
23
- * press on the veil while `isCloseHeld` is set; nothing follows it. */
23
+ /** Union of all Messages a confirm dialog can produce. */
24
24
  export declare const Message: import("foldkit/message").MessageUnion<{
25
25
  readonly GotDialogMessage: {
26
26
  message: import("foldkit/message").MessageUnion<{
@@ -56,13 +56,12 @@ export declare const Message: import("foldkit/message").MessageUnion<{
56
56
  };
57
57
  readonly ClickedConfirm: {};
58
58
  readonly ClickedCancel: {};
59
- readonly RequestedCloseWhileHeld: {};
60
59
  }>;
61
60
  export type Message = typeof Message.Type;
62
61
  /** Union of OutMessages a confirm dialog reports. `Confirmed`: the reader pressed the action;
63
62
  * the dialog stays open until the parent calls `close`. `Cancelled`: cancel, Escape or a click
64
63
  * on the veil; the dialog has closed, and whether that also stops work already running is
65
- * the parent's to decide. Never reported while `isCloseHeld` is set. */
64
+ * the parent's to decide. Never reported while its ways out are held (`setCloseHeld`). */
66
65
  export declare const OutMessage: import("foldkit/message").MessageUnion<{
67
66
  readonly Confirmed: {};
68
67
  readonly Cancelled: {};
@@ -90,6 +89,7 @@ export declare const update: (model: Model, message: Message) => Readonly<{
90
89
  };
91
90
  readonly maybeFocusSelector: import("effect/Option").Option<string>;
92
91
  };
92
+ readonly isCloseHeld: boolean;
93
93
  };
94
94
  };
95
95
  commands?: Update.Commands<{
@@ -136,8 +136,6 @@ export declare const update: (model: Model, message: Message) => Readonly<{
136
136
  readonly _tag: "PressedActionKey";
137
137
  readonly direction: "Next" | "Previous";
138
138
  };
139
- } | {
140
- readonly _tag: "RequestedCloseWhileHeld";
141
139
  }, never>;
142
140
  outMessage?: {
143
141
  readonly _tag: "Cancelled";
@@ -145,15 +143,23 @@ export declare const update: (model: Model, message: Message) => Readonly<{
145
143
  readonly _tag: "Confirmed";
146
144
  };
147
145
  }>;
148
- /** Opens the confirm dialog: focus starts on the action, or on cancel when it is `isDanger`. */
146
+ /** Opens the confirm dialog with its ways out free: focus starts on the action, or on cancel
147
+ * when it is `isDanger`. */
149
148
  export declare const open: (model: Model) => Update.Return<Model, Message>;
150
- /** Closes the confirm dialog without reporting `Cancelled`: call it once confirmed work has
151
- * landed. */
149
+ /** Closes the confirm dialog without reporting `Cancelled`, and lets go of a hold: call it
150
+ * once confirmed work has landed. */
152
151
  export declare const close: (model: Model) => Update.Return<Model, Message>;
152
+ /** Holds cancel, Escape and the veil, or lets them go: while held the dialog stays open and
153
+ * reports no `Cancelled`, and cancel prints held (`aria-disabled`, in the keyboard). Hold it
154
+ * in the update that starts confirmed work whose failure must land here, and let go in the
155
+ * update where the work fails; `close` lets go once it lands. */
156
+ export declare const setCloseHeld: (model: Model, isHeld: boolean) => Model;
153
157
  /** The confirm dialog's id, unique in the document. */
154
158
  export declare const id: (model: Model) => string;
155
159
  /** Whether the confirm dialog is open. */
156
160
  export declare const isOpen: (model: Model) => boolean;
161
+ /** Whether its ways out are held (`setCloseHeld`). */
162
+ export declare const isCloseHeld: (model: Model) => boolean;
157
163
  /** Per-render inputs passed to `view` through `h.submodel`'s `viewInputs`. */
158
164
  export type ViewInputs = Readonly<{
159
165
  /** The title bar: the action's name (`"Delete"`). */
@@ -174,18 +180,12 @@ export type ViewInputs = Readonly<{
174
180
  isDanger?: boolean;
175
181
  /** The confirmed work is running: the confirming button is held (its word stays, the
176
182
  * working cursor prints, a second press does nothing) and keeps focus. Cancel stays live
177
- * unless `isCloseHeld`. */
183
+ * unless the dialog's ways out are held (`setCloseHeld`). */
178
184
  isBusy?: boolean;
179
185
  /** The action cannot run now (nothing is running; it is blocked): the confirming button is
180
186
  * held, `aria-disabled` without the working cursor, and stays in the keyboard, so focus
181
187
  * does not fall to the page. Cancel stays live. */
182
188
  isDisabled?: boolean;
183
- /** The reader may not walk away from the work running now (a delete whose failure must
184
- * land in this dialog): cancel is held as a Button is (`aria-disabled`, in the keyboard,
185
- * a press does nothing), and Escape and a press on the veil leave the
186
- * dialog open, so it reports no `Cancelled` while this is set. `close` still closes it.
187
- * Usually set with `isBusy`. */
188
- isCloseHeld?: boolean;
189
189
  /** The page's live region and toasts while this is the topmost open dialog, `undefined`
190
190
  * while it is not (see `Dialog`). */
191
191
  toLiveRegionView?: (() => Html) | undefined;
@@ -200,8 +200,8 @@ export type ViewInputs = Readonly<{
200
200
  * double-click through.
201
201
  *
202
202
  * Work that takes a while stays in the dialog: set `isBusy` while it runs, `close` once it
203
- * has landed, and on failure keep it open with the error in `toDetailView`. Set
204
- * `isCloseHeld` with it when the reader must stay to see how it ends.
203
+ * has landed, and on failure keep it open with the error in `toDetailView`. Hold its ways
204
+ * out with `setCloseHeld` too when the reader must stay to see how it ends.
205
205
  */
206
206
  export declare const view: import("foldkit/submodel").View<{
207
207
  readonly dialog: {
@@ -217,6 +217,7 @@ export declare const view: import("foldkit/submodel").View<{
217
217
  };
218
218
  readonly maybeFocusSelector: import("effect/Option").Option<string>;
219
219
  };
220
+ readonly isCloseHeld: boolean;
220
221
  };
221
222
  }, {
222
223
  readonly _tag: "ClickedCancel";
@@ -262,8 +263,6 @@ export declare const view: import("foldkit/submodel").View<{
262
263
  readonly _tag: "PressedActionKey";
263
264
  readonly direction: "Next" | "Previous";
264
265
  };
265
- } | {
266
- readonly _tag: "RequestedCloseWhileHeld";
267
266
  }, Readonly<{
268
267
  /** The title bar: the action's name (`"Delete"`). */
269
268
  title: string;
@@ -283,18 +282,12 @@ export declare const view: import("foldkit/submodel").View<{
283
282
  isDanger?: boolean;
284
283
  /** The confirmed work is running: the confirming button is held (its word stays, the
285
284
  * working cursor prints, a second press does nothing) and keeps focus. Cancel stays live
286
- * unless `isCloseHeld`. */
285
+ * unless the dialog's ways out are held (`setCloseHeld`). */
287
286
  isBusy?: boolean;
288
287
  /** The action cannot run now (nothing is running; it is blocked): the confirming button is
289
288
  * held, `aria-disabled` without the working cursor, and stays in the keyboard, so focus
290
289
  * does not fall to the page. Cancel stays live. */
291
290
  isDisabled?: boolean;
292
- /** The reader may not walk away from the work running now (a delete whose failure must
293
- * land in this dialog): cancel is held as a Button is (`aria-disabled`, in the keyboard,
294
- * a press does nothing), and Escape and a press on the veil leave the
295
- * dialog open, so it reports no `Cancelled` while this is set. `close` still closes it.
296
- * Usually set with `isBusy`. */
297
- isCloseHeld?: boolean;
298
291
  /** The page's live region and toasts while this is the topmost open dialog, `undefined`
299
292
  * while it is not (see `Dialog`). */
300
293
  toLiveRegionView?: (() => Html) | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"confirmDialog.d.ts","sourceRoot":"","sources":["../../../src/confirmDialog/confirmDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAItD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAUzC,uEAAuE;AACvE,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;EAEhB,CAAC;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI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,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,CAAC;IACjB;;uCAEmC;IACnC,IAAI,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IACnC;;oBAEgB;IAChB,YAAY,CAAC,EAAE,MAAM,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IAClD,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;kEAE8D;IAC9D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;wDAEoD;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;0CACsC;IACtC,gBAAgB,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;CAC7C,CAAC,CAAC;AAyDH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAjGf,qDAAqD;WAC9C,MAAM;IACb,6FAA6F;cACnF,MAAM;IAChB;;uCAEmC;UAC7B,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC;IAClC;;oBAEgB;mBACD,MAAM,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC;IACjD,iDAAiD;WAC1C,MAAM;IACb,mFAAmF;eACxE,OAAO;IAClB;;kEAE8D;aACrD,OAAO;IAChB;;wDAEoD;iBACvC,OAAO;IACpB;0CACsC;uBACnB,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS;GAoF5C,CAAC"}
@@ -15,19 +15,17 @@ export const Model = Schema.Struct({
15
15
  dialog: Dialog.Model,
16
16
  });
17
17
  // MESSAGE
18
- /** Union of all Messages a confirm dialog can produce. `RequestedCloseWhileHeld`: Escape or a
19
- * press on the veil while `isCloseHeld` is set; nothing follows it. */
18
+ /** Union of all Messages a confirm dialog can produce. */
20
19
  export const Message = defineMessageUnion({
21
20
  GotDialogMessage: { message: Dialog.Message },
22
21
  ClickedConfirm: {},
23
22
  ClickedCancel: {},
24
- RequestedCloseWhileHeld: {},
25
23
  });
26
24
  // OUT MESSAGE
27
25
  /** Union of OutMessages a confirm dialog reports. `Confirmed`: the reader pressed the action;
28
26
  * the dialog stays open until the parent calls `close`. `Cancelled`: cancel, Escape or a click
29
27
  * on the veil; the dialog has closed, and whether that also stops work already running is
30
- * the parent's to decide. Never reported while `isCloseHeld` is set. */
28
+ * the parent's to decide. Never reported while its ways out are held (`setCloseHeld`). */
31
29
  export const OutMessage = defineMessageUnion({
32
30
  Confirmed: {},
33
31
  Cancelled: {},
@@ -50,21 +48,30 @@ const dialogFold = foldDialog(Dialog, {
50
48
  export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
51
49
  GotDialogMessage: ({ message: dialogMessage }) => __foldkitBrandViewResult((dialogFold.update(model, dialogMessage)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#GotDialogMessage"),
52
50
  ClickedConfirm: () => (__foldkitBrandViewResult(({ model, outMessage: OutMessage.Confirmed() }), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#ClickedConfirm")),
53
- ClickedCancel: () => __foldkitBrandViewResult((pipe(dialogFold.close(model), Update.withOutMessage(OutMessage.Cancelled()))), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#ClickedCancel"),
54
- RequestedCloseWhileHeld: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#RequestedCloseWhileHeld")),
51
+ ClickedCancel: () => __foldkitBrandViewResult((Dialog.isCloseHeld(model.dialog)
52
+ ? { model }
53
+ : pipe(dialogFold.close(model), Update.withOutMessage(OutMessage.Cancelled()))), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#ClickedCancel"),
55
54
  })), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#update");
56
- /** Opens the confirm dialog: focus starts on the action, or on cancel when it is `isDanger`. */
55
+ /** Opens the confirm dialog with its ways out free: focus starts on the action, or on cancel
56
+ * when it is `isDanger`. */
57
57
  export const open = (model) => __foldkitBrandViewResult((dialogFold.open(model)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#open");
58
- /** Closes the confirm dialog without reporting `Cancelled`: call it once confirmed work has
59
- * landed. */
58
+ /** Closes the confirm dialog without reporting `Cancelled`, and lets go of a hold: call it
59
+ * once confirmed work has landed. */
60
60
  export const close = (model) => __foldkitBrandViewResult((dialogFold.close(model)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#close");
61
+ /** Holds cancel, Escape and the veil, or lets them go: while held the dialog stays open and
62
+ * reports no `Cancelled`, and cancel prints held (`aria-disabled`, in the keyboard). Hold it
63
+ * in the update that starts confirmed work whose failure must land here, and let go in the
64
+ * update where the work fails; `close` lets go once it lands. */
65
+ export const setCloseHeld = (model, isHeld) => __foldkitBrandViewResult((modifyFields(model, { dialog: (dialog) => __foldkitBrandViewResult((Dialog.setCloseHeld(dialog, isHeld)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#dialog~2") })), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#setCloseHeld");
61
66
  // ACCESSORS
62
67
  /** The confirm dialog's id, unique in the document. */
63
68
  export const id = (model) => __foldkitBrandViewResult((Dialog.id(model.dialog)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#id");
64
69
  /** Whether the confirm dialog is open. */
65
70
  export const isOpen = (model) => __foldkitBrandViewResult((Dialog.isOpen(model.dialog)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#isOpen");
66
- const cardView = (viewInputs, render, h) => {
67
- const { isDanger = false, isBusy = false, isDisabled = false, isCloseHeld = false, toDetailView, } = viewInputs;
71
+ /** Whether its ways out are held (`setCloseHeld`). */
72
+ export const isCloseHeld = (model) => __foldkitBrandViewResult((Dialog.isCloseHeld(model.dialog)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#isCloseHeld");
73
+ const cardView = (model, viewInputs, render, h) => {
74
+ const { isDanger = false, isBusy = false, isDisabled = false, toDetailView } = viewInputs;
68
75
  const commit = Button.view({
69
76
  label: viewInputs.label,
70
77
  variant: isDanger ? "Danger" : "Primary",
@@ -77,7 +84,7 @@ const cardView = (viewInputs, render, h) => {
77
84
  const cancel = Button.view({
78
85
  label: "cancel",
79
86
  isDefault: isDanger,
80
- isDisabled: isCloseHeld,
87
+ isDisabled: Dialog.isCloseHeld(model.dialog),
81
88
  onClick: Message.ClickedCancel(),
82
89
  attributes: isDanger ? render.initialFocus : [],
83
90
  }, h);
@@ -108,8 +115,8 @@ const cardView = (viewInputs, render, h) => {
108
115
  * double-click through.
109
116
  *
110
117
  * Work that takes a while stays in the dialog: set `isBusy` while it runs, `close` once it
111
- * has landed, and on failure keep it open with the error in `toDetailView`. Set
112
- * `isCloseHeld` with it when the reader must stay to see how it ends.
118
+ * has landed, and on failure keep it open with the error in `toDetailView`. Hold its ways
119
+ * out with `setCloseHeld` too when the reader must stay to see how it ends.
113
120
  */
114
121
  export const view = defineView((model, viewInputs, h) => __foldkitBrandViewResult((h.submodel({
115
122
  slotId: id(model),
@@ -119,11 +126,7 @@ export const view = defineView((model, viewInputs, h) => __foldkitBrandViewResul
119
126
  isAlert: viewInputs.isDanger ?? false,
120
127
  hasDescription: true,
121
128
  toLiveRegionView: viewInputs.toLiveRegionView,
122
- toView: (render) => __foldkitBrandViewResult((cardView(viewInputs, render, h)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#toView"),
129
+ toView: (render) => __foldkitBrandViewResult((cardView(model, viewInputs, render, h)), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#toView"),
123
130
  },
124
- // NOTE: while closing is held, Escape and a press on the veil are handed on as
125
- // `RequestedCloseWhileHeld` instead of reaching the Dialog.
126
- toParentMessage: (message) => __foldkitBrandViewResult((viewInputs.isCloseHeld === true && Dialog.isCloseRequest(message)
127
- ? Message.RequestedCloseWhileHeld()
128
- : Message.GotDialogMessage({ message })), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#toParentMessage~2"),
131
+ toParentMessage: (message) => __foldkitBrandViewResult((Message.GotDialogMessage({ message })), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#toParentMessage~2"),
129
132
  })), "@gjermundgaraba-designs/pixel-paper/src/confirmDialog/confirmDialog.js#anonymous"));
@@ -1,3 +1,3 @@
1
- export { Message, Model, OutMessage, close, id, init, isOpen, open, update, view, } from "./confirmDialog.ts";
1
+ export { Message, Model, OutMessage, close, id, init, isCloseHeld, isOpen, open, setCloseHeld, update, view, } from "./confirmDialog.ts";
2
2
  export type { InitConfig, ViewInputs } from "./confirmDialog.ts";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/confirmDialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EACL,UAAU,EACV,KAAK,EACL,EAAE,EACF,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,IAAI,GACL,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/confirmDialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EACL,UAAU,EACV,KAAK,EACL,EAAE,EACF,IAAI,EACJ,WAAW,EACX,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,IAAI,GACL,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}