@foldkit/ui 0.118.0 → 0.119.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/dialog/index.d.ts +37 -5
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +37 -1
- package/dist/dialog/public.d.ts +1 -1
- package/dist/dialog/public.d.ts.map +1 -1
- package/dist/dialog/public.js +1 -1
- package/dist/disclosure/index.d.ts +9 -0
- package/dist/disclosure/index.d.ts.map +1 -1
- package/dist/disclosure/index.js +16 -0
- package/dist/test/apps/disabledButton.d.ts +2 -2
- package/package.json +4 -2
package/dist/dialog/index.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ export declare const RequestedClose: import("foldkit/schema").CallableTaggedStru
|
|
|
22
22
|
export declare const CompletedShowDialog: import("foldkit/schema").CallableTaggedStruct<"CompletedShowDialog", {}>;
|
|
23
23
|
/** Sent when the close-dialog command completes. */
|
|
24
24
|
export declare const CompletedCloseDialog: import("foldkit/schema").CallableTaggedStruct<"CompletedCloseDialog", {}>;
|
|
25
|
+
/** Sent when the native `<dialog>` element is removed from the DOM, the classic
|
|
26
|
+
* case being navigation away from a route-keyed subtree that contains the
|
|
27
|
+
* dialog. When the dialog still holds framework resources, `update` triggers
|
|
28
|
+
* the hygiene-only `ReleaseDialogResources` command and resets the model to a
|
|
29
|
+
* clean closed state. Does not emit `Closed` or run any consumer close
|
|
30
|
+
* Commands: it is a backstop, not the purposeful close. */
|
|
31
|
+
export declare const Unmounted: import("foldkit/schema").CallableTaggedStruct<"Unmounted", {}>;
|
|
32
|
+
/** Sent when the release-dialog-resources command completes. */
|
|
33
|
+
export declare const CompletedReleaseDialogResources: import("foldkit/schema").CallableTaggedStruct<"CompletedReleaseDialogResources", {}>;
|
|
25
34
|
/** Wraps an Animation submodel message for delegation. */
|
|
26
35
|
export declare const GotAnimationMessage: import("foldkit/schema").CallableTaggedStruct<"GotAnimationMessage", {
|
|
27
36
|
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"Showed", {}>, import("foldkit/schema").CallableTaggedStruct<"Hid", {}>, import("foldkit/schema").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("foldkit/schema").CallableTaggedStruct<"EndedAnimation", {}>]>;
|
|
@@ -32,12 +41,16 @@ export declare const Message: S.Union<[
|
|
|
32
41
|
typeof RequestedClose,
|
|
33
42
|
typeof CompletedShowDialog,
|
|
34
43
|
typeof CompletedCloseDialog,
|
|
44
|
+
typeof Unmounted,
|
|
45
|
+
typeof CompletedReleaseDialogResources,
|
|
35
46
|
typeof GotAnimationMessage
|
|
36
47
|
]>;
|
|
37
48
|
export type RequestedOpen = typeof RequestedOpen.Type;
|
|
38
49
|
export type RequestedClose = typeof RequestedClose.Type;
|
|
39
50
|
export type CompletedShowDialog = typeof CompletedShowDialog.Type;
|
|
40
51
|
export type CompletedCloseDialog = typeof CompletedCloseDialog.Type;
|
|
52
|
+
export type Unmounted = typeof Unmounted.Type;
|
|
53
|
+
export type CompletedReleaseDialogResources = typeof CompletedReleaseDialogResources.Type;
|
|
41
54
|
export type Message = typeof Message.Type;
|
|
42
55
|
/** Sent once the dialog has transitioned to open. Fires after `update`
|
|
43
56
|
* has processed `RequestedOpen` and `isOpen` reflects the new state.
|
|
@@ -54,7 +67,10 @@ export declare const OutMessage: S.Union<readonly [import("foldkit/schema").Call
|
|
|
54
67
|
export type Opened = typeof Opened.Type;
|
|
55
68
|
export type Closed = typeof Closed.Type;
|
|
56
69
|
export type OutMessage = typeof OutMessage.Type;
|
|
57
|
-
/** Configuration for creating a dialog model with `init`.
|
|
70
|
+
/** Configuration for creating a dialog model with `init`. The `id` must be
|
|
71
|
+
* non-empty and unique within the document: it keys the dialog element, its
|
|
72
|
+
* ARIA references, and the framework's per-dialog resource cleanup, so a
|
|
73
|
+
* duplicate or empty id breaks cleanup accounting. */
|
|
58
74
|
export type InitConfig = Readonly<{
|
|
59
75
|
id: string;
|
|
60
76
|
isOpen?: boolean;
|
|
@@ -81,6 +97,15 @@ export declare const CloseDialog: Command.CommandDefinitionWithArgs<"CloseDialog
|
|
|
81
97
|
}, Effect.Effect<{
|
|
82
98
|
readonly _tag: "CompletedCloseDialog";
|
|
83
99
|
}, never, never>>;
|
|
100
|
+
/** Releases the framework hygiene the dialog holds while open (scroll lock,
|
|
101
|
+
* focus trap, return focus, stack entry) when the element unmounts without a
|
|
102
|
+
* purposeful close. Idempotent: a no-op if the dialog already released its
|
|
103
|
+
* resources through `CloseDialog`. */
|
|
104
|
+
export declare const ReleaseDialogResources: Command.CommandDefinitionWithArgs<"ReleaseDialogResources", {
|
|
105
|
+
id: S.String;
|
|
106
|
+
}, Effect.Effect<{
|
|
107
|
+
readonly _tag: "CompletedReleaseDialogResources";
|
|
108
|
+
}, never, never>>;
|
|
84
109
|
/** Processes a dialog message and returns the next model and commands. */
|
|
85
110
|
export declare const update: (model: Model, message: Message) => UpdateReturn;
|
|
86
111
|
/** Programmatically opens the dialog. */
|
|
@@ -94,10 +119,13 @@ export declare const descriptionId: (model: Model) => string;
|
|
|
94
119
|
/** Render-time payload published to the consumer's `toView`.
|
|
95
120
|
*
|
|
96
121
|
* - `dialog`: attributes for the native `<dialog>` element. Carries
|
|
97
|
-
* the id, ARIA labelling, `open` prop, positioning style,
|
|
98
|
-
* `OnCancel` handler that wires Escape to `RequestedClose
|
|
99
|
-
*
|
|
100
|
-
*
|
|
122
|
+
* the id, ARIA labelling, `open` prop, positioning style, the
|
|
123
|
+
* `OnCancel` handler that wires Escape to `RequestedClose`, and an
|
|
124
|
+
* `OnUnmount` backstop that releases framework hygiene (scroll lock,
|
|
125
|
+
* focus trap, return focus) if the element is removed from the DOM
|
|
126
|
+
* while still open, such as navigating away from a route-keyed subtree.
|
|
127
|
+
* The consumer MUST render an `h.dialog(...)` element so the framework
|
|
128
|
+
* can open and close it, and so the unmount backstop can fire.
|
|
101
129
|
* - `backdrop`: attributes for the backdrop element. Includes the
|
|
102
130
|
* Animation data attributes and the `OnClick` handler that closes
|
|
103
131
|
* the dialog on outside-click (suppressed while a leave animation
|
|
@@ -142,6 +170,10 @@ export declare const view: import("foldkit/submodel").View<S.Struct.ReadonlySide
|
|
|
142
170
|
readonly _tag: S.tag<"CompletedShowDialog">;
|
|
143
171
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
144
172
|
readonly _tag: S.tag<"CompletedCloseDialog">;
|
|
173
|
+
}, "Type"> | S.Struct.ReadonlySide<{
|
|
174
|
+
readonly _tag: S.tag<"Unmounted">;
|
|
175
|
+
}, "Type"> | S.Struct.ReadonlySide<{
|
|
176
|
+
readonly _tag: S.tag<"CompletedReleaseDialogResources">;
|
|
145
177
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
146
178
|
readonly _tag: S.tag<"GotAnimationMessage">;
|
|
147
179
|
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"Showed", {}>, import("foldkit/schema").CallableTaggedStruct<"Hid", {}>, import("foldkit/schema").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("foldkit/schema").CallableTaggedStruct<"EndedAnimation", {}>]>;
|
|
@@ -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,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EAGV,MAAM,cAAc,CAAA;AAwBrB,6IAA6I;AAC7I,eAAO,MAAM,KAAK;;;;;;;;;;EAMhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,yEAAyE;AACzE,eAAO,MAAM,aAAa,oEAAqB,CAAA;AAC/C,uFAAuF;AACvF,eAAO,MAAM,cAAc,qEAAsB,CAAA;AACjD,mDAAmD;AACnD,eA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;YALP,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;GAmFrC,CAAA"}
|
package/dist/dialog/index.js
CHANGED
|
@@ -29,6 +29,15 @@ export const RequestedClose = m('RequestedClose');
|
|
|
29
29
|
export const CompletedShowDialog = m('CompletedShowDialog');
|
|
30
30
|
/** Sent when the close-dialog command completes. */
|
|
31
31
|
export const CompletedCloseDialog = m('CompletedCloseDialog');
|
|
32
|
+
/** Sent when the native `<dialog>` element is removed from the DOM, the classic
|
|
33
|
+
* case being navigation away from a route-keyed subtree that contains the
|
|
34
|
+
* dialog. When the dialog still holds framework resources, `update` triggers
|
|
35
|
+
* the hygiene-only `ReleaseDialogResources` command and resets the model to a
|
|
36
|
+
* clean closed state. Does not emit `Closed` or run any consumer close
|
|
37
|
+
* Commands: it is a backstop, not the purposeful close. */
|
|
38
|
+
export const Unmounted = m('Unmounted');
|
|
39
|
+
/** Sent when the release-dialog-resources command completes. */
|
|
40
|
+
export const CompletedReleaseDialogResources = m('CompletedReleaseDialogResources');
|
|
32
41
|
/** Wraps an Animation submodel message for delegation. */
|
|
33
42
|
export const GotAnimationMessage = m('GotAnimationMessage', {
|
|
34
43
|
message: AnimationMessage,
|
|
@@ -39,6 +48,8 @@ export const Message = S.Union([
|
|
|
39
48
|
RequestedClose,
|
|
40
49
|
CompletedShowDialog,
|
|
41
50
|
CompletedCloseDialog,
|
|
51
|
+
Unmounted,
|
|
52
|
+
CompletedReleaseDialogResources,
|
|
42
53
|
GotAnimationMessage,
|
|
43
54
|
]);
|
|
44
55
|
// OUT MESSAGE
|
|
@@ -75,6 +86,11 @@ export const ShowDialog = Command.define('ShowDialog', { id: S.String, maybeFocu
|
|
|
75
86
|
}))), Effect.ignore, Effect.as(CompletedShowDialog())));
|
|
76
87
|
/** Calls `close()` on the native dialog element and unlocks page scroll. */
|
|
77
88
|
export const CloseDialog = Command.define('CloseDialog', { id: S.String }, CompletedCloseDialog)(({ id }) => Dom.closeModal(dialogSelector(id)).pipe(Effect.andThen(() => Dom.unlockScroll), Effect.ignore, Effect.as(CompletedCloseDialog())));
|
|
89
|
+
/** Releases the framework hygiene the dialog holds while open (scroll lock,
|
|
90
|
+
* focus trap, return focus, stack entry) when the element unmounts without a
|
|
91
|
+
* purposeful close. Idempotent: a no-op if the dialog already released its
|
|
92
|
+
* resources through `CloseDialog`. */
|
|
93
|
+
export const ReleaseDialogResources = Command.define('ReleaseDialogResources', { id: S.String }, CompletedReleaseDialogResources)(({ id }) => Dom.releaseDialogResources(id).pipe(Effect.ignore, Effect.as(CompletedReleaseDialogResources())));
|
|
78
94
|
const wrapAnimationMessage = (message) => GotAnimationMessage({ message });
|
|
79
95
|
const delegateToAnimation = (model, animationMessage) => {
|
|
80
96
|
const [nextAnimation, animationCommands, maybeOutMessage] = animationUpdate(model.animation, animationMessage);
|
|
@@ -140,8 +156,26 @@ export const update = (model, message) => M.value(message).pipe(withUpdateReturn
|
|
|
140
156
|
];
|
|
141
157
|
},
|
|
142
158
|
GotAnimationMessage: ({ message: animationMessage }) => delegateToAnimation(model, animationMessage),
|
|
159
|
+
Unmounted: () => {
|
|
160
|
+
const isHoldingResources = model.isOpen || model.animation.transitionState !== 'Idle';
|
|
161
|
+
if (isHoldingResources) {
|
|
162
|
+
const nextModel = evo(model, {
|
|
163
|
+
isOpen: () => false,
|
|
164
|
+
animation: () => animationInit({ id: `${model.id}-panel` }),
|
|
165
|
+
});
|
|
166
|
+
return [
|
|
167
|
+
nextModel,
|
|
168
|
+
[ReleaseDialogResources({ id: model.id })],
|
|
169
|
+
Option.none(),
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
return [model, [], Option.none()];
|
|
174
|
+
}
|
|
175
|
+
},
|
|
143
176
|
CompletedShowDialog: () => [model, [], Option.none()],
|
|
144
177
|
CompletedCloseDialog: () => [model, [], Option.none()],
|
|
178
|
+
CompletedReleaseDialogResources: () => [model, [], Option.none()],
|
|
145
179
|
}));
|
|
146
180
|
/** Programmatically opens the dialog. */
|
|
147
181
|
export const open = (model) => update(model, RequestedOpen());
|
|
@@ -193,7 +227,9 @@ export const view = defineView((model, viewInputs) => {
|
|
|
193
227
|
? { position: 'fixed', inset: '0', zIndex: '2147483600' }
|
|
194
228
|
: {}),
|
|
195
229
|
}),
|
|
196
|
-
...(isVisible
|
|
230
|
+
...(isVisible
|
|
231
|
+
? [h.DataAttribute('open', ''), h.OnUnmount(Unmounted())]
|
|
232
|
+
: []),
|
|
197
233
|
];
|
|
198
234
|
const backdropAttributes = [
|
|
199
235
|
h.Style({ minHeight: '100vh' }),
|
package/dist/dialog/public.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { init, update, open, close, view, titleId, descriptionId, Model, Message, OutMessage, Opened, Closed, RequestedOpen, RequestedClose, CompletedShowDialog, CompletedCloseDialog, GotAnimationMessage, ShowDialog, CloseDialog, } from './index.js';
|
|
1
|
+
export { init, update, open, close, view, titleId, descriptionId, Model, Message, OutMessage, Opened, Closed, RequestedOpen, RequestedClose, CompletedShowDialog, CompletedCloseDialog, Unmounted, CompletedReleaseDialogResources, GotAnimationMessage, 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,MAAM,EACN,MAAM,EACN,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,WAAW,
|
|
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,MAAM,EACN,MAAM,EACN,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,+BAA+B,EAC/B,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,sBAAsB,GACvB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/dialog/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, update, open, close, view, titleId, descriptionId, Model, Message, OutMessage, Opened, Closed, RequestedOpen, RequestedClose, CompletedShowDialog, CompletedCloseDialog, GotAnimationMessage, ShowDialog, CloseDialog, } from './index.js';
|
|
1
|
+
export { init, update, open, close, view, titleId, descriptionId, Model, Message, OutMessage, Opened, Closed, RequestedOpen, RequestedClose, CompletedShowDialog, CompletedCloseDialog, Unmounted, CompletedReleaseDialogResources, GotAnimationMessage, ShowDialog, CloseDialog, ReleaseDialogResources, } from './index.js';
|
|
@@ -72,6 +72,15 @@ export declare const reflectOpenState: Reflect<Model, boolean>;
|
|
|
72
72
|
export type DisclosureAttributes = Readonly<{
|
|
73
73
|
button: ReadonlyArray<ChildAttribute>;
|
|
74
74
|
panel: ReadonlyArray<ChildAttribute>;
|
|
75
|
+
/** Wraps panel content in a CSS-grid container that smoothly animates
|
|
76
|
+
* height (`grid-template-rows: 0fr → 1fr` with `overflow: hidden`) as
|
|
77
|
+
* the disclosure opens and closes. Unlike the bare conditional render,
|
|
78
|
+
* the panel stays mounted while collapsed, so the transition has
|
|
79
|
+
* something to animate from and to. Spread the `panel` bundle onto the
|
|
80
|
+
* element you pass in, and render it unconditionally rather than gating
|
|
81
|
+
* on `isOpen`. The collapsed content is marked `aria-hidden`. Mirrors the
|
|
82
|
+
* `Ui.Animation` `animateSize` flag. */
|
|
83
|
+
animatePanel: (content: Html) => Html;
|
|
75
84
|
}>;
|
|
76
85
|
/** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field.
|
|
77
86
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/disclosure/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAwB,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1E,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EAGV,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,kBAAkB,CAAA;AAM3D,kGAAkG;AAClG,eAAO,MAAM,KAAK;;;EAGhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,iFAAiF;AACjF,eAAO,MAAM,OAAO,8DAAe,CAAA;AACnC,gFAAgF;AAChF,eAAO,MAAM,MAAM,6DAAc,CAAA;AACjC,kEAAkE;AAClE,eAAO,MAAM,oBAAoB,2EAA4B,CAAA;AAE7D,kEAAkE;AAClE,eAAO,MAAM,OAAO,EAAE,CAAC,CAAC,KAAK,CAC3B;IAAC,OAAO,OAAO;IAAE,OAAO,MAAM;IAAE,OAAO,oBAAoB;CAAC,CACV,CAAA;AAEpD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AACzC,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AACvC,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAA;AAEnE,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,4RAA4R;AAC5R,eAAO,MAAM,gBAAgB;;EAA+C,CAAA;AAE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AY,GAAG,SAAS;IAC3B,KAAK;IACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;CAC1B,CAAA;AAGD,oGAAoG;AACpG,eAAO,MAAM,MAAM,GAAI,OAAO,KAAK,EAAE,SAAS,OAAO,KAAG,YAkCrD,CAAA;AAEH;2DAC2D;AAC3D,eAAO,MAAM,MAAM,GAAI,OAAO,KAAK,KAAG,YAAwC,CAAA;AAE9E;4EAC4E;AAC5E,eAAO,MAAM,KAAK,GAAI,OAAO,KAAK,KAAG,YAAuC,CAAA;AAE5E;;;;;yDAKyD;AACzD,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAIpD,CAAA;AAMD;;sCAEsC;AACtC,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACrC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACpC;;;;;;;6CAOyC;IACzC,YAAY,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAA;CACtC,CAAC,CAAA;AAEF;;;;;;;yDAOyD;AACzD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,CAAC,UAAU,EAAE,oBAAoB,KAAK,IAAI,CAAA;IAClD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAC,CAAA;AAEF;;;;;;;yDAOyD;AACzD,eAAO,MAAM,IAAI;;;;;;;;;;YAZP,CAAC,UAAU,EAAE,oBAAoB,KAAK,IAAI;iBACrC,OAAO;GAwErB,CAAA"}
|
package/dist/disclosure/index.js
CHANGED
|
@@ -74,6 +74,8 @@ export const close = (model) => update(model, Closed());
|
|
|
74
74
|
* *choices* and emit `ToggledOpenState`. Returns the model directly
|
|
75
75
|
* because it produces no commands and no OutMessage. */
|
|
76
76
|
export const reflectOpenState = Function.dual(2, (model, isOpen) => evo(model, { isOpen: () => isOpen }));
|
|
77
|
+
// VIEW
|
|
78
|
+
const panelSizeTransition = 'grid-template-rows 200ms ease-out';
|
|
77
79
|
/** Renders a headless disclosure component with accessible ARIA
|
|
78
80
|
* attributes and keyboard support. The consumer composes the layout
|
|
79
81
|
* through the `toView` slot, spreading the published `button` and
|
|
@@ -105,8 +107,22 @@ export const view = defineView((model, viewInputs) => {
|
|
|
105
107
|
h.Id(panelId(id)),
|
|
106
108
|
...(isOpen ? [h.DataAttribute('open', '')] : []),
|
|
107
109
|
];
|
|
110
|
+
const animatePanel = (content) => h.div([
|
|
111
|
+
h.Style({
|
|
112
|
+
display: 'grid',
|
|
113
|
+
gridTemplateRows: isOpen ? '1fr' : '0fr',
|
|
114
|
+
transition: panelSizeTransition,
|
|
115
|
+
overflow: 'hidden',
|
|
116
|
+
}),
|
|
117
|
+
], [
|
|
118
|
+
h.div([
|
|
119
|
+
h.Style({ minHeight: '0px', overflow: 'hidden' }),
|
|
120
|
+
...(isOpen ? [] : [h.AriaHidden(true)]),
|
|
121
|
+
], [content]),
|
|
122
|
+
]);
|
|
108
123
|
return toView({
|
|
109
124
|
button: childAttributes(buttonAttributes),
|
|
110
125
|
panel: childAttributes(panelAttributes),
|
|
126
|
+
animatePanel,
|
|
111
127
|
});
|
|
112
128
|
});
|
|
@@ -19,12 +19,12 @@ export type Model = typeof Model.Type;
|
|
|
19
19
|
export declare const ClickedToggle: import("foldkit/schema").CallableTaggedStruct<"ClickedToggle", {}>;
|
|
20
20
|
export declare const ClickedSubmit: import("foldkit/schema").CallableTaggedStruct<"ClickedSubmit", {}>;
|
|
21
21
|
export declare const GotDialogMessage: import("foldkit/schema").CallableTaggedStruct<"GotDialogMessage", {
|
|
22
|
-
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"RequestedOpen", {}>, import("foldkit/schema").CallableTaggedStruct<"RequestedClose", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedShowDialog", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedCloseDialog", {}>, import("foldkit/schema").CallableTaggedStruct<"GotAnimationMessage", {
|
|
22
|
+
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"RequestedOpen", {}>, import("foldkit/schema").CallableTaggedStruct<"RequestedClose", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedShowDialog", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedCloseDialog", {}>, import("foldkit/schema").CallableTaggedStruct<"Unmounted", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedReleaseDialogResources", {}>, import("foldkit/schema").CallableTaggedStruct<"GotAnimationMessage", {
|
|
23
23
|
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"Showed", {}>, import("foldkit/schema").CallableTaggedStruct<"Hid", {}>, import("foldkit/schema").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("foldkit/schema").CallableTaggedStruct<"EndedAnimation", {}>]>;
|
|
24
24
|
}>]>;
|
|
25
25
|
}>;
|
|
26
26
|
export declare const Message: S.Union<readonly [import("foldkit/schema").CallableTaggedStruct<"ClickedToggle", {}>, import("foldkit/schema").CallableTaggedStruct<"ClickedSubmit", {}>, import("foldkit/schema").CallableTaggedStruct<"GotDialogMessage", {
|
|
27
|
-
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"RequestedOpen", {}>, import("foldkit/schema").CallableTaggedStruct<"RequestedClose", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedShowDialog", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedCloseDialog", {}>, import("foldkit/schema").CallableTaggedStruct<"GotAnimationMessage", {
|
|
27
|
+
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"RequestedOpen", {}>, import("foldkit/schema").CallableTaggedStruct<"RequestedClose", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedShowDialog", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedCloseDialog", {}>, import("foldkit/schema").CallableTaggedStruct<"Unmounted", {}>, import("foldkit/schema").CallableTaggedStruct<"CompletedReleaseDialogResources", {}>, import("foldkit/schema").CallableTaggedStruct<"GotAnimationMessage", {
|
|
28
28
|
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"Showed", {}>, import("foldkit/schema").CallableTaggedStruct<"Hid", {}>, import("foldkit/schema").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("foldkit/schema").CallableTaggedStruct<"EndedAnimation", {}>]>;
|
|
29
29
|
}>]>;
|
|
30
30
|
}>]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foldkit/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.119.0",
|
|
4
4
|
"description": "Headless, accessible UI components for Foldkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -124,9 +124,10 @@
|
|
|
124
124
|
"effect": "4.0.0-beta.88",
|
|
125
125
|
"happy-dom": "^20.10.4",
|
|
126
126
|
"rimraf": "^6.1.3",
|
|
127
|
+
"typedoc": "^0.28.19",
|
|
127
128
|
"typescript": "^6.0.3",
|
|
128
129
|
"vitest": "^4.1.9",
|
|
129
|
-
"foldkit": "0.
|
|
130
|
+
"foldkit": "0.119.0"
|
|
130
131
|
},
|
|
131
132
|
"keywords": [
|
|
132
133
|
"foldkit",
|
|
@@ -151,6 +152,7 @@
|
|
|
151
152
|
"scripts": {
|
|
152
153
|
"clean": "rimraf dist *.tsbuildinfo",
|
|
153
154
|
"build": "pnpm run clean && tsc -b tsconfig.build.json",
|
|
155
|
+
"docs": "typedoc",
|
|
154
156
|
"watch": "tsc -b tsconfig.build.json --watch",
|
|
155
157
|
"lint": "pnpm --filter @foldkit/oxlint-plugin build && oxlint src",
|
|
156
158
|
"typecheck": "tsc -b tsconfig.build.json --noEmit",
|