@foldkit/ui 0.129.0 → 0.131.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 { Array, Match as M, Option, Schema as S } from 'effect';
2
3
  import * as File from 'foldkit/file';
3
4
  import { childAttributes, html, } from 'foldkit/html';
@@ -57,38 +58,38 @@ export const RejectedNonFiles = m('RejectedNonFiles');
57
58
  * path and `RejectedNonFiles` when a drop event fires without files. */
58
59
  export const OutMessage = S.Union([ReceivedFiles, RejectedNonFiles]);
59
60
  /** Creates an initial file-drop model. Drag state starts cleared. */
60
- export const init = (config) => ({
61
+ export const init = (config) => (__foldkitBrandViewResult(({
61
62
  id: config.id,
62
63
  isDragOver: false,
63
- });
64
+ }), "@foldkit/ui/fileDrop/index.js#init"));
64
65
  /** Processes a file-drop message and returns the next model, commands,
65
66
  * and optional OutMessage. */
66
- export const update = (model, message) => M.value(message).pipe(M.withReturnType(), M.tagsExhaustive({
67
- EnteredDragZone: () => [
68
- evo(model, { isDragOver: () => true }),
67
+ export const update = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(M.withReturnType(), M.tagsExhaustive({
68
+ EnteredDragZone: () => __foldkitBrandViewResult(([
69
+ evo(model, { isDragOver: () => __foldkitBrandViewResult((true), "@foldkit/ui/fileDrop/index.js#isDragOver") }),
69
70
  [],
70
71
  Option.none(),
71
- ],
72
- LeftDragZone: () => [
73
- evo(model, { isDragOver: () => false }),
72
+ ]), "@foldkit/ui/fileDrop/index.js#EnteredDragZone"),
73
+ LeftDragZone: () => __foldkitBrandViewResult(([
74
+ evo(model, { isDragOver: () => __foldkitBrandViewResult((false), "@foldkit/ui/fileDrop/index.js#isDragOver~2") }),
74
75
  [],
75
76
  Option.none(),
76
- ],
77
- DroppedFiles: ({ files }) => [
78
- evo(model, { isDragOver: () => false }),
77
+ ]), "@foldkit/ui/fileDrop/index.js#LeftDragZone"),
78
+ DroppedFiles: ({ files }) => __foldkitBrandViewResult(([
79
+ evo(model, { isDragOver: () => __foldkitBrandViewResult((false), "@foldkit/ui/fileDrop/index.js#isDragOver~3") }),
79
80
  [],
80
81
  Option.some(ReceivedFiles({ files })),
81
- ],
82
- DroppedNonFiles: () => [
83
- evo(model, { isDragOver: () => false }),
82
+ ]), "@foldkit/ui/fileDrop/index.js#DroppedFiles"),
83
+ DroppedNonFiles: () => __foldkitBrandViewResult(([
84
+ evo(model, { isDragOver: () => __foldkitBrandViewResult((false), "@foldkit/ui/fileDrop/index.js#isDragOver~4") }),
84
85
  [],
85
86
  Option.some(RejectedNonFiles()),
86
- ],
87
- }));
88
- const dispatchDroppedFiles = (files) => Array.match(files, {
89
- onEmpty: () => DroppedNonFiles(),
90
- onNonEmpty: nonEmptyFiles => DroppedFiles({ files: [...nonEmptyFiles] }),
91
- });
87
+ ]), "@foldkit/ui/fileDrop/index.js#DroppedNonFiles"),
88
+ }))), "@foldkit/ui/fileDrop/index.js#update");
89
+ const dispatchDroppedFiles = (files) => __foldkitBrandViewResult((Array.match(files, {
90
+ onEmpty: () => __foldkitBrandViewResult((DroppedNonFiles()), "@foldkit/ui/fileDrop/index.js#onEmpty"),
91
+ onNonEmpty: nonEmptyFiles => __foldkitBrandViewResult((DroppedFiles({ files: [...nonEmptyFiles] })), "@foldkit/ui/fileDrop/index.js#onNonEmpty"),
92
+ })), "@foldkit/ui/fileDrop/index.js#dispatchDroppedFiles");
92
93
  /** Renders an accessible file-drop zone by publishing attribute groups
93
94
  * for a `<label>`-wrapped hidden file input. */
94
95
  export const view = defineView((model, viewInputs) => {
@@ -120,8 +121,8 @@ export const view = defineView((model, viewInputs) => {
120
121
  ? [h.Disabled(true)]
121
122
  : [h.OnFileChange(dispatchDroppedFiles)]),
122
123
  ];
123
- return toView({
124
+ return __foldkitBrandViewResult((toView({
124
125
  root: childAttributes(rootAttributes),
125
126
  input: childAttributes(inputAttributes),
126
- });
127
+ })), "@foldkit/ui/fileDrop/index.js#anonymous");
127
128
  });
package/dist/group.js CHANGED
@@ -1,13 +1,14 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  import { Array } from 'effect';
2
3
  /** Groups items into contiguous segments by a key function. Adjacent items with the same key are collected into a single segment. */
3
4
  export const groupContiguous = (items, toKey) => {
4
- const tagged = Array.map(items, (item, index) => ({
5
+ const tagged = Array.map(items, (item, index) => (__foldkitBrandViewResult(({
5
6
  key: toKey(item, index),
6
7
  item,
7
- }));
8
- return Array.chop(tagged, nonEmpty => {
8
+ }), "@foldkit/ui/group.js#anonymous")));
9
+ return __foldkitBrandViewResult((Array.chop(tagged, nonEmpty => {
9
10
  const key = Array.headNonEmpty(nonEmpty).key;
10
- const [matching, rest] = Array.span(nonEmpty, tagged => tagged.key === key);
11
- return [{ key, items: Array.map(matching, ({ item }) => item) }, rest];
12
- });
11
+ const [matching, rest] = Array.span(nonEmpty, tagged => __foldkitBrandViewResult((tagged.key === key), "@foldkit/ui/group.js#anonymous~3"));
12
+ return __foldkitBrandViewResult(([{ key, items: Array.map(matching, ({ item }) => __foldkitBrandViewResult((item), "@foldkit/ui/group.js#anonymous~4")) }, rest]), "@foldkit/ui/group.js#anonymous~2");
13
+ })), "@foldkit/ui/group.js#groupContiguous");
13
14
  };
@@ -1,7 +1,8 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  import { Predicate } from 'effect';
2
3
  import { html } from 'foldkit/html';
3
4
  /** Generates the description element ID from the input's base ID. */
4
- export const descriptionId = (id) => `${id}-description`;
5
+ export const descriptionId = (id) => __foldkitBrandViewResult((`${id}-description`), "@foldkit/ui/input/index.js#descriptionId");
5
6
  /** Renders an accessible input by building ARIA attribute groups and delegating layout to the consumer's `toView` callback. */
6
7
  export const view = (config) => {
7
8
  const h = html();
@@ -35,9 +36,9 @@ export const view = (config) => {
35
36
  ];
36
37
  const labelAttributes = [h.For(id)];
37
38
  const descriptionAttributes = [h.Id(descriptionId(id))];
38
- return toView({
39
+ return __foldkitBrandViewResult((toView({
39
40
  input: allInputAttributes,
40
41
  label: labelAttributes,
41
42
  description: descriptionAttributes,
42
- });
43
+ })), "@foldkit/ui/input/index.js#view");
43
44
  };
@@ -1,2 +1,3 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  import { Function, Option } from 'effect';
2
- export const when = Function.dual(2, (condition, value) => Option.liftPredicate(value, () => condition));
3
+ export const when = Function.dual(2, (condition, value) => __foldkitBrandViewResult((Option.liftPredicate(value, () => __foldkitBrandViewResult((condition), "@foldkit/ui/internal/optionExtensions.js#anonymous~2"))), "@foldkit/ui/internal/optionExtensions.js#anonymous"));
@@ -1,3 +1,4 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  /**
2
3
  * Builds a CSS id selector from an element's id value.
3
4
  *
@@ -5,4 +6,4 @@
5
6
  * identifiers on their own (most notably ids beginning with a digit, as
6
7
  * produced by UUID-prefixed ids) still yield a usable selector.
7
8
  */
8
- export const idSelector = (id) => `#${CSS.escape(id)}`;
9
+ export const idSelector = (id) => __foldkitBrandViewResult((`#${CSS.escape(id)}`), "@foldkit/ui/internal/selectors.js#idSelector");
package/dist/keyboard.js CHANGED
@@ -1,9 +1,10 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  import { Array, Match as M, Option, Predicate, pipe } from 'effect';
2
3
  /** Whether a keyboard event key is a single printable character (not a named key like "Enter" or "ArrowDown"). */
3
- export const isPrintableKey = (key) => key.length === 1;
4
- export const wrapIndex = (index, length) => ((index % length) + length) % length;
5
- export const findFirstEnabledIndex = (itemCount, focusedIndex, isDisabled) => (startIndex, direction) => pipe(itemCount, Array.makeBy(step => wrapIndex(startIndex + step * direction, itemCount)), Array.findFirst(Predicate.not(isDisabled)), Option.getOrElse(() => focusedIndex));
4
+ export const isPrintableKey = (key) => __foldkitBrandViewResult((key.length === 1), "@foldkit/ui/keyboard.js#isPrintableKey");
5
+ export const wrapIndex = (index, length) => __foldkitBrandViewResult((((index % length) + length) % length), "@foldkit/ui/keyboard.js#wrapIndex");
6
+ export const findFirstEnabledIndex = (itemCount, focusedIndex, isDisabled) => __foldkitBrandViewResult(((startIndex, direction) => __foldkitBrandViewResult((pipe(itemCount, Array.makeBy(step => __foldkitBrandViewResult((wrapIndex(startIndex + step * direction, itemCount)), "@foldkit/ui/keyboard.js#anonymous~2")), Array.findFirst(Predicate.not(isDisabled)), Option.getOrElse(() => __foldkitBrandViewResult((focusedIndex), "@foldkit/ui/keyboard.js#anonymous~3")))), "@foldkit/ui/keyboard.js#anonymous")), "@foldkit/ui/keyboard.js#findFirstEnabledIndex");
6
7
  export const keyToIndex = (nextKey, previousKey, itemCount, focusedIndex, isDisabled) => {
7
8
  const find = findFirstEnabledIndex(itemCount, focusedIndex, isDisabled);
8
- return (key) => M.value(key).pipe(M.when(nextKey, () => find(focusedIndex + 1, 1)), M.when(previousKey, () => find(focusedIndex - 1, -1)), M.whenOr('Home', 'PageUp', () => find(0, 1)), M.whenOr('End', 'PageDown', () => find(itemCount - 1, -1)), M.orElse(() => focusedIndex));
9
+ return __foldkitBrandViewResult(((key) => __foldkitBrandViewResult((M.value(key).pipe(M.when(nextKey, () => __foldkitBrandViewResult((find(focusedIndex + 1, 1)), "@foldkit/ui/keyboard.js#anonymous~5")), M.when(previousKey, () => __foldkitBrandViewResult((find(focusedIndex - 1, -1)), "@foldkit/ui/keyboard.js#anonymous~6")), M.whenOr('Home', 'PageUp', () => __foldkitBrandViewResult((find(0, 1)), "@foldkit/ui/keyboard.js#anonymous~7")), M.whenOr('End', 'PageDown', () => __foldkitBrandViewResult((find(itemCount - 1, -1)), "@foldkit/ui/keyboard.js#anonymous~8")), M.orElse(() => __foldkitBrandViewResult((focusedIndex), "@foldkit/ui/keyboard.js#anonymous~9")))), "@foldkit/ui/keyboard.js#anonymous~4")), "@foldkit/ui/keyboard.js#keyToIndex");
9
10
  };
@@ -1,3 +1,4 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
1
2
  import { Option, Schema as S } from 'effect';
2
3
  import { BaseModel, Closed, Opened, SelectedItem, Selected as SharedSelected, baseInit, makeUpdate, makeView, } from './shared.js';
3
4
  // MODEL
@@ -6,22 +7,22 @@ export const Model = S.Struct({
6
7
  ...BaseModel.fields,
7
8
  });
8
9
  /** Creates an initial multi-select listbox model from a config. Defaults to closed with no active item. */
9
- export const init = (config) => baseInit(config);
10
+ export const init = (config) => __foldkitBrandViewResult((baseInit(config)), "@foldkit/ui/listbox/multi.js#init");
10
11
  // UPDATE
11
12
  /** Processes a listbox message and returns the next model, commands, and optional OutMessage. Stays open on selection (multi-select behavior); emits a `Selected({ value })` OutMessage the parent folds by toggling the value's membership in the selection it owns. */
12
- export const update = makeUpdate((model, item) => [
13
+ export const update = makeUpdate((model, item) => __foldkitBrandViewResult(([
13
14
  model,
14
15
  [],
15
16
  Option.some(SharedSelected({ value: item })),
16
- ]);
17
+ ]), "@foldkit/ui/listbox/multi.js#anonymous"));
17
18
  /** Programmatically opens the listbox, updating the model and returning
18
19
  * focus and modal commands. Use this in domain-event handlers to open the listbox. */
19
- export const open = (model) => update(model, Opened({ maybeActiveItemIndex: Option.none() }));
20
+ export const open = (model) => __foldkitBrandViewResult((update(model, Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/listbox/multi.js#open");
20
21
  /** Programmatically closes the listbox, updating the model and returning
21
22
  * focus and modal commands. Use this in domain-event handlers to close the listbox. */
22
- export const close = (model) => update(model, Closed());
23
+ export const close = (model) => __foldkitBrandViewResult((update(model, Closed())), "@foldkit/ui/listbox/multi.js#close");
23
24
  /** Programmatically activates an item in the multi-select listbox. Emits `Selected({ value })`; the parent toggles the value's membership. */
24
- export const selectItem = (model, item) => update(model, SelectedItem({ item }));
25
+ export const selectItem = (model, item) => __foldkitBrandViewResult((update(model, SelectedItem({ item }))), "@foldkit/ui/listbox/multi.js#selectItem");
25
26
  const internalView = makeView({ ariaMultiSelectable: true });
26
27
  /** Pairs the multi-select listbox's `view` and `update` (and programmatic
27
28
  * helpers) behind a single Item-typed entry point. Same shape as
@@ -31,11 +32,11 @@ const internalView = makeView({ ariaMultiSelectable: true });
31
32
  export const create = () => {
32
33
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
33
34
  const typedUpdate = update;
34
- return {
35
+ return __foldkitBrandViewResult(({
35
36
  view: internalView(),
36
37
  update: typedUpdate,
37
- selectItem: (model, item) => typedUpdate(model, SelectedItem({ item })),
38
- open: model => typedUpdate(model, Opened({ maybeActiveItemIndex: Option.none() })),
39
- close: model => typedUpdate(model, Closed()),
40
- };
38
+ selectItem: (model, item) => __foldkitBrandViewResult((typedUpdate(model, SelectedItem({ item }))), "@foldkit/ui/listbox/multi.js#selectItem~2"),
39
+ open: model => __foldkitBrandViewResult((typedUpdate(model, Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/listbox/multi.js#open~2"),
40
+ close: model => __foldkitBrandViewResult((typedUpdate(model, Closed())), "@foldkit/ui/listbox/multi.js#close~2"),
41
+ }), "@foldkit/ui/listbox/multi.js#create");
41
42
  };