@foldkit/ui 0.128.1 → 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.
- 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.d.ts +1 -0
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +20 -19
- package/dist/combobox/shared.d.ts +1 -0
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +169 -168
- package/dist/combobox/single.d.ts +1 -0
- package/dist/combobox/single.d.ts.map +1 -1
- 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.d.ts +1 -0
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +12 -11
- package/dist/listbox/shared.d.ts +1 -0
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +171 -170
- package/dist/listbox/single.d.ts +1 -0
- package/dist/listbox/single.d.ts.map +1 -1
- 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.d.ts +4 -0
- package/dist/toast/index.d.ts.map +1 -1
- 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.d.ts +4 -0
- package/dist/toast/update.d.ts.map +1 -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/dialog/index.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';
|
|
@@ -66,7 +67,7 @@ export const Closed = m('Closed');
|
|
|
66
67
|
/** Union of out-messages the dialog component can produce. */
|
|
67
68
|
export const OutMessage = S.Union([Opened, Closed]);
|
|
68
69
|
/** Creates an initial dialog model from a config. Defaults to closed and non-animated. */
|
|
69
|
-
export const init = (config) => ({
|
|
70
|
+
export const init = (config) => (__foldkitBrandViewResult(({
|
|
70
71
|
id: config.id,
|
|
71
72
|
isOpen: config.isOpen ?? false,
|
|
72
73
|
isAnimated: config.isAnimated ?? false,
|
|
@@ -75,9 +76,9 @@ export const init = (config) => ({
|
|
|
75
76
|
...(config.isOpen !== undefined ? { isShowing: config.isOpen } : {}),
|
|
76
77
|
}),
|
|
77
78
|
maybeFocusSelector: Option.fromNullishOr(config.focusSelector),
|
|
78
|
-
});
|
|
79
|
+
}), "@foldkit/ui/dialog/index.js#init"));
|
|
79
80
|
// UPDATE
|
|
80
|
-
const dialogSelector = (id) => idSelector(id);
|
|
81
|
+
const dialogSelector = (id) => __foldkitBrandViewResult((idSelector(id)), "@foldkit/ui/dialog/index.js#dialogSelector");
|
|
81
82
|
/** Data attribute the dialog places on the `initialFocus` RenderInfo group and
|
|
82
83
|
* focuses on open. */
|
|
83
84
|
export const initialFocusMarkerAttribute = 'foldkit-dialog-initial-focus';
|
|
@@ -90,104 +91,104 @@ const withUpdateReturn = M.withReturnType();
|
|
|
90
91
|
* high-z-index overlays stay interactive. It layers the dialog with a high
|
|
91
92
|
* z-index, traps focus, and dispatches a `cancel` event on Esc. The Dialog
|
|
92
93
|
* component supplies its own backdrop. */
|
|
93
|
-
export const ShowDialog = Command.define('ShowDialog', { id: S.String, focusSelector: S.String }, CompletedShowDialog)(({ id, focusSelector }) => Dom.lockScroll.pipe(Effect.andThen(() => Dom.showDialog(dialogSelector(id), { focusSelector })), Effect.ignore, Effect.as(CompletedShowDialog())));
|
|
94
|
+
export const ShowDialog = Command.define('ShowDialog', { id: S.String, focusSelector: S.String }, CompletedShowDialog)(({ id, focusSelector }) => __foldkitBrandViewResult((Dom.lockScroll.pipe(Effect.andThen(() => __foldkitBrandViewResult((Dom.showDialog(dialogSelector(id), { focusSelector })), "@foldkit/ui/dialog/index.js#anonymous~2")), Effect.ignore, Effect.as(CompletedShowDialog()))), "@foldkit/ui/dialog/index.js#anonymous"));
|
|
94
95
|
/** Calls `close()` on the native dialog element and unlocks page scroll. */
|
|
95
|
-
export const CloseDialog = Command.define('CloseDialog', { id: S.String }, CompletedCloseDialog)(({ id }) => Dom.closeDialog(dialogSelector(id)).pipe(Effect.andThen(() => Dom.unlockScroll), Effect.ignore, Effect.as(CompletedCloseDialog())));
|
|
96
|
+
export const CloseDialog = Command.define('CloseDialog', { id: S.String }, CompletedCloseDialog)(({ id }) => __foldkitBrandViewResult((Dom.closeDialog(dialogSelector(id)).pipe(Effect.andThen(() => __foldkitBrandViewResult((Dom.unlockScroll), "@foldkit/ui/dialog/index.js#anonymous~4")), Effect.ignore, Effect.as(CompletedCloseDialog()))), "@foldkit/ui/dialog/index.js#anonymous~3"));
|
|
96
97
|
/** Releases the framework hygiene the dialog holds while open (scroll lock,
|
|
97
98
|
* focus trap, return focus, stack entry) when the element unmounts without a
|
|
98
99
|
* purposeful close. Idempotent: a no-op if the dialog already released its
|
|
99
100
|
* resources through `CloseDialog`. */
|
|
100
|
-
export const ReleaseDialogResources = Command.define('ReleaseDialogResources', { id: S.String }, CompletedReleaseDialogResources)(({ id }) => Dom.releaseDialogResources(id).pipe(Effect.ignore, Effect.as(CompletedReleaseDialogResources())));
|
|
101
|
-
const wrapAnimationMessage = (message) => GotAnimationMessage({ message });
|
|
101
|
+
export const ReleaseDialogResources = Command.define('ReleaseDialogResources', { id: S.String }, CompletedReleaseDialogResources)(({ id }) => __foldkitBrandViewResult((Dom.releaseDialogResources(id).pipe(Effect.ignore, Effect.as(CompletedReleaseDialogResources()))), "@foldkit/ui/dialog/index.js#anonymous~5"));
|
|
102
|
+
const wrapAnimationMessage = (message) => __foldkitBrandViewResult((GotAnimationMessage({ message })), "@foldkit/ui/dialog/index.js#wrapAnimationMessage");
|
|
102
103
|
const delegateToAnimation = (model, animationMessage) => {
|
|
103
104
|
const [nextAnimation, animationCommands, maybeOutMessage] = animationUpdate(model.animation, animationMessage);
|
|
104
105
|
const mappedCommands = Command.mapMessages(animationCommands, wrapAnimationMessage);
|
|
105
106
|
const additionalCommands = Option.match(maybeOutMessage, {
|
|
106
|
-
onNone: () => [],
|
|
107
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/dialog/index.js#onNone"),
|
|
107
108
|
onSome: M.type().pipe(M.tagsExhaustive({
|
|
108
|
-
StartedLeaveAnimating: () => [
|
|
109
|
+
StartedLeaveAnimating: () => __foldkitBrandViewResult(([
|
|
109
110
|
Command.mapMessage(animationDefaultLeaveCommand(nextAnimation), wrapAnimationMessage),
|
|
110
|
-
],
|
|
111
|
-
TransitionedOut: () => [CloseDialog({ id: model.id })],
|
|
111
|
+
]), "@foldkit/ui/dialog/index.js#StartedLeaveAnimating"),
|
|
112
|
+
TransitionedOut: () => __foldkitBrandViewResult(([CloseDialog({ id: model.id })]), "@foldkit/ui/dialog/index.js#TransitionedOut"),
|
|
112
113
|
})),
|
|
113
114
|
});
|
|
114
|
-
return [
|
|
115
|
-
evo(model, { animation: () => nextAnimation }),
|
|
115
|
+
return __foldkitBrandViewResult(([
|
|
116
|
+
evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/dialog/index.js#animation") }),
|
|
116
117
|
[...mappedCommands, ...additionalCommands],
|
|
117
118
|
Option.none(),
|
|
118
|
-
];
|
|
119
|
+
]), "@foldkit/ui/dialog/index.js#delegateToAnimation");
|
|
119
120
|
};
|
|
120
121
|
/** Processes a dialog message and returns the next model and commands. */
|
|
121
|
-
export const update = (model, message) => M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
122
|
+
export const update = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
122
123
|
RequestedOpen: () => {
|
|
123
124
|
const wasClosed = !model.isOpen;
|
|
124
125
|
const maybeShow = Option.liftPredicate(ShowDialog({
|
|
125
126
|
id: model.id,
|
|
126
|
-
focusSelector: Option.getOrElse(model.maybeFocusSelector, () => initialFocusMarkerSelector),
|
|
127
|
-
}), () => wasClosed);
|
|
127
|
+
focusSelector: Option.getOrElse(model.maybeFocusSelector, () => __foldkitBrandViewResult((initialFocusMarkerSelector), "@foldkit/ui/dialog/index.js#anonymous~6")),
|
|
128
|
+
}), () => __foldkitBrandViewResult((wasClosed), "@foldkit/ui/dialog/index.js#anonymous~7"));
|
|
128
129
|
const maybeOutMessage = wasClosed
|
|
129
130
|
? Option.some(Opened())
|
|
130
131
|
: Option.none();
|
|
131
132
|
if (model.isAnimated) {
|
|
132
133
|
const [nextModel, animationCommands] = delegateToAnimation(model, AnimationShowed());
|
|
133
|
-
return [
|
|
134
|
-
evo(nextModel, { isOpen: () => true }),
|
|
134
|
+
return __foldkitBrandViewResult(([
|
|
135
|
+
evo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/dialog/index.js#isOpen") }),
|
|
135
136
|
[...Option.toArray(maybeShow), ...animationCommands],
|
|
136
137
|
maybeOutMessage,
|
|
137
|
-
];
|
|
138
|
+
]), "@foldkit/ui/dialog/index.js#RequestedOpen");
|
|
138
139
|
}
|
|
139
|
-
return [
|
|
140
|
-
evo(model, { isOpen: () => true }),
|
|
140
|
+
return __foldkitBrandViewResult(([
|
|
141
|
+
evo(model, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/dialog/index.js#isOpen~2") }),
|
|
141
142
|
Option.toArray(maybeShow),
|
|
142
143
|
maybeOutMessage,
|
|
143
|
-
];
|
|
144
|
+
]), "@foldkit/ui/dialog/index.js#RequestedOpen");
|
|
144
145
|
},
|
|
145
146
|
RequestedClose: () => {
|
|
146
147
|
const { transitionState } = model.animation;
|
|
147
148
|
const isLeaving = transitionState === 'LeaveStart' ||
|
|
148
149
|
transitionState === 'LeaveAnimating';
|
|
149
150
|
if (isLeaving) {
|
|
150
|
-
return [model, [], Option.none()];
|
|
151
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/dialog/index.js#RequestedClose");
|
|
151
152
|
}
|
|
152
153
|
const wasOpen = model.isOpen;
|
|
153
154
|
const maybeOutMessage = wasOpen ? Option.some(Closed()) : Option.none();
|
|
154
155
|
if (model.isAnimated) {
|
|
155
|
-
const [nextModel, animationCommands] = delegateToAnimation(evo(model, { isOpen: () => false }), AnimationHid());
|
|
156
|
-
return [nextModel, animationCommands, maybeOutMessage];
|
|
156
|
+
const [nextModel, animationCommands] = delegateToAnimation(evo(model, { isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~3") }), AnimationHid());
|
|
157
|
+
return __foldkitBrandViewResult(([nextModel, animationCommands, maybeOutMessage]), "@foldkit/ui/dialog/index.js#RequestedClose");
|
|
157
158
|
}
|
|
158
|
-
const maybeClose = Option.liftPredicate(CloseDialog({ id: model.id }), () => wasOpen);
|
|
159
|
-
return [
|
|
160
|
-
evo(model, { isOpen: () => false }),
|
|
159
|
+
const maybeClose = Option.liftPredicate(CloseDialog({ id: model.id }), () => __foldkitBrandViewResult((wasOpen), "@foldkit/ui/dialog/index.js#anonymous~8"));
|
|
160
|
+
return __foldkitBrandViewResult(([
|
|
161
|
+
evo(model, { isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~4") }),
|
|
161
162
|
Option.toArray(maybeClose),
|
|
162
163
|
maybeOutMessage,
|
|
163
|
-
];
|
|
164
|
+
]), "@foldkit/ui/dialog/index.js#RequestedClose");
|
|
164
165
|
},
|
|
165
|
-
GotAnimationMessage: ({ message: animationMessage }) => delegateToAnimation(model, animationMessage),
|
|
166
|
+
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((delegateToAnimation(model, animationMessage)), "@foldkit/ui/dialog/index.js#GotAnimationMessage"),
|
|
166
167
|
Unmounted: () => {
|
|
167
168
|
const isHoldingResources = model.isOpen || model.animation.transitionState !== 'Idle';
|
|
168
169
|
if (isHoldingResources) {
|
|
169
170
|
const nextModel = evo(model, {
|
|
170
|
-
isOpen: () => false,
|
|
171
|
-
animation: () => animationInit({ id: `${model.id}-panel` }),
|
|
171
|
+
isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~5"),
|
|
172
|
+
animation: () => __foldkitBrandViewResult((animationInit({ id: `${model.id}-panel` })), "@foldkit/ui/dialog/index.js#animation~2"),
|
|
172
173
|
});
|
|
173
|
-
return [
|
|
174
|
+
return __foldkitBrandViewResult(([
|
|
174
175
|
nextModel,
|
|
175
176
|
[ReleaseDialogResources({ id: model.id })],
|
|
176
177
|
Option.none(),
|
|
177
|
-
];
|
|
178
|
+
]), "@foldkit/ui/dialog/index.js#Unmounted");
|
|
178
179
|
}
|
|
179
180
|
else {
|
|
180
|
-
return [model, [], Option.none()];
|
|
181
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/dialog/index.js#Unmounted");
|
|
181
182
|
}
|
|
182
183
|
},
|
|
183
|
-
CompletedShowDialog: () => [model, [], Option.none()],
|
|
184
|
-
CompletedCloseDialog: () => [model, [], Option.none()],
|
|
185
|
-
CompletedReleaseDialogResources: () => [model, [], Option.none()],
|
|
186
|
-
}));
|
|
184
|
+
CompletedShowDialog: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/dialog/index.js#CompletedShowDialog"),
|
|
185
|
+
CompletedCloseDialog: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/dialog/index.js#CompletedCloseDialog"),
|
|
186
|
+
CompletedReleaseDialogResources: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/dialog/index.js#CompletedReleaseDialogResources"),
|
|
187
|
+
}))), "@foldkit/ui/dialog/index.js#update");
|
|
187
188
|
/** Programmatically opens the dialog. */
|
|
188
|
-
export const open = (model) => update(model, RequestedOpen());
|
|
189
|
+
export const open = (model) => __foldkitBrandViewResult((update(model, RequestedOpen())), "@foldkit/ui/dialog/index.js#open");
|
|
189
190
|
/** Programmatically closes the dialog. */
|
|
190
|
-
export const close = (model) => update(model, RequestedClose());
|
|
191
|
+
export const close = (model) => __foldkitBrandViewResult((update(model, RequestedClose())), "@foldkit/ui/dialog/index.js#close");
|
|
191
192
|
// VIEW
|
|
192
193
|
/** Returns the framework-managed id the dialog's `aria-labelledby` points at,
|
|
193
194
|
* the `-dialog-title` suffix on `model.id`.
|
|
@@ -197,7 +198,7 @@ export const close = (model) => update(model, RequestedClose());
|
|
|
197
198
|
* helper only when you need the id as a value outside `toView`: a Command that
|
|
198
199
|
* calls `getElementById`, a cross-element `aria-describedby`, or a test. Do not
|
|
199
200
|
* hand-roll the id string. */
|
|
200
|
-
export const titleId = (model) => `${model.id}-dialog-title
|
|
201
|
+
export const titleId = (model) => __foldkitBrandViewResult((`${model.id}-dialog-title`), "@foldkit/ui/dialog/index.js#titleId");
|
|
201
202
|
/** Returns the framework-managed id the dialog's `aria-describedby` points at,
|
|
202
203
|
* the `-dialog-description` suffix on `model.id`.
|
|
203
204
|
*
|
|
@@ -206,7 +207,7 @@ export const titleId = (model) => `${model.id}-dialog-title`;
|
|
|
206
207
|
* for you. Reach for this helper only when you need the id as a value outside
|
|
207
208
|
* `toView`: a Command that calls `getElementById`, a cross-element
|
|
208
209
|
* `aria-describedby`, or a test. Do not hand-roll the id string. */
|
|
209
|
-
export const descriptionId = (model) => `${model.id}-dialog-description
|
|
210
|
+
export const descriptionId = (model) => __foldkitBrandViewResult((`${model.id}-dialog-description`), "@foldkit/ui/dialog/index.js#descriptionId");
|
|
210
211
|
/** Renders a headless dialog component backed by the native `<dialog>`
|
|
211
212
|
* element. `ShowDialog` opens it through `Dom.showDialog`, which uses `show()`
|
|
212
213
|
* (not native `showModal()`) with a high z-index, a focus trap, a
|
|
@@ -217,21 +218,21 @@ export const view = defineView((model, viewInputs) => {
|
|
|
217
218
|
const { toView } = viewInputs;
|
|
218
219
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
219
220
|
const isVisible = isOpen || isLeaving;
|
|
220
|
-
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => [
|
|
221
|
+
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
221
222
|
h.DataAttribute('closed', ''),
|
|
222
223
|
h.DataAttribute('enter', ''),
|
|
223
224
|
h.DataAttribute('transition', ''),
|
|
224
|
-
]), M.when('EnterAnimating', () => [
|
|
225
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~10")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
225
226
|
h.DataAttribute('enter', ''),
|
|
226
227
|
h.DataAttribute('transition', ''),
|
|
227
|
-
]), M.when('LeaveStart', () => [
|
|
228
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~11")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
228
229
|
h.DataAttribute('leave', ''),
|
|
229
230
|
h.DataAttribute('transition', ''),
|
|
230
|
-
]), M.when('LeaveAnimating', () => [
|
|
231
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~12")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
231
232
|
h.DataAttribute('closed', ''),
|
|
232
233
|
h.DataAttribute('leave', ''),
|
|
233
234
|
h.DataAttribute('transition', ''),
|
|
234
|
-
]), M.orElse(() => []));
|
|
235
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~13")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/dialog/index.js#anonymous~14")));
|
|
235
236
|
const dialogAttributes = [
|
|
236
237
|
h.Id(id),
|
|
237
238
|
h.AriaLabelledBy(titleId(model)),
|
|
@@ -266,7 +267,7 @@ export const view = defineView((model, viewInputs) => {
|
|
|
266
267
|
h.DataAttribute(initialFocusMarkerAttribute, ''),
|
|
267
268
|
];
|
|
268
269
|
const closeButtonAttributes = isLeaving ? [] : [h.OnClick(RequestedClose())];
|
|
269
|
-
return toView({
|
|
270
|
+
return __foldkitBrandViewResult((toView({
|
|
270
271
|
dialog: childAttributes(dialogAttributes),
|
|
271
272
|
backdrop: childAttributes(backdropAttributes),
|
|
272
273
|
panel: childAttributes(panelAttributes),
|
|
@@ -275,5 +276,5 @@ export const view = defineView((model, viewInputs) => {
|
|
|
275
276
|
initialFocus: childAttributes(initialFocusAttributes),
|
|
276
277
|
closeButton: childAttributes(closeButtonAttributes),
|
|
277
278
|
isVisible,
|
|
278
|
-
});
|
|
279
|
+
})), "@foldkit/ui/dialog/index.js#anonymous~9");
|
|
279
280
|
});
|
package/dist/disclosure/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Match as M, Option, Predicate } from 'effect';
|
|
2
3
|
import { html } from 'foldkit/html';
|
|
3
4
|
// VIEW
|
|
@@ -5,8 +6,8 @@ import { html } from 'foldkit/html';
|
|
|
5
6
|
* disclosure's base id. Use this to associate an external label with the
|
|
6
7
|
* button via a native `<label for={Disclosure.buttonId(id)}>` or an
|
|
7
8
|
* `aria-labelledby` reference. */
|
|
8
|
-
export const buttonId = (id) => `${id}-button
|
|
9
|
-
const panelId = (id) => `${id}-panel
|
|
9
|
+
export const buttonId = (id) => __foldkitBrandViewResult((`${id}-button`), "@foldkit/ui/disclosure/index.js#buttonId");
|
|
10
|
+
const panelId = (id) => __foldkitBrandViewResult((`${id}-panel`), "@foldkit/ui/disclosure/index.js#panelId");
|
|
10
11
|
const panelSizeTransition = 'grid-template-rows 200ms ease-out';
|
|
11
12
|
/** Renders a headless disclosure as a stateless controlled component. The
|
|
12
13
|
* parent owns the open state (`isOpen`) and receives the new state via
|
|
@@ -33,19 +34,19 @@ export const view = (config) => {
|
|
|
33
34
|
const h = html();
|
|
34
35
|
const { id, isOpen, onToggle, toView, isDisabled = false, ariaLabel, ariaLabelledBy, } = config;
|
|
35
36
|
const nextOpen = !isOpen;
|
|
36
|
-
const handleKeyDown = (key) => M.value(key).pipe(M.whenOr('Enter', ' ', () => Option.some(onToggle(nextOpen))), M.orElse(() => Option.none()));
|
|
37
|
+
const handleKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', () => __foldkitBrandViewResult((Option.some(onToggle(nextOpen))), "@foldkit/ui/disclosure/index.js#anonymous")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/disclosure/index.js#anonymous~2")))), "@foldkit/ui/disclosure/index.js#handleKeyDown");
|
|
37
38
|
const disabledAttributes = isDisabled
|
|
38
39
|
? [h.AriaDisabled(true), h.DataAttribute('disabled', '')]
|
|
39
40
|
: [];
|
|
40
41
|
const resolveButtonLabel = () => {
|
|
41
42
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
42
|
-
return [h.AriaLabel(ariaLabel)];
|
|
43
|
+
return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/disclosure/index.js#resolveButtonLabel");
|
|
43
44
|
}
|
|
44
45
|
else if (Predicate.isNotUndefined(ariaLabelledBy)) {
|
|
45
|
-
return [h.AriaLabelledBy(ariaLabelledBy)];
|
|
46
|
+
return __foldkitBrandViewResult(([h.AriaLabelledBy(ariaLabelledBy)]), "@foldkit/ui/disclosure/index.js#resolveButtonLabel");
|
|
46
47
|
}
|
|
47
48
|
else {
|
|
48
|
-
return [];
|
|
49
|
+
return __foldkitBrandViewResult(([]), "@foldkit/ui/disclosure/index.js#resolveButtonLabel");
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
52
|
const buttonAttributes = [
|
|
@@ -67,7 +68,7 @@ export const view = (config) => {
|
|
|
67
68
|
h.Id(panelId(id)),
|
|
68
69
|
...(isOpen ? [h.DataAttribute('open', '')] : []),
|
|
69
70
|
];
|
|
70
|
-
const animatePanel = (content) => h.div([
|
|
71
|
+
const animatePanel = (content) => __foldkitBrandViewResult((h.div([
|
|
71
72
|
h.Style({
|
|
72
73
|
display: 'grid',
|
|
73
74
|
gridTemplateRows: isOpen ? '1fr' : '0fr',
|
|
@@ -79,10 +80,10 @@ export const view = (config) => {
|
|
|
79
80
|
h.Style({ minHeight: '0px', overflow: 'hidden' }),
|
|
80
81
|
...(isOpen ? [] : [h.AriaHidden(true)]),
|
|
81
82
|
], [content]),
|
|
82
|
-
]);
|
|
83
|
-
return toView({
|
|
83
|
+
])), "@foldkit/ui/disclosure/index.js#animatePanel");
|
|
84
|
+
return __foldkitBrandViewResult((toView({
|
|
84
85
|
button: buttonAttributes,
|
|
85
86
|
panel: panelAttributes,
|
|
86
87
|
animatePanel,
|
|
87
|
-
});
|
|
88
|
+
})), "@foldkit/ui/disclosure/index.js#view");
|
|
88
89
|
};
|