@amboss/design-system 4.6.7-canary.0 → 4.7.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/build/cjs/components/Internal/Panel/Panel.d.ts +3 -7
- package/build/cjs/components/Internal/Panel/Panel.js +1 -1
- package/build/cjs/components/Internal/PanelHeader/PanelHeader.d.ts +4 -8
- package/build/cjs/components/Internal/PanelHeader/PanelHeader.js +1 -1
- package/build/cjs/components/Internal/Sandwich/-types.d.ts +0 -5
- package/build/cjs/components/Internal/Sandwich/Sandwich.d.ts +1 -1
- package/build/cjs/components/Internal/Sandwich/Sandwich.js +1 -1
- package/build/cjs/components/Layout/-types.d.ts +8 -64
- package/build/cjs/components/Layout/Layout.d.ts +0 -4
- package/build/cjs/components/Layout/Layout.js +1 -1
- package/build/cjs/components/Layout/LeftPanel/LeftPanel.js +1 -1
- package/build/cjs/components/Layout/LeftPanel/LeftPanelDocked.d.ts +5 -15
- package/build/cjs/components/Layout/LeftPanel/LeftPanelDocked.js +1 -1
- package/build/cjs/components/Layout/LeftPanel/LeftPanelDrawer.js +1 -1
- package/build/cjs/components/Layout/LeftPanel/LeftPanelFooter.js +1 -1
- package/build/cjs/components/Layout/LeftPanel/LeftPanelHeader.d.ts +3 -5
- package/build/cjs/components/Layout/LeftPanel/LeftPanelHeader.js +1 -1
- package/build/cjs/components/Layout/PanelSlideBody.d.ts +18 -0
- package/build/cjs/components/Layout/PanelSlideBody.js +1 -0
- package/build/cjs/components/Layout/registry.d.ts +0 -11
- package/build/cjs/components/Layout/registry.js +1 -1
- package/build/cjs/components/Layout/rules.js +1 -1
- package/build/cjs/components/Layout/useLayoutRules.js +1 -1
- package/build/cjs/components/Layout/usePanelDockedSlide.d.ts +5 -10
- package/build/cjs/components/Layout/usePanelDockedSlide.js +1 -1
- package/build/cjs/shared/mixins/index.d.ts +0 -1
- package/build/cjs/shared/mixins/index.js +1 -1
- package/build/cjs/web-tokens/_sizes.json +54 -64
- package/build/cjs/web-tokens/visualConfig.d.ts +0 -7
- package/build/cjs/web-tokens/visualConfig.js +1 -1
- package/build/esm/components/Internal/Panel/Panel.d.ts +3 -7
- package/build/esm/components/Internal/Panel/Panel.js +1 -1
- package/build/esm/components/Internal/PanelHeader/PanelHeader.d.ts +4 -8
- package/build/esm/components/Internal/PanelHeader/PanelHeader.js +1 -1
- package/build/esm/components/Internal/Sandwich/-types.d.ts +0 -5
- package/build/esm/components/Internal/Sandwich/Sandwich.d.ts +1 -1
- package/build/esm/components/Internal/Sandwich/Sandwich.js +1 -1
- package/build/esm/components/Layout/-types.d.ts +8 -64
- package/build/esm/components/Layout/Layout.d.ts +0 -4
- package/build/esm/components/Layout/Layout.js +1 -1
- package/build/esm/components/Layout/LeftPanel/LeftPanel.js +1 -1
- package/build/esm/components/Layout/LeftPanel/LeftPanelDocked.d.ts +5 -15
- package/build/esm/components/Layout/LeftPanel/LeftPanelDocked.js +1 -1
- package/build/esm/components/Layout/LeftPanel/LeftPanelDrawer.js +1 -1
- package/build/esm/components/Layout/LeftPanel/LeftPanelFooter.js +1 -1
- package/build/esm/components/Layout/LeftPanel/LeftPanelHeader.d.ts +3 -5
- package/build/esm/components/Layout/LeftPanel/LeftPanelHeader.js +1 -1
- package/build/esm/components/Layout/PanelSlideBody.d.ts +18 -0
- package/build/esm/components/Layout/PanelSlideBody.js +1 -0
- package/build/esm/components/Layout/registry.d.ts +0 -11
- package/build/esm/components/Layout/registry.js +1 -1
- package/build/esm/components/Layout/rules.js +1 -1
- package/build/esm/components/Layout/useLayoutRules.js +1 -1
- package/build/esm/components/Layout/usePanelDockedSlide.d.ts +5 -10
- package/build/esm/components/Layout/usePanelDockedSlide.js +1 -1
- package/build/esm/shared/mixins/index.d.ts +0 -1
- package/build/esm/shared/mixins/index.js +1 -1
- package/build/esm/web-tokens/_sizes.json +54 -64
- package/build/esm/web-tokens/visualConfig.d.ts +0 -7
- package/build/esm/web-tokens/visualConfig.js +1 -1
- package/build/fonts/fontStylesheet.d.ts +4 -0
- package/build/fonts/fontStylesheet.js +2 -0
- package/build/scss/_variables.scss +0 -3
- package/package.json +8 -2
- package/build/cjs/components/Layout/LeftNavBar/LeftNavBar.d.ts +0 -17
- package/build/cjs/components/Layout/LeftNavBar/LeftNavBar.js +0 -1
- package/build/cjs/components/Layout/LeftNavBar/LeftNavBarFooter.d.ts +0 -7
- package/build/cjs/components/Layout/LeftNavBar/LeftNavBarFooter.js +0 -1
- package/build/cjs/components/Layout/LeftPanel/LeftBarLayers.d.ts +0 -45
- package/build/cjs/components/Layout/LeftPanel/LeftBarLayers.js +0 -1
- package/build/cjs/components/Layout/LeftPanel/LeftBarToggle.d.ts +0 -15
- package/build/cjs/components/Layout/LeftPanel/LeftBarToggle.js +0 -1
- package/build/cjs/components/Layout/LeftPanel/LeftPanelOffcanvas.d.ts +0 -29
- package/build/cjs/components/Layout/LeftPanel/LeftPanelOffcanvas.js +0 -1
- package/build/cjs/components/Layout/LeftPanel/useLeftBarContext.d.ts +0 -11
- package/build/cjs/components/Layout/LeftPanel/useLeftBarContext.js +0 -1
- package/build/cjs/components/Layout/LeftPanel/useLeftPanelCollapseContext.d.ts +0 -11
- package/build/cjs/components/Layout/LeftPanel/useLeftPanelCollapseContext.js +0 -1
- package/build/cjs/components/Layout/useLeftPanelId.d.ts +0 -6
- package/build/cjs/components/Layout/useLeftPanelId.js +0 -1
- package/build/cjs/shared/mixins/getLeftPanelFadeStyles.d.ts +0 -19
- package/build/cjs/shared/mixins/getLeftPanelFadeStyles.js +0 -1
- package/build/esm/components/Layout/LeftNavBar/LeftNavBar.d.ts +0 -17
- package/build/esm/components/Layout/LeftNavBar/LeftNavBar.js +0 -1
- package/build/esm/components/Layout/LeftNavBar/LeftNavBarFooter.d.ts +0 -7
- package/build/esm/components/Layout/LeftNavBar/LeftNavBarFooter.js +0 -1
- package/build/esm/components/Layout/LeftPanel/LeftBarLayers.d.ts +0 -45
- package/build/esm/components/Layout/LeftPanel/LeftBarLayers.js +0 -1
- package/build/esm/components/Layout/LeftPanel/LeftBarToggle.d.ts +0 -15
- package/build/esm/components/Layout/LeftPanel/LeftBarToggle.js +0 -1
- package/build/esm/components/Layout/LeftPanel/LeftPanelOffcanvas.d.ts +0 -29
- package/build/esm/components/Layout/LeftPanel/LeftPanelOffcanvas.js +0 -1
- package/build/esm/components/Layout/LeftPanel/useLeftBarContext.d.ts +0 -11
- package/build/esm/components/Layout/LeftPanel/useLeftBarContext.js +0 -1
- package/build/esm/components/Layout/LeftPanel/useLeftPanelCollapseContext.d.ts +0 -11
- package/build/esm/components/Layout/LeftPanel/useLeftPanelCollapseContext.js +0 -1
- package/build/esm/components/Layout/useLeftPanelId.d.ts +0 -6
- package/build/esm/components/Layout/useLeftPanelId.js +0 -1
- package/build/esm/shared/mixins/getLeftPanelFadeStyles.d.ts +0 -19
- package/build/esm/shared/mixins/getLeftPanelFadeStyles.js +0 -1
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { ForwardedScrollProps } from "../-types";
|
|
2
|
+
import type { ForwardedScrollProps, Size } from "../-types";
|
|
3
3
|
export type LeftPanelDockedProps = ForwardedScrollProps & {
|
|
4
4
|
children: React.ReactNode;
|
|
5
|
-
/** Accessible name for the left bar's open button. */
|
|
6
|
-
toggleButtonLabel: string;
|
|
7
5
|
"aria-label"?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
minSize?: number;
|
|
12
|
-
maxSize?: number;
|
|
6
|
+
defaultSize?: Size;
|
|
7
|
+
minSize?: Size;
|
|
8
|
+
maxSize?: Size;
|
|
13
9
|
collapsible?: boolean;
|
|
14
10
|
resizable?: boolean;
|
|
15
11
|
};
|
|
@@ -17,15 +13,9 @@ export type LeftPanelDockedProps = ForwardedScrollProps & {
|
|
|
17
13
|
* Docked (desktop) left panel. Declares the `leftPanel` slot and portals its
|
|
18
14
|
* content into the Group's host - an in-flow, resizable column whose width
|
|
19
15
|
* slides open/closed via {@link usePanelDockedSlide} (when collapsible). Content
|
|
20
|
-
* lives in {@link
|
|
16
|
+
* lives in a {@link PanelContainer} so `Layout.LeftPanelHeader` /
|
|
21
17
|
* `Layout.LeftPanelFooter` children stick to the edges. The mobile presentation
|
|
22
18
|
* lives in {@link LeftPanelDrawer}; `LeftPanel` picks between the two by
|
|
23
19
|
* breakpoint.
|
|
24
|
-
*
|
|
25
|
-
* The column never leaves the row: it rests at the left bar's width and widens
|
|
26
|
-
* to `defaultSize`. Content and footer hold the open width and are clipped, so
|
|
27
|
-
* nothing in them moves - the panel simply shows less of itself. The header is
|
|
28
|
-
* left to narrow with the column, which walks a control at its trailing edge
|
|
29
|
-
* down into the left bar.
|
|
30
20
|
*/
|
|
31
21
|
export declare const LeftPanelDocked: React.FC<LeftPanelDockedProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from"react";import
|
|
1
|
+
import React from"react";import{Slot}from"../-constants";import{useLayoutPortal}from"../registry";import{usePanelDockedSlide}from"../usePanelDockedSlide";import{PanelSlideBody}from"../PanelSlideBody";import{PanelContainer}from"../PanelContainer";export const LeftPanelDocked=({children,"aria-label":ariaLabel,defaultSize,minSize,maxSize,collapsible=!0,resizable,scrollContainerRef,onScroll})=>{let{isMounted,pinnedWidth}=usePanelDockedSlide({slot:Slot.leftPanel,defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize:!0});return useLayoutPortal(Slot.leftPanel,isMounted?React.createElement(PanelSlideBody,{anchor:"right",pinnedWidth:pinnedWidth},React.createElement(PanelContainer,{showBorderRight:!0,"aria-label":ariaLabel,scrollContainerRef:scrollContainerRef,onScroll:onScroll},children)):null)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from"react";import styled from"@emotion/styled";import{Drawer}from"../../Internal/Drawer/Drawer";import{PanelContainer}from"../PanelContainer";
|
|
1
|
+
import React from"react";import styled from"@emotion/styled";import{Drawer}from"../../Internal/Drawer/Drawer";import{PanelContainer}from"../PanelContainer";let StyledLeftPanelBody=styled("div",{target:"e1pciy730",label:"StyledLeftPanelBody"})({width:"80vw",height:"100dvh"});export const LeftPanelDrawer=({children,isVisible,hide,"aria-label":ariaLabel,scrollContainerRef,onScroll})=>React.createElement(Drawer,{isVisible:isVisible,positionX:"left",handleClose:hide,"aria-label":ariaLabel},React.createElement(StyledLeftPanelBody,null,React.createElement(PanelContainer,{scrollContainerRef:scrollContainerRef,onScroll:onScroll},children)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from"react";import
|
|
1
|
+
import React from"react";import{Sandwich}from"../../Internal/Sandwich/Sandwich";export function LeftPanelFooter({children,"data-e2e-test-id":dataE2eTestId}){return React.createElement(Sandwich.Footer,{"data-e2e-test-id":dataE2eTestId},children)}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { LeftPanelHeaderProps } from "../-types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* sticks to the top while the rest of the content scrolls.
|
|
6
|
-
* slot, an optional title, a right slot, and beneath them whatever is passed as
|
|
7
|
-
* `children`.
|
|
4
|
+
* Optional sticky header for `Layout.LeftPanel` - place it among the panel's
|
|
5
|
+
* children; it sticks to the top while the rest of the content scrolls.
|
|
8
6
|
*/
|
|
9
|
-
export declare function LeftPanelHeader({ leftSlot,
|
|
7
|
+
export declare function LeftPanelHeader({ leftSlot, rightSlot, "data-e2e-test-id": dataE2eTestId, }: LeftPanelHeaderProps): React.ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from"react";import
|
|
1
|
+
import React from"react";import{Sandwich}from"../../Internal/Sandwich/Sandwich";import{PanelHeader}from"../../Internal/PanelHeader/PanelHeader";export function LeftPanelHeader({leftSlot,rightSlot,"data-e2e-test-id":dataE2eTestId}){return React.createElement(Sandwich.Header,{"data-e2e-test-id":dataE2eTestId},React.createElement(PanelHeader,{leftSlot:leftSlot,rightSlot:rightSlot}))}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** Edge the body is pinned to while the column slides - the panel's docked
|
|
3
|
+
* edge (`right` for the left panel, `left` for the right panel). */
|
|
4
|
+
export type PanelSlideAnchor = "left" | "right";
|
|
5
|
+
export type PanelSlideBodyProps = {
|
|
6
|
+
/** Body width (px) while sliding; `null` at rest (fills the column). Comes
|
|
7
|
+
* from {@link usePanelDockedSlide}. */
|
|
8
|
+
pinnedWidth: number | null;
|
|
9
|
+
/** The edge the panel docks against. */
|
|
10
|
+
anchor: PanelSlideAnchor;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The clipped, edge-anchored body a docked side panel's content lives in so
|
|
15
|
+
* its open/close width animation reads as a drawer slide. Pair with
|
|
16
|
+
* {@link usePanelDockedSlide}, which supplies `pinnedWidth`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PanelSlideBody: React.FC<PanelSlideBodyProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from"react";import styled from"@emotion/styled";import{PAGE_BOTTOM_BAR_INSET}from"./-constants";let StyledPanelSlideClip=styled("div",{target:"e1mhh3wi0",label:"StyledPanelSlideClip"})({position:"relative",width:"100%",height:`calc(100% - ${PAGE_BOTTOM_BAR_INSET})`,overflow:"hidden"}),StyledPanelSlideBody=styled("div",{shouldForwardProp:prop=>"pinnedWidth"!==prop&&"anchor"!==prop,target:"e1mhh3wi1",label:"StyledPanelSlideBody"})(({pinnedWidth,anchor})=>({width:"100%",height:"100%",...null!=pinnedWidth&&{position:"absolute",top:0,[anchor]:0,width:`${pinnedWidth}px`}}));export const PanelSlideBody=({pinnedWidth,anchor,children})=>React.createElement(StyledPanelSlideClip,null,React.createElement(StyledPanelSlideBody,{pinnedWidth:pinnedWidth,anchor:anchor},children));
|
|
@@ -40,17 +40,6 @@ export declare const PanelRegistryContext: React.Context<PanelRegistry>;
|
|
|
40
40
|
export declare function useDeclarePanel(slot: SlotKey, reg: PanelReg): void;
|
|
41
41
|
export type PanelDeclarations = Partial<Record<SlotKey, PanelReg>>;
|
|
42
42
|
export declare const PanelDeclarationsContext: React.Context<Partial<Record<"content" | "leftPanel" | "splitview" | "rightPanel", PanelReg>>>;
|
|
43
|
-
/**
|
|
44
|
-
* The ids of the columns in the resizable row, in order, joined with commas.
|
|
45
|
-
* Changes when a column joins or leaves the row, and only then. A column that
|
|
46
|
-
* has to hold a width of its own across such a change - the left bar column,
|
|
47
|
-
* which react-resizable-panels would otherwise put back at whatever width it
|
|
48
|
-
* had the last time the same set of columns was on screen - re-checks its rest
|
|
49
|
-
* against it.
|
|
50
|
-
*/
|
|
51
|
-
export declare const PanelRowContext: React.Context<string>;
|
|
52
|
-
/** The row's current column set, as a stable key. Empty outside a Layout. */
|
|
53
|
-
export declare function usePanelRow(): string;
|
|
54
43
|
/**
|
|
55
44
|
* Keeps an animating-out panel in the resizable row while its exit plays - the
|
|
56
45
|
* Group would otherwise drop the column the instant it's hidden. The panel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext,useContext,useEffect,useLayoutEffect,useRef}from"react";import{createPortal}from"react-dom";import{Slot}from"./-constants";import{useLayoutPanelsEnabled}from"./context";export const LayoutPortalContext=createContext({});export function useLayoutPortal(slot,children){let slotNode=useContext(LayoutPortalContext)[slot]??null;return slotNode?createPortal(children,slotNode):null}export const PanelRegistryContext=createContext(null);export function useDeclarePanel(slot,reg){let registry=useContext(PanelRegistryContext),declarationEnabled=!0===useLayoutPanelsEnabled()||slot===Slot.content,{defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize,variant}=reg;useLayoutEffect(()=>{if(registry&&declarationEnabled)return registry.register(slot,{defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize,variant}),()=>registry.unregister(slot)},[registry,declarationEnabled,slot,defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize,variant])}export const PanelDeclarationsContext=createContext({});export const
|
|
1
|
+
import{createContext,useContext,useEffect,useLayoutEffect,useRef}from"react";import{createPortal}from"react-dom";import{Slot}from"./-constants";import{useLayoutPanelsEnabled}from"./context";export const LayoutPortalContext=createContext({});export function useLayoutPortal(slot,children){let slotNode=useContext(LayoutPortalContext)[slot]??null;return slotNode?createPortal(children,slotNode):null}export const PanelRegistryContext=createContext(null);export function useDeclarePanel(slot,reg){let registry=useContext(PanelRegistryContext),declarationEnabled=!0===useLayoutPanelsEnabled()||slot===Slot.content,{defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize,variant}=reg;useLayoutEffect(()=>{if(registry&&declarationEnabled)return registry.register(slot,{defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize,variant}),()=>registry.unregister(slot)},[registry,declarationEnabled,slot,defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize,variant])}export const PanelDeclarationsContext=createContext({});export const PanelPresenceContext=createContext(null);export function usePanelPresence(slot,isPresent){let presence=useContext(PanelPresenceContext);useLayoutEffect(()=>{if(presence)return presence.setPresent(slot,isPresent),()=>presence.setPresent(slot,!1)},[presence,slot,isPresent])}export const PanelAnimationContext=createContext(null);export function usePanelAnimationControl(){return useContext(PanelAnimationContext)}export function useRunCallbackOnValueChange(value,onChange){let prev=useRef(value);useEffect(()=>{prev.current!==value&&(prev.current=value,onChange?.(value))},[value,onChange])}export function useVisibleChange(visible,onChange){useRunCallbackOnValueChange(visible,onChange)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export const DEFAULT_LAYOUT_RULES={maxDockedPanels:{xs:1,m:2,l:3},rightPanel:{priority:1,condition:({isLowPrio,isMobile,layout})=>{isLowPrio&&!isMobile&&layout.rightPanel.setVariant("float")}},splitview:{priority:2,condition:({isLowPrio,isMobile,layout})=>{isLowPrio&&!isMobile&&layout.splitview.hide()}},leftPanel:{priority:3,condition:({isLowPrio,isMobile,layout})=>{let variant=isMobile||isLowPrio?"drawer":"sidebar";variant!==layout.leftPanel.state.variant&&(layout.leftPanel.setVariant(variant),"drawer"!==variant||isMobile||layout.leftPanel.hide())}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect,useRef}from"react";import{useBreakpoints}from"../../shared/useBreakpoints";import{PANEL_ORDER,Slot,TOGGLABLE_SLOTS}from"./-constants";let DEFAULT_PRIORITY={[Slot.rightPanel]:1,[Slot.splitview]:2,[Slot.leftPanel]:3},maxDockedFor=(maxDockedPanels,breakpoints)=>{let{xs,m=xs,l=m}=maxDockedPanels;return breakpoints.isMobile?xs:breakpoints.isTablet?m:l},isDockedPanel=({state,declared,slot})=>!!declared[slot]&&!!state[slot].visible&&(slot===Slot.rightPanel?"float"!==state.rightPanel.variant:slot!==Slot.leftPanel||"
|
|
1
|
+
import{useEffect,useRef}from"react";import{useBreakpoints}from"../../shared/useBreakpoints";import{PANEL_ORDER,Slot,TOGGLABLE_SLOTS}from"./-constants";let DEFAULT_PRIORITY={[Slot.rightPanel]:1,[Slot.splitview]:2,[Slot.leftPanel]:3},maxDockedFor=(maxDockedPanels,breakpoints)=>{let{xs,m=xs,l=m}=maxDockedPanels;return breakpoints.isMobile?xs:breakpoints.isTablet?m:l},isDockedPanel=({state,declared,slot})=>!!declared[slot]&&!!state[slot].visible&&(slot===Slot.rightPanel?"float"!==state.rightPanel.variant:slot!==Slot.leftPanel||"drawer"!==state.leftPanel.variant),resolveLowPrioSlots=({rules,state,declared,breakpoints})=>{let freeSlots=Math.max(0,maxDockedFor(rules.maxDockedPanels,breakpoints)-1),priorityFor=slot=>rules[slot]?.priority??DEFAULT_PRIORITY[slot],outranks=(slot,other)=>{let byPriority=priorityFor(slot)-priorityFor(other);return 0!==byPriority?byPriority<0:PANEL_ORDER.indexOf(slot)<PANEL_ORDER.indexOf(other)},countStrongerDocked=slot=>TOGGLABLE_SLOTS.filter(other=>other!==slot&&isDockedPanel({state,declared,slot:other})&&outranks(other,slot)).length;return TOGGLABLE_SLOTS.filter(slot=>countStrongerDocked(slot)>=freeSlots)};export function useLayoutRules({layout,declared,rules,additionalData}){let layoutRef=useRef(layout);layoutRef.current=layout;let{isMobile,isTablet,isDesktop}=useBreakpoints(),{state}=layout;useEffect(()=>{if(!rules)return;let lowPrioSlots=resolveLowPrioSlots({rules,state,declared,breakpoints:{isMobile,isTablet,isDesktop}});TOGGLABLE_SLOTS.forEach(slot=>{let condition=rules[slot]?.condition;condition&&condition({...additionalData,isLowPrio:lowPrioSlots.includes(slot),isMobile,isTablet,isDesktop,layout:layoutRef.current})})},[rules,additionalData,state,declared,isMobile,isTablet,isDesktop])}
|
|
@@ -14,12 +14,6 @@ export type PanelDockedSlideOptions = {
|
|
|
14
14
|
/** Forwarded to the declaration: lock the column's width when the window
|
|
15
15
|
* resizes. Doesn't affect the slide, which resizes the column outright. */
|
|
16
16
|
lockWidthOnWindowResize?: boolean;
|
|
17
|
-
/** Width the column rests at while hidden, instead of collapsing to nothing.
|
|
18
|
-
* Set it and the column never unmounts: closing narrows it to this, opening
|
|
19
|
-
* widens it back, so one box carries both states (a nav left bar that widens
|
|
20
|
-
* into the panel). The column stops being collapsible - there is no zero to
|
|
21
|
-
* collapse to - and this becomes its `minSize` while it is hidden. */
|
|
22
|
-
collapsedSize?: Size;
|
|
23
17
|
};
|
|
24
18
|
export type PanelDockedSlide = {
|
|
25
19
|
/** Whether the panel's content should render at all (entering, open, or
|
|
@@ -32,9 +26,10 @@ export type PanelDockedSlide = {
|
|
|
32
26
|
/**
|
|
33
27
|
* Animates a docked side panel's open/close as a width slide on its
|
|
34
28
|
* `react-resizable-panels` column, pushing neighbouring content smoothly
|
|
35
|
-
* instead of snapping. Slot-generic - works for either side panel
|
|
36
|
-
*
|
|
37
|
-
*
|
|
29
|
+
* instead of snapping. Slot-generic - works for either side panel; render the
|
|
30
|
+
* returned state with {@link PanelSlideBody}. Falls back to an instant
|
|
31
|
+
* open/close when the panel isn't collapsible, no handle is available, or
|
|
32
|
+
* reduced motion is requested. The mobile modal-drawer lifecycle lives in
|
|
38
33
|
* {@link useExitAnimation} and the Drawer's styled components.
|
|
39
34
|
*/
|
|
40
|
-
export declare function usePanelDockedSlide({ slot, defaultSize, minSize, maxSize, collapsible, resizable, lockWidthOnWindowResize,
|
|
35
|
+
export declare function usePanelDockedSlide({ slot, defaultSize, minSize, maxSize, collapsible, resizable, lockWidthOnWindowResize, }: PanelDockedSlideOptions): PanelDockedSlide;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLayoutEffect,
|
|
1
|
+
import{useLayoutEffect,useState}from"react";import{useTheme}from"@emotion/react";import{useWindow}from"../../shared/useWindow";import{prefersReducedMotion}from"../../shared/prefersReducedMotion";import{useDeclarePanel,usePanelAnimationControl,usePanelPresence}from"./registry";import{useLayout}from"./useLayout";let parseDurationMs=duration=>{let trimmed=duration.trim();return trimmed.endsWith("ms")?parseFloat(trimmed):trimmed.endsWith("s")?1e3*parseFloat(trimmed):parseFloat(trimmed)||0},resolveSizePx=(size,groupWidthPx)=>{if("number"==typeof size)return size;if("string"!=typeof size)return null;let parsed=parseFloat(size);return Number.isFinite(parsed)?size.trim().endsWith("px")?parsed:null!=groupWidthPx?parsed/100*groupWidthPx:null:null},groupColumnsOf=element=>{let columns=element.closest("[data-group]")?.querySelectorAll("[data-panel]");return columns?Array.from(columns):[element]},isHandleReady=handle=>{try{return handle.isCollapsed(),!0}catch{return!1}};export function usePanelDockedSlide({slot,defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize}){let{isVisible,state}=useLayout()[slot],theme=useTheme(),window=useWindow(),animation=usePanelAnimationControl(),reducedMotion=prefersReducedMotion(window),[isMounted,setIsMounted]=useState(isVisible),[phase,setPhase]=useState("idle"),[pinnedWidth,setPinnedWidth]=useState(null),[prevVisible,setPrevVisible]=useState(isVisible);return isVisible!==prevVisible&&(setPrevVisible(isVisible),setPhase(isVisible?"entering":"exiting"),isVisible&&setIsMounted(!0)),useDeclarePanel(slot,{defaultSize:"entering"===phase&&collapsible&&!reducedMotion?0:defaultSize,minSize,maxSize,collapsible,resizable,lockWidthOnWindowResize}),usePanelPresence(slot,isMounted),useLayoutEffect(()=>{if("idle"===phase)return;let cancelled=!1,frame=0,settleTimer=0,animatedColumns=[];animation?.setResizeSuppressed(slot,!0);let{duration,timingFunction}=theme.variables.animation.navSlide.open,durationMs=parseDurationMs(duration),setColumnTransitions=enabled=>{animatedColumns.forEach(column=>{enabled?column.style.setProperty("transition",`flex-grow ${duration} ${timingFunction}`):column.style.removeProperty("transition")})},targetSize=state.size??defaultSize??minSize,openColumn=(handle,targetPx)=>{handle.isCollapsed()&&handle.expand(),handle.resize(targetPx??targetSize??minSize??"20%")},settle=handle=>{if(setColumnTransitions(!1),animation?.setResizeSuppressed(slot,!1),"entering"===phase&&handle)try{handle.getSize().inPixels<1&&openColumn(handle,null)}catch{}setPinnedWidth(null),"exiting"===phase&&setIsMounted(!1),setPhase("idle")},runSlide=(handle,element)=>{animatedColumns=groupColumnsOf(element);let targetPx=resolveSizePx(targetSize,element.closest("[data-group]")?.getBoundingClientRect().width??null);setPinnedWidth("entering"===phase?targetPx:handle.getSize().inPixels),setColumnTransitions(!0),element.getBoundingClientRect();try{"entering"===phase?openColumn(handle,targetPx):handle.collapse()}catch{settle(handle);return}settleTimer=window.setTimeout(()=>settle(handle),durationMs+80)},waitForColumn=attempt=>{if(cancelled)return;let handle=animation?.getHandle(slot)??null,element=animation?.getElement(slot)??null;return handle&&element&&isHandleReady(handle)?void runSlide(handle,element):"exiting"===phase||!animation||attempt>=30?void settle(handle):void(frame=window.requestAnimationFrame(()=>waitForColumn(attempt+1)))};return!collapsible||reducedMotion?settle(animation?.getHandle(slot)??null):waitForColumn(0),()=>{cancelled=!0,window.cancelAnimationFrame(frame),window.clearTimeout(settleTimer),setColumnTransitions(!1),animation?.setResizeSuppressed(slot,!1)}},[phase,slot,collapsible,animation,window,theme]),{isMounted,pinnedWidth}}
|
|
@@ -6,5 +6,4 @@ export { getBaseButtonStyles } from "./Button/getBaseButtonStyles";
|
|
|
6
6
|
export { getPressedStyles } from "./Button/getPressedStyles";
|
|
7
7
|
export { getPillStyles } from "./Button/getPillStyles";
|
|
8
8
|
export { getFocusStyles } from "./getFocusStyles";
|
|
9
|
-
export { getLeftPanelFadeStyles } from "./getLeftPanelFadeStyles";
|
|
10
9
|
export { getPrimaryVariantStyles, getSecondaryVariantStyles, getTertiaryVariantStyles, } from "./Button/getVariantStyles";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{getInputTextPlaceholder}from"./TextInput/getInputTextPlaceholder";export{getInputTextStyles}from"./TextInput/getInputTextStyles";export{getDisabledStyles}from"./Button/getDisabledStyles";export{getButtonAppearanceReset}from"./Button/getButtonAppearanceReset";export{getBaseButtonStyles}from"./Button/getBaseButtonStyles";export{getPressedStyles}from"./Button/getPressedStyles";export{getPillStyles}from"./Button/getPillStyles";export{getFocusStyles}from"./getFocusStyles";export{
|
|
1
|
+
export{getInputTextPlaceholder}from"./TextInput/getInputTextPlaceholder";export{getInputTextStyles}from"./TextInput/getInputTextStyles";export{getDisabledStyles}from"./Button/getDisabledStyles";export{getButtonAppearanceReset}from"./Button/getButtonAppearanceReset";export{getBaseButtonStyles}from"./Button/getBaseButtonStyles";export{getPressedStyles}from"./Button/getPressedStyles";export{getPillStyles}from"./Button/getPillStyles";export{getFocusStyles}from"./getFocusStyles";export{getPrimaryVariantStyles,getSecondaryVariantStyles,getTertiaryVariantStyles}from"./Button/getVariantStyles";
|