@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.
- package/dist/anchor.js +12 -11
- package/dist/animation/index.js +11 -10
- package/dist/animation/schema.js +3 -2
- package/dist/animation/update.js +26 -25
- package/dist/button/index.js +3 -2
- package/dist/calendar/index.js +159 -158
- package/dist/checkbox/index.js +9 -8
- package/dist/combobox/multi.js +20 -19
- package/dist/combobox/shared.js +169 -168
- package/dist/combobox/single.js +23 -22
- package/dist/datePicker/index.js +69 -68
- package/dist/dialog/index.js +52 -51
- package/dist/disclosure/index.js +11 -10
- package/dist/dragAndDrop/index.js +122 -121
- package/dist/fieldset/index.js +5 -4
- package/dist/fileDrop/index.js +23 -22
- package/dist/group.js +7 -6
- package/dist/input/index.js +4 -3
- package/dist/internal/optionExtensions.js +2 -1
- package/dist/internal/selectors.js +2 -1
- package/dist/keyboard.js +5 -4
- package/dist/listbox/multi.js +12 -11
- package/dist/listbox/shared.js +171 -170
- package/dist/listbox/single.js +13 -12
- package/dist/menu/index.js +167 -166
- package/dist/nav/index.js +7 -6
- package/dist/popover/index.js +87 -86
- package/dist/radioGroup/index.js +23 -22
- package/dist/select/index.js +4 -3
- package/dist/slider/index.js +72 -71
- package/dist/switch/index.js +6 -5
- package/dist/tabs/index.js +34 -33
- package/dist/test/apps/disabledButton.js +17 -16
- package/dist/textarea/index.js +4 -3
- package/dist/toast/index.js +19 -18
- package/dist/toast/schema.js +10 -9
- package/dist/toast/test.js +2 -1
- package/dist/toast/update.js +79 -78
- package/dist/tooltip/index.js +59 -58
- package/dist/typeahead.js +6 -5
- package/dist/virtualList/index.js +66 -65
- package/package.json +4 -3
package/dist/anchor.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Function, Schema as S } from 'effect';
|
|
2
3
|
import { autoUpdate, computePosition, flip, offset as floatingOffset, shift, size, } from '@floating-ui/dom';
|
|
3
4
|
/** Schema mirroring `@floating-ui/dom`'s `Placement` literal union: a side
|
|
@@ -37,7 +38,7 @@ const getOrCreatePortalRoot = (element) => {
|
|
|
37
38
|
const parent = inShadow ? root : document.body;
|
|
38
39
|
const existing = owner.getElementById(PORTAL_ROOT_ID);
|
|
39
40
|
if (existing) {
|
|
40
|
-
return existing;
|
|
41
|
+
return __foldkitBrandViewResult((existing), "@foldkit/ui/anchor.js#getOrCreatePortalRoot");
|
|
41
42
|
}
|
|
42
43
|
const portalRoot = document.createElement('div');
|
|
43
44
|
portalRoot.id = PORTAL_ROOT_ID;
|
|
@@ -48,7 +49,7 @@ const getOrCreatePortalRoot = (element) => {
|
|
|
48
49
|
// breaking click-outside detection. Prepending makes wrappers paint
|
|
49
50
|
// above the backdrop, while panels (z-10) still win via step 9.
|
|
50
51
|
parent.prepend(portalRoot);
|
|
51
|
-
return portalRoot;
|
|
52
|
+
return __foldkitBrandViewResult((portalRoot), "@foldkit/ui/anchor.js#getOrCreatePortalRoot");
|
|
52
53
|
};
|
|
53
54
|
/** Relocates an element into the shared `foldkit-portal-root` div within its
|
|
54
55
|
* containing root: the shadow root when mounted inside one, otherwise
|
|
@@ -59,7 +60,7 @@ const getOrCreatePortalRoot = (element) => {
|
|
|
59
60
|
* stashes the returned cleanup in the `Mount` result. */
|
|
60
61
|
export const portalToContainingRoot = (element) => {
|
|
61
62
|
getOrCreatePortalRoot(element).appendChild(element);
|
|
62
|
-
return () => {
|
|
63
|
+
return __foldkitBrandViewResult((() => {
|
|
63
64
|
try {
|
|
64
65
|
element.remove();
|
|
65
66
|
}
|
|
@@ -68,7 +69,7 @@ export const portalToContainingRoot = (element) => {
|
|
|
68
69
|
// so the remove() call can throw on a node that's already been removed.
|
|
69
70
|
// Swallow the error.
|
|
70
71
|
}
|
|
71
|
-
};
|
|
72
|
+
}), "@foldkit/ui/anchor.js#portalToContainingRoot");
|
|
72
73
|
};
|
|
73
74
|
/** Positions a floating element relative to its button using Floating UI, then
|
|
74
75
|
* returns a cleanup function. Designed to be called inside an `OnMount`
|
|
@@ -81,7 +82,7 @@ export const portalToContainingRoot = (element) => {
|
|
|
81
82
|
* requestAnimationFrame so the element is painted before focus fires.
|
|
82
83
|
* `focusSelector` optionally targets a descendant (e.g. a calendar grid
|
|
83
84
|
* inside a popover panel) instead of the panel itself. */
|
|
84
|
-
export const anchorSetup = (config) => (element) => {
|
|
85
|
+
export const anchorSetup = (config) => __foldkitBrandViewResult(((element) => {
|
|
85
86
|
// NOTE: resolve the button and any focus target within the element's own
|
|
86
87
|
// root, which is a shadow root when the app is hosted in one (e.g. the
|
|
87
88
|
// DevTools overlay isolates its UI in a shadow root). document.getElementById
|
|
@@ -92,7 +93,7 @@ export const anchorSetup = (config) => (element) => {
|
|
|
92
93
|
const owner = inShadow ? root : document;
|
|
93
94
|
const button = owner.getElementById(config.buttonId);
|
|
94
95
|
if (!(button instanceof HTMLElement) || !(element instanceof HTMLElement)) {
|
|
95
|
-
return Function.constVoid;
|
|
96
|
+
return __foldkitBrandViewResult((Function.constVoid), "@foldkit/ui/anchor.js#anonymous~2");
|
|
96
97
|
}
|
|
97
98
|
const isPortal = config.anchor.portal ?? true;
|
|
98
99
|
const portalCleanup = isPortal ? portalToContainingRoot(element) : undefined;
|
|
@@ -154,16 +155,16 @@ export const anchorSetup = (config) => (element) => {
|
|
|
154
155
|
}
|
|
155
156
|
};
|
|
156
157
|
element.addEventListener('keydown', handleTabKey);
|
|
157
|
-
return () => {
|
|
158
|
+
return __foldkitBrandViewResult((() => {
|
|
158
159
|
floatingCleanup();
|
|
159
160
|
element.removeEventListener('keydown', handleTabKey);
|
|
160
161
|
portalCleanup?.();
|
|
161
|
-
};
|
|
162
|
+
}), "@foldkit/ui/anchor.js#anonymous~2");
|
|
162
163
|
}
|
|
163
164
|
else {
|
|
164
|
-
return () => {
|
|
165
|
+
return __foldkitBrandViewResult((() => {
|
|
165
166
|
floatingCleanup();
|
|
166
167
|
portalCleanup?.();
|
|
167
|
-
};
|
|
168
|
+
}), "@foldkit/ui/anchor.js#anonymous~2");
|
|
168
169
|
}
|
|
169
|
-
};
|
|
170
|
+
}), "@foldkit/ui/anchor.js#anchorSetup");
|
package/dist/animation/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Match as M } from 'effect';
|
|
2
3
|
import { html, } from 'foldkit/html';
|
|
3
4
|
import { defineView } from 'foldkit/submodel';
|
|
@@ -20,26 +21,26 @@ export const view = defineView((model, viewInputs) => {
|
|
|
20
21
|
const { content, className, attributes = [], element = 'div', animateSize = false, } = viewInputs;
|
|
21
22
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
22
23
|
const isVisible = isShowing || isLeaving;
|
|
23
|
-
const transitionAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => [
|
|
24
|
+
const transitionAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
24
25
|
h.DataAttribute('closed', ''),
|
|
25
26
|
h.DataAttribute('enter', ''),
|
|
26
27
|
h.DataAttribute('transition', ''),
|
|
27
|
-
]), M.when('EnterAnimating', () => [
|
|
28
|
+
]), "@foldkit/ui/animation/index.js#anonymous~2")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
28
29
|
h.DataAttribute('enter', ''),
|
|
29
30
|
h.DataAttribute('transition', ''),
|
|
30
|
-
]), M.when('LeaveStart', () => [
|
|
31
|
+
]), "@foldkit/ui/animation/index.js#anonymous~3")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
31
32
|
h.DataAttribute('leave', ''),
|
|
32
33
|
h.DataAttribute('transition', ''),
|
|
33
|
-
]), M.when('LeaveAnimating', () => [
|
|
34
|
+
]), "@foldkit/ui/animation/index.js#anonymous~4")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
34
35
|
h.DataAttribute('closed', ''),
|
|
35
36
|
h.DataAttribute('leave', ''),
|
|
36
37
|
h.DataAttribute('transition', ''),
|
|
37
|
-
]), M.orElse(() => []));
|
|
38
|
+
]), "@foldkit/ui/animation/index.js#anonymous~5")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/animation/index.js#anonymous~6")));
|
|
38
39
|
if (animateSize) {
|
|
39
40
|
const isClosed = transitionState === 'EnterStart' ||
|
|
40
41
|
transitionState === 'LeaveAnimating' ||
|
|
41
42
|
!isVisible;
|
|
42
|
-
return h.div([
|
|
43
|
+
return __foldkitBrandViewResult((h.div([
|
|
43
44
|
h.Style({
|
|
44
45
|
display: 'grid',
|
|
45
46
|
gridTemplateRows: isClosed ? '0fr' : '1fr',
|
|
@@ -61,15 +62,15 @@ export const view = defineView((model, viewInputs) => {
|
|
|
61
62
|
...attributes,
|
|
62
63
|
], [content]),
|
|
63
64
|
]),
|
|
64
|
-
]);
|
|
65
|
+
])), "@foldkit/ui/animation/index.js#anonymous");
|
|
65
66
|
}
|
|
66
67
|
if (!isVisible) {
|
|
67
|
-
return h.empty;
|
|
68
|
+
return __foldkitBrandViewResult((h.empty), "@foldkit/ui/animation/index.js#anonymous");
|
|
68
69
|
}
|
|
69
|
-
return h.keyed(element)(id, [
|
|
70
|
+
return __foldkitBrandViewResult((h.keyed(element)(id, [
|
|
70
71
|
h.Id(id),
|
|
71
72
|
...transitionAttributes,
|
|
72
73
|
...(className ? [h.Class(className)] : []),
|
|
73
74
|
...attributes,
|
|
74
|
-
], [content]);
|
|
75
|
+
], [content])), "@foldkit/ui/animation/index.js#anonymous");
|
|
75
76
|
});
|
package/dist/animation/schema.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Schema as S } from 'effect';
|
|
2
3
|
import { m } from 'foldkit/message';
|
|
3
4
|
// TRANSITION STATE
|
|
@@ -34,8 +35,8 @@ export const StartedLeaveAnimating = m('StartedLeaveAnimating');
|
|
|
34
35
|
export const TransitionedOut = m('TransitionedOut');
|
|
35
36
|
export const OutMessage = S.Union([StartedLeaveAnimating, TransitionedOut]);
|
|
36
37
|
/** Creates an initial animation model from a config. Defaults to hidden. */
|
|
37
|
-
export const init = (config) => ({
|
|
38
|
+
export const init = (config) => (__foldkitBrandViewResult(({
|
|
38
39
|
id: config.id,
|
|
39
40
|
isShowing: config.isShowing ?? false,
|
|
40
41
|
transitionState: 'Idle',
|
|
41
|
-
});
|
|
42
|
+
}), "@foldkit/ui/animation/schema.js#init"));
|
package/dist/animation/update.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Effect, Match as M, Option, Schema as S } from 'effect';
|
|
2
3
|
import * as Command from 'foldkit/command';
|
|
3
4
|
import * as Dom from 'foldkit/dom';
|
|
@@ -6,63 +7,63 @@ import { evo } from 'foldkit/struct';
|
|
|
6
7
|
import { idSelector } from '../internal/selectors.js';
|
|
7
8
|
import { AdvancedAnimationFrame, EndedAnimation, StartedLeaveAnimating, TransitionedOut, } from './schema.js';
|
|
8
9
|
// UPDATE
|
|
9
|
-
const elementSelector = (id) => idSelector(id);
|
|
10
|
+
const elementSelector = (id) => __foldkitBrandViewResult((idSelector(id)), "@foldkit/ui/animation/update.js#elementSelector");
|
|
10
11
|
const withUpdateReturn = M.withReturnType();
|
|
11
12
|
/** Advances the enter/leave lifecycle by waiting a double-rAF. */
|
|
12
13
|
export const RequestFrame = Command.define('RequestFrame', AdvancedAnimationFrame)(Render.afterPaint.pipe(Effect.as(AdvancedAnimationFrame())));
|
|
13
14
|
/** Waits for all CSS animations on the element to settle. Covers both CSS transitions and CSS keyframe animations. */
|
|
14
|
-
export const WaitForAnimationSettled = Command.define('WaitForAnimationSettled', { id: S.String }, EndedAnimation)(({ id }) => Dom.waitForAnimationSettled(elementSelector(id)).pipe(Effect.as(EndedAnimation())));
|
|
15
|
+
export const WaitForAnimationSettled = Command.define('WaitForAnimationSettled', { id: S.String }, EndedAnimation)(({ id }) => __foldkitBrandViewResult((Dom.waitForAnimationSettled(elementSelector(id)).pipe(Effect.as(EndedAnimation()))), "@foldkit/ui/animation/update.js#anonymous"));
|
|
15
16
|
/** Processes an animation message and returns the next model, commands, and optional OutMessage. */
|
|
16
17
|
export const update = (model, message) => {
|
|
17
18
|
const maybeNextFrame = RequestFrame();
|
|
18
|
-
return M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
19
|
+
return __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
19
20
|
Showed: () => {
|
|
20
21
|
if (model.isShowing) {
|
|
21
|
-
return [model, [], Option.none()];
|
|
22
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/animation/update.js#Showed");
|
|
22
23
|
}
|
|
23
|
-
return [
|
|
24
|
+
return __foldkitBrandViewResult(([
|
|
24
25
|
evo(model, {
|
|
25
|
-
isShowing: () => true,
|
|
26
|
-
transitionState: () => 'EnterStart',
|
|
26
|
+
isShowing: () => __foldkitBrandViewResult((true), "@foldkit/ui/animation/update.js#isShowing"),
|
|
27
|
+
transitionState: () => __foldkitBrandViewResult(('EnterStart'), "@foldkit/ui/animation/update.js#transitionState"),
|
|
27
28
|
}),
|
|
28
29
|
[maybeNextFrame],
|
|
29
30
|
Option.none(),
|
|
30
|
-
];
|
|
31
|
+
]), "@foldkit/ui/animation/update.js#Showed");
|
|
31
32
|
},
|
|
32
33
|
Hid: () => {
|
|
33
34
|
const isLeaving = model.transitionState === 'LeaveStart' ||
|
|
34
35
|
model.transitionState === 'LeaveAnimating';
|
|
35
36
|
if (isLeaving || !model.isShowing) {
|
|
36
|
-
return [model, [], Option.none()];
|
|
37
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/animation/update.js#Hid");
|
|
37
38
|
}
|
|
38
|
-
return [
|
|
39
|
+
return __foldkitBrandViewResult(([
|
|
39
40
|
evo(model, {
|
|
40
|
-
isShowing: () => false,
|
|
41
|
-
transitionState: () => 'LeaveStart',
|
|
41
|
+
isShowing: () => __foldkitBrandViewResult((false), "@foldkit/ui/animation/update.js#isShowing~2"),
|
|
42
|
+
transitionState: () => __foldkitBrandViewResult(('LeaveStart'), "@foldkit/ui/animation/update.js#transitionState~2"),
|
|
42
43
|
}),
|
|
43
44
|
[maybeNextFrame],
|
|
44
45
|
Option.none(),
|
|
45
|
-
];
|
|
46
|
+
]), "@foldkit/ui/animation/update.js#Hid");
|
|
46
47
|
},
|
|
47
|
-
AdvancedAnimationFrame: () => M.value(model.transitionState).pipe(withUpdateReturn, M.when('EnterStart', () => [
|
|
48
|
-
evo(model, { transitionState: () => 'EnterAnimating' }),
|
|
48
|
+
AdvancedAnimationFrame: () => __foldkitBrandViewResult((M.value(model.transitionState).pipe(withUpdateReturn, M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
49
|
+
evo(model, { transitionState: () => __foldkitBrandViewResult(('EnterAnimating'), "@foldkit/ui/animation/update.js#transitionState~3") }),
|
|
49
50
|
[WaitForAnimationSettled({ id: model.id })],
|
|
50
51
|
Option.none(),
|
|
51
|
-
]), M.when('LeaveStart', () => [
|
|
52
|
-
evo(model, { transitionState: () => 'LeaveAnimating' }),
|
|
52
|
+
]), "@foldkit/ui/animation/update.js#anonymous~2")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
53
|
+
evo(model, { transitionState: () => __foldkitBrandViewResult(('LeaveAnimating'), "@foldkit/ui/animation/update.js#transitionState~4") }),
|
|
53
54
|
[],
|
|
54
55
|
Option.some(StartedLeaveAnimating()),
|
|
55
|
-
]), M.orElse(() => [model, [], Option.none()])),
|
|
56
|
-
EndedAnimation: () => M.value(model.transitionState).pipe(withUpdateReturn, M.when('EnterAnimating', () => [
|
|
57
|
-
evo(model, { transitionState: () => 'Idle' }),
|
|
56
|
+
]), "@foldkit/ui/animation/update.js#anonymous~3")), M.orElse(() => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/animation/update.js#anonymous~4")))), "@foldkit/ui/animation/update.js#AdvancedAnimationFrame"),
|
|
57
|
+
EndedAnimation: () => __foldkitBrandViewResult((M.value(model.transitionState).pipe(withUpdateReturn, M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
58
|
+
evo(model, { transitionState: () => __foldkitBrandViewResult(('Idle'), "@foldkit/ui/animation/update.js#transitionState~5") }),
|
|
58
59
|
[],
|
|
59
60
|
Option.none(),
|
|
60
|
-
]), M.when('LeaveAnimating', () => [
|
|
61
|
-
evo(model, { transitionState: () => 'Idle' }),
|
|
61
|
+
]), "@foldkit/ui/animation/update.js#anonymous~5")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
62
|
+
evo(model, { transitionState: () => __foldkitBrandViewResult(('Idle'), "@foldkit/ui/animation/update.js#transitionState~6") }),
|
|
62
63
|
[],
|
|
63
64
|
Option.some(TransitionedOut()),
|
|
64
|
-
]), M.orElse(() => [model, [], Option.none()])),
|
|
65
|
-
}));
|
|
65
|
+
]), "@foldkit/ui/animation/update.js#anonymous~6")), M.orElse(() => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/animation/update.js#anonymous~7")))), "@foldkit/ui/animation/update.js#EndedAnimation"),
|
|
66
|
+
}))), "@foldkit/ui/animation/update.js#update");
|
|
66
67
|
};
|
|
67
68
|
/** Creates the standard leave-phase command that waits for CSS animations on the element to settle. Use this when handling the `StartedLeaveAnimating` OutMessage for components that don't need custom leave behavior. */
|
|
68
|
-
export const defaultLeaveCommand = (model) => WaitForAnimationSettled({ id: model.id });
|
|
69
|
+
export const defaultLeaveCommand = (model) => __foldkitBrandViewResult((WaitForAnimationSettled({ id: model.id })), "@foldkit/ui/animation/update.js#defaultLeaveCommand");
|
package/dist/button/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Predicate } from 'effect';
|
|
2
3
|
import { html } from 'foldkit/html';
|
|
3
4
|
/** Renders an accessible button by building attribute groups and delegating layout to the consumer's `toView` callback. */
|
|
@@ -16,7 +17,7 @@ export const view = (config) => {
|
|
|
16
17
|
...clickAttributes,
|
|
17
18
|
...autofocusAttributes,
|
|
18
19
|
];
|
|
19
|
-
return toView({
|
|
20
|
+
return __foldkitBrandViewResult((toView({
|
|
20
21
|
button: buttonAttributes,
|
|
21
|
-
});
|
|
22
|
+
})), "@foldkit/ui/button/index.js#view");
|
|
22
23
|
};
|