@mantine/core 9.5.1-alpha.1 → 9.5.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/Cascader/Cascader.cjs +9 -3
- package/cjs/components/Cascader/Cascader.cjs.map +1 -1
- package/cjs/components/Cascader/CascaderColumns.cjs +34 -3
- package/cjs/components/Cascader/CascaderColumns.cjs.map +1 -1
- package/cjs/components/Cascader/use-cascader-safe-area.cjs +76 -0
- package/cjs/components/Cascader/use-cascader-safe-area.cjs.map +1 -0
- package/cjs/components/Checkbox/CheckboxCard/CheckboxCard.cjs +8 -4
- package/cjs/components/Checkbox/CheckboxCard/CheckboxCard.cjs.map +1 -1
- package/cjs/components/Checkbox/CheckboxIndicator/CheckboxIndicator.cjs +3 -2
- package/cjs/components/Checkbox/CheckboxIndicator/CheckboxIndicator.cjs.map +1 -1
- package/cjs/components/ColorInput/ColorInput.cjs +4 -2
- package/cjs/components/ColorInput/ColorInput.cjs.map +1 -1
- package/cjs/components/ColorPicker/ColorPicker.cjs.map +1 -1
- package/cjs/components/Combobox/get-options-lockup/get-option-by-label.cjs +17 -0
- package/cjs/components/Combobox/get-options-lockup/get-option-by-label.cjs.map +1 -0
- package/cjs/components/Combobox/is-external-input-change/is-external-input-change.cjs +17 -0
- package/cjs/components/Combobox/is-external-input-change/is-external-input-change.cjs.map +1 -0
- package/cjs/components/ComboboxPopover/ComboboxPopover.cjs.map +1 -1
- package/cjs/components/FloatingIndicator/use-floating-indicator.cjs +6 -4
- package/cjs/components/FloatingIndicator/use-floating-indicator.cjs.map +1 -1
- package/cjs/components/MultiSelect/MultiSelect.cjs +9 -0
- package/cjs/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/cjs/components/Notification/Notification.cjs.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs +4 -3
- package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/cjs/components/RollingNumber/RollingNumber.cjs +7 -3
- package/cjs/components/RollingNumber/RollingNumber.cjs.map +1 -1
- package/cjs/components/RollingNumber/RollingNumber.module.cjs +1 -0
- package/cjs/components/RollingNumber/RollingNumber.module.cjs.map +1 -1
- package/cjs/components/Select/Select.cjs +12 -0
- package/cjs/components/Select/Select.cjs.map +1 -1
- package/cjs/components/TagsInput/TagsInput.cjs +5 -1
- package/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
- package/cjs/components/Tooltip/Tooltip.cjs +11 -3
- package/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/cjs/components/Tooltip/Tooltip.module.cjs.map +1 -1
- package/cjs/components/Tooltip/TooltipFloating/TooltipFloating.cjs +2 -2
- package/cjs/components/Tooltip/TooltipFloating/TooltipFloating.cjs.map +1 -1
- package/cjs/components/Tooltip/TooltipFloating/use-floating-tooltip.cjs +1 -0
- package/cjs/components/Tooltip/TooltipFloating/use-floating-tooltip.cjs.map +1 -1
- package/cjs/components/Tooltip/use-tooltip.cjs +2 -1
- package/cjs/components/Tooltip/use-tooltip.cjs.map +1 -1
- package/cjs/components/TreeSelect/TreeSelect.cjs +3 -0
- package/cjs/components/TreeSelect/TreeSelect.cjs.map +1 -1
- package/esm/components/Cascader/Cascader.mjs +9 -3
- package/esm/components/Cascader/Cascader.mjs.map +1 -1
- package/esm/components/Cascader/CascaderColumns.mjs +35 -4
- package/esm/components/Cascader/CascaderColumns.mjs.map +1 -1
- package/esm/components/Cascader/use-cascader-safe-area.mjs +76 -0
- package/esm/components/Cascader/use-cascader-safe-area.mjs.map +1 -0
- package/esm/components/Checkbox/CheckboxCard/CheckboxCard.mjs +8 -4
- package/esm/components/Checkbox/CheckboxCard/CheckboxCard.mjs.map +1 -1
- package/esm/components/Checkbox/CheckboxIndicator/CheckboxIndicator.mjs +3 -2
- package/esm/components/Checkbox/CheckboxIndicator/CheckboxIndicator.mjs.map +1 -1
- package/esm/components/ColorInput/ColorInput.mjs +4 -2
- package/esm/components/ColorInput/ColorInput.mjs.map +1 -1
- package/esm/components/ColorPicker/ColorPicker.mjs.map +1 -1
- package/esm/components/Combobox/get-options-lockup/get-option-by-label.mjs +17 -0
- package/esm/components/Combobox/get-options-lockup/get-option-by-label.mjs.map +1 -0
- package/esm/components/Combobox/is-external-input-change/is-external-input-change.mjs +17 -0
- package/esm/components/Combobox/is-external-input-change/is-external-input-change.mjs.map +1 -0
- package/esm/components/ComboboxPopover/ComboboxPopover.mjs.map +1 -1
- package/esm/components/FloatingIndicator/use-floating-indicator.mjs +6 -4
- package/esm/components/FloatingIndicator/use-floating-indicator.mjs.map +1 -1
- package/esm/components/MultiSelect/MultiSelect.mjs +9 -0
- package/esm/components/MultiSelect/MultiSelect.mjs.map +1 -1
- package/esm/components/Notification/Notification.mjs.map +1 -1
- package/esm/components/PasswordInput/PasswordInput.mjs +4 -3
- package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
- package/esm/components/RollingNumber/RollingNumber.mjs +8 -4
- package/esm/components/RollingNumber/RollingNumber.mjs.map +1 -1
- package/esm/components/RollingNumber/RollingNumber.module.mjs +1 -0
- package/esm/components/RollingNumber/RollingNumber.module.mjs.map +1 -1
- package/esm/components/Select/Select.mjs +12 -0
- package/esm/components/Select/Select.mjs.map +1 -1
- package/esm/components/TagsInput/TagsInput.mjs +5 -1
- package/esm/components/TagsInput/TagsInput.mjs.map +1 -1
- package/esm/components/Tooltip/Tooltip.mjs +11 -3
- package/esm/components/Tooltip/Tooltip.mjs.map +1 -1
- package/esm/components/Tooltip/Tooltip.module.mjs.map +1 -1
- package/esm/components/Tooltip/TooltipFloating/TooltipFloating.mjs +2 -2
- package/esm/components/Tooltip/TooltipFloating/TooltipFloating.mjs.map +1 -1
- package/esm/components/Tooltip/TooltipFloating/use-floating-tooltip.mjs +1 -0
- package/esm/components/Tooltip/TooltipFloating/use-floating-tooltip.mjs.map +1 -1
- package/esm/components/Tooltip/use-tooltip.mjs +3 -2
- package/esm/components/Tooltip/use-tooltip.mjs.map +1 -1
- package/esm/components/TreeSelect/TreeSelect.mjs +3 -0
- package/esm/components/TreeSelect/TreeSelect.mjs.map +1 -1
- package/lib/components/Cascader/Cascader.d.ts +4 -0
- package/lib/components/Cascader/CascaderColumns.d.ts +3 -2
- package/lib/components/Cascader/use-cascader-safe-area.d.ts +20 -0
- package/lib/components/Checkbox/CheckboxCard/CheckboxCard.d.ts +3 -0
- package/lib/components/ColorPicker/ColorPicker.d.ts +2 -2
- package/lib/components/Combobox/get-options-lockup/get-option-by-label.d.ts +8 -0
- package/lib/components/Combobox/is-external-input-change/is-external-input-change.d.ts +7 -0
- package/lib/components/ComboboxPopover/ComboboxPopover.d.ts +1 -1
- package/lib/components/Notification/Notification.d.ts +2 -1
- package/lib/components/PasswordInput/PasswordInput.d.ts +2 -0
- package/lib/components/RollingNumber/RollingNumber.d.ts +1 -1
- package/lib/components/Tooltip/Tooltip.d.ts +2 -0
- package/lib/components/Tooltip/use-tooltip.d.ts +1 -0
- package/package.json +2 -2
- package/styles/RollingNumber.css +21 -0
- package/styles/RollingNumber.layer.css +21 -0
- package/styles/Tooltip.css +4 -0
- package/styles/Tooltip.layer.css +4 -0
- package/styles.css +25 -0
- package/styles.layer.css +25 -0
|
@@ -16,6 +16,7 @@ function useFloatingTooltip({ offset, position, defaultOpened }) {
|
|
|
16
16
|
const horizontalOffset = placement.includes("right") ? offset : position.includes("left") ? offset * -1 : 0;
|
|
17
17
|
const verticalOffset = placement.includes("bottom") ? offset : position.includes("top") ? offset * -1 : 0;
|
|
18
18
|
const handleMouseMove = (0, react.useCallback)(({ clientX, clientY }) => {
|
|
19
|
+
if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) return;
|
|
19
20
|
refs.setPositionReference({ getBoundingClientRect() {
|
|
20
21
|
return {
|
|
21
22
|
width: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-floating-tooltip.cjs","names":[],"sources":["../../../../src/components/Tooltip/TooltipFloating/use-floating-tooltip.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { getOverflowAncestors, shift, useFloating } from '@floating-ui/react';\nimport { FloatingPosition } from '../../../utils/Floating';\n\ninterface UseFloatingTooltip {\n offset: number;\n position: FloatingPosition;\n defaultOpened?: boolean;\n}\n\nexport function useFloatingTooltip<T extends HTMLElement = any>({\n offset,\n position,\n defaultOpened,\n}: UseFloatingTooltip) {\n const [opened, setOpened] = useState(defaultOpened);\n const boundaryRef = useRef<T>(null);\n const { x, y, elements, refs, update, placement } = useFloating({\n placement: position,\n middleware: [\n shift({\n crossAxis: true,\n padding: 5,\n rootBoundary: 'document',\n }),\n ],\n });\n\n const horizontalOffset = placement.includes('right')\n ? offset\n : position.includes('left')\n ? offset * -1\n : 0;\n\n const verticalOffset = placement.includes('bottom')\n ? offset\n : position.includes('top')\n ? offset * -1\n : 0;\n\n const handleMouseMove = useCallback(\n ({ clientX, clientY }: MouseEvent | React.MouseEvent<T, MouseEvent>) => {\n refs.setPositionReference({\n getBoundingClientRect() {\n return {\n width: 0,\n height: 0,\n x: clientX,\n y: clientY,\n left: clientX + horizontalOffset,\n top: clientY + verticalOffset,\n right: clientX,\n bottom: clientY,\n };\n },\n });\n },\n [elements.reference]\n );\n\n useEffect(() => {\n if (refs.floating.current) {\n const boundary = boundaryRef.current!;\n boundary.addEventListener('mousemove', handleMouseMove);\n\n const parents = getOverflowAncestors(refs.floating.current);\n parents.forEach((parent) => {\n parent.addEventListener('scroll', update);\n });\n\n return () => {\n boundary.removeEventListener('mousemove', handleMouseMove);\n parents.forEach((parent) => {\n parent.removeEventListener('scroll', update);\n });\n };\n }\n\n return undefined;\n }, [elements.reference, refs.floating.current, update, handleMouseMove, opened]);\n\n return { handleMouseMove, x, y, opened, setOpened, boundaryRef, floating: refs.setFloating };\n}\n"],"mappings":";;;;AAUA,SAAgB,mBAAgD,EAC9D,QACA,UACA,iBACqB;CACrB,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,SAAA,CAAsB,aAAa;CAClD,MAAM,eAAA,GAA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use-floating-tooltip.cjs","names":[],"sources":["../../../../src/components/Tooltip/TooltipFloating/use-floating-tooltip.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { getOverflowAncestors, shift, useFloating } from '@floating-ui/react';\nimport { FloatingPosition } from '../../../utils/Floating';\n\ninterface UseFloatingTooltip {\n offset: number;\n position: FloatingPosition;\n defaultOpened?: boolean;\n}\n\nexport function useFloatingTooltip<T extends HTMLElement = any>({\n offset,\n position,\n defaultOpened,\n}: UseFloatingTooltip) {\n const [opened, setOpened] = useState(defaultOpened);\n const boundaryRef = useRef<T>(null);\n const { x, y, elements, refs, update, placement } = useFloating({\n placement: position,\n middleware: [\n shift({\n crossAxis: true,\n padding: 5,\n rootBoundary: 'document',\n }),\n ],\n });\n\n const horizontalOffset = placement.includes('right')\n ? offset\n : position.includes('left')\n ? offset * -1\n : 0;\n\n const verticalOffset = placement.includes('bottom')\n ? offset\n : position.includes('top')\n ? offset * -1\n : 0;\n\n const handleMouseMove = useCallback(\n ({ clientX, clientY }: MouseEvent | React.MouseEvent<T, MouseEvent>) => {\n if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {\n return;\n }\n\n refs.setPositionReference({\n getBoundingClientRect() {\n return {\n width: 0,\n height: 0,\n x: clientX,\n y: clientY,\n left: clientX + horizontalOffset,\n top: clientY + verticalOffset,\n right: clientX,\n bottom: clientY,\n };\n },\n });\n },\n [elements.reference]\n );\n\n useEffect(() => {\n if (refs.floating.current) {\n const boundary = boundaryRef.current!;\n boundary.addEventListener('mousemove', handleMouseMove);\n\n const parents = getOverflowAncestors(refs.floating.current);\n parents.forEach((parent) => {\n parent.addEventListener('scroll', update);\n });\n\n return () => {\n boundary.removeEventListener('mousemove', handleMouseMove);\n parents.forEach((parent) => {\n parent.removeEventListener('scroll', update);\n });\n };\n }\n\n return undefined;\n }, [elements.reference, refs.floating.current, update, handleMouseMove, opened]);\n\n return { handleMouseMove, x, y, opened, setOpened, boundaryRef, floating: refs.setFloating };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B,UAAU,MAAM;IAC7C,CAAC;GACH;EACF;CAGF,GAAG;EAAC,SAAS;EAAW,KAAK,SAAS;EAAS;EAAQ;EAAiB;CAAM,CAAC;CAE/E,OAAO;EAAE;EAAiB;EAAG;EAAG;EAAQ;EAAW;EAAa,UAAU,KAAK;CAAY;AAC7F"}
|
|
@@ -55,7 +55,8 @@ function useTooltip(settings) {
|
|
|
55
55
|
open: settings.openDelay,
|
|
56
56
|
close: settings.closeDelay
|
|
57
57
|
},
|
|
58
|
-
mouseOnly: !settings.events?.touch
|
|
58
|
+
mouseOnly: !settings.events?.touch,
|
|
59
|
+
handleClose: settings.interactive ? (0, _floating_ui_react.safePolygon)() : null
|
|
59
60
|
}),
|
|
60
61
|
(0, _floating_ui_react.useFocus)(context, {
|
|
61
62
|
enabled: settings.events?.focus,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tooltip.cjs","names":["TooltipGroupContext","autoUpdate"],"sources":["../../../src/components/Tooltip/use-tooltip.ts"],"sourcesContent":["import { use, useCallback, useRef, useState } from 'react';\nimport {\n arrow,\n autoUpdate,\n flip,\n inline,\n offset,\n shift,\n useDelayGroup,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useRole,\n type Middleware,\n} from '@floating-ui/react';\nimport { useId, useIsomorphicEffect } from '@mantine/hooks';\nimport { FloatingAxesOffsets, FloatingPosition, FloatingStrategy } from '../../utils/Floating';\nimport { type TooltipMiddlewares } from './Tooltip.types';\nimport { TooltipGroupContext } from './TooltipGroup/TooltipGroup';\n\ninterface UseTooltip {\n position: FloatingPosition;\n closeDelay?: number;\n openDelay?: number;\n onPositionChange?: (position: FloatingPosition) => void;\n opened?: boolean;\n defaultOpened?: boolean;\n offset: number | FloatingAxesOffsets;\n arrowRef?: React.RefObject<HTMLDivElement | null>;\n arrowOffset?: number;\n events?: { hover: boolean; focus: boolean; touch: boolean };\n inline?: boolean;\n strategy?: FloatingStrategy;\n middlewares?: TooltipMiddlewares;\n}\n\nfunction getDefaultMiddlewares(middlewares: TooltipMiddlewares | undefined): TooltipMiddlewares {\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 getTooltipMiddlewares(settings: UseTooltip) {\n const middlewaresOptions = getDefaultMiddlewares(settings.middlewares);\n const middlewares: Middleware[] = [offset(settings.offset)];\n\n if (middlewaresOptions.shift) {\n middlewares.push(\n shift(\n typeof middlewaresOptions.shift === 'boolean'\n ? { padding: 8 }\n : { padding: 8, ...middlewaresOptions.shift }\n )\n );\n }\n\n if (middlewaresOptions.flip) {\n middlewares.push(\n typeof middlewaresOptions.flip === 'boolean' ? flip() : flip(middlewaresOptions.flip)\n );\n }\n\n middlewares.push(arrow({ element: settings.arrowRef!, padding: settings.arrowOffset }));\n\n if (middlewaresOptions.inline) {\n middlewares.push(\n typeof middlewaresOptions.inline === 'boolean' ? inline() : inline(middlewaresOptions.inline)\n );\n } else if (settings.inline) {\n middlewares.push(inline());\n }\n\n return middlewares;\n}\n\nexport function useTooltip(settings: UseTooltip) {\n const [uncontrolledOpened, setUncontrolledOpened] = useState(settings.defaultOpened);\n const controlled = typeof settings.opened === 'boolean';\n const opened = controlled ? settings.opened : uncontrolledOpened;\n const withinGroup = use(TooltipGroupContext).withinGroup;\n const uid = useId();\n\n const onChange = useCallback(\n (_opened: boolean) => {\n setUncontrolledOpened(_opened);\n\n if (_opened) {\n setCurrentId(uid);\n }\n },\n [uid]\n );\n\n const {\n x,\n y,\n context,\n refs,\n placement,\n middlewareData: { arrow: { x: arrowX, y: arrowY } = {} },\n } = useFloating({\n strategy: settings.strategy,\n placement: settings.position,\n open: opened,\n onOpenChange: onChange,\n middleware: getTooltipMiddlewares(settings),\n whileElementsMounted: autoUpdate,\n });\n\n const { delay: groupDelay, currentId, setCurrentId } = useDelayGroup(context, { id: uid });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useHover(context, {\n enabled: settings.events?.hover,\n delay: withinGroup ? groupDelay : { open: settings.openDelay, close: settings.closeDelay },\n mouseOnly: !settings.events?.touch,\n }),\n useFocus(context, { enabled: settings.events?.focus, visibleOnly: true }),\n useRole(context, { role: 'tooltip' }),\n // Cannot be used with controlled tooltip, page jumps\n useDismiss(context, { enabled: typeof settings.opened === 'undefined' }),\n ]);\n\n const previousPlacementRef = useRef(placement);\n useIsomorphicEffect(() => {\n if (previousPlacementRef.current !== placement) {\n previousPlacementRef.current = placement;\n settings.onPositionChange?.(placement);\n }\n }, [placement]);\n\n const isGroupPhase = opened && currentId && currentId !== uid;\n\n return {\n x,\n y,\n arrowX,\n arrowY,\n reference: refs.setReference,\n floating: refs.setFloating,\n getFloatingProps,\n getReferenceProps,\n isGroupPhase,\n opened,\n placement,\n };\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"use-tooltip.cjs","names":["TooltipGroupContext","autoUpdate"],"sources":["../../../src/components/Tooltip/use-tooltip.ts"],"sourcesContent":["import { use, useCallback, useRef, useState } from 'react';\nimport {\n arrow,\n autoUpdate,\n flip,\n inline,\n offset,\n safePolygon,\n shift,\n useDelayGroup,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useRole,\n type Middleware,\n} from '@floating-ui/react';\nimport { useId, useIsomorphicEffect } from '@mantine/hooks';\nimport { FloatingAxesOffsets, FloatingPosition, FloatingStrategy } from '../../utils/Floating';\nimport { type TooltipMiddlewares } from './Tooltip.types';\nimport { TooltipGroupContext } from './TooltipGroup/TooltipGroup';\n\ninterface UseTooltip {\n position: FloatingPosition;\n closeDelay?: number;\n openDelay?: number;\n onPositionChange?: (position: FloatingPosition) => void;\n opened?: boolean;\n defaultOpened?: boolean;\n offset: number | FloatingAxesOffsets;\n arrowRef?: React.RefObject<HTMLDivElement | null>;\n arrowOffset?: number;\n events?: { hover: boolean; focus: boolean; touch: boolean };\n interactive?: boolean;\n inline?: boolean;\n strategy?: FloatingStrategy;\n middlewares?: TooltipMiddlewares;\n}\n\nfunction getDefaultMiddlewares(middlewares: TooltipMiddlewares | undefined): TooltipMiddlewares {\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 getTooltipMiddlewares(settings: UseTooltip) {\n const middlewaresOptions = getDefaultMiddlewares(settings.middlewares);\n const middlewares: Middleware[] = [offset(settings.offset)];\n\n if (middlewaresOptions.shift) {\n middlewares.push(\n shift(\n typeof middlewaresOptions.shift === 'boolean'\n ? { padding: 8 }\n : { padding: 8, ...middlewaresOptions.shift }\n )\n );\n }\n\n if (middlewaresOptions.flip) {\n middlewares.push(\n typeof middlewaresOptions.flip === 'boolean' ? flip() : flip(middlewaresOptions.flip)\n );\n }\n\n middlewares.push(arrow({ element: settings.arrowRef!, padding: settings.arrowOffset }));\n\n if (middlewaresOptions.inline) {\n middlewares.push(\n typeof middlewaresOptions.inline === 'boolean' ? inline() : inline(middlewaresOptions.inline)\n );\n } else if (settings.inline) {\n middlewares.push(inline());\n }\n\n return middlewares;\n}\n\nexport function useTooltip(settings: UseTooltip) {\n const [uncontrolledOpened, setUncontrolledOpened] = useState(settings.defaultOpened);\n const controlled = typeof settings.opened === 'boolean';\n const opened = controlled ? settings.opened : uncontrolledOpened;\n const withinGroup = use(TooltipGroupContext).withinGroup;\n const uid = useId();\n\n const onChange = useCallback(\n (_opened: boolean) => {\n setUncontrolledOpened(_opened);\n\n if (_opened) {\n setCurrentId(uid);\n }\n },\n [uid]\n );\n\n const {\n x,\n y,\n context,\n refs,\n placement,\n middlewareData: { arrow: { x: arrowX, y: arrowY } = {} },\n } = useFloating({\n strategy: settings.strategy,\n placement: settings.position,\n open: opened,\n onOpenChange: onChange,\n middleware: getTooltipMiddlewares(settings),\n whileElementsMounted: autoUpdate,\n });\n\n const { delay: groupDelay, currentId, setCurrentId } = useDelayGroup(context, { id: uid });\n\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useHover(context, {\n enabled: settings.events?.hover,\n delay: withinGroup ? groupDelay : { open: settings.openDelay, close: settings.closeDelay },\n mouseOnly: !settings.events?.touch,\n handleClose: settings.interactive ? safePolygon() : null,\n }),\n useFocus(context, { enabled: settings.events?.focus, visibleOnly: true }),\n useRole(context, { role: 'tooltip' }),\n // Cannot be used with controlled tooltip, page jumps\n useDismiss(context, { enabled: typeof settings.opened === 'undefined' }),\n ]);\n\n const previousPlacementRef = useRef(placement);\n useIsomorphicEffect(() => {\n if (previousPlacementRef.current !== placement) {\n previousPlacementRef.current = placement;\n settings.onPositionChange?.(placement);\n }\n }, [placement]);\n\n const isGroupPhase = opened && currentId && currentId !== uid;\n\n return {\n x,\n y,\n arrowX,\n arrowY,\n reference: refs.setReference,\n floating: refs.setFloating,\n getFloatingProps,\n getReferenceProps,\n isGroupPhase,\n opened,\n placement,\n };\n}\n"],"mappings":";;;;;;AAwCA,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,sBAAsB,UAAsB;CACnD,MAAM,qBAAqB,sBAAsB,SAAS,WAAW;CACrE,MAAM,cAA4B,EAAA,GAAA,mBAAA,OAAA,CAAQ,SAAS,MAAM,CAAC;CAE1D,IAAI,mBAAmB,OACrB,YAAY,MAAA,GAAA,mBAAA,MAAA,CAER,OAAO,mBAAmB,UAAU,YAChC,EAAE,SAAS,EAAE,IACb;EAAE,SAAS;EAAG,GAAG,mBAAmB;CAAM,CAChD,CACF;CAGF,IAAI,mBAAmB,MAC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AA,mBAAA,gBAAA,CAAqC;mCACrD,SAAS;GAChB,SAAS,SAAS,QAAQ;GAC1B,OAAO,cAAc,aAAa;IAAE,MAAM,SAAS;IAAW,OAAO,SAAS;GAAW;GACzF,WAAW,CAAC,SAAS,QAAQ;GAC7B,aAAa,SAAS,eAAA,GAAA,mBAAA,YAAA,CAA0B,IAAI;EACtD,CAAC;mCACQ,SAAS;GAAE,SAAS,SAAS,QAAQ;GAAO,aAAa;EAAK,CAAC;kCAChE,SAAS,EAAE,MAAM,UAAU,CAAC;qCAEzB,SAAS,EAAE,SAAS,OAAO,SAAS,WAAW,YAAY,CAAC;CACzE,CAAC;CAED,MAAM,wBAAA,GAAA,MAAA,OAAA,CAA8B,SAAS;CAC7C,CAAA,GAAA,eAAA,oBAAA,OAA0B;EACxB,IAAI,qBAAqB,YAAY,WAAW;GAC9C,qBAAqB,UAAU;GAC/B,SAAS,mBAAmB,SAAS;EACvC;CACF,GAAG,CAAC,SAAS,CAAC;CAEd,MAAM,eAAe,UAAU,aAAa,cAAc;CAE1D,OAAO;EACL;EACA;EACA;EACA;EACA,WAAW,KAAK;EAChB,UAAU,KAAK;EACf;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -8,6 +8,7 @@ const require_ScrollArea = require("../ScrollArea/ScrollArea.cjs");
|
|
|
8
8
|
const require_InputBase = require("../InputBase/InputBase.cjs");
|
|
9
9
|
const require_use_combobox = require("../Combobox/use-combobox/use-combobox.cjs");
|
|
10
10
|
const require_Combobox = require("../Combobox/Combobox.cjs");
|
|
11
|
+
const require_is_external_input_change = require("../Combobox/is-external-input-change/is-external-input-change.cjs");
|
|
11
12
|
const require_Pill = require("../Pill/Pill.cjs");
|
|
12
13
|
const require_PillsInput = require("../PillsInput/PillsInput.cjs");
|
|
13
14
|
const require_get_children_nodes_values = require("../Tree/get-children-nodes-values/get-children-nodes-values.cjs");
|
|
@@ -485,6 +486,7 @@ const TreeSelect = require_factory.genericFactory((_props) => {
|
|
|
485
486
|
onKeyDown: handleKeyDown,
|
|
486
487
|
value: _searchValue,
|
|
487
488
|
onChange: (event) => {
|
|
489
|
+
if (require_is_external_input_change.isExternalInputChange(event)) return;
|
|
488
490
|
handleSearchChange(event.currentTarget.value);
|
|
489
491
|
if (searchable) combobox.openDropdown();
|
|
490
492
|
},
|
|
@@ -538,6 +540,7 @@ const TreeSelect = require_factory.genericFactory((_props) => {
|
|
|
538
540
|
readOnly: readOnly || !searchable,
|
|
539
541
|
value: searchable ? _searchValue : singleDisplayLabel,
|
|
540
542
|
onChange: (event) => {
|
|
543
|
+
if (require_is_external_input_change.isExternalInputChange(event)) return;
|
|
541
544
|
handleSearchChange(event.currentTarget.value);
|
|
542
545
|
combobox.openDropdown();
|
|
543
546
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSelect.cjs","names":["genericFactory","useProps","useCombobox","getTreeExpandedState","findTreeNode","expandToLeafChecked","filterTreeData","flattenTreeSelectData","useStyles","useResolvedStylesApi","extractStyleProps","isNodeChecked","getChildrenNodesValues","checkedToValue","Combobox","Pill","isNodeIndeterminate","TreeSelectOption","classes","ScrollArea","PillsInput","InputBase"],"sources":["../../../src/components/TreeSelect/TreeSelect.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n genericFactory,\n MantineColor,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Combobox, ComboboxLikeStylesNames, useCombobox } from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Pill } from '../Pill';\nimport { PillsInput } from '../PillsInput';\nimport { ScrollArea, ScrollAreaProps } from '../ScrollArea';\nimport type { TreeNodeData } from '../Tree';\nimport { filterTreeData } from '../Tree/filter-tree-data/filter-tree-data';\nimport {\n findTreeNode,\n getChildrenNodesValues,\n} from '../Tree/get-children-nodes-values/get-children-nodes-values';\nimport { isNodeChecked } from '../Tree/is-node-checked/is-node-checked';\nimport { isNodeIndeterminate } from '../Tree/is-node-indeterminate/is-node-indeterminate';\nimport { getTreeExpandedState, TreeExpandedState } from '../Tree/use-tree';\nimport { flattenTreeSelectData } from './flatten-tree-select-data';\nimport {\n CheckedStrategy,\n checkedToValue,\n expandToLeafChecked,\n} from './get-checked-values-by-strategy';\nimport {\n TreeSelectChevronAriaLabels,\n TreeSelectOption,\n TreeSelectRenderNodePayload,\n} from './TreeSelectOption';\nimport classes from './TreeSelect.module.css';\n\nexport type TreeSelectStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport type TreeSelectMode = 'single' | 'multiple' | 'checkbox';\n\nexport type TreeSelectValue<Mode extends TreeSelectMode> = Mode extends 'single'\n ? string | null\n : string[];\n\nexport interface TreeSelectProps<Mode extends TreeSelectMode = 'single'>\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<TreeSelectFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Tree data */\n data: TreeNodeData[];\n\n /** Selection mode: 'single', 'multiple', or 'checkbox' (with cascade) @default 'single' */\n mode?: Mode;\n\n /** Controlled value */\n value?: TreeSelectValue<Mode>;\n\n /** Default value */\n defaultValue?: TreeSelectValue<Mode>;\n\n /** Called when value changes */\n onChange?: (value: TreeSelectValue<Mode>) => void;\n\n /** Disables parent-child cascade in checkbox mode @default false */\n checkStrictly?: boolean;\n\n /** Controls which checked nodes appear in value/pills in checkbox mode @default 'child' */\n checkedStrategy?: CheckedStrategy;\n\n /** Default expanded node values */\n defaultExpandedValues?: string[];\n\n /** Expand all nodes by default @default false */\n defaultExpandAll?: boolean;\n\n /** Controlled expanded state */\n expandedValues?: string[];\n\n /** Called when expanded state changes */\n onExpandedChange?: (values: string[]) => void;\n\n /** Also toggle expand when clicking a parent node (not just the chevron). In `single` and `multiple` modes, parent clicks only expand; only leaves can be selected. In `checkbox` mode, parent clicks both check and expand. @default false */\n expandOnClick?: boolean;\n\n /** Enables search filtering @default false */\n searchable?: boolean;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Custom filter function */\n filter?: (query: string, node: TreeNodeData) => boolean;\n\n /** Message when no nodes match search */\n nothingFoundMessage?: React.ReactNode;\n\n /** Allows deselecting in single mode @default true */\n allowDeselect?: boolean;\n\n /** Shows clear button @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props for the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Maximum selectable values (multiple/checkbox mode) */\n maxValues?: number;\n\n /** Maximum displayed pills before \"+N more\" */\n maxDisplayedValues?: number;\n\n /** Content shown when values overflow maxDisplayedValues */\n maxDisplayedValuesContent?: React.ReactNode | ((overflow: number) => React.ReactNode);\n\n /** Called with removed value in multiple/checkbox mode */\n onRemove?: (value: string) => void;\n\n /** Called when clear button is clicked */\n onClear?: () => void;\n\n /** Custom node rendering in the dropdown */\n renderNode?: (payload: TreeSelectRenderNodePayload) => React.ReactNode;\n\n /** Show tree connection lines between parent and child nodes @default true */\n withLines?: boolean;\n\n /** Props for the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Divider for hidden input values @default ',' */\n hiddenInputValuesDivider?: string;\n\n /** Props for the ScrollArea in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls the default chevron color */\n chevronColor?: MantineColor;\n\n /** Max dropdown height @default 220 */\n maxDropdownHeight?: number | string;\n\n /** Controlled dropdown state */\n dropdownOpened?: boolean;\n\n /** Default dropdown state */\n defaultDropdownOpened?: boolean;\n\n /** Called when dropdown opens */\n onDropdownOpen?: () => void;\n\n /** Called when dropdown closes */\n onDropdownClose?: () => void;\n\n /** Props passed to the underlying Combobox */\n comboboxProps?: Record<string, any>;\n\n /** Clear search on selection change @default true */\n clearSearchOnChange?: boolean;\n\n /** Opens dropdown on focus (searchable mode) @default true */\n openOnFocus?: boolean;\n\n /** aria-label values for the expand/collapse chevron button */\n chevronAriaLabels?: TreeSelectChevronAriaLabels;\n}\n\nexport type TreeSelectFactory = Factory<{\n props: TreeSelectProps;\n ref: HTMLInputElement;\n stylesNames: TreeSelectStylesNames;\n variant: InputVariant;\n signature: <Mode extends TreeSelectMode = 'single'>(\n props: TreeSelectProps<Mode>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n mode: 'single',\n allowDeselect: true,\n checkedStrategy: 'child',\n maxValues: Infinity,\n hiddenInputValuesDivider: ',',\n clearSearchOnChange: true,\n openOnFocus: true,\n size: 'sm',\n withLines: true,\n} satisfies Partial<TreeSelectProps<TreeSelectMode>>;\n\nconst clearSectionOffset: Record<string, number> = {\n xs: 41,\n sm: 50,\n md: 60,\n lg: 72,\n xl: 89,\n};\n\nfunction getAncestorsToNode(value: string, nodes: TreeNodeData[]): string[] | null {\n for (const node of nodes) {\n if (node.value === value) {\n return [];\n }\n if (Array.isArray(node.children)) {\n const path = getAncestorsToNode(value, node.children);\n if (path !== null) {\n return [node.value, ...path];\n }\n }\n }\n return null;\n}\n\nexport const TreeSelect = genericFactory<TreeSelectFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'TreeSelect'], defaultProps as any, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n data,\n mode,\n value,\n defaultValue,\n onChange,\n checkStrictly,\n checkedStrategy,\n defaultExpandedValues,\n defaultExpandAll,\n expandedValues,\n onExpandedChange,\n expandOnClick,\n searchable,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n filter,\n nothingFoundMessage,\n allowDeselect,\n clearable,\n clearSectionMode,\n clearButtonProps,\n maxValues,\n maxDisplayedValues,\n maxDisplayedValuesContent,\n onRemove,\n onClear,\n renderNode,\n withLines,\n hiddenInputProps,\n hiddenInputValuesDivider,\n scrollAreaProps,\n chevronColor,\n maxDropdownHeight,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n comboboxProps,\n clearSearchOnChange,\n openOnFocus,\n chevronAriaLabels,\n variant,\n onKeyDown,\n onFocus,\n onBlur,\n onClick,\n readOnly,\n disabled,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n labelProps,\n descriptionProps,\n errorProps,\n successProps,\n wrapperProps,\n description,\n label,\n error,\n success,\n withErrorStyles,\n withSuccessStyles,\n name,\n form,\n id,\n placeholder,\n required,\n mod,\n attributes,\n ...others\n } = props;\n\n const isMulti = mode === 'multiple' || mode === 'checkbox';\n const isCheckbox = mode === 'checkbox';\n const _id = useId(id);\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n combobox.updateSelectedOptionIndex('active', { scrollIntoView: true });\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\n });\n\n const initialExpanded = useMemo(() => {\n if (defaultExpandAll) {\n return getTreeExpandedState(data, '*');\n }\n if (defaultExpandedValues) {\n return getTreeExpandedState(data, defaultExpandedValues);\n }\n return getTreeExpandedState(data, []);\n }, []);\n\n const expandedToRecord = useCallback(\n (values: string[] | undefined): TreeExpandedState | undefined => {\n if (!values) {\n return undefined;\n }\n return getTreeExpandedState(data, values);\n },\n [data]\n );\n\n const [_expandedState, setExpandedState] = useUncontrolled<TreeExpandedState>({\n value: expandedToRecord(expandedValues),\n defaultValue: initialExpanded,\n finalValue: {},\n onChange: (val) => {\n if (onExpandedChange) {\n onExpandedChange(\n Object.entries(val)\n .filter(([, v]) => v)\n .map(([k]) => k)\n );\n }\n },\n });\n\n const toggleExpand = useCallback(\n (nodeValue: string) => {\n setExpandedState({ ..._expandedState, [nodeValue]: !_expandedState[nodeValue] });\n },\n [_expandedState]\n );\n\n const initialSearchValue = useMemo(() => {\n if (mode !== 'single' || !defaultValue) {\n return '';\n }\n const node = findTreeNode(defaultValue as string, data);\n return node ? (typeof node.label === 'string' ? node.label : '') : '';\n }, []);\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: initialSearchValue,\n onChange: onSearchChange,\n });\n\n const handleSearchChange = (val: string) => {\n setSearchValue(val);\n combobox.resetSelectedOption();\n };\n\n const [_value, setValue] = useUncontrolled({\n value: value as any,\n defaultValue: defaultValue as any,\n finalValue: isMulti ? [] : null,\n onChange,\n });\n\n const internalChecked = useMemo(() => {\n if (!isCheckbox || !_value || !Array.isArray(_value)) {\n return [];\n }\n if (checkStrictly) {\n return _value;\n }\n return expandToLeafChecked(_value, data);\n }, [isCheckbox, _value, data, checkStrictly]);\n\n const filteredData = useMemo(() => {\n if (!searchable || !_searchValue) {\n return data;\n }\n if (mode === 'single' && _value) {\n const node = findTreeNode(_value as string, data);\n if (node && _searchValue === (typeof node.label === 'string' ? node.label : '')) {\n return data;\n }\n }\n return filterTreeData(data, _searchValue, filter);\n }, [data, _searchValue, filter, searchable, mode, _value]);\n\n const expandedForRender = useMemo(() => {\n if (_searchValue && filteredData !== data) {\n const expanded = { ..._expandedState };\n const expandFilteredParents = (nodes: TreeNodeData[]) => {\n for (const node of nodes) {\n if (Array.isArray(node.children) && node.children.length > 0) {\n expanded[node.value] = true;\n expandFilteredParents(node.children);\n }\n }\n };\n expandFilteredParents(filteredData);\n return expanded;\n }\n return _expandedState;\n }, [filteredData, _expandedState, _searchValue, data]);\n\n const flatNodes = useMemo(\n () => flattenTreeSelectData(filteredData, expandedForRender),\n [filteredData, expandedForRender]\n );\n\n const flatNodesRef = useRef(flatNodes);\n flatNodesRef.current = flatNodes;\n\n const nodeLookup = useMemo(() => {\n const lookup: Record<string, TreeNodeData> = {};\n const walk = (nodes: TreeNodeData[]) => {\n for (const node of nodes) {\n lookup[node.value] = node;\n if (Array.isArray(node.children)) {\n walk(node.children);\n }\n }\n };\n walk(data);\n return lookup;\n }, [data]);\n\n const getNodeLabel = (nodeValue: string): string => {\n const node = nodeLookup[nodeValue];\n if (!node) {\n return nodeValue;\n }\n return typeof node.label === 'string' ? node.label : nodeValue;\n };\n\n const getStyles = useStyles<TreeSelectFactory>({\n name: 'TreeSelect',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<TreeSelectFactory>({\n props,\n styles,\n classNames,\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const handleOptionSubmit = (val: string) => {\n if (mode === 'single') {\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n toggleExpand(val);\n return;\n }\n }\n const nextValue = allowDeselect && val === _value ? null : val;\n setValue(nextValue);\n combobox.closeDropdown();\n if (clearSearchOnChange) {\n handleSearchChange(nextValue ? getNodeLabel(nextValue) : '');\n }\n } else if (mode === 'multiple') {\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n toggleExpand(val);\n return;\n }\n }\n const arr = (_value as string[]) || [];\n if (arr.includes(val)) {\n setValue(arr.filter((v: string) => v !== val));\n onRemove?.(val);\n } else if (arr.length < (maxValues ?? Infinity)) {\n setValue([...arr, val]);\n } else {\n return;\n }\n if (clearSearchOnChange) {\n setSearchValue('');\n }\n } else if (mode === 'checkbox') {\n const nodeChecked = checkStrictly\n ? internalChecked.includes(val)\n : isNodeChecked(val, data, internalChecked);\n\n let newInternalChecked: string[];\n if (checkStrictly) {\n newInternalChecked = nodeChecked\n ? internalChecked.filter((v) => v !== val)\n : [...internalChecked, val];\n } else {\n const childLeaves = getChildrenNodesValues(val, data);\n if (nodeChecked) {\n newInternalChecked = internalChecked.filter((v) => !childLeaves.includes(v));\n } else {\n newInternalChecked = [...new Set([...internalChecked, ...childLeaves])];\n }\n }\n\n const newValue = checkedToValue(newInternalChecked, data, checkedStrategy!);\n if (!nodeChecked && newValue.length > (maxValues ?? Infinity)) {\n return;\n }\n setValue(newValue);\n if (clearSearchOnChange) {\n setSearchValue('');\n }\n\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n if (!_expandedState[val]) {\n toggleExpand(val);\n }\n }\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.key === ' ' && !searchable && isMulti) {\n event.preventDefault();\n combobox.toggleDropdown();\n }\n\n if (event.key === 'Backspace' && _searchValue.length === 0 && isMulti) {\n const arr = (_value as string[]) || [];\n if (arr.length > 0) {\n const removed = arr[arr.length - 1];\n onRemove?.(removed);\n setValue(arr.slice(0, -1));\n }\n }\n\n if (!combobox.dropdownOpened) {\n return;\n }\n\n const index = combobox.getSelectedOptionIndex();\n if (index < 0 || index >= flatNodesRef.current.length) {\n return;\n }\n\n const currentNode = flatNodesRef.current[index];\n\n if (event.key === 'ArrowRight') {\n if (currentNode.hasChildren && !currentNode.expanded) {\n event.preventDefault();\n toggleExpand(currentNode.node.value);\n }\n }\n\n if (event.key === 'ArrowLeft') {\n if (currentNode.hasChildren && currentNode.expanded) {\n event.preventDefault();\n toggleExpand(currentNode.node.value);\n } else if (currentNode.parent) {\n event.preventDefault();\n const parentIndex = flatNodesRef.current.findIndex(\n (n) => n.node.value === currentNode.parent\n );\n if (parentIndex >= 0) {\n combobox.selectOption(parentIndex);\n }\n }\n }\n };\n\n useEffect(() => {\n if (mode !== 'single' || !searchable) {\n return;\n }\n if (value === null) {\n handleSearchChange('');\n } else if (typeof value === 'string') {\n handleSearchChange(getNodeLabel(value));\n }\n }, [value]);\n\n const prevDropdownOpenedRef = useRef(false);\n useEffect(() => {\n if (combobox.dropdownOpened && !prevDropdownOpenedRef.current && searchable && _value) {\n const targets = Array.isArray(_value) ? _value : [_value];\n const newExpanded = { ..._expandedState };\n let changed = false;\n for (const target of targets) {\n const ancestors = getAncestorsToNode(target as string, data);\n if (ancestors) {\n for (const a of ancestors) {\n if (!newExpanded[a]) {\n newExpanded[a] = true;\n changed = true;\n }\n }\n }\n }\n if (changed) {\n setExpandedState(newExpanded);\n requestAnimationFrame(() => {\n combobox.updateSelectedOptionIndex('active', { scrollIntoView: true });\n });\n }\n }\n prevDropdownOpenedRef.current = combobox.dropdownOpened;\n });\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n setValue(isMulti ? [] : null);\n handleSearchChange('');\n combobox.focusTarget();\n }}\n />\n );\n\n const hasValue = isMulti\n ? Array.isArray(_value) && _value.length > 0\n : _value != null && _value !== '';\n const _clearable = clearable && hasValue && !disabled && !readOnly;\n\n const singleDisplayLabel = useMemo(() => {\n if (mode !== 'single' || !_value) {\n return '';\n }\n return getNodeLabel(_value as string);\n }, [mode, _value, nodeLookup]);\n\n const displayValues = useMemo(() => {\n if (!isMulti || !Array.isArray(_value)) {\n return [];\n }\n return _value as string[];\n }, [isMulti, _value]);\n\n const pillsListStyle =\n _clearable && isMulti\n ? { paddingInlineEnd: clearSectionOffset[size as string] ?? clearSectionOffset.sm }\n : undefined;\n\n const visiblePills =\n maxDisplayedValues != null ? displayValues.slice(0, maxDisplayedValues) : displayValues;\n\n const overflowCount =\n maxDisplayedValues != null ? Math.max(0, displayValues.length - maxDisplayedValues) : 0;\n\n const pills = visiblePills.map((item, index) => (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly}\n onRemove={() => {\n if (isCheckbox) {\n const childLeaves = checkStrictly ? [item] : getChildrenNodesValues(item, data);\n const newInternal = internalChecked.filter((v) => !childLeaves.includes(v));\n setValue(checkedToValue(newInternal, data, checkedStrategy!));\n } else {\n setValue((_value as string[]).filter((v: string) => v !== item));\n }\n onRemove?.(item);\n }}\n unstyled={unstyled}\n disabled={disabled}\n {...getStyles('pill')}\n >\n {getNodeLabel(item)}\n </Pill>\n ));\n\n if (overflowCount > 0) {\n const overflowContent =\n typeof maxDisplayedValuesContent === 'function'\n ? maxDisplayedValuesContent(overflowCount)\n : maxDisplayedValuesContent || `+${overflowCount} more`;\n pills.push(\n <Pill key=\"__overflow\" unstyled={unstyled} disabled={disabled} {...getStyles('pill')}>\n {overflowContent}\n </Pill>\n );\n }\n\n const isEmpty = flatNodes.length === 0;\n\n const options = flatNodes.map((flatNode) => {\n const isSelected =\n mode === 'single'\n ? _value === flatNode.node.value\n : mode === 'multiple'\n ? ((_value as string[]) || []).includes(flatNode.node.value)\n : false;\n\n const nodeChecked = isCheckbox\n ? checkStrictly\n ? internalChecked.includes(flatNode.node.value)\n : isNodeChecked(flatNode.node.value, data, internalChecked)\n : false;\n\n const nodeIndeterminate =\n isCheckbox && !checkStrictly\n ? isNodeIndeterminate(flatNode.node.value, data, internalChecked)\n : false;\n\n return (\n <TreeSelectOption\n key={flatNode.node.value}\n node={flatNode.node}\n level={flatNode.level}\n expanded={flatNode.expanded}\n hasChildren={flatNode.hasChildren}\n selected={isSelected}\n checked={nodeChecked}\n indeterminate={nodeIndeterminate}\n showCheckbox={isCheckbox}\n isLastChild={flatNode.isLastChild}\n lineGuides={flatNode.lineGuides}\n withLines={!!withLines}\n onToggleExpand={toggleExpand}\n renderNode={renderNode}\n chevronAriaLabels={chevronAriaLabels}\n />\n );\n });\n\n const dropdown = (\n <Combobox.Dropdown hidden={readOnly || disabled}>\n <Combobox.Options\n className={classes.optionsWrapper}\n aria-multiselectable={isMulti || undefined}\n >\n <ScrollArea.Autosize\n mah={maxDropdownHeight ?? 220}\n type=\"scroll\"\n scrollbarSize=\"var(--combobox-padding)\"\n offsetScrollbars=\"y\"\n {...scrollAreaProps}\n >\n {options}\n </ScrollArea.Autosize>\n {isEmpty && nothingFoundMessage && <Combobox.Empty>{nothingFoundMessage}</Combobox.Empty>}\n </Combobox.Options>\n </Combobox.Dropdown>\n );\n\n if (isMulti) {\n return (\n <>\n <Combobox\n store={combobox}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n readOnly={readOnly}\n __staticSelector=\"TreeSelect\"\n attributes={attributes}\n onOptionSubmit={handleOptionSubmit}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"TreeSelect\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n className={className}\n style={style}\n variant={variant}\n disabled={disabled}\n radius={radius}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n successProps={successProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n error={error}\n success={success}\n withErrorStyles={withErrorStyles}\n withSuccessStyles={withSuccessStyles}\n __stylesApiProps={{\n ...props,\n rightSectionPointerEvents: rightSectionPointerEvents || 'none',\n multiline: true,\n }}\n pointer={!searchable}\n onClick={() => (searchable ? combobox.openDropdown() : combobox.toggleDropdown())}\n data-expanded={combobox.dropdownOpened || undefined}\n id={_id}\n required={required}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group\n attributes={attributes}\n disabled={disabled}\n unstyled={unstyled}\n {...getStyles('pillsList', { style: pillsListStyle })}\n >\n {pills}\n <Combobox.EventsTarget autoComplete={autoComplete}>\n <PillsInput.Field\n {...rest}\n id={_id}\n placeholder={placeholder}\n type={!searchable && !placeholder ? 'hidden' : 'visible'}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onFocus={(event) => {\n onFocus?.(event);\n if (openOnFocus && searchable) {\n combobox.openDropdown();\n }\n }}\n onBlur={(event) => {\n onBlur?.(event);\n combobox.closeDropdown();\n handleSearchChange('');\n }}\n onKeyDown={handleKeyDown}\n value={_searchValue}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n if (searchable) {\n combobox.openDropdown();\n }\n }}\n disabled={disabled}\n readOnly={readOnly || !searchable}\n pointer={!searchable}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n {dropdown}\n </Combobox>\n <Combobox.HiddenInput\n name={name}\n valuesDivider={hiddenInputValuesDivider}\n value={_value}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n }\n\n return (\n <>\n <Combobox\n store={combobox}\n __staticSelector=\"TreeSelect\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n onOptionSubmit={handleOptionSubmit}\n {...comboboxProps}\n >\n <Combobox.Target targetType={searchable ? 'input' : 'button'} autoComplete={autoComplete}>\n <InputBase\n id={_id}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n {...rest}\n {...styleProps}\n size={size}\n __staticSelector=\"TreeSelect\"\n disabled={disabled}\n readOnly={readOnly || !searchable}\n value={searchable ? _searchValue : singleDisplayLabel}\n onChange={(event) => {\n handleSearchChange(event.currentTarget.value);\n combobox.openDropdown();\n }}\n onFocus={(event) => {\n if (openOnFocus && searchable) {\n combobox.openDropdown();\n }\n onFocus?.(event);\n }}\n onBlur={(event) => {\n if (searchable) {\n combobox.closeDropdown();\n }\n handleSearchChange(_value ? getNodeLabel(_value as string) : '');\n onBlur?.(event);\n }}\n onClick={(event) => {\n searchable ? combobox.openDropdown() : combobox.toggleDropdown();\n onClick?.(event);\n }}\n onKeyDown={handleKeyDown}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n pointer={!searchable}\n error={error}\n success={success}\n attributes={attributes}\n className={className}\n style={style}\n variant={variant}\n radius={radius}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n successProps={successProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n withErrorStyles={withErrorStyles}\n withSuccessStyles={withSuccessStyles}\n placeholder={placeholder}\n required={required}\n mod={mod}\n />\n </Combobox.Target>\n {dropdown}\n </Combobox>\n <Combobox.HiddenInput\n value={_value}\n name={name}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nTreeSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nTreeSelect.displayName = '@mantine/core/TreeSelect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4MA,MAAM,eAAe;CACnB,MAAM;CACN,eAAe;CACf,iBAAiB;CACjB,WAAW;CACX,0BAA0B;CAC1B,qBAAqB;CACrB,aAAa;CACb,MAAM;CACN,WAAW;AACb;AAEA,MAAM,qBAA6C;CACjD,I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,kBAAA,IAAA,CAACA,iBAAAA,SAAS,aAAV;EACE,OAAO;EACD;EACA;EACI;EACV,GAAI;CACL,CAAA,CACD,EAAA,CAAA;AAEN,CAAC;AAED,WAAW,UAAU;CAAE,GAAGO,kBAAAA,UAAU;CAAS,GAAGP,iBAAAA,SAAS;AAAQ;AACjE,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"TreeSelect.cjs","names":["genericFactory","useProps","useCombobox","getTreeExpandedState","findTreeNode","expandToLeafChecked","filterTreeData","flattenTreeSelectData","useStyles","useResolvedStylesApi","extractStyleProps","isNodeChecked","getChildrenNodesValues","checkedToValue","Combobox","Pill","isNodeIndeterminate","TreeSelectOption","classes","ScrollArea","PillsInput","isExternalInputChange","InputBase"],"sources":["../../../src/components/TreeSelect/TreeSelect.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n genericFactory,\n MantineColor,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Combobox, ComboboxLikeStylesNames, useCombobox } from '../Combobox';\nimport { isExternalInputChange } from '../Combobox/is-external-input-change/is-external-input-change';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { Pill } from '../Pill';\nimport { PillsInput } from '../PillsInput';\nimport { ScrollArea, ScrollAreaProps } from '../ScrollArea';\nimport type { TreeNodeData } from '../Tree';\nimport { filterTreeData } from '../Tree/filter-tree-data/filter-tree-data';\nimport {\n findTreeNode,\n getChildrenNodesValues,\n} from '../Tree/get-children-nodes-values/get-children-nodes-values';\nimport { isNodeChecked } from '../Tree/is-node-checked/is-node-checked';\nimport { isNodeIndeterminate } from '../Tree/is-node-indeterminate/is-node-indeterminate';\nimport { getTreeExpandedState, TreeExpandedState } from '../Tree/use-tree';\nimport { flattenTreeSelectData } from './flatten-tree-select-data';\nimport {\n CheckedStrategy,\n checkedToValue,\n expandToLeafChecked,\n} from './get-checked-values-by-strategy';\nimport {\n TreeSelectChevronAriaLabels,\n TreeSelectOption,\n TreeSelectRenderNodePayload,\n} from './TreeSelectOption';\nimport classes from './TreeSelect.module.css';\n\nexport type TreeSelectStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'pill'\n | 'pillsList'\n | 'inputField';\n\nexport type TreeSelectMode = 'single' | 'multiple' | 'checkbox';\n\nexport type TreeSelectValue<Mode extends TreeSelectMode> = Mode extends 'single'\n ? string | null\n : string[];\n\nexport interface TreeSelectProps<Mode extends TreeSelectMode = 'single'>\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<TreeSelectFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Tree data */\n data: TreeNodeData[];\n\n /** Selection mode: 'single', 'multiple', or 'checkbox' (with cascade) @default 'single' */\n mode?: Mode;\n\n /** Controlled value */\n value?: TreeSelectValue<Mode>;\n\n /** Default value */\n defaultValue?: TreeSelectValue<Mode>;\n\n /** Called when value changes */\n onChange?: (value: TreeSelectValue<Mode>) => void;\n\n /** Disables parent-child cascade in checkbox mode @default false */\n checkStrictly?: boolean;\n\n /** Controls which checked nodes appear in value/pills in checkbox mode @default 'child' */\n checkedStrategy?: CheckedStrategy;\n\n /** Default expanded node values */\n defaultExpandedValues?: string[];\n\n /** Expand all nodes by default @default false */\n defaultExpandAll?: boolean;\n\n /** Controlled expanded state */\n expandedValues?: string[];\n\n /** Called when expanded state changes */\n onExpandedChange?: (values: string[]) => void;\n\n /** Also toggle expand when clicking a parent node (not just the chevron). In `single` and `multiple` modes, parent clicks only expand; only leaves can be selected. In `checkbox` mode, parent clicks both check and expand. @default false */\n expandOnClick?: boolean;\n\n /** Enables search filtering @default false */\n searchable?: boolean;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Default search value */\n defaultSearchValue?: string;\n\n /** Called when search changes */\n onSearchChange?: (value: string) => void;\n\n /** Custom filter function */\n filter?: (query: string, node: TreeNodeData) => boolean;\n\n /** Message when no nodes match search */\n nothingFoundMessage?: React.ReactNode;\n\n /** Allows deselecting in single mode @default true */\n allowDeselect?: boolean;\n\n /** Shows clear button @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and rightSection are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props for the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Maximum selectable values (multiple/checkbox mode) */\n maxValues?: number;\n\n /** Maximum displayed pills before \"+N more\" */\n maxDisplayedValues?: number;\n\n /** Content shown when values overflow maxDisplayedValues */\n maxDisplayedValuesContent?: React.ReactNode | ((overflow: number) => React.ReactNode);\n\n /** Called with removed value in multiple/checkbox mode */\n onRemove?: (value: string) => void;\n\n /** Called when clear button is clicked */\n onClear?: () => void;\n\n /** Custom node rendering in the dropdown */\n renderNode?: (payload: TreeSelectRenderNodePayload) => React.ReactNode;\n\n /** Show tree connection lines between parent and child nodes @default true */\n withLines?: boolean;\n\n /** Props for the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Divider for hidden input values @default ',' */\n hiddenInputValuesDivider?: string;\n\n /** Props for the ScrollArea in the dropdown */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls the default chevron color */\n chevronColor?: MantineColor;\n\n /** Max dropdown height @default 220 */\n maxDropdownHeight?: number | string;\n\n /** Controlled dropdown state */\n dropdownOpened?: boolean;\n\n /** Default dropdown state */\n defaultDropdownOpened?: boolean;\n\n /** Called when dropdown opens */\n onDropdownOpen?: () => void;\n\n /** Called when dropdown closes */\n onDropdownClose?: () => void;\n\n /** Props passed to the underlying Combobox */\n comboboxProps?: Record<string, any>;\n\n /** Clear search on selection change @default true */\n clearSearchOnChange?: boolean;\n\n /** Opens dropdown on focus (searchable mode) @default true */\n openOnFocus?: boolean;\n\n /** aria-label values for the expand/collapse chevron button */\n chevronAriaLabels?: TreeSelectChevronAriaLabels;\n}\n\nexport type TreeSelectFactory = Factory<{\n props: TreeSelectProps;\n ref: HTMLInputElement;\n stylesNames: TreeSelectStylesNames;\n variant: InputVariant;\n signature: <Mode extends TreeSelectMode = 'single'>(\n props: TreeSelectProps<Mode>\n ) => React.JSX.Element;\n}>;\n\nconst defaultProps = {\n mode: 'single',\n allowDeselect: true,\n checkedStrategy: 'child',\n maxValues: Infinity,\n hiddenInputValuesDivider: ',',\n clearSearchOnChange: true,\n openOnFocus: true,\n size: 'sm',\n withLines: true,\n} satisfies Partial<TreeSelectProps<TreeSelectMode>>;\n\nconst clearSectionOffset: Record<string, number> = {\n xs: 41,\n sm: 50,\n md: 60,\n lg: 72,\n xl: 89,\n};\n\nfunction getAncestorsToNode(value: string, nodes: TreeNodeData[]): string[] | null {\n for (const node of nodes) {\n if (node.value === value) {\n return [];\n }\n if (Array.isArray(node.children)) {\n const path = getAncestorsToNode(value, node.children);\n if (path !== null) {\n return [node.value, ...path];\n }\n }\n }\n return null;\n}\n\nexport const TreeSelect = genericFactory<TreeSelectFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'TreeSelect'], defaultProps as any, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n data,\n mode,\n value,\n defaultValue,\n onChange,\n checkStrictly,\n checkedStrategy,\n defaultExpandedValues,\n defaultExpandAll,\n expandedValues,\n onExpandedChange,\n expandOnClick,\n searchable,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n filter,\n nothingFoundMessage,\n allowDeselect,\n clearable,\n clearSectionMode,\n clearButtonProps,\n maxValues,\n maxDisplayedValues,\n maxDisplayedValuesContent,\n onRemove,\n onClear,\n renderNode,\n withLines,\n hiddenInputProps,\n hiddenInputValuesDivider,\n scrollAreaProps,\n chevronColor,\n maxDropdownHeight,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n comboboxProps,\n clearSearchOnChange,\n openOnFocus,\n chevronAriaLabels,\n variant,\n onKeyDown,\n onFocus,\n onBlur,\n onClick,\n readOnly,\n disabled,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n labelProps,\n descriptionProps,\n errorProps,\n successProps,\n wrapperProps,\n description,\n label,\n error,\n success,\n withErrorStyles,\n withSuccessStyles,\n name,\n form,\n id,\n placeholder,\n required,\n mod,\n attributes,\n ...others\n } = props;\n\n const isMulti = mode === 'multiple' || mode === 'checkbox';\n const isCheckbox = mode === 'checkbox';\n const _id = useId(id);\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n combobox.updateSelectedOptionIndex('active', { scrollIntoView: true });\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n combobox.resetSelectedOption();\n },\n });\n\n const initialExpanded = useMemo(() => {\n if (defaultExpandAll) {\n return getTreeExpandedState(data, '*');\n }\n if (defaultExpandedValues) {\n return getTreeExpandedState(data, defaultExpandedValues);\n }\n return getTreeExpandedState(data, []);\n }, []);\n\n const expandedToRecord = useCallback(\n (values: string[] | undefined): TreeExpandedState | undefined => {\n if (!values) {\n return undefined;\n }\n return getTreeExpandedState(data, values);\n },\n [data]\n );\n\n const [_expandedState, setExpandedState] = useUncontrolled<TreeExpandedState>({\n value: expandedToRecord(expandedValues),\n defaultValue: initialExpanded,\n finalValue: {},\n onChange: (val) => {\n if (onExpandedChange) {\n onExpandedChange(\n Object.entries(val)\n .filter(([, v]) => v)\n .map(([k]) => k)\n );\n }\n },\n });\n\n const toggleExpand = useCallback(\n (nodeValue: string) => {\n setExpandedState({ ..._expandedState, [nodeValue]: !_expandedState[nodeValue] });\n },\n [_expandedState]\n );\n\n const initialSearchValue = useMemo(() => {\n if (mode !== 'single' || !defaultValue) {\n return '';\n }\n const node = findTreeNode(defaultValue as string, data);\n return node ? (typeof node.label === 'string' ? node.label : '') : '';\n }, []);\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: initialSearchValue,\n onChange: onSearchChange,\n });\n\n const handleSearchChange = (val: string) => {\n setSearchValue(val);\n combobox.resetSelectedOption();\n };\n\n const [_value, setValue] = useUncontrolled({\n value: value as any,\n defaultValue: defaultValue as any,\n finalValue: isMulti ? [] : null,\n onChange,\n });\n\n const internalChecked = useMemo(() => {\n if (!isCheckbox || !_value || !Array.isArray(_value)) {\n return [];\n }\n if (checkStrictly) {\n return _value;\n }\n return expandToLeafChecked(_value, data);\n }, [isCheckbox, _value, data, checkStrictly]);\n\n const filteredData = useMemo(() => {\n if (!searchable || !_searchValue) {\n return data;\n }\n if (mode === 'single' && _value) {\n const node = findTreeNode(_value as string, data);\n if (node && _searchValue === (typeof node.label === 'string' ? node.label : '')) {\n return data;\n }\n }\n return filterTreeData(data, _searchValue, filter);\n }, [data, _searchValue, filter, searchable, mode, _value]);\n\n const expandedForRender = useMemo(() => {\n if (_searchValue && filteredData !== data) {\n const expanded = { ..._expandedState };\n const expandFilteredParents = (nodes: TreeNodeData[]) => {\n for (const node of nodes) {\n if (Array.isArray(node.children) && node.children.length > 0) {\n expanded[node.value] = true;\n expandFilteredParents(node.children);\n }\n }\n };\n expandFilteredParents(filteredData);\n return expanded;\n }\n return _expandedState;\n }, [filteredData, _expandedState, _searchValue, data]);\n\n const flatNodes = useMemo(\n () => flattenTreeSelectData(filteredData, expandedForRender),\n [filteredData, expandedForRender]\n );\n\n const flatNodesRef = useRef(flatNodes);\n flatNodesRef.current = flatNodes;\n\n const nodeLookup = useMemo(() => {\n const lookup: Record<string, TreeNodeData> = {};\n const walk = (nodes: TreeNodeData[]) => {\n for (const node of nodes) {\n lookup[node.value] = node;\n if (Array.isArray(node.children)) {\n walk(node.children);\n }\n }\n };\n walk(data);\n return lookup;\n }, [data]);\n\n const getNodeLabel = (nodeValue: string): string => {\n const node = nodeLookup[nodeValue];\n if (!node) {\n return nodeValue;\n }\n return typeof node.label === 'string' ? node.label : nodeValue;\n };\n\n const getStyles = useStyles<TreeSelectFactory>({\n name: 'TreeSelect',\n classes: {} as any,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<TreeSelectFactory>({\n props,\n styles,\n classNames,\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const handleOptionSubmit = (val: string) => {\n if (mode === 'single') {\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n toggleExpand(val);\n return;\n }\n }\n const nextValue = allowDeselect && val === _value ? null : val;\n setValue(nextValue);\n combobox.closeDropdown();\n if (clearSearchOnChange) {\n handleSearchChange(nextValue ? getNodeLabel(nextValue) : '');\n }\n } else if (mode === 'multiple') {\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n toggleExpand(val);\n return;\n }\n }\n const arr = (_value as string[]) || [];\n if (arr.includes(val)) {\n setValue(arr.filter((v: string) => v !== val));\n onRemove?.(val);\n } else if (arr.length < (maxValues ?? Infinity)) {\n setValue([...arr, val]);\n } else {\n return;\n }\n if (clearSearchOnChange) {\n setSearchValue('');\n }\n } else if (mode === 'checkbox') {\n const nodeChecked = checkStrictly\n ? internalChecked.includes(val)\n : isNodeChecked(val, data, internalChecked);\n\n let newInternalChecked: string[];\n if (checkStrictly) {\n newInternalChecked = nodeChecked\n ? internalChecked.filter((v) => v !== val)\n : [...internalChecked, val];\n } else {\n const childLeaves = getChildrenNodesValues(val, data);\n if (nodeChecked) {\n newInternalChecked = internalChecked.filter((v) => !childLeaves.includes(v));\n } else {\n newInternalChecked = [...new Set([...internalChecked, ...childLeaves])];\n }\n }\n\n const newValue = checkedToValue(newInternalChecked, data, checkedStrategy!);\n if (!nodeChecked && newValue.length > (maxValues ?? Infinity)) {\n return;\n }\n setValue(newValue);\n if (clearSearchOnChange) {\n setSearchValue('');\n }\n\n if (expandOnClick) {\n const node = findTreeNode(val, data);\n if (node && Array.isArray(node.children) && node.children.length > 0) {\n if (!_expandedState[val]) {\n toggleExpand(val);\n }\n }\n }\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.key === ' ' && !searchable && isMulti) {\n event.preventDefault();\n combobox.toggleDropdown();\n }\n\n if (event.key === 'Backspace' && _searchValue.length === 0 && isMulti) {\n const arr = (_value as string[]) || [];\n if (arr.length > 0) {\n const removed = arr[arr.length - 1];\n onRemove?.(removed);\n setValue(arr.slice(0, -1));\n }\n }\n\n if (!combobox.dropdownOpened) {\n return;\n }\n\n const index = combobox.getSelectedOptionIndex();\n if (index < 0 || index >= flatNodesRef.current.length) {\n return;\n }\n\n const currentNode = flatNodesRef.current[index];\n\n if (event.key === 'ArrowRight') {\n if (currentNode.hasChildren && !currentNode.expanded) {\n event.preventDefault();\n toggleExpand(currentNode.node.value);\n }\n }\n\n if (event.key === 'ArrowLeft') {\n if (currentNode.hasChildren && currentNode.expanded) {\n event.preventDefault();\n toggleExpand(currentNode.node.value);\n } else if (currentNode.parent) {\n event.preventDefault();\n const parentIndex = flatNodesRef.current.findIndex(\n (n) => n.node.value === currentNode.parent\n );\n if (parentIndex >= 0) {\n combobox.selectOption(parentIndex);\n }\n }\n }\n };\n\n useEffect(() => {\n if (mode !== 'single' || !searchable) {\n return;\n }\n if (value === null) {\n handleSearchChange('');\n } else if (typeof value === 'string') {\n handleSearchChange(getNodeLabel(value));\n }\n }, [value]);\n\n const prevDropdownOpenedRef = useRef(false);\n useEffect(() => {\n if (combobox.dropdownOpened && !prevDropdownOpenedRef.current && searchable && _value) {\n const targets = Array.isArray(_value) ? _value : [_value];\n const newExpanded = { ..._expandedState };\n let changed = false;\n for (const target of targets) {\n const ancestors = getAncestorsToNode(target as string, data);\n if (ancestors) {\n for (const a of ancestors) {\n if (!newExpanded[a]) {\n newExpanded[a] = true;\n changed = true;\n }\n }\n }\n }\n if (changed) {\n setExpandedState(newExpanded);\n requestAnimationFrame(() => {\n combobox.updateSelectedOptionIndex('active', { scrollIntoView: true });\n });\n }\n }\n prevDropdownOpenedRef.current = combobox.dropdownOpened;\n });\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n setValue(isMulti ? [] : null);\n handleSearchChange('');\n combobox.focusTarget();\n }}\n />\n );\n\n const hasValue = isMulti\n ? Array.isArray(_value) && _value.length > 0\n : _value != null && _value !== '';\n const _clearable = clearable && hasValue && !disabled && !readOnly;\n\n const singleDisplayLabel = useMemo(() => {\n if (mode !== 'single' || !_value) {\n return '';\n }\n return getNodeLabel(_value as string);\n }, [mode, _value, nodeLookup]);\n\n const displayValues = useMemo(() => {\n if (!isMulti || !Array.isArray(_value)) {\n return [];\n }\n return _value as string[];\n }, [isMulti, _value]);\n\n const pillsListStyle =\n _clearable && isMulti\n ? { paddingInlineEnd: clearSectionOffset[size as string] ?? clearSectionOffset.sm }\n : undefined;\n\n const visiblePills =\n maxDisplayedValues != null ? displayValues.slice(0, maxDisplayedValues) : displayValues;\n\n const overflowCount =\n maxDisplayedValues != null ? Math.max(0, displayValues.length - maxDisplayedValues) : 0;\n\n const pills = visiblePills.map((item, index) => (\n <Pill\n key={`${item}-${index}`}\n withRemoveButton={!readOnly}\n onRemove={() => {\n if (isCheckbox) {\n const childLeaves = checkStrictly ? [item] : getChildrenNodesValues(item, data);\n const newInternal = internalChecked.filter((v) => !childLeaves.includes(v));\n setValue(checkedToValue(newInternal, data, checkedStrategy!));\n } else {\n setValue((_value as string[]).filter((v: string) => v !== item));\n }\n onRemove?.(item);\n }}\n unstyled={unstyled}\n disabled={disabled}\n {...getStyles('pill')}\n >\n {getNodeLabel(item)}\n </Pill>\n ));\n\n if (overflowCount > 0) {\n const overflowContent =\n typeof maxDisplayedValuesContent === 'function'\n ? maxDisplayedValuesContent(overflowCount)\n : maxDisplayedValuesContent || `+${overflowCount} more`;\n pills.push(\n <Pill key=\"__overflow\" unstyled={unstyled} disabled={disabled} {...getStyles('pill')}>\n {overflowContent}\n </Pill>\n );\n }\n\n const isEmpty = flatNodes.length === 0;\n\n const options = flatNodes.map((flatNode) => {\n const isSelected =\n mode === 'single'\n ? _value === flatNode.node.value\n : mode === 'multiple'\n ? ((_value as string[]) || []).includes(flatNode.node.value)\n : false;\n\n const nodeChecked = isCheckbox\n ? checkStrictly\n ? internalChecked.includes(flatNode.node.value)\n : isNodeChecked(flatNode.node.value, data, internalChecked)\n : false;\n\n const nodeIndeterminate =\n isCheckbox && !checkStrictly\n ? isNodeIndeterminate(flatNode.node.value, data, internalChecked)\n : false;\n\n return (\n <TreeSelectOption\n key={flatNode.node.value}\n node={flatNode.node}\n level={flatNode.level}\n expanded={flatNode.expanded}\n hasChildren={flatNode.hasChildren}\n selected={isSelected}\n checked={nodeChecked}\n indeterminate={nodeIndeterminate}\n showCheckbox={isCheckbox}\n isLastChild={flatNode.isLastChild}\n lineGuides={flatNode.lineGuides}\n withLines={!!withLines}\n onToggleExpand={toggleExpand}\n renderNode={renderNode}\n chevronAriaLabels={chevronAriaLabels}\n />\n );\n });\n\n const dropdown = (\n <Combobox.Dropdown hidden={readOnly || disabled}>\n <Combobox.Options\n className={classes.optionsWrapper}\n aria-multiselectable={isMulti || undefined}\n >\n <ScrollArea.Autosize\n mah={maxDropdownHeight ?? 220}\n type=\"scroll\"\n scrollbarSize=\"var(--combobox-padding)\"\n offsetScrollbars=\"y\"\n {...scrollAreaProps}\n >\n {options}\n </ScrollArea.Autosize>\n {isEmpty && nothingFoundMessage && <Combobox.Empty>{nothingFoundMessage}</Combobox.Empty>}\n </Combobox.Options>\n </Combobox.Dropdown>\n );\n\n if (isMulti) {\n return (\n <>\n <Combobox\n store={combobox}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n readOnly={readOnly}\n __staticSelector=\"TreeSelect\"\n attributes={attributes}\n onOptionSubmit={handleOptionSubmit}\n {...comboboxProps}\n >\n <Combobox.DropdownTarget>\n <PillsInput\n {...styleProps}\n __staticSelector=\"TreeSelect\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n size={size}\n className={className}\n style={style}\n variant={variant}\n disabled={disabled}\n radius={radius}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n successProps={successProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n error={error}\n success={success}\n withErrorStyles={withErrorStyles}\n withSuccessStyles={withSuccessStyles}\n __stylesApiProps={{\n ...props,\n rightSectionPointerEvents: rightSectionPointerEvents || 'none',\n multiline: true,\n }}\n pointer={!searchable}\n onClick={() => (searchable ? combobox.openDropdown() : combobox.toggleDropdown())}\n data-expanded={combobox.dropdownOpened || undefined}\n id={_id}\n required={required}\n mod={mod}\n attributes={attributes}\n >\n <Pill.Group\n attributes={attributes}\n disabled={disabled}\n unstyled={unstyled}\n {...getStyles('pillsList', { style: pillsListStyle })}\n >\n {pills}\n <Combobox.EventsTarget autoComplete={autoComplete}>\n <PillsInput.Field\n {...rest}\n id={_id}\n placeholder={placeholder}\n type={!searchable && !placeholder ? 'hidden' : 'visible'}\n {...getStyles('inputField')}\n unstyled={unstyled}\n onFocus={(event) => {\n onFocus?.(event);\n if (openOnFocus && searchable) {\n combobox.openDropdown();\n }\n }}\n onBlur={(event) => {\n onBlur?.(event);\n combobox.closeDropdown();\n handleSearchChange('');\n }}\n onKeyDown={handleKeyDown}\n value={_searchValue}\n onChange={(event) => {\n if (isExternalInputChange(event)) {\n return;\n }\n\n handleSearchChange(event.currentTarget.value);\n if (searchable) {\n combobox.openDropdown();\n }\n }}\n disabled={disabled}\n readOnly={readOnly || !searchable}\n pointer={!searchable}\n />\n </Combobox.EventsTarget>\n </Pill.Group>\n </PillsInput>\n </Combobox.DropdownTarget>\n {dropdown}\n </Combobox>\n <Combobox.HiddenInput\n name={name}\n valuesDivider={hiddenInputValuesDivider}\n value={_value}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n }\n\n return (\n <>\n <Combobox\n store={combobox}\n __staticSelector=\"TreeSelect\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n onOptionSubmit={handleOptionSubmit}\n {...comboboxProps}\n >\n <Combobox.Target targetType={searchable ? 'input' : 'button'} autoComplete={autoComplete}>\n <InputBase\n id={_id}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n {...rest}\n {...styleProps}\n size={size}\n __staticSelector=\"TreeSelect\"\n disabled={disabled}\n readOnly={readOnly || !searchable}\n value={searchable ? _searchValue : singleDisplayLabel}\n onChange={(event) => {\n if (isExternalInputChange(event)) {\n return;\n }\n\n handleSearchChange(event.currentTarget.value);\n combobox.openDropdown();\n }}\n onFocus={(event) => {\n if (openOnFocus && searchable) {\n combobox.openDropdown();\n }\n onFocus?.(event);\n }}\n onBlur={(event) => {\n if (searchable) {\n combobox.closeDropdown();\n }\n handleSearchChange(_value ? getNodeLabel(_value as string) : '');\n onBlur?.(event);\n }}\n onClick={(event) => {\n searchable ? combobox.openDropdown() : combobox.toggleDropdown();\n onClick?.(event);\n }}\n onKeyDown={handleKeyDown}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n pointer={!searchable}\n error={error}\n success={success}\n attributes={attributes}\n className={className}\n style={style}\n variant={variant}\n radius={radius}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n successProps={successProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n withErrorStyles={withErrorStyles}\n withSuccessStyles={withSuccessStyles}\n placeholder={placeholder}\n required={required}\n mod={mod}\n />\n </Combobox.Target>\n {dropdown}\n </Combobox>\n <Combobox.HiddenInput\n value={_value}\n name={name}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nTreeSelect.classes = { ...InputBase.classes, ...Combobox.classes };\nTreeSelect.displayName = '@mantine/core/TreeSelect';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6MA,MAAM,eAAe;CACnB,MAAM;CACN,eAAe;CACf,iBAAiB;CACjB,WAAW;CACX,0BAA0B;CAC1B,qBAAqB;CACrB,aAAa;CACb,MAAM;CACN,WAAW;AACb;AAEA,MAAM,qBAA6C;CACjD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,mBAAmB,OAAe,OAAwC;CACjF,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,KAAK,UAAU,OAC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EACI;EACV,GAAI;CACL,CAAA,CACD,EAAA,CAAA;AAEN,CAAC;AAED,WAAW,UAAU;CAAE,GAAGQ,kBAAAA,UAAU;CAAS,GAAGR,iBAAAA,SAAS;AAAQ;AACjE,WAAW,cAAc"}
|
|
@@ -9,6 +9,7 @@ import { InputBase } from "../InputBase/InputBase.mjs";
|
|
|
9
9
|
import { useCombobox } from "../Combobox/use-combobox/use-combobox.mjs";
|
|
10
10
|
import { Combobox } from "../Combobox/Combobox.mjs";
|
|
11
11
|
import { CheckIcon } from "../Checkbox/CheckIcon.mjs";
|
|
12
|
+
import { isExternalInputChange } from "../Combobox/is-external-input-change/is-external-input-change.mjs";
|
|
12
13
|
import { CascaderColumns } from "./CascaderColumns.mjs";
|
|
13
14
|
import { flattenCascaderPaths } from "./flatten-cascader-paths.mjs";
|
|
14
15
|
import { getCascaderPathOptions } from "./get-cascader-path-options.mjs";
|
|
@@ -20,6 +21,7 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
|
20
21
|
//#region packages/@mantine/core/src/components/Cascader/Cascader.tsx
|
|
21
22
|
const defaultProps = {
|
|
22
23
|
expandTrigger: "click",
|
|
24
|
+
safeAreaPolygon: true,
|
|
23
25
|
changeOnSelect: false,
|
|
24
26
|
allowDeselect: true,
|
|
25
27
|
withCheckIcon: true,
|
|
@@ -68,7 +70,7 @@ const Cascader = factory((_props) => {
|
|
|
68
70
|
"InputWrapper",
|
|
69
71
|
"Cascader"
|
|
70
72
|
], defaultProps, _props);
|
|
71
|
-
const { classNames, className, style, styles, unstyled, vars, size, data, value, defaultValue, onChange, changeOnSelect, closeOnSelect, allowDeselect, withCheckIcon, checkIconPosition, withColumns, expandTrigger, searchable, searchValue, defaultSearchValue, onSearchChange, filter, renderSearchOption, formatValue, renderOption, separator, columnWidth, maxDisplayedLevels, previousLevelsControlLabel, nextLevelsControlLabel, maxDropdownHeight, nothingFoundMessage, clearable, clearSectionMode, clearButtonProps, onClear, dropdownOpened, defaultDropdownOpened, onDropdownOpen, onDropdownClose, comboboxProps, scrollAreaProps, chevronColor, hiddenInputProps, openOnFocus, variant, onKeyDown, onFocus, onBlur, onClick, readOnly, disabled, radius, rightSection, rightSectionWidth, rightSectionPointerEvents, rightSectionProps, leftSection, leftSectionWidth, leftSectionPointerEvents, leftSectionProps, inputContainer, inputWrapperOrder, withAsterisk, labelProps, descriptionProps, errorProps, successProps, wrapperProps, description, label, error, success, withErrorStyles, withSuccessStyles, name, form, id, placeholder, required, mod, attributes, ...others } = props;
|
|
73
|
+
const { classNames, className, style, styles, unstyled, vars, size, data, value, defaultValue, onChange, changeOnSelect, closeOnSelect, allowDeselect, withCheckIcon, checkIconPosition, withColumns, expandTrigger, safeAreaPolygon, searchable, searchValue, defaultSearchValue, onSearchChange, filter, renderSearchOption, formatValue, renderOption, separator, columnWidth, maxDisplayedLevels, previousLevelsControlLabel, nextLevelsControlLabel, maxDropdownHeight, nothingFoundMessage, clearable, clearSectionMode, clearButtonProps, onClear, dropdownOpened, defaultDropdownOpened, onDropdownOpen, onDropdownClose, comboboxProps, scrollAreaProps, chevronColor, hiddenInputProps, openOnFocus, variant, onKeyDown, onFocus, onBlur, onClick, readOnly, disabled, radius, rightSection, rightSectionWidth, rightSectionPointerEvents, rightSectionProps, leftSection, leftSectionWidth, leftSectionPointerEvents, leftSectionProps, inputContainer, inputWrapperOrder, withAsterisk, labelProps, descriptionProps, errorProps, successProps, wrapperProps, description, label, error, success, withErrorStyles, withSuccessStyles, name, form, id, placeholder, required, mod, attributes, ...others } = props;
|
|
72
74
|
const _id = useId$1(id);
|
|
73
75
|
const separatorString = typeof separator === "string" || typeof separator === "number" ? String(separator) : "/";
|
|
74
76
|
const combobox = useCombobox({
|
|
@@ -252,7 +254,8 @@ const Cascader = factory((_props) => {
|
|
|
252
254
|
if (expandTrigger === "hover") cascader.setActivePath(cascader.value ?? []);
|
|
253
255
|
},
|
|
254
256
|
onPointerActivity: () => cascader.setKeyboardNav(false),
|
|
255
|
-
listId
|
|
257
|
+
listId,
|
|
258
|
+
safeAreaPolygon: expandTrigger === "hover" ? safeAreaPolygon : false
|
|
256
259
|
})
|
|
257
260
|
});
|
|
258
261
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Combobox, {
|
|
@@ -299,7 +302,10 @@ const Cascader = factory((_props) => {
|
|
|
299
302
|
disabled,
|
|
300
303
|
readOnly: readOnly || !searchable,
|
|
301
304
|
value: searchable ? _searchValue : displayString,
|
|
302
|
-
onChange: (event) =>
|
|
305
|
+
onChange: (event) => {
|
|
306
|
+
if (isExternalInputChange(event)) return;
|
|
307
|
+
handleSearchChange(event.currentTarget.value);
|
|
308
|
+
},
|
|
303
309
|
onFocus: (event) => {
|
|
304
310
|
if (openOnFocus && searchable && canInteract) combobox.openDropdown();
|
|
305
311
|
onFocus?.(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cascader.mjs","names":["useId","classes"],"sources":["../../../src/components/Cascader/Cascader.tsx"],"sourcesContent":["import { Fragment, useEffect, useMemo } from 'react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n factory,\n MantineColor,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { CheckIcon } from '../Checkbox/CheckIcon';\nimport { Combobox, ComboboxLikeStylesNames, useCombobox } from '../Combobox';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { ScrollArea, ScrollAreaProps } from '../ScrollArea';\nimport { CascaderColumns } from './CascaderColumns';\nimport { flattenCascaderPaths } from './flatten-cascader-paths';\nimport { getCascaderPathOptions } from './get-cascader-path-options';\nimport { useCascader } from './use-cascader';\nimport classes from './Cascader.module.css';\n\nexport interface CascaderOption {\n /** Option value, must be unique across the whole data tree */\n value: string;\n\n /** Option label, if not set `value` is used instead */\n label?: React.ReactNode;\n\n /** Nested options */\n children?: CascaderOption[];\n\n /** If set, the option cannot be selected or expanded */\n disabled?: boolean;\n}\n\nexport interface CascaderFormatValueInput {\n /** Selected path from root to node */\n value: string[];\n\n /** Option chain resolved from the selected path */\n options: CascaderOption[];\n}\n\nexport type CascaderFormatValue = (input: CascaderFormatValueInput) => React.ReactNode;\n\nexport type CascaderStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'columnsList'\n | 'columnsOverflow'\n | 'column'\n | 'columnScroll'\n | 'columnOption'\n | 'columnOptionLabel'\n | 'columnOptionIcon'\n | 'columnOptionCheck'\n | 'columnEmpty'\n | 'flatOption';\n\nexport interface CascaderProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<CascaderFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Hierarchical options data */\n data: CascaderOption[];\n\n /** Controlled selected path from root to node */\n value?: string[] | null;\n\n /** Uncontrolled selected path from root to node */\n defaultValue?: string[] | null;\n\n /** Called when the selected path changes with the path and the resolved option chain */\n onChange?: (value: string[] | null, options: CascaderOption[]) => void;\n\n /** If set, any intermediate option can be selected, not only leaf options @default false */\n changeOnSelect?: boolean;\n\n /** Determines whether the dropdown should be closed when a value is selected, defaults to `!allowDeselect` */\n closeOnSelect?: boolean;\n\n /** If set, the selected value can be deselected by selecting it again @default true */\n allowDeselect?: boolean;\n\n /** If set, the check icon is displayed on the selected option @default true */\n withCheckIcon?: boolean;\n\n /** Position of the check icon relative to the option label @default 'right' */\n checkIconPosition?: 'left' | 'right';\n\n /** Renders the dropdown as cascading columns. When `false`, options are rendered as a flat list of paths, the same way as search results (useful for narrow/mobile layouts) @default true */\n withColumns?: boolean;\n\n /** Determines how the next column is opened @default 'click' */\n expandTrigger?: 'click' | 'hover';\n\n /** If set, options can be searched by their flattened paths @default false */\n searchable?: boolean;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Uncontrolled search value */\n defaultSearchValue?: string;\n\n /** Called when the search value changes */\n onSearchChange?: (value: string) => void;\n\n /** Custom search filter, matched against the full option path */\n filter?: (query: string, options: CascaderOption[]) => boolean;\n\n /** Custom rendering of a search result row */\n renderSearchOption?: (query: string, options: CascaderOption[]) => React.ReactNode;\n\n /** A function to format the selected path displayed in the input, should return a string */\n formatValue?: CascaderFormatValue;\n\n /** Custom rendering of an option in columns */\n renderOption?: (option: CascaderOption, level: number) => React.ReactNode;\n\n /** Path separator displayed in the input and search results @default '/' */\n separator?: React.ReactNode;\n\n /** Width of each column */\n columnWidth?: number | string;\n\n /** Maximum number of columns (levels) displayed next to each other, deeper levels replace earlier ones @default 3 */\n maxDisplayedLevels?: number;\n\n /** `aria-label` and `title` of the control that reveals levels hidden before the visible ones by `maxDisplayedLevels` @default 'Show previous levels' */\n previousLevelsControlLabel?: string;\n\n /** `aria-label` and `title` of the control that reveals levels hidden after the visible ones by `maxDisplayedLevels` @default 'Show next levels' */\n nextLevelsControlLabel?: string;\n\n /** Max height of a column before it becomes scrollable @default 260 */\n maxDropdownHeight?: number | string;\n\n /** Message displayed when there are no options or search results */\n nothingFoundMessage?: React.ReactNode;\n\n /** If set, the clear button is displayed when a value is selected @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and `rightSection` are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Controlled dropdown opened state */\n dropdownOpened?: boolean;\n\n /** Uncontrolled dropdown opened state */\n defaultDropdownOpened?: boolean;\n\n /** Called when the dropdown opens */\n onDropdownOpen?: () => void;\n\n /** Called when the dropdown closes */\n onDropdownClose?: () => void;\n\n /** Props passed down to the underlying `Combobox` component */\n comboboxProps?: Record<string, any>;\n\n /** Props passed down to the dropdown `ScrollArea` */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls the default chevron color */\n chevronColor?: MantineColor;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Opens the dropdown when the input is focused in `searchable` mode @default true */\n openOnFocus?: boolean;\n}\n\nexport type CascaderFactory = Factory<{\n props: CascaderProps;\n ref: HTMLInputElement;\n stylesNames: CascaderStylesNames;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n expandTrigger: 'click',\n changeOnSelect: false,\n allowDeselect: true,\n withCheckIcon: true,\n checkIconPosition: 'right',\n withColumns: true,\n searchable: false,\n separator: '/',\n maxDisplayedLevels: 3,\n previousLevelsControlLabel: 'Show previous levels',\n nextLevelsControlLabel: 'Show next levels',\n maxDropdownHeight: 260,\n openOnFocus: true,\n size: 'sm',\n} satisfies Partial<CascaderProps>;\n\nfunction optionLabelToString(option: CascaderOption): string {\n return typeof option.label === 'string' || typeof option.label === 'number'\n ? String(option.label)\n : option.value;\n}\n\nfunction firstEnabledOptionIndex(options: CascaderOption[]): number {\n return options.findIndex((option) => !option.disabled);\n}\n\nfunction lastEnabledOptionIndex(options: CascaderOption[]): number {\n for (let index = options.length - 1; index >= 0; index -= 1) {\n if (!options[index].disabled) {\n return index;\n }\n }\n return -1;\n}\n\nfunction joinPathLabels(options: CascaderOption[], separator: string): string {\n return options.map(optionLabelToString).join(` ${separator} `);\n}\n\nfunction defaultCascaderFilter(\n query: string,\n options: CascaderOption[],\n separator: string\n): boolean {\n const trimmed = query.trim().toLowerCase();\n if (trimmed.length === 0) {\n return true;\n }\n return joinPathLabels(options, separator).toLowerCase().includes(trimmed);\n}\n\nfunction defaultRenderSearchOption(\n options: CascaderOption[],\n separator: React.ReactNode\n): React.ReactNode {\n return options.map((option, index) => (\n <Fragment key={option.value}>\n {index > 0 && <span data-cascader-separator> {separator} </span>}\n {option.label ?? option.value}\n </Fragment>\n ));\n}\n\nexport const Cascader = factory<CascaderFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'Cascader'], defaultProps as any, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n data,\n value,\n defaultValue,\n onChange,\n changeOnSelect,\n closeOnSelect,\n allowDeselect,\n withCheckIcon,\n checkIconPosition,\n withColumns,\n expandTrigger,\n searchable,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n filter,\n renderSearchOption,\n formatValue,\n renderOption,\n separator,\n columnWidth,\n maxDisplayedLevels,\n previousLevelsControlLabel,\n nextLevelsControlLabel,\n maxDropdownHeight,\n nothingFoundMessage,\n clearable,\n clearSectionMode,\n clearButtonProps,\n onClear,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n comboboxProps,\n scrollAreaProps,\n chevronColor,\n hiddenInputProps,\n openOnFocus,\n variant,\n onKeyDown,\n onFocus,\n onBlur,\n onClick,\n readOnly,\n disabled,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n labelProps,\n descriptionProps,\n errorProps,\n successProps,\n wrapperProps,\n description,\n label,\n error,\n success,\n withErrorStyles,\n withSuccessStyles,\n name,\n form,\n id,\n placeholder,\n required,\n mod,\n attributes,\n ...others\n } = props;\n\n const _id = useId(id);\n const separatorString =\n typeof separator === 'string' || typeof separator === 'number' ? String(separator) : '/';\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n cascader.resetActivePath();\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n if (searchable) {\n setSearchValue(cascader.value ? displayString : '');\n }\n },\n });\n\n // When `allowDeselect` is enabled, keep the dropdown open by default so the value can be toggled\n const shouldCloseOnSelect = closeOnSelect ?? !allowDeselect;\n\n const cascader = useCascader({\n data,\n value,\n defaultValue,\n onChange,\n changeOnSelect,\n allowDeselect,\n expandTrigger,\n onLeafSelect: () => {\n if (shouldCloseOnSelect) {\n combobox.closeDropdown();\n }\n },\n });\n\n const getStyles = useStyles<CascaderFactory>({\n name: 'Cascader',\n classes,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<CascaderFactory>({\n props,\n styles,\n classNames,\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const displayString = useMemo(() => {\n if (cascader.pathOptions.length === 0 || !cascader.value) {\n return '';\n }\n if (formatValue) {\n const rendered = formatValue({ value: cascader.value, options: cascader.pathOptions });\n if (typeof rendered === 'string' || typeof rendered === 'number') {\n return String(rendered);\n }\n }\n return joinPathLabels(cascader.pathOptions, separatorString);\n }, [cascader.pathOptions, cascader.value, formatValue, separatorString]);\n\n const initialSearchValue = useMemo(() => {\n if (!searchable || !defaultValue) {\n return '';\n }\n return joinPathLabels(getCascaderPathOptions(data, defaultValue), separatorString);\n }, []);\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: initialSearchValue,\n onChange: onSearchChange,\n });\n\n const isSearching =\n !!searchable && _searchValue.trim().length > 0 && _searchValue !== displayString;\n\n useEffect(() => {\n if (searchable) {\n setSearchValue(cascader.value ? displayString : '');\n }\n }, [cascader.value]);\n\n // The dropdown renders a flat list of paths when searching or when `withColumns` is disabled\n const showFlatList = isSearching || !withColumns;\n\n const flatPaths = useMemo(() => flattenCascaderPaths(data), [data]);\n\n const flatListItems = useMemo(() => {\n if (!showFlatList) {\n return [];\n }\n const base = flatPaths.filter((flatPath) => (changeOnSelect ? true : flatPath.leaf));\n if (!isSearching) {\n return base;\n }\n return base.filter((flatPath) =>\n filter\n ? filter(_searchValue, flatPath.options)\n : defaultCascaderFilter(_searchValue, flatPath.options, separatorString)\n );\n }, [flatPaths, showFlatList, isSearching, _searchValue, changeOnSelect, filter, separatorString]);\n\n const canInteract = !readOnly && !disabled;\n\n const handleSearchChange = (nextValue: string) => {\n setSearchValue(nextValue);\n if (canInteract) {\n combobox.openDropdown();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.key === 'Escape') {\n combobox.closeDropdown();\n return;\n }\n\n if (showFlatList || !canInteract) {\n return;\n }\n\n if (!combobox.dropdownOpened) {\n const opensDropdown =\n event.key === 'ArrowDown' ||\n event.key === 'ArrowUp' ||\n event.key === 'ArrowRight' ||\n event.key === 'Enter' ||\n (!searchable && event.key === ' ');\n\n if (opensDropdown) {\n event.preventDefault();\n cascader.setKeyboardNav(true);\n combobox.openDropdown();\n\n if (!cascader.value && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n const rootIndex =\n event.key === 'ArrowDown'\n ? firstEnabledOptionIndex(data)\n : lastEnabledOptionIndex(data);\n if (rootIndex >= 0) {\n cascader.setActivePath([data[rootIndex].value]);\n }\n }\n }\n return;\n }\n\n if (cascader.handleColumnsKeyDown(event)) {\n event.preventDefault();\n } else if (!searchable && event.key === ' ') {\n event.preventDefault();\n }\n };\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n cascader.setValue(null);\n cascader.setActivePath([]);\n setSearchValue('');\n combobox.focusTarget();\n }}\n />\n );\n\n const hasValue = Array.isArray(cascader.value) && cascader.value.length > 0;\n const _clearable = clearable && hasValue && !disabled && !readOnly;\n\n const listId = _id ? `${_id}-cascader-list` : undefined;\n const valueKey = cascader.value ? JSON.stringify(cascader.value) : null;\n\n const dropdown = (\n <Combobox.Dropdown\n hidden={readOnly || disabled}\n style={showFlatList ? undefined : { padding: 0 }}\n >\n {showFlatList ? (\n <Combobox.Options aria-label={typeof label === 'string' ? label : undefined}>\n <ScrollArea.Autosize\n mah={maxDropdownHeight ?? 260}\n type=\"scroll\"\n scrollbarSize=\"var(--combobox-padding)\"\n offsetScrollbars=\"y\"\n {...scrollAreaProps}\n >\n {flatListItems.map((flatPath, index) => {\n const pathKey = JSON.stringify(flatPath.path);\n const active = valueKey !== null && pathKey === valueKey;\n return (\n <Combobox.Option\n key={pathKey}\n value={`${index}`}\n active={active}\n disabled={flatPath.disabled}\n >\n <span {...getStyles('flatOption')}>\n {active && withCheckIcon && checkIconPosition === 'left' && (\n <CheckIcon {...getStyles('columnOptionCheck')} />\n )}\n <span {...getStyles('columnOptionLabel')}>\n {renderSearchOption\n ? renderSearchOption(_searchValue, flatPath.options)\n : defaultRenderSearchOption(flatPath.options, separator)}\n </span>\n {active && withCheckIcon && checkIconPosition !== 'left' && (\n <CheckIcon {...getStyles('columnOptionCheck')} />\n )}\n </span>\n </Combobox.Option>\n );\n })}\n </ScrollArea.Autosize>\n {flatListItems.length === 0 && nothingFoundMessage && (\n <Combobox.Empty>{nothingFoundMessage}</Combobox.Empty>\n )}\n </Combobox.Options>\n ) : (\n <CascaderColumns\n data={data}\n activePath={cascader.activePath}\n value={cascader.value}\n keyboardNav={cascader.keyboardNav}\n withCheckIcon={withCheckIcon}\n checkIconPosition={checkIconPosition}\n renderOption={renderOption}\n columnWidth={columnWidth}\n maxDisplayedLevels={maxDisplayedLevels}\n previousLevelsControlLabel={previousLevelsControlLabel}\n nextLevelsControlLabel={nextLevelsControlLabel}\n maxDropdownHeight={maxDropdownHeight}\n nothingFoundMessage={nothingFoundMessage}\n getStyles={getStyles}\n unstyled={unstyled}\n scrollAreaProps={scrollAreaProps}\n onOptionClick={cascader.handleOptionClick}\n onOptionMouseEnter={cascader.handleOptionMouseEnter}\n onColumnsMouseLeave={() => {\n if (expandTrigger === 'hover') {\n cascader.setActivePath(cascader.value ?? []);\n }\n }}\n onPointerActivity={() => cascader.setKeyboardNav(false)}\n listId={listId}\n />\n )}\n </Combobox.Dropdown>\n );\n\n return (\n <>\n <Combobox\n store={combobox}\n __staticSelector=\"Cascader\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n width={showFlatList ? 'target' : 'max-content'}\n position=\"bottom-start\"\n onOptionSubmit={(val) => {\n const index = Number(val);\n const flatPath = flatListItems[index];\n if (!flatPath || flatPath.disabled) {\n return;\n }\n cascader.selectPath(flatPath.path);\n cascader.setActivePath(flatPath.path);\n if (shouldCloseOnSelect) {\n combobox.closeDropdown();\n }\n }}\n {...comboboxProps}\n >\n <Combobox.Target\n targetType={searchable ? 'input' : 'button'}\n withKeyboardNavigation={showFlatList}\n autoComplete={autoComplete}\n >\n <InputBase\n id={_id}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n {...rest}\n {...styleProps}\n size={size}\n __staticSelector=\"Cascader\"\n disabled={disabled}\n readOnly={readOnly || !searchable}\n value={searchable ? _searchValue : displayString}\n onChange={(event) => handleSearchChange(event.currentTarget.value)}\n onFocus={(event) => {\n if (openOnFocus && searchable && canInteract) {\n combobox.openDropdown();\n }\n onFocus?.(event);\n }}\n onBlur={(event) => {\n combobox.closeDropdown();\n onBlur?.(event);\n }}\n onClick={(event) => {\n if (canInteract) {\n cascader.setKeyboardNav(false);\n if (searchable) {\n combobox.openDropdown();\n } else {\n combobox.toggleDropdown();\n }\n }\n onClick?.(event);\n }}\n onKeyDown={handleKeyDown}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n pointer={!searchable}\n error={error}\n success={success}\n attributes={attributes}\n className={className}\n style={style}\n variant={variant}\n radius={radius}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n successProps={successProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n withErrorStyles={withErrorStyles}\n withSuccessStyles={withSuccessStyles}\n placeholder={placeholder}\n required={required}\n mod={mod}\n />\n </Combobox.Target>\n {dropdown}\n </Combobox>\n <Combobox.HiddenInput\n value={cascader.value}\n name={name}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nCascader.classes = { ...InputBase.classes, ...Combobox.classes, ...classes };\nCascader.displayName = '@mantine/core/Cascader';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwMA,MAAM,eAAe;CACnB,eAAe;CACf,gBAAgB;CAChB,eAAe;CACf,eAAe;CACf,mBAAmB;CACnB,aAAa;CACb,YAAY;CACZ,WAAW;CACX,oBAAoB;CACpB,4BAA4B;CAC5B,wBAAwB;CACxB,mBAAmB;CACnB,aAAa;CACb,MAAM;AACR;AAEA,SAAS,oBAAoB,QAAgC;CAC3D,OAAO,OAAO,OAAO,UAAU,YAAY,OAAO,OAAO,UAAU,WAC/D,OAAO,OAAO,KAAK,IACnB,OAAO;AACb;AAEA,SAAS,wBAAwB,SAAmC;CAClE,OAAO,QAAQ,WAAW,WAAW,CAAC,OAAO,QAAQ;AACvD;AAEA,SAAS,uBAAuB,SAAmC;CACjE,KAAK,IAAI,QAAQ,QAAQ,SAAS,GAAG,SAAS,GAAG,SAAS,GACxD,IAAI,CAAC,QAAQ,MAAM,CAAC,UAClB,OAAO;CAGX,OAAO;AACT;AAEA,SAAS,eAAe,SAA2B,WAA2B;CAC5E,OAAO,QAAQ,IAAI,mBAAmB,CAAC,CAAC,KAAK,IAAI,UAAU,EAAE;AAC/D;AAEA,SAAS,sBACP,OACA,SACA,WACS;CACT,MAAM,UAAU,MAAM,KAAK,CAAC,CAAC,YAAY;CACzC,IAAI,QAAQ,WAAW,GACrB,OAAO;CAET,OAAO,eAAe,SAAS,SAAS,CAAC,CAAC,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AAe,KAAK;MAC7B,IAAI,YACF,SAAS,aAAa;WAEtB,SAAS,eAAe;KAE5B;KACA,UAAU,KAAK;IACjB;IACA,WAAW;IACX,YAAY;IACZ,QAAQ;IACE;IACV,SAAS,CAAC;IACH;IACE;IACG;IACD;IACJ;IACE;IACD;IACK;IACK;IACQ;IACR;IACC;IACA;IACH;IACG;IACL;IACF;IACM;IACN;IACE;IACA;IACD;IACN;IACU;IACE;IACN;IACH;IACL;GACN,CAAA;EACc,CAAA,GAChB,QACO;KACV,oBAAC,SAAS,aAAV;EACE,OAAO,SAAS;EACV;EACA;EACI;EACV,GAAI;CACL,CAAA,CACD,EAAA,CAAA;AAEN,CAAC;AAED,SAAS,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS,GAAGC;AAAQ;AAC3E,SAAS,cAAc"}
|
|
1
|
+
{"version":3,"file":"Cascader.mjs","names":["useId","classes"],"sources":["../../../src/components/Cascader/Cascader.tsx"],"sourcesContent":["import { Fragment, useEffect, useMemo } from 'react';\nimport type { SafePolygonOptions } from '@floating-ui/react';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n ElementProps,\n extractStyleProps,\n Factory,\n factory,\n MantineColor,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { CheckIcon } from '../Checkbox/CheckIcon';\nimport { Combobox, ComboboxLikeStylesNames, useCombobox } from '../Combobox';\nimport { isExternalInputChange } from '../Combobox/is-external-input-change/is-external-input-change';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n ClearSectionMode,\n InputClearButtonProps,\n InputVariant,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { ScrollArea, ScrollAreaProps } from '../ScrollArea';\nimport { CascaderColumns } from './CascaderColumns';\nimport { flattenCascaderPaths } from './flatten-cascader-paths';\nimport { getCascaderPathOptions } from './get-cascader-path-options';\nimport { useCascader } from './use-cascader';\nimport classes from './Cascader.module.css';\n\nexport interface CascaderOption {\n /** Option value, must be unique across the whole data tree */\n value: string;\n\n /** Option label, if not set `value` is used instead */\n label?: React.ReactNode;\n\n /** Nested options */\n children?: CascaderOption[];\n\n /** If set, the option cannot be selected or expanded */\n disabled?: boolean;\n}\n\nexport interface CascaderFormatValueInput {\n /** Selected path from root to node */\n value: string[];\n\n /** Option chain resolved from the selected path */\n options: CascaderOption[];\n}\n\nexport type CascaderFormatValue = (input: CascaderFormatValueInput) => React.ReactNode;\n\nexport type CascaderSafeAreaPolygonOptions = Omit<SafePolygonOptions, 'blockPointerEvents'>;\n\nexport type CascaderStylesNames =\n | __InputStylesNames\n | ComboboxLikeStylesNames\n | 'columnsList'\n | 'columnsOverflow'\n | 'column'\n | 'columnScroll'\n | 'columnOption'\n | 'columnOptionLabel'\n | 'columnOptionIcon'\n | 'columnOptionCheck'\n | 'columnEmpty'\n | 'flatOption';\n\nexport interface CascaderProps\n extends\n BoxProps,\n __BaseInputProps,\n StylesApiProps<CascaderFactory>,\n ElementProps<'input', 'size' | 'value' | 'defaultValue' | 'onChange'> {\n /** Hierarchical options data */\n data: CascaderOption[];\n\n /** Controlled selected path from root to node */\n value?: string[] | null;\n\n /** Uncontrolled selected path from root to node */\n defaultValue?: string[] | null;\n\n /** Called when the selected path changes with the path and the resolved option chain */\n onChange?: (value: string[] | null, options: CascaderOption[]) => void;\n\n /** If set, any intermediate option can be selected, not only leaf options @default false */\n changeOnSelect?: boolean;\n\n /** Determines whether the dropdown should be closed when a value is selected, defaults to `!allowDeselect` */\n closeOnSelect?: boolean;\n\n /** If set, the selected value can be deselected by selecting it again @default true */\n allowDeselect?: boolean;\n\n /** If set, the check icon is displayed on the selected option @default true */\n withCheckIcon?: boolean;\n\n /** Position of the check icon relative to the option label @default 'right' */\n checkIconPosition?: 'left' | 'right';\n\n /** Renders the dropdown as cascading columns. When `false`, options are rendered as a flat list of paths, the same way as search results (useful for narrow/mobile layouts) @default true */\n withColumns?: boolean;\n\n /** Determines how the next column is opened @default 'click' */\n expandTrigger?: 'click' | 'hover';\n\n /** Determines whether the next column stays open while the cursor moves toward it, applicable only when `expandTrigger=\"hover\"`. Pass an object to configure safe polygon behavior. @default true */\n safeAreaPolygon?: boolean | CascaderSafeAreaPolygonOptions;\n\n /** If set, options can be searched by their flattened paths @default false */\n searchable?: boolean;\n\n /** Controlled search value */\n searchValue?: string;\n\n /** Uncontrolled search value */\n defaultSearchValue?: string;\n\n /** Called when the search value changes */\n onSearchChange?: (value: string) => void;\n\n /** Custom search filter, matched against the full option path */\n filter?: (query: string, options: CascaderOption[]) => boolean;\n\n /** Custom rendering of a search result row */\n renderSearchOption?: (query: string, options: CascaderOption[]) => React.ReactNode;\n\n /** A function to format the selected path displayed in the input, should return a string */\n formatValue?: CascaderFormatValue;\n\n /** Custom rendering of an option in columns */\n renderOption?: (option: CascaderOption, level: number) => React.ReactNode;\n\n /** Path separator displayed in the input and search results @default '/' */\n separator?: React.ReactNode;\n\n /** Width of each column */\n columnWidth?: number | string;\n\n /** Maximum number of columns (levels) displayed next to each other, deeper levels replace earlier ones @default 3 */\n maxDisplayedLevels?: number;\n\n /** `aria-label` and `title` of the control that reveals levels hidden before the visible ones by `maxDisplayedLevels` @default 'Show previous levels' */\n previousLevelsControlLabel?: string;\n\n /** `aria-label` and `title` of the control that reveals levels hidden after the visible ones by `maxDisplayedLevels` @default 'Show next levels' */\n nextLevelsControlLabel?: string;\n\n /** Max height of a column before it becomes scrollable @default 260 */\n maxDropdownHeight?: number | string;\n\n /** Message displayed when there are no options or search results */\n nothingFoundMessage?: React.ReactNode;\n\n /** If set, the clear button is displayed when a value is selected @default false */\n clearable?: boolean;\n\n /** Determines how the clear button and `rightSection` are rendered @default 'both' */\n clearSectionMode?: ClearSectionMode;\n\n /** Props passed down to the clear button */\n clearButtonProps?: InputClearButtonProps;\n\n /** Called when the clear button is clicked */\n onClear?: () => void;\n\n /** Controlled dropdown opened state */\n dropdownOpened?: boolean;\n\n /** Uncontrolled dropdown opened state */\n defaultDropdownOpened?: boolean;\n\n /** Called when the dropdown opens */\n onDropdownOpen?: () => void;\n\n /** Called when the dropdown closes */\n onDropdownClose?: () => void;\n\n /** Props passed down to the underlying `Combobox` component */\n comboboxProps?: Record<string, any>;\n\n /** Props passed down to the dropdown `ScrollArea` */\n scrollAreaProps?: ScrollAreaProps;\n\n /** Controls the default chevron color */\n chevronColor?: MantineColor;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: Omit<React.ComponentProps<'input'>, 'value'>;\n\n /** Opens the dropdown when the input is focused in `searchable` mode @default true */\n openOnFocus?: boolean;\n}\n\nexport type CascaderFactory = Factory<{\n props: CascaderProps;\n ref: HTMLInputElement;\n stylesNames: CascaderStylesNames;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n expandTrigger: 'click',\n safeAreaPolygon: true,\n changeOnSelect: false,\n allowDeselect: true,\n withCheckIcon: true,\n checkIconPosition: 'right',\n withColumns: true,\n searchable: false,\n separator: '/',\n maxDisplayedLevels: 3,\n previousLevelsControlLabel: 'Show previous levels',\n nextLevelsControlLabel: 'Show next levels',\n maxDropdownHeight: 260,\n openOnFocus: true,\n size: 'sm',\n} satisfies Partial<CascaderProps>;\n\nfunction optionLabelToString(option: CascaderOption): string {\n return typeof option.label === 'string' || typeof option.label === 'number'\n ? String(option.label)\n : option.value;\n}\n\nfunction firstEnabledOptionIndex(options: CascaderOption[]): number {\n return options.findIndex((option) => !option.disabled);\n}\n\nfunction lastEnabledOptionIndex(options: CascaderOption[]): number {\n for (let index = options.length - 1; index >= 0; index -= 1) {\n if (!options[index].disabled) {\n return index;\n }\n }\n return -1;\n}\n\nfunction joinPathLabels(options: CascaderOption[], separator: string): string {\n return options.map(optionLabelToString).join(` ${separator} `);\n}\n\nfunction defaultCascaderFilter(\n query: string,\n options: CascaderOption[],\n separator: string\n): boolean {\n const trimmed = query.trim().toLowerCase();\n if (trimmed.length === 0) {\n return true;\n }\n return joinPathLabels(options, separator).toLowerCase().includes(trimmed);\n}\n\nfunction defaultRenderSearchOption(\n options: CascaderOption[],\n separator: React.ReactNode\n): React.ReactNode {\n return options.map((option, index) => (\n <Fragment key={option.value}>\n {index > 0 && <span data-cascader-separator> {separator} </span>}\n {option.label ?? option.value}\n </Fragment>\n ));\n}\n\nexport const Cascader = factory<CascaderFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'Cascader'], defaultProps as any, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n data,\n value,\n defaultValue,\n onChange,\n changeOnSelect,\n closeOnSelect,\n allowDeselect,\n withCheckIcon,\n checkIconPosition,\n withColumns,\n expandTrigger,\n safeAreaPolygon,\n searchable,\n searchValue,\n defaultSearchValue,\n onSearchChange,\n filter,\n renderSearchOption,\n formatValue,\n renderOption,\n separator,\n columnWidth,\n maxDisplayedLevels,\n previousLevelsControlLabel,\n nextLevelsControlLabel,\n maxDropdownHeight,\n nothingFoundMessage,\n clearable,\n clearSectionMode,\n clearButtonProps,\n onClear,\n dropdownOpened,\n defaultDropdownOpened,\n onDropdownOpen,\n onDropdownClose,\n comboboxProps,\n scrollAreaProps,\n chevronColor,\n hiddenInputProps,\n openOnFocus,\n variant,\n onKeyDown,\n onFocus,\n onBlur,\n onClick,\n readOnly,\n disabled,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n rightSectionProps,\n leftSection,\n leftSectionWidth,\n leftSectionPointerEvents,\n leftSectionProps,\n inputContainer,\n inputWrapperOrder,\n withAsterisk,\n labelProps,\n descriptionProps,\n errorProps,\n successProps,\n wrapperProps,\n description,\n label,\n error,\n success,\n withErrorStyles,\n withSuccessStyles,\n name,\n form,\n id,\n placeholder,\n required,\n mod,\n attributes,\n ...others\n } = props;\n\n const _id = useId(id);\n const separatorString =\n typeof separator === 'string' || typeof separator === 'number' ? String(separator) : '/';\n\n const combobox = useCombobox({\n opened: dropdownOpened,\n defaultOpened: defaultDropdownOpened,\n onDropdownOpen: () => {\n onDropdownOpen?.();\n cascader.resetActivePath();\n },\n onDropdownClose: () => {\n onDropdownClose?.();\n if (searchable) {\n setSearchValue(cascader.value ? displayString : '');\n }\n },\n });\n\n // When `allowDeselect` is enabled, keep the dropdown open by default so the value can be toggled\n const shouldCloseOnSelect = closeOnSelect ?? !allowDeselect;\n\n const cascader = useCascader({\n data,\n value,\n defaultValue,\n onChange,\n changeOnSelect,\n allowDeselect,\n expandTrigger,\n onLeafSelect: () => {\n if (shouldCloseOnSelect) {\n combobox.closeDropdown();\n }\n },\n });\n\n const getStyles = useStyles<CascaderFactory>({\n name: 'Cascader',\n classes,\n props: props as any,\n classNames,\n styles,\n unstyled,\n attributes,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<CascaderFactory>({\n props,\n styles,\n classNames,\n });\n\n const {\n styleProps,\n rest: { type, autoComplete, ...rest },\n } = extractStyleProps(others);\n\n const displayString = useMemo(() => {\n if (cascader.pathOptions.length === 0 || !cascader.value) {\n return '';\n }\n if (formatValue) {\n const rendered = formatValue({ value: cascader.value, options: cascader.pathOptions });\n if (typeof rendered === 'string' || typeof rendered === 'number') {\n return String(rendered);\n }\n }\n return joinPathLabels(cascader.pathOptions, separatorString);\n }, [cascader.pathOptions, cascader.value, formatValue, separatorString]);\n\n const initialSearchValue = useMemo(() => {\n if (!searchable || !defaultValue) {\n return '';\n }\n return joinPathLabels(getCascaderPathOptions(data, defaultValue), separatorString);\n }, []);\n\n const [_searchValue, setSearchValue] = useUncontrolled({\n value: searchValue,\n defaultValue: defaultSearchValue,\n finalValue: initialSearchValue,\n onChange: onSearchChange,\n });\n\n const isSearching =\n !!searchable && _searchValue.trim().length > 0 && _searchValue !== displayString;\n\n useEffect(() => {\n if (searchable) {\n setSearchValue(cascader.value ? displayString : '');\n }\n }, [cascader.value]);\n\n // The dropdown renders a flat list of paths when searching or when `withColumns` is disabled\n const showFlatList = isSearching || !withColumns;\n\n const flatPaths = useMemo(() => flattenCascaderPaths(data), [data]);\n\n const flatListItems = useMemo(() => {\n if (!showFlatList) {\n return [];\n }\n const base = flatPaths.filter((flatPath) => (changeOnSelect ? true : flatPath.leaf));\n if (!isSearching) {\n return base;\n }\n return base.filter((flatPath) =>\n filter\n ? filter(_searchValue, flatPath.options)\n : defaultCascaderFilter(_searchValue, flatPath.options, separatorString)\n );\n }, [flatPaths, showFlatList, isSearching, _searchValue, changeOnSelect, filter, separatorString]);\n\n const canInteract = !readOnly && !disabled;\n\n const handleSearchChange = (nextValue: string) => {\n setSearchValue(nextValue);\n if (canInteract) {\n combobox.openDropdown();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n onKeyDown?.(event);\n\n if (event.key === 'Escape') {\n combobox.closeDropdown();\n return;\n }\n\n if (showFlatList || !canInteract) {\n return;\n }\n\n if (!combobox.dropdownOpened) {\n const opensDropdown =\n event.key === 'ArrowDown' ||\n event.key === 'ArrowUp' ||\n event.key === 'ArrowRight' ||\n event.key === 'Enter' ||\n (!searchable && event.key === ' ');\n\n if (opensDropdown) {\n event.preventDefault();\n cascader.setKeyboardNav(true);\n combobox.openDropdown();\n\n if (!cascader.value && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n const rootIndex =\n event.key === 'ArrowDown'\n ? firstEnabledOptionIndex(data)\n : lastEnabledOptionIndex(data);\n if (rootIndex >= 0) {\n cascader.setActivePath([data[rootIndex].value]);\n }\n }\n }\n return;\n }\n\n if (cascader.handleColumnsKeyDown(event)) {\n event.preventDefault();\n } else if (!searchable && event.key === ' ') {\n event.preventDefault();\n }\n };\n\n const clearButton = (\n <Combobox.ClearButton\n {...clearButtonProps}\n onClear={() => {\n onClear?.();\n cascader.setValue(null);\n cascader.setActivePath([]);\n setSearchValue('');\n combobox.focusTarget();\n }}\n />\n );\n\n const hasValue = Array.isArray(cascader.value) && cascader.value.length > 0;\n const _clearable = clearable && hasValue && !disabled && !readOnly;\n\n const listId = _id ? `${_id}-cascader-list` : undefined;\n const valueKey = cascader.value ? JSON.stringify(cascader.value) : null;\n\n const dropdown = (\n <Combobox.Dropdown\n hidden={readOnly || disabled}\n style={showFlatList ? undefined : { padding: 0 }}\n >\n {showFlatList ? (\n <Combobox.Options aria-label={typeof label === 'string' ? label : undefined}>\n <ScrollArea.Autosize\n mah={maxDropdownHeight ?? 260}\n type=\"scroll\"\n scrollbarSize=\"var(--combobox-padding)\"\n offsetScrollbars=\"y\"\n {...scrollAreaProps}\n >\n {flatListItems.map((flatPath, index) => {\n const pathKey = JSON.stringify(flatPath.path);\n const active = valueKey !== null && pathKey === valueKey;\n return (\n <Combobox.Option\n key={pathKey}\n value={`${index}`}\n active={active}\n disabled={flatPath.disabled}\n >\n <span {...getStyles('flatOption')}>\n {active && withCheckIcon && checkIconPosition === 'left' && (\n <CheckIcon {...getStyles('columnOptionCheck')} />\n )}\n <span {...getStyles('columnOptionLabel')}>\n {renderSearchOption\n ? renderSearchOption(_searchValue, flatPath.options)\n : defaultRenderSearchOption(flatPath.options, separator)}\n </span>\n {active && withCheckIcon && checkIconPosition !== 'left' && (\n <CheckIcon {...getStyles('columnOptionCheck')} />\n )}\n </span>\n </Combobox.Option>\n );\n })}\n </ScrollArea.Autosize>\n {flatListItems.length === 0 && nothingFoundMessage && (\n <Combobox.Empty>{nothingFoundMessage}</Combobox.Empty>\n )}\n </Combobox.Options>\n ) : (\n <CascaderColumns\n data={data}\n activePath={cascader.activePath}\n value={cascader.value}\n keyboardNav={cascader.keyboardNav}\n withCheckIcon={withCheckIcon}\n checkIconPosition={checkIconPosition}\n renderOption={renderOption}\n columnWidth={columnWidth}\n maxDisplayedLevels={maxDisplayedLevels}\n previousLevelsControlLabel={previousLevelsControlLabel}\n nextLevelsControlLabel={nextLevelsControlLabel}\n maxDropdownHeight={maxDropdownHeight}\n nothingFoundMessage={nothingFoundMessage}\n getStyles={getStyles}\n unstyled={unstyled}\n scrollAreaProps={scrollAreaProps}\n onOptionClick={cascader.handleOptionClick}\n onOptionMouseEnter={cascader.handleOptionMouseEnter}\n onColumnsMouseLeave={() => {\n if (expandTrigger === 'hover') {\n cascader.setActivePath(cascader.value ?? []);\n }\n }}\n onPointerActivity={() => cascader.setKeyboardNav(false)}\n listId={listId}\n safeAreaPolygon={expandTrigger === 'hover' ? safeAreaPolygon : false}\n />\n )}\n </Combobox.Dropdown>\n );\n\n return (\n <>\n <Combobox\n store={combobox}\n __staticSelector=\"Cascader\"\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n readOnly={readOnly}\n size={size}\n attributes={attributes}\n width={showFlatList ? 'target' : 'max-content'}\n position=\"bottom-start\"\n onOptionSubmit={(val) => {\n const index = Number(val);\n const flatPath = flatListItems[index];\n if (!flatPath || flatPath.disabled) {\n return;\n }\n cascader.selectPath(flatPath.path);\n cascader.setActivePath(flatPath.path);\n if (shouldCloseOnSelect) {\n combobox.closeDropdown();\n }\n }}\n {...comboboxProps}\n >\n <Combobox.Target\n targetType={searchable ? 'input' : 'button'}\n withKeyboardNavigation={showFlatList}\n autoComplete={autoComplete}\n >\n <InputBase\n id={_id}\n __defaultRightSection={\n <Combobox.Chevron\n size={size}\n error={error}\n unstyled={unstyled}\n color={chevronColor}\n />\n }\n __clearSection={clearButton}\n __clearable={_clearable}\n __clearSectionMode={clearSectionMode}\n rightSection={rightSection}\n rightSectionPointerEvents={rightSectionPointerEvents || 'none'}\n {...rest}\n {...styleProps}\n size={size}\n __staticSelector=\"Cascader\"\n disabled={disabled}\n readOnly={readOnly || !searchable}\n value={searchable ? _searchValue : displayString}\n onChange={(event) => {\n if (isExternalInputChange(event)) {\n return;\n }\n\n handleSearchChange(event.currentTarget.value);\n }}\n onFocus={(event) => {\n if (openOnFocus && searchable && canInteract) {\n combobox.openDropdown();\n }\n onFocus?.(event);\n }}\n onBlur={(event) => {\n combobox.closeDropdown();\n onBlur?.(event);\n }}\n onClick={(event) => {\n if (canInteract) {\n cascader.setKeyboardNav(false);\n if (searchable) {\n combobox.openDropdown();\n } else {\n combobox.toggleDropdown();\n }\n }\n onClick?.(event);\n }}\n onKeyDown={handleKeyDown}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n unstyled={unstyled}\n pointer={!searchable}\n error={error}\n success={success}\n attributes={attributes}\n className={className}\n style={style}\n variant={variant}\n radius={radius}\n leftSection={leftSection}\n leftSectionWidth={leftSectionWidth}\n leftSectionPointerEvents={leftSectionPointerEvents}\n leftSectionProps={leftSectionProps}\n rightSectionWidth={rightSectionWidth}\n rightSectionProps={rightSectionProps}\n inputContainer={inputContainer}\n inputWrapperOrder={inputWrapperOrder}\n withAsterisk={withAsterisk}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorProps={errorProps}\n successProps={successProps}\n wrapperProps={wrapperProps}\n description={description}\n label={label}\n withErrorStyles={withErrorStyles}\n withSuccessStyles={withSuccessStyles}\n placeholder={placeholder}\n required={required}\n mod={mod}\n />\n </Combobox.Target>\n {dropdown}\n </Combobox>\n <Combobox.HiddenInput\n value={cascader.value}\n name={name}\n form={form}\n disabled={disabled}\n {...hiddenInputProps}\n />\n </>\n );\n});\n\nCascader.classes = { ...InputBase.classes, ...Combobox.classes, ...classes };\nCascader.displayName = '@mantine/core/Cascader';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+MA,MAAM,eAAe;CACnB,eAAe;CACf,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;CACf,eAAe;CACf,mBAAmB;CACnB,aAAa;CACb,YAAY;CACZ,WAAW;CACX,oBAAoB;CACpB,4BAA4B;CAC5B,wBAAwB;CACxB,mBAAmB;CACnB,aAAa;CACb,MAAM;AACR;AAEA,SAAS,oBAAoB,QAAgC;CAC3D,OAAO,OAAO,OAAO,UAAU,YAAY,OAAO,OAAO,UAAU,WAC/D,OAAO,OAAO,KAAK,IACnB,OAAO;AACb;AAEA,SAAS,wBAAwB,SAAmC;CAClE,OAAO,QAAQ,WAAW,WAAW,CAAC,OAAO,QAAQ;AACvD;AAEA,SAAS,uBAAuB,SAAmC;CACjE,KAAK,IAAI,QAAQ,QAAQ,SAA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R,CAAA;IAEH,gBAAgB;IAChB,aAAa;IACb,oBAAoB;IACN;IACd,2BAA2B,6BAA6B;IACxD,GAAI;IACJ,GAAI;IACE;IACN,kBAAiB;IACP;IACV,UAAU,YAAY,CAAC;IACvB,OAAO,aAAa,eAAe;IACnC,WAAW,UAAU;KACnB,IAAI,sBAAsB,KAAK,GAC7B;KAGF,mBAAmB,MAAM,cAAc,KAAK;IAC9C;IACA,UAAU,UAAU;KAClB,IAAI,eAAe,cAAc,aAC/B,SAAS,aAAa;KAExB,UAAU,KAAK;IACjB;IACA,SAAS,UAAU;KACjB,SAAS,cAAc;KACvB,SAAS,KAAK;IAChB;IACA,UAAU,UAAU;KAClB,IAAI,aAAa;MACf,SAAS,eAAe,KAAK;MAC7B,IAAI,YACF,SAAS,aAAa;WAEtB,SAAS,eAAe;KAE5B;KACA,UAAU,KAAK;IACjB;IACA,WAAW;IACX,YAAY;IACZ,QAAQ;IACE;IACV,SAAS,CAAC;IACH;IACE;IACG;IACD;IACJ;IACE;IACD;IACK;IACK;IACQ;IACR;IACC;IACA;IACH;IACG;IACL;IACF;IACM;IACN;IACE;IACA;IACD;IACN;IACU;IACE;IACN;IACH;IACL;GACN,CAAA;EACc,CAAA,GAChB,QACO;KACV,oBAAC,SAAS,aAAV;EACE,OAAO,SAAS;EACV;EACA;EACI;EACV,GAAI;CACL,CAAA,CACD,EAAA,CAAA;AAEN,CAAC;AAED,SAAS,UAAU;CAAE,GAAG,UAAU;CAAS,GAAG,SAAS;CAAS,GAAGC;AAAQ;AAC3E,SAAS,cAAc"}
|
|
@@ -4,13 +4,14 @@ import { UnstyledButton } from "../UnstyledButton/UnstyledButton.mjs";
|
|
|
4
4
|
import { AccordionChevron } from "../Accordion/AccordionChevron.mjs";
|
|
5
5
|
import { CheckIcon } from "../Checkbox/CheckIcon.mjs";
|
|
6
6
|
import { cascaderOptionHasChildren, getCascaderColumns } from "./get-cascader-columns.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { useCascaderSafeArea } from "./use-cascader-safe-area.mjs";
|
|
8
|
+
import { useRef, useState } from "react";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
//#region packages/@mantine/core/src/components/Cascader/CascaderColumns.tsx
|
|
10
11
|
function getCascaderOptionId(listId, level, value) {
|
|
11
12
|
return listId ? `${listId}-${level}-${value}` : void 0;
|
|
12
13
|
}
|
|
13
|
-
function CascaderColumns({ data, activePath, value, keyboardNav, withCheckIcon, checkIconPosition, renderOption, columnWidth, maxDisplayedLevels, previousLevelsControlLabel, nextLevelsControlLabel, maxDropdownHeight, nothingFoundMessage, getStyles, unstyled, scrollAreaProps, onOptionClick, onOptionMouseEnter, onColumnsMouseLeave, onPointerActivity, listId }) {
|
|
14
|
+
function CascaderColumns({ data, activePath, value, keyboardNav, withCheckIcon, checkIconPosition, renderOption, columnWidth, maxDisplayedLevels, previousLevelsControlLabel, nextLevelsControlLabel, maxDropdownHeight, nothingFoundMessage, getStyles, unstyled, scrollAreaProps, onOptionClick, onOptionMouseEnter, onColumnsMouseLeave, onPointerActivity, listId, safeAreaPolygon }) {
|
|
14
15
|
const allColumns = getCascaderColumns(data, activePath);
|
|
15
16
|
const totalColumns = allColumns.length;
|
|
16
17
|
const maxLevels = maxDisplayedLevels && maxDisplayedLevels > 0 ? maxDisplayedLevels : totalColumns;
|
|
@@ -37,10 +38,18 @@ function CascaderColumns({ data, activePath, value, keyboardNav, withCheckIcon,
|
|
|
37
38
|
const hiddenBefore = windowStart;
|
|
38
39
|
const hiddenAfter = totalColumns - windowEnd;
|
|
39
40
|
const check = showCheckIcon ? /* @__PURE__ */ jsx(CheckIcon, { ...getStyles("columnOptionCheck") }) : null;
|
|
41
|
+
const columnRefs = useRef({});
|
|
42
|
+
const safeArea = useCascaderSafeArea({
|
|
43
|
+
safeAreaPolygon,
|
|
44
|
+
onFlush: onOptionMouseEnter
|
|
45
|
+
});
|
|
40
46
|
return /* @__PURE__ */ jsxs("div", {
|
|
41
47
|
...getStyles("columnsList"),
|
|
42
48
|
role: "presentation",
|
|
43
|
-
onMouseLeave:
|
|
49
|
+
onMouseLeave: () => {
|
|
50
|
+
safeArea.disarm();
|
|
51
|
+
onColumnsMouseLeave?.();
|
|
52
|
+
},
|
|
44
53
|
onMouseMove: onPointerActivity,
|
|
45
54
|
children: [
|
|
46
55
|
hiddenBefore > 0 && /* @__PURE__ */ jsx(UnstyledButton, {
|
|
@@ -57,6 +66,9 @@ function CascaderColumns({ data, activePath, value, keyboardNav, withCheckIcon,
|
|
|
57
66
|
visibleColumns.map((options, index) => {
|
|
58
67
|
const level = windowStart + index;
|
|
59
68
|
return /* @__PURE__ */ jsx("div", {
|
|
69
|
+
ref: (node) => {
|
|
70
|
+
columnRefs.current[level] = node;
|
|
71
|
+
},
|
|
60
72
|
"data-last": index === visibleColumns.length - 1 && hiddenAfter === 0 || void 0,
|
|
61
73
|
...getStyles("column", { style: columnWidth ? {
|
|
62
74
|
width: columnWidth,
|
|
@@ -94,7 +106,26 @@ function CascaderColumns({ data, activePath, value, keyboardNav, withCheckIcon,
|
|
|
94
106
|
if (!option.disabled) onOptionClick(level, option);
|
|
95
107
|
},
|
|
96
108
|
onMouseEnter: () => {
|
|
97
|
-
if (
|
|
109
|
+
if (option.disabled) return;
|
|
110
|
+
if (safeArea.isBlocked(level)) {
|
|
111
|
+
safeArea.setPending(level, option);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
onOptionMouseEnter(level, option);
|
|
115
|
+
},
|
|
116
|
+
onMouseLeave: (event) => {
|
|
117
|
+
safeArea.clearPending(level, option);
|
|
118
|
+
if (!safeArea.enabled || option.disabled) return;
|
|
119
|
+
if (activePath[level] !== option.value) return;
|
|
120
|
+
const floating = columnRefs.current[level + 1];
|
|
121
|
+
if (!floating) return;
|
|
122
|
+
safeArea.arm({
|
|
123
|
+
level,
|
|
124
|
+
reference: event.currentTarget,
|
|
125
|
+
floating,
|
|
126
|
+
clientX: event.clientX,
|
|
127
|
+
clientY: event.clientY
|
|
128
|
+
});
|
|
98
129
|
},
|
|
99
130
|
...getStyles("columnOption"),
|
|
100
131
|
children: [
|