@foldkit/ui 0.162.0 → 0.163.0-canary.5401108272c3
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/anchor.d.ts.map +1 -1
- package/dist/anchor/anchor.js +10 -1
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +11 -7
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +27 -19
- package/dist/checkbox/index.d.ts +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/combobox/multi.js +2 -2
- package/dist/combobox/shared.js +15 -15
- package/dist/combobox/single.js +4 -4
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +10 -10
- package/dist/dialog/index.js +9 -9
- package/dist/disclosure/index.d.ts +2 -2
- package/dist/disclosure/index.js +1 -1
- package/dist/dragAndDrop/index.js +14 -14
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +7 -5
- package/dist/hoverIntent/hoverIntent.d.ts.map +1 -1
- package/dist/hoverIntent/hoverIntent.js +16 -16
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +20 -18
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +23 -17
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +12 -10
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +5 -3
- package/dist/slider/index.d.ts +60 -25
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +155 -62
- package/dist/slider/public.d.ts +1 -1
- package/dist/slider/public.d.ts.map +1 -1
- package/dist/slider/public.js +1 -1
- package/dist/switch/index.d.ts +1 -1
- package/dist/switch/index.js +1 -1
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +5 -3
- package/dist/test/apps/disabledButton.d.ts +4 -4
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +3 -3
- package/dist/toast/index.d.ts +822 -43
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +77 -17
- package/dist/toast/public.d.ts +2 -2
- package/dist/toast/public.d.ts.map +1 -1
- package/dist/toast/public.js +1 -1
- package/dist/toast/schema.d.ts +145 -2
- package/dist/toast/schema.d.ts.map +1 -1
- package/dist/toast/schema.js +69 -2
- package/dist/toast/swipeTarget.d.ts +5 -0
- package/dist/toast/swipeTarget.d.ts.map +1 -0
- package/dist/toast/swipeTarget.js +18 -0
- package/dist/toast/test.d.ts +1 -1
- package/dist/toast/test.js +1 -1
- package/dist/toast/update.d.ts +726 -5
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +283 -68
- package/dist/tooltip/tooltip.d.ts +2 -2
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +14 -12
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +8 -6
- package/package.json +7 -7
package/dist/slider/index.js
CHANGED
|
@@ -3,20 +3,20 @@ import { Effect, Equal, Function, Match, Option, Schema, Stream, String, pipe, }
|
|
|
3
3
|
import { childAttributes } from 'foldkit/html';
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message';
|
|
5
5
|
import { defineTaggedUnion } from 'foldkit/schema';
|
|
6
|
-
import {
|
|
6
|
+
import { modifyFields } from 'foldkit/struct';
|
|
7
7
|
import { defineView } from 'foldkit/submodel';
|
|
8
8
|
import * as Subscription from 'foldkit/subscription';
|
|
9
|
-
import { attributeSelector } from '../internal/selectors.js';
|
|
9
|
+
import { attributeSelector, idSelector } from '../internal/selectors.js';
|
|
10
10
|
// MODEL
|
|
11
11
|
const DragState = defineTaggedUnion({
|
|
12
12
|
Idle: {},
|
|
13
13
|
Dragging: { originValue: Schema.Number },
|
|
14
14
|
});
|
|
15
|
-
/** Schema for the
|
|
15
|
+
/** Schema for the Slider's private interaction state. The current
|
|
16
16
|
* value is owned by the parent and passed in via `ViewInputs.value`, so it is
|
|
17
|
-
* not stored here. `min
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* not stored here. `min`, `max`, and `step` configure how the drag Subscription
|
|
18
|
+
* maps pointer positions into values. `dragState` tracks the active drag phase
|
|
19
|
+
* and captures the pre-drag value so Escape can restore it. */
|
|
20
20
|
export const Model = Schema.Struct({
|
|
21
21
|
id: Schema.String,
|
|
22
22
|
min: Schema.Number,
|
|
@@ -25,7 +25,7 @@ export const Model = Schema.Struct({
|
|
|
25
25
|
dragState: DragState,
|
|
26
26
|
});
|
|
27
27
|
// MESSAGE
|
|
28
|
-
/** Union of all
|
|
28
|
+
/** Union of all Messages the Slider can produce. */
|
|
29
29
|
export const Message = defineMessageUnion({
|
|
30
30
|
PressedThumb: { originValue: Schema.Number },
|
|
31
31
|
PressedPointer: {
|
|
@@ -48,11 +48,11 @@ export const Message = defineMessageUnion({
|
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
// OUT MESSAGE
|
|
51
|
-
/** Union of all
|
|
51
|
+
/** Union of all OutMessages the Slider can emit to its parent. */
|
|
52
52
|
export const OutMessage = defineMessageUnion({
|
|
53
53
|
ChangedValue: { value: Schema.Number },
|
|
54
54
|
});
|
|
55
|
-
/** Creates an initial
|
|
55
|
+
/** Creates an initial Slider Model from a config. The value lives in the
|
|
56
56
|
* parent Model; initialize it there and snap it with {@link snapAndClamp}. */
|
|
57
57
|
export const init = (config) => (__foldkitBrandViewResult(({
|
|
58
58
|
id: config.id,
|
|
@@ -75,7 +75,7 @@ const roundToStepPrecision = (value, step) => {
|
|
|
75
75
|
};
|
|
76
76
|
const clamp = (value, min, max) => __foldkitBrandViewResult((Math.min(Math.max(value, min), max)), "@foldkit/ui/slider/index.js#clamp");
|
|
77
77
|
/** Snaps a value to the nearest step and clamps it into `[min, max]`. Exported
|
|
78
|
-
* so a parent can conform the value it owns to the
|
|
78
|
+
* so a parent can conform the value it owns to the Slider's range, for example
|
|
79
79
|
* when seeding the initial value or reacting to an external update. */
|
|
80
80
|
export const snapAndClamp = (value, min, max, step) => {
|
|
81
81
|
const snapped = min + Math.round((value - min) / step) * step;
|
|
@@ -113,7 +113,7 @@ const withChangedValue = (model, currentValue, nextValue) => {
|
|
|
113
113
|
* Model. */
|
|
114
114
|
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
115
115
|
PressedThumb: ({ originValue }) => __foldkitBrandViewResult((Match.value(model.dragState).pipe(withUpdateReturn, Match.tag('Dragging', () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~7"))), Match.orElse(() => (__foldkitBrandViewResult(({
|
|
116
|
-
model:
|
|
116
|
+
model: modifyFields(model, {
|
|
117
117
|
dragState: () => __foldkitBrandViewResult((DragState.Dragging({ originValue })), "@foldkit/ui/slider/index.js#dragState"),
|
|
118
118
|
}),
|
|
119
119
|
}), "@foldkit/ui/slider/index.js#anonymous~8"))))), "@foldkit/ui/slider/index.js#PressedThumb"),
|
|
@@ -125,7 +125,7 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
125
125
|
// off-center on a non-zero-width thumb.
|
|
126
126
|
PressedPointer: ({ value, originValue }) => __foldkitBrandViewResult((Match.value(model.dragState).pipe(withUpdateReturn, Match.tag('Dragging', () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~9"))), Match.orElse(() => {
|
|
127
127
|
const snapped = snapAndClamp(value, model.min, model.max, model.step);
|
|
128
|
-
return __foldkitBrandViewResult((withChangedValue(
|
|
128
|
+
return __foldkitBrandViewResult((withChangedValue(modifyFields(model, {
|
|
129
129
|
dragState: () => __foldkitBrandViewResult((DragState.Dragging({ originValue })), "@foldkit/ui/slider/index.js#dragState~2"),
|
|
130
130
|
}), originValue, snapped)), "@foldkit/ui/slider/index.js#anonymous~10");
|
|
131
131
|
}))), "@foldkit/ui/slider/index.js#PressedPointer"),
|
|
@@ -136,10 +136,10 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
136
136
|
}),
|
|
137
137
|
}), "@foldkit/ui/slider/index.js#anonymous~11"))), Match.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~12"))))), "@foldkit/ui/slider/index.js#MovedDragPointer"),
|
|
138
138
|
ReleasedDragPointer: () => __foldkitBrandViewResult((Match.value(model.dragState).pipe(withUpdateReturn, Match.tag('Dragging', () => (__foldkitBrandViewResult(({
|
|
139
|
-
model:
|
|
139
|
+
model: modifyFields(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/slider/index.js#dragState~3") }),
|
|
140
140
|
}), "@foldkit/ui/slider/index.js#anonymous~13"))), Match.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~14"))))), "@foldkit/ui/slider/index.js#ReleasedDragPointer"),
|
|
141
141
|
CancelledDrag: () => __foldkitBrandViewResult((Match.value(model.dragState).pipe(withUpdateReturn, Match.tag('Dragging', ({ originValue }) => (__foldkitBrandViewResult(({
|
|
142
|
-
model:
|
|
142
|
+
model: modifyFields(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/slider/index.js#dragState~4") }),
|
|
143
143
|
outMessage: OutMessage.ChangedValue({ value: originValue }),
|
|
144
144
|
}), "@foldkit/ui/slider/index.js#anonymous~15"))), Match.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~16"))))), "@foldkit/ui/slider/index.js#CancelledDrag"),
|
|
145
145
|
PressedKeyboardNavigation: ({ direction, value }) => __foldkitBrandViewResult((withChangedValue(model, value, nextValueForDirection(value, model.min, model.max, model.step, direction))), "@foldkit/ui/slider/index.js#PressedKeyboardNavigation"),
|
|
@@ -148,28 +148,71 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
148
148
|
* derive from external state (e.g. a bounded buffer whose first/last index
|
|
149
149
|
* shifts over time). The parent owns the value, so conform it to the new range
|
|
150
150
|
* in the same update with {@link snapAndClamp}. */
|
|
151
|
-
export const reflectRange = Function.dual(2, (model, range) => __foldkitBrandViewResult((
|
|
151
|
+
export const reflectRange = Function.dual(2, (model, range) => __foldkitBrandViewResult((modifyFields(model, {
|
|
152
152
|
min: () => __foldkitBrandViewResult((range.min), "@foldkit/ui/slider/index.js#min"),
|
|
153
153
|
max: () => __foldkitBrandViewResult((range.max), "@foldkit/ui/slider/index.js#max"),
|
|
154
154
|
})), "@foldkit/ui/slider/index.js#anonymous~17"));
|
|
155
155
|
// SUBSCRIPTION
|
|
156
156
|
const DragActivity = Schema.Literals(['Idle', 'Active']);
|
|
157
157
|
const dragActivityFromModel = (model) => __foldkitBrandViewResult((Match.value(model.dragState).pipe(Match.withReturnType(), Match.tag('Dragging', () => __foldkitBrandViewResult(('Active'), "@foldkit/ui/slider/index.js#anonymous~18")), Match.orElse(() => __foldkitBrandViewResult(('Idle'), "@foldkit/ui/slider/index.js#anonymous~19")))), "@foldkit/ui/slider/index.js#dragActivityFromModel");
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
const findTrackElement = (sliderId, trackRoot) => __foldkitBrandViewResult((Option.fromNullishOr(trackRoot.querySelector(attributeSelector('data-slider-track-id', sliderId)))), "@foldkit/ui/slider/index.js#findTrackElement");
|
|
159
|
+
const isVerticalTrack = (track) => __foldkitBrandViewResult((track.getAttribute('data-orientation') === 'vertical' ||
|
|
160
|
+
track.hasAttribute('data-vertical')), "@foldkit/ui/slider/index.js#isVerticalTrack");
|
|
161
|
+
const isEdgeAlignedTrack = (track) => __foldkitBrandViewResult((track.getAttribute('data-thumb-alignment') === 'edge'), "@foldkit/ui/slider/index.js#isEdgeAlignedTrack");
|
|
162
|
+
const findThumbElementForTrack = (track) => __foldkitBrandViewResult((pipe(track.getAttribute('data-slider-track-id'), Option.fromNullishOr, Option.flatMap(sliderId => {
|
|
163
|
+
const thumbSelector = idSelector(`${sliderId}-thumb`);
|
|
164
|
+
const maybeSliderRoot = Option.fromNullishOr(track.closest(attributeSelector('data-slider-id', sliderId)));
|
|
165
|
+
return __foldkitBrandViewResult((Option.match(maybeSliderRoot, {
|
|
166
|
+
onNone: () => __foldkitBrandViewResult((Option.fromNullishOr(track.ownerDocument.getElementById(`${sliderId}-thumb`))), "@foldkit/ui/slider/index.js#onNone~2"),
|
|
167
|
+
onSome: sliderRoot => __foldkitBrandViewResult((Option.fromNullishOr(sliderRoot.querySelector(thumbSelector))), "@foldkit/ui/slider/index.js#onSome~2"),
|
|
168
|
+
})), "@foldkit/ui/slider/index.js#anonymous~20");
|
|
169
|
+
}))), "@foldkit/ui/slider/index.js#findThumbElementForTrack");
|
|
170
|
+
const edgeInsetForTrack = (track) => {
|
|
171
|
+
if (!isEdgeAlignedTrack(track)) {
|
|
172
|
+
return __foldkitBrandViewResult((0), "@foldkit/ui/slider/index.js#edgeInsetForTrack");
|
|
173
|
+
}
|
|
174
|
+
const maybeThumb = findThumbElementForTrack(track);
|
|
175
|
+
if (Option.isNone(maybeThumb)) {
|
|
176
|
+
return __foldkitBrandViewResult((0), "@foldkit/ui/slider/index.js#edgeInsetForTrack");
|
|
177
|
+
}
|
|
178
|
+
const thumbRect = maybeThumb.value.getBoundingClientRect();
|
|
179
|
+
const thumbSize = isVerticalTrack(track) ? thumbRect.height : thumbRect.width;
|
|
180
|
+
return __foldkitBrandViewResult((thumbSize / 2), "@foldkit/ui/slider/index.js#edgeInsetForTrack");
|
|
181
|
+
};
|
|
182
|
+
const fractionOfPointerPosition = (pointerPosition, trackSize, edgeInset) => {
|
|
183
|
+
const travelSize = trackSize - edgeInset * 2;
|
|
184
|
+
if (travelSize <= 0) {
|
|
185
|
+
return __foldkitBrandViewResult((clamp(pointerPosition / trackSize, 0, 1)), "@foldkit/ui/slider/index.js#fractionOfPointerPosition");
|
|
163
186
|
}
|
|
164
187
|
else {
|
|
165
|
-
|
|
166
|
-
return __foldkitBrandViewResult((min + fraction * (max - min)), "@foldkit/ui/slider/index.js#valueFromClientX");
|
|
188
|
+
return __foldkitBrandViewResult((clamp((pointerPosition - edgeInset) / travelSize, 0, 1)), "@foldkit/ui/slider/index.js#fractionOfPointerPosition");
|
|
167
189
|
}
|
|
168
190
|
};
|
|
169
|
-
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
|
|
191
|
+
/** Maps a pointer position to a Slider value. Vertical tracks place `min` at
|
|
192
|
+
* the bottom and `max` at the top. Edge-aligned tracks measure the rendered
|
|
193
|
+
* thumb and map the pointer across the same inset range it travels through. */
|
|
194
|
+
export const valueFromPointer = (clientX, clientY, track, min, max) => {
|
|
195
|
+
const trackRect = track.getBoundingClientRect();
|
|
196
|
+
if (isVerticalTrack(track)) {
|
|
197
|
+
if (trackRect.height === 0) {
|
|
198
|
+
return __foldkitBrandViewResult((min), "@foldkit/ui/slider/index.js#valueFromPointer");
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const fraction = fractionOfPointerPosition(trackRect.bottom - clientY, trackRect.height, edgeInsetForTrack(track));
|
|
202
|
+
return __foldkitBrandViewResult((min + fraction * (max - min)), "@foldkit/ui/slider/index.js#valueFromPointer");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (trackRect.width === 0) {
|
|
206
|
+
return __foldkitBrandViewResult((min), "@foldkit/ui/slider/index.js#valueFromPointer");
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
const fraction = fractionOfPointerPosition(clientX - trackRect.left, trackRect.width, edgeInsetForTrack(track));
|
|
210
|
+
return __foldkitBrandViewResult((min + fraction * (max - min)), "@foldkit/ui/slider/index.js#valueFromPointer");
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/** Builds Slider drag Subscriptions that find the track through the supplied
|
|
214
|
+
* root resolver. Use this when the Slider is rendered inside a Shadow DOM.
|
|
215
|
+
* The resolver runs at subscription time. */
|
|
173
216
|
export const subscriptionsForRoot = (getTrackRoot) => __foldkitBrandViewResult((Subscription.make()(entry => (__foldkitBrandViewResult(({
|
|
174
217
|
dragPointer: entry({
|
|
175
218
|
dragActivity: DragActivity,
|
|
@@ -184,9 +227,9 @@ export const subscriptionsForRoot = (getTrackRoot) => __foldkitBrandViewResult((
|
|
|
184
227
|
max: model.max,
|
|
185
228
|
}), "@foldkit/ui/slider/index.js#modelToDependencies")),
|
|
186
229
|
dependenciesToStream: ({ dragActivity, id, min, max }) => {
|
|
187
|
-
const pointerEvents = Stream.merge(Stream.fromEventListener(document, 'pointermove').pipe(Stream.mapEffect(event => __foldkitBrandViewResult((Effect.sync(() => __foldkitBrandViewResult((Option.map(
|
|
188
|
-
value:
|
|
189
|
-
})), "@foldkit/ui/slider/index.js#anonymous~
|
|
230
|
+
const pointerEvents = Stream.merge(Stream.fromEventListener(document, 'pointermove').pipe(Stream.mapEffect(event => __foldkitBrandViewResult((Effect.sync(() => __foldkitBrandViewResult((Option.map(findTrackElement(id, getTrackRoot()), track => __foldkitBrandViewResult((Message.MovedDragPointer({
|
|
231
|
+
value: valueFromPointer(event.clientX, event.clientY, track, min, max),
|
|
232
|
+
})), "@foldkit/ui/slider/index.js#anonymous~24"))), "@foldkit/ui/slider/index.js#anonymous~23"))), "@foldkit/ui/slider/index.js#anonymous~22")), Stream.filter(Option.isSome), Stream.map(option => __foldkitBrandViewResult((option.value), "@foldkit/ui/slider/index.js#anonymous~25"))), Stream.fromEventListener(document, 'pointerup').pipe(Stream.map(() => __foldkitBrandViewResult((Message.ReleasedDragPointer()), "@foldkit/ui/slider/index.js#anonymous~26"))));
|
|
190
233
|
// NOTE: prevents text selection and locks cursor to grabbing while the
|
|
191
234
|
// user drags the thumb. Matches the approach used in drag-and-drop.
|
|
192
235
|
const documentDragStyles = Stream.callback(() => __foldkitBrandViewResult((Effect.acquireRelease(Effect.sync(() => {
|
|
@@ -195,54 +238,113 @@ export const subscriptionsForRoot = (getTrackRoot) => __foldkitBrandViewResult((
|
|
|
195
238
|
const cursorStyle = document.createElement('style');
|
|
196
239
|
cursorStyle.textContent = '* { cursor: grabbing !important; }';
|
|
197
240
|
document.head.appendChild(cursorStyle);
|
|
198
|
-
return __foldkitBrandViewResult((cursorStyle), "@foldkit/ui/slider/index.js#anonymous~
|
|
241
|
+
return __foldkitBrandViewResult((cursorStyle), "@foldkit/ui/slider/index.js#anonymous~28");
|
|
199
242
|
}), cursorStyle => __foldkitBrandViewResult((Effect.sync(() => {
|
|
200
243
|
document.documentElement.style.removeProperty('user-select');
|
|
201
244
|
document.documentElement.style.removeProperty('-webkit-user-select');
|
|
202
245
|
cursorStyle.remove();
|
|
203
|
-
})), "@foldkit/ui/slider/index.js#anonymous~
|
|
204
|
-
return __foldkitBrandViewResult((Stream.when(Stream.merge(pointerEvents, documentDragStyles), Effect.sync(() => __foldkitBrandViewResult((dragActivity === 'Active'), "@foldkit/ui/slider/index.js#anonymous~
|
|
246
|
+
})), "@foldkit/ui/slider/index.js#anonymous~29")).pipe(Effect.flatMap(() => __foldkitBrandViewResult((Effect.never), "@foldkit/ui/slider/index.js#anonymous~31")))), "@foldkit/ui/slider/index.js#anonymous~27"));
|
|
247
|
+
return __foldkitBrandViewResult((Stream.when(Stream.merge(pointerEvents, documentDragStyles), Effect.sync(() => __foldkitBrandViewResult((dragActivity === 'Active'), "@foldkit/ui/slider/index.js#anonymous~32")))), "@foldkit/ui/slider/index.js#dependenciesToStream");
|
|
205
248
|
},
|
|
206
249
|
}),
|
|
207
250
|
dragEscape: entry({ dragActivity: DragActivity }, {
|
|
208
251
|
modelToDependencies: model => (__foldkitBrandViewResult(({
|
|
209
252
|
dragActivity: dragActivityFromModel(model),
|
|
210
253
|
}), "@foldkit/ui/slider/index.js#modelToDependencies~2")),
|
|
211
|
-
dependenciesToStream: ({ dragActivity }) => __foldkitBrandViewResult((Stream.when(Stream.fromEventListener(document, 'keydown').pipe(Stream.filter(({ key }) => __foldkitBrandViewResult((key === 'Escape'), "@foldkit/ui/slider/index.js#anonymous~
|
|
254
|
+
dependenciesToStream: ({ dragActivity }) => __foldkitBrandViewResult((Stream.when(Stream.fromEventListener(document, 'keydown').pipe(Stream.filter(({ key }) => __foldkitBrandViewResult((key === 'Escape'), "@foldkit/ui/slider/index.js#anonymous~33")), Stream.map(() => __foldkitBrandViewResult((Message.CancelledDrag()), "@foldkit/ui/slider/index.js#anonymous~34"))), Effect.sync(() => __foldkitBrandViewResult((dragActivity === 'Active'), "@foldkit/ui/slider/index.js#anonymous~35")))), "@foldkit/ui/slider/index.js#dependenciesToStream~2"),
|
|
212
255
|
}),
|
|
213
|
-
}), "@foldkit/ui/slider/index.js#anonymous~
|
|
214
|
-
/** Default drag
|
|
215
|
-
export const subscriptions = subscriptionsForRoot(() => __foldkitBrandViewResult((document), "@foldkit/ui/slider/index.js#anonymous~
|
|
256
|
+
}), "@foldkit/ui/slider/index.js#anonymous~21")))), "@foldkit/ui/slider/index.js#subscriptionsForRoot");
|
|
257
|
+
/** Default drag Subscriptions, with the track looked up via `document`. */
|
|
258
|
+
export const subscriptions = subscriptionsForRoot(() => __foldkitBrandViewResult((document), "@foldkit/ui/slider/index.js#anonymous~36"));
|
|
216
259
|
// VIEW
|
|
217
260
|
const LEFT_MOUSE_BUTTON = 0;
|
|
218
261
|
const labelId = (id) => __foldkitBrandViewResult((`${id}-label`), "@foldkit/ui/slider/index.js#labelId");
|
|
219
|
-
const keyToDirection = (key) => __foldkitBrandViewResult((Match.value(key).pipe(Match.withReturnType(), Match.whenOr('ArrowRight', 'ArrowUp', () => __foldkitBrandViewResult(('StepIncrement'), "@foldkit/ui/slider/index.js#anonymous~
|
|
262
|
+
const keyToDirection = (key) => __foldkitBrandViewResult((Match.value(key).pipe(Match.withReturnType(), Match.whenOr('ArrowRight', 'ArrowUp', () => __foldkitBrandViewResult(('StepIncrement'), "@foldkit/ui/slider/index.js#anonymous~37")), Match.whenOr('ArrowLeft', 'ArrowDown', () => __foldkitBrandViewResult(('StepDecrement'), "@foldkit/ui/slider/index.js#anonymous~38")), Match.when('PageUp', () => __foldkitBrandViewResult(('PageIncrement'), "@foldkit/ui/slider/index.js#anonymous~39")), Match.when('PageDown', () => __foldkitBrandViewResult(('PageDecrement'), "@foldkit/ui/slider/index.js#anonymous~40")), Match.when('Home', () => __foldkitBrandViewResult(('Min'), "@foldkit/ui/slider/index.js#anonymous~41")), Match.when('End', () => __foldkitBrandViewResult(('Max'), "@foldkit/ui/slider/index.js#anonymous~42")), Match.option)), "@foldkit/ui/slider/index.js#keyToDirection");
|
|
220
263
|
const percentString = (fraction) => __foldkitBrandViewResult((`${Math.round(fraction * 10000) / 100}%`), "@foldkit/ui/slider/index.js#percentString");
|
|
264
|
+
/** Direction in which the Slider lays out its track and maps pointer input. */
|
|
265
|
+
export const Orientation = Schema.Literals(['Horizontal', 'Vertical']);
|
|
266
|
+
/** Whether the thumb's center or outer edge aligns with the track endpoints. */
|
|
267
|
+
export const ThumbAlignment = Schema.Literals(['Center', 'Edge']);
|
|
268
|
+
const filledTrackStyle = (orientation, thumbAlignment, thumbSize, fraction) => __foldkitBrandViewResult((Match.value({ orientation, thumbAlignment }).pipe(Match.withReturnType(), Match.when({ orientation: 'Vertical', thumbAlignment: 'Center' }, () => (__foldkitBrandViewResult(({
|
|
269
|
+
position: 'absolute',
|
|
270
|
+
bottom: '0',
|
|
271
|
+
left: '0',
|
|
272
|
+
right: '0',
|
|
273
|
+
height: percentString(fraction),
|
|
274
|
+
width: '100%',
|
|
275
|
+
'pointer-events': 'none',
|
|
276
|
+
}), "@foldkit/ui/slider/index.js#anonymous~43"))), Match.when({ orientation: 'Vertical', thumbAlignment: 'Edge' }, () => (__foldkitBrandViewResult(({
|
|
277
|
+
position: 'absolute',
|
|
278
|
+
bottom: '0',
|
|
279
|
+
left: '0',
|
|
280
|
+
right: '0',
|
|
281
|
+
height: `calc((100% - ${thumbSize}) * ${fraction} + ${thumbSize} / 2)`,
|
|
282
|
+
width: '100%',
|
|
283
|
+
'pointer-events': 'none',
|
|
284
|
+
}), "@foldkit/ui/slider/index.js#anonymous~44"))), Match.when({ orientation: 'Horizontal', thumbAlignment: 'Center' }, () => (__foldkitBrandViewResult(({
|
|
285
|
+
position: 'absolute',
|
|
286
|
+
left: '0',
|
|
287
|
+
top: '0',
|
|
288
|
+
bottom: '0',
|
|
289
|
+
width: percentString(fraction),
|
|
290
|
+
'pointer-events': 'none',
|
|
291
|
+
}), "@foldkit/ui/slider/index.js#anonymous~45"))), Match.when({ orientation: 'Horizontal', thumbAlignment: 'Edge' }, () => (__foldkitBrandViewResult(({
|
|
292
|
+
position: 'absolute',
|
|
293
|
+
left: '0',
|
|
294
|
+
top: '0',
|
|
295
|
+
bottom: '0',
|
|
296
|
+
width: `calc((100% - ${thumbSize}) * ${fraction} + ${thumbSize} / 2)`,
|
|
297
|
+
'pointer-events': 'none',
|
|
298
|
+
}), "@foldkit/ui/slider/index.js#anonymous~46"))), Match.exhaustive)), "@foldkit/ui/slider/index.js#filledTrackStyle");
|
|
299
|
+
const thumbStyle = (orientation, thumbAlignment, thumbSize, fraction) => __foldkitBrandViewResult((Match.value({ orientation, thumbAlignment }).pipe(Match.withReturnType(), Match.when({ orientation: 'Vertical', thumbAlignment: 'Center' }, () => (__foldkitBrandViewResult(({
|
|
300
|
+
position: 'absolute',
|
|
301
|
+
bottom: percentString(fraction),
|
|
302
|
+
left: '50%',
|
|
303
|
+
transform: 'translateX(-50%) translateY(50%)',
|
|
304
|
+
'touch-action': 'none',
|
|
305
|
+
}), "@foldkit/ui/slider/index.js#anonymous~47"))), Match.when({ orientation: 'Vertical', thumbAlignment: 'Edge' }, () => (__foldkitBrandViewResult(({
|
|
306
|
+
position: 'absolute',
|
|
307
|
+
bottom: `calc((100% - ${thumbSize}) * ${fraction})`,
|
|
308
|
+
left: '50%',
|
|
309
|
+
transform: 'translateX(-50%)',
|
|
310
|
+
'touch-action': 'none',
|
|
311
|
+
}), "@foldkit/ui/slider/index.js#anonymous~48"))), Match.when({ orientation: 'Horizontal', thumbAlignment: 'Center' }, () => (__foldkitBrandViewResult(({
|
|
312
|
+
position: 'absolute',
|
|
313
|
+
left: percentString(fraction),
|
|
314
|
+
transform: 'translateX(-50%)',
|
|
315
|
+
'touch-action': 'none',
|
|
316
|
+
}), "@foldkit/ui/slider/index.js#anonymous~49"))), Match.when({ orientation: 'Horizontal', thumbAlignment: 'Edge' }, () => (__foldkitBrandViewResult(({
|
|
317
|
+
position: 'absolute',
|
|
318
|
+
left: `calc((100% - ${thumbSize}) * ${fraction})`,
|
|
319
|
+
'touch-action': 'none',
|
|
320
|
+
}), "@foldkit/ui/slider/index.js#anonymous~50"))), Match.exhaustive)), "@foldkit/ui/slider/index.js#thumbStyle");
|
|
221
321
|
/** Renders an accessible slider by building ARIA attribute groups and
|
|
222
322
|
* delegating layout to the consumer's `toView` callback. Follows the
|
|
223
323
|
* WAI-ARIA slider pattern: role="slider" on the thumb, aria-valuemin /
|
|
224
324
|
* aria-valuemax / aria-valuenow, keyboard navigation by step / page / home /
|
|
225
|
-
* end. Pointer drag is handled by the
|
|
325
|
+
* end. Pointer drag is handled by the Slider's drag Subscriptions. */
|
|
226
326
|
export const view = defineView((model, viewInputs, h) => {
|
|
227
|
-
const { value, formatValue, isDisabled = false, isReadOnly = false, name, getTrackRoot = () => __foldkitBrandViewResult((document), "@foldkit/ui/slider/index.js#anonymous~
|
|
327
|
+
const { value, formatValue, isDisabled = false, isReadOnly = false, name, orientation = 'Horizontal', thumbAlignment = 'Center', thumbSize = '0.75rem', getTrackRoot = () => __foldkitBrandViewResult((document), "@foldkit/ui/slider/index.js#anonymous~52"), } = viewInputs;
|
|
228
328
|
const { id, min, max } = model;
|
|
229
329
|
const isDragging = model.dragState._tag === 'Dragging';
|
|
230
330
|
const fraction = fractionOfValue(value, min, max);
|
|
231
|
-
const handleKeyDown = (key) => __foldkitBrandViewResult((Option.map(keyToDirection(key), direction => __foldkitBrandViewResult((Message.PressedKeyboardNavigation({ direction, value })), "@foldkit/ui/slider/index.js#anonymous~
|
|
232
|
-
const
|
|
233
|
-
value:
|
|
331
|
+
const handleKeyDown = (key) => __foldkitBrandViewResult((Option.map(keyToDirection(key), direction => __foldkitBrandViewResult((Message.PressedKeyboardNavigation({ direction, value })), "@foldkit/ui/slider/index.js#anonymous~53"))), "@foldkit/ui/slider/index.js#handleKeyDown");
|
|
332
|
+
const pressedPointerMessageAt = (clientX, clientY) => __foldkitBrandViewResult((Option.map(findTrackElement(id, getTrackRoot()), track => __foldkitBrandViewResult((Message.PressedPointer({
|
|
333
|
+
value: valueFromPointer(clientX, clientY, track, min, max),
|
|
234
334
|
originValue: value,
|
|
235
|
-
})), "@foldkit/ui/slider/index.js#anonymous~
|
|
236
|
-
const trackPointerHandler = (_pointerType, button, _screenX, _screenY, _timeStamp, clientX) => __foldkitBrandViewResult((pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.flatMap(() => __foldkitBrandViewResult((
|
|
237
|
-
const thumbPointerHandler = (_pointerType, button) => __foldkitBrandViewResult((pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.map(() => __foldkitBrandViewResult((Message.PressedThumb({ originValue: value })), "@foldkit/ui/slider/index.js#anonymous~
|
|
335
|
+
})), "@foldkit/ui/slider/index.js#anonymous~54"))), "@foldkit/ui/slider/index.js#pressedPointerMessageAt");
|
|
336
|
+
const trackPointerHandler = (_pointerType, button, _screenX, _screenY, _timeStamp, clientX, clientY) => __foldkitBrandViewResult((pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.flatMap(() => __foldkitBrandViewResult((pressedPointerMessageAt(clientX, clientY)), "@foldkit/ui/slider/index.js#anonymous~55")))), "@foldkit/ui/slider/index.js#trackPointerHandler");
|
|
337
|
+
const thumbPointerHandler = (_pointerType, button) => __foldkitBrandViewResult((pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.map(() => __foldkitBrandViewResult((Message.PressedThumb({ originValue: value })), "@foldkit/ui/slider/index.js#anonymous~56")))), "@foldkit/ui/slider/index.js#thumbPointerHandler");
|
|
238
338
|
const stateAttributes = [
|
|
239
339
|
...(isDragging ? [h.DataAttribute('dragging', '')] : []),
|
|
240
340
|
...(isDisabled ? [h.DataAttribute('disabled', '')] : []),
|
|
241
341
|
...(isReadOnly ? [h.DataAttribute('readonly', '')] : []),
|
|
242
342
|
];
|
|
343
|
+
const orientationAttributeValue = String.toLowerCase(orientation);
|
|
243
344
|
const rootAttributes = [
|
|
244
345
|
h.DataAttribute('slider-id', id),
|
|
245
|
-
h.DataAttribute('orientation',
|
|
346
|
+
h.DataAttribute('orientation', orientationAttributeValue),
|
|
347
|
+
h.DataAttribute(orientationAttributeValue, ''),
|
|
246
348
|
...stateAttributes,
|
|
247
349
|
];
|
|
248
350
|
const isInteractive = !isDisabled && !isReadOnly;
|
|
@@ -251,19 +353,15 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
251
353
|
: [];
|
|
252
354
|
const trackAttributes = [
|
|
253
355
|
h.DataAttribute('slider-track-id', id),
|
|
356
|
+
h.DataAttribute('orientation', orientationAttributeValue),
|
|
357
|
+
h.DataAttribute(orientationAttributeValue, ''),
|
|
358
|
+
h.DataAttribute('thumb-alignment', String.toLowerCase(thumbAlignment)),
|
|
254
359
|
h.Style({ position: 'relative', 'touch-action': 'none' }),
|
|
255
360
|
...stateAttributes,
|
|
256
361
|
...trackInteractionAttributes,
|
|
257
362
|
];
|
|
258
363
|
const filledTrackAttributes = [
|
|
259
|
-
h.Style(
|
|
260
|
-
position: 'absolute',
|
|
261
|
-
left: '0',
|
|
262
|
-
top: '0',
|
|
263
|
-
bottom: '0',
|
|
264
|
-
width: percentString(fraction),
|
|
265
|
-
'pointer-events': 'none',
|
|
266
|
-
}),
|
|
364
|
+
h.Style(filledTrackStyle(orientation, thumbAlignment, thumbSize, fraction)),
|
|
267
365
|
...stateAttributes,
|
|
268
366
|
];
|
|
269
367
|
const resolveThumbLabel = () => {
|
|
@@ -289,7 +387,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
289
387
|
h.Id(`${id}-thumb`),
|
|
290
388
|
h.Role('slider'),
|
|
291
389
|
h.Tabindex(0),
|
|
292
|
-
h.AriaOrientation(
|
|
390
|
+
h.AriaOrientation(orientationAttributeValue),
|
|
293
391
|
h.AriaValuemin(min),
|
|
294
392
|
h.AriaValuemax(max),
|
|
295
393
|
h.AriaValuenow(value),
|
|
@@ -297,12 +395,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
297
395
|
...thumbLabelAttributes,
|
|
298
396
|
...(isDisabled ? [h.AriaDisabled(true)] : []),
|
|
299
397
|
...(isReadOnly ? [h.AriaReadonly(true)] : []),
|
|
300
|
-
h.Style(
|
|
301
|
-
position: 'absolute',
|
|
302
|
-
left: percentString(fraction),
|
|
303
|
-
transform: 'translateX(-50%)',
|
|
304
|
-
'touch-action': 'none',
|
|
305
|
-
}),
|
|
398
|
+
h.Style(thumbStyle(orientation, thumbAlignment, thumbSize, fraction)),
|
|
306
399
|
...stateAttributes,
|
|
307
400
|
...thumbInteractionAttributes,
|
|
308
401
|
];
|
|
@@ -317,5 +410,5 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
317
410
|
thumb: childAttributes(thumbAttributes),
|
|
318
411
|
label: childAttributes(labelAttributes),
|
|
319
412
|
hiddenInput: childAttributes(hiddenInputAttributes),
|
|
320
|
-
})), "@foldkit/ui/slider/index.js#anonymous~
|
|
413
|
+
})), "@foldkit/ui/slider/index.js#anonymous~51");
|
|
321
414
|
});
|
package/dist/slider/public.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { init, update, reflectRange, view, subscriptions, subscriptionsForRoot, fractionOfValue, snapAndClamp, Model, Message, OutMessage, type PressedThumb, type PressedPointer, type MovedDragPointer, type ReleasedDragPointer, type CancelledDrag, type PressedKeyboardNavigation, } from './index.js';
|
|
1
|
+
export { init, update, reflectRange, view, subscriptions, subscriptionsForRoot, fractionOfValue, snapAndClamp, valueFromPointer, Model, Message, Orientation, OutMessage, ThumbAlignment, type PressedThumb, type PressedPointer, type MovedDragPointer, type ReleasedDragPointer, type CancelledDrag, type PressedKeyboardNavigation, } from './index.js';
|
|
2
2
|
export type { InitConfig, ViewInputs, SliderAttributes } from './index.js';
|
|
3
3
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/slider/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/slider/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,WAAW,EACX,UAAU,EACV,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/slider/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, update, reflectRange, view, subscriptions, subscriptionsForRoot, fractionOfValue, snapAndClamp, Model, Message, OutMessage, } from './index.js';
|
|
1
|
+
export { init, update, reflectRange, view, subscriptions, subscriptionsForRoot, fractionOfValue, snapAndClamp, valueFromPointer, Model, Message, Orientation, OutMessage, ThumbAlignment, } from './index.js';
|
package/dist/switch/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare const descriptionId: (id: string) => string;
|
|
|
67
67
|
*
|
|
68
68
|
* // In update:
|
|
69
69
|
* ToggledNotifications: ({ isChecked }) => ({
|
|
70
|
-
* model:
|
|
70
|
+
* model: modifyFields(model, { notificationsEnabled: () => isChecked }),
|
|
71
71
|
* }),
|
|
72
72
|
* ``` */
|
|
73
73
|
export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
|
package/dist/switch/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export const descriptionId = (id) => __foldkitBrandViewResult((`${id}-descriptio
|
|
|
22
22
|
*
|
|
23
23
|
* // In update:
|
|
24
24
|
* ToggledNotifications: ({ isChecked }) => ({
|
|
25
|
-
* model:
|
|
25
|
+
* model: modifyFields(model, { notificationsEnabled: () => isChecked }),
|
|
26
26
|
* }),
|
|
27
27
|
* ``` */
|
|
28
28
|
export const view = (config, h) => {
|
package/dist/tabs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAS,MAAM,EAAE,MAAM,EAAgB,MAAM,QAAQ,CAAA;AAC3E,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAG9E,OAAO,EAAE,KAAK,IAAI,IAAI,YAAY,EAAc,MAAM,kBAAkB,CAAA;AAKxE,OAAO,EAAE,SAAS,EAAE,qBA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b,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;CACpE,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;mDAiBmD;AACnD,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,MAAM,GAAG,MAAM,OAAK,MAAM,CAAC,KAAK,CAmBpE,CAAA"}
|
package/dist/tabs/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as Command from 'foldkit/command';
|
|
|
4
4
|
import * as Dom from 'foldkit/dom';
|
|
5
5
|
import { childAttributes } from 'foldkit/html';
|
|
6
6
|
import { defineMessageUnion } from 'foldkit/message';
|
|
7
|
-
import {
|
|
7
|
+
import { modifyFields } from 'foldkit/struct';
|
|
8
8
|
import { defineView } from 'foldkit/submodel';
|
|
9
9
|
import { idSelector } from '../internal/selectors.js';
|
|
10
10
|
import { keyToIndex } from '../keyboard.js';
|
|
@@ -65,12 +65,14 @@ export const FocusTab = Command.define('FocusTab', {
|
|
|
65
65
|
* `selectedValue`. */
|
|
66
66
|
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
67
67
|
SelectedTab: ({ index, value }) => (__foldkitBrandViewResult(({
|
|
68
|
-
model:
|
|
68
|
+
model: modifyFields(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tabs/index.js#maybeFocusedIndex") }),
|
|
69
69
|
commands: [FocusTab({ id: model.id, index })],
|
|
70
70
|
outMessage: OutMessage.Selected({ value, index }),
|
|
71
71
|
}), "@foldkit/ui/tabs/index.js#SelectedTab")),
|
|
72
72
|
FocusedTab: ({ index }) => (__foldkitBrandViewResult(({
|
|
73
|
-
model:
|
|
73
|
+
model: modifyFields(model, {
|
|
74
|
+
maybeFocusedIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/tabs/index.js#maybeFocusedIndex~2"),
|
|
75
|
+
}),
|
|
74
76
|
commands: [FocusTab({ id: model.id, index })],
|
|
75
77
|
}), "@foldkit/ui/tabs/index.js#FocusedTab")),
|
|
76
78
|
CompletedFocusTab: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/tabs/index.js#CompletedFocusTab")),
|
|
@@ -65,10 +65,6 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
65
65
|
} | {
|
|
66
66
|
readonly _tag: "GotDialogMessage";
|
|
67
67
|
readonly message: {
|
|
68
|
-
readonly _tag: "RequestedClose";
|
|
69
|
-
} | {
|
|
70
|
-
readonly _tag: "RequestedOpen";
|
|
71
|
-
} | {
|
|
72
68
|
readonly _tag: "CompletedCloseDialog";
|
|
73
69
|
} | {
|
|
74
70
|
readonly _tag: "CompletedReleaseDialogResources";
|
|
@@ -87,6 +83,10 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
87
83
|
} | {
|
|
88
84
|
readonly _tag: "Showed";
|
|
89
85
|
};
|
|
86
|
+
} | {
|
|
87
|
+
readonly _tag: "RequestedClose";
|
|
88
|
+
} | {
|
|
89
|
+
readonly _tag: "RequestedOpen";
|
|
90
90
|
} | {
|
|
91
91
|
readonly _tag: "SucceededAcquireResources";
|
|
92
92
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disabledButton.d.ts","sourceRoot":"","sources":["../../../src/test/apps/disabledButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAGrD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAMxC,eAAO,MAAM,KAAK;;;;;;;;;;;;;EAGhB,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,eAAO,MAAM,OAAO;;;;QAGE,OAAO;;;;;;;;;;;;;;;;;;;;EAC3B,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,eAAO,MAAM,YAAY,EAAE,KAG1B,CAAA;
|
|
1
|
+
{"version":3,"file":"disabledButton.d.ts","sourceRoot":"","sources":["../../../src/test/apps/disabledButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAGrD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAMxC,eAAO,MAAM,KAAK;;;;;;;;;;;;;EAGhB,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,eAAO,MAAM,OAAO;;;;QAGE,OAAO;;;;;;;;;;;;;;;;;;;;EAC3B,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,eAAO,MAAM,YAAY,EAAE,KAG1B,CAAA;AAoBD,eAAO,MAAM,MAAM,UAAW,KAAK,WAAW,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQjD,CAAA;AAeJ,qCAAqC;AACrC,eAAO,MAAM,IAAI,UAAW,KAAK,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAQ5D,CAAA;AAED,uDAAuD;AACvD,eAAO,MAAM,cAAc,UAAW,KAAK,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAyBtE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
2
|
import { Option, Schema } from 'effect';
|
|
3
3
|
import { defineMessageUnion } from 'foldkit/message';
|
|
4
|
-
import {
|
|
4
|
+
import { modifyFields } from 'foldkit/struct';
|
|
5
5
|
import * as Update from 'foldkit/update';
|
|
6
6
|
import * as Dialog from '../../dialog/index.js';
|
|
7
7
|
// MODEL
|
|
@@ -28,13 +28,13 @@ const foldDialogOutMessage = Dialog.OutMessage.match({
|
|
|
28
28
|
const foldDialog = Update.foldChild({
|
|
29
29
|
update: Dialog.update,
|
|
30
30
|
read: (model) => __foldkitBrandViewResult((Option.some(model.dialog)), "@foldkit/ui/test/apps/disabledButton.js#read"),
|
|
31
|
-
write: (model, nextDialog) => __foldkitBrandViewResult((
|
|
31
|
+
write: (model, nextDialog) => __foldkitBrandViewResult((modifyFields(model, { dialog: () => __foldkitBrandViewResult((nextDialog), "@foldkit/ui/test/apps/disabledButton.js#dialog") })), "@foldkit/ui/test/apps/disabledButton.js#write"),
|
|
32
32
|
toParentMessage: message => __foldkitBrandViewResult((Message.GotDialogMessage({ message })), "@foldkit/ui/test/apps/disabledButton.js#toParentMessage"),
|
|
33
33
|
foldOutMessage: foldDialogOutMessage,
|
|
34
34
|
});
|
|
35
35
|
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
36
36
|
ClickedToggle: () => (__foldkitBrandViewResult(({
|
|
37
|
-
model:
|
|
37
|
+
model: modifyFields(model, { isEnabled: isEnabled => __foldkitBrandViewResult((!isEnabled), "@foldkit/ui/test/apps/disabledButton.js#isEnabled") }),
|
|
38
38
|
}), "@foldkit/ui/test/apps/disabledButton.js#ClickedToggle")),
|
|
39
39
|
ClickedSubmit: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/test/apps/disabledButton.js#ClickedSubmit")),
|
|
40
40
|
GotDialogMessage: ({ message: dialogMessage }) => __foldkitBrandViewResult((foldDialog(model, dialogMessage)), "@foldkit/ui/test/apps/disabledButton.js#GotDialogMessage"),
|