foldkit 0.100.1 → 0.102.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/README.md +3 -2
- package/dist/canvas/view.d.ts +1 -1
- package/dist/canvas/view.d.ts.map +1 -1
- package/dist/canvas/view.js +5 -5
- package/dist/command/index.d.ts +71 -0
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +34 -1
- package/dist/command/public.d.ts +1 -1
- package/dist/command/public.d.ts.map +1 -1
- package/dist/command/public.js +1 -1
- package/dist/devTools/overlay.d.ts.map +1 -1
- package/dist/devTools/overlay.js +156 -149
- package/dist/dom/dom.d.ts +8 -11
- package/dist/dom/dom.d.ts.map +1 -1
- package/dist/dom/dom.js +8 -11
- package/dist/dom/elementMovement.d.ts +1 -3
- package/dist/dom/elementMovement.d.ts.map +1 -1
- package/dist/dom/elementMovement.js +1 -3
- package/dist/dom/inert.d.ts +2 -4
- package/dist/dom/inert.d.ts.map +1 -1
- package/dist/dom/inert.js +2 -4
- package/dist/dom/scrollLock.d.ts +2 -2
- package/dist/dom/scrollLock.js +2 -2
- package/dist/dom/waitForAnimation.d.ts +1 -1
- package/dist/dom/waitForAnimation.js +1 -1
- package/dist/html/boundary.d.ts +98 -0
- package/dist/html/boundary.d.ts.map +1 -0
- package/dist/html/boundary.js +176 -0
- package/dist/html/childAttribute.d.ts +44 -0
- package/dist/html/childAttribute.d.ts.map +1 -0
- package/dist/html/childAttribute.js +34 -0
- package/dist/html/index.d.ts +70 -23
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +639 -575
- package/dist/html/lazy.d.ts +12 -7
- package/dist/html/lazy.d.ts.map +1 -1
- package/dist/html/lazy.js +30 -11
- package/dist/html/public.d.ts +2 -2
- package/dist/html/public.d.ts.map +1 -1
- package/dist/html/public.js +1 -1
- package/dist/html/runtimeSingleton.d.ts +72 -0
- package/dist/html/runtimeSingleton.d.ts.map +1 -0
- package/dist/html/runtimeSingleton.js +112 -0
- package/dist/html/submodel.d.ts +98 -0
- package/dist/html/submodel.d.ts.map +1 -0
- package/dist/html/submodel.js +190 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/render/render.d.ts +1 -1
- package/dist/render/render.js +1 -1
- package/dist/runtime/messagePriority.d.ts +5 -1
- package/dist/runtime/messagePriority.d.ts.map +1 -1
- package/dist/runtime/messagePriority.js +25 -4
- package/dist/runtime/runtime.d.ts +11 -11
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +118 -63
- package/dist/runtime/subscription.d.ts +139 -19
- package/dist/runtime/subscription.d.ts.map +1 -1
- package/dist/runtime/subscription.js +90 -9
- package/dist/submodel/public.d.ts +4 -0
- package/dist/submodel/public.d.ts.map +1 -0
- package/dist/submodel/public.js +1 -0
- package/dist/submodel/submodel.d.ts +32 -0
- package/dist/submodel/submodel.d.ts.map +1 -0
- package/dist/submodel/submodel.js +1 -0
- package/dist/subscription/animationFrame.d.ts +23 -26
- package/dist/subscription/animationFrame.d.ts.map +1 -1
- package/dist/subscription/animationFrame.js +17 -18
- package/dist/subscription/public.d.ts +2 -2
- package/dist/subscription/public.d.ts.map +1 -1
- package/dist/subscription/public.js +1 -1
- package/dist/test/apps/disabledButton.d.ts +4 -5
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +16 -16
- package/dist/test/scene.d.ts +8 -8
- package/dist/test/scene.d.ts.map +1 -1
- package/dist/test/scene.js +25 -13
- package/dist/test/story.d.ts +15 -8
- package/dist/test/story.d.ts.map +1 -1
- package/dist/test/story.js +21 -9
- package/dist/ui/animation/index.d.ts +30 -14
- package/dist/ui/animation/index.d.ts.map +1 -1
- package/dist/ui/animation/index.js +9 -19
- package/dist/ui/animation/public.d.ts +2 -2
- package/dist/ui/animation/public.d.ts.map +1 -1
- package/dist/ui/animation/public.js +1 -1
- package/dist/ui/calendar/index.d.ts +199 -84
- package/dist/ui/calendar/index.d.ts.map +1 -1
- package/dist/ui/calendar/index.js +129 -140
- package/dist/ui/calendar/public.d.ts +2 -2
- package/dist/ui/calendar/public.d.ts.map +1 -1
- package/dist/ui/calendar/public.js +1 -1
- package/dist/ui/checkbox/index.d.ts +93 -21
- package/dist/ui/checkbox/index.d.ts.map +1 -1
- package/dist/ui/checkbox/index.js +62 -33
- package/dist/ui/checkbox/public.d.ts +2 -2
- package/dist/ui/checkbox/public.d.ts.map +1 -1
- package/dist/ui/checkbox/public.js +1 -1
- package/dist/ui/combobox/multi.d.ts +35 -91
- package/dist/ui/combobox/multi.d.ts.map +1 -1
- package/dist/ui/combobox/multi.js +34 -17
- package/dist/ui/combobox/multiPublic.d.ts +2 -2
- package/dist/ui/combobox/multiPublic.d.ts.map +1 -1
- package/dist/ui/combobox/multiPublic.js +1 -1
- package/dist/ui/combobox/public.d.ts +3 -3
- package/dist/ui/combobox/public.d.ts.map +1 -1
- package/dist/ui/combobox/public.js +2 -2
- package/dist/ui/combobox/shared.d.ts +56 -31
- package/dist/ui/combobox/shared.d.ts.map +1 -1
- package/dist/ui/combobox/shared.js +333 -322
- package/dist/ui/combobox/single.d.ts +46 -93
- package/dist/ui/combobox/single.d.ts.map +1 -1
- package/dist/ui/combobox/single.js +44 -17
- package/dist/ui/datePicker/index.d.ts +256 -48
- package/dist/ui/datePicker/index.d.ts.map +1 -1
- package/dist/ui/datePicker/index.js +149 -104
- package/dist/ui/datePicker/public.d.ts +2 -2
- package/dist/ui/datePicker/public.d.ts.map +1 -1
- package/dist/ui/datePicker/public.js +1 -1
- package/dist/ui/dialog/index.d.ts +95 -39
- package/dist/ui/dialog/index.d.ts.map +1 -1
- package/dist/ui/dialog/index.js +71 -62
- package/dist/ui/dialog/public.d.ts +2 -2
- package/dist/ui/dialog/public.d.ts.map +1 -1
- package/dist/ui/dialog/public.js +1 -1
- package/dist/ui/disclosure/index.d.ts +71 -31
- package/dist/ui/disclosure/index.d.ts.map +1 -1
- package/dist/ui/disclosure/index.js +57 -62
- package/dist/ui/disclosure/public.d.ts +2 -2
- package/dist/ui/disclosure/public.d.ts.map +1 -1
- package/dist/ui/disclosure/public.js +1 -1
- package/dist/ui/dragAndDrop/index.d.ts +385 -103
- package/dist/ui/dragAndDrop/index.d.ts.map +1 -1
- package/dist/ui/dragAndDrop/index.js +26 -31
- package/dist/ui/dragAndDrop/public.d.ts +1 -1
- package/dist/ui/dragAndDrop/public.d.ts.map +1 -1
- package/dist/ui/dragAndDrop/public.js +1 -1
- package/dist/ui/fileDrop/index.d.ts +42 -46
- package/dist/ui/fileDrop/index.d.ts.map +1 -1
- package/dist/ui/fileDrop/index.js +30 -46
- package/dist/ui/fileDrop/public.d.ts +2 -2
- package/dist/ui/fileDrop/public.d.ts.map +1 -1
- package/dist/ui/fileDrop/public.js +1 -1
- package/dist/ui/listbox/multi.d.ts +39 -84
- package/dist/ui/listbox/multi.d.ts.map +1 -1
- package/dist/ui/listbox/multi.js +38 -20
- package/dist/ui/listbox/multiPublic.d.ts +2 -2
- package/dist/ui/listbox/multiPublic.d.ts.map +1 -1
- package/dist/ui/listbox/multiPublic.js +1 -1
- package/dist/ui/listbox/public.d.ts +3 -3
- package/dist/ui/listbox/public.d.ts.map +1 -1
- package/dist/ui/listbox/public.js +2 -2
- package/dist/ui/listbox/shared.d.ts +71 -30
- package/dist/ui/listbox/shared.d.ts.map +1 -1
- package/dist/ui/listbox/shared.js +319 -296
- package/dist/ui/listbox/single.d.ts +57 -85
- package/dist/ui/listbox/single.d.ts.map +1 -1
- package/dist/ui/listbox/single.js +48 -24
- package/dist/ui/menu/index.d.ts +80 -36
- package/dist/ui/menu/index.d.ts.map +1 -1
- package/dist/ui/menu/index.js +117 -86
- package/dist/ui/menu/public.d.ts +2 -2
- package/dist/ui/menu/public.d.ts.map +1 -1
- package/dist/ui/menu/public.js +1 -1
- package/dist/ui/popover/index.d.ts +117 -44
- package/dist/ui/popover/index.d.ts.map +1 -1
- package/dist/ui/popover/index.js +88 -101
- package/dist/ui/popover/public.d.ts +2 -2
- package/dist/ui/popover/public.d.ts.map +1 -1
- package/dist/ui/popover/public.js +1 -1
- package/dist/ui/radioGroup/index.d.ts +122 -45
- package/dist/ui/radioGroup/index.d.ts.map +1 -1
- package/dist/ui/radioGroup/index.js +111 -72
- package/dist/ui/radioGroup/public.d.ts +2 -2
- package/dist/ui/radioGroup/public.d.ts.map +1 -1
- package/dist/ui/radioGroup/public.js +1 -1
- package/dist/ui/slider/index.d.ts +247 -103
- package/dist/ui/slider/index.d.ts.map +1 -1
- package/dist/ui/slider/index.js +52 -68
- package/dist/ui/slider/public.d.ts +2 -2
- package/dist/ui/slider/public.d.ts.map +1 -1
- package/dist/ui/slider/public.js +1 -1
- package/dist/ui/switch/index.d.ts +74 -21
- package/dist/ui/switch/index.d.ts.map +1 -1
- package/dist/ui/switch/index.js +62 -33
- package/dist/ui/switch/public.d.ts +2 -2
- package/dist/ui/switch/public.d.ts.map +1 -1
- package/dist/ui/switch/public.js +1 -1
- package/dist/ui/tabs/index.d.ts +107 -45
- package/dist/ui/tabs/index.d.ts.map +1 -1
- package/dist/ui/tabs/index.js +99 -81
- package/dist/ui/tabs/public.d.ts +2 -2
- package/dist/ui/tabs/public.d.ts.map +1 -1
- package/dist/ui/tabs/public.js +1 -1
- package/dist/ui/toast/index.d.ts +93 -109
- package/dist/ui/toast/index.d.ts.map +1 -1
- package/dist/ui/toast/index.js +16 -29
- package/dist/ui/toast/schema.d.ts +15 -4
- package/dist/ui/toast/schema.d.ts.map +1 -1
- package/dist/ui/toast/schema.js +11 -4
- package/dist/ui/toast/update.d.ts +36 -18
- package/dist/ui/toast/update.d.ts.map +1 -1
- package/dist/ui/toast/update.js +33 -14
- package/dist/ui/tooltip/index.d.ts +94 -42
- package/dist/ui/tooltip/index.d.ts.map +1 -1
- package/dist/ui/tooltip/index.js +64 -73
- package/dist/ui/tooltip/public.d.ts +2 -2
- package/dist/ui/tooltip/public.d.ts.map +1 -1
- package/dist/ui/tooltip/public.js +1 -1
- package/dist/ui/virtualList/index.d.ts +63 -80
- package/dist/ui/virtualList/index.d.ts.map +1 -1
- package/dist/ui/virtualList/index.js +22 -49
- package/dist/ui/virtualList/public.d.ts +2 -2
- package/dist/ui/virtualList/public.d.ts.map +1 -1
- package/dist/ui/virtualList/public.js +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import * as Command from '../../command/index.js';
|
|
|
3
3
|
import * as Dom from '../../dom/index.js';
|
|
4
4
|
import { html } from '../../html/index.js';
|
|
5
5
|
import { m } from '../../message/index.js';
|
|
6
|
-
import
|
|
6
|
+
import * as Subscription from '../../runtime/subscription.js';
|
|
7
7
|
import { ts } from '../../schema/index.js';
|
|
8
8
|
import { evo } from '../../struct/index.js';
|
|
9
9
|
// MODEL
|
|
@@ -96,7 +96,7 @@ export const PressedArrowKey = m('PressedArrowKey', {
|
|
|
96
96
|
]),
|
|
97
97
|
});
|
|
98
98
|
/** An animation frame fired during auto-scroll. */
|
|
99
|
-
export const
|
|
99
|
+
export const AdvancedAutoScrollFrame = m('AdvancedAutoScrollFrame');
|
|
100
100
|
/** The FocusItem Command completed. */
|
|
101
101
|
export const CompletedFocusItem = m('CompletedFocusItem');
|
|
102
102
|
/** Union of all messages the drag-and-drop component can produce. */
|
|
@@ -109,12 +109,12 @@ export const Message = S.Union([
|
|
|
109
109
|
ResolvedKeyboardMove,
|
|
110
110
|
ConfirmedKeyboardDrop,
|
|
111
111
|
PressedArrowKey,
|
|
112
|
-
|
|
112
|
+
AdvancedAutoScrollFrame,
|
|
113
113
|
CompletedFocusItem,
|
|
114
114
|
]);
|
|
115
115
|
// OUT MESSAGE
|
|
116
116
|
/** Emitted when a drag completes with a valid drop target. The parent uses this to commit the reorder. */
|
|
117
|
-
export const Reordered =
|
|
117
|
+
export const Reordered = m('Reordered', {
|
|
118
118
|
itemId: S.String,
|
|
119
119
|
fromContainerId: S.String,
|
|
120
120
|
fromIndex: S.Number,
|
|
@@ -122,7 +122,7 @@ export const Reordered = ts('Reordered', {
|
|
|
122
122
|
toIndex: S.Number,
|
|
123
123
|
});
|
|
124
124
|
/** Emitted when a drag is cancelled via Escape or pointer release without a drop target. */
|
|
125
|
-
export const Cancelled =
|
|
125
|
+
export const Cancelled = m('Cancelled');
|
|
126
126
|
/** Union of all out-messages the drag-and-drop component can emit to its parent. */
|
|
127
127
|
export const OutMessage = S.Union([Reordered, Cancelled]);
|
|
128
128
|
// INIT
|
|
@@ -323,7 +323,7 @@ export const update = (model, message) => M.value(message).pipe(withUpdateReturn
|
|
|
323
323
|
],
|
|
324
324
|
Option.none(),
|
|
325
325
|
]), M.orElse(() => [model, [], Option.none()])),
|
|
326
|
-
|
|
326
|
+
AdvancedAutoScrollFrame: () => [model, [], Option.none()],
|
|
327
327
|
CompletedFocusItem: () => [model, [], Option.none()],
|
|
328
328
|
}));
|
|
329
329
|
// SUBSCRIPTION
|
|
@@ -365,22 +365,12 @@ const autoScroll = (clientY) => {
|
|
|
365
365
|
const pointerDragActivityFromModel = (model) => M.value(model.dragState).pipe(M.withReturnType(), M.tag('Pending', 'Dragging', () => 'Active'), M.orElse(() => 'Idle'));
|
|
366
366
|
const dragActivityFromModel = (model) => M.value(model.dragState).pipe(M.withReturnType(), M.tag('Idle', () => 'Idle'), M.orElse(() => 'Active'));
|
|
367
367
|
const keyboardDragActivityFromModel = (model) => M.value(model.dragState).pipe(M.withReturnType(), M.tag('KeyboardDragging', () => 'Active'), M.orElse(() => 'Idle'));
|
|
368
|
-
/**
|
|
369
|
-
export const
|
|
370
|
-
documentPointer:
|
|
368
|
+
/** Document-level subscriptions for pointer and keyboard events during drag operations. */
|
|
369
|
+
export const subscriptions = Subscription.make()(entry => ({
|
|
370
|
+
documentPointer: entry({
|
|
371
371
|
dragActivity: PointerDragActivity,
|
|
372
372
|
orientation: Orientation,
|
|
373
|
-
}
|
|
374
|
-
documentEscape: S.Struct({ dragActivity: DragActivity }),
|
|
375
|
-
documentKeyboard: S.Struct({ dragActivity: KeyboardDragActivity }),
|
|
376
|
-
autoScroll: S.Struct({
|
|
377
|
-
isDragging: S.Boolean,
|
|
378
|
-
clientY: S.Number,
|
|
379
|
-
}),
|
|
380
|
-
});
|
|
381
|
-
/** Document-level subscriptions for pointer and keyboard events during drag operations. */
|
|
382
|
-
export const subscriptions = makeSubscriptions(SubscriptionDependencies)({
|
|
383
|
-
documentPointer: {
|
|
373
|
+
}, {
|
|
384
374
|
modelToDependencies: model => ({
|
|
385
375
|
dragActivity: pointerDragActivityFromModel(model),
|
|
386
376
|
orientation: model.orientation,
|
|
@@ -410,20 +400,20 @@ export const subscriptions = makeSubscriptions(SubscriptionDependencies)({
|
|
|
410
400
|
})).pipe(Effect.flatMap(() => Effect.never)));
|
|
411
401
|
return Stream.when(Stream.merge(pointerEvents, documentDragStyles), Effect.sync(() => dragActivity === 'Active'));
|
|
412
402
|
},
|
|
413
|
-
},
|
|
414
|
-
documentEscape: {
|
|
403
|
+
}),
|
|
404
|
+
documentEscape: entry({ dragActivity: DragActivity }, {
|
|
415
405
|
modelToDependencies: model => ({
|
|
416
406
|
dragActivity: dragActivityFromModel(model),
|
|
417
407
|
}),
|
|
418
408
|
dependenciesToStream: ({ dragActivity }) => Stream.when(Stream.fromEventListener(document, 'keydown').pipe(Stream.filter(({ key }) => key === 'Escape'), Stream.map(() => CancelledDrag())), Effect.sync(() => dragActivity === 'Active')),
|
|
419
|
-
},
|
|
420
|
-
documentKeyboard: {
|
|
409
|
+
}),
|
|
410
|
+
documentKeyboard: entry({ dragActivity: KeyboardDragActivity }, {
|
|
421
411
|
modelToDependencies: model => ({
|
|
422
412
|
dragActivity: keyboardDragActivityFromModel(model),
|
|
423
413
|
}),
|
|
424
414
|
dependenciesToStream: ({ dragActivity }) => Stream.when(Stream.fromEventListener(document, 'keydown').pipe(Stream.mapEffect((event) => Effect.sync(() => {
|
|
425
415
|
// NOTE: the draggable's OnKeyDownPreventDefault calls preventDefault on
|
|
426
|
-
// the Space that activates keyboard drag
|
|
416
|
+
// the Space that activates keyboard drag. Skip it here so the same
|
|
427
417
|
// keypress doesn't also confirm the drop in the same tick.
|
|
428
418
|
if (event.defaultPrevented) {
|
|
429
419
|
return Option.none();
|
|
@@ -445,27 +435,32 @@ export const subscriptions = makeSubscriptions(SubscriptionDependencies)({
|
|
|
445
435
|
return PressedArrowKey({ direction });
|
|
446
436
|
});
|
|
447
437
|
})), Stream.filter(Option.isSome), Stream.map(option => option.value)), Effect.sync(() => dragActivity === 'Active')),
|
|
448
|
-
},
|
|
449
|
-
autoScroll: {
|
|
438
|
+
}),
|
|
439
|
+
autoScroll: entry({
|
|
440
|
+
isDragging: S.Boolean,
|
|
441
|
+
clientY: S.Number,
|
|
442
|
+
}, {
|
|
450
443
|
modelToDependencies: model => ({
|
|
451
444
|
isDragging: model.dragState._tag === 'Dragging',
|
|
452
445
|
clientY: model.dragState._tag === 'Dragging'
|
|
453
446
|
? model.dragState.current.clientY
|
|
454
447
|
: 0,
|
|
455
448
|
}),
|
|
456
|
-
|
|
449
|
+
keepAliveEquivalence: Equivalence.Struct({
|
|
450
|
+
isDragging: Equivalence.Boolean,
|
|
451
|
+
}),
|
|
457
452
|
dependenciesToStream: ({ isDragging }, readDependencies) => Stream.when(Stream.callback(queue => Effect.acquireRelease(Effect.sync(() => {
|
|
458
453
|
const ref = { id: 0 };
|
|
459
454
|
const step = () => {
|
|
460
455
|
autoScroll(readDependencies().clientY);
|
|
461
|
-
Queue.offerUnsafe(queue,
|
|
456
|
+
Queue.offerUnsafe(queue, AdvancedAutoScrollFrame());
|
|
462
457
|
ref.id = requestAnimationFrame(step);
|
|
463
458
|
};
|
|
464
459
|
ref.id = requestAnimationFrame(step);
|
|
465
460
|
return ref;
|
|
466
461
|
}), ref => Effect.sync(() => cancelAnimationFrame(ref.id))).pipe(Effect.flatMap(() => Effect.never))), Effect.sync(() => isDragging)),
|
|
467
|
-
},
|
|
468
|
-
});
|
|
462
|
+
}),
|
|
463
|
+
}));
|
|
469
464
|
// VIEW
|
|
470
465
|
const LEFT_MOUSE_BUTTON = 0;
|
|
471
466
|
const arrowKeyToDirection = (key) => M.value(key).pipe(M.withReturnType(), M.when('ArrowUp', () => 'Up'), M.when('ArrowDown', () => 'Down'), M.when('ArrowLeft', () => 'Left'), M.when('ArrowRight', () => 'Right'), M.option);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { init, update, draggable, droppable, sortable, ghostStyle, isDragging, maybeDraggedItemId, maybeDropTarget, subscriptions,
|
|
1
|
+
export { init, update, draggable, droppable, sortable, ghostStyle, isDragging, maybeDraggedItemId, maybeDropTarget, subscriptions, Model, Message, OutMessage, PressedDraggable, MovedPointer, ReleasedPointer, CancelledDrag, ActivatedKeyboardDrag, ResolvedKeyboardMove, ConfirmedKeyboardDrop, PressedArrowKey, AdvancedAutoScrollFrame, CompletedFocusItem, FocusItem, ResolveKeyboardMove, Reordered, Cancelled, } from './index.js';
|
|
2
2
|
export type { InitConfig, DraggableConfig, DraggableMessage } from './index.js';
|
|
3
3
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/dragAndDrop/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/dragAndDrop/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,KAAK,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, update, draggable, droppable, sortable, ghostStyle, isDragging, maybeDraggedItemId, maybeDropTarget, subscriptions,
|
|
1
|
+
export { init, update, draggable, droppable, sortable, ghostStyle, isDragging, maybeDraggedItemId, maybeDropTarget, subscriptions, Model, Message, OutMessage, PressedDraggable, MovedPointer, ReleasedPointer, CancelledDrag, ActivatedKeyboardDrag, ResolvedKeyboardMove, ConfirmedKeyboardDrop, PressedArrowKey, AdvancedAutoScrollFrame, CompletedFocusItem, FocusItem, ResolveKeyboardMove, Reordered, Cancelled, } from './index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option, Schema as S } from 'effect';
|
|
2
2
|
import * as Command from '../../command/index.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type ChildAttribute, type Html } from '../../html/index.js';
|
|
4
4
|
/** Schema for the file-drop component's state.
|
|
5
5
|
*
|
|
6
6
|
* `isDragOver` controls the `data-drag-over` attribute on the root while a
|
|
@@ -25,16 +25,16 @@ export declare const LeftDragZone: import("../../schema/index.js").CallableTagge
|
|
|
25
25
|
export declare const DroppedFiles: import("../../schema/index.js").CallableTaggedStruct<"DroppedFiles", {
|
|
26
26
|
files: S.NonEmptyArray<S.Schema<File>>;
|
|
27
27
|
}>;
|
|
28
|
-
/** Sent when a drop or input-change event fires without any files
|
|
28
|
+
/** Sent when a drop or input-change event fires without any files,
|
|
29
29
|
* typically a drag of non-file data (text, URLs, images from another
|
|
30
|
-
* page). Resets `isDragOver` and emits `
|
|
30
|
+
* page). Resets `isDragOver` and emits `RejectedNonFiles` as an
|
|
31
31
|
* OutMessage so the consumer can surface a message (e.g. "Only files are
|
|
32
32
|
* accepted"). */
|
|
33
|
-
export declare const
|
|
33
|
+
export declare const DroppedNonFiles: import("../../schema/index.js").CallableTaggedStruct<"DroppedNonFiles", {}>;
|
|
34
34
|
/** Union of all messages the file-drop component can produce. */
|
|
35
35
|
export declare const Message: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"EnteredDragZone", {}>, import("../../schema/index.js").CallableTaggedStruct<"LeftDragZone", {}>, import("../../schema/index.js").CallableTaggedStruct<"DroppedFiles", {
|
|
36
36
|
files: S.NonEmptyArray<S.Schema<File>>;
|
|
37
|
-
}>, import("../../schema/index.js").CallableTaggedStruct<"
|
|
37
|
+
}>, import("../../schema/index.js").CallableTaggedStruct<"DroppedNonFiles", {}>]>;
|
|
38
38
|
export type Message = typeof Message.Type;
|
|
39
39
|
/** Emitted when files arrive via drop or input-change. The consumer's
|
|
40
40
|
* parent update handles this to process the files (validate, upload,
|
|
@@ -42,14 +42,15 @@ export type Message = typeof Message.Type;
|
|
|
42
42
|
export declare const ReceivedFiles: import("../../schema/index.js").CallableTaggedStruct<"ReceivedFiles", {
|
|
43
43
|
files: S.NonEmptyArray<S.Schema<File>>;
|
|
44
44
|
}>;
|
|
45
|
+
/** Emitted when a drop or input-change event produces no files. The
|
|
46
|
+
* consumer's parent update handles this to surface a message (e.g. "Only
|
|
47
|
+
* files are accepted"). */
|
|
48
|
+
export declare const RejectedNonFiles: import("../../schema/index.js").CallableTaggedStruct<"RejectedNonFiles", {}>;
|
|
45
49
|
/** The file-drop component's OutMessages: `ReceivedFiles` on the happy
|
|
46
|
-
* path and `
|
|
47
|
-
* `DroppedWithoutFiles` is reused from the Message definitions — the
|
|
48
|
-
* fact is the same whether the component is handling it or reporting it
|
|
49
|
-
* up. */
|
|
50
|
+
* path and `RejectedNonFiles` when a drop event fires without files. */
|
|
50
51
|
export declare const OutMessage: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"ReceivedFiles", {
|
|
51
52
|
files: S.NonEmptyArray<S.Schema<File>>;
|
|
52
|
-
}>, import("../../schema/index.js").CallableTaggedStruct<"
|
|
53
|
+
}>, import("../../schema/index.js").CallableTaggedStruct<"RejectedNonFiles", {}>]>;
|
|
53
54
|
export type OutMessage = typeof OutMessage.Type;
|
|
54
55
|
/** Configuration for creating a file-drop model with `init`. */
|
|
55
56
|
export type InitConfig = Readonly<{
|
|
@@ -66,48 +67,43 @@ type UpdateReturn = readonly [
|
|
|
66
67
|
* and optional OutMessage. */
|
|
67
68
|
export declare const update: (model: Model, message: Message) => UpdateReturn;
|
|
68
69
|
/** Attribute groups the file-drop component provides to the consumer's
|
|
69
|
-
*
|
|
70
|
-
|
|
71
|
-
* hidden input, `input` on the `<input type="file">`. */
|
|
72
|
-
export type FileDropAttributes<ParentMessage> = Readonly<{
|
|
70
|
+
* `toView` callback. */
|
|
71
|
+
export type FileDropAttributes = Readonly<{
|
|
73
72
|
/** Attributes for the outer drop zone element (typically a `<label>`):
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
root: ReadonlyArray<
|
|
73
|
+
* drag-and-drop handlers, `data-drag-over` while a drag hovers, and
|
|
74
|
+
* `data-disabled` when disabled. */
|
|
75
|
+
root: ReadonlyArray<ChildAttribute>;
|
|
77
76
|
/** Attributes for a hidden `<input type="file">` nested inside the
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
input: ReadonlyArray<
|
|
77
|
+
* root: file-change handler, `type`, `id`, `multiple`, `accept`, and
|
|
78
|
+
* `sr-only` class. */
|
|
79
|
+
input: ReadonlyArray<ChildAttribute>;
|
|
81
80
|
}>;
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* FileDrop's. `toParentMessage` receives a FileDrop message and returns
|
|
86
|
-
* your parent message. */
|
|
87
|
-
export type ViewConfig<ParentMessage> = Readonly<{
|
|
88
|
-
model: Model;
|
|
89
|
-
toParentMessage: (message: Message) => ParentMessage;
|
|
90
|
-
toView: (attributes: FileDropAttributes<ParentMessage>) => Html;
|
|
91
|
-
/** List of accepted MIME types or file extensions (e.g.
|
|
92
|
-
* `['application/pdf', '.doc']`). Joined with commas and forwarded to
|
|
93
|
-
* the hidden input's `accept` attribute. Omit or pass an empty array
|
|
94
|
-
* to accept any file type. */
|
|
81
|
+
/** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field. */
|
|
82
|
+
export type ViewInputs = Readonly<{
|
|
83
|
+
toView: (attributes: FileDropAttributes) => Html;
|
|
95
84
|
accept?: ReadonlyArray<string>;
|
|
96
|
-
/** When true, the hidden input accepts multiple files per selection. */
|
|
97
85
|
multiple?: boolean;
|
|
98
|
-
/** When true, drag handlers are stripped from the root and the input
|
|
99
|
-
* is disabled. Styling can react via `data-disabled` on the root. */
|
|
100
86
|
isDisabled?: boolean;
|
|
101
87
|
}>;
|
|
102
|
-
/** Renders an accessible file-drop zone by
|
|
103
|
-
* a `<label>`-wrapped hidden file input.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
88
|
+
/** Renders an accessible file-drop zone by publishing attribute groups
|
|
89
|
+
* for a `<label>`-wrapped hidden file input. */
|
|
90
|
+
export declare const view: import("../../html/submodel.js").SubmodelView<{
|
|
91
|
+
readonly id: string;
|
|
92
|
+
readonly isDragOver: boolean;
|
|
93
|
+
}, {
|
|
94
|
+
readonly _tag: "EnteredDragZone";
|
|
95
|
+
} | {
|
|
96
|
+
readonly _tag: "LeftDragZone";
|
|
97
|
+
} | {
|
|
98
|
+
readonly _tag: "DroppedFiles";
|
|
99
|
+
readonly files: readonly [File, ...File[]];
|
|
100
|
+
} | {
|
|
101
|
+
readonly _tag: "DroppedNonFiles";
|
|
102
|
+
}, Readonly<{
|
|
103
|
+
toView: (attributes: FileDropAttributes) => Html;
|
|
104
|
+
accept?: ReadonlyArray<string>;
|
|
105
|
+
multiple?: boolean;
|
|
106
|
+
isDisabled?: boolean;
|
|
107
|
+
}>>;
|
|
112
108
|
export {};
|
|
113
109
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/fileDrop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/D,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AAEjD,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/fileDrop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/D,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AAEjD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EAIV,MAAM,qBAAqB,CAAA;AAM5B;;;;;iEAKiE;AACjE,eAAO,MAAM,KAAK;;;EAGhB,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC;oDACoD;AACpD,eAAO,MAAM,eAAe,6EAAuB,CAAA;AACnD;iCACiC;AACjC,eAAO,MAAM,YAAY,0EAAoB,CAAA;AAC7C;;;iBAGiB;AACjB,eAAO,MAAM,YAAY;;EAEvB,CAAA;AACF;;;;iBAIiB;AACjB,eAAO,MAAM,eAAe,6EAAuB,CAAA;AAEnD,iEAAiE;AACjE,eAAO,MAAM,OAAO;;iFAKlB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC;;yDAEyD;AACzD,eAAO,MAAM,aAAa;;EAExB,CAAA;AAEF;;2BAE2B;AAC3B,eAAO,MAAM,gBAAgB,8EAAwB,CAAA;AAErD;wEACwE;AACxE,eAAO,MAAM,UAAU;;kFAA6C,CAAA;AACpE,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA;AAI/C,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,EAAE,EAAE,MAAM,CAAA;CACX,CAAC,CAAA;AAEF,qEAAqE;AACrE,eAAO,MAAM,IAAI,GAAI,QAAQ,UAAU,KAAG,KAGxC,CAAA;AAIF,KAAK,YAAY,GAAG,SAAS;IAC3B,KAAK;IACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;CAC1B,CAAA;AAED;8BAC8B;AAC9B,eAAO,MAAM,MAAM,GAAI,OAAO,KAAK,EAAE,SAAS,OAAO,KAAG,YAyBrD,CAAA;AAIH;yBACyB;AACzB,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC;;yCAEqC;IACrC,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACnC;;2BAEuB;IACvB,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CACrC,CAAC,CAAA;AAEF,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,CAAC,UAAU,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAChD,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAC,CAAA;AAQF;iDACiD;AACjD,eAAO,MAAM,IAAI;;;;;;;;;;;;;YAdP,CAAC,UAAU,EAAE,kBAAkB,KAAK,IAAI;aACvC,aAAa,CAAC,MAAM,CAAC;eACnB,OAAO;iBACL,OAAO;GAmDrB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array, Match as M, Option, Schema as S } from 'effect';
|
|
2
2
|
import * as File from '../../file/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { childAttributes, defineView, html, } from '../../html/index.js';
|
|
4
4
|
import { m } from '../../message/index.js';
|
|
5
5
|
import { evo } from '../../struct/index.js';
|
|
6
6
|
// MODEL
|
|
@@ -28,18 +28,18 @@ export const LeftDragZone = m('LeftDragZone');
|
|
|
28
28
|
export const DroppedFiles = m('DroppedFiles', {
|
|
29
29
|
files: S.NonEmptyArray(File.File),
|
|
30
30
|
});
|
|
31
|
-
/** Sent when a drop or input-change event fires without any files
|
|
31
|
+
/** Sent when a drop or input-change event fires without any files,
|
|
32
32
|
* typically a drag of non-file data (text, URLs, images from another
|
|
33
|
-
* page). Resets `isDragOver` and emits `
|
|
33
|
+
* page). Resets `isDragOver` and emits `RejectedNonFiles` as an
|
|
34
34
|
* OutMessage so the consumer can surface a message (e.g. "Only files are
|
|
35
35
|
* accepted"). */
|
|
36
|
-
export const
|
|
36
|
+
export const DroppedNonFiles = m('DroppedNonFiles');
|
|
37
37
|
/** Union of all messages the file-drop component can produce. */
|
|
38
38
|
export const Message = S.Union([
|
|
39
39
|
EnteredDragZone,
|
|
40
40
|
LeftDragZone,
|
|
41
41
|
DroppedFiles,
|
|
42
|
-
|
|
42
|
+
DroppedNonFiles,
|
|
43
43
|
]);
|
|
44
44
|
// OUT MESSAGE
|
|
45
45
|
/** Emitted when files arrive via drop or input-change. The consumer's
|
|
@@ -48,12 +48,13 @@ export const Message = S.Union([
|
|
|
48
48
|
export const ReceivedFiles = m('ReceivedFiles', {
|
|
49
49
|
files: S.NonEmptyArray(File.File),
|
|
50
50
|
});
|
|
51
|
+
/** Emitted when a drop or input-change event produces no files. The
|
|
52
|
+
* consumer's parent update handles this to surface a message (e.g. "Only
|
|
53
|
+
* files are accepted"). */
|
|
54
|
+
export const RejectedNonFiles = m('RejectedNonFiles');
|
|
51
55
|
/** The file-drop component's OutMessages: `ReceivedFiles` on the happy
|
|
52
|
-
* path and `
|
|
53
|
-
|
|
54
|
-
* fact is the same whether the component is handling it or reporting it
|
|
55
|
-
* up. */
|
|
56
|
-
export const OutMessage = S.Union([ReceivedFiles, DroppedWithoutFiles]);
|
|
56
|
+
* path and `RejectedNonFiles` when a drop event fires without files. */
|
|
57
|
+
export const OutMessage = S.Union([ReceivedFiles, RejectedNonFiles]);
|
|
57
58
|
/** Creates an initial file-drop model. Drag state starts cleared. */
|
|
58
59
|
export const init = (config) => ({
|
|
59
60
|
id: config.id,
|
|
@@ -77,20 +78,22 @@ export const update = (model, message) => M.value(message).pipe(M.withReturnType
|
|
|
77
78
|
[],
|
|
78
79
|
Option.some(ReceivedFiles({ files })),
|
|
79
80
|
],
|
|
80
|
-
|
|
81
|
+
DroppedNonFiles: () => [
|
|
81
82
|
evo(model, { isDragOver: () => false }),
|
|
82
83
|
[],
|
|
83
|
-
Option.some(
|
|
84
|
+
Option.some(RejectedNonFiles()),
|
|
84
85
|
],
|
|
85
86
|
}));
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
const dispatchDroppedFiles = (files) => Array.match(files, {
|
|
88
|
+
onEmpty: () => DroppedNonFiles(),
|
|
89
|
+
onNonEmpty: nonEmptyFiles => DroppedFiles({ files: [...nonEmptyFiles] }),
|
|
90
|
+
});
|
|
91
|
+
/** Renders an accessible file-drop zone by publishing attribute groups
|
|
92
|
+
* for a `<label>`-wrapped hidden file input. */
|
|
93
|
+
export const view = defineView((model, viewInputs) => {
|
|
92
94
|
const h = html();
|
|
93
|
-
const {
|
|
95
|
+
const { id, isDragOver } = model;
|
|
96
|
+
const { toView, accept, multiple = false, isDisabled = false } = viewInputs;
|
|
94
97
|
const stateAttributes = [
|
|
95
98
|
...(isDragOver ? [h.DataAttribute('drag-over', '')] : []),
|
|
96
99
|
...(isDisabled ? [h.DataAttribute('disabled', '')] : []),
|
|
@@ -99,13 +102,10 @@ export const view = (config) => {
|
|
|
99
102
|
? stateAttributes
|
|
100
103
|
: [
|
|
101
104
|
...stateAttributes,
|
|
102
|
-
h.OnDragEnter(
|
|
103
|
-
h.OnDragLeave(
|
|
105
|
+
h.OnDragEnter(EnteredDragZone()),
|
|
106
|
+
h.OnDragLeave(LeftDragZone()),
|
|
104
107
|
h.AllowDrop(),
|
|
105
|
-
h.OnDropFiles(
|
|
106
|
-
onEmpty: () => DroppedWithoutFiles(),
|
|
107
|
-
onNonEmpty: nonEmptyFiles => DroppedFiles({ files: [...nonEmptyFiles] }),
|
|
108
|
-
}))),
|
|
108
|
+
h.OnDropFiles(dispatchDroppedFiles),
|
|
109
109
|
];
|
|
110
110
|
const inputAttributes = [
|
|
111
111
|
h.Id(id),
|
|
@@ -117,26 +117,10 @@ export const view = (config) => {
|
|
|
117
117
|
: []),
|
|
118
118
|
...(isDisabled
|
|
119
119
|
? [h.Disabled(true)]
|
|
120
|
-
: [
|
|
121
|
-
h.OnFileChange(files => toParentMessage(Array.match(files, {
|
|
122
|
-
onEmpty: () => DroppedWithoutFiles(),
|
|
123
|
-
onNonEmpty: nonEmptyFiles => DroppedFiles({ files: [...nonEmptyFiles] }),
|
|
124
|
-
}))),
|
|
125
|
-
]),
|
|
120
|
+
: [h.OnFileChange(dispatchDroppedFiles)]),
|
|
126
121
|
];
|
|
127
|
-
return
|
|
128
|
-
root: rootAttributes,
|
|
129
|
-
input: inputAttributes,
|
|
122
|
+
return toView({
|
|
123
|
+
root: childAttributes(rootAttributes),
|
|
124
|
+
input: childAttributes(inputAttributes),
|
|
130
125
|
});
|
|
131
|
-
};
|
|
132
|
-
/** Creates a memoized file-drop view. Static config is captured in a
|
|
133
|
-
* closure; only `model` and `toParentMessage` are compared per render via
|
|
134
|
-
* `createLazy`. */
|
|
135
|
-
export const lazy = (staticConfig) => {
|
|
136
|
-
const lazyView = createLazy();
|
|
137
|
-
return (model, toParentMessage) => lazyView((currentModel, currentToParentMessage) => view({
|
|
138
|
-
...staticConfig,
|
|
139
|
-
model: currentModel,
|
|
140
|
-
toParentMessage: currentToParentMessage,
|
|
141
|
-
}), [model, toParentMessage]);
|
|
142
|
-
};
|
|
126
|
+
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { init, update, view,
|
|
2
|
-
export type { InitConfig,
|
|
1
|
+
export { init, update, view, Model, Message, OutMessage, ReceivedFiles, EnteredDragZone, LeftDragZone, DroppedFiles, DroppedNonFiles, RejectedNonFiles, } from './index.js';
|
|
2
|
+
export type { InitConfig, ViewInputs, FileDropAttributes } from './index.js';
|
|
3
3
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/fileDrop/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/fileDrop/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,EACP,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, update, view,
|
|
1
|
+
export { init, update, view, Model, Message, OutMessage, ReceivedFiles, EnteredDragZone, LeftDragZone, DroppedFiles, DroppedNonFiles, RejectedNonFiles, } from './index.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Option, Schema as S } from 'effect';
|
|
2
2
|
import type * as Command from '../../command/index.js';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import type { SubmodelView } from '../../html/index.js';
|
|
4
|
+
import type { Reflect } from '../../submodel/submodel.js';
|
|
5
|
+
import { type BaseInitConfig, type BaseViewInputs, type Message, type OutMessage } from './shared.js';
|
|
5
6
|
/** Schema for the multi-select listbox component's state, tracking open/closed status, active item, selected items, activation trigger, and typeahead search. */
|
|
6
7
|
export declare const Model: S.Struct<{
|
|
7
8
|
readonly selectedItems: S.$Array<S.String>;
|
|
@@ -32,7 +33,7 @@ export type InitConfig = BaseInitConfig & Readonly<{
|
|
|
32
33
|
}>;
|
|
33
34
|
/** Creates an initial multi-select listbox model from a config. Defaults to closed with no active item and no selection. */
|
|
34
35
|
export declare const init: (config: InitConfig) => Model;
|
|
35
|
-
/** Processes a listbox message and returns the next model and
|
|
36
|
+
/** Processes a listbox message and returns the next model, commands, and optional OutMessage. Stays open on selection and toggles item membership (multi-select behavior); emits a `Selected({ value, wasAdded })` OutMessage indicating whether the value was added or removed. */
|
|
36
37
|
export declare const update: (model: {
|
|
37
38
|
readonly selectedItems: readonly string[];
|
|
38
39
|
readonly id: string;
|
|
@@ -114,9 +115,9 @@ export declare const update: (model: {
|
|
|
114
115
|
} | {
|
|
115
116
|
readonly _tag: "CompletedUnlockScroll";
|
|
116
117
|
} | {
|
|
117
|
-
readonly _tag: "
|
|
118
|
+
readonly _tag: "CompletedInertOthers";
|
|
118
119
|
} | {
|
|
119
|
-
readonly _tag: "
|
|
120
|
+
readonly _tag: "CompletedRestoreInert";
|
|
120
121
|
} | {
|
|
121
122
|
readonly _tag: "CompletedFocusButton";
|
|
122
123
|
} | {
|
|
@@ -149,87 +150,41 @@ export declare const update: (model: {
|
|
|
149
150
|
readonly pointerType: string;
|
|
150
151
|
readonly button: number;
|
|
151
152
|
}, never, never>;
|
|
152
|
-
}>[]
|
|
153
|
+
}>[], Option.Option<Readonly<{
|
|
154
|
+
readonly _tag: "Selected";
|
|
155
|
+
readonly value: string;
|
|
156
|
+
readonly wasAdded: boolean;
|
|
157
|
+
}>>];
|
|
158
|
+
type UpdateReturn = ReturnType<typeof update>;
|
|
153
159
|
/** Programmatically opens the listbox, updating the model and returning
|
|
154
160
|
* focus and modal commands. Use this in domain-event handlers to open the listbox. */
|
|
155
|
-
export declare const open: (model: Model) =>
|
|
161
|
+
export declare const open: (model: Model) => UpdateReturn;
|
|
156
162
|
/** Programmatically closes the listbox, updating the model and returning
|
|
157
163
|
* focus and modal commands. Use this in domain-event handlers to close the listbox. */
|
|
158
|
-
export declare const close: (model: Model) =>
|
|
159
|
-
/** Programmatically toggles an item in the multi-select listbox.
|
|
160
|
-
export declare const selectItem: (model: Model, item: string) =>
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}>;
|
|
185
|
-
readonly maybeLastButtonPointerType: Option.Option<string>;
|
|
186
|
-
};
|
|
187
|
-
toParentMessage: (message: Opened | Closed | import("./shared.js").BlurredItems | import("./shared.js").ActivatedItem | import("./shared.js").DeactivatedItem | SelectedItem | import("./shared.js").MovedPointerOverItem | import("./shared.js").RequestedItemClick | import("./shared.js").Searched | import("./shared.js").PressedPointerOnButton | import("./shared.js").IgnoredMouseClick | import("./shared.js").SuppressedSpaceScroll | {
|
|
188
|
-
readonly _tag: "CompletedAnchorListbox";
|
|
189
|
-
} | {
|
|
190
|
-
readonly _tag: "CompletedPortalListboxBackdrop";
|
|
191
|
-
}) => ParentMessage;
|
|
192
|
-
onSelectedItem?: (value: string) => ParentMessage;
|
|
193
|
-
items: readonly Item[];
|
|
194
|
-
itemToConfig: (item: Item, context: Readonly<{
|
|
195
|
-
isActive: boolean;
|
|
196
|
-
isDisabled: boolean;
|
|
197
|
-
isSelected: boolean;
|
|
198
|
-
}>) => Readonly<{
|
|
199
|
-
className?: string;
|
|
200
|
-
content: Html;
|
|
201
|
-
}>;
|
|
202
|
-
isItemDisabled?: (item: Item, index: number) => boolean;
|
|
203
|
-
itemToSearchText?: (item: Item, index: number) => string;
|
|
204
|
-
itemToValue?: (item: Item) => string;
|
|
205
|
-
isButtonDisabled?: boolean;
|
|
206
|
-
buttonContent: Html;
|
|
207
|
-
buttonClassName?: string;
|
|
208
|
-
buttonAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
209
|
-
itemsClassName?: string;
|
|
210
|
-
itemsAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
211
|
-
itemsScrollClassName?: string;
|
|
212
|
-
itemsScrollAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
213
|
-
backdropClassName?: string;
|
|
214
|
-
backdropAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
215
|
-
className?: string;
|
|
216
|
-
attributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
217
|
-
itemGroupKey?: (item: Item, index: number) => string;
|
|
218
|
-
groupToHeading?: (groupKey: string) => Readonly<{
|
|
219
|
-
content: Html;
|
|
220
|
-
className?: string;
|
|
221
|
-
}> | undefined;
|
|
222
|
-
groupClassName?: string;
|
|
223
|
-
groupAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
224
|
-
separatorClassName?: string;
|
|
225
|
-
separatorAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
226
|
-
anchor?: import("./public.js").AnchorConfig;
|
|
227
|
-
name?: string;
|
|
228
|
-
form?: string;
|
|
229
|
-
isDisabled?: boolean;
|
|
230
|
-
isInvalid?: boolean;
|
|
231
|
-
}>) => Html;
|
|
232
|
-
/** Creates a memoized multi-select listbox view. Static config is captured in a closure;
|
|
233
|
-
* only `model` and `toParentMessage` are compared per render via `createLazy`. */
|
|
234
|
-
export declare const lazy: <ParentMessage, Item>(staticConfig: Omit<ViewConfig<ParentMessage, Item>, "model" | "toParentMessage" | "onSelectedItem">) => ((model: Model, toParentMessage: BaseViewConfig<ParentMessage, Item, Model>["toParentMessage"]) => Html);
|
|
164
|
+
export declare const close: (model: Model) => UpdateReturn;
|
|
165
|
+
/** Programmatically toggles an item in the multi-select listbox. Emits `Selected({ value, wasAdded })`. */
|
|
166
|
+
export declare const selectItem: (model: Model, item: string) => UpdateReturn;
|
|
167
|
+
/** Reflects an externally-sourced selection set onto the model without
|
|
168
|
+
* emitting an OutMessage or running selection side effects. Use this to
|
|
169
|
+
* mirror external truth (URL parameters, restored storage, a server push)
|
|
170
|
+
* onto the listbox's selected items. Contrast with `selectItem`, which
|
|
171
|
+
* toggles a single item as a user *choice* and emits `Selected`. Returns
|
|
172
|
+
* the model directly because it produces no commands and no OutMessage. */
|
|
173
|
+
export declare const reflectSelectedItems: Reflect<Model, ReadonlyArray<string>>;
|
|
174
|
+
/** Per-render view inputs passed to the view via `h.submodel`'s `viewInputs` field. */
|
|
175
|
+
export type ViewInputs<Item, Value extends string = string> = BaseViewInputs<Item, Value>;
|
|
176
|
+
/** Pairs the multi-select listbox's `view` and `update` (and programmatic
|
|
177
|
+
* helpers) behind a single Item-typed entry point. Same shape as
|
|
178
|
+
* `Ui.Listbox.create`. Two type params support object-typed items via
|
|
179
|
+
* `itemToValue`: `Value` defaults to `Item` when `Item extends string`,
|
|
180
|
+
* else `string`. */
|
|
181
|
+
export declare const create: <Item = string, Value extends string = Item extends string ? Item : string>() => Readonly<{
|
|
182
|
+
view: SubmodelView<Model, Message, BaseViewInputs<Item, Value>>;
|
|
183
|
+
update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
|
|
184
|
+
selectItem: (model: Model, item: Value) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
|
|
185
|
+
open: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
|
|
186
|
+
close: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
|
|
187
|
+
reflectSelectedItems: Reflect<Model, ReadonlyArray<Value>>;
|
|
188
|
+
}>;
|
|
189
|
+
export {};
|
|
235
190
|
//# sourceMappingURL=multi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi.d.ts","sourceRoot":"","sources":["../../../src/ui/listbox/multi.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"multi.d.ts","sourceRoot":"","sources":["../../../src/ui/listbox/multi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,IAAI,CAAC,EAAQ,MAAM,QAAQ,CAAA;AAEnE,OAAO,KAAK,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,cAAc,EAEnB,KAAK,OAAO,EAEZ,KAAK,UAAU,EAMhB,MAAM,aAAa,CAAA;AAIpB,iKAAiK;AACjK,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;EAGhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,6RAA6R;AAC7R,MAAM,MAAM,UAAU,GAAG,cAAc,GACrC,QAAQ,CAAC;IACP,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACtC,CAAC,CAAA;AAEJ,4HAA4H;AAC5H,eAAO,MAAM,IAAI,GAAI,QAAQ,UAAU,KAAG,KAGxC,CAAA;AAIF,oRAAoR;AACpR,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAWjB,CAAA;AAEF,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAA;AAE7C;uFACuF;AACvF,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,KAAG,YAC4B,CAAA;AAEhE;wFACwF;AACxF,eAAO,MAAM,KAAK,GAAI,OAAO,KAAK,KAAG,YAAuC,CAAA;AAE5E,2GAA2G;AAC3G,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,EAAE,MAAM,MAAM,KAAG,YACjB,CAAA;AAEvC;;;;;4EAK4E;AAC5E,eAAO,MAAM,oBAAoB,EAAE,OAAO,CACxC,KAAK,EACL,aAAa,CAAC,MAAM,CAAC,CAKtB,CAAA;AAID,uFAAuF;AACvF,MAAM,MAAM,UAAU,CAAC,IAAI,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI,cAAc,CAC1E,IAAI,EACJ,KAAK,CACN,CAAA;AAgBD;;;;qBAIqB;AACrB,eAAO,MAAM,MAAM,GACjB,IAAI,GAAG,MAAM,EACb,KAAK,SAAS,MAAM,GAAG,IAAI,SAAS,MAAM,GAAG,IAAI,GAAG,MAAM,OACvD,QAAQ,CAAC;IACZ,IAAI,EAAE,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IAC/D,MAAM,EAAE,CACN,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,KACb,SAAS,CACZ,KAAK,EACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACjC,CAAA;IACD,UAAU,EAAE,CACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,KAAK,KACR,SAAS,CACZ,KAAK,EACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACjC,CAAA;IACD,IAAI,EAAE,CACJ,KAAK,EAAE,KAAK,KACT,SAAS,CACZ,KAAK,EACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACjC,CAAA;IACD,KAAK,EAAE,CACL,KAAK,EAAE,KAAK,KACT,SAAS,CACZ,KAAK,EACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACjC,CAAA;IACD,oBAAoB,EAAE,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;CAC3D,CAqBA,CAAA"}
|