@mantine/core 9.3.0 → 9.3.2
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/cjs/components/Blockquote/Blockquote.module.cjs.map +1 -1
- package/cjs/components/Checkbox/Checkbox.cjs +2 -1
- package/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
- package/cjs/components/Collapse/Collapse.cjs +2 -1
- package/cjs/components/Collapse/Collapse.cjs.map +1 -1
- package/cjs/components/Combobox/Combobox.cjs +1 -0
- package/cjs/components/Combobox/Combobox.cjs.map +1 -1
- package/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/cjs/components/HoverCard/HoverCard.cjs +1 -0
- package/cjs/components/HoverCard/HoverCard.cjs.map +1 -1
- package/cjs/components/HoverCard/HoverCard.context.cjs.map +1 -1
- package/cjs/components/HoverCard/HoverCardTarget/HoverCardTarget.cjs +10 -2
- package/cjs/components/HoverCard/HoverCardTarget/HoverCardTarget.cjs.map +1 -1
- package/cjs/components/HoverCard/use-hover-card.cjs +24 -0
- package/cjs/components/HoverCard/use-hover-card.cjs.map +1 -1
- package/cjs/components/Input/Input.module.cjs.map +1 -1
- package/cjs/components/Menu/MenuContextMenu/MenuContextMenu.cjs +4 -3
- package/cjs/components/Menu/MenuContextMenu/MenuContextMenu.cjs.map +1 -1
- package/cjs/components/Menu/MenuSub/MenuSub.cjs +16 -13
- package/cjs/components/Menu/MenuSub/MenuSub.cjs.map +1 -1
- package/cjs/components/Pagination/Pagination.icons.cjs.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs +3 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/cjs/components/Popover/Popover.cjs +2 -1
- package/cjs/components/Popover/Popover.cjs.map +1 -1
- package/cjs/components/Popover/Popover.context.cjs.map +1 -1
- package/cjs/components/Popover/PopoverContextMenu/PopoverContextMenu.cjs +4 -3
- package/cjs/components/Popover/PopoverContextMenu/PopoverContextMenu.cjs.map +1 -1
- package/cjs/components/Popover/PopoverDropdown/PopoverDropdown.cjs +1 -0
- package/cjs/components/Popover/PopoverDropdown/PopoverDropdown.cjs.map +1 -1
- package/cjs/components/Popover/use-popover.cjs +23 -11
- package/cjs/components/Popover/use-popover.cjs.map +1 -1
- package/cjs/components/SegmentedControl/SegmentedControl.module.cjs.map +1 -1
- package/cjs/components/Slider/Thumb/Thumb.cjs.map +1 -1
- package/cjs/components/Splitter/Splitter.cjs +5 -3
- package/cjs/components/Splitter/Splitter.cjs.map +1 -1
- package/cjs/components/Text/Text.module.cjs.map +1 -1
- package/cjs/components/Textarea/Autosize.cjs +14 -0
- package/cjs/components/Textarea/Autosize.cjs.map +1 -1
- package/cjs/components/Transition/Transition.cjs +17 -10
- package/cjs/components/Transition/Transition.cjs.map +1 -1
- package/cjs/components/Tree/TreeNode.cjs +8 -1
- package/cjs/components/Tree/TreeNode.cjs.map +1 -1
- package/cjs/core/Box/Box.cjs.map +1 -1
- package/cjs/core/styles-api/use-styles/use-styles.cjs.map +1 -1
- package/cjs/utils/Floating/use-context-menu-handlers.cjs +85 -0
- package/cjs/utils/Floating/use-context-menu-handlers.cjs.map +1 -0
- package/esm/components/Blockquote/Blockquote.module.mjs.map +1 -1
- package/esm/components/Checkbox/Checkbox.mjs +2 -1
- package/esm/components/Checkbox/Checkbox.mjs.map +1 -1
- package/esm/components/Collapse/Collapse.mjs +2 -1
- package/esm/components/Collapse/Collapse.mjs.map +1 -1
- package/esm/components/Combobox/Combobox.mjs +1 -0
- package/esm/components/Combobox/Combobox.mjs.map +1 -1
- package/esm/components/Dialog/Dialog.mjs.map +1 -1
- package/esm/components/HoverCard/HoverCard.context.mjs.map +1 -1
- package/esm/components/HoverCard/HoverCard.mjs +1 -0
- package/esm/components/HoverCard/HoverCard.mjs.map +1 -1
- package/esm/components/HoverCard/HoverCardTarget/HoverCardTarget.mjs +10 -2
- package/esm/components/HoverCard/HoverCardTarget/HoverCardTarget.mjs.map +1 -1
- package/esm/components/HoverCard/use-hover-card.mjs +24 -0
- package/esm/components/HoverCard/use-hover-card.mjs.map +1 -1
- package/esm/components/Input/Input.module.mjs.map +1 -1
- package/esm/components/Menu/MenuContextMenu/MenuContextMenu.mjs +4 -3
- package/esm/components/Menu/MenuContextMenu/MenuContextMenu.mjs.map +1 -1
- package/esm/components/Menu/MenuSub/MenuSub.mjs +18 -15
- package/esm/components/Menu/MenuSub/MenuSub.mjs.map +1 -1
- package/esm/components/Pagination/Pagination.icons.mjs.map +1 -1
- package/esm/components/PasswordInput/PasswordInput.mjs +3 -1
- package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
- package/esm/components/Popover/Popover.context.mjs.map +1 -1
- package/esm/components/Popover/Popover.mjs +2 -1
- package/esm/components/Popover/Popover.mjs.map +1 -1
- package/esm/components/Popover/PopoverContextMenu/PopoverContextMenu.mjs +4 -3
- package/esm/components/Popover/PopoverContextMenu/PopoverContextMenu.mjs.map +1 -1
- package/esm/components/Popover/PopoverDropdown/PopoverDropdown.mjs +1 -0
- package/esm/components/Popover/PopoverDropdown/PopoverDropdown.mjs.map +1 -1
- package/esm/components/Popover/use-popover.mjs +23 -11
- package/esm/components/Popover/use-popover.mjs.map +1 -1
- package/esm/components/SegmentedControl/SegmentedControl.module.mjs.map +1 -1
- package/esm/components/Slider/Thumb/Thumb.mjs.map +1 -1
- package/esm/components/Splitter/Splitter.mjs +5 -3
- package/esm/components/Splitter/Splitter.mjs.map +1 -1
- package/esm/components/Text/Text.module.mjs.map +1 -1
- package/esm/components/Textarea/Autosize.mjs +14 -0
- package/esm/components/Textarea/Autosize.mjs.map +1 -1
- package/esm/components/Transition/Transition.mjs +17 -10
- package/esm/components/Transition/Transition.mjs.map +1 -1
- package/esm/components/Tree/TreeNode.mjs +8 -1
- package/esm/components/Tree/TreeNode.mjs.map +1 -1
- package/esm/core/Box/Box.mjs.map +1 -1
- package/esm/core/styles-api/use-styles/use-styles.mjs.map +1 -1
- package/esm/utils/Floating/use-context-menu-handlers.mjs +85 -0
- package/esm/utils/Floating/use-context-menu-handlers.mjs.map +1 -0
- package/lib/components/Collapse/Collapse.d.ts +1 -1
- package/lib/components/Dialog/Dialog.d.ts +1 -1
- package/lib/components/HoverCard/HoverCard.context.d.ts +1 -0
- package/lib/components/HoverCard/use-hover-card.d.ts +1 -0
- package/lib/components/Input/use-input-props.d.ts +3 -3
- package/lib/components/MaskInput/use-mask-input-props.d.ts +2 -2
- package/lib/components/Menu/MenuContextMenu/MenuContextMenu.d.ts +2 -0
- package/lib/components/Menu/MenuSub/MenuSub.d.ts +2 -0
- package/lib/components/Pagination/Pagination.icons.d.ts +1 -1
- package/lib/components/Popover/Popover.context.d.ts +1 -0
- package/lib/components/Popover/Popover.d.ts +7 -0
- package/lib/components/Popover/PopoverContextMenu/PopoverContextMenu.d.ts +2 -0
- package/lib/components/Slider/Thumb/Thumb.d.ts +1 -1
- package/lib/components/Splitter/Splitter.d.ts +2 -0
- package/lib/components/Transition/Transition.d.ts +8 -1
- package/lib/core/Box/Box.d.ts +1 -1
- package/lib/core/styles-api/styles-api.types.d.ts +2 -2
- package/lib/core/styles-api/use-styles/use-styles.d.ts +1 -1
- package/lib/utils/Floating/{create-context-menu-handlers.d.ts → use-context-menu-handlers.d.ts} +9 -2
- package/package.json +2 -2
- package/styles/Blockquote.css +1 -1
- package/styles/Blockquote.layer.css +1 -1
- package/styles/Input.css +1 -1
- package/styles/Input.layer.css +1 -1
- package/styles/SegmentedControl.css +4 -1
- package/styles/SegmentedControl.layer.css +4 -1
- package/styles/Text.css +1 -1
- package/styles/Text.layer.css +1 -1
- package/styles.css +7 -4
- package/styles.layer.css +7 -4
- package/cjs/utils/Floating/create-context-menu-handlers.cjs +0 -38
- package/cjs/utils/Floating/create-context-menu-handlers.cjs.map +0 -1
- package/esm/utils/Floating/create-context-menu-handlers.mjs +0 -38
- package/esm/utils/Floating/create-context-menu-handlers.mjs.map +0 -1
|
@@ -57,7 +57,7 @@ const varsResolver = createVarsResolver((_, { radius, shadow }) => ({ dropdown:
|
|
|
57
57
|
} }));
|
|
58
58
|
function Popover(_props) {
|
|
59
59
|
const props = useProps("Popover", defaultProps, _props);
|
|
60
|
-
const { children, position, offset, onPositionChange, opened, transitionProps, onExitTransitionEnd, onEnterTransitionEnd, width, middlewares, withArrow, arrowSize, arrowOffset, arrowRadius, arrowPosition, unstyled, classNames, styles, closeOnClickOutside, withinPortal, portalProps, closeOnEscape, clickOutsideEvents, trapFocus, onClose, onDismiss, onOpen, onChange, zIndex, radius, shadow, id, defaultOpened, __staticSelector, withRoles, disabled, returnFocus, variant, keepMounted, vars, floatingStrategy, withOverlay, overlayProps, hideDetached, attributes, preventPositionChangeWhenVisible, ...others } = props;
|
|
60
|
+
const { children, position, offset, onPositionChange, opened, transitionProps, onExitTransitionEnd, onEnterTransitionEnd, width, middlewares, withArrow, arrowSize, arrowOffset, arrowRadius, arrowPosition, unstyled, classNames, styles, closeOnClickOutside, withinPortal, portalProps, closeOnEscape, clickOutsideEvents, trapFocus, onClose, onDismiss, onOpen, onChange, zIndex, radius, shadow, id, defaultOpened, __staticSelector, withRoles, disabled, returnFocus, variant, keepMounted, keepMountedMode, vars, floatingStrategy, withOverlay, overlayProps, hideDetached, attributes, preventPositionChangeWhenVisible, ...others } = props;
|
|
61
61
|
const getStyles = useStyles({
|
|
62
62
|
name: __staticSelector,
|
|
63
63
|
props,
|
|
@@ -172,6 +172,7 @@ function Popover(_props) {
|
|
|
172
172
|
unstyled,
|
|
173
173
|
variant,
|
|
174
174
|
keepMounted,
|
|
175
|
+
keepMountedMode,
|
|
175
176
|
getStyles,
|
|
176
177
|
resolvedStyles,
|
|
177
178
|
floatingStrategy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.mjs","names":["useId"],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport { useClickOutside, useId } from '@mantine/hooks';\nimport {\n createVarsResolver,\n ElementProps,\n ExtendComponent,\n Factory,\n getDefaultZIndex,\n getRadius,\n getShadow,\n MantineRadius,\n MantineShadow,\n StylesApiProps,\n useDirection,\n useMantineEnv,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n ArrowPosition,\n FloatingAxesOffsets,\n FloatingPosition,\n FloatingStrategy,\n getFloatingPosition,\n} from '../../utils/Floating';\nimport { Overlay, OverlayProps } from '../Overlay';\nimport { BasePortalProps, OptionalPortal } from '../Portal';\nimport { Transition, TransitionOverride } from '../Transition';\nimport { PopoverContextProvider, PopoverContextValue } from './Popover.context';\nimport { PopoverMiddlewares, PopoverWidth } from './Popover.types';\nimport {\n PopoverContextMenu,\n PopoverContextMenuProps,\n} from './PopoverContextMenu/PopoverContextMenu';\nimport { PopoverDropdown, PopoverDropdownProps } from './PopoverDropdown/PopoverDropdown';\nimport { PopoverTarget, PopoverTargetProps } from './PopoverTarget/PopoverTarget';\nimport { usePopover } from './use-popover';\nimport classes from './Popover.module.css';\n\nexport type PopoverStylesNames = 'dropdown' | 'arrow' | 'overlay';\nexport type PopoverCssVariables = {\n dropdown: '--popover-radius' | '--popover-shadow';\n};\n\nexport interface __PopoverProps {\n /** Dropdown position relative to the target element @default 'bottom' */\n position?: FloatingPosition;\n\n /** Offset of the dropdown element @default 8 */\n offset?: number | FloatingAxesOffsets;\n\n /** Called when dropdown position changes */\n onPositionChange?: (position: FloatingPosition) => void;\n\n /** Called when dropdown closes */\n onClose?: () => void;\n\n /** Called when the popover is dismissed by clicking outside or by pressing escape */\n onDismiss?: () => void;\n\n /** Called when dropdown opens */\n onOpen?: () => void;\n\n /** If set, the dropdown is not unmounted from the DOM when hidden. `display: none` styles are added instead. */\n keepMounted?: boolean;\n\n /** Props passed down to the `Transition` component. Use to configure duration and animation type. @default { duration: 150, transition: 'fade' } */\n transitionProps?: TransitionOverride;\n\n /** Called when exit transition ends */\n onExitTransitionEnd?: () => void;\n\n /** Called when enter transition ends */\n onEnterTransitionEnd?: () => void;\n\n /** Dropdown width, or `'target'` to make dropdown width the same as target element @default 'max-content' */\n width?: PopoverWidth;\n\n /** Floating ui middlewares to configure position handling @default { flip: true, shift: true, inline: false } */\n middlewares?: PopoverMiddlewares;\n\n /** Determines whether component should have an arrow @default false */\n withArrow?: boolean;\n\n /** Determines whether the overlay should be displayed when the dropdown is opened @default false */\n withOverlay?: boolean;\n\n /** Props passed down to `Overlay` component */\n overlayProps?: OverlayProps & ElementProps<'div'>;\n\n /** Arrow size in px @default 7 */\n arrowSize?: number;\n\n /** Arrow offset in px @default 5 */\n arrowOffset?: number;\n\n /** Arrow `border-radius` in px @default 0 */\n arrowRadius?: number;\n\n /** Arrow position */\n arrowPosition?: ArrowPosition;\n\n /** Determines whether dropdown should be rendered within the `Portal` @default true */\n withinPortal?: boolean;\n\n /** Props to pass down to the `Portal` when `withinPortal` is true */\n portalProps?: BasePortalProps;\n\n /** Dropdown `z-index` @default 300 */\n zIndex?: string | number;\n\n /** Key of `theme.radius` or any valid CSS value to set border-radius @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Key of `theme.shadows` or any other valid CSS `box-shadow` value */\n shadow?: MantineShadow;\n\n /** If set, popover dropdown will not be rendered */\n disabled?: boolean;\n\n /** Determines whether focus should be automatically returned to control when dropdown closes @default false */\n returnFocus?: boolean;\n\n /** Changes floating ui [position strategy](https://floating-ui.com/docs/usefloating#strategy) @default 'absolute' */\n floatingStrategy?: FloatingStrategy;\n\n /** If set, the dropdown is hidden when the element is hidden with styles or not visible on the screen @default true */\n hideDetached?: boolean;\n\n /** If `true`, the dropdown picks its side on open (flip runs once, preferring the `position` prop) and then never changes side — scrolling, resizing, and content size changes will not flip the dropdown. The side is recalculated fresh on the next open. Does not affect the `shift` middleware. Set to `false` to keep flip active and allow the dropdown to re-flip on every change. @default true */\n preventPositionChangeWhenVisible?: boolean;\n}\n\nexport interface PopoverProps extends __PopoverProps, StylesApiProps<PopoverFactory> {\n __staticSelector?: string;\n\n /** `Popover.Target` and `Popover.Dropdown` components */\n children?: React.ReactNode;\n\n /** Initial opened state for uncontrolled component */\n defaultOpened?: boolean;\n\n /** Controlled dropdown opened state */\n opened?: boolean;\n\n /** Called with current state when dropdown opens or closes */\n onChange?: (opened: boolean) => void;\n\n /** Determines whether dropdown should be closed on outside clicks @default true */\n closeOnClickOutside?: boolean;\n\n /** Events that trigger outside clicks */\n clickOutsideEvents?: string[];\n\n /** Determines whether focus should be trapped within dropdown @default false */\n trapFocus?: boolean;\n\n /** Determines whether dropdown should be closed when `Escape` key is pressed @default true */\n closeOnEscape?: boolean;\n\n /** Id base to create accessibility connections */\n id?: string;\n\n /** Determines whether dropdown and target elements should have accessible roles @default true */\n withRoles?: boolean;\n}\n\nexport type PopoverFactory = Factory<{\n props: PopoverProps;\n stylesNames: PopoverStylesNames;\n vars: PopoverCssVariables;\n}>;\n\nconst defaultProps = {\n position: 'bottom',\n offset: 8,\n transitionProps: { transition: 'fade', duration: 150 },\n middlewares: { flip: true, shift: true, inline: false },\n arrowSize: 7,\n arrowOffset: 5,\n arrowRadius: 0,\n arrowPosition: 'side',\n closeOnClickOutside: true,\n withinPortal: true,\n closeOnEscape: true,\n trapFocus: false,\n withRoles: true,\n returnFocus: false,\n withOverlay: false,\n hideDetached: true,\n preventPositionChangeWhenVisible: true,\n clickOutsideEvents: ['mousedown', 'touchstart'],\n zIndex: getDefaultZIndex('popover'),\n __staticSelector: 'Popover',\n width: 'max-content',\n} satisfies Partial<PopoverProps>;\n\nconst varsResolver = createVarsResolver<PopoverFactory>((_, { radius, shadow }) => ({\n dropdown: {\n '--popover-radius': radius === undefined ? undefined : getRadius(radius),\n '--popover-shadow': getShadow(shadow),\n },\n}));\n\nexport function Popover(_props: PopoverProps) {\n const props = useProps('Popover', defaultProps, _props);\n const {\n children,\n position,\n offset,\n onPositionChange,\n opened,\n transitionProps,\n onExitTransitionEnd,\n onEnterTransitionEnd,\n width,\n middlewares,\n withArrow,\n arrowSize,\n arrowOffset,\n arrowRadius,\n arrowPosition,\n unstyled,\n classNames,\n styles,\n closeOnClickOutside,\n withinPortal,\n portalProps,\n closeOnEscape,\n clickOutsideEvents,\n trapFocus,\n onClose,\n onDismiss,\n onOpen,\n onChange,\n zIndex,\n radius,\n shadow,\n id,\n defaultOpened,\n __staticSelector,\n withRoles,\n disabled,\n returnFocus,\n variant,\n keepMounted,\n vars,\n floatingStrategy,\n withOverlay,\n overlayProps,\n hideDetached,\n attributes,\n preventPositionChangeWhenVisible,\n ...others\n } = props;\n\n const getStyles = useStyles<PopoverFactory>({\n name: __staticSelector,\n props,\n classes,\n classNames,\n styles,\n unstyled,\n attributes,\n rootSelector: 'dropdown',\n vars,\n varsResolver,\n });\n\n const { resolvedStyles } = useResolvedStylesApi<PopoverFactory>({ classNames, styles, props });\n\n const arrowRef = useRef<HTMLDivElement | null>(null);\n const [targetNode, setTargetNode] = useState<HTMLElement | null>(null);\n const [dropdownNode, setDropdownNode] = useState<HTMLElement | null>(null);\n const { dir } = useDirection();\n const env = useMantineEnv();\n\n const uid = useId(id);\n const popover = usePopover({\n middlewares,\n width,\n position: getFloatingPosition(dir, position),\n offset: typeof offset === 'number' ? offset + (withArrow ? arrowSize / 2 : 0) : offset,\n arrowRef,\n arrowOffset,\n onPositionChange,\n opened,\n defaultOpened,\n onChange,\n onOpen,\n onClose,\n onDismiss,\n strategy: floatingStrategy,\n disabled,\n preventPositionChangeWhenVisible,\n keepMounted,\n });\n\n useClickOutside(\n () => {\n if (closeOnClickOutside) {\n popover.onClose();\n onDismiss?.();\n }\n },\n clickOutsideEvents,\n [targetNode, dropdownNode]\n );\n\n const reference = useCallback(\n (node: HTMLElement) => {\n setTargetNode(node);\n popover.floating.refs.setReference(node);\n },\n [popover.floating.refs.setReference]\n );\n\n const floating = useCallback(\n (node: HTMLElement) => {\n setDropdownNode(node);\n popover.floating.refs.setFloating(node);\n },\n [popover.floating.refs.setFloating]\n );\n\n const onExited = useCallback(() => {\n transitionProps?.onExited?.();\n onExitTransitionEnd?.();\n popover.resetLockedPlacement();\n }, [transitionProps?.onExited, onExitTransitionEnd, popover.resetLockedPlacement]);\n\n const onEntered = useCallback(() => {\n transitionProps?.onEntered?.();\n onEnterTransitionEnd?.();\n }, [transitionProps?.onEntered, onEnterTransitionEnd]);\n\n return (\n <PopoverContextProvider\n value={{\n returnFocus,\n disabled,\n controlled: popover.controlled,\n reference,\n floating,\n x: popover.floating.x,\n y: popover.floating.y,\n arrowX: popover.floating?.middlewareData?.arrow?.x,\n arrowY: popover.floating?.middlewareData?.arrow?.y,\n opened: popover.opened,\n arrowRef,\n transitionProps: { ...transitionProps, onExited, onEntered },\n width,\n withArrow,\n arrowSize,\n arrowOffset,\n arrowRadius,\n arrowPosition,\n placement: popover.floating.placement,\n trapFocus,\n withinPortal,\n portalProps,\n zIndex,\n radius,\n shadow,\n closeOnEscape,\n onDismiss,\n onClose: popover.onClose,\n onToggle: popover.onToggle,\n getTargetId: () => uid,\n getDropdownId: () => `${uid}-dropdown`,\n withRoles,\n targetProps: others,\n __staticSelector,\n classNames,\n styles,\n unstyled,\n variant,\n keepMounted,\n getStyles,\n resolvedStyles,\n floatingStrategy,\n referenceHidden:\n hideDetached && env !== 'test'\n ? popover.floating.middlewareData.hide?.referenceHidden\n : false,\n }}\n >\n {children}\n {withOverlay && (\n <Transition\n transition=\"fade\"\n mounted={popover.opened}\n duration={transitionProps?.duration || 250}\n exitDuration={transitionProps?.exitDuration || 250}\n >\n {(transitionStyles) => (\n <OptionalPortal withinPortal={withinPortal}>\n <Overlay\n {...overlayProps}\n {...getStyles('overlay', {\n className: overlayProps?.className,\n style: [transitionStyles, overlayProps?.style],\n })}\n />\n </OptionalPortal>\n )}\n </Transition>\n )}\n </PopoverContextProvider>\n );\n}\n\nPopover.Target = PopoverTarget;\nPopover.Dropdown = PopoverDropdown;\nPopover.ContextMenu = PopoverContextMenu;\nPopover.varsResolver = varsResolver;\nPopover.displayName = '@mantine/core/Popover';\nPopover.extend = (input: ExtendComponent<PopoverFactory>) => input;\nPopover.withProps = (fixedProps: Partial<PopoverProps>) => {\n const Extended = (props: PopoverProps) => <Popover {...fixedProps} {...props} />;\n Extended.extend = Popover.extend;\n Extended.displayName = `WithProps(${Popover.displayName})`;\n return Extended;\n};\n\nexport namespace Popover {\n export type Props = PopoverProps;\n export type __Props = __PopoverProps;\n export type Factory = PopoverFactory;\n export type StylesNames = PopoverStylesNames;\n export type TargetProps = PopoverTargetProps;\n export type DropdownProps = PopoverDropdownProps;\n export type Width = PopoverWidth;\n export type ContextValue = PopoverContextValue;\n\n export namespace Target {\n export type Props = PopoverTargetProps;\n }\n\n export namespace Dropdown {\n export type Props = PopoverDropdownProps;\n }\n\n export namespace ContextMenu {\n export type Props = PopoverContextMenuProps;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8KA,MAAM,eAAe;CACnB,UAAU;CACV,QAAQ;CACR,iBAAiB;EAAE,YAAY;EAAQ,UAAU;CAAI;CACrD,aAAa;EAAE,MAAM;EAAM,OAAO;EAAM,QAAQ;CAAM;CACtD,WAAW;CACX,aAAa;CACb,aAAa;CACb,eAAe;CACf,qBAAqB;CACrB,cAAc;CACd,eAAe;CACf,WAAW;CACX,WAAW;CACX,aAAa;CACb,aAAa;CACb,cAAc;CACd,kCAAkC;CAClC,oBAAoB,CAAC,aAAa,YAAY;CAC9C,QAAQ,iBAAiB,SAAS;CAClC,kBAAkB;CAClB,OAAO;AACT;AAEA,MAAM,eAAe,oBAAoC,GAAG,EAAE,QAAQ,cAAc,EAClF,UAAU;CACR,oBAAoB,WAAW,KAAA,IAAY,KAAA,IAAY,UAAU,MAAM;CACvE,oBAAoB,UAAU,MAAM;AACtC,EACF,EAAE;AAEF,SAAgB,QAAQ,QAAsB;CAC5C,MAAM,QAAQ,SAAS,WAAW,cAAc,MAAM;CACtD,MAAM,EACJ,UACA,UACA,QACA,kBACA,QACA,iBACA,qBACA,sBACA,OACA,aACA,WACA,WACA,aACA,aACA,eACA,UACA,YACA,QACA,qBACA,cACA,aACA,eACA,oBACA,WAC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I;EAAY,GAAI;CAAQ,CAAA;CAC/E,SAAS,SAAS,QAAQ;CAC1B,SAAS,cAAc,aAAa,QAAQ,YAAY;CACxD,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"Popover.mjs","names":["useId"],"sources":["../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport { useClickOutside, useId } from '@mantine/hooks';\nimport {\n createVarsResolver,\n ElementProps,\n ExtendComponent,\n Factory,\n getDefaultZIndex,\n getRadius,\n getShadow,\n MantineRadius,\n MantineShadow,\n StylesApiProps,\n useDirection,\n useMantineEnv,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport {\n ArrowPosition,\n FloatingAxesOffsets,\n FloatingPosition,\n FloatingStrategy,\n getFloatingPosition,\n} from '../../utils/Floating';\nimport { Overlay, OverlayProps } from '../Overlay';\nimport { BasePortalProps, OptionalPortal } from '../Portal';\nimport { Transition, TransitionOverride } from '../Transition';\nimport { PopoverContextProvider, PopoverContextValue } from './Popover.context';\nimport { PopoverMiddlewares, PopoverWidth } from './Popover.types';\nimport {\n PopoverContextMenu,\n PopoverContextMenuProps,\n} from './PopoverContextMenu/PopoverContextMenu';\nimport { PopoverDropdown, PopoverDropdownProps } from './PopoverDropdown/PopoverDropdown';\nimport { PopoverTarget, PopoverTargetProps } from './PopoverTarget/PopoverTarget';\nimport { usePopover } from './use-popover';\nimport classes from './Popover.module.css';\n\nexport type PopoverStylesNames = 'dropdown' | 'arrow' | 'overlay';\nexport type PopoverCssVariables = {\n dropdown: '--popover-radius' | '--popover-shadow';\n};\n\nexport interface __PopoverProps {\n /** Dropdown position relative to the target element @default 'bottom' */\n position?: FloatingPosition;\n\n /** Offset of the dropdown element @default 8 */\n offset?: number | FloatingAxesOffsets;\n\n /** Called when dropdown position changes */\n onPositionChange?: (position: FloatingPosition) => void;\n\n /** Called when dropdown closes */\n onClose?: () => void;\n\n /** Called when the popover is dismissed by clicking outside or by pressing escape */\n onDismiss?: () => void;\n\n /** Called when dropdown opens */\n onOpen?: () => void;\n\n /** If set, the dropdown is not unmounted from the DOM when hidden. `display: none` styles are added instead. */\n keepMounted?: boolean;\n\n /**\n * Controls how the dropdown is hidden when `keepMounted` is set:\n * `'activity'` – hidden with React 19 `Activity` component,\n * `'display-none'` – hidden with `display: none` styles\n * @default 'activity'\n */\n keepMountedMode?: 'activity' | 'display-none';\n\n /** Props passed down to the `Transition` component. Use to configure duration and animation type. @default { duration: 150, transition: 'fade' } */\n transitionProps?: TransitionOverride;\n\n /** Called when exit transition ends */\n onExitTransitionEnd?: () => void;\n\n /** Called when enter transition ends */\n onEnterTransitionEnd?: () => void;\n\n /** Dropdown width, or `'target'` to make dropdown width the same as target element @default 'max-content' */\n width?: PopoverWidth;\n\n /** Floating ui middlewares to configure position handling @default { flip: true, shift: true, inline: false } */\n middlewares?: PopoverMiddlewares;\n\n /** Determines whether component should have an arrow @default false */\n withArrow?: boolean;\n\n /** Determines whether the overlay should be displayed when the dropdown is opened @default false */\n withOverlay?: boolean;\n\n /** Props passed down to `Overlay` component */\n overlayProps?: OverlayProps & ElementProps<'div'>;\n\n /** Arrow size in px @default 7 */\n arrowSize?: number;\n\n /** Arrow offset in px @default 5 */\n arrowOffset?: number;\n\n /** Arrow `border-radius` in px @default 0 */\n arrowRadius?: number;\n\n /** Arrow position */\n arrowPosition?: ArrowPosition;\n\n /** Determines whether dropdown should be rendered within the `Portal` @default true */\n withinPortal?: boolean;\n\n /** Props to pass down to the `Portal` when `withinPortal` is true */\n portalProps?: BasePortalProps;\n\n /** Dropdown `z-index` @default 300 */\n zIndex?: string | number;\n\n /** Key of `theme.radius` or any valid CSS value to set border-radius @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Key of `theme.shadows` or any other valid CSS `box-shadow` value */\n shadow?: MantineShadow;\n\n /** If set, popover dropdown will not be rendered */\n disabled?: boolean;\n\n /** Determines whether focus should be automatically returned to control when dropdown closes @default false */\n returnFocus?: boolean;\n\n /** Changes floating ui [position strategy](https://floating-ui.com/docs/usefloating#strategy) @default 'absolute' */\n floatingStrategy?: FloatingStrategy;\n\n /** If set, the dropdown is hidden when the element is hidden with styles or not visible on the screen @default true */\n hideDetached?: boolean;\n\n /** If `true`, the dropdown picks its side on open (flip runs once, preferring the `position` prop) and then never changes side — scrolling, resizing, and content size changes will not flip the dropdown. The side is recalculated fresh on the next open. Does not affect the `shift` middleware. Set to `false` to keep flip active and allow the dropdown to re-flip on every change. @default true */\n preventPositionChangeWhenVisible?: boolean;\n}\n\nexport interface PopoverProps extends __PopoverProps, StylesApiProps<PopoverFactory> {\n __staticSelector?: string;\n\n /** `Popover.Target` and `Popover.Dropdown` components */\n children?: React.ReactNode;\n\n /** Initial opened state for uncontrolled component */\n defaultOpened?: boolean;\n\n /** Controlled dropdown opened state */\n opened?: boolean;\n\n /** Called with current state when dropdown opens or closes */\n onChange?: (opened: boolean) => void;\n\n /** Determines whether dropdown should be closed on outside clicks @default true */\n closeOnClickOutside?: boolean;\n\n /** Events that trigger outside clicks */\n clickOutsideEvents?: string[];\n\n /** Determines whether focus should be trapped within dropdown @default false */\n trapFocus?: boolean;\n\n /** Determines whether dropdown should be closed when `Escape` key is pressed @default true */\n closeOnEscape?: boolean;\n\n /** Id base to create accessibility connections */\n id?: string;\n\n /** Determines whether dropdown and target elements should have accessible roles @default true */\n withRoles?: boolean;\n}\n\nexport type PopoverFactory = Factory<{\n props: PopoverProps;\n stylesNames: PopoverStylesNames;\n vars: PopoverCssVariables;\n}>;\n\nconst defaultProps = {\n position: 'bottom',\n offset: 8,\n transitionProps: { transition: 'fade', duration: 150 },\n middlewares: { flip: true, shift: true, inline: false },\n arrowSize: 7,\n arrowOffset: 5,\n arrowRadius: 0,\n arrowPosition: 'side',\n closeOnClickOutside: true,\n withinPortal: true,\n closeOnEscape: true,\n trapFocus: false,\n withRoles: true,\n returnFocus: false,\n withOverlay: false,\n hideDetached: true,\n preventPositionChangeWhenVisible: true,\n clickOutsideEvents: ['mousedown', 'touchstart'],\n zIndex: getDefaultZIndex('popover'),\n __staticSelector: 'Popover',\n width: 'max-content',\n} satisfies Partial<PopoverProps>;\n\nconst varsResolver = createVarsResolver<PopoverFactory>((_, { radius, shadow }) => ({\n dropdown: {\n '--popover-radius': radius === undefined ? undefined : getRadius(radius),\n '--popover-shadow': getShadow(shadow),\n },\n}));\n\nexport function Popover(_props: PopoverProps) {\n const props = useProps('Popover', defaultProps, _props);\n const {\n children,\n position,\n offset,\n onPositionChange,\n opened,\n transitionProps,\n onExitTransitionEnd,\n onEnterTransitionEnd,\n width,\n middlewares,\n withArrow,\n arrowSize,\n arrowOffset,\n arrowRadius,\n arrowPosition,\n unstyled,\n classNames,\n styles,\n closeOnClickOutside,\n withinPortal,\n portalProps,\n closeOnEscape,\n clickOutsideEvents,\n trapFocus,\n onClose,\n onDismiss,\n onOpen,\n onChange,\n zIndex,\n radius,\n shadow,\n id,\n defaultOpened,\n __staticSelector,\n withRoles,\n disabled,\n returnFocus,\n variant,\n keepMounted,\n keepMountedMode,\n vars,\n floatingStrategy,\n withOverlay,\n overlayProps,\n hideDetached,\n attributes,\n preventPositionChangeWhenVisible,\n ...others\n } = props;\n\n const getStyles = useStyles<PopoverFactory>({\n name: __staticSelector,\n props,\n classes,\n classNames,\n styles,\n unstyled,\n attributes,\n rootSelector: 'dropdown',\n vars,\n varsResolver,\n });\n\n const { resolvedStyles } = useResolvedStylesApi<PopoverFactory>({ classNames, styles, props });\n\n const arrowRef = useRef<HTMLDivElement | null>(null);\n const [targetNode, setTargetNode] = useState<HTMLElement | null>(null);\n const [dropdownNode, setDropdownNode] = useState<HTMLElement | null>(null);\n const { dir } = useDirection();\n const env = useMantineEnv();\n\n const uid = useId(id);\n const popover = usePopover({\n middlewares,\n width,\n position: getFloatingPosition(dir, position),\n offset: typeof offset === 'number' ? offset + (withArrow ? arrowSize / 2 : 0) : offset,\n arrowRef,\n arrowOffset,\n onPositionChange,\n opened,\n defaultOpened,\n onChange,\n onOpen,\n onClose,\n onDismiss,\n strategy: floatingStrategy,\n disabled,\n preventPositionChangeWhenVisible,\n keepMounted,\n });\n\n useClickOutside(\n () => {\n if (closeOnClickOutside) {\n popover.onClose();\n onDismiss?.();\n }\n },\n clickOutsideEvents,\n [targetNode, dropdownNode]\n );\n\n const reference = useCallback(\n (node: HTMLElement) => {\n setTargetNode(node);\n popover.floating.refs.setReference(node);\n },\n [popover.floating.refs.setReference]\n );\n\n const floating = useCallback(\n (node: HTMLElement) => {\n setDropdownNode(node);\n popover.floating.refs.setFloating(node);\n },\n [popover.floating.refs.setFloating]\n );\n\n const onExited = useCallback(() => {\n transitionProps?.onExited?.();\n onExitTransitionEnd?.();\n popover.resetLockedPlacement();\n }, [transitionProps?.onExited, onExitTransitionEnd, popover.resetLockedPlacement]);\n\n const onEntered = useCallback(() => {\n transitionProps?.onEntered?.();\n onEnterTransitionEnd?.();\n }, [transitionProps?.onEntered, onEnterTransitionEnd]);\n\n return (\n <PopoverContextProvider\n value={{\n returnFocus,\n disabled,\n controlled: popover.controlled,\n reference,\n floating,\n x: popover.floating.x,\n y: popover.floating.y,\n arrowX: popover.floating?.middlewareData?.arrow?.x,\n arrowY: popover.floating?.middlewareData?.arrow?.y,\n opened: popover.opened,\n arrowRef,\n transitionProps: { ...transitionProps, onExited, onEntered },\n width,\n withArrow,\n arrowSize,\n arrowOffset,\n arrowRadius,\n arrowPosition,\n placement: popover.floating.placement,\n trapFocus,\n withinPortal,\n portalProps,\n zIndex,\n radius,\n shadow,\n closeOnEscape,\n onDismiss,\n onClose: popover.onClose,\n onToggle: popover.onToggle,\n getTargetId: () => uid,\n getDropdownId: () => `${uid}-dropdown`,\n withRoles,\n targetProps: others,\n __staticSelector,\n classNames,\n styles,\n unstyled,\n variant,\n keepMounted,\n keepMountedMode,\n getStyles,\n resolvedStyles,\n floatingStrategy,\n referenceHidden:\n hideDetached && env !== 'test'\n ? popover.floating.middlewareData.hide?.referenceHidden\n : false,\n }}\n >\n {children}\n {withOverlay && (\n <Transition\n transition=\"fade\"\n mounted={popover.opened}\n duration={transitionProps?.duration || 250}\n exitDuration={transitionProps?.exitDuration || 250}\n >\n {(transitionStyles) => (\n <OptionalPortal withinPortal={withinPortal}>\n <Overlay\n {...overlayProps}\n {...getStyles('overlay', {\n className: overlayProps?.className,\n style: [transitionStyles, overlayProps?.style],\n })}\n />\n </OptionalPortal>\n )}\n </Transition>\n )}\n </PopoverContextProvider>\n );\n}\n\nPopover.Target = PopoverTarget;\nPopover.Dropdown = PopoverDropdown;\nPopover.ContextMenu = PopoverContextMenu;\nPopover.varsResolver = varsResolver;\nPopover.displayName = '@mantine/core/Popover';\nPopover.extend = (input: ExtendComponent<PopoverFactory>) => input;\nPopover.withProps = (fixedProps: Partial<PopoverProps>) => {\n const Extended = (props: PopoverProps) => <Popover {...fixedProps} {...props} />;\n Extended.extend = Popover.extend;\n Extended.displayName = `WithProps(${Popover.displayName})`;\n return Extended;\n};\n\nexport namespace Popover {\n export type Props = PopoverProps;\n export type __Props = __PopoverProps;\n export type Factory = PopoverFactory;\n export type StylesNames = PopoverStylesNames;\n export type TargetProps = PopoverTargetProps;\n export type DropdownProps = PopoverDropdownProps;\n export type Width = PopoverWidth;\n export type ContextValue = PopoverContextValue;\n\n export namespace Target {\n export type Props = PopoverTargetProps;\n }\n\n export namespace Dropdown {\n export type Props = PopoverDropdownProps;\n }\n\n export namespace ContextMenu {\n export type Props = PopoverContextMenuProps;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsLA,MAAM,eAAe;CACnB,UAAU;CACV,QAAQ;CACR,iBAAiB;EAAE,YAAY;EAAQ,UAAU;CAAI;CACrD,aAAa;EAAE,MAAM;EAAM,OAAO;EAAM,QAAQ;CAAM;CACtD,WAAW;CACX,aAAa;CACb,aAAa;CACb,eAAe;CACf,qBAAqB;CACrB,cAAc;CACd,eAAe;CACf,WAAW;CACX,WAAW;CACX,aAAa;CACb,aAAa;CACb,cAAc;CACd,kCAAkC;CAClC,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,QAAQ;GACjB,UAAU,iBAAiB,YAAY;GACvC,cAAc,iBAAiB,gBAAgB;cAE7C,qBACA,oBAAC,gBAAD;IAA8B;cAC5B,oBAAC,SAAD;KACE,GAAI;KACJ,GAAI,UAAU,WAAW;MACvB,WAAW,cAAc;MACzB,OAAO,CAAC,kBAAkB,cAAc,KAAK;KAC/C,CAAC;IACF,CAAA;GACa,CAAA;EAER,CAAA,CAEQ;;AAE5B;AAEA,QAAQ,SAAS;AACjB,QAAQ,WAAW;AACnB,QAAQ,cAAc;AACtB,QAAQ,eAAe;AACvB,QAAQ,cAAc;AACtB,QAAQ,UAAU,UAA2C;AAC7D,QAAQ,aAAa,eAAsC;CACzD,MAAM,YAAY,UAAwB,oBAAC,SAAD;EAAS,GAAI;EAAY,GAAI;CAAQ,CAAA;CAC/E,SAAS,SAAS,QAAQ;CAC1B,SAAS,cAAc,aAAa,QAAQ,YAAY;CACxD,OAAO;AACT"}
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
import { getSingleElementChild } from "../../../core/utils/get-single-element-child/get-single-element-child.mjs";
|
|
3
3
|
import { useProps } from "../../../core/MantineProvider/use-props/use-props.mjs";
|
|
4
4
|
import { usePopoverContext } from "../Popover.context.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { useContextMenuHandlers } from "../../../utils/Floating/use-context-menu-handlers.mjs";
|
|
6
6
|
import { cloneElement } from "react";
|
|
7
7
|
//#region packages/@mantine/core/src/components/Popover/PopoverContextMenu/PopoverContextMenu.tsx
|
|
8
8
|
function PopoverContextMenu(props) {
|
|
9
|
-
const { children, disabled } = useProps("PopoverContextMenu", null, props);
|
|
9
|
+
const { children, disabled, longPressDelay } = useProps("PopoverContextMenu", null, props);
|
|
10
10
|
const child = getSingleElementChild(children);
|
|
11
11
|
if (!child) throw new Error("Popover.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported");
|
|
12
12
|
const ctx = usePopoverContext();
|
|
13
|
-
return cloneElement(child,
|
|
13
|
+
return cloneElement(child, useContextMenuHandlers({
|
|
14
14
|
childProps: child.props,
|
|
15
15
|
disabled: disabled || ctx.disabled,
|
|
16
16
|
opened: ctx.opened,
|
|
17
|
+
longPressDelay,
|
|
17
18
|
setReference: ctx.reference,
|
|
18
19
|
open: () => {
|
|
19
20
|
if (!ctx.opened) ctx.onToggle();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverContextMenu.mjs","names":[],"sources":["../../../../src/components/Popover/PopoverContextMenu/PopoverContextMenu.tsx"],"sourcesContent":["import { cloneElement } from 'react';\nimport { getSingleElementChild, useProps } from '../../../core';\nimport {
|
|
1
|
+
{"version":3,"file":"PopoverContextMenu.mjs","names":[],"sources":["../../../../src/components/Popover/PopoverContextMenu/PopoverContextMenu.tsx"],"sourcesContent":["import { cloneElement } from 'react';\nimport { getSingleElementChild, useProps } from '../../../core';\nimport { useContextMenuHandlers } from '../../../utils/Floating/use-context-menu-handlers';\nimport { usePopoverContext } from '../Popover.context';\n\nexport interface PopoverContextMenuProps {\n /** Element that opens the popover when right-clicked. Dropdown is positioned at the cursor. The trigger element must not call `event.preventDefault()` in its own `onContextMenu` handler, otherwise the native context menu is not suppressed. */\n children: React.ReactNode;\n\n /** If set, the right-click trigger is disabled and the browser's default context menu is shown */\n disabled?: boolean;\n\n /** Delay in ms before a touch long-press opens the dropdown on touch devices, `500` by default */\n longPressDelay?: number;\n}\n\nexport function PopoverContextMenu(props: PopoverContextMenuProps) {\n const { children, disabled, longPressDelay } = useProps('PopoverContextMenu', null, props);\n\n const child = getSingleElementChild(children);\n if (!child) {\n throw new Error(\n 'Popover.ContextMenu component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported'\n );\n }\n\n const ctx = usePopoverContext();\n\n const handlers = useContextMenuHandlers({\n childProps: child.props as any,\n disabled: disabled || ctx.disabled,\n opened: ctx.opened,\n longPressDelay,\n setReference: ctx.reference as unknown as (node: object) => void,\n open: () => {\n if (!ctx.opened) {\n ctx.onToggle();\n }\n },\n });\n\n return cloneElement(child, handlers as any);\n}\n\nPopoverContextMenu.displayName = '@mantine/core/PopoverContextMenu';\n"],"mappings":";;;;;;;AAgBA,SAAgB,mBAAmB,OAAgC;CACjE,MAAM,EAAE,UAAU,UAAU,mBAAmB,SAAS,sBAAsB,MAAM,KAAK;CAEzF,MAAM,QAAQ,sBAAsB,QAAQ;CAC5C,IAAI,CAAC,OACH,MAAM,IAAI,MACR,uKACF;CAGF,MAAM,MAAM,kBAAkB;CAe9B,OAAO,aAAa,OAbH,uBAAuB;EACtC,YAAY,MAAM;EAClB,UAAU,YAAY,IAAI;EAC1B,QAAQ,IAAI;EACZ;EACA,cAAc,IAAI;EAClB,YAAY;GACV,IAAI,CAAC,IAAI,QACP,IAAI,SAAS;EAEjB;CACF,CAEkC,CAAQ;AAC5C;AAEA,mBAAmB,cAAc"}
|
|
@@ -45,6 +45,7 @@ const PopoverDropdown = factory((_props) => {
|
|
|
45
45
|
transition: ctx.transitionProps?.transition || "fade",
|
|
46
46
|
duration: ctx.transitionProps?.duration ?? 150,
|
|
47
47
|
keepMounted: ctx.keepMounted,
|
|
48
|
+
keepMountedMode: ctx.keepMountedMode,
|
|
48
49
|
exitDuration: typeof ctx.transitionProps?.exitDuration === "number" ? ctx.transitionProps.exitDuration : ctx.transitionProps?.duration,
|
|
49
50
|
children: (transitionStyles) => /* @__PURE__ */ jsx(FocusTrap, {
|
|
50
51
|
active: ctx.trapFocus && ctx.opened,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopoverDropdown.mjs","names":["classes"],"sources":["../../../../src/components/Popover/PopoverDropdown/PopoverDropdown.tsx"],"sourcesContent":["import { useFocusReturn, useMergedRef } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n closeOnEscape,\n CompoundStylesApiProps,\n ElementProps,\n factory,\n Factory,\n rem,\n useDirection,\n useProps,\n} from '../../../core';\nimport { FloatingArrow, getArrowMergeDropdownStyles } from '../../../utils/Floating';\nimport { FocusTrap } from '../../FocusTrap';\nimport { OptionalPortal } from '../../Portal';\nimport { Transition } from '../../Transition';\nimport type { PopoverStylesNames } from '../Popover';\nimport { usePopoverContext } from '../Popover.context';\nimport classes from '../Popover.module.css';\n\nexport interface PopoverDropdownProps\n extends BoxProps, CompoundStylesApiProps<PopoverDropdownFactory>, ElementProps<'div'> {}\n\nexport type PopoverDropdownFactory = Factory<{\n props: PopoverDropdownProps;\n ref: HTMLDivElement;\n stylesNames: PopoverStylesNames;\n compound: true;\n}>;\n\nexport const PopoverDropdown = factory<PopoverDropdownFactory>((_props) => {\n const props = useProps('PopoverDropdown', null, _props);\n const {\n className,\n style,\n vars,\n children,\n onKeyDownCapture,\n variant,\n classNames,\n styles,\n ref,\n ...others\n } = props;\n\n const ctx = usePopoverContext();\n const { dir } = useDirection();\n\n const mergeStyles =\n ctx.arrowPosition === 'merge' && ctx.withArrow\n ? getArrowMergeDropdownStyles({ position: ctx.placement, dir })\n : undefined;\n\n const returnFocus = useFocusReturn({\n opened: ctx.opened,\n shouldReturnFocus: ctx.returnFocus,\n });\n\n const accessibleProps = ctx.withRoles\n ? {\n 'aria-labelledby': ctx.getTargetId(),\n id: ctx.getDropdownId(),\n role: 'dialog',\n tabIndex: -1,\n }\n : {};\n\n const mergedRef = useMergedRef(ref, ctx.floating);\n\n if (ctx.disabled) {\n return null;\n }\n\n return (\n <OptionalPortal {...ctx.portalProps} withinPortal={ctx.withinPortal}>\n <Transition\n mounted={ctx.opened}\n {...ctx.transitionProps}\n transition={ctx.transitionProps?.transition || 'fade'}\n duration={ctx.transitionProps?.duration ?? 150}\n keepMounted={ctx.keepMounted}\n exitDuration={\n typeof ctx.transitionProps?.exitDuration === 'number'\n ? ctx.transitionProps.exitDuration\n : ctx.transitionProps?.duration\n }\n >\n {(transitionStyles) => (\n <FocusTrap active={ctx.trapFocus && ctx.opened} innerRef={mergedRef}>\n <Box\n {...accessibleProps}\n {...others}\n variant={variant}\n onKeyDownCapture={closeOnEscape(\n () => {\n ctx.onClose?.();\n ctx.onDismiss?.();\n },\n {\n active: ctx.closeOnEscape,\n onTrigger: returnFocus,\n onKeyDown: onKeyDownCapture,\n }\n )}\n data-position={ctx.placement}\n data-fixed={ctx.floatingStrategy === 'fixed' || undefined}\n {...ctx.getStyles('dropdown', {\n className,\n props,\n classNames,\n styles,\n style: [\n {\n ...transitionStyles,\n ...mergeStyles,\n zIndex: ctx.zIndex as React.CSSProperties['zIndex'],\n top: ctx.y ?? 0,\n left: ctx.x ?? 0,\n width: ctx.width === 'target' ? undefined : rem(ctx.width),\n ...(ctx.referenceHidden ? { display: 'none' } : null),\n },\n ctx.resolvedStyles?.dropdown,\n styles?.dropdown,\n style,\n ],\n })}\n >\n {children}\n\n <FloatingArrow\n ref={ctx.arrowRef}\n arrowX={ctx.arrowX}\n arrowY={ctx.arrowY}\n visible={ctx.withArrow}\n position={ctx.placement}\n arrowSize={ctx.arrowSize}\n arrowRadius={ctx.arrowRadius}\n arrowOffset={ctx.arrowOffset}\n arrowPosition={ctx.arrowPosition}\n {...ctx.getStyles('arrow', {\n props,\n classNames,\n styles,\n })}\n />\n </Box>\n </FocusTrap>\n )}\n </Transition>\n </OptionalPortal>\n );\n});\n\nPopoverDropdown.classes = classes;\nPopoverDropdown.displayName = '@mantine/core/PopoverDropdown';\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,MAAa,kBAAkB,SAAiC,WAAW;CACzE,MAAM,QAAQ,SAAS,mBAAmB,MAAM,MAAM;CACtD,MAAM,EACJ,WACA,OACA,MACA,UACA,kBACA,SACA,YACA,QACA,KACA,GAAG,WACD;CAEJ,MAAM,MAAM,kBAAkB;CAC9B,MAAM,EAAE,QAAQ,aAAa;CAE7B,MAAM,cACJ,IAAI,kBAAkB,WAAW,IAAI,YACjC,4BAA4B;EAAE,UAAU,IAAI;EAAW;CAAI,CAAC,IAC5D,KAAA;CAEN,MAAM,cAAc,eAAe;EACjC,QAAQ,IAAI;EACZ,mBAA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,WAAW,IAAI;MACf,aAAa,IAAI;MACjB,aAAa,IAAI;MACjB,eAAe,IAAI;MACnB,GAAI,IAAI,UAAU,SAAS;OACzB;OACA;OACA;MACF,CAAC;KACF,CAAA,CACE;;GACI,CAAA;EAEH,CAAA;CACE,CAAA;AAEpB,CAAC;AAED,gBAAgB,UAAUA;AAC1B,gBAAgB,cAAc"}
|
|
1
|
+
{"version":3,"file":"PopoverDropdown.mjs","names":["classes"],"sources":["../../../../src/components/Popover/PopoverDropdown/PopoverDropdown.tsx"],"sourcesContent":["import { useFocusReturn, useMergedRef } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n closeOnEscape,\n CompoundStylesApiProps,\n ElementProps,\n factory,\n Factory,\n rem,\n useDirection,\n useProps,\n} from '../../../core';\nimport { FloatingArrow, getArrowMergeDropdownStyles } from '../../../utils/Floating';\nimport { FocusTrap } from '../../FocusTrap';\nimport { OptionalPortal } from '../../Portal';\nimport { Transition } from '../../Transition';\nimport type { PopoverStylesNames } from '../Popover';\nimport { usePopoverContext } from '../Popover.context';\nimport classes from '../Popover.module.css';\n\nexport interface PopoverDropdownProps\n extends BoxProps, CompoundStylesApiProps<PopoverDropdownFactory>, ElementProps<'div'> {}\n\nexport type PopoverDropdownFactory = Factory<{\n props: PopoverDropdownProps;\n ref: HTMLDivElement;\n stylesNames: PopoverStylesNames;\n compound: true;\n}>;\n\nexport const PopoverDropdown = factory<PopoverDropdownFactory>((_props) => {\n const props = useProps('PopoverDropdown', null, _props);\n const {\n className,\n style,\n vars,\n children,\n onKeyDownCapture,\n variant,\n classNames,\n styles,\n ref,\n ...others\n } = props;\n\n const ctx = usePopoverContext();\n const { dir } = useDirection();\n\n const mergeStyles =\n ctx.arrowPosition === 'merge' && ctx.withArrow\n ? getArrowMergeDropdownStyles({ position: ctx.placement, dir })\n : undefined;\n\n const returnFocus = useFocusReturn({\n opened: ctx.opened,\n shouldReturnFocus: ctx.returnFocus,\n });\n\n const accessibleProps = ctx.withRoles\n ? {\n 'aria-labelledby': ctx.getTargetId(),\n id: ctx.getDropdownId(),\n role: 'dialog',\n tabIndex: -1,\n }\n : {};\n\n const mergedRef = useMergedRef(ref, ctx.floating);\n\n if (ctx.disabled) {\n return null;\n }\n\n return (\n <OptionalPortal {...ctx.portalProps} withinPortal={ctx.withinPortal}>\n <Transition\n mounted={ctx.opened}\n {...ctx.transitionProps}\n transition={ctx.transitionProps?.transition || 'fade'}\n duration={ctx.transitionProps?.duration ?? 150}\n keepMounted={ctx.keepMounted}\n keepMountedMode={ctx.keepMountedMode}\n exitDuration={\n typeof ctx.transitionProps?.exitDuration === 'number'\n ? ctx.transitionProps.exitDuration\n : ctx.transitionProps?.duration\n }\n >\n {(transitionStyles) => (\n <FocusTrap active={ctx.trapFocus && ctx.opened} innerRef={mergedRef}>\n <Box\n {...accessibleProps}\n {...others}\n variant={variant}\n onKeyDownCapture={closeOnEscape(\n () => {\n ctx.onClose?.();\n ctx.onDismiss?.();\n },\n {\n active: ctx.closeOnEscape,\n onTrigger: returnFocus,\n onKeyDown: onKeyDownCapture,\n }\n )}\n data-position={ctx.placement}\n data-fixed={ctx.floatingStrategy === 'fixed' || undefined}\n {...ctx.getStyles('dropdown', {\n className,\n props,\n classNames,\n styles,\n style: [\n {\n ...transitionStyles,\n ...mergeStyles,\n zIndex: ctx.zIndex as React.CSSProperties['zIndex'],\n top: ctx.y ?? 0,\n left: ctx.x ?? 0,\n width: ctx.width === 'target' ? undefined : rem(ctx.width),\n ...(ctx.referenceHidden ? { display: 'none' } : null),\n },\n ctx.resolvedStyles?.dropdown,\n styles?.dropdown,\n style,\n ],\n })}\n >\n {children}\n\n <FloatingArrow\n ref={ctx.arrowRef}\n arrowX={ctx.arrowX}\n arrowY={ctx.arrowY}\n visible={ctx.withArrow}\n position={ctx.placement}\n arrowSize={ctx.arrowSize}\n arrowRadius={ctx.arrowRadius}\n arrowOffset={ctx.arrowOffset}\n arrowPosition={ctx.arrowPosition}\n {...ctx.getStyles('arrow', {\n props,\n classNames,\n styles,\n })}\n />\n </Box>\n </FocusTrap>\n )}\n </Transition>\n </OptionalPortal>\n );\n});\n\nPopoverDropdown.classes = classes;\nPopoverDropdown.displayName = '@mantine/core/PopoverDropdown';\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,MAAa,kBAAkB,SAAiC,WAAW;CACzE,MAAM,QAAQ,SAAS,mBAAmB,MAAM,MAAM;CACtD,MAAM,EACJ,WACA,OACA,MACA,UACA,kBACA,SACA,YACA,QACA,KACA,GAAG,WACD;CAEJ,MAAM,MAAM,kBAAkB;CAC9B,MAAM,EAAE,QAAQ,aAAa;CAE7B,MAAM,cACJ,IAAI,kBAAkB,WAAW,IAAI,YACjC,4BAA4B;EAAE,UAAU,IAAI;EAAW;CAAI,CAAC,IAC5D,KAAA;CAEN,MAAM,cAAc,eAAe;EACjC,QAAQ,IAAI;EACZ,mBAAmB,IAAI;CACzB,CAAC;CAED,MAAM,kBAAkB,IAAI,YACxB;EACE,mBAAmB,IAAI,YAAY;EACnC,IAAI,IAAI,cAAc;EACtB,MAAM;EACN,UAAU;CACZ,IACA,CAAC;CAEL,MAAM,YAAY,aAAa,KAAK,IAAI,QAAQ;CAEhD,IAAI,IAAI,UACN,OAAO;CAGT,OACE,oBAAC,gBAAD;EAAgB,GAAI,IAAI;EAAa,cAAc,IAAI;YACrD,oBAAC,YAAD;GACE,SAAS,IAAI;GACb,GAAI,IAAI;GACR,YAAY,IAAI,iBAAiB,cAAc;GAC/C,UAAU,IAAI,iBAAiB,YAAY;GAC3C,aAAa,IAAI;GACjB,iBAAiB,IAAI;GACrB,cACE,OAAO,IAAI,iBAAiB,iBAAiB,WACzC,IAAI,gBAAgB,eACpB,IAAI,iBAAiB;cAGzB,qBACA,oBAAC,WAAD;IAAW,QAAQ,IAAI,aAAa,IAAI;IAAQ,UAAU;cACxD,qBAAC,KAAD;KACE,GAAI;KACJ,GAAI;KACK;KACT,kBAAkB,oBACV;MACJ,IAAI,UAAU;MACd,IAAI,YAAY;KAClB,GACA;MACE,QAAQ,IAAI;MACZ,WAAW;MACX,WAAW;KACb,CACF;KACA,iBAAe,IAAI;KACnB,cAAY,IAAI,qBAAqB,WAAW,KAAA;KAChD,GAAI,IAAI,UAAU,YAAY;MAC5B;MACA;MACA;MACA;MACA,OAAO;OACL;QACE,GAAG;QACH,GAAG;QACH,QAAQ,IAAI;QACZ,KAAK,IAAI,KAAK;QACd,MAAM,IAAI,KAAK;QACf,OAAO,IAAI,UAAU,WAAW,KAAA,IAAY,IAAI,IAAI,KAAK;QACzD,GAAI,IAAI,kBAAkB,EAAE,SAAS,OAAO,IAAI;OAClD;OACA,IAAI,gBAAgB;OACpB,QAAQ;OACR;MACF;KACF,CAAC;eApCH,CAsCG,UAED,oBAAC,eAAD;MACE,KAAK,IAAI;MACT,QAAQ,IAAI;MACZ,QAAQ,IAAI;MACZ,SAAS,IAAI;MACb,UAAU,IAAI;MACd,WAAW,IAAI;MACf,aAAa,IAAI;MACjB,aAAa,IAAI;MACjB,eAAe,IAAI;MACnB,GAAI,IAAI,UAAU,SAAS;OACzB;OACA;OACA;MACF,CAAC;KACF,CAAA,CACE;;GACI,CAAA;EAEH,CAAA;CACE,CAAA;AAEpB,CAAC;AAED,gBAAgB,UAAUA;AAC1B,gBAAgB,cAAc"}
|
|
@@ -24,14 +24,18 @@ function getPopoverMiddlewares(options, getFloating, disableFlip, lockEnabled) {
|
|
|
24
24
|
} : userFlip;
|
|
25
25
|
middlewares.push(flip(flipOptions));
|
|
26
26
|
}
|
|
27
|
-
if (middlewaresOptions.shift)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
if (middlewaresOptions.shift) {
|
|
28
|
+
const shiftOptions = typeof middlewaresOptions.shift === "boolean" ? {} : middlewaresOptions.shift;
|
|
29
|
+
middlewares.push(shift((state) => {
|
|
30
|
+
const isVerticalPlacement = state.placement.startsWith("top") || state.placement.startsWith("bottom");
|
|
31
|
+
return {
|
|
32
|
+
limiter: limitShift(),
|
|
33
|
+
padding: 5,
|
|
34
|
+
...options.width === "target" && isVerticalPlacement ? { mainAxis: false } : null,
|
|
35
|
+
...shiftOptions
|
|
36
|
+
};
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
35
39
|
if (middlewaresOptions.inline) middlewares.push(typeof middlewaresOptions.inline === "boolean" ? inline() : inline(middlewaresOptions.inline));
|
|
36
40
|
middlewares.push(arrow({
|
|
37
41
|
element: options.arrowRef,
|
|
@@ -86,9 +90,17 @@ function usePopover(options) {
|
|
|
86
90
|
whileElementsMounted: !options.keepMounted ? autoUpdate : void 0
|
|
87
91
|
});
|
|
88
92
|
useEffect(() => {
|
|
89
|
-
if (!
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
if (!options.keepMounted) return;
|
|
94
|
+
const referenceElement = floating.refs.reference.current;
|
|
95
|
+
const floatingElement = floating.refs.floating.current;
|
|
96
|
+
if (_opened && referenceElement && floatingElement) return autoUpdate(referenceElement, floatingElement, floating.update);
|
|
97
|
+
}, [
|
|
98
|
+
options.keepMounted,
|
|
99
|
+
_opened,
|
|
100
|
+
floating.update,
|
|
101
|
+
floating.elements.reference,
|
|
102
|
+
floating.elements.floating
|
|
103
|
+
]);
|
|
92
104
|
const measuredAfterShowRef = useRef(false);
|
|
93
105
|
useIsomorphicEffect(() => {
|
|
94
106
|
if (!_opened) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-popover.mjs","names":[],"sources":["../../../src/components/Popover/use-popover.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport {\n arrow,\n autoUpdate,\n flip,\n hide,\n inline,\n limitShift,\n Middleware,\n offset,\n shift,\n size,\n useFloating,\n UseFloatingReturn,\n} from '@floating-ui/react';\nimport { useDidUpdate, useIsomorphicEffect, useUncontrolled } from '@mantine/hooks';\nimport { FloatingAxesOffsets, FloatingPosition, FloatingStrategy } from '../../utils/Floating';\nimport { PopoverMiddlewares, PopoverWidth } from './Popover.types';\n\ninterface UsePopoverOptions {\n offset: number | FloatingAxesOffsets;\n position: FloatingPosition;\n onPositionChange?: (position: FloatingPosition) => void;\n opened: boolean | undefined;\n defaultOpened: boolean | undefined;\n onChange?: (opened: boolean) => void;\n onClose?: () => void;\n onDismiss?: () => void;\n onOpen?: () => void;\n width: PopoverWidth;\n middlewares: PopoverMiddlewares | undefined;\n arrowRef: React.RefObject<HTMLDivElement | null>;\n arrowOffset: number;\n strategy?: FloatingStrategy;\n disabled: boolean | undefined;\n preventPositionChangeWhenVisible: boolean | undefined;\n keepMounted: boolean | undefined;\n}\n\nfunction getDefaultMiddlewares(middlewares: PopoverMiddlewares | undefined): PopoverMiddlewares {\n if (middlewares === undefined) {\n return { shift: true, flip: true };\n }\n\n const result = { ...middlewares };\n if (middlewares.shift === undefined) {\n result.shift = true;\n }\n\n if (middlewares.flip === undefined) {\n result.flip = true;\n }\n\n return result;\n}\n\nfunction getPopoverMiddlewares(\n options: UsePopoverOptions,\n getFloating: () => UseFloatingReturn<Element>,\n disableFlip: boolean,\n lockEnabled: boolean\n) {\n const middlewaresOptions = getDefaultMiddlewares(options.middlewares);\n const middlewares: Middleware[] = [offset(options.offset), hide()];\n\n if (middlewaresOptions.flip && !disableFlip) {\n const userFlip = typeof middlewaresOptions.flip === 'boolean' ? {} : middlewaresOptions.flip;\n const flipOptions = lockEnabled\n ? { fallbackStrategy: 'initialPlacement' as const, ...userFlip }\n : userFlip;\n middlewares.push(flip(flipOptions));\n }\n\n if (middlewaresOptions.shift) {\n middlewares.push(\n shift(\n typeof middlewaresOptions.shift === 'boolean'\n ? { limiter: limitShift(), padding: 5 }\n : { limiter: limitShift(), padding: 5, ...middlewaresOptions.shift }\n )\n );\n }\n\n if (middlewaresOptions.inline) {\n middlewares.push(\n typeof middlewaresOptions.inline === 'boolean' ? inline() : inline(middlewaresOptions.inline)\n );\n }\n\n middlewares.push(arrow({ element: options.arrowRef, padding: options.arrowOffset }));\n\n if (middlewaresOptions.size || options.width === 'target') {\n middlewares.push(\n size({\n ...(typeof middlewaresOptions.size === 'boolean' ? {} : middlewaresOptions.size),\n apply({ rects, availableWidth, availableHeight, ...rest }) {\n const floating = getFloating();\n const styles = floating.refs.floating.current?.style ?? {};\n\n if (middlewaresOptions.size) {\n // If custom apply function is given use that else set defaults\n if (typeof middlewaresOptions.size === 'object' && !!middlewaresOptions.size.apply) {\n middlewaresOptions.size.apply({ rects, availableWidth, availableHeight, ...rest });\n } else {\n Object.assign(styles, {\n maxWidth: `${availableWidth}px`,\n maxHeight: `${availableHeight}px`,\n });\n }\n }\n\n if (options.width === 'target') {\n Object.assign(styles, {\n width: `${rects.reference.width}px`,\n });\n }\n },\n })\n );\n }\n\n return middlewares;\n}\n\nexport function usePopover(options: UsePopoverOptions) {\n const [_opened, setOpened] = useUncontrolled({\n value: options.opened,\n defaultValue: options.defaultOpened,\n finalValue: false,\n onChange: options.onChange,\n });\n\n const previouslyOpened = useRef(_opened);\n\n const [lockedPlacement, setLockedPlacement] = useState<FloatingPosition | null>(null);\n const lockEnabled = options.preventPositionChangeWhenVisible !== false;\n\n const wasOpenedRef = useRef(_opened);\n if (_opened !== wasOpenedRef.current) {\n wasOpenedRef.current = _opened;\n if (_opened && lockedPlacement !== null) {\n setLockedPlacement(null);\n }\n }\n\n const resetLockedPlacement = useCallback(() => setLockedPlacement(null), []);\n\n const onClose = () => {\n if (_opened && !options.disabled) {\n setOpened(false);\n }\n };\n\n const onToggle = () => {\n if (!options.disabled) {\n setOpened(!_opened);\n }\n };\n\n const floating: UseFloatingReturn<Element> = useFloating({\n open: _opened,\n strategy: options.strategy,\n placement: lockEnabled ? (lockedPlacement ?? options.position) : options.position,\n middleware: getPopoverMiddlewares(\n options,\n () => floating,\n lockEnabled && lockedPlacement !== null,\n lockEnabled\n ),\n whileElementsMounted: !options.keepMounted ? autoUpdate : undefined,\n });\n\n useEffect(() => {\n if (!floating.refs.reference.current || !floating.refs.floating.current) {\n return;\n }\n\n if (_opened) {\n return autoUpdate(\n floating.refs.reference.current,\n floating.refs.floating.current,\n floating.update\n );\n }\n }, [_opened, floating.update]);\n\n const measuredAfterShowRef = useRef(false);\n\n useIsomorphicEffect(() => {\n if (!_opened) {\n measuredAfterShowRef.current = false;\n return;\n }\n\n if (!lockEnabled || lockedPlacement !== null) {\n return;\n }\n\n const flEl = floating.refs.floating.current as HTMLElement | null;\n if (!flEl || flEl.offsetHeight === 0 || flEl.offsetWidth === 0) {\n return;\n }\n\n if (!measuredAfterShowRef.current) {\n measuredAfterShowRef.current = true;\n floating.update();\n return;\n }\n\n if (floating.isPositioned) {\n setLockedPlacement(floating.placement);\n }\n }, [\n lockEnabled,\n _opened,\n floating.isPositioned,\n floating.placement,\n lockedPlacement,\n floating.update,\n ]);\n\n const previousPlacementRef = useRef(floating.placement);\n useIsomorphicEffect(() => {\n if (previousPlacementRef.current !== floating.placement) {\n previousPlacementRef.current = floating.placement;\n options.onPositionChange?.(floating.placement);\n }\n }, [floating.placement]);\n\n useDidUpdate(() => {\n if (_opened !== previouslyOpened.current) {\n if (!_opened) {\n options.onClose?.();\n } else {\n options.onOpen?.();\n }\n }\n\n previouslyOpened.current = _opened;\n }, [_opened, options.onClose, options.onOpen]);\n\n return {\n floating,\n controlled: typeof options.opened === 'boolean',\n opened: _opened,\n onClose,\n onToggle,\n resetLockedPlacement,\n };\n}\n"],"mappings":";;;;;AAuCA,SAAS,sBAAsB,aAAiE;CAC9F,IAAI,gBAAgB,KAAA,GAClB,OAAO;EAAE,OAAO;EAAM,MAAM;CAAK;CAGnC,MAAM,SAAS,EAAE,GAAG,YAAY;CAChC,IAAI,YAAY,UAAU,KAAA,GACxB,OAAO,QAAQ;CAGjB,IAAI,YAAY,SAAS,KAAA,GACvB,OAAO,OAAO;CAGhB,OAAO;AACT;AAEA,SAAS,sBACP,SACA,aACA,aACA,aACA;CACA,MAAM,qBAAqB,sBAAsB,QAAQ,WAAW;CACpE,MAAM,cAA4B,CA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C,IAAI,CAAC,QAAQ,KAAK,iBAAiB,KAAK,KAAK,gBAAgB,GAC3D;EAGF,IAAI,CAAC,qBAAqB,SAAS;GACjC,qBAAqB,UAAU;GAC/B,SAAS,OAAO;GAChB;EACF;EAEA,IAAI,SAAS,cACX,mBAAmB,SAAS,SAAS;CAEzC,GAAG;EACD;EACA;EACA,SAAS;EACT,SAAS;EACT;EACA,SAAS;CACX,CAAC;CAED,MAAM,uBAAuB,OAAO,SAAS,SAAS;CACtD,0BAA0B;EACxB,IAAI,qBAAqB,YAAY,SAAS,WAAW;GACvD,qBAAqB,UAAU,SAAS;GACxC,QAAQ,mBAAmB,SAAS,SAAS;EAC/C;CACF,GAAG,CAAC,SAAS,SAAS,CAAC;CAEvB,mBAAmB;EACjB,IAAI,YAAY,iBAAiB,SAC/B,IAAI,CAAC,SACH,QAAQ,UAAU;OAElB,QAAQ,SAAS;EAIrB,iBAAiB,UAAU;CAC7B,GAAG;EAAC;EAAS,QAAQ;EAAS,QAAQ;CAAM,CAAC;CAE7C,OAAO;EACL;EACA,YAAY,OAAO,QAAQ,WAAW;EACtC,QAAQ;EACR;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"use-popover.mjs","names":[],"sources":["../../../src/components/Popover/use-popover.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport {\n arrow,\n autoUpdate,\n flip,\n hide,\n inline,\n limitShift,\n Middleware,\n offset,\n shift,\n size,\n useFloating,\n UseFloatingReturn,\n} from '@floating-ui/react';\nimport { useDidUpdate, useIsomorphicEffect, useUncontrolled } from '@mantine/hooks';\nimport { FloatingAxesOffsets, FloatingPosition, FloatingStrategy } from '../../utils/Floating';\nimport { PopoverMiddlewares, PopoverWidth } from './Popover.types';\n\ninterface UsePopoverOptions {\n offset: number | FloatingAxesOffsets;\n position: FloatingPosition;\n onPositionChange?: (position: FloatingPosition) => void;\n opened: boolean | undefined;\n defaultOpened: boolean | undefined;\n onChange?: (opened: boolean) => void;\n onClose?: () => void;\n onDismiss?: () => void;\n onOpen?: () => void;\n width: PopoverWidth;\n middlewares: PopoverMiddlewares | undefined;\n arrowRef: React.RefObject<HTMLDivElement | null>;\n arrowOffset: number;\n strategy?: FloatingStrategy;\n disabled: boolean | undefined;\n preventPositionChangeWhenVisible: boolean | undefined;\n keepMounted: boolean | undefined;\n}\n\nfunction getDefaultMiddlewares(middlewares: PopoverMiddlewares | undefined): PopoverMiddlewares {\n if (middlewares === undefined) {\n return { shift: true, flip: true };\n }\n\n const result = { ...middlewares };\n if (middlewares.shift === undefined) {\n result.shift = true;\n }\n\n if (middlewares.flip === undefined) {\n result.flip = true;\n }\n\n return result;\n}\n\nfunction getPopoverMiddlewares(\n options: UsePopoverOptions,\n getFloating: () => UseFloatingReturn<Element>,\n disableFlip: boolean,\n lockEnabled: boolean\n) {\n const middlewaresOptions = getDefaultMiddlewares(options.middlewares);\n const middlewares: Middleware[] = [offset(options.offset), hide()];\n\n if (middlewaresOptions.flip && !disableFlip) {\n const userFlip = typeof middlewaresOptions.flip === 'boolean' ? {} : middlewaresOptions.flip;\n const flipOptions = lockEnabled\n ? { fallbackStrategy: 'initialPlacement' as const, ...userFlip }\n : userFlip;\n middlewares.push(flip(flipOptions));\n }\n\n if (middlewaresOptions.shift) {\n const shiftOptions =\n typeof middlewaresOptions.shift === 'boolean' ? {} : middlewaresOptions.shift;\n middlewares.push(\n shift((state) => {\n const isVerticalPlacement =\n state.placement.startsWith('top') || state.placement.startsWith('bottom');\n return {\n limiter: limitShift(),\n padding: 5,\n ...(options.width === 'target' && isVerticalPlacement ? { mainAxis: false } : null),\n ...shiftOptions,\n };\n })\n );\n }\n\n if (middlewaresOptions.inline) {\n middlewares.push(\n typeof middlewaresOptions.inline === 'boolean' ? inline() : inline(middlewaresOptions.inline)\n );\n }\n\n middlewares.push(arrow({ element: options.arrowRef, padding: options.arrowOffset }));\n\n if (middlewaresOptions.size || options.width === 'target') {\n middlewares.push(\n size({\n ...(typeof middlewaresOptions.size === 'boolean' ? {} : middlewaresOptions.size),\n apply({ rects, availableWidth, availableHeight, ...rest }) {\n const floating = getFloating();\n const styles = floating.refs.floating.current?.style ?? {};\n\n if (middlewaresOptions.size) {\n // If custom apply function is given use that else set defaults\n if (typeof middlewaresOptions.size === 'object' && !!middlewaresOptions.size.apply) {\n middlewaresOptions.size.apply({ rects, availableWidth, availableHeight, ...rest });\n } else {\n Object.assign(styles, {\n maxWidth: `${availableWidth}px`,\n maxHeight: `${availableHeight}px`,\n });\n }\n }\n\n if (options.width === 'target') {\n Object.assign(styles, {\n width: `${rects.reference.width}px`,\n });\n }\n },\n })\n );\n }\n\n return middlewares;\n}\n\nexport function usePopover(options: UsePopoverOptions) {\n const [_opened, setOpened] = useUncontrolled({\n value: options.opened,\n defaultValue: options.defaultOpened,\n finalValue: false,\n onChange: options.onChange,\n });\n\n const previouslyOpened = useRef(_opened);\n\n const [lockedPlacement, setLockedPlacement] = useState<FloatingPosition | null>(null);\n const lockEnabled = options.preventPositionChangeWhenVisible !== false;\n\n const wasOpenedRef = useRef(_opened);\n if (_opened !== wasOpenedRef.current) {\n wasOpenedRef.current = _opened;\n if (_opened && lockedPlacement !== null) {\n setLockedPlacement(null);\n }\n }\n\n const resetLockedPlacement = useCallback(() => setLockedPlacement(null), []);\n\n const onClose = () => {\n if (_opened && !options.disabled) {\n setOpened(false);\n }\n };\n\n const onToggle = () => {\n if (!options.disabled) {\n setOpened(!_opened);\n }\n };\n\n const floating: UseFloatingReturn<Element> = useFloating({\n open: _opened,\n strategy: options.strategy,\n placement: lockEnabled ? (lockedPlacement ?? options.position) : options.position,\n middleware: getPopoverMiddlewares(\n options,\n () => floating,\n lockEnabled && lockedPlacement !== null,\n lockEnabled\n ),\n whileElementsMounted: !options.keepMounted ? autoUpdate : undefined,\n });\n\n useEffect(() => {\n if (!options.keepMounted) {\n return undefined;\n }\n\n const referenceElement = floating.refs.reference.current;\n const floatingElement = floating.refs.floating.current;\n\n if (_opened && referenceElement && floatingElement) {\n return autoUpdate(referenceElement, floatingElement, floating.update);\n }\n\n return undefined;\n }, [\n options.keepMounted,\n _opened,\n floating.update,\n floating.elements.reference,\n floating.elements.floating,\n ]);\n\n const measuredAfterShowRef = useRef(false);\n\n useIsomorphicEffect(() => {\n if (!_opened) {\n measuredAfterShowRef.current = false;\n return;\n }\n\n if (!lockEnabled || lockedPlacement !== null) {\n return;\n }\n\n const flEl = floating.refs.floating.current as HTMLElement | null;\n if (!flEl || flEl.offsetHeight === 0 || flEl.offsetWidth === 0) {\n return;\n }\n\n if (!measuredAfterShowRef.current) {\n measuredAfterShowRef.current = true;\n floating.update();\n return;\n }\n\n if (floating.isPositioned) {\n setLockedPlacement(floating.placement);\n }\n }, [\n lockEnabled,\n _opened,\n floating.isPositioned,\n floating.placement,\n lockedPlacement,\n floating.update,\n ]);\n\n const previousPlacementRef = useRef(floating.placement);\n useIsomorphicEffect(() => {\n if (previousPlacementRef.current !== floating.placement) {\n previousPlacementRef.current = floating.placement;\n options.onPositionChange?.(floating.placement);\n }\n }, [floating.placement]);\n\n useDidUpdate(() => {\n if (_opened !== previouslyOpened.current) {\n if (!_opened) {\n options.onClose?.();\n } else {\n options.onOpen?.();\n }\n }\n\n previouslyOpened.current = _opened;\n }, [_opened, options.onClose, options.onOpen]);\n\n return {\n floating,\n controlled: typeof options.opened === 'boolean',\n opened: _opened,\n onClose,\n onToggle,\n resetLockedPlacement,\n };\n}\n"],"mappings":";;;;;AAuCA,SAAS,sBAAsB,aAAiE;CAC9F,IAAI,gBAAgB,KAAA,GAClB,OAAO;EAAE,OAAO;EAAM,MAAM;CAAK;CAGnC,MAAM,SAAS,EAAE,GAAG,YAAY;CAChC,IAAI,YAAY,UAAU,KAAA,GACxB,OAAO,QAAQ;CAGjB,IAAI,YAAY,SAAS,KAAA,GACvB,OAAO,OAAO;CAGhB,OAAO;AACT;AAEA,SAAS,sBACP,SACA,aACA,aACA,aACA;CACA,MAAM,qBAAqB,sBAAsB,QAAQ,WAAW;CAC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;EACR;EACA,SAAS;EACT,SAAS,SAAS;EAClB,SAAS,SAAS;CACpB,CAAC;CAED,MAAM,uBAAuB,OAAO,KAAK;CAEzC,0BAA0B;EACxB,IAAI,CAAC,SAAS;GACZ,qBAAqB,UAAU;GAC/B;EACF;EAEA,IAAI,CAAC,eAAe,oBAAoB,MACtC;EAGF,MAAM,OAAO,SAAS,KAAK,SAAS;EACpC,IAAI,CAAC,QAAQ,KAAK,iBAAiB,KAAK,KAAK,gBAAgB,GAC3D;EAGF,IAAI,CAAC,qBAAqB,SAAS;GACjC,qBAAqB,UAAU;GAC/B,SAAS,OAAO;GAChB;EACF;EAEA,IAAI,SAAS,cACX,mBAAmB,SAAS,SAAS;CAEzC,GAAG;EACD;EACA;EACA,SAAS;EACT,SAAS;EACT;EACA,SAAS;CACX,CAAC;CAED,MAAM,uBAAuB,OAAO,SAAS,SAAS;CACtD,0BAA0B;EACxB,IAAI,qBAAqB,YAAY,SAAS,WAAW;GACvD,qBAAqB,UAAU,SAAS;GACxC,QAAQ,mBAAmB,SAAS,SAAS;EAC/C;CACF,GAAG,CAAC,SAAS,SAAS,CAAC;CAEvB,mBAAmB;EACjB,IAAI,YAAY,iBAAiB,SAC/B,IAAI,CAAC,SACH,QAAQ,UAAU;OAElB,QAAQ,SAAS;EAIrB,iBAAiB,UAAU;CAC7B,GAAG;EAAC;EAAS,QAAQ;EAAS,QAAQ;CAAM,CAAC;CAE7C,OAAO;EACL;EACA,YAAY,OAAO,QAAQ,WAAW;EACtC,QAAQ;EACR;EACA;EACA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.module.mjs","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.module.css"],"sourcesContent":[".root {\n --sc-padding-xs: 2px 6px;\n --sc-padding-sm: 3px 10px;\n --sc-padding-md: 4px 14px;\n --sc-padding-lg: 7px 16px;\n --sc-padding-xl: 10px 20px;\n\n --sc-transition-duration: 200ms;\n --sc-padding: var(--sc-padding-sm);\n --sc-transition-timing-function: ease;\n --sc-font-size: var(--mantine-font-size-sm);\n\n position: relative;\n display: inline-flex;\n flex-direction: row;\n width: auto;\n border-radius: var(--sc-radius, var(--mantine-radius-default));\n overflow: hidden;\n padding: 4px;\n\n &:where([data-full-width]) {\n display: flex;\n }\n\n &:where([data-orientation='vertical']) {\n display: flex;\n flex-direction: column;\n width: max-content;\n\n &:where([data-full-width]) {\n width: auto;\n }\n }\n\n @mixin where-light {\n background-color: var(--mantine-color-gray-1);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-8);\n }\n}\n\n.indicator {\n position: absolute;\n display: block;\n z-index: 1;\n border-radius: calc(var(--sc-radius, var(--mantine-radius-default)) - 4px);\n\n @mixin where-light {\n box-shadow: var(--sc-shadow, none);\n background-color: var(--sc-color, var(--mantine-color-white));\n }\n\n @mixin where-dark {\n box-shadow: none;\n background-color: var(--sc-color, var(--mantine-color-dark-5));\n }\n}\n\n.label {\n -webkit-tap-highlight-color: transparent;\n font-weight: var(--mantine-font-weight-medium);\n display: block;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n user-select: none;\n border-radius: calc(var(--sc-radius, var(--mantine-radius-default)) - 4px);\n font-size: var(--sc-font-size);\n padding: var(--sc-padding);\n transition: color var(--sc-transition-duration) var(--sc-transition-timing-function);\n cursor: pointer;\n\n /* outline is controlled by .input */\n outline: var(--segmented-control-outline, none);\n\n @mixin where-light {\n color: var(--mantine-color-gray-7);\n }\n\n @mixin where-dark {\n color: var(--mantine-color-dark-1);\n }\n\n &:where([data-read-only]) {\n cursor: default;\n }\n\n fieldset:disabled &,\n &:where([data-disabled]) {\n cursor: not-allowed;\n color: var(--mantine-color-disabled-color);\n }\n\n &:where([data-active]) {\n @mixin where-light {\n color: var(--sc-label-color, var(--mantine-color-black));\n }\n\n @mixin where-dark {\n color: var(--sc-label-color, var(--mantine-color-white));\n }\n\n &::before {\n .root:where([data-initialized]) & {\n display: none;\n }\n content: '';\n inset: 0;\n z-index: 0;\n position: absolute;\n border-radius: calc(var(--sc-radius, var(--mantine-radius-default)) - 4px);\n\n @mixin where-light {\n box-shadow: var(--sc-shadow, none);\n background-color: var(--sc-color, var(--mantine-color-white));\n }\n\n @mixin where-dark {\n box-shadow: none;\n background-color: var(--sc-color, var(--mantine-color-dark-5));\n }\n }\n }\n\n &:where(:not([data-disabled], [data-active], [data-read-only])) {\n @mixin hover {\n @mixin where-light {\n color: var(--mantine-color-black);\n }\n\n @mixin where-dark {\n color: var(--mantine-color-white);\n }\n }\n }\n\n fieldset:disabled & {\n @mixin hover {\n color: var(--mantine-color-disabled-color) !important;\n }\n }\n}\n\n.input {\n height: 0;\n width: 0;\n position: absolute;\n overflow: hidden;\n white-space: nowrap;\n opacity: 0;\n\n &[data-focus-ring='auto'] {\n &:focus:focus-visible {\n & + .label {\n --segmented-control-outline: 2px solid var(--mantine-primary-color-filled);\n }\n }\n }\n\n &[data-focus-ring='always'] {\n &:focus {\n & + .label {\n --segmented-control-outline: 2px solid var(--mantine-primary-color-filled);\n }\n }\n }\n}\n\n.control {\n position: relative;\n flex: 1;\n z-index: 2;\n transition: border-color var(--sc-transition-duration) var(--sc-transition-timing-function);\n\n .root[data-with-items-borders] :where(&)::before {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n inset-inline-start: 0;\n background-color: var(--separator-color);\n width: 1px;\n transition: background-color var(--sc-transition-duration) var(--sc-transition-timing-function);\n }\n\n &[data-orientation='vertical'] {\n &::before {\n top: 0;\n inset-inline: 0;\n bottom: auto;\n height: 1px;\n width: auto;\n }\n }\n\n @mixin where-light {\n --separator-color: var(--mantine-color-gray-3);\n }\n\n @mixin where-dark {\n --separator-color: var(--mantine-color-dark-4);\n }\n\n &:first-of-type {\n &::before {\n --separator-color: transparent;\n }\n }\n\n &[data-active] {\n [data-mantine-color-scheme] & {\n &,\n & + .control {\n &::before {\n --separator-color: transparent;\n }\n }\n }\n }\n}\n\n.innerLabel {\n position: relative;\n z-index: 2;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"SegmentedControl.module.mjs","names":[],"sources":["../../../src/components/SegmentedControl/SegmentedControl.module.css"],"sourcesContent":[".root {\n --sc-padding-xs: 2px 6px;\n --sc-padding-sm: 3px 10px;\n --sc-padding-md: 4px 14px;\n --sc-padding-lg: 7px 16px;\n --sc-padding-xl: 10px 20px;\n\n --sc-transition-duration: 200ms;\n --sc-padding: var(--sc-padding-sm);\n --sc-transition-timing-function: ease;\n --sc-font-size: var(--mantine-font-size-sm);\n\n position: relative;\n display: inline-flex;\n flex-direction: row;\n width: auto;\n border-radius: var(--sc-radius, var(--mantine-radius-default));\n overflow: hidden;\n padding: 4px;\n\n &:where([data-full-width]) {\n display: flex;\n }\n\n &:where([data-orientation='vertical']) {\n display: flex;\n flex-direction: column;\n width: max-content;\n\n &:where([data-full-width]) {\n width: auto;\n }\n }\n\n @mixin where-light {\n background-color: var(--mantine-color-gray-1);\n }\n\n @mixin where-dark {\n background-color: var(--mantine-color-dark-8);\n }\n}\n\n.indicator {\n position: absolute;\n display: block;\n z-index: 1;\n border-radius: max(\n calc(var(--sc-radius, var(--mantine-radius-default)) - 4px),\n calc(var(--sc-radius, var(--mantine-radius-default)) / 4)\n );\n\n @mixin where-light {\n box-shadow: var(--sc-shadow, none);\n background-color: var(--sc-color, var(--mantine-color-white));\n }\n\n @mixin where-dark {\n box-shadow: none;\n background-color: var(--sc-color, var(--mantine-color-dark-5));\n }\n}\n\n.label {\n -webkit-tap-highlight-color: transparent;\n font-weight: var(--mantine-font-weight-medium);\n display: block;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n user-select: none;\n border-radius: calc(var(--sc-radius, var(--mantine-radius-default)) - 4px);\n font-size: var(--sc-font-size);\n padding: var(--sc-padding);\n transition: color var(--sc-transition-duration) var(--sc-transition-timing-function);\n cursor: pointer;\n\n /* outline is controlled by .input */\n outline: var(--segmented-control-outline, none);\n\n @mixin where-light {\n color: var(--mantine-color-gray-7);\n }\n\n @mixin where-dark {\n color: var(--mantine-color-dark-1);\n }\n\n &:where([data-read-only]) {\n cursor: default;\n }\n\n fieldset:disabled &,\n &:where([data-disabled]) {\n cursor: not-allowed;\n color: var(--mantine-color-disabled-color);\n }\n\n &:where([data-active]) {\n @mixin where-light {\n color: var(--sc-label-color, var(--mantine-color-black));\n }\n\n @mixin where-dark {\n color: var(--sc-label-color, var(--mantine-color-white));\n }\n\n &::before {\n .root:where([data-initialized]) & {\n display: none;\n }\n content: '';\n inset: 0;\n z-index: 0;\n position: absolute;\n border-radius: calc(var(--sc-radius, var(--mantine-radius-default)) - 4px);\n\n @mixin where-light {\n box-shadow: var(--sc-shadow, none);\n background-color: var(--sc-color, var(--mantine-color-white));\n }\n\n @mixin where-dark {\n box-shadow: none;\n background-color: var(--sc-color, var(--mantine-color-dark-5));\n }\n }\n }\n\n &:where(:not([data-disabled], [data-active], [data-read-only])) {\n @mixin hover {\n @mixin where-light {\n color: var(--mantine-color-black);\n }\n\n @mixin where-dark {\n color: var(--mantine-color-white);\n }\n }\n }\n\n fieldset:disabled & {\n @mixin hover {\n color: var(--mantine-color-disabled-color) !important;\n }\n }\n}\n\n.input {\n height: 0;\n width: 0;\n position: absolute;\n overflow: hidden;\n white-space: nowrap;\n opacity: 0;\n\n &[data-focus-ring='auto'] {\n &:focus:focus-visible {\n & + .label {\n --segmented-control-outline: 2px solid var(--mantine-primary-color-filled);\n }\n }\n }\n\n &[data-focus-ring='always'] {\n &:focus {\n & + .label {\n --segmented-control-outline: 2px solid var(--mantine-primary-color-filled);\n }\n }\n }\n}\n\n.control {\n position: relative;\n flex: 1;\n z-index: 2;\n transition: border-color var(--sc-transition-duration) var(--sc-transition-timing-function);\n\n .root[data-with-items-borders] :where(&)::before {\n content: '';\n position: absolute;\n top: 0;\n bottom: 0;\n inset-inline-start: 0;\n background-color: var(--separator-color);\n width: 1px;\n transition: background-color var(--sc-transition-duration) var(--sc-transition-timing-function);\n }\n\n &[data-orientation='vertical'] {\n &::before {\n top: 0;\n inset-inline: 0;\n bottom: auto;\n height: 1px;\n width: auto;\n }\n }\n\n @mixin where-light {\n --separator-color: var(--mantine-color-gray-3);\n }\n\n @mixin where-dark {\n --separator-color: var(--mantine-color-dark-4);\n }\n\n &:first-of-type {\n &::before {\n --separator-color: transparent;\n }\n }\n\n &[data-active] {\n [data-mantine-color-scheme] & {\n &,\n & + .control {\n &::before {\n --separator-color: transparent;\n }\n }\n }\n }\n}\n\n.innerLabel {\n position: relative;\n z-index: 2;\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Thumb.mjs","names":[],"sources":["../../../../src/components/Slider/Thumb/Thumb.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Box } from '../../../core';\nimport { Transition, TransitionOverride } from '../../Transition';\nimport { useSliderContext } from '../Slider.context';\n\nexport interface ThumbProps extends Omit<React.ComponentProps<'div'>, 'value'> {\n max: number;\n min: number;\n value: number;\n position: number;\n dragging: boolean;\n label: React.ReactNode;\n thumbValueText?: string | ((value: number) => string);\n onKeyDownCapture?: (event: React.KeyboardEvent<HTMLDivElement>) => void;\n onMouseDown?: (event: any) => void;\n labelTransitionProps: TransitionOverride | undefined;\n labelAlwaysOn: boolean | undefined;\n thumbLabel: string | undefined;\n showLabelOnHover: boolean | undefined;\n isHovered?: boolean;\n children?: React.ReactNode;\n disabled: boolean | undefined;\n orientation?: 'horizontal' | 'vertical';\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function Thumb({\n max,\n min,\n value,\n position,\n label,\n dragging,\n onMouseDown,\n onKeyDownCapture,\n labelTransitionProps,\n labelAlwaysOn,\n thumbLabel,\n thumbValueText,\n onFocus,\n onBlur,\n showLabelOnHover,\n isHovered,\n children = null,\n disabled,\n orientation = 'horizontal',\n ref,\n}: ThumbProps) {\n const { getStyles } = useSliderContext();\n\n const [focused, setFocused] = useState(false);\n\n const isVisible = labelAlwaysOn || dragging || focused || (showLabelOnHover && isHovered);\n const valueText = typeof thumbValueText === 'function' ? thumbValueText(value) : thumbValueText;\n\n return (\n <Box<'div'>\n tabIndex={disabled ? -1 : 0}\n role=\"slider\"\n aria-label={thumbLabel}\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={value}\n aria-valuetext={valueText}\n aria-disabled={disabled}\n aria-orientation={orientation}\n ref={ref}\n __vars={{ '--slider-thumb-offset': `${position}%` }}\n {...getStyles('thumb', { focusable: true })}\n mod={{ dragging, disabled }}\n onFocus={(event) => {\n setFocused(true);\n typeof onFocus === 'function' && onFocus(event);\n }}\n onBlur={(event) => {\n setFocused(false);\n typeof onBlur === 'function' && onBlur(event);\n }}\n onTouchStart={onMouseDown}\n onMouseDown={onMouseDown}\n onKeyDownCapture={onKeyDownCapture}\n onClick={(event) => event.stopPropagation()}\n >\n {children}\n <Transition\n mounted={label != null && !!isVisible}\n transition=\"fade\"\n duration={0}\n {...labelTransitionProps}\n >\n {(transitionStyles) => (\n <div {...getStyles('label', { style: transitionStyles })}>{label}</div>\n )}\n </Transition>\n </Box>\n );\n}\n\nThumb.displayName = '@mantine/core/SliderThumb';\n"],"mappings":";;;;;;;AA2BA,SAAgB,MAAM,EACpB,KACA,KACA,OACA,UACA,OACA,UACA,aACA,kBACA,sBACA,eACA,YACA,gBACA,SACA,QACA,kBACA,WACA,WAAW,MACX,UACA,cAAc,cACd,OACa;CACb,MAAM,EAAE,cAAc,iBAAiB;CAEvC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAE5C,MAAM,YAAY,iBAAiB,YAAY,WAAY,oBAAoB;CAC/E,MAAM,YAAY,OAAO,mBAAmB,aAAa,eAAe,KAAK,IAAI;CAEjF,OACE,qBAAC,KAAD;EACE,UAAU,WAAW,KAAK;EAC1B,MAAK;EACL,cAAY;EACZ,iBAAe;EACf,iBAAe;EACf,iBAAe;EACf,kBAAgB;EAChB,iBAAe;EACf,oBAAkB;EACb;EACL,QAAQ,EAAE,yBAAyB,GAAG,SAAS,GAAG;EAClD,GAAI,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;EAC1C,KAAK;GAAE;GAAU;EAAS;EAC1B,UAAU,UAAU;GAClB,WAAW,IAAI;GACf,OAAO,YAAY,cAAc,QAAQ,KAAK;EAChD;EACA,SAAS,UAAU;GACjB,WAAW,KAAK;GAChB,OAAO,WAAW,cAAc,OAAO,KAAK;EAC9C;EACA,cAAc;EACD;EACK;EAClB,UAAU,UAAU,MAAM,gBAAgB;YAzB5C,CA2BG,UACD,oBAAC,YAAD;GACE,SAAS,SAAS,QAAQ,CAAC,CAAC;GAC5B,YAAW;GACX,UAAU;GACV,GAAI;cAEF,qBACA,oBAAC,OAAD;IAAK,GAAI,UAAU,SAAS,EAAE,OAAO,iBAAiB,CAAC;cAAI;GAAW,CAAA;EAE9D,CAAA,CACT;;AAET;AAEA,MAAM,cAAc"}
|
|
1
|
+
{"version":3,"file":"Thumb.mjs","names":[],"sources":["../../../../src/components/Slider/Thumb/Thumb.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Box } from '../../../core';\nimport { Transition, TransitionOverride } from '../../Transition';\nimport { useSliderContext } from '../Slider.context';\n\nexport interface ThumbProps extends Omit<React.ComponentProps<'div'>, 'value'> {\n max: number;\n min: number;\n value: number;\n position: number;\n dragging: boolean;\n label: React.ReactNode;\n thumbValueText?: string | ((value: number) => string);\n onKeyDownCapture?: (event: React.KeyboardEvent<HTMLDivElement>) => void;\n onMouseDown?: (event: any) => void;\n labelTransitionProps: TransitionOverride | undefined;\n labelAlwaysOn: boolean | undefined;\n thumbLabel: string | undefined;\n showLabelOnHover: boolean | undefined;\n isHovered?: boolean;\n children?: React.ReactNode;\n disabled: boolean | undefined;\n orientation?: 'horizontal' | 'vertical';\n className?: string | undefined;\n style?: React.CSSProperties;\n}\n\nexport function Thumb({\n max,\n min,\n value,\n position,\n label,\n dragging,\n onMouseDown,\n onKeyDownCapture,\n labelTransitionProps,\n labelAlwaysOn,\n thumbLabel,\n thumbValueText,\n onFocus,\n onBlur,\n showLabelOnHover,\n isHovered,\n children = null,\n disabled,\n orientation = 'horizontal',\n ref,\n}: ThumbProps) {\n const { getStyles } = useSliderContext();\n\n const [focused, setFocused] = useState(false);\n\n const isVisible = labelAlwaysOn || dragging || focused || (showLabelOnHover && isHovered);\n const valueText = typeof thumbValueText === 'function' ? thumbValueText(value) : thumbValueText;\n\n return (\n <Box<'div'>\n tabIndex={disabled ? -1 : 0}\n role=\"slider\"\n aria-label={thumbLabel}\n aria-valuemax={max}\n aria-valuemin={min}\n aria-valuenow={value}\n aria-valuetext={valueText}\n aria-disabled={disabled}\n aria-orientation={orientation}\n ref={ref}\n __vars={{ '--slider-thumb-offset': `${position}%` }}\n {...getStyles('thumb', { focusable: true })}\n mod={{ dragging, disabled }}\n onFocus={(event) => {\n setFocused(true);\n typeof onFocus === 'function' && onFocus(event);\n }}\n onBlur={(event) => {\n setFocused(false);\n typeof onBlur === 'function' && onBlur(event);\n }}\n onTouchStart={onMouseDown}\n onMouseDown={onMouseDown}\n onKeyDownCapture={onKeyDownCapture}\n onClick={(event) => event.stopPropagation()}\n >\n {children}\n <Transition\n mounted={label != null && !!isVisible}\n transition=\"fade\"\n duration={0}\n {...labelTransitionProps}\n >\n {(transitionStyles) => (\n <div {...getStyles('label', { style: transitionStyles })}>{label}</div>\n )}\n </Transition>\n </Box>\n );\n}\n\nThumb.displayName = '@mantine/core/SliderThumb';\n"],"mappings":";;;;;;;AA2BA,SAAgB,MAAM,EACpB,KACA,KACA,OACA,UACA,OACA,UACA,aACA,kBACA,sBACA,eACA,YACA,gBACA,SACA,QACA,kBACA,WACA,WAAW,MACX,UACA,cAAc,cACd,OACa;CACb,MAAM,EAAE,cAAc,iBAAiB;CAEvC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAE5C,MAAM,YAAY,iBAAiB,YAAY,WAAY,oBAAoB;CAC/E,MAAM,YAAY,OAAO,mBAAmB,aAAa,eAAe,KAAK,IAAI;CAEjF,OACE,qBAAC,KAAD;EACE,UAAU,WAAW,KAAK;EAC1B,MAAK;EACL,cAAY;EACZ,iBAAe;EACf,iBAAe;EACf,iBAAe;EACf,kBAAgB;EAChB,iBAAe;EACf,oBAAkB;EACb;EACL,QAAQ,EAAE,yBAAyB,GAAG,SAAS,GAAG;EAClD,GAAI,UAAU,SAAS,EAAE,WAAW,KAAK,CAAC;EAC1C,KAAK;GAAE;GAAU;EAAS;EAC1B,UAAU,UAAU;GAClB,WAAW,IAAI;GACf,OAAO,YAAY,cAAc,QAAQ,KAAK;EAChD;EACA,SAAS,UAAU;GACjB,WAAW,KAAK;GAChB,OAAO,WAAW,cAAc,OAAO,KAAK;EAC9C;EACA,cAAc;EACD;EACK;EAClB,UAAU,UAAU,MAAM,gBAAgB;YAzB5C,CA2BG,UACD,oBAAC,YAAD;GACE,SAAS,SAAS,QAAQ,CAAC,CAAC;GAC5B,YAAW;GACX,UAAU;GACV,GAAI;cAEF,qBACA,oBAAC,OAAD;IAAK,GAAI,UAAU,SAAS,EAAE,OAAO,iBAAiB,CAAC;cAAI;GAAW,CAAA;EAE9D,CAAA,CACT;;AAET;AAEA,MAAM,cAAc"}
|
|
@@ -18,7 +18,8 @@ import { jsx } from "react/jsx-runtime";
|
|
|
18
18
|
const defaultProps = {
|
|
19
19
|
orientation: "horizontal",
|
|
20
20
|
lineSize: 2,
|
|
21
|
-
withHandle: true
|
|
21
|
+
withHandle: true,
|
|
22
|
+
resetOnDoubleClick: true
|
|
22
23
|
};
|
|
23
24
|
const varsResolver = createVarsResolver((theme, { lineSize, handleColor }) => ({ root: {
|
|
24
25
|
"--splitter-line-size": rem(lineSize),
|
|
@@ -26,7 +27,7 @@ const varsResolver = createVarsResolver((theme, { lineSize, handleColor }) => ({
|
|
|
26
27
|
} }));
|
|
27
28
|
const Splitter = factory((_props) => {
|
|
28
29
|
const props = useProps("Splitter", defaultProps, _props);
|
|
29
|
-
const { orientation, sizes: controlledSizes, onSizeChange, onResizeStart, onResizeEnd, onCollapseChange, redistribute, step, shiftStep, lineSize, handleColor, handleIcon, withHandle, splitterRef, children, className, classNames, style, styles, unstyled, vars, mod, attributes, ref, ...others } = props;
|
|
30
|
+
const { orientation, sizes: controlledSizes, onSizeChange, onResizeStart, onResizeEnd, onCollapseChange, redistribute, step, shiftStep, lineSize, handleColor, handleIcon, withHandle, resetOnDoubleClick, splitterRef, children, className, classNames, style, styles, unstyled, vars, mod, attributes, ref, ...others } = props;
|
|
30
31
|
const { dir } = useDirection();
|
|
31
32
|
const paneChildren = Children.toArray(children);
|
|
32
33
|
const splitter = useSplitter({
|
|
@@ -46,7 +47,8 @@ const Splitter = factory((_props) => {
|
|
|
46
47
|
redistribute,
|
|
47
48
|
step,
|
|
48
49
|
shiftStep,
|
|
49
|
-
dir
|
|
50
|
+
dir,
|
|
51
|
+
resetOnDoubleClick
|
|
50
52
|
});
|
|
51
53
|
useImperativeHandle(splitterRef, () => splitter, [splitter]);
|
|
52
54
|
const mergedRef = useMergedRef(ref, splitter.ref);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Splitter.mjs","names":["classes"],"sources":["../../../src/components/Splitter/Splitter.tsx"],"sourcesContent":["import { Children, cloneElement, useImperativeHandle } from 'react';\nimport {\n useMergedRef,\n useSplitter,\n UseSplitterRedistributeFn,\n UseSplitterReturnValue,\n} from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n useDirection,\n useProps,\n useStyles,\n} from '../../core';\nimport { GripHorizontalIcon, GripVerticalIcon } from './GripIcon';\nimport { SplitterProvider } from './Splitter.context';\nimport {\n SplitterPane,\n SplitterPaneProps,\n SplitterPaneStylesNames,\n} from './SplitterPane/SplitterPane';\nimport classes from './Splitter.module.css';\n\nexport type SplitterStylesNames = 'root' | 'handle' | 'thumb' | SplitterPaneStylesNames;\n\nexport type SplitterCssVariables = {\n root: '--splitter-line-size' | '--splitter-handle-color';\n};\n\nexport interface SplitterProps\n extends BoxProps, StylesApiProps<SplitterFactory>, ElementProps<'div'> {\n /** Layout direction @default 'horizontal' */\n orientation?: 'horizontal' | 'vertical';\n\n /** Controlled sizes (percentages summing to 100) */\n sizes?: number[];\n\n /** Called during resize with updated sizes */\n onSizeChange?: (sizes: number[]) => void;\n\n /** Called when drag starts */\n onResizeStart?: (handleIndex: number) => void;\n\n /** Called when drag ends */\n onResizeEnd?: (handleIndex: number, sizes: number[]) => void;\n\n /** Called when a panel collapses or expands */\n onCollapseChange?: (panelIndex: number, collapsed: boolean) => void;\n\n /** How to redistribute space when immediate neighbor is at its min/max */\n redistribute?: 'nearest' | 'equal' | UseSplitterRedistributeFn;\n\n /** Keyboard step size in percentage @default 1 */\n step?: number;\n\n /** Shift+arrow step size in percentage @default 10 */\n shiftStep?: number;\n\n /** CSS value for separator line thickness between panes @default 2 */\n lineSize?: number | string;\n\n /** Key of `theme.colors` or any valid CSS color for the separator line */\n handleColor?: MantineColor;\n\n /** Custom icon displayed in the handle thumb, by default uses grip icon based on orientation */\n handleIcon?: React.ReactNode;\n\n /** Determines whether the thumb with grip icon is displayed on the handle @default true */\n withHandle?: boolean;\n\n /** Ref to imperative splitter API (sizes, collapse, expand, etc.) */\n splitterRef?: React.RefObject<UseSplitterReturnValue | null>;\n\n /** Splitter panes */\n children?: React.ReactNode;\n}\n\nexport type SplitterFactory = Factory<{\n props: SplitterProps;\n ref: HTMLDivElement;\n stylesNames: SplitterStylesNames;\n vars: SplitterCssVariables;\n staticComponents: {\n Pane: typeof SplitterPane;\n };\n}>;\n\nconst defaultProps = {\n orientation: 'horizontal',\n lineSize: 2,\n withHandle: true,\n} satisfies Partial<SplitterProps>;\n\nconst varsResolver = createVarsResolver<SplitterFactory>((theme, { lineSize, handleColor }) => ({\n root: {\n '--splitter-line-size': rem(lineSize),\n '--splitter-handle-color': handleColor ? getThemeColor(handleColor, theme) : undefined,\n },\n}));\n\nexport const Splitter = factory<SplitterFactory>((_props) => {\n const props = useProps('Splitter', defaultProps, _props);\n const {\n orientation,\n sizes: controlledSizes,\n onSizeChange,\n onResizeStart,\n onResizeEnd,\n onCollapseChange,\n redistribute,\n step,\n shiftStep,\n lineSize,\n handleColor,\n handleIcon,\n withHandle,\n splitterRef,\n children,\n className,\n classNames,\n style,\n styles,\n unstyled,\n vars,\n mod,\n attributes,\n ref,\n ...others\n } = props;\n\n const { dir } = useDirection();\n\n const paneChildren = Children.toArray(children) as React.ReactElement<SplitterPaneProps>[];\n\n const panels = paneChildren.map((child) => ({\n defaultSize: child.props.defaultSize,\n min: child.props.min,\n max: child.props.max,\n collapsible: child.props.collapsible,\n collapseThreshold: child.props.collapseThreshold,\n }));\n\n const splitter = useSplitter({\n panels,\n orientation,\n sizes: controlledSizes,\n onSizeChange,\n onResizeStart,\n onResizeEnd,\n onCollapseChange,\n redistribute,\n step,\n shiftStep,\n dir,\n });\n\n useImperativeHandle(splitterRef, () => splitter, [splitter]);\n\n const mergedRef = useMergedRef(ref, splitter.ref);\n\n const getStyles = useStyles<SplitterFactory>({\n name: 'Splitter',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const defaultIcon = orientation === 'vertical' ? <GripHorizontalIcon /> : <GripVerticalIcon />;\n const thumbIcon = handleIcon !== undefined ? handleIcon : defaultIcon;\n\n const items: React.ReactNode[] = [];\n\n paneChildren.forEach((child, index) => {\n if (index > 0) {\n const handleProps = splitter.getHandleProps({ index: index - 1 });\n const isActive = splitter.activeHandle === index - 1;\n items.push(\n <Box {...getStyles('handle')} key={`handle-${index - 1}`} {...handleProps}>\n {withHandle && (\n <div\n {...getStyles('thumb')}\n data-orientation={orientation}\n data-active={isActive || undefined}\n >\n {thumbIcon}\n </div>\n )}\n </Box>\n );\n }\n\n items.push(\n cloneElement(child, {\n key: `pane-${index}`,\n __index: index,\n })\n );\n });\n\n return (\n <SplitterProvider\n value={{\n getStyles,\n sizes: splitter.sizes,\n collapsed: splitter.collapsed,\n orientation: orientation!,\n }}\n >\n <Box ref={mergedRef} {...getStyles('root')} mod={[{ orientation }, mod]} {...others}>\n {items}\n </Box>\n </SplitterProvider>\n );\n});\n\nSplitter.classes = classes;\nSplitter.varsResolver = varsResolver;\nSplitter.displayName = '@mantine/core/Splitter';\nSplitter.Pane = SplitterPane;\n"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Splitter.mjs","names":["classes"],"sources":["../../../src/components/Splitter/Splitter.tsx"],"sourcesContent":["import { Children, cloneElement, useImperativeHandle } from 'react';\nimport {\n useMergedRef,\n useSplitter,\n UseSplitterRedistributeFn,\n UseSplitterReturnValue,\n} from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getThemeColor,\n MantineColor,\n rem,\n StylesApiProps,\n useDirection,\n useProps,\n useStyles,\n} from '../../core';\nimport { GripHorizontalIcon, GripVerticalIcon } from './GripIcon';\nimport { SplitterProvider } from './Splitter.context';\nimport {\n SplitterPane,\n SplitterPaneProps,\n SplitterPaneStylesNames,\n} from './SplitterPane/SplitterPane';\nimport classes from './Splitter.module.css';\n\nexport type SplitterStylesNames = 'root' | 'handle' | 'thumb' | SplitterPaneStylesNames;\n\nexport type SplitterCssVariables = {\n root: '--splitter-line-size' | '--splitter-handle-color';\n};\n\nexport interface SplitterProps\n extends BoxProps, StylesApiProps<SplitterFactory>, ElementProps<'div'> {\n /** Layout direction @default 'horizontal' */\n orientation?: 'horizontal' | 'vertical';\n\n /** Controlled sizes (percentages summing to 100) */\n sizes?: number[];\n\n /** Called during resize with updated sizes */\n onSizeChange?: (sizes: number[]) => void;\n\n /** Called when drag starts */\n onResizeStart?: (handleIndex: number) => void;\n\n /** Called when drag ends */\n onResizeEnd?: (handleIndex: number, sizes: number[]) => void;\n\n /** Called when a panel collapses or expands */\n onCollapseChange?: (panelIndex: number, collapsed: boolean) => void;\n\n /** How to redistribute space when immediate neighbor is at its min/max */\n redistribute?: 'nearest' | 'equal' | UseSplitterRedistributeFn;\n\n /** Keyboard step size in percentage @default 1 */\n step?: number;\n\n /** Shift+arrow step size in percentage @default 10 */\n shiftStep?: number;\n\n /** CSS value for separator line thickness between panes @default 2 */\n lineSize?: number | string;\n\n /** Key of `theme.colors` or any valid CSS color for the separator line */\n handleColor?: MantineColor;\n\n /** Custom icon displayed in the handle thumb, by default uses grip icon based on orientation */\n handleIcon?: React.ReactNode;\n\n /** Determines whether the thumb with grip icon is displayed on the handle @default true */\n withHandle?: boolean;\n\n /** Restore the two panes adjacent to a handle to their default ratio (preserving their combined size) when the handle is double-clicked @default true */\n resetOnDoubleClick?: boolean;\n\n /** Ref to imperative splitter API (sizes, collapse, expand, etc.) */\n splitterRef?: React.RefObject<UseSplitterReturnValue | null>;\n\n /** Splitter panes */\n children?: React.ReactNode;\n}\n\nexport type SplitterFactory = Factory<{\n props: SplitterProps;\n ref: HTMLDivElement;\n stylesNames: SplitterStylesNames;\n vars: SplitterCssVariables;\n staticComponents: {\n Pane: typeof SplitterPane;\n };\n}>;\n\nconst defaultProps = {\n orientation: 'horizontal',\n lineSize: 2,\n withHandle: true,\n resetOnDoubleClick: true,\n} satisfies Partial<SplitterProps>;\n\nconst varsResolver = createVarsResolver<SplitterFactory>((theme, { lineSize, handleColor }) => ({\n root: {\n '--splitter-line-size': rem(lineSize),\n '--splitter-handle-color': handleColor ? getThemeColor(handleColor, theme) : undefined,\n },\n}));\n\nexport const Splitter = factory<SplitterFactory>((_props) => {\n const props = useProps('Splitter', defaultProps, _props);\n const {\n orientation,\n sizes: controlledSizes,\n onSizeChange,\n onResizeStart,\n onResizeEnd,\n onCollapseChange,\n redistribute,\n step,\n shiftStep,\n lineSize,\n handleColor,\n handleIcon,\n withHandle,\n resetOnDoubleClick,\n splitterRef,\n children,\n className,\n classNames,\n style,\n styles,\n unstyled,\n vars,\n mod,\n attributes,\n ref,\n ...others\n } = props;\n\n const { dir } = useDirection();\n\n const paneChildren = Children.toArray(children) as React.ReactElement<SplitterPaneProps>[];\n\n const panels = paneChildren.map((child) => ({\n defaultSize: child.props.defaultSize,\n min: child.props.min,\n max: child.props.max,\n collapsible: child.props.collapsible,\n collapseThreshold: child.props.collapseThreshold,\n }));\n\n const splitter = useSplitter({\n panels,\n orientation,\n sizes: controlledSizes,\n onSizeChange,\n onResizeStart,\n onResizeEnd,\n onCollapseChange,\n redistribute,\n step,\n shiftStep,\n dir,\n resetOnDoubleClick,\n });\n\n useImperativeHandle(splitterRef, () => splitter, [splitter]);\n\n const mergedRef = useMergedRef(ref, splitter.ref);\n\n const getStyles = useStyles<SplitterFactory>({\n name: 'Splitter',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const defaultIcon = orientation === 'vertical' ? <GripHorizontalIcon /> : <GripVerticalIcon />;\n const thumbIcon = handleIcon !== undefined ? handleIcon : defaultIcon;\n\n const items: React.ReactNode[] = [];\n\n paneChildren.forEach((child, index) => {\n if (index > 0) {\n const handleProps = splitter.getHandleProps({ index: index - 1 });\n const isActive = splitter.activeHandle === index - 1;\n items.push(\n <Box {...getStyles('handle')} key={`handle-${index - 1}`} {...handleProps}>\n {withHandle && (\n <div\n {...getStyles('thumb')}\n data-orientation={orientation}\n data-active={isActive || undefined}\n >\n {thumbIcon}\n </div>\n )}\n </Box>\n );\n }\n\n items.push(\n cloneElement(child, {\n key: `pane-${index}`,\n __index: index,\n })\n );\n });\n\n return (\n <SplitterProvider\n value={{\n getStyles,\n sizes: splitter.sizes,\n collapsed: splitter.collapsed,\n orientation: orientation!,\n }}\n >\n <Box ref={mergedRef} {...getStyles('root')} mod={[{ orientation }, mod]} {...others}>\n {items}\n </Box>\n </SplitterProvider>\n );\n});\n\nSplitter.classes = classes;\nSplitter.varsResolver = varsResolver;\nSplitter.displayName = '@mantine/core/Splitter';\nSplitter.Pane = SplitterPane;\n"],"mappings":";;;;;;;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,eAAe,EAAE,OAAO,QAAQ,EAAE,CAAC;GAChE,MAAM,WAAW,SAAS,iBAAiB,QAAQ;GACnD,MAAM,KACJ,8BAAC,KAAD;IAAK,GAAI,UAAU,QAAQ;IAAG,KAAK,UAAU,QAAQ;IAAK,GAAI;GAUzD,GATF,cACC,oBAAC,OAAD;IACE,GAAI,UAAU,OAAO;IACrB,oBAAkB;IAClB,eAAa,YAAY,KAAA;cAExB;GACE,CAAA,CAEJ,CACP;EACF;EAEA,MAAM,KACJ,aAAa,OAAO;GAClB,KAAK,QAAQ;GACb,SAAS;EACX,CAAC,CACH;CACF,CAAC;CAED,OACE,oBAAC,kBAAD;EACE,OAAO;GACL;GACA,OAAO,SAAS;GAChB,WAAW,SAAS;GACP;EACf;YAEA,oBAAC,KAAD;GAAK,KAAK;GAAW,GAAI,UAAU,MAAM;GAAG,KAAK,CAAC,EAAE,YAAY,GAAG,GAAG;GAAG,GAAI;aAC1E;EACE,CAAA;CACW,CAAA;AAEtB,CAAC;AAED,SAAS,UAAUA;AACnB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.module.mjs","names":[],"sources":["../../../src/components/Text/Text.module.css"],"sourcesContent":[".root {\n -webkit-tap-highlight-color: transparent;\n text-decoration: none;\n font-size: var(--text-fz, var(--mantine-font-size-md));\n line-height: var(--text-lh, var(--mantine-line-height-md));\n font-weight: var(--mantine-font-weight-regular);\n text-wrap: var(--text-text-wrap, var(--mantine-text-wrap
|
|
1
|
+
{"version":3,"file":"Text.module.mjs","names":[],"sources":["../../../src/components/Text/Text.module.css"],"sourcesContent":[".root {\n -webkit-tap-highlight-color: transparent;\n text-decoration: none;\n font-size: var(--text-fz, var(--mantine-font-size-md));\n line-height: var(--text-lh, var(--mantine-line-height-md));\n font-weight: var(--mantine-font-weight-regular);\n text-wrap: var(--text-text-wrap, var(--mantine-text-wrap));\n margin: 0;\n padding: 0;\n\n &:where([data-truncate]) {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n &:where([data-truncate='start']) {\n direction: rtl;\n text-align: end;\n\n @mixin where-rtl {\n direction: ltr;\n text-align: start;\n }\n }\n\n &:where([data-variant='gradient']) {\n background-image: var(--text-gradient);\n background-clip: text;\n -webkit-background-clip: text;\n -webkit-text-fill-color: transparent;\n }\n\n &:where([data-line-clamp]) {\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: var(--text-line-clamp);\n -webkit-box-orient: vertical;\n }\n\n &:where([data-inherit]) {\n line-height: inherit;\n font-weight: inherit;\n font-size: inherit;\n }\n\n &:where([data-inline]) {\n line-height: 1;\n }\n}\n"],"mappings":""}
|
|
@@ -92,6 +92,7 @@ function TextareaAutosize({ maxRows, minRows, onChange, ref: userRef, ...props }
|
|
|
92
92
|
const libRef = useRef(null);
|
|
93
93
|
const ref = useMergedRef(libRef, userRef);
|
|
94
94
|
const heightRef = useRef(0);
|
|
95
|
+
const widthRef = useRef(0);
|
|
95
96
|
const resizeTextarea = () => {
|
|
96
97
|
const node = libRef.current;
|
|
97
98
|
if (!node) return;
|
|
@@ -113,6 +114,19 @@ function TextareaAutosize({ maxRows, minRows, onChange, ref: userRef, ...props }
|
|
|
113
114
|
window.addEventListener("resize", handleResize);
|
|
114
115
|
return () => window.removeEventListener("resize", handleResize);
|
|
115
116
|
}, []);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const node = libRef.current;
|
|
119
|
+
if (!node || typeof ResizeObserver === "undefined") return;
|
|
120
|
+
widthRef.current = node.offsetWidth;
|
|
121
|
+
const observer = new ResizeObserver(() => {
|
|
122
|
+
if (libRef.current && libRef.current.offsetWidth !== widthRef.current) {
|
|
123
|
+
widthRef.current = libRef.current.offsetWidth;
|
|
124
|
+
resizeTextarea();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
observer.observe(node);
|
|
128
|
+
return () => observer.disconnect();
|
|
129
|
+
}, []);
|
|
116
130
|
useEffect(() => {
|
|
117
131
|
const handleFontsLoaded = () => resizeTextarea();
|
|
118
132
|
document.fonts.addEventListener("loadingdone", handleFontsLoaded);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autosize.mjs","names":[],"sources":["../../../src/components/Textarea/Autosize.tsx"],"sourcesContent":["import React, { useEffect, useLayoutEffect, useRef } from 'react';\nimport { useMergedRef } from '@mantine/hooks';\n\ntype TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;\n\nexport interface TextareaAutosizeProps extends Omit<TextareaProps, 'style'> {\n ref?: React.Ref<HTMLTextAreaElement>;\n maxRows?: number;\n minRows?: number;\n style?: Omit<NonNullable<TextareaProps['style']>, 'maxHeight' | 'minHeight'> & {\n height?: number;\n };\n}\n\nconst SIZING_STYLE_KEYS = [\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderRightWidth',\n 'borderTopWidth',\n 'boxSizing',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontWeight',\n 'letterSpacing',\n 'lineHeight',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'tabSize',\n 'textIndent',\n 'textRendering',\n 'textTransform',\n 'width',\n 'wordBreak',\n 'wordSpacing',\n 'scrollbarGutter',\n] as const;\n\ntype SizingStyleKey = (typeof SIZING_STYLE_KEYS)[number];\n\ninterface SizingData {\n sizingStyle: Pick<CSSStyleDeclaration, Extract<SizingStyleKey, keyof CSSStyleDeclaration>>;\n paddingSize: number;\n borderSize: number;\n}\n\nconst HIDDEN_TEXTAREA_STYLE: Record<string, string> = {\n 'min-height': '0',\n 'max-height': 'none',\n height: '0',\n visibility: 'hidden',\n overflow: 'hidden',\n position: 'absolute',\n 'z-index': '-1000',\n top: '0',\n right: '0',\n display: 'block',\n};\n\nfunction forceHiddenStyles(node: HTMLElement) {\n Object.keys(HIDDEN_TEXTAREA_STYLE).forEach((key) => {\n node.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');\n });\n}\n\nfunction getSizingData(node: HTMLElement): SizingData | null {\n const style = window.getComputedStyle(node);\n\n if (style === null) {\n return null;\n }\n\n const sizingStyle = {} as SizingData['sizingStyle'];\n for (const key of SIZING_STYLE_KEYS) {\n (sizingStyle as any)[key] = style[key as keyof CSSStyleDeclaration];\n }\n\n if ((sizingStyle as any).boxSizing === '') {\n return null;\n }\n\n const paddingSize = parseFloat(sizingStyle.paddingBottom!) + parseFloat(sizingStyle.paddingTop!);\n\n const borderSize =\n parseFloat(sizingStyle.borderBottomWidth!) + parseFloat(sizingStyle.borderTopWidth!);\n\n return { sizingStyle, paddingSize, borderSize };\n}\n\nlet hiddenTextarea: HTMLTextAreaElement | null = null;\n\nfunction calculateNodeHeight(\n sizingData: SizingData,\n value: string,\n minRows = 1,\n maxRows = Infinity\n): [number, number] {\n if (!hiddenTextarea) {\n hiddenTextarea = document.createElement('textarea');\n hiddenTextarea.setAttribute('tabindex', '-1');\n hiddenTextarea.setAttribute('aria-hidden', 'true');\n hiddenTextarea.setAttribute('aria-label', 'autosize measurement');\n forceHiddenStyles(hiddenTextarea);\n }\n\n if (hiddenTextarea.parentNode === null) {\n document.body.appendChild(hiddenTextarea);\n }\n\n const { paddingSize, borderSize, sizingStyle } = sizingData;\n const { boxSizing } = sizingStyle;\n\n Object.keys(sizingStyle).forEach((key) => {\n (hiddenTextarea!.style as any)[key] = (sizingStyle as any)[key];\n });\n\n forceHiddenStyles(hiddenTextarea);\n\n hiddenTextarea.value = value;\n let height =\n boxSizing === 'border-box'\n ? hiddenTextarea.scrollHeight + borderSize\n : hiddenTextarea.scrollHeight - paddingSize;\n\n // Double set and calc due to Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1795904\n hiddenTextarea.value = value;\n height =\n boxSizing === 'border-box'\n ? hiddenTextarea.scrollHeight + borderSize\n : hiddenTextarea.scrollHeight - paddingSize;\n\n hiddenTextarea.value = 'x';\n const rowHeight = hiddenTextarea.scrollHeight - paddingSize;\n\n let minHeight = rowHeight * minRows;\n if (boxSizing === 'border-box') {\n minHeight = minHeight + paddingSize + borderSize;\n }\n height = Math.max(minHeight, height);\n\n let maxHeight = rowHeight * maxRows;\n if (boxSizing === 'border-box') {\n maxHeight = maxHeight + paddingSize + borderSize;\n }\n height = Math.min(maxHeight, height);\n\n return [height, rowHeight];\n}\n\nexport function TextareaAutosize({\n maxRows,\n minRows,\n onChange,\n ref: userRef,\n ...props\n}: TextareaAutosizeProps) {\n const isControlled = props.value !== undefined;\n const libRef = useRef<HTMLTextAreaElement | null>(null);\n const ref = useMergedRef(libRef, userRef);\n const heightRef = useRef(0);\n\n const resizeTextarea = () => {\n const node = libRef.current;\n\n if (!node) {\n return;\n }\n\n const nodeSizingData = getSizingData(node);\n\n if (!nodeSizingData) {\n return;\n }\n\n const [height] = calculateNodeHeight(\n nodeSizingData,\n node.value || node.placeholder || 'x',\n minRows,\n maxRows\n );\n\n if (heightRef.current !== height) {\n heightRef.current = height;\n node.style.setProperty('height', `${height}px`, 'important');\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) {\n resizeTextarea();\n }\n onChange?.(event);\n };\n\n useLayoutEffect(resizeTextarea);\n\n useEffect(() => {\n const handleResize = () => resizeTextarea();\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n useEffect(() => {\n const handleFontsLoaded = () => resizeTextarea();\n document.fonts.addEventListener('loadingdone', handleFontsLoaded);\n return () => document.fonts.removeEventListener('loadingdone', handleFontsLoaded);\n }, []);\n\n useEffect(() => {\n const handleReset = (event: Event) => {\n if (libRef.current?.form === event.target && !isControlled) {\n const currentValue = libRef.current!.value;\n requestAnimationFrame(() => {\n if (libRef.current && currentValue !== libRef.current.value) {\n resizeTextarea();\n }\n });\n }\n };\n document.body.addEventListener('reset', handleReset);\n return () => document.body.removeEventListener('reset', handleReset);\n }, [isControlled]);\n\n return <textar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ACxC,eAAiB,MAAc,OAAQ,YAAoB;CAC7D,CAAC;CAED,kBAAkB,cAAc;CAEhC,eAAe,QAAQ;CACvB,IAAI,SACF,cAAc,eACV,eAAe,eAAe,aAC9B,eAAe,eAAe;CAGpC,eAAe,QAAQ;CACvB,SACE,cAAc,eACV,eAAe,eAAe,aAC9B,eAAe,eAAe;CAEpC,eAAe,QAAQ;CACvB,MAAM,YAAY,eAAe,eAAe;CAEhD,IAAI,YAAY,YAAY;CAC5B,IAAI,cAAc,cAChB,YAAY,YAAY,cAAc;CAExC,SAAS,KAAK,IAAI,WAAW,MAAM;CAEnC,IAAI,YAAY,YAAY;CAC5B,IAAI,cAAc,cAChB,YAAY,YAAY,cAAc;CAExC,SAAS,KAAK,IAAI,WAAW,MAAM;CAEnC,OAAO,CAAC,QAAQ,SAAS;AAC3B;AAEA,SAAgB,iBAAiB,EAC/B,SACA,SACA,UACA,KAAK,SACL,GAAG,SACqB;CACxB,MAAM,eAAe,MAAM,UAAU,KAAA;CACrC,MAAM,SAAS,OAAmC,IAAI;CACtD,MAAM,MAAM,aAAa,QAAQ,OAAO;CACxC,MAAM,YAAY,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Autosize.mjs","names":[],"sources":["../../../src/components/Textarea/Autosize.tsx"],"sourcesContent":["import React, { useEffect, useLayoutEffect, useRef } from 'react';\nimport { useMergedRef } from '@mantine/hooks';\n\ntype TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;\n\nexport interface TextareaAutosizeProps extends Omit<TextareaProps, 'style'> {\n ref?: React.Ref<HTMLTextAreaElement>;\n maxRows?: number;\n minRows?: number;\n style?: Omit<NonNullable<TextareaProps['style']>, 'maxHeight' | 'minHeight'> & {\n height?: number;\n };\n}\n\nconst SIZING_STYLE_KEYS = [\n 'borderBottomWidth',\n 'borderLeftWidth',\n 'borderRightWidth',\n 'borderTopWidth',\n 'boxSizing',\n 'fontFamily',\n 'fontSize',\n 'fontStyle',\n 'fontWeight',\n 'letterSpacing',\n 'lineHeight',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingRight',\n 'paddingTop',\n 'tabSize',\n 'textIndent',\n 'textRendering',\n 'textTransform',\n 'width',\n 'wordBreak',\n 'wordSpacing',\n 'scrollbarGutter',\n] as const;\n\ntype SizingStyleKey = (typeof SIZING_STYLE_KEYS)[number];\n\ninterface SizingData {\n sizingStyle: Pick<CSSStyleDeclaration, Extract<SizingStyleKey, keyof CSSStyleDeclaration>>;\n paddingSize: number;\n borderSize: number;\n}\n\nconst HIDDEN_TEXTAREA_STYLE: Record<string, string> = {\n 'min-height': '0',\n 'max-height': 'none',\n height: '0',\n visibility: 'hidden',\n overflow: 'hidden',\n position: 'absolute',\n 'z-index': '-1000',\n top: '0',\n right: '0',\n display: 'block',\n};\n\nfunction forceHiddenStyles(node: HTMLElement) {\n Object.keys(HIDDEN_TEXTAREA_STYLE).forEach((key) => {\n node.style.setProperty(key, HIDDEN_TEXTAREA_STYLE[key], 'important');\n });\n}\n\nfunction getSizingData(node: HTMLElement): SizingData | null {\n const style = window.getComputedStyle(node);\n\n if (style === null) {\n return null;\n }\n\n const sizingStyle = {} as SizingData['sizingStyle'];\n for (const key of SIZING_STYLE_KEYS) {\n (sizingStyle as any)[key] = style[key as keyof CSSStyleDeclaration];\n }\n\n if ((sizingStyle as any).boxSizing === '') {\n return null;\n }\n\n const paddingSize = parseFloat(sizingStyle.paddingBottom!) + parseFloat(sizingStyle.paddingTop!);\n\n const borderSize =\n parseFloat(sizingStyle.borderBottomWidth!) + parseFloat(sizingStyle.borderTopWidth!);\n\n return { sizingStyle, paddingSize, borderSize };\n}\n\nlet hiddenTextarea: HTMLTextAreaElement | null = null;\n\nfunction calculateNodeHeight(\n sizingData: SizingData,\n value: string,\n minRows = 1,\n maxRows = Infinity\n): [number, number] {\n if (!hiddenTextarea) {\n hiddenTextarea = document.createElement('textarea');\n hiddenTextarea.setAttribute('tabindex', '-1');\n hiddenTextarea.setAttribute('aria-hidden', 'true');\n hiddenTextarea.setAttribute('aria-label', 'autosize measurement');\n forceHiddenStyles(hiddenTextarea);\n }\n\n if (hiddenTextarea.parentNode === null) {\n document.body.appendChild(hiddenTextarea);\n }\n\n const { paddingSize, borderSize, sizingStyle } = sizingData;\n const { boxSizing } = sizingStyle;\n\n Object.keys(sizingStyle).forEach((key) => {\n (hiddenTextarea!.style as any)[key] = (sizingStyle as any)[key];\n });\n\n forceHiddenStyles(hiddenTextarea);\n\n hiddenTextarea.value = value;\n let height =\n boxSizing === 'border-box'\n ? hiddenTextarea.scrollHeight + borderSize\n : hiddenTextarea.scrollHeight - paddingSize;\n\n // Double set and calc due to Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1795904\n hiddenTextarea.value = value;\n height =\n boxSizing === 'border-box'\n ? hiddenTextarea.scrollHeight + borderSize\n : hiddenTextarea.scrollHeight - paddingSize;\n\n hiddenTextarea.value = 'x';\n const rowHeight = hiddenTextarea.scrollHeight - paddingSize;\n\n let minHeight = rowHeight * minRows;\n if (boxSizing === 'border-box') {\n minHeight = minHeight + paddingSize + borderSize;\n }\n height = Math.max(minHeight, height);\n\n let maxHeight = rowHeight * maxRows;\n if (boxSizing === 'border-box') {\n maxHeight = maxHeight + paddingSize + borderSize;\n }\n height = Math.min(maxHeight, height);\n\n return [height, rowHeight];\n}\n\nexport function TextareaAutosize({\n maxRows,\n minRows,\n onChange,\n ref: userRef,\n ...props\n}: TextareaAutosizeProps) {\n const isControlled = props.value !== undefined;\n const libRef = useRef<HTMLTextAreaElement | null>(null);\n const ref = useMergedRef(libRef, userRef);\n const heightRef = useRef(0);\n const widthRef = useRef(0);\n\n const resizeTextarea = () => {\n const node = libRef.current;\n\n if (!node) {\n return;\n }\n\n const nodeSizingData = getSizingData(node);\n\n if (!nodeSizingData) {\n return;\n }\n\n const [height] = calculateNodeHeight(\n nodeSizingData,\n node.value || node.placeholder || 'x',\n minRows,\n maxRows\n );\n\n if (heightRef.current !== height) {\n heightRef.current = height;\n node.style.setProperty('height', `${height}px`, 'important');\n }\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) {\n resizeTextarea();\n }\n onChange?.(event);\n };\n\n useLayoutEffect(resizeTextarea);\n\n useEffect(() => {\n const handleResize = () => resizeTextarea();\n window.addEventListener('resize', handleResize);\n return () => window.removeEventListener('resize', handleResize);\n }, []);\n\n useEffect(() => {\n const node = libRef.current;\n\n if (!node || typeof ResizeObserver === 'undefined') {\n return undefined;\n }\n\n widthRef.current = node.offsetWidth;\n\n const observer = new ResizeObserver(() => {\n if (libRef.current && libRef.current.offsetWidth !== widthRef.current) {\n widthRef.current = libRef.current.offsetWidth;\n resizeTextarea();\n }\n });\n\n observer.observe(node);\n return () => observer.disconnect();\n }, []);\n\n useEffect(() => {\n const handleFontsLoaded = () => resizeTextarea();\n document.fonts.addEventListener('loadingdone', handleFontsLoaded);\n return () => document.fonts.removeEventListener('loadingdone', handleFontsLoaded);\n }, []);\n\n useEffect(() => {\n const handleReset = (event: Event) => {\n if (libRef.current?.form === event.target && !isControlled) {\n const currentValue = libRef.current!.value;\n requestAnimationFrame(() => {\n if (libRef.current && currentValue !== libRef.current.value) {\n resizeTextarea();\n }\n });\n }\n };\n document.body.addEventListener('reset', handleReset);\n return () => document.body.removeEventListener('reset', handleReset);\n }, [isControlled]);\n\n return <textarea {...props} onChange={handleChange} ref={ref} />;\n}\n"],"mappings":";;;;;AAcA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAUA,MAAM,wBAAgD;CACpD,cAAc;CACd,cAAc;CACd,QAAQ;CACR,YAAY;CACZ,UAAU;CACV,UAAU;CACV,WAAW;CACX,KAAK;CACL,OAAO;CACP,SAAS;AACX;AAEA,SAAS,kBAAkB,MAAmB;CAC5C,OAAO,KAAK,qBAAqB,EAAE,SAAS,QAAQ;EACl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AC,CAAC;CAEL,gBAAgB;EACd,MAAM,0BAA0B,eAAe;EAC/C,SAAS,MAAM,iBAAiB,eAAe,iBAAiB;EAChE,aAAa,SAAS,MAAM,oBAAoB,eAAe,iBAAiB;CAClF,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,MAAM,eAAe,UAAiB;GACpC,IAAI,OAAO,SAAS,SAAS,MAAM,UAAU,CAAC,cAAc;IAC1D,MAAM,eAAe,OAAO,QAAS;IACrC,4BAA4B;KAC1B,IAAI,OAAO,WAAW,iBAAiB,OAAO,QAAQ,OACpD,eAAe;IAEnB,CAAC;GACH;EACF;EACA,SAAS,KAAK,iBAAiB,SAAS,WAAW;EACnD,aAAa,SAAS,KAAK,oBAAoB,SAAS,WAAW;CACrE,GAAG,CAAC,YAAY,CAAC;CAEjB,OAAO,oBAAC,YAAD;EAAU,GAAI;EAAO,UAAU;EAAmB;CAAM,CAAA;AACjE"}
|
|
@@ -5,7 +5,7 @@ import { useTransition } from "./use-transition.mjs";
|
|
|
5
5
|
import { Activity } from "react";
|
|
6
6
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
7
7
|
//#region packages/@mantine/core/src/components/Transition/Transition.tsx
|
|
8
|
-
function Transition({ keepMounted, transition = "fade", duration = 250, exitDuration = duration, mounted, children, timingFunction = "ease", onExit, onEntered, onEnter, onExited, enterDelay, exitDelay }) {
|
|
8
|
+
function Transition({ keepMounted, keepMountedMode = "activity", transition = "fade", duration = 250, exitDuration = duration, mounted, children, timingFunction = "ease", onExit, onEntered, onEnter, onExited, enterDelay, exitDelay }) {
|
|
9
9
|
const env = useMantineEnv();
|
|
10
10
|
const { transitionDuration, transitionStatus, transitionTimingFunction } = useTransition({
|
|
11
11
|
mounted,
|
|
@@ -21,22 +21,29 @@ function Transition({ keepMounted, transition = "fade", duration = 250, exitDura
|
|
|
21
21
|
});
|
|
22
22
|
if (env === "test") return mounted ? /* @__PURE__ */ jsx(Fragment$1, { children: children({}) }) : keepMounted ? children({ display: "none" }) : null;
|
|
23
23
|
if (transitionDuration === 0) {
|
|
24
|
-
if (keepMounted)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (keepMounted) {
|
|
25
|
+
if (keepMountedMode === "display-none") return mounted ? /* @__PURE__ */ jsx(Fragment$1, { children: children({}) }) : children({ display: "none" });
|
|
26
|
+
return /* @__PURE__ */ jsx(Activity, {
|
|
27
|
+
mode: mounted ? "visible" : "hidden",
|
|
28
|
+
children: children({})
|
|
29
|
+
});
|
|
30
|
+
}
|
|
28
31
|
return mounted ? /* @__PURE__ */ jsx(Fragment$1, { children: children({}) }) : null;
|
|
29
32
|
}
|
|
30
33
|
const isExited = transitionStatus === "exited";
|
|
31
|
-
if (keepMounted)
|
|
32
|
-
|
|
33
|
-
children: children(isExited ? {} : getTransitionStyles({
|
|
34
|
+
if (keepMounted) {
|
|
35
|
+
const keepMountedChildren = children(isExited ? keepMountedMode === "display-none" ? { display: "none" } : {} : getTransitionStyles({
|
|
34
36
|
transition,
|
|
35
37
|
duration: transitionDuration,
|
|
36
38
|
state: transitionStatus,
|
|
37
39
|
timingFunction: transitionTimingFunction
|
|
38
|
-
}))
|
|
39
|
-
|
|
40
|
+
}));
|
|
41
|
+
if (keepMountedMode === "display-none") return keepMountedChildren;
|
|
42
|
+
return /* @__PURE__ */ jsx(Activity, {
|
|
43
|
+
mode: isExited ? "hidden" : "visible",
|
|
44
|
+
children: keepMountedChildren
|
|
45
|
+
});
|
|
46
|
+
}
|
|
40
47
|
return isExited ? null : /* @__PURE__ */ jsx(Fragment$1, { children: children(getTransitionStyles({
|
|
41
48
|
transition,
|
|
42
49
|
duration: transitionDuration,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transition.mjs","names":[],"sources":["../../../src/components/Transition/Transition.tsx"],"sourcesContent":["import { Activity } from 'react';\nimport { useMantineEnv } from '../../core';\nimport { getTransitionStyles } from './get-transition-styles/get-transition-styles';\nimport { MantineTransition } from './transitions';\nimport { useTransition } from './use-transition';\n\nexport interface TransitionProps {\n /** If set, the element is kept in the DOM when hidden. React 19 `Activity` is used to preserve state while the element is not visible. */\n keepMounted?: boolean;\n\n /** Transition name or object */\n transition?: MantineTransition;\n\n /** Transition duration in ms @default 250 */\n duration?: number;\n\n /** Exit transition duration in ms @default 250 */\n exitDuration?: number;\n\n /** Transition timing function @default theme.transitionTimingFunction */\n timingFunction?: string;\n\n /** Determines whether component should be mounted to the DOM */\n mounted: boolean;\n\n /** Render function with transition styles argument */\n children: (styles: React.CSSProperties) => React.JSX.Element;\n\n /** Called when exit transition ends */\n onExited?: () => void;\n\n /** Called when exit transition starts */\n onExit?: () => void;\n\n /** Called when enter transition starts */\n onEnter?: () => void;\n\n /** Called when enter transition ends */\n onEntered?: () => void;\n\n /** Delay in ms before enter transition starts */\n enterDelay?: number;\n\n /** Delay in ms before exit transition starts */\n exitDelay?: number;\n}\n\nexport type TransitionOverride = Partial<Omit<TransitionProps, 'mounted'>>;\n\nexport function Transition({\n keepMounted,\n transition = 'fade',\n duration = 250,\n exitDuration = duration,\n mounted,\n children,\n timingFunction = 'ease',\n onExit,\n onEntered,\n onEnter,\n onExited,\n enterDelay,\n exitDelay,\n}: TransitionProps) {\n const env = useMantineEnv();\n const { transitionDuration, transitionStatus, transitionTimingFunction } = useTransition({\n mounted,\n exitDuration,\n duration,\n timingFunction,\n onExit,\n onEntered,\n onEnter,\n onExited,\n enterDelay,\n exitDelay,\n });\n\n if (env === 'test') {\n return mounted ? <>{children({})}</> : keepMounted ? children({ display: 'none' }) : null;\n }\n\n if (transitionDuration === 0) {\n if (keepMounted) {\n return <Activity mode={mounted ? 'visible' : 'hidden'}>{children({})}</Activity>;\n }\n return mounted ? <>{children({})}</> : null;\n }\n\n const isExited = transitionStatus === 'exited';\n\n if (keepMounted) {\n
|
|
1
|
+
{"version":3,"file":"Transition.mjs","names":[],"sources":["../../../src/components/Transition/Transition.tsx"],"sourcesContent":["import { Activity } from 'react';\nimport { useMantineEnv } from '../../core';\nimport { getTransitionStyles } from './get-transition-styles/get-transition-styles';\nimport { MantineTransition } from './transitions';\nimport { useTransition } from './use-transition';\n\nexport interface TransitionProps {\n /** If set, the element is kept in the DOM when hidden. React 19 `Activity` is used to preserve state while the element is not visible. */\n keepMounted?: boolean;\n\n /**\n * Controls how the element is hidden when `keepMounted` is set:\n * `'activity'` – hidden with React 19 `Activity` component,\n * `'display-none'` – hidden with `display: none` styles\n * @default 'activity'\n */\n keepMountedMode?: 'activity' | 'display-none';\n\n /** Transition name or object */\n transition?: MantineTransition;\n\n /** Transition duration in ms @default 250 */\n duration?: number;\n\n /** Exit transition duration in ms @default 250 */\n exitDuration?: number;\n\n /** Transition timing function @default theme.transitionTimingFunction */\n timingFunction?: string;\n\n /** Determines whether component should be mounted to the DOM */\n mounted: boolean;\n\n /** Render function with transition styles argument */\n children: (styles: React.CSSProperties) => React.JSX.Element;\n\n /** Called when exit transition ends */\n onExited?: () => void;\n\n /** Called when exit transition starts */\n onExit?: () => void;\n\n /** Called when enter transition starts */\n onEnter?: () => void;\n\n /** Called when enter transition ends */\n onEntered?: () => void;\n\n /** Delay in ms before enter transition starts */\n enterDelay?: number;\n\n /** Delay in ms before exit transition starts */\n exitDelay?: number;\n}\n\nexport type TransitionOverride = Partial<Omit<TransitionProps, 'mounted'>>;\n\nexport function Transition({\n keepMounted,\n keepMountedMode = 'activity',\n transition = 'fade',\n duration = 250,\n exitDuration = duration,\n mounted,\n children,\n timingFunction = 'ease',\n onExit,\n onEntered,\n onEnter,\n onExited,\n enterDelay,\n exitDelay,\n}: TransitionProps) {\n const env = useMantineEnv();\n const { transitionDuration, transitionStatus, transitionTimingFunction } = useTransition({\n mounted,\n exitDuration,\n duration,\n timingFunction,\n onExit,\n onEntered,\n onEnter,\n onExited,\n enterDelay,\n exitDelay,\n });\n\n if (env === 'test') {\n return mounted ? <>{children({})}</> : keepMounted ? children({ display: 'none' }) : null;\n }\n\n if (transitionDuration === 0) {\n if (keepMounted) {\n if (keepMountedMode === 'display-none') {\n return mounted ? <>{children({})}</> : children({ display: 'none' });\n }\n\n return <Activity mode={mounted ? 'visible' : 'hidden'}>{children({})}</Activity>;\n }\n return mounted ? <>{children({})}</> : null;\n }\n\n const isExited = transitionStatus === 'exited';\n\n if (keepMounted) {\n const keepMountedChildren = children(\n isExited\n ? keepMountedMode === 'display-none'\n ? { display: 'none' }\n : {}\n : getTransitionStyles({\n transition,\n duration: transitionDuration,\n state: transitionStatus,\n timingFunction: transitionTimingFunction,\n })\n );\n\n if (keepMountedMode === 'display-none') {\n return keepMountedChildren;\n }\n\n return <Activity mode={isExited ? 'hidden' : 'visible'}>{keepMountedChildren}</Activity>;\n }\n\n return isExited ? null : (\n <>\n {children(\n getTransitionStyles({\n transition,\n duration: transitionDuration,\n state: transitionStatus,\n timingFunction: transitionTimingFunction,\n })\n )}\n </>\n );\n}\n\nTransition.displayName = '@mantine/core/Transition';\n\nexport namespace Transition {\n export type Props = TransitionProps;\n export type Override = TransitionOverride;\n}\n"],"mappings":";;;;;;;AAyDA,SAAgB,WAAW,EACzB,aACA,kBAAkB,YAClB,aAAa,QACb,WAAW,KACX,eAAe,UACf,SACA,UACA,iBAAiB,QACjB,QACA,WACA,SACA,UACA,YACA,aACkB;CAClB,MAAM,MAAM,cAAc;CAC1B,MAAM,EAAE,oBAAoB,kBAAkB,6BAA6B,cAAc;EACvF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,IAAI,QAAQ,QACV,OAAO,UAAU,oBAAA,YAAA,EAAA,UAAG,SAAS,CAAC,CAAC,EAAI,CAAA,IAAI,cAAc,SAAS,EAAE,SAAS,OAAO,CAAC,IAAI;CAGvF,IAAI,uBAAuB,GAAG;EAC5B,IAAI,aAAa;GACf,IAAI,oBAAoB,gBACtB,OAAO,UAAU,oBAAA,YAAA,EAAA,UAAG,SAAS,CAAC,CAAC,EAAI,CAAA,IAAI,SAAS,EAAE,SAAS,OAAO,CAAC;G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