@wallarm-org/design-system 4.6.0-rc-feat-claude-design.2 → 4.6.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/components/Drawer/DrawerBody.d.ts +5 -0
- package/dist/components/Drawer/DrawerBody.js +1 -1
- package/dist/components/Drawer/DrawerRoot.js +2 -0
- package/dist/components/Drawer/useNonModalFocusReturn.d.ts +10 -0
- package/dist/components/Drawer/useNonModalFocusReturn.js +63 -0
- package/dist/metadata/components.json +16 -2
- package/package.json +1 -1
|
@@ -3,4 +3,9 @@ export interface DrawerBodyProps {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
ref?: Ref<HTMLDivElement>;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* The drawer's vertically scrolling body. Its content must fit the drawer's width: a long value
|
|
8
|
+
* truncates, and anything genuinely wider (a chart, a fixed-width block) brings its own
|
|
9
|
+
* `overflow-x-auto` container — Table, CodeSnippet and CodeEditor already do.
|
|
10
|
+
*/
|
|
6
11
|
export declare const DrawerBody: FC<DrawerBodyProps>;
|
|
@@ -14,7 +14,7 @@ const DrawerBody = (t0)=>{
|
|
|
14
14
|
} else t1 = $[0];
|
|
15
15
|
let t2;
|
|
16
16
|
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
17
|
-
t2 = cn("flex flex-col px-24 min-h-full h-auto");
|
|
17
|
+
t2 = cn("flex flex-col px-24 min-h-full h-auto min-w-0!");
|
|
18
18
|
$[1] = t2;
|
|
19
19
|
} else t2 = $[1];
|
|
20
20
|
let t3;
|
|
@@ -3,6 +3,7 @@ import { c } from "react/compiler-runtime";
|
|
|
3
3
|
import { createContext, useContext } from "react";
|
|
4
4
|
import { Dialog } from "@ark-ui/react/dialog";
|
|
5
5
|
import { useDrawerContext } from "./DrawerContext/index.js";
|
|
6
|
+
import { useNonModalFocusReturn } from "./useNonModalFocusReturn.js";
|
|
6
7
|
const DrawerAncestorIdsContext = /*#__PURE__*/ createContext([]);
|
|
7
8
|
const EXITING_DIALOG_LAYER = '[data-scope="dialog"][data-part="content"][data-state="closed"]';
|
|
8
9
|
const keepOpenUnlessAncestorCloses = (ancestorIds)=>(event)=>{
|
|
@@ -18,6 +19,7 @@ const DrawerRoot = (t0)=>{
|
|
|
18
19
|
const { children, closeOnEscape, closeOnOutsideClick, modal, onInteractOutside, onEscapeKeyDown } = t0;
|
|
19
20
|
const { isOpen, onOpenChange, contentId } = useDrawerContext();
|
|
20
21
|
const ancestorIds = useContext(DrawerAncestorIdsContext);
|
|
22
|
+
useNonModalFocusReturn(isOpen, modal, contentId);
|
|
21
23
|
let t1;
|
|
22
24
|
if ($[0] !== onOpenChange) {
|
|
23
25
|
t1 = (t2)=>{
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zag returns focus on close only through the modal focus trap, so a non-modal drawer leaves focus
|
|
3
|
+
* on <body> once its focused content unmounts. While a non-modal drawer is open this tracks the page
|
|
4
|
+
* element that last opened it (a master-detail list retargets an open drawer from row to row) and,
|
|
5
|
+
* when the drawer closes, returns focus to that element without scrolling the page. It does so only
|
|
6
|
+
* if focus was lost with the drawer — on <body>, inside this drawer, or inside a layer that is
|
|
7
|
+
* closing with it. Focus the user has moved to another layer or control stays where it is, and a
|
|
8
|
+
* drawer closed by a pointer press on the page restores nothing: the user has moved on.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useNonModalFocusReturn: (isOpen: boolean, modal: boolean, contentId: string) => void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { useLayoutEffect } from "react";
|
|
3
|
+
const LAYER = '[data-part="positioner"], [data-scope="dialog"][data-part="content"]';
|
|
4
|
+
const EXITING_DIALOG_LAYER = '[data-scope="dialog"][data-part="content"][data-state="closed"]';
|
|
5
|
+
const isOnPage = (element)=>null === element.closest(LAYER);
|
|
6
|
+
const findTrigger = (contentId)=>Array.from(document.querySelectorAll('[data-scope="dialog"][data-part="trigger"]')).find((trigger)=>trigger.getAttribute("aria-controls") === contentId) ?? null;
|
|
7
|
+
const useNonModalFocusReturn = (isOpen, modal, contentId)=>{
|
|
8
|
+
const $ = c(7);
|
|
9
|
+
let t0;
|
|
10
|
+
if ($[0] !== contentId || $[1] !== isOpen || $[2] !== modal) {
|
|
11
|
+
t0 = ()=>{
|
|
12
|
+
if (!isOpen || modal) return;
|
|
13
|
+
const isInside = (node)=>node instanceof Node && document.getElementById(contentId)?.contains(node) === true;
|
|
14
|
+
const active = document.activeElement;
|
|
15
|
+
let target = active instanceof HTMLElement && active !== document.body && isOnPage(active) ? active : null;
|
|
16
|
+
let pressedOnPage = false;
|
|
17
|
+
const handleFocusIn = (event)=>{
|
|
18
|
+
const element = event.target;
|
|
19
|
+
if (element instanceof HTMLElement && !isInside(element) && isOnPage(element)) target = element;
|
|
20
|
+
};
|
|
21
|
+
const handlePointerDown = (event_0)=>{
|
|
22
|
+
const element_0 = event_0.target;
|
|
23
|
+
pressedOnPage = element_0 instanceof Element && !isInside(element_0) && isOnPage(element_0);
|
|
24
|
+
};
|
|
25
|
+
const handleKeyDown = ()=>{
|
|
26
|
+
pressedOnPage = false;
|
|
27
|
+
};
|
|
28
|
+
document.addEventListener("focusin", handleFocusIn, true);
|
|
29
|
+
document.addEventListener("pointerdown", handlePointerDown, true);
|
|
30
|
+
document.addEventListener("keydown", handleKeyDown, true);
|
|
31
|
+
return ()=>{
|
|
32
|
+
document.removeEventListener("focusin", handleFocusIn, true);
|
|
33
|
+
document.removeEventListener("pointerdown", handlePointerDown, true);
|
|
34
|
+
document.removeEventListener("keydown", handleKeyDown, true);
|
|
35
|
+
if (pressedOnPage) return;
|
|
36
|
+
queueMicrotask(()=>{
|
|
37
|
+
const focused = document.activeElement;
|
|
38
|
+
const lost = !focused || focused === document.body || isInside(focused) || null !== focused.closest(EXITING_DIALOG_LAYER);
|
|
39
|
+
const returnTo = target?.isConnected ? target : findTrigger(contentId);
|
|
40
|
+
if (lost && returnTo) returnTo.focus({
|
|
41
|
+
preventScroll: true
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
$[0] = contentId;
|
|
47
|
+
$[1] = isOpen;
|
|
48
|
+
$[2] = modal;
|
|
49
|
+
$[3] = t0;
|
|
50
|
+
} else t0 = $[3];
|
|
51
|
+
let t1;
|
|
52
|
+
if ($[4] !== contentId || $[5] !== isOpen) {
|
|
53
|
+
t1 = [
|
|
54
|
+
isOpen,
|
|
55
|
+
contentId
|
|
56
|
+
];
|
|
57
|
+
$[4] = contentId;
|
|
58
|
+
$[5] = isOpen;
|
|
59
|
+
$[6] = t1;
|
|
60
|
+
} else t1 = $[6];
|
|
61
|
+
useLayoutEffect(t0, t1);
|
|
62
|
+
};
|
|
63
|
+
export { useNonModalFocusReturn };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.
|
|
3
|
-
"generatedAt": "2026-11-
|
|
2
|
+
"version": "4.6.0",
|
|
3
|
+
"generatedAt": "2026-11-03T11:36:09.792Z",
|
|
4
4
|
"components": [
|
|
5
5
|
{
|
|
6
6
|
"name": "Accordion",
|
|
@@ -11851,6 +11851,13 @@
|
|
|
11851
11851
|
"storyTitle": "Overlay/Drawer",
|
|
11852
11852
|
"description": "Resizing with content that reflows, which is the case worth testing: the panel is only useful\nat its new width if what is inside adapts."
|
|
11853
11853
|
},
|
|
11854
|
+
{
|
|
11855
|
+
"name": "LongValues",
|
|
11856
|
+
"code": "import { Attribute, AttributeLabel, AttributeValue } from '@wallarm-org/design-system/Attribute';\nimport { Button } from '@wallarm-org/design-system/Button';\nimport { Drawer, DrawerBody, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger } from '@wallarm-org/design-system/Drawer';\nimport { Input } from '@wallarm-org/design-system/Input';\nimport { VStack } from '@wallarm-org/design-system/Stack';\nimport { Text } from '@wallarm-org/design-system/Text';\n\nexport const LongValues = () => (\n <Drawer data-testid='drawer'>\n <DrawerTrigger asChild>\n <Button variant='outline' color='neutral'>\n Open Drawer with Long Values\n </Button>\n </DrawerTrigger>\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>Long values</DrawerTitle>\n </DrawerHeader>\n <DrawerBody>\n <VStack gap={16}>\n <Attribute data-testid='url-attribute' orientation='horizontal'>\n <AttributeLabel width={120}>URL</AttributeLabel>\n <AttributeValue>\n <Text data-testid='url-text' size='sm' truncate>\n https://cdn.example.com/microfrontends/a-very-long-application-name/0.1.0-build.2469/mf-manifest.json\n </Text>\n </AttributeValue>\n </Attribute>\n <Input data-testid='notes-input' placeholder='Notes' />\n </VStack>\n </DrawerBody>\n </DrawerContent>\n </Drawer>\n);",
|
|
11857
|
+
"storyFile": "Drawer/Drawer.stories.tsx",
|
|
11858
|
+
"storyTitle": "Overlay/Drawer",
|
|
11859
|
+
"description": "A long value — a URL, an id — truncates inside the body instead of widening the drawer, so the\nfull-width field below it stays within the drawer too: the body never grows past the drawer's\nwidth. Content that is genuinely wider brings its own `overflow-x-auto` container."
|
|
11860
|
+
},
|
|
11854
11861
|
{
|
|
11855
11862
|
"name": "Scrollable",
|
|
11856
11863
|
"code": "import { Button } from '@wallarm-org/design-system/Button';\nimport { Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from '@wallarm-org/design-system/Drawer';\n\nexport const Scrollable = () => {\n return (\n <Drawer>\n <DrawerTrigger asChild>\n <Button variant='outline' color='neutral'>\n Open Drawer with Scroll\n </Button>\n </DrawerTrigger>\n\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>Scrollable Content</DrawerTitle>\n </DrawerHeader>\n\n <DrawerBody>\n <div className='flex flex-col gap-16 py-12'>\n {Array.from({ length: 20 }).map((_, i) => (\n <ContentPlaceholder key={i} height={100} />\n ))}\n </div>\n </DrawerBody>\n\n <DrawerFooter>\n <DrawerClose asChild>\n <Button variant='ghost' color='neutral' size='large'>\n Close\n </Button>\n </DrawerClose>\n <Button variant='primary' color='brand' size='large'>\n Confirm\n </Button>\n </DrawerFooter>\n </DrawerContent>\n </Drawer>\n );\n};",
|
|
@@ -11879,6 +11886,13 @@
|
|
|
11879
11886
|
"storyTitle": "Overlay/Drawer",
|
|
11880
11887
|
"description": "Without the backdrop, which is how a drawer reads as non-blocking. Pair it with\n`modal={false}` if the page behind should also stay usable."
|
|
11881
11888
|
},
|
|
11889
|
+
{
|
|
11890
|
+
"name": "NonModal",
|
|
11891
|
+
"code": "import { Button } from '@wallarm-org/design-system/Button';\nimport { Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerHeader, DrawerTitle, DrawerTrigger } from '@wallarm-org/design-system/Drawer';\nimport { VStack } from '@wallarm-org/design-system/Stack';\n\nexport const NonModal = () => (\n <VStack gap={16} align='start'>\n <Drawer data-testid='drawer' modal={false} overlay={false}>\n <DrawerTrigger asChild>\n <Button variant='outline' color='neutral'>\n Open Non-Modal Drawer\n </Button>\n </DrawerTrigger>\n\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>Non-modal drawer</DrawerTitle>\n <DrawerClose />\n </DrawerHeader>\n\n <DrawerBody>\n <div className='py-12'>\n <p>The page behind stays usable while this drawer is open.</p>\n </div>\n </DrawerBody>\n </DrawerContent>\n </Drawer>\n <ContentPlaceholder height={1600} />\n </VStack>\n);",
|
|
11892
|
+
"storyFile": "Drawer/Drawer.stories.tsx",
|
|
11893
|
+
"storyTitle": "Overlay/Drawer",
|
|
11894
|
+
"description": "`modal={false}` with no overlay keeps the page behind usable: scroll it, click it, keep typing.\nClosing returns focus to the trigger without scrolling the page back to it — unless the drawer\nwas closed by a click on the page, where the user has already moved on."
|
|
11895
|
+
},
|
|
11882
11896
|
{
|
|
11883
11897
|
"name": "WithNested",
|
|
11884
11898
|
"code": "import { Button } from '@wallarm-org/design-system/Button';\nimport { Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger } from '@wallarm-org/design-system/Drawer';\nimport { PanelRight } from '@wallarm-org/design-system/icons';\nimport { VStack } from '@wallarm-org/design-system/Stack';\nimport { Text } from '@wallarm-org/design-system/Text';\n\nexport const WithNested = () => {\n return (\n <Drawer>\n <DrawerTrigger asChild>\n <Button variant='outline' color='neutral'>\n 1st level drawer\n </Button>\n </DrawerTrigger>\n\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>[Level 1] Main Drawer</DrawerTitle>\n\n {/* Level 2 drawer */}\n <Drawer>\n <DrawerTrigger asChild>\n <Button variant='ghost' color='neutral' size='small'>\n <PanelRight />\n 2nd level drawer\n </Button>\n </DrawerTrigger>\n\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>[Level 2] Detail View</DrawerTitle>\n {/* Level 3 drawer */}\n <Drawer>\n <DrawerTrigger asChild>\n <Button variant='ghost' color='neutral' size='small'>\n <PanelRight />\n 3nd level drawer\n </Button>\n </DrawerTrigger>\n\n <DrawerContent>\n <DrawerHeader>\n <DrawerTitle>[Level 3] Deep Nested</DrawerTitle>\n </DrawerHeader>\n\n <DrawerBody>\n <VStack gap={12} align='start'>\n <Text>Level 3! Unlimited nesting works.</Text>\n <ContentPlaceholder height={150} />\n </VStack>\n </DrawerBody>\n\n <DrawerFooter>\n <DrawerClose asChild>\n <Button size='large' variant='ghost' color='neutral'>\n Back\n </Button>\n </DrawerClose>\n </DrawerFooter>\n </DrawerContent>\n </Drawer>\n </DrawerHeader>\n\n <DrawerBody>\n <VStack gap={12} align='start'>\n <Text>\n This is Level 2 drawer. Main drawer is pushed back. You can go deeper:\n </Text>\n\n <ContentPlaceholder height={150} />\n </VStack>\n </DrawerBody>\n\n <DrawerFooter>\n <DrawerClose asChild>\n <Button variant='ghost' color='neutral' size='large'>\n Back\n </Button>\n </DrawerClose>\n <Button variant='primary' color='brand' size='large'>\n Apply\n </Button>\n </DrawerFooter>\n </DrawerContent>\n </Drawer>\n </DrawerHeader>\n\n <DrawerBody>\n <VStack gap={12} align='start'>\n <Text>This is Level 1 drawer. Click below to open nested drawers:</Text>\n\n <ContentPlaceholder height={300} />\n </VStack>\n </DrawerBody>\n\n <DrawerFooter>\n <DrawerClose asChild>\n <Button variant='ghost' color='neutral' size='large'>\n Cancel\n </Button>\n </DrawerClose>\n <Button variant='primary' color='brand' size='large'>\n Save\n </Button>\n </DrawerFooter>\n </DrawerContent>\n </Drawer>\n );\n};",
|
package/package.json
CHANGED