@mantine/core 3.6.0-alpha.1 → 3.6.3
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/ActionIcon/ActionIcon.js +2 -5
- package/cjs/components/ActionIcon/ActionIcon.js.map +1 -1
- package/cjs/components/Code/Code.js +3 -1
- package/cjs/components/Code/Code.js.map +1 -1
- package/cjs/components/ColorInput/ColorInput.js +0 -2
- package/cjs/components/ColorInput/ColorInput.js.map +1 -1
- package/cjs/components/ColorInput/ColorInput.styles.js +0 -4
- package/cjs/components/ColorInput/ColorInput.styles.js.map +1 -1
- package/cjs/components/Drawer/Drawer.js +7 -1
- package/cjs/components/Drawer/Drawer.js.map +1 -1
- package/cjs/components/Input/Input.js +3 -0
- package/cjs/components/Input/Input.js.map +1 -1
- package/cjs/components/Input/Input.styles.js +11 -2
- package/cjs/components/Input/Input.styles.js.map +1 -1
- package/cjs/components/Menu/Menu.js +8 -3
- package/cjs/components/Menu/Menu.js.map +1 -1
- package/cjs/components/NumberInput/NumberInput.js.map +1 -1
- package/cjs/components/Pagination/DefaultItem/DefaultItem.js +10 -1
- package/cjs/components/Pagination/DefaultItem/DefaultItem.js.map +1 -1
- package/cjs/components/Popover/Popover.js +8 -3
- package/cjs/components/Popover/Popover.js.map +1 -1
- package/cjs/components/Popper/Popper.js +28 -2
- package/cjs/components/Popper/Popper.js.map +1 -1
- package/cjs/components/Popper/Popper.styles.js +20 -12
- package/cjs/components/Popper/Popper.styles.js.map +1 -1
- package/cjs/components/Portal/Portal.js +3 -0
- package/cjs/components/Portal/Portal.js.map +1 -1
- package/cjs/components/Progress/Progress.js +3 -3
- package/cjs/components/Progress/Progress.js.map +1 -1
- package/cjs/components/ScrollArea/ScrollArea.js +6 -4
- package/cjs/components/ScrollArea/ScrollArea.js.map +1 -1
- package/cjs/components/ScrollArea/ScrollArea.styles.js +2 -3
- package/cjs/components/ScrollArea/ScrollArea.styles.js.map +1 -1
- package/cjs/components/SegmentedControl/SegmentedControl.js +34 -11
- package/cjs/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/cjs/components/SegmentedControl/SegmentedControl.styles.js +53 -41
- package/cjs/components/SegmentedControl/SegmentedControl.styles.js.map +1 -1
- package/cjs/components/Select/Select.js +5 -4
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/Slider/RangeSlider/RangeSlider.js +25 -10
- package/cjs/components/Slider/RangeSlider/RangeSlider.js.map +1 -1
- package/cjs/components/Slider/Slider/Slider.js +21 -9
- package/cjs/components/Slider/Slider/Slider.js.map +1 -1
- package/cjs/components/Slider/Thumb/Thumb.js +3 -2
- package/cjs/components/Slider/Thumb/Thumb.js.map +1 -1
- package/cjs/components/Tabs/Tabs.js +5 -4
- package/cjs/components/Tabs/Tabs.js.map +1 -1
- package/cjs/components/TransferList/RenderList/RenderList.js +16 -3
- package/cjs/components/TransferList/RenderList/RenderList.js.map +1 -1
- package/cjs/components/TransferList/RenderList/RenderList.styles.js +0 -2
- package/cjs/components/TransferList/RenderList/RenderList.styles.js.map +1 -1
- package/esm/components/ActionIcon/ActionIcon.js +2 -5
- package/esm/components/ActionIcon/ActionIcon.js.map +1 -1
- package/esm/components/Code/Code.js +3 -1
- package/esm/components/Code/Code.js.map +1 -1
- package/esm/components/ColorInput/ColorInput.js +0 -2
- package/esm/components/ColorInput/ColorInput.js.map +1 -1
- package/esm/components/ColorInput/ColorInput.styles.js +0 -4
- package/esm/components/ColorInput/ColorInput.styles.js.map +1 -1
- package/esm/components/Drawer/Drawer.js +7 -1
- package/esm/components/Drawer/Drawer.js.map +1 -1
- package/esm/components/Input/Input.js +3 -0
- package/esm/components/Input/Input.js.map +1 -1
- package/esm/components/Input/Input.styles.js +11 -2
- package/esm/components/Input/Input.styles.js.map +1 -1
- package/esm/components/Menu/Menu.js +8 -3
- package/esm/components/Menu/Menu.js.map +1 -1
- package/esm/components/NumberInput/NumberInput.js.map +1 -1
- package/esm/components/Pagination/DefaultItem/DefaultItem.js +10 -1
- package/esm/components/Pagination/DefaultItem/DefaultItem.js.map +1 -1
- package/esm/components/Popover/Popover.js +8 -3
- package/esm/components/Popover/Popover.js.map +1 -1
- package/esm/components/Popper/Popper.js +28 -2
- package/esm/components/Popper/Popper.js.map +1 -1
- package/esm/components/Popper/Popper.styles.js +20 -12
- package/esm/components/Popper/Popper.styles.js.map +1 -1
- package/esm/components/Portal/Portal.js +3 -0
- package/esm/components/Portal/Portal.js.map +1 -1
- package/esm/components/Progress/Progress.js +3 -3
- package/esm/components/Progress/Progress.js.map +1 -1
- package/esm/components/ScrollArea/ScrollArea.js +5 -3
- package/esm/components/ScrollArea/ScrollArea.js.map +1 -1
- package/esm/components/ScrollArea/ScrollArea.styles.js +2 -3
- package/esm/components/ScrollArea/ScrollArea.styles.js.map +1 -1
- package/esm/components/SegmentedControl/SegmentedControl.js +34 -11
- package/esm/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/esm/components/SegmentedControl/SegmentedControl.styles.js +53 -41
- package/esm/components/SegmentedControl/SegmentedControl.styles.js.map +1 -1
- package/esm/components/Select/Select.js +5 -4
- package/esm/components/Select/Select.js.map +1 -1
- package/esm/components/Slider/RangeSlider/RangeSlider.js +21 -6
- package/esm/components/Slider/RangeSlider/RangeSlider.js.map +1 -1
- package/esm/components/Slider/Slider/Slider.js +17 -5
- package/esm/components/Slider/Slider/Slider.js.map +1 -1
- package/esm/components/Slider/Thumb/Thumb.js +3 -2
- package/esm/components/Slider/Thumb/Thumb.js.map +1 -1
- package/esm/components/Tabs/Tabs.js +5 -4
- package/esm/components/Tabs/Tabs.js.map +1 -1
- package/esm/components/TransferList/RenderList/RenderList.js +16 -3
- package/esm/components/TransferList/RenderList/RenderList.js.map +1 -1
- package/esm/components/TransferList/RenderList/RenderList.styles.js +0 -2
- package/esm/components/TransferList/RenderList/RenderList.styles.js.map +1 -1
- package/lib/components/Code/Code.d.ts.map +1 -1
- package/lib/components/ColorInput/ColorInput.d.ts.map +1 -1
- package/lib/components/ColorInput/ColorInput.styles.d.ts +2 -2
- package/lib/components/ColorInput/ColorInput.styles.d.ts.map +1 -1
- package/lib/components/Drawer/Drawer.d.ts.map +1 -1
- package/lib/components/Input/Input.d.ts +2 -0
- package/lib/components/Input/Input.d.ts.map +1 -1
- package/lib/components/Input/Input.styles.d.ts +1 -0
- package/lib/components/Input/Input.styles.d.ts.map +1 -1
- package/lib/components/Menu/Menu.d.ts +2 -0
- package/lib/components/Menu/Menu.d.ts.map +1 -1
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/lib/components/Pagination/DefaultItem/DefaultItem.d.ts.map +1 -1
- package/lib/components/Popover/Popover.d.ts +3 -1
- package/lib/components/Popover/Popover.d.ts.map +1 -1
- package/lib/components/Popper/Popper.d.ts.map +1 -1
- package/lib/components/Popper/Popper.styles.d.ts +2 -1
- package/lib/components/Popper/Popper.styles.d.ts.map +1 -1
- package/lib/components/Portal/Portal.d.ts.map +1 -1
- package/lib/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/lib/components/ScrollArea/ScrollArea.styles.d.ts +0 -1
- package/lib/components/ScrollArea/ScrollArea.styles.d.ts.map +1 -1
- package/lib/components/SegmentedControl/SegmentedControl.d.ts +4 -0
- package/lib/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/lib/components/SegmentedControl/SegmentedControl.styles.d.ts +3 -2
- package/lib/components/SegmentedControl/SegmentedControl.styles.d.ts.map +1 -1
- package/lib/components/Select/Select.d.ts.map +1 -1
- package/lib/components/Slider/RangeSlider/RangeSlider.d.ts.map +1 -1
- package/lib/components/Slider/Slider/Slider.d.ts +1 -1
- package/lib/components/Slider/Slider/Slider.d.ts.map +1 -1
- package/lib/components/Slider/Thumb/Thumb.d.ts.map +1 -1
- package/lib/components/Tabs/Tabs.d.ts.map +1 -1
- package/lib/components/TransferList/RenderList/RenderList.d.ts.map +1 -1
- package/lib/components/TransferList/RenderList/RenderList.styles.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var Progress_styles = require('./Progress.styles.js');
|
|
7
|
-
var Text = require('../Text/Text.js');
|
|
8
7
|
var Box = require('../Box/Box.js');
|
|
8
|
+
var Text = require('../Text/Text.js');
|
|
9
9
|
|
|
10
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
11
11
|
|
|
@@ -78,10 +78,10 @@ const Progress = React.forwardRef((_a, ref) => {
|
|
|
78
78
|
"sections"
|
|
79
79
|
]);
|
|
80
80
|
const { classes, cx, theme } = Progress_styles['default']({ color, size, radius, striped: striped || animate, animate }, { classNames, styles, name: "Progress" });
|
|
81
|
-
const segments = Array.isArray(sections) ? getCumulativeSections(sections).map((section, index) => /* @__PURE__ */ React__default.createElement(
|
|
81
|
+
const segments = Array.isArray(sections) ? getCumulativeSections(sections).map((section, index) => /* @__PURE__ */ React__default.createElement(Box.Box, {
|
|
82
82
|
key: index,
|
|
83
83
|
className: classes.bar,
|
|
84
|
-
|
|
84
|
+
sx: {
|
|
85
85
|
width: `${section.value}%`,
|
|
86
86
|
left: `${section.accumulated}%`,
|
|
87
87
|
backgroundColor: theme.fn.themeColor(section.color, 6, false)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Progress.js","sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { DefaultProps, MantineNumberSize, MantineColor, ClassNames } from '@mantine/styles';\nimport { Box } from '../Box';\nimport useStyles from './Progress.styles';\nimport { Text } from '../Text';\n\nexport type ProgressStylesNames = ClassNames<typeof useStyles>;\n\nexport interface ProgressProps\n extends DefaultProps<ProgressStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Percent of filled bar (0-100) */\n value?: number;\n\n /** Progress color from theme */\n color?: MantineColor;\n\n /** Predefined progress height or number for height in px */\n size?: MantineNumberSize;\n\n /** Predefined progress radius from theme.radius or number for height in px */\n radius?: MantineNumberSize;\n\n /** Adds stripes */\n striped?: boolean;\n\n /** Whether to animate striped progress bars */\n animate?: boolean;\n\n /** Text to be placed inside the progress bar */\n label?: string;\n\n /** Replaces value if present, renders multiple sections instead of single one */\n sections?: { value: number; color: MantineColor; label?: string }[];\n}\n\nfunction getCumulativeSections(\n sections: { value: number; color: MantineColor; label?: string }[]\n): { value: number; color: MantineColor; accumulated: number; label?: string }[] {\n return sections.reduce(\n (acc, section) => {\n acc.sections.push({ ...section, accumulated: acc.accumulated });\n acc.accumulated += section.value;\n return acc;\n },\n { accumulated: 0, sections: [] }\n ).sections;\n}\n\nexport const Progress = forwardRef<HTMLDivElement, ProgressProps>(\n (\n {\n className,\n value,\n color,\n size = 'md',\n radius = 'sm',\n striped = false,\n animate = false,\n label = '',\n 'aria-label': ariaLabel,\n classNames,\n styles,\n sections,\n ...others\n }: ProgressProps,\n ref\n ) => {\n const { classes, cx, theme } = useStyles(\n { color, size, radius, striped: striped || animate, animate },\n { classNames, styles, name: 'Progress' }\n );\n\n const segments = Array.isArray(sections)\n ? getCumulativeSections(sections).map((section, index) => (\n <
|
|
1
|
+
{"version":3,"file":"Progress.js","sources":["../../../src/components/Progress/Progress.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { DefaultProps, MantineNumberSize, MantineColor, ClassNames } from '@mantine/styles';\nimport { Box } from '../Box';\nimport useStyles from './Progress.styles';\nimport { Text } from '../Text';\n\nexport type ProgressStylesNames = ClassNames<typeof useStyles>;\n\nexport interface ProgressProps\n extends DefaultProps<ProgressStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Percent of filled bar (0-100) */\n value?: number;\n\n /** Progress color from theme */\n color?: MantineColor;\n\n /** Predefined progress height or number for height in px */\n size?: MantineNumberSize;\n\n /** Predefined progress radius from theme.radius or number for height in px */\n radius?: MantineNumberSize;\n\n /** Adds stripes */\n striped?: boolean;\n\n /** Whether to animate striped progress bars */\n animate?: boolean;\n\n /** Text to be placed inside the progress bar */\n label?: string;\n\n /** Replaces value if present, renders multiple sections instead of single one */\n sections?: { value: number; color: MantineColor; label?: string }[];\n}\n\nfunction getCumulativeSections(\n sections: { value: number; color: MantineColor; label?: string }[]\n): { value: number; color: MantineColor; accumulated: number; label?: string }[] {\n return sections.reduce(\n (acc, section) => {\n acc.sections.push({ ...section, accumulated: acc.accumulated });\n acc.accumulated += section.value;\n return acc;\n },\n { accumulated: 0, sections: [] }\n ).sections;\n}\n\nexport const Progress = forwardRef<HTMLDivElement, ProgressProps>(\n (\n {\n className,\n value,\n color,\n size = 'md',\n radius = 'sm',\n striped = false,\n animate = false,\n label = '',\n 'aria-label': ariaLabel,\n classNames,\n styles,\n sections,\n ...others\n }: ProgressProps,\n ref\n ) => {\n const { classes, cx, theme } = useStyles(\n { color, size, radius, striped: striped || animate, animate },\n { classNames, styles, name: 'Progress' }\n );\n\n const segments = Array.isArray(sections)\n ? getCumulativeSections(sections).map((section, index) => (\n <Box\n key={index}\n className={classes.bar}\n sx={{\n width: `${section.value}%`,\n left: `${section.accumulated}%`,\n backgroundColor: theme.fn.themeColor(section.color, 6, false),\n }}\n >\n {section.label && <Text className={classes.label}>{section.label}</Text>}\n </Box>\n ))\n : null;\n\n return (\n <Box className={cx(classes.root, className)} ref={ref} {...others}>\n {segments || (\n <div\n role=\"progressbar\"\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={value}\n aria-label={ariaLabel}\n className={classes.bar}\n style={{ width: `${value}%` }}\n >\n {label ? <Text className={classes.label}>{label}</Text> : ''}\n </div>\n )}\n </Box>\n );\n }\n);\n\nProgress.displayName = '@mantine/core/Progress';\n"],"names":["forwardRef","useStyles","React","Box","Text"],"mappings":";;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAA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');
|
|
6
6
|
var RadixScrollArea = require('@radix-ui/react-scroll-area');
|
|
7
|
+
var styles = require('@mantine/styles');
|
|
7
8
|
var ScrollArea_styles = require('./ScrollArea.styles.js');
|
|
8
9
|
var Box = require('../Box/Box.js');
|
|
9
10
|
|
|
@@ -57,11 +58,11 @@ const ScrollArea = React.forwardRef((_a, ref) => {
|
|
|
57
58
|
children,
|
|
58
59
|
className,
|
|
59
60
|
classNames,
|
|
60
|
-
styles,
|
|
61
|
+
styles: styles$1,
|
|
61
62
|
scrollbarSize = 12,
|
|
62
63
|
scrollHideDelay = 1e3,
|
|
63
64
|
type = "hover",
|
|
64
|
-
dir
|
|
65
|
+
dir,
|
|
65
66
|
offsetScrollbars = false,
|
|
66
67
|
viewportRef,
|
|
67
68
|
onScrollPositionChange
|
|
@@ -79,11 +80,12 @@ const ScrollArea = React.forwardRef((_a, ref) => {
|
|
|
79
80
|
"onScrollPositionChange"
|
|
80
81
|
]);
|
|
81
82
|
const [scrollbarHovered, setScrollbarHovered] = React.useState(false);
|
|
82
|
-
const
|
|
83
|
+
const theme = styles.useMantineTheme();
|
|
84
|
+
const { classes, cx } = ScrollArea_styles['default']({ scrollbarSize, offsetScrollbars, scrollbarHovered }, { name: "ScrollArea", classNames, styles: styles$1 });
|
|
83
85
|
return /* @__PURE__ */ React__default.createElement(RadixScrollArea__namespace.Root, {
|
|
84
86
|
type,
|
|
85
87
|
scrollHideDelay,
|
|
86
|
-
dir,
|
|
88
|
+
dir: dir || theme.dir,
|
|
87
89
|
ref,
|
|
88
90
|
asChild: true
|
|
89
91
|
}, /* @__PURE__ */ React__default.createElement(Box.Box, __spreadValues({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollArea.js","sources":["../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import React, { useState, forwardRef } from 'react';\nimport * as RadixScrollArea from '@radix-ui/react-scroll-area';\nimport { DefaultProps, ClassNames } from '@mantine/styles';\nimport { Box } from '../Box';\nimport useStyles from './ScrollArea.styles';\n\nexport type ScrollAreaStylesNames = ClassNames<typeof useStyles>;\n\nexport interface ScrollAreaProps\n extends DefaultProps<ScrollAreaStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Scrollbar size in px */\n scrollbarSize?: number;\n\n /** Scrollbars type */\n type?: 'auto' | 'always' | 'scroll' | 'hover';\n\n /** Scroll hide delay in ms, for scroll and hover types only */\n scrollHideDelay?: number;\n\n /** Reading direction of the scroll area */\n dir?: 'ltr' | 'rtl';\n\n /** Should scrollbars be offset with padding */\n offsetScrollbars?: boolean;\n\n /** Get viewport ref */\n viewportRef?: React.ForwardedRef<HTMLDivElement>;\n\n /** Subscribe to scroll position changes */\n onScrollPositionChange?(position: { x: number; y: number }): void;\n}\n\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(\n (\n {\n children,\n className,\n classNames,\n styles,\n scrollbarSize = 12,\n scrollHideDelay = 1000,\n type = 'hover',\n dir
|
|
1
|
+
{"version":3,"file":"ScrollArea.js","sources":["../../../src/components/ScrollArea/ScrollArea.tsx"],"sourcesContent":["import React, { useState, forwardRef } from 'react';\nimport * as RadixScrollArea from '@radix-ui/react-scroll-area';\nimport { DefaultProps, ClassNames, useMantineTheme } from '@mantine/styles';\nimport { Box } from '../Box';\nimport useStyles from './ScrollArea.styles';\n\nexport type ScrollAreaStylesNames = ClassNames<typeof useStyles>;\n\nexport interface ScrollAreaProps\n extends DefaultProps<ScrollAreaStylesNames>,\n React.ComponentPropsWithoutRef<'div'> {\n /** Scrollbar size in px */\n scrollbarSize?: number;\n\n /** Scrollbars type */\n type?: 'auto' | 'always' | 'scroll' | 'hover';\n\n /** Scroll hide delay in ms, for scroll and hover types only */\n scrollHideDelay?: number;\n\n /** Reading direction of the scroll area */\n dir?: 'ltr' | 'rtl';\n\n /** Should scrollbars be offset with padding */\n offsetScrollbars?: boolean;\n\n /** Get viewport ref */\n viewportRef?: React.ForwardedRef<HTMLDivElement>;\n\n /** Subscribe to scroll position changes */\n onScrollPositionChange?(position: { x: number; y: number }): void;\n}\n\nexport const ScrollArea = forwardRef<HTMLDivElement, ScrollAreaProps>(\n (\n {\n children,\n className,\n classNames,\n styles,\n scrollbarSize = 12,\n scrollHideDelay = 1000,\n type = 'hover',\n dir,\n offsetScrollbars = false,\n viewportRef,\n onScrollPositionChange,\n ...others\n }: ScrollAreaProps,\n ref\n ) => {\n const [scrollbarHovered, setScrollbarHovered] = useState(false);\n const theme = useMantineTheme();\n const { classes, cx } = useStyles(\n { scrollbarSize, offsetScrollbars, scrollbarHovered },\n { name: 'ScrollArea', classNames, styles }\n );\n\n return (\n <RadixScrollArea.Root\n type={type}\n scrollHideDelay={scrollHideDelay}\n dir={dir || theme.dir}\n ref={ref}\n asChild\n >\n <Box className={cx(classes.root, className)} {...others}>\n <RadixScrollArea.Viewport\n className={classes.viewport}\n ref={viewportRef}\n onScroll={\n typeof onScrollPositionChange === 'function'\n ? ({ currentTarget }) =>\n onScrollPositionChange({\n x: currentTarget.scrollLeft,\n y: currentTarget.scrollTop,\n })\n : undefined\n }\n >\n {children}\n </RadixScrollArea.Viewport>\n <RadixScrollArea.Scrollbar\n orientation=\"horizontal\"\n className={classes.scrollbar}\n forceMount\n onMouseEnter={() => setScrollbarHovered(true)}\n onMouseLeave={() => setScrollbarHovered(false)}\n >\n <RadixScrollArea.Thumb className={classes.thumb} />\n </RadixScrollArea.Scrollbar>\n <RadixScrollArea.Scrollbar\n orientation=\"vertical\"\n className={classes.scrollbar}\n forceMount\n onMouseEnter={() => setScrollbarHovered(true)}\n onMouseLeave={() => setScrollbarHovered(false)}\n >\n <RadixScrollArea.Thumb className={classes.thumb} />\n </RadixScrollArea.Scrollbar>\n <RadixScrollArea.Corner className={classes.corner} />\n </Box>\n </RadixScrollArea.Root>\n );\n }\n);\n\nScrollArea.displayName = '@mantine/core/ScrollArea';\n"],"names":["forwardRef","styles","useState","useMantineTheme","useStyles","React","RadixScrollArea","Box"],"mappings":";;;;;;;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AChC,IAAI,UAAU,EAAE,IAAI;AACpB,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC,IAAI,CAAC;AACjD,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC,KAAK,CAAC;AAClD,GAAG,kBAAkBD,cAAK,CAAC,aAAa,CAACC,0BAAe,CAAC,KAAK,EAAE;AAChE,IAAI,SAAS,EAAE,OAAO,CAAC,KAAK;AAC5B,GAAG,CAAC,CAAC,kBAAkBD,cAAK,CAAC,aAAa,CAACC,0BAAe,CAAC,SAAS,EAAE;AACtE,IAAI,WAAW,EAAE,UAAU;AAC3B,IAAI,SAAS,EAAE,OAAO,CAAC,SAAS;AAChC,IAAI,UAAU,EAAE,IAAI;AACpB,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC,IAAI,CAAC;AACjD,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC,KAAK,CAAC;AAClD,GAAG,kBAAkBD,cAAK,CAAC,aAAa,CAACC,0BAAe,CAAC,KAAK,EAAE;AAChE,IAAI,SAAS,EAAE,OAAO,CAAC,KAAK;AAC5B,GAAG,CAAC,CAAC,kBAAkBD,cAAK,CAAC,aAAa,CAACC,0BAAe,CAAC,MAAM,EAAE;AACnE,IAAI,SAAS,EAAE,OAAO,CAAC,MAAM;AAC7B,GAAG,CAAC,CAAC,CAAC,CAAC;AACP,CAAC,EAAE;AACH,UAAU,CAAC,WAAW,GAAG,0BAA0B;;;;"}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var styles = require('@mantine/styles');
|
|
6
6
|
|
|
7
|
-
var useStyles = styles.createStyles((theme, { scrollbarSize,
|
|
7
|
+
var useStyles = styles.createStyles((theme, { scrollbarSize, offsetScrollbars, scrollbarHovered }, getRef) => {
|
|
8
8
|
const thumb = getRef("thumb");
|
|
9
9
|
return {
|
|
10
10
|
root: {
|
|
@@ -13,8 +13,7 @@ var useStyles = styles.createStyles((theme, { scrollbarSize, dir, offsetScrollba
|
|
|
13
13
|
viewport: {
|
|
14
14
|
width: "100%",
|
|
15
15
|
height: "100%",
|
|
16
|
-
paddingRight:
|
|
17
|
-
paddingLeft: dir === "rtl" && offsetScrollbars ? scrollbarSize : void 0
|
|
16
|
+
paddingRight: offsetScrollbars ? scrollbarSize : void 0
|
|
18
17
|
},
|
|
19
18
|
scrollbar: {
|
|
20
19
|
display: "flex",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollArea.styles.js","sources":["../../../src/components/ScrollArea/ScrollArea.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/styles';\n\ninterface ScrollAreaStyles {\n scrollbarSize: number;\n
|
|
1
|
+
{"version":3,"file":"ScrollArea.styles.js","sources":["../../../src/components/ScrollArea/ScrollArea.styles.ts"],"sourcesContent":["import { createStyles } from '@mantine/styles';\n\ninterface ScrollAreaStyles {\n scrollbarSize: number;\n offsetScrollbars: boolean;\n scrollbarHovered: boolean;\n}\n\nexport default createStyles(\n (theme, { scrollbarSize, offsetScrollbars, scrollbarHovered }: ScrollAreaStyles, getRef) => {\n const thumb = getRef('thumb');\n return {\n root: {\n overflow: 'hidden',\n },\n\n viewport: {\n width: '100%',\n height: '100%',\n paddingRight: offsetScrollbars ? scrollbarSize : undefined,\n },\n\n scrollbar: {\n display: 'flex',\n userSelect: 'none',\n touchAction: 'none',\n boxSizing: 'border-box',\n padding: scrollbarSize / 5,\n transition: 'background-color 150ms ease, opacity 150ms ease',\n\n '&:hover': {\n backgroundColor:\n theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.colors.gray[0],\n [`& .${thumb}`]: {\n backgroundColor:\n theme.colorScheme === 'dark'\n ? theme.fn.rgba('#ffffff', 0.5)\n : theme.fn.rgba(theme.black, 0.5),\n },\n },\n\n '&[data-orientation=\"vertical\"]': {\n width: scrollbarSize,\n },\n\n '&[data-orientation=\"horizontal\"]': {\n flexDirection: 'column',\n height: scrollbarSize,\n },\n\n '&[data-state=\"hidden\"]': {\n opacity: 0,\n },\n },\n\n thumb: {\n ref: thumb,\n flex: 1,\n backgroundColor:\n theme.colorScheme === 'dark'\n ? theme.fn.rgba('#ffffff', 0.4)\n : theme.fn.rgba(theme.black, 0.4),\n borderRadius: scrollbarSize,\n position: 'relative',\n transition: 'background-color 150ms ease',\n\n '&::before': {\n content: '\"\"',\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n width: '100%',\n height: '100%',\n minWidth: 44,\n minHeight: 44,\n },\n },\n\n corner: {\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[0],\n transition: 'opacity 150ms ease',\n opacity: scrollbarHovered ? 1 : 0,\n },\n };\n }\n);\n"],"names":["createStyles"],"mappings":";;;;;;AACA,gBAAeA,mBAAY,CAAC,CAAC,KAAK,EAAE,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,EAAE,MAAM,KAAK;AACtG,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE;AACV,MAAM,QAAQ,EAAE,QAAQ;AACxB,KAAK;AACL,IAAI,QAAQ,EAAE;AACd,MAAM,KAAK,EAAE,MAAM;AACnB,MAAM,MAAM,EAAE,MAAM;AACpB,MAAM,YAAY,EAAE,gBAAgB,GAAG,aAAa,GAAG,KAAK,CAAC;AAC7D,KAAK;AACL,IAAI,SAAS,EAAE;AACf,MAAM,OAAO,EAAE,MAAM;AACrB,MAAM,UAAU,EAAE,MAAM;AACxB,MAAM,WAAW,EAAE,MAAM;AACzB,MAAM,SAAS,EAAE,YAAY;AAC7B,MAAM,OAAO,EAAE,aAAa,GAAG,CAAC;AAChC,MAAM,UAAU,EAAE,iDAAiD;AACnE,MAAM,SAAS,EAAE;AACjB,QAAQ,eAAe,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,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,MAAM;AACtB,QAAQ,QAAQ,EAAE,EAAE;AACpB,QAAQ,SAAS,EAAE,EAAE;AACrB,OAAO;AACP,KAAK;AACL,IAAI,MAAM,EAAE;AACZ,MAAM,eAAe,EAAE,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjG,MAAM,UAAU,EAAE,oBAAoB;AACtC,MAAM,OAAO,EAAE,gBAAgB,GAAG,CAAC,GAAG,CAAC;AACvC,KAAK;AACL,GAAG,CAAC;AACJ,CAAC,CAAC;;;;"}
|
|
@@ -42,6 +42,7 @@ var __objRest = (source, exclude) => {
|
|
|
42
42
|
const SegmentedControl = React.forwardRef((_a, ref) => {
|
|
43
43
|
var _b = _a, {
|
|
44
44
|
className,
|
|
45
|
+
disabled = false,
|
|
45
46
|
data: _data,
|
|
46
47
|
name,
|
|
47
48
|
value,
|
|
@@ -54,9 +55,11 @@ const SegmentedControl = React.forwardRef((_a, ref) => {
|
|
|
54
55
|
transitionTimingFunction,
|
|
55
56
|
classNames,
|
|
56
57
|
styles,
|
|
57
|
-
defaultValue
|
|
58
|
+
defaultValue,
|
|
59
|
+
orientation
|
|
58
60
|
} = _b, others = __objRest(_b, [
|
|
59
61
|
"className",
|
|
62
|
+
"disabled",
|
|
60
63
|
"data",
|
|
61
64
|
"name",
|
|
62
65
|
"value",
|
|
@@ -69,7 +72,8 @@ const SegmentedControl = React.forwardRef((_a, ref) => {
|
|
|
69
72
|
"transitionTimingFunction",
|
|
70
73
|
"classNames",
|
|
71
74
|
"styles",
|
|
72
|
-
"defaultValue"
|
|
75
|
+
"defaultValue",
|
|
76
|
+
"orientation"
|
|
73
77
|
]);
|
|
74
78
|
const reduceMotion = hooks.useReducedMotion();
|
|
75
79
|
const data = _data.map((item) => typeof item === "string" ? { label: item, value: item } : item);
|
|
@@ -81,16 +85,21 @@ const SegmentedControl = React.forwardRef((_a, ref) => {
|
|
|
81
85
|
onChange,
|
|
82
86
|
rule: (val) => !!val
|
|
83
87
|
});
|
|
84
|
-
const { classes, cx } = SegmentedControl_styles['default']({
|
|
88
|
+
const { classes, cx, theme } = SegmentedControl_styles['default']({
|
|
85
89
|
size,
|
|
86
90
|
fullWidth,
|
|
87
91
|
color,
|
|
88
92
|
radius,
|
|
89
93
|
shouldAnimate: reduceMotion || !shouldAnimate,
|
|
90
94
|
transitionDuration,
|
|
91
|
-
transitionTimingFunction
|
|
95
|
+
transitionTimingFunction,
|
|
96
|
+
orientation
|
|
92
97
|
}, { classNames, styles, name: "SegmentedControl" });
|
|
93
|
-
const [activePosition, setActivePosition] = React.useState({
|
|
98
|
+
const [activePosition, setActivePosition] = React.useState({
|
|
99
|
+
width: 0,
|
|
100
|
+
height: 0,
|
|
101
|
+
translate: [0, 0]
|
|
102
|
+
});
|
|
94
103
|
const uuid = hooks.useUuid(name);
|
|
95
104
|
const refs = React.useRef({});
|
|
96
105
|
const [observerRef, containerRect] = hooks.useResizeObserver();
|
|
@@ -99,9 +108,17 @@ const SegmentedControl = React.forwardRef((_a, ref) => {
|
|
|
99
108
|
const element = refs.current[_value];
|
|
100
109
|
const elementRect = element.getBoundingClientRect();
|
|
101
110
|
const scaledValue = element.offsetWidth / elementRect.width;
|
|
111
|
+
const width = elementRect.width * scaledValue || 0;
|
|
112
|
+
const height = elementRect.height * scaledValue || 0;
|
|
113
|
+
const offsetRight = containerRect.width - element.parentElement.offsetLeft + SegmentedControl_styles.WRAPPER_PADDING - width;
|
|
114
|
+
const offsetLeft = element.parentElement.offsetLeft - SegmentedControl_styles.WRAPPER_PADDING;
|
|
102
115
|
setActivePosition({
|
|
103
|
-
width
|
|
104
|
-
|
|
116
|
+
width,
|
|
117
|
+
height,
|
|
118
|
+
translate: [
|
|
119
|
+
theme.dir === "rtl" ? offsetRight : offsetLeft,
|
|
120
|
+
element.parentElement.offsetTop - SegmentedControl_styles.WRAPPER_PADDING
|
|
121
|
+
]
|
|
105
122
|
});
|
|
106
123
|
}
|
|
107
124
|
}, [_value, containerRect]);
|
|
@@ -113,6 +130,7 @@ const SegmentedControl = React.forwardRef((_a, ref) => {
|
|
|
113
130
|
key: item.value
|
|
114
131
|
}, /* @__PURE__ */ React__default.createElement("input", {
|
|
115
132
|
className: classes.input,
|
|
133
|
+
disabled,
|
|
116
134
|
type: "radio",
|
|
117
135
|
name: uuid,
|
|
118
136
|
value: item.value,
|
|
@@ -120,7 +138,10 @@ const SegmentedControl = React.forwardRef((_a, ref) => {
|
|
|
120
138
|
checked: _value === item.value,
|
|
121
139
|
onChange: () => handleValueChange(item.value)
|
|
122
140
|
}), /* @__PURE__ */ React__default.createElement("label", {
|
|
123
|
-
className: cx(classes.label, {
|
|
141
|
+
className: cx(classes.label, {
|
|
142
|
+
[classes.labelActive]: _value === item.value,
|
|
143
|
+
[classes.disabled]: disabled
|
|
144
|
+
}),
|
|
124
145
|
htmlFor: `${uuid}-${item.value}`,
|
|
125
146
|
ref: (node) => {
|
|
126
147
|
refs.current[item.value] = node;
|
|
@@ -129,11 +150,13 @@ const SegmentedControl = React.forwardRef((_a, ref) => {
|
|
|
129
150
|
return /* @__PURE__ */ React__default.createElement(Box.Box, __spreadValues({
|
|
130
151
|
className: cx(classes.root, className),
|
|
131
152
|
ref: hooks.useMergedRef(observerRef, ref)
|
|
132
|
-
}, others), !!_value && /* @__PURE__ */ React__default.createElement(
|
|
153
|
+
}, others), !!_value && /* @__PURE__ */ React__default.createElement(Box.Box, {
|
|
154
|
+
component: "span",
|
|
133
155
|
className: classes.active,
|
|
134
|
-
|
|
156
|
+
sx: {
|
|
135
157
|
width: activePosition.width,
|
|
136
|
-
|
|
158
|
+
height: activePosition.height,
|
|
159
|
+
transform: `translate(${activePosition.translate[0]}px, ${activePosition.translate[1]}px )`
|
|
137
160
|
}
|
|
138
161
|
}), controls);
|
|
139
162
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.js","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState, forwardRef } from 'react';\nimport {\n useReducedMotion,\n useResizeObserver,\n useUncontrolled,\n useUuid,\n useMergedRef,\n} from '@mantine/hooks';\nimport {\n DefaultProps,\n MantineNumberSize,\n MantineSize,\n MantineColor,\n ClassNames,\n} from '@mantine/styles';\nimport { Box } from '../Box';\nimport useStyles, { WRAPPER_PADDING } from './SegmentedControl.styles';\n\nexport interface SegmentedControlItem {\n value: string;\n label: React.ReactNode;\n}\n\nexport type SegmentedControlStylesNames = ClassNames<typeof useStyles>;\n\nexport interface SegmentedControlProps\n extends DefaultProps<SegmentedControlStylesNames>,\n Omit<React.ComponentPropsWithoutRef<'div'>, 'value' | 'onChange'> {\n /** Data based on which controls are rendered */\n data: string[] | SegmentedControlItem[];\n\n /** Current selected value */\n value?: string;\n\n /** Called when value changes */\n onChange?(value: string): void;\n\n /** Name of the radio group, default to random id */\n name?: string;\n\n /** True if component should have 100% width */\n fullWidth?: boolean;\n\n /** Active control color from theme.colors, defaults to white in light color scheme and theme.colors.dark[9] in dark */\n color?: MantineColor;\n\n /** Controls font-size, paddings and height */\n size?: MantineSize;\n\n /** Border-radius from theme or number to set border-radius in px */\n radius?: MantineNumberSize;\n\n /** Transition duration in ms, set to 0 to turn off transitions */\n transitionDuration?: number;\n\n /** Transition timing function for all transitions, defaults to theme.transitionTimingFunction */\n transitionTimingFunction?: string;\n\n /** Default value for uncontrolled component */\n defaultValue?: string;\n}\n\nexport const SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(\n (\n {\n className,\n data: _data,\n name,\n value,\n onChange,\n color,\n fullWidth,\n radius = 'sm',\n size = 'sm',\n transitionDuration = 200,\n transitionTimingFunction,\n classNames,\n styles,\n defaultValue,\n ...others\n },\n ref\n ) => {\n const reduceMotion = useReducedMotion();\n const data = _data.map((item: any) =>\n typeof item === 'string' ? { label: item, value: item } : item\n );\n\n const [shouldAnimate, setShouldAnimate] = useState(false);\n const [_value, handleValueChange] = useUncontrolled({\n value,\n defaultValue,\n finalValue: Array.isArray(data) ? data[0].value : null,\n onChange,\n rule: (val) => !!val,\n });\n\n const { classes, cx } = useStyles(\n {\n size,\n fullWidth,\n color,\n radius,\n shouldAnimate: reduceMotion || !shouldAnimate,\n transitionDuration,\n transitionTimingFunction,\n },\n { classNames, styles, name: 'SegmentedControl' }\n );\n\n const [activePosition, setActivePosition] = useState({ width: 0, translate: 0 });\n const uuid = useUuid(name);\n const refs = useRef<Record<string, HTMLLabelElement>>({});\n const [observerRef, containerRect] = useResizeObserver();\n\n useEffect(() => {\n if (_value in refs.current && observerRef.current) {\n const element = refs.current[_value];\n const elementRect = element.getBoundingClientRect();\n const scaledValue = element.offsetWidth / elementRect.width;\n\n setActivePosition({\n width: elementRect.width * scaledValue || 0,\n translate: element.parentElement.offsetLeft - WRAPPER_PADDING,\n });\n }\n }, [_value, containerRect]);\n\n useEffect(() => {\n setShouldAnimate(true);\n }, []);\n\n const controls = data.map((item) => (\n <div\n className={cx(classes.control, { [classes.controlActive]: _value === item.value })}\n key={item.value}\n >\n <input\n className={classes.input}\n type=\"radio\"\n name={uuid}\n value={item.value}\n id={`${uuid}-${item.value}`}\n checked={_value === item.value}\n onChange={() => handleValueChange(item.value)}\n />\n\n <label\n className={cx(classes.label, { [classes.labelActive]: _value === item.value })}\n htmlFor={`${uuid}-${item.value}`}\n ref={(node) => {\n refs.current[item.value] = node;\n }}\n >\n {item.label}\n </label>\n </div>\n ));\n\n return (\n <Box className={cx(classes.root, className)} ref={useMergedRef(observerRef, ref)} {...others}>\n {!!_value && (\n <span\n className={classes.active}\n style={{\n width: activePosition.width,\n transform: `translateX(${activePosition.translate}px)`,\n }}\n />\n )}\n\n {controls}\n </Box>\n );\n }\n);\n\nSegmentedControl.displayName = '@mantine/core/SegmentedControl';\n"],"names":["forwardRef","useReducedMotion","useState","useUncontrolled","useStyles","useUuid","useRef","useResizeObser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,MAAM,KAAK,EAAE,cAAc,CAAC,KAAK;AACjC,MAAM,SAAS,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC;AAC5D,KAAK;AACL,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;AAChB,CAAC,EAAE;AACH,gBAAgB,CAAC,WAAW,GAAG,gCAAgC;;;;"}
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","sources":["../../../src/components/SegmentedControl/SegmentedControl.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState, forwardRef } from 'react';\nimport {\n useReducedMotion,\n useResizeObserver,\n useUncontrolled,\n useUuid,\n useMergedRef,\n} from '@mantine/hooks';\nimport {\n DefaultProps,\n MantineNumberSize,\n MantineSize,\n MantineColor,\n ClassNames,\n} from '@mantine/styles';\nimport { Box } from '../Box';\nimport useStyles, { WRAPPER_PADDING } from './SegmentedControl.styles';\n\nexport interface SegmentedControlItem {\n value: string;\n label: React.ReactNode;\n}\n\nexport type SegmentedControlStylesNames = ClassNames<typeof useStyles>;\n\nexport interface SegmentedControlProps\n extends DefaultProps<SegmentedControlStylesNames>,\n Omit<React.ComponentPropsWithoutRef<'div'>, 'value' | 'onChange'> {\n /** Data based on which controls are rendered */\n data: string[] | SegmentedControlItem[];\n\n /** Current selected value */\n value?: string;\n\n /** Disabled input state */\n disabled?: boolean;\n\n /** Called when value changes */\n onChange?(value: string): void;\n\n /** Name of the radio group, default to random id */\n name?: string;\n\n /** True if component should have 100% width */\n fullWidth?: boolean;\n\n /** Active control color from theme.colors, defaults to white in light color scheme and theme.colors.dark[9] in dark */\n color?: MantineColor;\n\n /** Controls font-size, paddings and height */\n size?: MantineSize;\n\n /** Border-radius from theme or number to set border-radius in px */\n radius?: MantineNumberSize;\n\n /** Transition duration in ms, set to 0 to turn off transitions */\n transitionDuration?: number;\n\n /** Transition timing function for all transitions, defaults to theme.transitionTimingFunction */\n transitionTimingFunction?: string;\n\n /** Default value for uncontrolled component */\n defaultValue?: string;\n\n /** Display Vertically */\n orientation?: 'vertical' | 'horizontal';\n}\n\nexport const SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(\n (\n {\n className,\n disabled = false,\n data: _data,\n name,\n value,\n onChange,\n color,\n fullWidth,\n radius = 'sm',\n size = 'sm',\n transitionDuration = 200,\n transitionTimingFunction,\n classNames,\n styles,\n defaultValue,\n orientation,\n ...others\n },\n ref\n ) => {\n const reduceMotion = useReducedMotion();\n const data = _data.map((item: any) =>\n typeof item === 'string' ? { label: item, value: item } : item\n );\n\n const [shouldAnimate, setShouldAnimate] = useState(false);\n const [_value, handleValueChange] = useUncontrolled({\n value,\n defaultValue,\n finalValue: Array.isArray(data) ? data[0].value : null,\n onChange,\n rule: (val) => !!val,\n });\n\n const { classes, cx, theme } = useStyles(\n {\n size,\n fullWidth,\n color,\n radius,\n shouldAnimate: reduceMotion || !shouldAnimate,\n transitionDuration,\n transitionTimingFunction,\n orientation,\n },\n { classNames, styles, name: 'SegmentedControl' }\n );\n\n const [activePosition, setActivePosition] = useState({\n width: 0,\n height: 0,\n translate: [0, 0],\n });\n const uuid = useUuid(name);\n const refs = useRef<Record<string, HTMLLabelElement>>({});\n const [observerRef, containerRect] = useResizeObserver();\n\n useEffect(() => {\n if (_value in refs.current && observerRef.current) {\n const element = refs.current[_value];\n const elementRect = element.getBoundingClientRect();\n const scaledValue = element.offsetWidth / elementRect.width;\n const width = elementRect.width * scaledValue || 0;\n const height = elementRect.height * scaledValue || 0;\n\n const offsetRight =\n containerRect.width - element.parentElement.offsetLeft + WRAPPER_PADDING - width;\n const offsetLeft = element.parentElement.offsetLeft - WRAPPER_PADDING;\n\n setActivePosition({\n width,\n height,\n translate: [\n theme.dir === 'rtl' ? offsetRight : offsetLeft,\n element.parentElement.offsetTop - WRAPPER_PADDING,\n ],\n });\n }\n }, [_value, containerRect]);\n\n useEffect(() => {\n setShouldAnimate(true);\n }, []);\n\n const controls = data.map((item) => (\n <div\n className={cx(classes.control, { [classes.controlActive]: _value === item.value })}\n key={item.value}\n >\n <input\n className={classes.input}\n disabled={disabled}\n type=\"radio\"\n name={uuid}\n value={item.value}\n id={`${uuid}-${item.value}`}\n checked={_value === item.value}\n onChange={() => handleValueChange(item.value)}\n />\n\n <label\n className={cx(classes.label, {\n [classes.labelActive]: _value === item.value,\n [classes.disabled]: disabled,\n })}\n htmlFor={`${uuid}-${item.value}`}\n ref={(node) => {\n refs.current[item.value] = node;\n }}\n >\n {item.label}\n </label>\n </div>\n ));\n\n return (\n <Box className={cx(classes.root, className)} ref={useMergedRef(observerRef, ref)} {...others}>\n {!!_value && (\n <Box\n component=\"span\"\n className={classes.active}\n sx={{\n width: activePosition.width,\n height: activePosition.height,\n transform: `translate(${activePosition.translate[0]}px, ${activePosition.translate[1]}px )`,\n }}\n />\n )}\n\n {controls}\n </Box>\n );\n }\n);\n\nSegmentedControl.displayName = '@mantine/core/SegmentedControl';\n"],"names":["forwardRef","useReducedMotion","useState","useUncontrolled","useStyles","useUuid","useRef","useResizeObserver","useEffect","WRAPPER_PADDING","React","Box","useMergedRef"],"mappings":";;;;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CA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G,EAAE;AACnE,IAAI,SAAS,EAAE,MAAM;AACrB,IAAI,SAAS,EAAE,OAAO,CAAC,MAAM;AAC7B,IAAI,EAAE,EAAE;AACR,MAAM,KAAK,EAAE,cAAc,CAAC,KAAK;AACjC,MAAM,MAAM,EAAE,cAAc,CAAC,MAAM;AACnC,MAAM,SAAS,EAAE,CAAC,UAAU,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjG,KAAK;AACL,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC;AAChB,CAAC,EAAE;AACH,gBAAgB,CAAC,WAAW,GAAG,gCAAgC;;;;"}
|
|
@@ -38,42 +38,47 @@ var useStyles = styles.createStyles((theme, {
|
|
|
38
38
|
shouldAnimate,
|
|
39
39
|
transitionDuration,
|
|
40
40
|
transitionTimingFunction,
|
|
41
|
-
size
|
|
41
|
+
size,
|
|
42
|
+
orientation
|
|
42
43
|
}, getRef) => {
|
|
43
|
-
const label =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
WebkitTapHighlightColor: "transparent",
|
|
47
|
-
borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),
|
|
48
|
-
fontWeight: 500,
|
|
49
|
-
fontSize: size in theme.fontSizes ? theme.fontSizes[size] : theme.fontSizes.sm,
|
|
50
|
-
cursor: "pointer",
|
|
51
|
-
display: "block",
|
|
52
|
-
textAlign: "center",
|
|
53
|
-
padding: sizes[size in sizes ? size : "sm"],
|
|
54
|
-
whiteSpace: "nowrap",
|
|
55
|
-
overflow: "hidden",
|
|
56
|
-
textOverflow: "ellipsis",
|
|
57
|
-
color: theme.colorScheme === "dark" ? theme.colors.dark[1] : theme.colors.gray[7],
|
|
58
|
-
transition: `color ${shouldAnimate ? 0 : transitionDuration}ms ${transitionTimingFunction || theme.transitionTimingFunction}`,
|
|
59
|
-
"&:hover": {
|
|
60
|
-
color: theme.colorScheme === "dark" ? theme.colors.dark[0] : theme.black
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
const control = {
|
|
64
|
-
ref: getRef("control"),
|
|
65
|
-
position: "relative",
|
|
66
|
-
boxSizing: "border-box",
|
|
67
|
-
flex: 1,
|
|
68
|
-
zIndex: 2,
|
|
69
|
-
transition: `border-left-color ${shouldAnimate ? 0 : transitionDuration}ms ${transitionTimingFunction || theme.transitionTimingFunction}`,
|
|
70
|
-
"&:not(:first-of-type)": {
|
|
71
|
-
borderLeft: `1px solid ${theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[3]}`
|
|
72
|
-
}
|
|
73
|
-
};
|
|
44
|
+
const label = getRef("label");
|
|
45
|
+
const control = getRef("control");
|
|
46
|
+
const vertical = orientation === "vertical";
|
|
74
47
|
return {
|
|
75
|
-
label
|
|
76
|
-
|
|
48
|
+
label: __spreadProps(__spreadValues(__spreadValues({
|
|
49
|
+
ref: label
|
|
50
|
+
}, theme.fn.focusStyles()), theme.fn.fontStyles()), {
|
|
51
|
+
WebkitTapHighlightColor: "transparent",
|
|
52
|
+
borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),
|
|
53
|
+
fontWeight: 500,
|
|
54
|
+
fontSize: size in theme.fontSizes ? theme.fontSizes[size] : theme.fontSizes.sm,
|
|
55
|
+
cursor: "pointer",
|
|
56
|
+
display: "block",
|
|
57
|
+
textAlign: "center",
|
|
58
|
+
padding: sizes[size in sizes ? size : "sm"],
|
|
59
|
+
whiteSpace: "nowrap",
|
|
60
|
+
overflow: "hidden",
|
|
61
|
+
textOverflow: "ellipsis",
|
|
62
|
+
userSelect: "none",
|
|
63
|
+
color: theme.colorScheme === "dark" ? theme.colors.dark[1] : theme.colors.gray[7],
|
|
64
|
+
transition: `color ${shouldAnimate ? 0 : transitionDuration}ms ${transitionTimingFunction || theme.transitionTimingFunction}`,
|
|
65
|
+
"&:hover": {
|
|
66
|
+
color: theme.colorScheme === "dark" ? theme.colors.dark[0] : theme.black
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
control: {
|
|
70
|
+
ref: control,
|
|
71
|
+
position: "relative",
|
|
72
|
+
boxSizing: "border-box",
|
|
73
|
+
flex: 1,
|
|
74
|
+
zIndex: 2,
|
|
75
|
+
transition: `border-left-color ${shouldAnimate ? 0 : transitionDuration}ms ${transitionTimingFunction || theme.transitionTimingFunction}`,
|
|
76
|
+
"&:not(:first-of-type)": {
|
|
77
|
+
borderStyle: "solid",
|
|
78
|
+
borderWidth: orientation === "vertical" ? "1px 0 0 0" : "0 0 0 1px",
|
|
79
|
+
borderColor: theme.colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[3]
|
|
80
|
+
}
|
|
81
|
+
},
|
|
77
82
|
input: {
|
|
78
83
|
height: 0,
|
|
79
84
|
width: 0,
|
|
@@ -83,12 +88,12 @@ var useStyles = styles.createStyles((theme, {
|
|
|
83
88
|
opacity: 0,
|
|
84
89
|
"&:focus": {
|
|
85
90
|
outline: "none",
|
|
86
|
-
[`& + .${label
|
|
91
|
+
[`& + .${label}`]: {
|
|
87
92
|
outline: "none",
|
|
88
93
|
boxShadow: `0 0 0 2px ${theme.colorScheme === "dark" ? theme.colors.dark[9] : theme.white}, 0 0 0 4px ${theme.colors[theme.primaryColor][5]}`
|
|
89
94
|
},
|
|
90
95
|
"&:focus:not(:focus-visible)": {
|
|
91
|
-
[`& + .${label
|
|
96
|
+
[`& + .${label}`]: {
|
|
92
97
|
boxShadow: "none"
|
|
93
98
|
}
|
|
94
99
|
}
|
|
@@ -96,7 +101,9 @@ var useStyles = styles.createStyles((theme, {
|
|
|
96
101
|
},
|
|
97
102
|
root: {
|
|
98
103
|
position: "relative",
|
|
99
|
-
display: fullWidth ? "flex" : "inline-flex",
|
|
104
|
+
display: fullWidth || vertical ? "flex" : "inline-flex",
|
|
105
|
+
width: vertical && !fullWidth ? "max-content" : "inherit",
|
|
106
|
+
flexDirection: vertical ? "column" : "row",
|
|
100
107
|
backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[8] : theme.colors.gray[1],
|
|
101
108
|
borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),
|
|
102
109
|
overflow: "hidden",
|
|
@@ -104,8 +111,10 @@ var useStyles = styles.createStyles((theme, {
|
|
|
104
111
|
},
|
|
105
112
|
controlActive: {
|
|
106
113
|
borderLeftColor: "transparent !important",
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
borderTopColor: "transparent !important",
|
|
115
|
+
[`& + .${control}`]: {
|
|
116
|
+
borderLeftColor: "transparent !important",
|
|
117
|
+
borderTopColor: "transparent !important"
|
|
109
118
|
}
|
|
110
119
|
},
|
|
111
120
|
labelActive: {
|
|
@@ -113,12 +122,15 @@ var useStyles = styles.createStyles((theme, {
|
|
|
113
122
|
color: color in theme.colors || theme.colorScheme === "dark" ? theme.white : theme.black
|
|
114
123
|
}
|
|
115
124
|
},
|
|
125
|
+
disabled: {
|
|
126
|
+
"&, &:hover": {
|
|
127
|
+
color: theme.colorScheme === "dark" ? theme.colors.dark[3] : theme.colors.gray[5]
|
|
128
|
+
}
|
|
129
|
+
},
|
|
116
130
|
active: {
|
|
117
131
|
boxSizing: "border-box",
|
|
118
132
|
borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),
|
|
119
133
|
position: "absolute",
|
|
120
|
-
top: 4,
|
|
121
|
-
bottom: 4,
|
|
122
134
|
zIndex: 1,
|
|
123
135
|
boxShadow: color || theme.colorScheme === "dark" ? "none" : theme.shadows.xs,
|
|
124
136
|
transition: `transform ${shouldAnimate ? 0 : transitionDuration}ms ${theme.transitionTimingFunction}, width ${shouldAnimate ? 0 : transitionDuration / 2}ms ${transitionTimingFunction || theme.transitionTimingFunction}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.styles.js","sources":["../../../src/components/SegmentedControl/SegmentedControl.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize, MantineSize, MantineColor } from '@mantine/styles';\n\nexport const WRAPPER_PADDING = 4;\n\ninterface SegmentedControlStyles {\n fullWidth: boolean;\n color: MantineColor;\n radius: MantineNumberSize;\n shouldAnimate: boolean;\n transitionDuration: number;\n transitionTimingFunction: string;\n size: MantineSize;\n}\n\nconst sizes = {\n xs: '3px 6px',\n sm: '5px 10px',\n md: '7px 14px',\n lg: '9px 16px',\n xl: '12px 20px',\n};\n\nexport default createStyles(\n (\n theme,\n {\n fullWidth,\n color,\n radius,\n shouldAnimate,\n transitionDuration,\n transitionTimingFunction,\n size,\n }: SegmentedControlStyles,\n getRef\n ) => {\n const label = {\n ref: getRef('label'),\n ...theme.fn.focusStyles(),\n ...theme.fn.fontStyles(),\n WebkitTapHighlightColor: 'transparent',\n borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),\n fontWeight: 500,\n fontSize: size in theme.fontSizes ? theme.fontSizes[size] : theme.fontSizes.sm,\n cursor: 'pointer',\n display: 'block',\n textAlign: 'center',\n padding: sizes[size in sizes ? size : 'sm'],\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n color: theme.colorScheme === 'dark' ? theme.colors.dark[1] : theme.colors.gray[7],\n transition: `color ${shouldAnimate ? 0 : transitionDuration}ms ${\n transitionTimingFunction || theme.transitionTimingFunction\n }`,\n\n '&:hover': {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.black,\n },\n } as const;\n\n const control = {\n ref: getRef('control'),\n position: 'relative',\n boxSizing: 'border-box',\n flex: 1,\n zIndex: 2,\n transition: `border-left-color ${shouldAnimate ? 0 : transitionDuration}ms ${\n transitionTimingFunction || theme.transitionTimingFunction\n }`,\n\n '&:not(:first-of-type)': {\n borderLeft: `1px solid ${\n theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]\n }`,\n },\n } as const;\n\n return {\n label,\n control,\n\n input: {\n height: 0,\n width: 0,\n position: 'absolute',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n opacity: 0,\n\n // input is hidden by default, these styles add focus to label when user navigates with keyboard\n '&:focus': {\n outline: 'none',\n\n [`& + .${label.ref}`]: {\n outline: 'none',\n boxShadow: `0 0 0 2px ${\n theme.colorScheme === 'dark' ? theme.colors.dark[9] : theme.white\n }, 0 0 0 4px ${theme.colors[theme.primaryColor][5]}`,\n },\n\n '&:focus:not(:focus-visible)': {\n [`& + .${label.ref}`]: {\n boxShadow: 'none',\n },\n },\n },\n },\n\n root: {\n position: 'relative',\n display: fullWidth ? 'flex' : 'inline-flex',\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.colors.gray[1],\n borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),\n overflow: 'hidden',\n padding: WRAPPER_PADDING,\n },\n\n controlActive: {\n borderLeftColor: 'transparent !important',\n\n [`& + .${control.ref}`]: {\n borderLeftColor: 'transparent !important',\n },\n },\n\n labelActive: {\n '&, &:hover': {\n color: color in theme.colors || theme.colorScheme === 'dark' ? theme.white : theme.black,\n },\n },\n\n active: {\n boxSizing: 'border-box',\n borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),\n position: 'absolute',\n top: 4,\n bottom: 4,\n zIndex: 1,\n boxShadow: color || theme.colorScheme === 'dark' ? 'none' : theme.shadows.xs,\n transition: `transform ${shouldAnimate ? 0 : transitionDuration}ms ${\n theme.transitionTimingFunction\n }, width ${shouldAnimate ? 0 : transitionDuration / 2}ms ${\n transitionTimingFunction || theme.transitionTimingFunction\n }`,\n backgroundColor:\n color in theme.colors\n ? theme.fn.themeColor(color, 6)\n : theme.colorScheme === 'dark'\n ? theme.colors.dark[5]\n : theme.white,\n },\n };\n }\n);\n"],"names":["createStyles"],"mappings":";;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAA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"SegmentedControl.styles.js","sources":["../../../src/components/SegmentedControl/SegmentedControl.styles.ts"],"sourcesContent":["import { createStyles, MantineNumberSize, MantineSize, MantineColor } from '@mantine/styles';\n\nexport const WRAPPER_PADDING = 4;\n\ninterface SegmentedControlStyles {\n fullWidth: boolean;\n color: MantineColor;\n radius: MantineNumberSize;\n shouldAnimate: boolean;\n transitionDuration: number;\n transitionTimingFunction: string;\n size: MantineSize;\n orientation: 'vertical' | 'horizontal';\n}\n\nconst sizes = {\n xs: '3px 6px',\n sm: '5px 10px',\n md: '7px 14px',\n lg: '9px 16px',\n xl: '12px 20px',\n};\n\nexport default createStyles(\n (\n theme,\n {\n fullWidth,\n color,\n radius,\n shouldAnimate,\n transitionDuration,\n transitionTimingFunction,\n size,\n orientation,\n }: SegmentedControlStyles,\n getRef\n ) => {\n const label = getRef('label');\n const control = getRef('control');\n const vertical = orientation === 'vertical';\n\n return {\n label: {\n ref: label,\n ...theme.fn.focusStyles(),\n ...theme.fn.fontStyles(),\n WebkitTapHighlightColor: 'transparent',\n borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),\n fontWeight: 500,\n fontSize: size in theme.fontSizes ? theme.fontSizes[size] : theme.fontSizes.sm,\n cursor: 'pointer',\n display: 'block',\n textAlign: 'center',\n padding: sizes[size in sizes ? size : 'sm'],\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n userSelect: 'none',\n color: theme.colorScheme === 'dark' ? theme.colors.dark[1] : theme.colors.gray[7],\n transition: `color ${shouldAnimate ? 0 : transitionDuration}ms ${\n transitionTimingFunction || theme.transitionTimingFunction\n }`,\n\n '&:hover': {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[0] : theme.black,\n },\n },\n\n control: {\n ref: control,\n position: 'relative',\n boxSizing: 'border-box',\n flex: 1,\n zIndex: 2,\n transition: `border-left-color ${shouldAnimate ? 0 : transitionDuration}ms ${\n transitionTimingFunction || theme.transitionTimingFunction\n }`,\n\n '&:not(:first-of-type)': {\n borderStyle: 'solid',\n borderWidth: orientation === 'vertical' ? '1px 0 0 0' : '0 0 0 1px',\n borderColor: theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3],\n },\n },\n\n input: {\n height: 0,\n width: 0,\n position: 'absolute',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n opacity: 0,\n\n // input is hidden by default, these styles add focus to label when user navigates with keyboard\n '&:focus': {\n outline: 'none',\n\n [`& + .${label}`]: {\n outline: 'none',\n boxShadow: `0 0 0 2px ${\n theme.colorScheme === 'dark' ? theme.colors.dark[9] : theme.white\n }, 0 0 0 4px ${theme.colors[theme.primaryColor][5]}`,\n },\n\n '&:focus:not(:focus-visible)': {\n [`& + .${label}`]: {\n boxShadow: 'none',\n },\n },\n },\n },\n\n root: {\n position: 'relative',\n display: fullWidth || vertical ? 'flex' : 'inline-flex',\n width: vertical && !fullWidth ? 'max-content' : 'inherit',\n flexDirection: vertical ? 'column' : 'row',\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.colors.gray[1],\n borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),\n overflow: 'hidden',\n padding: WRAPPER_PADDING,\n },\n\n controlActive: {\n borderLeftColor: 'transparent !important',\n borderTopColor: 'transparent !important',\n\n [`& + .${control}`]: {\n borderLeftColor: 'transparent !important',\n borderTopColor: 'transparent !important',\n },\n },\n\n labelActive: {\n '&, &:hover': {\n color: color in theme.colors || theme.colorScheme === 'dark' ? theme.white : theme.black,\n },\n },\n\n disabled: {\n '&, &:hover': {\n color: theme.colorScheme === 'dark' ? theme.colors.dark[3] : theme.colors.gray[5],\n },\n },\n\n active: {\n boxSizing: 'border-box',\n borderRadius: theme.fn.size({ size: radius, sizes: theme.radius }),\n position: 'absolute',\n zIndex: 1,\n boxShadow: color || theme.colorScheme === 'dark' ? 'none' : theme.shadows.xs,\n transition: `transform ${shouldAnimate ? 0 : transitionDuration}ms ${\n theme.transitionTimingFunction\n }, width ${shouldAnimate ? 0 : transitionDuration / 2}ms ${\n transitionTimingFunction || theme.transitionTimingFunction\n }`,\n backgroundColor:\n color in theme.colors\n ? theme.fn.themeColor(color, 6)\n : theme.colorScheme === 'dark'\n ? theme.colors.dark[5]\n : theme.white,\n },\n };\n }\n);\n"],"names":["createStyles"],"mappings":";;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI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AAO;AACP,KAAK;AACL,IAAI,MAAM,EAAE;AACZ,MAAM,SAAS,EAAE,YAAY;AAC7B,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AACxE,MAAM,QAAQ,EAAE,UAAU;AAC1B,MAAM,MAAM,EAAE,CAAC;AACf,MAAM,SAAS,EAAE,KAAK,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE;AAClF,MAAM,UAAU,EAAE,CAAC,UAAU,EAAE,aAAa,GAAG,CAAC,GAAG,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,wBAAwB,CAAC,QAAQ,EAAE,aAAa,GAAG,CAAC,GAAG,kBAAkB,GAAG,CAAC,CAAC,GAAG,EAAE,wBAAwB,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAChO,MAAM,eAAe,EAAE,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,KAAK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK;AAChJ,KAAK;AACL,GAAG,CAAC;AACJ,CAAC,CAAC;;;;;"}
|
|
@@ -357,6 +357,7 @@ const Select = React.forwardRef((_a, ref) => {
|
|
|
357
357
|
typeof onFocus === "function" && onFocus(event);
|
|
358
358
|
if (searchable) {
|
|
359
359
|
setDropdownOpened(true);
|
|
360
|
+
scrollSelectedItemIntoView();
|
|
360
361
|
}
|
|
361
362
|
};
|
|
362
363
|
const handleInputChange = (event) => {
|
|
@@ -368,12 +369,12 @@ const Select = React.forwardRef((_a, ref) => {
|
|
|
368
369
|
setDropdownOpened(true);
|
|
369
370
|
};
|
|
370
371
|
const handleInputClick = () => {
|
|
372
|
+
let dropdownOpen = true;
|
|
371
373
|
if (!searchable) {
|
|
372
|
-
|
|
373
|
-
} else {
|
|
374
|
-
setDropdownOpened(true);
|
|
374
|
+
dropdownOpen = !dropdownOpened;
|
|
375
375
|
}
|
|
376
|
-
|
|
376
|
+
setDropdownOpened(dropdownOpen);
|
|
377
|
+
if (_value && dropdownOpen) {
|
|
377
378
|
setHovered(selectedItemIndex);
|
|
378
379
|
scrollSelectedItemIntoView();
|
|
379
380
|
}
|