@foldkit/ui 0.148.2 → 0.149.0

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 (129) hide show
  1. package/dist/animation/index.d.ts +3 -3
  2. package/dist/animation/index.d.ts.map +1 -1
  3. package/dist/animation/index.js +2 -2
  4. package/dist/animation/public.d.ts +1 -1
  5. package/dist/animation/public.d.ts.map +1 -1
  6. package/dist/animation/public.js +1 -1
  7. package/dist/animation/schema.d.ts +12 -21
  8. package/dist/animation/schema.d.ts.map +1 -1
  9. package/dist/animation/schema.js +11 -15
  10. package/dist/animation/update.d.ts +1 -1
  11. package/dist/animation/update.d.ts.map +1 -1
  12. package/dist/animation/update.js +9 -9
  13. package/dist/calendar/index.d.ts +50 -105
  14. package/dist/calendar/index.d.ts.map +1 -1
  15. package/dist/calendar/index.js +61 -98
  16. package/dist/calendar/public.d.ts +1 -1
  17. package/dist/calendar/public.d.ts.map +1 -1
  18. package/dist/calendar/public.js +1 -1
  19. package/dist/combobox/multi.d.ts +9 -9
  20. package/dist/combobox/multi.d.ts.map +1 -1
  21. package/dist/combobox/multi.js +9 -9
  22. package/dist/combobox/public.d.ts +1 -1
  23. package/dist/combobox/public.d.ts.map +1 -1
  24. package/dist/combobox/public.js +1 -1
  25. package/dist/combobox/shared.d.ts +93 -137
  26. package/dist/combobox/shared.d.ts.map +1 -1
  27. package/dist/combobox/shared.js +108 -153
  28. package/dist/combobox/single.d.ts +9 -9
  29. package/dist/combobox/single.d.ts.map +1 -1
  30. package/dist/combobox/single.js +10 -10
  31. package/dist/datePicker/index.d.ts +88 -84
  32. package/dist/datePicker/index.d.ts.map +1 -1
  33. package/dist/datePicker/index.js +33 -63
  34. package/dist/datePicker/public.d.ts +1 -1
  35. package/dist/datePicker/public.d.ts.map +1 -1
  36. package/dist/datePicker/public.js +1 -1
  37. package/dist/dialog/index.d.ts +28 -49
  38. package/dist/dialog/index.d.ts.map +1 -1
  39. package/dist/dialog/index.js +39 -67
  40. package/dist/dialog/public.d.ts +1 -1
  41. package/dist/dialog/public.d.ts.map +1 -1
  42. package/dist/dialog/public.js +1 -1
  43. package/dist/dragAndDrop/index.d.ts +45 -72
  44. package/dist/dragAndDrop/index.d.ts.map +1 -1
  45. package/dist/dragAndDrop/index.js +72 -93
  46. package/dist/dragAndDrop/public.d.ts +1 -1
  47. package/dist/dragAndDrop/public.d.ts.map +1 -1
  48. package/dist/dragAndDrop/public.js +1 -1
  49. package/dist/fileDrop/index.d.ts +14 -35
  50. package/dist/fileDrop/index.d.ts.map +1 -1
  51. package/dist/fileDrop/index.js +20 -46
  52. package/dist/fileDrop/public.d.ts +1 -1
  53. package/dist/fileDrop/public.d.ts.map +1 -1
  54. package/dist/fileDrop/public.js +1 -1
  55. package/dist/listbox/multi.d.ts +7 -7
  56. package/dist/listbox/multi.d.ts.map +1 -1
  57. package/dist/listbox/multi.js +8 -8
  58. package/dist/listbox/public.d.ts +1 -1
  59. package/dist/listbox/public.d.ts.map +1 -1
  60. package/dist/listbox/public.js +1 -1
  61. package/dist/listbox/shared.d.ts +80 -127
  62. package/dist/listbox/shared.d.ts.map +1 -1
  63. package/dist/listbox/shared.js +92 -149
  64. package/dist/listbox/single.d.ts +7 -7
  65. package/dist/listbox/single.d.ts.map +1 -1
  66. package/dist/listbox/single.js +8 -8
  67. package/dist/menu/index.d.ts +86 -134
  68. package/dist/menu/index.d.ts.map +1 -1
  69. package/dist/menu/index.js +141 -189
  70. package/dist/menu/public.d.ts +1 -1
  71. package/dist/menu/public.d.ts.map +1 -1
  72. package/dist/menu/public.js +1 -1
  73. package/dist/popover/index.d.ts +39 -65
  74. package/dist/popover/index.d.ts.map +1 -1
  75. package/dist/popover/index.js +68 -98
  76. package/dist/popover/public.d.ts +1 -1
  77. package/dist/popover/public.d.ts.map +1 -1
  78. package/dist/popover/public.js +1 -1
  79. package/dist/radioGroup/index.d.ts +18 -29
  80. package/dist/radioGroup/index.d.ts.map +1 -1
  81. package/dist/radioGroup/index.js +22 -27
  82. package/dist/radioGroup/public.d.ts +1 -1
  83. package/dist/radioGroup/public.d.ts.map +1 -1
  84. package/dist/radioGroup/public.js +1 -1
  85. package/dist/slider/index.d.ts +29 -51
  86. package/dist/slider/index.d.ts.map +1 -1
  87. package/dist/slider/index.js +36 -56
  88. package/dist/slider/public.d.ts +1 -1
  89. package/dist/slider/public.d.ts.map +1 -1
  90. package/dist/slider/public.js +1 -1
  91. package/dist/tabs/index.d.ts +18 -28
  92. package/dist/tabs/index.d.ts.map +1 -1
  93. package/dist/tabs/index.js +22 -26
  94. package/dist/tabs/public.d.ts +1 -1
  95. package/dist/tabs/public.d.ts.map +1 -1
  96. package/dist/tabs/public.js +1 -1
  97. package/dist/test/apps/disabledButton.d.ts +71 -14
  98. package/dist/test/apps/disabledButton.d.ts.map +1 -1
  99. package/dist/test/apps/disabledButton.js +14 -13
  100. package/dist/toast/index.d.ts +124 -109
  101. package/dist/toast/index.d.ts.map +1 -1
  102. package/dist/toast/index.js +5 -5
  103. package/dist/toast/public.d.ts +1 -1
  104. package/dist/toast/public.d.ts.map +1 -1
  105. package/dist/toast/public.js +1 -1
  106. package/dist/toast/schema.d.ts +72 -84
  107. package/dist/toast/schema.d.ts.map +1 -1
  108. package/dist/toast/schema.js +31 -41
  109. package/dist/toast/test.d.ts.map +1 -1
  110. package/dist/toast/test.js +6 -3
  111. package/dist/toast/update.d.ts +104 -89
  112. package/dist/toast/update.d.ts.map +1 -1
  113. package/dist/toast/update.js +19 -20
  114. package/dist/tooltip/message.d.ts +26 -47
  115. package/dist/tooltip/message.d.ts.map +1 -1
  116. package/dist/tooltip/message.js +15 -40
  117. package/dist/tooltip/public.d.ts +1 -1
  118. package/dist/tooltip/public.d.ts.map +1 -1
  119. package/dist/tooltip/public.js +1 -1
  120. package/dist/tooltip/tooltip.d.ts +1 -1
  121. package/dist/tooltip/tooltip.d.ts.map +1 -1
  122. package/dist/tooltip/tooltip.js +15 -16
  123. package/dist/virtualList/index.d.ts +46 -23
  124. package/dist/virtualList/index.d.ts.map +1 -1
  125. package/dist/virtualList/index.js +12 -23
  126. package/dist/virtualList/public.d.ts +1 -1
  127. package/dist/virtualList/public.d.ts.map +1 -1
  128. package/dist/virtualList/public.js +1 -1
  129. package/package.json +3 -3
@@ -3,7 +3,7 @@ import { Array, Effect, Match as M, Option, Predicate, Schema as S, String, pipe
3
3
  import * as Command from 'foldkit/command';
4
4
  import * as Dom from 'foldkit/dom';
5
5
  import { childAttributes } from 'foldkit/html';
6
- import { m } from 'foldkit/message';
6
+ import { defineMessageUnion } from 'foldkit/message';
7
7
  import { evo } from 'foldkit/struct';
8
8
  import { defineView } from 'foldkit/submodel';
9
9
  import { idSelector } from '../internal/selectors.js';
@@ -21,27 +21,22 @@ export const Model = S.Struct({
21
21
  maybeFocusedIndex: S.Option(S.Number),
22
22
  });
23
23
  // MESSAGE
24
- /** Sent when an option is committed via click or keyboard. Commits the option
25
- * as the new selection and moves focus onto it. */
26
- export const SelectedOption = m('SelectedOption', {
27
- index: S.Number,
28
- value: S.String,
29
- });
30
- /** Sent when an option receives keyboard focus without being committed, which
31
- * is how a read-only group navigates. */
32
- export const FocusedOption = m('FocusedOption', { index: S.Number });
33
- /** Sent when the focus-option command completes. */
34
- export const CompletedFocusOption = m('CompletedFocusOption');
35
24
  /** Union of all messages the radio group can produce. */
36
- export const Message = S.Union([SelectedOption, FocusedOption, CompletedFocusOption]);
37
- // OUT MESSAGE
38
- /** Sent to the parent when an option is committed via click or keyboard. Carries both the option's value (typed as `Value` via `RadioGroup.create<Value>()`) and its index. Generic at the type level; the schema stores `value: string` and the factory's fenced cast types it as `Value`. */
39
- export const Selected = m('Selected', {
40
- value: S.String,
41
- index: S.Number,
25
+ export const Message = defineMessageUnion({
26
+ SelectedOption: {
27
+ index: S.Number,
28
+ value: S.String,
29
+ },
30
+ FocusedOption: { index: S.Number },
31
+ CompletedFocusOption: {},
42
32
  });
43
33
  /** Union of out-messages the radio group can produce. Surfaced as the third element of `update`'s return tuple and pattern-matched by the parent. */
44
- export const OutMessage = S.Union([Selected]);
34
+ export const OutMessage = defineMessageUnion({
35
+ Selected: {
36
+ value: S.String,
37
+ index: S.Number,
38
+ },
39
+ });
45
40
  /** Creates an initial radio group model from a config. Focus follows the
46
41
  * selected option until the user navigates a read-only group, so
47
42
  * `maybeFocusedIndex` starts `None`. */
@@ -56,18 +51,18 @@ const descriptionId = (id, index) => __foldkitBrandViewResult((`${id}-option-${i
56
51
  /** Moves focus to the option at the given index. */
57
52
  export const FocusOption = Command.define('FocusOption', {
58
53
  args: { id: S.String, index: S.Number },
59
- messages: [CompletedFocusOption],
60
- execute: ({ id, index }) => __foldkitBrandViewResult((Dom.focus(idSelector(optionId(id, index))).pipe(Effect.ignore, Effect.as(CompletedFocusOption()))), "@foldkit/ui/radioGroup/index.js#execute"),
54
+ messages: [Message.CompletedFocusOption],
55
+ execute: ({ id, index }) => __foldkitBrandViewResult((Dom.focus(idSelector(optionId(id, index))).pipe(Effect.ignore, Effect.as(Message.CompletedFocusOption()))), "@foldkit/ui/radioGroup/index.js#execute"),
61
56
  });
62
57
  /** Processes a radio group message and returns the next model, commands, and
63
58
  * an optional OutMessage. `Selected` fires when an option is committed via
64
59
  * click or keyboard; the parent stores the new value and passes it back in as
65
60
  * `selectedValue`. */
66
- export const update = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(M.withReturnType(), M.tagsExhaustive({
61
+ export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
67
62
  SelectedOption: ({ index, value }) => __foldkitBrandViewResult(([
68
63
  evo(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/radioGroup/index.js#maybeFocusedIndex") }),
69
64
  [FocusOption({ id: model.id, index })],
70
- Option.some(Selected({ value, index })),
65
+ Option.some(OutMessage.Selected({ value, index })),
71
66
  ]), "@foldkit/ui/radioGroup/index.js#SelectedOption"),
72
67
  FocusedOption: ({ index }) => __foldkitBrandViewResult(([
73
68
  evo(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/radioGroup/index.js#maybeFocusedIndex~2") }),
@@ -75,7 +70,7 @@ export const update = (model, message) => __foldkitBrandViewResult((M.value(mess
75
70
  Option.none(),
76
71
  ]), "@foldkit/ui/radioGroup/index.js#FocusedOption"),
77
72
  CompletedFocusOption: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/radioGroup/index.js#CompletedFocusOption"),
78
- }))), "@foldkit/ui/radioGroup/index.js#update");
73
+ })), "@foldkit/ui/radioGroup/index.js#update");
79
74
  const internalView = defineView((model, viewInputs, h) => {
80
75
  const { id, maybeFocusedIndex } = model;
81
76
  const { options, selectedValue, ariaLabel, toView, orientation = 'Vertical', isOptionDisabled: isOptionDisabledFn, isDisabled: isGroupDisabled = false, isReadOnly = false, name, } = viewInputs;
@@ -104,9 +99,9 @@ const internalView = defineView((model, viewInputs, h) => {
104
99
  previousKey: 'ArrowUp',
105
100
  }), "@foldkit/ui/radioGroup/index.js#anonymous~10"))), M.exhaustive);
106
101
  const resolveKeyIndex = keyToIndex(nextKey, previousKey, options.length, focusedIndex, isDisabled);
107
- const optionSelectedAt = (index) => __foldkitBrandViewResult((pipe(options, Array.get(index), Option.map(value => __foldkitBrandViewResult((SelectedOption({ index, value })), "@foldkit/ui/radioGroup/index.js#anonymous~11")))), "@foldkit/ui/radioGroup/index.js#optionSelectedAt");
102
+ const optionSelectedAt = (index) => __foldkitBrandViewResult((pipe(options, Array.get(index), Option.map(value => __foldkitBrandViewResult((Message.SelectedOption({ index, value })), "@foldkit/ui/radioGroup/index.js#anonymous~11")))), "@foldkit/ui/radioGroup/index.js#optionSelectedAt");
108
103
  const handleSelectingKeyDown = (currentIndex, key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(nextKey, previousKey, 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((optionSelectedAt(resolveKeyIndex(key))), "@foldkit/ui/radioGroup/index.js#anonymous~12")), M.when(' ', () => __foldkitBrandViewResult((optionSelectedAt(currentIndex)), "@foldkit/ui/radioGroup/index.js#anonymous~13")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/radioGroup/index.js#anonymous~14")))), "@foldkit/ui/radioGroup/index.js#handleSelectingKeyDown");
109
- const handleReadOnlyKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(nextKey, previousKey, 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((Option.some(FocusedOption({ index: resolveKeyIndex(key) }))), "@foldkit/ui/radioGroup/index.js#anonymous~15")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/radioGroup/index.js#anonymous~16")))), "@foldkit/ui/radioGroup/index.js#handleReadOnlyKeyDown");
104
+ const handleReadOnlyKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(nextKey, previousKey, 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((Option.some(Message.FocusedOption({ index: resolveKeyIndex(key) }))), "@foldkit/ui/radioGroup/index.js#anonymous~15")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/radioGroup/index.js#anonymous~16")))), "@foldkit/ui/radioGroup/index.js#handleReadOnlyKeyDown");
110
105
  const handleKeyDown = (currentIndex) => __foldkitBrandViewResult(((key) => {
111
106
  if (isReadOnly) {
112
107
  return __foldkitBrandViewResult((handleReadOnlyKeyDown(key)), "@foldkit/ui/radioGroup/index.js#anonymous~17");
@@ -131,7 +126,7 @@ const internalView = defineView((model, viewInputs, h) => {
131
126
  : [];
132
127
  const clickAttributes = isOptionDisabledNow || isReadOnly
133
128
  ? []
134
- : [h.OnClick(SelectedOption({ index, value }))];
129
+ : [h.OnClick(Message.SelectedOption({ index, value }))];
135
130
  const keyDownAttributes = isOptionDisabledNow
136
131
  ? []
137
132
  : [h.OnKeyDownPreventDefault(handleKeyDown(index))];
@@ -1,3 +1,3 @@
1
- export { init, create, Model, Message, OutMessage, Selected, SelectedOption, FocusedOption, CompletedFocusOption, FocusOption, Orientation, } from './index.js';
1
+ export { init, create, Model, Message, OutMessage, type Selected, type SelectedOption, type FocusedOption, FocusOption, Orientation, } from './index.js';
2
2
  export type { InitConfig, ViewInputs, RenderInfo, OptionInfo, Bundle, } from './index.js';
3
3
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/radioGroup/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,OAAO,EACP,UAAU,EACV,QAAQ,EACR,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,MAAM,GACP,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/radioGroup/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,MAAM,GACP,MAAM,YAAY,CAAA"}
@@ -1 +1 @@
1
- export { init, create, Model, Message, OutMessage, Selected, SelectedOption, FocusedOption, CompletedFocusOption, FocusOption, Orientation, } from './index.js';
1
+ export { init, create, Model, Message, OutMessage, FocusOption, Orientation, } from './index.js';
@@ -18,60 +18,38 @@ export declare const Model: S.Struct<{
18
18
  }>]>;
19
19
  }>;
20
20
  export type Model = typeof Model.Type;
21
- /** The user pressed the thumb. Starts a drag without changing the value. The
22
- * view supplies `originValue`, the current value, so Escape can restore it. */
23
- export declare const PressedThumb: import("foldkit/schema").CallableTaggedStruct<"PressedThumb", {
24
- originValue: S.Number;
25
- }>;
26
- /** The user pressed the track. Starts a drag and snaps the value to the
27
- * cursor position. Ignored while already dragging, which absorbs the bubble
28
- * from a thumb press so the value is not shifted. `originValue` is the current
29
- * value the drag restores to on Escape. */
30
- export declare const PressedPointer: import("foldkit/schema").CallableTaggedStruct<"PressedPointer", {
31
- value: S.Number;
32
- originValue: S.Number;
33
- }>;
34
- /** The pointer moved during a drag, producing a new snapped value from the
35
- * cursor position within the track. */
36
- export declare const MovedDragPointer: import("foldkit/schema").CallableTaggedStruct<"MovedDragPointer", {
37
- value: S.Number;
38
- }>;
39
- /** The pointer was released during a drag. Commits the current value. */
40
- export declare const ReleasedDragPointer: import("foldkit/schema").CallableTaggedStruct<"ReleasedDragPointer", {}>;
41
- /** Escape was pressed during a drag. Restores the value from the drag origin. */
42
- export declare const CancelledDrag: import("foldkit/schema").CallableTaggedStruct<"CancelledDrag", {}>;
43
- /** The user pressed a keyboard navigation key on the focused thumb. The view
44
- * supplies `value`, the current value, to compute the next one from. */
45
- export declare const PressedKeyboardNavigation: import("foldkit/schema").CallableTaggedStruct<"PressedKeyboardNavigation", {
46
- direction: S.Literals<readonly ["StepDecrement", "StepIncrement", "PageDecrement", "PageIncrement", "Min", "Max"]>;
47
- value: S.Number;
48
- }>;
49
21
  /** Union of all messages the slider component can produce. */
50
- export declare const Message: S.Union<[
51
- typeof PressedThumb,
52
- typeof PressedPointer,
53
- typeof MovedDragPointer,
54
- typeof ReleasedDragPointer,
55
- typeof CancelledDrag,
56
- typeof PressedKeyboardNavigation
57
- ]>;
58
- export type Message = typeof Message.Type;
59
- export type PressedThumb = typeof PressedThumb.Type;
60
- export type PressedPointer = typeof PressedPointer.Type;
61
- export type MovedDragPointer = typeof MovedDragPointer.Type;
62
- export type ReleasedDragPointer = typeof ReleasedDragPointer.Type;
63
- export type CancelledDrag = typeof CancelledDrag.Type;
64
- export type PressedKeyboardNavigation = typeof PressedKeyboardNavigation.Type;
65
- /** Emitted when the slider value changes. The parent can handle this to
66
- * update its own state or dispatch its own Commands, for example to run
67
- * validation or trigger a downstream Command. */
68
- export declare const ChangedValue: import("foldkit/schema").CallableTaggedStruct<"ChangedValue", {
69
- value: S.Number;
22
+ export declare const Message: import("foldkit/message").MessageUnion<{
23
+ readonly PressedThumb: {
24
+ readonly originValue: S.Number;
25
+ };
26
+ readonly PressedPointer: {
27
+ readonly value: S.Number;
28
+ readonly originValue: S.Number;
29
+ };
30
+ readonly MovedDragPointer: {
31
+ readonly value: S.Number;
32
+ };
33
+ readonly ReleasedDragPointer: {};
34
+ readonly CancelledDrag: {};
35
+ readonly PressedKeyboardNavigation: {
36
+ readonly direction: S.Literals<readonly ["StepDecrement", "StepIncrement", "PageDecrement", "PageIncrement", "Min", "Max"]>;
37
+ readonly value: S.Number;
38
+ };
70
39
  }>;
40
+ export type Message = typeof Message.Type;
41
+ export type PressedThumb = typeof Message.PressedThumb.Type;
42
+ export type PressedPointer = typeof Message.PressedPointer.Type;
43
+ export type MovedDragPointer = typeof Message.MovedDragPointer.Type;
44
+ export type ReleasedDragPointer = typeof Message.ReleasedDragPointer.Type;
45
+ export type CancelledDrag = typeof Message.CancelledDrag.Type;
46
+ export type PressedKeyboardNavigation = typeof Message.PressedKeyboardNavigation.Type;
71
47
  /** Union of all out-messages the slider component can emit to its parent. */
72
- export declare const OutMessage: S.Union<readonly [import("foldkit/schema").CallableTaggedStruct<"ChangedValue", {
73
- value: S.Number;
74
- }>]>;
48
+ export declare const OutMessage: import("foldkit/message").MessageUnion<{
49
+ readonly ChangedValue: {
50
+ readonly value: S.Number;
51
+ };
52
+ }>;
75
53
  export type OutMessage = typeof OutMessage.Type;
76
54
  /** Configuration for creating a slider model with `init`. */
77
55
  export type InitConfig = Readonly<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,MAAM,EACN,MAAM,IAAI,CAAC,EA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EF;;;;0EAI0E;AAC1E,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAnCf;8EAC0E;WACnE,MAAM;YACL,CAAC,UAAU,EAAE,gBAAgB,KAAK,IAAI;gBAClC,MAAM;qBACD,MAAM;kBACT,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM;IACvC;;;gCAG4B;iBACf,OAAO;IACpB;;;;;;;;eAQW;iBACE,OAAO;WACb,MAAM;IACb;;;4DAGwD;mBACzC,MAAM,QAAQ,GAAG,UAAU;GA2J3C,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
2
  import { Effect, Equal, Function, Match as M, Option, Schema as S, Stream, String as String_, pipe, } from 'effect';
3
3
  import { childAttributes } from 'foldkit/html';
4
- import { m } from 'foldkit/message';
4
+ import { defineMessageUnion } from 'foldkit/message';
5
5
  import { ts } from 'foldkit/schema';
6
6
  import { evo } from 'foldkit/struct';
7
7
  import { defineView } from 'foldkit/submodel';
@@ -24,53 +24,33 @@ export const Model = S.Struct({
24
24
  dragState: DragState,
25
25
  });
26
26
  // MESSAGE
27
- /** The user pressed the thumb. Starts a drag without changing the value. The
28
- * view supplies `originValue`, the current value, so Escape can restore it. */
29
- export const PressedThumb = m('PressedThumb', { originValue: S.Number });
30
- /** The user pressed the track. Starts a drag and snaps the value to the
31
- * cursor position. Ignored while already dragging, which absorbs the bubble
32
- * from a thumb press so the value is not shifted. `originValue` is the current
33
- * value the drag restores to on Escape. */
34
- export const PressedPointer = m('PressedPointer', {
35
- value: S.Number,
36
- originValue: S.Number,
37
- });
38
- /** The pointer moved during a drag, producing a new snapped value from the
39
- * cursor position within the track. */
40
- export const MovedDragPointer = m('MovedDragPointer', { value: S.Number });
41
- /** The pointer was released during a drag. Commits the current value. */
42
- export const ReleasedDragPointer = m('ReleasedDragPointer');
43
- /** Escape was pressed during a drag. Restores the value from the drag origin. */
44
- export const CancelledDrag = m('CancelledDrag');
45
- /** The user pressed a keyboard navigation key on the focused thumb. The view
46
- * supplies `value`, the current value, to compute the next one from. */
47
- export const PressedKeyboardNavigation = m('PressedKeyboardNavigation', {
48
- direction: S.Literals([
49
- 'StepDecrement',
50
- 'StepIncrement',
51
- 'PageDecrement',
52
- 'PageIncrement',
53
- 'Min',
54
- 'Max',
55
- ]),
56
- value: S.Number,
57
- });
58
27
  /** Union of all messages the slider component can produce. */
59
- export const Message = S.Union([
60
- PressedThumb,
61
- PressedPointer,
62
- MovedDragPointer,
63
- ReleasedDragPointer,
64
- CancelledDrag,
65
- PressedKeyboardNavigation,
66
- ]);
28
+ export const Message = defineMessageUnion({
29
+ PressedThumb: { originValue: S.Number },
30
+ PressedPointer: {
31
+ value: S.Number,
32
+ originValue: S.Number,
33
+ },
34
+ MovedDragPointer: { value: S.Number },
35
+ ReleasedDragPointer: {},
36
+ CancelledDrag: {},
37
+ PressedKeyboardNavigation: {
38
+ direction: S.Literals([
39
+ 'StepDecrement',
40
+ 'StepIncrement',
41
+ 'PageDecrement',
42
+ 'PageIncrement',
43
+ 'Min',
44
+ 'Max',
45
+ ]),
46
+ value: S.Number,
47
+ },
48
+ });
67
49
  // OUT MESSAGE
68
- /** Emitted when the slider value changes. The parent can handle this to
69
- * update its own state or dispatch its own Commands, for example to run
70
- * validation or trigger a downstream Command. */
71
- export const ChangedValue = m('ChangedValue', { value: S.Number });
72
50
  /** Union of all out-messages the slider component can emit to its parent. */
73
- export const OutMessage = S.Union([ChangedValue]);
51
+ export const OutMessage = defineMessageUnion({
52
+ ChangedValue: { value: S.Number },
53
+ });
74
54
  /** Creates an initial slider model from a config. The value lives in the
75
55
  * parent Model; initialize it there and snap it with {@link snapAndClamp}. */
76
56
  export const init = (config) => (__foldkitBrandViewResult(({
@@ -116,12 +96,12 @@ const nextValueForDirection = (value, min, max, step, direction) => __foldkitBra
116
96
  const withUpdateReturn = M.withReturnType();
117
97
  const changedValueOption = (currentValue, nextValue) => __foldkitBrandViewResult((nextValue === currentValue
118
98
  ? Option.none()
119
- : Option.some(ChangedValue({ value: nextValue }))), "@foldkit/ui/slider/index.js#changedValueOption");
99
+ : Option.some(OutMessage.ChangedValue({ value: nextValue }))), "@foldkit/ui/slider/index.js#changedValueOption");
120
100
  /** Processes a slider message and returns the next model, commands, and an
121
101
  * optional out-message for the parent. The value lives in the parent Model:
122
102
  * the view supplies the current value on the messages that need it, and value
123
103
  * changes surface as `ChangedValue` rather than mutating this Model. */
124
- export const update = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
104
+ export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
125
105
  PressedThumb: ({ originValue }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/slider/index.js#anonymous~7")), M.orElse(() => __foldkitBrandViewResult(([
126
106
  evo(model, { dragState: () => __foldkitBrandViewResult((Dragging({ originValue })), "@foldkit/ui/slider/index.js#dragState") }),
127
107
  [],
@@ -144,7 +124,7 @@ export const update = (model, message) => __foldkitBrandViewResult((M.value(mess
144
124
  MovedDragPointer: ({ value }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => __foldkitBrandViewResult(([
145
125
  model,
146
126
  [],
147
- Option.some(ChangedValue({
127
+ Option.some(OutMessage.ChangedValue({
148
128
  value: snapAndClamp(value, model.min, model.max, model.step),
149
129
  })),
150
130
  ]), "@foldkit/ui/slider/index.js#anonymous~11")), M.orElse(() => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/slider/index.js#anonymous~12")))), "@foldkit/ui/slider/index.js#MovedDragPointer"),
@@ -156,14 +136,14 @@ export const update = (model, message) => __foldkitBrandViewResult((M.value(mess
156
136
  CancelledDrag: () => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', ({ originValue }) => __foldkitBrandViewResult(([
157
137
  evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/slider/index.js#dragState~4") }),
158
138
  [],
159
- Option.some(ChangedValue({ value: originValue })),
139
+ Option.some(OutMessage.ChangedValue({ value: originValue })),
160
140
  ]), "@foldkit/ui/slider/index.js#anonymous~15")), M.orElse(() => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/slider/index.js#anonymous~16")))), "@foldkit/ui/slider/index.js#CancelledDrag"),
161
141
  PressedKeyboardNavigation: ({ direction, value }) => __foldkitBrandViewResult(([
162
142
  model,
163
143
  [],
164
144
  changedValueOption(value, nextValueForDirection(value, model.min, model.max, model.step, direction)),
165
145
  ]), "@foldkit/ui/slider/index.js#PressedKeyboardNavigation"),
166
- }))), "@foldkit/ui/slider/index.js#update");
146
+ })), "@foldkit/ui/slider/index.js#update");
167
147
  /** Reflects an externally-driven range onto the slider. Use this when min/max
168
148
  * derive from external state (e.g. a bounded buffer whose first/last index
169
149
  * shifts over time). The parent owns the value, so conform it to the new range
@@ -204,9 +184,9 @@ export const subscriptionsForRoot = (getTrackRoot) => __foldkitBrandViewResult((
204
184
  max: model.max,
205
185
  }), "@foldkit/ui/slider/index.js#modelToDependencies")),
206
186
  dependenciesToStream: ({ dragActivity, id, min, max }) => {
207
- const pointerEvents = Stream.merge(Stream.fromEventListener(document, 'pointermove').pipe(Stream.mapEffect(event => __foldkitBrandViewResult((Effect.sync(() => __foldkitBrandViewResult((Option.map(trackElement(id, getTrackRoot()), element => __foldkitBrandViewResult((MovedDragPointer({
187
+ const pointerEvents = Stream.merge(Stream.fromEventListener(document, 'pointermove').pipe(Stream.mapEffect(event => __foldkitBrandViewResult((Effect.sync(() => __foldkitBrandViewResult((Option.map(trackElement(id, getTrackRoot()), element => __foldkitBrandViewResult((Message.MovedDragPointer({
208
188
  value: valueFromClientX(event.clientX, element, min, max),
209
- })), "@foldkit/ui/slider/index.js#anonymous~23"))), "@foldkit/ui/slider/index.js#anonymous~22"))), "@foldkit/ui/slider/index.js#anonymous~21")), Stream.filter(Option.isSome), Stream.map(option => __foldkitBrandViewResult((option.value), "@foldkit/ui/slider/index.js#anonymous~24"))), Stream.fromEventListener(document, 'pointerup').pipe(Stream.map(() => __foldkitBrandViewResult((ReleasedDragPointer()), "@foldkit/ui/slider/index.js#anonymous~25"))));
189
+ })), "@foldkit/ui/slider/index.js#anonymous~23"))), "@foldkit/ui/slider/index.js#anonymous~22"))), "@foldkit/ui/slider/index.js#anonymous~21")), Stream.filter(Option.isSome), Stream.map(option => __foldkitBrandViewResult((option.value), "@foldkit/ui/slider/index.js#anonymous~24"))), Stream.fromEventListener(document, 'pointerup').pipe(Stream.map(() => __foldkitBrandViewResult((Message.ReleasedDragPointer()), "@foldkit/ui/slider/index.js#anonymous~25"))));
210
190
  // NOTE: prevents text selection and locks cursor to grabbing while the
211
191
  // user drags the thumb. Matches the approach used in drag-and-drop.
212
192
  const documentDragStyles = Stream.callback(() => __foldkitBrandViewResult((Effect.acquireRelease(Effect.sync(() => {
@@ -228,7 +208,7 @@ export const subscriptionsForRoot = (getTrackRoot) => __foldkitBrandViewResult((
228
208
  modelToDependencies: model => (__foldkitBrandViewResult(({
229
209
  dragActivity: dragActivityFromModel(model),
230
210
  }), "@foldkit/ui/slider/index.js#modelToDependencies~2")),
231
- dependenciesToStream: ({ dragActivity }) => __foldkitBrandViewResult((Stream.when(Stream.fromEventListener(document, 'keydown').pipe(Stream.filter(({ key }) => __foldkitBrandViewResult((key === 'Escape'), "@foldkit/ui/slider/index.js#anonymous~32")), Stream.map(() => __foldkitBrandViewResult((CancelledDrag()), "@foldkit/ui/slider/index.js#anonymous~33"))), Effect.sync(() => __foldkitBrandViewResult((dragActivity === 'Active'), "@foldkit/ui/slider/index.js#anonymous~34")))), "@foldkit/ui/slider/index.js#dependenciesToStream~2"),
211
+ dependenciesToStream: ({ dragActivity }) => __foldkitBrandViewResult((Stream.when(Stream.fromEventListener(document, 'keydown').pipe(Stream.filter(({ key }) => __foldkitBrandViewResult((key === 'Escape'), "@foldkit/ui/slider/index.js#anonymous~32")), Stream.map(() => __foldkitBrandViewResult((Message.CancelledDrag()), "@foldkit/ui/slider/index.js#anonymous~33"))), Effect.sync(() => __foldkitBrandViewResult((dragActivity === 'Active'), "@foldkit/ui/slider/index.js#anonymous~34")))), "@foldkit/ui/slider/index.js#dependenciesToStream~2"),
232
212
  }),
233
213
  }), "@foldkit/ui/slider/index.js#anonymous~20")))), "@foldkit/ui/slider/index.js#subscriptionsForRoot");
234
214
  /** Default drag subscriptions, with the track looked up via `document`. */
@@ -248,13 +228,13 @@ export const view = defineView((model, viewInputs, h) => {
248
228
  const { id, min, max } = model;
249
229
  const isDragging = model.dragState._tag === 'Dragging';
250
230
  const fraction = fractionOfValue(value, min, max);
251
- const handleKeyDown = (key) => __foldkitBrandViewResult((Option.map(keyToDirection(key), direction => __foldkitBrandViewResult((PressedKeyboardNavigation({ direction, value })), "@foldkit/ui/slider/index.js#anonymous~44"))), "@foldkit/ui/slider/index.js#handleKeyDown");
252
- const pointerAtClientX = (clientX) => __foldkitBrandViewResult((Option.map(trackElement(id, getTrackRoot()), element => __foldkitBrandViewResult((PressedPointer({
231
+ const handleKeyDown = (key) => __foldkitBrandViewResult((Option.map(keyToDirection(key), direction => __foldkitBrandViewResult((Message.PressedKeyboardNavigation({ direction, value })), "@foldkit/ui/slider/index.js#anonymous~44"))), "@foldkit/ui/slider/index.js#handleKeyDown");
232
+ const pointerAtClientX = (clientX) => __foldkitBrandViewResult((Option.map(trackElement(id, getTrackRoot()), element => __foldkitBrandViewResult((Message.PressedPointer({
253
233
  value: valueFromClientX(clientX, element, min, max),
254
234
  originValue: value,
255
235
  })), "@foldkit/ui/slider/index.js#anonymous~45"))), "@foldkit/ui/slider/index.js#pointerAtClientX");
256
236
  const trackPointerHandler = (_pointerType, button, _screenX, _screenY, _timeStamp, clientX) => __foldkitBrandViewResult((pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.flatMap(() => __foldkitBrandViewResult((pointerAtClientX(clientX)), "@foldkit/ui/slider/index.js#anonymous~46")))), "@foldkit/ui/slider/index.js#trackPointerHandler");
257
- const thumbPointerHandler = (_pointerType, button) => __foldkitBrandViewResult((pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.map(() => __foldkitBrandViewResult((PressedThumb({ originValue: value })), "@foldkit/ui/slider/index.js#anonymous~47")))), "@foldkit/ui/slider/index.js#thumbPointerHandler");
237
+ const thumbPointerHandler = (_pointerType, button) => __foldkitBrandViewResult((pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.map(() => __foldkitBrandViewResult((Message.PressedThumb({ originValue: value })), "@foldkit/ui/slider/index.js#anonymous~47")))), "@foldkit/ui/slider/index.js#thumbPointerHandler");
258
238
  const stateAttributes = [
259
239
  ...(isDragging ? [h.DataAttribute('dragging', '')] : []),
260
240
  ...(isDisabled ? [h.DataAttribute('disabled', '')] : []),
@@ -1,3 +1,3 @@
1
- export { init, update, reflectRange, view, subscriptions, subscriptionsForRoot, fractionOfValue, snapAndClamp, Model, Message, OutMessage, PressedThumb, PressedPointer, MovedDragPointer, ReleasedDragPointer, CancelledDrag, PressedKeyboardNavigation, } from './index.js';
1
+ export { init, update, reflectRange, view, subscriptions, subscriptionsForRoot, fractionOfValue, snapAndClamp, Model, Message, OutMessage, type PressedThumb, type PressedPointer, type MovedDragPointer, type ReleasedDragPointer, type CancelledDrag, type PressedKeyboardNavigation, } from './index.js';
2
2
  export type { InitConfig, ViewInputs, SliderAttributes } from './index.js';
3
3
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/slider/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,KAAK,EACL,OAAO,EACP,UAAU,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,yBAAyB,GAC1B,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/slider/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
@@ -1 +1 @@
1
- export { init, update, reflectRange, view, subscriptions, subscriptionsForRoot, fractionOfValue, snapAndClamp, Model, Message, OutMessage, PressedThumb, PressedPointer, MovedDragPointer, ReleasedDragPointer, CancelledDrag, PressedKeyboardNavigation, } from './index.js';
1
+ export { init, update, reflectRange, view, subscriptions, subscriptionsForRoot, fractionOfValue, snapAndClamp, Model, Message, OutMessage, } from './index.js';
@@ -20,42 +20,32 @@ export declare const Model: S.Struct<{
20
20
  readonly activationMode: S.Literals<readonly ["Automatic", "Manual"]>;
21
21
  }>;
22
22
  export type Model = typeof Model.Type;
23
- /** Sent when a tab is selected via click or keyboard. Commits the tab as the
24
- * new selection and moves focus onto it. */
25
- export declare const SelectedTab: import("foldkit/schema").CallableTaggedStruct<"SelectedTab", {
26
- index: S.Number;
27
- value: S.String;
28
- }>;
29
- /** Sent when a tab receives keyboard focus in `Manual` mode without being activated. */
30
- export declare const FocusedTab: import("foldkit/schema").CallableTaggedStruct<"FocusedTab", {
31
- index: S.Number;
32
- }>;
33
- /** Sent when the focus-tab command completes. */
34
- export declare const CompletedFocusTab: import("foldkit/schema").CallableTaggedStruct<"CompletedFocusTab", {}>;
35
23
  /** Union of all messages the tabs component can produce. */
36
- export declare const Message: S.Union<[
37
- typeof SelectedTab,
38
- typeof FocusedTab,
39
- typeof CompletedFocusTab
40
- ]>;
41
- export type SelectedTab = typeof SelectedTab.Type;
42
- export type FocusedTab = typeof FocusedTab.Type;
43
- export type Message = typeof Message.Type;
44
- /** Sent to the parent when a tab is committed via click or keyboard. Carries both the tab's value (typed as `Value` via `Tabs.create<Value>()`) and its index. Generic at the type level; the schema stores `value: string` and the factory's fenced cast types it as `Value`. */
45
- export declare const Selected: import("foldkit/schema").CallableTaggedStruct<"Selected", {
46
- value: S.String;
47
- index: S.Number;
24
+ export declare const Message: import("foldkit/message").MessageUnion<{
25
+ readonly SelectedTab: {
26
+ readonly index: S.Number;
27
+ readonly value: S.String;
28
+ };
29
+ readonly FocusedTab: {
30
+ readonly index: S.Number;
31
+ };
32
+ readonly CompletedFocusTab: {};
48
33
  }>;
34
+ export type SelectedTab = typeof Message.SelectedTab.Type;
35
+ export type FocusedTab = typeof Message.FocusedTab.Type;
36
+ export type Message = typeof Message.Type;
49
37
  export type Selected<Value extends string = string> = Readonly<{
50
38
  readonly _tag: 'Selected';
51
39
  readonly value: Value;
52
40
  readonly index: number;
53
41
  }>;
54
42
  /** Union of out-messages the tabs component can produce. Surfaced as the third element of `update`'s return tuple and pattern-matched by the parent. */
55
- export declare const OutMessage: S.Union<readonly [import("foldkit/schema").CallableTaggedStruct<"Selected", {
56
- value: S.String;
57
- index: S.Number;
58
- }>]>;
43
+ export declare const OutMessage: import("foldkit/message").MessageUnion<{
44
+ readonly Selected: {
45
+ readonly value: S.String;
46
+ readonly index: S.Number;
47
+ };
48
+ }>;
59
49
  /** Generic over `Value extends string` so consumers using
60
50
  * `Tabs.create<MyUnion>()` receive `value: MyUnion` in the
61
51
  * `Selected` OutMessage. Defaults to `string`. */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D;AACnD,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,MAAM,GAAG,MAAM,OAAK,MAAM,CAAC,KAAK,CAmBpE,CAAA"}
@@ -3,7 +3,7 @@ import { Array, Effect, Match as M, Option, Schema as S, String, pipe, } from 'e
3
3
  import * as Command from 'foldkit/command';
4
4
  import * as Dom from 'foldkit/dom';
5
5
  import { childAttributes } from 'foldkit/html';
6
- import { m } from 'foldkit/message';
6
+ import { defineMessageUnion } from 'foldkit/message';
7
7
  import { evo } from 'foldkit/struct';
8
8
  import { defineView } from 'foldkit/submodel';
9
9
  import { idSelector } from '../internal/selectors.js';
@@ -25,26 +25,22 @@ export const Model = S.Struct({
25
25
  activationMode: ActivationMode,
26
26
  });
27
27
  // MESSAGE
28
- /** Sent when a tab is selected via click or keyboard. Commits the tab as the
29
- * new selection and moves focus onto it. */
30
- export const SelectedTab = m('SelectedTab', {
31
- index: S.Number,
32
- value: S.String,
33
- });
34
- /** Sent when a tab receives keyboard focus in `Manual` mode without being activated. */
35
- export const FocusedTab = m('FocusedTab', { index: S.Number });
36
- /** Sent when the focus-tab command completes. */
37
- export const CompletedFocusTab = m('CompletedFocusTab');
38
28
  /** Union of all messages the tabs component can produce. */
39
- export const Message = S.Union([SelectedTab, FocusedTab, CompletedFocusTab]);
40
- // OUT MESSAGE
41
- /** Sent to the parent when a tab is committed via click or keyboard. Carries both the tab's value (typed as `Value` via `Tabs.create<Value>()`) and its index. Generic at the type level; the schema stores `value: string` and the factory's fenced cast types it as `Value`. */
42
- export const Selected = m('Selected', {
43
- value: S.String,
44
- index: S.Number,
29
+ export const Message = defineMessageUnion({
30
+ SelectedTab: {
31
+ index: S.Number,
32
+ value: S.String,
33
+ },
34
+ FocusedTab: { index: S.Number },
35
+ CompletedFocusTab: {},
45
36
  });
46
37
  /** Union of out-messages the tabs component can produce. Surfaced as the third element of `update`'s return tuple and pattern-matched by the parent. */
47
- export const OutMessage = S.Union([Selected]);
38
+ export const OutMessage = defineMessageUnion({
39
+ Selected: {
40
+ value: S.String,
41
+ index: S.Number,
42
+ },
43
+ });
48
44
  /** Creates an initial tabs model from a config. Focus follows the selected
49
45
  * tab until the user navigates in `Manual` mode, so `maybeFocusedIndex`
50
46
  * starts `None`. Defaults to automatic activation. */
@@ -59,18 +55,18 @@ const tabPanelId = (id, index) => __foldkitBrandViewResult((`${id}-panel-${index
59
55
  /** Moves focus to the tab at the given index. */
60
56
  export const FocusTab = Command.define('FocusTab', {
61
57
  args: { id: S.String, index: S.Number },
62
- messages: [CompletedFocusTab],
63
- execute: ({ id, index }) => __foldkitBrandViewResult((Dom.focus(idSelector(tabId(id, index))).pipe(Effect.ignore, Effect.as(CompletedFocusTab()))), "@foldkit/ui/tabs/index.js#execute"),
58
+ messages: [Message.CompletedFocusTab],
59
+ execute: ({ id, index }) => __foldkitBrandViewResult((Dom.focus(idSelector(tabId(id, index))).pipe(Effect.ignore, Effect.as(Message.CompletedFocusTab()))), "@foldkit/ui/tabs/index.js#execute"),
64
60
  });
65
61
  /** Processes a tabs message and returns the next model, commands, and an
66
62
  * optional OutMessage. `Selected` fires when a tab is committed via click or
67
63
  * keyboard; the parent stores the new value and passes it back in as
68
64
  * `selectedValue`. */
69
- export const update = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(M.withReturnType(), M.tagsExhaustive({
65
+ export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
70
66
  SelectedTab: ({ index, value }) => __foldkitBrandViewResult(([
71
67
  evo(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tabs/index.js#maybeFocusedIndex") }),
72
68
  [FocusTab({ id: model.id, index })],
73
- Option.some(Selected({ value, index })),
69
+ Option.some(OutMessage.Selected({ value, index })),
74
70
  ]), "@foldkit/ui/tabs/index.js#SelectedTab"),
75
71
  FocusedTab: ({ index }) => __foldkitBrandViewResult(([
76
72
  evo(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/tabs/index.js#maybeFocusedIndex~2") }),
@@ -78,7 +74,7 @@ export const update = (model, message) => __foldkitBrandViewResult((M.value(mess
78
74
  Option.none(),
79
75
  ]), "@foldkit/ui/tabs/index.js#FocusedTab"),
80
76
  CompletedFocusTab: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/tabs/index.js#CompletedFocusTab"),
81
- }))), "@foldkit/ui/tabs/index.js#update");
77
+ })), "@foldkit/ui/tabs/index.js#update");
82
78
  const internalView = defineView((model, viewInputs, h) => {
83
79
  const { id, activationMode, maybeFocusedIndex } = model;
84
80
  const { tabs, selectedValue, ariaLabel, toView, isTabDisabled, orientation = 'Horizontal', } = viewInputs;
@@ -94,9 +90,9 @@ const internalView = defineView((model, viewInputs, h) => {
94
90
  previousKey: 'ArrowUp',
95
91
  }), "@foldkit/ui/tabs/index.js#anonymous~8"))), M.exhaustive);
96
92
  const resolveKeyIndex = keyToIndex(nextKey, previousKey, tabs.length, focusedIndex, isDisabled);
97
- const tabSelectedAt = (index) => __foldkitBrandViewResult((pipe(tabs, Array.get(index), Option.map(value => __foldkitBrandViewResult((SelectedTab({ index, value })), "@foldkit/ui/tabs/index.js#anonymous~9")))), "@foldkit/ui/tabs/index.js#tabSelectedAt");
93
+ const tabSelectedAt = (index) => __foldkitBrandViewResult((pipe(tabs, Array.get(index), Option.map(value => __foldkitBrandViewResult((Message.SelectedTab({ index, value })), "@foldkit/ui/tabs/index.js#anonymous~9")))), "@foldkit/ui/tabs/index.js#tabSelectedAt");
98
94
  const handleAutomaticKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(nextKey, previousKey, 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((tabSelectedAt(resolveKeyIndex(key))), "@foldkit/ui/tabs/index.js#anonymous~10")), M.whenOr('Enter', ' ', () => __foldkitBrandViewResult((tabSelectedAt(focusedIndex)), "@foldkit/ui/tabs/index.js#anonymous~11")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tabs/index.js#anonymous~12")))), "@foldkit/ui/tabs/index.js#handleAutomaticKeyDown");
99
- const handleManualKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(nextKey, previousKey, 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((Option.some(FocusedTab({ index: resolveKeyIndex(key) }))), "@foldkit/ui/tabs/index.js#anonymous~13")), M.whenOr('Enter', ' ', () => __foldkitBrandViewResult((tabSelectedAt(focusedIndex)), "@foldkit/ui/tabs/index.js#anonymous~14")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tabs/index.js#anonymous~15")))), "@foldkit/ui/tabs/index.js#handleManualKeyDown");
95
+ const handleManualKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(nextKey, previousKey, 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((Option.some(Message.FocusedTab({ index: resolveKeyIndex(key) }))), "@foldkit/ui/tabs/index.js#anonymous~13")), M.whenOr('Enter', ' ', () => __foldkitBrandViewResult((tabSelectedAt(focusedIndex)), "@foldkit/ui/tabs/index.js#anonymous~14")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tabs/index.js#anonymous~15")))), "@foldkit/ui/tabs/index.js#handleManualKeyDown");
100
96
  const handleKeyDown = (key) => __foldkitBrandViewResult((M.value(activationMode).pipe(M.when('Automatic', () => __foldkitBrandViewResult((handleAutomaticKeyDown(key)), "@foldkit/ui/tabs/index.js#anonymous~16")), M.when('Manual', () => __foldkitBrandViewResult((handleManualKeyDown(key)), "@foldkit/ui/tabs/index.js#anonymous~17")), M.exhaustive)), "@foldkit/ui/tabs/index.js#handleKeyDown");
101
97
  const tabInfos = Array.map(tabs, (value, index) => {
102
98
  const isActive = index === activeIndex;
@@ -116,7 +112,7 @@ const internalView = defineView((model, viewInputs, h) => {
116
112
  h.AriaDisabled(true),
117
113
  h.DataAttribute('disabled', ''),
118
114
  ]
119
- : [h.OnClick(SelectedTab({ index, value }))]),
115
+ : [h.OnClick(Message.SelectedTab({ index, value }))]),
120
116
  h.OnKeyDownPreventDefault(handleKeyDown),
121
117
  ];
122
118
  const panelAttributes = [
@@ -1,3 +1,3 @@
1
- export { init, create, Model, Message, OutMessage, Selected, SelectedTab, FocusedTab, CompletedFocusTab, FocusTab, Orientation, } from './index.js';
1
+ export { init, create, Model, Message, OutMessage, type Selected, type SelectedTab, type FocusedTab, FocusTab, Orientation, } from './index.js';
2
2
  export type { ActivationMode, InitConfig, ViewInputs, RenderInfo, TabInfo, Bundle, } from './index.js';
3
3
  //# sourceMappingURL=public.d.ts.map