@foldkit/ui 0.129.0 → 0.130.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 (42) hide show
  1. package/dist/anchor.js +12 -11
  2. package/dist/animation/index.js +11 -10
  3. package/dist/animation/schema.js +3 -2
  4. package/dist/animation/update.js +26 -25
  5. package/dist/button/index.js +3 -2
  6. package/dist/calendar/index.js +159 -158
  7. package/dist/checkbox/index.js +9 -8
  8. package/dist/combobox/multi.js +20 -19
  9. package/dist/combobox/shared.js +169 -168
  10. package/dist/combobox/single.js +23 -22
  11. package/dist/datePicker/index.js +69 -68
  12. package/dist/dialog/index.js +52 -51
  13. package/dist/disclosure/index.js +11 -10
  14. package/dist/dragAndDrop/index.js +122 -121
  15. package/dist/fieldset/index.js +5 -4
  16. package/dist/fileDrop/index.js +23 -22
  17. package/dist/group.js +7 -6
  18. package/dist/input/index.js +4 -3
  19. package/dist/internal/optionExtensions.js +2 -1
  20. package/dist/internal/selectors.js +2 -1
  21. package/dist/keyboard.js +5 -4
  22. package/dist/listbox/multi.js +12 -11
  23. package/dist/listbox/shared.js +171 -170
  24. package/dist/listbox/single.js +13 -12
  25. package/dist/menu/index.js +167 -166
  26. package/dist/nav/index.js +7 -6
  27. package/dist/popover/index.js +87 -86
  28. package/dist/radioGroup/index.js +23 -22
  29. package/dist/select/index.js +4 -3
  30. package/dist/slider/index.js +72 -71
  31. package/dist/switch/index.js +6 -5
  32. package/dist/tabs/index.js +34 -33
  33. package/dist/test/apps/disabledButton.js +17 -16
  34. package/dist/textarea/index.js +4 -3
  35. package/dist/toast/index.js +19 -18
  36. package/dist/toast/schema.js +10 -9
  37. package/dist/toast/test.js +2 -1
  38. package/dist/toast/update.js +79 -78
  39. package/dist/tooltip/index.js +59 -58
  40. package/dist/typeahead.js +6 -5
  41. package/dist/virtualList/index.js +66 -65
  42. package/package.json +4 -3
@@ -1,3 +1,4 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  import { Duration, Effect, Equal, Function, Match as M, Number, Option, Predicate, Schema as S, } from 'effect';
2
3
  import * as Command from 'foldkit/command';
3
4
  import { childAttributes, html, } from 'foldkit/html';
@@ -67,11 +68,11 @@ export const OutMessage = S.Union([Shown, Hidden]);
67
68
  * tooltip's base id. Use this to associate an external label with the
68
69
  * trigger via a native `<label for={Tooltip.triggerId(id)}>` or an
69
70
  * `aria-labelledby` reference. */
70
- export const triggerId = (id) => `${id}-trigger`;
71
+ export const triggerId = (id) => __foldkitBrandViewResult((`${id}-trigger`), "@foldkit/ui/tooltip/index.js#triggerId");
71
72
  // INIT
72
73
  const DEFAULT_SHOW_DELAY = Duration.millis(500);
73
74
  /** Creates an initial tooltip model from a config. Defaults to hidden. */
74
- export const init = (config) => ({
75
+ export const init = (config) => (__foldkitBrandViewResult(({
75
76
  id: config.id,
76
77
  isOpen: false,
77
78
  isHovered: false,
@@ -82,105 +83,105 @@ export const init = (config) => ({
82
83
  : Duration.fromInputUnsafe(config.showDelay),
83
84
  pendingShowVersion: 0,
84
85
  maybeLastPointerType: Option.none(),
85
- });
86
+ }), "@foldkit/ui/tooltip/index.js#init"));
86
87
  const withUpdateReturn = M.withReturnType();
87
88
  /** Waits for the tooltip's show delay before emitting `ElapsedShowDelay`. */
88
- export const ShowAfterDelay = Command.define('ShowAfterDelay', { delay: S.DurationFromMillis, version: S.Number }, ElapsedShowDelay)(({ delay, version }) => Effect.sleep(delay).pipe(Effect.as(ElapsedShowDelay({ version }))));
89
+ export const ShowAfterDelay = Command.define('ShowAfterDelay', { delay: S.DurationFromMillis, version: S.Number }, ElapsedShowDelay)(({ delay, version }) => __foldkitBrandViewResult((Effect.sleep(delay).pipe(Effect.as(ElapsedShowDelay({ version })))), "@foldkit/ui/tooltip/index.js#anonymous"));
89
90
  /** The anchor-positioning Mount this Tooltip renders on its panel. */
90
- export const AnchorTooltip = Mount.define('AnchorTooltip', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorTooltip)(({ buttonId, anchor }) => element => Effect.gen(function* () {
91
- yield* Effect.acquireRelease(Effect.sync(() => anchorSetup({
91
+ export const AnchorTooltip = Mount.define('AnchorTooltip', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorTooltip)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
92
+ yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup({
92
93
  buttonId,
93
94
  anchor,
94
95
  interceptTab: false,
95
- })(element)), cleanup => Effect.sync(cleanup));
96
- return CompletedAnchorTooltip();
97
- }));
98
- const computeUpdate = (model, message) => M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
96
+ })(element)), "@foldkit/ui/tooltip/index.js#anonymous~5")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/tooltip/index.js#anonymous~6"));
97
+ return __foldkitBrandViewResult((CompletedAnchorTooltip()), "@foldkit/ui/tooltip/index.js#anonymous~4");
98
+ })), "@foldkit/ui/tooltip/index.js#anonymous~3")), "@foldkit/ui/tooltip/index.js#anonymous~2"));
99
+ const computeUpdate = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
99
100
  EnteredTrigger: () => {
100
101
  if (model.isOpen || model.isDismissed) {
101
- return [evo(model, { isHovered: () => true }), []];
102
+ return __foldkitBrandViewResult(([evo(model, { isHovered: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/index.js#isHovered") }), []]), "@foldkit/ui/tooltip/index.js#EnteredTrigger");
102
103
  }
103
104
  const nextVersion = Number.increment(model.pendingShowVersion);
104
- return [
105
+ return __foldkitBrandViewResult(([
105
106
  evo(model, {
106
- isHovered: () => true,
107
- pendingShowVersion: () => nextVersion,
107
+ isHovered: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/index.js#isHovered~2"),
108
+ pendingShowVersion: () => __foldkitBrandViewResult((nextVersion), "@foldkit/ui/tooltip/index.js#pendingShowVersion"),
108
109
  }),
109
110
  [ShowAfterDelay({ delay: model.showDelay, version: nextVersion })],
110
- ];
111
+ ]), "@foldkit/ui/tooltip/index.js#EnteredTrigger");
111
112
  },
112
- LeftTrigger: () => [
113
+ LeftTrigger: () => __foldkitBrandViewResult(([
113
114
  evo(model, {
114
- isHovered: () => false,
115
- isOpen: () => model.isFocused && model.isOpen,
116
- isDismissed: () => false,
115
+ isHovered: () => __foldkitBrandViewResult((false), "@foldkit/ui/tooltip/index.js#isHovered~3"),
116
+ isOpen: () => __foldkitBrandViewResult((model.isFocused && model.isOpen), "@foldkit/ui/tooltip/index.js#isOpen"),
117
+ isDismissed: () => __foldkitBrandViewResult((false), "@foldkit/ui/tooltip/index.js#isDismissed"),
117
118
  pendingShowVersion: Number.increment,
118
119
  }),
119
120
  [],
120
- ],
121
+ ]), "@foldkit/ui/tooltip/index.js#LeftTrigger"),
121
122
  FocusedTrigger: () => {
122
123
  const isFromMousePress = Option.exists(model.maybeLastPointerType, Equal.equals('mouse'));
123
124
  if (isFromMousePress) {
124
- return [
125
+ return __foldkitBrandViewResult(([
125
126
  evo(model, {
126
- maybeLastPointerType: () => Option.none(),
127
+ maybeLastPointerType: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tooltip/index.js#maybeLastPointerType"),
127
128
  }),
128
129
  [],
129
- ];
130
+ ]), "@foldkit/ui/tooltip/index.js#FocusedTrigger");
130
131
  }
131
132
  if (model.isDismissed) {
132
- return [
133
+ return __foldkitBrandViewResult(([
133
134
  evo(model, {
134
- isFocused: () => true,
135
- maybeLastPointerType: () => Option.none(),
135
+ isFocused: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/index.js#isFocused"),
136
+ maybeLastPointerType: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tooltip/index.js#maybeLastPointerType~2"),
136
137
  }),
137
138
  [],
138
- ];
139
+ ]), "@foldkit/ui/tooltip/index.js#FocusedTrigger");
139
140
  }
140
- return [
141
+ return __foldkitBrandViewResult(([
141
142
  evo(model, {
142
- isFocused: () => true,
143
- isOpen: () => true,
143
+ isFocused: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/index.js#isFocused~2"),
144
+ isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/index.js#isOpen~2"),
144
145
  pendingShowVersion: Number.increment,
145
146
  }),
146
147
  [],
147
- ];
148
+ ]), "@foldkit/ui/tooltip/index.js#FocusedTrigger");
148
149
  },
149
- BlurredTrigger: () => [
150
+ BlurredTrigger: () => __foldkitBrandViewResult(([
150
151
  evo(model, {
151
- isFocused: () => false,
152
- isOpen: () => model.isHovered && model.isOpen,
153
- isDismissed: () => false,
152
+ isFocused: () => __foldkitBrandViewResult((false), "@foldkit/ui/tooltip/index.js#isFocused~3"),
153
+ isOpen: () => __foldkitBrandViewResult((model.isHovered && model.isOpen), "@foldkit/ui/tooltip/index.js#isOpen~3"),
154
+ isDismissed: () => __foldkitBrandViewResult((false), "@foldkit/ui/tooltip/index.js#isDismissed~2"),
154
155
  pendingShowVersion: Number.increment,
155
- maybeLastPointerType: () => Option.none(),
156
+ maybeLastPointerType: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tooltip/index.js#maybeLastPointerType~3"),
156
157
  }),
157
158
  [],
158
- ],
159
- PressedEscape: () => [
159
+ ]), "@foldkit/ui/tooltip/index.js#BlurredTrigger"),
160
+ PressedEscape: () => __foldkitBrandViewResult(([
160
161
  evo(model, {
161
- isOpen: () => false,
162
- isDismissed: () => true,
162
+ isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/tooltip/index.js#isOpen~4"),
163
+ isDismissed: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/index.js#isDismissed~3"),
163
164
  pendingShowVersion: Number.increment,
164
165
  }),
165
166
  [],
166
- ],
167
- PressedPointerOnTrigger: ({ pointerType }) => [
167
+ ]), "@foldkit/ui/tooltip/index.js#PressedEscape"),
168
+ PressedPointerOnTrigger: ({ pointerType }) => __foldkitBrandViewResult(([
168
169
  evo(model, {
169
- maybeLastPointerType: () => Option.some(pointerType),
170
+ maybeLastPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/tooltip/index.js#maybeLastPointerType~4"),
170
171
  }),
171
172
  [],
172
- ],
173
+ ]), "@foldkit/ui/tooltip/index.js#PressedPointerOnTrigger"),
173
174
  ElapsedShowDelay: ({ version }) => {
174
175
  if (version !== model.pendingShowVersion) {
175
- return [model, []];
176
+ return __foldkitBrandViewResult(([model, []]), "@foldkit/ui/tooltip/index.js#ElapsedShowDelay");
176
177
  }
177
178
  if (!model.isHovered) {
178
- return [model, []];
179
+ return __foldkitBrandViewResult(([model, []]), "@foldkit/ui/tooltip/index.js#ElapsedShowDelay");
179
180
  }
180
- return [evo(model, { isOpen: () => true }), []];
181
+ return __foldkitBrandViewResult(([evo(model, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/index.js#isOpen~5") }), []]), "@foldkit/ui/tooltip/index.js#ElapsedShowDelay");
181
182
  },
182
- CompletedAnchorTooltip: () => [model, []],
183
- }));
183
+ CompletedAnchorTooltip: () => __foldkitBrandViewResult(([model, []]), "@foldkit/ui/tooltip/index.js#CompletedAnchorTooltip"),
184
+ }))), "@foldkit/ui/tooltip/index.js#computeUpdate");
184
185
  /** Processes a tooltip message and returns the next model, commands, and
185
186
  * an optional OutMessage. `Shown`/`Hidden` fire only on `isOpen`
186
187
  * transitions, so consumers don't get spurious events for messages that
@@ -192,12 +193,12 @@ export const update = (model, message) => {
192
193
  : model.isOpen && !nextModel.isOpen
193
194
  ? Option.some(Hidden())
194
195
  : Option.none();
195
- return [nextModel, commands, maybeOutMessage];
196
+ return __foldkitBrandViewResult(([nextModel, commands, maybeOutMessage]), "@foldkit/ui/tooltip/index.js#update");
196
197
  };
197
198
  /** Reflects an externally-sourced hover show-delay onto the model without
198
199
  * emitting an OutMessage. Use to mirror an external config value (a user
199
200
  * preference, a restored setting) onto the tooltip. */
200
- export const reflectShowDelay = Function.dual(2, (model, showDelay) => evo(model, { showDelay: () => Duration.fromInputUnsafe(showDelay) }));
201
+ export const reflectShowDelay = Function.dual(2, (model, showDelay) => __foldkitBrandViewResult((evo(model, { showDelay: () => __foldkitBrandViewResult((Duration.fromInputUnsafe(showDelay)), "@foldkit/ui/tooltip/index.js#showDelay") })), "@foldkit/ui/tooltip/index.js#anonymous~7"));
201
202
  /** Renders a headless tooltip with an anchored non-interactive panel.
202
203
  * Shows on hover (after delay) or focus (from keyboard, touch, or pen;
203
204
  * mouse-click focus is excluded). Hides on leave, blur, or Escape. */
@@ -207,18 +208,18 @@ export const view = defineView((model, viewInputs) => {
207
208
  const { anchor, toView, isDisabled, ariaLabel, ariaLabelledBy } = viewInputs;
208
209
  const resolveTriggerLabel = () => {
209
210
  if (Predicate.isNotUndefined(ariaLabel)) {
210
- return [h.AriaLabel(ariaLabel)];
211
+ return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/tooltip/index.js#resolveTriggerLabel");
211
212
  }
212
213
  else if (Predicate.isNotUndefined(ariaLabelledBy)) {
213
- return [h.AriaLabelledBy(ariaLabelledBy)];
214
+ return __foldkitBrandViewResult(([h.AriaLabelledBy(ariaLabelledBy)]), "@foldkit/ui/tooltip/index.js#resolveTriggerLabel");
214
215
  }
215
216
  else {
216
- return [];
217
+ return __foldkitBrandViewResult(([]), "@foldkit/ui/tooltip/index.js#resolveTriggerLabel");
217
218
  }
218
219
  };
219
220
  const triggerLabelAttributes = resolveTriggerLabel();
220
- const handleTriggerKeyDown = (key) => M.value(key).pipe(M.when('Escape', () => OptionExt.when(isOpen, PressedEscape())), M.orElse(() => Option.none()));
221
- const handleTriggerPointerDown = (pointerType) => Option.some(PressedPointerOnTrigger({ pointerType }));
221
+ const handleTriggerKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, PressedEscape())), "@foldkit/ui/tooltip/index.js#anonymous~9")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tooltip/index.js#anonymous~10")))), "@foldkit/ui/tooltip/index.js#handleTriggerKeyDown");
222
+ const handleTriggerPointerDown = (pointerType) => __foldkitBrandViewResult((Option.some(PressedPointerOnTrigger({ pointerType }))), "@foldkit/ui/tooltip/index.js#handleTriggerPointerDown");
222
223
  const triggerAttributes = [
223
224
  h.Id(`${id}-trigger`),
224
225
  h.Type('button'),
@@ -248,9 +249,9 @@ export const view = defineView((model, viewInputs) => {
248
249
  h.OnMount(AnchorTooltip({ buttonId: `${id}-trigger`, anchor })),
249
250
  ...(isOpen ? [h.DataAttribute('open', '')] : []),
250
251
  ];
251
- return toView({
252
+ return __foldkitBrandViewResult((toView({
252
253
  trigger: childAttributes(triggerAttributes),
253
254
  panel: childAttributes(panelAttributes),
254
255
  isVisible: isOpen,
255
- });
256
+ })), "@foldkit/ui/tooltip/index.js#anonymous~8");
256
257
  });
package/dist/typeahead.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  import { Array, Option, String as Str, pipe } from 'effect';
2
3
  import { wrapIndex } from './keyboard.js';
3
4
  /** Finds the first enabled item whose search text starts with the query, searching forward from the active item and wrapping around. On a fresh search, starts after the active item; on a refinement, includes the active item. */
@@ -5,10 +6,10 @@ export const resolveTypeaheadMatch = (items, query, maybeActiveItemIndex, isDisa
5
6
  const lowerQuery = Str.toLowerCase(query);
6
7
  const offset = isRefinement ? 0 : 1;
7
8
  const startIndex = Option.match(maybeActiveItemIndex, {
8
- onNone: () => 0,
9
- onSome: index => index + offset,
9
+ onNone: () => __foldkitBrandViewResult((0), "@foldkit/ui/typeahead.js#onNone"),
10
+ onSome: index => __foldkitBrandViewResult((index + offset), "@foldkit/ui/typeahead.js#onSome"),
10
11
  });
11
- const isEnabledMatch = (index) => !isDisabled(index) &&
12
- pipe(items, Array.get(index), Option.exists(item => pipe(itemToSearchText(item, index), Str.toLowerCase, Str.startsWith(lowerQuery))));
13
- return pipe(items, Array.length, Array.makeBy(step => wrapIndex(startIndex + step, items.length)), Array.findFirst(isEnabledMatch));
12
+ const isEnabledMatch = (index) => __foldkitBrandViewResult((!isDisabled(index) &&
13
+ pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((pipe(itemToSearchText(item, index), Str.toLowerCase, Str.startsWith(lowerQuery))), "@foldkit/ui/typeahead.js#anonymous")))), "@foldkit/ui/typeahead.js#isEnabledMatch");
14
+ return __foldkitBrandViewResult((pipe(items, Array.length, Array.makeBy(step => __foldkitBrandViewResult((wrapIndex(startIndex + step, items.length)), "@foldkit/ui/typeahead.js#anonymous~2")), Array.findFirst(isEnabledMatch))), "@foldkit/ui/typeahead.js#resolveTypeaheadMatch");
14
15
  };
@@ -1,3 +1,4 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  import { Array, Effect, Match as M, Number, Option, Queue, Schema as S, Stream, pipe, } from 'effect';
2
3
  import * as Command from 'foldkit/command';
3
4
  import { childAttributes, html, } from 'foldkit/html';
@@ -55,41 +56,41 @@ export const Message = S.Union([ScrolledContainer, MeasuredContainer, CompletedA
55
56
  /** Creates an initial virtual list model from a config. The container starts
56
57
  * in `Unmeasured` state. The first `ResizeObserver` entry transitions it to
57
58
  * `Measured`. */
58
- export const init = (config) => ({
59
+ export const init = (config) => (__foldkitBrandViewResult(({
59
60
  id: config.id,
60
61
  rowHeightPx: config.rowHeightPx,
61
62
  scrollTop: config.initialScrollTop ?? 0,
62
63
  measurement: Unmeasured(),
63
64
  pendingScroll: Idle(),
64
65
  pendingScrollVersion: 0,
65
- });
66
+ }), "@foldkit/ui/virtualList/index.js#init"));
66
67
  // UPDATE
67
- export const ApplyScroll = Command.define('ApplyScroll', { id: S.String, scrollTop: S.Number, version: S.Number }, CompletedApplyScroll)(({ id, scrollTop, version }) => Effect.sync(() => {
68
+ export const ApplyScroll = Command.define('ApplyScroll', { id: S.String, scrollTop: S.Number, version: S.Number }, CompletedApplyScroll)(({ id, scrollTop, version }) => __foldkitBrandViewResult((Effect.sync(() => {
68
69
  const element = document.getElementById(id);
69
70
  if (element !== null) {
70
71
  element.scrollTop = scrollTop;
71
72
  }
72
- return CompletedApplyScroll({ version });
73
- }));
73
+ return __foldkitBrandViewResult((CompletedApplyScroll({ version })), "@foldkit/ui/virtualList/index.js#anonymous~2");
74
+ })), "@foldkit/ui/virtualList/index.js#anonymous"));
74
75
  /** Processes a virtual list message and returns the next model and commands. */
75
- export const update = (model, message) => M.value(message).pipe(M.withReturnType(), M.tagsExhaustive({
76
- ScrolledContainer: ({ scrollTop }) => [
77
- evo(model, { scrollTop: () => scrollTop }),
76
+ export const update = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(M.withReturnType(), M.tagsExhaustive({
77
+ ScrolledContainer: ({ scrollTop }) => __foldkitBrandViewResult(([
78
+ evo(model, { scrollTop: () => __foldkitBrandViewResult((scrollTop), "@foldkit/ui/virtualList/index.js#scrollTop") }),
78
79
  [],
79
- ],
80
+ ]), "@foldkit/ui/virtualList/index.js#ScrolledContainer"),
80
81
  MeasuredContainer: ({ containerHeight }) => {
81
82
  const wasUnmeasured = model.measurement._tag === 'Unmeasured';
82
83
  const needsInitialApply = wasUnmeasured && model.scrollTop !== 0;
83
84
  if (needsInitialApply) {
84
85
  const nextVersion = Number.increment(model.pendingScrollVersion);
85
- return [
86
+ return __foldkitBrandViewResult(([
86
87
  evo(model, {
87
- measurement: () => Measured({ containerHeight }),
88
- pendingScrollVersion: () => nextVersion,
89
- pendingScroll: () => ScrollingToIndex({
88
+ measurement: () => __foldkitBrandViewResult((Measured({ containerHeight })), "@foldkit/ui/virtualList/index.js#measurement"),
89
+ pendingScrollVersion: () => __foldkitBrandViewResult((nextVersion), "@foldkit/ui/virtualList/index.js#pendingScrollVersion"),
90
+ pendingScroll: () => __foldkitBrandViewResult((ScrollingToIndex({
90
91
  index: Math.floor(model.scrollTop / model.rowHeightPx),
91
92
  version: nextVersion,
92
- }),
93
+ })), "@foldkit/ui/virtualList/index.js#pendingScroll"),
93
94
  }),
94
95
  [
95
96
  ApplyScroll({
@@ -98,30 +99,30 @@ export const update = (model, message) => M.value(message).pipe(M.withReturnType
98
99
  version: nextVersion,
99
100
  }),
100
101
  ],
101
- ];
102
+ ]), "@foldkit/ui/virtualList/index.js#MeasuredContainer");
102
103
  }
103
104
  else {
104
- return [
105
- evo(model, { measurement: () => Measured({ containerHeight }) }),
105
+ return __foldkitBrandViewResult(([
106
+ evo(model, { measurement: () => __foldkitBrandViewResult((Measured({ containerHeight })), "@foldkit/ui/virtualList/index.js#measurement~2") }),
106
107
  [],
107
- ];
108
+ ]), "@foldkit/ui/virtualList/index.js#MeasuredContainer");
108
109
  }
109
110
  },
110
111
  CompletedApplyScroll: ({ version }) => {
111
112
  if (version !== model.pendingScrollVersion) {
112
- return [model, []];
113
+ return __foldkitBrandViewResult(([model, []]), "@foldkit/ui/virtualList/index.js#CompletedApplyScroll");
113
114
  }
114
115
  else {
115
- return [evo(model, { pendingScroll: () => Idle() }), []];
116
+ return __foldkitBrandViewResult(([evo(model, { pendingScroll: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/virtualList/index.js#pendingScroll~2") }), []]), "@foldkit/ui/virtualList/index.js#CompletedApplyScroll");
116
117
  }
117
118
  },
118
- }));
119
+ }))), "@foldkit/ui/virtualList/index.js#update");
119
120
  const buildScrollToIndex = (model, index, targetScrollTop) => {
120
121
  const nextVersion = Number.increment(model.pendingScrollVersion);
121
- return [
122
+ return __foldkitBrandViewResult(([
122
123
  evo(model, {
123
- pendingScrollVersion: () => nextVersion,
124
- pendingScroll: () => ScrollingToIndex({ index, version: nextVersion }),
124
+ pendingScrollVersion: () => __foldkitBrandViewResult((nextVersion), "@foldkit/ui/virtualList/index.js#pendingScrollVersion~2"),
125
+ pendingScroll: () => __foldkitBrandViewResult((ScrollingToIndex({ index, version: nextVersion })), "@foldkit/ui/virtualList/index.js#pendingScroll~3"),
125
126
  }),
126
127
  [
127
128
  ApplyScroll({
@@ -130,7 +131,7 @@ const buildScrollToIndex = (model, index, targetScrollTop) => {
130
131
  version: nextVersion,
131
132
  }),
132
133
  ],
133
- ];
134
+ ]), "@foldkit/ui/virtualList/index.js#buildScrollToIndex");
134
135
  };
135
136
  /** Programmatically scrolls the container so the row at `index` is visible.
136
137
  * Returns the next model and a Command that mutates `element.scrollTop`. The
@@ -148,7 +149,7 @@ const buildScrollToIndex = (model, index, targetScrollTop) => {
148
149
  * Assumes uniform row heights: target scroll position is computed as
149
150
  * `index * model.rowHeightPx`. For variable-height rows, use
150
151
  * `scrollToIndexVariable`. */
151
- export const scrollToIndex = (model, index) => buildScrollToIndex(model, index, index * model.rowHeightPx);
152
+ export const scrollToIndex = (model, index) => __foldkitBrandViewResult((buildScrollToIndex(model, index, index * model.rowHeightPx)), "@foldkit/ui/virtualList/index.js#scrollToIndex");
152
153
  /** Variable-height counterpart of `scrollToIndex`. Walks the heights of items
153
154
  * before `index` to compute the target `scrollTop`. Use this when rendering
154
155
  * the list with `itemToRowHeightPx`; use `scrollToIndex` for uniform heights.
@@ -164,15 +165,15 @@ export const scrollToIndex = (model, index) => buildScrollToIndex(model, index,
164
165
  * `MeasuredContainer` arrives. */
165
166
  export const scrollToIndexVariable = (model, items, itemToRowHeightPx, index) => {
166
167
  const cumulativeOffsets = prefixSum(items, itemToRowHeightPx);
167
- const targetScrollTop = pipe(cumulativeOffsets, Array.get(Math.max(0, index)), Option.getOrElse(() => lastOrZero(cumulativeOffsets)));
168
- return buildScrollToIndex(model, index, targetScrollTop);
168
+ const targetScrollTop = pipe(cumulativeOffsets, Array.get(Math.max(0, index)), Option.getOrElse(() => __foldkitBrandViewResult((lastOrZero(cumulativeOffsets)), "@foldkit/ui/virtualList/index.js#anonymous~3")));
169
+ return __foldkitBrandViewResult((buildScrollToIndex(model, index, targetScrollTop)), "@foldkit/ui/virtualList/index.js#scrollToIndexVariable");
169
170
  };
170
- const clampIndex = (index, itemCount) => Math.max(0, Math.min(index, itemCount));
171
+ const clampIndex = (index, itemCount) => __foldkitBrandViewResult((Math.max(0, Math.min(index, itemCount))), "@foldkit/ui/virtualList/index.js#clampIndex");
171
172
  const prefixSum = (items, itemToRowHeightPx) => {
172
173
  const heights = Array.map(items, itemToRowHeightPx);
173
- return Array.scan(heights, 0, (cumulative, height) => cumulative + height);
174
+ return __foldkitBrandViewResult((Array.scan(heights, 0, (cumulative, height) => __foldkitBrandViewResult((cumulative + height), "@foldkit/ui/virtualList/index.js#anonymous~4"))), "@foldkit/ui/virtualList/index.js#prefixSum");
174
175
  };
175
- const lastOrZero = (values) => pipe(values, Array.last, Option.getOrElse(() => 0));
176
+ const lastOrZero = (values) => __foldkitBrandViewResult((pipe(values, Array.last, Option.getOrElse(() => __foldkitBrandViewResult((0), "@foldkit/ui/virtualList/index.js#anonymous~5")))), "@foldkit/ui/virtualList/index.js#lastOrZero");
176
177
  /** Computes the visible slice of a data array given the current scroll
177
178
  * position, container height, row height, and an overscan buffer.
178
179
  *
@@ -182,8 +183,8 @@ const lastOrZero = (values) => pipe(values, Array.last, Option.getOrElse(() => 0
182
183
  * Returns `Option.none()` when the container has not yet been measured;
183
184
  * callers should render a placeholder (or `Html.empty`) and wait for the
184
185
  * first `MeasuredContainer` message. */
185
- export const visibleWindow = (model, itemCount, overscan) => M.value(model.measurement).pipe(M.withReturnType(), M.tagsExhaustive({
186
- Unmeasured: () => Option.none(),
186
+ export const visibleWindow = (model, itemCount, overscan) => __foldkitBrandViewResult((M.value(model.measurement).pipe(M.withReturnType(), M.tagsExhaustive({
187
+ Unmeasured: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/virtualList/index.js#Unmeasured"),
187
188
  Measured: ({ containerHeight }) => {
188
189
  const firstVisibleIndex = Math.floor(model.scrollTop / model.rowHeightPx);
189
190
  const lastVisibleIndex = Math.ceil((model.scrollTop + containerHeight) / model.rowHeightPx);
@@ -191,14 +192,14 @@ export const visibleWindow = (model, itemCount, overscan) => M.value(model.measu
191
192
  const endIndex = clampIndex(lastVisibleIndex + overscan, itemCount);
192
193
  const topSpacerHeight = startIndex * model.rowHeightPx;
193
194
  const bottomSpacerHeight = (itemCount - endIndex) * model.rowHeightPx;
194
- return Option.some({
195
+ return __foldkitBrandViewResult((Option.some({
195
196
  startIndex,
196
197
  endIndex,
197
198
  topSpacerHeight,
198
199
  bottomSpacerHeight,
199
- });
200
+ })), "@foldkit/ui/virtualList/index.js#Measured");
200
201
  },
201
- }));
202
+ }))), "@foldkit/ui/virtualList/index.js#visibleWindow");
202
203
  /** Variable-height counterpart of `visibleWindow`. Walks the heights of every
203
204
  * item to build a prefix-sum array, then locates the visible slice with two
204
205
  * linear searches.
@@ -210,32 +211,32 @@ export const visibleWindow = (model, itemCount, overscan) => M.value(model.measu
210
211
  * return shape so consumers don't have to know.
211
212
  *
212
213
  * Returns `Option.none()` when the container has not yet been measured. */
213
- export const visibleWindowVariable = (model, items, itemToRowHeightPx, overscan) => M.value(model.measurement).pipe(M.withReturnType(), M.tagsExhaustive({
214
- Unmeasured: () => Option.none(),
214
+ export const visibleWindowVariable = (model, items, itemToRowHeightPx, overscan) => __foldkitBrandViewResult((M.value(model.measurement).pipe(M.withReturnType(), M.tagsExhaustive({
215
+ Unmeasured: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/virtualList/index.js#Unmeasured~2"),
215
216
  Measured: ({ containerHeight }) => {
216
217
  const itemCount = items.length;
217
218
  const cumulativeOffsets = prefixSum(items, itemToRowHeightPx);
218
219
  const totalHeight = lastOrZero(cumulativeOffsets);
219
220
  const firstVisibleIndex = pipe(cumulativeOffsets, Array.findFirstIndex(Number.isGreaterThan(model.scrollTop)), Option.match({
220
- onNone: () => itemCount,
221
- onSome: index => Math.max(0, index - 1),
221
+ onNone: () => __foldkitBrandViewResult((itemCount), "@foldkit/ui/virtualList/index.js#onNone"),
222
+ onSome: index => __foldkitBrandViewResult((Math.max(0, index - 1)), "@foldkit/ui/virtualList/index.js#onSome"),
222
223
  }));
223
- const lastVisibleIndex = pipe(cumulativeOffsets, Array.findFirstIndex(Number.isGreaterThanOrEqualTo(model.scrollTop + containerHeight)), Option.getOrElse(() => itemCount));
224
+ const lastVisibleIndex = pipe(cumulativeOffsets, Array.findFirstIndex(Number.isGreaterThanOrEqualTo(model.scrollTop + containerHeight)), Option.getOrElse(() => __foldkitBrandViewResult((itemCount), "@foldkit/ui/virtualList/index.js#anonymous~6")));
224
225
  const startIndex = clampIndex(firstVisibleIndex - overscan, itemCount);
225
226
  const endIndex = clampIndex(lastVisibleIndex + overscan, itemCount);
226
- const topSpacerHeight = pipe(cumulativeOffsets, Array.get(startIndex), Option.getOrElse(() => 0));
227
- const offsetAtEnd = pipe(cumulativeOffsets, Array.get(endIndex), Option.getOrElse(() => totalHeight));
227
+ const topSpacerHeight = pipe(cumulativeOffsets, Array.get(startIndex), Option.getOrElse(() => __foldkitBrandViewResult((0), "@foldkit/ui/virtualList/index.js#anonymous~7")));
228
+ const offsetAtEnd = pipe(cumulativeOffsets, Array.get(endIndex), Option.getOrElse(() => __foldkitBrandViewResult((totalHeight), "@foldkit/ui/virtualList/index.js#anonymous~8")));
228
229
  const bottomSpacerHeight = totalHeight - offsetAtEnd;
229
- return Option.some({
230
+ return __foldkitBrandViewResult((Option.some({
230
231
  startIndex,
231
232
  endIndex,
232
233
  topSpacerHeight,
233
234
  bottomSpacerHeight,
234
- });
235
+ })), "@foldkit/ui/virtualList/index.js#Measured~2");
235
236
  },
236
- }));
237
+ }))), "@foldkit/ui/virtualList/index.js#visibleWindowVariable");
237
238
  // SUBSCRIPTION
238
- const containerElement = (id) => Option.fromNullishOr(document.getElementById(id));
239
+ const containerElement = (id) => __foldkitBrandViewResult((Option.fromNullishOr(document.getElementById(id))), "@foldkit/ui/virtualList/index.js#containerElement");
239
240
  /** Subscriptions that track the container's scroll position and size.
240
241
  *
241
242
  * - **scroll**: listens for `scroll` events on the container element and
@@ -249,10 +250,10 @@ const containerElement = (id) => Option.fromNullishOr(document.getElementById(id
249
250
  * makes the subscription robust across SPA route changes: navigating to a
250
251
  * page that mounts the list, away, and back all reattach correctly without
251
252
  * the consumer having to teach the framework about navigation. */
252
- export const subscriptions = Subscription.make()(entry => ({
253
+ export const subscriptions = Subscription.make()(entry => (__foldkitBrandViewResult(({
253
254
  containerEvents: entry({ id: S.String }, {
254
- modelToDependencies: model => ({ id: model.id }),
255
- dependenciesToStream: ({ id }) => Stream.callback(queue => Effect.acquireRelease(Effect.sync(() => {
255
+ modelToDependencies: model => (__foldkitBrandViewResult(({ id: model.id }), "@foldkit/ui/virtualList/index.js#modelToDependencies")),
256
+ dependenciesToStream: ({ id }) => __foldkitBrandViewResult((Stream.callback(queue => __foldkitBrandViewResult((Effect.acquireRelease(Effect.sync(() => {
256
257
  const state = {
257
258
  scrollListener: null,
258
259
  resizeObserver: null,
@@ -272,7 +273,7 @@ export const subscriptions = Subscription.make()(entry => ({
272
273
  state.scrollListener = null;
273
274
  };
274
275
  const attach = (element) => {
275
- const listener = () => Queue.offerUnsafe(queue, ScrolledContainer({ scrollTop: element.scrollTop }));
276
+ const listener = () => __foldkitBrandViewResult((Queue.offerUnsafe(queue, ScrolledContainer({ scrollTop: element.scrollTop }))), "@foldkit/ui/virtualList/index.js#listener");
276
277
  element.addEventListener('scroll', listener, { passive: true });
277
278
  state.scrollListener = listener;
278
279
  state.observedElement = element;
@@ -321,21 +322,21 @@ export const subscriptions = Subscription.make()(entry => ({
321
322
  childList: true,
322
323
  subtree: true,
323
324
  });
324
- return { state, detach, mutationObserver };
325
- }), ({ state, detach, mutationObserver }) => Effect.sync(() => {
325
+ return __foldkitBrandViewResult(({ state, detach, mutationObserver }), "@foldkit/ui/virtualList/index.js#anonymous~11");
326
+ }), ({ state, detach, mutationObserver }) => __foldkitBrandViewResult((Effect.sync(() => {
326
327
  mutationObserver.disconnect();
327
328
  if (state.pendingFrame !== null) {
328
329
  cancelAnimationFrame(state.pendingFrame);
329
330
  }
330
331
  detach();
331
- })).pipe(Effect.flatMap(() => Effect.never))),
332
+ })), "@foldkit/ui/virtualList/index.js#anonymous~15")).pipe(Effect.flatMap(() => __foldkitBrandViewResult((Effect.never), "@foldkit/ui/virtualList/index.js#anonymous~17")))), "@foldkit/ui/virtualList/index.js#anonymous~10"))), "@foldkit/ui/virtualList/index.js#dependenciesToStream"),
332
333
  }),
333
- }));
334
+ }), "@foldkit/ui/virtualList/index.js#anonymous~9")));
334
335
  // VIEW
335
336
  const DEFAULT_OVERSCAN = 5;
336
337
  export const view = () =>
337
338
  /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
338
- viewImpl;
339
+ __foldkitBrandViewResult((viewImpl), "@foldkit/ui/virtualList/index.js#view");
339
340
  const viewImpl = defineView((model, viewInputs) => {
340
341
  const h = html();
341
342
  const { items, itemToKey, itemToView, itemToRowHeightPx, overscan = DEFAULT_OVERSCAN, rowElement = 'li', containerClassName, containerAttributes = [], } = viewInputs;
@@ -357,15 +358,15 @@ const viewImpl = defineView((model, viewInputs) => {
357
358
  ...childAttributes(baseContainerAttributes),
358
359
  ...containerAttributes,
359
360
  ];
360
- const renderContainer = (children) => h.keyed('ul')(model.id, allContainerAttributes, children);
361
+ const renderContainer = (children) => __foldkitBrandViewResult((h.keyed('ul')(model.id, allContainerAttributes, children)), "@foldkit/ui/virtualList/index.js#renderContainer");
361
362
  const maybeWindow = itemToRowHeightPx !== undefined
362
363
  ? visibleWindowVariable(model, items, itemToRowHeightPx, overscan)
363
364
  : visibleWindow(model, items.length, overscan);
364
- const rowHeightFor = (item, dataIndex) => itemToRowHeightPx !== undefined
365
+ const rowHeightFor = (item, dataIndex) => __foldkitBrandViewResult((itemToRowHeightPx !== undefined
365
366
  ? itemToRowHeightPx(item, dataIndex)
366
- : model.rowHeightPx;
367
- return Option.match(maybeWindow, {
368
- onNone: () => renderContainer([]),
367
+ : model.rowHeightPx), "@foldkit/ui/virtualList/index.js#rowHeightFor");
368
+ return __foldkitBrandViewResult((Option.match(maybeWindow, {
369
+ onNone: () => __foldkitBrandViewResult((renderContainer([])), "@foldkit/ui/virtualList/index.js#onNone~2"),
369
370
  onSome: ({ startIndex, endIndex, topSpacerHeight, bottomSpacerHeight, }) => {
370
371
  const visibleItems = items.slice(startIndex, endIndex);
371
372
  const topSpacer = h.keyed('li')(`${model.id}-top-spacer`, [h.Role('presentation'), h.Style({ height: `${topSpacerHeight}px` })], []);
@@ -375,7 +376,7 @@ const viewImpl = defineView((model, viewInputs) => {
375
376
  ], []);
376
377
  const renderedRows = Array.map(visibleItems, (item, sliceIndex) => {
377
378
  const dataIndex = startIndex + sliceIndex;
378
- return h.keyed(rowElement)(itemToKey(item, dataIndex), [
379
+ return __foldkitBrandViewResult((h.keyed(rowElement)(itemToKey(item, dataIndex), [
379
380
  h.Role('listitem'),
380
381
  h.DataAttribute('virtual-list-item-index', String(dataIndex)),
381
382
  h.AriaSetsize(items.length),
@@ -384,9 +385,9 @@ const viewImpl = defineView((model, viewInputs) => {
384
385
  height: `${rowHeightFor(item, dataIndex)}px`,
385
386
  display: 'grid',
386
387
  }),
387
- ], [itemToView(item, dataIndex)]);
388
+ ], [itemToView(item, dataIndex)])), "@foldkit/ui/virtualList/index.js#anonymous~19");
388
389
  });
389
- return renderContainer([topSpacer, ...renderedRows, bottomSpacer]);
390
+ return __foldkitBrandViewResult((renderContainer([topSpacer, ...renderedRows, bottomSpacer])), "@foldkit/ui/virtualList/index.js#onSome~2");
390
391
  },
391
- });
392
+ })), "@foldkit/ui/virtualList/index.js#anonymous~18");
392
393
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldkit/ui",
3
- "version": "0.129.0",
3
+ "version": "0.130.0",
4
4
  "description": "Headless, accessible UI components for Foldkit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -127,7 +127,8 @@
127
127
  "typedoc": "^0.28.19",
128
128
  "typescript": "^6.0.3",
129
129
  "vitest": "^4.1.9",
130
- "foldkit": "0.129.0"
130
+ "@foldkit/vite-plugin": "0.11.0",
131
+ "foldkit": "0.130.0"
131
132
  },
132
133
  "keywords": [
133
134
  "foldkit",
@@ -151,7 +152,7 @@
151
152
  },
152
153
  "scripts": {
153
154
  "clean": "rimraf dist *.tsbuildinfo",
154
- "build": "pnpm run clean && tsc -b tsconfig.build.json",
155
+ "build": "pnpm run clean && tsc -b tsconfig.build.json && node scripts/brand-dist.mjs",
155
156
  "docs": "typedoc",
156
157
  "watch": "tsc -b tsconfig.build.json --watch",
157
158
  "lint": "pnpm --filter @foldkit/oxlint-plugin build && oxlint src",