@neo4j-ndl/react 5.6.4 → 6.0.0-alpha.0.d77a467
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/accordion/Accordion.js +2 -2
- package/lib/cjs/accordion/Accordion.js.map +1 -1
- package/lib/cjs/ai/preview/Preview.js +1 -1
- package/lib/cjs/ai/preview/Preview.js.map +1 -1
- package/lib/cjs/ai/reasoning/Reasoning.js +2 -2
- package/lib/cjs/ai/reasoning/Reasoning.js.map +1 -1
- package/lib/cjs/ai/thinking/Thinking.js +2 -2
- package/lib/cjs/ai/thinking/Thinking.js.map +1 -1
- package/lib/cjs/avatar/Avatar.js +1 -1
- package/lib/cjs/avatar/Avatar.js.map +1 -1
- package/lib/cjs/banner/Banner.js +1 -1
- package/lib/cjs/banner/Banner.js.map +1 -1
- package/lib/cjs/data-grid/Components.js +1 -1
- package/lib/cjs/data-grid/Components.js.map +1 -1
- package/lib/cjs/date-picker/DatePicker.js +2 -2
- package/lib/cjs/date-picker/DatePicker.js.map +1 -1
- package/lib/cjs/dialog/Dialog.js +1 -1
- package/lib/cjs/dialog/Dialog.js.map +1 -1
- package/lib/cjs/drawer/Drawer.js +1 -1
- package/lib/cjs/drawer/Drawer.js.map +1 -1
- package/lib/cjs/dropzone/Dropzone.js +2 -2
- package/lib/cjs/dropzone/Dropzone.js.map +1 -1
- package/lib/cjs/icons/index.js +1 -1
- package/lib/cjs/index.js +4 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/inline-edit/InlineEdit.js +1 -1
- package/lib/cjs/inline-edit/InlineEdit.js.map +1 -1
- package/lib/cjs/inline-edit/utils.js +2 -4
- package/lib/cjs/inline-edit/utils.js.map +1 -1
- package/lib/cjs/search-field/SearchField.js +94 -0
- package/lib/cjs/search-field/SearchField.js.map +1 -0
- package/lib/cjs/search-field/index.js +30 -0
- package/lib/cjs/search-field/index.js.map +1 -0
- package/lib/cjs/side-navigation/SideNavigation.js +2 -2
- package/lib/cjs/side-navigation/SideNavigation.js.map +1 -1
- package/lib/cjs/spotlight/Spotlight.js +1 -1
- package/lib/cjs/spotlight/Spotlight.js.map +1 -1
- package/lib/cjs/tabs/Tabs.js +1 -1
- package/lib/cjs/tabs/Tabs.js.map +1 -1
- package/lib/cjs/text-input/TextInput.js +1 -1
- package/lib/cjs/text-input/TextInput.js.map +1 -1
- package/lib/cjs/tooltip/Tooltip.js +1 -1
- package/lib/cjs/tooltip/Tooltip.js.map +1 -1
- package/lib/cjs/tree-view/TreeViewTextItem.js +1 -1
- package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -1
- package/lib/esm/accordion/Accordion.mjs +2 -2
- package/lib/esm/accordion/Accordion.mjs.map +1 -1
- package/lib/esm/ai/preview/Preview.mjs +1 -1
- package/lib/esm/ai/preview/Preview.mjs.map +1 -1
- package/lib/esm/ai/reasoning/Reasoning.mjs +2 -2
- package/lib/esm/ai/reasoning/Reasoning.mjs.map +1 -1
- package/lib/esm/ai/thinking/Thinking.mjs +2 -2
- package/lib/esm/ai/thinking/Thinking.mjs.map +1 -1
- package/lib/esm/avatar/Avatar.mjs +1 -1
- package/lib/esm/avatar/Avatar.mjs.map +1 -1
- package/lib/esm/banner/Banner.mjs +1 -1
- package/lib/esm/banner/Banner.mjs.map +1 -1
- package/lib/esm/data-grid/Components.mjs +1 -1
- package/lib/esm/data-grid/Components.mjs.map +1 -1
- package/lib/esm/date-picker/DatePicker.mjs +2 -2
- package/lib/esm/date-picker/DatePicker.mjs.map +1 -1
- package/lib/esm/dialog/Dialog.mjs +1 -1
- package/lib/esm/dialog/Dialog.mjs.map +1 -1
- package/lib/esm/drawer/Drawer.mjs +1 -1
- package/lib/esm/drawer/Drawer.mjs.map +1 -1
- package/lib/esm/dropzone/Dropzone.mjs +2 -2
- package/lib/esm/dropzone/Dropzone.mjs.map +1 -1
- package/lib/esm/icons/index.mjs +1 -1
- package/lib/esm/index.mjs +4 -3
- package/lib/esm/index.mjs.map +1 -1
- package/lib/esm/inline-edit/InlineEdit.mjs +1 -1
- package/lib/esm/inline-edit/InlineEdit.mjs.map +1 -1
- package/lib/esm/inline-edit/utils.mjs +2 -4
- package/lib/esm/inline-edit/utils.mjs.map +1 -1
- package/lib/esm/search-field/SearchField.mjs +89 -0
- package/lib/esm/search-field/SearchField.mjs.map +1 -0
- package/lib/esm/search-field/index.mjs +24 -0
- package/lib/esm/search-field/index.mjs.map +1 -0
- package/lib/esm/side-navigation/SideNavigation.mjs +2 -2
- package/lib/esm/side-navigation/SideNavigation.mjs.map +1 -1
- package/lib/esm/spotlight/Spotlight.mjs +1 -1
- package/lib/esm/spotlight/Spotlight.mjs.map +1 -1
- package/lib/esm/tabs/Tabs.mjs +1 -1
- package/lib/esm/tabs/Tabs.mjs.map +1 -1
- package/lib/esm/text-input/TextInput.mjs +1 -1
- package/lib/esm/text-input/TextInput.mjs.map +1 -1
- package/lib/esm/tooltip/Tooltip.mjs +1 -1
- package/lib/esm/tooltip/Tooltip.mjs.map +1 -1
- package/lib/esm/tree-view/TreeViewTextItem.mjs +1 -1
- package/lib/esm/tree-view/TreeViewTextItem.mjs.map +1 -1
- package/lib/types/ai/thinking/Thinking.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/inline-edit/InlineEdit.d.ts +1 -1
- package/lib/types/inline-edit/utils.d.ts.map +1 -1
- package/lib/types/search-field/SearchField.d.ts +52 -0
- package/lib/types/search-field/SearchField.d.ts.map +1 -0
- package/lib/types/search-field/index.d.ts +22 -0
- package/lib/types/search-field/index.d.ts.map +1 -0
- package/package.json +9 -3
- package/skills/ndl-react/SKILL.md +3 -2
- package/skills/ndl-react/components/accordion.md +3 -3
- package/skills/ndl-react/components/clean-icon-button.md +5 -5
- package/skills/ndl-react/components/date-picker.md +2 -2
- package/skills/ndl-react/components/dropzone.md +2 -2
- package/skills/ndl-react/components/icon-button.md +5 -5
- package/skills/ndl-react/components/inline-edit.md +1 -1
- package/skills/ndl-react/components/radio.md +1 -1
- package/skills/ndl-react/components/search-field.md +254 -0
- package/skills/ndl-react/components/select-icon-button.md +6 -6
- package/skills/ndl-react/components/side-navigation.md +4 -4
- package/skills/ndl-react/components/skeleton.md +3 -3
- package/skills/ndl-react/components/status-indicator.md +5 -5
- package/skills/ndl-react/components/tabs.md +4 -4
- package/skills/ndl-react/components/timezone-picker.md +1 -1
- package/skills/ndl-react/components/tooltip.md +1 -1
- package/skills/ndl-react/components/typography.md +2 -2
- package/skills/ndl-react/references/styling.md +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.mjs","names":[],"sources":["../../../src/drawer/Drawer.tsx"],"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/generated/heroIcons/XMarkIconOutline';\nimport { Typography } from '../typography';\n\ntype DrawerPosition = 'left' | 'right';\n\ntype DrawerType = 'overlay' | 'push' | 'modal';\n\n/**\n * @remarks\n * Where `ResizableProps` is the props for the `re-resizable` library. For more information, see the [re-resizable documentation](https://github.com/bokuweb/re-resizable).\n *\n * @remarks\n * Where `FloatingPortalProps` is the props for the `@floating-ui/react` library. For more information, see the [FloatingPortal documentation](https://floating-ui.com/docs/floatingportal).\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 * The property enable has default values set for bottom, bottomLeft etc based on the position prop.\n */\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 /**\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 true.\n * - When type is \"push\", no effect.\n */\n shouldCloseOnEscape?: boolean;\n\n // TODO: 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 shouldCloseOnClickOutside?: 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` is optional on this branch so that omitting it types as 'overlay' which matches the default value and requires `ariaLabel`.\n type?: 'modal' | 'overlay';\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';\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 if (/^\\d+(\\.\\d+)?px$/i.test(value)) {\n return parseFloat(value);\n }\n return undefined;\n}\n\nfunction parsePercentage(\n value: string | number | undefined,\n referenceWidth: number | undefined,\n): number | undefined {\n if (\n typeof value !== 'string' ||\n !value.endsWith('%') ||\n referenceWidth === undefined\n ) {\n return undefined;\n }\n const percent = parseFloat(value);\n return Number.isNaN(percent) ? undefined : (percent / 100) * referenceWidth;\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 (event: React.KeyboardEvent<HTMLDivElement>) => {\n const isArrowKey =\n event.key === 'ArrowLeft' || event.key === 'ArrowRight';\n if (isArrowKey) {\n event.preventDefault();\n const delta =\n handleSide === 'right'\n ? event.key === 'ArrowRight'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX\n : event.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 shouldCloseOnEscape = type === 'push' ? false : true,\n shouldCloseOnClickOutside = 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: shouldCloseOnEscape && type !== 'push',\n outsidePress: shouldCloseOnClickOutside && 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 parentWidth =\n resizableRef.current.resizable?.parentElement?.offsetWidth;\n const min =\n parsePixelSize(resizeableProps?.minWidth) ??\n parsePercentage(resizeableProps?.minWidth, parentWidth);\n const max =\n parsePixelSize(resizeableProps?.maxWidth) ??\n parsePercentage(resizeableProps?.maxWidth, parentWidth);\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={resizeableProps?.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 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 if (type === 'overlay' && isExpanded) {\n return (\n <ConditionalWrap\n shouldWrap={isPortaled}\n wrap={(wrapChildren) => (\n <FloatingPortal preserveTabOrder={true} {...portalProps}>\n {wrapChildren}\n </FloatingPortal>\n )}\n >\n <FloatingFocusManager\n disabled={!isExpanded}\n context={context}\n modal={true}\n returnFocus={true}\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 </ConditionalWrap>\n );\n }\n\n return content;\n};\n\nDrawerComponent.displayName = 'Drawer';\n\ntype DrawerHeaderProps = {\n children: React.ReactNode;\n};\n\nconst DrawerHeader = <T extends React.ElementType = 'div'>({\n as,\n children,\n className = '',\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, DrawerHeaderProps>) => {\n const classes = classNames('ndl-drawer-header', className);\n const Component: React.ElementType = as ?? 'div';\n\n if (typeof children === 'string' || typeof children === 'number') {\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"title-3\"\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgOE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA4QA;CACA;CACA;CACA;CACA;CACA;;;CA0CA;CACA;CACA;;;CAmBA;CACA;CACA;;AAncF,MAAM,0BAA0B;AAEhC,SAAS,eACP,OACoB;CACpB,IAAI,UAAU,KAAA,GACZ;CAEF,IAAI,OAAO,UAAU,UACnB,OAAO;CAET,IAAI,mBAAmB,KAAK,KAAK,GAC/B,OAAO,WAAW,KAAK;AAG3B;AAEA,SAAS,gBACP,OACA,gBACoB;CACpB,IACE,OAAO,UAAU,YACjB,CAAC,MAAM,SAAS,GAAG,KACnB,mBAAmB,KAAA,GAEnB;CAEF,MAAM,UAAU,WAAW,KAAK;CAChC,OAAO,OAAO,MAAM,OAAO,IAAI,KAAA,IAAa,UAAU,MAAO;AAC/D;AAgBA,SAAS,mBAAmB,EAC1B,YACA,YACA,UACA,UACA,YAC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EAEH,SAAA,CACS,CAAA;CAIhB,OACE,oBAAC,WAAA,eAAA,eAAA,eAAA;EACC,WAAW;EACN;EACE;CACH,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAEH,SAAA,CACQ,CAAA;AAEf;AAQA,MAAM,iBAAiB,UAKG;CALH,IAAA,EACrB,UACA,YAAY,IACZ,mBAAA,OACG,YAAA,yBAAA,OAAA,UAAA;CAEH,MAAM,UAAU,WAAW,sBAAsB,SAAS;CAE1D,OACE,oBAAC,OAAA,eAAA,eAAA,eAAA,EAAI,WAAW,QAAA,GAAa,SAAA,GAAe,cAAA,GAAA,CAAA,GAAA,EACzC,SAAA,CACE,CAAA;AAET;AAQA,MAAM,cAAc,UAKG;CALH,IAAA,EAClB,UACA,YAAY,IACZ,mBAAA,OACG,YAAA,yBAAA,OAAA,UAAA;CAEH,MAAM,UAAU,WAAW,mBAAmB,SAAS;CAEvD,OACE,oBAAC,OAAD;EAAK,WAAU;EACb,UAAA,oBAAC,OAAA,eAAA,eAAA,eAAA,EAAI,WAAW,QAAA,GAAa,SAAA,GAAe,cAAA,GAAA,CAAA,GAAA,EACzC,SAAA,CACE,CAAA;CACF,CAAA;AAET;AAEA,MAAM,SAAS,OAAO,OAAO,iBAAiB;CAC5C,SAAS;CACT,MAAM;CACN,QAAQ;AACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"Drawer.mjs","names":[],"sources":["../../../src/drawer/Drawer.tsx"],"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/generated/heroIcons/XMarkIconOutline';\nimport { Typography } from '../typography';\n\ntype DrawerPosition = 'left' | 'right';\n\ntype DrawerType = 'overlay' | 'push' | 'modal';\n\n/**\n * @remarks\n * Where `ResizableProps` is the props for the `re-resizable` library. For more information, see the [re-resizable documentation](https://github.com/bokuweb/re-resizable).\n *\n * @remarks\n * Where `FloatingPortalProps` is the props for the `@floating-ui/react` library. For more information, see the [FloatingPortal documentation](https://floating-ui.com/docs/floatingportal).\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 * The property enable has default values set for bottom, bottomLeft etc based on the position prop.\n */\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 /**\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 true.\n * - When type is \"push\", no effect.\n */\n shouldCloseOnEscape?: boolean;\n\n // TODO: 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 shouldCloseOnClickOutside?: 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` is optional on this branch so that omitting it types as 'overlay' which matches the default value and requires `ariaLabel`.\n type?: 'modal' | 'overlay';\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';\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 if (/^\\d+(\\.\\d+)?px$/i.test(value)) {\n return parseFloat(value);\n }\n return undefined;\n}\n\nfunction parsePercentage(\n value: string | number | undefined,\n referenceWidth: number | undefined,\n): number | undefined {\n if (\n typeof value !== 'string' ||\n !value.endsWith('%') ||\n referenceWidth === undefined\n ) {\n return undefined;\n }\n const percent = parseFloat(value);\n return Number.isNaN(percent) ? undefined : (percent / 100) * referenceWidth;\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 (event: React.KeyboardEvent<HTMLDivElement>) => {\n const isArrowKey =\n event.key === 'ArrowLeft' || event.key === 'ArrowRight';\n if (isArrowKey) {\n event.preventDefault();\n const delta =\n handleSide === 'right'\n ? event.key === 'ArrowRight'\n ? KEYBOARD_RESIZE_STEP_PX\n : -KEYBOARD_RESIZE_STEP_PX\n : event.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 shouldCloseOnEscape = type === 'push' ? false : true,\n shouldCloseOnClickOutside = 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: shouldCloseOnEscape && type !== 'push',\n outsidePress: shouldCloseOnClickOutside && 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 parentWidth =\n resizableRef.current.resizable?.parentElement?.offsetWidth;\n const min =\n parsePixelSize(resizeableProps?.minWidth) ??\n parsePercentage(resizeableProps?.minWidth, parentWidth);\n const max =\n parsePixelSize(resizeableProps?.maxWidth) ??\n parsePercentage(resizeableProps?.maxWidth, parentWidth);\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={resizeableProps?.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 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 if (type === 'overlay' && isExpanded) {\n return (\n <ConditionalWrap\n shouldWrap={isPortaled}\n wrap={(wrapChildren) => (\n <FloatingPortal preserveTabOrder={true} {...portalProps}>\n {wrapChildren}\n </FloatingPortal>\n )}\n >\n <FloatingFocusManager\n disabled={!isExpanded}\n context={context}\n modal={true}\n returnFocus={true}\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 </ConditionalWrap>\n );\n }\n\n return content;\n};\n\nDrawerComponent.displayName = 'Drawer';\n\ntype DrawerHeaderProps = {\n children: React.ReactNode;\n};\n\nconst DrawerHeader = <T extends React.ElementType = 'div'>({\n as,\n children,\n className = '',\n style,\n htmlAttributes,\n ref,\n ...restProps\n}: PolymorphicCommonProps<T, DrawerHeaderProps>) => {\n const classes = classNames('ndl-drawer-header', className);\n const Component: React.ElementType = as ?? 'div';\n\n if (typeof children === 'string' || typeof children === 'number') {\n return (\n <Typography\n as={Component}\n className={classes}\n ref={ref}\n style={style}\n variant=\"title-2\"\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Typography>\n );\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n {children}\n </Component>\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgOE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA4QA;CACA;CACA;CACA;CACA;CACA;;;CA0CA;CACA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iBAAiB;CAC5C,SAAS;CACT,MAAM;CACN,QAAQ;AACV,CAAC"}
|
|
@@ -118,7 +118,7 @@ const DropzoneComponent = (_ref) => {
|
|
|
118
118
|
!isUploading && /* @__PURE__ */ jsxs("div", {
|
|
119
119
|
className: "ndl-dnd-title-container",
|
|
120
120
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
121
|
-
variant: "subheading-
|
|
121
|
+
variant: "subheading-large",
|
|
122
122
|
children: titleText || (heading !== null && heading !== void 0 ? heading : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
123
123
|
"Drag ",
|
|
124
124
|
/* @__PURE__ */ jsx("span", {
|
|
@@ -164,7 +164,7 @@ const DropzoneLoadingProgressBarComponent = (_ref2) => {
|
|
|
164
164
|
className: "ndl-dropzone-loading-progress-bar-indicators",
|
|
165
165
|
children: [/* @__PURE__ */ jsx(Typography, {
|
|
166
166
|
className: "ndl-dropzone-loading-progress-bar-precentage",
|
|
167
|
-
variant: "subheading-
|
|
167
|
+
variant: "subheading-medium",
|
|
168
168
|
children: `${progressBarPrecentage}%`
|
|
169
169
|
}), Boolean(progressBarMinute) && /* @__PURE__ */ jsx(Typography, {
|
|
170
170
|
className: "ndl-dropzone-loading-progress-bar-minute",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropzone.mjs","names":["XCircleSolidIcon","DocumentArrowUpSolidIcon","DocumentArrowUpOutlineIcon"],"sources":["../../../src/dropzone/Dropzone.tsx"],"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 { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { type RefObject, useMemo, useRef, useState } from 'react';\nimport {\n type DropEvent,\n type DropzoneOptions,\n type FileRejection,\n useDropzone,\n} from 'react-dropzone';\nimport { useResizeObserver } from 'usehooks-ts';\n\nimport { type CommonProps } from '../_common/types';\nimport { Banner } from '../banner';\nimport DocumentArrowUpOutlineIcon from '../icons/generated/custom/DocumentArrowUpOutline';\nimport DocumentArrowUpSolidIcon from '../icons/generated/custom/DocumentArrowUpSolid';\nimport XCircleSolidIcon from '../icons/generated/custom/XCircleSolid';\nimport { ProgressBar } from '../progress-bar';\nimport { Typography } from '../typography';\n\n/**\n *\n *\n * Types\n *\n *\n */\n/**\n * @remarks\n * Where `DropzoneOptions` is the props for the `react-dropzone` library. For more information, see the [react-dropzone documentation](https://react-dropzone.js.org/#src).\n */\ntype DropzoneProps = {\n /** Props for the underlying `react-dropzone` component. Don't use `accept`. If using custom file extensions as this option is broken. Instead use the `acceptedFileExtensions` property. */\n dropZoneOptions: DropzoneOptions;\n\n /** Informational text that highlights the supported file types, will be displayed in the footer. */\n supportedFilesDescription?: React.ReactNode;\n\n /** Element to display when uploading the file. */\n loadingElement?: React.ReactNode;\n\n /** Use when wanting a custom heading. */\n heading?: React.ReactNode;\n\n /** Message shown when a file is rejected. Defaults to \"File extension not supported.\" when omitted. */\n rejectedText?: React.ReactNode;\n\n /** The accepted file extensions for the Drag-and-Drop. */\n acceptedFileExtensions?: string[];\n\n /** Whether to display the dashed border around the dropzone. */\n hasBorder?: boolean;\n};\n\ntype DropzoneLoadingProgressBarProps = {\n /** The percentage of the progress bar. */\n progressBarPrecentage: number;\n\n /** The time in minute left to upload the file. */\n progressBarMinute?: number;\n};\n\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst DropzoneComponent = ({\n dropZoneOptions,\n supportedFilesDescription,\n loadingElement,\n heading,\n rejectedText,\n acceptedFileExtensions,\n hasBorder = true,\n htmlAttributes,\n style,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', DropzoneProps>) => {\n /**\n * We intercept the onDrop function in order to enforce\n * custom file extensions. Before calling the onDrop props we check\n * if the custom file extensions is acceptable. If the extension\n * conforms to acceptedFileExtensions, we call onDrop. Otherwise, we\n * present an error message.\n */\n function onDropInterceptor<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ) {\n if (acceptedFileExtensions && acceptedFileExtensions.length > 0) {\n for (const file of acceptedFiles) {\n const isAccepted = acceptedFileExtensions.some((extension) =>\n file.name.endsWith(extension),\n );\n if (!isAccepted) {\n setIsRejected(true);\n return;\n }\n }\n }\n setIsRejected(false);\n dropZoneOptions.onDrop?.(acceptedFiles, fileRejections, event);\n }\n\n const [isRejected, setIsRejected] = useState(false);\n const dropZoneRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([dropZoneRef, ref]);\n const isDisabled = dropZoneOptions?.disabled || Boolean(loadingElement);\n\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n isDragAccept,\n isDragReject,\n open,\n } = useDropzone({\n ...dropZoneOptions,\n disabled: isDisabled,\n noClick: true,\n onDrop: onDropInterceptor,\n });\n\n const { width } = useResizeObserver({\n ref: dropZoneRef as RefObject<HTMLElement>,\n });\n\n const isUploading = Boolean(loadingElement);\n\n const titleText =\n isDragActive && isDragReject\n ? 'Format not supported'\n : isDragActive && !isDragReject\n ? 'Drop files'\n : null;\n\n const activeDragIcon = isDragReject ? (\n <XCircleSolidIcon className=\"ndl-dropzone-drag-icon ndl-rejected\" />\n ) : isDragAccept ? (\n <DocumentArrowUpSolidIcon className=\"ndl-dropzone-drag-icon ndl-accepted\" />\n ) : (\n <DocumentArrowUpOutlineIcon className=\"ndl-dropzone-upload-icon\" />\n );\n\n const wrapperClasses = classNames('ndl-dropzone', className, {\n 'ndl-drag-active': isDragActive,\n 'ndl-drag-disabled': dropZoneOptions?.disabled,\n 'ndl-dropzone-borderless': !hasBorder,\n 'ndl-file-invalid': isDragActive && isDragReject,\n });\n\n useMemo(() => {\n if (isDragActive && isRejected) {\n setIsRejected(false);\n }\n }, [isDragActive, isRejected]);\n\n return (\n <>\n {isRejected && (\n <Banner className=\"ndl-dropzone-error-alert\" variant=\"danger\">\n <Banner.Header>Error</Banner.Header>\n <Banner.Description>\n {rejectedText ?? 'File extension not supported.'}\n </Banner.Description>\n </Banner>\n )}\n <div\n ref={mergedRef}\n className={wrapperClasses}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-dropzone-inner-wrapper\" {...getRootProps()}>\n <input aria-label=\"Drag and drop area\" {...getInputProps()} />\n <div className=\"ndl-dropzone-inner\">\n {/* Illustration should be visible only after arbitrary width */}\n {width !== undefined && width > 230 && (\n <>\n {isDragActive ? (\n activeDragIcon\n ) : (\n <DocumentArrowUpOutlineIcon className=\"ndl-dropzone-upload-icon\" />\n )}\n </>\n )}\n {!isUploading && (\n <div className=\"ndl-dnd-title-container\">\n <Typography variant=\"subheading-medium\">\n {titleText ||\n (heading ?? (\n <>\n Drag <span className=\"ndl-dnd-title-ampersand\">&</span>{' '}\n Drop\n </>\n ))}\n </Typography>\n {!isDragActive && !isDragReject && (\n <div className=\"ndl-dnd-subtitle\">\n <Typography variant=\"body-medium\">or</Typography>{' '}\n <button\n className=\"ndl-dnd-browse-link\"\n onClick={() => open()}\n disabled={isDisabled}\n type=\"button\"\n >\n Browse\n </button>\n </div>\n )}\n </div>\n )}\n <div className=\"ndl-dropzone-footer\">\n {isUploading && <>{loadingElement}</>}\n {!isUploading && !isDragActive && (\n <div className=\"ndl-file-support-text\">\n {supportedFilesDescription}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n </>\n );\n};\n\nconst DropzoneLoadingProgressBarComponent = ({\n progressBarPrecentage,\n progressBarMinute,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'div', DropzoneLoadingProgressBarProps>) => {\n return (\n <div className=\"ndl-dropzone-loading-progress-bar-wrapper\">\n <div className=\"ndl-dropzone-loading-progress-bar-indicators\">\n <Typography\n className=\"ndl-dropzone-loading-progress-bar-precentage\"\n variant=\"subheading-small\"\n >\n {`${progressBarPrecentage}%`}\n </Typography>\n {Boolean(progressBarMinute) && (\n <Typography\n className=\"ndl-dropzone-loading-progress-bar-minute\"\n variant=\"body-medium\"\n >{`(${progressBarMinute} minutes left)`}</Typography>\n )}\n </div>\n <ProgressBar\n className={classNames('ndl-dropzone-loading-progress-bar', className)}\n value={progressBarPrecentage}\n size=\"large\"\n htmlAttributes={htmlAttributes}\n ref={ref}\n style={style}\n {...restProps}\n />\n </div>\n );\n};\n\nconst Dropzone = Object.assign(DropzoneComponent, {\n LoadingProgressBar: DropzoneLoadingProgressBarComponent,\n});\n\nexport { Dropzone };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0FE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA2JA;CACA;CACA;CACA;CACA;CACA;;;;;;;;;AA3KF,MAAM,qBAAqB,SAac;CAbd,IAAA,EACzB,iBACA,2BACA,gBACA,SACA,cACA,wBACA,YAAY,MACZ,gBACA,OACA,WACA,QAAA,MACG,YAAA,yBAAA,MAAA,SAAA;;;;;;;;CASH,SAAS,kBACP,eACA,gBACA,OACA;;EACA,IAAI,0BAA0B,uBAAuB,SAAS,GACvD;QAAA,MAAM,QAAQ,eAIjB,IAAI,CAHe,uBAAuB,MAAM,cAC9C,KAAK,KAAK,SAAS,SAAS,CAEhB,GAAG;IACf,cAAc,IAAI;IAClB;GACF;;EAGJ,cAAc,KAAK;EACnB,CAAA,wBAAA,gBAAgB,YAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,iBAAS,eAAe,gBAAgB,KAAK;CAC/D;CAEA,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,cA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OACG,YAAA,yBAAA,OAAA,UAAA;CAEH,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,YAAD;IACE,WAAU;IACV,SAAQ;IAEP,UAAA,GAAG,sBAAsB;GAChB,CAAA,GACX,QAAQ,iBAAiB,KACxB,oBAAC,YAAD;IACE,WAAU;IACV,SAAQ;IACR,UAAA,IAAI,kBAAkB;GAA4B,CAAA,CAEnD;EACL,CAAA,GAAA,oBAAC,aAAA,eAAA;GACC,WAAW,WAAW,qCAAqC,SAAS;GACpE,OAAO;GACP,MAAK;GACW;GACX;GACE;EACH,GAAA,SACL,CAAA,CACE;;AAET;AAEA,MAAM,WAAW,OAAO,OAAO,mBAAmB,EAChD,oBAAoB,oCACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Dropzone.mjs","names":["XCircleSolidIcon","DocumentArrowUpSolidIcon","DocumentArrowUpOutlineIcon"],"sources":["../../../src/dropzone/Dropzone.tsx"],"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 { useMergeRefs } from '@floating-ui/react';\nimport classNames from 'classnames';\nimport { type RefObject, useMemo, useRef, useState } from 'react';\nimport {\n type DropEvent,\n type DropzoneOptions,\n type FileRejection,\n useDropzone,\n} from 'react-dropzone';\nimport { useResizeObserver } from 'usehooks-ts';\n\nimport { type CommonProps } from '../_common/types';\nimport { Banner } from '../banner';\nimport DocumentArrowUpOutlineIcon from '../icons/generated/custom/DocumentArrowUpOutline';\nimport DocumentArrowUpSolidIcon from '../icons/generated/custom/DocumentArrowUpSolid';\nimport XCircleSolidIcon from '../icons/generated/custom/XCircleSolid';\nimport { ProgressBar } from '../progress-bar';\nimport { Typography } from '../typography';\n\n/**\n *\n *\n * Types\n *\n *\n */\n/**\n * @remarks\n * Where `DropzoneOptions` is the props for the `react-dropzone` library. For more information, see the [react-dropzone documentation](https://react-dropzone.js.org/#src).\n */\ntype DropzoneProps = {\n /** Props for the underlying `react-dropzone` component. Don't use `accept`. If using custom file extensions as this option is broken. Instead use the `acceptedFileExtensions` property. */\n dropZoneOptions: DropzoneOptions;\n\n /** Informational text that highlights the supported file types, will be displayed in the footer. */\n supportedFilesDescription?: React.ReactNode;\n\n /** Element to display when uploading the file. */\n loadingElement?: React.ReactNode;\n\n /** Use when wanting a custom heading. */\n heading?: React.ReactNode;\n\n /** Message shown when a file is rejected. Defaults to \"File extension not supported.\" when omitted. */\n rejectedText?: React.ReactNode;\n\n /** The accepted file extensions for the Drag-and-Drop. */\n acceptedFileExtensions?: string[];\n\n /** Whether to display the dashed border around the dropzone. */\n hasBorder?: boolean;\n};\n\ntype DropzoneLoadingProgressBarProps = {\n /** The percentage of the progress bar. */\n progressBarPrecentage: number;\n\n /** The time in minute left to upload the file. */\n progressBarMinute?: number;\n};\n\n/**\n *\n *\n * Helpers\n *\n *\n */\n\nconst DropzoneComponent = ({\n dropZoneOptions,\n supportedFilesDescription,\n loadingElement,\n heading,\n rejectedText,\n acceptedFileExtensions,\n hasBorder = true,\n htmlAttributes,\n style,\n className,\n ref,\n ...restProps\n}: CommonProps<'div', DropzoneProps>) => {\n /**\n * We intercept the onDrop function in order to enforce\n * custom file extensions. Before calling the onDrop props we check\n * if the custom file extensions is acceptable. If the extension\n * conforms to acceptedFileExtensions, we call onDrop. Otherwise, we\n * present an error message.\n */\n function onDropInterceptor<T extends File>(\n acceptedFiles: T[],\n fileRejections: FileRejection[],\n event: DropEvent,\n ) {\n if (acceptedFileExtensions && acceptedFileExtensions.length > 0) {\n for (const file of acceptedFiles) {\n const isAccepted = acceptedFileExtensions.some((extension) =>\n file.name.endsWith(extension),\n );\n if (!isAccepted) {\n setIsRejected(true);\n return;\n }\n }\n }\n setIsRejected(false);\n dropZoneOptions.onDrop?.(acceptedFiles, fileRejections, event);\n }\n\n const [isRejected, setIsRejected] = useState(false);\n const dropZoneRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([dropZoneRef, ref]);\n const isDisabled = dropZoneOptions?.disabled || Boolean(loadingElement);\n\n const {\n getRootProps,\n getInputProps,\n isDragActive,\n isDragAccept,\n isDragReject,\n open,\n } = useDropzone({\n ...dropZoneOptions,\n disabled: isDisabled,\n noClick: true,\n onDrop: onDropInterceptor,\n });\n\n const { width } = useResizeObserver({\n ref: dropZoneRef as RefObject<HTMLElement>,\n });\n\n const isUploading = Boolean(loadingElement);\n\n const titleText =\n isDragActive && isDragReject\n ? 'Format not supported'\n : isDragActive && !isDragReject\n ? 'Drop files'\n : null;\n\n const activeDragIcon = isDragReject ? (\n <XCircleSolidIcon className=\"ndl-dropzone-drag-icon ndl-rejected\" />\n ) : isDragAccept ? (\n <DocumentArrowUpSolidIcon className=\"ndl-dropzone-drag-icon ndl-accepted\" />\n ) : (\n <DocumentArrowUpOutlineIcon className=\"ndl-dropzone-upload-icon\" />\n );\n\n const wrapperClasses = classNames('ndl-dropzone', className, {\n 'ndl-drag-active': isDragActive,\n 'ndl-drag-disabled': dropZoneOptions?.disabled,\n 'ndl-dropzone-borderless': !hasBorder,\n 'ndl-file-invalid': isDragActive && isDragReject,\n });\n\n useMemo(() => {\n if (isDragActive && isRejected) {\n setIsRejected(false);\n }\n }, [isDragActive, isRejected]);\n\n return (\n <>\n {isRejected && (\n <Banner className=\"ndl-dropzone-error-alert\" variant=\"danger\">\n <Banner.Header>Error</Banner.Header>\n <Banner.Description>\n {rejectedText ?? 'File extension not supported.'}\n </Banner.Description>\n </Banner>\n )}\n <div\n ref={mergedRef}\n className={wrapperClasses}\n style={style}\n {...restProps}\n {...htmlAttributes}\n >\n <div className=\"ndl-dropzone-inner-wrapper\" {...getRootProps()}>\n <input aria-label=\"Drag and drop area\" {...getInputProps()} />\n <div className=\"ndl-dropzone-inner\">\n {/* Illustration should be visible only after arbitrary width */}\n {width !== undefined && width > 230 && (\n <>\n {isDragActive ? (\n activeDragIcon\n ) : (\n <DocumentArrowUpOutlineIcon className=\"ndl-dropzone-upload-icon\" />\n )}\n </>\n )}\n {!isUploading && (\n <div className=\"ndl-dnd-title-container\">\n <Typography variant=\"subheading-large\">\n {titleText ||\n (heading ?? (\n <>\n Drag <span className=\"ndl-dnd-title-ampersand\">&</span>{' '}\n Drop\n </>\n ))}\n </Typography>\n {!isDragActive && !isDragReject && (\n <div className=\"ndl-dnd-subtitle\">\n <Typography variant=\"body-medium\">or</Typography>{' '}\n <button\n className=\"ndl-dnd-browse-link\"\n onClick={() => open()}\n disabled={isDisabled}\n type=\"button\"\n >\n Browse\n </button>\n </div>\n )}\n </div>\n )}\n <div className=\"ndl-dropzone-footer\">\n {isUploading && <>{loadingElement}</>}\n {!isUploading && !isDragActive && (\n <div className=\"ndl-file-support-text\">\n {supportedFilesDescription}\n </div>\n )}\n </div>\n </div>\n </div>\n </div>\n </>\n );\n};\n\nconst DropzoneLoadingProgressBarComponent = ({\n progressBarPrecentage,\n progressBarMinute,\n htmlAttributes,\n className,\n style,\n ref,\n ...restProps\n}: CommonProps<'div', DropzoneLoadingProgressBarProps>) => {\n return (\n <div className=\"ndl-dropzone-loading-progress-bar-wrapper\">\n <div className=\"ndl-dropzone-loading-progress-bar-indicators\">\n <Typography\n className=\"ndl-dropzone-loading-progress-bar-precentage\"\n variant=\"subheading-medium\"\n >\n {`${progressBarPrecentage}%`}\n </Typography>\n {Boolean(progressBarMinute) && (\n <Typography\n className=\"ndl-dropzone-loading-progress-bar-minute\"\n variant=\"body-medium\"\n >{`(${progressBarMinute} minutes left)`}</Typography>\n )}\n </div>\n <ProgressBar\n className={classNames('ndl-dropzone-loading-progress-bar', className)}\n value={progressBarPrecentage}\n size=\"large\"\n htmlAttributes={htmlAttributes}\n ref={ref}\n style={style}\n {...restProps}\n />\n </div>\n );\n};\n\nconst Dropzone = Object.assign(DropzoneComponent, {\n LoadingProgressBar: DropzoneLoadingProgressBarComponent,\n});\n\nexport { Dropzone };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0FE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;CA2JA;CACA;CACA;CACA;CACA;CACA;;;;;;;;;AA3KF,MAAM,qBAAqB,SAac;CAbd,IAAA,EACzB,iBACA,2BACA,gBACA,SACA,cACA,wBACA,YAAY,MACZ,gBACA,OACA,WACA,QAAA,MACG,YAAA,yBAAA,MAAA,SAAA;;;;;;;;CASH,SAAS,kBACP,eACA,gBACA,OACA;;EACA,IAAI,0BAA0B,uBAAuB,SAAS,GACvD;QAAA,MAAM,QAAQ,eAIjB,IAAI,CAHe,uBAAuB,MAAM,cAC9C,KAAK,KAAK,SAAS,SAAS,CAEhB,GAAG;IACf,cAAc,IAAI;IAClB;GACF;;EAGJ,cAAc,KAAK;EACnB,CAAA,wBAAA,gBAAgB,YAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,iBAAS,eAAe,gBAAgB,KAAK;CAC/D;CAEA,MAAM,CAAC,YAAY,iBAAiB,SAAS,KAAK;CAClD,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,YAAY,aAAa,CAAC,aAAa,GAAG,CAAC;CACjD,MAAM,cAAA,oBAAA,QAAA,oBAAA,KAAA,IAAA,KAAA,IAAa,gBAAiB,aAAY,QAAQ,cAAc;CAEtE,MAAM,EACJ,cACA,eACA,cACA,cACA,cACA,SACE,YAAA,eAAA,eAAA,CAAA,GACC,eAAA,GAAA,CAAA,GAAA;EACH,UAAU;EACV,SAAS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,kBAAkB;GAA4B,CAAA,CAEnD;EACL,CAAA,GAAA,oBAAC,aAAA,eAAA;GACC,WAAW,WAAW,qCAAqC,SAAS;GACpE,OAAO;GACP,MAAK;GACW;GACX;GACE;EACH,GAAA,SACL,CAAA,CACE;;AAET;AAEA,MAAM,WAAW,OAAO,OAAO,mBAAmB,EAChD,oBAAoB,oCACtB,CAAC"}
|
package/lib/esm/icons/index.mjs
CHANGED
|
@@ -29,6 +29,7 @@ import { BarsArrowUpIconOutline } from "./generated/heroIcons/BarsArrowUpIconOut
|
|
|
29
29
|
import { ChevronDownIconSolid } from "./generated/heroIcons/ChevronDownIconSolid.mjs";
|
|
30
30
|
import { ChevronLeftIconOutline } from "./generated/heroIcons/ChevronLeftIconOutline.mjs";
|
|
31
31
|
import { EllipsisHorizontalIconOutline } from "./generated/heroIcons/EllipsisHorizontalIconOutline.mjs";
|
|
32
|
+
import SvgMagnifyingGlassOutline from "./generated/custom/MagnifyingGlassOutline.mjs";
|
|
32
33
|
import SvgAcademicCapOutline from "./generated/custom/AcademicCapOutline.mjs";
|
|
33
34
|
import SvgAdjustmentsHorizontalOutline from "./generated/custom/AdjustmentsHorizontalOutline.mjs";
|
|
34
35
|
import SvgAdjustmentsVerticalOutline from "./generated/custom/AdjustmentsVerticalOutline.mjs";
|
|
@@ -403,7 +404,6 @@ import SvgLockOpenOutline from "./generated/custom/LockOpenOutline.mjs";
|
|
|
403
404
|
import SvgLogOutOutline from "./generated/custom/LogOutOutline.mjs";
|
|
404
405
|
import SvgMagnifyingGlassCircleOutline from "./generated/custom/MagnifyingGlassCircleOutline.mjs";
|
|
405
406
|
import SvgMagnifyingGlassMinusOutline from "./generated/custom/MagnifyingGlassMinusOutline.mjs";
|
|
406
|
-
import SvgMagnifyingGlassOutline from "./generated/custom/MagnifyingGlassOutline.mjs";
|
|
407
407
|
import SvgMagnifyingGlassPlusOutline from "./generated/custom/MagnifyingGlassPlusOutline.mjs";
|
|
408
408
|
import SvgMagnifyingGlassResetOutline from "./generated/custom/MagnifyingGlassResetOutline.mjs";
|
|
409
409
|
import SvgMagnifyingGlassReset from "./generated/custom/MagnifyingGlassReset.mjs";
|
package/lib/esm/index.mjs
CHANGED
|
@@ -20,6 +20,7 @@ import { Popover, placementTranslation, usePopoverContext } from "./popover/Popo
|
|
|
20
20
|
import { ProgressBar } from "./progress-bar/ProgressBar.mjs";
|
|
21
21
|
import { Dropzone } from "./dropzone/Dropzone.mjs";
|
|
22
22
|
import { TextInput } from "./text-input/TextInput.mjs";
|
|
23
|
+
import { SearchField } from "./search-field/SearchField.mjs";
|
|
23
24
|
import { TextArea } from "./text-area/TextArea.mjs";
|
|
24
25
|
import { TextLink } from "./text-link/TextLink.mjs";
|
|
25
26
|
import { Select } from "./select/Select.mjs";
|
|
@@ -32,19 +33,19 @@ import { SideNavigation } from "./side-navigation/SideNavigation.mjs";
|
|
|
32
33
|
import { Typography } from "./typography/Typography.mjs";
|
|
33
34
|
import { Drawer } from "./drawer/Drawer.mjs";
|
|
34
35
|
import { Breadcrumbs } from "./breadcrumbs/Breadcrumbs.mjs";
|
|
35
|
-
import { useCopyToClipboard, useDebounceValue, useEffectDebugger, useEventListener, useInterval, useMediaQuery, useOnClickOutside, usePrevious, useRenderCount, useRenderDebugger, useResizeObserver, useScrollLock, useWindowSize } from "./hooks/index.mjs";
|
|
36
36
|
import { useDataGridContext } from "./data-grid/data-grid-context.mjs";
|
|
37
37
|
import { helpers_exports } from "./data-grid/helpers/index.mjs";
|
|
38
38
|
import { useDebounceCallback } from "./hooks/use-debounce-callback/index.mjs";
|
|
39
|
+
import { useCopyToClipboard, useDebounceValue, useEffectDebugger, useEventListener, useInterval, useMediaQuery, useOnClickOutside, usePrevious, useRenderCount, useRenderDebugger, useResizeObserver, useScrollLock, useWindowSize } from "./hooks/index.mjs";
|
|
39
40
|
import { Box } from "./box/Box.mjs";
|
|
40
41
|
import { Flex } from "./flex/Flex.mjs";
|
|
41
|
-
import { Avatar } from "./avatar/Avatar.mjs";
|
|
42
42
|
import { evaluateDataGridStyleRules } from "./data-grid/style-rules/evaluate.mjs";
|
|
43
43
|
import { useDataGridCellStyle } from "./data-grid/style-rules/hooks.mjs";
|
|
44
44
|
import { DataGridNav } from "./data-grid/data-grid-nav/data-grid-nav.mjs";
|
|
45
45
|
import { useTableNav } from "./data-grid/data-grid-nav/index.mjs";
|
|
46
46
|
import { DataGrid } from "./data-grid/DataGrid.mjs";
|
|
47
47
|
import { isDataGridStyleRule } from "./data-grid/style-rules/guard.mjs";
|
|
48
|
+
import { Avatar } from "./avatar/Avatar.mjs";
|
|
48
49
|
import { Logo } from "./logo/Logo.mjs";
|
|
49
50
|
import { ClipboardButton } from "./clipboard-button/ClipboardButton.mjs";
|
|
50
51
|
import { Slider } from "./slider/Slider.mjs";
|
|
@@ -101,6 +102,6 @@ import { Combobox } from "./combobox/Combobox.mjs";
|
|
|
101
102
|
* You should have received a copy of the GNU General Public License
|
|
102
103
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
103
104
|
*/
|
|
104
|
-
export { Accordion, AnnouncementBanner, Avatar, Banner, Box, Breadcrumbs, Checkbox, CheckboxGroup, CleanIconButton, ClipboardButton, Code, CodeBlock, ColorPicker, Combobox, ConditionalWrap, DataGrid, DataGridNav, DatePicker, Dialog, DismissibleTag, Divider, Drawer, DropdownButton, Dropzone, Fieldset, FilledButton, Flex, GraphLabel, IconButton, IconButtonArray, InlineEdit, Kbd, LoadingBar, LoadingSpinner, Logo, Menu, NeedleThemeProvider, NeedleTime, OperationalTag, OutlinedButton, Popover, ProgressBar, Radio, RadioGroup, ReadOnlyTag, SegmentedControl, Select, SelectIconButton, SelectableTag, SideNavigation, Skeleton, Slider, Spotlight, SpotlightProvider, SpotlightTarget, SpotlightTour, StatusIndicator, StatusLabel, Switch, Tabs, Tag, TextArea, TextButton, TextInput, TextLink, ThemeContext, TimePicker, TimeZonePicker, Toaster, ToasterControlled, TokensContext, Tooltip, TreeView, Typography, Wizard, helpers_exports as dataGridUtils, evaluateDataGridStyleRules, isDataGridStyleRule, useToken as n, useToken, placementTranslation, toast, useCopyToClipboard, useDataGridCellStyle, useDataGridContext, useDebounceCallback, useDebounceValue, useEffectDebugger, useEventListener, useInterval, useMediaQuery, useNeedleTheme, useOnClickOutside, usePopoverContext, usePrevious, useRenderCount, useRenderDebugger, useResizeObserver, useScrollLock, useSpotlightContext, useTableNav, useWindowSize };
|
|
105
|
+
export { Accordion, AnnouncementBanner, Avatar, Banner, Box, Breadcrumbs, Checkbox, CheckboxGroup, CleanIconButton, ClipboardButton, Code, CodeBlock, ColorPicker, Combobox, ConditionalWrap, DataGrid, DataGridNav, DatePicker, Dialog, DismissibleTag, Divider, Drawer, DropdownButton, Dropzone, Fieldset, FilledButton, Flex, GraphLabel, IconButton, IconButtonArray, InlineEdit, Kbd, LoadingBar, LoadingSpinner, Logo, Menu, NeedleThemeProvider, NeedleTime, OperationalTag, OutlinedButton, Popover, ProgressBar, Radio, RadioGroup, ReadOnlyTag, SearchField, SegmentedControl, Select, SelectIconButton, SelectableTag, SideNavigation, Skeleton, Slider, Spotlight, SpotlightProvider, SpotlightTarget, SpotlightTour, StatusIndicator, StatusLabel, Switch, Tabs, Tag, TextArea, TextButton, TextInput, TextLink, ThemeContext, TimePicker, TimeZonePicker, Toaster, ToasterControlled, TokensContext, Tooltip, TreeView, Typography, Wizard, helpers_exports as dataGridUtils, evaluateDataGridStyleRules, isDataGridStyleRule, useToken as n, useToken, placementTranslation, toast, useCopyToClipboard, useDataGridCellStyle, useDataGridContext, useDebounceCallback, useDebounceValue, useEffectDebugger, useEventListener, useInterval, useMediaQuery, useNeedleTheme, useOnClickOutside, usePopoverContext, usePrevious, useRenderCount, useRenderDebugger, useResizeObserver, useScrollLock, useSpotlightContext, useTableNav, useWindowSize };
|
|
105
106
|
|
|
106
107
|
//# sourceMappingURL=index.mjs.map
|
package/lib/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"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 */\n\nexport { Accordion } from './accordion';\nexport { StatusLabel } from './status-label';\nexport { Banner } from './banner';\nexport { AnnouncementBanner } from './announcement-banner';\nexport { Checkbox } from './checkbox';\nexport { CheckboxGroup } from './checkbox-group';\nexport { Fieldset } from './fieldset';\nexport { Switch } from './switch';\nexport { Radio } from './radio';\nexport { RadioGroup } from './radio-group';\nexport { Menu } from './menu';\nexport { DatePicker } from './date-picker';\nexport { Dialog } from './dialog';\nexport { LoadingSpinner } from './loading-spinner';\nexport { Tabs } from './tabs';\nexport { SegmentedControl } from './segmented-control';\nexport * from './popover';\nexport { ProgressBar } from './progress-bar';\nexport { Dropzone } from './dropzone';\nexport * from './data-grid';\nexport { TextInput } from './text-input';\nexport { TextArea } from './text-area';\nexport { TextLink } from './text-link';\nexport { Select } from './select';\nexport { Tag } from './tag';\nexport * from './theme';\nexport { Wizard } from './wizard';\nexport { GraphLabel } from './graph-label';\nexport { CodeBlock } from './code-block';\nexport { StatusIndicator } from './status-indicator';\nexport { SideNavigation } from './side-navigation';\nexport { Typography } from './typography';\nexport { Drawer } from './drawer';\nexport { Breadcrumbs } from './breadcrumbs';\nexport * from './hooks';\nexport { Box } from './box';\nexport { Flex } from './flex';\nexport { Avatar } from './avatar';\nexport { Logo } from './logo';\nexport { ClipboardButton } from './clipboard-button';\nexport { Slider } from './slider';\nexport { InlineEdit } from './inline-edit';\nexport { DropdownButton } from './dropdown-button';\nexport { Divider } from './divider';\nexport * from './tree-view';\nexport { ToasterControlled, Toaster, toast, type ToastId } from './toast';\nexport { Tooltip } from './tooltip';\nexport { Skeleton } from './skeleton';\nexport { TimePicker, NeedleTime } from './time-picker';\nexport { TimeZonePicker } from './timezone-picker';\nexport {\n Spotlight,\n SpotlightProvider,\n SpotlightTarget,\n SpotlightTour,\n useSpotlightContext,\n} from './spotlight';\nexport { LoadingBar } from './loading-bar';\nexport { IconButton } from './icon-button';\nexport { CleanIconButton } from './clean-icon-button';\nexport { IconButtonArray } from './icon-button-array';\nexport { ConditionalWrap } from './conditional-wrap';\nexport { ColorPicker } from './color-picker';\nexport { OutlinedButton } from './outlined-button';\nexport { FilledButton } from './filled-button';\nexport { TextButton } from './text-button';\nexport { Code } from './code';\nexport { Kbd } from './kbd';\nexport { SelectIconButton } from './select-icon-button';\nexport { ReadOnlyTag } from './read-only-tag';\nexport { DismissibleTag } from './dismissible-tag';\nexport { SelectableTag } from './selectable-tag';\nexport { OperationalTag } from './operational-tag';\nexport * from './combobox';\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"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 */\n\nexport { Accordion } from './accordion';\nexport { StatusLabel } from './status-label';\nexport { Banner } from './banner';\nexport { AnnouncementBanner } from './announcement-banner';\nexport { Checkbox } from './checkbox';\nexport { CheckboxGroup } from './checkbox-group';\nexport { Fieldset } from './fieldset';\nexport { Switch } from './switch';\nexport { Radio } from './radio';\nexport { RadioGroup } from './radio-group';\nexport { Menu } from './menu';\nexport { DatePicker } from './date-picker';\nexport { Dialog } from './dialog';\nexport { LoadingSpinner } from './loading-spinner';\nexport { Tabs } from './tabs';\nexport { SegmentedControl } from './segmented-control';\nexport * from './popover';\nexport { ProgressBar } from './progress-bar';\nexport { Dropzone } from './dropzone';\nexport * from './data-grid';\nexport { TextInput } from './text-input';\nexport { SearchField } from './search-field';\nexport { TextArea } from './text-area';\nexport { TextLink } from './text-link';\nexport { Select } from './select';\nexport { Tag } from './tag';\nexport * from './theme';\nexport { Wizard } from './wizard';\nexport { GraphLabel } from './graph-label';\nexport { CodeBlock } from './code-block';\nexport { StatusIndicator } from './status-indicator';\nexport { SideNavigation } from './side-navigation';\nexport { Typography } from './typography';\nexport { Drawer } from './drawer';\nexport { Breadcrumbs } from './breadcrumbs';\nexport * from './hooks';\nexport { Box } from './box';\nexport { Flex } from './flex';\nexport { Avatar } from './avatar';\nexport { Logo } from './logo';\nexport { ClipboardButton } from './clipboard-button';\nexport { Slider } from './slider';\nexport { InlineEdit } from './inline-edit';\nexport { DropdownButton } from './dropdown-button';\nexport { Divider } from './divider';\nexport * from './tree-view';\nexport { ToasterControlled, Toaster, toast, type ToastId } from './toast';\nexport { Tooltip } from './tooltip';\nexport { Skeleton } from './skeleton';\nexport { TimePicker, NeedleTime } from './time-picker';\nexport { TimeZonePicker } from './timezone-picker';\nexport {\n Spotlight,\n SpotlightProvider,\n SpotlightTarget,\n SpotlightTour,\n useSpotlightContext,\n} from './spotlight';\nexport { LoadingBar } from './loading-bar';\nexport { IconButton } from './icon-button';\nexport { CleanIconButton } from './clean-icon-button';\nexport { IconButtonArray } from './icon-button-array';\nexport { ConditionalWrap } from './conditional-wrap';\nexport { ColorPicker } from './color-picker';\nexport { OutlinedButton } from './outlined-button';\nexport { FilledButton } from './filled-button';\nexport { TextButton } from './text-button';\nexport { Code } from './code';\nexport { Kbd } from './kbd';\nexport { SelectIconButton } from './select-icon-button';\nexport { ReadOnlyTag } from './read-only-tag';\nexport { DismissibleTag } from './dismissible-tag';\nexport { SelectableTag } from './selectable-tag';\nexport { OperationalTag } from './operational-tag';\nexport * from './combobox';\n"],"mappings":""}
|
|
@@ -59,7 +59,7 @@ const _excluded = [
|
|
|
59
59
|
const MINIMUM_WIDTH = 320;
|
|
60
60
|
const InlineEdit = (_ref) => {
|
|
61
61
|
var _ref2;
|
|
62
|
-
let { as, className, defaultValue, htmlAttributes, label, ariaLabel, onChange, onCancel, onConfirm, ref, style, value, hasEditIcon = false, inputProps, isDisabled = false, isEditing, blurBehavior = "confirm", isFluid = false, typographyVariant = "subheading-
|
|
62
|
+
let { as, className, defaultValue, htmlAttributes, label, ariaLabel, onChange, onCancel, onConfirm, ref, style, value, hasEditIcon = false, inputProps, isDisabled = false, isEditing, blurBehavior = "confirm", isFluid = false, typographyVariant = "subheading-large", placeholder } = _ref, restProps = _objectWithoutProperties(_ref, _excluded);
|
|
63
63
|
const [hasEditMode, setEditMode] = useState(false);
|
|
64
64
|
const [currentValue, setCurrentValue] = useSemicontrolledState({
|
|
65
65
|
isControlled: value !== void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineEdit.mjs","names":[],"sources":["../../../src/inline-edit/InlineEdit.tsx"],"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 classNames from 'classnames';\nimport type React from 'react';\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFocusWithin } from 'react-aria';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { useSemicontrolledState } from '../_common/use-semi-controlled-state';\nimport { needleWarningMessage, randomId } from '../_common/utils';\nimport { IconButton } from '../icon-button';\nimport { CheckIconOutline } from '../icons/generated/heroIcons/CheckIconOutline';\nimport { PencilIconOutline } from '../icons/generated/heroIcons/PencilIconOutline';\nimport { XMarkIconOutline } from '../icons/generated/heroIcons/XMarkIconOutline';\nimport { Typography } from '../typography';\nimport { type TypographyVariants } from '../typography';\nimport { getIconStyle, getMinHeight } from './utils';\n\ntype InlineEditProps = {\n /** Label text */\n label?: ReactNode;\n\n /**\n * The aria label for the input. If not provided, defaults to the `label` text, or a generic\n * \"Inline edit input\" string as a last resort.\n */\n ariaLabel?: string;\n\n /**\n * The typographyVariant of the component applied to Typography as its variant.\n * @default subheading-medium\n */\n typographyVariant?: TypographyVariants;\n\n /**\n * The default input value. Use for an uncontrolled component.\n */\n defaultValue?: string;\n\n /**\n * The input value. Makes the component controlled.\n */\n value?: string;\n\n /**\n * Callback when the input value changes. Must be used when the component is controlled.\n */\n onChange?: (value: string) => void;\n\n /**\n * Placeholder text displayed when the input is empty.\n */\n placeholder: string;\n\n /**\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * If edit pencil icon should be visible on hover\n * @default false\n */\n hasEditIcon?: boolean;\n\n /**\n * If the input is in editing mode\n * Used in a stateless inline edit\n * @default undefined\n */\n isEditing?: boolean;\n\n /** Callback when confirm icon button is pressed */\n onConfirm?: (\n value: string,\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n\n /** Callback when cancel icon button is pressed */\n onCancel?: (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n\n /**\n * What the input should do on blur\n * - \"confirm\" will confirm the value\n * - \"cancel\" will cancel the value\n * - \"none\" will do nothing\n * @default \"confirm\"\n */\n blurBehavior?: 'confirm' | 'cancel' | 'none';\n\n /** props applied to the internal input element */\n inputProps?: HtmlAttributes<'input'>;\n\n /**\n * If the input is fluid\n * @default false\n */\n isFluid?: boolean;\n};\n\n// The input should not be less than this (it does shrink if container is smaller though).\nconst MINIMUM_WIDTH = 320;\n\nexport const InlineEdit = <T extends React.ElementType = 'div'>({\n as,\n className,\n defaultValue,\n htmlAttributes,\n label,\n ariaLabel,\n onChange,\n onCancel,\n onConfirm,\n ref,\n style,\n value,\n hasEditIcon = false,\n inputProps,\n isDisabled = false,\n isEditing,\n blurBehavior = 'confirm',\n isFluid = false,\n typographyVariant = 'subheading-medium',\n placeholder,\n ...restProps\n}: PolymorphicCommonProps<T, InlineEditProps>) => {\n const [hasEditMode, setEditMode] = useState(false);\n\n const [currentValue, setCurrentValue] = useSemicontrolledState({\n isControlled: value !== undefined,\n onChange,\n state: value ?? defaultValue ?? '',\n });\n const [previousConfirmedValue, setPreviousConfirmedValue] =\n useState(currentValue);\n\n const mirrorRef = useRef<HTMLSpanElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n /**\n * This ref is used to prevent the blur behavior from being triggered on mouse down events\n * on the confirm and cancel buttons. So when true, the blur behavior is not triggered.\n * This is needed due to Webkit browsers (like Safari) triggering blur on mouse down events.\n *\n * It is also used to prevent the blur behavior from being triggered after the component exits edit mode without blur.\n * This bug caused the handler to be called when something was focused after confirming.\n */\n const blurWithinRef = useRef(false);\n\n // Validate controlled mode requirements\n useEffect(() => {\n if (value !== undefined && onChange === undefined) {\n needleWarningMessage(\n 'onChange prop should be supplied when using controlled mode (value prop is provided).',\n );\n }\n }, [value, onChange]);\n\n const { focusWithinProps } = useFocusWithin({\n onBlurWithin: () => {\n if (blurWithinRef.current) {\n return;\n }\n\n if (blurBehavior === 'confirm') {\n onConfirmHandler();\n return;\n }\n if (blurBehavior === 'cancel') {\n onCancelHandler();\n return;\n }\n },\n });\n\n const resetToDefaults = useCallback(() => {\n // In controlled mode, don't reset the value - let the parent manage it\n // In uncontrolled mode, reset to default value\n if (value === undefined) {\n setCurrentValue(previousConfirmedValue ?? '');\n }\n // Only reset edit mode if isEditing is not controlled (undefined)\n if (isEditing === undefined) {\n blurWithinRef.current = true;\n setEditMode(false);\n }\n }, [previousConfirmedValue, isEditing, setCurrentValue, value]);\n\n const resetEditState = useCallback(() => {\n // Only reset edit mode if isEditing is not controlled (undefined)\n if (isEditing === undefined) {\n blurWithinRef.current = true;\n setEditMode(false);\n }\n }, [isEditing]);\n\n const onConfirmHandler = useCallback(\n async (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => {\n setPreviousConfirmedValue(currentValue);\n onConfirm?.(currentValue, event);\n resetEditState();\n },\n [onConfirm, currentValue, resetEditState],\n );\n\n const onCancelHandler = useCallback(\n (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => {\n onCancel?.(event);\n resetToDefaults();\n },\n [onCancel, resetToDefaults],\n );\n\n const inputID = useMemo(() => {\n return inputProps?.id ?? randomId(12);\n }, [inputProps?.id]);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (['Enter', 'Escape'].includes(event.key)) {\n if (event.key === 'Enter') {\n onConfirmHandler();\n }\n if (event.key === 'Escape') {\n onCancelHandler();\n }\n event.preventDefault();\n event.stopPropagation();\n }\n },\n [onConfirmHandler, onCancelHandler],\n );\n\n const handleInputChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = event.target.value;\n setCurrentValue(newValue);\n },\n [setCurrentValue],\n );\n\n const isInEditMode = isEditing ?? hasEditMode;\n\n const handleEditClick = useCallback(() => {\n if (isDisabled === false) {\n setEditMode(true);\n blurWithinRef.current = false;\n }\n }, [isDisabled]);\n\n const updateInputWidth = useCallback(() => {\n if (mirrorRef.current && containerRef.current && !isFluid) {\n const mirrorWidth = mirrorRef.current.offsetWidth;\n const newWidth = Math.max(mirrorWidth, MINIMUM_WIDTH);\n containerRef.current.style.width = `${newWidth}px`;\n }\n }, [mirrorRef, containerRef, isFluid]);\n\n // Width calculation effect\n useLayoutEffect(() => {\n updateInputWidth();\n }, [updateInputWidth, isInEditMode, currentValue]);\n\n const displayText = currentValue || placeholder;\n const buttonAriaLabel = `${displayText}, edit`;\n const inputAriaLabel =\n ariaLabel ?? (typeof label === 'string' ? label : 'Inline edit input');\n\n return (\n <Typography\n as={as ?? 'div'}\n variant={typographyVariant}\n className={classNames('ndl-inline-edit', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-fluid': isFluid,\n })}\n style={style}\n ref={ref}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {Boolean(label) && <label htmlFor={inputID}>{label}</label>}\n {isInEditMode === true ? (\n <div\n className=\"ndl-inline-edit-container\"\n ref={containerRef}\n {...focusWithinProps}\n >\n {/* Mirror span for measuring width */}\n <span\n aria-hidden={true}\n className=\"ndl-inline-edit-mirror\"\n ref={mirrorRef}\n >\n {displayText}\n </span>\n <input\n {...inputProps}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n aria-label={inputAriaLabel}\n className={classNames(\n 'ndl-inline-edit-input',\n inputProps?.className,\n )}\n id={inputID}\n value={currentValue}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n />\n <div className=\"ndl-inline-edit-buttons\">\n <IconButton\n description=\"Accept\"\n tooltipProps={{\n root: { placement: 'bottom' },\n }}\n onClick={onConfirmHandler}\n size=\"small\"\n isFloating={true}\n htmlAttributes={{\n onMouseDown: () => {\n blurWithinRef.current = true;\n },\n }}\n >\n <CheckIconOutline />\n </IconButton>\n <IconButton\n description=\"Cancel\"\n tooltipProps={{\n root: { placement: 'bottom' },\n }}\n onClick={(event) => onCancelHandler(event)}\n size=\"small\"\n isFloating={true}\n htmlAttributes={{\n onMouseDown: () => {\n blurWithinRef.current = true;\n },\n }}\n >\n <XMarkIconOutline />\n </IconButton>\n </div>\n </div>\n ) : (\n <button\n type=\"button\"\n className={classNames('ndl-inline-idle-container', {\n 'ndl-disabled': isDisabled,\n 'ndl-has-edit-icon': hasEditIcon,\n 'ndl-placeholder': displayText === placeholder,\n })}\n aria-disabled={isDisabled}\n aria-label={buttonAriaLabel}\n disabled={isDisabled}\n onClick={handleEditClick}\n style={{\n minHeight: getMinHeight(typographyVariant),\n }}\n >\n <span className=\"ndl-inline-edit-text\">{displayText}</span>\n {hasEditIcon && (\n <PencilIconOutline\n className=\"ndl-inline-edit-pencil-icon\"\n style={getIconStyle(typographyVariant)}\n />\n )}\n </button>\n )}\n </Typography>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuIE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAtBF,MAAM,gBAAgB;AAEtB,MAAa,cAAmD,SAsBd;;CAtBc,IAAA,EAC9D,IACA,WACA,cACA,gBACA,OACA,WACA,UACA,UACA,WACA,KACA,OACA,OACA,cAAc,OACd,YACA,aAAa,OACb,WACA,eAAe,WACf,UAAU,OACV,oBAAoB,qBACpB,gBAAA,MACG,YAAA,yBAAA,MAAA,SAAA;CAEH,MAAM,CAAC,aAAa,eAAe,SAAS,KAAK;CAEjD,MAAM,CAAC,cAAc,mBAAmB,uBAAuB;EAC7D,cAAc,UAAU,KAAA;EACxB;EACA,QAAA,QAAO,UAAA,QAAA,UAAA,KAAA,IAAA,QAAS,kBAAA,QAAA,UAAA,KAAA,IAAA,QAAgB;CAClC,CAAC;CACD,MAAM,CAAC,wBAAwB,6BAC7B,SAAS,YAAY;CAEvB,MAAM,YAAY,OAAwB,IAAI;CAC9C,MAAM,eAAe,OAAuB,IAAI;;;;;;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AC;EACD,iBAAe;EACf,cAAY;EACZ,UAAU;EACV,SAAS;EACT,OAAO,EACL,WAAW,aAAa,iBAAiB,EAC3C;EAbF,UAAA,CAeE,oBAAC,QAAD;GAAM,WAAU;GAAwB,UAAA;EAAkB,CAAA,GACzD,eACC,oBAAC,mBAAD;GACE,WAAU;GACV,OAAO,aAAa,iBAAiB;EACtC,CAAA,CAEG;CAEA,CAAA,CAAA,EAAA,CAAA,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"InlineEdit.mjs","names":[],"sources":["../../../src/inline-edit/InlineEdit.tsx"],"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 classNames from 'classnames';\nimport type React from 'react';\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useFocusWithin } from 'react-aria';\n\nimport {\n type HtmlAttributes,\n type PolymorphicCommonProps,\n} from '../_common/types';\nimport { useSemicontrolledState } from '../_common/use-semi-controlled-state';\nimport { needleWarningMessage, randomId } from '../_common/utils';\nimport { IconButton } from '../icon-button';\nimport { CheckIconOutline } from '../icons/generated/heroIcons/CheckIconOutline';\nimport { PencilIconOutline } from '../icons/generated/heroIcons/PencilIconOutline';\nimport { XMarkIconOutline } from '../icons/generated/heroIcons/XMarkIconOutline';\nimport { Typography } from '../typography';\nimport { type TypographyVariants } from '../typography';\nimport { getIconStyle, getMinHeight } from './utils';\n\ntype InlineEditProps = {\n /** Label text */\n label?: ReactNode;\n\n /**\n * The aria label for the input. If not provided, defaults to the `label` text, or a generic\n * \"Inline edit input\" string as a last resort.\n */\n ariaLabel?: string;\n\n /**\n * The typographyVariant of the component applied to Typography as its variant.\n * @default subheading-large\n */\n typographyVariant?: TypographyVariants;\n\n /**\n * The default input value. Use for an uncontrolled component.\n */\n defaultValue?: string;\n\n /**\n * The input value. Makes the component controlled.\n */\n value?: string;\n\n /**\n * Callback when the input value changes. Must be used when the component is controlled.\n */\n onChange?: (value: string) => void;\n\n /**\n * Placeholder text displayed when the input is empty.\n */\n placeholder: string;\n\n /**\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * If edit pencil icon should be visible on hover\n * @default false\n */\n hasEditIcon?: boolean;\n\n /**\n * If the input is in editing mode\n * Used in a stateless inline edit\n * @default undefined\n */\n isEditing?: boolean;\n\n /** Callback when confirm icon button is pressed */\n onConfirm?: (\n value: string,\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n\n /** Callback when cancel icon button is pressed */\n onCancel?: (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => void;\n\n /**\n * What the input should do on blur\n * - \"confirm\" will confirm the value\n * - \"cancel\" will cancel the value\n * - \"none\" will do nothing\n * @default \"confirm\"\n */\n blurBehavior?: 'confirm' | 'cancel' | 'none';\n\n /** props applied to the internal input element */\n inputProps?: HtmlAttributes<'input'>;\n\n /**\n * If the input is fluid\n * @default false\n */\n isFluid?: boolean;\n};\n\n// The input should not be less than this (it does shrink if container is smaller though).\nconst MINIMUM_WIDTH = 320;\n\nexport const InlineEdit = <T extends React.ElementType = 'div'>({\n as,\n className,\n defaultValue,\n htmlAttributes,\n label,\n ariaLabel,\n onChange,\n onCancel,\n onConfirm,\n ref,\n style,\n value,\n hasEditIcon = false,\n inputProps,\n isDisabled = false,\n isEditing,\n blurBehavior = 'confirm',\n isFluid = false,\n typographyVariant = 'subheading-large',\n placeholder,\n ...restProps\n}: PolymorphicCommonProps<T, InlineEditProps>) => {\n const [hasEditMode, setEditMode] = useState(false);\n\n const [currentValue, setCurrentValue] = useSemicontrolledState({\n isControlled: value !== undefined,\n onChange,\n state: value ?? defaultValue ?? '',\n });\n const [previousConfirmedValue, setPreviousConfirmedValue] =\n useState(currentValue);\n\n const mirrorRef = useRef<HTMLSpanElement>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n /**\n * This ref is used to prevent the blur behavior from being triggered on mouse down events\n * on the confirm and cancel buttons. So when true, the blur behavior is not triggered.\n * This is needed due to Webkit browsers (like Safari) triggering blur on mouse down events.\n *\n * It is also used to prevent the blur behavior from being triggered after the component exits edit mode without blur.\n * This bug caused the handler to be called when something was focused after confirming.\n */\n const blurWithinRef = useRef(false);\n\n // Validate controlled mode requirements\n useEffect(() => {\n if (value !== undefined && onChange === undefined) {\n needleWarningMessage(\n 'onChange prop should be supplied when using controlled mode (value prop is provided).',\n );\n }\n }, [value, onChange]);\n\n const { focusWithinProps } = useFocusWithin({\n onBlurWithin: () => {\n if (blurWithinRef.current) {\n return;\n }\n\n if (blurBehavior === 'confirm') {\n onConfirmHandler();\n return;\n }\n if (blurBehavior === 'cancel') {\n onCancelHandler();\n return;\n }\n },\n });\n\n const resetToDefaults = useCallback(() => {\n // In controlled mode, don't reset the value - let the parent manage it\n // In uncontrolled mode, reset to default value\n if (value === undefined) {\n setCurrentValue(previousConfirmedValue ?? '');\n }\n // Only reset edit mode if isEditing is not controlled (undefined)\n if (isEditing === undefined) {\n blurWithinRef.current = true;\n setEditMode(false);\n }\n }, [previousConfirmedValue, isEditing, setCurrentValue, value]);\n\n const resetEditState = useCallback(() => {\n // Only reset edit mode if isEditing is not controlled (undefined)\n if (isEditing === undefined) {\n blurWithinRef.current = true;\n setEditMode(false);\n }\n }, [isEditing]);\n\n const onConfirmHandler = useCallback(\n async (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => {\n setPreviousConfirmedValue(currentValue);\n onConfirm?.(currentValue, event);\n resetEditState();\n },\n [onConfirm, currentValue, resetEditState],\n );\n\n const onCancelHandler = useCallback(\n (\n event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n ) => {\n onCancel?.(event);\n resetToDefaults();\n },\n [onCancel, resetToDefaults],\n );\n\n const inputID = useMemo(() => {\n return inputProps?.id ?? randomId(12);\n }, [inputProps?.id]);\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent) => {\n if (['Enter', 'Escape'].includes(event.key)) {\n if (event.key === 'Enter') {\n onConfirmHandler();\n }\n if (event.key === 'Escape') {\n onCancelHandler();\n }\n event.preventDefault();\n event.stopPropagation();\n }\n },\n [onConfirmHandler, onCancelHandler],\n );\n\n const handleInputChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = event.target.value;\n setCurrentValue(newValue);\n },\n [setCurrentValue],\n );\n\n const isInEditMode = isEditing ?? hasEditMode;\n\n const handleEditClick = useCallback(() => {\n if (isDisabled === false) {\n setEditMode(true);\n blurWithinRef.current = false;\n }\n }, [isDisabled]);\n\n const updateInputWidth = useCallback(() => {\n if (mirrorRef.current && containerRef.current && !isFluid) {\n const mirrorWidth = mirrorRef.current.offsetWidth;\n const newWidth = Math.max(mirrorWidth, MINIMUM_WIDTH);\n containerRef.current.style.width = `${newWidth}px`;\n }\n }, [mirrorRef, containerRef, isFluid]);\n\n // Width calculation effect\n useLayoutEffect(() => {\n updateInputWidth();\n }, [updateInputWidth, isInEditMode, currentValue]);\n\n const displayText = currentValue || placeholder;\n const buttonAriaLabel = `${displayText}, edit`;\n const inputAriaLabel =\n ariaLabel ?? (typeof label === 'string' ? label : 'Inline edit input');\n\n return (\n <Typography\n as={as ?? 'div'}\n variant={typographyVariant}\n className={classNames('ndl-inline-edit', className, {\n 'ndl-disabled': isDisabled,\n 'ndl-fluid': isFluid,\n })}\n style={style}\n ref={ref}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {Boolean(label) && <label htmlFor={inputID}>{label}</label>}\n {isInEditMode === true ? (\n <div\n className=\"ndl-inline-edit-container\"\n ref={containerRef}\n {...focusWithinProps}\n >\n {/* Mirror span for measuring width */}\n <span\n aria-hidden={true}\n className=\"ndl-inline-edit-mirror\"\n ref={mirrorRef}\n >\n {displayText}\n </span>\n <input\n {...inputProps}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus\n aria-label={inputAriaLabel}\n className={classNames(\n 'ndl-inline-edit-input',\n inputProps?.className,\n )}\n id={inputID}\n value={currentValue}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n />\n <div className=\"ndl-inline-edit-buttons\">\n <IconButton\n description=\"Accept\"\n tooltipProps={{\n root: { placement: 'bottom' },\n }}\n onClick={onConfirmHandler}\n size=\"small\"\n isFloating={true}\n htmlAttributes={{\n onMouseDown: () => {\n blurWithinRef.current = true;\n },\n }}\n >\n <CheckIconOutline />\n </IconButton>\n <IconButton\n description=\"Cancel\"\n tooltipProps={{\n root: { placement: 'bottom' },\n }}\n onClick={(event) => onCancelHandler(event)}\n size=\"small\"\n isFloating={true}\n htmlAttributes={{\n onMouseDown: () => {\n blurWithinRef.current = true;\n },\n }}\n >\n <XMarkIconOutline />\n </IconButton>\n </div>\n </div>\n ) : (\n <button\n type=\"button\"\n className={classNames('ndl-inline-idle-container', {\n 'ndl-disabled': isDisabled,\n 'ndl-has-edit-icon': hasEditIcon,\n 'ndl-placeholder': displayText === placeholder,\n })}\n aria-disabled={isDisabled}\n aria-label={buttonAriaLabel}\n disabled={isDisabled}\n onClick={handleEditClick}\n style={{\n minHeight: getMinHeight(typographyVariant),\n }}\n >\n <span className=\"ndl-inline-edit-text\">{displayText}</span>\n {hasEditIcon && (\n <PencilIconOutline\n className=\"ndl-inline-edit-pencil-icon\"\n style={getIconStyle(typographyVariant)}\n />\n )}\n </button>\n )}\n </Typography>\n );\n};\n"],"mappings":";;;;;;;;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AI;GACJ,OAAO;GACP,UAAU;GACV,WAAW;GACE;EACd,CAAA,CAAA;EACD,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,YAAD;IACE,aAAY;IACZ,cAAc,EACZ,MAAM,EAAE,WAAW,SAAS,EAC9B;IACA,SAAS;IACT,MAAK;IACL,YAAY;IACZ,gBAAgB,EACd,mBAAmB;KACjB,cAAc,UAAU;IAC1B,EACF;IAEA,UAAA,oBAAC,kBAAD,CAAmB,CAAA;GACT,CAAA,GACZ,oBAAC,YAAD;IACE,aAAY;IACZ,cAAc,EACZ,MAAM,EAAE,WAAW,SAAS,EAC9B;IACA,UAAU,UAAU,gBAAgB,KAAK;IACzC,MAAK;IACL,YAAY;IACZ,gBAAgB,EACd,mBAAmB;KACjB,cAAc,UAAU;IAC1B,EACF;IAEA,UAAA,oBAAC,kBAAD,CAAmB,CAAA;GACT,CAAA,CACT;;CACF,EAAA,CAAA,CAAA,IAEL,qBAAC,UAAD;EACE,MAAK;EACL,WAAW,WAAW,6BAA6B;GACjD,gBAAgB;GAChB,qBAAqB;GACrB,mBAAmB,gBAAgB;EACrC,CAAC;EACD,iBAAe;EACf,cAAY;EACZ,UAAU;EACV,SAAS;EACT,OAAO,EACL,WAAW,aAAa,iBAAiB,EAC3C;EAbF,UAAA,CAeE,oBAAC,QAAD;GAAM,WAAU;GAAwB,UAAA;EAAkB,CAAA,GACzD,eACC,oBAAC,mBAAD;GACE,WAAU;GACV,OAAO,aAAa,iBAAiB;EACtC,CAAA,CAEG;CAEA,CAAA,CAAA,EAAA,CAAA,CAAA;AAEhB"}
|
|
@@ -39,11 +39,9 @@ function _validateValue() {
|
|
|
39
39
|
function getIconSizeForVariant(variant) {
|
|
40
40
|
switch (variant) {
|
|
41
41
|
case "display":
|
|
42
|
-
case "title-1":
|
|
42
|
+
case "title-1":
|
|
43
43
|
case "title-2":
|
|
44
|
-
case "title-3":
|
|
45
|
-
case "title-4":
|
|
46
|
-
case "subheading-large": return 20;
|
|
44
|
+
case "title-3": return 20;
|
|
47
45
|
default: return 16;
|
|
48
46
|
}
|
|
49
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/inline-edit/utils.ts"],"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 */\n\nimport { tokens } from '@neo4j-ndl/base';\n\nimport { type TypographyVariants } from '../typography';\n\ntype ValidationFunction = (\n value: string,\n) => Promise<true | string> | true | string;\n\nexport async function validateValue(\n value: string,\n validate?: ValidationFunction,\n): Promise<string | null> {\n if (!validate) {\n return null;\n }\n\n const validation = validate(value);\n\n let isValid: string | boolean;\n if (validation instanceof Promise) {\n isValid = await validation;\n } else {\n isValid = validation;\n }\n\n if (typeof isValid === 'string') {\n return isValid;\n }\n\n return null;\n}\n\nexport function getIconSizeForVariant(variant: TypographyVariants): number {\n switch (variant) {\n case 'display':\n case 'title-1':\n
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../../src/inline-edit/utils.ts"],"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 */\n\nimport { tokens } from '@neo4j-ndl/base';\n\nimport { type TypographyVariants } from '../typography';\n\ntype ValidationFunction = (\n value: string,\n) => Promise<true | string> | true | string;\n\nexport async function validateValue(\n value: string,\n validate?: ValidationFunction,\n): Promise<string | null> {\n if (!validate) {\n return null;\n }\n\n const validation = validate(value);\n\n let isValid: string | boolean;\n if (validation instanceof Promise) {\n isValid = await validation;\n } else {\n isValid = validation;\n }\n\n if (typeof isValid === 'string') {\n return isValid;\n }\n\n return null;\n}\n\nexport function getIconSizeForVariant(variant: TypographyVariants): number {\n switch (variant) {\n case 'display':\n case 'title-1':\n case 'title-2':\n case 'title-3':\n return 20;\n default:\n return 16;\n }\n}\n\nexport const getIconStyle = (\n variant: TypographyVariants,\n): React.CSSProperties => ({\n height: `${getIconSizeForVariant(variant)}px`,\n width: `${getIconSizeForVariant(variant)}px`,\n});\n\nexport const getMinHeight = (variant: TypographyVariants): string => {\n return `${tokens.typography[variant].lineHeight * parseFloat(tokens.typography[variant].fontSize)}rem`;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAsB,cACpB,IACA,KAAA;;;;CADA,iBAAA,kBAAA,WAAA,OACA,UACwB;EACxB,IAAI,CAAC,UACH,OAAO;EAGT,MAAM,aAAa,SAAS,KAAK;EAEjC,IAAI;EACJ,IAAI,sBAAsB,SACxB,UAAU,MAAM;OAEhB,UAAU;EAGZ,IAAI,OAAO,YAAY,UACrB,OAAO;EAGT,OAAO;CACT,CAAA;;;AAEA,SAAgB,sBAAsB,SAAqC;CACzE,QAAQ,SAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAa,gBACX,aACyB;CACzB,QAAQ,GAAG,sBAAsB,OAAO,EAAE;CAC1C,OAAO,GAAG,sBAAsB,OAAO,EAAE;AAC3C;AAEA,MAAa,gBAAgB,YAAwC;CACnE,OAAO,GAAG,OAAO,WAAW,QAAQ,CAAC,aAAa,WAAW,OAAO,WAAW,QAAQ,CAAC,QAAQ,EAAE;AACpG"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useDebounceCallback } from "../hooks/use-debounce-callback/index.mjs";
|
|
2
|
+
import SvgMagnifyingGlassOutline from "../icons/generated/custom/MagnifyingGlassOutline.mjs";
|
|
3
|
+
import { TextInput } from "../text-input/TextInput.mjs";
|
|
4
|
+
import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.mjs";
|
|
5
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.mjs";
|
|
6
|
+
import { useCallback } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
// src/search-field/SearchField.tsx
|
|
9
|
+
/*!
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) "Neo4j"
|
|
12
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
13
|
+
*
|
|
14
|
+
* This file is part of Neo4j.
|
|
15
|
+
*
|
|
16
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
17
|
+
* it under the terms of the GNU General Public License as published by
|
|
18
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
19
|
+
* (at your option) any later version.
|
|
20
|
+
*
|
|
21
|
+
* This program is distributed in the hope that it will be useful,
|
|
22
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
24
|
+
* GNU General Public License for more details.
|
|
25
|
+
*
|
|
26
|
+
* You should have received a copy of the GNU General Public License
|
|
27
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
28
|
+
*/
|
|
29
|
+
const _excluded = [
|
|
30
|
+
"debounceDelay",
|
|
31
|
+
"htmlAttributes",
|
|
32
|
+
"label",
|
|
33
|
+
"onChange",
|
|
34
|
+
"onSearch"
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* A text input for entering search queries.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* SearchField renders a fixed search icon and uses the native `search` input
|
|
41
|
+
* type. `onChange` is called immediately, while `onSearch` is debounced until
|
|
42
|
+
* typing pauses. Pressing Enter or clearing the field calls `onSearch`
|
|
43
|
+
* immediately.
|
|
44
|
+
*/
|
|
45
|
+
const SearchField = (_ref) => {
|
|
46
|
+
let { debounceDelay = 500, htmlAttributes, label, onChange, onSearch } = _ref, textInputProps = _objectWithoutProperties(_ref, _excluded);
|
|
47
|
+
const debouncedSearch = useDebounceCallback((query) => {
|
|
48
|
+
onSearch === null || onSearch === void 0 || onSearch(query);
|
|
49
|
+
}, debounceDelay);
|
|
50
|
+
const handleChange = useCallback((event) => {
|
|
51
|
+
onChange === null || onChange === void 0 || onChange(event);
|
|
52
|
+
const query = event.target.value;
|
|
53
|
+
if (query === "") {
|
|
54
|
+
debouncedSearch.cancel();
|
|
55
|
+
onSearch === null || onSearch === void 0 || onSearch("");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
debouncedSearch(query);
|
|
59
|
+
}, [
|
|
60
|
+
debouncedSearch,
|
|
61
|
+
onChange,
|
|
62
|
+
onSearch
|
|
63
|
+
]);
|
|
64
|
+
const handleKeyDown = useCallback((event) => {
|
|
65
|
+
var _htmlAttributes$onKey;
|
|
66
|
+
htmlAttributes === null || htmlAttributes === void 0 || (_htmlAttributes$onKey = htmlAttributes.onKeyDown) === null || _htmlAttributes$onKey === void 0 || _htmlAttributes$onKey.call(htmlAttributes, event);
|
|
67
|
+
if (event.key === "Enter" && !event.defaultPrevented && !event.nativeEvent.isComposing) {
|
|
68
|
+
if (debouncedSearch.isPending()) debouncedSearch.flush();
|
|
69
|
+
else onSearch === null || onSearch === void 0 || onSearch(event.currentTarget.value);
|
|
70
|
+
}
|
|
71
|
+
}, [
|
|
72
|
+
debouncedSearch,
|
|
73
|
+
htmlAttributes,
|
|
74
|
+
onSearch
|
|
75
|
+
]);
|
|
76
|
+
return /* @__PURE__ */ jsx(TextInput, _objectSpread2(_objectSpread2({}, textInputProps), {}, {
|
|
77
|
+
htmlAttributes: _objectSpread2(_objectSpread2({}, htmlAttributes), {}, {
|
|
78
|
+
"aria-label": label,
|
|
79
|
+
onKeyDown: handleKeyDown,
|
|
80
|
+
type: "search"
|
|
81
|
+
}),
|
|
82
|
+
isClearable: true,
|
|
83
|
+
leadingElement: /* @__PURE__ */ jsx(SvgMagnifyingGlassOutline, {}),
|
|
84
|
+
onChange: handleChange
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
87
|
+
export { SearchField };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=SearchField.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchField.mjs","names":["MagnifyingGlassOutlineIcon"],"sources":["../../../src/search-field/SearchField.tsx"],"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 */\n\nimport { type ChangeEvent, type ComponentProps, useCallback } from 'react';\n\nimport { useDebounceCallback } from '../hooks/use-debounce-callback';\nimport MagnifyingGlassOutlineIcon from '../icons/generated/custom/MagnifyingGlassOutline';\nimport { TextInput } from '../text-input';\n\ntype SearchFieldTextInputProps = Pick<\n ComponentProps<typeof TextInput>,\n | 'className'\n | 'errorText'\n | 'helpText'\n | 'htmlAttributes'\n | 'isDisabled'\n | 'isFluid'\n | 'isLoading'\n | 'isReadOnly'\n | 'isSkeletonLoading'\n | 'onChange'\n | 'placeholder'\n | 'ref'\n | 'size'\n | 'skeletonProps'\n | 'style'\n | 'value'\n>;\n\nexport type SearchFieldProps = SearchFieldTextInputProps & {\n /**\n * Accessible name for the search field. The label is announced by assistive\n * technologies but is not rendered visually.\n */\n label: string;\n\n /**\n * Called with the search query after typing pauses for `debounceDelay`, and\n * immediately when the user presses Enter or clears the field.\n */\n onSearch?: (query: string) => void;\n\n /**\n * Delay in milliseconds before calling `onSearch` after the query changes.\n * @default 500\n */\n debounceDelay?: number;\n};\n\n/**\n * A text input for entering search queries.\n *\n * @remarks\n * SearchField renders a fixed search icon and uses the native `search` input\n * type. `onChange` is called immediately, while `onSearch` is debounced until\n * typing pauses. Pressing Enter or clearing the field calls `onSearch`\n * immediately.\n */\nexport const SearchField = ({\n debounceDelay = 500,\n htmlAttributes,\n label,\n onChange,\n onSearch,\n ...textInputProps\n}: SearchFieldProps) => {\n const debouncedSearch = useDebounceCallback((query: string) => {\n onSearch?.(query);\n }, debounceDelay);\n\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n\n const query = event.target.value;\n if (query === '') {\n debouncedSearch.cancel();\n onSearch?.('');\n return;\n }\n\n debouncedSearch(query);\n },\n [debouncedSearch, onChange, onSearch],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n htmlAttributes?.onKeyDown?.(event);\n\n if (\n event.key === 'Enter' &&\n !event.defaultPrevented &&\n !event.nativeEvent.isComposing\n ) {\n if (debouncedSearch.isPending()) {\n debouncedSearch.flush();\n } else {\n onSearch?.(event.currentTarget.value);\n }\n }\n },\n [debouncedSearch, htmlAttributes, onSearch],\n );\n\n return (\n <TextInput\n {...textInputProps}\n htmlAttributes={{\n ...htmlAttributes,\n 'aria-label': label,\n onKeyDown: handleKeyDown,\n type: 'search',\n }}\n isClearable\n leadingElement={<MagnifyingGlassOutlineIcon />}\n onChange={handleChange}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6EE;CACA;CACA;CACA;CACA;;;;;;;;;;;AALF,MAAa,eAAe,SAOJ;CAPI,IAAA,EAC1B,gBAAgB,KAChB,gBACA,OACA,UACA,aAAA,MACG,iBAAA,yBAAA,MAAA,SAAA;CAEH,MAAM,kBAAkB,qBAAqB,UAAkB;EAC7D,aAAA,QAAA,aAAA,KAAA,KAAA,SAAW,KAAK;CAClB,GAAG,aAAa;CAEhB,MAAM,eAAe,aAClB,UAAyC;EACxC,aAAA,QAAA,aAAA,KAAA,KAAA,SAAW,KAAK;EAEhB,MAAM,QAAQ,MAAM,OAAO;EAC3B,IAAI,UAAU,IAAI;GAChB,gBAAgB,OAAO;GACvB,aAAA,QAAA,aAAA,KAAA,KAAA,SAAW,EAAE;GACb;EACF;EAEA,gBAAgB,KAAK;CACvB,GACA;EAAC;EAAiB;EAAU;CAAQ,CACtC;CAEA,MAAM,gBAAgB,aACnB,UAAiD;;EAChD,mBAAA,QAAA,mBAAA,KAAA,MAAA,wBAAA,eAAgB,eAAA,QAAA,0BAAA,KAAA,KAAA,sBAAA,KAAA,gBAAY,KAAK;EAEjC,IACE,MAAM,QAAQ,WACd,CAAC,MAAM,oBACP,CAAC,MAAM,YAAY,aACnB;GACA,IAAI,gBAAgB,UAAU,GAC5B,gBAAgB,MAAM;QAEtB,aAAA,QAAA,aAAA,KAAA,KAAA,SAAW,MAAM,cAAc,KAAK;EAExC;CACF,GACA;EAAC;EAAiB;EAAgB;CAAQ,CAC5C;CAEA,OACE,oBAAC,WAAA,eAAA,eAAA,CAAA,GACK,cAAA,GAAA,CAAA,GAAA;EACJ,gBAAA,eAAA,eAAA,CAAA,GACK,cAAA,GAAA,CAAA,GAAA;GACH,cAAc;GACd,WAAW;GACX,MAAM;EACR,CAAA;EACA,aAAA;EACA,gBAAgB,oBAACA,2BAAD,CAA6B,CAAA;EAC7C,UAAU;CACX,CAAA,CAAA;AAEL"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/search-field/index.ts
|
|
2
|
+
/*!
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
export { SearchField } from "./SearchField.mjs";
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/search-field/index.ts"],"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 */\n\nexport * from './SearchField';\n"],"mappings":""}
|
|
@@ -463,7 +463,7 @@ const CategoryHeader = (_ref5) => {
|
|
|
463
463
|
const classes = classNames("ndl-side-nav-category-header", className, { "ndl-side-nav-category-header-expanded": isExpanded || isHovered });
|
|
464
464
|
return /* @__PURE__ */ jsx(Typography, _objectSpread2(_objectSpread2({
|
|
465
465
|
ref,
|
|
466
|
-
variant: "
|
|
466
|
+
variant: "title-4",
|
|
467
467
|
as: "li",
|
|
468
468
|
className: classes,
|
|
469
469
|
htmlAttributes: _objectSpread2(_objectSpread2({}, htmlAttributes), {}, { role: "separator" }),
|
|
@@ -500,7 +500,7 @@ const ItemBadge = (_ref6) => {
|
|
|
500
500
|
return /* @__PURE__ */ jsx(Typography, _objectSpread2(_objectSpread2({
|
|
501
501
|
as: "span",
|
|
502
502
|
className: badgeClasses,
|
|
503
|
-
variant: "subheading-
|
|
503
|
+
variant: "subheading-medium",
|
|
504
504
|
htmlAttributes: _objectSpread2({ "aria-label": `${number} notifications of type ${type}` }, htmlAttributes),
|
|
505
505
|
style,
|
|
506
506
|
ref
|