@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/nav/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Array, Option } from 'effect';
|
|
2
3
|
import { childAttributes, html, } from 'foldkit/html';
|
|
3
4
|
// VIEW
|
|
@@ -23,21 +24,21 @@ export const view = (viewInputs) => {
|
|
|
23
24
|
const { items, ariaLabel, toHref, isItemCurrent, toView } = viewInputs;
|
|
24
25
|
const itemInfos = Array.map(items, (value, index) => {
|
|
25
26
|
const isCurrent = isItemCurrent(value, index);
|
|
26
|
-
const maybeCurrentAttributes = Option.liftPredicate([h.AriaCurrent(ARIA_CURRENT_PAGE), h.DataAttribute('current', '')], () => isCurrent);
|
|
27
|
+
const maybeCurrentAttributes = Option.liftPredicate([h.AriaCurrent(ARIA_CURRENT_PAGE), h.DataAttribute('current', '')], () => __foldkitBrandViewResult((isCurrent), "@foldkit/ui/nav/index.js#anonymous~2"));
|
|
27
28
|
const linkAttributes = [
|
|
28
29
|
h.Href(toHref(value, index)),
|
|
29
|
-
...Option.getOrElse(maybeCurrentAttributes, () => []),
|
|
30
|
+
...Option.getOrElse(maybeCurrentAttributes, () => __foldkitBrandViewResult(([]), "@foldkit/ui/nav/index.js#anonymous~3")),
|
|
30
31
|
];
|
|
31
|
-
return {
|
|
32
|
+
return __foldkitBrandViewResult(({
|
|
32
33
|
value,
|
|
33
34
|
index,
|
|
34
35
|
isCurrent,
|
|
35
36
|
link: childAttributes(linkAttributes),
|
|
36
|
-
};
|
|
37
|
+
}), "@foldkit/ui/nav/index.js#anonymous");
|
|
37
38
|
});
|
|
38
39
|
const navAttributes = [h.AriaLabel(ariaLabel)];
|
|
39
|
-
return toView({
|
|
40
|
+
return __foldkitBrandViewResult((toView({
|
|
40
41
|
nav: childAttributes(navAttributes),
|
|
41
42
|
items: itemInfos,
|
|
42
|
-
});
|
|
43
|
+
})), "@foldkit/ui/nav/index.js#view");
|
|
43
44
|
};
|
package/dist/popover/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Array, Effect, Equal, Match as M, Option, Predicate, Schema as S, } from 'effect';
|
|
2
3
|
import * as Command from 'foldkit/command';
|
|
3
4
|
import * as Dom from 'foldkit/dom';
|
|
@@ -89,7 +90,7 @@ export const OutMessage = S.Union([Opened, Closed]);
|
|
|
89
90
|
// INIT
|
|
90
91
|
const LEFT_MOUSE_BUTTON = 0;
|
|
91
92
|
/** Creates an initial popover model from a config. Defaults to closed. */
|
|
92
|
-
export const init = (config) => ({
|
|
93
|
+
export const init = (config) => (__foldkitBrandViewResult(({
|
|
93
94
|
id: config.id,
|
|
94
95
|
isOpen: false,
|
|
95
96
|
isAnimated: config.isAnimated ?? false,
|
|
@@ -97,51 +98,51 @@ export const init = (config) => ({
|
|
|
97
98
|
contentFocus: config.contentFocus ?? false,
|
|
98
99
|
animation: animationInit({ id: `${config.id}-panel` }),
|
|
99
100
|
maybeLastButtonPointerType: Option.none(),
|
|
100
|
-
});
|
|
101
|
+
}), "@foldkit/ui/popover/index.js#init"));
|
|
101
102
|
// UPDATE
|
|
102
|
-
const closedModel = (model) => evo(model, {
|
|
103
|
-
isOpen: () => false,
|
|
104
|
-
maybeLastButtonPointerType: () => Option.none(),
|
|
105
|
-
});
|
|
106
|
-
const buttonSelector = (id) => idSelector(`${id}-button`);
|
|
107
|
-
const panelSelector = (id) => idSelector(`${id}-panel`);
|
|
103
|
+
const closedModel = (model) => __foldkitBrandViewResult((evo(model, {
|
|
104
|
+
isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/popover/index.js#isOpen"),
|
|
105
|
+
maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType"),
|
|
106
|
+
})), "@foldkit/ui/popover/index.js#closedModel");
|
|
107
|
+
const buttonSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-button`)), "@foldkit/ui/popover/index.js#buttonSelector");
|
|
108
|
+
const panelSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-panel`)), "@foldkit/ui/popover/index.js#panelSelector");
|
|
108
109
|
/** Returns the bare DOM id of the popover trigger button, derived from the
|
|
109
110
|
* popover's base id. Use this to associate an external label with the
|
|
110
111
|
* trigger via a native `<label for={Popover.buttonId(id)}>` or an
|
|
111
112
|
* `aria-labelledby` reference. */
|
|
112
|
-
export const buttonId = (id) => `${id}-button
|
|
113
|
+
export const buttonId = (id) => __foldkitBrandViewResult((`${id}-button`), "@foldkit/ui/popover/index.js#buttonId");
|
|
113
114
|
const withUpdateReturn = M.withReturnType();
|
|
114
115
|
/** Prevents page scrolling while the popover is open in modal mode. */
|
|
115
116
|
export const LockScroll = Command.define('LockScroll', CompletedLockScroll)(Dom.lockScroll.pipe(Effect.as(CompletedLockScroll())));
|
|
116
117
|
/** Re-enables page scrolling after the popover closes. */
|
|
117
118
|
export const UnlockScroll = Command.define('UnlockScroll', CompletedUnlockScroll)(Dom.unlockScroll.pipe(Effect.as(CompletedUnlockScroll())));
|
|
118
119
|
/** Marks all elements outside the popover as inert for modal behavior. */
|
|
119
|
-
export const InertOthers = Command.define('InertOthers', { id: S.String }, CompletedInertOthers)(({ id }) => Dom.inertOthers(id, [buttonSelector(id), panelSelector(id)]).pipe(Effect.as(CompletedInertOthers())));
|
|
120
|
+
export const InertOthers = Command.define('InertOthers', { id: S.String }, CompletedInertOthers)(({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [buttonSelector(id), panelSelector(id)]).pipe(Effect.as(CompletedInertOthers()))), "@foldkit/ui/popover/index.js#anonymous"));
|
|
120
121
|
/** Removes the inert attribute from elements outside the popover. */
|
|
121
|
-
export const RestoreInert = Command.define('RestoreInert', { id: S.String }, CompletedRestoreInert)(({ id }) => Dom.restoreInert(id).pipe(Effect.as(CompletedRestoreInert())));
|
|
122
|
+
export const RestoreInert = Command.define('RestoreInert', { id: S.String }, CompletedRestoreInert)(({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(CompletedRestoreInert()))), "@foldkit/ui/popover/index.js#anonymous~2"));
|
|
122
123
|
/** Moves focus to the popover panel after opening. */
|
|
123
|
-
export const FocusPanel = Command.define('FocusPanel', { id: S.String }, CompletedFocusPanel)(({ id }) => Dom.focus(panelSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusPanel())));
|
|
124
|
+
export const FocusPanel = Command.define('FocusPanel', { id: S.String }, CompletedFocusPanel)(({ id }) => __foldkitBrandViewResult((Dom.focus(panelSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusPanel()))), "@foldkit/ui/popover/index.js#anonymous~3"));
|
|
124
125
|
/** Moves focus back to the popover button after closing. */
|
|
125
|
-
export const FocusButton = Command.define('FocusButton', { id: S.String }, CompletedFocusButton)(({ id }) => Dom.focus(buttonSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton())));
|
|
126
|
+
export const FocusButton = Command.define('FocusButton', { id: S.String }, CompletedFocusButton)(({ id }) => __foldkitBrandViewResult((Dom.focus(buttonSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton()))), "@foldkit/ui/popover/index.js#anonymous~4"));
|
|
126
127
|
/** Detects whether the popover button moved or the leave animation ended. Whichever comes first; both outcomes signal the Animation submodel that leave is complete. */
|
|
127
|
-
export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnimationEnd', { id: S.String }, GotAnimationMessage)(({ id }) => Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))), Dom.waitForAnimationSettled(panelSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() })))));
|
|
128
|
+
export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnimationEnd', { id: S.String }, GotAnimationMessage)(({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))), Dom.waitForAnimationSettled(panelSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))))), "@foldkit/ui/popover/index.js#anonymous~5"));
|
|
128
129
|
const delegateToAnimation = (model, animationMessage) => {
|
|
129
130
|
const [nextAnimation, animationCommands, maybeOutMessage] = animationUpdate(model.animation, animationMessage);
|
|
130
|
-
const mappedCommands = Command.mapMessages(animationCommands, message => GotAnimationMessage({ message }));
|
|
131
|
+
const mappedCommands = Command.mapMessages(animationCommands, message => __foldkitBrandViewResult((GotAnimationMessage({ message })), "@foldkit/ui/popover/index.js#anonymous~6"));
|
|
131
132
|
const additionalCommands = Option.match(maybeOutMessage, {
|
|
132
|
-
onNone: () => [],
|
|
133
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/popover/index.js#onNone"),
|
|
133
134
|
onSome: M.type().pipe(M.tagsExhaustive({
|
|
134
|
-
StartedLeaveAnimating: () => [
|
|
135
|
+
StartedLeaveAnimating: () => __foldkitBrandViewResult(([
|
|
135
136
|
DetectMovementOrAnimationEnd({ id: model.id }),
|
|
136
|
-
],
|
|
137
|
-
TransitionedOut: () => [],
|
|
137
|
+
]), "@foldkit/ui/popover/index.js#StartedLeaveAnimating"),
|
|
138
|
+
TransitionedOut: () => __foldkitBrandViewResult(([]), "@foldkit/ui/popover/index.js#TransitionedOut"),
|
|
138
139
|
})),
|
|
139
140
|
});
|
|
140
|
-
return [
|
|
141
|
-
evo(model, { animation: () => nextAnimation }),
|
|
141
|
+
return __foldkitBrandViewResult(([
|
|
142
|
+
evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/popover/index.js#animation") }),
|
|
142
143
|
[...mappedCommands, ...additionalCommands],
|
|
143
144
|
Option.none(),
|
|
144
|
-
];
|
|
145
|
+
]), "@foldkit/ui/popover/index.js#delegateToAnimation");
|
|
145
146
|
};
|
|
146
147
|
/** Processes a popover message and returns the next model, commands, and optional OutMessage. */
|
|
147
148
|
export const update = (model, message) => {
|
|
@@ -162,77 +163,77 @@ export const update = (model, message) => {
|
|
|
162
163
|
const openPopover = (baseModel) => {
|
|
163
164
|
if (model.isAnimated) {
|
|
164
165
|
const [nextModel, animationCommands] = delegateToAnimation(baseModel, AnimationShowed());
|
|
165
|
-
return [
|
|
166
|
-
evo(nextModel, { isOpen: () => true }),
|
|
166
|
+
return __foldkitBrandViewResult(([
|
|
167
|
+
evo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/popover/index.js#isOpen~2") }),
|
|
167
168
|
[...openCommands, ...animationCommands],
|
|
168
169
|
Option.some(Opened()),
|
|
169
|
-
];
|
|
170
|
+
]), "@foldkit/ui/popover/index.js#openPopover");
|
|
170
171
|
}
|
|
171
|
-
return [
|
|
172
|
-
evo(baseModel, { isOpen: () => true }),
|
|
172
|
+
return __foldkitBrandViewResult(([
|
|
173
|
+
evo(baseModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/popover/index.js#isOpen~3") }),
|
|
173
174
|
openCommands,
|
|
174
175
|
Option.some(Opened()),
|
|
175
|
-
];
|
|
176
|
+
]), "@foldkit/ui/popover/index.js#openPopover");
|
|
176
177
|
};
|
|
177
178
|
const closePopover = (baseModel, commands) => {
|
|
178
179
|
if (!baseModel.isOpen) {
|
|
179
|
-
return [baseModel, commands, Option.none()];
|
|
180
|
+
return __foldkitBrandViewResult(([baseModel, commands, Option.none()]), "@foldkit/ui/popover/index.js#closePopover");
|
|
180
181
|
}
|
|
181
182
|
const closed = closedModel(baseModel);
|
|
182
183
|
if (model.isAnimated) {
|
|
183
184
|
const [nextModel, animationCommands] = delegateToAnimation(closed, AnimationHid());
|
|
184
|
-
return [
|
|
185
|
+
return __foldkitBrandViewResult(([
|
|
185
186
|
nextModel,
|
|
186
187
|
[...commands, ...animationCommands],
|
|
187
188
|
Option.some(Closed()),
|
|
188
|
-
];
|
|
189
|
+
]), "@foldkit/ui/popover/index.js#closePopover");
|
|
189
190
|
}
|
|
190
|
-
return [closed, commands, Option.some(Closed())];
|
|
191
|
+
return __foldkitBrandViewResult(([closed, commands, Option.some(Closed())]), "@foldkit/ui/popover/index.js#closePopover");
|
|
191
192
|
};
|
|
192
|
-
return M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
193
|
-
RequestedOpen: () => openPopover(model),
|
|
194
|
-
RequestedClose: () => closePopover(model, closeWithFocusCommands),
|
|
193
|
+
return __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
194
|
+
RequestedOpen: () => __foldkitBrandViewResult((openPopover(model)), "@foldkit/ui/popover/index.js#RequestedOpen"),
|
|
195
|
+
RequestedClose: () => __foldkitBrandViewResult((closePopover(model, closeWithFocusCommands)), "@foldkit/ui/popover/index.js#RequestedClose"),
|
|
195
196
|
BlurredPanel: () => {
|
|
196
197
|
if (Option.exists(model.maybeLastButtonPointerType, Equal.equals('mouse'))) {
|
|
197
|
-
return [model, [], Option.none()];
|
|
198
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#BlurredPanel");
|
|
198
199
|
}
|
|
199
|
-
return closePopover(model, closeWithoutFocusCommands);
|
|
200
|
+
return __foldkitBrandViewResult((closePopover(model, closeWithoutFocusCommands)), "@foldkit/ui/popover/index.js#BlurredPanel");
|
|
200
201
|
},
|
|
201
202
|
PressedPointerOnButton: ({ pointerType, button }) => {
|
|
202
203
|
const withPointerType = evo(model, {
|
|
203
|
-
maybeLastButtonPointerType: () => Option.some(pointerType),
|
|
204
|
+
maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType~2"),
|
|
204
205
|
});
|
|
205
206
|
if (pointerType !== 'mouse' || button !== LEFT_MOUSE_BUTTON) {
|
|
206
|
-
return [withPointerType, [], Option.none()];
|
|
207
|
+
return __foldkitBrandViewResult(([withPointerType, [], Option.none()]), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
|
|
207
208
|
}
|
|
208
209
|
if (model.isOpen) {
|
|
209
210
|
const [closed, commands, maybeOutMessage] = closePopover(withPointerType, closeWithFocusCommands);
|
|
210
|
-
return [
|
|
211
|
+
return __foldkitBrandViewResult(([
|
|
211
212
|
evo(closed, {
|
|
212
|
-
maybeLastButtonPointerType: () => Option.some(pointerType),
|
|
213
|
+
maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType~3"),
|
|
213
214
|
}),
|
|
214
215
|
commands,
|
|
215
216
|
maybeOutMessage,
|
|
216
|
-
];
|
|
217
|
+
]), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
|
|
217
218
|
}
|
|
218
|
-
return openPopover(withPointerType);
|
|
219
|
+
return __foldkitBrandViewResult((openPopover(withPointerType)), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
|
|
219
220
|
},
|
|
220
|
-
GotAnimationMessage: ({ message: animationMessage }) => delegateToAnimation(model, animationMessage),
|
|
221
|
-
CompletedFocusPanel: () => [model, [], Option.none()],
|
|
222
|
-
CompletedFocusButton: () => [model, [], Option.none()],
|
|
223
|
-
CompletedLockScroll: () => [model, [], Option.none()],
|
|
224
|
-
CompletedUnlockScroll: () => [model, [], Option.none()],
|
|
225
|
-
CompletedInertOthers: () => [model, [], Option.none()],
|
|
226
|
-
CompletedRestoreInert: () => [model, [], Option.none()],
|
|
227
|
-
IgnoredMouseClick: () => [
|
|
228
|
-
evo(model, { maybeLastButtonPointerType: () => Option.none() }),
|
|
221
|
+
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((delegateToAnimation(model, animationMessage)), "@foldkit/ui/popover/index.js#GotAnimationMessage"),
|
|
222
|
+
CompletedFocusPanel: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedFocusPanel"),
|
|
223
|
+
CompletedFocusButton: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedFocusButton"),
|
|
224
|
+
CompletedLockScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedLockScroll"),
|
|
225
|
+
CompletedUnlockScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedUnlockScroll"),
|
|
226
|
+
CompletedInertOthers: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedInertOthers"),
|
|
227
|
+
CompletedRestoreInert: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedRestoreInert"),
|
|
228
|
+
IgnoredMouseClick: () => __foldkitBrandViewResult(([
|
|
229
|
+
evo(model, { maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType~4") }),
|
|
229
230
|
[],
|
|
230
231
|
Option.none(),
|
|
231
|
-
],
|
|
232
|
-
SuppressedSpaceScroll: () => [model, [], Option.none()],
|
|
233
|
-
CompletedAnchorPopover: () => [model, [], Option.none()],
|
|
234
|
-
CompletedPortalPopoverBackdrop: () => [model, [], Option.none()],
|
|
235
|
-
}));
|
|
232
|
+
]), "@foldkit/ui/popover/index.js#IgnoredMouseClick"),
|
|
233
|
+
SuppressedSpaceScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#SuppressedSpaceScroll"),
|
|
234
|
+
CompletedAnchorPopover: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedAnchorPopover"),
|
|
235
|
+
CompletedPortalPopoverBackdrop: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedPortalPopoverBackdrop"),
|
|
236
|
+
}))), "@foldkit/ui/popover/index.js#update");
|
|
236
237
|
};
|
|
237
238
|
/** The anchor-positioning Mount this Popover renders on its panel. Exposed so
|
|
238
239
|
* Scene tests can call `Scene.Mount.resolve(AnchorPopover, CompletedAnchorPopover())`
|
|
@@ -241,29 +242,29 @@ export const AnchorPopover = Mount.define('AnchorPopover', {
|
|
|
241
242
|
buttonId: S.String,
|
|
242
243
|
anchor: AnchorConfig,
|
|
243
244
|
focusSelector: S.optional(S.String),
|
|
244
|
-
}, CompletedAnchorPopover)(({ buttonId, anchor, focusSelector }) => element => Effect.gen(function* () {
|
|
245
|
-
yield* Effect.acquireRelease(Effect.sync(() => anchorSetup({
|
|
245
|
+
}, CompletedAnchorPopover)(({ buttonId, anchor, focusSelector }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
246
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup({
|
|
246
247
|
buttonId,
|
|
247
248
|
anchor,
|
|
248
249
|
interceptTab: false,
|
|
249
250
|
focusAfterPosition: true,
|
|
250
251
|
...(focusSelector !== undefined && { focusSelector }),
|
|
251
|
-
})(element)), cleanup => Effect.sync(cleanup));
|
|
252
|
-
return CompletedAnchorPopover();
|
|
253
|
-
}));
|
|
252
|
+
})(element)), "@foldkit/ui/popover/index.js#anonymous~10")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~11"));
|
|
253
|
+
return __foldkitBrandViewResult((CompletedAnchorPopover()), "@foldkit/ui/popover/index.js#anonymous~9");
|
|
254
|
+
})), "@foldkit/ui/popover/index.js#anonymous~8")), "@foldkit/ui/popover/index.js#anonymous~7"));
|
|
254
255
|
/** The backdrop-portaling Mount this Popover renders. Exposed so Scene tests can
|
|
255
256
|
* call `Scene.Mount.resolve(PortalPopoverBackdrop, CompletedPortalPopoverBackdrop())` to
|
|
256
257
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
257
|
-
export const PortalPopoverBackdrop = Mount.define('PortalPopoverBackdrop', CompletedPortalPopoverBackdrop)(element => Effect.gen(function* () {
|
|
258
|
-
yield* Effect.acquireRelease(Effect.sync(() => portalToContainingRoot(element)), cleanup => Effect.sync(cleanup));
|
|
259
|
-
return CompletedPortalPopoverBackdrop();
|
|
260
|
-
}));
|
|
258
|
+
export const PortalPopoverBackdrop = Mount.define('PortalPopoverBackdrop', CompletedPortalPopoverBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
259
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/popover/index.js#anonymous~14")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~15"));
|
|
260
|
+
return __foldkitBrandViewResult((CompletedPortalPopoverBackdrop()), "@foldkit/ui/popover/index.js#anonymous~13");
|
|
261
|
+
})), "@foldkit/ui/popover/index.js#anonymous~12"));
|
|
261
262
|
/** Programmatically opens the popover, updating the model and returning
|
|
262
263
|
* focus and modal commands plus an `Opened` OutMessage. */
|
|
263
|
-
export const open = (model) => update(model, RequestedOpen());
|
|
264
|
+
export const open = (model) => __foldkitBrandViewResult((update(model, RequestedOpen())), "@foldkit/ui/popover/index.js#open");
|
|
264
265
|
/** Programmatically closes the popover, updating the model and returning
|
|
265
266
|
* focus and modal commands plus a `Closed` OutMessage when it was open. */
|
|
266
|
-
export const close = (model) => update(model, RequestedClose());
|
|
267
|
+
export const close = (model) => __foldkitBrandViewResult((update(model, RequestedClose())), "@foldkit/ui/popover/index.js#close");
|
|
267
268
|
/** Renders a headless popover with a trigger button and a floating panel. */
|
|
268
269
|
export const view = defineView((model, viewInputs) => {
|
|
269
270
|
const h = html();
|
|
@@ -271,46 +272,46 @@ export const view = defineView((model, viewInputs) => {
|
|
|
271
272
|
const { anchor, toView, isDisabled, focusSelector, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
272
273
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
273
274
|
const isVisible = isOpen || isLeaving;
|
|
274
|
-
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => [
|
|
275
|
+
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
275
276
|
h.DataAttribute('closed', ''),
|
|
276
277
|
h.DataAttribute('enter', ''),
|
|
277
278
|
h.DataAttribute('transition', ''),
|
|
278
|
-
]), M.when('EnterAnimating', () => [
|
|
279
|
+
]), "@foldkit/ui/popover/index.js#anonymous~17")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
279
280
|
h.DataAttribute('enter', ''),
|
|
280
281
|
h.DataAttribute('transition', ''),
|
|
281
|
-
]), M.when('LeaveStart', () => [
|
|
282
|
+
]), "@foldkit/ui/popover/index.js#anonymous~18")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
282
283
|
h.DataAttribute('leave', ''),
|
|
283
284
|
h.DataAttribute('transition', ''),
|
|
284
|
-
]), M.when('LeaveAnimating', () => [
|
|
285
|
+
]), "@foldkit/ui/popover/index.js#anonymous~19")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
285
286
|
h.DataAttribute('closed', ''),
|
|
286
287
|
h.DataAttribute('leave', ''),
|
|
287
288
|
h.DataAttribute('transition', ''),
|
|
288
|
-
]), M.orElse(() => []));
|
|
289
|
-
const handleButtonKeyDown = (key) => M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => Option.some(isOpen ? RequestedClose() : RequestedOpen())), M.when('Escape', () => OptionExt.when(isOpen, RequestedClose())), M.orElse(() => Option.none()));
|
|
290
|
-
const handleButtonPointerDown = (pointerType, button) => Option.some(PressedPointerOnButton({ pointerType, button }));
|
|
289
|
+
]), "@foldkit/ui/popover/index.js#anonymous~20")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/popover/index.js#anonymous~21")));
|
|
290
|
+
const handleButtonKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(isOpen ? RequestedClose() : RequestedOpen())), "@foldkit/ui/popover/index.js#anonymous~22")), M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~23")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~24")))), "@foldkit/ui/popover/index.js#handleButtonKeyDown");
|
|
291
|
+
const handleButtonPointerDown = (pointerType, button) => __foldkitBrandViewResult((Option.some(PressedPointerOnButton({ pointerType, button }))), "@foldkit/ui/popover/index.js#handleButtonPointerDown");
|
|
291
292
|
const handleButtonClick = () => {
|
|
292
|
-
const isMouse = Option.exists(maybeLastButtonPointerType, type => type === 'mouse');
|
|
293
|
+
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/popover/index.js#anonymous~25"));
|
|
293
294
|
if (isMouse) {
|
|
294
|
-
return IgnoredMouseClick();
|
|
295
|
+
return __foldkitBrandViewResult((IgnoredMouseClick()), "@foldkit/ui/popover/index.js#handleButtonClick");
|
|
295
296
|
}
|
|
296
297
|
else if (isOpen) {
|
|
297
|
-
return RequestedClose();
|
|
298
|
+
return __foldkitBrandViewResult((RequestedClose()), "@foldkit/ui/popover/index.js#handleButtonClick");
|
|
298
299
|
}
|
|
299
300
|
else {
|
|
300
|
-
return RequestedOpen();
|
|
301
|
+
return __foldkitBrandViewResult((RequestedOpen()), "@foldkit/ui/popover/index.js#handleButtonClick");
|
|
301
302
|
}
|
|
302
303
|
};
|
|
303
|
-
const handleSpaceKeyUp = (key) => OptionExt.when(key === ' ', SuppressedSpaceScroll());
|
|
304
|
-
const handlePanelKeyDown = (key) => M.value(key).pipe(M.when('Escape', () => Option.some(RequestedClose())), M.orElse(() => Option.none()));
|
|
304
|
+
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', SuppressedSpaceScroll())), "@foldkit/ui/popover/index.js#handleSpaceKeyUp");
|
|
305
|
+
const handlePanelKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~26")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~27")))), "@foldkit/ui/popover/index.js#handlePanelKeyDown");
|
|
305
306
|
const resolveButtonLabel = () => {
|
|
306
307
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
307
|
-
return [h.AriaLabel(ariaLabel)];
|
|
308
|
+
return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/popover/index.js#resolveButtonLabel");
|
|
308
309
|
}
|
|
309
310
|
else if (Predicate.isNotUndefined(ariaLabelledBy)) {
|
|
310
|
-
return [h.AriaLabelledBy(ariaLabelledBy)];
|
|
311
|
+
return __foldkitBrandViewResult(([h.AriaLabelledBy(ariaLabelledBy)]), "@foldkit/ui/popover/index.js#resolveButtonLabel");
|
|
311
312
|
}
|
|
312
313
|
else {
|
|
313
|
-
return [];
|
|
314
|
+
return __foldkitBrandViewResult(([]), "@foldkit/ui/popover/index.js#resolveButtonLabel");
|
|
314
315
|
}
|
|
315
316
|
};
|
|
316
317
|
const buttonLabelAttributes = resolveButtonLabel();
|
|
@@ -356,10 +357,10 @@ export const view = defineView((model, viewInputs) => {
|
|
|
356
357
|
h.OnMount(PortalPopoverBackdrop()),
|
|
357
358
|
...(isLeaving ? [] : [h.OnClick(RequestedClose())]),
|
|
358
359
|
];
|
|
359
|
-
return toView({
|
|
360
|
+
return __foldkitBrandViewResult((toView({
|
|
360
361
|
button: childAttributes(buttonAttributes),
|
|
361
362
|
panel: childAttributes(panelAttributes),
|
|
362
363
|
backdrop: childAttributes(backdropAttributes),
|
|
363
364
|
isVisible,
|
|
364
|
-
});
|
|
365
|
+
})), "@foldkit/ui/popover/index.js#anonymous~16");
|
|
365
366
|
});
|
package/dist/radioGroup/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Array, Match as M, Option, Predicate, Schema as S, String, pipe, } from 'effect';
|
|
2
3
|
import { html } from 'foldkit/html';
|
|
3
4
|
import { idSelector } from '../internal/selectors.js';
|
|
@@ -6,9 +7,9 @@ import { keyToIndex } from '../keyboard.js';
|
|
|
6
7
|
/** Controls the radio group layout direction and which arrow keys navigate between options. */
|
|
7
8
|
export const Orientation = S.Literals(['Horizontal', 'Vertical']);
|
|
8
9
|
// VIEW
|
|
9
|
-
const optionId = (id, index) => `${id}-option-${index}
|
|
10
|
-
const labelId = (id, index) => `${id}-option-${index}-label
|
|
11
|
-
const descriptionId = (id, index) => `${id}-option-${index}-description
|
|
10
|
+
const optionId = (id, index) => __foldkitBrandViewResult((`${id}-option-${index}`), "@foldkit/ui/radioGroup/index.js#optionId");
|
|
11
|
+
const labelId = (id, index) => __foldkitBrandViewResult((`${id}-option-${index}-label`), "@foldkit/ui/radioGroup/index.js#labelId");
|
|
12
|
+
const descriptionId = (id, index) => __foldkitBrandViewResult((`${id}-option-${index}-description`), "@foldkit/ui/radioGroup/index.js#descriptionId");
|
|
12
13
|
/** Renders an accessible radio group as a stateless controlled component. The
|
|
13
14
|
* parent owns the selection (`selectedValue`) and receives the parent's own
|
|
14
15
|
* Message via `onSelect` when an option is chosen. Moving focus onto the
|
|
@@ -35,34 +36,34 @@ export const view = (config) => {
|
|
|
35
36
|
const { id, selectedValue, options, onSelect, ariaLabel, toView, orientation = 'Vertical', isOptionDisabled: isOptionDisabledFn, isDisabled: isGroupDisabled = false, name, } = config;
|
|
36
37
|
const isDisabled = (index) => {
|
|
37
38
|
if (isGroupDisabled) {
|
|
38
|
-
return true;
|
|
39
|
+
return __foldkitBrandViewResult((true), "@foldkit/ui/radioGroup/index.js#isDisabled");
|
|
39
40
|
}
|
|
40
41
|
if (!isOptionDisabledFn) {
|
|
41
|
-
return false;
|
|
42
|
+
return __foldkitBrandViewResult((false), "@foldkit/ui/radioGroup/index.js#isDisabled");
|
|
42
43
|
}
|
|
43
|
-
return pipe(options, Array.get(index), Option.exists(option => isOptionDisabledFn(option, index)));
|
|
44
|
+
return __foldkitBrandViewResult((pipe(options, Array.get(index), Option.exists(option => __foldkitBrandViewResult((isOptionDisabledFn(option, index)), "@foldkit/ui/radioGroup/index.js#anonymous")))), "@foldkit/ui/radioGroup/index.js#isDisabled");
|
|
44
45
|
};
|
|
45
|
-
const selectedIndex = Option.flatMap(selectedValue, value => Array.findFirstIndex(options, option => option === value));
|
|
46
|
-
const firstEnabledIndex = pipe(options.length, Array.makeBy(index => index), Array.findFirst(Predicate.not(isDisabled)), Option.getOrElse(() => 0));
|
|
46
|
+
const selectedIndex = Option.flatMap(selectedValue, value => __foldkitBrandViewResult((Array.findFirstIndex(options, option => __foldkitBrandViewResult((option === value), "@foldkit/ui/radioGroup/index.js#anonymous~3"))), "@foldkit/ui/radioGroup/index.js#anonymous~2"));
|
|
47
|
+
const firstEnabledIndex = pipe(options.length, Array.makeBy(index => __foldkitBrandViewResult((index), "@foldkit/ui/radioGroup/index.js#anonymous~4")), Array.findFirst(Predicate.not(isDisabled)), Option.getOrElse(() => __foldkitBrandViewResult((0), "@foldkit/ui/radioGroup/index.js#anonymous~5")));
|
|
47
48
|
// NOTE: The selected index only becomes the roving tab stop when it is
|
|
48
49
|
// enabled. A disabled selected option would otherwise be the group's sole
|
|
49
50
|
// tab stop with no keydown handler, stranding keyboard navigation.
|
|
50
|
-
const focusedIndex = pipe(selectedIndex, Option.filter(Predicate.not(isDisabled)), Option.getOrElse(() => firstEnabledIndex));
|
|
51
|
-
const { nextKey, previousKey } = M.value(orientation).pipe(M.when('Horizontal', () => ({
|
|
51
|
+
const focusedIndex = pipe(selectedIndex, Option.filter(Predicate.not(isDisabled)), Option.getOrElse(() => __foldkitBrandViewResult((firstEnabledIndex), "@foldkit/ui/radioGroup/index.js#anonymous~6")));
|
|
52
|
+
const { nextKey, previousKey } = M.value(orientation).pipe(M.when('Horizontal', () => (__foldkitBrandViewResult(({
|
|
52
53
|
nextKey: 'ArrowRight',
|
|
53
54
|
previousKey: 'ArrowLeft',
|
|
54
|
-
})), M.when('Vertical', () => ({
|
|
55
|
+
}), "@foldkit/ui/radioGroup/index.js#anonymous~7"))), M.when('Vertical', () => (__foldkitBrandViewResult(({
|
|
55
56
|
nextKey: 'ArrowDown',
|
|
56
57
|
previousKey: 'ArrowUp',
|
|
57
|
-
})), M.exhaustive);
|
|
58
|
+
}), "@foldkit/ui/radioGroup/index.js#anonymous~8"))), M.exhaustive);
|
|
58
59
|
const resolveKeyIndex = keyToIndex(nextKey, previousKey, options.length, focusedIndex, isDisabled);
|
|
59
|
-
const selectionAt = (index) => pipe(options, Array.get(index), Option.map(value => ({
|
|
60
|
+
const selectionAt = (index) => __foldkitBrandViewResult((pipe(options, Array.get(index), Option.map(value => (__foldkitBrandViewResult(({
|
|
60
61
|
focusSelector: idSelector(optionId(id, index)),
|
|
61
62
|
message: onSelect(value),
|
|
62
|
-
})));
|
|
63
|
-
const handleKeyDown = (currentIndex) => (key) => M.value(key).pipe(M.whenOr(nextKey, previousKey, 'Home', 'End', 'PageUp', 'PageDown', () => selectionAt(resolveKeyIndex(key))), M.when(' ', () => selectionAt(currentIndex)), M.orElse(() => Option.none()));
|
|
63
|
+
}), "@foldkit/ui/radioGroup/index.js#anonymous~9"))))), "@foldkit/ui/radioGroup/index.js#selectionAt");
|
|
64
|
+
const handleKeyDown = (currentIndex) => __foldkitBrandViewResult(((key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(nextKey, previousKey, 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((selectionAt(resolveKeyIndex(key))), "@foldkit/ui/radioGroup/index.js#anonymous~11")), M.when(' ', () => __foldkitBrandViewResult((selectionAt(currentIndex)), "@foldkit/ui/radioGroup/index.js#anonymous~12")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/radioGroup/index.js#anonymous~13")))), "@foldkit/ui/radioGroup/index.js#anonymous~10")), "@foldkit/ui/radioGroup/index.js#handleKeyDown");
|
|
64
65
|
const optionInfos = Array.map(options, (value, index) => {
|
|
65
|
-
const isSelected = Option.exists(selectedIndex, selectedIdx => selectedIdx === index);
|
|
66
|
+
const isSelected = Option.exists(selectedIndex, selectedIdx => __foldkitBrandViewResult((selectedIdx === index), "@foldkit/ui/radioGroup/index.js#anonymous~15"));
|
|
66
67
|
const isFocusable = index === focusedIndex;
|
|
67
68
|
const isOptionDisabledNow = isDisabled(index);
|
|
68
69
|
const checkedAttributes = isSelected
|
|
@@ -93,7 +94,7 @@ export const view = (config) => {
|
|
|
93
94
|
];
|
|
94
95
|
const labelAttributes = [h.Id(labelId(id, index))];
|
|
95
96
|
const descriptionAttributes = [h.Id(descriptionId(id, index))];
|
|
96
|
-
return {
|
|
97
|
+
return __foldkitBrandViewResult(({
|
|
97
98
|
value,
|
|
98
99
|
index,
|
|
99
100
|
isSelected,
|
|
@@ -102,22 +103,22 @@ export const view = (config) => {
|
|
|
102
103
|
option: optionAttributes,
|
|
103
104
|
label: labelAttributes,
|
|
104
105
|
description: descriptionAttributes,
|
|
105
|
-
};
|
|
106
|
+
}), "@foldkit/ui/radioGroup/index.js#anonymous~14");
|
|
106
107
|
});
|
|
107
108
|
const groupAttributes = [
|
|
108
109
|
h.Role('radiogroup'),
|
|
109
110
|
h.AriaOrientation(String.toLowerCase(orientation)),
|
|
110
111
|
h.AriaLabel(ariaLabel),
|
|
111
112
|
];
|
|
112
|
-
const hiddenInputAttributes = pipe(Option.fromNullishOr(name), Option.flatMap(inputName => Option.map(selectedValue, value => [
|
|
113
|
+
const hiddenInputAttributes = pipe(Option.fromNullishOr(name), Option.flatMap(inputName => __foldkitBrandViewResult((Option.map(selectedValue, value => __foldkitBrandViewResult(([
|
|
113
114
|
h.Type('hidden'),
|
|
114
115
|
h.Name(inputName),
|
|
115
116
|
h.Value(value),
|
|
116
|
-
])), Option.getOrElse(() => []));
|
|
117
|
-
return toView({
|
|
117
|
+
]), "@foldkit/ui/radioGroup/index.js#anonymous~17"))), "@foldkit/ui/radioGroup/index.js#anonymous~16")), Option.getOrElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/radioGroup/index.js#anonymous~18")));
|
|
118
|
+
return __foldkitBrandViewResult((toView({
|
|
118
119
|
group: groupAttributes,
|
|
119
120
|
options: optionInfos,
|
|
120
121
|
selectedValue,
|
|
121
122
|
hiddenInput: hiddenInputAttributes,
|
|
122
|
-
});
|
|
123
|
+
})), "@foldkit/ui/radioGroup/index.js#view");
|
|
123
124
|
};
|
package/dist/select/index.js
CHANGED
|
@@ -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 select's base ID. */
|
|
4
|
-
export const descriptionId = (id) => `${id}-description
|
|
5
|
+
export const descriptionId = (id) => __foldkitBrandViewResult((`${id}-description`), "@foldkit/ui/select/index.js#descriptionId");
|
|
5
6
|
/** Renders an accessible select 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();
|
|
@@ -32,9 +33,9 @@ export const view = (config) => {
|
|
|
32
33
|
];
|
|
33
34
|
const labelAttributes = [h.For(id)];
|
|
34
35
|
const descriptionAttributes = [h.Id(descriptionId(id))];
|
|
35
|
-
return toView({
|
|
36
|
+
return __foldkitBrandViewResult((toView({
|
|
36
37
|
select: allSelectAttributes,
|
|
37
38
|
label: labelAttributes,
|
|
38
39
|
description: descriptionAttributes,
|
|
39
|
-
});
|
|
40
|
+
})), "@foldkit/ui/select/index.js#view");
|
|
40
41
|
};
|