@foldkit/ui 0.153.0 → 0.154.0-canary.2f2a07458578
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 +1 -1
- package/dist/anchor/anchor.d.ts +14 -1
- package/dist/anchor/anchor.d.ts.map +1 -1
- package/dist/anchor/anchor.js +58 -5
- package/dist/animation/index.d.ts +5 -5
- package/dist/animation/schema.d.ts.map +1 -1
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/button/index.d.ts.map +1 -1
- package/dist/calendar/index.d.ts +44 -44
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/combobox/multi.d.ts +47 -47
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/shared.d.ts +44 -44
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +91 -78
- package/dist/combobox/single.d.ts +50 -50
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/datePicker/index.d.ts +102 -102
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/dialog/index.d.ts +38 -18
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +66 -39
- package/dist/dialog/public.d.ts +1 -1
- package/dist/dialog/public.d.ts.map +1 -1
- package/dist/disclosure/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.d.ts +191 -191
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/fieldset/index.d.ts.map +1 -1
- package/dist/fileDrop/index.d.ts +10 -10
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/group.d.ts.map +1 -1
- package/dist/hoverIntent/hoverIntent.d.ts +103 -0
- package/dist/hoverIntent/hoverIntent.d.ts.map +1 -0
- package/dist/hoverIntent/hoverIntent.js +210 -0
- package/dist/hoverIntent/index.d.ts +4 -0
- package/dist/hoverIntent/index.d.ts.map +1 -0
- package/dist/hoverIntent/index.js +2 -0
- package/dist/hoverIntent/message.d.ts +42 -0
- package/dist/hoverIntent/message.d.ts.map +1 -0
- package/dist/hoverIntent/message.js +23 -0
- package/dist/hoverIntent/public.d.ts +3 -0
- package/dist/hoverIntent/public.d.ts.map +1 -0
- package/dist/hoverIntent/public.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/input/index.d.ts.map +1 -1
- package/dist/internal/optionExtensions.d.ts.map +1 -1
- package/dist/internal/selectors.d.ts.map +1 -1
- package/dist/keyboard.d.ts.map +1 -1
- package/dist/listbox/multi.d.ts +43 -43
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/shared.d.ts +38 -38
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +46 -39
- package/dist/listbox/single.d.ts +45 -45
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/menu/index.d.ts +70 -70
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +39 -32
- package/dist/nav/index.d.ts.map +1 -1
- package/dist/popover/index.d.ts +48 -33
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +46 -26
- package/dist/popover/public.d.ts +1 -1
- package/dist/popover/public.d.ts.map +1 -1
- package/dist/popover/public.js +1 -1
- package/dist/radioGroup/index.d.ts +6 -6
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/select/index.d.ts.map +1 -1
- package/dist/slider/index.d.ts +72 -72
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/switch/index.d.ts.map +1 -1
- package/dist/tabs/index.d.ts +6 -6
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.d.ts +18 -15
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/textarea/index.d.ts.map +1 -1
- package/dist/toast/index.d.ts +224 -224
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/schema.d.ts +16 -16
- package/dist/toast/schema.d.ts.map +1 -1
- package/dist/toast/test.d.ts.map +1 -1
- package/dist/toast/update.d.ts +151 -151
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/tooltip/message.d.ts +2 -2
- package/dist/tooltip/message.d.ts.map +1 -1
- package/dist/tooltip/tooltip.d.ts +7 -7
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +15 -11
- package/dist/typeahead.d.ts.map +1 -1
- package/dist/virtualList/index.d.ts +10 -10
- package/dist/virtualList/index.d.ts.map +1 -1
- package/package.json +12 -10
package/dist/dialog/index.d.ts
CHANGED
|
@@ -19,12 +19,13 @@ export type Model = typeof Model.Type;
|
|
|
19
19
|
export declare const Message: import("foldkit/message").MessageUnion<{
|
|
20
20
|
readonly RequestedOpen: {};
|
|
21
21
|
readonly RequestedClose: {};
|
|
22
|
-
readonly
|
|
22
|
+
readonly SucceededShowDialog: {};
|
|
23
|
+
readonly FailedShowDialog: {};
|
|
23
24
|
readonly CompletedCloseDialog: {};
|
|
24
25
|
readonly Unmounted: {};
|
|
25
26
|
readonly CompletedReleaseDialogResources: {};
|
|
26
27
|
readonly GotAnimationMessage: {
|
|
27
|
-
|
|
28
|
+
message: import("foldkit/message").MessageUnion<{
|
|
28
29
|
readonly Showed: {};
|
|
29
30
|
readonly Hid: {};
|
|
30
31
|
readonly CompletedWaitForPaint: {};
|
|
@@ -34,7 +35,8 @@ export declare const Message: import("foldkit/message").MessageUnion<{
|
|
|
34
35
|
}>;
|
|
35
36
|
export type RequestedOpen = typeof Message.RequestedOpen.Type;
|
|
36
37
|
export type RequestedClose = typeof Message.RequestedClose.Type;
|
|
37
|
-
export type
|
|
38
|
+
export type SucceededShowDialog = typeof Message.SucceededShowDialog.Type;
|
|
39
|
+
export type FailedShowDialog = typeof Message.FailedShowDialog.Type;
|
|
38
40
|
export type CompletedCloseDialog = typeof Message.CompletedCloseDialog.Type;
|
|
39
41
|
export type Unmounted = typeof Message.Unmounted.Type;
|
|
40
42
|
export type CompletedReleaseDialogResources = typeof Message.CompletedReleaseDialogResources.Type;
|
|
@@ -80,14 +82,28 @@ type UpdateReturn = Update.ReturnWithOutMessage<Model, Message, OutMessage>;
|
|
|
80
82
|
* `Dom.showDialog`, which calls `show()` (not native `showModal()`) so other
|
|
81
83
|
* high-z-index overlays stay interactive. It layers the dialog with a high
|
|
82
84
|
* z-index, traps focus, and dispatches a `cancel` event on Esc. The Dialog
|
|
83
|
-
* component supplies its own backdrop.
|
|
85
|
+
* component supplies its own backdrop. If the dialog element is gone by the
|
|
86
|
+
* time the show runs, the lock is released and the Command reports
|
|
87
|
+
* `FailedShowDialog`. A closed dialog has no `OnUnmount`, so nothing else
|
|
88
|
+
* would release the lock. The update function then closes the Model. Without
|
|
89
|
+
* this close, the dialog would render open with no lock and no focus trap.
|
|
90
|
+
* The lock is also released if the Command is interrupted while it waits. */
|
|
84
91
|
export declare const ShowDialog: Command.CommandDefinitionWithArgs<"ShowDialog", {
|
|
85
92
|
id: S.String;
|
|
86
93
|
focusSelector: S.String;
|
|
87
94
|
}, Effect.Effect<{
|
|
88
|
-
readonly _tag: "
|
|
95
|
+
readonly _tag: "SucceededShowDialog";
|
|
96
|
+
} | {
|
|
97
|
+
readonly _tag: "FailedShowDialog";
|
|
89
98
|
}, never, never>>;
|
|
90
|
-
/** Calls `close()` on the native dialog element and unlocks page scroll
|
|
99
|
+
/** Calls `close()` on the native dialog element and unlocks page scroll when
|
|
100
|
+
* the close released the resources `ShowDialog` installed. A close that runs
|
|
101
|
+
* before the show has installed them leaves the lock alone. When the show
|
|
102
|
+
* then fails, it releases the lock itself. When the show succeeds, update
|
|
103
|
+
* closes the dialog again. If the dialog element is gone by the time the
|
|
104
|
+
* close runs, the Command calls `Dom.releaseDialogResources` instead. That
|
|
105
|
+
* releases the scroll lock, focus trap, return focus, and stack entry if the
|
|
106
|
+
* dialog still holds them. */
|
|
91
107
|
export declare const CloseDialog: Command.CommandDefinitionWithArgs<"CloseDialog", {
|
|
92
108
|
id: S.String;
|
|
93
109
|
}, Effect.Effect<{
|
|
@@ -111,7 +127,7 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
111
127
|
readonly animation: {
|
|
112
128
|
readonly id: string;
|
|
113
129
|
readonly isShowing: boolean;
|
|
114
|
-
readonly transitionState: "
|
|
130
|
+
readonly transitionState: "EnterAnimating" | "EnterStart" | "Idle" | "LeaveAnimating" | "LeaveStart";
|
|
115
131
|
};
|
|
116
132
|
readonly maybeFocusSelector: Option.Option<string>;
|
|
117
133
|
};
|
|
@@ -120,7 +136,9 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
120
136
|
} | {
|
|
121
137
|
readonly _tag: "RequestedClose";
|
|
122
138
|
} | {
|
|
123
|
-
readonly _tag: "
|
|
139
|
+
readonly _tag: "SucceededShowDialog";
|
|
140
|
+
} | {
|
|
141
|
+
readonly _tag: "FailedShowDialog";
|
|
124
142
|
} | {
|
|
125
143
|
readonly _tag: "CompletedCloseDialog";
|
|
126
144
|
} | {
|
|
@@ -130,13 +148,13 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
130
148
|
} | {
|
|
131
149
|
readonly _tag: "GotAnimationMessage";
|
|
132
150
|
readonly message: {
|
|
133
|
-
readonly _tag: "Showed";
|
|
134
|
-
} | {
|
|
135
|
-
readonly _tag: "Hid";
|
|
136
|
-
} | {
|
|
137
151
|
readonly _tag: "CompletedWaitForPaint";
|
|
138
152
|
} | {
|
|
139
153
|
readonly _tag: "EndedAnimation";
|
|
154
|
+
} | {
|
|
155
|
+
readonly _tag: "Hid";
|
|
156
|
+
} | {
|
|
157
|
+
readonly _tag: "Showed";
|
|
140
158
|
};
|
|
141
159
|
}, never>;
|
|
142
160
|
outMessage?: {
|
|
@@ -229,7 +247,7 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
229
247
|
readonly animation: {
|
|
230
248
|
readonly id: string;
|
|
231
249
|
readonly isShowing: boolean;
|
|
232
|
-
readonly transitionState: "
|
|
250
|
+
readonly transitionState: "EnterAnimating" | "EnterStart" | "Idle" | "LeaveAnimating" | "LeaveStart";
|
|
233
251
|
};
|
|
234
252
|
readonly maybeFocusSelector: Option.Option<string>;
|
|
235
253
|
}, {
|
|
@@ -237,7 +255,9 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
237
255
|
} | {
|
|
238
256
|
readonly _tag: "RequestedClose";
|
|
239
257
|
} | {
|
|
240
|
-
readonly _tag: "
|
|
258
|
+
readonly _tag: "SucceededShowDialog";
|
|
259
|
+
} | {
|
|
260
|
+
readonly _tag: "FailedShowDialog";
|
|
241
261
|
} | {
|
|
242
262
|
readonly _tag: "CompletedCloseDialog";
|
|
243
263
|
} | {
|
|
@@ -247,13 +267,13 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
247
267
|
} | {
|
|
248
268
|
readonly _tag: "GotAnimationMessage";
|
|
249
269
|
readonly message: {
|
|
250
|
-
readonly _tag: "Showed";
|
|
251
|
-
} | {
|
|
252
|
-
readonly _tag: "Hid";
|
|
253
|
-
} | {
|
|
254
270
|
readonly _tag: "CompletedWaitForPaint";
|
|
255
271
|
} | {
|
|
256
272
|
readonly _tag: "EndedAnimation";
|
|
273
|
+
} | {
|
|
274
|
+
readonly _tag: "Hid";
|
|
275
|
+
} | {
|
|
276
|
+
readonly _tag: "Showed";
|
|
257
277
|
};
|
|
258
278
|
}, Readonly<{
|
|
259
279
|
toView: (render: RenderInfo) => Html;
|
|
@@ -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,EAAQ,MAAM,QAAQ,CAAA;AACtE,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAI9E,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAmBxC,6IAA6I;AAC7I,eA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AAO,MAAM,KAAK,UAAW,KAAK,KAAG,YACI,CAAA;AAIzC;;;;;;;+BAO+B;AAC/B,eAAO,MAAM,OAAO,UAAW,KAAK,KAAG,MAAoC,CAAA;AAE3E;;;;;;;qEAOqE;AACrE,eAAO,MAAM,aAAa,UAAW,KAAK,KAAG,MACX,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAoC4B;AAC5B,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACrC,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACvC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACpC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACpC,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;GA6FrC,CAAA"}
|
package/dist/dialog/index.js
CHANGED
|
@@ -27,7 +27,8 @@ export const Model = S.Struct({
|
|
|
27
27
|
export const Message = defineMessageUnion({
|
|
28
28
|
RequestedOpen: {},
|
|
29
29
|
RequestedClose: {},
|
|
30
|
-
|
|
30
|
+
SucceededShowDialog: {},
|
|
31
|
+
FailedShowDialog: {},
|
|
31
32
|
CompletedCloseDialog: {},
|
|
32
33
|
Unmounted: {},
|
|
33
34
|
CompletedReleaseDialogResources: {},
|
|
@@ -62,17 +63,29 @@ export const initialFocusMarkerSelector = `[data-${initialFocusMarkerAttribute}]
|
|
|
62
63
|
* `Dom.showDialog`, which calls `show()` (not native `showModal()`) so other
|
|
63
64
|
* high-z-index overlays stay interactive. It layers the dialog with a high
|
|
64
65
|
* z-index, traps focus, and dispatches a `cancel` event on Esc. The Dialog
|
|
65
|
-
* component supplies its own backdrop.
|
|
66
|
+
* component supplies its own backdrop. If the dialog element is gone by the
|
|
67
|
+
* time the show runs, the lock is released and the Command reports
|
|
68
|
+
* `FailedShowDialog`. A closed dialog has no `OnUnmount`, so nothing else
|
|
69
|
+
* would release the lock. The update function then closes the Model. Without
|
|
70
|
+
* this close, the dialog would render open with no lock and no focus trap.
|
|
71
|
+
* The lock is also released if the Command is interrupted while it waits. */
|
|
66
72
|
export const ShowDialog = Command.define('ShowDialog', {
|
|
67
73
|
args: { id: S.String, focusSelector: S.String },
|
|
68
|
-
messages: [Message.
|
|
69
|
-
execute: ({ id, focusSelector }) => __foldkitBrandViewResult((Dom.lockScroll.pipe(Effect.andThen(() => __foldkitBrandViewResult((Dom.showDialog(dialogSelector(id), { focusSelector })), "@foldkit/ui/dialog/index.js#anonymous")), Effect.
|
|
74
|
+
messages: [Message.SucceededShowDialog, Message.FailedShowDialog],
|
|
75
|
+
execute: ({ id, focusSelector }) => __foldkitBrandViewResult((Dom.lockScroll.pipe(Effect.andThen(() => __foldkitBrandViewResult((Dom.showDialog(dialogSelector(id), { focusSelector }).pipe(Effect.onError(() => __foldkitBrandViewResult((Dom.unlockScroll), "@foldkit/ui/dialog/index.js#anonymous~2")), Effect.as(Message.SucceededShowDialog()), Effect.catch(() => __foldkitBrandViewResult((Effect.succeed(Message.FailedShowDialog())), "@foldkit/ui/dialog/index.js#anonymous~3")))), "@foldkit/ui/dialog/index.js#anonymous")))), "@foldkit/ui/dialog/index.js#execute"),
|
|
70
76
|
});
|
|
71
|
-
/** Calls `close()` on the native dialog element and unlocks page scroll
|
|
77
|
+
/** Calls `close()` on the native dialog element and unlocks page scroll when
|
|
78
|
+
* the close released the resources `ShowDialog` installed. A close that runs
|
|
79
|
+
* before the show has installed them leaves the lock alone. When the show
|
|
80
|
+
* then fails, it releases the lock itself. When the show succeeds, update
|
|
81
|
+
* closes the dialog again. If the dialog element is gone by the time the
|
|
82
|
+
* close runs, the Command calls `Dom.releaseDialogResources` instead. That
|
|
83
|
+
* releases the scroll lock, focus trap, return focus, and stack entry if the
|
|
84
|
+
* dialog still holds them. */
|
|
72
85
|
export const CloseDialog = Command.define('CloseDialog', {
|
|
73
86
|
args: { id: S.String },
|
|
74
87
|
messages: [Message.CompletedCloseDialog],
|
|
75
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.closeDialog(dialogSelector(id)).pipe(Effect.andThen(
|
|
88
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.closeDialog(dialogSelector(id)).pipe(Effect.andThen(isReleased => __foldkitBrandViewResult((isReleased ? Dom.unlockScroll : Effect.void), "@foldkit/ui/dialog/index.js#anonymous~4")), Effect.catch(() => __foldkitBrandViewResult((Dom.releaseDialogResources(id)), "@foldkit/ui/dialog/index.js#anonymous~5")), Effect.as(Message.CompletedCloseDialog()))), "@foldkit/ui/dialog/index.js#execute~2"),
|
|
76
89
|
});
|
|
77
90
|
/** Releases the framework hygiene the dialog holds while open (scroll lock,
|
|
78
91
|
* focus trap, return focus, stack entry) when the element unmounts without a
|
|
@@ -83,21 +96,28 @@ export const ReleaseDialogResources = Command.define('ReleaseDialogResources', {
|
|
|
83
96
|
messages: [Message.CompletedReleaseDialogResources],
|
|
84
97
|
execute: ({ id }) => __foldkitBrandViewResult((Dom.releaseDialogResources(id).pipe(Effect.ignore, Effect.as(Message.CompletedReleaseDialogResources()))), "@foldkit/ui/dialog/index.js#execute~3"),
|
|
85
98
|
});
|
|
99
|
+
const isLeaving = (model) => __foldkitBrandViewResult((model.animation.transitionState === 'LeaveStart' ||
|
|
100
|
+
model.animation.transitionState === 'LeaveAnimating'), "@foldkit/ui/dialog/index.js#isLeaving");
|
|
101
|
+
const isOpenOrAnimating = (model) => __foldkitBrandViewResult((model.isOpen || model.animation.transitionState !== 'Idle'), "@foldkit/ui/dialog/index.js#isOpenOrAnimating");
|
|
102
|
+
const resetToClosed = (model) => __foldkitBrandViewResult((evo(model, {
|
|
103
|
+
isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen"),
|
|
104
|
+
animation: () => __foldkitBrandViewResult((animationInit({ id: `${model.id}-panel` })), "@foldkit/ui/dialog/index.js#animation"),
|
|
105
|
+
})), "@foldkit/ui/dialog/index.js#resetToClosed");
|
|
86
106
|
const wrapAnimationMessage = (message) => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/dialog/index.js#wrapAnimationMessage");
|
|
87
107
|
const foldAnimationOutMessage = (outMessage, { liftCommand }) => __foldkitBrandViewResult((AnimationOutMessage.match(outMessage, {
|
|
88
108
|
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({
|
|
89
109
|
model,
|
|
90
110
|
commands: [liftCommand(animationDefaultLeaveCommand(model.animation))],
|
|
91
|
-
}), "@foldkit/ui/dialog/index.js#anonymous~
|
|
111
|
+
}), "@foldkit/ui/dialog/index.js#anonymous~6"))), "@foldkit/ui/dialog/index.js#StartedLeaveAnimating"),
|
|
92
112
|
TransitionedOut: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({
|
|
93
113
|
model,
|
|
94
114
|
commands: [CloseDialog({ id: model.id })],
|
|
95
|
-
}), "@foldkit/ui/dialog/index.js#anonymous~
|
|
115
|
+
}), "@foldkit/ui/dialog/index.js#anonymous~7"))), "@foldkit/ui/dialog/index.js#TransitionedOut"),
|
|
96
116
|
})), "@foldkit/ui/dialog/index.js#foldAnimationOutMessage");
|
|
97
117
|
const foldAnimation = Update.foldChild({
|
|
98
118
|
update: animationUpdate,
|
|
99
119
|
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/dialog/index.js#read"),
|
|
100
|
-
write: (model, nextAnimation) => __foldkitBrandViewResult((evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/dialog/index.js#animation") })), "@foldkit/ui/dialog/index.js#write"),
|
|
120
|
+
write: (model, nextAnimation) => __foldkitBrandViewResult((evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/dialog/index.js#animation~2") })), "@foldkit/ui/dialog/index.js#write"),
|
|
101
121
|
toParentMessage: wrapAnimationMessage,
|
|
102
122
|
foldOutMessage: foldAnimationOutMessage,
|
|
103
123
|
});
|
|
@@ -107,44 +127,42 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
107
127
|
const wasClosed = !model.isOpen;
|
|
108
128
|
const maybeShow = Option.liftPredicate(ShowDialog({
|
|
109
129
|
id: model.id,
|
|
110
|
-
focusSelector: Option.getOrElse(model.maybeFocusSelector, () => __foldkitBrandViewResult((initialFocusMarkerSelector), "@foldkit/ui/dialog/index.js#anonymous~
|
|
111
|
-
}), () => __foldkitBrandViewResult((wasClosed), "@foldkit/ui/dialog/index.js#anonymous~
|
|
130
|
+
focusSelector: Option.getOrElse(model.maybeFocusSelector, () => __foldkitBrandViewResult((initialFocusMarkerSelector), "@foldkit/ui/dialog/index.js#anonymous~8")),
|
|
131
|
+
}), () => __foldkitBrandViewResult((wasClosed), "@foldkit/ui/dialog/index.js#anonymous~9"));
|
|
112
132
|
const commands = Option.toArray(maybeShow);
|
|
113
133
|
const dialogOpen = model.isAnimated
|
|
114
134
|
? Update.combine(model, [
|
|
115
|
-
stepModel => (__foldkitBrandViewResult(({ model: stepModel, commands }), "@foldkit/ui/dialog/index.js#anonymous~
|
|
135
|
+
stepModel => (__foldkitBrandViewResult(({ model: stepModel, commands }), "@foldkit/ui/dialog/index.js#anonymous~10")),
|
|
116
136
|
foldAnimation(AnimationMessage.Showed()),
|
|
117
137
|
stepModel => (__foldkitBrandViewResult(({
|
|
118
|
-
model: evo(stepModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/dialog/index.js#isOpen") }),
|
|
119
|
-
}), "@foldkit/ui/dialog/index.js#anonymous~
|
|
138
|
+
model: evo(stepModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/dialog/index.js#isOpen~2") }),
|
|
139
|
+
}), "@foldkit/ui/dialog/index.js#anonymous~11")),
|
|
120
140
|
])
|
|
121
|
-
: { model: evo(model, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/dialog/index.js#isOpen~
|
|
141
|
+
: { model: evo(model, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/dialog/index.js#isOpen~3") }), commands };
|
|
122
142
|
return __foldkitBrandViewResult((wasClosed
|
|
123
143
|
? pipe(dialogOpen, Update.withOutMessage(OutMessage.Opened()))
|
|
124
144
|
: dialogOpen), "@foldkit/ui/dialog/index.js#RequestedOpen");
|
|
125
145
|
},
|
|
126
146
|
RequestedClose: () => {
|
|
127
|
-
|
|
128
|
-
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
129
|
-
if (isLeaving) {
|
|
147
|
+
if (isLeaving(model)) {
|
|
130
148
|
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#RequestedClose");
|
|
131
149
|
}
|
|
132
150
|
const wasOpen = model.isOpen;
|
|
133
151
|
if (model.isAnimated) {
|
|
134
152
|
const dialogClose = Update.combine(model, [
|
|
135
153
|
stepModel => (__foldkitBrandViewResult(({
|
|
136
|
-
model: evo(stepModel, { isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~
|
|
137
|
-
}), "@foldkit/ui/dialog/index.js#anonymous~
|
|
154
|
+
model: evo(stepModel, { isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~4") }),
|
|
155
|
+
}), "@foldkit/ui/dialog/index.js#anonymous~12")),
|
|
138
156
|
foldAnimation(AnimationMessage.Hid()),
|
|
139
157
|
]);
|
|
140
158
|
return __foldkitBrandViewResult((wasOpen
|
|
141
159
|
? pipe(dialogClose, Update.withOutMessage(OutMessage.Closed()))
|
|
142
160
|
: dialogClose), "@foldkit/ui/dialog/index.js#RequestedClose");
|
|
143
161
|
}
|
|
144
|
-
const maybeClose = Option.liftPredicate(CloseDialog({ id: model.id }), () => __foldkitBrandViewResult((wasOpen), "@foldkit/ui/dialog/index.js#anonymous~
|
|
162
|
+
const maybeClose = Option.liftPredicate(CloseDialog({ id: model.id }), () => __foldkitBrandViewResult((wasOpen), "@foldkit/ui/dialog/index.js#anonymous~13"));
|
|
145
163
|
const commands = Option.toArray(maybeClose);
|
|
146
164
|
const dialogClose = {
|
|
147
|
-
model: evo(model, { isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~
|
|
165
|
+
model: evo(model, { isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~5") }),
|
|
148
166
|
commands,
|
|
149
167
|
};
|
|
150
168
|
return __foldkitBrandViewResult((wasOpen
|
|
@@ -153,14 +171,9 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
153
171
|
},
|
|
154
172
|
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((foldAnimation(model, animationMessage)), "@foldkit/ui/dialog/index.js#GotAnimationMessage"),
|
|
155
173
|
Unmounted: () => {
|
|
156
|
-
|
|
157
|
-
if (isHoldingResources) {
|
|
158
|
-
const nextModel = evo(model, {
|
|
159
|
-
isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/dialog/index.js#isOpen~5"),
|
|
160
|
-
animation: () => __foldkitBrandViewResult((animationInit({ id: `${model.id}-panel` })), "@foldkit/ui/dialog/index.js#animation~2"),
|
|
161
|
-
});
|
|
174
|
+
if (isOpenOrAnimating(model)) {
|
|
162
175
|
return __foldkitBrandViewResult(({
|
|
163
|
-
model:
|
|
176
|
+
model: resetToClosed(model),
|
|
164
177
|
commands: [ReleaseDialogResources({ id: model.id })],
|
|
165
178
|
}), "@foldkit/ui/dialog/index.js#Unmounted");
|
|
166
179
|
}
|
|
@@ -168,7 +181,22 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
168
181
|
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#Unmounted");
|
|
169
182
|
}
|
|
170
183
|
},
|
|
171
|
-
|
|
184
|
+
SucceededShowDialog: () => {
|
|
185
|
+
if (model.isOpen || isLeaving(model)) {
|
|
186
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#SucceededShowDialog");
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
return __foldkitBrandViewResult(({ model, commands: [CloseDialog({ id: model.id })] }), "@foldkit/ui/dialog/index.js#SucceededShowDialog");
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
FailedShowDialog: () => {
|
|
193
|
+
if (isOpenOrAnimating(model)) {
|
|
194
|
+
return __foldkitBrandViewResult(({ model: resetToClosed(model) }), "@foldkit/ui/dialog/index.js#FailedShowDialog");
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#FailedShowDialog");
|
|
198
|
+
}
|
|
199
|
+
},
|
|
172
200
|
CompletedCloseDialog: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#CompletedCloseDialog")),
|
|
173
201
|
CompletedReleaseDialogResources: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dialog/index.js#CompletedReleaseDialogResources")),
|
|
174
202
|
})), "@foldkit/ui/dialog/index.js#update");
|
|
@@ -202,23 +230,22 @@ export const descriptionId = (model) => __foldkitBrandViewResult((`${model.id}-d
|
|
|
202
230
|
export const view = defineView((model, viewInputs, h) => {
|
|
203
231
|
const { id, isOpen, animation: { transitionState }, } = model;
|
|
204
232
|
const { toView } = viewInputs;
|
|
205
|
-
const
|
|
206
|
-
const isVisible = isOpen || isLeaving;
|
|
233
|
+
const isVisible = isOpen || isLeaving(model);
|
|
207
234
|
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
208
235
|
h.DataAttribute('closed', ''),
|
|
209
236
|
h.DataAttribute('enter', ''),
|
|
210
237
|
h.DataAttribute('transition', ''),
|
|
211
|
-
]), "@foldkit/ui/dialog/index.js#anonymous~
|
|
238
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~15")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
212
239
|
h.DataAttribute('enter', ''),
|
|
213
240
|
h.DataAttribute('transition', ''),
|
|
214
|
-
]), "@foldkit/ui/dialog/index.js#anonymous~
|
|
241
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~16")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
215
242
|
h.DataAttribute('leave', ''),
|
|
216
243
|
h.DataAttribute('transition', ''),
|
|
217
|
-
]), "@foldkit/ui/dialog/index.js#anonymous~
|
|
244
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~17")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
218
245
|
h.DataAttribute('closed', ''),
|
|
219
246
|
h.DataAttribute('leave', ''),
|
|
220
247
|
h.DataAttribute('transition', ''),
|
|
221
|
-
]), "@foldkit/ui/dialog/index.js#anonymous~
|
|
248
|
+
]), "@foldkit/ui/dialog/index.js#anonymous~18")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/dialog/index.js#anonymous~19")));
|
|
222
249
|
const dialogAttributes = [
|
|
223
250
|
h.Id(id),
|
|
224
251
|
h.AriaLabelledBy(titleId(model)),
|
|
@@ -244,7 +271,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
244
271
|
const backdropAttributes = [
|
|
245
272
|
h.Style({ minHeight: '100vh' }),
|
|
246
273
|
...animationAttributes,
|
|
247
|
-
...(isLeaving ? [] : [h.OnClick(Message.RequestedClose())]),
|
|
274
|
+
...(isLeaving(model) ? [] : [h.OnClick(Message.RequestedClose())]),
|
|
248
275
|
];
|
|
249
276
|
const panelAttributes = [h.Id(`${id}-panel`), ...animationAttributes];
|
|
250
277
|
const titleAttributes = [h.Id(titleId(model))];
|
|
@@ -254,7 +281,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
254
281
|
];
|
|
255
282
|
const closeButtonAttributes = [
|
|
256
283
|
h.Type('button'),
|
|
257
|
-
...(isLeaving ? [] : [h.OnClick(Message.RequestedClose())]),
|
|
284
|
+
...(isLeaving(model) ? [] : [h.OnClick(Message.RequestedClose())]),
|
|
258
285
|
];
|
|
259
286
|
return __foldkitBrandViewResult((toView({
|
|
260
287
|
dialog: childAttributes(dialogAttributes),
|
|
@@ -265,5 +292,5 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
265
292
|
initialFocus: childAttributes(initialFocusAttributes),
|
|
266
293
|
closeButton: childAttributes(closeButtonAttributes),
|
|
267
294
|
isVisible,
|
|
268
|
-
})), "@foldkit/ui/dialog/index.js#anonymous~
|
|
295
|
+
})), "@foldkit/ui/dialog/index.js#anonymous~14");
|
|
269
296
|
});
|
package/dist/dialog/public.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { init, update, open, close, view, titleId, descriptionId, Model, Message, OutMessage, type Opened, type Closed, type RequestedOpen, type RequestedClose, type
|
|
1
|
+
export { init, update, open, close, view, titleId, descriptionId, Model, Message, OutMessage, type Opened, type Closed, type RequestedOpen, type RequestedClose, type SucceededShowDialog, type FailedShowDialog, type CompletedCloseDialog, type Unmounted, type CompletedReleaseDialogResources, ShowDialog, CloseDialog, ReleaseDialogResources, } from './index.js';
|
|
2
2
|
export type { InitConfig, ViewInputs, RenderInfo } from './index.js';
|
|
3
3
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/dialog/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,EACP,aAAa,EACb,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,+BAA+B,EACpC,UAAU,EACV,WAAW,EACX,sBAAsB,GACvB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/dialog/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,EACP,aAAa,EACb,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,+BAA+B,EACpC,UAAU,EACV,WAAW,EACX,sBAAsB,GACvB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":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