@neo4j-ndl/react 4.9.25 → 4.9.27
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/lib/cjs/drawer/Drawer.js +16 -19
- package/lib/cjs/drawer/Drawer.js.map +1 -1
- package/lib/cjs/drawer/stories/drawer-overlay.story.js +4 -4
- package/lib/cjs/drawer/stories/drawer-overlay.story.js.map +1 -1
- package/lib/cjs/drawer/stories/drawer-portaled.story.js +6 -4
- package/lib/cjs/drawer/stories/drawer-portaled.story.js.map +1 -1
- package/lib/esm/drawer/Drawer.js +18 -21
- package/lib/esm/drawer/Drawer.js.map +1 -1
- package/lib/esm/drawer/stories/drawer-overlay.story.js +5 -5
- package/lib/esm/drawer/stories/drawer-overlay.story.js.map +1 -1
- package/lib/esm/drawer/stories/drawer-portaled.story.js +6 -4
- package/lib/esm/drawer/stories/drawer-portaled.story.js.map +1 -1
- package/lib/types/drawer/Drawer.d.ts +4 -6
- package/lib/types/drawer/Drawer.d.ts.map +1 -1
- package/package.json +2 -2
package/lib/cjs/drawer/Drawer.js
CHANGED
|
@@ -78,7 +78,7 @@ function DrawerResizeHandle({ handleSide, onResizeBy, valueMax, valueMin, valueN
|
|
|
78
78
|
tabIndex: 0 }));
|
|
79
79
|
}
|
|
80
80
|
const DrawerComponent = function DrawerComponent(_a) {
|
|
81
|
-
var { children, className = '', isExpanded, onExpandedChange, position = 'left', type = 'overlay', isResizeable = false, resizeableProps, isCloseable = true, isPortaled = false, portalProps = {}, closeOnEscape = type === 'modal' ? true : false, closeOnClickOutside = false,
|
|
81
|
+
var { children, className = '', isExpanded, onExpandedChange, position = 'left', type = 'overlay', isResizeable = false, resizeableProps, isCloseable = true, isPortaled = false, portalProps = {}, closeOnEscape = type === 'modal' ? true : false, closeOnClickOutside = false, ariaLabel, htmlAttributes, style, ref, as } = _a, restProps = __rest(_a, ["children", "className", "isExpanded", "onExpandedChange", "position", "type", "isResizeable", "resizeableProps", "isCloseable", "isPortaled", "portalProps", "closeOnEscape", "closeOnClickOutside", "ariaLabel", "htmlAttributes", "style", "ref", "as"]);
|
|
82
82
|
const resizableRef = (0, react_2.useRef)(null);
|
|
83
83
|
const [resizeWidth, setResizeWidth] = (0, react_2.useState)(0);
|
|
84
84
|
if ((type === 'modal' || type === 'overlay') && !ariaLabel) {
|
|
@@ -94,8 +94,8 @@ const DrawerComponent = function DrawerComponent(_a) {
|
|
|
94
94
|
(type === 'overlay' && isPortaled);
|
|
95
95
|
const dismiss = (0, react_1.useDismiss)(context, {
|
|
96
96
|
enabled: shouldUseDismiss,
|
|
97
|
-
escapeKey: closeOnEscape,
|
|
98
|
-
outsidePress: closeOnClickOutside,
|
|
97
|
+
escapeKey: closeOnEscape && type !== 'push',
|
|
98
|
+
outsidePress: closeOnClickOutside && type !== 'push',
|
|
99
99
|
});
|
|
100
100
|
const role = (0, react_1.useRole)(context, {
|
|
101
101
|
enabled: type === 'modal' || type === 'overlay',
|
|
@@ -131,10 +131,8 @@ const DrawerComponent = function DrawerComponent(_a) {
|
|
|
131
131
|
setResizeWidth(width);
|
|
132
132
|
}
|
|
133
133
|
}, [isResizeable]);
|
|
134
|
-
const setOnExpandedChange = (0, react_2.useCallback)(() => {
|
|
135
|
-
onExpandedChange === null || onExpandedChange === void 0 ? void 0 : onExpandedChange(!isExpanded);
|
|
136
|
-
}, [isExpanded, onExpandedChange]);
|
|
137
134
|
const classes = (0, classnames_1.default)('ndl-drawer', className, {
|
|
135
|
+
'ndl-drawer-expanded': isExpanded,
|
|
138
136
|
'ndl-drawer-left': position === 'left',
|
|
139
137
|
'ndl-drawer-modal': type === 'modal',
|
|
140
138
|
'ndl-drawer-overlay': type === 'overlay',
|
|
@@ -144,9 +142,12 @@ const DrawerComponent = function DrawerComponent(_a) {
|
|
|
144
142
|
});
|
|
145
143
|
const resizableStylePosition = type === 'overlay' ? 'absolute' : 'relative';
|
|
146
144
|
const Component = as !== null && as !== void 0 ? as : 'div';
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
const handleClose = (0, react_2.useCallback)(() => {
|
|
146
|
+
onExpandedChange === null || onExpandedChange === void 0 ? void 0 : onExpandedChange(false);
|
|
147
|
+
}, [onExpandedChange]);
|
|
148
|
+
const closeButton = (0, react_2.useMemo)(() => isCloseable || type === 'modal' ? ((0, jsx_runtime_1.jsx)(clean_icon_button_1.CleanIconButton, { className: "ndl-drawer-close-button", onClick: handleClose, description: null, size: "medium", htmlAttributes: {
|
|
149
|
+
'aria-label': 'Close',
|
|
150
|
+
}, children: (0, jsx_runtime_1.jsx)(icons_1.XMarkIconOutline, {}) })) : null, [handleClose, isCloseable, type]);
|
|
150
151
|
const resizableContent = ((0, jsx_runtime_1.jsxs)(re_resizable_1.Resizable, Object.assign({ as: Component, defaultSize: {
|
|
151
152
|
height: '100%',
|
|
152
153
|
width: 'auto',
|
|
@@ -165,20 +166,16 @@ const DrawerComponent = function DrawerComponent(_a) {
|
|
|
165
166
|
}
|
|
166
167
|
: {
|
|
167
168
|
left: ((0, jsx_runtime_1.jsx)(DrawerResizeHandle, { handleSide: "left", onResizeBy: handleResizeBy, valueMax: parsePixelSize(resizeableProps === null || resizeableProps === void 0 ? void 0 : resizeableProps.maxWidth), valueMin: parsePixelSize(resizeableProps === null || resizeableProps === void 0 ? void 0 : resizeableProps.minWidth), valueNow: resizeWidth })),
|
|
168
|
-
}, onResize: handleResize, ref: resizableMergedRef }, restProps, htmlAttributes, { children: [
|
|
169
|
-
const regularContent = ((0, jsx_runtime_1.jsxs)(Component, Object.assign({ className: (0, classnames_1.default)(classes), style: style, ref: ref }, restProps, htmlAttributes, { children: [
|
|
169
|
+
}, onResize: handleResize, ref: resizableMergedRef }, restProps, htmlAttributes, { children: [closeButton, children] })));
|
|
170
|
+
const regularContent = ((0, jsx_runtime_1.jsxs)(Component, Object.assign({ className: (0, classnames_1.default)(classes), style: style, ref: ref }, restProps, htmlAttributes, { children: [closeButton, children] })));
|
|
170
171
|
/** what content to render*/
|
|
171
172
|
const content = isResizeable ? resizableContent : regularContent;
|
|
172
|
-
const floatingRefs =
|
|
173
|
-
/** if the drawer is not expanded, don't render anything */
|
|
174
|
-
if (isExpanded === false) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
173
|
+
// const floatingRefs = useMergeRefs([refs.setFloating, refs.setReference]);
|
|
177
174
|
/** modal behavior */
|
|
178
|
-
if (type === 'modal') {
|
|
179
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.FloatingPortal, Object.assign({}, portalProps, { children: [(0, jsx_runtime_1.jsx)(react_1.FloatingOverlay, { className: "ndl-drawer-overlay-root", lockScroll: true }), (0, jsx_runtime_1.jsx)(react_1.FloatingFocusManager, { context: context, modal: true, returnFocus: true, children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { "aria-label": ariaLabel, "aria-modal": "true", children: content })) })] })));
|
|
175
|
+
if (type === 'modal' && isExpanded) {
|
|
176
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.FloatingPortal, Object.assign({}, portalProps, { children: [(0, jsx_runtime_1.jsx)(react_1.FloatingOverlay, { className: "ndl-drawer-overlay-root", lockScroll: true }), (0, jsx_runtime_1.jsx)(react_1.FloatingFocusManager, { disabled: !isExpanded, context: context, modal: true, returnFocus: true, initialFocus: 0, children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { "aria-label": ariaLabel, "aria-modal": "true", children: content })) })] })));
|
|
180
177
|
}
|
|
181
|
-
return ((0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: isPortaled && type === 'overlay', wrap: (wrapChildren) => ((0, jsx_runtime_1.jsx)(react_1.FloatingPortal, Object.assign({ preserveTabOrder: true }, portalProps, { children: wrapChildren }))), children: (0, jsx_runtime_1.jsx)(react_1.FloatingFocusManager, { disabled: !isExpanded || type === 'push', context: context, modal:
|
|
178
|
+
return ((0, jsx_runtime_1.jsx)(conditional_wrap_1.ConditionalWrap, { shouldWrap: isPortaled && type === 'overlay' && isExpanded, wrap: (wrapChildren) => ((0, jsx_runtime_1.jsx)(react_1.FloatingPortal, Object.assign({ preserveTabOrder: true }, portalProps, { children: wrapChildren }))), children: (0, jsx_runtime_1.jsx)(react_1.FloatingFocusManager, { disabled: !isExpanded || type === 'push', context: context, modal: true, initialFocus: 0, children: (0, jsx_runtime_1.jsx)("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { "aria-label": ariaLabel, children: content })) }) }));
|
|
182
179
|
};
|
|
183
180
|
DrawerComponent.displayName = 'Drawer';
|
|
184
181
|
const DrawerHeader = (_a) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/drawer/Drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAS4B;AAC5B,4DAAoC;AACpC,+CAA8D;AAE9D,iCAMe;AAMf,4CAAwD;AACxD,4DAAuD;AACvD,0DAAsD;AACtD,oCAA4C;AAC5C,8CAA2C;AA8E3C,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,SAAS,cAAc,CACrB,KAAkC;IAElC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AACnD,CAAC;AAgBD,SAAS,kBAAkB,CAAC,EAC1B,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,E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AM","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useDismiss,\n useFloating,\n useInteractions,\n useMergeRefs,\n useRole,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { Resizable, type ResizableProps } from 're-resizable';\nimport type React from 'react';\nimport {\n type ComponentProps,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { needleWarningMessage } from '../_common/utils';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { XMarkIconOutline } from '../icons';\nimport { Typography } from '../typography';\n\ntype DrawerPosition = 'left' | 'right';\n\ntype DrawerType = 'overlay' | 'push' | 'modal';\n\ntype DrawerProps = {\n /** Controls whether the drawer is open (expanded) or closed (collapsed). */\n isExpanded: boolean;\n\n /** Callback fired when the drawer's expanded state changes (close button, Escape, click outside, or programmatic change). */\n onExpandedChange?: (expanded: boolean) => void;\n\n /** Position where the drawer appears on screen. By default, it appears from the left. */\n position?: DrawerPosition;\n\n /** How the drawer affects the layout of sibling content. By default, it overlays content. */\n type?: DrawerType;\n\n /** Enables horizontal resizing of the drawer, by default it is not resizable. */\n isResizeable?: boolean;\n\n /** To use this prop the isResizeable prop must be set to true. For overriding the third party library props: https://github.com/bokuweb/re-resizable */\n resizeableProps?: ResizableProps;\n\n /** Whether a close button (X) is displayed in the drawer. */\n isCloseable?: boolean;\n\n /** Whether to portal the content. Only applies when type is \"overlay\". Type \"modal\" is always portaled.*/\n isPortaled?: boolean;\n\n // TODO v5: this should maybe be default on portaled in the future\n /**\n * Whether pressing Escape closes the drawer.\n * - When type is \"modal\", this defaults to true.\n * - When type is \"overlay\", this defaults to false.\n * - When type is \"push\", no effect.\n */\n closeOnEscape?: boolean;\n\n // TODO v5: this should maybe be default on overlay in the future\n /**\n * When type is \"overlay\", whether clicking outside the drawer closes it.\n * - When type is \"overlay\" or \"modal\", this defaults to false.\n * - When type is \"push\", no effect.\n */\n closeOnClickOutside?: boolean;\n\n // TODO v5: this should maybe be default on overlay in the future\n /**\n * Whether tabbing focus outside the drawer closes it.\n * - When type is \"overlay\", this defaults to false.\n * - When type is \"push\" or \"modal\", no effect.\n */\n closeOnFocusOut?: boolean;\n\n /** The content to display within the drawer. */\n children: React.ReactNode;\n\n /**\n * Props to pass to the portal from @floating-ui/react FloatingPortal\n * Only applies when type is \"overlay\" and isPortaled is true, or if type is \"modal\".\n * @see https://floating-ui.com/docs/floatingportal\n */\n portalProps?: ComponentProps<typeof FloatingPortal>;\n} & (\n | {\n type: 'modal';\n /** The aria-label to apply to the drawer. Required for accessibility when type is \"modal\" or \"overlay\".*/\n ariaLabel: string;\n }\n | {\n type?: 'push' | 'overlay';\n // TODO v5: aria label should be required when type is \"overlay\" too.\n ariaLabel?: string;\n }\n);\n\nconst KEYBOARD_RESIZE_STEP_PX = 16;\n\nfunction parsePixelSize(\n value: string | number | undefined,\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === 'number') {\n return value;\n }\n const parsed = parseInt(value.replace(/px$/i, ''), 10);\n return Number.isNaN(parsed) ? undefined : parsed;\n}\n\ntype DrawerResizeHandleProps = {\n /** Which edge this handle resizes (right = drawer’s right edge, left = drawer’s left edge). */\n handleSide: 'left' | 'right';\n /** Called with a pixel delta to apply to the drawer width (positive = wider). */\n onResizeBy: (delta: number) => void;\n onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;\n /** Current width in pixels (for aria-valuenow). */\n valueNow?: number;\n /** Minimum width in pixels (for aria-valuemin). */\n valueMin?: number;\n /** Maximum width in pixels (for aria-valuemax). */\n valueMax?: number;\n};\n\nfunction DrawerResizeHandle({\n handleSide,\n onResizeBy,\n valueMax,\n valueMin,\n valueNow,\n}: DrawerResizeHandleProps) {\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const isArrowKey = e.key === 'ArrowLeft' || e.key === 'ArrowRight';\n if (isArrowKey) {\n e.preventDefault();\n const delta =\n handleSide === 'right'\n ? e.key === 'ArrowRight'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX\n : e.key === 'ArrowLeft'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX;\n onResizeBy(delta);\n }\n },\n [handleSide, onResizeBy],\n );\n\n return (\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- Resize handle is focusable for keyboard resize. */\n <div\n aria-label={`Resize drawer with arrow keys. Handle on ${handleSide}.`}\n aria-orientation=\"vertical\"\n aria-valuemax={valueMax}\n aria-valuemin={valueMin}\n aria-valuenow={valueNow ?? 0}\n aria-valuetext={`drawer width ${valueNow ?? 0}px`}\n className=\"ndl-drawer-resize-handle\"\n data-drawer-handle={handleSide}\n onKeyDown={handleKeyDown}\n role=\"separator\"\n style={{ height: '100%', width: '100%' }}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- Resize handle is focusable for keyboard resize.\n tabIndex={0}\n />\n );\n}\n\nconst DrawerComponent = function DrawerComponent<\n T extends React.ElementType = 'div',\n>({\n children,\n className = '',\n isExpanded,\n onExpandedChange,\n position = 'left',\n type = 'overlay',\n isResizeable = false,\n resizeableProps,\n isCloseable = true,\n isPortaled = false,\n portalProps = {},\n closeOnEscape = type === 'modal' ? true : false,\n closeOnClickOutside = false,\n closeOnFocusOut = false,\n ariaLabel,\n htmlAttributes,\n style,\n ref,\n as,\n ...restProps\n}: PolymorphicCommonProps<T, DrawerProps>) {\n const resizableRef = useRef<Resizable | null>(null);\n const [resizeWidth, setResizeWidth] = useState<number>(0);\n\n if ((type === 'modal' || type === 'overlay') && !ariaLabel) {\n needleWarningMessage(\n 'A Drawer should have an aria-label when type is \"modal\" or \"overlay\" to be accessible.',\n );\n }\n\n const { refs, context } = useFloating({\n onOpenChange: onExpandedChange,\n open: isExpanded,\n });\n\n /** Dismiss (escape + click outside) applies to portaled overlay and to non-portaled overlay. */\n const shouldUseDismiss =\n type === 'modal' ||\n (type === 'overlay' && !isPortaled && isExpanded) ||\n (type === 'overlay' && isPortaled);\n\n const dismiss = useDismiss(context, {\n enabled: shouldUseDismiss,\n escapeKey: closeOnEscape,\n outsidePress: closeOnClickOutside,\n });\n const role = useRole(context, {\n enabled: type === 'modal' || type === 'overlay',\n role: 'dialog',\n });\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n const resizableMergedRef = useMergeRefs([resizableRef, ref]);\n\n const handleResizeBy = useCallback(\n (delta: number) => {\n if (!resizableRef.current) {\n return;\n }\n const current = resizableRef.current.size;\n const min = parsePixelSize(resizeableProps?.minWidth);\n const max = parsePixelSize(resizeableProps?.maxWidth);\n const newWidth = Math.max(\n min ?? 0,\n Math.min(max ?? Number.POSITIVE_INFINITY, current.width + delta),\n );\n resizableRef.current.updateSize({\n height: '100%',\n width: newWidth,\n });\n setResizeWidth(newWidth);\n },\n [resizeableProps?.minWidth, resizeableProps?.maxWidth],\n );\n\n const handleResize = useCallback(\n (\n event: MouseEvent | TouchEvent,\n direction: Parameters<NonNullable<ResizableProps['onResize']>>[1],\n elementRef: HTMLElement,\n delta: { width: number; height: number },\n ) => {\n setResizeWidth(elementRef.offsetWidth);\n resizeableProps?.onResize?.(event, direction, elementRef, delta);\n },\n [resizeableProps],\n );\n\n useEffect(() => {\n if (!isResizeable || !resizableRef.current) {\n return;\n }\n const width = resizableRef.current.size.width;\n if (width > 0) {\n setResizeWidth(width);\n }\n }, [isResizeable]);\n\n const setOnExpandedChange = useCallback(() => {\n onExpandedChange?.(!isExpanded);\n }, [isExpanded, onExpandedChange]);\n\n const classes = classNames('ndl-drawer', className, {\n 'ndl-drawer-left': position === 'left',\n 'ndl-drawer-modal': type === 'modal',\n 'ndl-drawer-overlay': type === 'overlay',\n 'ndl-drawer-portaled': isPortaled && type === 'overlay',\n 'ndl-drawer-push': type === 'push',\n 'ndl-drawer-right': position === 'right',\n });\n\n const resizableStylePosition = type === 'overlay' ? 'absolute' : 'relative';\n const Component = as ?? 'div';\n\n const Close = () => (\n <>\n {(isCloseable || type === 'modal') && (\n <CleanIconButton\n className=\"ndl-drawer-close-button\"\n onClick={setOnExpandedChange}\n description={null}\n size=\"medium\"\n htmlAttributes={{\n 'aria-label': 'Close',\n }}\n >\n <XMarkIconOutline />\n </CleanIconButton>\n )}\n </>\n );\n\n const resizableContent = (\n <Resizable\n as={Component}\n defaultSize={{\n height: '100%',\n width: 'auto',\n }}\n {...resizeableProps}\n className={classes}\n style={{\n position: resizableStylePosition,\n ...style,\n ...resizeableProps?.style,\n }}\n boundsByDirection={true}\n bounds=\"parent\"\n handleStyles={{\n /*\n * Small offset so the handle is easier to hit when the drawer content is scrollable.\n */\n ...(position === 'left' && { right: { right: '-8px' } }),\n ...(position === 'right' && { left: { left: '-8px' } }),\n }}\n enable={{\n bottom: false,\n bottomLeft: false,\n bottomRight: false,\n left: position === 'right',\n right: position === 'left',\n top: false,\n topLeft: false,\n topRight: false,\n }}\n handleComponent={\n position === 'left'\n ? {\n right: (\n <DrawerResizeHandle\n handleSide=\"right\"\n onResizeBy={handleResizeBy}\n valueMax={parsePixelSize(resizeableProps?.maxWidth)}\n valueMin={parsePixelSize(resizeableProps?.minWidth)}\n valueNow={resizeWidth}\n />\n ),\n }\n : {\n left: (\n <DrawerResizeHandle\n handleSide=\"left\"\n onResizeBy={handleResizeBy}\n valueMax={parsePixelSize(resizeableProps?.maxWidth)}\n valueMin={parsePixelSize(resizeableProps?.minWidth)}\n valueNow={resizeWidth}\n />\n ),\n }\n }\n onResize={handleResize}\n ref={resizableMergedRef}\n {...restProps}\n {...htmlAttributes}\n >\n <Close />\n {children}\n </Resizable>\n );\n\n const regularContent = (\n <Component\n className={classNames(classes)}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <Close />\n {children}\n </Component>\n );\n\n /** what content to render*/\n const content = isResizeable ? resizableContent : regularContent;\n\n const floatingRefs = useMergeRefs([refs.setFloating, refs.setReference]);\n\n /** if the drawer is not expanded, don't render anything */\n if (isExpanded === false) {\n return null;\n }\n\n /** modal behavior */\n if (type === 'modal') {\n return (\n <FloatingPortal {...portalProps}>\n <FloatingOverlay\n className=\"ndl-drawer-overlay-root\"\n lockScroll={true}\n />\n <FloatingFocusManager context={context} modal={true} returnFocus={true}>\n <div\n ref={refs.setFloating}\n {...getFloatingProps()}\n aria-label={ariaLabel}\n aria-modal=\"true\"\n >\n {content}\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={isPortaled && type === 'overlay'}\n wrap={(wrapChildren) => (\n <FloatingPortal preserveTabOrder={true} {...portalProps}>\n {wrapChildren}\n </FloatingPortal>\n )}\n >\n <FloatingFocusManager\n disabled={!isExpanded || type === 'push'}\n context={context}\n modal={false}\n returnFocus={true}\n closeOnFocusOut={closeOnFocusOut}\n >\n <ConditionalWrap\n shouldWrap={type === 'overlay'}\n wrap={(wrapChildren) => (\n <div\n ref={floatingRefs}\n {...getFloatingProps()}\n aria-label={ariaLabel}\n >\n {wrapChildren}\n </div>\n )}\n >\n {content}\n </ConditionalWrap>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\nDrawerComponent.displayName = 'Drawer';\n\ntype DrawerHeaderProps = {\n children: React.ReactNode;\n className?: string;\n // TODO v5: fix the typing on the Drawer subcomponents to use the common props type. Also, this is not an h5 haha. Should be polymorphic I guess, maybe default to h2 as we've recommended.\n htmlAttributes?: HtmlAttributes<'h5'>;\n};\n\nconst DrawerHeader = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerHeaderProps) => {\n const classes = classNames('ndl-drawer-header', className);\n\n if (typeof children === 'string' || typeof children === 'number') {\n return (\n <Typography\n className={classes}\n variant=\"title-3\"\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n }\n\n return (\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n );\n};\n\ntype DrawerActionsProps = {\n children: React.ReactNode;\n className?: string;\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst DrawerActions = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerActionsProps) => {\n const classes = classNames('ndl-drawer-actions', className);\n\n return (\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n );\n};\n\ntype DrawerBodyProps = {\n children: React.ReactNode;\n className?: string;\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst DrawerBody = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerBodyProps) => {\n const classes = classNames('ndl-drawer-body', className);\n\n return (\n <div className=\"ndl-drawer-body-wrapper\">\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n </div>\n );\n};\n\nconst Drawer = Object.assign(DrawerComponent, {\n Actions: DrawerActions,\n Body: DrawerBody,\n Header: DrawerHeader,\n});\n\nexport { Drawer };\n"]}
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/drawer/Drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8CAS4B;AAC5B,4DAAoC;AACpC,+CAA8D;AAE9D,iCAOe;AAMf,4CAAwD;AACxD,4DAAuD;AACvD,0DAAsD;AACtD,oCAA4C;AAC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O,GAAG,IAAA,oBAAU,EAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;IAEzD,OAAO,CACL,gCAAK,SAAS,EAAC,yBAAyB,YACtC,8CAAK,SAAS,EAAE,OAAO,IAAM,SAAS,EAAM,cAAc,cACvD,QAAQ,IACL,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IAC5C,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;CACrB,CAAC,CAAC;AAEM,wBAAM","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useDismiss,\n useFloating,\n useInteractions,\n useMergeRefs,\n useRole,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { Resizable, type ResizableProps } from 're-resizable';\nimport type React from 'react';\nimport {\n type ComponentProps,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { needleWarningMessage } from '../_common/utils';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { XMarkIconOutline } from '../icons';\nimport { Typography } from '../typography';\n\ntype DrawerPosition = 'left' | 'right';\n\ntype DrawerType = 'overlay' | 'push' | 'modal';\n\ntype DrawerProps = {\n /** Controls whether the drawer is open (expanded) or closed (collapsed). */\n isExpanded: boolean;\n\n /** Callback fired when the drawer's expanded state changes (close button, Escape, click outside, or programmatic change). */\n onExpandedChange?: (expanded: boolean) => void;\n\n /** Position where the drawer appears on screen. By default, it appears from the left. */\n position?: DrawerPosition;\n\n /** How the drawer affects the layout of sibling content. By default, it overlays content. */\n type?: DrawerType;\n\n /** Enables horizontal resizing of the drawer, by default it is not resizable. */\n isResizeable?: boolean;\n\n /** To use this prop the isResizeable prop must be set to true. For overriding the third party library props: https://github.com/bokuweb/re-resizable */\n resizeableProps?: ResizableProps;\n\n /** Whether a close button (X) is displayed in the drawer. */\n isCloseable?: boolean;\n\n /** Whether to portal the content. Only applies when type is \"overlay\". Type \"modal\" is always portaled.*/\n isPortaled?: boolean;\n\n // TODO v5: this should maybe be default on portaled in the future\n /**\n * Whether pressing Escape closes the drawer. Should be set to true for overlay drawers.\n * - When type is \"modal\", this defaults to true.\n * - When type is \"overlay\", this defaults to false.\n * - When type is \"push\", no effect.\n */\n closeOnEscape?: boolean;\n\n // TODO v5: this should maybe be default on overlay in the future\n /**\n * When type is \"overlay\", whether clicking outside the drawer closes it. Should be set to true for overlay drawers.\n * - When type is \"overlay\" or \"modal\", this defaults to false.\n * - When type is \"push\", no effect.\n */\n closeOnClickOutside?: boolean;\n\n // TODO v5: remove this prop\n /**\n * @deprecated overlay are now focus trapped by default, this prop has no effect anymore.\n */\n closeOnFocusOut?: boolean;\n\n /** The content to display within the drawer. */\n children: React.ReactNode;\n\n /**\n * Props to pass to the portal from @floating-ui/react FloatingPortal\n * Only applies when type is \"overlay\" and isPortaled is true, or if type is \"modal\".\n * @see https://floating-ui.com/docs/floatingportal\n */\n portalProps?: ComponentProps<typeof FloatingPortal>;\n} & (\n | {\n type: 'modal';\n /** The aria-label to apply to the drawer. Required for accessibility when type is \"modal\" or \"overlay\".*/\n ariaLabel: string;\n }\n | {\n type?: 'push' | 'overlay';\n // TODO v5: aria label should be required when type is \"overlay\" too.\n ariaLabel?: string;\n }\n);\n\nconst KEYBOARD_RESIZE_STEP_PX = 16;\n\nfunction parsePixelSize(\n value: string | number | undefined,\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === 'number') {\n return value;\n }\n const parsed = parseInt(value.replace(/px$/i, ''), 10);\n return Number.isNaN(parsed) ? undefined : parsed;\n}\n\ntype DrawerResizeHandleProps = {\n /** Which edge this handle resizes (right = drawer’s right edge, left = drawer’s left edge). */\n handleSide: 'left' | 'right';\n /** Called with a pixel delta to apply to the drawer width (positive = wider). */\n onResizeBy: (delta: number) => void;\n onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;\n /** Current width in pixels (for aria-valuenow). */\n valueNow?: number;\n /** Minimum width in pixels (for aria-valuemin). */\n valueMin?: number;\n /** Maximum width in pixels (for aria-valuemax). */\n valueMax?: number;\n};\n\nfunction DrawerResizeHandle({\n handleSide,\n onResizeBy,\n valueMax,\n valueMin,\n valueNow,\n}: DrawerResizeHandleProps) {\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const isArrowKey = e.key === 'ArrowLeft' || e.key === 'ArrowRight';\n if (isArrowKey) {\n e.preventDefault();\n const delta =\n handleSide === 'right'\n ? e.key === 'ArrowRight'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX\n : e.key === 'ArrowLeft'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX;\n onResizeBy(delta);\n }\n },\n [handleSide, onResizeBy],\n );\n\n return (\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- Resize handle is focusable for keyboard resize. */\n <div\n aria-label={`Resize drawer with arrow keys. Handle on ${handleSide}.`}\n aria-orientation=\"vertical\"\n aria-valuemax={valueMax}\n aria-valuemin={valueMin}\n aria-valuenow={valueNow ?? 0}\n aria-valuetext={`drawer width ${valueNow ?? 0}px`}\n className=\"ndl-drawer-resize-handle\"\n data-drawer-handle={handleSide}\n onKeyDown={handleKeyDown}\n role=\"separator\"\n style={{ height: '100%', width: '100%' }}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- Resize handle is focusable for keyboard resize.\n tabIndex={0}\n />\n );\n}\n\nconst DrawerComponent = function DrawerComponent<\n T extends React.ElementType = 'div',\n>({\n children,\n className = '',\n isExpanded,\n onExpandedChange,\n position = 'left',\n type = 'overlay',\n isResizeable = false,\n resizeableProps,\n isCloseable = true,\n isPortaled = false,\n portalProps = {},\n closeOnEscape = type === 'modal' ? true : false,\n closeOnClickOutside = false,\n ariaLabel,\n htmlAttributes,\n style,\n ref,\n as,\n ...restProps\n}: PolymorphicCommonProps<T, DrawerProps>) {\n const resizableRef = useRef<Resizable | null>(null);\n const [resizeWidth, setResizeWidth] = useState<number>(0);\n\n if ((type === 'modal' || type === 'overlay') && !ariaLabel) {\n needleWarningMessage(\n 'A Drawer should have an aria-label when type is \"modal\" or \"overlay\" to be accessible.',\n );\n }\n\n const { refs, context } = useFloating({\n onOpenChange: onExpandedChange,\n open: isExpanded,\n });\n\n /** Dismiss (escape + click outside) applies to portaled overlay and to non-portaled overlay. */\n const shouldUseDismiss =\n type === 'modal' ||\n (type === 'overlay' && !isPortaled && isExpanded) ||\n (type === 'overlay' && isPortaled);\n\n const dismiss = useDismiss(context, {\n enabled: shouldUseDismiss,\n escapeKey: closeOnEscape && type !== 'push',\n outsidePress: closeOnClickOutside && type !== 'push',\n });\n const role = useRole(context, {\n enabled: type === 'modal' || type === 'overlay',\n role: 'dialog',\n });\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n const resizableMergedRef = useMergeRefs([resizableRef, ref]);\n\n const handleResizeBy = useCallback(\n (delta: number) => {\n if (!resizableRef.current) {\n return;\n }\n const current = resizableRef.current.size;\n const min = parsePixelSize(resizeableProps?.minWidth);\n const max = parsePixelSize(resizeableProps?.maxWidth);\n const newWidth = Math.max(\n min ?? 0,\n Math.min(max ?? Number.POSITIVE_INFINITY, current.width + delta),\n );\n resizableRef.current.updateSize({\n height: '100%',\n width: newWidth,\n });\n setResizeWidth(newWidth);\n },\n [resizeableProps?.minWidth, resizeableProps?.maxWidth],\n );\n\n const handleResize = useCallback(\n (\n event: MouseEvent | TouchEvent,\n direction: Parameters<NonNullable<ResizableProps['onResize']>>[1],\n elementRef: HTMLElement,\n delta: { width: number; height: number },\n ) => {\n setResizeWidth(elementRef.offsetWidth);\n resizeableProps?.onResize?.(event, direction, elementRef, delta);\n },\n [resizeableProps],\n );\n\n useEffect(() => {\n if (!isResizeable || !resizableRef.current) {\n return;\n }\n const width = resizableRef.current.size.width;\n if (width > 0) {\n setResizeWidth(width);\n }\n }, [isResizeable]);\n\n const classes = classNames('ndl-drawer', className, {\n 'ndl-drawer-expanded': isExpanded,\n 'ndl-drawer-left': position === 'left',\n 'ndl-drawer-modal': type === 'modal',\n 'ndl-drawer-overlay': type === 'overlay',\n 'ndl-drawer-portaled': isPortaled && type === 'overlay',\n 'ndl-drawer-push': type === 'push',\n 'ndl-drawer-right': position === 'right',\n });\n\n const resizableStylePosition = type === 'overlay' ? 'absolute' : 'relative';\n const Component = as ?? 'div';\n\n const handleClose = useCallback(() => {\n onExpandedChange?.(false);\n }, [onExpandedChange]);\n\n const closeButton = useMemo(\n () =>\n isCloseable || type === 'modal' ? (\n <CleanIconButton\n className=\"ndl-drawer-close-button\"\n onClick={handleClose}\n description={null}\n size=\"medium\"\n htmlAttributes={{\n 'aria-label': 'Close',\n }}\n >\n <XMarkIconOutline />\n </CleanIconButton>\n ) : null,\n [handleClose, isCloseable, type],\n );\n\n const resizableContent = (\n <Resizable\n as={Component}\n defaultSize={{\n height: '100%',\n width: 'auto',\n }}\n {...resizeableProps}\n className={classes}\n style={{\n position: resizableStylePosition,\n ...style,\n ...resizeableProps?.style,\n }}\n boundsByDirection={true}\n bounds=\"parent\"\n handleStyles={{\n /*\n * Small offset so the handle is easier to hit when the drawer content is scrollable.\n */\n ...(position === 'left' && { right: { right: '-8px' } }),\n ...(position === 'right' && { left: { left: '-8px' } }),\n }}\n enable={{\n bottom: false,\n bottomLeft: false,\n bottomRight: false,\n left: position === 'right',\n right: position === 'left',\n top: false,\n topLeft: false,\n topRight: false,\n }}\n handleComponent={\n position === 'left'\n ? {\n right: (\n <DrawerResizeHandle\n handleSide=\"right\"\n onResizeBy={handleResizeBy}\n valueMax={parsePixelSize(resizeableProps?.maxWidth)}\n valueMin={parsePixelSize(resizeableProps?.minWidth)}\n valueNow={resizeWidth}\n />\n ),\n }\n : {\n left: (\n <DrawerResizeHandle\n handleSide=\"left\"\n onResizeBy={handleResizeBy}\n valueMax={parsePixelSize(resizeableProps?.maxWidth)}\n valueMin={parsePixelSize(resizeableProps?.minWidth)}\n valueNow={resizeWidth}\n />\n ),\n }\n }\n onResize={handleResize}\n ref={resizableMergedRef}\n {...restProps}\n {...htmlAttributes}\n >\n {closeButton}\n {children}\n </Resizable>\n );\n\n const regularContent = (\n <Component\n className={classNames(classes)}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {closeButton}\n {children}\n </Component>\n );\n\n /** what content to render*/\n const content = isResizeable ? resizableContent : regularContent;\n\n // const floatingRefs = useMergeRefs([refs.setFloating, refs.setReference]);\n\n /** modal behavior */\n if (type === 'modal' && isExpanded) {\n return (\n <FloatingPortal {...portalProps}>\n <FloatingOverlay\n className=\"ndl-drawer-overlay-root\"\n lockScroll={true}\n />\n <FloatingFocusManager\n disabled={!isExpanded}\n context={context}\n modal={true}\n returnFocus={true}\n initialFocus={0}\n >\n <div\n ref={refs.setFloating}\n {...getFloatingProps()}\n aria-label={ariaLabel}\n aria-modal=\"true\"\n >\n {content}\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={isPortaled && type === 'overlay' && isExpanded}\n wrap={(wrapChildren) => (\n <FloatingPortal preserveTabOrder={true} {...portalProps}>\n {wrapChildren}\n </FloatingPortal>\n )}\n >\n <FloatingFocusManager\n disabled={!isExpanded || type === 'push'}\n context={context}\n modal={true}\n initialFocus={0}\n >\n <div\n ref={refs.setFloating}\n {...getFloatingProps()}\n aria-label={ariaLabel}\n >\n {content}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\nDrawerComponent.displayName = 'Drawer';\n\ntype DrawerHeaderProps = {\n children: React.ReactNode;\n className?: string;\n // TODO v5: fix the typing on the Drawer subcomponents to use the common props type. Also, this is not an h5 haha. Should be polymorphic I guess, maybe default to h2 as we've recommended.\n htmlAttributes?: HtmlAttributes<'h5'>;\n};\n\nconst DrawerHeader = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerHeaderProps) => {\n const classes = classNames('ndl-drawer-header', className);\n\n if (typeof children === 'string' || typeof children === 'number') {\n return (\n <Typography\n className={classes}\n variant=\"title-3\"\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n }\n\n return (\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n );\n};\n\ntype DrawerActionsProps = {\n children: React.ReactNode;\n className?: string;\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst DrawerActions = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerActionsProps) => {\n const classes = classNames('ndl-drawer-actions', className);\n\n return (\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n );\n};\n\ntype DrawerBodyProps = {\n children: React.ReactNode;\n className?: string;\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst DrawerBody = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerBodyProps) => {\n const classes = classNames('ndl-drawer-body', className);\n\n return (\n <div className=\"ndl-drawer-body-wrapper\">\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n </div>\n );\n};\n\nconst Drawer = Object.assign(DrawerComponent, {\n Actions: DrawerActions,\n Body: DrawerBody,\n Header: DrawerHeader,\n});\n\nexport { Drawer };\n"]}
|
|
@@ -26,10 +26,10 @@ const react_1 = require("@neo4j-ndl/react");
|
|
|
26
26
|
const react_2 = require("react");
|
|
27
27
|
const Component = () => {
|
|
28
28
|
const [isExpanded, setIsExpanded] = (0, react_2.useState)(false);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const referenceElement = (0, react_2.useRef)(null);
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "n-h-[calc(40vh-32px)] n-min-h-[700px] n-flex n-relative n-overflow-hidden", children: [(0, jsx_runtime_1.jsxs)(react_1.Drawer, { isExpanded: isExpanded, onExpandedChange: () => setIsExpanded(false), type: "overlay", ariaLabel: "Drawer", position: "left", closeOnClickOutside: true, closeOnEscape: true, isCloseable: true, style: { maxWidth: '400px' }, children: [(0, jsx_runtime_1.jsx)(react_1.Drawer.Header, { children: "Drawer" }), (0, jsx_runtime_1.jsxs)(react_1.Drawer.Body, { children: ["If you use an overlay drawer, and there is a risk that it covers interactive elements, you should set ", (0, jsx_runtime_1.jsx)("code", { children: "closeOnClickOutside" }), ' ', "and ", (0, jsx_runtime_1.jsx)("code", { children: "closeOnFocusOut" }), " to true. This prevents it from hiding focus, making it more accessible."] }), (0, jsx_runtime_1.jsx)(react_1.Drawer.Actions, { children: (0, jsx_runtime_1.jsx)(react_1.FilledButton, { onClick: () => setIsExpanded(false), size: "medium", children: "Close" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16 w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "n-border-dashed n-border-2 n-border-light-primary-bg-strong n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md", children: (0, jsx_runtime_1.jsx)(react_1.FilledButton, { onClick: () => setIsExpanded(true), htmlAttributes: {
|
|
31
|
+
'aria-expanded': isExpanded,
|
|
32
|
+
}, ref: referenceElement, children: "Press to show the Drawer" }) }) })] }));
|
|
33
33
|
};
|
|
34
34
|
exports.default = Component;
|
|
35
35
|
//# sourceMappingURL=drawer-overlay.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer-overlay.story.js","sourceRoot":"","sources":["../../../../src/drawer/stories/drawer-overlay.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAAwD;AACxD,
|
|
1
|
+
{"version":3,"file":"drawer-overlay.story.js","sourceRoot":"","sources":["../../../../src/drawer/stories/drawer-overlay.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAAwD;AACxD,iCAAyC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACpD,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAoB,IAAI,CAAC,CAAC;IAEzD,OAAO,CACL,iCAAK,SAAS,EAAC,2EAA2E,aACxF,wBAAC,cAAM,IACL,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAC5C,IAAI,EAAC,SAAS,EACd,SAAS,EAAC,QAAQ,EAClB,QAAQ,EAAC,MAAM,EACf,mBAAmB,EAAE,IAAI,EACzB,aAAa,EAAE,IAAI,EACnB,WAAW,EAAE,IAAI,EACjB,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,aAE5B,uBAAC,cAAM,CAAC,MAAM,yBAAuB,EACrC,wBAAC,cAAM,CAAC,IAAI,yHAE2B,mEAAgC,EAAC,GAAG,UACrE,+DAA4B,gFAEpB,EACd,uBAAC,cAAM,CAAC,OAAO,cACb,uBAAC,oBAAY,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC,QAAQ,sBAEjD,GACA,IACV,EACT,gCAAK,SAAS,EAAC,gGAAgG,YAC7G,gCAAK,SAAS,EAAC,wIAAwI,YACrJ,uBAAC,oBAAY,IACX,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAClC,cAAc,EAAE;4BACd,eAAe,EAAE,UAAU;yBAC5B,EACD,GAAG,EAAE,gBAAgB,yCAGR,GACX,GACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Drawer, FilledButton } from '@neo4j-ndl/react';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const [isExpanded, setIsExpanded] = useState(false);\n const referenceElement = useRef<HTMLButtonElement>(null);\n\n return (\n <div className=\"n-h-[calc(40vh-32px)] n-min-h-[700px] n-flex n-relative n-overflow-hidden\">\n <Drawer\n isExpanded={isExpanded}\n onExpandedChange={() => setIsExpanded(false)}\n type=\"overlay\"\n ariaLabel=\"Drawer\"\n position=\"left\"\n closeOnClickOutside={true}\n closeOnEscape={true}\n isCloseable={true}\n style={{ maxWidth: '400px' }}\n >\n <Drawer.Header>Drawer</Drawer.Header>\n <Drawer.Body>\n If you use an overlay drawer, and there is a risk that it covers\n interactive elements, you should set <code>closeOnClickOutside</code>{' '}\n and <code>closeOnFocusOut</code> to true. This prevents it from hiding\n focus, making it more accessible.\n </Drawer.Body>\n <Drawer.Actions>\n <FilledButton onClick={() => setIsExpanded(false)} size=\"medium\">\n Close\n </FilledButton>\n </Drawer.Actions>\n </Drawer>\n <div className=\"n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16 w-full\">\n <div className=\"n-border-dashed n-border-2 n-border-light-primary-bg-strong n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md\">\n <FilledButton\n onClick={() => setIsExpanded(true)}\n htmlAttributes={{\n 'aria-expanded': isExpanded,\n }}\n ref={referenceElement}\n >\n Press to show the Drawer\n </FilledButton>\n </div>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -28,12 +28,14 @@ const Component = () => {
|
|
|
28
28
|
const [isExpanded, setIsExpanded] = (0, react_2.useState)(false);
|
|
29
29
|
const [isMenuOpen, setIsMenuOpen] = (0, react_2.useState)(false);
|
|
30
30
|
const anchorRef = (0, react_2.useRef)(null);
|
|
31
|
-
const
|
|
32
|
-
'aria-expanded': isExpanded,
|
|
33
|
-
}, children: "Press to show the Drawer" }) }) }));
|
|
31
|
+
const referenceElementRef = (0, react_2.useRef)(null);
|
|
34
32
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "n-h-[calc(40vh-32px)] n-min-h-[700px] n-flex n-relative n-overflow-hidden", children: [(0, jsx_runtime_1.jsxs)(react_1.Drawer, { type: "modal", isExpanded: isExpanded, onExpandedChange: () => setIsExpanded(false), position: "left", closeOnEscape: true, ariaLabel: "Drawer", htmlAttributes: {
|
|
35
33
|
id: 'drawer',
|
|
36
|
-
}, children: [(0, jsx_runtime_1.jsx)(react_1.Drawer.Header, { children: "Drawer" }), (0, jsx_runtime_1.jsxs)(react_1.Drawer.Body, { children: ["Lorem ipsum dolor sit amet.", ' ', (0, jsx_runtime_1.jsx)(react_1.DropdownButton, { ref: anchorRef, onClick: () => setIsMenuOpen(true), children: "Dropdown Button" }), (0, jsx_runtime_1.jsxs)(react_1.Menu, { strategy: "fixed", portalTarget: document.getElementById('drawer'), anchorRef: anchorRef, isOpen: isMenuOpen, onClose: () =>
|
|
34
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_1.Drawer.Header, { children: "Drawer" }), (0, jsx_runtime_1.jsxs)(react_1.Drawer.Body, { children: ["Lorem ipsum dolor sit amet.", ' ', (0, jsx_runtime_1.jsx)(react_1.DropdownButton, { ref: anchorRef, onClick: () => setIsMenuOpen(true), children: "Dropdown Button" }), (0, jsx_runtime_1.jsxs)(react_1.Menu, { strategy: "fixed", portalTarget: document.getElementById('drawer'), anchorRef: anchorRef, isOpen: isMenuOpen, onClose: (_event) => {
|
|
35
|
+
setIsMenuOpen(false);
|
|
36
|
+
}, children: [(0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Menu Item 1" }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Menu Item 2" }), (0, jsx_runtime_1.jsx)(react_1.Menu.Item, { title: "Menu Item 3" })] })] }), (0, jsx_runtime_1.jsx)(react_1.Drawer.Actions, { children: (0, jsx_runtime_1.jsx)(react_1.FilledButton, { onClick: () => setIsExpanded(false), size: "medium", children: "Close" }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16 w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "n-border-dashed n-border-2 n-border-light-primary-bg-strong n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md", children: (0, jsx_runtime_1.jsx)(react_1.FilledButton, { onClick: () => setIsExpanded(true), htmlAttributes: {
|
|
37
|
+
'aria-expanded': isExpanded,
|
|
38
|
+
}, ref: referenceElementRef, children: "Press to show the Drawer" }) }) })] }));
|
|
37
39
|
};
|
|
38
40
|
exports.default = Component;
|
|
39
41
|
//# sourceMappingURL=drawer-portaled.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer-portaled.story.js","sourceRoot":"","sources":["../../../../src/drawer/stories/drawer-portaled.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAA8E;AAC9E,iCAAyC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,IAAA,cAAM,EAA2B,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"drawer-portaled.story.js","sourceRoot":"","sources":["../../../../src/drawer/stories/drawer-portaled.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mDAAiD;AAEjD,4CAA8E;AAC9E,iCAAyC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,IAAA,cAAM,EAA2B,IAAI,CAAC,CAAC;IACzD,MAAM,mBAAmB,GAAG,IAAA,cAAM,EAA2B,IAAI,CAAC,CAAC;IAEnE,OAAO,CACL,iCAAK,SAAS,EAAC,2EAA2E,aACxF,wBAAC,cAAM,IACL,IAAI,EAAC,OAAO,EACZ,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAC5C,QAAQ,EAAC,MAAM,EACf,aAAa,EAAE,IAAI,EACnB,SAAS,EAAC,QAAQ,EAClB,cAAc,EAAE;oBACd,EAAE,EAAE,QAAQ;iBACb,aAED,uBAAC,cAAM,CAAC,MAAM,yBAAuB,EACrC,wBAAC,cAAM,CAAC,IAAI,8CACkB,GAAG,EAC/B,uBAAC,sBAAc,IAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,gCAEjD,EACjB,wBAAC,YAAI,IACH,QAAQ,EAAC,OAAO,EAChB,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,EAC/C,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE;oCAClB,aAAa,CAAC,KAAK,CAAC,CAAC;gCACvB,CAAC,aAED,uBAAC,YAAI,CAAC,IAAI,IAAC,KAAK,EAAC,aAAa,GAAG,EACjC,uBAAC,YAAI,CAAC,IAAI,IAAC,KAAK,EAAC,aAAa,GAAG,EACjC,uBAAC,YAAI,CAAC,IAAI,IAAC,KAAK,EAAC,aAAa,GAAG,IAC5B,IACK,EACd,uBAAC,cAAM,CAAC,OAAO,cACb,uBAAC,oBAAY,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC,QAAQ,sBAEjD,GACA,IACV,EACT,gCAAK,SAAS,EAAC,gGAAgG,YAC7G,gCAAK,SAAS,EAAC,wIAAwI,YACrJ,uBAAC,oBAAY,IACX,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAClC,cAAc,EAAE;4BACd,eAAe,EAAE,UAAU;yBAC5B,EACD,GAAG,EAAE,mBAAmB,yCAGX,GACX,GACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Drawer, DropdownButton, FilledButton, Menu } from '@neo4j-ndl/react';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const [isExpanded, setIsExpanded] = useState(false);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n const anchorRef = useRef<HTMLButtonElement | null>(null);\n const referenceElementRef = useRef<HTMLButtonElement | null>(null);\n\n return (\n <div className=\"n-h-[calc(40vh-32px)] n-min-h-[700px] n-flex n-relative n-overflow-hidden\">\n <Drawer\n type=\"modal\"\n isExpanded={isExpanded}\n onExpandedChange={() => setIsExpanded(false)}\n position=\"left\"\n closeOnEscape={true}\n ariaLabel=\"Drawer\"\n htmlAttributes={{\n id: 'drawer',\n }}\n >\n <Drawer.Header>Drawer</Drawer.Header>\n <Drawer.Body>\n Lorem ipsum dolor sit amet.{' '}\n <DropdownButton ref={anchorRef} onClick={() => setIsMenuOpen(true)}>\n Dropdown Button\n </DropdownButton>\n <Menu\n strategy=\"fixed\"\n portalTarget={document.getElementById('drawer')}\n anchorRef={anchorRef}\n isOpen={isMenuOpen}\n onClose={(_event) => {\n setIsMenuOpen(false);\n }}\n >\n <Menu.Item title=\"Menu Item 1\" />\n <Menu.Item title=\"Menu Item 2\" />\n <Menu.Item title=\"Menu Item 3\" />\n </Menu>\n </Drawer.Body>\n <Drawer.Actions>\n <FilledButton onClick={() => setIsExpanded(false)} size=\"medium\">\n Close\n </FilledButton>\n </Drawer.Actions>\n </Drawer>\n <div className=\"n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16 w-full\">\n <div className=\"n-border-dashed n-border-2 n-border-light-primary-bg-strong n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md\">\n <FilledButton\n onClick={() => setIsExpanded(true)}\n htmlAttributes={{\n 'aria-expanded': isExpanded,\n }}\n ref={referenceElementRef}\n >\n Press to show the Drawer\n </FilledButton>\n </div>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
package/lib/esm/drawer/Drawer.js
CHANGED
|
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { jsx as _jsx,
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* Copyright (c) "Neo4j"
|
|
@@ -33,7 +33,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
33
33
|
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useDismiss, useFloating, useInteractions, useMergeRefs, useRole, } from '@floating-ui/react';
|
|
34
34
|
import classNames from 'classnames';
|
|
35
35
|
import { Resizable } from 're-resizable';
|
|
36
|
-
import { useCallback, useEffect, useRef, useState, } from 'react';
|
|
36
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
37
37
|
import { needleWarningMessage } from '../_common/utils';
|
|
38
38
|
import { CleanIconButton } from '../clean-icon-button';
|
|
39
39
|
import { ConditionalWrap } from '../conditional-wrap';
|
|
@@ -72,7 +72,7 @@ function DrawerResizeHandle({ handleSide, onResizeBy, valueMax, valueMin, valueN
|
|
|
72
72
|
tabIndex: 0 }));
|
|
73
73
|
}
|
|
74
74
|
const DrawerComponent = function DrawerComponent(_a) {
|
|
75
|
-
var { children, className = '', isExpanded, onExpandedChange, position = 'left', type = 'overlay', isResizeable = false, resizeableProps, isCloseable = true, isPortaled = false, portalProps = {}, closeOnEscape = type === 'modal' ? true : false, closeOnClickOutside = false,
|
|
75
|
+
var { children, className = '', isExpanded, onExpandedChange, position = 'left', type = 'overlay', isResizeable = false, resizeableProps, isCloseable = true, isPortaled = false, portalProps = {}, closeOnEscape = type === 'modal' ? true : false, closeOnClickOutside = false, ariaLabel, htmlAttributes, style, ref, as } = _a, restProps = __rest(_a, ["children", "className", "isExpanded", "onExpandedChange", "position", "type", "isResizeable", "resizeableProps", "isCloseable", "isPortaled", "portalProps", "closeOnEscape", "closeOnClickOutside", "ariaLabel", "htmlAttributes", "style", "ref", "as"]);
|
|
76
76
|
const resizableRef = useRef(null);
|
|
77
77
|
const [resizeWidth, setResizeWidth] = useState(0);
|
|
78
78
|
if ((type === 'modal' || type === 'overlay') && !ariaLabel) {
|
|
@@ -88,8 +88,8 @@ const DrawerComponent = function DrawerComponent(_a) {
|
|
|
88
88
|
(type === 'overlay' && isPortaled);
|
|
89
89
|
const dismiss = useDismiss(context, {
|
|
90
90
|
enabled: shouldUseDismiss,
|
|
91
|
-
escapeKey: closeOnEscape,
|
|
92
|
-
outsidePress: closeOnClickOutside,
|
|
91
|
+
escapeKey: closeOnEscape && type !== 'push',
|
|
92
|
+
outsidePress: closeOnClickOutside && type !== 'push',
|
|
93
93
|
});
|
|
94
94
|
const role = useRole(context, {
|
|
95
95
|
enabled: type === 'modal' || type === 'overlay',
|
|
@@ -125,10 +125,8 @@ const DrawerComponent = function DrawerComponent(_a) {
|
|
|
125
125
|
setResizeWidth(width);
|
|
126
126
|
}
|
|
127
127
|
}, [isResizeable]);
|
|
128
|
-
const setOnExpandedChange = useCallback(() => {
|
|
129
|
-
onExpandedChange === null || onExpandedChange === void 0 ? void 0 : onExpandedChange(!isExpanded);
|
|
130
|
-
}, [isExpanded, onExpandedChange]);
|
|
131
128
|
const classes = classNames('ndl-drawer', className, {
|
|
129
|
+
'ndl-drawer-expanded': isExpanded,
|
|
132
130
|
'ndl-drawer-left': position === 'left',
|
|
133
131
|
'ndl-drawer-modal': type === 'modal',
|
|
134
132
|
'ndl-drawer-overlay': type === 'overlay',
|
|
@@ -138,9 +136,12 @@ const DrawerComponent = function DrawerComponent(_a) {
|
|
|
138
136
|
});
|
|
139
137
|
const resizableStylePosition = type === 'overlay' ? 'absolute' : 'relative';
|
|
140
138
|
const Component = as !== null && as !== void 0 ? as : 'div';
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
const handleClose = useCallback(() => {
|
|
140
|
+
onExpandedChange === null || onExpandedChange === void 0 ? void 0 : onExpandedChange(false);
|
|
141
|
+
}, [onExpandedChange]);
|
|
142
|
+
const closeButton = useMemo(() => isCloseable || type === 'modal' ? (_jsx(CleanIconButton, { className: "ndl-drawer-close-button", onClick: handleClose, description: null, size: "medium", htmlAttributes: {
|
|
143
|
+
'aria-label': 'Close',
|
|
144
|
+
}, children: _jsx(XMarkIconOutline, {}) })) : null, [handleClose, isCloseable, type]);
|
|
144
145
|
const resizableContent = (_jsxs(Resizable, Object.assign({ as: Component, defaultSize: {
|
|
145
146
|
height: '100%',
|
|
146
147
|
width: 'auto',
|
|
@@ -159,20 +160,16 @@ const DrawerComponent = function DrawerComponent(_a) {
|
|
|
159
160
|
}
|
|
160
161
|
: {
|
|
161
162
|
left: (_jsx(DrawerResizeHandle, { handleSide: "left", onResizeBy: handleResizeBy, valueMax: parsePixelSize(resizeableProps === null || resizeableProps === void 0 ? void 0 : resizeableProps.maxWidth), valueMin: parsePixelSize(resizeableProps === null || resizeableProps === void 0 ? void 0 : resizeableProps.minWidth), valueNow: resizeWidth })),
|
|
162
|
-
}, onResize: handleResize, ref: resizableMergedRef }, restProps, htmlAttributes, { children: [
|
|
163
|
-
const regularContent = (_jsxs(Component, Object.assign({ className: classNames(classes), style: style, ref: ref }, restProps, htmlAttributes, { children: [
|
|
163
|
+
}, onResize: handleResize, ref: resizableMergedRef }, restProps, htmlAttributes, { children: [closeButton, children] })));
|
|
164
|
+
const regularContent = (_jsxs(Component, Object.assign({ className: classNames(classes), style: style, ref: ref }, restProps, htmlAttributes, { children: [closeButton, children] })));
|
|
164
165
|
/** what content to render*/
|
|
165
166
|
const content = isResizeable ? resizableContent : regularContent;
|
|
166
|
-
const floatingRefs = useMergeRefs([refs.setFloating, refs.setReference]);
|
|
167
|
-
/** if the drawer is not expanded, don't render anything */
|
|
168
|
-
if (isExpanded === false) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
167
|
+
// const floatingRefs = useMergeRefs([refs.setFloating, refs.setReference]);
|
|
171
168
|
/** modal behavior */
|
|
172
|
-
if (type === 'modal') {
|
|
173
|
-
return (_jsxs(FloatingPortal, Object.assign({}, portalProps, { children: [_jsx(FloatingOverlay, { className: "ndl-drawer-overlay-root", lockScroll: true }), _jsx(FloatingFocusManager, { context: context, modal: true, returnFocus: true, children: _jsx("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { "aria-label": ariaLabel, "aria-modal": "true", children: content })) })] })));
|
|
169
|
+
if (type === 'modal' && isExpanded) {
|
|
170
|
+
return (_jsxs(FloatingPortal, Object.assign({}, portalProps, { children: [_jsx(FloatingOverlay, { className: "ndl-drawer-overlay-root", lockScroll: true }), _jsx(FloatingFocusManager, { disabled: !isExpanded, context: context, modal: true, returnFocus: true, initialFocus: 0, children: _jsx("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { "aria-label": ariaLabel, "aria-modal": "true", children: content })) })] })));
|
|
174
171
|
}
|
|
175
|
-
return (_jsx(ConditionalWrap, { shouldWrap: isPortaled && type === 'overlay', wrap: (wrapChildren) => (_jsx(FloatingPortal, Object.assign({ preserveTabOrder: true }, portalProps, { children: wrapChildren }))), children: _jsx(FloatingFocusManager, { disabled: !isExpanded || type === 'push', context: context, modal:
|
|
172
|
+
return (_jsx(ConditionalWrap, { shouldWrap: isPortaled && type === 'overlay' && isExpanded, wrap: (wrapChildren) => (_jsx(FloatingPortal, Object.assign({ preserveTabOrder: true }, portalProps, { children: wrapChildren }))), children: _jsx(FloatingFocusManager, { disabled: !isExpanded || type === 'push', context: context, modal: true, initialFocus: 0, children: _jsx("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { "aria-label": ariaLabel, children: content })) }) }));
|
|
176
173
|
};
|
|
177
174
|
DrawerComponent.displayName = 'Drawer';
|
|
178
175
|
const DrawerHeader = (_a) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/drawer/Drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,UAAU,EACV,WAAW,EACX,eAAe,EACf,YAAY,EACZ,OAAO,GACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAC;AAE9D,OAAO,EAEL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAMf,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA8E3C,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,SAAS,cAAc,CACrB,KAAkC;IAElC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,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YAAY;CACrB,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useDismiss,\n useFloating,\n useInteractions,\n useMergeRefs,\n useRole,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { Resizable, type ResizableProps } from 're-resizable';\nimport type React from 'react';\nimport {\n type ComponentProps,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { needleWarningMessage } from '../_common/utils';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { XMarkIconOutline } from '../icons';\nimport { Typography } from '../typography';\n\ntype DrawerPosition = 'left' | 'right';\n\ntype DrawerType = 'overlay' | 'push' | 'modal';\n\ntype DrawerProps = {\n /** Controls whether the drawer is open (expanded) or closed (collapsed). */\n isExpanded: boolean;\n\n /** Callback fired when the drawer's expanded state changes (close button, Escape, click outside, or programmatic change). */\n onExpandedChange?: (expanded: boolean) => void;\n\n /** Position where the drawer appears on screen. By default, it appears from the left. */\n position?: DrawerPosition;\n\n /** How the drawer affects the layout of sibling content. By default, it overlays content. */\n type?: DrawerType;\n\n /** Enables horizontal resizing of the drawer, by default it is not resizable. */\n isResizeable?: boolean;\n\n /** To use this prop the isResizeable prop must be set to true. For overriding the third party library props: https://github.com/bokuweb/re-resizable */\n resizeableProps?: ResizableProps;\n\n /** Whether a close button (X) is displayed in the drawer. */\n isCloseable?: boolean;\n\n /** Whether to portal the content. Only applies when type is \"overlay\". Type \"modal\" is always portaled.*/\n isPortaled?: boolean;\n\n // TODO v5: this should maybe be default on portaled in the future\n /**\n * Whether pressing Escape closes the drawer.\n * - When type is \"modal\", this defaults to true.\n * - When type is \"overlay\", this defaults to false.\n * - When type is \"push\", no effect.\n */\n closeOnEscape?: boolean;\n\n // TODO v5: this should maybe be default on overlay in the future\n /**\n * When type is \"overlay\", whether clicking outside the drawer closes it.\n * - When type is \"overlay\" or \"modal\", this defaults to false.\n * - When type is \"push\", no effect.\n */\n closeOnClickOutside?: boolean;\n\n // TODO v5: this should maybe be default on overlay in the future\n /**\n * Whether tabbing focus outside the drawer closes it.\n * - When type is \"overlay\", this defaults to false.\n * - When type is \"push\" or \"modal\", no effect.\n */\n closeOnFocusOut?: boolean;\n\n /** The content to display within the drawer. */\n children: React.ReactNode;\n\n /**\n * Props to pass to the portal from @floating-ui/react FloatingPortal\n * Only applies when type is \"overlay\" and isPortaled is true, or if type is \"modal\".\n * @see https://floating-ui.com/docs/floatingportal\n */\n portalProps?: ComponentProps<typeof FloatingPortal>;\n} & (\n | {\n type: 'modal';\n /** The aria-label to apply to the drawer. Required for accessibility when type is \"modal\" or \"overlay\".*/\n ariaLabel: string;\n }\n | {\n type?: 'push' | 'overlay';\n // TODO v5: aria label should be required when type is \"overlay\" too.\n ariaLabel?: string;\n }\n);\n\nconst KEYBOARD_RESIZE_STEP_PX = 16;\n\nfunction parsePixelSize(\n value: string | number | undefined,\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === 'number') {\n return value;\n }\n const parsed = parseInt(value.replace(/px$/i, ''), 10);\n return Number.isNaN(parsed) ? undefined : parsed;\n}\n\ntype DrawerResizeHandleProps = {\n /** Which edge this handle resizes (right = drawer’s right edge, left = drawer’s left edge). */\n handleSide: 'left' | 'right';\n /** Called with a pixel delta to apply to the drawer width (positive = wider). */\n onResizeBy: (delta: number) => void;\n onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;\n /** Current width in pixels (for aria-valuenow). */\n valueNow?: number;\n /** Minimum width in pixels (for aria-valuemin). */\n valueMin?: number;\n /** Maximum width in pixels (for aria-valuemax). */\n valueMax?: number;\n};\n\nfunction DrawerResizeHandle({\n handleSide,\n onResizeBy,\n valueMax,\n valueMin,\n valueNow,\n}: DrawerResizeHandleProps) {\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const isArrowKey = e.key === 'ArrowLeft' || e.key === 'ArrowRight';\n if (isArrowKey) {\n e.preventDefault();\n const delta =\n handleSide === 'right'\n ? e.key === 'ArrowRight'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX\n : e.key === 'ArrowLeft'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX;\n onResizeBy(delta);\n }\n },\n [handleSide, onResizeBy],\n );\n\n return (\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- Resize handle is focusable for keyboard resize. */\n <div\n aria-label={`Resize drawer with arrow keys. Handle on ${handleSide}.`}\n aria-orientation=\"vertical\"\n aria-valuemax={valueMax}\n aria-valuemin={valueMin}\n aria-valuenow={valueNow ?? 0}\n aria-valuetext={`drawer width ${valueNow ?? 0}px`}\n className=\"ndl-drawer-resize-handle\"\n data-drawer-handle={handleSide}\n onKeyDown={handleKeyDown}\n role=\"separator\"\n style={{ height: '100%', width: '100%' }}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- Resize handle is focusable for keyboard resize.\n tabIndex={0}\n />\n );\n}\n\nconst DrawerComponent = function DrawerComponent<\n T extends React.ElementType = 'div',\n>({\n children,\n className = '',\n isExpanded,\n onExpandedChange,\n position = 'left',\n type = 'overlay',\n isResizeable = false,\n resizeableProps,\n isCloseable = true,\n isPortaled = false,\n portalProps = {},\n closeOnEscape = type === 'modal' ? true : false,\n closeOnClickOutside = false,\n closeOnFocusOut = false,\n ariaLabel,\n htmlAttributes,\n style,\n ref,\n as,\n ...restProps\n}: PolymorphicCommonProps<T, DrawerProps>) {\n const resizableRef = useRef<Resizable | null>(null);\n const [resizeWidth, setResizeWidth] = useState<number>(0);\n\n if ((type === 'modal' || type === 'overlay') && !ariaLabel) {\n needleWarningMessage(\n 'A Drawer should have an aria-label when type is \"modal\" or \"overlay\" to be accessible.',\n );\n }\n\n const { refs, context } = useFloating({\n onOpenChange: onExpandedChange,\n open: isExpanded,\n });\n\n /** Dismiss (escape + click outside) applies to portaled overlay and to non-portaled overlay. */\n const shouldUseDismiss =\n type === 'modal' ||\n (type === 'overlay' && !isPortaled && isExpanded) ||\n (type === 'overlay' && isPortaled);\n\n const dismiss = useDismiss(context, {\n enabled: shouldUseDismiss,\n escapeKey: closeOnEscape,\n outsidePress: closeOnClickOutside,\n });\n const role = useRole(context, {\n enabled: type === 'modal' || type === 'overlay',\n role: 'dialog',\n });\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n const resizableMergedRef = useMergeRefs([resizableRef, ref]);\n\n const handleResizeBy = useCallback(\n (delta: number) => {\n if (!resizableRef.current) {\n return;\n }\n const current = resizableRef.current.size;\n const min = parsePixelSize(resizeableProps?.minWidth);\n const max = parsePixelSize(resizeableProps?.maxWidth);\n const newWidth = Math.max(\n min ?? 0,\n Math.min(max ?? Number.POSITIVE_INFINITY, current.width + delta),\n );\n resizableRef.current.updateSize({\n height: '100%',\n width: newWidth,\n });\n setResizeWidth(newWidth);\n },\n [resizeableProps?.minWidth, resizeableProps?.maxWidth],\n );\n\n const handleResize = useCallback(\n (\n event: MouseEvent | TouchEvent,\n direction: Parameters<NonNullable<ResizableProps['onResize']>>[1],\n elementRef: HTMLElement,\n delta: { width: number; height: number },\n ) => {\n setResizeWidth(elementRef.offsetWidth);\n resizeableProps?.onResize?.(event, direction, elementRef, delta);\n },\n [resizeableProps],\n );\n\n useEffect(() => {\n if (!isResizeable || !resizableRef.current) {\n return;\n }\n const width = resizableRef.current.size.width;\n if (width > 0) {\n setResizeWidth(width);\n }\n }, [isResizeable]);\n\n const setOnExpandedChange = useCallback(() => {\n onExpandedChange?.(!isExpanded);\n }, [isExpanded, onExpandedChange]);\n\n const classes = classNames('ndl-drawer', className, {\n 'ndl-drawer-left': position === 'left',\n 'ndl-drawer-modal': type === 'modal',\n 'ndl-drawer-overlay': type === 'overlay',\n 'ndl-drawer-portaled': isPortaled && type === 'overlay',\n 'ndl-drawer-push': type === 'push',\n 'ndl-drawer-right': position === 'right',\n });\n\n const resizableStylePosition = type === 'overlay' ? 'absolute' : 'relative';\n const Component = as ?? 'div';\n\n const Close = () => (\n <>\n {(isCloseable || type === 'modal') && (\n <CleanIconButton\n className=\"ndl-drawer-close-button\"\n onClick={setOnExpandedChange}\n description={null}\n size=\"medium\"\n htmlAttributes={{\n 'aria-label': 'Close',\n }}\n >\n <XMarkIconOutline />\n </CleanIconButton>\n )}\n </>\n );\n\n const resizableContent = (\n <Resizable\n as={Component}\n defaultSize={{\n height: '100%',\n width: 'auto',\n }}\n {...resizeableProps}\n className={classes}\n style={{\n position: resizableStylePosition,\n ...style,\n ...resizeableProps?.style,\n }}\n boundsByDirection={true}\n bounds=\"parent\"\n handleStyles={{\n /*\n * Small offset so the handle is easier to hit when the drawer content is scrollable.\n */\n ...(position === 'left' && { right: { right: '-8px' } }),\n ...(position === 'right' && { left: { left: '-8px' } }),\n }}\n enable={{\n bottom: false,\n bottomLeft: false,\n bottomRight: false,\n left: position === 'right',\n right: position === 'left',\n top: false,\n topLeft: false,\n topRight: false,\n }}\n handleComponent={\n position === 'left'\n ? {\n right: (\n <DrawerResizeHandle\n handleSide=\"right\"\n onResizeBy={handleResizeBy}\n valueMax={parsePixelSize(resizeableProps?.maxWidth)}\n valueMin={parsePixelSize(resizeableProps?.minWidth)}\n valueNow={resizeWidth}\n />\n ),\n }\n : {\n left: (\n <DrawerResizeHandle\n handleSide=\"left\"\n onResizeBy={handleResizeBy}\n valueMax={parsePixelSize(resizeableProps?.maxWidth)}\n valueMin={parsePixelSize(resizeableProps?.minWidth)}\n valueNow={resizeWidth}\n />\n ),\n }\n }\n onResize={handleResize}\n ref={resizableMergedRef}\n {...restProps}\n {...htmlAttributes}\n >\n <Close />\n {children}\n </Resizable>\n );\n\n const regularContent = (\n <Component\n className={classNames(classes)}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n <Close />\n {children}\n </Component>\n );\n\n /** what content to render*/\n const content = isResizeable ? resizableContent : regularContent;\n\n const floatingRefs = useMergeRefs([refs.setFloating, refs.setReference]);\n\n /** if the drawer is not expanded, don't render anything */\n if (isExpanded === false) {\n return null;\n }\n\n /** modal behavior */\n if (type === 'modal') {\n return (\n <FloatingPortal {...portalProps}>\n <FloatingOverlay\n className=\"ndl-drawer-overlay-root\"\n lockScroll={true}\n />\n <FloatingFocusManager context={context} modal={true} returnFocus={true}>\n <div\n ref={refs.setFloating}\n {...getFloatingProps()}\n aria-label={ariaLabel}\n aria-modal=\"true\"\n >\n {content}\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={isPortaled && type === 'overlay'}\n wrap={(wrapChildren) => (\n <FloatingPortal preserveTabOrder={true} {...portalProps}>\n {wrapChildren}\n </FloatingPortal>\n )}\n >\n <FloatingFocusManager\n disabled={!isExpanded || type === 'push'}\n context={context}\n modal={false}\n returnFocus={true}\n closeOnFocusOut={closeOnFocusOut}\n >\n <ConditionalWrap\n shouldWrap={type === 'overlay'}\n wrap={(wrapChildren) => (\n <div\n ref={floatingRefs}\n {...getFloatingProps()}\n aria-label={ariaLabel}\n >\n {wrapChildren}\n </div>\n )}\n >\n {content}\n </ConditionalWrap>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\nDrawerComponent.displayName = 'Drawer';\n\ntype DrawerHeaderProps = {\n children: React.ReactNode;\n className?: string;\n // TODO v5: fix the typing on the Drawer subcomponents to use the common props type. Also, this is not an h5 haha. Should be polymorphic I guess, maybe default to h2 as we've recommended.\n htmlAttributes?: HtmlAttributes<'h5'>;\n};\n\nconst DrawerHeader = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerHeaderProps) => {\n const classes = classNames('ndl-drawer-header', className);\n\n if (typeof children === 'string' || typeof children === 'number') {\n return (\n <Typography\n className={classes}\n variant=\"title-3\"\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n }\n\n return (\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n );\n};\n\ntype DrawerActionsProps = {\n children: React.ReactNode;\n className?: string;\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst DrawerActions = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerActionsProps) => {\n const classes = classNames('ndl-drawer-actions', className);\n\n return (\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n );\n};\n\ntype DrawerBodyProps = {\n children: React.ReactNode;\n className?: string;\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst DrawerBody = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerBodyProps) => {\n const classes = classNames('ndl-drawer-body', className);\n\n return (\n <div className=\"ndl-drawer-body-wrapper\">\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n </div>\n );\n};\n\nconst Drawer = Object.assign(DrawerComponent, {\n Actions: DrawerActions,\n Body: DrawerBody,\n Header: DrawerHeader,\n});\n\nexport { Drawer };\n"]}
|
|
1
|
+
{"version":3,"file":"Drawer.js","sourceRoot":"","sources":["../../../src/drawer/Drawer.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,UAAU,EACV,WAAW,E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MAAM,OAAO,GAAG,UAAU,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;IAE5D,OAAO,CACL,4BAAK,SAAS,EAAE,OAAO,IAAM,SAAS,EAAM,cAAc,cACvD,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAQF,MAAM,UAAU,GAAG,CAAC,EAKF,EAAE,EAAE;QALF,EAClB,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,cAAc,OAEE,EADb,SAAS,cAJM,2CAKnB,CADa;IAEZ,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;IAEzD,OAAO,CACL,cAAK,SAAS,EAAC,yBAAyB,YACtC,4BAAK,SAAS,EAAE,OAAO,IAAM,SAAS,EAAM,cAAc,cACvD,QAAQ,IACL,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IAC5C,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE,UAAU;IAChB,MAAM,EAAE,YAAY;CACrB,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport {\n FloatingFocusManager,\n FloatingOverlay,\n FloatingPortal,\n useDismiss,\n useFloating,\n useInteractions,\n useMergeRefs,\n useRole,\n} from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { Resizable, type ResizableProps } from 're-resizable';\nimport type React from 'react';\nimport {\n type ComponentProps,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { needleWarningMessage } from '../_common/utils';\nimport { CleanIconButton } from '../clean-icon-button';\nimport { ConditionalWrap } from '../conditional-wrap';\nimport { XMarkIconOutline } from '../icons';\nimport { Typography } from '../typography';\n\ntype DrawerPosition = 'left' | 'right';\n\ntype DrawerType = 'overlay' | 'push' | 'modal';\n\ntype DrawerProps = {\n /** Controls whether the drawer is open (expanded) or closed (collapsed). */\n isExpanded: boolean;\n\n /** Callback fired when the drawer's expanded state changes (close button, Escape, click outside, or programmatic change). */\n onExpandedChange?: (expanded: boolean) => void;\n\n /** Position where the drawer appears on screen. By default, it appears from the left. */\n position?: DrawerPosition;\n\n /** How the drawer affects the layout of sibling content. By default, it overlays content. */\n type?: DrawerType;\n\n /** Enables horizontal resizing of the drawer, by default it is not resizable. */\n isResizeable?: boolean;\n\n /** To use this prop the isResizeable prop must be set to true. For overriding the third party library props: https://github.com/bokuweb/re-resizable */\n resizeableProps?: ResizableProps;\n\n /** Whether a close button (X) is displayed in the drawer. */\n isCloseable?: boolean;\n\n /** Whether to portal the content. Only applies when type is \"overlay\". Type \"modal\" is always portaled.*/\n isPortaled?: boolean;\n\n // TODO v5: this should maybe be default on portaled in the future\n /**\n * Whether pressing Escape closes the drawer. Should be set to true for overlay drawers.\n * - When type is \"modal\", this defaults to true.\n * - When type is \"overlay\", this defaults to false.\n * - When type is \"push\", no effect.\n */\n closeOnEscape?: boolean;\n\n // TODO v5: this should maybe be default on overlay in the future\n /**\n * When type is \"overlay\", whether clicking outside the drawer closes it. Should be set to true for overlay drawers.\n * - When type is \"overlay\" or \"modal\", this defaults to false.\n * - When type is \"push\", no effect.\n */\n closeOnClickOutside?: boolean;\n\n // TODO v5: remove this prop\n /**\n * @deprecated overlay are now focus trapped by default, this prop has no effect anymore.\n */\n closeOnFocusOut?: boolean;\n\n /** The content to display within the drawer. */\n children: React.ReactNode;\n\n /**\n * Props to pass to the portal from @floating-ui/react FloatingPortal\n * Only applies when type is \"overlay\" and isPortaled is true, or if type is \"modal\".\n * @see https://floating-ui.com/docs/floatingportal\n */\n portalProps?: ComponentProps<typeof FloatingPortal>;\n} & (\n | {\n type: 'modal';\n /** The aria-label to apply to the drawer. Required for accessibility when type is \"modal\" or \"overlay\".*/\n ariaLabel: string;\n }\n | {\n type?: 'push' | 'overlay';\n // TODO v5: aria label should be required when type is \"overlay\" too.\n ariaLabel?: string;\n }\n);\n\nconst KEYBOARD_RESIZE_STEP_PX = 16;\n\nfunction parsePixelSize(\n value: string | number | undefined,\n): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === 'number') {\n return value;\n }\n const parsed = parseInt(value.replace(/px$/i, ''), 10);\n return Number.isNaN(parsed) ? undefined : parsed;\n}\n\ntype DrawerResizeHandleProps = {\n /** Which edge this handle resizes (right = drawer’s right edge, left = drawer’s left edge). */\n handleSide: 'left' | 'right';\n /** Called with a pixel delta to apply to the drawer width (positive = wider). */\n onResizeBy: (delta: number) => void;\n onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;\n /** Current width in pixels (for aria-valuenow). */\n valueNow?: number;\n /** Minimum width in pixels (for aria-valuemin). */\n valueMin?: number;\n /** Maximum width in pixels (for aria-valuemax). */\n valueMax?: number;\n};\n\nfunction DrawerResizeHandle({\n handleSide,\n onResizeBy,\n valueMax,\n valueMin,\n valueNow,\n}: DrawerResizeHandleProps) {\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLDivElement>) => {\n const isArrowKey = e.key === 'ArrowLeft' || e.key === 'ArrowRight';\n if (isArrowKey) {\n e.preventDefault();\n const delta =\n handleSide === 'right'\n ? e.key === 'ArrowRight'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX\n : e.key === 'ArrowLeft'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX;\n onResizeBy(delta);\n }\n },\n [handleSide, onResizeBy],\n );\n\n return (\n /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- Resize handle is focusable for keyboard resize. */\n <div\n aria-label={`Resize drawer with arrow keys. Handle on ${handleSide}.`}\n aria-orientation=\"vertical\"\n aria-valuemax={valueMax}\n aria-valuemin={valueMin}\n aria-valuenow={valueNow ?? 0}\n aria-valuetext={`drawer width ${valueNow ?? 0}px`}\n className=\"ndl-drawer-resize-handle\"\n data-drawer-handle={handleSide}\n onKeyDown={handleKeyDown}\n role=\"separator\"\n style={{ height: '100%', width: '100%' }}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- Resize handle is focusable for keyboard resize.\n tabIndex={0}\n />\n );\n}\n\nconst DrawerComponent = function DrawerComponent<\n T extends React.ElementType = 'div',\n>({\n children,\n className = '',\n isExpanded,\n onExpandedChange,\n position = 'left',\n type = 'overlay',\n isResizeable = false,\n resizeableProps,\n isCloseable = true,\n isPortaled = false,\n portalProps = {},\n closeOnEscape = type === 'modal' ? true : false,\n closeOnClickOutside = false,\n ariaLabel,\n htmlAttributes,\n style,\n ref,\n as,\n ...restProps\n}: PolymorphicCommonProps<T, DrawerProps>) {\n const resizableRef = useRef<Resizable | null>(null);\n const [resizeWidth, setResizeWidth] = useState<number>(0);\n\n if ((type === 'modal' || type === 'overlay') && !ariaLabel) {\n needleWarningMessage(\n 'A Drawer should have an aria-label when type is \"modal\" or \"overlay\" to be accessible.',\n );\n }\n\n const { refs, context } = useFloating({\n onOpenChange: onExpandedChange,\n open: isExpanded,\n });\n\n /** Dismiss (escape + click outside) applies to portaled overlay and to non-portaled overlay. */\n const shouldUseDismiss =\n type === 'modal' ||\n (type === 'overlay' && !isPortaled && isExpanded) ||\n (type === 'overlay' && isPortaled);\n\n const dismiss = useDismiss(context, {\n enabled: shouldUseDismiss,\n escapeKey: closeOnEscape && type !== 'push',\n outsidePress: closeOnClickOutside && type !== 'push',\n });\n const role = useRole(context, {\n enabled: type === 'modal' || type === 'overlay',\n role: 'dialog',\n });\n const { getFloatingProps } = useInteractions([dismiss, role]);\n\n const resizableMergedRef = useMergeRefs([resizableRef, ref]);\n\n const handleResizeBy = useCallback(\n (delta: number) => {\n if (!resizableRef.current) {\n return;\n }\n const current = resizableRef.current.size;\n const min = parsePixelSize(resizeableProps?.minWidth);\n const max = parsePixelSize(resizeableProps?.maxWidth);\n const newWidth = Math.max(\n min ?? 0,\n Math.min(max ?? Number.POSITIVE_INFINITY, current.width + delta),\n );\n resizableRef.current.updateSize({\n height: '100%',\n width: newWidth,\n });\n setResizeWidth(newWidth);\n },\n [resizeableProps?.minWidth, resizeableProps?.maxWidth],\n );\n\n const handleResize = useCallback(\n (\n event: MouseEvent | TouchEvent,\n direction: Parameters<NonNullable<ResizableProps['onResize']>>[1],\n elementRef: HTMLElement,\n delta: { width: number; height: number },\n ) => {\n setResizeWidth(elementRef.offsetWidth);\n resizeableProps?.onResize?.(event, direction, elementRef, delta);\n },\n [resizeableProps],\n );\n\n useEffect(() => {\n if (!isResizeable || !resizableRef.current) {\n return;\n }\n const width = resizableRef.current.size.width;\n if (width > 0) {\n setResizeWidth(width);\n }\n }, [isResizeable]);\n\n const classes = classNames('ndl-drawer', className, {\n 'ndl-drawer-expanded': isExpanded,\n 'ndl-drawer-left': position === 'left',\n 'ndl-drawer-modal': type === 'modal',\n 'ndl-drawer-overlay': type === 'overlay',\n 'ndl-drawer-portaled': isPortaled && type === 'overlay',\n 'ndl-drawer-push': type === 'push',\n 'ndl-drawer-right': position === 'right',\n });\n\n const resizableStylePosition = type === 'overlay' ? 'absolute' : 'relative';\n const Component = as ?? 'div';\n\n const handleClose = useCallback(() => {\n onExpandedChange?.(false);\n }, [onExpandedChange]);\n\n const closeButton = useMemo(\n () =>\n isCloseable || type === 'modal' ? (\n <CleanIconButton\n className=\"ndl-drawer-close-button\"\n onClick={handleClose}\n description={null}\n size=\"medium\"\n htmlAttributes={{\n 'aria-label': 'Close',\n }}\n >\n <XMarkIconOutline />\n </CleanIconButton>\n ) : null,\n [handleClose, isCloseable, type],\n );\n\n const resizableContent = (\n <Resizable\n as={Component}\n defaultSize={{\n height: '100%',\n width: 'auto',\n }}\n {...resizeableProps}\n className={classes}\n style={{\n position: resizableStylePosition,\n ...style,\n ...resizeableProps?.style,\n }}\n boundsByDirection={true}\n bounds=\"parent\"\n handleStyles={{\n /*\n * Small offset so the handle is easier to hit when the drawer content is scrollable.\n */\n ...(position === 'left' && { right: { right: '-8px' } }),\n ...(position === 'right' && { left: { left: '-8px' } }),\n }}\n enable={{\n bottom: false,\n bottomLeft: false,\n bottomRight: false,\n left: position === 'right',\n right: position === 'left',\n top: false,\n topLeft: false,\n topRight: false,\n }}\n handleComponent={\n position === 'left'\n ? {\n right: (\n <DrawerResizeHandle\n handleSide=\"right\"\n onResizeBy={handleResizeBy}\n valueMax={parsePixelSize(resizeableProps?.maxWidth)}\n valueMin={parsePixelSize(resizeableProps?.minWidth)}\n valueNow={resizeWidth}\n />\n ),\n }\n : {\n left: (\n <DrawerResizeHandle\n handleSide=\"left\"\n onResizeBy={handleResizeBy}\n valueMax={parsePixelSize(resizeableProps?.maxWidth)}\n valueMin={parsePixelSize(resizeableProps?.minWidth)}\n valueNow={resizeWidth}\n />\n ),\n }\n }\n onResize={handleResize}\n ref={resizableMergedRef}\n {...restProps}\n {...htmlAttributes}\n >\n {closeButton}\n {children}\n </Resizable>\n );\n\n const regularContent = (\n <Component\n className={classNames(classes)}\n style={style}\n ref={ref}\n {...restProps}\n {...htmlAttributes}\n >\n {closeButton}\n {children}\n </Component>\n );\n\n /** what content to render*/\n const content = isResizeable ? resizableContent : regularContent;\n\n // const floatingRefs = useMergeRefs([refs.setFloating, refs.setReference]);\n\n /** modal behavior */\n if (type === 'modal' && isExpanded) {\n return (\n <FloatingPortal {...portalProps}>\n <FloatingOverlay\n className=\"ndl-drawer-overlay-root\"\n lockScroll={true}\n />\n <FloatingFocusManager\n disabled={!isExpanded}\n context={context}\n modal={true}\n returnFocus={true}\n initialFocus={0}\n >\n <div\n ref={refs.setFloating}\n {...getFloatingProps()}\n aria-label={ariaLabel}\n aria-modal=\"true\"\n >\n {content}\n </div>\n </FloatingFocusManager>\n </FloatingPortal>\n );\n }\n\n return (\n <ConditionalWrap\n shouldWrap={isPortaled && type === 'overlay' && isExpanded}\n wrap={(wrapChildren) => (\n <FloatingPortal preserveTabOrder={true} {...portalProps}>\n {wrapChildren}\n </FloatingPortal>\n )}\n >\n <FloatingFocusManager\n disabled={!isExpanded || type === 'push'}\n context={context}\n modal={true}\n initialFocus={0}\n >\n <div\n ref={refs.setFloating}\n {...getFloatingProps()}\n aria-label={ariaLabel}\n >\n {content}\n </div>\n </FloatingFocusManager>\n </ConditionalWrap>\n );\n};\n\nDrawerComponent.displayName = 'Drawer';\n\ntype DrawerHeaderProps = {\n children: React.ReactNode;\n className?: string;\n // TODO v5: fix the typing on the Drawer subcomponents to use the common props type. Also, this is not an h5 haha. Should be polymorphic I guess, maybe default to h2 as we've recommended.\n htmlAttributes?: HtmlAttributes<'h5'>;\n};\n\nconst DrawerHeader = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerHeaderProps) => {\n const classes = classNames('ndl-drawer-header', className);\n\n if (typeof children === 'string' || typeof children === 'number') {\n return (\n <Typography\n className={classes}\n variant=\"title-3\"\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n }\n\n return (\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n );\n};\n\ntype DrawerActionsProps = {\n children: React.ReactNode;\n className?: string;\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst DrawerActions = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerActionsProps) => {\n const classes = classNames('ndl-drawer-actions', className);\n\n return (\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n );\n};\n\ntype DrawerBodyProps = {\n children: React.ReactNode;\n className?: string;\n htmlAttributes?: HtmlAttributes<'div'>;\n};\n\nconst DrawerBody = ({\n children,\n className = '',\n htmlAttributes,\n ...restProps\n}: DrawerBodyProps) => {\n const classes = classNames('ndl-drawer-body', className);\n\n return (\n <div className=\"ndl-drawer-body-wrapper\">\n <div className={classes} {...restProps} {...htmlAttributes}>\n {children}\n </div>\n </div>\n );\n};\n\nconst Drawer = Object.assign(DrawerComponent, {\n Actions: DrawerActions,\n Body: DrawerBody,\n Header: DrawerHeader,\n});\n\nexport { Drawer };\n"]}
|
|
@@ -21,13 +21,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
21
21
|
*/
|
|
22
22
|
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';
|
|
23
23
|
import { Drawer, FilledButton } from '@neo4j-ndl/react';
|
|
24
|
-
import { useState } from 'react';
|
|
24
|
+
import { useRef, useState } from 'react';
|
|
25
25
|
const Component = () => {
|
|
26
26
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const referenceElement = useRef(null);
|
|
28
|
+
return (_jsxs("div", { className: "n-h-[calc(40vh-32px)] n-min-h-[700px] n-flex n-relative n-overflow-hidden", children: [_jsxs(Drawer, { isExpanded: isExpanded, onExpandedChange: () => setIsExpanded(false), type: "overlay", ariaLabel: "Drawer", position: "left", closeOnClickOutside: true, closeOnEscape: true, isCloseable: true, style: { maxWidth: '400px' }, children: [_jsx(Drawer.Header, { children: "Drawer" }), _jsxs(Drawer.Body, { children: ["If you use an overlay drawer, and there is a risk that it covers interactive elements, you should set ", _jsx("code", { children: "closeOnClickOutside" }), ' ', "and ", _jsx("code", { children: "closeOnFocusOut" }), " to true. This prevents it from hiding focus, making it more accessible."] }), _jsx(Drawer.Actions, { children: _jsx(FilledButton, { onClick: () => setIsExpanded(false), size: "medium", children: "Close" }) })] }), _jsx("div", { className: "n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16 w-full", children: _jsx("div", { className: "n-border-dashed n-border-2 n-border-light-primary-bg-strong n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md", children: _jsx(FilledButton, { onClick: () => setIsExpanded(true), htmlAttributes: {
|
|
29
|
+
'aria-expanded': isExpanded,
|
|
30
|
+
}, ref: referenceElement, children: "Press to show the Drawer" }) }) })] }));
|
|
31
31
|
};
|
|
32
32
|
export default Component;
|
|
33
33
|
//# sourceMappingURL=drawer-overlay.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer-overlay.story.js","sourceRoot":"","sources":["../../../../src/drawer/stories/drawer-overlay.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"drawer-overlay.story.js","sourceRoot":"","sources":["../../../../src/drawer/stories/drawer-overlay.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,gBAAgB,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAEzD,OAAO,CACL,eAAK,SAAS,EAAC,2EAA2E,aACxF,MAAC,MAAM,IACL,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAC5C,IAAI,EAAC,SAAS,EACd,SAAS,EAAC,QAAQ,EAClB,QAAQ,EAAC,MAAM,EACf,mBAAmB,EAAE,IAAI,EACzB,aAAa,EAAE,IAAI,EACnB,WAAW,EAAE,IAAI,EACjB,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,aAE5B,KAAC,MAAM,CAAC,MAAM,yBAAuB,EACrC,MAAC,MAAM,CAAC,IAAI,yHAE2B,iDAAgC,EAAC,GAAG,UACrE,6CAA4B,gFAEpB,EACd,KAAC,MAAM,CAAC,OAAO,cACb,KAAC,YAAY,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,IAAI,EAAC,QAAQ,sBAEjD,GACA,IACV,EACT,cAAK,SAAS,EAAC,gGAAgG,YAC7G,cAAK,SAAS,EAAC,wIAAwI,YACrJ,KAAC,YAAY,IACX,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAClC,cAAc,EAAE;4BACd,eAAe,EAAE,UAAU;yBAC5B,EACD,GAAG,EAAE,gBAAgB,yCAGR,GACX,GACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Drawer, FilledButton } from '@neo4j-ndl/react';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const [isExpanded, setIsExpanded] = useState(false);\n const referenceElement = useRef<HTMLButtonElement>(null);\n\n return (\n <div className=\"n-h-[calc(40vh-32px)] n-min-h-[700px] n-flex n-relative n-overflow-hidden\">\n <Drawer\n isExpanded={isExpanded}\n onExpandedChange={() => setIsExpanded(false)}\n type=\"overlay\"\n ariaLabel=\"Drawer\"\n position=\"left\"\n closeOnClickOutside={true}\n closeOnEscape={true}\n isCloseable={true}\n style={{ maxWidth: '400px' }}\n >\n <Drawer.Header>Drawer</Drawer.Header>\n <Drawer.Body>\n If you use an overlay drawer, and there is a risk that it covers\n interactive elements, you should set <code>closeOnClickOutside</code>{' '}\n and <code>closeOnFocusOut</code> to true. This prevents it from hiding\n focus, making it more accessible.\n </Drawer.Body>\n <Drawer.Actions>\n <FilledButton onClick={() => setIsExpanded(false)} size=\"medium\">\n Close\n </FilledButton>\n </Drawer.Actions>\n </Drawer>\n <div className=\"n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16 w-full\">\n <div className=\"n-border-dashed n-border-2 n-border-light-primary-bg-strong n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md\">\n <FilledButton\n onClick={() => setIsExpanded(true)}\n htmlAttributes={{\n 'aria-expanded': isExpanded,\n }}\n ref={referenceElement}\n >\n Press to show the Drawer\n </FilledButton>\n </div>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -26,12 +26,14 @@ const Component = () => {
|
|
|
26
26
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
27
27
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
28
28
|
const anchorRef = useRef(null);
|
|
29
|
-
const
|
|
30
|
-
'aria-expanded': isExpanded,
|
|
31
|
-
}, children: "Press to show the Drawer" }) }) }));
|
|
29
|
+
const referenceElementRef = useRef(null);
|
|
32
30
|
return (_jsxs("div", { className: "n-h-[calc(40vh-32px)] n-min-h-[700px] n-flex n-relative n-overflow-hidden", children: [_jsxs(Drawer, { type: "modal", isExpanded: isExpanded, onExpandedChange: () => setIsExpanded(false), position: "left", closeOnEscape: true, ariaLabel: "Drawer", htmlAttributes: {
|
|
33
31
|
id: 'drawer',
|
|
34
|
-
}, children: [_jsx(Drawer.Header, { children: "Drawer" }), _jsxs(Drawer.Body, { children: ["Lorem ipsum dolor sit amet.", ' ', _jsx(DropdownButton, { ref: anchorRef, onClick: () => setIsMenuOpen(true), children: "Dropdown Button" }), _jsxs(Menu, { strategy: "fixed", portalTarget: document.getElementById('drawer'), anchorRef: anchorRef, isOpen: isMenuOpen, onClose: () =>
|
|
32
|
+
}, children: [_jsx(Drawer.Header, { children: "Drawer" }), _jsxs(Drawer.Body, { children: ["Lorem ipsum dolor sit amet.", ' ', _jsx(DropdownButton, { ref: anchorRef, onClick: () => setIsMenuOpen(true), children: "Dropdown Button" }), _jsxs(Menu, { strategy: "fixed", portalTarget: document.getElementById('drawer'), anchorRef: anchorRef, isOpen: isMenuOpen, onClose: (_event) => {
|
|
33
|
+
setIsMenuOpen(false);
|
|
34
|
+
}, children: [_jsx(Menu.Item, { title: "Menu Item 1" }), _jsx(Menu.Item, { title: "Menu Item 2" }), _jsx(Menu.Item, { title: "Menu Item 3" })] })] }), _jsx(Drawer.Actions, { children: _jsx(FilledButton, { onClick: () => setIsExpanded(false), size: "medium", children: "Close" }) })] }), _jsx("div", { className: "n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16 w-full", children: _jsx("div", { className: "n-border-dashed n-border-2 n-border-light-primary-bg-strong n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md", children: _jsx(FilledButton, { onClick: () => setIsExpanded(true), htmlAttributes: {
|
|
35
|
+
'aria-expanded': isExpanded,
|
|
36
|
+
}, ref: referenceElementRef, children: "Press to show the Drawer" }) }) })] }));
|
|
35
37
|
};
|
|
36
38
|
export default Component;
|
|
37
39
|
//# sourceMappingURL=drawer-portaled.story.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer-portaled.story.js","sourceRoot":"","sources":["../../../../src/drawer/stories/drawer-portaled.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"drawer-portaled.story.js","sourceRoot":"","sources":["../../../../src/drawer/stories/drawer-portaled.story.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IACzD,MAAM,mBAAmB,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IAEnE,OAAO,C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E,UAAU;yBAC5B,EACD,GAAG,EAAE,mBAAmB,yCAGX,GACX,GACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { Drawer, DropdownButton, FilledButton, Menu } from '@neo4j-ndl/react';\nimport { useRef, useState } from 'react';\n\nconst Component = () => {\n const [isExpanded, setIsExpanded] = useState(false);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n const anchorRef = useRef<HTMLButtonElement | null>(null);\n const referenceElementRef = useRef<HTMLButtonElement | null>(null);\n\n return (\n <div className=\"n-h-[calc(40vh-32px)] n-min-h-[700px] n-flex n-relative n-overflow-hidden\">\n <Drawer\n type=\"modal\"\n isExpanded={isExpanded}\n onExpandedChange={() => setIsExpanded(false)}\n position=\"left\"\n closeOnEscape={true}\n ariaLabel=\"Drawer\"\n htmlAttributes={{\n id: 'drawer',\n }}\n >\n <Drawer.Header>Drawer</Drawer.Header>\n <Drawer.Body>\n Lorem ipsum dolor sit amet.{' '}\n <DropdownButton ref={anchorRef} onClick={() => setIsMenuOpen(true)}>\n Dropdown Button\n </DropdownButton>\n <Menu\n strategy=\"fixed\"\n portalTarget={document.getElementById('drawer')}\n anchorRef={anchorRef}\n isOpen={isMenuOpen}\n onClose={(_event) => {\n setIsMenuOpen(false);\n }}\n >\n <Menu.Item title=\"Menu Item 1\" />\n <Menu.Item title=\"Menu Item 2\" />\n <Menu.Item title=\"Menu Item 3\" />\n </Menu>\n </Drawer.Body>\n <Drawer.Actions>\n <FilledButton onClick={() => setIsExpanded(false)} size=\"medium\">\n Close\n </FilledButton>\n </Drawer.Actions>\n </Drawer>\n <div className=\"n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md n-p-token-16 w-full\">\n <div className=\"n-border-dashed n-border-2 n-border-light-primary-bg-strong n-size-full n-flex n-flex-col n-items-center n-justify-center n-rounded-md\">\n <FilledButton\n onClick={() => setIsExpanded(true)}\n htmlAttributes={{\n 'aria-expanded': isExpanded,\n }}\n ref={referenceElementRef}\n >\n Press to show the Drawer\n </FilledButton>\n </div>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -43,22 +43,20 @@ type DrawerProps = {
|
|
|
43
43
|
/** Whether to portal the content. Only applies when type is "overlay". Type "modal" is always portaled.*/
|
|
44
44
|
isPortaled?: boolean;
|
|
45
45
|
/**
|
|
46
|
-
* Whether pressing Escape closes the drawer.
|
|
46
|
+
* Whether pressing Escape closes the drawer. Should be set to true for overlay drawers.
|
|
47
47
|
* - When type is "modal", this defaults to true.
|
|
48
48
|
* - When type is "overlay", this defaults to false.
|
|
49
49
|
* - When type is "push", no effect.
|
|
50
50
|
*/
|
|
51
51
|
closeOnEscape?: boolean;
|
|
52
52
|
/**
|
|
53
|
-
* When type is "overlay", whether clicking outside the drawer closes it.
|
|
53
|
+
* When type is "overlay", whether clicking outside the drawer closes it. Should be set to true for overlay drawers.
|
|
54
54
|
* - When type is "overlay" or "modal", this defaults to false.
|
|
55
55
|
* - When type is "push", no effect.
|
|
56
56
|
*/
|
|
57
57
|
closeOnClickOutside?: boolean;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
* - When type is "overlay", this defaults to false.
|
|
61
|
-
* - When type is "push" or "modal", no effect.
|
|
59
|
+
* @deprecated overlay are now focus trapped by default, this prop has no effect anymore.
|
|
62
60
|
*/
|
|
63
61
|
closeOnFocusOut?: boolean;
|
|
64
62
|
/** The content to display within the drawer. */
|
|
@@ -93,7 +91,7 @@ type DrawerBodyProps = {
|
|
|
93
91
|
htmlAttributes?: HtmlAttributes<'div'>;
|
|
94
92
|
};
|
|
95
93
|
declare const Drawer: {
|
|
96
|
-
<T extends React.ElementType = "div">({ children, className, isExpanded, onExpandedChange, position, type, isResizeable, resizeableProps, isCloseable, isPortaled, portalProps, closeOnEscape, closeOnClickOutside,
|
|
94
|
+
<T extends React.ElementType = "div">({ children, className, isExpanded, onExpandedChange, position, type, isResizeable, resizeableProps, isCloseable, isPortaled, portalProps, closeOnEscape, closeOnClickOutside, ariaLabel, htmlAttributes, style, ref, as, ...restProps }: PolymorphicCommonProps<T, DrawerProps>): import("react/jsx-runtime").JSX.Element;
|
|
97
95
|
displayName: string;
|
|
98
96
|
} & {
|
|
99
97
|
Actions: ({ children, className, htmlAttributes, ...restProps }: DrawerActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/drawer/Drawer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAGL,cAAc,EAMf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/drawer/Drawer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAGL,cAAc,EAMf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,OAAO,CA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AiB,GAAG;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,cAAc,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;CACvC,CAAC;AA8BF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;CACxC,CAAC;AAiBF,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;CACxC,CAAC;AAmBF,QAAA,MAAM,MAAM;KApWV,CAAC,SAAS,KAAK,CAAC,WAAW,mPAqB1B,sBAAsB,CAAC,CAAC,EAAE,WAAW,CAAC;;;qEA8StC,kBAAkB;kEAqBlB,eAAe;oEAvDf,iBAAiB;CAuElB,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-ndl/react",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.27",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "React implementation of Neo4j Design System",
|
|
6
6
|
"keywords": [
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@tanstack/react-table": "8.21.3",
|
|
88
88
|
"react": ">=19.0.0",
|
|
89
89
|
"react-dom": ">=19.0.0",
|
|
90
|
-
"@neo4j-ndl/base": "^4.9.
|
|
90
|
+
"@neo4j-ndl/base": "^4.9.15"
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@dnd-kit/core": "6.3.1",
|