@foris/avocado-suite 1.13.0 → 1.14.1
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/avocado-suite.es.js +21065 -20226
- package/dist/avocado-suite.umd.js +165 -157
- package/dist/components/access-panel/AccessPanel.d.ts +5 -0
- package/dist/components/access-panel/AccessPanel.test.d.ts +0 -0
- package/dist/components/access-panel/accessPanel.locale.d.ts +16 -0
- package/dist/components/access-panel/components/access-product/AccessProduct.d.ts +1 -0
- package/dist/components/account-menu/components/menu-locale-dropdown/MenuLocaleDropdown.test.d.ts +0 -0
- package/dist/components/drawer/Drawer.d.ts +78 -41
- package/dist/components/drawer/Drawer.test.d.ts +1 -0
- package/dist/components/drawer/DrawerExpansion.test.d.ts +1 -0
- package/dist/components/drawer/DrawerGuards.test.d.ts +1 -0
- package/dist/components/drawer/DrawerKeyboard.test.d.ts +1 -0
- package/dist/components/drawer/DrawerMotion.test.d.ts +1 -0
- package/dist/components/drawer/DrawerNavigation.test.d.ts +1 -0
- package/dist/components/drawer/DrawerStacking.test.d.ts +1 -0
- package/dist/components/drawer/components/body/DrawerBody.d.ts +9 -0
- package/dist/components/drawer/components/footer/DrawerFooter.d.ts +11 -0
- package/dist/components/drawer/components/header/DrawerCloseControl.d.ts +15 -0
- package/dist/components/drawer/components/header/DrawerHeader.d.ts +13 -0
- package/dist/components/drawer/components/header/DrawerIconButton.d.ts +11 -0
- package/dist/components/drawer/components/header/DrawerLegacyHeader.d.ts +19 -0
- package/dist/components/drawer/components/navigation/DrawerNavigationView.d.ts +19 -0
- package/dist/components/drawer/components/navigation/DrawerNavigationVisit.d.ts +17 -0
- package/dist/components/drawer/components/navigation/DrawerView.d.ts +19 -0
- package/dist/components/drawer/contexts/drawerNavigationContext.d.ts +19 -0
- package/dist/components/drawer/drawer.locale.d.ts +10 -0
- package/dist/components/drawer/hooks/useDrawerExpansion.d.ts +11 -0
- package/dist/components/drawer/hooks/useDrawerLifecycle.d.ts +17 -0
- package/dist/components/drawer/hooks/useDrawerNavigation.d.ts +3 -0
- package/dist/components/drawer/hooks/useDrawerNavigation.test.d.ts +1 -0
- package/dist/components/drawer/hooks/useDrawerNavigationContext.d.ts +3 -0
- package/dist/components/drawer/hooks/useDrawerStack.d.ts +4 -0
- package/dist/components/drawer/hooks/useDrawerStack.test.d.ts +1 -0
- package/dist/components/drawer/index.d.ts +9 -0
- package/dist/components/drawer/types/drawerExpansion.types.d.ts +9 -0
- package/dist/components/drawer/types/drawerHeader.types.d.ts +56 -0
- package/dist/components/drawer/types/drawerNavigation.types.d.ts +68 -0
- package/dist/components/drawer/utils/createDrawerNavigation.d.ts +9 -0
- package/dist/components/drawer/utils/createDrawerNavigation.test.d.ts +1 -0
- package/dist/components/drawer/utils/drawerKeyboard.d.ts +3 -0
- package/dist/components/drawer/utils/drawerNavigationInternals.d.ts +21 -0
- package/dist/components/drawer/utils/drawerNavigationState.d.ts +21 -0
- package/dist/components/drawer/utils/drawerRequestGate.d.ts +9 -0
- package/dist/components/drawer/utils/drawerStack.d.ts +9 -0
- package/dist/components/drawer/utils/drawerStack.test.d.ts +1 -0
- package/dist/components/drawer-layout/DrawerLayout.d.ts +17 -0
- package/dist/components/drawer-layout/DrawerLayout.test.d.ts +1 -0
- package/dist/components/drawer-layout/drawerLayoutContext.d.ts +20 -0
- package/dist/components/drawer-layout/index.d.ts +3 -0
- package/dist/drawer-types.d.ts +2 -0
- package/dist/index.d.ts +7 -3
- package/dist/style.css +1 -1
- package/package.json +5 -2
|
@@ -9,10 +9,15 @@ export type AccessPanelProduct = {
|
|
|
9
9
|
export interface AccessPanelProps {
|
|
10
10
|
className?: string;
|
|
11
11
|
isOpen?: boolean;
|
|
12
|
+
/** Header text. Falls back to a localized default. */
|
|
12
13
|
title?: string;
|
|
14
|
+
/** Products section title. Falls back to a localized default. */
|
|
13
15
|
productsTitle?: string;
|
|
16
|
+
/** Recent products section title. Falls back to a localized default. */
|
|
14
17
|
recentProductsTitle?: string;
|
|
18
|
+
/** Custom products section title. Falls back to a localized default. */
|
|
15
19
|
customProductsTitle?: string;
|
|
20
|
+
/** Pill text on the active product. Falls back to a localized default. */
|
|
16
21
|
activePillText?: string;
|
|
17
22
|
products?: AccessPanelProduct[];
|
|
18
23
|
recentProducts?: AccessPanelProduct[];
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const ACCESS_PANEL_STRINGS: {
|
|
2
|
+
en: {
|
|
3
|
+
title: string;
|
|
4
|
+
productsTitle: string;
|
|
5
|
+
recentProductsTitle: string;
|
|
6
|
+
customProductsTitle: string;
|
|
7
|
+
activePillText: string;
|
|
8
|
+
};
|
|
9
|
+
es: {
|
|
10
|
+
title: string;
|
|
11
|
+
productsTitle: string;
|
|
12
|
+
recentProductsTitle: string;
|
|
13
|
+
customProductsTitle: string;
|
|
14
|
+
activePillText: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AccessPanelProduct } from '../../AccessPanel';
|
|
2
2
|
interface AccessProductProps extends AccessPanelProduct {
|
|
3
|
+
/** Pill text when active. Falls back to a localized default. */
|
|
3
4
|
activePillText?: string;
|
|
4
5
|
}
|
|
5
6
|
declare const AccessProduct: ({ isActive, name, logo, activePillText, onClick, }: AccessProductProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/components/account-menu/components/menu-locale-dropdown/MenuLocaleDropdown.test.d.ts
ADDED
|
File without changes
|
|
@@ -1,64 +1,101 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/** Main panel content (scrollable body). */
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
/** Sticky footer below the body. */
|
|
12
|
-
footer?: React.ReactNode;
|
|
13
|
-
/** When `true`, the drawer is visible (open animation). Controlled from the parent. */
|
|
2
|
+
import { type DrawerMode } from '../drawer-layout/drawerLayoutContext';
|
|
3
|
+
import type { DrawerExpansionConfig } from './types/drawerExpansion.types';
|
|
4
|
+
import type { DrawerHeaderConfig } from './types/drawerHeader.types';
|
|
5
|
+
import type { DrawerCloseReason, DrawerNavigationBinding, DrawerNavigationTarget } from './types/drawerNavigation.types';
|
|
6
|
+
/** Content, presentation and lifecycle options for a contextual panel. */
|
|
7
|
+
export interface DrawerProps<Target extends DrawerNavigationTarget = DrawerNavigationTarget> {
|
|
8
|
+
/** Controlled visibility; opens or starts the closing animation. */
|
|
14
9
|
isOpen: boolean;
|
|
10
|
+
/** Notifies the caller after the closing transition, when the panel is removed. */
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Allows or denies user dismissal; false, a thrown error or a rejection keeps the panel open.
|
|
14
|
+
* Controlled isOpen changes bypass this guard.
|
|
15
|
+
*/
|
|
16
|
+
beforeClose?: (reason: DrawerCloseReason) => boolean | Promise<boolean>;
|
|
17
|
+
/** Notifies an allowed user dismissal before the exit completes; onClose remains after-exit. */
|
|
18
|
+
onRequestClose?: (reason: DrawerCloseReason) => void;
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @default false
|
|
20
|
+
* Allows a backdrop click to start closing the panel.
|
|
21
|
+
* @defaultValue false
|
|
19
22
|
*/
|
|
20
23
|
closeOnOverlayClick?: boolean;
|
|
24
|
+
/** Structured header configuration; takes precedence over the legacy header props. */
|
|
25
|
+
headerConfig?: DrawerHeaderConfig;
|
|
26
|
+
/** Main content for a static Drawer; navigation supplies its own body when enabled. */
|
|
27
|
+
children?: React.ReactNode;
|
|
28
|
+
/** Optional local navigation; each visit renders its own DrawerView and replaces the static slots. */
|
|
29
|
+
navigation?: DrawerNavigationBinding<Target>;
|
|
30
|
+
/** Main footer content below the scrollable body; composition belongs to the caller. */
|
|
31
|
+
footer?: React.ReactNode;
|
|
32
|
+
/** Optional content below the footer, with caller-owned formatting; also works on its own. */
|
|
33
|
+
footerMessage?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Applies the standard body padding; disable for edge-to-edge embedded content.
|
|
36
|
+
* @defaultValue true
|
|
37
|
+
*/
|
|
38
|
+
bodyPadding?: boolean;
|
|
39
|
+
/** Requested presentation; pinned requires a DrawerLayout host and sufficient space. Without a host it floats. @defaultValue 'floating' */
|
|
40
|
+
mode?: DrawerMode;
|
|
41
|
+
/** Accessible panel name; hosted panels default to the structured title, otherwise "Drawer content". */
|
|
42
|
+
accessibleLabel?: string;
|
|
21
43
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @default 50
|
|
25
|
-
* @example
|
|
26
|
-
* <Drawer heightGap={50} />
|
|
44
|
+
* Floating top offset in pixels; ignored when pinned or expanded.
|
|
45
|
+
* @defaultValue 50
|
|
27
46
|
*/
|
|
28
47
|
heightGap?: number;
|
|
29
48
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @default 'right'
|
|
49
|
+
* Edge from which the panel slides into view.
|
|
50
|
+
* @defaultValue 'right'
|
|
33
51
|
*/
|
|
34
52
|
origin?: 'left' | 'right';
|
|
35
|
-
/** Class name on the root overlay `section`. */
|
|
36
|
-
className?: string;
|
|
37
|
-
/** Class name on the inner panel (`drawer_content`), e.g. to override max-width. */
|
|
38
|
-
contentClassName?: string;
|
|
39
53
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
54
|
+
* Panel width outside DrawerLayout: `md` is responsive up to 507px and `lg` up to 600px.
|
|
55
|
+
* DrawerLayout supplies its own width.
|
|
56
|
+
* @defaultValue 'md'
|
|
43
57
|
*/
|
|
44
|
-
|
|
58
|
+
size?: 'md' | 'lg';
|
|
45
59
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @default 'default'
|
|
60
|
+
* Standalone width policy.
|
|
61
|
+
* @deprecated Use `size`: `default` is `md` and `fit` is `lg`. `size` wins when both are set.
|
|
49
62
|
*/
|
|
50
63
|
contentWidth?: 'default' | 'fit';
|
|
51
64
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @default false
|
|
65
|
+
* Fills the viewport, ignores heightGap and releases any pinned column; controlled by the caller.
|
|
66
|
+
* @defaultValue false
|
|
56
67
|
*/
|
|
57
68
|
isExpanded?: boolean;
|
|
69
|
+
/** Enables the built-in desktop expand/collapse button in either header. Defaults to disabled. */
|
|
70
|
+
expansion?: boolean | DrawerExpansionConfig;
|
|
71
|
+
/** Reports an expansion toggle; required when isExpanded controls the built-in button. */
|
|
72
|
+
onExpandedChange?: (isExpanded: boolean) => void;
|
|
73
|
+
/** Additional class on the root overlay section. */
|
|
74
|
+
className?: string;
|
|
75
|
+
/** Additional class on the inner panel, for example to customize its width. */
|
|
76
|
+
contentClassName?: string;
|
|
58
77
|
/**
|
|
59
|
-
*
|
|
78
|
+
* Title content in the legacy header row.
|
|
79
|
+
* @deprecated Use `headerConfig.title` (plain text) and `headerConfig.closeLabel`.
|
|
80
|
+
* Move icons and metadata to their dedicated configuration fields.
|
|
60
81
|
*/
|
|
61
|
-
|
|
82
|
+
title?: React.ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* Custom content beside the legacy title and close button.
|
|
85
|
+
* @deprecated Use `headerConfig.controls` for desktop presentation actions,
|
|
86
|
+
* or `headerConfig.toolbar` for actions available on all screen sizes.
|
|
87
|
+
*/
|
|
88
|
+
header?: React.ReactNode;
|
|
89
|
+
/**
|
|
90
|
+
* Additional content below the legacy header row.
|
|
91
|
+
* @deprecated Use `headerConfig.pills`, `description`, `context` or `toolbar`
|
|
92
|
+
* according to the content.
|
|
93
|
+
*/
|
|
94
|
+
headerExtra?: React.ReactNode;
|
|
62
95
|
}
|
|
63
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Stable shell that keeps its content mounted through mode changes and until exit completes.
|
|
98
|
+
* Generic so `navigation.renderView` receives the controller's typed entries.
|
|
99
|
+
*/
|
|
100
|
+
declare function Drawer<Target extends DrawerNavigationTarget = DrawerNavigationTarget>(props: DrawerProps<Target>): import("react/jsx-runtime").JSX.Element | null;
|
|
64
101
|
export default Drawer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type HTMLAttributes } from 'react';
|
|
2
|
+
/** Shared scrolling surface for static content and navigable visits. */
|
|
3
|
+
export interface DrawerBodyProps extends HTMLAttributes<HTMLElement> {
|
|
4
|
+
/** Applies the standard content inset; disable for embedded edge-to-edge components. */
|
|
5
|
+
hasPadding: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Keeps body geometry identical in both composition modes. */
|
|
8
|
+
declare const DrawerBody: import("react").ForwardRefExoticComponent<DrawerBodyProps & import("react").RefAttributes<HTMLElement>>;
|
|
9
|
+
export default DrawerBody;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FC, type ReactNode } from 'react';
|
|
2
|
+
/** Optional footer regions supplied by the Drawer shell. */
|
|
3
|
+
export interface DrawerFooterProps {
|
|
4
|
+
/** Main footer content, such as actions, an input or a custom component. */
|
|
5
|
+
content?: ReactNode;
|
|
6
|
+
/** Supporting content below the main slot, with caller-owned formatting. */
|
|
7
|
+
message?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/** Keeps optional footer slots outside the scrolling body without styling their contents. */
|
|
10
|
+
declare const DrawerFooter: FC<DrawerFooterProps>;
|
|
11
|
+
export default DrawerFooter;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
/** Private close action shared by the static header and the navigable Drawer shell. */
|
|
3
|
+
export interface DrawerCloseControlProps {
|
|
4
|
+
/** Localized accessible name for dismissal. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Requests dismissal; the Drawer shell decides whether it is allowed. */
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
/** Blocks dismissal while a confirmation is pending or exit has begun. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Keeps the button fixed above the visits that slide beneath it. */
|
|
11
|
+
persistent?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** One close-button implementation preserves layout and keyboard behavior across modes. */
|
|
14
|
+
declare const DrawerCloseControl: FC<DrawerCloseControlProps>;
|
|
15
|
+
export default DrawerCloseControl;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { DrawerHeaderConfig } from '../../types/drawerHeader.types';
|
|
3
|
+
import { type DrawerCloseControlProps } from './DrawerCloseControl';
|
|
4
|
+
/** Internal connection between the structured header and the Drawer shell. */
|
|
5
|
+
export interface DrawerHeaderProps {
|
|
6
|
+
/** Identity, actions and optional contextual rows supplied by the caller. */
|
|
7
|
+
config: Omit<DrawerHeaderConfig, 'closeLabel'>;
|
|
8
|
+
/** Inline close control; without it, the slot is reserved for the shell's persistent one. */
|
|
9
|
+
close?: Omit<DrawerCloseControlProps, 'persistent'>;
|
|
10
|
+
}
|
|
11
|
+
/** Renders the header regions; the Drawer shell owns visibility and dismissal. */
|
|
12
|
+
declare const DrawerHeader: FC<DrawerHeaderProps>;
|
|
13
|
+
export default DrawerHeader;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, FC } from 'react';
|
|
2
|
+
import type { IconTypes } from '../../../../../../avocado-icons';
|
|
3
|
+
/** Private icon-only action shared by the header's leading, Back and close controls. */
|
|
4
|
+
export interface DrawerIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
5
|
+
/** Glyph shown inside the button. */
|
|
6
|
+
icon: IconTypes;
|
|
7
|
+
/** Localized accessible name, also used as the tooltip. */
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
declare const DrawerIconButton: FC<DrawerIconButtonProps>;
|
|
11
|
+
export default DrawerIconButton;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FC, ReactNode } from 'react';
|
|
2
|
+
/** @deprecated Private compatibility branch; remove with Drawer's legacy header props. */
|
|
3
|
+
export interface DrawerLegacyHeaderProps {
|
|
4
|
+
/** Legacy identity content. */
|
|
5
|
+
title?: ReactNode;
|
|
6
|
+
/** Legacy controls beside the title. */
|
|
7
|
+
header?: ReactNode;
|
|
8
|
+
/** Legacy content below the main row. */
|
|
9
|
+
headerExtra?: ReactNode;
|
|
10
|
+
/** Built-in desktop presentation controls; do not create a header on their own. */
|
|
11
|
+
presentationControls?: ReactNode;
|
|
12
|
+
/** Requests dismissal through the shell's guard. */
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
/** Disables dismissal during a guard or exit. */
|
|
15
|
+
isCloseDisabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** @deprecated Preserves legacy composition until the next breaking header migration. */
|
|
18
|
+
declare const DrawerLegacyHeader: FC<DrawerLegacyHeaderProps>;
|
|
19
|
+
export default DrawerLegacyHeader;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { DrawerNavigationBinding, DrawerNavigationTarget } from '../../types/drawerNavigation.types';
|
|
3
|
+
import type { DrawerNavigationSnapshotDetails } from '../../utils/drawerNavigationInternals';
|
|
4
|
+
/** Id of a visit's body, whose accessible name is the visit title. */
|
|
5
|
+
export declare const getDrawerVisitLabelId: (entryKey: string) => string;
|
|
6
|
+
/** Renders every visit in history; only the current one is visible and interactive. */
|
|
7
|
+
export interface DrawerNavigationViewProps<Target extends DrawerNavigationTarget> {
|
|
8
|
+
/** Controller, view renderer and Back label supplied by the consumer. */
|
|
9
|
+
navigation: DrawerNavigationBinding<Target>;
|
|
10
|
+
/** Built-in controls shared by every visit header. */
|
|
11
|
+
presentationControls?: ReactNode;
|
|
12
|
+
/** Operation that produced the current snapshot; selects the transition. */
|
|
13
|
+
lastAction: DrawerNavigationSnapshotDetails['lastAction'];
|
|
14
|
+
/** Applies the standard body padding when true. */
|
|
15
|
+
bodyPadding: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Previous visits stay mounted, so their state, scroll and focus survive Back. */
|
|
18
|
+
declare function DrawerNavigationView<Target extends DrawerNavigationTarget>({ navigation: { controller, renderView, backLabel }, lastAction, bodyPadding, presentationControls, }: DrawerNavigationViewProps<Target>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export default DrawerNavigationView;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FC, type MutableRefObject, type ReactNode } from 'react';
|
|
2
|
+
import { type DrawerVisitContextValue } from '../../contexts/drawerNavigationContext';
|
|
3
|
+
export interface DrawerNavigationVisitProps extends Omit<DrawerVisitContextValue, 'bodyRef'> {
|
|
4
|
+
/** The current visit; covered and exiting visits are hidden and inert. */
|
|
5
|
+
isActive: boolean;
|
|
6
|
+
/** Direction for push/back, or zero for replace/reset. */
|
|
7
|
+
direction: -1 | 0 | 1;
|
|
8
|
+
/** Removes horizontal travel and duration for reduced-motion users. */
|
|
9
|
+
isReducedMotion: boolean;
|
|
10
|
+
/** False only while the view renders its first visit, which must not take focus. */
|
|
11
|
+
hasNavigated: MutableRefObject<boolean>;
|
|
12
|
+
/** The consumer's DrawerView for this visit. */
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/** Keeps one visit mounted; Back reveals it with its state, scroll and last focus intact. */
|
|
16
|
+
declare const DrawerNavigationVisit: FC<DrawerNavigationVisitProps>;
|
|
17
|
+
export default DrawerNavigationVisit;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type FC, type ReactNode } from 'react';
|
|
2
|
+
import type { DrawerHeaderConfig } from '../../types/drawerHeader.types';
|
|
3
|
+
/** One navigable visit: its header, scrolling body and footer change together. */
|
|
4
|
+
export interface DrawerViewProps {
|
|
5
|
+
/**
|
|
6
|
+
* Identity, actions and contextual rows; Back replaces the leading action below the root.
|
|
7
|
+
* The close label belongs to `navigation.closeLabel`, since Close stays outside the visit.
|
|
8
|
+
*/
|
|
9
|
+
headerConfig: Omit<DrawerHeaderConfig, 'closeLabel'>;
|
|
10
|
+
/** Scrolling content of this visit. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/** Optional main footer content for this visit. */
|
|
13
|
+
footer?: ReactNode;
|
|
14
|
+
/** Optional supporting content beneath this visit's footer. */
|
|
15
|
+
footerMessage?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/** Composes a visit inside `navigation.renderView`; the shell keeps Close fixed above it. */
|
|
18
|
+
declare const DrawerView: FC<DrawerViewProps>;
|
|
19
|
+
export default DrawerView;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type RefObject, type ReactNode } from 'react';
|
|
2
|
+
import type { DrawerHeaderAction } from '../types/drawerHeader.types';
|
|
3
|
+
import type { DrawerNavigationController } from '../types/drawerNavigation.types';
|
|
4
|
+
/** Private provider shared by all regions of a navigable Drawer. */
|
|
5
|
+
export declare const DrawerNavigationContext: import("react").Context<DrawerNavigationController<import("../types/drawerNavigation.types").DrawerNavigationTarget> | null>;
|
|
6
|
+
/** Private connection between one rendered visit and the DrawerView it contains. */
|
|
7
|
+
export interface DrawerVisitContextValue {
|
|
8
|
+
/** Automatic Back action; absent for the root visit. */
|
|
9
|
+
backAction?: DrawerHeaderAction;
|
|
10
|
+
/** Built-in presentation controls supplied by the shell. */
|
|
11
|
+
presentationControls?: ReactNode;
|
|
12
|
+
/** Applies the standard body padding when true. */
|
|
13
|
+
bodyPadding: boolean;
|
|
14
|
+
/** Scrolling body, used as the last focus fallback. */
|
|
15
|
+
bodyRef: RefObject<HTMLElement>;
|
|
16
|
+
/** Id of the body, which carries the visit title as its accessible name. */
|
|
17
|
+
labelId: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const DrawerVisitContext: import("react").Context<DrawerVisitContextValue | null>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DrawerProps } from '../Drawer';
|
|
2
|
+
/** Owns optional expansion without changing controlled consumers or remounting content. */
|
|
3
|
+
export declare function useDrawerExpansion({ expansion, isExpanded: controlledExpanded, onExpandedChange, shouldRender, }: Pick<DrawerProps, 'expansion' | 'isExpanded' | 'onExpandedChange'> & {
|
|
4
|
+
shouldRender: boolean;
|
|
5
|
+
}): {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
isExpanded: boolean;
|
|
8
|
+
label: string;
|
|
9
|
+
isDisabled: boolean;
|
|
10
|
+
toggle(): void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DrawerProps } from '../Drawer';
|
|
2
|
+
import type { DrawerCloseReason } from '../types/drawerNavigation.types';
|
|
3
|
+
import type { DrawerNavigationInternals } from '../utils/drawerNavigationInternals';
|
|
4
|
+
interface DrawerLifecycleOptions extends Pick<DrawerProps, 'isOpen' | 'onClose' | 'beforeClose' | 'onRequestClose'> {
|
|
5
|
+
/** Optional navigation session sharing the shell's request lock. */
|
|
6
|
+
internal?: DrawerNavigationInternals;
|
|
7
|
+
}
|
|
8
|
+
/** Keeps dismissal, interrupted transitions and session cleanup independent of rendering. */
|
|
9
|
+
export declare function useDrawerLifecycle(options: DrawerLifecycleOptions): {
|
|
10
|
+
shouldRender: boolean;
|
|
11
|
+
isInternalOpen: boolean;
|
|
12
|
+
isClosing: boolean;
|
|
13
|
+
isClosePending: boolean;
|
|
14
|
+
requestClose: (reason: DrawerCloseReason) => Promise<boolean> | undefined;
|
|
15
|
+
completeClose: () => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DrawerNavigationController, DrawerNavigationOptions, DrawerNavigationTarget } from '../types/drawerNavigation.types';
|
|
2
|
+
/** Owns one local history of visits; data and UI state stay in the consumer's view components. */
|
|
3
|
+
export declare function useDrawerNavigation<Target extends DrawerNavigationTarget>(options: DrawerNavigationOptions<Target>): DrawerNavigationController<Target>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DrawerNavigationController, DrawerNavigationTarget } from '../types/drawerNavigation.types';
|
|
2
|
+
/** Reads the nearest Drawer controller; use the same target union as its owner. */
|
|
3
|
+
export declare function useDrawerNavigationContext<Target extends DrawerNavigationTarget = DrawerNavigationTarget>(): DrawerNavigationController<Target>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default } from './Drawer';
|
|
2
|
+
export type { DrawerProps } from './Drawer';
|
|
3
|
+
export type { DrawerExpansionConfig } from './types/drawerExpansion.types';
|
|
4
|
+
export { default as DrawerView } from './components/navigation/DrawerView';
|
|
5
|
+
export type { DrawerViewProps } from './components/navigation/DrawerView';
|
|
6
|
+
export { useDrawerNavigation } from './hooks/useDrawerNavigation';
|
|
7
|
+
export { useDrawerNavigationContext } from './hooks/useDrawerNavigationContext';
|
|
8
|
+
export type { DrawerHeaderAction, DrawerHeaderConfig, } from './types/drawerHeader.types';
|
|
9
|
+
export type { DrawerCloseReason, DrawerNavigationBinding, DrawerNavigationController, DrawerNavigationEntry, DrawerNavigationOptions, DrawerNavigationRequest, DrawerNavigationTarget, } from './types/drawerNavigation.types';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Options for the Drawer's built-in desktop expansion control. */
|
|
2
|
+
export interface DrawerExpansionConfig {
|
|
3
|
+
/** Initial uncontrolled state; restored after a completed close. */
|
|
4
|
+
defaultExpanded?: boolean;
|
|
5
|
+
/** Accessible name and tooltip while collapsed; defaults to the current locale. */
|
|
6
|
+
expandLabel?: string;
|
|
7
|
+
/** Accessible name and tooltip while expanded; defaults to the current locale. */
|
|
8
|
+
collapseLabel?: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { IconTypes } from '../../../../../avocado-icons';
|
|
3
|
+
/** Optional leading action; its behavior is owned by the caller. */
|
|
4
|
+
export interface DrawerHeaderAction {
|
|
5
|
+
/** Icon displayed inside the action button. */
|
|
6
|
+
icon: IconTypes;
|
|
7
|
+
/** Localized accessible name and tooltip for the action. */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Runs when the enabled action is clicked. */
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Prevents interaction while keeping the action visible.
|
|
13
|
+
* @defaultValue false
|
|
14
|
+
*/
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Opt-in composition for Drawer; custom slots remain owned by the consumer. */
|
|
18
|
+
export interface DrawerHeaderConfig {
|
|
19
|
+
/** Plain-text heading; wraps when it exceeds the available width. */
|
|
20
|
+
title: string;
|
|
21
|
+
/**
|
|
22
|
+
* Places metadata inline (`basic`) or above the title (`stacked`).
|
|
23
|
+
* @defaultValue 'basic'
|
|
24
|
+
*/
|
|
25
|
+
layout?: 'basic' | 'stacked';
|
|
26
|
+
/** Optional icon displayed beside the title. */
|
|
27
|
+
icon?: IconTypes;
|
|
28
|
+
/** Supporting identity content, inline or above the title according to the layout. */
|
|
29
|
+
metadata?: ReactNode;
|
|
30
|
+
/** Status indicators displayed alongside the metadata. */
|
|
31
|
+
badges?: ReactNode;
|
|
32
|
+
/** Optional button before the identity; does not create navigation behavior. */
|
|
33
|
+
leadingAction?: DrawerHeaderAction;
|
|
34
|
+
/** Desktop-only presentation controls, ordered expand then pin by the caller. */
|
|
35
|
+
controls?: ReactNode;
|
|
36
|
+
/** Localized accessible name and tooltip for the built-in close button. */
|
|
37
|
+
closeLabel: string;
|
|
38
|
+
/** Full-width wrapping row, typically composed with Pill. */
|
|
39
|
+
pills?: ReactNode;
|
|
40
|
+
/** Supporting text rendered below the pills. */
|
|
41
|
+
description?: string;
|
|
42
|
+
/** Full-width content; Drawer adds no card surface or business behavior. */
|
|
43
|
+
context?: ReactNode;
|
|
44
|
+
/** Additional actions below the context, available on all screen sizes. */
|
|
45
|
+
toolbar?: ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Shows a divider along the bottom of the header.
|
|
48
|
+
* @defaultValue true
|
|
49
|
+
*/
|
|
50
|
+
hasDivider?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Visual emphasis of the bottom divider when it is shown.
|
|
53
|
+
* @defaultValue 'subtle'
|
|
54
|
+
*/
|
|
55
|
+
dividerTone?: 'subtle' | 'strong';
|
|
56
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** Consumer-defined destination; parameters identify data, not rendered components. */
|
|
3
|
+
export interface DrawerNavigationTarget {
|
|
4
|
+
/** Registered view identifier, such as `subject` or `requirement`. */
|
|
5
|
+
viewId: string;
|
|
6
|
+
/** Parameters read by the consumer's view component or data hook. */
|
|
7
|
+
params?: unknown;
|
|
8
|
+
}
|
|
9
|
+
/** A visit has its own identity even when the same destination appears twice. */
|
|
10
|
+
export type DrawerNavigationEntry<Target extends DrawerNavigationTarget = DrawerNavigationTarget> = Target & {
|
|
11
|
+
/** Unique identity within this controller, including resets and repeated visits. */
|
|
12
|
+
readonly key: string;
|
|
13
|
+
};
|
|
14
|
+
/** Options for a local, opt-in history; no URL or browser-history integration. */
|
|
15
|
+
export interface DrawerNavigationOptions<Target extends DrawerNavigationTarget> {
|
|
16
|
+
/** Latest initial destination, used when context changes or the session resets. */
|
|
17
|
+
rootView: Target;
|
|
18
|
+
/** Entity or route identity; changing it replaces the complete history. */
|
|
19
|
+
navigationKey: string | number;
|
|
20
|
+
/** Allowed view identifiers; unknown destinations are ignored at runtime. */
|
|
21
|
+
viewIds: readonly Target['viewId'][];
|
|
22
|
+
/** Allows or denies user navigation; false, a thrown error or a rejection keeps the view. */
|
|
23
|
+
beforeNavigate?: (request: DrawerNavigationRequest<Target>) => boolean | Promise<boolean>;
|
|
24
|
+
}
|
|
25
|
+
/** Navigation awaiting the consumer's approval. */
|
|
26
|
+
export interface DrawerNavigationRequest<Target extends DrawerNavigationTarget = DrawerNavigationTarget> {
|
|
27
|
+
/** Requested history operation. */
|
|
28
|
+
action: 'push' | 'back' | 'replace' | 'reset';
|
|
29
|
+
/** Visit being left. */
|
|
30
|
+
from: DrawerNavigationEntry<Target>;
|
|
31
|
+
/** Destination, including the previous visit on Back. */
|
|
32
|
+
to: Target;
|
|
33
|
+
}
|
|
34
|
+
/** User interaction that requested dismissal. */
|
|
35
|
+
export type DrawerCloseReason = 'close-button' | 'backdrop' | 'escape';
|
|
36
|
+
/** Navigation state and commands available to the owner and descendant content. */
|
|
37
|
+
export interface DrawerNavigationController<Target extends DrawerNavigationTarget = DrawerNavigationTarget> {
|
|
38
|
+
/** Current visit, including its typed destination parameters. */
|
|
39
|
+
readonly entry: DrawerNavigationEntry<Target>;
|
|
40
|
+
/** Visits from the root through the current one; all of them stay mounted. */
|
|
41
|
+
readonly entries: readonly DrawerNavigationEntry<Target>[];
|
|
42
|
+
/** Whether there is a previous entry to return to. */
|
|
43
|
+
readonly canGoBack: boolean;
|
|
44
|
+
/** A navigation or close confirmation is awaiting a decision; other requests resolve false. */
|
|
45
|
+
readonly isPending: boolean;
|
|
46
|
+
/** Appends a fresh visit; resolves true when history changed. */
|
|
47
|
+
push(target: Target): Promise<boolean>;
|
|
48
|
+
/** Removes the current visit; resolves false at the root. */
|
|
49
|
+
back(): Promise<boolean>;
|
|
50
|
+
/** Replaces the current visit without changing history depth. */
|
|
51
|
+
replace(target: Target): Promise<boolean>;
|
|
52
|
+
/** Starts a new session at the supplied destination or latest root. */
|
|
53
|
+
reset(target?: Target): Promise<boolean>;
|
|
54
|
+
}
|
|
55
|
+
/** Connects a controller and the consumer's view renderer to the Drawer shell. */
|
|
56
|
+
export interface DrawerNavigationBinding<Target extends DrawerNavigationTarget = DrawerNavigationTarget> {
|
|
57
|
+
/** Controller created by useDrawerNavigation for this drawer. */
|
|
58
|
+
controller: DrawerNavigationController<Target>;
|
|
59
|
+
/**
|
|
60
|
+
* Renders one visit, usually as a component that returns DrawerView.
|
|
61
|
+
* Called for every visit in history; hidden visits stay mounted.
|
|
62
|
+
*/
|
|
63
|
+
renderView: (entry: DrawerNavigationEntry<Target>) => ReactNode;
|
|
64
|
+
/** Localized accessible name and tooltip for the automatic back action. */
|
|
65
|
+
backLabel: string;
|
|
66
|
+
/** Localized accessible name and tooltip for the close control, fixed above every visit. */
|
|
67
|
+
closeLabel: string;
|
|
68
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DrawerNavigationController, DrawerNavigationOptions, DrawerNavigationTarget } from '../types/drawerNavigation.types';
|
|
2
|
+
/** Creates one local controller store; nothing is shared across Drawer instances. */
|
|
3
|
+
export declare function createDrawerNavigation<Target extends DrawerNavigationTarget>(initialOptions: DrawerNavigationOptions<Target>, keyPrefix: string): {
|
|
4
|
+
getSnapshot: () => DrawerNavigationController<Target>;
|
|
5
|
+
subscribe(listener: () => void): () => void;
|
|
6
|
+
configure(next: DrawerNavigationOptions<Target>): void;
|
|
7
|
+
activate(): void;
|
|
8
|
+
deactivate(): void;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|