entasis 0.7.1 → 0.8.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/components/FloatingWindow/FloatingWindow.svelte +26 -2
- package/dist/components/FloatingWindow/floatingWindow.dock.svelte.js +11 -2
- package/dist/components/FloatingWindow/floatingWindow.mcp.d.ts +1 -1
- package/dist/components/FloatingWindow/floatingWindow.mcp.js +7 -4
- package/dist/components/FloatingWindow/floatingWindow.props.d.ts +6 -0
- package/dist/components/FloatingWindow/floatingWindow.state.svelte.d.ts +3 -0
- package/dist/components/FloatingWindow/floatingWindow.state.svelte.js +18 -4
- package/dist/components/FloatingWindow/floatingWindow.theme.d.ts +3 -0
- package/dist/components/FloatingWindow/floatingWindow.theme.js +20 -7
- package/dist/components/Form/File/FileInput.svelte +6 -42
- package/dist/components/Sidebar/Sidebar.svelte +52 -9
- package/dist/components/Sidebar/Sidebar.svelte.d.ts +1 -1
- package/dist/components/Sidebar/SidebarMenuItem.svelte +19 -2
- package/dist/components/Sidebar/SidebarMenuItem.svelte.d.ts +4 -0
- package/dist/components/Sidebar/SidebarPanel.svelte +199 -88
- package/dist/components/Sidebar/SidebarPanel.svelte.d.ts +3 -0
- package/dist/components/Sidebar/SidebarViewStage.svelte +103 -0
- package/dist/components/Sidebar/SidebarViewStage.svelte.d.ts +18 -0
- package/dist/components/Sidebar/index.d.ts +1 -1
- package/dist/components/Sidebar/sidebar.mcp.d.ts +1 -1
- package/dist/components/Sidebar/sidebar.mcp.js +18 -1
- package/dist/components/Sidebar/sidebar.props.d.ts +56 -1
- package/dist/components/Sidebar/sidebar.state.svelte.d.ts +4 -0
- package/dist/components/Sidebar/sidebar.state.svelte.js +9 -1
- package/dist/components/Sidebar/sidebar.theme.d.ts +116 -5
- package/dist/components/Sidebar/sidebar.theme.js +42 -0
- package/dist/components/Sidebar/sidebar.views.svelte.d.ts +138 -0
- package/dist/components/Sidebar/sidebar.views.svelte.js +303 -0
- package/dist/components/Theme/theme.floatingWindows.d.ts +6 -1
- package/dist/components/Theme/theme.floatingWindows.js +7 -2
- package/dist/components/Theme/theme.mcp.d.ts +1 -1
- package/dist/components/Theme/theme.mcp.js +1 -0
- package/dist/generated/componentContract.d.ts +1 -1
- package/dist/generated/componentContract.js +1 -0
- package/dist/generated/componentMcpRegistry.d.ts +4 -4
- package/dist/tailwind/index.mcp.d.ts +1 -1
- package/dist/tailwind/index.mcp.js +4 -0
- package/dist/tailwind/scales.js +11 -3
- package/dist/tailwind/spacing.js +17 -0
- package/dist/utils/cva/merge.d.ts +7 -0
- package/dist/utils/cva/merge.js +6 -1
- package/dist/utils/pointerDrag.js +7 -1
- package/package.json +1 -1
|
@@ -80,6 +80,10 @@ export type SidebarApi = {
|
|
|
80
80
|
setDisplayState: (state: SidebarDisplayState) => void;
|
|
81
81
|
/** Set the mobile drawer open state. */
|
|
82
82
|
setOpenMobile: (open: boolean) => void;
|
|
83
|
+
/** The view on screen when `views` is set, undefined otherwise. */
|
|
84
|
+
readonly view: string | undefined;
|
|
85
|
+
/** Show another view. Its depth against the current one picks the slide direction. */
|
|
86
|
+
setView: (view: string) => void;
|
|
83
87
|
};
|
|
84
88
|
export type SidebarActivityBarItem = {
|
|
85
89
|
/** Stable identity used as the render key. Defaults to the label and index. */
|
|
@@ -206,10 +210,15 @@ type SidebarMenuEntryBase = {
|
|
|
206
210
|
action?: Snippet<[SidebarApi]> | SidebarMenuActionDescriptor;
|
|
207
211
|
};
|
|
208
212
|
type SidebarMenuEntryNavigation = SidebarMenuEntryBase & {
|
|
209
|
-
/** Link href. Mutually exclusive with menu. */
|
|
213
|
+
/** Link href. Mutually exclusive with menu and view. */
|
|
210
214
|
href?: string;
|
|
211
215
|
/** Native click handler. Mutually exclusive with menu. */
|
|
212
216
|
onclick?: (event: MouseEvent) => void;
|
|
217
|
+
/**
|
|
218
|
+
* Key of the `views` entry this row opens, sliding it in. Mutually exclusive with href, menu,
|
|
219
|
+
* and items.
|
|
220
|
+
*/
|
|
221
|
+
view?: string;
|
|
213
222
|
/** Popup menu rows own the whole trigger, so they cannot also navigate. */
|
|
214
223
|
menu?: never;
|
|
215
224
|
};
|
|
@@ -218,6 +227,7 @@ type SidebarMenuEntryMenu = SidebarMenuEntryBase & {
|
|
|
218
227
|
menu: MenuItem[];
|
|
219
228
|
href?: never;
|
|
220
229
|
onclick?: never;
|
|
230
|
+
view?: never;
|
|
221
231
|
};
|
|
222
232
|
export type SidebarMenuEntry = SidebarMenuEntryNavigation | SidebarMenuEntryMenu;
|
|
223
233
|
export type SidebarSearch = {
|
|
@@ -250,6 +260,38 @@ export type SidebarTreeNode = {
|
|
|
250
260
|
/** Child nodes. */
|
|
251
261
|
children?: SidebarTreeNode[];
|
|
252
262
|
};
|
|
263
|
+
/**
|
|
264
|
+
* One panel content in `views`. Header and footer props left undefined come from the parent view,
|
|
265
|
+
* then from the Sidebar's props; `null` removes an inherited one.
|
|
266
|
+
*/
|
|
267
|
+
export type SidebarView = {
|
|
268
|
+
/** The view's name, shown on the back row of the views nested under it. */
|
|
269
|
+
label?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Key of the view this one is nested under. A nested view opens with a back row to it, and
|
|
272
|
+
* on mobile a swipe toward the inline end goes back. A view without a parent is a top-level
|
|
273
|
+
* section.
|
|
274
|
+
*/
|
|
275
|
+
parent?: string;
|
|
276
|
+
/** Groups rendered in the scrollable body. */
|
|
277
|
+
items?: SidebarGroup[];
|
|
278
|
+
/** Custom scrollable body. Overrides items. */
|
|
279
|
+
content?: Snippet<[SidebarApi]>;
|
|
280
|
+
/** Sticky top large menu row. */
|
|
281
|
+
headerButton?: SidebarMenuButtonItem | null;
|
|
282
|
+
/** Search box rendered in the header. */
|
|
283
|
+
search?: SidebarSearch | null;
|
|
284
|
+
/** Pinned menu rendered in the header. */
|
|
285
|
+
headerMenu?: SidebarMenuEntry[] | null;
|
|
286
|
+
/** Sticky top custom content. */
|
|
287
|
+
header?: Snippet<[SidebarApi]> | null;
|
|
288
|
+
/** Sticky bottom large menu row. */
|
|
289
|
+
footerButton?: SidebarMenuButtonItem | null;
|
|
290
|
+
/** Pinned menu rendered in the footer. */
|
|
291
|
+
footerMenu?: SidebarMenuEntry[] | null;
|
|
292
|
+
/** Sticky bottom custom content. */
|
|
293
|
+
footer?: Snippet<[SidebarApi]> | null;
|
|
294
|
+
};
|
|
253
295
|
export type SidebarGroup = {
|
|
254
296
|
/** Group label. Hidden in icon-collapsed mode. */
|
|
255
297
|
label?: string;
|
|
@@ -378,6 +420,19 @@ type SidebarOwnProps = {
|
|
|
378
420
|
activityBar?: SidebarActivityBar;
|
|
379
421
|
/** Items rendered in the scrollable body. Each item is a labelled sidebar group. */
|
|
380
422
|
items?: SidebarGroup[];
|
|
423
|
+
/**
|
|
424
|
+
* Named panel contents, one on screen at a time, replacing `items` and `content`. Changing
|
|
425
|
+
* the view slides between them: deeper views push in, shallower ones slide back, sections at
|
|
426
|
+
* the same depth crossfade. Header and footer props a view leaves out come from its parent,
|
|
427
|
+
* then from the Sidebar's own props.
|
|
428
|
+
*/
|
|
429
|
+
views?: Record<string, SidebarView>;
|
|
430
|
+
/** Bindable key of the view on screen. Defaults to `defaultView`, then the first view. */
|
|
431
|
+
view?: string;
|
|
432
|
+
/** Initial view when `view` is omitted. */
|
|
433
|
+
defaultView?: string;
|
|
434
|
+
/** Fires once for each library-originated view change: a view row, a back row, a swipe. */
|
|
435
|
+
onViewChange?: (view: string) => void;
|
|
381
436
|
/** Classes applied to the outer wrapper. */
|
|
382
437
|
class?: string;
|
|
383
438
|
/** Indicator style for collapsible menu items. */
|
|
@@ -6,7 +6,9 @@ type SidebarStateOptions = {
|
|
|
6
6
|
readonly side: SidebarSide;
|
|
7
7
|
readonly collapsible: SidebarCollapsible;
|
|
8
8
|
readonly peeking: boolean;
|
|
9
|
+
readonly view: string | undefined;
|
|
9
10
|
setDisplayState: (state: SidebarDisplayState) => void;
|
|
11
|
+
setView: (view: string) => void;
|
|
10
12
|
};
|
|
11
13
|
export declare class SidebarStateController {
|
|
12
14
|
private options;
|
|
@@ -19,6 +21,8 @@ export declare class SidebarStateController {
|
|
|
19
21
|
get displayState(): SidebarDisplayState;
|
|
20
22
|
get collapsibleState(): SidebarCollapsible | '';
|
|
21
23
|
get isMobile(): boolean;
|
|
24
|
+
get view(): string | undefined;
|
|
25
|
+
setView: (view: string) => void;
|
|
22
26
|
get side(): SidebarSide;
|
|
23
27
|
get collapsible(): SidebarCollapsible;
|
|
24
28
|
/**
|
|
@@ -39,7 +39,11 @@ function createSidebarApi(controller) {
|
|
|
39
39
|
toggle: () => controller.toggle(),
|
|
40
40
|
setOpen: (open) => controller.setOpen(open),
|
|
41
41
|
setDisplayState: (state) => controller.setDisplayState(state),
|
|
42
|
-
setOpenMobile: (open) => controller.setOpenMobile(open)
|
|
42
|
+
setOpenMobile: (open) => controller.setOpenMobile(open),
|
|
43
|
+
get view() {
|
|
44
|
+
return controller.view;
|
|
45
|
+
},
|
|
46
|
+
setView: (view) => controller.setView(view)
|
|
43
47
|
};
|
|
44
48
|
}
|
|
45
49
|
export class SidebarStateController {
|
|
@@ -89,6 +93,10 @@ export class SidebarStateController {
|
|
|
89
93
|
get isMobile() {
|
|
90
94
|
return this.mobileQuery.current;
|
|
91
95
|
}
|
|
96
|
+
get view() {
|
|
97
|
+
return this.options.view;
|
|
98
|
+
}
|
|
99
|
+
setView = (view) => this.options.setView(view);
|
|
92
100
|
get side() {
|
|
93
101
|
return this.options.side;
|
|
94
102
|
}
|
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
import { type InferComponentTheme } from '../../utils/cva/index.js';
|
|
2
|
-
export declare const defaultSidebarMotion: import("../../utils/motion/index.js").MotionResolver<
|
|
2
|
+
export declare const defaultSidebarMotion: import("../../utils/motion/index.js").MotionResolver<{
|
|
3
|
+
readonly part: {
|
|
4
|
+
readonly collapse: {};
|
|
5
|
+
readonly view: {
|
|
6
|
+
readonly in: {
|
|
7
|
+
readonly axis: "x";
|
|
8
|
+
readonly x: "100%";
|
|
9
|
+
readonly opacity: 0;
|
|
10
|
+
};
|
|
11
|
+
readonly out: {
|
|
12
|
+
readonly axis: "x";
|
|
13
|
+
readonly x: "100%";
|
|
14
|
+
readonly opacity: 0;
|
|
15
|
+
};
|
|
16
|
+
readonly duration: "slow";
|
|
17
|
+
readonly easing: "enter";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
3
21
|
export declare const sidebarTheme: {
|
|
4
|
-
motion: import("../../utils/motion/index.js").MotionResolver<
|
|
22
|
+
motion: import("../../utils/motion/index.js").MotionResolver<{
|
|
23
|
+
readonly part: {
|
|
24
|
+
readonly collapse: {};
|
|
25
|
+
readonly view: {
|
|
26
|
+
readonly in: {
|
|
27
|
+
readonly axis: "x";
|
|
28
|
+
readonly x: "100%";
|
|
29
|
+
readonly opacity: 0;
|
|
30
|
+
};
|
|
31
|
+
readonly out: {
|
|
32
|
+
readonly axis: "x";
|
|
33
|
+
readonly x: "100%";
|
|
34
|
+
readonly opacity: 0;
|
|
35
|
+
};
|
|
36
|
+
readonly duration: "slow";
|
|
37
|
+
readonly easing: "enter";
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
5
41
|
root: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
6
42
|
variant: {
|
|
7
43
|
admin: string;
|
|
@@ -54,6 +90,13 @@ export declare const sidebarTheme: {
|
|
|
54
90
|
comfortable: string;
|
|
55
91
|
};
|
|
56
92
|
}> & import("../../utils/cva/types.js").CVAClassProp) | undefined) => string;
|
|
93
|
+
viewStage: (props?: import("../../utils/cva/types.js").CVAClassProp | undefined) => string;
|
|
94
|
+
viewLayer: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
95
|
+
swipe: {
|
|
96
|
+
true: string;
|
|
97
|
+
false: null;
|
|
98
|
+
};
|
|
99
|
+
}> & import("../../utils/cva/types.js").CVAClassProp) | undefined) => string;
|
|
57
100
|
footer: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
58
101
|
density: {
|
|
59
102
|
compact: string;
|
|
@@ -483,7 +526,25 @@ export declare const sidebarTheme: {
|
|
|
483
526
|
export type SidebarTheme = typeof sidebarTheme;
|
|
484
527
|
export type SidebarThemeProps = InferComponentTheme<SidebarTheme>;
|
|
485
528
|
export declare const setSidebarTheme: (theme: InferComponentTheme<{
|
|
486
|
-
motion: import("../../utils/motion/index.js").MotionResolver<
|
|
529
|
+
motion: import("../../utils/motion/index.js").MotionResolver<{
|
|
530
|
+
readonly part: {
|
|
531
|
+
readonly collapse: {};
|
|
532
|
+
readonly view: {
|
|
533
|
+
readonly in: {
|
|
534
|
+
readonly axis: "x";
|
|
535
|
+
readonly x: "100%";
|
|
536
|
+
readonly opacity: 0;
|
|
537
|
+
};
|
|
538
|
+
readonly out: {
|
|
539
|
+
readonly axis: "x";
|
|
540
|
+
readonly x: "100%";
|
|
541
|
+
readonly opacity: 0;
|
|
542
|
+
};
|
|
543
|
+
readonly duration: "slow";
|
|
544
|
+
readonly easing: "enter";
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
}>;
|
|
487
548
|
root: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
488
549
|
variant: {
|
|
489
550
|
admin: string;
|
|
@@ -536,6 +597,13 @@ export declare const setSidebarTheme: (theme: InferComponentTheme<{
|
|
|
536
597
|
comfortable: string;
|
|
537
598
|
};
|
|
538
599
|
}> & import("../../utils/cva/types.js").CVAClassProp) | undefined) => string;
|
|
600
|
+
viewStage: (props?: import("../../utils/cva/types.js").CVAClassProp | undefined) => string;
|
|
601
|
+
viewLayer: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
602
|
+
swipe: {
|
|
603
|
+
true: string;
|
|
604
|
+
false: null;
|
|
605
|
+
};
|
|
606
|
+
}> & import("../../utils/cva/types.js").CVAClassProp) | undefined) => string;
|
|
539
607
|
footer: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
540
608
|
density: {
|
|
541
609
|
compact: string;
|
|
@@ -963,7 +1031,25 @@ export declare const setSidebarTheme: (theme: InferComponentTheme<{
|
|
|
963
1031
|
}> & import("../../utils/cva/types.js").CVAClassProp) | undefined) => string;
|
|
964
1032
|
}>) => void;
|
|
965
1033
|
export declare const useSidebarTheme: import("../../utils/cva/theme.js").UseComponentTheme<{
|
|
966
|
-
motion: import("../../utils/motion/index.js").MotionResolver<
|
|
1034
|
+
motion: import("../../utils/motion/index.js").MotionResolver<{
|
|
1035
|
+
readonly part: {
|
|
1036
|
+
readonly collapse: {};
|
|
1037
|
+
readonly view: {
|
|
1038
|
+
readonly in: {
|
|
1039
|
+
readonly axis: "x";
|
|
1040
|
+
readonly x: "100%";
|
|
1041
|
+
readonly opacity: 0;
|
|
1042
|
+
};
|
|
1043
|
+
readonly out: {
|
|
1044
|
+
readonly axis: "x";
|
|
1045
|
+
readonly x: "100%";
|
|
1046
|
+
readonly opacity: 0;
|
|
1047
|
+
};
|
|
1048
|
+
readonly duration: "slow";
|
|
1049
|
+
readonly easing: "enter";
|
|
1050
|
+
};
|
|
1051
|
+
};
|
|
1052
|
+
}>;
|
|
967
1053
|
root: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
968
1054
|
variant: {
|
|
969
1055
|
admin: string;
|
|
@@ -1016,6 +1102,13 @@ export declare const useSidebarTheme: import("../../utils/cva/theme.js").UseComp
|
|
|
1016
1102
|
comfortable: string;
|
|
1017
1103
|
};
|
|
1018
1104
|
}> & import("../../utils/cva/types.js").CVAClassProp) | undefined) => string;
|
|
1105
|
+
viewStage: (props?: import("../../utils/cva/types.js").CVAClassProp | undefined) => string;
|
|
1106
|
+
viewLayer: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
1107
|
+
swipe: {
|
|
1108
|
+
true: string;
|
|
1109
|
+
false: null;
|
|
1110
|
+
};
|
|
1111
|
+
}> & import("../../utils/cva/types.js").CVAClassProp) | undefined) => string;
|
|
1019
1112
|
footer: (props?: (import("../../utils/cva/types.js").CVAVariantSchema<{
|
|
1020
1113
|
density: {
|
|
1021
1114
|
compact: string;
|
|
@@ -1442,4 +1535,22 @@ export declare const useSidebarTheme: import("../../utils/cva/theme.js").UseComp
|
|
|
1442
1535
|
};
|
|
1443
1536
|
}> & import("../../utils/cva/types.js").CVAClassProp) | undefined) => string;
|
|
1444
1537
|
}>;
|
|
1445
|
-
export declare const useSidebarMotion: () => import("../../utils/motion/index.js").ComponentMotion<
|
|
1538
|
+
export declare const useSidebarMotion: () => import("../../utils/motion/index.js").ComponentMotion<{
|
|
1539
|
+
readonly part: {
|
|
1540
|
+
readonly collapse: {};
|
|
1541
|
+
readonly view: {
|
|
1542
|
+
readonly in: {
|
|
1543
|
+
readonly axis: "x";
|
|
1544
|
+
readonly x: "100%";
|
|
1545
|
+
readonly opacity: 0;
|
|
1546
|
+
};
|
|
1547
|
+
readonly out: {
|
|
1548
|
+
readonly axis: "x";
|
|
1549
|
+
readonly x: "100%";
|
|
1550
|
+
readonly opacity: 0;
|
|
1551
|
+
};
|
|
1552
|
+
readonly duration: "slow";
|
|
1553
|
+
readonly easing: "enter";
|
|
1554
|
+
};
|
|
1555
|
+
};
|
|
1556
|
+
}>;
|
|
@@ -111,6 +111,28 @@ const defaultNav = cva({
|
|
|
111
111
|
density: 'normal'
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
|
+
// With `views`, the panel and the menu inside it are one-cell grids whose layers are the views
|
|
115
|
+
// they show: one at rest, two while they slide past each other. The cell clips the slide.
|
|
116
|
+
const defaultViewStage = cva({
|
|
117
|
+
base: 'grid min-h-0 flex-1 grid-cols-1 grid-rows-1 overflow-x-clip'
|
|
118
|
+
});
|
|
119
|
+
// `translate` / `opacity` carry the swipe: they follow the finger with no transition while
|
|
120
|
+
// dragging, then ease to rest. The view-change motion animates `transform`, so the two never fight.
|
|
121
|
+
const defaultViewLayer = cva({
|
|
122
|
+
base: 'col-start-1 row-start-1 min-w-0 transition-[translate,opacity] ease-enter data-[dragging=true]:transition-none',
|
|
123
|
+
variants: {
|
|
124
|
+
// A body layer is its own scroll container, and `touch-action` only counts up to the nearest
|
|
125
|
+
// one: set on the layer, it leaves vertical scrolling to the browser and horizontal moves to
|
|
126
|
+
// the back swipe.
|
|
127
|
+
swipe: {
|
|
128
|
+
true: 'touch-pan-y',
|
|
129
|
+
false: null
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
defaultVariants: {
|
|
133
|
+
swipe: false
|
|
134
|
+
}
|
|
135
|
+
});
|
|
114
136
|
const defaultGroup = cva({
|
|
115
137
|
base: 'relative flex w-full min-w-0 flex-col',
|
|
116
138
|
variants: {
|
|
@@ -891,6 +913,24 @@ export const defaultSidebarMotion = motion({
|
|
|
891
913
|
out: { axis: 'y', x: 0, y: 0, scale: 1, opacity: 0.2 },
|
|
892
914
|
duration: 'normal',
|
|
893
915
|
easing: 'standard'
|
|
916
|
+
},
|
|
917
|
+
variants: {
|
|
918
|
+
part: {
|
|
919
|
+
collapse: {},
|
|
920
|
+
// The pager between views: the arriving view comes from the inline end and the leaving
|
|
921
|
+
// one goes to the start, side by side, each travelling `x` while it fades between
|
|
922
|
+
// `opacity` and 1. `enter` easing moves on the first frame; an in-out curve would sit
|
|
923
|
+
// still for the first and last fifth and squeeze the whole swap into a blink.
|
|
924
|
+
view: {
|
|
925
|
+
in: { axis: 'x', x: '100%', opacity: 0 },
|
|
926
|
+
out: { axis: 'x', x: '100%', opacity: 0 },
|
|
927
|
+
duration: 'slow',
|
|
928
|
+
easing: 'enter'
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
defaultVariants: {
|
|
933
|
+
part: 'collapse'
|
|
894
934
|
}
|
|
895
935
|
});
|
|
896
936
|
export const sidebarTheme = {
|
|
@@ -899,6 +939,8 @@ export const sidebarTheme = {
|
|
|
899
939
|
panel: defaultPanel,
|
|
900
940
|
header: defaultStackSection,
|
|
901
941
|
nav: defaultNav,
|
|
942
|
+
viewStage: defaultViewStage,
|
|
943
|
+
viewLayer: defaultViewLayer,
|
|
902
944
|
footer: defaultStackSection,
|
|
903
945
|
group: defaultGroup,
|
|
904
946
|
groupLabel: defaultGroupLabel,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { TransitionConfig } from 'svelte/transition';
|
|
3
|
+
import type { ResolvedMotion } from '../../utils/motion/index.js';
|
|
4
|
+
import type { SidebarApi, SidebarGroup, SidebarMenuButtonItem, SidebarMenuEntry, SidebarSearch, SidebarSide, SidebarView } from './sidebar.props.js';
|
|
5
|
+
/** What the panel renders for a view: the Sidebar's own props, or a view's resolved over its parents. */
|
|
6
|
+
export type SidebarSlotValues = {
|
|
7
|
+
items?: SidebarGroup[];
|
|
8
|
+
content?: Snippet<[SidebarApi]>;
|
|
9
|
+
headerButton?: SidebarMenuButtonItem;
|
|
10
|
+
search?: SidebarSearch;
|
|
11
|
+
headerMenu?: SidebarMenuEntry[];
|
|
12
|
+
header?: Snippet<[SidebarApi]>;
|
|
13
|
+
footerButton?: SidebarMenuButtonItem;
|
|
14
|
+
footerMenu?: SidebarMenuEntry[];
|
|
15
|
+
footer?: Snippet<[SidebarApi]>;
|
|
16
|
+
};
|
|
17
|
+
/** The header and footer props a view can set; together they are the panel's chrome. */
|
|
18
|
+
declare const chromeProps: readonly ["header", "headerButton", "search", "headerMenu", "footerButton", "footerMenu", "footer"];
|
|
19
|
+
/**
|
|
20
|
+
* What slides on a view change. `body` is the menu alone; `panel` is the whole panel (header,
|
|
21
|
+
* menu, footer), which only swaps when the two views do not share the same chrome.
|
|
22
|
+
*/
|
|
23
|
+
export type SidebarViewKind = 'panel' | 'body';
|
|
24
|
+
type Views = Record<string, SidebarView>;
|
|
25
|
+
type PropSlot = (typeof chromeProps)[number];
|
|
26
|
+
/** The view and its ancestors, nearest first. A missing parent or a parent cycle ends the chain. */
|
|
27
|
+
export declare const viewChain: (views: Views, id: string) => string[];
|
|
28
|
+
/**
|
|
29
|
+
* Resolves one header or footer prop for a view: the nearest view in the chain that sets it
|
|
30
|
+
* (`null` counts, and clears it), else the Sidebar. `owner` names where it came from, so two
|
|
31
|
+
* views share the slot exactly when it resolves to the same owner.
|
|
32
|
+
*/
|
|
33
|
+
export declare const resolveSlot: <S extends PropSlot>(views: Views, id: string, slot: S, root: SidebarSlotValues) => {
|
|
34
|
+
owner: string | null;
|
|
35
|
+
value: SidebarSlotValues[S];
|
|
36
|
+
};
|
|
37
|
+
export type SidebarViewDirection = 'forward' | 'back' | 'none';
|
|
38
|
+
/** Which half of a back swipe a layer plays: the view leaving (`over`) or its parent (`under`). */
|
|
39
|
+
export type SidebarSwipeRole = 'over' | 'under';
|
|
40
|
+
export type SidebarViewLayer = {
|
|
41
|
+
key: string;
|
|
42
|
+
view: string;
|
|
43
|
+
role?: SidebarSwipeRole;
|
|
44
|
+
};
|
|
45
|
+
type Swipe = {
|
|
46
|
+
from: string;
|
|
47
|
+
to: string;
|
|
48
|
+
/** `drag` follows the finger; `commit` / `cancel` animate to rest, then the swipe ends. */
|
|
49
|
+
phase: 'drag' | 'commit' | 'cancel';
|
|
50
|
+
/** Distance travelled toward the inline end, in px. */
|
|
51
|
+
offset: number;
|
|
52
|
+
width: number;
|
|
53
|
+
/** The commit has finished moving and waits for the view change to land (a route, say). */
|
|
54
|
+
settled?: boolean;
|
|
55
|
+
};
|
|
56
|
+
type SidebarViewsOptions = {
|
|
57
|
+
readonly views: Views | undefined;
|
|
58
|
+
readonly view: string | undefined;
|
|
59
|
+
readonly defaultView: string | undefined;
|
|
60
|
+
readonly onViewChange: ((view: string) => void) | undefined;
|
|
61
|
+
readonly isMobile: boolean;
|
|
62
|
+
readonly side: SidebarSide;
|
|
63
|
+
readonly root: SidebarSlotValues;
|
|
64
|
+
setViewProp: (view: string | undefined) => void;
|
|
65
|
+
};
|
|
66
|
+
export declare class SidebarViewsState {
|
|
67
|
+
#private;
|
|
68
|
+
private options;
|
|
69
|
+
swipe: Swipe | null;
|
|
70
|
+
rtl: boolean;
|
|
71
|
+
constructor(options: SidebarViewsOptions);
|
|
72
|
+
get enabled(): boolean;
|
|
73
|
+
/** The view on screen: the selected one when it exists, else `defaultView`, else the first. */
|
|
74
|
+
get current(): string | undefined;
|
|
75
|
+
depth(id: string): number;
|
|
76
|
+
parentOf(id: string): string | undefined;
|
|
77
|
+
labelOf(id: string): string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* The last change of the current view and its direction, read by the layer transitions when
|
|
80
|
+
* they start. Deeper slides forward and shallower slides back; at one depth (sections), the
|
|
81
|
+
* later view in `views` is forward, like pages in order.
|
|
82
|
+
*/
|
|
83
|
+
get lastChange(): {
|
|
84
|
+
from?: string;
|
|
85
|
+
to?: string;
|
|
86
|
+
direction: SidebarViewDirection;
|
|
87
|
+
};
|
|
88
|
+
setView: (view: string) => void;
|
|
89
|
+
/** A view's body. */
|
|
90
|
+
body(view: string): {
|
|
91
|
+
items: SidebarGroup[] | undefined;
|
|
92
|
+
content: Snippet<[SidebarApi]> | undefined;
|
|
93
|
+
};
|
|
94
|
+
/** A view's header and footer props, each from the nearest view that sets it, else the Sidebar. */
|
|
95
|
+
chrome(view: string): SidebarSlotValues;
|
|
96
|
+
/**
|
|
97
|
+
* The layers a stage renders, bottom first. Outside a swipe that is the current view alone;
|
|
98
|
+
* during one it is the parent under the view being swiped away. Two views that share a layer
|
|
99
|
+
* key collapse to one layer that never moves: the panel's key is where its chrome comes from,
|
|
100
|
+
* so views with the same header and footer keep one panel and only their bodies slide.
|
|
101
|
+
*/
|
|
102
|
+
layers(kind: SidebarViewKind): SidebarViewLayer[];
|
|
103
|
+
/**
|
|
104
|
+
* A swipe layer's drag position, as `translate` / `opacity` styles; empty at rest. The view
|
|
105
|
+
* under the finger stays opaque and follows it; its parent comes from `travel` toward the
|
|
106
|
+
* start and from `opacity`, the same way the view motion brings a view in.
|
|
107
|
+
*/
|
|
108
|
+
swipeStyle(role: SidebarSwipeRole | undefined, travel: number | string, opacity: number): {
|
|
109
|
+
translate?: undefined;
|
|
110
|
+
opacity?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
translate: string;
|
|
113
|
+
opacity: number;
|
|
114
|
+
};
|
|
115
|
+
get canSwipeBack(): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* The mobile drawer dismisses on a swipe toward its own edge. When going back points the same
|
|
118
|
+
* way (a right drawer in LTR, a left one in RTL), the view body keeps the gesture.
|
|
119
|
+
*/
|
|
120
|
+
get ownsDrawerSwipe(): boolean;
|
|
121
|
+
/** Called by the body stage once a settling swipe has had its motion duration. */
|
|
122
|
+
settleSwipe(): void;
|
|
123
|
+
/** Back swipe on the view body: toward the inline end, anywhere on the body, mobile only. */
|
|
124
|
+
swipeAttachment: (node: HTMLElement) => void | (() => void);
|
|
125
|
+
}
|
|
126
|
+
type ViewTransitionParams = {
|
|
127
|
+
phase: 'in' | 'out';
|
|
128
|
+
direction: SidebarViewDirection;
|
|
129
|
+
motion: ResolvedMotion;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Pager motion between views. Forward, the new view comes from the inline end and the old one
|
|
133
|
+
* leaves to the start, side by side, each travelling the motion's `x` and fading along the whole
|
|
134
|
+
* way; back mirrors it. A layer a swipe put in place is already where it belongs, so it enters
|
|
135
|
+
* and leaves without motion.
|
|
136
|
+
*/
|
|
137
|
+
export declare const sidebarViewTransition: (node: HTMLElement, { phase, direction, motion }: ViewTransitionParams) => TransitionConfig;
|
|
138
|
+
export {};
|