@mantine/core 9.6.2 → 9.7.0
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/ActionBar/ActionBar.cjs +0 -3
- package/cjs/components/ActionBar/ActionBar.cjs.map +1 -1
- package/cjs/components/ActionBar/ActionBar.module.cjs.map +1 -1
- package/cjs/components/AppShell/AppShell.cjs +33 -6
- package/cjs/components/AppShell/AppShell.cjs.map +1 -1
- package/cjs/components/AppShell/AppShell.context.cjs.map +1 -1
- package/cjs/components/AppShell/AppShell.module.cjs +2 -1
- package/cjs/components/AppShell/AppShell.module.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellAside/AppShellAside.cjs +28 -7
- package/cjs/components/AppShell/AppShellAside/AppShellAside.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellFooter/AppShellFooter.cjs +28 -7
- package/cjs/components/AppShell/AppShellFooter/AppShellFooter.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellHeader/AppShellHeader.cjs +28 -7
- package/cjs/components/AppShell/AppShellHeader/AppShellHeader.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellMediaStyles/AppShellMediaStyles.cjs +3 -2
- package/cjs/components/AppShell/AppShellMediaStyles/AppShellMediaStyles.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellMediaStyles/assign-aside-variables/assign-aside-variables.cjs +27 -16
- package/cjs/components/AppShell/AppShellMediaStyles/assign-aside-variables/assign-aside-variables.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellMediaStyles/assign-footer-variables/assign-footer-variables.cjs +24 -16
- package/cjs/components/AppShell/AppShellMediaStyles/assign-footer-variables/assign-footer-variables.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellMediaStyles/assign-header-variables/assign-header-variables.cjs +24 -16
- package/cjs/components/AppShell/AppShellMediaStyles/assign-header-variables/assign-header-variables.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellMediaStyles/assign-navbar-variables/assign-navbar-variables.cjs +30 -19
- package/cjs/components/AppShell/AppShellMediaStyles/assign-navbar-variables/assign-navbar-variables.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellMediaStyles/escape-css-id/escape-css-id.cjs +26 -0
- package/cjs/components/AppShell/AppShellMediaStyles/escape-css-id/escape-css-id.cjs.map +1 -0
- package/cjs/components/AppShell/AppShellMediaStyles/get-resized-value/get-resized-value.cjs +10 -0
- package/cjs/components/AppShell/AppShellMediaStyles/get-resized-value/get-resized-value.cjs.map +1 -0
- package/cjs/components/AppShell/AppShellMediaStyles/get-variables/get-variables.cjs +13 -5
- package/cjs/components/AppShell/AppShellMediaStyles/get-variables/get-variables.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellNavbar/AppShellNavbar.cjs +28 -7
- package/cjs/components/AppShell/AppShellNavbar/AppShellNavbar.cjs.map +1 -1
- package/cjs/components/AppShell/AppShellResizeHandle/AppShellResizeHandle.cjs +270 -0
- package/cjs/components/AppShell/AppShellResizeHandle/AppShellResizeHandle.cjs.map +1 -0
- package/cjs/components/AppShell/use-app-shell-resize/clamp-resize-size.cjs +15 -0
- package/cjs/components/AppShell/use-app-shell-resize/clamp-resize-size.cjs.map +1 -0
- package/cjs/components/AppShell/use-app-shell-resize/resize-section-config.cjs +51 -0
- package/cjs/components/AppShell/use-app-shell-resize/resize-section-config.cjs.map +1 -0
- package/cjs/components/AppShell/use-app-shell-resize/safe-area-inset.cjs +12 -0
- package/cjs/components/AppShell/use-app-shell-resize/safe-area-inset.cjs.map +1 -0
- package/cjs/components/AppShell/use-app-shell-resize/use-app-shell-resize.cjs +127 -0
- package/cjs/components/AppShell/use-app-shell-resize/use-app-shell-resize.cjs.map +1 -0
- package/cjs/components/AppShell/use-resizing/use-resizing.cjs +20 -2
- package/cjs/components/AppShell/use-resizing/use-resizing.cjs.map +1 -1
- package/cjs/components/Checkbox/Checkbox.cjs +10 -2
- package/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
- package/cjs/components/Checkbox/Checkbox.module.cjs +1 -0
- package/cjs/components/Checkbox/Checkbox.module.cjs.map +1 -1
- package/cjs/components/Checkbox/CheckboxIndicator/CheckboxIndicator.cjs +10 -2
- package/cjs/components/Checkbox/CheckboxIndicator/CheckboxIndicator.cjs.map +1 -1
- package/cjs/components/Checkbox/CheckboxIndicator/CheckboxIndicator.module.cjs +1 -0
- package/cjs/components/Checkbox/CheckboxIndicator/CheckboxIndicator.module.cjs.map +1 -1
- package/cjs/components/ComboboxPopover/ComboboxPopover.cjs.map +1 -1
- package/cjs/components/Dialog/Dialog.cjs +0 -1
- package/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/cjs/components/Dialog/Dialog.module.cjs.map +1 -1
- package/cjs/components/HoverCard/HoverCard.cjs +34 -5
- package/cjs/components/HoverCard/HoverCard.cjs.map +1 -1
- package/cjs/components/HoverCard/HoverCard.context.cjs.map +1 -1
- package/cjs/components/HoverCard/HoverCardDropdown/HoverCardDropdown.cjs +13 -18
- package/cjs/components/HoverCard/HoverCardDropdown/HoverCardDropdown.cjs.map +1 -1
- package/cjs/components/HoverCard/HoverCardTarget/HoverCardTarget.cjs +6 -23
- package/cjs/components/HoverCard/HoverCardTarget/HoverCardTarget.cjs.map +1 -1
- package/cjs/components/HoverCard/use-hover-card.cjs +26 -12
- package/cjs/components/HoverCard/use-hover-card.cjs.map +1 -1
- package/cjs/components/Input/InputWrapper/InputWrapper.cjs +1 -1
- package/cjs/components/Input/InputWrapper/InputWrapper.cjs.map +1 -1
- package/cjs/components/Marquee/Marquee.cjs.map +1 -1
- package/cjs/components/Marquee/Marquee.module.cjs.map +1 -1
- package/cjs/components/PasswordInput/PasswordInput.cjs +10 -5
- package/cjs/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/cjs/components/PinInput/PinInput.cjs.map +1 -1
- package/cjs/components/Portal/Portal.cjs +10 -1
- package/cjs/components/Portal/Portal.cjs.map +1 -1
- package/cjs/components/Radio/Radio.cjs +10 -2
- package/cjs/components/Radio/Radio.cjs.map +1 -1
- package/cjs/components/Radio/Radio.module.cjs +1 -0
- package/cjs/components/Radio/Radio.module.cjs.map +1 -1
- package/cjs/components/Radio/RadioIndicator/RadioIndicator.cjs +10 -2
- package/cjs/components/Radio/RadioIndicator/RadioIndicator.cjs.map +1 -1
- package/cjs/components/Radio/RadioIndicator/RadioIndicator.module.cjs +1 -0
- package/cjs/components/Radio/RadioIndicator/RadioIndicator.module.cjs.map +1 -1
- package/cjs/components/Rating/Rating.cjs +35 -12
- package/cjs/components/Rating/Rating.cjs.map +1 -1
- package/cjs/components/Select/Select.cjs +1 -1
- package/cjs/components/Select/Select.cjs.map +1 -1
- package/cjs/components/Slider/Thumb/Thumb.cjs +7 -2
- package/cjs/components/Slider/Thumb/Thumb.cjs.map +1 -1
- package/cjs/components/Table/Table.cjs +23 -10
- package/cjs/components/Table/Table.cjs.map +1 -1
- package/cjs/components/Toggle/Toggle.cjs +80 -0
- package/cjs/components/Toggle/Toggle.cjs.map +1 -0
- package/cjs/components/Toggle/Toggle.module.cjs +7 -0
- package/cjs/components/Toggle/Toggle.module.cjs.map +1 -0
- package/cjs/components/Toolbar/Toolbar.cjs +107 -0
- package/cjs/components/Toolbar/Toolbar.cjs.map +1 -0
- package/cjs/components/Toolbar/Toolbar.context.cjs +8 -0
- package/cjs/components/Toolbar/Toolbar.context.cjs.map +1 -0
- package/cjs/components/Toolbar/Toolbar.module.cjs +12 -0
- package/cjs/components/Toolbar/Toolbar.module.cjs.map +1 -0
- package/cjs/components/Toolbar/ToolbarDivider/ToolbarDivider.cjs +31 -0
- package/cjs/components/Toolbar/ToolbarDivider/ToolbarDivider.cjs.map +1 -0
- package/cjs/components/Toolbar/ToolbarGroup/ToolbarGroup.cjs +31 -0
- package/cjs/components/Toolbar/ToolbarGroup/ToolbarGroup.cjs.map +1 -0
- package/cjs/components/Toolbar/ToolbarToggle/ToolbarToggle.cjs +47 -0
- package/cjs/components/Toolbar/ToolbarToggle/ToolbarToggle.cjs.map +1 -0
- package/cjs/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.cjs +61 -0
- package/cjs/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.cjs.map +1 -0
- package/cjs/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.context.cjs +8 -0
- package/cjs/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.context.cjs.map +1 -0
- package/cjs/components/Toolbar/ToolbarToggleItem/ToolbarToggleItem.cjs +51 -0
- package/cjs/components/Toolbar/ToolbarToggleItem/ToolbarToggleItem.cjs.map +1 -0
- package/cjs/components/Toolbar/use-toolbar-navigation.cjs +76 -0
- package/cjs/components/Toolbar/use-toolbar-navigation.cjs.map +1 -0
- package/cjs/components/Tooltip/Tooltip.cjs +9 -5
- package/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/cjs/components/Tooltip/use-tooltip.cjs +6 -3
- package/cjs/components/Tooltip/use-tooltip.cjs.map +1 -1
- package/cjs/components/Tour/Tour.cjs +283 -0
- package/cjs/components/Tour/Tour.cjs.map +1 -0
- package/cjs/components/Tour/Tour.context.cjs +25 -0
- package/cjs/components/Tour/Tour.context.cjs.map +1 -0
- package/cjs/components/Tour/Tour.module.cjs +19 -0
- package/cjs/components/Tour/Tour.module.cjs.map +1 -0
- package/cjs/components/Tour/TourBeacon/TourBeacon.cjs +54 -0
- package/cjs/components/Tour/TourBeacon/TourBeacon.cjs.map +1 -0
- package/cjs/components/Tour/TourBeaconPositioned.cjs +46 -0
- package/cjs/components/Tour/TourBeaconPositioned.cjs.map +1 -0
- package/cjs/components/Tour/TourBody/TourBody.cjs +37 -0
- package/cjs/components/Tour/TourBody/TourBody.cjs.map +1 -0
- package/cjs/components/Tour/TourCloseButton/TourCloseButton.cjs +26 -0
- package/cjs/components/Tour/TourCloseButton/TourCloseButton.cjs.map +1 -0
- package/cjs/components/Tour/TourNavigation/TourNavigation.cjs +63 -0
- package/cjs/components/Tour/TourNavigation/TourNavigation.cjs.map +1 -0
- package/cjs/components/Tour/TourOverlay/TourOverlay.cjs +70 -0
- package/cjs/components/Tour/TourOverlay/TourOverlay.cjs.map +1 -0
- package/cjs/components/Tour/TourRoot/TourRoot.cjs +125 -0
- package/cjs/components/Tour/TourRoot/TourRoot.cjs.map +1 -0
- package/cjs/components/Tour/TourStep/TourStep.cjs +10 -0
- package/cjs/components/Tour/TourStep/TourStep.cjs.map +1 -0
- package/cjs/components/Tour/TourTitle/TourTitle.cjs +38 -0
- package/cjs/components/Tour/TourTitle/TourTitle.cjs.map +1 -0
- package/cjs/components/Tour/TourTooltip/TourTooltip.cjs +87 -0
- package/cjs/components/Tour/TourTooltip/TourTooltip.cjs.map +1 -0
- package/cjs/components/Tour/get-overlay-hit-path.cjs +17 -0
- package/cjs/components/Tour/get-overlay-hit-path.cjs.map +1 -0
- package/cjs/components/Tour/is-element-in-view.cjs +30 -0
- package/cjs/components/Tour/is-element-in-view.cjs.map +1 -0
- package/cjs/components/Tour/press-aware-auto-update.cjs +38 -0
- package/cjs/components/Tour/press-aware-auto-update.cjs.map +1 -0
- package/cjs/components/Tour/use-target-rect.cjs +61 -0
- package/cjs/components/Tour/use-target-rect.cjs.map +1 -0
- package/cjs/components/Tour/use-tooltip-auto-focus.cjs +34 -0
- package/cjs/components/Tour/use-tooltip-auto-focus.cjs.map +1 -0
- package/cjs/components/Tour/use-tour-state.cjs +102 -0
- package/cjs/components/Tour/use-tour-state.cjs.map +1 -0
- package/cjs/components/Tour/use-tour.cjs +155 -0
- package/cjs/components/Tour/use-tour.cjs.map +1 -0
- package/cjs/components/TreeSelect/TreeSelect.cjs +29 -16
- package/cjs/components/TreeSelect/TreeSelect.cjs.map +1 -1
- package/cjs/core/Box/Box.cjs +1 -1
- package/cjs/core/Box/Box.cjs.map +1 -1
- package/cjs/core/Box/style-props/style-props-data.cjs +2 -2
- package/cjs/core/Box/style-props/style-props-data.cjs.map +1 -1
- package/cjs/core/styles-api/use-styles/use-styles.cjs +32 -2
- package/cjs/core/styles-api/use-styles/use-styles.cjs.map +1 -1
- package/cjs/core/utils/shallow-equal/shallow-equal.cjs +19 -0
- package/cjs/core/utils/shallow-equal/shallow-equal.cjs.map +1 -0
- package/cjs/index.cjs +42 -2
- package/esm/components/ActionBar/ActionBar.mjs +0 -3
- package/esm/components/ActionBar/ActionBar.mjs.map +1 -1
- package/esm/components/ActionBar/ActionBar.module.mjs.map +1 -1
- package/esm/components/AppShell/AppShell.context.mjs.map +1 -1
- package/esm/components/AppShell/AppShell.mjs +35 -8
- package/esm/components/AppShell/AppShell.mjs.map +1 -1
- package/esm/components/AppShell/AppShell.module.mjs +2 -1
- package/esm/components/AppShell/AppShell.module.mjs.map +1 -1
- package/esm/components/AppShell/AppShellAside/AppShellAside.mjs +29 -8
- package/esm/components/AppShell/AppShellAside/AppShellAside.mjs.map +1 -1
- package/esm/components/AppShell/AppShellFooter/AppShellFooter.mjs +29 -8
- package/esm/components/AppShell/AppShellFooter/AppShellFooter.mjs.map +1 -1
- package/esm/components/AppShell/AppShellHeader/AppShellHeader.mjs +29 -8
- package/esm/components/AppShell/AppShellHeader/AppShellHeader.mjs.map +1 -1
- package/esm/components/AppShell/AppShellMediaStyles/AppShellMediaStyles.mjs +3 -2
- package/esm/components/AppShell/AppShellMediaStyles/AppShellMediaStyles.mjs.map +1 -1
- package/esm/components/AppShell/AppShellMediaStyles/assign-aside-variables/assign-aside-variables.mjs +27 -16
- package/esm/components/AppShell/AppShellMediaStyles/assign-aside-variables/assign-aside-variables.mjs.map +1 -1
- package/esm/components/AppShell/AppShellMediaStyles/assign-footer-variables/assign-footer-variables.mjs +24 -16
- package/esm/components/AppShell/AppShellMediaStyles/assign-footer-variables/assign-footer-variables.mjs.map +1 -1
- package/esm/components/AppShell/AppShellMediaStyles/assign-header-variables/assign-header-variables.mjs +24 -16
- package/esm/components/AppShell/AppShellMediaStyles/assign-header-variables/assign-header-variables.mjs.map +1 -1
- package/esm/components/AppShell/AppShellMediaStyles/assign-navbar-variables/assign-navbar-variables.mjs +30 -19
- package/esm/components/AppShell/AppShellMediaStyles/assign-navbar-variables/assign-navbar-variables.mjs.map +1 -1
- package/esm/components/AppShell/AppShellMediaStyles/escape-css-id/escape-css-id.mjs +26 -0
- package/esm/components/AppShell/AppShellMediaStyles/escape-css-id/escape-css-id.mjs.map +1 -0
- package/esm/components/AppShell/AppShellMediaStyles/get-resized-value/get-resized-value.mjs +10 -0
- package/esm/components/AppShell/AppShellMediaStyles/get-resized-value/get-resized-value.mjs.map +1 -0
- package/esm/components/AppShell/AppShellMediaStyles/get-variables/get-variables.mjs +13 -5
- package/esm/components/AppShell/AppShellMediaStyles/get-variables/get-variables.mjs.map +1 -1
- package/esm/components/AppShell/AppShellNavbar/AppShellNavbar.mjs +29 -8
- package/esm/components/AppShell/AppShellNavbar/AppShellNavbar.mjs.map +1 -1
- package/esm/components/AppShell/AppShellResizeHandle/AppShellResizeHandle.mjs +270 -0
- package/esm/components/AppShell/AppShellResizeHandle/AppShellResizeHandle.mjs.map +1 -0
- package/esm/components/AppShell/use-app-shell-resize/clamp-resize-size.mjs +14 -0
- package/esm/components/AppShell/use-app-shell-resize/clamp-resize-size.mjs.map +1 -0
- package/esm/components/AppShell/use-app-shell-resize/resize-section-config.mjs +49 -0
- package/esm/components/AppShell/use-app-shell-resize/resize-section-config.mjs.map +1 -0
- package/esm/components/AppShell/use-app-shell-resize/safe-area-inset.mjs +12 -0
- package/esm/components/AppShell/use-app-shell-resize/safe-area-inset.mjs.map +1 -0
- package/esm/components/AppShell/use-app-shell-resize/use-app-shell-resize.mjs +127 -0
- package/esm/components/AppShell/use-app-shell-resize/use-app-shell-resize.mjs.map +1 -0
- package/esm/components/AppShell/use-resizing/use-resizing.mjs +21 -3
- package/esm/components/AppShell/use-resizing/use-resizing.mjs.map +1 -1
- package/esm/components/Checkbox/Checkbox.mjs +10 -2
- package/esm/components/Checkbox/Checkbox.mjs.map +1 -1
- package/esm/components/Checkbox/Checkbox.module.mjs +1 -0
- package/esm/components/Checkbox/Checkbox.module.mjs.map +1 -1
- package/esm/components/Checkbox/CheckboxIndicator/CheckboxIndicator.mjs +10 -2
- package/esm/components/Checkbox/CheckboxIndicator/CheckboxIndicator.mjs.map +1 -1
- package/esm/components/Checkbox/CheckboxIndicator/CheckboxIndicator.module.mjs +1 -0
- package/esm/components/Checkbox/CheckboxIndicator/CheckboxIndicator.module.mjs.map +1 -1
- package/esm/components/ComboboxPopover/ComboboxPopover.mjs.map +1 -1
- package/esm/components/Dialog/Dialog.mjs +0 -1
- package/esm/components/Dialog/Dialog.mjs.map +1 -1
- package/esm/components/Dialog/Dialog.module.mjs.map +1 -1
- package/esm/components/HoverCard/HoverCard.context.mjs.map +1 -1
- package/esm/components/HoverCard/HoverCard.mjs +34 -5
- package/esm/components/HoverCard/HoverCard.mjs.map +1 -1
- package/esm/components/HoverCard/HoverCardDropdown/HoverCardDropdown.mjs +13 -18
- package/esm/components/HoverCard/HoverCardDropdown/HoverCardDropdown.mjs.map +1 -1
- package/esm/components/HoverCard/HoverCardTarget/HoverCardTarget.mjs +7 -24
- package/esm/components/HoverCard/HoverCardTarget/HoverCardTarget.mjs.map +1 -1
- package/esm/components/HoverCard/use-hover-card.mjs +27 -13
- package/esm/components/HoverCard/use-hover-card.mjs.map +1 -1
- package/esm/components/Input/InputWrapper/InputWrapper.mjs +1 -1
- package/esm/components/Input/InputWrapper/InputWrapper.mjs.map +1 -1
- package/esm/components/Marquee/Marquee.mjs.map +1 -1
- package/esm/components/Marquee/Marquee.module.mjs.map +1 -1
- package/esm/components/PasswordInput/PasswordInput.mjs +12 -7
- package/esm/components/PasswordInput/PasswordInput.mjs.map +1 -1
- package/esm/components/PinInput/PinInput.mjs.map +1 -1
- package/esm/components/Portal/Portal.mjs +10 -1
- package/esm/components/Portal/Portal.mjs.map +1 -1
- package/esm/components/Radio/Radio.mjs +10 -2
- package/esm/components/Radio/Radio.mjs.map +1 -1
- package/esm/components/Radio/Radio.module.mjs +1 -0
- package/esm/components/Radio/Radio.module.mjs.map +1 -1
- package/esm/components/Radio/RadioIndicator/RadioIndicator.mjs +10 -2
- package/esm/components/Radio/RadioIndicator/RadioIndicator.mjs.map +1 -1
- package/esm/components/Radio/RadioIndicator/RadioIndicator.module.mjs +1 -0
- package/esm/components/Radio/RadioIndicator/RadioIndicator.module.mjs.map +1 -1
- package/esm/components/Rating/Rating.mjs +35 -12
- package/esm/components/Rating/Rating.mjs.map +1 -1
- package/esm/components/Select/Select.mjs +1 -1
- package/esm/components/Select/Select.mjs.map +1 -1
- package/esm/components/Slider/Thumb/Thumb.mjs +7 -2
- package/esm/components/Slider/Thumb/Thumb.mjs.map +1 -1
- package/esm/components/Table/Table.mjs +23 -10
- package/esm/components/Table/Table.mjs.map +1 -1
- package/esm/components/Toggle/Toggle.mjs +80 -0
- package/esm/components/Toggle/Toggle.mjs.map +1 -0
- package/esm/components/Toggle/Toggle.module.mjs +7 -0
- package/esm/components/Toggle/Toggle.module.mjs.map +1 -0
- package/esm/components/Toolbar/Toolbar.context.mjs +8 -0
- package/esm/components/Toolbar/Toolbar.context.mjs.map +1 -0
- package/esm/components/Toolbar/Toolbar.mjs +107 -0
- package/esm/components/Toolbar/Toolbar.mjs.map +1 -0
- package/esm/components/Toolbar/Toolbar.module.mjs +12 -0
- package/esm/components/Toolbar/Toolbar.module.mjs.map +1 -0
- package/esm/components/Toolbar/ToolbarDivider/ToolbarDivider.mjs +31 -0
- package/esm/components/Toolbar/ToolbarDivider/ToolbarDivider.mjs.map +1 -0
- package/esm/components/Toolbar/ToolbarGroup/ToolbarGroup.mjs +31 -0
- package/esm/components/Toolbar/ToolbarGroup/ToolbarGroup.mjs.map +1 -0
- package/esm/components/Toolbar/ToolbarToggle/ToolbarToggle.mjs +47 -0
- package/esm/components/Toolbar/ToolbarToggle/ToolbarToggle.mjs.map +1 -0
- package/esm/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.context.mjs +8 -0
- package/esm/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.context.mjs.map +1 -0
- package/esm/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.mjs +61 -0
- package/esm/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.mjs.map +1 -0
- package/esm/components/Toolbar/ToolbarToggleItem/ToolbarToggleItem.mjs +51 -0
- package/esm/components/Toolbar/ToolbarToggleItem/ToolbarToggleItem.mjs.map +1 -0
- package/esm/components/Toolbar/use-toolbar-navigation.mjs +76 -0
- package/esm/components/Toolbar/use-toolbar-navigation.mjs.map +1 -0
- package/esm/components/Tooltip/Tooltip.mjs +9 -5
- package/esm/components/Tooltip/Tooltip.mjs.map +1 -1
- package/esm/components/Tooltip/use-tooltip.mjs +7 -4
- package/esm/components/Tooltip/use-tooltip.mjs.map +1 -1
- package/esm/components/Tour/Tour.context.mjs +22 -0
- package/esm/components/Tour/Tour.context.mjs.map +1 -0
- package/esm/components/Tour/Tour.mjs +283 -0
- package/esm/components/Tour/Tour.mjs.map +1 -0
- package/esm/components/Tour/Tour.module.mjs +19 -0
- package/esm/components/Tour/Tour.module.mjs.map +1 -0
- package/esm/components/Tour/TourBeacon/TourBeacon.mjs +54 -0
- package/esm/components/Tour/TourBeacon/TourBeacon.mjs.map +1 -0
- package/esm/components/Tour/TourBeaconPositioned.mjs +46 -0
- package/esm/components/Tour/TourBeaconPositioned.mjs.map +1 -0
- package/esm/components/Tour/TourBody/TourBody.mjs +37 -0
- package/esm/components/Tour/TourBody/TourBody.mjs.map +1 -0
- package/esm/components/Tour/TourCloseButton/TourCloseButton.mjs +26 -0
- package/esm/components/Tour/TourCloseButton/TourCloseButton.mjs.map +1 -0
- package/esm/components/Tour/TourNavigation/TourNavigation.mjs +63 -0
- package/esm/components/Tour/TourNavigation/TourNavigation.mjs.map +1 -0
- package/esm/components/Tour/TourOverlay/TourOverlay.mjs +70 -0
- package/esm/components/Tour/TourOverlay/TourOverlay.mjs.map +1 -0
- package/esm/components/Tour/TourRoot/TourRoot.mjs +125 -0
- package/esm/components/Tour/TourRoot/TourRoot.mjs.map +1 -0
- package/esm/components/Tour/TourStep/TourStep.mjs +10 -0
- package/esm/components/Tour/TourStep/TourStep.mjs.map +1 -0
- package/esm/components/Tour/TourTitle/TourTitle.mjs +38 -0
- package/esm/components/Tour/TourTitle/TourTitle.mjs.map +1 -0
- package/esm/components/Tour/TourTooltip/TourTooltip.mjs +87 -0
- package/esm/components/Tour/TourTooltip/TourTooltip.mjs.map +1 -0
- package/esm/components/Tour/get-overlay-hit-path.mjs +17 -0
- package/esm/components/Tour/get-overlay-hit-path.mjs.map +1 -0
- package/esm/components/Tour/is-element-in-view.mjs +30 -0
- package/esm/components/Tour/is-element-in-view.mjs.map +1 -0
- package/esm/components/Tour/press-aware-auto-update.mjs +38 -0
- package/esm/components/Tour/press-aware-auto-update.mjs.map +1 -0
- package/esm/components/Tour/use-target-rect.mjs +59 -0
- package/esm/components/Tour/use-target-rect.mjs.map +1 -0
- package/esm/components/Tour/use-tooltip-auto-focus.mjs +34 -0
- package/esm/components/Tour/use-tooltip-auto-focus.mjs.map +1 -0
- package/esm/components/Tour/use-tour-state.mjs +102 -0
- package/esm/components/Tour/use-tour-state.mjs.map +1 -0
- package/esm/components/Tour/use-tour.mjs +155 -0
- package/esm/components/Tour/use-tour.mjs.map +1 -0
- package/esm/components/TreeSelect/TreeSelect.mjs +30 -17
- package/esm/components/TreeSelect/TreeSelect.mjs.map +1 -1
- package/esm/core/Box/Box.mjs +2 -2
- package/esm/core/Box/Box.mjs.map +1 -1
- package/esm/core/Box/style-props/style-props-data.mjs +2 -2
- package/esm/core/Box/style-props/style-props-data.mjs.map +1 -1
- package/esm/core/styles-api/use-styles/use-styles.mjs +32 -2
- package/esm/core/styles-api/use-styles/use-styles.mjs.map +1 -1
- package/esm/core/utils/shallow-equal/shallow-equal.mjs +19 -0
- package/esm/core/utils/shallow-equal/shallow-equal.mjs.map +1 -0
- package/esm/index.mjs +22 -3
- package/lib/components/ActionBar/ActionBar.d.ts +1 -1
- package/lib/components/AppShell/AppShell.context.d.ts +4 -0
- package/lib/components/AppShell/AppShell.d.ts +5 -3
- package/lib/components/AppShell/AppShell.types.d.ts +70 -0
- package/lib/components/AppShell/AppShellMediaStyles/AppShellMediaStyles.d.ts +6 -1
- package/lib/components/AppShell/AppShellMediaStyles/assign-aside-variables/assign-aside-variables.d.ts +3 -1
- package/lib/components/AppShell/AppShellMediaStyles/assign-footer-variables/assign-footer-variables.d.ts +3 -1
- package/lib/components/AppShell/AppShellMediaStyles/assign-header-variables/assign-header-variables.d.ts +3 -1
- package/lib/components/AppShell/AppShellMediaStyles/assign-navbar-variables/assign-navbar-variables.d.ts +3 -1
- package/lib/components/AppShell/AppShellMediaStyles/escape-css-id/escape-css-id.d.ts +2 -0
- package/lib/components/AppShell/AppShellMediaStyles/get-resized-value/get-resized-value.d.ts +1 -0
- package/lib/components/AppShell/AppShellMediaStyles/get-variables/get-variables.d.ts +6 -1
- package/lib/components/AppShell/AppShellResizeHandle/AppShellResizeHandle.d.ts +10 -0
- package/lib/components/AppShell/index.d.ts +3 -2
- package/lib/components/AppShell/use-app-shell-resize/clamp-resize-size.d.ts +9 -0
- package/lib/components/AppShell/use-app-shell-resize/resize-section-config.d.ts +29 -0
- package/lib/components/AppShell/use-app-shell-resize/safe-area-inset.d.ts +1 -0
- package/lib/components/AppShell/use-app-shell-resize/use-app-shell-resize.d.ts +2 -0
- package/lib/components/AppShell/use-resizing/use-resizing.d.ts +2 -1
- package/lib/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/components/Checkbox/CheckboxIndicator/CheckboxIndicator.d.ts +2 -2
- package/lib/components/Combobox/Combobox.types.d.ts +1 -1
- package/lib/components/ComboboxPopover/ComboboxPopover.d.ts +1 -1
- package/lib/components/HoverCard/HoverCard.context.d.ts +8 -4
- package/lib/components/HoverCard/HoverCard.d.ts +41 -0
- package/lib/components/HoverCard/index.d.ts +1 -1
- package/lib/components/HoverCard/use-hover-card.d.ts +11 -0
- package/lib/components/Marquee/Marquee.d.ts +1 -1
- package/lib/components/PinInput/PinInput.d.ts +1 -1
- package/lib/components/Radio/Radio.d.ts +2 -2
- package/lib/components/Radio/RadioIndicator/RadioIndicator.d.ts +2 -2
- package/lib/components/Slider/Thumb/Thumb.d.ts +1 -1
- package/lib/components/Toggle/Toggle.d.ts +73 -0
- package/lib/components/Toggle/index.d.ts +7 -0
- package/lib/components/Toolbar/Toolbar.context.d.ts +7 -0
- package/lib/components/Toolbar/Toolbar.d.ts +58 -0
- package/lib/components/Toolbar/ToolbarDivider/ToolbarDivider.d.ts +16 -0
- package/lib/components/Toolbar/ToolbarGroup/ToolbarGroup.d.ts +16 -0
- package/lib/components/Toolbar/ToolbarToggle/ToolbarToggle.d.ts +44 -0
- package/lib/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.context.d.ts +7 -0
- package/lib/components/Toolbar/ToolbarToggleGroup/ToolbarToggleGroup.d.ts +42 -0
- package/lib/components/Toolbar/ToolbarToggleItem/ToolbarToggleItem.d.ts +22 -0
- package/lib/components/Toolbar/index.d.ts +32 -0
- package/lib/components/Toolbar/use-toolbar-navigation.d.ts +11 -0
- package/lib/components/Tooltip/Tooltip.d.ts +3 -1
- package/lib/components/Tooltip/use-tooltip.d.ts +2 -0
- package/lib/components/Tour/Tour.context.d.ts +66 -0
- package/lib/components/Tour/Tour.d.ts +144 -0
- package/lib/components/Tour/TourBeacon/TourBeacon.d.ts +23 -0
- package/lib/components/Tour/TourBeaconPositioned.d.ts +13 -0
- package/lib/components/Tour/TourBody/TourBody.d.ts +19 -0
- package/lib/components/Tour/TourCloseButton/TourCloseButton.d.ts +12 -0
- package/lib/components/Tour/TourNavigation/TourNavigation.d.ts +11 -0
- package/lib/components/Tour/TourOverlay/TourOverlay.d.ts +22 -0
- package/lib/components/Tour/TourRoot/TourRoot.d.ts +72 -0
- package/lib/components/Tour/TourStep/TourStep.d.ts +30 -0
- package/lib/components/Tour/TourTitle/TourTitle.d.ts +19 -0
- package/lib/components/Tour/TourTooltip/TourTooltip.d.ts +29 -0
- package/lib/components/Tour/get-overlay-hit-path.d.ts +2 -0
- package/lib/components/Tour/index.d.ts +23 -0
- package/lib/components/Tour/is-element-in-view.d.ts +1 -0
- package/lib/components/Tour/press-aware-auto-update.d.ts +2 -0
- package/lib/components/Tour/use-target-rect.d.ts +13 -0
- package/lib/components/Tour/use-tooltip-auto-focus.d.ts +7 -0
- package/lib/components/Tour/use-tour-state.d.ts +23 -0
- package/lib/components/Tour/use-tour.d.ts +40 -0
- package/lib/components/TreeSelect/TreeSelect.d.ts +14 -0
- package/lib/components/TreeSelect/index.d.ts +2 -2
- package/lib/components/index.d.ts +3 -0
- package/lib/core/Box/style-props/index.d.ts +1 -1
- package/lib/core/Box/style-props/style-props-data.d.ts +1 -1
- package/lib/core/styles-api/use-styles/use-styles.d.ts +2 -1
- package/lib/core/utils/shallow-equal/shallow-equal.d.ts +1 -0
- package/package.json +5 -5
- package/styles/ActionBar.css +1 -0
- package/styles/ActionBar.layer.css +1 -0
- package/styles/AppShell.css +68 -0
- package/styles/AppShell.layer.css +68 -0
- package/styles/Checkbox.css +20 -0
- package/styles/Checkbox.layer.css +20 -0
- package/styles/CheckboxIndicator.css +16 -0
- package/styles/CheckboxIndicator.layer.css +16 -0
- package/styles/Dialog.css +1 -0
- package/styles/Dialog.layer.css +1 -0
- package/styles/Marquee.css +1 -1
- package/styles/Marquee.layer.css +1 -1
- package/styles/Radio.css +10 -0
- package/styles/Radio.layer.css +10 -0
- package/styles/RadioIndicator.css +11 -0
- package/styles/RadioIndicator.layer.css +11 -0
- package/styles/Toggle.css +98 -0
- package/styles/Toggle.layer.css +99 -0
- package/styles/Toolbar.css +220 -0
- package/styles/Toolbar.layer.css +221 -0
- package/styles/Tour.css +127 -0
- package/styles/Tour.layer.css +128 -0
- package/styles.css +576 -1
- package/styles.layer.css +576 -1
|
@@ -8,7 +8,9 @@ function useHoverCard(settings) {
|
|
|
8
8
|
const [uncontrolledOpened, setUncontrolledOpened] = (0, react.useState)(settings.defaultOpened);
|
|
9
9
|
const opened = typeof settings.opened === "boolean" ? settings.opened : uncontrolledOpened;
|
|
10
10
|
const withinGroup = (0, react.use)(require_HoverCardGroup.HoverCardGroupContext).withinGroup;
|
|
11
|
-
const uid = (0, _mantine_hooks.useId)();
|
|
11
|
+
const uid = (0, _mantine_hooks.useId)(settings.id);
|
|
12
|
+
const openedRef = (0, react.useRef)(opened);
|
|
13
|
+
openedRef.current = opened;
|
|
12
14
|
const openTimeout = (0, react.useRef)(-1);
|
|
13
15
|
const closeTimeout = (0, react.useRef)(-1);
|
|
14
16
|
const targetRef = (0, react.useRef)(null);
|
|
@@ -20,6 +22,8 @@ function useHoverCard(settings) {
|
|
|
20
22
|
window.clearTimeout(closeTimeout.current);
|
|
21
23
|
}, []);
|
|
22
24
|
const onChange = (0, react.useCallback)((_opened) => {
|
|
25
|
+
if (openedRef.current === _opened) return;
|
|
26
|
+
openedRef.current = _opened;
|
|
23
27
|
setUncontrolledOpened(_opened);
|
|
24
28
|
if (_opened) {
|
|
25
29
|
setCurrentId(uid);
|
|
@@ -30,40 +34,49 @@ function useHoverCard(settings) {
|
|
|
30
34
|
settings.onOpen,
|
|
31
35
|
settings.onClose
|
|
32
36
|
]);
|
|
37
|
+
const onOpenChange = (0, react.useCallback)((_opened, _event, reason) => {
|
|
38
|
+
const wasOpened = openedRef.current;
|
|
39
|
+
onChange(_opened);
|
|
40
|
+
if (wasOpened && !_opened && (reason === "escape-key" || reason === "outside-press")) settings.onDismiss?.();
|
|
41
|
+
}, [onChange, settings.onDismiss]);
|
|
33
42
|
const { context, refs } = (0, _floating_ui_react.useFloating)({
|
|
34
43
|
open: opened,
|
|
35
|
-
onOpenChange
|
|
44
|
+
onOpenChange
|
|
36
45
|
});
|
|
37
46
|
const { delay: groupDelay, setCurrentId } = (0, _floating_ui_react.useDelayGroup)(context, { id: uid });
|
|
38
47
|
const { getReferenceProps, getFloatingProps } = (0, _floating_ui_react.useInteractions)([
|
|
39
48
|
(0, _floating_ui_react.useHover)(context, {
|
|
40
|
-
enabled:
|
|
49
|
+
enabled: settings.events.hover,
|
|
41
50
|
delay: withinGroup ? groupDelay : {
|
|
42
51
|
open: settings.openDelay,
|
|
43
52
|
close: settings.closeDelay
|
|
44
|
-
}
|
|
53
|
+
},
|
|
54
|
+
mouseOnly: !settings.events.touch,
|
|
55
|
+
handleClose: settings.interactive ? (0, _floating_ui_react.safePolygon)() : null
|
|
56
|
+
}),
|
|
57
|
+
(0, _floating_ui_react.useFocus)(context, {
|
|
58
|
+
enabled: settings.events.focus,
|
|
59
|
+
visibleOnly: true
|
|
45
60
|
}),
|
|
46
|
-
(0, _floating_ui_react.
|
|
47
|
-
|
|
61
|
+
(0, _floating_ui_react.useDismiss)(context, {
|
|
62
|
+
escapeKey: settings.closeOnEscape,
|
|
63
|
+
outsidePress: settings.closeOnClickOutside
|
|
64
|
+
})
|
|
48
65
|
]);
|
|
49
66
|
const openDropdown = (0, react.useCallback)(() => {
|
|
50
|
-
if (withinGroup) return;
|
|
51
67
|
clearTimeouts();
|
|
52
|
-
if (settings.openDelay
|
|
68
|
+
if (!settings.openDelay) onChange(true);
|
|
53
69
|
else openTimeout.current = window.setTimeout(() => onChange(true), settings.openDelay);
|
|
54
70
|
}, [
|
|
55
|
-
withinGroup,
|
|
56
71
|
clearTimeouts,
|
|
57
72
|
settings.openDelay,
|
|
58
73
|
onChange
|
|
59
74
|
]);
|
|
60
75
|
const closeDropdown = (0, react.useCallback)(() => {
|
|
61
|
-
if (withinGroup) return;
|
|
62
76
|
clearTimeouts();
|
|
63
|
-
if (settings.closeDelay
|
|
77
|
+
if (!settings.closeDelay) onChange(false);
|
|
64
78
|
else closeTimeout.current = window.setTimeout(() => onChange(false), settings.closeDelay);
|
|
65
79
|
}, [
|
|
66
|
-
withinGroup,
|
|
67
80
|
clearTimeouts,
|
|
68
81
|
settings.closeDelay,
|
|
69
82
|
onChange
|
|
@@ -90,6 +103,7 @@ function useHoverCard(settings) {
|
|
|
90
103
|
]);
|
|
91
104
|
return {
|
|
92
105
|
opened,
|
|
106
|
+
dropdownId: `${uid}-dropdown`,
|
|
93
107
|
reference: refs.setReference,
|
|
94
108
|
floating: refs.setFloating,
|
|
95
109
|
assignTarget,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-hover-card.cjs","names":["useState","use","HoverCardGroupContext","useId","useRef","useCallback","useFloating","useDelayGroup","useInteractions","useHover","
|
|
1
|
+
{"version":3,"file":"use-hover-card.cjs","names":["useState","use","HoverCardGroupContext","useId","useRef","useCallback","useFloating","useDelayGroup","useInteractions","useHover","safePolygon","useFocus","useDismiss"],"sources":["../../../src/components/HoverCard/use-hover-card.ts"],"sourcesContent":["import { use, useCallback, useEffect, useRef, useState } from 'react';\nimport {\n OpenChangeReason,\n safePolygon,\n useDelayGroup,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n} from '@floating-ui/react';\nimport { useId } from '@mantine/hooks';\nimport { HoverCardGroupContext } from './HoverCardGroup/HoverCardGroup';\n\ninterface UseHoverCard {\n openDelay?: number;\n closeDelay?: number;\n opened?: boolean;\n defaultOpened?: boolean;\n onOpen?: () => void;\n onClose?: () => void;\n events: { hover: boolean; focus: boolean; touch: boolean };\n interactive: boolean;\n closeOnEscape: boolean;\n closeOnClickOutside: boolean;\n onDismiss?: () => void;\n id?: string;\n}\n\nexport function useHoverCard(settings: UseHoverCard) {\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(HoverCardGroupContext).withinGroup;\n const uid = useId(settings.id);\n\n const openedRef = useRef(opened);\n openedRef.current = opened;\n\n const openTimeout = useRef(-1);\n const closeTimeout = useRef(-1);\n const targetRef = useRef<HTMLElement | null>(null);\n\n const assignTarget = useCallback((node: HTMLElement | null) => {\n targetRef.current = node;\n }, []);\n\n const clearTimeouts = useCallback(() => {\n window.clearTimeout(openTimeout.current);\n window.clearTimeout(closeTimeout.current);\n }, []);\n\n const onChange = useCallback(\n (_opened: boolean) => {\n if (openedRef.current === _opened) {\n return;\n }\n\n openedRef.current = _opened;\n setUncontrolledOpened(_opened);\n\n if (_opened) {\n setCurrentId(uid);\n settings.onOpen?.();\n } else {\n settings.onClose?.();\n }\n },\n [uid, settings.onOpen, settings.onClose]\n );\n\n const onOpenChange = useCallback(\n (_opened: boolean, _event?: Event, reason?: OpenChangeReason) => {\n const wasOpened = openedRef.current;\n onChange(_opened);\n\n if (wasOpened && !_opened && (reason === 'escape-key' || reason === 'outside-press')) {\n settings.onDismiss?.();\n }\n },\n [onChange, settings.onDismiss]\n );\n\n const { context, refs } = useFloating({\n open: opened,\n onOpenChange,\n });\n\n const { delay: groupDelay, 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 useDismiss(context, {\n escapeKey: settings.closeOnEscape,\n outsidePress: settings.closeOnClickOutside,\n }),\n ]);\n\n const openDropdown = useCallback(() => {\n clearTimeouts();\n if (!settings.openDelay) {\n onChange(true);\n } else {\n openTimeout.current = window.setTimeout(() => onChange(true), settings.openDelay);\n }\n }, [clearTimeouts, settings.openDelay, onChange]);\n\n const closeDropdown = useCallback(() => {\n clearTimeouts();\n if (!settings.closeDelay) {\n onChange(false);\n } else {\n closeTimeout.current = window.setTimeout(() => onChange(false), settings.closeDelay);\n }\n }, [clearTimeouts, settings.closeDelay, onChange]);\n\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => () => clearTimeouts(), [clearTimeouts]);\n\n useEffect(() => {\n if (!opened || withinGroup || typeof IntersectionObserver === 'undefined') {\n return undefined;\n }\n\n const node = targetRef.current;\n if (!node) {\n return undefined;\n }\n\n const observer = new IntersectionObserver(() => {\n if (!node.isConnected || node.getClientRects().length === 0) {\n clearTimeouts();\n onChangeRef.current(false);\n }\n });\n\n observer.observe(node);\n return () => observer.disconnect();\n }, [opened, withinGroup, clearTimeouts]);\n\n return {\n opened,\n dropdownId: `${uid}-dropdown`,\n reference: refs.setReference,\n floating: refs.setFloating,\n assignTarget,\n getReferenceProps,\n getFloatingProps,\n openDropdown,\n closeDropdown,\n };\n}\n"],"mappings":";;;;;;AA6BA,SAAgB,aAAa,UAAwB;CACnD,MAAM,CAAC,oBAAoB,0BAAA,GAAyBA,MAAAA,SAAAA,CAAS,SAAS,aAAa;CAEnF,MAAM,SADa,OAAO,SAAS,WAAW,YAClB,SAAS,SAAS;CAC9C,MAAM,eAAA,GAAcC,MAAAA,IAAAA,CAAIC,uBAAAA,qBAAqB,CAAC,CAAC;CAC/C,MAAM,OAAA,GAAMC,eAAAA,MAAAA,CAAM,SAAS,EAAE;CAE7B,MAAM,aAAA,GAAYC,MAAAA,OAAAA,CAAO,MAAM;CAC/B,UAAU,UAAU;CAEpB,MAAM,eAAA,GAAcA,MAAAA,OAAAA,CAAO,EAAE;CAC7B,MAAM,gBAAA,GAAeA,MAAAA,OAAAA,CAAO,EAAE;CAC9B,MAAM,aAAA,GAAYA,MAAAA,OAAAA,CAA2B,IAAI;CAEjD,MAAM,gBAAA,GAAeC,MAAAA,YAAAA,EAAa,SAA6B;EAC7D,UAAU,UAAU;CACtB,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAA,GAAgBA,MAAAA,YAAAA,OAAkB;EACtC,OAAO,aAAa,YAAY,OAAO;EACvC,OAAO,aAAa,aAAa,OAAO;CAC1C,GAAG,CAAC,CAAC;CAEL,MAAM,YAAA,GAAWA,MAAAA,YAAAA,EACd,YAAqB;EACpB,IAAI,UAAU,YAAY,SACxB;EAGF,UAAU,UAAU;EACpB,sBAAsB,OAAO;EAE7B,IAAI,SAAS;GACX,aAAa,GAAG;GAChB,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A,MAAAA,YAAAA,OAAkB;EACtC,cAAc;EACd,IAAI,CAAC,SAAS,YACZ,SAAS,KAAK;OAEd,aAAa,UAAU,OAAO,iBAAiB,SAAS,KAAK,GAAG,SAAS,UAAU;CAEvF,GAAG;EAAC;EAAe,SAAS;EAAY;CAAQ,CAAC;CAEjD,MAAM,eAAA,GAAcD,MAAAA,OAAAA,CAAO,QAAQ;CACnC,YAAY,UAAU;CAEtB,CAAA,GAAA,MAAA,UAAA,aAAsB,cAAc,GAAG,CAAC,aAAa,CAAC;CAEtD,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,UAAU,eAAe,OAAO,yBAAyB,aAC5D;EAGF,MAAM,OAAO,UAAU;EACvB,IAAI,CAAC,MACH;EAGF,MAAM,WAAW,IAAI,2BAA2B;GAC9C,IAAI,CAAC,KAAK,eAAe,KAAK,eAAe,CAAC,CAAC,WAAW,GAAG;IAC3D,cAAc;IACd,YAAY,QAAQ,KAAK;GAC3B;EACF,CAAC;EAED,SAAS,QAAQ,IAAI;EACrB,aAAa,SAAS,WAAW;CACnC,GAAG;EAAC;EAAQ;EAAa;CAAa,CAAC;CAEvC,OAAO;EACL;EACA,YAAY,GAAG,IAAI;EACnB,WAAW,KAAK;EAChB,UAAU,KAAK;EACf;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -117,7 +117,7 @@ const InputWrapper = require_factory.factory((_props) => {
|
|
|
117
117
|
getStyles,
|
|
118
118
|
describedBy,
|
|
119
119
|
inputId,
|
|
120
|
-
labelId,
|
|
120
|
+
labelId: _label && inputWrapperOrder.includes("label") ? labelId : void 0,
|
|
121
121
|
...require_get_input_offsets.getInputOffsets(inputWrapperOrder, {
|
|
122
122
|
hasDescription,
|
|
123
123
|
hasError: hasError || hasSuccess
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputWrapper.cjs","names":["createVarsResolver","getFontSize","rem","factory","useProps","useStyles","useId","InputLabel","InputDescription","Fragment","InputError","InputSuccess","InputWrapperContext","getInputOffsets","Box","classes"],"sources":["../../../../src/components/Input/InputWrapper/InputWrapper.tsx"],"sourcesContent":["import { Fragment } from 'react';\nimport { useId } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n factory,\n Factory,\n getFontSize,\n MantineFontSize,\n PlaceholderPolymorphicProps,\n rem,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../../core';\nimport {\n InputDescription,\n InputDescriptionCssVariables,\n InputDescriptionProps,\n InputDescriptionStylesNames,\n} from '../InputDescription/InputDescription';\nimport {\n InputError,\n InputErrorCssVariables,\n InputErrorProps,\n InputErrorStylesNames,\n} from '../InputError/InputError';\nimport {\n InputLabel,\n InputLabelCssVariables,\n InputLabelProps,\n InputLabelStylesNames,\n} from '../InputLabel/InputLabel';\nimport {\n InputSuccess,\n InputSuccessCssVariables,\n InputSuccessProps,\n InputSuccessStylesNames,\n} from '../InputSuccess/InputSuccess';\nimport { InputWrapperContext } from '../InputWrapper.context';\nimport { getInputOffsets } from './get-input-offsets/get-input-offsets';\nimport classes from '../Input.module.css';\n\nexport type InputWrapperCssVariables = InputLabelCssVariables &\n InputErrorCssVariables &\n InputSuccessCssVariables &\n InputDescriptionCssVariables;\n\nexport type InputWrapperStylesNames =\n | 'root'\n | InputLabelStylesNames\n | InputDescriptionStylesNames\n | InputErrorStylesNames\n | InputSuccessStylesNames;\n\nexport interface __InputWrapperProps {\n /** Contents of `Input.Label` component. If not set, label is not displayed. */\n label?: React.ReactNode;\n\n /** Contents of `Input.Description` component. If not set, description is not displayed. */\n description?: React.ReactNode;\n\n /** Contents of `Input.Error` component. If not set, error is not displayed. */\n error?: React.ReactNode;\n\n /** Contents of `Input.Success` component. If not set, success is not displayed. */\n success?: React.ReactNode;\n\n /** Adds required attribute to the input and a red asterisk on the right side of label @default false */\n required?: boolean;\n\n /** If set, the required asterisk is displayed next to the label. Overrides `required` prop. Does not add required attribute to the input. @default false */\n withAsterisk?: boolean;\n\n /** Props passed down to the `Input.Label` component */\n labelProps?: InputLabelProps & DataAttributes & PlaceholderPolymorphicProps;\n\n /** Props passed down to the `Input.Description` component */\n descriptionProps?: InputDescriptionProps & DataAttributes & PlaceholderPolymorphicProps;\n\n /** Props passed down to the `Input.Error` component */\n errorProps?: InputErrorProps & DataAttributes & PlaceholderPolymorphicProps;\n\n /** Props passed down to the `Input.Success` component */\n successProps?: InputSuccessProps & DataAttributes & PlaceholderPolymorphicProps;\n\n /** Render function to wrap the input element. Useful for adding tooltips, popovers, or other wrappers around the input. @default React.Fragment */\n inputContainer?: (children: React.ReactNode) => React.ReactNode;\n\n /** Controls order and visibility of wrapper elements. Only elements included in this array will be rendered. @default ['label', 'description', 'input', 'error'] */\n inputWrapperOrder?: ('label' | 'input' | 'description' | 'error')[];\n}\n\nexport interface InputWrapperProps\n extends __InputWrapperProps, BoxProps, StylesApiProps<InputWrapperFactory>, ElementProps<'div'> {\n __staticSelector?: string;\n\n /** Props passed to Styles API context, replaces Input.Wrapper props */\n __stylesApiProps?: Record<string, any>;\n\n /** Static id used as base to generate `aria-` attributes, by default generates random id */\n id?: string;\n\n /** Controls size of `Input.Label`, `Input.Description` and `Input.Error` components */\n size?: MantineFontSize;\n\n /** Root element for the label. Use `'div'` when wrapper contains multiple input elements and you need to handle `htmlFor` manually. @default 'label' */\n labelElement?: 'label' | 'div';\n}\n\nexport type InputWrapperFactory = Factory<{\n props: InputWrapperProps;\n ref: HTMLDivElement;\n stylesNames: InputWrapperStylesNames;\n vars: InputWrapperCssVariables;\n}>;\n\nconst defaultProps = {\n labelElement: 'label',\n inputContainer: (children) => children,\n inputWrapperOrder: ['label', 'description', 'input', 'error'],\n} satisfies Partial<InputWrapperProps>;\n\nconst varsResolver = createVarsResolver<InputWrapperFactory>((_, { size }) => ({\n label: {\n '--input-label-size': getFontSize(size),\n '--input-asterisk-color': undefined,\n },\n\n error: {\n '--input-error-size': size === undefined ? undefined : `calc(${getFontSize(size)} - ${rem(2)})`,\n },\n\n success: {\n '--input-success-size':\n size === undefined ? undefined : `calc(${getFontSize(size)} - ${rem(2)})`,\n },\n\n description: {\n '--input-description-size':\n size === undefined ? undefined : `calc(${getFontSize(size)} - ${rem(2)})`,\n },\n}));\n\nexport const InputWrapper = factory<InputWrapperFactory>((_props) => {\n const props = useProps('InputWrapper', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n variant,\n __staticSelector,\n inputContainer,\n inputWrapperOrder,\n label,\n error,\n success,\n description,\n labelProps,\n descriptionProps,\n errorProps,\n successProps,\n labelElement,\n children,\n withAsterisk,\n id,\n required,\n __stylesApiProps,\n mod,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<InputWrapperFactory>({\n name: ['InputWrapper', __staticSelector],\n props: __stylesApiProps || props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const sharedProps = {\n size,\n variant,\n __staticSelector,\n };\n\n const idBase = useId(id);\n const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;\n const errorId = errorProps?.id || `${idBase}-error`;\n const successId = successProps?.id || `${idBase}-success`;\n const descriptionId = descriptionProps?.id || `${idBase}-description`;\n const inputId = idBase;\n const hasError = !!error && typeof error !== 'boolean';\n const hasSuccess = !!success && typeof success !== 'boolean' && !error;\n const hasDescription = !!description;\n const errorRendered = hasError && inputWrapperOrder.includes('error');\n const successRendered = hasSuccess && inputWrapperOrder.includes('error');\n const descriptionRendered = hasDescription && inputWrapperOrder.includes('description');\n const _describedBy = `${errorRendered ? errorId : ''} ${successRendered ? successId : ''} ${descriptionRendered ? descriptionId : ''}`;\n const describedBy = _describedBy.trim().length > 0 ? _describedBy.trim() : undefined;\n const labelId = labelProps?.id || `${idBase}-label`;\n\n const _label = label && (\n <InputLabel\n key=\"label\"\n labelElement={labelElement}\n id={labelId}\n htmlFor={inputId}\n required={isRequired}\n {...sharedProps}\n {...labelProps}\n >\n {label}\n </InputLabel>\n );\n\n const _description = hasDescription && (\n <InputDescription\n key=\"description\"\n {...descriptionProps}\n {...sharedProps}\n size={descriptionProps?.size || sharedProps.size}\n id={descriptionProps?.id || descriptionId}\n >\n {description}\n </InputDescription>\n );\n\n const _input = <Fragment key=\"input\">{inputContainer(children)}</Fragment>;\n\n const _error = hasError && (\n <InputError\n {...errorProps}\n {...sharedProps}\n size={errorProps?.size || sharedProps.size}\n key=\"error\"\n id={errorProps?.id || errorId}\n >\n {error}\n </InputError>\n );\n\n const _success = hasSuccess && (\n <InputSuccess\n {...successProps}\n {...sharedProps}\n size={successProps?.size || sharedProps.size}\n key=\"success\"\n id={successProps?.id || successId}\n >\n {success}\n </InputSuccess>\n );\n\n const content = inputWrapperOrder.map((part) => {\n switch (part) {\n case 'label':\n return _label;\n case 'input':\n return _input;\n case 'description':\n return _description;\n case 'error':\n return _error || _success;\n default:\n return null;\n }\n });\n\n return (\n <InputWrapperContext\n value={{\n getStyles,\n describedBy,\n inputId,\n labelId,\n ...getInputOffsets(inputWrapperOrder, { hasDescription, hasError: hasError || hasSuccess }),\n }}\n >\n <Box\n variant={variant}\n size={size}\n mod={[{ error: !!error, success: !!success && !error }, mod]}\n id={labelElement === 'label' ? undefined : id}\n {...getStyles('root')}\n {...others}\n >\n {content}\n </Box>\n </InputWrapperContext>\n );\n});\n\nInputWrapper.classes = classes;\nInputWrapper.varsResolver = varsResolver;\nInputWrapper.displayName = '@mantine/core/InputWrapper';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwHA,MAAM,eAAe;CACnB,cAAc;CACd,iBAAiB,aAAa;CAC9B,mBAAmB;EAAC;EAAS;EAAe;EAAS;CAAO;AAC9D;AAEA,MAAM,eAAeA,6BAAAA,oBAAyC,GAAG,EAAE,YAAY;CAC7E,OAAO;EACL,sBAAsBC,iBAAAA,YAAY,IAAI;EACtC,0BAA0B,KAAA;CAC5B;CAEA,OAAO,EACL,sBAAsB,SAAS,KAAA,IAAY,KAAA,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AAO;GACT,KAAK,eACH,OAAO;GACT,KAAK,SACH,OAAO,UAAU;GACnB,SACE,OAAO;EACX;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,qBAAD;EACE,OAAO;GACL;GACA;GACA;GACA;GACA,GAAGC,0BAAAA,gBAAgB,mBAAmB;IAAE;IAAgB,UAAU,YAAY;GAAW,CAAC;EAC5F;EAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,YAAAA,KAAD;GACW;GACH;GACN,KAAK,CAAC;IAAE,OAAO,CAAC,CAAC;IAAO,SAAS,CAAC,CAAC,WAAW,CAAC;GAAM,GAAG,GAAG;GAC3D,IAAI,iBAAiB,UAAU,KAAA,IAAY;GAC3C,GAAI,UAAU,MAAM;GACpB,GAAI;GAEH,UAAA;EACE,CAAA;CACc,CAAA;AAEzB,CAAC;AAED,aAAa,UAAUC,qBAAAA;AACvB,aAAa,eAAe;AAC5B,aAAa,cAAc"}
|
|
1
|
+
{"version":3,"file":"InputWrapper.cjs","names":["createVarsResolver","getFontSize","rem","factory","useProps","useStyles","useId","InputLabel","InputDescription","Fragment","InputError","InputSuccess","InputWrapperContext","getInputOffsets","Box","classes"],"sources":["../../../../src/components/Input/InputWrapper/InputWrapper.tsx"],"sourcesContent":["import { Fragment } from 'react';\nimport { useId } from '@mantine/hooks';\nimport {\n Box,\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n factory,\n Factory,\n getFontSize,\n MantineFontSize,\n PlaceholderPolymorphicProps,\n rem,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../../core';\nimport {\n InputDescription,\n InputDescriptionCssVariables,\n InputDescriptionProps,\n InputDescriptionStylesNames,\n} from '../InputDescription/InputDescription';\nimport {\n InputError,\n InputErrorCssVariables,\n InputErrorProps,\n InputErrorStylesNames,\n} from '../InputError/InputError';\nimport {\n InputLabel,\n InputLabelCssVariables,\n InputLabelProps,\n InputLabelStylesNames,\n} from '../InputLabel/InputLabel';\nimport {\n InputSuccess,\n InputSuccessCssVariables,\n InputSuccessProps,\n InputSuccessStylesNames,\n} from '../InputSuccess/InputSuccess';\nimport { InputWrapperContext } from '../InputWrapper.context';\nimport { getInputOffsets } from './get-input-offsets/get-input-offsets';\nimport classes from '../Input.module.css';\n\nexport type InputWrapperCssVariables = InputLabelCssVariables &\n InputErrorCssVariables &\n InputSuccessCssVariables &\n InputDescriptionCssVariables;\n\nexport type InputWrapperStylesNames =\n | 'root'\n | InputLabelStylesNames\n | InputDescriptionStylesNames\n | InputErrorStylesNames\n | InputSuccessStylesNames;\n\nexport interface __InputWrapperProps {\n /** Contents of `Input.Label` component. If not set, label is not displayed. */\n label?: React.ReactNode;\n\n /** Contents of `Input.Description` component. If not set, description is not displayed. */\n description?: React.ReactNode;\n\n /** Contents of `Input.Error` component. If not set, error is not displayed. */\n error?: React.ReactNode;\n\n /** Contents of `Input.Success` component. If not set, success is not displayed. */\n success?: React.ReactNode;\n\n /** Adds required attribute to the input and a red asterisk on the right side of label @default false */\n required?: boolean;\n\n /** If set, the required asterisk is displayed next to the label. Overrides `required` prop. Does not add required attribute to the input. @default false */\n withAsterisk?: boolean;\n\n /** Props passed down to the `Input.Label` component */\n labelProps?: InputLabelProps & DataAttributes & PlaceholderPolymorphicProps;\n\n /** Props passed down to the `Input.Description` component */\n descriptionProps?: InputDescriptionProps & DataAttributes & PlaceholderPolymorphicProps;\n\n /** Props passed down to the `Input.Error` component */\n errorProps?: InputErrorProps & DataAttributes & PlaceholderPolymorphicProps;\n\n /** Props passed down to the `Input.Success` component */\n successProps?: InputSuccessProps & DataAttributes & PlaceholderPolymorphicProps;\n\n /** Render function to wrap the input element. Useful for adding tooltips, popovers, or other wrappers around the input. @default React.Fragment */\n inputContainer?: (children: React.ReactNode) => React.ReactNode;\n\n /** Controls order and visibility of wrapper elements. Only elements included in this array will be rendered. @default ['label', 'description', 'input', 'error'] */\n inputWrapperOrder?: ('label' | 'input' | 'description' | 'error')[];\n}\n\nexport interface InputWrapperProps\n extends __InputWrapperProps, BoxProps, StylesApiProps<InputWrapperFactory>, ElementProps<'div'> {\n __staticSelector?: string;\n\n /** Props passed to Styles API context, replaces Input.Wrapper props */\n __stylesApiProps?: Record<string, any>;\n\n /** Static id used as base to generate `aria-` attributes, by default generates random id */\n id?: string;\n\n /** Controls size of `Input.Label`, `Input.Description` and `Input.Error` components */\n size?: MantineFontSize;\n\n /** Root element for the label. Use `'div'` when wrapper contains multiple input elements and you need to handle `htmlFor` manually. @default 'label' */\n labelElement?: 'label' | 'div';\n}\n\nexport type InputWrapperFactory = Factory<{\n props: InputWrapperProps;\n ref: HTMLDivElement;\n stylesNames: InputWrapperStylesNames;\n vars: InputWrapperCssVariables;\n}>;\n\nconst defaultProps = {\n labelElement: 'label',\n inputContainer: (children) => children,\n inputWrapperOrder: ['label', 'description', 'input', 'error'],\n} satisfies Partial<InputWrapperProps>;\n\nconst varsResolver = createVarsResolver<InputWrapperFactory>((_, { size }) => ({\n label: {\n '--input-label-size': getFontSize(size),\n '--input-asterisk-color': undefined,\n },\n\n error: {\n '--input-error-size': size === undefined ? undefined : `calc(${getFontSize(size)} - ${rem(2)})`,\n },\n\n success: {\n '--input-success-size':\n size === undefined ? undefined : `calc(${getFontSize(size)} - ${rem(2)})`,\n },\n\n description: {\n '--input-description-size':\n size === undefined ? undefined : `calc(${getFontSize(size)} - ${rem(2)})`,\n },\n}));\n\nexport const InputWrapper = factory<InputWrapperFactory>((_props) => {\n const props = useProps('InputWrapper', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n size,\n variant,\n __staticSelector,\n inputContainer,\n inputWrapperOrder,\n label,\n error,\n success,\n description,\n labelProps,\n descriptionProps,\n errorProps,\n successProps,\n labelElement,\n children,\n withAsterisk,\n id,\n required,\n __stylesApiProps,\n mod,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<InputWrapperFactory>({\n name: ['InputWrapper', __staticSelector],\n props: __stylesApiProps || props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const sharedProps = {\n size,\n variant,\n __staticSelector,\n };\n\n const idBase = useId(id);\n const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;\n const errorId = errorProps?.id || `${idBase}-error`;\n const successId = successProps?.id || `${idBase}-success`;\n const descriptionId = descriptionProps?.id || `${idBase}-description`;\n const inputId = idBase;\n const hasError = !!error && typeof error !== 'boolean';\n const hasSuccess = !!success && typeof success !== 'boolean' && !error;\n const hasDescription = !!description;\n const errorRendered = hasError && inputWrapperOrder.includes('error');\n const successRendered = hasSuccess && inputWrapperOrder.includes('error');\n const descriptionRendered = hasDescription && inputWrapperOrder.includes('description');\n const _describedBy = `${errorRendered ? errorId : ''} ${successRendered ? successId : ''} ${descriptionRendered ? descriptionId : ''}`;\n const describedBy = _describedBy.trim().length > 0 ? _describedBy.trim() : undefined;\n const labelId = labelProps?.id || `${idBase}-label`;\n\n const _label = label && (\n <InputLabel\n key=\"label\"\n labelElement={labelElement}\n id={labelId}\n htmlFor={inputId}\n required={isRequired}\n {...sharedProps}\n {...labelProps}\n >\n {label}\n </InputLabel>\n );\n\n const _description = hasDescription && (\n <InputDescription\n key=\"description\"\n {...descriptionProps}\n {...sharedProps}\n size={descriptionProps?.size || sharedProps.size}\n id={descriptionProps?.id || descriptionId}\n >\n {description}\n </InputDescription>\n );\n\n const _input = <Fragment key=\"input\">{inputContainer(children)}</Fragment>;\n\n const _error = hasError && (\n <InputError\n {...errorProps}\n {...sharedProps}\n size={errorProps?.size || sharedProps.size}\n key=\"error\"\n id={errorProps?.id || errorId}\n >\n {error}\n </InputError>\n );\n\n const _success = hasSuccess && (\n <InputSuccess\n {...successProps}\n {...sharedProps}\n size={successProps?.size || sharedProps.size}\n key=\"success\"\n id={successProps?.id || successId}\n >\n {success}\n </InputSuccess>\n );\n\n const content = inputWrapperOrder.map((part) => {\n switch (part) {\n case 'label':\n return _label;\n case 'input':\n return _input;\n case 'description':\n return _description;\n case 'error':\n return _error || _success;\n default:\n return null;\n }\n });\n\n return (\n <InputWrapperContext\n value={{\n getStyles,\n describedBy,\n inputId,\n labelId: _label && inputWrapperOrder.includes('label') ? labelId : undefined,\n ...getInputOffsets(inputWrapperOrder, { hasDescription, hasError: hasError || hasSuccess }),\n }}\n >\n <Box\n variant={variant}\n size={size}\n mod={[{ error: !!error, success: !!success && !error }, mod]}\n id={labelElement === 'label' ? undefined : id}\n {...getStyles('root')}\n {...others}\n >\n {content}\n </Box>\n </InputWrapperContext>\n );\n});\n\nInputWrapper.classes = classes;\nInputWrapper.varsResolver = varsResolver;\nInputWrapper.displayName = '@mantine/core/InputWrapper';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwHA,MAAM,eAAe;CACnB,cAAc;CACd,iBAAiB,aAAa;CAC9B,mBAAmB;EAAC;EAAS;EAAe;EAAS;CAAO;AAC9D;AAEA,MAAM,eAAeA,6BAAAA,oBAAyC,GAAG,EAAE,YAAY;CAC7E,OAAO;EACL,sBAAsBC,iBAAAA,YAAY,IAAI;EACtC,0BAA0B,KAAA;CAC5B;CAEA,OAAO,EACL,sBAAsB,SAAS,KAAA,IAAY,KAAA,IAAY,QAAQA,iBAAAA,YAAY,IAAI,EAAE,KAAKC,YAAAA,IAAI,CAAC,EAAE,GAC/F;CAEA,SAAS,EACP,wBACE,SAAS,KAAA,IAAY,KAAA,IAAY,QAAQD,iBAAAA,YAAY,IAAI,EAAE,KAAKC,YAAAA,IAAI,CAAC,EAAE,GAC3E;CAEA,aAAa,EACX,4BACE,SAAS,KAAA,IAAY,KAAA,IAAY,QAAQD,iBAAAA,YAAY,IAAI,EAAE,KAAKC,YAAAA,IAAI,CAAC,EAAE,GAC3E;AACF,EAAE;AAEF,MAAa,eAAeC,gBAAAA,SAA8B,WAAW;CACnE,MAAM,QAAQC,kBAAAA,SAAS,gBAAgB,cAAc,MAAM;CAC3D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA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BAAiB,UAAU,KAAA,IAAY;GAC3C,GAAI,UAAU,MAAM;GACpB,GAAI;GAEH,UAAA;EACE,CAAA;CACc,CAAA;AAEzB,CAAC;AAED,aAAa,UAAUC,qBAAAA;AACvB,aAAa,eAAe;AAC5B,aAAa,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marquee.cjs","names":["createVarsResolver","getSpacing","factory","useProps","useStyles","Box","classes"],"sources":["../../../src/components/Marquee/Marquee.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getSpacing,\n MantineSpacing,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport classes from './Marquee.module.css';\n\nexport type MarqueeStylesNames = 'root' | 'content' | 'group';\nexport type MarqueeCssVariables = {\n root:\n | '--marquee-duration'\n | '--marquee-gap'\n | '--marquee-repeat'\n | '--marquee-fade-color'\n | '--marquee-fade-size';\n};\n\nexport interface MarqueeProps\n extends BoxProps, StylesApiProps<MarqueeFactory>, ElementProps<'div'> {\n /** Reverses animation direction @default false */\n reverse?: boolean;\n\n /** Pauses animation on hover @default false */\n pauseOnHover?: boolean;\n\n /** Content to scroll */\n children: React.ReactNode;\n\n /** Scroll orientation @default 'horizontal' */\n orientation?: 'horizontal' | 'vertical';\n\n /** Number of times children are repeated inline for seamless scrolling @default 4 */\n repeat?: number;\n\n /** Animation duration in ms @default
|
|
1
|
+
{"version":3,"file":"Marquee.cjs","names":["createVarsResolver","getSpacing","factory","useProps","useStyles","Box","classes"],"sources":["../../../src/components/Marquee/Marquee.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n createVarsResolver,\n ElementProps,\n factory,\n Factory,\n getSpacing,\n MantineSpacing,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport classes from './Marquee.module.css';\n\nexport type MarqueeStylesNames = 'root' | 'content' | 'group';\nexport type MarqueeCssVariables = {\n root:\n | '--marquee-duration'\n | '--marquee-gap'\n | '--marquee-repeat'\n | '--marquee-fade-color'\n | '--marquee-fade-size';\n};\n\nexport interface MarqueeProps\n extends BoxProps, StylesApiProps<MarqueeFactory>, ElementProps<'div'> {\n /** Reverses animation direction @default false */\n reverse?: boolean;\n\n /** Pauses animation on hover @default false */\n pauseOnHover?: boolean;\n\n /** Content to scroll */\n children: React.ReactNode;\n\n /** Scroll orientation @default 'horizontal' */\n orientation?: 'horizontal' | 'vertical';\n\n /** Number of times children are repeated inline for seamless scrolling @default 4 */\n repeat?: number;\n\n /** Animation duration in ms @default 100000 */\n duration?: number;\n\n /** Gap between repeated children, key of `theme.spacing` or any valid CSS value @default 'md' */\n gap?: MantineSpacing;\n\n /** Whether to show gradient fade on edges, @default true */\n fadeEdges?: boolean;\n\n /** Color of the fade gradient, @default 'var(--mantine-color-body)' */\n fadeEdgeColor?: string;\n\n /** Size of the fade gradient, @default '5%' */\n fadeEdgeSize?: string;\n}\n\nexport type MarqueeFactory = Factory<{\n props: MarqueeProps;\n ref: HTMLDivElement;\n stylesNames: MarqueeStylesNames;\n vars: MarqueeCssVariables;\n}>;\n\nconst defaultProps = {\n repeat: 4,\n duration: 100_000,\n orientation: 'horizontal',\n fadeEdges: true,\n} satisfies Partial<MarqueeProps>;\n\nconst varsResolver = createVarsResolver<MarqueeFactory>(\n (_, { duration, gap, repeat, fadeEdgeColor, fadeEdgeSize }) => ({\n root: {\n '--marquee-duration': `${duration}ms`,\n '--marquee-gap': getSpacing(gap),\n '--marquee-repeat': (repeat ?? 4).toString(),\n '--marquee-fade-color': fadeEdgeColor,\n '--marquee-fade-size': fadeEdgeSize,\n },\n })\n);\n\nexport const Marquee = factory<MarqueeFactory>((_props) => {\n const props = useProps('Marquee', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n children,\n reverse,\n pauseOnHover,\n orientation,\n repeat,\n duration,\n gap,\n fadeEdges,\n fadeEdgeColor,\n fadeEdgeSize,\n mod,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<MarqueeFactory>({\n name: 'Marquee',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const repeatedChildren = Array(repeat)\n .fill(0)\n .map((_, index) => (\n <div key={index} {...getStyles('group')}>\n {children}\n </div>\n ));\n\n return (\n <Box\n {...getStyles('root')}\n mod={[{ orientation, reverse, pauseOnHover, 'fade-edges': fadeEdges }, mod]}\n {...others}\n >\n <div {...getStyles('content')}>{repeatedChildren}</div>\n </Box>\n );\n});\n\nMarquee.classes = classes;\nMarquee.varsResolver = varsResolver;\nMarquee.displayName = '@mantine/core/Marquee';\n\nexport namespace Marquee {\n export type Props = MarqueeProps;\n export type StylesNames = MarqueeStylesNames;\n export type CssVariables = MarqueeCssVariables;\n export type Factory = MarqueeFactory;\n}\n"],"mappings":";;;;;;;;;;AAiEA,MAAM,eAAe;CACnB,QAAQ;CACR,UAAU;CACV,aAAa;CACb,WAAW;AACb;AAEA,MAAM,eAAeA,6BAAAA,oBAClB,GAAG,EAAE,UAAU,KAAK,QAAQ,eAAe,oBAAoB,EAC9D,MAAM;CACJ,sBAAsB,GAAG,SAAS;CAClC,iBAAiBC,iBAAAA,WAAW,GAAG;CAC/B,qBAAqB,UAAU,EAAA,CAAG,SAAS;CAC3C,wBAAwB;CACxB,uBAAuB;AACzB,EACF,EACF;AAEA,MAAa,UAAUC,gBAAAA,SAAyB,WAAW;CACzD,MAAM,QAAQC,kBAAAA,SAAS,WAAW,cAAc,MAAM;CACtD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,SACA,cACA,aACA,QACA,UACA,KACA,WACA,eACA,cACA,KACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAYC,mBAAAA,UAA0B;EAC1C,MAAM;EACN,SAAA,uBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,mBAAmB,MAAM,MAAM,CAAC,CACnC,KAAK,CAAC,CAAC,CACP,KAAK,GAAG,UACP,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAiB,GAAI,UAAU,OAAO;EACnC;CACE,GAFK,KAEL,CACN;CAEH,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,YAAAA,KAAD;EACE,GAAI,UAAU,MAAM;EACpB,KAAK,CAAC;GAAE;GAAa;GAAS;GAAc,cAAc;EAAU,GAAG,GAAG;EAC1E,GAAI;EAEJ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,GAAI,UAAU,SAAS;GAAI,UAAA;EAAsB,CAAA;CACnD,CAAA;AAET,CAAC;AAED,QAAQ,UAAUC,uBAAAA;AAClB,QAAQ,eAAe;AACvB,QAAQ,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marquee.module.cjs","names":[],"sources":["../../../src/components/Marquee/Marquee.module.css"],"sourcesContent":["@keyframes marquee-horizontal {\n from {\n transform: translateX(0);\n }\n\n to {\n transform: translateX(\n calc(\n -100% / var(--marquee-repeat, 4) - var(--marquee-gap, var(--mantine-spacing-md)) /\n var(--marquee-repeat, 4)\n )\n );\n }\n}\n\n@keyframes marquee-vertical {\n from {\n transform: translateY(0);\n }\n\n to {\n transform: translateY(\n calc(\n -100% / var(--marquee-repeat, 4) - var(--marquee-gap, var(--mantine-spacing-md)) /\n var(--marquee-repeat, 4)\n )\n );\n }\n}\n\n.root {\n --_fade-color: var(--marquee-fade-color, var(--mantine-color-body));\n --_fade-size: var(--marquee-fade-size, 5%);\n\n position: relative;\n overflow: hidden;\n display: flex;\n max-height: 100%;\n max-width: 100%;\n\n &:where([data-orientation='horizontal']) {\n flex-direction: row;\n }\n\n &:where([data-orientation='vertical']) {\n flex-direction: column;\n }\n\n /* Fade edges using pseudo-elements */\n &[data-fade-edges]::before,\n &[data-fade-edges]::after {\n content: '';\n position: absolute;\n z-index: 1;\n pointer-events: none;\n }\n\n /* Horizontal fade edges */\n &[data-orientation='horizontal'][data-fade-edges]::before,\n &[data-orientation='horizontal'][data-fade-edges]::after {\n top: 0;\n bottom: 0;\n width: var(--_fade-size);\n }\n\n &[data-orientation='horizontal'][data-fade-edges]::before {\n left: 0;\n background: linear-gradient(to right, var(--_fade-color), transparent);\n }\n\n &[data-orientation='horizontal'][data-fade-edges]::after {\n right: 0;\n background: linear-gradient(to left, var(--_fade-color), transparent);\n }\n\n /* Vertical fade edges */\n &[data-orientation='vertical'][data-fade-edges]::before,\n &[data-orientation='vertical'][data-fade-edges]::after {\n left: 0;\n right: 0;\n height: var(--_fade-size);\n }\n\n &[data-orientation='vertical'][data-fade-edges]::before {\n top: 0;\n background: linear-gradient(to bottom, var(--_fade-color), transparent);\n }\n\n &[data-orientation='vertical'][data-fade-edges]::after {\n bottom: 0;\n background: linear-gradient(to top, var(--_fade-color), transparent);\n }\n}\n\n.content {\n display: flex;\n gap: var(--marquee-gap, var(--mantine-spacing-md));\n animation-duration: var(--marquee-duration,
|
|
1
|
+
{"version":3,"file":"Marquee.module.cjs","names":[],"sources":["../../../src/components/Marquee/Marquee.module.css"],"sourcesContent":["@keyframes marquee-horizontal {\n from {\n transform: translateX(0);\n }\n\n to {\n transform: translateX(\n calc(\n -100% / var(--marquee-repeat, 4) - var(--marquee-gap, var(--mantine-spacing-md)) /\n var(--marquee-repeat, 4)\n )\n );\n }\n}\n\n@keyframes marquee-vertical {\n from {\n transform: translateY(0);\n }\n\n to {\n transform: translateY(\n calc(\n -100% / var(--marquee-repeat, 4) - var(--marquee-gap, var(--mantine-spacing-md)) /\n var(--marquee-repeat, 4)\n )\n );\n }\n}\n\n.root {\n --_fade-color: var(--marquee-fade-color, var(--mantine-color-body));\n --_fade-size: var(--marquee-fade-size, 5%);\n\n position: relative;\n overflow: hidden;\n display: flex;\n max-height: 100%;\n max-width: 100%;\n\n &:where([data-orientation='horizontal']) {\n flex-direction: row;\n }\n\n &:where([data-orientation='vertical']) {\n flex-direction: column;\n }\n\n /* Fade edges using pseudo-elements */\n &[data-fade-edges]::before,\n &[data-fade-edges]::after {\n content: '';\n position: absolute;\n z-index: 1;\n pointer-events: none;\n }\n\n /* Horizontal fade edges */\n &[data-orientation='horizontal'][data-fade-edges]::before,\n &[data-orientation='horizontal'][data-fade-edges]::after {\n top: 0;\n bottom: 0;\n width: var(--_fade-size);\n }\n\n &[data-orientation='horizontal'][data-fade-edges]::before {\n left: 0;\n background: linear-gradient(to right, var(--_fade-color), transparent);\n }\n\n &[data-orientation='horizontal'][data-fade-edges]::after {\n right: 0;\n background: linear-gradient(to left, var(--_fade-color), transparent);\n }\n\n /* Vertical fade edges */\n &[data-orientation='vertical'][data-fade-edges]::before,\n &[data-orientation='vertical'][data-fade-edges]::after {\n left: 0;\n right: 0;\n height: var(--_fade-size);\n }\n\n &[data-orientation='vertical'][data-fade-edges]::before {\n top: 0;\n background: linear-gradient(to bottom, var(--_fade-color), transparent);\n }\n\n &[data-orientation='vertical'][data-fade-edges]::after {\n bottom: 0;\n background: linear-gradient(to top, var(--_fade-color), transparent);\n }\n}\n\n.content {\n display: flex;\n gap: var(--marquee-gap, var(--mantine-spacing-md));\n animation-duration: var(--marquee-duration, 100000ms);\n animation-timing-function: linear;\n animation-iteration-count: infinite;\n\n .root[data-orientation='horizontal'] > & {\n flex-direction: row;\n animation-name: marquee-horizontal;\n }\n\n .root[data-orientation='vertical'] > & {\n flex-direction: column;\n animation-name: marquee-vertical;\n }\n\n .root[data-reverse] > & {\n animation-direction: reverse;\n }\n\n .root[data-pause-on-hover]:hover > & {\n animation-play-state: paused;\n }\n}\n\n.group {\n display: flex;\n flex-shrink: 0;\n gap: var(--marquee-gap, var(--mantine-spacing-md));\n\n .root[data-orientation='horizontal'] & {\n flex-direction: row;\n }\n\n .root[data-orientation='vertical'] & {\n flex-direction: column;\n }\n}\n"],"mappings":""}
|
|
@@ -8,10 +8,12 @@ const require_use_styles = require("../../core/styles-api/use-styles/use-styles.
|
|
|
8
8
|
const require_extract_style_props = require("../../core/Box/style-props/extract-style-props/extract-style-props.cjs");
|
|
9
9
|
const require_factory = require("../../core/factory/factory.cjs");
|
|
10
10
|
const require_ActionIcon = require("../ActionIcon/ActionIcon.cjs");
|
|
11
|
+
const require_InputWrapper_context = require("../Input/InputWrapper.context.cjs");
|
|
11
12
|
const require_Input = require("../Input/Input.cjs");
|
|
12
13
|
const require_InputBase = require("../InputBase/InputBase.cjs");
|
|
13
14
|
const require_PasswordToggleIcon = require("./PasswordToggleIcon.cjs");
|
|
14
15
|
const require_PasswordInput_module = require("./PasswordInput.module.cjs");
|
|
16
|
+
let react = require("react");
|
|
15
17
|
let _mantine_hooks = require("@mantine/hooks");
|
|
16
18
|
let clsx = require("clsx");
|
|
17
19
|
clsx = require_runtime.__toESM(clsx);
|
|
@@ -26,6 +28,13 @@ const varsResolver = require_create_vars_resolver.createVarsResolver((_, { size
|
|
|
26
28
|
"--psi-icon-size": require_get_size.getSize(size, "psi-icon-size"),
|
|
27
29
|
"--psi-button-size": require_get_size.getSize(size, "psi-button-size")
|
|
28
30
|
} }));
|
|
31
|
+
function PasswordInputField(props) {
|
|
32
|
+
const ctx = (0, react.use)(require_InputWrapper_context.InputWrapperContext);
|
|
33
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
34
|
+
...props,
|
|
35
|
+
"aria-describedby": ctx?.describedBy
|
|
36
|
+
});
|
|
37
|
+
}
|
|
29
38
|
const PasswordInput = require_factory.factory((_props) => {
|
|
30
39
|
const props = require_use_props.useProps([
|
|
31
40
|
"Input",
|
|
@@ -63,9 +72,6 @@ const PasswordInput = require_factory.factory((_props) => {
|
|
|
63
72
|
const errorId = errorProps?.id || `${uuid}-error`;
|
|
64
73
|
const successId = successProps?.id || `${uuid}-success`;
|
|
65
74
|
const descriptionId = descriptionProps?.id || `${uuid}-description`;
|
|
66
|
-
const hasError = !!error && typeof error !== "boolean";
|
|
67
|
-
const _describedBy = `${hasError ? errorId : ""} ${!!success && typeof success !== "boolean" && !hasError ? successId : ""} ${!!description ? descriptionId : ""}`;
|
|
68
|
-
const describedBy = _describedBy.trim().length > 0 ? _describedBy.trim() : void 0;
|
|
69
75
|
const visibilityToggleButton = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ActionIcon.ActionIcon, {
|
|
70
76
|
...getStyles("visibilityToggle"),
|
|
71
77
|
disabled,
|
|
@@ -163,7 +169,7 @@ const PasswordInput = require_factory.factory((_props) => {
|
|
|
163
169
|
withErrorStyles,
|
|
164
170
|
withSuccessStyles,
|
|
165
171
|
attributes,
|
|
166
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
172
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PasswordInputField, {
|
|
167
173
|
required,
|
|
168
174
|
"data-invalid": !!error || void 0,
|
|
169
175
|
"data-with-left-section": !!leftSection || void 0,
|
|
@@ -172,7 +178,6 @@ const PasswordInput = require_factory.factory((_props) => {
|
|
|
172
178
|
id: uuid,
|
|
173
179
|
dir,
|
|
174
180
|
...rest,
|
|
175
|
-
"aria-describedby": describedBy,
|
|
176
181
|
autoComplete: rest.autoComplete || "off",
|
|
177
182
|
type: _visible ? "text" : "password"
|
|
178
183
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordInput.cjs","names":["PasswordToggleIcon","createVarsResolver","getSize","factory","useProps","useId","useUncontrolled","useStyles","useResolvedStylesApi","extractStyleProps","ActionIcon","Input","cx","classes","InputBase"],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["import cx from 'clsx';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getSize,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { ActionIcon } from '../ActionIcon';\nimport { __BaseInputProps, __InputStylesNames, Input, InputVariant } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PasswordToggleIcon } from './PasswordToggleIcon';\nimport classes from './PasswordInput.module.css';\n\nexport type PasswordInputStylesNames =\n | 'root'\n | 'visibilityToggle'\n | 'innerInput'\n | __InputStylesNames;\nexport type PasswordInputCssVariables = {\n root: '--psi-icon-size' | '--psi-button-size';\n};\n\nexport interface PasswordInputProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<PasswordInputFactory>,\n ElementProps<'input', 'size'> {\n /** A component to replace the visibility toggle icon */\n visibilityToggleIcon?: React.FC<{ reveal: boolean }>;\n\n /** Props passed down to the visibility toggle button */\n visibilityToggleButtonProps?: Record<string, any>;\n\n /** If set, the visibility toggle button is focusable with keyboard @default `false` */\n visibilityToggleFocusable?: boolean;\n\n /** If set, the input value is visible */\n visible?: boolean;\n\n /** If set, the input value is visible by default */\n defaultVisible?: boolean;\n\n /** Called when visibility changes */\n onVisibilityChange?: (visible: boolean) => void;\n}\n\nexport type PasswordInputFactory = Factory<{\n props: PasswordInputProps;\n ref: HTMLInputElement;\n stylesNames: PasswordInputStylesNames;\n vars: PasswordInputCssVariables;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n visibilityToggleIcon: PasswordToggleIcon,\n visibilityToggleFocusable: false,\n size: 'sm',\n} satisfies Partial<PasswordInputProps>;\n\nconst varsResolver = createVarsResolver<PasswordInputFactory>((_, { size }) => ({\n root: {\n '--psi-icon-size': getSize(size, 'psi-icon-size'),\n '--psi-button-size': getSize(size, 'psi-button-size'),\n },\n}));\n\nexport const PasswordInput = factory<PasswordInputFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'PasswordInput'], defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n required,\n error,\n success,\n leftSection,\n disabled,\n id,\n variant,\n inputContainer,\n description,\n label,\n size,\n errorProps,\n successProps,\n descriptionProps,\n labelProps,\n withAsterisk,\n inputWrapperOrder,\n wrapperProps,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n leftSectionWidth,\n visible,\n defaultVisible,\n onVisibilityChange,\n visibilityToggleIcon: VisibilityToggleIcon,\n visibilityToggleButtonProps,\n visibilityToggleFocusable,\n rightSectionProps,\n leftSectionProps,\n leftSectionPointerEvents,\n withErrorStyles,\n withSuccessStyles,\n mod,\n attributes,\n dir,\n ...others\n } = props;\n\n const uuid = useId(id);\n\n const [_visible, setVisibility] = useUncontrolled({\n value: visible,\n defaultValue: defaultVisible,\n finalValue: false,\n onChange: onVisibilityChange,\n });\n\n const toggleVisibility = () => setVisibility(!_visible);\n\n const getStyles = useStyles<PasswordInputFactory>({\n name: 'PasswordInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PasswordInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const { styleProps, rest } = extractStyleProps(others);\n const errorId = errorProps?.id || `${uuid}-error`;\n const successId = successProps?.id || `${uuid}-success`;\n const descriptionId = descriptionProps?.id || `${uuid}-description`;\n const hasError = !!error && typeof error !== 'boolean';\n const hasSuccess = !!success && typeof success !== 'boolean';\n const hasDescription = !!description;\n const _describedBy = `${hasError ? errorId : ''} ${hasSuccess && !hasError ? successId : ''} ${hasDescription ? descriptionId : ''}`;\n const describedBy = _describedBy.trim().length > 0 ? _describedBy.trim() : undefined;\n\n const visibilityToggleButton = (\n <ActionIcon<'button'>\n {...getStyles('visibilityToggle')}\n disabled={disabled}\n radius={radius}\n aria-pressed={_visible}\n tabIndex={visibilityToggleFocusable ? 0 : -1}\n aria-label=\"Toggle password visibility\"\n {...visibilityToggleButtonProps}\n variant={visibilityToggleButtonProps?.variant ?? 'subtle'}\n color=\"gray\"\n unstyled={unstyled}\n onTouchEnd={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onTouchEnd?.(event);\n toggleVisibility();\n }}\n onMouseDown={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onMouseDown?.(event);\n toggleVisibility();\n }}\n onKeyDown={(event) => {\n visibilityToggleButtonProps?.onKeyDown?.(event);\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n toggleVisibility();\n }\n }}\n >\n <VisibilityToggleIcon reveal={_visible} />\n </ActionIcon>\n );\n\n return (\n <Input.Wrapper\n required={required}\n id={uuid}\n label={label}\n error={error}\n success={success}\n description={description}\n size={size}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n unstyled={unstyled}\n withAsterisk={withAsterisk}\n inputWrapperOrder={inputWrapperOrder}\n inputContainer={inputContainer}\n variant={variant}\n labelProps={{ ...labelProps, htmlFor: uuid }}\n descriptionProps={{ ...descriptionProps, id: descriptionId }}\n errorProps={{ ...errorProps, id: errorId }}\n successProps={{ ...successProps, id: successId }}\n mod={mod}\n attributes={attributes}\n {...getStyles('root')}\n {...styleProps}\n {...wrapperProps}\n >\n <Input\n component=\"div\"\n dir={dir}\n error={error}\n success={success}\n leftSection={leftSection}\n size={size}\n classNames={{ ...resolvedClassNames, input: cx(classes.input, resolvedClassNames?.input) }}\n styles={resolvedStyles}\n radius={radius}\n disabled={disabled}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n rightSectionWidth={rightSectionWidth}\n rightSection={rightSection ?? visibilityToggleButton}\n variant={variant}\n unstyled={unstyled}\n leftSectionWidth={leftSectionWidth}\n rightSectionPointerEvents={rightSectionPointerEvents || 'all'}\n rightSectionProps={rightSectionProps}\n leftSectionProps={leftSectionProps}\n leftSectionPointerEvents={leftSectionPointerEvents}\n withAria={false}\n withErrorStyles={withErrorStyles}\n withSuccessStyles={withSuccessStyles}\n attributes={attributes}\n >\n <input\n required={required}\n data-invalid={!!error || undefined}\n data-with-left-section={!!leftSection || undefined}\n {...getStyles('innerInput')}\n disabled={disabled}\n id={uuid}\n dir={dir}\n {...rest}\n aria-describedby={describedBy}\n autoComplete={rest.autoComplete || 'off'}\n type={_visible ? 'text' : 'password'}\n />\n </Input>\n </Input.Wrapper>\n );\n});\n\nPasswordInput.classes = { ...InputBase.classes, ...classes };\nPasswordInput.varsResolver = varsResolver;\nPasswordInput.displayName = '@mantine/core/PasswordInput';\n\nexport namespace PasswordInput {\n export type Props = PasswordInputProps;\n export type StylesNames = PasswordInputStylesNames;\n export type CssVariables = PasswordInputCssVariables;\n export type Factory = PasswordInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+DA,MAAM,eAAe;CACnB,sBAAsBA,2BAAAA;CACtB,2BAA2B;CAC3B,MAAM;AACR;AAEA,MAAM,eAAeC,6BAAAA,oBAA0C,GAAG,EAAE,YAAY,EAC9E,MAAM;CACJ,mBAAmBC,iBAAAA,QAAQ,MAAM,eAAe;CAChD,qBAAqBA,iBAAAA,QAAQ,MAAM,iBAAiB;AACtD,EACF,EAAE;AAEF,MAAa,gBAAgBC,gBAAAA,SAA+B,WAAW;CACrE,MAAM,QAAQC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;CAAe,GAAG,cAAc,MAAM;CACvF,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,OACA,SACA,aACA,UACA,IACA,SACA,gBACA,aACA,OACA,MACA,YACA,cACA,kBACA,YACA,cACA,mBACA,cACA,QACA,cACA,mBACA,2BACA,kBACA,SACA,gBACA,oBACA,sBAAsB,sBACtB,6BACA,2BACA,mBACA,kBACA,0BACA,iBACA,mBACA,KACA,YACA,KACA,GAAG,WACD;CAEJ,MAAM,QAAA,GAAOC,eAAAA,MAAAA,CAAM,EAAE;CAErB,MAAM,CAAC,UAAU,kBAAA,GAAiBC,eAAAA,gBAAAA,CAAgB;EAChD,OAAO;EACP,cAAc;EACd,YAAY;EACZ,UAAU;CACZ,CAAC;CAED,MAAM,yBAAyB,cAAc,CAAC,QAAQ;CAEtD,MAAM,YAAYC,mBAAAA,UAAgC;EAChD,MAAM;EACN,SAAA,6BAAA;EACA;EACA;EACA;EACA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AP;EACY;EACV,IAAI;EACG;EACA;EACE;EACI;EACP;EACN,YAAY;EACZ,QAAQ;EACR,kBAAiB;EACjB,kBAAkB;EACR;EACI;EACK;EACH;EACP;EACT,YAAY;GAAE,GAAG;GAAY,SAAS;EAAK;EAC3C,kBAAkB;GAAE,GAAG;GAAkB,IAAI;EAAc;EAC3D,YAAY;GAAE,GAAG;GAAY,IAAI;EAAQ;EACzC,cAAc;GAAE,GAAG;GAAc,IAAI;EAAU;EAC1C;EACO;EACZ,GAAI,UAAU,MAAM;EACpB,GAAI;EACJ,GAAI;EAEJ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAD;GACE,WAAU;GACL;GACE;GACE;GACI;GACP;GACN,YAAY;IAAE,GAAG;IAAoB,QAAA,GAAOC,KAAAA,QAAAA,CAAGC,6BAAAA,QAAQ,OAAO,oBAAoB,KAAK;GAAE;GACzF,QAAQ;GACA;GACE;GACV,kBAAiB;GACjB,kBAAkB;GACC;GACnB,cAAc,gBAAgB;GACrB;GACC;GACQ;GAClB,2BAA2B,6BAA6B;GACrC;GACD;GACQ;GAC1B,UAAU;GACO;GACE;GACP;GAEZ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;IACY;IACV,gBAAc,CAAC,CAAC,SAAS,KAAA;IACzB,0BAAwB,CAAC,CAAC,eAAe,KAAA;IACzC,GAAI,UAAU,YAAY;IAChB;IACV,IAAI;IACC;IACL,GAAI;IACJ,oBAAkB;IAClB,cAAc,KAAK,gBAAgB;IACnC,MAAM,WAAW,SAAS;GAC3B,CAAA;EACI,CAAA;CACM,CAAA;AAEnB,CAAC;AAED,cAAc,UAAU;CAAE,GAAGC,kBAAAA,UAAU;CAAS,GAAGD,6BAAAA;AAAQ;AAC3D,cAAc,eAAe;AAC7B,cAAc,cAAc"}
|
|
1
|
+
{"version":3,"file":"PasswordInput.cjs","names":["PasswordToggleIcon","createVarsResolver","getSize","use","InputWrapperContext","factory","useProps","useId","useUncontrolled","useStyles","useResolvedStylesApi","extractStyleProps","ActionIcon","Input","cx","classes","InputBase"],"sources":["../../../src/components/PasswordInput/PasswordInput.tsx"],"sourcesContent":["import { use } from 'react';\nimport cx from 'clsx';\nimport { useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n ElementProps,\n extractStyleProps,\n factory,\n Factory,\n getSize,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { ActionIcon } from '../ActionIcon';\nimport {\n __BaseInputProps,\n __InputStylesNames,\n Input,\n InputVariant,\n InputWrapperContext,\n} from '../Input';\nimport { InputBase } from '../InputBase';\nimport { PasswordToggleIcon } from './PasswordToggleIcon';\nimport classes from './PasswordInput.module.css';\n\nexport type PasswordInputStylesNames =\n | 'root'\n | 'visibilityToggle'\n | 'innerInput'\n | __InputStylesNames;\nexport type PasswordInputCssVariables = {\n root: '--psi-icon-size' | '--psi-button-size';\n};\n\nexport interface PasswordInputProps\n extends\n BoxProps,\n Omit<__BaseInputProps, 'pointer'>,\n StylesApiProps<PasswordInputFactory>,\n ElementProps<'input', 'size'> {\n /** A component to replace the visibility toggle icon */\n visibilityToggleIcon?: React.FC<{ reveal: boolean }>;\n\n /** Props passed down to the visibility toggle button */\n visibilityToggleButtonProps?: Record<string, any>;\n\n /** If set, the visibility toggle button is focusable with keyboard @default `false` */\n visibilityToggleFocusable?: boolean;\n\n /** If set, the input value is visible */\n visible?: boolean;\n\n /** If set, the input value is visible by default */\n defaultVisible?: boolean;\n\n /** Called when visibility changes */\n onVisibilityChange?: (visible: boolean) => void;\n}\n\nexport type PasswordInputFactory = Factory<{\n props: PasswordInputProps;\n ref: HTMLInputElement;\n stylesNames: PasswordInputStylesNames;\n vars: PasswordInputCssVariables;\n variant: InputVariant;\n}>;\n\nconst defaultProps = {\n visibilityToggleIcon: PasswordToggleIcon,\n visibilityToggleFocusable: false,\n size: 'sm',\n} satisfies Partial<PasswordInputProps>;\n\nconst varsResolver = createVarsResolver<PasswordInputFactory>((_, { size }) => ({\n root: {\n '--psi-icon-size': getSize(size, 'psi-icon-size'),\n '--psi-button-size': getSize(size, 'psi-button-size'),\n },\n}));\n\nfunction PasswordInputField(props: React.ComponentProps<'input'>) {\n const ctx = use(InputWrapperContext);\n return <input {...props} aria-describedby={ctx?.describedBy} />;\n}\n\nexport const PasswordInput = factory<PasswordInputFactory>((_props) => {\n const props = useProps(['Input', 'InputWrapper', 'PasswordInput'], defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n required,\n error,\n success,\n leftSection,\n disabled,\n id,\n variant,\n inputContainer,\n description,\n label,\n size,\n errorProps,\n successProps,\n descriptionProps,\n labelProps,\n withAsterisk,\n inputWrapperOrder,\n wrapperProps,\n radius,\n rightSection,\n rightSectionWidth,\n rightSectionPointerEvents,\n leftSectionWidth,\n visible,\n defaultVisible,\n onVisibilityChange,\n visibilityToggleIcon: VisibilityToggleIcon,\n visibilityToggleButtonProps,\n visibilityToggleFocusable,\n rightSectionProps,\n leftSectionProps,\n leftSectionPointerEvents,\n withErrorStyles,\n withSuccessStyles,\n mod,\n attributes,\n dir,\n ...others\n } = props;\n\n const uuid = useId(id);\n\n const [_visible, setVisibility] = useUncontrolled({\n value: visible,\n defaultValue: defaultVisible,\n finalValue: false,\n onChange: onVisibilityChange,\n });\n\n const toggleVisibility = () => setVisibility(!_visible);\n\n const getStyles = useStyles<PasswordInputFactory>({\n name: 'PasswordInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PasswordInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const { styleProps, rest } = extractStyleProps(others);\n const errorId = errorProps?.id || `${uuid}-error`;\n const successId = successProps?.id || `${uuid}-success`;\n const descriptionId = descriptionProps?.id || `${uuid}-description`;\n\n const visibilityToggleButton = (\n <ActionIcon<'button'>\n {...getStyles('visibilityToggle')}\n disabled={disabled}\n radius={radius}\n aria-pressed={_visible}\n tabIndex={visibilityToggleFocusable ? 0 : -1}\n aria-label=\"Toggle password visibility\"\n {...visibilityToggleButtonProps}\n variant={visibilityToggleButtonProps?.variant ?? 'subtle'}\n color=\"gray\"\n unstyled={unstyled}\n onTouchEnd={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onTouchEnd?.(event);\n toggleVisibility();\n }}\n onMouseDown={(event) => {\n event.preventDefault();\n visibilityToggleButtonProps?.onMouseDown?.(event);\n toggleVisibility();\n }}\n onKeyDown={(event) => {\n visibilityToggleButtonProps?.onKeyDown?.(event);\n if (event.key === ' ' || event.key === 'Enter') {\n event.preventDefault();\n toggleVisibility();\n }\n }}\n >\n <VisibilityToggleIcon reveal={_visible} />\n </ActionIcon>\n );\n\n return (\n <Input.Wrapper\n required={required}\n id={uuid}\n label={label}\n error={error}\n success={success}\n description={description}\n size={size}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n unstyled={unstyled}\n withAsterisk={withAsterisk}\n inputWrapperOrder={inputWrapperOrder}\n inputContainer={inputContainer}\n variant={variant}\n labelProps={{ ...labelProps, htmlFor: uuid }}\n descriptionProps={{ ...descriptionProps, id: descriptionId }}\n errorProps={{ ...errorProps, id: errorId }}\n successProps={{ ...successProps, id: successId }}\n mod={mod}\n attributes={attributes}\n {...getStyles('root')}\n {...styleProps}\n {...wrapperProps}\n >\n <Input\n component=\"div\"\n dir={dir}\n error={error}\n success={success}\n leftSection={leftSection}\n size={size}\n classNames={{ ...resolvedClassNames, input: cx(classes.input, resolvedClassNames?.input) }}\n styles={resolvedStyles}\n radius={radius}\n disabled={disabled}\n __staticSelector=\"PasswordInput\"\n __stylesApiProps={props}\n rightSectionWidth={rightSectionWidth}\n rightSection={rightSection ?? visibilityToggleButton}\n variant={variant}\n unstyled={unstyled}\n leftSectionWidth={leftSectionWidth}\n rightSectionPointerEvents={rightSectionPointerEvents || 'all'}\n rightSectionProps={rightSectionProps}\n leftSectionProps={leftSectionProps}\n leftSectionPointerEvents={leftSectionPointerEvents}\n withAria={false}\n withErrorStyles={withErrorStyles}\n withSuccessStyles={withSuccessStyles}\n attributes={attributes}\n >\n <PasswordInputField\n required={required}\n data-invalid={!!error || undefined}\n data-with-left-section={!!leftSection || undefined}\n {...getStyles('innerInput')}\n disabled={disabled}\n id={uuid}\n dir={dir}\n {...rest}\n autoComplete={rest.autoComplete || 'off'}\n type={_visible ? 'text' : 'password'}\n />\n </Input>\n </Input.Wrapper>\n );\n});\n\nPasswordInput.classes = { ...InputBase.classes, ...classes };\nPasswordInput.varsResolver = varsResolver;\nPasswordInput.displayName = '@mantine/core/PasswordInput';\n\nexport namespace PasswordInput {\n export type Props = PasswordInputProps;\n export type StylesNames = PasswordInputStylesNames;\n export type CssVariables = PasswordInputCssVariables;\n export type Factory = PasswordInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsEA,MAAM,eAAe;CACnB,sBAAsBA,2BAAAA;CACtB,2BAA2B;CAC3B,MAAM;AACR;AAEA,MAAM,eAAeC,6BAAAA,oBAA0C,GAAG,EAAE,YAAY,EAC9E,MAAM;CACJ,mBAAmBC,iBAAAA,QAAQ,MAAM,eAAe;CAChD,qBAAqBA,iBAAAA,QAAQ,MAAM,iBAAiB;AACtD,EACF,EAAE;AAEF,SAAS,mBAAmB,OAAsC;CAChE,MAAM,OAAA,GAAMC,MAAAA,IAAAA,CAAIC,6BAAAA,mBAAmB;CACnC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;EAAO,GAAI;EAAO,oBAAkB,KAAK;CAAc,CAAA;AAChE;AAEA,MAAa,gBAAgBC,gBAAAA,SAA+B,WAAW;CACrE,MAAM,QAAQC,kBAAAA,SAAS;EAAC;EAAS;EAAgB;CAAe,GAAG,cAAc,MAAM;CACvF,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,UACA,OACA,S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AC;AAED,cAAc,UAAU;CAAE,GAAGC,kBAAAA,UAAU;CAAS,GAAGD,6BAAAA;AAAQ;AAC3D,cAAc,eAAe;AAC7B,cAAc,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinInput.cjs","names":["createVarsResolver","getSize","factory","useProps","useId","useStyles","useResolvedStylesApi","useState","useRef","useUncontrolled","createPinArray","Group","Input","assignRef","classes","InputBase"],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { assignRef, useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n Factory,\n factory,\n getSize,\n MantineRadius,\n MantineSize,\n MantineSpacing,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Group } from '../Group';\nimport { Input, InputProps } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { createPinArray } from './create-pin-array/create-pin-array';\nimport classes from './PinInput.module.css';\n\nconst regex = {\n number: /^[0-9]+$/,\n alphanumeric: /^[a-zA-Z0-9]+$/i,\n};\n\nexport type PinInputStylesNames = 'root' | 'pinInput' | 'input';\n\nexport type PinInputCssVariables = {\n root: '--pin-input-size';\n};\n\nexport interface PinInputProps\n extends BoxProps, StylesApiProps<PinInputFactory>, ElementProps<'div', 'onChange' | 'ref'> {\n ref?: React.Ref<HTMLInputElement>;\n\n /** Hidden input `name` attribute */\n name?: string;\n\n /** Hidden input `form` attribute */\n form?: string;\n\n /** Key of `theme.spacing` or any valid CSS value to set `gap` between inputs, numbers are converted to rem @default 'md' */\n gap?: MantineSpacing;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Controls inputs `width` and `height` @default 'sm' */\n size?: MantineSize;\n\n /** If set, the first input is focused when component is mounted @default false */\n autoFocus?: boolean;\n\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Called when all inputs have value */\n onComplete?: (value: string) => void;\n\n /** Inputs placeholder @default '○' */\n placeholder?: string;\n\n /** Determines whether focus should be moved automatically to the next input once filled @default true */\n manageFocus?: boolean;\n\n /** Determines whether `autocomplete=\"one-time-code\"` attribute should be set on all inputs @default true */\n oneTimeCode?: boolean;\n\n /** Base id used to generate unique ids for inputs */\n id?: string;\n\n /** Adds disabled attribute to all inputs */\n disabled?: boolean;\n\n /** Sets `aria-invalid` attribute and applies error styles to all inputs */\n error?: boolean;\n\n /** Applies success styles to all inputs */\n success?: boolean;\n\n /** Determines which values can be entered @default 'alphanumeric' */\n type?: 'alphanumeric' | 'number' | RegExp;\n\n /** Changes input type to `\"password\"` @default false */\n mask?: boolean;\n\n /** Number of inputs @default 4 */\n length?: number;\n\n /** If set, the user cannot edit the value */\n readOnly?: boolean;\n\n /** Inputs `type` attribute, inferred from the `type` prop if not specified */\n inputType?: React.HTMLInputTypeAttribute;\n\n /** `inputmode` attribute, inferred from the `type` prop if not specified */\n inputMode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search'\n | undefined;\n\n /** `aria-label` attribute */\n ariaLabel?: string;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: React.ComponentProps<'input'>;\n\n /** Assigns ref of the root element */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Props added to the input element depending on its index */\n getInputProps?: (index: number) => InputProps & ElementProps<'input', 'size'> & DataAttributes;\n}\n\nexport type PinInputFactory = Factory<{\n props: PinInputProps;\n ref: HTMLDivElement;\n stylesNames: PinInputStylesNames;\n vars: PinInputCssVariables;\n}>;\n\nconst defaultProps = {\n gap: 'sm',\n length: 4,\n manageFocus: true,\n oneTimeCode: true,\n placeholder: '○',\n type: 'alphanumeric',\n ariaLabel: 'PinInput',\n size: 'sm',\n} satisfies Partial<PinInputProps>;\n\nconst varsResolver = createVarsResolver<PinInputFactory>((_, { size }) => ({\n root: {\n '--pin-input-size': getSize(size ?? 'sm', 'pin-input-size'),\n },\n}));\n\nexport const PinInput = factory<PinInputFactory>((props) => {\n const {\n name,\n form,\n className,\n value,\n defaultValue,\n variant,\n gap,\n style,\n size,\n classNames,\n styles,\n unstyled,\n length,\n onChange,\n onComplete,\n manageFocus,\n autoFocus,\n error,\n success,\n radius,\n disabled,\n oneTimeCode,\n placeholder,\n type,\n mask,\n readOnly,\n inputType,\n inputMode,\n ariaLabel,\n vars,\n id,\n hiddenInputProps,\n rootRef,\n getInputProps,\n attributes,\n ref,\n ...others\n } = useProps(['Input', 'PinInput'], defaultProps, props);\n\n const uuid = useId(id);\n\n const getStyles = useStyles<PinInputFactory>({\n name: 'PinInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PinInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [focusedIndex, setFocusedIndex] = useState(-1);\n const inputsRef = useRef<Array<HTMLInputElement>>([]);\n const currentLength = length ?? 4;\n\n const completedRef = useRef(false);\n\n const [_value, setValues] = useUncontrolled<string[]>({\n value: value !== undefined ? createPinArray(currentLength, value) : undefined,\n defaultValue: defaultValue?.split('').slice(0, currentLength),\n finalValue: createPinArray(currentLength, ''),\n onChange: (val) => {\n const stringValue = val.join('').trim();\n onChange?.(stringValue);\n if (stringValue.length === currentLength && !completedRef.current) {\n completedRef.current = true;\n onComplete?.(stringValue);\n } else if (stringValue.length < currentLength) {\n completedRef.current = false;\n }\n },\n });\n\n const currentValue =\n _value.length !== currentLength ? createPinArray(currentLength, _value.join('')) : _value;\n\n const _valueToString = currentValue.join('').trim();\n\n const validate = (code: string) => {\n const re = type instanceof RegExp ? type : type && type in regex ? regex[type] : null;\n return re?.test(code);\n };\n\n const focusInputField = (dir: 'next' | 'prev', index: number) => {\n if (!manageFocus) {\n return;\n }\n\n if (dir === 'next') {\n const nextIndex = index + 1;\n if (nextIndex < currentLength) {\n inputsRef.current[nextIndex]?.focus();\n }\n } else if (dir === 'prev') {\n const prevIndex = index - 1;\n if (prevIndex >= 0) {\n inputsRef.current[prevIndex]?.focus();\n }\n }\n };\n\n const setFieldValue = (val: string, index: number) => {\n const values = [...currentValue];\n values[index] = val;\n setValues(values);\n return values;\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const inputValue = event.target.value;\n\n if (inputValue.length > 1) {\n const isPaste = inputValue.length > 2;\n if (isPaste) {\n const isValid = validate(inputValue);\n if (isValid) {\n setValues(createPinArray(currentLength, inputValue));\n const filledCount = Math.min(inputValue.length, currentLength);\n if (filledCount < currentLength) {\n focusInputField('next', filledCount - 1);\n }\n }\n return;\n }\n\n const newChar = inputValue.split('')[inputValue.length - 1];\n if (validate(newChar)) {\n setFieldValue(newChar, index);\n focusInputField('next', index);\n }\n return;\n }\n\n if (inputValue.length === 1) {\n if (validate(inputValue)) {\n setFieldValue(inputValue, index);\n focusInputField('next', index);\n } else {\n setFieldValue('', index);\n }\n } else if (inputValue.length === 0) {\n setFieldValue('', index);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>, index: number) => {\n const { ctrlKey, metaKey, key, shiftKey, target } = event;\n const inputValue = (target as HTMLInputElement).value;\n\n if (inputMode === 'numeric') {\n const allowedKeys = ['Backspace', 'Tab', 'Control', 'Delete', 'ArrowLeft', 'ArrowRight'];\n const isModifierShortcut = ctrlKey || metaKey;\n const isAllowedKey =\n allowedKeys.includes(key) || isModifierShortcut || !Number.isNaN(Number(key));\n\n if (!isAllowedKey) {\n event.preventDefault();\n return;\n }\n }\n\n switch (key) {\n case 'ArrowLeft':\n event.preventDefault();\n focusInputField('prev', index);\n break;\n\n case 'ArrowRight':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Tab':\n if (shiftKey) {\n if (index > 0 && manageFocus) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n case ' ':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Delete':\n event.preventDefault();\n setFieldValue('', index);\n break;\n\n case 'Backspace':\n if (inputValue === '') {\n event.preventDefault();\n focusInputField('prev', index);\n } else {\n setFieldValue('', index);\n if (index < currentLength - 1) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n default:\n if (inputValue.length > 0 && key === currentValue[index]) {\n event.preventDefault();\n focusInputField('next', index);\n }\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>, index: number) => {\n event.target.select();\n setFocusedIndex(index);\n };\n\n const handleBlur = () => {\n setFocusedIndex(-1);\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n const pasteData = event.clipboardData.getData('text/plain').replace(/[\\n\\r\\s]+/g, '');\n const isValid = validate(pasteData.trim());\n\n if (isValid) {\n const pasteArray = createPinArray(currentLength, pasteData);\n setValues(pasteArray);\n const filledCount = pasteArray.filter((val) => val !== '').length;\n if (filledCount >= currentLength) {\n inputsRef.current[currentLength - 1]?.focus();\n } else {\n inputsRef.current[filledCount]?.focus();\n }\n }\n };\n\n return (\n <>\n <Group\n {...others}\n {...getStyles('root')}\n ref={rootRef}\n role=\"group\"\n id={uuid}\n gap={gap}\n unstyled={unstyled}\n wrap=\"nowrap\"\n variant={variant}\n __size={size}\n dir=\"ltr\"\n >\n {currentValue.map((char: string, index: number) => (\n <Input\n component=\"input\"\n {...getStyles('pinInput', {\n style: {\n '--input-padding': '0',\n '--input-text-align': 'center',\n } as React.CSSProperties,\n })}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n size={size}\n __staticSelector=\"PinInput\"\n id={`${uuid}-${index + 1}`}\n key={`${uuid}-${index}`}\n inputMode={inputMode || (type === 'number' ? 'numeric' : 'text')}\n onChange={(event) => handleChange(event, index)}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={(event) => handleFocus(event, index)}\n onBlur={handleBlur}\n onPaste={handlePaste}\n type={inputType || (mask ? 'password' : type === 'number' ? 'tel' : 'text')}\n radius={radius}\n error={error}\n success={success}\n variant={variant}\n disabled={disabled}\n ref={(node) => {\n if (node) {\n index === 0 && assignRef(ref, node);\n inputsRef.current[index] = node;\n }\n }}\n autoComplete={oneTimeCode ? 'one-time-code' : 'off'}\n placeholder={focusedIndex === index ? '' : placeholder}\n value={char}\n autoFocus={autoFocus && index === 0}\n unstyled={unstyled}\n aria-label={ariaLabel}\n readOnly={readOnly}\n {...getInputProps?.(index)}\n />\n ))}\n </Group>\n\n <input type=\"hidden\" name={name} form={form} value={_valueToString} {...hiddenInputProps} />\n </>\n );\n});\n\nPinInput.classes = { ...classes, ...InputBase.classes };\nPinInput.varsResolver = varsResolver;\nPinInput.displayName = '@mantine/core/PinInput';\n\nexport namespace PinInput {\n export type Props = PinInputProps;\n export type StylesNames = PinInputStylesNames;\n export type Factory = PinInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,QAAQ;CACZ,QAAQ;CACR,cAAc;AAChB;AA8GA,MAAM,eAAe;CACnB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CACb,MAAM;CACN,WAAW;CACX,MAAM;AACR;AAEA,MAAM,eAAeA,6BAAAA,oBAAqC,GAAG,EAAE,YAAY,EACzE,MAAM,EACJ,oBAAoBC,iBAAAA,QAAQ,QAAQ,MAAM,gBAAgB,EAC5D,EACF,EAAE;AAEF,MAAa,WAAWC,gBAAAA,SAA0B,UAAU;CAC1D,MAAM,EACJ,MACA,MACA,WACA,OACA,cACA,SACA,KACA,OACA,MACA,YACA,QACA,UACA,QACA,UACA,YACA,aACA,WACA,OACA,SACA,QACA,UACA,aACA,aACA,MACA,MACA,UACA,WACA,WACA,WACA,MACA,IACA,kBACA,SACA,eACA,YACA,KACA,GAAG,WACDC,kBAAAA,SAAS,CAAC,SAAS,UAAU,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Y;GACF;GACV,GAAI,gBAAgB,KAAK;EAC1B,CAAA,CACF;CACI,CAAA,GAEP,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;EAAO,MAAK;EAAe;EAAY;EAAM,OAAO;EAAgB,GAAI;CAAmB,CAAA,CAC3F,EAAA,CAAA;AAEN,CAAC;AAED,SAAS,UAAU;CAAE,GAAGC,wBAAAA;CAAS,GAAGC,kBAAAA,UAAU;AAAQ;AACtD,SAAS,eAAe;AACxB,SAAS,cAAc"}
|
|
1
|
+
{"version":3,"file":"PinInput.cjs","names":["createVarsResolver","getSize","factory","useProps","useId","useStyles","useResolvedStylesApi","useState","useRef","useUncontrolled","createPinArray","Group","Input","assignRef","classes","InputBase"],"sources":["../../../src/components/PinInput/PinInput.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { assignRef, useId, useUncontrolled } from '@mantine/hooks';\nimport {\n BoxProps,\n createVarsResolver,\n DataAttributes,\n ElementProps,\n Factory,\n factory,\n getSize,\n MantineRadius,\n MantineSize,\n MantineSpacing,\n StylesApiProps,\n useProps,\n useResolvedStylesApi,\n useStyles,\n} from '../../core';\nimport { Group } from '../Group';\nimport { Input, InputProps } from '../Input';\nimport { InputBase } from '../InputBase';\nimport { createPinArray } from './create-pin-array/create-pin-array';\nimport classes from './PinInput.module.css';\n\nconst regex = {\n number: /^[0-9]+$/,\n alphanumeric: /^[a-zA-Z0-9]+$/i,\n};\n\nexport type PinInputStylesNames = 'root' | 'pinInput' | 'input';\n\nexport type PinInputCssVariables = {\n root: '--pin-input-size';\n};\n\nexport interface PinInputProps\n extends BoxProps, StylesApiProps<PinInputFactory>, ElementProps<'div', 'onChange' | 'ref'> {\n ref?: React.Ref<HTMLInputElement>;\n\n /** Hidden input `name` attribute */\n name?: string;\n\n /** Hidden input `form` attribute */\n form?: string;\n\n /** Key of `theme.spacing` or any valid CSS value to set `gap` between inputs, numbers are converted to rem @default 'sm' */\n gap?: MantineSpacing;\n\n /** Key of `theme.radius` or any valid CSS value to set `border-radius`, numbers are converted to rem @default theme.defaultRadius */\n radius?: MantineRadius;\n\n /** Controls inputs `width` and `height` @default 'sm' */\n size?: MantineSize;\n\n /** If set, the first input is focused when component is mounted @default false */\n autoFocus?: boolean;\n\n /** Controlled component value */\n value?: string;\n\n /** Uncontrolled component default value */\n defaultValue?: string;\n\n /** Called when value changes */\n onChange?: (value: string) => void;\n\n /** Called when all inputs have value */\n onComplete?: (value: string) => void;\n\n /** Inputs placeholder @default '○' */\n placeholder?: string;\n\n /** Determines whether focus should be moved automatically to the next input once filled @default true */\n manageFocus?: boolean;\n\n /** Determines whether `autocomplete=\"one-time-code\"` attribute should be set on all inputs @default true */\n oneTimeCode?: boolean;\n\n /** Base id used to generate unique ids for inputs */\n id?: string;\n\n /** Adds disabled attribute to all inputs */\n disabled?: boolean;\n\n /** Sets `aria-invalid` attribute and applies error styles to all inputs */\n error?: boolean;\n\n /** Applies success styles to all inputs */\n success?: boolean;\n\n /** Determines which values can be entered @default 'alphanumeric' */\n type?: 'alphanumeric' | 'number' | RegExp;\n\n /** Changes input type to `\"password\"` @default false */\n mask?: boolean;\n\n /** Number of inputs @default 4 */\n length?: number;\n\n /** If set, the user cannot edit the value */\n readOnly?: boolean;\n\n /** Inputs `type` attribute, inferred from the `type` prop if not specified */\n inputType?: React.HTMLInputTypeAttribute;\n\n /** `inputmode` attribute, inferred from the `type` prop if not specified */\n inputMode?:\n | 'none'\n | 'text'\n | 'tel'\n | 'url'\n | 'email'\n | 'numeric'\n | 'decimal'\n | 'search'\n | undefined;\n\n /** `aria-label` attribute */\n ariaLabel?: string;\n\n /** Props passed down to the hidden input */\n hiddenInputProps?: React.ComponentProps<'input'>;\n\n /** Assigns ref of the root element */\n rootRef?: React.Ref<HTMLDivElement>;\n\n /** Props added to the input element depending on its index */\n getInputProps?: (index: number) => InputProps & ElementProps<'input', 'size'> & DataAttributes;\n}\n\nexport type PinInputFactory = Factory<{\n props: PinInputProps;\n ref: HTMLDivElement;\n stylesNames: PinInputStylesNames;\n vars: PinInputCssVariables;\n}>;\n\nconst defaultProps = {\n gap: 'sm',\n length: 4,\n manageFocus: true,\n oneTimeCode: true,\n placeholder: '○',\n type: 'alphanumeric',\n ariaLabel: 'PinInput',\n size: 'sm',\n} satisfies Partial<PinInputProps>;\n\nconst varsResolver = createVarsResolver<PinInputFactory>((_, { size }) => ({\n root: {\n '--pin-input-size': getSize(size ?? 'sm', 'pin-input-size'),\n },\n}));\n\nexport const PinInput = factory<PinInputFactory>((props) => {\n const {\n name,\n form,\n className,\n value,\n defaultValue,\n variant,\n gap,\n style,\n size,\n classNames,\n styles,\n unstyled,\n length,\n onChange,\n onComplete,\n manageFocus,\n autoFocus,\n error,\n success,\n radius,\n disabled,\n oneTimeCode,\n placeholder,\n type,\n mask,\n readOnly,\n inputType,\n inputMode,\n ariaLabel,\n vars,\n id,\n hiddenInputProps,\n rootRef,\n getInputProps,\n attributes,\n ref,\n ...others\n } = useProps(['Input', 'PinInput'], defaultProps, props);\n\n const uuid = useId(id);\n\n const getStyles = useStyles<PinInputFactory>({\n name: 'PinInput',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi<PinInputFactory>({\n classNames,\n styles,\n props,\n });\n\n const [focusedIndex, setFocusedIndex] = useState(-1);\n const inputsRef = useRef<Array<HTMLInputElement>>([]);\n const currentLength = length ?? 4;\n\n const completedRef = useRef(false);\n\n const [_value, setValues] = useUncontrolled<string[]>({\n value: value !== undefined ? createPinArray(currentLength, value) : undefined,\n defaultValue: defaultValue?.split('').slice(0, currentLength),\n finalValue: createPinArray(currentLength, ''),\n onChange: (val) => {\n const stringValue = val.join('').trim();\n onChange?.(stringValue);\n if (stringValue.length === currentLength && !completedRef.current) {\n completedRef.current = true;\n onComplete?.(stringValue);\n } else if (stringValue.length < currentLength) {\n completedRef.current = false;\n }\n },\n });\n\n const currentValue =\n _value.length !== currentLength ? createPinArray(currentLength, _value.join('')) : _value;\n\n const _valueToString = currentValue.join('').trim();\n\n const validate = (code: string) => {\n const re = type instanceof RegExp ? type : type && type in regex ? regex[type] : null;\n return re?.test(code);\n };\n\n const focusInputField = (dir: 'next' | 'prev', index: number) => {\n if (!manageFocus) {\n return;\n }\n\n if (dir === 'next') {\n const nextIndex = index + 1;\n if (nextIndex < currentLength) {\n inputsRef.current[nextIndex]?.focus();\n }\n } else if (dir === 'prev') {\n const prevIndex = index - 1;\n if (prevIndex >= 0) {\n inputsRef.current[prevIndex]?.focus();\n }\n }\n };\n\n const setFieldValue = (val: string, index: number) => {\n const values = [...currentValue];\n values[index] = val;\n setValues(values);\n return values;\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const inputValue = event.target.value;\n\n if (inputValue.length > 1) {\n const isPaste = inputValue.length > 2;\n if (isPaste) {\n const isValid = validate(inputValue);\n if (isValid) {\n setValues(createPinArray(currentLength, inputValue));\n const filledCount = Math.min(inputValue.length, currentLength);\n if (filledCount < currentLength) {\n focusInputField('next', filledCount - 1);\n }\n }\n return;\n }\n\n const newChar = inputValue.split('')[inputValue.length - 1];\n if (validate(newChar)) {\n setFieldValue(newChar, index);\n focusInputField('next', index);\n }\n return;\n }\n\n if (inputValue.length === 1) {\n if (validate(inputValue)) {\n setFieldValue(inputValue, index);\n focusInputField('next', index);\n } else {\n setFieldValue('', index);\n }\n } else if (inputValue.length === 0) {\n setFieldValue('', index);\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>, index: number) => {\n const { ctrlKey, metaKey, key, shiftKey, target } = event;\n const inputValue = (target as HTMLInputElement).value;\n\n if (inputMode === 'numeric') {\n const allowedKeys = ['Backspace', 'Tab', 'Control', 'Delete', 'ArrowLeft', 'ArrowRight'];\n const isModifierShortcut = ctrlKey || metaKey;\n const isAllowedKey =\n allowedKeys.includes(key) || isModifierShortcut || !Number.isNaN(Number(key));\n\n if (!isAllowedKey) {\n event.preventDefault();\n return;\n }\n }\n\n switch (key) {\n case 'ArrowLeft':\n event.preventDefault();\n focusInputField('prev', index);\n break;\n\n case 'ArrowRight':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Tab':\n if (shiftKey) {\n if (index > 0 && manageFocus) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n case ' ':\n event.preventDefault();\n focusInputField('next', index);\n break;\n\n case 'Delete':\n event.preventDefault();\n setFieldValue('', index);\n break;\n\n case 'Backspace':\n if (inputValue === '') {\n event.preventDefault();\n focusInputField('prev', index);\n } else {\n setFieldValue('', index);\n if (index < currentLength - 1) {\n event.preventDefault();\n focusInputField('prev', index);\n }\n }\n break;\n\n default:\n if (inputValue.length > 0 && key === currentValue[index]) {\n event.preventDefault();\n focusInputField('next', index);\n }\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>, index: number) => {\n event.target.select();\n setFocusedIndex(index);\n };\n\n const handleBlur = () => {\n setFocusedIndex(-1);\n };\n\n const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault();\n const pasteData = event.clipboardData.getData('text/plain').replace(/[\\n\\r\\s]+/g, '');\n const isValid = validate(pasteData.trim());\n\n if (isValid) {\n const pasteArray = createPinArray(currentLength, pasteData);\n setValues(pasteArray);\n const filledCount = pasteArray.filter((val) => val !== '').length;\n if (filledCount >= currentLength) {\n inputsRef.current[currentLength - 1]?.focus();\n } else {\n inputsRef.current[filledCount]?.focus();\n }\n }\n };\n\n return (\n <>\n <Group\n {...others}\n {...getStyles('root')}\n ref={rootRef}\n role=\"group\"\n id={uuid}\n gap={gap}\n unstyled={unstyled}\n wrap=\"nowrap\"\n variant={variant}\n __size={size}\n dir=\"ltr\"\n >\n {currentValue.map((char: string, index: number) => (\n <Input\n component=\"input\"\n {...getStyles('pinInput', {\n style: {\n '--input-padding': '0',\n '--input-text-align': 'center',\n } as React.CSSProperties,\n })}\n classNames={resolvedClassNames}\n styles={resolvedStyles}\n size={size}\n __staticSelector=\"PinInput\"\n id={`${uuid}-${index + 1}`}\n key={`${uuid}-${index}`}\n inputMode={inputMode || (type === 'number' ? 'numeric' : 'text')}\n onChange={(event) => handleChange(event, index)}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={(event) => handleFocus(event, index)}\n onBlur={handleBlur}\n onPaste={handlePaste}\n type={inputType || (mask ? 'password' : type === 'number' ? 'tel' : 'text')}\n radius={radius}\n error={error}\n success={success}\n variant={variant}\n disabled={disabled}\n ref={(node) => {\n if (node) {\n index === 0 && assignRef(ref, node);\n inputsRef.current[index] = node;\n }\n }}\n autoComplete={oneTimeCode ? 'one-time-code' : 'off'}\n placeholder={focusedIndex === index ? '' : placeholder}\n value={char}\n autoFocus={autoFocus && index === 0}\n unstyled={unstyled}\n aria-label={ariaLabel}\n readOnly={readOnly}\n {...getInputProps?.(index)}\n />\n ))}\n </Group>\n\n <input type=\"hidden\" name={name} form={form} value={_valueToString} {...hiddenInputProps} />\n </>\n );\n});\n\nPinInput.classes = { ...classes, ...InputBase.classes };\nPinInput.varsResolver = varsResolver;\nPinInput.displayName = '@mantine/core/PinInput';\n\nexport namespace PinInput {\n export type Props = PinInputProps;\n export type StylesNames = PinInputStylesNames;\n export type Factory = PinInputFactory;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAM,QAAQ;CACZ,QAAQ;CACR,cAAc;AAChB;AA8GA,MAAM,eAAe;CACnB,KAAK;CACL,QAAQ;CACR,aAAa;CACb,aAAa;CACb,aAAa;CACb,MAAM;CACN,WAAW;CACX,MAAM;AACR;AAEA,MAAM,eAAeA,6BAAAA,oBAAqC,GAAG,EAAE,YAAY,EACzE,MAAM,EACJ,oBAAoBC,iBAAAA,QAAQ,QAAQ,MAAM,gBAAgB,EAC5D,EACF,EAAE;AAEF,MAAa,WAAWC,gBAAAA,SAA0B,UAAU;CAC1D,MAAM,EACJ,MACA,MACA,WACA,OACA,cACA,SACA,KACA,OACA,MACA,YAC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UAAAA,CAAU,KAAK,IAAI;KAClC,UAAU,QAAQ,SAAS;IAC7B;GACF;GACA,cAAc,cAAc,kBAAkB;GAC9C,aAAa,iBAAiB,QAAQ,KAAK;GAC3C,OAAO;GACP,WAAW,aAAa,UAAU;GACxB;GACV,cAAY;GACF;GACV,GAAI,gBAAgB,KAAK;EAC1B,CAAA,CACF;CACI,CAAA,GAEP,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;EAAO,MAAK;EAAe;EAAY;EAAM,OAAO;EAAgB,GAAI;CAAmB,CAAA,CAC3F,EAAA,CAAA;AAEN,CAAC;AAED,SAAS,UAAU;CAAE,GAAGC,wBAAAA;CAAS,GAAGC,kBAAAA,UAAU;AAAQ;AACtD,SAAS,eAAe;AACxB,SAAS,cAAc"}
|
|
@@ -14,17 +14,26 @@ function createPortalNode(props) {
|
|
|
14
14
|
typeof props.id === "string" && node.setAttribute("id", props.id);
|
|
15
15
|
return node;
|
|
16
16
|
}
|
|
17
|
+
let cachedSharedPortalNode = null;
|
|
17
18
|
function getTargetNode({ target, reuseTargetNode, ...others }) {
|
|
18
19
|
if (target) {
|
|
19
20
|
if (typeof target === "string") return document.querySelector(target) || createPortalNode(others);
|
|
20
21
|
return target;
|
|
21
22
|
}
|
|
22
23
|
if (reuseTargetNode) {
|
|
24
|
+
if (cachedSharedPortalNode) {
|
|
25
|
+
if (document.body.contains(cachedSharedPortalNode)) return cachedSharedPortalNode;
|
|
26
|
+
cachedSharedPortalNode = null;
|
|
27
|
+
}
|
|
23
28
|
const existingNode = document.querySelector("[data-mantine-shared-portal-node]");
|
|
24
|
-
if (existingNode)
|
|
29
|
+
if (existingNode) {
|
|
30
|
+
cachedSharedPortalNode = existingNode;
|
|
31
|
+
return existingNode;
|
|
32
|
+
}
|
|
25
33
|
const node = createPortalNode(others);
|
|
26
34
|
node.setAttribute("data-mantine-shared-portal-node", "true");
|
|
27
35
|
document.body.appendChild(node);
|
|
36
|
+
cachedSharedPortalNode = node;
|
|
28
37
|
return node;
|
|
29
38
|
}
|
|
30
39
|
return createPortalNode(others);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portal.cjs","names":["factory","useProps","useState","useRef","createPortal"],"sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { assignRef, useIsomorphicEffect } from '@mantine/hooks';\nimport { Factory, factory, useProps } from '../../core';\n\nfunction createPortalNode(props: React.ComponentProps<'div'>) {\n const node = document.createElement('div');\n node.setAttribute('data-portal', 'true');\n typeof props.className === 'string' &&\n node.classList.add(...props.className.split(' ').filter(Boolean));\n typeof props.style === 'object' && Object.assign(node.style, props.style);\n typeof props.id === 'string' && node.setAttribute('id', props.id);\n return node;\n}\n\nexport interface BasePortalProps extends React.ComponentProps<'div'> {\n /**\n * Target element where portal should be rendered. Accepts:\n * - HTMLElement: Renders portal inside this element\n * - string: CSS selector - renders inside first matching element\n * - undefined: Uses shared portal node or creates new one based on `reuseTargetNode`\n *\n * Note: If selector doesn't match any element, portal will not render\n */\n target?: HTMLElement | string;\n\n /**\n * When true and target is not specified, all Portal instances share a single\n * container node appended to document.body. When false, each Portal creates\n * its own container node.\n *\n * Has no effect when target is specified.\n *\n * @default true\n */\n reuseTargetNode?: boolean;\n}\n\nexport interface PortalProps extends BasePortalProps {\n /** Content to render inside the portal */\n children: React.ReactNode;\n}\n\nfunction getTargetNode({ target, reuseTargetNode, ...others }: BasePortalProps): HTMLElement {\n if (target) {\n if (typeof target === 'string') {\n return document.querySelector<HTMLElement>(target) || createPortalNode(others);\n }\n\n return target;\n }\n\n if (reuseTargetNode) {\n const existingNode = document.querySelector<HTMLElement>('[data-mantine-shared-portal-node]');\n\n if (existingNode) {\n return existingNode;\n }\n\n const node = createPortalNode(others);\n node.setAttribute('data-mantine-shared-portal-node', 'true');\n document.body.appendChild(node);\n return node;\n }\n\n return createPortalNode(others);\n}\n\nexport type PortalFactory = Factory<{\n props: PortalProps;\n ref: HTMLDivElement;\n}>;\n\nconst defaultProps = {\n reuseTargetNode: true,\n} satisfies Partial<PortalProps>;\n\nexport const Portal = factory<PortalFactory>((props) => {\n const { children, target, reuseTargetNode, ref, ...others } = useProps(\n 'Portal',\n defaultProps,\n props\n );\n\n const [mounted, setMounted] = useState(false);\n const nodeRef = useRef<HTMLElement | null>(null);\n\n useIsomorphicEffect(() => {\n setMounted(true);\n nodeRef.current = getTargetNode({ target, reuseTargetNode, ...others });\n assignRef(ref, nodeRef.current);\n\n if (!target && !reuseTargetNode && nodeRef.current) {\n document.body.appendChild(nodeRef.current);\n }\n\n return () => {\n if (!target && !reuseTargetNode && nodeRef.current) {\n document.body.removeChild(nodeRef.current);\n }\n };\n }, [target]);\n\n if (!mounted || !nodeRef.current) {\n return null;\n }\n\n return createPortal(<>{children}</>, nodeRef.current);\n});\n\nPortal.displayName = '@mantine/core/Portal';\n\nexport namespace Portal {\n export type Props = PortalProps;\n}\n"],"mappings":";;;;;;;;AAKA,SAAS,iBAAiB,OAAoC;CAC5D,MAAM,OAAO,SAAS,cAAc,KAAK;CACzC,KAAK,aAAa,eAAe,MAAM;CACvC,OAAO,MAAM,cAAc,YACzB,KAAK,UAAU,IAAI,GAAG,MAAM,UAAU,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,CAAC;CAClE,OAAO,MAAM,UAAU,YAAY,OAAO,OAAO,KAAK,OAAO,MAAM,KAAK;CACxE,OAAO,MAAM,OAAO,YAAY,KAAK,aAAa,MAAM,MAAM,EAAE;CAChE,OAAO;AACT;AA8BA,SAAS,cAAc,EAAE,QAAQ,iBAAiB,GAAG,UAAwC;CAC3F,IAAI,QAAQ;EACV,IAAI,OAAO,WAAW,UACpB,OAAO,SAAS,cAA2B,MAAM,KAAK,iBAAiB,MAAM;EAG/E,OAAO;CACT;CAEA,IAAI,iBAAiB;EACnB,MAAM,eAAe,SAAS,cAA2B,mCAAmC;EAE5F,IAAI,
|
|
1
|
+
{"version":3,"file":"Portal.cjs","names":["factory","useProps","useState","useRef","createPortal"],"sources":["../../../src/components/Portal/Portal.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport { assignRef, useIsomorphicEffect } from '@mantine/hooks';\nimport { Factory, factory, useProps } from '../../core';\n\nfunction createPortalNode(props: React.ComponentProps<'div'>) {\n const node = document.createElement('div');\n node.setAttribute('data-portal', 'true');\n typeof props.className === 'string' &&\n node.classList.add(...props.className.split(' ').filter(Boolean));\n typeof props.style === 'object' && Object.assign(node.style, props.style);\n typeof props.id === 'string' && node.setAttribute('id', props.id);\n return node;\n}\n\nexport interface BasePortalProps extends React.ComponentProps<'div'> {\n /**\n * Target element where portal should be rendered. Accepts:\n * - HTMLElement: Renders portal inside this element\n * - string: CSS selector - renders inside first matching element\n * - undefined: Uses shared portal node or creates new one based on `reuseTargetNode`\n *\n * Note: If selector doesn't match any element, portal will not render\n */\n target?: HTMLElement | string;\n\n /**\n * When true and target is not specified, all Portal instances share a single\n * container node appended to document.body. When false, each Portal creates\n * its own container node.\n *\n * Has no effect when target is specified.\n *\n * @default true\n */\n reuseTargetNode?: boolean;\n}\n\nexport interface PortalProps extends BasePortalProps {\n /** Content to render inside the portal */\n children: React.ReactNode;\n}\n\nlet cachedSharedPortalNode: HTMLElement | null = null;\n\nfunction getTargetNode({ target, reuseTargetNode, ...others }: BasePortalProps): HTMLElement {\n if (target) {\n if (typeof target === 'string') {\n return document.querySelector<HTMLElement>(target) || createPortalNode(others);\n }\n\n return target;\n }\n\n if (reuseTargetNode) {\n if (cachedSharedPortalNode) {\n if (document.body.contains(cachedSharedPortalNode)) {\n return cachedSharedPortalNode;\n }\n\n cachedSharedPortalNode = null;\n }\n\n const existingNode = document.querySelector<HTMLElement>('[data-mantine-shared-portal-node]');\n\n if (existingNode) {\n cachedSharedPortalNode = existingNode;\n return existingNode;\n }\n\n const node = createPortalNode(others);\n node.setAttribute('data-mantine-shared-portal-node', 'true');\n document.body.appendChild(node);\n cachedSharedPortalNode = node;\n return node;\n }\n\n return createPortalNode(others);\n}\n\nexport type PortalFactory = Factory<{\n props: PortalProps;\n ref: HTMLDivElement;\n}>;\n\nconst defaultProps = {\n reuseTargetNode: true,\n} satisfies Partial<PortalProps>;\n\nexport const Portal = factory<PortalFactory>((props) => {\n const { children, target, reuseTargetNode, ref, ...others } = useProps(\n 'Portal',\n defaultProps,\n props\n );\n\n const [mounted, setMounted] = useState(false);\n const nodeRef = useRef<HTMLElement | null>(null);\n\n useIsomorphicEffect(() => {\n setMounted(true);\n nodeRef.current = getTargetNode({ target, reuseTargetNode, ...others });\n assignRef(ref, nodeRef.current);\n\n if (!target && !reuseTargetNode && nodeRef.current) {\n document.body.appendChild(nodeRef.current);\n }\n\n return () => {\n if (!target && !reuseTargetNode && nodeRef.current) {\n document.body.removeChild(nodeRef.current);\n }\n };\n }, [target]);\n\n if (!mounted || !nodeRef.current) {\n return null;\n }\n\n return createPortal(<>{children}</>, nodeRef.current);\n});\n\nPortal.displayName = '@mantine/core/Portal';\n\nexport namespace Portal {\n export type Props = PortalProps;\n}\n"],"mappings":";;;;;;;;AAKA,SAAS,iBAAiB,OAAoC;CAC5D,MAAM,OAAO,SAAS,cAAc,KAAK;CACzC,KAAK,aAAa,eAAe,MAAM;CACvC,OAAO,MAAM,cAAc,YACzB,KAAK,UAAU,IAAI,GAAG,MAAM,UAAU,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,CAAC;CAClE,OAAO,MAAM,UAAU,YAAY,OAAO,OAAO,KAAK,OAAO,MAAM,KAAK;CACxE,OAAO,MAAM,OAAO,YAAY,KAAK,aAAa,MAAM,MAAM,EAAE;CAChE,OAAO;AACT;AA8BA,IAAI,yBAA6C;AAEjD,SAAS,cAAc,EAAE,QAAQ,iBAAiB,GAAG,UAAwC;CAC3F,IAAI,QAAQ;EACV,IAAI,OAAO,WAAW,UACpB,OAAO,SAAS,cAA2B,MAAM,KAAK,iBAAiB,MAAM;EAG/E,OAAO;CACT;CAEA,IAAI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"}
|
|
@@ -30,11 +30,19 @@ const varsResolver = require_create_vars_resolver.createVarsResolver((theme, { s
|
|
|
30
30
|
theme
|
|
31
31
|
});
|
|
32
32
|
const outlineColor = parsedColor.isThemeColor && parsedColor.shade === void 0 ? `var(--mantine-color-${parsedColor.color}-outline)` : parsedColor.color;
|
|
33
|
+
const lightColors = variant === "light" ? theme.variantColorResolver({
|
|
34
|
+
color: color || theme.primaryColor,
|
|
35
|
+
theme,
|
|
36
|
+
variant: "light",
|
|
37
|
+
autoContrast
|
|
38
|
+
}) : void 0;
|
|
39
|
+
const resolvedColor = variant === "outline" ? outlineColor : lightColors ? lightColors.color : require_get_theme_color.getThemeColor(color, theme);
|
|
33
40
|
return { root: {
|
|
34
41
|
"--radio-size": require_get_size.getSize(size, "radio-size"),
|
|
35
42
|
"--radio-radius": radius === void 0 ? void 0 : require_get_size.getRadius(radius),
|
|
36
|
-
"--radio-color":
|
|
37
|
-
"--radio-
|
|
43
|
+
"--radio-color": resolvedColor,
|
|
44
|
+
"--radio-bg": lightColors?.background,
|
|
45
|
+
"--radio-icon-color": iconColor ? require_get_theme_color.getThemeColor(iconColor, theme) : lightColors ? lightColors.color : require_get_auto_contrast_value.getAutoContrastValue(autoContrast, theme) ? require_get_contrast_color.getContrastColor({
|
|
38
46
|
color,
|
|
39
47
|
theme,
|
|
40
48
|
autoContrast
|