@foldkit/ui 0.150.0 → 0.151.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/animation/update.d.ts +10 -9
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +27 -35
- package/dist/calendar/index.d.ts +100 -11
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +66 -80
- package/dist/checkbox/index.d.ts +3 -4
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/checkbox/index.js +3 -4
- package/dist/combobox/multi.d.ts +40 -51
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +19 -16
- package/dist/combobox/shared.d.ts +20 -20
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +134 -128
- package/dist/combobox/single.d.ts +38 -51
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +21 -17
- package/dist/datePicker/index.d.ts +182 -15
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +37 -54
- package/dist/dialog/index.d.ts +45 -7
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +54 -49
- package/dist/disclosure/index.d.ts +3 -4
- package/dist/disclosure/index.d.ts.map +1 -1
- package/dist/disclosure/index.js +3 -4
- package/dist/dragAndDrop/index.d.ts +96 -7
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.js +49 -61
- package/dist/fileDrop/index.d.ts +26 -11
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +16 -23
- package/dist/listbox/multi.d.ts +39 -52
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +9 -7
- package/dist/listbox/shared.d.ts +14 -22
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +113 -114
- package/dist/listbox/single.d.ts +40 -55
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +8 -7
- package/dist/menu/index.d.ts +131 -37
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +111 -120
- package/dist/popover/index.d.ts +71 -10
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +80 -73
- package/dist/radioGroup/index.d.ts +31 -19
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +18 -18
- package/dist/slider/index.d.ts +44 -13
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +33 -38
- package/dist/switch/index.d.ts +3 -4
- package/dist/switch/index.d.ts.map +1 -1
- package/dist/switch/index.js +3 -4
- package/dist/tabs/index.d.ts +31 -17
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +17 -17
- package/dist/test/apps/disabledButton.d.ts +17 -17
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +6 -4
- package/dist/toast/index.d.ts +96 -100
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/update.d.ts +97 -100
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +60 -58
- package/dist/tooltip/index.d.ts +2 -1
- package/dist/tooltip/index.d.ts.map +1 -1
- package/dist/tooltip/index.js +1 -1
- package/dist/tooltip/tooltip.d.ts +5 -10
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +45 -48
- package/dist/virtualList/index.d.ts +30 -29
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +21 -21
- package/package.json +3 -3
package/dist/dialog/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect, Option, Schema as S } from 'effect';
|
|
2
2
|
import * as Command from 'foldkit/command';
|
|
3
3
|
import { type ChildAttribute, type Html } from 'foldkit/html';
|
|
4
|
+
import * as Update from 'foldkit/update';
|
|
4
5
|
/** Schema for the dialog component's state, tracking its unique ID, open/closed status, animation support, and animation lifecycle phase. */
|
|
5
6
|
export declare const Model: S.Struct<{
|
|
6
7
|
readonly id: S.String;
|
|
@@ -74,11 +75,7 @@ export declare const initialFocusMarkerAttribute = "foldkit-dialog-initial-focus
|
|
|
74
75
|
/** Selector for {@link initialFocusMarkerAttribute}, focused against the open
|
|
75
76
|
* dialog when no `focusSelector` is configured. */
|
|
76
77
|
export declare const initialFocusMarkerSelector = "[data-foldkit-dialog-initial-focus]";
|
|
77
|
-
type UpdateReturn =
|
|
78
|
-
Model,
|
|
79
|
-
ReadonlyArray<Command.Command<Message>>,
|
|
80
|
-
Option.Option<OutMessage>
|
|
81
|
-
];
|
|
78
|
+
type UpdateReturn = Update.ReturnWithOutMessage<Model, Message, OutMessage>;
|
|
82
79
|
/** Locks page scroll and opens the native dialog element through
|
|
83
80
|
* `Dom.showDialog`, which calls `show()` (not native `showModal()`) so other
|
|
84
81
|
* high-z-index overlays stay interactive. It layers the dialog with a high
|
|
@@ -105,8 +102,49 @@ export declare const ReleaseDialogResources: Command.CommandDefinitionWithArgs<"
|
|
|
105
102
|
}, Effect.Effect<{
|
|
106
103
|
readonly _tag: "CompletedReleaseDialogResources";
|
|
107
104
|
}, never, never>>;
|
|
108
|
-
/** Processes a
|
|
109
|
-
export declare const update: (model: Model, message: Message) =>
|
|
105
|
+
/** Processes a Dialog Message and returns the next Model and optional Commands. */
|
|
106
|
+
export declare const update: (model: Model, message: Message) => Readonly<{
|
|
107
|
+
model: {
|
|
108
|
+
readonly id: string;
|
|
109
|
+
readonly isOpen: boolean;
|
|
110
|
+
readonly isAnimated: boolean;
|
|
111
|
+
readonly animation: {
|
|
112
|
+
readonly id: string;
|
|
113
|
+
readonly isShowing: boolean;
|
|
114
|
+
readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
|
|
115
|
+
};
|
|
116
|
+
readonly maybeFocusSelector: Option.Option<string>;
|
|
117
|
+
};
|
|
118
|
+
commands?: Update.Commands<{
|
|
119
|
+
readonly _tag: "RequestedOpen";
|
|
120
|
+
} | {
|
|
121
|
+
readonly _tag: "RequestedClose";
|
|
122
|
+
} | {
|
|
123
|
+
readonly _tag: "CompletedShowDialog";
|
|
124
|
+
} | {
|
|
125
|
+
readonly _tag: "CompletedCloseDialog";
|
|
126
|
+
} | {
|
|
127
|
+
readonly _tag: "Unmounted";
|
|
128
|
+
} | {
|
|
129
|
+
readonly _tag: "CompletedReleaseDialogResources";
|
|
130
|
+
} | {
|
|
131
|
+
readonly _tag: "GotAnimationMessage";
|
|
132
|
+
readonly message: {
|
|
133
|
+
readonly _tag: "Showed";
|
|
134
|
+
} | {
|
|
135
|
+
readonly _tag: "Hid";
|
|
136
|
+
} | {
|
|
137
|
+
readonly _tag: "CompletedWaitForPaint";
|
|
138
|
+
} | {
|
|
139
|
+
readonly _tag: "EndedAnimation";
|
|
140
|
+
};
|
|
141
|
+
}, never>;
|
|
142
|
+
outMessage?: {
|
|
143
|
+
readonly _tag: "Opened";
|
|
144
|
+
} | {
|
|
145
|
+
readonly _tag: "Closed";
|
|
146
|
+
};
|
|
147
|
+
}>;
|
|
110
148
|
/** Programmatically opens the dialog. */
|
|
111
149
|
export declare const open: (model: Model) => UpdateReturn;
|
|
112
150
|
/** Programmatically closes the dialog. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,EAAE,MAAM,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,EAAE,MAAM,IAAI,CAAC,EAAQ,MAAM,QAAQ,CAAA;AACtE,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAI9E,OAA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pC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC1C,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC3C,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC1C,SAAS,EAAE,OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;CACrC,CAAC,CAAA;AAEF;;;2EAG2E;AAC3E,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAPP,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;GA+FrC,CAAA"}
|
package/dist/dialog/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
-
import { Effect, Match as M, Option, Schema as S } from 'effect';
|
|
2
|
+
import { Effect, Match as M, Option, Schema as S, pipe } from 'effect';
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import * as Dom from 'foldkit/dom';
|
|
5
5
|
import { childAttributes } from 'foldkit/html';
|
|
@@ -85,21 +85,23 @@ export const ReleaseDialogResources = Command.define('ReleaseDialogResources', {
|
|
|
85
85
|
});
|
|
86
86
|
const wrapAnimationMessage = (message) => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/dialog/index.js#wrapAnimationMessage");
|
|
87
87
|
const foldAnimationOutMessage = (outMessage, { liftCommand }) => __foldkitBrandViewResult((AnimationOutMessage.match(outMessage, {
|
|
88
|
-
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult((
|
|
88
|
+
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({
|
|
89
89
|
model,
|
|
90
|
-
[liftCommand(animationDefaultLeaveCommand(model.animation))],
|
|
91
|
-
|
|
92
|
-
TransitionedOut: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult((
|
|
90
|
+
commands: [liftCommand(animationDefaultLeaveCommand(model.animation))],
|
|
91
|
+
}), "@foldkit/ui/dialog/index.js#anonymous~3"))), "@foldkit/ui/dialog/index.js#StartedLeaveAnimating"),
|
|
92
|
+
TransitionedOut: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({
|
|
93
|
+
model,
|
|
94
|
+
commands: [CloseDialog({ id: model.id })],
|
|
95
|
+
}), "@foldkit/ui/dialog/index.js#anonymous~4"))), "@foldkit/ui/dialog/index.js#TransitionedOut"),
|
|
93
96
|
})), "@foldkit/ui/dialog/index.js#foldAnimationOutMessage");
|
|
94
97
|
const foldAnimation = Update.foldChild({
|
|
95
98
|
update: animationUpdate,
|
|
96
99
|
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/dialog/index.js#read"),
|
|
97
100
|
write: (model, nextAnimation) => __foldkitBrandViewResult((evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/dialog/index.js#animation") })), "@foldkit/ui/dialog/index.js#write"),
|
|
98
101
|
toParentMessage: wrapAnimationMessage,
|
|
99
|
-
toParentOutMessage: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/dialog/index.js#toParentOutMessage"),
|
|
100
102
|
foldOutMessage: foldAnimationOutMessage,
|
|
101
103
|
});
|
|
102
|
-
/** Processes a
|
|
104
|
+
/** Processes a Dialog Message and returns the next Model and optional Commands. */
|
|
103
105
|
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
104
106
|
RequestedOpen: () => {
|
|
105
107
|
const wasClosed = !model.isOpen;
|
|
@@ -107,43 +109,47 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
107
109
|
id: model.id,
|
|
108
110
|
focusSelector: Option.getOrElse(model.maybeFocusSelector, () => __foldkitBrandViewResult((initialFocusMarkerSelector), "@foldkit/ui/dialog/index.js#anonymous~5")),
|
|
109
111
|
}), () => __foldkitBrandViewResult((wasClosed), "@foldkit/ui/dialog/index.js#anonymous~6"));
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
Option.toArray(maybeShow),
|
|
124
|
-
maybeOutMessage,
|
|
125
|
-
]), "@foldkit/ui/dialog/index.js#RequestedOpen");
|
|
112
|
+
const commands = Option.toArray(maybeShow);
|
|
113
|
+
const dialogOpen = model.isAnimated
|
|
114
|
+
? Update.combine(model, [
|
|
115
|
+
stepModel => (__foldkitBrandViewResult(({ model: stepModel, commands }), "@foldkit/ui/dialog/index.js#anonymous~7")),
|
|
116
|
+
foldAnimation(AnimationMessage.Showed()),
|
|
117
|
+
stepModel => (__foldkitBrandViewResult(({
|
|
118
|
+
model: evo(stepModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/dialog/index.js#isOpen") }),
|
|
119
|
+
}), "@foldkit/ui/dialog/index.js#anonymous~8")),
|
|
120
|
+
])
|
|
121
|
+
: { model: evo(model, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/dialog/index.js#isOpen~2") }), commands };
|
|
122
|
+
return __foldkitBrandViewResult((wasClosed
|
|
123
|
+
? pipe(dialogOpen, Update.withOutMessage(OutMessage.Opened()))
|
|
124
|
+
: dialogOpen), "@foldkit/ui/dialog/index.js#RequestedOpen");
|
|
126
125
|
},
|
|
127
126
|
RequestedClose: () => {
|
|
128
127
|
const { transitionState } = model.animation;
|
|
129
128
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
130
129
|
if (isLeaving) {
|
|
131
|
-
return __foldkitBrandViewResult((
|
|
130
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#RequestedClose");
|
|
132
131
|
}
|
|
133
132
|
const wasOpen = model.isOpen;
|
|
134
|
-
const maybeOutMessage = wasOpen
|
|
135
|
-
? Option.some(OutMessage.Closed())
|
|
136
|
-
: Option.none();
|
|
137
133
|
if (model.isAnimated) {
|
|
138
|
-
const
|
|
139
|
-
|
|
134
|
+
const dialogClose = Update.combine(model, [
|
|
135
|
+
stepModel => (__foldkitBrandViewResult(({
|
|
136
|
+
model: evo(stepModel, { isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~3") }),
|
|
137
|
+
}), "@foldkit/ui/dialog/index.js#anonymous~9")),
|
|
138
|
+
foldAnimation(AnimationMessage.Hid()),
|
|
139
|
+
]);
|
|
140
|
+
return __foldkitBrandViewResult((wasOpen
|
|
141
|
+
? pipe(dialogClose, Update.withOutMessage(OutMessage.Closed()))
|
|
142
|
+
: dialogClose), "@foldkit/ui/dialog/index.js#RequestedClose");
|
|
140
143
|
}
|
|
141
|
-
const maybeClose = Option.liftPredicate(CloseDialog({ id: model.id }), () => __foldkitBrandViewResult((wasOpen), "@foldkit/ui/dialog/index.js#anonymous~
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
const maybeClose = Option.liftPredicate(CloseDialog({ id: model.id }), () => __foldkitBrandViewResult((wasOpen), "@foldkit/ui/dialog/index.js#anonymous~10"));
|
|
145
|
+
const commands = Option.toArray(maybeClose);
|
|
146
|
+
const dialogClose = {
|
|
147
|
+
model: evo(model, { isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~4") }),
|
|
148
|
+
commands,
|
|
149
|
+
};
|
|
150
|
+
return __foldkitBrandViewResult((wasOpen
|
|
151
|
+
? pipe(dialogClose, Update.withOutMessage(OutMessage.Closed()))
|
|
152
|
+
: dialogClose), "@foldkit/ui/dialog/index.js#RequestedClose");
|
|
147
153
|
},
|
|
148
154
|
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((foldAnimation(model, animationMessage)), "@foldkit/ui/dialog/index.js#GotAnimationMessage"),
|
|
149
155
|
Unmounted: () => {
|
|
@@ -153,19 +159,18 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
153
159
|
isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~5"),
|
|
154
160
|
animation: () => __foldkitBrandViewResult((animationInit({ id: `${model.id}-panel` })), "@foldkit/ui/dialog/index.js#animation~2"),
|
|
155
161
|
});
|
|
156
|
-
return __foldkitBrandViewResult((
|
|
157
|
-
nextModel,
|
|
158
|
-
[ReleaseDialogResources({ id: model.id })],
|
|
159
|
-
|
|
160
|
-
]), "@foldkit/ui/dialog/index.js#Unmounted");
|
|
162
|
+
return __foldkitBrandViewResult(({
|
|
163
|
+
model: nextModel,
|
|
164
|
+
commands: [ReleaseDialogResources({ id: model.id })],
|
|
165
|
+
}), "@foldkit/ui/dialog/index.js#Unmounted");
|
|
161
166
|
}
|
|
162
167
|
else {
|
|
163
|
-
return __foldkitBrandViewResult((
|
|
168
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#Unmounted");
|
|
164
169
|
}
|
|
165
170
|
},
|
|
166
|
-
CompletedShowDialog: () => __foldkitBrandViewResult((
|
|
167
|
-
CompletedCloseDialog: () => __foldkitBrandViewResult((
|
|
168
|
-
CompletedReleaseDialogResources: () => __foldkitBrandViewResult((
|
|
171
|
+
CompletedShowDialog: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#CompletedShowDialog")),
|
|
172
|
+
CompletedCloseDialog: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#CompletedCloseDialog")),
|
|
173
|
+
CompletedReleaseDialogResources: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#CompletedReleaseDialogResources")),
|
|
169
174
|
})), "@foldkit/ui/dialog/index.js#update");
|
|
170
175
|
/** Programmatically opens the dialog. */
|
|
171
176
|
export const open = (model) => __foldkitBrandViewResult((update(model, Message.RequestedOpen())), "@foldkit/ui/dialog/index.js#open");
|
|
@@ -203,17 +208,17 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
203
208
|
h.DataAttribute('closed', ''),
|
|
204
209
|
h.DataAttribute('enter', ''),
|
|
205
210
|
h.DataAttribute('transition', ''),
|
|
206
|
-
]), "@foldkit/ui/dialog/index.js#anonymous~
|
|
211
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~12")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
207
212
|
h.DataAttribute('enter', ''),
|
|
208
213
|
h.DataAttribute('transition', ''),
|
|
209
|
-
]), "@foldkit/ui/dialog/index.js#anonymous~
|
|
214
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~13")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
210
215
|
h.DataAttribute('leave', ''),
|
|
211
216
|
h.DataAttribute('transition', ''),
|
|
212
|
-
]), "@foldkit/ui/dialog/index.js#anonymous~
|
|
217
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~14")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
213
218
|
h.DataAttribute('closed', ''),
|
|
214
219
|
h.DataAttribute('leave', ''),
|
|
215
220
|
h.DataAttribute('transition', ''),
|
|
216
|
-
]), "@foldkit/ui/dialog/index.js#anonymous~
|
|
221
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~15")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/dialog/index.js#anonymous~16")));
|
|
217
222
|
const dialogAttributes = [
|
|
218
223
|
h.Id(id),
|
|
219
224
|
h.AriaLabelledBy(titleId(model)),
|
|
@@ -260,5 +265,5 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
260
265
|
initialFocus: childAttributes(initialFocusAttributes),
|
|
261
266
|
closeButton: childAttributes(closeButtonAttributes),
|
|
262
267
|
isVisible,
|
|
263
|
-
})), "@foldkit/ui/dialog/index.js#anonymous~
|
|
268
|
+
})), "@foldkit/ui/dialog/index.js#anonymous~11");
|
|
264
269
|
});
|
|
@@ -64,10 +64,9 @@ export type ViewConfig<Message> = Readonly<{
|
|
|
64
64
|
* )
|
|
65
65
|
*
|
|
66
66
|
* // In update:
|
|
67
|
-
* ToggledDetails: ({ isOpen }) =>
|
|
68
|
-
* evo(model, { isDetailsOpen: () => isOpen }),
|
|
69
|
-
*
|
|
70
|
-
* ],
|
|
67
|
+
* ToggledDetails: ({ isOpen }) => ({
|
|
68
|
+
* model: evo(model, { isDetailsOpen: () => isOpen }),
|
|
69
|
+
* }),
|
|
71
70
|
* ``` */
|
|
72
71
|
export declare const view: <Message>(config: ViewConfig<Message>, h: HtmlBuilder<Message>) => Html;
|
|
73
72
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/disclosure/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAIhE;;;mCAGmC;AACnC,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,KAAG,MAAwB,CAAA;AAM9D;;;;;;;;;sEASsE;AACtE,MAAM,MAAM,oBAAoB,CAAC,OAAO,IAAI,QAAQ,CAAC;IACnD,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACzC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACxC;;;;;kFAK8E;IAC9E,YAAY,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAA;CACtC,CAAC,CAAA;AAEF;;;;;;;;;;oBAUoB;AACpB,MAAM,MAAM,UAAU,CAAC,OAAO,IAAI,QAAQ,CAAC;IACzC,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,CAAC,MAAM,E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UAsBU;AACV,eAAO,MAAM,IAAI,GAAI,OAAO,EAC1B,QAAQ,UAAU,CAAC,OAAO,CAAC,EAC3B,GAAG,WAAW,CAAC,OAAO,CAAC,KACtB,IAiFF,CAAA"}
|
package/dist/disclosure/index.js
CHANGED
|
@@ -27,10 +27,9 @@ const panelSizeTransition = 'grid-template-rows 200ms ease-out';
|
|
|
27
27
|
* )
|
|
28
28
|
*
|
|
29
29
|
* // In update:
|
|
30
|
-
* ToggledDetails: ({ isOpen }) =>
|
|
31
|
-
* evo(model, { isDetailsOpen: () => isOpen }),
|
|
32
|
-
*
|
|
33
|
-
* ],
|
|
30
|
+
* ToggledDetails: ({ isOpen }) => ({
|
|
31
|
+
* model: evo(model, { isDetailsOpen: () => isOpen }),
|
|
32
|
+
* }),
|
|
34
33
|
* ``` */
|
|
35
34
|
export const view = (config, h) => {
|
|
36
35
|
const { id, isOpen, onToggle, toView, isDisabled = false, ariaLabel, ariaLabelledBy, } = config;
|
|
@@ -2,6 +2,7 @@ import { Effect, Equivalence, Option, Schema as S, Stream } from 'effect';
|
|
|
2
2
|
import * as Command from 'foldkit/command';
|
|
3
3
|
import { type Attribute, type HtmlBuilder } from 'foldkit/html';
|
|
4
4
|
import * as Subscription from 'foldkit/subscription';
|
|
5
|
+
import * as Update from 'foldkit/update';
|
|
5
6
|
declare const DropTarget: S.Struct<{
|
|
6
7
|
readonly containerId: S.String;
|
|
7
8
|
readonly index: S.Number;
|
|
@@ -118,13 +119,101 @@ export declare const ResolveKeyboardMove: Command.CommandDefinitionWithArgs<"Res
|
|
|
118
119
|
readonly targetContainerId: string;
|
|
119
120
|
readonly targetIndex: number;
|
|
120
121
|
}, never, never>>;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
/** Processes a drag-and-drop Message and returns the next Model, optional
|
|
123
|
+
* Commands, and an optional OutMessage for the parent. */
|
|
124
|
+
export declare const update: (model: Model, message: Message) => Readonly<{
|
|
125
|
+
model: {
|
|
126
|
+
readonly id: string;
|
|
127
|
+
readonly orientation: "Horizontal" | "Vertical";
|
|
128
|
+
readonly activationThreshold: number;
|
|
129
|
+
readonly dragState: {
|
|
130
|
+
readonly _tag: "Idle";
|
|
131
|
+
} | {
|
|
132
|
+
readonly _tag: "Pending";
|
|
133
|
+
readonly itemId: string;
|
|
134
|
+
readonly containerId: string;
|
|
135
|
+
readonly index: number;
|
|
136
|
+
readonly origin: {
|
|
137
|
+
readonly screenX: number;
|
|
138
|
+
readonly screenY: number;
|
|
139
|
+
};
|
|
140
|
+
} | {
|
|
141
|
+
readonly _tag: "Dragging";
|
|
142
|
+
readonly itemId: string;
|
|
143
|
+
readonly sourceContainerId: string;
|
|
144
|
+
readonly sourceIndex: number;
|
|
145
|
+
readonly origin: {
|
|
146
|
+
readonly screenX: number;
|
|
147
|
+
readonly screenY: number;
|
|
148
|
+
};
|
|
149
|
+
readonly current: {
|
|
150
|
+
readonly clientX: number;
|
|
151
|
+
readonly clientY: number;
|
|
152
|
+
};
|
|
153
|
+
readonly maybeDropTarget: Option.Option<{
|
|
154
|
+
readonly containerId: string;
|
|
155
|
+
readonly index: number;
|
|
156
|
+
}>;
|
|
157
|
+
} | {
|
|
158
|
+
readonly _tag: "KeyboardDragging";
|
|
159
|
+
readonly itemId: string;
|
|
160
|
+
readonly sourceContainerId: string;
|
|
161
|
+
readonly sourceIndex: number;
|
|
162
|
+
readonly targetContainerId: string;
|
|
163
|
+
readonly targetIndex: number;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
commands?: Update.Commands<{
|
|
167
|
+
readonly _tag: "PressedDraggable";
|
|
168
|
+
readonly itemId: string;
|
|
169
|
+
readonly containerId: string;
|
|
170
|
+
readonly index: number;
|
|
171
|
+
readonly screenX: number;
|
|
172
|
+
readonly screenY: number;
|
|
173
|
+
} | {
|
|
174
|
+
readonly _tag: "MovedPointer";
|
|
175
|
+
readonly screenX: number;
|
|
176
|
+
readonly screenY: number;
|
|
177
|
+
readonly clientX: number;
|
|
178
|
+
readonly clientY: number;
|
|
179
|
+
readonly maybeDropTarget: Option.Option<{
|
|
180
|
+
readonly containerId: string;
|
|
181
|
+
readonly index: number;
|
|
182
|
+
}>;
|
|
183
|
+
} | {
|
|
184
|
+
readonly _tag: "ReleasedPointer";
|
|
185
|
+
} | {
|
|
186
|
+
readonly _tag: "CancelledDrag";
|
|
187
|
+
} | {
|
|
188
|
+
readonly _tag: "ActivatedKeyboardDrag";
|
|
189
|
+
readonly itemId: string;
|
|
190
|
+
readonly containerId: string;
|
|
191
|
+
readonly index: number;
|
|
192
|
+
} | {
|
|
193
|
+
readonly _tag: "CompletedResolveKeyboardMove";
|
|
194
|
+
readonly targetContainerId: string;
|
|
195
|
+
readonly targetIndex: number;
|
|
196
|
+
} | {
|
|
197
|
+
readonly _tag: "ConfirmedKeyboardDrop";
|
|
198
|
+
} | {
|
|
199
|
+
readonly _tag: "PressedArrowKey";
|
|
200
|
+
readonly direction: "Up" | "Down" | "Left" | "Right" | "NextContainer" | "PreviousContainer";
|
|
201
|
+
} | {
|
|
202
|
+
readonly _tag: "AdvancedAutoScrollFrame";
|
|
203
|
+
} | {
|
|
204
|
+
readonly _tag: "CompletedFocusItem";
|
|
205
|
+
}, never>;
|
|
206
|
+
outMessage?: {
|
|
207
|
+
readonly _tag: "Reordered";
|
|
208
|
+
readonly itemId: string;
|
|
209
|
+
readonly fromContainerId: string;
|
|
210
|
+
readonly fromIndex: number;
|
|
211
|
+
readonly toContainerId: string;
|
|
212
|
+
readonly toIndex: number;
|
|
213
|
+
} | {
|
|
214
|
+
readonly _tag: "Cancelled";
|
|
215
|
+
};
|
|
216
|
+
}>;
|
|
128
217
|
/** Document-level subscriptions for pointer and keyboard events during drag operations. */
|
|
129
218
|
export declare const subscriptions: {
|
|
130
219
|
readonly documentPointer: Subscription.EntryWithoutKeepAlive<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dragAndDrop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAEN,WAAW,EAEX,MAAM,EAEN,MAAM,IAAI,CAAC,EACX,MAAM,EAEP,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAmB,MAAM,cAAc,CAAA;AAIhF,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dragAndDrop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAEN,WAAW,EAEX,MAAM,EAEN,MAAM,IAAI,CAAC,EACX,MAAM,EAEP,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAmB,MAAM,cAAc,CAAA;AAIhF,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAkBxC,QAAA,MAAM,UAAU;;;EAGd,CAAA;AA8BF,mHAAmH;AACnH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,qEAAqE;AACrE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuClB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,oFAAoF;AACpF,eAAO,MAAM,UAAU;;;;;;;;;EASrB,CAAA;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA;AAO/C,MAAM,MAAM,UAAU,GAAG,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,QAAQ,CAAC;IACpD,KAAK,EAAE,KAAK,CAAA;IACZ,eAAe,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,aAAa,CAAA;IAC7D,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;CACd,CAAC,CAAA;AAEF,0HAA0H;AAC1H,eAAO,MAAM,SAAS,GAAI,aAAa,EACrC,QAAQ,eAAe,CAAC,aAAa,CAAC,EACtC,GAAG,WAAW,CAAC,aAAa,CAAC,KAC5B,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC,CA2DxC,CAAA;AAED;;8CAE8C;AAC9C,eAAO,MAAM,SAAS,GACpB,aAAa,MAAM,EACnB,QAAQ,MAAM,KACb,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAIhC,CAAA;AAED;;;aAGa;AACb,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,KAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAEvE,CAAA;AAKD,kGAAkG;AAClG,eAAO,MAAM,UAAU,GACrB,OAAO,KAAK,KACX,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcpC,CAAA;AAEH,kFAAkF;AAClF,eAAO,MAAM,UAAU,GAAI,yBAAyB,KAAK,KAAG,OACR,CAAA;AAEpD,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,GAAI,OAAO,KAAK,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAMnE,CAAA;AAEH,oJAAoJ;AACpJ,eAAO,MAAM,eAAe,GAC1B,OAAO,KAAK,KACX,MAAM,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,IAAI,CAUpC,CAAA"}
|
|
@@ -7,6 +7,7 @@ import { defineMessageUnion } from 'foldkit/message';
|
|
|
7
7
|
import { ts } from 'foldkit/schema';
|
|
8
8
|
import { evo } from 'foldkit/struct';
|
|
9
9
|
import * as Subscription from 'foldkit/subscription';
|
|
10
|
+
import * as Update from 'foldkit/update';
|
|
10
11
|
import { attributeSelector } from '../internal/selectors.js';
|
|
11
12
|
// MODEL
|
|
12
13
|
const Orientation = S.Literals(['Horizontal', 'Vertical']);
|
|
@@ -188,10 +189,11 @@ export const ResolveKeyboardMove = Command.define('ResolveKeyboardMove', {
|
|
|
188
189
|
execute: resolveKeyboardMoveTarget,
|
|
189
190
|
});
|
|
190
191
|
const withUpdateReturn = M.withReturnType();
|
|
191
|
-
/** Processes a drag-and-drop
|
|
192
|
+
/** Processes a drag-and-drop Message and returns the next Model, optional
|
|
193
|
+
* Commands, and an optional OutMessage for the parent. */
|
|
192
194
|
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
193
|
-
PressedDraggable: ({ itemId, containerId, index, screenX, screenY }) => __foldkitBrandViewResult((
|
|
194
|
-
evo(model, {
|
|
195
|
+
PressedDraggable: ({ itemId, containerId, index, screenX, screenY }) => (__foldkitBrandViewResult(({
|
|
196
|
+
model: evo(model, {
|
|
195
197
|
dragState: () => __foldkitBrandViewResult((Pending({
|
|
196
198
|
itemId,
|
|
197
199
|
containerId,
|
|
@@ -199,18 +201,16 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
199
201
|
origin: { screenX, screenY },
|
|
200
202
|
})), "@foldkit/ui/dragAndDrop/index.js#dragState"),
|
|
201
203
|
}),
|
|
202
|
-
|
|
203
|
-
Option.none(),
|
|
204
|
-
]), "@foldkit/ui/dragAndDrop/index.js#PressedDraggable"),
|
|
204
|
+
}), "@foldkit/ui/dragAndDrop/index.js#PressedDraggable")),
|
|
205
205
|
MovedPointer: ({ screenX, screenY, clientX, clientY, maybeDropTarget }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Pending', pending => {
|
|
206
206
|
const deltaX = screenX - pending.origin.screenX;
|
|
207
207
|
const deltaY = screenY - pending.origin.screenY;
|
|
208
208
|
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
209
209
|
if (distance < model.activationThreshold) {
|
|
210
|
-
return __foldkitBrandViewResult((
|
|
210
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#anonymous~9");
|
|
211
211
|
}
|
|
212
|
-
return __foldkitBrandViewResult((
|
|
213
|
-
evo(model, {
|
|
212
|
+
return __foldkitBrandViewResult(({
|
|
213
|
+
model: evo(model, {
|
|
214
214
|
dragState: () => __foldkitBrandViewResult((Dragging({
|
|
215
215
|
itemId: pending.itemId,
|
|
216
216
|
sourceContainerId: pending.containerId,
|
|
@@ -220,53 +220,45 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
220
220
|
maybeDropTarget,
|
|
221
221
|
})), "@foldkit/ui/dragAndDrop/index.js#dragState~2"),
|
|
222
222
|
}),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}), M.tag('Dragging', dragging => __foldkitBrandViewResult(([
|
|
227
|
-
evo(model, {
|
|
223
|
+
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~9");
|
|
224
|
+
}), M.tag('Dragging', dragging => (__foldkitBrandViewResult(({
|
|
225
|
+
model: evo(model, {
|
|
228
226
|
dragState: () => __foldkitBrandViewResult((Dragging({
|
|
229
227
|
...dragging,
|
|
230
228
|
current: { clientX, clientY },
|
|
231
229
|
maybeDropTarget,
|
|
232
230
|
})), "@foldkit/ui/dragAndDrop/index.js#dragState~3"),
|
|
233
231
|
}),
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~
|
|
244
|
-
|
|
245
|
-
Option.some(OutMessage.Cancelled()),
|
|
246
|
-
]), "@foldkit/ui/dragAndDrop/index.js#onNone"),
|
|
247
|
-
onSome: dropTarget => __foldkitBrandViewResult(([
|
|
248
|
-
evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~6") }),
|
|
249
|
-
[],
|
|
250
|
-
Option.some(OutMessage.Reordered({
|
|
232
|
+
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~10"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#anonymous~11"))))), "@foldkit/ui/dragAndDrop/index.js#MovedPointer"),
|
|
233
|
+
ReleasedPointer: () => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Pending', () => (__foldkitBrandViewResult(({
|
|
234
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~4") }),
|
|
235
|
+
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~12"))), M.tag('Dragging', dragging => __foldkitBrandViewResult((Option.match(dragging.maybeDropTarget, {
|
|
236
|
+
onNone: () => (__foldkitBrandViewResult(({
|
|
237
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~5") }),
|
|
238
|
+
outMessage: OutMessage.Cancelled(),
|
|
239
|
+
}), "@foldkit/ui/dragAndDrop/index.js#onNone")),
|
|
240
|
+
onSome: dropTarget => (__foldkitBrandViewResult(({
|
|
241
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~6") }),
|
|
242
|
+
outMessage: OutMessage.Reordered({
|
|
251
243
|
itemId: dragging.itemId,
|
|
252
244
|
fromContainerId: dragging.sourceContainerId,
|
|
253
245
|
fromIndex: dragging.sourceIndex,
|
|
254
246
|
toContainerId: dropTarget.containerId,
|
|
255
247
|
toIndex: dropTarget.index,
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
})), "@foldkit/ui/dragAndDrop/index.js#anonymous~13")), M.orElse(() => __foldkitBrandViewResult((
|
|
248
|
+
}),
|
|
249
|
+
}), "@foldkit/ui/dragAndDrop/index.js#onSome")),
|
|
250
|
+
})), "@foldkit/ui/dragAndDrop/index.js#anonymous~13")), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#anonymous~14"))))), "@foldkit/ui/dragAndDrop/index.js#ReleasedPointer"),
|
|
259
251
|
CancelledDrag: () => {
|
|
260
252
|
const maybeFocusCommand = Option.liftPredicate(model.dragState, dragState => __foldkitBrandViewResult((dragState._tag === 'KeyboardDragging'), "@foldkit/ui/dragAndDrop/index.js#anonymous~15")).pipe(Option.map(({ itemId }) => __foldkitBrandViewResult((FocusItem({ itemId })), "@foldkit/ui/dragAndDrop/index.js#anonymous~16")));
|
|
261
253
|
const maybeOutMessage = Option.liftPredicate(model.dragState._tag, _tag => __foldkitBrandViewResult((_tag === 'Dragging' || _tag === 'KeyboardDragging'), "@foldkit/ui/dragAndDrop/index.js#anonymous~17")).pipe(Option.map(() => __foldkitBrandViewResult((OutMessage.Cancelled()), "@foldkit/ui/dragAndDrop/index.js#anonymous~18")));
|
|
262
|
-
|
|
263
|
-
evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~7") }),
|
|
264
|
-
Option.toArray(maybeFocusCommand),
|
|
265
|
-
|
|
266
|
-
|
|
254
|
+
const dragCancellation = {
|
|
255
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~7") }),
|
|
256
|
+
commands: Option.toArray(maybeFocusCommand),
|
|
257
|
+
};
|
|
258
|
+
return __foldkitBrandViewResult((pipe(dragCancellation, Update.withOutMessage(Option.getOrUndefined(maybeOutMessage)))), "@foldkit/ui/dragAndDrop/index.js#CancelledDrag");
|
|
267
259
|
},
|
|
268
|
-
ActivatedKeyboardDrag: ({ itemId, containerId, index }) => __foldkitBrandViewResult((
|
|
269
|
-
evo(model, {
|
|
260
|
+
ActivatedKeyboardDrag: ({ itemId, containerId, index }) => (__foldkitBrandViewResult(({
|
|
261
|
+
model: evo(model, {
|
|
270
262
|
dragState: () => __foldkitBrandViewResult((KeyboardDragging({
|
|
271
263
|
itemId,
|
|
272
264
|
sourceContainerId: containerId,
|
|
@@ -275,34 +267,31 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
275
267
|
targetIndex: index,
|
|
276
268
|
})), "@foldkit/ui/dragAndDrop/index.js#dragState~8"),
|
|
277
269
|
}),
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
CompletedResolveKeyboardMove: ({ targetContainerId, targetIndex }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('KeyboardDragging', keyboardDragging => __foldkitBrandViewResult(([
|
|
282
|
-
evo(model, {
|
|
270
|
+
}), "@foldkit/ui/dragAndDrop/index.js#ActivatedKeyboardDrag")),
|
|
271
|
+
CompletedResolveKeyboardMove: ({ targetContainerId, targetIndex }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('KeyboardDragging', keyboardDragging => (__foldkitBrandViewResult(({
|
|
272
|
+
model: evo(model, {
|
|
283
273
|
dragState: () => __foldkitBrandViewResult((KeyboardDragging({
|
|
284
274
|
...keyboardDragging,
|
|
285
275
|
targetContainerId,
|
|
286
276
|
targetIndex,
|
|
287
277
|
})), "@foldkit/ui/dragAndDrop/index.js#dragState~9"),
|
|
288
278
|
}),
|
|
289
|
-
[FocusItem({ itemId: keyboardDragging.itemId })],
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
Option.some(OutMessage.Reordered({
|
|
279
|
+
commands: [FocusItem({ itemId: keyboardDragging.itemId })],
|
|
280
|
+
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~19"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#anonymous~20"))))), "@foldkit/ui/dragAndDrop/index.js#CompletedResolveKeyboardMove"),
|
|
281
|
+
ConfirmedKeyboardDrop: () => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('KeyboardDragging', keyboardDragging => (__foldkitBrandViewResult(({
|
|
282
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~10") }),
|
|
283
|
+
commands: [FocusItem({ itemId: keyboardDragging.itemId })],
|
|
284
|
+
outMessage: OutMessage.Reordered({
|
|
296
285
|
itemId: keyboardDragging.itemId,
|
|
297
286
|
fromContainerId: keyboardDragging.sourceContainerId,
|
|
298
287
|
fromIndex: keyboardDragging.sourceIndex,
|
|
299
288
|
toContainerId: keyboardDragging.targetContainerId,
|
|
300
289
|
toIndex: keyboardDragging.targetIndex,
|
|
301
|
-
})
|
|
302
|
-
|
|
303
|
-
PressedArrowKey: ({ direction }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('KeyboardDragging', keyboardDragging => __foldkitBrandViewResult((
|
|
290
|
+
}),
|
|
291
|
+
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~21"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#anonymous~22"))))), "@foldkit/ui/dragAndDrop/index.js#ConfirmedKeyboardDrop"),
|
|
292
|
+
PressedArrowKey: ({ direction }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('KeyboardDragging', keyboardDragging => (__foldkitBrandViewResult(({
|
|
304
293
|
model,
|
|
305
|
-
[
|
|
294
|
+
commands: [
|
|
306
295
|
ResolveKeyboardMove({
|
|
307
296
|
itemId: keyboardDragging.itemId,
|
|
308
297
|
currentContainerId: keyboardDragging.targetContainerId,
|
|
@@ -310,10 +299,9 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
310
299
|
direction,
|
|
311
300
|
}),
|
|
312
301
|
],
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
CompletedFocusItem: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/dragAndDrop/index.js#CompletedFocusItem"),
|
|
302
|
+
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~23"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#anonymous~24"))))), "@foldkit/ui/dragAndDrop/index.js#PressedArrowKey"),
|
|
303
|
+
AdvancedAutoScrollFrame: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#AdvancedAutoScrollFrame")),
|
|
304
|
+
CompletedFocusItem: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#CompletedFocusItem")),
|
|
317
305
|
})), "@foldkit/ui/dragAndDrop/index.js#update");
|
|
318
306
|
// SUBSCRIPTION
|
|
319
307
|
const DragActivity = S.Literals(['Idle', 'Active']);
|